@velajs/vela 1.19.0 → 1.19.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 (449) hide show
  1. package/CHANGELOG.md +22 -14
  2. package/dist/configurable-module.builder-5FGMaXG6.js +91 -0
  3. package/dist/configurable-module.builder-5FGMaXG6.js.map +1 -0
  4. package/dist/container-BqUHID4l.js +645 -0
  5. package/dist/container-BqUHID4l.js.map +1 -0
  6. package/dist/cron-matcher-C9qv5OUA.js +113 -0
  7. package/dist/cron-matcher-C9qv5OUA.js.map +1 -0
  8. package/dist/decorate-GcSMAbKn.js +528 -0
  9. package/dist/decorate-GcSMAbKn.js.map +1 -0
  10. package/dist/decorators-C8YBFCIk.js +53 -0
  11. package/dist/decorators-C8YBFCIk.js.map +1 -0
  12. package/dist/define-module-NOyOZNXD.js +235 -0
  13. package/dist/define-module-NOyOZNXD.js.map +1 -0
  14. package/dist/discovery.service-BYm95SSD.js +368 -0
  15. package/dist/discovery.service-BYm95SSD.js.map +1 -0
  16. package/dist/discovery.service-Cpf1QcZ5.d.ts +648 -0
  17. package/dist/i18n/index.d.ts +138 -10
  18. package/dist/i18n/index.js +270 -8
  19. package/dist/i18n/index.js.map +1 -0
  20. package/dist/index-D72EQfcC.d.ts +430 -0
  21. package/dist/index-DhShDLCM.d.ts +2310 -0
  22. package/dist/index.d.ts +6 -70
  23. package/dist/index.js +14 -76
  24. package/dist/internal.d.ts +13 -17
  25. package/dist/internal.js +6 -19
  26. package/dist/live/index.d.ts +2 -12
  27. package/dist/live/index.js +826 -16
  28. package/dist/live/index.js.map +1 -0
  29. package/dist/metadata.registry-D1od8ZBt.d.ts +842 -0
  30. package/dist/plugin-ByBlVOve.js +1387 -0
  31. package/dist/plugin-ByBlVOve.js.map +1 -0
  32. package/dist/queue/index.d.ts +247 -10
  33. package/dist/queue/index.js +384 -12
  34. package/dist/queue/index.js.map +1 -0
  35. package/dist/request-context-C3nCGJNd.js +26 -0
  36. package/dist/request-context-C3nCGJNd.js.map +1 -0
  37. package/dist/route.manager-DRAZ5X04.js +991 -0
  38. package/dist/route.manager-DRAZ5X04.js.map +1 -0
  39. package/dist/schedule-node/index.d.ts +32 -3
  40. package/dist/schedule-node/index.js +97 -3
  41. package/dist/schedule-node/index.js.map +1 -0
  42. package/dist/schedule.registry-DVm7Jp5w.d.ts +55 -0
  43. package/dist/seeder/index.d.ts +75 -5
  44. package/dist/seeder/index.js +105 -4
  45. package/dist/seeder/index.js.map +1 -0
  46. package/dist/signed-url-CMmi0SIb.js +56 -0
  47. package/dist/signed-url-CMmi0SIb.js.map +1 -0
  48. package/dist/signed-url-DKhgja4U.d.ts +16 -0
  49. package/dist/src-eb5CI6Xn.js +2151 -0
  50. package/dist/src-eb5CI6Xn.js.map +1 -0
  51. package/dist/storage/index.d.ts +57 -4
  52. package/dist/storage/index.js +22 -5
  53. package/dist/storage/index.js.map +1 -0
  54. package/dist/streaming/index.d.ts +2 -2
  55. package/dist/streaming/index.js +2 -1
  56. package/dist/websocket/index.d.ts +3 -12
  57. package/dist/websocket/index.js +2 -16
  58. package/dist/websocket-DXmB-MWJ.js +697 -0
  59. package/dist/websocket-DXmB-MWJ.js.map +1 -0
  60. package/dist/websocket-node/index.d.ts +108 -6
  61. package/dist/websocket-node/index.js +228 -6
  62. package/dist/websocket-node/index.js.map +1 -0
  63. package/package.json +66 -53
  64. package/dist/__tests__/workers/entry.d.ts +0 -9
  65. package/dist/__tests__/workers-als/entry-als.d.ts +0 -9
  66. package/dist/application.d.ts +0 -104
  67. package/dist/application.js +0 -364
  68. package/dist/cache/cache.decorators.d.ts +0 -2
  69. package/dist/cache/cache.decorators.js +0 -4
  70. package/dist/cache/cache.interceptor.d.ts +0 -9
  71. package/dist/cache/cache.interceptor.js +0 -60
  72. package/dist/cache/cache.module.d.ts +0 -7
  73. package/dist/cache/cache.module.js +0 -58
  74. package/dist/cache/cache.service.d.ts +0 -9
  75. package/dist/cache/cache.service.js +0 -42
  76. package/dist/cache/cache.store.d.ts +0 -12
  77. package/dist/cache/cache.store.js +0 -51
  78. package/dist/cache/cache.tokens.d.ts +0 -6
  79. package/dist/cache/cache.tokens.js +0 -5
  80. package/dist/cache/cache.types.d.ts +0 -41
  81. package/dist/cache/cache.types.js +0 -1
  82. package/dist/cache/index.d.ts +0 -8
  83. package/dist/cache/index.js +0 -7
  84. package/dist/cache/tiered-cache.store.d.ts +0 -19
  85. package/dist/cache/tiered-cache.store.js +0 -40
  86. package/dist/config/config.module.d.ts +0 -19
  87. package/dist/config/config.module.js +0 -98
  88. package/dist/config/config.service.d.ts +0 -20
  89. package/dist/config/config.service.js +0 -43
  90. package/dist/config/config.store.d.ts +0 -46
  91. package/dist/config/config.store.js +0 -119
  92. package/dist/config/config.tokens.d.ts +0 -13
  93. package/dist/config/config.tokens.js +0 -14
  94. package/dist/config/config.types.d.ts +0 -41
  95. package/dist/config/config.types.js +0 -4
  96. package/dist/config/index.d.ts +0 -7
  97. package/dist/config/index.js +0 -5
  98. package/dist/config/register-as.d.ts +0 -52
  99. package/dist/config/register-as.js +0 -39
  100. package/dist/constants.d.ts +0 -44
  101. package/dist/constants.js +0 -46
  102. package/dist/container/container.d.ts +0 -154
  103. package/dist/container/container.js +0 -849
  104. package/dist/container/decorators.d.ts +0 -17
  105. package/dist/container/decorators.js +0 -57
  106. package/dist/container/disposable.d.ts +0 -5
  107. package/dist/container/disposable.js +0 -33
  108. package/dist/container/index.d.ts +0 -6
  109. package/dist/container/index.js +0 -5
  110. package/dist/container/mixin.d.ts +0 -24
  111. package/dist/container/mixin.js +0 -26
  112. package/dist/container/module-ref.d.ts +0 -21
  113. package/dist/container/module-ref.js +0 -48
  114. package/dist/container/types.d.ts +0 -154
  115. package/dist/container/types.js +0 -49
  116. package/dist/cors/cors.module.d.ts +0 -7
  117. package/dist/cors/cors.module.js +0 -37
  118. package/dist/cors/cors.tokens.d.ts +0 -3
  119. package/dist/cors/cors.tokens.js +0 -2
  120. package/dist/cors/cors.types.d.ts +0 -8
  121. package/dist/cors/cors.types.js +0 -1
  122. package/dist/cors/index.d.ts +0 -3
  123. package/dist/cors/index.js +0 -2
  124. package/dist/crypto/signed-url.d.ts +0 -12
  125. package/dist/crypto/signed-url.js +0 -60
  126. package/dist/discovery/discoverable.decorator.d.ts +0 -38
  127. package/dist/discovery/discoverable.decorator.js +0 -42
  128. package/dist/discovery/discovery.service.d.ts +0 -102
  129. package/dist/discovery/discovery.service.js +0 -177
  130. package/dist/discovery/index.d.ts +0 -2
  131. package/dist/discovery/index.js +0 -2
  132. package/dist/entrypoint/entrypoint.registry.d.ts +0 -42
  133. package/dist/entrypoint/entrypoint.registry.js +0 -112
  134. package/dist/entrypoint/entrypoint.types.d.ts +0 -41
  135. package/dist/entrypoint/entrypoint.types.js +0 -3
  136. package/dist/entrypoint/execution-context.d.ts +0 -15
  137. package/dist/entrypoint/execution-context.js +0 -21
  138. package/dist/entrypoint/execution-scope.d.ts +0 -21
  139. package/dist/entrypoint/execution-scope.js +0 -28
  140. package/dist/entrypoint/index.d.ts +0 -4
  141. package/dist/entrypoint/index.js +0 -4
  142. package/dist/errors/http-exception.d.ts +0 -63
  143. package/dist/errors/http-exception.js +0 -142
  144. package/dist/errors/index.d.ts +0 -1
  145. package/dist/errors/index.js +0 -1
  146. package/dist/event-emitter/event-emitter.decorators.d.ts +0 -1
  147. package/dist/event-emitter/event-emitter.decorators.js +0 -10
  148. package/dist/event-emitter/event-emitter.module.d.ts +0 -2
  149. package/dist/event-emitter/event-emitter.module.js +0 -23
  150. package/dist/event-emitter/event-emitter.service.d.ts +0 -13
  151. package/dist/event-emitter/event-emitter.service.js +0 -127
  152. package/dist/event-emitter/event-emitter.subscriber.d.ts +0 -9
  153. package/dist/event-emitter/event-emitter.subscriber.js +0 -45
  154. package/dist/event-emitter/event-emitter.tokens.d.ts +0 -1
  155. package/dist/event-emitter/event-emitter.tokens.js +0 -1
  156. package/dist/event-emitter/event-emitter.types.d.ts +0 -5
  157. package/dist/event-emitter/event-emitter.types.js +0 -1
  158. package/dist/event-emitter/index.d.ts +0 -6
  159. package/dist/event-emitter/index.js +0 -5
  160. package/dist/exceptions/errors.module.d.ts +0 -40
  161. package/dist/exceptions/errors.module.js +0 -46
  162. package/dist/exceptions/exception-handler.d.ts +0 -56
  163. package/dist/exceptions/exception-handler.js +0 -17
  164. package/dist/exceptions/index.d.ts +0 -6
  165. package/dist/exceptions/index.js +0 -3
  166. package/dist/exceptions/reporter.d.ts +0 -21
  167. package/dist/exceptions/reporter.js +0 -70
  168. package/dist/factory/adapter.d.ts +0 -36
  169. package/dist/factory/adapter.js +0 -18
  170. package/dist/factory/bootstrap.d.ts +0 -23
  171. package/dist/factory/bootstrap.js +0 -110
  172. package/dist/factory.d.ts +0 -16
  173. package/dist/factory.js +0 -36
  174. package/dist/fetch/fetch.module.d.ts +0 -7
  175. package/dist/fetch/fetch.module.js +0 -31
  176. package/dist/fetch/fetch.service.d.ts +0 -24
  177. package/dist/fetch/fetch.service.js +0 -145
  178. package/dist/fetch/fetch.types.d.ts +0 -24
  179. package/dist/fetch/fetch.types.js +0 -1
  180. package/dist/fetch/index.d.ts +0 -3
  181. package/dist/fetch/index.js +0 -2
  182. package/dist/health/health.http.d.ts +0 -14
  183. package/dist/health/health.http.js +0 -75
  184. package/dist/health/health.indicator.d.ts +0 -9
  185. package/dist/health/health.indicator.js +0 -32
  186. package/dist/health/health.module.d.ts +0 -2
  187. package/dist/health/health.module.js +0 -26
  188. package/dist/health/health.service.d.ts +0 -7
  189. package/dist/health/health.service.js +0 -69
  190. package/dist/health/health.types.d.ts +0 -15
  191. package/dist/health/health.types.js +0 -1
  192. package/dist/health/index.d.ts +0 -6
  193. package/dist/health/index.js +0 -4
  194. package/dist/http/ambient.d.ts +0 -17
  195. package/dist/http/ambient.js +0 -44
  196. package/dist/http/argument-resolver.d.ts +0 -10
  197. package/dist/http/argument-resolver.js +0 -89
  198. package/dist/http/decorators.d.ts +0 -198
  199. package/dist/http/decorators.js +0 -321
  200. package/dist/http/execution-context.d.ts +0 -8
  201. package/dist/http/execution-context.js +0 -35
  202. package/dist/http/handler-executor.d.ts +0 -20
  203. package/dist/http/handler-executor.js +0 -133
  204. package/dist/http/index.d.ts +0 -12
  205. package/dist/http/index.js +0 -7
  206. package/dist/http/instantiate.d.ts +0 -4
  207. package/dist/http/instantiate.js +0 -45
  208. package/dist/http/lazy-param.decorator.d.ts +0 -37
  209. package/dist/http/lazy-param.decorator.js +0 -117
  210. package/dist/http/request-container.d.ts +0 -16
  211. package/dist/http/request-container.js +0 -19
  212. package/dist/http/request-context.d.ts +0 -13
  213. package/dist/http/request-context.js +0 -22
  214. package/dist/http/response-mapper.d.ts +0 -8
  215. package/dist/http/response-mapper.js +0 -42
  216. package/dist/http/route-contributor.d.ts +0 -68
  217. package/dist/http/route-contributor.js +0 -22
  218. package/dist/http/route-map.d.ts +0 -30
  219. package/dist/http/route-map.js +0 -27
  220. package/dist/http/route.manager.d.ts +0 -92
  221. package/dist/http/route.manager.js +0 -481
  222. package/dist/http/types.d.ts +0 -37
  223. package/dist/http/types.js +0 -1
  224. package/dist/http/url/index.d.ts +0 -4
  225. package/dist/http/url/index.js +0 -3
  226. package/dist/http/url/signed-url.guard.d.ts +0 -27
  227. package/dist/http/url/signed-url.guard.js +0 -62
  228. package/dist/http/url/signing-secret.d.ts +0 -20
  229. package/dist/http/url/signing-secret.js +0 -24
  230. package/dist/http/url/url-generator.service.d.ts +0 -52
  231. package/dist/http/url/url-generator.service.js +0 -104
  232. package/dist/i18n/deep-merge.d.ts +0 -2
  233. package/dist/i18n/deep-merge.js +0 -15
  234. package/dist/i18n/i18n.middleware.d.ts +0 -15
  235. package/dist/i18n/i18n.middleware.js +0 -94
  236. package/dist/i18n/i18n.module.d.ts +0 -13
  237. package/dist/i18n/i18n.module.js +0 -69
  238. package/dist/i18n/i18n.options.d.ts +0 -30
  239. package/dist/i18n/i18n.options.js +0 -16
  240. package/dist/i18n/i18n.service.d.ts +0 -20
  241. package/dist/i18n/i18n.service.js +0 -49
  242. package/dist/i18n/i18n.tokens.d.ts +0 -6
  243. package/dist/i18n/i18n.tokens.js +0 -3
  244. package/dist/i18n/i18n.types.d.ts +0 -6
  245. package/dist/i18n/i18n.types.js +0 -1
  246. package/dist/i18n/message-loader.service.d.ts +0 -21
  247. package/dist/i18n/message-loader.service.js +0 -90
  248. package/dist/i18n/message-registry.d.ts +0 -16
  249. package/dist/i18n/message-registry.js +0 -49
  250. package/dist/lifecycle/index.d.ts +0 -20
  251. package/dist/lifecycle/index.js +0 -15
  252. package/dist/live/live.cursor.d.ts +0 -22
  253. package/dist/live/live.cursor.js +0 -56
  254. package/dist/live/live.decorators.d.ts +0 -32
  255. package/dist/live/live.decorators.js +0 -46
  256. package/dist/live/live.delta.d.ts +0 -15
  257. package/dist/live/live.delta.js +0 -51
  258. package/dist/live/live.engine.d.ts +0 -88
  259. package/dist/live/live.engine.js +0 -471
  260. package/dist/live/live.invalidation.d.ts +0 -45
  261. package/dist/live/live.invalidation.js +0 -99
  262. package/dist/live/live.module.d.ts +0 -28
  263. package/dist/live/live.module.js +0 -87
  264. package/dist/live/live.tokens.d.ts +0 -9
  265. package/dist/live/live.tokens.js +0 -8
  266. package/dist/live/live.types.d.ts +0 -138
  267. package/dist/live/live.types.js +0 -1
  268. package/dist/live/presence.d.ts +0 -44
  269. package/dist/live/presence.js +0 -130
  270. package/dist/metadata.d.ts +0 -10
  271. package/dist/metadata.js +0 -20
  272. package/dist/module/configurable-module.builder.d.ts +0 -56
  273. package/dist/module/configurable-module.builder.js +0 -84
  274. package/dist/module/configurable-module.types.d.ts +0 -93
  275. package/dist/module/configurable-module.types.js +0 -5
  276. package/dist/module/decorators.d.ts +0 -10
  277. package/dist/module/decorators.js +0 -47
  278. package/dist/module/define-module.d.ts +0 -112
  279. package/dist/module/define-module.js +0 -232
  280. package/dist/module/graph.d.ts +0 -10
  281. package/dist/module/graph.js +0 -35
  282. package/dist/module/index.d.ts +0 -10
  283. package/dist/module/index.js +0 -7
  284. package/dist/module/lazy-modules.d.ts +0 -82
  285. package/dist/module/lazy-modules.js +0 -231
  286. package/dist/module/lazy-provider.d.ts +0 -65
  287. package/dist/module/lazy-provider.js +0 -111
  288. package/dist/module/middleware.d.ts +0 -30
  289. package/dist/module/middleware.js +0 -67
  290. package/dist/module/module-loader.d.ts +0 -58
  291. package/dist/module/module-loader.js +0 -484
  292. package/dist/module/stable-hash.d.ts +0 -15
  293. package/dist/module/stable-hash.js +0 -52
  294. package/dist/module/types.d.ts +0 -1
  295. package/dist/module/types.js +0 -1
  296. package/dist/openapi/decorators.d.ts +0 -34
  297. package/dist/openapi/decorators.js +0 -66
  298. package/dist/openapi/document.d.ts +0 -3
  299. package/dist/openapi/document.js +0 -316
  300. package/dist/openapi/index.d.ts +0 -7
  301. package/dist/openapi/index.js +0 -6
  302. package/dist/openapi/redoc-ui.d.ts +0 -1
  303. package/dist/openapi/redoc-ui.js +0 -19
  304. package/dist/openapi/scalar-ui.d.ts +0 -1
  305. package/dist/openapi/scalar-ui.js +0 -19
  306. package/dist/openapi/swagger-ui.d.ts +0 -1
  307. package/dist/openapi/swagger-ui.js +0 -23
  308. package/dist/openapi/types.d.ts +0 -182
  309. package/dist/openapi/types.js +0 -4
  310. package/dist/openapi/zod-to-json-schema.d.ts +0 -4
  311. package/dist/openapi/zod-to-json-schema.js +0 -57
  312. package/dist/pipeline/app-providers.d.ts +0 -10
  313. package/dist/pipeline/app-providers.js +0 -43
  314. package/dist/pipeline/component.manager.d.ts +0 -25
  315. package/dist/pipeline/component.manager.js +0 -66
  316. package/dist/pipeline/decorators.d.ts +0 -10
  317. package/dist/pipeline/decorators.js +0 -42
  318. package/dist/pipeline/index.d.ts +0 -12
  319. package/dist/pipeline/index.js +0 -7
  320. package/dist/pipeline/pipeline-runner.d.ts +0 -31
  321. package/dist/pipeline/pipeline-runner.js +0 -40
  322. package/dist/pipeline/pipes.d.ts +0 -48
  323. package/dist/pipeline/pipes.js +0 -104
  324. package/dist/pipeline/reflector.d.ts +0 -86
  325. package/dist/pipeline/reflector.js +0 -121
  326. package/dist/pipeline/scoped-components.d.ts +0 -26
  327. package/dist/pipeline/scoped-components.js +0 -27
  328. package/dist/pipeline/tokens.d.ts +0 -57
  329. package/dist/pipeline/tokens.js +0 -47
  330. package/dist/pipeline/types.d.ts +0 -64
  331. package/dist/pipeline/types.js +0 -1
  332. package/dist/plugin/plugin.d.ts +0 -31
  333. package/dist/plugin/plugin.js +0 -111
  334. package/dist/queue/inline.driver.d.ts +0 -30
  335. package/dist/queue/inline.driver.js +0 -58
  336. package/dist/queue/queue.binding.d.ts +0 -23
  337. package/dist/queue/queue.binding.js +0 -60
  338. package/dist/queue/queue.client.d.ts +0 -20
  339. package/dist/queue/queue.client.js +0 -33
  340. package/dist/queue/queue.decorators.d.ts +0 -23
  341. package/dist/queue/queue.decorators.js +0 -46
  342. package/dist/queue/queue.dispatch.d.ts +0 -36
  343. package/dist/queue/queue.dispatch.js +0 -109
  344. package/dist/queue/queue.module.d.ts +0 -32
  345. package/dist/queue/queue.module.js +0 -80
  346. package/dist/queue/queue.tokens.d.ts +0 -21
  347. package/dist/queue/queue.tokens.js +0 -34
  348. package/dist/queue/queue.types.d.ts +0 -61
  349. package/dist/queue/queue.types.js +0 -4
  350. package/dist/registry/index.d.ts +0 -2
  351. package/dist/registry/index.js +0 -1
  352. package/dist/registry/metadata.registry.d.ts +0 -73
  353. package/dist/registry/metadata.registry.js +0 -357
  354. package/dist/registry/paths.d.ts +0 -3
  355. package/dist/registry/paths.js +0 -15
  356. package/dist/registry/types.d.ts +0 -116
  357. package/dist/registry/types.js +0 -1
  358. package/dist/registry/util.d.ts +0 -3
  359. package/dist/registry/util.js +0 -8
  360. package/dist/schedule/cron-matcher.d.ts +0 -2
  361. package/dist/schedule/cron-matcher.js +0 -62
  362. package/dist/schedule/index.d.ts +0 -8
  363. package/dist/schedule/index.js +0 -5
  364. package/dist/schedule/schedule.decorators.d.ts +0 -2
  365. package/dist/schedule/schedule.decorators.js +0 -18
  366. package/dist/schedule/schedule.module.d.ts +0 -9
  367. package/dist/schedule/schedule.module.js +0 -28
  368. package/dist/schedule/schedule.registry.d.ts +0 -23
  369. package/dist/schedule/schedule.registry.js +0 -63
  370. package/dist/schedule/schedule.tokens.d.ts +0 -2
  371. package/dist/schedule/schedule.tokens.js +0 -2
  372. package/dist/schedule/schedule.types.d.ts +0 -8
  373. package/dist/schedule/schedule.types.js +0 -1
  374. package/dist/schedule-node/schedule-node.module.d.ts +0 -9
  375. package/dist/schedule-node/schedule-node.module.js +0 -28
  376. package/dist/schedule-node/schedule.executor.d.ts +0 -19
  377. package/dist/schedule-node/schedule.executor.js +0 -112
  378. package/dist/seeder/seeder.decorator.d.ts +0 -7
  379. package/dist/seeder/seeder.decorator.js +0 -15
  380. package/dist/seeder/seeder.module.d.ts +0 -16
  381. package/dist/seeder/seeder.module.js +0 -44
  382. package/dist/seeder/seeder.registry.d.ts +0 -23
  383. package/dist/seeder/seeder.registry.js +0 -83
  384. package/dist/seeder/seeder.tokens.d.ts +0 -2
  385. package/dist/seeder/seeder.tokens.js +0 -1
  386. package/dist/seeder/seeder.types.d.ts +0 -20
  387. package/dist/seeder/seeder.types.js +0 -1
  388. package/dist/serialization/index.d.ts +0 -2
  389. package/dist/serialization/index.js +0 -2
  390. package/dist/serialization/serialize.decorator.d.ts +0 -6
  391. package/dist/serialization/serialize.decorator.js +0 -7
  392. package/dist/serialization/serializer.interceptor.d.ts +0 -4
  393. package/dist/serialization/serializer.interceptor.js +0 -16
  394. package/dist/services/index.d.ts +0 -2
  395. package/dist/services/index.js +0 -1
  396. package/dist/services/logger.d.ts +0 -59
  397. package/dist/services/logger.js +0 -159
  398. package/dist/storage/path-template.d.ts +0 -9
  399. package/dist/storage/path-template.js +0 -20
  400. package/dist/storage/storage.types.d.ts +0 -41
  401. package/dist/storage/storage.types.js +0 -5
  402. package/dist/throttler/index.d.ts +0 -6
  403. package/dist/throttler/index.js +0 -5
  404. package/dist/throttler/throttler.decorators.d.ts +0 -3
  405. package/dist/throttler/throttler.decorators.js +0 -4
  406. package/dist/throttler/throttler.guard.d.ts +0 -9
  407. package/dist/throttler/throttler.guard.js +0 -72
  408. package/dist/throttler/throttler.module.d.ts +0 -7
  409. package/dist/throttler/throttler.module.js +0 -41
  410. package/dist/throttler/throttler.storage.d.ts +0 -10
  411. package/dist/throttler/throttler.storage.js +0 -44
  412. package/dist/throttler/throttler.tokens.d.ts +0 -6
  413. package/dist/throttler/throttler.tokens.js +0 -5
  414. package/dist/throttler/throttler.types.d.ts +0 -25
  415. package/dist/throttler/throttler.types.js +0 -1
  416. package/dist/validation/create-zod-dto.d.ts +0 -13
  417. package/dist/validation/create-zod-dto.js +0 -18
  418. package/dist/validation/index.d.ts +0 -3
  419. package/dist/validation/index.js +0 -2
  420. package/dist/validation/validation.pipe.d.ts +0 -4
  421. package/dist/validation/validation.pipe.js +0 -19
  422. package/dist/websocket/websocket.decorators.d.ts +0 -47
  423. package/dist/websocket/websocket.decorators.js +0 -80
  424. package/dist/websocket/websocket.module.d.ts +0 -35
  425. package/dist/websocket/websocket.module.js +0 -63
  426. package/dist/websocket/websocket.tokens.d.ts +0 -30
  427. package/dist/websocket/websocket.tokens.js +0 -27
  428. package/dist/websocket/websocket.types.d.ts +0 -102
  429. package/dist/websocket/websocket.types.js +0 -4
  430. package/dist/websocket/ws-argument-resolver.d.ts +0 -13
  431. package/dist/websocket/ws-argument-resolver.js +0 -40
  432. package/dist/websocket/ws-dispatcher.d.ts +0 -54
  433. package/dist/websocket/ws-dispatcher.js +0 -343
  434. package/dist/websocket/ws-exception.d.ts +0 -25
  435. package/dist/websocket/ws-exception.js +0 -42
  436. package/dist/websocket/ws-execution-context.d.ts +0 -9
  437. package/dist/websocket/ws-execution-context.js +0 -24
  438. package/dist/websocket/ws-server.d.ts +0 -31
  439. package/dist/websocket/ws-server.js +0 -74
  440. package/dist/websocket/ws-sync.d.ts +0 -47
  441. package/dist/websocket/ws-sync.js +0 -74
  442. package/dist/websocket-node/node-ws-client.d.ts +0 -24
  443. package/dist/websocket-node/node-ws-client.js +0 -49
  444. package/dist/websocket-node/redis-live.d.ts +0 -24
  445. package/dist/websocket-node/redis-live.js +0 -57
  446. package/dist/websocket-node/redis-sync.d.ts +0 -33
  447. package/dist/websocket-node/redis-sync.js +0 -56
  448. package/dist/websocket-node/register-gateways.d.ts +0 -20
  449. package/dist/websocket-node/register-gateways.js +0 -61
@@ -0,0 +1,991 @@
1
+ import { c as getInjectMetadata, d as HttpMethod, k as MetadataRegistry, m as Scope, p as ParamType, s as getConstructorDependencies } from "./decorate-GcSMAbKn.js";
2
+ import { n as resolveErrorReporter, s as ForbiddenException, u as HttpException } from "./discovery.service-BYm95SSD.js";
3
+ import { n as createRequestContext, t as REQUEST_CONTEXT } from "./request-context-C3nCGJNd.js";
4
+ import { STATUS_TO_CODE, toErrorBody } from "@velajs/errors";
5
+ import { Hono } from "hono";
6
+ import { contextStorage } from "hono/context-storage";
7
+ import { getCookie } from "hono/cookie";
8
+ //#region src/metadata.ts
9
+ function defineMetadata(key, value, target, propertyKey) {
10
+ MetadataRegistry.setReflectMetadata(target, key, value, propertyKey);
11
+ }
12
+ function getMetadata(key, target, propertyKey) {
13
+ return MetadataRegistry.getReflectMetadata(target, key, propertyKey);
14
+ }
15
+ if (typeof Reflect.defineMetadata !== "function") {
16
+ Reflect.defineMetadata = defineMetadata;
17
+ Reflect.getMetadata = getMetadata;
18
+ Reflect.getOwnMetadata = getMetadata;
19
+ Reflect.metadata = (key, value) => {
20
+ return (target, propertyKey) => {
21
+ defineMetadata(key, value, target, propertyKey);
22
+ };
23
+ };
24
+ }
25
+ //#endregion
26
+ //#region src/registry/paths.ts
27
+ function normalizePath(path) {
28
+ if (!path) return path;
29
+ return path.startsWith("/") ? path : `/${path}`;
30
+ }
31
+ function joinPaths(prefix, path) {
32
+ return `${prefix.endsWith("/") ? prefix.slice(0, -1) : prefix}${path && !path.startsWith("/") ? `/${path}` : path}` || "/";
33
+ }
34
+ function toOpenApiPath(path) {
35
+ return path.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g, "{$1}");
36
+ }
37
+ //#endregion
38
+ //#region src/http/instantiate.ts
39
+ function instantiate(classOrInstance, container) {
40
+ if (typeof classOrInstance === "function") {
41
+ const clazz = classOrInstance;
42
+ if (container.has(clazz)) return container.resolve(clazz);
43
+ if (constructorExpectsDependencies(clazz)) throw new Error(`Cannot instantiate ${clazz.name}: the class declares constructor dependencies (\`@Inject(...)\` parameters or typed constructor parameters), but no matching provider is registered in the container. Add it to a module's providers (and export it if used outside its declaring module) instead of relying on the bare \`new\` fallback, which would construct the class without honouring its dependency-injection metadata and leave every injected field \`undefined\`.`);
44
+ return new clazz();
45
+ }
46
+ if (container.has(classOrInstance)) return container.resolve(classOrInstance);
47
+ return classOrInstance;
48
+ }
49
+ function constructorExpectsDependencies(clazz) {
50
+ if (getInjectMetadata(clazz).length > 0) return true;
51
+ return getConstructorDependencies(clazz).length > 0;
52
+ }
53
+ function instantiateMany(items, container) {
54
+ return items.map((item) => instantiate(item, container));
55
+ }
56
+ //#endregion
57
+ //#region src/http/argument-resolver.ts
58
+ const PARAM_EXTRACTORS = /* @__PURE__ */ new Map([
59
+ [ParamType.PARAM, (c, p) => p.name ? c.req.param(p.name) : c.req.param()],
60
+ [ParamType.QUERY, (c, p) => p.name ? c.req.query(p.name) : c.req.query()],
61
+ [ParamType.BODY, async (c, p) => {
62
+ let body;
63
+ try {
64
+ body = await c.req.json();
65
+ } catch {
66
+ return;
67
+ }
68
+ return p.name && body !== null && typeof body === "object" ? body[p.name] : body;
69
+ }],
70
+ [ParamType.HEADERS, (c, p) => p.name ? c.req.header(p.name) : c.req.header()],
71
+ [ParamType.REQUEST, (c) => c],
72
+ [ParamType.RESPONSE, (c) => c],
73
+ [ParamType.COOKIE, (c, p) => p.name ? getCookie(c, p.name) : getCookie(c)],
74
+ [ParamType.RAW_BODY, async (c) => new Uint8Array(await c.req.arrayBuffer())]
75
+ ]);
76
+ var ArgumentResolver = class {
77
+ ipExtractor;
78
+ constructor(ipExtractor) {
79
+ this.ipExtractor = ipExtractor;
80
+ }
81
+ async extract(c, paramMetadata, pipes, requestContainer, paramTypes) {
82
+ if (paramMetadata.length === 0) return [c];
83
+ const maxIndex = paramMetadata.at(-1).index;
84
+ const args = new Array(maxIndex + 1).fill(void 0);
85
+ for (const param of paramMetadata) {
86
+ let value = await this.extractParam(c, param);
87
+ const metadata = {
88
+ type: param.type,
89
+ data: param.name,
90
+ metatype: param.metatype ?? paramTypes?.[param.index]
91
+ };
92
+ for (const pipe of pipes) value = await pipe.transform(value, metadata);
93
+ if (param.pipes && param.pipes.length > 0) for (const paramPipe of param.pipes) value = await instantiate(paramPipe, requestContainer).transform(value, metadata);
94
+ args[param.index] = value;
95
+ }
96
+ return args;
97
+ }
98
+ extractParam(c, param) {
99
+ if (param.type === ParamType.IP) return this.ipExtractor(c);
100
+ const extractor = PARAM_EXTRACTORS.get(param.type);
101
+ if (extractor) return extractor(c, param);
102
+ return param.factory ? param.factory(param.name, c) : void 0;
103
+ }
104
+ };
105
+ //#endregion
106
+ //#region src/http/route-contributor.ts
107
+ const STORE_KEY = Symbol.for("vela:route-contributors:v1");
108
+ function store() {
109
+ const g = globalThis;
110
+ return g[STORE_KEY] ??= /* @__PURE__ */ new Map();
111
+ }
112
+ /** Register a contributor. Last registration per `id` wins. */
113
+ function registerRouteContributor(contributor) {
114
+ store().set(contributor.id, contributor);
115
+ }
116
+ /** All registered contributors (registration order). */
117
+ function getRouteContributors() {
118
+ return [...store().values()];
119
+ }
120
+ //#endregion
121
+ //#region src/http/execution-context.ts
122
+ function buildExecutionContext(c, controller, handlerName) {
123
+ return {
124
+ getType: () => "http",
125
+ getClass: () => controller,
126
+ getHandler: () => handlerName,
127
+ getContext: () => c,
128
+ getRequest: () => c.req.raw,
129
+ switchToHttp: () => ({
130
+ getRequest: () => c.req.raw,
131
+ getResponse: () => c
132
+ }),
133
+ switchToWs: () => {
134
+ throw new Error("switchToWs() called on an HTTP ExecutionContext. This handler runs over HTTP, not a WebSocket gateway.");
135
+ }
136
+ };
137
+ }
138
+ var VelaMiddlewareHost = class {};
139
+ const VELA_MIDDLEWARE_HANDLER = Symbol.for("vela.middleware");
140
+ function buildMiddlewareExecutionContext(c) {
141
+ return buildExecutionContext(c, VelaMiddlewareHost, VELA_MIDDLEWARE_HANDLER);
142
+ }
143
+ //#endregion
144
+ //#region src/pipeline/pipeline-runner.ts
145
+ /**
146
+ * The transport-agnostic guard → pipe → interceptor execution core shared by
147
+ * the HTTP `HandlerExecutor` and the WebSocket `WsDispatcher` (and any future
148
+ * entrypoint dispatcher: queue consumers, scheduled jobs, …). Exception
149
+ * FILTERS stay with the caller — their terminal behavior is transport-specific
150
+ * (HTTP maps to a Response, WS sends an error frame).
151
+ */
152
+ var PipelineRunner = class PipelineRunner {
153
+ static async run(options) {
154
+ let args;
155
+ if (options.argsBeforeGuards) args = await options.resolveArgs();
156
+ for (const guard of options.guards) if (!await guard.canActivate(options.context)) throw options.onGuardReject?.() ?? new ForbiddenException();
157
+ args ??= await options.resolveArgs();
158
+ const resolvedArgs = args;
159
+ return PipelineRunner.chainInterceptors(options.interceptors, options.context, () => options.invoke(resolvedArgs));
160
+ }
161
+ /** Interceptor onion — innermost is the core handler. */
162
+ static async chainInterceptors(interceptors, context, coreHandler) {
163
+ if (interceptors.length === 0) return coreHandler();
164
+ let next = { handle: coreHandler };
165
+ for (let i = interceptors.length - 1; i >= 0; i--) {
166
+ const interceptor = interceptors[i];
167
+ const currentNext = next;
168
+ next = { handle: () => interceptor.intercept(context, currentNext) };
169
+ }
170
+ return next.handle();
171
+ }
172
+ };
173
+ //#endregion
174
+ //#region src/pipeline/component.manager.ts
175
+ function isObject(value) {
176
+ return typeof value === "object" && value !== null;
177
+ }
178
+ /**
179
+ * Component registration + resolution for the controller/handler tiers.
180
+ * App-wide (global) components have exactly ONE source: the per-app
181
+ * `RouteManager` (`APP_*` provider tokens + `useGlobalX()`) — callers merge
182
+ * `routeManager.getGlobalComponents()` with {@link getScopedComponents}.
183
+ *
184
+ * Stateless by design: no process-global container (two apps in one process
185
+ * never cross-talk) — every `resolve*` takes the resolving container.
186
+ */
187
+ var ComponentManager = class {
188
+ static registerController(type, controller, ...components) {
189
+ for (const component of components) MetadataRegistry.registerController(type, controller, component);
190
+ }
191
+ static registerHandler(type, controller, handlerName, ...components) {
192
+ for (const component of components) MetadataRegistry.registerHandler(type, controller, handlerName, component);
193
+ }
194
+ static getScopedComponents(type, controller, handlerName) {
195
+ return [...MetadataRegistry.getController(type, controller), ...MetadataRegistry.getHandler(type, controller, handlerName)];
196
+ }
197
+ static resolveAll(items, methodKey, container) {
198
+ return items.map((item) => isObject(item) && methodKey in item ? item : container.resolve(item));
199
+ }
200
+ static resolveMiddleware(items, container) {
201
+ return this.resolveAll(items, "use", container);
202
+ }
203
+ static resolveGuards(items, container) {
204
+ return this.resolveAll(items, "canActivate", container);
205
+ }
206
+ static resolvePipes(items, container) {
207
+ return this.resolveAll(items, "transform", container);
208
+ }
209
+ static resolveInterceptors(items, container) {
210
+ return this.resolveAll(items, "intercept", container);
211
+ }
212
+ static resolveFilters(items, container) {
213
+ return this.resolveAll(items, "catch", container);
214
+ }
215
+ static async executePipes(value, metadata, pipes) {
216
+ let transformed = value;
217
+ for (const pipe of pipes) transformed = await pipe.transform(transformed, metadata);
218
+ return transformed;
219
+ }
220
+ static async runInterceptorChain(interceptors, context, coreHandler) {
221
+ return PipelineRunner.chainInterceptors(interceptors, context, coreHandler);
222
+ }
223
+ };
224
+ //#endregion
225
+ //#region src/pipeline/decorators.ts
226
+ function UseComponent(type, ...components) {
227
+ return (target, propertyKey) => {
228
+ if (propertyKey !== void 0) ComponentManager.registerHandler(type, target.constructor, propertyKey, ...components);
229
+ else ComponentManager.registerController(type, target, ...components);
230
+ };
231
+ }
232
+ function UseMiddleware(...middleware) {
233
+ return UseComponent("middleware", ...middleware);
234
+ }
235
+ function UseGuards(...guards) {
236
+ return UseComponent("guard", ...guards);
237
+ }
238
+ function UsePipes(...pipes) {
239
+ return UseComponent("pipe", ...pipes);
240
+ }
241
+ function UseInterceptors(...interceptors) {
242
+ return UseComponent("interceptor", ...interceptors);
243
+ }
244
+ function UseFilters(...filters) {
245
+ return UseComponent("filter", ...filters);
246
+ }
247
+ function Catch(...exceptions) {
248
+ return (target) => {
249
+ MetadataRegistry.setCatchTypes(target, exceptions);
250
+ };
251
+ }
252
+ function getCatchTypes(filter) {
253
+ const filterClass = typeof filter === "function" ? filter : filter.constructor;
254
+ return MetadataRegistry.getCatchTypes(filterClass) ?? [];
255
+ }
256
+ function shouldFilterCatch(filter, exception) {
257
+ const catchTypes = getCatchTypes(filter);
258
+ if (catchTypes.length === 0) return true;
259
+ return catchTypes.some((type) => exception instanceof type);
260
+ }
261
+ //#endregion
262
+ //#region src/http/decorators.ts
263
+ /**
264
+ * Marks a class as a controller.
265
+ * Accepts a path string or an options object with `path` and `version`.
266
+ *
267
+ * @example
268
+ * ```ts
269
+ * @Controller('/users')
270
+ * @Controller({ path: '/users', version: 1 })
271
+ * @Controller({ path: '/users', version: [1, 2] })
272
+ * ```
273
+ */
274
+ function Controller(pathOrOptions) {
275
+ return (target) => {
276
+ const ctor = target;
277
+ const path = typeof pathOrOptions === "string" ? pathOrOptions : pathOrOptions?.path ?? "";
278
+ const version = typeof pathOrOptions === "object" ? pathOrOptions?.version : void 0;
279
+ MetadataRegistry.setControllerPath(ctor, normalizePath(path));
280
+ if (version !== void 0) MetadataRegistry.setControllerOptions(ctor, { version });
281
+ MetadataRegistry.markInjectable(ctor);
282
+ MetadataRegistry.setScope(ctor, Scope.SINGLETON);
283
+ };
284
+ }
285
+ /**
286
+ * Override the version for a specific route method.
287
+ *
288
+ * @example
289
+ * ```ts
290
+ * @Controller({ prefix: '/users', version: 1 })
291
+ * class UserController {
292
+ * @Get()
293
+ * listV1() { ... } // GET /v1/users
294
+ *
295
+ * @Version(2)
296
+ * @Get()
297
+ * listV2() { ... } // GET /v2/users
298
+ * }
299
+ * ```
300
+ */
301
+ function Version(version) {
302
+ return (target, propertyKey, _descriptor) => {
303
+ const ctor = target.constructor;
304
+ MetadataRegistry.setRouteVersion(ctor, propertyKey, version);
305
+ const route = MetadataRegistry.getRoutes(ctor).find((r) => r.handlerName === propertyKey);
306
+ if (route) route.version = version;
307
+ };
308
+ }
309
+ function createMethodDecorator(method) {
310
+ return (path = "", options) => {
311
+ return (target, propertyKey, _descriptor) => {
312
+ const ctor = target.constructor;
313
+ const normalizedPath = normalizePath(path);
314
+ const version = MetadataRegistry.getRouteVersion(ctor, propertyKey);
315
+ MetadataRegistry.addRoute(ctor, {
316
+ method,
317
+ path: normalizedPath,
318
+ handlerName: propertyKey,
319
+ ...version !== void 0 ? { version } : {},
320
+ ...options?.name !== void 0 ? { name: options.name } : {}
321
+ });
322
+ };
323
+ };
324
+ }
325
+ const Get = createMethodDecorator(HttpMethod.GET);
326
+ const Post = createMethodDecorator(HttpMethod.POST);
327
+ const Put = createMethodDecorator(HttpMethod.PUT);
328
+ const Patch = createMethodDecorator(HttpMethod.PATCH);
329
+ const Delete = createMethodDecorator(HttpMethod.DELETE);
330
+ const Options = createMethodDecorator(HttpMethod.OPTIONS);
331
+ const Head = createMethodDecorator(HttpMethod.HEAD);
332
+ const All = createMethodDecorator(HttpMethod.ALL);
333
+ const Sse = createMethodDecorator(HttpMethod.GET);
334
+ const CUSTOM_PARAM_TYPE = "custom";
335
+ function createBuiltinParamDecorator(type) {
336
+ return (nameOrPipe, ...pipes) => {
337
+ return (target, propertyKey, parameterIndex) => {
338
+ if (propertyKey === void 0) throw new Error("Parameter decorators can only be used on method parameters");
339
+ let name;
340
+ let allPipes;
341
+ if (typeof nameOrPipe === "string") {
342
+ name = nameOrPipe;
343
+ allPipes = pipes;
344
+ } else if (nameOrPipe !== void 0) {
345
+ name = void 0;
346
+ allPipes = [nameOrPipe, ...pipes];
347
+ } else {
348
+ name = void 0;
349
+ allPipes = pipes;
350
+ }
351
+ MetadataRegistry.addParameter(target.constructor, propertyKey, {
352
+ index: parameterIndex,
353
+ type,
354
+ name,
355
+ ...allPipes.length > 0 ? { pipes: allPipes } : {}
356
+ });
357
+ };
358
+ };
359
+ }
360
+ const Param = createBuiltinParamDecorator(ParamType.PARAM);
361
+ const Query = createBuiltinParamDecorator(ParamType.QUERY);
362
+ const Body = createBuiltinParamDecorator(ParamType.BODY);
363
+ const Headers = createBuiltinParamDecorator(ParamType.HEADERS);
364
+ const Req = createBuiltinParamDecorator(ParamType.REQUEST);
365
+ /**
366
+ * Injects the Hono `Context` as the response handle.
367
+ * In Hono, request and response state are unified in the `Context` object,
368
+ * so `@Res()` and `@Req()` both return it.
369
+ *
370
+ * Use `c.header()`, `c.setCookie()`, `c.redirect()`, etc. for response control.
371
+ *
372
+ * @example
373
+ * ```ts
374
+ * @Get('/set-cookie')
375
+ * handle(@Res() c: Context) {
376
+ * c.setCookie('session', 'abc123', { httpOnly: true });
377
+ * return { ok: true };
378
+ * }
379
+ * ```
380
+ */
381
+ const Res = createBuiltinParamDecorator(ParamType.RESPONSE);
382
+ const Ip = createBuiltinParamDecorator(ParamType.IP);
383
+ const Cookie = createBuiltinParamDecorator(ParamType.COOKIE);
384
+ /**
385
+ * Injects all cookies as a `Record<string, string>`, or a single cookie value by name.
386
+ *
387
+ * - `@Cookie()` — all cookies as an object
388
+ * - `@Cookie('token')` — the value of the `token` cookie
389
+ *
390
+ * @example
391
+ * ```ts
392
+ * @Get('/me')
393
+ * handle(@Cookie('session') session: string) { ... }
394
+ * ```
395
+ */
396
+ const Cookies = Cookie;
397
+ /**
398
+ * Injects the raw request body as a `Uint8Array`.
399
+ * Useful for webhook HMAC verification (Stripe, GitHub, etc.) where you
400
+ * need the raw bytes before any JSON parsing.
401
+ *
402
+ * @example
403
+ * ```ts
404
+ * @Post('/webhook')
405
+ * async handle(@RawBody() body: Uint8Array) {
406
+ * const sig = new TextDecoder().decode(body);
407
+ * // verify HMAC...
408
+ * }
409
+ * ```
410
+ */
411
+ function RawBody() {
412
+ return (target, propertyKey, parameterIndex) => {
413
+ if (propertyKey === void 0) throw new Error("Parameter decorators can only be used on method parameters");
414
+ MetadataRegistry.addParameter(target.constructor, propertyKey, {
415
+ index: parameterIndex,
416
+ type: ParamType.RAW_BODY
417
+ });
418
+ };
419
+ }
420
+ /**
421
+ * Factory for creating custom parameter decorators.
422
+ *
423
+ * @example
424
+ * ```ts
425
+ * const CurrentUser = createParamDecorator(
426
+ * (data: unknown, ctx: ExecutionContext) => {
427
+ * const req = ctx.getRequest();
428
+ * return req.headers.get('x-user-id');
429
+ * }
430
+ * );
431
+ *
432
+ * // Usage:
433
+ * @Get()
434
+ * handle(@CurrentUser() userId: string) { ... }
435
+ *
436
+ * // With data argument:
437
+ * const Header = createParamDecorator(
438
+ * (data: string, ctx: ExecutionContext) => {
439
+ * return ctx.getRequest().headers.get(data);
440
+ * }
441
+ * );
442
+ *
443
+ * @Get()
444
+ * handle(@Header('x-request-id') requestId: string) { ... }
445
+ * ```
446
+ */
447
+ function createParamDecorator(factory) {
448
+ return (data, ...pipes) => {
449
+ return (target, propertyKey, parameterIndex) => {
450
+ if (propertyKey === void 0) throw new Error("Parameter decorators can only be used on method parameters");
451
+ MetadataRegistry.addParameter(target.constructor, propertyKey, {
452
+ index: parameterIndex,
453
+ type: CUSTOM_PARAM_TYPE,
454
+ name: void 0,
455
+ factory: (_unused, ctx) => {
456
+ return factory(data, buildExecutionContext(ctx, target.constructor, propertyKey));
457
+ },
458
+ ...pipes.length > 0 ? { pipes } : {}
459
+ });
460
+ };
461
+ };
462
+ }
463
+ /**
464
+ * Override the HTTP status code for a handler's response.
465
+ *
466
+ * @example
467
+ * ```ts
468
+ * @Post()
469
+ * @HttpCode(201)
470
+ * create(@Body() data: CreateDto) { return data; }
471
+ * ```
472
+ */
473
+ function HttpCode(statusCode) {
474
+ return (target, propertyKey, _descriptor) => {
475
+ MetadataRegistry.setHandlerHttpMeta(target.constructor, propertyKey, { httpCode: statusCode });
476
+ };
477
+ }
478
+ /**
479
+ * Set a response header declaratively.
480
+ * Can be applied multiple times to set multiple headers.
481
+ *
482
+ * @example
483
+ * ```ts
484
+ * @Get()
485
+ * @Header('Cache-Control', 'no-cache')
486
+ * @Header('X-Custom', 'value')
487
+ * handle() { return { ok: true }; }
488
+ * ```
489
+ */
490
+ function Header(name, value) {
491
+ return (target, propertyKey, _descriptor) => {
492
+ MetadataRegistry.setHandlerHttpMeta(target.constructor, propertyKey, { responseHeaders: [[name, value]] });
493
+ };
494
+ }
495
+ /**
496
+ * Redirect to another URL. The handler's return value can override the URL.
497
+ *
498
+ * @example
499
+ * ```ts
500
+ * @Get('/old')
501
+ * @Redirect('/new', 301)
502
+ * handleOld() {}
503
+ *
504
+ * // Dynamic redirect — return { url, statusCode? } to override
505
+ * @Get('/go')
506
+ * @Redirect('/default')
507
+ * handleGo(@Query('to') to?: string) {
508
+ * if (to) return { url: to };
509
+ * }
510
+ * ```
511
+ */
512
+ function Redirect(url, statusCode = 302) {
513
+ return (target, propertyKey, _descriptor) => {
514
+ MetadataRegistry.setHandlerHttpMeta(target.constructor, propertyKey, { redirect: {
515
+ url,
516
+ statusCode
517
+ } });
518
+ };
519
+ }
520
+ function getHttpCode(target, method) {
521
+ return MetadataRegistry.getHandlerHttpMeta(target, method)?.httpCode;
522
+ }
523
+ function getResponseHeaders(target, method) {
524
+ return MetadataRegistry.getHandlerHttpMeta(target, method)?.responseHeaders ?? [];
525
+ }
526
+ function getRedirect(target, method) {
527
+ return MetadataRegistry.getHandlerHttpMeta(target, method)?.redirect;
528
+ }
529
+ function applyDecorators(...decorators) {
530
+ return ((target, propertyKey, descriptor) => {
531
+ for (const decorator of decorators) if (propertyKey === void 0 && typeof descriptor !== "number") decorator(target);
532
+ else if (typeof descriptor === "number") decorator(target, propertyKey, descriptor);
533
+ else decorator(target, propertyKey, descriptor);
534
+ });
535
+ }
536
+ //#endregion
537
+ //#region src/http/response-mapper.ts
538
+ function parseRedirectResult(result) {
539
+ if (typeof result !== "object" || result === null) return void 0;
540
+ if (!("url" in result)) return void 0;
541
+ const obj = result;
542
+ if (typeof obj.url !== "string") return void 0;
543
+ return {
544
+ url: obj.url,
545
+ ...typeof obj.statusCode === "number" ? { statusCode: obj.statusCode } : {}
546
+ };
547
+ }
548
+ function mapResponse(c, result, statusCode) {
549
+ if (result instanceof Response) return result;
550
+ if (result === null || result === void 0) return c.body(null, statusCode ?? 204);
551
+ if (typeof result === "string") return c.text(result, statusCode ?? 200);
552
+ return c.json(result, statusCode ?? 200);
553
+ }
554
+ function mapRedirect(c, result, redirect) {
555
+ const overrides = parseRedirectResult(result);
556
+ const finalUrl = overrides?.url ?? redirect.url;
557
+ const finalStatus = overrides?.statusCode ?? redirect.statusCode;
558
+ return c.redirect(finalUrl, finalStatus);
559
+ }
560
+ function applyResponseHeaders(response, headers) {
561
+ for (const [name, value] of headers) response.headers.set(name, value);
562
+ }
563
+ //#endregion
564
+ //#region src/http/handler-executor.ts
565
+ var HandlerExecutor = class {
566
+ argumentResolver;
567
+ getGlobals;
568
+ getRequestContainer;
569
+ constructor(argumentResolver, getGlobals, getRequestContainer) {
570
+ this.argumentResolver = argumentResolver;
571
+ this.getGlobals = getGlobals;
572
+ this.getRequestContainer = getRequestContainer;
573
+ }
574
+ create(route, controller, allParamMetadata) {
575
+ const paramMetadata = (allParamMetadata.get(route.handlerName) || []).sort((a, b) => a.index - b.index);
576
+ const paramTypes = Reflect.getMetadata("design:paramtypes", controller.prototype, route.handlerName);
577
+ const methodGuards = ComponentManager.getScopedComponents("guard", controller, route.handlerName);
578
+ const methodPipes = ComponentManager.getScopedComponents("pipe", controller, route.handlerName);
579
+ const methodInterceptors = ComponentManager.getScopedComponents("interceptor", controller, route.handlerName);
580
+ const methodFilters = [...ComponentManager.getScopedComponents("filter", controller, route.handlerName)].reverse();
581
+ const httpCode = getHttpCode(controller, route.handlerName);
582
+ const responseHeaders = getResponseHeaders(controller, route.handlerName);
583
+ const redirect = getRedirect(controller, route.handlerName);
584
+ return async (c) => {
585
+ const requestContainer = this.getRequestContainer(c);
586
+ const globals = this.getGlobals();
587
+ const guards = [...instantiateMany(globals.guards, requestContainer), ...instantiateMany(methodGuards, requestContainer)];
588
+ const pipes = [...instantiateMany(globals.pipes, requestContainer), ...instantiateMany(methodPipes, requestContainer)];
589
+ const interceptors = [...instantiateMany(globals.interceptors, requestContainer), ...instantiateMany(methodInterceptors, requestContainer)];
590
+ const filters = [...instantiateMany(methodFilters, requestContainer), ...instantiateMany(globals.filters, requestContainer)];
591
+ const executionContext = buildExecutionContext(c, controller, route.handlerName);
592
+ try {
593
+ const instance = requestContainer.resolve(controller);
594
+ const method = Reflect.get(instance, route.handlerName);
595
+ if (typeof method !== "function") throw new Error(`Method ${String(route.handlerName)} not found on controller`);
596
+ const result = await PipelineRunner.run({
597
+ context: executionContext,
598
+ guards,
599
+ interceptors,
600
+ argsBeforeGuards: true,
601
+ resolveArgs: () => this.argumentResolver.extract(c, paramMetadata, pipes, requestContainer, paramTypes),
602
+ invoke: async (args) => Reflect.apply(method, instance, args)
603
+ });
604
+ if (redirect) return mapRedirect(c, result, redirect);
605
+ const response = mapResponse(c, result, httpCode);
606
+ applyResponseHeaders(response, responseHeaders);
607
+ return response;
608
+ } catch (error) {
609
+ const reporter = resolveErrorReporter(requestContainer);
610
+ const source = `${controller.name}.${String(route.handlerName)}`;
611
+ reporter.report(error, {
612
+ edge: "http",
613
+ source
614
+ });
615
+ for (const filter of filters) if (shouldFilterCatch(filter, error)) try {
616
+ return mapResponse(c, await filter.catch(error, executionContext));
617
+ } catch (filterError) {
618
+ reporter.report(filterError, {
619
+ edge: "http",
620
+ source,
621
+ note: "exception filter threw"
622
+ });
623
+ break;
624
+ }
625
+ const rendered = reporter.render(error, executionContext);
626
+ if (rendered instanceof Response) return rendered;
627
+ if (rendered) return c.json(rendered.body, rendered.status);
628
+ if (error instanceof HttpException) {
629
+ const status = error.getStatus();
630
+ const raw = error.getRawResponse() ?? error.message;
631
+ if (typeof raw === "string") return c.json({ error: {
632
+ code: STATUS_TO_CODE[status] ?? "internal",
633
+ message: raw
634
+ } }, status);
635
+ return c.json(raw, status);
636
+ }
637
+ const { body, status } = toErrorBody(error, { catalog: reporter.catalog });
638
+ return c.json(body, status);
639
+ }
640
+ };
641
+ }
642
+ };
643
+ //#endregion
644
+ //#region src/http/route.manager.ts
645
+ const defaultGetClientIp = (c) => c.req.raw.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ?? c.req.raw.headers.get("x-real-ip") ?? null;
646
+ function disposeStreamWhenDone(body, onDone) {
647
+ const reader = body.getReader();
648
+ let finished = false;
649
+ const finish = () => {
650
+ if (!finished) {
651
+ finished = true;
652
+ onDone();
653
+ }
654
+ };
655
+ return new ReadableStream({
656
+ async pull(controller) {
657
+ try {
658
+ const { done, value } = await reader.read();
659
+ if (done) {
660
+ controller.close();
661
+ finish();
662
+ return;
663
+ }
664
+ controller.enqueue(value);
665
+ } catch (error) {
666
+ controller.error(error);
667
+ finish();
668
+ }
669
+ },
670
+ cancel(reason) {
671
+ finish();
672
+ return reader.cancel(reason);
673
+ }
674
+ });
675
+ }
676
+ var RouteManager = class RouteManager {
677
+ container;
678
+ static METHOD_REGISTRAR = /* @__PURE__ */ new Map([
679
+ [HttpMethod.GET, (app, p, h) => app.get(p, h)],
680
+ [HttpMethod.POST, (app, p, h) => app.post(p, h)],
681
+ [HttpMethod.PUT, (app, p, h) => app.put(p, h)],
682
+ [HttpMethod.PATCH, (app, p, h) => app.patch(p, h)],
683
+ [HttpMethod.DELETE, (app, p, h) => app.delete(p, h)],
684
+ [HttpMethod.OPTIONS, (app, p, h) => app.options(p, h)],
685
+ [HttpMethod.HEAD, (app, p, h) => app.get(p, (c, next) => c.req.method === "HEAD" ? h(c) : next())],
686
+ [HttpMethod.ALL, (app, p, h) => app.all(p, h)]
687
+ ]);
688
+ controllers = [];
689
+ globalMiddleware = [];
690
+ globalPipes = [];
691
+ globalGuards = [];
692
+ globalInterceptors = [];
693
+ globalFilters = [];
694
+ globalPrefix = "";
695
+ consumerMiddlewareDefinitions = [];
696
+ routeDescriptions = [];
697
+ handlerExecutor;
698
+ ambientContainer;
699
+ constructor(container, options = {}) {
700
+ this.container = container;
701
+ this.ambientContainer = options.ambientContainer ?? false;
702
+ const argumentResolver = new ArgumentResolver(options.getClientIp ?? defaultGetClientIp);
703
+ this.handlerExecutor = new HandlerExecutor(argumentResolver, () => ({
704
+ guards: this.globalGuards,
705
+ pipes: this.globalPipes,
706
+ interceptors: this.globalInterceptors,
707
+ filters: this.globalFilters
708
+ }), (c) => this.getRequestContainer(c));
709
+ }
710
+ /**
711
+ * The global-tier components (`APP_*` provider tokens + imperative
712
+ * `app.useGlobalX()` instances). Exposed so non-HTTP transports (the
713
+ * WebSocket dispatcher) can apply the same app-wide guards/pipes/interceptors/
714
+ * filters as HTTP routes, read live so late registrations propagate.
715
+ */
716
+ getGlobalComponents() {
717
+ return {
718
+ guards: this.globalGuards,
719
+ pipes: this.globalPipes,
720
+ interceptors: this.globalInterceptors,
721
+ filters: this.globalFilters
722
+ };
723
+ }
724
+ registerConsumerMiddleware(definitions) {
725
+ this.consumerMiddlewareDefinitions.push(...definitions);
726
+ return this;
727
+ }
728
+ setGlobalPrefix(prefix) {
729
+ this.globalPrefix = prefix && !prefix.startsWith("/") ? `/${prefix}` : prefix;
730
+ return this;
731
+ }
732
+ useGlobalMiddleware(...middleware) {
733
+ this.globalMiddleware.push(...middleware);
734
+ return this;
735
+ }
736
+ useGlobalMiddlewareTokens(...middlewareTokens) {
737
+ this.globalMiddleware.push(...middlewareTokens);
738
+ return this;
739
+ }
740
+ useGlobalPipes(...pipes) {
741
+ this.globalPipes.push(...pipes);
742
+ return this;
743
+ }
744
+ useGlobalPipeTokens(...pipeTokens) {
745
+ this.globalPipes.push(...pipeTokens);
746
+ return this;
747
+ }
748
+ useGlobalGuards(...guards) {
749
+ this.globalGuards.push(...guards);
750
+ return this;
751
+ }
752
+ useGlobalGuardTokens(...guardTokens) {
753
+ this.globalGuards.push(...guardTokens);
754
+ return this;
755
+ }
756
+ useGlobalInterceptors(...interceptors) {
757
+ this.globalInterceptors.push(...interceptors);
758
+ return this;
759
+ }
760
+ useGlobalInterceptorTokens(...interceptorTokens) {
761
+ this.globalInterceptors.push(...interceptorTokens);
762
+ return this;
763
+ }
764
+ useGlobalFilters(...filters) {
765
+ this.globalFilters.push(...filters);
766
+ return this;
767
+ }
768
+ useGlobalFilterTokens(...filterTokens) {
769
+ this.globalFilters.push(...filterTokens);
770
+ return this;
771
+ }
772
+ getMiddlewarePriority(entry) {
773
+ if (entry == null) return 0;
774
+ if (typeof entry === "function") {
775
+ const p = entry.priority;
776
+ if (typeof p === "number") return p;
777
+ }
778
+ if (typeof entry === "object") {
779
+ const inst = entry;
780
+ if (typeof inst.priority === "number") return inst.priority;
781
+ if (typeof inst.constructor?.priority === "number") return inst.constructor.priority;
782
+ }
783
+ if (this.container.isLazyPending(entry)) return 0;
784
+ try {
785
+ const resolved = instantiate(entry, this.container);
786
+ if (resolved && typeof resolved === "object") {
787
+ const p = resolved.priority;
788
+ if (typeof p === "number") return p;
789
+ const cp = resolved.constructor?.priority;
790
+ if (typeof cp === "number") return cp;
791
+ }
792
+ } catch {}
793
+ return 0;
794
+ }
795
+ getRequestContainer(c) {
796
+ const existing = c.get("container");
797
+ if (existing) return existing;
798
+ const child = this.container.createChild();
799
+ child.setRequestInstance(REQUEST_CONTEXT, createRequestContext(c));
800
+ c.set("container", child);
801
+ return child;
802
+ }
803
+ wrapMiddlewareWithFilters(handler) {
804
+ return async (c, next) => {
805
+ try {
806
+ return await handler(c, next);
807
+ } catch (error) {
808
+ const response = await this.mapMiddlewareError(c, error);
809
+ c.res = response;
810
+ return response;
811
+ }
812
+ };
813
+ }
814
+ async mapMiddlewareError(c, error) {
815
+ const requestContainer = this.getRequestContainer(c);
816
+ const filters = instantiateMany(this.globalFilters, requestContainer);
817
+ const host = buildMiddlewareExecutionContext(c);
818
+ for (const filter of filters) if (shouldFilterCatch(filter, error)) try {
819
+ return mapResponse(c, await filter.catch(error, host));
820
+ } catch {
821
+ break;
822
+ }
823
+ if (error instanceof HttpException) {
824
+ const response = error.getResponse();
825
+ const status = error.getStatus();
826
+ return c.json(response, status);
827
+ }
828
+ throw error;
829
+ }
830
+ registerController(controller) {
831
+ const prefix = MetadataRegistry.getControllerPath(controller);
832
+ const options = MetadataRegistry.getControllerOptions(controller);
833
+ const routes = MetadataRegistry.getRoutes(controller);
834
+ if (!this.container.has(controller)) this.container.register(controller);
835
+ this.controllers.push({
836
+ controller,
837
+ metadata: {
838
+ prefix,
839
+ version: options.version
840
+ },
841
+ routes
842
+ });
843
+ return this;
844
+ }
845
+ /** The explicit controller routes recorded by the last `build()`. */
846
+ getRouteDescriptions() {
847
+ return [...this.routeDescriptions];
848
+ }
849
+ /** The global prefix in effect (set at bootstrap; '' when none). */
850
+ getGlobalPrefix() {
851
+ return this.globalPrefix;
852
+ }
853
+ async build() {
854
+ const app = new Hono();
855
+ this.routeDescriptions = [];
856
+ app.use("*", async (c, next) => {
857
+ let threw = false;
858
+ try {
859
+ await next();
860
+ } catch (error) {
861
+ threw = true;
862
+ throw error;
863
+ } finally {
864
+ const child = c.get("container");
865
+ if (child?.hasDisposables()) {
866
+ const body = threw ? null : c.res?.body ?? null;
867
+ if (body) c.res = new Response(disposeStreamWhenDone(body, () => void child.dispose()), {
868
+ status: c.res.status,
869
+ statusText: c.res.statusText,
870
+ headers: c.res.headers
871
+ });
872
+ else await child.dispose();
873
+ }
874
+ }
875
+ });
876
+ if (this.ambientContainer) app.use("*", contextStorage());
877
+ const sortedGlobal = this.globalMiddleware.map((entry, index) => ({
878
+ entry,
879
+ index,
880
+ priority: this.getMiddlewarePriority(entry)
881
+ })).sort((a, b) => a.priority - b.priority || a.index - b.index);
882
+ for (const { entry } of sortedGlobal) app.use("*", this.wrapMiddlewareWithFilters((c, next) => {
883
+ const requestContainer = this.getRequestContainer(c);
884
+ return instantiate(entry, requestContainer).use(c, next);
885
+ }));
886
+ const sortedConsumer = this.consumerMiddlewareDefinitions.map((def, index) => ({
887
+ def,
888
+ index,
889
+ priority: def.priority ?? 0
890
+ })).sort((a, b) => a.priority - b.priority || a.index - b.index);
891
+ for (const { def } of sortedConsumer) {
892
+ const matchRoute = this.compileRouteMatcher(def.routes);
893
+ const matchExclude = this.compileRouteMatcher(def.excludes);
894
+ app.use("*", this.wrapMiddlewareWithFilters((c, next) => {
895
+ const path = c.req.path;
896
+ const method = c.req.method;
897
+ if (!matchRoute(path, method) || matchExclude(path, method)) return next();
898
+ const requestContainer = this.getRequestContainer(c);
899
+ const runChain = (index) => {
900
+ if (index >= def.middleware.length) return next();
901
+ return instantiate(def.middleware[index], requestContainer).use(c, () => runChain(index + 1)).then(() => {});
902
+ };
903
+ return runChain(0);
904
+ }));
905
+ }
906
+ for (const { controller, metadata, routes } of this.controllers) if (routes.length > 0) {
907
+ const allParamMetadata = MetadataRegistry.getParameters(controller);
908
+ for (const route of routes) {
909
+ const effectiveVersion = route.version ?? metadata.version;
910
+ const versionedPaths = this.buildVersionedPaths(this.globalPrefix, metadata.prefix, route.path, effectiveVersion);
911
+ const versionsForPaths = effectiveVersion === void 0 ? [void 0] : Array.isArray(effectiveVersion) ? effectiveVersion : [effectiveVersion];
912
+ const middlewareItems = ComponentManager.getScopedComponents("middleware", controller, route.handlerName);
913
+ const handler = this.handlerExecutor.create(route, controller, allParamMetadata);
914
+ for (const [pathIndex, fullPath] of versionedPaths.entries()) {
915
+ for (const middlewareItem of middlewareItems) app.use(fullPath, this.wrapMiddlewareWithFilters((c, next) => {
916
+ const requestContainer = this.getRequestContainer(c);
917
+ return instantiate(middlewareItem, requestContainer).use(c, next);
918
+ }));
919
+ this.registerRoute(app, route.method, fullPath, handler);
920
+ this.routeDescriptions.push({
921
+ method: String(route.method),
922
+ path: fullPath || "/",
923
+ controller: controller.name,
924
+ handler: String(route.handlerName),
925
+ version: versionsForPaths[pathIndex],
926
+ ...route.name !== void 0 ? { name: route.name } : {}
927
+ });
928
+ }
929
+ }
930
+ }
931
+ const contributors = getRouteContributors();
932
+ for (const { controller, metadata, routes } of this.controllers) {
933
+ for (const contributor of contributors) {
934
+ const meta = getMetadata(contributor.claimsMetaKey, controller);
935
+ if (meta === void 0) continue;
936
+ await contributor.buildRoutes(app, {
937
+ controller,
938
+ controllerPrefix: metadata.prefix,
939
+ meta,
940
+ globalPrefix: this.globalPrefix,
941
+ globalGuards: instantiateMany(this.globalGuards, this.container),
942
+ container: this.container,
943
+ joinPaths
944
+ });
945
+ }
946
+ if (getMetadata("vela:crud", controller) !== void 0 && routes.length === 0 && !contributors.some((c) => c.claimsMetaKey === "vela:crud")) console.warn(`[vela] ${controller.name} carries @Crud() metadata but produced no routes — install and import '@velajs/crud' (>=1.18), or remove the decorator.`);
947
+ }
948
+ return app;
949
+ }
950
+ registerRoute(app, method, path, handler) {
951
+ const normalizedPath = path || "/";
952
+ const registrar = RouteManager.METHOD_REGISTRAR.get(method);
953
+ if (registrar) registrar(app, normalizedPath, handler);
954
+ else app.on(method, normalizedPath, handler);
955
+ }
956
+ buildVersionedPaths(globalPrefix, controllerPrefix, routePath, version) {
957
+ if (version === void 0) return [joinPaths(globalPrefix, joinPaths(controllerPrefix, routePath))];
958
+ return (Array.isArray(version) ? version : [version]).map((v) => {
959
+ return joinPaths(globalPrefix, joinPaths(`/v${v}`, joinPaths(controllerPrefix, routePath)));
960
+ });
961
+ }
962
+ compilePathMatcher(routePath) {
963
+ if (routePath === "*") return () => true;
964
+ const norm = routePath.startsWith("/") ? routePath : `/${routePath}`;
965
+ if (norm.endsWith("*")) {
966
+ const prefix = norm.slice(0, -1);
967
+ return (p) => p.startsWith(prefix);
968
+ }
969
+ return (p) => p === norm || p.startsWith(`${norm}/`);
970
+ }
971
+ compileRouteMatcher(routes) {
972
+ const matchers = routes.map((route) => {
973
+ const matchPath = this.compilePathMatcher(route.path);
974
+ return (path, method) => {
975
+ if (!matchPath(path)) return false;
976
+ if (route.method && route.method !== HttpMethod.ALL) return method === route.method;
977
+ return true;
978
+ };
979
+ });
980
+ if (matchers.length === 0) return () => false;
981
+ if (matchers.length === 1) return matchers[0];
982
+ return (path, method) => matchers.some((m) => m(path, method));
983
+ }
984
+ getControllers() {
985
+ return [...this.controllers];
986
+ }
987
+ };
988
+ //#endregion
989
+ export { UseGuards as A, registerRouteContributor as B, Res as C, createParamDecorator as D, applyDecorators as E, shouldFilterCatch as F, getMetadata as G, joinPaths as H, ComponentManager as I, PipelineRunner as L, UseMiddleware as M, UsePipes as N, Catch as O, getCatchTypes as P, buildExecutionContext as R, Req as S, Version as T, toOpenApiPath as U, instantiateMany as V, defineMetadata as W, Post as _, Cookie as a, RawBody as b, Get as c, Headers as d, HttpCode as f, Patch as g, Param as h, Controller as i, UseInterceptors as j, UseFilters as k, Head as l, Options as m, All as n, Cookies as o, Ip as p, Body as r, Delete as s, RouteManager as t, Header as u, Put as v, Sse as w, Redirect as x, Query as y, getRouteContributors as z };
990
+
991
+ //# sourceMappingURL=route.manager-DRAZ5X04.js.map