@depup/nestjs__core 11.1.17-depup.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.
- package/LICENSE +22 -0
- package/PACKAGE.md +1 -0
- package/README.md +25 -0
- package/Readme.md +146 -0
- package/adapters/http-adapter.d.ts +80 -0
- package/adapters/http-adapter.js +90 -0
- package/adapters/index.d.ts +1 -0
- package/adapters/index.js +4 -0
- package/application-config.d.ts +47 -0
- package/application-config.js +107 -0
- package/changes.json +5 -0
- package/constants.d.ts +14 -0
- package/constants.js +21 -0
- package/discovery/discoverable-meta-host-collection.d.ts +46 -0
- package/discovery/discoverable-meta-host-collection.js +98 -0
- package/discovery/discovery-module.d.ts +5 -0
- package/discovery/discovery-module.js +19 -0
- package/discovery/discovery-service.d.ts +76 -0
- package/discovery/discovery-service.js +98 -0
- package/discovery/index.d.ts +2 -0
- package/discovery/index.js +5 -0
- package/errors/exception-handler.d.ts +4 -0
- package/errors/exception-handler.js +11 -0
- package/errors/exceptions/circular-dependency.exception.d.ts +4 -0
- package/errors/exceptions/circular-dependency.exception.js +11 -0
- package/errors/exceptions/index.d.ts +8 -0
- package/errors/exceptions/index.js +11 -0
- package/errors/exceptions/invalid-class-module.exception.d.ts +4 -0
- package/errors/exceptions/invalid-class-module.exception.js +11 -0
- package/errors/exceptions/invalid-class-scope.exception.d.ts +5 -0
- package/errors/exceptions/invalid-class-scope.exception.js +16 -0
- package/errors/exceptions/invalid-class.exception.d.ts +4 -0
- package/errors/exceptions/invalid-class.exception.js +11 -0
- package/errors/exceptions/invalid-exception-filter.exception.d.ts +4 -0
- package/errors/exceptions/invalid-exception-filter.exception.js +11 -0
- package/errors/exceptions/invalid-middleware-configuration.exception.d.ts +4 -0
- package/errors/exceptions/invalid-middleware-configuration.exception.js +11 -0
- package/errors/exceptions/invalid-middleware.exception.d.ts +4 -0
- package/errors/exceptions/invalid-middleware.exception.js +11 -0
- package/errors/exceptions/invalid-module.exception.d.ts +4 -0
- package/errors/exceptions/invalid-module.exception.js +11 -0
- package/errors/exceptions/runtime.exception.d.ts +4 -0
- package/errors/exceptions/runtime.exception.js +12 -0
- package/errors/exceptions/undefined-dependency.exception.d.ts +6 -0
- package/errors/exceptions/undefined-dependency.exception.js +11 -0
- package/errors/exceptions/undefined-forwardref.exception.d.ts +5 -0
- package/errors/exceptions/undefined-forwardref.exception.js +11 -0
- package/errors/exceptions/undefined-module.exception.d.ts +4 -0
- package/errors/exceptions/undefined-module.exception.js +11 -0
- package/errors/exceptions/unknown-dependencies.exception.d.ts +16 -0
- package/errors/exceptions/unknown-dependencies.exception.js +15 -0
- package/errors/exceptions/unknown-element.exception.d.ts +4 -0
- package/errors/exceptions/unknown-element.exception.js +11 -0
- package/errors/exceptions/unknown-export.exception.d.ts +4 -0
- package/errors/exceptions/unknown-export.exception.js +11 -0
- package/errors/exceptions/unknown-module.exception.d.ts +4 -0
- package/errors/exceptions/unknown-module.exception.js +10 -0
- package/errors/exceptions/unknown-request-mapping.exception.d.ts +5 -0
- package/errors/exceptions/unknown-request-mapping.exception.js +11 -0
- package/errors/exceptions-zone.d.ts +5 -0
- package/errors/exceptions-zone.js +34 -0
- package/errors/messages.d.ts +17 -0
- package/errors/messages.js +174 -0
- package/exceptions/base-exception-filter-context.d.ts +14 -0
- package/exceptions/base-exception-filter-context.js +56 -0
- package/exceptions/base-exception-filter.d.ts +20 -0
- package/exceptions/base-exception-filter.js +72 -0
- package/exceptions/exceptions-handler.d.ts +10 -0
- package/exceptions/exceptions-handler.js +34 -0
- package/exceptions/external-exception-filter-context.d.ts +12 -0
- package/exceptions/external-exception-filter-context.js +42 -0
- package/exceptions/external-exception-filter.d.ts +5 -0
- package/exceptions/external-exception-filter.js +15 -0
- package/exceptions/external-exceptions-handler.d.ts +9 -0
- package/exceptions/external-exceptions-handler.js +34 -0
- package/exceptions/index.d.ts +1 -0
- package/exceptions/index.js +4 -0
- package/guards/constants.d.ts +1 -0
- package/guards/constants.js +4 -0
- package/guards/guards-consumer.d.ts +9 -0
- package/guards/guards-consumer.js +39 -0
- package/guards/guards-context-creator.d.ts +17 -0
- package/guards/guards-context-creator.js +70 -0
- package/guards/index.d.ts +3 -0
- package/guards/index.js +6 -0
- package/helpers/barrier.d.ts +30 -0
- package/helpers/barrier.js +46 -0
- package/helpers/context-creator.d.ts +10 -0
- package/helpers/context-creator.js +33 -0
- package/helpers/context-id-factory.d.ts +41 -0
- package/helpers/context-id-factory.js +67 -0
- package/helpers/context-utils.d.ts +23 -0
- package/helpers/context-utils.js +55 -0
- package/helpers/execution-context-host.d.ts +19 -0
- package/helpers/execution-context-host.js +50 -0
- package/helpers/external-context-creator.d.ts +51 -0
- package/helpers/external-context-creator.js +166 -0
- package/helpers/external-proxy.d.ts +5 -0
- package/helpers/external-proxy.js +19 -0
- package/helpers/get-class-scope.d.ts +3 -0
- package/helpers/get-class-scope.js +8 -0
- package/helpers/handler-metadata-storage.d.ts +27 -0
- package/helpers/handler-metadata-storage.js +26 -0
- package/helpers/http-adapter-host.d.ts +51 -0
- package/helpers/http-adapter-host.js +73 -0
- package/helpers/index.d.ts +3 -0
- package/helpers/index.js +6 -0
- package/helpers/interfaces/external-handler-metadata.interface.d.ts +11 -0
- package/helpers/interfaces/external-handler-metadata.interface.js +2 -0
- package/helpers/interfaces/index.d.ts +2 -0
- package/helpers/interfaces/index.js +5 -0
- package/helpers/interfaces/params-metadata.interface.d.ts +6 -0
- package/helpers/interfaces/params-metadata.interface.js +2 -0
- package/helpers/is-durable.d.ts +2 -0
- package/helpers/is-durable.js +8 -0
- package/helpers/load-adapter.d.ts +1 -0
- package/helpers/load-adapter.js +15 -0
- package/helpers/messages.d.ts +7 -0
- package/helpers/messages.js +29 -0
- package/helpers/optional-require.d.ts +1 -0
- package/helpers/optional-require.js +11 -0
- package/helpers/rethrow.d.ts +1 -0
- package/helpers/rethrow.js +7 -0
- package/helpers/router-method-factory.d.ts +23 -0
- package/helpers/router-method-factory.js +33 -0
- package/hooks/before-app-shutdown.hook.d.ts +9 -0
- package/hooks/before-app-shutdown.hook.js +51 -0
- package/hooks/index.d.ts +5 -0
- package/hooks/index.js +8 -0
- package/hooks/on-app-bootstrap.hook.d.ts +8 -0
- package/hooks/on-app-bootstrap.hook.js +53 -0
- package/hooks/on-app-shutdown.hook.d.ts +9 -0
- package/hooks/on-app-shutdown.hook.js +54 -0
- package/hooks/on-module-destroy.hook.d.ts +8 -0
- package/hooks/on-module-destroy.hook.js +53 -0
- package/hooks/on-module-init.hook.d.ts +8 -0
- package/hooks/on-module-init.hook.js +53 -0
- package/hooks/utils/get-instances-grouped-by-hierarchy-level.d.ts +3 -0
- package/hooks/utils/get-instances-grouped-by-hierarchy-level.js +27 -0
- package/hooks/utils/get-sorted-hierarchy-levels.d.ts +1 -0
- package/hooks/utils/get-sorted-hierarchy-levels.js +7 -0
- package/index.d.ts +17 -0
- package/index.js +32 -0
- package/injector/abstract-instance-resolver.d.ts +16 -0
- package/injector/abstract-instance-resolver.js +49 -0
- package/injector/compiler.d.ts +18 -0
- package/injector/compiler.js +35 -0
- package/injector/constants.d.ts +3 -0
- package/injector/constants.js +8 -0
- package/injector/container.d.ts +67 -0
- package/injector/container.js +233 -0
- package/injector/helpers/provider-classifier.d.ts +4 -0
- package/injector/helpers/provider-classifier.js +16 -0
- package/injector/helpers/silent-logger.d.ts +10 -0
- package/injector/helpers/silent-logger.js +18 -0
- package/injector/helpers/transient-instances.d.ts +12 -0
- package/injector/helpers/transient-instances.js +28 -0
- package/injector/index.d.ts +6 -0
- package/injector/index.js +8 -0
- package/injector/injector.d.ts +104 -0
- package/injector/injector.js +554 -0
- package/injector/inquirer/index.d.ts +1 -0
- package/injector/inquirer/index.js +4 -0
- package/injector/inquirer/inquirer-constants.d.ts +1 -0
- package/injector/inquirer/inquirer-constants.js +4 -0
- package/injector/inquirer/inquirer-providers.d.ts +2 -0
- package/injector/inquirer/inquirer-providers.js +11 -0
- package/injector/instance-links-host.d.ts +22 -0
- package/injector/instance-links-host.js +56 -0
- package/injector/instance-loader.d.ts +23 -0
- package/injector/instance-loader.js +88 -0
- package/injector/instance-wrapper.d.ts +99 -0
- package/injector/instance-wrapper.js +350 -0
- package/injector/internal-core-module/index.d.ts +1 -0
- package/injector/internal-core-module/index.js +4 -0
- package/injector/internal-core-module/internal-core-module-factory.d.ts +9 -0
- package/injector/internal-core-module/internal-core-module-factory.js +52 -0
- package/injector/internal-core-module/internal-core-module.d.ts +5 -0
- package/injector/internal-core-module/internal-core-module.js +40 -0
- package/injector/internal-providers-storage.d.ts +9 -0
- package/injector/internal-providers-storage.js +19 -0
- package/injector/lazy-module-loader/lazy-module-loader-options.interface.d.ts +6 -0
- package/injector/lazy-module-loader/lazy-module-loader-options.interface.js +2 -0
- package/injector/lazy-module-loader/lazy-module-loader.d.ts +20 -0
- package/injector/lazy-module-loader/lazy-module-loader.js +49 -0
- package/injector/module-ref.d.ts +106 -0
- package/injector/module-ref.js +66 -0
- package/injector/module.d.ts +82 -0
- package/injector/module.js +432 -0
- package/injector/modules-container.d.ts +27 -0
- package/injector/modules-container.js +42 -0
- package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.d.ts +15 -0
- package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.js +41 -0
- package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.d.ts +15 -0
- package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.js +83 -0
- package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.d.ts +18 -0
- package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.js +2 -0
- package/injector/settlement-signal.d.ts +37 -0
- package/injector/settlement-signal.js +55 -0
- package/injector/topology-tree/topology-tree.d.ts +8 -0
- package/injector/topology-tree/topology-tree.js +51 -0
- package/injector/topology-tree/tree-node.d.ts +14 -0
- package/injector/topology-tree/tree-node.js +54 -0
- package/inspector/deterministic-uuid-registry.d.ts +6 -0
- package/inspector/deterministic-uuid-registry.js +24 -0
- package/inspector/graph-inspector.d.ts +26 -0
- package/inspector/graph-inspector.js +166 -0
- package/inspector/index.d.ts +4 -0
- package/inspector/index.js +7 -0
- package/inspector/initialize-on-preview.allowlist.d.ts +6 -0
- package/inspector/initialize-on-preview.allowlist.js +13 -0
- package/inspector/interfaces/edge.interface.d.ts +28 -0
- package/inspector/interfaces/edge.interface.js +2 -0
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.d.ts +12 -0
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.js +2 -0
- package/inspector/interfaces/entrypoint.interface.d.ts +23 -0
- package/inspector/interfaces/entrypoint.interface.js +2 -0
- package/inspector/interfaces/extras.interface.d.ts +18 -0
- package/inspector/interfaces/extras.interface.js +2 -0
- package/inspector/interfaces/node.interface.d.ts +48 -0
- package/inspector/interfaces/node.interface.js +2 -0
- package/inspector/interfaces/serialized-graph-json.interface.d.ts +14 -0
- package/inspector/interfaces/serialized-graph-json.interface.js +2 -0
- package/inspector/interfaces/serialized-graph-metadata.interface.d.ts +10 -0
- package/inspector/interfaces/serialized-graph-metadata.interface.js +2 -0
- package/inspector/noop-graph-inspector.d.ts +2 -0
- package/inspector/noop-graph-inspector.js +8 -0
- package/inspector/partial-graph.host.d.ts +7 -0
- package/inspector/partial-graph.host.js +15 -0
- package/inspector/serialized-graph.d.ts +52 -0
- package/inspector/serialized-graph.js +124 -0
- package/inspector/uuid-factory.d.ts +9 -0
- package/inspector/uuid-factory.js +22 -0
- package/interceptors/index.d.ts +2 -0
- package/interceptors/index.js +5 -0
- package/interceptors/interceptors-consumer.d.ts +9 -0
- package/interceptors/interceptors-consumer.js +37 -0
- package/interceptors/interceptors-context-creator.d.ts +16 -0
- package/interceptors/interceptors-context-creator.js +69 -0
- package/interfaces/index.d.ts +2 -0
- package/interfaces/index.js +2 -0
- package/interfaces/module-definition.interface.d.ts +3 -0
- package/interfaces/module-definition.interface.js +2 -0
- package/interfaces/module-override.interface.d.ts +5 -0
- package/interfaces/module-override.interface.js +2 -0
- package/internal.d.ts +38 -0
- package/internal.js +46 -0
- package/metadata-scanner.d.ts +17 -0
- package/metadata-scanner.js +83 -0
- package/middleware/builder.d.ts +15 -0
- package/middleware/builder.js +91 -0
- package/middleware/container.d.ts +14 -0
- package/middleware/container.js +49 -0
- package/middleware/index.d.ts +1 -0
- package/middleware/index.js +4 -0
- package/middleware/middleware-module.d.ts +33 -0
- package/middleware/middleware-module.js +208 -0
- package/middleware/resolver.d.ts +10 -0
- package/middleware/resolver.js +18 -0
- package/middleware/route-info-path-extractor.d.ts +15 -0
- package/middleware/route-info-path-extractor.js +81 -0
- package/middleware/routes-mapper.d.ts +19 -0
- package/middleware/routes-mapper.js +117 -0
- package/middleware/utils.d.ts +8 -0
- package/middleware/utils.js +106 -0
- package/nest-application-context.d.ts +173 -0
- package/nest-application-context.js +327 -0
- package/nest-application.d.ts +64 -0
- package/nest-application.js +328 -0
- package/nest-factory.d.ts +83 -0
- package/nest-factory.js +232 -0
- package/package.json +73 -0
- package/pipes/index.d.ts +3 -0
- package/pipes/index.js +6 -0
- package/pipes/params-token-factory.d.ts +5 -0
- package/pipes/params-token-factory.js +19 -0
- package/pipes/pipes-consumer.d.ts +10 -0
- package/pipes/pipes-consumer.js +21 -0
- package/pipes/pipes-context-creator.d.ts +17 -0
- package/pipes/pipes-context-creator.js +72 -0
- package/repl/assign-to-object.util.d.ts +5 -0
- package/repl/assign-to-object.util.js +14 -0
- package/repl/constants.d.ts +1 -0
- package/repl/constants.js +4 -0
- package/repl/index.d.ts +1 -0
- package/repl/index.js +4 -0
- package/repl/native-functions/debug-repl-fn.d.ts +9 -0
- package/repl/native-functions/debug-repl-fn.js +46 -0
- package/repl/native-functions/get-repl-fn.d.ts +7 -0
- package/repl/native-functions/get-repl-fn.js +19 -0
- package/repl/native-functions/help-repl-fn.d.ts +7 -0
- package/repl/native-functions/help-repl-fn.js +29 -0
- package/repl/native-functions/index.d.ts +6 -0
- package/repl/native-functions/index.js +9 -0
- package/repl/native-functions/methods-repl-fn.d.ts +8 -0
- package/repl/native-functions/methods-repl-fn.js +28 -0
- package/repl/native-functions/resolve-repl-fn.d.ts +7 -0
- package/repl/native-functions/resolve-repl-fn.js +18 -0
- package/repl/native-functions/select-relp-fn.d.ts +7 -0
- package/repl/native-functions/select-relp-fn.js +18 -0
- package/repl/repl-context.d.ts +26 -0
- package/repl/repl-context.js +126 -0
- package/repl/repl-function.d.ts +18 -0
- package/repl/repl-function.js +19 -0
- package/repl/repl-logger.d.ts +5 -0
- package/repl/repl-logger.js +22 -0
- package/repl/repl-native-commands.d.ts +2 -0
- package/repl/repl-native-commands.js +46 -0
- package/repl/repl.d.ts +3 -0
- package/repl/repl.interfaces.d.ts +16 -0
- package/repl/repl.interfaces.js +2 -0
- package/repl/repl.js +32 -0
- package/router/index.d.ts +3 -0
- package/router/index.js +8 -0
- package/router/interfaces/exceptions-filter.interface.d.ts +6 -0
- package/router/interfaces/exceptions-filter.interface.js +2 -0
- package/router/interfaces/exclude-route-metadata.interface.d.ts +15 -0
- package/router/interfaces/exclude-route-metadata.interface.js +2 -0
- package/router/interfaces/index.d.ts +1 -0
- package/router/interfaces/index.js +4 -0
- package/router/interfaces/resolver.interface.d.ts +5 -0
- package/router/interfaces/resolver.interface.js +2 -0
- package/router/interfaces/route-params-factory.interface.d.ts +8 -0
- package/router/interfaces/route-params-factory.interface.js +2 -0
- package/router/interfaces/route-path-metadata.interface.d.ts +32 -0
- package/router/interfaces/route-path-metadata.interface.js +2 -0
- package/router/interfaces/routes.interface.d.ts +7 -0
- package/router/interfaces/routes.interface.js +2 -0
- package/router/legacy-route-converter.d.ts +16 -0
- package/router/legacy-route-converter.js +61 -0
- package/router/paths-explorer.d.ts +18 -0
- package/router/paths-explorer.js +45 -0
- package/router/request/index.d.ts +1 -0
- package/router/request/index.js +5 -0
- package/router/request/request-constants.d.ts +2 -0
- package/router/request/request-constants.js +5 -0
- package/router/request/request-providers.d.ts +2 -0
- package/router/request/request-providers.js +11 -0
- package/router/route-params-factory.d.ts +9 -0
- package/router/route-params-factory.js +41 -0
- package/router/route-path-factory.d.ts +14 -0
- package/router/route-path-factory.js +101 -0
- package/router/router-exception-filters.d.ts +14 -0
- package/router/router-exception-filters.js +40 -0
- package/router/router-execution-context.d.ts +54 -0
- package/router/router-execution-context.js +186 -0
- package/router/router-explorer.d.ts +47 -0
- package/router/router-explorer.js +234 -0
- package/router/router-module.d.ts +19 -0
- package/router/router-module.js +80 -0
- package/router/router-proxy.d.ts +6 -0
- package/router/router-proxy.js +31 -0
- package/router/router-response-controller.d.ts +28 -0
- package/router/router-response-controller.js +98 -0
- package/router/routes-resolver.d.ts +27 -0
- package/router/routes-resolver.js +129 -0
- package/router/sse-stream.d.ts +43 -0
- package/router/sse-stream.js +83 -0
- package/router/utils/exclude-route.util.d.ts +4 -0
- package/router/utils/exclude-route.util.js +19 -0
- package/router/utils/flatten-route-paths.util.d.ts +6 -0
- package/router/utils/flatten-route-paths.util.js +25 -0
- package/router/utils/index.d.ts +2 -0
- package/router/utils/index.js +5 -0
- package/scanner.d.ts +89 -0
- package/scanner.js +416 -0
- package/services/index.d.ts +1 -0
- package/services/index.js +4 -0
- package/services/reflector.service.d.ts +111 -0
- package/services/reflector.service.js +100 -0
- package/tsconfig.build.json +21 -0
|
@@ -0,0 +1,51 @@
|
|
|
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");
|
|
7
|
+
/**
|
|
8
|
+
* Checks if the given instance has the `beforeApplicationShutdown` function
|
|
9
|
+
*
|
|
10
|
+
* @param instance The instance which should be checked
|
|
11
|
+
*/
|
|
12
|
+
function hasBeforeApplicationShutdownHook(instance) {
|
|
13
|
+
return (0, shared_utils_1.isFunction)(instance.beforeApplicationShutdown);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Calls the given instances
|
|
17
|
+
*/
|
|
18
|
+
function callOperator(instances, signal) {
|
|
19
|
+
return (0, iterare_1.iterate)(instances)
|
|
20
|
+
.filter(instance => !(0, shared_utils_1.isNil)(instance))
|
|
21
|
+
.filter(hasBeforeApplicationShutdownHook)
|
|
22
|
+
.map(async (instance) => instance.beforeApplicationShutdown(signal))
|
|
23
|
+
.toArray();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Calls the `beforeApplicationShutdown` function on the module and its children
|
|
27
|
+
* (providers / controllers).
|
|
28
|
+
*
|
|
29
|
+
* @param module The module which will be initialized
|
|
30
|
+
* @param signal The signal which caused the shutdown
|
|
31
|
+
*/
|
|
32
|
+
async function callBeforeAppShutdownHook(module, signal) {
|
|
33
|
+
const providers = module.getNonAliasProviders();
|
|
34
|
+
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));
|
|
45
|
+
const moduleClassInstance = moduleClassHost.instance;
|
|
46
|
+
if (moduleClassInstance &&
|
|
47
|
+
hasBeforeApplicationShutdownHook(moduleClassInstance) &&
|
|
48
|
+
moduleClassHost.isDependencyTreeStatic()) {
|
|
49
|
+
await moduleClassInstance.beforeApplicationShutdown(signal);
|
|
50
|
+
}
|
|
51
|
+
}
|
package/hooks/index.d.ts
ADDED
package/hooks/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Module } from '../injector/module';
|
|
2
|
+
/**
|
|
3
|
+
* Calls the `onApplicationBootstrap` function on the module and its children
|
|
4
|
+
* (providers / controllers).
|
|
5
|
+
*
|
|
6
|
+
* @param module The module which will be initialized
|
|
7
|
+
*/
|
|
8
|
+
export declare function callModuleBootstrapHook(module: Module): Promise<any>;
|
|
@@ -0,0 +1,53 @@
|
|
|
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");
|
|
7
|
+
/**
|
|
8
|
+
* Checks if the given instance has the `onApplicationBootstrap` function
|
|
9
|
+
*
|
|
10
|
+
* @param instance The instance which should be checked
|
|
11
|
+
*/
|
|
12
|
+
function hasOnAppBootstrapHook(instance) {
|
|
13
|
+
return (0, shared_utils_1.isFunction)(instance.onApplicationBootstrap);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Calls the given instances
|
|
17
|
+
*/
|
|
18
|
+
function callOperator(instances) {
|
|
19
|
+
return (0, iterare_1.iterate)(instances)
|
|
20
|
+
.filter(instance => !(0, shared_utils_1.isNil)(instance))
|
|
21
|
+
.filter(hasOnAppBootstrapHook)
|
|
22
|
+
.map(async (instance) => instance.onApplicationBootstrap())
|
|
23
|
+
.toArray();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Calls the `onApplicationBootstrap` function on the module and its children
|
|
27
|
+
* (providers / controllers).
|
|
28
|
+
*
|
|
29
|
+
* @param module The module which will be initialized
|
|
30
|
+
*/
|
|
31
|
+
async function callModuleBootstrapHook(module) {
|
|
32
|
+
const providers = module.getNonAliasProviders();
|
|
33
|
+
// Module (class) instance is the first element of the providers array
|
|
34
|
+
// Lifecycle hook has to be called once all classes are properly initialized
|
|
35
|
+
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));
|
|
46
|
+
// Call the instance itself
|
|
47
|
+
const moduleClassInstance = moduleClassHost.instance;
|
|
48
|
+
if (moduleClassInstance &&
|
|
49
|
+
hasOnAppBootstrapHook(moduleClassInstance) &&
|
|
50
|
+
moduleClassHost.isDependencyTreeStatic()) {
|
|
51
|
+
await moduleClassInstance.onApplicationBootstrap();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Module } from '../injector/module';
|
|
2
|
+
/**
|
|
3
|
+
* Calls the `onApplicationShutdown` function on the module and its children
|
|
4
|
+
* (providers / controllers).
|
|
5
|
+
*
|
|
6
|
+
* @param module The module which will be initialized
|
|
7
|
+
* @param signal
|
|
8
|
+
*/
|
|
9
|
+
export declare function callAppShutdownHook(module: Module, signal?: string): Promise<any>;
|
|
@@ -0,0 +1,54 @@
|
|
|
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");
|
|
7
|
+
/**
|
|
8
|
+
* Checks if the given instance has the `onApplicationShutdown` function
|
|
9
|
+
*
|
|
10
|
+
* @param instance The instance which should be checked
|
|
11
|
+
*/
|
|
12
|
+
function hasOnAppShutdownHook(instance) {
|
|
13
|
+
return (0, shared_utils_1.isFunction)(instance.onApplicationShutdown);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Calls the given instances
|
|
17
|
+
*/
|
|
18
|
+
function callOperator(instances, signal) {
|
|
19
|
+
return (0, iterare_1.iterate)(instances)
|
|
20
|
+
.filter(instance => !(0, shared_utils_1.isNil)(instance))
|
|
21
|
+
.filter(hasOnAppShutdownHook)
|
|
22
|
+
.map(async (instance) => instance.onApplicationShutdown(signal))
|
|
23
|
+
.toArray();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Calls the `onApplicationShutdown` function on the module and its children
|
|
27
|
+
* (providers / controllers).
|
|
28
|
+
*
|
|
29
|
+
* @param module The module which will be initialized
|
|
30
|
+
* @param signal
|
|
31
|
+
*/
|
|
32
|
+
async function callAppShutdownHook(module, signal) {
|
|
33
|
+
const providers = module.getNonAliasProviders();
|
|
34
|
+
// Module (class) instance is the first element of the providers array
|
|
35
|
+
// Lifecycle hook has to be called once all classes are properly initialized
|
|
36
|
+
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));
|
|
47
|
+
// Call the instance itself
|
|
48
|
+
const moduleClassInstance = moduleClassHost.instance;
|
|
49
|
+
if (moduleClassInstance &&
|
|
50
|
+
hasOnAppShutdownHook(moduleClassInstance) &&
|
|
51
|
+
moduleClassHost.isDependencyTreeStatic()) {
|
|
52
|
+
await moduleClassInstance.onApplicationShutdown(signal);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Module } from '../injector/module';
|
|
2
|
+
/**
|
|
3
|
+
* Calls the `onModuleDestroy` function on the module and its children
|
|
4
|
+
* (providers / controllers).
|
|
5
|
+
*
|
|
6
|
+
* @param module The module which will be initialized
|
|
7
|
+
*/
|
|
8
|
+
export declare function callModuleDestroyHook(module: Module): Promise<any>;
|
|
@@ -0,0 +1,53 @@
|
|
|
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");
|
|
7
|
+
/**
|
|
8
|
+
* Returns true or false if the given instance has a `onModuleDestroy` function
|
|
9
|
+
*
|
|
10
|
+
* @param instance The instance which should be checked
|
|
11
|
+
*/
|
|
12
|
+
function hasOnModuleDestroyHook(instance) {
|
|
13
|
+
return (0, shared_utils_1.isFunction)(instance.onModuleDestroy);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Calls the given instances onModuleDestroy hook
|
|
17
|
+
*/
|
|
18
|
+
function callOperator(instances) {
|
|
19
|
+
return (0, iterare_1.iterate)(instances)
|
|
20
|
+
.filter(instance => !(0, shared_utils_1.isNil)(instance))
|
|
21
|
+
.filter(hasOnModuleDestroyHook)
|
|
22
|
+
.map(async (instance) => instance.onModuleDestroy())
|
|
23
|
+
.toArray();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Calls the `onModuleDestroy` function on the module and its children
|
|
27
|
+
* (providers / controllers).
|
|
28
|
+
*
|
|
29
|
+
* @param module The module which will be initialized
|
|
30
|
+
*/
|
|
31
|
+
async function callModuleDestroyHook(module) {
|
|
32
|
+
const providers = module.getNonAliasProviders();
|
|
33
|
+
// Module (class) instance is the first element of the providers array
|
|
34
|
+
// Lifecycle hook has to be called once all classes are properly destroyed
|
|
35
|
+
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));
|
|
46
|
+
// Call the module instance itself
|
|
47
|
+
const moduleClassInstance = moduleClassHost.instance;
|
|
48
|
+
if (moduleClassInstance &&
|
|
49
|
+
hasOnModuleDestroyHook(moduleClassInstance) &&
|
|
50
|
+
moduleClassHost.isDependencyTreeStatic()) {
|
|
51
|
+
await moduleClassInstance.onModuleDestroy();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Module } from '../injector/module';
|
|
2
|
+
/**
|
|
3
|
+
* Calls the `onModuleInit` function on the module and its children
|
|
4
|
+
* (providers / controllers).
|
|
5
|
+
*
|
|
6
|
+
* @param module The module which will be initialized
|
|
7
|
+
*/
|
|
8
|
+
export declare function callModuleInitHook(module: Module): Promise<void>;
|
|
@@ -0,0 +1,53 @@
|
|
|
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");
|
|
7
|
+
/**
|
|
8
|
+
* Returns true or false if the given instance has a `onModuleInit` function
|
|
9
|
+
*
|
|
10
|
+
* @param instance The instance which should be checked
|
|
11
|
+
*/
|
|
12
|
+
function hasOnModuleInitHook(instance) {
|
|
13
|
+
return (0, shared_utils_1.isFunction)(instance.onModuleInit);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Calls the given instances
|
|
17
|
+
*/
|
|
18
|
+
function callOperator(instances) {
|
|
19
|
+
return (0, iterare_1.iterate)(instances)
|
|
20
|
+
.filter(instance => !(0, shared_utils_1.isNil)(instance))
|
|
21
|
+
.filter(hasOnModuleInitHook)
|
|
22
|
+
.map(async (instance) => instance.onModuleInit())
|
|
23
|
+
.toArray();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Calls the `onModuleInit` function on the module and its children
|
|
27
|
+
* (providers / controllers).
|
|
28
|
+
*
|
|
29
|
+
* @param module The module which will be initialized
|
|
30
|
+
*/
|
|
31
|
+
async function callModuleInitHook(module) {
|
|
32
|
+
const providers = module.getNonAliasProviders();
|
|
33
|
+
// Module (class) instance is the first element of the providers array
|
|
34
|
+
// Lifecycle hook has to be called once all classes are properly initialized
|
|
35
|
+
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));
|
|
46
|
+
// Call the instance itself
|
|
47
|
+
const moduleClassInstance = moduleClassHost.instance;
|
|
48
|
+
if (moduleClassInstance &&
|
|
49
|
+
hasOnModuleInitHook(moduleClassInstance) &&
|
|
50
|
+
moduleClassHost.isDependencyTreeStatic()) {
|
|
51
|
+
await moduleClassInstance.onModuleInit();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -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[];
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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';
|
package/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
/*
|
|
6
|
+
* Nest @core
|
|
7
|
+
* Copyright(c) 2017 - 2025 Kamil Mysliwiec
|
|
8
|
+
* https://nestjs.com
|
|
9
|
+
* MIT Licensed
|
|
10
|
+
*/
|
|
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);
|
|
@@ -0,0 +1,16 @@
|
|
|
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';
|
|
7
|
+
export declare abstract class AbstractInstanceResolver {
|
|
8
|
+
protected abstract instanceLinksHost: InstanceLinksHost;
|
|
9
|
+
protected abstract injector: Injector;
|
|
10
|
+
protected abstract get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, options?: GetOrResolveOptions): TResult | Array<TResult>;
|
|
11
|
+
protected find<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, options: {
|
|
12
|
+
moduleId?: string;
|
|
13
|
+
each?: boolean;
|
|
14
|
+
}): TResult | Array<TResult>;
|
|
15
|
+
protected resolvePerContext<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, contextModule: Module, contextId: ContextId, options?: GetOrResolveOptions): Promise<TResult | Array<TResult>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 {
|
|
7
|
+
find(typeOrToken, options) {
|
|
8
|
+
const instanceLinkOrArray = this.instanceLinksHost.get(typeOrToken, options);
|
|
9
|
+
const pluckInstance = ({ wrapperRef }) => {
|
|
10
|
+
if (wrapperRef.scope === common_1.Scope.REQUEST ||
|
|
11
|
+
wrapperRef.scope === common_1.Scope.TRANSIENT ||
|
|
12
|
+
!wrapperRef.isDependencyTreeStatic()) {
|
|
13
|
+
throw new exceptions_1.InvalidClassScopeException(typeOrToken);
|
|
14
|
+
}
|
|
15
|
+
return wrapperRef.instance;
|
|
16
|
+
};
|
|
17
|
+
if (Array.isArray(instanceLinkOrArray)) {
|
|
18
|
+
return instanceLinkOrArray.map(pluckInstance);
|
|
19
|
+
}
|
|
20
|
+
return pluckInstance(instanceLinkOrArray);
|
|
21
|
+
}
|
|
22
|
+
async resolvePerContext(typeOrToken, contextModule, contextId, options) {
|
|
23
|
+
const instanceLinkOrArray = options?.strict
|
|
24
|
+
? this.instanceLinksHost.get(typeOrToken, {
|
|
25
|
+
moduleId: contextModule.id,
|
|
26
|
+
each: options.each,
|
|
27
|
+
})
|
|
28
|
+
: this.instanceLinksHost.get(typeOrToken, {
|
|
29
|
+
each: options?.each,
|
|
30
|
+
});
|
|
31
|
+
const pluckInstance = async (instanceLink) => {
|
|
32
|
+
const { wrapperRef, collection } = instanceLink;
|
|
33
|
+
if (wrapperRef.isDependencyTreeStatic() && !wrapperRef.isTransient) {
|
|
34
|
+
return wrapperRef.instance;
|
|
35
|
+
}
|
|
36
|
+
const ctorHost = wrapperRef.instance || { constructor: typeOrToken };
|
|
37
|
+
const instance = await this.injector.loadPerContext(ctorHost, wrapperRef.host, collection, contextId, wrapperRef);
|
|
38
|
+
if (!instance) {
|
|
39
|
+
throw new exceptions_1.UnknownElementException();
|
|
40
|
+
}
|
|
41
|
+
return instance;
|
|
42
|
+
};
|
|
43
|
+
if (Array.isArray(instanceLinkOrArray)) {
|
|
44
|
+
return Promise.all(instanceLinkOrArray.map(instanceLink => pluckInstance(instanceLink)));
|
|
45
|
+
}
|
|
46
|
+
return pluckInstance(instanceLinkOrArray);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.AbstractInstanceResolver = AbstractInstanceResolver;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DynamicModule, ForwardReference, Type } from '@nestjs/common/interfaces';
|
|
2
|
+
import { ModuleOpaqueKeyFactory } from './opaque-key-factory/interfaces/module-opaque-key-factory.interface';
|
|
3
|
+
export interface ModuleFactory {
|
|
4
|
+
type: Type<any>;
|
|
5
|
+
token: string;
|
|
6
|
+
dynamicMetadata?: Partial<DynamicModule>;
|
|
7
|
+
}
|
|
8
|
+
export declare class ModuleCompiler {
|
|
9
|
+
private readonly _moduleOpaqueKeyFactory;
|
|
10
|
+
constructor(_moduleOpaqueKeyFactory: ModuleOpaqueKeyFactory);
|
|
11
|
+
get moduleOpaqueKeyFactory(): ModuleOpaqueKeyFactory;
|
|
12
|
+
compile(moduleClsOrDynamic: Type | DynamicModule | ForwardReference | Promise<DynamicModule>): Promise<ModuleFactory>;
|
|
13
|
+
extractMetadata(moduleClsOrDynamic: Type | ForwardReference | DynamicModule): {
|
|
14
|
+
type: Type;
|
|
15
|
+
dynamicMetadata: Omit<DynamicModule, 'module'> | undefined;
|
|
16
|
+
};
|
|
17
|
+
isDynamicModule(moduleClsOrDynamic: Type | DynamicModule | ForwardReference): moduleClsOrDynamic is DynamicModule;
|
|
18
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModuleCompiler = void 0;
|
|
4
|
+
class ModuleCompiler {
|
|
5
|
+
constructor(_moduleOpaqueKeyFactory) {
|
|
6
|
+
this._moduleOpaqueKeyFactory = _moduleOpaqueKeyFactory;
|
|
7
|
+
}
|
|
8
|
+
get moduleOpaqueKeyFactory() {
|
|
9
|
+
return this._moduleOpaqueKeyFactory;
|
|
10
|
+
}
|
|
11
|
+
async compile(moduleClsOrDynamic) {
|
|
12
|
+
moduleClsOrDynamic = await moduleClsOrDynamic;
|
|
13
|
+
const { type, dynamicMetadata } = this.extractMetadata(moduleClsOrDynamic);
|
|
14
|
+
const token = dynamicMetadata
|
|
15
|
+
? this._moduleOpaqueKeyFactory.createForDynamic(type, dynamicMetadata, moduleClsOrDynamic)
|
|
16
|
+
: this._moduleOpaqueKeyFactory.createForStatic(type, moduleClsOrDynamic);
|
|
17
|
+
return { type, dynamicMetadata, token };
|
|
18
|
+
}
|
|
19
|
+
extractMetadata(moduleClsOrDynamic) {
|
|
20
|
+
if (!this.isDynamicModule(moduleClsOrDynamic)) {
|
|
21
|
+
return {
|
|
22
|
+
type: moduleClsOrDynamic?.forwardRef
|
|
23
|
+
? moduleClsOrDynamic.forwardRef()
|
|
24
|
+
: moduleClsOrDynamic,
|
|
25
|
+
dynamicMetadata: undefined,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const { module: type, ...dynamicMetadata } = moduleClsOrDynamic;
|
|
29
|
+
return { type, dynamicMetadata };
|
|
30
|
+
}
|
|
31
|
+
isDynamicModule(moduleClsOrDynamic) {
|
|
32
|
+
return !!moduleClsOrDynamic.module;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.ModuleCompiler = ModuleCompiler;
|
|
@@ -0,0 +1,8 @@
|
|
|
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';
|
|
5
|
+
const STATIC_CONTEXT_ID = 1;
|
|
6
|
+
exports.STATIC_CONTEXT = Object.freeze({
|
|
7
|
+
id: STATIC_CONTEXT_ID,
|
|
8
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DynamicModule, Provider } from '@nestjs/common';
|
|
2
|
+
import { EnhancerSubtype } from '@nestjs/common/constants';
|
|
3
|
+
import { Injectable, Type } from '@nestjs/common/interfaces';
|
|
4
|
+
import { NestApplicationContextOptions } from '@nestjs/common/interfaces/nest-application-context-options.interface';
|
|
5
|
+
import { ApplicationConfig } from '../application-config';
|
|
6
|
+
import { SerializedGraph } from '../inspector/serialized-graph';
|
|
7
|
+
import { ModuleCompiler } from './compiler';
|
|
8
|
+
import { ContextId } from './instance-wrapper';
|
|
9
|
+
import { Module } from './module';
|
|
10
|
+
import { ModulesContainer } from './modules-container';
|
|
11
|
+
import { ModuleOpaqueKeyFactory } from './opaque-key-factory/interfaces/module-opaque-key-factory.interface';
|
|
12
|
+
type ModuleMetatype = Type<any> | DynamicModule | Promise<DynamicModule>;
|
|
13
|
+
type ModuleScope = Type<any>[];
|
|
14
|
+
export declare class NestContainer {
|
|
15
|
+
private readonly _applicationConfig;
|
|
16
|
+
private readonly _contextOptions;
|
|
17
|
+
private readonly globalModules;
|
|
18
|
+
private readonly modules;
|
|
19
|
+
private readonly dynamicModulesMetadata;
|
|
20
|
+
private readonly internalProvidersStorage;
|
|
21
|
+
private readonly _serializedGraph;
|
|
22
|
+
private moduleCompiler;
|
|
23
|
+
private internalCoreModule;
|
|
24
|
+
constructor(_applicationConfig?: ApplicationConfig | undefined, _contextOptions?: NestApplicationContextOptions | undefined);
|
|
25
|
+
get serializedGraph(): SerializedGraph;
|
|
26
|
+
get applicationConfig(): ApplicationConfig | undefined;
|
|
27
|
+
get contextOptions(): NestApplicationContextOptions | undefined;
|
|
28
|
+
setHttpAdapter(httpAdapter: any): void;
|
|
29
|
+
getHttpAdapterRef(): import("..").AbstractHttpAdapter<any, any, any>;
|
|
30
|
+
getHttpAdapterHostRef(): import("..").HttpAdapterHost<import("..").AbstractHttpAdapter<any, any, any>>;
|
|
31
|
+
addModule(metatype: ModuleMetatype, scope: ModuleScope): Promise<{
|
|
32
|
+
moduleRef: Module;
|
|
33
|
+
inserted: boolean;
|
|
34
|
+
} | undefined>;
|
|
35
|
+
replaceModule(metatypeToReplace: ModuleMetatype, newMetatype: ModuleMetatype, scope: ModuleScope): Promise<{
|
|
36
|
+
moduleRef: Module;
|
|
37
|
+
inserted: boolean;
|
|
38
|
+
} | undefined>;
|
|
39
|
+
private setModule;
|
|
40
|
+
addDynamicMetadata(token: string, dynamicModuleMetadata: Partial<DynamicModule>, scope: Type<any>[]): Promise<void>;
|
|
41
|
+
addDynamicModules(modules: any[], scope: Type<any>[]): Promise<void>;
|
|
42
|
+
isGlobalModule(metatype: Type<any>, dynamicMetadata?: Partial<DynamicModule>): boolean;
|
|
43
|
+
addGlobalModule(module: Module): void;
|
|
44
|
+
getModules(): ModulesContainer;
|
|
45
|
+
getModuleCompiler(): ModuleCompiler;
|
|
46
|
+
getModuleByKey(moduleKey: string): Module | undefined;
|
|
47
|
+
getInternalCoreModuleRef(): Module | undefined;
|
|
48
|
+
addImport(relatedModule: Type<any> | DynamicModule, token: string): Promise<void>;
|
|
49
|
+
addProvider(provider: Provider, token: string, enhancerSubtype?: EnhancerSubtype): string | symbol | Function;
|
|
50
|
+
addInjectable(injectable: Provider, token: string, enhancerSubtype: EnhancerSubtype, host?: Type<Injectable>): string | symbol | Function | import("./instance-wrapper").InstanceWrapper<unknown>;
|
|
51
|
+
addExportedProviderOrModule(toExport: Type<any> | DynamicModule, token: string): void;
|
|
52
|
+
addController(controller: Type<any>, token: string): void;
|
|
53
|
+
clear(): void;
|
|
54
|
+
replace(toReplace: any, options: {
|
|
55
|
+
scope: any[] | null;
|
|
56
|
+
}): void;
|
|
57
|
+
bindGlobalScope(): void;
|
|
58
|
+
bindGlobalsToImports(moduleRef: Module): void;
|
|
59
|
+
bindGlobalModuleToModule(target: Module, globalModule: Module): void;
|
|
60
|
+
getDynamicMetadataByToken(token: string): Partial<DynamicModule>;
|
|
61
|
+
getDynamicMetadataByToken<K extends Exclude<keyof DynamicModule, 'global' | 'module'>>(token: string, metadataKey: K): DynamicModule[K];
|
|
62
|
+
registerCoreModuleRef(moduleRef: Module): void;
|
|
63
|
+
getModuleTokenFactory(): ModuleOpaqueKeyFactory;
|
|
64
|
+
registerRequestProvider<T = any>(request: T, contextId: ContextId): void;
|
|
65
|
+
private shouldInitOnPreview;
|
|
66
|
+
}
|
|
67
|
+
export {};
|