@nestjs/core 10.4.10 → 11.0.0-next.1
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 +14 -0
- package/adapters/http-adapter.js +21 -1
- package/errors/exception-handler.d.ts +1 -2
- package/errors/exception-handler.js +1 -6
- package/errors/exceptions/undefined-dependency.exception.d.ts +2 -2
- package/errors/exceptions/undefined-dependency.exception.js +2 -2
- package/errors/exceptions/unknown-dependencies.exception.d.ts +2 -2
- package/errors/exceptions-zone.d.ts +2 -2
- package/errors/messages.d.ts +2 -2
- package/errors/messages.js +3 -3
- package/exceptions/base-exception-filter-context.js +1 -1
- package/exceptions/base-exception-filter.d.ts +2 -2
- package/exceptions/base-exception-filter.js +2 -3
- package/exceptions/exceptions-handler.d.ts +2 -2
- package/exceptions/exceptions-handler.js +2 -2
- package/exceptions/external-exception-filter-context.d.ts +1 -1
- package/exceptions/external-exception-filter-context.js +1 -1
- package/exceptions/external-exception-filter.js +3 -2
- package/exceptions/external-exceptions-handler.d.ts +2 -2
- package/exceptions/external-exceptions-handler.js +2 -2
- package/guards/guards-context-creator.d.ts +1 -1
- package/guards/guards-context-creator.js +2 -2
- package/helpers/execution-context-host.d.ts +1 -1
- package/helpers/external-context-creator.d.ts +1 -1
- package/helpers/external-context-creator.js +8 -8
- package/helpers/router-method-factory.js +7 -0
- package/injector/abstract-instance-resolver.js +2 -2
- package/injector/compiler.d.ts +9 -8
- package/injector/compiler.js +20 -14
- package/injector/container.d.ts +8 -7
- package/injector/container.js +13 -5
- package/injector/helpers/silent-logger.js +0 -1
- package/injector/injector.d.ts +5 -5
- package/injector/injector.js +7 -7
- package/injector/inquirer/inquirer-providers.js +0 -1
- package/injector/instance-wrapper.d.ts +4 -4
- package/injector/instance-wrapper.js +4 -4
- package/injector/lazy-module-loader/lazy-module-loader.d.ts +1 -1
- package/injector/module-ref.js +1 -0
- package/injector/module.d.ts +2 -2
- package/injector/module.js +7 -3
- package/inspector/noop-graph-inspector.js +0 -1
- package/inspector/serialized-graph.d.ts +2 -2
- package/interceptors/interceptors-context-creator.d.ts +1 -1
- package/interceptors/interceptors-context-creator.js +2 -2
- package/metadata-scanner.d.ts +1 -1
- package/middleware/builder.d.ts +1 -1
- package/middleware/builder.js +2 -3
- package/middleware/middleware-module.js +1 -1
- package/middleware/route-info-path-extractor.js +6 -2
- package/middleware/utils.js +22 -11
- package/nest-application-context.d.ts +3 -3
- package/nest-application-context.js +16 -6
- package/nest-application.js +2 -2
- package/nest-factory.d.ts +7 -5
- package/nest-factory.js +1 -1
- package/package.json +3 -3
- package/pipes/pipes-context-creator.d.ts +1 -1
- package/pipes/pipes-context-creator.js +2 -2
- package/repl/assign-to-object.util.d.ts +1 -1
- package/router/interfaces/route-params-factory.interface.d.ts +1 -1
- package/router/legacy-route-converter.d.ts +13 -0
- package/router/legacy-route-converter.js +48 -0
- package/router/request/request-providers.js +0 -1
- package/router/route-params-factory.d.ts +2 -2
- package/router/route-params-factory.js +1 -0
- package/router/route-path-factory.d.ts +1 -1
- package/router/router-exception-filters.d.ts +1 -1
- package/router/router-exception-filters.js +1 -1
- package/router/router-execution-context.d.ts +2 -2
- package/router/router-execution-context.js +1 -1
- package/router/router-explorer.js +24 -5
- package/router/router-proxy.d.ts +3 -3
- package/router/sse-stream.js +1 -1
- package/router/utils/flatten-route-paths.util.d.ts +5 -1
- package/scanner.d.ts +2 -2
- package/scanner.js +6 -6
- package/services/reflector.service.d.ts +3 -3
- package/services/reflector.service.js +7 -0
|
@@ -23,6 +23,20 @@ export declare abstract class AbstractHttpAdapter<TServer = any, TRequest = any,
|
|
|
23
23
|
put(path: any, handler: RequestHandler): any;
|
|
24
24
|
patch(handler: RequestHandler): any;
|
|
25
25
|
patch(path: any, handler: RequestHandler): any;
|
|
26
|
+
propfind(handler: RequestHandler): any;
|
|
27
|
+
propfind(path: any, handler: RequestHandler): any;
|
|
28
|
+
proppatch(handler: RequestHandler): any;
|
|
29
|
+
proppatch(path: any, handler: RequestHandler): any;
|
|
30
|
+
mkcol(handler: RequestHandler): any;
|
|
31
|
+
mkcol(path: any, handler: RequestHandler): any;
|
|
32
|
+
copy(handler: RequestHandler): any;
|
|
33
|
+
copy(path: any, handler: RequestHandler): any;
|
|
34
|
+
move(handler: RequestHandler): any;
|
|
35
|
+
move(path: any, handler: RequestHandler): any;
|
|
36
|
+
lock(handler: RequestHandler): any;
|
|
37
|
+
lock(path: any, handler: RequestHandler): any;
|
|
38
|
+
unlock(handler: RequestHandler): any;
|
|
39
|
+
unlock(path: any, handler: RequestHandler): any;
|
|
26
40
|
all(handler: RequestHandler): any;
|
|
27
41
|
all(path: any, handler: RequestHandler): any;
|
|
28
42
|
search(handler: RequestHandler): any;
|
package/adapters/http-adapter.js
CHANGED
|
@@ -8,7 +8,6 @@ class AbstractHttpAdapter {
|
|
|
8
8
|
constructor(instance) {
|
|
9
9
|
this.instance = instance;
|
|
10
10
|
}
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
12
11
|
async init() { }
|
|
13
12
|
use(...args) {
|
|
14
13
|
return this.instance.use(...args);
|
|
@@ -31,6 +30,27 @@ class AbstractHttpAdapter {
|
|
|
31
30
|
patch(...args) {
|
|
32
31
|
return this.instance.patch(...args);
|
|
33
32
|
}
|
|
33
|
+
propfind(...args) {
|
|
34
|
+
return this.instance.propfind(...args);
|
|
35
|
+
}
|
|
36
|
+
proppatch(...args) {
|
|
37
|
+
return this.instance.proppatch(...args);
|
|
38
|
+
}
|
|
39
|
+
mkcol(...args) {
|
|
40
|
+
return this.instance.mkcol(...args);
|
|
41
|
+
}
|
|
42
|
+
copy(...args) {
|
|
43
|
+
return this.instance.copy(...args);
|
|
44
|
+
}
|
|
45
|
+
move(...args) {
|
|
46
|
+
return this.instance.move(...args);
|
|
47
|
+
}
|
|
48
|
+
lock(...args) {
|
|
49
|
+
return this.instance.lock(...args);
|
|
50
|
+
}
|
|
51
|
+
unlock(...args) {
|
|
52
|
+
return this.instance.unlock(...args);
|
|
53
|
+
}
|
|
34
54
|
all(...args) {
|
|
35
55
|
return this.instance.all(...args);
|
|
36
56
|
}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExceptionHandler = void 0;
|
|
4
|
-
const runtime_exception_1 = require("./exceptions/runtime.exception");
|
|
5
4
|
const logger_service_1 = require("@nestjs/common/services/logger.service");
|
|
6
5
|
class ExceptionHandler {
|
|
7
6
|
handle(exception) {
|
|
8
|
-
|
|
9
|
-
ExceptionHandler.logger.error(exception.message, exception.stack);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
ExceptionHandler.logger.error(exception.what(), exception.stack);
|
|
7
|
+
ExceptionHandler.logger.error(exception);
|
|
13
8
|
}
|
|
14
9
|
}
|
|
15
10
|
exports.ExceptionHandler = ExceptionHandler;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InjectorDependencyContext } from '../../injector/injector';
|
|
2
|
-
import { RuntimeException } from './runtime.exception';
|
|
3
2
|
import { Module } from '../../injector/module';
|
|
3
|
+
import { RuntimeException } from './runtime.exception';
|
|
4
4
|
export declare class UndefinedDependencyException extends RuntimeException {
|
|
5
|
-
constructor(type: string, undefinedDependencyContext: InjectorDependencyContext,
|
|
5
|
+
constructor(type: string, undefinedDependencyContext: InjectorDependencyContext, moduleRef?: Module);
|
|
6
6
|
}
|
|
@@ -4,8 +4,8 @@ exports.UndefinedDependencyException = void 0;
|
|
|
4
4
|
const messages_1 = require("../messages");
|
|
5
5
|
const runtime_exception_1 = require("./runtime.exception");
|
|
6
6
|
class UndefinedDependencyException extends runtime_exception_1.RuntimeException {
|
|
7
|
-
constructor(type, undefinedDependencyContext,
|
|
8
|
-
super((0, messages_1.UNKNOWN_DEPENDENCIES_MESSAGE)(type, undefinedDependencyContext,
|
|
7
|
+
constructor(type, undefinedDependencyContext, moduleRef) {
|
|
8
|
+
super((0, messages_1.UNKNOWN_DEPENDENCIES_MESSAGE)(type, undefinedDependencyContext, moduleRef));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
exports.UndefinedDependencyException = UndefinedDependencyException;
|
|
@@ -6,11 +6,11 @@ export declare class UnknownDependenciesException extends RuntimeException {
|
|
|
6
6
|
readonly context: InjectorDependencyContext;
|
|
7
7
|
readonly metadata?: {
|
|
8
8
|
id: string;
|
|
9
|
-
};
|
|
9
|
+
} | undefined;
|
|
10
10
|
readonly moduleRef: {
|
|
11
11
|
id: string;
|
|
12
12
|
} | undefined;
|
|
13
13
|
constructor(type: string | symbol, context: InjectorDependencyContext, moduleRef?: Module, metadata?: {
|
|
14
14
|
id: string;
|
|
15
|
-
});
|
|
15
|
+
} | undefined);
|
|
16
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare class ExceptionsZone {
|
|
2
2
|
private static readonly exceptionHandler;
|
|
3
|
-
static run(callback: () => void, teardown: (err: any) => void, autoFlushLogs: boolean): void;
|
|
4
|
-
static asyncRun(callback: () => Promise<void>, teardown: (err: any) => void, autoFlushLogs: boolean): Promise<void>;
|
|
3
|
+
static run(callback: () => void, teardown: ((err: any) => void) | undefined, autoFlushLogs: boolean): void;
|
|
4
|
+
static asyncRun(callback: () => Promise<void>, teardown: ((err: any) => void) | undefined, autoFlushLogs: boolean): Promise<void>;
|
|
5
5
|
}
|
package/errors/messages.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { ForwardReference, Type } from '@nestjs/common';
|
|
2
2
|
import { InjectorDependencyContext } from '../injector/injector';
|
|
3
3
|
import { Module } from '../injector/module';
|
|
4
|
-
export declare const UNKNOWN_DEPENDENCIES_MESSAGE: (type: string | symbol, unknownDependencyContext: InjectorDependencyContext,
|
|
4
|
+
export declare const UNKNOWN_DEPENDENCIES_MESSAGE: (type: string | symbol, unknownDependencyContext: InjectorDependencyContext, moduleRef: Module | undefined) => string;
|
|
5
5
|
export declare const INVALID_MIDDLEWARE_MESSAGE: (text: TemplateStringsArray, name: string) => string;
|
|
6
6
|
export declare const UNDEFINED_FORWARDREF_MESSAGE: (scope: Type<any>[]) => string;
|
|
7
7
|
export declare const INVALID_MODULE_MESSAGE: (parentModule: any, index: number, scope: any[]) => string;
|
|
8
8
|
export declare const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE: (metatypeUsedAsAModule: Type | ForwardReference, scope: any[]) => string;
|
|
9
9
|
export declare const UNDEFINED_MODULE_MESSAGE: (parentModule: any, index: number, scope: any[]) => string;
|
|
10
|
-
export declare const UNKNOWN_EXPORT_MESSAGE: (token: string | symbol, module: string) => string;
|
|
10
|
+
export declare const UNKNOWN_EXPORT_MESSAGE: (token: (string | symbol) | undefined, module: string) => string;
|
|
11
11
|
export declare const INVALID_CLASS_MESSAGE: (text: TemplateStringsArray, value: any) => string;
|
|
12
12
|
export declare const INVALID_CLASS_SCOPE_MESSAGE: (text: TemplateStringsArray, name: string | undefined) => string;
|
|
13
13
|
export declare const UNKNOWN_REQUEST_MAPPING: (metatype: Type) => string;
|
package/errors/messages.js
CHANGED
|
@@ -44,9 +44,9 @@ getInstanceName(dependency) ||
|
|
|
44
44
|
*/
|
|
45
45
|
const getModuleName = (module) => (module && getInstanceName(module.metatype)) || 'current';
|
|
46
46
|
const stringifyScope = (scope) => (scope || []).map(getInstanceName).join(' -> ');
|
|
47
|
-
const UNKNOWN_DEPENDENCIES_MESSAGE = (type, unknownDependencyContext,
|
|
47
|
+
const UNKNOWN_DEPENDENCIES_MESSAGE = (type, unknownDependencyContext, moduleRef) => {
|
|
48
48
|
const { index, name, dependencies, key } = unknownDependencyContext;
|
|
49
|
-
const moduleName = getModuleName(
|
|
49
|
+
const moduleName = getModuleName(moduleRef);
|
|
50
50
|
const dependencyName = getDependencyName(name, 'dependency');
|
|
51
51
|
const potentialSolutions =
|
|
52
52
|
// If module's name is well defined
|
|
@@ -99,7 +99,7 @@ Scope [${stringifyScope(scope)}]`;
|
|
|
99
99
|
};
|
|
100
100
|
exports.INVALID_MODULE_MESSAGE = INVALID_MODULE_MESSAGE;
|
|
101
101
|
const USING_INVALID_CLASS_AS_A_MODULE_MESSAGE = (metatypeUsedAsAModule, scope) => {
|
|
102
|
-
const metatypeNameQuote = `"${getInstanceName(metatypeUsedAsAModule)}"
|
|
102
|
+
const metatypeNameQuote = `"${getInstanceName(metatypeUsedAsAModule)}"`;
|
|
103
103
|
return `Classes annotated with @Injectable(), @Catch(), and @Controller() decorators must not appear in the "imports" array of a module.
|
|
104
104
|
Please remove ${metatypeNameQuote} (including forwarded occurrences, if any) from all of the "imports" arrays.
|
|
105
105
|
|
|
@@ -26,7 +26,7 @@ class BaseExceptionFilterContext extends context_creator_1.ContextCreator {
|
|
|
26
26
|
.toArray();
|
|
27
27
|
}
|
|
28
28
|
getFilterInstance(filter, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
|
|
29
|
-
const isObject = filter.catch;
|
|
29
|
+
const isObject = !!filter.catch;
|
|
30
30
|
if (isObject) {
|
|
31
31
|
return filter;
|
|
32
32
|
}
|
|
@@ -2,10 +2,10 @@ import { ArgumentsHost, ExceptionFilter, HttpServer } from '@nestjs/common';
|
|
|
2
2
|
import { AbstractHttpAdapter } from '../adapters';
|
|
3
3
|
import { HttpAdapterHost } from '../helpers/http-adapter-host';
|
|
4
4
|
export declare class BaseExceptionFilter<T = any> implements ExceptionFilter<T> {
|
|
5
|
-
protected readonly applicationRef?: HttpServer;
|
|
5
|
+
protected readonly applicationRef?: HttpServer | undefined;
|
|
6
6
|
private static readonly logger;
|
|
7
7
|
protected readonly httpAdapterHost?: HttpAdapterHost;
|
|
8
|
-
constructor(applicationRef?: HttpServer);
|
|
8
|
+
constructor(applicationRef?: HttpServer | undefined);
|
|
9
9
|
catch(exception: T, host: ArgumentsHost): void;
|
|
10
10
|
handleUnknownError(exception: T, host: ArgumentsHost, applicationRef: AbstractHttpAdapter | HttpServer): void;
|
|
11
11
|
isExceptionObject(err: any): err is Error;
|
|
@@ -48,10 +48,9 @@ class BaseExceptionFilter {
|
|
|
48
48
|
else {
|
|
49
49
|
applicationRef.end(response);
|
|
50
50
|
}
|
|
51
|
-
if (
|
|
52
|
-
|
|
51
|
+
if (!(exception instanceof common_1.IntrinsicException)) {
|
|
52
|
+
BaseExceptionFilter.logger.error(exception);
|
|
53
53
|
}
|
|
54
|
-
return BaseExceptionFilter.logger.error(exception);
|
|
55
54
|
}
|
|
56
55
|
isExceptionObject(err) {
|
|
57
56
|
return (0, shared_utils_1.isObject)(err) && !!err.message;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { HttpException } from '@nestjs/common';
|
|
2
|
-
import { ArgumentsHost } from '@nestjs/common/interfaces/features/arguments-host.interface';
|
|
3
2
|
import { ExceptionFilterMetadata } from '@nestjs/common/interfaces/exceptions/exception-filter-metadata.interface';
|
|
3
|
+
import { ArgumentsHost } from '@nestjs/common/interfaces/features/arguments-host.interface';
|
|
4
4
|
import { BaseExceptionFilter } from './base-exception-filter';
|
|
5
5
|
export declare class ExceptionsHandler extends BaseExceptionFilter {
|
|
6
6
|
private filters;
|
|
7
|
-
next(exception: Error | HttpException
|
|
7
|
+
next(exception: Error | HttpException, ctx: ArgumentsHost): void;
|
|
8
8
|
setCustomFilters(filters: ExceptionFilterMetadata[]): void;
|
|
9
9
|
invokeCustomFilters<T = any>(exception: T, ctx: ArgumentsHost): boolean;
|
|
10
10
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExceptionsHandler = void 0;
|
|
4
|
-
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
5
4
|
const select_exception_filter_metadata_util_1 = require("@nestjs/common/utils/select-exception-filter-metadata.util");
|
|
6
|
-
const
|
|
5
|
+
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
7
6
|
const invalid_exception_filter_exception_1 = require("../errors/exceptions/invalid-exception-filter.exception");
|
|
7
|
+
const base_exception_filter_1 = require("./base-exception-filter");
|
|
8
8
|
class ExceptionsHandler extends base_exception_filter_1.BaseExceptionFilter {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
@@ -6,7 +6,7 @@ import { BaseExceptionFilterContext } from './base-exception-filter-context';
|
|
|
6
6
|
import { ExternalExceptionsHandler } from './external-exceptions-handler';
|
|
7
7
|
export declare class ExternalExceptionFilterContext extends BaseExceptionFilterContext {
|
|
8
8
|
private readonly config?;
|
|
9
|
-
constructor(container: NestContainer, config?: ApplicationConfig);
|
|
9
|
+
constructor(container: NestContainer, config?: ApplicationConfig | undefined);
|
|
10
10
|
create(instance: Controller, callback: RouterProxyCallback, module: string, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): ExternalExceptionsHandler;
|
|
11
11
|
getGlobalMetadata<T extends any[]>(contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): T;
|
|
12
12
|
}
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ExternalExceptionFilterContext = void 0;
|
|
4
4
|
const constants_1 = require("@nestjs/common/constants");
|
|
5
5
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
6
|
+
const iterare_1 = require("iterare");
|
|
6
7
|
const constants_2 = require("../injector/constants");
|
|
7
8
|
const base_exception_filter_context_1 = require("./base-exception-filter-context");
|
|
8
9
|
const external_exceptions_handler_1 = require("./external-exceptions-handler");
|
|
9
|
-
const iterare_1 = require("iterare");
|
|
10
10
|
class ExternalExceptionFilterContext extends base_exception_filter_context_1.BaseExceptionFilterContext {
|
|
11
11
|
constructor(container, config) {
|
|
12
12
|
super(container);
|
|
@@ -4,8 +4,9 @@ exports.ExternalExceptionFilter = void 0;
|
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
class ExternalExceptionFilter {
|
|
6
6
|
catch(exception, host) {
|
|
7
|
-
if (exception instanceof Error &&
|
|
8
|
-
|
|
7
|
+
if (exception instanceof Error &&
|
|
8
|
+
!(exception instanceof common_1.IntrinsicException)) {
|
|
9
|
+
ExternalExceptionFilter.logger.error(exception);
|
|
9
10
|
}
|
|
10
11
|
throw exception;
|
|
11
12
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ArgumentsHost } from '@nestjs/common/interfaces/features/arguments-host.interface';
|
|
2
1
|
import { ExceptionFilterMetadata } from '@nestjs/common/interfaces/exceptions';
|
|
2
|
+
import { ArgumentsHost } from '@nestjs/common/interfaces/features/arguments-host.interface';
|
|
3
3
|
import { ExternalExceptionFilter } from './external-exception-filter';
|
|
4
4
|
export declare class ExternalExceptionsHandler extends ExternalExceptionFilter {
|
|
5
5
|
private filters;
|
|
6
|
-
next(exception: Error
|
|
6
|
+
next(exception: Error, host: ArgumentsHost): Promise<any>;
|
|
7
7
|
setCustomFilters(filters: ExceptionFilterMetadata[]): void;
|
|
8
8
|
invokeCustomFilters<T = any>(exception: T, host: ArgumentsHost): Promise<any> | null;
|
|
9
9
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExternalExceptionsHandler = void 0;
|
|
4
|
-
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
5
4
|
const select_exception_filter_metadata_util_1 = require("@nestjs/common/utils/select-exception-filter-metadata.util");
|
|
6
|
-
const
|
|
5
|
+
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
7
6
|
const invalid_exception_filter_exception_1 = require("../errors/exceptions/invalid-exception-filter.exception");
|
|
7
|
+
const external_exception_filter_1 = require("./external-exception-filter");
|
|
8
8
|
class ExternalExceptionsHandler extends external_exception_filter_1.ExternalExceptionFilter {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
@@ -8,7 +8,7 @@ export declare class GuardsContextCreator extends ContextCreator {
|
|
|
8
8
|
private readonly container;
|
|
9
9
|
private readonly config?;
|
|
10
10
|
private moduleContext;
|
|
11
|
-
constructor(container: NestContainer, config?: ApplicationConfig);
|
|
11
|
+
constructor(container: NestContainer, config?: ApplicationConfig | undefined);
|
|
12
12
|
create(instance: Controller, callback: (...args: unknown[]) => unknown, module: string, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): CanActivate[];
|
|
13
13
|
createConcreteContext<T extends unknown[], R extends unknown[]>(metadata: T, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): R;
|
|
14
14
|
getGuardInstance(metatype: Function | CanActivate, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): CanActivate | null;
|
|
@@ -23,11 +23,11 @@ class GuardsContextCreator extends context_creator_1.ContextCreator {
|
|
|
23
23
|
return (0, iterare_1.iterate)(metadata)
|
|
24
24
|
.filter((guard) => guard && (guard.name || guard.canActivate))
|
|
25
25
|
.map(guard => this.getGuardInstance(guard, contextId, inquirerId))
|
|
26
|
-
.filter((guard) => guard && (0, shared_utils_1.isFunction)(guard.canActivate))
|
|
26
|
+
.filter((guard) => !!guard && (0, shared_utils_1.isFunction)(guard.canActivate))
|
|
27
27
|
.toArray();
|
|
28
28
|
}
|
|
29
29
|
getGuardInstance(metatype, contextId = constants_2.STATIC_CONTEXT, inquirerId) {
|
|
30
|
-
const isObject = metatype.canActivate;
|
|
30
|
+
const isObject = !!metatype.canActivate;
|
|
31
31
|
if (isObject) {
|
|
32
32
|
return metatype;
|
|
33
33
|
}
|
|
@@ -6,7 +6,7 @@ export declare class ExecutionContextHost implements ExecutionContext {
|
|
|
6
6
|
private readonly constructorRef;
|
|
7
7
|
private readonly handler;
|
|
8
8
|
private contextType;
|
|
9
|
-
constructor(args: any[], constructorRef?: Type<any
|
|
9
|
+
constructor(args: any[], constructorRef?: Type<any> | null, handler?: Function | null);
|
|
10
10
|
setType<TContext extends string = ContextType>(type: TContext): void;
|
|
11
11
|
getType<TContext extends string = ContextType>(): TContext;
|
|
12
12
|
getClass<T = any>(): Type<T>;
|
|
@@ -39,7 +39,7 @@ export declare class ExternalContextCreator {
|
|
|
39
39
|
exchangeKeysForValues<TMetadata = any>(keys: string[], metadata: TMetadata, moduleContext: string, paramsFactory: ParamsFactory, contextId?: ContextId, inquirerId?: string, contextFactory?: (args: unknown[]) => import("./execution-context-host").ExecutionContextHost): ParamProperties[];
|
|
40
40
|
createPipesFn(pipes: PipeTransform[], paramsOptions: (ParamProperties & {
|
|
41
41
|
metatype?: unknown;
|
|
42
|
-
})[]): (args: unknown[], ...params: unknown[]) => Promise<void
|
|
42
|
+
})[]): ((args: unknown[], ...params: unknown[]) => Promise<void>) | null;
|
|
43
43
|
getParamValue<T>(value: T, { metatype, type, data }: {
|
|
44
44
|
metatype: any;
|
|
45
45
|
type: any;
|
|
@@ -6,8 +6,8 @@ const constants_1 = require("@nestjs/common/constants");
|
|
|
6
6
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
7
7
|
const rxjs_1 = require("rxjs");
|
|
8
8
|
const external_exception_filter_context_1 = require("../exceptions/external-exception-filter-context");
|
|
9
|
-
const constants_2 = require("../guards/constants");
|
|
10
9
|
const guards_1 = require("../guards");
|
|
10
|
+
const constants_2 = require("../guards/constants");
|
|
11
11
|
const constants_3 = require("../injector/constants");
|
|
12
12
|
const interceptors_1 = require("../interceptors");
|
|
13
13
|
const pipes_1 = require("../pipes");
|
|
@@ -45,15 +45,15 @@ class ExternalContextCreator {
|
|
|
45
45
|
guards: true,
|
|
46
46
|
filters: true,
|
|
47
47
|
}, contextType = 'http') {
|
|
48
|
-
const
|
|
48
|
+
const moduleKey = this.getContextModuleKey(instance.constructor);
|
|
49
49
|
const { argsLength, paramtypes, getParamsMetadata } = this.getMetadata(instance, methodName, metadataKey, paramsFactory, contextType);
|
|
50
|
-
const pipes = this.pipesContextCreator.create(instance, callback,
|
|
51
|
-
const guards = this.guardsContextCreator.create(instance, callback,
|
|
52
|
-
const exceptionFilter = this.filtersContextCreator.create(instance, callback,
|
|
50
|
+
const pipes = this.pipesContextCreator.create(instance, callback, moduleKey, contextId, inquirerId);
|
|
51
|
+
const guards = this.guardsContextCreator.create(instance, callback, moduleKey, contextId, inquirerId);
|
|
52
|
+
const exceptionFilter = this.filtersContextCreator.create(instance, callback, moduleKey, contextId, inquirerId);
|
|
53
53
|
const interceptors = options.interceptors
|
|
54
|
-
? this.interceptorsContextCreator.create(instance, callback,
|
|
54
|
+
? this.interceptorsContextCreator.create(instance, callback, moduleKey, contextId, inquirerId)
|
|
55
55
|
: [];
|
|
56
|
-
const paramsMetadata = getParamsMetadata(
|
|
56
|
+
const paramsMetadata = getParamsMetadata(moduleKey, contextId, inquirerId);
|
|
57
57
|
const paramsOptions = paramsMetadata
|
|
58
58
|
? this.contextUtils.mergeParamsMetatypes(paramsMetadata, paramtypes)
|
|
59
59
|
: [];
|
|
@@ -94,7 +94,7 @@ class ExternalContextCreator {
|
|
|
94
94
|
const handlerMetadata = {
|
|
95
95
|
argsLength,
|
|
96
96
|
paramtypes,
|
|
97
|
-
getParamsMetadata,
|
|
97
|
+
getParamsMetadata: getParamsMetadata,
|
|
98
98
|
};
|
|
99
99
|
this.handlerMetadataStorage.set(instance, methodName, handlerMetadata);
|
|
100
100
|
return handlerMetadata;
|
|
@@ -12,6 +12,13 @@ const REQUEST_METHOD_MAP = {
|
|
|
12
12
|
[request_method_enum_1.RequestMethod.OPTIONS]: 'options',
|
|
13
13
|
[request_method_enum_1.RequestMethod.HEAD]: 'head',
|
|
14
14
|
[request_method_enum_1.RequestMethod.SEARCH]: 'search',
|
|
15
|
+
[request_method_enum_1.RequestMethod.PROPFIND]: 'propfind',
|
|
16
|
+
[request_method_enum_1.RequestMethod.PROPPATCH]: 'proppatch',
|
|
17
|
+
[request_method_enum_1.RequestMethod.MKCOL]: 'mkcol',
|
|
18
|
+
[request_method_enum_1.RequestMethod.COPY]: 'copy',
|
|
19
|
+
[request_method_enum_1.RequestMethod.MOVE]: 'move',
|
|
20
|
+
[request_method_enum_1.RequestMethod.LOCK]: 'lock',
|
|
21
|
+
[request_method_enum_1.RequestMethod.UNLOCK]: 'unlock',
|
|
15
22
|
};
|
|
16
23
|
class RouterMethodFactory {
|
|
17
24
|
get(target, requestMethod) {
|
|
@@ -25,12 +25,12 @@ class AbstractInstanceResolver {
|
|
|
25
25
|
each: options.each,
|
|
26
26
|
})
|
|
27
27
|
: this.instanceLinksHost.get(typeOrToken, {
|
|
28
|
-
each: options
|
|
28
|
+
each: options?.each,
|
|
29
29
|
});
|
|
30
30
|
const pluckInstance = async (instanceLink) => {
|
|
31
31
|
const { wrapperRef, collection } = instanceLink;
|
|
32
32
|
if (wrapperRef.isDependencyTreeStatic() && !wrapperRef.isTransient) {
|
|
33
|
-
return this.get(typeOrToken, { strict: options
|
|
33
|
+
return this.get(typeOrToken, { strict: options?.strict });
|
|
34
34
|
}
|
|
35
35
|
const ctorHost = wrapperRef.instance || { constructor: typeOrToken };
|
|
36
36
|
const instance = await this.injector.loadPerContext(ctorHost, wrapperRef.host, collection, contextId, wrapperRef);
|
package/injector/compiler.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { DynamicModule, ForwardReference, Type } from '@nestjs/common/interfaces';
|
|
2
|
-
import {
|
|
2
|
+
import { ModuleOpaqueKeyFactory } from './opaque-key-factory/interfaces/module-opaque-key-factory.interface';
|
|
3
3
|
export interface ModuleFactory {
|
|
4
4
|
type: Type<any>;
|
|
5
5
|
token: string;
|
|
6
6
|
dynamicMetadata?: Partial<DynamicModule>;
|
|
7
7
|
}
|
|
8
8
|
export declare class ModuleCompiler {
|
|
9
|
-
private readonly
|
|
10
|
-
constructor(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
private readonly _moduleOpaqueKeyFactory;
|
|
10
|
+
constructor(_moduleOpaqueKeyFactory: ModuleOpaqueKeyFactory);
|
|
11
|
+
get moduleOpaqueKeyFactory(): ModuleOpaqueKeyFactory;
|
|
12
|
+
compile(moduleClsOrDynamic: Type | DynamicModule | ForwardReference | Promise<DynamicModule>): Promise<ModuleFactory>;
|
|
13
|
+
extractMetadata(moduleClsOrDynamic: Type | ForwardReference | DynamicModule): {
|
|
14
|
+
type: Type;
|
|
15
|
+
dynamicMetadata: Omit<DynamicModule, 'module'> | undefined;
|
|
15
16
|
};
|
|
16
|
-
isDynamicModule(
|
|
17
|
+
isDynamicModule(moduleClsOrDynamic: Type | DynamicModule | ForwardReference): moduleClsOrDynamic is DynamicModule;
|
|
17
18
|
}
|
package/injector/compiler.js
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ModuleCompiler = void 0;
|
|
4
|
-
const module_token_factory_1 = require("./module-token-factory");
|
|
5
4
|
class ModuleCompiler {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
5
|
+
constructor(_moduleOpaqueKeyFactory) {
|
|
6
|
+
this._moduleOpaqueKeyFactory = _moduleOpaqueKeyFactory;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
get moduleOpaqueKeyFactory() {
|
|
9
|
+
return this._moduleOpaqueKeyFactory;
|
|
10
|
+
}
|
|
11
|
+
async compile(moduleClsOrDynamic) {
|
|
12
|
+
moduleClsOrDynamic = await moduleClsOrDynamic;
|
|
13
|
+
const { type, dynamicMetadata } = this.extractMetadata(moduleClsOrDynamic);
|
|
14
|
+
const token = dynamicMetadata
|
|
15
|
+
? this._moduleOpaqueKeyFactory.createForDynamic(type, dynamicMetadata, moduleClsOrDynamic)
|
|
16
|
+
: this._moduleOpaqueKeyFactory.createForStatic(type, moduleClsOrDynamic);
|
|
12
17
|
return { type, dynamicMetadata, token };
|
|
13
18
|
}
|
|
14
|
-
extractMetadata(
|
|
15
|
-
if (!this.isDynamicModule(
|
|
19
|
+
extractMetadata(moduleClsOrDynamic) {
|
|
20
|
+
if (!this.isDynamicModule(moduleClsOrDynamic)) {
|
|
16
21
|
return {
|
|
17
|
-
type:
|
|
18
|
-
?
|
|
19
|
-
:
|
|
22
|
+
type: moduleClsOrDynamic?.forwardRef
|
|
23
|
+
? moduleClsOrDynamic.forwardRef()
|
|
24
|
+
: moduleClsOrDynamic,
|
|
25
|
+
dynamicMetadata: undefined,
|
|
20
26
|
};
|
|
21
27
|
}
|
|
22
|
-
const { module: type, ...dynamicMetadata } =
|
|
28
|
+
const { module: type, ...dynamicMetadata } = moduleClsOrDynamic;
|
|
23
29
|
return { type, dynamicMetadata };
|
|
24
30
|
}
|
|
25
|
-
isDynamicModule(
|
|
26
|
-
return !!
|
|
31
|
+
isDynamicModule(moduleClsOrDynamic) {
|
|
32
|
+
return !!moduleClsOrDynamic.module;
|
|
27
33
|
}
|
|
28
34
|
}
|
|
29
35
|
exports.ModuleCompiler = ModuleCompiler;
|
package/injector/container.d.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { DynamicModule, Provider } from '@nestjs/common';
|
|
2
2
|
import { EnhancerSubtype } from '@nestjs/common/constants';
|
|
3
3
|
import { Injectable, Type } from '@nestjs/common/interfaces';
|
|
4
|
+
import { NestApplicationContextOptions } from '@nestjs/common/interfaces/nest-application-context-options.interface';
|
|
4
5
|
import { ApplicationConfig } from '../application-config';
|
|
5
6
|
import { SerializedGraph } from '../inspector/serialized-graph';
|
|
6
7
|
import { ModuleCompiler } from './compiler';
|
|
7
8
|
import { ContextId } from './instance-wrapper';
|
|
8
9
|
import { Module } from './module';
|
|
9
|
-
import { ModuleTokenFactory } from './module-token-factory';
|
|
10
10
|
import { ModulesContainer } from './modules-container';
|
|
11
|
+
import { ModuleOpaqueKeyFactory } from './opaque-key-factory/interfaces/module-opaque-key-factory.interface';
|
|
11
12
|
type ModuleMetatype = Type<any> | DynamicModule | Promise<DynamicModule>;
|
|
12
13
|
type ModuleScope = Type<any>[];
|
|
13
14
|
export declare class NestContainer {
|
|
14
15
|
private readonly _applicationConfig;
|
|
16
|
+
private readonly _contextOptions;
|
|
15
17
|
private readonly globalModules;
|
|
16
|
-
private readonly moduleTokenFactory;
|
|
17
|
-
private readonly moduleCompiler;
|
|
18
18
|
private readonly modules;
|
|
19
19
|
private readonly dynamicModulesMetadata;
|
|
20
20
|
private readonly internalProvidersStorage;
|
|
21
21
|
private readonly _serializedGraph;
|
|
22
|
+
private moduleCompiler;
|
|
22
23
|
private internalCoreModule;
|
|
23
|
-
constructor(_applicationConfig?: ApplicationConfig);
|
|
24
|
+
constructor(_applicationConfig?: ApplicationConfig | undefined, _contextOptions?: NestApplicationContextOptions | undefined);
|
|
24
25
|
get serializedGraph(): SerializedGraph;
|
|
25
26
|
get applicationConfig(): ApplicationConfig | undefined;
|
|
26
27
|
setHttpAdapter(httpAdapter: any): void;
|
|
@@ -41,7 +42,7 @@ export declare class NestContainer {
|
|
|
41
42
|
addGlobalModule(module: Module): void;
|
|
42
43
|
getModules(): ModulesContainer;
|
|
43
44
|
getModuleCompiler(): ModuleCompiler;
|
|
44
|
-
getModuleByKey(moduleKey: string): Module;
|
|
45
|
+
getModuleByKey(moduleKey: string): Module | undefined;
|
|
45
46
|
getInternalCoreModuleRef(): Module | undefined;
|
|
46
47
|
addImport(relatedModule: Type<any> | DynamicModule, token: string): Promise<void>;
|
|
47
48
|
addProvider(provider: Provider, token: string, enhancerSubtype?: EnhancerSubtype): string | symbol | Function;
|
|
@@ -49,7 +50,7 @@ export declare class NestContainer {
|
|
|
49
50
|
addExportedProvider(provider: Type<any>, token: string): void;
|
|
50
51
|
addController(controller: Type<any>, token: string): void;
|
|
51
52
|
clear(): void;
|
|
52
|
-
replace(toReplace: any, options:
|
|
53
|
+
replace(toReplace: any, options: {
|
|
53
54
|
scope: any[] | null;
|
|
54
55
|
}): void;
|
|
55
56
|
bindGlobalScope(): void;
|
|
@@ -58,7 +59,7 @@ export declare class NestContainer {
|
|
|
58
59
|
getDynamicMetadataByToken(token: string): Partial<DynamicModule>;
|
|
59
60
|
getDynamicMetadataByToken<K extends Exclude<keyof DynamicModule, 'global' | 'module'>>(token: string, metadataKey: K): DynamicModule[K];
|
|
60
61
|
registerCoreModuleRef(moduleRef: Module): void;
|
|
61
|
-
getModuleTokenFactory():
|
|
62
|
+
getModuleTokenFactory(): ModuleOpaqueKeyFactory;
|
|
62
63
|
registerRequestProvider<T = any>(request: T, contextId: ContextId): void;
|
|
63
64
|
private shouldInitOnPreview;
|
|
64
65
|
}
|
package/injector/container.js
CHANGED
|
@@ -11,18 +11,26 @@ const compiler_1 = require("./compiler");
|
|
|
11
11
|
const internal_core_module_1 = require("./internal-core-module/internal-core-module");
|
|
12
12
|
const internal_providers_storage_1 = require("./internal-providers-storage");
|
|
13
13
|
const module_1 = require("./module");
|
|
14
|
-
const module_token_factory_1 = require("./module-token-factory");
|
|
15
14
|
const modules_container_1 = require("./modules-container");
|
|
15
|
+
const by_reference_module_opaque_key_factory_1 = require("./opaque-key-factory/by-reference-module-opaque-key-factory");
|
|
16
|
+
const deep_hashed_module_opaque_key_factory_1 = require("./opaque-key-factory/deep-hashed-module-opaque-key-factory");
|
|
16
17
|
class NestContainer {
|
|
17
|
-
constructor(_applicationConfig = undefined) {
|
|
18
|
+
constructor(_applicationConfig = undefined, _contextOptions = undefined) {
|
|
18
19
|
this._applicationConfig = _applicationConfig;
|
|
20
|
+
this._contextOptions = _contextOptions;
|
|
19
21
|
this.globalModules = new Set();
|
|
20
|
-
this.moduleTokenFactory = new module_token_factory_1.ModuleTokenFactory();
|
|
21
|
-
this.moduleCompiler = new compiler_1.ModuleCompiler(this.moduleTokenFactory);
|
|
22
22
|
this.modules = new modules_container_1.ModulesContainer();
|
|
23
23
|
this.dynamicModulesMetadata = new Map();
|
|
24
24
|
this.internalProvidersStorage = new internal_providers_storage_1.InternalProvidersStorage();
|
|
25
25
|
this._serializedGraph = new serialized_graph_1.SerializedGraph();
|
|
26
|
+
const moduleOpaqueKeyFactory = this._contextOptions?.moduleIdGeneratorAlgorithm === 'deep-hash'
|
|
27
|
+
? new deep_hashed_module_opaque_key_factory_1.DeepHashedModuleOpaqueKeyFactory()
|
|
28
|
+
: new by_reference_module_opaque_key_factory_1.ByReferenceModuleOpaqueKeyFactory({
|
|
29
|
+
keyGenerationStrategy: this._contextOptions?.snapshot
|
|
30
|
+
? 'shallow'
|
|
31
|
+
: 'random',
|
|
32
|
+
});
|
|
33
|
+
this.moduleCompiler = new compiler_1.ModuleCompiler(moduleOpaqueKeyFactory);
|
|
26
34
|
}
|
|
27
35
|
get serializedGraph() {
|
|
28
36
|
return this._serializedGraph;
|
|
@@ -203,7 +211,7 @@ class NestContainer {
|
|
|
203
211
|
this.modules[internal_core_module_1.InternalCoreModule.name] = moduleRef;
|
|
204
212
|
}
|
|
205
213
|
getModuleTokenFactory() {
|
|
206
|
-
return this.
|
|
214
|
+
return this.moduleCompiler.moduleOpaqueKeyFactory;
|
|
207
215
|
}
|
|
208
216
|
registerRequestProvider(request, contextId) {
|
|
209
217
|
const wrapper = this.internalCoreModule.getProviderByKey(request_constants_1.REQUEST);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SilentLogger = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
6
5
|
const noop = () => { };
|
|
7
6
|
class SilentLogger extends common_1.Logger {
|
|
8
7
|
constructor() {
|