@tsed/di 7.83.3 → 8.0.0-alpha.10

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 (289) hide show
  1. package/lib/browser/di.umd.min.js +1 -1
  2. package/lib/browser/di.umd.min.js.map +1 -1
  3. package/lib/esm/common/constants/constants.js +5 -3
  4. package/lib/esm/common/constants/constants.js.map +1 -1
  5. package/lib/esm/common/decorators/autoInjectable.js +23 -3
  6. package/lib/esm/common/decorators/autoInjectable.js.map +1 -1
  7. package/lib/esm/common/decorators/configuration.js.map +1 -1
  8. package/lib/esm/common/decorators/constant.js +28 -11
  9. package/lib/esm/common/decorators/constant.js.map +1 -1
  10. package/lib/esm/common/decorators/controller.js.map +1 -1
  11. package/lib/esm/common/decorators/inject.js +63 -73
  12. package/lib/esm/common/decorators/inject.js.map +1 -1
  13. package/lib/esm/common/decorators/intercept.js +40 -13
  14. package/lib/esm/common/decorators/intercept.js.map +1 -1
  15. package/lib/esm/common/decorators/lazyInject.js +15 -15
  16. package/lib/esm/common/decorators/lazyInject.js.map +1 -1
  17. package/lib/esm/common/decorators/module.js +1 -1
  18. package/lib/esm/common/decorators/module.js.map +1 -1
  19. package/lib/esm/common/decorators/opts.js +2 -2
  20. package/lib/esm/common/decorators/opts.js.map +1 -1
  21. package/lib/esm/common/decorators/overrideProvider.js.map +1 -1
  22. package/lib/esm/common/decorators/scope.js.map +1 -1
  23. package/lib/esm/common/decorators/useOpts.js +3 -7
  24. package/lib/esm/common/decorators/useOpts.js.map +1 -1
  25. package/lib/esm/common/decorators/value.js +17 -11
  26. package/lib/esm/common/decorators/value.js.map +1 -1
  27. package/lib/esm/common/domain/Container.js +3 -3
  28. package/lib/esm/common/domain/Container.js.map +1 -1
  29. package/lib/esm/common/domain/LocalsContainer.js.map +1 -1
  30. package/lib/esm/common/domain/Provider.js +1 -1
  31. package/lib/esm/common/domain/Provider.js.map +1 -1
  32. package/lib/esm/common/errors/InjectionError.js.map +1 -1
  33. package/lib/esm/common/index.js +0 -2
  34. package/lib/esm/common/index.js.map +1 -1
  35. package/lib/esm/common/registries/GlobalProviders.js +7 -7
  36. package/lib/esm/common/registries/GlobalProviders.js.map +1 -1
  37. package/lib/esm/common/registries/ProviderRegistry.js.map +1 -1
  38. package/lib/esm/common/services/DIConfiguration.js.map +1 -1
  39. package/lib/esm/common/services/InjectorService.js +50 -167
  40. package/lib/esm/common/services/InjectorService.js.map +1 -1
  41. package/lib/esm/common/utils/createContainer.js.map +1 -1
  42. package/lib/esm/common/utils/resolveControllers.js +1 -1
  43. package/lib/esm/common/utils/resolveControllers.js.map +1 -1
  44. package/lib/esm/node/decorators/injectContext.js +14 -5
  45. package/lib/esm/node/decorators/injectContext.js.map +1 -1
  46. package/lib/esm/node/domain/ContextLogger.js +2 -2
  47. package/lib/esm/node/domain/ContextLogger.js.map +1 -1
  48. package/lib/esm/node/domain/DIContext.js.map +1 -1
  49. package/lib/esm/node/services/DILogger.js.map +1 -1
  50. package/lib/esm/node/services/DITest.js +10 -5
  51. package/lib/esm/node/services/DITest.js.map +1 -1
  52. package/lib/esm/node/utils/asyncHookContext.js +3 -2
  53. package/lib/esm/node/utils/asyncHookContext.js.map +1 -1
  54. package/lib/esm/node/utils/setLoggerFormat.js.map +1 -1
  55. package/lib/esm/node/utils/setLoggerLevel.js.map +1 -1
  56. package/lib/types/common/constants/constants.d.ts +5 -3
  57. package/lib/types/common/decorators/constant.d.ts +4 -1
  58. package/lib/types/common/decorators/inject.d.ts +17 -4
  59. package/lib/types/common/decorators/intercept.d.ts +3 -0
  60. package/lib/types/common/decorators/module.d.ts +1 -1
  61. package/lib/types/common/decorators/value.d.ts +2 -1
  62. package/lib/types/common/domain/Container.d.ts +4 -4
  63. package/lib/types/common/domain/Provider.d.ts +6 -6
  64. package/lib/types/common/index.d.ts +0 -2
  65. package/lib/types/common/interfaces/ImportTokenProviderOpts.d.ts +2 -2
  66. package/lib/types/common/interfaces/InterceptorContext.d.ts +1 -1
  67. package/lib/types/common/interfaces/InvokeOptions.d.ts +8 -2
  68. package/lib/types/common/interfaces/ProviderOpts.d.ts +2 -2
  69. package/lib/types/common/interfaces/RegistrySettings.d.ts +2 -1
  70. package/lib/types/common/interfaces/ResolvedInvokeOptions.d.ts +1 -1
  71. package/lib/types/common/interfaces/TokenProvider.d.ts +2 -6
  72. package/lib/types/common/registries/GlobalProviders.d.ts +2 -2
  73. package/lib/types/common/services/InjectorService.d.ts +30 -54
  74. package/lib/types/node/decorators/injectContext.d.ts +2 -1
  75. package/lib/types/node/domain/ContextLogger.d.ts +3 -3
  76. package/lib/types/node/domain/DIContext.d.ts +1 -1
  77. package/lib/types/node/services/DITest.d.ts +1 -1
  78. package/lib/types/node/utils/asyncHookContext.d.ts +4 -3
  79. package/package.json +21 -18
  80. package/lib/cjs/common/constants/constants.js +0 -7
  81. package/lib/cjs/common/constants/constants.js.map +0 -1
  82. package/lib/cjs/common/decorators/autoInjectable.js +0 -18
  83. package/lib/cjs/common/decorators/autoInjectable.js.map +0 -1
  84. package/lib/cjs/common/decorators/configuration.js +0 -24
  85. package/lib/cjs/common/decorators/configuration.js.map +0 -1
  86. package/lib/cjs/common/decorators/constant.js +0 -55
  87. package/lib/cjs/common/decorators/constant.js.map +0 -1
  88. package/lib/cjs/common/decorators/controller.js +0 -53
  89. package/lib/cjs/common/decorators/controller.js.map +0 -1
  90. package/lib/cjs/common/decorators/inject.js +0 -93
  91. package/lib/cjs/common/decorators/inject.js.map +0 -1
  92. package/lib/cjs/common/decorators/injectable.js +0 -32
  93. package/lib/cjs/common/decorators/injectable.js.map +0 -1
  94. package/lib/cjs/common/decorators/intercept.js +0 -36
  95. package/lib/cjs/common/decorators/intercept.js.map +0 -1
  96. package/lib/cjs/common/decorators/interceptor.js +0 -21
  97. package/lib/cjs/common/decorators/interceptor.js.map +0 -1
  98. package/lib/cjs/common/decorators/lazyInject.js +0 -71
  99. package/lib/cjs/common/decorators/lazyInject.js.map +0 -1
  100. package/lib/cjs/common/decorators/module.js +0 -32
  101. package/lib/cjs/common/decorators/module.js.map +0 -1
  102. package/lib/cjs/common/decorators/opts.js +0 -54
  103. package/lib/cjs/common/decorators/opts.js.map +0 -1
  104. package/lib/cjs/common/decorators/overrideProvider.js +0 -17
  105. package/lib/cjs/common/decorators/overrideProvider.js.map +0 -1
  106. package/lib/cjs/common/decorators/scope.js +0 -16
  107. package/lib/cjs/common/decorators/scope.js.map +0 -1
  108. package/lib/cjs/common/decorators/service.js +0 -18
  109. package/lib/cjs/common/decorators/service.js.map +0 -1
  110. package/lib/cjs/common/decorators/useOpts.js +0 -65
  111. package/lib/cjs/common/decorators/useOpts.js.map +0 -1
  112. package/lib/cjs/common/decorators/value.js +0 -55
  113. package/lib/cjs/common/decorators/value.js.map +0 -1
  114. package/lib/cjs/common/domain/Container.js +0 -72
  115. package/lib/cjs/common/domain/Container.js.map +0 -1
  116. package/lib/cjs/common/domain/ControllerProvider.js +0 -36
  117. package/lib/cjs/common/domain/ControllerProvider.js.map +0 -1
  118. package/lib/cjs/common/domain/InjectablePropertyType.js +0 -12
  119. package/lib/cjs/common/domain/InjectablePropertyType.js.map +0 -1
  120. package/lib/cjs/common/domain/LocalsContainer.js +0 -15
  121. package/lib/cjs/common/domain/LocalsContainer.js.map +0 -1
  122. package/lib/cjs/common/domain/Provider.js +0 -134
  123. package/lib/cjs/common/domain/Provider.js.map +0 -1
  124. package/lib/cjs/common/domain/ProviderScope.js +0 -10
  125. package/lib/cjs/common/domain/ProviderScope.js.map +0 -1
  126. package/lib/cjs/common/domain/ProviderType.js +0 -15
  127. package/lib/cjs/common/domain/ProviderType.js.map +0 -1
  128. package/lib/cjs/common/errors/InjectionError.js +0 -58
  129. package/lib/cjs/common/errors/InjectionError.js.map +0 -1
  130. package/lib/cjs/common/errors/InvalidPropertyTokenError.js +0 -12
  131. package/lib/cjs/common/errors/InvalidPropertyTokenError.js.map +0 -1
  132. package/lib/cjs/common/errors/UndefinedTokenError.js +0 -11
  133. package/lib/cjs/common/errors/UndefinedTokenError.js.map +0 -1
  134. package/lib/cjs/common/index.js +0 -60
  135. package/lib/cjs/common/index.js.map +0 -1
  136. package/lib/cjs/common/interfaces/DIConfigurationOptions.js +0 -3
  137. package/lib/cjs/common/interfaces/DIConfigurationOptions.js.map +0 -1
  138. package/lib/cjs/common/interfaces/DILogger.js +0 -3
  139. package/lib/cjs/common/interfaces/DILogger.js.map +0 -1
  140. package/lib/cjs/common/interfaces/DILoggerOptions.js +0 -3
  141. package/lib/cjs/common/interfaces/DILoggerOptions.js.map +0 -1
  142. package/lib/cjs/common/interfaces/DIResolver.js +0 -3
  143. package/lib/cjs/common/interfaces/DIResolver.js.map +0 -1
  144. package/lib/cjs/common/interfaces/ImportTokenProviderOpts.js +0 -3
  145. package/lib/cjs/common/interfaces/ImportTokenProviderOpts.js.map +0 -1
  146. package/lib/cjs/common/interfaces/InjectableProperties.js +0 -3
  147. package/lib/cjs/common/interfaces/InjectableProperties.js.map +0 -1
  148. package/lib/cjs/common/interfaces/InterceptorContext.js +0 -3
  149. package/lib/cjs/common/interfaces/InterceptorContext.js.map +0 -1
  150. package/lib/cjs/common/interfaces/InterceptorMethods.js +0 -3
  151. package/lib/cjs/common/interfaces/InterceptorMethods.js.map +0 -1
  152. package/lib/cjs/common/interfaces/InvokeOptions.js +0 -3
  153. package/lib/cjs/common/interfaces/InvokeOptions.js.map +0 -1
  154. package/lib/cjs/common/interfaces/OnDestroy.js +0 -3
  155. package/lib/cjs/common/interfaces/OnDestroy.js.map +0 -1
  156. package/lib/cjs/common/interfaces/OnInit.js +0 -3
  157. package/lib/cjs/common/interfaces/OnInit.js.map +0 -1
  158. package/lib/cjs/common/interfaces/ProviderOpts.js +0 -3
  159. package/lib/cjs/common/interfaces/ProviderOpts.js.map +0 -1
  160. package/lib/cjs/common/interfaces/RegistrySettings.js +0 -3
  161. package/lib/cjs/common/interfaces/RegistrySettings.js.map +0 -1
  162. package/lib/cjs/common/interfaces/ResolvedInvokeOptions.js +0 -3
  163. package/lib/cjs/common/interfaces/ResolvedInvokeOptions.js.map +0 -1
  164. package/lib/cjs/common/interfaces/TokenProvider.js +0 -3
  165. package/lib/cjs/common/interfaces/TokenProvider.js.map +0 -1
  166. package/lib/cjs/common/interfaces/TokenRoute.js +0 -3
  167. package/lib/cjs/common/interfaces/TokenRoute.js.map +0 -1
  168. package/lib/cjs/common/registries/GlobalProviders.js +0 -117
  169. package/lib/cjs/common/registries/GlobalProviders.js.map +0 -1
  170. package/lib/cjs/common/registries/ProviderRegistry.js +0 -86
  171. package/lib/cjs/common/registries/ProviderRegistry.js.map +0 -1
  172. package/lib/cjs/common/services/DIConfiguration.js +0 -142
  173. package/lib/cjs/common/services/DIConfiguration.js.map +0 -1
  174. package/lib/cjs/common/services/DILogger.js +0 -14
  175. package/lib/cjs/common/services/DILogger.js.map +0 -1
  176. package/lib/cjs/common/services/InjectorService.js +0 -653
  177. package/lib/cjs/common/services/InjectorService.js.map +0 -1
  178. package/lib/cjs/common/utils/colors.js +0 -10
  179. package/lib/cjs/common/utils/colors.js.map +0 -1
  180. package/lib/cjs/common/utils/createContainer.js +0 -14
  181. package/lib/cjs/common/utils/createContainer.js.map +0 -1
  182. package/lib/cjs/common/utils/getConfiguration.js +0 -23
  183. package/lib/cjs/common/utils/getConfiguration.js.map +0 -1
  184. package/lib/cjs/common/utils/getConstructorDependencies.js +0 -13
  185. package/lib/cjs/common/utils/getConstructorDependencies.js.map +0 -1
  186. package/lib/cjs/common/utils/resolveControllers.js +0 -47
  187. package/lib/cjs/common/utils/resolveControllers.js.map +0 -1
  188. package/lib/cjs/index.js +0 -6
  189. package/lib/cjs/index.js.map +0 -1
  190. package/lib/cjs/node/decorators/injectContext.js +0 -30
  191. package/lib/cjs/node/decorators/injectContext.js.map +0 -1
  192. package/lib/cjs/node/domain/ContextLogger.js +0 -99
  193. package/lib/cjs/node/domain/ContextLogger.js.map +0 -1
  194. package/lib/cjs/node/domain/DIContext.js +0 -102
  195. package/lib/cjs/node/domain/DIContext.js.map +0 -1
  196. package/lib/cjs/node/index.js +0 -18
  197. package/lib/cjs/node/index.js.map +0 -1
  198. package/lib/cjs/node/interfaces/AlterRunInContext.js +0 -3
  199. package/lib/cjs/node/interfaces/AlterRunInContext.js.map +0 -1
  200. package/lib/cjs/node/services/DILogger.js +0 -12
  201. package/lib/cjs/node/services/DILogger.js.map +0 -1
  202. package/lib/cjs/node/services/DITest.js +0 -121
  203. package/lib/cjs/node/services/DITest.js.map +0 -1
  204. package/lib/cjs/node/utils/asyncHookContext.js +0 -42
  205. package/lib/cjs/node/utils/asyncHookContext.js.map +0 -1
  206. package/lib/cjs/node/utils/attachLogger.js +0 -10
  207. package/lib/cjs/node/utils/attachLogger.js.map +0 -1
  208. package/lib/cjs/node/utils/setLoggerConfiguration.js +0 -11
  209. package/lib/cjs/node/utils/setLoggerConfiguration.js.map +0 -1
  210. package/lib/cjs/node/utils/setLoggerFormat.js +0 -33
  211. package/lib/cjs/node/utils/setLoggerFormat.js.map +0 -1
  212. package/lib/cjs/node/utils/setLoggerLevel.js +0 -15
  213. package/lib/cjs/node/utils/setLoggerLevel.js.map +0 -1
  214. package/lib/cjs/package.json +0 -3
  215. package/lib/esm/common/errors/UndefinedTokenError.js +0 -7
  216. package/lib/esm/common/errors/UndefinedTokenError.js.map +0 -1
  217. package/lib/esm/common/interfaces/InjectableProperties.js +0 -2
  218. package/lib/esm/common/interfaces/InjectableProperties.js.map +0 -1
  219. package/lib/esm/package.json +0 -3
  220. package/lib/types/common/errors/UndefinedTokenError.d.ts +0 -4
  221. package/lib/types/common/interfaces/InjectableProperties.d.ts +0 -25
  222. package/lib/types-esm/common/constants/constants.d.ts +0 -3
  223. package/lib/types-esm/common/decorators/autoInjectable.d.ts +0 -1
  224. package/lib/types-esm/common/decorators/configuration.d.ts +0 -8
  225. package/lib/types-esm/common/decorators/constant.d.ts +0 -36
  226. package/lib/types-esm/common/decorators/controller.d.ts +0 -42
  227. package/lib/types-esm/common/decorators/inject.d.ts +0 -22
  228. package/lib/types-esm/common/decorators/injectable.d.ts +0 -20
  229. package/lib/types-esm/common/decorators/intercept.d.ts +0 -10
  230. package/lib/types-esm/common/decorators/interceptor.d.ts +0 -10
  231. package/lib/types-esm/common/decorators/lazyInject.d.ts +0 -43
  232. package/lib/types-esm/common/decorators/module.d.ts +0 -37
  233. package/lib/types-esm/common/decorators/opts.d.ts +0 -41
  234. package/lib/types-esm/common/decorators/overrideProvider.d.ts +0 -8
  235. package/lib/types-esm/common/decorators/scope.d.ts +0 -8
  236. package/lib/types-esm/common/decorators/service.d.ts +0 -10
  237. package/lib/types-esm/common/decorators/useOpts.d.ts +0 -42
  238. package/lib/types-esm/common/decorators/value.d.ts +0 -36
  239. package/lib/types-esm/common/domain/Container.d.ts +0 -43
  240. package/lib/types-esm/common/domain/ControllerProvider.d.ts +0 -17
  241. package/lib/types-esm/common/domain/InjectablePropertyType.d.ts +0 -7
  242. package/lib/types-esm/common/domain/LocalsContainer.d.ts +0 -6
  243. package/lib/types-esm/common/domain/Provider.d.ts +0 -71
  244. package/lib/types-esm/common/domain/ProviderScope.d.ts +0 -5
  245. package/lib/types-esm/common/domain/ProviderType.d.ts +0 -10
  246. package/lib/types-esm/common/errors/InjectionError.d.ts +0 -8
  247. package/lib/types-esm/common/errors/InvalidPropertyTokenError.d.ts +0 -4
  248. package/lib/types-esm/common/errors/UndefinedTokenError.d.ts +0 -4
  249. package/lib/types-esm/common/index.d.ts +0 -56
  250. package/lib/types-esm/common/interfaces/DIConfigurationOptions.d.ts +0 -29
  251. package/lib/types-esm/common/interfaces/DILogger.d.ts +0 -8
  252. package/lib/types-esm/common/interfaces/DILoggerOptions.d.ts +0 -53
  253. package/lib/types-esm/common/interfaces/DIResolver.d.ts +0 -5
  254. package/lib/types-esm/common/interfaces/ImportTokenProviderOpts.d.ts +0 -19
  255. package/lib/types-esm/common/interfaces/InjectableProperties.d.ts +0 -25
  256. package/lib/types-esm/common/interfaces/InterceptorContext.d.ts +0 -11
  257. package/lib/types-esm/common/interfaces/InterceptorMethods.d.ts +0 -4
  258. package/lib/types-esm/common/interfaces/InvokeOptions.d.ts +0 -24
  259. package/lib/types-esm/common/interfaces/OnDestroy.d.ts +0 -3
  260. package/lib/types-esm/common/interfaces/OnInit.d.ts +0 -3
  261. package/lib/types-esm/common/interfaces/ProviderOpts.d.ts +0 -59
  262. package/lib/types-esm/common/interfaces/RegistrySettings.d.ts +0 -20
  263. package/lib/types-esm/common/interfaces/ResolvedInvokeOptions.d.ts +0 -12
  264. package/lib/types-esm/common/interfaces/TokenProvider.d.ts +0 -6
  265. package/lib/types-esm/common/interfaces/TokenRoute.d.ts +0 -5
  266. package/lib/types-esm/common/registries/GlobalProviders.d.ts +0 -58
  267. package/lib/types-esm/common/registries/ProviderRegistry.d.ts +0 -58
  268. package/lib/types-esm/common/services/DIConfiguration.d.ts +0 -57
  269. package/lib/types-esm/common/services/DILogger.d.ts +0 -3
  270. package/lib/types-esm/common/services/InjectorService.d.ts +0 -227
  271. package/lib/types-esm/common/utils/colors.d.ts +0 -5
  272. package/lib/types-esm/common/utils/createContainer.d.ts +0 -3
  273. package/lib/types-esm/common/utils/getConfiguration.d.ts +0 -3
  274. package/lib/types-esm/common/utils/getConstructorDependencies.d.ts +0 -2
  275. package/lib/types-esm/common/utils/resolveControllers.d.ts +0 -12
  276. package/lib/types-esm/index.d.ts +0 -2
  277. package/lib/types-esm/node/decorators/injectContext.d.ts +0 -15
  278. package/lib/types-esm/node/domain/ContextLogger.d.ts +0 -37
  279. package/lib/types-esm/node/domain/DIContext.d.ts +0 -61
  280. package/lib/types-esm/node/index.d.ts +0 -14
  281. package/lib/types-esm/node/interfaces/AlterRunInContext.d.ts +0 -3
  282. package/lib/types-esm/node/services/DILogger.d.ts +0 -1
  283. package/lib/types-esm/node/services/DITest.d.ts +0 -37
  284. package/lib/types-esm/node/utils/asyncHookContext.d.ts +0 -14
  285. package/lib/types-esm/node/utils/attachLogger.d.ts +0 -2
  286. package/lib/types-esm/node/utils/setLoggerConfiguration.d.ts +0 -2
  287. package/lib/types-esm/node/utils/setLoggerFormat.d.ts +0 -6
  288. package/lib/types-esm/node/utils/setLoggerLevel.d.ts +0 -6
  289. /package/{webpack.config.js → webpack.config.cjs} +0 -0
@@ -1,10 +1,8 @@
1
- import { type Type } from "@tsed/core";
2
1
  import { Container } from "../domain/Container.js";
3
2
  import { LocalsContainer } from "../domain/LocalsContainer.js";
4
3
  import { Provider } from "../domain/Provider.js";
5
4
  import { ProviderScope } from "../domain/ProviderScope.js";
6
5
  import type { DILogger } from "../interfaces/DILogger.js";
7
- import { InjectablePropertyOptions, InjectablePropertyValue } from "../interfaces/InjectableProperties.js";
8
6
  import type { InvokeOptions } from "../interfaces/InvokeOptions.js";
9
7
  import type { TokenProvider } from "../interfaces/TokenProvider.js";
10
8
  import { DIConfiguration } from "./DIConfiguration.js";
@@ -37,8 +35,18 @@ export declare class InjectorService extends Container {
37
35
  constructor();
38
36
  get resolvers(): import("../index.js").DIResolver[];
39
37
  get scopes(): Record<string, ProviderScope>;
40
- static resolveAutoInjectableArgs(token: Type, locals: LocalsContainer, args: unknown[]): any[];
41
- static bind(instance: any, locals: LocalsContainer): void;
38
+ /**
39
+ * Return the current injector service.
40
+ */
41
+ static getInstance(): InjectorService;
42
+ /**
43
+ * Get the locals container initiated by DITest or .bootstrap() method.
44
+ */
45
+ static getLocals(): LocalsContainer;
46
+ /**
47
+ * Reset the locals container.
48
+ */
49
+ static unsetLocals(): void;
42
50
  /**
43
51
  * Retrieve default scope for a given provider.
44
52
  * @param provider
@@ -66,22 +74,19 @@ export declare class InjectorService extends Container {
66
74
  *
67
75
  * @param token The class or symbol registered in InjectorService.
68
76
  * @param options
69
- * @returns {boolean}
70
77
  */
71
- get<T = any>(token: TokenProvider<T>, options?: any): T | undefined;
78
+ get<T = any>(token: TokenProvider<T>, options?: Record<string, unknown>): T | undefined;
72
79
  /**
73
80
  * Return all instance of the same provider type
74
- * @param type
75
- * @param locals
76
- * @param options
77
81
  */
78
82
  getMany<Type = any>(type: any, locals?: LocalsContainer, options?: Partial<InvokeOptions>): Type[];
79
83
  /**
80
84
  * The has() method returns a boolean indicating whether an element with the specified key exists or not.
81
- * @returns {boolean}
82
- * @param token
83
85
  */
84
86
  has(token: TokenProvider): boolean;
87
+ /**
88
+ * Declare an alias for a given token.
89
+ */
85
90
  alias(token: TokenProvider, alias: TokenProvider): this;
86
91
  /**
87
92
  * Invoke the class and inject all services that required by the class constructor.
@@ -104,11 +109,14 @@ export declare class InjectorService extends Container {
104
109
  * @param options
105
110
  * @returns {Type} The class constructed.
106
111
  */
107
- invoke<Type = any>(token: TokenProvider, locals?: LocalsContainer, options?: Partial<InvokeOptions>): Type;
112
+ invoke<Type = any>(token: TokenProvider<Type>, locals?: LocalsContainer, options?: Partial<InvokeOptions>): Type;
108
113
  /**
109
114
  * Build only providers which are asynchronous.
110
115
  */
111
116
  loadAsync(): Promise<void>;
117
+ /**
118
+ * Build only providers which are synchronous.
119
+ */
112
120
  loadSync(): void;
113
121
  /**
114
122
  * Boostrap injector from container and resolve configuration.
@@ -131,68 +139,36 @@ export declare class InjectorService extends Container {
131
139
  * Load all configurations registered on providers
132
140
  */
133
141
  resolveConfiguration(): void;
134
- /**
135
- *
136
- * @param instance
137
- * @param locals
138
- * @param options
139
- */
140
- bindInjectableProperties(instance: any, locals: LocalsContainer, options: Partial<InvokeOptions>): void;
141
- /**
142
- * Create an injectable property.
143
- *
144
- * @param instance
145
- * @param {string} propertyKey
146
- * @param {any} useType
147
- * @param resolver
148
- * @param options
149
- * @param locals
150
- * @param invokeOptions
151
- */
152
- bindProperty(instance: any, { propertyKey, resolver, options }: InjectablePropertyOptions, locals: LocalsContainer, invokeOptions: Partial<InvokeOptions>): void;
153
- /**
154
- *
155
- * @param instance
156
- * @param {string} propertyKey
157
- * @param {any} useType
158
- */
159
- bindValue(instance: any, { propertyKey, expression, defaultValue }: InjectablePropertyValue): void;
160
- /**
161
- *
162
- * @param instance
163
- * @param {string} propertyKey
164
- * @param {any} useType
165
- */
166
- bindConstant(instance: any, { propertyKey, expression, defaultValue }: InjectablePropertyValue): void;
167
- /**
168
- *
169
- * @param instance
170
- * @param propertyKey
171
- * @param useType
172
- * @param options
173
- */
174
- bindInterceptor(instance: any, { propertyKey, useType, options }: InjectablePropertyOptions): void;
175
142
  lazyInvoke<T = any>(token: TokenProvider): Promise<any>;
176
143
  /**
177
144
  * Emit an event to all service. See service [lifecycle hooks](/docs/services.md#lifecycle-hooks).
178
145
  * @param eventName The event name to emit at all services.
179
146
  * @param args List of the parameters to give to each service.
180
- * @returns {Promise<any[]>} A list of promises.
147
+ * @returns A list of promises.
181
148
  */
182
149
  emit(eventName: string, ...args: any[]): Promise<void>;
183
150
  /**
151
+ * Alter value attached to an event.
184
152
  * @param eventName
185
153
  * @param value
186
154
  * @param args
187
155
  */
188
156
  alter<T = any>(eventName: string, value: any, ...args: any[]): T;
189
157
  /**
158
+ * Alter value attached to an event asynchronously.
190
159
  * @param eventName
191
160
  * @param value
192
161
  * @param args
193
162
  */
194
163
  alterAsync<T = any>(eventName: string, value: any, ...args: any[]): Promise<T>;
164
+ /**
165
+ * Destroy the injector and all services.
166
+ */
195
167
  destroy(): Promise<void>;
168
+ /**
169
+ * Ensure that a provider is added to the container.
170
+ * @protected
171
+ */
196
172
  protected ensureProvider(token: TokenProvider, force: true): Provider;
197
173
  protected ensureProvider(token: TokenProvider, force: false): Provider | undefined;
198
174
  protected ensureProvider(token: TokenProvider): Provider | undefined;
@@ -1,3 +1,4 @@
1
+ import { DIContext } from "../domain/DIContext.js";
1
2
  /**
2
3
  * Inject a context like PlatformContext or any BaseContext.
3
4
  *
@@ -12,4 +13,4 @@
12
13
  * @returns {Function}
13
14
  * @decorator
14
15
  */
15
- export declare function InjectContext(): PropertyDecorator;
16
+ export declare function InjectContext(transform?: ($ctx: DIContext) => unknown): PropertyDecorator;
@@ -1,6 +1,6 @@
1
- import { DILogger } from "../../common/index.js";
2
1
  import { Hooks } from "@tsed/core";
3
2
  import { LogLevel } from "@tsed/logger";
3
+ import { DILogger } from "../../common/index.js";
4
4
  export interface ContextLoggerOptions extends Record<string, any> {
5
5
  id: string;
6
6
  logger?: DILogger;
@@ -17,10 +17,10 @@ export declare class ContextLogger {
17
17
  constructor({ id, logger, dateStart, level, maxStackSize, additionalProps }: ContextLoggerOptions);
18
18
  get hooks(): Hooks;
19
19
  private get stack();
20
- alterLog(cb: (data: any, level: "debug" | "info" | "warn" | "error" | "off" | "all", withRequest: boolean) => any): Hooks;
20
+ alterLog(cb: (data: any, level: "debug" | "info" | "warn" | "error" | "all", withRequest: boolean) => any): Hooks;
21
21
  alterIgnoreLog(cb: (ignore: boolean, data: any) => boolean): Hooks;
22
22
  info(obj: any): this;
23
- debug(obj: any, withRequest?: boolean): this;
23
+ debug(obj: any): this;
24
24
  warn(obj: any): this;
25
25
  error(obj: any): this;
26
26
  fatal(obj: any): this;
@@ -50,7 +50,7 @@ export declare class DIContext {
50
50
  get container(): LocalsContainer;
51
51
  destroy(): Promise<any>;
52
52
  emit(eventName: string, ...args: any[]): Promise<void>;
53
- runInContext(next: Function): Promise<any>;
53
+ runInContext<Result = unknown>(next: (...args: unknown[]) => Result): Promise<Result>;
54
54
  cache<Value = any>(key: string, cb: () => Value): Value;
55
55
  cacheAsync<Value = any>(key: string, cb: () => Promise<Value>): Promise<Value>;
56
56
  delete(key: any): boolean;
@@ -25,7 +25,7 @@ export declare class DITest {
25
25
  * @param target
26
26
  * @param providers
27
27
  */
28
- static invoke<T = any>(target: TokenProvider, providers?: UseImportTokenProviderOpts[]): Promise<T>;
28
+ static invoke<T = any>(target: TokenProvider<T>, providers?: UseImportTokenProviderOpts[]): Promise<T>;
29
29
  /**
30
30
  * Return the instance from injector registry
31
31
  * @param target
@@ -1,4 +1,4 @@
1
- /// <reference types="node" />
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  import { AsyncLocalStorage } from "async_hooks";
3
3
  import { InjectorService } from "../../common/index.js";
4
4
  import type { DIContext } from "../domain/DIContext.js";
@@ -8,7 +8,8 @@ export declare function getAsyncStore(): AsyncLocalStorage<{
8
8
  export declare function useContextRef(): {
9
9
  current: DIContext | undefined;
10
10
  } | undefined;
11
- export declare function getContext<Context = DIContext>(): Context | undefined;
12
- export declare function runInContext(ctx: DIContext | undefined, cb: any, injector?: InjectorService): Promise<any>;
11
+ export declare function useContext<Context = DIContext>(initialValue?: DIContext): Context | undefined;
12
+ export declare const getContext: typeof useContext;
13
+ export declare function runInContext<Result = unknown>(ctx: DIContext | undefined, cb: (...args: unknown[]) => Result, injector?: InjectorService): Promise<Result>;
13
14
  export declare function setContext(ctx: DIContext): void;
14
15
  export declare function bindContext(cb: any): any;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@tsed/di",
3
3
  "description": "DI module for Ts.ED Framework",
4
- "type": "commonjs",
5
- "version": "7.83.3",
4
+ "type": "module",
5
+ "version": "8.0.0-alpha.10",
6
6
  "source": "./src/index.ts",
7
- "main": "lib/esm/index.js",
8
- "module": "lib/esm/index.js",
7
+ "main": "./lib/esm/index.js",
8
+ "module": "./lib/esm/index.js",
9
9
  "typings": "./lib/types/index.d.ts",
10
10
  "browser": "./lib/browser/di.umd.min.js",
11
11
  "exports": {
@@ -13,8 +13,7 @@
13
13
  "types": "./lib/types/index.d.ts",
14
14
  "browser": "./lib/browser/di.umd.min.js",
15
15
  "import": "./lib/esm/index.js",
16
- "require": "./lib/cjs/index.js",
17
- "default": "./lib/cjs/index.js"
16
+ "default": "./lib/esm/index.js"
18
17
  }
19
18
  },
20
19
  "scripts": {
@@ -26,24 +25,25 @@
26
25
  "test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
27
26
  },
28
27
  "dependencies": {
29
- "tslib": "2.6.2"
28
+ "tslib": "2.7.0",
29
+ "uuid": "^10.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@tsed/barrels": "7.83.3",
33
- "@tsed/core": "7.83.3",
34
- "@tsed/logger": ">=6.7.5",
35
- "@tsed/schema": "7.83.3",
36
- "@tsed/typescript": "7.83.3",
32
+ "@tsed/barrels": "8.0.0-alpha.10",
33
+ "@tsed/core": "8.0.0-alpha.10",
34
+ "@tsed/logger": "^6.7.8",
35
+ "@tsed/schema": "8.0.0-alpha.10",
36
+ "@tsed/typescript": "8.0.0-alpha.10",
37
37
  "cross-env": "7.0.3",
38
- "eslint": "^8.57.0",
39
- "typescript": "4.9.5",
40
- "vitest": "2.0.4",
38
+ "eslint": "9.12.0",
39
+ "typescript": "5.4.5",
40
+ "vitest": "2.1.2",
41
41
  "webpack": "^5.75.0"
42
42
  },
43
43
  "peerDependencies": {
44
- "@tsed/core": "7.83.3",
44
+ "@tsed/core": "8.0.0-alpha.10",
45
45
  "@tsed/logger": ">=6.7.5",
46
- "@tsed/schema": "7.83.3"
46
+ "@tsed/schema": "8.0.0-alpha.10"
47
47
  },
48
48
  "peerDependenciesMeta": {
49
49
  "@tsed/core": {
@@ -62,5 +62,8 @@
62
62
  },
63
63
  "homepage": "https://github.com/tsedio/tsed/tree/production/packages/di",
64
64
  "author": "Romain Lenzotti",
65
- "license": "MIT"
65
+ "license": "MIT",
66
+ "publishConfig": {
67
+ "tag": "alpha"
68
+ }
66
69
  }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DI_PARAM_OPTIONS = exports.DI_PARAMS = exports.INJECTABLE_PROP = void 0;
4
- exports.INJECTABLE_PROP = "DI:INJECTABLE_PROP";
5
- exports.DI_PARAMS = "DI:PARAMS";
6
- exports.DI_PARAM_OPTIONS = "DI:PARAM:OPTIONS";
7
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/common/constants/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,oBAAoB,CAAC;AACvC,QAAA,SAAS,GAAG,WAAW,CAAC;AACxB,QAAA,gBAAgB,GAAG,kBAAkB,CAAC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AutoInjectable = void 0;
4
- const LocalsContainer_js_1 = require("../domain/LocalsContainer.js");
5
- const InjectorService_js_1 = require("../services/InjectorService.js");
6
- function AutoInjectable() {
7
- return (constr) => {
8
- return class AutoInjectable extends constr {
9
- constructor(...args) {
10
- const locals = new LocalsContainer_js_1.LocalsContainer();
11
- super(...InjectorService_js_1.InjectorService.resolveAutoInjectableArgs(constr, locals, args));
12
- InjectorService_js_1.InjectorService.bind(this, locals);
13
- }
14
- };
15
- };
16
- }
17
- exports.AutoInjectable = AutoInjectable;
18
- //# sourceMappingURL=autoInjectable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"autoInjectable.js","sourceRoot":"","sources":["../../../../src/common/decorators/autoInjectable.ts"],"names":[],"mappings":";;;AAAA,qEAA6D;AAC7D,uEAA+D;AAE/D,SAAgB,cAAc;IAC5B,OAAO,CAAyD,MAAS,EAAK,EAAE;QAC9E,OAAO,MAAM,cAAe,SAAQ,MAAM;YACxC,YAAY,GAAG,IAAW;gBACxB,MAAM,MAAM,GAAG,IAAI,oCAAe,EAAE,CAAC;gBACrC,KAAK,CAAC,GAAG,oCAAe,CAAC,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;gBAC1E,oCAAe,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACrC,CAAC;SACc,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAVD,wCAUC"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Configuration = void 0;
4
- const core_1 = require("@tsed/core");
5
- const inject_js_1 = require("./inject.js");
6
- /**
7
- * Get or set Configuration on a class.
8
- *
9
- * @decorator
10
- */
11
- function Configuration(configuration = {}) {
12
- return (...args) => {
13
- switch ((0, core_1.decoratorTypeOf)(args)) {
14
- case core_1.DecoratorTypes.CLASS:
15
- (0, core_1.StoreSet)("configuration", configuration)(args[0]);
16
- break;
17
- default:
18
- case core_1.DecoratorTypes.PARAM_CTOR:
19
- return (0, inject_js_1.Inject)(Configuration)(args[0], args[1], args[2]);
20
- }
21
- };
22
- }
23
- exports.Configuration = Configuration;
24
- //# sourceMappingURL=configuration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../../src/common/decorators/configuration.ts"],"names":[],"mappings":";;;AAAA,qCAA0F;AAC1F,2CAAmC;AAGnC;;;;GAIG;AACH,SAAgB,aAAa,CAAC,gBAA6C,EAAE;IAC3E,OAAO,CAAC,GAAG,IAAyB,EAAE,EAAE;QACtC,QAAQ,IAAA,sBAAe,EAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,qBAAc,CAAC,KAAK;gBACvB,IAAA,eAAQ,EAAC,eAAe,EAAE,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAElD,MAAM;YACR,QAAQ;YACR,KAAK,qBAAc,CAAC,UAAU;gBAC5B,OAAO,IAAA,kBAAM,EAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAW,CAAC,CAAC;SACrE;IACH,CAAC,CAAC;AACJ,CAAC;AAZD,sCAYC"}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Constant = void 0;
4
- const core_1 = require("@tsed/core");
5
- const constants_js_1 = require("../constants/constants.js");
6
- const InjectablePropertyType_js_1 = require("../domain/InjectablePropertyType.js");
7
- /**
8
- * Return value from Configuration.
9
- *
10
- * ## Example
11
- *
12
- * ```typescript
13
- * import {Env} from "@tsed/core";
14
- * import {Constant, Value} from "@tsed/di";
15
- *
16
- * export class MyClass {
17
- *
18
- * @Constant("env")
19
- * env: Env;
20
- *
21
- * @Value("swagger.path")
22
- * swaggerPath: string;
23
- *
24
- * @Value("swagger.path", "defaultValue")
25
- * swaggerPath: string;
26
- *
27
- * constructor() {
28
- * console.log(this.swaggerPath) // undefined. Not available on constructor
29
- * }
30
- *
31
- * $onInit() {
32
- * console.log(this.swaggerPath) // something
33
- * }
34
- * }
35
- * ```
36
- *
37
- * @param {string} expression
38
- * @param defaultValue
39
- * @returns {(targetClass: any, attributeName: string) => any}
40
- * @decorator
41
- */
42
- function Constant(expression, defaultValue) {
43
- return (target, propertyKey) => {
44
- core_1.Store.from(target).merge(constants_js_1.INJECTABLE_PROP, {
45
- [propertyKey]: {
46
- bindingType: InjectablePropertyType_js_1.InjectablePropertyType.CONSTANT,
47
- propertyKey,
48
- expression,
49
- defaultValue
50
- }
51
- });
52
- };
53
- }
54
- exports.Constant = Constant;
55
- //# sourceMappingURL=constant.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../../src/common/decorators/constant.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,4DAA0D;AAE1D,mFAA2E;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,QAAQ,CAAC,UAAkB,EAAE,YAAkB;IAC7D,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QAC1C,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,8BAAe,EAAE;YACxC,CAAC,WAAW,CAAC,EAAE;gBACb,WAAW,EAAE,kDAAsB,CAAC,QAAQ;gBAC5C,WAAW;gBACX,UAAU;gBACV,YAAY;aACb;SACsB,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC;AAXD,4BAWC"}
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Controller = void 0;
4
- const core_1 = require("@tsed/core");
5
- const schema_1 = require("@tsed/schema");
6
- const ProviderRegistry_js_1 = require("../registries/ProviderRegistry.js");
7
- function mapOptions(options) {
8
- if (typeof options === "string" || options instanceof RegExp || (0, core_1.isArrayOrArrayClass)(options)) {
9
- return {
10
- path: options
11
- };
12
- }
13
- return options;
14
- }
15
- /**
16
- * Declare a new controller with his Rest path. His methods annotated will be collected to build the routing list.
17
- * This routing listing will be built with the `express.Router` object.
18
- *
19
- * ::: tip
20
- * See [Controllers](/docs/controllers.md) section for more details
21
- * :::
22
- *
23
- * ```typescript
24
- * @Controller("/calendars")
25
- * export provide CalendarCtrl {
26
- *
27
- * @Get("/:id")
28
- * public get(
29
- * @Req() request: Req,
30
- * @Res() response: Res,
31
- * @Next() next: Next
32
- * ): void {
33
- *
34
- * }
35
- * }
36
- * ```
37
- *
38
- * @param options
39
- * @controller
40
- * @decorator
41
- * @classDecorator
42
- */
43
- function Controller(options) {
44
- const { children = [], path, ...opts } = mapOptions(options);
45
- return (0, core_1.useDecorators)((target) => {
46
- (0, ProviderRegistry_js_1.registerController)({
47
- provide: target,
48
- ...opts
49
- });
50
- }, path && (0, schema_1.Path)(path), (0, schema_1.Children)(...children));
51
- }
52
- exports.Controller = Controller;
53
- //# sourceMappingURL=controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../src/common/decorators/controller.ts"],"names":[],"mappings":";;;AAAA,qCAAoE;AACpE,yCAA4C;AAE5C,2EAAqE;AAgBrE,SAAS,UAAU,CAAC,OAAY;IAC9B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,YAAY,MAAM,IAAI,IAAA,0BAAmB,EAAC,OAAO,CAAC,EAAE;QAC5F,OAAO;YACL,IAAI,EAAE,OAAO;SACd,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,UAAU,CAAC,OAAqC;IAC9D,MAAM,EAAC,QAAQ,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,IAAI,EAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAE3D,OAAO,IAAA,oBAAa,EAClB,CAAC,MAAY,EAAE,EAAE;QACf,IAAA,wCAAkB,EAAC;YACjB,OAAO,EAAE,MAAM;YACf,GAAG,IAAI;SACR,CAAC,CAAC;IACL,CAAC,EACD,IAAI,IAAI,IAAA,aAAI,EAAC,IAAW,CAAC,EACzB,IAAA,iBAAQ,EAAC,GAAG,QAAQ,CAAC,CACtB,CAAC;AACJ,CAAC;AAbD,gCAaC"}
@@ -1,93 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Inject = exports.injectProperty = void 0;
4
- const core_1 = require("@tsed/core");
5
- const constants_js_1 = require("../constants/constants.js");
6
- const InvalidPropertyTokenError_js_1 = require("../errors/InvalidPropertyTokenError.js");
7
- const getConstructorDependencies_js_1 = require("../utils/getConstructorDependencies.js");
8
- function injectProperty(target, propertyKey, options) {
9
- core_1.Store.from(target).merge(constants_js_1.INJECTABLE_PROP, {
10
- [propertyKey]: {
11
- bindingType: core_1.DecoratorTypes.PROP,
12
- propertyKey,
13
- ...options
14
- }
15
- });
16
- }
17
- exports.injectProperty = injectProperty;
18
- /**
19
- * Inject a provider to another provider.
20
- *
21
- * Use this decorator to inject a custom provider on constructor parameter or property.
22
- *
23
- * ```typescript
24
- * @Injectable()
25
- * export class MyService {
26
- * @Inject(CONNECTION)
27
- * connection: CONNECTION;
28
- * }
29
- * ```
30
- *
31
- * @param token A token provider or token provider group
32
- * @param onGet Use the given name method to inject
33
- * @returns {Function}
34
- * @decorator
35
- */
36
- function Inject(token, onGet = (bean) => bean) {
37
- return (target, propertyKey, descriptor) => {
38
- const bindingType = (0, core_1.decoratorTypeOf)([target, propertyKey, descriptor]);
39
- switch (bindingType) {
40
- case core_1.DecoratorTypes.PARAM_CTOR:
41
- if (token) {
42
- const paramTypes = (0, getConstructorDependencies_js_1.getConstructorDependencies)(target, propertyKey);
43
- const type = paramTypes[descriptor];
44
- paramTypes[descriptor] = type === Array ? [token] : token;
45
- core_1.Metadata.setParamTypes(target, propertyKey, paramTypes);
46
- (0, getConstructorDependencies_js_1.setConstructorDependencies)(target, paramTypes);
47
- }
48
- break;
49
- case core_1.DecoratorTypes.PROP:
50
- const useType = token || core_1.Metadata.getType(target, propertyKey);
51
- if (useType === Object) {
52
- throw new InvalidPropertyTokenError_js_1.InvalidPropertyTokenError(target, String(propertyKey));
53
- }
54
- injectProperty(target, String(propertyKey), {
55
- resolver(injector, locals, { options, ...invokeOptions }) {
56
- const originalType = core_1.Metadata.getType(target, propertyKey);
57
- locals.set(constants_js_1.DI_PARAM_OPTIONS, { ...options });
58
- if (originalType === Array) {
59
- let bean;
60
- if (!bean) {
61
- bean = injector.getMany(token, locals, invokeOptions);
62
- locals.delete(constants_js_1.DI_PARAM_OPTIONS);
63
- }
64
- bean.forEach((instance, index) => {
65
- if ((0, core_1.isPromise)(bean)) {
66
- instance.then((result) => {
67
- bean[index] = result;
68
- });
69
- }
70
- });
71
- return () => onGet(bean);
72
- }
73
- let bean;
74
- if (!bean) {
75
- bean = injector.invoke(useType, locals, invokeOptions);
76
- locals.delete(constants_js_1.DI_PARAM_OPTIONS);
77
- }
78
- if ((0, core_1.isPromise)(bean)) {
79
- bean.then((result) => {
80
- bean = result;
81
- });
82
- }
83
- return () => onGet(bean);
84
- }
85
- });
86
- break;
87
- default:
88
- throw new core_1.UnsupportedDecoratorType(Inject, [target, propertyKey, descriptor]);
89
- }
90
- };
91
- }
92
- exports.Inject = Inject;
93
- //# sourceMappingURL=inject.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../../src/common/decorators/inject.ts"],"names":[],"mappings":"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"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Injectable = void 0;
4
- const ProviderRegistry_js_1 = require("../registries/ProviderRegistry.js");
5
- /**
6
- * The decorators `@Injectable()` declare a new service can be injected in other service, controller, interceptor, etc.. on there `constructor`.
7
- * All classes annotated with `@Injectable()` are built one time, excepted if you change the default provider configuration.
8
- *
9
- * ::: tip
10
- * `@Injectable()` use the `reflect-metadata` to collect and inject the built provided to other services.
11
- * :::
12
- *
13
- * ### Options
14
- *
15
- * - type (@@ProviderType@@ or `string`): Kind of provider. (Default: `ProviderType.PROVIDER`)
16
- * - scope (@@ProviderScope@@): Kind of provider. (Default: `ProviderScope.SINGLETON`)
17
- * - provide (@@TokenProvider@@): An injection token (Note: This option override default metadata generated by Typescript).
18
- * - deps (`Type<any>`): List of class or provider which will be injected to the constructor (Note: This options override default metadata generated by Typescript).
19
- *
20
- * @returns {Function}
21
- * @decorator
22
- */
23
- function Injectable(options = {}) {
24
- return (target) => {
25
- (0, ProviderRegistry_js_1.registerProvider)({
26
- ...options,
27
- ...(options.provide ? { useClass: target } : { provide: target })
28
- });
29
- };
30
- }
31
- exports.Injectable = Injectable;
32
- //# sourceMappingURL=injectable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectable.js","sourceRoot":"","sources":["../../../../src/common/decorators/injectable.ts"],"names":[],"mappings":";;;AACA,2EAAmE;AAEnE;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,UAAU,CAAC,UAAiC,EAAE;IAC5D,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,sCAAgB,EAAC;YACf,GAAG,OAAO;YACV,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAAC,CAAC,EAAC,OAAO,EAAE,MAAM,EAAC,CAAC;SAC9D,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAPD,gCAOC"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Intercept = void 0;
4
- const core_1 = require("@tsed/core");
5
- const constants_js_1 = require("../constants/constants.js");
6
- const InjectablePropertyType_js_1 = require("../domain/InjectablePropertyType.js");
7
- /**
8
- * Attaches interceptor to method call and executes the before and after methods
9
- *
10
- * @param interceptor
11
- * @param options
12
- * @decorator
13
- */
14
- function Intercept(interceptor, options) {
15
- return (...args) => {
16
- const [target, propertyKey, descriptor] = args;
17
- const type = (0, core_1.decoratorTypeOf)(args);
18
- switch (type) {
19
- case core_1.DecoratorTypes.CLASS:
20
- (0, core_1.decorateMethodsOf)(target, Intercept(interceptor, options));
21
- break;
22
- case core_1.DecoratorTypes.METHOD:
23
- core_1.Store.from(target).merge(constants_js_1.INJECTABLE_PROP, {
24
- [propertyKey]: {
25
- options,
26
- propertyKey,
27
- useType: interceptor,
28
- bindingType: InjectablePropertyType_js_1.InjectablePropertyType.INTERCEPTOR
29
- }
30
- });
31
- return descriptor;
32
- }
33
- };
34
- }
35
- exports.Intercept = Intercept;
36
- //# sourceMappingURL=intercept.js.map