@nestjs/common 9.4.3 → 10.0.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/constants.d.ts +0 -4
- package/constants.js +1 -5
- package/decorators/core/inject.decorator.d.ts +1 -1
- package/decorators/core/optional.decorator.d.ts +1 -1
- package/decorators/http/request-mapping.decorator.d.ts +8 -0
- package/decorators/http/request-mapping.decorator.js +9 -1
- package/decorators/http/route-params.decorator.js +7 -4
- package/enums/http-status.enum.js +1 -1
- package/enums/request-method.enum.d.ts +2 -1
- package/enums/request-method.enum.js +2 -1
- package/enums/route-paramtypes.enum.js +1 -1
- package/enums/shutdown-signal.enum.js +1 -1
- package/enums/version-type.enum.js +1 -1
- package/exceptions/http.exception.d.ts +9 -8
- package/exceptions/http.exception.js +21 -23
- package/file-stream/streamable-file.js +1 -3
- package/index.d.ts +1 -2
- package/index.js +0 -1
- package/interfaces/features/arguments-host.interface.d.ts +4 -0
- package/interfaces/http/http-server.interface.d.ts +2 -2
- package/interfaces/http/index.d.ts +1 -0
- package/interfaces/http/index.js +1 -0
- package/interfaces/modules/injection-token.interface.d.ts +1 -1
- package/interfaces/nest-application.interface.d.ts +3 -3
- package/interfaces/scope-options.interface.js +1 -1
- package/module-utils/configurable-module.builder.js +14 -9
- package/module-utils/utils/get-injection-providers.util.js +4 -4
- package/package.json +1 -5
- package/pipes/default-value.pipe.js +2 -3
- package/pipes/file/file-type.validator.d.ts +2 -1
- package/pipes/file/file-type.validator.js +3 -4
- package/pipes/file/file-validator.interface.d.ts +2 -1
- package/pipes/file/max-file-size.validator.d.ts +2 -1
- package/pipes/file/max-file-size.validator.js +2 -2
- package/pipes/file/parse-file-pipe.builder.js +4 -1
- package/pipes/file/parse-file.pipe.js +3 -4
- package/pipes/parse-array.pipe.js +9 -6
- package/pipes/parse-bool.pipe.js +2 -3
- package/pipes/parse-enum.pipe.js +2 -3
- package/pipes/parse-float.pipe.js +2 -3
- package/pipes/parse-int.pipe.js +2 -3
- package/pipes/parse-uuid.pipe.js +3 -4
- package/pipes/validation.pipe.js +20 -9
- package/serializer/class-serializer.interceptor.js +9 -7
- package/services/console-logger.service.js +7 -10
- package/services/logger.service.js +14 -27
- package/services/utils/is-log-level-enabled.util.js +5 -6
- package/utils/assign-custom-metadata.util.js +5 -2
package/constants.d.ts
CHANGED
|
@@ -16,10 +16,6 @@ export declare const SCOPE_OPTIONS_METADATA = "scope:options";
|
|
|
16
16
|
export declare const METHOD_METADATA = "method";
|
|
17
17
|
export declare const ROUTE_ARGS_METADATA = "__routeArguments__";
|
|
18
18
|
export declare const CUSTOM_ROUTE_ARGS_METADATA = "__customRouteArgs__";
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated Use `CUSTOM_ROUTE_ARGS_METADATA` instead
|
|
21
|
-
*/
|
|
22
|
-
export declare const CUSTOM_ROUTE_AGRS_METADATA = "__customRouteArgs__";
|
|
23
19
|
export declare const FILTER_CATCH_EXCEPTIONS = "__filterCatchExceptions__";
|
|
24
20
|
export declare const PIPES_METADATA = "__pipes__";
|
|
25
21
|
export declare const GUARDS_METADATA = "__guards__";
|
package/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ENTRY_PROVIDER_WATERMARK = exports.CATCH_WATERMARK = exports.CONTROLLER_WATERMARK = exports.INJECTABLE_WATERMARK = exports.VERSION_METADATA = exports.SSE_METADATA = exports.RESPONSE_PASSTHROUGH_METADATA = exports.REDIRECT_METADATA = exports.HEADERS_METADATA = exports.MODULE_PATH = exports.HTTP_CODE_METADATA = exports.RENDER_METADATA = exports.ENHANCER_KEY_TO_SUBTYPE_MAP = exports.EXCEPTION_FILTERS_METADATA = exports.INTERCEPTORS_METADATA = exports.GUARDS_METADATA = exports.PIPES_METADATA = exports.FILTER_CATCH_EXCEPTIONS = exports.
|
|
3
|
+
exports.ENTRY_PROVIDER_WATERMARK = exports.CATCH_WATERMARK = exports.CONTROLLER_WATERMARK = exports.INJECTABLE_WATERMARK = exports.VERSION_METADATA = exports.SSE_METADATA = exports.RESPONSE_PASSTHROUGH_METADATA = exports.REDIRECT_METADATA = exports.HEADERS_METADATA = exports.MODULE_PATH = exports.HTTP_CODE_METADATA = exports.RENDER_METADATA = exports.ENHANCER_KEY_TO_SUBTYPE_MAP = exports.EXCEPTION_FILTERS_METADATA = exports.INTERCEPTORS_METADATA = exports.GUARDS_METADATA = exports.PIPES_METADATA = exports.FILTER_CATCH_EXCEPTIONS = exports.CUSTOM_ROUTE_ARGS_METADATA = exports.ROUTE_ARGS_METADATA = exports.METHOD_METADATA = exports.SCOPE_OPTIONS_METADATA = exports.OPTIONAL_PROPERTY_DEPS_METADATA = exports.PROPERTY_DEPS_METADATA = exports.OPTIONAL_DEPS_METADATA = exports.SELF_DECLARED_DEPS_METADATA = exports.PARAMTYPES_METADATA = exports.PATH_METADATA = exports.HOST_METADATA = exports.GLOBAL_MODULE_METADATA = exports.MODULE_METADATA = void 0;
|
|
4
4
|
exports.MODULE_METADATA = {
|
|
5
5
|
IMPORTS: 'imports',
|
|
6
6
|
PROVIDERS: 'providers',
|
|
@@ -19,10 +19,6 @@ exports.SCOPE_OPTIONS_METADATA = 'scope:options';
|
|
|
19
19
|
exports.METHOD_METADATA = 'method';
|
|
20
20
|
exports.ROUTE_ARGS_METADATA = '__routeArguments__';
|
|
21
21
|
exports.CUSTOM_ROUTE_ARGS_METADATA = '__customRouteArgs__';
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated Use `CUSTOM_ROUTE_ARGS_METADATA` instead
|
|
24
|
-
*/
|
|
25
|
-
exports.CUSTOM_ROUTE_AGRS_METADATA = exports.CUSTOM_ROUTE_ARGS_METADATA;
|
|
26
22
|
exports.FILTER_CATCH_EXCEPTIONS = '__filterCatchExceptions__';
|
|
27
23
|
exports.PIPES_METADATA = '__pipes__';
|
|
28
24
|
exports.GUARDS_METADATA = '__guards__';
|
|
@@ -68,3 +68,11 @@ export declare const Head: (path?: string | string[]) => MethodDecorator;
|
|
|
68
68
|
* @publicApi
|
|
69
69
|
*/
|
|
70
70
|
export declare const All: (path?: string | string[]) => MethodDecorator;
|
|
71
|
+
/**
|
|
72
|
+
* Route handler (method) Decorator. Routes all HTTP requests to the specified path.
|
|
73
|
+
*
|
|
74
|
+
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
75
|
+
*
|
|
76
|
+
* @publicApi
|
|
77
|
+
*/
|
|
78
|
+
export declare const Search: (path?: string | string[]) => MethodDecorator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.All = exports.Head = exports.Options = exports.Patch = exports.Put = exports.Delete = exports.Get = exports.Post = exports.RequestMapping = void 0;
|
|
3
|
+
exports.Search = exports.All = exports.Head = exports.Options = exports.Patch = exports.Put = exports.Delete = exports.Get = exports.Post = exports.RequestMapping = void 0;
|
|
4
4
|
const constants_1 = require("../../constants");
|
|
5
5
|
const request_method_enum_1 = require("../../enums/request-method.enum");
|
|
6
6
|
const defaultMetadata = {
|
|
@@ -88,3 +88,11 @@ exports.Head = createMappingDecorator(request_method_enum_1.RequestMethod.HEAD);
|
|
|
88
88
|
* @publicApi
|
|
89
89
|
*/
|
|
90
90
|
exports.All = createMappingDecorator(request_method_enum_1.RequestMethod.ALL);
|
|
91
|
+
/**
|
|
92
|
+
* Route handler (method) Decorator. Routes all HTTP requests to the specified path.
|
|
93
|
+
*
|
|
94
|
+
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
95
|
+
*
|
|
96
|
+
* @publicApi
|
|
97
|
+
*/
|
|
98
|
+
exports.Search = createMappingDecorator(request_method_enum_1.RequestMethod.SEARCH);
|
|
@@ -5,11 +5,14 @@ const constants_1 = require("../../constants");
|
|
|
5
5
|
const route_paramtypes_enum_1 = require("../../enums/route-paramtypes.enum");
|
|
6
6
|
const shared_utils_1 = require("../../utils/shared.utils");
|
|
7
7
|
function assignMetadata(args, paramtype, index, data, ...pipes) {
|
|
8
|
-
return
|
|
8
|
+
return {
|
|
9
|
+
...args,
|
|
10
|
+
[`${paramtype}:${index}`]: {
|
|
9
11
|
index,
|
|
10
12
|
data,
|
|
11
13
|
pipes,
|
|
12
|
-
}
|
|
14
|
+
},
|
|
15
|
+
};
|
|
13
16
|
}
|
|
14
17
|
exports.assignMetadata = assignMetadata;
|
|
15
18
|
function createRouteParamDecorator(paramtype) {
|
|
@@ -47,8 +50,8 @@ exports.Request = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamty
|
|
|
47
50
|
* @publicApi
|
|
48
51
|
*/
|
|
49
52
|
const Response = (options) => (target, key, index) => {
|
|
50
|
-
if (options
|
|
51
|
-
Reflect.defineMetadata(constants_1.RESPONSE_PASSTHROUGH_METADATA, options
|
|
53
|
+
if (options?.passthrough) {
|
|
54
|
+
Reflect.defineMetadata(constants_1.RESPONSE_PASSTHROUGH_METADATA, options?.passthrough, target.constructor, key);
|
|
52
55
|
}
|
|
53
56
|
return createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.RESPONSE)()(target, key, index);
|
|
54
57
|
};
|
|
@@ -54,4 +54,4 @@ var HttpStatus;
|
|
|
54
54
|
HttpStatus[HttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
55
55
|
HttpStatus[HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
56
56
|
HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
57
|
-
})(HttpStatus
|
|
57
|
+
})(HttpStatus || (exports.HttpStatus = HttpStatus = {}));
|
|
@@ -11,4 +11,5 @@ var RequestMethod;
|
|
|
11
11
|
RequestMethod[RequestMethod["ALL"] = 5] = "ALL";
|
|
12
12
|
RequestMethod[RequestMethod["OPTIONS"] = 6] = "OPTIONS";
|
|
13
13
|
RequestMethod[RequestMethod["HEAD"] = 7] = "HEAD";
|
|
14
|
-
|
|
14
|
+
RequestMethod[RequestMethod["SEARCH"] = 8] = "SEARCH";
|
|
15
|
+
})(RequestMethod || (exports.RequestMethod = RequestMethod = {}));
|
|
@@ -15,4 +15,4 @@ var RouteParamtypes;
|
|
|
15
15
|
RouteParamtypes[RouteParamtypes["FILES"] = 9] = "FILES";
|
|
16
16
|
RouteParamtypes[RouteParamtypes["HOST"] = 10] = "HOST";
|
|
17
17
|
RouteParamtypes[RouteParamtypes["IP"] = 11] = "IP";
|
|
18
|
-
})(RouteParamtypes
|
|
18
|
+
})(RouteParamtypes || (exports.RouteParamtypes = RouteParamtypes = {}));
|
|
@@ -17,4 +17,4 @@ var ShutdownSignal;
|
|
|
17
17
|
ShutdownSignal["SIGSEGV"] = "SIGSEGV";
|
|
18
18
|
ShutdownSignal["SIGUSR2"] = "SIGUSR2";
|
|
19
19
|
ShutdownSignal["SIGTERM"] = "SIGTERM";
|
|
20
|
-
})(ShutdownSignal
|
|
20
|
+
})(ShutdownSignal || (exports.ShutdownSignal = ShutdownSignal = {}));
|
|
@@ -10,4 +10,4 @@ var VersioningType;
|
|
|
10
10
|
VersioningType[VersioningType["HEADER"] = 1] = "HEADER";
|
|
11
11
|
VersioningType[VersioningType["MEDIA_TYPE"] = 2] = "MEDIA_TYPE";
|
|
12
12
|
VersioningType[VersioningType["CUSTOM"] = 3] = "CUSTOM";
|
|
13
|
-
})(VersioningType
|
|
13
|
+
})(VersioningType || (exports.VersioningType = VersioningType = {}));
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { HttpExceptionBody, HttpExceptionBodyMessage } from '../interfaces/http/http-exception-body.interface';
|
|
1
2
|
export interface HttpExceptionOptions {
|
|
2
|
-
cause
|
|
3
|
+
/** original cause of the error */
|
|
4
|
+
cause?: unknown;
|
|
3
5
|
description?: string;
|
|
4
6
|
}
|
|
5
7
|
export interface DescriptionAndOptions {
|
|
@@ -24,8 +26,6 @@ export declare class HttpException extends Error {
|
|
|
24
26
|
* @example
|
|
25
27
|
* throw new HttpException()
|
|
26
28
|
* throw new HttpException('message', HttpStatus.BAD_REQUEST)
|
|
27
|
-
* throw new HttpException({ reason: 'this can be a human readable reason' }, HttpStatus.BAD_REQUEST)
|
|
28
|
-
* throw new HttpException(new Error('Cause Error'), HttpStatus.BAD_REQUEST)
|
|
29
29
|
* throw new HttpException('custom message', HttpStatus.BAD_REQUEST, {
|
|
30
30
|
* cause: new Error('Cause Error'),
|
|
31
31
|
* })
|
|
@@ -55,20 +55,21 @@ export declare class HttpException extends Error {
|
|
|
55
55
|
* @param options An object used to add an error cause.
|
|
56
56
|
*/
|
|
57
57
|
constructor(response: string | Record<string, any>, status: number, options?: HttpExceptionOptions);
|
|
58
|
-
cause:
|
|
58
|
+
cause: unknown;
|
|
59
59
|
/**
|
|
60
60
|
* Configures error chaining support
|
|
61
61
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* - https://github.com/microsoft/TypeScript/issues/45167
|
|
62
|
+
* @see https://nodejs.org/en/blog/release/v16.9.0/#error-cause
|
|
63
|
+
* @see https://github.com/microsoft/TypeScript/issues/45167
|
|
65
64
|
*/
|
|
66
65
|
initCause(): void;
|
|
67
66
|
initMessage(): void;
|
|
68
67
|
initName(): void;
|
|
69
68
|
getResponse(): string | object;
|
|
70
69
|
getStatus(): number;
|
|
71
|
-
static createBody(
|
|
70
|
+
static createBody(nil: null | '', message: HttpExceptionBodyMessage, statusCode: number): HttpExceptionBody;
|
|
71
|
+
static createBody(message: HttpExceptionBodyMessage, error: string, statusCode: number): HttpExceptionBody;
|
|
72
|
+
static createBody<Body extends Record<string, unknown>>(custom: Body): Body;
|
|
72
73
|
static getDescriptionFrom(descriptionOrOptions: string | HttpExceptionOptions): string;
|
|
73
74
|
static getHttpExceptionOptionsFrom(descriptionOrOptions: string | HttpExceptionOptions): HttpExceptionOptions;
|
|
74
75
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpException = void 0;
|
|
4
|
-
const services_1 = require("../services");
|
|
5
4
|
const shared_utils_1 = require("../utils/shared.utils");
|
|
6
5
|
/**
|
|
7
6
|
* Defines the base Nest HTTP exception, which is handled by the default
|
|
@@ -18,8 +17,6 @@ class HttpException extends Error {
|
|
|
18
17
|
* @example
|
|
19
18
|
* throw new HttpException()
|
|
20
19
|
* throw new HttpException('message', HttpStatus.BAD_REQUEST)
|
|
21
|
-
* throw new HttpException({ reason: 'this can be a human readable reason' }, HttpStatus.BAD_REQUEST)
|
|
22
|
-
* throw new HttpException(new Error('Cause Error'), HttpStatus.BAD_REQUEST)
|
|
23
20
|
* throw new HttpException('custom message', HttpStatus.BAD_REQUEST, {
|
|
24
21
|
* cause: new Error('Cause Error'),
|
|
25
22
|
* })
|
|
@@ -60,23 +57,16 @@ class HttpException extends Error {
|
|
|
60
57
|
/**
|
|
61
58
|
* Configures error chaining support
|
|
62
59
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* - https://github.com/microsoft/TypeScript/issues/45167
|
|
60
|
+
* @see https://nodejs.org/en/blog/release/v16.9.0/#error-cause
|
|
61
|
+
* @see https://github.com/microsoft/TypeScript/issues/45167
|
|
66
62
|
*/
|
|
67
63
|
initCause() {
|
|
68
|
-
|
|
69
|
-
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.cause) {
|
|
64
|
+
if (this.options?.cause) {
|
|
70
65
|
this.cause = this.options.cause;
|
|
71
66
|
return;
|
|
72
67
|
}
|
|
73
|
-
if (this.response instanceof Error) {
|
|
74
|
-
services_1.Logger.warn('DEPRECATED! Passing the error cause as the first argument to HttpException constructor is deprecated. You should use the "options" parameter instead: new HttpException("message", 400, { cause: new Error("Some Error") }) ');
|
|
75
|
-
this.cause = this.response;
|
|
76
|
-
}
|
|
77
68
|
}
|
|
78
69
|
initMessage() {
|
|
79
|
-
var _a, _b;
|
|
80
70
|
if ((0, shared_utils_1.isString)(this.response)) {
|
|
81
71
|
this.message = this.response;
|
|
82
72
|
}
|
|
@@ -86,7 +76,8 @@ class HttpException extends Error {
|
|
|
86
76
|
}
|
|
87
77
|
else if (this.constructor) {
|
|
88
78
|
this.message =
|
|
89
|
-
|
|
79
|
+
this.constructor.name.match(/[A-Z][a-z]+|[0-9]+/g)?.join(' ') ??
|
|
80
|
+
'Error';
|
|
90
81
|
}
|
|
91
82
|
}
|
|
92
83
|
initName() {
|
|
@@ -98,19 +89,26 @@ class HttpException extends Error {
|
|
|
98
89
|
getStatus() {
|
|
99
90
|
return this.status;
|
|
100
91
|
}
|
|
101
|
-
static createBody(
|
|
102
|
-
if (!
|
|
103
|
-
return {
|
|
92
|
+
static createBody(arg0, arg1, statusCode) {
|
|
93
|
+
if (!arg0) {
|
|
94
|
+
return {
|
|
95
|
+
message: arg1,
|
|
96
|
+
statusCode: statusCode,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if ((0, shared_utils_1.isString)(arg0) || Array.isArray(arg0)) {
|
|
100
|
+
return {
|
|
101
|
+
message: arg0,
|
|
102
|
+
error: arg1,
|
|
103
|
+
statusCode: statusCode,
|
|
104
|
+
};
|
|
104
105
|
}
|
|
105
|
-
return
|
|
106
|
-
!Array.isArray(objectOrErrorMessage)
|
|
107
|
-
? objectOrErrorMessage
|
|
108
|
-
: { statusCode, message: objectOrErrorMessage, error: description };
|
|
106
|
+
return arg0;
|
|
109
107
|
}
|
|
110
108
|
static getDescriptionFrom(descriptionOrOptions) {
|
|
111
109
|
return (0, shared_utils_1.isString)(descriptionOrOptions)
|
|
112
110
|
? descriptionOrOptions
|
|
113
|
-
: descriptionOrOptions
|
|
111
|
+
: descriptionOrOptions?.description;
|
|
114
112
|
}
|
|
115
113
|
static getHttpExceptionOptionsFrom(descriptionOrOptions) {
|
|
116
114
|
return (0, shared_utils_1.isString)(descriptionOrOptions) ? {} : descriptionOrOptions;
|
|
@@ -123,7 +121,7 @@ class HttpException extends Error {
|
|
|
123
121
|
static extractDescriptionAndOptionsFrom(descriptionOrOptions) {
|
|
124
122
|
const description = (0, shared_utils_1.isString)(descriptionOrOptions)
|
|
125
123
|
? descriptionOrOptions
|
|
126
|
-
: descriptionOrOptions
|
|
124
|
+
: descriptionOrOptions?.description;
|
|
127
125
|
const httpExceptionOptions = (0, shared_utils_1.isString)(descriptionOrOptions)
|
|
128
126
|
? {}
|
|
129
127
|
: descriptionOrOptions;
|
|
@@ -12,8 +12,6 @@ const shared_utils_1 = require("../utils/shared.utils");
|
|
|
12
12
|
*/
|
|
13
13
|
class StreamableFile {
|
|
14
14
|
constructor(bufferOrReadStream, options = {}) {
|
|
15
|
-
var _a;
|
|
16
|
-
var _b;
|
|
17
15
|
this.options = options;
|
|
18
16
|
this.handleError = (err, res) => {
|
|
19
17
|
if (res.destroyed) {
|
|
@@ -30,7 +28,7 @@ class StreamableFile {
|
|
|
30
28
|
this.stream = new stream_1.Readable();
|
|
31
29
|
this.stream.push(bufferOrReadStream);
|
|
32
30
|
this.stream.push(null);
|
|
33
|
-
|
|
31
|
+
this.options.length ??= bufferOrReadStream.length;
|
|
34
32
|
}
|
|
35
33
|
else if (bufferOrReadStream.pipe && (0, shared_utils_1.isFunction)(bufferOrReadStream.pipe)) {
|
|
36
34
|
this.stream = bufferOrReadStream;
|
package/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
export * from './cache';
|
|
3
2
|
export * from './decorators';
|
|
4
3
|
export * from './enums';
|
|
5
4
|
export * from './exceptions';
|
|
6
5
|
export * from './file-stream';
|
|
7
|
-
export { Abstract, ArgumentMetadata, ArgumentsHost, BeforeApplicationShutdown, CallHandler, CanActivate, ClassProvider, ContextType, DynamicModule, ExceptionFilter, ExecutionContext, ExistingProvider, FactoryProvider, ForwardReference, HttpServer, INestApplication, INestApplicationContext, INestMicroservice, InjectionToken, IntrospectionResult, MessageEvent, MiddlewareConsumer, ModuleMetadata, NestApplicationOptions, NestHybridApplicationOptions, NestInterceptor, NestMiddleware, NestModule, OnApplicationBootstrap, OnApplicationShutdown, OnModuleDestroy, OnModuleInit, OptionalFactoryDependency, Paramtype, PipeTransform, Provider, RawBodyRequest, RpcExceptionFilter, Scope, ScopeOptions, Type, ValidationError, ValueProvider, VersioningOptions, VERSION_NEUTRAL, WebSocketAdapter, WsExceptionFilter, WsMessageHandler, } from './interfaces';
|
|
6
|
+
export { Abstract, ArgumentMetadata, ArgumentsHost, BeforeApplicationShutdown, CallHandler, CanActivate, ClassProvider, ContextType, DynamicModule, ExceptionFilter, ExecutionContext, ExistingProvider, FactoryProvider, ForwardReference, HttpServer, HttpExceptionBody, HttpExceptionBodyMessage, INestApplication, INestApplicationContext, INestMicroservice, InjectionToken, IntrospectionResult, MessageEvent, MiddlewareConsumer, ModuleMetadata, NestApplicationOptions, NestHybridApplicationOptions, NestInterceptor, NestMiddleware, NestModule, OnApplicationBootstrap, OnApplicationShutdown, OnModuleDestroy, OnModuleInit, OptionalFactoryDependency, Paramtype, PipeTransform, Provider, RawBodyRequest, RpcExceptionFilter, Scope, ScopeOptions, Type, ValidationError, ValueProvider, VersioningOptions, VERSION_NEUTRAL, WebSocketAdapter, WsExceptionFilter, WsMessageHandler, } from './interfaces';
|
|
8
7
|
export * from './module-utils';
|
|
9
8
|
export * from './pipes';
|
|
10
9
|
export * from './serializer';
|
package/index.js
CHANGED
|
@@ -9,7 +9,6 @@ const tslib_1 = require("tslib");
|
|
|
9
9
|
* MIT Licensed
|
|
10
10
|
*/
|
|
11
11
|
require("reflect-metadata");
|
|
12
|
-
tslib_1.__exportStar(require("./cache"), exports);
|
|
13
12
|
tslib_1.__exportStar(require("./decorators"), exports);
|
|
14
13
|
tslib_1.__exportStar(require("./enums"), exports);
|
|
15
14
|
tslib_1.__exportStar(require("./exceptions"), exports);
|
|
@@ -4,7 +4,7 @@ import { NestApplicationOptions } from '../../interfaces/nest-application-option
|
|
|
4
4
|
import { VersioningOptions, VersionValue } from '../version-options.interface';
|
|
5
5
|
export type ErrorHandler<TRequest = any, TResponse = any> = (error: any, req: TRequest, res: TResponse, next?: Function) => any;
|
|
6
6
|
export type RequestHandler<TRequest = any, TResponse = any> = (req: TRequest, res: TResponse, next?: Function) => any;
|
|
7
|
-
export interface HttpServer<TRequest = any, TResponse = any> {
|
|
7
|
+
export interface HttpServer<TRequest = any, TResponse = any, ServerInstance = any> {
|
|
8
8
|
use(handler: RequestHandler<TRequest, TResponse> | ErrorHandler<TRequest, TResponse>): any;
|
|
9
9
|
use(path: string, handler: RequestHandler<TRequest, TResponse> | ErrorHandler<TRequest, TResponse>): any;
|
|
10
10
|
useBodyParser?(...args: any[]): any;
|
|
@@ -42,7 +42,7 @@ export interface HttpServer<TRequest = any, TResponse = any> {
|
|
|
42
42
|
getRequestHostname?(request: TRequest): string;
|
|
43
43
|
getRequestMethod?(request: TRequest): string;
|
|
44
44
|
getRequestUrl?(request: TRequest): string;
|
|
45
|
-
getInstance():
|
|
45
|
+
getInstance(): ServerInstance;
|
|
46
46
|
registerParserMiddleware(...args: any[]): any;
|
|
47
47
|
enableCors(options: CorsOptions | CorsOptionsDelegate<TRequest>): any;
|
|
48
48
|
getHttpServer(): any;
|
package/interfaces/http/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./http-exception-body.interface"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./http-server.interface"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./message-event.interface"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./raw-body-request.interface"), exports);
|
|
@@ -12,7 +12,7 @@ import { WebSocketAdapter } from './websockets/web-socket-adapter.interface';
|
|
|
12
12
|
*
|
|
13
13
|
* @publicApi
|
|
14
14
|
*/
|
|
15
|
-
export interface INestApplication extends INestApplicationContext {
|
|
15
|
+
export interface INestApplication<TServer = any> extends INestApplicationContext {
|
|
16
16
|
/**
|
|
17
17
|
* A wrapper function around HTTP adapter method: `adapter.use()`.
|
|
18
18
|
* Example `app.use(cors())`
|
|
@@ -85,9 +85,9 @@ export interface INestApplication extends INestApplicationContext {
|
|
|
85
85
|
/**
|
|
86
86
|
* Returns the underlying native HTTP server.
|
|
87
87
|
*
|
|
88
|
-
* @returns {
|
|
88
|
+
* @returns {TServer}
|
|
89
89
|
*/
|
|
90
|
-
getHttpServer():
|
|
90
|
+
getHttpServer(): TServer;
|
|
91
91
|
/**
|
|
92
92
|
* Returns the underlying HTTP adapter.
|
|
93
93
|
*
|
|
@@ -81,14 +81,13 @@ class ConfigurableModuleBuilder {
|
|
|
81
81
|
* easily construct dynamic configurable modules. See "ConfigurableModuleHost" interface for more details.
|
|
82
82
|
*/
|
|
83
83
|
build() {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
(_c = (_e = this.options).optionsInjectionToken) !== null && _c !== void 0 ? _c : (_e.optionsInjectionToken = this.options.moduleName
|
|
84
|
+
this.staticMethodKey ??= constants_1.DEFAULT_METHOD_KEY;
|
|
85
|
+
this.factoryClassMethodKey ??=
|
|
86
|
+
constants_1.DEFAULT_FACTORY_CLASS_METHOD_KEY;
|
|
87
|
+
this.options.optionsInjectionToken ??= this.options.moduleName
|
|
89
88
|
? this.constructInjectionTokenString()
|
|
90
|
-
: (0, utils_1.generateOptionsInjectionToken)()
|
|
91
|
-
|
|
89
|
+
: (0, utils_1.generateOptionsInjectionToken)();
|
|
90
|
+
this.transformModuleDefinition ??= definition => definition;
|
|
92
91
|
return {
|
|
93
92
|
ConfigurableModuleClass: this.createConfigurableModuleCls(),
|
|
94
93
|
MODULE_OPTIONS_TOKEN: this.options.optionsInjectionToken,
|
|
@@ -125,7 +124,10 @@ class ConfigurableModuleBuilder {
|
|
|
125
124
|
return self.transformModuleDefinition({
|
|
126
125
|
module: this,
|
|
127
126
|
providers,
|
|
128
|
-
},
|
|
127
|
+
}, {
|
|
128
|
+
...self.extras,
|
|
129
|
+
...options,
|
|
130
|
+
});
|
|
129
131
|
}
|
|
130
132
|
static [asyncMethodKey](options) {
|
|
131
133
|
const providers = this.createAsyncProviders(options);
|
|
@@ -139,7 +141,10 @@ class ConfigurableModuleBuilder {
|
|
|
139
141
|
module: this,
|
|
140
142
|
imports: options.imports || [],
|
|
141
143
|
providers,
|
|
142
|
-
},
|
|
144
|
+
}, {
|
|
145
|
+
...self.extras,
|
|
146
|
+
...options,
|
|
147
|
+
});
|
|
143
148
|
}
|
|
144
149
|
static omitExtras(input, extras) {
|
|
145
150
|
if (!extras) {
|
|
@@ -8,7 +8,7 @@ exports.getInjectionProviders = void 0;
|
|
|
8
8
|
* @returns x is OptionalFactoryDependency
|
|
9
9
|
*/
|
|
10
10
|
function isOptionalFactoryDependency(x) {
|
|
11
|
-
return !!(
|
|
11
|
+
return !!(x?.token && !x?.prototype);
|
|
12
12
|
}
|
|
13
13
|
const mapInjectToTokens = (t) => isOptionalFactoryDependency(t) ? t.token : t;
|
|
14
14
|
/**
|
|
@@ -21,12 +21,12 @@ function getInjectionProviders(providers, tokens) {
|
|
|
21
21
|
const result = [];
|
|
22
22
|
let search = tokens.map(mapInjectToTokens);
|
|
23
23
|
while (search.length > 0) {
|
|
24
|
-
const match = (providers
|
|
25
|
-
(search.includes(p) || search.includes(p
|
|
24
|
+
const match = (providers ?? []).filter(p => !result.includes(p) && // this prevents circular loops and duplication
|
|
25
|
+
(search.includes(p) || search.includes(p?.provide)));
|
|
26
26
|
result.push(...match);
|
|
27
27
|
// get injection tokens of the matched providers, if any
|
|
28
28
|
search = match
|
|
29
|
-
.filter(p => p
|
|
29
|
+
.filter(p => p?.inject)
|
|
30
30
|
.map(p => p.inject)
|
|
31
31
|
.flat()
|
|
32
32
|
.map(mapInjectToTokens);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.1",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"homepage": "https://nestjs.com",
|
|
@@ -23,16 +23,12 @@
|
|
|
23
23
|
"uid": "2.0.2"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"cache-manager": "<=5",
|
|
27
26
|
"class-transformer": "*",
|
|
28
27
|
"class-validator": "*",
|
|
29
28
|
"reflect-metadata": "^0.1.12",
|
|
30
29
|
"rxjs": "^7.1.0"
|
|
31
30
|
},
|
|
32
31
|
"peerDependenciesMeta": {
|
|
33
|
-
"cache-manager": {
|
|
34
|
-
"optional": true
|
|
35
|
-
},
|
|
36
32
|
"class-validator": {
|
|
37
33
|
"optional": true
|
|
38
34
|
},
|
|
@@ -11,7 +11,7 @@ const shared_utils_1 = require("../utils/shared.utils");
|
|
|
11
11
|
*
|
|
12
12
|
* @publicApi
|
|
13
13
|
*/
|
|
14
|
-
let DefaultValuePipe = class DefaultValuePipe {
|
|
14
|
+
let DefaultValuePipe = exports.DefaultValuePipe = class DefaultValuePipe {
|
|
15
15
|
constructor(defaultValue) {
|
|
16
16
|
this.defaultValue = defaultValue;
|
|
17
17
|
}
|
|
@@ -23,8 +23,7 @@ let DefaultValuePipe = class DefaultValuePipe {
|
|
|
23
23
|
return value;
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
DefaultValuePipe = tslib_1.__decorate([
|
|
26
|
+
exports.DefaultValuePipe = DefaultValuePipe = tslib_1.__decorate([
|
|
27
27
|
(0, injectable_decorator_1.Injectable)(),
|
|
28
28
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
29
29
|
], DefaultValuePipe);
|
|
30
|
-
exports.DefaultValuePipe = DefaultValuePipe;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FileValidator } from './file-validator.interface';
|
|
2
|
+
import { IFile } from './interfaces';
|
|
2
3
|
export type FileTypeValidatorOptions = {
|
|
3
4
|
fileType: string | RegExp;
|
|
4
5
|
};
|
|
@@ -15,5 +16,5 @@ export type FileTypeValidatorOptions = {
|
|
|
15
16
|
*/
|
|
16
17
|
export declare class FileTypeValidator extends FileValidator<FileTypeValidatorOptions> {
|
|
17
18
|
buildErrorMessage(): string;
|
|
18
|
-
isValid(file
|
|
19
|
+
isValid<TFile extends IFile = any>(file?: TFile): boolean;
|
|
19
20
|
}
|
|
@@ -21,10 +21,9 @@ class FileTypeValidator extends file_validator_interface_1.FileValidator {
|
|
|
21
21
|
if (!this.validationOptions) {
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return Boolean(file.mimetype.match(this.validationOptions.fileType));
|
|
24
|
+
return (!!file &&
|
|
25
|
+
'mimetype' in file &&
|
|
26
|
+
!!file.mimetype.match(this.validationOptions.fileType));
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
exports.FileTypeValidator = FileTypeValidator;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IFile } from './interfaces';
|
|
1
2
|
/**
|
|
2
3
|
* Interface describing FileValidators, which can be added to a ParseFilePipe
|
|
3
4
|
*
|
|
@@ -11,7 +12,7 @@ export declare abstract class FileValidator<TValidationOptions = Record<string,
|
|
|
11
12
|
* Indicates if this file should be considered valid, according to the options passed in the constructor.
|
|
12
13
|
* @param file the file from the request object
|
|
13
14
|
*/
|
|
14
|
-
abstract isValid(file?:
|
|
15
|
+
abstract isValid<TFile extends IFile = any>(file?: TFile): boolean | Promise<boolean>;
|
|
15
16
|
/**
|
|
16
17
|
* Builds an error message in case the validation fails.
|
|
17
18
|
* @param file the file from the request object
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FileValidator } from './file-validator.interface';
|
|
2
|
+
import { IFile } from './interfaces';
|
|
2
3
|
export type MaxFileSizeValidatorOptions = {
|
|
3
4
|
maxSize: number;
|
|
4
5
|
message?: string | ((maxSize: number) => string);
|
|
@@ -12,5 +13,5 @@ export type MaxFileSizeValidatorOptions = {
|
|
|
12
13
|
*/
|
|
13
14
|
export declare class MaxFileSizeValidator extends FileValidator<MaxFileSizeValidatorOptions> {
|
|
14
15
|
buildErrorMessage(): string;
|
|
15
|
-
isValid(file
|
|
16
|
+
isValid<TFile extends IFile = any>(file?: TFile): boolean;
|
|
16
17
|
}
|
|
@@ -20,10 +20,10 @@ class MaxFileSizeValidator extends file_validator_interface_1.FileValidator {
|
|
|
20
20
|
return `Validation failed (expected size is less than ${this.validationOptions.maxSize})`;
|
|
21
21
|
}
|
|
22
22
|
isValid(file) {
|
|
23
|
-
if (!this.validationOptions) {
|
|
23
|
+
if (!this.validationOptions || !file) {
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
|
-
return file.size < this.validationOptions.maxSize;
|
|
26
|
+
return 'size' in file && file.size < this.validationOptions.maxSize;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
exports.MaxFileSizeValidator = MaxFileSizeValidator;
|
|
@@ -22,7 +22,10 @@ class ParseFilePipeBuilder {
|
|
|
22
22
|
return this;
|
|
23
23
|
}
|
|
24
24
|
build(additionalOptions) {
|
|
25
|
-
const parseFilePipe = new parse_file_pipe_1.ParseFilePipe(
|
|
25
|
+
const parseFilePipe = new parse_file_pipe_1.ParseFilePipe({
|
|
26
|
+
...additionalOptions,
|
|
27
|
+
validators: this.validators,
|
|
28
|
+
});
|
|
26
29
|
this.validators = [];
|
|
27
30
|
return parseFilePipe;
|
|
28
31
|
}
|
|
@@ -16,14 +16,14 @@ const shared_utils_1 = require("../../utils/shared.utils");
|
|
|
16
16
|
*
|
|
17
17
|
* @publicApi
|
|
18
18
|
*/
|
|
19
|
-
let ParseFilePipe = class ParseFilePipe {
|
|
19
|
+
let ParseFilePipe = exports.ParseFilePipe = class ParseFilePipe {
|
|
20
20
|
constructor(options = {}) {
|
|
21
21
|
const { exceptionFactory, errorHttpStatusCode = enums_1.HttpStatus.BAD_REQUEST, validators = [], fileIsRequired, } = options;
|
|
22
22
|
this.exceptionFactory =
|
|
23
23
|
exceptionFactory ||
|
|
24
24
|
(error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
|
|
25
25
|
this.validators = validators;
|
|
26
|
-
this.fileIsRequired = fileIsRequired
|
|
26
|
+
this.fileIsRequired = fileIsRequired ?? true;
|
|
27
27
|
}
|
|
28
28
|
async transform(value) {
|
|
29
29
|
const areThereAnyFilesIn = this.thereAreNoFilesIn(value);
|
|
@@ -68,9 +68,8 @@ let ParseFilePipe = class ParseFilePipe {
|
|
|
68
68
|
return this.validators;
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
-
ParseFilePipe = tslib_1.__decorate([
|
|
71
|
+
exports.ParseFilePipe = ParseFilePipe = tslib_1.__decorate([
|
|
72
72
|
(0, core_1.Injectable)(),
|
|
73
73
|
tslib_1.__param(0, (0, core_1.Optional)()),
|
|
74
74
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
75
75
|
], ParseFilePipe);
|
|
76
|
-
exports.ParseFilePipe = ParseFilePipe;
|
|
@@ -17,10 +17,14 @@ const DEFAULT_ARRAY_SEPARATOR = ',';
|
|
|
17
17
|
*
|
|
18
18
|
* @publicApi
|
|
19
19
|
*/
|
|
20
|
-
let ParseArrayPipe = class ParseArrayPipe {
|
|
20
|
+
let ParseArrayPipe = exports.ParseArrayPipe = class ParseArrayPipe {
|
|
21
21
|
constructor(options = {}) {
|
|
22
22
|
this.options = options;
|
|
23
|
-
this.validationPipe = new validation_pipe_1.ValidationPipe(
|
|
23
|
+
this.validationPipe = new validation_pipe_1.ValidationPipe({
|
|
24
|
+
transform: true,
|
|
25
|
+
validateCustomDecorators: true,
|
|
26
|
+
...options,
|
|
27
|
+
});
|
|
24
28
|
const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST } = options;
|
|
25
29
|
this.exceptionFactory =
|
|
26
30
|
exceptionFactory ||
|
|
@@ -50,7 +54,7 @@ let ParseArrayPipe = class ParseArrayPipe {
|
|
|
50
54
|
.trim()
|
|
51
55
|
.split(this.options.separator || DEFAULT_ARRAY_SEPARATOR);
|
|
52
56
|
}
|
|
53
|
-
catch
|
|
57
|
+
catch {
|
|
54
58
|
throw this.exceptionFactory(VALIDATION_ERROR_MESSAGE);
|
|
55
59
|
}
|
|
56
60
|
}
|
|
@@ -66,7 +70,7 @@ let ParseArrayPipe = class ParseArrayPipe {
|
|
|
66
70
|
try {
|
|
67
71
|
item = JSON.parse(item);
|
|
68
72
|
}
|
|
69
|
-
catch
|
|
73
|
+
catch { }
|
|
70
74
|
}
|
|
71
75
|
if (isExpectedTypePrimitive) {
|
|
72
76
|
return this.validatePrimitive(item, index);
|
|
@@ -134,9 +138,8 @@ let ParseArrayPipe = class ParseArrayPipe {
|
|
|
134
138
|
return originalValue;
|
|
135
139
|
}
|
|
136
140
|
};
|
|
137
|
-
ParseArrayPipe = tslib_1.__decorate([
|
|
141
|
+
exports.ParseArrayPipe = ParseArrayPipe = tslib_1.__decorate([
|
|
138
142
|
(0, injectable_decorator_1.Injectable)(),
|
|
139
143
|
tslib_1.__param(0, (0, optional_decorator_1.Optional)()),
|
|
140
144
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
141
145
|
], ParseArrayPipe);
|
|
142
|
-
exports.ParseArrayPipe = ParseArrayPipe;
|
package/pipes/parse-bool.pipe.js
CHANGED
|
@@ -13,7 +13,7 @@ const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
|
|
|
13
13
|
*
|
|
14
14
|
* @publicApi
|
|
15
15
|
*/
|
|
16
|
-
let ParseBoolPipe = class ParseBoolPipe {
|
|
16
|
+
let ParseBoolPipe = exports.ParseBoolPipe = class ParseBoolPipe {
|
|
17
17
|
constructor(options) {
|
|
18
18
|
options = options || {};
|
|
19
19
|
const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST } = options;
|
|
@@ -54,9 +54,8 @@ let ParseBoolPipe = class ParseBoolPipe {
|
|
|
54
54
|
return value === false || value === 'false';
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
-
ParseBoolPipe = tslib_1.__decorate([
|
|
57
|
+
exports.ParseBoolPipe = ParseBoolPipe = tslib_1.__decorate([
|
|
58
58
|
(0, injectable_decorator_1.Injectable)(),
|
|
59
59
|
tslib_1.__param(0, (0, optional_decorator_1.Optional)()),
|
|
60
60
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
61
61
|
], ParseBoolPipe);
|
|
62
|
-
exports.ParseBoolPipe = ParseBoolPipe;
|
package/pipes/parse-enum.pipe.js
CHANGED
|
@@ -12,7 +12,7 @@ const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
|
|
|
12
12
|
*
|
|
13
13
|
* @publicApi
|
|
14
14
|
*/
|
|
15
|
-
let ParseEnumPipe = class ParseEnumPipe {
|
|
15
|
+
let ParseEnumPipe = exports.ParseEnumPipe = class ParseEnumPipe {
|
|
16
16
|
constructor(enumType, options) {
|
|
17
17
|
this.enumType = enumType;
|
|
18
18
|
if (!enumType) {
|
|
@@ -42,9 +42,8 @@ let ParseEnumPipe = class ParseEnumPipe {
|
|
|
42
42
|
return enumValues.includes(value);
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
ParseEnumPipe = tslib_1.__decorate([
|
|
45
|
+
exports.ParseEnumPipe = ParseEnumPipe = tslib_1.__decorate([
|
|
46
46
|
(0, core_1.Injectable)(),
|
|
47
47
|
tslib_1.__param(1, (0, core_1.Optional)()),
|
|
48
48
|
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
49
49
|
], ParseEnumPipe);
|
|
50
|
-
exports.ParseEnumPipe = ParseEnumPipe;
|
|
@@ -12,7 +12,7 @@ const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
|
|
|
12
12
|
*
|
|
13
13
|
* @publicApi
|
|
14
14
|
*/
|
|
15
|
-
let ParseFloatPipe = class ParseFloatPipe {
|
|
15
|
+
let ParseFloatPipe = exports.ParseFloatPipe = class ParseFloatPipe {
|
|
16
16
|
constructor(options) {
|
|
17
17
|
options = options || {};
|
|
18
18
|
const { exceptionFactory, errorHttpStatusCode = index_1.HttpStatus.BAD_REQUEST } = options;
|
|
@@ -43,9 +43,8 @@ let ParseFloatPipe = class ParseFloatPipe {
|
|
|
43
43
|
isFinite(value));
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
ParseFloatPipe = tslib_1.__decorate([
|
|
46
|
+
exports.ParseFloatPipe = ParseFloatPipe = tslib_1.__decorate([
|
|
47
47
|
(0, core_1.Injectable)(),
|
|
48
48
|
tslib_1.__param(0, (0, core_1.Optional)()),
|
|
49
49
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
50
50
|
], ParseFloatPipe);
|
|
51
|
-
exports.ParseFloatPipe = ParseFloatPipe;
|
package/pipes/parse-int.pipe.js
CHANGED
|
@@ -13,7 +13,7 @@ const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
|
|
|
13
13
|
*
|
|
14
14
|
* @publicApi
|
|
15
15
|
*/
|
|
16
|
-
let ParseIntPipe = class ParseIntPipe {
|
|
16
|
+
let ParseIntPipe = exports.ParseIntPipe = class ParseIntPipe {
|
|
17
17
|
constructor(options) {
|
|
18
18
|
options = options || {};
|
|
19
19
|
const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST } = options;
|
|
@@ -44,9 +44,8 @@ let ParseIntPipe = class ParseIntPipe {
|
|
|
44
44
|
isFinite(value));
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
ParseIntPipe = tslib_1.__decorate([
|
|
47
|
+
exports.ParseIntPipe = ParseIntPipe = tslib_1.__decorate([
|
|
48
48
|
(0, injectable_decorator_1.Injectable)(),
|
|
49
49
|
tslib_1.__param(0, (0, optional_decorator_1.Optional)()),
|
|
50
50
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
51
51
|
], ParseIntPipe);
|
|
52
|
-
exports.ParseIntPipe = ParseIntPipe;
|
package/pipes/parse-uuid.pipe.js
CHANGED
|
@@ -15,7 +15,7 @@ const shared_utils_1 = require("../utils/shared.utils");
|
|
|
15
15
|
*
|
|
16
16
|
* @publicApi
|
|
17
17
|
*/
|
|
18
|
-
let ParseUUIDPipe = ParseUUIDPipe_1 = class ParseUUIDPipe {
|
|
18
|
+
let ParseUUIDPipe = exports.ParseUUIDPipe = ParseUUIDPipe_1 = class ParseUUIDPipe {
|
|
19
19
|
constructor(options) {
|
|
20
20
|
options = options || {};
|
|
21
21
|
const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST, version, } = options;
|
|
@@ -35,7 +35,7 @@ let ParseUUIDPipe = ParseUUIDPipe_1 = class ParseUUIDPipe {
|
|
|
35
35
|
throw this.exceptionFactory('The value passed as UUID is not a string');
|
|
36
36
|
}
|
|
37
37
|
const pattern = ParseUUIDPipe_1.uuidRegExps[version];
|
|
38
|
-
return pattern
|
|
38
|
+
return pattern?.test(str);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
ParseUUIDPipe.uuidRegExps = {
|
|
@@ -44,9 +44,8 @@ ParseUUIDPipe.uuidRegExps = {
|
|
|
44
44
|
5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
|
|
45
45
|
all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
|
|
46
46
|
};
|
|
47
|
-
ParseUUIDPipe = ParseUUIDPipe_1 = tslib_1.__decorate([
|
|
47
|
+
exports.ParseUUIDPipe = ParseUUIDPipe = ParseUUIDPipe_1 = tslib_1.__decorate([
|
|
48
48
|
(0, injectable_decorator_1.Injectable)(),
|
|
49
49
|
tslib_1.__param(0, (0, optional_decorator_1.Optional)()),
|
|
50
50
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
51
51
|
], ParseUUIDPipe);
|
|
52
|
-
exports.ParseUUIDPipe = ParseUUIDPipe;
|
package/pipes/validation.pipe.js
CHANGED
|
@@ -17,12 +17,12 @@ let classTransformer = {};
|
|
|
17
17
|
*
|
|
18
18
|
* @publicApi
|
|
19
19
|
*/
|
|
20
|
-
let ValidationPipe = class ValidationPipe {
|
|
20
|
+
let ValidationPipe = exports.ValidationPipe = class ValidationPipe {
|
|
21
21
|
constructor(options) {
|
|
22
22
|
options = options || {};
|
|
23
|
-
const { transform, disableErrorMessages, errorHttpStatusCode, expectedType, transformOptions, validateCustomDecorators
|
|
23
|
+
const { transform, disableErrorMessages, errorHttpStatusCode, expectedType, transformOptions, validateCustomDecorators, ...validatorOptions } = options;
|
|
24
24
|
// @see https://github.com/nestjs/nest/issues/10683#issuecomment-1413690508
|
|
25
|
-
this.validatorOptions =
|
|
25
|
+
this.validatorOptions = { forbidUnknownValues: false, ...validatorOptions };
|
|
26
26
|
this.isTransformEnabled = !!transform;
|
|
27
27
|
this.transformOptions = transformOptions;
|
|
28
28
|
this.isDetailedOutputDisabled = disableErrorMessages;
|
|
@@ -35,14 +35,16 @@ let ValidationPipe = class ValidationPipe {
|
|
|
35
35
|
classTransformer = this.loadTransformer(options.transformerPackage);
|
|
36
36
|
}
|
|
37
37
|
loadValidator(validatorPackage) {
|
|
38
|
-
return (validatorPackage
|
|
38
|
+
return (validatorPackage ??
|
|
39
|
+
(0, load_package_util_1.loadPackage)('class-validator', 'ValidationPipe', () => require('class-validator')));
|
|
39
40
|
}
|
|
40
41
|
loadTransformer(transformerPackage) {
|
|
41
|
-
return (transformerPackage
|
|
42
|
+
return (transformerPackage ??
|
|
43
|
+
(0, load_package_util_1.loadPackage)('class-transformer', 'ValidationPipe', () => require('class-transformer')));
|
|
42
44
|
}
|
|
43
45
|
async transform(value, metadata) {
|
|
44
46
|
if (this.expectedType) {
|
|
45
|
-
metadata =
|
|
47
|
+
metadata = { ...metadata, metatype: this.expectedType };
|
|
46
48
|
}
|
|
47
49
|
const metatype = metadata.metatype;
|
|
48
50
|
if (!metatype || !this.toValidate(metadata)) {
|
|
@@ -117,6 +119,13 @@ let ValidationPipe = class ValidationPipe {
|
|
|
117
119
|
return value;
|
|
118
120
|
}
|
|
119
121
|
if (metatype === Boolean) {
|
|
122
|
+
if ((0, shared_utils_1.isUndefined)(value)) {
|
|
123
|
+
// This is an workaround to deal with optional boolean values since
|
|
124
|
+
// optional booleans shouldn't be parsed to a valid boolean when
|
|
125
|
+
// they were not defined
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
// Any fasly value but `undefined` will be parsed to `false`
|
|
120
129
|
return value === true || value === 'true';
|
|
121
130
|
}
|
|
122
131
|
if (metatype === Number) {
|
|
@@ -180,12 +189,14 @@ let ValidationPipe = class ValidationPipe {
|
|
|
180
189
|
for (const key in error.constraints) {
|
|
181
190
|
constraints[key] = `${parentPath}.${error.constraints[key]}`;
|
|
182
191
|
}
|
|
183
|
-
return
|
|
192
|
+
return {
|
|
193
|
+
...error,
|
|
194
|
+
constraints,
|
|
195
|
+
};
|
|
184
196
|
}
|
|
185
197
|
};
|
|
186
|
-
ValidationPipe = tslib_1.__decorate([
|
|
198
|
+
exports.ValidationPipe = ValidationPipe = tslib_1.__decorate([
|
|
187
199
|
(0, core_1.Injectable)(),
|
|
188
200
|
tslib_1.__param(0, (0, decorators_1.Optional)()),
|
|
189
201
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
190
202
|
], ValidationPipe);
|
|
191
|
-
exports.ValidationPipe = ValidationPipe;
|
|
@@ -16,20 +16,23 @@ const REFLECTOR = 'Reflector';
|
|
|
16
16
|
/**
|
|
17
17
|
* @publicApi
|
|
18
18
|
*/
|
|
19
|
-
let ClassSerializerInterceptor = class ClassSerializerInterceptor {
|
|
19
|
+
let ClassSerializerInterceptor = exports.ClassSerializerInterceptor = class ClassSerializerInterceptor {
|
|
20
20
|
constructor(reflector, defaultOptions = {}) {
|
|
21
|
-
var _a;
|
|
22
21
|
this.reflector = reflector;
|
|
23
22
|
this.defaultOptions = defaultOptions;
|
|
24
23
|
classTransformer =
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
defaultOptions?.transformerPackage ??
|
|
25
|
+
(0, load_package_util_1.loadPackage)('class-transformer', 'ClassSerializerInterceptor', () => require('class-transformer'));
|
|
26
|
+
if (!defaultOptions?.transformerPackage) {
|
|
27
27
|
require('class-transformer');
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
intercept(context, next) {
|
|
31
31
|
const contextOptions = this.getContextOptions(context);
|
|
32
|
-
const options =
|
|
32
|
+
const options = {
|
|
33
|
+
...this.defaultOptions,
|
|
34
|
+
...contextOptions,
|
|
35
|
+
};
|
|
33
36
|
return next
|
|
34
37
|
.handle()
|
|
35
38
|
.pipe((0, operators_1.map)((res) => this.serialize(res, options)));
|
|
@@ -65,10 +68,9 @@ let ClassSerializerInterceptor = class ClassSerializerInterceptor {
|
|
|
65
68
|
]);
|
|
66
69
|
}
|
|
67
70
|
};
|
|
68
|
-
ClassSerializerInterceptor = tslib_1.__decorate([
|
|
71
|
+
exports.ClassSerializerInterceptor = ClassSerializerInterceptor = tslib_1.__decorate([
|
|
69
72
|
(0, core_1.Injectable)(),
|
|
70
73
|
tslib_1.__param(0, (0, core_1.Inject)(REFLECTOR)),
|
|
71
74
|
tslib_1.__param(1, (0, core_1.Optional)()),
|
|
72
75
|
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
73
76
|
], ClassSerializerInterceptor);
|
|
74
|
-
exports.ClassSerializerInterceptor = ClassSerializerInterceptor;
|
|
@@ -22,7 +22,7 @@ const dateTimeFormatter = new Intl.DateTimeFormat(undefined, {
|
|
|
22
22
|
day: '2-digit',
|
|
23
23
|
month: '2-digit',
|
|
24
24
|
});
|
|
25
|
-
let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
25
|
+
let ConsoleLogger = exports.ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
26
26
|
constructor(context, options = {}) {
|
|
27
27
|
this.context = context;
|
|
28
28
|
this.options = options;
|
|
@@ -105,8 +105,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
105
105
|
this.context = this.originalContext;
|
|
106
106
|
}
|
|
107
107
|
isLevelEnabled(level) {
|
|
108
|
-
|
|
109
|
-
const logLevels = (_a = this.options) === null || _a === void 0 ? void 0 : _a.logLevels;
|
|
108
|
+
const logLevels = this.options?.logLevels;
|
|
110
109
|
return (0, utils_1.isLogLevelEnabled)(level, logLevels);
|
|
111
110
|
}
|
|
112
111
|
getTimestamp() {
|
|
@@ -119,7 +118,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
119
118
|
const timestampDiff = this.updateAndGetTimestampDiff();
|
|
120
119
|
const formattedLogLevel = logLevel.toUpperCase().padStart(7, ' ');
|
|
121
120
|
const formattedMessage = this.formatMessage(logLevel, message, pidMessage, formattedLogLevel, contextMessage, timestampDiff);
|
|
122
|
-
process[writeStreamType
|
|
121
|
+
process[writeStreamType ?? 'stdout'].write(formattedMessage);
|
|
123
122
|
});
|
|
124
123
|
}
|
|
125
124
|
formatPid(pid) {
|
|
@@ -153,8 +152,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
153
152
|
process.stderr.write(`${stack}\n`);
|
|
154
153
|
}
|
|
155
154
|
updateAndGetTimestampDiff() {
|
|
156
|
-
|
|
157
|
-
const includeTimestamp = ConsoleLogger_1.lastTimestampAt && ((_a = this.options) === null || _a === void 0 ? void 0 : _a.timestamp);
|
|
155
|
+
const includeTimestamp = ConsoleLogger_1.lastTimestampAt && this.options?.timestamp;
|
|
158
156
|
const result = includeTimestamp
|
|
159
157
|
? this.formatTimestampDiff(Date.now() - ConsoleLogger_1.lastTimestampAt)
|
|
160
158
|
: '';
|
|
@@ -165,7 +163,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
165
163
|
return (0, cli_colors_util_1.yellow)(` +${timestampDiff}ms`);
|
|
166
164
|
}
|
|
167
165
|
getContextAndMessagesToPrint(args) {
|
|
168
|
-
if (
|
|
166
|
+
if (args?.length <= 1) {
|
|
169
167
|
return { messages: args, context: this.context };
|
|
170
168
|
}
|
|
171
169
|
const lastElement = args[args.length - 1];
|
|
@@ -192,7 +190,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
192
190
|
};
|
|
193
191
|
}
|
|
194
192
|
const { messages, context } = this.getContextAndMessagesToPrint(args);
|
|
195
|
-
if (
|
|
193
|
+
if (messages?.length <= 1) {
|
|
196
194
|
return { messages, context };
|
|
197
195
|
}
|
|
198
196
|
const lastElement = messages[messages.length - 1];
|
|
@@ -228,10 +226,9 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
228
226
|
}
|
|
229
227
|
}
|
|
230
228
|
};
|
|
231
|
-
ConsoleLogger = ConsoleLogger_1 = tslib_1.__decorate([
|
|
229
|
+
exports.ConsoleLogger = ConsoleLogger = ConsoleLogger_1 = tslib_1.__decorate([
|
|
232
230
|
(0, core_1.Injectable)(),
|
|
233
231
|
tslib_1.__param(0, (0, core_1.Optional)()),
|
|
234
232
|
tslib_1.__param(1, (0, core_1.Optional)()),
|
|
235
233
|
tslib_1.__metadata("design:paramtypes", [String, Object])
|
|
236
234
|
], ConsoleLogger);
|
|
237
|
-
exports.ConsoleLogger = ConsoleLogger;
|
|
@@ -19,7 +19,7 @@ const dateTimeFormatter = new Intl.DateTimeFormat(undefined, {
|
|
|
19
19
|
/**
|
|
20
20
|
* @publicApi
|
|
21
21
|
*/
|
|
22
|
-
let Logger = Logger_1 = class Logger {
|
|
22
|
+
let Logger = exports.Logger = Logger_1 = class Logger {
|
|
23
23
|
constructor(context, options = {}) {
|
|
24
24
|
this.context = context;
|
|
25
25
|
this.options = options;
|
|
@@ -37,59 +37,49 @@ let Logger = Logger_1 = class Logger {
|
|
|
37
37
|
return Logger_1.staticInstanceRef;
|
|
38
38
|
}
|
|
39
39
|
error(message, ...optionalParams) {
|
|
40
|
-
var _a;
|
|
41
40
|
optionalParams = this.context
|
|
42
41
|
? (optionalParams.length ? optionalParams : [undefined]).concat(this.context)
|
|
43
42
|
: optionalParams;
|
|
44
|
-
|
|
43
|
+
this.localInstance?.error(message, ...optionalParams);
|
|
45
44
|
}
|
|
46
45
|
log(message, ...optionalParams) {
|
|
47
|
-
var _a;
|
|
48
46
|
optionalParams = this.context
|
|
49
47
|
? optionalParams.concat(this.context)
|
|
50
48
|
: optionalParams;
|
|
51
|
-
|
|
49
|
+
this.localInstance?.log(message, ...optionalParams);
|
|
52
50
|
}
|
|
53
51
|
warn(message, ...optionalParams) {
|
|
54
|
-
var _a;
|
|
55
52
|
optionalParams = this.context
|
|
56
53
|
? optionalParams.concat(this.context)
|
|
57
54
|
: optionalParams;
|
|
58
|
-
|
|
55
|
+
this.localInstance?.warn(message, ...optionalParams);
|
|
59
56
|
}
|
|
60
57
|
debug(message, ...optionalParams) {
|
|
61
|
-
var _a, _b;
|
|
62
58
|
optionalParams = this.context
|
|
63
59
|
? optionalParams.concat(this.context)
|
|
64
60
|
: optionalParams;
|
|
65
|
-
|
|
61
|
+
this.localInstance?.debug?.(message, ...optionalParams);
|
|
66
62
|
}
|
|
67
63
|
verbose(message, ...optionalParams) {
|
|
68
|
-
var _a, _b;
|
|
69
64
|
optionalParams = this.context
|
|
70
65
|
? optionalParams.concat(this.context)
|
|
71
66
|
: optionalParams;
|
|
72
|
-
|
|
67
|
+
this.localInstance?.verbose?.(message, ...optionalParams);
|
|
73
68
|
}
|
|
74
69
|
static error(message, ...optionalParams) {
|
|
75
|
-
|
|
76
|
-
(_a = this.staticInstanceRef) === null || _a === void 0 ? void 0 : _a.error(message, ...optionalParams);
|
|
70
|
+
this.staticInstanceRef?.error(message, ...optionalParams);
|
|
77
71
|
}
|
|
78
72
|
static log(message, ...optionalParams) {
|
|
79
|
-
|
|
80
|
-
(_a = this.staticInstanceRef) === null || _a === void 0 ? void 0 : _a.log(message, ...optionalParams);
|
|
73
|
+
this.staticInstanceRef?.log(message, ...optionalParams);
|
|
81
74
|
}
|
|
82
75
|
static warn(message, ...optionalParams) {
|
|
83
|
-
|
|
84
|
-
(_a = this.staticInstanceRef) === null || _a === void 0 ? void 0 : _a.warn(message, ...optionalParams);
|
|
76
|
+
this.staticInstanceRef?.warn(message, ...optionalParams);
|
|
85
77
|
}
|
|
86
78
|
static debug(message, ...optionalParams) {
|
|
87
|
-
|
|
88
|
-
(_b = (_a = this.staticInstanceRef) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
79
|
+
this.staticInstanceRef?.debug?.(message, ...optionalParams);
|
|
89
80
|
}
|
|
90
81
|
static verbose(message, ...optionalParams) {
|
|
91
|
-
|
|
92
|
-
(_b = (_a = this.staticInstanceRef) === null || _a === void 0 ? void 0 : _a.verbose) === null || _b === void 0 ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
82
|
+
this.staticInstanceRef?.verbose?.(message, ...optionalParams);
|
|
93
83
|
}
|
|
94
84
|
/**
|
|
95
85
|
* Print buffered logs and detach buffer.
|
|
@@ -117,10 +107,9 @@ let Logger = Logger_1 = class Logger {
|
|
|
117
107
|
return dateTimeFormatter.format(Date.now());
|
|
118
108
|
}
|
|
119
109
|
static overrideLogger(logger) {
|
|
120
|
-
var _a;
|
|
121
110
|
if (Array.isArray(logger)) {
|
|
122
111
|
Logger_1.logLevels = logger;
|
|
123
|
-
return
|
|
112
|
+
return this.staticInstanceRef?.setLogLevels(logger);
|
|
124
113
|
}
|
|
125
114
|
if ((0, shared_utils_1.isObject)(logger)) {
|
|
126
115
|
if (logger instanceof Logger_1 && logger.constructor !== Logger_1) {
|
|
@@ -139,12 +128,11 @@ let Logger = Logger_1 = class Logger {
|
|
|
139
128
|
return (0, utils_1.isLogLevelEnabled)(level, logLevels);
|
|
140
129
|
}
|
|
141
130
|
registerLocalInstanceRef() {
|
|
142
|
-
var _a;
|
|
143
131
|
if (this.localInstanceRef) {
|
|
144
132
|
return this.localInstanceRef;
|
|
145
133
|
}
|
|
146
134
|
this.localInstanceRef = new console_logger_service_1.ConsoleLogger(this.context, {
|
|
147
|
-
timestamp:
|
|
135
|
+
timestamp: this.options?.timestamp,
|
|
148
136
|
logLevels: Logger_1.logLevels,
|
|
149
137
|
});
|
|
150
138
|
return this.localInstanceRef;
|
|
@@ -225,10 +213,9 @@ tslib_1.__decorate([
|
|
|
225
213
|
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
226
214
|
tslib_1.__metadata("design:returntype", void 0)
|
|
227
215
|
], Logger, "verbose", null);
|
|
228
|
-
Logger = Logger_1 = tslib_1.__decorate([
|
|
216
|
+
exports.Logger = Logger = Logger_1 = tslib_1.__decorate([
|
|
229
217
|
(0, core_1.Injectable)(),
|
|
230
218
|
tslib_1.__param(0, (0, core_1.Optional)()),
|
|
231
219
|
tslib_1.__param(1, (0, core_1.Optional)()),
|
|
232
220
|
tslib_1.__metadata("design:paramtypes", [String, Object])
|
|
233
221
|
], Logger);
|
|
234
|
-
exports.Logger = Logger;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isLogLevelEnabled = void 0;
|
|
4
4
|
const LOG_LEVEL_VALUES = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
verbose: 0,
|
|
6
|
+
debug: 1,
|
|
7
7
|
log: 2,
|
|
8
8
|
warn: 3,
|
|
9
9
|
error: 4,
|
|
@@ -14,16 +14,15 @@ const LOG_LEVEL_VALUES = {
|
|
|
14
14
|
* @param logLevels array of enabled log levels
|
|
15
15
|
*/
|
|
16
16
|
function isLogLevelEnabled(targetLevel, logLevels) {
|
|
17
|
-
|
|
18
|
-
if (!logLevels || (Array.isArray(logLevels) && (logLevels === null || logLevels === void 0 ? void 0 : logLevels.length) === 0)) {
|
|
17
|
+
if (!logLevels || (Array.isArray(logLevels) && logLevels?.length === 0)) {
|
|
19
18
|
return false;
|
|
20
19
|
}
|
|
21
20
|
if (logLevels.includes(targetLevel)) {
|
|
22
21
|
return true;
|
|
23
22
|
}
|
|
24
|
-
const highestLogLevelValue =
|
|
23
|
+
const highestLogLevelValue = logLevels
|
|
25
24
|
.map(level => LOG_LEVEL_VALUES[level])
|
|
26
|
-
.sort((a, b) => b - a)
|
|
25
|
+
.sort((a, b) => b - a)?.[0];
|
|
27
26
|
const targetLevelValue = LOG_LEVEL_VALUES[targetLevel];
|
|
28
27
|
return targetLevelValue >= highestLogLevelValue;
|
|
29
28
|
}
|
|
@@ -3,11 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.assignCustomParameterMetadata = void 0;
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
function assignCustomParameterMetadata(args, paramtype, index, factory, data, ...pipes) {
|
|
6
|
-
return
|
|
6
|
+
return {
|
|
7
|
+
...args,
|
|
8
|
+
[`${paramtype}${constants_1.CUSTOM_ROUTE_ARGS_METADATA}:${index}`]: {
|
|
7
9
|
index,
|
|
8
10
|
factory,
|
|
9
11
|
data,
|
|
10
12
|
pipes,
|
|
11
|
-
}
|
|
13
|
+
},
|
|
14
|
+
};
|
|
12
15
|
}
|
|
13
16
|
exports.assignCustomParameterMetadata = assignCustomParameterMetadata;
|