rivetkit 0.0.0-sqlite-profiling-compat.4a9a623 → 0.0.0-sqlite-sync-3x-release.a00b07f
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.
- package/dist/browser/client.d.ts +1317 -765
- package/dist/browser/client.js +1457 -737
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +252 -129
- package/dist/browser/inspector/client.js +2042 -228
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +6 -2
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +5 -1
- package/dist/tsup/agent-os/index.cjs +3 -2367
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +1 -2277
- package/dist/tsup/agent-os/index.d.ts +1 -2277
- package/dist/tsup/agent-os/index.js +3 -2367
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-7QKCGUTJ.cjs → chunk-2MOLY6AM.cjs} +444 -29
- package/dist/tsup/chunk-2MOLY6AM.cjs.map +1 -0
- package/dist/tsup/{chunk-IICIOTML.js → chunk-3DONDAMG.js} +2 -2
- package/dist/tsup/{chunk-XIX5DOZN.js → chunk-6FEYCVZC.js} +196 -20
- package/dist/tsup/chunk-6FEYCVZC.js.map +1 -0
- package/dist/tsup/chunk-6KXVLIXL.cjs +14 -0
- package/dist/tsup/chunk-6KXVLIXL.cjs.map +1 -0
- package/dist/tsup/chunk-73RNTXHB.cjs +243 -0
- package/dist/tsup/chunk-73RNTXHB.cjs.map +1 -0
- package/dist/tsup/{chunk-HXUEHHJF.js → chunk-A2CF6PFH.js} +19 -11
- package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
- package/dist/tsup/{chunk-75UE45DE.js → chunk-BRH4PQS5.js} +436 -21
- package/dist/tsup/chunk-BRH4PQS5.js.map +1 -0
- package/dist/tsup/{chunk-2WMYYG4R.cjs → chunk-BTSDFFDC.cjs} +18 -11
- package/dist/tsup/chunk-BTSDFFDC.cjs.map +1 -0
- package/dist/tsup/{chunk-RIT7N3TX.js → chunk-D5WUPE47.js} +50 -3
- package/dist/tsup/chunk-D5WUPE47.js.map +1 -0
- package/dist/tsup/{chunk-4PX3ZKJR.js → chunk-DJUBJQEQ.js} +3 -3
- package/dist/tsup/chunk-DJUBJQEQ.js.map +1 -0
- package/dist/tsup/{chunk-3MHDOUD7.cjs → chunk-HDVZ6YZG.cjs} +197 -21
- package/dist/tsup/chunk-HDVZ6YZG.cjs.map +1 -0
- package/dist/tsup/{chunk-JZ7TWV65.js → chunk-JTHHCZCZ.js} +24 -1
- package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
- package/dist/tsup/{chunk-ND567FR5.cjs → chunk-JUHXV3HF.cjs} +3 -3
- package/dist/tsup/chunk-JUHXV3HF.cjs.map +1 -0
- package/dist/tsup/chunk-JUWMP5O3.js +14 -0
- package/dist/tsup/chunk-JUWMP5O3.js.map +1 -0
- package/dist/tsup/{chunk-ZA7FLHKH.cjs → chunk-KVFIONKQ.cjs} +25 -2
- package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
- package/dist/tsup/{chunk-4FC7TVS6.cjs → chunk-MGI2VVF6.cjs} +39 -7
- package/dist/tsup/chunk-MGI2VVF6.cjs.map +1 -0
- package/dist/tsup/{chunk-NHUTYWKU.cjs → chunk-OTVJYZ2L.cjs} +1139 -470
- package/dist/tsup/chunk-OTVJYZ2L.cjs.map +1 -0
- package/dist/tsup/{chunk-VE2X4KMG.cjs → chunk-RTWH3AX3.cjs} +18 -10
- package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
- package/dist/tsup/{chunk-QAVN4QNO.cjs → chunk-TM76Z7XT.cjs} +7 -7
- package/dist/tsup/chunk-TM76Z7XT.cjs.map +1 -0
- package/dist/tsup/{chunk-AGDY6TKH.js → chunk-TRUHDXOU.js} +1023 -354
- package/dist/tsup/chunk-TRUHDXOU.js.map +1 -0
- package/dist/tsup/{chunk-XFYEVYHG.js → chunk-TSQTI6H6.js} +16 -9
- package/dist/tsup/chunk-TSQTI6H6.js.map +1 -0
- package/dist/tsup/{chunk-2CICCOBL.cjs → chunk-Z7E2G3JZ.cjs} +52 -5
- package/dist/tsup/chunk-Z7E2G3JZ.cjs.map +1 -0
- package/dist/tsup/{chunk-ZZ3WBRPD.js → chunk-ZOVJDAOW.js} +38 -6
- package/dist/tsup/chunk-ZOVJDAOW.js.map +1 -0
- package/dist/tsup/chunk-ZYK4B5WV.js +243 -0
- package/dist/tsup/chunk-ZYK4B5WV.js.map +1 -0
- package/dist/tsup/client/mod.cjs +8 -9
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +32 -6
- package/dist/tsup/client/mod.d.ts +32 -6
- package/dist/tsup/client/mod.js +7 -8
- package/dist/tsup/common/log.cjs +5 -3
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.d.cts +5 -1
- package/dist/tsup/common/log.d.ts +5 -1
- package/dist/tsup/common/log.js +6 -4
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.cjs.map +1 -1
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-BR1Nn0QQ.d.ts → config-B4erdavw.d.ts} +571 -65
- package/dist/tsup/{config-B0LNDrLY.d.ts → config-BfG1qpYz.d.cts} +80 -14
- package/dist/tsup/{config-B0LNDrLY.d.cts → config-BfG1qpYz.d.ts} +80 -14
- package/dist/tsup/{config-tCvkwzyN.d.cts → config-DK144OAw.d.cts} +571 -65
- package/dist/tsup/{context-oc9zhA3x.d.ts → context-Cvnf3BRe.d.cts} +3 -2
- package/dist/tsup/{context-D4WDwf9m.d.cts → context-Oxi6YWcG.d.ts} +3 -2
- package/dist/tsup/db/drizzle.cjs +127 -67
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +8 -4
- package/dist/tsup/db/drizzle.d.ts +8 -4
- package/dist/tsup/db/drizzle.js +127 -67
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +6 -126
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.d.cts +8 -4
- package/dist/tsup/db/mod.d.ts +8 -4
- package/dist/tsup/db/mod.js +5 -125
- package/dist/tsup/db/mod.js.map +1 -1
- package/dist/tsup/dynamic/mod.cjs +2 -2
- package/dist/tsup/dynamic/mod.cjs.map +1 -1
- package/dist/tsup/dynamic/mod.d.cts +6 -4
- package/dist/tsup/dynamic/mod.d.ts +6 -4
- package/dist/tsup/dynamic/mod.js +1 -1
- package/dist/tsup/inspector/mod.cjs +47 -12
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +26 -136
- package/dist/tsup/inspector/mod.d.ts +26 -136
- package/dist/tsup/inspector/mod.js +46 -11
- package/dist/tsup/inspector/mod.js.map +1 -1
- package/dist/tsup/inspector/workflow.cjs +21 -0
- package/dist/tsup/inspector/workflow.cjs.map +1 -0
- package/dist/tsup/inspector/workflow.d.cts +144 -0
- package/dist/tsup/inspector/workflow.d.ts +144 -0
- package/dist/tsup/inspector/workflow.js +21 -0
- package/dist/tsup/inspector/workflow.js.map +1 -0
- package/dist/tsup/inspector-tab/mod.cjs +2 -13
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -1
- package/dist/tsup/inspector-tab/mod.d.cts +9 -17
- package/dist/tsup/inspector-tab/mod.d.ts +9 -17
- package/dist/tsup/inspector-tab/mod.js +1 -12
- package/dist/tsup/inspector-tab/mod.js.map +1 -1
- package/dist/tsup/mod.cjs +2724 -611
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +9 -7
- package/dist/tsup/mod.d.ts +9 -7
- package/dist/tsup/mod.js +2641 -528
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +19 -17
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +6 -4
- package/dist/tsup/test/mod.d.ts +6 -4
- package/dist/tsup/test/mod.js +18 -16
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/unstable/migrations.cjs +101 -0
- package/dist/tsup/unstable/migrations.cjs.map +1 -0
- package/dist/tsup/unstable/migrations.d.cts +29 -0
- package/dist/tsup/unstable/migrations.d.ts +29 -0
- package/dist/tsup/unstable/migrations.js +101 -0
- package/dist/tsup/unstable/migrations.js.map +1 -0
- package/dist/tsup/{utils-CqDnC_PS.d.cts → utils-3rsE0JvI.d.cts} +25 -2
- package/dist/tsup/{utils-CqDnC_PS.d.ts → utils-3rsE0JvI.d.ts} +25 -2
- package/dist/tsup/utils-C1O-SklO.d.ts +162 -0
- package/dist/tsup/utils-C6b0aYUM.d.cts +162 -0
- package/dist/tsup/utils.cjs +7 -3
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +4 -147
- package/dist/tsup/utils.d.ts +4 -147
- package/dist/tsup/utils.js +6 -2
- package/dist/tsup/workflow/mod.cjs +260 -200
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +8 -6
- package/dist/tsup/workflow/mod.d.ts +8 -6
- package/dist/tsup/workflow/mod.js +249 -189
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +34 -14
- package/src/actor/actions.ts +155 -0
- package/src/actor/config.ts +403 -43
- package/src/actor/definition.ts +26 -7
- package/src/actor/errors.ts +87 -5
- package/src/actor/keys.ts +86 -0
- package/src/actor/mod.ts +15 -1
- package/src/actor/tracing.ts +28 -0
- package/src/agent-os/index.ts +5 -65
- package/src/client/actor-common.ts +8 -15
- package/src/client/actor-conn.ts +135 -8
- package/src/client/actor-handle.ts +180 -42
- package/src/client/actor-query.ts +8 -1
- package/src/client/auth.ts +37 -0
- package/src/client/client.ts +89 -21
- package/src/client/config.ts +27 -2
- package/src/client/errors.ts +2 -1
- package/src/client/lifecycle-errors.ts +16 -1
- package/src/client/mod.ts +9 -0
- package/src/client/outbound-telemetry.ts +66 -0
- package/src/client/query.ts +2 -0
- package/src/client/queue.ts +3 -0
- package/src/client/raw-utils.ts +37 -8
- package/src/client/resolve-gateway-target.ts +2 -0
- package/src/client/retry-budget.ts +78 -0
- package/src/client/token-provider.ts +93 -0
- package/src/client/utils.ts +16 -2
- package/src/common/actor-router-consts.ts +5 -0
- package/src/common/actor-telemetry-context.ts +19 -0
- package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +848 -0
- package/src/common/bare/generated/inspector/v5.ts +1016 -0
- package/src/common/bare/generated/inspector/v6.ts +1367 -0
- package/src/common/bare/transport/v1.ts +36 -0
- package/src/common/database/config.ts +108 -15
- package/src/common/database/mod.ts +247 -76
- package/src/common/database/native-database.ts +433 -23
- package/src/common/database/shared.ts +24 -0
- package/src/common/encoding.ts +31 -21
- package/src/common/fetch-like.ts +63 -0
- package/src/common/inspector-transport.ts +12 -2
- package/src/common/log.ts +14 -8
- package/src/common/otel-context.ts +99 -0
- package/src/common/router.ts +1 -1
- package/src/common/utils.ts +7 -19
- package/src/db/drizzle.ts +182 -80
- package/src/db/mod.ts +2 -0
- package/src/dynamic/isolate-runtime.ts +0 -2
- package/src/engine-api/actors.ts +3 -3
- package/src/engine-client/actor-http-client.ts +29 -20
- package/src/engine-client/actor-websocket-client.ts +6 -3
- package/src/engine-client/api-endpoints.ts +72 -14
- package/src/engine-client/driver.ts +8 -15
- package/src/engine-client/mod.ts +248 -112
- package/src/inspector/client.browser.ts +134 -16
- package/src/inspector/mod.ts +1 -1
- package/src/inspector/workflow.ts +61 -0
- package/src/inspector-tab/mod.ts +1 -15
- package/src/registry/config/envoy.ts +2 -18
- package/src/registry/config/index.ts +53 -61
- package/src/registry/index.ts +311 -21
- package/src/registry/napi-runtime.ts +583 -39
- package/src/registry/native-http.ts +225 -0
- package/src/registry/native.ts +1365 -414
- package/src/registry/run-handler-coordinator.ts +219 -0
- package/src/registry/runtime.ts +372 -7
- package/src/registry/wasm-runtime.ts +490 -21
- package/src/registry/write-through-proxy.ts +101 -0
- package/src/test/mod.ts +1 -19
- package/src/test/ready.ts +22 -0
- package/src/unstable/migrations.ts +141 -0
- package/src/utils/env-vars.ts +15 -6
- package/src/utils/node.ts +44 -28
- package/src/utils.ts +3 -0
- package/src/workflow/context.ts +9 -27
- package/src/workflow/driver.ts +253 -116
- package/src/workflow/inspector.ts +23 -24
- package/src/workflow/mod.ts +50 -72
- package/dist/tsup/chunk-2CICCOBL.cjs.map +0 -1
- package/dist/tsup/chunk-2WMYYG4R.cjs.map +0 -1
- package/dist/tsup/chunk-3MHDOUD7.cjs.map +0 -1
- package/dist/tsup/chunk-4FC7TVS6.cjs.map +0 -1
- package/dist/tsup/chunk-4PX3ZKJR.js.map +0 -1
- package/dist/tsup/chunk-75UE45DE.js.map +0 -1
- package/dist/tsup/chunk-7QKCGUTJ.cjs.map +0 -1
- package/dist/tsup/chunk-AGDY6TKH.js.map +0 -1
- package/dist/tsup/chunk-HXUEHHJF.js.map +0 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +0 -1
- package/dist/tsup/chunk-ND567FR5.cjs.map +0 -1
- package/dist/tsup/chunk-NHUTYWKU.cjs.map +0 -1
- package/dist/tsup/chunk-QAVN4QNO.cjs.map +0 -1
- package/dist/tsup/chunk-RIT7N3TX.js.map +0 -1
- package/dist/tsup/chunk-RV5MAFDT.cjs +0 -382
- package/dist/tsup/chunk-RV5MAFDT.cjs.map +0 -1
- package/dist/tsup/chunk-VE2X4KMG.cjs.map +0 -1
- package/dist/tsup/chunk-XFYEVYHG.js.map +0 -1
- package/dist/tsup/chunk-XHGDS3DZ.js +0 -382
- package/dist/tsup/chunk-XHGDS3DZ.js.map +0 -1
- package/dist/tsup/chunk-XIX5DOZN.js.map +0 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +0 -1
- package/dist/tsup/chunk-ZZ3WBRPD.js.map +0 -1
- package/src/actor/driver.ts +0 -141
- package/src/actor/instance/mod.ts +0 -2484
- package/src/actor/keys.test.ts +0 -275
- package/src/actor/utils.test.ts +0 -48
- package/src/agent-os/actor/cron.ts +0 -84
- package/src/agent-os/actor/db.ts +0 -54
- package/src/agent-os/actor/filesystem.ts +0 -131
- package/src/agent-os/actor/index.ts +0 -285
- package/src/agent-os/actor/network.ts +0 -58
- package/src/agent-os/actor/preview.ts +0 -190
- package/src/agent-os/actor/process.ts +0 -177
- package/src/agent-os/actor/session.ts +0 -518
- package/src/agent-os/actor/shell.ts +0 -60
- package/src/agent-os/config.ts +0 -79
- package/src/agent-os/fs/database-vfs.ts +0 -624
- package/src/agent-os/types.ts +0 -148
- package/src/client/test.ts +0 -44
- package/src/common/database/mod.test.ts +0 -137
- package/src/common/database/native-database.test.ts +0 -211
- package/src/common/inline-websocket-adapter.test.ts +0 -51
- package/src/drivers/engine/actor-driver.ts +0 -2473
- package/src/registry/process-metrics.ts +0 -250
- package/src/registry/runtime.test.ts +0 -50
- package/src/utils/endpoint-parser.test.ts +0 -206
- package/src/utils.test.ts +0 -34
- /package/dist/tsup/{chunk-IICIOTML.js.map → chunk-3DONDAMG.js.map} +0 -0
package/dist/tsup/test/mod.cjs
CHANGED
|
@@ -1,41 +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
|
|
3
|
+
var _chunkTM76Z7XTcjs = require('../chunk-TM76Z7XT.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunkOTVJYZ2Lcjs = require('../chunk-OTVJYZ2L.cjs');
|
|
7
|
+
require('../chunk-RTWH3AX3.cjs');
|
|
8
|
+
require('../chunk-JUHXV3HF.cjs');
|
|
9
|
+
require('../chunk-KVFIONKQ.cjs');
|
|
10
|
+
require('../chunk-2MOLY6AM.cjs');
|
|
11
|
+
require('../chunk-MGI2VVF6.cjs');
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
require('../chunk-VE2X4KMG.cjs');
|
|
9
|
-
require('../chunk-RV5MAFDT.cjs');
|
|
10
|
-
require('../chunk-ZA7FLHKH.cjs');
|
|
11
|
-
require('../chunk-ND567FR5.cjs');
|
|
12
|
-
require('../chunk-7QKCGUTJ.cjs');
|
|
13
|
-
require('../chunk-4FC7TVS6.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 = _chunkNHUTYWKUcjs.convertRegistryConfigToClientConfig.call(void 0,
|
|
19
|
-
registry.parseConfig()
|
|
20
|
-
);
|
|
21
16
|
await _pretry2.default.call(void 0,
|
|
22
17
|
async () => {
|
|
23
|
-
await
|
|
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
24
|
},
|
|
25
25
|
{
|
|
26
|
-
retries:
|
|
26
|
+
retries: 120,
|
|
27
27
|
minTimeout: 50,
|
|
28
28
|
maxTimeout: 250
|
|
29
29
|
}
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
// src/test/mod.ts
|
|
32
34
|
async function setupTest(c, registry) {
|
|
33
35
|
registry.config.test = { ...registry.config.test, enabled: true };
|
|
34
36
|
registry.config.noWelcome = true;
|
|
35
37
|
registry.start();
|
|
36
38
|
await waitForRegistryReady(registry);
|
|
37
|
-
const client =
|
|
38
|
-
...
|
|
39
|
+
const client = _chunkTM76Z7XTcjs.createClient.call(void 0, {
|
|
40
|
+
..._chunkOTVJYZ2Lcjs.convertRegistryConfigToClientConfig.call(void 0, registry.parseConfig()),
|
|
39
41
|
disableMetadataLookup: false
|
|
40
42
|
});
|
|
41
43
|
c.onTestFinished(async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/
|
|
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"]}
|
package/dist/tsup/test/mod.d.cts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { TestContext } from 'vitest';
|
|
2
|
-
import {
|
|
2
|
+
import { aI as Registry, a6 as Client } from '../config-DK144OAw.cjs';
|
|
3
3
|
import 'zod/v4';
|
|
4
|
-
import '../config-
|
|
4
|
+
import '../config-BfG1qpYz.cjs';
|
|
5
5
|
import '@rivetkit/rivetkit-wasm';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'pino';
|
|
8
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-CqDnC_PS.cjs';
|
|
14
|
+
import '../utils-3rsE0JvI.cjs';
|
|
13
15
|
import 'hono/utils/http-status';
|
|
14
16
|
|
|
15
17
|
interface SetupTestResult<A extends Registry<any>> {
|
package/dist/tsup/test/mod.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { TestContext } from 'vitest';
|
|
2
|
-
import {
|
|
2
|
+
import { aI as Registry, a6 as Client } from '../config-B4erdavw.js';
|
|
3
3
|
import 'zod/v4';
|
|
4
|
-
import '../config-
|
|
4
|
+
import '../config-BfG1qpYz.js';
|
|
5
5
|
import '@rivetkit/rivetkit-wasm';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'pino';
|
|
8
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-CqDnC_PS.js';
|
|
14
|
+
import '../utils-3rsE0JvI.js';
|
|
13
15
|
import 'hono/utils/http-status';
|
|
14
16
|
|
|
15
17
|
interface SetupTestResult<A extends Registry<any>> {
|
package/dist/tsup/test/mod.js
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createClient
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-DJUBJQEQ.js";
|
|
4
4
|
import {
|
|
5
|
-
convertRegistryConfigToClientConfig
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-75UE45DE.js";
|
|
13
|
-
import "../chunk-ZZ3WBRPD.js";
|
|
5
|
+
convertRegistryConfigToClientConfig
|
|
6
|
+
} from "../chunk-TRUHDXOU.js";
|
|
7
|
+
import "../chunk-A2CF6PFH.js";
|
|
8
|
+
import "../chunk-3DONDAMG.js";
|
|
9
|
+
import "../chunk-JTHHCZCZ.js";
|
|
10
|
+
import "../chunk-BRH4PQS5.js";
|
|
11
|
+
import "../chunk-ZOVJDAOW.js";
|
|
14
12
|
|
|
15
|
-
// src/test/
|
|
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()
|
|
20
|
-
);
|
|
21
16
|
await pRetry(
|
|
22
17
|
async () => {
|
|
23
|
-
await
|
|
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
24
|
},
|
|
25
25
|
{
|
|
26
|
-
retries:
|
|
26
|
+
retries: 120,
|
|
27
27
|
minTimeout: 50,
|
|
28
28
|
maxTimeout: 250
|
|
29
29
|
}
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
// src/test/mod.ts
|
|
32
34
|
async function setupTest(c, registry) {
|
|
33
35
|
registry.config.test = { ...registry.config.test, enabled: true };
|
|
34
36
|
registry.config.noWelcome = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/test/mod.ts"],"sourcesContent":["import pRetry from \"p-retry\";\nimport type {
|
|
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-BfG1qpYz.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-BfG1qpYz.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;
|
|
@@ -52,6 +55,7 @@ declare class RivetError extends Error {
|
|
|
52
55
|
__type: "RivetError";
|
|
53
56
|
public: boolean;
|
|
54
57
|
metadata?: unknown;
|
|
58
|
+
readonly rayId?: string;
|
|
55
59
|
statusCode: number;
|
|
56
60
|
actor?: ActorSpecifier;
|
|
57
61
|
readonly group: string;
|
|
@@ -66,7 +70,25 @@ declare class UserError extends RivetError {
|
|
|
66
70
|
constructor(message: string, options?: UserErrorOptions);
|
|
67
71
|
}
|
|
68
72
|
declare function toRivetError(error: unknown, fallback?: Partial<RivetErrorLike>): RivetError;
|
|
69
|
-
|
|
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;
|
|
70
92
|
declare function decodeBridgeRivetErrorPayload(value: string): BridgeRivetErrorPayload | undefined;
|
|
71
93
|
declare function decodeBridgeRivetError(value: string): RivetError | undefined;
|
|
72
94
|
declare function isRivetErrorCode(error: unknown, group: string, code: string): error is RivetError;
|
|
@@ -95,10 +117,11 @@ interface DeconstructedError {
|
|
|
95
117
|
code: string;
|
|
96
118
|
message: string;
|
|
97
119
|
metadata?: unknown;
|
|
120
|
+
rayId?: string;
|
|
98
121
|
actor?: ActorSpecifier;
|
|
99
122
|
}
|
|
100
123
|
declare function stringifyError(error: unknown): string;
|
|
101
124
|
/** Generates a `Next` handler to pass to middleware in order to be able to call arbitrary middleware. */
|
|
102
125
|
declare function noopNext(): Next;
|
|
103
126
|
|
|
104
|
-
export { type ActorRestartingOptions as A, BRIDGE_RIVET_ERROR_PREFIX as B, 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,
|
|
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;
|
|
@@ -52,6 +55,7 @@ declare class RivetError extends Error {
|
|
|
52
55
|
__type: "RivetError";
|
|
53
56
|
public: boolean;
|
|
54
57
|
metadata?: unknown;
|
|
58
|
+
readonly rayId?: string;
|
|
55
59
|
statusCode: number;
|
|
56
60
|
actor?: ActorSpecifier;
|
|
57
61
|
readonly group: string;
|
|
@@ -66,7 +70,25 @@ declare class UserError extends RivetError {
|
|
|
66
70
|
constructor(message: string, options?: UserErrorOptions);
|
|
67
71
|
}
|
|
68
72
|
declare function toRivetError(error: unknown, fallback?: Partial<RivetErrorLike>): RivetError;
|
|
69
|
-
|
|
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;
|
|
70
92
|
declare function decodeBridgeRivetErrorPayload(value: string): BridgeRivetErrorPayload | undefined;
|
|
71
93
|
declare function decodeBridgeRivetError(value: string): RivetError | undefined;
|
|
72
94
|
declare function isRivetErrorCode(error: unknown, group: string, code: string): error is RivetError;
|
|
@@ -95,10 +117,11 @@ interface DeconstructedError {
|
|
|
95
117
|
code: string;
|
|
96
118
|
message: string;
|
|
97
119
|
metadata?: unknown;
|
|
120
|
+
rayId?: string;
|
|
98
121
|
actor?: ActorSpecifier;
|
|
99
122
|
}
|
|
100
123
|
declare function stringifyError(error: unknown): string;
|
|
101
124
|
/** Generates a `Next` handler to pass to middleware in order to be able to call arbitrary middleware. */
|
|
102
125
|
declare function noopNext(): Next;
|
|
103
126
|
|
|
104
|
-
export { type ActorRestartingOptions as A, BRIDGE_RIVET_ERROR_PREFIX as B, 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,
|
|
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 };
|