@nestjs/common 9.3.0-beta.3 → 9.3.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/cache/decorators/cache-ttl.decorator.d.ts +1 -1
- package/cache/interceptors/cache.interceptor.d.ts +5 -0
- package/cache/interceptors/cache.interceptor.js +5 -0
- package/cache/interfaces/cache-manager.interface.d.ts +2 -2
- package/cache/interfaces/cache-module.interface.d.ts +1 -1
- package/constants.d.ts +1 -1
- package/decorators/core/dependencies.decorator.d.ts +2 -0
- package/decorators/core/dependencies.decorator.js +2 -0
- package/decorators/core/inject.decorator.d.ts +1 -1
- package/decorators/core/injectable.decorator.d.ts +4 -1
- package/decorators/core/injectable.decorator.js +5 -2
- package/decorators/core/optional.decorator.d.ts +1 -1
- package/decorators/core/set-metadata.decorator.d.ts +1 -1
- package/decorators/http/create-route-param-metadata.decorator.d.ts +3 -1
- package/decorators/http/create-route-param-metadata.decorator.js +4 -2
- package/decorators/http/route-params.decorator.d.ts +1 -1
- package/enums/http-status.enum.d.ts +3 -0
- package/enums/http-status.enum.js +3 -0
- package/exceptions/http.exception.js +3 -3
- package/file-stream/interfaces/index.d.ts +2 -0
- package/file-stream/interfaces/index.js +5 -0
- package/file-stream/interfaces/streamable-handler-response.interface.d.ts +12 -0
- package/file-stream/{streamable-options.interface.js → interfaces/streamable-handler-response.interface.js} +0 -0
- package/file-stream/{streamable-options.interface.d.ts → interfaces/streamable-options.interface.d.ts} +5 -0
- package/file-stream/interfaces/streamable-options.interface.js +2 -0
- package/file-stream/streamable-file.d.ts +6 -6
- package/file-stream/streamable-file.js +14 -3
- package/interfaces/controllers/controller.interface.d.ts +1 -1
- package/interfaces/external/cors-options.interface.d.ts +2 -2
- package/interfaces/features/arguments-host.interface.d.ts +1 -1
- package/interfaces/features/custom-route-param-factory.interface.d.ts +4 -1
- package/interfaces/features/paramtype.interface.d.ts +4 -1
- package/interfaces/features/pipe-transform.interface.d.ts +1 -1
- package/interfaces/http/http-server.interface.d.ts +3 -2
- package/interfaces/http/raw-body-request.interface.d.ts +4 -1
- package/interfaces/injectable.interface.d.ts +1 -1
- package/interfaces/microservices/nest-hybrid-application-options.interface.d.ts +3 -0
- package/interfaces/microservices/nest-microservice-options.interface.d.ts +4 -1
- package/interfaces/middleware/middleware-config-proxy.interface.d.ts +3 -0
- package/interfaces/middleware/nest-middleware.interface.d.ts +5 -0
- package/interfaces/modules/injection-token.interface.d.ts +4 -1
- package/interfaces/modules/nest-module.interface.d.ts +3 -0
- package/interfaces/modules/optional-factory-dependency.interface.d.ts +4 -1
- package/interfaces/modules/provider.interface.d.ts +1 -1
- package/interfaces/version-options.interface.d.ts +20 -2
- package/interfaces/websockets/web-socket-adapter.interface.d.ts +6 -0
- package/module-utils/interfaces/configurable-module-async-options.interface.d.ts +1 -1
- package/module-utils/interfaces/configurable-module-cls.interface.d.ts +1 -1
- package/package.json +2 -2
- package/pipes/file/file-type.validator.d.ts +1 -1
- package/pipes/file/file-validator.interface.d.ts +2 -0
- package/pipes/file/file-validator.interface.js +2 -0
- package/pipes/file/max-file-size.validator.d.ts +1 -1
- package/pipes/file/parse-file-options.interface.d.ts +3 -0
- package/pipes/file/parse-file-pipe.builder.d.ts +3 -0
- package/pipes/file/parse-file-pipe.builder.js +3 -0
- package/pipes/file/parse-file.pipe.d.ts +2 -0
- package/pipes/file/parse-file.pipe.js +16 -3
- package/pipes/parse-array.pipe.d.ts +3 -0
- package/pipes/parse-bool.pipe.d.ts +3 -0
- package/pipes/parse-enum.pipe.d.ts +3 -0
- package/pipes/parse-float.pipe.d.ts +3 -0
- package/pipes/parse-int.pipe.d.ts +3 -0
- package/pipes/parse-uuid.pipe.d.ts +10 -0
- package/pipes/parse-uuid.pipe.js +7 -0
- package/pipes/validation.pipe.d.ts +8 -0
- package/pipes/validation.pipe.js +5 -0
- package/serializer/class-serializer.interceptor.d.ts +6 -0
- package/serializer/class-serializer.interceptor.js +3 -0
- package/serializer/class-serializer.interfaces.d.ts +3 -0
- package/serializer/decorators/serialize-options.decorator.d.ts +3 -0
- package/serializer/decorators/serialize-options.decorator.js +3 -0
- package/services/console-logger.service.js +9 -9
- package/services/logger.service.d.ts +10 -1
- package/services/logger.service.js +17 -15
- package/utils/forward-ref.util.d.ts +3 -0
- package/utils/forward-ref.util.js +3 -0
- package/utils/http-error-by-code.util.d.ts +1 -1
- package/utils/merge-with-values.util.d.ts +1 -1
- package/utils/random-string-generator.util.d.ts +1 -1
- package/utils/random-string-generator.util.js +2 -2
|
@@ -10,6 +10,6 @@ import { ExecutionContext } from '../../interfaces/features/execution-context.in
|
|
|
10
10
|
*
|
|
11
11
|
* @publicApi
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
type CacheTTLFactory = (ctx: ExecutionContext) => Promise<number> | number;
|
|
14
14
|
export declare const CacheTTL: (ttl: number | CacheTTLFactory) => import("../../decorators").CustomDecorator<string>;
|
|
15
15
|
export {};
|
|
@@ -3,6 +3,11 @@ import { CallHandler, ExecutionContext, HttpServer, NestInterceptor } from '../.
|
|
|
3
3
|
export interface HttpAdapterHost<T extends HttpServer = any> {
|
|
4
4
|
httpAdapter: T;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* @see [Caching](https://docs.nestjs.com/techniques/caching)
|
|
8
|
+
*
|
|
9
|
+
* @publicApi
|
|
10
|
+
*/
|
|
6
11
|
export declare class CacheInterceptor implements NestInterceptor {
|
|
7
12
|
protected readonly cacheManager: any;
|
|
8
13
|
protected readonly reflector: any;
|
|
@@ -10,6 +10,11 @@ const shared_utils_1 = require("../../utils/shared.utils");
|
|
|
10
10
|
const cache_constants_1 = require("../cache.constants");
|
|
11
11
|
const HTTP_ADAPTER_HOST = 'HttpAdapterHost';
|
|
12
12
|
const REFLECTOR = 'Reflector';
|
|
13
|
+
/**
|
|
14
|
+
* @see [Caching](https://docs.nestjs.com/techniques/caching)
|
|
15
|
+
*
|
|
16
|
+
* @publicApi
|
|
17
|
+
*/
|
|
13
18
|
let CacheInterceptor = class CacheInterceptor {
|
|
14
19
|
constructor(cacheManager, reflector) {
|
|
15
20
|
this.cacheManager = cacheManager;
|
|
@@ -40,7 +40,7 @@ export interface CacheStoreSetOptions<T> {
|
|
|
40
40
|
*
|
|
41
41
|
* @publicApi
|
|
42
42
|
*/
|
|
43
|
-
export
|
|
43
|
+
export type CacheStoreFactory = {
|
|
44
44
|
/**
|
|
45
45
|
* Return a configured cache store.
|
|
46
46
|
*
|
|
@@ -48,7 +48,7 @@ export interface CacheStoreFactory {
|
|
|
48
48
|
* or `CacheModule.registerAsync()`
|
|
49
49
|
*/
|
|
50
50
|
create(args: LiteralObject): CacheStore;
|
|
51
|
-
}
|
|
51
|
+
} | ((args: LiteralObject) => CacheStore | Promise<CacheStore>);
|
|
52
52
|
/**
|
|
53
53
|
* Interface defining Cache Manager configuration options.
|
|
54
54
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Provider, Type } from '../../interfaces';
|
|
2
2
|
import { ConfigurableModuleAsyncOptions } from '../../module-utils';
|
|
3
3
|
import { CacheManagerOptions } from './cache-manager.interface';
|
|
4
|
-
export
|
|
4
|
+
export type CacheModuleOptions<StoreConfig extends Record<any, any> = Record<string, any>> = CacheManagerOptions & StoreConfig & {
|
|
5
5
|
/**
|
|
6
6
|
* If "true', register `CacheModule` as a global module.
|
|
7
7
|
*/
|
package/constants.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare const ENHANCER_KEY_TO_SUBTYPE_MAP: {
|
|
|
31
31
|
readonly __pipes__: "pipe";
|
|
32
32
|
readonly __exceptionFilters__: "filter";
|
|
33
33
|
};
|
|
34
|
-
export
|
|
34
|
+
export type EnhancerSubtype = typeof ENHANCER_KEY_TO_SUBTYPE_MAP[keyof typeof ENHANCER_KEY_TO_SUBTYPE_MAP];
|
|
35
35
|
export declare const RENDER_METADATA = "__renderTemplate__";
|
|
36
36
|
export declare const HTTP_CODE_METADATA = "__httpCode__";
|
|
37
37
|
export declare const MODULE_PATH = "__module_path__";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare function flatten<T extends Array<unknown> = any>(arr: T): T extends Array<infer R> ? R : never;
|
|
2
2
|
/**
|
|
3
3
|
* Decorator that sets required dependencies (required with a vanilla JavaScript objects)
|
|
4
|
+
*
|
|
5
|
+
* @publicApi
|
|
4
6
|
*/
|
|
5
7
|
export declare const Dependencies: (...dependencies: Array<unknown>) => ClassDecorator;
|
|
@@ -9,6 +9,8 @@ function flatten(arr) {
|
|
|
9
9
|
exports.flatten = flatten;
|
|
10
10
|
/**
|
|
11
11
|
* Decorator that sets required dependencies (required with a vanilla JavaScript objects)
|
|
12
|
+
*
|
|
13
|
+
* @publicApi
|
|
12
14
|
*/
|
|
13
15
|
const Dependencies = (...dependencies) => {
|
|
14
16
|
const flattenDeps = flatten(dependencies);
|
|
@@ -27,4 +27,4 @@
|
|
|
27
27
|
*
|
|
28
28
|
* @publicApi
|
|
29
29
|
*/
|
|
30
|
-
export declare function Inject<T = any>(token?: T): (target: object, key: string | symbol, index?: number) => void;
|
|
30
|
+
export declare function Inject<T = any>(token?: T): (target: object, key: string | symbol | undefined, index?: number) => void;
|
|
@@ -7,7 +7,7 @@ import { Type } from '../../interfaces/type.interface';
|
|
|
7
7
|
*
|
|
8
8
|
* @publicApi
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type InjectableOptions = ScopeOptions;
|
|
11
11
|
/**
|
|
12
12
|
* Decorator that marks a class as a [provider](https://docs.nestjs.com/providers).
|
|
13
13
|
* Providers can be injected into other classes via constructor parameter injection
|
|
@@ -37,4 +37,7 @@ export declare type InjectableOptions = ScopeOptions;
|
|
|
37
37
|
* @publicApi
|
|
38
38
|
*/
|
|
39
39
|
export declare function Injectable(options?: InjectableOptions): ClassDecorator;
|
|
40
|
+
/**
|
|
41
|
+
* @publicApi
|
|
42
|
+
*/
|
|
40
43
|
export declare function mixin<T>(mixinClass: Type<T>): Type<T>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mixin = exports.Injectable = void 0;
|
|
4
|
-
const
|
|
4
|
+
const uid_1 = require("uid");
|
|
5
5
|
const constants_1 = require("../../constants");
|
|
6
6
|
/**
|
|
7
7
|
* Decorator that marks a class as a [provider](https://docs.nestjs.com/providers).
|
|
@@ -38,9 +38,12 @@ function Injectable(options) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
exports.Injectable = Injectable;
|
|
41
|
+
/**
|
|
42
|
+
* @publicApi
|
|
43
|
+
*/
|
|
41
44
|
function mixin(mixinClass) {
|
|
42
45
|
Object.defineProperty(mixinClass, 'name', {
|
|
43
|
-
value: (0,
|
|
46
|
+
value: (0, uid_1.uid)(21),
|
|
44
47
|
});
|
|
45
48
|
Injectable()(mixinClass);
|
|
46
49
|
return mixinClass;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { PipeTransform } from '../../index';
|
|
2
2
|
import { Type } from '../../interfaces';
|
|
3
3
|
import { CustomParamFactory } from '../../interfaces/features/custom-route-param-factory.interface';
|
|
4
|
-
export
|
|
4
|
+
export type ParamDecoratorEnhancer = ParameterDecorator;
|
|
5
5
|
/**
|
|
6
6
|
* Defines HTTP route param decorator
|
|
7
7
|
*
|
|
8
8
|
* @param factory
|
|
9
|
+
*
|
|
10
|
+
* @publicApi
|
|
9
11
|
*/
|
|
10
12
|
export declare function createParamDecorator<FactoryData = any, FactoryInput = any, FactoryOutput = any>(factory: CustomParamFactory<FactoryData, FactoryInput, FactoryOutput>, enhancers?: ParamDecoratorEnhancer[]): (...dataOrPipes: (Type<PipeTransform> | PipeTransform | FactoryData)[]) => ParameterDecorator;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createParamDecorator = void 0;
|
|
4
|
-
const
|
|
4
|
+
const uid_1 = require("uid");
|
|
5
5
|
const constants_1 = require("../../constants");
|
|
6
6
|
const assign_custom_metadata_util_1 = require("../../utils/assign-custom-metadata.util");
|
|
7
7
|
const shared_utils_1 = require("../../utils/shared.utils");
|
|
@@ -9,9 +9,11 @@ const shared_utils_1 = require("../../utils/shared.utils");
|
|
|
9
9
|
* Defines HTTP route param decorator
|
|
10
10
|
*
|
|
11
11
|
* @param factory
|
|
12
|
+
*
|
|
13
|
+
* @publicApi
|
|
12
14
|
*/
|
|
13
15
|
function createParamDecorator(factory, enhancers = []) {
|
|
14
|
-
const paramtype = (0,
|
|
16
|
+
const paramtype = (0, uid_1.uid)(21);
|
|
15
17
|
return (data, ...pipes) => (target, key, index) => {
|
|
16
18
|
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) || {};
|
|
17
19
|
const isPipe = (pipe) => pipe &&
|
|
@@ -13,7 +13,7 @@ export interface ResponseDecoratorOptions {
|
|
|
13
13
|
*/
|
|
14
14
|
passthrough: boolean;
|
|
15
15
|
}
|
|
16
|
-
export
|
|
16
|
+
export type ParamData = object | string | number;
|
|
17
17
|
export interface RouteParamMetadata {
|
|
18
18
|
index: number;
|
|
19
19
|
data?: ParamData;
|
|
@@ -76,6 +76,7 @@ class HttpException extends Error {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
initMessage() {
|
|
79
|
+
var _a, _b;
|
|
79
80
|
if ((0, shared_utils_1.isString)(this.response)) {
|
|
80
81
|
this.message = this.response;
|
|
81
82
|
}
|
|
@@ -84,9 +85,8 @@ class HttpException extends Error {
|
|
|
84
85
|
this.message = this.response.message;
|
|
85
86
|
}
|
|
86
87
|
else if (this.constructor) {
|
|
87
|
-
this.message = this.constructor.name
|
|
88
|
-
.match(/[A-Z][a-z]+|[0-9]+/g)
|
|
89
|
-
.join(' ');
|
|
88
|
+
this.message = (_b = (_a = this.constructor.name
|
|
89
|
+
.match(/[A-Z][a-z]+|[0-9]+/g)) === null || _a === void 0 ? void 0 : _a.join(' ')) !== null && _b !== void 0 ? _b : 'Error';
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
initName() {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./streamable-options.interface"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./streamable-handler-response.interface"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface StreamableHandlerResponse {
|
|
2
|
+
/** `true` if the connection is destroyed, `false` otherwise. */
|
|
3
|
+
destroyed: boolean;
|
|
4
|
+
/** `true` if headers were sent, `false` otherwise. */
|
|
5
|
+
headersSent: boolean;
|
|
6
|
+
/** The status code that will be sent to the client when the headers get flushed. */
|
|
7
|
+
statusCode: number;
|
|
8
|
+
/** Sends the HTTP response. */
|
|
9
|
+
send: (body: string) => void;
|
|
10
|
+
/** Signals to the server that all of the response headers and body have been sent. */
|
|
11
|
+
end: () => void;
|
|
12
|
+
}
|
|
File without changes
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Readable } from 'stream';
|
|
3
|
-
import { StreamableFileOptions } from './
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { StreamableFileOptions, StreamableHandlerResponse } from './interfaces';
|
|
4
|
+
/**
|
|
5
|
+
* @see [Streaming files](https://docs.nestjs.com/techniques/streaming-files)
|
|
6
|
+
*
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
9
|
export declare class StreamableFile {
|
|
10
10
|
readonly options: StreamableFileOptions;
|
|
11
11
|
private readonly stream;
|
|
@@ -3,17 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.StreamableFile = void 0;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
5
|
const util_1 = require("util");
|
|
6
|
+
const enums_1 = require("../enums");
|
|
6
7
|
const shared_utils_1 = require("../utils/shared.utils");
|
|
8
|
+
/**
|
|
9
|
+
* @see [Streaming files](https://docs.nestjs.com/techniques/streaming-files)
|
|
10
|
+
*
|
|
11
|
+
* @publicApi
|
|
12
|
+
*/
|
|
7
13
|
class StreamableFile {
|
|
8
14
|
constructor(bufferOrReadStream, options = {}) {
|
|
9
15
|
var _a;
|
|
10
16
|
var _b;
|
|
11
17
|
this.options = options;
|
|
12
18
|
this.handleError = (err, res) => {
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
res.send(err.message);
|
|
19
|
+
if (res.destroyed) {
|
|
20
|
+
return;
|
|
16
21
|
}
|
|
22
|
+
if (res.headersSent) {
|
|
23
|
+
res.end();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
res.statusCode = enums_1.HttpStatus.BAD_REQUEST;
|
|
27
|
+
res.send(err.message);
|
|
17
28
|
};
|
|
18
29
|
if (util_1.types.isUint8Array(bufferOrReadStream)) {
|
|
19
30
|
this.stream = new stream_1.Readable();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Controller = object;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type StaticOrigin = boolean | string | RegExp | (string | RegExp)[];
|
|
2
2
|
/**
|
|
3
3
|
* Set origin to a function implementing some custom logic. The function takes the
|
|
4
4
|
* request origin as the first parameter and a callback (which expects the signature
|
|
@@ -8,7 +8,7 @@ declare type StaticOrigin = boolean | string | RegExp | (string | RegExp)[];
|
|
|
8
8
|
*
|
|
9
9
|
* @publicApi
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type CustomOrigin = (requestOrigin: string, callback: (err: Error | null, origin?: StaticOrigin) => void) => void;
|
|
12
12
|
/**
|
|
13
13
|
* Interface describing CORS options that can be set.
|
|
14
14
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Type } from '../type.interface';
|
|
2
2
|
import { Paramtype } from './paramtype.interface';
|
|
3
|
-
export
|
|
3
|
+
export type Transform<T = any> = (value: T, metadata: ArgumentMetadata) => any;
|
|
4
4
|
/**
|
|
5
5
|
* Interface describing a pipe implementation's `transform()` method metadata argument.
|
|
6
6
|
*
|
|
@@ -2,11 +2,12 @@ import { RequestMethod } from '../../enums';
|
|
|
2
2
|
import { CorsOptions, CorsOptionsDelegate } from '../../interfaces/external/cors-options.interface';
|
|
3
3
|
import { NestApplicationOptions } from '../../interfaces/nest-application-options.interface';
|
|
4
4
|
import { VersioningOptions, VersionValue } from '../version-options.interface';
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type ErrorHandler<TRequest = any, TResponse = any> = (error: any, req: TRequest, res: TResponse, next?: Function) => any;
|
|
6
|
+
export type RequestHandler<TRequest = any, TResponse = any> = (req: TRequest, res: TResponse, next?: Function) => any;
|
|
7
7
|
export interface HttpServer<TRequest = any, TResponse = 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
|
+
useBodyParser?(...args: any[]): any;
|
|
10
11
|
get(handler: RequestHandler<TRequest, TResponse>): any;
|
|
11
12
|
get(path: string, handler: RequestHandler<TRequest, TResponse>): any;
|
|
12
13
|
post(handler: RequestHandler<TRequest, TResponse>): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Injectable = unknown;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import { NestApplicationContextOptions } from '../nest-application-context-options.interface';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @publicApi
|
|
4
|
+
*/
|
|
5
|
+
export type NestMicroserviceOptions = NestApplicationContextOptions;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Type } from '../type.interface';
|
|
2
2
|
import { RouteInfo } from './middleware-configuration.interface';
|
|
3
3
|
import { MiddlewareConsumer } from './middleware-consumer.interface';
|
|
4
|
+
/**
|
|
5
|
+
* @publicApi
|
|
6
|
+
*/
|
|
4
7
|
export interface MiddlewareConfigProxy {
|
|
5
8
|
/**
|
|
6
9
|
* Excludes routes from the currently processed middleware.
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { Abstract } from '../abstract.interface';
|
|
2
2
|
import { Type } from '../type.interface';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @publicApi
|
|
5
|
+
*/
|
|
6
|
+
export type InjectionToken = string | symbol | Type<any> | Abstract<any> | Function;
|
|
@@ -6,7 +6,7 @@ import { OptionalFactoryDependency } from './optional-factory-dependency.interfa
|
|
|
6
6
|
*
|
|
7
7
|
* @publicApi
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type Provider<T = any> = Type<any> | ClassProvider<T> | ValueProvider<T> | FactoryProvider<T> | ExistingProvider<T>;
|
|
10
10
|
/**
|
|
11
11
|
* Interface defining a *Class* type provider.
|
|
12
12
|
*
|
|
@@ -5,7 +5,10 @@ import { VersioningType } from '../enums/version-type.enum';
|
|
|
5
5
|
* @publicApi
|
|
6
6
|
*/
|
|
7
7
|
export declare const VERSION_NEUTRAL: unique symbol;
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* @publicApi
|
|
10
|
+
*/
|
|
11
|
+
export type VersionValue = string | typeof VERSION_NEUTRAL | Array<string | typeof VERSION_NEUTRAL>;
|
|
9
12
|
/**
|
|
10
13
|
* @publicApi
|
|
11
14
|
*/
|
|
@@ -21,6 +24,9 @@ export interface VersionOptions {
|
|
|
21
24
|
*/
|
|
22
25
|
version?: VersionValue;
|
|
23
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* @publicApi
|
|
29
|
+
*/
|
|
24
30
|
export interface HeaderVersioningOptions {
|
|
25
31
|
type: VersioningType.HEADER;
|
|
26
32
|
/**
|
|
@@ -28,6 +34,9 @@ export interface HeaderVersioningOptions {
|
|
|
28
34
|
*/
|
|
29
35
|
header: string;
|
|
30
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* @publicApi
|
|
39
|
+
*/
|
|
31
40
|
export interface UriVersioningOptions {
|
|
32
41
|
type: VersioningType.URI;
|
|
33
42
|
/**
|
|
@@ -39,6 +48,9 @@ export interface UriVersioningOptions {
|
|
|
39
48
|
*/
|
|
40
49
|
prefix?: string | false;
|
|
41
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* @publicApi
|
|
53
|
+
*/
|
|
42
54
|
export interface MediaTypeVersioningOptions {
|
|
43
55
|
type: VersioningType.MEDIA_TYPE;
|
|
44
56
|
/**
|
|
@@ -48,6 +60,9 @@ export interface MediaTypeVersioningOptions {
|
|
|
48
60
|
*/
|
|
49
61
|
key: string;
|
|
50
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* @publicApi
|
|
65
|
+
*/
|
|
51
66
|
export interface CustomVersioningOptions {
|
|
52
67
|
type: VersioningType.CUSTOM;
|
|
53
68
|
/**
|
|
@@ -60,6 +75,9 @@ export interface CustomVersioningOptions {
|
|
|
60
75
|
*/
|
|
61
76
|
extractor: (request: unknown) => string | string[];
|
|
62
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* @publicApi
|
|
80
|
+
*/
|
|
63
81
|
interface VersioningCommonOptions {
|
|
64
82
|
/**
|
|
65
83
|
* The default version to be used as a fallback when you did not provide some
|
|
@@ -70,5 +88,5 @@ interface VersioningCommonOptions {
|
|
|
70
88
|
/**
|
|
71
89
|
* @publicApi
|
|
72
90
|
*/
|
|
73
|
-
export
|
|
91
|
+
export type VersioningOptions = VersioningCommonOptions & (HeaderVersioningOptions | UriVersioningOptions | MediaTypeVersioningOptions | CustomVersioningOptions);
|
|
74
92
|
export {};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
+
/**
|
|
3
|
+
* @publicApi
|
|
4
|
+
*/
|
|
2
5
|
export interface WsMessageHandler<T = string> {
|
|
3
6
|
message: T;
|
|
4
7
|
callback: (...args: any[]) => Observable<any> | Promise<any>;
|
|
5
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* @publicApi
|
|
11
|
+
*/
|
|
6
12
|
export interface WebSocketAdapter<TServer = any, TClient = any, TOptions = any> {
|
|
7
13
|
create(port: number, options?: TOptions): TServer;
|
|
8
14
|
bindClientConnect(server: TServer, callback: Function): any;
|
|
@@ -6,7 +6,7 @@ import { DEFAULT_FACTORY_CLASS_METHOD_KEY } from '../constants';
|
|
|
6
6
|
*
|
|
7
7
|
* @publicApi
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type ConfigurableModuleOptionsFactory<ModuleOptions, FactoryClassMethodKey extends string> = Record<`${FactoryClassMethodKey}`, () => Promise<ModuleOptions> | ModuleOptions>;
|
|
10
10
|
/**
|
|
11
11
|
* Interface that represents the module async options object
|
|
12
12
|
* Factory method name varies depending on the "FactoryClassMethodKey" type argument.
|
|
@@ -8,6 +8,6 @@ import { ConfigurableModuleAsyncOptions } from './configurable-module-async-opti
|
|
|
8
8
|
*
|
|
9
9
|
* @publicApi
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type ConfigurableModuleCls<ModuleOptions, MethodKey extends string = typeof DEFAULT_METHOD_KEY, FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY, ExtraModuleDefinitionOptions = {}> = {
|
|
12
12
|
new (): any;
|
|
13
13
|
} & Record<`${MethodKey}`, (options: ModuleOptions & Partial<ExtraModuleDefinitionOptions>) => DynamicModule> & Record<`${MethodKey}Async`, (options: ConfigurableModuleAsyncOptions<ModuleOptions, FactoryClassMethodKey> & Partial<ExtraModuleDefinitionOptions>) => DynamicModule>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/common",
|
|
3
|
-
"version": "9.3.
|
|
3
|
+
"version": "9.3.1",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"homepage": "https://nestjs.com",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"iterare": "1.2.1",
|
|
21
21
|
"tslib": "2.4.1",
|
|
22
|
-
"
|
|
22
|
+
"uid": "2.0.1"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"cache-manager": "<=5",
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FileValidator = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Interface describing FileValidators, which can be added to a {@link ParseFilePipe}.
|
|
6
|
+
*
|
|
7
|
+
* @publicApi
|
|
6
8
|
*/
|
|
7
9
|
class FileValidator {
|
|
8
10
|
constructor(validationOptions) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ErrorHttpStatusCode } from '../../utils/http-error-by-code.util';
|
|
2
2
|
import { FileValidator } from './file-validator.interface';
|
|
3
|
+
/**
|
|
4
|
+
* @publicApi
|
|
5
|
+
*/
|
|
3
6
|
export interface ParseFileOptions {
|
|
4
7
|
validators?: FileValidator[];
|
|
5
8
|
errorHttpStatusCode?: ErrorHttpStatusCode;
|
|
@@ -3,6 +3,9 @@ import { FileValidator } from './file-validator.interface';
|
|
|
3
3
|
import { MaxFileSizeValidatorOptions } from './max-file-size.validator';
|
|
4
4
|
import { ParseFileOptions } from './parse-file-options.interface';
|
|
5
5
|
import { ParseFilePipe } from './parse-file.pipe';
|
|
6
|
+
/**
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
6
9
|
export declare class ParseFilePipeBuilder {
|
|
7
10
|
private validators;
|
|
8
11
|
addMaxSizeValidator(options: MaxFileSizeValidatorOptions): this;
|
|
@@ -4,6 +4,9 @@ exports.ParseFilePipeBuilder = void 0;
|
|
|
4
4
|
const file_type_validator_1 = require("./file-type.validator");
|
|
5
5
|
const max_file_size_validator_1 = require("./max-file-size.validator");
|
|
6
6
|
const parse_file_pipe_1 = require("./parse-file.pipe");
|
|
7
|
+
/**
|
|
8
|
+
* @publicApi
|
|
9
|
+
*/
|
|
7
10
|
class ParseFilePipeBuilder {
|
|
8
11
|
constructor() {
|
|
9
12
|
this.validators = [];
|
|
@@ -17,6 +17,8 @@ export declare class ParseFilePipe implements PipeTransform<any> {
|
|
|
17
17
|
private readonly fileIsRequired;
|
|
18
18
|
constructor(options?: ParseFileOptions);
|
|
19
19
|
transform(value: any): Promise<any>;
|
|
20
|
+
private validateFiles;
|
|
21
|
+
private thereAreNoFilesIn;
|
|
20
22
|
protected validate(file: any): Promise<any>;
|
|
21
23
|
private validateOrThrow;
|
|
22
24
|
/**
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ParseFilePipe = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const shared_utils_1 = require("../../utils/shared.utils");
|
|
6
5
|
const core_1 = require("../../decorators/core");
|
|
7
6
|
const enums_1 = require("../../enums");
|
|
8
7
|
const http_error_by_code_util_1 = require("../../utils/http-error-by-code.util");
|
|
8
|
+
const shared_utils_1 = require("../../utils/shared.utils");
|
|
9
9
|
/**
|
|
10
10
|
* Defines the built-in ParseFile Pipe. This pipe can be used to validate incoming files
|
|
11
11
|
* with `@UploadedFile()` decorator. You can use either other specific built-in validators
|
|
@@ -26,17 +26,30 @@ let ParseFilePipe = class ParseFilePipe {
|
|
|
26
26
|
this.fileIsRequired = fileIsRequired !== null && fileIsRequired !== void 0 ? fileIsRequired : true;
|
|
27
27
|
}
|
|
28
28
|
async transform(value) {
|
|
29
|
-
if (
|
|
29
|
+
if (this.thereAreNoFilesIn(value)) {
|
|
30
30
|
if (this.fileIsRequired) {
|
|
31
31
|
throw this.exceptionFactory('File is required');
|
|
32
32
|
}
|
|
33
33
|
return value;
|
|
34
34
|
}
|
|
35
35
|
if (this.validators.length) {
|
|
36
|
-
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
await this.validateFiles(value);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
await this.validate(value);
|
|
41
|
+
}
|
|
37
42
|
}
|
|
38
43
|
return value;
|
|
39
44
|
}
|
|
45
|
+
validateFiles(files) {
|
|
46
|
+
return Promise.all(files.map(f => this.validate(f)));
|
|
47
|
+
}
|
|
48
|
+
thereAreNoFilesIn(value) {
|
|
49
|
+
const isEmptyArray = Array.isArray(value) && (0, shared_utils_1.isEmpty)(value);
|
|
50
|
+
const isEmptyObject = (0, shared_utils_1.isObject)(value) && (0, shared_utils_1.isEmpty)(Object.keys(value));
|
|
51
|
+
return (0, shared_utils_1.isUndefined)(value) || isEmptyArray || isEmptyObject;
|
|
52
|
+
}
|
|
40
53
|
async validate(file) {
|
|
41
54
|
for (const validator of this.validators) {
|
|
42
55
|
await this.validateOrThrow(file, validator);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Type } from '../interfaces';
|
|
2
2
|
import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
3
3
|
import { ValidationPipe, ValidationPipeOptions } from './validation.pipe';
|
|
4
|
+
/**
|
|
5
|
+
* @publicApi
|
|
6
|
+
*/
|
|
4
7
|
export interface ParseArrayOptions extends Omit<ValidationPipeOptions, 'transform' | 'validateCustomDecorators' | 'exceptionFactory'> {
|
|
5
8
|
items?: Type<unknown>;
|
|
6
9
|
separator?: string;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
2
2
|
import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
|
|
3
|
+
/**
|
|
4
|
+
* @publicApi
|
|
5
|
+
*/
|
|
3
6
|
export interface ParseBoolPipeOptions {
|
|
4
7
|
errorHttpStatusCode?: ErrorHttpStatusCode;
|
|
5
8
|
exceptionFactory?: (error: string) => any;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ArgumentMetadata } from '../index';
|
|
2
2
|
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
3
3
|
import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
|
|
4
|
+
/**
|
|
5
|
+
* @publicApi
|
|
6
|
+
*/
|
|
4
7
|
export interface ParseEnumPipeOptions {
|
|
5
8
|
errorHttpStatusCode?: ErrorHttpStatusCode;
|
|
6
9
|
exceptionFactory?: (error: string) => any;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ArgumentMetadata } from '../index';
|
|
2
2
|
import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
3
3
|
import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
|
|
4
|
+
/**
|
|
5
|
+
* @publicApi
|
|
6
|
+
*/
|
|
4
7
|
export interface ParseFloatPipeOptions {
|
|
5
8
|
errorHttpStatusCode?: ErrorHttpStatusCode;
|
|
6
9
|
exceptionFactory?: (error: string) => any;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
2
2
|
import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
|
|
3
|
+
/**
|
|
4
|
+
* @publicApi
|
|
5
|
+
*/
|
|
3
6
|
export interface ParseIntPipeOptions {
|
|
4
7
|
errorHttpStatusCode?: ErrorHttpStatusCode;
|
|
5
8
|
exceptionFactory?: (error: string) => any;
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
2
2
|
import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
|
|
3
|
+
/**
|
|
4
|
+
* @publicApi
|
|
5
|
+
*/
|
|
3
6
|
export interface ParseUUIDPipeOptions {
|
|
4
7
|
version?: '3' | '4' | '5';
|
|
5
8
|
errorHttpStatusCode?: ErrorHttpStatusCode;
|
|
6
9
|
exceptionFactory?: (errors: string) => any;
|
|
7
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Defines the built-in ParseUUID Pipe
|
|
13
|
+
*
|
|
14
|
+
* @see [Built-in Pipes](https://docs.nestjs.com/pipes#built-in-pipes)
|
|
15
|
+
*
|
|
16
|
+
* @publicApi
|
|
17
|
+
*/
|
|
8
18
|
export declare class ParseUUIDPipe implements PipeTransform<string> {
|
|
9
19
|
protected static uuidRegExps: {
|
|
10
20
|
3: RegExp;
|
package/pipes/parse-uuid.pipe.js
CHANGED
|
@@ -8,6 +8,13 @@ const optional_decorator_1 = require("../decorators/core/optional.decorator");
|
|
|
8
8
|
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
9
9
|
const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
|
|
10
10
|
const shared_utils_1 = require("../utils/shared.utils");
|
|
11
|
+
/**
|
|
12
|
+
* Defines the built-in ParseUUID Pipe
|
|
13
|
+
*
|
|
14
|
+
* @see [Built-in Pipes](https://docs.nestjs.com/pipes#built-in-pipes)
|
|
15
|
+
*
|
|
16
|
+
* @publicApi
|
|
17
|
+
*/
|
|
11
18
|
let ParseUUIDPipe = ParseUUIDPipe_1 = class ParseUUIDPipe {
|
|
12
19
|
constructor(options) {
|
|
13
20
|
options = options || {};
|
|
@@ -6,6 +6,9 @@ import { ValidatorPackage } from '../interfaces/external/validator-package.inter
|
|
|
6
6
|
import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
|
|
7
7
|
import { Type } from '../interfaces/type.interface';
|
|
8
8
|
import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
|
|
9
|
+
/**
|
|
10
|
+
* @publicApi
|
|
11
|
+
*/
|
|
9
12
|
export interface ValidationPipeOptions extends ValidatorOptions {
|
|
10
13
|
transform?: boolean;
|
|
11
14
|
disableErrorMessages?: boolean;
|
|
@@ -17,6 +20,11 @@ export interface ValidationPipeOptions extends ValidatorOptions {
|
|
|
17
20
|
validatorPackage?: ValidatorPackage;
|
|
18
21
|
transformerPackage?: TransformerPackage;
|
|
19
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* @see [Validation](https://docs.nestjs.com/techniques/validation)
|
|
25
|
+
*
|
|
26
|
+
* @publicApi
|
|
27
|
+
*/
|
|
20
28
|
export declare class ValidationPipe implements PipeTransform<any> {
|
|
21
29
|
protected isTransformEnabled: boolean;
|
|
22
30
|
protected isDetailedOutputDisabled?: boolean;
|
package/pipes/validation.pipe.js
CHANGED
|
@@ -12,6 +12,11 @@ const load_package_util_1 = require("../utils/load-package.util");
|
|
|
12
12
|
const shared_utils_1 = require("../utils/shared.utils");
|
|
13
13
|
let classValidator = {};
|
|
14
14
|
let classTransformer = {};
|
|
15
|
+
/**
|
|
16
|
+
* @see [Validation](https://docs.nestjs.com/techniques/validation)
|
|
17
|
+
*
|
|
18
|
+
* @publicApi
|
|
19
|
+
*/
|
|
15
20
|
let ValidationPipe = class ValidationPipe {
|
|
16
21
|
constructor(options) {
|
|
17
22
|
options = options || {};
|
|
@@ -6,9 +6,15 @@ import { TransformerPackage } from '../interfaces/external/transformer-package.i
|
|
|
6
6
|
export interface PlainLiteralObject {
|
|
7
7
|
[key: string]: any;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* @publicApi
|
|
11
|
+
*/
|
|
9
12
|
export interface ClassSerializerInterceptorOptions extends ClassTransformOptions {
|
|
10
13
|
transformerPackage?: TransformerPackage;
|
|
11
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* @publicApi
|
|
17
|
+
*/
|
|
12
18
|
export declare class ClassSerializerInterceptor implements NestInterceptor {
|
|
13
19
|
protected readonly reflector: any;
|
|
14
20
|
protected readonly defaultOptions: ClassSerializerInterceptorOptions;
|
|
@@ -13,6 +13,9 @@ let classTransformer = {};
|
|
|
13
13
|
// We need to deduplicate them here due to the circular dependency
|
|
14
14
|
// between core and common packages
|
|
15
15
|
const REFLECTOR = 'Reflector';
|
|
16
|
+
/**
|
|
17
|
+
* @publicApi
|
|
18
|
+
*/
|
|
16
19
|
let ClassSerializerInterceptor = class ClassSerializerInterceptor {
|
|
17
20
|
constructor(reflector, defaultOptions = {}) {
|
|
18
21
|
var _a;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ClassTransformOptions } from '../interfaces/external/class-transform-options.interface';
|
|
2
2
|
import { Type } from '../interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* @publicApi
|
|
5
|
+
*/
|
|
3
6
|
export interface ClassSerializerContextOptions extends ClassTransformOptions {
|
|
4
7
|
type?: Type<any>;
|
|
5
8
|
}
|
|
@@ -3,5 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SerializeOptions = void 0;
|
|
4
4
|
const decorators_1 = require("../../decorators");
|
|
5
5
|
const class_serializer_constants_1 = require("../class-serializer.constants");
|
|
6
|
+
/**
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
6
9
|
const SerializeOptions = (options) => (0, decorators_1.SetMetadata)(class_serializer_constants_1.CLASS_SERIALIZER_OPTIONS, options);
|
|
7
10
|
exports.SerializeOptions = SerializeOptions;
|
|
@@ -14,6 +14,14 @@ const DEFAULT_LOG_LEVELS = [
|
|
|
14
14
|
'debug',
|
|
15
15
|
'verbose',
|
|
16
16
|
];
|
|
17
|
+
const dateTimeFormatter = new Intl.DateTimeFormat(undefined, {
|
|
18
|
+
year: 'numeric',
|
|
19
|
+
hour: 'numeric',
|
|
20
|
+
minute: 'numeric',
|
|
21
|
+
second: 'numeric',
|
|
22
|
+
day: '2-digit',
|
|
23
|
+
month: '2-digit',
|
|
24
|
+
});
|
|
17
25
|
let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
18
26
|
constructor(context, options = {}) {
|
|
19
27
|
this.context = context;
|
|
@@ -102,15 +110,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
102
110
|
return (0, utils_1.isLogLevelEnabled)(level, logLevels);
|
|
103
111
|
}
|
|
104
112
|
getTimestamp() {
|
|
105
|
-
|
|
106
|
-
year: 'numeric',
|
|
107
|
-
hour: 'numeric',
|
|
108
|
-
minute: 'numeric',
|
|
109
|
-
second: 'numeric',
|
|
110
|
-
day: '2-digit',
|
|
111
|
-
month: '2-digit',
|
|
112
|
-
};
|
|
113
|
-
return new Date(Date.now()).toLocaleString(undefined, localeStringOptions);
|
|
113
|
+
return dateTimeFormatter.format(Date.now());
|
|
114
114
|
}
|
|
115
115
|
printMessages(messages, context = '', logLevel = 'log', writeStreamType) {
|
|
116
116
|
messages.forEach(message => {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @publicApi
|
|
3
|
+
*/
|
|
4
|
+
export type LogLevel = 'log' | 'error' | 'warn' | 'debug' | 'verbose';
|
|
5
|
+
/**
|
|
6
|
+
* @publicApi
|
|
7
|
+
*/
|
|
2
8
|
export interface LoggerService {
|
|
3
9
|
/**
|
|
4
10
|
* Write a 'log' level log.
|
|
@@ -36,6 +42,9 @@ interface LogBufferRecord {
|
|
|
36
42
|
*/
|
|
37
43
|
arguments: unknown[];
|
|
38
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* @publicApi
|
|
47
|
+
*/
|
|
39
48
|
export declare class Logger implements LoggerService {
|
|
40
49
|
protected context?: string;
|
|
41
50
|
protected options: {
|
|
@@ -3,12 +3,22 @@ var Logger_1;
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Logger = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
-
const
|
|
7
|
-
const optional_decorator_1 = require("../decorators/core/optional.decorator");
|
|
6
|
+
const core_1 = require("../decorators/core");
|
|
8
7
|
const shared_utils_1 = require("../utils/shared.utils");
|
|
9
8
|
const console_logger_service_1 = require("./console-logger.service");
|
|
10
9
|
const utils_1 = require("./utils");
|
|
11
10
|
const DEFAULT_LOGGER = new console_logger_service_1.ConsoleLogger();
|
|
11
|
+
const dateTimeFormatter = new Intl.DateTimeFormat(undefined, {
|
|
12
|
+
year: 'numeric',
|
|
13
|
+
hour: 'numeric',
|
|
14
|
+
minute: 'numeric',
|
|
15
|
+
second: 'numeric',
|
|
16
|
+
day: '2-digit',
|
|
17
|
+
month: '2-digit',
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* @publicApi
|
|
21
|
+
*/
|
|
12
22
|
let Logger = Logger_1 = class Logger {
|
|
13
23
|
constructor(context, options = {}) {
|
|
14
24
|
this.context = context;
|
|
@@ -29,7 +39,7 @@ let Logger = Logger_1 = class Logger {
|
|
|
29
39
|
error(message, ...optionalParams) {
|
|
30
40
|
var _a;
|
|
31
41
|
optionalParams = this.context
|
|
32
|
-
? optionalParams.concat(this.context)
|
|
42
|
+
? (optionalParams.length ? optionalParams : [undefined]).concat(this.context)
|
|
33
43
|
: optionalParams;
|
|
34
44
|
(_a = this.localInstance) === null || _a === void 0 ? void 0 : _a.error(message, ...optionalParams);
|
|
35
45
|
}
|
|
@@ -104,15 +114,7 @@ let Logger = Logger_1 = class Logger {
|
|
|
104
114
|
this.isBufferAttached = false;
|
|
105
115
|
}
|
|
106
116
|
static getTimestamp() {
|
|
107
|
-
|
|
108
|
-
year: 'numeric',
|
|
109
|
-
hour: 'numeric',
|
|
110
|
-
minute: 'numeric',
|
|
111
|
-
second: 'numeric',
|
|
112
|
-
day: '2-digit',
|
|
113
|
-
month: '2-digit',
|
|
114
|
-
};
|
|
115
|
-
return new Date(Date.now()).toLocaleString(undefined, localeStringOptions);
|
|
117
|
+
return dateTimeFormatter.format(Date.now());
|
|
116
118
|
}
|
|
117
119
|
static overrideLogger(logger) {
|
|
118
120
|
var _a;
|
|
@@ -224,9 +226,9 @@ tslib_1.__decorate([
|
|
|
224
226
|
tslib_1.__metadata("design:returntype", void 0)
|
|
225
227
|
], Logger, "verbose", null);
|
|
226
228
|
Logger = Logger_1 = tslib_1.__decorate([
|
|
227
|
-
(0,
|
|
228
|
-
tslib_1.__param(0, (0,
|
|
229
|
-
tslib_1.__param(1, (0,
|
|
229
|
+
(0, core_1.Injectable)(),
|
|
230
|
+
tslib_1.__param(0, (0, core_1.Optional)()),
|
|
231
|
+
tslib_1.__param(1, (0, core_1.Optional)()),
|
|
230
232
|
tslib_1.__metadata("design:paramtypes", [String, Object])
|
|
231
233
|
], Logger);
|
|
232
234
|
exports.Logger = Logger;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { HttpStatus } from '../enums';
|
|
2
2
|
import { Type } from '../interfaces';
|
|
3
|
-
export
|
|
3
|
+
export type ErrorHttpStatusCode = HttpStatus.BAD_GATEWAY | HttpStatus.BAD_REQUEST | HttpStatus.CONFLICT | HttpStatus.FORBIDDEN | HttpStatus.GATEWAY_TIMEOUT | HttpStatus.GONE | HttpStatus.I_AM_A_TEAPOT | HttpStatus.INTERNAL_SERVER_ERROR | HttpStatus.METHOD_NOT_ALLOWED | HttpStatus.NOT_ACCEPTABLE | HttpStatus.NOT_FOUND | HttpStatus.NOT_IMPLEMENTED | HttpStatus.PAYLOAD_TOO_LARGE | HttpStatus.PRECONDITION_FAILED | HttpStatus.REQUEST_TIMEOUT | HttpStatus.SERVICE_UNAVAILABLE | HttpStatus.UNAUTHORIZED | HttpStatus.UNPROCESSABLE_ENTITY | HttpStatus.UNSUPPORTED_MEDIA_TYPE;
|
|
4
4
|
export declare const HttpErrorByCode: Record<ErrorHttpStatusCode, Type<unknown>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const randomStringGenerator: () =>
|
|
1
|
+
export declare const randomStringGenerator: () => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.randomStringGenerator = void 0;
|
|
4
|
-
const
|
|
5
|
-
const randomStringGenerator = () => (0,
|
|
4
|
+
const uid_1 = require("uid");
|
|
5
|
+
const randomStringGenerator = () => (0, uid_1.uid)(21);
|
|
6
6
|
exports.randomStringGenerator = randomStringGenerator;
|