@loopback/boot 2.3.1 → 2.3.5
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 +49 -0
- package/dist/.sandbox/{63541odlHvc → 18043muTUQs}/model-endpoints/product.rest-config.js +0 -0
- package/dist/.sandbox/18043muTUQs/models/product.model.js +25 -0
- package/dist/.sandbox/{635419mu8mo → 18043wLA3S3}/application.js +0 -0
- package/dist/.sandbox/18043wLA3S3/controllers/multiple.controller.js +39 -0
- package/dist/.sandbox/{63541DlS0Ic → 18044FOwh70}/application.js +0 -0
- package/dist/.sandbox/18044FOwh70/interceptors/interceptor.interceptor.js +51 -0
- package/dist/.sandbox/18044FOwh70/interceptors/non-global-interceptor.interceptor.js +51 -0
- package/dist/.sandbox/{63541DshyBF → 18045Jt9E5K}/application.js +0 -0
- package/dist/.sandbox/{63541ik89oh → 18045Jt9E5K}/models/multiple-models.model.js +0 -0
- package/dist/.sandbox/18045Jt9E5K/models/no-entity.model.js +25 -0
- package/dist/.sandbox/18045Jt9E5K/models/product.model.js +25 -0
- package/dist/.sandbox/{63541IEce5V → 18045YaR1P2}/application.js +0 -0
- package/dist/.sandbox/{63541DshyBF → 18045YaR1P2}/observers/lifecycle-observer.observer.js +0 -0
- package/dist/.sandbox/{635415cxfJi → 18045e2CYyx}/service-provider.artifact.js +0 -0
- package/dist/.sandbox/18045hzRuQ4/dist/application.js +20 -0
- package/dist/.sandbox/{63541meTxP7 → 18045hzRuQ4}/package.json +1 -1
- package/dist/.sandbox/{635419t6TqH → 18045rgy7Ui}/datasource.artifact.js +5 -8
- package/dist/.sandbox/{63541ik89oh → 18046d8C54w}/application.js +0 -0
- package/dist/.sandbox/18046d8C54w/controllers/multiple.controller.js +39 -0
- package/dist/.sandbox/{package.json → 18046d8C54w/package.json} +1 -1
- package/dist/.sandbox/18046kEhstv/multiple.artifact.js +39 -0
- package/dist/.sandbox/18046obZENY/multiple.artifact.js +39 -0
- package/dist/.sandbox/{63541meTxP7 → 18047EeHfXu}/application.js +0 -0
- package/dist/.sandbox/18047EeHfXu/repositories/multiple.repository.js +39 -0
- package/dist/.sandbox/{63541nGmQFL → 18048e1iuZt}/application.js +0 -0
- package/dist/.sandbox/{635419mu8mo → 18048e1iuZt}/services/bindable-classes.service.js +19 -25
- package/dist/.sandbox/{635419mu8mo → 18048e1iuZt}/services/geocoder.service.js +0 -0
- package/dist/.sandbox/{635419mu8mo → 18048e1iuZt}/services/greeting.service.js +0 -0
- package/dist/.sandbox/18048urj9RP/application.js +20 -0
- package/dist/.sandbox/18048urj9RP/controllers/multiple.controller.js +39 -0
- package/dist/.sandbox/18048urj9RP/package.json +18 -0
- package/dist/.sandbox/{635411GGsm1 → 18049UriL05}/model-endpoints/no-entity.rest-config.js +0 -0
- package/dist/.sandbox/18049UriL05/models/no-entity.model.js +25 -0
- package/dist/.sandbox/{63541ruUDNf → 18049gfsPc4}/application.js +0 -0
- package/dist/.sandbox/{63541IEce5V → 18049gfsPc4}/datasources/db.datasource.js +5 -8
- package/dist/boot.component.js +30 -34
- package/dist/boot.component.js.map +1 -1
- package/dist/booters/application-metadata.booter.js +19 -23
- package/dist/booters/application-metadata.booter.js.map +1 -1
- package/dist/booters/base-artifact.booter.d.ts +1 -1
- package/dist/booters/base-artifact.booter.js +1 -1
- package/dist/booters/booter-utils.d.ts +1 -1
- package/dist/booters/component-application.booter.js +39 -42
- package/dist/booters/component-application.booter.js.map +1 -1
- package/dist/booters/controller.booter.js +26 -30
- package/dist/booters/controller.booter.js.map +1 -1
- package/dist/booters/datasource.booter.js +36 -40
- package/dist/booters/datasource.booter.js.map +1 -1
- package/dist/booters/interceptor.booter.d.ts +1 -2
- package/dist/booters/interceptor.booter.js +28 -32
- package/dist/booters/interceptor.booter.js.map +1 -1
- package/dist/booters/lifecyle-observer.booter.d.ts +1 -1
- package/dist/booters/lifecyle-observer.booter.js +29 -32
- package/dist/booters/lifecyle-observer.booter.js.map +1 -1
- package/dist/booters/model-api.booter.js +63 -66
- package/dist/booters/model-api.booter.js.map +1 -1
- package/dist/booters/model.booter.js +31 -35
- package/dist/booters/model.booter.js.map +1 -1
- package/dist/booters/repository.booter.js +35 -39
- package/dist/booters/repository.booter.js.map +1 -1
- package/dist/booters/service.booter.js +30 -34
- package/dist/booters/service.booter.js.map +1 -1
- package/dist/bootstrapper.d.ts +1 -2
- package/dist/bootstrapper.js +77 -85
- package/dist/bootstrapper.js.map +1 -1
- package/dist/keys.d.ts +1 -1
- package/dist/keys.js +4 -4
- package/dist/keys.js.map +1 -1
- package/dist/mixins/boot.mixin.d.ts +52 -41
- package/dist/mixins/boot.mixin.js +40 -18
- package/dist/mixins/boot.mixin.js.map +1 -1
- package/dist/types.d.ts +7 -1
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/package.json +18 -19
- package/src/boot.component.ts +7 -2
- package/src/booters/application-metadata.booter.ts +1 -2
- package/src/booters/base-artifact.booter.ts +2 -2
- package/src/booters/booter-utils.ts +1 -1
- package/src/booters/controller.booter.ts +1 -2
- package/src/booters/datasource.booter.ts +2 -3
- package/src/booters/interceptor.booter.ts +3 -2
- package/src/booters/lifecyle-observer.booter.ts +1 -1
- package/src/booters/model.booter.ts +1 -2
- package/src/booters/repository.booter.ts +1 -2
- package/src/booters/service.booter.ts +2 -2
- package/src/bootstrapper.ts +11 -10
- package/src/keys.ts +1 -1
- package/src/mixins/boot.mixin.ts +50 -45
- package/src/types.ts +8 -1
- package/dist/.sandbox/635411GGsm1/models/no-entity.model.js +0 -28
- package/dist/.sandbox/63541BtDxTa/multiple.artifact.js +0 -45
- package/dist/.sandbox/63541DlS0Ic/repositories/multiple.repository.js +0 -45
- package/dist/.sandbox/63541ik89oh/models/no-entity.model.js +0 -28
- package/dist/.sandbox/63541ik89oh/models/product.model.js +0 -28
- package/dist/.sandbox/63541meTxP7/controllers/multiple.controller.js +0 -45
- package/dist/.sandbox/63541nGmQFL/controllers/multiple.controller.js +0 -45
- package/dist/.sandbox/63541odlHvc/models/product.model.js +0 -28
- package/dist/.sandbox/63541ruUDNf/interceptors/interceptor.interceptor.js +0 -54
- package/dist/.sandbox/63541ruUDNf/interceptors/non-global-interceptor.interceptor.js +0 -54
- package/dist/.sandbox/63541vSi6af/multiple.artifact.js +0 -45
- package/dist/.sandbox/application.js +0 -20
- package/dist/.sandbox/controllers/multiple.controller.js +0 -45
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ServiceDefaults = exports.ServiceBooter = void 0;
|
|
8
8
|
const tslib_1 = require("tslib");
|
|
9
|
-
const context_1 = require("@loopback/context");
|
|
10
9
|
const core_1 = require("@loopback/core");
|
|
11
10
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
12
11
|
const keys_1 = require("../keys");
|
|
@@ -23,39 +22,36 @@ const debug = debug_1.default('loopback:boot:service-booter');
|
|
|
23
22
|
* @param projectRoot - Root of User Project relative to which all paths are resolved
|
|
24
23
|
* @param bootConfig - Service Artifact Options Object
|
|
25
24
|
*/
|
|
26
|
-
let ServiceBooter =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
debug('Binding created for class: %j', binding);
|
|
47
|
-
}
|
|
25
|
+
let ServiceBooter = class ServiceBooter extends base_artifact_booter_1.BaseArtifactBooter {
|
|
26
|
+
constructor(app, projectRoot, serviceConfig = {}) {
|
|
27
|
+
super(projectRoot,
|
|
28
|
+
// Set Service Booter Options if passed in via bootConfig
|
|
29
|
+
Object.assign({}, exports.ServiceDefaults, serviceConfig));
|
|
30
|
+
this.app = app;
|
|
31
|
+
this.serviceConfig = serviceConfig;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
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.
|
|
36
|
+
*/
|
|
37
|
+
async load() {
|
|
38
|
+
await super.load();
|
|
39
|
+
for (const cls of this.classes) {
|
|
40
|
+
if (!isBindableClass(cls))
|
|
41
|
+
continue;
|
|
42
|
+
debug('Bind class: %s', cls.name);
|
|
43
|
+
const binding = this.app.service(cls);
|
|
44
|
+
debug('Binding created for class: %j', binding);
|
|
48
45
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
})();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
ServiceBooter = tslib_1.__decorate([
|
|
49
|
+
types_1.booter('services'),
|
|
50
|
+
tslib_1.__param(0, core_1.inject(core_1.CoreBindings.APPLICATION_INSTANCE)),
|
|
51
|
+
tslib_1.__param(1, core_1.inject(keys_1.BootBindings.PROJECT_ROOT)),
|
|
52
|
+
tslib_1.__param(2, core_1.config()),
|
|
53
|
+
tslib_1.__metadata("design:paramtypes", [Object, String, Object])
|
|
54
|
+
], ServiceBooter);
|
|
59
55
|
exports.ServiceBooter = ServiceBooter;
|
|
60
56
|
/**
|
|
61
57
|
* Default ArtifactOptions for DataSourceBooter.
|
|
@@ -71,7 +67,7 @@ function isServiceProvider(cls) {
|
|
|
71
67
|
return hasSupportedName && hasValueMethod;
|
|
72
68
|
}
|
|
73
69
|
function isBindableClass(cls) {
|
|
74
|
-
if (
|
|
70
|
+
if (core_1.MetadataInspector.getClassMetadata(core_1.BINDING_METADATA_KEY, cls)) {
|
|
75
71
|
return true;
|
|
76
72
|
}
|
|
77
73
|
if (isServiceProvider(cls)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.booter.js","sourceRoot":"","sources":["../../src/booters/service.booter.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE
|
|
1
|
+
{"version":3,"file":"service.booter.js","sourceRoot":"","sources":["../../src/booters/service.booter.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAOwB;AAExB,0DAAiC;AACjC,kCAAqC;AACrC,oCAAiD;AACjD,iEAA0D;AAE1D,MAAM,KAAK,GAAG,eAAY,CAAC,8BAA8B,CAAC,CAAC;AAE3D;;;;;;;;;GASG;AAEH,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,yCAAkB;IACnD,YAES,GAA4B,EACA,WAAmB,EAE/C,gBAAiC,EAAE;QAE1C,KAAK,CACH,WAAW;QACX,yDAAyD;QACzD,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,uBAAe,EAAE,aAAa,CAAC,CAClD,CAAC;QATK,QAAG,GAAH,GAAG,CAAyB;QAG5B,kBAAa,GAAb,aAAa,CAAsB;IAO5C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QAEnB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE;YAC9B,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC;gBAAE,SAAS;YAEpC,KAAK,CAAC,gBAAgB,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;YAClC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACtC,KAAK,CAAC,+BAA+B,EAAE,OAAO,CAAC,CAAC;SACjD;IACH,CAAC;CACF,CAAA;AA9BY,aAAa;IADzB,cAAM,CAAC,UAAU,CAAC;IAGd,mBAAA,aAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;IAEzC,mBAAA,aAAM,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAA;IACjC,mBAAA,aAAM,EAAE,CAAA;;GALA,aAAa,CA8BzB;AA9BY,sCAAa;AAgC1B;;GAEG;AACU,QAAA,eAAe,GAAoB;IAC9C,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,UAAU,EAAE,CAAC,aAAa,CAAC;IAC3B,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,SAAS,iBAAiB,CAAC,GAAyB;IAClD,MAAM,gBAAgB,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,cAAc,GAAG,OAAO,GAAG,CAAC,SAAS,CAAC,KAAK,KAAK,UAAU,CAAC;IACjE,OAAO,gBAAgB,IAAI,cAAc,CAAC;AAC5C,CAAC;AAED,SAAS,eAAe,CAAC,GAAyB;IAChD,IAAI,wBAAiB,CAAC,gBAAgB,CAAC,2BAAoB,EAAE,GAAG,CAAC,EAAE;QACjE,OAAO,IAAI,CAAC;KACb;IACD,IAAI,iBAAiB,CAAC,GAAG,CAAC,EAAE;QAC1B,KAAK,CAAC,0BAA0B,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC;KACb;IACD,KAAK,CAAC,yCAAyC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3D,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/bootstrapper.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Context } from '@loopback/
|
|
2
|
-
import { Application } from '@loopback/core';
|
|
1
|
+
import { Application, Context } from '@loopback/core';
|
|
3
2
|
import { Bootable, BootExecutionOptions, BootOptions } from './types';
|
|
4
3
|
/**
|
|
5
4
|
* The Bootstrapper class provides the `boot` function that is responsible for
|
package/dist/bootstrapper.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.Bootstrapper = void 0;
|
|
8
8
|
const tslib_1 = require("tslib");
|
|
9
|
-
const context_1 = require("@loopback/context");
|
|
10
9
|
const core_1 = require("@loopback/core");
|
|
11
10
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
12
11
|
const path_1 = require("path");
|
|
@@ -25,93 +24,86 @@ const debug = debug_1.default('loopback:boot:bootstrapper');
|
|
|
25
24
|
* @param projectRoot - The root directory of the project, relative to which all other paths are resolved
|
|
26
25
|
* @param bootOptions - The BootOptions describing the conventions to be used by various Booters
|
|
27
26
|
*/
|
|
28
|
-
let Bootstrapper =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
let Bootstrapper = class Bootstrapper {
|
|
28
|
+
constructor(app, projectRoot, bootOptions = {}) {
|
|
29
|
+
this.app = app;
|
|
30
|
+
this.projectRoot = projectRoot;
|
|
31
|
+
this.bootOptions = bootOptions;
|
|
32
|
+
// Resolve path to projectRoot and re-bind
|
|
33
|
+
this.projectRoot = path_1.resolve(this.projectRoot);
|
|
34
|
+
app.bind(keys_1.BootBindings.PROJECT_ROOT).to(this.projectRoot);
|
|
35
|
+
// This is re-bound for testing reasons where this value may be passed directly
|
|
36
|
+
// and needs to be propagated to the Booters via DI
|
|
37
|
+
app.bind(keys_1.BootBindings.BOOT_OPTIONS).to(this.bootOptions);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Function is responsible for calling all registered Booter classes that
|
|
41
|
+
* are bound to the Application instance. Each phase of an instance must
|
|
42
|
+
* complete before the next phase is started.
|
|
43
|
+
*
|
|
44
|
+
* @param execOptions - Execution options for boot. These
|
|
45
|
+
* determine the phases and booters that are run.
|
|
46
|
+
* @param ctx - Optional Context to use to resolve bindings. This is
|
|
47
|
+
* primarily useful when running app.boot() again but with different settings
|
|
48
|
+
* (in particular phases) such as 'start' / 'stop'. Using a returned Context from
|
|
49
|
+
* a previous boot call allows DI to retrieve the same instances of Booters previously
|
|
50
|
+
* used as they are bound using a CONTEXT scope. This is important as Booter instances
|
|
51
|
+
* may maintain state.
|
|
52
|
+
*/
|
|
53
|
+
async boot(execOptions, ctx) {
|
|
54
|
+
var _a, _b, _c;
|
|
55
|
+
const bootCtx = ctx !== null && ctx !== void 0 ? ctx : new core_1.Context(this.app);
|
|
56
|
+
// Bind booters passed in as a part of BootOptions
|
|
57
|
+
// We use _bindBooter so this Class can be used without the Mixin
|
|
58
|
+
if (execOptions === null || execOptions === void 0 ? void 0 : execOptions.booters) {
|
|
59
|
+
execOptions.booters.forEach(booter => mixins_1.bindBooter(this.app, booter));
|
|
40
60
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// names of booters that should be run), that is the value, otherwise it
|
|
77
|
-
// is all the registered booters by default.
|
|
78
|
-
const names = execOptions
|
|
79
|
-
? execOptions.filter && execOptions.filter.booters
|
|
80
|
-
? execOptions.filter.booters
|
|
81
|
-
: defaultBooterNames
|
|
82
|
-
: defaultBooterNames;
|
|
83
|
-
// Filter bindings by names
|
|
84
|
-
const filteredBindings = bindings.filter(binding => names.includes(binding.key.slice(prefixLength)));
|
|
85
|
-
// Resolve Booter Instances
|
|
86
|
-
const booterInsts = await context_1.resolveList(filteredBindings, binding =>
|
|
87
|
-
// We cannot use Booter interface here because "filter.booters"
|
|
88
|
-
// allows arbitrary string values, not only the phases defined
|
|
89
|
-
// by Booter interface
|
|
90
|
-
bootCtx.get(binding.key));
|
|
91
|
-
// Run phases of booters
|
|
92
|
-
for (const phase of phases) {
|
|
93
|
-
for (const inst of booterInsts) {
|
|
94
|
-
const instName = inst.constructor.name;
|
|
95
|
-
if (inst[phase]) {
|
|
96
|
-
debug(`${instName} phase: ${phase} starting.`);
|
|
97
|
-
await inst[phase]();
|
|
98
|
-
debug(`${instName} phase: ${phase} complete.`);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
debug(`${instName} phase: ${phase} not implemented.`);
|
|
102
|
-
}
|
|
61
|
+
// Determine the phases to be run. If a user set a phases filter, those
|
|
62
|
+
// are selected otherwise we run the default phases (BOOTER_PHASES).
|
|
63
|
+
const phases = (_b = (_a = execOptions === null || execOptions === void 0 ? void 0 : execOptions.filter) === null || _a === void 0 ? void 0 : _a.phases) !== null && _b !== void 0 ? _b : types_1.BOOTER_PHASES;
|
|
64
|
+
// Find booters registered to the BOOTERS_TAG by getting the bindings
|
|
65
|
+
const bindings = bootCtx.findByTag(keys_1.BootTags.BOOTER);
|
|
66
|
+
// Prefix length. +1 because of `.` => 'booters.'
|
|
67
|
+
const prefixLength = keys_1.BootBindings.BOOTER_PREFIX.length + 1;
|
|
68
|
+
// Names of all registered booters.
|
|
69
|
+
const defaultBooterNames = bindings.map(binding => binding.key.slice(prefixLength));
|
|
70
|
+
// Determining the booters to be run. If a user set a booters filter (class
|
|
71
|
+
// names of booters that should be run), that is the value, otherwise it
|
|
72
|
+
// is all the registered booters by default.
|
|
73
|
+
const names = execOptions
|
|
74
|
+
? ((_c = execOptions.filter) === null || _c === void 0 ? void 0 : _c.booters) ? execOptions.filter.booters
|
|
75
|
+
: defaultBooterNames
|
|
76
|
+
: defaultBooterNames;
|
|
77
|
+
// Filter bindings by names
|
|
78
|
+
const filteredBindings = bindings.filter(binding => names.includes(binding.key.slice(prefixLength)));
|
|
79
|
+
// Resolve Booter Instances
|
|
80
|
+
const booterInsts = await core_1.resolveList(filteredBindings, binding =>
|
|
81
|
+
// We cannot use Booter interface here because "filter.booters"
|
|
82
|
+
// allows arbitrary string values, not only the phases defined
|
|
83
|
+
// by Booter interface
|
|
84
|
+
bootCtx.get(binding.key));
|
|
85
|
+
// Run phases of booters
|
|
86
|
+
for (const phase of phases) {
|
|
87
|
+
for (const inst of booterInsts) {
|
|
88
|
+
const instName = inst.constructor.name;
|
|
89
|
+
if (inst[phase]) {
|
|
90
|
+
debug(`${instName} phase: ${phase} starting.`);
|
|
91
|
+
await inst[phase]();
|
|
92
|
+
debug(`${instName} phase: ${phase} complete.`);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
debug(`${instName} phase: ${phase} not implemented.`);
|
|
103
96
|
}
|
|
104
97
|
}
|
|
105
|
-
return bootCtx;
|
|
106
98
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
99
|
+
return bootCtx;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
Bootstrapper = tslib_1.__decorate([
|
|
103
|
+
tslib_1.__param(0, core_1.inject(core_1.CoreBindings.APPLICATION_INSTANCE)),
|
|
104
|
+
tslib_1.__param(1, core_1.inject(keys_1.BootBindings.PROJECT_ROOT)),
|
|
105
|
+
tslib_1.__param(2, core_1.inject(keys_1.BootBindings.BOOT_OPTIONS, { optional: true })),
|
|
106
|
+
tslib_1.__metadata("design:paramtypes", [Object, String, Object])
|
|
107
|
+
], Bootstrapper);
|
|
116
108
|
exports.Bootstrapper = Bootstrapper;
|
|
117
109
|
//# sourceMappingURL=bootstrapper.js.map
|
package/dist/bootstrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrapper.js","sourceRoot":"","sources":["../src/bootstrapper.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;AAEhE
|
|
1
|
+
{"version":3,"file":"bootstrapper.js","sourceRoot":"","sources":["../src/bootstrapper.ts"],"names":[],"mappings":"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"}
|
package/dist/keys.d.ts
CHANGED
package/dist/keys.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.BootTags = exports.BootBindings = void 0;
|
|
8
|
-
const
|
|
8
|
+
const core_1 = require("@loopback/core");
|
|
9
9
|
/**
|
|
10
10
|
* Namespace for boot related binding keys
|
|
11
11
|
*/
|
|
@@ -14,15 +14,15 @@ var BootBindings;
|
|
|
14
14
|
/**
|
|
15
15
|
* Binding key for boot options
|
|
16
16
|
*/
|
|
17
|
-
BootBindings.BOOT_OPTIONS =
|
|
17
|
+
BootBindings.BOOT_OPTIONS = core_1.BindingKey.create('boot.options');
|
|
18
18
|
/**
|
|
19
19
|
* Binding key for determining project root directory
|
|
20
20
|
*/
|
|
21
|
-
BootBindings.PROJECT_ROOT =
|
|
21
|
+
BootBindings.PROJECT_ROOT = core_1.BindingKey.create('boot.project_root');
|
|
22
22
|
/**
|
|
23
23
|
* Binding key for binding the BootStrapper class
|
|
24
24
|
*/
|
|
25
|
-
BootBindings.BOOTSTRAPPER_KEY =
|
|
25
|
+
BootBindings.BOOTSTRAPPER_KEY = core_1.BindingKey.create('application.bootstrapper');
|
|
26
26
|
BootBindings.BOOTER_PREFIX = 'booters';
|
|
27
27
|
})(BootBindings = exports.BootBindings || (exports.BootBindings = {}));
|
|
28
28
|
/**
|
package/dist/keys.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;AAEhE
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;AAEhE,yCAA0C;AAI1C;;GAEG;AACH,IAAiB,YAAY,CAkB5B;AAlBD,WAAiB,YAAY;IAC3B;;OAEG;IACU,yBAAY,GAAG,iBAAU,CAAC,MAAM,CAAc,cAAc,CAAC,CAAC;IAC3E;;OAEG;IACU,yBAAY,GAAG,iBAAU,CAAC,MAAM,CAAS,mBAAmB,CAAC,CAAC;IAE3E;;OAEG;IACU,6BAAgB,GAAG,iBAAU,CAAC,MAAM,CAC/C,0BAA0B,CAC3B,CAAC;IAEW,0BAAa,GAAG,SAAS,CAAC;AACzC,CAAC,EAlBgB,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAkB5B;AAED;;GAEG;AACH,IAAiB,QAAQ,CAMxB;AAND,WAAiB,QAAQ;IACV,eAAM,GAAG,QAAQ,CAAC;IAC/B;;OAEG;IACU,mBAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;AAC5C,CAAC,EANgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAMxB"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Binding, BindingFilter, BindingFromClassOptions, Constructor, Context } from '@loopback/
|
|
1
|
+
import { Binding, BindingFilter, BindingFromClassOptions, Constructor, Context } from '@loopback/core';
|
|
2
2
|
import { Application, Component, MixinTarget } from '@loopback/core';
|
|
3
|
-
import { Bootable, Booter, BootOptions } from '../types';
|
|
4
|
-
import
|
|
5
|
-
import { Server, ApplicationConfig, ApplicationMetadata, LifeCycleObserver, ServiceOptions } from '@loopback/core';
|
|
3
|
+
import { Bootable, Booter, BootOptions, InstanceWithBooters } from '../types';
|
|
4
|
+
import * as loopbackContext from '@loopback/core';
|
|
6
5
|
export { Binding };
|
|
7
6
|
/**
|
|
8
7
|
* Mixin for @loopback/boot. This Mixin provides the following:
|
|
@@ -15,6 +14,11 @@ export { Binding };
|
|
|
15
14
|
* - Provides the `booter()` convenience method to bind a Booter(s) to the Application
|
|
16
15
|
* - Override `component()` to call `mountComponentBooters`
|
|
17
16
|
* - Adds `mountComponentBooters` which binds Booters to the application from `component.booters[]`
|
|
17
|
+
*
|
|
18
|
+
* @param superClass - Application class
|
|
19
|
+
* @returns A new class that extends the super class with boot related methods
|
|
20
|
+
*
|
|
21
|
+
* @typeParam T - Type of the application class as the target for the mixin
|
|
18
22
|
*/
|
|
19
23
|
export declare function BootMixin<T extends MixinTarget<Application>>(superClass: T): {
|
|
20
24
|
new (...args: any[]): {
|
|
@@ -72,62 +76,68 @@ export declare function BootMixin<T extends MixinTarget<Application>>(superClass
|
|
|
72
76
|
*
|
|
73
77
|
* @param component - The component to mount booters of
|
|
74
78
|
*/
|
|
75
|
-
mountComponentBooters(
|
|
76
|
-
readonly options: ApplicationConfig;
|
|
79
|
+
mountComponentBooters(componentInstanceOrClass: Constructor<unknown> | InstanceWithBooters): void;
|
|
80
|
+
readonly options: loopbackContext.ApplicationConfig;
|
|
77
81
|
readonly state: string;
|
|
78
82
|
controller: <T_1>(controllerCtor: Constructor<T_1>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_1>;
|
|
79
|
-
server: <T_2 extends Server>(ctor: Constructor<T_2>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_2>;
|
|
80
|
-
servers: <T_3 extends Server>(ctors: Constructor<T_3>[]) => Binding<any>[];
|
|
81
|
-
getServer: <T_4 extends Server>(target: string | Constructor<T_4>) => Promise<T_4>;
|
|
83
|
+
server: <T_2 extends loopbackContext.Server>(ctor: Constructor<T_2>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_2>;
|
|
84
|
+
servers: <T_3 extends loopbackContext.Server>(ctors: Constructor<T_3>[]) => Binding<any>[];
|
|
85
|
+
getServer: <T_4 extends loopbackContext.Server>(target: string | Constructor<T_4>) => Promise<T_4>;
|
|
82
86
|
start: () => Promise<void>;
|
|
83
87
|
stop: () => Promise<void>;
|
|
84
|
-
setMetadata: (metadata: ApplicationMetadata) => void;
|
|
85
|
-
lifeCycleObserver: <T_5 extends LifeCycleObserver>(ctor: Constructor<T_5>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_5>;
|
|
86
|
-
service: <S>(cls: Constructor<S | Provider<S>>, nameOrOptions?: string | ServiceOptions | undefined) => Binding<S>;
|
|
87
|
-
interceptor: (interceptor: Interceptor | Constructor<Provider<Interceptor>>, nameOrOptions?: string | InterceptorBindingOptions | undefined) => Binding<Interceptor>;
|
|
88
|
+
setMetadata: (metadata: loopbackContext.ApplicationMetadata) => void;
|
|
89
|
+
lifeCycleObserver: <T_5 extends loopbackContext.LifeCycleObserver>(ctor: Constructor<T_5>, nameOrOptions?: string | BindingFromClassOptions | undefined) => Binding<T_5>;
|
|
90
|
+
service: <S>(cls: Constructor<S | loopbackContext.Provider<S>>, nameOrOptions?: string | loopbackContext.ServiceOptions | undefined) => Binding<S>;
|
|
91
|
+
interceptor: (interceptor: loopbackContext.Interceptor | Constructor<loopbackContext.Provider<loopbackContext.Interceptor>>, nameOrOptions?: string | loopbackContext.InterceptorBindingOptions | undefined) => Binding<loopbackContext.Interceptor>;
|
|
88
92
|
readonly name: string;
|
|
89
|
-
readonly subscriptionManager: ContextSubscriptionManager;
|
|
93
|
+
readonly subscriptionManager: loopbackContext.ContextSubscriptionManager;
|
|
90
94
|
readonly parent: Context | undefined;
|
|
91
|
-
emitEvent: <T_6 extends ContextEvent>(type: string, event: T_6) => void;
|
|
95
|
+
emitEvent: <T_6 extends loopbackContext.ContextEvent>(type: string, event: T_6) => void;
|
|
92
96
|
emitError: (err: unknown) => void;
|
|
93
|
-
bind: <ValueType = any>(key: BindingAddress<ValueType>) => Binding<ValueType>;
|
|
97
|
+
bind: <ValueType = any>(key: loopbackContext.BindingAddress<ValueType>) => Binding<ValueType>;
|
|
94
98
|
add: (binding: Binding<unknown>) => Application;
|
|
95
|
-
configure: <ConfigValueType = any>(key?: string | BindingKey<unknown> | undefined) => Binding<ConfigValueType>;
|
|
96
|
-
getConfigAsValueOrPromise: <ConfigValueType_1>(key: BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: ResolutionOptions | undefined) => ValueOrPromise<ConfigValueType_1 | undefined>;
|
|
97
|
-
getConfig: <ConfigValueType_2>(key: BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: ResolutionOptions | undefined) => Promise<ConfigValueType_2 | undefined>;
|
|
98
|
-
getConfigSync: <ConfigValueType_3>(key: BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: ResolutionOptions | undefined) => ConfigValueType_3 | undefined;
|
|
99
|
-
unbind: (key: BindingAddress<unknown>) => boolean;
|
|
100
|
-
subscribe: (observer: ContextEventObserver) => Subscription;
|
|
101
|
-
unsubscribe: (observer: ContextEventObserver) => boolean;
|
|
99
|
+
configure: <ConfigValueType = any>(key?: string | loopbackContext.BindingKey<unknown> | undefined) => Binding<ConfigValueType>;
|
|
100
|
+
getConfigAsValueOrPromise: <ConfigValueType_1>(key: loopbackContext.BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: loopbackContext.ResolutionOptions | undefined) => loopbackContext.ValueOrPromise<ConfigValueType_1 | undefined>;
|
|
101
|
+
getConfig: <ConfigValueType_2>(key: loopbackContext.BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: loopbackContext.ResolutionOptions | undefined) => Promise<ConfigValueType_2 | undefined>;
|
|
102
|
+
getConfigSync: <ConfigValueType_3>(key: loopbackContext.BindingAddress<unknown>, propertyPath?: string | undefined, resolutionOptions?: loopbackContext.ResolutionOptions | undefined) => ConfigValueType_3 | undefined;
|
|
103
|
+
unbind: (key: loopbackContext.BindingAddress<unknown>) => boolean;
|
|
104
|
+
subscribe: (observer: loopbackContext.ContextEventObserver) => loopbackContext.Subscription;
|
|
105
|
+
unsubscribe: (observer: loopbackContext.ContextEventObserver) => boolean;
|
|
102
106
|
close: () => void;
|
|
103
|
-
isSubscribed: (observer: ContextObserver) => boolean;
|
|
104
|
-
createView: <T_7 = unknown>(filter: BindingFilter, comparator?: BindingComparator | undefined) => ContextView<T_7>;
|
|
105
|
-
contains: (key: BindingAddress<unknown>) => boolean;
|
|
106
|
-
isBound: (key: BindingAddress<unknown>) => boolean;
|
|
107
|
-
getOwnerContext: (key: BindingAddress<unknown>) => Context | undefined;
|
|
107
|
+
isSubscribed: (observer: loopbackContext.ContextObserver) => boolean;
|
|
108
|
+
createView: <T_7 = unknown>(filter: BindingFilter, comparator?: loopbackContext.BindingComparator | undefined) => loopbackContext.ContextView<T_7>;
|
|
109
|
+
contains: (key: loopbackContext.BindingAddress<unknown>) => boolean;
|
|
110
|
+
isBound: (key: loopbackContext.BindingAddress<unknown>) => boolean;
|
|
111
|
+
getOwnerContext: (key: loopbackContext.BindingAddress<unknown>) => Context | undefined;
|
|
108
112
|
find: <ValueType_1 = any>(pattern?: string | RegExp | BindingFilter | undefined) => Readonly<Binding<ValueType_1>>[];
|
|
109
113
|
findByTag: <ValueType_2 = any>(tagFilter: string | RegExp | Record<string, any>) => Readonly<Binding<ValueType_2>>[];
|
|
110
114
|
get: {
|
|
111
|
-
<ValueType_3>(keyWithPath: BindingAddress<ValueType_3>, session?: ResolutionSession | undefined): Promise<ValueType_3>;
|
|
112
|
-
<ValueType_4>(keyWithPath: BindingAddress<ValueType_4>, options: ResolutionOptions): Promise<ValueType_4 | undefined>;
|
|
115
|
+
<ValueType_3>(keyWithPath: loopbackContext.BindingAddress<ValueType_3>, session?: loopbackContext.ResolutionSession | undefined): Promise<ValueType_3>;
|
|
116
|
+
<ValueType_4>(keyWithPath: loopbackContext.BindingAddress<ValueType_4>, options: loopbackContext.ResolutionOptions): Promise<ValueType_4 | undefined>;
|
|
113
117
|
};
|
|
114
118
|
getSync: {
|
|
115
|
-
<ValueType_5>(keyWithPath: BindingAddress<ValueType_5>, session?: ResolutionSession | undefined): ValueType_5;
|
|
116
|
-
<ValueType_6>(keyWithPath: BindingAddress<ValueType_6>, options?: ResolutionOptions | undefined): ValueType_6 | undefined;
|
|
119
|
+
<ValueType_5>(keyWithPath: loopbackContext.BindingAddress<ValueType_5>, session?: loopbackContext.ResolutionSession | undefined): ValueType_5;
|
|
120
|
+
<ValueType_6>(keyWithPath: loopbackContext.BindingAddress<ValueType_6>, options?: loopbackContext.ResolutionOptions | undefined): ValueType_6 | undefined;
|
|
117
121
|
};
|
|
118
122
|
getBinding: {
|
|
119
|
-
<ValueType_7 = any>(key: BindingAddress<ValueType_7>): Binding<ValueType_7>;
|
|
120
|
-
<ValueType_8>(key: BindingAddress<ValueType_8>, options?: {
|
|
123
|
+
<ValueType_7 = any>(key: loopbackContext.BindingAddress<ValueType_7>): Binding<ValueType_7>;
|
|
124
|
+
<ValueType_8>(key: loopbackContext.BindingAddress<ValueType_8>, options?: {
|
|
121
125
|
optional?: boolean | undefined;
|
|
122
126
|
} | undefined): Binding<ValueType_8> | undefined;
|
|
123
127
|
};
|
|
124
|
-
findOrCreateBinding: <T_8>(key: BindingAddress<T_8>, policy?: BindingCreationPolicy | undefined) => Binding<T_8>;
|
|
125
|
-
getValueOrPromise: <ValueType_9>(keyWithPath: BindingAddress<ValueType_9>, optionsOrSession?: ResolutionSession | ResolutionOptions | undefined) => ValueOrPromise<ValueType_9 | undefined>;
|
|
126
|
-
toJSON: () => JSONObject;
|
|
127
|
-
inspect: (options?: ContextInspectOptions | undefined) => JSONObject;
|
|
128
|
+
findOrCreateBinding: <T_8>(key: loopbackContext.BindingAddress<T_8>, policy?: loopbackContext.BindingCreationPolicy | undefined) => Binding<T_8>;
|
|
129
|
+
getValueOrPromise: <ValueType_9>(keyWithPath: loopbackContext.BindingAddress<ValueType_9>, optionsOrSession?: loopbackContext.ResolutionSession | loopbackContext.ResolutionOptions | undefined) => loopbackContext.ValueOrPromise<ValueType_9 | undefined>;
|
|
130
|
+
toJSON: () => loopbackContext.JSONObject;
|
|
131
|
+
inspect: (options?: loopbackContext.ContextInspectOptions | undefined) => loopbackContext.JSONObject;
|
|
132
|
+
on: {
|
|
133
|
+
(eventName: "bind" | "unbind", listener: loopbackContext.ContextEventListener): Application;
|
|
134
|
+
(event: string | symbol, listener: (...args: any[]) => void): Application;
|
|
135
|
+
};
|
|
136
|
+
once: {
|
|
137
|
+
(eventName: "bind" | "unbind", listener: loopbackContext.ContextEventListener): Application;
|
|
138
|
+
(event: string | symbol, listener: (...args: any[]) => void): Application;
|
|
139
|
+
};
|
|
128
140
|
addListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
129
|
-
on: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
130
|
-
once: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
131
141
|
prependListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
132
142
|
prependOnceListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
133
143
|
removeListener: (event: string | symbol, listener: (...args: any[]) => void) => Application;
|
|
@@ -149,4 +159,5 @@ export declare function BootMixin<T extends MixinTarget<Application>>(superClass
|
|
|
149
159
|
* @param ctx - The Context to bind the Booter Class
|
|
150
160
|
* @param booterCls - Booter class to be bound
|
|
151
161
|
*/
|
|
152
|
-
export declare function
|
|
162
|
+
export declare function bindBooter(ctx: Context, booterCls: Constructor<Booter>): Binding;
|
|
163
|
+
export declare const _bindBooter: typeof bindBooter;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2018,
|
|
2
|
+
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
3
3
|
// Node module: @loopback/boot
|
|
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._bindBooter = exports.BootMixin = exports.Binding = void 0;
|
|
8
|
-
const
|
|
9
|
-
Object.defineProperty(exports, "Binding", { enumerable: true, get: function () { return
|
|
7
|
+
exports._bindBooter = exports.bindBooter = exports.BootMixin = exports.Binding = void 0;
|
|
8
|
+
const core_1 = require("@loopback/core");
|
|
9
|
+
Object.defineProperty(exports, "Binding", { enumerable: true, get: function () { return core_1.Binding; } });
|
|
10
|
+
const core_2 = require("@loopback/core");
|
|
10
11
|
const boot_component_1 = require("../boot.component");
|
|
11
12
|
const component_application_booter_1 = require("../booters/component-application.booter");
|
|
12
13
|
const keys_1 = require("../keys");
|
|
@@ -21,6 +22,11 @@ const keys_1 = require("../keys");
|
|
|
21
22
|
* - Provides the `booter()` convenience method to bind a Booter(s) to the Application
|
|
22
23
|
* - Override `component()` to call `mountComponentBooters`
|
|
23
24
|
* - Adds `mountComponentBooters` which binds Booters to the application from `component.booters[]`
|
|
25
|
+
*
|
|
26
|
+
* @param superClass - Application class
|
|
27
|
+
* @returns A new class that extends the super class with boot related methods
|
|
28
|
+
*
|
|
29
|
+
* @typeParam T - Type of the application class as the target for the mixin
|
|
24
30
|
*/
|
|
25
31
|
function BootMixin(superClass) {
|
|
26
32
|
return class extends superClass {
|
|
@@ -37,7 +43,7 @@ function BootMixin(superClass) {
|
|
|
37
43
|
* Convenience method to call bootstrapper.boot() by resolving bootstrapper
|
|
38
44
|
*/
|
|
39
45
|
async boot() {
|
|
40
|
-
/* eslint-disable @typescript-eslint/ban-ts-
|
|
46
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
41
47
|
// A workaround to access protected Application methods
|
|
42
48
|
const self = this;
|
|
43
49
|
if (this.state === 'booting') {
|
|
@@ -57,7 +63,7 @@ function BootMixin(superClass) {
|
|
|
57
63
|
await bootstrapper.boot();
|
|
58
64
|
// @ts-ignore
|
|
59
65
|
this.setState('booted');
|
|
60
|
-
/* eslint-enable @typescript-eslint/ban-ts-
|
|
66
|
+
/* eslint-enable @typescript-eslint/ban-ts-comment */
|
|
61
67
|
}
|
|
62
68
|
/**
|
|
63
69
|
* Given a N number of Booter Classes, this method binds them using the
|
|
@@ -71,7 +77,7 @@ function BootMixin(superClass) {
|
|
|
71
77
|
* ```
|
|
72
78
|
*/
|
|
73
79
|
booters(...booterCls) {
|
|
74
|
-
return booterCls.map(cls =>
|
|
80
|
+
return booterCls.map(cls => bindBooter(this, cls));
|
|
75
81
|
}
|
|
76
82
|
/**
|
|
77
83
|
* Register a booter to boot a sub-application. See
|
|
@@ -107,11 +113,12 @@ function BootMixin(superClass) {
|
|
|
107
113
|
*/
|
|
108
114
|
// Unfortunately, TypeScript does not allow overriding methods inherited
|
|
109
115
|
// from mapped types. https://github.com/microsoft/TypeScript/issues/38496
|
|
110
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
111
117
|
// @ts-ignore
|
|
112
118
|
component(componentCtor, nameOrOptions) {
|
|
113
119
|
const binding = super.component(componentCtor, nameOrOptions);
|
|
114
|
-
this.
|
|
120
|
+
const instance = this.getSync(binding.key);
|
|
121
|
+
this.mountComponentBooters(instance);
|
|
115
122
|
return binding;
|
|
116
123
|
}
|
|
117
124
|
/**
|
|
@@ -121,11 +128,24 @@ function BootMixin(superClass) {
|
|
|
121
128
|
*
|
|
122
129
|
* @param component - The component to mount booters of
|
|
123
130
|
*/
|
|
124
|
-
mountComponentBooters(
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
131
|
+
mountComponentBooters(componentInstanceOrClass) {
|
|
132
|
+
const componentInstance = resolveComponentInstance(this);
|
|
133
|
+
if (componentInstance.booters) {
|
|
134
|
+
this.booters(...componentInstance.booters);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Determines if componentInstanceOrClass is an instance of a component,
|
|
138
|
+
* or a class that needs to be instantiated from context.
|
|
139
|
+
* @param ctx
|
|
140
|
+
*/
|
|
141
|
+
function resolveComponentInstance(ctx) {
|
|
142
|
+
if (typeof componentInstanceOrClass !== 'function') {
|
|
143
|
+
return componentInstanceOrClass;
|
|
144
|
+
}
|
|
145
|
+
// TODO(semver-major) @bajtos: Reminder to remove this on the next major release
|
|
146
|
+
const componentName = componentInstanceOrClass.name;
|
|
147
|
+
const componentKey = `${core_2.CoreBindings.COMPONENTS}.${componentName}`;
|
|
148
|
+
return ctx.getSync(componentKey);
|
|
129
149
|
}
|
|
130
150
|
}
|
|
131
151
|
};
|
|
@@ -138,10 +158,10 @@ exports.BootMixin = BootMixin;
|
|
|
138
158
|
* @param ctx - The Context to bind the Booter Class
|
|
139
159
|
* @param booterCls - Booter class to be bound
|
|
140
160
|
*/
|
|
141
|
-
function
|
|
142
|
-
const binding =
|
|
161
|
+
function bindBooter(ctx, booterCls) {
|
|
162
|
+
const binding = core_1.createBindingFromClass(booterCls, {
|
|
143
163
|
namespace: keys_1.BootBindings.BOOTER_PREFIX,
|
|
144
|
-
defaultScope:
|
|
164
|
+
defaultScope: core_1.BindingScope.SINGLETON,
|
|
145
165
|
}).tag(keys_1.BootTags.BOOTER);
|
|
146
166
|
ctx.add(binding);
|
|
147
167
|
/**
|
|
@@ -155,5 +175,7 @@ function _bindBooter(ctx, booterCls) {
|
|
|
155
175
|
}
|
|
156
176
|
return binding;
|
|
157
177
|
}
|
|
158
|
-
exports.
|
|
178
|
+
exports.bindBooter = bindBooter;
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
180
|
+
exports._bindBooter = bindBooter; // For backward-compatibility
|
|
159
181
|
//# sourceMappingURL=boot.mixin.js.map
|