@depup/nestjs__common 11.1.16-depup.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/LICENSE +22 -0
  2. package/PACKAGE.md +1 -0
  3. package/Readme.md +31 -0
  4. package/changes.json +10 -0
  5. package/constants.d.ts +42 -0
  6. package/constants.js +44 -0
  7. package/decorators/core/apply-decorators.d.ts +10 -0
  8. package/decorators/core/apply-decorators.js +23 -0
  9. package/decorators/core/bind.decorator.d.ts +11 -0
  10. package/decorators/core/bind.decorator.js +19 -0
  11. package/decorators/core/catch.decorator.d.ts +19 -0
  12. package/decorators/core/catch.decorator.js +27 -0
  13. package/decorators/core/controller.decorator.d.ts +102 -0
  14. package/decorators/core/controller.decorator.js +61 -0
  15. package/decorators/core/dependencies.decorator.d.ts +7 -0
  16. package/decorators/core/dependencies.decorator.js +23 -0
  17. package/decorators/core/exception-filters.decorator.d.ts +23 -0
  18. package/decorators/core/exception-filters.decorator.js +43 -0
  19. package/decorators/core/index.d.ts +14 -0
  20. package/decorators/core/index.js +17 -0
  21. package/decorators/core/inject.decorator.d.ts +31 -0
  22. package/decorators/core/inject.decorator.js +53 -0
  23. package/decorators/core/injectable.decorator.d.ts +43 -0
  24. package/decorators/core/injectable.decorator.js +50 -0
  25. package/decorators/core/optional.decorator.d.ts +14 -0
  26. package/decorators/core/optional.decorator.js +29 -0
  27. package/decorators/core/set-metadata.decorator.d.ts +20 -0
  28. package/decorators/core/set-metadata.decorator.js +32 -0
  29. package/decorators/core/use-guards.decorator.d.ts +23 -0
  30. package/decorators/core/use-guards.decorator.js +41 -0
  31. package/decorators/core/use-interceptors.decorator.d.ts +23 -0
  32. package/decorators/core/use-interceptors.decorator.js +42 -0
  33. package/decorators/core/use-pipes.decorator.d.ts +23 -0
  34. package/decorators/core/use-pipes.decorator.js +40 -0
  35. package/decorators/core/version.decorator.d.ts +7 -0
  36. package/decorators/core/version.decorator.js +19 -0
  37. package/decorators/http/create-route-param-metadata.decorator.d.ts +13 -0
  38. package/decorators/http/create-route-param-metadata.decorator.js +32 -0
  39. package/decorators/http/header.decorator.d.ts +15 -0
  40. package/decorators/http/header.decorator.js +25 -0
  41. package/decorators/http/http-code.decorator.d.ts +11 -0
  42. package/decorators/http/http-code.decorator.js +20 -0
  43. package/decorators/http/index.d.ts +8 -0
  44. package/decorators/http/index.js +11 -0
  45. package/decorators/http/redirect.decorator.d.ts +6 -0
  46. package/decorators/http/redirect.decorator.js +15 -0
  47. package/decorators/http/render.decorator.d.ts +12 -0
  48. package/decorators/http/render.decorator.js +21 -0
  49. package/decorators/http/request-mapping.decorator.d.ts +134 -0
  50. package/decorators/http/request-mapping.decorator.js +154 -0
  51. package/decorators/http/route-params.decorator.d.ts +445 -0
  52. package/decorators/http/route-params.decorator.js +265 -0
  53. package/decorators/http/sse.decorator.d.ts +10 -0
  54. package/decorators/http/sse.decorator.js +21 -0
  55. package/decorators/index.d.ts +3 -0
  56. package/decorators/index.js +6 -0
  57. package/decorators/modules/global.decorator.d.ts +12 -0
  58. package/decorators/modules/global.decorator.js +20 -0
  59. package/decorators/modules/index.d.ts +2 -0
  60. package/decorators/modules/index.js +5 -0
  61. package/decorators/modules/module.decorator.d.ts +16 -0
  62. package/decorators/modules/module.decorator.js +29 -0
  63. package/enums/http-status.enum.d.ts +60 -0
  64. package/enums/http-status.enum.js +64 -0
  65. package/enums/index.d.ts +4 -0
  66. package/enums/index.js +7 -0
  67. package/enums/request-method.enum.d.ts +18 -0
  68. package/enums/request-method.enum.js +22 -0
  69. package/enums/route-paramtypes.enum.d.ts +16 -0
  70. package/enums/route-paramtypes.enum.js +20 -0
  71. package/enums/shutdown-signal.enum.d.ts +16 -0
  72. package/enums/shutdown-signal.enum.js +20 -0
  73. package/enums/version-type.enum.d.ts +9 -0
  74. package/enums/version-type.enum.js +13 -0
  75. package/exceptions/bad-gateway.exception.d.ts +35 -0
  76. package/exceptions/bad-gateway.exception.js +43 -0
  77. package/exceptions/bad-request.exception.d.ts +35 -0
  78. package/exceptions/bad-request.exception.js +43 -0
  79. package/exceptions/conflict.exception.d.ts +35 -0
  80. package/exceptions/conflict.exception.js +43 -0
  81. package/exceptions/forbidden.exception.d.ts +35 -0
  82. package/exceptions/forbidden.exception.js +43 -0
  83. package/exceptions/gateway-timeout.exception.d.ts +35 -0
  84. package/exceptions/gateway-timeout.exception.js +43 -0
  85. package/exceptions/gone.exception.d.ts +35 -0
  86. package/exceptions/gone.exception.js +43 -0
  87. package/exceptions/http-version-not-supported.exception.d.ts +35 -0
  88. package/exceptions/http-version-not-supported.exception.js +43 -0
  89. package/exceptions/http.exception.d.ts +85 -0
  90. package/exceptions/http.exception.js +133 -0
  91. package/exceptions/im-a-teapot.exception.d.ts +38 -0
  92. package/exceptions/im-a-teapot.exception.js +46 -0
  93. package/exceptions/index.d.ts +23 -0
  94. package/exceptions/index.js +26 -0
  95. package/exceptions/internal-server-error.exception.d.ts +35 -0
  96. package/exceptions/internal-server-error.exception.js +43 -0
  97. package/exceptions/intrinsic.exception.d.ts +8 -0
  98. package/exceptions/intrinsic.exception.js +12 -0
  99. package/exceptions/method-not-allowed.exception.d.ts +35 -0
  100. package/exceptions/method-not-allowed.exception.js +43 -0
  101. package/exceptions/misdirected.exception.d.ts +35 -0
  102. package/exceptions/misdirected.exception.js +43 -0
  103. package/exceptions/not-acceptable.exception.d.ts +35 -0
  104. package/exceptions/not-acceptable.exception.js +43 -0
  105. package/exceptions/not-found.exception.d.ts +35 -0
  106. package/exceptions/not-found.exception.js +43 -0
  107. package/exceptions/not-implemented.exception.d.ts +35 -0
  108. package/exceptions/not-implemented.exception.js +43 -0
  109. package/exceptions/payload-too-large.exception.d.ts +35 -0
  110. package/exceptions/payload-too-large.exception.js +43 -0
  111. package/exceptions/precondition-failed.exception.d.ts +35 -0
  112. package/exceptions/precondition-failed.exception.js +43 -0
  113. package/exceptions/request-timeout.exception.d.ts +35 -0
  114. package/exceptions/request-timeout.exception.js +43 -0
  115. package/exceptions/service-unavailable.exception.d.ts +35 -0
  116. package/exceptions/service-unavailable.exception.js +43 -0
  117. package/exceptions/unauthorized.exception.d.ts +35 -0
  118. package/exceptions/unauthorized.exception.js +43 -0
  119. package/exceptions/unprocessable-entity.exception.d.ts +35 -0
  120. package/exceptions/unprocessable-entity.exception.js +43 -0
  121. package/exceptions/unsupported-media-type.exception.d.ts +35 -0
  122. package/exceptions/unsupported-media-type.exception.js +43 -0
  123. package/file-stream/index.d.ts +1 -0
  124. package/file-stream/index.js +4 -0
  125. package/file-stream/interfaces/index.d.ts +2 -0
  126. package/file-stream/interfaces/index.js +5 -0
  127. package/file-stream/interfaces/streamable-handler-response.interface.d.ts +12 -0
  128. package/file-stream/interfaces/streamable-handler-response.interface.js +2 -0
  129. package/file-stream/interfaces/streamable-options.interface.d.ts +22 -0
  130. package/file-stream/interfaces/streamable-options.interface.js +2 -0
  131. package/file-stream/streamable-file.d.ts +27 -0
  132. package/file-stream/streamable-file.js +68 -0
  133. package/index.d.ts +11 -0
  134. package/index.js +23 -0
  135. package/interfaces/abstract.interface.d.ts +3 -0
  136. package/interfaces/abstract.interface.js +2 -0
  137. package/interfaces/controllers/controller-metadata.interface.d.ts +3 -0
  138. package/interfaces/controllers/controller-metadata.interface.js +2 -0
  139. package/interfaces/controllers/controller.interface.d.ts +1 -0
  140. package/interfaces/controllers/controller.interface.js +2 -0
  141. package/interfaces/controllers/index.d.ts +2 -0
  142. package/interfaces/controllers/index.js +5 -0
  143. package/interfaces/exceptions/exception-filter-metadata.interface.d.ts +6 -0
  144. package/interfaces/exceptions/exception-filter-metadata.interface.js +2 -0
  145. package/interfaces/exceptions/exception-filter.interface.d.ts +18 -0
  146. package/interfaces/exceptions/exception-filter.interface.js +2 -0
  147. package/interfaces/exceptions/index.d.ts +5 -0
  148. package/interfaces/exceptions/index.js +8 -0
  149. package/interfaces/exceptions/rpc-exception-filter-metadata.interface.d.ts +6 -0
  150. package/interfaces/exceptions/rpc-exception-filter-metadata.interface.js +2 -0
  151. package/interfaces/exceptions/rpc-exception-filter.interface.d.ts +19 -0
  152. package/interfaces/exceptions/rpc-exception-filter.interface.js +2 -0
  153. package/interfaces/exceptions/ws-exception-filter.interface.d.ts +18 -0
  154. package/interfaces/exceptions/ws-exception-filter.interface.js +2 -0
  155. package/interfaces/external/class-transform-options.interface.d.ts +65 -0
  156. package/interfaces/external/class-transform-options.interface.js +2 -0
  157. package/interfaces/external/cors-options.interface.d.ts +58 -0
  158. package/interfaces/external/cors-options.interface.js +2 -0
  159. package/interfaces/external/https-options.interface.d.ts +105 -0
  160. package/interfaces/external/https-options.interface.js +2 -0
  161. package/interfaces/external/transformer-package.interface.d.ts +6 -0
  162. package/interfaces/external/transformer-package.interface.js +2 -0
  163. package/interfaces/external/validation-error.interface.d.ts +42 -0
  164. package/interfaces/external/validation-error.interface.js +2 -0
  165. package/interfaces/external/validator-options.interface.d.ts +76 -0
  166. package/interfaces/external/validator-options.interface.js +2 -0
  167. package/interfaces/external/validator-package.interface.d.ts +5 -0
  168. package/interfaces/external/validator-package.interface.js +2 -0
  169. package/interfaces/features/arguments-host.interface.d.ts +88 -0
  170. package/interfaces/features/arguments-host.interface.js +2 -0
  171. package/interfaces/features/can-activate.interface.d.ts +22 -0
  172. package/interfaces/features/can-activate.interface.js +2 -0
  173. package/interfaces/features/custom-route-param-factory.interface.d.ts +5 -0
  174. package/interfaces/features/custom-route-param-factory.interface.js +2 -0
  175. package/interfaces/features/execution-context.interface.d.ts +20 -0
  176. package/interfaces/features/execution-context.interface.js +2 -0
  177. package/interfaces/features/nest-interceptor.interface.d.ts +34 -0
  178. package/interfaces/features/nest-interceptor.interface.js +2 -0
  179. package/interfaces/features/paramtype.interface.d.ts +4 -0
  180. package/interfaces/features/paramtype.interface.js +2 -0
  181. package/interfaces/features/pipe-transform.interface.d.ts +42 -0
  182. package/interfaces/features/pipe-transform.interface.js +2 -0
  183. package/interfaces/global-prefix-options.interface.d.ts +7 -0
  184. package/interfaces/global-prefix-options.interface.js +2 -0
  185. package/interfaces/hooks/before-application-shutdown.interface.d.ts +3 -0
  186. package/interfaces/hooks/before-application-shutdown.interface.js +2 -0
  187. package/interfaces/hooks/index.d.ts +5 -0
  188. package/interfaces/hooks/index.js +8 -0
  189. package/interfaces/hooks/on-application-bootstrap.interface.d.ts +11 -0
  190. package/interfaces/hooks/on-application-bootstrap.interface.js +2 -0
  191. package/interfaces/hooks/on-application-shutdown.interface.d.ts +11 -0
  192. package/interfaces/hooks/on-application-shutdown.interface.js +2 -0
  193. package/interfaces/hooks/on-destroy.interface.d.ts +12 -0
  194. package/interfaces/hooks/on-destroy.interface.js +2 -0
  195. package/interfaces/hooks/on-init.interface.d.ts +10 -0
  196. package/interfaces/hooks/on-init.interface.js +2 -0
  197. package/interfaces/http/http-exception-body.interface.d.ts +6 -0
  198. package/interfaces/http/http-exception-body.interface.js +2 -0
  199. package/interfaces/http/http-redirect-response.interface.d.ts +5 -0
  200. package/interfaces/http/http-redirect-response.interface.js +2 -0
  201. package/interfaces/http/http-server.interface.d.ts +70 -0
  202. package/interfaces/http/http-server.interface.js +2 -0
  203. package/interfaces/http/index.d.ts +5 -0
  204. package/interfaces/http/index.js +8 -0
  205. package/interfaces/http/message-event.interface.d.ts +6 -0
  206. package/interfaces/http/message-event.interface.js +2 -0
  207. package/interfaces/http/raw-body-request.interface.d.ts +6 -0
  208. package/interfaces/http/raw-body-request.interface.js +2 -0
  209. package/interfaces/index.d.ts +30 -0
  210. package/interfaces/index.js +33 -0
  211. package/interfaces/injectable.interface.d.ts +1 -0
  212. package/interfaces/injectable.interface.js +2 -0
  213. package/interfaces/microservices/nest-hybrid-application-options.interface.d.ts +7 -0
  214. package/interfaces/microservices/nest-hybrid-application-options.interface.js +2 -0
  215. package/interfaces/microservices/nest-microservice-options.interface.d.ts +5 -0
  216. package/interfaces/microservices/nest-microservice-options.interface.js +2 -0
  217. package/interfaces/middleware/index.d.ts +4 -0
  218. package/interfaces/middleware/index.js +7 -0
  219. package/interfaces/middleware/middleware-config-proxy.interface.d.ts +24 -0
  220. package/interfaces/middleware/middleware-config-proxy.interface.js +2 -0
  221. package/interfaces/middleware/middleware-configuration.interface.d.ts +12 -0
  222. package/interfaces/middleware/middleware-configuration.interface.js +2 -0
  223. package/interfaces/middleware/middleware-consumer.interface.d.ts +18 -0
  224. package/interfaces/middleware/middleware-consumer.interface.js +2 -0
  225. package/interfaces/middleware/nest-middleware.interface.d.ts +8 -0
  226. package/interfaces/middleware/nest-middleware.interface.js +2 -0
  227. package/interfaces/modules/dynamic-module.interface.d.ts +25 -0
  228. package/interfaces/modules/dynamic-module.interface.js +2 -0
  229. package/interfaces/modules/forward-reference.interface.d.ts +3 -0
  230. package/interfaces/modules/forward-reference.interface.js +2 -0
  231. package/interfaces/modules/index.d.ts +8 -0
  232. package/interfaces/modules/index.js +11 -0
  233. package/interfaces/modules/injection-token.interface.d.ts +6 -0
  234. package/interfaces/modules/injection-token.interface.js +2 -0
  235. package/interfaces/modules/introspection-result.interface.d.ts +10 -0
  236. package/interfaces/modules/introspection-result.interface.js +2 -0
  237. package/interfaces/modules/module-metadata.interface.d.ts +34 -0
  238. package/interfaces/modules/module-metadata.interface.js +2 -0
  239. package/interfaces/modules/nest-module.interface.d.ts +7 -0
  240. package/interfaces/modules/nest-module.interface.js +2 -0
  241. package/interfaces/modules/optional-factory-dependency.interface.d.ts +8 -0
  242. package/interfaces/modules/optional-factory-dependency.interface.js +2 -0
  243. package/interfaces/modules/provider.interface.d.ts +156 -0
  244. package/interfaces/modules/provider.interface.js +2 -0
  245. package/interfaces/nest-application-context-options.interface.d.ts +68 -0
  246. package/interfaces/nest-application-context-options.interface.js +9 -0
  247. package/interfaces/nest-application-context.interface.d.ts +139 -0
  248. package/interfaces/nest-application-context.interface.js +2 -0
  249. package/interfaces/nest-application-options.interface.d.ts +29 -0
  250. package/interfaces/nest-application-options.interface.js +2 -0
  251. package/interfaces/nest-application.interface.d.ts +135 -0
  252. package/interfaces/nest-application.interface.js +2 -0
  253. package/interfaces/nest-microservice.interface.d.ts +75 -0
  254. package/interfaces/nest-microservice.interface.js +2 -0
  255. package/interfaces/scope-options.interface.d.ts +37 -0
  256. package/interfaces/scope-options.interface.js +23 -0
  257. package/interfaces/shutdown-hooks-options.interface.d.ts +21 -0
  258. package/interfaces/shutdown-hooks-options.interface.js +2 -0
  259. package/interfaces/type.interface.d.ts +3 -0
  260. package/interfaces/type.interface.js +2 -0
  261. package/interfaces/version-options.interface.d.ts +92 -0
  262. package/interfaces/version-options.interface.js +9 -0
  263. package/interfaces/websockets/web-socket-adapter.interface.d.ts +19 -0
  264. package/interfaces/websockets/web-socket-adapter.interface.js +2 -0
  265. package/module-utils/configurable-module.builder.d.ts +93 -0
  266. package/module-utils/configurable-module.builder.js +219 -0
  267. package/module-utils/constants.d.ts +9 -0
  268. package/module-utils/constants.js +19 -0
  269. package/module-utils/index.d.ts +2 -0
  270. package/module-utils/index.js +5 -0
  271. package/module-utils/interfaces/configurable-module-async-options.interface.d.ts +42 -0
  272. package/module-utils/interfaces/configurable-module-async-options.interface.js +2 -0
  273. package/module-utils/interfaces/configurable-module-cls.interface.d.ts +13 -0
  274. package/module-utils/interfaces/configurable-module-cls.interface.js +2 -0
  275. package/module-utils/interfaces/configurable-module-host.interface.d.ts +62 -0
  276. package/module-utils/interfaces/configurable-module-host.interface.js +2 -0
  277. package/module-utils/interfaces/index.d.ts +3 -0
  278. package/module-utils/interfaces/index.js +6 -0
  279. package/module-utils/utils/generate-options-injection-token.util.d.ts +1 -0
  280. package/module-utils/utils/generate-options-injection-token.util.js +8 -0
  281. package/module-utils/utils/get-injection-providers.util.d.ts +8 -0
  282. package/module-utils/utils/get-injection-providers.util.js +35 -0
  283. package/module-utils/utils/index.d.ts +2 -0
  284. package/module-utils/utils/index.js +5 -0
  285. package/package.json +61 -0
  286. package/pipes/default-value.pipe.d.ts +13 -0
  287. package/pipes/default-value.pipe.js +30 -0
  288. package/pipes/file/file-type.validator.d.ts +62 -0
  289. package/pipes/file/file-type.validator.js +102 -0
  290. package/pipes/file/file-validator-context.interface.d.ts +5 -0
  291. package/pipes/file/file-validator-context.interface.js +2 -0
  292. package/pipes/file/file-validator.interface.d.ts +21 -0
  293. package/pipes/file/file-validator.interface.js +15 -0
  294. package/pipes/file/index.d.ts +6 -0
  295. package/pipes/file/index.js +9 -0
  296. package/pipes/file/interfaces/file.interface.d.ts +5 -0
  297. package/pipes/file/interfaces/file.interface.js +2 -0
  298. package/pipes/file/interfaces/index.d.ts +1 -0
  299. package/pipes/file/interfaces/index.js +4 -0
  300. package/pipes/file/max-file-size.validator.d.ts +44 -0
  301. package/pipes/file/max-file-size.validator.js +37 -0
  302. package/pipes/file/parse-file-options.interface.d.ts +15 -0
  303. package/pipes/file/parse-file-options.interface.js +2 -0
  304. package/pipes/file/parse-file-pipe.builder.d.ts +15 -0
  305. package/pipes/file/parse-file-pipe.builder.js +33 -0
  306. package/pipes/file/parse-file.pipe.d.ts +28 -0
  307. package/pipes/file/parse-file.pipe.js +76 -0
  308. package/pipes/index.d.ts +10 -0
  309. package/pipes/index.js +13 -0
  310. package/pipes/parse-array.pipe.d.ts +52 -0
  311. package/pipes/parse-array.pipe.js +148 -0
  312. package/pipes/parse-bool.pipe.d.ts +55 -0
  313. package/pipes/parse-bool.pipe.js +67 -0
  314. package/pipes/parse-date.pipe.d.ts +37 -0
  315. package/pipes/parse-date.pipe.js +42 -0
  316. package/pipes/parse-enum.pipe.d.ts +46 -0
  317. package/pipes/parse-enum.pipe.js +55 -0
  318. package/pipes/parse-float.pipe.d.ts +49 -0
  319. package/pipes/parse-float.pipe.js +56 -0
  320. package/pipes/parse-int.pipe.d.ts +48 -0
  321. package/pipes/parse-int.pipe.js +57 -0
  322. package/pipes/parse-uuid.pipe.d.ts +49 -0
  323. package/pipes/parse-uuid.pipe.js +57 -0
  324. package/pipes/validation.pipe.d.ts +51 -0
  325. package/pipes/validation.pipe.js +245 -0
  326. package/serializer/class-serializer.constants.d.ts +1 -0
  327. package/serializer/class-serializer.constants.js +4 -0
  328. package/serializer/class-serializer.interceptor.d.ts +29 -0
  329. package/serializer/class-serializer.interceptor.js +77 -0
  330. package/serializer/class-serializer.interfaces.d.ts +8 -0
  331. package/serializer/class-serializer.interfaces.js +2 -0
  332. package/serializer/decorators/index.d.ts +1 -0
  333. package/serializer/decorators/index.js +4 -0
  334. package/serializer/decorators/serialize-options.decorator.d.ts +5 -0
  335. package/serializer/decorators/serialize-options.decorator.js +10 -0
  336. package/serializer/index.d.ts +3 -0
  337. package/serializer/index.js +6 -0
  338. package/services/console-logger.service.d.ts +202 -0
  339. package/services/console-logger.service.js +379 -0
  340. package/services/index.d.ts +3 -0
  341. package/services/index.js +6 -0
  342. package/services/logger.service.d.ts +152 -0
  343. package/services/logger.service.js +251 -0
  344. package/services/utils/filter-log-levels.util.d.ts +5 -0
  345. package/services/utils/filter-log-levels.util.js +23 -0
  346. package/services/utils/index.d.ts +3 -0
  347. package/services/utils/index.js +6 -0
  348. package/services/utils/is-log-level-enabled.util.d.ts +7 -0
  349. package/services/utils/is-log-level-enabled.util.js +32 -0
  350. package/services/utils/is-log-level.util.d.ts +5 -0
  351. package/services/utils/is-log-level.util.js +10 -0
  352. package/tsconfig.build.json +10 -0
  353. package/utils/assign-custom-metadata.util.d.ts +4 -0
  354. package/utils/assign-custom-metadata.util.js +15 -0
  355. package/utils/cli-colors.util.d.ts +10 -0
  356. package/utils/cli-colors.util.js +15 -0
  357. package/utils/extend-metadata.util.d.ts +1 -0
  358. package/utils/extend-metadata.util.js +8 -0
  359. package/utils/forward-ref.util.d.ts +5 -0
  360. package/utils/forward-ref.util.js +10 -0
  361. package/utils/http-error-by-code.util.d.ts +4 -0
  362. package/utils/http-error-by-code.util.js +26 -0
  363. package/utils/index.d.ts +1 -0
  364. package/utils/index.js +4 -0
  365. package/utils/load-package.util.d.ts +1 -0
  366. package/utils/load-package.util.js +16 -0
  367. package/utils/merge-with-values.util.d.ts +4 -0
  368. package/utils/merge-with-values.util.js +18 -0
  369. package/utils/random-string-generator.util.d.ts +1 -0
  370. package/utils/random-string-generator.util.js +6 -0
  371. package/utils/select-exception-filter-metadata.util.d.ts +2 -0
  372. package/utils/select-exception-filter-metadata.util.js +6 -0
  373. package/utils/shared.utils.d.ts +13 -0
  374. package/utils/shared.utils.js +51 -0
  375. package/utils/validate-each.util.d.ts +8 -0
  376. package/utils/validate-each.util.js +25 -0
  377. package/utils/validate-module-keys.util.d.ts +2 -0
  378. package/utils/validate-module-keys.util.js +22 -0
@@ -0,0 +1,49 @@
1
+ import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
2
+ import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
3
+ /**
4
+ * @publicApi
5
+ */
6
+ export interface ParseUUIDPipeOptions {
7
+ /**
8
+ * UUID version to validate
9
+ */
10
+ version?: '3' | '4' | '5' | '7';
11
+ /**
12
+ * The HTTP status code to be used in the response when the validation fails.
13
+ */
14
+ errorHttpStatusCode?: ErrorHttpStatusCode;
15
+ /**
16
+ * A factory function that returns an exception object to be thrown
17
+ * if validation fails.
18
+ * @param error Error message
19
+ * @returns The exception object
20
+ */
21
+ exceptionFactory?: (errors: string) => any;
22
+ /**
23
+ * If true, the pipe will return null or undefined if the value is not provided
24
+ * @default false
25
+ */
26
+ optional?: boolean;
27
+ }
28
+ /**
29
+ * Defines the built-in ParseUUID Pipe
30
+ *
31
+ * @see [Built-in Pipes](https://docs.nestjs.com/pipes#built-in-pipes)
32
+ *
33
+ * @publicApi
34
+ */
35
+ export declare class ParseUUIDPipe implements PipeTransform<string> {
36
+ protected readonly options?: ParseUUIDPipeOptions | undefined;
37
+ protected static uuidRegExps: {
38
+ 3: RegExp;
39
+ 4: RegExp;
40
+ 5: RegExp;
41
+ 7: RegExp;
42
+ all: RegExp;
43
+ };
44
+ private readonly version;
45
+ protected exceptionFactory: (errors: string) => any;
46
+ constructor(options?: ParseUUIDPipeOptions | undefined);
47
+ transform(value: string, metadata: ArgumentMetadata): Promise<string>;
48
+ protected isUUID(str: unknown, version?: string): any;
49
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ 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");
11
+ /**
12
+ * Defines the built-in ParseUUID Pipe
13
+ *
14
+ * @see [Built-in Pipes](https://docs.nestjs.com/pipes#built-in-pipes)
15
+ *
16
+ * @publicApi
17
+ */
18
+ let ParseUUIDPipe = ParseUUIDPipe_1 = class ParseUUIDPipe {
19
+ constructor(options) {
20
+ this.options = options;
21
+ options = options || {};
22
+ const { exceptionFactory, errorHttpStatusCode = http_status_enum_1.HttpStatus.BAD_REQUEST, version, } = options;
23
+ this.version = version;
24
+ this.exceptionFactory =
25
+ exceptionFactory ||
26
+ (error => new http_error_by_code_util_1.HttpErrorByCode[errorHttpStatusCode](error));
27
+ }
28
+ async transform(value, metadata) {
29
+ if ((0, shared_utils_1.isNil)(value) && this.options?.optional) {
30
+ return value;
31
+ }
32
+ if (!this.isUUID(value, this.version)) {
33
+ throw this.exceptionFactory(`Validation failed (uuid${this.version ? ` v ${this.version}` : ''} is expected)`);
34
+ }
35
+ return value;
36
+ }
37
+ isUUID(str, version = 'all') {
38
+ if (!(0, shared_utils_1.isString)(str)) {
39
+ throw this.exceptionFactory('The value passed as UUID is not a string');
40
+ }
41
+ const pattern = ParseUUIDPipe_1.uuidRegExps[version];
42
+ return pattern?.test(str);
43
+ }
44
+ };
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])
57
+ ], ParseUUIDPipe);
@@ -0,0 +1,51 @@
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';
9
+ /**
10
+ * @publicApi
11
+ */
12
+ export interface ValidationPipeOptions extends ValidatorOptions {
13
+ transform?: boolean;
14
+ disableErrorMessages?: boolean;
15
+ transformOptions?: ClassTransformOptions;
16
+ errorHttpStatusCode?: ErrorHttpStatusCode;
17
+ exceptionFactory?: (errors: ValidationError[]) => any;
18
+ validateCustomDecorators?: boolean;
19
+ expectedType?: Type<any>;
20
+ validatorPackage?: ValidatorPackage;
21
+ transformerPackage?: TransformerPackage;
22
+ }
23
+ /**
24
+ * @see [Validation](https://docs.nestjs.com/techniques/validation)
25
+ *
26
+ * @publicApi
27
+ */
28
+ export declare class ValidationPipe implements PipeTransform<any> {
29
+ protected isTransformEnabled: boolean;
30
+ protected isDetailedOutputDisabled?: boolean;
31
+ protected validatorOptions: ValidatorOptions;
32
+ protected transformOptions: ClassTransformOptions | undefined;
33
+ protected errorHttpStatusCode: ErrorHttpStatusCode;
34
+ protected expectedType: Type<any> | undefined;
35
+ protected exceptionFactory: (errors: ValidationError[]) => any;
36
+ protected validateCustomDecorators: boolean;
37
+ constructor(options?: ValidationPipeOptions);
38
+ protected loadValidator(validatorPackage?: ValidatorPackage): ValidatorPackage;
39
+ protected loadTransformer(transformerPackage?: TransformerPackage): TransformerPackage;
40
+ transform(value: any, metadata: ArgumentMetadata): Promise<any>;
41
+ createExceptionFactory(): (validationErrors?: ValidationError[]) => unknown;
42
+ 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;
45
+ protected stripProtoKeys(value: any): void;
46
+ protected isPrimitive(value: unknown): boolean;
47
+ protected validate(object: object, validatorOptions?: ValidatorOptions): Promise<ValidationError[]> | ValidationError[];
48
+ protected flattenValidationErrors(validationErrors: ValidationError[]): string[];
49
+ protected mapChildrenToValidationErrors(error: ValidationError, parentPath?: string): ValidationError[];
50
+ protected prependConstraintsWithParentProp(parentPath: string, error: ValidationError): ValidationError;
51
+ }
@@ -0,0 +1,245 @@
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");
13
+ let classValidator = {};
14
+ let classTransformer = {};
15
+ /**
16
+ * Built-in JavaScript types that should be excluded from prototype stripping
17
+ * to avoid conflicts with test frameworks like Jest's useFakeTimers
18
+ */
19
+ const BUILT_IN_TYPES = [Date, RegExp, Error, Map, Set, WeakMap, WeakSet];
20
+ /**
21
+ * @see [Validation](https://docs.nestjs.com/techniques/validation)
22
+ *
23
+ * @publicApi
24
+ */
25
+ let ValidationPipe = class ValidationPipe {
26
+ constructor(options) {
27
+ options = options || {};
28
+ const { transform, disableErrorMessages, errorHttpStatusCode, expectedType, transformOptions, validateCustomDecorators, ...validatorOptions } = options;
29
+ // @see [https://github.com/nestjs/nest/issues/10683#issuecomment-1413690508](https://github.com/nestjs/nest/issues/10683#issuecomment-1413690508)
30
+ this.validatorOptions = { forbidUnknownValues: false, ...validatorOptions };
31
+ this.isTransformEnabled = !!transform;
32
+ this.transformOptions = transformOptions;
33
+ this.isDetailedOutputDisabled = disableErrorMessages;
34
+ this.validateCustomDecorators = validateCustomDecorators || false;
35
+ this.errorHttpStatusCode = errorHttpStatusCode || http_status_enum_1.HttpStatus.BAD_REQUEST;
36
+ this.expectedType = expectedType;
37
+ this.exceptionFactory =
38
+ options.exceptionFactory || this.createExceptionFactory();
39
+ classValidator = this.loadValidator(options.validatorPackage);
40
+ classTransformer = this.loadTransformer(options.transformerPackage);
41
+ }
42
+ loadValidator(validatorPackage) {
43
+ return (validatorPackage ??
44
+ (0, load_package_util_1.loadPackage)('class-validator', 'ValidationPipe', () => require('class-validator')));
45
+ }
46
+ loadTransformer(transformerPackage) {
47
+ return (transformerPackage ??
48
+ (0, load_package_util_1.loadPackage)('class-transformer', 'ValidationPipe', () => require('class-transformer')));
49
+ }
50
+ async transform(value, metadata) {
51
+ if (this.expectedType) {
52
+ metadata = { ...metadata, metatype: this.expectedType };
53
+ }
54
+ const metatype = metadata.metatype;
55
+ if (!metatype || !this.toValidate(metadata)) {
56
+ return this.isTransformEnabled
57
+ ? this.transformPrimitive(value, metadata)
58
+ : value;
59
+ }
60
+ const originalValue = value;
61
+ value = this.toEmptyIfNil(value, metatype);
62
+ const isNil = value !== originalValue;
63
+ const isPrimitive = this.isPrimitive(value);
64
+ this.stripProtoKeys(value);
65
+ let entity = classTransformer.plainToInstance(metatype, value, this.transformOptions);
66
+ const originalEntity = entity;
67
+ const isCtorNotEqual = entity.constructor !== metatype;
68
+ if (isCtorNotEqual && !isPrimitive) {
69
+ entity.constructor = metatype;
70
+ }
71
+ else if (isCtorNotEqual) {
72
+ // when "entity" is a primitive value, we have to temporarily
73
+ // replace the entity to perform the validation against the original
74
+ // metatype defined inside the handler
75
+ entity = { constructor: metatype };
76
+ }
77
+ const errors = await this.validate(entity, this.validatorOptions);
78
+ if (errors.length > 0) {
79
+ throw await this.exceptionFactory(errors);
80
+ }
81
+ if (originalValue === undefined && originalEntity === '') {
82
+ // Since SWC requires empty string for validation (to avoid an error),
83
+ // a fallback is needed to revert to the original value (when undefined).
84
+ // @see [https://github.com/nestjs/nest/issues/14430](https://github.com/nestjs/nest/issues/14430)
85
+ return originalValue;
86
+ }
87
+ if (isPrimitive) {
88
+ // if the value is a primitive value and the validation process has been successfully completed
89
+ // we have to revert the original value passed through the pipe
90
+ entity = originalEntity;
91
+ }
92
+ if (this.isTransformEnabled) {
93
+ return entity;
94
+ }
95
+ if (isNil) {
96
+ // if the value was originally undefined or null, revert it back
97
+ return originalValue;
98
+ }
99
+ // we check if the number of keys of the "validatorOptions" is higher than 1 (instead of 0)
100
+ // because the "forbidUnknownValues" now fallbacks to "false" (in case it wasn't explicitly specified)
101
+ const shouldTransformToPlain = Object.keys(this.validatorOptions).length > 1;
102
+ return shouldTransformToPlain
103
+ ? classTransformer.classToPlain(entity, this.transformOptions)
104
+ : value;
105
+ }
106
+ createExceptionFactory() {
107
+ return (validationErrors = []) => {
108
+ if (this.isDetailedOutputDisabled) {
109
+ return new http_error_by_code_util_1.HttpErrorByCode[this.errorHttpStatusCode]();
110
+ }
111
+ const errors = this.flattenValidationErrors(validationErrors);
112
+ return new http_error_by_code_util_1.HttpErrorByCode[this.errorHttpStatusCode](errors);
113
+ };
114
+ }
115
+ toValidate(metadata) {
116
+ const { metatype, type } = metadata;
117
+ if (type === 'custom' && !this.validateCustomDecorators) {
118
+ return false;
119
+ }
120
+ const types = [String, Boolean, Number, Array, Object, Buffer, Date];
121
+ return !types.some(t => metatype === t) && !(0, shared_utils_1.isNil)(metatype);
122
+ }
123
+ transformPrimitive(value, metadata) {
124
+ if (!metadata.data) {
125
+ // leave top-level query/param objects unmodified
126
+ return value;
127
+ }
128
+ const { type, metatype } = metadata;
129
+ if (type !== 'param' && type !== 'query') {
130
+ return value;
131
+ }
132
+ if (metatype === Boolean) {
133
+ if ((0, shared_utils_1.isUndefined)(value)) {
134
+ // This is an workaround to deal with optional boolean values since
135
+ // optional booleans shouldn't be parsed to a valid boolean when
136
+ // they were not defined
137
+ return undefined;
138
+ }
139
+ // Any fasly value but `undefined` will be parsed to `false`
140
+ return value === true || value === 'true';
141
+ }
142
+ if (metatype === Number) {
143
+ if ((0, shared_utils_1.isUndefined)(value)) {
144
+ // This is a workaround to deal with optional numeric values since
145
+ // optional numerics shouldn't be parsed to a valid number when
146
+ // they were not defined
147
+ return undefined;
148
+ }
149
+ return +value;
150
+ }
151
+ if (metatype === String && !(0, shared_utils_1.isUndefined)(value)) {
152
+ return String(value);
153
+ }
154
+ return value;
155
+ }
156
+ toEmptyIfNil(value, metatype) {
157
+ if (!(0, shared_utils_1.isNil)(value)) {
158
+ return value;
159
+ }
160
+ if (typeof metatype === 'function' ||
161
+ (metatype && 'prototype' in metatype && metatype.prototype?.constructor)) {
162
+ return {};
163
+ }
164
+ // SWC requires empty string to be returned instead of an empty object
165
+ // when the value is nil and the metatype is not a class instance, but a plain object (enum, for example).
166
+ // Otherwise, the error will be thrown.
167
+ // @see [https://github.com/nestjs/nest/issues/12680](https://github.com/nestjs/nest/issues/12680)
168
+ return '';
169
+ }
170
+ stripProtoKeys(value) {
171
+ if (value == null ||
172
+ typeof value !== 'object' ||
173
+ util_1.types.isTypedArray(value)) {
174
+ return;
175
+ }
176
+ // Skip built-in JavaScript primitives to avoid Jest useFakeTimers conflicts
177
+ if (BUILT_IN_TYPES.some(type => value instanceof type)) {
178
+ return;
179
+ }
180
+ if (Array.isArray(value)) {
181
+ for (const v of value) {
182
+ this.stripProtoKeys(v);
183
+ }
184
+ return;
185
+ }
186
+ // Delete dangerous prototype pollution keys
187
+ delete value.__proto__;
188
+ delete value.prototype;
189
+ // Only delete constructor if it's NOT a built-in type
190
+ const constructorType = value?.constructor;
191
+ if (constructorType && !BUILT_IN_TYPES.includes(constructorType)) {
192
+ delete value.constructor;
193
+ }
194
+ for (const key in value) {
195
+ this.stripProtoKeys(value[key]);
196
+ }
197
+ }
198
+ isPrimitive(value) {
199
+ return ['number', 'boolean', 'string'].includes(typeof value);
200
+ }
201
+ validate(object, validatorOptions) {
202
+ return classValidator.validate(object, validatorOptions);
203
+ }
204
+ flattenValidationErrors(validationErrors) {
205
+ return (0, iterare_1.iterate)(validationErrors)
206
+ .map(error => this.mapChildrenToValidationErrors(error))
207
+ .flatten()
208
+ .filter(item => !!item.constraints)
209
+ .map(item => Object.values(item.constraints))
210
+ .flatten()
211
+ .toArray();
212
+ }
213
+ mapChildrenToValidationErrors(error, parentPath) {
214
+ if (!(error.children && error.children.length)) {
215
+ return [error];
216
+ }
217
+ const validationErrors = [];
218
+ parentPath = parentPath
219
+ ? `${parentPath}.${error.property}`
220
+ : error.property;
221
+ for (const item of error.children) {
222
+ if (item.children && item.children.length) {
223
+ validationErrors.push(...this.mapChildrenToValidationErrors(item, parentPath));
224
+ }
225
+ validationErrors.push(this.prependConstraintsWithParentProp(parentPath, item));
226
+ }
227
+ return validationErrors;
228
+ }
229
+ prependConstraintsWithParentProp(parentPath, error) {
230
+ const constraints = {};
231
+ for (const key in error.constraints) {
232
+ constraints[key] = `${parentPath}.${error.constraints[key]}`;
233
+ }
234
+ return {
235
+ ...error,
236
+ constraints,
237
+ };
238
+ }
239
+ };
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])
245
+ ], ValidationPipe);
@@ -0,0 +1 @@
1
+ export declare const CLASS_SERIALIZER_OPTIONS = "class_serializer:options";
@@ -0,0 +1,4 @@
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';
@@ -0,0 +1,29 @@
1
+ import { ClassSerializerContextOptions } from './class-serializer.interfaces';
2
+ 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';
6
+ export interface PlainLiteralObject {
7
+ [key: string]: any;
8
+ }
9
+ /**
10
+ * @publicApi
11
+ */
12
+ export interface ClassSerializerInterceptorOptions extends ClassTransformOptions {
13
+ transformerPackage?: TransformerPackage;
14
+ }
15
+ /**
16
+ * @publicApi
17
+ */
18
+ export declare class ClassSerializerInterceptor implements NestInterceptor {
19
+ protected readonly reflector: any;
20
+ protected readonly defaultOptions: ClassSerializerInterceptorOptions;
21
+ constructor(reflector: any, defaultOptions?: ClassSerializerInterceptorOptions);
22
+ intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
23
+ /**
24
+ * Serializes responses that are non-null objects nor streamable files.
25
+ */
26
+ serialize(response: PlainLiteralObject | Array<PlainLiteralObject>, options: ClassSerializerContextOptions): PlainLiteralObject | Array<PlainLiteralObject>;
27
+ transformToPlain(plainOrClass: any, options: ClassSerializerContextOptions): PlainLiteralObject;
28
+ protected getContextOptions(context: ExecutionContext): ClassSerializerContextOptions | undefined;
29
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClassSerializerInterceptor = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const operators_1 = require("rxjs/operators");
6
+ const core_1 = require("../decorators/core");
7
+ const file_stream_1 = require("../file-stream");
8
+ const load_package_util_1 = require("../utils/load-package.util");
9
+ const shared_utils_1 = require("../utils/shared.utils");
10
+ const class_serializer_constants_1 = require("./class-serializer.constants");
11
+ let classTransformer = {};
12
+ // NOTE (external)
13
+ // We need to deduplicate them here due to the circular dependency
14
+ // between core and common packages
15
+ const REFLECTOR = 'Reflector';
16
+ /**
17
+ * @publicApi
18
+ */
19
+ let ClassSerializerInterceptor = class ClassSerializerInterceptor {
20
+ constructor(reflector, defaultOptions = {}) {
21
+ this.reflector = reflector;
22
+ this.defaultOptions = defaultOptions;
23
+ classTransformer =
24
+ defaultOptions?.transformerPackage ??
25
+ (0, load_package_util_1.loadPackage)('class-transformer', 'ClassSerializerInterceptor', () => require('class-transformer'));
26
+ if (!defaultOptions?.transformerPackage) {
27
+ require('class-transformer');
28
+ }
29
+ }
30
+ intercept(context, next) {
31
+ const contextOptions = this.getContextOptions(context);
32
+ const options = {
33
+ ...this.defaultOptions,
34
+ ...contextOptions,
35
+ };
36
+ return next
37
+ .handle()
38
+ .pipe((0, operators_1.map)((res) => this.serialize(res, options)));
39
+ }
40
+ /**
41
+ * Serializes responses that are non-null objects nor streamable files.
42
+ */
43
+ serialize(response, options) {
44
+ if (!(0, shared_utils_1.isObject)(response) || response instanceof file_stream_1.StreamableFile) {
45
+ return response;
46
+ }
47
+ return Array.isArray(response)
48
+ ? response.map(item => this.transformToPlain(item, options))
49
+ : this.transformToPlain(response, options);
50
+ }
51
+ transformToPlain(plainOrClass, options) {
52
+ if (!plainOrClass) {
53
+ return plainOrClass;
54
+ }
55
+ if (!options.type) {
56
+ return classTransformer.classToPlain(plainOrClass, options);
57
+ }
58
+ if (plainOrClass instanceof options.type) {
59
+ return classTransformer.classToPlain(plainOrClass, options);
60
+ }
61
+ const instance = classTransformer.plainToInstance(options.type, plainOrClass, options);
62
+ return classTransformer.classToPlain(instance, options);
63
+ }
64
+ getContextOptions(context) {
65
+ return this.reflector.getAllAndOverride(class_serializer_constants_1.CLASS_SERIALIZER_OPTIONS, [
66
+ context.getHandler(),
67
+ context.getClass(),
68
+ ]);
69
+ }
70
+ };
71
+ exports.ClassSerializerInterceptor = ClassSerializerInterceptor;
72
+ exports.ClassSerializerInterceptor = ClassSerializerInterceptor = tslib_1.__decorate([
73
+ (0, core_1.Injectable)(),
74
+ tslib_1.__param(0, (0, core_1.Inject)(REFLECTOR)),
75
+ tslib_1.__param(1, (0, core_1.Optional)()),
76
+ tslib_1.__metadata("design:paramtypes", [Object, Object])
77
+ ], ClassSerializerInterceptor);
@@ -0,0 +1,8 @@
1
+ import { ClassTransformOptions } from '../interfaces/external/class-transform-options.interface';
2
+ import { Type } from '../interfaces';
3
+ /**
4
+ * @publicApi
5
+ */
6
+ export interface ClassSerializerContextOptions extends ClassTransformOptions {
7
+ type?: Type<any>;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from './serialize-options.decorator';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./serialize-options.decorator"), exports);
@@ -0,0 +1,5 @@
1
+ import { ClassSerializerContextOptions } from '../class-serializer.interfaces';
2
+ /**
3
+ * @publicApi
4
+ */
5
+ export declare const SerializeOptions: (options: ClassSerializerContextOptions) => import("../../decorators").CustomDecorator<string>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SerializeOptions = void 0;
4
+ const decorators_1 = require("../../decorators");
5
+ const class_serializer_constants_1 = require("../class-serializer.constants");
6
+ /**
7
+ * @publicApi
8
+ */
9
+ const SerializeOptions = (options) => (0, decorators_1.SetMetadata)(class_serializer_constants_1.CLASS_SERIALIZER_OPTIONS, options);
10
+ exports.SerializeOptions = SerializeOptions;
@@ -0,0 +1,3 @@
1
+ export * from './class-serializer.interceptor';
2
+ export * from './decorators';
3
+ export * from './class-serializer.interfaces';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./class-serializer.interceptor"), exports);
5
+ tslib_1.__exportStar(require("./decorators"), exports);
6
+ tslib_1.__exportStar(require("./class-serializer.interfaces"), exports);