@nestjs/core 9.4.3 → 10.0.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 +2 -0
- package/adapters/http-adapter.js +3 -0
- package/discovery/discovery-module.js +2 -3
- package/discovery/discovery-service.js +2 -3
- package/errors/exception-handler.js +1 -1
- package/errors/exceptions-zone.js +1 -1
- package/errors/messages.js +7 -8
- package/exceptions/base-exception-filter.js +2 -2
- package/exceptions/exceptions-handler.d.ts +1 -1
- package/exceptions/exceptions-handler.js +3 -6
- package/exceptions/external-exception-filter.js +1 -1
- package/exceptions/external-exceptions-handler.d.ts +1 -1
- package/exceptions/external-exceptions-handler.js +3 -6
- package/helpers/context-id-factory.js +1 -2
- package/helpers/context-utils.js +4 -1
- package/helpers/execution-context-host.js +1 -0
- package/injector/abstract-instance-resolver.js +1 -1
- package/injector/compiler.js +2 -3
- package/injector/container.d.ts +6 -1
- package/injector/container.js +23 -3
- package/injector/helpers/provider-classifier.js +2 -2
- package/injector/helpers/transient-instances.d.ts +3 -3
- package/injector/injector.d.ts +7 -7
- package/injector/injector.js +24 -20
- package/injector/instance-links-host.d.ts +4 -4
- package/injector/instance-links-host.js +1 -1
- package/injector/instance-wrapper.d.ts +4 -4
- package/injector/instance-wrapper.js +17 -10
- package/injector/internal-core-module/internal-core-module-factory.d.ts +2 -1
- package/injector/internal-core-module/internal-core-module-factory.js +2 -6
- package/injector/internal-core-module/internal-core-module.js +2 -3
- package/injector/lazy-module-loader/lazy-module-loader.d.ts +3 -1
- package/injector/lazy-module-loader/lazy-module-loader.js +7 -3
- package/injector/module.d.ts +12 -29
- package/injector/module.js +14 -32
- package/inspector/deterministic-uuid-registry.js +1 -1
- package/inspector/graph-inspector.js +18 -14
- package/inspector/initialize-on-preview.allowlist.js +1 -1
- package/inspector/partial-graph.host.js +2 -4
- package/inspector/serialized-graph.js +15 -8
- package/inspector/uuid-factory.js +2 -2
- package/interceptors/interceptors-consumer.js +4 -5
- package/middleware/builder.js +26 -3
- package/middleware/container.d.ts +2 -2
- package/middleware/container.js +1 -2
- package/middleware/middleware-module.js +4 -4
- package/middleware/route-info-path-extractor.js +1 -2
- package/middleware/routes-mapper.d.ts +5 -2
- package/middleware/routes-mapper.js +45 -26
- package/middleware/utils.js +2 -3
- package/nest-application-context.js +3 -5
- package/nest-application.js +9 -10
- package/nest-factory.js +3 -3
- package/package.json +6 -6
- package/repl/native-functions/help-repl-fn.js +1 -1
- package/repl/native-functions/methods-repl-fn.js +1 -1
- package/repl/repl-context.js +6 -5
- package/repl/repl-logger.js +1 -1
- package/repl/repl-native-commands.js +1 -1
- package/router/route-path-factory.d.ts +4 -2
- package/router/route-path-factory.js +20 -4
- package/router/router-execution-context.js +1 -2
- package/router/router-explorer.js +12 -2
- package/router/router-module.js +8 -6
- package/router/routes-resolver.js +3 -3
- package/router/sse-stream.js +9 -4
- package/scanner.d.ts +17 -3
- package/scanner.js +49 -10
- package/services/reflector.service.js +4 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Provider, Scope, Type } from '@nestjs/common';
|
|
2
2
|
import { EnhancerSubtype } from '@nestjs/common/constants';
|
|
3
|
-
import { FactoryProvider } from '@nestjs/common/interfaces';
|
|
4
|
-
import {
|
|
3
|
+
import { FactoryProvider, InjectionToken } from '@nestjs/common/interfaces';
|
|
4
|
+
import { Module } from './module';
|
|
5
5
|
export declare const INSTANCE_METADATA_SYMBOL: unique symbol;
|
|
6
6
|
export declare const INSTANCE_ID_SYMBOL: unique symbol;
|
|
7
7
|
export interface HostComponentInfo {
|
|
8
8
|
/**
|
|
9
9
|
* Injection token (or class reference)
|
|
10
10
|
*/
|
|
11
|
-
token:
|
|
11
|
+
token: InjectionToken;
|
|
12
12
|
/**
|
|
13
13
|
* Flag that indicates whether DI subtree is durable
|
|
14
14
|
*/
|
|
@@ -31,7 +31,7 @@ export interface PropertyMetadata {
|
|
|
31
31
|
}
|
|
32
32
|
export declare class InstanceWrapper<T = any> {
|
|
33
33
|
readonly name: any;
|
|
34
|
-
readonly token:
|
|
34
|
+
readonly token: InjectionToken;
|
|
35
35
|
readonly async?: boolean;
|
|
36
36
|
readonly host?: Module;
|
|
37
37
|
readonly isAlias: boolean;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.InstanceWrapper = exports.INSTANCE_ID_SYMBOL = exports.INSTANCE_METADATA_SYMBOL = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
5
|
const common_1 = require("@nestjs/common");
|
|
7
6
|
const cli_colors_util_1 = require("@nestjs/common/utils/cli-colors.util");
|
|
8
7
|
const random_string_generator_util_1 = require("@nestjs/common/utils/random-string-generator.util");
|
|
@@ -15,14 +14,13 @@ exports.INSTANCE_METADATA_SYMBOL = Symbol.for('instance_metadata:cache');
|
|
|
15
14
|
exports.INSTANCE_ID_SYMBOL = Symbol.for('instance_metadata:id');
|
|
16
15
|
class InstanceWrapper {
|
|
17
16
|
constructor(metadata = {}) {
|
|
18
|
-
var _b;
|
|
19
17
|
this.isAlias = false;
|
|
20
18
|
this.scope = common_1.Scope.DEFAULT;
|
|
21
19
|
this.values = new WeakMap();
|
|
22
20
|
this[_a] = {};
|
|
23
21
|
this.initialize(metadata);
|
|
24
22
|
this[exports.INSTANCE_ID_SYMBOL] =
|
|
25
|
-
|
|
23
|
+
metadata[exports.INSTANCE_ID_SYMBOL] ?? this.generateUuid();
|
|
26
24
|
}
|
|
27
25
|
get id() {
|
|
28
26
|
return this[exports.INSTANCE_ID_SYMBOL];
|
|
@@ -168,7 +166,12 @@ class InstanceWrapper {
|
|
|
168
166
|
if (this.isDependencyTreeStatic()) {
|
|
169
167
|
return staticInstance;
|
|
170
168
|
}
|
|
171
|
-
const instancePerContext =
|
|
169
|
+
const instancePerContext = {
|
|
170
|
+
...staticInstance,
|
|
171
|
+
instance: undefined,
|
|
172
|
+
isResolved: false,
|
|
173
|
+
isPending: false,
|
|
174
|
+
};
|
|
172
175
|
if (this.isNewable()) {
|
|
173
176
|
instancePerContext.instance = Object.create(this.metatype.prototype);
|
|
174
177
|
}
|
|
@@ -177,7 +180,12 @@ class InstanceWrapper {
|
|
|
177
180
|
}
|
|
178
181
|
cloneTransientInstance(contextId, inquirerId) {
|
|
179
182
|
const staticInstance = this.getInstanceByContextId(constants_1.STATIC_CONTEXT);
|
|
180
|
-
const instancePerContext =
|
|
183
|
+
const instancePerContext = {
|
|
184
|
+
...staticInstance,
|
|
185
|
+
instance: undefined,
|
|
186
|
+
isResolved: false,
|
|
187
|
+
isPending: false,
|
|
188
|
+
};
|
|
181
189
|
if (this.isNewable()) {
|
|
182
190
|
instancePerContext.instance = Object.create(this.metatype.prototype);
|
|
183
191
|
}
|
|
@@ -252,7 +260,7 @@ class InstanceWrapper {
|
|
|
252
260
|
return (0, shared_utils_1.isNil)(this.inject) && this.metatype && this.metatype.prototype;
|
|
253
261
|
}
|
|
254
262
|
initialize(metadata) {
|
|
255
|
-
const { instance, isResolved
|
|
263
|
+
const { instance, isResolved, ...wrapperPartial } = metadata;
|
|
256
264
|
Object.assign(this, wrapperPartial);
|
|
257
265
|
this.setInstanceByContextId(constants_1.STATIC_CONTEXT, {
|
|
258
266
|
instance,
|
|
@@ -280,12 +288,11 @@ class InstanceWrapper {
|
|
|
280
288
|
return !!process.env.NEST_DEBUG;
|
|
281
289
|
}
|
|
282
290
|
generateUuid() {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
key += (_f = (_e = this.host) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : '';
|
|
291
|
+
let key = this.name?.toString() ?? this.token?.toString();
|
|
292
|
+
key += this.host?.name ?? '';
|
|
286
293
|
return key ? uuid_factory_1.UuidFactory.get(key) : (0, random_string_generator_util_1.randomStringGenerator)();
|
|
287
294
|
}
|
|
288
295
|
}
|
|
296
|
+
exports.InstanceWrapper = InstanceWrapper;
|
|
289
297
|
_a = exports.INSTANCE_METADATA_SYMBOL;
|
|
290
298
|
InstanceWrapper.logger = new common_1.Logger(InstanceWrapper.name);
|
|
291
|
-
exports.InstanceWrapper = InstanceWrapper;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { HttpAdapterHost } from '../../helpers/http-adapter-host';
|
|
2
2
|
import { GraphInspector } from '../../inspector/graph-inspector';
|
|
3
|
+
import { ModuleOverride } from '../../interfaces/module-override.interface';
|
|
3
4
|
import { DependenciesScanner } from '../../scanner';
|
|
4
5
|
import { ModuleCompiler } from '../compiler';
|
|
5
6
|
import { NestContainer } from '../container';
|
|
6
7
|
export declare class InternalCoreModuleFactory {
|
|
7
|
-
static create(container: NestContainer, scanner: DependenciesScanner, moduleCompiler: ModuleCompiler, httpAdapterHost: HttpAdapterHost, graphInspector: GraphInspector): import("@nestjs/common").DynamicModule;
|
|
8
|
+
static create(container: NestContainer, scanner: DependenciesScanner, moduleCompiler: ModuleCompiler, httpAdapterHost: HttpAdapterHost, graphInspector: GraphInspector, moduleOverrides?: ModuleOverride[]): import("@nestjs/common").DynamicModule;
|
|
8
9
|
}
|
|
@@ -11,14 +11,14 @@ const lazy_module_loader_1 = require("../lazy-module-loader/lazy-module-loader")
|
|
|
11
11
|
const modules_container_1 = require("../modules-container");
|
|
12
12
|
const internal_core_module_1 = require("./internal-core-module");
|
|
13
13
|
class InternalCoreModuleFactory {
|
|
14
|
-
static create(container, scanner, moduleCompiler, httpAdapterHost, graphInspector) {
|
|
14
|
+
static create(container, scanner, moduleCompiler, httpAdapterHost, graphInspector, moduleOverrides) {
|
|
15
15
|
const lazyModuleLoaderFactory = () => {
|
|
16
16
|
const logger = new common_1.Logger(lazy_module_loader_1.LazyModuleLoader.name, {
|
|
17
17
|
timestamp: false,
|
|
18
18
|
});
|
|
19
19
|
const injector = new injector_1.Injector();
|
|
20
20
|
const instanceLoader = new instance_loader_1.InstanceLoader(container, injector, graphInspector, logger);
|
|
21
|
-
return new lazy_module_loader_1.LazyModuleLoader(scanner, instanceLoader, moduleCompiler, container.getModules());
|
|
21
|
+
return new lazy_module_loader_1.LazyModuleLoader(scanner, instanceLoader, moduleCompiler, container.getModules(), moduleOverrides);
|
|
22
22
|
};
|
|
23
23
|
return internal_core_module_1.InternalCoreModule.register([
|
|
24
24
|
{
|
|
@@ -33,10 +33,6 @@ class InternalCoreModuleFactory {
|
|
|
33
33
|
provide: http_adapter_host_1.HttpAdapterHost,
|
|
34
34
|
useValue: httpAdapterHost,
|
|
35
35
|
},
|
|
36
|
-
{
|
|
37
|
-
provide: http_adapter_host_1.HttpAdapterHost.name,
|
|
38
|
-
useExisting: http_adapter_host_1.HttpAdapterHost,
|
|
39
|
-
},
|
|
40
36
|
{
|
|
41
37
|
provide: lazy_module_loader_1.LazyModuleLoader,
|
|
42
38
|
useFactory: lazyModuleLoaderFactory,
|
|
@@ -11,7 +11,7 @@ const ReflectorAliasProvider = {
|
|
|
11
11
|
provide: services_1.Reflector.name,
|
|
12
12
|
useExisting: services_1.Reflector,
|
|
13
13
|
};
|
|
14
|
-
let InternalCoreModule = InternalCoreModule_1 = class InternalCoreModule {
|
|
14
|
+
let InternalCoreModule = exports.InternalCoreModule = InternalCoreModule_1 = class InternalCoreModule {
|
|
15
15
|
static register(providers) {
|
|
16
16
|
return {
|
|
17
17
|
module: InternalCoreModule_1,
|
|
@@ -20,7 +20,7 @@ let InternalCoreModule = InternalCoreModule_1 = class InternalCoreModule {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
InternalCoreModule = InternalCoreModule_1 = tslib_1.__decorate([
|
|
23
|
+
exports.InternalCoreModule = InternalCoreModule = InternalCoreModule_1 = tslib_1.__decorate([
|
|
24
24
|
(0, common_1.Global)(),
|
|
25
25
|
(0, common_1.Module)({
|
|
26
26
|
providers: [
|
|
@@ -37,4 +37,3 @@ InternalCoreModule = InternalCoreModule_1 = tslib_1.__decorate([
|
|
|
37
37
|
],
|
|
38
38
|
})
|
|
39
39
|
], InternalCoreModule);
|
|
40
|
-
exports.InternalCoreModule = InternalCoreModule;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DynamicModule, Type } from '@nestjs/common';
|
|
2
|
+
import { ModuleOverride } from '../../interfaces/module-override.interface';
|
|
2
3
|
import { DependenciesScanner } from '../../scanner';
|
|
3
4
|
import { ModuleCompiler } from '../compiler';
|
|
4
5
|
import { InstanceLoader } from '../instance-loader';
|
|
@@ -10,7 +11,8 @@ export declare class LazyModuleLoader {
|
|
|
10
11
|
private readonly instanceLoader;
|
|
11
12
|
private readonly moduleCompiler;
|
|
12
13
|
private readonly modulesContainer;
|
|
13
|
-
|
|
14
|
+
private readonly moduleOverrides?;
|
|
15
|
+
constructor(dependenciesScanner: DependenciesScanner, instanceLoader: InstanceLoader, moduleCompiler: ModuleCompiler, modulesContainer: ModulesContainer, moduleOverrides?: ModuleOverride[]);
|
|
14
16
|
load(loaderFn: () => Promise<Type<unknown> | DynamicModule> | Type<unknown> | DynamicModule, loadOpts?: LazyModuleLoaderLoadOptions): Promise<ModuleRef>;
|
|
15
17
|
private registerLoggerConfiguration;
|
|
16
18
|
private createLazyModulesContainer;
|
|
@@ -4,16 +4,20 @@ exports.LazyModuleLoader = void 0;
|
|
|
4
4
|
const silent_logger_1 = require("../helpers/silent-logger");
|
|
5
5
|
const module_ref_1 = require("../module-ref");
|
|
6
6
|
class LazyModuleLoader {
|
|
7
|
-
constructor(dependenciesScanner, instanceLoader, moduleCompiler, modulesContainer) {
|
|
7
|
+
constructor(dependenciesScanner, instanceLoader, moduleCompiler, modulesContainer, moduleOverrides) {
|
|
8
8
|
this.dependenciesScanner = dependenciesScanner;
|
|
9
9
|
this.instanceLoader = instanceLoader;
|
|
10
10
|
this.moduleCompiler = moduleCompiler;
|
|
11
11
|
this.modulesContainer = modulesContainer;
|
|
12
|
+
this.moduleOverrides = moduleOverrides;
|
|
12
13
|
}
|
|
13
14
|
async load(loaderFn, loadOpts) {
|
|
14
15
|
this.registerLoggerConfiguration(loadOpts);
|
|
15
16
|
const moduleClassOrDynamicDefinition = await loaderFn();
|
|
16
|
-
const moduleInstances = await this.dependenciesScanner.scanForModules(
|
|
17
|
+
const moduleInstances = await this.dependenciesScanner.scanForModules({
|
|
18
|
+
moduleDefinition: moduleClassOrDynamicDefinition,
|
|
19
|
+
overrides: this.moduleOverrides,
|
|
20
|
+
});
|
|
17
21
|
if (moduleInstances.length === 0) {
|
|
18
22
|
// The module has been loaded already. In this case, we must
|
|
19
23
|
// retrieve a module reference from the existing container.
|
|
@@ -28,7 +32,7 @@ class LazyModuleLoader {
|
|
|
28
32
|
return this.getTargetModuleRef(targetModule);
|
|
29
33
|
}
|
|
30
34
|
registerLoggerConfiguration(loadOpts) {
|
|
31
|
-
if (
|
|
35
|
+
if (loadOpts?.logger === false) {
|
|
32
36
|
this.instanceLoader.setLogger(new silent_logger_1.SilentLogger());
|
|
33
37
|
}
|
|
34
38
|
}
|
package/injector/module.d.ts
CHANGED
|
@@ -3,11 +3,6 @@ import { ClassProvider, Controller, DynamicModule, ExistingProvider, FactoryProv
|
|
|
3
3
|
import { NestContainer } from './container';
|
|
4
4
|
import { InstanceWrapper } from './instance-wrapper';
|
|
5
5
|
import { ModuleRef } from './module-ref';
|
|
6
|
-
/**
|
|
7
|
-
* @note
|
|
8
|
-
* Left for backward compatibility
|
|
9
|
-
*/
|
|
10
|
-
export type InstanceToken = InjectionToken;
|
|
11
6
|
export declare class Module {
|
|
12
7
|
private readonly _metatype;
|
|
13
8
|
private readonly container;
|
|
@@ -32,25 +27,13 @@ export declare class Module {
|
|
|
32
27
|
set isGlobal(global: boolean);
|
|
33
28
|
get initOnPreview(): boolean;
|
|
34
29
|
set initOnPreview(initOnPreview: boolean);
|
|
35
|
-
get providers(): Map<
|
|
36
|
-
get middlewares(): Map<
|
|
30
|
+
get providers(): Map<InjectionToken, InstanceWrapper<Injectable>>;
|
|
31
|
+
get middlewares(): Map<InjectionToken, InstanceWrapper<Injectable>>;
|
|
37
32
|
get imports(): Set<Module>;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*/
|
|
41
|
-
get relatedModules(): Set<Module>;
|
|
42
|
-
/**
|
|
43
|
-
* Left for backward-compatibility reasons
|
|
44
|
-
*/
|
|
45
|
-
get components(): Map<InstanceToken, InstanceWrapper<Injectable>>;
|
|
46
|
-
/**
|
|
47
|
-
* Left for backward-compatibility reasons
|
|
48
|
-
*/
|
|
49
|
-
get routes(): Map<InstanceToken, InstanceWrapper<Controller>>;
|
|
50
|
-
get injectables(): Map<InstanceToken, InstanceWrapper<Injectable>>;
|
|
51
|
-
get controllers(): Map<InstanceToken, InstanceWrapper<Controller>>;
|
|
33
|
+
get injectables(): Map<InjectionToken, InstanceWrapper<Injectable>>;
|
|
34
|
+
get controllers(): Map<InjectionToken, InstanceWrapper<Controller>>;
|
|
52
35
|
get entryProviders(): Array<InstanceWrapper<Injectable>>;
|
|
53
|
-
get exports(): Set<
|
|
36
|
+
get exports(): Set<InjectionToken>;
|
|
54
37
|
get instance(): NestModule;
|
|
55
38
|
get metatype(): Type<any>;
|
|
56
39
|
get distance(): number;
|
|
@@ -69,26 +52,26 @@ export declare class Module {
|
|
|
69
52
|
isCustomFactory(provider: any): provider is FactoryProvider;
|
|
70
53
|
isCustomUseExisting(provider: any): provider is ExistingProvider;
|
|
71
54
|
isDynamicModule(exported: any): exported is DynamicModule;
|
|
72
|
-
addCustomClass(provider: ClassProvider, collection: Map<
|
|
55
|
+
addCustomClass(provider: ClassProvider, collection: Map<InjectionToken, InstanceWrapper>, enhancerSubtype?: EnhancerSubtype): void;
|
|
73
56
|
addCustomValue(provider: ValueProvider, collection: Map<Function | string | symbol, InstanceWrapper>, enhancerSubtype?: EnhancerSubtype): void;
|
|
74
57
|
addCustomFactory(provider: FactoryProvider, collection: Map<Function | string | symbol, InstanceWrapper>, enhancerSubtype?: EnhancerSubtype): void;
|
|
75
58
|
addCustomUseExisting(provider: ExistingProvider, collection: Map<Function | string | symbol, InstanceWrapper>, enhancerSubtype?: EnhancerSubtype): void;
|
|
76
59
|
addExportedProvider(provider: Provider | string | symbol | DynamicModule): Set<InjectionToken>;
|
|
77
60
|
addCustomExportedProvider(provider: FactoryProvider | ValueProvider | ClassProvider | ExistingProvider): Set<InjectionToken>;
|
|
78
|
-
validateExportedProvider(token:
|
|
61
|
+
validateExportedProvider(token: InjectionToken): InjectionToken;
|
|
79
62
|
addController(controller: Type<Controller>): void;
|
|
80
63
|
assignControllerUniqueId(controller: Type<Controller>): void;
|
|
81
64
|
addRelatedModule(module: Module): void;
|
|
82
|
-
replace(toReplace:
|
|
83
|
-
hasProvider(token:
|
|
84
|
-
hasInjectable(token:
|
|
85
|
-
getProviderByKey<T = any>(name:
|
|
65
|
+
replace(toReplace: InjectionToken, options: any): void;
|
|
66
|
+
hasProvider(token: InjectionToken): boolean;
|
|
67
|
+
hasInjectable(token: InjectionToken): boolean;
|
|
68
|
+
getProviderByKey<T = any>(name: InjectionToken): InstanceWrapper<T>;
|
|
86
69
|
getProviderById<T = any>(id: string): InstanceWrapper<T> | undefined;
|
|
87
70
|
getControllerById<T = any>(id: string): InstanceWrapper<T> | undefined;
|
|
88
71
|
getInjectableById<T = any>(id: string): InstanceWrapper<T> | undefined;
|
|
89
72
|
getMiddlewareById<T = any>(id: string): InstanceWrapper<T> | undefined;
|
|
90
73
|
getNonAliasProviders(): Array<[
|
|
91
|
-
|
|
74
|
+
InjectionToken,
|
|
92
75
|
InstanceWrapper<Injectable>
|
|
93
76
|
]>;
|
|
94
77
|
createModuleReferenceType(): Type<ModuleRef>;
|
package/injector/module.js
CHANGED
|
@@ -64,24 +64,6 @@ class Module {
|
|
|
64
64
|
get imports() {
|
|
65
65
|
return this._imports;
|
|
66
66
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Left for backward-compatibility reasons
|
|
69
|
-
*/
|
|
70
|
-
get relatedModules() {
|
|
71
|
-
return this._imports;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Left for backward-compatibility reasons
|
|
75
|
-
*/
|
|
76
|
-
get components() {
|
|
77
|
-
return this._providers;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Left for backward-compatibility reasons
|
|
81
|
-
*/
|
|
82
|
-
get routes() {
|
|
83
|
-
return this._controllers;
|
|
84
|
-
}
|
|
85
67
|
get injectables() {
|
|
86
68
|
return this._injectables;
|
|
87
69
|
}
|
|
@@ -238,7 +220,7 @@ class Module {
|
|
|
238
220
|
const token = provider.provide;
|
|
239
221
|
collection.set(token, new instance_wrapper_1.InstanceWrapper({
|
|
240
222
|
token,
|
|
241
|
-
name:
|
|
223
|
+
name: useClass?.name || useClass,
|
|
242
224
|
metatype: useClass,
|
|
243
225
|
instance: null,
|
|
244
226
|
isResolved: false,
|
|
@@ -252,7 +234,7 @@ class Module {
|
|
|
252
234
|
const { useValue: value, provide: providerToken } = provider;
|
|
253
235
|
collection.set(providerToken, new instance_wrapper_1.InstanceWrapper({
|
|
254
236
|
token: providerToken,
|
|
255
|
-
name:
|
|
237
|
+
name: providerToken?.name || providerToken,
|
|
256
238
|
metatype: null,
|
|
257
239
|
instance: value,
|
|
258
240
|
isResolved: true,
|
|
@@ -265,7 +247,7 @@ class Module {
|
|
|
265
247
|
const { useFactory: factory, inject, scope, durable, provide: providerToken, } = provider;
|
|
266
248
|
collection.set(providerToken, new instance_wrapper_1.InstanceWrapper({
|
|
267
249
|
token: providerToken,
|
|
268
|
-
name:
|
|
250
|
+
name: providerToken?.name || providerToken,
|
|
269
251
|
metatype: factory,
|
|
270
252
|
instance: null,
|
|
271
253
|
isResolved: false,
|
|
@@ -280,7 +262,7 @@ class Module {
|
|
|
280
262
|
const { useExisting, provide: providerToken } = provider;
|
|
281
263
|
collection.set(providerToken, new instance_wrapper_1.InstanceWrapper({
|
|
282
264
|
token: providerToken,
|
|
283
|
-
name:
|
|
265
|
+
name: providerToken?.name || providerToken,
|
|
284
266
|
metatype: (instance => instance),
|
|
285
267
|
instance: null,
|
|
286
268
|
isResolved: false,
|
|
@@ -354,11 +336,14 @@ class Module {
|
|
|
354
336
|
replace(toReplace, options) {
|
|
355
337
|
if (options.isProvider && this.hasProvider(toReplace)) {
|
|
356
338
|
const originalProvider = this._providers.get(toReplace);
|
|
357
|
-
return originalProvider.mergeWith(
|
|
339
|
+
return originalProvider.mergeWith({ provide: toReplace, ...options });
|
|
358
340
|
}
|
|
359
341
|
else if (!options.isProvider && this.hasInjectable(toReplace)) {
|
|
360
342
|
const originalInjectable = this._injectables.get(toReplace);
|
|
361
|
-
return originalInjectable.mergeWith(
|
|
343
|
+
return originalInjectable.mergeWith({
|
|
344
|
+
provide: toReplace,
|
|
345
|
+
...options,
|
|
346
|
+
});
|
|
362
347
|
}
|
|
363
348
|
}
|
|
364
349
|
hasProvider(token) {
|
|
@@ -393,9 +378,8 @@ class Module {
|
|
|
393
378
|
super(self.container);
|
|
394
379
|
}
|
|
395
380
|
get(typeOrToken, options = {}) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
(_b = options.each) !== null && _b !== void 0 ? _b : (options.each = false);
|
|
381
|
+
options.strict ??= true;
|
|
382
|
+
options.each ??= false;
|
|
399
383
|
return this.find(typeOrToken, options.strict
|
|
400
384
|
? {
|
|
401
385
|
moduleId: self.id,
|
|
@@ -404,9 +388,8 @@ class Module {
|
|
|
404
388
|
: options);
|
|
405
389
|
}
|
|
406
390
|
resolve(typeOrToken, contextId = (0, context_id_factory_1.createContextId)(), options = {}) {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
(_b = options.each) !== null && _b !== void 0 ? _b : (options.each = false);
|
|
391
|
+
options.strict ??= true;
|
|
392
|
+
options.each ??= false;
|
|
410
393
|
return this.resolvePerContext(typeOrToken, self, contextId, options);
|
|
411
394
|
}
|
|
412
395
|
async create(type) {
|
|
@@ -423,9 +406,8 @@ class Module {
|
|
|
423
406
|
: false;
|
|
424
407
|
}
|
|
425
408
|
generateUuid() {
|
|
426
|
-
var _a, _b, _c;
|
|
427
409
|
const prefix = 'M_';
|
|
428
|
-
const key =
|
|
410
|
+
const key = this.name?.toString() ?? this.token?.toString();
|
|
429
411
|
return key ? uuid_factory_1.UuidFactory.get(`${prefix}_${key}`) : (0, random_string_generator_util_1.randomStringGenerator)();
|
|
430
412
|
}
|
|
431
413
|
}
|
|
@@ -20,15 +20,14 @@ class GraphInspector {
|
|
|
20
20
|
deterministic_uuid_registry_1.DeterministicUuidRegistry.clear();
|
|
21
21
|
}
|
|
22
22
|
registerPartial(error) {
|
|
23
|
-
var _a, _b;
|
|
24
23
|
this.graph.status = 'partial';
|
|
25
24
|
if (error instanceof unknown_dependencies_exception_1.UnknownDependenciesException) {
|
|
26
25
|
this.graph.metadata = {
|
|
27
26
|
cause: {
|
|
28
27
|
type: 'unknown-dependencies',
|
|
29
28
|
context: error.context,
|
|
30
|
-
moduleId:
|
|
31
|
-
nodeId:
|
|
29
|
+
moduleId: error.moduleRef?.id,
|
|
30
|
+
nodeId: error.metadata?.id,
|
|
32
31
|
},
|
|
33
32
|
};
|
|
34
33
|
}
|
|
@@ -44,16 +43,18 @@ class GraphInspector {
|
|
|
44
43
|
}
|
|
45
44
|
inspectInstanceWrapper(source, moduleRef) {
|
|
46
45
|
const ctorMetadata = source.getCtorMetadata();
|
|
47
|
-
ctorMetadata
|
|
46
|
+
ctorMetadata?.forEach((target, index) => this.insertClassToClassEdge(source, target, moduleRef, index, 'constructor'));
|
|
48
47
|
const propertiesMetadata = source.getPropertiesMetadata();
|
|
49
|
-
propertiesMetadata
|
|
48
|
+
propertiesMetadata?.forEach(({ key, wrapper: target }) => this.insertClassToClassEdge(source, target, moduleRef, key, 'property'));
|
|
50
49
|
}
|
|
51
50
|
insertEnhancerMetadataCache(entry) {
|
|
52
51
|
this.enhancersMetadataCache.push(entry);
|
|
53
52
|
}
|
|
54
53
|
insertOrphanedEnhancer(entry) {
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
this.graph.insertOrphanedEnhancer({
|
|
55
|
+
...entry,
|
|
56
|
+
ref: entry.ref?.constructor?.name ?? 'Object',
|
|
57
|
+
});
|
|
57
58
|
}
|
|
58
59
|
insertAttachedEnhancer(wrapper) {
|
|
59
60
|
const existingNode = this.graph.getNodeById(wrapper.id);
|
|
@@ -61,7 +62,10 @@ class GraphInspector {
|
|
|
61
62
|
this.graph.insertAttachedEnhancer(existingNode.id);
|
|
62
63
|
}
|
|
63
64
|
insertEntrypointDefinition(definition, parentId) {
|
|
64
|
-
definition =
|
|
65
|
+
definition = {
|
|
66
|
+
...definition,
|
|
67
|
+
id: `${definition.classNodeId}_${definition.methodName}`,
|
|
68
|
+
};
|
|
65
69
|
this.graph.insertEntrypoint(definition, parentId);
|
|
66
70
|
}
|
|
67
71
|
insertClassNode(moduleRef, wrapper, type) {
|
|
@@ -112,11 +116,11 @@ class GraphInspector {
|
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
118
|
insertEnhancerEdge(entry) {
|
|
115
|
-
var _a, _b, _c, _d;
|
|
116
119
|
const moduleRef = this.container.getModuleByKey(entry.moduleToken);
|
|
117
|
-
const sourceInstanceWrapper =
|
|
120
|
+
const sourceInstanceWrapper = moduleRef.controllers.get(entry.classRef) ??
|
|
121
|
+
moduleRef.providers.get(entry.classRef);
|
|
118
122
|
const existingSourceNode = this.graph.getNodeById(sourceInstanceWrapper.id);
|
|
119
|
-
const enhancers =
|
|
123
|
+
const enhancers = existingSourceNode.metadata.enhancers ?? [];
|
|
120
124
|
if (entry.enhancerInstanceWrapper) {
|
|
121
125
|
this.insertClassToClassEdge(sourceInstanceWrapper, entry.enhancerInstanceWrapper, moduleRef, undefined, 'decorator');
|
|
122
126
|
enhancers.push({
|
|
@@ -126,7 +130,8 @@ class GraphInspector {
|
|
|
126
130
|
});
|
|
127
131
|
}
|
|
128
132
|
else {
|
|
129
|
-
const name =
|
|
133
|
+
const name = entry.enhancerRef.constructor?.name ??
|
|
134
|
+
entry.enhancerRef.name;
|
|
130
135
|
enhancers.push({
|
|
131
136
|
name,
|
|
132
137
|
methodKey: entry.methodKey,
|
|
@@ -136,7 +141,6 @@ class GraphInspector {
|
|
|
136
141
|
existingSourceNode.metadata.enhancers = enhancers;
|
|
137
142
|
}
|
|
138
143
|
insertClassToClassEdge(source, target, moduleRef, keyOrIndex, injectionType) {
|
|
139
|
-
var _a;
|
|
140
144
|
this.graph.insertEdge({
|
|
141
145
|
source: source.id,
|
|
142
146
|
target: target.id,
|
|
@@ -147,7 +151,7 @@ class GraphInspector {
|
|
|
147
151
|
targetClassName: target.name,
|
|
148
152
|
sourceClassToken: source.token,
|
|
149
153
|
targetClassToken: target.token,
|
|
150
|
-
targetModuleName:
|
|
154
|
+
targetModuleName: target.host?.name,
|
|
151
155
|
keyOrIndex,
|
|
152
156
|
injectionType,
|
|
153
157
|
},
|
|
@@ -9,5 +9,5 @@ class InitializeOnPreviewAllowlist {
|
|
|
9
9
|
return this.allowlist.has(type);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
InitializeOnPreviewAllowlist.allowlist = new WeakMap();
|
|
13
12
|
exports.InitializeOnPreviewAllowlist = InitializeOnPreviewAllowlist;
|
|
13
|
+
InitializeOnPreviewAllowlist.allowlist = new WeakMap();
|
|
@@ -3,12 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PartialGraphHost = void 0;
|
|
4
4
|
class PartialGraphHost {
|
|
5
5
|
static toJSON() {
|
|
6
|
-
|
|
7
|
-
return (_a = this.partialGraph) === null || _a === void 0 ? void 0 : _a.toJSON();
|
|
6
|
+
return this.partialGraph?.toJSON();
|
|
8
7
|
}
|
|
9
8
|
static toString() {
|
|
10
|
-
|
|
11
|
-
return (_a = this.partialGraph) === null || _a === void 0 ? void 0 : _a.toString();
|
|
9
|
+
return this.partialGraph?.toString();
|
|
12
10
|
}
|
|
13
11
|
static register(partialGraph) {
|
|
14
12
|
this.partialGraph = partialGraph;
|
|
@@ -31,7 +31,10 @@ class SerializedGraph {
|
|
|
31
31
|
insertNode(nodeDefinition) {
|
|
32
32
|
if (nodeDefinition.metadata.type === 'provider' &&
|
|
33
33
|
SerializedGraph.INTERNAL_PROVIDERS.includes(nodeDefinition.metadata.token)) {
|
|
34
|
-
nodeDefinition.metadata =
|
|
34
|
+
nodeDefinition.metadata = {
|
|
35
|
+
...nodeDefinition.metadata,
|
|
36
|
+
internal: true,
|
|
37
|
+
};
|
|
35
38
|
}
|
|
36
39
|
if (this.nodes.has(nodeDefinition.id)) {
|
|
37
40
|
return this.nodes.get(nodeDefinition.id);
|
|
@@ -40,14 +43,19 @@ class SerializedGraph {
|
|
|
40
43
|
return nodeDefinition;
|
|
41
44
|
}
|
|
42
45
|
insertEdge(edgeDefinition) {
|
|
43
|
-
var _a;
|
|
44
46
|
if (edgeDefinition.metadata.type === 'class-to-class' &&
|
|
45
47
|
(SerializedGraph.INTERNAL_PROVIDERS.includes(edgeDefinition.metadata.sourceClassToken) ||
|
|
46
48
|
SerializedGraph.INTERNAL_PROVIDERS.includes(edgeDefinition.metadata.targetClassToken))) {
|
|
47
|
-
edgeDefinition.metadata =
|
|
49
|
+
edgeDefinition.metadata = {
|
|
50
|
+
...edgeDefinition.metadata,
|
|
51
|
+
internal: true,
|
|
52
|
+
};
|
|
48
53
|
}
|
|
49
|
-
const id =
|
|
50
|
-
const edge =
|
|
54
|
+
const id = edgeDefinition.id ?? this.generateUuidByEdgeDefinition(edgeDefinition);
|
|
55
|
+
const edge = {
|
|
56
|
+
...edgeDefinition,
|
|
57
|
+
id,
|
|
58
|
+
};
|
|
51
59
|
this.edges.set(id, edge);
|
|
52
60
|
return edge;
|
|
53
61
|
}
|
|
@@ -88,11 +96,10 @@ class SerializedGraph {
|
|
|
88
96
|
}
|
|
89
97
|
toString() {
|
|
90
98
|
const replacer = (key, value) => {
|
|
91
|
-
var _a;
|
|
92
99
|
if (typeof value === 'symbol') {
|
|
93
100
|
return value.toString();
|
|
94
101
|
}
|
|
95
|
-
return typeof value === 'function' ?
|
|
102
|
+
return typeof value === 'function' ? value.name ?? 'Function' : value;
|
|
96
103
|
};
|
|
97
104
|
return JSON.stringify(this.toJSON(), replacer, 2);
|
|
98
105
|
}
|
|
@@ -100,6 +107,7 @@ class SerializedGraph {
|
|
|
100
107
|
return deterministic_uuid_registry_1.DeterministicUuidRegistry.get(JSON.stringify(edgeDefinition));
|
|
101
108
|
}
|
|
102
109
|
}
|
|
110
|
+
exports.SerializedGraph = SerializedGraph;
|
|
103
111
|
SerializedGraph.INTERNAL_PROVIDERS = [
|
|
104
112
|
application_config_1.ApplicationConfig,
|
|
105
113
|
module_ref_1.ModuleRef,
|
|
@@ -114,4 +122,3 @@ SerializedGraph.INTERNAL_PROVIDERS = [
|
|
|
114
122
|
request_constants_1.REQUEST,
|
|
115
123
|
inquirer_constants_1.INQUIRER,
|
|
116
124
|
];
|
|
117
|
-
exports.SerializedGraph = SerializedGraph;
|
|
@@ -7,7 +7,7 @@ var UuidFactoryMode;
|
|
|
7
7
|
(function (UuidFactoryMode) {
|
|
8
8
|
UuidFactoryMode["Random"] = "random";
|
|
9
9
|
UuidFactoryMode["Deterministic"] = "deterministic";
|
|
10
|
-
})(UuidFactoryMode
|
|
10
|
+
})(UuidFactoryMode || (exports.UuidFactoryMode = UuidFactoryMode = {}));
|
|
11
11
|
class UuidFactory {
|
|
12
12
|
static set mode(value) {
|
|
13
13
|
this._mode = value;
|
|
@@ -18,5 +18,5 @@ class UuidFactory {
|
|
|
18
18
|
: (0, random_string_generator_util_1.randomStringGenerator)();
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
UuidFactory._mode = UuidFactoryMode.Random;
|
|
22
21
|
exports.UuidFactory = UuidFactory;
|
|
22
|
+
UuidFactory._mode = UuidFactoryMode.Random;
|
|
@@ -12,17 +12,16 @@ class InterceptorsConsumer {
|
|
|
12
12
|
}
|
|
13
13
|
const context = this.createContext(args, instance, callback);
|
|
14
14
|
context.setType(type);
|
|
15
|
-
const
|
|
16
|
-
const nextFn = (i = 0) => async () => {
|
|
15
|
+
const nextFn = async (i = 0) => {
|
|
17
16
|
if (i >= interceptors.length) {
|
|
18
|
-
return
|
|
17
|
+
return this.transformDeferred(next);
|
|
19
18
|
}
|
|
20
19
|
const handler = {
|
|
21
|
-
handle: () => (0, rxjs_1.from)(nextFn(i + 1)
|
|
20
|
+
handle: () => (0, rxjs_1.from)(nextFn(i + 1)).pipe((0, operators_1.mergeAll)()),
|
|
22
21
|
};
|
|
23
22
|
return interceptors[i].intercept(context, handler);
|
|
24
23
|
};
|
|
25
|
-
return nextFn()();
|
|
24
|
+
return (0, rxjs_1.defer)(() => nextFn()).pipe((0, operators_1.mergeAll)());
|
|
26
25
|
}
|
|
27
26
|
createContext(args, instance, callback) {
|
|
28
27
|
return new execution_context_host_1.ExecutionContextHost(args, instance.constructor, callback);
|