@tsed/di 7.0.0-beta.2 → 7.0.0-beta.20

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 (224) hide show
  1. package/coverage.json +6 -0
  2. package/jest.config.js +9 -0
  3. package/lib/cjs/constants/{index.js → constants.js} +1 -1
  4. package/lib/cjs/constants/constants.js.map +1 -0
  5. package/lib/cjs/decorators/constant.js +1 -1
  6. package/lib/cjs/decorators/constant.js.map +1 -1
  7. package/lib/cjs/decorators/controller.js.map +1 -1
  8. package/lib/cjs/decorators/inject.js +27 -2
  9. package/lib/cjs/decorators/inject.js.map +1 -1
  10. package/lib/cjs/decorators/injectable.js +0 -2
  11. package/lib/cjs/decorators/injectable.js.map +1 -1
  12. package/lib/cjs/decorators/intercept.js +20 -12
  13. package/lib/cjs/decorators/intercept.js.map +1 -1
  14. package/lib/cjs/decorators/module.js +4 -3
  15. package/lib/cjs/decorators/module.js.map +1 -1
  16. package/lib/cjs/decorators/opts.js +1 -1
  17. package/lib/cjs/decorators/opts.js.map +1 -1
  18. package/lib/cjs/decorators/useOpts.js +1 -1
  19. package/lib/cjs/decorators/useOpts.js.map +1 -1
  20. package/lib/cjs/decorators/value.js +1 -1
  21. package/lib/cjs/decorators/value.js.map +1 -1
  22. package/lib/cjs/domain/Container.js +1 -2
  23. package/lib/cjs/domain/Container.js.map +1 -1
  24. package/lib/cjs/domain/ContextLogger.js +41 -30
  25. package/lib/cjs/domain/ContextLogger.js.map +1 -1
  26. package/lib/cjs/domain/ControllerProvider.js +37 -0
  27. package/lib/cjs/domain/ControllerProvider.js.map +1 -0
  28. package/lib/cjs/domain/DIContext.js +86 -30
  29. package/lib/cjs/domain/DIContext.js.map +1 -1
  30. package/lib/cjs/domain/LocalsContainer.js +3 -46
  31. package/lib/cjs/domain/LocalsContainer.js.map +1 -1
  32. package/lib/cjs/domain/Provider.js +20 -1
  33. package/lib/cjs/domain/Provider.js.map +1 -1
  34. package/lib/cjs/errors/InjectionError.js +3 -2
  35. package/lib/cjs/errors/InjectionError.js.map +1 -1
  36. package/lib/cjs/errors/UndefinedTokenError.js +1 -1
  37. package/lib/cjs/errors/UndefinedTokenError.js.map +1 -1
  38. package/lib/cjs/index.js +60 -17
  39. package/lib/cjs/index.js.map +1 -1
  40. package/lib/cjs/interfaces/AlterRunInContext.js +3 -0
  41. package/lib/cjs/interfaces/AlterRunInContext.js.map +1 -0
  42. package/lib/cjs/interfaces/DIConfigurationOptions.js.map +1 -1
  43. package/lib/cjs/interfaces/DILoggerOptions.js +3 -0
  44. package/lib/cjs/interfaces/DILoggerOptions.js.map +1 -0
  45. package/lib/cjs/interfaces/InjectableProperties.js.map +1 -1
  46. package/lib/cjs/interfaces/InterceptorMethods.js.map +1 -1
  47. package/lib/cjs/interfaces/ProviderOpts.js +3 -0
  48. package/lib/cjs/interfaces/ProviderOpts.js.map +1 -0
  49. package/lib/cjs/interfaces/RegistrySettings.js.map +1 -1
  50. package/lib/cjs/interfaces/TokenProvider.js.map +1 -1
  51. package/lib/cjs/interfaces/{IProvider.js → TokenRoute.js} +1 -1
  52. package/lib/cjs/interfaces/TokenRoute.js.map +1 -0
  53. package/lib/cjs/package.json +3 -0
  54. package/lib/cjs/registries/GlobalProviders.js +7 -12
  55. package/lib/cjs/registries/GlobalProviders.js.map +1 -1
  56. package/lib/cjs/registries/ProviderRegistry.js +8 -7
  57. package/lib/cjs/registries/ProviderRegistry.js.map +1 -1
  58. package/lib/cjs/services/DIConfiguration.js +56 -43
  59. package/lib/cjs/services/DIConfiguration.js.map +1 -1
  60. package/lib/cjs/services/DITest.js +13 -6
  61. package/lib/cjs/services/DITest.js.map +1 -1
  62. package/lib/cjs/services/InjectorService.js +115 -113
  63. package/lib/cjs/services/InjectorService.js.map +1 -1
  64. package/lib/cjs/utils/asyncHookContext.js +42 -0
  65. package/lib/cjs/utils/asyncHookContext.js.map +1 -0
  66. package/lib/cjs/utils/getConfiguration.js +13 -10
  67. package/lib/cjs/utils/getConfiguration.js.map +1 -1
  68. package/lib/cjs/utils/resolveControllers.js +47 -0
  69. package/lib/cjs/utils/resolveControllers.js.map +1 -0
  70. package/lib/cjs/utils/setLoggerConfiguration.js +11 -0
  71. package/lib/cjs/utils/setLoggerConfiguration.js.map +1 -0
  72. package/lib/cjs/utils/setLoggerFormat.js +33 -0
  73. package/lib/cjs/utils/setLoggerFormat.js.map +1 -0
  74. package/lib/cjs/utils/setLoggerLevel.js +1 -2
  75. package/lib/cjs/utils/setLoggerLevel.js.map +1 -1
  76. package/lib/esm/constants/{index.js → constants.js} +1 -1
  77. package/lib/esm/constants/constants.js.map +1 -0
  78. package/lib/esm/decorators/configuration.js +1 -1
  79. package/lib/esm/decorators/constant.js +2 -2
  80. package/lib/esm/decorators/constant.js.map +1 -1
  81. package/lib/esm/decorators/controller.js +1 -1
  82. package/lib/esm/decorators/controller.js.map +1 -1
  83. package/lib/esm/decorators/inject.js +25 -1
  84. package/lib/esm/decorators/inject.js.map +1 -1
  85. package/lib/esm/decorators/injectable.js +1 -3
  86. package/lib/esm/decorators/injectable.js.map +1 -1
  87. package/lib/esm/decorators/intercept.js +21 -13
  88. package/lib/esm/decorators/intercept.js.map +1 -1
  89. package/lib/esm/decorators/interceptor.js +2 -2
  90. package/lib/esm/decorators/lazyInject.js +1 -1
  91. package/lib/esm/decorators/module.js +4 -3
  92. package/lib/esm/decorators/module.js.map +1 -1
  93. package/lib/esm/decorators/opts.js +4 -4
  94. package/lib/esm/decorators/opts.js.map +1 -1
  95. package/lib/esm/decorators/overrideProvider.js +1 -1
  96. package/lib/esm/decorators/scope.js +1 -1
  97. package/lib/esm/decorators/service.js +1 -1
  98. package/lib/esm/decorators/useOpts.js +1 -1
  99. package/lib/esm/decorators/useOpts.js.map +1 -1
  100. package/lib/esm/decorators/value.js +2 -2
  101. package/lib/esm/decorators/value.js.map +1 -1
  102. package/lib/esm/domain/Container.js +3 -4
  103. package/lib/esm/domain/Container.js.map +1 -1
  104. package/lib/esm/domain/ContextLogger.js +41 -30
  105. package/lib/esm/domain/ContextLogger.js.map +1 -1
  106. package/lib/esm/domain/ControllerProvider.js +33 -0
  107. package/lib/esm/domain/ControllerProvider.js.map +1 -0
  108. package/lib/esm/domain/DIContext.js +88 -32
  109. package/lib/esm/domain/DIContext.js.map +1 -1
  110. package/lib/esm/domain/LocalsContainer.js +3 -46
  111. package/lib/esm/domain/LocalsContainer.js.map +1 -1
  112. package/lib/esm/domain/Provider.js +23 -4
  113. package/lib/esm/domain/Provider.js.map +1 -1
  114. package/lib/esm/errors/InjectionError.js +4 -3
  115. package/lib/esm/errors/InjectionError.js.map +1 -1
  116. package/lib/esm/errors/UndefinedTokenError.js +1 -1
  117. package/lib/esm/errors/UndefinedTokenError.js.map +1 -1
  118. package/lib/esm/index.js +60 -17
  119. package/lib/esm/index.js.map +1 -1
  120. package/lib/esm/interfaces/AlterRunInContext.js +2 -0
  121. package/lib/esm/interfaces/AlterRunInContext.js.map +1 -0
  122. package/lib/esm/interfaces/DIConfigurationOptions.js.map +1 -1
  123. package/lib/esm/interfaces/DILoggerOptions.js +2 -0
  124. package/lib/esm/interfaces/DILoggerOptions.js.map +1 -0
  125. package/lib/esm/interfaces/InjectableProperties.js.map +1 -1
  126. package/lib/esm/interfaces/InterceptorMethods.js.map +1 -1
  127. package/lib/esm/interfaces/ProviderOpts.js +2 -0
  128. package/lib/esm/interfaces/ProviderOpts.js.map +1 -0
  129. package/lib/esm/interfaces/RegistrySettings.js.map +1 -1
  130. package/lib/esm/interfaces/TokenProvider.js.map +1 -1
  131. package/lib/esm/interfaces/TokenRoute.js +2 -0
  132. package/lib/esm/interfaces/TokenRoute.js.map +1 -0
  133. package/lib/esm/package.json +3 -0
  134. package/lib/esm/registries/GlobalProviders.js +9 -14
  135. package/lib/esm/registries/GlobalProviders.js.map +1 -1
  136. package/lib/esm/registries/ProviderRegistry.js +6 -5
  137. package/lib/esm/registries/ProviderRegistry.js.map +1 -1
  138. package/lib/esm/services/DIConfiguration.js +57 -44
  139. package/lib/esm/services/DIConfiguration.js.map +1 -1
  140. package/lib/esm/services/DILogger.js +2 -2
  141. package/lib/esm/services/DITest.js +16 -9
  142. package/lib/esm/services/DITest.js.map +1 -1
  143. package/lib/esm/services/InjectorService.js +116 -114
  144. package/lib/esm/services/InjectorService.js.map +1 -1
  145. package/lib/esm/utils/asyncHookContext.js +33 -0
  146. package/lib/esm/utils/asyncHookContext.js.map +1 -0
  147. package/lib/esm/utils/createContainer.js +2 -2
  148. package/lib/esm/utils/getConfiguration.js +12 -10
  149. package/lib/esm/utils/getConfiguration.js.map +1 -1
  150. package/lib/esm/utils/resolveControllers.js +42 -0
  151. package/lib/esm/utils/resolveControllers.js.map +1 -0
  152. package/lib/esm/utils/setLoggerConfiguration.js +7 -0
  153. package/lib/esm/utils/setLoggerConfiguration.js.map +1 -0
  154. package/lib/esm/utils/setLoggerFormat.js +29 -0
  155. package/lib/esm/utils/setLoggerFormat.js.map +1 -0
  156. package/lib/esm/utils/setLoggerLevel.js +1 -2
  157. package/lib/esm/utils/setLoggerLevel.js.map +1 -1
  158. package/lib/types/constants/{index.d.ts → constants.d.ts} +0 -0
  159. package/lib/types/decorators/controller.d.ts +2 -3
  160. package/lib/types/decorators/inject.d.ts +15 -0
  161. package/lib/types/decorators/injectable.d.ts +2 -4
  162. package/lib/types/decorators/intercept.d.ts +2 -2
  163. package/lib/types/decorators/module.d.ts +3 -2
  164. package/lib/types/domain/Container.d.ts +3 -3
  165. package/lib/types/domain/ContextLogger.d.ts +13 -18
  166. package/lib/types/domain/ControllerProvider.d.ts +17 -0
  167. package/lib/types/domain/DIContext.d.ts +23 -35
  168. package/lib/types/domain/LocalsContainer.d.ts +3 -22
  169. package/lib/types/domain/Provider.d.ts +5 -6
  170. package/lib/types/errors/InjectionError.d.ts +1 -1
  171. package/lib/types/index.d.ts +54 -11
  172. package/lib/types/interfaces/AlterRunInContext.d.ts +3 -0
  173. package/lib/types/interfaces/DIConfigurationOptions.d.ts +5 -2
  174. package/lib/types/interfaces/DILoggerOptions.d.ts +44 -0
  175. package/lib/types/interfaces/InjectableProperties.d.ts +2 -1
  176. package/lib/types/interfaces/InterceptorMethods.d.ts +1 -1
  177. package/lib/types/interfaces/{IProvider.d.ts → ProviderOpts.d.ts} +5 -4
  178. package/lib/types/interfaces/RegistrySettings.d.ts +1 -1
  179. package/lib/types/interfaces/TokenProvider.d.ts +1 -1
  180. package/lib/types/interfaces/TokenRoute.d.ts +5 -0
  181. package/lib/types/registries/GlobalProviders.d.ts +9 -6
  182. package/lib/types/registries/ProviderRegistry.d.ts +5 -4
  183. package/lib/types/services/DIConfiguration.d.ts +21 -12
  184. package/lib/types/services/DITest.d.ts +2 -0
  185. package/lib/types/services/InjectorService.d.ts +28 -34
  186. package/lib/types/utils/asyncHookContext.d.ts +14 -0
  187. package/lib/types/utils/getConfiguration.d.ts +1 -0
  188. package/lib/types/utils/resolveControllers.d.ts +12 -0
  189. package/lib/types/utils/setLoggerConfiguration.d.ts +2 -0
  190. package/lib/types/utils/setLoggerFormat.d.ts +6 -0
  191. package/lib/types/utils/setLoggerLevel.d.ts +1 -1
  192. package/package.json +29 -10
  193. package/readme.md +40 -43
  194. package/tsconfig.compile.esm.json +1 -0
  195. package/lib/cjs/constants/index.js.map +0 -1
  196. package/lib/cjs/decorators/index.js +0 -19
  197. package/lib/cjs/decorators/index.js.map +0 -1
  198. package/lib/cjs/domain/index.js +0 -12
  199. package/lib/cjs/domain/index.js.map +0 -1
  200. package/lib/cjs/interfaces/IProvider.js.map +0 -1
  201. package/lib/cjs/interfaces/index.js +0 -18
  202. package/lib/cjs/interfaces/index.js.map +0 -1
  203. package/lib/cjs/utils/data/Test1.js +0 -8
  204. package/lib/cjs/utils/data/Test1.js.map +0 -1
  205. package/lib/cjs/utils/data/Test2.js +0 -8
  206. package/lib/cjs/utils/data/Test2.js.map +0 -1
  207. package/lib/esm/constants/index.js.map +0 -1
  208. package/lib/esm/decorators/index.js +0 -16
  209. package/lib/esm/decorators/index.js.map +0 -1
  210. package/lib/esm/domain/index.js +0 -9
  211. package/lib/esm/domain/index.js.map +0 -1
  212. package/lib/esm/interfaces/IProvider.js +0 -2
  213. package/lib/esm/interfaces/IProvider.js.map +0 -1
  214. package/lib/esm/interfaces/index.js +0 -15
  215. package/lib/esm/interfaces/index.js.map +0 -1
  216. package/lib/esm/utils/data/Test1.js +0 -4
  217. package/lib/esm/utils/data/Test1.js.map +0 -1
  218. package/lib/esm/utils/data/Test2.js +0 -4
  219. package/lib/esm/utils/data/Test2.js.map +0 -1
  220. package/lib/types/decorators/index.d.ts +0 -15
  221. package/lib/types/domain/index.d.ts +0 -8
  222. package/lib/types/interfaces/index.d.ts +0 -14
  223. package/lib/types/utils/data/Test1.d.ts +0 -3
  224. package/lib/types/utils/data/Test2.d.ts +0 -3
@@ -1,44 +1,100 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DIContext = void 0;
4
+ const asyncHookContext_1 = require("../utils/asyncHookContext");
4
5
  const ContextLogger_1 = require("./ContextLogger");
5
6
  const LocalsContainer_1 = require("./LocalsContainer");
6
- class DIContext extends Map {
7
- constructor({ id, injector, logger, ignoreLog, ...options }) {
8
- super();
9
- /**
10
- * Date when request have been handled by the server. @@RequestLogger@@ use this date to log request duration.
11
- */
12
- this.dateStart = new Date();
13
- /**
14
- * The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`
15
- */
16
- this.container = new LocalsContainer_1.LocalsContainer();
17
- this.id = id;
18
- injector && (this.injector = injector);
19
- this.logger = new ContextLogger_1.ContextLogger(logger, {
20
- ...options,
21
- dateStart: this.dateStart,
22
- id,
23
- ignoreLog
24
- });
7
+ class DIContext {
8
+ opts;
9
+ #container;
10
+ #cache;
11
+ #logger;
12
+ constructor(opts) {
13
+ this.opts = opts;
14
+ }
15
+ /**
16
+ * Logger attached to the context request.
17
+ */
18
+ get logger() {
19
+ this.#logger = this.#logger || new ContextLogger_1.ContextLogger(this.opts);
20
+ return this.#logger;
21
+ }
22
+ /**
23
+ * Request id generated by @@contextMiddleware@@.
24
+ *
25
+ * ::: tip
26
+ * By default Ts.ED generate uuid like that `uuidv4().replace(/-/gi, ""))`.
27
+ * Dash are removed to simplify tracking logs in Kibana
28
+ * :::
29
+ *
30
+ * ::: tip
31
+ * Request id can by customized by changing the server configuration.
32
+ *
33
+ * ```typescript
34
+ * @Configuration({
35
+ * logger: {
36
+ * reqIdBuilder: createUniqId // give your own id generator function
37
+ * }
38
+ * })
39
+ * class Server {
40
+ *
41
+ * }
42
+ * ```
43
+ * :::
44
+ *
45
+ */
46
+ get id() {
47
+ return this.opts.id;
48
+ }
49
+ get dateStart() {
50
+ return this.logger.dateStart;
51
+ }
52
+ get injector() {
53
+ return this.opts.injector;
25
54
  }
26
55
  get env() {
27
- return this.injector.settings.env;
56
+ return this.injector.settings.get("env");
57
+ }
58
+ /**
59
+ * The request container used by the Ts.ED DI. It contains all services annotated with `@Scope(ProviderScope.REQUEST)`
60
+ */
61
+ get container() {
62
+ return (this.#container = this.#container || new LocalsContainer_1.LocalsContainer());
28
63
  }
29
64
  async destroy() {
30
- await this.container.destroy();
31
- this.logger.destroy();
32
- // @ts-ignore
33
- delete this.container;
34
- // @ts-ignore
35
- delete this.logger;
36
- // @ts-ignore
37
- delete this.injector;
65
+ return Promise.all([this.#container?.destroy(), this.#logger?.flush()]);
38
66
  }
39
67
  async emit(eventName, ...args) {
40
- var _a;
41
- return (_a = this.injector) === null || _a === void 0 ? void 0 : _a.emit(eventName, ...args);
68
+ return this.injector?.emit(eventName, ...args);
69
+ }
70
+ async runInContext(next) {
71
+ return (0, asyncHookContext_1.runInContext)(this, next);
72
+ }
73
+ cache(key, cb) {
74
+ if (!this.has(key)) {
75
+ this.set(key, cb());
76
+ }
77
+ return this.get(key);
78
+ }
79
+ async cacheAsync(key, cb) {
80
+ if (!this.has(key)) {
81
+ this.set(key, await cb());
82
+ }
83
+ return this.get(key);
84
+ }
85
+ delete(key) {
86
+ return !!this.#cache?.delete(key);
87
+ }
88
+ get(key) {
89
+ return this.#cache?.get(key);
90
+ }
91
+ has(key) {
92
+ return !!this.#cache?.has(key);
93
+ }
94
+ set(key, value) {
95
+ this.#cache = this.#cache || new Map();
96
+ this.#cache.set(key, value);
97
+ return this;
42
98
  }
43
99
  }
44
100
  exports.DIContext = DIContext;
@@ -1 +1 @@
1
- {"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../../src/domain/DIContext.ts"],"names":[],"mappings":";;;AAEA,mDAAoE;AACpE,uDAAkD;AAwBlD,MAAa,SAAU,SAAQ,GAAa;IA4C1C,YAAY,EAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,EAAmB;QACzE,KAAK,EAAE,CAAC;QAlBV;;WAEG;QACM,cAAS,GAAS,IAAI,IAAI,EAAE,CAAC;QACtC;;WAEG;QACI,cAAS,GAAG,IAAI,iCAAe,EAAO,CAAC;QAY5C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QAEb,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;QAEvC,IAAI,CAAC,MAAM,GAAG,IAAI,6BAAa,CAAC,MAAM,EAAE;YACtC,GAAG,OAAO;YACV,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,EAAE;YACF,SAAS;SACV,CAAC,CAAC;IACL,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,aAAa;QACb,OAAO,IAAI,CAAC,SAAS,CAAC;QACtB,aAAa;QACb,OAAO,IAAI,CAAC,MAAM,CAAC;QACnB,aAAa;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAiB,EAAE,GAAG,IAAW;;QAC1C,OAAO,MAAA,IAAI,CAAC,QAAQ,0CAAE,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IACjD,CAAC;CACF;AA5ED,8BA4EC","sourcesContent":["import type {Env} from \"@tsed/core\";\nimport {InjectorService} from \"../services/InjectorService\";\nimport {ContextLogger, ContextLoggerOptions} from \"./ContextLogger\";\nimport {LocalsContainer} from \"./LocalsContainer\";\n\nexport interface ContextMethods extends Map<any, any> {\n readonly id: string;\n readonly logger: ContextLogger;\n readonly injector: InjectorService;\n readonly container: LocalsContainer;\n readonly env: Env;\n\n destroy(): any;\n}\n\ndeclare global {\n namespace TsED {\n interface Context {}\n }\n}\n\nexport interface DIContextOptions extends Omit<ContextLoggerOptions, \"dateStart\"> {\n id: string;\n logger: any;\n injector?: InjectorService;\n}\n\nexport class DIContext extends Map<any, any> implements ContextMethods {\n [x: string]: any;\n /**\n * Request id generated by @@contextMiddleware@@.\n *\n * ::: tip\n * By default Ts.ED generate uuid like that `uuidv4().replace(/-/gi, \"\"))`.\n * Dash are removed to simplify tracking logs in Kibana\n * :::\n *\n * ::: tip\n * Request id can by customized by changing the server configuration.\n *\n * ```typescript\n * @Configuration({\n * logger: {\n * reqIdBuilder: createUniqId // give your own id generator function\n * }\n * })\n * class Server {\n *\n * }\n * ```\n * :::\n *\n */\n readonly id: string;\n /**\n * Date when request have been handled by the server. @@RequestLogger@@ use this date to log request duration.\n */\n readonly dateStart: Date = new Date();\n /**\n * The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`\n */\n public container = new LocalsContainer<any>();\n /**\n * Logger attached to the context request.\n */\n public logger: ContextLogger;\n /**\n *\n */\n public injector: InjectorService;\n\n constructor({id, injector, logger, ignoreLog, ...options}: DIContextOptions) {\n super();\n this.id = id;\n\n injector && (this.injector = injector);\n\n this.logger = new ContextLogger(logger, {\n ...options,\n dateStart: this.dateStart,\n id,\n ignoreLog\n });\n }\n\n get env() {\n return this.injector.settings.env;\n }\n\n async destroy() {\n await this.container.destroy();\n this.logger.destroy();\n // @ts-ignore\n delete this.container;\n // @ts-ignore\n delete this.logger;\n // @ts-ignore\n delete this.injector;\n }\n\n async emit(eventName: string, ...args: any[]) {\n return this.injector?.emit(eventName, ...args);\n }\n}\n\nexport type BaseContext = DIContext & TsED.Context;\n"]}
1
+ {"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../../src/domain/DIContext.ts"],"names":[],"mappings":";;;AACA,gEAAuD;AACvD,mDAAoE;AACpE,uDAAkD;AAQlD,MAAa,SAAS;IAOD;IAJnB,UAAU,CAAmB;IAC7B,MAAM,CAAiB;IACvB,OAAO,CAAiB;IAExB,YAAmB,IAAsB;QAAtB,SAAI,GAAJ,IAAI,CAAkB;IAAG,CAAC;IAE7C;;OAEG;IACH,IAAI,MAAM;QACR,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,6BAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACtB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,QAAS,CAAC;IAC7B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACX,OAAO,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,iCAAe,EAAE,CA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AAG,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAED,GAAG,CAAC,GAAQ,EAAE,KAAU;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,GAAG,EAAY,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA7GD,8BA6GC","sourcesContent":["import {InjectorService} from \"../services/InjectorService\";\nimport {runInContext} from \"../utils/asyncHookContext\";\nimport {ContextLogger, ContextLoggerOptions} from \"./ContextLogger\";\nimport {LocalsContainer} from \"./LocalsContainer\";\n\nexport interface DIContextOptions extends Omit<ContextLoggerOptions, \"dateStart\"> {\n id: string;\n injector: InjectorService;\n logger: any;\n}\n\nexport class DIContext {\n [x: string]: any;\n\n #container?: LocalsContainer;\n #cache?: Map<any, any>;\n #logger?: ContextLogger;\n\n constructor(public opts: DIContextOptions) {}\n\n /**\n * Logger attached to the context request.\n */\n get logger() {\n this.#logger = this.#logger || new ContextLogger(this.opts);\n return this.#logger;\n }\n\n /**\n * Request id generated by @@contextMiddleware@@.\n *\n * ::: tip\n * By default Ts.ED generate uuid like that `uuidv4().replace(/-/gi, \"\"))`.\n * Dash are removed to simplify tracking logs in Kibana\n * :::\n *\n * ::: tip\n * Request id can by customized by changing the server configuration.\n *\n * ```typescript\n * @Configuration({\n * logger: {\n * reqIdBuilder: createUniqId // give your own id generator function\n * }\n * })\n * class Server {\n *\n * }\n * ```\n * :::\n *\n */\n get id() {\n return this.opts.id;\n }\n\n get dateStart() {\n return this.logger.dateStart;\n }\n\n get injector(): InjectorService {\n return this.opts.injector!;\n }\n\n get env() {\n return this.injector.settings.get(\"env\");\n }\n\n /**\n * The request container used by the Ts.ED DI. It contains all services annotated with `@Scope(ProviderScope.REQUEST)`\n */\n get container() {\n return (this.#container = this.#container || new LocalsContainer());\n }\n\n async destroy(): Promise<any> {\n return Promise.all([this.#container?.destroy(), this.#logger?.flush()]);\n }\n\n async emit(eventName: string, ...args: any[]) {\n return this.injector?.emit(eventName, ...args);\n }\n\n async runInContext(next: Function) {\n return runInContext(this, next);\n }\n\n cache<Value = any>(key: string, cb: () => Value): Value {\n if (!this.has(key)) {\n this.set(key, cb());\n }\n\n return this.get(key);\n }\n\n async cacheAsync<Value = any>(key: string, cb: () => Promise<Value>): Promise<Value> {\n if (!this.has(key)) {\n this.set(key, await cb());\n }\n\n return this.get(key);\n }\n\n delete(key: any): boolean {\n return !!this.#cache?.delete(key);\n }\n\n get<T = any>(key: any): T {\n return this.#cache?.get(key);\n }\n\n has(key: any): boolean {\n return !!this.#cache?.has(key);\n }\n\n set(key: any, value: any): this {\n this.#cache = this.#cache || new Map<any, any>();\n this.#cache.set(key, value);\n return this;\n }\n}\n\nexport type BaseContext = DIContext & TsED.Context;\n"]}
@@ -1,54 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LocalsContainer = void 0;
4
+ const core_1 = require("@tsed/core");
4
5
  class LocalsContainer extends Map {
5
- /**
6
- * Emit an event to all service. See service [lifecycle hooks](/docs/services.md#lifecycle-hooks).
7
- * @param eventName The event name to emit at all services.
8
- * @param args List of the parameters to give to each services.
9
- * @returns {Promise<any[]>} A list of promises.
10
- */
11
- async emit(eventName, ...args) {
12
- for (const handler of this.getListeners(eventName)) {
13
- await handler(...args);
14
- }
15
- }
16
- /**
17
- * @param eventName
18
- * @param value
19
- * @param args
20
- */
21
- alter(eventName, value, ...args) {
22
- for (const handler of this.getListeners(eventName)) {
23
- value = handler(value, ...args);
24
- }
25
- return value;
26
- }
27
- /**
28
- * @param eventName
29
- * @param value
30
- * @param args
31
- */
32
- async alterAsync(eventName, value, ...args) {
33
- for (const handler of this.getListeners(eventName)) {
34
- value = handler(value, ...args);
35
- }
36
- return value;
37
- }
38
- toArray() {
39
- return [...this.values()];
40
- }
6
+ hooks = new core_1.Hooks();
41
7
  async destroy() {
42
- await this.emit("$onDestroy");
43
- this.clear();
44
- }
45
- getListeners(event) {
46
- return this.toArray().reduce((listeners, instance) => {
47
- if (typeof instance === "object" && instance && event in instance) {
48
- return listeners.concat(instance[event].bind(instance));
49
- }
50
- return listeners;
51
- }, []);
8
+ await this.hooks.asyncEmit("$onDestroy");
52
9
  }
53
10
  }
54
11
  exports.LocalsContainer = LocalsContainer;
@@ -1 +1 @@
1
- {"version":3,"file":"LocalsContainer.js","sourceRoot":"","sources":["../../../src/domain/LocalsContainer.ts"],"names":[],"mappings":";;;AAEA,MAAa,eAAyB,SAAQ,GAAqB;IACjE;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CAAC,SAAiB,EAAE,GAAG,IAAW;QACjD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE;YAClD,MAAM,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;SACxB;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAU,SAAiB,EAAE,KAAU,EAAE,GAAG,IAAW;QACjE,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE;YAClD,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;SACjC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,UAAU,CAAU,SAAiB,EAAE,KAAU,EAAE,GAAG,IAAW;QAC5E,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE;YAClD,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;SACjC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO;QACL,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAES,YAAY,CAAC,KAAa;QAClC,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE;YACnD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK,IAAI,QAAQ,EAAE;gBACjE,OAAO,SAAS,CAAC,MAAM,CAAE,QAAgB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;aAClE;YAED,OAAO,SAAS,CAAC;QACnB,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF;AAzDD,0CAyDC","sourcesContent":["import type {TokenProvider} from \"../interfaces/TokenProvider\";\n\nexport class LocalsContainer<V = any> extends Map<TokenProvider, V> {\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 for (const handler of this.getListeners(eventName)) {\n await handler(...args);\n }\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 for (const handler of this.getListeners(eventName)) {\n value = handler(value, ...args);\n }\n\n return value;\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 for (const handler of this.getListeners(eventName)) {\n value = handler(value, ...args);\n }\n\n return value;\n }\n\n toArray() {\n return [...this.values()];\n }\n\n async destroy() {\n await this.emit(\"$onDestroy\");\n this.clear();\n }\n\n protected getListeners(event: string): any[] {\n return this.toArray().reduce((listeners, instance) => {\n if (typeof instance === \"object\" && instance && event in instance) {\n return listeners.concat((instance as any)[event].bind(instance));\n }\n\n return listeners;\n }, []);\n }\n}\n"]}
1
+ {"version":3,"file":"LocalsContainer.js","sourceRoot":"","sources":["../../../src/domain/LocalsContainer.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAGjC,MAAa,eAAgB,SAAQ,GAAuB;IACjD,KAAK,GAAG,IAAI,YAAK,EAAE,CAAC;IAE7B,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAC3C,CAAC;CACF;AAND,0CAMC","sourcesContent":["import {Hooks} from \"@tsed/core\";\nimport type {TokenProvider} from \"../interfaces/TokenProvider\";\n\nexport class LocalsContainer extends Map<TokenProvider, any> {\n readonly hooks = new Hooks();\n\n async destroy() {\n await this.hooks.asyncEmit(\"$onDestroy\");\n }\n}\n"]}
@@ -5,8 +5,18 @@ const core_1 = require("@tsed/core");
5
5
  const ProviderScope_1 = require("./ProviderScope");
6
6
  const ProviderType_1 = require("./ProviderType");
7
7
  class Provider {
8
+ type = ProviderType_1.ProviderType.PROVIDER;
9
+ deps;
10
+ imports;
11
+ useFactory;
12
+ useAsyncFactory;
13
+ useValue;
14
+ hooks;
15
+ _useClass;
16
+ _provide;
17
+ _store;
18
+ _tokenStore;
8
19
  constructor(token, options = {}) {
9
- this.type = ProviderType_1.ProviderType.PROVIDER;
10
20
  this.provide = token;
11
21
  this.useClass = token;
12
22
  Object.assign(this, options);
@@ -34,6 +44,15 @@ class Provider {
34
44
  if ((0, core_1.isClass)(value)) {
35
45
  this._useClass = (0, core_1.classOf)(value);
36
46
  this._store = core_1.Store.from(value);
47
+ this.hooks = (0, core_1.methodsOf)(this._useClass).reduce((hooks, { propertyKey }) => {
48
+ if (String(propertyKey).startsWith("$")) {
49
+ return {
50
+ ...hooks,
51
+ [propertyKey]: (instance, ...args) => instance[propertyKey](...args)
52
+ };
53
+ }
54
+ return hooks;
55
+ }, {});
37
56
  }
38
57
  }
39
58
  get className() {
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.js","sourceRoot":"","sources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I,WAAW;QAChB,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAChC,CAAC;IAED;;;OAGG;IACI,SAAS;QACd,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC9C,CAAC;IAED,QAAQ;QACN,OAAO;YACL,OAAO;YACP,IAAI,CAAC,IAAI;YACT,IAAI,CAAC,QAAQ,IAAI,IAAA,aAAM,EAAC,IAAI,CAAC,QAAQ,CAAC;YACtC,IAAI,CAAC,UAAU,IAAI,SAAS;YAC5B,IAAI,CAAC,QAAQ,IAAI,OAAO;YACxB,IAAI,CAAC,eAAe,IAAI,cAAc;SACvC;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;CACF;AAxJD,4BAwJC","sourcesContent":["import {classOf, getClassOrSymbol, isClass, nameOf, Store, Type} from \"@tsed/core\";\nimport {IProvider, TokenProvider} from \"../interfaces\";\nimport {ProviderScope} from \"./ProviderScope\";\nimport {ProviderType} from \"./ProviderType\";\n\nexport class Provider<T = any> implements IProvider<T> {\n public type: ProviderType | any = ProviderType.PROVIDER;\n /**\n * @deprecated Use injector.get(provider.token) instead.\n */\n public instance: T;\n public deps: TokenProvider[];\n public imports: any[];\n public useFactory: Function;\n public useAsyncFactory: Function;\n public useValue: any;\n private _useClass: Type<T>;\n private _provide: TokenProvider;\n private _store: Store;\n private _tokenStore: Store;\n\n [key: string]: any;\n\n constructor(token: TokenProvider, options: Partial<Provider> = {}) {\n this.provide = token;\n this.useClass = token;\n\n Object.assign(this, options);\n }\n\n get token() {\n return this._provide;\n }\n\n get provide(): TokenProvider {\n return this._provide;\n }\n\n set provide(value: TokenProvider) {\n if (value) {\n this._provide = getClassOrSymbol(value);\n this._tokenStore = this._store = Store.from(value);\n }\n }\n\n get useClass(): Type<T> {\n return this._useClass;\n }\n\n /**\n * Create a new store if the given value is a class. Otherwise the value is ignored.\n * @param value\n */\n set useClass(value: Type<T>) {\n if (isClass(value)) {\n this._useClass = classOf(value);\n this._store = Store.from(value);\n }\n }\n\n get className() {\n return this.name;\n }\n\n get name() {\n return nameOf(this.provide);\n }\n\n get store(): Store {\n return this._store;\n }\n\n get path() {\n return this.store.get(\"path\", \"/\");\n }\n\n set path(path: string) {\n this.store.set(\"path\", path);\n }\n\n /**\n * Get the scope of the provider.\n *\n * ::: tip Note\n * Async provider is always a SINGLETON\n * :::\n *\n * @returns {boolean}\n */\n get scope(): ProviderScope {\n if (this.isAsync()) {\n return ProviderScope.SINGLETON;\n }\n\n return this.get(\"scope\");\n }\n\n /**\n * Change the scope value of the provider.\n * @param scope\n */\n set scope(scope: ProviderScope) {\n this.store.set(\"scope\", scope);\n }\n\n get configuration(): Partial<TsED.Configuration> {\n return this.get(\"configuration\");\n }\n\n set configuration(configuration: Partial<TsED.Configuration>) {\n this.store.set(\"configuration\", configuration);\n }\n\n get children(): TokenProvider[] {\n return this.store.get(\"childrenControllers\", []);\n }\n\n get(key: string) {\n return this.store.get(key) || this._tokenStore.get(key);\n }\n\n isAsync(): boolean {\n return !!this.useAsyncFactory;\n }\n\n clone(): Provider {\n return new (classOf(this))(this._provide, this);\n }\n\n /**\n *\n * @returns {boolean}\n */\n public hasChildren(): boolean {\n return !!this.children.length;\n }\n\n /**\n *\n * @returns {boolean}\n */\n public hasParent(): boolean {\n return !!this.store.get(\"parentController\");\n }\n\n toString() {\n return [\n \"Token\",\n this.name,\n this.useClass && nameOf(this.useClass),\n this.useFactory && \"Factory\",\n this.useValue && \"Value\",\n this.useAsyncFactory && \"AsyncFactory\"\n ]\n .filter(Boolean)\n .join(\":\");\n }\n}\n"]}
1
+ {"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../src/domain/Provider.ts"],"names":[],"mappings":";;;AAAA,qCAA8F;AAG9F,mDAA8C;AAC9C,iDAA4C;AAI5C,MAAa,QAAQ;IACZ,IAAI,GAAuB,2BAAY,CAAC,Q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AC;IACjD,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO;QACL,OAAO,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IAED;;;OAGG;IACI,WAAW;QAChB,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAChC,CAAC;IAED;;;OAGG;IACI,SAAS;QACd,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC9C,CAAC;IAED,QAAQ;QACN,OAAO;YACL,OAAO;YACP,IAAI,CAAC,IAAI;YACT,IAAI,CAAC,QAAQ,IAAI,IAAA,aAAM,EAAC,IAAI,CAAC,QAAQ,CAAC;YACtC,IAAI,CAAC,UAAU,IAAI,SAAS;YAC5B,IAAI,CAAC,QAAQ,IAAI,OAAO;YACxB,IAAI,CAAC,eAAe,IAAI,cAAc;SACvC;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;CACF;AA/JD,4BA+JC","sourcesContent":["import {classOf, getClassOrSymbol, isClass, methodsOf, nameOf, Store, Type} from \"@tsed/core\";\nimport {ProviderOpts} from \"../interfaces/ProviderOpts\";\nimport {TokenProvider} from \"../interfaces/TokenProvider\";\nimport {ProviderScope} from \"./ProviderScope\";\nimport {ProviderType} from \"./ProviderType\";\n\nexport type ProviderHookCallback<T = any> = (instance: T, ...args: any[]) => Promise<void> | void;\n\nexport class Provider<T = any> implements ProviderOpts<T> {\n public type: ProviderType | any = ProviderType.PROVIDER;\n public deps: TokenProvider[];\n public imports: any[];\n public useFactory: Function;\n public useAsyncFactory: Function;\n public useValue: any;\n public hooks?: Record<string, ProviderHookCallback<T>>;\n private _useClass: Type<T>;\n private _provide: TokenProvider;\n private _store: Store;\n private _tokenStore: Store;\n\n [key: string]: any;\n\n constructor(token: TokenProvider, options: Partial<Provider> = {}) {\n this.provide = token;\n this.useClass = token;\n\n Object.assign(this, options);\n }\n\n get token() {\n return this._provide;\n }\n\n get provide(): TokenProvider {\n return this._provide;\n }\n\n set provide(value: TokenProvider) {\n if (value) {\n this._provide = getClassOrSymbol(value);\n this._tokenStore = this._store = Store.from(value);\n }\n }\n\n get useClass(): Type<T> {\n return this._useClass;\n }\n\n /**\n * Create a new store if the given value is a class. Otherwise the value is ignored.\n * @param value\n */\n set useClass(value: Type<T>) {\n if (isClass(value)) {\n this._useClass = classOf(value);\n this._store = Store.from(value);\n\n this.hooks = methodsOf(this._useClass).reduce((hooks, {propertyKey}) => {\n if (String(propertyKey).startsWith(\"$\")) {\n return {\n ...hooks,\n [propertyKey]: (instance: any, ...args: any[]) => instance[propertyKey](...args)\n };\n }\n return hooks;\n }, {} as any);\n }\n }\n\n get className() {\n return this.name;\n }\n\n get name() {\n return nameOf(this.provide);\n }\n\n get store(): Store {\n return this._store;\n }\n\n get path() {\n return this.store.get(\"path\", \"/\");\n }\n\n set path(path: string) {\n this.store.set(\"path\", path);\n }\n\n /**\n * Get the scope of the provider.\n *\n * ::: tip Note\n * Async provider is always a SINGLETON\n * :::\n *\n * @returns {boolean}\n */\n get scope(): ProviderScope {\n if (this.isAsync()) {\n return ProviderScope.SINGLETON;\n }\n\n return this.get(\"scope\");\n }\n\n /**\n * Change the scope value of the provider.\n * @param scope\n */\n set scope(scope: ProviderScope) {\n this.store.set(\"scope\", scope);\n }\n\n get configuration(): Partial<TsED.Configuration> {\n return this.get(\"configuration\");\n }\n\n set configuration(configuration: Partial<TsED.Configuration>) {\n this.store.set(\"configuration\", configuration);\n }\n\n get children(): TokenProvider[] {\n return this.store.get(\"childrenControllers\", []);\n }\n\n get(key: string) {\n return this.store.get(key) || this._tokenStore.get(key);\n }\n\n isAsync(): boolean {\n return !!this.useAsyncFactory;\n }\n\n clone(): Provider {\n return new (classOf(this))(this._provide, this);\n }\n\n /**\n *\n * @returns {boolean}\n */\n public hasChildren(): boolean {\n return !!this.children.length;\n }\n\n /**\n *\n * @returns {boolean}\n */\n public hasParent(): boolean {\n return !!this.store.get(\"parentController\");\n }\n\n toString() {\n return [\n \"Token\",\n this.name,\n this.useClass && nameOf(this.useClass),\n this.useFactory && \"Factory\",\n this.useValue && \"Value\",\n this.useAsyncFactory && \"AsyncFactory\"\n ]\n .filter(Boolean)\n .join(\":\");\n }\n}\n"]}
@@ -4,10 +4,11 @@ exports.InjectionError = void 0;
4
4
  const core_1 = require("@tsed/core");
5
5
  const colors_1 = require("../utils/colors");
6
6
  class InjectionError extends Error {
7
+ name = "INJECTION_ERROR";
8
+ tokens = [];
9
+ origin;
7
10
  constructor(token, origin) {
8
11
  super((0, core_1.isString)(origin) ? origin : "");
9
- this.name = "INJECTION_ERROR";
10
- this.tokens = [];
11
12
  this.tokens = [token];
12
13
  if (origin) {
13
14
  if ((0, core_1.isString)(origin)) {
@@ -1 +1 @@
1
- {"version":3,"file":"InjectionError.js","sourceRoot":"","sources":["../../../src/errors/InjectionError.ts"],"names":[],"mappings":";;;AAAA,qCAA6E;AAE7E,4CAAuC;AAEvC,MAAa,cAAe,SAAQ,KAAK;IAMvC,YAAY,KAAoB,EAAE,MAAY;QAC5C,KAAK,CAAC,IAAA,eAAQ,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QANxC,SAAI,GAAG,iBAAiB,CAAC;QAElB,WAAM,GAAo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\"../interfaces\";\nimport {colors} from \"../utils/colors\";\n\nexport class InjectionError extends Error {\n name = \"INJECTION_ERROR\";\n\n public tokens: TokenProvider[] = [];\n public origin: any;\n\n constructor(token: TokenProvider, origin?: any) {\n super(isString(origin) ? origin : \"\");\n\n this.tokens = [token];\n\n if (origin) {\n if (isString(origin)) {\n this.origin = {\n message: origin,\n stack: this.stack\n };\n } else {\n if (origin.tokens) {\n this.tokens = this.tokens.concat(origin.tokens);\n this.origin = origin.origin;\n } else {\n this.origin = origin;\n this.stack = origin.stack;\n }\n }\n }\n\n const originMessage = this.origin ? \"\\nOrigin: \" + this.origin.message : \"\";\n const tokensMessage = this.tokens.map((token) => nameOf(token)).join(\" > \");\n\n this.message = `Injection failed on ${tokensMessage}${originMessage}`;\n }\n\n static throwInjectorError(token: any, currentDependency: any, error: any) {\n if (currentDependency && isClass(token)) {\n error.message = printDependencyInjectionError(token, {...currentDependency, message: error.message});\n }\n\n throw new InjectionError(token, error);\n }\n}\n\nfunction printDependencyInjectionError(token: any, options: {token: any; index: number; deps: any[]; message: string}) {\n let erroredArg = \"\";\n\n const args = getConstructorArgNames(token)\n .map((arg, index) => {\n if (options.index === index) {\n erroredArg = arg;\n arg = colors.red(arg);\n }\n\n return `${arg}: ${nameOf(options.deps[index])}`;\n })\n .join(\", \");\n\n const signature = nameOf(token) + \"->constructor(\" + args + \")\";\n const indexOf = signature.indexOf(erroredArg) - 5;\n const drawline = (indexOf: number) => \" \".repeat(indexOf) + colors.red(\"^\" + \"‾\".repeat(erroredArg.length - 1));\n\n return \"Unable to inject dependency. \" + options.message + \"\\n\\n\" + signature + \"\\n\" + (indexOf > -1 ? drawline(indexOf) : \"\");\n}\n"]}
1
+ {"version":3,"file":"InjectionError.js","sourceRoot":"","sources":["../../../src/errors/InjectionError.ts"],"names":[],"mappings":";;;AAAA,qCAA6E;AAE7E,4CAAuC;AAEvC,MAAa,cAAe,SAAQ,KAAK;IACvC,IAAI,GAAG,iBAAiB,CAAC;IAElB,M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,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACjI,CAAC","sourcesContent":["import {getConstructorArgNames, isClass, isString, nameOf} from \"@tsed/core\";\nimport {TokenProvider} from \"../interfaces/TokenProvider\";\nimport {colors} from \"../utils/colors\";\n\nexport class InjectionError extends Error {\n name = \"INJECTION_ERROR\";\n\n public tokens: TokenProvider[] = [];\n public origin: any;\n\n constructor(token: TokenProvider, origin?: any) {\n super(isString(origin) ? origin : \"\");\n\n this.tokens = [token];\n\n if (origin) {\n if (isString(origin)) {\n this.origin = {\n message: origin,\n stack: this.stack\n };\n } else {\n if (origin.tokens) {\n this.tokens = this.tokens.concat(origin.tokens);\n this.origin = origin.origin;\n } else {\n this.origin = origin;\n this.stack = origin.stack;\n }\n }\n }\n\n const originMessage = this.origin ? \"\\nOrigin: \" + this.origin.message : \"\";\n const tokensMessage = this.tokens.map((token) => nameOf(token)).join(\" > \");\n\n this.message = `Injection failed on ${tokensMessage}${originMessage}`;\n }\n\n static throwInjectorError(token: any, currentDependency: any, error: any) {\n if (currentDependency && isClass(token)) {\n error.message = printDependencyInjectionError(token, {...currentDependency, message: error.message});\n }\n\n throw new InjectionError(token, error);\n }\n}\n\nfunction printDependencyInjectionError(token: any, options: {token: any; index: number; deps: any[]; message: string}) {\n let erroredArg = \"\";\n\n const args = getConstructorArgNames(token)\n .map((arg, index) => {\n if (options.index === index) {\n erroredArg = arg;\n arg = colors.red(arg);\n }\n\n return `${arg}: ${nameOf(options.deps[index])}`;\n })\n .join(\", \");\n\n const signature = nameOf(token) + \"->constructor(\" + args + \")\";\n const indexOf = signature.indexOf(erroredArg) - 5;\n const drawline = (indexOf: number) => \" \".repeat(indexOf) + colors.red(\"^\" + \"‾\".repeat(erroredArg.length - 1));\n\n return \"Unable to inject dependency. \" + options.message + \"\\n\\n\" + signature + \"\\n\" + (indexOf > -1 ? drawline(indexOf) : \"\");\n}\n"]}
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UndefinedTokenError = void 0;
4
4
  class UndefinedTokenError extends Error {
5
+ name = "UNDEFINED_TOKEN_ERROR";
5
6
  constructor() {
6
7
  super("Given token is undefined. Have you enabled emitDecoratorMetadata in your tsconfig.json or decorated your class with @Injectable, @Service, ... decorator ?");
7
- this.name = "UNDEFINED_TOKEN_ERROR";
8
8
  }
9
9
  }
10
10
  exports.UndefinedTokenError = UndefinedTokenError;
@@ -1 +1 @@
1
- {"version":3,"file":"UndefinedTokenError.js","sourceRoot":"","sources":["../../../src/errors/UndefinedTokenError.ts"],"names":[],"mappings":";;;AAAA,MAAa,mBAAoB,SAAQ,KAAK;IAG5C;QACE,KAAK,CACH,4JAA4J,CAC7J,CAAC;QALJ,SAAI,GAAG,uBAAuB,CAAC;IAM/B,CAAC;CACF;AARD,kDAQC","sourcesContent":["export class UndefinedTokenError extends Error {\n name = \"UNDEFINED_TOKEN_ERROR\";\n\n constructor() {\n super(\n \"Given token is undefined. Have you enabled emitDecoratorMetadata in your tsconfig.json or decorated your class with @Injectable, @Service, ... decorator ?\"\n );\n }\n}\n"]}
1
+ {"version":3,"file":"UndefinedTokenError.js","sourceRoot":"","sources":["../../../src/errors/UndefinedTokenError.ts"],"names":[],"mappings":";;;AAAA,MAAa,mBAAoB,SAAQ,KAAK;IAC5C,IAAI,GAAG,uBAAuB,CAAC;IAE/B;QACE,KAAK,CACH,4JAA4J,CAC7J,CAAC;IACJ,CAAC;CACF;AARD,kDAQC","sourcesContent":["export class UndefinedTokenError extends Error {\n name = \"UNDEFINED_TOKEN_ERROR\";\n\n constructor() {\n super(\n \"Given token is undefined. Have you enabled emitDecoratorMetadata in your tsconfig.json or decorated your class with @Injectable, @Service, ... decorator ?\"\n );\n }\n}\n"]}
package/lib/cjs/index.js CHANGED
@@ -1,21 +1,64 @@
1
1
  "use strict";
2
+ /**
3
+ * @file Automatically generated by barrelsby.
4
+ */
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  const tslib_1 = require("tslib");
4
- (0, tslib_1.__exportStar)(require("./constants/index"), exports);
5
- (0, tslib_1.__exportStar)(require("./domain"), exports);
6
- (0, tslib_1.__exportStar)(require("./interfaces"), exports);
7
- (0, tslib_1.__exportStar)(require("./decorators"), exports);
8
- (0, tslib_1.__exportStar)(require("./registries/ProviderRegistry"), exports);
9
- (0, tslib_1.__exportStar)(require("./registries/GlobalProviders"), exports);
10
- (0, tslib_1.__exportStar)(require("./services/InjectorService"), exports);
11
- (0, tslib_1.__exportStar)(require("./services/DILogger"), exports);
12
- (0, tslib_1.__exportStar)(require("./services/DIConfiguration"), exports);
13
- (0, tslib_1.__exportStar)(require("./services/DITest"), exports);
14
- (0, tslib_1.__exportStar)(require("./errors/InjectionError"), exports);
15
- (0, tslib_1.__exportStar)(require("./errors/UndefinedTokenError"), exports);
16
- (0, tslib_1.__exportStar)(require("./utils/createContainer"), exports);
17
- (0, tslib_1.__exportStar)(require("./utils/getConfiguration"), exports);
18
- (0, tslib_1.__exportStar)(require("./utils/getConfiguration"), exports);
19
- (0, tslib_1.__exportStar)(require("./utils/setLoggerLevel"), exports);
20
- (0, tslib_1.__exportStar)(require("./utils/colors"), exports);
7
+ tslib_1.__exportStar(require("./constants/constants"), exports);
8
+ tslib_1.__exportStar(require("./decorators/configuration"), exports);
9
+ tslib_1.__exportStar(require("./decorators/constant"), exports);
10
+ tslib_1.__exportStar(require("./decorators/controller"), exports);
11
+ tslib_1.__exportStar(require("./decorators/inject"), exports);
12
+ tslib_1.__exportStar(require("./decorators/injectable"), exports);
13
+ tslib_1.__exportStar(require("./decorators/intercept"), exports);
14
+ tslib_1.__exportStar(require("./decorators/interceptor"), exports);
15
+ tslib_1.__exportStar(require("./decorators/lazyInject"), exports);
16
+ tslib_1.__exportStar(require("./decorators/module"), exports);
17
+ tslib_1.__exportStar(require("./decorators/opts"), exports);
18
+ tslib_1.__exportStar(require("./decorators/overrideProvider"), exports);
19
+ tslib_1.__exportStar(require("./decorators/scope"), exports);
20
+ tslib_1.__exportStar(require("./decorators/service"), exports);
21
+ tslib_1.__exportStar(require("./decorators/useOpts"), exports);
22
+ tslib_1.__exportStar(require("./decorators/value"), exports);
23
+ tslib_1.__exportStar(require("./domain/Container"), exports);
24
+ tslib_1.__exportStar(require("./domain/ContextLogger"), exports);
25
+ tslib_1.__exportStar(require("./domain/ControllerProvider"), exports);
26
+ tslib_1.__exportStar(require("./domain/DIContext"), exports);
27
+ tslib_1.__exportStar(require("./domain/InjectablePropertyType"), exports);
28
+ tslib_1.__exportStar(require("./domain/LocalsContainer"), exports);
29
+ tslib_1.__exportStar(require("./domain/Provider"), exports);
30
+ tslib_1.__exportStar(require("./domain/ProviderScope"), exports);
31
+ tslib_1.__exportStar(require("./domain/ProviderType"), exports);
32
+ tslib_1.__exportStar(require("./errors/InjectionError"), exports);
33
+ tslib_1.__exportStar(require("./errors/UndefinedTokenError"), exports);
34
+ tslib_1.__exportStar(require("./interfaces/AlterRunInContext"), exports);
35
+ tslib_1.__exportStar(require("./interfaces/DIConfigurationOptions"), exports);
36
+ tslib_1.__exportStar(require("./interfaces/DILogger"), exports);
37
+ tslib_1.__exportStar(require("./interfaces/DILoggerOptions"), exports);
38
+ tslib_1.__exportStar(require("./interfaces/DIResolver"), exports);
39
+ tslib_1.__exportStar(require("./interfaces/InjectableProperties"), exports);
40
+ tslib_1.__exportStar(require("./interfaces/InterceptorContext"), exports);
41
+ tslib_1.__exportStar(require("./interfaces/InterceptorMethods"), exports);
42
+ tslib_1.__exportStar(require("./interfaces/InvokeOptions"), exports);
43
+ tslib_1.__exportStar(require("./interfaces/OnDestroy"), exports);
44
+ tslib_1.__exportStar(require("./interfaces/OnInit"), exports);
45
+ tslib_1.__exportStar(require("./interfaces/ProviderOpts"), exports);
46
+ tslib_1.__exportStar(require("./interfaces/RegistrySettings"), exports);
47
+ tslib_1.__exportStar(require("./interfaces/ResolvedInvokeOptions"), exports);
48
+ tslib_1.__exportStar(require("./interfaces/TokenProvider"), exports);
49
+ tslib_1.__exportStar(require("./interfaces/TokenRoute"), exports);
50
+ tslib_1.__exportStar(require("./registries/GlobalProviders"), exports);
51
+ tslib_1.__exportStar(require("./registries/ProviderRegistry"), exports);
52
+ tslib_1.__exportStar(require("./services/DIConfiguration"), exports);
53
+ tslib_1.__exportStar(require("./services/DILogger"), exports);
54
+ tslib_1.__exportStar(require("./services/DITest"), exports);
55
+ tslib_1.__exportStar(require("./services/InjectorService"), exports);
56
+ tslib_1.__exportStar(require("./utils/asyncHookContext"), exports);
57
+ tslib_1.__exportStar(require("./utils/colors"), exports);
58
+ tslib_1.__exportStar(require("./utils/createContainer"), exports);
59
+ tslib_1.__exportStar(require("./utils/getConfiguration"), exports);
60
+ tslib_1.__exportStar(require("./utils/resolveControllers"), exports);
61
+ tslib_1.__exportStar(require("./utils/setLoggerConfiguration"), exports);
62
+ tslib_1.__exportStar(require("./utils/setLoggerFormat"), exports);
63
+ tslib_1.__exportStar(require("./utils/setLoggerLevel"), exports);
21
64
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iEAAkC;AAClC,wDAAyB;AACzB,4DAA6B;AAC7B,4DAA6B;AAC7B,6EAA8C;AAC9C,4EAA6C;AAE7C,0EAA2C;AAC3C,mEAAoC;AACpC,0EAA2C;AAC3C,iEAAkC;AAElC,uEAAwC;AACxC,4EAA6C;AAE7C,uEAAwC;AACxC,wEAAyC;AACzC,wEAAyC;AACzC,sEAAuC;AACvC,8DAA+B","sourcesContent":["export * from \"./constants/index\";\nexport * from \"./domain\";\nexport * from \"./interfaces\";\nexport * from \"./decorators\";\nexport * from \"./registries/ProviderRegistry\";\nexport * from \"./registries/GlobalProviders\";\n\nexport * from \"./services/InjectorService\";\nexport * from \"./services/DILogger\";\nexport * from \"./services/DIConfiguration\";\nexport * from \"./services/DITest\";\n\nexport * from \"./errors/InjectionError\";\nexport * from \"./errors/UndefinedTokenError\";\n\nexport * from \"./utils/createContainer\";\nexport * from \"./utils/getConfiguration\";\nexport * from \"./utils/getConfiguration\";\nexport * from \"./utils/setLoggerLevel\";\nexport * from \"./utils/colors\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,gEAAsC;AACtC,qEAA2C;AAC3C,gEAAsC;AACtC,kEAAwC;AACxC,8DAAoC;AACpC,kEAAwC;AACxC,iEAAuC;AACvC,mEAAyC;AACzC,kEAAwC;AACxC,8DAAoC;AACpC,4DAAkC;AAClC,wEAA8C;AAC9C,6DAAmC;AACnC,+DAAqC;AACrC,+DAAqC;AACrC,6DAAmC;AACnC,6DAAmC;AACnC,iEAAuC;AACvC,sEAA4C;AAC5C,6DAAmC;AACnC,0EAAgD;AAChD,mEAAyC;AACzC,4DAAkC;AAClC,iEAAuC;AACvC,gEAAsC;AACtC,kEAAwC;AACxC,uEAA6C;AAC7C,yEAA+C;AAC/C,8EAAoD;AACpD,gEAAsC;AACtC,uEAA6C;AAC7C,kEAAwC;AACxC,4EAAkD;AAClD,0EAAgD;AAChD,0EAAgD;AAChD,qEAA2C;AAC3C,iEAAuC;AACvC,8DAAoC;AACpC,oEAA0C;AAC1C,wEAA8C;AAC9C,6EAAmD;AACnD,qEAA2C;AAC3C,kEAAwC;AACxC,uEAA6C;AAC7C,wEAA8C;AAC9C,qEAA2C;AAC3C,8DAAoC;AACpC,4DAAkC;AAClC,qEAA2C;AAC3C,mEAAyC;AACzC,yDAA+B;AAC/B,kEAAwC;AACxC,mEAAyC;AACzC,qEAA2C;AAC3C,yEAA+C;AAC/C,kEAAwC;AACxC,iEAAuC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./constants/constants\";\nexport * from \"./decorators/configuration\";\nexport * from \"./decorators/constant\";\nexport * from \"./decorators/controller\";\nexport * from \"./decorators/inject\";\nexport * from \"./decorators/injectable\";\nexport * from \"./decorators/intercept\";\nexport * from \"./decorators/interceptor\";\nexport * from \"./decorators/lazyInject\";\nexport * from \"./decorators/module\";\nexport * from \"./decorators/opts\";\nexport * from \"./decorators/overrideProvider\";\nexport * from \"./decorators/scope\";\nexport * from \"./decorators/service\";\nexport * from \"./decorators/useOpts\";\nexport * from \"./decorators/value\";\nexport * from \"./domain/Container\";\nexport * from \"./domain/ContextLogger\";\nexport * from \"./domain/ControllerProvider\";\nexport * from \"./domain/DIContext\";\nexport * from \"./domain/InjectablePropertyType\";\nexport * from \"./domain/LocalsContainer\";\nexport * from \"./domain/Provider\";\nexport * from \"./domain/ProviderScope\";\nexport * from \"./domain/ProviderType\";\nexport * from \"./errors/InjectionError\";\nexport * from \"./errors/UndefinedTokenError\";\nexport * from \"./interfaces/AlterRunInContext\";\nexport * from \"./interfaces/DIConfigurationOptions\";\nexport * from \"./interfaces/DILogger\";\nexport * from \"./interfaces/DILoggerOptions\";\nexport * from \"./interfaces/DIResolver\";\nexport * from \"./interfaces/InjectableProperties\";\nexport * from \"./interfaces/InterceptorContext\";\nexport * from \"./interfaces/InterceptorMethods\";\nexport * from \"./interfaces/InvokeOptions\";\nexport * from \"./interfaces/OnDestroy\";\nexport * from \"./interfaces/OnInit\";\nexport * from \"./interfaces/ProviderOpts\";\nexport * from \"./interfaces/RegistrySettings\";\nexport * from \"./interfaces/ResolvedInvokeOptions\";\nexport * from \"./interfaces/TokenProvider\";\nexport * from \"./interfaces/TokenRoute\";\nexport * from \"./registries/GlobalProviders\";\nexport * from \"./registries/ProviderRegistry\";\nexport * from \"./services/DIConfiguration\";\nexport * from \"./services/DILogger\";\nexport * from \"./services/DITest\";\nexport * from \"./services/InjectorService\";\nexport * from \"./utils/asyncHookContext\";\nexport * from \"./utils/colors\";\nexport * from \"./utils/createContainer\";\nexport * from \"./utils/getConfiguration\";\nexport * from \"./utils/resolveControllers\";\nexport * from \"./utils/setLoggerConfiguration\";\nexport * from \"./utils/setLoggerFormat\";\nexport * from \"./utils/setLoggerLevel\";\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AlterRunInContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AlterRunInContext.js","sourceRoot":"","sources":["../../../src/interfaces/AlterRunInContext.ts"],"names":[],"mappings":"","sourcesContent":["export interface AlterRunInContext {\n $alterRunInContext(next: (...args: unknown[]) => unknown): () => unknown | Promise<() => unknown>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DIConfigurationOptions.js","sourceRoot":"","sources":["../../../src/interfaces/DIConfigurationOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type {DIResolver} from \"./DIResolver\";\nimport type {ProviderScope} from \"../domain/ProviderScope\";\nimport type {TokenProvider} from \"./TokenProvider\";\n\ndeclare global {\n namespace TsED {\n interface Context {}\n interface Configuration {\n scopes: {[key: string]: ProviderScope};\n /**\n * Define a list of resolvers (it can be an external DI).\n */\n resolvers: DIResolver[];\n /**\n * Define dependencies to build the provider\n */\n imports: TokenProvider[];\n\n [key: string]: any;\n }\n }\n}\n\nexport interface DIConfigurationOptions extends TsED.Configuration {}\n"]}
1
+ {"version":3,"file":"DIConfigurationOptions.js","sourceRoot":"","sources":["../../../src/interfaces/DIConfigurationOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type {DIResolver} from \"./DIResolver\";\nimport type {ProviderScope} from \"../domain/ProviderScope\";\nimport type {TokenProvider} from \"./TokenProvider\";\n\ndeclare global {\n namespace TsED {\n // @ts-ignore\n interface Context {}\n interface Configuration extends Record<string, any> {\n scopes: {[key: string]: ProviderScope};\n /**\n * Define a list of resolvers (it can be an external DI).\n */\n resolvers: DIResolver[];\n /**\n * Define dependencies to build the provider\n */\n imports: TokenProvider[];\n /**\n * Mount controllers\n */\n mount: Record<string, TokenProvider[]>;\n }\n }\n}\n\nexport interface DIConfigurationOptions extends TsED.Configuration {}\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=DILoggerOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DILoggerOptions.js","sourceRoot":"","sources":["../../../src/interfaces/DILoggerOptions.ts"],"names":[],"mappings":"","sourcesContent":["export interface DILoggerOptions {\n /**\n * Enable debug mode. By default debug is false.\n */\n debug?: boolean;\n /**\n * Enable info mode. By default debug is false.\n */\n level?: \"debug\" | \"info\" | \"warn\" | \"error\" | \"off\";\n /**\n * Enable log performance tracker and disable log server.\n */\n perf?: boolean;\n /**\n * List of regexp to ignore log.\n */\n ignoreUrlPatterns?: (string | RegExp)[];\n /**\n * The number of space characters to use as white space in JSON output. Default is 2 (0 in production).\n */\n jsonIndentation?: number;\n /**\n * A function called for each incoming request to create a request id.\n * @returns {number}\n */\n reqIdBuilder?: (req: any) => string;\n /**\n * Disable routes table displayed in the logger. By default debug is `false`.\n */\n disableRoutesSummary?: boolean;\n /**\n * Disable bootstrap log displayed in the logger. By default debug is `false`.\n */\n disableBootstrapLog?: boolean;\n /**\n * Specify log format. Example: `%[%d{[yyyy-MM-dd hh:mm:ss,SSS}] %p%] %m`. See [@tsed/logger configuration](https://tsedio.github.io/logger/).\n */\n format?: string;\n /**\n * Specify the log stack size for the context.logger. When the stack.length is reach, the logger is flushed during the request.\n * Default size is set to 30.\n */\n maxStackSize?: number;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"InjectableProperties.js","sourceRoot":"","sources":["../../../src/interfaces/InjectableProperties.ts"],"names":[],"mappings":"","sourcesContent":["import type {InjectablePropertyType} from \"../domain/InjectablePropertyType\";\nimport type {TokenProvider} from \"./TokenProvider\";\nimport type {InjectorService} from \"../services/InjectorService\";\nimport type {InvokeOptions} from \"./InvokeOptions\";\n\nexport interface InjectableProperty {\n propertyKey: string;\n}\n\nexport interface InjectablePropertyOptions extends InjectableProperty {\n bindingType: InjectablePropertyType.METHOD | InjectablePropertyType.PROPERTY | InjectablePropertyType.INTERCEPTOR;\n propertyType: string;\n useType?: TokenProvider;\n resolver: (injector: InjectorService, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions> & {options: any}) => () => any;\n options?: any;\n}\n\nexport interface InjectablePropertyValue extends InjectableProperty {\n bindingType: InjectablePropertyType.CONSTANT | InjectablePropertyType.VALUE;\n expression: string;\n defaultValue?: any;\n}\n\nexport interface InjectableProperties {\n [key: string]: InjectablePropertyOptions | InjectablePropertyValue;\n}\n"]}
1
+ {"version":3,"file":"InjectableProperties.js","sourceRoot":"","sources":["../../../src/interfaces/InjectableProperties.ts"],"names":[],"mappings":"","sourcesContent":["import type {InjectablePropertyType} from \"../domain/InjectablePropertyType\";\nimport type {LocalsContainer} from \"../domain/LocalsContainer\";\nimport type {TokenProvider} from \"./TokenProvider\";\nimport type {InjectorService} from \"../services/InjectorService\";\nimport type {InvokeOptions} from \"./InvokeOptions\";\n\nexport interface InjectableProperty {\n propertyKey: string;\n}\n\nexport interface InjectablePropertyOptions extends InjectableProperty {\n bindingType: InjectablePropertyType.METHOD | InjectablePropertyType.PROPERTY | InjectablePropertyType.INTERCEPTOR;\n propertyType: string;\n useType?: TokenProvider;\n resolver: (injector: InjectorService, locals: LocalsContainer, options: Partial<InvokeOptions> & {options: any}) => () => any;\n options?: any;\n}\n\nexport interface InjectablePropertyValue extends InjectableProperty {\n bindingType: InjectablePropertyType.CONSTANT | InjectablePropertyType.VALUE;\n expression: string;\n defaultValue?: any;\n}\n\nexport interface InjectableProperties {\n [key: string]: InjectablePropertyOptions | InjectablePropertyValue;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"InterceptorMethods.js","sourceRoot":"","sources":["../../../src/interfaces/InterceptorMethods.ts"],"names":[],"mappings":"","sourcesContent":["import type {InterceptorContext, InterceptorNext} from \"./InterceptorContext\";\n\nexport interface InterceptorMethods {\n intercept?(context: InterceptorContext, next?: InterceptorNext): any;\n}\n"]}
1
+ {"version":3,"file":"InterceptorMethods.js","sourceRoot":"","sources":["../../../src/interfaces/InterceptorMethods.ts"],"names":[],"mappings":"","sourcesContent":["import type {InterceptorContext, InterceptorNext} from \"./InterceptorContext\";\n\nexport interface InterceptorMethods {\n intercept(context: InterceptorContext, next?: InterceptorNext): any;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ProviderOpts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProviderOpts.js","sourceRoot":"","sources":["../../../src/interfaces/ProviderOpts.ts"],"names":[],"mappings":"","sourcesContent":["import type {Type} from \"@tsed/core\";\nimport type {DIResolver} from \"./DIResolver\";\nimport type {ProviderScope} from \"../domain/ProviderScope\";\nimport type {ProviderType} from \"../domain/ProviderType\";\nimport type {TokenProvider} from \"./TokenProvider\";\n\nexport interface ProviderOpts<T = any> {\n /**\n * An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).\n */\n provide: TokenProvider;\n /**\n * Provider type\n */\n type?: ProviderType | string;\n /**\n * Instance build by the injector\n */\n instance?: T;\n /**\n * Define dependencies to build the provider\n */\n deps?: TokenProvider[];\n /**\n * Class to instantiate for the `token`.\n */\n useClass?: Type<T>;\n /**\n * Provide a function to build the provider\n */\n useFactory?: Function;\n /**\n * Provide an async function to build the provider\n */\n useAsyncFactory?: Function;\n /**\n * Provide predefined value\n */\n useValue?: any;\n /**\n * Scope used by the injector to build the provider.\n */\n scope?: ProviderScope;\n /**\n * A list of resolvers which will be used to resolve missing Symbol/Class when injector invoke a Class. This property allow external DI usage.\n */\n resolvers?: DIResolver[];\n\n /**\n * hooks to intercept custom events\n */\n hooks?: Record<string, (instance: T, ...args: any[]) => Promise<any> | any>;\n /**\n *\n */\n [key: string]: any;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RegistrySettings.js","sourceRoot":"","sources":["../../../src/interfaces/RegistrySettings.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport type {Provider} from \"../domain\";\nimport type {InjectorService} from \"../services/InjectorService\";\nimport type {ResolvedInvokeOptions} from \"./ResolvedInvokeOptions\";\n\n/**\n * @ignore\n */\nexport interface RegistrySettings {\n injectable?: boolean;\n model?: Type<Provider>;\n\n /**\n *\n * @param provider\n * @param {Map<string | Function, any>} locals\n * @param options\n */\n onInvoke?(provider: Provider, locals: Map<string | Function, any>, options: ResolvedInvokeOptions & {injector: InjectorService}): void;\n}\n"]}
1
+ {"version":3,"file":"RegistrySettings.js","sourceRoot":"","sources":["../../../src/interfaces/RegistrySettings.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport type {Provider} from \"../domain/Provider\";\nimport type {InjectorService} from \"../services/InjectorService\";\nimport type {ResolvedInvokeOptions} from \"./ResolvedInvokeOptions\";\n\n/**\n * @ignore\n */\nexport interface RegistrySettings {\n injectable?: boolean;\n model?: Type<Provider>;\n\n /**\n *\n * @param provider\n * @param {Map<string | Function, any>} locals\n * @param options\n */\n onInvoke?(provider: Provider, locals: Map<string | Function, any>, options: ResolvedInvokeOptions & {injector: InjectorService}): void;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TokenProvider.js","sourceRoot":"","sources":["../../../src/interfaces/TokenProvider.ts"],"names":[],"mappings":"","sourcesContent":["import type {Type} from \"@tsed/core\";\n\nexport type TokenProvider = string | symbol | Type | Function | any;\n"]}
1
+ {"version":3,"file":"TokenProvider.js","sourceRoot":"","sources":["../../../src/interfaces/TokenProvider.ts"],"names":[],"mappings":"","sourcesContent":["import type {Type} from \"@tsed/core\";\n\nexport type TokenProvider<T = any> = string | symbol | Type<T> | Function | any;\n"]}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=IProvider.js.map
3
+ //# sourceMappingURL=TokenRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TokenRoute.js","sourceRoot":"","sources":["../../../src/interfaces/TokenRoute.ts"],"names":[],"mappings":"","sourcesContent":["import {TokenProvider} from \"./TokenProvider\";\n\nexport interface TokenRoute {\n token: TokenProvider;\n route: string;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }