@nestjs/core 7.6.0 → 7.6.4
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/injector/injector.d.ts
CHANGED
|
@@ -40,21 +40,21 @@ export interface InjectorDependencyContext {
|
|
|
40
40
|
dependencies?: InjectorDependency[];
|
|
41
41
|
}
|
|
42
42
|
export declare class Injector {
|
|
43
|
+
loadPrototype<T>({ name }: InstanceWrapper<T>, collection: Map<string, InstanceWrapper<T>>, contextId?: ContextId): void;
|
|
44
|
+
loadInstance<T>(wrapper: InstanceWrapper<T>, collection: Map<string, InstanceWrapper>, moduleRef: Module, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<void>;
|
|
43
45
|
loadMiddleware(wrapper: InstanceWrapper, collection: Map<string, InstanceWrapper>, moduleRef: Module, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<void>;
|
|
44
46
|
loadController(wrapper: InstanceWrapper<Controller>, moduleRef: Module, contextId?: ContextId): Promise<void>;
|
|
45
47
|
loadInjectable<T = any>(wrapper: InstanceWrapper<T>, moduleRef: Module, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<void>;
|
|
46
48
|
loadProvider(wrapper: InstanceWrapper<Injectable>, moduleRef: Module, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<void>;
|
|
47
|
-
loadPrototype<T>({ name }: InstanceWrapper<T>, collection: Map<string, InstanceWrapper<T>>, contextId?: ContextId): void;
|
|
48
49
|
applyDoneHook<T>(wrapper: InstancePerContext<T>): () => void;
|
|
49
|
-
|
|
50
|
-
resolveConstructorParams<T>(wrapper: InstanceWrapper<T>, moduleRef: Module, inject: InjectorDependency[], callback: (args: unknown[]) => void, contextId?: ContextId, inquirer?: InstanceWrapper, parentInquirer?: InstanceWrapper): Promise<void>;
|
|
50
|
+
resolveConstructorParams<T>(wrapper: InstanceWrapper<T>, moduleRef: Module, inject: InjectorDependency[], callback: (args: unknown[]) => void | Promise<void>, contextId?: ContextId, inquirer?: InstanceWrapper, parentInquirer?: InstanceWrapper): Promise<void>;
|
|
51
51
|
reflectConstructorParams<T>(type: Type<T>): any[];
|
|
52
52
|
reflectOptionalParams<T>(type: Type<T>): any[];
|
|
53
53
|
reflectSelfParams<T>(type: Type<T>): any[];
|
|
54
54
|
resolveSingleParam<T>(wrapper: InstanceWrapper<T>, param: Type<any> | string | symbol | any, dependencyContext: InjectorDependencyContext, moduleRef: Module, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number): Promise<InstanceWrapper<any>>;
|
|
55
55
|
resolveParamToken<T>(wrapper: InstanceWrapper<T>, param: Type<any> | string | symbol | any): any;
|
|
56
56
|
resolveComponentInstance<T>(moduleRef: Module, name: any, dependencyContext: InjectorDependencyContext, wrapper: InstanceWrapper<T>, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number): Promise<InstanceWrapper>;
|
|
57
|
-
resolveComponentHost<T>(moduleRef: Module, instanceWrapper: InstanceWrapper<T
|
|
57
|
+
resolveComponentHost<T>(moduleRef: Module, instanceWrapper: InstanceWrapper<T | Promise<T>>, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<InstanceWrapper>;
|
|
58
58
|
lookupComponent<T = any>(providers: Map<string | symbol, InstanceWrapper>, moduleRef: Module, dependencyContext: InjectorDependencyContext, wrapper: InstanceWrapper<T>, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number): Promise<InstanceWrapper<T>>;
|
|
59
59
|
lookupComponentInParentModules<T = any>(dependencyContext: InjectorDependencyContext, moduleRef: Module, wrapper: InstanceWrapper<T>, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number): Promise<any>;
|
|
60
60
|
lookupComponentInImports(moduleRef: Module, name: any, wrapper: InstanceWrapper, moduleRegistry?: any[], contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number, isTraversing?: boolean): Promise<any>;
|
package/injector/injector.js
CHANGED
|
@@ -11,33 +11,6 @@ const constants_2 = require("./constants");
|
|
|
11
11
|
const inquirer_1 = require("./inquirer");
|
|
12
12
|
const instance_wrapper_1 = require("./instance-wrapper");
|
|
13
13
|
class Injector {
|
|
14
|
-
async loadMiddleware(wrapper, collection, moduleRef, contextId = constants_2.STATIC_CONTEXT, inquirer) {
|
|
15
|
-
const { metatype } = wrapper;
|
|
16
|
-
const targetWrapper = collection.get(metatype.name);
|
|
17
|
-
if (!shared_utils_1.isUndefined(targetWrapper.instance)) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const loadInstance = (instances) => {
|
|
21
|
-
targetWrapper.instance = targetWrapper.isDependencyTreeStatic()
|
|
22
|
-
? new metatype(...instances)
|
|
23
|
-
: Object.create(metatype.prototype);
|
|
24
|
-
};
|
|
25
|
-
await this.resolveConstructorParams(wrapper, moduleRef, null, loadInstance, contextId, inquirer);
|
|
26
|
-
}
|
|
27
|
-
async loadController(wrapper, moduleRef, contextId = constants_2.STATIC_CONTEXT) {
|
|
28
|
-
const controllers = moduleRef.controllers;
|
|
29
|
-
await this.loadInstance(wrapper, controllers, moduleRef, contextId, wrapper);
|
|
30
|
-
await this.loadEnhancersPerContext(wrapper, contextId, wrapper);
|
|
31
|
-
}
|
|
32
|
-
async loadInjectable(wrapper, moduleRef, contextId = constants_2.STATIC_CONTEXT, inquirer) {
|
|
33
|
-
const injectables = moduleRef.injectables;
|
|
34
|
-
await this.loadInstance(wrapper, injectables, moduleRef, contextId, inquirer);
|
|
35
|
-
}
|
|
36
|
-
async loadProvider(wrapper, moduleRef, contextId = constants_2.STATIC_CONTEXT, inquirer) {
|
|
37
|
-
const providers = moduleRef.providers;
|
|
38
|
-
await this.loadInstance(wrapper, providers, moduleRef, contextId, inquirer);
|
|
39
|
-
await this.loadEnhancersPerContext(wrapper, contextId, wrapper);
|
|
40
|
-
}
|
|
41
14
|
loadPrototype({ name }, collection, contextId = constants_2.STATIC_CONTEXT) {
|
|
42
15
|
if (!collection) {
|
|
43
16
|
return;
|
|
@@ -49,14 +22,6 @@ class Injector {
|
|
|
49
22
|
collection.set(name, wrapper);
|
|
50
23
|
}
|
|
51
24
|
}
|
|
52
|
-
applyDoneHook(wrapper) {
|
|
53
|
-
let done;
|
|
54
|
-
wrapper.donePromise = new Promise((resolve, reject) => {
|
|
55
|
-
done = resolve;
|
|
56
|
-
});
|
|
57
|
-
wrapper.isPending = true;
|
|
58
|
-
return done;
|
|
59
|
-
}
|
|
60
25
|
async loadInstance(wrapper, collection, moduleRef, contextId = constants_2.STATIC_CONTEXT, inquirer) {
|
|
61
26
|
const inquirerId = this.getInquirerId(inquirer);
|
|
62
27
|
const instanceHost = wrapper.getInstanceByContextId(contextId, inquirerId);
|
|
@@ -80,6 +45,37 @@ class Injector {
|
|
|
80
45
|
};
|
|
81
46
|
await this.resolveConstructorParams(wrapper, moduleRef, inject, callback, contextId, wrapper, inquirer);
|
|
82
47
|
}
|
|
48
|
+
async loadMiddleware(wrapper, collection, moduleRef, contextId = constants_2.STATIC_CONTEXT, inquirer) {
|
|
49
|
+
const { metatype } = wrapper;
|
|
50
|
+
const targetWrapper = collection.get(metatype.name);
|
|
51
|
+
if (!shared_utils_1.isUndefined(targetWrapper.instance)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
targetWrapper.instance = Object.create(metatype.prototype);
|
|
55
|
+
await this.loadInstance(wrapper, collection, moduleRef, contextId, inquirer || wrapper);
|
|
56
|
+
}
|
|
57
|
+
async loadController(wrapper, moduleRef, contextId = constants_2.STATIC_CONTEXT) {
|
|
58
|
+
const controllers = moduleRef.controllers;
|
|
59
|
+
await this.loadInstance(wrapper, controllers, moduleRef, contextId, wrapper);
|
|
60
|
+
await this.loadEnhancersPerContext(wrapper, contextId, wrapper);
|
|
61
|
+
}
|
|
62
|
+
async loadInjectable(wrapper, moduleRef, contextId = constants_2.STATIC_CONTEXT, inquirer) {
|
|
63
|
+
const injectables = moduleRef.injectables;
|
|
64
|
+
await this.loadInstance(wrapper, injectables, moduleRef, contextId, inquirer);
|
|
65
|
+
}
|
|
66
|
+
async loadProvider(wrapper, moduleRef, contextId = constants_2.STATIC_CONTEXT, inquirer) {
|
|
67
|
+
const providers = moduleRef.providers;
|
|
68
|
+
await this.loadInstance(wrapper, providers, moduleRef, contextId, inquirer);
|
|
69
|
+
await this.loadEnhancersPerContext(wrapper, contextId, wrapper);
|
|
70
|
+
}
|
|
71
|
+
applyDoneHook(wrapper) {
|
|
72
|
+
let done;
|
|
73
|
+
wrapper.donePromise = new Promise((resolve, reject) => {
|
|
74
|
+
done = resolve;
|
|
75
|
+
});
|
|
76
|
+
wrapper.isPending = true;
|
|
77
|
+
return done;
|
|
78
|
+
}
|
|
83
79
|
async resolveConstructorParams(wrapper, moduleRef, inject, callback, contextId = constants_2.STATIC_CONTEXT, inquirer, parentInquirer) {
|
|
84
80
|
const inquirerId = this.getInquirerId(inquirer);
|
|
85
81
|
const metadata = wrapper.getCtorMetadata();
|
|
@@ -104,7 +100,7 @@ class Injector {
|
|
|
104
100
|
if (!instanceHost.isResolved && !paramWrapper.forwardRef) {
|
|
105
101
|
isResolved = false;
|
|
106
102
|
}
|
|
107
|
-
return instanceHost
|
|
103
|
+
return instanceHost === null || instanceHost === void 0 ? void 0 : instanceHost.instance;
|
|
108
104
|
}
|
|
109
105
|
catch (err) {
|
|
110
106
|
const isOptional = optionalDependenciesIds.includes(index);
|
|
@@ -39,11 +39,15 @@ class ModuleTokenFactory {
|
|
|
39
39
|
}
|
|
40
40
|
replacer(key, value) {
|
|
41
41
|
if (typeof value === 'function') {
|
|
42
|
-
const
|
|
42
|
+
const funcAsString = value.toString();
|
|
43
|
+
const isClass = /^class\s/.test(funcAsString);
|
|
43
44
|
if (isClass) {
|
|
44
45
|
return value.name;
|
|
45
46
|
}
|
|
46
|
-
return hash(
|
|
47
|
+
return hash(funcAsString, { ignoreUnknown: true });
|
|
48
|
+
}
|
|
49
|
+
if (typeof value === 'symbol') {
|
|
50
|
+
return value.toString();
|
|
47
51
|
}
|
|
48
52
|
return value;
|
|
49
53
|
}
|
|
@@ -81,6 +81,9 @@ class MiddlewareModule {
|
|
|
81
81
|
if (shared_utils_1.isUndefined(instanceWrapper)) {
|
|
82
82
|
throw new runtime_exception_1.RuntimeException();
|
|
83
83
|
}
|
|
84
|
+
if (instanceWrapper.isTransient) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
84
87
|
await this.bindHandler(instanceWrapper, applicationRef, routeInfo.method, routeInfo.path, moduleRef, collection);
|
|
85
88
|
}
|
|
86
89
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.4",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"uuid": "8.3.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@nestjs/common": "7.6.
|
|
39
|
+
"@nestjs/common": "7.6.4"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@nestjs/common": "^7.0.0",
|