@nestjs/common 11.1.16 → 12.0.0-alpha.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.
Files changed (329) hide show
  1. package/constants.js +35 -38
  2. package/decorators/core/apply-decorators.js +1 -4
  3. package/decorators/core/bind.decorator.js +1 -4
  4. package/decorators/core/catch.decorator.d.ts +1 -1
  5. package/decorators/core/catch.decorator.js +4 -7
  6. package/decorators/core/controller.decorator.d.ts +1 -1
  7. package/decorators/core/controller.decorator.js +10 -13
  8. package/decorators/core/dependencies.decorator.js +4 -9
  9. package/decorators/core/exception-filters.decorator.d.ts +1 -1
  10. package/decorators/core/exception-filters.decorator.js +10 -14
  11. package/decorators/core/index.d.ts +14 -14
  12. package/decorators/core/index.js +14 -17
  13. package/decorators/core/inject.decorator.d.ts +1 -1
  14. package/decorators/core/inject.decorator.js +9 -12
  15. package/decorators/core/injectable.decorator.d.ts +2 -2
  16. package/decorators/core/injectable.decorator.js +7 -11
  17. package/decorators/core/optional.decorator.js +8 -11
  18. package/decorators/core/set-metadata.decorator.js +1 -5
  19. package/decorators/core/use-guards.decorator.d.ts +1 -1
  20. package/decorators/core/use-guards.decorator.js +10 -13
  21. package/decorators/core/use-interceptors.decorator.d.ts +1 -1
  22. package/decorators/core/use-interceptors.decorator.js +10 -13
  23. package/decorators/core/use-pipes.decorator.d.ts +1 -1
  24. package/decorators/core/use-pipes.decorator.js +9 -12
  25. package/decorators/core/version.decorator.d.ts +1 -1
  26. package/decorators/core/version.decorator.js +3 -6
  27. package/decorators/http/create-route-param-metadata.decorator.d.ts +6 -5
  28. package/decorators/http/create-route-param-metadata.decorator.js +48 -16
  29. package/decorators/http/header.decorator.js +4 -7
  30. package/decorators/http/http-code.decorator.js +3 -6
  31. package/decorators/http/index.d.ts +8 -8
  32. package/decorators/http/index.js +8 -11
  33. package/decorators/http/redirect.decorator.js +3 -6
  34. package/decorators/http/render.decorator.js +3 -6
  35. package/decorators/http/request-mapping.decorator.d.ts +1 -1
  36. package/decorators/http/request-mapping.decorator.js +28 -32
  37. package/decorators/http/route-params.decorator.d.ts +153 -3
  38. package/decorators/http/route-params.decorator.js +124 -49
  39. package/decorators/http/sse.decorator.d.ts +2 -2
  40. package/decorators/http/sse.decorator.js +7 -10
  41. package/decorators/index.d.ts +3 -3
  42. package/decorators/index.js +3 -6
  43. package/decorators/modules/global.decorator.js +3 -6
  44. package/decorators/modules/index.d.ts +2 -2
  45. package/decorators/modules/index.js +2 -5
  46. package/decorators/modules/module.decorator.d.ts +1 -1
  47. package/decorators/modules/module.decorator.js +3 -6
  48. package/enums/http-status.enum.js +2 -5
  49. package/enums/index.d.ts +4 -4
  50. package/enums/index.js +4 -7
  51. package/enums/request-method.enum.js +2 -5
  52. package/enums/route-paramtypes.enum.js +2 -5
  53. package/enums/shutdown-signal.enum.js +2 -5
  54. package/enums/version-type.enum.js +2 -5
  55. package/exceptions/bad-gateway.exception.d.ts +1 -1
  56. package/exceptions/bad-gateway.exception.js +5 -9
  57. package/exceptions/bad-request.exception.d.ts +1 -1
  58. package/exceptions/bad-request.exception.js +5 -9
  59. package/exceptions/conflict.exception.d.ts +1 -1
  60. package/exceptions/conflict.exception.js +5 -9
  61. package/exceptions/forbidden.exception.d.ts +1 -1
  62. package/exceptions/forbidden.exception.js +5 -9
  63. package/exceptions/gateway-timeout.exception.d.ts +1 -1
  64. package/exceptions/gateway-timeout.exception.js +5 -9
  65. package/exceptions/gone.exception.d.ts +1 -1
  66. package/exceptions/gone.exception.js +5 -9
  67. package/exceptions/http-version-not-supported.exception.d.ts +1 -1
  68. package/exceptions/http-version-not-supported.exception.js +5 -9
  69. package/exceptions/http.exception.d.ts +6 -2
  70. package/exceptions/http.exception.js +36 -17
  71. package/exceptions/im-a-teapot.exception.d.ts +1 -1
  72. package/exceptions/im-a-teapot.exception.js +5 -9
  73. package/exceptions/index.d.ts +23 -23
  74. package/exceptions/index.js +23 -26
  75. package/exceptions/internal-server-error.exception.d.ts +1 -1
  76. package/exceptions/internal-server-error.exception.js +5 -9
  77. package/exceptions/intrinsic.exception.js +1 -5
  78. package/exceptions/method-not-allowed.exception.d.ts +1 -1
  79. package/exceptions/method-not-allowed.exception.js +5 -9
  80. package/exceptions/misdirected.exception.d.ts +1 -1
  81. package/exceptions/misdirected.exception.js +5 -9
  82. package/exceptions/not-acceptable.exception.d.ts +1 -1
  83. package/exceptions/not-acceptable.exception.js +5 -9
  84. package/exceptions/not-found.exception.d.ts +1 -1
  85. package/exceptions/not-found.exception.js +5 -9
  86. package/exceptions/not-implemented.exception.d.ts +1 -1
  87. package/exceptions/not-implemented.exception.js +5 -9
  88. package/exceptions/payload-too-large.exception.d.ts +1 -1
  89. package/exceptions/payload-too-large.exception.js +5 -9
  90. package/exceptions/precondition-failed.exception.d.ts +1 -1
  91. package/exceptions/precondition-failed.exception.js +5 -9
  92. package/exceptions/request-timeout.exception.d.ts +1 -1
  93. package/exceptions/request-timeout.exception.js +5 -9
  94. package/exceptions/service-unavailable.exception.d.ts +1 -1
  95. package/exceptions/service-unavailable.exception.js +5 -9
  96. package/exceptions/unauthorized.exception.d.ts +1 -1
  97. package/exceptions/unauthorized.exception.js +5 -9
  98. package/exceptions/unprocessable-entity.exception.d.ts +1 -1
  99. package/exceptions/unprocessable-entity.exception.js +5 -9
  100. package/exceptions/unsupported-media-type.exception.d.ts +1 -1
  101. package/exceptions/unsupported-media-type.exception.js +5 -9
  102. package/file-stream/index.d.ts +1 -1
  103. package/file-stream/index.js +1 -4
  104. package/file-stream/interfaces/index.d.ts +2 -2
  105. package/file-stream/interfaces/index.js +2 -5
  106. package/file-stream/interfaces/streamable-handler-response.interface.js +1 -2
  107. package/file-stream/interfaces/streamable-options.interface.js +1 -2
  108. package/file-stream/streamable-file.d.ts +2 -2
  109. package/file-stream/streamable-file.js +26 -28
  110. package/index.d.ts +10 -10
  111. package/index.js +11 -17
  112. package/interfaces/abstract.interface.js +1 -2
  113. package/interfaces/controllers/controller-metadata.interface.js +1 -2
  114. package/interfaces/controllers/controller.interface.js +1 -2
  115. package/interfaces/controllers/index.d.ts +2 -2
  116. package/interfaces/controllers/index.js +2 -5
  117. package/interfaces/exceptions/exception-filter-metadata.interface.d.ts +2 -2
  118. package/interfaces/exceptions/exception-filter-metadata.interface.js +1 -2
  119. package/interfaces/exceptions/exception-filter.interface.d.ts +1 -1
  120. package/interfaces/exceptions/exception-filter.interface.js +1 -2
  121. package/interfaces/exceptions/index.d.ts +5 -5
  122. package/interfaces/exceptions/index.js +5 -8
  123. package/interfaces/exceptions/rpc-exception-filter-metadata.interface.d.ts +2 -2
  124. package/interfaces/exceptions/rpc-exception-filter-metadata.interface.js +1 -2
  125. package/interfaces/exceptions/rpc-exception-filter.interface.d.ts +1 -1
  126. package/interfaces/exceptions/rpc-exception-filter.interface.js +1 -2
  127. package/interfaces/exceptions/ws-exception-filter.interface.d.ts +1 -1
  128. package/interfaces/exceptions/ws-exception-filter.interface.js +1 -2
  129. package/interfaces/external/class-transform-options.interface.js +1 -2
  130. package/interfaces/external/cors-options.interface.js +1 -2
  131. package/interfaces/external/https-options.interface.js +1 -2
  132. package/interfaces/external/transformer-package.interface.d.ts +2 -2
  133. package/interfaces/external/transformer-package.interface.js +1 -2
  134. package/interfaces/external/validation-error.interface.js +1 -2
  135. package/interfaces/external/validator-options.interface.js +1 -2
  136. package/interfaces/external/validator-package.interface.d.ts +2 -2
  137. package/interfaces/external/validator-package.interface.js +1 -2
  138. package/interfaces/features/arguments-host.interface.js +1 -2
  139. package/interfaces/features/can-activate.interface.d.ts +1 -1
  140. package/interfaces/features/can-activate.interface.js +1 -2
  141. package/interfaces/features/custom-route-param-factory.interface.d.ts +1 -1
  142. package/interfaces/features/custom-route-param-factory.interface.js +1 -2
  143. package/interfaces/features/execution-context.interface.d.ts +2 -2
  144. package/interfaces/features/execution-context.interface.js +1 -2
  145. package/interfaces/features/nest-interceptor.interface.d.ts +1 -1
  146. package/interfaces/features/nest-interceptor.interface.js +1 -2
  147. package/interfaces/features/paramtype.interface.js +1 -2
  148. package/interfaces/features/pipe-transform.interface.d.ts +10 -4
  149. package/interfaces/features/pipe-transform.interface.js +1 -2
  150. package/interfaces/global-prefix-options.interface.d.ts +1 -1
  151. package/interfaces/global-prefix-options.interface.js +1 -2
  152. package/interfaces/hooks/before-application-shutdown.interface.js +1 -2
  153. package/interfaces/hooks/index.d.ts +5 -5
  154. package/interfaces/hooks/index.js +5 -8
  155. package/interfaces/hooks/on-application-bootstrap.interface.js +1 -2
  156. package/interfaces/hooks/on-application-shutdown.interface.js +1 -2
  157. package/interfaces/hooks/on-destroy.interface.js +1 -2
  158. package/interfaces/hooks/on-init.interface.js +1 -2
  159. package/interfaces/http/http-exception-body.interface.d.ts +2 -1
  160. package/interfaces/http/http-exception-body.interface.js +1 -2
  161. package/interfaces/http/http-redirect-response.interface.d.ts +1 -1
  162. package/interfaces/http/http-redirect-response.interface.js +1 -2
  163. package/interfaces/http/http-server.interface.d.ts +4 -3
  164. package/interfaces/http/http-server.interface.js +1 -2
  165. package/interfaces/http/index.d.ts +5 -5
  166. package/interfaces/http/index.js +5 -8
  167. package/interfaces/http/message-event.interface.js +1 -2
  168. package/interfaces/http/raw-body-request.interface.js +1 -2
  169. package/interfaces/index.d.ts +31 -30
  170. package/interfaces/index.js +31 -33
  171. package/interfaces/injectable.interface.js +1 -2
  172. package/interfaces/microservices/nest-hybrid-application-options.interface.js +1 -2
  173. package/interfaces/microservices/nest-microservice-options.interface.d.ts +1 -1
  174. package/interfaces/microservices/nest-microservice-options.interface.js +1 -2
  175. package/interfaces/microservices/pre-request-hook.interface.d.ts +22 -0
  176. package/interfaces/microservices/pre-request-hook.interface.js +1 -0
  177. package/interfaces/middleware/index.d.ts +4 -4
  178. package/interfaces/middleware/index.js +4 -7
  179. package/interfaces/middleware/middleware-config-proxy.interface.d.ts +3 -3
  180. package/interfaces/middleware/middleware-config-proxy.interface.js +1 -2
  181. package/interfaces/middleware/middleware-configuration.interface.d.ts +3 -3
  182. package/interfaces/middleware/middleware-configuration.interface.js +1 -2
  183. package/interfaces/middleware/middleware-consumer.interface.d.ts +2 -2
  184. package/interfaces/middleware/middleware-consumer.interface.js +1 -2
  185. package/interfaces/middleware/nest-middleware.interface.js +1 -2
  186. package/interfaces/modules/dynamic-module.interface.d.ts +2 -2
  187. package/interfaces/modules/dynamic-module.interface.js +1 -2
  188. package/interfaces/modules/forward-reference.interface.js +1 -2
  189. package/interfaces/modules/index.d.ts +8 -8
  190. package/interfaces/modules/index.js +8 -11
  191. package/interfaces/modules/injection-token.interface.d.ts +2 -2
  192. package/interfaces/modules/injection-token.interface.js +1 -2
  193. package/interfaces/modules/introspection-result.interface.d.ts +1 -1
  194. package/interfaces/modules/introspection-result.interface.js +1 -2
  195. package/interfaces/modules/module-metadata.interface.d.ts +5 -5
  196. package/interfaces/modules/module-metadata.interface.js +1 -2
  197. package/interfaces/modules/nest-module.interface.d.ts +1 -1
  198. package/interfaces/modules/nest-module.interface.js +1 -2
  199. package/interfaces/modules/optional-factory-dependency.interface.d.ts +1 -1
  200. package/interfaces/modules/optional-factory-dependency.interface.js +1 -2
  201. package/interfaces/modules/provider.interface.d.ts +4 -4
  202. package/interfaces/modules/provider.interface.js +1 -2
  203. package/interfaces/nest-application-context-options.interface.d.ts +1 -1
  204. package/interfaces/nest-application-context-options.interface.js +55 -5
  205. package/interfaces/nest-application-context.interface.d.ts +6 -6
  206. package/interfaces/nest-application-context.interface.js +1 -2
  207. package/interfaces/nest-application-options.interface.d.ts +9 -3
  208. package/interfaces/nest-application-options.interface.js +1 -2
  209. package/interfaces/nest-application.interface.d.ts +8 -8
  210. package/interfaces/nest-application.interface.js +1 -2
  211. package/interfaces/nest-microservice.interface.d.ts +15 -6
  212. package/interfaces/nest-microservice.interface.js +1 -2
  213. package/interfaces/scope-options.interface.js +2 -5
  214. package/interfaces/shutdown-hooks-options.interface.js +1 -2
  215. package/interfaces/type.interface.js +1 -2
  216. package/interfaces/version-options.interface.d.ts +1 -1
  217. package/interfaces/version-options.interface.js +1 -4
  218. package/interfaces/websockets/web-socket-adapter.interface.js +1 -2
  219. package/internal.d.ts +30 -0
  220. package/internal.js +19 -0
  221. package/module-utils/configurable-module.builder.d.ts +4 -4
  222. package/module-utils/configurable-module.builder.js +21 -20
  223. package/module-utils/constants.js +5 -8
  224. package/module-utils/index.d.ts +2 -2
  225. package/module-utils/index.js +2 -5
  226. package/module-utils/interfaces/configurable-module-async-options.interface.d.ts +2 -2
  227. package/module-utils/interfaces/configurable-module-async-options.interface.js +1 -2
  228. package/module-utils/interfaces/configurable-module-cls.interface.d.ts +3 -3
  229. package/module-utils/interfaces/configurable-module-cls.interface.js +1 -2
  230. package/module-utils/interfaces/configurable-module-host.interface.d.ts +2 -2
  231. package/module-utils/interfaces/configurable-module-host.interface.js +1 -2
  232. package/module-utils/interfaces/index.d.ts +3 -3
  233. package/module-utils/interfaces/index.js +3 -6
  234. package/module-utils/utils/generate-options-injection-token.util.js +3 -6
  235. package/module-utils/utils/get-injection-providers.util.d.ts +1 -1
  236. package/module-utils/utils/get-injection-providers.util.js +4 -7
  237. package/module-utils/utils/index.d.ts +2 -2
  238. package/module-utils/utils/index.js +2 -5
  239. package/package.json +35 -2
  240. package/pipes/default-value.pipe.d.ts +1 -1
  241. package/pipes/default-value.pipe.js +10 -12
  242. package/pipes/file/file-type.validator.d.ts +3 -3
  243. package/pipes/file/file-type.validator.js +5 -19
  244. package/pipes/file/file-validator-context.interface.d.ts +1 -1
  245. package/pipes/file/file-validator-context.interface.js +1 -2
  246. package/pipes/file/file-validator.interface.d.ts +1 -1
  247. package/pipes/file/file-validator.interface.js +2 -5
  248. package/pipes/file/index.d.ts +6 -6
  249. package/pipes/file/index.js +6 -9
  250. package/pipes/file/interfaces/file.interface.js +1 -2
  251. package/pipes/file/interfaces/index.d.ts +1 -1
  252. package/pipes/file/interfaces/index.js +1 -4
  253. package/pipes/file/max-file-size.validator.d.ts +3 -3
  254. package/pipes/file/max-file-size.validator.js +2 -6
  255. package/pipes/file/parse-file-options.interface.d.ts +2 -2
  256. package/pipes/file/parse-file-options.interface.js +1 -2
  257. package/pipes/file/parse-file-pipe.builder.d.ts +5 -5
  258. package/pipes/file/parse-file-pipe.builder.js +8 -14
  259. package/pipes/file/parse-file.pipe.d.ts +7 -7
  260. package/pipes/file/parse-file.pipe.js +17 -18
  261. package/pipes/index.d.ts +11 -10
  262. package/pipes/index.js +11 -13
  263. package/pipes/parse-array.pipe.d.ts +4 -4
  264. package/pipes/parse-array.pipe.js +23 -23
  265. package/pipes/parse-bool.pipe.d.ts +6 -6
  266. package/pipes/parse-bool.pipe.js +16 -17
  267. package/pipes/parse-date.pipe.d.ts +4 -4
  268. package/pipes/parse-date.pipe.js +17 -16
  269. package/pipes/parse-enum.pipe.d.ts +5 -5
  270. package/pipes/parse-enum.pipe.js +16 -16
  271. package/pipes/parse-float.pipe.d.ts +6 -6
  272. package/pipes/parse-float.pipe.js +17 -18
  273. package/pipes/parse-int.pipe.d.ts +5 -5
  274. package/pipes/parse-int.pipe.js +18 -19
  275. package/pipes/parse-uuid.pipe.d.ts +4 -4
  276. package/pipes/parse-uuid.pipe.js +27 -26
  277. package/pipes/standard-schema-validation.pipe.d.ts +86 -0
  278. package/pipes/standard-schema-validation.pipe.js +120 -0
  279. package/pipes/validation.pipe.d.ts +32 -14
  280. package/pipes/validation.pipe.js +60 -30
  281. package/serializer/class-serializer.constants.js +1 -4
  282. package/serializer/class-serializer.interceptor.d.ts +5 -5
  283. package/serializer/class-serializer.interceptor.js +21 -24
  284. package/serializer/class-serializer.interfaces.d.ts +2 -2
  285. package/serializer/class-serializer.interfaces.js +1 -2
  286. package/serializer/decorators/index.d.ts +1 -1
  287. package/serializer/decorators/index.js +1 -4
  288. package/serializer/decorators/serialize-options.decorator.d.ts +3 -2
  289. package/serializer/decorators/serialize-options.decorator.js +3 -7
  290. package/serializer/index.d.ts +5 -3
  291. package/serializer/index.js +5 -6
  292. package/serializer/standard-schema-serializer.interceptor.d.ts +50 -0
  293. package/serializer/standard-schema-serializer.interceptor.js +75 -0
  294. package/serializer/standard-schema-serializer.interfaces.d.ts +18 -0
  295. package/serializer/standard-schema-serializer.interfaces.js +1 -0
  296. package/services/console-logger.service.d.ts +22 -3
  297. package/services/console-logger.service.js +132 -66
  298. package/services/index.d.ts +3 -3
  299. package/services/index.js +3 -6
  300. package/services/logger.service.js +86 -83
  301. package/services/utils/filter-log-levels.util.d.ts +1 -1
  302. package/services/utils/filter-log-levels.util.js +7 -10
  303. package/services/utils/index.d.ts +3 -3
  304. package/services/utils/index.js +3 -6
  305. package/services/utils/is-log-level-enabled.util.d.ts +1 -1
  306. package/services/utils/is-log-level-enabled.util.js +1 -4
  307. package/services/utils/is-log-level.util.d.ts +1 -1
  308. package/services/utils/is-log-level.util.js +3 -6
  309. package/tsconfig.build.json +1 -2
  310. package/utils/assign-custom-metadata.util.d.ts +5 -4
  311. package/utils/assign-custom-metadata.util.js +4 -6
  312. package/utils/cli-colors.util.js +4 -8
  313. package/utils/extend-metadata.util.js +1 -4
  314. package/utils/forward-ref.util.d.ts +1 -1
  315. package/utils/forward-ref.util.js +1 -5
  316. package/utils/http-error-by-code.util.d.ts +2 -2
  317. package/utils/http-error-by-code.util.js +22 -25
  318. package/utils/index.d.ts +1 -1
  319. package/utils/index.js +1 -4
  320. package/utils/load-package.util.d.ts +29 -1
  321. package/utils/load-package.util.js +84 -9
  322. package/utils/merge-with-values.util.js +1 -5
  323. package/utils/random-string-generator.util.js +2 -6
  324. package/utils/select-exception-filter-metadata.util.d.ts +1 -1
  325. package/utils/select-exception-filter-metadata.util.js +1 -5
  326. package/utils/shared.utils.d.ts +11 -10
  327. package/utils/shared.utils.js +28 -30
  328. package/utils/validate-each.util.js +3 -7
  329. package/utils/validate-module-keys.util.js +8 -13
@@ -1,6 +1,6 @@
1
- import { Type } from '../interfaces';
2
- import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
3
- import { ValidationPipe, ValidationPipeOptions } from './validation.pipe';
1
+ import { Type } from '../interfaces/index.js';
2
+ import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface.js';
3
+ import { ValidationPipe, ValidationPipeOptions } from './validation.pipe.js';
4
4
  /**
5
5
  * @publicApi
6
6
  */
@@ -46,7 +46,7 @@ export declare class ParseArrayPipe implements PipeTransform {
46
46
  * @param value currently processed route argument
47
47
  * @param metadata contains metadata about the currently processed route argument
48
48
  */
49
- transform(value: any, metadata: ArgumentMetadata): Promise<any>;
49
+ transform(value: unknown, metadata: ArgumentMetadata): Promise<any>;
50
50
  protected isExpectedTypePrimitive(): boolean;
51
51
  protected validatePrimitive(originalValue: any, index?: number): any;
52
52
  }
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParseArrayPipe = void 0;
4
- const tslib_1 = require("tslib");
5
- const injectable_decorator_1 = require("../decorators/core/injectable.decorator");
6
- const optional_decorator_1 = require("../decorators/core/optional.decorator");
7
- const http_status_enum_1 = require("../enums/http-status.enum");
8
- const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
9
- const shared_utils_1 = require("../utils/shared.utils");
10
- const validation_pipe_1 = require("./validation.pipe");
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Injectable } from '../decorators/core/injectable.decorator.js';
3
+ import { Optional } from '../decorators/core/optional.decorator.js';
4
+ import { HttpStatus } from '../enums/http-status.enum.js';
5
+ import { HttpErrorByCode } from '../utils/http-error-by-code.util.js';
6
+ import { isNil, isString, isUndefined } from '../utils/shared.utils.js';
7
+ import { ValidationPipe } from './validation.pipe.js';
11
8
  const VALIDATION_ERROR_MESSAGE = 'Validation failed (parsable array expected)';
12
9
  const DEFAULT_ARRAY_SEPARATOR = ',';
13
10
  /**
@@ -18,17 +15,20 @@ const DEFAULT_ARRAY_SEPARATOR = ',';
18
15
  * @publicApi
19
16
  */
20
17
  let ParseArrayPipe = class ParseArrayPipe {
18
+ options;
19
+ validationPipe;
20
+ exceptionFactory;
21
21
  constructor(options = {}) {
22
22
  this.options = options;
23
- this.validationPipe = new validation_pipe_1.ValidationPipe({
23
+ this.validationPipe = new ValidationPipe({
24
24
  transform: true,
25
25
  validateCustomDecorators: true,
26
26
  ...options,
27
27
  });
28
- const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST } = options;
28
+ const { exceptionFactory, errorHttpStatusCode = HttpStatus.BAD_REQUEST } = options;
29
29
  this.exceptionFactory =
30
30
  exceptionFactory ||
31
- (error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
31
+ (error => new HttpErrorByCode[errorHttpStatusCode](error));
32
32
  }
33
33
  /**
34
34
  * Method that accesses and performs optional transformation on argument for
@@ -41,11 +41,11 @@ let ParseArrayPipe = class ParseArrayPipe {
41
41
  if (!value && !this.options.optional) {
42
42
  throw this.exceptionFactory(VALIDATION_ERROR_MESSAGE);
43
43
  }
44
- else if ((0, shared_utils_1.isNil)(value) && this.options.optional) {
44
+ else if (isNil(value) && this.options.optional) {
45
45
  return value;
46
46
  }
47
47
  if (!Array.isArray(value)) {
48
- if (!(0, shared_utils_1.isString)(value)) {
48
+ if (!isString(value)) {
49
49
  throw this.exceptionFactory(VALIDATION_ERROR_MESSAGE);
50
50
  }
51
51
  else {
@@ -123,26 +123,26 @@ let ParseArrayPipe = class ParseArrayPipe {
123
123
  if (this.options.items === Number) {
124
124
  const value = originalValue !== null && originalValue !== '' ? +originalValue : NaN;
125
125
  if (isNaN(value)) {
126
- throw this.exceptionFactory(`${(0, shared_utils_1.isUndefined)(index) ? '' : `[${index}] `}item must be a number`);
126
+ throw this.exceptionFactory(`${isUndefined(index) ? '' : `[${index}] `}item must be a number`);
127
127
  }
128
128
  return value;
129
129
  }
130
130
  else if (this.options.items === String) {
131
- if (!(0, shared_utils_1.isString)(originalValue)) {
131
+ if (!isString(originalValue)) {
132
132
  return `${originalValue}`;
133
133
  }
134
134
  }
135
135
  else if (this.options.items === Boolean) {
136
136
  if (typeof originalValue !== 'boolean') {
137
- throw this.exceptionFactory(`${(0, shared_utils_1.isUndefined)(index) ? '' : `[${index}] `}item must be a boolean value`);
137
+ throw this.exceptionFactory(`${isUndefined(index) ? '' : `[${index}] `}item must be a boolean value`);
138
138
  }
139
139
  }
140
140
  return originalValue;
141
141
  }
142
142
  };
143
- exports.ParseArrayPipe = ParseArrayPipe;
144
- exports.ParseArrayPipe = ParseArrayPipe = tslib_1.__decorate([
145
- (0, injectable_decorator_1.Injectable)(),
146
- tslib_1.__param(0, (0, optional_decorator_1.Optional)()),
147
- tslib_1.__metadata("design:paramtypes", [Object])
143
+ ParseArrayPipe = __decorate([
144
+ Injectable(),
145
+ __param(0, Optional()),
146
+ __metadata("design:paramtypes", [Object])
148
147
  ], ParseArrayPipe);
148
+ export { ParseArrayPipe };
@@ -1,5 +1,5 @@
1
- import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
2
- import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
1
+ import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface.js';
2
+ import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util.js';
3
3
  /**
4
4
  * @publicApi
5
5
  */
@@ -28,7 +28,7 @@ export interface ParseBoolPipeOptions {
28
28
  *
29
29
  * @publicApi
30
30
  */
31
- export declare class ParseBoolPipe implements PipeTransform<string | boolean, Promise<boolean>> {
31
+ export declare class ParseBoolPipe implements PipeTransform {
32
32
  protected readonly options?: ParseBoolPipeOptions | undefined;
33
33
  protected exceptionFactory: (error: string) => any;
34
34
  constructor(options?: ParseBoolPipeOptions | undefined);
@@ -39,17 +39,17 @@ export declare class ParseBoolPipe implements PipeTransform<string | boolean, Pr
39
39
  * @param value currently processed route argument
40
40
  * @param metadata contains metadata about the currently processed route argument
41
41
  */
42
- transform(value: string | boolean, metadata: ArgumentMetadata): Promise<boolean>;
42
+ transform(value: unknown, metadata: ArgumentMetadata): Promise<boolean | undefined | null>;
43
43
  /**
44
44
  * @param value currently processed route argument
45
45
  * @returns `true` if `value` is said 'true', ie., if it is equal to the boolean
46
46
  * `true` or the string `"true"`
47
47
  */
48
- protected isTrue(value: string | boolean): boolean;
48
+ protected isTrue(value: unknown): boolean;
49
49
  /**
50
50
  * @param value currently processed route argument
51
51
  * @returns `true` if `value` is said 'false', ie., if it is equal to the boolean
52
52
  * `false` or the string `"false"`
53
53
  */
54
- protected isFalse(value: string | boolean): boolean;
54
+ protected isFalse(value: unknown): boolean;
55
55
  }
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParseBoolPipe = void 0;
4
- const tslib_1 = require("tslib");
5
- const injectable_decorator_1 = require("../decorators/core/injectable.decorator");
6
- const optional_decorator_1 = require("../decorators/core/optional.decorator");
7
- const http_status_enum_1 = require("../enums/http-status.enum");
8
- const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
9
- const shared_utils_1 = require("../utils/shared.utils");
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Injectable } from '../decorators/core/injectable.decorator.js';
3
+ import { Optional } from '../decorators/core/optional.decorator.js';
4
+ import { HttpStatus } from '../enums/http-status.enum.js';
5
+ import { HttpErrorByCode, } from '../utils/http-error-by-code.util.js';
6
+ import { isNil } from '../utils/shared.utils.js';
10
7
  /**
11
8
  * Defines the built-in ParseBool Pipe
12
9
  *
@@ -15,13 +12,15 @@ const shared_utils_1 = require("../utils/shared.utils");
15
12
  * @publicApi
16
13
  */
17
14
  let ParseBoolPipe = class ParseBoolPipe {
15
+ options;
16
+ exceptionFactory;
18
17
  constructor(options) {
19
18
  this.options = options;
20
19
  options = options || {};
21
- const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST } = options;
20
+ const { exceptionFactory, errorHttpStatusCode = HttpStatus.BAD_REQUEST } = options;
22
21
  this.exceptionFactory =
23
22
  exceptionFactory ||
24
- (error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
23
+ (error => new HttpErrorByCode[errorHttpStatusCode](error));
25
24
  }
26
25
  /**
27
26
  * Method that accesses and performs optional transformation on argument for
@@ -31,7 +30,7 @@ let ParseBoolPipe = class ParseBoolPipe {
31
30
  * @param metadata contains metadata about the currently processed route argument
32
31
  */
33
32
  async transform(value, metadata) {
34
- if ((0, shared_utils_1.isNil)(value) && this.options?.optional) {
33
+ if (isNil(value) && this.options?.optional) {
35
34
  return value;
36
35
  }
37
36
  if (this.isTrue(value)) {
@@ -59,9 +58,9 @@ let ParseBoolPipe = class ParseBoolPipe {
59
58
  return value === false || value === 'false';
60
59
  }
61
60
  };
62
- exports.ParseBoolPipe = ParseBoolPipe;
63
- exports.ParseBoolPipe = ParseBoolPipe = tslib_1.__decorate([
64
- (0, injectable_decorator_1.Injectable)(),
65
- tslib_1.__param(0, (0, optional_decorator_1.Optional)()),
66
- tslib_1.__metadata("design:paramtypes", [Object])
61
+ ParseBoolPipe = __decorate([
62
+ Injectable(),
63
+ __param(0, Optional()),
64
+ __metadata("design:paramtypes", [Object])
67
65
  ], ParseBoolPipe);
66
+ export { ParseBoolPipe };
@@ -1,5 +1,5 @@
1
- import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
2
- import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
1
+ import { PipeTransform } from '../interfaces/features/pipe-transform.interface.js';
2
+ import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util.js';
3
3
  export interface ParseDatePipeOptions {
4
4
  /**
5
5
  * If true, the pipe will return null or undefined if the value is not provided
@@ -22,7 +22,7 @@ export interface ParseDatePipeOptions {
22
22
  */
23
23
  exceptionFactory?: (error: string) => any;
24
24
  }
25
- export declare class ParseDatePipe implements PipeTransform<string | number | undefined | null> {
25
+ export declare class ParseDatePipe implements PipeTransform {
26
26
  private readonly options;
27
27
  protected exceptionFactory: (error: string) => any;
28
28
  constructor(options?: ParseDatePipeOptions);
@@ -33,5 +33,5 @@ export declare class ParseDatePipe implements PipeTransform<string | number | un
33
33
  * @param value currently processed route argument
34
34
  * @param metadata contains metadata about the currently processed route argument
35
35
  */
36
- transform(value: string | number | undefined | null): Date | null | undefined;
36
+ transform(value: unknown): Date | null | undefined;
37
37
  }
@@ -1,18 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParseDatePipe = void 0;
4
- const tslib_1 = require("tslib");
5
- const injectable_decorator_1 = require("../decorators/core/injectable.decorator");
6
- const http_status_enum_1 = require("../enums/http-status.enum");
7
- const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
8
- const shared_utils_1 = require("../utils/shared.utils");
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Injectable } from '../decorators/core/injectable.decorator.js';
3
+ import { HttpStatus } from '../enums/http-status.enum.js';
4
+ import { HttpErrorByCode, } from '../utils/http-error-by-code.util.js';
5
+ import { isNil, isNumber, isString } from '../utils/shared.utils.js';
9
6
  let ParseDatePipe = class ParseDatePipe {
7
+ options;
8
+ exceptionFactory;
10
9
  constructor(options = {}) {
11
10
  this.options = options;
12
- const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST } = options;
11
+ const { exceptionFactory, errorHttpStatusCode = HttpStatus.BAD_REQUEST } = options;
13
12
  this.exceptionFactory =
14
13
  exceptionFactory ||
15
- (error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
14
+ (error => new HttpErrorByCode[errorHttpStatusCode](error));
16
15
  }
17
16
  /**
18
17
  * Method that accesses and performs optional transformation on argument for
@@ -22,21 +21,23 @@ let ParseDatePipe = class ParseDatePipe {
22
21
  * @param metadata contains metadata about the currently processed route argument
23
22
  */
24
23
  transform(value) {
25
- if (this.options.optional && (0, shared_utils_1.isNil)(value)) {
24
+ if (this.options.optional && isNil(value)) {
26
25
  return this.options.default ? this.options.default() : value;
27
26
  }
28
27
  if (!value) {
29
28
  throw this.exceptionFactory('Validation failed (no Date provided)');
30
29
  }
31
- const transformedValue = new Date(value);
30
+ const transformedValue = isString(value) || isNumber(value) || value instanceof Date
31
+ ? new Date(value)
32
+ : new Date(NaN);
32
33
  if (isNaN(transformedValue.getTime())) {
33
34
  throw this.exceptionFactory('Validation failed (invalid date format)');
34
35
  }
35
36
  return transformedValue;
36
37
  }
37
38
  };
38
- exports.ParseDatePipe = ParseDatePipe;
39
- exports.ParseDatePipe = ParseDatePipe = tslib_1.__decorate([
40
- (0, injectable_decorator_1.Injectable)(),
41
- tslib_1.__metadata("design:paramtypes", [Object])
39
+ ParseDatePipe = __decorate([
40
+ Injectable(),
41
+ __metadata("design:paramtypes", [Object])
42
42
  ], ParseDatePipe);
43
+ export { ParseDatePipe };
@@ -1,6 +1,6 @@
1
- import { ArgumentMetadata } from '../index';
2
- import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
3
- import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
1
+ import { ArgumentMetadata } from '../index.js';
2
+ import { PipeTransform } from '../interfaces/features/pipe-transform.interface.js';
3
+ import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util.js';
4
4
  /**
5
5
  * @publicApi
6
6
  */
@@ -41,6 +41,6 @@ export declare class ParseEnumPipe<T = any> implements PipeTransform<T> {
41
41
  * @param value currently processed route argument
42
42
  * @param metadata contains metadata about the currently processed route argument
43
43
  */
44
- transform(value: T, metadata: ArgumentMetadata): Promise<T>;
45
- protected isEnum(value: T): boolean;
44
+ transform(value: unknown, metadata: ArgumentMetadata): Promise<T | undefined | null>;
45
+ protected isEnum(value: unknown): boolean;
46
46
  }
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParseEnumPipe = void 0;
4
- const tslib_1 = require("tslib");
5
- const core_1 = require("../decorators/core");
6
- const index_1 = require("../index");
7
- const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
8
- const shared_utils_1 = require("../utils/shared.utils");
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Injectable, Optional } from '../decorators/core/index.js';
3
+ import { HttpStatus } from '../index.js';
4
+ import { HttpErrorByCode, } from '../utils/http-error-by-code.util.js';
5
+ import { isNil } from '../utils/shared.utils.js';
9
6
  /**
10
7
  * Defines the built-in ParseEnum Pipe
11
8
  *
@@ -14,6 +11,9 @@ const shared_utils_1 = require("../utils/shared.utils");
14
11
  * @publicApi
15
12
  */
16
13
  let ParseEnumPipe = class ParseEnumPipe {
14
+ enumType;
15
+ options;
16
+ exceptionFactory;
17
17
  constructor(enumType, options) {
18
18
  this.enumType = enumType;
19
19
  this.options = options;
@@ -21,10 +21,10 @@ let ParseEnumPipe = class ParseEnumPipe {
21
21
  throw new Error(`"ParseEnumPipe" requires "enumType" argument specified (to validate input values).`);
22
22
  }
23
23
  options = options || {};
24
- const { exceptionFactory, errorHttpStatusCode = index_1.HttpStatus.BAD_REQUEST } = options;
24
+ const { exceptionFactory, errorHttpStatusCode = HttpStatus.BAD_REQUEST } = options;
25
25
  this.exceptionFactory =
26
26
  exceptionFactory ||
27
- (error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
27
+ (error => new HttpErrorByCode[errorHttpStatusCode](error));
28
28
  }
29
29
  /**
30
30
  * Method that accesses and performs optional transformation on argument for
@@ -34,7 +34,7 @@ let ParseEnumPipe = class ParseEnumPipe {
34
34
  * @param metadata contains metadata about the currently processed route argument
35
35
  */
36
36
  async transform(value, metadata) {
37
- if ((0, shared_utils_1.isNil)(value) && this.options?.optional) {
37
+ if (isNil(value) && this.options?.optional) {
38
38
  return value;
39
39
  }
40
40
  if (!this.isEnum(value)) {
@@ -47,9 +47,9 @@ let ParseEnumPipe = class ParseEnumPipe {
47
47
  return enumValues.includes(value);
48
48
  }
49
49
  };
50
- exports.ParseEnumPipe = ParseEnumPipe;
51
- exports.ParseEnumPipe = ParseEnumPipe = tslib_1.__decorate([
52
- (0, core_1.Injectable)(),
53
- tslib_1.__param(1, (0, core_1.Optional)()),
54
- tslib_1.__metadata("design:paramtypes", [Object, Object])
50
+ ParseEnumPipe = __decorate([
51
+ Injectable(),
52
+ __param(1, Optional()),
53
+ __metadata("design:paramtypes", [Object, Object])
55
54
  ], ParseEnumPipe);
55
+ export { ParseEnumPipe };
@@ -1,6 +1,6 @@
1
- import { ArgumentMetadata } from '../index';
2
- import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
3
- import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
1
+ import { ArgumentMetadata } from '../index.js';
2
+ import { PipeTransform } from '../interfaces/features/pipe-transform.interface.js';
3
+ import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util.js';
4
4
  /**
5
5
  * @publicApi
6
6
  */
@@ -29,7 +29,7 @@ export interface ParseFloatPipeOptions {
29
29
  *
30
30
  * @publicApi
31
31
  */
32
- export declare class ParseFloatPipe implements PipeTransform<string> {
32
+ export declare class ParseFloatPipe implements PipeTransform {
33
33
  protected readonly options?: ParseFloatPipeOptions | undefined;
34
34
  protected exceptionFactory: (error: string) => any;
35
35
  constructor(options?: ParseFloatPipeOptions | undefined);
@@ -40,10 +40,10 @@ export declare class ParseFloatPipe implements PipeTransform<string> {
40
40
  * @param value currently processed route argument
41
41
  * @param metadata contains metadata about the currently processed route argument
42
42
  */
43
- transform(value: string, metadata: ArgumentMetadata): Promise<number>;
43
+ transform(value: unknown, metadata: ArgumentMetadata): Promise<number | undefined | null>;
44
44
  /**
45
45
  * @param value currently processed route argument
46
46
  * @returns `true` if `value` is a valid float number
47
47
  */
48
- protected isNumeric(value: string): boolean;
48
+ protected isNumeric(value: unknown): boolean;
49
49
  }
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParseFloatPipe = void 0;
4
- const tslib_1 = require("tslib");
5
- const core_1 = require("../decorators/core");
6
- const index_1 = require("../index");
7
- const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
8
- const shared_utils_1 = require("../utils/shared.utils");
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Injectable, Optional } from '../decorators/core/index.js';
3
+ import { HttpStatus } from '../index.js';
4
+ import { HttpErrorByCode, } from '../utils/http-error-by-code.util.js';
5
+ import { isNil } from '../utils/shared.utils.js';
9
6
  /**
10
7
  * Defines the built-in ParseFloat Pipe
11
8
  *
@@ -14,13 +11,15 @@ const shared_utils_1 = require("../utils/shared.utils");
14
11
  * @publicApi
15
12
  */
16
13
  let ParseFloatPipe = class ParseFloatPipe {
14
+ options;
15
+ exceptionFactory;
17
16
  constructor(options) {
18
17
  this.options = options;
19
18
  options = options || {};
20
- const { exceptionFactory, errorHttpStatusCode = index_1.HttpStatus.BAD_REQUEST } = options;
19
+ const { exceptionFactory, errorHttpStatusCode = HttpStatus.BAD_REQUEST } = options;
21
20
  this.exceptionFactory =
22
21
  exceptionFactory ||
23
- (error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
22
+ (error => new HttpErrorByCode[errorHttpStatusCode](error));
24
23
  }
25
24
  /**
26
25
  * Method that accesses and performs optional transformation on argument for
@@ -30,13 +29,13 @@ let ParseFloatPipe = class ParseFloatPipe {
30
29
  * @param metadata contains metadata about the currently processed route argument
31
30
  */
32
31
  async transform(value, metadata) {
33
- if ((0, shared_utils_1.isNil)(value) && this.options?.optional) {
32
+ if (isNil(value) && this.options?.optional) {
34
33
  return value;
35
34
  }
36
35
  if (!this.isNumeric(value)) {
37
36
  throw this.exceptionFactory('Validation failed (numeric string is expected)');
38
37
  }
39
- return parseFloat(value);
38
+ return parseFloat(String(value));
40
39
  }
41
40
  /**
42
41
  * @param value currently processed route argument
@@ -44,13 +43,13 @@ let ParseFloatPipe = class ParseFloatPipe {
44
43
  */
45
44
  isNumeric(value) {
46
45
  return (['string', 'number'].includes(typeof value) &&
47
- !isNaN(parseFloat(value)) &&
46
+ !isNaN(parseFloat(String(value))) &&
48
47
  isFinite(value));
49
48
  }
50
49
  };
51
- exports.ParseFloatPipe = ParseFloatPipe;
52
- exports.ParseFloatPipe = ParseFloatPipe = tslib_1.__decorate([
53
- (0, core_1.Injectable)(),
54
- tslib_1.__param(0, (0, core_1.Optional)()),
55
- tslib_1.__metadata("design:paramtypes", [Object])
50
+ ParseFloatPipe = __decorate([
51
+ Injectable(),
52
+ __param(0, Optional()),
53
+ __metadata("design:paramtypes", [Object])
56
54
  ], ParseFloatPipe);
55
+ export { ParseFloatPipe };
@@ -1,5 +1,5 @@
1
- import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
2
- import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
1
+ import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface.js';
2
+ import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util.js';
3
3
  /**
4
4
  * @publicApi
5
5
  */
@@ -28,7 +28,7 @@ export interface ParseIntPipeOptions {
28
28
  *
29
29
  * @publicApi
30
30
  */
31
- export declare class ParseIntPipe implements PipeTransform<string> {
31
+ export declare class ParseIntPipe implements PipeTransform {
32
32
  protected readonly options?: ParseIntPipeOptions | undefined;
33
33
  protected exceptionFactory: (error: string) => any;
34
34
  constructor(options?: ParseIntPipeOptions | undefined);
@@ -39,10 +39,10 @@ export declare class ParseIntPipe implements PipeTransform<string> {
39
39
  * @param value currently processed route argument
40
40
  * @param metadata contains metadata about the currently processed route argument
41
41
  */
42
- transform(value: string, metadata: ArgumentMetadata): Promise<number>;
42
+ transform(value: unknown, metadata: ArgumentMetadata): Promise<number | undefined | null>;
43
43
  /**
44
44
  * @param value currently processed route argument
45
45
  * @returns `true` if `value` is a valid integer number
46
46
  */
47
- protected isNumeric(value: string): boolean;
47
+ protected isNumeric(value: unknown): boolean;
48
48
  }
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParseIntPipe = void 0;
4
- const tslib_1 = require("tslib");
5
- const injectable_decorator_1 = require("../decorators/core/injectable.decorator");
6
- const optional_decorator_1 = require("../decorators/core/optional.decorator");
7
- const http_status_enum_1 = require("../enums/http-status.enum");
8
- const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
9
- const shared_utils_1 = require("../utils/shared.utils");
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Injectable } from '../decorators/core/injectable.decorator.js';
3
+ import { Optional } from '../decorators/core/optional.decorator.js';
4
+ import { HttpStatus } from '../enums/http-status.enum.js';
5
+ import { HttpErrorByCode, } from '../utils/http-error-by-code.util.js';
6
+ import { isNil } from '../utils/shared.utils.js';
10
7
  /**
11
8
  * Defines the built-in ParseInt Pipe
12
9
  *
@@ -15,13 +12,15 @@ const shared_utils_1 = require("../utils/shared.utils");
15
12
  * @publicApi
16
13
  */
17
14
  let ParseIntPipe = class ParseIntPipe {
15
+ options;
16
+ exceptionFactory;
18
17
  constructor(options) {
19
18
  this.options = options;
20
19
  options = options || {};
21
- const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST } = options;
20
+ const { exceptionFactory, errorHttpStatusCode = HttpStatus.BAD_REQUEST } = options;
22
21
  this.exceptionFactory =
23
22
  exceptionFactory ||
24
- (error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
23
+ (error => new HttpErrorByCode[errorHttpStatusCode](error));
25
24
  }
26
25
  /**
27
26
  * Method that accesses and performs optional transformation on argument for
@@ -31,13 +30,13 @@ let ParseIntPipe = class ParseIntPipe {
31
30
  * @param metadata contains metadata about the currently processed route argument
32
31
  */
33
32
  async transform(value, metadata) {
34
- if ((0, shared_utils_1.isNil)(value) && this.options?.optional) {
33
+ if (isNil(value) && this.options?.optional) {
35
34
  return value;
36
35
  }
37
36
  if (!this.isNumeric(value)) {
38
37
  throw this.exceptionFactory('Validation failed (numeric string is expected)');
39
38
  }
40
- return parseInt(value, 10);
39
+ return parseInt(String(value), 10);
41
40
  }
42
41
  /**
43
42
  * @param value currently processed route argument
@@ -45,13 +44,13 @@ let ParseIntPipe = class ParseIntPipe {
45
44
  */
46
45
  isNumeric(value) {
47
46
  return (['string', 'number'].includes(typeof value) &&
48
- /^-?\d+$/.test(value) &&
47
+ /^-?\d+$/.test(String(value)) &&
49
48
  isFinite(value));
50
49
  }
51
50
  };
52
- exports.ParseIntPipe = ParseIntPipe;
53
- exports.ParseIntPipe = ParseIntPipe = tslib_1.__decorate([
54
- (0, injectable_decorator_1.Injectable)(),
55
- tslib_1.__param(0, (0, optional_decorator_1.Optional)()),
56
- tslib_1.__metadata("design:paramtypes", [Object])
51
+ ParseIntPipe = __decorate([
52
+ Injectable(),
53
+ __param(0, Optional()),
54
+ __metadata("design:paramtypes", [Object])
57
55
  ], ParseIntPipe);
56
+ export { ParseIntPipe };
@@ -1,5 +1,5 @@
1
- import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
2
- import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
1
+ import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface.js';
2
+ import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util.js';
3
3
  /**
4
4
  * @publicApi
5
5
  */
@@ -32,7 +32,7 @@ export interface ParseUUIDPipeOptions {
32
32
  *
33
33
  * @publicApi
34
34
  */
35
- export declare class ParseUUIDPipe implements PipeTransform<string> {
35
+ export declare class ParseUUIDPipe implements PipeTransform {
36
36
  protected readonly options?: ParseUUIDPipeOptions | undefined;
37
37
  protected static uuidRegExps: {
38
38
  3: RegExp;
@@ -44,6 +44,6 @@ export declare class ParseUUIDPipe implements PipeTransform<string> {
44
44
  private readonly version;
45
45
  protected exceptionFactory: (errors: string) => any;
46
46
  constructor(options?: ParseUUIDPipeOptions | undefined);
47
- transform(value: string, metadata: ArgumentMetadata): Promise<string>;
47
+ transform(value: unknown, metadata: ArgumentMetadata): Promise<string | undefined | null>;
48
48
  protected isUUID(str: unknown, version?: string): any;
49
49
  }