@nestjs/core 8.4.3 → 8.4.6
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/Readme.md +7 -4
- package/adapters/http-adapter.d.ts +1 -1
- package/helpers/context-id-factory.d.ts +1 -1
- package/helpers/context-id-factory.js +8 -5
- package/index.js +1 -1
- package/injector/container.js +3 -3
- package/injector/injector.d.ts +7 -7
- package/injector/injector.js +6 -3
- package/injector/instance-wrapper.d.ts +2 -2
- package/nest-application-context.d.ts +1 -1
- package/nest-application-context.js +2 -2
- package/nest-application.js +4 -1
- package/package.json +3 -3
- package/router/router-explorer.js +20 -5
- package/router/sse-stream.d.ts +2 -0
package/Readme.md
CHANGED
|
@@ -64,17 +64,20 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
|
|
|
64
64
|
<a href="https://github.com/Sanofi-IADC" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/sanofi.png" width="180" valign="middle" /></a></td>
|
|
65
65
|
<td>
|
|
66
66
|
<a href="https://nx.dev" target="_blank"><img src="https://nestjs.com/img/nx-logo.png" height="45" valign="middle" /></a></td>
|
|
67
|
+
<td>
|
|
68
|
+
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td>
|
|
67
69
|
</tr></table>
|
|
68
70
|
|
|
69
71
|
#### Gold Sponsors
|
|
70
72
|
|
|
71
73
|
<table style="text-align:center;"><tr><td>
|
|
72
74
|
<a href="https://careers.labster.com/departments/platform" target="_blank"><img src="https://nestjs.com/img/labster-logo.png" width="170" valign="middle" /></a></td><td>
|
|
73
|
-
<a href="https://weld.app/" target="_blank"><img src="https://nestjs.com/img/weld-logo.svg" width="
|
|
74
|
-
<td>
|
|
75
|
-
<a href="https://valor-software.com/" target="_blank"><img src="https://docs.nestjs.com/assets/sponsors/valor-software.png" width="170" valign="middle" /></a></td>
|
|
75
|
+
<a href="https://weld.app/" target="_blank"><img src="https://nestjs.com/img/weld-logo.svg" width="140" valign="middle" /></a></td>
|
|
76
76
|
<td>
|
|
77
|
-
<a href="https://intrinsic.ventures/" target="_blank"><img src="https://nestjs.com/img/intrinisic-logo.png" width="210" valign="middle" /></a></td
|
|
77
|
+
<a href="https://intrinsic.ventures/" target="_blank"><img src="https://nestjs.com/img/intrinisic-logo.png" width="210" valign="middle" /></a></td>
|
|
78
|
+
<td>
|
|
79
|
+
<a href="https://jetbrains.com/" target="_blank"><img src="https://nestjs.com/img/jetbrains-logo.svg" width="110" valign="middle" /></a></td><td>
|
|
80
|
+
<a href="https://snyk.co/nestjs" target="_blank"><img src="https://nestjs.com/img/snyk-logo-black.png" width="185" valign="middle" /></a></td></</tr></table>
|
|
78
81
|
|
|
79
82
|
#### Silver Sponsors
|
|
80
83
|
|
|
@@ -47,7 +47,7 @@ export declare abstract class AbstractHttpAdapter<TServer = any, TRequest = any,
|
|
|
47
47
|
abstract setErrorHandler(handler: Function, prefix?: string): any;
|
|
48
48
|
abstract setNotFoundHandler(handler: Function, prefix?: string): any;
|
|
49
49
|
abstract setHeader(response: any, name: string, value: string): any;
|
|
50
|
-
abstract registerParserMiddleware(prefix?: string): any;
|
|
50
|
+
abstract registerParserMiddleware(prefix?: string, rawBody?: boolean): any;
|
|
51
51
|
abstract enableCors(options: CorsOptions | CorsOptionsDelegate<TRequest>, prefix?: string): any;
|
|
52
52
|
abstract createMiddlewareFactory(requestMethod: RequestMethod): ((path: string, callback: Function) => any) | Promise<(path: string, callback: Function) => any>;
|
|
53
53
|
abstract getType(): string;
|
|
@@ -9,5 +9,5 @@ export declare class ContextIdFactory {
|
|
|
9
9
|
* Generates a random identifier to track asynchronous execution context.
|
|
10
10
|
* @param request request object
|
|
11
11
|
*/
|
|
12
|
-
static getByRequest<T extends Record<any, any> = any>(request: T): ContextId;
|
|
12
|
+
static getByRequest<T extends Record<any, any> = any>(request: T, propsToInspect?: string[]): ContextId;
|
|
13
13
|
}
|
|
@@ -25,17 +25,20 @@ class ContextIdFactory {
|
|
|
25
25
|
* Generates a random identifier to track asynchronous execution context.
|
|
26
26
|
* @param request request object
|
|
27
27
|
*/
|
|
28
|
-
static getByRequest(request) {
|
|
28
|
+
static getByRequest(request, propsToInspect = ['raw']) {
|
|
29
|
+
var _a;
|
|
29
30
|
if (!request) {
|
|
30
|
-
return
|
|
31
|
+
return ContextIdFactory.create();
|
|
31
32
|
}
|
|
32
33
|
if (request[request_constants_1.REQUEST_CONTEXT_ID]) {
|
|
33
34
|
return request[request_constants_1.REQUEST_CONTEXT_ID];
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
for (const key of propsToInspect) {
|
|
37
|
+
if ((_a = request[key]) === null || _a === void 0 ? void 0 : _a[request_constants_1.REQUEST_CONTEXT_ID]) {
|
|
38
|
+
return request[key][request_constants_1.REQUEST_CONTEXT_ID];
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
|
-
return
|
|
41
|
+
return ContextIdFactory.create();
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
exports.ContextIdFactory = ContextIdFactory;
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.NestFactory = exports.APP_PIPE = exports.APP_INTERCEPTOR = exports.APP_G
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
/*
|
|
6
6
|
* Nest @core
|
|
7
|
-
* Copyright(c) 2017 -
|
|
7
|
+
* Copyright(c) 2017 - 2022 Kamil Mysliwiec
|
|
8
8
|
* https://nestjs.com
|
|
9
9
|
* MIT Licensed
|
|
10
10
|
*/
|
package/injector/container.js
CHANGED
|
@@ -103,13 +103,13 @@ class NestContainer {
|
|
|
103
103
|
moduleRef.addRelatedModule(related);
|
|
104
104
|
}
|
|
105
105
|
addProvider(provider, token) {
|
|
106
|
+
const moduleRef = this.modules.get(token);
|
|
106
107
|
if (!provider) {
|
|
107
|
-
throw new circular_dependency_exception_1.CircularDependencyException();
|
|
108
|
+
throw new circular_dependency_exception_1.CircularDependencyException(moduleRef === null || moduleRef === void 0 ? void 0 : moduleRef.metatype.name);
|
|
108
109
|
}
|
|
109
|
-
if (!
|
|
110
|
+
if (!moduleRef) {
|
|
110
111
|
throw new unknown_module_exception_1.UnknownModuleException();
|
|
111
112
|
}
|
|
112
|
-
const moduleRef = this.modules.get(token);
|
|
113
113
|
return moduleRef.addProvider(provider);
|
|
114
114
|
}
|
|
115
115
|
addInjectable(injectable, token, host) {
|
package/injector/injector.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare type InjectorDependency = InjectionToken;
|
|
|
12
12
|
* The property-based dependency
|
|
13
13
|
*/
|
|
14
14
|
export interface PropertyDependency {
|
|
15
|
-
key: string;
|
|
15
|
+
key: symbol | string;
|
|
16
16
|
name: InjectorDependency;
|
|
17
17
|
isOptional?: boolean;
|
|
18
18
|
instance?: any;
|
|
@@ -55,13 +55,13 @@ export declare class Injector {
|
|
|
55
55
|
reflectConstructorParams<T>(type: Type<T>): any[];
|
|
56
56
|
reflectOptionalParams<T>(type: Type<T>): any[];
|
|
57
57
|
reflectSelfParams<T>(type: Type<T>): any[];
|
|
58
|
-
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>>;
|
|
58
|
+
resolveSingleParam<T>(wrapper: InstanceWrapper<T>, param: Type<any> | string | symbol | any, dependencyContext: InjectorDependencyContext, moduleRef: Module, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: symbol | string | number): Promise<InstanceWrapper<any>>;
|
|
59
59
|
resolveParamToken<T>(wrapper: InstanceWrapper<T>, param: Type<any> | string | symbol | any): any;
|
|
60
|
-
resolveComponentInstance<T>(moduleRef: Module, token: InstanceToken, dependencyContext: InjectorDependencyContext, wrapper: InstanceWrapper<T>, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number): Promise<InstanceWrapper>;
|
|
60
|
+
resolveComponentInstance<T>(moduleRef: Module, token: InstanceToken, dependencyContext: InjectorDependencyContext, wrapper: InstanceWrapper<T>, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: symbol | string | number): Promise<InstanceWrapper>;
|
|
61
61
|
resolveComponentHost<T>(moduleRef: Module, instanceWrapper: InstanceWrapper<T | Promise<T>>, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<InstanceWrapper>;
|
|
62
|
-
lookupComponent<T = any>(providers: Map<Function | string | symbol, InstanceWrapper>, moduleRef: Module, dependencyContext: InjectorDependencyContext, wrapper: InstanceWrapper<T>, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number): Promise<InstanceWrapper<T>>;
|
|
63
|
-
lookupComponentInParentModules<T = any>(dependencyContext: InjectorDependencyContext, moduleRef: Module, wrapper: InstanceWrapper<T>, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number): Promise<any>;
|
|
64
|
-
lookupComponentInImports(moduleRef: Module, name: InstanceToken, wrapper: InstanceWrapper, moduleRegistry?: any[], contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number, isTraversing?: boolean): Promise<any>;
|
|
62
|
+
lookupComponent<T = any>(providers: Map<Function | string | symbol, InstanceWrapper>, moduleRef: Module, dependencyContext: InjectorDependencyContext, wrapper: InstanceWrapper<T>, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: symbol | string | number): Promise<InstanceWrapper<T>>;
|
|
63
|
+
lookupComponentInParentModules<T = any>(dependencyContext: InjectorDependencyContext, moduleRef: Module, wrapper: InstanceWrapper<T>, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: symbol | string | number): Promise<any>;
|
|
64
|
+
lookupComponentInImports(moduleRef: Module, name: InstanceToken, wrapper: InstanceWrapper, moduleRegistry?: any[], contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: symbol | string | number, isTraversing?: boolean): Promise<any>;
|
|
65
65
|
resolveProperties<T>(wrapper: InstanceWrapper<T>, moduleRef: Module, inject?: InjectorDependency[], contextId?: ContextId, inquirer?: InstanceWrapper, parentInquirer?: InstanceWrapper): Promise<PropertyDependency[]>;
|
|
66
66
|
reflectProperties<T>(type: Type<T>): PropertyDependency[];
|
|
67
67
|
applyProperties<T = any>(instance: T, properties: PropertyDependency[]): void;
|
|
@@ -74,7 +74,7 @@ export declare class Injector {
|
|
|
74
74
|
private resolveScopedComponentHost;
|
|
75
75
|
private isInquirerRequest;
|
|
76
76
|
private isInquirer;
|
|
77
|
-
protected addDependencyMetadata(keyOrIndex:
|
|
77
|
+
protected addDependencyMetadata(keyOrIndex: symbol | string | number, hostWrapper: InstanceWrapper, instanceWrapper: InstanceWrapper): void;
|
|
78
78
|
private getTokenName;
|
|
79
79
|
private printResolvingDependenciesLog;
|
|
80
80
|
private printLookingForProviderLog;
|
package/injector/injector.js
CHANGED
|
@@ -386,9 +386,12 @@ class Injector {
|
|
|
386
386
|
return param === inquirer_1.INQUIRER && parentInquirer;
|
|
387
387
|
}
|
|
388
388
|
addDependencyMetadata(keyOrIndex, hostWrapper, instanceWrapper) {
|
|
389
|
-
(0, shared_utils_1.isString)(keyOrIndex)
|
|
390
|
-
|
|
391
|
-
|
|
389
|
+
if ((0, shared_utils_1.isSymbol)(keyOrIndex) || (0, shared_utils_1.isString)(keyOrIndex)) {
|
|
390
|
+
hostWrapper.addPropertiesMetadata(keyOrIndex, instanceWrapper);
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
hostWrapper.addCtorMetadata(keyOrIndex, instanceWrapper);
|
|
394
|
+
}
|
|
392
395
|
}
|
|
393
396
|
getTokenName(token) {
|
|
394
397
|
return (0, shared_utils_1.isFunction)(token) ? token.name : token.toString();
|
|
@@ -13,7 +13,7 @@ export interface InstancePerContext<T> {
|
|
|
13
13
|
donePromise?: Promise<void>;
|
|
14
14
|
}
|
|
15
15
|
export interface PropertyMetadata {
|
|
16
|
-
key: string;
|
|
16
|
+
key: symbol | string;
|
|
17
17
|
wrapper: InstanceWrapper;
|
|
18
18
|
}
|
|
19
19
|
export declare class InstanceWrapper<T = any> {
|
|
@@ -43,7 +43,7 @@ export declare class InstanceWrapper<T = any> {
|
|
|
43
43
|
setInstanceByInquirerId(contextId: ContextId, inquirerId: string, value: InstancePerContext<T>): void;
|
|
44
44
|
addCtorMetadata(index: number, wrapper: InstanceWrapper): void;
|
|
45
45
|
getCtorMetadata(): InstanceWrapper[];
|
|
46
|
-
addPropertiesMetadata(key: string, wrapper: InstanceWrapper): void;
|
|
46
|
+
addPropertiesMetadata(key: symbol | string, wrapper: InstanceWrapper): void;
|
|
47
47
|
getPropertiesMetadata(): PropertyMetadata[];
|
|
48
48
|
addEnhancerMetadata(wrapper: InstanceWrapper): void;
|
|
49
49
|
getEnhancersMetadata(): InstanceWrapper[];
|
|
@@ -32,7 +32,7 @@ export declare class NestApplicationContext implements INestApplicationContext {
|
|
|
32
32
|
}): Promise<TResult>;
|
|
33
33
|
registerRequestByContextId<T = any>(request: T, contextId: ContextId): void;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Initializes the Nest application.
|
|
36
36
|
* Calls the Nest lifecycle events.
|
|
37
37
|
*
|
|
38
38
|
* @returns {Promise<this>} The NestApplicationContext instance as Promise
|
|
@@ -63,7 +63,7 @@ class NestApplicationContext {
|
|
|
63
63
|
this.container.registerRequestProvider(request, contextId);
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* Initializes the Nest application.
|
|
67
67
|
* Calls the Nest lifecycle events.
|
|
68
68
|
*
|
|
69
69
|
* @returns {Promise<this>} The NestApplicationContext instance as Promise
|
|
@@ -237,7 +237,7 @@ class NestApplicationContext {
|
|
|
237
237
|
return this.get(typeOrToken, options);
|
|
238
238
|
}
|
|
239
239
|
const ctorHost = wrapperRef.instance || { constructor: typeOrToken };
|
|
240
|
-
const instance = await this.injector.loadPerContext(ctorHost, wrapperRef.host, collection, contextId);
|
|
240
|
+
const instance = await this.injector.loadPerContext(ctorHost, wrapperRef.host, collection, contextId, wrapperRef);
|
|
241
241
|
if (!instance) {
|
|
242
242
|
throw new unknown_element_exception_1.UnknownElementException();
|
|
243
243
|
}
|
package/nest-application.js
CHANGED
|
@@ -101,7 +101,10 @@ class NestApplication extends nest_application_context_1.NestApplicationContext
|
|
|
101
101
|
return this;
|
|
102
102
|
}
|
|
103
103
|
registerParserMiddleware() {
|
|
104
|
-
|
|
104
|
+
var _a;
|
|
105
|
+
const prefix = this.config.getGlobalPrefix();
|
|
106
|
+
const rawBody = !!((_a = this.appOptions) === null || _a === void 0 ? void 0 : _a.rawBody);
|
|
107
|
+
this.httpAdapter.registerParserMiddleware(prefix, rawBody);
|
|
105
108
|
}
|
|
106
109
|
async registerRouter() {
|
|
107
110
|
await this.registerMiddleware(this.httpAdapter);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/core",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.6",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"iterare": "1.2.1",
|
|
33
33
|
"object-hash": "3.0.0",
|
|
34
34
|
"path-to-regexp": "3.2.0",
|
|
35
|
-
"tslib": "2.
|
|
35
|
+
"tslib": "2.4.0",
|
|
36
36
|
"uuid": "8.3.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@nestjs/common": "8.4.
|
|
39
|
+
"@nestjs/common": "8.4.6"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@nestjs/common": "^8.0.0",
|
|
@@ -166,8 +166,7 @@ class RouterExplorer {
|
|
|
166
166
|
return router.applyVersionFilter(handler, version, versioningOptions);
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
|
-
* This
|
|
170
|
-
* Left for backward-compatibility.
|
|
169
|
+
* TODO(v9): This was left for backward-compatibility and can be removed.
|
|
171
170
|
*/
|
|
172
171
|
return (req, res, next) => {
|
|
173
172
|
var _a, _b, _c, _d;
|
|
@@ -209,8 +208,16 @@ class RouterExplorer {
|
|
|
209
208
|
((_b = req.headers) === null || _b === void 0 ? void 0 : _b[MEDIA_TYPE_HEADER.toLowerCase()]);
|
|
210
209
|
const acceptHeaderVersionParameter = acceptHeaderValue
|
|
211
210
|
? acceptHeaderValue.split(';')[1]
|
|
212
|
-
:
|
|
213
|
-
|
|
211
|
+
: undefined;
|
|
212
|
+
// No version was supplied
|
|
213
|
+
if ((0, shared_utils_1.isUndefined)(acceptHeaderVersionParameter)) {
|
|
214
|
+
if (Array.isArray(version)) {
|
|
215
|
+
if (version.includes(version_options_interface_1.VERSION_NEUTRAL)) {
|
|
216
|
+
return handler(req, res, next);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
214
221
|
const headerVersion = acceptHeaderVersionParameter.split(versioningOptions.key)[1];
|
|
215
222
|
if (Array.isArray(version)) {
|
|
216
223
|
if (version.includes(headerVersion)) {
|
|
@@ -228,7 +235,15 @@ class RouterExplorer {
|
|
|
228
235
|
else if (versioningOptions.type === version_type_enum_1.VersioningType.HEADER) {
|
|
229
236
|
const customHeaderVersionParameter = ((_c = req.headers) === null || _c === void 0 ? void 0 : _c[versioningOptions.header]) ||
|
|
230
237
|
((_d = req.headers) === null || _d === void 0 ? void 0 : _d[versioningOptions.header.toLowerCase()]);
|
|
231
|
-
|
|
238
|
+
// No version was supplied
|
|
239
|
+
if ((0, shared_utils_1.isUndefined)(customHeaderVersionParameter)) {
|
|
240
|
+
if (Array.isArray(version)) {
|
|
241
|
+
if (version.includes(version_options_interface_1.VERSION_NEUTRAL)) {
|
|
242
|
+
return handler(req, res, next);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
232
247
|
if (Array.isArray(version)) {
|
|
233
248
|
if (version.includes(customHeaderVersionParameter)) {
|
|
234
249
|
return handler(req, res, next);
|
package/router/sse-stream.d.ts
CHANGED