@nestjs/core 11.1.16 → 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.
- package/adapters/http-adapter.d.ts +5 -3
- package/adapters/http-adapter.js +8 -5
- package/adapters/index.d.ts +1 -1
- package/adapters/index.js +1 -4
- package/application-config.d.ts +7 -4
- package/application-config.js +20 -15
- package/constants.d.ts +1 -1
- package/constants.js +10 -13
- package/discovery/discoverable-meta-host-collection.d.ts +3 -3
- package/discovery/discoverable-meta-host-collection.js +15 -19
- package/discovery/discovery-module.js +9 -12
- package/discovery/discovery-service.d.ts +4 -4
- package/discovery/discovery-service.js +17 -19
- package/discovery/index.d.ts +2 -2
- package/discovery/index.js +2 -5
- package/errors/exception-handler.js +3 -7
- package/errors/exceptions/circular-dependency.exception.d.ts +1 -1
- package/errors/exceptions/circular-dependency.exception.js +2 -6
- package/errors/exceptions/index.d.ts +8 -8
- package/errors/exceptions/index.js +8 -11
- package/errors/exceptions/invalid-class-module.exception.d.ts +1 -1
- package/errors/exceptions/invalid-class-module.exception.js +4 -8
- package/errors/exceptions/invalid-class-scope.exception.d.ts +2 -2
- package/errors/exceptions/invalid-class-scope.exception.js +6 -10
- package/errors/exceptions/invalid-class.exception.d.ts +1 -1
- package/errors/exceptions/invalid-class.exception.js +4 -8
- package/errors/exceptions/invalid-exception-filter.exception.d.ts +1 -1
- package/errors/exceptions/invalid-exception-filter.exception.js +4 -8
- package/errors/exceptions/invalid-middleware-configuration.exception.d.ts +1 -1
- package/errors/exceptions/invalid-middleware-configuration.exception.js +4 -8
- package/errors/exceptions/invalid-middleware.exception.d.ts +1 -1
- package/errors/exceptions/invalid-middleware.exception.js +4 -8
- package/errors/exceptions/invalid-module.exception.d.ts +1 -1
- package/errors/exceptions/invalid-module.exception.js +4 -8
- package/errors/exceptions/runtime.exception.js +1 -5
- package/errors/exceptions/undefined-dependency.exception.d.ts +3 -3
- package/errors/exceptions/undefined-dependency.exception.js +4 -8
- package/errors/exceptions/undefined-forwardref.exception.d.ts +2 -2
- package/errors/exceptions/undefined-forwardref.exception.js +4 -8
- package/errors/exceptions/undefined-module.exception.d.ts +1 -1
- package/errors/exceptions/undefined-module.exception.js +4 -8
- package/errors/exceptions/unknown-dependencies.exception.d.ts +3 -3
- package/errors/exceptions/unknown-dependencies.exception.js +8 -8
- package/errors/exceptions/unknown-element.exception.d.ts +1 -1
- package/errors/exceptions/unknown-element.exception.js +2 -6
- package/errors/exceptions/unknown-export.exception.d.ts +1 -1
- package/errors/exceptions/unknown-export.exception.js +4 -8
- package/errors/exceptions/unknown-module.exception.d.ts +1 -1
- package/errors/exceptions/unknown-module.exception.js +2 -6
- package/errors/exceptions/unknown-request-mapping.exception.d.ts +1 -1
- package/errors/exceptions/unknown-request-mapping.exception.js +4 -8
- package/errors/exceptions-zone.js +6 -10
- package/errors/messages.d.ts +2 -2
- package/errors/messages.js +20 -36
- package/exceptions/base-exception-filter-context.d.ts +6 -7
- package/exceptions/base-exception-filter-context.js +13 -16
- package/exceptions/base-exception-filter.d.ts +4 -4
- package/exceptions/base-exception-filter.js +33 -23
- package/exceptions/exceptions-handler.d.ts +4 -4
- package/exceptions/exceptions-handler.js +8 -16
- package/exceptions/external-exception-filter-context.d.ts +8 -8
- package/exceptions/external-exception-filter-context.js +14 -18
- package/exceptions/external-exception-filter.d.ts +1 -1
- package/exceptions/external-exception-filter.js +4 -8
- package/exceptions/external-exceptions-handler.d.ts +3 -3
- package/exceptions/external-exceptions-handler.js +8 -16
- package/exceptions/index.d.ts +1 -1
- package/exceptions/index.js +1 -4
- package/guards/constants.js +1 -4
- package/guards/guards-consumer.d.ts +4 -3
- package/guards/guards-consumer.js +8 -12
- package/guards/guards-context-creator.d.ts +11 -10
- package/guards/guards-context-creator.js +18 -20
- package/guards/index.d.ts +3 -3
- package/guards/index.js +3 -6
- package/helpers/barrier.js +5 -5
- package/helpers/context-creator.d.ts +2 -2
- package/helpers/context-creator.js +3 -7
- package/helpers/context-id-factory.d.ts +1 -1
- package/helpers/context-id-factory.js +10 -14
- package/helpers/context-utils.d.ts +6 -3
- package/helpers/context-utils.js +7 -12
- package/helpers/execution-context-host.d.ts +3 -3
- package/helpers/execution-context-host.js +5 -6
- package/helpers/external-context-creator.d.ts +15 -18
- package/helpers/external-context-creator.js +54 -43
- package/helpers/external-proxy.d.ts +2 -2
- package/helpers/external-proxy.js +3 -7
- package/helpers/get-class-scope.d.ts +2 -2
- package/helpers/get-class-scope.js +3 -6
- package/helpers/handler-metadata-storage.d.ts +4 -4
- package/helpers/handler-metadata-storage.js +7 -15
- package/helpers/http-adapter-host.d.ts +1 -1
- package/helpers/http-adapter-host.js +6 -11
- package/helpers/index.d.ts +3 -3
- package/helpers/index.js +3 -6
- package/helpers/interfaces/external-handler-metadata.interface.d.ts +2 -2
- package/helpers/interfaces/external-handler-metadata.interface.js +1 -2
- package/helpers/interfaces/index.d.ts +2 -2
- package/helpers/interfaces/index.js +2 -5
- package/helpers/interfaces/params-metadata.interface.d.ts +1 -1
- package/helpers/interfaces/params-metadata.interface.js +1 -2
- package/helpers/is-durable.d.ts +1 -1
- package/helpers/is-durable.js +3 -6
- package/helpers/load-adapter.d.ts +1 -1
- package/helpers/load-adapter.js +4 -7
- package/helpers/messages.d.ts +1 -1
- package/helpers/messages.js +10 -20
- package/helpers/optional-require.d.ts +1 -1
- package/helpers/optional-require.js +2 -5
- package/helpers/rethrow.js +1 -5
- package/helpers/router-method-factory.d.ts +2 -2
- package/helpers/router-method-factory.js +20 -24
- package/hooks/before-app-shutdown.hook.d.ts +3 -3
- package/hooks/before-app-shutdown.hook.js +15 -22
- package/hooks/index.d.ts +5 -5
- package/hooks/index.js +5 -8
- package/hooks/on-app-bootstrap.hook.d.ts +3 -3
- package/hooks/on-app-bootstrap.hook.js +15 -22
- package/hooks/on-app-shutdown.hook.d.ts +3 -3
- package/hooks/on-app-shutdown.hook.js +15 -22
- package/hooks/on-module-destroy.hook.d.ts +3 -3
- package/hooks/on-module-destroy.hook.js +15 -22
- package/hooks/on-module-init.hook.d.ts +3 -3
- package/hooks/on-module-init.hook.js +15 -22
- 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 +16 -16
- package/index.js +17 -26
- package/injector/abstract-instance-resolver.d.ts +6 -6
- package/injector/abstract-instance-resolver.js +7 -11
- package/injector/compiler.d.ts +2 -2
- package/injector/compiler.js +2 -5
- package/injector/constants.d.ts +1 -1
- package/injector/constants.js +2 -5
- package/injector/container.d.ts +13 -14
- package/injector/container.js +40 -40
- package/injector/helpers/provider-classifier.d.ts +1 -1
- package/injector/helpers/provider-classifier.js +5 -10
- package/injector/helpers/silent-logger.js +9 -16
- package/injector/index.d.ts +6 -6
- package/injector/index.js +5 -8
- package/injector/injector.d.ts +7 -6
- package/injector/injector.js +78 -78
- package/injector/inquirer/index.d.ts +1 -1
- package/injector/inquirer/index.js +1 -4
- package/injector/inquirer/inquirer-constants.js +1 -4
- package/injector/inquirer/inquirer-providers.d.ts +1 -1
- package/injector/inquirer/inquirer-providers.js +5 -8
- package/injector/instance-links-host.d.ts +3 -3
- package/injector/instance-links-host.js +8 -11
- package/injector/instance-loader.d.ts +5 -5
- package/injector/instance-loader.js +11 -11
- package/injector/instance-wrapper.d.ts +8 -5
- package/injector/instance-wrapper.js +93 -74
- package/injector/internal-core-module/index.d.ts +1 -1
- package/injector/internal-core-module/index.js +1 -4
- package/injector/internal-core-module/internal-core-module-factory.d.ts +6 -6
- package/injector/internal-core-module/internal-core-module-factory.js +23 -27
- package/injector/internal-core-module/internal-core-module.d.ts +2 -2
- package/injector/internal-core-module/internal-core-module.js +17 -20
- package/injector/internal-providers-storage.d.ts +2 -2
- package/injector/internal-providers-storage.js +4 -9
- package/injector/lazy-module-loader/lazy-module-loader-options.interface.js +1 -2
- package/injector/lazy-module-loader/lazy-module-loader.d.ts +8 -8
- package/injector/lazy-module-loader/lazy-module-loader.js +10 -9
- package/injector/module-ref.d.ts +7 -7
- package/injector/module-ref.js +19 -20
- package/injector/module.d.ts +5 -5
- package/injector/module.js +93 -79
- package/injector/modules-container.d.ts +1 -1
- package/injector/modules-container.js +5 -12
- package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.d.ts +2 -4
- package/injector/opaque-key-factory/by-reference-module-opaque-key-factory.js +6 -9
- package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.d.ts +2 -3
- package/injector/opaque-key-factory/deep-hashed-module-opaque-key-factory.js +17 -22
- package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.d.ts +1 -3
- package/injector/opaque-key-factory/interfaces/module-opaque-key-factory.interface.js +1 -2
- package/injector/settlement-signal.js +5 -7
- package/injector/topology-tree/topology-tree.d.ts +1 -1
- package/injector/topology-tree/topology-tree.js +6 -9
- package/injector/topology-tree/tree-node.js +4 -6
- package/inspector/deterministic-uuid-registry.js +2 -6
- package/inspector/graph-inspector.d.ts +7 -7
- package/inspector/graph-inspector.js +10 -12
- package/inspector/index.d.ts +4 -4
- package/inspector/index.js +4 -7
- package/inspector/initialize-on-preview.allowlist.d.ts +1 -1
- package/inspector/initialize-on-preview.allowlist.js +2 -6
- package/inspector/interfaces/edge.interface.d.ts +1 -1
- package/inspector/interfaces/edge.interface.js +1 -2
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.d.ts +3 -3
- package/inspector/interfaces/enhancer-metadata-cache-entry.interface.js +1 -2
- package/inspector/interfaces/entrypoint.interface.d.ts +2 -2
- package/inspector/interfaces/entrypoint.interface.js +1 -2
- package/inspector/interfaces/extras.interface.d.ts +1 -1
- package/inspector/interfaces/extras.interface.js +1 -2
- package/inspector/interfaces/node.interface.d.ts +2 -2
- package/inspector/interfaces/node.interface.js +1 -2
- package/inspector/interfaces/serialized-graph-json.interface.d.ts +6 -6
- package/inspector/interfaces/serialized-graph-json.interface.js +1 -2
- package/inspector/interfaces/serialized-graph-metadata.interface.d.ts +1 -1
- package/inspector/interfaces/serialized-graph-metadata.interface.js +1 -2
- package/inspector/noop-graph-inspector.d.ts +1 -1
- package/inspector/noop-graph-inspector.js +2 -5
- package/inspector/partial-graph.host.d.ts +2 -2
- package/inspector/partial-graph.host.js +2 -5
- package/inspector/serialized-graph.d.ts +7 -7
- package/inspector/serialized-graph.js +35 -40
- package/inspector/uuid-factory.js +8 -12
- package/interceptors/index.d.ts +2 -2
- package/interceptors/index.js +2 -5
- package/interceptors/interceptors-consumer.d.ts +4 -3
- package/interceptors/interceptors-consumer.js +13 -17
- package/interceptors/interceptors-context-creator.d.ts +10 -9
- package/interceptors/interceptors-context-creator.js +18 -20
- package/interfaces/index.d.ts +2 -0
- package/interfaces/index.js +2 -0
- package/interfaces/module-definition.interface.d.ts +2 -2
- package/interfaces/module-definition.interface.js +1 -2
- package/interfaces/module-override.interface.d.ts +1 -1
- package/interfaces/module-override.interface.js +1 -2
- package/internal.d.ts +38 -0
- package/internal.js +46 -0
- package/metadata-scanner.d.ts +1 -1
- package/metadata-scanner.js +8 -14
- package/middleware/builder.d.ts +4 -4
- package/middleware/builder.js +78 -76
- package/middleware/container.d.ts +4 -4
- package/middleware/container.js +10 -13
- package/middleware/index.d.ts +1 -1
- package/middleware/index.js +1 -4
- package/middleware/middleware-module.d.ts +8 -9
- package/middleware/middleware-module.js +47 -44
- package/middleware/resolver.d.ts +3 -3
- package/middleware/resolver.js +3 -5
- package/middleware/route-info-path-extractor.d.ts +2 -2
- package/middleware/route-info-path-extractor.js +26 -25
- package/middleware/routes-mapper.d.ts +4 -3
- package/middleware/routes-mapper.js +22 -24
- package/middleware/utils.d.ts +3 -2
- package/middleware/utils.js +34 -45
- package/nest-application-context.d.ts +10 -9
- package/nest-application-context.js +50 -47
- package/nest-application.d.ts +18 -10
- package/nest-application.js +87 -55
- package/nest-factory.d.ts +4 -5
- package/nest-factory.js +61 -68
- package/package.json +32 -3
- package/pipes/index.d.ts +3 -3
- package/pipes/index.js +3 -6
- package/pipes/params-token-factory.d.ts +2 -2
- package/pipes/params-token-factory.js +5 -9
- package/pipes/pipes-consumer.d.ts +3 -7
- package/pipes/pipes-consumer.js +17 -18
- package/pipes/pipes-context-creator.d.ts +10 -9
- package/pipes/pipes-context-creator.js +18 -20
- package/repl/assign-to-object.util.js +1 -4
- package/repl/constants.js +1 -4
- package/repl/index.d.ts +1 -1
- package/repl/index.js +1 -4
- package/repl/native-functions/debug-repl-fn.d.ts +2 -2
- package/repl/native-functions/debug-repl-fn.js +14 -21
- package/repl/native-functions/get-repl-fn.d.ts +2 -2
- package/repl/native-functions/get-repl-fn.js +8 -15
- package/repl/native-functions/help-repl-fn.d.ts +2 -2
- package/repl/native-functions/help-repl-fn.js +13 -20
- package/repl/native-functions/index.d.ts +6 -6
- package/repl/native-functions/index.js +6 -9
- package/repl/native-functions/methods-repl-fn.d.ts +2 -2
- package/repl/native-functions/methods-repl-fn.js +12 -19
- package/repl/native-functions/resolve-repl-fn.d.ts +2 -2
- package/repl/native-functions/resolve-repl-fn.js +7 -14
- package/repl/native-functions/select-relp-fn.d.ts +2 -2
- package/repl/native-functions/select-relp-fn.js +7 -14
- package/repl/repl-context.d.ts +3 -3
- package/repl/repl-context.js +21 -23
- package/repl/repl-function.d.ts +3 -3
- package/repl/repl-function.js +5 -7
- package/repl/repl-logger.js +10 -14
- package/repl/repl-native-commands.js +1 -4
- package/repl/repl.d.ts +1 -1
- package/repl/repl.interfaces.d.ts +2 -2
- package/repl/repl.interfaces.js +1 -2
- package/repl/repl.js +17 -20
- package/router/index.d.ts +3 -3
- package/router/index.js +3 -8
- package/router/interfaces/exceptions-filter.interface.d.ts +3 -3
- package/router/interfaces/exceptions-filter.interface.js +1 -2
- package/router/interfaces/exclude-route-metadata.interface.d.ts +1 -1
- package/router/interfaces/exclude-route-metadata.interface.js +1 -2
- package/router/interfaces/index.d.ts +1 -1
- package/router/interfaces/index.js +1 -4
- package/router/interfaces/resolver.interface.js +1 -2
- package/router/interfaces/route-params-factory.interface.d.ts +1 -1
- package/router/interfaces/route-params-factory.interface.js +1 -2
- package/router/interfaces/route-path-metadata.interface.d.ts +2 -2
- package/router/interfaces/route-path-metadata.interface.js +1 -2
- package/router/interfaces/routes.interface.d.ts +1 -1
- package/router/interfaces/routes.interface.js +1 -2
- package/router/legacy-route-converter.js +3 -7
- package/router/paths-explorer.d.ts +4 -5
- package/router/paths-explorer.js +11 -15
- package/router/request/index.d.ts +1 -1
- package/router/request/index.js +1 -5
- package/router/request/request-constants.js +2 -5
- package/router/request/request-providers.d.ts +1 -1
- package/router/request/request-providers.js +5 -8
- package/router/route-params-factory.d.ts +2 -2
- package/router/route-params-factory.js +15 -19
- package/router/route-path-factory.d.ts +4 -4
- package/router/route-path-factory.js +19 -22
- package/router/router-exception-filters.d.ts +9 -9
- package/router/router-exception-filters.js +15 -18
- package/router/router-execution-context.d.ts +17 -20
- package/router/router-execution-context.js +57 -49
- package/router/router-explorer.d.ts +14 -16
- package/router/router-explorer.js +55 -54
- package/router/router-module.d.ts +4 -4
- package/router/router-module.js +21 -23
- package/router/router-proxy.d.ts +1 -1
- package/router/router-proxy.js +4 -8
- package/router/router-response-controller.d.ts +2 -2
- package/router/router-response-controller.js +20 -23
- package/router/routes-resolver.d.ts +8 -9
- package/router/routes-resolver.js +36 -51
- package/router/sse-stream.d.ts +1 -1
- package/router/sse-stream.js +5 -9
- package/router/utils/exclude-route.util.d.ts +1 -1
- package/router/utils/exclude-route.util.js +7 -12
- package/router/utils/flatten-route-paths.util.d.ts +2 -2
- package/router/utils/flatten-route-paths.util.js +4 -7
- package/router/utils/index.d.ts +2 -2
- package/router/utils/index.js +2 -5
- package/scanner.d.ts +11 -11
- package/scanner.js +64 -65
- package/services/index.d.ts +1 -1
- package/services/index.js +1 -4
- package/services/reflector.service.d.ts +1 -1
- package/services/reflector.service.js +9 -13
- package/tsconfig.build.json +1 -9
|
@@ -1,54 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { Logger, Scope, } from '@nestjs/common';
|
|
2
|
+
import { clc, isNil, isString, isUndefined, randomStringGenerator, } from '@nestjs/common/internal';
|
|
3
|
+
import { iterate } from 'iterare';
|
|
4
|
+
import { UuidFactory } from '../inspector/uuid-factory.js';
|
|
5
|
+
import { STATIC_CONTEXT } from './constants.js';
|
|
6
|
+
import { isClassProvider, isFactoryProvider, isValueProvider, } from './helpers/provider-classifier.js';
|
|
7
|
+
export const INSTANCE_METADATA_SYMBOL = Symbol.for('instance_metadata:cache');
|
|
8
|
+
export const INSTANCE_ID_SYMBOL = Symbol.for('instance_metadata:id');
|
|
9
|
+
export class InstanceWrapper {
|
|
10
|
+
name;
|
|
11
|
+
token;
|
|
12
|
+
async;
|
|
13
|
+
host;
|
|
14
|
+
isAlias = false;
|
|
15
|
+
subtype;
|
|
16
|
+
scope = Scope.DEFAULT;
|
|
17
|
+
metatype;
|
|
18
|
+
inject;
|
|
19
|
+
forwardRef;
|
|
20
|
+
durable;
|
|
21
|
+
initTime;
|
|
22
|
+
settlementSignal;
|
|
23
|
+
static logger = new Logger(InstanceWrapper.name);
|
|
24
|
+
values = new WeakMap();
|
|
25
|
+
[INSTANCE_METADATA_SYMBOL] = {};
|
|
26
|
+
[INSTANCE_ID_SYMBOL];
|
|
27
|
+
transientMap;
|
|
28
|
+
isTreeStatic;
|
|
29
|
+
isTreeDurable;
|
|
30
|
+
_hierarchyLevel = 0;
|
|
31
|
+
get hierarchyLevel() {
|
|
32
|
+
return this._hierarchyLevel;
|
|
33
|
+
}
|
|
34
|
+
set hierarchyLevel(level) {
|
|
35
|
+
this._hierarchyLevel = level;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The root inquirer reference. Present only if child instance wrapper
|
|
39
|
+
* is transient and has a parent inquirer.
|
|
40
|
+
*/
|
|
41
|
+
rootInquirer;
|
|
16
42
|
constructor(metadata = {}) {
|
|
17
|
-
this.isAlias = false;
|
|
18
|
-
this.scope = common_1.Scope.DEFAULT;
|
|
19
|
-
this.values = new WeakMap();
|
|
20
|
-
this[_a] = {};
|
|
21
43
|
this.initialize(metadata);
|
|
22
|
-
this[
|
|
23
|
-
metadata[
|
|
44
|
+
this[INSTANCE_ID_SYMBOL] =
|
|
45
|
+
metadata[INSTANCE_ID_SYMBOL] ?? this.generateUuid();
|
|
24
46
|
}
|
|
25
47
|
get id() {
|
|
26
|
-
return this[
|
|
48
|
+
return this[INSTANCE_ID_SYMBOL];
|
|
27
49
|
}
|
|
28
50
|
set instance(value) {
|
|
29
|
-
this.values.set(
|
|
51
|
+
this.values.set(STATIC_CONTEXT, { instance: value });
|
|
30
52
|
}
|
|
31
53
|
get instance() {
|
|
32
|
-
const instancePerContext = this.getInstanceByContextId(
|
|
54
|
+
const instancePerContext = this.getInstanceByContextId(STATIC_CONTEXT);
|
|
33
55
|
return instancePerContext.instance;
|
|
34
56
|
}
|
|
35
57
|
get isNotMetatype() {
|
|
36
58
|
return !this.metatype || this.isFactory;
|
|
37
59
|
}
|
|
38
60
|
get isFactory() {
|
|
39
|
-
return !!this.metatype && !
|
|
61
|
+
return !!this.metatype && !isNil(this.inject);
|
|
40
62
|
}
|
|
41
63
|
get isTransient() {
|
|
42
|
-
return this.scope ===
|
|
64
|
+
return this.scope === Scope.TRANSIENT;
|
|
43
65
|
}
|
|
44
66
|
getInstanceByContextId(contextId, inquirerId) {
|
|
45
|
-
if (this.scope ===
|
|
67
|
+
if (this.scope === Scope.TRANSIENT && inquirerId) {
|
|
46
68
|
return this.getInstanceByInquirerId(contextId, inquirerId);
|
|
47
69
|
}
|
|
48
70
|
const instancePerContext = this.values.get(contextId);
|
|
49
71
|
return instancePerContext
|
|
50
72
|
? instancePerContext
|
|
51
|
-
: contextId !==
|
|
73
|
+
: contextId !== STATIC_CONTEXT
|
|
52
74
|
? this.cloneStaticInstance(contextId)
|
|
53
75
|
: {
|
|
54
76
|
instance: null,
|
|
@@ -68,7 +90,7 @@ class InstanceWrapper {
|
|
|
68
90
|
: this.cloneTransientInstance(contextId, inquirerId);
|
|
69
91
|
}
|
|
70
92
|
setInstanceByContextId(contextId, value, inquirerId) {
|
|
71
|
-
if (this.scope ===
|
|
93
|
+
if (this.scope === Scope.TRANSIENT && inquirerId) {
|
|
72
94
|
return this.setInstanceByInquirerId(contextId, inquirerId, value);
|
|
73
95
|
}
|
|
74
96
|
this.values.set(contextId, value);
|
|
@@ -82,7 +104,7 @@ class InstanceWrapper {
|
|
|
82
104
|
collection.set(contextId, value);
|
|
83
105
|
}
|
|
84
106
|
removeInstanceByContextId(contextId, inquirerId) {
|
|
85
|
-
if (this.scope ===
|
|
107
|
+
if (this.scope === Scope.TRANSIENT && inquirerId) {
|
|
86
108
|
return this.removeInstanceByInquirerId(contextId, inquirerId);
|
|
87
109
|
}
|
|
88
110
|
this.values.delete(contextId);
|
|
@@ -95,40 +117,40 @@ class InstanceWrapper {
|
|
|
95
117
|
collection.delete(contextId);
|
|
96
118
|
}
|
|
97
119
|
addCtorMetadata(index, wrapper) {
|
|
98
|
-
if (!this[
|
|
99
|
-
this[
|
|
120
|
+
if (!this[INSTANCE_METADATA_SYMBOL].dependencies) {
|
|
121
|
+
this[INSTANCE_METADATA_SYMBOL].dependencies = [];
|
|
100
122
|
}
|
|
101
|
-
this[
|
|
123
|
+
this[INSTANCE_METADATA_SYMBOL].dependencies[index] = wrapper;
|
|
102
124
|
}
|
|
103
125
|
getCtorMetadata() {
|
|
104
|
-
return this[
|
|
126
|
+
return this[INSTANCE_METADATA_SYMBOL].dependencies;
|
|
105
127
|
}
|
|
106
128
|
addPropertiesMetadata(key, wrapper) {
|
|
107
|
-
if (!this[
|
|
108
|
-
this[
|
|
129
|
+
if (!this[INSTANCE_METADATA_SYMBOL].properties) {
|
|
130
|
+
this[INSTANCE_METADATA_SYMBOL].properties = [];
|
|
109
131
|
}
|
|
110
|
-
this[
|
|
132
|
+
this[INSTANCE_METADATA_SYMBOL].properties.push({
|
|
111
133
|
key,
|
|
112
134
|
wrapper,
|
|
113
135
|
});
|
|
114
136
|
}
|
|
115
137
|
getPropertiesMetadata() {
|
|
116
|
-
return this[
|
|
138
|
+
return this[INSTANCE_METADATA_SYMBOL].properties;
|
|
117
139
|
}
|
|
118
140
|
addEnhancerMetadata(wrapper) {
|
|
119
|
-
if (!this[
|
|
120
|
-
this[
|
|
141
|
+
if (!this[INSTANCE_METADATA_SYMBOL].enhancers) {
|
|
142
|
+
this[INSTANCE_METADATA_SYMBOL].enhancers = [];
|
|
121
143
|
}
|
|
122
|
-
this[
|
|
144
|
+
this[INSTANCE_METADATA_SYMBOL].enhancers.push(wrapper);
|
|
123
145
|
}
|
|
124
146
|
getEnhancersMetadata() {
|
|
125
|
-
return this[
|
|
147
|
+
return this[INSTANCE_METADATA_SYMBOL].enhancers;
|
|
126
148
|
}
|
|
127
149
|
isDependencyTreeDurable(lookupRegistry = []) {
|
|
128
|
-
if (!
|
|
150
|
+
if (!isUndefined(this.isTreeDurable)) {
|
|
129
151
|
return this.isTreeDurable;
|
|
130
152
|
}
|
|
131
|
-
if (this.scope ===
|
|
153
|
+
if (this.scope === Scope.REQUEST) {
|
|
132
154
|
this.isTreeDurable = this.durable === undefined ? false : this.durable;
|
|
133
155
|
if (this.isTreeDurable) {
|
|
134
156
|
this.printIntrospectedAsDurable();
|
|
@@ -148,11 +170,11 @@ class InstanceWrapper {
|
|
|
148
170
|
return this.isTreeDurable;
|
|
149
171
|
}
|
|
150
172
|
introspectDepsAttribute(callback, lookupRegistry = []) {
|
|
151
|
-
if (lookupRegistry.includes(this[
|
|
173
|
+
if (lookupRegistry.includes(this[INSTANCE_ID_SYMBOL])) {
|
|
152
174
|
return false;
|
|
153
175
|
}
|
|
154
|
-
lookupRegistry = lookupRegistry.concat(this[
|
|
155
|
-
const { dependencies, properties, enhancers } = this[
|
|
176
|
+
lookupRegistry = lookupRegistry.concat(this[INSTANCE_ID_SYMBOL]);
|
|
177
|
+
const { dependencies, properties, enhancers } = this[INSTANCE_METADATA_SYMBOL];
|
|
156
178
|
let introspectionResult = dependencies
|
|
157
179
|
? callback(dependencies, lookupRegistry)
|
|
158
180
|
: false;
|
|
@@ -168,10 +190,10 @@ class InstanceWrapper {
|
|
|
168
190
|
return enhancers ? callback(enhancers, lookupRegistry) : false;
|
|
169
191
|
}
|
|
170
192
|
isDependencyTreeStatic(lookupRegistry = []) {
|
|
171
|
-
if (!
|
|
193
|
+
if (!isUndefined(this.isTreeStatic)) {
|
|
172
194
|
return this.isTreeStatic;
|
|
173
195
|
}
|
|
174
|
-
if (this.scope ===
|
|
196
|
+
if (this.scope === Scope.REQUEST) {
|
|
175
197
|
this.isTreeStatic = false;
|
|
176
198
|
this.printIntrospectedAsRequestScoped();
|
|
177
199
|
return this.isTreeStatic;
|
|
@@ -183,7 +205,7 @@ class InstanceWrapper {
|
|
|
183
205
|
return this.isTreeStatic;
|
|
184
206
|
}
|
|
185
207
|
cloneStaticInstance(contextId) {
|
|
186
|
-
const staticInstance = this.getInstanceByContextId(
|
|
208
|
+
const staticInstance = this.getInstanceByContextId(STATIC_CONTEXT);
|
|
187
209
|
if (this.isDependencyTreeStatic()) {
|
|
188
210
|
return staticInstance;
|
|
189
211
|
}
|
|
@@ -200,7 +222,7 @@ class InstanceWrapper {
|
|
|
200
222
|
return instancePerContext;
|
|
201
223
|
}
|
|
202
224
|
cloneTransientInstance(contextId, inquirerId) {
|
|
203
|
-
const staticInstance = this.getInstanceByContextId(
|
|
225
|
+
const staticInstance = this.getInstanceByContextId(STATIC_CONTEXT);
|
|
204
226
|
const instancePerContext = {
|
|
205
227
|
...staticInstance,
|
|
206
228
|
instance: undefined,
|
|
@@ -223,24 +245,24 @@ class InstanceWrapper {
|
|
|
223
245
|
isInRequestScope(contextId, inquirer) {
|
|
224
246
|
const isDependencyTreeStatic = this.isDependencyTreeStatic();
|
|
225
247
|
return (!isDependencyTreeStatic &&
|
|
226
|
-
contextId !==
|
|
248
|
+
contextId !== STATIC_CONTEXT &&
|
|
227
249
|
(!this.isTransient || (this.isTransient && !!inquirer)));
|
|
228
250
|
}
|
|
229
251
|
isLazyTransient(contextId, inquirer) {
|
|
230
252
|
const isInquirerRequestScoped = !!(inquirer && !inquirer.isDependencyTreeStatic());
|
|
231
253
|
return (this.isDependencyTreeStatic() &&
|
|
232
|
-
contextId !==
|
|
254
|
+
contextId !== STATIC_CONTEXT &&
|
|
233
255
|
this.isTransient &&
|
|
234
256
|
isInquirerRequestScoped);
|
|
235
257
|
}
|
|
236
258
|
isExplicitlyRequested(contextId, inquirer) {
|
|
237
259
|
const isSelfRequested = inquirer === this;
|
|
238
260
|
return (this.isDependencyTreeStatic() &&
|
|
239
|
-
contextId !==
|
|
240
|
-
(isSelfRequested || !!(inquirer && inquirer.scope ===
|
|
261
|
+
contextId !== STATIC_CONTEXT &&
|
|
262
|
+
(isSelfRequested || !!(inquirer && inquirer.scope === Scope.TRANSIENT)));
|
|
241
263
|
}
|
|
242
264
|
isStatic(contextId, inquirer) {
|
|
243
|
-
if (!this.isDependencyTreeStatic() || contextId !==
|
|
265
|
+
if (!this.isDependencyTreeStatic() || contextId !== STATIC_CONTEXT) {
|
|
244
266
|
return false;
|
|
245
267
|
}
|
|
246
268
|
// Non-transient provider in static context
|
|
@@ -279,8 +301,8 @@ class InstanceWrapper {
|
|
|
279
301
|
return [];
|
|
280
302
|
}
|
|
281
303
|
const instances = [...this.transientMap.values()];
|
|
282
|
-
return
|
|
283
|
-
.map(item => item.get(
|
|
304
|
+
return iterate(instances)
|
|
305
|
+
.map(item => item.get(STATIC_CONTEXT))
|
|
284
306
|
.filter(item => {
|
|
285
307
|
// Only return items where constructor has been actually called
|
|
286
308
|
// This prevents calling lifecycle hooks on non-instantiated transient services
|
|
@@ -289,51 +311,51 @@ class InstanceWrapper {
|
|
|
289
311
|
.toArray();
|
|
290
312
|
}
|
|
291
313
|
mergeWith(provider) {
|
|
292
|
-
if (
|
|
314
|
+
if (isValueProvider(provider)) {
|
|
293
315
|
this.metatype = null;
|
|
294
316
|
this.inject = null;
|
|
295
|
-
this.scope =
|
|
296
|
-
this.setInstanceByContextId(
|
|
317
|
+
this.scope = Scope.DEFAULT;
|
|
318
|
+
this.setInstanceByContextId(STATIC_CONTEXT, {
|
|
297
319
|
instance: provider.useValue,
|
|
298
320
|
isResolved: true,
|
|
299
321
|
isPending: false,
|
|
300
322
|
});
|
|
301
323
|
}
|
|
302
|
-
else if (
|
|
324
|
+
else if (isClassProvider(provider)) {
|
|
303
325
|
this.inject = null;
|
|
304
326
|
this.metatype = provider.useClass;
|
|
305
327
|
}
|
|
306
|
-
else if (
|
|
328
|
+
else if (isFactoryProvider(provider)) {
|
|
307
329
|
this.metatype = provider.useFactory;
|
|
308
330
|
this.inject = provider.inject || [];
|
|
309
331
|
}
|
|
310
332
|
}
|
|
311
333
|
isNewable() {
|
|
312
|
-
return
|
|
334
|
+
return isNil(this.inject) && this.metatype && this.metatype.prototype;
|
|
313
335
|
}
|
|
314
336
|
initialize(metadata) {
|
|
315
337
|
const { instance, isResolved, ...wrapperPartial } = metadata;
|
|
316
338
|
Object.assign(this, wrapperPartial);
|
|
317
|
-
this.setInstanceByContextId(
|
|
339
|
+
this.setInstanceByContextId(STATIC_CONTEXT, {
|
|
318
340
|
instance: instance,
|
|
319
341
|
isResolved,
|
|
320
342
|
});
|
|
321
|
-
this.scope ===
|
|
343
|
+
this.scope === Scope.TRANSIENT && (this.transientMap = new Map());
|
|
322
344
|
}
|
|
323
345
|
printIntrospectedAsRequestScoped() {
|
|
324
346
|
if (!this.isDebugMode() || this.name === 'REQUEST') {
|
|
325
347
|
return;
|
|
326
348
|
}
|
|
327
|
-
if (
|
|
328
|
-
InstanceWrapper.logger.log(`${
|
|
349
|
+
if (isString(this.name)) {
|
|
350
|
+
InstanceWrapper.logger.log(`${clc.cyanBright(this.name)}${clc.green(' introspected as ')}${clc.magentaBright('request-scoped')}`);
|
|
329
351
|
}
|
|
330
352
|
}
|
|
331
353
|
printIntrospectedAsDurable() {
|
|
332
354
|
if (!this.isDebugMode()) {
|
|
333
355
|
return;
|
|
334
356
|
}
|
|
335
|
-
if (
|
|
336
|
-
InstanceWrapper.logger.log(`${
|
|
357
|
+
if (isString(this.name)) {
|
|
358
|
+
InstanceWrapper.logger.log(`${clc.cyanBright(this.name)}${clc.green(' introspected as ')}${clc.magentaBright('durable')}`);
|
|
337
359
|
}
|
|
338
360
|
}
|
|
339
361
|
isDebugMode() {
|
|
@@ -342,9 +364,6 @@ class InstanceWrapper {
|
|
|
342
364
|
generateUuid() {
|
|
343
365
|
let key = this.name?.toString() ?? this.token?.toString();
|
|
344
366
|
key += this.host?.name ?? '';
|
|
345
|
-
return key ?
|
|
367
|
+
return key ? UuidFactory.get(key) : randomStringGenerator();
|
|
346
368
|
}
|
|
347
369
|
}
|
|
348
|
-
exports.InstanceWrapper = InstanceWrapper;
|
|
349
|
-
_a = exports.INSTANCE_METADATA_SYMBOL;
|
|
350
|
-
InstanceWrapper.logger = new common_1.Logger(InstanceWrapper.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './internal-core-module';
|
|
1
|
+
export * from './internal-core-module.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { HttpAdapterHost } from '../../helpers/http-adapter-host';
|
|
2
|
-
import { GraphInspector } from '../../inspector/graph-inspector';
|
|
3
|
-
import { ModuleOverride } from '../../interfaces/module-override.interface';
|
|
4
|
-
import { DependenciesScanner } from '../../scanner';
|
|
5
|
-
import { ModuleCompiler } from '../compiler';
|
|
6
|
-
import { NestContainer } from '../container';
|
|
1
|
+
import { HttpAdapterHost } from '../../helpers/http-adapter-host.js';
|
|
2
|
+
import { GraphInspector } from '../../inspector/graph-inspector.js';
|
|
3
|
+
import { ModuleOverride } from '../../interfaces/module-override.interface.js';
|
|
4
|
+
import { DependenciesScanner } from '../../scanner.js';
|
|
5
|
+
import { ModuleCompiler } from '../compiler.js';
|
|
6
|
+
import { NestContainer } from '../container.js';
|
|
7
7
|
export declare class InternalCoreModuleFactory {
|
|
8
8
|
static create(container: NestContainer, scanner: DependenciesScanner, moduleCompiler: ModuleCompiler, httpAdapterHost: HttpAdapterHost, graphInspector: GraphInspector, moduleOverrides?: ModuleOverride[]): import("@nestjs/common").DynamicModule;
|
|
9
9
|
}
|
|
@@ -1,52 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const modules_container_1 = require("../modules-container");
|
|
13
|
-
const internal_core_module_1 = require("./internal-core-module");
|
|
14
|
-
class InternalCoreModuleFactory {
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { ExternalContextCreator } from '../../helpers/external-context-creator.js';
|
|
3
|
+
import { HttpAdapterHost } from '../../helpers/http-adapter-host.js';
|
|
4
|
+
import { InitializeOnPreviewAllowlist } from '../../inspector/initialize-on-preview.allowlist.js';
|
|
5
|
+
import { SerializedGraph } from '../../inspector/serialized-graph.js';
|
|
6
|
+
import { Injector } from '../injector.js';
|
|
7
|
+
import { InstanceLoader } from '../instance-loader.js';
|
|
8
|
+
import { LazyModuleLoader } from '../lazy-module-loader/lazy-module-loader.js';
|
|
9
|
+
import { ModulesContainer } from '../modules-container.js';
|
|
10
|
+
import { InternalCoreModule } from './internal-core-module.js';
|
|
11
|
+
export class InternalCoreModuleFactory {
|
|
15
12
|
static create(container, scanner, moduleCompiler, httpAdapterHost, graphInspector, moduleOverrides) {
|
|
16
13
|
const lazyModuleLoaderFactory = () => {
|
|
17
|
-
const logger = new
|
|
14
|
+
const logger = new Logger(LazyModuleLoader.name, {
|
|
18
15
|
timestamp: false,
|
|
19
16
|
});
|
|
20
|
-
const injector = new
|
|
17
|
+
const injector = new Injector({
|
|
21
18
|
preview: container.contextOptions?.preview,
|
|
22
19
|
instanceDecorator: container.contextOptions?.instrument?.instanceDecorator,
|
|
23
20
|
});
|
|
24
|
-
const instanceLoader = new
|
|
25
|
-
return new
|
|
21
|
+
const instanceLoader = new InstanceLoader(container, injector, graphInspector, logger);
|
|
22
|
+
return new LazyModuleLoader(scanner, instanceLoader, moduleCompiler, container.getModules(), moduleOverrides);
|
|
26
23
|
};
|
|
27
|
-
|
|
28
|
-
return
|
|
24
|
+
InitializeOnPreviewAllowlist.add(InternalCoreModule);
|
|
25
|
+
return InternalCoreModule.register([
|
|
29
26
|
{
|
|
30
|
-
provide:
|
|
31
|
-
useFactory: () =>
|
|
27
|
+
provide: ExternalContextCreator,
|
|
28
|
+
useFactory: () => ExternalContextCreator.fromContainer(container),
|
|
32
29
|
},
|
|
33
30
|
{
|
|
34
|
-
provide:
|
|
31
|
+
provide: ModulesContainer,
|
|
35
32
|
useFactory: () => container.getModules(),
|
|
36
33
|
},
|
|
37
34
|
{
|
|
38
|
-
provide:
|
|
35
|
+
provide: HttpAdapterHost,
|
|
39
36
|
useFactory: () => httpAdapterHost,
|
|
40
37
|
},
|
|
41
38
|
{
|
|
42
|
-
provide:
|
|
39
|
+
provide: LazyModuleLoader,
|
|
43
40
|
useFactory: lazyModuleLoaderFactory,
|
|
44
41
|
},
|
|
45
42
|
{
|
|
46
|
-
provide:
|
|
43
|
+
provide: SerializedGraph,
|
|
47
44
|
useFactory: () => container.serializedGraph,
|
|
48
45
|
},
|
|
49
46
|
]);
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
|
-
exports.InternalCoreModuleFactory = InternalCoreModuleFactory;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { ExistingProvider, FactoryProvider, ValueProvider } from '@nestjs/common
|
|
1
|
+
import { type DynamicModule } from '@nestjs/common';
|
|
2
|
+
import type { ExistingProvider, FactoryProvider, ValueProvider } from '@nestjs/common';
|
|
3
3
|
export declare class InternalCoreModule {
|
|
4
4
|
static register(providers: Array<ValueProvider | FactoryProvider | ExistingProvider>): DynamicModule;
|
|
5
5
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var InternalCoreModule_1;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const services_1 = require("../../services");
|
|
9
|
-
const inquirer_providers_1 = require("../inquirer/inquirer-providers");
|
|
2
|
+
import { __decorate } from "tslib";
|
|
3
|
+
import { Global, Module } from '@nestjs/common';
|
|
4
|
+
import { requestProvider } from '../../router/request/request-providers.js';
|
|
5
|
+
import { Reflector } from '../../services/index.js';
|
|
6
|
+
import { inquirerProvider } from '../inquirer/inquirer-providers.js';
|
|
10
7
|
const ReflectorAliasProvider = {
|
|
11
|
-
provide:
|
|
12
|
-
useExisting:
|
|
8
|
+
provide: Reflector.name,
|
|
9
|
+
useExisting: Reflector,
|
|
13
10
|
};
|
|
14
11
|
let InternalCoreModule = InternalCoreModule_1 = class InternalCoreModule {
|
|
15
12
|
static register(providers) {
|
|
@@ -20,21 +17,21 @@ let InternalCoreModule = InternalCoreModule_1 = class InternalCoreModule {
|
|
|
20
17
|
};
|
|
21
18
|
}
|
|
22
19
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(
|
|
26
|
-
(0, common_1.Module)({
|
|
20
|
+
InternalCoreModule = InternalCoreModule_1 = __decorate([
|
|
21
|
+
Global(),
|
|
22
|
+
Module({
|
|
27
23
|
providers: [
|
|
28
|
-
|
|
24
|
+
Reflector,
|
|
29
25
|
ReflectorAliasProvider,
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
requestProvider,
|
|
27
|
+
inquirerProvider,
|
|
32
28
|
],
|
|
33
29
|
exports: [
|
|
34
|
-
|
|
30
|
+
Reflector,
|
|
35
31
|
ReflectorAliasProvider,
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
requestProvider,
|
|
33
|
+
inquirerProvider,
|
|
38
34
|
],
|
|
39
35
|
})
|
|
40
36
|
], InternalCoreModule);
|
|
37
|
+
export { InternalCoreModule };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractHttpAdapter } from '../adapters';
|
|
2
|
-
import { HttpAdapterHost } from '../helpers/http-adapter-host';
|
|
1
|
+
import { AbstractHttpAdapter } from '../adapters/index.js';
|
|
2
|
+
import { HttpAdapterHost } from '../helpers/http-adapter-host.js';
|
|
3
3
|
export declare class InternalProvidersStorage {
|
|
4
4
|
private readonly _httpAdapterHost;
|
|
5
5
|
private _httpAdapter;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class InternalProvidersStorage {
|
|
6
|
-
constructor() {
|
|
7
|
-
this._httpAdapterHost = new http_adapter_host_1.HttpAdapterHost();
|
|
8
|
-
}
|
|
1
|
+
import { HttpAdapterHost } from '../helpers/http-adapter-host.js';
|
|
2
|
+
export class InternalProvidersStorage {
|
|
3
|
+
_httpAdapterHost = new HttpAdapterHost();
|
|
4
|
+
_httpAdapter;
|
|
9
5
|
get httpAdapterHost() {
|
|
10
6
|
return this._httpAdapterHost;
|
|
11
7
|
}
|
|
@@ -16,4 +12,3 @@ class InternalProvidersStorage {
|
|
|
16
12
|
this._httpAdapter = httpAdapter;
|
|
17
13
|
}
|
|
18
14
|
}
|
|
19
|
-
exports.InternalProvidersStorage = InternalProvidersStorage;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { DynamicModule, Type } from '@nestjs/common';
|
|
2
|
-
import { ModuleOverride } from '../../interfaces/module-override.interface';
|
|
3
|
-
import { DependenciesScanner } from '../../scanner';
|
|
4
|
-
import { ModuleCompiler } from '../compiler';
|
|
5
|
-
import { InstanceLoader } from '../instance-loader';
|
|
6
|
-
import { ModuleRef } from '../module-ref';
|
|
7
|
-
import { ModulesContainer } from '../modules-container';
|
|
8
|
-
import { LazyModuleLoaderLoadOptions } from './lazy-module-loader-options.interface';
|
|
1
|
+
import type { DynamicModule, Type } from '@nestjs/common';
|
|
2
|
+
import { ModuleOverride } from '../../interfaces/module-override.interface.js';
|
|
3
|
+
import { DependenciesScanner } from '../../scanner.js';
|
|
4
|
+
import { ModuleCompiler } from '../compiler.js';
|
|
5
|
+
import { InstanceLoader } from '../instance-loader.js';
|
|
6
|
+
import { ModuleRef } from '../module-ref.js';
|
|
7
|
+
import { ModulesContainer } from '../modules-container.js';
|
|
8
|
+
import { LazyModuleLoaderLoadOptions } from './lazy-module-loader-options.interface.js';
|
|
9
9
|
export declare class LazyModuleLoader {
|
|
10
10
|
private readonly dependenciesScanner;
|
|
11
11
|
private readonly instanceLoader;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { SilentLogger } from '../helpers/silent-logger.js';
|
|
2
|
+
import { ModuleRef } from '../module-ref.js';
|
|
3
|
+
export class LazyModuleLoader {
|
|
4
|
+
dependenciesScanner;
|
|
5
|
+
instanceLoader;
|
|
6
|
+
moduleCompiler;
|
|
7
|
+
modulesContainer;
|
|
8
|
+
moduleOverrides;
|
|
7
9
|
constructor(dependenciesScanner, instanceLoader, moduleCompiler, modulesContainer, moduleOverrides) {
|
|
8
10
|
this.dependenciesScanner = dependenciesScanner;
|
|
9
11
|
this.instanceLoader = instanceLoader;
|
|
@@ -34,7 +36,7 @@ class LazyModuleLoader {
|
|
|
34
36
|
}
|
|
35
37
|
registerLoggerConfiguration(loadOpts) {
|
|
36
38
|
if (loadOpts?.logger === false) {
|
|
37
|
-
this.instanceLoader.setLogger(new
|
|
39
|
+
this.instanceLoader.setLogger(new SilentLogger());
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
createLazyModulesContainer(moduleInstances) {
|
|
@@ -42,8 +44,7 @@ class LazyModuleLoader {
|
|
|
42
44
|
return new Map(moduleInstances.map(ref => [ref.token, ref]));
|
|
43
45
|
}
|
|
44
46
|
getTargetModuleRef(moduleInstance) {
|
|
45
|
-
const moduleRefInstanceWrapper = moduleInstance.getProviderByKey(
|
|
47
|
+
const moduleRefInstanceWrapper = moduleInstance.getProviderByKey(ModuleRef);
|
|
46
48
|
return moduleRefInstanceWrapper.instance;
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
|
-
exports.LazyModuleLoader = LazyModuleLoader;
|
package/injector/module-ref.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IntrospectionResult, Type } from '@nestjs/common';
|
|
2
|
-
import { AbstractInstanceResolver } from './abstract-instance-resolver';
|
|
3
|
-
import { NestContainer } from './container';
|
|
4
|
-
import { Injector } from './injector';
|
|
5
|
-
import { InstanceLinksHost } from './instance-links-host';
|
|
6
|
-
import { ContextId } from './instance-wrapper';
|
|
7
|
-
import { Module } from './module';
|
|
1
|
+
import { type IntrospectionResult, type Type } from '@nestjs/common';
|
|
2
|
+
import { AbstractInstanceResolver } from './abstract-instance-resolver.js';
|
|
3
|
+
import { NestContainer } from './container.js';
|
|
4
|
+
import { Injector } from './injector.js';
|
|
5
|
+
import { InstanceLinksHost } from './instance-links-host.js';
|
|
6
|
+
import { ContextId } from './instance-wrapper.js';
|
|
7
|
+
import { Module } from './module.js';
|
|
8
8
|
export interface ModuleRefGetOrResolveOpts {
|
|
9
9
|
/**
|
|
10
10
|
* If enabled, lookup will only be performed in the host module.
|