@nestjs/core 11.1.15 → 12.0.0-alpha.0

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 (343) hide show
  1. package/adapters/http-adapter.d.ts +5 -3
  2. package/adapters/http-adapter.js +8 -5
  3. package/adapters/index.d.ts +1 -1
  4. package/adapters/index.js +1 -4
  5. package/application-config.d.ts +7 -4
  6. package/application-config.js +20 -15
  7. package/constants.d.ts +1 -1
  8. package/constants.js +10 -13
  9. package/discovery/discoverable-meta-host-collection.d.ts +3 -3
  10. package/discovery/discoverable-meta-host-collection.js +15 -19
  11. package/discovery/discovery-module.js +9 -12
  12. package/discovery/discovery-service.d.ts +4 -4
  13. package/discovery/discovery-service.js +17 -19
  14. package/discovery/index.d.ts +2 -2
  15. package/discovery/index.js +2 -5
  16. package/errors/exception-handler.js +3 -7
  17. package/errors/exceptions/circular-dependency.exception.d.ts +1 -1
  18. package/errors/exceptions/circular-dependency.exception.js +2 -6
  19. package/errors/exceptions/index.d.ts +8 -8
  20. package/errors/exceptions/index.js +8 -11
  21. package/errors/exceptions/invalid-class-module.exception.d.ts +1 -1
  22. package/errors/exceptions/invalid-class-module.exception.js +4 -8
  23. package/errors/exceptions/invalid-class-scope.exception.d.ts +2 -2
  24. package/errors/exceptions/invalid-class-scope.exception.js +6 -10
  25. package/errors/exceptions/invalid-class.exception.d.ts +1 -1
  26. package/errors/exceptions/invalid-class.exception.js +4 -8
  27. package/errors/exceptions/invalid-exception-filter.exception.d.ts +1 -1
  28. package/errors/exceptions/invalid-exception-filter.exception.js +4 -8
  29. package/errors/exceptions/invalid-middleware-configuration.exception.d.ts +1 -1
  30. package/errors/exceptions/invalid-middleware-configuration.exception.js +4 -8
  31. package/errors/exceptions/invalid-middleware.exception.d.ts +1 -1
  32. package/errors/exceptions/invalid-middleware.exception.js +4 -8
  33. package/errors/exceptions/invalid-module.exception.d.ts +1 -1
  34. package/errors/exceptions/invalid-module.exception.js +4 -8
  35. package/errors/exceptions/runtime.exception.js +1 -5
  36. package/errors/exceptions/undefined-dependency.exception.d.ts +3 -3
  37. package/errors/exceptions/undefined-dependency.exception.js +4 -8
  38. package/errors/exceptions/undefined-forwardref.exception.d.ts +2 -2
  39. package/errors/exceptions/undefined-forwardref.exception.js +4 -8
  40. package/errors/exceptions/undefined-module.exception.d.ts +1 -1
  41. package/errors/exceptions/undefined-module.exception.js +4 -8
  42. package/errors/exceptions/unknown-dependencies.exception.d.ts +3 -3
  43. package/errors/exceptions/unknown-dependencies.exception.js +8 -8
  44. package/errors/exceptions/unknown-element.exception.d.ts +1 -1
  45. package/errors/exceptions/unknown-element.exception.js +2 -6
  46. package/errors/exceptions/unknown-export.exception.d.ts +1 -1
  47. package/errors/exceptions/unknown-export.exception.js +4 -8
  48. package/errors/exceptions/unknown-module.exception.d.ts +1 -1
  49. package/errors/exceptions/unknown-module.exception.js +2 -6
  50. package/errors/exceptions/unknown-request-mapping.exception.d.ts +1 -1
  51. package/errors/exceptions/unknown-request-mapping.exception.js +4 -8
  52. package/errors/exceptions-zone.js +6 -10
  53. package/errors/messages.d.ts +2 -2
  54. package/errors/messages.js +19 -32
  55. package/exceptions/base-exception-filter-context.d.ts +6 -7
  56. package/exceptions/base-exception-filter-context.js +13 -16
  57. package/exceptions/base-exception-filter.d.ts +4 -4
  58. package/exceptions/base-exception-filter.js +33 -23
  59. package/exceptions/exceptions-handler.d.ts +4 -4
  60. package/exceptions/exceptions-handler.js +8 -16
  61. package/exceptions/external-exception-filter-context.d.ts +8 -8
  62. package/exceptions/external-exception-filter-context.js +14 -18
  63. package/exceptions/external-exception-filter.d.ts +1 -1
  64. package/exceptions/external-exception-filter.js +4 -8
  65. package/exceptions/external-exceptions-handler.d.ts +3 -3
  66. package/exceptions/external-exceptions-handler.js +8 -16
  67. package/exceptions/index.d.ts +1 -1
  68. package/exceptions/index.js +1 -4
  69. package/guards/constants.js +1 -4
  70. package/guards/guards-consumer.d.ts +4 -3
  71. package/guards/guards-consumer.js +8 -12
  72. package/guards/guards-context-creator.d.ts +11 -10
  73. package/guards/guards-context-creator.js +18 -20
  74. package/guards/index.d.ts +3 -3
  75. package/guards/index.js +3 -6
  76. package/helpers/barrier.js +5 -5
  77. package/helpers/context-creator.d.ts +2 -2
  78. package/helpers/context-creator.js +3 -7
  79. package/helpers/context-id-factory.d.ts +1 -1
  80. package/helpers/context-id-factory.js +10 -14
  81. package/helpers/context-utils.d.ts +6 -3
  82. package/helpers/context-utils.js +7 -12
  83. package/helpers/execution-context-host.d.ts +3 -3
  84. package/helpers/execution-context-host.js +5 -6
  85. package/helpers/external-context-creator.d.ts +15 -18
  86. package/helpers/external-context-creator.js +54 -43
  87. package/helpers/external-proxy.d.ts +2 -2
  88. package/helpers/external-proxy.js +3 -7
  89. package/helpers/get-class-scope.d.ts +2 -2
  90. package/helpers/get-class-scope.js +3 -6
  91. package/helpers/handler-metadata-storage.d.ts +4 -4
  92. package/helpers/handler-metadata-storage.js +7 -15
  93. package/helpers/http-adapter-host.d.ts +1 -1
  94. package/helpers/http-adapter-host.js +6 -11
  95. package/helpers/index.d.ts +3 -3
  96. package/helpers/index.js +3 -6
  97. package/helpers/interfaces/external-handler-metadata.interface.d.ts +2 -2
  98. package/helpers/interfaces/external-handler-metadata.interface.js +1 -2
  99. package/helpers/interfaces/index.d.ts +2 -2
  100. package/helpers/interfaces/index.js +2 -5
  101. package/helpers/interfaces/params-metadata.interface.d.ts +1 -1
  102. package/helpers/interfaces/params-metadata.interface.js +1 -2
  103. package/helpers/is-durable.d.ts +1 -1
  104. package/helpers/is-durable.js +3 -6
  105. package/helpers/load-adapter.d.ts +1 -1
  106. package/helpers/load-adapter.js +4 -7
  107. package/helpers/messages.d.ts +1 -1
  108. package/helpers/messages.js +10 -20
  109. package/helpers/optional-require.d.ts +1 -1
  110. package/helpers/optional-require.js +2 -5
  111. package/helpers/rethrow.js +1 -5
  112. package/helpers/router-method-factory.d.ts +2 -2
  113. package/helpers/router-method-factory.js +20 -24
  114. package/hooks/before-app-shutdown.hook.d.ts +3 -3
  115. package/hooks/before-app-shutdown.hook.js +15 -22
  116. package/hooks/index.d.ts +5 -5
  117. package/hooks/index.js +5 -8
  118. package/hooks/on-app-bootstrap.hook.d.ts +3 -3
  119. package/hooks/on-app-bootstrap.hook.js +15 -22
  120. package/hooks/on-app-shutdown.hook.d.ts +3 -3
  121. package/hooks/on-app-shutdown.hook.js +15 -22
  122. package/hooks/on-module-destroy.hook.d.ts +3 -3
  123. package/hooks/on-module-destroy.hook.js +15 -22
  124. package/hooks/on-module-init.hook.d.ts +3 -3
  125. package/hooks/on-module-init.hook.js +15 -22
  126. package/hooks/utils/get-instances-grouped-by-hierarchy-level.d.ts +3 -0
  127. package/hooks/utils/get-instances-grouped-by-hierarchy-level.js +27 -0
  128. package/hooks/utils/get-sorted-hierarchy-levels.d.ts +1 -0
  129. package/hooks/utils/get-sorted-hierarchy-levels.js +7 -0
  130. package/index.d.ts +16 -16
  131. package/index.js +17 -26
  132. package/injector/abstract-instance-resolver.d.ts +6 -6
  133. package/injector/abstract-instance-resolver.js +7 -11
  134. package/injector/compiler.d.ts +2 -2
  135. package/injector/compiler.js +2 -5
  136. package/injector/constants.d.ts +1 -1
  137. package/injector/constants.js +2 -5
  138. package/injector/container.d.ts +13 -14
  139. package/injector/container.js +40 -40
  140. package/injector/helpers/provider-classifier.d.ts +1 -1
  141. package/injector/helpers/provider-classifier.js +5 -10
  142. package/injector/helpers/silent-logger.js +9 -16
  143. package/injector/index.d.ts +6 -6
  144. package/injector/index.js +5 -8
  145. package/injector/injector.d.ts +7 -6
  146. package/injector/injector.js +78 -78
  147. package/injector/inquirer/index.d.ts +1 -1
  148. package/injector/inquirer/index.js +1 -4
  149. package/injector/inquirer/inquirer-constants.js +1 -4
  150. package/injector/inquirer/inquirer-providers.d.ts +1 -1
  151. package/injector/inquirer/inquirer-providers.js +5 -8
  152. package/injector/instance-links-host.d.ts +3 -3
  153. package/injector/instance-links-host.js +8 -11
  154. package/injector/instance-loader.d.ts +5 -5
  155. package/injector/instance-loader.js +11 -11
  156. package/injector/instance-wrapper.d.ts +8 -5
  157. package/injector/instance-wrapper.js +93 -74
  158. package/injector/internal-core-module/index.d.ts +1 -1
  159. package/injector/internal-core-module/index.js +1 -4
  160. package/injector/internal-core-module/internal-core-module-factory.d.ts +6 -6
  161. package/injector/internal-core-module/internal-core-module-factory.js +23 -27
  162. package/injector/internal-core-module/internal-core-module.d.ts +2 -2
  163. package/injector/internal-core-module/internal-core-module.js +17 -20
  164. package/injector/internal-providers-storage.d.ts +2 -2
  165. package/injector/internal-providers-storage.js +4 -9
  166. package/injector/lazy-module-loader/lazy-module-loader-options.interface.js +1 -2
  167. package/injector/lazy-module-loader/lazy-module-loader.d.ts +8 -8
  168. package/injector/lazy-module-loader/lazy-module-loader.js +10 -9
  169. package/injector/module-ref.d.ts +7 -7
  170. package/injector/module-ref.js +19 -20
  171. package/injector/module.d.ts +5 -5
  172. package/injector/module.js +93 -79
  173. package/injector/modules-container.d.ts +1 -1
  174. package/injector/modules-container.js +5 -12
  175. package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.d.ts +2 -4
  176. package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.js +6 -9
  177. package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.d.ts +2 -3
  178. package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.js +17 -22
  179. package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.d.ts +1 -3
  180. package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.js +1 -2
  181. package/injector/settlement-signal.js +5 -7
  182. package/injector/topology-tree/topology-tree.d.ts +1 -1
  183. package/injector/topology-tree/topology-tree.js +6 -9
  184. package/injector/topology-tree/tree-node.js +4 -6
  185. package/inspector/deterministic-uuid-registry.js +2 -6
  186. package/inspector/graph-inspector.d.ts +7 -7
  187. package/inspector/graph-inspector.js +10 -12
  188. package/inspector/index.d.ts +4 -4
  189. package/inspector/index.js +4 -7
  190. package/inspector/initialize-on-preview.allowlist.d.ts +1 -1
  191. package/inspector/initialize-on-preview.allowlist.js +2 -6
  192. package/inspector/interfaces/edge.interface.d.ts +1 -1
  193. package/inspector/interfaces/edge.interface.js +1 -2
  194. package/inspector/interfaces/enhancer-metadata-cache-entry.interface.d.ts +3 -3
  195. package/inspector/interfaces/enhancer-metadata-cache-entry.interface.js +1 -2
  196. package/inspector/interfaces/entrypoint.interface.d.ts +2 -2
  197. package/inspector/interfaces/entrypoint.interface.js +1 -2
  198. package/inspector/interfaces/extras.interface.d.ts +1 -1
  199. package/inspector/interfaces/extras.interface.js +1 -2
  200. package/inspector/interfaces/node.interface.d.ts +2 -2
  201. package/inspector/interfaces/node.interface.js +1 -2
  202. package/inspector/interfaces/serialized-graph-json.interface.d.ts +6 -6
  203. package/inspector/interfaces/serialized-graph-json.interface.js +1 -2
  204. package/inspector/interfaces/serialized-graph-metadata.interface.d.ts +1 -1
  205. package/inspector/interfaces/serialized-graph-metadata.interface.js +1 -2
  206. package/inspector/noop-graph-inspector.d.ts +1 -1
  207. package/inspector/noop-graph-inspector.js +2 -5
  208. package/inspector/partial-graph.host.d.ts +2 -2
  209. package/inspector/partial-graph.host.js +2 -5
  210. package/inspector/serialized-graph.d.ts +7 -7
  211. package/inspector/serialized-graph.js +35 -40
  212. package/inspector/uuid-factory.js +8 -12
  213. package/interceptors/index.d.ts +2 -2
  214. package/interceptors/index.js +2 -5
  215. package/interceptors/interceptors-consumer.d.ts +4 -3
  216. package/interceptors/interceptors-consumer.js +13 -17
  217. package/interceptors/interceptors-context-creator.d.ts +10 -9
  218. package/interceptors/interceptors-context-creator.js +18 -20
  219. package/interfaces/index.d.ts +2 -0
  220. package/interfaces/index.js +2 -0
  221. package/interfaces/module-definition.interface.d.ts +2 -2
  222. package/interfaces/module-definition.interface.js +1 -2
  223. package/interfaces/module-override.interface.d.ts +1 -1
  224. package/interfaces/module-override.interface.js +1 -2
  225. package/internal.d.ts +38 -0
  226. package/internal.js +46 -0
  227. package/metadata-scanner.d.ts +1 -1
  228. package/metadata-scanner.js +8 -14
  229. package/middleware/builder.d.ts +4 -4
  230. package/middleware/builder.js +78 -76
  231. package/middleware/container.d.ts +4 -4
  232. package/middleware/container.js +10 -13
  233. package/middleware/index.d.ts +1 -1
  234. package/middleware/index.js +1 -4
  235. package/middleware/middleware-module.d.ts +8 -9
  236. package/middleware/middleware-module.js +47 -44
  237. package/middleware/resolver.d.ts +3 -3
  238. package/middleware/resolver.js +3 -5
  239. package/middleware/route-info-path-extractor.d.ts +2 -2
  240. package/middleware/route-info-path-extractor.js +26 -25
  241. package/middleware/routes-mapper.d.ts +4 -3
  242. package/middleware/routes-mapper.js +22 -24
  243. package/middleware/utils.d.ts +3 -2
  244. package/middleware/utils.js +34 -45
  245. package/nest-application-context.d.ts +10 -9
  246. package/nest-application-context.js +50 -47
  247. package/nest-application.d.ts +18 -10
  248. package/nest-application.js +87 -55
  249. package/nest-factory.d.ts +4 -5
  250. package/nest-factory.js +61 -68
  251. package/package.json +32 -3
  252. package/pipes/index.d.ts +3 -3
  253. package/pipes/index.js +3 -6
  254. package/pipes/params-token-factory.d.ts +2 -2
  255. package/pipes/params-token-factory.js +5 -9
  256. package/pipes/pipes-consumer.d.ts +3 -7
  257. package/pipes/pipes-consumer.js +17 -18
  258. package/pipes/pipes-context-creator.d.ts +10 -9
  259. package/pipes/pipes-context-creator.js +18 -20
  260. package/repl/assign-to-object.util.js +1 -4
  261. package/repl/constants.js +1 -4
  262. package/repl/index.d.ts +1 -1
  263. package/repl/index.js +1 -4
  264. package/repl/native-functions/debug-repl-fn.d.ts +2 -2
  265. package/repl/native-functions/debug-repl-fn.js +14 -21
  266. package/repl/native-functions/get-repl-fn.d.ts +2 -2
  267. package/repl/native-functions/get-repl-fn.js +8 -15
  268. package/repl/native-functions/help-repl-fn.d.ts +2 -2
  269. package/repl/native-functions/help-repl-fn.js +13 -20
  270. package/repl/native-functions/index.d.ts +6 -6
  271. package/repl/native-functions/index.js +6 -9
  272. package/repl/native-functions/methods-repl-fn.d.ts +2 -2
  273. package/repl/native-functions/methods-repl-fn.js +12 -19
  274. package/repl/native-functions/resolve-repl-fn.d.ts +2 -2
  275. package/repl/native-functions/resolve-repl-fn.js +7 -14
  276. package/repl/native-functions/select-relp-fn.d.ts +2 -2
  277. package/repl/native-functions/select-relp-fn.js +7 -14
  278. package/repl/repl-context.d.ts +3 -3
  279. package/repl/repl-context.js +21 -23
  280. package/repl/repl-function.d.ts +3 -3
  281. package/repl/repl-function.js +5 -7
  282. package/repl/repl-logger.js +10 -14
  283. package/repl/repl-native-commands.js +1 -4
  284. package/repl/repl.d.ts +1 -1
  285. package/repl/repl.interfaces.d.ts +2 -2
  286. package/repl/repl.interfaces.js +1 -2
  287. package/repl/repl.js +17 -20
  288. package/router/index.d.ts +3 -3
  289. package/router/index.js +3 -8
  290. package/router/interfaces/exceptions-filter.interface.d.ts +3 -3
  291. package/router/interfaces/exceptions-filter.interface.js +1 -2
  292. package/router/interfaces/exclude-route-metadata.interface.d.ts +1 -1
  293. package/router/interfaces/exclude-route-metadata.interface.js +1 -2
  294. package/router/interfaces/index.d.ts +1 -1
  295. package/router/interfaces/index.js +1 -4
  296. package/router/interfaces/resolver.interface.js +1 -2
  297. package/router/interfaces/route-params-factory.interface.d.ts +1 -1
  298. package/router/interfaces/route-params-factory.interface.js +1 -2
  299. package/router/interfaces/route-path-metadata.interface.d.ts +2 -2
  300. package/router/interfaces/route-path-metadata.interface.js +1 -2
  301. package/router/interfaces/routes.interface.d.ts +1 -1
  302. package/router/interfaces/routes.interface.js +1 -2
  303. package/router/legacy-route-converter.js +3 -7
  304. package/router/paths-explorer.d.ts +4 -5
  305. package/router/paths-explorer.js +11 -15
  306. package/router/request/index.d.ts +1 -1
  307. package/router/request/index.js +1 -5
  308. package/router/request/request-constants.js +2 -5
  309. package/router/request/request-providers.d.ts +1 -1
  310. package/router/request/request-providers.js +5 -8
  311. package/router/route-params-factory.d.ts +2 -2
  312. package/router/route-params-factory.js +15 -19
  313. package/router/route-path-factory.d.ts +4 -4
  314. package/router/route-path-factory.js +19 -22
  315. package/router/router-exception-filters.d.ts +9 -9
  316. package/router/router-exception-filters.js +15 -18
  317. package/router/router-execution-context.d.ts +17 -20
  318. package/router/router-execution-context.js +57 -49
  319. package/router/router-explorer.d.ts +14 -16
  320. package/router/router-explorer.js +55 -54
  321. package/router/router-module.d.ts +4 -4
  322. package/router/router-module.js +21 -23
  323. package/router/router-proxy.d.ts +1 -1
  324. package/router/router-proxy.js +4 -8
  325. package/router/router-response-controller.d.ts +2 -2
  326. package/router/router-response-controller.js +20 -23
  327. package/router/routes-resolver.d.ts +8 -9
  328. package/router/routes-resolver.js +36 -51
  329. package/router/sse-stream.d.ts +1 -1
  330. package/router/sse-stream.js +5 -9
  331. package/router/utils/exclude-route.util.d.ts +1 -1
  332. package/router/utils/exclude-route.util.js +7 -12
  333. package/router/utils/flatten-route-paths.util.d.ts +2 -2
  334. package/router/utils/flatten-route-paths.util.js +4 -7
  335. package/router/utils/index.d.ts +2 -2
  336. package/router/utils/index.js +2 -5
  337. package/scanner.d.ts +11 -11
  338. package/scanner.js +64 -65
  339. package/services/index.d.ts +1 -1
  340. package/services/index.js +1 -4
  341. package/services/reflector.service.d.ts +1 -1
  342. package/services/reflector.service.js +9 -13
  343. package/tsconfig.build.json +1 -9
@@ -1,23 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.callBeforeAppShutdownHook = callBeforeAppShutdownHook;
4
- const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
5
- const iterare_1 = require("iterare");
6
- const transient_instances_1 = require("../injector/helpers/transient-instances");
1
+ import { isFunction, isNil } from '@nestjs/common/internal';
2
+ import { iterate } from 'iterare';
3
+ import { getInstancesGroupedByHierarchyLevel } from './utils/get-instances-grouped-by-hierarchy-level.js';
4
+ import { getSortedHierarchyLevels } from './utils/get-sorted-hierarchy-levels.js';
7
5
  /**
8
6
  * Checks if the given instance has the `beforeApplicationShutdown` function
9
7
  *
10
8
  * @param instance The instance which should be checked
11
9
  */
12
10
  function hasBeforeApplicationShutdownHook(instance) {
13
- return (0, shared_utils_1.isFunction)(instance.beforeApplicationShutdown);
11
+ return isFunction(instance.beforeApplicationShutdown);
14
12
  }
15
13
  /**
16
14
  * Calls the given instances
17
15
  */
18
16
  function callOperator(instances, signal) {
19
- return (0, iterare_1.iterate)(instances)
20
- .filter(instance => !(0, shared_utils_1.isNil)(instance))
17
+ return iterate(instances)
18
+ .filter(instance => !isNil(instance))
21
19
  .filter(hasBeforeApplicationShutdownHook)
22
20
  .map(async (instance) => instance.beforeApplicationShutdown(signal))
23
21
  .toArray();
@@ -26,22 +24,17 @@ function callOperator(instances, signal) {
26
24
  * Calls the `beforeApplicationShutdown` function on the module and its children
27
25
  * (providers / controllers).
28
26
  *
29
- * @param module The module which will be initialized
27
+ * @param moduleRef The module which will be initialized
30
28
  * @param signal The signal which caused the shutdown
31
29
  */
32
- async function callBeforeAppShutdownHook(module, signal) {
33
- const providers = module.getNonAliasProviders();
30
+ export async function callBeforeAppShutdownHook(moduleRef, signal) {
31
+ const providers = moduleRef.getNonAliasProviders();
34
32
  const [_, moduleClassHost] = providers.shift();
35
- const instances = [
36
- ...module.controllers,
37
- ...providers,
38
- ...module.injectables,
39
- ...module.middlewares,
40
- ];
41
- const nonTransientInstances = (0, transient_instances_1.getNonTransientInstances)(instances);
42
- await Promise.all(callOperator(nonTransientInstances, signal));
43
- const transientInstances = (0, transient_instances_1.getTransientInstances)(instances);
44
- await Promise.all(callOperator(transientInstances, signal));
33
+ const groupedInstances = getInstancesGroupedByHierarchyLevel(moduleRef.controllers, moduleRef.injectables, moduleRef.middlewares, providers);
34
+ const levels = getSortedHierarchyLevels(groupedInstances, 'DESC');
35
+ for (const level of levels) {
36
+ await Promise.all(callOperator(groupedInstances.get(level), signal));
37
+ }
45
38
  const moduleClassInstance = moduleClassHost.instance;
46
39
  if (moduleClassInstance &&
47
40
  hasBeforeApplicationShutdownHook(moduleClassInstance) &&
package/hooks/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from './on-app-bootstrap.hook';
2
- export * from './on-app-shutdown.hook';
3
- export * from './on-module-destroy.hook';
4
- export * from './on-module-init.hook';
5
- export * from './before-app-shutdown.hook';
1
+ export * from './on-app-bootstrap.hook.js';
2
+ export * from './on-app-shutdown.hook.js';
3
+ export * from './on-module-destroy.hook.js';
4
+ export * from './on-module-init.hook.js';
5
+ export * from './before-app-shutdown.hook.js';
package/hooks/index.js CHANGED
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./on-app-bootstrap.hook"), exports);
5
- tslib_1.__exportStar(require("./on-app-shutdown.hook"), exports);
6
- tslib_1.__exportStar(require("./on-module-destroy.hook"), exports);
7
- tslib_1.__exportStar(require("./on-module-init.hook"), exports);
8
- tslib_1.__exportStar(require("./before-app-shutdown.hook"), exports);
1
+ export * from './on-app-bootstrap.hook.js';
2
+ export * from './on-app-shutdown.hook.js';
3
+ export * from './on-module-destroy.hook.js';
4
+ export * from './on-module-init.hook.js';
5
+ export * from './before-app-shutdown.hook.js';
@@ -1,8 +1,8 @@
1
- import { Module } from '../injector/module';
1
+ import { Module } from '../injector/module.js';
2
2
  /**
3
3
  * Calls the `onApplicationBootstrap` function on the module and its children
4
4
  * (providers / controllers).
5
5
  *
6
- * @param module The module which will be initialized
6
+ * @param moduleRef The module which will be initialized
7
7
  */
8
- export declare function callModuleBootstrapHook(module: Module): Promise<any>;
8
+ export declare function callModuleBootstrapHook(moduleRef: Module): Promise<any>;
@@ -1,23 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.callModuleBootstrapHook = callModuleBootstrapHook;
4
- const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
5
- const iterare_1 = require("iterare");
6
- const transient_instances_1 = require("../injector/helpers/transient-instances");
1
+ import { isFunction, isNil } from '@nestjs/common/internal';
2
+ import { iterate } from 'iterare';
3
+ import { getInstancesGroupedByHierarchyLevel } from './utils/get-instances-grouped-by-hierarchy-level.js';
4
+ import { getSortedHierarchyLevels } from './utils/get-sorted-hierarchy-levels.js';
7
5
  /**
8
6
  * Checks if the given instance has the `onApplicationBootstrap` function
9
7
  *
10
8
  * @param instance The instance which should be checked
11
9
  */
12
10
  function hasOnAppBootstrapHook(instance) {
13
- return (0, shared_utils_1.isFunction)(instance.onApplicationBootstrap);
11
+ return isFunction(instance.onApplicationBootstrap);
14
12
  }
15
13
  /**
16
14
  * Calls the given instances
17
15
  */
18
16
  function callOperator(instances) {
19
- return (0, iterare_1.iterate)(instances)
20
- .filter(instance => !(0, shared_utils_1.isNil)(instance))
17
+ return iterate(instances)
18
+ .filter(instance => !isNil(instance))
21
19
  .filter(hasOnAppBootstrapHook)
22
20
  .map(async (instance) => instance.onApplicationBootstrap())
23
21
  .toArray();
@@ -26,23 +24,18 @@ function callOperator(instances) {
26
24
  * Calls the `onApplicationBootstrap` function on the module and its children
27
25
  * (providers / controllers).
28
26
  *
29
- * @param module The module which will be initialized
27
+ * @param moduleRef The module which will be initialized
30
28
  */
31
- async function callModuleBootstrapHook(module) {
32
- const providers = module.getNonAliasProviders();
29
+ export async function callModuleBootstrapHook(moduleRef) {
30
+ const providers = moduleRef.getNonAliasProviders();
33
31
  // Module (class) instance is the first element of the providers array
34
32
  // Lifecycle hook has to be called once all classes are properly initialized
35
33
  const [_, moduleClassHost] = providers.shift();
36
- const instances = [
37
- ...module.controllers,
38
- ...providers,
39
- ...module.injectables,
40
- ...module.middlewares,
41
- ];
42
- const nonTransientInstances = (0, transient_instances_1.getNonTransientInstances)(instances);
43
- await Promise.all(callOperator(nonTransientInstances));
44
- const transientInstances = (0, transient_instances_1.getTransientInstances)(instances);
45
- await Promise.all(callOperator(transientInstances));
34
+ const groupedInstances = getInstancesGroupedByHierarchyLevel(moduleRef.controllers, moduleRef.injectables, moduleRef.middlewares, providers);
35
+ const levels = getSortedHierarchyLevels(groupedInstances);
36
+ for (const level of levels) {
37
+ await Promise.all(callOperator(groupedInstances.get(level)));
38
+ }
46
39
  // Call the instance itself
47
40
  const moduleClassInstance = moduleClassHost.instance;
48
41
  if (moduleClassInstance &&
@@ -1,9 +1,9 @@
1
- import { Module } from '../injector/module';
1
+ import { Module } from '../injector/module.js';
2
2
  /**
3
3
  * Calls the `onApplicationShutdown` function on the module and its children
4
4
  * (providers / controllers).
5
5
  *
6
- * @param module The module which will be initialized
6
+ * @param moduleRef The module which will be initialized
7
7
  * @param signal
8
8
  */
9
- export declare function callAppShutdownHook(module: Module, signal?: string): Promise<any>;
9
+ export declare function callAppShutdownHook(moduleRef: Module, signal?: string): Promise<any>;
@@ -1,23 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.callAppShutdownHook = callAppShutdownHook;
4
- const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
5
- const iterare_1 = require("iterare");
6
- const transient_instances_1 = require("../injector/helpers/transient-instances");
1
+ import { isFunction, isNil } from '@nestjs/common/internal';
2
+ import { iterate } from 'iterare';
3
+ import { getInstancesGroupedByHierarchyLevel } from './utils/get-instances-grouped-by-hierarchy-level.js';
4
+ import { getSortedHierarchyLevels } from './utils/get-sorted-hierarchy-levels.js';
7
5
  /**
8
6
  * Checks if the given instance has the `onApplicationShutdown` function
9
7
  *
10
8
  * @param instance The instance which should be checked
11
9
  */
12
10
  function hasOnAppShutdownHook(instance) {
13
- return (0, shared_utils_1.isFunction)(instance.onApplicationShutdown);
11
+ return isFunction(instance.onApplicationShutdown);
14
12
  }
15
13
  /**
16
14
  * Calls the given instances
17
15
  */
18
16
  function callOperator(instances, signal) {
19
- return (0, iterare_1.iterate)(instances)
20
- .filter(instance => !(0, shared_utils_1.isNil)(instance))
17
+ return iterate(instances)
18
+ .filter(instance => !isNil(instance))
21
19
  .filter(hasOnAppShutdownHook)
22
20
  .map(async (instance) => instance.onApplicationShutdown(signal))
23
21
  .toArray();
@@ -26,24 +24,19 @@ function callOperator(instances, signal) {
26
24
  * Calls the `onApplicationShutdown` function on the module and its children
27
25
  * (providers / controllers).
28
26
  *
29
- * @param module The module which will be initialized
27
+ * @param moduleRef The module which will be initialized
30
28
  * @param signal
31
29
  */
32
- async function callAppShutdownHook(module, signal) {
33
- const providers = module.getNonAliasProviders();
30
+ export async function callAppShutdownHook(moduleRef, signal) {
31
+ const providers = moduleRef.getNonAliasProviders();
34
32
  // Module (class) instance is the first element of the providers array
35
33
  // Lifecycle hook has to be called once all classes are properly initialized
36
34
  const [_, moduleClassHost] = providers.shift();
37
- const instances = [
38
- ...module.controllers,
39
- ...providers,
40
- ...module.injectables,
41
- ...module.middlewares,
42
- ];
43
- const nonTransientInstances = (0, transient_instances_1.getNonTransientInstances)(instances);
44
- await Promise.all(callOperator(nonTransientInstances, signal));
45
- const transientInstances = (0, transient_instances_1.getTransientInstances)(instances);
46
- await Promise.all(callOperator(transientInstances, signal));
35
+ const groupedInstances = getInstancesGroupedByHierarchyLevel(moduleRef.controllers, moduleRef.injectables, moduleRef.middlewares, providers);
36
+ const levels = getSortedHierarchyLevels(groupedInstances, 'DESC');
37
+ for (const level of levels) {
38
+ await Promise.all(callOperator(groupedInstances.get(level), signal));
39
+ }
47
40
  // Call the instance itself
48
41
  const moduleClassInstance = moduleClassHost.instance;
49
42
  if (moduleClassInstance &&
@@ -1,8 +1,8 @@
1
- import { Module } from '../injector/module';
1
+ import { Module } from '../injector/module.js';
2
2
  /**
3
3
  * Calls the `onModuleDestroy` function on the module and its children
4
4
  * (providers / controllers).
5
5
  *
6
- * @param module The module which will be initialized
6
+ * @param moduleRef The module which will be initialized
7
7
  */
8
- export declare function callModuleDestroyHook(module: Module): Promise<any>;
8
+ export declare function callModuleDestroyHook(moduleRef: Module): Promise<any>;
@@ -1,23 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.callModuleDestroyHook = callModuleDestroyHook;
4
- const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
5
- const iterare_1 = require("iterare");
6
- const transient_instances_1 = require("../injector/helpers/transient-instances");
1
+ import { isFunction, isNil } from '@nestjs/common/internal';
2
+ import { iterate } from 'iterare';
3
+ import { getInstancesGroupedByHierarchyLevel } from './utils/get-instances-grouped-by-hierarchy-level.js';
4
+ import { getSortedHierarchyLevels } from './utils/get-sorted-hierarchy-levels.js';
7
5
  /**
8
6
  * Returns true or false if the given instance has a `onModuleDestroy` function
9
7
  *
10
8
  * @param instance The instance which should be checked
11
9
  */
12
10
  function hasOnModuleDestroyHook(instance) {
13
- return (0, shared_utils_1.isFunction)(instance.onModuleDestroy);
11
+ return isFunction(instance.onModuleDestroy);
14
12
  }
15
13
  /**
16
14
  * Calls the given instances onModuleDestroy hook
17
15
  */
18
16
  function callOperator(instances) {
19
- return (0, iterare_1.iterate)(instances)
20
- .filter(instance => !(0, shared_utils_1.isNil)(instance))
17
+ return iterate(instances)
18
+ .filter(instance => !isNil(instance))
21
19
  .filter(hasOnModuleDestroyHook)
22
20
  .map(async (instance) => instance.onModuleDestroy())
23
21
  .toArray();
@@ -26,23 +24,18 @@ function callOperator(instances) {
26
24
  * Calls the `onModuleDestroy` function on the module and its children
27
25
  * (providers / controllers).
28
26
  *
29
- * @param module The module which will be initialized
27
+ * @param moduleRef The module which will be initialized
30
28
  */
31
- async function callModuleDestroyHook(module) {
32
- const providers = module.getNonAliasProviders();
29
+ export async function callModuleDestroyHook(moduleRef) {
30
+ const providers = moduleRef.getNonAliasProviders();
33
31
  // Module (class) instance is the first element of the providers array
34
32
  // Lifecycle hook has to be called once all classes are properly destroyed
35
33
  const [_, moduleClassHost] = providers.shift();
36
- const instances = [
37
- ...module.controllers,
38
- ...providers,
39
- ...module.injectables,
40
- ...module.middlewares,
41
- ];
42
- const nonTransientInstances = (0, transient_instances_1.getNonTransientInstances)(instances);
43
- await Promise.all(callOperator(nonTransientInstances));
44
- const transientInstances = (0, transient_instances_1.getTransientInstances)(instances);
45
- await Promise.all(callOperator(transientInstances));
34
+ const groupedInstances = getInstancesGroupedByHierarchyLevel(moduleRef.controllers, moduleRef.injectables, moduleRef.middlewares, providers);
35
+ const levels = getSortedHierarchyLevels(groupedInstances, 'DESC');
36
+ for (const level of levels) {
37
+ await Promise.all(callOperator(groupedInstances.get(level)));
38
+ }
46
39
  // Call the module instance itself
47
40
  const moduleClassInstance = moduleClassHost.instance;
48
41
  if (moduleClassInstance &&
@@ -1,8 +1,8 @@
1
- import { Module } from '../injector/module';
1
+ import { Module } from '../injector/module.js';
2
2
  /**
3
3
  * Calls the `onModuleInit` function on the module and its children
4
4
  * (providers / controllers).
5
5
  *
6
- * @param module The module which will be initialized
6
+ * @param moduleRef The module which will be initialized
7
7
  */
8
- export declare function callModuleInitHook(module: Module): Promise<void>;
8
+ export declare function callModuleInitHook(moduleRef: Module): Promise<void>;
@@ -1,23 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.callModuleInitHook = callModuleInitHook;
4
- const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
5
- const iterare_1 = require("iterare");
6
- const transient_instances_1 = require("../injector/helpers/transient-instances");
1
+ import { isFunction, isNil } from '@nestjs/common/internal';
2
+ import { iterate } from 'iterare';
3
+ import { getInstancesGroupedByHierarchyLevel } from './utils/get-instances-grouped-by-hierarchy-level.js';
4
+ import { getSortedHierarchyLevels } from './utils/get-sorted-hierarchy-levels.js';
7
5
  /**
8
6
  * Returns true or false if the given instance has a `onModuleInit` function
9
7
  *
10
8
  * @param instance The instance which should be checked
11
9
  */
12
10
  function hasOnModuleInitHook(instance) {
13
- return (0, shared_utils_1.isFunction)(instance.onModuleInit);
11
+ return isFunction(instance.onModuleInit);
14
12
  }
15
13
  /**
16
14
  * Calls the given instances
17
15
  */
18
16
  function callOperator(instances) {
19
- return (0, iterare_1.iterate)(instances)
20
- .filter(instance => !(0, shared_utils_1.isNil)(instance))
17
+ return iterate(instances)
18
+ .filter(instance => !isNil(instance))
21
19
  .filter(hasOnModuleInitHook)
22
20
  .map(async (instance) => instance.onModuleInit())
23
21
  .toArray();
@@ -26,23 +24,18 @@ function callOperator(instances) {
26
24
  * Calls the `onModuleInit` function on the module and its children
27
25
  * (providers / controllers).
28
26
  *
29
- * @param module The module which will be initialized
27
+ * @param moduleRef The module which will be initialized
30
28
  */
31
- async function callModuleInitHook(module) {
32
- const providers = module.getNonAliasProviders();
29
+ export async function callModuleInitHook(moduleRef) {
30
+ const providers = moduleRef.getNonAliasProviders();
33
31
  // Module (class) instance is the first element of the providers array
34
32
  // Lifecycle hook has to be called once all classes are properly initialized
35
33
  const [_, moduleClassHost] = providers.shift();
36
- const instances = [
37
- ...module.controllers,
38
- ...providers,
39
- ...module.injectables,
40
- ...module.middlewares,
41
- ];
42
- const nonTransientInstances = (0, transient_instances_1.getNonTransientInstances)(instances);
43
- await Promise.all(callOperator(nonTransientInstances));
44
- const transientInstances = (0, transient_instances_1.getTransientInstances)(instances);
45
- await Promise.all(callOperator(transientInstances));
34
+ const groupedInstances = getInstancesGroupedByHierarchyLevel(moduleRef.controllers, moduleRef.injectables, moduleRef.middlewares, providers);
35
+ const levels = getSortedHierarchyLevels(groupedInstances);
36
+ for (const level of levels) {
37
+ await Promise.all(callOperator(groupedInstances.get(level)));
38
+ }
46
39
  // Call the instance itself
47
40
  const moduleClassInstance = moduleClassHost.instance;
48
41
  if (moduleClassInstance &&
@@ -0,0 +1,3 @@
1
+ import { InjectionToken } from '@nestjs/common';
2
+ import { InstanceWrapper } from '../../injector/instance-wrapper.js';
3
+ export declare function getInstancesGroupedByHierarchyLevel(...collections: Array<Map<InjectionToken, InstanceWrapper> | Array<[InjectionToken, InstanceWrapper]>>): Map<number, unknown[]>;
@@ -0,0 +1,27 @@
1
+ export function getInstancesGroupedByHierarchyLevel(...collections) {
2
+ const groupedByHierarchyLevel = new Map();
3
+ for (const collection of collections) {
4
+ for (const [_, wrapper] of collection) {
5
+ if (!wrapper.isDependencyTreeStatic()) {
6
+ continue;
7
+ }
8
+ const level = wrapper.hierarchyLevel;
9
+ if (!groupedByHierarchyLevel.has(level)) {
10
+ groupedByHierarchyLevel.set(level, []);
11
+ }
12
+ const byHierarchyLevelGroup = groupedByHierarchyLevel.get(level);
13
+ if (wrapper.isTransient) {
14
+ const staticTransientInstances = wrapper
15
+ .getStaticTransientInstances()
16
+ .filter(i => !!i)
17
+ .map(i => i.instance);
18
+ byHierarchyLevelGroup.push(...staticTransientInstances);
19
+ continue;
20
+ }
21
+ if (wrapper.instance) {
22
+ byHierarchyLevelGroup.push(wrapper.instance);
23
+ }
24
+ }
25
+ }
26
+ return groupedByHierarchyLevel;
27
+ }
@@ -0,0 +1 @@
1
+ export declare function getSortedHierarchyLevels(groups: Map<number, unknown[]>, order?: 'ASC' | 'DESC'): number[];
@@ -0,0 +1,7 @@
1
+ export function getSortedHierarchyLevels(groups, order = 'ASC') {
2
+ const comparator = order === 'ASC'
3
+ ? (a, b) => a - b
4
+ : (a, b) => b - a;
5
+ const levels = Array.from(groups.keys()).sort(comparator);
6
+ return levels;
7
+ }
package/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  import 'reflect-metadata';
2
- export * from './adapters';
3
- export * from './application-config';
4
- export { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from './constants';
5
- export * from './discovery';
6
- export * from './exceptions';
7
- export * from './helpers';
8
- export * from './injector';
9
- export * from './inspector';
10
- export * from './metadata-scanner';
11
- export * from './middleware';
12
- export * from './nest-application';
13
- export * from './nest-application-context';
14
- export { NestFactory } from './nest-factory';
15
- export * from './repl';
16
- export * from './router';
17
- export * from './services';
2
+ export * from './adapters/index.js';
3
+ export * from './application-config.js';
4
+ export { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_PIPE, } from './constants.js';
5
+ export * from './discovery/index.js';
6
+ export * from './exceptions/index.js';
7
+ export * from './helpers/index.js';
8
+ export * from './injector/index.js';
9
+ export * from './inspector/index.js';
10
+ export * from './metadata-scanner.js';
11
+ export * from './middleware/index.js';
12
+ export * from './nest-application.js';
13
+ export * from './nest-application-context.js';
14
+ export { NestFactory } from './nest-factory.js';
15
+ export * from './repl/index.js';
16
+ export * from './router/index.js';
17
+ export * from './services/index.js';
package/index.js CHANGED
@@ -1,32 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NestFactory = exports.APP_PIPE = exports.APP_INTERCEPTOR = exports.APP_GUARD = exports.APP_FILTER = void 0;
4
- const tslib_1 = require("tslib");
5
1
  /*
6
2
  * Nest @core
7
3
  * Copyright(c) 2017 - 2025 Kamil Mysliwiec
8
4
  * https://nestjs.com
9
5
  * MIT Licensed
10
6
  */
11
- require("reflect-metadata");
12
- tslib_1.__exportStar(require("./adapters"), exports);
13
- tslib_1.__exportStar(require("./application-config"), exports);
14
- var constants_1 = require("./constants");
15
- Object.defineProperty(exports, "APP_FILTER", { enumerable: true, get: function () { return constants_1.APP_FILTER; } });
16
- Object.defineProperty(exports, "APP_GUARD", { enumerable: true, get: function () { return constants_1.APP_GUARD; } });
17
- Object.defineProperty(exports, "APP_INTERCEPTOR", { enumerable: true, get: function () { return constants_1.APP_INTERCEPTOR; } });
18
- Object.defineProperty(exports, "APP_PIPE", { enumerable: true, get: function () { return constants_1.APP_PIPE; } });
19
- tslib_1.__exportStar(require("./discovery"), exports);
20
- tslib_1.__exportStar(require("./exceptions"), exports);
21
- tslib_1.__exportStar(require("./helpers"), exports);
22
- tslib_1.__exportStar(require("./injector"), exports);
23
- tslib_1.__exportStar(require("./inspector"), exports);
24
- tslib_1.__exportStar(require("./metadata-scanner"), exports);
25
- tslib_1.__exportStar(require("./middleware"), exports);
26
- tslib_1.__exportStar(require("./nest-application"), exports);
27
- tslib_1.__exportStar(require("./nest-application-context"), exports);
28
- var nest_factory_1 = require("./nest-factory");
29
- Object.defineProperty(exports, "NestFactory", { enumerable: true, get: function () { return nest_factory_1.NestFactory; } });
30
- tslib_1.__exportStar(require("./repl"), exports);
31
- tslib_1.__exportStar(require("./router"), exports);
32
- tslib_1.__exportStar(require("./services"), exports);
7
+ import 'reflect-metadata';
8
+ export * from './adapters/index.js';
9
+ export * from './application-config.js';
10
+ export { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_PIPE, } from './constants.js';
11
+ export * from './discovery/index.js';
12
+ export * from './exceptions/index.js';
13
+ export * from './helpers/index.js';
14
+ export * from './injector/index.js';
15
+ export * from './inspector/index.js';
16
+ export * from './metadata-scanner.js';
17
+ export * from './middleware/index.js';
18
+ export * from './nest-application.js';
19
+ export * from './nest-application-context.js';
20
+ export { NestFactory } from './nest-factory.js';
21
+ export * from './repl/index.js';
22
+ export * from './router/index.js';
23
+ export * from './services/index.js';
@@ -1,9 +1,9 @@
1
- import { Abstract, Type } from '@nestjs/common';
2
- import { GetOrResolveOptions } from '@nestjs/common/interfaces';
3
- import { Injector } from './injector';
4
- import { InstanceLinksHost } from './instance-links-host';
5
- import { ContextId } from './instance-wrapper';
6
- import { Module } from './module';
1
+ import { type Abstract, type Type } from '@nestjs/common';
2
+ import { Injector } from './injector.js';
3
+ import { InstanceLinksHost } from './instance-links-host.js';
4
+ import { ContextId } from './instance-wrapper.js';
5
+ import { Module } from './module.js';
6
+ import type { GetOrResolveOptions } from '@nestjs/common/internal';
7
7
  export declare abstract class AbstractInstanceResolver {
8
8
  protected abstract instanceLinksHost: InstanceLinksHost;
9
9
  protected abstract injector: Injector;
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractInstanceResolver = void 0;
4
- const common_1 = require("@nestjs/common");
5
- const exceptions_1 = require("../errors/exceptions");
6
- class AbstractInstanceResolver {
1
+ import { Scope } from '@nestjs/common';
2
+ import { InvalidClassScopeException, UnknownElementException, } from '../errors/exceptions/index.js';
3
+ export class AbstractInstanceResolver {
7
4
  find(typeOrToken, options) {
8
5
  const instanceLinkOrArray = this.instanceLinksHost.get(typeOrToken, options);
9
6
  const pluckInstance = ({ wrapperRef }) => {
10
- if (wrapperRef.scope === common_1.Scope.REQUEST ||
11
- wrapperRef.scope === common_1.Scope.TRANSIENT ||
7
+ if (wrapperRef.scope === Scope.REQUEST ||
8
+ wrapperRef.scope === Scope.TRANSIENT ||
12
9
  !wrapperRef.isDependencyTreeStatic()) {
13
- throw new exceptions_1.InvalidClassScopeException(typeOrToken);
10
+ throw new InvalidClassScopeException(typeOrToken);
14
11
  }
15
12
  return wrapperRef.instance;
16
13
  };
@@ -36,7 +33,7 @@ class AbstractInstanceResolver {
36
33
  const ctorHost = wrapperRef.instance || { constructor: typeOrToken };
37
34
  const instance = await this.injector.loadPerContext(ctorHost, wrapperRef.host, collection, contextId, wrapperRef);
38
35
  if (!instance) {
39
- throw new exceptions_1.UnknownElementException();
36
+ throw new UnknownElementException();
40
37
  }
41
38
  return instance;
42
39
  };
@@ -46,4 +43,3 @@ class AbstractInstanceResolver {
46
43
  return pluckInstance(instanceLinkOrArray);
47
44
  }
48
45
  }
49
- exports.AbstractInstanceResolver = AbstractInstanceResolver;
@@ -1,5 +1,5 @@
1
- import { DynamicModule, ForwardReference, Type } from '@nestjs/common/interfaces';
2
- import { ModuleOpaqueKeyFactory } from './opaque-key-factory/interfaces/module-opaque-key-factory.interface';
1
+ import { ModuleOpaqueKeyFactory } from './opaque-key-factory/interfaces/module-opaque-key-factory.interface.js';
2
+ import type { DynamicModule, ForwardReference, Type } from '@nestjs/common';
3
3
  export interface ModuleFactory {
4
4
  type: Type<any>;
5
5
  token: string;
@@ -1,7 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModuleCompiler = void 0;
4
- class ModuleCompiler {
1
+ export class ModuleCompiler {
2
+ _moduleOpaqueKeyFactory;
5
3
  constructor(_moduleOpaqueKeyFactory) {
6
4
  this._moduleOpaqueKeyFactory = _moduleOpaqueKeyFactory;
7
5
  }
@@ -32,4 +30,3 @@ class ModuleCompiler {
32
30
  return !!moduleClsOrDynamic.module;
33
31
  }
34
32
  }
35
- exports.ModuleCompiler = ModuleCompiler;
@@ -1,3 +1,3 @@
1
- import { ContextId } from './instance-wrapper';
1
+ import { ContextId } from './instance-wrapper.js';
2
2
  export declare const CONTROLLER_ID_KEY = "CONTROLLER_ID";
3
3
  export declare const STATIC_CONTEXT: ContextId;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STATIC_CONTEXT = exports.CONTROLLER_ID_KEY = void 0;
4
- exports.CONTROLLER_ID_KEY = 'CONTROLLER_ID';
1
+ export const CONTROLLER_ID_KEY = 'CONTROLLER_ID';
5
2
  const STATIC_CONTEXT_ID = 1;
6
- exports.STATIC_CONTEXT = Object.freeze({
3
+ export const STATIC_CONTEXT = Object.freeze({
7
4
  id: STATIC_CONTEXT_ID,
8
5
  });