@tsed/di 7.0.0-alpha.2 → 7.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/lib/cjs/constants/index.js +7 -0
  2. package/lib/cjs/constants/index.js.map +1 -0
  3. package/lib/cjs/decorators/configuration.js +24 -0
  4. package/lib/cjs/decorators/configuration.js.map +1 -0
  5. package/lib/cjs/decorators/constant.js +55 -0
  6. package/lib/cjs/decorators/constant.js.map +1 -0
  7. package/lib/cjs/decorators/controller.js +53 -0
  8. package/lib/cjs/decorators/controller.js.map +1 -0
  9. package/lib/cjs/decorators/index.js +19 -0
  10. package/lib/cjs/decorators/index.js.map +1 -0
  11. package/lib/cjs/decorators/inject.js +79 -0
  12. package/lib/cjs/decorators/inject.js.map +1 -0
  13. package/lib/cjs/decorators/injectable.js +34 -0
  14. package/lib/cjs/decorators/injectable.js.map +1 -0
  15. package/lib/cjs/decorators/intercept.js +28 -0
  16. package/lib/cjs/decorators/intercept.js.map +1 -0
  17. package/lib/cjs/decorators/interceptor.js +21 -0
  18. package/lib/cjs/decorators/interceptor.js.map +1 -0
  19. package/lib/cjs/decorators/lazyInject.js +71 -0
  20. package/lib/cjs/decorators/lazyInject.js.map +1 -0
  21. package/lib/cjs/decorators/module.js +31 -0
  22. package/lib/cjs/decorators/module.js.map +1 -0
  23. package/lib/cjs/decorators/opts.js +54 -0
  24. package/lib/cjs/decorators/opts.js.map +1 -0
  25. package/lib/cjs/decorators/overrideProvider.js +17 -0
  26. package/lib/cjs/decorators/overrideProvider.js.map +1 -0
  27. package/lib/cjs/decorators/scope.js +16 -0
  28. package/lib/cjs/decorators/scope.js.map +1 -0
  29. package/lib/cjs/decorators/service.js +18 -0
  30. package/lib/cjs/decorators/service.js.map +1 -0
  31. package/lib/cjs/decorators/useOpts.js +65 -0
  32. package/lib/cjs/decorators/useOpts.js.map +1 -0
  33. package/lib/cjs/decorators/value.js +55 -0
  34. package/lib/cjs/decorators/value.js.map +1 -0
  35. package/lib/cjs/domain/Container.js +72 -0
  36. package/lib/cjs/domain/Container.js.map +1 -0
  37. package/lib/cjs/domain/ContextLogger.js +85 -0
  38. package/lib/cjs/domain/ContextLogger.js.map +1 -0
  39. package/lib/cjs/domain/DIContext.js +45 -0
  40. package/lib/cjs/domain/DIContext.js.map +1 -0
  41. package/lib/cjs/domain/InjectablePropertyType.js +12 -0
  42. package/lib/cjs/domain/InjectablePropertyType.js.map +1 -0
  43. package/lib/cjs/domain/LocalsContainer.js +55 -0
  44. package/lib/cjs/domain/LocalsContainer.js.map +1 -0
  45. package/lib/cjs/domain/Provider.js +122 -0
  46. package/lib/cjs/domain/Provider.js.map +1 -0
  47. package/lib/cjs/domain/ProviderScope.js +10 -0
  48. package/lib/cjs/domain/ProviderScope.js.map +1 -0
  49. package/lib/cjs/domain/ProviderType.js +15 -0
  50. package/lib/cjs/domain/ProviderType.js.map +1 -0
  51. package/lib/cjs/domain/index.js +12 -0
  52. package/lib/cjs/domain/index.js.map +1 -0
  53. package/lib/cjs/errors/InjectionError.js +58 -0
  54. package/lib/cjs/errors/InjectionError.js.map +1 -0
  55. package/lib/cjs/errors/UndefinedTokenError.js +11 -0
  56. package/lib/cjs/errors/UndefinedTokenError.js.map +1 -0
  57. package/lib/cjs/index.js +21 -0
  58. package/lib/cjs/index.js.map +1 -0
  59. package/lib/cjs/interfaces/DIConfigurationOptions.js +3 -0
  60. package/lib/cjs/interfaces/DIConfigurationOptions.js.map +1 -0
  61. package/lib/cjs/interfaces/DILogger.js +3 -0
  62. package/lib/cjs/interfaces/DILogger.js.map +1 -0
  63. package/lib/cjs/interfaces/DIResolver.js +3 -0
  64. package/lib/cjs/interfaces/DIResolver.js.map +1 -0
  65. package/lib/cjs/interfaces/IProvider.js +3 -0
  66. package/lib/cjs/interfaces/IProvider.js.map +1 -0
  67. package/lib/cjs/interfaces/InjectableProperties.js +3 -0
  68. package/lib/cjs/interfaces/InjectableProperties.js.map +1 -0
  69. package/lib/cjs/interfaces/InterceptorContext.js +3 -0
  70. package/lib/cjs/interfaces/InterceptorContext.js.map +1 -0
  71. package/lib/cjs/interfaces/InterceptorMethods.js +3 -0
  72. package/lib/cjs/interfaces/InterceptorMethods.js.map +1 -0
  73. package/lib/cjs/interfaces/InvokeOptions.js +3 -0
  74. package/lib/cjs/interfaces/InvokeOptions.js.map +1 -0
  75. package/lib/cjs/interfaces/OnDestroy.js +3 -0
  76. package/lib/cjs/interfaces/OnDestroy.js.map +1 -0
  77. package/lib/cjs/interfaces/OnInit.js +3 -0
  78. package/lib/cjs/interfaces/OnInit.js.map +1 -0
  79. package/lib/cjs/interfaces/RegistrySettings.js +3 -0
  80. package/lib/cjs/interfaces/RegistrySettings.js.map +1 -0
  81. package/lib/cjs/interfaces/ResolvedInvokeOptions.js +3 -0
  82. package/lib/cjs/interfaces/ResolvedInvokeOptions.js.map +1 -0
  83. package/lib/cjs/interfaces/TokenProvider.js +3 -0
  84. package/lib/cjs/interfaces/TokenProvider.js.map +1 -0
  85. package/lib/cjs/interfaces/index.js +18 -0
  86. package/lib/cjs/interfaces/index.js.map +1 -0
  87. package/lib/cjs/registries/GlobalProviders.js +124 -0
  88. package/lib/cjs/registries/GlobalProviders.js.map +1 -0
  89. package/lib/cjs/registries/ProviderRegistry.js +85 -0
  90. package/lib/cjs/registries/ProviderRegistry.js.map +1 -0
  91. package/lib/cjs/services/DIConfiguration.js +129 -0
  92. package/lib/cjs/services/DIConfiguration.js.map +1 -0
  93. package/lib/cjs/services/DILogger.js +13 -0
  94. package/lib/cjs/services/DILogger.js.map +1 -0
  95. package/lib/cjs/services/DITest.js +108 -0
  96. package/lib/cjs/services/DITest.js.map +1 -0
  97. package/lib/cjs/services/InjectorService.js +581 -0
  98. package/lib/cjs/services/InjectorService.js.map +1 -0
  99. package/lib/cjs/utils/colors.js +10 -0
  100. package/lib/cjs/utils/colors.js.map +1 -0
  101. package/lib/cjs/utils/createContainer.js +14 -0
  102. package/lib/cjs/utils/createContainer.js.map +1 -0
  103. package/lib/cjs/utils/data/Test1.js +8 -0
  104. package/lib/cjs/utils/data/Test1.js.map +1 -0
  105. package/lib/cjs/utils/data/Test2.js +8 -0
  106. package/lib/cjs/utils/data/Test2.js.map +1 -0
  107. package/lib/cjs/utils/getConfiguration.js +20 -0
  108. package/lib/cjs/utils/getConfiguration.js.map +1 -0
  109. package/lib/cjs/utils/setLoggerLevel.js +16 -0
  110. package/lib/cjs/utils/setLoggerLevel.js.map +1 -0
  111. package/lib/esm/constants/index.js +4 -0
  112. package/lib/esm/constants/index.js.map +1 -0
  113. package/lib/esm/decorators/configuration.js +20 -0
  114. package/lib/esm/decorators/configuration.js.map +1 -0
  115. package/lib/esm/decorators/constant.js +51 -0
  116. package/lib/esm/decorators/constant.js.map +1 -0
  117. package/lib/esm/decorators/controller.js +49 -0
  118. package/lib/esm/decorators/controller.js.map +1 -0
  119. package/lib/esm/decorators/index.js +16 -0
  120. package/lib/esm/decorators/index.js.map +1 -0
  121. package/lib/esm/decorators/inject.js +74 -0
  122. package/lib/esm/decorators/inject.js.map +1 -0
  123. package/lib/esm/decorators/injectable.js +30 -0
  124. package/lib/esm/decorators/injectable.js.map +1 -0
  125. package/lib/esm/decorators/intercept.js +24 -0
  126. package/lib/esm/decorators/intercept.js.map +1 -0
  127. package/lib/esm/decorators/interceptor.js +17 -0
  128. package/lib/esm/decorators/interceptor.js.map +1 -0
  129. package/lib/esm/decorators/lazyInject.js +66 -0
  130. package/lib/esm/decorators/lazyInject.js.map +1 -0
  131. package/lib/esm/decorators/module.js +27 -0
  132. package/lib/esm/decorators/module.js.map +1 -0
  133. package/lib/esm/decorators/opts.js +50 -0
  134. package/lib/esm/decorators/opts.js.map +1 -0
  135. package/lib/esm/decorators/overrideProvider.js +13 -0
  136. package/lib/esm/decorators/overrideProvider.js.map +1 -0
  137. package/lib/esm/decorators/scope.js +12 -0
  138. package/lib/esm/decorators/scope.js.map +1 -0
  139. package/lib/esm/decorators/service.js +14 -0
  140. package/lib/esm/decorators/service.js.map +1 -0
  141. package/lib/esm/decorators/useOpts.js +61 -0
  142. package/lib/esm/decorators/useOpts.js.map +1 -0
  143. package/lib/esm/decorators/value.js +51 -0
  144. package/lib/esm/decorators/value.js.map +1 -0
  145. package/lib/esm/domain/Container.js +68 -0
  146. package/lib/esm/domain/Container.js.map +1 -0
  147. package/lib/esm/domain/ContextLogger.js +81 -0
  148. package/lib/esm/domain/ContextLogger.js.map +1 -0
  149. package/lib/esm/domain/DIContext.js +41 -0
  150. package/lib/esm/domain/DIContext.js.map +1 -0
  151. package/lib/esm/domain/InjectablePropertyType.js +9 -0
  152. package/lib/esm/domain/InjectablePropertyType.js.map +1 -0
  153. package/lib/esm/domain/LocalsContainer.js +51 -0
  154. package/lib/esm/domain/LocalsContainer.js.map +1 -0
  155. package/lib/esm/domain/Provider.js +118 -0
  156. package/lib/esm/domain/Provider.js.map +1 -0
  157. package/lib/esm/domain/ProviderScope.js +7 -0
  158. package/lib/esm/domain/ProviderScope.js.map +1 -0
  159. package/lib/esm/domain/ProviderType.js +12 -0
  160. package/lib/esm/domain/ProviderType.js.map +1 -0
  161. package/lib/esm/domain/index.js +9 -0
  162. package/lib/esm/domain/index.js.map +1 -0
  163. package/lib/esm/errors/InjectionError.js +54 -0
  164. package/lib/esm/errors/InjectionError.js.map +1 -0
  165. package/lib/esm/errors/UndefinedTokenError.js +7 -0
  166. package/lib/esm/errors/UndefinedTokenError.js.map +1 -0
  167. package/lib/esm/index.js +18 -0
  168. package/lib/esm/index.js.map +1 -0
  169. package/lib/esm/interfaces/DIConfigurationOptions.js +2 -0
  170. package/lib/esm/interfaces/DIConfigurationOptions.js.map +1 -0
  171. package/lib/esm/interfaces/DILogger.js +2 -0
  172. package/lib/esm/interfaces/DILogger.js.map +1 -0
  173. package/lib/esm/interfaces/DIResolver.js +2 -0
  174. package/lib/esm/interfaces/DIResolver.js.map +1 -0
  175. package/lib/esm/interfaces/IProvider.js +2 -0
  176. package/lib/esm/interfaces/IProvider.js.map +1 -0
  177. package/lib/esm/interfaces/InjectableProperties.js +2 -0
  178. package/lib/esm/interfaces/InjectableProperties.js.map +1 -0
  179. package/lib/esm/interfaces/InterceptorContext.js +2 -0
  180. package/lib/esm/interfaces/InterceptorContext.js.map +1 -0
  181. package/lib/esm/interfaces/InterceptorMethods.js +2 -0
  182. package/lib/esm/interfaces/InterceptorMethods.js.map +1 -0
  183. package/lib/esm/interfaces/InvokeOptions.js +2 -0
  184. package/lib/esm/interfaces/InvokeOptions.js.map +1 -0
  185. package/lib/esm/interfaces/OnDestroy.js +2 -0
  186. package/lib/esm/interfaces/OnDestroy.js.map +1 -0
  187. package/lib/esm/interfaces/OnInit.js +2 -0
  188. package/lib/esm/interfaces/OnInit.js.map +1 -0
  189. package/lib/esm/interfaces/RegistrySettings.js +2 -0
  190. package/lib/esm/interfaces/RegistrySettings.js.map +1 -0
  191. package/lib/esm/interfaces/ResolvedInvokeOptions.js +2 -0
  192. package/lib/esm/interfaces/ResolvedInvokeOptions.js.map +1 -0
  193. package/lib/esm/interfaces/TokenProvider.js +2 -0
  194. package/lib/esm/interfaces/TokenProvider.js.map +1 -0
  195. package/lib/esm/interfaces/index.js +15 -0
  196. package/lib/esm/interfaces/index.js.map +1 -0
  197. package/lib/esm/registries/GlobalProviders.js +120 -0
  198. package/lib/esm/registries/GlobalProviders.js.map +1 -0
  199. package/lib/esm/registries/ProviderRegistry.js +80 -0
  200. package/lib/esm/registries/ProviderRegistry.js.map +1 -0
  201. package/lib/esm/services/DIConfiguration.js +125 -0
  202. package/lib/esm/services/DIConfiguration.js.map +1 -0
  203. package/lib/esm/services/DILogger.js +11 -0
  204. package/lib/esm/services/DILogger.js.map +1 -0
  205. package/lib/esm/services/DITest.js +104 -0
  206. package/lib/esm/services/DITest.js.map +1 -0
  207. package/lib/esm/services/InjectorService.js +578 -0
  208. package/lib/esm/services/InjectorService.js.map +1 -0
  209. package/lib/esm/utils/colors.js +7 -0
  210. package/lib/esm/utils/colors.js.map +1 -0
  211. package/lib/esm/utils/createContainer.js +10 -0
  212. package/lib/esm/utils/createContainer.js.map +1 -0
  213. package/lib/esm/utils/data/Test1.js +4 -0
  214. package/lib/esm/utils/data/Test1.js.map +1 -0
  215. package/lib/esm/utils/data/Test2.js +4 -0
  216. package/lib/esm/utils/data/Test2.js.map +1 -0
  217. package/lib/esm/utils/getConfiguration.js +16 -0
  218. package/lib/esm/utils/getConfiguration.js.map +1 -0
  219. package/lib/esm/utils/setLoggerLevel.js +12 -0
  220. package/lib/esm/utils/setLoggerLevel.js.map +1 -0
  221. package/lib/{constants → types/constants}/index.d.ts +0 -0
  222. package/lib/{decorators → types/decorators}/configuration.d.ts +0 -0
  223. package/lib/{decorators → types/decorators}/constant.d.ts +0 -0
  224. package/lib/{decorators → types/decorators}/controller.d.ts +0 -0
  225. package/lib/{decorators → types/decorators}/index.d.ts +1 -0
  226. package/lib/{decorators → types/decorators}/inject.d.ts +2 -0
  227. package/lib/{decorators → types/decorators}/injectable.d.ts +2 -1
  228. package/lib/{decorators → types/decorators}/intercept.d.ts +0 -0
  229. package/lib/{decorators → types/decorators}/interceptor.d.ts +0 -0
  230. package/lib/types/decorators/lazyInject.d.ts +43 -0
  231. package/lib/{decorators → types/decorators}/module.d.ts +0 -0
  232. package/lib/{decorators → types/decorators}/opts.d.ts +0 -0
  233. package/lib/{decorators → types/decorators}/overrideProvider.d.ts +0 -0
  234. package/lib/{decorators → types/decorators}/scope.d.ts +0 -0
  235. package/lib/{decorators → types/decorators}/service.d.ts +0 -0
  236. package/lib/{decorators → types/decorators}/useOpts.d.ts +0 -0
  237. package/lib/{decorators → types/decorators}/value.d.ts +0 -0
  238. package/lib/{domain → types/domain}/Container.d.ts +2 -3
  239. package/lib/{domain → types/domain}/ContextLogger.d.ts +0 -0
  240. package/lib/{domain → types/domain}/DIContext.d.ts +0 -0
  241. package/lib/{domain → types/domain}/InjectablePropertyType.d.ts +0 -0
  242. package/lib/{domain → types/domain}/LocalsContainer.d.ts +0 -0
  243. package/lib/{domain → types/domain}/Provider.d.ts +16 -0
  244. package/lib/{domain → types/domain}/ProviderScope.d.ts +0 -0
  245. package/lib/{domain → types/domain}/ProviderType.d.ts +0 -0
  246. package/lib/{domain → types/domain}/index.d.ts +0 -0
  247. package/lib/{errors → types/errors}/InjectionError.d.ts +0 -0
  248. package/lib/{errors → types/errors}/UndefinedTokenError.d.ts +0 -0
  249. package/lib/{index.d.ts → types/index.d.ts} +1 -0
  250. package/lib/{interfaces → types/interfaces}/DIConfigurationOptions.d.ts +0 -0
  251. package/lib/{interfaces → types/interfaces}/DILogger.d.ts +0 -0
  252. package/lib/{interfaces → types/interfaces}/DIResolver.d.ts +0 -0
  253. package/lib/{interfaces → types/interfaces}/IProvider.d.ts +0 -0
  254. package/lib/{interfaces → types/interfaces}/InjectableProperties.d.ts +8 -4
  255. package/lib/{interfaces → types/interfaces}/InterceptorContext.d.ts +0 -0
  256. package/lib/{interfaces → types/interfaces}/InterceptorMethods.d.ts +0 -0
  257. package/lib/{interfaces → types/interfaces}/InvokeOptions.d.ts +0 -0
  258. package/lib/{interfaces → types/interfaces}/OnDestroy.d.ts +0 -0
  259. package/lib/{interfaces → types/interfaces}/OnInit.d.ts +0 -0
  260. package/lib/{interfaces → types/interfaces}/RegistrySettings.d.ts +6 -2
  261. package/lib/types/interfaces/ResolvedInvokeOptions.d.ts +12 -0
  262. package/lib/{interfaces → types/interfaces}/TokenProvider.d.ts +0 -0
  263. package/lib/{interfaces → types/interfaces}/index.d.ts +1 -0
  264. package/lib/{registries → types/registries}/GlobalProviders.d.ts +5 -1
  265. package/lib/{registries → types/registries}/ProviderRegistry.d.ts +0 -0
  266. package/lib/{services → types/services}/DIConfiguration.d.ts +0 -0
  267. package/lib/{services → types/services}/DILogger.d.ts +0 -0
  268. package/lib/{services → types/services}/DITest.d.ts +5 -1
  269. package/lib/{services → types/services}/InjectorService.d.ts +32 -8
  270. package/lib/types/utils/colors.d.ts +5 -0
  271. package/lib/{utils → types/utils}/createContainer.d.ts +0 -0
  272. package/lib/types/utils/data/Test1.d.ts +3 -0
  273. package/lib/types/utils/data/Test2.d.ts +3 -0
  274. package/lib/{utils → types/utils}/getConfiguration.d.ts +0 -0
  275. package/lib/{utils → types/utils}/setLoggerLevel.d.ts +0 -0
  276. package/package.json +15 -14
  277. package/tsconfig.compile.esm.json +24 -0
  278. package/lib/index.js +0 -2269
  279. package/lib/index.js.map +0 -1
  280. package/lib/index.modern.js +0 -2232
  281. package/lib/index.modern.js.map +0 -1
@@ -0,0 +1,7 @@
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=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,oBAAoB,CAAC;AACvC,QAAA,SAAS,GAAG,WAAW,CAAC;AACxB,QAAA,gBAAgB,GAAG,kBAAkB,CAAC","sourcesContent":["export const INJECTABLE_PROP = \"DI:INJECTABLE_PROP\";\nexport const DI_PARAMS = \"DI:PARAMS\";\nexport const DI_PARAM_OPTIONS = \"DI:PARAM:OPTIONS\";\n"]}
@@ -0,0 +1,24 @@
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_1 = require("../decorators/inject");
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_1.Inject)(Configuration)(args[0], args[1], args[2]);
20
+ }
21
+ };
22
+ }
23
+ exports.Configuration = Configuration;
24
+ //# sourceMappingURL=configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/decorators/configuration.ts"],"names":[],"mappings":";;;AAAA,qCAA0F;AAC1F,iDAA4C;AAG5C;;;;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,eAAM,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","sourcesContent":["import {DecoratorParameters, decoratorTypeOf, DecoratorTypes, StoreSet} from \"@tsed/core\";\nimport {Inject} from \"../decorators/inject\";\nimport {DIConfiguration} from \"../services/DIConfiguration\";\n\n/**\n * Get or set Configuration on a class.\n *\n * @decorator\n */\nexport function Configuration(configuration: Partial<TsED.Configuration> = {}): Function {\n return (...args: DecoratorParameters) => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.CLASS:\n StoreSet(\"configuration\", configuration)(args[0]);\n\n break;\n default:\n case DecoratorTypes.PARAM_CTOR:\n return Inject(Configuration)(args[0], args[1], args[2] as number);\n }\n };\n}\n\nexport type Configuration = TsED.Configuration & DIConfiguration;\n"]}
@@ -0,0 +1,55 @@
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_1 = require("../constants");
6
+ const InjectablePropertyType_1 = require("../domain/InjectablePropertyType");
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_1.INJECTABLE_PROP, {
45
+ [propertyKey]: {
46
+ bindingType: InjectablePropertyType_1.InjectablePropertyType.CONSTANT,
47
+ propertyKey,
48
+ expression,
49
+ defaultValue
50
+ }
51
+ });
52
+ };
53
+ }
54
+ exports.Constant = Constant;
55
+ //# sourceMappingURL=constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../src/decorators/constant.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,4CAA6C;AAE7C,6EAAwE;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,2BAAe,EAAE;YACxC,CAAC,WAAW,CAAC,EAAE;gBACb,WAAW,EAAE,+CAAsB,CAAC,QAAQ;gBAC5C,WAAW;gBACX,UAAU;gBACV,YAAY;aACb;SACsB,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC;AAXD,4BAWC","sourcesContent":["import {Store} from \"@tsed/core\";\nimport {INJECTABLE_PROP} from \"../constants\";\nimport type {InjectableProperties} from \"../interfaces\";\nimport {InjectablePropertyType} from \"../domain/InjectablePropertyType\";\n\n/**\n * Return value from Configuration.\n *\n * ## Example\n *\n * ```typescript\n * import {Env} from \"@tsed/core\";\n * import {Constant, Value} from \"@tsed/di\";\n *\n * export class MyClass {\n *\n * @Constant(\"env\")\n * env: Env;\n *\n * @Value(\"swagger.path\")\n * swaggerPath: string;\n *\n * @Value(\"swagger.path\", \"defaultValue\")\n * swaggerPath: string;\n *\n * constructor() {\n * console.log(this.swaggerPath) // undefined. Not available on constructor\n * }\n *\n * $onInit() {\n * console.log(this.swaggerPath) // something\n * }\n * }\n * ```\n *\n * @param {string} expression\n * @param defaultValue\n * @returns {(targetClass: any, attributeName: string) => any}\n * @decorator\n */\nexport function Constant(expression: string, defaultValue?: any): any {\n return (target: any, propertyKey: string) => {\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType: InjectablePropertyType.CONSTANT,\n propertyKey,\n expression,\n defaultValue\n }\n } as InjectableProperties);\n };\n}\n"]}
@@ -0,0 +1,53 @@
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_1 = require("../registries/ProviderRegistry");
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_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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/decorators/controller.ts"],"names":[],"mappings":";;;AAAA,qCAAoE;AACpE,yCAA4C;AAE5C,qEAAkE;AAiBlE,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,qCAAkB,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","sourcesContent":["import {isArrayOrArrayClass, Type, useDecorators} from \"@tsed/core\";\nimport {Children, Path} from \"@tsed/schema\";\nimport {IProvider} from \"../interfaces/IProvider\";\nimport {registerController} from \"../registries/ProviderRegistry\";\n\nexport type PathType = string | RegExp | (string | RegExp)[];\n\nexport interface ControllerMiddlewares {\n useBefore: any[];\n use: any[];\n useAfter: any[];\n}\n\nexport interface ControllerOptions extends Partial<IProvider<any>> {\n path?: PathType;\n children?: Type<any>[];\n routerOptions?: any;\n middlewares?: Partial<ControllerMiddlewares>;\n}\n\nfunction mapOptions(options: any): ControllerOptions {\n if (typeof options === \"string\" || options instanceof RegExp || isArrayOrArrayClass(options)) {\n return {\n path: options\n };\n }\n\n return options;\n}\n\n/**\n * Declare a new controller with his Rest path. His methods annotated will be collected to build the routing list.\n * This routing listing will be built with the `express.Router` object.\n *\n * ::: tip\n * See [Controllers](/docs/controllers.md) section for more details\n * :::\n *\n * ```typescript\n * @Controller(\"/calendars\")\n * export provide CalendarCtrl {\n *\n * @Get(\"/:id\")\n * public get(\n * @Req() request: Req,\n * @Res() response: Res,\n * @Next() next: Next\n * ): void {\n *\n * }\n * }\n * ```\n *\n * @param options\n * @controller\n * @decorator\n * @classDecorator\n */\nexport function Controller(options: PathType | ControllerOptions): ClassDecorator {\n const {children = [], path, ...opts} = mapOptions(options);\n\n return useDecorators(\n (target: Type) => {\n registerController({\n provide: target,\n ...opts\n });\n },\n path && Path(path as any),\n Children(...children)\n );\n}\n"]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./scope"), exports);
5
+ (0, tslib_1.__exportStar)(require("./service"), exports);
6
+ (0, tslib_1.__exportStar)(require("./overrideProvider"), exports);
7
+ (0, tslib_1.__exportStar)(require("./inject"), exports);
8
+ (0, tslib_1.__exportStar)(require("./lazyInject"), exports);
9
+ (0, tslib_1.__exportStar)(require("./injectable"), exports);
10
+ (0, tslib_1.__exportStar)(require("./constant"), exports);
11
+ (0, tslib_1.__exportStar)(require("./value"), exports);
12
+ (0, tslib_1.__exportStar)(require("./intercept"), exports);
13
+ (0, tslib_1.__exportStar)(require("./interceptor"), exports);
14
+ (0, tslib_1.__exportStar)(require("./configuration"), exports);
15
+ (0, tslib_1.__exportStar)(require("./module"), exports);
16
+ (0, tslib_1.__exportStar)(require("./opts"), exports);
17
+ (0, tslib_1.__exportStar)(require("./useOpts"), exports);
18
+ (0, tslib_1.__exportStar)(require("./controller"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,uDAAwB;AACxB,yDAA0B;AAC1B,kEAAmC;AACnC,wDAAyB;AACzB,4DAA6B;AAC7B,4DAA6B;AAC7B,0DAA2B;AAC3B,uDAAwB;AACxB,2DAA4B;AAC5B,6DAA8B;AAC9B,+DAAgC;AAChC,wDAAyB;AACzB,sDAAuB;AACvB,yDAA0B;AAC1B,4DAA6B","sourcesContent":["export * from \"./scope\";\nexport * from \"./service\";\nexport * from \"./overrideProvider\";\nexport * from \"./inject\";\nexport * from \"./lazyInject\";\nexport * from \"./injectable\";\nexport * from \"./constant\";\nexport * from \"./value\";\nexport * from \"./intercept\";\nexport * from \"./interceptor\";\nexport * from \"./configuration\";\nexport * from \"./module\";\nexport * from \"./opts\";\nexport * from \"./useOpts\";\nexport * from \"./controller\";\n"]}
@@ -0,0 +1,79 @@
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_1 = require("../constants");
6
+ function injectProperty(target, propertyKey, options) {
7
+ core_1.Store.from(target).merge(constants_1.INJECTABLE_PROP, {
8
+ [propertyKey]: {
9
+ bindingType: core_1.DecoratorTypes.PROP,
10
+ propertyKey,
11
+ ...options
12
+ }
13
+ });
14
+ }
15
+ exports.injectProperty = injectProperty;
16
+ /**
17
+ * Inject a provider to another provider.
18
+ *
19
+ * Use this decorator to inject a custom provider on constructor parameter or property.
20
+ *
21
+ * ```typescript
22
+ * @Injectable()
23
+ * export class MyService {
24
+ * @Inject(CONNECTION)
25
+ * connection: CONNECTION;
26
+ * }
27
+ * ```
28
+ *
29
+ * @param symbol
30
+ * @param onGet Use the given name method to inject
31
+ * @returns {Function}
32
+ * @decorator
33
+ */
34
+ function Inject(symbol, onGet = (bean) => bean) {
35
+ return (target, propertyKey, descriptor) => {
36
+ const bindingType = (0, core_1.decoratorTypeOf)([target, propertyKey, descriptor]);
37
+ switch (bindingType) {
38
+ case core_1.DecoratorTypes.PARAM:
39
+ case core_1.DecoratorTypes.PARAM_CTOR:
40
+ if (symbol) {
41
+ const paramTypes = core_1.Metadata.getParamTypes(target, propertyKey);
42
+ paramTypes[descriptor] = symbol;
43
+ core_1.Metadata.setParamTypes(target, propertyKey, paramTypes);
44
+ }
45
+ break;
46
+ case core_1.DecoratorTypes.PROP:
47
+ injectProperty(target, propertyKey, {
48
+ resolver(injector, locals, { options, ...invokeOptions }) {
49
+ locals.set(constants_1.DI_PARAM_OPTIONS, { ...options });
50
+ let bean;
51
+ if (!bean) {
52
+ const useType = symbol || core_1.Metadata.getType(target, propertyKey);
53
+ bean = injector.invoke(useType, locals, invokeOptions);
54
+ locals.delete(constants_1.DI_PARAM_OPTIONS);
55
+ }
56
+ if ((0, core_1.isPromise)(bean)) {
57
+ bean.then((result) => {
58
+ bean = result;
59
+ });
60
+ }
61
+ return () => onGet(bean);
62
+ }
63
+ });
64
+ break;
65
+ case core_1.DecoratorTypes.METHOD:
66
+ core_1.Store.from(target).merge(constants_1.INJECTABLE_PROP, {
67
+ [propertyKey]: {
68
+ bindingType,
69
+ propertyKey
70
+ }
71
+ });
72
+ return descriptor;
73
+ default:
74
+ throw new core_1.UnsupportedDecoratorType(Inject, [target, propertyKey, descriptor]);
75
+ }
76
+ };
77
+ }
78
+ exports.Inject = Inject;
79
+ //# sourceMappingURL=inject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../src/decorators/inject.ts"],"names":[],"mappings":";;;AAAA,qCAAiH;AACjH,4CAA+D;AAG/D,SAAgB,cAAc,CAAC,MAAW,EAAE,WAAmB,EAAE,OAA2C;IAC1G,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,2BAAe,EAAE;QACxC,CAAC,WAAW,CAAC,EAAE;YACb,WAAW,EAAE,qBAAc,CAAC,IAAI;YAChC,WAAW;YACX,GAAG,OAAO;SACX;KACF,CAAC,CAAC;AACL,CAAC;AARD,wCAQC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,MAAM,CAAC,MAAY,EAAE,QAAQ,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI;IAC9D,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,UAAsD,EAAc,EAAE;QAC9G,MAAM,WAAW,GAAG,IAAA,sBAAe,EAAC,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;QAEvE,QAAQ,WAAW,EAAE;YACnB,KAAK,qBAAc,CAAC,KAAK,CAAC;YAC1B,KAAK,qBAAc,CAAC,UAAU;gBAC5B,IAAI,MAAM,EAAE;oBACV,MAAM,UAAU,GAAG,eAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;oBAE/D,UAAU,CAAC,UAAoB,CAAC,GAAG,MAAM,CAAC;oBAC1C,eAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;iBACzD;gBACD,MAAM;YAER,KAAK,qBAAc,CAAC,IAAI;gBACtB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE;oBAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAC,OAAO,EAAE,GAAG,aAAa,EAAC;wBACpD,MAAM,CAAC,GAAG,CAAC,4BAAgB,EAAE,EAAC,GAAG,OAAO,EAAC,CAAC,CAAC;wBAE3C,IAAI,IAAS,CAAC;wBAEd,IAAI,CAAC,IAAI,EAAE;4BACT,MAAM,OAAO,GAAG,MAAM,IAAI,eAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;4BAChE,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;4BACvD,MAAM,CAAC,MAAM,CAAC,4BAAgB,CAAC,CAAC;yBACjC;wBAED,IAAI,IAAA,gBAAS,EAAC,IAAI,CAAC,EAAE;4BACnB,IAAI,CAAC,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE;gCACxB,IAAI,GAAG,MAAM,CAAC;4BAChB,CAAC,CAAC,CAAC;yBACJ;wBAED,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBAC3B,CAAC;iBACF,CAAC,CAAC;gBACH,MAAM;YAER,KAAK,qBAAc,CAAC,MAAM;gBACxB,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,2BAAe,EAAE;oBACxC,CAAC,WAAW,CAAC,EAAE;wBACb,WAAW;wBACX,WAAW;qBACZ;iBACF,CAAC,CAAC;gBAEH,OAAO,UAAU,CAAC;YAEpB;gBACE,MAAM,IAAI,+BAAwB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;SACjF;IACH,CAAC,CAAC;AACJ,CAAC;AArDD,wBAqDC","sourcesContent":["import {decoratorTypeOf, DecoratorTypes, isPromise, Metadata, Store, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {DI_PARAM_OPTIONS, INJECTABLE_PROP} from \"../constants\";\nimport type {InjectablePropertyOptions} from \"../interfaces/InjectableProperties\";\n\nexport function injectProperty(target: any, propertyKey: string, options: Partial<InjectablePropertyOptions>) {\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType: DecoratorTypes.PROP,\n propertyKey,\n ...options\n }\n });\n}\n\n/**\n * Inject a provider to another provider.\n *\n * Use this decorator to inject a custom provider on constructor parameter or property.\n *\n * ```typescript\n * @Injectable()\n * export class MyService {\n * @Inject(CONNECTION)\n * connection: CONNECTION;\n * }\n * ```\n *\n * @param symbol\n * @param onGet Use the given name method to inject\n * @returns {Function}\n * @decorator\n */\nexport function Inject(symbol?: any, onGet = (bean: any) => bean): Function {\n return (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<Function> | number): any | void => {\n const bindingType = decoratorTypeOf([target, propertyKey, descriptor]);\n\n switch (bindingType) {\n case DecoratorTypes.PARAM:\n case DecoratorTypes.PARAM_CTOR:\n if (symbol) {\n const paramTypes = Metadata.getParamTypes(target, propertyKey);\n\n paramTypes[descriptor as number] = symbol;\n Metadata.setParamTypes(target, propertyKey, paramTypes);\n }\n break;\n\n case DecoratorTypes.PROP:\n injectProperty(target, propertyKey, {\n resolver(injector, locals, {options, ...invokeOptions}) {\n locals.set(DI_PARAM_OPTIONS, {...options});\n\n let bean: any;\n\n if (!bean) {\n const useType = symbol || Metadata.getType(target, propertyKey);\n bean = injector.invoke(useType, locals, invokeOptions);\n locals.delete(DI_PARAM_OPTIONS);\n }\n\n if (isPromise(bean)) {\n bean.then((result: any) => {\n bean = result;\n });\n }\n\n return () => onGet(bean);\n }\n });\n break;\n\n case DecoratorTypes.METHOD:\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType,\n propertyKey\n }\n });\n\n return descriptor;\n\n default:\n throw new UnsupportedDecoratorType(Inject, [target, propertyKey, descriptor]);\n }\n };\n}\n"]}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Injectable = void 0;
4
+ const ProviderRegistry_1 = require("../registries/ProviderRegistry");
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
+ * <<< @/docs/snippets/providers/getting-started-injectable.ts
10
+ *
11
+ * ::: tip
12
+ * `@Injectable()` use the `reflect-metadata` to collect and inject the built provided to other services.
13
+ * :::
14
+ *
15
+ * ### Options
16
+ *
17
+ * - type (@@ProviderType@@ or `string`): Kind of provider. (Default: `ProviderType.PROVIDER`)
18
+ * - scope (@@ProviderScope@@): Kind of provider. (Default: `ProviderScope.SINGLETON`)
19
+ * - provide (@@TokenProvider@@): An injection token (Note: This option override default metadata generated by Typescript).
20
+ * - deps (`Type<any>`): List of class or provider which will be injected to the constructor (Note: This options override default metadata generated by Typescript).
21
+ *
22
+ * @returns {Function}
23
+ * @decorator
24
+ */
25
+ function Injectable(options = {}) {
26
+ return (target) => {
27
+ (0, ProviderRegistry_1.registerProvider)({
28
+ ...options,
29
+ ...(options.provide ? { useClass: target } : { provide: target })
30
+ });
31
+ };
32
+ }
33
+ exports.Injectable = Injectable;
34
+ //# sourceMappingURL=injectable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injectable.js","sourceRoot":"","sources":["../../../src/decorators/injectable.ts"],"names":[],"mappings":";;;AACA,qEAAgE;AAEhE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,UAAU,CAAC,UAA8B,EAAE;IACzD,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,mCAAgB,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","sourcesContent":["import type {IProvider} from \"../interfaces\";\nimport {registerProvider} from \"../registries/ProviderRegistry\";\n\n/**\n * The decorators `@Injectable()` declare a new service can be injected in other service, controller, interceptor, etc.. on there `constructor`.\n * All classes annotated with `@Injectable()` are built one time, excepted if you change the default provider configuration.\n *\n * <<< @/docs/snippets/providers/getting-started-injectable.ts\n *\n * ::: tip\n * `@Injectable()` use the `reflect-metadata` to collect and inject the built provided to other services.\n * :::\n *\n * ### Options\n *\n * - type (@@ProviderType@@ or `string`): Kind of provider. (Default: `ProviderType.PROVIDER`)\n * - scope (@@ProviderScope@@): Kind of provider. (Default: `ProviderScope.SINGLETON`)\n * - provide (@@TokenProvider@@): An injection token (Note: This option override default metadata generated by Typescript).\n * - deps (`Type<any>`): List of class or provider which will be injected to the constructor (Note: This options override default metadata generated by Typescript).\n *\n * @returns {Function}\n * @decorator\n */\nexport function Injectable(options: Partial<IProvider> = {}): ClassDecorator {\n return (target: any) => {\n registerProvider({\n ...options,\n ...(options.provide ? {useClass: target} : {provide: target})\n });\n };\n}\n"]}
@@ -0,0 +1,28 @@
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_1 = require("../constants");
6
+ const domain_1 = require("../domain");
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 (target, propertyKey, descriptor) => {
16
+ core_1.Store.from(target).merge(constants_1.INJECTABLE_PROP, {
17
+ [propertyKey]: {
18
+ bindingType: domain_1.InjectablePropertyType.INTERCEPTOR,
19
+ propertyKey,
20
+ useType: interceptor,
21
+ options
22
+ }
23
+ });
24
+ return descriptor;
25
+ };
26
+ }
27
+ exports.Intercept = Intercept;
28
+ //# sourceMappingURL=intercept.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intercept.js","sourceRoot":"","sources":["../../../src/decorators/intercept.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,4CAA6C;AAE7C,sCAAiD;AAEjD;;;;;;GAMG;AACH,SAAgB,SAAS,CAA+B,WAAoB,EAAE,OAAa;IACzF,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,UAA8B,EAAE,EAAE;QAC1E,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,2BAAe,EAAE;YACxC,CAAC,WAAW,CAAC,EAAE;gBACb,WAAW,EAAE,+BAAsB,CAAC,WAAW;gBAC/C,WAAW;gBACX,OAAO,EAAE,WAAW;gBACpB,OAAO;aACR;SACsB,CAAC,CAAC;QAE3B,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAbD,8BAaC","sourcesContent":["import {Store, Type} from \"@tsed/core\";\nimport {INJECTABLE_PROP} from \"../constants\";\nimport type {InjectableProperties, InterceptorMethods} from \"../interfaces\";\nimport {InjectablePropertyType} from \"../domain\";\n\n/**\n * Attaches interceptor to method call and executes the before and after methods\n *\n * @param interceptor\n * @param options\n * @decorator\n */\nexport function Intercept<T extends InterceptorMethods>(interceptor: Type<T>, options?: any): MethodDecorator {\n return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType: InjectablePropertyType.INTERCEPTOR,\n propertyKey,\n useType: interceptor,\n options\n }\n } as InjectableProperties);\n\n return descriptor;\n };\n}\n"]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Interceptor = void 0;
4
+ const ProviderType_1 = require("../domain/ProviderType");
5
+ const injectable_1 = require("./injectable");
6
+ /**
7
+ * The decorators `@Service()` declare a new service can be injected in other service or controller on there `constructor`.
8
+ * All services annotated with `@Service()` are constructed one time.
9
+ *
10
+ * > `@Service()` use the `reflect-metadata` to collect and inject service on controllers or other services.
11
+ *
12
+ * @returns {Function}
13
+ * @decorator
14
+ */
15
+ function Interceptor() {
16
+ return (0, injectable_1.Injectable)({
17
+ type: ProviderType_1.ProviderType.INTERCEPTOR
18
+ });
19
+ }
20
+ exports.Interceptor = Interceptor;
21
+ //# sourceMappingURL=interceptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interceptor.js","sourceRoot":"","sources":["../../../src/decorators/interceptor.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AACpD,6CAAwC;AAExC;;;;;;;;GAQG;AACH,SAAgB,WAAW;IACzB,OAAO,IAAA,uBAAU,EAAC;QAChB,IAAI,EAAE,2BAAY,CAAC,WAAW;KAC/B,CAAC,CAAC;AACL,CAAC;AAJD,kCAIC","sourcesContent":["import {ProviderType} from \"../domain/ProviderType\";\nimport {Injectable} from \"./injectable\";\n\n/**\n * The decorators `@Service()` declare a new service can be injected in other service or controller on there `constructor`.\n * All services annotated with `@Service()` are constructed one time.\n *\n * > `@Service()` use the `reflect-metadata` to collect and inject service on controllers or other services.\n *\n * @returns {Function}\n * @decorator\n */\nexport function Interceptor(): Function {\n return Injectable({\n type: ProviderType.INTERCEPTOR\n });\n}\n"]}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OptionalLazyInject = exports.LazyInject = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ const inject_1 = require("./inject");
6
+ /**
7
+ * Lazy load a provider from his package and invoke only when the provider is used
8
+ *
9
+ * ```typescript
10
+ * import type {PlatformException} from "@tsed/platform-exceptions";
11
+ *
12
+ * @Injectable()
13
+ * export class MyService {
14
+ * @LazyInject("PlatformException", () => import("@tsed/platform-exceptions"))
15
+ * exceptions: Promise<PlatformException>;
16
+ * }
17
+ * ```
18
+ *
19
+ * @param key
20
+ * @param packageName
21
+ * @param resolver
22
+ * @param optional
23
+ * @returns {Function}
24
+ * @decorator
25
+ */
26
+ function LazyInject(key, resolver, { optional = false, packageName = resolver.toString() } = {}) {
27
+ return (target, propertyKey) => {
28
+ let bean, token;
29
+ (0, inject_1.injectProperty)(target, propertyKey, {
30
+ resolver(injector) {
31
+ return async () => {
32
+ if (!token) {
33
+ const exports = await (0, core_1.importPackage)(packageName, resolver, optional);
34
+ token = exports[key];
35
+ if (!token) {
36
+ if (!optional) {
37
+ throw new Error(`Unable to lazy load the "${key}". The token isn\'t a valid token provider.`);
38
+ }
39
+ }
40
+ bean = token ? await injector.lazyInvoke(token) : {};
41
+ }
42
+ return bean;
43
+ };
44
+ }
45
+ });
46
+ };
47
+ }
48
+ exports.LazyInject = LazyInject;
49
+ /**
50
+ * Optionally Lazy load a provider from his package and invoke only when the provider is used
51
+ *
52
+ * ```typescript
53
+ * import type {PlatformException} from "@tsed/platform-exceptions";
54
+ *
55
+ * @Injectable()
56
+ * export class MyService {
57
+ * @OptionalLazyInject("@tsed/platform-exceptions")
58
+ * exceptions: Promise<PlatformException>;
59
+ * }
60
+ * ```
61
+ *
62
+ * @param key
63
+ * @param resolver
64
+ * @returns {Function}
65
+ * @decorator
66
+ */
67
+ function OptionalLazyInject(key, resolver) {
68
+ return LazyInject(key, resolver, { optional: true });
69
+ }
70
+ exports.OptionalLazyInject = OptionalLazyInject;
71
+ //# sourceMappingURL=lazyInject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazyInject.js","sourceRoot":"","sources":["../../../src/decorators/lazyInject.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AACzC,qCAAwC;AAExC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,UAAU,CACxB,GAAW,EACX,QAAmB,EACnB,EAAC,QAAQ,GAAG,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC,QAAQ,EAAE,KAAgD,EAAE;IAEtG,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAc,EAAE;QACtD,IAAI,IAAS,EAAE,KAAU,CAAC;QAC1B,IAAA,uBAAc,EAAC,MAAM,EAAE,WAAW,EAAE;YAClC,QAAQ,CAAC,QAAQ;gBACf,OAAO,KAAK,IAAI,EAAE;oBAChB,IAAI,CAAC,KAAK,EAAE;wBACV,MAAM,OAAO,GAAG,MAAM,IAAA,oBAAa,EAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;wBACrE,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;wBAErB,IAAI,CAAC,KAAK,EAAE;4BACV,IAAI,CAAC,QAAQ,EAAE;gCACb,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,6CAA6C,CAAC,CAAC;6BAC/F;yBACF;wBAED,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;qBACtD;oBAED,OAAO,IAAI,CAAC;gBACd,CAAC,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AA5BD,gCA4BC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,kBAAkB,CAAC,GAAW,EAAE,QAAmB;IACjE,OAAQ,UAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;AAC9D,CAAC;AAFD,gDAEC","sourcesContent":["import {importPackage} from \"@tsed/core\";\nimport {injectProperty} from \"./inject\";\n\n/**\n * Lazy load a provider from his package and invoke only when the provider is used\n *\n * ```typescript\n * import type {PlatformException} from \"@tsed/platform-exceptions\";\n *\n * @Injectable()\n * export class MyService {\n * @LazyInject(\"PlatformException\", () => import(\"@tsed/platform-exceptions\"))\n * exceptions: Promise<PlatformException>;\n * }\n * ```\n *\n * @param key\n * @param packageName\n * @param resolver\n * @param optional\n * @returns {Function}\n * @decorator\n */\nexport function LazyInject(\n key: string,\n resolver: () => any,\n {optional = false, packageName = resolver.toString()}: {optional?: boolean; packageName?: string} = {}\n): PropertyDecorator {\n return (target: any, propertyKey: string): any | void => {\n let bean: any, token: any;\n injectProperty(target, propertyKey, {\n resolver(injector) {\n return async () => {\n if (!token) {\n const exports = await importPackage(packageName, resolver, optional);\n token = exports[key];\n\n if (!token) {\n if (!optional) {\n throw new Error(`Unable to lazy load the \"${key}\". The token isn\\'t a valid token provider.`);\n }\n }\n\n bean = token ? await injector.lazyInvoke(token) : {};\n }\n\n return bean;\n };\n }\n });\n };\n}\n\n/**\n * Optionally Lazy load a provider from his package and invoke only when the provider is used\n *\n * ```typescript\n * import type {PlatformException} from \"@tsed/platform-exceptions\";\n *\n * @Injectable()\n * export class MyService {\n * @OptionalLazyInject(\"@tsed/platform-exceptions\")\n * exceptions: Promise<PlatformException>;\n * }\n * ```\n *\n * @param key\n * @param resolver\n * @returns {Function}\n * @decorator\n */\nexport function OptionalLazyInject(key: string, resolver: () => any): PropertyDecorator {\n return (LazyInject as any)(key, resolver, {optional: true});\n}\n"]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Module = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ const domain_1 = require("../domain");
6
+ const configuration_1 = require("./configuration");
7
+ const injectable_1 = require("./injectable");
8
+ /**
9
+ * Declare a new Ts.ED module
10
+ *
11
+ * ## Options
12
+ * - imports: List of Provider which must be built by injector before invoking the module
13
+ * - resolvers: List of external DI must be used to resolve unknown provider
14
+ * - deps: List of provider must be injected to the module constructor (explicit declaration)
15
+ *
16
+ * @param options
17
+ * @decorator
18
+ */
19
+ function Module(options = {}) {
20
+ const { scopes, imports, resolvers, deps, scope, ...configuration } = options;
21
+ return (0, core_1.useDecorators)((0, configuration_1.Configuration)(configuration), (0, injectable_1.Injectable)({
22
+ type: domain_1.ProviderType.MODULE,
23
+ scope: domain_1.ProviderScope.SINGLETON,
24
+ imports,
25
+ deps,
26
+ injectable: false,
27
+ resolvers
28
+ }));
29
+ }
30
+ exports.Module = Module;
31
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../../src/decorators/module.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AACzC,sCAAsD;AAEtD,mDAA8C;AAC9C,6CAAwC;AA0BxC;;;;;;;;;;GAUG;AACH,SAAgB,MAAM,CAAC,UAAkC,EAAE;IACzD,MAAM,EAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,aAAa,EAAC,GAAG,OAAO,CAAC;IAE5E,OAAO,IAAA,oBAAa,EAClB,IAAA,6BAAa,EAAC,aAAa,CAAC,EAC5B,IAAA,uBAAU,EAAC;QACT,IAAI,EAAE,qBAAY,CAAC,MAAM;QACzB,KAAK,EAAE,sBAAa,CAAC,SAAS;QAC9B,OAAO;QACP,IAAI;QACJ,UAAU,EAAE,KAAK;QACjB,SAAS;KACV,CAAC,CACH,CAAC;AACJ,CAAC;AAdD,wBAcC","sourcesContent":["import {useDecorators} from \"@tsed/core\";\nimport {ProviderScope, ProviderType} from \"../domain\";\nimport type {DIResolver, TokenProvider} from \"../interfaces\";\nimport {Configuration} from \"./configuration\";\nimport {Injectable} from \"./injectable\";\n\nexport interface ModuleOptions extends Omit<TsED.Configuration, \"scopes\"> {\n /**\n * Provider scope\n */\n scope?: ProviderScope;\n /**\n * Providers must be initialized before building this module\n */\n imports?: TokenProvider[];\n /**\n * Explicit token must be injected in the constructor\n */\n deps?: TokenProvider[];\n /**\n * A list of resolvers to inject provider from external DI.\n */\n resolvers?: DIResolver[];\n\n /**\n * Additional properties are stored as provider configuration.\n */\n [key: string]: any;\n}\n\n/**\n * Declare a new Ts.ED module\n *\n * ## Options\n * - imports: List of Provider which must be built by injector before invoking the module\n * - resolvers: List of external DI must be used to resolve unknown provider\n * - deps: List of provider must be injected to the module constructor (explicit declaration)\n *\n * @param options\n * @decorator\n */\nexport function Module(options: Partial<ModuleOptions> = {}) {\n const {scopes, imports, resolvers, deps, scope, ...configuration} = options;\n\n return useDecorators(\n Configuration(configuration),\n Injectable({\n type: ProviderType.MODULE,\n scope: ProviderScope.SINGLETON,\n imports,\n deps,\n injectable: false,\n resolvers\n })\n );\n}\n"]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Opts = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ const constants_1 = require("../constants");
6
+ const ProviderScope_1 = require("../domain/ProviderScope");
7
+ const inject_1 = require("./inject");
8
+ const scope_1 = require("./scope");
9
+ /**
10
+ * Get instance options. This options depending on his invocation context.
11
+ *
12
+ * ```typescript
13
+ * import {Injectable, Opts, UseOpts} from "@tsed/di";
14
+ *
15
+ * @Injectable()
16
+ * class MyConfigurableService {
17
+ * source: string;
18
+ * constructor(@Opts options: any = {}) {
19
+ * console.log("Hello ", options.source); // log: Hello Service1 then Hello Service2
20
+ *
21
+ * this.source = options.source;
22
+ * }
23
+ * }
24
+ *
25
+ * @Injectable()
26
+ * class MyService1 {
27
+ * constructor(@UseOpts({source: 'Service1'}) service: MyConfigurableService) {
28
+ * console.log(service.source) // log: Service1
29
+ * }
30
+ * }
31
+ *
32
+ * @Injectable()
33
+ * class MyService2 {
34
+ * constructor(@UseOpts({source: 'Service2'}) service: MyConfigurableService) {
35
+ * console.log(service.source) // log: Service2
36
+ * }
37
+ * }
38
+ * ```
39
+ *
40
+ * ::: warning
41
+ * Using @@Opts@@ decorator on a constructor parameter change the Scope of the provider to `ProviderScope.INSTANCE`.
42
+ * :::
43
+ *
44
+ * @param target
45
+ * @param propertyKey
46
+ * @param index
47
+ * @decorator
48
+ */
49
+ function Opts(target, propertyKey, index) {
50
+ (0, scope_1.Scope)(ProviderScope_1.ProviderScope.INSTANCE)((0, core_1.classOf)(target));
51
+ (0, inject_1.Inject)(constants_1.DI_PARAM_OPTIONS)(target, propertyKey, index);
52
+ }
53
+ exports.Opts = Opts;
54
+ //# sourceMappingURL=opts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opts.js","sourceRoot":"","sources":["../../../src/decorators/opts.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AACnC,4CAA8C;AAC9C,2DAAsD;AACtD,qCAAgC;AAChC,mCAA8B;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,SAAgB,IAAI,CAAC,MAAW,EAAE,WAA4B,EAAE,KAAa;IAC3E,IAAA,aAAK,EAAC,6BAAa,CAAC,QAAQ,CAAC,CAAC,IAAA,cAAO,EAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,IAAA,eAAM,EAAC,4BAAgB,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;AACvD,CAAC;AAHD,oBAGC","sourcesContent":["import {classOf} from \"@tsed/core\";\nimport {DI_PARAM_OPTIONS} from \"../constants\";\nimport {ProviderScope} from \"../domain/ProviderScope\";\nimport {Inject} from \"./inject\";\nimport {Scope} from \"./scope\";\n\n/**\n * Get instance options. This options depending on his invocation context.\n *\n * ```typescript\n * import {Injectable, Opts, UseOpts} from \"@tsed/di\";\n *\n * @Injectable()\n * class MyConfigurableService {\n * source: string;\n * constructor(@Opts options: any = {}) {\n * console.log(\"Hello \", options.source); // log: Hello Service1 then Hello Service2\n *\n * this.source = options.source;\n * }\n * }\n *\n * @Injectable()\n * class MyService1 {\n * constructor(@UseOpts({source: 'Service1'}) service: MyConfigurableService) {\n * console.log(service.source) // log: Service1\n * }\n * }\n *\n * @Injectable()\n * class MyService2 {\n * constructor(@UseOpts({source: 'Service2'}) service: MyConfigurableService) {\n * console.log(service.source) // log: Service2\n * }\n * }\n * ```\n *\n * ::: warning\n * Using @@Opts@@ decorator on a constructor parameter change the Scope of the provider to `ProviderScope.INSTANCE`.\n * :::\n *\n * @param target\n * @param propertyKey\n * @param index\n * @decorator\n */\nexport function Opts(target: any, propertyKey: string | symbol, index: number) {\n Scope(ProviderScope.INSTANCE)(classOf(target));\n Inject(DI_PARAM_OPTIONS)(target, propertyKey, index);\n}\n"]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OverrideProvider = void 0;
4
+ const GlobalProviders_1 = require("../registries/GlobalProviders");
5
+ /**
6
+ * Override a provider which is already registered in ProviderRegistry.
7
+ * @returns {Function}
8
+ * @decorators
9
+ * @param originalProvider
10
+ */
11
+ function OverrideProvider(originalProvider) {
12
+ return (target) => {
13
+ GlobalProviders_1.GlobalProviders.get(originalProvider).useClass = target;
14
+ };
15
+ }
16
+ exports.OverrideProvider = OverrideProvider;
17
+ //# sourceMappingURL=overrideProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overrideProvider.js","sourceRoot":"","sources":["../../../src/decorators/overrideProvider.ts"],"names":[],"mappings":";;;AACA,mEAA8D;AAE9D;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,gBAA2B;IAC1D,OAAO,CAAC,MAAiB,EAAQ,EAAE;QACjC,iCAAe,CAAC,GAAG,CAAC,gBAAgB,CAAE,CAAC,QAAQ,GAAG,MAAM,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC;AAJD,4CAIC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {GlobalProviders} from \"../registries/GlobalProviders\";\n\n/**\n * Override a provider which is already registered in ProviderRegistry.\n * @returns {Function}\n * @decorators\n * @param originalProvider\n */\nexport function OverrideProvider(originalProvider: Type<any>): Function {\n return (target: Type<any>): void => {\n GlobalProviders.get(originalProvider)!.useClass = target;\n };\n}\n"]}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Scope = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ const ProviderScope_1 = require("../domain/ProviderScope");
6
+ /**
7
+ *
8
+ * @param {"request" | "singleton" | ProviderScope} scope
9
+ * @returns {Function}
10
+ * @constructor
11
+ */
12
+ function Scope(scope = ProviderScope_1.ProviderScope.REQUEST) {
13
+ return (0, core_1.StoreSet)("scope", scope);
14
+ }
15
+ exports.Scope = Scope;
16
+ //# sourceMappingURL=scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/decorators/scope.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AACpC,2DAAsD;AAEtD;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,QAAiD,6BAAa,CAAC,OAAO;IAC1F,OAAO,IAAA,eAAQ,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC;AAFD,sBAEC","sourcesContent":["import {StoreSet} from \"@tsed/core\";\nimport {ProviderScope} from \"../domain/ProviderScope\";\n\n/**\n *\n * @param {\"request\" | \"singleton\" | ProviderScope} scope\n * @returns {Function}\n * @constructor\n */\nexport function Scope(scope: \"request\" | \"singleton\" | ProviderScope = ProviderScope.REQUEST) {\n return StoreSet(\"scope\", scope);\n}\n"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Service = void 0;
4
+ const injectable_1 = require("./injectable");
5
+ /**
6
+ * The decorators `@Service()` declare a new service can be injected in other service or controller on there `constructor`.
7
+ * All services annotated with `@Service()` are constructed one time.
8
+ *
9
+ * > `@Service()` use the `reflect-metadata` to collect and inject service on controllers or other services.
10
+ *
11
+ * @returns {Function}
12
+ * @decorator
13
+ */
14
+ function Service() {
15
+ return (0, injectable_1.Injectable)();
16
+ }
17
+ exports.Service = Service;
18
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/decorators/service.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC;;;;;;;;GAQG;AACH,SAAgB,OAAO;IACrB,OAAO,IAAA,uBAAU,GAAE,CAAC;AACtB,CAAC;AAFD,0BAEC","sourcesContent":["import {Injectable} from \"./injectable\";\n\n/**\n * The decorators `@Service()` declare a new service can be injected in other service or controller on there `constructor`.\n * All services annotated with `@Service()` are constructed one time.\n *\n * > `@Service()` use the `reflect-metadata` to collect and inject service on controllers or other services.\n *\n * @returns {Function}\n * @decorator\n */\nexport function Service(): Function {\n return Injectable();\n}\n"]}