@loopback/boot 1.5.11 → 1.7.2
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 +48 -0
- package/dist/.sandbox/service-provider.artifact.js +1 -1
- package/dist/boot.component.d.ts +2 -2
- package/dist/boot.component.js +1 -0
- package/dist/boot.component.js.map +1 -1
- package/dist/booters/application-metadata.booter.js +6 -3
- package/dist/booters/application-metadata.booter.js.map +1 -1
- package/dist/booters/base-artifact.booter.js +7 -4
- package/dist/booters/base-artifact.booter.js.map +1 -1
- package/dist/booters/booter-utils.js +7 -4
- package/dist/booters/booter-utils.js.map +1 -1
- package/dist/booters/index.d.ts +1 -0
- package/dist/booters/index.js +1 -0
- package/dist/booters/index.js.map +1 -1
- package/dist/booters/interceptor.booter.js +5 -2
- package/dist/booters/interceptor.booter.js.map +1 -1
- package/dist/booters/lifecyle-observer.booter.js +5 -2
- package/dist/booters/lifecyle-observer.booter.js.map +1 -1
- package/dist/booters/model-api.booter.d.ts +28 -0
- package/dist/booters/model-api.booter.js +112 -0
- package/dist/booters/model-api.booter.js.map +1 -0
- package/dist/booters/service.booter.js +5 -2
- package/dist/booters/service.booter.js.map +1 -1
- package/dist/bootstrapper.js +8 -4
- package/dist/bootstrapper.js.map +1 -1
- package/dist/mixins/boot.mixin.js +8 -0
- package/dist/mixins/boot.mixin.js.map +1 -1
- package/package.json +13 -12
- package/src/boot.component.ts +2 -0
- package/src/booters/application-metadata.booter.ts +2 -2
- package/src/booters/base-artifact.booter.ts +2 -2
- package/src/booters/booter-utils.ts +2 -2
- package/src/booters/index.ts +1 -0
- package/src/booters/interceptor.booter.ts +1 -1
- package/src/booters/lifecyle-observer.booter.ts +1 -1
- package/src/booters/model-api.booter.ts +117 -0
- package/src/booters/service.booter.ts +1 -1
- package/src/bootstrapper.ts +3 -3
- package/src/mixins/boot.mixin.ts +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,54 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.7.2](https://github.com/strongloop/loopback-next/compare/@loopback/boot@1.7.1...@loopback/boot@1.7.2) (2020-01-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @loopback/boot
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [1.7.1](https://github.com/strongloop/loopback-next/compare/@loopback/boot@1.7.0...@loopback/boot@1.7.1) (2020-01-07)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @loopback/boot
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [1.7.0](https://github.com/strongloop/loopback-next/compare/@loopback/boot@1.6.0...@loopback/boot@1.7.0) (2020-01-07)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* add model-api-builder and model-api-booter ([bacadcc](https://github.com/strongloop/loopback-next/commit/bacadcc22f6c813ee384d1d040f518190d9aae17))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# [1.6.0](https://github.com/strongloop/loopback-next/compare/@loopback/boot@1.5.12...@loopback/boot@1.6.0) (2019-12-09)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* **boot:** set up booting and booted states for boot() ([96c9313](https://github.com/strongloop/loopback-next/commit/96c93134db0509ce7d97ce6c5451377bed4fc6fe))
|
|
39
|
+
* **core:** enable start/stop/boot to be idempotent ([b614a78](https://github.com/strongloop/loopback-next/commit/b614a7825be1dc1875556388443f72385525fa29))
|
|
40
|
+
* **core:** improve application states for start/stop ([01dac15](https://github.com/strongloop/loopback-next/commit/01dac151260e6c743cc77863f6495a85d19d338c))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## [1.5.12](https://github.com/strongloop/loopback-next/compare/@loopback/boot@1.5.11...@loopback/boot@1.5.12) (2019-11-25)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @loopback/boot
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
6
54
|
## [1.5.11](https://github.com/strongloop/loopback-next/compare/@loopback/boot@1.5.10...@loopback/boot@1.5.11) (2019-11-12)
|
|
7
55
|
|
|
8
56
|
**Note:** Version bump only for package @loopback/boot
|
|
@@ -17,4 +17,4 @@ class GeocoderServiceProvider {
|
|
|
17
17
|
}
|
|
18
18
|
exports.GeocoderServiceProvider = GeocoderServiceProvider;
|
|
19
19
|
//# sourceMappingURL=service-provider.artifact.js.map
|
|
20
|
-
//# sourceMappingURL=/Users/rfeng/Projects/
|
|
20
|
+
//# sourceMappingURL=/Users/rfeng/Projects/loopback4/loopback-next/packages/boot/dist/__tests__/fixtures/service-provider.artifact.js.map
|
package/dist/boot.component.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Application, Component } from '@loopback/core';
|
|
2
|
-
import { ApplicationMetadataBooter, ControllerBooter, DataSourceBooter, InterceptorProviderBooter, LifeCycleObserverBooter, RepositoryBooter, ServiceBooter } from './booters';
|
|
2
|
+
import { ApplicationMetadataBooter, ControllerBooter, DataSourceBooter, InterceptorProviderBooter, LifeCycleObserverBooter, ModelApiBooter, RepositoryBooter, ServiceBooter } from './booters';
|
|
3
3
|
/**
|
|
4
4
|
* BootComponent is used to export the default list of Booter's made
|
|
5
5
|
* available by this module as well as bind the BootStrapper to the app so it
|
|
6
6
|
* can be used to run the Booters.
|
|
7
7
|
*/
|
|
8
8
|
export declare class BootComponent implements Component {
|
|
9
|
-
booters: (typeof ApplicationMetadataBooter | typeof ControllerBooter | typeof DataSourceBooter | typeof InterceptorProviderBooter | typeof LifeCycleObserverBooter | typeof RepositoryBooter | typeof ServiceBooter)[];
|
|
9
|
+
booters: (typeof ApplicationMetadataBooter | typeof ControllerBooter | typeof DataSourceBooter | typeof InterceptorProviderBooter | typeof LifeCycleObserverBooter | typeof ModelApiBooter | typeof RepositoryBooter | typeof ServiceBooter)[];
|
|
10
10
|
/**
|
|
11
11
|
*
|
|
12
12
|
* @param app - Application instance
|
package/dist/boot.component.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot.component.js","sourceRoot":"","sources":["../src/boot.component.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;AAEhE,+CAAuD;AACvD,yCAAoE;AACpE,
|
|
1
|
+
{"version":3,"file":"boot.component.js","sourceRoot":"","sources":["../src/boot.component.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;AAEhE,+CAAuD;AACvD,yCAAoE;AACpE,uCASmB;AACnB,iDAA4C;AAC5C,iCAAoC;AAEpC;;;;GAIG;AACH,IAAa,aAAa,GAA1B,MAAa,aAAa;IAcxB;;;OAGG;IACH,YAAuD,GAAgB;QAjBvE,sEAAsE;QACtE,gDAAgD;QAChD,YAAO,GAAG;YACR,mCAAyB;YACzB,0BAAgB;YAChB,0BAAgB;YAChB,uBAAa;YACb,0BAAgB;YAChB,iCAAuB;YACvB,mCAAyB;YACzB,wBAAc;SACf,CAAC;QAOA,8DAA8D;QAC9D,GAAG;aACA,IAAI,CAAC,mBAAY,CAAC,gBAAgB,CAAC;aACnC,OAAO,CAAC,2BAAY,CAAC;aACrB,OAAO,CAAC,sBAAY,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;CACF,CAAA;AAzBY,aAAa;IAkBX,WAAA,gBAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;qCAAM,kBAAW;GAlB5D,aAAa,CAyBzB;AAzBY,sCAAa"}
|
|
@@ -15,13 +15,16 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
15
15
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
16
16
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
17
17
|
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
18
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
const core_1 = require("@loopback/core");
|
|
20
22
|
const context_1 = require("@loopback/context");
|
|
23
|
+
const core_1 = require("@loopback/core");
|
|
24
|
+
const debug_1 = __importDefault(require("debug"));
|
|
21
25
|
const keys_1 = require("../keys");
|
|
22
26
|
const path = require("path");
|
|
23
|
-
const
|
|
24
|
-
const debug = debugModule('loopback:boot:booter:application-metadata');
|
|
27
|
+
const debug = debug_1.default('loopback:boot:booter:application-metadata');
|
|
25
28
|
/**
|
|
26
29
|
*
|
|
27
30
|
* Configure the application with metadata from `package.json`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-metadata.booter.js","sourceRoot":"","sources":["../../src/booters/application-metadata.booter.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"application-metadata.booter.js","sourceRoot":"","sources":["../../src/booters/application-metadata.booter.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;;;;AAEhE,+CAAyC;AACzC,yCAAyD;AACzD,kDAAgC;AAChC,kCAAqC;AAErC,6BAA8B;AAE9B,MAAM,KAAK,GAAG,eAAW,CAAC,2CAA2C,CAAC,CAAC;AAEvE;;;;;;GAMG;AACH,IAAa,yBAAyB,GAAtC,MAAa,yBAAyB;IACpC,YACoD,GAAgB,EACvB,WAAmB;QADZ,QAAG,GAAH,GAAG,CAAa;QACvB,gBAAW,GAAX,WAAW,CAAQ;IAC7D,CAAC;IAEJ,KAAK,CAAC,SAAS;QACb,IAAI;YACF,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;YACpE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;SAC3B;QAAC,OAAO,GAAG,EAAE;YACZ,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;SACtC;IACH,CAAC;CACF,CAAA;AAdY,yBAAyB;IAEjC,WAAA,gBAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;IACzC,WAAA,gBAAM,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAA;qCADqB,kBAAW;GAFzD,yBAAyB,CAcrC;AAdY,8DAAyB"}
|
|
@@ -3,11 +3,14 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
6
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
8
|
-
const
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
9
12
|
const booter_utils_1 = require("./booter-utils");
|
|
10
|
-
const debug =
|
|
13
|
+
const debug = debug_1.default('loopback:boot:base-artifact-booter');
|
|
11
14
|
/**
|
|
12
15
|
* This class serves as a base class for Booters which follow a pattern of
|
|
13
16
|
* configure, discover files in a folder(s) using explicit folder / extensions
|
|
@@ -69,7 +72,7 @@ class BaseArtifactBooter {
|
|
|
69
72
|
debug('Discovering %s artifacts in %j using glob %j', this.artifactName, this.projectRoot, this.glob);
|
|
70
73
|
this.discovered = await booter_utils_1.discoverFiles(this.glob, this.projectRoot);
|
|
71
74
|
if (debug.enabled) {
|
|
72
|
-
debug('Artifact files found: %s', JSON.stringify(this.discovered.map(f =>
|
|
75
|
+
debug('Artifact files found: %s', JSON.stringify(this.discovered.map(f => path_1.default.relative(this.projectRoot, f)), null, 2));
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-artifact.booter.js","sourceRoot":"","sources":["../../src/booters/base-artifact.booter.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"base-artifact.booter.js","sourceRoot":"","sources":["../../src/booters/base-artifact.booter.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;AAGhE,kDAAiC;AACjC,gDAAwB;AAExB,iDAAmE;AAEnE,MAAM,KAAK,GAAG,eAAY,CAAC,oCAAoC,CAAC,CAAC;AAEjE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,kBAAkB;IA+B7B,YAAY,WAAmB,EAAE,OAAwB;QACvD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI;YAC3B,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;gBAChC,CAAC,CAAC,IAAI,CAAC,OAAO,CAA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,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAC5D,IAAI,EACJ,CAAC,CACF,CACF,CAAC;SACH;IACH,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,OAAO,GAAG,mCAAoB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACzE,CAAC;CACF;AA/GD,gDA+GC"}
|
|
@@ -3,12 +3,15 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
6
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
8
|
-
const
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
9
12
|
const util_1 = require("util");
|
|
10
13
|
const glob = util_1.promisify(require('glob'));
|
|
11
|
-
const debug =
|
|
14
|
+
const debug = debug_1.default('loopback:boot:booter-utils');
|
|
12
15
|
/**
|
|
13
16
|
* Returns all files matching the given glob pattern relative to root
|
|
14
17
|
*
|
|
@@ -43,7 +46,7 @@ exports.isClass = isClass;
|
|
|
43
46
|
function loadClassesFromFiles(files, projectRootDir) {
|
|
44
47
|
const classes = [];
|
|
45
48
|
for (const file of files) {
|
|
46
|
-
debug('Loading artifact file %j',
|
|
49
|
+
debug('Loading artifact file %j', path_1.default.relative(projectRootDir, file));
|
|
47
50
|
const moduleObj = require(file);
|
|
48
51
|
for (const k in moduleObj) {
|
|
49
52
|
const exported = moduleObj[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"booter-utils.js","sourceRoot":"","sources":["../../src/booters/booter-utils.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8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IAAI,CAAC,CAAC;gBAC/C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aACxB;iBAAM;gBACL,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;aACjC;SACF;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AApBD,oDAoBC"}
|
package/dist/booters/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export * from './controller.booter';
|
|
|
5
5
|
export * from './datasource.booter';
|
|
6
6
|
export * from './interceptor.booter';
|
|
7
7
|
export * from './lifecyle-observer.booter';
|
|
8
|
+
export * from './model-api.booter';
|
|
8
9
|
export * from './repository.booter';
|
|
9
10
|
export * from './service.booter';
|
package/dist/booters/index.js
CHANGED
|
@@ -14,6 +14,7 @@ __export(require("./controller.booter"));
|
|
|
14
14
|
__export(require("./datasource.booter"));
|
|
15
15
|
__export(require("./interceptor.booter"));
|
|
16
16
|
__export(require("./lifecyle-observer.booter"));
|
|
17
|
+
__export(require("./model-api.booter"));
|
|
17
18
|
__export(require("./repository.booter"));
|
|
18
19
|
__export(require("./service.booter"));
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/booters/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,mDAA8C;AAC9C,4CAAuC;AACvC,oCAA+B;AAC/B,yCAAoC;AACpC,yCAAoC;AACpC,0CAAqC;AACrC,gDAA2C;AAC3C,yCAAoC;AACpC,sCAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/booters/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,mDAA8C;AAC9C,4CAAuC;AACvC,oCAA+B;AAC/B,yCAAoC;AACpC,yCAAoC;AACpC,0CAAqC;AACrC,gDAA2C;AAC3C,wCAAmC;AACnC,yCAAoC;AACpC,sCAAiC"}
|
|
@@ -15,14 +15,17 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
15
15
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
16
16
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
17
17
|
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
18
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
22
|
const context_1 = require("@loopback/context");
|
|
20
23
|
const core_1 = require("@loopback/core");
|
|
21
|
-
const
|
|
24
|
+
const debug_1 = __importDefault(require("debug"));
|
|
22
25
|
const keys_1 = require("../keys");
|
|
23
26
|
const types_1 = require("../types");
|
|
24
27
|
const base_artifact_booter_1 = require("./base-artifact.booter");
|
|
25
|
-
const debug =
|
|
28
|
+
const debug = debug_1.default('loopback:boot:interceptor-booter');
|
|
26
29
|
/**
|
|
27
30
|
* A class that extends BaseArtifactBooter to boot the 'InterceptorProvider' artifact type.
|
|
28
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interceptor.booter.js","sourceRoot":"","sources":["../../src/booters/interceptor.booter.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"interceptor.booter.js","sourceRoot":"","sources":["../../src/booters/interceptor.booter.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;;;;AAEhE,+CAQ2B;AAC3B,yCAAyD;AACzD,kDAAiC;AACjC,kCAAqC;AACrC,oCAAiD;AACjD,iEAA0D;AAE1D,MAAM,KAAK,GAAG,eAAY,CAAC,kCAAkC,CAAC,CAAC;AAI/D;;;;;;;;GAQG;A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@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
15
15
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
16
16
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
17
17
|
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
18
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
22
|
const context_1 = require("@loopback/context");
|
|
20
23
|
const core_1 = require("@loopback/core");
|
|
21
|
-
const
|
|
24
|
+
const debug_1 = __importDefault(require("debug"));
|
|
22
25
|
const keys_1 = require("../keys");
|
|
23
26
|
const types_1 = require("../types");
|
|
24
27
|
const base_artifact_booter_1 = require("./base-artifact.booter");
|
|
25
|
-
const debug =
|
|
28
|
+
const debug = debug_1.default('loopback:boot:lifecycle-observer-booter');
|
|
26
29
|
/**
|
|
27
30
|
* A class that extends BaseArtifactBooter to boot the 'LifeCycleObserver' artifact type.
|
|
28
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecyle-observer.booter.js","sourceRoot":"","sources":["../../src/booters/lifecyle-observer.booter.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,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,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;;;;AAEhE,+CAA8D;AAC9D,yCAKwB;AACxB,kDAAiC;AACjC,kCAAqC;AACrC,oCAAiD;AACjD,iEAA0D;AAE1D,MAAM,KAAK,GAAG,eAAY,CAAC,yCAAyC,CAAC,CAAC;AAItE;;;;;;;;GAQG;AAEH,IAAa,uBAAuB,GAApC,MAAa,uBAAwB,SAAQ,yCAAkB;IAG7D,YAES,GAAgB,EACY,WAAmB,EAE/C,iBAAkC,EAAE;QAE3C,KAAK,CACH,WAAW;QACX,mEAAmE;QACnE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,iCAAyB,EAAE,cAAc,CAAC,CAC7D,CAAC;QATK,QAAG,GAAH,GAAG,CAAa;QAGhB,mBAAc,GAAd,cAAc,CAAsB;IAO7C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QAEnB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,+BAAwB,CAAC,CAAC;QAC/D,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;YACrC,KAAK,CAAC,8BAA8B,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YACrD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;YACrD,KAAK,CAAC,6CAA6C,EAAE,OAAO,CAAC,CAAC;SAC/D;IACH,CAAC;CACF,CAAA;AA/BY,uBAAuB;IADnC,cAAM,CAAC,WAAW,CAAC;IAKf,WAAA,gBAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;IAEzC,WAAA,gBAAM,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAA;IACjC,WAAA,gBAAM,EAAE,CAAA;qCAFG,kBAAW;GALd,uBAAuB,CA+BnC;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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Getter } from '@loopback/core';
|
|
2
|
+
import { ModelApiBuilder } from '@loopback/model-api-builder';
|
|
3
|
+
import { ApplicationWithRepositories } from '@loopback/repository';
|
|
4
|
+
import { ArtifactOptions } from '../types';
|
|
5
|
+
import { BaseArtifactBooter } from './base-artifact.booter';
|
|
6
|
+
export declare class ModelApiBooter extends BaseArtifactBooter {
|
|
7
|
+
app: ApplicationWithRepositories;
|
|
8
|
+
getModelApiBuilders: Getter<ModelApiBuilder[]>;
|
|
9
|
+
booterConfig: ArtifactOptions;
|
|
10
|
+
constructor(app: ApplicationWithRepositories, projectRoot: string, getModelApiBuilders: Getter<ModelApiBuilder[]>, booterConfig?: ArtifactOptions);
|
|
11
|
+
/**
|
|
12
|
+
* Load the the model config files
|
|
13
|
+
*/
|
|
14
|
+
load(): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Set up the loaded model classes
|
|
17
|
+
*/
|
|
18
|
+
setupModel(configFile: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieve the API builder that matches the pattern provided
|
|
21
|
+
* @param pattern - name of pattern for an API builder
|
|
22
|
+
*/
|
|
23
|
+
getApiBuilderForPattern(pattern: string): Promise<ModelApiBuilder>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Default ArtifactOptions for ControllerBooter.
|
|
27
|
+
*/
|
|
28
|
+
export declare const RestDefaults: ArtifactOptions;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2019. 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
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
13
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
14
|
+
};
|
|
15
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
16
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
17
|
+
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
25
|
+
result["default"] = mod;
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const core_1 = require("@loopback/core");
|
|
30
|
+
const model_api_builder_1 = require("@loopback/model-api-builder");
|
|
31
|
+
const debug_1 = __importDefault(require("debug"));
|
|
32
|
+
const path = __importStar(require("path"));
|
|
33
|
+
const keys_1 = require("../keys");
|
|
34
|
+
const types_1 = require("../types");
|
|
35
|
+
const base_artifact_booter_1 = require("./base-artifact.booter");
|
|
36
|
+
const debug = debug_1.default('loopback:boot:model-api');
|
|
37
|
+
let ModelApiBooter = class ModelApiBooter extends base_artifact_booter_1.BaseArtifactBooter {
|
|
38
|
+
constructor(app, projectRoot, getModelApiBuilders, booterConfig = {}) {
|
|
39
|
+
// TODO assert that `app` has RepositoryMixin members
|
|
40
|
+
super(projectRoot,
|
|
41
|
+
// Set booter options if passed in via bootConfig
|
|
42
|
+
Object.assign({}, exports.RestDefaults, booterConfig));
|
|
43
|
+
this.app = app;
|
|
44
|
+
this.getModelApiBuilders = getModelApiBuilders;
|
|
45
|
+
this.booterConfig = booterConfig;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Load the the model config files
|
|
49
|
+
*/
|
|
50
|
+
async load() {
|
|
51
|
+
// Important: don't call `super.load()` here, it would try to load
|
|
52
|
+
// classes via `loadClassesFromFiles` - that won't work for JSON files
|
|
53
|
+
await Promise.all(this.discovered.map(async (f) => {
|
|
54
|
+
try {
|
|
55
|
+
// It's important to await before returning,
|
|
56
|
+
// otherwise the catch block won't receive errors
|
|
57
|
+
await this.setupModel(f);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
const shortPath = path.relative(this.projectRoot, f);
|
|
61
|
+
err.message += ` (while loading ${shortPath})`;
|
|
62
|
+
throw err;
|
|
63
|
+
}
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Set up the loaded model classes
|
|
68
|
+
*/
|
|
69
|
+
async setupModel(configFile) {
|
|
70
|
+
const cfg = require(configFile);
|
|
71
|
+
debug('Loaded model config from %s', path.relative(this.projectRoot, configFile), cfg);
|
|
72
|
+
const modelClass = cfg.model;
|
|
73
|
+
if (typeof modelClass !== 'function') {
|
|
74
|
+
throw new Error(`Invalid "model" field. Expected a Model class, found ${modelClass}`);
|
|
75
|
+
}
|
|
76
|
+
const builder = await this.getApiBuilderForPattern(cfg.pattern);
|
|
77
|
+
await builder.build(this.app, modelClass, cfg);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Retrieve the API builder that matches the pattern provided
|
|
81
|
+
* @param pattern - name of pattern for an API builder
|
|
82
|
+
*/
|
|
83
|
+
async getApiBuilderForPattern(pattern) {
|
|
84
|
+
const allBuilders = await this.getModelApiBuilders();
|
|
85
|
+
const builder = allBuilders.find(b => b.pattern === pattern);
|
|
86
|
+
if (!builder) {
|
|
87
|
+
const availableBuilders = allBuilders.map(b => b.pattern).join(', ');
|
|
88
|
+
throw new Error(`Unsupported API pattern "${pattern}". ` +
|
|
89
|
+
`Available patterns: ${availableBuilders || '<none>'}`);
|
|
90
|
+
}
|
|
91
|
+
return builder;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
ModelApiBooter = __decorate([
|
|
95
|
+
types_1.booter('modelApi'),
|
|
96
|
+
core_1.extensionPoint(model_api_builder_1.MODEL_API_BUILDER_PLUGINS),
|
|
97
|
+
__param(0, core_1.inject(core_1.CoreBindings.APPLICATION_INSTANCE)),
|
|
98
|
+
__param(1, core_1.inject(keys_1.BootBindings.PROJECT_ROOT)),
|
|
99
|
+
__param(2, core_1.extensions()),
|
|
100
|
+
__param(3, core_1.config()),
|
|
101
|
+
__metadata("design:paramtypes", [Object, String, Function, Object])
|
|
102
|
+
], ModelApiBooter);
|
|
103
|
+
exports.ModelApiBooter = ModelApiBooter;
|
|
104
|
+
/**
|
|
105
|
+
* Default ArtifactOptions for ControllerBooter.
|
|
106
|
+
*/
|
|
107
|
+
exports.RestDefaults = {
|
|
108
|
+
dirs: ['model-endpoints'],
|
|
109
|
+
extensions: ['-config.js'],
|
|
110
|
+
nested: true,
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=model-api.booter.js.map
|
|
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;AAEhE,yCAOwB;AACxB,mEAIqC;AAErC,kDAAiC;AACjC,2CAA6B;AAC7B,kCAAqC;AACrC,oCAAiD;AACjD,iEAA0D;AAE1D,MAAM,KAAK,GAAG,eAAY,CAAC,yBAAyB,CAAC,CAAC;AAItD,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,yCAAkB;IACpD,YAES,GAAgC,EACJ,WAAmB,EAE/C,mBAA8C,EAE9C,eAAgC,EAAE;QAEzC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MAAM,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,uBAAuB,CAAC,OAAe;QAC3C,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACrD,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;QAC7D,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrE,MAAM,IAAI,KAAK,CACb,4BAA4B,OAAO,KAAK;gBACtC,uBAAuB,iBAAiB,IAAI,QAAQ,EAAE,CACzD,CAAC;SACH;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AA9EY,cAAc;IAF1B,cAAM,CAAC,UAAU,CAAC;IAClB,qBAAc,CAAC,6CAAyB,CAAC;IAGrC,WAAA,aAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;IAEzC,WAAA,aAAM,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAA;IACjC,WAAA,iBAAU,EAAE,CAAA;IAEZ,WAAA,aAAM,EAAE,CAAA;;GAPA,cAAc,CA8E1B;AA9EY,wCAAc;AAgF3B;;GAEG;AACU,QAAA,YAAY,GAAoB;IAC3C,IAAI,EAAE,CAAC,iBAAiB,CAAC;IACzB,UAAU,EAAE,CAAC,YAAY,CAAC;IAC1B,MAAM,EAAE,IAAI;CACb,CAAC"}
|
|
@@ -15,14 +15,17 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
15
15
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
16
16
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
17
17
|
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
18
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
22
|
const context_1 = require("@loopback/context");
|
|
20
23
|
const core_1 = require("@loopback/core");
|
|
21
|
-
const
|
|
24
|
+
const debug_1 = __importDefault(require("debug"));
|
|
22
25
|
const keys_1 = require("../keys");
|
|
23
26
|
const types_1 = require("../types");
|
|
24
27
|
const base_artifact_booter_1 = require("./base-artifact.booter");
|
|
25
|
-
const debug =
|
|
28
|
+
const debug = debug_1.default('loopback:boot:service-booter');
|
|
26
29
|
/**
|
|
27
30
|
* A class that extends BaseArtifactBooter to boot the 'Service' artifact type.
|
|
28
31
|
* Discovered DataSources are bound using `app.controller()`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.booter.js","sourceRoot":"","sources":["../../src/booters/service.booter.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"service.booter.js","sourceRoot":"","sources":["../../src/booters/service.booter.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;;;;AAEhE,+CAM2B;AAC3B,yCAA4C;AAE5C,kDAAiC;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,CAA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AAO,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.js
CHANGED
|
@@ -15,15 +15,18 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
15
15
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
16
16
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
17
17
|
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
18
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
22
|
const context_1 = require("@loopback/context");
|
|
20
23
|
const core_1 = require("@loopback/core");
|
|
21
|
-
const
|
|
24
|
+
const debug_1 = __importDefault(require("debug"));
|
|
22
25
|
const path_1 = require("path");
|
|
23
26
|
const keys_1 = require("./keys");
|
|
24
27
|
const mixins_1 = require("./mixins");
|
|
25
28
|
const types_1 = require("./types");
|
|
26
|
-
const debug =
|
|
29
|
+
const debug = debug_1.default('loopback:boot:bootstrapper');
|
|
27
30
|
/**
|
|
28
31
|
* The Bootstrapper class provides the `boot` function that is responsible for
|
|
29
32
|
* finding and executing the Booters in an application based on given options.
|
|
@@ -62,10 +65,11 @@ let Bootstrapper = class Bootstrapper {
|
|
|
62
65
|
* may maintain state.
|
|
63
66
|
*/
|
|
64
67
|
async boot(execOptions, ctx) {
|
|
65
|
-
|
|
68
|
+
var _a;
|
|
69
|
+
const bootCtx = (ctx !== null && ctx !== void 0 ? ctx : new context_1.Context(this.app));
|
|
66
70
|
// Bind booters passed in as a part of BootOptions
|
|
67
71
|
// We use _bindBooter so this Class can be used without the Mixin
|
|
68
|
-
if (execOptions
|
|
72
|
+
if ((_a = execOptions) === null || _a === void 0 ? void 0 : _a.booters) {
|
|
69
73
|
execOptions.booters.forEach(booter => mixins_1._bindBooter(this.app, booter));
|
|
70
74
|
}
|
|
71
75
|
// Determine the phases to be run. If a user set a phases filter, those
|
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
|
|
1
|
+
{"version":3,"file":"bootstrapper.js","sourceRoot":"","sources":["../src/bootstrapper.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;;;;AAEhE,+CAA+D;AAC/D,yCAAyD;AACzD,kDAAgC;AAChC,+BAA6B;AAC7B,iCAA8C;AAC9C,qCAAqC;AACrC,mCAKiB;AAEjB,MAAM,KAAK,GAAG,eAAW,CAAC,4BAA4B,CAAC,CAAC;AAExD;;;;;;;;;;GAUG;AACH,IAAa,YAAY,GAAzB,MAAa,YAAY;IACvB,YAEU,GAA2B,EACQ,WAAmB,EAEtD,cAA2B,EAAE;QAH7B,QAAG,GAAH,GAAG,CAAwB;QACQ,gBAAW,GAAX,WAAW,CAAQ;QAEtD,gBAAW,GAAX,WAAW,CAAkB;QAErC,0CAA0C;QAC1C,IAAI,CAAC,WAAW,GAAG,cAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC7C,GAAG,CAAC,IAAI,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEzD,+EAA+E;QAC/E,mDAAmD;QACnD,GAAG,CAAC,IAAI,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,WA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
|
|
|
45
45
|
* Convenience method to call bootstrapper.boot() by resolving bootstrapper
|
|
46
46
|
*/
|
|
47
47
|
async boot() {
|
|
48
|
+
if (this.state === 'booting')
|
|
49
|
+
return this.awaitState('booted');
|
|
50
|
+
this.assertNotInProcess('boot');
|
|
51
|
+
this.assertInStates('boot', 'created', 'booted');
|
|
52
|
+
if (this.state === 'booted')
|
|
53
|
+
return;
|
|
54
|
+
this.setState('booting');
|
|
48
55
|
// Get a instance of the BootStrapper
|
|
49
56
|
const bootstrapper = await this.get(keys_1.BootBindings.BOOTSTRAPPER_KEY);
|
|
50
57
|
await bootstrapper.boot();
|
|
58
|
+
this.setState('booted');
|
|
51
59
|
}
|
|
52
60
|
/**
|
|
53
61
|
* Given a N number of Booter Classes, this method binds them using the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot.mixin.js","sourceRoot":"","sources":["../../src/mixins/boot.mixin.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;AAEhE,+CAM2B;AAQnB,kBAbN,iBAAO,CAaM;AAPf,sDAAgD;AAEhD,kCAA+C;AAO/C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,8DAA8D;AAC9D,SAAgB,SAAS,CAA6B,UAAa;IACjE,OAAO,KAAM,SAAQ,UAAU;QAI7B,8DAA8D;QAC9D,YAAY,GAAG,IAAW;YACxB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACf,IAAI,CAAC,SAAS,CAAC,8BAAa,CAAC,CAAC;YAE9B,4EAA4E;YAC5E,gFAAgF;YAChF,IAAI,CAAC,IAAI,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAC,cAAc,CACjD,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CACvB,CAAC;YACF,IAAI,CAAC,IAAI,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAC,cAAc,CACjD,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,C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AAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACjB;;;OAGG;IACH,IAAI,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE;QACpC,GAAG;aACA,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC;aACtB,OAAO,CACN,GAAG,mBAAY,CAAC,YAAY,CAAC,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,CACvE,CAAC;KACL;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AArBD,kCAqBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopback/boot",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "A collection of Booters for LoopBack 4 Applications",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=8.9"
|
|
@@ -22,22 +22,23 @@
|
|
|
22
22
|
"copyright.owner": "IBM Corp.",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@loopback/context": "^
|
|
26
|
-
"@loopback/core": "^1.
|
|
27
|
-
"@loopback/
|
|
28
|
-
"@loopback/
|
|
25
|
+
"@loopback/context": "^2.0.0",
|
|
26
|
+
"@loopback/core": "^1.12.2",
|
|
27
|
+
"@loopback/model-api-builder": "^1.1.2",
|
|
28
|
+
"@loopback/repository": "^1.18.0",
|
|
29
|
+
"@loopback/service-proxy": "^1.3.15",
|
|
29
30
|
"@types/debug": "^4.1.5",
|
|
30
31
|
"@types/glob": "^7.1.1",
|
|
31
32
|
"debug": "^4.1.1",
|
|
32
33
|
"glob": "^7.1.6"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@loopback/build": "^
|
|
36
|
-
"@loopback/eslint-config": "^
|
|
37
|
-
"@loopback/openapi-v3": "^1.
|
|
38
|
-
"@loopback/rest": "^1.
|
|
39
|
-
"@loopback/testlab": "^1.
|
|
40
|
-
"@types/node": "^10.17.
|
|
36
|
+
"@loopback/build": "^3.1.0",
|
|
37
|
+
"@loopback/eslint-config": "^5.0.2",
|
|
38
|
+
"@loopback/openapi-v3": "^1.12.0",
|
|
39
|
+
"@loopback/rest": "^1.26.0",
|
|
40
|
+
"@loopback/testlab": "^1.10.2",
|
|
41
|
+
"@types/node": "^10.17.13"
|
|
41
42
|
},
|
|
42
43
|
"files": [
|
|
43
44
|
"README.md",
|
|
@@ -52,5 +53,5 @@
|
|
|
52
53
|
"url": "https://github.com/strongloop/loopback-next.git",
|
|
53
54
|
"directory": "packages/boot"
|
|
54
55
|
},
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "d08f135a0d1040edc61497739a8d86a866e4e29a"
|
|
56
57
|
}
|
package/src/boot.component.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
DataSourceBooter,
|
|
12
12
|
InterceptorProviderBooter,
|
|
13
13
|
LifeCycleObserverBooter,
|
|
14
|
+
ModelApiBooter,
|
|
14
15
|
RepositoryBooter,
|
|
15
16
|
ServiceBooter,
|
|
16
17
|
} from './booters';
|
|
@@ -33,6 +34,7 @@ export class BootComponent implements Component {
|
|
|
33
34
|
DataSourceBooter,
|
|
34
35
|
LifeCycleObserverBooter,
|
|
35
36
|
InterceptorProviderBooter,
|
|
37
|
+
ModelApiBooter,
|
|
36
38
|
];
|
|
37
39
|
|
|
38
40
|
/**
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
// This file is licensed under the MIT License.
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
5
5
|
|
|
6
|
-
import {CoreBindings, Application} from '@loopback/core';
|
|
7
6
|
import {inject} from '@loopback/context';
|
|
7
|
+
import {Application, CoreBindings} from '@loopback/core';
|
|
8
|
+
import debugModule from 'debug';
|
|
8
9
|
import {BootBindings} from '../keys';
|
|
9
10
|
import {Booter} from '../types';
|
|
10
11
|
import path = require('path');
|
|
11
12
|
|
|
12
|
-
import * as debugModule from 'debug';
|
|
13
13
|
const debug = debugModule('loopback:boot:booter:application-metadata');
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
5
5
|
|
|
6
6
|
import {Constructor} from '@loopback/context';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import debugFactory from 'debug';
|
|
8
|
+
import path from 'path';
|
|
9
9
|
import {ArtifactOptions, Booter} from '../types';
|
|
10
10
|
import {discoverFiles, loadClassesFromFiles} from './booter-utils';
|
|
11
11
|
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
5
5
|
|
|
6
6
|
import {Constructor} from '@loopback/context';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import debugFactory from 'debug';
|
|
8
|
+
import path from 'path';
|
|
9
9
|
import {promisify} from 'util';
|
|
10
10
|
const glob = promisify(require('glob'));
|
|
11
11
|
|
package/src/booters/index.ts
CHANGED
|
@@ -10,5 +10,6 @@ export * from './controller.booter';
|
|
|
10
10
|
export * from './datasource.booter';
|
|
11
11
|
export * from './interceptor.booter';
|
|
12
12
|
export * from './lifecyle-observer.booter';
|
|
13
|
+
export * from './model-api.booter';
|
|
13
14
|
export * from './repository.booter';
|
|
14
15
|
export * from './service.booter';
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
Provider,
|
|
14
14
|
} from '@loopback/context';
|
|
15
15
|
import {Application, CoreBindings} from '@loopback/core';
|
|
16
|
-
import
|
|
16
|
+
import debugFactory from 'debug';
|
|
17
17
|
import {BootBindings} from '../keys';
|
|
18
18
|
import {ArtifactOptions, booter} from '../types';
|
|
19
19
|
import {BaseArtifactBooter} from './base-artifact.booter';
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
isLifeCycleObserverClass,
|
|
11
11
|
LifeCycleObserver,
|
|
12
12
|
} from '@loopback/core';
|
|
13
|
-
import
|
|
13
|
+
import debugFactory from 'debug';
|
|
14
14
|
import {BootBindings} from '../keys';
|
|
15
15
|
import {ArtifactOptions, booter} from '../types';
|
|
16
16
|
import {BaseArtifactBooter} from './base-artifact.booter';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Copyright IBM Corp. 2019. All Rights Reserved.
|
|
2
|
+
// Node module: @loopback/boot
|
|
3
|
+
// This file is licensed under the MIT License.
|
|
4
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
config,
|
|
8
|
+
CoreBindings,
|
|
9
|
+
extensionPoint,
|
|
10
|
+
extensions,
|
|
11
|
+
Getter,
|
|
12
|
+
inject,
|
|
13
|
+
} from '@loopback/core';
|
|
14
|
+
import {
|
|
15
|
+
ModelApiBuilder,
|
|
16
|
+
ModelApiConfig,
|
|
17
|
+
MODEL_API_BUILDER_PLUGINS,
|
|
18
|
+
} from '@loopback/model-api-builder';
|
|
19
|
+
import {ApplicationWithRepositories} from '@loopback/repository';
|
|
20
|
+
import debugFactory from 'debug';
|
|
21
|
+
import * as path from 'path';
|
|
22
|
+
import {BootBindings} from '../keys';
|
|
23
|
+
import {ArtifactOptions, booter} from '../types';
|
|
24
|
+
import {BaseArtifactBooter} from './base-artifact.booter';
|
|
25
|
+
|
|
26
|
+
const debug = debugFactory('loopback:boot:model-api');
|
|
27
|
+
|
|
28
|
+
@booter('modelApi')
|
|
29
|
+
@extensionPoint(MODEL_API_BUILDER_PLUGINS)
|
|
30
|
+
export class ModelApiBooter extends BaseArtifactBooter {
|
|
31
|
+
constructor(
|
|
32
|
+
@inject(CoreBindings.APPLICATION_INSTANCE)
|
|
33
|
+
public app: ApplicationWithRepositories,
|
|
34
|
+
@inject(BootBindings.PROJECT_ROOT) projectRoot: string,
|
|
35
|
+
@extensions()
|
|
36
|
+
public getModelApiBuilders: Getter<ModelApiBuilder[]>,
|
|
37
|
+
@config()
|
|
38
|
+
public booterConfig: ArtifactOptions = {},
|
|
39
|
+
) {
|
|
40
|
+
// TODO assert that `app` has RepositoryMixin members
|
|
41
|
+
|
|
42
|
+
super(
|
|
43
|
+
projectRoot,
|
|
44
|
+
// Set booter options if passed in via bootConfig
|
|
45
|
+
Object.assign({}, RestDefaults, booterConfig),
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Load the the model config files
|
|
51
|
+
*/
|
|
52
|
+
async load(): Promise<void> {
|
|
53
|
+
// Important: don't call `super.load()` here, it would try to load
|
|
54
|
+
// classes via `loadClassesFromFiles` - that won't work for JSON files
|
|
55
|
+
await Promise.all(
|
|
56
|
+
this.discovered.map(async f => {
|
|
57
|
+
try {
|
|
58
|
+
// It's important to await before returning,
|
|
59
|
+
// otherwise the catch block won't receive errors
|
|
60
|
+
await this.setupModel(f);
|
|
61
|
+
} catch (err) {
|
|
62
|
+
const shortPath = path.relative(this.projectRoot, f);
|
|
63
|
+
err.message += ` (while loading ${shortPath})`;
|
|
64
|
+
throw err;
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Set up the loaded model classes
|
|
72
|
+
*/
|
|
73
|
+
async setupModel(configFile: string): Promise<void> {
|
|
74
|
+
const cfg: ModelApiConfig = require(configFile);
|
|
75
|
+
debug(
|
|
76
|
+
'Loaded model config from %s',
|
|
77
|
+
path.relative(this.projectRoot, configFile),
|
|
78
|
+
cfg,
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const modelClass = cfg.model;
|
|
82
|
+
if (typeof modelClass !== 'function') {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Invalid "model" field. Expected a Model class, found ${modelClass}`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const builder = await this.getApiBuilderForPattern(cfg.pattern);
|
|
89
|
+
await builder.build(this.app, modelClass, cfg);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Retrieve the API builder that matches the pattern provided
|
|
94
|
+
* @param pattern - name of pattern for an API builder
|
|
95
|
+
*/
|
|
96
|
+
async getApiBuilderForPattern(pattern: string): Promise<ModelApiBuilder> {
|
|
97
|
+
const allBuilders = await this.getModelApiBuilders();
|
|
98
|
+
const builder = allBuilders.find(b => b.pattern === pattern);
|
|
99
|
+
if (!builder) {
|
|
100
|
+
const availableBuilders = allBuilders.map(b => b.pattern).join(', ');
|
|
101
|
+
throw new Error(
|
|
102
|
+
`Unsupported API pattern "${pattern}". ` +
|
|
103
|
+
`Available patterns: ${availableBuilders || '<none>'}`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
return builder;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Default ArtifactOptions for ControllerBooter.
|
|
112
|
+
*/
|
|
113
|
+
export const RestDefaults: ArtifactOptions = {
|
|
114
|
+
dirs: ['model-endpoints'],
|
|
115
|
+
extensions: ['-config.js'],
|
|
116
|
+
nested: true,
|
|
117
|
+
};
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from '@loopback/context';
|
|
13
13
|
import {CoreBindings} from '@loopback/core';
|
|
14
14
|
import {ApplicationWithServices} from '@loopback/service-proxy';
|
|
15
|
-
import
|
|
15
|
+
import debugFactory from 'debug';
|
|
16
16
|
import {BootBindings} from '../keys';
|
|
17
17
|
import {ArtifactOptions, booter} from '../types';
|
|
18
18
|
import {BaseArtifactBooter} from './base-artifact.booter';
|
package/src/bootstrapper.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import {Context, inject, resolveList} from '@loopback/context';
|
|
7
7
|
import {Application, CoreBindings} from '@loopback/core';
|
|
8
|
-
import
|
|
8
|
+
import debugModule from 'debug';
|
|
9
9
|
import {resolve} from 'path';
|
|
10
10
|
import {BootBindings, BootTags} from './keys';
|
|
11
11
|
import {_bindBooter} from './mixins';
|
|
@@ -64,11 +64,11 @@ export class Bootstrapper {
|
|
|
64
64
|
execOptions?: BootExecutionOptions,
|
|
65
65
|
ctx?: Context,
|
|
66
66
|
): Promise<Context> {
|
|
67
|
-
const bootCtx = ctx
|
|
67
|
+
const bootCtx = ctx ?? new Context(this.app);
|
|
68
68
|
|
|
69
69
|
// Bind booters passed in as a part of BootOptions
|
|
70
70
|
// We use _bindBooter so this Class can be used without the Mixin
|
|
71
|
-
if (execOptions
|
|
71
|
+
if (execOptions?.booters) {
|
|
72
72
|
execOptions.booters.forEach(booter => _bindBooter(this.app, booter));
|
|
73
73
|
}
|
|
74
74
|
|
package/src/mixins/boot.mixin.ts
CHANGED
|
@@ -65,12 +65,18 @@ export function BootMixin<T extends Constructor<any>>(superClass: T) {
|
|
|
65
65
|
* Convenience method to call bootstrapper.boot() by resolving bootstrapper
|
|
66
66
|
*/
|
|
67
67
|
async boot(): Promise<void> {
|
|
68
|
+
if (this.state === 'booting') return this.awaitState('booted');
|
|
69
|
+
this.assertNotInProcess('boot');
|
|
70
|
+
this.assertInStates('boot', 'created', 'booted');
|
|
71
|
+
if (this.state === 'booted') return;
|
|
72
|
+
this.setState('booting');
|
|
68
73
|
// Get a instance of the BootStrapper
|
|
69
74
|
const bootstrapper: Bootstrapper = await this.get(
|
|
70
75
|
BootBindings.BOOTSTRAPPER_KEY,
|
|
71
76
|
);
|
|
72
77
|
|
|
73
78
|
await bootstrapper.boot();
|
|
79
|
+
this.setState('booted');
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
/**
|