rivetkit 2.0.2 → 2.0.4-rc.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 (403) hide show
  1. package/README.md +3 -5
  2. package/dist/browser/client.d.ts +2485 -0
  3. package/dist/browser/client.js +5182 -0
  4. package/dist/browser/client.js.map +1 -0
  5. package/dist/browser/inspector/client.d.ts +130 -0
  6. package/dist/browser/inspector/client.js +2854 -0
  7. package/dist/browser/inspector/client.js.map +1 -0
  8. package/dist/browser/v3-DnYObHH3.d.ts +279 -0
  9. package/dist/inspector.tar.gz +0 -0
  10. package/dist/schemas/actor-inspector/v1.ts +784 -0
  11. package/dist/schemas/actor-inspector/v2.ts +796 -0
  12. package/dist/schemas/actor-inspector/v3.ts +899 -0
  13. package/dist/schemas/actor-persist/v1.ts +225 -0
  14. package/dist/schemas/actor-persist/v2.ts +268 -0
  15. package/dist/schemas/actor-persist/v3.ts +280 -0
  16. package/dist/schemas/actor-persist/v4.ts +406 -0
  17. package/dist/schemas/client-protocol/v1.ts +441 -0
  18. package/dist/schemas/client-protocol/v2.ts +438 -0
  19. package/dist/schemas/client-protocol/v3.ts +554 -0
  20. package/dist/schemas/file-system-driver/v1.ts +108 -0
  21. package/dist/schemas/file-system-driver/v2.ts +142 -0
  22. package/dist/schemas/file-system-driver/v3.ts +167 -0
  23. package/dist/schemas/persist/v1.ts +781 -0
  24. package/dist/schemas/transport/v1.ts +697 -0
  25. package/dist/tsup/actor/errors.cjs +106 -0
  26. package/dist/tsup/actor/errors.cjs.map +1 -0
  27. package/dist/tsup/actor/errors.d.cts +188 -0
  28. package/dist/tsup/actor/errors.d.ts +188 -0
  29. package/dist/tsup/actor/errors.js +106 -0
  30. package/dist/tsup/actor/errors.js.map +1 -0
  31. package/dist/tsup/actor-router-consts-D29T1Z-K.d.cts +24 -0
  32. package/dist/tsup/actor-router-consts-D29T1Z-K.d.ts +24 -0
  33. package/dist/tsup/chunk-325TLXJT.js +1060 -0
  34. package/dist/tsup/chunk-325TLXJT.js.map +1 -0
  35. package/dist/tsup/chunk-424PT5DM.js +23 -0
  36. package/dist/tsup/chunk-424PT5DM.js.map +1 -0
  37. package/dist/tsup/chunk-4JVIG3SS.cjs +6289 -0
  38. package/dist/tsup/chunk-4JVIG3SS.cjs.map +1 -0
  39. package/dist/tsup/chunk-6LJAZ5R4.cjs +96 -0
  40. package/dist/tsup/chunk-6LJAZ5R4.cjs.map +1 -0
  41. package/dist/tsup/chunk-6XU3FMCB.cjs +534 -0
  42. package/dist/tsup/chunk-6XU3FMCB.cjs.map +1 -0
  43. package/dist/tsup/chunk-7HTNH26M.js +509 -0
  44. package/dist/tsup/chunk-7HTNH26M.js.map +1 -0
  45. package/dist/tsup/chunk-AUVH72RE.cjs +5977 -0
  46. package/dist/tsup/chunk-AUVH72RE.cjs.map +1 -0
  47. package/dist/tsup/chunk-D4BYUPNQ.js +645 -0
  48. package/dist/tsup/chunk-D4BYUPNQ.js.map +1 -0
  49. package/dist/tsup/chunk-HDQ2JUQT.cjs +23 -0
  50. package/dist/tsup/chunk-HDQ2JUQT.cjs.map +1 -0
  51. package/dist/tsup/chunk-HHXX2VRM.js +6289 -0
  52. package/dist/tsup/chunk-HHXX2VRM.js.map +1 -0
  53. package/dist/tsup/chunk-JEAEA2PB.js +49 -0
  54. package/dist/tsup/chunk-JEAEA2PB.js.map +1 -0
  55. package/dist/tsup/chunk-JYSEG3VF.cjs +642 -0
  56. package/dist/tsup/chunk-JYSEG3VF.cjs.map +1 -0
  57. package/dist/tsup/chunk-K6DGYILQ.js +2657 -0
  58. package/dist/tsup/chunk-K6DGYILQ.js.map +1 -0
  59. package/dist/tsup/chunk-KJSYAUOM.js +96 -0
  60. package/dist/tsup/chunk-KJSYAUOM.js.map +1 -0
  61. package/dist/tsup/chunk-L47L3ZWJ.cjs +509 -0
  62. package/dist/tsup/chunk-L47L3ZWJ.cjs.map +1 -0
  63. package/dist/tsup/chunk-LXUQ667X.js +2006 -0
  64. package/dist/tsup/chunk-LXUQ667X.js.map +1 -0
  65. package/dist/tsup/chunk-MXNPAB5W.js +5977 -0
  66. package/dist/tsup/chunk-MXNPAB5W.js.map +1 -0
  67. package/dist/tsup/chunk-N4KRDJ56.js +72 -0
  68. package/dist/tsup/chunk-N4KRDJ56.js.map +1 -0
  69. package/dist/tsup/chunk-NIYZDWMW.cjs +2006 -0
  70. package/dist/tsup/chunk-NIYZDWMW.cjs.map +1 -0
  71. package/dist/tsup/chunk-PQZHDKRW.cjs +1060 -0
  72. package/dist/tsup/chunk-PQZHDKRW.cjs.map +1 -0
  73. package/dist/tsup/chunk-PVOE6BU7.cjs +1050 -0
  74. package/dist/tsup/chunk-PVOE6BU7.cjs.map +1 -0
  75. package/dist/tsup/chunk-Q4UD2GA4.cjs +1810 -0
  76. package/dist/tsup/chunk-Q4UD2GA4.cjs.map +1 -0
  77. package/dist/tsup/chunk-QUD664YZ.js +1810 -0
  78. package/dist/tsup/chunk-QUD664YZ.js.map +1 -0
  79. package/dist/tsup/chunk-RTOCTWME.js +1050 -0
  80. package/dist/tsup/chunk-RTOCTWME.js.map +1 -0
  81. package/dist/tsup/chunk-SAZZ4SB2.cjs +2657 -0
  82. package/dist/tsup/chunk-SAZZ4SB2.cjs.map +1 -0
  83. package/dist/tsup/chunk-SR3KQE7Q.cjs +72 -0
  84. package/dist/tsup/chunk-SR3KQE7Q.cjs.map +1 -0
  85. package/dist/tsup/chunk-V2GHLYC6.cjs +49 -0
  86. package/dist/tsup/chunk-V2GHLYC6.cjs.map +1 -0
  87. package/dist/tsup/chunk-V3WG7XTW.cjs +645 -0
  88. package/dist/tsup/chunk-V3WG7XTW.cjs.map +1 -0
  89. package/dist/tsup/chunk-VKVNIQRQ.js +257 -0
  90. package/dist/tsup/chunk-VKVNIQRQ.js.map +1 -0
  91. package/dist/tsup/chunk-WMPW7JYC.js +642 -0
  92. package/dist/tsup/chunk-WMPW7JYC.js.map +1 -0
  93. package/dist/tsup/chunk-Z7HNQ2WF.js +534 -0
  94. package/dist/tsup/chunk-Z7HNQ2WF.js.map +1 -0
  95. package/dist/tsup/chunk-ZFY5J2EP.cjs +257 -0
  96. package/dist/tsup/chunk-ZFY5J2EP.cjs.map +1 -0
  97. package/dist/tsup/client/mod.cjs +33 -0
  98. package/dist/tsup/client/mod.cjs.map +1 -0
  99. package/dist/tsup/client/mod.d.cts +64 -0
  100. package/dist/tsup/client/mod.d.ts +64 -0
  101. package/dist/tsup/client/mod.js +33 -0
  102. package/dist/tsup/client/mod.js.map +1 -0
  103. package/dist/tsup/common/log.cjs +21 -0
  104. package/dist/tsup/common/log.cjs.map +1 -0
  105. package/dist/tsup/common/log.d.cts +34 -0
  106. package/dist/tsup/common/log.d.ts +34 -0
  107. package/dist/tsup/common/log.js +21 -0
  108. package/dist/tsup/common/log.js.map +1 -0
  109. package/dist/tsup/common/websocket.cjs +10 -0
  110. package/dist/tsup/common/websocket.cjs.map +1 -0
  111. package/dist/tsup/common/websocket.d.cts +3 -0
  112. package/dist/tsup/common/websocket.d.ts +3 -0
  113. package/dist/tsup/common/websocket.js +10 -0
  114. package/dist/tsup/common/websocket.js.map +1 -0
  115. package/dist/tsup/config-BiNoIHRs.d.cts +80 -0
  116. package/dist/tsup/config-BiNoIHRs.d.ts +80 -0
  117. package/dist/tsup/config-P3XujgRr.d.ts +2594 -0
  118. package/dist/tsup/config-_gfywqqI.d.cts +2594 -0
  119. package/dist/tsup/context-Bxd8Cx4H.d.cts +75 -0
  120. package/dist/tsup/context-uNA4TRn3.d.ts +75 -0
  121. package/dist/tsup/db/drizzle/mod.cjs +49 -0
  122. package/dist/tsup/db/drizzle/mod.cjs.map +1 -0
  123. package/dist/tsup/db/drizzle/mod.d.cts +17 -0
  124. package/dist/tsup/db/drizzle/mod.d.ts +17 -0
  125. package/dist/tsup/db/drizzle/mod.js +49 -0
  126. package/dist/tsup/db/drizzle/mod.js.map +1 -0
  127. package/dist/tsup/db/mod.cjs +9 -0
  128. package/dist/tsup/db/mod.cjs.map +1 -0
  129. package/dist/tsup/db/mod.d.cts +9 -0
  130. package/dist/tsup/db/mod.d.ts +9 -0
  131. package/dist/tsup/db/mod.js +9 -0
  132. package/dist/tsup/db/mod.js.map +1 -0
  133. package/dist/tsup/driver-BcLvZcKl.d.cts +13 -0
  134. package/dist/tsup/driver-CPGHKXyh.d.ts +13 -0
  135. package/dist/tsup/driver-helpers/mod.cjs +53 -0
  136. package/dist/tsup/driver-helpers/mod.cjs.map +1 -0
  137. package/dist/tsup/driver-helpers/mod.d.cts +47 -0
  138. package/dist/tsup/driver-helpers/mod.d.ts +47 -0
  139. package/dist/tsup/driver-helpers/mod.js +53 -0
  140. package/dist/tsup/driver-helpers/mod.js.map +1 -0
  141. package/dist/tsup/driver-test-suite/mod.cjs +4974 -0
  142. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -0
  143. package/dist/tsup/driver-test-suite/mod.d.cts +73 -0
  144. package/dist/tsup/driver-test-suite/mod.d.ts +73 -0
  145. package/dist/tsup/driver-test-suite/mod.js +4974 -0
  146. package/dist/tsup/driver-test-suite/mod.js.map +1 -0
  147. package/dist/tsup/inspector/mod.cjs +164 -0
  148. package/dist/tsup/inspector/mod.cjs.map +1 -0
  149. package/dist/tsup/inspector/mod.d.cts +130 -0
  150. package/dist/tsup/inspector/mod.d.ts +130 -0
  151. package/dist/tsup/inspector/mod.js +164 -0
  152. package/dist/tsup/inspector/mod.js.map +1 -0
  153. package/dist/tsup/keys-CydblqMh.d.cts +13 -0
  154. package/dist/tsup/keys-CydblqMh.d.ts +13 -0
  155. package/dist/tsup/mod.cjs +82 -0
  156. package/dist/tsup/mod.cjs.map +1 -0
  157. package/dist/tsup/mod.d.cts +126 -0
  158. package/dist/tsup/mod.d.ts +126 -0
  159. package/dist/tsup/mod.js +82 -0
  160. package/dist/tsup/mod.js.map +1 -0
  161. package/dist/tsup/serve-test-suite/mod.cjs +2601 -0
  162. package/dist/tsup/serve-test-suite/mod.cjs.map +1 -0
  163. package/dist/tsup/serve-test-suite/mod.d.cts +9 -0
  164. package/dist/tsup/serve-test-suite/mod.d.ts +9 -0
  165. package/dist/tsup/serve-test-suite/mod.js +2601 -0
  166. package/dist/tsup/serve-test-suite/mod.js.map +1 -0
  167. package/dist/tsup/test/mod.cjs +90 -0
  168. package/dist/tsup/test/mod.cjs.map +1 -0
  169. package/dist/tsup/test/mod.d.cts +26 -0
  170. package/dist/tsup/test/mod.d.ts +26 -0
  171. package/dist/tsup/test/mod.js +90 -0
  172. package/dist/tsup/test/mod.js.map +1 -0
  173. package/dist/tsup/utils-fwx3o3K9.d.cts +18 -0
  174. package/dist/tsup/utils-fwx3o3K9.d.ts +18 -0
  175. package/dist/tsup/utils.cjs +43 -0
  176. package/dist/tsup/utils.cjs.map +1 -0
  177. package/dist/tsup/utils.d.cts +148 -0
  178. package/dist/tsup/utils.d.ts +148 -0
  179. package/dist/tsup/utils.js +43 -0
  180. package/dist/tsup/utils.js.map +1 -0
  181. package/dist/tsup/v3-DnYObHH3.d.cts +279 -0
  182. package/dist/tsup/v3-DnYObHH3.d.ts +279 -0
  183. package/dist/tsup/workflow/mod.cjs +16 -0
  184. package/dist/tsup/workflow/mod.cjs.map +1 -0
  185. package/dist/tsup/workflow/mod.d.cts +25 -0
  186. package/dist/tsup/workflow/mod.d.ts +25 -0
  187. package/dist/tsup/workflow/mod.js +16 -0
  188. package/dist/tsup/workflow/mod.js.map +1 -0
  189. package/package.json +293 -5
  190. package/src/actor/config.ts +1221 -0
  191. package/src/actor/conn/driver.ts +61 -0
  192. package/src/actor/conn/drivers/http.ts +17 -0
  193. package/src/actor/conn/drivers/raw-request.ts +24 -0
  194. package/src/actor/conn/drivers/raw-websocket.ts +65 -0
  195. package/src/actor/conn/drivers/websocket.ts +144 -0
  196. package/src/actor/conn/mod.ts +288 -0
  197. package/src/actor/conn/persisted.ts +81 -0
  198. package/src/actor/conn/state-manager.ts +196 -0
  199. package/src/actor/contexts/action.ts +47 -0
  200. package/src/actor/contexts/base/actor.ts +347 -0
  201. package/src/actor/contexts/base/conn-init.ts +68 -0
  202. package/src/actor/contexts/base/conn.ts +73 -0
  203. package/src/actor/contexts/before-action-response.ts +42 -0
  204. package/src/actor/contexts/before-connect.ts +31 -0
  205. package/src/actor/contexts/connect.ts +42 -0
  206. package/src/actor/contexts/create-conn-state.ts +32 -0
  207. package/src/actor/contexts/create-vars.ts +39 -0
  208. package/src/actor/contexts/create.ts +39 -0
  209. package/src/actor/contexts/destroy.ts +42 -0
  210. package/src/actor/contexts/disconnect.ts +43 -0
  211. package/src/actor/contexts/index.ts +33 -0
  212. package/src/actor/contexts/request.ts +80 -0
  213. package/src/actor/contexts/run.ts +47 -0
  214. package/src/actor/contexts/sleep.ts +42 -0
  215. package/src/actor/contexts/state-change.ts +42 -0
  216. package/src/actor/contexts/wake.ts +42 -0
  217. package/src/actor/contexts/websocket.ts +80 -0
  218. package/src/actor/database.ts +13 -0
  219. package/src/actor/definition.ts +64 -0
  220. package/src/actor/driver.ts +114 -0
  221. package/src/actor/errors.ts +556 -0
  222. package/src/actor/instance/connection-manager.ts +574 -0
  223. package/src/actor/instance/event-manager.ts +314 -0
  224. package/src/actor/instance/keys.ts +146 -0
  225. package/src/actor/instance/kv.ts +241 -0
  226. package/src/actor/instance/mod.ts +1658 -0
  227. package/src/actor/instance/persisted.ts +67 -0
  228. package/src/actor/instance/queue-manager.ts +603 -0
  229. package/src/actor/instance/queue.ts +345 -0
  230. package/src/actor/instance/schedule-manager.ts +392 -0
  231. package/src/actor/instance/state-manager.ts +542 -0
  232. package/src/actor/instance/traces-driver.ts +128 -0
  233. package/src/actor/keys.test.ts +275 -0
  234. package/src/actor/keys.ts +89 -0
  235. package/src/actor/log.ts +6 -0
  236. package/src/actor/mod.ts +110 -0
  237. package/src/actor/protocol/old.ts +416 -0
  238. package/src/actor/protocol/serde.ts +222 -0
  239. package/src/actor/router-endpoints.ts +400 -0
  240. package/src/actor/router-websocket-endpoints.test.ts +54 -0
  241. package/src/actor/router-websocket-endpoints.ts +405 -0
  242. package/src/actor/router.ts +380 -0
  243. package/src/actor/schedule.ts +17 -0
  244. package/src/actor/schema.ts +291 -0
  245. package/src/actor/utils.test.ts +48 -0
  246. package/src/actor/utils.ts +158 -0
  247. package/src/client/actor-common.ts +32 -0
  248. package/src/client/actor-conn.ts +1262 -0
  249. package/src/client/actor-handle.ts +344 -0
  250. package/src/client/actor-query.ts +112 -0
  251. package/src/client/client.ts +558 -0
  252. package/src/client/config.ts +151 -0
  253. package/src/client/errors.ts +76 -0
  254. package/src/client/log.ts +5 -0
  255. package/src/client/mod.browser.ts +2 -0
  256. package/src/client/mod.ts +70 -0
  257. package/src/client/queue.ts +146 -0
  258. package/src/client/raw-utils.ts +149 -0
  259. package/src/client/test.ts +44 -0
  260. package/src/client/utils.ts +252 -0
  261. package/src/common/actor-router-consts.ts +59 -0
  262. package/src/common/cors.ts +57 -0
  263. package/src/common/eventsource-interface.ts +47 -0
  264. package/src/common/eventsource.ts +44 -0
  265. package/src/common/inline-websocket-adapter.ts +154 -0
  266. package/src/common/log-levels.ts +27 -0
  267. package/src/common/log.ts +229 -0
  268. package/src/common/logfmt.ts +221 -0
  269. package/src/common/network.ts +2 -0
  270. package/src/common/router.ts +174 -0
  271. package/src/common/utils.ts +339 -0
  272. package/src/common/websocket-interface.ts +7 -0
  273. package/src/common/websocket.ts +43 -0
  274. package/src/db/config.ts +100 -0
  275. package/src/db/drizzle/mod.ts +226 -0
  276. package/src/db/drizzle/sqlite-core.ts +22 -0
  277. package/src/db/mod.ts +125 -0
  278. package/src/db/shared.ts +92 -0
  279. package/src/db/sqlite-vfs.ts +12 -0
  280. package/src/devtools-loader/index.ts +33 -0
  281. package/src/devtools-loader/log.ts +5 -0
  282. package/src/driver-helpers/mod.ts +33 -0
  283. package/src/driver-helpers/utils.ts +54 -0
  284. package/src/driver-test-suite/log.ts +5 -0
  285. package/src/driver-test-suite/mod.ts +293 -0
  286. package/src/driver-test-suite/test-inline-client-driver.ts +307 -0
  287. package/src/driver-test-suite/tests/access-control.ts +218 -0
  288. package/src/driver-test-suite/tests/action-features.ts +203 -0
  289. package/src/driver-test-suite/tests/actor-conn-hibernation.ts +152 -0
  290. package/src/driver-test-suite/tests/actor-conn-state.ts +300 -0
  291. package/src/driver-test-suite/tests/actor-conn.ts +596 -0
  292. package/src/driver-test-suite/tests/actor-db-raw.ts +73 -0
  293. package/src/driver-test-suite/tests/actor-db.ts +477 -0
  294. package/src/driver-test-suite/tests/actor-destroy.ts +294 -0
  295. package/src/driver-test-suite/tests/actor-driver.ts +18 -0
  296. package/src/driver-test-suite/tests/actor-error-handling.ts +150 -0
  297. package/src/driver-test-suite/tests/actor-handle.ts +312 -0
  298. package/src/driver-test-suite/tests/actor-inline-client.ts +163 -0
  299. package/src/driver-test-suite/tests/actor-inspector.ts +264 -0
  300. package/src/driver-test-suite/tests/actor-kv.ts +65 -0
  301. package/src/driver-test-suite/tests/actor-metadata.ts +116 -0
  302. package/src/driver-test-suite/tests/actor-onstatechange.ts +95 -0
  303. package/src/driver-test-suite/tests/actor-queue.ts +325 -0
  304. package/src/driver-test-suite/tests/actor-run.ts +181 -0
  305. package/src/driver-test-suite/tests/actor-schedule.ts +97 -0
  306. package/src/driver-test-suite/tests/actor-sleep.ts +415 -0
  307. package/src/driver-test-suite/tests/actor-state.ts +54 -0
  308. package/src/driver-test-suite/tests/actor-stateless.ts +70 -0
  309. package/src/driver-test-suite/tests/actor-vars.ts +97 -0
  310. package/src/driver-test-suite/tests/actor-workflow.ts +118 -0
  311. package/src/driver-test-suite/tests/manager-driver.ts +388 -0
  312. package/src/driver-test-suite/tests/raw-http-direct-registry.ts +227 -0
  313. package/src/driver-test-suite/tests/raw-http-request-properties.ts +454 -0
  314. package/src/driver-test-suite/tests/raw-http.ts +359 -0
  315. package/src/driver-test-suite/tests/raw-websocket-direct-registry.ts +393 -0
  316. package/src/driver-test-suite/tests/raw-websocket.ts +513 -0
  317. package/src/driver-test-suite/tests/request-access.ts +240 -0
  318. package/src/driver-test-suite/utils.ts +80 -0
  319. package/src/drivers/default.ts +38 -0
  320. package/src/drivers/engine/actor-driver.ts +1027 -0
  321. package/src/drivers/engine/config.ts +43 -0
  322. package/src/drivers/engine/log.ts +5 -0
  323. package/src/drivers/engine/mod.ts +36 -0
  324. package/src/drivers/file-system/actor.ts +102 -0
  325. package/src/drivers/file-system/global-state.ts +1445 -0
  326. package/src/drivers/file-system/kv-limits.ts +70 -0
  327. package/src/drivers/file-system/log.ts +5 -0
  328. package/src/drivers/file-system/manager.ts +300 -0
  329. package/src/drivers/file-system/mod.ts +78 -0
  330. package/src/drivers/file-system/sqlite-runtime.ts +210 -0
  331. package/src/drivers/file-system/utils.ts +125 -0
  332. package/src/engine-process/constants.ts +2 -0
  333. package/src/engine-process/log.ts +5 -0
  334. package/src/engine-process/mod.ts +464 -0
  335. package/src/globals.d.ts +35 -0
  336. package/src/inspector/actor-inspector.ts +352 -0
  337. package/src/inspector/config.ts +49 -0
  338. package/src/inspector/handler.ts +273 -0
  339. package/src/inspector/log.ts +5 -0
  340. package/src/inspector/mod.browser.ts +8 -0
  341. package/src/inspector/mod.ts +4 -0
  342. package/src/inspector/serve-ui.ts +40 -0
  343. package/src/inspector/transport.ts +18 -0
  344. package/src/inspector/utils.ts +32 -0
  345. package/src/manager/driver.ts +106 -0
  346. package/src/manager/gateway.ts +668 -0
  347. package/src/manager/log.ts +5 -0
  348. package/src/manager/mod.ts +2 -0
  349. package/src/manager/protocol/mod.ts +22 -0
  350. package/src/manager/protocol/query.ts +85 -0
  351. package/src/manager/router-schema.ts +22 -0
  352. package/src/manager/router.ts +660 -0
  353. package/src/manager-api/actors.ts +83 -0
  354. package/src/manager-api/common.ts +4 -0
  355. package/src/mod.ts +24 -0
  356. package/src/registry/config/driver.ts +21 -0
  357. package/src/registry/config/index.ts +510 -0
  358. package/src/registry/config/legacy-runner.ts +157 -0
  359. package/src/registry/config/runner.ts +21 -0
  360. package/src/registry/config/serverless.ts +94 -0
  361. package/src/registry/index.ts +194 -0
  362. package/src/registry/log.ts +5 -0
  363. package/src/remote-manager-driver/actor-http-client.ts +84 -0
  364. package/src/remote-manager-driver/actor-websocket-client.ts +81 -0
  365. package/src/remote-manager-driver/api-endpoints.ts +159 -0
  366. package/src/remote-manager-driver/api-utils.ts +69 -0
  367. package/src/remote-manager-driver/log.ts +5 -0
  368. package/src/remote-manager-driver/metadata.ts +64 -0
  369. package/src/remote-manager-driver/mod.ts +414 -0
  370. package/src/remote-manager-driver/ws-proxy.ts +189 -0
  371. package/src/schemas/actor-inspector/mod.ts +1 -0
  372. package/src/schemas/actor-inspector/versioned.ts +233 -0
  373. package/src/schemas/actor-persist/mod.ts +1 -0
  374. package/src/schemas/actor-persist/versioned.ts +217 -0
  375. package/src/schemas/client-protocol/mod.ts +1 -0
  376. package/src/schemas/client-protocol/versioned.ts +330 -0
  377. package/src/schemas/client-protocol-zod/mod.ts +118 -0
  378. package/src/schemas/file-system-driver/mod.ts +1 -0
  379. package/src/schemas/file-system-driver/versioned.ts +135 -0
  380. package/src/schemas/persist/mod.ts +1 -0
  381. package/src/schemas/transport/mod.ts +1 -0
  382. package/src/serde.ts +138 -0
  383. package/src/serve-test-suite/mod.ts +148 -0
  384. package/src/serverless/configure.ts +82 -0
  385. package/src/serverless/log.ts +5 -0
  386. package/src/serverless/router.test.ts +299 -0
  387. package/src/serverless/router.ts +215 -0
  388. package/src/test/log.ts +5 -0
  389. package/src/test/mod.ts +99 -0
  390. package/src/utils/crypto.ts +24 -0
  391. package/src/utils/endpoint-parser.test.ts +202 -0
  392. package/src/utils/endpoint-parser.ts +124 -0
  393. package/src/utils/env-vars.ts +78 -0
  394. package/src/utils/node.ts +178 -0
  395. package/src/utils/router.ts +83 -0
  396. package/src/utils/serve.ts +212 -0
  397. package/src/utils.test.ts +34 -0
  398. package/src/utils.ts +437 -0
  399. package/src/workflow/constants.ts +2 -0
  400. package/src/workflow/context.ts +597 -0
  401. package/src/workflow/driver.ts +194 -0
  402. package/src/workflow/inspector.ts +268 -0
  403. package/src/workflow/mod.ts +128 -0
@@ -0,0 +1,796 @@
1
+ // @generated - post-processed by compile-bare.ts
2
+ import * as bare from "@rivetkit/bare-ts"
3
+
4
+ const config = /* @__PURE__ */ bare.Config({})
5
+
6
+ export type uint = bigint
7
+
8
+ export type PatchStateRequest = {
9
+ readonly state: ArrayBuffer,
10
+ }
11
+
12
+ export function readPatchStateRequest(bc: bare.ByteCursor): PatchStateRequest {
13
+ return {
14
+ state: bare.readData(bc),
15
+ }
16
+ }
17
+
18
+ export function writePatchStateRequest(bc: bare.ByteCursor, x: PatchStateRequest): void {
19
+ bare.writeData(bc, x.state)
20
+ }
21
+
22
+ export type ActionRequest = {
23
+ readonly id: uint,
24
+ readonly name: string,
25
+ readonly args: ArrayBuffer,
26
+ }
27
+
28
+ export function readActionRequest(bc: bare.ByteCursor): ActionRequest {
29
+ return {
30
+ id: bare.readUint(bc),
31
+ name: bare.readString(bc),
32
+ args: bare.readData(bc),
33
+ }
34
+ }
35
+
36
+ export function writeActionRequest(bc: bare.ByteCursor, x: ActionRequest): void {
37
+ bare.writeUint(bc, x.id)
38
+ bare.writeString(bc, x.name)
39
+ bare.writeData(bc, x.args)
40
+ }
41
+
42
+ export type StateRequest = {
43
+ readonly id: uint,
44
+ }
45
+
46
+ export function readStateRequest(bc: bare.ByteCursor): StateRequest {
47
+ return {
48
+ id: bare.readUint(bc),
49
+ }
50
+ }
51
+
52
+ export function writeStateRequest(bc: bare.ByteCursor, x: StateRequest): void {
53
+ bare.writeUint(bc, x.id)
54
+ }
55
+
56
+ export type ConnectionsRequest = {
57
+ readonly id: uint,
58
+ }
59
+
60
+ export function readConnectionsRequest(bc: bare.ByteCursor): ConnectionsRequest {
61
+ return {
62
+ id: bare.readUint(bc),
63
+ }
64
+ }
65
+
66
+ export function writeConnectionsRequest(bc: bare.ByteCursor, x: ConnectionsRequest): void {
67
+ bare.writeUint(bc, x.id)
68
+ }
69
+
70
+ export type RpcsListRequest = {
71
+ readonly id: uint,
72
+ }
73
+
74
+ export function readRpcsListRequest(bc: bare.ByteCursor): RpcsListRequest {
75
+ return {
76
+ id: bare.readUint(bc),
77
+ }
78
+ }
79
+
80
+ export function writeRpcsListRequest(bc: bare.ByteCursor, x: RpcsListRequest): void {
81
+ bare.writeUint(bc, x.id)
82
+ }
83
+
84
+ export type TraceQueryRequest = {
85
+ readonly id: uint,
86
+ readonly startMs: uint,
87
+ readonly endMs: uint,
88
+ readonly limit: uint,
89
+ }
90
+
91
+ export function readTraceQueryRequest(bc: bare.ByteCursor): TraceQueryRequest {
92
+ return {
93
+ id: bare.readUint(bc),
94
+ startMs: bare.readUint(bc),
95
+ endMs: bare.readUint(bc),
96
+ limit: bare.readUint(bc),
97
+ }
98
+ }
99
+
100
+ export function writeTraceQueryRequest(bc: bare.ByteCursor, x: TraceQueryRequest): void {
101
+ bare.writeUint(bc, x.id)
102
+ bare.writeUint(bc, x.startMs)
103
+ bare.writeUint(bc, x.endMs)
104
+ bare.writeUint(bc, x.limit)
105
+ }
106
+
107
+ export type QueueRequest = {
108
+ readonly id: uint,
109
+ readonly limit: uint,
110
+ }
111
+
112
+ export function readQueueRequest(bc: bare.ByteCursor): QueueRequest {
113
+ return {
114
+ id: bare.readUint(bc),
115
+ limit: bare.readUint(bc),
116
+ }
117
+ }
118
+
119
+ export function writeQueueRequest(bc: bare.ByteCursor, x: QueueRequest): void {
120
+ bare.writeUint(bc, x.id)
121
+ bare.writeUint(bc, x.limit)
122
+ }
123
+
124
+ export type WorkflowHistoryRequest = {
125
+ readonly id: uint,
126
+ }
127
+
128
+ export function readWorkflowHistoryRequest(bc: bare.ByteCursor): WorkflowHistoryRequest {
129
+ return {
130
+ id: bare.readUint(bc),
131
+ }
132
+ }
133
+
134
+ export function writeWorkflowHistoryRequest(bc: bare.ByteCursor, x: WorkflowHistoryRequest): void {
135
+ bare.writeUint(bc, x.id)
136
+ }
137
+
138
+ export type ToServerBody =
139
+ | { readonly tag: "PatchStateRequest", readonly val: PatchStateRequest }
140
+ | { readonly tag: "StateRequest", readonly val: StateRequest }
141
+ | { readonly tag: "ConnectionsRequest", readonly val: ConnectionsRequest }
142
+ | { readonly tag: "ActionRequest", readonly val: ActionRequest }
143
+ | { readonly tag: "RpcsListRequest", readonly val: RpcsListRequest }
144
+ | { readonly tag: "TraceQueryRequest", readonly val: TraceQueryRequest }
145
+ | { readonly tag: "QueueRequest", readonly val: QueueRequest }
146
+ | { readonly tag: "WorkflowHistoryRequest", readonly val: WorkflowHistoryRequest }
147
+
148
+ export function readToServerBody(bc: bare.ByteCursor): ToServerBody {
149
+ const offset = bc.offset
150
+ const tag = bare.readU8(bc)
151
+ switch (tag) {
152
+ case 0:
153
+ return { tag: "PatchStateRequest", val: readPatchStateRequest(bc) }
154
+ case 1:
155
+ return { tag: "StateRequest", val: readStateRequest(bc) }
156
+ case 2:
157
+ return { tag: "ConnectionsRequest", val: readConnectionsRequest(bc) }
158
+ case 3:
159
+ return { tag: "ActionRequest", val: readActionRequest(bc) }
160
+ case 4:
161
+ return { tag: "RpcsListRequest", val: readRpcsListRequest(bc) }
162
+ case 5:
163
+ return { tag: "TraceQueryRequest", val: readTraceQueryRequest(bc) }
164
+ case 6:
165
+ return { tag: "QueueRequest", val: readQueueRequest(bc) }
166
+ case 7:
167
+ return { tag: "WorkflowHistoryRequest", val: readWorkflowHistoryRequest(bc) }
168
+ default: {
169
+ bc.offset = offset
170
+ throw new bare.BareError(offset, "invalid tag")
171
+ }
172
+ }
173
+ }
174
+
175
+ export function writeToServerBody(bc: bare.ByteCursor, x: ToServerBody): void {
176
+ switch (x.tag) {
177
+ case "PatchStateRequest": {
178
+ bare.writeU8(bc, 0)
179
+ writePatchStateRequest(bc, x.val)
180
+ break
181
+ }
182
+ case "StateRequest": {
183
+ bare.writeU8(bc, 1)
184
+ writeStateRequest(bc, x.val)
185
+ break
186
+ }
187
+ case "ConnectionsRequest": {
188
+ bare.writeU8(bc, 2)
189
+ writeConnectionsRequest(bc, x.val)
190
+ break
191
+ }
192
+ case "ActionRequest": {
193
+ bare.writeU8(bc, 3)
194
+ writeActionRequest(bc, x.val)
195
+ break
196
+ }
197
+ case "RpcsListRequest": {
198
+ bare.writeU8(bc, 4)
199
+ writeRpcsListRequest(bc, x.val)
200
+ break
201
+ }
202
+ case "TraceQueryRequest": {
203
+ bare.writeU8(bc, 5)
204
+ writeTraceQueryRequest(bc, x.val)
205
+ break
206
+ }
207
+ case "QueueRequest": {
208
+ bare.writeU8(bc, 6)
209
+ writeQueueRequest(bc, x.val)
210
+ break
211
+ }
212
+ case "WorkflowHistoryRequest": {
213
+ bare.writeU8(bc, 7)
214
+ writeWorkflowHistoryRequest(bc, x.val)
215
+ break
216
+ }
217
+ }
218
+ }
219
+
220
+ export type ToServer = {
221
+ readonly body: ToServerBody,
222
+ }
223
+
224
+ export function readToServer(bc: bare.ByteCursor): ToServer {
225
+ return {
226
+ body: readToServerBody(bc),
227
+ }
228
+ }
229
+
230
+ export function writeToServer(bc: bare.ByteCursor, x: ToServer): void {
231
+ writeToServerBody(bc, x.body)
232
+ }
233
+
234
+ export function encodeToServer(x: ToServer): Uint8Array {
235
+ const bc = new bare.ByteCursor(
236
+ new Uint8Array(config.initialBufferLength),
237
+ config
238
+ )
239
+ writeToServer(bc, x)
240
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
241
+ }
242
+
243
+ export function decodeToServer(bytes: Uint8Array): ToServer {
244
+ const bc = new bare.ByteCursor(bytes, config)
245
+ const result = readToServer(bc)
246
+ if (bc.offset < bc.view.byteLength) {
247
+ throw new bare.BareError(bc.offset, "remaining bytes")
248
+ }
249
+ return result
250
+ }
251
+
252
+ export type State = ArrayBuffer
253
+
254
+ export function readState(bc: bare.ByteCursor): State {
255
+ return bare.readData(bc)
256
+ }
257
+
258
+ export function writeState(bc: bare.ByteCursor, x: State): void {
259
+ bare.writeData(bc, x)
260
+ }
261
+
262
+ export type Connection = {
263
+ readonly id: string,
264
+ readonly details: ArrayBuffer,
265
+ }
266
+
267
+ export function readConnection(bc: bare.ByteCursor): Connection {
268
+ return {
269
+ id: bare.readString(bc),
270
+ details: bare.readData(bc),
271
+ }
272
+ }
273
+
274
+ export function writeConnection(bc: bare.ByteCursor, x: Connection): void {
275
+ bare.writeString(bc, x.id)
276
+ bare.writeData(bc, x.details)
277
+ }
278
+
279
+ export type WorkflowHistory = ArrayBuffer
280
+
281
+ export function readWorkflowHistory(bc: bare.ByteCursor): WorkflowHistory {
282
+ return bare.readData(bc)
283
+ }
284
+
285
+ export function writeWorkflowHistory(bc: bare.ByteCursor, x: WorkflowHistory): void {
286
+ bare.writeData(bc, x)
287
+ }
288
+
289
+ function read0(bc: bare.ByteCursor): readonly Connection[] {
290
+ const len = bare.readUintSafe(bc)
291
+ if (len === 0) { return [] }
292
+ const result = [readConnection(bc)]
293
+ for (let i = 1; i < len; i++) {
294
+ result[i] = readConnection(bc)
295
+ }
296
+ return result
297
+ }
298
+
299
+ function write0(bc: bare.ByteCursor, x: readonly Connection[]): void {
300
+ bare.writeUintSafe(bc, x.length)
301
+ for (let i = 0; i < x.length; i++) {
302
+ writeConnection(bc, x[i])
303
+ }
304
+ }
305
+
306
+ function read1(bc: bare.ByteCursor): State | null {
307
+ return bare.readBool(bc)
308
+ ? readState(bc)
309
+ : null
310
+ }
311
+
312
+ function write1(bc: bare.ByteCursor, x: State | null): void {
313
+ bare.writeBool(bc, x !== null)
314
+ if (x !== null) {
315
+ writeState(bc, x)
316
+ }
317
+ }
318
+
319
+ function read2(bc: bare.ByteCursor): readonly string[] {
320
+ const len = bare.readUintSafe(bc)
321
+ if (len === 0) { return [] }
322
+ const result = [bare.readString(bc)]
323
+ for (let i = 1; i < len; i++) {
324
+ result[i] = bare.readString(bc)
325
+ }
326
+ return result
327
+ }
328
+
329
+ function write2(bc: bare.ByteCursor, x: readonly string[]): void {
330
+ bare.writeUintSafe(bc, x.length)
331
+ for (let i = 0; i < x.length; i++) {
332
+ bare.writeString(bc, x[i])
333
+ }
334
+ }
335
+
336
+ function read3(bc: bare.ByteCursor): WorkflowHistory | null {
337
+ return bare.readBool(bc)
338
+ ? readWorkflowHistory(bc)
339
+ : null
340
+ }
341
+
342
+ function write3(bc: bare.ByteCursor, x: WorkflowHistory | null): void {
343
+ bare.writeBool(bc, x !== null)
344
+ if (x !== null) {
345
+ writeWorkflowHistory(bc, x)
346
+ }
347
+ }
348
+
349
+ export type Init = {
350
+ readonly connections: readonly Connection[],
351
+ readonly state: State | null,
352
+ readonly isStateEnabled: boolean,
353
+ readonly rpcs: readonly string[],
354
+ readonly isDatabaseEnabled: boolean,
355
+ readonly queueSize: uint,
356
+ readonly workflowHistory: WorkflowHistory | null,
357
+ readonly isWorkflowEnabled: boolean,
358
+ }
359
+
360
+ export function readInit(bc: bare.ByteCursor): Init {
361
+ return {
362
+ connections: read0(bc),
363
+ state: read1(bc),
364
+ isStateEnabled: bare.readBool(bc),
365
+ rpcs: read2(bc),
366
+ isDatabaseEnabled: bare.readBool(bc),
367
+ queueSize: bare.readUint(bc),
368
+ workflowHistory: read3(bc),
369
+ isWorkflowEnabled: bare.readBool(bc),
370
+ }
371
+ }
372
+
373
+ export function writeInit(bc: bare.ByteCursor, x: Init): void {
374
+ write0(bc, x.connections)
375
+ write1(bc, x.state)
376
+ bare.writeBool(bc, x.isStateEnabled)
377
+ write2(bc, x.rpcs)
378
+ bare.writeBool(bc, x.isDatabaseEnabled)
379
+ bare.writeUint(bc, x.queueSize)
380
+ write3(bc, x.workflowHistory)
381
+ bare.writeBool(bc, x.isWorkflowEnabled)
382
+ }
383
+
384
+ export type ConnectionsResponse = {
385
+ readonly rid: uint,
386
+ readonly connections: readonly Connection[],
387
+ }
388
+
389
+ export function readConnectionsResponse(bc: bare.ByteCursor): ConnectionsResponse {
390
+ return {
391
+ rid: bare.readUint(bc),
392
+ connections: read0(bc),
393
+ }
394
+ }
395
+
396
+ export function writeConnectionsResponse(bc: bare.ByteCursor, x: ConnectionsResponse): void {
397
+ bare.writeUint(bc, x.rid)
398
+ write0(bc, x.connections)
399
+ }
400
+
401
+ export type StateResponse = {
402
+ readonly rid: uint,
403
+ readonly state: State | null,
404
+ readonly isStateEnabled: boolean,
405
+ }
406
+
407
+ export function readStateResponse(bc: bare.ByteCursor): StateResponse {
408
+ return {
409
+ rid: bare.readUint(bc),
410
+ state: read1(bc),
411
+ isStateEnabled: bare.readBool(bc),
412
+ }
413
+ }
414
+
415
+ export function writeStateResponse(bc: bare.ByteCursor, x: StateResponse): void {
416
+ bare.writeUint(bc, x.rid)
417
+ write1(bc, x.state)
418
+ bare.writeBool(bc, x.isStateEnabled)
419
+ }
420
+
421
+ export type ActionResponse = {
422
+ readonly rid: uint,
423
+ readonly output: ArrayBuffer,
424
+ }
425
+
426
+ export function readActionResponse(bc: bare.ByteCursor): ActionResponse {
427
+ return {
428
+ rid: bare.readUint(bc),
429
+ output: bare.readData(bc),
430
+ }
431
+ }
432
+
433
+ export function writeActionResponse(bc: bare.ByteCursor, x: ActionResponse): void {
434
+ bare.writeUint(bc, x.rid)
435
+ bare.writeData(bc, x.output)
436
+ }
437
+
438
+ export type TraceQueryResponse = {
439
+ readonly rid: uint,
440
+ readonly payload: ArrayBuffer,
441
+ }
442
+
443
+ export function readTraceQueryResponse(bc: bare.ByteCursor): TraceQueryResponse {
444
+ return {
445
+ rid: bare.readUint(bc),
446
+ payload: bare.readData(bc),
447
+ }
448
+ }
449
+
450
+ export function writeTraceQueryResponse(bc: bare.ByteCursor, x: TraceQueryResponse): void {
451
+ bare.writeUint(bc, x.rid)
452
+ bare.writeData(bc, x.payload)
453
+ }
454
+
455
+ export type QueueMessageSummary = {
456
+ readonly id: uint,
457
+ readonly name: string,
458
+ readonly createdAtMs: uint,
459
+ }
460
+
461
+ export function readQueueMessageSummary(bc: bare.ByteCursor): QueueMessageSummary {
462
+ return {
463
+ id: bare.readUint(bc),
464
+ name: bare.readString(bc),
465
+ createdAtMs: bare.readUint(bc),
466
+ }
467
+ }
468
+
469
+ export function writeQueueMessageSummary(bc: bare.ByteCursor, x: QueueMessageSummary): void {
470
+ bare.writeUint(bc, x.id)
471
+ bare.writeString(bc, x.name)
472
+ bare.writeUint(bc, x.createdAtMs)
473
+ }
474
+
475
+ function read4(bc: bare.ByteCursor): readonly QueueMessageSummary[] {
476
+ const len = bare.readUintSafe(bc)
477
+ if (len === 0) { return [] }
478
+ const result = [readQueueMessageSummary(bc)]
479
+ for (let i = 1; i < len; i++) {
480
+ result[i] = readQueueMessageSummary(bc)
481
+ }
482
+ return result
483
+ }
484
+
485
+ function write4(bc: bare.ByteCursor, x: readonly QueueMessageSummary[]): void {
486
+ bare.writeUintSafe(bc, x.length)
487
+ for (let i = 0; i < x.length; i++) {
488
+ writeQueueMessageSummary(bc, x[i])
489
+ }
490
+ }
491
+
492
+ export type QueueStatus = {
493
+ readonly size: uint,
494
+ readonly maxSize: uint,
495
+ readonly messages: readonly QueueMessageSummary[],
496
+ readonly truncated: boolean,
497
+ }
498
+
499
+ export function readQueueStatus(bc: bare.ByteCursor): QueueStatus {
500
+ return {
501
+ size: bare.readUint(bc),
502
+ maxSize: bare.readUint(bc),
503
+ messages: read4(bc),
504
+ truncated: bare.readBool(bc),
505
+ }
506
+ }
507
+
508
+ export function writeQueueStatus(bc: bare.ByteCursor, x: QueueStatus): void {
509
+ bare.writeUint(bc, x.size)
510
+ bare.writeUint(bc, x.maxSize)
511
+ write4(bc, x.messages)
512
+ bare.writeBool(bc, x.truncated)
513
+ }
514
+
515
+ export type QueueResponse = {
516
+ readonly rid: uint,
517
+ readonly status: QueueStatus,
518
+ }
519
+
520
+ export function readQueueResponse(bc: bare.ByteCursor): QueueResponse {
521
+ return {
522
+ rid: bare.readUint(bc),
523
+ status: readQueueStatus(bc),
524
+ }
525
+ }
526
+
527
+ export function writeQueueResponse(bc: bare.ByteCursor, x: QueueResponse): void {
528
+ bare.writeUint(bc, x.rid)
529
+ writeQueueStatus(bc, x.status)
530
+ }
531
+
532
+ export type WorkflowHistoryResponse = {
533
+ readonly rid: uint,
534
+ readonly history: WorkflowHistory | null,
535
+ readonly isWorkflowEnabled: boolean,
536
+ }
537
+
538
+ export function readWorkflowHistoryResponse(bc: bare.ByteCursor): WorkflowHistoryResponse {
539
+ return {
540
+ rid: bare.readUint(bc),
541
+ history: read3(bc),
542
+ isWorkflowEnabled: bare.readBool(bc),
543
+ }
544
+ }
545
+
546
+ export function writeWorkflowHistoryResponse(bc: bare.ByteCursor, x: WorkflowHistoryResponse): void {
547
+ bare.writeUint(bc, x.rid)
548
+ write3(bc, x.history)
549
+ bare.writeBool(bc, x.isWorkflowEnabled)
550
+ }
551
+
552
+ export type StateUpdated = {
553
+ readonly state: State,
554
+ }
555
+
556
+ export function readStateUpdated(bc: bare.ByteCursor): StateUpdated {
557
+ return {
558
+ state: readState(bc),
559
+ }
560
+ }
561
+
562
+ export function writeStateUpdated(bc: bare.ByteCursor, x: StateUpdated): void {
563
+ writeState(bc, x.state)
564
+ }
565
+
566
+ export type QueueUpdated = {
567
+ readonly queueSize: uint,
568
+ }
569
+
570
+ export function readQueueUpdated(bc: bare.ByteCursor): QueueUpdated {
571
+ return {
572
+ queueSize: bare.readUint(bc),
573
+ }
574
+ }
575
+
576
+ export function writeQueueUpdated(bc: bare.ByteCursor, x: QueueUpdated): void {
577
+ bare.writeUint(bc, x.queueSize)
578
+ }
579
+
580
+ export type WorkflowHistoryUpdated = {
581
+ readonly history: WorkflowHistory,
582
+ }
583
+
584
+ export function readWorkflowHistoryUpdated(bc: bare.ByteCursor): WorkflowHistoryUpdated {
585
+ return {
586
+ history: readWorkflowHistory(bc),
587
+ }
588
+ }
589
+
590
+ export function writeWorkflowHistoryUpdated(bc: bare.ByteCursor, x: WorkflowHistoryUpdated): void {
591
+ writeWorkflowHistory(bc, x.history)
592
+ }
593
+
594
+ export type RpcsListResponse = {
595
+ readonly rid: uint,
596
+ readonly rpcs: readonly string[],
597
+ }
598
+
599
+ export function readRpcsListResponse(bc: bare.ByteCursor): RpcsListResponse {
600
+ return {
601
+ rid: bare.readUint(bc),
602
+ rpcs: read2(bc),
603
+ }
604
+ }
605
+
606
+ export function writeRpcsListResponse(bc: bare.ByteCursor, x: RpcsListResponse): void {
607
+ bare.writeUint(bc, x.rid)
608
+ write2(bc, x.rpcs)
609
+ }
610
+
611
+ export type ConnectionsUpdated = {
612
+ readonly connections: readonly Connection[],
613
+ }
614
+
615
+ export function readConnectionsUpdated(bc: bare.ByteCursor): ConnectionsUpdated {
616
+ return {
617
+ connections: read0(bc),
618
+ }
619
+ }
620
+
621
+ export function writeConnectionsUpdated(bc: bare.ByteCursor, x: ConnectionsUpdated): void {
622
+ write0(bc, x.connections)
623
+ }
624
+
625
+ export type Error = {
626
+ readonly message: string,
627
+ }
628
+
629
+ export function readError(bc: bare.ByteCursor): Error {
630
+ return {
631
+ message: bare.readString(bc),
632
+ }
633
+ }
634
+
635
+ export function writeError(bc: bare.ByteCursor, x: Error): void {
636
+ bare.writeString(bc, x.message)
637
+ }
638
+
639
+ export type ToClientBody =
640
+ | { readonly tag: "StateResponse", readonly val: StateResponse }
641
+ | { readonly tag: "ConnectionsResponse", readonly val: ConnectionsResponse }
642
+ | { readonly tag: "ActionResponse", readonly val: ActionResponse }
643
+ | { readonly tag: "ConnectionsUpdated", readonly val: ConnectionsUpdated }
644
+ | { readonly tag: "QueueUpdated", readonly val: QueueUpdated }
645
+ | { readonly tag: "StateUpdated", readonly val: StateUpdated }
646
+ | { readonly tag: "WorkflowHistoryUpdated", readonly val: WorkflowHistoryUpdated }
647
+ | { readonly tag: "RpcsListResponse", readonly val: RpcsListResponse }
648
+ | { readonly tag: "TraceQueryResponse", readonly val: TraceQueryResponse }
649
+ | { readonly tag: "QueueResponse", readonly val: QueueResponse }
650
+ | { readonly tag: "WorkflowHistoryResponse", readonly val: WorkflowHistoryResponse }
651
+ | { readonly tag: "Error", readonly val: Error }
652
+ | { readonly tag: "Init", readonly val: Init }
653
+
654
+ export function readToClientBody(bc: bare.ByteCursor): ToClientBody {
655
+ const offset = bc.offset
656
+ const tag = bare.readU8(bc)
657
+ switch (tag) {
658
+ case 0:
659
+ return { tag: "StateResponse", val: readStateResponse(bc) }
660
+ case 1:
661
+ return { tag: "ConnectionsResponse", val: readConnectionsResponse(bc) }
662
+ case 2:
663
+ return { tag: "ActionResponse", val: readActionResponse(bc) }
664
+ case 3:
665
+ return { tag: "ConnectionsUpdated", val: readConnectionsUpdated(bc) }
666
+ case 4:
667
+ return { tag: "QueueUpdated", val: readQueueUpdated(bc) }
668
+ case 5:
669
+ return { tag: "StateUpdated", val: readStateUpdated(bc) }
670
+ case 6:
671
+ return { tag: "WorkflowHistoryUpdated", val: readWorkflowHistoryUpdated(bc) }
672
+ case 7:
673
+ return { tag: "RpcsListResponse", val: readRpcsListResponse(bc) }
674
+ case 8:
675
+ return { tag: "TraceQueryResponse", val: readTraceQueryResponse(bc) }
676
+ case 9:
677
+ return { tag: "QueueResponse", val: readQueueResponse(bc) }
678
+ case 10:
679
+ return { tag: "WorkflowHistoryResponse", val: readWorkflowHistoryResponse(bc) }
680
+ case 11:
681
+ return { tag: "Error", val: readError(bc) }
682
+ case 12:
683
+ return { tag: "Init", val: readInit(bc) }
684
+ default: {
685
+ bc.offset = offset
686
+ throw new bare.BareError(offset, "invalid tag")
687
+ }
688
+ }
689
+ }
690
+
691
+ export function writeToClientBody(bc: bare.ByteCursor, x: ToClientBody): void {
692
+ switch (x.tag) {
693
+ case "StateResponse": {
694
+ bare.writeU8(bc, 0)
695
+ writeStateResponse(bc, x.val)
696
+ break
697
+ }
698
+ case "ConnectionsResponse": {
699
+ bare.writeU8(bc, 1)
700
+ writeConnectionsResponse(bc, x.val)
701
+ break
702
+ }
703
+ case "ActionResponse": {
704
+ bare.writeU8(bc, 2)
705
+ writeActionResponse(bc, x.val)
706
+ break
707
+ }
708
+ case "ConnectionsUpdated": {
709
+ bare.writeU8(bc, 3)
710
+ writeConnectionsUpdated(bc, x.val)
711
+ break
712
+ }
713
+ case "QueueUpdated": {
714
+ bare.writeU8(bc, 4)
715
+ writeQueueUpdated(bc, x.val)
716
+ break
717
+ }
718
+ case "StateUpdated": {
719
+ bare.writeU8(bc, 5)
720
+ writeStateUpdated(bc, x.val)
721
+ break
722
+ }
723
+ case "WorkflowHistoryUpdated": {
724
+ bare.writeU8(bc, 6)
725
+ writeWorkflowHistoryUpdated(bc, x.val)
726
+ break
727
+ }
728
+ case "RpcsListResponse": {
729
+ bare.writeU8(bc, 7)
730
+ writeRpcsListResponse(bc, x.val)
731
+ break
732
+ }
733
+ case "TraceQueryResponse": {
734
+ bare.writeU8(bc, 8)
735
+ writeTraceQueryResponse(bc, x.val)
736
+ break
737
+ }
738
+ case "QueueResponse": {
739
+ bare.writeU8(bc, 9)
740
+ writeQueueResponse(bc, x.val)
741
+ break
742
+ }
743
+ case "WorkflowHistoryResponse": {
744
+ bare.writeU8(bc, 10)
745
+ writeWorkflowHistoryResponse(bc, x.val)
746
+ break
747
+ }
748
+ case "Error": {
749
+ bare.writeU8(bc, 11)
750
+ writeError(bc, x.val)
751
+ break
752
+ }
753
+ case "Init": {
754
+ bare.writeU8(bc, 12)
755
+ writeInit(bc, x.val)
756
+ break
757
+ }
758
+ }
759
+ }
760
+
761
+ export type ToClient = {
762
+ readonly body: ToClientBody,
763
+ }
764
+
765
+ export function readToClient(bc: bare.ByteCursor): ToClient {
766
+ return {
767
+ body: readToClientBody(bc),
768
+ }
769
+ }
770
+
771
+ export function writeToClient(bc: bare.ByteCursor, x: ToClient): void {
772
+ writeToClientBody(bc, x.body)
773
+ }
774
+
775
+ export function encodeToClient(x: ToClient): Uint8Array {
776
+ const bc = new bare.ByteCursor(
777
+ new Uint8Array(config.initialBufferLength),
778
+ config
779
+ )
780
+ writeToClient(bc, x)
781
+ return new Uint8Array(bc.view.buffer, bc.view.byteOffset, bc.offset)
782
+ }
783
+
784
+ export function decodeToClient(bytes: Uint8Array): ToClient {
785
+ const bc = new bare.ByteCursor(bytes, config)
786
+ const result = readToClient(bc)
787
+ if (bc.offset < bc.view.byteLength) {
788
+ throw new bare.BareError(bc.offset, "remaining bytes")
789
+ }
790
+ return result
791
+ }
792
+
793
+
794
+ function assert(condition: boolean, message?: string): asserts condition {
795
+ if (!condition) throw new Error(message ?? "Assertion failed")
796
+ }