rivetkit 2.0.42 → 2.1.0-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 (322) hide show
  1. package/dist/{tsup/config-CLnylLYY.d.ts → browser/client.d.ts} +2127 -1910
  2. package/dist/browser/client.js +5182 -0
  3. package/dist/browser/client.js.map +1 -0
  4. package/dist/browser/inspector/client.d.ts +130 -0
  5. package/dist/browser/inspector/client.js +2854 -0
  6. package/dist/browser/inspector/client.js.map +1 -0
  7. package/dist/browser/v3-DnYObHH3.d.ts +279 -0
  8. package/dist/schemas/actor-inspector/v2.ts +796 -0
  9. package/dist/schemas/actor-inspector/v3.ts +899 -0
  10. package/dist/schemas/actor-persist/v4.ts +406 -0
  11. package/dist/schemas/client-protocol/v3.ts +554 -0
  12. package/dist/schemas/persist/v1.ts +781 -0
  13. package/dist/schemas/transport/v1.ts +697 -0
  14. package/dist/tsup/actor/errors.cjs +27 -3
  15. package/dist/tsup/actor/errors.cjs.map +1 -1
  16. package/dist/tsup/actor/errors.d.cts +37 -1
  17. package/dist/tsup/actor/errors.d.ts +37 -1
  18. package/dist/tsup/actor/errors.js +26 -1
  19. package/dist/tsup/{actor-router-consts-DzI2szci.d.cts → actor-router-consts-D29T1Z-K.d.cts} +1 -1
  20. package/dist/tsup/{actor-router-consts-DzI2szci.d.ts → actor-router-consts-D29T1Z-K.d.ts} +1 -1
  21. package/dist/tsup/chunk-424PT5DM.js +23 -0
  22. package/dist/tsup/chunk-424PT5DM.js.map +1 -0
  23. package/dist/tsup/{chunk-JDAD2YFA.js → chunk-5ESWDTHJ.js} +148 -273
  24. package/dist/tsup/chunk-5ESWDTHJ.js.map +1 -0
  25. package/dist/tsup/{chunk-FJ3KTN4V.js → chunk-6LIBPELE.js} +119 -11
  26. package/dist/tsup/chunk-6LIBPELE.js.map +1 -0
  27. package/dist/tsup/chunk-6LJAZ5R4.cjs +96 -0
  28. package/dist/tsup/chunk-6LJAZ5R4.cjs.map +1 -0
  29. package/dist/tsup/{chunk-LFVF5SCU.js → chunk-7HTNH26M.js} +126 -1
  30. package/dist/tsup/chunk-7HTNH26M.js.map +1 -0
  31. package/dist/tsup/chunk-7K4CYDGD.js +630 -0
  32. package/dist/tsup/chunk-7K4CYDGD.js.map +1 -0
  33. package/dist/tsup/{chunk-XXGJCOL6.js → chunk-A6YIZWTK.js} +2 -2
  34. package/dist/tsup/chunk-AIYEYMX5.cjs +630 -0
  35. package/dist/tsup/chunk-AIYEYMX5.cjs.map +1 -0
  36. package/dist/tsup/{chunk-Q6W7RJJP.js → chunk-DIGBC2VI.js} +211 -2316
  37. package/dist/tsup/chunk-DIGBC2VI.js.map +1 -0
  38. package/dist/tsup/{chunk-RZW2DNND.cjs → chunk-F6JYU5IK.cjs} +1957 -1039
  39. package/dist/tsup/chunk-F6JYU5IK.cjs.map +1 -0
  40. package/dist/tsup/chunk-HAZL2EPK.cjs +534 -0
  41. package/dist/tsup/chunk-HAZL2EPK.cjs.map +1 -0
  42. package/dist/tsup/chunk-HDQ2JUQT.cjs +23 -0
  43. package/dist/tsup/chunk-HDQ2JUQT.cjs.map +1 -0
  44. package/dist/tsup/chunk-HIDX4C5Y.cjs +1036 -0
  45. package/dist/tsup/chunk-HIDX4C5Y.cjs.map +1 -0
  46. package/dist/tsup/chunk-IVG73YCW.js +534 -0
  47. package/dist/tsup/chunk-IVG73YCW.js.map +1 -0
  48. package/dist/tsup/chunk-KJSYAUOM.js +96 -0
  49. package/dist/tsup/chunk-KJSYAUOM.js.map +1 -0
  50. package/dist/tsup/{chunk-2XQS746M.cjs → chunk-L47L3ZWJ.cjs} +127 -2
  51. package/dist/tsup/chunk-L47L3ZWJ.cjs.map +1 -0
  52. package/dist/tsup/{chunk-H4TB4X25.cjs → chunk-LW6KLR7A.cjs} +126 -18
  53. package/dist/tsup/chunk-LW6KLR7A.cjs.map +1 -0
  54. package/dist/tsup/chunk-LXUQ667X.js +2006 -0
  55. package/dist/tsup/chunk-LXUQ667X.js.map +1 -0
  56. package/dist/tsup/{chunk-GMAVRZSF.js → chunk-M2T62AZQ.js} +1790 -872
  57. package/dist/tsup/chunk-M2T62AZQ.js.map +1 -0
  58. package/dist/tsup/chunk-MZ37VV3P.js +5974 -0
  59. package/dist/tsup/chunk-MZ37VV3P.js.map +1 -0
  60. package/dist/tsup/chunk-N4KRDJ56.js +72 -0
  61. package/dist/tsup/chunk-N4KRDJ56.js.map +1 -0
  62. package/dist/tsup/chunk-NIYZDWMW.cjs +2006 -0
  63. package/dist/tsup/chunk-NIYZDWMW.cjs.map +1 -0
  64. package/dist/tsup/chunk-OMEPCQK2.js +649 -0
  65. package/dist/tsup/chunk-OMEPCQK2.js.map +1 -0
  66. package/dist/tsup/chunk-SR3KQE7Q.cjs +72 -0
  67. package/dist/tsup/chunk-SR3KQE7Q.cjs.map +1 -0
  68. package/dist/tsup/chunk-SSEP6DHP.cjs +2657 -0
  69. package/dist/tsup/chunk-SSEP6DHP.cjs.map +1 -0
  70. package/dist/tsup/chunk-T5YCUGVS.js +1036 -0
  71. package/dist/tsup/chunk-T5YCUGVS.js.map +1 -0
  72. package/dist/tsup/{chunk-EJVBH5VF.cjs → chunk-TPGXWFQT.cjs} +3 -3
  73. package/dist/tsup/{chunk-EJVBH5VF.cjs.map → chunk-TPGXWFQT.cjs.map} +1 -1
  74. package/dist/tsup/{chunk-X35U3YNX.cjs → chunk-TYLXNCA5.cjs} +214 -339
  75. package/dist/tsup/chunk-TYLXNCA5.cjs.map +1 -0
  76. package/dist/tsup/chunk-VKVNIQRQ.js +257 -0
  77. package/dist/tsup/chunk-VKVNIQRQ.js.map +1 -0
  78. package/dist/tsup/chunk-XWBAQO5H.cjs +649 -0
  79. package/dist/tsup/chunk-XWBAQO5H.cjs.map +1 -0
  80. package/dist/tsup/chunk-YQ4LDVD6.cjs +5974 -0
  81. package/dist/tsup/chunk-YQ4LDVD6.cjs.map +1 -0
  82. package/dist/tsup/chunk-ZFY5J2EP.cjs +257 -0
  83. package/dist/tsup/chunk-ZFY5J2EP.cjs.map +1 -0
  84. package/dist/tsup/client/mod.cjs +9 -10
  85. package/dist/tsup/client/mod.cjs.map +1 -1
  86. package/dist/tsup/client/mod.d.cts +11 -5
  87. package/dist/tsup/client/mod.d.ts +11 -5
  88. package/dist/tsup/client/mod.js +8 -8
  89. package/dist/tsup/common/log.cjs +4 -4
  90. package/dist/tsup/common/log.d.cts +2 -2
  91. package/dist/tsup/common/log.d.ts +2 -2
  92. package/dist/tsup/common/log.js +3 -2
  93. package/dist/tsup/common/websocket.cjs +5 -5
  94. package/dist/tsup/common/websocket.js +4 -3
  95. package/dist/tsup/config-BFqid9Gr.d.ts +2574 -0
  96. package/dist/tsup/config-BiNoIHRs.d.cts +80 -0
  97. package/dist/tsup/config-BiNoIHRs.d.ts +80 -0
  98. package/dist/tsup/{config-CZB2-W8x.d.cts → config-CAZphOS1.d.cts} +681 -355
  99. package/dist/tsup/db/drizzle/mod.cjs +49 -0
  100. package/dist/tsup/db/drizzle/mod.cjs.map +1 -0
  101. package/dist/tsup/db/drizzle/mod.d.cts +17 -0
  102. package/dist/tsup/db/drizzle/mod.d.ts +17 -0
  103. package/dist/tsup/db/drizzle/mod.js +49 -0
  104. package/dist/tsup/db/drizzle/mod.js.map +1 -0
  105. package/dist/tsup/db/mod.cjs +9 -0
  106. package/dist/tsup/db/mod.cjs.map +1 -0
  107. package/dist/tsup/db/mod.d.cts +9 -0
  108. package/dist/tsup/db/mod.d.ts +9 -0
  109. package/dist/tsup/db/mod.js +9 -0
  110. package/dist/tsup/db/mod.js.map +1 -0
  111. package/dist/tsup/{driver-D0QX9M11.d.ts → driver-Bxv62E2p.d.ts} +2 -2
  112. package/dist/tsup/{driver-q-zqG7fc.d.cts → driver-DYXwJR5D.d.cts} +2 -2
  113. package/dist/tsup/driver-helpers/mod.cjs +12 -6
  114. package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
  115. package/dist/tsup/driver-helpers/mod.d.cts +12 -5
  116. package/dist/tsup/driver-helpers/mod.d.ts +12 -5
  117. package/dist/tsup/driver-helpers/mod.js +12 -5
  118. package/dist/tsup/driver-test-suite/mod.cjs +1370 -116
  119. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  120. package/dist/tsup/driver-test-suite/mod.d.cts +10 -4
  121. package/dist/tsup/driver-test-suite/mod.d.ts +10 -4
  122. package/dist/tsup/driver-test-suite/mod.js +2093 -838
  123. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  124. package/dist/tsup/inspector/mod.cjs +29 -3
  125. package/dist/tsup/inspector/mod.cjs.map +1 -1
  126. package/dist/tsup/inspector/mod.d.cts +124 -3
  127. package/dist/tsup/inspector/mod.d.ts +124 -3
  128. package/dist/tsup/inspector/mod.js +72 -45
  129. package/dist/tsup/keys-CydblqMh.d.cts +13 -0
  130. package/dist/tsup/keys-CydblqMh.d.ts +13 -0
  131. package/dist/tsup/mod.cjs +16 -10
  132. package/dist/tsup/mod.cjs.map +1 -1
  133. package/dist/tsup/mod.d.cts +26 -14
  134. package/dist/tsup/mod.d.ts +26 -14
  135. package/dist/tsup/mod.js +20 -13
  136. package/dist/tsup/serve-test-suite/mod.cjs +1165 -83
  137. package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
  138. package/dist/tsup/serve-test-suite/mod.js +1114 -29
  139. package/dist/tsup/serve-test-suite/mod.js.map +1 -1
  140. package/dist/tsup/test/mod.cjs +84 -11
  141. package/dist/tsup/test/mod.cjs.map +1 -1
  142. package/dist/tsup/test/mod.d.cts +10 -5
  143. package/dist/tsup/test/mod.d.ts +10 -5
  144. package/dist/tsup/test/mod.js +85 -11
  145. package/dist/tsup/test/mod.js.map +1 -1
  146. package/dist/tsup/utils.cjs +10 -4
  147. package/dist/tsup/utils.cjs.map +1 -1
  148. package/dist/tsup/utils.d.cts +72 -2
  149. package/dist/tsup/utils.d.ts +72 -2
  150. package/dist/tsup/utils.js +9 -2
  151. package/dist/tsup/v3-DnYObHH3.d.cts +279 -0
  152. package/dist/tsup/v3-DnYObHH3.d.ts +279 -0
  153. package/dist/tsup/workflow/mod.cjs +16 -0
  154. package/dist/tsup/workflow/mod.cjs.map +1 -0
  155. package/dist/tsup/workflow/mod.d.cts +83 -0
  156. package/dist/tsup/workflow/mod.d.ts +83 -0
  157. package/dist/tsup/workflow/mod.js +16 -0
  158. package/dist/tsup/workflow/mod.js.map +1 -0
  159. package/package.json +62 -5
  160. package/src/actor/config.ts +478 -68
  161. package/src/actor/conn/mod.ts +68 -16
  162. package/src/actor/conn/state-manager.ts +2 -2
  163. package/src/actor/contexts/action.ts +20 -12
  164. package/src/actor/contexts/base/actor.ts +137 -7
  165. package/src/actor/contexts/base/conn-init.ts +27 -7
  166. package/src/actor/contexts/base/conn.ts +27 -18
  167. package/src/actor/contexts/before-action-response.ts +9 -2
  168. package/src/actor/contexts/before-connect.ts +7 -2
  169. package/src/actor/contexts/connect.ts +9 -2
  170. package/src/actor/contexts/create-conn-state.ts +7 -2
  171. package/src/actor/contexts/create-vars.ts +16 -3
  172. package/src/actor/contexts/create.ts +16 -3
  173. package/src/actor/contexts/destroy.ts +9 -3
  174. package/src/actor/contexts/disconnect.ts +10 -4
  175. package/src/actor/contexts/index.ts +4 -3
  176. package/src/actor/contexts/request.ts +23 -6
  177. package/src/actor/contexts/run.ts +47 -0
  178. package/src/actor/contexts/sleep.ts +9 -3
  179. package/src/actor/contexts/state-change.ts +9 -3
  180. package/src/actor/contexts/wake.ts +9 -3
  181. package/src/actor/contexts/websocket.ts +23 -6
  182. package/src/actor/database.ts +8 -18
  183. package/src/actor/definition.ts +20 -6
  184. package/src/actor/driver.ts +32 -3
  185. package/src/actor/errors.ts +127 -0
  186. package/src/actor/instance/connection-manager.ts +183 -80
  187. package/src/actor/instance/event-manager.ts +26 -15
  188. package/src/actor/instance/keys.ts +117 -0
  189. package/src/actor/instance/mod.ts +784 -174
  190. package/src/actor/instance/queue-manager.ts +603 -0
  191. package/src/actor/instance/queue.ts +287 -0
  192. package/src/actor/instance/schedule-manager.ts +49 -7
  193. package/src/actor/instance/state-manager.ts +35 -11
  194. package/src/actor/instance/traces-driver.ts +128 -0
  195. package/src/actor/mod.ts +26 -2
  196. package/src/actor/protocol/old.ts +28 -13
  197. package/src/actor/protocol/serde.ts +1 -1
  198. package/src/actor/router-endpoints.ts +177 -21
  199. package/src/actor/router-websocket-endpoints.ts +18 -29
  200. package/src/actor/router.ts +177 -0
  201. package/src/actor/schema.ts +291 -0
  202. package/src/actor/utils.ts +40 -0
  203. package/src/client/actor-common.ts +1 -1
  204. package/src/client/actor-conn.ts +100 -33
  205. package/src/client/actor-handle.ts +61 -33
  206. package/src/client/client.ts +2 -4
  207. package/src/client/config.ts +1 -1
  208. package/src/client/mod.browser.ts +2 -0
  209. package/src/client/mod.ts +1 -4
  210. package/src/client/queue.ts +146 -0
  211. package/src/client/utils.ts +1 -1
  212. package/src/common/log.ts +1 -1
  213. package/src/common/utils.ts +3 -3
  214. package/src/db/config.ts +100 -0
  215. package/src/db/drizzle/mod.ts +226 -0
  216. package/src/db/drizzle/sqlite-core.ts +22 -0
  217. package/src/db/mod.ts +125 -0
  218. package/src/db/shared.ts +92 -0
  219. package/src/db/sqlite-vfs.ts +12 -0
  220. package/src/driver-helpers/mod.ts +1 -0
  221. package/src/driver-test-suite/mod.ts +69 -43
  222. package/src/driver-test-suite/tests/access-control.ts +218 -0
  223. package/src/driver-test-suite/tests/actor-db-raw.ts +73 -0
  224. package/src/driver-test-suite/tests/actor-db.ts +394 -0
  225. package/src/driver-test-suite/tests/actor-inspector.ts +259 -358
  226. package/src/driver-test-suite/tests/actor-kv.ts +41 -20
  227. package/src/driver-test-suite/tests/actor-queue.ts +324 -0
  228. package/src/driver-test-suite/tests/actor-run.ts +181 -0
  229. package/src/driver-test-suite/tests/actor-schedule.ts +5 -2
  230. package/src/driver-test-suite/tests/actor-sleep.ts +3 -3
  231. package/src/driver-test-suite/tests/actor-stateless.ts +70 -0
  232. package/src/driver-test-suite/tests/actor-workflow.ts +108 -0
  233. package/src/driver-test-suite/tests/manager-driver.ts +11 -0
  234. package/src/driver-test-suite/tests/raw-http-request-properties.ts +1 -1
  235. package/src/driver-test-suite/tests/raw-websocket.ts +12 -12
  236. package/src/drivers/default.ts +7 -2
  237. package/src/drivers/engine/actor-driver.ts +45 -37
  238. package/src/drivers/engine/config.ts +1 -1
  239. package/src/drivers/file-system/actor.ts +20 -2
  240. package/src/drivers/file-system/global-state.ts +569 -258
  241. package/src/drivers/file-system/kv-limits.ts +70 -0
  242. package/src/drivers/file-system/manager.ts +22 -6
  243. package/src/drivers/file-system/mod.ts +39 -16
  244. package/src/drivers/file-system/sqlite-runtime.ts +210 -0
  245. package/src/inspector/actor-inspector.ts +224 -102
  246. package/src/inspector/config.ts +1 -1
  247. package/src/inspector/handler.ts +102 -20
  248. package/src/inspector/mod.browser.ts +8 -0
  249. package/src/inspector/mod.ts +2 -0
  250. package/src/inspector/serve-ui.ts +40 -0
  251. package/src/inspector/transport.ts +18 -0
  252. package/src/inspector/utils.ts +5 -39
  253. package/src/manager/gateway.ts +1 -1
  254. package/src/manager/protocol/mod.ts +1 -1
  255. package/src/manager/protocol/query.ts +1 -1
  256. package/src/manager/router-schema.ts +1 -1
  257. package/src/manager/router.ts +38 -12
  258. package/src/manager-api/actors.ts +1 -1
  259. package/src/manager-api/common.ts +1 -1
  260. package/src/registry/config/driver.ts +1 -1
  261. package/src/registry/config/index.ts +212 -43
  262. package/src/registry/config/legacy-runner.ts +1 -1
  263. package/src/registry/config/runner.ts +1 -1
  264. package/src/registry/config/serverless.ts +1 -1
  265. package/src/registry/index.ts +7 -5
  266. package/src/remote-manager-driver/api-utils.ts +1 -1
  267. package/src/schemas/actor-inspector/mod.ts +1 -1
  268. package/src/schemas/actor-inspector/versioned.ts +195 -8
  269. package/src/schemas/actor-persist/versioned.ts +87 -7
  270. package/src/schemas/client-protocol/mod.ts +1 -1
  271. package/src/schemas/client-protocol/versioned.ts +127 -11
  272. package/src/schemas/client-protocol-zod/mod.ts +16 -1
  273. package/src/schemas/persist/mod.ts +1 -0
  274. package/src/schemas/transport/mod.ts +1 -0
  275. package/src/serde.ts +1 -1
  276. package/src/serve-test-suite/mod.ts +10 -9
  277. package/src/test/mod.ts +15 -56
  278. package/src/utils/endpoint-parser.test.ts +1 -1
  279. package/src/utils/endpoint-parser.ts +1 -1
  280. package/src/utils/env-vars.ts +12 -1
  281. package/src/utils/node.ts +15 -2
  282. package/src/utils.test.ts +34 -0
  283. package/src/utils.ts +140 -6
  284. package/src/workflow/constants.ts +2 -0
  285. package/src/workflow/context.ts +532 -0
  286. package/src/workflow/driver.ts +191 -0
  287. package/src/workflow/inspector.ts +268 -0
  288. package/src/workflow/mod.ts +122 -0
  289. package/dist/tsup/chunk-2IJTYN6K.cjs +0 -278
  290. package/dist/tsup/chunk-2IJTYN6K.cjs.map +0 -1
  291. package/dist/tsup/chunk-2XQS746M.cjs.map +0 -1
  292. package/dist/tsup/chunk-3VP5CSHV.cjs +0 -114
  293. package/dist/tsup/chunk-3VP5CSHV.cjs.map +0 -1
  294. package/dist/tsup/chunk-AQFSQMBG.js +0 -114
  295. package/dist/tsup/chunk-AQFSQMBG.js.map +0 -1
  296. package/dist/tsup/chunk-E6ZE2YEA.js +0 -664
  297. package/dist/tsup/chunk-E6ZE2YEA.js.map +0 -1
  298. package/dist/tsup/chunk-FJ3KTN4V.js.map +0 -1
  299. package/dist/tsup/chunk-GBENOENJ.cjs +0 -8
  300. package/dist/tsup/chunk-GBENOENJ.cjs.map +0 -1
  301. package/dist/tsup/chunk-GD7UXGOE.cjs +0 -4762
  302. package/dist/tsup/chunk-GD7UXGOE.cjs.map +0 -1
  303. package/dist/tsup/chunk-GMAVRZSF.js.map +0 -1
  304. package/dist/tsup/chunk-H4TB4X25.cjs.map +0 -1
  305. package/dist/tsup/chunk-JDAD2YFA.js.map +0 -1
  306. package/dist/tsup/chunk-KCOVZOPS.js +0 -1946
  307. package/dist/tsup/chunk-KCOVZOPS.js.map +0 -1
  308. package/dist/tsup/chunk-KDFWJKMJ.cjs +0 -664
  309. package/dist/tsup/chunk-KDFWJKMJ.cjs.map +0 -1
  310. package/dist/tsup/chunk-LFVF5SCU.js.map +0 -1
  311. package/dist/tsup/chunk-Q6W7RJJP.js.map +0 -1
  312. package/dist/tsup/chunk-RUW5CZ5Z.cjs +0 -1949
  313. package/dist/tsup/chunk-RUW5CZ5Z.cjs.map +0 -1
  314. package/dist/tsup/chunk-RZW2DNND.cjs.map +0 -1
  315. package/dist/tsup/chunk-TCOEBUUE.js +0 -278
  316. package/dist/tsup/chunk-TCOEBUUE.js.map +0 -1
  317. package/dist/tsup/chunk-X35U3YNX.cjs.map +0 -1
  318. package/dist/tsup/keys-Chhy4ylv.d.cts +0 -8
  319. package/dist/tsup/keys-Chhy4ylv.d.ts +0 -8
  320. package/dist/tsup/v1-Gq4avTK3.d.cts +0 -240
  321. package/dist/tsup/v1-Gq4avTK3.d.ts +0 -240
  322. /package/dist/tsup/{chunk-XXGJCOL6.js.map → chunk-A6YIZWTK.js.map} +0 -0
@@ -0,0 +1,291 @@
1
+ import type { StandardSchemaV1 } from "@standard-schema/spec";
2
+ import { Unsupported } from "./errors";
3
+
4
+ export type SchemaHookResult = boolean | Promise<boolean>;
5
+
6
+ type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
7
+
8
+ export interface EventTypeToken<T, TContext = any> {
9
+ readonly _eventType?: T;
10
+ readonly canSubscribe?: SchemaHook<TContext>;
11
+ readonly schema?: PrimitiveSchema;
12
+ }
13
+
14
+ export interface QueueTypeToken<
15
+ TMessage,
16
+ TComplete = never,
17
+ TContext = any,
18
+ > {
19
+ readonly _queueMessage?: TMessage;
20
+ readonly _queueComplete?: TComplete;
21
+ readonly canPublish?: SchemaHook<TContext>;
22
+ readonly message?: PrimitiveSchema;
23
+ readonly complete?: PrimitiveSchema;
24
+ }
25
+
26
+ /** @deprecated Use `event<T>()`. */
27
+ export type Type<T> = EventTypeToken<T, any>;
28
+
29
+ interface EventOptions<TContext = any> {
30
+ canSubscribe?: SchemaHook<TContext>;
31
+ schema?: PrimitiveSchema;
32
+ }
33
+
34
+ interface QueueOptions<TContext = any> {
35
+ canPublish?: SchemaHook<TContext>;
36
+ message?: PrimitiveSchema;
37
+ complete?: PrimitiveSchema;
38
+ }
39
+
40
+ export function event<T, TContext = any>(
41
+ options?: EventOptions<TContext>,
42
+ ): EventTypeToken<T, TContext> {
43
+ return (options ?? {}) as EventTypeToken<T, TContext>;
44
+ }
45
+
46
+ export function queue<TMessage, TComplete = never, TContext = any>(
47
+ options?: QueueOptions<TContext>,
48
+ ): QueueTypeToken<
49
+ TMessage,
50
+ TComplete,
51
+ TContext
52
+ > {
53
+ return (options ?? {}) as QueueTypeToken<TMessage, TComplete, TContext>;
54
+ }
55
+
56
+ export type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
57
+
58
+ export interface EventSchemaDefinition<TContext = any> {
59
+ schema: PrimitiveSchema;
60
+ canSubscribe?: SchemaHook<TContext>;
61
+ }
62
+
63
+ export interface QueueSchemaDefinition<TContext = any> {
64
+ message: PrimitiveSchema;
65
+ complete?: PrimitiveSchema;
66
+ canPublish?: SchemaHook<TContext>;
67
+ }
68
+
69
+ export type EventSchema<TContext = any> =
70
+ | PrimitiveSchema
71
+ | EventSchemaDefinition<TContext>;
72
+ export type QueueSchema =
73
+ | PrimitiveSchema
74
+ | QueueSchemaDefinition<any>
75
+ | QueueTypeToken<unknown, unknown, any>;
76
+ export type EventSchemaConfig<TContext = any> = Record<
77
+ string,
78
+ EventSchema<TContext>
79
+ >;
80
+ export type QueueSchemaConfig<TContext = any> = Record<string, QueueSchema>;
81
+ export type AnySchemaConfig = EventSchemaConfig | QueueSchemaConfig;
82
+
83
+ /** @deprecated Use `EventSchema` or `QueueSchema`. */
84
+ export type Schema = QueueSchema;
85
+ /** @deprecated Use `EventSchemaConfig` or `QueueSchemaConfig`. */
86
+ export type SchemaConfig = QueueSchemaConfig;
87
+
88
+ export type InferSchema<T> =
89
+ T extends QueueSchemaDefinition<any>
90
+ ? InferSchema<T["message"]>
91
+ : T extends QueueTypeToken<infer M, unknown, any>
92
+ ? M
93
+ : T extends EventSchemaDefinition<any>
94
+ ? InferSchema<T["schema"]>
95
+ : T extends StandardSchemaV1<any, infer O>
96
+ ? O
97
+ : T extends EventTypeToken<infer R, any>
98
+ ? R
99
+ : never;
100
+
101
+ export type InferSchemaMap<T extends Record<string, unknown>> = {
102
+ [K in keyof T]: InferSchema<T[K]>;
103
+ };
104
+
105
+ export type InferQueueComplete<T> =
106
+ T extends QueueTypeToken<unknown, infer C, any>
107
+ ? [C] extends [never]
108
+ ? never
109
+ : C
110
+ : T extends QueueSchemaDefinition<any>
111
+ ? T["complete"] extends PrimitiveSchema
112
+ ? InferSchema<T["complete"]>
113
+ : never
114
+ : never;
115
+
116
+ export type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
117
+ [K in keyof T]: InferQueueComplete<T[K]>;
118
+ };
119
+
120
+ export type InferEventArgs<T> = T extends readonly unknown[]
121
+ ? number extends T["length"]
122
+ ? [T]
123
+ : T
124
+ : [T];
125
+
126
+ export type ValidationResult<T> =
127
+ | { success: true; data: T }
128
+ | { success: false; issues: unknown[] };
129
+
130
+ export function isStandardSchema(value: unknown): value is StandardSchemaV1 {
131
+ return typeof value === "object" && value !== null && "~standard" in value;
132
+ }
133
+
134
+ export function isQueueSchemaDefinition(
135
+ value: unknown,
136
+ ): value is QueueSchemaDefinition<any> {
137
+ if (isEventSchemaDefinition(value)) {
138
+ return false;
139
+ }
140
+ return (
141
+ typeof value === "object" &&
142
+ value !== null &&
143
+ "message" in value &&
144
+ (value as { message?: unknown }).message !== undefined
145
+ );
146
+ }
147
+
148
+ export function isEventSchemaDefinition(
149
+ value: unknown,
150
+ ): value is EventSchemaDefinition<any> {
151
+ return (
152
+ typeof value === "object" &&
153
+ value !== null &&
154
+ "schema" in value &&
155
+ (value as { schema?: unknown }).schema !== undefined
156
+ );
157
+ }
158
+
159
+ export function hasSchemaConfigKey<T extends AnySchemaConfig>(
160
+ schemas: T | undefined,
161
+ key: string,
162
+ ): boolean {
163
+ if (!schemas) {
164
+ return false;
165
+ }
166
+ return Object.prototype.hasOwnProperty.call(schemas, key);
167
+ }
168
+
169
+ export function getEventCanSubscribe<TContext = any>(
170
+ schemas: EventSchemaConfig<TContext> | undefined,
171
+ key: string,
172
+ ): SchemaHook<TContext> | undefined {
173
+ const schema = schemas?.[key];
174
+ if (!schema || isStandardSchema(schema)) {
175
+ return undefined;
176
+ }
177
+
178
+ const maybeCanSubscribe = (schema as { canSubscribe?: unknown })
179
+ .canSubscribe;
180
+ return typeof maybeCanSubscribe === "function"
181
+ ? (maybeCanSubscribe as SchemaHook<TContext>)
182
+ : undefined;
183
+ }
184
+
185
+ export function getQueueCanPublish<TContext = any>(
186
+ schemas: QueueSchemaConfig | undefined,
187
+ key: string,
188
+ ): SchemaHook<TContext> | undefined {
189
+ const schema = schemas?.[key];
190
+ if (!schema || isStandardSchema(schema)) {
191
+ return undefined;
192
+ }
193
+
194
+ const maybeCanPublish = (schema as { canPublish?: unknown }).canPublish;
195
+ return typeof maybeCanPublish === "function"
196
+ ? (maybeCanPublish as SchemaHook<TContext>)
197
+ : undefined;
198
+ }
199
+
200
+ function getValidationSchema(
201
+ schema: QueueSchema | EventSchema | undefined,
202
+ ): QueueSchema | EventSchema | undefined {
203
+ if (!schema) {
204
+ return undefined;
205
+ }
206
+ if (isEventSchemaDefinition(schema)) {
207
+ return schema.schema;
208
+ }
209
+ if (isQueueSchemaDefinition(schema)) {
210
+ return schema.message;
211
+ }
212
+ if (
213
+ typeof schema === "object" &&
214
+ schema !== null &&
215
+ "schema" in schema &&
216
+ (schema as { schema?: unknown }).schema !== undefined
217
+ ) {
218
+ return (schema as { schema: QueueSchema | EventSchema }).schema;
219
+ }
220
+ if (
221
+ typeof schema === "object" &&
222
+ schema !== null &&
223
+ "message" in schema &&
224
+ (schema as { message?: unknown }).message !== undefined
225
+ ) {
226
+ return (schema as { message: QueueSchema | EventSchema }).message;
227
+ }
228
+ return schema;
229
+ }
230
+
231
+ function isPromiseLike(value: unknown): value is PromiseLike<unknown> {
232
+ return (
233
+ typeof value === "object" &&
234
+ value !== null &&
235
+ "then" in value &&
236
+ typeof (value as { then?: unknown }).then === "function"
237
+ );
238
+ }
239
+
240
+ export async function validateSchema<T extends AnySchemaConfig>(
241
+ schemas: T | undefined,
242
+ key: keyof T & string,
243
+ data: unknown,
244
+ ): Promise<ValidationResult<InferSchemaMap<T>[typeof key]>> {
245
+ const schema = getValidationSchema(schemas?.[key]);
246
+
247
+ if (!schema) {
248
+ return { success: true, data: data as InferSchemaMap<T>[typeof key] };
249
+ }
250
+
251
+ if (isStandardSchema(schema)) {
252
+ const result = await schema["~standard"].validate(data);
253
+ if (result.issues) {
254
+ return { success: false, issues: [...result.issues] };
255
+ }
256
+ return {
257
+ success: true,
258
+ data: result.value as InferSchemaMap<T>[typeof key],
259
+ };
260
+ }
261
+
262
+ return { success: true, data: data as InferSchemaMap<T>[typeof key] };
263
+ }
264
+
265
+ export function validateSchemaSync<T extends AnySchemaConfig>(
266
+ schemas: T | undefined,
267
+ key: keyof T & string,
268
+ data: unknown,
269
+ ): ValidationResult<InferSchemaMap<T>[typeof key]> {
270
+ const schema = getValidationSchema(schemas?.[key]);
271
+
272
+ if (!schema) {
273
+ return { success: true, data: data as InferSchemaMap<T>[typeof key] };
274
+ }
275
+
276
+ if (isStandardSchema(schema)) {
277
+ const result = schema["~standard"].validate(data);
278
+ if (isPromiseLike(result)) {
279
+ throw new Unsupported("async schema validation");
280
+ }
281
+ if (result.issues) {
282
+ return { success: false, issues: [...result.issues] };
283
+ }
284
+ return {
285
+ success: true,
286
+ data: result.value as InferSchemaMap<T>[typeof key],
287
+ };
288
+ }
289
+
290
+ return { success: true, data: data as InferSchemaMap<T>[typeof key] };
291
+ }
@@ -84,6 +84,46 @@ export class Lock<T> {
84
84
  }
85
85
  }
86
86
 
87
+ export interface JoinedAbortSignal {
88
+ signal?: AbortSignal;
89
+ cleanup: () => void;
90
+ }
91
+
92
+ export function joinAbortSignals(
93
+ ...signals: Array<AbortSignal | undefined>
94
+ ): JoinedAbortSignal {
95
+ const activeSignals = signals.filter(
96
+ (signal): signal is AbortSignal => signal !== undefined,
97
+ );
98
+ if (activeSignals.length === 0) {
99
+ return { signal: undefined, cleanup: () => {} };
100
+ }
101
+ if (activeSignals.length === 1) {
102
+ return { signal: activeSignals[0], cleanup: () => {} };
103
+ }
104
+
105
+ const controller = new AbortController();
106
+ if (activeSignals.some((signal) => signal.aborted)) {
107
+ controller.abort();
108
+ return { signal: controller.signal, cleanup: () => {} };
109
+ }
110
+
111
+ const cleanup = () => {
112
+ for (const signal of activeSignals) {
113
+ signal.removeEventListener("abort", onAbort);
114
+ }
115
+ };
116
+ const onAbort = () => {
117
+ controller.abort();
118
+ cleanup();
119
+ };
120
+ for (const signal of activeSignals) {
121
+ signal.addEventListener("abort", onAbort, { once: true });
122
+ }
123
+
124
+ return { signal: controller.signal, cleanup };
125
+ }
126
+
87
127
  export function generateSecureToken(length = 32) {
88
128
  const array = new Uint8Array(length);
89
129
  crypto.getRandomValues(array);
@@ -21,7 +21,7 @@ export type ActorActionFunction<
21
21
  */
22
22
  export type ActorDefinitionActions<AD extends AnyActorDefinition> =
23
23
  // biome-ignore lint/suspicious/noExplicitAny: safe to use any here
24
- AD extends ActorDefinition<any, any, any, any, any, any, infer R>
24
+ AD extends ActorDefinition<any, any, any, any, any, any, any, any, infer R>
25
25
  ? {
26
26
  [K in keyof R]: R[K] extends (
27
27
  ...args: infer Args
@@ -30,6 +30,13 @@ import { checkForSchedulingError, queryActor } from "./actor-query";
30
30
  import { ACTOR_CONNS_SYMBOL, type ClientRaw } from "./client";
31
31
  import * as errors from "./errors";
32
32
  import { logger } from "./log";
33
+ import {
34
+ createQueueSender,
35
+ type QueueSendNoWaitOptions,
36
+ type QueueSendOptions,
37
+ type QueueSendResult,
38
+ type QueueSendWaitOptions,
39
+ } from "./queue";
33
40
  import {
34
41
  type WebSocketMessage as ConnMessage,
35
42
  messageLength,
@@ -131,10 +138,12 @@ export class ActorConnRaw {
131
138
 
132
139
  #errorHandlers = new Set<ActorErrorCallback>();
133
140
  #openHandlers = new Set<ConnectionStateCallback>();
141
+ #openScheduled = false;
134
142
  #closeHandlers = new Set<ConnectionStateCallback>();
135
143
  #statusChangeHandlers = new Set<StatusChangeCallback>();
136
144
 
137
145
  #actionIdCounter = 0;
146
+ #queueSender: ReturnType<typeof createQueueSender>;
138
147
 
139
148
  /**
140
149
  * Interval that keeps the NodeJS process alive if this is the only thing running.
@@ -175,10 +184,43 @@ export class ActorConnRaw {
175
184
  this.#params = params;
176
185
  this.#encoding = encoding;
177
186
  this.#actorQuery = actorQuery;
187
+ this.#queueSender = createQueueSender({
188
+ encoding: this.#encoding,
189
+ params: this.#params,
190
+ customFetch: async (request: Request) => {
191
+ if (!this.#actorId) {
192
+ const { actorId } = await queryActor(
193
+ undefined,
194
+ this.#actorQuery,
195
+ this.#driver,
196
+ );
197
+ this.#actorId = actorId;
198
+ }
199
+ return this.#driver.sendRequest(this.#actorId, request);
200
+ },
201
+ });
178
202
 
179
203
  this.#keepNodeAliveInterval = setInterval(() => 60_000);
180
204
  }
181
205
 
206
+ send(
207
+ name: string,
208
+ body: unknown,
209
+ options: QueueSendWaitOptions,
210
+ ): Promise<QueueSendResult>;
211
+ send(
212
+ name: string,
213
+ body: unknown,
214
+ options?: QueueSendNoWaitOptions,
215
+ ): Promise<void>;
216
+ send(
217
+ name: string,
218
+ body: unknown,
219
+ options?: QueueSendOptions,
220
+ ): Promise<QueueSendResult | void> {
221
+ return this.#queueSender.send(name, body, options as any);
222
+ }
223
+
182
224
  /**
183
225
  * Call a raw action connection. See {@link ActorConn} for type-safe action calls.
184
226
  *
@@ -206,7 +248,7 @@ export class ActorConnRaw {
206
248
  const { promise, resolve, reject } = promiseWithResolvers<{
207
249
  id: bigint;
208
250
  output: unknown;
209
- }>();
251
+ }>((reason) => logger().warn({ msg: "unhandled action promise rejection", reason }));
210
252
  this.#actionsInFlight.set(actionId, {
211
253
  name: opts.name,
212
254
  resolve,
@@ -243,7 +285,6 @@ export class ActorConnRaw {
243
285
 
244
286
  /**
245
287
  * Do not call this directly.
246
- enc
247
288
  * Establishes a connection to the server using the specified endpoint & encoding & driver.
248
289
  *
249
290
  * @protected
@@ -338,7 +379,7 @@ enc
338
379
  // Create promise for open
339
380
  if (this.#onOpenPromise)
340
381
  throw new Error("#onOpenPromise already defined");
341
- this.#onOpenPromise = promiseWithResolvers();
382
+ this.#onOpenPromise = promiseWithResolvers((reason) => logger().warn({ msg: "unhandled open promise rejection", reason }));
342
383
 
343
384
  await this.#connectWebSocket();
344
385
 
@@ -424,39 +465,58 @@ enc
424
465
  return;
425
466
  }
426
467
 
427
- logger().debug({
428
- msg: "socket open",
429
- messageQueueLength: this.#messageQueue.length,
430
- connId: this.#connId,
431
- });
468
+ if (this.#connStatus === "connected" || this.#openScheduled) {
469
+ return;
470
+ }
471
+ this.#openScheduled = true;
472
+
473
+ queueMicrotask(() => {
474
+ this.#openScheduled = false;
475
+ if (this.#disposed) {
476
+ logger().debug({
477
+ msg: "handleOnOpen scheduled after dispose, closing websocket",
478
+ });
479
+ if (this.#websocket) {
480
+ this.#websocket.close(1000, "Disposed");
481
+ this.#websocket = undefined;
482
+ }
483
+ return;
484
+ }
432
485
 
433
- // Update connection state (this also notifies handlers)
434
- this.#setConnStatus("connected");
486
+ logger().debug({
487
+ msg: "socket open",
488
+ messageQueueLength: this.#messageQueue.length,
489
+ connId: this.#connId,
490
+ });
435
491
 
436
- // Resolve open promise
437
- if (this.#onOpenPromise) {
438
- this.#onOpenPromise.resolve(undefined);
439
- } else {
440
- logger().warn({ msg: "#onOpenPromise is undefined" });
441
- }
492
+ // Update connection state (this also notifies handlers)
493
+ this.#setConnStatus("connected");
442
494
 
443
- // Resubscribe to all active events
444
- for (const eventName of this.#eventSubscriptions.keys()) {
445
- this.#sendSubscription(eventName, true);
446
- }
495
+ // Resolve open promise
496
+ if (this.#onOpenPromise) {
497
+ this.#onOpenPromise.resolve(undefined);
498
+ } else {
499
+ logger().warn({ msg: "#onOpenPromise is undefined" });
500
+ }
447
501
 
448
- // Flush queue
449
- //
450
- // If the message fails to send, the message will be re-queued
451
- const queue = this.#messageQueue;
452
- this.#messageQueue = [];
453
- logger().debug({
454
- msg: "flushing message queue",
455
- queueLength: queue.length,
502
+ // Resubscribe to all active events
503
+ for (const eventName of this.#eventSubscriptions.keys()) {
504
+ this.#sendSubscription(eventName, true);
505
+ }
506
+
507
+ // Flush queue
508
+ //
509
+ // If the message fails to send, the message will be re-queued
510
+ const queue = this.#messageQueue;
511
+ this.#messageQueue = [];
512
+ logger().debug({
513
+ msg: "flushing message queue",
514
+ queueLength: queue.length,
515
+ });
516
+ for (const msg of queue) {
517
+ this.#sendMessage(msg);
518
+ }
456
519
  });
457
- for (const msg of queue) {
458
- this.#sendMessage(msg);
459
- }
460
520
  }
461
521
 
462
522
  /** Called by the onmessage event from drivers. */
@@ -939,7 +999,14 @@ enc
939
999
  messageType: (message.body as any).tag,
940
1000
  actionName: (message.body as any).val?.name,
941
1001
  });
942
- if (readyState === 1) {
1002
+ if (this.#connStatus !== "connected") {
1003
+ logger().debug({
1004
+ msg: "websocket init pending, queueing message",
1005
+ connStatus: this.#connStatus,
1006
+ messageType: (message.body as any).tag,
1007
+ });
1008
+ queueMessage = true;
1009
+ } else if (readyState === 1) {
943
1010
  try {
944
1011
  const messageSerialized = serializeWithEncoding(
945
1012
  this.#encoding,
@@ -1149,7 +1216,7 @@ enc
1149
1216
  ws.readyState !== 2 /* CLOSING */ &&
1150
1217
  ws.readyState !== 3 /* CLOSED */
1151
1218
  ) {
1152
- const { promise, resolve } = promiseWithResolvers();
1219
+ const { promise, resolve } = promiseWithResolvers((reason) => logger().warn({ msg: "unhandled websocket close promise rejection", reason }));
1153
1220
  ws.addEventListener("close", () => resolve(undefined));
1154
1221
  ws.close(1000, "Disposed");
1155
1222
  await promise;
@@ -29,6 +29,13 @@ import { checkForSchedulingError, queryActor } from "./actor-query";
29
29
  import { type ClientRaw, CREATE_ACTOR_CONN_PROXY } from "./client";
30
30
  import { ActorError, isSchedulingError } from "./errors";
31
31
  import { logger } from "./log";
32
+ import {
33
+ createQueueSender,
34
+ type QueueSendNoWaitOptions,
35
+ type QueueSendOptions,
36
+ type QueueSendResult,
37
+ type QueueSendWaitOptions,
38
+ } from "./queue";
32
39
  import { rawHttpFetch, rawWebSocket } from "./raw-utils";
33
40
  import { sendHttpRequest } from "./utils";
34
41
 
@@ -44,6 +51,7 @@ export class ActorHandleRaw {
44
51
  #encoding: Encoding;
45
52
  #actorQuery: ActorQuery;
46
53
  #params: unknown;
54
+ #queueSender: ReturnType<typeof createQueueSender>;
47
55
 
48
56
  /**
49
57
  * Do not call this directly.
@@ -64,6 +72,36 @@ export class ActorHandleRaw {
64
72
  this.#encoding = encoding;
65
73
  this.#actorQuery = actorQuery;
66
74
  this.#params = params;
75
+ this.#queueSender = createQueueSender({
76
+ encoding: this.#encoding,
77
+ params: this.#params,
78
+ customFetch: async (request: Request) => {
79
+ const { actorId } = await queryActor(
80
+ undefined,
81
+ this.#actorQuery,
82
+ this.#driver,
83
+ );
84
+ return this.#driver.sendRequest(actorId, request);
85
+ },
86
+ });
87
+ }
88
+
89
+ send(
90
+ name: string,
91
+ body: unknown,
92
+ options: QueueSendWaitOptions,
93
+ ): Promise<QueueSendResult>;
94
+ send(
95
+ name: string,
96
+ body: unknown,
97
+ options?: QueueSendNoWaitOptions,
98
+ ): Promise<void>;
99
+ send(
100
+ name: string,
101
+ body: unknown,
102
+ options?: QueueSendOptions,
103
+ ): Promise<QueueSendResult | void> {
104
+ return this.#queueSender.send(name, body, options as any);
67
105
  }
68
106
 
69
107
  /**
@@ -199,16 +237,10 @@ export class ActorHandleRaw {
199
237
  }
200
238
 
201
239
  /**
202
- * Makes a raw HTTP request to the actor.
203
- *
204
- * @param input - The URL, path, or Request object
205
- * @param init - Standard fetch RequestInit options
206
- * @returns Promise<Response> - The raw HTTP response
240
+ * Fetches a resource from this actor via the /request endpoint. This is a
241
+ * convenience wrapper around the raw HTTP API.
207
242
  */
208
- async fetch(
209
- input: string | URL | Request,
210
- init?: RequestInit,
211
- ): Promise<Response> {
243
+ fetch(input: string | URL | Request, init?: RequestInit) {
212
244
  return rawHttpFetch(
213
245
  this.#driver,
214
246
  this.#actorQuery,
@@ -219,16 +251,9 @@ export class ActorHandleRaw {
219
251
  }
220
252
 
221
253
  /**
222
- * Creates a raw WebSocket connection to the actor.
223
- *
224
- * @param path - The path for the WebSocket connection (e.g., "stream")
225
- * @param protocols - Optional WebSocket subprotocols
226
- * @returns WebSocket - A raw WebSocket connection
254
+ * Opens a raw WebSocket connection to this actor.
227
255
  */
228
- async websocket(
229
- path?: string,
230
- protocols?: string | string[],
231
- ): Promise<WebSocket> {
256
+ webSocket(path?: string, protocols?: string | string[]) {
232
257
  return rawWebSocket(
233
258
  this.#driver,
234
259
  this.#actorQuery,
@@ -241,21 +266,24 @@ export class ActorHandleRaw {
241
266
  /**
242
267
  * Resolves the actor to get its unique actor ID.
243
268
  */
244
- async resolve({ signal }: { signal?: AbortSignal } = {}): Promise<string> {
245
- if (
246
- "getForKey" in this.#actorQuery ||
247
- "getOrCreateForKey" in this.#actorQuery
248
- ) {
249
- // TODO:
250
- let name: string;
251
- if ("getForKey" in this.#actorQuery) {
252
- name = this.#actorQuery.getForKey.name;
253
- } else if ("getOrCreateForKey" in this.#actorQuery) {
254
- name = this.#actorQuery.getOrCreateForKey.name;
255
- } else {
256
- assertUnreachable(this.#actorQuery);
257
- }
269
+ async resolve(): Promise<string> {
270
+ if ("getForKey" in this.#actorQuery) {
271
+ const name = this.#actorQuery.getForKey.name;
272
+
273
+ // Query the actor to get the id
274
+ const { actorId } = await queryActor(
275
+ undefined,
276
+ this.#actorQuery,
277
+ this.#driver,
278
+ );
279
+
280
+ this.#actorQuery = { getForId: { actorId, name } };
281
+
282
+ return actorId;
283
+ } else if ("getOrCreateForKey" in this.#actorQuery) {
284
+ const name = this.#actorQuery.getOrCreateForKey.name;
258
285
 
286
+ // Query the actor to get or create and get the id
259
287
  const { actorId } = await queryActor(
260
288
  undefined,
261
289
  this.#actorQuery,
@@ -266,7 +294,7 @@ export class ActorHandleRaw {
266
294
 
267
295
  return actorId;
268
296
  } else if ("getForId" in this.#actorQuery) {
269
- // SKip since it's already resolved
297
+ // Skip since it's already resolved
270
298
  return this.#actorQuery.getForId.actorId;
271
299
  } else if ("create" in this.#actorQuery) {
272
300
  // Cannot create a handle with this query