rivetkit 2.1.5 → 2.1.6-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/client.d.ts +593 -588
- package/dist/browser/client.js +215 -35
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +109 -10
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/inspector.tar.gz +0 -0
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/{actor-router-consts-D29T1Z-K.d.cts → actor-router-consts-DU-1IdQj.d.cts} +1 -1
- package/dist/tsup/{actor-router-consts-D29T1Z-K.d.ts → actor-router-consts-DU-1IdQj.d.ts} +1 -1
- package/dist/tsup/chunk-2ELYUO6C.cjs +112 -0
- package/dist/tsup/chunk-2ELYUO6C.cjs.map +1 -0
- package/dist/tsup/chunk-2LY7RW3Y.cjs +2316 -0
- package/dist/tsup/chunk-2LY7RW3Y.cjs.map +1 -0
- package/dist/tsup/{chunk-L47L3ZWJ.cjs → chunk-6G7ZNM27.cjs} +11 -6
- package/dist/tsup/chunk-6G7ZNM27.cjs.map +1 -0
- package/dist/tsup/{chunk-PB5AEMKQ.cjs → chunk-A4KEUCB6.cjs} +84 -34
- package/dist/tsup/chunk-A4KEUCB6.cjs.map +1 -0
- package/dist/tsup/{chunk-7HTNH26M.js → chunk-AKUJ5OTO.js} +11 -6
- package/dist/tsup/chunk-AKUJ5OTO.js.map +1 -0
- package/dist/tsup/{chunk-TADUYCHF.js → chunk-C22JYHVT.js} +77 -27
- package/dist/tsup/chunk-C22JYHVT.js.map +1 -0
- package/dist/tsup/chunk-C4EB42ET.js +1459 -0
- package/dist/tsup/chunk-C4EB42ET.js.map +1 -0
- package/dist/tsup/chunk-CGGGBIDP.cjs +1459 -0
- package/dist/tsup/chunk-CGGGBIDP.cjs.map +1 -0
- package/dist/tsup/chunk-CMQPDBBR.cjs +1486 -0
- package/dist/tsup/chunk-CMQPDBBR.cjs.map +1 -0
- package/dist/tsup/{chunk-GQGRQDRL.cjs → chunk-DH6UINWA.cjs} +4 -4
- package/dist/tsup/{chunk-GQGRQDRL.cjs.map → chunk-DH6UINWA.cjs.map} +1 -1
- package/dist/tsup/chunk-DK46YYCJ.js +1486 -0
- package/dist/tsup/chunk-DK46YYCJ.js.map +1 -0
- package/dist/tsup/chunk-EGWXXBZV.js +2316 -0
- package/dist/tsup/chunk-EGWXXBZV.js.map +1 -0
- package/dist/tsup/{chunk-S662Y6ZU.js → chunk-EONWXYMN.js} +2 -2
- package/dist/tsup/{chunk-N4KRDJ56.js → chunk-GFGRBYO2.js} +35 -6
- package/dist/tsup/chunk-GFGRBYO2.js.map +1 -0
- package/dist/tsup/{chunk-IIJNPVPQ.cjs → chunk-GUHXWPGB.cjs} +1515 -1479
- package/dist/tsup/chunk-GUHXWPGB.cjs.map +1 -0
- package/dist/tsup/{chunk-TI5PXQGG.cjs → chunk-HNE2AK6C.cjs} +2375 -3713
- package/dist/tsup/chunk-HNE2AK6C.cjs.map +1 -0
- package/dist/tsup/{chunk-2OK7S6QF.js → chunk-I5I6OALK.js} +2 -2
- package/dist/tsup/chunk-IHQAF2HV.cjs +23 -0
- package/dist/tsup/chunk-IHQAF2HV.cjs.map +1 -0
- package/dist/tsup/{chunk-U5SMSA27.cjs → chunk-JJNZQDUN.cjs} +667 -2517
- package/dist/tsup/chunk-JJNZQDUN.cjs.map +1 -0
- package/dist/tsup/{chunk-ZPWOYQHN.js → chunk-JJSPHLJN.js} +219 -287
- package/dist/tsup/chunk-JJSPHLJN.js.map +1 -0
- package/dist/tsup/chunk-JRKPV5NJ.js +481 -0
- package/dist/tsup/chunk-JRKPV5NJ.js.map +1 -0
- package/dist/tsup/{chunk-VKVNIQRQ.js → chunk-K7MVU5SI.js} +36 -41
- package/dist/tsup/chunk-K7MVU5SI.js.map +1 -0
- package/dist/tsup/{chunk-KJSYAUOM.js → chunk-MLK3GY6P.js} +43 -27
- package/dist/tsup/chunk-MLK3GY6P.js.map +1 -0
- package/dist/tsup/{chunk-HYPIHCDT.cjs → chunk-MPLMTJY5.cjs} +123 -23
- package/dist/tsup/chunk-MPLMTJY5.cjs.map +1 -0
- package/dist/tsup/{chunk-MIX2KB6U.js → chunk-PQWI44WD.js} +1755 -3093
- package/dist/tsup/chunk-PQWI44WD.js.map +1 -0
- package/dist/tsup/{chunk-SR3KQE7Q.cjs → chunk-SQFCIDCG.cjs} +35 -6
- package/dist/tsup/chunk-SQFCIDCG.cjs.map +1 -0
- package/dist/tsup/{chunk-WY2SHWXQ.js → chunk-SVHJSM2E.js} +110 -24
- package/dist/tsup/chunk-SVHJSM2E.js.map +1 -0
- package/dist/tsup/chunk-T5KYKM6R.js +49 -0
- package/dist/tsup/chunk-T5KYKM6R.js.map +1 -0
- package/dist/tsup/{chunk-7WF2QSIC.cjs → chunk-TJ7DKW6F.cjs} +123 -37
- package/dist/tsup/chunk-TJ7DKW6F.cjs.map +1 -0
- package/dist/tsup/chunk-UQZRMTM3.js +23 -0
- package/dist/tsup/chunk-UQZRMTM3.js.map +1 -0
- package/dist/tsup/{chunk-JC6BEPE7.cjs → chunk-V3JSZR5P.cjs} +3 -3
- package/dist/tsup/{chunk-JC6BEPE7.cjs.map → chunk-V3JSZR5P.cjs.map} +1 -1
- package/dist/tsup/{chunk-OAXJWGMU.cjs → chunk-VBR35EQF.cjs} +271 -339
- package/dist/tsup/chunk-VBR35EQF.cjs.map +1 -0
- package/dist/tsup/{chunk-EIATSBYZ.js → chunk-VWYO36X4.js} +117 -17
- package/dist/tsup/chunk-VWYO36X4.js.map +1 -0
- package/dist/tsup/{chunk-JPXO2H55.js → chunk-WW27B6DM.js} +1452 -1416
- package/dist/tsup/chunk-WW27B6DM.js.map +1 -0
- package/dist/tsup/chunk-YAE3MEJM.cjs +49 -0
- package/dist/tsup/chunk-YAE3MEJM.cjs.map +1 -0
- package/dist/tsup/{chunk-SRIM3GHD.js → chunk-YGYGANCA.js} +473 -2323
- package/dist/tsup/chunk-YGYGANCA.js.map +1 -0
- package/dist/tsup/chunk-YZJWZBY5.cjs +481 -0
- package/dist/tsup/chunk-YZJWZBY5.cjs.map +1 -0
- package/dist/tsup/{chunk-ZFY5J2EP.cjs → chunk-ZZLJ5TSM.cjs} +39 -44
- package/dist/tsup/chunk-ZZLJ5TSM.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +10 -7
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +6 -6
- package/dist/tsup/client/mod.d.ts +6 -6
- package/dist/tsup/client/mod.js +11 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-Qj-zLJPc.d.ts → config-C2Wwnc69.d.ts} +142 -208
- package/dist/tsup/{config-BiNoIHRs.d.ts → config-DROwzBLT.d.cts} +82 -6
- package/dist/tsup/{config-BiNoIHRs.d.cts → config-DROwzBLT.d.ts} +82 -6
- package/dist/tsup/{config-iPj5l1bL.d.cts → config-ehT-_3BB.d.cts} +142 -208
- package/dist/tsup/{context-DzvH1PBK.d.cts → context-DGMJuAyc.d.ts} +16 -3
- package/dist/tsup/{context-CQCMuHND.d.ts → context-Dpp2RJbW.d.cts} +16 -3
- package/dist/tsup/db/drizzle/mod.cjs +3 -3
- package/dist/tsup/db/drizzle/mod.d.cts +1 -1
- package/dist/tsup/db/drizzle/mod.d.ts +1 -1
- package/dist/tsup/db/drizzle/mod.js +2 -2
- package/dist/tsup/db/mod.cjs +3 -3
- package/dist/tsup/db/mod.d.cts +1 -1
- package/dist/tsup/db/mod.d.ts +1 -1
- package/dist/tsup/db/mod.js +2 -2
- package/dist/tsup/{driver-Jo8v-kbU.d.ts → driver-CYZP9QYo.d.ts} +1 -1
- package/dist/tsup/{driver-iV8J-WMv.d.cts → driver-CoTFpipv.d.cts} +1 -1
- package/dist/tsup/driver-helpers/mod.cjs +7 -5
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +17 -18
- package/dist/tsup/driver-helpers/mod.d.ts +17 -18
- package/dist/tsup/driver-helpers/mod.js +11 -9
- package/dist/tsup/driver-test-suite/mod.cjs +1275 -228
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +6 -5
- package/dist/tsup/driver-test-suite/mod.d.ts +6 -5
- package/dist/tsup/driver-test-suite/mod.js +1581 -534
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +4 -4
- package/dist/tsup/inspector/mod.js +3 -3
- package/dist/tsup/mod.cjs +15 -9
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +9 -9
- package/dist/tsup/mod.d.ts +9 -9
- package/dist/tsup/mod.js +19 -13
- package/dist/tsup/sandbox/client.cjs +28 -0
- package/dist/tsup/sandbox/client.cjs.map +1 -0
- package/dist/tsup/sandbox/client.d.cts +88 -0
- package/dist/tsup/sandbox/client.d.ts +88 -0
- package/dist/tsup/sandbox/client.js +28 -0
- package/dist/tsup/sandbox/client.js.map +1 -0
- package/dist/tsup/sandbox/index.cjs +761 -0
- package/dist/tsup/sandbox/index.cjs.map +1 -0
- package/dist/tsup/sandbox/index.d.cts +120 -0
- package/dist/tsup/sandbox/index.d.ts +120 -0
- package/dist/tsup/sandbox/index.js +761 -0
- package/dist/tsup/sandbox/index.js.map +1 -0
- package/dist/tsup/sandbox/providers/computesdk.cjs +3 -0
- package/dist/tsup/sandbox/providers/computesdk.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/computesdk.d.cts +7 -0
- package/dist/tsup/sandbox/providers/computesdk.d.ts +7 -0
- package/dist/tsup/sandbox/providers/computesdk.js +3 -0
- package/dist/tsup/sandbox/providers/computesdk.js.map +1 -0
- package/dist/tsup/sandbox/providers/daytona.cjs +3 -0
- package/dist/tsup/sandbox/providers/daytona.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/daytona.d.cts +1 -0
- package/dist/tsup/sandbox/providers/daytona.d.ts +1 -0
- package/dist/tsup/sandbox/providers/daytona.js +3 -0
- package/dist/tsup/sandbox/providers/daytona.js.map +1 -0
- package/dist/tsup/sandbox/providers/docker.cjs +3 -0
- package/dist/tsup/sandbox/providers/docker.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/docker.d.cts +1 -0
- package/dist/tsup/sandbox/providers/docker.d.ts +1 -0
- package/dist/tsup/sandbox/providers/docker.js +3 -0
- package/dist/tsup/sandbox/providers/docker.js.map +1 -0
- package/dist/tsup/sandbox/providers/e2b.cjs +3 -0
- package/dist/tsup/sandbox/providers/e2b.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/e2b.d.cts +1 -0
- package/dist/tsup/sandbox/providers/e2b.d.ts +1 -0
- package/dist/tsup/sandbox/providers/e2b.js +3 -0
- package/dist/tsup/sandbox/providers/e2b.js.map +1 -0
- package/dist/tsup/sandbox/providers/local.cjs +3 -0
- package/dist/tsup/sandbox/providers/local.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/local.d.cts +1 -0
- package/dist/tsup/sandbox/providers/local.d.ts +1 -0
- package/dist/tsup/sandbox/providers/local.js +3 -0
- package/dist/tsup/sandbox/providers/local.js.map +1 -0
- package/dist/tsup/sandbox/providers/modal.cjs +3 -0
- package/dist/tsup/sandbox/providers/modal.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/modal.d.cts +1 -0
- package/dist/tsup/sandbox/providers/modal.d.ts +1 -0
- package/dist/tsup/sandbox/providers/modal.js +3 -0
- package/dist/tsup/sandbox/providers/modal.js.map +1 -0
- package/dist/tsup/sandbox/providers/vercel.cjs +3 -0
- package/dist/tsup/sandbox/providers/vercel.cjs.map +1 -0
- package/dist/tsup/sandbox/providers/vercel.d.cts +1 -0
- package/dist/tsup/sandbox/providers/vercel.d.ts +1 -0
- package/dist/tsup/sandbox/providers/vercel.js +3 -0
- package/dist/tsup/sandbox/providers/vercel.js.map +1 -0
- package/dist/tsup/serve-test-suite/mod.cjs +451 -327
- package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/serve-test-suite/mod.js +362 -238
- package/dist/tsup/serve-test-suite/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +17 -14
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +4 -4
- package/dist/tsup/test/mod.d.ts +4 -4
- package/dist/tsup/test/mod.js +14 -11
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +6 -6
- package/dist/tsup/workflow/mod.d.cts +13 -9
- package/dist/tsup/workflow/mod.d.ts +13 -9
- package/dist/tsup/workflow/mod.js +5 -5
- package/package.json +114 -15
- package/src/actor/config.ts +94 -88
- package/src/actor/conn/drivers/websocket.ts +2 -1
- package/src/actor/contexts/base/actor.ts +27 -4
- package/src/actor/database.ts +6 -1
- package/src/actor/driver.ts +27 -8
- package/src/actor/errors.ts +10 -5
- package/src/actor/instance/connection-manager.ts +4 -3
- package/src/actor/instance/kv.ts +52 -9
- package/src/actor/instance/mod.ts +135 -84
- package/src/actor/instance/queue-manager.ts +2 -5
- package/src/actor/instance/queue.ts +31 -29
- package/src/actor/instance/state-manager.ts +7 -1
- package/src/actor/instance/traces-driver.ts +34 -36
- package/src/actor/metrics.ts +137 -0
- package/src/actor/protocol/old.ts +9 -12
- package/src/actor/router-websocket-endpoints.ts +12 -6
- package/src/actor/router.ts +46 -9
- package/src/actor/schema.ts +14 -22
- package/src/client/actor-common.ts +65 -0
- package/src/client/actor-conn.ts +71 -9
- package/src/client/actor-handle.ts +22 -5
- package/src/client/client.ts +32 -6
- package/src/client/config.ts +18 -21
- package/src/client/mod.ts +1 -0
- package/src/client/queue.ts +8 -6
- package/src/common/inline-websocket-adapter.ts +8 -2
- package/src/common/router.ts +1 -4
- package/src/common/utils.ts +2 -5
- package/src/db/config.ts +10 -5
- package/src/db/drizzle/mod.ts +51 -41
- package/src/db/mod.ts +54 -29
- package/src/db/shared.ts +42 -8
- package/src/driver-helpers/mod.ts +2 -1
- package/src/driver-helpers/sqlite-pool.ts +42 -0
- package/src/driver-helpers/utils.ts +0 -20
- package/src/driver-test-suite/mod.ts +11 -1
- package/src/driver-test-suite/tests/access-control.ts +19 -12
- package/src/driver-test-suite/tests/action-features.ts +20 -8
- package/src/driver-test-suite/tests/actor-conn.ts +94 -8
- package/src/driver-test-suite/tests/actor-db-kv-stats.ts +282 -0
- package/src/driver-test-suite/tests/actor-db-raw.ts +6 -2
- package/src/driver-test-suite/tests/actor-db.ts +101 -31
- package/src/driver-test-suite/tests/actor-inspector.ts +174 -32
- package/src/driver-test-suite/tests/actor-kv.ts +79 -33
- package/src/driver-test-suite/tests/actor-lifecycle.ts +4 -12
- package/src/driver-test-suite/tests/actor-queue.ts +125 -17
- package/src/driver-test-suite/tests/actor-run.ts +59 -55
- package/src/driver-test-suite/tests/actor-sandbox.ts +78 -0
- package/src/driver-test-suite/tests/actor-schedule.ts +1 -4
- package/src/driver-test-suite/tests/actor-sleep.ts +111 -0
- package/src/driver-test-suite/tests/actor-workflow.ts +387 -3
- package/src/driver-test-suite/tests/conn-error-serialization.ts +3 -1
- package/src/driver-test-suite/tests/raw-websocket.ts +5 -1
- package/src/drivers/default.ts +1 -3
- package/src/drivers/engine/actor-driver.ts +94 -21
- package/src/drivers/engine/config.ts +4 -12
- package/src/drivers/engine/mod.ts +1 -5
- package/src/drivers/file-system/actor.ts +43 -8
- package/src/drivers/file-system/global-state.ts +180 -64
- package/src/drivers/file-system/kv-limits.ts +1 -1
- package/src/drivers/file-system/sqlite-runtime.ts +13 -4
- package/src/engine-process/mod.ts +5 -1
- package/src/inspector/actor-inspector.ts +47 -21
- package/src/inspector/config.ts +1 -4
- package/src/inspector/mod.browser.ts +2 -2
- package/src/inspector/mod.ts +4 -1
- package/src/inspector/serve-ui.ts +0 -1
- package/src/inspector/workflow-history-json.ts +309 -0
- package/src/manager/gateway.ts +6 -2
- package/src/manager/router.ts +3 -3
- package/src/registry/config/index.ts +65 -12
- package/src/registry/config/runner.ts +19 -4
- package/src/registry/index.ts +42 -89
- package/src/sandbox/actor/db.ts +36 -0
- package/src/sandbox/actor/index.ts +476 -0
- package/src/sandbox/actor/session.ts +350 -0
- package/src/sandbox/actor.test.ts +36 -0
- package/src/sandbox/client.test.ts +484 -0
- package/src/sandbox/client.ts +707 -0
- package/src/sandbox/config.ts +151 -0
- package/src/sandbox/index.ts +41 -0
- package/src/sandbox/providers/computesdk.ts +1 -0
- package/src/sandbox/providers/daytona.ts +1 -0
- package/src/sandbox/providers/docker.ts +1 -0
- package/src/sandbox/providers/e2b.ts +1 -0
- package/src/sandbox/providers/local.ts +1 -0
- package/src/sandbox/providers/modal.ts +1 -0
- package/src/sandbox/providers/vercel.ts +1 -0
- package/src/sandbox/session-persist-driver.ts +180 -0
- package/src/sandbox/types.ts +138 -0
- package/src/serverless/configure.ts +5 -3
- package/src/serverless/router.test.ts +17 -9
- package/src/serverless/router.ts +20 -13
- package/src/test/mod.ts +3 -4
- package/src/utils/endpoint-parser.test.ts +6 -2
- package/src/utils/endpoint-parser.ts +6 -2
- package/src/utils/env-vars.ts +0 -2
- package/src/utils/node.ts +1 -1
- package/src/utils/serve.ts +10 -5
- package/src/utils.ts +6 -1
- package/src/workflow/constants.ts +1 -2
- package/src/workflow/context.ts +42 -9
- package/src/workflow/driver.ts +57 -23
- package/src/workflow/inspector.ts +7 -13
- package/src/workflow/mod.ts +91 -4
- package/dist/tsup/chunk-6LJAZ5R4.cjs +0 -96
- package/dist/tsup/chunk-6LJAZ5R4.cjs.map +0 -1
- package/dist/tsup/chunk-7HTNH26M.js.map +0 -1
- package/dist/tsup/chunk-7WF2QSIC.cjs.map +0 -1
- package/dist/tsup/chunk-D2SPAJVT.cjs +0 -645
- package/dist/tsup/chunk-D2SPAJVT.cjs.map +0 -1
- package/dist/tsup/chunk-EIATSBYZ.js.map +0 -1
- package/dist/tsup/chunk-HYPIHCDT.cjs.map +0 -1
- package/dist/tsup/chunk-IIJNPVPQ.cjs.map +0 -1
- package/dist/tsup/chunk-JPXO2H55.js.map +0 -1
- package/dist/tsup/chunk-KJSYAUOM.js.map +0 -1
- package/dist/tsup/chunk-L47L3ZWJ.cjs.map +0 -1
- package/dist/tsup/chunk-MIX2KB6U.js.map +0 -1
- package/dist/tsup/chunk-N4KRDJ56.js.map +0 -1
- package/dist/tsup/chunk-OAXJWGMU.cjs.map +0 -1
- package/dist/tsup/chunk-PB5AEMKQ.cjs.map +0 -1
- package/dist/tsup/chunk-R5OQUSLN.js +0 -645
- package/dist/tsup/chunk-R5OQUSLN.js.map +0 -1
- package/dist/tsup/chunk-SR3KQE7Q.cjs.map +0 -1
- package/dist/tsup/chunk-SRIM3GHD.js.map +0 -1
- package/dist/tsup/chunk-TADUYCHF.js.map +0 -1
- package/dist/tsup/chunk-TI5PXQGG.cjs.map +0 -1
- package/dist/tsup/chunk-U5SMSA27.cjs.map +0 -1
- package/dist/tsup/chunk-VKVNIQRQ.js.map +0 -1
- package/dist/tsup/chunk-WY2SHWXQ.js.map +0 -1
- package/dist/tsup/chunk-ZFY5J2EP.cjs.map +0 -1
- package/dist/tsup/chunk-ZPWOYQHN.js.map +0 -1
- package/src/db/sqlite-vfs.ts +0 -12
- /package/dist/tsup/{chunk-S662Y6ZU.js.map → chunk-EONWXYMN.js.map} +0 -0
- /package/dist/tsup/{chunk-2OK7S6QF.js.map → chunk-I5I6OALK.js.map} +0 -0
package/src/actor/config.ts
CHANGED
|
@@ -212,13 +212,14 @@ export const ActorConfigSchema = z
|
|
|
212
212
|
onDestroyTimeout: z.number().positive().default(5000),
|
|
213
213
|
stateSaveInterval: z.number().positive().default(10_000),
|
|
214
214
|
actionTimeout: z.number().positive().default(60_000),
|
|
215
|
-
//
|
|
215
|
+
// Deprecated timeout for legacy background shutdown tasks
|
|
216
216
|
waitUntilTimeout: z.number().positive().default(15_000),
|
|
217
217
|
// Max time to wait for run handler to stop during shutdown
|
|
218
218
|
runStopTimeout: z.number().positive().default(15_000),
|
|
219
219
|
connectionLivenessTimeout: z.number().positive().default(2500),
|
|
220
220
|
connectionLivenessInterval: z.number().positive().default(5000),
|
|
221
|
-
|
|
221
|
+
/** @deprecated Use `c.setPreventSleep(true)` in `onWake` instead. Will be removed in 2.2. */
|
|
222
|
+
noSleep: z.boolean().default(false),
|
|
222
223
|
sleepTimeout: z.number().positive().default(30_000),
|
|
223
224
|
maxQueueSize: z.number().positive().default(1000),
|
|
224
225
|
maxQueueMessageSize: z
|
|
@@ -286,11 +287,11 @@ type CreateState<
|
|
|
286
287
|
> =
|
|
287
288
|
| { state: TState }
|
|
288
289
|
| {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
290
|
+
createState: (
|
|
291
|
+
c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>,
|
|
292
|
+
input: TInput,
|
|
293
|
+
) => TState | Promise<TState>;
|
|
294
|
+
}
|
|
294
295
|
| Record<never, never>;
|
|
295
296
|
|
|
296
297
|
// Creates connection state config
|
|
@@ -310,18 +311,18 @@ type CreateConnState<
|
|
|
310
311
|
> =
|
|
311
312
|
| { connState: TConnState }
|
|
312
313
|
| {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
314
|
+
createConnState: (
|
|
315
|
+
c: CreateConnStateContext<
|
|
316
|
+
TState,
|
|
317
|
+
TVars,
|
|
318
|
+
TInput,
|
|
319
|
+
TDatabase,
|
|
320
|
+
TEvents,
|
|
321
|
+
TQueues
|
|
322
|
+
>,
|
|
323
|
+
params: TConnParams,
|
|
324
|
+
) => TConnState | Promise<TConnState>;
|
|
325
|
+
}
|
|
325
326
|
| Record<never, never>;
|
|
326
327
|
|
|
327
328
|
// Creates vars config
|
|
@@ -341,26 +342,26 @@ type CreateVars<
|
|
|
341
342
|
TQueues extends QueueSchemaConfig,
|
|
342
343
|
> =
|
|
343
344
|
| {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
345
|
+
/**
|
|
346
|
+
* @experimental
|
|
347
|
+
*/
|
|
348
|
+
vars: TVars;
|
|
349
|
+
}
|
|
349
350
|
| {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
351
|
+
/**
|
|
352
|
+
* @experimental
|
|
353
|
+
*/
|
|
354
|
+
createVars: (
|
|
355
|
+
c: CreateVarsContext<
|
|
356
|
+
TState,
|
|
357
|
+
TInput,
|
|
358
|
+
TDatabase,
|
|
359
|
+
TEvents,
|
|
360
|
+
TQueues
|
|
361
|
+
>,
|
|
362
|
+
driverCtx: any,
|
|
363
|
+
) => TVars | Promise<TVars>;
|
|
364
|
+
}
|
|
364
365
|
| Record<never, never>;
|
|
365
366
|
|
|
366
367
|
export interface Actions<
|
|
@@ -498,43 +499,48 @@ interface BaseActorConfig<
|
|
|
498
499
|
* - Custom workflow logic
|
|
499
500
|
*
|
|
500
501
|
* **Important:** The actor may go to sleep at any time during the `run`
|
|
501
|
-
* handler. Use `c.
|
|
502
|
-
*
|
|
502
|
+
* handler. Use `c.setPreventSleep(true)` while work is active, then clear
|
|
503
|
+
* it with `c.setPreventSleep(false)` once the actor can sleep again.
|
|
503
504
|
*
|
|
504
505
|
* The handler receives an abort signal via `c.abortSignal` and a
|
|
505
506
|
* `c.aborted` alias for loop checks. Use these to gracefully exit.
|
|
506
507
|
*
|
|
507
|
-
* If this handler exits
|
|
508
|
+
* If this handler exits, the actor will follow the normal idle sleep timeout
|
|
509
|
+
* once it becomes idle.
|
|
510
|
+
* If this handler throws, the actor logs the error and then sleeps once it
|
|
511
|
+
* becomes idle.
|
|
512
|
+
* Call `c.destroy()` explicitly if a run handler should destroy the actor.
|
|
513
|
+
*
|
|
508
514
|
* On shutdown, the actor waits for this handler to complete with a
|
|
509
515
|
* configurable timeout (options.runStopTimeout, default 15s).
|
|
510
516
|
*
|
|
511
517
|
* Can be either a function or a RunConfig object with optional name/icon metadata.
|
|
512
518
|
*
|
|
513
|
-
* @returns Void or a Promise.
|
|
519
|
+
* @returns Void or a Promise.
|
|
514
520
|
*/
|
|
515
521
|
run?:
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
522
|
+
| ((
|
|
523
|
+
c: RunContext<
|
|
524
|
+
TState,
|
|
525
|
+
TConnParams,
|
|
526
|
+
TConnState,
|
|
527
|
+
TVars,
|
|
528
|
+
TInput,
|
|
529
|
+
TDatabase,
|
|
530
|
+
TEvents,
|
|
531
|
+
TQueues
|
|
532
|
+
>,
|
|
533
|
+
) => void | Promise<void>)
|
|
534
|
+
| RunConfig<
|
|
535
|
+
TState,
|
|
536
|
+
TConnParams,
|
|
537
|
+
TConnState,
|
|
538
|
+
TVars,
|
|
539
|
+
TInput,
|
|
540
|
+
TDatabase,
|
|
541
|
+
TEvents,
|
|
542
|
+
TQueues
|
|
543
|
+
>;
|
|
538
544
|
|
|
539
545
|
/**
|
|
540
546
|
* Called when the actor's state changes.
|
|
@@ -739,11 +745,11 @@ interface BaseActorConfig<
|
|
|
739
745
|
|
|
740
746
|
type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> =
|
|
741
747
|
| {
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
748
|
+
/**
|
|
749
|
+
* @experimental
|
|
750
|
+
*/
|
|
751
|
+
db: TDatabase;
|
|
752
|
+
}
|
|
747
753
|
| Record<never, never>;
|
|
748
754
|
|
|
749
755
|
// 1. Infer schema
|
|
@@ -1041,7 +1047,7 @@ export const DocActorOptionsSchema = z
|
|
|
1041
1047
|
.number()
|
|
1042
1048
|
.optional()
|
|
1043
1049
|
.describe(
|
|
1044
|
-
"Max time in ms to wait for
|
|
1050
|
+
"Deprecated. Max time in ms to wait for legacy background shutdown tasks. Default: 15000",
|
|
1045
1051
|
),
|
|
1046
1052
|
runStopTimeout: z
|
|
1047
1053
|
.number()
|
|
@@ -1064,7 +1070,7 @@ export const DocActorOptionsSchema = z
|
|
|
1064
1070
|
noSleep: z
|
|
1065
1071
|
.boolean()
|
|
1066
1072
|
.optional()
|
|
1067
|
-
.describe("If true, the actor will never sleep. Default: false"),
|
|
1073
|
+
.describe("Deprecated: use c.setPreventSleep(true) in onWake instead. Will be removed in 2.2. If true, the actor will never sleep. Default: false"),
|
|
1068
1074
|
sleepTimeout: z
|
|
1069
1075
|
.number()
|
|
1070
1076
|
.optional()
|
|
@@ -1160,24 +1166,24 @@ export const DocActorConfigSchema = z
|
|
|
1160
1166
|
.unknown()
|
|
1161
1167
|
.optional()
|
|
1162
1168
|
.describe(
|
|
1163
|
-
"Called after actor starts. Does not block startup. Use for background tasks like queue processing or tick loops. If it exits
|
|
1169
|
+
"Called after actor starts. Does not block startup. Use for background tasks like queue processing or tick loops. If it exits, the actor follows the normal idle sleep timeout once idle. If it throws, the actor logs the error and then follows the normal idle sleep timeout once idle.",
|
|
1170
|
+
),
|
|
1171
|
+
onStateChange: z
|
|
1172
|
+
.unknown()
|
|
1173
|
+
.optional()
|
|
1174
|
+
.describe(
|
|
1175
|
+
"Called when the actor's state changes. State changes within this hook won't trigger recursion.",
|
|
1164
1176
|
),
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
"Called before a client connects. Throw an error to reject the connection.",
|
|
1176
|
-
),
|
|
1177
|
-
onConnect: z
|
|
1178
|
-
.unknown()
|
|
1179
|
-
.optional()
|
|
1180
|
-
.describe("Called when a client successfully connects."),
|
|
1177
|
+
onBeforeConnect: z
|
|
1178
|
+
.unknown()
|
|
1179
|
+
.optional()
|
|
1180
|
+
.describe(
|
|
1181
|
+
"Called before a client connects. Throw an error to reject the connection.",
|
|
1182
|
+
),
|
|
1183
|
+
onConnect: z
|
|
1184
|
+
.unknown()
|
|
1185
|
+
.optional()
|
|
1186
|
+
.describe("Called when a client successfully connects."),
|
|
1181
1187
|
onDisconnect: z
|
|
1182
1188
|
.unknown()
|
|
1183
1189
|
.optional()
|
|
@@ -62,7 +62,8 @@ export function createWebSocketDriver(
|
|
|
62
62
|
|
|
63
63
|
// Check outgoing message size
|
|
64
64
|
const messageSize =
|
|
65
|
-
(serialized as any).byteLength ||
|
|
65
|
+
(serialized as any).byteLength ||
|
|
66
|
+
(serialized as any).length;
|
|
66
67
|
if (messageSize > config.maxOutgoingMessageSize) {
|
|
67
68
|
actor.rLog.error({
|
|
68
69
|
msg: "outgoing message exceeds maxOutgoingMessageSize",
|
|
@@ -245,7 +245,7 @@ export class ActorContext<
|
|
|
245
245
|
/**
|
|
246
246
|
* Returns the client for the given registry.
|
|
247
247
|
*/
|
|
248
|
-
client<R extends Registry<any>>(): Client<R> {
|
|
248
|
+
client<R extends Registry<any> = Registry<any>>(): Client<R> {
|
|
249
249
|
return this.#actor.inlineClient as Client<R>;
|
|
250
250
|
}
|
|
251
251
|
|
|
@@ -274,19 +274,42 @@ export class ActorContext<
|
|
|
274
274
|
|
|
275
275
|
/**
|
|
276
276
|
* Prevents the actor from sleeping until promise is complete.
|
|
277
|
+
*
|
|
278
|
+
* @deprecated Use `onSleep` for shutdown or flush work, or
|
|
279
|
+
* `c.setPreventSleep(true)` while work is active if the actor must stay
|
|
280
|
+
* awake until it finishes.
|
|
277
281
|
*/
|
|
278
282
|
waitUntil(promise: Promise<void>): void {
|
|
279
283
|
this.#actor.waitUntil(promise);
|
|
280
284
|
}
|
|
281
285
|
|
|
282
286
|
/**
|
|
283
|
-
* Prevents the actor from sleeping
|
|
287
|
+
* Prevents the actor from automatically sleeping until cleared.
|
|
284
288
|
*
|
|
285
|
-
*
|
|
286
|
-
|
|
289
|
+
* @experimental
|
|
290
|
+
*/
|
|
291
|
+
setPreventSleep(prevent: boolean): void {
|
|
292
|
+
this.#actor.setPreventSleep(prevent);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* True when the actor is explicitly blocking automatic sleep.
|
|
297
|
+
*
|
|
298
|
+
* @experimental
|
|
299
|
+
*/
|
|
300
|
+
get preventSleep(): boolean {
|
|
301
|
+
return this.#actor.preventSleep;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Prevents the actor from sleeping while the given promise is running.
|
|
287
306
|
*
|
|
288
307
|
* Returns the resolved value and resets the sleep timer on completion.
|
|
289
308
|
* Errors are propagated to the caller.
|
|
309
|
+
*
|
|
310
|
+
* @deprecated Use `c.setPreventSleep(true)` while work is active, or move
|
|
311
|
+
* shutdown and flush work to `onSleep` if it can wait until the actor is
|
|
312
|
+
* sleeping.
|
|
290
313
|
*/
|
|
291
314
|
keepAwake<T>(promise: Promise<T>): Promise<T> {
|
|
292
315
|
return this.#actor.keepAwake(promise);
|
package/src/actor/database.ts
CHANGED
|
@@ -10,4 +10,9 @@ export type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> =
|
|
|
10
10
|
? Awaited<ReturnType<DBProvider["createClient"]>>
|
|
11
11
|
: never;
|
|
12
12
|
|
|
13
|
-
export type {
|
|
13
|
+
export type {
|
|
14
|
+
AnyDatabaseProvider,
|
|
15
|
+
DatabaseProvider,
|
|
16
|
+
RawDatabaseClient,
|
|
17
|
+
DrizzleDatabaseClient,
|
|
18
|
+
};
|
package/src/actor/driver.ts
CHANGED
|
@@ -4,10 +4,8 @@ import type { ManagerDriver } from "@/manager/driver";
|
|
|
4
4
|
import { type AnyConn } from "./conn/mod";
|
|
5
5
|
import type { AnyActorInstance } from "./instance/mod";
|
|
6
6
|
import type { RegistryConfig } from "@/registry/config";
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
} from "@/db/config";
|
|
10
|
-
import type { SqliteVfs } from "@rivetkit/sqlite-vfs";
|
|
7
|
+
import type { RawDatabaseClient } from "@/db/config";
|
|
8
|
+
import type { ISqliteVfs } from "@rivetkit/sqlite-vfs";
|
|
11
9
|
import { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";
|
|
12
10
|
|
|
13
11
|
export type ActorDriverBuilder = (
|
|
@@ -39,10 +37,32 @@ export interface ActorDriver {
|
|
|
39
37
|
/** Batch delete multiple keys. */
|
|
40
38
|
kvBatchDelete(actorId: string, keys: Uint8Array[]): Promise<void>;
|
|
41
39
|
|
|
40
|
+
/** Delete all keys in the half-open range [start, end). */
|
|
41
|
+
kvDeleteRange(
|
|
42
|
+
actorId: string,
|
|
43
|
+
start: Uint8Array,
|
|
44
|
+
end: Uint8Array,
|
|
45
|
+
): Promise<void>;
|
|
46
|
+
|
|
42
47
|
/** List all keys with a given prefix. */
|
|
43
48
|
kvListPrefix(
|
|
44
49
|
actorId: string,
|
|
45
50
|
prefix: Uint8Array,
|
|
51
|
+
options?: {
|
|
52
|
+
reverse?: boolean;
|
|
53
|
+
limit?: number;
|
|
54
|
+
},
|
|
55
|
+
): Promise<[Uint8Array, Uint8Array][]>;
|
|
56
|
+
|
|
57
|
+
/** List all keys in the half-open range [start, end). */
|
|
58
|
+
kvListRange(
|
|
59
|
+
actorId: string,
|
|
60
|
+
start: Uint8Array,
|
|
61
|
+
end: Uint8Array,
|
|
62
|
+
options?: {
|
|
63
|
+
reverse?: boolean;
|
|
64
|
+
limit?: number;
|
|
65
|
+
},
|
|
46
66
|
): Promise<[Uint8Array, Uint8Array][]>;
|
|
47
67
|
|
|
48
68
|
// Schedule
|
|
@@ -66,19 +86,18 @@ export interface ActorDriver {
|
|
|
66
86
|
*/
|
|
67
87
|
overrideDrizzleDatabaseClient?(
|
|
68
88
|
actorId: string,
|
|
69
|
-
): Promise<BaseSQLiteDatabase<any,any,any,any> | undefined>;
|
|
89
|
+
): Promise<BaseSQLiteDatabase<any, any, any, any> | undefined>;
|
|
70
90
|
|
|
71
91
|
/**
|
|
72
92
|
* Creates a SQLite VFS instance for creating KV-backed databases.
|
|
73
93
|
* If not provided, the database provider will need an override.
|
|
74
94
|
*
|
|
75
|
-
*
|
|
76
|
-
* should return a new instance per call for actor-level isolation.
|
|
95
|
+
* Drivers may use the actorId for pool-based instance assignment.
|
|
77
96
|
*
|
|
78
97
|
* This is a method (not a property) so drivers can use dynamic imports,
|
|
79
98
|
* keeping the core driver tree-shakeable from @rivetkit/sqlite.
|
|
80
99
|
*/
|
|
81
|
-
createSqliteVfs?():
|
|
100
|
+
createSqliteVfs?(actorId: string): ISqliteVfs | Promise<ISqliteVfs>;
|
|
82
101
|
|
|
83
102
|
/**
|
|
84
103
|
* Requests the actor to go to sleep.
|
package/src/actor/errors.ts
CHANGED
|
@@ -138,7 +138,7 @@ export class IncomingMessageTooLong extends ActorError {
|
|
|
138
138
|
super(
|
|
139
139
|
"message",
|
|
140
140
|
"incoming_too_long",
|
|
141
|
-
"Incoming message too long. This can be configured with: `
|
|
141
|
+
"Incoming message too long. This can be configured with: `setup({ maxIncomingMessageSize: ... })`",
|
|
142
142
|
{ public: true },
|
|
143
143
|
);
|
|
144
144
|
}
|
|
@@ -149,7 +149,7 @@ export class OutgoingMessageTooLong extends ActorError {
|
|
|
149
149
|
super(
|
|
150
150
|
"message",
|
|
151
151
|
"outgoing_too_long",
|
|
152
|
-
"Outgoing message too long. This can be configured with: `
|
|
152
|
+
"Outgoing message too long. This can be configured with: `setup({ maxOutgoingMessageSize: ... })`",
|
|
153
153
|
{ public: true },
|
|
154
154
|
);
|
|
155
155
|
}
|
|
@@ -256,9 +256,14 @@ export class QueueCompletionPayloadInvalid extends ActorError {
|
|
|
256
256
|
|
|
257
257
|
export class QueueAlreadyCompleted extends ActorError {
|
|
258
258
|
constructor() {
|
|
259
|
-
super(
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
super(
|
|
260
|
+
"queue",
|
|
261
|
+
"already_completed",
|
|
262
|
+
"Queue message was already completed.",
|
|
263
|
+
{
|
|
264
|
+
public: true,
|
|
265
|
+
},
|
|
266
|
+
);
|
|
262
267
|
}
|
|
263
268
|
}
|
|
264
269
|
|
|
@@ -370,7 +370,9 @@ export class ConnectionManager<
|
|
|
370
370
|
if (conn.isHibernatable) {
|
|
371
371
|
const key = makeConnKey(conn.id);
|
|
372
372
|
try {
|
|
373
|
-
await this.#actor.driver.kvBatchDelete(this.#actor.id, [
|
|
373
|
+
await this.#actor.driver.kvBatchDelete(this.#actor.id, [
|
|
374
|
+
key,
|
|
375
|
+
]);
|
|
374
376
|
this.#actor.rLog.debug({
|
|
375
377
|
msg: "removed connection from KV",
|
|
376
378
|
connId: conn.id,
|
|
@@ -396,8 +398,7 @@ export class ConnectionManager<
|
|
|
396
398
|
): Promise<number> {
|
|
397
399
|
const staleConnections = Array.from(this.#connections.values()).filter(
|
|
398
400
|
(conn) =>
|
|
399
|
-
conn.isHibernatable &&
|
|
400
|
-
conn[CONN_DRIVER_SYMBOL] === undefined,
|
|
401
|
+
conn.isHibernatable && conn[CONN_DRIVER_SYMBOL] === undefined,
|
|
401
402
|
);
|
|
402
403
|
if (staleConnections.length === 0) {
|
|
403
404
|
return 0;
|
package/src/actor/instance/kv.ts
CHANGED
|
@@ -28,6 +28,8 @@ type KvListOptions<
|
|
|
28
28
|
K extends KvKeyType = "text",
|
|
29
29
|
> = KvValueOptions<T> & {
|
|
30
30
|
keyType?: K;
|
|
31
|
+
reverse?: boolean;
|
|
32
|
+
limit?: number;
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
const textEncoder = new TextEncoder();
|
|
@@ -92,12 +94,16 @@ function encodeValue<T extends KvValueType = KvValueType>(
|
|
|
92
94
|
return textEncoder.encode(value);
|
|
93
95
|
case "arrayBuffer":
|
|
94
96
|
if (!(value instanceof ArrayBuffer)) {
|
|
95
|
-
throw new TypeError(
|
|
97
|
+
throw new TypeError(
|
|
98
|
+
"Expected an ArrayBuffer when type is arrayBuffer",
|
|
99
|
+
);
|
|
96
100
|
}
|
|
97
101
|
return new Uint8Array(value);
|
|
98
102
|
case "binary":
|
|
99
103
|
if (!(value instanceof Uint8Array)) {
|
|
100
|
-
throw new TypeError(
|
|
104
|
+
throw new TypeError(
|
|
105
|
+
"Expected a Uint8Array when type is binary",
|
|
106
|
+
);
|
|
101
107
|
}
|
|
102
108
|
return value;
|
|
103
109
|
default:
|
|
@@ -158,9 +164,7 @@ export class ActorKv {
|
|
|
158
164
|
keys: KvKey[],
|
|
159
165
|
options?: KvValueOptions<T>,
|
|
160
166
|
): Promise<(KvValueTypeMap[T] | null)[]> {
|
|
161
|
-
const prefixedKeys = keys.map((key) =>
|
|
162
|
-
makePrefixedKey(encodeKey(key)),
|
|
163
|
-
);
|
|
167
|
+
const prefixedKeys = keys.map((key) => makePrefixedKey(encodeKey(key)));
|
|
164
168
|
const results = await this.#driver.kvBatchGet(
|
|
165
169
|
this.#actorId,
|
|
166
170
|
prefixedKeys,
|
|
@@ -212,12 +216,21 @@ export class ActorKv {
|
|
|
212
216
|
* Delete multiple keys.
|
|
213
217
|
*/
|
|
214
218
|
async deleteBatch(keys: KvKey[]): Promise<void> {
|
|
215
|
-
const prefixedKeys = keys.map((key) =>
|
|
216
|
-
makePrefixedKey(encodeKey(key)),
|
|
217
|
-
);
|
|
219
|
+
const prefixedKeys = keys.map((key) => makePrefixedKey(encodeKey(key)));
|
|
218
220
|
await this.#driver.kvBatchDelete(this.#actorId, prefixedKeys);
|
|
219
221
|
}
|
|
220
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Delete all keys in the half-open range [start, end).
|
|
225
|
+
*/
|
|
226
|
+
async deleteRange(start: KvKey, end: KvKey): Promise<void> {
|
|
227
|
+
await this.#driver.kvDeleteRange(
|
|
228
|
+
this.#actorId,
|
|
229
|
+
makePrefixedKey(encodeKey(start)),
|
|
230
|
+
makePrefixedKey(encodeKey(end)),
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
221
234
|
/**
|
|
222
235
|
* List all keys with a given prefix.
|
|
223
236
|
* Returns key-value pairs where keys have the user prefix removed.
|
|
@@ -232,10 +245,40 @@ export class ActorKv {
|
|
|
232
245
|
const results = await this.#driver.kvListPrefix(
|
|
233
246
|
this.#actorId,
|
|
234
247
|
prefixedPrefix,
|
|
248
|
+
{
|
|
249
|
+
reverse: options?.reverse,
|
|
250
|
+
limit: options?.limit,
|
|
251
|
+
},
|
|
235
252
|
);
|
|
236
253
|
return results.map(([key, value]) => [
|
|
237
254
|
decodeKey<K>(removePrefixFromKey(key), options?.keyType),
|
|
238
255
|
decodeValue<T>(value, options),
|
|
239
256
|
]);
|
|
240
257
|
}
|
|
241
|
-
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* List all key-value pairs in the half-open range [start, end).
|
|
261
|
+
*/
|
|
262
|
+
async listRange<
|
|
263
|
+
T extends KvValueType = "text",
|
|
264
|
+
K extends KvKeyType = "text",
|
|
265
|
+
>(
|
|
266
|
+
start: KvKeyTypeMap[K],
|
|
267
|
+
end: KvKeyTypeMap[K],
|
|
268
|
+
options?: KvListOptions<T, K>,
|
|
269
|
+
): Promise<[KvKeyTypeMap[K], KvValueTypeMap[T]][]> {
|
|
270
|
+
const results = await this.#driver.kvListRange(
|
|
271
|
+
this.#actorId,
|
|
272
|
+
makePrefixedKey(encodeKey(start, options?.keyType)),
|
|
273
|
+
makePrefixedKey(encodeKey(end, options?.keyType)),
|
|
274
|
+
{
|
|
275
|
+
reverse: options?.reverse,
|
|
276
|
+
limit: options?.limit,
|
|
277
|
+
},
|
|
278
|
+
);
|
|
279
|
+
return results.map(([key, value]) => [
|
|
280
|
+
decodeKey<K>(removePrefixFromKey(key), options?.keyType),
|
|
281
|
+
decodeValue<T>(value, options),
|
|
282
|
+
]);
|
|
283
|
+
}
|
|
284
|
+
}
|