@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.
Files changed (100) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/.sandbox/{11889PRvhvm → 635411GGsm1}/model-endpoints/no-entity.rest-config.js +0 -0
  3. package/dist/.sandbox/635411GGsm1/models/no-entity.model.js +28 -0
  4. package/dist/.sandbox/{11889wtTpPA → 635415cxfJi}/service-provider.artifact.js +1 -0
  5. package/dist/.sandbox/{118893KtxoA → 635419mu8mo}/application.js +1 -0
  6. package/dist/.sandbox/{11889S6GDvS → 635419mu8mo}/services/bindable-classes.service.js +26 -19
  7. package/dist/.sandbox/{11889S6GDvS → 635419mu8mo}/services/geocoder.service.js +1 -0
  8. package/dist/.sandbox/{11889S6GDvS → 635419mu8mo}/services/greeting.service.js +1 -0
  9. package/dist/.sandbox/{11889K8KL2J → 635419t6TqH}/datasource.artifact.js +9 -5
  10. package/dist/.sandbox/63541BtDxTa/multiple.artifact.js +45 -0
  11. package/dist/.sandbox/{11889CQQ0nI → 63541DlS0Ic}/application.js +1 -0
  12. package/dist/.sandbox/63541DlS0Ic/repositories/multiple.repository.js +45 -0
  13. package/dist/.sandbox/{118896Rj4ze → 63541DshyBF}/application.js +1 -0
  14. package/dist/.sandbox/{118893KtxoA → 63541DshyBF}/observers/lifecycle-observer.observer.js +1 -0
  15. package/dist/.sandbox/{11889DQbyT8 → 63541IEce5V}/application.js +1 -0
  16. package/dist/.sandbox/{11889zAsxZb → 63541IEce5V}/datasources/db.datasource.js +9 -5
  17. package/dist/.sandbox/63541ik89oh/application.js +20 -0
  18. package/dist/.sandbox/63541ik89oh/models/multiple-models.model.js +16 -0
  19. package/dist/.sandbox/63541ik89oh/models/no-entity.model.js +28 -0
  20. package/dist/.sandbox/63541ik89oh/models/product.model.js +28 -0
  21. package/dist/.sandbox/63541meTxP7/application.js +20 -0
  22. package/dist/.sandbox/63541meTxP7/controllers/multiple.controller.js +45 -0
  23. package/dist/.sandbox/{11889DQbyT8 → 63541meTxP7}/package.json +0 -0
  24. package/dist/.sandbox/63541nGmQFL/application.js +20 -0
  25. package/dist/.sandbox/63541nGmQFL/controllers/multiple.controller.js +45 -0
  26. package/dist/.sandbox/{11889mdaOd9 → 63541odlHvc}/model-endpoints/product.rest-config.js +0 -0
  27. package/dist/.sandbox/63541odlHvc/models/product.model.js +28 -0
  28. package/dist/.sandbox/63541ruUDNf/application.js +20 -0
  29. package/dist/.sandbox/63541ruUDNf/interceptors/interceptor.interceptor.js +54 -0
  30. package/dist/.sandbox/63541ruUDNf/interceptors/non-global-interceptor.interceptor.js +54 -0
  31. package/dist/.sandbox/63541vSi6af/multiple.artifact.js +45 -0
  32. package/dist/.sandbox/application.js +20 -0
  33. package/dist/.sandbox/controllers/multiple.controller.js +45 -0
  34. package/dist/boot.component.d.ts +2 -2
  35. package/dist/boot.component.js +34 -29
  36. package/dist/boot.component.js.map +1 -1
  37. package/dist/booters/application-metadata.booter.js +23 -19
  38. package/dist/booters/application-metadata.booter.js.map +1 -1
  39. package/dist/booters/base-artifact.booter.js +1 -0
  40. package/dist/booters/base-artifact.booter.js.map +1 -1
  41. package/dist/booters/booter-utils.js +1 -0
  42. package/dist/booters/booter-utils.js.map +1 -1
  43. package/dist/booters/component-application.booter.d.ts +25 -0
  44. package/dist/booters/component-application.booter.js +99 -0
  45. package/dist/booters/component-application.booter.js.map +1 -0
  46. package/dist/booters/controller.booter.js +30 -26
  47. package/dist/booters/controller.booter.js.map +1 -1
  48. package/dist/booters/datasource.booter.d.ts +1 -1
  49. package/dist/booters/datasource.booter.js +40 -36
  50. package/dist/booters/datasource.booter.js.map +1 -1
  51. package/dist/booters/index.d.ts +2 -0
  52. package/dist/booters/index.js +2 -0
  53. package/dist/booters/index.js.map +1 -1
  54. package/dist/booters/interceptor.booter.js +32 -31
  55. package/dist/booters/interceptor.booter.js.map +1 -1
  56. package/dist/booters/lifecyle-observer.booter.js +32 -28
  57. package/dist/booters/lifecyle-observer.booter.js.map +1 -1
  58. package/dist/booters/model-api.booter.js +67 -63
  59. package/dist/booters/model-api.booter.js.map +1 -1
  60. package/dist/booters/model.booter.d.ts +26 -0
  61. package/dist/booters/model.booter.js +74 -0
  62. package/dist/booters/model.booter.js.map +1 -0
  63. package/dist/booters/repository.booter.js +39 -35
  64. package/dist/booters/repository.booter.js.map +1 -1
  65. package/dist/booters/service.booter.d.ts +1 -1
  66. package/dist/booters/service.booter.js +34 -30
  67. package/dist/booters/service.booter.js.map +1 -1
  68. package/dist/bootstrapper.js +85 -81
  69. package/dist/bootstrapper.js.map +1 -1
  70. package/dist/keys.js +1 -0
  71. package/dist/keys.js.map +1 -1
  72. package/dist/mixins/boot.mixin.d.ts +84 -15
  73. package/dist/mixins/boot.mixin.js +40 -20
  74. package/dist/mixins/boot.mixin.js.map +1 -1
  75. package/dist/types.js +1 -0
  76. package/dist/types.js.map +1 -1
  77. package/package.json +17 -17
  78. package/src/boot.component.ts +2 -0
  79. package/src/booters/component-application.booter.ts +123 -0
  80. package/src/booters/datasource.booter.ts +1 -1
  81. package/src/booters/index.ts +2 -0
  82. package/src/booters/interceptor.booter.ts +1 -6
  83. package/src/booters/model.booter.ts +76 -0
  84. package/src/booters/service.booter.ts +1 -1
  85. package/src/mixins/boot.mixin.ts +84 -20
  86. package/dist/.sandbox/118896Rj4ze/repositories/multiple.repository.js +0 -38
  87. package/dist/.sandbox/11889CQQ0nI/controllers/multiple.controller.js +0 -38
  88. package/dist/.sandbox/11889DQbyT8/controllers/multiple.controller.js +0 -38
  89. package/dist/.sandbox/11889PRvhvm/models/no-entity.model.js +0 -24
  90. package/dist/.sandbox/11889S6GDvS/application.js +0 -19
  91. package/dist/.sandbox/11889SgiPny/multiple.artifact.js +0 -38
  92. package/dist/.sandbox/11889SuGYhr/application.js +0 -19
  93. package/dist/.sandbox/11889SuGYhr/interceptors/interceptor.interceptor.js +0 -50
  94. package/dist/.sandbox/11889SuGYhr/interceptors/non-global-interceptor.interceptor.js +0 -50
  95. package/dist/.sandbox/11889mdaOd9/models/product.model.js +0 -24
  96. package/dist/.sandbox/11889t5aVl4/multiple.artifact.js +0 -38
  97. package/dist/.sandbox/11889zAsxZb/application.js +0 -19
  98. package/dist/.sandbox/dist/application.js +0 -19
  99. package/index.d.ts +0 -6
  100. 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;;;AAEhE,+CAAiD;AACjD,yCAAyD;AACzD,kCAAqC;AACrC,oCAAiD;AACjD,iEAA0D;AAE1D;;;;;;;;;GASG;AAEH,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,yCAAkB;IACtD,YACoD,GAAgB,EAC/B,WAAmB,EAE/C,mBAAoC,EAAE;QAE7C,KAAK,CACH,WAAW;QACX,4DAA4D;QAC5D,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,0BAAkB,EAAE,gBAAgB,CAAC,CACxD,CAAC;QATgD,QAAG,GAAH,GAAG,CAAa;QAG3D,qBAAgB,GAAhB,gBAAgB,CAAsB;IAO/C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACzB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAxBY,gBAAgB;IAD5B,cAAM,CAAC,aAAa,CAAC;IAGjB,mBAAA,gBAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;IACzC,mBAAA,gBAAM,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAA;IACjC,mBAAA,gBAAM,EAAE,CA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AFzD,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.controller()`.
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.controller()`.
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 DataSourceBooter extends base_artifact_booter_1.BaseArtifactBooter {
24
- constructor(app, projectRoot, datasourceConfig = {}) {
25
- super(projectRoot,
26
- // Set DataSource Booter Options if passed in via bootConfig
27
- Object.assign({}, exports.DataSourceDefaults, datasourceConfig));
28
- this.app = app;
29
- this.datasourceConfig = datasourceConfig;
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
- * If DataSource Classes were discovered, we need to make sure RepositoryMixin
39
- * was used (so we have `app.dataSource()`) to perform the binding of a
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
- if (this.classes.length > 0) {
43
- if (!this.app.dataSource) {
44
- console.warn('app.dataSource() function is needed for DataSourceBooter. You can add ' +
45
- 'it to your Application using RepositoryMixin from @loopback/repository.');
46
- }
47
- else {
48
- this.classes.forEach(cls => {
49
- this.app.dataSource(cls);
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
- DataSourceBooter = tslib_1.__decorate([
56
- types_1.booter('datasources'),
57
- tslib_1.__param(0, context_1.inject(core_1.CoreBindings.APPLICATION_INSTANCE)),
58
- tslib_1.__param(1, context_1.inject(keys_1.BootBindings.PROJECT_ROOT)),
59
- tslib_1.__param(2, context_1.config()),
60
- tslib_1.__metadata("design:paramtypes", [Object, String, Object])
61
- ], DataSourceBooter);
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;;;AAEhE,+CAAiD;AACjD,yCAA4C;AAM5C,kCAAqC;AACrC,oCAAiD;AACjD,iEAA0D;AAE1D;;;;;;;;;GASG;AAEH,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,yCAAkB;IACtD,YAES,GAAgC,EACJ,WAAmB,EAE/C,mBAAoC,EAAE;QAE7C,KAAK,CACH,WAAW;QACX,4DAA4D;QAC5D,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,0BAAkB,EAAE,gBAAgB,CAAC,CACxD,CAAC;QATK,QAAG,GAAH,GAAG,CAA6B;QAGhC,qBAAgB,GAAhB,gBAAgB,CAAsB;IAO/C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QAEnB;;;;WAIG;QACH,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE;gBACxB,OAAO,CAAC,IAAI,CACV,wEAAwE;oBACtE,yEAAyE,CAC5E,CAAC;aACH;iBAAM;gBACL,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;oBACzB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAgC,CAAC,CAAC;gBACxD,CAAC,CAAC,CAAC;aACJ;SACF;IACH,CAAC;CACF,CAAA;AAxCY,gBAAgB;IAD5B,cAAM,CAAC,aAAa,CAAC;IAGjB,mBAAA,gBAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;IAEzC,mBAAA,gBAAM,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAA;IACjC,mBAAA,gBAAM,EAAE,CAAA;;GALA,gBAAgB,CAwC5B;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"}
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"}
@@ -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';
@@ -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 InterceptorProviderBooter extends base_artifact_booter_1.BaseArtifactBooter {
25
- constructor(app, projectRoot, interceptorConfig = {}) {
26
- super(projectRoot,
27
- // Set InterceptorProvider Booter Options if passed in via bootConfig
28
- Object.assign({}, exports.InterceptorProviderDefaults, interceptorConfig));
29
- this.app = app;
30
- this.interceptorConfig = interceptorConfig;
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
- InterceptorProviderBooter = tslib_1.__decorate([
50
- types_1.booter('interceptors'),
51
- tslib_1.__param(0, context_1.inject(core_1.CoreBindings.APPLICATION_INSTANCE)),
52
- tslib_1.__param(1, context_1.inject(keys_1.BootBindings.PROJECT_ROOT)),
53
- tslib_1.__param(2, context_1.config()),
54
- tslib_1.__metadata("design:paramtypes", [core_1.Application, String, Object])
55
- ], InterceptorProviderBooter);
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;;;AAEhE,+CAQ2B;AAC3B,yCAAyD;AACzD,0DAAiC;AACjC,kCAAqC;AACrC,oCAAiD;AACjD,iEAA0D;AAE1D,MAAM,KAAK,GAAG,eAAY,CAAC,kCAAkC,CAAC,CAAC;AAI/D;;;;;;;;GAQG;AAEH,IAAa,yBAAyB,GAAtC,MAAa,yBAA0B,SAAQ,yCAAkB;IAG/D,YAES,GAAgB,EACY,WAAmB,EAE/C,oBAAqC,EAAE;QAE9C,KAAK,CACH,WAAW;QACX,qEAAqE;QACrE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,mCAA2B,EAAE,iBAAiB,CAAC,CAClE,CAAC;QATK,QAAG,GAAH,GAAG,CAA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IT 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 LifeCycleObserverBooter extends base_artifact_booter_1.BaseArtifactBooter {
25
- constructor(app, projectRoot, observerConfig = {}) {
26
- super(projectRoot,
27
- // Set LifeCycleObserver Booter Options if passed in via bootConfig
28
- Object.assign({}, exports.LifeCycleObserverDefaults, observerConfig));
29
- this.app = app;
30
- this.observerConfig = observerConfig;
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
- LifeCycleObserverBooter = tslib_1.__decorate([
47
- types_1.booter('observers'),
48
- tslib_1.__param(0, context_1.inject(core_1.CoreBindings.APPLICATION_INSTANCE)),
49
- tslib_1.__param(1, context_1.inject(keys_1.BootBindings.PROJECT_ROOT)),
50
- tslib_1.__param(2, context_1.config()),
51
- tslib_1.__metadata("design:paramtypes", [core_1.Application, String, Object])
52
- ], LifeCycleObserverBooter);
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;;;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,uBAAuB,GAApC,MAAa,uBAAwB,SAAQ,yCAAkB;IAG7D,YAES,GAAgB,EACY,WAAmB,EAE/C,iBAAkC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C,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 ModelApiBooter extends base_artifact_booter_1.BaseArtifactBooter {
17
- constructor(app, projectRoot, getModelApiBuilders, booterConfig = {}) {
18
- // TODO assert that `app` has RepositoryMixin members
19
- super(projectRoot,
20
- // Set booter options if passed in via bootConfig
21
- Object.assign({}, exports.RestDefaults, booterConfig));
22
- this.app = app;
23
- this.getModelApiBuilders = getModelApiBuilders;
24
- this.booterConfig = booterConfig;
25
- }
26
- /**
27
- * Load the the model config files
28
- */
29
- async load() {
30
- // Important: don't call `super.load()` here, it would try to load
31
- // classes via `loadClassesFromFiles` - that won't work for JSON files
32
- await Promise.all(this.discovered.map(async (f) => {
33
- try {
34
- // It's important to await before returning,
35
- // otherwise the catch block won't receive errors
36
- await this.setupModel(f);
37
- }
38
- catch (err) {
39
- const shortPath = path.relative(this.projectRoot, f);
40
- err.message += ` (while loading ${shortPath})`;
41
- throw err;
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
- const builder = await this.getApiBuilderForPattern(cfg.pattern);
56
- await builder.build(this.app, modelClass, cfg);
57
- }
58
- /**
59
- * Retrieve the API builder that matches the pattern provided
60
- * @param pattern - name of pattern for an API builder
61
- */
62
- async getApiBuilderForPattern(pattern) {
63
- const allBuilders = await this.getModelApiBuilders();
64
- const builder = allBuilders.find(b => b.pattern === pattern);
65
- if (!builder) {
66
- const availableBuilders = allBuilders.map(b => b.pattern).join(', ');
67
- throw new Error(`Unsupported API pattern "${pattern}". ` +
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
- return builder;
71
- }
72
- };
73
- ModelApiBooter = tslib_1.__decorate([
74
- types_1.booter('modelApi'),
75
- core_1.extensionPoint(model_api_builder_1.MODEL_API_BUILDER_PLUGINS),
76
- tslib_1.__param(0, core_1.inject(core_1.CoreBindings.APPLICATION_INSTANCE)),
77
- tslib_1.__param(1, core_1.inject(keys_1.BootBindings.PROJECT_ROOT)),
78
- tslib_1.__param(2, core_1.extensions()),
79
- tslib_1.__param(3, core_1.config()),
80
- tslib_1.__metadata("design:paramtypes", [Object, String, Function, Object])
81
- ], ModelApiBooter);
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"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AAiB,IAAI,QAAQ,EAAE,CACzD,CAAC;aACH;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAA;IA9EY,cAAc;QAF1B,cAAM,CAAC,UAAU,CAAC;QAClB,qBAAc,CAAC,6CAAyB,CAAC;QAGrC,mBAAA,aAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;QAEzC,mBAAA,aAAM,CAAC,mBAAY,CAAC,YAAY,CAAC,CAAA;QACjC,mBAAA,iBAAU,EAAE,CAAA;QAEZ,mBAAA,aAAM,EAAE,CAAA;;OAPA,cAAc,CA8E1B;IAAD,qBAAC;KAAA;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"}
@@ -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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