@loopback/boot 2.1.1 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/dist/.sandbox/{11889PRvhvm → 635411GGsm1}/model-endpoints/no-entity.rest-config.js +0 -0
- package/dist/.sandbox/635411GGsm1/models/no-entity.model.js +28 -0
- package/dist/.sandbox/{11889wtTpPA → 635415cxfJi}/service-provider.artifact.js +1 -0
- package/dist/.sandbox/{118893KtxoA → 635419mu8mo}/application.js +1 -0
- package/dist/.sandbox/{11889S6GDvS → 635419mu8mo}/services/bindable-classes.service.js +26 -19
- package/dist/.sandbox/{11889S6GDvS → 635419mu8mo}/services/geocoder.service.js +1 -0
- package/dist/.sandbox/{11889S6GDvS → 635419mu8mo}/services/greeting.service.js +1 -0
- package/dist/.sandbox/{11889K8KL2J → 635419t6TqH}/datasource.artifact.js +9 -5
- package/dist/.sandbox/63541BtDxTa/multiple.artifact.js +45 -0
- package/dist/.sandbox/{11889CQQ0nI → 63541DlS0Ic}/application.js +1 -0
- package/dist/.sandbox/63541DlS0Ic/repositories/multiple.repository.js +45 -0
- package/dist/.sandbox/{118896Rj4ze → 63541DshyBF}/application.js +1 -0
- package/dist/.sandbox/{118893KtxoA → 63541DshyBF}/observers/lifecycle-observer.observer.js +1 -0
- package/dist/.sandbox/{11889DQbyT8 → 63541IEce5V}/application.js +1 -0
- package/dist/.sandbox/{11889zAsxZb → 63541IEce5V}/datasources/db.datasource.js +9 -5
- package/dist/.sandbox/63541ik89oh/application.js +20 -0
- package/dist/.sandbox/63541ik89oh/models/multiple-models.model.js +16 -0
- package/dist/.sandbox/63541ik89oh/models/no-entity.model.js +28 -0
- package/dist/.sandbox/63541ik89oh/models/product.model.js +28 -0
- package/dist/.sandbox/63541meTxP7/application.js +20 -0
- package/dist/.sandbox/63541meTxP7/controllers/multiple.controller.js +45 -0
- package/dist/.sandbox/{11889DQbyT8 → 63541meTxP7}/package.json +0 -0
- package/dist/.sandbox/63541nGmQFL/application.js +20 -0
- package/dist/.sandbox/63541nGmQFL/controllers/multiple.controller.js +45 -0
- package/dist/.sandbox/{11889mdaOd9 → 63541odlHvc}/model-endpoints/product.rest-config.js +0 -0
- package/dist/.sandbox/63541odlHvc/models/product.model.js +28 -0
- package/dist/.sandbox/63541ruUDNf/application.js +20 -0
- package/dist/.sandbox/63541ruUDNf/interceptors/interceptor.interceptor.js +54 -0
- package/dist/.sandbox/63541ruUDNf/interceptors/non-global-interceptor.interceptor.js +54 -0
- package/dist/.sandbox/63541vSi6af/multiple.artifact.js +45 -0
- package/dist/.sandbox/application.js +20 -0
- package/dist/.sandbox/controllers/multiple.controller.js +45 -0
- package/dist/boot.component.d.ts +2 -2
- package/dist/boot.component.js +34 -29
- package/dist/boot.component.js.map +1 -1
- package/dist/booters/application-metadata.booter.js +23 -19
- package/dist/booters/application-metadata.booter.js.map +1 -1
- package/dist/booters/base-artifact.booter.js +1 -0
- package/dist/booters/base-artifact.booter.js.map +1 -1
- package/dist/booters/booter-utils.js +1 -0
- package/dist/booters/booter-utils.js.map +1 -1
- package/dist/booters/component-application.booter.d.ts +25 -0
- package/dist/booters/component-application.booter.js +99 -0
- package/dist/booters/component-application.booter.js.map +1 -0
- package/dist/booters/controller.booter.js +30 -26
- package/dist/booters/controller.booter.js.map +1 -1
- package/dist/booters/datasource.booter.d.ts +1 -1
- package/dist/booters/datasource.booter.js +40 -36
- package/dist/booters/datasource.booter.js.map +1 -1
- package/dist/booters/index.d.ts +2 -0
- package/dist/booters/index.js +2 -0
- package/dist/booters/index.js.map +1 -1
- package/dist/booters/interceptor.booter.js +32 -31
- package/dist/booters/interceptor.booter.js.map +1 -1
- package/dist/booters/lifecyle-observer.booter.js +32 -28
- package/dist/booters/lifecyle-observer.booter.js.map +1 -1
- package/dist/booters/model-api.booter.js +67 -63
- package/dist/booters/model-api.booter.js.map +1 -1
- package/dist/booters/model.booter.d.ts +26 -0
- package/dist/booters/model.booter.js +74 -0
- package/dist/booters/model.booter.js.map +1 -0
- package/dist/booters/repository.booter.js +39 -35
- package/dist/booters/repository.booter.js.map +1 -1
- package/dist/booters/service.booter.d.ts +1 -1
- package/dist/booters/service.booter.js +34 -30
- package/dist/booters/service.booter.js.map +1 -1
- package/dist/bootstrapper.js +85 -81
- package/dist/bootstrapper.js.map +1 -1
- package/dist/keys.js +1 -0
- package/dist/keys.js.map +1 -1
- package/dist/mixins/boot.mixin.d.ts +84 -15
- package/dist/mixins/boot.mixin.js +40 -20
- package/dist/mixins/boot.mixin.js.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +17 -17
- package/src/boot.component.ts +2 -0
- package/src/booters/component-application.booter.ts +123 -0
- package/src/booters/datasource.booter.ts +1 -1
- package/src/booters/index.ts +2 -0
- package/src/booters/interceptor.booter.ts +1 -6
- package/src/booters/model.booter.ts +76 -0
- package/src/booters/service.booter.ts +1 -1
- package/src/mixins/boot.mixin.ts +84 -20
- package/dist/.sandbox/118896Rj4ze/repositories/multiple.repository.js +0 -38
- package/dist/.sandbox/11889CQQ0nI/controllers/multiple.controller.js +0 -38
- package/dist/.sandbox/11889DQbyT8/controllers/multiple.controller.js +0 -38
- package/dist/.sandbox/11889PRvhvm/models/no-entity.model.js +0 -24
- package/dist/.sandbox/11889S6GDvS/application.js +0 -19
- package/dist/.sandbox/11889SgiPny/multiple.artifact.js +0 -38
- package/dist/.sandbox/11889SuGYhr/application.js +0 -19
- package/dist/.sandbox/11889SuGYhr/interceptors/interceptor.interceptor.js +0 -50
- package/dist/.sandbox/11889SuGYhr/interceptors/non-global-interceptor.interceptor.js +0 -50
- package/dist/.sandbox/11889mdaOd9/models/product.model.js +0 -24
- package/dist/.sandbox/11889t5aVl4/multiple.artifact.js +0 -38
- package/dist/.sandbox/11889zAsxZb/application.js +0 -19
- package/dist/.sandbox/dist/application.js +0 -19
- package/index.d.ts +0 -6
- package/index.js +0 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.booter.js","sourceRoot":"","sources":["../../src/booters/controller.booter.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"controller.booter.js","sourceRoot":"","sources":["../../src/booters/controller.booter.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,+CAAiD;AACjD,yCAAyD;AACzD,kCAAqC;AACrC,oCAAiD;AACjD,iEAA0D;AAE1D;;;;;;;;;GASG;AAEH;IAAA,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,yCAAkB;QACtD,YACoD,GAAgB,EAC/B,WAAmB,EAE/C,mBAAoC,EAAE;YAE7C,KAAK,CACH,WAAW;YACX,4DAA4D;YAC5D,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,0BAAkB,EAAE,gBAAgB,CAAC,CACxD,CAAC;YATgD,QAAG,GAAH,GAAG,CAAa;YAG3D,qBAAgB,GAAhB,gBAAgB,CAAsB;QAO/C,CAAC;QAED;;;WAGG;QACH,KAAK,CAAC,IAAI;YACR,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACzB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAA;IAxBY,gBAAgB;QAD5B,cAAM,CAAC,aAAa,CAAC;QAGjB,mBAAA,gBAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;QACzC,mBAAA,gBAAM,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAA;QACjC,mBAAA,gBAAM,EAAE,CAAA;iDAF8C,kBAAW;OAFzD,gBAAgB,CAwB5B;IAAD,uBAAC;KAAA;AAxBY,4CAAgB;AA0B7B;;GAEG;AACU,QAAA,kBAAkB,GAAoB;IACjD,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,UAAU,EAAE,CAAC,gBAAgB,CAAC;IAC9B,MAAM,EAAE,IAAI;CACb,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { ArtifactOptions } from '../types';
|
|
|
3
3
|
import { BaseArtifactBooter } from './base-artifact.booter';
|
|
4
4
|
/**
|
|
5
5
|
* A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
|
|
6
|
-
* Discovered DataSources are bound using `app.
|
|
6
|
+
* Discovered DataSources are bound using `app.dataSource()`.
|
|
7
7
|
*
|
|
8
8
|
* Supported phases: configure, discover, load
|
|
9
9
|
*
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DataSourceDefaults = exports.DataSourceBooter = void 0;
|
|
7
8
|
const tslib_1 = require("tslib");
|
|
8
9
|
const context_1 = require("@loopback/context");
|
|
9
10
|
const core_1 = require("@loopback/core");
|
|
@@ -12,7 +13,7 @@ const types_1 = require("../types");
|
|
|
12
13
|
const base_artifact_booter_1 = require("./base-artifact.booter");
|
|
13
14
|
/**
|
|
14
15
|
* A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
|
|
15
|
-
* Discovered DataSources are bound using `app.
|
|
16
|
+
* Discovered DataSources are bound using `app.dataSource()`.
|
|
16
17
|
*
|
|
17
18
|
* Supported phases: configure, discover, load
|
|
18
19
|
*
|
|
@@ -20,45 +21,48 @@ const base_artifact_booter_1 = require("./base-artifact.booter");
|
|
|
20
21
|
* @param projectRoot - Root of User Project relative to which all paths are resolved
|
|
21
22
|
* @param bootConfig - DataSource Artifact Options Object
|
|
22
23
|
*/
|
|
23
|
-
let DataSourceBooter = class
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* Uses super method to get a list of Artifact classes. Boot each file by
|
|
33
|
-
* creating a DataSourceConstructor and binding it to the application class.
|
|
34
|
-
*/
|
|
35
|
-
async load() {
|
|
36
|
-
await super.load();
|
|
24
|
+
let DataSourceBooter = /** @class */ (() => {
|
|
25
|
+
let DataSourceBooter = class DataSourceBooter extends base_artifact_booter_1.BaseArtifactBooter {
|
|
26
|
+
constructor(app, projectRoot, datasourceConfig = {}) {
|
|
27
|
+
super(projectRoot,
|
|
28
|
+
// Set DataSource Booter Options if passed in via bootConfig
|
|
29
|
+
Object.assign({}, exports.DataSourceDefaults, datasourceConfig));
|
|
30
|
+
this.app = app;
|
|
31
|
+
this.datasourceConfig = datasourceConfig;
|
|
32
|
+
}
|
|
37
33
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* DataSource Class.
|
|
34
|
+
* Uses super method to get a list of Artifact classes. Boot each file by
|
|
35
|
+
* creating a DataSourceConstructor and binding it to the application class.
|
|
41
36
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
async load() {
|
|
38
|
+
await super.load();
|
|
39
|
+
/**
|
|
40
|
+
* If DataSource Classes were discovered, we need to make sure RepositoryMixin
|
|
41
|
+
* was used (so we have `app.dataSource()`) to perform the binding of a
|
|
42
|
+
* DataSource Class.
|
|
43
|
+
*/
|
|
44
|
+
if (this.classes.length > 0) {
|
|
45
|
+
if (!this.app.dataSource) {
|
|
46
|
+
console.warn('app.dataSource() function is needed for DataSourceBooter. You can add ' +
|
|
47
|
+
'it to your Application using RepositoryMixin from @loopback/repository.');
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.classes.forEach(cls => {
|
|
51
|
+
this.app.dataSource(cls);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
};
|
|
57
|
+
DataSourceBooter = tslib_1.__decorate([
|
|
58
|
+
types_1.booter('datasources'),
|
|
59
|
+
tslib_1.__param(0, context_1.inject(core_1.CoreBindings.APPLICATION_INSTANCE)),
|
|
60
|
+
tslib_1.__param(1, context_1.inject(keys_1.BootBindings.PROJECT_ROOT)),
|
|
61
|
+
tslib_1.__param(2, context_1.config()),
|
|
62
|
+
tslib_1.__metadata("design:paramtypes", [Object, String, Object])
|
|
63
|
+
], DataSourceBooter);
|
|
64
|
+
return DataSourceBooter;
|
|
65
|
+
})();
|
|
62
66
|
exports.DataSourceBooter = DataSourceBooter;
|
|
63
67
|
/**
|
|
64
68
|
* Default ArtifactOptions for DataSourceBooter.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasource.booter.js","sourceRoot":"","sources":["../../src/booters/datasource.booter.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"datasource.booter.js","sourceRoot":"","sources":["../../src/booters/datasource.booter.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,+CAAiD;AACjD,yCAA4C;AAM5C,kCAAqC;AACrC,oCAAiD;AACjD,iEAA0D;AAE1D;;;;;;;;;GASG;AAEH;IAAA,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,yCAAkB;QACtD,YAES,GAAgC,EACJ,WAAmB,EAE/C,mBAAoC,EAAE;YAE7C,KAAK,CACH,WAAW;YACX,4DAA4D;YAC5D,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,0BAAkB,EAAE,gBAAgB,CAAC,CACxD,CAAC;YATK,QAAG,GAAH,GAAG,CAA6B;YAGhC,qBAAgB,GAAhB,gBAAgB,CAAsB;QAO/C,CAAC;QAED;;;WAGG;QACH,KAAK,CAAC,IAAI;YACR,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;YAEnB;;;;eAIG;YACH,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE;oBACxB,OAAO,CAAC,IAAI,CACV,wEAAwE;wBACtE,yEAAyE,CAC5E,CAAC;iBACH;qBAAM;oBACL,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;wBACzB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAgC,CAAC,CAAC;oBACxD,CAAC,CAAC,CAAC;iBACJ;aACF;QACH,CAAC;KACF,CAAA;IAxCY,gBAAgB;QAD5B,cAAM,CAAC,aAAa,CAAC;QAGjB,mBAAA,gBAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;QAEzC,mBAAA,gBAAM,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAA;QACjC,mBAAA,gBAAM,EAAE,CAAA;;OALA,gBAAgB,CAwC5B;IAAD,uBAAC;KAAA;AAxCY,4CAAgB;AA0C7B;;GAEG;AACU,QAAA,kBAAkB,GAAoB;IACjD,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,UAAU,EAAE,CAAC,gBAAgB,CAAC;IAC9B,MAAM,EAAE,IAAI;CACb,CAAC"}
|
package/dist/booters/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export * from './application-metadata.booter';
|
|
2
2
|
export * from './base-artifact.booter';
|
|
3
3
|
export * from './booter-utils';
|
|
4
|
+
export * from './component-application.booter';
|
|
4
5
|
export * from './controller.booter';
|
|
5
6
|
export * from './datasource.booter';
|
|
6
7
|
export * from './interceptor.booter';
|
|
7
8
|
export * from './lifecyle-observer.booter';
|
|
8
9
|
export * from './model-api.booter';
|
|
10
|
+
export * from './model.booter';
|
|
9
11
|
export * from './repository.booter';
|
|
10
12
|
export * from './service.booter';
|
package/dist/booters/index.js
CHANGED
|
@@ -8,11 +8,13 @@ const tslib_1 = require("tslib");
|
|
|
8
8
|
tslib_1.__exportStar(require("./application-metadata.booter"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./base-artifact.booter"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./booter-utils"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./component-application.booter"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./controller.booter"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./datasource.booter"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./interceptor.booter"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./lifecyle-observer.booter"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./model-api.booter"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./model.booter"), exports);
|
|
16
18
|
tslib_1.__exportStar(require("./repository.booter"), exports);
|
|
17
19
|
tslib_1.__exportStar(require("./service.booter"), exports);
|
|
18
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/booters/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;AAEhE,wEAA8C;AAC9C,iEAAuC;AACvC,yDAA+B;AAC/B,8DAAoC;AACpC,8DAAoC;AACpC,+DAAqC;AACrC,qEAA2C;AAC3C,6DAAmC;AACnC,8DAAoC;AACpC,2DAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/booters/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;AAEhE,wEAA8C;AAC9C,iEAAuC;AACvC,yDAA+B;AAC/B,yEAA+C;AAC/C,8DAAoC;AACpC,8DAAoC;AACpC,+DAAqC;AACrC,qEAA2C;AAC3C,6DAAmC;AACnC,yDAA+B;AAC/B,8DAAoC;AACpC,2DAAiC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.InterceptorProviderDefaults = exports.InterceptorProviderBooter = void 0;
|
|
7
8
|
const tslib_1 = require("tslib");
|
|
8
9
|
const context_1 = require("@loopback/context");
|
|
9
10
|
const core_1 = require("@loopback/core");
|
|
@@ -21,38 +22,38 @@ const debug = debug_1.default('loopback:boot:interceptor-booter');
|
|
|
21
22
|
* @param projectRoot - Root of User Project relative to which all paths are resolved
|
|
22
23
|
* @param bootConfig - InterceptorProvider Artifact Options Object
|
|
23
24
|
*/
|
|
24
|
-
let InterceptorProviderBooter = class
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Uses super method to get a list of Artifact classes. Boot each file by
|
|
34
|
-
* creating a DataSourceConstructor and binding it to the application class.
|
|
35
|
-
*/
|
|
36
|
-
async load() {
|
|
37
|
-
await super.load();
|
|
38
|
-
this.interceptors = this.classes;
|
|
39
|
-
for (const interceptor of this.interceptors) {
|
|
40
|
-
debug('Bind interceptor: %s', interceptor.name);
|
|
41
|
-
const binding = context_1.createBindingFromClass(interceptor, {
|
|
42
|
-
defaultScope: context_1.BindingScope.TRANSIENT,
|
|
43
|
-
});
|
|
44
|
-
this.app.add(binding);
|
|
45
|
-
debug('Binding created for interceptor: %j', binding);
|
|
25
|
+
let InterceptorProviderBooter = /** @class */ (() => {
|
|
26
|
+
let InterceptorProviderBooter = class InterceptorProviderBooter extends base_artifact_booter_1.BaseArtifactBooter {
|
|
27
|
+
constructor(app, projectRoot, interceptorConfig = {}) {
|
|
28
|
+
super(projectRoot,
|
|
29
|
+
// Set InterceptorProvider Booter Options if passed in via bootConfig
|
|
30
|
+
Object.assign({}, exports.InterceptorProviderDefaults, interceptorConfig));
|
|
31
|
+
this.app = app;
|
|
32
|
+
this.interceptorConfig = interceptorConfig;
|
|
46
33
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Uses super method to get a list of Artifact classes. Boot each file by
|
|
36
|
+
* creating a DataSourceConstructor and binding it to the application class.
|
|
37
|
+
*/
|
|
38
|
+
async load() {
|
|
39
|
+
await super.load();
|
|
40
|
+
this.interceptors = this.classes;
|
|
41
|
+
for (const interceptor of this.interceptors) {
|
|
42
|
+
debug('Bind interceptor: %s', interceptor.name);
|
|
43
|
+
const binding = this.app.interceptor(interceptor);
|
|
44
|
+
debug('Binding created for interceptor: %j', binding);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
InterceptorProviderBooter = tslib_1.__decorate([
|
|
49
|
+
types_1.booter('interceptors'),
|
|
50
|
+
tslib_1.__param(0, context_1.inject(core_1.CoreBindings.APPLICATION_INSTANCE)),
|
|
51
|
+
tslib_1.__param(1, context_1.inject(keys_1.BootBindings.PROJECT_ROOT)),
|
|
52
|
+
tslib_1.__param(2, context_1.config()),
|
|
53
|
+
tslib_1.__metadata("design:paramtypes", [core_1.Application, String, Object])
|
|
54
|
+
], InterceptorProviderBooter);
|
|
55
|
+
return InterceptorProviderBooter;
|
|
56
|
+
})();
|
|
56
57
|
exports.InterceptorProviderBooter = InterceptorProviderBooter;
|
|
57
58
|
/**
|
|
58
59
|
* Default ArtifactOptions for InterceptorProviderBooter.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptor.booter.js","sourceRoot":"","sources":["../../src/booters/interceptor.booter.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"interceptor.booter.js","sourceRoot":"","sources":["../../src/booters/interceptor.booter.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,+CAM2B;AAC3B,yCAAyD;AACzD,0DAAiC;AACjC,kCAAqC;AACrC,oCAAiD;AACjD,iEAA0D;AAE1D,MAAM,KAAK,GAAG,eAAY,CAAC,kCAAkC,CAAC,CAAC;AAI/D;;;;;;;;GAQG;AAEH;IAAA,IAAa,yBAAyB,GAAtC,MAAa,yBAA0B,SAAQ,yCAAkB;QAG/D,YAES,GAAgB,EACY,WAAmB,EAE/C,oBAAqC,EAAE;YAE9C,KAAK,CACH,WAAW;YACX,qEAAqE;YACrE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,mCAA2B,EAAE,iBAAiB,CAAC,CAClE,CAAC;YATK,QAAG,GAAH,GAAG,CAAa;YAGhB,sBAAiB,GAAjB,iBAAiB,CAAsB;QAOhD,CAAC;QAED;;;WAGG;QACH,KAAK,CAAC,IAAI;YACR,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;YAEnB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAqC,CAAC;YAC/D,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,YAAY,EAAE;gBAC3C,KAAK,CAAC,sBAAsB,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;gBAChD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBAClD,KAAK,CAAC,qCAAqC,EAAE,OAAO,CAAC,CAAC;aACvD;QACH,CAAC;KACF,CAAA;IA/BY,yBAAyB;QADrC,cAAM,CAAC,cAAc,CAAC;QAKlB,mBAAA,gBAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;QAEzC,mBAAA,gBAAM,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAA;QACjC,mBAAA,gBAAM,EAAE,CAAA;iDAFG,kBAAW;OALd,yBAAyB,CA+BrC;IAAD,gCAAC;KAAA;AA/BY,8DAAyB;AAiCtC;;GAEG;AACU,QAAA,2BAA2B,GAAoB;IAC1D,IAAI,EAAE,CAAC,cAAc,CAAC;IACtB,UAAU,EAAE,CAAC,iBAAiB,CAAC;IAC/B,MAAM,EAAE,IAAI;CACb,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.LifeCycleObserverDefaults = exports.LifeCycleObserverBooter = void 0;
|
|
7
8
|
const tslib_1 = require("tslib");
|
|
8
9
|
const context_1 = require("@loopback/context");
|
|
9
10
|
const core_1 = require("@loopback/core");
|
|
@@ -21,35 +22,38 @@ const debug = debug_1.default('loopback:boot:lifecycle-observer-booter');
|
|
|
21
22
|
* @param projectRoot - Root of User Project relative to which all paths are resolved
|
|
22
23
|
* @param bootConfig - LifeCycleObserver Artifact Options Object
|
|
23
24
|
*/
|
|
24
|
-
let LifeCycleObserverBooter = class
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Uses super method to get a list of Artifact classes. Boot each file by
|
|
34
|
-
* creating a DataSourceConstructor and binding it to the application class.
|
|
35
|
-
*/
|
|
36
|
-
async load() {
|
|
37
|
-
await super.load();
|
|
38
|
-
this.observers = this.classes.filter(core_1.isLifeCycleObserverClass);
|
|
39
|
-
for (const observer of this.observers) {
|
|
40
|
-
debug('Bind life cycle observer: %s', observer.name);
|
|
41
|
-
const binding = this.app.lifeCycleObserver(observer);
|
|
42
|
-
debug('Binding created for life cycle observer: %j', binding);
|
|
25
|
+
let LifeCycleObserverBooter = /** @class */ (() => {
|
|
26
|
+
let LifeCycleObserverBooter = class LifeCycleObserverBooter extends base_artifact_booter_1.BaseArtifactBooter {
|
|
27
|
+
constructor(app, projectRoot, observerConfig = {}) {
|
|
28
|
+
super(projectRoot,
|
|
29
|
+
// Set LifeCycleObserver Booter Options if passed in via bootConfig
|
|
30
|
+
Object.assign({}, exports.LifeCycleObserverDefaults, observerConfig));
|
|
31
|
+
this.app = app;
|
|
32
|
+
this.observerConfig = observerConfig;
|
|
43
33
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Uses super method to get a list of Artifact classes. Boot each file by
|
|
36
|
+
* creating a DataSourceConstructor and binding it to the application class.
|
|
37
|
+
*/
|
|
38
|
+
async load() {
|
|
39
|
+
await super.load();
|
|
40
|
+
this.observers = this.classes.filter(core_1.isLifeCycleObserverClass);
|
|
41
|
+
for (const observer of this.observers) {
|
|
42
|
+
debug('Bind life cycle observer: %s', observer.name);
|
|
43
|
+
const binding = this.app.lifeCycleObserver(observer);
|
|
44
|
+
debug('Binding created for life cycle observer: %j', binding);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
LifeCycleObserverBooter = tslib_1.__decorate([
|
|
49
|
+
types_1.booter('observers'),
|
|
50
|
+
tslib_1.__param(0, context_1.inject(core_1.CoreBindings.APPLICATION_INSTANCE)),
|
|
51
|
+
tslib_1.__param(1, context_1.inject(keys_1.BootBindings.PROJECT_ROOT)),
|
|
52
|
+
tslib_1.__param(2, context_1.config()),
|
|
53
|
+
tslib_1.__metadata("design:paramtypes", [core_1.Application, String, Object])
|
|
54
|
+
], LifeCycleObserverBooter);
|
|
55
|
+
return LifeCycleObserverBooter;
|
|
56
|
+
})();
|
|
53
57
|
exports.LifeCycleObserverBooter = LifeCycleObserverBooter;
|
|
54
58
|
/**
|
|
55
59
|
* Default ArtifactOptions for DataSourceBooter.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecyle-observer.booter.js","sourceRoot":"","sources":["../../src/booters/lifecyle-observer.booter.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"lifecyle-observer.booter.js","sourceRoot":"","sources":["../../src/booters/lifecyle-observer.booter.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,+CAA8D;AAC9D,yCAKwB;AACxB,0DAAiC;AACjC,kCAAqC;AACrC,oCAAiD;AACjD,iEAA0D;AAE1D,MAAM,KAAK,GAAG,eAAY,CAAC,yCAAyC,CAAC,CAAC;AAItE;;;;;;;;GAQG;AAEH;IAAA,IAAa,uBAAuB,GAApC,MAAa,uBAAwB,SAAQ,yCAAkB;QAG7D,YAES,GAAgB,EACY,WAAmB,EAE/C,iBAAkC,EAAE;YAE3C,KAAK,CACH,WAAW;YACX,mEAAmE;YACnE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,iCAAyB,EAAE,cAAc,CAAC,CAC7D,CAAC;YATK,QAAG,GAAH,GAAG,CAAa;YAGhB,mBAAc,GAAd,cAAc,CAAsB;QAO7C,CAAC;QAED;;;WAGG;QACH,KAAK,CAAC,IAAI;YACR,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;YAEnB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,+BAAwB,CAAC,CAAC;YAC/D,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;gBACrC,KAAK,CAAC,8BAA8B,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACrD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;gBACrD,KAAK,CAAC,6CAA6C,EAAE,OAAO,CAAC,CAAC;aAC/D;QACH,CAAC;KACF,CAAA;IA/BY,uBAAuB;QADnC,cAAM,CAAC,WAAW,CAAC;QAKf,mBAAA,gBAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;QAEzC,mBAAA,gBAAM,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAA;QACjC,mBAAA,gBAAM,EAAE,CAAA;iDAFG,kBAAW;OALd,uBAAuB,CA+BnC;IAAD,8BAAC;KAAA;AA/BY,0DAAuB;AAiCpC;;GAEG;AACU,QAAA,yBAAyB,GAAoB;IACxD,IAAI,EAAE,CAAC,WAAW,CAAC;IACnB,UAAU,EAAE,CAAC,cAAc,CAAC;IAC5B,MAAM,EAAE,IAAI;CACb,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.RestDefaults = exports.ModelApiBooter = void 0;
|
|
7
8
|
const tslib_1 = require("tslib");
|
|
8
9
|
const core_1 = require("@loopback/core");
|
|
9
10
|
const model_api_builder_1 = require("@loopback/model-api-builder");
|
|
@@ -13,72 +14,75 @@ const keys_1 = require("../keys");
|
|
|
13
14
|
const types_1 = require("../types");
|
|
14
15
|
const base_artifact_booter_1 = require("./base-artifact.booter");
|
|
15
16
|
const debug = debug_1.default('loopback:boot:model-api');
|
|
16
|
-
let ModelApiBooter = class
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
let ModelApiBooter = /** @class */ (() => {
|
|
18
|
+
let ModelApiBooter = class ModelApiBooter extends base_artifact_booter_1.BaseArtifactBooter {
|
|
19
|
+
constructor(app, projectRoot, getModelApiBuilders, booterConfig = {}) {
|
|
20
|
+
// TODO assert that `app` has RepositoryMixin members
|
|
21
|
+
super(projectRoot,
|
|
22
|
+
// Set booter options if passed in via bootConfig
|
|
23
|
+
Object.assign({}, exports.RestDefaults, booterConfig));
|
|
24
|
+
this.app = app;
|
|
25
|
+
this.getModelApiBuilders = getModelApiBuilders;
|
|
26
|
+
this.booterConfig = booterConfig;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Load the the model config files
|
|
30
|
+
*/
|
|
31
|
+
async load() {
|
|
32
|
+
// Important: don't call `super.load()` here, it would try to load
|
|
33
|
+
// classes via `loadClassesFromFiles` - that won't work for JSON files
|
|
34
|
+
await Promise.all(this.discovered.map(async (f) => {
|
|
35
|
+
try {
|
|
36
|
+
// It's important to await before returning,
|
|
37
|
+
// otherwise the catch block won't receive errors
|
|
38
|
+
await this.setupModel(f);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
const shortPath = path.relative(this.projectRoot, f);
|
|
42
|
+
err.message += ` (while loading ${shortPath})`;
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Set up the loaded model classes
|
|
49
|
+
*/
|
|
50
|
+
async setupModel(configFile) {
|
|
51
|
+
const cfg = require(configFile);
|
|
52
|
+
debug('Loaded model config from %s', path.relative(this.projectRoot, configFile), cfg);
|
|
53
|
+
const modelClass = cfg.model;
|
|
54
|
+
if (typeof modelClass !== 'function') {
|
|
55
|
+
throw new Error(`Invalid "model" field. Expected a Model class, found ${modelClass}`);
|
|
42
56
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Set up the loaded model classes
|
|
47
|
-
*/
|
|
48
|
-
async setupModel(configFile) {
|
|
49
|
-
const cfg = require(configFile);
|
|
50
|
-
debug('Loaded model config from %s', path.relative(this.projectRoot, configFile), cfg);
|
|
51
|
-
const modelClass = cfg.model;
|
|
52
|
-
if (typeof modelClass !== 'function') {
|
|
53
|
-
throw new Error(`Invalid "model" field. Expected a Model class, found ${modelClass}`);
|
|
57
|
+
const builder = await this.getApiBuilderForPattern(cfg.pattern);
|
|
58
|
+
await builder.build(this.app, modelClass, cfg);
|
|
54
59
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
`Available patterns: ${availableBuilders || '<none>'}`);
|
|
60
|
+
/**
|
|
61
|
+
* Retrieve the API builder that matches the pattern provided
|
|
62
|
+
* @param pattern - name of pattern for an API builder
|
|
63
|
+
*/
|
|
64
|
+
async getApiBuilderForPattern(pattern) {
|
|
65
|
+
const allBuilders = await this.getModelApiBuilders();
|
|
66
|
+
const builder = allBuilders.find(b => b.pattern === pattern);
|
|
67
|
+
if (!builder) {
|
|
68
|
+
const availableBuilders = allBuilders.map(b => b.pattern).join(', ');
|
|
69
|
+
throw new Error(`Unsupported API pattern "${pattern}". ` +
|
|
70
|
+
`Available patterns: ${availableBuilders || '<none>'}`);
|
|
71
|
+
}
|
|
72
|
+
return builder;
|
|
69
73
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
};
|
|
75
|
+
ModelApiBooter = tslib_1.__decorate([
|
|
76
|
+
types_1.booter('modelApi'),
|
|
77
|
+
core_1.extensionPoint(model_api_builder_1.MODEL_API_BUILDER_PLUGINS),
|
|
78
|
+
tslib_1.__param(0, core_1.inject(core_1.CoreBindings.APPLICATION_INSTANCE)),
|
|
79
|
+
tslib_1.__param(1, core_1.inject(keys_1.BootBindings.PROJECT_ROOT)),
|
|
80
|
+
tslib_1.__param(2, core_1.extensions()),
|
|
81
|
+
tslib_1.__param(3, core_1.config()),
|
|
82
|
+
tslib_1.__metadata("design:paramtypes", [Object, String, Function, Object])
|
|
83
|
+
], ModelApiBooter);
|
|
84
|
+
return ModelApiBooter;
|
|
85
|
+
})();
|
|
82
86
|
exports.ModelApiBooter = ModelApiBooter;
|
|
83
87
|
/**
|
|
84
88
|
* Default ArtifactOptions for ControllerBooter.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-api.booter.js","sourceRoot":"","sources":["../../src/booters/model-api.booter.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"model-api.booter.js","sourceRoot":"","sources":["../../src/booters/model-api.booter.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ApplicationWithRepositories } from '@loopback/repository';
|
|
2
|
+
import { ArtifactOptions } from '../types';
|
|
3
|
+
import { BaseArtifactBooter } from './base-artifact.booter';
|
|
4
|
+
/**
|
|
5
|
+
* A class that extends BaseArtifactBooter to boot the 'Model' artifact type.
|
|
6
|
+
*
|
|
7
|
+
* Supported phases: configure, discover, load
|
|
8
|
+
*
|
|
9
|
+
* @param app - Application instance
|
|
10
|
+
* @param projectRoot - Root of User Project relative to which all paths are resolved
|
|
11
|
+
* @param bootConfig - Model Artifact Options Object
|
|
12
|
+
*/
|
|
13
|
+
export declare class ModelBooter extends BaseArtifactBooter {
|
|
14
|
+
app: ApplicationWithRepositories;
|
|
15
|
+
modelConfig: ArtifactOptions;
|
|
16
|
+
constructor(app: ApplicationWithRepositories, projectRoot: string, modelConfig?: ArtifactOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Uses super method to get a list of Artifact classes. Boot each file by
|
|
19
|
+
* creating a DataSourceConstructor and binding it to the application class.
|
|
20
|
+
*/
|
|
21
|
+
load(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Default ArtifactOptions for DataSourceBooter.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ModelDefaults: ArtifactOptions;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/boot
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ModelDefaults = exports.ModelBooter = void 0;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
const context_1 = require("@loopback/context");
|
|
10
|
+
const core_1 = require("@loopback/core");
|
|
11
|
+
const repository_1 = require("@loopback/repository");
|
|
12
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
13
|
+
const keys_1 = require("../keys");
|
|
14
|
+
const types_1 = require("../types");
|
|
15
|
+
const base_artifact_booter_1 = require("./base-artifact.booter");
|
|
16
|
+
const debug = debug_1.default('loopback:boot:model-booter');
|
|
17
|
+
/**
|
|
18
|
+
* A class that extends BaseArtifactBooter to boot the 'Model' artifact type.
|
|
19
|
+
*
|
|
20
|
+
* Supported phases: configure, discover, load
|
|
21
|
+
*
|
|
22
|
+
* @param app - Application instance
|
|
23
|
+
* @param projectRoot - Root of User Project relative to which all paths are resolved
|
|
24
|
+
* @param bootConfig - Model Artifact Options Object
|
|
25
|
+
*/
|
|
26
|
+
let ModelBooter = /** @class */ (() => {
|
|
27
|
+
let ModelBooter = class ModelBooter extends base_artifact_booter_1.BaseArtifactBooter {
|
|
28
|
+
constructor(app, projectRoot, modelConfig = {}) {
|
|
29
|
+
super(projectRoot,
|
|
30
|
+
// Set Model Booter Options if passed in via bootConfig
|
|
31
|
+
Object.assign({}, exports.ModelDefaults, modelConfig));
|
|
32
|
+
this.app = app;
|
|
33
|
+
this.modelConfig = modelConfig;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Uses super method to get a list of Artifact classes. Boot each file by
|
|
37
|
+
* creating a DataSourceConstructor and binding it to the application class.
|
|
38
|
+
*/
|
|
39
|
+
async load() {
|
|
40
|
+
await super.load();
|
|
41
|
+
for (const cls of this.classes) {
|
|
42
|
+
if (!isModelClass(cls)) {
|
|
43
|
+
debug('Skipping class %s - no @model is found', cls.name);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
debug('Bind class: %s', cls.name);
|
|
47
|
+
// We are binding the model class itself
|
|
48
|
+
const binding = this.app.model(cls);
|
|
49
|
+
debug('Binding created for model class %s: %j', cls.name, binding);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
ModelBooter = tslib_1.__decorate([
|
|
54
|
+
types_1.booter('models'),
|
|
55
|
+
tslib_1.__param(0, context_1.inject(core_1.CoreBindings.APPLICATION_INSTANCE)),
|
|
56
|
+
tslib_1.__param(1, context_1.inject(keys_1.BootBindings.PROJECT_ROOT)),
|
|
57
|
+
tslib_1.__param(2, context_1.config()),
|
|
58
|
+
tslib_1.__metadata("design:paramtypes", [Object, String, Object])
|
|
59
|
+
], ModelBooter);
|
|
60
|
+
return ModelBooter;
|
|
61
|
+
})();
|
|
62
|
+
exports.ModelBooter = ModelBooter;
|
|
63
|
+
/**
|
|
64
|
+
* Default ArtifactOptions for DataSourceBooter.
|
|
65
|
+
*/
|
|
66
|
+
exports.ModelDefaults = {
|
|
67
|
+
dirs: ['models'],
|
|
68
|
+
extensions: ['.model.js'],
|
|
69
|
+
nested: true,
|
|
70
|
+
};
|
|
71
|
+
function isModelClass(cls) {
|
|
72
|
+
return repository_1.ModelMetadataHelper.getModelMetadata(cls) != null;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=model.booter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.booter.js","sourceRoot":"","sources":["../../src/booters/model.booter.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,+CAA8D;AAC9D,yCAA4C;AAC5C,qDAG8B;AAC9B,0DAAiC;AACjC,kCAAqC;AACrC,oCAAiD;AACjD,iEAA0D;AAE1D,MAAM,KAAK,GAAG,eAAY,CAAC,4BAA4B,CAAC,CAAC;AAEzD;;;;;;;;GAQG;AAEH;IAAA,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,yCAAkB;QACjD,YAES,GAAgC,EACJ,WAAmB,EAE/C,cAA+B,EAAE;YAExC,KAAK,CACH,WAAW;YACX,uDAAuD;YACvD,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,qBAAa,EAAE,WAAW,CAAC,CAC9C,CAAC;YATK,QAAG,GAAH,GAAG,CAA6B;YAGhC,gBAAW,GAAX,WAAW,CAAsB;QAO1C,CAAC;QAED;;;WAGG;QACH,KAAK,CAAC,IAAI;YACR,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;YAEnB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE;gBAC9B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE;oBACtB,KAAK,CAAC,wCAAwC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;oBAC1D,SAAS;iBACV;gBAED,KAAK,CAAC,gBAAgB,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;gBAClC,wCAAwC;gBACxC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACpC,KAAK,CAAC,wCAAwC,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;aACpE;QACH,CAAC;KACF,CAAA;IAlCY,WAAW;QADvB,cAAM,CAAC,QAAQ,CAAC;QAGZ,mBAAA,gBAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;QAEzC,mBAAA,gBAAM,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAA;QACjC,mBAAA,gBAAM,EAAE,CAAA;;OALA,WAAW,CAkCvB;IAAD,kBAAC;KAAA;AAlCY,kCAAW;AAoCxB;;GAEG;AACU,QAAA,aAAa,GAAoB;IAC5C,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,UAAU,EAAE,CAAC,WAAW,CAAC;IACzB,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,SAAS,YAAY,CAAC,GAAyB;IAC7C,OAAO,gCAAmB,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;AAC3D,CAAC"}
|