@tsed/di 8.0.0-alpha.1 → 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 (251) 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/decorators/autoInjectable.js.map +1 -1
  4. package/lib/esm/common/decorators/configuration.js.map +1 -1
  5. package/lib/esm/common/decorators/constant.js.map +1 -1
  6. package/lib/esm/common/decorators/controller.js.map +1 -1
  7. package/lib/esm/common/decorators/inject.js +1 -1
  8. package/lib/esm/common/decorators/inject.js.map +1 -1
  9. package/lib/esm/common/decorators/intercept.js.map +1 -1
  10. package/lib/esm/common/decorators/lazyInject.js.map +1 -1
  11. package/lib/esm/common/decorators/module.js +1 -1
  12. package/lib/esm/common/decorators/module.js.map +1 -1
  13. package/lib/esm/common/decorators/opts.js.map +1 -1
  14. package/lib/esm/common/decorators/overrideProvider.js.map +1 -1
  15. package/lib/esm/common/decorators/scope.js.map +1 -1
  16. package/lib/esm/common/decorators/useOpts.js +1 -1
  17. package/lib/esm/common/decorators/useOpts.js.map +1 -1
  18. package/lib/esm/common/decorators/value.js.map +1 -1
  19. package/lib/esm/common/domain/Container.js.map +1 -1
  20. package/lib/esm/common/domain/LocalsContainer.js.map +1 -1
  21. package/lib/esm/common/domain/Provider.js.map +1 -1
  22. package/lib/esm/common/errors/InjectionError.js.map +1 -1
  23. package/lib/esm/common/registries/GlobalProviders.js +1 -5
  24. package/lib/esm/common/registries/GlobalProviders.js.map +1 -1
  25. package/lib/esm/common/registries/ProviderRegistry.js.map +1 -1
  26. package/lib/esm/common/services/DIConfiguration.js.map +1 -1
  27. package/lib/esm/common/services/InjectorService.js.map +1 -1
  28. package/lib/esm/common/utils/createContainer.js.map +1 -1
  29. package/lib/esm/common/utils/resolveControllers.js +1 -1
  30. package/lib/esm/common/utils/resolveControllers.js.map +1 -1
  31. package/lib/esm/node/decorators/injectContext.js +2 -2
  32. package/lib/esm/node/decorators/injectContext.js.map +1 -1
  33. package/lib/esm/node/domain/ContextLogger.js +2 -2
  34. package/lib/esm/node/domain/ContextLogger.js.map +1 -1
  35. package/lib/esm/node/domain/DIContext.js.map +1 -1
  36. package/lib/esm/node/services/DILogger.js.map +1 -1
  37. package/lib/esm/node/services/DITest.js +1 -1
  38. package/lib/esm/node/services/DITest.js.map +1 -1
  39. package/lib/esm/node/utils/asyncHookContext.js +3 -2
  40. package/lib/esm/node/utils/asyncHookContext.js.map +1 -1
  41. package/lib/esm/node/utils/setLoggerFormat.js.map +1 -1
  42. package/lib/esm/node/utils/setLoggerLevel.js.map +1 -1
  43. package/lib/types/common/decorators/module.d.ts +1 -1
  44. package/lib/types/common/domain/Container.d.ts +1 -1
  45. package/lib/types/common/domain/Provider.d.ts +1 -1
  46. package/lib/types/common/interfaces/ProviderOpts.d.ts +1 -1
  47. package/lib/types/common/interfaces/TokenProvider.d.ts +1 -1
  48. package/lib/types/node/decorators/injectContext.d.ts +2 -1
  49. package/lib/types/node/domain/ContextLogger.d.ts +3 -3
  50. package/lib/types/node/domain/DIContext.d.ts +1 -1
  51. package/lib/types/node/utils/asyncHookContext.d.ts +4 -3
  52. package/package.json +17 -18
  53. package/vitest.config.mts +4 -4
  54. package/lib/cjs/common/constants/constants.js +0 -9
  55. package/lib/cjs/common/constants/constants.js.map +0 -1
  56. package/lib/cjs/common/decorators/autoInjectable.js +0 -38
  57. package/lib/cjs/common/decorators/autoInjectable.js.map +0 -1
  58. package/lib/cjs/common/decorators/configuration.js +0 -24
  59. package/lib/cjs/common/decorators/configuration.js.map +0 -1
  60. package/lib/cjs/common/decorators/constant.js +0 -74
  61. package/lib/cjs/common/decorators/constant.js.map +0 -1
  62. package/lib/cjs/common/decorators/controller.js +0 -53
  63. package/lib/cjs/common/decorators/controller.js.map +0 -1
  64. package/lib/cjs/common/decorators/inject.js +0 -84
  65. package/lib/cjs/common/decorators/inject.js.map +0 -1
  66. package/lib/cjs/common/decorators/injectable.js +0 -32
  67. package/lib/cjs/common/decorators/injectable.js.map +0 -1
  68. package/lib/cjs/common/decorators/intercept.js +0 -65
  69. package/lib/cjs/common/decorators/intercept.js.map +0 -1
  70. package/lib/cjs/common/decorators/interceptor.js +0 -21
  71. package/lib/cjs/common/decorators/interceptor.js.map +0 -1
  72. package/lib/cjs/common/decorators/lazyInject.js +0 -71
  73. package/lib/cjs/common/decorators/lazyInject.js.map +0 -1
  74. package/lib/cjs/common/decorators/module.js +0 -32
  75. package/lib/cjs/common/decorators/module.js.map +0 -1
  76. package/lib/cjs/common/decorators/opts.js +0 -54
  77. package/lib/cjs/common/decorators/opts.js.map +0 -1
  78. package/lib/cjs/common/decorators/overrideProvider.js +0 -17
  79. package/lib/cjs/common/decorators/overrideProvider.js.map +0 -1
  80. package/lib/cjs/common/decorators/scope.js +0 -16
  81. package/lib/cjs/common/decorators/scope.js.map +0 -1
  82. package/lib/cjs/common/decorators/service.js +0 -18
  83. package/lib/cjs/common/decorators/service.js.map +0 -1
  84. package/lib/cjs/common/decorators/useOpts.js +0 -61
  85. package/lib/cjs/common/decorators/useOpts.js.map +0 -1
  86. package/lib/cjs/common/decorators/value.js +0 -62
  87. package/lib/cjs/common/decorators/value.js.map +0 -1
  88. package/lib/cjs/common/domain/Container.js +0 -72
  89. package/lib/cjs/common/domain/Container.js.map +0 -1
  90. package/lib/cjs/common/domain/ControllerProvider.js +0 -36
  91. package/lib/cjs/common/domain/ControllerProvider.js.map +0 -1
  92. package/lib/cjs/common/domain/InjectablePropertyType.js +0 -12
  93. package/lib/cjs/common/domain/InjectablePropertyType.js.map +0 -1
  94. package/lib/cjs/common/domain/LocalsContainer.js +0 -15
  95. package/lib/cjs/common/domain/LocalsContainer.js.map +0 -1
  96. package/lib/cjs/common/domain/Provider.js +0 -134
  97. package/lib/cjs/common/domain/Provider.js.map +0 -1
  98. package/lib/cjs/common/domain/ProviderScope.js +0 -10
  99. package/lib/cjs/common/domain/ProviderScope.js.map +0 -1
  100. package/lib/cjs/common/domain/ProviderType.js +0 -15
  101. package/lib/cjs/common/domain/ProviderType.js.map +0 -1
  102. package/lib/cjs/common/errors/InjectionError.js +0 -58
  103. package/lib/cjs/common/errors/InjectionError.js.map +0 -1
  104. package/lib/cjs/common/errors/InvalidPropertyTokenError.js +0 -12
  105. package/lib/cjs/common/errors/InvalidPropertyTokenError.js.map +0 -1
  106. package/lib/cjs/common/index.js +0 -58
  107. package/lib/cjs/common/index.js.map +0 -1
  108. package/lib/cjs/common/interfaces/DIConfigurationOptions.js +0 -3
  109. package/lib/cjs/common/interfaces/DIConfigurationOptions.js.map +0 -1
  110. package/lib/cjs/common/interfaces/DILogger.js +0 -3
  111. package/lib/cjs/common/interfaces/DILogger.js.map +0 -1
  112. package/lib/cjs/common/interfaces/DILoggerOptions.js +0 -3
  113. package/lib/cjs/common/interfaces/DILoggerOptions.js.map +0 -1
  114. package/lib/cjs/common/interfaces/DIResolver.js +0 -3
  115. package/lib/cjs/common/interfaces/DIResolver.js.map +0 -1
  116. package/lib/cjs/common/interfaces/ImportTokenProviderOpts.js +0 -3
  117. package/lib/cjs/common/interfaces/ImportTokenProviderOpts.js.map +0 -1
  118. package/lib/cjs/common/interfaces/InterceptorContext.js +0 -3
  119. package/lib/cjs/common/interfaces/InterceptorContext.js.map +0 -1
  120. package/lib/cjs/common/interfaces/InterceptorMethods.js +0 -3
  121. package/lib/cjs/common/interfaces/InterceptorMethods.js.map +0 -1
  122. package/lib/cjs/common/interfaces/InvokeOptions.js +0 -3
  123. package/lib/cjs/common/interfaces/InvokeOptions.js.map +0 -1
  124. package/lib/cjs/common/interfaces/OnDestroy.js +0 -3
  125. package/lib/cjs/common/interfaces/OnDestroy.js.map +0 -1
  126. package/lib/cjs/common/interfaces/OnInit.js +0 -3
  127. package/lib/cjs/common/interfaces/OnInit.js.map +0 -1
  128. package/lib/cjs/common/interfaces/ProviderOpts.js +0 -3
  129. package/lib/cjs/common/interfaces/ProviderOpts.js.map +0 -1
  130. package/lib/cjs/common/interfaces/RegistrySettings.js +0 -3
  131. package/lib/cjs/common/interfaces/RegistrySettings.js.map +0 -1
  132. package/lib/cjs/common/interfaces/ResolvedInvokeOptions.js +0 -3
  133. package/lib/cjs/common/interfaces/ResolvedInvokeOptions.js.map +0 -1
  134. package/lib/cjs/common/interfaces/TokenProvider.js +0 -3
  135. package/lib/cjs/common/interfaces/TokenProvider.js.map +0 -1
  136. package/lib/cjs/common/interfaces/TokenRoute.js +0 -3
  137. package/lib/cjs/common/interfaces/TokenRoute.js.map +0 -1
  138. package/lib/cjs/common/registries/GlobalProviders.js +0 -121
  139. package/lib/cjs/common/registries/GlobalProviders.js.map +0 -1
  140. package/lib/cjs/common/registries/ProviderRegistry.js +0 -86
  141. package/lib/cjs/common/registries/ProviderRegistry.js.map +0 -1
  142. package/lib/cjs/common/services/DIConfiguration.js +0 -142
  143. package/lib/cjs/common/services/DIConfiguration.js.map +0 -1
  144. package/lib/cjs/common/services/DILogger.js +0 -14
  145. package/lib/cjs/common/services/DILogger.js.map +0 -1
  146. package/lib/cjs/common/services/InjectorService.js +0 -536
  147. package/lib/cjs/common/services/InjectorService.js.map +0 -1
  148. package/lib/cjs/common/utils/colors.js +0 -10
  149. package/lib/cjs/common/utils/colors.js.map +0 -1
  150. package/lib/cjs/common/utils/createContainer.js +0 -14
  151. package/lib/cjs/common/utils/createContainer.js.map +0 -1
  152. package/lib/cjs/common/utils/getConfiguration.js +0 -23
  153. package/lib/cjs/common/utils/getConfiguration.js.map +0 -1
  154. package/lib/cjs/common/utils/getConstructorDependencies.js +0 -13
  155. package/lib/cjs/common/utils/getConstructorDependencies.js.map +0 -1
  156. package/lib/cjs/common/utils/resolveControllers.js +0 -47
  157. package/lib/cjs/common/utils/resolveControllers.js.map +0 -1
  158. package/lib/cjs/index.js +0 -6
  159. package/lib/cjs/index.js.map +0 -1
  160. package/lib/cjs/node/decorators/injectContext.js +0 -39
  161. package/lib/cjs/node/decorators/injectContext.js.map +0 -1
  162. package/lib/cjs/node/domain/ContextLogger.js +0 -99
  163. package/lib/cjs/node/domain/ContextLogger.js.map +0 -1
  164. package/lib/cjs/node/domain/DIContext.js +0 -102
  165. package/lib/cjs/node/domain/DIContext.js.map +0 -1
  166. package/lib/cjs/node/index.js +0 -18
  167. package/lib/cjs/node/index.js.map +0 -1
  168. package/lib/cjs/node/interfaces/AlterRunInContext.js +0 -3
  169. package/lib/cjs/node/interfaces/AlterRunInContext.js.map +0 -1
  170. package/lib/cjs/node/services/DILogger.js +0 -12
  171. package/lib/cjs/node/services/DILogger.js.map +0 -1
  172. package/lib/cjs/node/services/DITest.js +0 -126
  173. package/lib/cjs/node/services/DITest.js.map +0 -1
  174. package/lib/cjs/node/utils/asyncHookContext.js +0 -42
  175. package/lib/cjs/node/utils/asyncHookContext.js.map +0 -1
  176. package/lib/cjs/node/utils/attachLogger.js +0 -10
  177. package/lib/cjs/node/utils/attachLogger.js.map +0 -1
  178. package/lib/cjs/node/utils/setLoggerConfiguration.js +0 -11
  179. package/lib/cjs/node/utils/setLoggerConfiguration.js.map +0 -1
  180. package/lib/cjs/node/utils/setLoggerFormat.js +0 -33
  181. package/lib/cjs/node/utils/setLoggerFormat.js.map +0 -1
  182. package/lib/cjs/node/utils/setLoggerLevel.js +0 -15
  183. package/lib/cjs/node/utils/setLoggerLevel.js.map +0 -1
  184. package/lib/cjs/package.json +0 -3
  185. package/lib/esm/package.json +0 -3
  186. package/lib/types-esm/common/constants/constants.d.ts +0 -5
  187. package/lib/types-esm/common/decorators/autoInjectable.d.ts +0 -1
  188. package/lib/types-esm/common/decorators/configuration.d.ts +0 -8
  189. package/lib/types-esm/common/decorators/constant.d.ts +0 -39
  190. package/lib/types-esm/common/decorators/controller.d.ts +0 -42
  191. package/lib/types-esm/common/decorators/inject.d.ts +0 -35
  192. package/lib/types-esm/common/decorators/injectable.d.ts +0 -20
  193. package/lib/types-esm/common/decorators/intercept.d.ts +0 -13
  194. package/lib/types-esm/common/decorators/interceptor.d.ts +0 -10
  195. package/lib/types-esm/common/decorators/lazyInject.d.ts +0 -43
  196. package/lib/types-esm/common/decorators/module.d.ts +0 -37
  197. package/lib/types-esm/common/decorators/opts.d.ts +0 -41
  198. package/lib/types-esm/common/decorators/overrideProvider.d.ts +0 -8
  199. package/lib/types-esm/common/decorators/scope.d.ts +0 -8
  200. package/lib/types-esm/common/decorators/service.d.ts +0 -10
  201. package/lib/types-esm/common/decorators/useOpts.d.ts +0 -42
  202. package/lib/types-esm/common/decorators/value.d.ts +0 -37
  203. package/lib/types-esm/common/domain/Container.d.ts +0 -43
  204. package/lib/types-esm/common/domain/ControllerProvider.d.ts +0 -17
  205. package/lib/types-esm/common/domain/InjectablePropertyType.d.ts +0 -7
  206. package/lib/types-esm/common/domain/LocalsContainer.d.ts +0 -6
  207. package/lib/types-esm/common/domain/Provider.d.ts +0 -71
  208. package/lib/types-esm/common/domain/ProviderScope.d.ts +0 -5
  209. package/lib/types-esm/common/domain/ProviderType.d.ts +0 -10
  210. package/lib/types-esm/common/errors/InjectionError.d.ts +0 -8
  211. package/lib/types-esm/common/errors/InvalidPropertyTokenError.d.ts +0 -4
  212. package/lib/types-esm/common/index.d.ts +0 -54
  213. package/lib/types-esm/common/interfaces/DIConfigurationOptions.d.ts +0 -29
  214. package/lib/types-esm/common/interfaces/DILogger.d.ts +0 -8
  215. package/lib/types-esm/common/interfaces/DILoggerOptions.d.ts +0 -53
  216. package/lib/types-esm/common/interfaces/DIResolver.d.ts +0 -5
  217. package/lib/types-esm/common/interfaces/ImportTokenProviderOpts.d.ts +0 -19
  218. package/lib/types-esm/common/interfaces/InterceptorContext.d.ts +0 -11
  219. package/lib/types-esm/common/interfaces/InterceptorMethods.d.ts +0 -4
  220. package/lib/types-esm/common/interfaces/InvokeOptions.d.ts +0 -30
  221. package/lib/types-esm/common/interfaces/OnDestroy.d.ts +0 -3
  222. package/lib/types-esm/common/interfaces/OnInit.d.ts +0 -3
  223. package/lib/types-esm/common/interfaces/ProviderOpts.d.ts +0 -59
  224. package/lib/types-esm/common/interfaces/RegistrySettings.d.ts +0 -21
  225. package/lib/types-esm/common/interfaces/ResolvedInvokeOptions.d.ts +0 -12
  226. package/lib/types-esm/common/interfaces/TokenProvider.d.ts +0 -2
  227. package/lib/types-esm/common/interfaces/TokenRoute.d.ts +0 -5
  228. package/lib/types-esm/common/registries/GlobalProviders.d.ts +0 -58
  229. package/lib/types-esm/common/registries/ProviderRegistry.d.ts +0 -58
  230. package/lib/types-esm/common/services/DIConfiguration.d.ts +0 -57
  231. package/lib/types-esm/common/services/DILogger.d.ts +0 -3
  232. package/lib/types-esm/common/services/InjectorService.d.ts +0 -203
  233. package/lib/types-esm/common/utils/colors.d.ts +0 -5
  234. package/lib/types-esm/common/utils/createContainer.d.ts +0 -3
  235. package/lib/types-esm/common/utils/getConfiguration.d.ts +0 -3
  236. package/lib/types-esm/common/utils/getConstructorDependencies.d.ts +0 -2
  237. package/lib/types-esm/common/utils/resolveControllers.d.ts +0 -12
  238. package/lib/types-esm/index.d.ts +0 -2
  239. package/lib/types-esm/node/decorators/injectContext.d.ts +0 -15
  240. package/lib/types-esm/node/domain/ContextLogger.d.ts +0 -37
  241. package/lib/types-esm/node/domain/DIContext.d.ts +0 -61
  242. package/lib/types-esm/node/index.d.ts +0 -14
  243. package/lib/types-esm/node/interfaces/AlterRunInContext.d.ts +0 -3
  244. package/lib/types-esm/node/services/DILogger.d.ts +0 -1
  245. package/lib/types-esm/node/services/DITest.d.ts +0 -37
  246. package/lib/types-esm/node/utils/asyncHookContext.d.ts +0 -14
  247. package/lib/types-esm/node/utils/attachLogger.d.ts +0 -2
  248. package/lib/types-esm/node/utils/setLoggerConfiguration.d.ts +0 -2
  249. package/lib/types-esm/node/utils/setLoggerFormat.d.ts +0 -6
  250. package/lib/types-esm/node/utils/setLoggerLevel.d.ts +0 -6
  251. /package/{webpack.config.js → webpack.config.cjs} +0 -0
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveControllers = exports.getTokens = void 0;
4
- const core_1 = require("@tsed/core");
5
- const GlobalProviders_js_1 = require("../registries/GlobalProviders.js");
6
- const ProviderType_js_1 = require("../domain/ProviderType.js");
7
- const lookupProperties = ["mount", "imports"];
8
- function getTokens(config) {
9
- if (!config) {
10
- return [];
11
- }
12
- if ((0, core_1.isArray)(config)) {
13
- return config.filter(core_1.isClass).map((value) => {
14
- return { token: value };
15
- });
16
- }
17
- return Object.keys(config).reduce((list, route) => {
18
- return [
19
- ...list,
20
- ...[]
21
- .concat(config[route])
22
- .filter(core_1.isClass)
23
- .map((token) => ({
24
- route,
25
- token
26
- }))
27
- ];
28
- }, []);
29
- }
30
- exports.getTokens = getTokens;
31
- function resolveRecursively(providers) {
32
- return providers
33
- .map(({ token }) => GlobalProviders_js_1.GlobalProviders.get(token))
34
- .filter((provider) => provider?.type === ProviderType_js_1.ProviderType.MODULE && provider.configuration)
35
- .flatMap((provider) => resolveControllers(provider.configuration));
36
- }
37
- /**
38
- * Return controllers and is base route according to his configuration in module configuration.
39
- *
40
- * @param settings
41
- */
42
- function resolveControllers(settings) {
43
- const providers = lookupProperties.flatMap((property) => getTokens(settings[property]));
44
- return [...resolveRecursively(providers), ...providers].filter((provider) => !!provider.route);
45
- }
46
- exports.resolveControllers = resolveControllers;
47
- //# sourceMappingURL=resolveControllers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveControllers.js","sourceRoot":"","sources":["../../../../src/common/utils/resolveControllers.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAE5C,yEAAiE;AACjE,+DAAuD;AAIvD,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAE9C,SAAgB,SAAS,CAAC,MAAW;IACnC,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,EAAE,CAAC;KACX;IAED,IAAI,IAAA,cAAO,EAAC,MAAM,CAAC,EAAE;QACnB,OAAO,MAAM,CAAC,MAAM,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,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAU,CAAC;AAC1G,CAAC;AAJD,gDAIC"}
package/lib/cjs/index.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./common/index.js"), exports);
5
- tslib_1.__exportStar(require("./node/index.js"), exports);
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,0DAAgC"}
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InjectContext = void 0;
4
- const core_1 = require("@tsed/core");
5
- const index_js_1 = require("../../common/index.js");
6
- const DIContext_js_1 = require("../domain/DIContext.js");
7
- const asyncHookContext_js_1 = require("../utils/asyncHookContext.js");
8
- /**
9
- * Inject a context like PlatformContext or any BaseContext.
10
- *
11
- * ```typescript
12
- * @Injectable()
13
- * export class MyService {
14
- * @InjectContext()
15
- * ctx?: Context;
16
- * }
17
- * ```
18
- *
19
- * @returns {Function}
20
- * @decorator
21
- */
22
- function InjectContext() {
23
- return (target, propertyKey) => {
24
- (0, core_1.catchError)(() => Reflect.deleteProperty(target, propertyKey));
25
- Reflect.defineProperty(target, propertyKey, {
26
- get() {
27
- return ((0, asyncHookContext_js_1.getContext)() ||
28
- new DIContext_js_1.DIContext({
29
- id: "",
30
- logger: index_js_1.InjectorService.getInstance().logger,
31
- injector: index_js_1.InjectorService.getInstance(),
32
- maxStackSize: 0
33
- }));
34
- }
35
- });
36
- };
37
- }
38
- exports.InjectContext = InjectContext;
39
- //# sourceMappingURL=injectContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectContext.js","sourceRoot":"","sources":["../../../../src/node/decorators/injectContext.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AACtC,oDAAsD;AACtD,yDAAiD;AACjD,sEAAwD;AAExD;;;;;;;;;;;;;GAaG;AACH,SAAgB,aAAa;IAC3B,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAc,EAAE;QACtD,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;QAC9D,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE;YAC1C,GAAG;gBACD,OAAO,CACL,IAAA,gCAAU,GAAE;oBACZ,IAAI,wBAAS,CAAC;wBACZ,EAAE,EAAE,EAAE;wBACN,MAAM,EAAE,0BAAe,CAAC,WAAW,EAAE,CAAC,MAAM;wBAC5C,QAAQ,EAAE,0BAAe,CAAC,WAAW,EAAE;wBACvC,YAAY,EAAE,CAAC;qBAChB,CAAC,CACH,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAjBD,sCAiBC"}
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ContextLogger = void 0;
4
- const core_1 = require("@tsed/core");
5
- const logger_1 = require("@tsed/logger");
6
- const LEVELS = (0, logger_1.levels)();
7
- class ContextLogger {
8
- #additionalProps;
9
- #hooks;
10
- #stack;
11
- #logger;
12
- constructor({ id, logger, dateStart = new Date(), level = "all", maxStackSize = 30, additionalProps }) {
13
- this.dateStart = dateStart;
14
- this.id = id;
15
- this.#logger = logger;
16
- this.#additionalProps = additionalProps;
17
- this.level = (LEVELS[level.toUpperCase()] || LEVELS.ALL);
18
- this.maxStackSize = maxStackSize;
19
- }
20
- get hooks() {
21
- return (this.#hooks = this.#hooks || new core_1.Hooks());
22
- }
23
- get stack() {
24
- return (this.#stack = this.#stack || []);
25
- }
26
- alterLog(cb) {
27
- return this.hooks.on("log", cb);
28
- }
29
- alterIgnoreLog(cb) {
30
- return this.hooks.on("ignore", cb);
31
- }
32
- info(obj) {
33
- this.run((0, logger_1.levels)().INFO, obj);
34
- return this;
35
- }
36
- debug(obj, withRequest = true) {
37
- this.run((0, logger_1.levels)().DEBUG, obj, withRequest);
38
- return this;
39
- }
40
- warn(obj) {
41
- this.run((0, logger_1.levels)().WARN, obj);
42
- return this;
43
- }
44
- error(obj) {
45
- this.run((0, logger_1.levels)().ERROR, obj);
46
- return this;
47
- }
48
- fatal(obj) {
49
- this.run((0, logger_1.levels)().FATAL, obj);
50
- return this;
51
- }
52
- trace(obj) {
53
- this.run((0, logger_1.levels)().TRACE, obj);
54
- return this;
55
- }
56
- flush(stream = false) {
57
- if (this.stack.length) {
58
- this.stack.forEach(({ level, data }) => {
59
- this.#logger[level](data);
60
- });
61
- this.#stack = [];
62
- }
63
- if (stream) {
64
- this.maxStackSize = 0;
65
- }
66
- }
67
- isLevelEnabled(otherLevel) {
68
- return this.level.isLessThanOrEqualTo(otherLevel);
69
- }
70
- /**
71
- * Return the duration between the time when LogIncomingRequest has handle the request and now.
72
- * @returns {number}
73
- */
74
- getDuration() {
75
- return new Date().getTime() - this.dateStart.getTime();
76
- }
77
- getData(obj) {
78
- if (typeof obj === "string") {
79
- obj = { message: obj };
80
- }
81
- return { ...this.#additionalProps, reqId: this.id, time: new Date(), duration: this.getDuration(), ...obj };
82
- }
83
- run(level, obj, withRequest) {
84
- if (!this.isLevelEnabled(level)) {
85
- return;
86
- }
87
- const ignore = this.#hooks?.alter("ignore", false, [obj]);
88
- if (!ignore) {
89
- const levelStr = level.levelStr.toLowerCase();
90
- obj = this.hooks.alter("log", this.getData(obj), [levelStr, withRequest]);
91
- this.stack.push({ level: levelStr, data: obj });
92
- }
93
- if (this.maxStackSize < this.stack.length || [(0, logger_1.levels)().FATAL, (0, logger_1.levels)().ERROR].includes(level)) {
94
- this.flush();
95
- }
96
- }
97
- }
98
- exports.ContextLogger = ContextLogger;
99
- //# sourceMappingURL=ContextLogger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContextLogger.js","sourceRoot":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AC,MAAM,IAAI,CAAC,IAAA,eAAM,GAAE,CAAC,KAAK,EAAE,IAAA,eAAM,GAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YAC7F,IAAI,CAAC,KAAK,EAAE,CAAC;SACd;IACH,CAAC;CACF;AAxHD,sCAwHC"}
@@ -1,102 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DIContext = void 0;
4
- const index_js_1 = require("../../common/index.js");
5
- const asyncHookContext_js_1 = require("../utils/asyncHookContext.js");
6
- const ContextLogger_js_1 = require("./ContextLogger.js");
7
- class DIContext {
8
- #container;
9
- #cache;
10
- #logger;
11
- constructor(opts) {
12
- this.opts = opts;
13
- this.PLATFORM = "DI";
14
- this.PLATFORM = opts.platform || this.PLATFORM;
15
- }
16
- /**
17
- * Logger attached to the context request.
18
- */
19
- get logger() {
20
- this.#logger = this.#logger || new ContextLogger_js_1.ContextLogger(this.opts);
21
- return this.#logger;
22
- }
23
- /**
24
- * Request id generated by @@contextMiddleware@@.
25
- *
26
- * ::: tip
27
- * By default Ts.ED generate uuid like that `uuidv4().replace(/-/gi, ""))`.
28
- * Dash are removed to simplify tracking logs in Kibana
29
- * :::
30
- *
31
- * ::: tip
32
- * Request id can by customized by changing the server configuration.
33
- *
34
- * ```typescript
35
- * @Configuration({
36
- * logger: {
37
- * reqIdBuilder: createUniqId // give your own id generator function
38
- * }
39
- * })
40
- * class Server {
41
- *
42
- * }
43
- * ```
44
- * :::
45
- *
46
- */
47
- get id() {
48
- return this.opts.id;
49
- }
50
- get dateStart() {
51
- return this.logger.dateStart;
52
- }
53
- get injector() {
54
- return this.opts.injector;
55
- }
56
- get env() {
57
- return this.injector.settings.get("env");
58
- }
59
- /**
60
- * The request container used by the Ts.ED DI. It contains all services annotated with `@Scope(ProviderScope.REQUEST)`
61
- */
62
- get container() {
63
- return (this.#container = this.#container || new index_js_1.LocalsContainer());
64
- }
65
- destroy() {
66
- return Promise.all([this.#container?.destroy(), this.#logger?.flush(true)]);
67
- }
68
- emit(eventName, ...args) {
69
- return this.injector?.emit(eventName, ...args);
70
- }
71
- runInContext(next) {
72
- return (0, asyncHookContext_js_1.runInContext)(this, next);
73
- }
74
- cache(key, cb) {
75
- if (!this.has(key)) {
76
- this.set(key, cb());
77
- }
78
- return this.get(key);
79
- }
80
- async cacheAsync(key, cb) {
81
- if (!this.has(key)) {
82
- this.set(key, await cb());
83
- }
84
- return this.get(key);
85
- }
86
- delete(key) {
87
- return !!this.#cache?.delete(key);
88
- }
89
- get(key) {
90
- return this.#cache?.get(key);
91
- }
92
- has(key) {
93
- return !!this.#cache?.has(key);
94
- }
95
- set(key, value) {
96
- this.#cache = this.#cache || new Map();
97
- this.#cache.set(key, value);
98
- return this;
99
- }
100
- }
101
- exports.DIContext = DIContext;
102
- //# sourceMappingURL=DIContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../../../src/node/domain/DIContext.ts"],"names":[],"mappings":";;;AAAA,oDAAuE;AACvE,sEAA0D;AAC1D,yDAAuE;AASvE,MAAa,SAAS;IAGpB,UAAU,CAAmB;IAC7B,MAAM,CAAiB;IACvB,OAAO,CAAiB;IAExB,YAAmB,IAAsB;QAAtB,SAAI,GAAJ,IAAI,CAAkB;QALhC,aAAQ,GAAW,IAAI,CAAC;QAM/B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACR,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,gCAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC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CAAC;SAC3B;QAED,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,GAAQ;QACb,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,GAAG,CAAU,GAAQ;QACnB,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,GAAG,CAAC,GAAQ;QACV,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAED,GAAG,CAAC,GAAQ,EAAE,KAAU;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,GAAG,EAAY,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/GD,8BA+GC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /**
5
- * @file Automatically generated by @tsed/barrels.
6
- */
7
- tslib_1.__exportStar(require("./decorators/injectContext.js"), exports);
8
- tslib_1.__exportStar(require("./domain/ContextLogger.js"), exports);
9
- tslib_1.__exportStar(require("./domain/DIContext.js"), exports);
10
- tslib_1.__exportStar(require("./interfaces/AlterRunInContext.js"), exports);
11
- tslib_1.__exportStar(require("./services/DILogger.js"), exports);
12
- tslib_1.__exportStar(require("./services/DITest.js"), exports);
13
- tslib_1.__exportStar(require("./utils/asyncHookContext.js"), exports);
14
- tslib_1.__exportStar(require("./utils/attachLogger.js"), exports);
15
- tslib_1.__exportStar(require("./utils/setLoggerConfiguration.js"), exports);
16
- tslib_1.__exportStar(require("./utils/setLoggerFormat.js"), exports);
17
- tslib_1.__exportStar(require("./utils/setLoggerLevel.js"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,wEAA8C;AAC9C,oEAA0C;AAC1C,gEAAsC;AACtC,4EAAkD;AAClD,iEAAuC;AACvC,+DAAqC;AACrC,sEAA4C;AAC5C,kEAAwC;AACxC,4EAAkD;AAClD,qEAA2C;AAC3C,oEAA0C"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=AlterRunInContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AlterRunInContext.js","sourceRoot":"","sources":["../../../../src/node/interfaces/AlterRunInContext.ts"],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const logger_1 = require("@tsed/logger");
4
- const index_js_1 = require("../../common/index.js");
5
- (0, index_js_1.registerProvider)({
6
- provide: logger_1.Logger,
7
- deps: [index_js_1.InjectorService],
8
- useFactory(injector) {
9
- return injector.logger;
10
- }
11
- });
12
- //# sourceMappingURL=DILogger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DILogger.js","sourceRoot":"","sources":["../../../../src/node/services/DILogger.ts"],"names":[],"mappings":";;AAAA,yCAAoC;AACpC,oDAAwE;AAExE,IAAA,2BAAgB,EAAC;IACf,OAAO,EAAE,eAAM;IACf,IAAI,EAAE,CAAC,0BAAe,CAAC;IACvB,UAAU,CAAC,QAAyB;QAClC,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;CACF,CAAC,CAAC"}
@@ -1,126 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DITest = void 0;
4
- const core_1 = require("@tsed/core");
5
- const logger_1 = require("@tsed/logger");
6
- const index_js_1 = require("../../common/index.js");
7
- const DIContext_js_1 = require("../domain/DIContext.js");
8
- const setLoggerConfiguration_js_1 = require("../utils/setLoggerConfiguration.js");
9
- /**
10
- * Tool to run test with lightweight DI sandbox.
11
- */
12
- class DITest {
13
- static { this.options = {}; }
14
- static { this._injector = null; }
15
- static get injector() {
16
- if (DITest._injector) {
17
- return DITest._injector;
18
- }
19
- /* istanbul ignore next */
20
- throw new Error("PlatformTest.injector is not initialized. Use PlatformTest.create(): Promise before PlatformTest.invoke() or PlatformTest.injector.\n" +
21
- "Example:\n" +
22
- "before(async () => {\n" +
23
- " await PlatformTest.create()\n" +
24
- " await PlatformTest.invoke(MyService, [])\n" +
25
- "})");
26
- }
27
- static set injector(injector) {
28
- DITest._injector = injector;
29
- }
30
- static set(key, value) {
31
- (0, core_1.setValue)(DITest.options, key, value);
32
- }
33
- static hasInjector() {
34
- return !!DITest._injector;
35
- }
36
- static async create(settings = {}) {
37
- settings = {
38
- ...DITest.options,
39
- ...settings
40
- };
41
- DITest.injector = DITest.createInjector(settings);
42
- await DITest.createContainer();
43
- }
44
- static async createContainer() {
45
- await DITest.injector.load((0, index_js_1.createContainer)());
46
- }
47
- /**
48
- * Create a new injector with the right default services
49
- */
50
- static createInjector(settings = {}) {
51
- const injector = new index_js_1.InjectorService();
52
- injector.logger = logger_1.$log;
53
- // @ts-ignore
54
- injector.settings.set(DITest.configure(settings));
55
- (0, setLoggerConfiguration_js_1.setLoggerConfiguration)(injector);
56
- return injector;
57
- }
58
- /**
59
- * Resets the test injector of the test context, so it won't pollute your next test. Call this in your `tearDown` logic.
60
- */
61
- static async reset() {
62
- if (DITest.hasInjector()) {
63
- await DITest.injector.destroy();
64
- index_js_1.InjectorService.unsetLocals();
65
- DITest._injector = null;
66
- }
67
- }
68
- /**
69
- * Invoke a provider and return a fresh instance
70
- * @param target
71
- * @param providers
72
- */
73
- static async invoke(target, providers = []) {
74
- const locals = index_js_1.InjectorService.getLocals();
75
- providers.forEach((p) => {
76
- locals.set(p.token, p.use);
77
- });
78
- locals.set(index_js_1.InjectorService, DITest.injector);
79
- const instance = DITest.injector.invoke(target, locals, { rebuild: true });
80
- if ((0, core_1.isObject)(instance) && "$onInit" in instance) {
81
- const result = instance.$onInit();
82
- if (result instanceof Promise) {
83
- return result
84
- .then(() => {
85
- return;
86
- })
87
- .then(() => instance);
88
- }
89
- }
90
- if ((0, core_1.isClass)(instance)) {
91
- const keys = instance[index_js_1.DI_INJECTABLE_PROPS];
92
- if (keys) {
93
- await Promise.all([...keys.keys()].map((key) => instance[key]));
94
- }
95
- }
96
- index_js_1.InjectorService.unsetLocals();
97
- return instance;
98
- }
99
- /**
100
- * Return the instance from injector registry
101
- * @param target
102
- * @param options
103
- */
104
- static get(target, options = {}) {
105
- return DITest.injector.get(target, options);
106
- }
107
- static createDIContext() {
108
- return new DIContext_js_1.DIContext({
109
- id: "id",
110
- injector: DITest.injector,
111
- logger: DITest.injector.logger
112
- });
113
- }
114
- static configure(settings = {}) {
115
- return {
116
- ...settings,
117
- env: (0, core_1.getValue)(settings, "env", core_1.Env.TEST),
118
- logger: {
119
- ...(0, core_1.getValue)(settings, "logger", {}),
120
- level: (0, core_1.getValue)(settings, "logger.level", "off")
121
- }
122
- };
123
- }
124
- }
125
- exports.DITest = DITest;
126
- //# sourceMappingURL=DITest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DITest.js","sourceRoot":"","sources":["../../../../src/node/services/DITest.ts"],"names":[],"mappings":";;;AAAA,qCAAiF;AACjF,yCAAkC;AAClC,oDAO+B;AAC/B,yDAAiD;AACjD,kFAA0E;AAE1E;;GAEG;AACH,MAAa,MAAM;aACV,YAAO,GAAgC,EAAE,CAAC;aAChC,cAAS,GAA2B,IAAI,CAAC;IAE1D,MAAM,KAAK,QAAQ;QACjB,IAAI,MAAM,CAAC,SAAS,EAAE;YACpB,OAAO,MAAM,CAAC,SAAU,CAAC;SAC1B;QAED,0BAA0B;QAC1B,MAAM,IAAI,KAAK,CACb,uIAAuI;YACrI,YAAY;YACZ,wBAAwB;YACxB,kCAA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C;aAClF;SACF;QAED,0BAAe,CAAC,WAAW,EAAE,CAAC;QAE9B,OAAO,QAAe,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAU,MAAqB,EAAE,UAAe,EAAE;QAC1D,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAI,MAAM,EAAE,OAAO,CAAE,CAAC;IAClD,CAAC;IAED,MAAM,CAAC,eAAe;QACpB,OAAO,IAAI,wBAAS,CAAC;YACnB,EAAE,EAAE,IAAI;YACR,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;SAC/B,CAAC,CAAC;IACL,CAAC;IAES,MAAM,CAAC,SAAS,CAAC,WAAwC,EAAE;QACnE,OAAO;YACL,GAAG,QAAQ;YACX,GAAG,EAAE,IAAA,eAAQ,EAAC,QAAQ,EAAE,KAAK,EAAE,UAAG,CAAC,IAAI,CAAC;YACxC,MAAM,EAAE;gBACN,GAAG,IAAA,eAAQ,EAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC;gBACnC,KAAK,EAAE,IAAA,eAAQ,EAAC,QAAQ,EAAE,cAAc,EAAE,KAAK,CAAC;aACjD;SACF,CAAC;IACJ,CAAC;;AA5IH,wBA6IC"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bindContext = exports.setContext = exports.runInContext = exports.getContext = exports.useContextRef = exports.getAsyncStore = void 0;
4
- const async_hooks_1 = require("async_hooks");
5
- const storage = new async_hooks_1.AsyncLocalStorage();
6
- function getAsyncStore() {
7
- return storage;
8
- }
9
- exports.getAsyncStore = getAsyncStore;
10
- function useContextRef() {
11
- return getAsyncStore().getStore();
12
- }
13
- exports.useContextRef = useContextRef;
14
- function getContext() {
15
- return useContextRef()?.current;
16
- }
17
- exports.getContext = getContext;
18
- async function runInContext(ctx, cb, injector) {
19
- const ref = useContextRef();
20
- if (ref) {
21
- ctx && setContext(ctx);
22
- return cb();
23
- }
24
- else {
25
- injector = ctx?.injector || injector;
26
- cb = (await injector?.alterAsync("$alterRunInContext", cb)) || cb;
27
- return storage.run({ current: ctx }, cb);
28
- }
29
- }
30
- exports.runInContext = runInContext;
31
- function setContext(ctx) {
32
- const ref = useContextRef();
33
- if (ref && !ref.current) {
34
- ref.current = ctx;
35
- }
36
- }
37
- exports.setContext = setContext;
38
- function bindContext(cb) {
39
- return async_hooks_1.AsyncResource.bind(cb);
40
- }
41
- exports.bindContext = bindContext;
42
- //# sourceMappingURL=asyncHookContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"asyncHookContext.js","sourceRoot":"","sources":["../../../../src/node/utils/asyncHookContext.ts"],"names":[],"mappings":";;;AAAA,6CAA6D;AAI7D,MAAM,OAAO,GAAwD,IAAI,+BAAiB,EAAE,CAAC;AAE7F,SAAgB,aAAa;IAC3B,OAAO,OAAO,CAAC;AACjB,CAAC;AAFD,sCAEC;AAED,SAAgB,aAAa;IAC3B,OAAO,aAAa,EAAE,CAAC,QAAQ,EAAE,CAAC;AACpC,CAAC;AAFD,sCAEC;AAED,SAAgB,UAAU;IACxB,OAAO,aAAa,EAAE,EAAE,OAAc,CAAC;AACzC,CAAC;AAFD,gCAEC;AAEM,KAAK,UAAU,YAAY,CAAC,GAA0B,EAAE,EAAO,EAAE,QAA0B;IAChG,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAE5B,IAAI,GAAG,EAAE;QACP,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;QACvB,OAAO,EAAE,EAAE,CAAC;KACb;SAAM;QACL,QAAQ,GAAG,GAAG,EAAE,QAAQ,IAAI,QAAQ,CAAC;QACrC,EAAE,GAAG,CAAC,MAAM,QAAQ,EAAE,UAAU,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAElE,OAAO,OAAO,CAAC,GAAG,CAAC,EAAC,OAAO,EAAE,GAAG,EAAC,EAAE,EAAE,CAAC,CAAC;KACxC;AACH,CAAC;AAZD,oCAYC;AAED,SAAgB,UAAU,CAAC,GAAc;IACvC,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAE5B,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QACvB,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC;KACnB;AACH,CAAC;AAND,gCAMC;AAED,SAAgB,WAAW,CAAC,EAAO;IACjC,OAAO,2BAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC;AAFD,kCAEC"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.attachLogger = void 0;
4
- const setLoggerConfiguration_js_1 = require("./setLoggerConfiguration.js");
5
- function attachLogger(injector, $log) {
6
- injector.logger = $log;
7
- (0, setLoggerConfiguration_js_1.setLoggerConfiguration)(injector);
8
- }
9
- exports.attachLogger = attachLogger;
10
- //# sourceMappingURL=attachLogger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachLogger.js","sourceRoot":"","sources":["../../../../src/node/utils/attachLogger.ts"],"names":[],"mappings":";;;AACA,2EAAmE;AAEnE,SAAgB,YAAY,CAAC,QAAyB,EAAE,IAAc;IACpE,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,IAAA,kDAAsB,EAAC,QAAQ,CAAC,CAAC;AACnC,CAAC;AAHD,oCAGC"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setLoggerConfiguration = void 0;
4
- const setLoggerFormat_js_1 = require("./setLoggerFormat.js");
5
- const setLoggerLevel_js_1 = require("./setLoggerLevel.js");
6
- function setLoggerConfiguration(injector) {
7
- (0, setLoggerLevel_js_1.setLoggerLevel)(injector);
8
- (0, setLoggerFormat_js_1.setLoggerFormat)(injector);
9
- }
10
- exports.setLoggerConfiguration = setLoggerConfiguration;
11
- //# sourceMappingURL=setLoggerConfiguration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setLoggerConfiguration.js","sourceRoot":"","sources":["../../../../src/node/utils/setLoggerConfiguration.ts"],"names":[],"mappings":";;;AACA,6DAAqD;AACrD,2DAAmD;AAEnD,SAAgB,sBAAsB,CAAC,QAAyB;IAC9D,IAAA,kCAAc,EAAC,QAAQ,CAAC,CAAC;IACzB,IAAA,oCAAe,EAAC,QAAQ,CAAC,CAAC;AAC5B,CAAC;AAHD,wDAGC"}
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setLoggerFormat = void 0;
4
- /**
5
- * @ignore
6
- * @param injector
7
- */
8
- function setLoggerFormat(injector) {
9
- const { level, format } = injector.settings.logger;
10
- if (level) {
11
- injector.logger.level = level;
12
- }
13
- if (format && injector.logger.appenders) {
14
- injector.logger.appenders.set("stdout", {
15
- type: "stdout",
16
- levels: ["info", "debug"],
17
- layout: {
18
- type: "pattern",
19
- pattern: format
20
- }
21
- });
22
- injector.logger.appenders.set("stderr", {
23
- levels: ["trace", "fatal", "error", "warn"],
24
- type: "stderr",
25
- layout: {
26
- type: "pattern",
27
- pattern: format
28
- }
29
- });
30
- }
31
- }
32
- exports.setLoggerFormat = setLoggerFormat;
33
- //# sourceMappingURL=setLoggerFormat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setLoggerFormat.js","sourceRoot":"","sources":["../../../../src/node/utils/setLoggerFormat.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,SAAgB,eAAe,CAAC,QAAyB;IACvD,MAAM,EAAC,KAAK,EAAE,MAAM,EAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;IAEjD,IAAI,KAAK,EAAE;QACT,QAAQ,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;KAC/B;IAED,IAAI,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE;QACvC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE;YACtC,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;YACzB,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,MAAM;aAChB;SACF,CAAC,CAAC;QAEH,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE;YACtC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC;YAC3C,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,MAAM;aAChB;SACF,CAAC,CAAC;KACJ;AACH,CAAC;AA1BD,0CA0BC"}
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setLoggerLevel = void 0;
4
- /**
5
- * @ignore
6
- * @param injector
7
- */
8
- function setLoggerLevel(injector) {
9
- const { level } = injector.settings.logger;
10
- if (level) {
11
- injector.logger.level = level;
12
- }
13
- }
14
- exports.setLoggerLevel = setLoggerLevel;
15
- //# sourceMappingURL=setLoggerLevel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setLoggerLevel.js","sourceRoot":"","sources":["../../../../src/node/utils/setLoggerLevel.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,SAAgB,cAAc,CAAC,QAAyB;IACtD,MAAM,EAAC,KAAK,EAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;IAEzC,IAAI,KAAK,EAAE;QACT,QAAQ,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;KAC/B;AACH,CAAC;AAND,wCAMC"}
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }