@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
@@ -1,471 +0,0 @@
1
- function _ts_decorate(decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- }
7
- function _ts_metadata(k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- }
10
- function _ts_param(paramIndex, decorator) {
11
- return function(target, key) {
12
- decorator(target, key, paramIndex);
13
- };
14
- }
15
- import { LIVE_ERROR_CODES, LIVE_PROTOCOL, encodeLiveEnvelope, isClientLiveFrame } from "@velajs/live-protocol";
16
- import { Container, DiscoveryService, Inject, Injectable, Optional, PipelineRunner, ReservedWsEvent, buildEntrypointExecutionContext, isVelaError, resolveErrorReporter, resolveScopedComponents, runInEntrypointScope, toErrorBody } from "../index.js";
17
- import { getLiveQueries } from "./live.decorators.js";
18
- import { encodeSubscriptionUpdate } from "./live.delta.js";
19
- import { LIVE_CURSOR_LOG, LIVE_DRIVER, LIVE_MODULE_OPTIONS, LIVE_RESOLVER_METADATA } from "./live.tokens.js";
20
- import { PresenceService } from "./presence.js";
21
- /** How many subscriptions refresh concurrently per flush (lunora's socket-pool default). */ const REFRESH_POOL_SIZE = 8;
22
- /**
23
- * Where the engine persists a connection's subscription records inside
24
- * `client.data` (committed through `WsClient.commit()`). On Cloudflare that
25
- * lands in the hibernation attachment, so subscriptions survive DO eviction;
26
- * the transport replays them via `restoreSubscription` on wake. On node,
27
- * `commit()` is a no-op and this is just in-memory bookkeeping.
28
- */ export const LIVE_SUBS_DATA_KEY = '__velaLiveSubs';
29
- /** Read the subscription records a transport persisted for a connection (wake/restore path). */ export function readPersistedLiveSubscriptions(client) {
30
- const raw = client.data?.[LIVE_SUBS_DATA_KEY];
31
- if (!Array.isArray(raw)) return [];
32
- return raw.filter((record)=>typeof record === 'object' && record !== null && typeof record.sub === 'string' && typeof record.query === 'string' && Array.isArray(record.tags));
33
- }
34
- const defaultIdentity = (client)=>{
35
- const data = client.data;
36
- if (!data || Object.keys(data).length === 0) return undefined;
37
- return {
38
- ...data
39
- };
40
- };
41
- async function runPool(items, size, run) {
42
- const queue = [
43
- ...items
44
- ];
45
- const workers = Array.from({
46
- length: Math.min(size, queue.length)
47
- }, async ()=>{
48
- for(let item = queue.shift(); item !== undefined; item = queue.shift()){
49
- await run(item);
50
- }
51
- });
52
- await Promise.all(workers);
53
- }
54
- export class LiveEngine {
55
- container;
56
- discovery;
57
- log;
58
- options;
59
- presence;
60
- queries = new Map();
61
- connections = new Map();
62
- pendingTags = new Set();
63
- drainChain = Promise.resolve();
64
- draining = false;
65
- constructor(container, discovery, log, driver, options, presence){
66
- this.container = container;
67
- this.discovery = discovery;
68
- this.log = log;
69
- this.options = options;
70
- this.presence = presence;
71
- driver.bind(this);
72
- this.presence?.bindInvalidator((tags)=>{
73
- void driver.dispatch({
74
- tags
75
- });
76
- });
77
- }
78
- async onApplicationBootstrap() {
79
- for (const found of this.discovery.providersWithMeta(LIVE_RESOLVER_METADATA)){
80
- if (!found.instance) continue;
81
- for (const declared of getLiveQueries(found.metatype)){
82
- if (this.queries.has(declared.name)) {
83
- const msg = `[vela] duplicate @LiveQuery('${declared.name}') ` + `(${found.metatype.name}); keeping the first.`;
84
- if (this.container.getDiagnostics() === 'throw') throw new Error(msg);
85
- console.warn(msg);
86
- continue;
87
- }
88
- this.queries.set(declared.name, {
89
- token: found.metatype,
90
- methodName: declared.methodName,
91
- options: declared.options
92
- });
93
- }
94
- }
95
- }
96
- /** The `'live'` entrypoint — how transports (node registrar, CF DO bootstrap) find the engine. */ collectEntrypoints() {
97
- return [
98
- {
99
- kind: 'live',
100
- token: LiveEngine,
101
- instance: this,
102
- meta: {
103
- engine: this
104
- }
105
- }
106
- ];
107
- }
108
- // ---- ReservedWsEventHandler ----
109
- async handleReservedEvent(path, client, message) {
110
- const frame = message.data;
111
- // Forward-compat: unknown frame shapes are ignored, not errors.
112
- if (!isClientLiveFrame(frame)) return;
113
- switch(frame.t){
114
- case 'sub':
115
- await this.onSubscribe(path, client, frame);
116
- return;
117
- case 'unsub':
118
- {
119
- const conn = this.connections.get(client.id);
120
- if (!conn) return;
121
- conn.subs.delete(frame.sub);
122
- if (conn.subs.size === 0) this.connections.delete(client.id);
123
- await this.persistSubscriptions(conn);
124
- return;
125
- }
126
- case 'presence':
127
- if (this.presence?.enabled) {
128
- this.presence.beat(frame.room, client.id, frame.meta);
129
- }
130
- return;
131
- }
132
- }
133
- async handleSocketClose(_path, client) {
134
- this.connections.delete(client.id);
135
- this.presence?.reap(client.id);
136
- }
137
- // ---- LiveInvalidationSink ----
138
- async applyInvalidation(cmd) {
139
- const stamp = await this.log.append(cmd.tags);
140
- for (const tag of cmd.tags)this.pendingTags.add(tag);
141
- this.scheduleDrain();
142
- return stamp;
143
- }
144
- /** Settles when every pending invalidation has been flushed (tests, graceful transports). */ async whenIdle() {
145
- do {
146
- await this.drainChain;
147
- }while (this.draining || this.pendingTags.size > 0)
148
- }
149
- /**
150
- * Re-attach a persisted subscription without the subscribe handshake — the
151
- * Cloudflare transport replays hibernation-attachment records through this
152
- * on wake. No frames are sent; the next relevant invalidation pushes.
153
- */ restoreSubscription(path, client, record) {
154
- this.ensureConnection(path, client).subs.set(record.sub, record);
155
- }
156
- // ---- subscribe path ----
157
- async onSubscribe(path, client, frame) {
158
- if (frame.v !== undefined && frame.v > LIVE_PROTOCOL) {
159
- this.sendFrame(client, {
160
- t: 'error',
161
- sub: frame.sub,
162
- code: LIVE_ERROR_CODES.UNSUPPORTED_PROTOCOL,
163
- message: `server speaks live protocol v${LIVE_PROTOCOL}, client asked for v${frame.v}`,
164
- fatal: true
165
- });
166
- return;
167
- }
168
- const conn = this.ensureConnection(path, client);
169
- if (conn.subs.has(frame.sub)) {
170
- this.sendFrame(client, {
171
- t: 'error',
172
- sub: frame.sub,
173
- code: LIVE_ERROR_CODES.DUPLICATE_SUB,
174
- message: `subscription id '${frame.sub}' is already active on this socket`,
175
- fatal: false
176
- });
177
- return;
178
- }
179
- const registered = this.queries.get(frame.query);
180
- if (!registered) {
181
- this.sendFrame(client, {
182
- t: 'error',
183
- sub: frame.sub,
184
- code: LIVE_ERROR_CODES.UNKNOWN_QUERY,
185
- message: `no @LiveQuery('${frame.query}') is registered`,
186
- fatal: true
187
- });
188
- return;
189
- }
190
- let args = frame.args;
191
- if (registered.options.parse) {
192
- try {
193
- args = registered.options.parse(frame.args);
194
- } catch (err) {
195
- this.sendFrame(client, {
196
- t: 'error',
197
- sub: frame.sub,
198
- code: LIVE_ERROR_CODES.BAD_ARGS,
199
- message: err instanceof Error ? err.message : 'invalid subscription args',
200
- fatal: true
201
- });
202
- return;
203
- }
204
- }
205
- // Resolver-tier guards run ONCE, here (app-wide guards already ran in the
206
- // dispatcher's reserved-event path). Re-runs are server-initiated and rely
207
- // on the identity captured below instead of re-authorizing.
208
- if (!await this.runSubscribeGuards(registered, client, frame.query, args)) {
209
- this.sendFrame(client, {
210
- t: 'error',
211
- sub: frame.sub,
212
- code: LIVE_ERROR_CODES.FORBIDDEN,
213
- message: `subscription to '${frame.query}' was rejected`,
214
- fatal: true
215
- });
216
- return;
217
- }
218
- const identity = (this.options.identity ?? defaultIdentity)(client);
219
- const tags = typeof registered.options.tags === 'function' ? registered.options.tags(args) : registered.options.tags;
220
- const record = {
221
- sub: frame.sub,
222
- query: frame.query,
223
- args,
224
- tags,
225
- key: frame.key ?? registered.options.key,
226
- identity
227
- };
228
- conn.subs.set(frame.sub, record);
229
- await this.persistSubscriptions(conn);
230
- this.sendFrame(client, {
231
- t: 'ack',
232
- sub: frame.sub
233
- });
234
- // Resume: when the client's cursor is still explainable and none of the
235
- // subscription's tags were invalidated in the gap, a tiny `resume` frame
236
- // keeps its cached value — no re-run at all. The diff baseline stays
237
- // undefined, so the next relevant change sends a full snapshot.
238
- if (frame.sinceCursor !== undefined && frame.sinceEpoch !== undefined) {
239
- const verdict = await this.log.evaluateResume(frame.sinceCursor, frame.sinceEpoch, tags);
240
- if (verdict === 'resume') {
241
- const stamp = await this.log.current();
242
- if (this.sendFrame(client, {
243
- t: 'resume',
244
- sub: frame.sub,
245
- cursor: stamp.cursor,
246
- epoch: stamp.epoch
247
- })) {
248
- record.lastCursor = stamp.cursor;
249
- }
250
- return;
251
- }
252
- }
253
- await this.push(conn, record, await this.log.current(), {
254
- initial: true
255
- });
256
- }
257
- async runSubscribeGuards(registered, client, query, args) {
258
- const guards = resolveScopedComponents('guard', registered.token, registered.methodName, this.container);
259
- if (guards.length === 0) return true;
260
- const context = buildEntrypointExecutionContext('live', registered.token, registered.methodName, {
261
- query,
262
- args,
263
- client
264
- });
265
- try {
266
- for (const guard of guards){
267
- if (!await guard.canActivate(context)) return false;
268
- }
269
- return true;
270
- } catch {
271
- return false;
272
- }
273
- }
274
- // ---- refresh path ----
275
- scheduleDrain() {
276
- if (this.draining) return;
277
- this.draining = true;
278
- this.drainChain = this.drainChain.then(()=>this.drainLoop()).catch((err)=>{
279
- if (this.container.getDiagnostics() !== 'silent') {
280
- console.warn('[vela] live refresh flush failed:', err);
281
- }
282
- }).finally(()=>{
283
- this.draining = false;
284
- if (this.pendingTags.size > 0) this.scheduleDrain();
285
- });
286
- }
287
- async drainLoop() {
288
- while(this.pendingTags.size > 0){
289
- const changed = new Set(this.pendingTags);
290
- this.pendingTags.clear();
291
- // The stamp is resolved once per pass, BEFORE the re-runs (lunora
292
- // resolves its CDC cut the same way): results can only be newer than
293
- // the cursor they carry.
294
- const stamp = await this.log.current();
295
- const work = [];
296
- for (const conn of this.connections.values()){
297
- for (const record of conn.subs.values()){
298
- if (record.tags.some((tag)=>changed.has(tag))) work.push({
299
- conn,
300
- record
301
- });
302
- }
303
- }
304
- await runPool(work, REFRESH_POOL_SIZE, async ({ conn, record })=>{
305
- await this.push(conn, record, stamp, {
306
- initial: false
307
- });
308
- });
309
- }
310
- }
311
- /**
312
- * Map a resolver failure to its live error-frame code. A branded
313
- * {@link VelaError} carries an HTTP-ish status that projects onto the live
314
- * vocabulary (403 → forbidden, 400/422 → bad_args); everything else — and
315
- * every unbranded error — is `internal` (the client sees a redacted message).
316
- */ static liveFrameCode(err) {
317
- if (!isVelaError(err)) return LIVE_ERROR_CODES.INTERNAL;
318
- if (err.status === 403) return LIVE_ERROR_CODES.FORBIDDEN;
319
- if (err.status === 400 || err.status === 422) return LIVE_ERROR_CODES.BAD_ARGS;
320
- return LIVE_ERROR_CODES.INTERNAL;
321
- }
322
- async push(conn, record, stamp, { initial }) {
323
- // Outbound expiry enforcement — the only place expiry CAN be enforced for
324
- // a passive subscriber.
325
- const expiresAt = record.identity?.expiresAt;
326
- if (typeof expiresAt === 'number' && expiresAt <= Date.now()) {
327
- this.connections.delete(conn.client.id);
328
- try {
329
- conn.client.close(1008, 'identity expired');
330
- } catch {
331
- // already gone
332
- }
333
- return;
334
- }
335
- let json;
336
- let result;
337
- try {
338
- result = await this.runQuery(record, conn.client);
339
- // `undefined` has no JSON form — normalize so the frame always carries
340
- // an explicit `snapshot` and the baseline stays a string.
341
- if (result === undefined) result = null;
342
- json = JSON.stringify(result);
343
- } catch (err) {
344
- if (initial) {
345
- // Close the leak: an initial-subscribe resolver failure is REDACTED
346
- // through `toErrorBody` (the single wire-redaction seam) — an unbranded
347
- // error's raw message never reaches the browser, it surfaces only via
348
- // the reporter. Branded VelaErrors keep their client-facing message.
349
- conn.subs.delete(record.sub);
350
- const reporter = resolveErrorReporter(this.container);
351
- reporter.report(err, {
352
- edge: 'live',
353
- source: record.query
354
- });
355
- const safe = toErrorBody(err, {
356
- catalog: reporter.catalog
357
- });
358
- this.sendFrame(conn.client, {
359
- t: 'error',
360
- sub: record.sub,
361
- code: LiveEngine.liveFrameCode(err),
362
- message: safe.body.error.message,
363
- fatal: true
364
- });
365
- } else if (this.container.getDiagnostics() !== 'silent') {
366
- // Transient: baseline untouched, the subscription retries next flush.
367
- console.warn(`[vela] live query '${record.query}' re-run failed (will retry):`, err);
368
- }
369
- return;
370
- }
371
- const frame = encodeSubscriptionUpdate(record, json, result, stamp, initial);
372
- if (this.sendFrame(conn.client, frame)) {
373
- record.lastJson = json;
374
- record.lastCursor = stamp.cursor;
375
- }
376
- }
377
- async runQuery(record, client) {
378
- const registered = this.queries.get(record.query);
379
- if (!registered) throw new Error(`live query '${record.query}' disappeared from the registry`);
380
- return runInEntrypointScope(this.container, async (scope)=>{
381
- // Async seam: lazy resolver modules materialize, request-scoped
382
- // resolvers rebuild per run (mirrors queue dispatch).
383
- const instance = await scope.resolveAsync(registered.token);
384
- const liveContext = {
385
- identity: record.identity,
386
- clientId: client.id,
387
- rooms: [
388
- ...client.rooms
389
- ]
390
- };
391
- const context = buildEntrypointExecutionContext('live', registered.token, registered.methodName, {
392
- query: record.query,
393
- args: record.args,
394
- client
395
- });
396
- const interceptors = resolveScopedComponents('interceptor', registered.token, registered.methodName, scope);
397
- return PipelineRunner.run({
398
- context,
399
- guards: [],
400
- interceptors,
401
- resolveArgs: async ()=>[
402
- record.args,
403
- liveContext
404
- ],
405
- invoke: async (args)=>{
406
- const method = instance[registered.methodName];
407
- return method.apply(instance, args);
408
- }
409
- });
410
- });
411
- }
412
- /**
413
- * Mirror the connection's records into `client.data` + `commit()` so
414
- * hibernating transports can replay them on wake. The volatile diff
415
- * baseline (`lastJson`/`lastCursor`) is deliberately stripped: it can be
416
- * large (the whole last result vs the 16 KiB attachment cap) and a lost
417
- * baseline just means the next relevant change sends a full snapshot.
418
- */ async persistSubscriptions(conn) {
419
- const records = [
420
- ...conn.subs.values()
421
- ].map(({ lastJson: _lastJson, lastCursor: _lastCursor, ...persisted })=>persisted);
422
- try {
423
- conn.client.data[LIVE_SUBS_DATA_KEY] = records;
424
- await conn.client.commit();
425
- } catch (err) {
426
- if (this.container.getDiagnostics() !== 'silent') {
427
- console.warn('[vela] live subscription persistence failed (resume across eviction disabled):', err);
428
- }
429
- }
430
- }
431
- ensureConnection(path, client) {
432
- let conn = this.connections.get(client.id);
433
- if (!conn) {
434
- conn = {
435
- client,
436
- path,
437
- subs: new Map()
438
- };
439
- this.connections.set(client.id, conn);
440
- }
441
- return conn;
442
- }
443
- sendFrame(client, frame) {
444
- try {
445
- client.sendRaw(encodeLiveEnvelope(frame));
446
- return true;
447
- } catch {
448
- return false;
449
- }
450
- }
451
- }
452
- LiveEngine = _ts_decorate([
453
- ReservedWsEvent('$live'),
454
- Injectable(),
455
- _ts_param(0, Inject(Container)),
456
- _ts_param(1, Inject(DiscoveryService)),
457
- _ts_param(2, Inject(LIVE_CURSOR_LOG)),
458
- _ts_param(3, Inject(LIVE_DRIVER)),
459
- _ts_param(4, Inject(LIVE_MODULE_OPTIONS)),
460
- _ts_param(5, Optional()),
461
- _ts_param(5, Inject(PresenceService)),
462
- _ts_metadata("design:type", Function),
463
- _ts_metadata("design:paramtypes", [
464
- typeof Container === "undefined" ? Object : Container,
465
- typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
466
- typeof CursorLog === "undefined" ? Object : CursorLog,
467
- typeof LiveDriver === "undefined" ? Object : LiveDriver,
468
- typeof LiveModuleOptions === "undefined" ? Object : LiveModuleOptions,
469
- typeof PresenceService === "undefined" ? Object : PresenceService
470
- ])
471
- ], LiveEngine);
@@ -1,45 +0,0 @@
1
- import type { CommitStamp, InvalidationCommand, LiveDriver } from './live.types';
2
- /** Single-scope default driver: deliver straight to this process's engine. */
3
- export declare function localLive(): LiveDriver;
4
- /**
5
- * Per-app wrapper around a (possibly SHARED) driver instance.
6
- *
7
- * A driver passed to `LiveModule.forRoot({ driver })` is a plain config object
8
- * — and on Cloudflare the SAME app module (thus the same driver object)
9
- * bootstraps in the Worker isolate AND inside each Durable Object, often
10
- * within one isolate. Mutable per-app state must therefore never live on the
11
- * driver itself: the DO flipping a shared `durableObjectLive()` into local
12
- * mode would otherwise poison the Worker's engine, which then executes the
13
- * DO's storage handle in the wrong request context ("Cannot perform I/O on
14
- * behalf of a different request").
15
- *
16
- * The wrapper owns the per-app sink and the per-app local-mode flag; isolate-
17
- * wide concerns (env capture) forward to the underlying driver. Platform init
18
- * hooks (`_setLocalMode`, `_initializeEnv`) are exposed pass-through so
19
- * platform packages can keep type-guarding on their presence.
20
- */
21
- export declare function perAppLiveDriver(underlying: LiveDriver): LiveDriver;
22
- /**
23
- * The injectable invalidation surface for custom (non-CRUD) write paths:
24
- *
25
- * ```ts
26
- * await this.live.invalidate({ tags: ['todos:' + listId] });
27
- * ```
28
- *
29
- * Every affected live query re-runs and pushes. Returns the commit stamp of
30
- * the targeted log scope so mutation endpoints can expose it to the client
31
- * (`Vela-Commit-Cursor` / `Vela-Commit-Epoch`) — the cursor optimistic
32
- * updates gate on. When ambient request access is enabled
33
- * (`VelaFactory.create(m, { ambientContainer: true })`) the headers are
34
- * stamped onto the current HTTP response automatically; otherwise stamp them
35
- * yourself via {@link stampCommitHeaders}.
36
- */
37
- export declare class LiveInvalidation {
38
- private readonly driver;
39
- constructor(driver: LiveDriver);
40
- invalidate(cmd: InvalidationCommand): Promise<CommitStamp | undefined>;
41
- }
42
- /** Write the commit headers onto a Hono context (a mutation route's response). */
43
- export declare function stampCommitHeaders(c: {
44
- header: (name: string, value: string) => unknown;
45
- }, stamp: CommitStamp): void;
@@ -1,99 +0,0 @@
1
- import { COMMIT_CURSOR_HEADER, COMMIT_EPOCH_HEADER } from "@velajs/live-protocol";
2
- import { getContext } from "hono/context-storage";
3
- /** Single-scope default driver: deliver straight to this process's engine. */ export function localLive() {
4
- let sink;
5
- return {
6
- kind: 'local',
7
- bind (s) {
8
- sink = s;
9
- },
10
- dispatch (cmd) {
11
- return sink?.applyInvalidation(cmd);
12
- }
13
- };
14
- }
15
- /**
16
- * Per-app wrapper around a (possibly SHARED) driver instance.
17
- *
18
- * A driver passed to `LiveModule.forRoot({ driver })` is a plain config object
19
- * — and on Cloudflare the SAME app module (thus the same driver object)
20
- * bootstraps in the Worker isolate AND inside each Durable Object, often
21
- * within one isolate. Mutable per-app state must therefore never live on the
22
- * driver itself: the DO flipping a shared `durableObjectLive()` into local
23
- * mode would otherwise poison the Worker's engine, which then executes the
24
- * DO's storage handle in the wrong request context ("Cannot perform I/O on
25
- * behalf of a different request").
26
- *
27
- * The wrapper owns the per-app sink and the per-app local-mode flag; isolate-
28
- * wide concerns (env capture) forward to the underlying driver. Platform init
29
- * hooks (`_setLocalMode`, `_initializeEnv`) are exposed pass-through so
30
- * platform packages can keep type-guarding on their presence.
31
- */ export function perAppLiveDriver(underlying) {
32
- let ownSink;
33
- let localMode = false;
34
- const cfHooks = underlying;
35
- return {
36
- get kind () {
37
- return underlying.kind;
38
- },
39
- bind (sink) {
40
- ownSink = sink;
41
- underlying.bind(sink);
42
- },
43
- dispatch (cmd) {
44
- if (localMode && ownSink) return ownSink.applyInvalidation(cmd);
45
- return underlying.dispatch(cmd);
46
- },
47
- start: underlying.start ? ()=>underlying.start?.() : undefined,
48
- stop: underlying.stop ? ()=>underlying.stop?.() : undefined,
49
- // Platform hooks (Cloudflare): local mode is PER APP; env is per isolate.
50
- _setLocalMode () {
51
- localMode = true;
52
- },
53
- _initializeEnv (env) {
54
- cfHooks._initializeEnv?.(env);
55
- }
56
- };
57
- }
58
- /**
59
- * The injectable invalidation surface for custom (non-CRUD) write paths:
60
- *
61
- * ```ts
62
- * await this.live.invalidate({ tags: ['todos:' + listId] });
63
- * ```
64
- *
65
- * Every affected live query re-runs and pushes. Returns the commit stamp of
66
- * the targeted log scope so mutation endpoints can expose it to the client
67
- * (`Vela-Commit-Cursor` / `Vela-Commit-Epoch`) — the cursor optimistic
68
- * updates gate on. When ambient request access is enabled
69
- * (`VelaFactory.create(m, { ambientContainer: true })`) the headers are
70
- * stamped onto the current HTTP response automatically; otherwise stamp them
71
- * yourself via {@link stampCommitHeaders}.
72
- */ export class LiveInvalidation {
73
- driver;
74
- constructor(driver){
75
- this.driver = driver;
76
- }
77
- async invalidate(cmd) {
78
- const stamp = await this.driver.dispatch(cmd);
79
- if (stamp) stampAmbientCommitHeaders(stamp);
80
- return stamp;
81
- }
82
- }
83
- /** Write the commit headers onto a Hono context (a mutation route's response). */ export function stampCommitHeaders(c, stamp) {
84
- c.header(COMMIT_CURSOR_HEADER, String(stamp.cursor));
85
- c.header(COMMIT_EPOCH_HEADER, stamp.epoch);
86
- }
87
- /**
88
- * Best-effort automatic header stamping through Hono's ambient context
89
- * storage. A no-op outside a request or when `contextStorage()` isn't
90
- * registered — ALS keeps this per-request-correct under concurrency (a
91
- * mutable singleton slot would race interleaved awaits).
92
- */ function stampAmbientCommitHeaders(stamp) {
93
- try {
94
- stampCommitHeaders(getContext(), stamp);
95
- } catch {
96
- // Ambient access not enabled, or invalidate() ran outside a request
97
- // (queue job, cron tick) — there is no HTTP response to stamp.
98
- }
99
- }
@@ -1,28 +0,0 @@
1
- import type { LiveModuleOptions } from './live.types';
2
- /**
3
- * First-party live-query module (tag-based realtime reactivity) — authored,
4
- * like the queue module, entirely on vela's public API (`live-openness.test.ts`
5
- * machine-verifies it; the only extra dependency is the shared wire package
6
- * `@velajs/live-protocol`).
7
- *
8
- * ```ts
9
- * imports: [WebSocketModule.forRoot({}), LiveModule.forRoot({})]
10
- * ```
11
- *
12
- * App code declares `@LiveResolver` classes with `@LiveQuery(name, { tags })`
13
- * methods; clients subscribe over the `$live` reserved WebSocket event; writes
14
- * invalidate tags via `LiveInvalidation` (the `@velajs/crud` bridge does it
15
- * automatically per table). See `LIVE.md` for the wire protocol, delivery
16
- * guarantees, and the resume story.
17
- *
18
- * Deliberately EAGER (like WebSocketModule): the engine self-drives — it
19
- * claims the `$live` event at bootstrap and receives invalidations from
20
- * writes that never touch a live token — so the lazy-module contract
21
- * ("nothing self-drives") rules laziness out.
22
- */
23
- declare const ConfigurableModuleClass: import("../module").ConfigurableModuleClassType<LiveModuleOptions, "forRoot", "create", {
24
- isGlobal?: boolean;
25
- }>;
26
- export declare class LiveModule extends ConfigurableModuleClass {
27
- }
28
- export {};