@nestjs/common 8.3.0 → 8.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/Readme.md +1 -0
- package/cache/cache.module.js +3 -3
- 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/decorators/index.js +2 -2
- package/cache/index.js +5 -5
- package/cache/interceptors/cache.interceptor.js +14 -14
- package/cache/interceptors/index.js +1 -1
- package/cache/interfaces/index.js +2 -2
- package/decorators/core/controller.decorator.js +2 -2
- package/decorators/core/exception-filters.decorator.js +5 -5
- package/decorators/core/index.js +14 -14
- 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/index.js +8 -8
- package/decorators/http/request-mapping.decorator.js +1 -1
- package/decorators/http/route-params.decorator.js +1 -1
- package/decorators/index.js +3 -3
- package/decorators/modules/index.js +2 -2
- package/decorators/modules/module.decorator.js +1 -1
- package/enums/index.js +4 -4
- package/exceptions/http.exception.js +4 -4
- package/exceptions/index.js +22 -22
- package/file-stream/index.js +1 -1
- package/file-stream/streamable-file.js +1 -1
- package/http/http.module.js +4 -4
- package/http/http.service.js +3 -3
- package/http/index.js +3 -3
- package/http/interfaces/index.js +1 -1
- package/index.js +10 -10
- package/interfaces/controllers/index.js +2 -2
- package/interfaces/exceptions/index.js +5 -5
- package/interfaces/hooks/index.js +5 -5
- package/interfaces/http/index.js +2 -2
- package/interfaces/index.js +29 -29
- package/interfaces/middleware/index.js +4 -4
- package/interfaces/modules/index.js +6 -6
- package/package.json +1 -1
- package/pipes/default-value.pipe.js +5 -5
- package/pipes/index.js +8 -8
- package/pipes/parse-array.pipe.js +9 -9
- package/pipes/parse-bool.pipe.js +4 -4
- package/pipes/parse-enum.pipe.js +4 -4
- package/pipes/parse-float.pipe.js +4 -4
- package/pipes/parse-int.pipe.js +4 -4
- package/pipes/parse-uuid.pipe.js +5 -5
- package/pipes/validation.pipe.js +12 -12
- package/serializer/class-serializer.interceptor.js +8 -8
- package/serializer/decorators/index.js +1 -1
- package/serializer/decorators/serialize-options.decorator.js +1 -1
- package/serializer/index.js +2 -2
- package/services/console-logger.service.js +11 -11
- package/services/index.js +2 -2
- package/services/logger.service.js +47 -47
- package/services/utils/index.js +1 -1
- package/utils/index.js +1 -1
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./controller-metadata.interface"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./controller.interface"), exports);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./exception-filter-metadata.interface"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./exception-filter.interface"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./rpc-exception-filter-metadata.interface"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./rpc-exception-filter.interface"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./ws-exception-filter.interface"), exports);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./before-application-shutdown.interface"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./on-application-bootstrap.interface"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./on-application-shutdown.interface"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./on-destroy.interface"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./on-init.interface"), exports);
|
package/interfaces/http/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./http-server.interface"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./message-event.interface"), exports);
|
package/interfaces/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./abstract.interface"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./controllers/controller-metadata.interface"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./controllers/controller.interface"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./exceptions/exception-filter.interface"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./exceptions/rpc-exception-filter.interface"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./exceptions/ws-exception-filter.interface"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./external/validation-error.interface"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./features/arguments-host.interface"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./features/can-activate.interface"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./features/custom-route-param-factory.interface"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./features/execution-context.interface"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./features/nest-interceptor.interface"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./features/paramtype.interface"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./features/pipe-transform.interface"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./global-prefix-options.interface"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./hooks"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./http"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./injectable.interface"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./microservices/nest-hybrid-application-options.interface"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./middleware"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./modules"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./nest-application-context.interface"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./nest-application-options.interface"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./nest-application.interface"), exports);
|
|
28
|
+
tslib_1.__exportStar(require("./nest-microservice.interface"), exports);
|
|
29
|
+
tslib_1.__exportStar(require("./scope-options.interface"), exports);
|
|
30
|
+
tslib_1.__exportStar(require("./type.interface"), exports);
|
|
31
|
+
tslib_1.__exportStar(require("./version-options.interface"), exports);
|
|
32
|
+
tslib_1.__exportStar(require("./websockets/web-socket-adapter.interface"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./middleware-config-proxy.interface"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./middleware-configuration.interface"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./middleware-consumer.interface"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./nest-middleware.interface"), exports);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./dynamic-module.interface"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./forward-reference.interface"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./introspection-result.interface"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./module-metadata.interface"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./nest-module.interface"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./provider.interface"), exports);
|
package/package.json
CHANGED
|
@@ -16,15 +16,15 @@ let DefaultValuePipe = class DefaultValuePipe {
|
|
|
16
16
|
this.defaultValue = defaultValue;
|
|
17
17
|
}
|
|
18
18
|
transform(value, _metadata) {
|
|
19
|
-
if (
|
|
20
|
-
(
|
|
19
|
+
if (shared_utils_1.isNil(value) ||
|
|
20
|
+
(shared_utils_1.isNumber(value) && isNaN(value))) {
|
|
21
21
|
return this.defaultValue;
|
|
22
22
|
}
|
|
23
23
|
return value;
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
DefaultValuePipe =
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
DefaultValuePipe = tslib_1.__decorate([
|
|
27
|
+
injectable_decorator_1.Injectable(),
|
|
28
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
29
29
|
], DefaultValuePipe);
|
|
30
30
|
exports.DefaultValuePipe = DefaultValuePipe;
|
package/pipes/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./default-value.pipe"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./parse-array.pipe"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./parse-bool.pipe"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./parse-int.pipe"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./parse-float.pipe"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./parse-enum.pipe"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./parse-uuid.pipe"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./validation.pipe"), exports);
|
|
@@ -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 (
|
|
40
|
+
else if (shared_utils_1.isNil(value) && this.options.optional) {
|
|
41
41
|
return value;
|
|
42
42
|
}
|
|
43
43
|
if (!Array.isArray(value)) {
|
|
44
|
-
if (!
|
|
44
|
+
if (!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(`${
|
|
118
|
+
throw this.exceptionFactory(`${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 (!
|
|
123
|
+
if (!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(`${
|
|
129
|
+
throw this.exceptionFactory(`${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
|
-
ParseArrayPipe =
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
ParseArrayPipe = tslib_1.__decorate([
|
|
136
|
+
injectable_decorator_1.Injectable(),
|
|
137
|
+
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
138
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
139
139
|
], ParseArrayPipe);
|
|
140
140
|
exports.ParseArrayPipe = ParseArrayPipe;
|
package/pipes/parse-bool.pipe.js
CHANGED
|
@@ -38,9 +38,9 @@ let ParseBoolPipe = class ParseBoolPipe {
|
|
|
38
38
|
throw this.exceptionFactory('Validation failed (boolean string is expected)');
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
ParseBoolPipe =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
ParseBoolPipe = tslib_1.__decorate([
|
|
42
|
+
injectable_decorator_1.Injectable(),
|
|
43
|
+
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
44
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
45
45
|
], ParseBoolPipe);
|
|
46
46
|
exports.ParseBoolPipe = ParseBoolPipe;
|
package/pipes/parse-enum.pipe.js
CHANGED
|
@@ -41,9 +41,9 @@ let ParseEnumPipe = class ParseEnumPipe {
|
|
|
41
41
|
return enumValues.includes(value);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
ParseEnumPipe =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
ParseEnumPipe = tslib_1.__decorate([
|
|
45
|
+
index_1.Injectable(),
|
|
46
|
+
tslib_1.__param(1, index_1.Optional()),
|
|
47
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
48
48
|
], ParseEnumPipe);
|
|
49
49
|
exports.ParseEnumPipe = ParseEnumPipe;
|
|
@@ -36,9 +36,9 @@ let ParseFloatPipe = class ParseFloatPipe {
|
|
|
36
36
|
return parseFloat(value);
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
ParseFloatPipe =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
ParseFloatPipe = tslib_1.__decorate([
|
|
40
|
+
index_1.Injectable(),
|
|
41
|
+
tslib_1.__param(0, index_1.Optional()),
|
|
42
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
43
43
|
], ParseFloatPipe);
|
|
44
44
|
exports.ParseFloatPipe = ParseFloatPipe;
|
package/pipes/parse-int.pipe.js
CHANGED
|
@@ -38,9 +38,9 @@ let ParseIntPipe = class ParseIntPipe {
|
|
|
38
38
|
return parseInt(value, 10);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
ParseIntPipe =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
ParseIntPipe = tslib_1.__decorate([
|
|
42
|
+
injectable_decorator_1.Injectable(),
|
|
43
|
+
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
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 (!
|
|
20
|
+
if (!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
|
-
ParseUUIDPipe =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
ParseUUIDPipe = tslib_1.__decorate([
|
|
27
|
+
injectable_decorator_1.Injectable(),
|
|
28
|
+
tslib_1.__param(0, optional_decorator_1.Optional()),
|
|
29
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
30
30
|
], ParseUUIDPipe);
|
|
31
31
|
exports.ParseUUIDPipe = ParseUUIDPipe;
|
package/pipes/validation.pipe.js
CHANGED
|
@@ -14,7 +14,7 @@ let classTransformer = {};
|
|
|
14
14
|
let ValidationPipe = class ValidationPipe {
|
|
15
15
|
constructor(options) {
|
|
16
16
|
options = options || {};
|
|
17
|
-
const { transform, disableErrorMessages, errorHttpStatusCode, expectedType, transformOptions, validateCustomDecorators } = options, validatorOptions =
|
|
17
|
+
const { transform, disableErrorMessages, errorHttpStatusCode, expectedType, transformOptions, validateCustomDecorators } = options, validatorOptions = tslib_1.__rest(options, ["transform", "disableErrorMessages", "errorHttpStatusCode", "expectedType", "transformOptions", "validateCustomDecorators"]);
|
|
18
18
|
this.isTransformEnabled = !!transform;
|
|
19
19
|
this.validatorOptions = validatorOptions;
|
|
20
20
|
this.transformOptions = transformOptions;
|
|
@@ -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 :
|
|
31
|
+
return (validatorPackage !== null && validatorPackage !== void 0 ? validatorPackage : 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 :
|
|
34
|
+
return (transformerPackage !== null && transformerPackage !== void 0 ? transformerPackage : 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) && !
|
|
98
|
+
return !types.some(t => metatype === t) && !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
|
|
118
|
+
return 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
|
-
|
|
124
|
-
.filter(key =>
|
|
123
|
+
iterare_1.iterate(keys)
|
|
124
|
+
.filter(key => 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
|
|
134
|
+
return iterare_1.iterate(validationErrors)
|
|
135
135
|
.map(error => this.mapChildrenToValidationErrors(error))
|
|
136
136
|
.flatten()
|
|
137
137
|
.filter(item => !!item.constraints)
|
|
@@ -163,9 +163,9 @@ let ValidationPipe = class ValidationPipe {
|
|
|
163
163
|
return Object.assign(Object.assign({}, error), { constraints });
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
|
-
ValidationPipe =
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
ValidationPipe = tslib_1.__decorate([
|
|
167
|
+
core_1.Injectable(),
|
|
168
|
+
tslib_1.__param(0, decorators_1.Optional()),
|
|
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 :
|
|
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'));
|
|
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(
|
|
32
|
+
.pipe(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 (!
|
|
38
|
+
if (!shared_utils_1.isObject(response) || response instanceof file_stream_1.StreamableFile) {
|
|
39
39
|
return response;
|
|
40
40
|
}
|
|
41
41
|
return Array.isArray(response)
|
|
@@ -55,10 +55,10 @@ let ClassSerializerInterceptor = class ClassSerializerInterceptor {
|
|
|
55
55
|
return this.reflector.get(class_serializer_constants_1.CLASS_SERIALIZER_OPTIONS, obj);
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
ClassSerializerInterceptor =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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()),
|
|
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) =>
|
|
6
|
+
const SerializeOptions = (options) => decorators_1.SetMetadata(class_serializer_constants_1.CLASS_SERIALIZER_OPTIONS, options);
|
|
7
7
|
exports.SerializeOptions = SerializeOptions;
|
package/serializer/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./class-serializer.interceptor"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./decorators"), exports);
|
|
@@ -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
|
|
103
|
+
return utils_1.isLogLevelEnabled(level, logLevels);
|
|
104
104
|
}
|
|
105
105
|
getTimestamp() {
|
|
106
106
|
const localeStringOptions = {
|
|
@@ -116,11 +116,11 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
116
116
|
printMessages(messages, context = '', logLevel = 'log', writeStreamType) {
|
|
117
117
|
const color = this.getColorByLogLevel(logLevel);
|
|
118
118
|
messages.forEach(message => {
|
|
119
|
-
const output =
|
|
119
|
+
const output = shared_utils_1.isPlainObject(message)
|
|
120
120
|
? `${color('Object:')}\n${JSON.stringify(message, (key, value) => typeof value === 'bigint' ? value.toString() : value, 2)}\n`
|
|
121
121
|
: color(message);
|
|
122
122
|
const pidMessage = color(`[Nest] ${process.pid} - `);
|
|
123
|
-
const contextMessage = context ?
|
|
123
|
+
const contextMessage = context ? cli_colors_util_1.yellow(`[${context}] `) : '';
|
|
124
124
|
const timestampDiff = this.updateAndGetTimestampDiff();
|
|
125
125
|
const formattedLogLevel = color(logLevel.toUpperCase().padStart(7, ' '));
|
|
126
126
|
const computedMessage = `${pidMessage}${this.getTimestamp()} ${formattedLogLevel} ${contextMessage}${output}${timestampDiff}\n`;
|
|
@@ -137,7 +137,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
137
137
|
var _a;
|
|
138
138
|
const includeTimestamp = ConsoleLogger_1.lastTimestampAt && ((_a = this.options) === null || _a === void 0 ? void 0 : _a.timestamp);
|
|
139
139
|
const result = includeTimestamp
|
|
140
|
-
?
|
|
140
|
+
? cli_colors_util_1.yellow(` +${Date.now() - ConsoleLogger_1.lastTimestampAt}ms`)
|
|
141
141
|
: '';
|
|
142
142
|
ConsoleLogger_1.lastTimestampAt = Date.now();
|
|
143
143
|
return result;
|
|
@@ -147,7 +147,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
147
147
|
return { messages: args, context: this.context };
|
|
148
148
|
}
|
|
149
149
|
const lastElement = args[args.length - 1];
|
|
150
|
-
const isContext =
|
|
150
|
+
const isContext = shared_utils_1.isString(lastElement);
|
|
151
151
|
if (!isContext) {
|
|
152
152
|
return { messages: args, context: this.context };
|
|
153
153
|
}
|
|
@@ -162,7 +162,7 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
162
162
|
return { messages, context };
|
|
163
163
|
}
|
|
164
164
|
const lastElement = messages[messages.length - 1];
|
|
165
|
-
const isStack =
|
|
165
|
+
const isStack = shared_utils_1.isString(lastElement);
|
|
166
166
|
if (!isStack) {
|
|
167
167
|
return { messages, context };
|
|
168
168
|
}
|
|
@@ -187,10 +187,10 @@ let ConsoleLogger = ConsoleLogger_1 = class ConsoleLogger {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
|
-
ConsoleLogger = ConsoleLogger_1 =
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
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()),
|
|
194
|
+
tslib_1.__metadata("design:paramtypes", [String, Object])
|
|
195
195
|
], ConsoleLogger);
|
|
196
196
|
exports.ConsoleLogger = ConsoleLogger;
|
package/services/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./console-logger.service"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./logger.service"), exports);
|