@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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class LegacyRouteConverter {
|
|
2
|
+
private static readonly logger;
|
|
3
|
+
/**
|
|
4
|
+
* Convert legacy routes to the new format (syntax).
|
|
5
|
+
* path-to-regexp used by Express>=v5 and @fastify/middie>=v9 no longer support unnamed wildcards.
|
|
6
|
+
* This method attempts to convert the old syntax to the new one, and logs an error if it fails.
|
|
7
|
+
* @param route The route to convert.
|
|
8
|
+
* @returns The converted route, or the original route if it cannot be converted.
|
|
9
|
+
*/
|
|
10
|
+
static tryConvert(route: string): string;
|
|
11
|
+
static printError(route: string): void;
|
|
12
|
+
static printWarning(route: string): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LegacyRouteConverter = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const UNSUPPORTED_PATH_MESSAGE = (text, route) => `Unsupported route path: "${route}". In previous versions, the symbols ?, *, and + were used to denote optional or repeating path parameters. The latest version of "path-to-regexp" now requires the use of named parameters. For example, instead of using a route like /users/* to capture all routes starting with "/users", you should use /users/*path. For more details, refer to the migration guide.`;
|
|
6
|
+
class LegacyRouteConverter {
|
|
7
|
+
/**
|
|
8
|
+
* Convert legacy routes to the new format (syntax).
|
|
9
|
+
* path-to-regexp used by Express>=v5 and @fastify/middie>=v9 no longer support unnamed wildcards.
|
|
10
|
+
* This method attempts to convert the old syntax to the new one, and logs an error if it fails.
|
|
11
|
+
* @param route The route to convert.
|
|
12
|
+
* @returns The converted route, or the original route if it cannot be converted.
|
|
13
|
+
*/
|
|
14
|
+
static tryConvert(route) {
|
|
15
|
+
// Normalize path to eliminate additional conditions.
|
|
16
|
+
const routeWithLeadingSlash = route.startsWith('/') ? route : `/${route}`;
|
|
17
|
+
const normalizedRoute = route.endsWith('/')
|
|
18
|
+
? routeWithLeadingSlash
|
|
19
|
+
: `${routeWithLeadingSlash}/`;
|
|
20
|
+
if (normalizedRoute.endsWith('/(.*)/')) {
|
|
21
|
+
// Skip printing warning for the "all" wildcard.
|
|
22
|
+
if (normalizedRoute !== '/(.*)/') {
|
|
23
|
+
this.printWarning(route);
|
|
24
|
+
}
|
|
25
|
+
return route.replace('(.*)', '*path');
|
|
26
|
+
}
|
|
27
|
+
if (normalizedRoute.endsWith('/*/')) {
|
|
28
|
+
// Skip printing warning for the "all" wildcard.
|
|
29
|
+
if (normalizedRoute !== '/*/') {
|
|
30
|
+
this.printWarning(route);
|
|
31
|
+
}
|
|
32
|
+
return route.replace('*', '*path');
|
|
33
|
+
}
|
|
34
|
+
if (normalizedRoute.endsWith('/+/')) {
|
|
35
|
+
this.printWarning(route);
|
|
36
|
+
return route.replace('/+', '/*path');
|
|
37
|
+
}
|
|
38
|
+
return route;
|
|
39
|
+
}
|
|
40
|
+
static printError(route) {
|
|
41
|
+
this.logger.error(UNSUPPORTED_PATH_MESSAGE `${route}`);
|
|
42
|
+
}
|
|
43
|
+
static printWarning(route) {
|
|
44
|
+
this.logger.warn(UNSUPPORTED_PATH_MESSAGE `${route}` + ' Attempting to convert...');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.LegacyRouteConverter = LegacyRouteConverter;
|
|
48
|
+
LegacyRouteConverter.logger = new common_1.Logger(LegacyRouteConverter.name);
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.requestProvider = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const request_constants_1 = require("./request-constants");
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
7
6
|
const noop = () => { };
|
|
8
7
|
exports.requestProvider = {
|
|
9
8
|
provide: request_constants_1.REQUEST,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RouteParamtypes } from '@nestjs/common/enums/route-paramtypes.enum';
|
|
2
2
|
import { IRouteParamsFactory } from './interfaces/route-params-factory.interface';
|
|
3
3
|
export declare class RouteParamsFactory implements IRouteParamsFactory {
|
|
4
|
-
exchangeKeyForValue<TRequest extends Record<string, any> = any, TResponse = any, TResult = any>(key: RouteParamtypes | string, data: string
|
|
4
|
+
exchangeKeyForValue<TRequest extends Record<string, any> = any, TResponse = any, TResult = any>(key: RouteParamtypes | string, data: string, { req, res, next }: {
|
|
5
5
|
req: TRequest;
|
|
6
6
|
res: TResponse;
|
|
7
7
|
next: Function;
|
|
8
|
-
}): TResult;
|
|
8
|
+
}): TResult | null;
|
|
9
9
|
}
|
|
@@ -18,6 +18,7 @@ class RouteParamsFactory {
|
|
|
18
18
|
case route_paramtypes_enum_1.RouteParamtypes.PARAM:
|
|
19
19
|
return data ? req.params[data] : req.params;
|
|
20
20
|
case route_paramtypes_enum_1.RouteParamtypes.HOST:
|
|
21
|
+
/* eslint-disable-next-line no-case-declarations */
|
|
21
22
|
const hosts = req.hosts || {};
|
|
22
23
|
return data ? hosts[data] : hosts;
|
|
23
24
|
case route_paramtypes_enum_1.RouteParamtypes.QUERY:
|
|
@@ -6,7 +6,7 @@ export declare class RoutePathFactory {
|
|
|
6
6
|
private readonly applicationConfig;
|
|
7
7
|
constructor(applicationConfig: ApplicationConfig);
|
|
8
8
|
create(metadata: RoutePathMetadata, requestMethod?: RequestMethod): string[];
|
|
9
|
-
getVersion(metadata: RoutePathMetadata): VersionValue;
|
|
9
|
+
getVersion(metadata: RoutePathMetadata): VersionValue | undefined;
|
|
10
10
|
getVersionPrefix(versioningOptions: VersioningOptions): string;
|
|
11
11
|
appendToAllIfDefined(paths: string[], fragmentToAppend: string | string[] | undefined): string[];
|
|
12
12
|
isExcludedFromGlobalPrefix(path: string, requestMethod?: RequestMethod, versionOrVersions?: VersionValue, versioningOptions?: VersioningOptions): boolean;
|
|
@@ -9,6 +9,6 @@ export declare class RouterExceptionFilters extends BaseExceptionFilterContext {
|
|
|
9
9
|
private readonly config;
|
|
10
10
|
private readonly applicationRef;
|
|
11
11
|
constructor(container: NestContainer, config: ApplicationConfig, applicationRef: HttpServer);
|
|
12
|
-
create(instance: Controller, callback: RouterProxyCallback, moduleKey: string, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): ExceptionsHandler;
|
|
12
|
+
create(instance: Controller, callback: RouterProxyCallback, moduleKey: string | undefined, contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): ExceptionsHandler;
|
|
13
13
|
getGlobalMetadata<T extends unknown[]>(contextId?: import("../injector/instance-wrapper").ContextId, inquirerId?: string): T;
|
|
14
14
|
}
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RouterExceptionFilters = 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 base_exception_filter_context_1 = require("../exceptions/base-exception-filter-context");
|
|
7
8
|
const exceptions_handler_1 = require("../exceptions/exceptions-handler");
|
|
8
9
|
const constants_2 = require("../injector/constants");
|
|
9
|
-
const iterare_1 = require("iterare");
|
|
10
10
|
class RouterExceptionFilters extends base_exception_filter_context_1.BaseExceptionFilterContext {
|
|
11
11
|
constructor(container, config, applicationRef) {
|
|
12
12
|
super(container);
|
|
@@ -45,10 +45,10 @@ export declare class RouterExecutionContext {
|
|
|
45
45
|
data: unknown;
|
|
46
46
|
}, pipes: PipeTransform[]): Promise<unknown>;
|
|
47
47
|
isPipeable(type: number | string): boolean;
|
|
48
|
-
createGuardsFn<TContext extends string = ContextType>(guards: CanActivate[], instance: Controller, callback: (...args: any[]) => any, contextType?: TContext): (args: any[]) => Promise<void> | null;
|
|
48
|
+
createGuardsFn<TContext extends string = ContextType>(guards: CanActivate[], instance: Controller, callback: (...args: any[]) => any, contextType?: TContext): ((args: any[]) => Promise<void>) | null;
|
|
49
49
|
createPipesFn(pipes: PipeTransform[], paramsOptions: (ParamProperties & {
|
|
50
50
|
metatype?: any;
|
|
51
|
-
})[]): <TRequest, TResponse>(args: any[], req: TRequest, res: TResponse, next: Function) => Promise<void
|
|
51
|
+
})[]): (<TRequest, TResponse>(args: any[], req: TRequest, res: TResponse, next: Function) => Promise<void>) | null;
|
|
52
52
|
createHandleResponseFn(callback: (...args: unknown[]) => unknown, isResponseHandled: boolean, redirectResponse?: RedirectResponse, httpStatusCode?: number): HandleResponseFn;
|
|
53
53
|
private isResponseHandled;
|
|
54
54
|
}
|
|
@@ -6,7 +6,7 @@ const enums_1 = require("@nestjs/common/enums");
|
|
|
6
6
|
const exceptions_1 = require("@nestjs/common/exceptions");
|
|
7
7
|
const logger_service_1 = require("@nestjs/common/services/logger.service");
|
|
8
8
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
9
|
-
const
|
|
9
|
+
const path_to_regexp_1 = require("path-to-regexp");
|
|
10
10
|
const unknown_request_mapping_exception_1 = require("../errors/exceptions/unknown-request-mapping.exception");
|
|
11
11
|
const guards_1 = require("../guards");
|
|
12
12
|
const context_id_factory_1 = require("../helpers/context-id-factory");
|
|
@@ -16,6 +16,7 @@ const router_method_factory_1 = require("../helpers/router-method-factory");
|
|
|
16
16
|
const constants_2 = require("../injector/constants");
|
|
17
17
|
const interceptors_1 = require("../interceptors");
|
|
18
18
|
const pipes_1 = require("../pipes");
|
|
19
|
+
const legacy_route_converter_1 = require("./legacy-route-converter");
|
|
19
20
|
const paths_explorer_1 = require("./paths-explorer");
|
|
20
21
|
const request_constants_1 = require("./request/request-constants");
|
|
21
22
|
const route_params_factory_1 = require("./route-params-factory");
|
|
@@ -102,7 +103,16 @@ class RouterExplorer {
|
|
|
102
103
|
},
|
|
103
104
|
};
|
|
104
105
|
this.copyMetadataToCallback(targetCallback, routeHandler);
|
|
105
|
-
|
|
106
|
+
try {
|
|
107
|
+
const convertedPath = legacy_route_converter_1.LegacyRouteConverter.tryConvert(path);
|
|
108
|
+
routerMethodRef(convertedPath, routeHandler);
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
if (e instanceof TypeError) {
|
|
112
|
+
legacy_route_converter_1.LegacyRouteConverter.printError(path);
|
|
113
|
+
}
|
|
114
|
+
throw e;
|
|
115
|
+
}
|
|
106
116
|
this.graphInspector.insertEntrypointDefinition(entrypointDefinition, instanceWrapper.id);
|
|
107
117
|
});
|
|
108
118
|
const pathsToLog = this.routePathFactory.create({
|
|
@@ -127,9 +137,18 @@ class RouterExplorer {
|
|
|
127
137
|
const httpAdapterRef = this.container.getHttpAdapterRef();
|
|
128
138
|
const hosts = Array.isArray(host) ? host : [host];
|
|
129
139
|
const hostRegExps = hosts.map((host) => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
140
|
+
if (typeof host === 'string') {
|
|
141
|
+
try {
|
|
142
|
+
return (0, path_to_regexp_1.pathToRegexp)(host);
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
if (e instanceof TypeError) {
|
|
146
|
+
this.logger.error(`Unsupported host "${host}" syntax. In past releases, ?, *, and + were used to denote optional or repeating path parameters. The latest version of "path-to-regexp" now requires the use of named parameters. For example, instead of using a route like /users/* to capture all routes starting with "/users", you should use /users/*path. Please see the migration guide for more information.`);
|
|
147
|
+
}
|
|
148
|
+
throw e;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return { regexp: host, keys: [] };
|
|
133
152
|
});
|
|
134
153
|
const unsupportedFilteringErrorMessage = Array.isArray(host)
|
|
135
154
|
? `HTTP adapter does not support filtering on hosts: ["${host.join('", "')}"]`
|
package/router/router-proxy.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExceptionsHandler } from '../exceptions/exceptions-handler';
|
|
2
|
-
export type RouterProxyCallback = <TRequest, TResponse>(req
|
|
2
|
+
export type RouterProxyCallback = <TRequest, TResponse>(req: TRequest, res: TResponse, next: () => void) => void | Promise<void>;
|
|
3
3
|
export declare class RouterProxy {
|
|
4
|
-
createProxy(targetCallback: RouterProxyCallback, exceptionsHandler: ExceptionsHandler): <TRequest, TResponse>(req: TRequest, res: TResponse, next: () => void) => Promise<TResponse>;
|
|
5
|
-
createExceptionLayerProxy(targetCallback: <TError, TRequest, TResponse>(err: TError, req: TRequest, res: TResponse, next: () => void) => void
|
|
4
|
+
createProxy(targetCallback: RouterProxyCallback, exceptionsHandler: ExceptionsHandler): <TRequest, TResponse>(req: TRequest, res: TResponse, next: () => void) => Promise<TResponse | undefined>;
|
|
5
|
+
createExceptionLayerProxy(targetCallback: <TError, TRequest, TResponse>(err: TError, req: TRequest, res: TResponse, next: () => void) => void | Promise<void>, exceptionsHandler: ExceptionsHandler): <TError, TRequest, TResponse>(err: TError, req: TRequest, res: TResponse, next: () => void) => Promise<TResponse | undefined>;
|
|
6
6
|
}
|
package/router/sse-stream.js
CHANGED
|
@@ -49,7 +49,7 @@ class SseStream extends stream_1.Transform {
|
|
|
49
49
|
// NGINX support https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-buffering
|
|
50
50
|
'X-Accel-Buffering': 'no',
|
|
51
51
|
});
|
|
52
|
-
destination.flushHeaders();
|
|
52
|
+
destination.flushHeaders?.();
|
|
53
53
|
}
|
|
54
54
|
destination.write('\n');
|
|
55
55
|
return super.pipe(destination, options);
|
package/scanner.d.ts
CHANGED
|
@@ -46,8 +46,8 @@ export declare class DependenciesScanner {
|
|
|
46
46
|
calculateModulesDistance(): void;
|
|
47
47
|
insertImport(related: any, token: string, context: string): Promise<void>;
|
|
48
48
|
isCustomProvider(provider: Provider): provider is ClassProvider | ValueProvider | FactoryProvider | ExistingProvider;
|
|
49
|
-
insertProvider(provider: Provider, token: string): string | symbol | Function | InstanceWrapper<unknown
|
|
50
|
-
insertInjectable(injectable: Type<Injectable> | object, token: string, host: Type<Injectable>, subtype: EnhancerSubtype, methodKey?: string): InstanceWrapper<any
|
|
49
|
+
insertProvider(provider: Provider, token: string): string | symbol | Function | InstanceWrapper<unknown> | undefined;
|
|
50
|
+
insertInjectable(injectable: Type<Injectable> | object, token: string, host: Type<Injectable>, subtype: EnhancerSubtype, methodKey?: string): InstanceWrapper<any> | undefined;
|
|
51
51
|
insertExportedProvider(exportedProvider: Type<Injectable> | ForwardReference, token: string): void;
|
|
52
52
|
insertController(controller: Type<Controller>, token: string): void;
|
|
53
53
|
private insertOrOverrideModule;
|
package/scanner.js
CHANGED
|
@@ -29,9 +29,9 @@ class DependenciesScanner {
|
|
|
29
29
|
overrides: options?.overrides,
|
|
30
30
|
});
|
|
31
31
|
await this.scanModulesForDependencies();
|
|
32
|
-
this.calculateModulesDistance();
|
|
33
32
|
this.addScopedEnhancersMetadata();
|
|
34
33
|
this.container.bindGlobalScope();
|
|
34
|
+
this.calculateModulesDistance();
|
|
35
35
|
}
|
|
36
36
|
async scanForModules({ moduleDefinition, lazy, scope = [], ctxRegistry = [], overrides = [], }) {
|
|
37
37
|
const { moduleRef: moduleInstance, inserted: moduleInserted } = (await this.insertOrOverrideModule(moduleDefinition, overrides, scope)) ??
|
|
@@ -198,19 +198,19 @@ class DependenciesScanner {
|
|
|
198
198
|
const modulesGenerator = this.container.getModules().values();
|
|
199
199
|
// Skip "InternalCoreModule" from calculating distance
|
|
200
200
|
modulesGenerator.next();
|
|
201
|
-
const modulesStack = []
|
|
202
|
-
|
|
203
|
-
if (!moduleRef ||
|
|
201
|
+
const calculateDistance = (moduleRef, distance = 1, modulesStack = []) => {
|
|
202
|
+
const localModulesStack = [...modulesStack];
|
|
203
|
+
if (!moduleRef || localModulesStack.includes(moduleRef)) {
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
|
|
206
|
+
localModulesStack.push(moduleRef);
|
|
207
207
|
const moduleImports = moduleRef.imports;
|
|
208
208
|
moduleImports.forEach(importedModuleRef => {
|
|
209
209
|
if (importedModuleRef) {
|
|
210
210
|
if (distance > importedModuleRef.distance) {
|
|
211
211
|
importedModuleRef.distance = distance;
|
|
212
212
|
}
|
|
213
|
-
calculateDistance(importedModuleRef, distance + 1);
|
|
213
|
+
calculateDistance(importedModuleRef, distance + 1, localModulesStack);
|
|
214
214
|
}
|
|
215
215
|
});
|
|
216
216
|
};
|
|
@@ -66,7 +66,7 @@ export declare class Reflector {
|
|
|
66
66
|
* @param targets context (decorated objects) to retrieve metadata from
|
|
67
67
|
*
|
|
68
68
|
*/
|
|
69
|
-
getAll<
|
|
69
|
+
getAll<TParam = any, TTransformed = TParam>(decorator: ReflectableDecorator<TParam, TTransformed>, targets: (Type<any> | Function)[]): TTransformed extends Array<any> ? TTransformed : TTransformed[];
|
|
70
70
|
/**
|
|
71
71
|
* Retrieve metadata for a specified key for a specified set of targets.
|
|
72
72
|
*
|
|
@@ -82,7 +82,7 @@ export declare class Reflector {
|
|
|
82
82
|
* @param targets context (decorated objects) to retrieve metadata from
|
|
83
83
|
*
|
|
84
84
|
*/
|
|
85
|
-
getAllAndMerge<
|
|
85
|
+
getAllAndMerge<TParam = any, TTransformed = TParam>(decorator: ReflectableDecorator<TParam, TTransformed>, targets: (Type<any> | Function)[]): TTransformed extends Array<any> ? TTransformed : TTransformed extends object ? TTransformed : TTransformed[];
|
|
86
86
|
/**
|
|
87
87
|
* Retrieve metadata for a specified key for a specified set of targets and merge results.
|
|
88
88
|
*
|
|
@@ -98,7 +98,7 @@ export declare class Reflector {
|
|
|
98
98
|
* @param targets context (decorated objects) to retrieve metadata from
|
|
99
99
|
*
|
|
100
100
|
*/
|
|
101
|
-
getAllAndOverride<
|
|
101
|
+
getAllAndOverride<TParam = any, TTransformed = TParam>(decorator: ReflectableDecorator<TParam, TTransformed>, targets: (Type<any> | Function)[]): TTransformed;
|
|
102
102
|
/**
|
|
103
103
|
* Retrieve metadata for a specified key for a specified set of targets and return a first not undefined value.
|
|
104
104
|
*
|
|
@@ -60,6 +60,13 @@ class Reflector {
|
|
|
60
60
|
if ((0, shared_utils_1.isEmpty)(metadataCollection)) {
|
|
61
61
|
return metadataCollection;
|
|
62
62
|
}
|
|
63
|
+
if (metadataCollection.length === 1) {
|
|
64
|
+
const value = metadataCollection[0];
|
|
65
|
+
if ((0, shared_utils_1.isObject)(value)) {
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
return metadataCollection;
|
|
69
|
+
}
|
|
63
70
|
return metadataCollection.reduce((a, b) => {
|
|
64
71
|
if (Array.isArray(a)) {
|
|
65
72
|
return a.concat(b);
|