rivetkit 0.0.0-active-actors-fix-active-count.253e406 → 0.0.0-bisect-sync-sqlite-1.910d1c7

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 (303) hide show
  1. package/dist/browser/client.d.ts +1286 -89
  2. package/dist/browser/client.js +1699 -704
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.d.ts +252 -129
  5. package/dist/browser/inspector/client.js +2083 -236
  6. package/dist/browser/inspector/client.js.map +1 -1
  7. package/dist/tsup/actor/errors.cjs +8 -2
  8. package/dist/tsup/actor/errors.cjs.map +1 -1
  9. package/dist/tsup/actor/errors.d.cts +1 -1
  10. package/dist/tsup/actor/errors.d.ts +1 -1
  11. package/dist/tsup/actor/errors.js +7 -1
  12. package/dist/tsup/agent-os/index.cjs +3 -2289
  13. package/dist/tsup/agent-os/index.cjs.map +1 -1
  14. package/dist/tsup/agent-os/index.d.cts +1 -1813
  15. package/dist/tsup/agent-os/index.d.ts +1 -1813
  16. package/dist/tsup/agent-os/index.js +3 -2289
  17. package/dist/tsup/agent-os/index.js.map +1 -1
  18. package/dist/tsup/chunk-2JJU7IQ7.cjs +14 -0
  19. package/dist/tsup/chunk-2JJU7IQ7.cjs.map +1 -0
  20. package/dist/tsup/{chunk-DZJZLZ4R.js → chunk-2MXBZGUP.js} +2 -2
  21. package/dist/tsup/{chunk-L4FVS7GY.js → chunk-47IS5ZFI.js} +6 -6
  22. package/dist/tsup/chunk-47IS5ZFI.js.map +1 -0
  23. package/dist/tsup/{chunk-DXWOGCZY.js → chunk-5XWY5CBA.js} +70 -8
  24. package/dist/tsup/chunk-5XWY5CBA.js.map +1 -0
  25. package/dist/tsup/{chunk-OQEEZDIK.cjs → chunk-6XVNZKKP.cjs} +506 -31
  26. package/dist/tsup/chunk-6XVNZKKP.cjs.map +1 -0
  27. package/dist/tsup/{chunk-3YY5S6TV.js → chunk-A2CF6PFH.js} +20 -12
  28. package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
  29. package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-AQJFKHBK.cjs} +276 -27
  30. package/dist/tsup/chunk-AQJFKHBK.cjs.map +1 -0
  31. package/dist/tsup/chunk-DPWLASMC.cjs +244 -0
  32. package/dist/tsup/chunk-DPWLASMC.cjs.map +1 -0
  33. package/dist/tsup/{chunk-VUF2YEF4.cjs → chunk-DYJOU3MF.cjs} +10 -10
  34. package/dist/tsup/chunk-DYJOU3MF.cjs.map +1 -0
  35. package/dist/tsup/{chunk-7WXCRV25.cjs → chunk-ELZ6MT3V.cjs} +18 -11
  36. package/dist/tsup/chunk-ELZ6MT3V.cjs.map +1 -0
  37. package/dist/tsup/chunk-HYIVSH5X.js +244 -0
  38. package/dist/tsup/chunk-HYIVSH5X.js.map +1 -0
  39. package/dist/tsup/{chunk-T6YVRM4K.js → chunk-IHEO5OT3.js} +275 -26
  40. package/dist/tsup/chunk-IHEO5OT3.js.map +1 -0
  41. package/dist/tsup/chunk-IWACVNN5.js +14 -0
  42. package/dist/tsup/chunk-IWACVNN5.js.map +1 -0
  43. package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JTHHCZCZ.js} +24 -1
  44. package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
  45. package/dist/tsup/{chunk-V4JUWAT6.js → chunk-K3AJOPSF.js} +498 -23
  46. package/dist/tsup/chunk-K3AJOPSF.js.map +1 -0
  47. package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-KVFIONKQ.cjs} +25 -2
  48. package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
  49. package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-MGI2VVF6.cjs} +45 -9
  50. package/dist/tsup/chunk-MGI2VVF6.cjs.map +1 -0
  51. package/dist/tsup/{chunk-QNLGOTQP.js → chunk-NPHTIUUJ.js} +1291 -420
  52. package/dist/tsup/chunk-NPHTIUUJ.js.map +1 -0
  53. package/dist/tsup/{chunk-7GKQJFSB.cjs → chunk-POCSZXPQ.cjs} +72 -10
  54. package/dist/tsup/chunk-POCSZXPQ.cjs.map +1 -0
  55. package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-RTWH3AX3.cjs} +19 -11
  56. package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
  57. package/dist/tsup/{chunk-ARRBQTAR.cjs → chunk-X76BM5JS.cjs} +1420 -549
  58. package/dist/tsup/chunk-X76BM5JS.cjs.map +1 -0
  59. package/dist/tsup/{chunk-AGBP757I.js → chunk-X7SYKFPM.js} +16 -9
  60. package/dist/tsup/chunk-X7SYKFPM.js.map +1 -0
  61. package/dist/tsup/{chunk-GKAMEBTZ.cjs → chunk-XLDJSZ3B.cjs} +3 -3
  62. package/dist/tsup/{chunk-GKAMEBTZ.cjs.map → chunk-XLDJSZ3B.cjs.map} +1 -1
  63. package/dist/tsup/{chunk-KIWH5H3K.js → chunk-ZOVJDAOW.js} +44 -8
  64. package/dist/tsup/chunk-ZOVJDAOW.js.map +1 -0
  65. package/dist/tsup/client/mod.cjs +8 -9
  66. package/dist/tsup/client/mod.cjs.map +1 -1
  67. package/dist/tsup/client/mod.d.cts +33 -7
  68. package/dist/tsup/client/mod.d.ts +33 -7
  69. package/dist/tsup/client/mod.js +7 -8
  70. package/dist/tsup/common/log.cjs +5 -3
  71. package/dist/tsup/common/log.cjs.map +1 -1
  72. package/dist/tsup/common/log.d.cts +5 -1
  73. package/dist/tsup/common/log.d.ts +5 -1
  74. package/dist/tsup/common/log.js +6 -4
  75. package/dist/tsup/common/websocket.cjs +4 -4
  76. package/dist/tsup/common/websocket.js +3 -3
  77. package/dist/tsup/{config-nlTlOKaE.d.cts → config-BMGUEKMZ.d.cts} +1252 -75
  78. package/dist/tsup/config-CBTr4IhE.d.cts +224 -0
  79. package/dist/tsup/config-CBTr4IhE.d.ts +224 -0
  80. package/dist/tsup/{config-D7ykAntK.d.ts → config-iBpXyITj.d.ts} +1252 -75
  81. package/dist/tsup/context-hyVakgnU.d.ts +136 -0
  82. package/dist/tsup/context-qfvLuF0P.d.cts +136 -0
  83. package/dist/tsup/db/drizzle.cjs +127 -67
  84. package/dist/tsup/db/drizzle.cjs.map +1 -1
  85. package/dist/tsup/db/drizzle.d.cts +8 -4
  86. package/dist/tsup/db/drizzle.d.ts +8 -4
  87. package/dist/tsup/db/drizzle.js +127 -67
  88. package/dist/tsup/db/drizzle.js.map +1 -1
  89. package/dist/tsup/db/mod.cjs +6 -124
  90. package/dist/tsup/db/mod.cjs.map +1 -1
  91. package/dist/tsup/db/mod.d.cts +12 -4
  92. package/dist/tsup/db/mod.d.ts +12 -4
  93. package/dist/tsup/db/mod.js +5 -123
  94. package/dist/tsup/db/mod.js.map +1 -1
  95. package/dist/tsup/dynamic/mod.cjs +24 -0
  96. package/dist/tsup/dynamic/mod.cjs.map +1 -0
  97. package/dist/tsup/dynamic/mod.d.cts +39 -0
  98. package/dist/tsup/dynamic/mod.d.ts +39 -0
  99. package/dist/tsup/dynamic/mod.js +24 -0
  100. package/dist/tsup/dynamic/mod.js.map +1 -0
  101. package/dist/tsup/inspector/mod.cjs +47 -12
  102. package/dist/tsup/inspector/mod.cjs.map +1 -1
  103. package/dist/tsup/inspector/mod.d.cts +26 -136
  104. package/dist/tsup/inspector/mod.d.ts +26 -136
  105. package/dist/tsup/inspector/mod.js +46 -11
  106. package/dist/tsup/inspector/mod.js.map +1 -1
  107. package/dist/tsup/inspector/workflow.cjs +21 -0
  108. package/dist/tsup/inspector/workflow.cjs.map +1 -0
  109. package/dist/tsup/inspector/workflow.d.cts +144 -0
  110. package/dist/tsup/inspector/workflow.d.ts +144 -0
  111. package/dist/tsup/inspector/workflow.js +21 -0
  112. package/dist/tsup/inspector/workflow.js.map +1 -0
  113. package/dist/tsup/inspector-tab/mod.cjs +162 -0
  114. package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
  115. package/dist/tsup/inspector-tab/mod.d.cts +242 -0
  116. package/dist/tsup/inspector-tab/mod.d.ts +242 -0
  117. package/dist/tsup/inspector-tab/mod.js +162 -0
  118. package/dist/tsup/inspector-tab/mod.js.map +1 -0
  119. package/dist/tsup/mod.cjs +3527 -753
  120. package/dist/tsup/mod.cjs.map +1 -1
  121. package/dist/tsup/mod.d.cts +11 -7
  122. package/dist/tsup/mod.d.ts +11 -7
  123. package/dist/tsup/mod.js +3468 -694
  124. package/dist/tsup/mod.js.map +1 -1
  125. package/dist/tsup/test/mod.cjs +26 -21
  126. package/dist/tsup/test/mod.cjs.map +1 -1
  127. package/dist/tsup/test/mod.d.cts +7 -5
  128. package/dist/tsup/test/mod.d.ts +7 -5
  129. package/dist/tsup/test/mod.js +25 -20
  130. package/dist/tsup/test/mod.js.map +1 -1
  131. package/dist/tsup/unstable/migrations.cjs +101 -0
  132. package/dist/tsup/unstable/migrations.cjs.map +1 -0
  133. package/dist/tsup/unstable/migrations.d.cts +29 -0
  134. package/dist/tsup/unstable/migrations.d.ts +29 -0
  135. package/dist/tsup/unstable/migrations.js +101 -0
  136. package/dist/tsup/unstable/migrations.js.map +1 -0
  137. package/dist/tsup/{utils-DVekpm4I.d.ts → utils-3rsE0JvI.d.cts} +26 -2
  138. package/dist/tsup/{utils-DVekpm4I.d.cts → utils-3rsE0JvI.d.ts} +26 -2
  139. package/dist/tsup/utils-C1O-SklO.d.ts +162 -0
  140. package/dist/tsup/utils-C6b0aYUM.d.cts +162 -0
  141. package/dist/tsup/utils.cjs +7 -3
  142. package/dist/tsup/utils.cjs.map +1 -1
  143. package/dist/tsup/utils.d.cts +4 -147
  144. package/dist/tsup/utils.d.ts +4 -147
  145. package/dist/tsup/utils.js +6 -2
  146. package/dist/tsup/workflow/mod.cjs +557 -410
  147. package/dist/tsup/workflow/mod.cjs.map +1 -1
  148. package/dist/tsup/workflow/mod.d.cts +11 -9
  149. package/dist/tsup/workflow/mod.d.ts +11 -9
  150. package/dist/tsup/workflow/mod.js +551 -404
  151. package/dist/tsup/workflow/mod.js.map +1 -1
  152. package/package.json +67 -18
  153. package/src/actor/actions.ts +155 -0
  154. package/src/actor/config.ts +679 -101
  155. package/src/actor/contexts/index.ts +9 -2
  156. package/src/actor/definition.ts +75 -26
  157. package/src/actor/errors.ts +107 -8
  158. package/src/actor/keys.ts +87 -1
  159. package/src/actor/mod.ts +36 -20
  160. package/src/actor/schema.ts +6 -2
  161. package/src/actor/tracing.ts +28 -0
  162. package/src/agent-os/index.ts +5 -64
  163. package/src/client/actor-common.ts +84 -54
  164. package/src/client/actor-conn.ts +231 -68
  165. package/src/client/actor-handle.ts +283 -89
  166. package/src/client/actor-query.ts +13 -6
  167. package/src/client/auth.ts +37 -0
  168. package/src/client/client.ts +182 -21
  169. package/src/client/config.ts +28 -3
  170. package/src/client/errors.ts +15 -2
  171. package/src/client/lifecycle-errors.ts +63 -5
  172. package/src/client/mod.ts +10 -0
  173. package/src/client/outbound-telemetry.ts +66 -0
  174. package/src/client/query.ts +3 -1
  175. package/src/client/queue.ts +13 -3
  176. package/src/client/raw-utils.ts +59 -14
  177. package/src/client/resolve-gateway-target.ts +3 -1
  178. package/src/client/retry-budget.ts +81 -0
  179. package/src/client/token-provider.ts +93 -0
  180. package/src/client/utils.ts +22 -9
  181. package/src/common/actor-router-consts.ts +6 -0
  182. package/src/common/actor-telemetry-context.ts +19 -0
  183. package/src/common/actor-websocket.ts +3 -1
  184. package/src/common/bare/actor-persist/v1.ts +205 -163
  185. package/src/common/bare/actor-persist/v2.ts +265 -213
  186. package/src/common/bare/actor-persist/v3.ts +176 -172
  187. package/src/common/bare/actor-persist/v4.ts +254 -253
  188. package/src/common/bare/generated/inspector/v5.ts +1016 -0
  189. package/src/common/bare/generated/inspector/v6.ts +1367 -0
  190. package/src/common/bare/transport/v1.ts +694 -542
  191. package/src/common/client-protocol-versioned.ts +66 -64
  192. package/src/common/database/config.ts +175 -9
  193. package/src/common/database/mod.ts +262 -77
  194. package/src/common/database/native-database.ts +442 -20
  195. package/src/common/database/shared.ts +25 -0
  196. package/src/common/encoding.ts +278 -34
  197. package/src/common/engine.ts +28 -1
  198. package/src/common/eventsource.ts +1 -1
  199. package/src/common/fetch-like.ts +63 -0
  200. package/src/common/inline-websocket-adapter.ts +14 -13
  201. package/src/common/inspector-transport.ts +12 -2
  202. package/src/common/log.ts +15 -8
  203. package/src/common/otel-context.ts +99 -0
  204. package/src/common/router.ts +14 -18
  205. package/src/common/utils.ts +8 -169
  206. package/src/common/websocket-interface.ts +1 -1
  207. package/src/db/drizzle.ts +182 -80
  208. package/src/db/mod.ts +5 -1
  209. package/src/devtools-loader/index.ts +4 -7
  210. package/src/devtools-loader/serve-devtools.ts +26 -0
  211. package/src/dynamic/instance.ts +32 -0
  212. package/src/dynamic/internal.ts +50 -0
  213. package/src/dynamic/isolate-runtime.ts +64 -0
  214. package/src/dynamic/mod.ts +32 -0
  215. package/src/engine-api/actors.ts +15 -3
  216. package/src/engine-client/actor-http-client.ts +37 -22
  217. package/src/engine-client/actor-websocket-client.ts +37 -9
  218. package/src/engine-client/api-endpoints.ts +128 -5
  219. package/src/engine-client/api-utils.ts +2 -2
  220. package/src/engine-client/driver.ts +21 -16
  221. package/src/engine-client/mod.ts +280 -111
  222. package/src/engine-client/ws-proxy.ts +9 -4
  223. package/src/inspector/client.browser.ts +127 -15
  224. package/src/inspector/mod.ts +2 -4
  225. package/src/inspector/workflow.ts +61 -0
  226. package/src/inspector-tab/mod.ts +301 -0
  227. package/src/registry/config/envoy.ts +3 -20
  228. package/src/registry/config/index.ts +91 -74
  229. package/src/registry/index.ts +702 -80
  230. package/src/registry/napi-runtime.ts +643 -42
  231. package/src/registry/native-http.ts +225 -0
  232. package/src/registry/native-validation.ts +10 -12
  233. package/src/registry/native.ts +1881 -582
  234. package/src/registry/run-handler-coordinator.ts +219 -0
  235. package/src/registry/runtime.ts +441 -7
  236. package/src/registry/wasm-runtime.ts +516 -23
  237. package/src/registry/write-through-proxy.ts +141 -0
  238. package/src/serde.ts +2 -2
  239. package/src/serverless/configure.ts +18 -7
  240. package/src/test/mod.ts +2 -17
  241. package/src/test/ready.ts +22 -0
  242. package/src/unstable/migrations.ts +141 -0
  243. package/src/utils/endpoint-parser.ts +1 -1
  244. package/src/utils/env-vars.ts +50 -2
  245. package/src/utils/node.ts +44 -28
  246. package/src/utils/router.ts +1 -1
  247. package/src/utils.ts +4 -2
  248. package/src/workflow/context.ts +703 -242
  249. package/src/workflow/driver.ts +284 -125
  250. package/src/workflow/inspector.ts +24 -24
  251. package/src/workflow/mod.ts +76 -84
  252. package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
  253. package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
  254. package/dist/tsup/chunk-6NT2LIFN.cjs +0 -268
  255. package/dist/tsup/chunk-6NT2LIFN.cjs.map +0 -1
  256. package/dist/tsup/chunk-7GKQJFSB.cjs.map +0 -1
  257. package/dist/tsup/chunk-7WXCRV25.cjs.map +0 -1
  258. package/dist/tsup/chunk-AGBP757I.js.map +0 -1
  259. package/dist/tsup/chunk-ARRBQTAR.cjs.map +0 -1
  260. package/dist/tsup/chunk-DXWOGCZY.js.map +0 -1
  261. package/dist/tsup/chunk-JGIPV3QU.js +0 -268
  262. package/dist/tsup/chunk-JGIPV3QU.js.map +0 -1
  263. package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
  264. package/dist/tsup/chunk-L4FVS7GY.js.map +0 -1
  265. package/dist/tsup/chunk-LD5YASJU.cjs.map +0 -1
  266. package/dist/tsup/chunk-OQEEZDIK.cjs.map +0 -1
  267. package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
  268. package/dist/tsup/chunk-QAZLM4WT.cjs.map +0 -1
  269. package/dist/tsup/chunk-QNLGOTQP.js.map +0 -1
  270. package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
  271. package/dist/tsup/chunk-V4JUWAT6.js.map +0 -1
  272. package/dist/tsup/chunk-VUF2YEF4.cjs.map +0 -1
  273. package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
  274. package/dist/tsup/config-CxjGYf4K.d.cts +0 -121
  275. package/dist/tsup/config-CxjGYf4K.d.ts +0 -121
  276. package/dist/tsup/context-88opQsfZ.d.cts +0 -92
  277. package/dist/tsup/context-CVEG5zfg.d.ts +0 -92
  278. package/src/actor/driver.ts +0 -141
  279. package/src/actor/instance/mod.ts +0 -2492
  280. package/src/actor/keys.test.ts +0 -275
  281. package/src/actor/utils.test.ts +0 -48
  282. package/src/agent-os/actor/cron.ts +0 -84
  283. package/src/agent-os/actor/db.ts +0 -54
  284. package/src/agent-os/actor/filesystem.ts +0 -131
  285. package/src/agent-os/actor/index.ts +0 -265
  286. package/src/agent-os/actor/network.ts +0 -58
  287. package/src/agent-os/actor/preview.ts +0 -191
  288. package/src/agent-os/actor/process.ts +0 -177
  289. package/src/agent-os/actor/session.ts +0 -518
  290. package/src/agent-os/actor/shell.ts +0 -60
  291. package/src/agent-os/config.ts +0 -79
  292. package/src/agent-os/fs/database-vfs.ts +0 -624
  293. package/src/agent-os/types.ts +0 -148
  294. package/src/client/test.ts +0 -44
  295. package/src/common/database/mod.test.ts +0 -137
  296. package/src/common/database/native-database.test.ts +0 -211
  297. package/src/common/inline-websocket-adapter.test.ts +0 -51
  298. package/src/drivers/engine/actor-driver.ts +0 -2460
  299. package/src/registry/runtime.test.ts +0 -50
  300. package/src/utils/endpoint-parser.test.ts +0 -206
  301. package/src/utils/serve.ts +0 -217
  302. package/src/utils.test.ts +0 -34
  303. /package/dist/tsup/{chunk-DZJZLZ4R.js.map → chunk-2MXBZGUP.js.map} +0 -0
@@ -1,38 +1,43 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunkVUF2YEF4cjs = require('../chunk-VUF2YEF4.cjs');
3
+ var _chunkDYJOU3MFcjs = require('../chunk-DYJOU3MF.cjs');
4
4
 
5
5
 
6
+ var _chunkX76BM5JScjs = require('../chunk-X76BM5JS.cjs');
7
+ require('../chunk-RTWH3AX3.cjs');
8
+ require('../chunk-XLDJSZ3B.cjs');
9
+ require('../chunk-KVFIONKQ.cjs');
10
+ require('../chunk-6XVNZKKP.cjs');
11
+ require('../chunk-MGI2VVF6.cjs');
6
12
 
7
- var _chunkARRBQTARcjs = require('../chunk-ARRBQTAR.cjs');
8
- require('../chunk-LD5YASJU.cjs');
9
- require('../chunk-6NT2LIFN.cjs');
10
- require('../chunk-2NDZ7JCR.cjs');
11
- require('../chunk-GKAMEBTZ.cjs');
12
- require('../chunk-OQEEZDIK.cjs');
13
- require('../chunk-QAZLM4WT.cjs');
14
-
15
- // src/test/mod.ts
13
+ // src/test/ready.ts
16
14
  var _pretry = require('p-retry'); var _pretry2 = _interopRequireDefault(_pretry);
17
15
  async function waitForRegistryReady(registry) {
18
- const clientConfig = _chunkARRBQTARcjs.convertRegistryConfigToClientConfig.call(void 0,
19
- registry.parseConfig()
16
+ await _pretry2.default.call(void 0,
17
+ async () => {
18
+ const response = await registry.routes.health();
19
+ if (!response.ok) {
20
+ throw new Error(
21
+ `RivetKit registry is not ready: ${response.status} ${await response.text()}`
22
+ );
23
+ }
24
+ },
25
+ {
26
+ retries: 120,
27
+ minTimeout: 50,
28
+ maxTimeout: 250
29
+ }
20
30
  );
21
- await _pretry2.default.call(void 0, async () => {
22
- await _chunkARRBQTARcjs.getMetadata.call(void 0, clientConfig);
23
- }, {
24
- retries: 20,
25
- minTimeout: 50,
26
- maxTimeout: 250
27
- });
28
31
  }
32
+
33
+ // src/test/mod.ts
29
34
  async function setupTest(c, registry) {
30
35
  registry.config.test = { ...registry.config.test, enabled: true };
31
36
  registry.config.noWelcome = true;
32
37
  registry.start();
33
38
  await waitForRegistryReady(registry);
34
- const client = _chunkVUF2YEF4cjs.createClient.call(void 0, {
35
- ..._chunkARRBQTARcjs.convertRegistryConfigToClientConfig.call(void 0, registry.parseConfig()),
39
+ const client = _chunkDYJOU3MFcjs.createClient.call(void 0, {
40
+ ..._chunkX76BM5JScjs.convertRegistryConfigToClientConfig.call(void 0, registry.parseConfig()),
36
41
  disableMetadataLookup: false
37
42
  });
38
43
  c.onTestFinished(async () => {
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/test/mod.cjs","../../../src/test/mod.ts"],"names":[],"mappings":"AAAA;AACE;AACF,yDAA8B;AAC9B;AACE;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACA;ACdA,iFAAmB;AAWnB,MAAA,SAAe,oBAAA,CAAqB,QAAA,EAAwC;AAC3E,EAAA,MAAM,aAAA,EAAe,mEAAA;AAAA,IACpB,QAAA,CAAS,WAAA,CAAY;AAAA,EACtB,CAAA;AAEA,EAAA,MAAM,8BAAA,MAAO,CAAA,EAAA,GAAY;AACxB,IAAA,MAAM,2CAAA,YAAwB,CAAA;AAAA,EAC/B,CAAA,EAAG;AAAA,IACF,OAAA,EAAS,EAAA;AAAA,IACT,UAAA,EAAY,EAAA;AAAA,IACZ,UAAA,EAAY;AAAA,EACb,CAAC,CAAA;AACF;AAEA,MAAA,SAAsB,SAAA,CACrB,CAAA,EACA,QAAA,EAC8B;AAC9B,EAAA,QAAA,CAAS,MAAA,CAAO,KAAA,EAAO,EAAE,GAAG,QAAA,CAAS,MAAA,CAAO,IAAA,EAAM,OAAA,EAAS,KAAK,CAAA;AAChE,EAAA,QAAA,CAAS,MAAA,CAAO,UAAA,EAAY,IAAA;AAE5B,EAAA,QAAA,CAAS,KAAA,CAAM,CAAA;AACf,EAAA,MAAM,oBAAA,CAAqB,QAAQ,CAAA;AAEnC,EAAA,MAAM,OAAA,EAAS,4CAAA;AAAgB,IAC9B,GAAG,mEAAA,QAAoC,CAAS,WAAA,CAAY,CAAC,CAAA;AAAA,IAC7D,qBAAA,EAAuB;AAAA,EACxB,CAAC,CAAA;AAED,EAAA,CAAA,CAAE,cAAA,CAAe,MAAA,CAAA,EAAA,GAAY;AAC5B,IAAA,MAAM,MAAA,CAAO,OAAA,CAAQ,CAAA;AAAA,EACtB,CAAC,CAAA;AAED,EAAA,OAAO,EAAE,OAAO,CAAA;AACjB;ADHA;AACE;AACF,8BAAC","file":"/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/test/mod.cjs","sourcesContent":[null,"import pRetry from \"p-retry\";\nimport type { TestContext } from \"vitest\";\nimport { type Client, createClient } from \"@/client/mod\";\nimport { convertRegistryConfigToClientConfig } from \"@/client/config\";\nimport { getMetadata } from \"@/engine-client/api-endpoints\";\nimport type { Registry } from \"@/registry\";\n\nexport interface SetupTestResult<A extends Registry<any>> {\n\tclient: Client<A>;\n}\n\nasync function waitForRegistryReady(registry: Registry<any>): Promise<void> {\n\tconst clientConfig = convertRegistryConfigToClientConfig(\n\t\tregistry.parseConfig(),\n\t);\n\n\tawait pRetry(async () => {\n\t\tawait getMetadata(clientConfig);\n\t}, {\n\t\tretries: 20,\n\t\tminTimeout: 50,\n\t\tmaxTimeout: 250,\n\t});\n}\n\nexport async function setupTest<A extends Registry<any>>(\n\tc: TestContext,\n\tregistry: A,\n): Promise<SetupTestResult<A>> {\n\tregistry.config.test = { ...registry.config.test, enabled: true };\n\tregistry.config.noWelcome = true;\n\n\tregistry.start();\n\tawait waitForRegistryReady(registry);\n\n\tconst client = createClient<A>({\n\t\t...convertRegistryConfigToClientConfig(registry.parseConfig()),\n\t\tdisableMetadataLookup: false,\n\t});\n\n\tc.onTestFinished(async () => {\n\t\tawait client.dispose();\n\t});\n\n\treturn { client };\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/test/mod.cjs","../../../src/test/ready.ts","../../../src/test/mod.ts"],"names":[],"mappings":"AAAA;AACE;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACA;ACZA,iFAAmB;AAGnB,MAAA,SAAsB,oBAAA,CACrB,QAAA,EACgB;AAChB,EAAA,MAAM,8BAAA;AAAA,IACL,MAAA,CAAA,EAAA,GAAY;AACX,MAAA,MAAM,SAAA,EAAW,MAAM,QAAA,CAAS,MAAA,CAAO,MAAA,CAAO,CAAA;AAC9C,MAAA,GAAA,CAAI,CAAC,QAAA,CAAS,EAAA,EAAI;AACjB,QAAA,MAAM,IAAI,KAAA;AAAA,UACT,CAAA,gCAAA,EAAmC,QAAA,CAAS,MAAM,CAAA,CAAA,EAAI,MAAM,QAAA,CAAS,IAAA,CAAK,CAAC,CAAA;AAAA,QAAA;AAC5E,MAAA;AACD,IAAA;AACD,IAAA;AACA,MAAA;AACU,MAAA;AACG,MAAA;AACA,IAAA;AACb,EAAA;AAEF;ADUA;AACA;AEtBA;AAIC,EAAA;AACA,EAAA;AAEA,EAAA;AACA,EAAA;AAEA,EAAA;AAA+B,IAAA;AAC+B,IAAA;AACtC,EAAA;AAGxB,EAAA;AACC,IAAA;AAAqB,EAAA;AAGtB,EAAA;AACD;AFiBA;AACA;AACA","file":"/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/test/mod.cjs","sourcesContent":[null,"import pRetry from \"p-retry\";\nimport type { Registry } from \"@/registry\";\n\nexport async function waitForRegistryReady(\n\tregistry: Registry<any>,\n): Promise<void> {\n\tawait pRetry(\n\t\tasync () => {\n\t\t\tconst response = await registry.routes.health();\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`RivetKit registry is not ready: ${response.status} ${await response.text()}`,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tretries: 120,\n\t\t\tminTimeout: 50,\n\t\t\tmaxTimeout: 250,\n\t\t},\n\t);\n}\n","import type { TestContext } from \"vitest\";\nimport { convertRegistryConfigToClientConfig } from \"@/client/config\";\nimport { type Client, createClient } from \"@/client/mod\";\nimport type { Registry } from \"@/registry\";\nimport { waitForRegistryReady } from \"./ready\";\n\nexport interface SetupTestResult<A extends Registry<any>> {\n\tclient: Client<A>;\n}\n\nexport async function setupTest<A extends Registry<any>>(\n\tc: TestContext,\n\tregistry: A,\n): Promise<SetupTestResult<A>> {\n\tregistry.config.test = { ...registry.config.test, enabled: true };\n\tregistry.config.noWelcome = true;\n\n\tregistry.start();\n\tawait waitForRegistryReady(registry);\n\n\tconst client = createClient<A>({\n\t\t...convertRegistryConfigToClientConfig(registry.parseConfig()),\n\t\tdisableMetadataLookup: false,\n\t});\n\n\tc.onTestFinished(async () => {\n\t\tawait client.dispose();\n\t});\n\n\treturn { client };\n}\n"]}
@@ -1,15 +1,17 @@
1
1
  import { TestContext } from 'vitest';
2
- import { ap as Registry, V as Client } from '../config-nlTlOKaE.cjs';
2
+ import { aK as Registry, a8 as Client } from '../config-BMGUEKMZ.cjs';
3
3
  import 'zod/v4';
4
- import '@rivetkit/virtual-websocket';
5
- import '../config-CxjGYf4K.cjs';
4
+ import '../config-CBTr4IhE.cjs';
6
5
  import '@rivetkit/rivetkit-wasm';
7
6
  import 'zod';
8
7
  import 'pino';
8
+ import '@rivetkit/virtual-websocket';
9
+ import '../inspector/workflow.cjs';
9
10
  import '@standard-schema/spec';
11
+ import '@rivetkit/engine-api-full';
12
+ import '../utils-C6b0aYUM.cjs';
10
13
  import 'hono';
11
- import '../utils.cjs';
12
- import '../utils-DVekpm4I.cjs';
14
+ import '../utils-3rsE0JvI.cjs';
13
15
  import 'hono/utils/http-status';
14
16
 
15
17
  interface SetupTestResult<A extends Registry<any>> {
@@ -1,15 +1,17 @@
1
1
  import { TestContext } from 'vitest';
2
- import { ap as Registry, V as Client } from '../config-D7ykAntK.js';
2
+ import { aK as Registry, a8 as Client } from '../config-iBpXyITj.js';
3
3
  import 'zod/v4';
4
- import '@rivetkit/virtual-websocket';
5
- import '../config-CxjGYf4K.js';
4
+ import '../config-CBTr4IhE.js';
6
5
  import '@rivetkit/rivetkit-wasm';
7
6
  import 'zod';
8
7
  import 'pino';
8
+ import '@rivetkit/virtual-websocket';
9
+ import '../inspector/workflow.js';
9
10
  import '@standard-schema/spec';
11
+ import '@rivetkit/engine-api-full';
12
+ import '../utils-C1O-SklO.js';
10
13
  import 'hono';
11
- import '../utils.js';
12
- import '../utils-DVekpm4I.js';
14
+ import '../utils-3rsE0JvI.js';
13
15
  import 'hono/utils/http-status';
14
16
 
15
17
  interface SetupTestResult<A extends Registry<any>> {
@@ -1,31 +1,36 @@
1
1
  import {
2
2
  createClient
3
- } from "../chunk-L4FVS7GY.js";
3
+ } from "../chunk-47IS5ZFI.js";
4
4
  import {
5
- convertRegistryConfigToClientConfig,
6
- getMetadata
7
- } from "../chunk-QNLGOTQP.js";
8
- import "../chunk-3YY5S6TV.js";
9
- import "../chunk-JGIPV3QU.js";
10
- import "../chunk-PCBNKI2J.js";
11
- import "../chunk-DZJZLZ4R.js";
12
- import "../chunk-V4JUWAT6.js";
13
- import "../chunk-KIWH5H3K.js";
5
+ convertRegistryConfigToClientConfig
6
+ } from "../chunk-NPHTIUUJ.js";
7
+ import "../chunk-A2CF6PFH.js";
8
+ import "../chunk-2MXBZGUP.js";
9
+ import "../chunk-JTHHCZCZ.js";
10
+ import "../chunk-K3AJOPSF.js";
11
+ import "../chunk-ZOVJDAOW.js";
14
12
 
15
- // src/test/mod.ts
13
+ // src/test/ready.ts
16
14
  import pRetry from "p-retry";
17
15
  async function waitForRegistryReady(registry) {
18
- const clientConfig = convertRegistryConfigToClientConfig(
19
- registry.parseConfig()
16
+ await pRetry(
17
+ async () => {
18
+ const response = await registry.routes.health();
19
+ if (!response.ok) {
20
+ throw new Error(
21
+ `RivetKit registry is not ready: ${response.status} ${await response.text()}`
22
+ );
23
+ }
24
+ },
25
+ {
26
+ retries: 120,
27
+ minTimeout: 50,
28
+ maxTimeout: 250
29
+ }
20
30
  );
21
- await pRetry(async () => {
22
- await getMetadata(clientConfig);
23
- }, {
24
- retries: 20,
25
- minTimeout: 50,
26
- maxTimeout: 250
27
- });
28
31
  }
32
+
33
+ // src/test/mod.ts
29
34
  async function setupTest(c, registry) {
30
35
  registry.config.test = { ...registry.config.test, enabled: true };
31
36
  registry.config.noWelcome = true;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/test/mod.ts"],"sourcesContent":["import pRetry from \"p-retry\";\nimport type { TestContext } from \"vitest\";\nimport { type Client, createClient } from \"@/client/mod\";\nimport { convertRegistryConfigToClientConfig } from \"@/client/config\";\nimport { getMetadata } from \"@/engine-client/api-endpoints\";\nimport type { Registry } from \"@/registry\";\n\nexport interface SetupTestResult<A extends Registry<any>> {\n\tclient: Client<A>;\n}\n\nasync function waitForRegistryReady(registry: Registry<any>): Promise<void> {\n\tconst clientConfig = convertRegistryConfigToClientConfig(\n\t\tregistry.parseConfig(),\n\t);\n\n\tawait pRetry(async () => {\n\t\tawait getMetadata(clientConfig);\n\t}, {\n\t\tretries: 20,\n\t\tminTimeout: 50,\n\t\tmaxTimeout: 250,\n\t});\n}\n\nexport async function setupTest<A extends Registry<any>>(\n\tc: TestContext,\n\tregistry: A,\n): Promise<SetupTestResult<A>> {\n\tregistry.config.test = { ...registry.config.test, enabled: true };\n\tregistry.config.noWelcome = true;\n\n\tregistry.start();\n\tawait waitForRegistryReady(registry);\n\n\tconst client = createClient<A>({\n\t\t...convertRegistryConfigToClientConfig(registry.parseConfig()),\n\t\tdisableMetadataLookup: false,\n\t});\n\n\tc.onTestFinished(async () => {\n\t\tawait client.dispose();\n\t});\n\n\treturn { client };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,YAAY;AAWnB,eAAe,qBAAqB,UAAwC;AAC3E,QAAM,eAAe;AAAA,IACpB,SAAS,YAAY;AAAA,EACtB;AAEA,QAAM,OAAO,YAAY;AACxB,UAAM,YAAY,YAAY;AAAA,EAC/B,GAAG;AAAA,IACF,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,YAAY;AAAA,EACb,CAAC;AACF;AAEA,eAAsB,UACrB,GACA,UAC8B;AAC9B,WAAS,OAAO,OAAO,EAAE,GAAG,SAAS,OAAO,MAAM,SAAS,KAAK;AAChE,WAAS,OAAO,YAAY;AAE5B,WAAS,MAAM;AACf,QAAM,qBAAqB,QAAQ;AAEnC,QAAM,SAAS,aAAgB;AAAA,IAC9B,GAAG,oCAAoC,SAAS,YAAY,CAAC;AAAA,IAC7D,uBAAuB;AAAA,EACxB,CAAC;AAED,IAAE,eAAe,YAAY;AAC5B,UAAM,OAAO,QAAQ;AAAA,EACtB,CAAC;AAED,SAAO,EAAE,OAAO;AACjB;","names":[]}
1
+ {"version":3,"sources":["../../../src/test/ready.ts","../../../src/test/mod.ts"],"sourcesContent":["import pRetry from \"p-retry\";\nimport type { Registry } from \"@/registry\";\n\nexport async function waitForRegistryReady(\n\tregistry: Registry<any>,\n): Promise<void> {\n\tawait pRetry(\n\t\tasync () => {\n\t\t\tconst response = await registry.routes.health();\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`RivetKit registry is not ready: ${response.status} ${await response.text()}`,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tretries: 120,\n\t\t\tminTimeout: 50,\n\t\t\tmaxTimeout: 250,\n\t\t},\n\t);\n}\n","import type { TestContext } from \"vitest\";\nimport { convertRegistryConfigToClientConfig } from \"@/client/config\";\nimport { type Client, createClient } from \"@/client/mod\";\nimport type { Registry } from \"@/registry\";\nimport { waitForRegistryReady } from \"./ready\";\n\nexport interface SetupTestResult<A extends Registry<any>> {\n\tclient: Client<A>;\n}\n\nexport async function setupTest<A extends Registry<any>>(\n\tc: TestContext,\n\tregistry: A,\n): Promise<SetupTestResult<A>> {\n\tregistry.config.test = { ...registry.config.test, enabled: true };\n\tregistry.config.noWelcome = true;\n\n\tregistry.start();\n\tawait waitForRegistryReady(registry);\n\n\tconst client = createClient<A>({\n\t\t...convertRegistryConfigToClientConfig(registry.parseConfig()),\n\t\tdisableMetadataLookup: false,\n\t});\n\n\tc.onTestFinished(async () => {\n\t\tawait client.dispose();\n\t});\n\n\treturn { client };\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,OAAO,YAAY;AAGnB,eAAsB,qBACrB,UACgB;AAChB,QAAM;AAAA,IACL,YAAY;AACX,YAAM,WAAW,MAAM,SAAS,OAAO,OAAO;AAC9C,UAAI,CAAC,SAAS,IAAI;AACjB,cAAM,IAAI;AAAA,UACT,mCAAmC,SAAS,MAAM,IAAI,MAAM,SAAS,KAAK,CAAC;AAAA,QAC5E;AAAA,MACD;AAAA,IACD;AAAA,IACA;AAAA,MACC,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,YAAY;AAAA,IACb;AAAA,EACD;AACD;;;ACXA,eAAsB,UACrB,GACA,UAC8B;AAC9B,WAAS,OAAO,OAAO,EAAE,GAAG,SAAS,OAAO,MAAM,SAAS,KAAK;AAChE,WAAS,OAAO,YAAY;AAE5B,WAAS,MAAM;AACf,QAAM,qBAAqB,QAAQ;AAEnC,QAAM,SAAS,aAAgB;AAAA,IAC9B,GAAG,oCAAoC,SAAS,YAAY,CAAC;AAAA,IAC7D,uBAAuB;AAAA,EACxB,CAAC;AAED,IAAE,eAAe,YAAY;AAC5B,UAAM,OAAO,QAAQ;AAAA,EACtB,CAAC;AAED,SAAO,EAAE,OAAO;AACjB;","names":[]}
@@ -0,0 +1,101 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/unstable/migrations.ts
2
+ var DEFAULT_MIGRATION_TABLE_NAME = "rivetkit_schema_version";
3
+ function migrations({
4
+ tableName = DEFAULT_MIGRATION_TABLE_NAME,
5
+ adopt,
6
+ migrations: ladder
7
+ }) {
8
+ validateTableName(tableName);
9
+ validateLadder(ladder);
10
+ return async (database) => {
11
+ var _a;
12
+ const quotedTableName = `"${tableName}"`;
13
+ await database.execute(`
14
+ CREATE TABLE IF NOT EXISTS ${quotedTableName} (
15
+ singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
16
+ schema_version INTEGER NOT NULL CHECK (
17
+ schema_version BETWEEN 0 AND ${Number.MAX_SAFE_INTEGER}
18
+ )
19
+ ) STRICT
20
+ `);
21
+ const rows = await database.execute(
22
+ `SELECT schema_version FROM ${quotedTableName} WHERE singleton = 1`
23
+ );
24
+ if (rows.length > 1) {
25
+ throw new Error(
26
+ `invalid migration table "${tableName}": expected at most one version row, received ${rows.length}`
27
+ );
28
+ }
29
+ const rawCurrent = (_a = rows[0]) == null ? void 0 : _a.schema_version;
30
+ let current = rows.length === 0 ? 0 : rawCurrent;
31
+ if (rows.length === 0 && adopt) {
32
+ current = await adopt(database);
33
+ }
34
+ if (typeof current !== "number" || !Number.isSafeInteger(current) || current < 0) {
35
+ throw new Error(
36
+ `invalid schema version ${String(current)} in migration table "${tableName}"`
37
+ );
38
+ }
39
+ if (current > ladder.length) {
40
+ throw new Error(
41
+ `migration version ${current} in "${tableName}" is newer than supported version ${ladder.length}`
42
+ );
43
+ }
44
+ if (rows.length === 0 && current > 0) {
45
+ await writeVersion(database, quotedTableName, current);
46
+ }
47
+ for (const migration of ladder.slice(current)) {
48
+ if (migration.sql !== void 0) {
49
+ await database.execute(migration.sql);
50
+ } else {
51
+ await migration.up(database);
52
+ }
53
+ await writeVersion(database, quotedTableName, migration.version);
54
+ }
55
+ };
56
+ }
57
+ async function writeVersion(database, quotedTableName, version) {
58
+ await database.execute(
59
+ `INSERT INTO ${quotedTableName} (singleton, schema_version)
60
+ VALUES (1, ?)
61
+ ON CONFLICT(singleton) DO UPDATE SET schema_version = excluded.schema_version`,
62
+ version
63
+ );
64
+ }
65
+ function validateTableName(tableName) {
66
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(tableName)) {
67
+ throw new Error(
68
+ `invalid migration table name "${tableName}": expected a SQLite identifier`
69
+ );
70
+ }
71
+ }
72
+ function validateLadder(ladder) {
73
+ if (ladder.length === 0) {
74
+ throw new Error("migration ladder must not be empty");
75
+ }
76
+ for (const [index, migration] of ladder.entries()) {
77
+ const expectedVersion = index + 1;
78
+ if (migration.version !== expectedVersion) {
79
+ throw new Error(
80
+ `invalid migration ladder: expected version ${expectedVersion}, received ${migration.version}`
81
+ );
82
+ }
83
+ const hasSql = typeof migration.sql === "string";
84
+ const hasUp = typeof migration.up === "function";
85
+ if (hasSql === hasUp) {
86
+ throw new Error(
87
+ `invalid migration ${migration.version}: expected exactly one of sql or up`
88
+ );
89
+ }
90
+ if (hasSql && migration.sql.trim().length === 0) {
91
+ throw new Error(
92
+ `invalid migration ${migration.version}: SQL is empty`
93
+ );
94
+ }
95
+ }
96
+ }
97
+
98
+
99
+
100
+ exports.DEFAULT_MIGRATION_TABLE_NAME = DEFAULT_MIGRATION_TABLE_NAME; exports.migrations = migrations;
101
+ //# sourceMappingURL=migrations.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/unstable/migrations.cjs","../../../src/unstable/migrations.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,6BAAA,EAA+B,yBAAA;AA8BrC,SAAS,UAAA,CAAW;AAAA,EAC1B,UAAA,EAAY,4BAAA;AAAA,EACZ,KAAA;AAAA,EACA,UAAA,EAAY;AACb,CAAA,EAAgE;AAC/D,EAAA,iBAAA,CAAkB,SAAS,CAAA;AAC3B,EAAA,cAAA,CAAe,MAAM,CAAA;AAErB,EAAA,OAAO,MAAA,CAAO,QAAA,EAAA,GAAa;AAxC5B,IAAA,IAAA,EAAA;AAyCE,IAAA,MAAM,gBAAA,EAAkB,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA,CAAA;AACrC,IAAA,MAAM,QAAA,CAAS,OAAA,CAAQ,CAAA;AAAA,8BAAA,EACO,eAAe,CAAA;AAAA;AAAA;AAAA,kCAAA,EAGX,MAAA,CAAO,gBAAgB,CAAA;AAAA;AAAA;AAAA,EAAA,CAGxD,CAAA;AAED,IAAA,MAAM,KAAA,EAAO,MAAM,QAAA,CAAS,OAAA;AAAA,MAC3B,CAAA,2BAAA,EAA8B,eAAe,CAAA,oBAAA;AAAA,IAC9C,CAAA;AACA,IAAA,GAAA,CAAI,IAAA,CAAK,OAAA,EAAS,CAAA,EAAG;AACpB,MAAA,MAAM,IAAI,KAAA;AAAA,QACT,CAAA,yBAAA,EAA4B,SAAS,CAAA,8CAAA,EAAiD,IAAA,CAAK,MAAM,CAAA;AAAA,MAAA;AAClG,IAAA;AAGD,IAAA;AACA,IAAA;AACA,IAAA;AACC,MAAA;AAA8B,IAAA;AAE/B,IAAA;AAKC,MAAA;AAAU,QAAA;AACiE,MAAA;AAC3E,IAAA;AAED,IAAA;AACC,MAAA;AAAU,QAAA;AACsF,MAAA;AAChG,IAAA;AAED,IAAA;AACC,MAAA;AAAqD,IAAA;AAGtD,IAAA;AACC,MAAA;AACC,QAAA;AAAoC,MAAA;AAEpC,QAAA;AAA2B,MAAA;AAE5B,MAAA;AAA+D,IAAA;AAChE,EAAA;AAEF;AAEA;AAKC,EAAA;AAAe,IAAA;AACgB;AAAA,gFAAA;AAAA,IAAA;AAG9B,EAAA;AAEF;AAEA;AACC,EAAA;AACC,IAAA;AAAU,MAAA;AACiC,IAAA;AAC3C,EAAA;AAEF;AAEA;AACC,EAAA;AACC,IAAA;AAAoD,EAAA;AAGrD,EAAA;AACC,IAAA;AACA,IAAA;AACC,MAAA;AAAU,QAAA;AACmF,MAAA;AAC7F,IAAA;AAED,IAAA;AACA,IAAA;AACA,IAAA;AACC,MAAA;AAAU,QAAA;AAC6B,MAAA;AACvC,IAAA;AAED,IAAA;AACC,MAAA;AAAU,QAAA;AAC6B,MAAA;AACvC,IAAA;AACD,EAAA;AAEF;AD5CA;AACA;AACA;AACA","file":"/home/runner/work/rivet/rivet/rivetkit-typescript/packages/rivetkit/dist/tsup/unstable/migrations.cjs","sourcesContent":[null,"import type { RawAccess } from \"@/common/database/config\";\n\nexport const DEFAULT_MIGRATION_TABLE_NAME = \"rivetkit_schema_version\";\n\nexport type MigrationDatabase = Pick<RawAccess, \"execute\">;\n\nexport type Migration =\n\t| {\n\t\t\tversion: number;\n\t\t\tsql: string;\n\t\t\tup?: never;\n\t }\n\t| {\n\t\t\tversion: number;\n\t\t\tsql?: never;\n\t\t\tup: (db: MigrationDatabase) => Promise<void> | void;\n\t };\n\nexport interface MigrationsOptions {\n\t/** A table owned by this schema. Override this when multiple schemas share a database. */\n\ttableName?: string;\n\t/** Detect the version of a schema that predates its migration table. */\n\tadopt?: (db: MigrationDatabase) => Promise<number> | number;\n\t/** Contiguous migrations numbered from 1. */\n\tmigrations: readonly Migration[];\n}\n\n/**\n * Creates an `onMigrate` callback that applies each unapplied migration in order.\n * RivetKit runs the callback inside its migration savepoint, making the complete\n * ladder atomic when used with `db({ onMigrate })`.\n */\nexport function migrations({\n\ttableName = DEFAULT_MIGRATION_TABLE_NAME,\n\tadopt,\n\tmigrations: ladder,\n}: MigrationsOptions): (db: MigrationDatabase) => Promise<void> {\n\tvalidateTableName(tableName);\n\tvalidateLadder(ladder);\n\n\treturn async (database) => {\n\t\tconst quotedTableName = `\"${tableName}\"`;\n\t\tawait database.execute(`\n\t\t\tCREATE TABLE IF NOT EXISTS ${quotedTableName} (\n\t\t\t\tsingleton INTEGER PRIMARY KEY CHECK (singleton = 1),\n\t\t\t\tschema_version INTEGER NOT NULL CHECK (\n\t\t\t\t\tschema_version BETWEEN 0 AND ${Number.MAX_SAFE_INTEGER}\n\t\t\t\t)\n\t\t\t) STRICT\n\t\t`);\n\n\t\tconst rows = await database.execute<{ schema_version: unknown }>(\n\t\t\t`SELECT schema_version FROM ${quotedTableName} WHERE singleton = 1`,\n\t\t);\n\t\tif (rows.length > 1) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid migration table \"${tableName}\": expected at most one version row, received ${rows.length}`,\n\t\t\t);\n\t\t}\n\n\t\tconst rawCurrent = rows[0]?.schema_version;\n\t\tlet current = rows.length === 0 ? 0 : rawCurrent;\n\t\tif (rows.length === 0 && adopt) {\n\t\t\tcurrent = await adopt(database);\n\t\t}\n\t\tif (\n\t\t\ttypeof current !== \"number\" ||\n\t\t\t!Number.isSafeInteger(current) ||\n\t\t\tcurrent < 0\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid schema version ${String(current)} in migration table \"${tableName}\"`,\n\t\t\t);\n\t\t}\n\t\tif (current > ladder.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`migration version ${current} in \"${tableName}\" is newer than supported version ${ladder.length}`,\n\t\t\t);\n\t\t}\n\t\tif (rows.length === 0 && current > 0) {\n\t\t\tawait writeVersion(database, quotedTableName, current);\n\t\t}\n\n\t\tfor (const migration of ladder.slice(current)) {\n\t\t\tif (migration.sql !== undefined) {\n\t\t\t\tawait database.execute(migration.sql);\n\t\t\t} else {\n\t\t\t\tawait migration.up(database);\n\t\t\t}\n\t\t\tawait writeVersion(database, quotedTableName, migration.version);\n\t\t}\n\t};\n}\n\nasync function writeVersion(\n\tdatabase: MigrationDatabase,\n\tquotedTableName: string,\n\tversion: number,\n): Promise<void> {\n\tawait database.execute(\n\t\t`INSERT INTO ${quotedTableName} (singleton, schema_version)\n\t\t VALUES (1, ?)\n\t\t ON CONFLICT(singleton) DO UPDATE SET schema_version = excluded.schema_version`,\n\t\tversion,\n\t);\n}\n\nfunction validateTableName(tableName: string): void {\n\tif (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(tableName)) {\n\t\tthrow new Error(\n\t\t\t`invalid migration table name \"${tableName}\": expected a SQLite identifier`,\n\t\t);\n\t}\n}\n\nfunction validateLadder(ladder: readonly Migration[]): void {\n\tif (ladder.length === 0) {\n\t\tthrow new Error(\"migration ladder must not be empty\");\n\t}\n\n\tfor (const [index, migration] of ladder.entries()) {\n\t\tconst expectedVersion = index + 1;\n\t\tif (migration.version !== expectedVersion) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid migration ladder: expected version ${expectedVersion}, received ${migration.version}`,\n\t\t\t);\n\t\t}\n\t\tconst hasSql = typeof migration.sql === \"string\";\n\t\tconst hasUp = typeof migration.up === \"function\";\n\t\tif (hasSql === hasUp) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid migration ${migration.version}: expected exactly one of sql or up`,\n\t\t\t);\n\t\t}\n\t\tif (hasSql && migration.sql.trim().length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid migration ${migration.version}: SQL is empty`,\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import { R as RawAccess } from '../config-CBTr4IhE.cjs';
2
+
3
+ declare const DEFAULT_MIGRATION_TABLE_NAME = "rivetkit_schema_version";
4
+ type MigrationDatabase = Pick<RawAccess, "execute">;
5
+ type Migration = {
6
+ version: number;
7
+ sql: string;
8
+ up?: never;
9
+ } | {
10
+ version: number;
11
+ sql?: never;
12
+ up: (db: MigrationDatabase) => Promise<void> | void;
13
+ };
14
+ interface MigrationsOptions {
15
+ /** A table owned by this schema. Override this when multiple schemas share a database. */
16
+ tableName?: string;
17
+ /** Detect the version of a schema that predates its migration table. */
18
+ adopt?: (db: MigrationDatabase) => Promise<number> | number;
19
+ /** Contiguous migrations numbered from 1. */
20
+ migrations: readonly Migration[];
21
+ }
22
+ /**
23
+ * Creates an `onMigrate` callback that applies each unapplied migration in order.
24
+ * RivetKit runs the callback inside its migration savepoint, making the complete
25
+ * ladder atomic when used with `db({ onMigrate })`.
26
+ */
27
+ declare function migrations({ tableName, adopt, migrations: ladder, }: MigrationsOptions): (db: MigrationDatabase) => Promise<void>;
28
+
29
+ export { DEFAULT_MIGRATION_TABLE_NAME, type Migration, type MigrationDatabase, type MigrationsOptions, migrations };
@@ -0,0 +1,29 @@
1
+ import { R as RawAccess } from '../config-CBTr4IhE.js';
2
+
3
+ declare const DEFAULT_MIGRATION_TABLE_NAME = "rivetkit_schema_version";
4
+ type MigrationDatabase = Pick<RawAccess, "execute">;
5
+ type Migration = {
6
+ version: number;
7
+ sql: string;
8
+ up?: never;
9
+ } | {
10
+ version: number;
11
+ sql?: never;
12
+ up: (db: MigrationDatabase) => Promise<void> | void;
13
+ };
14
+ interface MigrationsOptions {
15
+ /** A table owned by this schema. Override this when multiple schemas share a database. */
16
+ tableName?: string;
17
+ /** Detect the version of a schema that predates its migration table. */
18
+ adopt?: (db: MigrationDatabase) => Promise<number> | number;
19
+ /** Contiguous migrations numbered from 1. */
20
+ migrations: readonly Migration[];
21
+ }
22
+ /**
23
+ * Creates an `onMigrate` callback that applies each unapplied migration in order.
24
+ * RivetKit runs the callback inside its migration savepoint, making the complete
25
+ * ladder atomic when used with `db({ onMigrate })`.
26
+ */
27
+ declare function migrations({ tableName, adopt, migrations: ladder, }: MigrationsOptions): (db: MigrationDatabase) => Promise<void>;
28
+
29
+ export { DEFAULT_MIGRATION_TABLE_NAME, type Migration, type MigrationDatabase, type MigrationsOptions, migrations };
@@ -0,0 +1,101 @@
1
+ // src/unstable/migrations.ts
2
+ var DEFAULT_MIGRATION_TABLE_NAME = "rivetkit_schema_version";
3
+ function migrations({
4
+ tableName = DEFAULT_MIGRATION_TABLE_NAME,
5
+ adopt,
6
+ migrations: ladder
7
+ }) {
8
+ validateTableName(tableName);
9
+ validateLadder(ladder);
10
+ return async (database) => {
11
+ var _a;
12
+ const quotedTableName = `"${tableName}"`;
13
+ await database.execute(`
14
+ CREATE TABLE IF NOT EXISTS ${quotedTableName} (
15
+ singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
16
+ schema_version INTEGER NOT NULL CHECK (
17
+ schema_version BETWEEN 0 AND ${Number.MAX_SAFE_INTEGER}
18
+ )
19
+ ) STRICT
20
+ `);
21
+ const rows = await database.execute(
22
+ `SELECT schema_version FROM ${quotedTableName} WHERE singleton = 1`
23
+ );
24
+ if (rows.length > 1) {
25
+ throw new Error(
26
+ `invalid migration table "${tableName}": expected at most one version row, received ${rows.length}`
27
+ );
28
+ }
29
+ const rawCurrent = (_a = rows[0]) == null ? void 0 : _a.schema_version;
30
+ let current = rows.length === 0 ? 0 : rawCurrent;
31
+ if (rows.length === 0 && adopt) {
32
+ current = await adopt(database);
33
+ }
34
+ if (typeof current !== "number" || !Number.isSafeInteger(current) || current < 0) {
35
+ throw new Error(
36
+ `invalid schema version ${String(current)} in migration table "${tableName}"`
37
+ );
38
+ }
39
+ if (current > ladder.length) {
40
+ throw new Error(
41
+ `migration version ${current} in "${tableName}" is newer than supported version ${ladder.length}`
42
+ );
43
+ }
44
+ if (rows.length === 0 && current > 0) {
45
+ await writeVersion(database, quotedTableName, current);
46
+ }
47
+ for (const migration of ladder.slice(current)) {
48
+ if (migration.sql !== void 0) {
49
+ await database.execute(migration.sql);
50
+ } else {
51
+ await migration.up(database);
52
+ }
53
+ await writeVersion(database, quotedTableName, migration.version);
54
+ }
55
+ };
56
+ }
57
+ async function writeVersion(database, quotedTableName, version) {
58
+ await database.execute(
59
+ `INSERT INTO ${quotedTableName} (singleton, schema_version)
60
+ VALUES (1, ?)
61
+ ON CONFLICT(singleton) DO UPDATE SET schema_version = excluded.schema_version`,
62
+ version
63
+ );
64
+ }
65
+ function validateTableName(tableName) {
66
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(tableName)) {
67
+ throw new Error(
68
+ `invalid migration table name "${tableName}": expected a SQLite identifier`
69
+ );
70
+ }
71
+ }
72
+ function validateLadder(ladder) {
73
+ if (ladder.length === 0) {
74
+ throw new Error("migration ladder must not be empty");
75
+ }
76
+ for (const [index, migration] of ladder.entries()) {
77
+ const expectedVersion = index + 1;
78
+ if (migration.version !== expectedVersion) {
79
+ throw new Error(
80
+ `invalid migration ladder: expected version ${expectedVersion}, received ${migration.version}`
81
+ );
82
+ }
83
+ const hasSql = typeof migration.sql === "string";
84
+ const hasUp = typeof migration.up === "function";
85
+ if (hasSql === hasUp) {
86
+ throw new Error(
87
+ `invalid migration ${migration.version}: expected exactly one of sql or up`
88
+ );
89
+ }
90
+ if (hasSql && migration.sql.trim().length === 0) {
91
+ throw new Error(
92
+ `invalid migration ${migration.version}: SQL is empty`
93
+ );
94
+ }
95
+ }
96
+ }
97
+ export {
98
+ DEFAULT_MIGRATION_TABLE_NAME,
99
+ migrations
100
+ };
101
+ //# sourceMappingURL=migrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/unstable/migrations.ts"],"sourcesContent":["import type { RawAccess } from \"@/common/database/config\";\n\nexport const DEFAULT_MIGRATION_TABLE_NAME = \"rivetkit_schema_version\";\n\nexport type MigrationDatabase = Pick<RawAccess, \"execute\">;\n\nexport type Migration =\n\t| {\n\t\t\tversion: number;\n\t\t\tsql: string;\n\t\t\tup?: never;\n\t }\n\t| {\n\t\t\tversion: number;\n\t\t\tsql?: never;\n\t\t\tup: (db: MigrationDatabase) => Promise<void> | void;\n\t };\n\nexport interface MigrationsOptions {\n\t/** A table owned by this schema. Override this when multiple schemas share a database. */\n\ttableName?: string;\n\t/** Detect the version of a schema that predates its migration table. */\n\tadopt?: (db: MigrationDatabase) => Promise<number> | number;\n\t/** Contiguous migrations numbered from 1. */\n\tmigrations: readonly Migration[];\n}\n\n/**\n * Creates an `onMigrate` callback that applies each unapplied migration in order.\n * RivetKit runs the callback inside its migration savepoint, making the complete\n * ladder atomic when used with `db({ onMigrate })`.\n */\nexport function migrations({\n\ttableName = DEFAULT_MIGRATION_TABLE_NAME,\n\tadopt,\n\tmigrations: ladder,\n}: MigrationsOptions): (db: MigrationDatabase) => Promise<void> {\n\tvalidateTableName(tableName);\n\tvalidateLadder(ladder);\n\n\treturn async (database) => {\n\t\tconst quotedTableName = `\"${tableName}\"`;\n\t\tawait database.execute(`\n\t\t\tCREATE TABLE IF NOT EXISTS ${quotedTableName} (\n\t\t\t\tsingleton INTEGER PRIMARY KEY CHECK (singleton = 1),\n\t\t\t\tschema_version INTEGER NOT NULL CHECK (\n\t\t\t\t\tschema_version BETWEEN 0 AND ${Number.MAX_SAFE_INTEGER}\n\t\t\t\t)\n\t\t\t) STRICT\n\t\t`);\n\n\t\tconst rows = await database.execute<{ schema_version: unknown }>(\n\t\t\t`SELECT schema_version FROM ${quotedTableName} WHERE singleton = 1`,\n\t\t);\n\t\tif (rows.length > 1) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid migration table \"${tableName}\": expected at most one version row, received ${rows.length}`,\n\t\t\t);\n\t\t}\n\n\t\tconst rawCurrent = rows[0]?.schema_version;\n\t\tlet current = rows.length === 0 ? 0 : rawCurrent;\n\t\tif (rows.length === 0 && adopt) {\n\t\t\tcurrent = await adopt(database);\n\t\t}\n\t\tif (\n\t\t\ttypeof current !== \"number\" ||\n\t\t\t!Number.isSafeInteger(current) ||\n\t\t\tcurrent < 0\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid schema version ${String(current)} in migration table \"${tableName}\"`,\n\t\t\t);\n\t\t}\n\t\tif (current > ladder.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`migration version ${current} in \"${tableName}\" is newer than supported version ${ladder.length}`,\n\t\t\t);\n\t\t}\n\t\tif (rows.length === 0 && current > 0) {\n\t\t\tawait writeVersion(database, quotedTableName, current);\n\t\t}\n\n\t\tfor (const migration of ladder.slice(current)) {\n\t\t\tif (migration.sql !== undefined) {\n\t\t\t\tawait database.execute(migration.sql);\n\t\t\t} else {\n\t\t\t\tawait migration.up(database);\n\t\t\t}\n\t\t\tawait writeVersion(database, quotedTableName, migration.version);\n\t\t}\n\t};\n}\n\nasync function writeVersion(\n\tdatabase: MigrationDatabase,\n\tquotedTableName: string,\n\tversion: number,\n): Promise<void> {\n\tawait database.execute(\n\t\t`INSERT INTO ${quotedTableName} (singleton, schema_version)\n\t\t VALUES (1, ?)\n\t\t ON CONFLICT(singleton) DO UPDATE SET schema_version = excluded.schema_version`,\n\t\tversion,\n\t);\n}\n\nfunction validateTableName(tableName: string): void {\n\tif (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(tableName)) {\n\t\tthrow new Error(\n\t\t\t`invalid migration table name \"${tableName}\": expected a SQLite identifier`,\n\t\t);\n\t}\n}\n\nfunction validateLadder(ladder: readonly Migration[]): void {\n\tif (ladder.length === 0) {\n\t\tthrow new Error(\"migration ladder must not be empty\");\n\t}\n\n\tfor (const [index, migration] of ladder.entries()) {\n\t\tconst expectedVersion = index + 1;\n\t\tif (migration.version !== expectedVersion) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid migration ladder: expected version ${expectedVersion}, received ${migration.version}`,\n\t\t\t);\n\t\t}\n\t\tconst hasSql = typeof migration.sql === \"string\";\n\t\tconst hasUp = typeof migration.up === \"function\";\n\t\tif (hasSql === hasUp) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid migration ${migration.version}: expected exactly one of sql or up`,\n\t\t\t);\n\t\t}\n\t\tif (hasSql && migration.sql.trim().length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`invalid migration ${migration.version}: SQL is empty`,\n\t\t\t);\n\t\t}\n\t}\n}\n"],"mappings":";AAEO,IAAM,+BAA+B;AA8BrC,SAAS,WAAW;AAAA,EAC1B,YAAY;AAAA,EACZ;AAAA,EACA,YAAY;AACb,GAAgE;AAC/D,oBAAkB,SAAS;AAC3B,iBAAe,MAAM;AAErB,SAAO,OAAO,aAAa;AAxC5B;AAyCE,UAAM,kBAAkB,IAAI,SAAS;AACrC,UAAM,SAAS,QAAQ;AAAA,gCACO,eAAe;AAAA;AAAA;AAAA,oCAGX,OAAO,gBAAgB;AAAA;AAAA;AAAA,GAGxD;AAED,UAAM,OAAO,MAAM,SAAS;AAAA,MAC3B,8BAA8B,eAAe;AAAA,IAC9C;AACA,QAAI,KAAK,SAAS,GAAG;AACpB,YAAM,IAAI;AAAA,QACT,4BAA4B,SAAS,iDAAiD,KAAK,MAAM;AAAA,MAClG;AAAA,IACD;AAEA,UAAM,cAAa,UAAK,CAAC,MAAN,mBAAS;AAC5B,QAAI,UAAU,KAAK,WAAW,IAAI,IAAI;AACtC,QAAI,KAAK,WAAW,KAAK,OAAO;AAC/B,gBAAU,MAAM,MAAM,QAAQ;AAAA,IAC/B;AACA,QACC,OAAO,YAAY,YACnB,CAAC,OAAO,cAAc,OAAO,KAC7B,UAAU,GACT;AACD,YAAM,IAAI;AAAA,QACT,0BAA0B,OAAO,OAAO,CAAC,wBAAwB,SAAS;AAAA,MAC3E;AAAA,IACD;AACA,QAAI,UAAU,OAAO,QAAQ;AAC5B,YAAM,IAAI;AAAA,QACT,qBAAqB,OAAO,QAAQ,SAAS,qCAAqC,OAAO,MAAM;AAAA,MAChG;AAAA,IACD;AACA,QAAI,KAAK,WAAW,KAAK,UAAU,GAAG;AACrC,YAAM,aAAa,UAAU,iBAAiB,OAAO;AAAA,IACtD;AAEA,eAAW,aAAa,OAAO,MAAM,OAAO,GAAG;AAC9C,UAAI,UAAU,QAAQ,QAAW;AAChC,cAAM,SAAS,QAAQ,UAAU,GAAG;AAAA,MACrC,OAAO;AACN,cAAM,UAAU,GAAG,QAAQ;AAAA,MAC5B;AACA,YAAM,aAAa,UAAU,iBAAiB,UAAU,OAAO;AAAA,IAChE;AAAA,EACD;AACD;AAEA,eAAe,aACd,UACA,iBACA,SACgB;AAChB,QAAM,SAAS;AAAA,IACd,eAAe,eAAe;AAAA;AAAA;AAAA,IAG9B;AAAA,EACD;AACD;AAEA,SAAS,kBAAkB,WAAyB;AACnD,MAAI,CAAC,2BAA2B,KAAK,SAAS,GAAG;AAChD,UAAM,IAAI;AAAA,MACT,iCAAiC,SAAS;AAAA,IAC3C;AAAA,EACD;AACD;AAEA,SAAS,eAAe,QAAoC;AAC3D,MAAI,OAAO,WAAW,GAAG;AACxB,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACrD;AAEA,aAAW,CAAC,OAAO,SAAS,KAAK,OAAO,QAAQ,GAAG;AAClD,UAAM,kBAAkB,QAAQ;AAChC,QAAI,UAAU,YAAY,iBAAiB;AAC1C,YAAM,IAAI;AAAA,QACT,8CAA8C,eAAe,cAAc,UAAU,OAAO;AAAA,MAC7F;AAAA,IACD;AACA,UAAM,SAAS,OAAO,UAAU,QAAQ;AACxC,UAAM,QAAQ,OAAO,UAAU,OAAO;AACtC,QAAI,WAAW,OAAO;AACrB,YAAM,IAAI;AAAA,QACT,qBAAqB,UAAU,OAAO;AAAA,MACvC;AAAA,IACD;AACA,QAAI,UAAU,UAAU,IAAI,KAAK,EAAE,WAAW,GAAG;AAChD,YAAM,IAAI;AAAA,QACT,qBAAqB,UAAU,OAAO;AAAA,MACvC;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
@@ -11,6 +11,8 @@ interface RivetErrorOptions extends ErrorOptions {
11
11
  public?: boolean;
12
12
  /** Metadata associated with this error. */
13
13
  metadata?: unknown;
14
+ /** Request identifier used to correlate this error with engine logs. */
15
+ rayId?: string;
14
16
  /** Explicit HTTP status override for router responses. */
15
17
  statusCode?: number;
16
18
  /** Actor context associated with this error. */
@@ -28,6 +30,7 @@ interface RivetErrorLike {
28
30
  code: string;
29
31
  message: string;
30
32
  metadata?: unknown;
33
+ rayId?: string;
31
34
  public?: boolean;
32
35
  statusCode?: number;
33
36
  actor?: ActorSpecifier;
@@ -47,10 +50,12 @@ interface UserErrorOptions extends ErrorOptions {
47
50
  metadata?: unknown;
48
51
  }
49
52
  declare function isRivetErrorLike(error: unknown): error is RivetError | DeconstructedError | RivetErrorLike;
53
+ declare function isActorAbortedError(error: unknown): boolean;
50
54
  declare class RivetError extends Error {
51
55
  __type: "RivetError";
52
56
  public: boolean;
53
57
  metadata?: unknown;
58
+ readonly rayId?: string;
54
59
  statusCode: number;
55
60
  actor?: ActorSpecifier;
56
61
  readonly group: string;
@@ -65,7 +70,25 @@ declare class UserError extends RivetError {
65
70
  constructor(message: string, options?: UserErrorOptions);
66
71
  }
67
72
  declare function toRivetError(error: unknown, fallback?: Partial<RivetErrorLike>): RivetError;
68
- declare function encodeBridgeRivetError(error: RivetErrorLike): string;
73
+ /** A structured error encoded for the bridge to Core. */
74
+ interface EncodedBridgeError {
75
+ readonly encoded: string;
76
+ /** Set when JSON could not encode the metadata, which was dropped. */
77
+ readonly droppedMetadataCause?: unknown;
78
+ }
79
+ /**
80
+ * Encodes a structured error for the bridge to Core. Metadata that JSON cannot
81
+ * encode, such as a `bigint`, is dropped so the error itself still crosses.
82
+ */
83
+ declare function encodeBridgeRivetError(error: RivetErrorLike): EncodedBridgeError;
84
+ /**
85
+ * Encodes an error for the telemetry bridge. A structured error crosses with
86
+ * its group and code. Anything else crosses as text so Core classifies it,
87
+ * which is the same rule that keeps raw messages out of every span.
88
+ */
89
+ declare function encodeErrorForBridge(error: unknown): string;
90
+ /** A `RivetError` instance, or a plain object carrying its full tagged shape. */
91
+ declare function isCanonicalStructuredRivetError(error: unknown): error is RivetErrorLike;
69
92
  declare function decodeBridgeRivetErrorPayload(value: string): BridgeRivetErrorPayload | undefined;
70
93
  declare function decodeBridgeRivetError(value: string): RivetError | undefined;
71
94
  declare function isRivetErrorCode(error: unknown, group: string, code: string): error is RivetError;
@@ -94,10 +117,11 @@ interface DeconstructedError {
94
117
  code: string;
95
118
  message: string;
96
119
  metadata?: unknown;
120
+ rayId?: string;
97
121
  actor?: ActorSpecifier;
98
122
  }
99
123
  declare function stringifyError(error: unknown): string;
100
124
  /** Generates a `Next` handler to pass to middleware in order to be able to call arbitrary middleware. */
101
125
  declare function noopNext(): Next;
102
126
 
103
- export { type ActorRestartingOptions as A, BRIDGE_RIVET_ERROR_PREFIX as B, INTERNAL_ERROR_CODE as I, RivetError as R, UserError as U, type UserErrorOptions as a, assertUnreachable as b, type ActorSpecifier as c, type BridgeRivetErrorPayload as d, INTERNAL_ERROR_DESCRIPTION as e, type InternalErrorMetadata as f, type RivetErrorLike as g, type RivetErrorOptions as h, USER_ERROR_CODE as i, actorNotFound as j, actorRestarting as k, actorStopping as l, decodeBridgeRivetError as m, noopNext as n, decodeBridgeRivetErrorPayload as o, encodeBridgeRivetError as p, forbiddenError as q, internalError as r, stringifyError as s, invalidEncoding as t, invalidRequest as u, isRivetErrorCode as v, isRivetErrorLike as w, toRivetError as x, unsupportedFeature as y };
127
+ export { type ActorRestartingOptions as A, BRIDGE_RIVET_ERROR_PREFIX as B, toRivetError as C, unsupportedFeature as D, type EncodedBridgeError as E, INTERNAL_ERROR_CODE as I, RivetError as R, UserError as U, type RivetErrorLike as a, type RivetErrorOptions as b, type UserErrorOptions as c, assertUnreachable as d, type ActorSpecifier as e, type BridgeRivetErrorPayload as f, INTERNAL_ERROR_DESCRIPTION as g, type InternalErrorMetadata as h, USER_ERROR_CODE as i, actorNotFound as j, actorRestarting as k, actorStopping as l, decodeBridgeRivetError as m, noopNext as n, decodeBridgeRivetErrorPayload as o, encodeBridgeRivetError as p, encodeErrorForBridge as q, forbiddenError as r, stringifyError as s, internalError as t, invalidEncoding as u, invalidRequest as v, isActorAbortedError as w, isCanonicalStructuredRivetError as x, isRivetErrorCode as y, isRivetErrorLike as z };
@@ -11,6 +11,8 @@ interface RivetErrorOptions extends ErrorOptions {
11
11
  public?: boolean;
12
12
  /** Metadata associated with this error. */
13
13
  metadata?: unknown;
14
+ /** Request identifier used to correlate this error with engine logs. */
15
+ rayId?: string;
14
16
  /** Explicit HTTP status override for router responses. */
15
17
  statusCode?: number;
16
18
  /** Actor context associated with this error. */
@@ -28,6 +30,7 @@ interface RivetErrorLike {
28
30
  code: string;
29
31
  message: string;
30
32
  metadata?: unknown;
33
+ rayId?: string;
31
34
  public?: boolean;
32
35
  statusCode?: number;
33
36
  actor?: ActorSpecifier;
@@ -47,10 +50,12 @@ interface UserErrorOptions extends ErrorOptions {
47
50
  metadata?: unknown;
48
51
  }
49
52
  declare function isRivetErrorLike(error: unknown): error is RivetError | DeconstructedError | RivetErrorLike;
53
+ declare function isActorAbortedError(error: unknown): boolean;
50
54
  declare class RivetError extends Error {
51
55
  __type: "RivetError";
52
56
  public: boolean;
53
57
  metadata?: unknown;
58
+ readonly rayId?: string;
54
59
  statusCode: number;
55
60
  actor?: ActorSpecifier;
56
61
  readonly group: string;
@@ -65,7 +70,25 @@ declare class UserError extends RivetError {
65
70
  constructor(message: string, options?: UserErrorOptions);
66
71
  }
67
72
  declare function toRivetError(error: unknown, fallback?: Partial<RivetErrorLike>): RivetError;
68
- declare function encodeBridgeRivetError(error: RivetErrorLike): string;
73
+ /** A structured error encoded for the bridge to Core. */
74
+ interface EncodedBridgeError {
75
+ readonly encoded: string;
76
+ /** Set when JSON could not encode the metadata, which was dropped. */
77
+ readonly droppedMetadataCause?: unknown;
78
+ }
79
+ /**
80
+ * Encodes a structured error for the bridge to Core. Metadata that JSON cannot
81
+ * encode, such as a `bigint`, is dropped so the error itself still crosses.
82
+ */
83
+ declare function encodeBridgeRivetError(error: RivetErrorLike): EncodedBridgeError;
84
+ /**
85
+ * Encodes an error for the telemetry bridge. A structured error crosses with
86
+ * its group and code. Anything else crosses as text so Core classifies it,
87
+ * which is the same rule that keeps raw messages out of every span.
88
+ */
89
+ declare function encodeErrorForBridge(error: unknown): string;
90
+ /** A `RivetError` instance, or a plain object carrying its full tagged shape. */
91
+ declare function isCanonicalStructuredRivetError(error: unknown): error is RivetErrorLike;
69
92
  declare function decodeBridgeRivetErrorPayload(value: string): BridgeRivetErrorPayload | undefined;
70
93
  declare function decodeBridgeRivetError(value: string): RivetError | undefined;
71
94
  declare function isRivetErrorCode(error: unknown, group: string, code: string): error is RivetError;
@@ -94,10 +117,11 @@ interface DeconstructedError {
94
117
  code: string;
95
118
  message: string;
96
119
  metadata?: unknown;
120
+ rayId?: string;
97
121
  actor?: ActorSpecifier;
98
122
  }
99
123
  declare function stringifyError(error: unknown): string;
100
124
  /** Generates a `Next` handler to pass to middleware in order to be able to call arbitrary middleware. */
101
125
  declare function noopNext(): Next;
102
126
 
103
- export { type ActorRestartingOptions as A, BRIDGE_RIVET_ERROR_PREFIX as B, INTERNAL_ERROR_CODE as I, RivetError as R, UserError as U, type UserErrorOptions as a, assertUnreachable as b, type ActorSpecifier as c, type BridgeRivetErrorPayload as d, INTERNAL_ERROR_DESCRIPTION as e, type InternalErrorMetadata as f, type RivetErrorLike as g, type RivetErrorOptions as h, USER_ERROR_CODE as i, actorNotFound as j, actorRestarting as k, actorStopping as l, decodeBridgeRivetError as m, noopNext as n, decodeBridgeRivetErrorPayload as o, encodeBridgeRivetError as p, forbiddenError as q, internalError as r, stringifyError as s, invalidEncoding as t, invalidRequest as u, isRivetErrorCode as v, isRivetErrorLike as w, toRivetError as x, unsupportedFeature as y };
127
+ export { type ActorRestartingOptions as A, BRIDGE_RIVET_ERROR_PREFIX as B, toRivetError as C, unsupportedFeature as D, type EncodedBridgeError as E, INTERNAL_ERROR_CODE as I, RivetError as R, UserError as U, type RivetErrorLike as a, type RivetErrorOptions as b, type UserErrorOptions as c, assertUnreachable as d, type ActorSpecifier as e, type BridgeRivetErrorPayload as f, INTERNAL_ERROR_DESCRIPTION as g, type InternalErrorMetadata as h, USER_ERROR_CODE as i, actorNotFound as j, actorRestarting as k, actorStopping as l, decodeBridgeRivetError as m, noopNext as n, decodeBridgeRivetErrorPayload as o, encodeBridgeRivetError as p, encodeErrorForBridge as q, forbiddenError as r, stringifyError as s, internalError as t, invalidEncoding as u, invalidRequest as v, isActorAbortedError as w, isCanonicalStructuredRivetError as x, isRivetErrorCode as y, isRivetErrorLike as z };