@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,219 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigurableModuleBuilder = void 0;
4
+ const logger_service_1 = require("../services/logger.service");
5
+ const random_string_generator_util_1 = require("../utils/random-string-generator.util");
6
+ const constants_1 = require("./constants");
7
+ const utils_1 = require("./utils");
8
+ /**
9
+ * Factory that lets you create configurable modules and
10
+ * provides a way to reduce the majority of dynamic module boilerplate.
11
+ *
12
+ * @publicApi
13
+ */
14
+ class ConfigurableModuleBuilder {
15
+ constructor(options = {}, parentBuilder) {
16
+ this.options = options;
17
+ this.logger = new logger_service_1.Logger(ConfigurableModuleBuilder.name);
18
+ if (parentBuilder) {
19
+ this.staticMethodKey = parentBuilder.staticMethodKey;
20
+ this.factoryClassMethodKey =
21
+ parentBuilder.factoryClassMethodKey;
22
+ this.transformModuleDefinition =
23
+ parentBuilder.transformModuleDefinition;
24
+ this.extras = parentBuilder.extras;
25
+ }
26
+ }
27
+ /**
28
+ * Registers the "extras" object (a set of extra options that can be used to modify the dynamic module definition).
29
+ * Values you specify within the "extras" object will be used as default values (that can be overridden by module consumers).
30
+ *
31
+ * This method also applies the so-called "module definition transform function" that takes the auto-generated
32
+ * dynamic module object ("DynamicModule") and the actual consumer "extras" object as input parameters.
33
+ * The "extras" object consists of values explicitly specified by module consumers and default values.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * .setExtras<{ isGlobal?: boolean }>({ isGlobal: false }, (definition, extras) =>
38
+ * ({ ...definition, global: extras.isGlobal })
39
+ * )
40
+ * ```
41
+ */
42
+ setExtras(extras, transformDefinition = def => def) {
43
+ const builder = new ConfigurableModuleBuilder(this.options, this);
44
+ builder.extras = extras;
45
+ builder.transformModuleDefinition = transformDefinition;
46
+ return builder;
47
+ }
48
+ /**
49
+ * Dynamic modules must expose public static methods that let you pass in
50
+ * configuration parameters (control the module's behavior from the outside).
51
+ * Some frequently used names that you may have seen in other modules are:
52
+ * "forRoot", "forFeature", "register", "configure".
53
+ *
54
+ * This method "setClassMethodName" lets you specify the name of the
55
+ * method that will be auto-generated.
56
+ *
57
+ * @param key name of the method
58
+ */
59
+ setClassMethodName(key) {
60
+ const builder = new ConfigurableModuleBuilder(this.options, this);
61
+ builder.staticMethodKey = key;
62
+ return builder;
63
+ }
64
+ /**
65
+ * Asynchronously configured modules (that rely on other modules, i.e. "ConfigModule")
66
+ * let you pass the configuration factory class that will be registered and instantiated as a provider.
67
+ * This provider then will be used to retrieve the module's configuration. To provide the configuration,
68
+ * the corresponding factory method must be implemented.
69
+ *
70
+ * This method ("setFactoryMethodName") lets you control what method name will have to be
71
+ * implemented by the config factory (default is "create").
72
+ *
73
+ * @param key name of the method
74
+ */
75
+ setFactoryMethodName(key) {
76
+ const builder = new ConfigurableModuleBuilder(this.options, this);
77
+ builder.factoryClassMethodKey = key;
78
+ return builder;
79
+ }
80
+ /**
81
+ * Returns an object consisting of multiple properties that lets you
82
+ * easily construct dynamic configurable modules. See "ConfigurableModuleHost" interface for more details.
83
+ */
84
+ build() {
85
+ this.staticMethodKey ??= constants_1.DEFAULT_METHOD_KEY;
86
+ this.factoryClassMethodKey ??=
87
+ constants_1.DEFAULT_FACTORY_CLASS_METHOD_KEY;
88
+ this.options.optionsInjectionToken ??= this.options.moduleName
89
+ ? this.constructInjectionTokenString()
90
+ : (0, utils_1.generateOptionsInjectionToken)();
91
+ this.transformModuleDefinition ??= definition => definition;
92
+ return {
93
+ ConfigurableModuleClass: this.createConfigurableModuleCls(),
94
+ MODULE_OPTIONS_TOKEN: this.options.optionsInjectionToken,
95
+ ASYNC_OPTIONS_TYPE: this.createTypeProxy('ASYNC_OPTIONS_TYPE'),
96
+ OPTIONS_TYPE: this.createTypeProxy('OPTIONS_TYPE'),
97
+ };
98
+ }
99
+ constructInjectionTokenString() {
100
+ const moduleNameInSnakeCase = this.options
101
+ .moduleName.trim()
102
+ .split(/(?=[A-Z])/)
103
+ .join('_')
104
+ .toUpperCase();
105
+ return `${moduleNameInSnakeCase}_MODULE_OPTIONS`;
106
+ }
107
+ createConfigurableModuleCls() {
108
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
109
+ const self = this;
110
+ const asyncMethodKey = this.staticMethodKey + constants_1.ASYNC_METHOD_SUFFIX;
111
+ class InternalModuleClass {
112
+ static [self.staticMethodKey](options) {
113
+ const providers = [
114
+ {
115
+ provide: self.options.optionsInjectionToken,
116
+ useValue: this.omitExtras(options, self.extras),
117
+ },
118
+ ];
119
+ if (self.options.alwaysTransient) {
120
+ providers.push({
121
+ provide: constants_1.CONFIGURABLE_MODULE_ID,
122
+ useValue: (0, random_string_generator_util_1.randomStringGenerator)(),
123
+ });
124
+ }
125
+ return self.transformModuleDefinition({
126
+ module: this,
127
+ providers,
128
+ }, {
129
+ ...self.extras,
130
+ ...options,
131
+ });
132
+ }
133
+ static [asyncMethodKey](options) {
134
+ const providers = this.createAsyncProviders(options);
135
+ if (self.options.alwaysTransient) {
136
+ providers.push({
137
+ provide: constants_1.CONFIGURABLE_MODULE_ID,
138
+ useValue: (0, random_string_generator_util_1.randomStringGenerator)(),
139
+ });
140
+ }
141
+ return self.transformModuleDefinition({
142
+ module: this,
143
+ imports: options.imports || [],
144
+ providers,
145
+ }, {
146
+ ...self.extras,
147
+ ...this.extractExtrasFromAsyncOptions(options, self.extras),
148
+ });
149
+ }
150
+ static omitExtras(input, extras) {
151
+ if (!extras) {
152
+ return input;
153
+ }
154
+ const moduleOptions = {};
155
+ const extrasKeys = Object.keys(extras);
156
+ Object.keys(input)
157
+ .filter(key => !extrasKeys.includes(key))
158
+ .forEach(key => {
159
+ moduleOptions[key] = input[key];
160
+ });
161
+ return moduleOptions;
162
+ }
163
+ static extractExtrasFromAsyncOptions(input, extras) {
164
+ if (!extras) {
165
+ return {};
166
+ }
167
+ const extrasOptions = {};
168
+ Object.keys(input)
169
+ .filter(key => !constants_1.ASYNC_OPTIONS_METADATA_KEYS.includes(key))
170
+ .forEach(key => {
171
+ extrasOptions[key] = input[key];
172
+ });
173
+ return extrasOptions;
174
+ }
175
+ static createAsyncProviders(options) {
176
+ if (options.useExisting || options.useFactory) {
177
+ if (options.inject && options.provideInjectionTokensFrom) {
178
+ return [
179
+ this.createAsyncOptionsProvider(options),
180
+ ...(0, utils_1.getInjectionProviders)(options.provideInjectionTokensFrom, options.inject),
181
+ ];
182
+ }
183
+ return [this.createAsyncOptionsProvider(options)];
184
+ }
185
+ return [
186
+ this.createAsyncOptionsProvider(options),
187
+ {
188
+ provide: options.useClass,
189
+ useClass: options.useClass,
190
+ },
191
+ ];
192
+ }
193
+ static createAsyncOptionsProvider(options) {
194
+ if (options.useFactory) {
195
+ return {
196
+ provide: self.options.optionsInjectionToken,
197
+ useFactory: options.useFactory,
198
+ inject: options.inject || [],
199
+ };
200
+ }
201
+ return {
202
+ provide: self.options.optionsInjectionToken,
203
+ useFactory: async (optionsFactory) => await optionsFactory[self.factoryClassMethodKey](),
204
+ inject: [options.useExisting || options.useClass],
205
+ };
206
+ }
207
+ }
208
+ return InternalModuleClass;
209
+ }
210
+ createTypeProxy(typeName) {
211
+ const proxy = new Proxy({}, {
212
+ get: () => {
213
+ throw new Error(`"${typeName}" is not supposed to be used as a value.`);
214
+ },
215
+ });
216
+ return proxy;
217
+ }
218
+ }
219
+ exports.ConfigurableModuleBuilder = ConfigurableModuleBuilder;
@@ -0,0 +1,9 @@
1
+ export declare const DEFAULT_METHOD_KEY = "register";
2
+ export declare const DEFAULT_FACTORY_CLASS_METHOD_KEY = "create";
3
+ export declare const ASYNC_METHOD_SUFFIX = "Async";
4
+ export declare const CONFIGURABLE_MODULE_ID = "CONFIGURABLE_MODULE_ID";
5
+ /**
6
+ * List of keys that are specific to ConfigurableModuleAsyncOptions
7
+ * and should be excluded when extracting user-defined extras.
8
+ */
9
+ export declare const ASYNC_OPTIONS_METADATA_KEYS: readonly ["useFactory", "useClass", "useExisting", "inject", "imports", "provideInjectionTokensFrom"];
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ASYNC_OPTIONS_METADATA_KEYS = exports.CONFIGURABLE_MODULE_ID = exports.ASYNC_METHOD_SUFFIX = exports.DEFAULT_FACTORY_CLASS_METHOD_KEY = exports.DEFAULT_METHOD_KEY = void 0;
4
+ exports.DEFAULT_METHOD_KEY = 'register';
5
+ exports.DEFAULT_FACTORY_CLASS_METHOD_KEY = 'create';
6
+ exports.ASYNC_METHOD_SUFFIX = 'Async';
7
+ exports.CONFIGURABLE_MODULE_ID = 'CONFIGURABLE_MODULE_ID';
8
+ /**
9
+ * List of keys that are specific to ConfigurableModuleAsyncOptions
10
+ * and should be excluded when extracting user-defined extras.
11
+ */
12
+ exports.ASYNC_OPTIONS_METADATA_KEYS = [
13
+ 'useFactory',
14
+ 'useClass',
15
+ 'useExisting',
16
+ 'inject',
17
+ 'imports',
18
+ 'provideInjectionTokensFrom',
19
+ ];
@@ -0,0 +1,2 @@
1
+ export * from './configurable-module.builder';
2
+ export * from './interfaces';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./configurable-module.builder"), exports);
5
+ tslib_1.__exportStar(require("./interfaces"), exports);
@@ -0,0 +1,42 @@
1
+ import { FactoryProvider, ModuleMetadata, Provider, Type } from '../../interfaces';
2
+ import { DEFAULT_FACTORY_CLASS_METHOD_KEY } from '../constants';
3
+ /**
4
+ * Interface that must be implemented by the module options factory class.
5
+ * Method key varies depending on the "FactoryClassMethodKey" type argument.
6
+ *
7
+ * @publicApi
8
+ */
9
+ export type ConfigurableModuleOptionsFactory<ModuleOptions, FactoryClassMethodKey extends string> = Record<`${FactoryClassMethodKey}`, () => Promise<ModuleOptions> | ModuleOptions>;
10
+ /**
11
+ * Interface that represents the module async options object
12
+ * Factory method name varies depending on the "FactoryClassMethodKey" type argument.
13
+ *
14
+ * @publicApi
15
+ */
16
+ export interface ConfigurableModuleAsyncOptions<ModuleOptions, FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY> extends Pick<ModuleMetadata, 'imports'> {
17
+ /**
18
+ * Injection token resolving to an existing provider. The provider must implement
19
+ * the corresponding interface.
20
+ */
21
+ useExisting?: Type<ConfigurableModuleOptionsFactory<ModuleOptions, FactoryClassMethodKey>>;
22
+ /**
23
+ * Injection token resolving to a class that will be instantiated as a provider.
24
+ * The class must implement the corresponding interface.
25
+ */
26
+ useClass?: Type<ConfigurableModuleOptionsFactory<ModuleOptions, FactoryClassMethodKey>>;
27
+ /**
28
+ * Function returning options (or a Promise resolving to options) to configure the
29
+ * module.
30
+ */
31
+ useFactory?: (...args: any[]) => Promise<ModuleOptions> | ModuleOptions;
32
+ /**
33
+ * Dependencies that a Factory may inject.
34
+ */
35
+ inject?: FactoryProvider['inject'];
36
+ /**
37
+ * List of parent module's providers that will be filtered to only provide necessary
38
+ * providers for the 'inject' array
39
+ * useful to pass options to nested async modules
40
+ */
41
+ provideInjectionTokensFrom?: Provider[];
42
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import { DynamicModule } from '../../interfaces';
2
+ import { DEFAULT_FACTORY_CLASS_METHOD_KEY, DEFAULT_METHOD_KEY } from '../constants';
3
+ import { ConfigurableModuleAsyncOptions } from './configurable-module-async-options.interface';
4
+ /**
5
+ * Class that represents a blueprint/prototype for a configurable Nest module.
6
+ * This class provides static methods for constructing dynamic modules. Their names
7
+ * can be controlled through the "MethodKey" type argument.
8
+ *
9
+ * @publicApi
10
+ */
11
+ export type ConfigurableModuleCls<ModuleOptions, MethodKey extends string = typeof DEFAULT_METHOD_KEY, FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY, ExtraModuleDefinitionOptions = {}> = {
12
+ new (): any;
13
+ } & Record<`${MethodKey}`, (options: ModuleOptions & Partial<ExtraModuleDefinitionOptions>) => DynamicModule> & Record<`${MethodKey}Async`, (options: ConfigurableModuleAsyncOptions<ModuleOptions, FactoryClassMethodKey> & Partial<ExtraModuleDefinitionOptions>) => DynamicModule>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,62 @@
1
+ import { ConfigurableModuleAsyncOptions } from './configurable-module-async-options.interface';
2
+ import { ConfigurableModuleCls } from './configurable-module-cls.interface';
3
+ /**
4
+ * Configurable module host. See properties for more details
5
+ *
6
+ * @publicApi
7
+ */
8
+ export interface ConfigurableModuleHost<ModuleOptions = Record<string, unknown>, MethodKey extends string = string, FactoryClassMethodKey extends string = string, ExtraModuleDefinitionOptions = {}> {
9
+ /**
10
+ * Class that represents a blueprint/prototype for a configurable Nest module.
11
+ * This class provides static methods for constructing dynamic modules. Their names
12
+ * can be controlled through the "MethodKey" type argument.
13
+ *
14
+ * Your module class should inherit from this class to make the static methods available.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * @Module({})
19
+ * class IntegrationModule extends ConfigurableModuleCls {
20
+ * // ...
21
+ * }
22
+ * ```
23
+ */
24
+ ConfigurableModuleClass: ConfigurableModuleCls<ModuleOptions, MethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
25
+ /**
26
+ * Module options provider token. Can be used to inject the "options object" to
27
+ * providers registered within the host module.
28
+ */
29
+ MODULE_OPTIONS_TOKEN: string | symbol;
30
+ /**
31
+ * Can be used to auto-infer the compound "async module options" type.
32
+ * Note: this property is not supposed to be used as a value.
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * @Module({})
37
+ * class IntegrationModule extends ConfigurableModuleCls {
38
+ * static module = initializer(IntegrationModule);
39
+ *
40
+ * static registerAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule {
41
+ * return super.registerAsync(options);
42
+ * }
43
+ * ```
44
+ */
45
+ ASYNC_OPTIONS_TYPE: ConfigurableModuleAsyncOptions<ModuleOptions, FactoryClassMethodKey> & Partial<ExtraModuleDefinitionOptions>;
46
+ /**
47
+ * Can be used to auto-infer the compound "module options" type (options interface + extra module definition options).
48
+ * Note: this property is not supposed to be used as a value.
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * @Module({})
53
+ * class IntegrationModule extends ConfigurableModuleCls {
54
+ * static module = initializer(IntegrationModule);
55
+ *
56
+ * static register(options: typeof OPTIONS_TYPE): DynamicModule {
57
+ * return super.register(options);
58
+ * }
59
+ * ```
60
+ */
61
+ OPTIONS_TYPE: ModuleOptions & Partial<ExtraModuleDefinitionOptions>;
62
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export * from './configurable-module-async-options.interface';
2
+ export * from './configurable-module-cls.interface';
3
+ export * from './configurable-module-host.interface';
@@ -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("./configurable-module-async-options.interface"), exports);
5
+ tslib_1.__exportStar(require("./configurable-module-cls.interface"), exports);
6
+ tslib_1.__exportStar(require("./configurable-module-host.interface"), exports);
@@ -0,0 +1 @@
1
+ export declare function generateOptionsInjectionToken(): string;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateOptionsInjectionToken = generateOptionsInjectionToken;
4
+ const random_string_generator_util_1 = require("../../utils/random-string-generator.util");
5
+ function generateOptionsInjectionToken() {
6
+ const hash = (0, random_string_generator_util_1.randomStringGenerator)();
7
+ return `CONFIGURABLE_MODULE_OPTIONS[${hash}]`;
8
+ }
@@ -0,0 +1,8 @@
1
+ import { FactoryProvider, Provider } from '../../interfaces';
2
+ /**
3
+ *
4
+ * @param providers List of a module's providers
5
+ * @param tokens Injection tokens needed for a useFactory function (usually the module's options' token)
6
+ * @returns All the providers needed for the tokens' injection (searched recursively)
7
+ */
8
+ export declare function getInjectionProviders(providers: Provider[], tokens: FactoryProvider['inject']): Provider[];
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getInjectionProviders = getInjectionProviders;
4
+ const shared_utils_1 = require("../../utils/shared.utils");
5
+ /**
6
+ * @param value
7
+ * @returns `true` if value is `OptionalFactoryDependency`
8
+ */
9
+ function isOptionalFactoryDependency(value) {
10
+ return (!(0, shared_utils_1.isUndefined)(value.token) &&
11
+ !(0, shared_utils_1.isUndefined)(value.optional) &&
12
+ !value.prototype);
13
+ }
14
+ const mapInjectToTokens = (t) => isOptionalFactoryDependency(t) ? t.token : t;
15
+ /**
16
+ *
17
+ * @param providers List of a module's providers
18
+ * @param tokens Injection tokens needed for a useFactory function (usually the module's options' token)
19
+ * @returns All the providers needed for the tokens' injection (searched recursively)
20
+ */
21
+ function getInjectionProviders(providers, tokens) {
22
+ const result = [];
23
+ let search = tokens.map(mapInjectToTokens);
24
+ while (search.length > 0) {
25
+ const match = (providers ?? []).filter(p => !result.includes(p) && // this prevents circular loops and duplication
26
+ (search.includes(p) || search.includes(p?.provide)));
27
+ result.push(...match);
28
+ // get injection tokens of the matched providers, if any
29
+ search = match
30
+ .filter(p => p?.inject)
31
+ .flatMap(p => p.inject)
32
+ .map(mapInjectToTokens);
33
+ }
34
+ return result;
35
+ }
@@ -0,0 +1,2 @@
1
+ export * from './generate-options-injection-token.util';
2
+ export * from './get-injection-providers.util';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./generate-options-injection-token.util"), exports);
5
+ tslib_1.__exportStar(require("./get-injection-providers.util"), exports);
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@depup/nestjs__common",
3
+ "version": "11.1.16-depup.1",
4
+ "description": "[DepUp] Nest - modern, fast, powerful node.js web framework (@common)",
5
+ "author": "Kamil Mysliwiec",
6
+ "homepage": "https://nestjs.com",
7
+ "funding": {
8
+ "type": "opencollective",
9
+ "url": "https://opencollective.com/nest"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/nestjs/nest.git",
14
+ "directory": "packages/common"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "file-type": "^21.3.1",
22
+ "iterare": "1.2.1",
23
+ "load-esm": "1.0.3",
24
+ "tslib": "2.8.1",
25
+ "uid": "2.0.2"
26
+ },
27
+ "peerDependencies": {
28
+ "class-transformer": ">=0.4.1",
29
+ "class-validator": ">=0.13.2",
30
+ "reflect-metadata": "^0.1.12 || ^0.2.0",
31
+ "rxjs": "^7.1.0"
32
+ },
33
+ "peerDependenciesMeta": {
34
+ "class-validator": {
35
+ "optional": true
36
+ },
37
+ "class-transformer": {
38
+ "optional": true
39
+ }
40
+ },
41
+ "gitHead": "315e698096208868b43dda25f2db9ac9d7c1d822",
42
+ "keywords": [
43
+ "depup",
44
+ "dependency-bumped",
45
+ "updated-deps",
46
+ "@nestjs/common"
47
+ ],
48
+ "depup": {
49
+ "changes": {
50
+ "file-type": {
51
+ "from": "21.3.0",
52
+ "to": "^21.3.1"
53
+ }
54
+ },
55
+ "depsUpdated": 1,
56
+ "originalPackage": "@nestjs/common",
57
+ "originalVersion": "11.1.16",
58
+ "processedAt": "2026-03-09T21:01:51.396Z",
59
+ "smokeTest": "passed"
60
+ }
61
+ }
@@ -0,0 +1,13 @@
1
+ import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
2
+ /**
3
+ * Defines the built-in DefaultValue Pipe
4
+ *
5
+ * @see [Built-in Pipes](https://docs.nestjs.com/pipes#built-in-pipes)
6
+ *
7
+ * @publicApi
8
+ */
9
+ export declare class DefaultValuePipe<T = any, R = any> implements PipeTransform<T, T | R> {
10
+ protected readonly defaultValue: R;
11
+ constructor(defaultValue: R);
12
+ transform(value?: T, _metadata?: ArgumentMetadata): T | R;
13
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultValuePipe = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const injectable_decorator_1 = require("../decorators/core/injectable.decorator");
6
+ const shared_utils_1 = require("../utils/shared.utils");
7
+ /**
8
+ * Defines the built-in DefaultValue Pipe
9
+ *
10
+ * @see [Built-in Pipes](https://docs.nestjs.com/pipes#built-in-pipes)
11
+ *
12
+ * @publicApi
13
+ */
14
+ let DefaultValuePipe = class DefaultValuePipe {
15
+ constructor(defaultValue) {
16
+ this.defaultValue = defaultValue;
17
+ }
18
+ transform(value, _metadata) {
19
+ if ((0, shared_utils_1.isNil)(value) ||
20
+ ((0, shared_utils_1.isNumber)(value) && isNaN(value))) {
21
+ return this.defaultValue;
22
+ }
23
+ return value;
24
+ }
25
+ };
26
+ exports.DefaultValuePipe = DefaultValuePipe;
27
+ exports.DefaultValuePipe = DefaultValuePipe = tslib_1.__decorate([
28
+ (0, injectable_decorator_1.Injectable)(),
29
+ tslib_1.__metadata("design:paramtypes", [Object])
30
+ ], DefaultValuePipe);
@@ -0,0 +1,62 @@
1
+ import { FileValidatorContext } from './file-validator-context.interface';
2
+ import { FileValidator } from './file-validator.interface';
3
+ import { IFile } from './interfaces';
4
+ type FileTypeValidatorContext = FileValidatorContext<Omit<FileTypeValidatorOptions, 'errorMessage'>>;
5
+ export type FileTypeValidatorOptions = {
6
+ /**
7
+ * Expected file type(s) for validation. Can be a string (MIME type)
8
+ * or a regular expression to match multiple types.
9
+ *
10
+ * @example
11
+ * // Match a single MIME type
12
+ * fileType: 'image/png'
13
+ *
14
+ * @example
15
+ * // Match multiple types using RegExp
16
+ * fileType: /^image\/(png|jpeg)$/
17
+ */
18
+ fileType: string | RegExp;
19
+ /**
20
+ * Custom error message displayed when file type validation fails
21
+ * Can be provided as a static string, or as a factory function
22
+ * that receives the validation context (file and validator configuration)
23
+ * and returns a dynamic error message.
24
+ *
25
+ * @example
26
+ * // Static message
27
+ * new FileTypeValidator({ fileType: 'image/png', errorMessage: 'Only PNG allowed' })
28
+ *
29
+ * @example
30
+ * // Dynamic message based on file object and validator configuration
31
+ * new FileTypeValidator({
32
+ * fileType: 'image/png',
33
+ * errorMessage: ctx => `Received file type '${ctx.file?.mimetype}', but expected '${ctx.config.fileType}'`
34
+ * })
35
+ */
36
+ errorMessage?: string | ((ctx: FileTypeValidatorContext) => string);
37
+ /**
38
+ * If `true`, the validator will skip the magic numbers validation.
39
+ * This can be useful when you can't identify some files as there are no common magic numbers available for some file types.
40
+ * @default false
41
+ */
42
+ skipMagicNumbersValidation?: boolean;
43
+ /**
44
+ * If `true`, and magic number check fails, fallback to mimetype comparison.
45
+ * @default false
46
+ */
47
+ fallbackToMimetype?: boolean;
48
+ };
49
+ /**
50
+ * Defines the built-in FileTypeValidator. It validates incoming files by examining
51
+ * their magic numbers using the file-type package, providing more reliable file type validation
52
+ * than just checking the mimetype string.
53
+ *
54
+ * @see [File Validators](https://docs.nestjs.com/techniques/file-upload#validators)
55
+ *
56
+ * @publicApi
57
+ */
58
+ export declare class FileTypeValidator extends FileValidator<FileTypeValidatorOptions, IFile> {
59
+ buildErrorMessage(file?: IFile): string;
60
+ isValid(file?: IFile): Promise<boolean>;
61
+ }
62
+ export {};