@tsed/di 7.0.0-beta.1 → 7.0.0-beta.4

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 (135) hide show
  1. package/lib/cjs/constants/{index.js → constants.js} +1 -1
  2. package/lib/cjs/constants/constants.js.map +1 -0
  3. package/lib/cjs/decorators/constant.js +1 -1
  4. package/lib/cjs/decorators/constant.js.map +1 -1
  5. package/lib/cjs/decorators/controller.js.map +1 -1
  6. package/lib/cjs/decorators/inject.js +1 -1
  7. package/lib/cjs/decorators/inject.js.map +1 -1
  8. package/lib/cjs/decorators/injectable.js +0 -2
  9. package/lib/cjs/decorators/injectable.js.map +1 -1
  10. package/lib/cjs/decorators/intercept.js +20 -12
  11. package/lib/cjs/decorators/intercept.js.map +1 -1
  12. package/lib/cjs/decorators/module.js +4 -3
  13. package/lib/cjs/decorators/module.js.map +1 -1
  14. package/lib/cjs/decorators/opts.js +1 -1
  15. package/lib/cjs/decorators/opts.js.map +1 -1
  16. package/lib/cjs/decorators/useOpts.js +1 -1
  17. package/lib/cjs/decorators/useOpts.js.map +1 -1
  18. package/lib/cjs/decorators/value.js +1 -1
  19. package/lib/cjs/decorators/value.js.map +1 -1
  20. package/lib/cjs/domain/Container.js.map +1 -1
  21. package/lib/cjs/domain/DIContext.js.map +1 -1
  22. package/lib/cjs/domain/Provider.js.map +1 -1
  23. package/lib/cjs/errors/InjectionError.js.map +1 -1
  24. package/lib/cjs/index.js +52 -17
  25. package/lib/cjs/index.js.map +1 -1
  26. package/lib/cjs/interfaces/{IProvider.js → ProviderOpts.js} +1 -1
  27. package/lib/cjs/interfaces/ProviderOpts.js.map +1 -0
  28. package/lib/cjs/interfaces/RegistrySettings.js.map +1 -1
  29. package/lib/cjs/package.json +3 -0
  30. package/lib/cjs/registries/GlobalProviders.js +4 -4
  31. package/lib/cjs/registries/GlobalProviders.js.map +1 -1
  32. package/lib/cjs/registries/ProviderRegistry.js +7 -6
  33. package/lib/cjs/registries/ProviderRegistry.js.map +1 -1
  34. package/lib/cjs/services/DIConfiguration.js.map +1 -1
  35. package/lib/cjs/services/InjectorService.js +45 -45
  36. package/lib/cjs/services/InjectorService.js.map +1 -1
  37. package/lib/esm/constants/{index.js → constants.js} +1 -1
  38. package/lib/esm/constants/constants.js.map +1 -0
  39. package/lib/esm/decorators/configuration.js +1 -1
  40. package/lib/esm/decorators/constant.js +2 -2
  41. package/lib/esm/decorators/constant.js.map +1 -1
  42. package/lib/esm/decorators/controller.js +1 -1
  43. package/lib/esm/decorators/controller.js.map +1 -1
  44. package/lib/esm/decorators/inject.js +1 -1
  45. package/lib/esm/decorators/inject.js.map +1 -1
  46. package/lib/esm/decorators/injectable.js +1 -3
  47. package/lib/esm/decorators/injectable.js.map +1 -1
  48. package/lib/esm/decorators/intercept.js +21 -13
  49. package/lib/esm/decorators/intercept.js.map +1 -1
  50. package/lib/esm/decorators/interceptor.js +2 -2
  51. package/lib/esm/decorators/lazyInject.js +1 -1
  52. package/lib/esm/decorators/module.js +4 -3
  53. package/lib/esm/decorators/module.js.map +1 -1
  54. package/lib/esm/decorators/opts.js +4 -4
  55. package/lib/esm/decorators/opts.js.map +1 -1
  56. package/lib/esm/decorators/overrideProvider.js +1 -1
  57. package/lib/esm/decorators/scope.js +1 -1
  58. package/lib/esm/decorators/service.js +1 -1
  59. package/lib/esm/decorators/useOpts.js +1 -1
  60. package/lib/esm/decorators/useOpts.js.map +1 -1
  61. package/lib/esm/decorators/value.js +2 -2
  62. package/lib/esm/decorators/value.js.map +1 -1
  63. package/lib/esm/domain/Container.js +2 -2
  64. package/lib/esm/domain/Container.js.map +1 -1
  65. package/lib/esm/domain/DIContext.js +2 -2
  66. package/lib/esm/domain/DIContext.js.map +1 -1
  67. package/lib/esm/domain/Provider.js +2 -2
  68. package/lib/esm/domain/Provider.js.map +1 -1
  69. package/lib/esm/errors/InjectionError.js +1 -1
  70. package/lib/esm/errors/InjectionError.js.map +1 -1
  71. package/lib/esm/index.js +52 -17
  72. package/lib/esm/index.js.map +1 -1
  73. package/lib/esm/interfaces/ProviderOpts.js +2 -0
  74. package/lib/esm/interfaces/ProviderOpts.js.map +1 -0
  75. package/lib/esm/interfaces/RegistrySettings.js.map +1 -1
  76. package/lib/esm/package.json +3 -0
  77. package/lib/esm/registries/GlobalProviders.js +2 -2
  78. package/lib/esm/registries/GlobalProviders.js.map +1 -1
  79. package/lib/esm/registries/ProviderRegistry.js +5 -4
  80. package/lib/esm/registries/ProviderRegistry.js.map +1 -1
  81. package/lib/esm/services/DIConfiguration.js.map +1 -1
  82. package/lib/esm/services/DILogger.js +2 -2
  83. package/lib/esm/services/DITest.js +4 -4
  84. package/lib/esm/services/InjectorService.js +27 -27
  85. package/lib/esm/services/InjectorService.js.map +1 -1
  86. package/lib/esm/utils/createContainer.js +2 -2
  87. package/lib/types/constants/{index.d.ts → constants.d.ts} +0 -0
  88. package/lib/types/decorators/controller.d.ts +2 -2
  89. package/lib/types/decorators/injectable.d.ts +2 -4
  90. package/lib/types/decorators/intercept.d.ts +2 -2
  91. package/lib/types/decorators/module.d.ts +3 -2
  92. package/lib/types/domain/Container.d.ts +3 -3
  93. package/lib/types/domain/DIContext.d.ts +0 -6
  94. package/lib/types/domain/Provider.d.ts +4 -6
  95. package/lib/types/errors/InjectionError.d.ts +1 -1
  96. package/lib/types/index.d.ts +46 -11
  97. package/lib/types/interfaces/{IProvider.d.ts → ProviderOpts.d.ts} +10 -4
  98. package/lib/types/interfaces/RegistrySettings.d.ts +1 -1
  99. package/lib/types/registries/GlobalProviders.d.ts +6 -4
  100. package/lib/types/registries/ProviderRegistry.d.ts +4 -4
  101. package/lib/types/services/DIConfiguration.d.ts +3 -2
  102. package/lib/types/services/InjectorService.d.ts +12 -10
  103. package/package.json +24 -9
  104. package/readme.md +37 -41
  105. package/tsconfig.compile.esm.json +1 -0
  106. package/lib/cjs/constants/index.js.map +0 -1
  107. package/lib/cjs/decorators/index.js +0 -19
  108. package/lib/cjs/decorators/index.js.map +0 -1
  109. package/lib/cjs/domain/index.js +0 -12
  110. package/lib/cjs/domain/index.js.map +0 -1
  111. package/lib/cjs/interfaces/IProvider.js.map +0 -1
  112. package/lib/cjs/interfaces/index.js +0 -18
  113. package/lib/cjs/interfaces/index.js.map +0 -1
  114. package/lib/cjs/utils/data/Test1.js +0 -8
  115. package/lib/cjs/utils/data/Test1.js.map +0 -1
  116. package/lib/cjs/utils/data/Test2.js +0 -8
  117. package/lib/cjs/utils/data/Test2.js.map +0 -1
  118. package/lib/esm/constants/index.js.map +0 -1
  119. package/lib/esm/decorators/index.js +0 -16
  120. package/lib/esm/decorators/index.js.map +0 -1
  121. package/lib/esm/domain/index.js +0 -9
  122. package/lib/esm/domain/index.js.map +0 -1
  123. package/lib/esm/interfaces/IProvider.js +0 -2
  124. package/lib/esm/interfaces/IProvider.js.map +0 -1
  125. package/lib/esm/interfaces/index.js +0 -15
  126. package/lib/esm/interfaces/index.js.map +0 -1
  127. package/lib/esm/utils/data/Test1.js +0 -4
  128. package/lib/esm/utils/data/Test1.js.map +0 -1
  129. package/lib/esm/utils/data/Test2.js +0 -4
  130. package/lib/esm/utils/data/Test2.js.map +0 -1
  131. package/lib/types/decorators/index.d.ts +0 -15
  132. package/lib/types/domain/index.d.ts +0 -8
  133. package/lib/types/interfaces/index.d.ts +0 -14
  134. package/lib/types/utils/data/Test1.d.ts +0 -3
  135. package/lib/types/utils/data/Test2.d.ts +0 -3
@@ -2,15 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerController = exports.registerValue = exports.registerProvider = void 0;
4
4
  const Provider_1 = require("../domain/Provider");
5
- const domain_1 = require("../domain");
5
+ const ProviderScope_1 = require("../domain/ProviderScope");
6
+ const ProviderType_1 = require("../domain/ProviderType");
6
7
  const GlobalProviders_1 = require("./GlobalProviders");
7
8
  /**
8
9
  *
9
10
  */
10
- GlobalProviders_1.GlobalProviders.createRegistry(domain_1.ProviderType.CONTROLLER, Provider_1.Provider);
11
+ GlobalProviders_1.GlobalProviders.createRegistry(ProviderType_1.ProviderType.CONTROLLER, Provider_1.Provider);
11
12
  /**
12
13
  * Register a provider configuration.
13
- * @param {IProvider<any>} provider
14
+ * @param {ProviderOpts<any>} provider
14
15
  */
15
16
  function registerProvider(provider) {
16
17
  if (!provider.provide) {
@@ -47,9 +48,9 @@ const registerValue = (provider, value) => {
47
48
  };
48
49
  }
49
50
  provider = Object.assign({
50
- scope: domain_1.ProviderScope.SINGLETON,
51
+ scope: ProviderScope_1.ProviderScope.SINGLETON,
51
52
  useValue: value
52
- }, provider, { type: domain_1.ProviderType.VALUE });
53
+ }, provider, { type: ProviderType_1.ProviderType.VALUE });
53
54
  GlobalProviders_1.GlobalProviders.merge(provider.provide, provider);
54
55
  };
55
56
  exports.registerValue = registerValue;
@@ -81,5 +82,5 @@ exports.registerValue = registerValue;
81
82
  *
82
83
  * @param provider Provider configuration.
83
84
  */
84
- exports.registerController = GlobalProviders_1.GlobalProviders.createRegisterFn(domain_1.ProviderType.CONTROLLER);
85
+ exports.registerController = GlobalProviders_1.GlobalProviders.createRegisterFn(ProviderType_1.ProviderType.CONTROLLER);
85
86
  //# sourceMappingURL=ProviderRegistry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProviderRegistry.js","sourceRoot":"","sources":["../../../src/registries/ProviderRegistry.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAE5C,sCAAsD;AACtD,uDAAkD;AAElD;;GAEG;AACH,iCAAe,CAAC,cAAc,CAAC,qBAAY,CAAC,UAAU,EAAE,mBAAQ,CAAC,CAAC;AAElE;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,QAA4B;IAC3D,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;KACjD;IAED,iCAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACpD,CAAC;AAND,4CAMC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,MAAM,aAAa,GAAG,CAAC,QAA8B,EAAE,KAAW,EAAQ,EAAE;IACjF,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;QACrB,QAAQ,GAAG;YACT,OAAO,EAAE,QAAQ;SAClB,CAAC;KACH;IAED,QAAQ,GAAG,MAAM,CAAC,MAAM,CACtB;QACE,KAAK,EAAE,sBAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,KAAK;KAChB,EACD,QAAQ,EACR,EAAC,IAAI,EAAE,qBAAY,CAAC,KAAK,EAAC,CAC3B,CAAC;IACF,iCAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACpD,CAAC,CAAC;AAhBW,QAAA,aAAa,iBAgBxB;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACU,QAAA,kBAAkB,GAAG,iCAAe,CAAC,gBAAgB,CAAC,qBAAY,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import {Provider} from \"../domain/Provider\";\nimport type {IProvider} from \"../interfaces\";\nimport {ProviderScope, ProviderType} from \"../domain\";\nimport {GlobalProviders} from \"./GlobalProviders\";\n\n/**\n *\n */\nGlobalProviders.createRegistry(ProviderType.CONTROLLER, Provider);\n\n/**\n * Register a provider configuration.\n * @param {IProvider<any>} provider\n */\nexport function registerProvider(provider: Partial<IProvider>): void {\n if (!provider.provide) {\n throw new Error(\"Provider.provide is required\");\n }\n\n GlobalProviders.merge(provider.provide, provider);\n}\n\n/**\n * Add a new value in the `ProviderRegistry`.\n *\n * #### Example with symbol definition\n *\n *\n * ```typescript\n * import {registerValue, InjectorService} from \"@tsed/di\";\n *\n * const MyValue = Symbol.from(\"MyValue\")\n *\n * registerValue({token: MyValue, useValue: \"myValue\"});\n *\n * @Service()\n * export class OtherService {\n * constructor(@Inject(MyValue) myValue: string){\n * console.log(myValue); /// \"myValue\"\n * }\n * }\n * ```\n */\nexport const registerValue = (provider: any | IProvider<any>, value?: any): void => {\n if (!provider.provide) {\n provider = {\n provide: provider\n };\n }\n\n provider = Object.assign(\n {\n scope: ProviderScope.SINGLETON,\n useValue: value\n },\n provider,\n {type: ProviderType.VALUE}\n );\n GlobalProviders.merge(provider.provide, provider);\n};\n\n/**\n * Add a new controller in the `ProviderRegistry`. This controller will be built when `InjectorService` will be loaded.\n *\n * #### Example\n *\n * ```typescript\n * import {registerController, InjectorService} from \"@tsed/di\";\n *\n * export default class MyController {\n * constructor(){}\n * transform() {\n * return \"test\";\n * }\n * }\n *\n * registerController({provide: MyController});\n * // or\n * registerController(MyController);\n *\n * const injector = new InjectorService();\n * injector.load();\n *\n * const myController = injector.get<MyController>(MyController);\n * myController.getFoo(); // test\n * ```\n *\n * @param provider Provider configuration.\n */\nexport const registerController = GlobalProviders.createRegisterFn(ProviderType.CONTROLLER);\n"]}
1
+ {"version":3,"file":"ProviderRegistry.js","sourceRoot":"","sources":["../../../src/registries/ProviderRegistry.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAC5C,2DAAsD;AACtD,yDAAoD;AAEpD,uDAAkD;AAElD;;GAEG;AACH,iCAAe,CAAC,cAAc,CAAC,2BAAY,CAAC,UAAU,EAAE,mBAAQ,CAAC,CAAC;AAElE;;;GAGG;AACH,SAAgB,gBAAgB,CAAa,QAAqC;IAChF,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;KACjD;IAED,iCAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACpD,CAAC;AAND,4CAMC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,MAAM,aAAa,GAAG,CAAC,QAAiC,EAAE,KAAW,EAAQ,EAAE;IACpF,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;QACrB,QAAQ,GAAG;YACT,OAAO,EAAE,QAAQ;SAClB,CAAC;KACH;IAED,QAAQ,GAAG,MAAM,CAAC,MAAM,CACtB;QACE,KAAK,EAAE,6BAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,KAAK;KAChB,EACD,QAAQ,EACR,EAAC,IAAI,EAAE,2BAAY,CAAC,KAAK,EAAC,CAC3B,CAAC;IACF,iCAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACpD,CAAC,CAAC;AAhBW,QAAA,aAAa,iBAgBxB;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACU,QAAA,kBAAkB,GAAG,iCAAe,CAAC,gBAAgB,CAAC,2BAAY,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import {Provider} from \"../domain/Provider\";\nimport {ProviderScope} from \"../domain/ProviderScope\";\nimport {ProviderType} from \"../domain/ProviderType\";\nimport type {ProviderOpts} from \"../interfaces/ProviderOpts\";\nimport {GlobalProviders} from \"./GlobalProviders\";\n\n/**\n *\n */\nGlobalProviders.createRegistry(ProviderType.CONTROLLER, Provider);\n\n/**\n * Register a provider configuration.\n * @param {ProviderOpts<any>} provider\n */\nexport function registerProvider<Type = any>(provider: Partial<ProviderOpts<Type>>): void {\n if (!provider.provide) {\n throw new Error(\"Provider.provide is required\");\n }\n\n GlobalProviders.merge(provider.provide, provider);\n}\n\n/**\n * Add a new value in the `ProviderRegistry`.\n *\n * #### Example with symbol definition\n *\n *\n * ```typescript\n * import {registerValue, InjectorService} from \"@tsed/di\";\n *\n * const MyValue = Symbol.from(\"MyValue\")\n *\n * registerValue({token: MyValue, useValue: \"myValue\"});\n *\n * @Service()\n * export class OtherService {\n * constructor(@Inject(MyValue) myValue: string){\n * console.log(myValue); /// \"myValue\"\n * }\n * }\n * ```\n */\nexport const registerValue = (provider: any | ProviderOpts<any>, value?: any): void => {\n if (!provider.provide) {\n provider = {\n provide: provider\n };\n }\n\n provider = Object.assign(\n {\n scope: ProviderScope.SINGLETON,\n useValue: value\n },\n provider,\n {type: ProviderType.VALUE}\n );\n GlobalProviders.merge(provider.provide, provider);\n};\n\n/**\n * Add a new controller in the `ProviderRegistry`. This controller will be built when `InjectorService` will be loaded.\n *\n * #### Example\n *\n * ```typescript\n * import {registerController, InjectorService} from \"@tsed/di\";\n *\n * export default class MyController {\n * constructor(){}\n * transform() {\n * return \"test\";\n * }\n * }\n *\n * registerController({provide: MyController});\n * // or\n * registerController(MyController);\n *\n * const injector = new InjectorService();\n * injector.load();\n *\n * const myController = injector.get<MyController>(MyController);\n * myController.getFoo(); // test\n * ```\n *\n * @param provider Provider configuration.\n */\nexport const registerController = GlobalProviders.createRegisterFn(ProviderType.CONTROLLER);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DIConfiguration.js","sourceRoot":"","sources":["../../../src/services/DIConfiguration.ts"],"names":[],"mappings":";;;AAAA,qCAAmF;AAInF,MAAa,eAAe;IAM1B,YAAY,YAAY,GAAG,EAAE;QALpB,YAAO,GAAqB,IAAI,GAAG,EAAE,CAAC;QACrC,QAAG,GAAqB,IAAI,GAAG,EAAE,CAAC;QAK1C,MAAM,CAAC,OAAO,CAAC;YACb,MAAM,EAAE,EAAE;YACV,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;YACX,GAAG,YAAY;SAChB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC1B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,OAAO,IAAA,sBAAe,EAAkB,IAAI,EAAE;YAC5C,OAAO,CAAC,MAAM;gBACZ,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;YAC1D,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,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GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,WAAmB,EAAE,YAAkB,EAAE,EAAE,CAAC,IAAA,eAAQ,EAAC,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IACtH,CAAC;CACF;AAxJD,0CAwJC","sourcesContent":["import {classOf, deepMerge, getValue, proxyDelegation, setValue} from \"@tsed/core\";\nimport {ProviderScope} from \"../domain\";\nimport type {DIResolver, TokenProvider} from \"../interfaces\";\n\nexport class DIConfiguration {\n readonly default: Map<string, any> = new Map();\n protected map: Map<string, any> = new Map();\n\n [key: string]: any;\n\n constructor(initialProps = {}) {\n Object.entries({\n scopes: {},\n resolvers: [],\n imports: [],\n ...initialProps\n }).forEach(([key, value]) => {\n this.default.set(key, value);\n });\n\n return proxyDelegation<DIConfiguration>(this, {\n ownKeys(target) {\n return [...target.default.keys(), ...target.map.keys()];\n }\n });\n }\n\n get scopes(): {[key: string]: ProviderScope} {\n return this.getRaw(\"scopes\");\n }\n\n set scopes(value: {[key: string]: ProviderScope}) {\n this.setRaw(\"scopes\", value);\n }\n\n get resolvers(): DIResolver[] {\n return this.getRaw(\"resolvers\");\n }\n\n set resolvers(resolvers: DIResolver[]) {\n this.setRaw(\"resolvers\", resolvers);\n }\n\n get imports(): TokenProvider[] {\n return this.getRaw(\"imports\");\n }\n\n set imports(imports: TokenProvider[]) {\n this.setRaw(\"imports\", imports);\n }\n\n /**\n *\n * @param callbackfn\n * @param thisArg\n */\n forEach(callbackfn: (value: any, index: string, map: Map<string, any>) => void, thisArg?: any) {\n return new Set([...Array.from(this.default.keys()), ...Array.from(this.map.keys())]).forEach((key) => {\n callbackfn(this.getRaw(key), key, this.map);\n }, thisArg);\n }\n\n /**\n *\n * @param propertyKey\n * @param value\n */\n set(propertyKey: string | Partial<TsED.Configuration>, value?: any): this {\n if (typeof propertyKey === \"string\") {\n this.setRaw(propertyKey, value);\n } else {\n Object.entries(propertyKey).forEach(([key, value]) => {\n this[key] = value;\n });\n }\n\n return this;\n }\n\n setRaw(propertyKey: string, value: any) {\n setValue(this.map, propertyKey, value);\n\n return this;\n }\n\n /**\n *\n * @param propertyKey\n * @param defaultValue\n * @returns {undefined|any}\n */\n get<T = any>(propertyKey: string, defaultValue?: T): T {\n return this.resolve(this.getRaw(propertyKey, defaultValue));\n }\n\n getRaw(propertyKey: string, defaultValue?: any): any {\n const value = getValue(this.map, propertyKey);\n\n if (value !== undefined) {\n return value;\n }\n\n return getValue(this.default, propertyKey, defaultValue);\n }\n\n merge(obj: Partial<TsED.Configuration>) {\n Object.entries(obj).forEach(([key, value]) => {\n const descriptor = Object.getOwnPropertyDescriptor(DIConfiguration.prototype, key);\n const originalValue = this.get(key);\n value = deepMerge(value, originalValue);\n\n if (descriptor && ![\"default\", \"set\", \"map\", \"get\"].includes(key)) {\n this[key] = value;\n }\n });\n }\n\n /**\n *\n * @param value\n * @returns {any}\n */\n resolve(value: any) {\n if (typeof value === \"object\" && value !== null) {\n if (![Array, Object].includes(classOf(value))) {\n return value;\n }\n\n return Object.entries(value).reduce(\n (o, [k, v]) => {\n // @ts-ignore\n o[k] = this.resolve(v);\n\n return o;\n },\n Array.isArray(value) ? [] : {}\n );\n }\n\n if (typeof value === \"string\") {\n const replacer = (match: string, key: string) => getValue(this.map, key);\n return value\n .replace(/\\${([\\w.]+)}/gi, replacer)\n .replace(/<([\\w.]+)>/gi, replacer)\n .replace(/{{([\\w.]+)}}/gi, replacer);\n }\n\n return value;\n }\n\n build() {\n this.forEach((value, key) => this.map.set(key, this.resolve(value)));\n\n this.set = this.setRaw;\n this.get = this.getRaw = (propertyKey: string, defaultValue?: any) => getValue(this.map, propertyKey, defaultValue);\n }\n}\n"]}
1
+ {"version":3,"file":"DIConfiguration.js","sourceRoot":"","sources":["../../../src/services/DIConfiguration.ts"],"names":[],"mappings":";;;AAAA,qCAAmF;AAKnF,MAAa,eAAe;IAM1B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,EACD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAC/B,CAAC;SACH;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,EAAE,CAAC,IAAA,eAAQ,EAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACzE,OAAO,KAAK;iBACT,OAAO,CAAC,gBAAgB,EAAE,QAAQ,CAAC;iBACnC,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC;iBACjC,OAAO,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;SACxC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAErE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,WAAmB,EAAE,YAAkB,EAAE,EAAE,CAAC,IAAA,eAAQ,EAAC,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IACtH,CAAC;CACF;AAxJD,0CAwJC","sourcesContent":["import {classOf, deepMerge, getValue, proxyDelegation, setValue} from \"@tsed/core\";\nimport {ProviderScope} from \"../domain/ProviderScope\";\nimport type {DIResolver} from \"../interfaces/DIResolver\";\nimport type {TokenProvider} from \"../interfaces/TokenProvider\";\n\nexport class DIConfiguration {\n readonly default: Map<string, any> = new Map();\n protected map: Map<string, any> = new Map();\n\n [key: string]: any;\n\n constructor(initialProps = {}) {\n Object.entries({\n scopes: {},\n resolvers: [],\n imports: [],\n ...initialProps\n }).forEach(([key, value]) => {\n this.default.set(key, value);\n });\n\n return proxyDelegation<DIConfiguration>(this, {\n ownKeys(target) {\n return [...target.default.keys(), ...target.map.keys()];\n }\n });\n }\n\n get scopes(): {[key: string]: ProviderScope} {\n return this.getRaw(\"scopes\");\n }\n\n set scopes(value: {[key: string]: ProviderScope}) {\n this.setRaw(\"scopes\", value);\n }\n\n get resolvers(): DIResolver[] {\n return this.getRaw(\"resolvers\");\n }\n\n set resolvers(resolvers: DIResolver[]) {\n this.setRaw(\"resolvers\", resolvers);\n }\n\n get imports(): TokenProvider[] {\n return this.getRaw(\"imports\");\n }\n\n set imports(imports: TokenProvider[]) {\n this.setRaw(\"imports\", imports);\n }\n\n /**\n *\n * @param callbackfn\n * @param thisArg\n */\n forEach(callbackfn: (value: any, index: string, map: Map<string, any>) => void, thisArg?: any) {\n return new Set([...Array.from(this.default.keys()), ...Array.from(this.map.keys())]).forEach((key) => {\n callbackfn(this.getRaw(key), key, this.map);\n }, thisArg);\n }\n\n /**\n *\n * @param propertyKey\n * @param value\n */\n set(propertyKey: string | Partial<TsED.Configuration>, value?: any): this {\n if (typeof propertyKey === \"string\") {\n this.setRaw(propertyKey, value);\n } else {\n Object.entries(propertyKey).forEach(([key, value]) => {\n this[key] = value;\n });\n }\n\n return this;\n }\n\n setRaw(propertyKey: string, value: any) {\n setValue(this.map, propertyKey, value);\n\n return this;\n }\n\n /**\n *\n * @param propertyKey\n * @param defaultValue\n * @returns {undefined|any}\n */\n get<T = any>(propertyKey: string, defaultValue?: T): T {\n return this.resolve(this.getRaw(propertyKey, defaultValue));\n }\n\n getRaw(propertyKey: string, defaultValue?: any): any {\n const value = getValue(this.map, propertyKey);\n\n if (value !== undefined) {\n return value;\n }\n\n return getValue(this.default, propertyKey, defaultValue);\n }\n\n merge(obj: Partial<TsED.Configuration>) {\n Object.entries(obj).forEach(([key, value]) => {\n const descriptor = Object.getOwnPropertyDescriptor(DIConfiguration.prototype, key);\n const originalValue = this.get(key);\n value = deepMerge(value, originalValue);\n\n if (descriptor && ![\"default\", \"set\", \"map\", \"get\"].includes(key)) {\n this[key] = value;\n }\n });\n }\n\n /**\n *\n * @param value\n * @returns {any}\n */\n resolve(value: any) {\n if (typeof value === \"object\" && value !== null) {\n if (![Array, Object].includes(classOf(value))) {\n return value;\n }\n\n return Object.entries(value).reduce(\n (o, [k, v]) => {\n // @ts-ignore\n o[k] = this.resolve(v);\n\n return o;\n },\n Array.isArray(value) ? [] : {}\n );\n }\n\n if (typeof value === \"string\") {\n const replacer = (match: string, key: string) => getValue(this.map, key);\n return value\n .replace(/\\${([\\w.]+)}/gi, replacer)\n .replace(/<([\\w.]+)>/gi, replacer)\n .replace(/{{([\\w.]+)}}/gi, replacer);\n }\n\n return value;\n }\n\n build() {\n this.forEach((value, key) => this.map.set(key, this.resolve(value)));\n\n this.set = this.setRaw;\n this.get = this.getRaw = (propertyKey: string, defaultValue?: any) => getValue(this.map, propertyKey, defaultValue);\n }\n}\n"]}
@@ -5,10 +5,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.InjectorService = void 0;
6
6
  const tslib_1 = require("tslib");
7
7
  const core_1 = require("@tsed/core");
8
- const constants_1 = require("../constants");
8
+ const constants_1 = require("../constants/constants");
9
9
  const configuration_1 = require("../decorators/configuration");
10
10
  const injectable_1 = require("../decorators/injectable");
11
- const domain_1 = require("../domain");
12
11
  const Container_1 = require("../domain/Container");
13
12
  const LocalsContainer_1 = require("../domain/LocalsContainer");
14
13
  const Provider_1 = require("../domain/Provider");
@@ -17,6 +16,8 @@ const UndefinedTokenError_1 = require("../errors/UndefinedTokenError");
17
16
  const GlobalProviders_1 = require("../registries/GlobalProviders");
18
17
  const createContainer_1 = require("../utils/createContainer");
19
18
  const DIConfiguration_1 = require("./DIConfiguration");
19
+ const ProviderScope_1 = require("../domain/ProviderScope");
20
+ const InjectablePropertyType_1 = require("../domain/InjectablePropertyType");
20
21
  /**
21
22
  * This service contain all services collected by `@Service` or services declared manually with `InjectorService.factory()` or `InjectorService.service()`.
22
23
  *
@@ -45,7 +46,7 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
45
46
  this.logger = console;
46
47
  this.resolvedConfiguration = false;
47
48
  _InjectorService_cache.set(this, new LocalsContainer_1.LocalsContainer());
48
- (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").set(InjectorService_1, this);
49
+ tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").set(InjectorService_1, this);
49
50
  }
50
51
  get resolvers() {
51
52
  return this.settings.resolvers;
@@ -58,28 +59,13 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
58
59
  * @param provider
59
60
  */
60
61
  scopeOf(provider) {
61
- return provider.scope || this.scopes[provider.type] || domain_1.ProviderScope.SINGLETON;
62
- }
63
- /**
64
- * Clone a provider from GlobalProviders and the given token. forkProvider method build automatically the provider if the instance parameter ins't given.
65
- * @param token
66
- * @param settings
67
- * @deprecated
68
- */
69
- forkProvider(token, settings = {}) {
70
- if (!this.hasProvider(token)) {
71
- this.addProvider(token);
72
- }
73
- const provider = this.getProvider(token);
74
- Object.assign(provider, settings);
75
- (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").set(token, this.invoke(token));
76
- return provider;
62
+ return provider.scope || this.scopes[provider.type] || ProviderScope_1.ProviderScope.SINGLETON;
77
63
  }
78
64
  /**
79
65
  * Return a list of instance build by the injector.
80
66
  */
81
67
  toArray() {
82
- return (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").toArray();
68
+ return tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").toArray();
83
69
  }
84
70
  /**
85
71
  * Get a service or factory already constructed from his symbol or class.
@@ -115,13 +101,22 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
115
101
  }
116
102
  }
117
103
  }
104
+ /**
105
+ * Return all instance of the same provider type
106
+ * @param type
107
+ */
108
+ getAll(type) {
109
+ return this.getProviders(type).map((provider) => {
110
+ return this.get(provider.token);
111
+ });
112
+ }
118
113
  /**
119
114
  * The has() method returns a boolean indicating whether an element with the specified key exists or not.
120
115
  * @returns {boolean}
121
116
  * @param token
122
117
  */
123
118
  has(token) {
124
- return (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").get(token) !== undefined;
119
+ return tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").get(token) !== undefined;
125
120
  }
126
121
  /**
127
122
  * Invoke the class and inject all services that required by the class constructor.
@@ -157,27 +152,27 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
157
152
  if (!provider || options.rebuild) {
158
153
  instance = this.resolve(token, locals, options);
159
154
  if (this.hasProvider(token)) {
160
- (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").set(token, instance);
155
+ tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").set(token, instance);
161
156
  }
162
157
  return instance;
163
158
  }
164
159
  switch (this.scopeOf(provider)) {
165
- case domain_1.ProviderScope.SINGLETON:
160
+ case ProviderScope_1.ProviderScope.SINGLETON:
166
161
  if (!this.has(token)) {
167
- (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").set(token, this.resolve(token, locals, options));
162
+ tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").set(token, this.resolve(token, locals, options));
168
163
  if (provider.isAsync()) {
169
- (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").get(token).then((instance) => {
170
- (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").set(token, instance);
164
+ tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").get(token).then((instance) => {
165
+ tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").set(token, instance);
171
166
  });
172
167
  }
173
168
  }
174
169
  instance = this.get(token);
175
170
  break;
176
- case domain_1.ProviderScope.REQUEST:
171
+ case ProviderScope_1.ProviderScope.REQUEST:
177
172
  instance = this.resolve(token, locals, options);
178
173
  locals.set(token, instance);
179
174
  break;
180
- case domain_1.ProviderScope.INSTANCE:
175
+ case ProviderScope_1.ProviderScope.INSTANCE:
181
176
  instance = this.resolve(provider.provide, locals, options);
182
177
  break;
183
178
  }
@@ -192,7 +187,7 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
192
187
  if (provider.isAsync()) {
193
188
  await this.invoke(provider.token, locals);
194
189
  }
195
- const instance = (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").get(provider.token);
190
+ const instance = tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").get(provider.token);
196
191
  if (instance !== undefined) {
197
192
  locals.set(provider.token, instance);
198
193
  }
@@ -202,10 +197,10 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
202
197
  }
203
198
  loadSync(locals = new LocalsContainer_1.LocalsContainer()) {
204
199
  for (const [, provider] of this) {
205
- if (!locals.has(provider.token) && this.scopeOf(provider) === domain_1.ProviderScope.SINGLETON) {
200
+ if (!locals.has(provider.token) && this.scopeOf(provider) === ProviderScope_1.ProviderScope.SINGLETON) {
206
201
  this.invoke(provider.token, locals);
207
202
  }
208
- const instance = (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").get(provider.token);
203
+ const instance = tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").get(provider.token);
209
204
  if (instance !== undefined) {
210
205
  locals.set(provider.token, instance);
211
206
  }
@@ -284,19 +279,19 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
284
279
  }, {});
285
280
  Object.values(properties).forEach((definition) => {
286
281
  switch (definition.bindingType) {
287
- case domain_1.InjectablePropertyType.METHOD:
282
+ case InjectablePropertyType_1.InjectablePropertyType.METHOD:
288
283
  this.bindMethod(instance, definition);
289
284
  break;
290
- case domain_1.InjectablePropertyType.PROPERTY:
285
+ case InjectablePropertyType_1.InjectablePropertyType.PROPERTY:
291
286
  this.bindProperty(instance, definition, locals, options);
292
287
  break;
293
- case domain_1.InjectablePropertyType.CONSTANT:
288
+ case InjectablePropertyType_1.InjectablePropertyType.CONSTANT:
294
289
  this.bindConstant(instance, definition);
295
290
  break;
296
- case domain_1.InjectablePropertyType.VALUE:
291
+ case InjectablePropertyType_1.InjectablePropertyType.VALUE:
297
292
  this.bindValue(instance, definition);
298
293
  break;
299
- case domain_1.InjectablePropertyType.INTERCEPTOR:
294
+ case InjectablePropertyType_1.InjectablePropertyType.INTERCEPTOR:
300
295
  this.bindInterceptor(instance, definition);
301
296
  break;
302
297
  }
@@ -429,7 +424,7 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
429
424
  * @returns {Promise<any[]>} A list of promises.
430
425
  */
431
426
  async emit(eventName, ...args) {
432
- return (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").emit(eventName, ...args);
427
+ return tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").emit(eventName, ...args);
433
428
  }
434
429
  /**
435
430
  * @param eventName
@@ -437,7 +432,7 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
437
432
  * @param args
438
433
  */
439
434
  alter(eventName, value, ...args) {
440
- return (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").alter(eventName, value, ...args);
435
+ return tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").alter(eventName, value, ...args);
441
436
  }
442
437
  /**
443
438
  * @param eventName
@@ -445,10 +440,10 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
445
440
  * @param args
446
441
  */
447
442
  async alterAsync(eventName, value, ...args) {
448
- return (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").alterAsync(eventName, value, ...args);
443
+ return tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").alterAsync(eventName, value, ...args);
449
444
  }
450
445
  async destroy() {
451
- await (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").destroy();
446
+ await tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").destroy();
452
447
  }
453
448
  ensureProvider(token) {
454
449
  if (!this.hasProvider(token) && GlobalProviders_1.GlobalProviders.has(token)) {
@@ -457,7 +452,7 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
457
452
  return this.getProvider(token);
458
453
  }
459
454
  getInstance(token) {
460
- return (0, tslib_1.__classPrivateFieldGet)(this, _InjectorService_cache, "f").get(token);
455
+ return tslib_1.__classPrivateFieldGet(this, _InjectorService_cache, "f").get(token);
461
456
  }
462
457
  /**
463
458
  * Invoke a class method and inject service.
@@ -510,6 +505,11 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
510
505
  if (instance && (0, core_1.isClass)((0, core_1.classOf)(instance))) {
511
506
  this.bindInjectableProperties(instance, locals, options);
512
507
  }
508
+ if (instance && provider.hooks) {
509
+ Object.entries(provider.hooks).forEach(([key, cb]) => {
510
+ instance[key] = (...args) => cb(instance, ...args);
511
+ });
512
+ }
513
513
  return instance;
514
514
  }
515
515
  /**
@@ -561,7 +561,7 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
561
561
  }
562
562
  return {
563
563
  token,
564
- scope: scope || core_1.Store.from(token).get("scope") || domain_1.ProviderScope.SINGLETON,
564
+ scope: scope || core_1.Store.from(token).get("scope") || ProviderScope_1.ProviderScope.SINGLETON,
565
565
  deps: deps || [],
566
566
  imports: imports || [],
567
567
  construct,
@@ -570,12 +570,12 @@ let InjectorService = InjectorService_1 = class InjectorService extends Containe
570
570
  }
571
571
  };
572
572
  _InjectorService_cache = new WeakMap();
573
- InjectorService = InjectorService_1 = (0, tslib_1.__decorate)([
573
+ InjectorService = InjectorService_1 = tslib_1.__decorate([
574
574
  (0, injectable_1.Injectable)({
575
- scope: domain_1.ProviderScope.SINGLETON,
575
+ scope: ProviderScope_1.ProviderScope.SINGLETON,
576
576
  global: true
577
577
  }),
578
- (0, tslib_1.__metadata)("design:paramtypes", [])
578
+ tslib_1.__metadata("design:paramtypes", [])
579
579
  ], InjectorService);
580
580
  exports.InjectorService = InjectorService;
581
581
  //# sourceMappingURL=InjectorService.js.map
@@ -1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,CAAC,CAAC;gBAC/B,OAAO,QAAQ,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC;YAC3C,CAAC,CAAC;SACH;aAAM;YACL,WAAW;YACX,IAAI,GAAG,IAAI,IAAI,eAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACzD,SAAS,GAAG,CAAC,IAAqB,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;SACvE;QAED,OAAO;YACL,KAAK;YACL,KAAK,EAAE,KAAK,IAAI,YAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,sBAAa,CAAC,SAAS;YACzE,IAAI,EAAE,IAAK,IAAI,EAAE;YACjB,OAAO,EAAE,OAAO,IAAI,EAAE;YACtB,SAAS;YACT,QAAQ;SACT,CAAC;IACJ,CAAC;CACF,CAAA;;AAvoBY,eAAe;IAJ3B,IAAA,uBAAU,EAAC;QACV,KAAK,EAAE,sBAAa,CAAC,SAAS;QAC9B,MAAM,EAAE,IAAI;KACb,CAAC;;GACW,eAAe,CAuoB3B;AAvoBY,0CAAe","sourcesContent":["import {\n ancestorsOf,\n catchError,\n classOf,\n deepClone,\n deepMerge,\n getClassOrSymbol,\n isClass,\n isFunction,\n isInheritedFrom,\n Metadata,\n nameOf,\n prototypeOf,\n Store\n} from \"@tsed/core\";\nimport {DI_PARAM_OPTIONS, INJECTABLE_PROP} from \"../constants\";\nimport {Configuration} from \"../decorators/configuration\";\nimport {Injectable} from \"../decorators/injectable\";\nimport {DIContext, InjectablePropertyType, ProviderScope} from \"../domain\";\nimport {Container} from \"../domain/Container\";\nimport {LocalsContainer} from \"../domain/LocalsContainer\";\nimport {Provider} from \"../domain/Provider\";\nimport {InjectionError} from \"../errors/InjectionError\";\nimport {UndefinedTokenError} from \"../errors/UndefinedTokenError\";\nimport {\n DILogger,\n InjectableProperties,\n InjectablePropertyOptions,\n InjectablePropertyValue,\n InterceptorContext,\n InterceptorMethods,\n InvokeOptions,\n IProvider,\n TokenProvider\n} from \"../interfaces\";\nimport {GlobalProviders} from \"../registries/GlobalProviders\";\nimport {createContainer} from \"../utils/createContainer\";\nimport {DIConfiguration} from \"./DIConfiguration\";\nimport {ResolvedInvokeOptions} from \"../interfaces/ResolvedInvokeOptions\";\n\n/**\n * This service contain all services collected by `@Service` or services declared manually with `InjectorService.factory()` or `InjectorService.service()`.\n *\n * ### Example:\n *\n * ```typescript\n * import {InjectorService} from \"@tsed/di\";\n *\n * // Import the services (all services are decorated with @Service()\";\n * import MyService1 from \"./services/service1\";\n * import MyService2 from \"./services/service2\";\n * import MyService3 from \"./services/service3\";\n *\n * // When all services is imported you can load InjectorService.\n * const injector = new InjectorService()\n *\n * await injector.load();\n *\n * const myService1 = injector.get<MyService1>(MyServcice1);\n * ```\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n global: true\n})\nexport class InjectorService extends Container {\n public settings: TsED.Configuration & DIConfiguration = new DIConfiguration() as any;\n public logger: DILogger = console;\n private resolvedConfiguration: boolean = false;\n #cache = new LocalsContainer();\n\n constructor() {\n super();\n this.#cache.set(InjectorService, this);\n }\n\n get resolvers() {\n return this.settings.resolvers!;\n }\n\n get scopes() {\n return this.settings.scopes || {};\n }\n\n /**\n * Retrieve default scope for a given provider.\n * @param provider\n */\n public scopeOf(provider: Provider) {\n return provider.scope || this.scopes[provider.type] || ProviderScope.SINGLETON;\n }\n\n /**\n * Clone a provider from GlobalProviders and the given token. forkProvider method build automatically the provider if the instance parameter ins't given.\n * @param token\n * @param settings\n * @deprecated\n */\n public forkProvider(token: TokenProvider, settings: Partial<IProvider<any>> = {}): Provider {\n if (!this.hasProvider(token)) {\n this.addProvider(token);\n }\n\n const provider = this.getProvider(token)!;\n\n Object.assign(provider, settings);\n\n this.#cache.set(token, this.invoke(token));\n\n return provider;\n }\n\n /**\n * Return a list of instance build by the injector.\n */\n public toArray(): any[] {\n return this.#cache.toArray();\n }\n\n /**\n * Get a service or factory already constructed from his symbol or class.\n *\n * #### Example\n *\n * ```typescript\n * import {InjectorService} from \"@tsed/di\";\n * import MyService from \"./services\";\n *\n * class OtherService {\n * constructor(injectorService: InjectorService) {\n * const myService = injectorService.get<MyService>(MyService);\n * }\n * }\n * ```\n *\n * @param token The class or symbol registered in InjectorService.\n * @param options\n * @returns {boolean}\n */\n get<T = any>(token: TokenProvider, options: any = {}): T | undefined {\n const instance = this.getInstance(token);\n\n if (instance !== undefined) {\n return instance;\n }\n\n if (!this.hasProvider(token)) {\n for (const resolver of this.resolvers) {\n const result = resolver.get(token, options);\n\n if (result !== undefined) {\n return result;\n }\n }\n }\n }\n\n /**\n * The has() method returns a boolean indicating whether an element with the specified key exists or not.\n * @returns {boolean}\n * @param token\n */\n has(token: TokenProvider): boolean {\n return this.#cache.get(token) !== undefined;\n }\n\n /**\n * Invoke the class and inject all services that required by the class constructor.\n *\n * #### Example\n *\n * ```typescript\n * import {InjectorService} from \"@tsed/di\";\n * import MyService from \"./services\";\n *\n * class OtherService {\n * constructor(injectorService: InjectorService) {\n * const myService = injectorService.invoke<MyService>(MyService);\n * }\n * }\n * ```\n *\n * @param token The injectable class to invoke. Class parameters are injected according constructor signature.\n * @param locals Optional object. If preset then any argument Class are read from this object first, before the `InjectorService` is consulted.\n * @param options\n * @returns {T} The class constructed.\n */\n public invoke<T>(\n token: TokenProvider,\n locals: Map<TokenProvider, any> = new LocalsContainer(),\n options: Partial<InvokeOptions<T>> = {}\n ): T {\n const provider = this.ensureProvider(token);\n let instance: any;\n\n !locals.has(Configuration) && locals.set(Configuration, this.settings);\n\n if (locals.has(token)) {\n return locals.get(token);\n }\n\n if (token === DI_PARAM_OPTIONS) {\n return {} as T;\n }\n\n if (!provider || options.rebuild) {\n instance = this.resolve(token, locals, options);\n\n if (this.hasProvider(token)) {\n this.#cache.set(token, instance);\n }\n\n return instance;\n }\n\n switch (this.scopeOf(provider)) {\n case ProviderScope.SINGLETON:\n if (!this.has(token)) {\n this.#cache.set(token, this.resolve(token, locals, options));\n\n if (provider.isAsync()) {\n this.#cache.get(token).then((instance: any) => {\n this.#cache.set(token, instance);\n });\n }\n }\n\n instance = this.get<T>(token)!;\n break;\n\n case ProviderScope.REQUEST:\n instance = this.resolve(token, locals, options);\n locals.set(token, instance);\n break;\n\n case ProviderScope.INSTANCE:\n instance = this.resolve(provider.provide, locals, options);\n break;\n }\n\n return instance;\n }\n\n /**\n * Build only providers which are asynchronous.\n */\n async loadAsync(locals: LocalsContainer = new LocalsContainer()) {\n for (const [, provider] of this) {\n if (!locals.has(provider.token)) {\n if (provider.isAsync()) {\n await this.invoke(provider.token, locals);\n }\n\n const instance = this.#cache.get(provider.token);\n if (instance !== undefined) {\n locals.set(provider.token, instance);\n }\n }\n }\n\n return locals;\n }\n\n loadSync(locals: LocalsContainer = new LocalsContainer()) {\n for (const [, provider] of this) {\n if (!locals.has(provider.token) && this.scopeOf(provider) === ProviderScope.SINGLETON) {\n this.invoke(provider.token, locals);\n }\n\n const instance = this.#cache.get(provider.token);\n if (instance !== undefined) {\n locals.set(provider.token, instance);\n }\n }\n\n return locals;\n }\n\n /**\n * Boostrap injector from container and resolve configuration.\n *\n * @param container\n */\n bootstrap(container: Container = createContainer()) {\n // Clone all providers in the container\n this.addProviders(container);\n\n // Resolve all configuration\n this.resolveConfiguration();\n\n return this;\n }\n\n /**\n * Build all providers from given container (or GlobalProviders) and emit `$onInit` event.\n *\n * @param container\n * @param rootModule\n */\n async load(container: Container = createContainer(), rootModule?: TokenProvider): Promise<LocalsContainer<any>> {\n this.bootstrap(container);\n\n // build async and sync provider\n let locals = await this.loadAsync();\n\n if (rootModule) {\n await this.invoke(rootModule);\n }\n\n // load sync provider\n locals = this.loadSync(locals);\n\n await locals.emit(\"$beforeInit\");\n await locals.emit(\"$onInit\");\n\n return locals;\n }\n\n /**\n * Load all configurations registered on providers\n */\n resolveConfiguration() {\n if (this.resolvedConfiguration) {\n return;\n }\n const mergedConfiguration = new Map();\n\n super.forEach((provider) => {\n if (provider.configuration && provider.type !== \"server:module\") {\n Object.entries(provider.configuration).forEach(([key, value]) => {\n value = mergedConfiguration.has(key) ? deepMerge(mergedConfiguration.get(key), value) : deepClone(value);\n mergedConfiguration.set(key, value);\n });\n }\n if (provider.resolvers) {\n this.resolvers.push(...provider.resolvers);\n }\n });\n\n mergedConfiguration.forEach((value, key) => {\n this.settings[key] = deepMerge(value, this.settings[key]);\n });\n\n this.settings.build();\n\n this.resolvedConfiguration = true;\n }\n\n /**\n *\n * @param instance\n * @param locals\n * @param options\n */\n public bindInjectableProperties(instance: any, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions>) {\n const properties: InjectableProperties = ancestorsOf(classOf(instance)).reduce((properties: any, target: any) => {\n const store = Store.from(target);\n\n return {\n ...properties,\n ...(store.get(INJECTABLE_PROP) || {})\n };\n }, {});\n\n Object.values(properties).forEach((definition) => {\n switch (definition.bindingType) {\n case InjectablePropertyType.METHOD:\n this.bindMethod(instance, definition);\n break;\n case InjectablePropertyType.PROPERTY:\n this.bindProperty(instance, definition, locals, options);\n break;\n case InjectablePropertyType.CONSTANT:\n this.bindConstant(instance, definition);\n break;\n case InjectablePropertyType.VALUE:\n this.bindValue(instance, definition);\n break;\n case InjectablePropertyType.INTERCEPTOR:\n this.bindInterceptor(instance, definition);\n break;\n }\n });\n }\n\n /**\n *\n * @param instance\n * @param {string} propertyKey\n */\n public bindMethod(instance: any, {propertyKey}: InjectablePropertyOptions) {\n const target = classOf(instance);\n const originalMethod = instance[propertyKey];\n const deps = Metadata.getParamTypes(prototypeOf(target), propertyKey);\n\n instance[propertyKey] = () => {\n const services = deps.map((dependency: any) => this.get(dependency));\n\n return originalMethod.call(instance, ...services);\n };\n }\n\n /**\n * Create an injectable property.\n *\n * @param instance\n * @param {string} propertyKey\n * @param {any} useType\n * @param resolver\n * @param options\n * @param locals\n * @param invokeOptions\n */\n public bindProperty(\n instance: any,\n {propertyKey, resolver, options = {}}: InjectablePropertyOptions,\n locals: Map<TokenProvider, any>,\n invokeOptions: Partial<InvokeOptions>\n ) {\n let get: () => any;\n\n get = resolver(this, locals, {...invokeOptions, options});\n\n catchError(() =>\n Object.defineProperty(instance, propertyKey, {\n get\n })\n );\n }\n\n /**\n *\n * @param instance\n * @param {string} propertyKey\n * @param {any} useType\n */\n public bindValue(instance: any, {propertyKey, expression, defaultValue}: InjectablePropertyValue) {\n const descriptor = {\n get: () => this.settings.get(expression) || defaultValue,\n set: (value: any) => this.settings.set(expression, value),\n enumerable: true,\n configurable: true\n };\n\n catchError(() => Object.defineProperty(instance, propertyKey, descriptor));\n }\n\n /**\n *\n * @param instance\n * @param {string} propertyKey\n * @param {any} useType\n */\n public bindConstant(instance: any, {propertyKey, expression, defaultValue}: InjectablePropertyValue) {\n let bean: any;\n\n const get = () => {\n if (bean !== undefined) {\n return bean;\n }\n\n const value = this.settings.get(expression, defaultValue);\n bean = Object.freeze(deepClone(value));\n\n return bean;\n };\n\n const descriptor = {\n get,\n enumerable: true,\n configurable: true\n };\n\n catchError(() => Object.defineProperty(instance, propertyKey, descriptor));\n }\n\n /**\n *\n * @param instance\n * @param propertyKey\n * @param useType\n * @param options\n */\n public bindInterceptor(instance: any, {propertyKey, useType, options}: InjectablePropertyOptions) {\n const target = classOf(instance);\n const originalMethod = instance[propertyKey];\n\n instance[propertyKey] = (...args: any[]) => {\n const next = (err?: Error) => {\n if (!err) {\n return originalMethod.apply(instance, args);\n }\n\n throw err;\n };\n\n const context: InterceptorContext<any> = {\n target,\n propertyKey,\n args,\n options,\n next\n };\n\n const interceptor = this.get<InterceptorMethods>(useType)!;\n\n return interceptor.intercept!(\n {\n ...context,\n options\n },\n next\n );\n };\n }\n\n /**\n * Allow handler hack for AsyncHookContext plugin.\n * @param ctx\n * @param cb\n * @protected\n */\n runInContext(ctx: DIContext, cb: any) {\n return cb();\n }\n\n async lazyInvoke<T = any>(token: TokenProvider) {\n let instance = this.getInstance(token);\n\n if (!instance) {\n instance = await this.invoke<T>(token);\n\n if (isFunction(instance?.$onInit)) {\n await instance.$onInit();\n }\n }\n\n return instance;\n }\n\n /**\n * Emit an event to all service. See service [lifecycle hooks](/docs/services.md#lifecycle-hooks).\n * @param eventName The event name to emit at all services.\n * @param args List of the parameters to give to each services.\n * @returns {Promise<any[]>} A list of promises.\n */\n public async emit(eventName: string, ...args: any[]) {\n return this.#cache.emit(eventName, ...args);\n }\n\n /**\n * @param eventName\n * @param value\n * @param args\n */\n public alter<T = any>(eventName: string, value: any, ...args: any[]): T {\n return this.#cache.alter(eventName, value, ...args);\n }\n\n /**\n * @param eventName\n * @param value\n * @param args\n */\n public async alterAsync<T = any>(eventName: string, value: any, ...args: any[]): Promise<T> {\n return this.#cache.alterAsync(eventName, value, ...args);\n }\n\n async destroy() {\n await this.#cache.destroy();\n }\n\n protected ensureProvider(token: TokenProvider): Provider | undefined {\n if (!this.hasProvider(token) && GlobalProviders.has(token)) {\n this.addProvider(token);\n }\n\n return this.getProvider(token)!;\n }\n\n protected getInstance(token: any) {\n return this.#cache.get(token);\n }\n\n /**\n * Invoke a class method and inject service.\n *\n * #### IInjectableMethod options\n *\n * * **target**: Optional. The class instance.\n * * **methodName**: `string` Optional. The method name.\n * * **designParamTypes**: `any[]` Optional. List of injectable types.\n * * **locals**: `Map<Function, any>` Optional. If preset then any argument Class are read from this object first, before the `InjectorService` is consulted.\n *\n * #### Example\n *\n * @param target\n * @param locals\n * @param options\n * @private\n */\n private resolve<T>(target: TokenProvider, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions<T>> = {}): Promise<T> {\n const resolvedOpts = this.mapInvokeOptions(target, locals, options);\n const {token, deps, construct, imports, provider} = resolvedOpts;\n\n if (provider) {\n GlobalProviders.onInvoke(provider, locals, {...resolvedOpts, injector: this});\n }\n\n let instance: any;\n let currentDependency: any = false;\n\n try {\n const invokeDependency = (parent?: any) => (token: any, index: number): any => {\n currentDependency = {token, index, deps};\n\n if (token !== DI_PARAM_OPTIONS) {\n const options = provider?.store?.get(`${DI_PARAM_OPTIONS}:${index}`);\n\n locals.set(DI_PARAM_OPTIONS, options || {});\n }\n\n return isInheritedFrom(token, Provider, 1) ? provider : this.invoke(token, locals, {parent});\n };\n\n // Invoke manually imported providers\n imports.forEach(invokeDependency());\n\n // Inject dependencies\n const services = deps.map(invokeDependency(token));\n\n currentDependency = false;\n\n instance = construct(services);\n } catch (error) {\n InjectionError.throwInjectorError(token, currentDependency, error);\n }\n\n if (instance === undefined) {\n throw new InjectionError(\n token,\n `Unable to create new instance from undefined value. Check your provider declaration for ${nameOf(token)}`\n );\n }\n\n if (instance && isClass(classOf(instance))) {\n this.bindInjectableProperties(instance, locals, options);\n }\n\n return instance;\n }\n\n /**\n * Create options to invoke a provider or class.\n * @param token\n * @param locals\n * @param options\n */\n private mapInvokeOptions(token: TokenProvider, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions>): ResolvedInvokeOptions {\n let imports: TokenProvider[] | undefined = options.imports;\n let deps: TokenProvider[] | undefined = options.deps;\n let scope = options.scope;\n let construct;\n\n if (!token) {\n throw new UndefinedTokenError();\n }\n\n let provider: Provider;\n\n if (!this.hasProvider(token)) {\n provider = new Provider(token);\n\n this.resolvers.forEach((resolver) => {\n const result = resolver.get(token, locals.get(DI_PARAM_OPTIONS));\n\n if (result !== undefined) {\n provider.useFactory = () => result;\n }\n });\n } else {\n provider = this.getProvider(token)!;\n }\n\n scope = scope || this.scopeOf(provider);\n deps = deps || provider.deps;\n imports = imports || provider.imports;\n\n if (provider.useValue !== undefined) {\n construct = () => (isFunction(provider.useValue) ? provider.useValue() : provider.useValue);\n } else if (provider.useFactory) {\n construct = (deps: TokenProvider[]) => provider.useFactory(...deps);\n } else if (provider.useAsyncFactory) {\n construct = async (deps: TokenProvider[]) => {\n deps = await Promise.all(deps);\n return provider.useAsyncFactory(...deps);\n };\n } else {\n // useClass\n deps = deps || Metadata.getParamTypes(provider.useClass);\n construct = (deps: TokenProvider[]) => new provider.useClass(...deps);\n }\n\n return {\n token,\n scope: scope || Store.from(token).get(\"scope\") || ProviderScope.SINGLETON,\n deps: deps! || [],\n imports: imports || [],\n construct,\n provider\n };\n }\n}\n"]}
1
+ {"version":3,"file":"InjectorService.js","sourceRoot":"","sources":["../../../src/services/InjectorService.ts"],"names":[],"mappings":";;;;;;AAAA,qCAaoB;AACpB,sDAAyE;AACzE,+DAA0D;AAC1D,yDAAoD;AACpD,mDAA8C;AAC9C,+DAA0D;AAC1D,iDAA4C;AAC5C,6DAAwD;AACxD,uEAAkE;AAClE,mEAA8D;AAC9D,8DAAyD;AACzD,uDAAkD;AAElD,2DAAsD;AAMtD,6EAAwE;AAKxE;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH,IAAa,eAAe,uBAA5B,MAAa,eAAgB,SAAQ,qBAAS;IAM5C;QACE,KAAK,EAAE,CAAC;QANH,aAAQ,GAAyC,IAAI,iCAAe,EAAS,CAAC;QAC9E,WAAM,GAAa,OAAO,CAAC;QAC1B,0BAAqB,GAAY,KAAK,CAAC;QAC/C,iCAAS,IAAI,iCAAe,EAAE,EAAC;QAI7B,+BAAA,IAAI,8BAAO,CAAC,GAAG,CAAC,iBAAe,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAU,CAAC;IAClC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,QAAkB;QAC/B,OAAO,QAAQ,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,6BAAa,CAAC,SAAS,CAAC;IACjF,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,OAAO,+BAAA,IAAI,8BAAO,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,GAAG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C,IAAqB,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;SACrE;aAAM,IAAI,QAAQ,CAAC,eAAe,EAAE;YACnC,SAAS,GAAG,KAAK,EAAE,IAAqB,EAAE,EAAE;gBAC1C,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC/B,OAAO,QAAQ,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC;YAC3C,CAAC,CAAC;SACH;aAAM;YACL,WAAW;YACX,IAAI,GAAG,IAAI,IAAI,eAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACzD,SAAS,GAAG,CAAC,IAAqB,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;SACvE;QAED,OAAO;YACL,KAAK;YACL,KAAK,EAAE,KAAK,IAAI,YAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,6BAAa,CAAC,SAAS;YACzE,IAAI,EAAE,IAAK,IAAI,EAAE;YACjB,OAAO,EAAE,OAAO,IAAI,EAAE;YACtB,SAAS;YACT,QAAQ;SACT,CAAC;IACJ,CAAC;CACF,CAAA;;AAroBY,eAAe;IAJ3B,IAAA,uBAAU,EAAC;QACV,KAAK,EAAE,6BAAa,CAAC,SAAS;QAC9B,MAAM,EAAE,IAAI;KACb,CAAC;;GACW,eAAe,CAqoB3B;AAroBY,0CAAe","sourcesContent":["import {\n ancestorsOf,\n catchError,\n classOf,\n deepClone,\n deepMerge,\n isClass,\n isFunction,\n isInheritedFrom,\n Metadata,\n nameOf,\n prototypeOf,\n Store\n} from \"@tsed/core\";\nimport {DI_PARAM_OPTIONS, INJECTABLE_PROP} from \"../constants/constants\";\nimport {Configuration} from \"../decorators/configuration\";\nimport {Injectable} from \"../decorators/injectable\";\nimport {Container} from \"../domain/Container\";\nimport {LocalsContainer} from \"../domain/LocalsContainer\";\nimport {Provider} from \"../domain/Provider\";\nimport {InjectionError} from \"../errors/InjectionError\";\nimport {UndefinedTokenError} from \"../errors/UndefinedTokenError\";\nimport {GlobalProviders} from \"../registries/GlobalProviders\";\nimport {createContainer} from \"../utils/createContainer\";\nimport {DIConfiguration} from \"./DIConfiguration\";\nimport {ResolvedInvokeOptions} from \"../interfaces/ResolvedInvokeOptions\";\nimport {ProviderScope} from \"../domain/ProviderScope\";\nimport {DILogger} from \"../interfaces/DILogger\";\nimport {TokenProvider} from \"../interfaces/TokenProvider\";\nimport {ProviderOpts} from \"../interfaces/ProviderOpts\";\nimport {InvokeOptions} from \"../interfaces/InvokeOptions\";\nimport {InjectableProperties, InjectablePropertyOptions, InjectablePropertyValue} from \"../interfaces/InjectableProperties\";\nimport {InjectablePropertyType} from \"../domain/InjectablePropertyType\";\nimport {InterceptorContext} from \"../interfaces/InterceptorContext\";\nimport {InterceptorMethods} from \"../interfaces/InterceptorMethods\";\nimport {DIContext} from \"../domain/DIContext\";\n\n/**\n * This service contain all services collected by `@Service` or services declared manually with `InjectorService.factory()` or `InjectorService.service()`.\n *\n * ### Example:\n *\n * ```typescript\n * import {InjectorService} from \"@tsed/di\";\n *\n * // Import the services (all services are decorated with @Service()\";\n * import MyService1 from \"./services/service1\";\n * import MyService2 from \"./services/service2\";\n * import MyService3 from \"./services/service3\";\n *\n * // When all services is imported you can load InjectorService.\n * const injector = new InjectorService()\n *\n * await injector.load();\n *\n * const myService1 = injector.get<MyService1>(MyServcice1);\n * ```\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n global: true\n})\nexport class InjectorService extends Container {\n public settings: TsED.Configuration & DIConfiguration = new DIConfiguration() as any;\n public logger: DILogger = console;\n private resolvedConfiguration: boolean = false;\n #cache = new LocalsContainer();\n\n constructor() {\n super();\n this.#cache.set(InjectorService, this);\n }\n\n get resolvers() {\n return this.settings.resolvers!;\n }\n\n get scopes() {\n return this.settings.scopes || {};\n }\n\n /**\n * Retrieve default scope for a given provider.\n * @param provider\n */\n public scopeOf(provider: Provider) {\n return provider.scope || this.scopes[provider.type] || ProviderScope.SINGLETON;\n }\n\n /**\n * Return a list of instance build by the injector.\n */\n public toArray(): any[] {\n return this.#cache.toArray();\n }\n\n /**\n * Get a service or factory already constructed from his symbol or class.\n *\n * #### Example\n *\n * ```typescript\n * import {InjectorService} from \"@tsed/di\";\n * import MyService from \"./services\";\n *\n * class OtherService {\n * constructor(injectorService: InjectorService) {\n * const myService = injectorService.get<MyService>(MyService);\n * }\n * }\n * ```\n *\n * @param token The class or symbol registered in InjectorService.\n * @param options\n * @returns {boolean}\n */\n get<T = any>(token: TokenProvider, options: any = {}): T | undefined {\n const instance = this.getInstance(token);\n\n if (instance !== undefined) {\n return instance;\n }\n\n if (!this.hasProvider(token)) {\n for (const resolver of this.resolvers) {\n const result = resolver.get(token, options);\n\n if (result !== undefined) {\n return result;\n }\n }\n }\n }\n\n /**\n * Return all instance of the same provider type\n * @param type\n */\n getAll(type: string) {\n return this.getProviders(type).map((provider) => {\n return this.get(provider.token);\n });\n }\n\n /**\n * The has() method returns a boolean indicating whether an element with the specified key exists or not.\n * @returns {boolean}\n * @param token\n */\n has(token: TokenProvider): boolean {\n return this.#cache.get(token) !== undefined;\n }\n\n /**\n * Invoke the class and inject all services that required by the class constructor.\n *\n * #### Example\n *\n * ```typescript\n * import {InjectorService} from \"@tsed/di\";\n * import MyService from \"./services\";\n *\n * class OtherService {\n * constructor(injectorService: InjectorService) {\n * const myService = injectorService.invoke<MyService>(MyService);\n * }\n * }\n * ```\n *\n * @param token The injectable class to invoke. Class parameters are injected according constructor signature.\n * @param locals Optional object. If preset then any argument Class are read from this object first, before the `InjectorService` is consulted.\n * @param options\n * @returns {T} The class constructed.\n */\n public invoke<T>(\n token: TokenProvider,\n locals: Map<TokenProvider, any> = new LocalsContainer(),\n options: Partial<InvokeOptions<T>> = {}\n ): T {\n const provider = this.ensureProvider(token);\n let instance: any;\n\n !locals.has(Configuration) && locals.set(Configuration, this.settings);\n\n if (locals.has(token)) {\n return locals.get(token);\n }\n\n if (token === DI_PARAM_OPTIONS) {\n return {} as T;\n }\n\n if (!provider || options.rebuild) {\n instance = this.resolve(token, locals, options);\n\n if (this.hasProvider(token)) {\n this.#cache.set(token, instance);\n }\n\n return instance;\n }\n\n switch (this.scopeOf(provider)) {\n case ProviderScope.SINGLETON:\n if (!this.has(token)) {\n this.#cache.set(token, this.resolve(token, locals, options));\n\n if (provider.isAsync()) {\n this.#cache.get(token).then((instance: any) => {\n this.#cache.set(token, instance);\n });\n }\n }\n\n instance = this.get<T>(token)!;\n break;\n\n case ProviderScope.REQUEST:\n instance = this.resolve(token, locals, options);\n locals.set(token, instance);\n break;\n\n case ProviderScope.INSTANCE:\n instance = this.resolve(provider.provide, locals, options);\n break;\n }\n\n return instance;\n }\n\n /**\n * Build only providers which are asynchronous.\n */\n async loadAsync(locals: LocalsContainer = new LocalsContainer()) {\n for (const [, provider] of this) {\n if (!locals.has(provider.token)) {\n if (provider.isAsync()) {\n await this.invoke(provider.token, locals);\n }\n\n const instance = this.#cache.get(provider.token);\n if (instance !== undefined) {\n locals.set(provider.token, instance);\n }\n }\n }\n\n return locals;\n }\n\n loadSync(locals: LocalsContainer = new LocalsContainer()) {\n for (const [, provider] of this) {\n if (!locals.has(provider.token) && this.scopeOf(provider) === ProviderScope.SINGLETON) {\n this.invoke(provider.token, locals);\n }\n\n const instance = this.#cache.get(provider.token);\n if (instance !== undefined) {\n locals.set(provider.token, instance);\n }\n }\n\n return locals;\n }\n\n /**\n * Boostrap injector from container and resolve configuration.\n *\n * @param container\n */\n bootstrap(container: Container = createContainer()) {\n // Clone all providers in the container\n this.addProviders(container);\n\n // Resolve all configuration\n this.resolveConfiguration();\n\n return this;\n }\n\n /**\n * Build all providers from given container (or GlobalProviders) and emit `$onInit` event.\n *\n * @param container\n * @param rootModule\n */\n async load(container: Container = createContainer(), rootModule?: TokenProvider): Promise<LocalsContainer<any>> {\n this.bootstrap(container);\n\n // build async and sync provider\n let locals = await this.loadAsync();\n\n if (rootModule) {\n await this.invoke(rootModule);\n }\n\n // load sync provider\n locals = this.loadSync(locals);\n\n await locals.emit(\"$beforeInit\");\n await locals.emit(\"$onInit\");\n\n return locals;\n }\n\n /**\n * Load all configurations registered on providers\n */\n resolveConfiguration() {\n if (this.resolvedConfiguration) {\n return;\n }\n const mergedConfiguration = new Map();\n\n super.forEach((provider) => {\n if (provider.configuration && provider.type !== \"server:module\") {\n Object.entries(provider.configuration).forEach(([key, value]) => {\n value = mergedConfiguration.has(key) ? deepMerge(mergedConfiguration.get(key), value) : deepClone(value);\n mergedConfiguration.set(key, value);\n });\n }\n if (provider.resolvers) {\n this.resolvers.push(...provider.resolvers);\n }\n });\n\n mergedConfiguration.forEach((value, key) => {\n this.settings[key] = deepMerge(value, this.settings[key]);\n });\n\n this.settings.build();\n\n this.resolvedConfiguration = true;\n }\n\n /**\n *\n * @param instance\n * @param locals\n * @param options\n */\n public bindInjectableProperties(instance: any, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions>) {\n const properties: InjectableProperties = ancestorsOf(classOf(instance)).reduce((properties: any, target: any) => {\n const store = Store.from(target);\n\n return {\n ...properties,\n ...(store.get(INJECTABLE_PROP) || {})\n };\n }, {});\n\n Object.values(properties).forEach((definition) => {\n switch (definition.bindingType) {\n case InjectablePropertyType.METHOD:\n this.bindMethod(instance, definition);\n break;\n case InjectablePropertyType.PROPERTY:\n this.bindProperty(instance, definition, locals, options);\n break;\n case InjectablePropertyType.CONSTANT:\n this.bindConstant(instance, definition);\n break;\n case InjectablePropertyType.VALUE:\n this.bindValue(instance, definition);\n break;\n case InjectablePropertyType.INTERCEPTOR:\n this.bindInterceptor(instance, definition);\n break;\n }\n });\n }\n\n /**\n *\n * @param instance\n * @param {string} propertyKey\n */\n public bindMethod(instance: any, {propertyKey}: InjectablePropertyOptions) {\n const target = classOf(instance);\n const originalMethod = instance[propertyKey];\n const deps = Metadata.getParamTypes(prototypeOf(target), propertyKey);\n\n instance[propertyKey] = () => {\n const services = deps.map((dependency: any) => this.get(dependency));\n\n return originalMethod.call(instance, ...services);\n };\n }\n\n /**\n * Create an injectable property.\n *\n * @param instance\n * @param {string} propertyKey\n * @param {any} useType\n * @param resolver\n * @param options\n * @param locals\n * @param invokeOptions\n */\n public bindProperty(\n instance: any,\n {propertyKey, resolver, options = {}}: InjectablePropertyOptions,\n locals: Map<TokenProvider, any>,\n invokeOptions: Partial<InvokeOptions>\n ) {\n let get: () => any;\n\n get = resolver(this, locals, {...invokeOptions, options});\n\n catchError(() =>\n Object.defineProperty(instance, propertyKey, {\n get\n })\n );\n }\n\n /**\n *\n * @param instance\n * @param {string} propertyKey\n * @param {any} useType\n */\n public bindValue(instance: any, {propertyKey, expression, defaultValue}: InjectablePropertyValue) {\n const descriptor = {\n get: () => this.settings.get(expression) || defaultValue,\n set: (value: any) => this.settings.set(expression, value),\n enumerable: true,\n configurable: true\n };\n\n catchError(() => Object.defineProperty(instance, propertyKey, descriptor));\n }\n\n /**\n *\n * @param instance\n * @param {string} propertyKey\n * @param {any} useType\n */\n public bindConstant(instance: any, {propertyKey, expression, defaultValue}: InjectablePropertyValue) {\n let bean: any;\n\n const get = () => {\n if (bean !== undefined) {\n return bean;\n }\n\n const value = this.settings.get(expression, defaultValue);\n bean = Object.freeze(deepClone(value));\n\n return bean;\n };\n\n const descriptor = {\n get,\n enumerable: true,\n configurable: true\n };\n\n catchError(() => Object.defineProperty(instance, propertyKey, descriptor));\n }\n\n /**\n *\n * @param instance\n * @param propertyKey\n * @param useType\n * @param options\n */\n public bindInterceptor(instance: any, {propertyKey, useType, options}: InjectablePropertyOptions) {\n const target = classOf(instance);\n const originalMethod = instance[propertyKey];\n\n instance[propertyKey] = (...args: any[]) => {\n const next = (err?: Error) => {\n if (!err) {\n return originalMethod.apply(instance, args);\n }\n\n throw err;\n };\n\n const context: InterceptorContext<any> = {\n target,\n propertyKey,\n args,\n options,\n next\n };\n\n const interceptor = this.get<InterceptorMethods>(useType)!;\n\n return interceptor.intercept!(\n {\n ...context,\n options\n },\n next\n );\n };\n }\n\n /**\n * Allow handler hack for AsyncHookContext plugin.\n * @param ctx\n * @param cb\n * @protected\n */\n runInContext(ctx: DIContext, cb: any) {\n return cb();\n }\n\n async lazyInvoke<T = any>(token: TokenProvider) {\n let instance = this.getInstance(token);\n\n if (!instance) {\n instance = await this.invoke<T>(token);\n\n if (isFunction(instance?.$onInit)) {\n await instance.$onInit();\n }\n }\n\n return instance;\n }\n\n /**\n * Emit an event to all service. See service [lifecycle hooks](/docs/services.md#lifecycle-hooks).\n * @param eventName The event name to emit at all services.\n * @param args List of the parameters to give to each services.\n * @returns {Promise<any[]>} A list of promises.\n */\n public async emit(eventName: string, ...args: any[]) {\n return this.#cache.emit(eventName, ...args);\n }\n\n /**\n * @param eventName\n * @param value\n * @param args\n */\n public alter<T = any>(eventName: string, value: any, ...args: any[]): T {\n return this.#cache.alter(eventName, value, ...args);\n }\n\n /**\n * @param eventName\n * @param value\n * @param args\n */\n public async alterAsync<T = any>(eventName: string, value: any, ...args: any[]): Promise<T> {\n return this.#cache.alterAsync(eventName, value, ...args);\n }\n\n async destroy() {\n await this.#cache.destroy();\n }\n\n protected ensureProvider(token: TokenProvider): Provider | undefined {\n if (!this.hasProvider(token) && GlobalProviders.has(token)) {\n this.addProvider(token);\n }\n\n return this.getProvider(token)!;\n }\n\n protected getInstance(token: any) {\n return this.#cache.get(token);\n }\n\n /**\n * Invoke a class method and inject service.\n *\n * #### IInjectableMethod options\n *\n * * **target**: Optional. The class instance.\n * * **methodName**: `string` Optional. The method name.\n * * **designParamTypes**: `any[]` Optional. List of injectable types.\n * * **locals**: `Map<Function, any>` Optional. If preset then any argument Class are read from this object first, before the `InjectorService` is consulted.\n *\n * #### Example\n *\n * @param target\n * @param locals\n * @param options\n * @private\n */\n private resolve<T>(target: TokenProvider, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions<T>> = {}): Promise<T> {\n const resolvedOpts = this.mapInvokeOptions(target, locals, options);\n const {token, deps, construct, imports, provider} = resolvedOpts;\n\n if (provider) {\n GlobalProviders.onInvoke(provider, locals, {...resolvedOpts, injector: this});\n }\n\n let instance: any;\n let currentDependency: any = false;\n\n try {\n const invokeDependency =\n (parent?: any) =>\n (token: any, index: number): any => {\n currentDependency = {token, index, deps};\n\n if (token !== DI_PARAM_OPTIONS) {\n const options = provider?.store?.get(`${DI_PARAM_OPTIONS}:${index}`);\n\n locals.set(DI_PARAM_OPTIONS, options || {});\n }\n\n return isInheritedFrom(token, Provider, 1) ? provider : this.invoke(token, locals, {parent});\n };\n\n // Invoke manually imported providers\n imports.forEach(invokeDependency());\n\n // Inject dependencies\n const services = deps.map(invokeDependency(token));\n\n currentDependency = false;\n\n instance = construct(services);\n } catch (error) {\n InjectionError.throwInjectorError(token, currentDependency, error);\n }\n\n if (instance === undefined) {\n throw new InjectionError(\n token,\n `Unable to create new instance from undefined value. Check your provider declaration for ${nameOf(token)}`\n );\n }\n\n if (instance && isClass(classOf(instance))) {\n this.bindInjectableProperties(instance, locals, options);\n }\n\n if (instance && provider.hooks) {\n Object.entries(provider.hooks).forEach(([key, cb]) => {\n instance[key] = (...args: any[]) => cb(instance, ...args);\n });\n }\n\n return instance;\n }\n\n /**\n * Create options to invoke a provider or class.\n * @param token\n * @param locals\n * @param options\n */\n private mapInvokeOptions(token: TokenProvider, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions>): ResolvedInvokeOptions {\n let imports: TokenProvider[] | undefined = options.imports;\n let deps: TokenProvider[] | undefined = options.deps;\n let scope = options.scope;\n let construct;\n\n if (!token) {\n throw new UndefinedTokenError();\n }\n\n let provider: Provider;\n\n if (!this.hasProvider(token)) {\n provider = new Provider(token);\n\n this.resolvers.forEach((resolver) => {\n const result = resolver.get(token, locals.get(DI_PARAM_OPTIONS));\n\n if (result !== undefined) {\n provider.useFactory = () => result;\n }\n });\n } else {\n provider = this.getProvider(token)!;\n }\n\n scope = scope || this.scopeOf(provider);\n deps = deps || provider.deps;\n imports = imports || provider.imports;\n\n if (provider.useValue !== undefined) {\n construct = () => (isFunction(provider.useValue) ? provider.useValue() : provider.useValue);\n } else if (provider.useFactory) {\n construct = (deps: TokenProvider[]) => provider.useFactory(...deps);\n } else if (provider.useAsyncFactory) {\n construct = async (deps: TokenProvider[]) => {\n deps = await Promise.all(deps);\n return provider.useAsyncFactory(...deps);\n };\n } else {\n // useClass\n deps = deps || Metadata.getParamTypes(provider.useClass);\n construct = (deps: TokenProvider[]) => new provider.useClass(...deps);\n }\n\n return {\n token,\n scope: scope || Store.from(token).get(\"scope\") || ProviderScope.SINGLETON,\n deps: deps! || [],\n imports: imports || [],\n construct,\n provider\n };\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export const INJECTABLE_PROP = "DI:INJECTABLE_PROP";
2
2
  export const DI_PARAMS = "DI:PARAMS";
3
3
  export const DI_PARAM_OPTIONS = "DI:PARAM:OPTIONS";
4
- //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,oBAAoB,CAAC;AACpD,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AACrC,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC","sourcesContent":["export const INJECTABLE_PROP = \"DI:INJECTABLE_PROP\";\nexport const DI_PARAMS = \"DI:PARAMS\";\nexport const DI_PARAM_OPTIONS = \"DI:PARAM:OPTIONS\";\n"]}
@@ -1,5 +1,5 @@
1
1
  import { decoratorTypeOf, DecoratorTypes, StoreSet } from "@tsed/core";
2
- import { Inject } from "../decorators/inject";
2
+ import { Inject } from "../decorators/inject.js";
3
3
  /**
4
4
  * Get or set Configuration on a class.
5
5
  *
@@ -1,6 +1,6 @@
1
1
  import { Store } from "@tsed/core";
2
- import { INJECTABLE_PROP } from "../constants";
3
- import { InjectablePropertyType } from "../domain/InjectablePropertyType";
2
+ import { INJECTABLE_PROP } from "../constants/constants.js";
3
+ import { InjectablePropertyType } from "../domain/InjectablePropertyType.js";
4
4
  /**
5
5
  * Return value from Configuration.
6
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../src/decorators/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAC,sBAAsB,EAAC,MAAM,kCAAkC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,QAAQ,CAAC,UAAkB,EAAE,YAAkB;IAC7D,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QAC1C,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,eAAe,EAAE;YACxC,CAAC,WAAW,CAAC,EAAE;gBACb,WAAW,EAAE,sBAAsB,CAAC,QAAQ;gBAC5C,WAAW;gBACX,UAAU;gBACV,YAAY;aACb;SACsB,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {Store} from \"@tsed/core\";\nimport {INJECTABLE_PROP} from \"../constants\";\nimport type {InjectableProperties} from \"../interfaces\";\nimport {InjectablePropertyType} from \"../domain/InjectablePropertyType\";\n\n/**\n * Return value from Configuration.\n *\n * ## Example\n *\n * ```typescript\n * import {Env} from \"@tsed/core\";\n * import {Constant, Value} from \"@tsed/di\";\n *\n * export class MyClass {\n *\n * @Constant(\"env\")\n * env: Env;\n *\n * @Value(\"swagger.path\")\n * swaggerPath: string;\n *\n * @Value(\"swagger.path\", \"defaultValue\")\n * swaggerPath: string;\n *\n * constructor() {\n * console.log(this.swaggerPath) // undefined. Not available on constructor\n * }\n *\n * $onInit() {\n * console.log(this.swaggerPath) // something\n * }\n * }\n * ```\n *\n * @param {string} expression\n * @param defaultValue\n * @returns {(targetClass: any, attributeName: string) => any}\n * @decorator\n */\nexport function Constant(expression: string, defaultValue?: any): any {\n return (target: any, propertyKey: string) => {\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType: InjectablePropertyType.CONSTANT,\n propertyKey,\n expression,\n defaultValue\n }\n } as InjectableProperties);\n };\n}\n"]}
1
+ {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../src/decorators/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAC,sBAAsB,EAAC,MAAM,kCAAkC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,QAAQ,CAAC,UAAkB,EAAE,YAAkB;IAC7D,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QAC1C,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,eAAe,EAAE;YACxC,CAAC,WAAW,CAAC,EAAE;gBACb,WAAW,EAAE,sBAAsB,CAAC,QAAQ;gBAC5C,WAAW;gBACX,UAAU;gBACV,YAAY;aACb;SACsB,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {Store} from \"@tsed/core\";\nimport {INJECTABLE_PROP} from \"../constants/constants\";\nimport type {InjectableProperties} from \"../interfaces/InjectableProperties\";\nimport {InjectablePropertyType} from \"../domain/InjectablePropertyType\";\n\n/**\n * Return value from Configuration.\n *\n * ## Example\n *\n * ```typescript\n * import {Env} from \"@tsed/core\";\n * import {Constant, Value} from \"@tsed/di\";\n *\n * export class MyClass {\n *\n * @Constant(\"env\")\n * env: Env;\n *\n * @Value(\"swagger.path\")\n * swaggerPath: string;\n *\n * @Value(\"swagger.path\", \"defaultValue\")\n * swaggerPath: string;\n *\n * constructor() {\n * console.log(this.swaggerPath) // undefined. Not available on constructor\n * }\n *\n * $onInit() {\n * console.log(this.swaggerPath) // something\n * }\n * }\n * ```\n *\n * @param {string} expression\n * @param defaultValue\n * @returns {(targetClass: any, attributeName: string) => any}\n * @decorator\n */\nexport function Constant(expression: string, defaultValue?: any): any {\n return (target: any, propertyKey: string) => {\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType: InjectablePropertyType.CONSTANT,\n propertyKey,\n expression,\n defaultValue\n }\n } as InjectableProperties);\n };\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { isArrayOrArrayClass, useDecorators } from "@tsed/core";
2
2
  import { Children, Path } from "@tsed/schema";
3
- import { registerController } from "../registries/ProviderRegistry";
3
+ import { registerController } from "../registries/ProviderRegistry.js";
4
4
  function mapOptions(options) {
5
5
  if (typeof options === "string" || options instanceof RegExp || isArrayOrArrayClass(options)) {
6
6
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/decorators/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAQ,aAAa,EAAC,MAAM,YAAY,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAiBlE,SAAS,UAAU,CAAC,OAAY;IAC9B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,YAAY,MAAM,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE;QAC5F,OAAO;YACL,IAAI,EAAE,OAAO;SACd,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,UAAU,CAAC,OAAqC;IAC9D,MAAM,EAAC,QAAQ,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,IAAI,EAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAE3D,OAAO,aAAa,CAClB,CAAC,MAAY,EAAE,EAAE;QACf,kBAAkB,CAAC;YACjB,OAAO,EAAE,MAAM;YACf,GAAG,IAAI;SACR,CAAC,CAAC;IACL,CAAC,EACD,IAAI,IAAI,IAAI,CAAC,IAAW,CAAC,EACzB,QAAQ,CAAC,GAAG,QAAQ,CAAC,CACtB,CAAC;AACJ,CAAC","sourcesContent":["import {isArrayOrArrayClass, Type, useDecorators} from \"@tsed/core\";\nimport {Children, Path} from \"@tsed/schema\";\nimport {IProvider} from \"../interfaces/IProvider\";\nimport {registerController} from \"../registries/ProviderRegistry\";\n\nexport type PathType = string | RegExp | (string | RegExp)[];\n\nexport interface ControllerMiddlewares {\n useBefore: any[];\n use: any[];\n useAfter: any[];\n}\n\nexport interface ControllerOptions extends Partial<IProvider<any>> {\n path?: PathType;\n children?: Type<any>[];\n routerOptions?: any;\n middlewares?: Partial<ControllerMiddlewares>;\n}\n\nfunction mapOptions(options: any): ControllerOptions {\n if (typeof options === \"string\" || options instanceof RegExp || isArrayOrArrayClass(options)) {\n return {\n path: options\n };\n }\n\n return options;\n}\n\n/**\n * Declare a new controller with his Rest path. His methods annotated will be collected to build the routing list.\n * This routing listing will be built with the `express.Router` object.\n *\n * ::: tip\n * See [Controllers](/docs/controllers.md) section for more details\n * :::\n *\n * ```typescript\n * @Controller(\"/calendars\")\n * export provide CalendarCtrl {\n *\n * @Get(\"/:id\")\n * public get(\n * @Req() request: Req,\n * @Res() response: Res,\n * @Next() next: Next\n * ): void {\n *\n * }\n * }\n * ```\n *\n * @param options\n * @controller\n * @decorator\n * @classDecorator\n */\nexport function Controller(options: PathType | ControllerOptions): ClassDecorator {\n const {children = [], path, ...opts} = mapOptions(options);\n\n return useDecorators(\n (target: Type) => {\n registerController({\n provide: target,\n ...opts\n });\n },\n path && Path(path as any),\n Children(...children)\n );\n}\n"]}
1
+ {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/decorators/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAQ,aAAa,EAAC,MAAM,YAAY,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAC;AAiBlE,SAAS,UAAU,CAAC,OAAY;IAC9B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,YAAY,MAAM,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE;QAC5F,OAAO;YACL,IAAI,EAAE,OAAO;SACd,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,UAAU,CAAC,OAAqC;IAC9D,MAAM,EAAC,QAAQ,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,IAAI,EAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAE3D,OAAO,aAAa,CAClB,CAAC,MAAY,EAAE,EAAE;QACf,kBAAkB,CAAC;YACjB,OAAO,EAAE,MAAM;YACf,GAAG,IAAI;SACR,CAAC,CAAC;IACL,CAAC,EACD,IAAI,IAAI,IAAI,CAAC,IAAW,CAAC,EACzB,QAAQ,CAAC,GAAG,QAAQ,CAAC,CACtB,CAAC;AACJ,CAAC","sourcesContent":["import {isArrayOrArrayClass, Type, useDecorators} from \"@tsed/core\";\nimport {Children, Path} from \"@tsed/schema\";\nimport {ProviderOpts} from \"../interfaces/ProviderOpts\";\nimport {registerController} from \"../registries/ProviderRegistry\";\n\nexport type PathType = string | RegExp | (string | RegExp)[];\n\nexport interface ControllerMiddlewares {\n useBefore: any[];\n use: any[];\n useAfter: any[];\n}\n\nexport interface ControllerOptions extends Partial<ProviderOpts<any>> {\n path?: PathType;\n children?: Type<any>[];\n routerOptions?: any;\n middlewares?: Partial<ControllerMiddlewares>;\n}\n\nfunction mapOptions(options: any): ControllerOptions {\n if (typeof options === \"string\" || options instanceof RegExp || isArrayOrArrayClass(options)) {\n return {\n path: options\n };\n }\n\n return options;\n}\n\n/**\n * Declare a new controller with his Rest path. His methods annotated will be collected to build the routing list.\n * This routing listing will be built with the `express.Router` object.\n *\n * ::: tip\n * See [Controllers](/docs/controllers.md) section for more details\n * :::\n *\n * ```typescript\n * @Controller(\"/calendars\")\n * export provide CalendarCtrl {\n *\n * @Get(\"/:id\")\n * public get(\n * @Req() request: Req,\n * @Res() response: Res,\n * @Next() next: Next\n * ): void {\n *\n * }\n * }\n * ```\n *\n * @param options\n * @controller\n * @decorator\n * @classDecorator\n */\nexport function Controller(options: PathType | ControllerOptions): ClassDecorator {\n const {children = [], path, ...opts} = mapOptions(options);\n\n return useDecorators(\n (target: Type) => {\n registerController({\n provide: target,\n ...opts\n });\n },\n path && Path(path as any),\n Children(...children)\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { decoratorTypeOf, DecoratorTypes, isPromise, Metadata, Store, UnsupportedDecoratorType } from "@tsed/core";
2
- import { DI_PARAM_OPTIONS, INJECTABLE_PROP } from "../constants";
2
+ import { DI_PARAM_OPTIONS, INJECTABLE_PROP } from "../constants/constants.js";
3
3
  export function injectProperty(target, propertyKey, options) {
4
4
  Store.from(target).merge(INJECTABLE_PROP, {
5
5
  [propertyKey]: {
@@ -1 +1 @@
1
- {"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../src/decorators/inject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,wBAAwB,EAAC,MAAM,YAAY,CAAC;AACjH,OAAO,EAAC,gBAAgB,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAG/D,MAAM,UAAU,cAAc,CAAC,MAAW,EAAE,WAAmB,EAAE,OAA2C;IAC1G,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,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,CAAC,CAAC;4BACvD,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;yBACjC;wBAED,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE;4BACnB,IAAI,CAAC,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE;gCACxB,IAAI,GAAG,MAAM,CAAC;4BAChB,CAAC,CAAC,CAAC;yBACJ;wBAED,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBAC3B,CAAC;iBACF,CAAC,CAAC;gBACH,MAAM;YAER,KAAK,cAAc,CAAC,MAAM;gBACxB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,eAAe,EAAE;oBACxC,CAAC,WAAW,CAAC,EAAE;wBACb,WAAW;wBACX,WAAW;qBACZ;iBACF,CAAC,CAAC;gBAEH,OAAO,UAAU,CAAC;YAEpB;gBACE,MAAM,IAAI,wBAAwB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;SACjF;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {decoratorTypeOf, DecoratorTypes, isPromise, Metadata, Store, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {DI_PARAM_OPTIONS, INJECTABLE_PROP} from \"../constants\";\nimport type {InjectablePropertyOptions} from \"../interfaces/InjectableProperties\";\n\nexport function injectProperty(target: any, propertyKey: string, options: Partial<InjectablePropertyOptions>) {\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType: DecoratorTypes.PROP,\n propertyKey,\n ...options\n }\n });\n}\n\n/**\n * Inject a provider to another provider.\n *\n * Use this decorator to inject a custom provider on constructor parameter or property.\n *\n * ```typescript\n * @Injectable()\n * export class MyService {\n * @Inject(CONNECTION)\n * connection: CONNECTION;\n * }\n * ```\n *\n * @param symbol\n * @param onGet Use the given name method to inject\n * @returns {Function}\n * @decorator\n */\nexport function Inject(symbol?: any, onGet = (bean: any) => bean): Function {\n return (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<Function> | number): any | void => {\n const bindingType = decoratorTypeOf([target, propertyKey, descriptor]);\n\n switch (bindingType) {\n case DecoratorTypes.PARAM:\n case DecoratorTypes.PARAM_CTOR:\n if (symbol) {\n const paramTypes = Metadata.getParamTypes(target, propertyKey);\n\n paramTypes[descriptor as number] = symbol;\n Metadata.setParamTypes(target, propertyKey, paramTypes);\n }\n break;\n\n case DecoratorTypes.PROP:\n injectProperty(target, propertyKey, {\n resolver(injector, locals, {options, ...invokeOptions}) {\n locals.set(DI_PARAM_OPTIONS, {...options});\n\n let bean: any;\n\n if (!bean) {\n const useType = symbol || Metadata.getType(target, propertyKey);\n bean = injector.invoke(useType, locals, invokeOptions);\n locals.delete(DI_PARAM_OPTIONS);\n }\n\n if (isPromise(bean)) {\n bean.then((result: any) => {\n bean = result;\n });\n }\n\n return () => onGet(bean);\n }\n });\n break;\n\n case DecoratorTypes.METHOD:\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType,\n propertyKey\n }\n });\n\n return descriptor;\n\n default:\n throw new UnsupportedDecoratorType(Inject, [target, propertyKey, descriptor]);\n }\n };\n}\n"]}
1
+ {"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../src/decorators/inject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,wBAAwB,EAAC,MAAM,YAAY,CAAC;AACjH,OAAO,EAAC,gBAAgB,EAAE,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAGzE,MAAM,UAAU,cAAc,CAAC,MAAW,EAAE,WAAmB,EAAE,OAA2C;IAC1G,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,eAAe,EAAE;QACxC,CAAC,WAAW,CAAC,EAAE;YACb,WAAW,EAAE,cAAc,CAAC,IAAI;YAChC,WAAW;YACX,GAAG,OAAO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AAI,CAAC,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE;gCACxB,IAAI,GAAG,MAAM,CAAC;4BAChB,CAAC,CAAC,CAAC;yBACJ;wBAED,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBAC3B,CAAC;iBACF,CAAC,CAAC;gBACH,MAAM;YAER,KAAK,cAAc,CAAC,MAAM;gBACxB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,eAAe,EAAE;oBACxC,CAAC,WAAW,CAAC,EAAE;wBACb,WAAW;wBACX,WAAW;qBACZ;iBACF,CAAC,CAAC;gBAEH,OAAO,UAAU,CAAC;YAEpB;gBACE,MAAM,IAAI,wBAAwB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;SACjF;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {decoratorTypeOf, DecoratorTypes, isPromise, Metadata, Store, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {DI_PARAM_OPTIONS, INJECTABLE_PROP} from \"../constants/constants\";\nimport type {InjectablePropertyOptions} from \"../interfaces/InjectableProperties\";\n\nexport function injectProperty(target: any, propertyKey: string, options: Partial<InjectablePropertyOptions>) {\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType: DecoratorTypes.PROP,\n propertyKey,\n ...options\n }\n });\n}\n\n/**\n * Inject a provider to another provider.\n *\n * Use this decorator to inject a custom provider on constructor parameter or property.\n *\n * ```typescript\n * @Injectable()\n * export class MyService {\n * @Inject(CONNECTION)\n * connection: CONNECTION;\n * }\n * ```\n *\n * @param symbol\n * @param onGet Use the given name method to inject\n * @returns {Function}\n * @decorator\n */\nexport function Inject(symbol?: any, onGet = (bean: any) => bean): Function {\n return (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<Function> | number): any | void => {\n const bindingType = decoratorTypeOf([target, propertyKey, descriptor]);\n\n switch (bindingType) {\n case DecoratorTypes.PARAM:\n case DecoratorTypes.PARAM_CTOR:\n if (symbol) {\n const paramTypes = Metadata.getParamTypes(target, propertyKey);\n\n paramTypes[descriptor as number] = symbol;\n Metadata.setParamTypes(target, propertyKey, paramTypes);\n }\n break;\n\n case DecoratorTypes.PROP:\n injectProperty(target, propertyKey, {\n resolver(injector, locals, {options, ...invokeOptions}) {\n locals.set(DI_PARAM_OPTIONS, {...options});\n\n let bean: any;\n\n if (!bean) {\n const useType = symbol || Metadata.getType(target, propertyKey);\n bean = injector.invoke(useType, locals, invokeOptions);\n locals.delete(DI_PARAM_OPTIONS);\n }\n\n if (isPromise(bean)) {\n bean.then((result: any) => {\n bean = result;\n });\n }\n\n return () => onGet(bean);\n }\n });\n break;\n\n case DecoratorTypes.METHOD:\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType,\n propertyKey\n }\n });\n\n return descriptor;\n\n default:\n throw new UnsupportedDecoratorType(Inject, [target, propertyKey, descriptor]);\n }\n };\n}\n"]}