@depup/nestjs__common 11.2.2-depup.0 → 12.0.1-depup.0
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 +3 -9
- package/changes.json +3 -8
- package/constants.js +35 -38
- package/decorators/core/apply-decorators.js +1 -4
- package/decorators/core/bind.decorator.js +1 -4
- package/decorators/core/catch.decorator.d.ts +1 -1
- package/decorators/core/catch.decorator.js +4 -7
- package/decorators/core/controller.decorator.d.ts +1 -1
- package/decorators/core/controller.decorator.js +10 -13
- package/decorators/core/dependencies.decorator.js +4 -9
- package/decorators/core/exception-filters.decorator.d.ts +1 -1
- package/decorators/core/exception-filters.decorator.js +10 -14
- package/decorators/core/index.d.ts +14 -14
- package/decorators/core/index.js +14 -17
- package/decorators/core/inject.decorator.d.ts +1 -1
- package/decorators/core/inject.decorator.js +9 -12
- package/decorators/core/injectable.decorator.d.ts +2 -2
- package/decorators/core/injectable.decorator.js +7 -11
- package/decorators/core/optional.decorator.js +8 -11
- package/decorators/core/set-metadata.decorator.js +1 -5
- package/decorators/core/use-guards.decorator.d.ts +1 -1
- package/decorators/core/use-guards.decorator.js +10 -13
- package/decorators/core/use-interceptors.decorator.d.ts +1 -1
- package/decorators/core/use-interceptors.decorator.js +10 -13
- package/decorators/core/use-pipes.decorator.d.ts +1 -1
- package/decorators/core/use-pipes.decorator.js +10 -13
- package/decorators/core/version.decorator.d.ts +1 -1
- package/decorators/core/version.decorator.js +3 -6
- package/decorators/http/create-route-param-metadata.decorator.d.ts +6 -5
- package/decorators/http/create-route-param-metadata.decorator.js +43 -16
- package/decorators/http/header.decorator.js +4 -7
- package/decorators/http/http-code.decorator.js +3 -6
- package/decorators/http/index.d.ts +9 -9
- package/decorators/http/index.js +9 -12
- package/decorators/http/redirect.decorator.js +3 -6
- package/decorators/http/render.decorator.js +3 -6
- package/decorators/http/request-mapping.decorator.d.ts +1 -1
- package/decorators/http/request-mapping.decorator.js +29 -33
- package/decorators/http/route-params.decorator.d.ts +153 -3
- package/decorators/http/route-params.decorator.js +122 -49
- package/decorators/http/sse-signal.decorator.js +4 -7
- package/decorators/http/sse.decorator.d.ts +2 -2
- package/decorators/http/sse.decorator.js +7 -10
- package/decorators/index.d.ts +3 -3
- package/decorators/index.js +3 -6
- package/decorators/modules/global.decorator.js +3 -6
- package/decorators/modules/index.d.ts +2 -2
- package/decorators/modules/index.js +2 -5
- package/decorators/modules/module.decorator.d.ts +1 -1
- package/decorators/modules/module.decorator.js +3 -6
- package/enums/http-status.enum.js +2 -5
- package/enums/index.d.ts +4 -4
- package/enums/index.js +4 -7
- package/enums/request-method.enum.js +2 -5
- package/enums/route-paramtypes.enum.js +2 -5
- package/enums/shutdown-signal.enum.js +2 -5
- package/enums/version-type.enum.js +2 -5
- package/exceptions/bad-gateway.exception.d.ts +1 -1
- package/exceptions/bad-gateway.exception.js +5 -9
- package/exceptions/bad-request.exception.d.ts +1 -1
- package/exceptions/bad-request.exception.js +5 -9
- package/exceptions/conflict.exception.d.ts +1 -1
- package/exceptions/conflict.exception.js +5 -9
- package/exceptions/forbidden.exception.d.ts +1 -1
- package/exceptions/forbidden.exception.js +5 -9
- package/exceptions/gateway-timeout.exception.d.ts +1 -1
- package/exceptions/gateway-timeout.exception.js +5 -9
- package/exceptions/gone.exception.d.ts +1 -1
- package/exceptions/gone.exception.js +5 -9
- package/exceptions/http-version-not-supported.exception.d.ts +1 -1
- package/exceptions/http-version-not-supported.exception.js +5 -9
- package/exceptions/http.exception.d.ts +6 -2
- package/exceptions/http.exception.js +36 -17
- package/exceptions/im-a-teapot.exception.d.ts +1 -1
- package/exceptions/im-a-teapot.exception.js +5 -9
- package/exceptions/index.d.ts +23 -23
- package/exceptions/index.js +23 -26
- package/exceptions/internal-server-error.exception.d.ts +1 -1
- package/exceptions/internal-server-error.exception.js +5 -9
- package/exceptions/intrinsic.exception.js +1 -5
- package/exceptions/method-not-allowed.exception.d.ts +1 -1
- package/exceptions/method-not-allowed.exception.js +5 -9
- package/exceptions/misdirected.exception.d.ts +1 -1
- package/exceptions/misdirected.exception.js +5 -9
- package/exceptions/not-acceptable.exception.d.ts +1 -1
- package/exceptions/not-acceptable.exception.js +5 -9
- package/exceptions/not-found.exception.d.ts +1 -1
- package/exceptions/not-found.exception.js +5 -9
- package/exceptions/not-implemented.exception.d.ts +1 -1
- package/exceptions/not-implemented.exception.js +5 -9
- package/exceptions/payload-too-large.exception.d.ts +1 -1
- package/exceptions/payload-too-large.exception.js +5 -9
- package/exceptions/precondition-failed.exception.d.ts +1 -1
- package/exceptions/precondition-failed.exception.js +5 -9
- package/exceptions/request-timeout.exception.d.ts +1 -1
- package/exceptions/request-timeout.exception.js +5 -9
- package/exceptions/service-unavailable.exception.d.ts +1 -1
- package/exceptions/service-unavailable.exception.js +5 -9
- package/exceptions/unauthorized.exception.d.ts +1 -1
- package/exceptions/unauthorized.exception.js +5 -9
- package/exceptions/unprocessable-entity.exception.d.ts +1 -1
- package/exceptions/unprocessable-entity.exception.js +5 -9
- package/exceptions/unsupported-media-type.exception.d.ts +1 -1
- package/exceptions/unsupported-media-type.exception.js +5 -9
- package/file-stream/index.d.ts +1 -1
- package/file-stream/index.js +1 -4
- package/file-stream/interfaces/index.d.ts +2 -2
- package/file-stream/interfaces/index.js +2 -5
- package/file-stream/interfaces/streamable-handler-response.interface.js +1 -2
- package/file-stream/interfaces/streamable-options.interface.js +1 -2
- package/file-stream/streamable-file.d.ts +2 -2
- package/file-stream/streamable-file.js +26 -28
- package/index.d.ts +10 -10
- package/index.js +11 -17
- package/interfaces/abstract.interface.js +1 -2
- package/interfaces/controllers/controller-metadata.interface.js +1 -2
- package/interfaces/controllers/controller.interface.js +1 -2
- package/interfaces/controllers/index.d.ts +2 -2
- package/interfaces/controllers/index.js +2 -5
- package/interfaces/exceptions/exception-filter-metadata.interface.d.ts +2 -2
- package/interfaces/exceptions/exception-filter-metadata.interface.js +1 -2
- package/interfaces/exceptions/exception-filter.interface.d.ts +1 -1
- package/interfaces/exceptions/exception-filter.interface.js +1 -2
- package/interfaces/exceptions/index.d.ts +5 -5
- package/interfaces/exceptions/index.js +5 -8
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.d.ts +2 -2
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.js +1 -2
- package/interfaces/exceptions/rpc-exception-filter.interface.d.ts +1 -1
- package/interfaces/exceptions/rpc-exception-filter.interface.js +1 -2
- package/interfaces/exceptions/ws-exception-filter.interface.d.ts +1 -1
- package/interfaces/exceptions/ws-exception-filter.interface.js +1 -2
- package/interfaces/external/class-transform-options.interface.js +1 -2
- package/interfaces/external/cors-options.interface.js +1 -2
- package/interfaces/external/https-options.interface.js +1 -2
- package/interfaces/external/transformer-package.interface.d.ts +2 -2
- package/interfaces/external/transformer-package.interface.js +1 -2
- package/interfaces/external/validation-error.interface.js +1 -2
- package/interfaces/external/validator-options.interface.js +1 -2
- package/interfaces/external/validator-package.interface.d.ts +2 -2
- package/interfaces/external/validator-package.interface.js +1 -2
- package/interfaces/features/arguments-host.interface.js +1 -2
- package/interfaces/features/can-activate.interface.d.ts +1 -1
- package/interfaces/features/can-activate.interface.js +1 -2
- package/interfaces/features/custom-route-param-factory.interface.d.ts +1 -1
- package/interfaces/features/custom-route-param-factory.interface.js +1 -2
- package/interfaces/features/execution-context.interface.d.ts +2 -2
- package/interfaces/features/execution-context.interface.js +1 -2
- package/interfaces/features/nest-interceptor.interface.d.ts +1 -1
- package/interfaces/features/nest-interceptor.interface.js +1 -2
- package/interfaces/features/paramtype.interface.js +1 -2
- package/interfaces/features/pipe-transform.interface.d.ts +10 -4
- package/interfaces/features/pipe-transform.interface.js +1 -2
- package/interfaces/global-prefix-options.interface.d.ts +1 -1
- package/interfaces/global-prefix-options.interface.js +1 -2
- package/interfaces/hooks/before-application-shutdown.interface.js +1 -2
- package/interfaces/hooks/index.d.ts +5 -5
- package/interfaces/hooks/index.js +5 -8
- package/interfaces/hooks/on-application-bootstrap.interface.js +1 -2
- package/interfaces/hooks/on-application-shutdown.interface.js +1 -2
- package/interfaces/hooks/on-destroy.interface.js +1 -2
- package/interfaces/hooks/on-init.interface.js +1 -2
- package/interfaces/http/http-exception-body.interface.d.ts +2 -1
- package/interfaces/http/http-exception-body.interface.js +1 -2
- package/interfaces/http/http-redirect-response.interface.d.ts +1 -1
- package/interfaces/http/http-redirect-response.interface.js +1 -2
- package/interfaces/http/http-server.interface.d.ts +5 -3
- package/interfaces/http/http-server.interface.js +1 -2
- package/interfaces/http/index.d.ts +5 -5
- package/interfaces/http/index.js +5 -8
- package/interfaces/http/message-event.interface.js +1 -2
- package/interfaces/http/raw-body-request.interface.js +1 -2
- package/interfaces/index.d.ts +33 -30
- package/interfaces/index.js +33 -33
- package/interfaces/injectable.interface.js +1 -2
- package/interfaces/microservices/nest-hybrid-application-options.interface.js +1 -2
- package/interfaces/microservices/nest-microservice-options.interface.d.ts +1 -1
- package/interfaces/microservices/nest-microservice-options.interface.js +1 -2
- package/interfaces/microservices/pre-request-hook.interface.d.ts +22 -0
- package/interfaces/microservices/pre-request-hook.interface.js +1 -0
- package/interfaces/microservices/transport-server.interface.d.ts +18 -0
- package/interfaces/microservices/transport-server.interface.js +1 -0
- package/interfaces/middleware/index.d.ts +4 -4
- package/interfaces/middleware/index.js +4 -7
- package/interfaces/middleware/middleware-config-proxy.interface.d.ts +3 -3
- package/interfaces/middleware/middleware-config-proxy.interface.js +1 -2
- package/interfaces/middleware/middleware-configuration.interface.d.ts +3 -3
- package/interfaces/middleware/middleware-configuration.interface.js +1 -2
- package/interfaces/middleware/middleware-consumer.interface.d.ts +2 -2
- package/interfaces/middleware/middleware-consumer.interface.js +1 -2
- package/interfaces/middleware/nest-middleware.interface.js +1 -2
- package/interfaces/modules/dynamic-module.interface.d.ts +2 -2
- package/interfaces/modules/dynamic-module.interface.js +1 -2
- package/interfaces/modules/forward-reference.interface.js +1 -2
- package/interfaces/modules/index.d.ts +8 -8
- package/interfaces/modules/index.js +8 -11
- package/interfaces/modules/injection-token.interface.d.ts +2 -2
- package/interfaces/modules/injection-token.interface.js +1 -2
- package/interfaces/modules/introspection-result.interface.d.ts +1 -1
- package/interfaces/modules/introspection-result.interface.js +1 -2
- package/interfaces/modules/module-metadata.interface.d.ts +5 -5
- package/interfaces/modules/module-metadata.interface.js +1 -2
- package/interfaces/modules/nest-module.interface.d.ts +1 -1
- package/interfaces/modules/nest-module.interface.js +1 -2
- package/interfaces/modules/optional-factory-dependency.interface.d.ts +1 -1
- package/interfaces/modules/optional-factory-dependency.interface.js +1 -2
- package/interfaces/modules/provider.interface.d.ts +4 -4
- package/interfaces/modules/provider.interface.js +1 -2
- package/interfaces/nest-application-context-options.interface.d.ts +1 -1
- package/interfaces/nest-application-context-options.interface.js +55 -5
- package/interfaces/nest-application-context.interface.d.ts +6 -6
- package/interfaces/nest-application-context.interface.js +1 -2
- package/interfaces/nest-application-options.interface.d.ts +24 -3
- package/interfaces/nest-application-options.interface.js +1 -2
- package/interfaces/nest-application.interface.d.ts +8 -8
- package/interfaces/nest-application.interface.js +1 -2
- package/interfaces/nest-microservice.interface.d.ts +22 -6
- package/interfaces/nest-microservice.interface.js +1 -2
- package/interfaces/router-options.interface.d.ts +28 -0
- package/interfaces/router-options.interface.js +1 -0
- package/interfaces/scope-options.interface.js +2 -5
- package/interfaces/shutdown-hooks-options.interface.js +1 -2
- package/interfaces/type.interface.js +1 -2
- package/interfaces/version-options.interface.d.ts +1 -1
- package/interfaces/version-options.interface.js +1 -4
- package/interfaces/websockets/web-socket-adapter.interface.js +1 -2
- package/internal.d.ts +31 -0
- package/internal.js +20 -0
- package/module-utils/configurable-module.builder.d.ts +4 -4
- package/module-utils/configurable-module.builder.js +21 -20
- package/module-utils/constants.js +5 -8
- package/module-utils/index.d.ts +2 -2
- package/module-utils/index.js +2 -5
- package/module-utils/interfaces/configurable-module-async-options.interface.d.ts +2 -2
- package/module-utils/interfaces/configurable-module-async-options.interface.js +1 -2
- package/module-utils/interfaces/configurable-module-cls.interface.d.ts +3 -3
- package/module-utils/interfaces/configurable-module-cls.interface.js +1 -2
- package/module-utils/interfaces/configurable-module-host.interface.d.ts +2 -2
- package/module-utils/interfaces/configurable-module-host.interface.js +1 -2
- package/module-utils/interfaces/index.d.ts +3 -3
- package/module-utils/interfaces/index.js +3 -6
- package/module-utils/utils/generate-options-injection-token.util.js +3 -6
- package/module-utils/utils/get-injection-providers.util.d.ts +1 -1
- package/module-utils/utils/get-injection-providers.util.js +4 -7
- package/module-utils/utils/index.d.ts +2 -2
- package/module-utils/utils/index.js +2 -5
- package/package.json +16 -12
- package/pipes/default-value.pipe.d.ts +1 -1
- package/pipes/default-value.pipe.js +10 -12
- package/pipes/file/file-type.validator.d.ts +3 -3
- package/pipes/file/file-type.validator.js +5 -19
- package/pipes/file/file-validator-context.interface.d.ts +1 -1
- package/pipes/file/file-validator-context.interface.js +1 -2
- package/pipes/file/file-validator.interface.d.ts +1 -1
- package/pipes/file/file-validator.interface.js +2 -5
- package/pipes/file/index.d.ts +6 -6
- package/pipes/file/index.js +6 -9
- package/pipes/file/interfaces/file.interface.js +1 -2
- package/pipes/file/interfaces/index.d.ts +1 -1
- package/pipes/file/interfaces/index.js +1 -4
- package/pipes/file/max-file-size.validator.d.ts +3 -3
- package/pipes/file/max-file-size.validator.js +2 -6
- package/pipes/file/parse-file-options.interface.d.ts +2 -2
- package/pipes/file/parse-file-options.interface.js +1 -2
- package/pipes/file/parse-file-pipe.builder.d.ts +5 -5
- package/pipes/file/parse-file-pipe.builder.js +8 -14
- package/pipes/file/parse-file.pipe.d.ts +7 -7
- package/pipes/file/parse-file.pipe.js +17 -18
- package/pipes/index.d.ts +11 -10
- package/pipes/index.js +11 -13
- package/pipes/parse-array.pipe.d.ts +4 -4
- package/pipes/parse-array.pipe.js +23 -23
- package/pipes/parse-bool.pipe.d.ts +6 -6
- package/pipes/parse-bool.pipe.js +16 -17
- package/pipes/parse-date.pipe.d.ts +4 -4
- package/pipes/parse-date.pipe.js +18 -17
- package/pipes/parse-enum.pipe.d.ts +5 -5
- package/pipes/parse-enum.pipe.js +16 -16
- package/pipes/parse-float.pipe.d.ts +6 -6
- package/pipes/parse-float.pipe.js +30 -20
- package/pipes/parse-int.pipe.d.ts +5 -5
- package/pipes/parse-int.pipe.js +18 -19
- package/pipes/parse-uuid.pipe.d.ts +4 -4
- package/pipes/parse-uuid.pipe.js +27 -26
- package/pipes/standard-schema-validation.pipe.d.ts +91 -0
- package/pipes/standard-schema-validation.pipe.js +132 -0
- package/pipes/validation.pipe.d.ts +32 -14
- package/pipes/validation.pipe.js +66 -30
- package/serializer/class-serializer.constants.js +1 -4
- package/serializer/class-serializer.interceptor.d.ts +5 -5
- package/serializer/class-serializer.interceptor.js +21 -24
- package/serializer/class-serializer.interfaces.d.ts +2 -2
- package/serializer/class-serializer.interfaces.js +1 -2
- package/serializer/decorators/index.d.ts +1 -1
- package/serializer/decorators/index.js +1 -4
- package/serializer/decorators/serialize-options.decorator.d.ts +3 -2
- package/serializer/decorators/serialize-options.decorator.js +3 -7
- package/serializer/index.d.ts +5 -3
- package/serializer/index.js +5 -6
- package/serializer/standard-schema-serializer.interceptor.d.ts +50 -0
- package/serializer/standard-schema-serializer.interceptor.js +75 -0
- package/serializer/standard-schema-serializer.interfaces.d.ts +18 -0
- package/serializer/standard-schema-serializer.interfaces.js +1 -0
- package/services/console-logger.service.d.ts +39 -3
- package/services/console-logger.service.js +138 -66
- package/services/index.d.ts +3 -3
- package/services/index.js +3 -6
- package/services/logger.service.js +86 -83
- package/services/utils/filter-log-levels.util.d.ts +1 -1
- package/services/utils/filter-log-levels.util.js +7 -10
- package/services/utils/index.d.ts +3 -3
- package/services/utils/index.js +3 -6
- package/services/utils/is-log-level-enabled.util.d.ts +1 -1
- package/services/utils/is-log-level-enabled.util.js +1 -4
- package/services/utils/is-log-level.util.d.ts +1 -1
- package/services/utils/is-log-level.util.js +3 -6
- package/tsconfig.build.json +1 -2
- package/utils/assign-custom-metadata.util.d.ts +5 -4
- package/utils/assign-custom-metadata.util.js +4 -6
- package/utils/cli-colors.util.js +4 -8
- package/utils/extend-metadata.util.js +1 -4
- package/utils/forward-ref.util.d.ts +1 -1
- package/utils/forward-ref.util.js +1 -5
- package/utils/http-error-by-code.util.d.ts +2 -2
- package/utils/http-error-by-code.util.js +24 -27
- package/utils/index.d.ts +1 -1
- package/utils/index.js +1 -4
- package/utils/load-package.util.d.ts +29 -1
- package/utils/load-package.util.js +90 -9
- package/utils/merge-with-values.util.js +1 -5
- package/utils/parameter-decorator-options.util.d.ts +13 -0
- package/utils/parameter-decorator-options.util.js +22 -0
- package/utils/random-string-generator.util.js +2 -6
- package/utils/select-exception-filter-metadata.util.d.ts +1 -1
- package/utils/select-exception-filter-metadata.util.js +1 -5
- package/utils/shared.utils.d.ts +11 -10
- package/utils/shared.utils.js +28 -30
- package/utils/validate-each.util.js +3 -7
- package/utils/validate-module-keys.util.js +8 -13
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
|
|
6
|
-
const shared_utils_1 = require("../../utils/shared.utils");
|
|
7
|
-
const validate_each_util_1 = require("../../utils/validate-each.util");
|
|
1
|
+
import { PIPES_METADATA } from '../../constants.js';
|
|
2
|
+
import { extendArrayMetadata } from '../../utils/extend-metadata.util.js';
|
|
3
|
+
import { isFunction } from '../../utils/shared.utils.js';
|
|
4
|
+
import { validateEach } from '../../utils/validate-each.util.js';
|
|
8
5
|
/**
|
|
9
6
|
* Decorator that binds pipes to the scope of the controller or method,
|
|
10
7
|
* depending on its context.
|
|
@@ -26,16 +23,16 @@ const validate_each_util_1 = require("../../utils/validate-each.util");
|
|
|
26
23
|
*
|
|
27
24
|
* @publicApi
|
|
28
25
|
*/
|
|
29
|
-
function UsePipes(...pipes) {
|
|
26
|
+
export function UsePipes(...pipes) {
|
|
30
27
|
return (target, key, descriptor) => {
|
|
31
|
-
const isPipeValid = (pipe) => pipe && (
|
|
28
|
+
const isPipeValid = (pipe) => pipe && (isFunction(pipe) || isFunction(pipe.transform));
|
|
32
29
|
if (descriptor) {
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
validateEach(target.constructor, pipes, isPipeValid, '@UsePipes', 'pipe');
|
|
31
|
+
extendArrayMetadata(PIPES_METADATA, pipes, descriptor.value);
|
|
35
32
|
return descriptor;
|
|
36
33
|
}
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
validateEach(target, pipes, isPipeValid, '@UsePipes', 'pipe');
|
|
35
|
+
extendArrayMetadata(PIPES_METADATA, pipes, target);
|
|
39
36
|
return target;
|
|
40
37
|
};
|
|
41
38
|
}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Version = Version;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
1
|
+
import { VERSION_METADATA } from '../../constants.js';
|
|
5
2
|
/**
|
|
6
3
|
* Sets the version of the endpoint to the passed version
|
|
7
4
|
*
|
|
8
5
|
* @publicApi
|
|
9
6
|
*/
|
|
10
|
-
function Version(version) {
|
|
7
|
+
export function Version(version) {
|
|
11
8
|
if (Array.isArray(version)) {
|
|
12
9
|
// Drop duplicated versions
|
|
13
10
|
version = Array.from(new Set(version));
|
|
14
11
|
}
|
|
15
12
|
return (target, key, descriptor) => {
|
|
16
|
-
Reflect.defineMetadata(
|
|
13
|
+
Reflect.defineMetadata(VERSION_METADATA, version, descriptor.value);
|
|
17
14
|
return descriptor;
|
|
18
15
|
};
|
|
19
16
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { PipeTransform } from '../../index';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { PipeTransform } from '../../index.js';
|
|
2
|
+
import { CustomParamFactory } from '../../interfaces/features/custom-route-param-factory.interface.js';
|
|
3
|
+
import { Type } from '../../interfaces/index.js';
|
|
4
|
+
import { ParameterDecoratorOptions } from './route-params.decorator.js';
|
|
4
5
|
export type ParamDecoratorEnhancer = ParameterDecorator;
|
|
5
6
|
/**
|
|
6
|
-
* Defines
|
|
7
|
+
* Defines route param decorator
|
|
7
8
|
*
|
|
8
9
|
* @param factory
|
|
9
10
|
* @param enhancers
|
|
10
11
|
*
|
|
11
12
|
* @publicApi
|
|
12
13
|
*/
|
|
13
|
-
export declare function createParamDecorator<FactoryData = any, FactoryOutput = any>(factory: CustomParamFactory<FactoryData, FactoryOutput>, enhancers?: ParamDecoratorEnhancer[]): (...dataOrPipes: (Type<PipeTransform> | PipeTransform | FactoryData)[]) => ParameterDecorator;
|
|
14
|
+
export declare function createParamDecorator<FactoryData = any, FactoryOutput = any>(factory: CustomParamFactory<FactoryData, FactoryOutput>, enhancers?: ParamDecoratorEnhancer[]): (...dataOrPipes: (Type<PipeTransform> | PipeTransform | FactoryData | ParameterDecoratorOptions)[]) => ParameterDecorator;
|
|
@@ -1,32 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const assign_custom_metadata_util_1 = require("../../utils/assign-custom-metadata.util");
|
|
7
|
-
const shared_utils_1 = require("../../utils/shared.utils");
|
|
1
|
+
import { uid } from 'uid';
|
|
2
|
+
import { ROUTE_ARGS_METADATA } from '../../constants.js';
|
|
3
|
+
import { assignCustomParameterMetadata } from '../../utils/assign-custom-metadata.util.js';
|
|
4
|
+
import { isFunction, isNil } from '../../utils/shared.utils.js';
|
|
5
|
+
import { isParameterDecoratorOptions } from '../../utils/parameter-decorator-options.util.js';
|
|
8
6
|
/**
|
|
9
|
-
* Defines
|
|
7
|
+
* Defines route param decorator
|
|
10
8
|
*
|
|
11
9
|
* @param factory
|
|
12
10
|
* @param enhancers
|
|
13
11
|
*
|
|
14
12
|
* @publicApi
|
|
15
13
|
*/
|
|
16
|
-
function createParamDecorator(factory, enhancers = []) {
|
|
17
|
-
const paramtype =
|
|
14
|
+
export function createParamDecorator(factory, enhancers = []) {
|
|
15
|
+
const paramtype = uid(21);
|
|
18
16
|
return (data, ...pipes) => (target, key, index) => {
|
|
19
|
-
const args = Reflect.getMetadata(
|
|
17
|
+
const args = Reflect.getMetadata(ROUTE_ARGS_METADATA, target.constructor, key) ||
|
|
20
18
|
{};
|
|
21
19
|
const isPipe = (pipe) => pipe &&
|
|
22
|
-
((
|
|
20
|
+
((isFunction(pipe) &&
|
|
23
21
|
pipe.prototype &&
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const hasParamData =
|
|
22
|
+
isFunction(pipe.prototype.transform)) ||
|
|
23
|
+
isFunction(pipe.transform));
|
|
24
|
+
const hasParamData = isNil(data) || !isPipe(data);
|
|
27
25
|
const paramData = hasParamData ? data : undefined;
|
|
28
26
|
const paramPipes = hasParamData ? pipes : [data, ...pipes];
|
|
29
|
-
|
|
27
|
+
// Check if data itself is an options object (when used as the first argument)
|
|
28
|
+
const isDataOptions = hasParamData && !isNil(data) && isParameterDecoratorOptions(data);
|
|
29
|
+
// Check if the last pipe argument is actually an options object
|
|
30
|
+
const lastPipeArg = paramPipes.length > 0 ? paramPipes[paramPipes.length - 1] : undefined;
|
|
31
|
+
const isLastPipeOptions = !isDataOptions && isParameterDecoratorOptions(lastPipeArg);
|
|
32
|
+
let finalData;
|
|
33
|
+
let finalSchema;
|
|
34
|
+
let finalPipes;
|
|
35
|
+
if (isDataOptions) {
|
|
36
|
+
const opts = data;
|
|
37
|
+
finalData = undefined;
|
|
38
|
+
finalSchema = opts.schema;
|
|
39
|
+
// Merge positional pipes passed after the options object
|
|
40
|
+
finalPipes = [...(opts.pipes ?? []), ...paramPipes];
|
|
41
|
+
}
|
|
42
|
+
else if (isLastPipeOptions) {
|
|
43
|
+
const opts = lastPipeArg;
|
|
44
|
+
finalData = paramData;
|
|
45
|
+
finalSchema = opts.schema;
|
|
46
|
+
finalPipes = [
|
|
47
|
+
...paramPipes.slice(0, -1),
|
|
48
|
+
...(opts.pipes ?? []),
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
finalData = paramData;
|
|
53
|
+
finalSchema = undefined;
|
|
54
|
+
finalPipes = paramPipes;
|
|
55
|
+
}
|
|
56
|
+
Reflect.defineMetadata(ROUTE_ARGS_METADATA, assignCustomParameterMetadata(args, paramtype, index, factory, finalData, finalSchema, ...finalPipes), target.constructor, key);
|
|
30
57
|
enhancers.forEach(fn => fn(target, key, index));
|
|
31
58
|
};
|
|
32
59
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Header = Header;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
|
|
1
|
+
import { HEADERS_METADATA } from '../../constants.js';
|
|
2
|
+
import { extendArrayMetadata } from '../../utils/extend-metadata.util.js';
|
|
6
3
|
/**
|
|
7
4
|
* Request method Decorator. Sets a response header.
|
|
8
5
|
*
|
|
@@ -17,9 +14,9 @@ const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
|
|
|
17
14
|
*
|
|
18
15
|
* @publicApi
|
|
19
16
|
*/
|
|
20
|
-
function Header(name, value) {
|
|
17
|
+
export function Header(name, value) {
|
|
21
18
|
return (target, key, descriptor) => {
|
|
22
|
-
|
|
19
|
+
extendArrayMetadata(HEADERS_METADATA, [{ name, value }], descriptor.value);
|
|
23
20
|
return descriptor;
|
|
24
21
|
};
|
|
25
22
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpCode = HttpCode;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
1
|
+
import { HTTP_CODE_METADATA } from '../../constants.js';
|
|
5
2
|
/**
|
|
6
3
|
* Request method Decorator. Defines the HTTP response status code. Overrides
|
|
7
4
|
* default status code for the decorated request method.
|
|
@@ -12,9 +9,9 @@ const constants_1 = require("../../constants");
|
|
|
12
9
|
*
|
|
13
10
|
* @publicApi
|
|
14
11
|
*/
|
|
15
|
-
function HttpCode(statusCode) {
|
|
12
|
+
export function HttpCode(statusCode) {
|
|
16
13
|
return (target, key, descriptor) => {
|
|
17
|
-
Reflect.defineMetadata(
|
|
14
|
+
Reflect.defineMetadata(HTTP_CODE_METADATA, statusCode, descriptor.value);
|
|
18
15
|
return descriptor;
|
|
19
16
|
};
|
|
20
17
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './request-mapping.decorator';
|
|
2
|
-
export * from './route-params.decorator';
|
|
3
|
-
export * from './http-code.decorator';
|
|
4
|
-
export * from './create-route-param-metadata.decorator';
|
|
5
|
-
export * from './render.decorator';
|
|
6
|
-
export * from './header.decorator';
|
|
7
|
-
export * from './redirect.decorator';
|
|
8
|
-
export * from './sse.decorator';
|
|
9
|
-
export * from './sse-signal.decorator';
|
|
1
|
+
export * from './request-mapping.decorator.js';
|
|
2
|
+
export * from './route-params.decorator.js';
|
|
3
|
+
export * from './http-code.decorator.js';
|
|
4
|
+
export * from './create-route-param-metadata.decorator.js';
|
|
5
|
+
export * from './render.decorator.js';
|
|
6
|
+
export * from './header.decorator.js';
|
|
7
|
+
export * from './redirect.decorator.js';
|
|
8
|
+
export * from './sse.decorator.js';
|
|
9
|
+
export * from './sse-signal.decorator.js';
|
package/decorators/http/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
tslib_1.__exportStar(require("./redirect.decorator"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./sse.decorator"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./sse-signal.decorator"), exports);
|
|
1
|
+
export * from './request-mapping.decorator.js';
|
|
2
|
+
export * from './route-params.decorator.js';
|
|
3
|
+
export * from './http-code.decorator.js';
|
|
4
|
+
export * from './create-route-param-metadata.decorator.js';
|
|
5
|
+
export * from './render.decorator.js';
|
|
6
|
+
export * from './header.decorator.js';
|
|
7
|
+
export * from './redirect.decorator.js';
|
|
8
|
+
export * from './sse.decorator.js';
|
|
9
|
+
export * from './sse-signal.decorator.js';
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Redirect = Redirect;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
1
|
+
import { REDIRECT_METADATA } from '../../constants.js';
|
|
5
2
|
/**
|
|
6
3
|
* Redirects request to the specified URL.
|
|
7
4
|
*
|
|
8
5
|
* @publicApi
|
|
9
6
|
*/
|
|
10
|
-
function Redirect(url = '', statusCode) {
|
|
7
|
+
export function Redirect(url = '', statusCode) {
|
|
11
8
|
return (target, key, descriptor) => {
|
|
12
|
-
Reflect.defineMetadata(
|
|
9
|
+
Reflect.defineMetadata(REDIRECT_METADATA, { statusCode, url }, descriptor.value);
|
|
13
10
|
return descriptor;
|
|
14
11
|
};
|
|
15
12
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Render = Render;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
1
|
+
import { RENDER_METADATA } from '../../constants.js';
|
|
5
2
|
/**
|
|
6
3
|
* Route handler method Decorator. Defines a template to be rendered by the controller.
|
|
7
4
|
*
|
|
@@ -13,9 +10,9 @@ const constants_1 = require("../../constants");
|
|
|
13
10
|
*
|
|
14
11
|
* @publicApi
|
|
15
12
|
*/
|
|
16
|
-
function Render(template) {
|
|
13
|
+
export function Render(template) {
|
|
17
14
|
return (target, key, descriptor) => {
|
|
18
|
-
Reflect.defineMetadata(
|
|
15
|
+
Reflect.defineMetadata(RENDER_METADATA, template, descriptor.value);
|
|
19
16
|
return descriptor;
|
|
20
17
|
};
|
|
21
18
|
}
|
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Unlock = exports.Lock = exports.Move = exports.Copy = exports.Mkcol = exports.Proppatch = exports.Propfind = exports.QueryMethod = exports.Search = exports.All = exports.Head = exports.Options = exports.Patch = exports.Put = exports.Delete = exports.Get = exports.Post = exports.RequestMapping = void 0;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
const request_method_enum_1 = require("../../enums/request-method.enum");
|
|
1
|
+
import { METHOD_METADATA, PATH_METADATA } from '../../constants.js';
|
|
2
|
+
import { RequestMethod } from '../../enums/request-method.enum.js';
|
|
6
3
|
const defaultMetadata = {
|
|
7
|
-
[
|
|
8
|
-
[
|
|
4
|
+
[PATH_METADATA]: '/',
|
|
5
|
+
[METHOD_METADATA]: RequestMethod.GET,
|
|
9
6
|
};
|
|
10
|
-
const RequestMapping = (metadata = defaultMetadata) => {
|
|
11
|
-
const pathMetadata = metadata[
|
|
7
|
+
export const RequestMapping = (metadata = defaultMetadata) => {
|
|
8
|
+
const pathMetadata = metadata[PATH_METADATA];
|
|
12
9
|
const path = pathMetadata && pathMetadata.length ? pathMetadata : '/';
|
|
13
|
-
const requestMethod = metadata[
|
|
10
|
+
const requestMethod = metadata[METHOD_METADATA] || RequestMethod.GET;
|
|
14
11
|
return (target, key, descriptor) => {
|
|
15
|
-
Reflect.defineMetadata(
|
|
16
|
-
Reflect.defineMetadata(
|
|
12
|
+
Reflect.defineMetadata(PATH_METADATA, path, descriptor.value);
|
|
13
|
+
Reflect.defineMetadata(METHOD_METADATA, requestMethod, descriptor.value);
|
|
17
14
|
return descriptor;
|
|
18
15
|
};
|
|
19
16
|
};
|
|
20
|
-
exports.RequestMapping = RequestMapping;
|
|
21
17
|
const createMappingDecorator = (method) => (path) => {
|
|
22
|
-
return
|
|
23
|
-
[
|
|
24
|
-
[
|
|
18
|
+
return RequestMapping({
|
|
19
|
+
[PATH_METADATA]: path,
|
|
20
|
+
[METHOD_METADATA]: method,
|
|
25
21
|
});
|
|
26
22
|
};
|
|
27
23
|
/**
|
|
@@ -31,7 +27,7 @@ const createMappingDecorator = (method) => (path) => {
|
|
|
31
27
|
*
|
|
32
28
|
* @publicApi
|
|
33
29
|
*/
|
|
34
|
-
|
|
30
|
+
export const Post = createMappingDecorator(RequestMethod.POST);
|
|
35
31
|
/**
|
|
36
32
|
* Route handler (method) Decorator. Routes HTTP GET requests to the specified path.
|
|
37
33
|
*
|
|
@@ -39,7 +35,7 @@ exports.Post = createMappingDecorator(request_method_enum_1.RequestMethod.POST);
|
|
|
39
35
|
*
|
|
40
36
|
* @publicApi
|
|
41
37
|
*/
|
|
42
|
-
|
|
38
|
+
export const Get = createMappingDecorator(RequestMethod.GET);
|
|
43
39
|
/**
|
|
44
40
|
* Route handler (method) Decorator. Routes HTTP DELETE requests to the specified path.
|
|
45
41
|
*
|
|
@@ -47,7 +43,7 @@ exports.Get = createMappingDecorator(request_method_enum_1.RequestMethod.GET);
|
|
|
47
43
|
*
|
|
48
44
|
* @publicApi
|
|
49
45
|
*/
|
|
50
|
-
|
|
46
|
+
export const Delete = createMappingDecorator(RequestMethod.DELETE);
|
|
51
47
|
/**
|
|
52
48
|
* Route handler (method) Decorator. Routes HTTP PUT requests to the specified path.
|
|
53
49
|
*
|
|
@@ -55,7 +51,7 @@ exports.Delete = createMappingDecorator(request_method_enum_1.RequestMethod.DELE
|
|
|
55
51
|
*
|
|
56
52
|
* @publicApi
|
|
57
53
|
*/
|
|
58
|
-
|
|
54
|
+
export const Put = createMappingDecorator(RequestMethod.PUT);
|
|
59
55
|
/**
|
|
60
56
|
* Route handler (method) Decorator. Routes HTTP PATCH requests to the specified path.
|
|
61
57
|
*
|
|
@@ -63,7 +59,7 @@ exports.Put = createMappingDecorator(request_method_enum_1.RequestMethod.PUT);
|
|
|
63
59
|
*
|
|
64
60
|
* @publicApi
|
|
65
61
|
*/
|
|
66
|
-
|
|
62
|
+
export const Patch = createMappingDecorator(RequestMethod.PATCH);
|
|
67
63
|
/**
|
|
68
64
|
* Route handler (method) Decorator. Routes HTTP OPTIONS requests to the specified path.
|
|
69
65
|
*
|
|
@@ -71,7 +67,7 @@ exports.Patch = createMappingDecorator(request_method_enum_1.RequestMethod.PATCH
|
|
|
71
67
|
*
|
|
72
68
|
* @publicApi
|
|
73
69
|
*/
|
|
74
|
-
|
|
70
|
+
export const Options = createMappingDecorator(RequestMethod.OPTIONS);
|
|
75
71
|
/**
|
|
76
72
|
* Route handler (method) Decorator. Routes HTTP HEAD requests to the specified path.
|
|
77
73
|
*
|
|
@@ -79,7 +75,7 @@ exports.Options = createMappingDecorator(request_method_enum_1.RequestMethod.OPT
|
|
|
79
75
|
*
|
|
80
76
|
* @publicApi
|
|
81
77
|
*/
|
|
82
|
-
|
|
78
|
+
export const Head = createMappingDecorator(RequestMethod.HEAD);
|
|
83
79
|
/**
|
|
84
80
|
* Route handler (method) Decorator. Routes all HTTP requests to the specified path.
|
|
85
81
|
*
|
|
@@ -87,7 +83,7 @@ exports.Head = createMappingDecorator(request_method_enum_1.RequestMethod.HEAD);
|
|
|
87
83
|
*
|
|
88
84
|
* @publicApi
|
|
89
85
|
*/
|
|
90
|
-
|
|
86
|
+
export const All = createMappingDecorator(RequestMethod.ALL);
|
|
91
87
|
/**
|
|
92
88
|
* Route handler (method) Decorator. Routes HTTP SEARCH requests to the specified path.
|
|
93
89
|
*
|
|
@@ -95,7 +91,7 @@ exports.All = createMappingDecorator(request_method_enum_1.RequestMethod.ALL);
|
|
|
95
91
|
*
|
|
96
92
|
* @publicApi
|
|
97
93
|
*/
|
|
98
|
-
|
|
94
|
+
export const Search = createMappingDecorator(RequestMethod.SEARCH);
|
|
99
95
|
/**
|
|
100
96
|
* Route handler (method) Decorator. Routes HTTP QUERY requests to the specified path.
|
|
101
97
|
*
|
|
@@ -106,7 +102,7 @@ exports.Search = createMappingDecorator(request_method_enum_1.RequestMethod.SEAR
|
|
|
106
102
|
*
|
|
107
103
|
* @publicApi
|
|
108
104
|
*/
|
|
109
|
-
|
|
105
|
+
export const QueryMethod = createMappingDecorator(RequestMethod.QUERY);
|
|
110
106
|
/**
|
|
111
107
|
* Route handler (method) Decorator. Routes Webdav PROPFIND requests to the specified path.
|
|
112
108
|
*
|
|
@@ -114,7 +110,7 @@ exports.QueryMethod = createMappingDecorator(request_method_enum_1.RequestMethod
|
|
|
114
110
|
*
|
|
115
111
|
* @publicApi
|
|
116
112
|
*/
|
|
117
|
-
|
|
113
|
+
export const Propfind = createMappingDecorator(RequestMethod.PROPFIND);
|
|
118
114
|
/**
|
|
119
115
|
* Route handler (method) Decorator. Routes Webdav PROPPATCH requests to the specified path.
|
|
120
116
|
*
|
|
@@ -122,7 +118,7 @@ exports.Propfind = createMappingDecorator(request_method_enum_1.RequestMethod.PR
|
|
|
122
118
|
*
|
|
123
119
|
* @publicApi
|
|
124
120
|
*/
|
|
125
|
-
|
|
121
|
+
export const Proppatch = createMappingDecorator(RequestMethod.PROPPATCH);
|
|
126
122
|
/**
|
|
127
123
|
* Route handler (method) Decorator. Routes Webdav MKCOL requests to the specified path.
|
|
128
124
|
*
|
|
@@ -130,7 +126,7 @@ exports.Proppatch = createMappingDecorator(request_method_enum_1.RequestMethod.P
|
|
|
130
126
|
*
|
|
131
127
|
* @publicApi
|
|
132
128
|
*/
|
|
133
|
-
|
|
129
|
+
export const Mkcol = createMappingDecorator(RequestMethod.MKCOL);
|
|
134
130
|
/**
|
|
135
131
|
* Route handler (method) Decorator. Routes Webdav COPY requests to the specified path.
|
|
136
132
|
*
|
|
@@ -138,7 +134,7 @@ exports.Mkcol = createMappingDecorator(request_method_enum_1.RequestMethod.MKCOL
|
|
|
138
134
|
*
|
|
139
135
|
* @publicApi
|
|
140
136
|
*/
|
|
141
|
-
|
|
137
|
+
export const Copy = createMappingDecorator(RequestMethod.COPY);
|
|
142
138
|
/**
|
|
143
139
|
* Route handler (method) Decorator. Routes Webdav MOVE requests to the specified path.
|
|
144
140
|
*
|
|
@@ -146,7 +142,7 @@ exports.Copy = createMappingDecorator(request_method_enum_1.RequestMethod.COPY);
|
|
|
146
142
|
*
|
|
147
143
|
* @publicApi
|
|
148
144
|
*/
|
|
149
|
-
|
|
145
|
+
export const Move = createMappingDecorator(RequestMethod.MOVE);
|
|
150
146
|
/**
|
|
151
147
|
* Route handler (method) Decorator. Routes Webdav LOCK requests to the specified path.
|
|
152
148
|
*
|
|
@@ -154,7 +150,7 @@ exports.Move = createMappingDecorator(request_method_enum_1.RequestMethod.MOVE);
|
|
|
154
150
|
*
|
|
155
151
|
* @publicApi
|
|
156
152
|
*/
|
|
157
|
-
|
|
153
|
+
export const Lock = createMappingDecorator(RequestMethod.LOCK);
|
|
158
154
|
/**
|
|
159
155
|
* Route handler (method) Decorator. Routes Webdav UNLOCK requests to the specified path.
|
|
160
156
|
*
|
|
@@ -162,4 +158,4 @@ exports.Lock = createMappingDecorator(request_method_enum_1.RequestMethod.LOCK);
|
|
|
162
158
|
*
|
|
163
159
|
* @publicApi
|
|
164
160
|
*/
|
|
165
|
-
|
|
161
|
+
export const Unlock = createMappingDecorator(RequestMethod.UNLOCK);
|