@nestjs/common 11.1.15 → 12.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +21 -1
  321. package/utils/load-package.util.js +62 -8
  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,13 +1,10 @@
1
- "use strict";
2
1
  var ParseUUIDPipe_1;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ParseUUIDPipe = void 0;
5
- const tslib_1 = require("tslib");
6
- const injectable_decorator_1 = require("../decorators/core/injectable.decorator");
7
- const optional_decorator_1 = require("../decorators/core/optional.decorator");
8
- const http_status_enum_1 = require("../enums/http-status.enum");
9
- const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
10
- const shared_utils_1 = require("../utils/shared.utils");
2
+ import { __decorate, __metadata, __param } from "tslib";
3
+ import { Injectable } from '../decorators/core/injectable.decorator.js';
4
+ import { Optional } from '../decorators/core/optional.decorator.js';
5
+ import { HttpStatus } from '../enums/http-status.enum.js';
6
+ import { HttpErrorByCode, } from '../utils/http-error-by-code.util.js';
7
+ import { isNil, isString } from '../utils/shared.utils.js';
11
8
  /**
12
9
  * Defines the built-in ParseUUID Pipe
13
10
  *
@@ -15,18 +12,29 @@ const shared_utils_1 = require("../utils/shared.utils");
15
12
  *
16
13
  * @publicApi
17
14
  */
18
- let ParseUUIDPipe = ParseUUIDPipe_1 = class ParseUUIDPipe {
15
+ let ParseUUIDPipe = class ParseUUIDPipe {
16
+ static { ParseUUIDPipe_1 = this; }
17
+ options;
18
+ static uuidRegExps = {
19
+ 3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
20
+ 4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
21
+ 5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
22
+ 7: /^[0-9A-F]{8}-[0-9A-F]{4}-7[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
23
+ all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
24
+ };
25
+ version;
26
+ exceptionFactory;
19
27
  constructor(options) {
20
28
  this.options = options;
21
29
  options = options || {};
22
- const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST, version, } = options;
30
+ const { exceptionFactory, errorHttpStatusCode = HttpStatus.BAD_REQUEST, version, } = options;
23
31
  this.version = version;
24
32
  this.exceptionFactory =
25
33
  exceptionFactory ||
26
- (error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
34
+ (error => new HttpErrorByCode[errorHttpStatusCode](error));
27
35
  }
28
36
  async transform(value, metadata) {
29
- if ((0, shared_utils_1.isNil)(value) && this.options?.optional) {
37
+ if (isNil(value) && this.options?.optional) {
30
38
  return value;
31
39
  }
32
40
  if (!this.isUUID(value, this.version)) {
@@ -35,23 +43,16 @@ let ParseUUIDPipe = ParseUUIDPipe_1 = class ParseUUIDPipe {
35
43
  return value;
36
44
  }
37
45
  isUUID(str, version = 'all') {
38
- if (!(0, shared_utils_1.isString)(str)) {
46
+ if (!isString(str)) {
39
47
  throw this.exceptionFactory('The value passed as UUID is not a string');
40
48
  }
41
49
  const pattern = ParseUUIDPipe_1.uuidRegExps[version];
42
50
  return pattern?.test(str);
43
51
  }
44
52
  };
45
- exports.ParseUUIDPipe = ParseUUIDPipe;
46
- ParseUUIDPipe.uuidRegExps = {
47
- 3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
48
- 4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
49
- 5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
50
- 7: /^[0-9A-F]{8}-[0-9A-F]{4}-7[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
51
- all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
52
- };
53
- exports.ParseUUIDPipe = ParseUUIDPipe = ParseUUIDPipe_1 = 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])
53
+ ParseUUIDPipe = ParseUUIDPipe_1 = __decorate([
54
+ Injectable(),
55
+ __param(0, Optional()),
56
+ __metadata("design:paramtypes", [Object])
57
57
  ], ParseUUIDPipe);
58
+ export { ParseUUIDPipe };
@@ -0,0 +1,86 @@
1
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
2
+ import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface.js';
3
+ import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util.js';
4
+ /**
5
+ * @publicApi
6
+ */
7
+ export interface StandardSchemaValidationPipeOptions {
8
+ /**
9
+ * If true, the pipe will return the value produced by the schema
10
+ * (which may differ from the input if the schema coerces/transforms values).
11
+ * If false, the original input value is returned after successful validation.
12
+ * @default true
13
+ */
14
+ transform?: boolean;
15
+ /**
16
+ * If true, the pipe will also validate parameters decorated with custom decorators
17
+ * (created with `createParamDecorator`). When false, custom parameters are skipped.
18
+ * @default false
19
+ */
20
+ validateCustomDecorators?: boolean;
21
+ /**
22
+ * Options to pass to the standard schema `validate` function.
23
+ * These options are forwarded as the second argument to the schema's `~standard.validate` method.
24
+ */
25
+ validateOptions?: Record<string, unknown>;
26
+ /**
27
+ * The HTTP status code to be used in the response when the validation fails.
28
+ * @default HttpStatus.BAD_REQUEST
29
+ */
30
+ errorHttpStatusCode?: ErrorHttpStatusCode;
31
+ /**
32
+ * A factory function that returns an exception object to be thrown
33
+ * if validation fails.
34
+ * @param issues The issues returned by the standard schema validation
35
+ * @returns The exception object
36
+ */
37
+ exceptionFactory?: (issues: readonly StandardSchemaV1.Issue[]) => any;
38
+ }
39
+ /**
40
+ * Defines the built-in StandardSchemaValidation Pipe.
41
+ *
42
+ * Uses a standard schema object (conforming to the Standard Schema spec)
43
+ * attached to the parameter metadata to validate incoming values.
44
+ *
45
+ * @see [Standard Schema](https://github.com/standard-schema/standard-schema)
46
+ *
47
+ * @publicApi
48
+ */
49
+ export declare class StandardSchemaValidationPipe implements PipeTransform {
50
+ protected readonly options?: StandardSchemaValidationPipeOptions | undefined;
51
+ protected isTransformEnabled: boolean;
52
+ protected validateCustomDecorators: boolean;
53
+ protected validateOptions: Record<string, unknown> | undefined;
54
+ protected exceptionFactory: (issues: readonly StandardSchemaV1.Issue[]) => any;
55
+ constructor(options?: StandardSchemaValidationPipeOptions | undefined);
56
+ /**
57
+ * Method that validates the incoming value against the standard schema
58
+ * provided in the parameter metadata.
59
+ *
60
+ * @param value currently processed route argument
61
+ * @param metadata contains metadata about the currently processed route argument
62
+ */
63
+ transform<T = any>(value: T, metadata: ArgumentMetadata): Promise<T>;
64
+ /**
65
+ * Determines whether validation should be performed for the given metadata.
66
+ * Skips validation for custom decorators unless `validateCustomDecorators` is enabled.
67
+ *
68
+ * @param metadata contains metadata about the currently processed route argument
69
+ * @returns `true` if validation should be performed
70
+ */
71
+ protected toValidate(metadata: ArgumentMetadata): boolean;
72
+ /**
73
+ * Validates a value against a standard schema.
74
+ * Can be overridden to customize validation behavior.
75
+ *
76
+ * @param value The value to validate
77
+ * @param schema The standard schema to validate against
78
+ * @param options Optional options forwarded to the schema's validate method
79
+ * @returns The validation result
80
+ */
81
+ protected validate<T = unknown>(value: unknown, schema: StandardSchemaV1, options?: Record<string, unknown>): Promise<StandardSchemaV1.Result<T>> | StandardSchemaV1.Result<T>;
82
+ /**
83
+ * Strips dangerous prototype pollution keys from an object.
84
+ */
85
+ protected stripProtoKeys(value: any): void;
86
+ }
@@ -0,0 +1,120 @@
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { types } from 'util';
3
+ import { Injectable } from '../decorators/core/injectable.decorator.js';
4
+ import { Optional } from '../decorators/core/optional.decorator.js';
5
+ import { HttpStatus } from '../enums/http-status.enum.js';
6
+ import { HttpErrorByCode, } from '../utils/http-error-by-code.util.js';
7
+ /**
8
+ * Built-in JavaScript types that should be excluded from prototype stripping
9
+ * to avoid conflicts with test frameworks like Jest's useFakeTimers
10
+ */
11
+ const BUILT_IN_TYPES = [Date, RegExp, Error, Map, Set, WeakMap, WeakSet];
12
+ /**
13
+ * Defines the built-in StandardSchemaValidation Pipe.
14
+ *
15
+ * Uses a standard schema object (conforming to the Standard Schema spec)
16
+ * attached to the parameter metadata to validate incoming values.
17
+ *
18
+ * @see [Standard Schema](https://github.com/standard-schema/standard-schema)
19
+ *
20
+ * @publicApi
21
+ */
22
+ let StandardSchemaValidationPipe = class StandardSchemaValidationPipe {
23
+ options;
24
+ isTransformEnabled;
25
+ validateCustomDecorators;
26
+ validateOptions;
27
+ exceptionFactory;
28
+ constructor(options) {
29
+ this.options = options;
30
+ const { transform = true, validateCustomDecorators = false, validateOptions, exceptionFactory, errorHttpStatusCode = HttpStatus.BAD_REQUEST, } = options || {};
31
+ this.isTransformEnabled = transform;
32
+ this.validateCustomDecorators = validateCustomDecorators;
33
+ this.validateOptions = validateOptions;
34
+ this.exceptionFactory =
35
+ exceptionFactory ||
36
+ (issues => {
37
+ const messages = issues.map(issue => issue.message);
38
+ return new HttpErrorByCode[errorHttpStatusCode](messages);
39
+ });
40
+ }
41
+ /**
42
+ * Method that validates the incoming value against the standard schema
43
+ * provided in the parameter metadata.
44
+ *
45
+ * @param value currently processed route argument
46
+ * @param metadata contains metadata about the currently processed route argument
47
+ */
48
+ async transform(value, metadata) {
49
+ const schema = metadata.schema;
50
+ if (!schema || !this.toValidate(metadata)) {
51
+ return value;
52
+ }
53
+ this.stripProtoKeys(value);
54
+ const result = await this.validate(value, schema, this.validateOptions);
55
+ if (result.issues) {
56
+ throw this.exceptionFactory(result.issues);
57
+ }
58
+ return this.isTransformEnabled ? result.value : value;
59
+ }
60
+ /**
61
+ * Determines whether validation should be performed for the given metadata.
62
+ * Skips validation for custom decorators unless `validateCustomDecorators` is enabled.
63
+ *
64
+ * @param metadata contains metadata about the currently processed route argument
65
+ * @returns `true` if validation should be performed
66
+ */
67
+ toValidate(metadata) {
68
+ const { type } = metadata;
69
+ if (type === 'custom' && !this.validateCustomDecorators) {
70
+ return false;
71
+ }
72
+ return true;
73
+ }
74
+ /**
75
+ * Validates a value against a standard schema.
76
+ * Can be overridden to customize validation behavior.
77
+ *
78
+ * @param value The value to validate
79
+ * @param schema The standard schema to validate against
80
+ * @param options Optional options forwarded to the schema's validate method
81
+ * @returns The validation result
82
+ */
83
+ validate(value, schema, options) {
84
+ return schema['~standard'].validate(value, options);
85
+ }
86
+ /**
87
+ * Strips dangerous prototype pollution keys from an object.
88
+ */
89
+ stripProtoKeys(value) {
90
+ if (value == null ||
91
+ typeof value !== 'object' ||
92
+ types.isTypedArray(value)) {
93
+ return;
94
+ }
95
+ if (BUILT_IN_TYPES.some(type => value instanceof type)) {
96
+ return;
97
+ }
98
+ if (Array.isArray(value)) {
99
+ for (const v of value) {
100
+ this.stripProtoKeys(v);
101
+ }
102
+ return;
103
+ }
104
+ delete value.__proto__;
105
+ delete value.prototype;
106
+ const constructorType = value?.constructor;
107
+ if (constructorType && !BUILT_IN_TYPES.includes(constructorType)) {
108
+ delete value.constructor;
109
+ }
110
+ for (const key in value) {
111
+ this.stripProtoKeys(value[key]);
112
+ }
113
+ }
114
+ };
115
+ StandardSchemaValidationPipe = __decorate([
116
+ Injectable(),
117
+ __param(0, Optional()),
118
+ __metadata("design:paramtypes", [Object])
119
+ ], StandardSchemaValidationPipe);
120
+ export { StandardSchemaValidationPipe };
@@ -1,11 +1,15 @@
1
- import { ClassTransformOptions } from '../interfaces/external/class-transform-options.interface';
2
- import { TransformerPackage } from '../interfaces/external/transformer-package.interface';
3
- import { ValidationError } from '../interfaces/external/validation-error.interface';
4
- import { ValidatorOptions } from '../interfaces/external/validator-options.interface';
5
- import { ValidatorPackage } from '../interfaces/external/validator-package.interface';
6
- import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
7
- import { Type } from '../interfaces/type.interface';
8
- import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
1
+ import { ClassTransformOptions } from '../interfaces/external/class-transform-options.interface.js';
2
+ import { TransformerPackage } from '../interfaces/external/transformer-package.interface.js';
3
+ import { ValidationError } from '../interfaces/external/validation-error.interface.js';
4
+ import { ValidatorOptions } from '../interfaces/external/validator-options.interface.js';
5
+ import { ValidatorPackage } from '../interfaces/external/validator-package.interface.js';
6
+ import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface.js';
7
+ import { Type } from '../interfaces/type.interface.js';
8
+ import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util.js';
9
+ /**
10
+ * @publicApi
11
+ */
12
+ export type ValidationErrorFormat = 'list' | 'grouped';
9
13
  /**
10
14
  * @publicApi
11
15
  */
@@ -19,13 +23,25 @@ export interface ValidationPipeOptions extends ValidatorOptions {
19
23
  expectedType?: Type<any>;
20
24
  validatorPackage?: ValidatorPackage;
21
25
  transformerPackage?: TransformerPackage;
26
+ /**
27
+ * Specifies the format of validation error messages.
28
+ * - 'list': Returns an array of error message strings (default). The response message is `string[]`.
29
+ * - 'grouped': Returns an object with property paths as keys and arrays of unmodified error messages as values.
30
+ * The response message is `Record<string, string[]>`. Custom messages defined in validation decorators
31
+ * (e.g., `@IsNotEmpty({ message: 'Name is required' })`) are preserved without parent path prefixes.
32
+ *
33
+ * @remarks
34
+ * When using 'grouped', the `message` property in the error response changes from `string[]` to `Record<string, string[]>`.
35
+ * If you have exception filters or interceptors that assume `message` is always an array, they will need to be updated.
36
+ */
37
+ errorFormat?: ValidationErrorFormat;
22
38
  }
23
39
  /**
24
40
  * @see [Validation](https://docs.nestjs.com/techniques/validation)
25
41
  *
26
42
  * @publicApi
27
43
  */
28
- export declare class ValidationPipe implements PipeTransform<any> {
44
+ export declare class ValidationPipe implements PipeTransform {
29
45
  protected isTransformEnabled: boolean;
30
46
  protected isDetailedOutputDisabled?: boolean;
31
47
  protected validatorOptions: ValidatorOptions;
@@ -34,18 +50,20 @@ export declare class ValidationPipe implements PipeTransform<any> {
34
50
  protected expectedType: Type<any> | undefined;
35
51
  protected exceptionFactory: (errors: ValidationError[]) => any;
36
52
  protected validateCustomDecorators: boolean;
53
+ protected errorFormat: ValidationErrorFormat;
37
54
  constructor(options?: ValidationPipeOptions);
38
- protected loadValidator(validatorPackage?: ValidatorPackage): ValidatorPackage;
39
- protected loadTransformer(transformerPackage?: TransformerPackage): TransformerPackage;
40
- transform(value: any, metadata: ArgumentMetadata): Promise<any>;
55
+ protected loadValidator(validatorPackage?: ValidatorPackage): ValidatorPackage | Promise<ValidatorPackage>;
56
+ protected loadTransformer(transformerPackage?: TransformerPackage): TransformerPackage | Promise<TransformerPackage>;
57
+ transform(value: unknown, metadata: ArgumentMetadata): Promise<any>;
41
58
  createExceptionFactory(): (validationErrors?: ValidationError[]) => unknown;
42
59
  protected toValidate(metadata: ArgumentMetadata): boolean;
43
- protected transformPrimitive(value: any, metadata: ArgumentMetadata): any;
44
- protected toEmptyIfNil<T = any, R = T>(value: T, metatype: Type<unknown> | object): R | object | string;
60
+ protected transformPrimitive(value: unknown, metadata: ArgumentMetadata): unknown;
61
+ protected toEmptyIfNil<T = any, R = T>(value: unknown, metatype: Type<unknown> | object): R | object | string;
45
62
  protected stripProtoKeys(value: any): void;
46
63
  protected isPrimitive(value: unknown): boolean;
47
64
  protected validate(object: object, validatorOptions?: ValidatorOptions): Promise<ValidationError[]> | ValidationError[];
48
65
  protected flattenValidationErrors(validationErrors: ValidationError[]): string[];
66
+ protected groupValidationErrors(validationErrors: ValidationError[], parentPath?: string): Record<string, string[]>;
49
67
  protected mapChildrenToValidationErrors(error: ValidationError, parentPath?: string): ValidationError[];
50
68
  protected prependConstraintsWithParentProp(parentPath: string, error: ValidationError): ValidationError;
51
69
  }
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValidationPipe = void 0;
4
- const tslib_1 = require("tslib");
5
- const iterare_1 = require("iterare");
6
- const util_1 = require("util");
7
- const decorators_1 = require("../decorators");
8
- const core_1 = require("../decorators/core");
9
- const http_status_enum_1 = require("../enums/http-status.enum");
10
- const http_error_by_code_util_1 = require("../utils/http-error-by-code.util");
11
- const load_package_util_1 = require("../utils/load-package.util");
12
- const shared_utils_1 = require("../utils/shared.utils");
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { iterate } from 'iterare';
3
+ import { types } from 'util';
4
+ import { Injectable } from '../decorators/core/index.js';
5
+ import { Optional } from '../decorators/index.js';
6
+ import { HttpStatus } from '../enums/http-status.enum.js';
7
+ import { HttpErrorByCode, } from '../utils/http-error-by-code.util.js';
8
+ import { loadPackage } from '../utils/load-package.util.js';
9
+ import { isNil, isUndefined } from '../utils/shared.utils.js';
13
10
  let classValidator = {};
14
11
  let classTransformer = {};
15
12
  /**
@@ -23,17 +20,27 @@ const BUILT_IN_TYPES = [Date, RegExp, Error, Map, Set, WeakMap, WeakSet];
23
20
  * @publicApi
24
21
  */
25
22
  let ValidationPipe = class ValidationPipe {
23
+ isTransformEnabled;
24
+ isDetailedOutputDisabled;
25
+ validatorOptions;
26
+ transformOptions;
27
+ errorHttpStatusCode;
28
+ expectedType;
29
+ exceptionFactory;
30
+ validateCustomDecorators;
31
+ errorFormat;
26
32
  constructor(options) {
27
33
  options = options || {};
28
- const { transform, disableErrorMessages, errorHttpStatusCode, expectedType, transformOptions, validateCustomDecorators, ...validatorOptions } = options;
34
+ const { transform, disableErrorMessages, errorHttpStatusCode, expectedType, transformOptions, validateCustomDecorators, errorFormat, ...validatorOptions } = options;
29
35
  // @see [https://github.com/nestjs/nest/issues/10683#issuecomment-1413690508](https://github.com/nestjs/nest/issues/10683#issuecomment-1413690508)
30
36
  this.validatorOptions = { forbidUnknownValues: false, ...validatorOptions };
31
37
  this.isTransformEnabled = !!transform;
32
38
  this.transformOptions = transformOptions;
33
39
  this.isDetailedOutputDisabled = disableErrorMessages;
34
40
  this.validateCustomDecorators = validateCustomDecorators || false;
35
- this.errorHttpStatusCode = errorHttpStatusCode || http_status_enum_1.HttpStatus.BAD_REQUEST;
41
+ this.errorHttpStatusCode = errorHttpStatusCode || HttpStatus.BAD_REQUEST;
36
42
  this.expectedType = expectedType;
43
+ this.errorFormat = errorFormat || 'list';
37
44
  this.exceptionFactory =
38
45
  options.exceptionFactory || this.createExceptionFactory();
39
46
  classValidator = this.loadValidator(options.validatorPackage);
@@ -41,11 +48,11 @@ let ValidationPipe = class ValidationPipe {
41
48
  }
42
49
  loadValidator(validatorPackage) {
43
50
  return (validatorPackage ??
44
- (0, load_package_util_1.loadPackage)('class-validator', 'ValidationPipe', () => require('class-validator')));
51
+ loadPackage('class-validator', 'ValidationPipe', () => import('class-validator')));
45
52
  }
46
53
  loadTransformer(transformerPackage) {
47
54
  return (transformerPackage ??
48
- (0, load_package_util_1.loadPackage)('class-transformer', 'ValidationPipe', () => require('class-transformer')));
55
+ loadPackage('class-transformer', 'ValidationPipe', () => import('class-transformer')));
49
56
  }
50
57
  async transform(value, metadata) {
51
58
  if (this.expectedType) {
@@ -57,6 +64,8 @@ let ValidationPipe = class ValidationPipe {
57
64
  ? this.transformPrimitive(value, metadata)
58
65
  : value;
59
66
  }
67
+ classValidator = (await classValidator);
68
+ classTransformer = (await classTransformer);
60
69
  const originalValue = value;
61
70
  value = this.toEmptyIfNil(value, metatype);
62
71
  const isNil = value !== originalValue;
@@ -106,10 +115,16 @@ let ValidationPipe = class ValidationPipe {
106
115
  createExceptionFactory() {
107
116
  return (validationErrors = []) => {
108
117
  if (this.isDetailedOutputDisabled) {
109
- return new http_error_by_code_util_1.HttpErrorByCode[this.errorHttpStatusCode]();
118
+ return new HttpErrorByCode[this.errorHttpStatusCode]();
119
+ }
120
+ if (this.errorFormat === 'grouped') {
121
+ const errors = this.groupValidationErrors(validationErrors);
122
+ return new HttpErrorByCode[this.errorHttpStatusCode]({
123
+ message: errors,
124
+ });
110
125
  }
111
126
  const errors = this.flattenValidationErrors(validationErrors);
112
- return new http_error_by_code_util_1.HttpErrorByCode[this.errorHttpStatusCode](errors);
127
+ return new HttpErrorByCode[this.errorHttpStatusCode](errors);
113
128
  };
114
129
  }
115
130
  toValidate(metadata) {
@@ -118,7 +133,7 @@ let ValidationPipe = class ValidationPipe {
118
133
  return false;
119
134
  }
120
135
  const types = [String, Boolean, Number, Array, Object, Buffer, Date];
121
- return !types.some(t => metatype === t) && !(0, shared_utils_1.isNil)(metatype);
136
+ return !types.some(t => metatype === t) && !isNil(metatype);
122
137
  }
123
138
  transformPrimitive(value, metadata) {
124
139
  if (!metadata.data) {
@@ -130,7 +145,7 @@ let ValidationPipe = class ValidationPipe {
130
145
  return value;
131
146
  }
132
147
  if (metatype === Boolean) {
133
- if ((0, shared_utils_1.isUndefined)(value)) {
148
+ if (isUndefined(value)) {
134
149
  // This is an workaround to deal with optional boolean values since
135
150
  // optional booleans shouldn't be parsed to a valid boolean when
136
151
  // they were not defined
@@ -140,7 +155,7 @@ let ValidationPipe = class ValidationPipe {
140
155
  return value === true || value === 'true';
141
156
  }
142
157
  if (metatype === Number) {
143
- if ((0, shared_utils_1.isUndefined)(value)) {
158
+ if (isUndefined(value)) {
144
159
  // This is a workaround to deal with optional numeric values since
145
160
  // optional numerics shouldn't be parsed to a valid number when
146
161
  // they were not defined
@@ -148,13 +163,13 @@ let ValidationPipe = class ValidationPipe {
148
163
  }
149
164
  return +value;
150
165
  }
151
- if (metatype === String && !(0, shared_utils_1.isUndefined)(value)) {
166
+ if (metatype === String && !isUndefined(value)) {
152
167
  return String(value);
153
168
  }
154
169
  return value;
155
170
  }
156
171
  toEmptyIfNil(value, metatype) {
157
- if (!(0, shared_utils_1.isNil)(value)) {
172
+ if (!isNil(value)) {
158
173
  return value;
159
174
  }
160
175
  if (typeof metatype === 'function' ||
@@ -170,7 +185,7 @@ let ValidationPipe = class ValidationPipe {
170
185
  stripProtoKeys(value) {
171
186
  if (value == null ||
172
187
  typeof value !== 'object' ||
173
- util_1.types.isTypedArray(value)) {
188
+ types.isTypedArray(value)) {
174
189
  return;
175
190
  }
176
191
  // Skip built-in JavaScript primitives to avoid Jest useFakeTimers conflicts
@@ -202,7 +217,7 @@ let ValidationPipe = class ValidationPipe {
202
217
  return classValidator.validate(object, validatorOptions);
203
218
  }
204
219
  flattenValidationErrors(validationErrors) {
205
- return (0, iterare_1.iterate)(validationErrors)
220
+ return iterate(validationErrors)
206
221
  .map(error => this.mapChildrenToValidationErrors(error))
207
222
  .flatten()
208
223
  .filter(item => !!item.constraints)
@@ -210,6 +225,21 @@ let ValidationPipe = class ValidationPipe {
210
225
  .flatten()
211
226
  .toArray();
212
227
  }
228
+ groupValidationErrors(validationErrors, parentPath) {
229
+ const result = {};
230
+ for (const error of validationErrors) {
231
+ const path = parentPath
232
+ ? `${parentPath}.${error.property}`
233
+ : error.property;
234
+ if (error.constraints) {
235
+ result[path] = Object.values(error.constraints);
236
+ }
237
+ if (error.children && error.children.length) {
238
+ Object.assign(result, this.groupValidationErrors(error.children, path));
239
+ }
240
+ }
241
+ return result;
242
+ }
213
243
  mapChildrenToValidationErrors(error, parentPath) {
214
244
  if (!(error.children && error.children.length)) {
215
245
  return [error];
@@ -237,9 +267,9 @@ let ValidationPipe = class ValidationPipe {
237
267
  };
238
268
  }
239
269
  };
240
- exports.ValidationPipe = ValidationPipe;
241
- exports.ValidationPipe = ValidationPipe = tslib_1.__decorate([
242
- (0, core_1.Injectable)(),
243
- tslib_1.__param(0, (0, decorators_1.Optional)()),
244
- tslib_1.__metadata("design:paramtypes", [Object])
270
+ ValidationPipe = __decorate([
271
+ Injectable(),
272
+ __param(0, Optional()),
273
+ __metadata("design:paramtypes", [Object])
245
274
  ], ValidationPipe);
275
+ export { ValidationPipe };
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CLASS_SERIALIZER_OPTIONS = void 0;
4
- exports.CLASS_SERIALIZER_OPTIONS = 'class_serializer:options';
1
+ export const CLASS_SERIALIZER_OPTIONS = 'class_serializer:options';
@@ -1,8 +1,8 @@
1
- import { ClassSerializerContextOptions } from './class-serializer.interfaces';
2
1
  import { Observable } from 'rxjs';
3
- import { CallHandler, ExecutionContext, NestInterceptor } from '../interfaces';
4
- import { ClassTransformOptions } from '../interfaces/external/class-transform-options.interface';
5
- import { TransformerPackage } from '../interfaces/external/transformer-package.interface';
2
+ import { ClassTransformOptions } from '../interfaces/external/class-transform-options.interface.js';
3
+ import { TransformerPackage } from '../interfaces/external/transformer-package.interface.js';
4
+ import { CallHandler, ExecutionContext, NestInterceptor } from '../interfaces/index.js';
5
+ import { ClassSerializerContextOptions } from './class-serializer.interfaces.js';
6
6
  export interface PlainLiteralObject {
7
7
  [key: string]: any;
8
8
  }
@@ -19,7 +19,7 @@ export declare class ClassSerializerInterceptor implements NestInterceptor {
19
19
  protected readonly reflector: any;
20
20
  protected readonly defaultOptions: ClassSerializerInterceptorOptions;
21
21
  constructor(reflector: any, defaultOptions?: ClassSerializerInterceptorOptions);
22
- intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
22
+ intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<any>>;
23
23
  /**
24
24
  * Serializes responses that are non-null objects nor streamable files.
25
25
  */