@depup/nestjs__common 11.1.16-depup.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/LICENSE +22 -0
- package/PACKAGE.md +1 -0
- package/Readme.md +31 -0
- package/changes.json +10 -0
- package/constants.d.ts +42 -0
- package/constants.js +44 -0
- package/decorators/core/apply-decorators.d.ts +10 -0
- package/decorators/core/apply-decorators.js +23 -0
- package/decorators/core/bind.decorator.d.ts +11 -0
- package/decorators/core/bind.decorator.js +19 -0
- package/decorators/core/catch.decorator.d.ts +19 -0
- package/decorators/core/catch.decorator.js +27 -0
- package/decorators/core/controller.decorator.d.ts +102 -0
- package/decorators/core/controller.decorator.js +61 -0
- package/decorators/core/dependencies.decorator.d.ts +7 -0
- package/decorators/core/dependencies.decorator.js +23 -0
- package/decorators/core/exception-filters.decorator.d.ts +23 -0
- package/decorators/core/exception-filters.decorator.js +43 -0
- package/decorators/core/index.d.ts +14 -0
- package/decorators/core/index.js +17 -0
- package/decorators/core/inject.decorator.d.ts +31 -0
- package/decorators/core/inject.decorator.js +53 -0
- package/decorators/core/injectable.decorator.d.ts +43 -0
- package/decorators/core/injectable.decorator.js +50 -0
- package/decorators/core/optional.decorator.d.ts +14 -0
- package/decorators/core/optional.decorator.js +29 -0
- package/decorators/core/set-metadata.decorator.d.ts +20 -0
- package/decorators/core/set-metadata.decorator.js +32 -0
- package/decorators/core/use-guards.decorator.d.ts +23 -0
- package/decorators/core/use-guards.decorator.js +41 -0
- package/decorators/core/use-interceptors.decorator.d.ts +23 -0
- package/decorators/core/use-interceptors.decorator.js +42 -0
- package/decorators/core/use-pipes.decorator.d.ts +23 -0
- package/decorators/core/use-pipes.decorator.js +40 -0
- package/decorators/core/version.decorator.d.ts +7 -0
- package/decorators/core/version.decorator.js +19 -0
- package/decorators/http/create-route-param-metadata.decorator.d.ts +13 -0
- package/decorators/http/create-route-param-metadata.decorator.js +32 -0
- package/decorators/http/header.decorator.d.ts +15 -0
- package/decorators/http/header.decorator.js +25 -0
- package/decorators/http/http-code.decorator.d.ts +11 -0
- package/decorators/http/http-code.decorator.js +20 -0
- package/decorators/http/index.d.ts +8 -0
- package/decorators/http/index.js +11 -0
- package/decorators/http/redirect.decorator.d.ts +6 -0
- package/decorators/http/redirect.decorator.js +15 -0
- package/decorators/http/render.decorator.d.ts +12 -0
- package/decorators/http/render.decorator.js +21 -0
- package/decorators/http/request-mapping.decorator.d.ts +134 -0
- package/decorators/http/request-mapping.decorator.js +154 -0
- package/decorators/http/route-params.decorator.d.ts +445 -0
- package/decorators/http/route-params.decorator.js +265 -0
- package/decorators/http/sse.decorator.d.ts +10 -0
- package/decorators/http/sse.decorator.js +21 -0
- package/decorators/index.d.ts +3 -0
- package/decorators/index.js +6 -0
- package/decorators/modules/global.decorator.d.ts +12 -0
- package/decorators/modules/global.decorator.js +20 -0
- package/decorators/modules/index.d.ts +2 -0
- package/decorators/modules/index.js +5 -0
- package/decorators/modules/module.decorator.d.ts +16 -0
- package/decorators/modules/module.decorator.js +29 -0
- package/enums/http-status.enum.d.ts +60 -0
- package/enums/http-status.enum.js +64 -0
- package/enums/index.d.ts +4 -0
- package/enums/index.js +7 -0
- package/enums/request-method.enum.d.ts +18 -0
- package/enums/request-method.enum.js +22 -0
- package/enums/route-paramtypes.enum.d.ts +16 -0
- package/enums/route-paramtypes.enum.js +20 -0
- package/enums/shutdown-signal.enum.d.ts +16 -0
- package/enums/shutdown-signal.enum.js +20 -0
- package/enums/version-type.enum.d.ts +9 -0
- package/enums/version-type.enum.js +13 -0
- package/exceptions/bad-gateway.exception.d.ts +35 -0
- package/exceptions/bad-gateway.exception.js +43 -0
- package/exceptions/bad-request.exception.d.ts +35 -0
- package/exceptions/bad-request.exception.js +43 -0
- package/exceptions/conflict.exception.d.ts +35 -0
- package/exceptions/conflict.exception.js +43 -0
- package/exceptions/forbidden.exception.d.ts +35 -0
- package/exceptions/forbidden.exception.js +43 -0
- package/exceptions/gateway-timeout.exception.d.ts +35 -0
- package/exceptions/gateway-timeout.exception.js +43 -0
- package/exceptions/gone.exception.d.ts +35 -0
- package/exceptions/gone.exception.js +43 -0
- package/exceptions/http-version-not-supported.exception.d.ts +35 -0
- package/exceptions/http-version-not-supported.exception.js +43 -0
- package/exceptions/http.exception.d.ts +85 -0
- package/exceptions/http.exception.js +133 -0
- package/exceptions/im-a-teapot.exception.d.ts +38 -0
- package/exceptions/im-a-teapot.exception.js +46 -0
- package/exceptions/index.d.ts +23 -0
- package/exceptions/index.js +26 -0
- package/exceptions/internal-server-error.exception.d.ts +35 -0
- package/exceptions/internal-server-error.exception.js +43 -0
- package/exceptions/intrinsic.exception.d.ts +8 -0
- package/exceptions/intrinsic.exception.js +12 -0
- package/exceptions/method-not-allowed.exception.d.ts +35 -0
- package/exceptions/method-not-allowed.exception.js +43 -0
- package/exceptions/misdirected.exception.d.ts +35 -0
- package/exceptions/misdirected.exception.js +43 -0
- package/exceptions/not-acceptable.exception.d.ts +35 -0
- package/exceptions/not-acceptable.exception.js +43 -0
- package/exceptions/not-found.exception.d.ts +35 -0
- package/exceptions/not-found.exception.js +43 -0
- package/exceptions/not-implemented.exception.d.ts +35 -0
- package/exceptions/not-implemented.exception.js +43 -0
- package/exceptions/payload-too-large.exception.d.ts +35 -0
- package/exceptions/payload-too-large.exception.js +43 -0
- package/exceptions/precondition-failed.exception.d.ts +35 -0
- package/exceptions/precondition-failed.exception.js +43 -0
- package/exceptions/request-timeout.exception.d.ts +35 -0
- package/exceptions/request-timeout.exception.js +43 -0
- package/exceptions/service-unavailable.exception.d.ts +35 -0
- package/exceptions/service-unavailable.exception.js +43 -0
- package/exceptions/unauthorized.exception.d.ts +35 -0
- package/exceptions/unauthorized.exception.js +43 -0
- package/exceptions/unprocessable-entity.exception.d.ts +35 -0
- package/exceptions/unprocessable-entity.exception.js +43 -0
- package/exceptions/unsupported-media-type.exception.d.ts +35 -0
- package/exceptions/unsupported-media-type.exception.js +43 -0
- package/file-stream/index.d.ts +1 -0
- package/file-stream/index.js +4 -0
- package/file-stream/interfaces/index.d.ts +2 -0
- package/file-stream/interfaces/index.js +5 -0
- package/file-stream/interfaces/streamable-handler-response.interface.d.ts +12 -0
- package/file-stream/interfaces/streamable-handler-response.interface.js +2 -0
- package/file-stream/interfaces/streamable-options.interface.d.ts +22 -0
- package/file-stream/interfaces/streamable-options.interface.js +2 -0
- package/file-stream/streamable-file.d.ts +27 -0
- package/file-stream/streamable-file.js +68 -0
- package/index.d.ts +11 -0
- package/index.js +23 -0
- package/interfaces/abstract.interface.d.ts +3 -0
- package/interfaces/abstract.interface.js +2 -0
- package/interfaces/controllers/controller-metadata.interface.d.ts +3 -0
- package/interfaces/controllers/controller-metadata.interface.js +2 -0
- package/interfaces/controllers/controller.interface.d.ts +1 -0
- package/interfaces/controllers/controller.interface.js +2 -0
- package/interfaces/controllers/index.d.ts +2 -0
- package/interfaces/controllers/index.js +5 -0
- package/interfaces/exceptions/exception-filter-metadata.interface.d.ts +6 -0
- package/interfaces/exceptions/exception-filter-metadata.interface.js +2 -0
- package/interfaces/exceptions/exception-filter.interface.d.ts +18 -0
- package/interfaces/exceptions/exception-filter.interface.js +2 -0
- package/interfaces/exceptions/index.d.ts +5 -0
- package/interfaces/exceptions/index.js +8 -0
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.d.ts +6 -0
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.js +2 -0
- package/interfaces/exceptions/rpc-exception-filter.interface.d.ts +19 -0
- package/interfaces/exceptions/rpc-exception-filter.interface.js +2 -0
- package/interfaces/exceptions/ws-exception-filter.interface.d.ts +18 -0
- package/interfaces/exceptions/ws-exception-filter.interface.js +2 -0
- package/interfaces/external/class-transform-options.interface.d.ts +65 -0
- package/interfaces/external/class-transform-options.interface.js +2 -0
- package/interfaces/external/cors-options.interface.d.ts +58 -0
- package/interfaces/external/cors-options.interface.js +2 -0
- package/interfaces/external/https-options.interface.d.ts +105 -0
- package/interfaces/external/https-options.interface.js +2 -0
- package/interfaces/external/transformer-package.interface.d.ts +6 -0
- package/interfaces/external/transformer-package.interface.js +2 -0
- package/interfaces/external/validation-error.interface.d.ts +42 -0
- package/interfaces/external/validation-error.interface.js +2 -0
- package/interfaces/external/validator-options.interface.d.ts +76 -0
- package/interfaces/external/validator-options.interface.js +2 -0
- package/interfaces/external/validator-package.interface.d.ts +5 -0
- package/interfaces/external/validator-package.interface.js +2 -0
- package/interfaces/features/arguments-host.interface.d.ts +88 -0
- package/interfaces/features/arguments-host.interface.js +2 -0
- package/interfaces/features/can-activate.interface.d.ts +22 -0
- package/interfaces/features/can-activate.interface.js +2 -0
- package/interfaces/features/custom-route-param-factory.interface.d.ts +5 -0
- package/interfaces/features/custom-route-param-factory.interface.js +2 -0
- package/interfaces/features/execution-context.interface.d.ts +20 -0
- package/interfaces/features/execution-context.interface.js +2 -0
- package/interfaces/features/nest-interceptor.interface.d.ts +34 -0
- package/interfaces/features/nest-interceptor.interface.js +2 -0
- package/interfaces/features/paramtype.interface.d.ts +4 -0
- package/interfaces/features/paramtype.interface.js +2 -0
- package/interfaces/features/pipe-transform.interface.d.ts +42 -0
- package/interfaces/features/pipe-transform.interface.js +2 -0
- package/interfaces/global-prefix-options.interface.d.ts +7 -0
- package/interfaces/global-prefix-options.interface.js +2 -0
- package/interfaces/hooks/before-application-shutdown.interface.d.ts +3 -0
- package/interfaces/hooks/before-application-shutdown.interface.js +2 -0
- package/interfaces/hooks/index.d.ts +5 -0
- package/interfaces/hooks/index.js +8 -0
- package/interfaces/hooks/on-application-bootstrap.interface.d.ts +11 -0
- package/interfaces/hooks/on-application-bootstrap.interface.js +2 -0
- package/interfaces/hooks/on-application-shutdown.interface.d.ts +11 -0
- package/interfaces/hooks/on-application-shutdown.interface.js +2 -0
- package/interfaces/hooks/on-destroy.interface.d.ts +12 -0
- package/interfaces/hooks/on-destroy.interface.js +2 -0
- package/interfaces/hooks/on-init.interface.d.ts +10 -0
- package/interfaces/hooks/on-init.interface.js +2 -0
- package/interfaces/http/http-exception-body.interface.d.ts +6 -0
- package/interfaces/http/http-exception-body.interface.js +2 -0
- package/interfaces/http/http-redirect-response.interface.d.ts +5 -0
- package/interfaces/http/http-redirect-response.interface.js +2 -0
- package/interfaces/http/http-server.interface.d.ts +70 -0
- package/interfaces/http/http-server.interface.js +2 -0
- package/interfaces/http/index.d.ts +5 -0
- package/interfaces/http/index.js +8 -0
- package/interfaces/http/message-event.interface.d.ts +6 -0
- package/interfaces/http/message-event.interface.js +2 -0
- package/interfaces/http/raw-body-request.interface.d.ts +6 -0
- package/interfaces/http/raw-body-request.interface.js +2 -0
- package/interfaces/index.d.ts +30 -0
- package/interfaces/index.js +33 -0
- package/interfaces/injectable.interface.d.ts +1 -0
- package/interfaces/injectable.interface.js +2 -0
- package/interfaces/microservices/nest-hybrid-application-options.interface.d.ts +7 -0
- package/interfaces/microservices/nest-hybrid-application-options.interface.js +2 -0
- package/interfaces/microservices/nest-microservice-options.interface.d.ts +5 -0
- package/interfaces/microservices/nest-microservice-options.interface.js +2 -0
- package/interfaces/middleware/index.d.ts +4 -0
- package/interfaces/middleware/index.js +7 -0
- package/interfaces/middleware/middleware-config-proxy.interface.d.ts +24 -0
- package/interfaces/middleware/middleware-config-proxy.interface.js +2 -0
- package/interfaces/middleware/middleware-configuration.interface.d.ts +12 -0
- package/interfaces/middleware/middleware-configuration.interface.js +2 -0
- package/interfaces/middleware/middleware-consumer.interface.d.ts +18 -0
- package/interfaces/middleware/middleware-consumer.interface.js +2 -0
- package/interfaces/middleware/nest-middleware.interface.d.ts +8 -0
- package/interfaces/middleware/nest-middleware.interface.js +2 -0
- package/interfaces/modules/dynamic-module.interface.d.ts +25 -0
- package/interfaces/modules/dynamic-module.interface.js +2 -0
- package/interfaces/modules/forward-reference.interface.d.ts +3 -0
- package/interfaces/modules/forward-reference.interface.js +2 -0
- package/interfaces/modules/index.d.ts +8 -0
- package/interfaces/modules/index.js +11 -0
- package/interfaces/modules/injection-token.interface.d.ts +6 -0
- package/interfaces/modules/injection-token.interface.js +2 -0
- package/interfaces/modules/introspection-result.interface.d.ts +10 -0
- package/interfaces/modules/introspection-result.interface.js +2 -0
- package/interfaces/modules/module-metadata.interface.d.ts +34 -0
- package/interfaces/modules/module-metadata.interface.js +2 -0
- package/interfaces/modules/nest-module.interface.d.ts +7 -0
- package/interfaces/modules/nest-module.interface.js +2 -0
- package/interfaces/modules/optional-factory-dependency.interface.d.ts +8 -0
- package/interfaces/modules/optional-factory-dependency.interface.js +2 -0
- package/interfaces/modules/provider.interface.d.ts +156 -0
- package/interfaces/modules/provider.interface.js +2 -0
- package/interfaces/nest-application-context-options.interface.d.ts +68 -0
- package/interfaces/nest-application-context-options.interface.js +9 -0
- package/interfaces/nest-application-context.interface.d.ts +139 -0
- package/interfaces/nest-application-context.interface.js +2 -0
- package/interfaces/nest-application-options.interface.d.ts +29 -0
- package/interfaces/nest-application-options.interface.js +2 -0
- package/interfaces/nest-application.interface.d.ts +135 -0
- package/interfaces/nest-application.interface.js +2 -0
- package/interfaces/nest-microservice.interface.d.ts +75 -0
- package/interfaces/nest-microservice.interface.js +2 -0
- package/interfaces/scope-options.interface.d.ts +37 -0
- package/interfaces/scope-options.interface.js +23 -0
- package/interfaces/shutdown-hooks-options.interface.d.ts +21 -0
- package/interfaces/shutdown-hooks-options.interface.js +2 -0
- package/interfaces/type.interface.d.ts +3 -0
- package/interfaces/type.interface.js +2 -0
- package/interfaces/version-options.interface.d.ts +92 -0
- package/interfaces/version-options.interface.js +9 -0
- package/interfaces/websockets/web-socket-adapter.interface.d.ts +19 -0
- package/interfaces/websockets/web-socket-adapter.interface.js +2 -0
- package/module-utils/configurable-module.builder.d.ts +93 -0
- package/module-utils/configurable-module.builder.js +219 -0
- package/module-utils/constants.d.ts +9 -0
- package/module-utils/constants.js +19 -0
- package/module-utils/index.d.ts +2 -0
- package/module-utils/index.js +5 -0
- package/module-utils/interfaces/configurable-module-async-options.interface.d.ts +42 -0
- package/module-utils/interfaces/configurable-module-async-options.interface.js +2 -0
- package/module-utils/interfaces/configurable-module-cls.interface.d.ts +13 -0
- package/module-utils/interfaces/configurable-module-cls.interface.js +2 -0
- package/module-utils/interfaces/configurable-module-host.interface.d.ts +62 -0
- package/module-utils/interfaces/configurable-module-host.interface.js +2 -0
- package/module-utils/interfaces/index.d.ts +3 -0
- package/module-utils/interfaces/index.js +6 -0
- package/module-utils/utils/generate-options-injection-token.util.d.ts +1 -0
- package/module-utils/utils/generate-options-injection-token.util.js +8 -0
- package/module-utils/utils/get-injection-providers.util.d.ts +8 -0
- package/module-utils/utils/get-injection-providers.util.js +35 -0
- package/module-utils/utils/index.d.ts +2 -0
- package/module-utils/utils/index.js +5 -0
- package/package.json +61 -0
- package/pipes/default-value.pipe.d.ts +13 -0
- package/pipes/default-value.pipe.js +30 -0
- package/pipes/file/file-type.validator.d.ts +62 -0
- package/pipes/file/file-type.validator.js +102 -0
- package/pipes/file/file-validator-context.interface.d.ts +5 -0
- package/pipes/file/file-validator-context.interface.js +2 -0
- package/pipes/file/file-validator.interface.d.ts +21 -0
- package/pipes/file/file-validator.interface.js +15 -0
- package/pipes/file/index.d.ts +6 -0
- package/pipes/file/index.js +9 -0
- package/pipes/file/interfaces/file.interface.d.ts +5 -0
- package/pipes/file/interfaces/file.interface.js +2 -0
- package/pipes/file/interfaces/index.d.ts +1 -0
- package/pipes/file/interfaces/index.js +4 -0
- package/pipes/file/max-file-size.validator.d.ts +44 -0
- package/pipes/file/max-file-size.validator.js +37 -0
- package/pipes/file/parse-file-options.interface.d.ts +15 -0
- package/pipes/file/parse-file-options.interface.js +2 -0
- package/pipes/file/parse-file-pipe.builder.d.ts +15 -0
- package/pipes/file/parse-file-pipe.builder.js +33 -0
- package/pipes/file/parse-file.pipe.d.ts +28 -0
- package/pipes/file/parse-file.pipe.js +76 -0
- package/pipes/index.d.ts +10 -0
- package/pipes/index.js +13 -0
- package/pipes/parse-array.pipe.d.ts +52 -0
- package/pipes/parse-array.pipe.js +148 -0
- package/pipes/parse-bool.pipe.d.ts +55 -0
- package/pipes/parse-bool.pipe.js +67 -0
- package/pipes/parse-date.pipe.d.ts +37 -0
- package/pipes/parse-date.pipe.js +42 -0
- package/pipes/parse-enum.pipe.d.ts +46 -0
- package/pipes/parse-enum.pipe.js +55 -0
- package/pipes/parse-float.pipe.d.ts +49 -0
- package/pipes/parse-float.pipe.js +56 -0
- package/pipes/parse-int.pipe.d.ts +48 -0
- package/pipes/parse-int.pipe.js +57 -0
- package/pipes/parse-uuid.pipe.d.ts +49 -0
- package/pipes/parse-uuid.pipe.js +57 -0
- package/pipes/validation.pipe.d.ts +51 -0
- package/pipes/validation.pipe.js +245 -0
- package/serializer/class-serializer.constants.d.ts +1 -0
- package/serializer/class-serializer.constants.js +4 -0
- package/serializer/class-serializer.interceptor.d.ts +29 -0
- package/serializer/class-serializer.interceptor.js +77 -0
- package/serializer/class-serializer.interfaces.d.ts +8 -0
- package/serializer/class-serializer.interfaces.js +2 -0
- package/serializer/decorators/index.d.ts +1 -0
- package/serializer/decorators/index.js +4 -0
- package/serializer/decorators/serialize-options.decorator.d.ts +5 -0
- package/serializer/decorators/serialize-options.decorator.js +10 -0
- package/serializer/index.d.ts +3 -0
- package/serializer/index.js +6 -0
- package/services/console-logger.service.d.ts +202 -0
- package/services/console-logger.service.js +379 -0
- package/services/index.d.ts +3 -0
- package/services/index.js +6 -0
- package/services/logger.service.d.ts +152 -0
- package/services/logger.service.js +251 -0
- package/services/utils/filter-log-levels.util.d.ts +5 -0
- package/services/utils/filter-log-levels.util.js +23 -0
- package/services/utils/index.d.ts +3 -0
- package/services/utils/index.js +6 -0
- package/services/utils/is-log-level-enabled.util.d.ts +7 -0
- package/services/utils/is-log-level-enabled.util.js +32 -0
- package/services/utils/is-log-level.util.d.ts +5 -0
- package/services/utils/is-log-level.util.js +10 -0
- package/tsconfig.build.json +10 -0
- package/utils/assign-custom-metadata.util.d.ts +4 -0
- package/utils/assign-custom-metadata.util.js +15 -0
- package/utils/cli-colors.util.d.ts +10 -0
- package/utils/cli-colors.util.js +15 -0
- package/utils/extend-metadata.util.d.ts +1 -0
- package/utils/extend-metadata.util.js +8 -0
- package/utils/forward-ref.util.d.ts +5 -0
- package/utils/forward-ref.util.js +10 -0
- package/utils/http-error-by-code.util.d.ts +4 -0
- package/utils/http-error-by-code.util.js +26 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +4 -0
- package/utils/load-package.util.d.ts +1 -0
- package/utils/load-package.util.js +16 -0
- package/utils/merge-with-values.util.d.ts +4 -0
- package/utils/merge-with-values.util.js +18 -0
- package/utils/random-string-generator.util.d.ts +1 -0
- package/utils/random-string-generator.util.js +6 -0
- package/utils/select-exception-filter-metadata.util.d.ts +2 -0
- package/utils/select-exception-filter-metadata.util.js +6 -0
- package/utils/shared.utils.d.ts +13 -0
- package/utils/shared.utils.js +51 -0
- package/utils/validate-each.util.d.ts +8 -0
- package/utils/validate-each.util.js +25 -0
- package/utils/validate-module-keys.util.d.ts +2 -0
- package/utils/validate-module-keys.util.js +22 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
export declare const LOG_LEVELS: ["verbose", "debug", "log", "warn", "error", "fatal"];
|
|
2
|
+
/**
|
|
3
|
+
* @publicApi
|
|
4
|
+
*/
|
|
5
|
+
export type LogLevel = (typeof LOG_LEVELS)[number];
|
|
6
|
+
/**
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
export interface LoggerService {
|
|
10
|
+
/**
|
|
11
|
+
* Write a 'log' level log.
|
|
12
|
+
*/
|
|
13
|
+
log(message: any, ...optionalParams: any[]): any;
|
|
14
|
+
/**
|
|
15
|
+
* Write an 'error' level log.
|
|
16
|
+
*/
|
|
17
|
+
error(message: any, ...optionalParams: any[]): any;
|
|
18
|
+
/**
|
|
19
|
+
* Write a 'warn' level log.
|
|
20
|
+
*/
|
|
21
|
+
warn(message: any, ...optionalParams: any[]): any;
|
|
22
|
+
/**
|
|
23
|
+
* Write a 'debug' level log.
|
|
24
|
+
*/
|
|
25
|
+
debug?(message: any, ...optionalParams: any[]): any;
|
|
26
|
+
/**
|
|
27
|
+
* Write a 'verbose' level log.
|
|
28
|
+
*/
|
|
29
|
+
verbose?(message: any, ...optionalParams: any[]): any;
|
|
30
|
+
/**
|
|
31
|
+
* Write a 'fatal' level log.
|
|
32
|
+
*/
|
|
33
|
+
fatal?(message: any, ...optionalParams: any[]): any;
|
|
34
|
+
/**
|
|
35
|
+
* Set log levels.
|
|
36
|
+
* @param levels log levels
|
|
37
|
+
*/
|
|
38
|
+
setLogLevels?(levels: LogLevel[]): any;
|
|
39
|
+
}
|
|
40
|
+
interface LogBufferRecord {
|
|
41
|
+
/**
|
|
42
|
+
* Method to execute.
|
|
43
|
+
*/
|
|
44
|
+
methodRef: Function;
|
|
45
|
+
/**
|
|
46
|
+
* Arguments to pass to the method.
|
|
47
|
+
*/
|
|
48
|
+
arguments: unknown[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @publicApi
|
|
52
|
+
*/
|
|
53
|
+
export declare class Logger implements LoggerService {
|
|
54
|
+
protected context?: string | undefined;
|
|
55
|
+
protected options: {
|
|
56
|
+
timestamp?: boolean;
|
|
57
|
+
};
|
|
58
|
+
protected static logBuffer: LogBufferRecord[];
|
|
59
|
+
protected static staticInstanceRef?: LoggerService;
|
|
60
|
+
protected static logLevels?: LogLevel[];
|
|
61
|
+
private static isBufferAttached;
|
|
62
|
+
protected localInstanceRef?: LoggerService;
|
|
63
|
+
private static WrapBuffer;
|
|
64
|
+
constructor();
|
|
65
|
+
constructor(context: string);
|
|
66
|
+
constructor(context: string, options?: {
|
|
67
|
+
timestamp?: boolean;
|
|
68
|
+
});
|
|
69
|
+
get localInstance(): LoggerService;
|
|
70
|
+
/**
|
|
71
|
+
* Write an 'error' level log.
|
|
72
|
+
*/
|
|
73
|
+
error(message: any, stack?: string, context?: string): void;
|
|
74
|
+
error(message: any, ...optionalParams: [...any, string?, string?]): void;
|
|
75
|
+
/**
|
|
76
|
+
* Write a 'log' level log.
|
|
77
|
+
*/
|
|
78
|
+
log(message: any, context?: string): void;
|
|
79
|
+
log(message: any, ...optionalParams: [...any, string?]): void;
|
|
80
|
+
/**
|
|
81
|
+
* Write a 'warn' level log.
|
|
82
|
+
*/
|
|
83
|
+
warn(message: any, context?: string): void;
|
|
84
|
+
warn(message: any, ...optionalParams: [...any, string?]): void;
|
|
85
|
+
/**
|
|
86
|
+
* Write a 'debug' level log.
|
|
87
|
+
*/
|
|
88
|
+
debug(message: any, context?: string): void;
|
|
89
|
+
debug(message: any, ...optionalParams: [...any, string?]): void;
|
|
90
|
+
/**
|
|
91
|
+
* Write a 'verbose' level log.
|
|
92
|
+
*/
|
|
93
|
+
verbose(message: any, context?: string): void;
|
|
94
|
+
verbose(message: any, ...optionalParams: [...any, string?]): void;
|
|
95
|
+
/**
|
|
96
|
+
* Write a 'fatal' level log.
|
|
97
|
+
*/
|
|
98
|
+
fatal(message: any, context?: string): void;
|
|
99
|
+
fatal(message: any, ...optionalParams: [...any, string?]): void;
|
|
100
|
+
/**
|
|
101
|
+
* Write an 'error' level log.
|
|
102
|
+
*/
|
|
103
|
+
static error(message: any, stackOrContext?: string): void;
|
|
104
|
+
static error(message: any, context?: string): void;
|
|
105
|
+
static error(message: any, stack?: string, context?: string): void;
|
|
106
|
+
static error(message: any, ...optionalParams: [...any, string?, string?]): void;
|
|
107
|
+
/**
|
|
108
|
+
* Write a 'log' level log.
|
|
109
|
+
*/
|
|
110
|
+
static log(message: any, context?: string): void;
|
|
111
|
+
static log(message: any, ...optionalParams: [...any, string?]): void;
|
|
112
|
+
/**
|
|
113
|
+
* Write a 'warn' level log.
|
|
114
|
+
*/
|
|
115
|
+
static warn(message: any, context?: string): void;
|
|
116
|
+
static warn(message: any, ...optionalParams: [...any, string?]): void;
|
|
117
|
+
/**
|
|
118
|
+
* Write a 'debug' level log, if the configured level allows for it.
|
|
119
|
+
* Prints to `stdout` with newline.
|
|
120
|
+
*/
|
|
121
|
+
static debug(message: any, context?: string): void;
|
|
122
|
+
static debug(message: any, ...optionalParams: [...any, string?]): void;
|
|
123
|
+
/**
|
|
124
|
+
* Write a 'verbose' level log.
|
|
125
|
+
*/
|
|
126
|
+
static verbose(message: any, context?: string): void;
|
|
127
|
+
static verbose(message: any, ...optionalParams: [...any, string?]): void;
|
|
128
|
+
/**
|
|
129
|
+
* Write a 'fatal' level log.
|
|
130
|
+
*/
|
|
131
|
+
static fatal(message: any, context?: string): void;
|
|
132
|
+
static fatal(message: any, ...optionalParams: [...any, string?]): void;
|
|
133
|
+
/**
|
|
134
|
+
* Print buffered logs and detach buffer.
|
|
135
|
+
*/
|
|
136
|
+
static flush(): void;
|
|
137
|
+
/**
|
|
138
|
+
* Attach buffer.
|
|
139
|
+
* Turns on initialization logs buffering.
|
|
140
|
+
*/
|
|
141
|
+
static attachBuffer(): void;
|
|
142
|
+
/**
|
|
143
|
+
* Detach buffer.
|
|
144
|
+
* Turns off initialization logs buffering.
|
|
145
|
+
*/
|
|
146
|
+
static detachBuffer(): void;
|
|
147
|
+
static getTimestamp(): string;
|
|
148
|
+
static overrideLogger(logger: LoggerService | LogLevel[] | boolean): any;
|
|
149
|
+
static isLevelEnabled(level: LogLevel): boolean;
|
|
150
|
+
private registerLocalInstanceRef;
|
|
151
|
+
}
|
|
152
|
+
export {};
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var Logger_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Logger = exports.LOG_LEVELS = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const core_1 = require("../decorators/core");
|
|
7
|
+
const shared_utils_1 = require("../utils/shared.utils");
|
|
8
|
+
const console_logger_service_1 = require("./console-logger.service");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
exports.LOG_LEVELS = [
|
|
11
|
+
'verbose',
|
|
12
|
+
'debug',
|
|
13
|
+
'log',
|
|
14
|
+
'warn',
|
|
15
|
+
'error',
|
|
16
|
+
'fatal',
|
|
17
|
+
];
|
|
18
|
+
const DEFAULT_LOGGER = new console_logger_service_1.ConsoleLogger();
|
|
19
|
+
const dateTimeFormatter = new Intl.DateTimeFormat(undefined, {
|
|
20
|
+
year: 'numeric',
|
|
21
|
+
hour: 'numeric',
|
|
22
|
+
minute: 'numeric',
|
|
23
|
+
second: 'numeric',
|
|
24
|
+
day: '2-digit',
|
|
25
|
+
month: '2-digit',
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* @publicApi
|
|
29
|
+
*/
|
|
30
|
+
let Logger = Logger_1 = class Logger {
|
|
31
|
+
constructor(context, options = {}) {
|
|
32
|
+
this.context = context;
|
|
33
|
+
this.options = options;
|
|
34
|
+
}
|
|
35
|
+
get localInstance() {
|
|
36
|
+
if (Logger_1.staticInstanceRef === DEFAULT_LOGGER) {
|
|
37
|
+
return this.registerLocalInstanceRef();
|
|
38
|
+
}
|
|
39
|
+
else if (Logger_1.staticInstanceRef instanceof Logger_1) {
|
|
40
|
+
const prototype = Object.getPrototypeOf(Logger_1.staticInstanceRef);
|
|
41
|
+
if (prototype.constructor === Logger_1) {
|
|
42
|
+
return this.registerLocalInstanceRef();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return Logger_1.staticInstanceRef;
|
|
46
|
+
}
|
|
47
|
+
error(message, ...optionalParams) {
|
|
48
|
+
optionalParams = this.context
|
|
49
|
+
? (optionalParams.length ? optionalParams : [undefined]).concat(this.context)
|
|
50
|
+
: optionalParams;
|
|
51
|
+
this.localInstance?.error(message, ...optionalParams);
|
|
52
|
+
}
|
|
53
|
+
log(message, ...optionalParams) {
|
|
54
|
+
optionalParams = this.context
|
|
55
|
+
? optionalParams.concat(this.context)
|
|
56
|
+
: optionalParams;
|
|
57
|
+
this.localInstance?.log(message, ...optionalParams);
|
|
58
|
+
}
|
|
59
|
+
warn(message, ...optionalParams) {
|
|
60
|
+
optionalParams = this.context
|
|
61
|
+
? optionalParams.concat(this.context)
|
|
62
|
+
: optionalParams;
|
|
63
|
+
this.localInstance?.warn(message, ...optionalParams);
|
|
64
|
+
}
|
|
65
|
+
debug(message, ...optionalParams) {
|
|
66
|
+
optionalParams = this.context
|
|
67
|
+
? optionalParams.concat(this.context)
|
|
68
|
+
: optionalParams;
|
|
69
|
+
this.localInstance?.debug?.(message, ...optionalParams);
|
|
70
|
+
}
|
|
71
|
+
verbose(message, ...optionalParams) {
|
|
72
|
+
optionalParams = this.context
|
|
73
|
+
? optionalParams.concat(this.context)
|
|
74
|
+
: optionalParams;
|
|
75
|
+
this.localInstance?.verbose?.(message, ...optionalParams);
|
|
76
|
+
}
|
|
77
|
+
fatal(message, ...optionalParams) {
|
|
78
|
+
optionalParams = this.context
|
|
79
|
+
? optionalParams.concat(this.context)
|
|
80
|
+
: optionalParams;
|
|
81
|
+
this.localInstance?.fatal?.(message, ...optionalParams);
|
|
82
|
+
}
|
|
83
|
+
static error(message, ...optionalParams) {
|
|
84
|
+
this.staticInstanceRef?.error(message, ...optionalParams);
|
|
85
|
+
}
|
|
86
|
+
static log(message, ...optionalParams) {
|
|
87
|
+
this.staticInstanceRef?.log(message, ...optionalParams);
|
|
88
|
+
}
|
|
89
|
+
static warn(message, ...optionalParams) {
|
|
90
|
+
this.staticInstanceRef?.warn(message, ...optionalParams);
|
|
91
|
+
}
|
|
92
|
+
static debug(message, ...optionalParams) {
|
|
93
|
+
this.staticInstanceRef?.debug?.(message, ...optionalParams);
|
|
94
|
+
}
|
|
95
|
+
static verbose(message, ...optionalParams) {
|
|
96
|
+
this.staticInstanceRef?.verbose?.(message, ...optionalParams);
|
|
97
|
+
}
|
|
98
|
+
static fatal(message, ...optionalParams) {
|
|
99
|
+
this.staticInstanceRef?.fatal?.(message, ...optionalParams);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Print buffered logs and detach buffer.
|
|
103
|
+
*/
|
|
104
|
+
static flush() {
|
|
105
|
+
this.isBufferAttached = false;
|
|
106
|
+
this.logBuffer.forEach(item => item.methodRef(...item.arguments));
|
|
107
|
+
this.logBuffer = [];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Attach buffer.
|
|
111
|
+
* Turns on initialization logs buffering.
|
|
112
|
+
*/
|
|
113
|
+
static attachBuffer() {
|
|
114
|
+
this.isBufferAttached = true;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Detach buffer.
|
|
118
|
+
* Turns off initialization logs buffering.
|
|
119
|
+
*/
|
|
120
|
+
static detachBuffer() {
|
|
121
|
+
this.isBufferAttached = false;
|
|
122
|
+
}
|
|
123
|
+
static getTimestamp() {
|
|
124
|
+
return dateTimeFormatter.format(Date.now());
|
|
125
|
+
}
|
|
126
|
+
static overrideLogger(logger) {
|
|
127
|
+
if (Array.isArray(logger)) {
|
|
128
|
+
Logger_1.logLevels = logger;
|
|
129
|
+
return this.staticInstanceRef?.setLogLevels?.(logger);
|
|
130
|
+
}
|
|
131
|
+
if ((0, shared_utils_1.isObject)(logger)) {
|
|
132
|
+
if (logger instanceof Logger_1 && logger.constructor !== Logger_1) {
|
|
133
|
+
const errorMessage = `Using the "extends Logger" instruction is not allowed in Nest v9. Please, use "extends ConsoleLogger" instead.`;
|
|
134
|
+
this.staticInstanceRef?.error(errorMessage);
|
|
135
|
+
throw new Error(errorMessage);
|
|
136
|
+
}
|
|
137
|
+
this.staticInstanceRef = logger;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
this.staticInstanceRef = undefined;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
static isLevelEnabled(level) {
|
|
144
|
+
const logLevels = Logger_1.logLevels;
|
|
145
|
+
return (0, utils_1.isLogLevelEnabled)(level, logLevels);
|
|
146
|
+
}
|
|
147
|
+
registerLocalInstanceRef() {
|
|
148
|
+
if (this.localInstanceRef) {
|
|
149
|
+
return this.localInstanceRef;
|
|
150
|
+
}
|
|
151
|
+
this.localInstanceRef = new console_logger_service_1.ConsoleLogger(this.context, {
|
|
152
|
+
timestamp: this.options?.timestamp,
|
|
153
|
+
logLevels: Logger_1.logLevels,
|
|
154
|
+
});
|
|
155
|
+
return this.localInstanceRef;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
exports.Logger = Logger;
|
|
159
|
+
Logger.logBuffer = new Array();
|
|
160
|
+
Logger.staticInstanceRef = DEFAULT_LOGGER;
|
|
161
|
+
Logger.WrapBuffer = (target, propertyKey, descriptor) => {
|
|
162
|
+
const originalFn = descriptor.value;
|
|
163
|
+
descriptor.value = function (...args) {
|
|
164
|
+
if (Logger_1.isBufferAttached) {
|
|
165
|
+
Logger_1.logBuffer.push({
|
|
166
|
+
methodRef: originalFn.bind(this),
|
|
167
|
+
arguments: args,
|
|
168
|
+
});
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
return originalFn.call(this, ...args);
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
tslib_1.__decorate([
|
|
175
|
+
Logger.WrapBuffer,
|
|
176
|
+
tslib_1.__metadata("design:type", Function),
|
|
177
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
178
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
179
|
+
], Logger.prototype, "error", null);
|
|
180
|
+
tslib_1.__decorate([
|
|
181
|
+
Logger.WrapBuffer,
|
|
182
|
+
tslib_1.__metadata("design:type", Function),
|
|
183
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
184
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
185
|
+
], Logger.prototype, "log", null);
|
|
186
|
+
tslib_1.__decorate([
|
|
187
|
+
Logger.WrapBuffer,
|
|
188
|
+
tslib_1.__metadata("design:type", Function),
|
|
189
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
190
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
191
|
+
], Logger.prototype, "warn", null);
|
|
192
|
+
tslib_1.__decorate([
|
|
193
|
+
Logger.WrapBuffer,
|
|
194
|
+
tslib_1.__metadata("design:type", Function),
|
|
195
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
196
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
197
|
+
], Logger.prototype, "debug", null);
|
|
198
|
+
tslib_1.__decorate([
|
|
199
|
+
Logger.WrapBuffer,
|
|
200
|
+
tslib_1.__metadata("design:type", Function),
|
|
201
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
202
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
203
|
+
], Logger.prototype, "verbose", null);
|
|
204
|
+
tslib_1.__decorate([
|
|
205
|
+
Logger.WrapBuffer,
|
|
206
|
+
tslib_1.__metadata("design:type", Function),
|
|
207
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
208
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
209
|
+
], Logger.prototype, "fatal", null);
|
|
210
|
+
tslib_1.__decorate([
|
|
211
|
+
Logger.WrapBuffer,
|
|
212
|
+
tslib_1.__metadata("design:type", Function),
|
|
213
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
214
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
215
|
+
], Logger, "error", null);
|
|
216
|
+
tslib_1.__decorate([
|
|
217
|
+
Logger.WrapBuffer,
|
|
218
|
+
tslib_1.__metadata("design:type", Function),
|
|
219
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
220
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
221
|
+
], Logger, "log", null);
|
|
222
|
+
tslib_1.__decorate([
|
|
223
|
+
Logger.WrapBuffer,
|
|
224
|
+
tslib_1.__metadata("design:type", Function),
|
|
225
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
226
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
227
|
+
], Logger, "warn", null);
|
|
228
|
+
tslib_1.__decorate([
|
|
229
|
+
Logger.WrapBuffer,
|
|
230
|
+
tslib_1.__metadata("design:type", Function),
|
|
231
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
232
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
233
|
+
], Logger, "debug", null);
|
|
234
|
+
tslib_1.__decorate([
|
|
235
|
+
Logger.WrapBuffer,
|
|
236
|
+
tslib_1.__metadata("design:type", Function),
|
|
237
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
238
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
239
|
+
], Logger, "verbose", null);
|
|
240
|
+
tslib_1.__decorate([
|
|
241
|
+
Logger.WrapBuffer,
|
|
242
|
+
tslib_1.__metadata("design:type", Function),
|
|
243
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
244
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
245
|
+
], Logger, "fatal", null);
|
|
246
|
+
exports.Logger = Logger = Logger_1 = tslib_1.__decorate([
|
|
247
|
+
(0, core_1.Injectable)(),
|
|
248
|
+
tslib_1.__param(0, (0, core_1.Optional)()),
|
|
249
|
+
tslib_1.__param(1, (0, core_1.Optional)()),
|
|
250
|
+
tslib_1.__metadata("design:paramtypes", [String, Object])
|
|
251
|
+
], Logger);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterLogLevels = filterLogLevels;
|
|
4
|
+
const logger_service_1 = require("../logger.service");
|
|
5
|
+
const is_log_level_util_1 = require("./is-log-level.util");
|
|
6
|
+
/**
|
|
7
|
+
* @publicApi
|
|
8
|
+
*/
|
|
9
|
+
function filterLogLevels(parseableString = '') {
|
|
10
|
+
const sanitizedString = parseableString.replaceAll(' ', '').toLowerCase();
|
|
11
|
+
if (sanitizedString[0] === '>') {
|
|
12
|
+
const orEqual = sanitizedString[1] === '=';
|
|
13
|
+
const logLevelIndex = logger_service_1.LOG_LEVELS.indexOf(sanitizedString.substring(orEqual ? 2 : 1));
|
|
14
|
+
if (logLevelIndex === -1) {
|
|
15
|
+
throw new Error(`parse error (unknown log level): ${sanitizedString}`);
|
|
16
|
+
}
|
|
17
|
+
return logger_service_1.LOG_LEVELS.slice(orEqual ? logLevelIndex : logLevelIndex + 1);
|
|
18
|
+
}
|
|
19
|
+
else if (sanitizedString.includes(',')) {
|
|
20
|
+
return sanitizedString.split(',').filter(is_log_level_util_1.isLogLevel);
|
|
21
|
+
}
|
|
22
|
+
return (0, is_log_level_util_1.isLogLevel)(sanitizedString) ? [sanitizedString] : logger_service_1.LOG_LEVELS;
|
|
23
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./filter-log-levels.util"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./is-log-level-enabled.util"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./is-log-level.util"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LogLevel } from '../logger.service';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if target level is enabled.
|
|
4
|
+
* @param targetLevel target level
|
|
5
|
+
* @param logLevels array of enabled log levels
|
|
6
|
+
*/
|
|
7
|
+
export declare function isLogLevelEnabled(targetLevel: LogLevel, logLevels: LogLevel[] | undefined): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLogLevelEnabled = isLogLevelEnabled;
|
|
4
|
+
const LOG_LEVEL_VALUES = {
|
|
5
|
+
verbose: 0,
|
|
6
|
+
debug: 1,
|
|
7
|
+
log: 2,
|
|
8
|
+
warn: 3,
|
|
9
|
+
error: 4,
|
|
10
|
+
fatal: 5,
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Checks if target level is enabled.
|
|
14
|
+
* @param targetLevel target level
|
|
15
|
+
* @param logLevels array of enabled log levels
|
|
16
|
+
*/
|
|
17
|
+
function isLogLevelEnabled(targetLevel, logLevels) {
|
|
18
|
+
if (!logLevels || (Array.isArray(logLevels) && logLevels?.length === 0)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (logLevels.includes(targetLevel)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
let highestLogLevelValue = -Infinity;
|
|
25
|
+
for (const level of logLevels) {
|
|
26
|
+
const v = LOG_LEVEL_VALUES[level];
|
|
27
|
+
if (v > highestLogLevelValue)
|
|
28
|
+
highestLogLevelValue = v;
|
|
29
|
+
}
|
|
30
|
+
const targetLevelValue = LOG_LEVEL_VALUES[targetLevel];
|
|
31
|
+
return targetLevelValue >= highestLogLevelValue;
|
|
32
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLogLevel = isLogLevel;
|
|
4
|
+
const logger_service_1 = require("../logger.service");
|
|
5
|
+
/**
|
|
6
|
+
* @publicApi
|
|
7
|
+
*/
|
|
8
|
+
function isLogLevel(maybeLogLevel) {
|
|
9
|
+
return logger_service_1.LOG_LEVELS.includes(maybeLogLevel);
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ParamData, RouteParamMetadata } from '../decorators/http/route-params.decorator';
|
|
2
|
+
import { PipeTransform, Type } from '../interfaces';
|
|
3
|
+
import { CustomParamFactory } from '../interfaces/features/custom-route-param-factory.interface';
|
|
4
|
+
export declare function assignCustomParameterMetadata(args: Record<number, RouteParamMetadata>, paramtype: number | string, index: number, factory: CustomParamFactory, data?: ParamData, ...pipes: (Type<PipeTransform> | PipeTransform)[]): {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assignCustomParameterMetadata = assignCustomParameterMetadata;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
function assignCustomParameterMetadata(args, paramtype, index, factory, data, ...pipes) {
|
|
6
|
+
return {
|
|
7
|
+
...args,
|
|
8
|
+
[`${paramtype}${constants_1.CUSTOM_ROUTE_ARGS_METADATA}:${index}`]: {
|
|
9
|
+
index,
|
|
10
|
+
factory,
|
|
11
|
+
data,
|
|
12
|
+
pipes,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const isColorAllowed: () => boolean;
|
|
2
|
+
export declare const clc: {
|
|
3
|
+
bold: (text: string) => string;
|
|
4
|
+
green: (text: string) => string;
|
|
5
|
+
yellow: (text: string) => string;
|
|
6
|
+
red: (text: string) => string;
|
|
7
|
+
magentaBright: (text: string) => string;
|
|
8
|
+
cyanBright: (text: string) => string;
|
|
9
|
+
};
|
|
10
|
+
export declare const yellow: (text: string) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.yellow = exports.clc = exports.isColorAllowed = void 0;
|
|
4
|
+
const isColorAllowed = () => !process.env.NO_COLOR;
|
|
5
|
+
exports.isColorAllowed = isColorAllowed;
|
|
6
|
+
const colorIfAllowed = (colorFn) => (text) => (0, exports.isColorAllowed)() ? colorFn(text) : text;
|
|
7
|
+
exports.clc = {
|
|
8
|
+
bold: colorIfAllowed((text) => `\x1B[1m${text}\x1B[0m`),
|
|
9
|
+
green: colorIfAllowed((text) => `\x1B[32m${text}\x1B[39m`),
|
|
10
|
+
yellow: colorIfAllowed((text) => `\x1B[33m${text}\x1B[39m`),
|
|
11
|
+
red: colorIfAllowed((text) => `\x1B[31m${text}\x1B[39m`),
|
|
12
|
+
magentaBright: colorIfAllowed((text) => `\x1B[95m${text}\x1B[39m`),
|
|
13
|
+
cyanBright: colorIfAllowed((text) => `\x1B[96m${text}\x1B[39m`),
|
|
14
|
+
};
|
|
15
|
+
exports.yellow = colorIfAllowed((text) => `\x1B[38;5;3m${text}\x1B[39m`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extendArrayMetadata<T extends Array<unknown>>(key: string, metadata: T, target: Function): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extendArrayMetadata = extendArrayMetadata;
|
|
4
|
+
function extendArrayMetadata(key, metadata, target) {
|
|
5
|
+
const previousValue = Reflect.getMetadata(key, target) || [];
|
|
6
|
+
const value = [...previousValue, ...metadata];
|
|
7
|
+
Reflect.defineMetadata(key, value, target);
|
|
8
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { HttpStatus } from '../enums';
|
|
2
|
+
import { Type } from '../interfaces';
|
|
3
|
+
export type ErrorHttpStatusCode = HttpStatus.BAD_GATEWAY | HttpStatus.BAD_REQUEST | HttpStatus.CONFLICT | HttpStatus.FORBIDDEN | HttpStatus.GATEWAY_TIMEOUT | HttpStatus.GONE | HttpStatus.I_AM_A_TEAPOT | HttpStatus.INTERNAL_SERVER_ERROR | HttpStatus.METHOD_NOT_ALLOWED | HttpStatus.NOT_ACCEPTABLE | HttpStatus.NOT_FOUND | HttpStatus.NOT_IMPLEMENTED | HttpStatus.PAYLOAD_TOO_LARGE | HttpStatus.PRECONDITION_FAILED | HttpStatus.REQUEST_TIMEOUT | HttpStatus.SERVICE_UNAVAILABLE | HttpStatus.UNAUTHORIZED | HttpStatus.UNPROCESSABLE_ENTITY | HttpStatus.UNSUPPORTED_MEDIA_TYPE;
|
|
4
|
+
export declare const HttpErrorByCode: Record<ErrorHttpStatusCode, Type<unknown>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpErrorByCode = void 0;
|
|
4
|
+
const enums_1 = require("../enums");
|
|
5
|
+
const exceptions_1 = require("../exceptions");
|
|
6
|
+
exports.HttpErrorByCode = {
|
|
7
|
+
[enums_1.HttpStatus.BAD_GATEWAY]: exceptions_1.BadGatewayException,
|
|
8
|
+
[enums_1.HttpStatus.BAD_REQUEST]: exceptions_1.BadRequestException,
|
|
9
|
+
[enums_1.HttpStatus.CONFLICT]: exceptions_1.ConflictException,
|
|
10
|
+
[enums_1.HttpStatus.FORBIDDEN]: exceptions_1.ForbiddenException,
|
|
11
|
+
[enums_1.HttpStatus.GATEWAY_TIMEOUT]: exceptions_1.GatewayTimeoutException,
|
|
12
|
+
[enums_1.HttpStatus.GONE]: exceptions_1.GoneException,
|
|
13
|
+
[enums_1.HttpStatus.I_AM_A_TEAPOT]: exceptions_1.ImATeapotException,
|
|
14
|
+
[enums_1.HttpStatus.INTERNAL_SERVER_ERROR]: exceptions_1.InternalServerErrorException,
|
|
15
|
+
[enums_1.HttpStatus.METHOD_NOT_ALLOWED]: exceptions_1.MethodNotAllowedException,
|
|
16
|
+
[enums_1.HttpStatus.NOT_ACCEPTABLE]: exceptions_1.NotAcceptableException,
|
|
17
|
+
[enums_1.HttpStatus.NOT_FOUND]: exceptions_1.NotFoundException,
|
|
18
|
+
[enums_1.HttpStatus.NOT_IMPLEMENTED]: exceptions_1.NotImplementedException,
|
|
19
|
+
[enums_1.HttpStatus.PAYLOAD_TOO_LARGE]: exceptions_1.PayloadTooLargeException,
|
|
20
|
+
[enums_1.HttpStatus.PRECONDITION_FAILED]: exceptions_1.PreconditionFailedException,
|
|
21
|
+
[enums_1.HttpStatus.REQUEST_TIMEOUT]: exceptions_1.RequestTimeoutException,
|
|
22
|
+
[enums_1.HttpStatus.SERVICE_UNAVAILABLE]: exceptions_1.ServiceUnavailableException,
|
|
23
|
+
[enums_1.HttpStatus.UNAUTHORIZED]: exceptions_1.UnauthorizedException,
|
|
24
|
+
[enums_1.HttpStatus.UNPROCESSABLE_ENTITY]: exceptions_1.UnprocessableEntityException,
|
|
25
|
+
[enums_1.HttpStatus.UNSUPPORTED_MEDIA_TYPE]: exceptions_1.UnsupportedMediaTypeException,
|
|
26
|
+
};
|
package/utils/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './forward-ref.util';
|
package/utils/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadPackage(packageName: string, context: string, loaderFn?: Function): any;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadPackage = loadPackage;
|
|
4
|
+
const logger_service_1 = require("../services/logger.service");
|
|
5
|
+
const MISSING_REQUIRED_DEPENDENCY = (name, reason) => `The "${name}" package is missing. Please, make sure to install it to take advantage of ${reason}.`;
|
|
6
|
+
const logger = new logger_service_1.Logger('PackageLoader');
|
|
7
|
+
function loadPackage(packageName, context, loaderFn) {
|
|
8
|
+
try {
|
|
9
|
+
return loaderFn ? loaderFn() : require(packageName);
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
logger.error(MISSING_REQUIRED_DEPENDENCY(packageName, context));
|
|
13
|
+
logger_service_1.Logger.flush();
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
}
|