Added dist files

This commit is contained in:
2018-05-22 16:10:33 +02:00
parent dcb055a1e0
commit 35cb83f30b
31 changed files with 248 additions and 5 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
dist/
# ---> Node
# Logs
logs

8
dist/adapters/PortResolver.d.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
import { IPortResolver } from '../domain/ports/IPortResolver';
export declare class PortResolver implements IPortResolver {
private _container;
constructor();
register<T>(name: string, fn: () => T): void;
registerInstance<T>(name: string, fn: () => T): void;
resolve<T>(name: string): T;
}

31
dist/adapters/PortResolver.js vendored Normal file
View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PortResolver = /** @class */ (function () {
function PortResolver() {
this._container = {};
}
PortResolver.prototype.register = function (name, fn) {
this._container[name] = fn;
};
PortResolver.prototype.registerInstance = function (name, fn) {
var _instance = null;
var getInstance = function (fn) {
return function () {
if (!_instance) {
_instance = fn();
}
return _instance;
};
};
this._container[name] = getInstance(fn);
};
PortResolver.prototype.resolve = function (name) {
if (name in this._container && typeof this._container[name] == 'function') {
return this._container[name]();
}
throw new Error('PortResolver can not resolve ' + name);
};
return PortResolver;
}());
exports.PortResolver = PortResolver;
//# sourceMappingURL=PortResolver.js.map

1
dist/adapters/PortResolver.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"PortResolver.js","sourceRoot":"","sources":["../../src/adapters/PortResolver.ts"],"names":[],"mappings":";;AAIA;IAEI;QADQ,eAAU,GAAS,EAAE,CAAC;IAG9B,CAAC;IACD,+BAAQ,GAAR,UAAY,IAAa,EAAE,EAAY;QACnC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IAC/B,CAAC;IACD,uCAAgB,GAAhB,UAAoB,IAAc,EAAE,EAAY;QAC5C,IAAI,SAAS,GAAS,IAAI,CAAC;QAC3B,IAAI,WAAW,GAAG,UAAC,EAAa;YAC5B,OAAO;gBACH,IAAI,CAAC,SAAS,EAAE;oBACZ,SAAS,GAAG,EAAE,EAAE,CAAC;iBACpB;gBACD,OAAO,SAAS,CAAC;YACrB,CAAC,CAAC;QACN,CAAC,CAAC;QACF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;IACD,8BAAO,GAAP,UAAW,IAAa;QACpB,IAAI,IAAI,IAAI,IAAI,CAAC,UAAU,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,EAAE;YACvE,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;SAClC;QACD,MAAM,IAAI,KAAK,CAAC,+BAA+B,GAAE,IAAI,CAAC,CAAC;IAC3D,CAAC;IACL,mBAAC;AAAD,CAAC,AA1BD,IA0BC;AA1BY,oCAAY"}

10
dist/adapters/music/VinylCatalog.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
import { Track } from "../../domain/models/Track";
import { IMusicRepository } from "../../domain/ports/IMusicRepository";
export declare class VinylCatalog implements IMusicRepository {
private vinylList;
get(): Track[];
getById(id: number): Track;
add(track: Track): number;
edit(id: number, track: Track): Track;
delete(id: number): Track;
}

40
dist/adapters/music/VinylCatalog.js vendored Normal file
View File

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Track_1 = require("../../domain/models/Track");
var VinylCatalog = /** @class */ (function () {
function VinylCatalog() {
this.vinylList = new Array(new Track_1.Track(1, "DNA.", "Kendrick Lamar", 340), new Track_1.Track(2, "Come Down", "Anderson Paak.", 430), new Track_1.Track(3, "DNA.", "Kendrick Lamar", 340), new Track_1.Track(4, "DNA.", "Kendrick Lamar", 340), new Track_1.Track(5, "DNA.", "Kendrick Lamar", 340));
}
VinylCatalog.prototype.get = function () {
return this.vinylList;
};
VinylCatalog.prototype.getById = function (id) {
return this.vinylList.filter(function (track) { return track.id == id; }).pop();
};
VinylCatalog.prototype.add = function (track) {
return this.vinylList.push(track);
};
VinylCatalog.prototype.edit = function (id, track) {
var existingTrack = this.getById(id);
if (existingTrack) {
existingTrack.artist = track.artist;
existingTrack.title = track.title;
existingTrack.duration = track.duration;
return existingTrack;
}
throw new Error("Track not found");
};
VinylCatalog.prototype.delete = function (id) {
var track = this.getById(id);
if (track) {
var targetIndex = this.vinylList.indexOf(track);
if (targetIndex < -1)
return null;
return this.vinylList.splice(targetIndex, 1)[0];
}
return null;
};
return VinylCatalog;
}());
exports.VinylCatalog = VinylCatalog;
//# sourceMappingURL=VinylCatalog.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"VinylCatalog.js","sourceRoot":"","sources":["../../../src/adapters/music/VinylCatalog.ts"],"names":[],"mappings":";;AAAA,mDAAkD;AAGlD;IAAA;QAEY,cAAS,GAAY,IAAI,KAAK,CAClC,IAAI,aAAK,CAAC,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAC3C,IAAI,aAAK,CAAC,CAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAChD,IAAI,aAAK,CAAC,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAC3C,IAAI,aAAK,CAAC,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAC3C,IAAI,aAAK,CAAC,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,CAAC,CAC9C,CAAC;IA8BN,CAAC;IA5BG,0BAAG,GAAH;QACI,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IACD,8BAAO,GAAP,UAAQ,EAAU;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,EAAE,IAAI,EAAE,EAAd,CAAc,CAAC,CAAC,GAAG,EAAE,CAAC;IAChE,CAAC;IACD,0BAAG,GAAH,UAAI,KAAY;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,2BAAI,GAAJ,UAAK,EAAU,EAAE,KAAY;QACzB,IAAI,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACrC,IAAI,aAAa,EAAE;YACf,aAAa,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YACpC,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YAClC,aAAa,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;YACxC,OAAO,aAAa,CAAC;SACxB;QACD,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IACD,6BAAM,GAAN,UAAO,EAAU;QACb,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC7B,IAAI,KAAK,EAAE;YACP,IAAI,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAChD,IAAI,WAAW,GAAG,CAAC,CAAC;gBAAE,OAAO,IAAI,CAAC;YAClC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACnD;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IACL,mBAAC;AAAD,CAAC,AAtCD,IAsCC;AAtCY,oCAAY"}

7
dist/domain/models/Track.d.ts vendored Normal file
View File

@@ -0,0 +1,7 @@
export declare class Track {
constructor(id: number, title: string, artist: string, duration: number);
id: number;
title: string;
artist: string;
duration: number;
}

13
dist/domain/models/Track.js vendored Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Track = /** @class */ (function () {
function Track(id, title, artist, duration) {
this.id = id;
this.title = title;
this.artist = artist;
this.duration = duration;
}
return Track;
}());
exports.Track = Track;
//# sourceMappingURL=Track.js.map

1
dist/domain/models/Track.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Track.js","sourceRoot":"","sources":["../../../src/domain/models/Track.ts"],"names":[],"mappings":";;AACA;IACI,eAAY,EAAU,EAAE,KAAa,EAAE,MAAc,EAAE,QAAe;QAClE,IAAI,CAAC,EAAE,GAAE,EAAE,CAAC;QACZ,IAAI,CAAC,KAAK,GAAE,KAAK,CAAC;QAClB,IAAI,CAAC,MAAM,GAAE,MAAM,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAE,QAAQ,CAAC;IAC5B,CAAC;IAML,YAAC;AAAD,CAAC,AAZD,IAYC;AAZY,sBAAK"}

View File

@@ -0,0 +1,8 @@
import { Track } from "../models/Track";
export interface IMusicRepository {
get(): Track[];
getById(id: number): Track;
add(track: Track): number;
edit(id: number, track: Track): Track;
delete(id: number): Track;
}

3
dist/domain/ports/IMusicRepository.js vendored Normal file
View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IMusicRepository.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"IMusicRepository.js","sourceRoot":"","sources":["../../../src/domain/ports/IMusicRepository.ts"],"names":[],"mappings":""}

5
dist/domain/ports/IPortResolver.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
export interface IPortResolver {
resolve<T>(name: string): T;
}
export declare let currentPortResolver: IPortResolver;
export declare let setCurrentPortResolver: (resolver: IPortResolver) => IPortResolver;

4
dist/domain/ports/IPortResolver.js vendored Normal file
View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setCurrentPortResolver = function (resolver) { return exports.currentPortResolver = resolver; };
//# sourceMappingURL=IPortResolver.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"IPortResolver.js","sourceRoot":"","sources":["../../../src/domain/ports/IPortResolver.ts"],"names":[],"mappings":";;AAOW,QAAA,sBAAsB,GAAG,UAAC,QAAwB,IAAK,OAAA,2BAAmB,GAAG,QAAQ,EAA9B,CAA8B,CAAC"}

5
dist/domain/services/BaseService.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
import { IPortResolver } from '../ports/IPortResolver';
export declare class BaseService {
protected PortResolver: IPortResolver;
constructor();
}

11
dist/domain/services/BaseService.js vendored Normal file
View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var IPortResolver_1 = require("../ports/IPortResolver");
var BaseService = /** @class */ (function () {
function BaseService() {
this.PortResolver = IPortResolver_1.currentPortResolver;
}
return BaseService;
}());
exports.BaseService = BaseService;
//# sourceMappingURL=BaseService.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BaseService.js","sourceRoot":"","sources":["../../../src/domain/services/BaseService.ts"],"names":[],"mappings":";;AACA,wDAA4E;AAE5E;IAEI;QACI,IAAI,CAAC,YAAY,GAAG,mCAAmB,CAAC;IAC5C,CAAC;IACL,kBAAC;AAAD,CAAC,AALD,IAKC;AALY,kCAAW"}

View File

@@ -0,0 +1,11 @@
import { BaseService } from './BaseService';
import { Track } from "../../domain/models/Track";
export declare class MusicCatalogService extends BaseService {
private repository;
constructor();
get(): Track[];
getById(id: number): Track | null;
add(track: Track): number;
edit(id: number, track: Track): Track;
delete(id: number): Track | null;
}

View File

@@ -0,0 +1,39 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var BaseService_1 = require("./BaseService");
var MusicCatalogService = /** @class */ (function (_super) {
__extends(MusicCatalogService, _super);
function MusicCatalogService() {
var _this = _super.call(this) || this;
_this.repository = _this.PortResolver.resolve('IMusicRepository');
return _this;
}
MusicCatalogService.prototype.get = function () {
return this.repository.get();
};
MusicCatalogService.prototype.getById = function (id) {
return this.repository.getById(id);
};
MusicCatalogService.prototype.add = function (track) {
return this.repository.add(track);
};
MusicCatalogService.prototype.edit = function (id, track) {
return this.repository.edit(id, track);
};
MusicCatalogService.prototype.delete = function (id) {
return this.repository.delete(id);
};
return MusicCatalogService;
}(BaseService_1.BaseService));
exports.MusicCatalogService = MusicCatalogService;
//# sourceMappingURL=MusicCatalogService.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MusicCatalogService.js","sourceRoot":"","sources":["../../../src/domain/services/MusicCatalogService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAK5C;IAAyC,uCAAW;IAGhD;QAAA,YACI,iBAAO,SAEV;QADG,KAAI,CAAC,UAAU,GAAG,KAAI,CAAC,YAAY,CAAC,OAAO,CAAmB,kBAAkB,CAAC,CAAC;;IACtF,CAAC;IACD,iCAAG,GAAH;QACI,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;IACjC,CAAC;IACD,qCAAO,GAAP,UAAQ,EAAU;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,iCAAG,GAAH,UAAI,KAAY;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,kCAAI,GAAJ,UAAK,EAAU,EAAE,KAAY;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IACD,oCAAM,GAAN,UAAO,EAAU;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC;IACL,0BAAC;AAAD,CAAC,AAtBD,CAAyC,yBAAW,GAsBnD;AAtBY,kDAAmB"}

3
dist/index.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
import { MusicCatalogService } from './domain/services/MusicCatalogService';
import { Track } from './domain/models/Track';
export { MusicCatalogService, Track };

11
dist/index.js vendored Normal file
View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Wiring_1 = require("./wiring/Wiring");
var MusicCatalogService_1 = require("./domain/services/MusicCatalogService");
exports.MusicCatalogService = MusicCatalogService_1.MusicCatalogService;
var Track_1 = require("./domain/models/Track");
exports.Track = Track_1.Track;
var wiring = new Wiring_1.Wiring();
wiring.apply();
// MusicRepository
//# sourceMappingURL=index.js.map

1
dist/index.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,0CAAyC;AACzC,6EAA4E;AAMnE,8BANA,yCAAmB,CAMA;AAL5B,+CAA8C;AAKhB,gBALrB,aAAK,CAKqB;AAHnC,IAAM,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;AAC5B,MAAM,CAAC,KAAK,EAAE,CAAC;AAIf,kBAAkB"}

3
dist/wiring/Wiring.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare class Wiring {
apply(): void;
}

17
dist/wiring/Wiring.js vendored Normal file
View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var IPortResolver_1 = require("../domain/ports/IPortResolver");
var PortResolver_1 = require("../adapters/PortResolver");
var VinylCatalog_1 = require("../adapters/music/VinylCatalog");
var Wiring = /** @class */ (function () {
function Wiring() {
}
Wiring.prototype.apply = function () {
var portResolver = new PortResolver_1.PortResolver();
portResolver.register('IMusicRepository', function () { return new VinylCatalog_1.VinylCatalog(); });
IPortResolver_1.setCurrentPortResolver(portResolver);
};
return Wiring;
}());
exports.Wiring = Wiring;
//# sourceMappingURL=Wiring.js.map

1
dist/wiring/Wiring.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Wiring.js","sourceRoot":"","sources":["../../src/wiring/Wiring.ts"],"names":[],"mappings":";;AAAA,+DAAsF;AACtF,yDAAwD;AACxD,+DAA8D;AAG9D;IAAA;IAOA,CAAC;IANU,sBAAK,GAAZ;QACI,IAAM,YAAY,GAAG,IAAI,2BAAY,EAAE,CAAC;QACxC,YAAY,CAAC,QAAQ,CAAmB,kBAAkB,EAAE,cAAM,OAAA,IAAI,2BAAY,EAAE,EAAlB,CAAkB,CAAC,CAAC;QAEtF,sCAAsB,CAAC,YAAY,CAAC,CAAC;IACzC,CAAC;IACL,aAAC;AAAD,CAAC,AAPD,IAOC;AAPY,wBAAM"}

View File

@@ -2,8 +2,8 @@
"name": "@nx/typescript-starter",
"version": "1.0.0",
"description": "Starter project for a typescript app",
"main": "dist/bundle.js",
"types": "dist/bundle.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc --listEmittedFiles --project tsconfig-app.json",
"test": "karma start karma.conf.js -sm=false",

View File

@@ -1,3 +1,10 @@
import { Wiring } from './wiring/Wiring';
import { MusicCatalogService } from './domain/services/MusicCatalogService';
import { Track } from './domain/models/Track';
const wiring = new Wiring();
wiring.apply();
export { MusicCatalogService, Track };
// MusicRepository

View File

@@ -1,8 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "amd",
"outFile": "./dist/bundle.js"
},
"files": [
"./src/index.ts"