@nestjs/common 8.4.0 → 8.4.3
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/cache.module.js +2 -2
- package/cache/cache.providers.js +1 -1
- package/cache/decorators/cache-key.decorator.js +1 -1
- package/cache/decorators/cache-ttl.decorator.js +1 -1
- package/cache/interceptors/cache.interceptor.js +10 -10
- package/decorators/core/controller.decorator.js +2 -2
- package/decorators/core/exception-filters.decorator.js +5 -5
- package/decorators/core/inject.decorator.js +1 -1
- package/decorators/core/injectable.decorator.js +1 -1
- package/decorators/core/optional.decorator.js +1 -1
- package/decorators/core/use-guards.decorator.js +6 -6
- package/decorators/core/use-interceptors.decorator.js +6 -6
- package/decorators/core/use-pipes.decorator.js +4 -4
- package/decorators/http/create-route-param-metadata.decorator.js +6 -6
- package/decorators/http/header.decorator.js +1 -1
- package/decorators/http/request-mapping.decorator.js +1 -1
- package/decorators/http/route-params.decorator.js +1 -1
- package/decorators/modules/module.decorator.js +1 -1
- package/exceptions/http.exception.js +4 -4
- package/file-stream/streamable-file.js +1 -1
- package/http/http.module.js +3 -3
- package/http/http.service.js +1 -1
- package/package.json +2 -2
- package/pipes/default-value.pipe.js +3 -3
- package/pipes/parse-array.pipe.js +7 -7
- package/pipes/parse-bool.pipe.js +2 -2
- package/pipes/parse-enum.pipe.js +2 -2
- package/pipes/parse-float.pipe.js +2 -2
- package/pipes/parse-int.pipe.js +2 -2
- package/pipes/parse-uuid.pipe.js +3 -3
- package/pipes/validation.pipe.js +9 -9
- package/serializer/class-serializer.interceptor.js +6 -6
- package/serializer/decorators/serialize-options.decorator.js +1 -1
- package/services/console-logger.service.d.ts +4 -0
- package/services/console-logger.service.js +30 -16
- package/services/logger.service.js +5 -5
- package/utils/is-uuid.js +1 -1
- package/utils/random-string-generator.util.js +1 -1
- package/utils/shared.utils.js +3 -3
- package/utils/validate-module-keys.util.js +1 -1
package/cache/cache.module.js
CHANGED
|
@@ -75,8 +75,8 @@ let CacheModule = CacheModule_1 = class CacheModule {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
CacheModule = CacheModule_1 = tslib_1.__decorate([
|
|
78
|
-
decorators_1.Module({
|
|
79
|
-
providers: [cache_providers_1.createCacheManager()],
|
|
78
|
+
(0, decorators_1.Module)({
|
|
79
|
+
providers: [(0, cache_providers_1.createCacheManager)()],
|
|
80
80
|
exports: [cache_constants_1.CACHE_MANAGER],
|
|
81
81
|
})
|
|
82
82
|
], CacheModule);
|
package/cache/cache.providers.js
CHANGED
|
@@ -13,7 +13,7 @@ function createCacheManager() {
|
|
|
13
13
|
return {
|
|
14
14
|
provide: cache_constants_1.CACHE_MANAGER,
|
|
15
15
|
useFactory: (options) => {
|
|
16
|
-
const cacheManager = load_package_util_1.loadPackage('cache-manager', 'CacheModule', () => require('cache-manager'));
|
|
16
|
+
const cacheManager = (0, load_package_util_1.loadPackage)('cache-manager', 'CacheModule', () => require('cache-manager'));
|
|
17
17
|
return Array.isArray(options)
|
|
18
18
|
? cacheManager.multiCaching(options.map(store => cacheManager.caching(Object.assign(Object.assign({}, default_options_1.defaultCacheOptions), (store || {})))))
|
|
19
19
|
: cacheManager.caching(Object.assign(Object.assign({}, default_options_1.defaultCacheOptions), (options || {})));
|
|
@@ -16,5 +16,5 @@ const cache_constants_1 = require("../cache.constants");
|
|
|
16
16
|
*
|
|
17
17
|
* @publicApi
|
|
18
18
|
*/
|
|
19
|
-
const CacheKey = (key) => decorators_1.SetMetadata(cache_constants_1.CACHE_KEY_METADATA, key);
|
|
19
|
+
const CacheKey = (key) => (0, decorators_1.SetMetadata)(cache_constants_1.CACHE_KEY_METADATA, key);
|
|
20
20
|
exports.CacheKey = CacheKey;
|
|
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CacheTTL = void 0;
|
|
4
4
|
const decorators_1 = require("../../decorators");
|
|
5
5
|
const cache_constants_1 = require("../cache.constants");
|
|
6
|
-
const CacheTTL = (ttl) => decorators_1.SetMetadata(cache_constants_1.CACHE_TTL_METADATA, ttl);
|
|
6
|
+
const CacheTTL = (ttl) => (0, decorators_1.SetMetadata)(cache_constants_1.CACHE_TTL_METADATA, ttl);
|
|
7
7
|
exports.CacheTTL = CacheTTL;
|
|
@@ -24,14 +24,14 @@ let CacheInterceptor = class CacheInterceptor {
|
|
|
24
24
|
}
|
|
25
25
|
try {
|
|
26
26
|
const value = await this.cacheManager.get(key);
|
|
27
|
-
if (!shared_utils_1.isNil(value)) {
|
|
28
|
-
return rxjs_1.of(value);
|
|
27
|
+
if (!(0, shared_utils_1.isNil)(value)) {
|
|
28
|
+
return (0, rxjs_1.of)(value);
|
|
29
29
|
}
|
|
30
|
-
const ttl = shared_utils_1.isFunction(ttlValueOrFactory)
|
|
30
|
+
const ttl = (0, shared_utils_1.isFunction)(ttlValueOrFactory)
|
|
31
31
|
? await ttlValueOrFactory(context)
|
|
32
32
|
: ttlValueOrFactory;
|
|
33
|
-
return next.handle().pipe(operators_1.tap(response => {
|
|
34
|
-
const args = shared_utils_1.isNil(ttl) ? [key, response] : [key, response, { ttl }];
|
|
33
|
+
return next.handle().pipe((0, operators_1.tap)(response => {
|
|
34
|
+
const args = (0, shared_utils_1.isNil)(ttl) ? [key, response] : [key, response, { ttl }];
|
|
35
35
|
this.cacheManager.set(...args);
|
|
36
36
|
}));
|
|
37
37
|
}
|
|
@@ -58,14 +58,14 @@ let CacheInterceptor = class CacheInterceptor {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
tslib_1.__decorate([
|
|
61
|
-
decorators_1.Optional(),
|
|
62
|
-
decorators_1.Inject(HTTP_ADAPTER_HOST),
|
|
61
|
+
(0, decorators_1.Optional)(),
|
|
62
|
+
(0, decorators_1.Inject)(HTTP_ADAPTER_HOST),
|
|
63
63
|
tslib_1.__metadata("design:type", Object)
|
|
64
64
|
], CacheInterceptor.prototype, "httpAdapterHost", void 0);
|
|
65
65
|
CacheInterceptor = tslib_1.__decorate([
|
|
66
|
-
decorators_1.Injectable(),
|
|
67
|
-
tslib_1.__param(0, decorators_1.Inject(cache_constants_1.CACHE_MANAGER)),
|
|
68
|
-
tslib_1.__param(1, decorators_1.Inject(REFLECTOR)),
|
|
66
|
+
(0, decorators_1.Injectable)(),
|
|
67
|
+
tslib_1.__param(0, (0, decorators_1.Inject)(cache_constants_1.CACHE_MANAGER)),
|
|
68
|
+
tslib_1.__param(1, (0, decorators_1.Inject)(REFLECTOR)),
|
|
69
69
|
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
70
70
|
], CacheInterceptor);
|
|
71
71
|
exports.CacheInterceptor = CacheInterceptor;
|
|
@@ -39,9 +39,9 @@ const shared_utils_1 = require("../../utils/shared.utils");
|
|
|
39
39
|
*/
|
|
40
40
|
function Controller(prefixOrOptions) {
|
|
41
41
|
const defaultPath = '/';
|
|
42
|
-
const [path, host, scopeOptions, versionOptions] = shared_utils_1.isUndefined(prefixOrOptions)
|
|
42
|
+
const [path, host, scopeOptions, versionOptions] = (0, shared_utils_1.isUndefined)(prefixOrOptions)
|
|
43
43
|
? [defaultPath, undefined, undefined, undefined]
|
|
44
|
-
: shared_utils_1.isString(prefixOrOptions) || Array.isArray(prefixOrOptions)
|
|
44
|
+
: (0, shared_utils_1.isString)(prefixOrOptions) || Array.isArray(prefixOrOptions)
|
|
45
45
|
? [prefixOrOptions, undefined, undefined, undefined]
|
|
46
46
|
: [
|
|
47
47
|
prefixOrOptions.path || defaultPath,
|
|
@@ -32,14 +32,14 @@ exports.UseFilters = UseFilters;
|
|
|
32
32
|
function addExceptionFiltersMetadata(...filters) {
|
|
33
33
|
return (target, key, descriptor) => {
|
|
34
34
|
const isFilterValid = (filter) => filter &&
|
|
35
|
-
(shared_utils_1.isFunction(filter) || shared_utils_1.isFunction(filter.catch));
|
|
35
|
+
((0, shared_utils_1.isFunction)(filter) || (0, shared_utils_1.isFunction)(filter.catch));
|
|
36
36
|
if (descriptor) {
|
|
37
|
-
validate_each_util_1.validateEach(target.constructor, filters, isFilterValid, '@UseFilters', 'filter');
|
|
38
|
-
extend_metadata_util_1.extendArrayMetadata(constants_1.EXCEPTION_FILTERS_METADATA, filters, descriptor.value);
|
|
37
|
+
(0, validate_each_util_1.validateEach)(target.constructor, filters, isFilterValid, '@UseFilters', 'filter');
|
|
38
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.EXCEPTION_FILTERS_METADATA, filters, descriptor.value);
|
|
39
39
|
return descriptor;
|
|
40
40
|
}
|
|
41
|
-
validate_each_util_1.validateEach(target, filters, isFilterValid, '@UseFilters', 'filter');
|
|
42
|
-
extend_metadata_util_1.extendArrayMetadata(constants_1.EXCEPTION_FILTERS_METADATA, filters, target);
|
|
41
|
+
(0, validate_each_util_1.validateEach)(target, filters, isFilterValid, '@UseFilters', 'filter');
|
|
42
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.EXCEPTION_FILTERS_METADATA, filters, target);
|
|
43
43
|
return target;
|
|
44
44
|
};
|
|
45
45
|
}
|
|
@@ -35,7 +35,7 @@ const shared_utils_1 = require("../../utils/shared.utils");
|
|
|
35
35
|
function Inject(token) {
|
|
36
36
|
return (target, key, index) => {
|
|
37
37
|
const type = token || Reflect.getMetadata('design:type', target, key);
|
|
38
|
-
if (!shared_utils_1.isUndefined(index)) {
|
|
38
|
+
if (!(0, shared_utils_1.isUndefined)(index)) {
|
|
39
39
|
let dependencies = Reflect.getMetadata(constants_1.SELF_DECLARED_DEPS_METADATA, target) || [];
|
|
40
40
|
dependencies = [...dependencies, { index, param: type }];
|
|
41
41
|
Reflect.defineMetadata(constants_1.SELF_DECLARED_DEPS_METADATA, dependencies, target);
|
|
@@ -18,7 +18,7 @@ const shared_utils_1 = require("../../utils/shared.utils");
|
|
|
18
18
|
*/
|
|
19
19
|
function Optional() {
|
|
20
20
|
return (target, key, index) => {
|
|
21
|
-
if (!shared_utils_1.isUndefined(index)) {
|
|
21
|
+
if (!(0, shared_utils_1.isUndefined)(index)) {
|
|
22
22
|
const args = Reflect.getMetadata(constants_1.OPTIONAL_DEPS_METADATA, target) || [];
|
|
23
23
|
Reflect.defineMetadata(constants_1.OPTIONAL_DEPS_METADATA, [...args, index], target);
|
|
24
24
|
return;
|
|
@@ -29,15 +29,15 @@ const validate_each_util_1 = require("../../utils/validate-each.util");
|
|
|
29
29
|
function UseGuards(...guards) {
|
|
30
30
|
return (target, key, descriptor) => {
|
|
31
31
|
const isGuardValid = (guard) => guard &&
|
|
32
|
-
(shared_utils_1.isFunction(guard) ||
|
|
33
|
-
shared_utils_1.isFunction(guard.canActivate));
|
|
32
|
+
((0, shared_utils_1.isFunction)(guard) ||
|
|
33
|
+
(0, shared_utils_1.isFunction)(guard.canActivate));
|
|
34
34
|
if (descriptor) {
|
|
35
|
-
validate_each_util_1.validateEach(target.constructor, guards, isGuardValid, '@UseGuards', 'guard');
|
|
36
|
-
extend_metadata_util_1.extendArrayMetadata(constants_1.GUARDS_METADATA, guards, descriptor.value);
|
|
35
|
+
(0, validate_each_util_1.validateEach)(target.constructor, guards, isGuardValid, '@UseGuards', 'guard');
|
|
36
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.GUARDS_METADATA, guards, descriptor.value);
|
|
37
37
|
return descriptor;
|
|
38
38
|
}
|
|
39
|
-
validate_each_util_1.validateEach(target, guards, isGuardValid, '@UseGuards', 'guard');
|
|
40
|
-
extend_metadata_util_1.extendArrayMetadata(constants_1.GUARDS_METADATA, guards, target);
|
|
39
|
+
(0, validate_each_util_1.validateEach)(target, guards, isGuardValid, '@UseGuards', 'guard');
|
|
40
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.GUARDS_METADATA, guards, target);
|
|
41
41
|
return target;
|
|
42
42
|
};
|
|
43
43
|
}
|
|
@@ -29,15 +29,15 @@ const validate_each_util_1 = require("../../utils/validate-each.util");
|
|
|
29
29
|
function UseInterceptors(...interceptors) {
|
|
30
30
|
return (target, key, descriptor) => {
|
|
31
31
|
const isInterceptorValid = (interceptor) => interceptor &&
|
|
32
|
-
(shared_utils_1.isFunction(interceptor) ||
|
|
33
|
-
shared_utils_1.isFunction(interceptor.intercept));
|
|
32
|
+
((0, shared_utils_1.isFunction)(interceptor) ||
|
|
33
|
+
(0, shared_utils_1.isFunction)(interceptor.intercept));
|
|
34
34
|
if (descriptor) {
|
|
35
|
-
validate_each_util_1.validateEach(target.constructor, interceptors, isInterceptorValid, '@UseInterceptors', 'interceptor');
|
|
36
|
-
extend_metadata_util_1.extendArrayMetadata(constants_1.INTERCEPTORS_METADATA, interceptors, descriptor.value);
|
|
35
|
+
(0, validate_each_util_1.validateEach)(target.constructor, interceptors, isInterceptorValid, '@UseInterceptors', 'interceptor');
|
|
36
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.INTERCEPTORS_METADATA, interceptors, descriptor.value);
|
|
37
37
|
return descriptor;
|
|
38
38
|
}
|
|
39
|
-
validate_each_util_1.validateEach(target, interceptors, isInterceptorValid, '@UseInterceptors', 'interceptor');
|
|
40
|
-
extend_metadata_util_1.extendArrayMetadata(constants_1.INTERCEPTORS_METADATA, interceptors, target);
|
|
39
|
+
(0, validate_each_util_1.validateEach)(target, interceptors, isInterceptorValid, '@UseInterceptors', 'interceptor');
|
|
40
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.INTERCEPTORS_METADATA, interceptors, target);
|
|
41
41
|
return target;
|
|
42
42
|
};
|
|
43
43
|
}
|
|
@@ -29,13 +29,13 @@ const validate_each_util_1 = require("../../utils/validate-each.util");
|
|
|
29
29
|
function UsePipes(...pipes) {
|
|
30
30
|
return (target, key, descriptor) => {
|
|
31
31
|
const isPipeValid = (pipe) => pipe &&
|
|
32
|
-
(shared_utils_1.isFunction(pipe) || shared_utils_1.isFunction(pipe.transform));
|
|
32
|
+
((0, shared_utils_1.isFunction)(pipe) || (0, shared_utils_1.isFunction)(pipe.transform));
|
|
33
33
|
if (descriptor) {
|
|
34
|
-
extend_metadata_util_1.extendArrayMetadata(constants_1.PIPES_METADATA, pipes, descriptor.value);
|
|
34
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.PIPES_METADATA, pipes, descriptor.value);
|
|
35
35
|
return descriptor;
|
|
36
36
|
}
|
|
37
|
-
validate_each_util_1.validateEach(target, pipes, isPipeValid, '@UsePipes', 'pipe');
|
|
38
|
-
extend_metadata_util_1.extendArrayMetadata(constants_1.PIPES_METADATA, pipes, target);
|
|
37
|
+
(0, validate_each_util_1.validateEach)(target, pipes, isPipeValid, '@UsePipes', 'pipe');
|
|
38
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.PIPES_METADATA, pipes, target);
|
|
39
39
|
return target;
|
|
40
40
|
};
|
|
41
41
|
}
|
|
@@ -11,18 +11,18 @@ const shared_utils_1 = require("../../utils/shared.utils");
|
|
|
11
11
|
* @param factory
|
|
12
12
|
*/
|
|
13
13
|
function createParamDecorator(factory, enhancers = []) {
|
|
14
|
-
const paramtype = uuid_1.v4();
|
|
14
|
+
const paramtype = (0, uuid_1.v4)();
|
|
15
15
|
return (data, ...pipes) => (target, key, index) => {
|
|
16
16
|
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) || {};
|
|
17
17
|
const isPipe = (pipe) => pipe &&
|
|
18
|
-
((shared_utils_1.isFunction(pipe) &&
|
|
18
|
+
(((0, shared_utils_1.isFunction)(pipe) &&
|
|
19
19
|
pipe.prototype &&
|
|
20
|
-
shared_utils_1.isFunction(pipe.prototype.transform)) ||
|
|
21
|
-
shared_utils_1.isFunction(pipe.transform));
|
|
22
|
-
const hasParamData = shared_utils_1.isNil(data) || !isPipe(data);
|
|
20
|
+
(0, shared_utils_1.isFunction)(pipe.prototype.transform)) ||
|
|
21
|
+
(0, shared_utils_1.isFunction)(pipe.transform));
|
|
22
|
+
const hasParamData = (0, shared_utils_1.isNil)(data) || !isPipe(data);
|
|
23
23
|
const paramData = hasParamData ? data : undefined;
|
|
24
24
|
const paramPipes = hasParamData ? pipes : [data, ...pipes];
|
|
25
|
-
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assign_custom_metadata_util_1.assignCustomParameterMetadata(args, paramtype, index, factory, paramData, ...paramPipes), target.constructor, key);
|
|
25
|
+
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, (0, assign_custom_metadata_util_1.assignCustomParameterMetadata)(args, paramtype, index, factory, paramData, ...paramPipes), target.constructor, key);
|
|
26
26
|
enhancers.forEach(fn => fn(target, key, index));
|
|
27
27
|
};
|
|
28
28
|
}
|
|
@@ -18,7 +18,7 @@ const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
|
|
|
18
18
|
*/
|
|
19
19
|
function Header(name, value) {
|
|
20
20
|
return (target, key, descriptor) => {
|
|
21
|
-
extend_metadata_util_1.extendArrayMetadata(constants_1.HEADERS_METADATA, [{ name, value }], descriptor.value);
|
|
21
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.HEADERS_METADATA, [{ name, value }], descriptor.value);
|
|
22
22
|
return descriptor;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
@@ -19,7 +19,7 @@ const RequestMapping = (metadata = defaultMetadata) => {
|
|
|
19
19
|
};
|
|
20
20
|
exports.RequestMapping = RequestMapping;
|
|
21
21
|
const createMappingDecorator = (method) => (path) => {
|
|
22
|
-
return exports.RequestMapping({
|
|
22
|
+
return (0, exports.RequestMapping)({
|
|
23
23
|
[constants_1.PATH_METADATA]: path,
|
|
24
24
|
[constants_1.METHOD_METADATA]: method,
|
|
25
25
|
});
|
|
@@ -20,7 +20,7 @@ function createRouteParamDecorator(paramtype) {
|
|
|
20
20
|
}
|
|
21
21
|
const createPipesRouteParamDecorator = (paramtype) => (data, ...pipes) => (target, key, index) => {
|
|
22
22
|
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) || {};
|
|
23
|
-
const hasParamData = shared_utils_1.isNil(data) || shared_utils_1.isString(data);
|
|
23
|
+
const hasParamData = (0, shared_utils_1.isNil)(data) || (0, shared_utils_1.isString)(data);
|
|
24
24
|
const paramData = hasParamData ? data : undefined;
|
|
25
25
|
const paramPipes = hasParamData ? pipes : [data, ...pipes];
|
|
26
26
|
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, paramData, ...paramPipes), target.constructor, key);
|
|
@@ -18,7 +18,7 @@ const validate_module_keys_util_1 = require("../../utils/validate-module-keys.ut
|
|
|
18
18
|
*/
|
|
19
19
|
function Module(metadata) {
|
|
20
20
|
const propsKeys = Object.keys(metadata);
|
|
21
|
-
validate_module_keys_util_1.validateModuleKeys(propsKeys);
|
|
21
|
+
(0, validate_module_keys_util_1.validateModuleKeys)(propsKeys);
|
|
22
22
|
return (target) => {
|
|
23
23
|
for (const property in metadata) {
|
|
24
24
|
if (metadata.hasOwnProperty(property)) {
|
|
@@ -44,11 +44,11 @@ class HttpException extends Error {
|
|
|
44
44
|
this.initName();
|
|
45
45
|
}
|
|
46
46
|
initMessage() {
|
|
47
|
-
if (shared_utils_1.isString(this.response)) {
|
|
47
|
+
if ((0, shared_utils_1.isString)(this.response)) {
|
|
48
48
|
this.message = this.response;
|
|
49
49
|
}
|
|
50
|
-
else if (shared_utils_1.isObject(this.response) &&
|
|
51
|
-
shared_utils_1.isString(this.response.message)) {
|
|
50
|
+
else if ((0, shared_utils_1.isObject)(this.response) &&
|
|
51
|
+
(0, shared_utils_1.isString)(this.response.message)) {
|
|
52
52
|
this.message = this.response.message;
|
|
53
53
|
}
|
|
54
54
|
else if (this.constructor) {
|
|
@@ -70,7 +70,7 @@ class HttpException extends Error {
|
|
|
70
70
|
if (!objectOrError) {
|
|
71
71
|
return { statusCode, message: description };
|
|
72
72
|
}
|
|
73
|
-
return shared_utils_1.isObject(objectOrError) && !Array.isArray(objectOrError)
|
|
73
|
+
return (0, shared_utils_1.isObject)(objectOrError) && !Array.isArray(objectOrError)
|
|
74
74
|
? objectOrError
|
|
75
75
|
: { statusCode, message: objectOrError, error: description };
|
|
76
76
|
}
|
|
@@ -12,7 +12,7 @@ class StreamableFile {
|
|
|
12
12
|
this.stream.push(bufferOrReadStream);
|
|
13
13
|
this.stream.push(null);
|
|
14
14
|
}
|
|
15
|
-
else if (bufferOrReadStream.pipe && shared_utils_1.isFunction(bufferOrReadStream.pipe)) {
|
|
15
|
+
else if (bufferOrReadStream.pipe && (0, shared_utils_1.isFunction)(bufferOrReadStream.pipe)) {
|
|
16
16
|
this.stream = bufferOrReadStream;
|
|
17
17
|
}
|
|
18
18
|
}
|
package/http/http.module.js
CHANGED
|
@@ -22,7 +22,7 @@ let HttpModule = HttpModule_1 = class HttpModule {
|
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
provide: http_constants_1.HTTP_MODULE_ID,
|
|
25
|
-
useValue: random_string_generator_util_1.randomStringGenerator(),
|
|
25
|
+
useValue: (0, random_string_generator_util_1.randomStringGenerator)(),
|
|
26
26
|
},
|
|
27
27
|
],
|
|
28
28
|
};
|
|
@@ -40,7 +40,7 @@ let HttpModule = HttpModule_1 = class HttpModule {
|
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
provide: http_constants_1.HTTP_MODULE_ID,
|
|
43
|
-
useValue: random_string_generator_util_1.randomStringGenerator(),
|
|
43
|
+
useValue: (0, random_string_generator_util_1.randomStringGenerator)(),
|
|
44
44
|
},
|
|
45
45
|
...(options.extraProviders || []),
|
|
46
46
|
],
|
|
@@ -74,7 +74,7 @@ let HttpModule = HttpModule_1 = class HttpModule {
|
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
HttpModule = HttpModule_1 = tslib_1.__decorate([
|
|
77
|
-
module_decorator_1.Module({
|
|
77
|
+
(0, module_decorator_1.Module)({
|
|
78
78
|
providers: [
|
|
79
79
|
http_service_1.HttpService,
|
|
80
80
|
{
|
package/http/http.service.js
CHANGED
|
@@ -68,7 +68,7 @@ let HttpService = class HttpService {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
HttpService = tslib_1.__decorate([
|
|
71
|
-
tslib_1.__param(0, decorators_1.Inject(http_constants_1.AXIOS_INSTANCE_TOKEN)),
|
|
71
|
+
tslib_1.__param(0, (0, decorators_1.Inject)(http_constants_1.AXIOS_INSTANCE_TOKEN)),
|
|
72
72
|
tslib_1.__metadata("design:paramtypes", [Function])
|
|
73
73
|
], HttpService);
|
|
74
74
|
exports.HttpService = HttpService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/common",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.3",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
|
|
5
5
|
"author": "Kamil Mysliwiec",
|
|
6
6
|
"homepage": "https://nestjs.com",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"axios": "0.26.
|
|
20
|
+
"axios": "0.26.1",
|
|
21
21
|
"iterare": "1.2.1",
|
|
22
22
|
"tslib": "2.3.1",
|
|
23
23
|
"uuid": "8.3.2"
|
|
@@ -16,15 +16,15 @@ let DefaultValuePipe = class DefaultValuePipe {
|
|
|
16
16
|
this.defaultValue = defaultValue;
|
|
17
17
|
}
|
|
18
18
|
transform(value, _metadata) {
|
|
19
|
-
if (shared_utils_1.isNil(value) ||
|
|
20
|
-
(shared_utils_1.isNumber(value) && isNaN(value))) {
|
|
19
|
+
if ((0, shared_utils_1.isNil)(value) ||
|
|
20
|
+
((0, shared_utils_1.isNumber)(value) && isNaN(value))) {
|
|
21
21
|
return this.defaultValue;
|
|
22
22
|
}
|
|
23
23
|
return value;
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
DefaultValuePipe = tslib_1.__decorate([
|
|
27
|
-
injectable_decorator_1.Injectable(),
|
|
27
|
+
(0, injectable_decorator_1.Injectable)(),
|
|
28
28
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
29
29
|
], DefaultValuePipe);
|
|
30
30
|
exports.DefaultValuePipe = DefaultValuePipe;
|
|
@@ -37,11 +37,11 @@ let ParseArrayPipe = class ParseArrayPipe {
|
|
|
37
37
|
if (!value && !this.options.optional) {
|
|
38
38
|
throw this.exceptionFactory(VALIDATION_ERROR_MESSAGE);
|
|
39
39
|
}
|
|
40
|
-
else if (shared_utils_1.isNil(value) && this.options.optional) {
|
|
40
|
+
else if ((0, shared_utils_1.isNil)(value) && this.options.optional) {
|
|
41
41
|
return value;
|
|
42
42
|
}
|
|
43
43
|
if (!Array.isArray(value)) {
|
|
44
|
-
if (!shared_utils_1.isString(value)) {
|
|
44
|
+
if (!(0, shared_utils_1.isString)(value)) {
|
|
45
45
|
throw this.exceptionFactory(VALIDATION_ERROR_MESSAGE);
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
@@ -115,26 +115,26 @@ let ParseArrayPipe = class ParseArrayPipe {
|
|
|
115
115
|
if (this.options.items === Number) {
|
|
116
116
|
const value = originalValue !== null && originalValue !== '' ? +originalValue : NaN;
|
|
117
117
|
if (isNaN(value)) {
|
|
118
|
-
throw this.exceptionFactory(`${shared_utils_1.isUndefined(index) ? '' : `[${index}] `}item must be a number`);
|
|
118
|
+
throw this.exceptionFactory(`${(0, shared_utils_1.isUndefined)(index) ? '' : `[${index}] `}item must be a number`);
|
|
119
119
|
}
|
|
120
120
|
return value;
|
|
121
121
|
}
|
|
122
122
|
else if (this.options.items === String) {
|
|
123
|
-
if (!shared_utils_1.isString(originalValue)) {
|
|
123
|
+
if (!(0, shared_utils_1.isString)(originalValue)) {
|
|
124
124
|
return `${originalValue}`;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
else if (this.options.items === Boolean) {
|
|
128
128
|
if (typeof originalValue !== 'boolean') {
|
|
129
|
-
throw this.exceptionFactory(`${shared_utils_1.isUndefined(index) ? '' : `[${index}] `}item must be a boolean value`);
|
|
129
|
+
throw this.exceptionFactory(`${(0, shared_utils_1.isUndefined)(index) ? '' : `[${index}] `}item must be a boolean value`);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
return originalValue;
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
ParseArrayPipe = tslib_1.__decorate([
|
|
136
|
-
injectable_decorator_1.Injectable(),
|
|
137
|
-
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
136
|
+
(0, injectable_decorator_1.Injectable)(),
|
|
137
|
+
tslib_1.__param(0, (0, optional_decorator_1.Optional)()),
|
|
138
138
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
139
139
|
], ParseArrayPipe);
|
|
140
140
|
exports.ParseArrayPipe = ParseArrayPipe;
|
package/pipes/parse-bool.pipe.js
CHANGED
|
@@ -39,8 +39,8 @@ let ParseBoolPipe = class ParseBoolPipe {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
ParseBoolPipe = tslib_1.__decorate([
|
|
42
|
-
injectable_decorator_1.Injectable(),
|
|
43
|
-
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
42
|
+
(0, injectable_decorator_1.Injectable)(),
|
|
43
|
+
tslib_1.__param(0, (0, optional_decorator_1.Optional)()),
|
|
44
44
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
45
45
|
], ParseBoolPipe);
|
|
46
46
|
exports.ParseBoolPipe = ParseBoolPipe;
|
package/pipes/parse-enum.pipe.js
CHANGED
|
@@ -42,8 +42,8 @@ let ParseEnumPipe = class ParseEnumPipe {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
ParseEnumPipe = tslib_1.__decorate([
|
|
45
|
-
index_1.Injectable(),
|
|
46
|
-
tslib_1.__param(1, index_1.Optional()),
|
|
45
|
+
(0, index_1.Injectable)(),
|
|
46
|
+
tslib_1.__param(1, (0, index_1.Optional)()),
|
|
47
47
|
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
48
48
|
], ParseEnumPipe);
|
|
49
49
|
exports.ParseEnumPipe = ParseEnumPipe;
|
|
@@ -37,8 +37,8 @@ let ParseFloatPipe = class ParseFloatPipe {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
ParseFloatPipe = tslib_1.__decorate([
|
|
40
|
-
index_1.Injectable(),
|
|
41
|
-
tslib_1.__param(0, index_1.Optional()),
|
|
40
|
+
(0, index_1.Injectable)(),
|
|
41
|
+
tslib_1.__param(0, (0, index_1.Optional)()),
|
|
42
42
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
43
43
|
], ParseFloatPipe);
|
|
44
44
|
exports.ParseFloatPipe = ParseFloatPipe;
|
package/pipes/parse-int.pipe.js
CHANGED
|
@@ -39,8 +39,8 @@ let ParseIntPipe = class ParseIntPipe {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
ParseIntPipe = tslib_1.__decorate([
|
|
42
|
-
injectable_decorator_1.Injectable(),
|
|
43
|
-
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
42
|
+
(0, injectable_decorator_1.Injectable)(),
|
|
43
|
+
tslib_1.__param(0, (0, optional_decorator_1.Optional)()),
|
|
44
44
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
45
45
|
], ParseIntPipe);
|
|
46
46
|
exports.ParseIntPipe = ParseIntPipe;
|
package/pipes/parse-uuid.pipe.js
CHANGED
|
@@ -17,15 +17,15 @@ let ParseUUIDPipe = class ParseUUIDPipe {
|
|
|
17
17
|
(error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
|
|
18
18
|
}
|
|
19
19
|
async transform(value, metadata) {
|
|
20
|
-
if (!is_uuid_1.isUUID(value, this.version)) {
|
|
20
|
+
if (!(0, is_uuid_1.isUUID)(value, this.version)) {
|
|
21
21
|
throw this.exceptionFactory(`Validation failed (uuid ${this.version ? 'v' + this.version : ''} is expected)`);
|
|
22
22
|
}
|
|
23
23
|
return value;
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
ParseUUIDPipe = tslib_1.__decorate([
|
|
27
|
-
injectable_decorator_1.Injectable(),
|
|
28
|
-
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
27
|
+
(0, injectable_decorator_1.Injectable)(),
|
|
28
|
+
tslib_1.__param(0, (0, optional_decorator_1.Optional)()),
|
|
29
29
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
30
30
|
], ParseUUIDPipe);
|
|
31
31
|
exports.ParseUUIDPipe = ParseUUIDPipe;
|
package/pipes/validation.pipe.js
CHANGED
|
@@ -28,10 +28,10 @@ let ValidationPipe = class ValidationPipe {
|
|
|
28
28
|
classTransformer = this.loadTransformer(options.transformerPackage);
|
|
29
29
|
}
|
|
30
30
|
loadValidator(validatorPackage) {
|
|
31
|
-
return (validatorPackage !== null && validatorPackage !== void 0 ? validatorPackage : load_package_util_1.loadPackage('class-validator', 'ValidationPipe', () => require('class-validator')));
|
|
31
|
+
return (validatorPackage !== null && validatorPackage !== void 0 ? validatorPackage : (0, load_package_util_1.loadPackage)('class-validator', 'ValidationPipe', () => require('class-validator')));
|
|
32
32
|
}
|
|
33
33
|
loadTransformer(transformerPackage) {
|
|
34
|
-
return (transformerPackage !== null && transformerPackage !== void 0 ? transformerPackage : load_package_util_1.loadPackage('class-transformer', 'ValidationPipe', () => require('class-transformer')));
|
|
34
|
+
return (transformerPackage !== null && transformerPackage !== void 0 ? transformerPackage : (0, load_package_util_1.loadPackage)('class-transformer', 'ValidationPipe', () => require('class-transformer')));
|
|
35
35
|
}
|
|
36
36
|
async transform(value, metadata) {
|
|
37
37
|
if (this.expectedType) {
|
|
@@ -95,7 +95,7 @@ let ValidationPipe = class ValidationPipe {
|
|
|
95
95
|
return false;
|
|
96
96
|
}
|
|
97
97
|
const types = [String, Boolean, Number, Array, Object, Buffer];
|
|
98
|
-
return !types.some(t => metatype === t) && !shared_utils_1.isNil(metatype);
|
|
98
|
+
return !types.some(t => metatype === t) && !(0, shared_utils_1.isNil)(metatype);
|
|
99
99
|
}
|
|
100
100
|
transformPrimitive(value, metadata) {
|
|
101
101
|
if (!metadata.data) {
|
|
@@ -115,13 +115,13 @@ let ValidationPipe = class ValidationPipe {
|
|
|
115
115
|
return value;
|
|
116
116
|
}
|
|
117
117
|
toEmptyIfNil(value) {
|
|
118
|
-
return shared_utils_1.isNil(value) ? {} : value;
|
|
118
|
+
return (0, shared_utils_1.isNil)(value) ? {} : value;
|
|
119
119
|
}
|
|
120
120
|
stripProtoKeys(value) {
|
|
121
121
|
delete value.__proto__;
|
|
122
122
|
const keys = Object.keys(value);
|
|
123
|
-
iterare_1.iterate(keys)
|
|
124
|
-
.filter(key => shared_utils_1.isObject(value[key]) && value[key])
|
|
123
|
+
(0, iterare_1.iterate)(keys)
|
|
124
|
+
.filter(key => (0, shared_utils_1.isObject)(value[key]) && value[key])
|
|
125
125
|
.forEach(key => this.stripProtoKeys(value[key]));
|
|
126
126
|
}
|
|
127
127
|
isPrimitive(value) {
|
|
@@ -131,7 +131,7 @@ let ValidationPipe = class ValidationPipe {
|
|
|
131
131
|
return classValidator.validate(object, validatorOptions);
|
|
132
132
|
}
|
|
133
133
|
flattenValidationErrors(validationErrors) {
|
|
134
|
-
return iterare_1.iterate(validationErrors)
|
|
134
|
+
return (0, iterare_1.iterate)(validationErrors)
|
|
135
135
|
.map(error => this.mapChildrenToValidationErrors(error))
|
|
136
136
|
.flatten()
|
|
137
137
|
.filter(item => !!item.constraints)
|
|
@@ -164,8 +164,8 @@ let ValidationPipe = class ValidationPipe {
|
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
166
|
ValidationPipe = tslib_1.__decorate([
|
|
167
|
-
core_1.Injectable(),
|
|
168
|
-
tslib_1.__param(0, decorators_1.Optional()),
|
|
167
|
+
(0, core_1.Injectable)(),
|
|
168
|
+
tslib_1.__param(0, (0, decorators_1.Optional)()),
|
|
169
169
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
170
170
|
], ValidationPipe);
|
|
171
171
|
exports.ValidationPipe = ValidationPipe;
|
|
@@ -19,7 +19,7 @@ let ClassSerializerInterceptor = class ClassSerializerInterceptor {
|
|
|
19
19
|
this.reflector = reflector;
|
|
20
20
|
this.defaultOptions = defaultOptions;
|
|
21
21
|
classTransformer =
|
|
22
|
-
(_a = defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.transformerPackage) !== null && _a !== void 0 ? _a : load_package_util_1.loadPackage('class-transformer', 'ClassSerializerInterceptor', () => require('class-transformer'));
|
|
22
|
+
(_a = defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.transformerPackage) !== null && _a !== void 0 ? _a : (0, load_package_util_1.loadPackage)('class-transformer', 'ClassSerializerInterceptor', () => require('class-transformer'));
|
|
23
23
|
if (!(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.transformerPackage)) {
|
|
24
24
|
require('class-transformer');
|
|
25
25
|
}
|
|
@@ -29,13 +29,13 @@ let ClassSerializerInterceptor = class ClassSerializerInterceptor {
|
|
|
29
29
|
const options = Object.assign(Object.assign({}, this.defaultOptions), contextOptions);
|
|
30
30
|
return next
|
|
31
31
|
.handle()
|
|
32
|
-
.pipe(operators_1.map((res) => this.serialize(res, options)));
|
|
32
|
+
.pipe((0, operators_1.map)((res) => this.serialize(res, options)));
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Serializes responses that are non-null objects nor streamable files.
|
|
36
36
|
*/
|
|
37
37
|
serialize(response, options) {
|
|
38
|
-
if (!shared_utils_1.isObject(response) || response instanceof file_stream_1.StreamableFile) {
|
|
38
|
+
if (!(0, shared_utils_1.isObject)(response) || response instanceof file_stream_1.StreamableFile) {
|
|
39
39
|
return response;
|
|
40
40
|
}
|
|
41
41
|
return Array.isArray(response)
|
|
@@ -56,9 +56,9 @@ let ClassSerializerInterceptor = class ClassSerializerInterceptor {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
ClassSerializerInterceptor = tslib_1.__decorate([
|
|
59
|
-
core_1.Injectable(),
|
|
60
|
-
tslib_1.__param(0, core_1.Inject(REFLECTOR)),
|
|
61
|
-
tslib_1.__param(1, core_1.Optional()),
|
|
59
|
+
(0, core_1.Injectable)(),
|
|
60
|
+
tslib_1.__param(0, (0, core_1.Inject)(REFLECTOR)),
|
|
61
|
+
tslib_1.__param(1, (0, core_1.Optional)()),
|
|
62
62
|
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
63
63
|
], ClassSerializerInterceptor);
|
|
64
64
|
exports.ClassSerializerInterceptor = ClassSerializerInterceptor;
|
|
@@ -3,5 +3,5 @@ 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
|
-
const SerializeOptions = (options) => decorators_1.SetMetadata(class_serializer_constants_1.CLASS_SERIALIZER_OPTIONS, options);
|
|
6
|
+
const SerializeOptions = (options) => (0, decorators_1.SetMetadata)(class_serializer_constants_1.CLASS_SERIALIZER_OPTIONS, options);
|
|
7
7
|
exports.SerializeOptions = SerializeOptions;
|
|
@@ -64,6 +64,10 @@ export declare class ConsoleLogger implements LoggerService {
|
|
|
64
64
|
isLevelEnabled(level: LogLevel): boolean;
|
|
65
65
|
protected getTimestamp(): string;
|
|
66
66
|
protected printMessages(messages: unknown[], context?: string, logLevel?: LogLevel, writeStreamType?: 'stdout' | 'stderr'): void;
|
|
67
|
+
protected formatPid(pid: number): string;
|
|
68
|
+
protected formatMessage(logLevel: LogLevel, message: unknown, pidMessage: string, formattedLogLevel: string, contextMessage: string, timestampDiff: string): string;
|
|
69
|
+
protected stringifyMessage(message: unknown, logLevel: LogLevel): string;
|
|
70
|
+
protected colorize(message: string, logLevel: LogLevel): string;
|
|
67
71
|
protected printStackTrace(stack: string): void;
|
|
68
72
|
private updateAndGetTimestampDiff;
|
|
69
73
|
private getContextAndMessagesToPrint;
|
|
@@ -100,7 +100,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
100
100
|
isLevelEnabled(level) {
|
|
101
101
|
var _a;
|
|
102
102
|
const logLevels = (_a = this.options) === null || _a === void 0 ? void 0 : _a.logLevels;
|
|
103
|
-
return utils_1.isLogLevelEnabled(level, logLevels);
|
|
103
|
+
return (0, utils_1.isLogLevelEnabled)(level, logLevels);
|
|
104
104
|
}
|
|
105
105
|
getTimestamp() {
|
|
106
106
|
const localeStringOptions = {
|
|
@@ -114,19 +114,33 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
114
114
|
return new Date(Date.now()).toLocaleString(undefined, localeStringOptions);
|
|
115
115
|
}
|
|
116
116
|
printMessages(messages, context = '', logLevel = 'log', writeStreamType) {
|
|
117
|
-
const color = this.getColorByLogLevel(logLevel);
|
|
118
117
|
messages.forEach(message => {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
: color(message);
|
|
122
|
-
const pidMessage = color(`[Nest] ${process.pid} - `);
|
|
123
|
-
const contextMessage = context ? cli_colors_util_1.yellow(`[${context}] `) : '';
|
|
118
|
+
const pidMessage = this.formatPid(process.pid);
|
|
119
|
+
const contextMessage = context ? (0, cli_colors_util_1.yellow)(`[${context}] `) : '';
|
|
124
120
|
const timestampDiff = this.updateAndGetTimestampDiff();
|
|
125
|
-
const formattedLogLevel =
|
|
126
|
-
const
|
|
127
|
-
process[writeStreamType !== null && writeStreamType !== void 0 ? writeStreamType : 'stdout'].write(
|
|
121
|
+
const formattedLogLevel = logLevel.toUpperCase().padStart(7, ' ');
|
|
122
|
+
const formatedMessage = this.formatMessage(logLevel, message, pidMessage, formattedLogLevel, contextMessage, timestampDiff);
|
|
123
|
+
process[writeStreamType !== null && writeStreamType !== void 0 ? writeStreamType : 'stdout'].write(formatedMessage);
|
|
128
124
|
});
|
|
129
125
|
}
|
|
126
|
+
formatPid(pid) {
|
|
127
|
+
return `[Nest] ${pid} - `;
|
|
128
|
+
}
|
|
129
|
+
formatMessage(logLevel, message, pidMessage, formattedLogLevel, contextMessage, timestampDiff) {
|
|
130
|
+
const output = this.stringifyMessage(message, logLevel);
|
|
131
|
+
pidMessage = this.colorize(pidMessage, logLevel);
|
|
132
|
+
formattedLogLevel = this.colorize(formattedLogLevel, logLevel);
|
|
133
|
+
return `${pidMessage}${this.getTimestamp()} ${formattedLogLevel} ${contextMessage}${output}${timestampDiff}\n`;
|
|
134
|
+
}
|
|
135
|
+
stringifyMessage(message, logLevel) {
|
|
136
|
+
return (0, shared_utils_1.isPlainObject)(message)
|
|
137
|
+
? `${this.colorize('Object:', logLevel)}\n${JSON.stringify(message, (key, value) => typeof value === 'bigint' ? value.toString() : value, 2)}\n`
|
|
138
|
+
: this.colorize(message, logLevel);
|
|
139
|
+
}
|
|
140
|
+
colorize(message, logLevel) {
|
|
141
|
+
const color = this.getColorByLogLevel(logLevel);
|
|
142
|
+
return color(message);
|
|
143
|
+
}
|
|
130
144
|
printStackTrace(stack) {
|
|
131
145
|
if (!stack) {
|
|
132
146
|
return;
|
|
@@ -137,7 +151,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
137
151
|
var _a;
|
|
138
152
|
const includeTimestamp = ConsoleLogger_1.lastTimestampAt && ((_a = this.options) === null || _a === void 0 ? void 0 : _a.timestamp);
|
|
139
153
|
const result = includeTimestamp
|
|
140
|
-
? cli_colors_util_1.yellow(` +${Date.now() - ConsoleLogger_1.lastTimestampAt}ms`)
|
|
154
|
+
? (0, cli_colors_util_1.yellow)(` +${Date.now() - ConsoleLogger_1.lastTimestampAt}ms`)
|
|
141
155
|
: '';
|
|
142
156
|
ConsoleLogger_1.lastTimestampAt = Date.now();
|
|
143
157
|
return result;
|
|
@@ -147,7 +161,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
147
161
|
return { messages: args, context: this.context };
|
|
148
162
|
}
|
|
149
163
|
const lastElement = args[args.length - 1];
|
|
150
|
-
const isContext = shared_utils_1.isString(lastElement);
|
|
164
|
+
const isContext = (0, shared_utils_1.isString)(lastElement);
|
|
151
165
|
if (!isContext) {
|
|
152
166
|
return { messages: args, context: this.context };
|
|
153
167
|
}
|
|
@@ -162,7 +176,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
162
176
|
return { messages, context };
|
|
163
177
|
}
|
|
164
178
|
const lastElement = messages[messages.length - 1];
|
|
165
|
-
const isStack = shared_utils_1.isString(lastElement);
|
|
179
|
+
const isStack = (0, shared_utils_1.isString)(lastElement);
|
|
166
180
|
if (!isStack) {
|
|
167
181
|
return { messages, context };
|
|
168
182
|
}
|
|
@@ -188,9 +202,9 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
188
202
|
}
|
|
189
203
|
};
|
|
190
204
|
ConsoleLogger = ConsoleLogger_1 = tslib_1.__decorate([
|
|
191
|
-
injectable_decorator_1.Injectable(),
|
|
192
|
-
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
193
|
-
tslib_1.__param(1, optional_decorator_1.Optional()),
|
|
205
|
+
(0, injectable_decorator_1.Injectable)(),
|
|
206
|
+
tslib_1.__param(0, (0, optional_decorator_1.Optional)()),
|
|
207
|
+
tslib_1.__param(1, (0, optional_decorator_1.Optional)()),
|
|
194
208
|
tslib_1.__metadata("design:paramtypes", [String, Object])
|
|
195
209
|
], ConsoleLogger);
|
|
196
210
|
exports.ConsoleLogger = ConsoleLogger;
|
|
@@ -120,7 +120,7 @@ let Logger = Logger_1 = class Logger {
|
|
|
120
120
|
Logger_1.logLevels = logger;
|
|
121
121
|
return (_a = this.staticInstanceRef) === null || _a === void 0 ? void 0 : _a.setLogLevels(logger);
|
|
122
122
|
}
|
|
123
|
-
if (shared_utils_1.isObject(logger)) {
|
|
123
|
+
if ((0, shared_utils_1.isObject)(logger)) {
|
|
124
124
|
if (logger instanceof Logger_1 && logger.constructor !== Logger_1) {
|
|
125
125
|
const errorMessage = `Using the "extends Logger" instruction is not allowed in Nest v8. Please, use "extends ConsoleLogger" instead.`;
|
|
126
126
|
this.staticInstanceRef.error(errorMessage);
|
|
@@ -134,7 +134,7 @@ let Logger = Logger_1 = class Logger {
|
|
|
134
134
|
}
|
|
135
135
|
static isLevelEnabled(level) {
|
|
136
136
|
const logLevels = Logger_1.logLevels;
|
|
137
|
-
return utils_1.isLogLevelEnabled(level, logLevels);
|
|
137
|
+
return (0, utils_1.isLogLevelEnabled)(level, logLevels);
|
|
138
138
|
}
|
|
139
139
|
registerLocalInstanceRef() {
|
|
140
140
|
var _a;
|
|
@@ -224,9 +224,9 @@ tslib_1.__decorate([
|
|
|
224
224
|
tslib_1.__metadata("design:returntype", void 0)
|
|
225
225
|
], Logger, "verbose", null);
|
|
226
226
|
Logger = Logger_1 = tslib_1.__decorate([
|
|
227
|
-
injectable_decorator_1.Injectable(),
|
|
228
|
-
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
229
|
-
tslib_1.__param(1, optional_decorator_1.Optional()),
|
|
227
|
+
(0, injectable_decorator_1.Injectable)(),
|
|
228
|
+
tslib_1.__param(0, (0, optional_decorator_1.Optional)()),
|
|
229
|
+
tslib_1.__param(1, (0, optional_decorator_1.Optional)()),
|
|
230
230
|
tslib_1.__metadata("design:paramtypes", [String, Object])
|
|
231
231
|
], Logger);
|
|
232
232
|
exports.Logger = Logger;
|
package/utils/is-uuid.js
CHANGED
|
@@ -10,7 +10,7 @@ const uuid = {
|
|
|
10
10
|
all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
|
|
11
11
|
};
|
|
12
12
|
function isUUID(str, version = 'all') {
|
|
13
|
-
if (!shared_utils_1.isString(str)) {
|
|
13
|
+
if (!(0, shared_utils_1.isString)(str)) {
|
|
14
14
|
throw new exceptions_1.BadRequestException('The value passed as UUID is not a string');
|
|
15
15
|
}
|
|
16
16
|
const pattern = uuid[version];
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.randomStringGenerator = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
|
-
const randomStringGenerator = () => uuid_1.v4();
|
|
5
|
+
const randomStringGenerator = () => (0, uuid_1.v4)();
|
|
6
6
|
exports.randomStringGenerator = randomStringGenerator;
|
package/utils/shared.utils.js
CHANGED
|
@@ -4,10 +4,10 @@ exports.isSymbol = exports.isEmpty = exports.isNil = exports.isConstructor = exp
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
5
5
|
const isUndefined = (obj) => typeof obj === 'undefined';
|
|
6
6
|
exports.isUndefined = isUndefined;
|
|
7
|
-
const isObject = (fn) => !exports.isNil(fn) && typeof fn === 'object';
|
|
7
|
+
const isObject = (fn) => !(0, exports.isNil)(fn) && typeof fn === 'object';
|
|
8
8
|
exports.isObject = isObject;
|
|
9
9
|
const isPlainObject = (fn) => {
|
|
10
|
-
if (!exports.isObject(fn)) {
|
|
10
|
+
if (!(0, exports.isObject)(fn)) {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
13
|
const proto = Object.getPrototypeOf(fn);
|
|
@@ -49,7 +49,7 @@ const isNumber = (val) => typeof val === 'number';
|
|
|
49
49
|
exports.isNumber = isNumber;
|
|
50
50
|
const isConstructor = (val) => val === 'constructor';
|
|
51
51
|
exports.isConstructor = isConstructor;
|
|
52
|
-
const isNil = (val) => exports.isUndefined(val) || val === null;
|
|
52
|
+
const isNil = (val) => (0, exports.isUndefined)(val) || val === null;
|
|
53
53
|
exports.isNil = isNil;
|
|
54
54
|
const isEmpty = (array) => !(array && array.length > 0);
|
|
55
55
|
exports.isEmpty = isEmpty;
|
|
@@ -15,7 +15,7 @@ function validateModuleKeys(keys) {
|
|
|
15
15
|
if (metadataKeys.includes(key)) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
throw new Error(exports.INVALID_MODULE_CONFIG_MESSAGE `${key}`);
|
|
18
|
+
throw new Error((0, exports.INVALID_MODULE_CONFIG_MESSAGE) `${key}`);
|
|
19
19
|
};
|
|
20
20
|
keys.forEach(validateKey);
|
|
21
21
|
}
|