rivetkit 2.0.42 → 2.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{tsup/config-CLnylLYY.d.ts → browser/client.d.ts} +2127 -1910
- package/dist/browser/client.js +5182 -0
- package/dist/browser/client.js.map +1 -0
- package/dist/browser/inspector/client.d.ts +130 -0
- package/dist/browser/inspector/client.js +2854 -0
- package/dist/browser/inspector/client.js.map +1 -0
- package/dist/browser/v3-DnYObHH3.d.ts +279 -0
- package/dist/schemas/actor-inspector/v2.ts +796 -0
- package/dist/schemas/actor-inspector/v3.ts +899 -0
- package/dist/schemas/actor-persist/v4.ts +406 -0
- package/dist/schemas/client-protocol/v3.ts +554 -0
- package/dist/schemas/persist/v1.ts +781 -0
- package/dist/schemas/transport/v1.ts +697 -0
- package/dist/tsup/actor/errors.cjs +27 -3
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +37 -1
- package/dist/tsup/actor/errors.d.ts +37 -1
- package/dist/tsup/actor/errors.js +26 -1
- package/dist/tsup/{actor-router-consts-DzI2szci.d.cts → actor-router-consts-D29T1Z-K.d.cts} +1 -1
- package/dist/tsup/{actor-router-consts-DzI2szci.d.ts → actor-router-consts-D29T1Z-K.d.ts} +1 -1
- package/dist/tsup/chunk-424PT5DM.js +23 -0
- package/dist/tsup/chunk-424PT5DM.js.map +1 -0
- package/dist/tsup/{chunk-JDAD2YFA.js → chunk-5ESWDTHJ.js} +148 -273
- package/dist/tsup/chunk-5ESWDTHJ.js.map +1 -0
- package/dist/tsup/{chunk-FJ3KTN4V.js → chunk-6LIBPELE.js} +119 -11
- package/dist/tsup/chunk-6LIBPELE.js.map +1 -0
- package/dist/tsup/chunk-6LJAZ5R4.cjs +96 -0
- package/dist/tsup/chunk-6LJAZ5R4.cjs.map +1 -0
- package/dist/tsup/{chunk-LFVF5SCU.js → chunk-7HTNH26M.js} +126 -1
- package/dist/tsup/chunk-7HTNH26M.js.map +1 -0
- package/dist/tsup/chunk-7K4CYDGD.js +630 -0
- package/dist/tsup/chunk-7K4CYDGD.js.map +1 -0
- package/dist/tsup/{chunk-XXGJCOL6.js → chunk-A6YIZWTK.js} +2 -2
- package/dist/tsup/chunk-AIYEYMX5.cjs +630 -0
- package/dist/tsup/chunk-AIYEYMX5.cjs.map +1 -0
- package/dist/tsup/{chunk-Q6W7RJJP.js → chunk-DIGBC2VI.js} +211 -2316
- package/dist/tsup/chunk-DIGBC2VI.js.map +1 -0
- package/dist/tsup/{chunk-RZW2DNND.cjs → chunk-F6JYU5IK.cjs} +1957 -1039
- package/dist/tsup/chunk-F6JYU5IK.cjs.map +1 -0
- package/dist/tsup/chunk-HAZL2EPK.cjs +534 -0
- package/dist/tsup/chunk-HAZL2EPK.cjs.map +1 -0
- package/dist/tsup/chunk-HDQ2JUQT.cjs +23 -0
- package/dist/tsup/chunk-HDQ2JUQT.cjs.map +1 -0
- package/dist/tsup/chunk-HIDX4C5Y.cjs +1036 -0
- package/dist/tsup/chunk-HIDX4C5Y.cjs.map +1 -0
- package/dist/tsup/chunk-IVG73YCW.js +534 -0
- package/dist/tsup/chunk-IVG73YCW.js.map +1 -0
- package/dist/tsup/chunk-KJSYAUOM.js +96 -0
- package/dist/tsup/chunk-KJSYAUOM.js.map +1 -0
- package/dist/tsup/{chunk-2XQS746M.cjs → chunk-L47L3ZWJ.cjs} +127 -2
- package/dist/tsup/chunk-L47L3ZWJ.cjs.map +1 -0
- package/dist/tsup/{chunk-H4TB4X25.cjs → chunk-LW6KLR7A.cjs} +126 -18
- package/dist/tsup/chunk-LW6KLR7A.cjs.map +1 -0
- package/dist/tsup/chunk-LXUQ667X.js +2006 -0
- package/dist/tsup/chunk-LXUQ667X.js.map +1 -0
- package/dist/tsup/{chunk-GMAVRZSF.js → chunk-M2T62AZQ.js} +1790 -872
- package/dist/tsup/chunk-M2T62AZQ.js.map +1 -0
- package/dist/tsup/chunk-MZ37VV3P.js +5974 -0
- package/dist/tsup/chunk-MZ37VV3P.js.map +1 -0
- package/dist/tsup/chunk-N4KRDJ56.js +72 -0
- package/dist/tsup/chunk-N4KRDJ56.js.map +1 -0
- package/dist/tsup/chunk-NIYZDWMW.cjs +2006 -0
- package/dist/tsup/chunk-NIYZDWMW.cjs.map +1 -0
- package/dist/tsup/chunk-OMEPCQK2.js +649 -0
- package/dist/tsup/chunk-OMEPCQK2.js.map +1 -0
- package/dist/tsup/chunk-SR3KQE7Q.cjs +72 -0
- package/dist/tsup/chunk-SR3KQE7Q.cjs.map +1 -0
- package/dist/tsup/chunk-SSEP6DHP.cjs +2657 -0
- package/dist/tsup/chunk-SSEP6DHP.cjs.map +1 -0
- package/dist/tsup/chunk-T5YCUGVS.js +1036 -0
- package/dist/tsup/chunk-T5YCUGVS.js.map +1 -0
- package/dist/tsup/{chunk-EJVBH5VF.cjs → chunk-TPGXWFQT.cjs} +3 -3
- package/dist/tsup/{chunk-EJVBH5VF.cjs.map → chunk-TPGXWFQT.cjs.map} +1 -1
- package/dist/tsup/{chunk-X35U3YNX.cjs → chunk-TYLXNCA5.cjs} +214 -339
- package/dist/tsup/chunk-TYLXNCA5.cjs.map +1 -0
- package/dist/tsup/chunk-VKVNIQRQ.js +257 -0
- package/dist/tsup/chunk-VKVNIQRQ.js.map +1 -0
- package/dist/tsup/chunk-XWBAQO5H.cjs +649 -0
- package/dist/tsup/chunk-XWBAQO5H.cjs.map +1 -0
- package/dist/tsup/chunk-YQ4LDVD6.cjs +5974 -0
- package/dist/tsup/chunk-YQ4LDVD6.cjs.map +1 -0
- package/dist/tsup/chunk-ZFY5J2EP.cjs +257 -0
- package/dist/tsup/chunk-ZFY5J2EP.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -10
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +11 -5
- package/dist/tsup/client/mod.d.ts +11 -5
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +4 -4
- package/dist/tsup/common/log.d.cts +2 -2
- package/dist/tsup/common/log.d.ts +2 -2
- package/dist/tsup/common/log.js +3 -2
- package/dist/tsup/common/websocket.cjs +5 -5
- package/dist/tsup/common/websocket.js +4 -3
- package/dist/tsup/config-BFqid9Gr.d.ts +2574 -0
- package/dist/tsup/config-BiNoIHRs.d.cts +80 -0
- package/dist/tsup/config-BiNoIHRs.d.ts +80 -0
- package/dist/tsup/{config-CZB2-W8x.d.cts → config-CAZphOS1.d.cts} +681 -355
- package/dist/tsup/db/drizzle/mod.cjs +49 -0
- package/dist/tsup/db/drizzle/mod.cjs.map +1 -0
- package/dist/tsup/db/drizzle/mod.d.cts +17 -0
- package/dist/tsup/db/drizzle/mod.d.ts +17 -0
- package/dist/tsup/db/drizzle/mod.js +49 -0
- package/dist/tsup/db/drizzle/mod.js.map +1 -0
- package/dist/tsup/db/mod.cjs +9 -0
- package/dist/tsup/db/mod.cjs.map +1 -0
- package/dist/tsup/db/mod.d.cts +9 -0
- package/dist/tsup/db/mod.d.ts +9 -0
- package/dist/tsup/db/mod.js +9 -0
- package/dist/tsup/db/mod.js.map +1 -0
- package/dist/tsup/{driver-D0QX9M11.d.ts → driver-Bxv62E2p.d.ts} +2 -2
- package/dist/tsup/{driver-q-zqG7fc.d.cts → driver-DYXwJR5D.d.cts} +2 -2
- package/dist/tsup/driver-helpers/mod.cjs +12 -6
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +12 -5
- package/dist/tsup/driver-helpers/mod.d.ts +12 -5
- package/dist/tsup/driver-helpers/mod.js +12 -5
- package/dist/tsup/driver-test-suite/mod.cjs +1370 -116
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +10 -4
- package/dist/tsup/driver-test-suite/mod.d.ts +10 -4
- package/dist/tsup/driver-test-suite/mod.js +2093 -838
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +29 -3
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +124 -3
- package/dist/tsup/inspector/mod.d.ts +124 -3
- package/dist/tsup/inspector/mod.js +72 -45
- package/dist/tsup/keys-CydblqMh.d.cts +13 -0
- package/dist/tsup/keys-CydblqMh.d.ts +13 -0
- package/dist/tsup/mod.cjs +16 -10
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +26 -14
- package/dist/tsup/mod.d.ts +26 -14
- package/dist/tsup/mod.js +20 -13
- package/dist/tsup/serve-test-suite/mod.cjs +1165 -83
- package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/serve-test-suite/mod.js +1114 -29
- package/dist/tsup/serve-test-suite/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +84 -11
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +10 -5
- package/dist/tsup/test/mod.d.ts +10 -5
- package/dist/tsup/test/mod.js +85 -11
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/utils.cjs +10 -4
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +72 -2
- package/dist/tsup/utils.d.ts +72 -2
- package/dist/tsup/utils.js +9 -2
- package/dist/tsup/v3-DnYObHH3.d.cts +279 -0
- package/dist/tsup/v3-DnYObHH3.d.ts +279 -0
- package/dist/tsup/workflow/mod.cjs +16 -0
- package/dist/tsup/workflow/mod.cjs.map +1 -0
- package/dist/tsup/workflow/mod.d.cts +83 -0
- package/dist/tsup/workflow/mod.d.ts +83 -0
- package/dist/tsup/workflow/mod.js +16 -0
- package/dist/tsup/workflow/mod.js.map +1 -0
- package/package.json +62 -5
- package/src/actor/config.ts +478 -68
- package/src/actor/conn/mod.ts +68 -16
- package/src/actor/conn/state-manager.ts +2 -2
- package/src/actor/contexts/action.ts +20 -12
- package/src/actor/contexts/base/actor.ts +137 -7
- package/src/actor/contexts/base/conn-init.ts +27 -7
- package/src/actor/contexts/base/conn.ts +27 -18
- package/src/actor/contexts/before-action-response.ts +9 -2
- package/src/actor/contexts/before-connect.ts +7 -2
- package/src/actor/contexts/connect.ts +9 -2
- package/src/actor/contexts/create-conn-state.ts +7 -2
- package/src/actor/contexts/create-vars.ts +16 -3
- package/src/actor/contexts/create.ts +16 -3
- package/src/actor/contexts/destroy.ts +9 -3
- package/src/actor/contexts/disconnect.ts +10 -4
- package/src/actor/contexts/index.ts +4 -3
- package/src/actor/contexts/request.ts +23 -6
- package/src/actor/contexts/run.ts +47 -0
- package/src/actor/contexts/sleep.ts +9 -3
- package/src/actor/contexts/state-change.ts +9 -3
- package/src/actor/contexts/wake.ts +9 -3
- package/src/actor/contexts/websocket.ts +23 -6
- package/src/actor/database.ts +8 -18
- package/src/actor/definition.ts +20 -6
- package/src/actor/driver.ts +32 -3
- package/src/actor/errors.ts +127 -0
- package/src/actor/instance/connection-manager.ts +183 -80
- package/src/actor/instance/event-manager.ts +26 -15
- package/src/actor/instance/keys.ts +117 -0
- package/src/actor/instance/mod.ts +784 -174
- package/src/actor/instance/queue-manager.ts +603 -0
- package/src/actor/instance/queue.ts +287 -0
- package/src/actor/instance/schedule-manager.ts +49 -7
- package/src/actor/instance/state-manager.ts +35 -11
- package/src/actor/instance/traces-driver.ts +128 -0
- package/src/actor/mod.ts +26 -2
- package/src/actor/protocol/old.ts +28 -13
- package/src/actor/protocol/serde.ts +1 -1
- package/src/actor/router-endpoints.ts +177 -21
- package/src/actor/router-websocket-endpoints.ts +18 -29
- package/src/actor/router.ts +177 -0
- package/src/actor/schema.ts +291 -0
- package/src/actor/utils.ts +40 -0
- package/src/client/actor-common.ts +1 -1
- package/src/client/actor-conn.ts +100 -33
- package/src/client/actor-handle.ts +61 -33
- package/src/client/client.ts +2 -4
- package/src/client/config.ts +1 -1
- package/src/client/mod.browser.ts +2 -0
- package/src/client/mod.ts +1 -4
- package/src/client/queue.ts +146 -0
- package/src/client/utils.ts +1 -1
- package/src/common/log.ts +1 -1
- package/src/common/utils.ts +3 -3
- package/src/db/config.ts +100 -0
- package/src/db/drizzle/mod.ts +226 -0
- package/src/db/drizzle/sqlite-core.ts +22 -0
- package/src/db/mod.ts +125 -0
- package/src/db/shared.ts +92 -0
- package/src/db/sqlite-vfs.ts +12 -0
- package/src/driver-helpers/mod.ts +1 -0
- package/src/driver-test-suite/mod.ts +69 -43
- package/src/driver-test-suite/tests/access-control.ts +218 -0
- package/src/driver-test-suite/tests/actor-db-raw.ts +73 -0
- package/src/driver-test-suite/tests/actor-db.ts +394 -0
- package/src/driver-test-suite/tests/actor-inspector.ts +259 -358
- package/src/driver-test-suite/tests/actor-kv.ts +41 -20
- package/src/driver-test-suite/tests/actor-queue.ts +324 -0
- package/src/driver-test-suite/tests/actor-run.ts +181 -0
- package/src/driver-test-suite/tests/actor-schedule.ts +5 -2
- package/src/driver-test-suite/tests/actor-sleep.ts +3 -3
- package/src/driver-test-suite/tests/actor-stateless.ts +70 -0
- package/src/driver-test-suite/tests/actor-workflow.ts +108 -0
- package/src/driver-test-suite/tests/manager-driver.ts +11 -0
- package/src/driver-test-suite/tests/raw-http-request-properties.ts +1 -1
- package/src/driver-test-suite/tests/raw-websocket.ts +12 -12
- package/src/drivers/default.ts +7 -2
- package/src/drivers/engine/actor-driver.ts +45 -37
- package/src/drivers/engine/config.ts +1 -1
- package/src/drivers/file-system/actor.ts +20 -2
- package/src/drivers/file-system/global-state.ts +569 -258
- package/src/drivers/file-system/kv-limits.ts +70 -0
- package/src/drivers/file-system/manager.ts +22 -6
- package/src/drivers/file-system/mod.ts +39 -16
- package/src/drivers/file-system/sqlite-runtime.ts +210 -0
- package/src/inspector/actor-inspector.ts +224 -102
- package/src/inspector/config.ts +1 -1
- package/src/inspector/handler.ts +102 -20
- package/src/inspector/mod.browser.ts +8 -0
- package/src/inspector/mod.ts +2 -0
- package/src/inspector/serve-ui.ts +40 -0
- package/src/inspector/transport.ts +18 -0
- package/src/inspector/utils.ts +5 -39
- package/src/manager/gateway.ts +1 -1
- package/src/manager/protocol/mod.ts +1 -1
- package/src/manager/protocol/query.ts +1 -1
- package/src/manager/router-schema.ts +1 -1
- package/src/manager/router.ts +38 -12
- package/src/manager-api/actors.ts +1 -1
- package/src/manager-api/common.ts +1 -1
- package/src/registry/config/driver.ts +1 -1
- package/src/registry/config/index.ts +212 -43
- package/src/registry/config/legacy-runner.ts +1 -1
- package/src/registry/config/runner.ts +1 -1
- package/src/registry/config/serverless.ts +1 -1
- package/src/registry/index.ts +7 -5
- package/src/remote-manager-driver/api-utils.ts +1 -1
- package/src/schemas/actor-inspector/mod.ts +1 -1
- package/src/schemas/actor-inspector/versioned.ts +195 -8
- package/src/schemas/actor-persist/versioned.ts +87 -7
- package/src/schemas/client-protocol/mod.ts +1 -1
- package/src/schemas/client-protocol/versioned.ts +127 -11
- package/src/schemas/client-protocol-zod/mod.ts +16 -1
- package/src/schemas/persist/mod.ts +1 -0
- package/src/schemas/transport/mod.ts +1 -0
- package/src/serde.ts +1 -1
- package/src/serve-test-suite/mod.ts +10 -9
- package/src/test/mod.ts +15 -56
- package/src/utils/endpoint-parser.test.ts +1 -1
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +12 -1
- package/src/utils/node.ts +15 -2
- package/src/utils.test.ts +34 -0
- package/src/utils.ts +140 -6
- package/src/workflow/constants.ts +2 -0
- package/src/workflow/context.ts +532 -0
- package/src/workflow/driver.ts +191 -0
- package/src/workflow/inspector.ts +268 -0
- package/src/workflow/mod.ts +122 -0
- package/dist/tsup/chunk-2IJTYN6K.cjs +0 -278
- package/dist/tsup/chunk-2IJTYN6K.cjs.map +0 -1
- package/dist/tsup/chunk-2XQS746M.cjs.map +0 -1
- package/dist/tsup/chunk-3VP5CSHV.cjs +0 -114
- package/dist/tsup/chunk-3VP5CSHV.cjs.map +0 -1
- package/dist/tsup/chunk-AQFSQMBG.js +0 -114
- package/dist/tsup/chunk-AQFSQMBG.js.map +0 -1
- package/dist/tsup/chunk-E6ZE2YEA.js +0 -664
- package/dist/tsup/chunk-E6ZE2YEA.js.map +0 -1
- package/dist/tsup/chunk-FJ3KTN4V.js.map +0 -1
- package/dist/tsup/chunk-GBENOENJ.cjs +0 -8
- package/dist/tsup/chunk-GBENOENJ.cjs.map +0 -1
- package/dist/tsup/chunk-GD7UXGOE.cjs +0 -4762
- package/dist/tsup/chunk-GD7UXGOE.cjs.map +0 -1
- package/dist/tsup/chunk-GMAVRZSF.js.map +0 -1
- package/dist/tsup/chunk-H4TB4X25.cjs.map +0 -1
- package/dist/tsup/chunk-JDAD2YFA.js.map +0 -1
- package/dist/tsup/chunk-KCOVZOPS.js +0 -1946
- package/dist/tsup/chunk-KCOVZOPS.js.map +0 -1
- package/dist/tsup/chunk-KDFWJKMJ.cjs +0 -664
- package/dist/tsup/chunk-KDFWJKMJ.cjs.map +0 -1
- package/dist/tsup/chunk-LFVF5SCU.js.map +0 -1
- package/dist/tsup/chunk-Q6W7RJJP.js.map +0 -1
- package/dist/tsup/chunk-RUW5CZ5Z.cjs +0 -1949
- package/dist/tsup/chunk-RUW5CZ5Z.cjs.map +0 -1
- package/dist/tsup/chunk-RZW2DNND.cjs.map +0 -1
- package/dist/tsup/chunk-TCOEBUUE.js +0 -278
- package/dist/tsup/chunk-TCOEBUUE.js.map +0 -1
- package/dist/tsup/chunk-X35U3YNX.cjs.map +0 -1
- package/dist/tsup/keys-Chhy4ylv.d.cts +0 -8
- package/dist/tsup/keys-Chhy4ylv.d.ts +0 -8
- package/dist/tsup/v1-Gq4avTK3.d.cts +0 -240
- package/dist/tsup/v1-Gq4avTK3.d.ts +0 -240
- /package/dist/tsup/{chunk-XXGJCOL6.js.map → chunk-A6YIZWTK.js.map} +0 -0
|
@@ -1,32 +1,19 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
1
|
+
import { z as z$1 } from 'zod/v4';
|
|
2
2
|
import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
3
|
+
import { A as AnyDatabaseProvider, D as DatabaseProvider, a as RawDatabaseClient } from './config-BiNoIHRs.cjs';
|
|
4
|
+
import { Traces, OtlpExportTraceServiceRequestJson, SpanHandle, SpanStatusInput } from '@rivetkit/traces';
|
|
3
5
|
import { Env, Context, Hono } from 'hono';
|
|
4
6
|
import { VersionedDataHandler } from 'vbare';
|
|
5
7
|
import { Logger } from 'pino';
|
|
6
8
|
import { GetUpgradeWebSocket } from './utils.cjs';
|
|
9
|
+
import { SqliteVfs } from '@rivetkit/sqlite-vfs';
|
|
10
|
+
import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
7
13
|
import * as nanoevents from 'nanoevents';
|
|
8
|
-
import {
|
|
14
|
+
import { W as WorkflowHistory, k as QueueStatus } from './v3-DnYObHH3.cjs';
|
|
9
15
|
|
|
10
16
|
type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : never;
|
|
11
|
-
type AnyDatabaseProvider = DatabaseProvider<any> | undefined;
|
|
12
|
-
type DatabaseProvider<DB extends {
|
|
13
|
-
execute: (query: string) => any;
|
|
14
|
-
}> = {
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new database client for the actor.
|
|
17
|
-
* The result is passed to the actor context as `c.db`.
|
|
18
|
-
* @experimental
|
|
19
|
-
*/
|
|
20
|
-
createClient: (ctx: {
|
|
21
|
-
getDatabase: () => Promise<string | unknown>;
|
|
22
|
-
}) => Promise<DB>;
|
|
23
|
-
/**
|
|
24
|
-
* Runs before the actor has started.
|
|
25
|
-
* Use this to run migrations or other setup tasks.
|
|
26
|
-
* @experimental
|
|
27
|
-
*/
|
|
28
|
-
onMigrate: (client: DB) => void | Promise<void>;
|
|
29
|
-
};
|
|
30
17
|
|
|
31
18
|
type ManagerDriverBuilder = (config: RegistryConfig) => ManagerDriver;
|
|
32
19
|
interface ManagerDriver {
|
|
@@ -116,10 +103,28 @@ interface ActorDriver {
|
|
|
116
103
|
/** ActorInstance ensure that only one instance of setAlarm is called in parallel at a time. */
|
|
117
104
|
setAlarm(actor: AnyActorInstance, timestamp: number): Promise<void>;
|
|
118
105
|
/**
|
|
106
|
+
* Override the default raw database client for the actor.
|
|
107
|
+
* If not provided, rivetkit will construct a KV-backed SQLite client.
|
|
119
108
|
* @experimental
|
|
120
|
-
* This is an experimental API that may change in the future.
|
|
121
109
|
*/
|
|
122
|
-
|
|
110
|
+
overrideRawDatabaseClient?(actorId: string): Promise<RawDatabaseClient | undefined>;
|
|
111
|
+
/**
|
|
112
|
+
* Override the default Drizzle database client for the actor.
|
|
113
|
+
* If not provided, rivetkit will construct a KV-backed Drizzle client.
|
|
114
|
+
* @experimental
|
|
115
|
+
*/
|
|
116
|
+
overrideDrizzleDatabaseClient?(actorId: string): Promise<BaseSQLiteDatabase<any, any, any, any> | undefined>;
|
|
117
|
+
/**
|
|
118
|
+
* Creates a SQLite VFS instance for creating KV-backed databases.
|
|
119
|
+
* If not provided, the database provider will need an override.
|
|
120
|
+
*
|
|
121
|
+
* @rivetkit/sqlite's async build is not re-entrant per module instance. Drivers
|
|
122
|
+
* should return a new instance per call for actor-level isolation.
|
|
123
|
+
*
|
|
124
|
+
* This is a method (not a property) so drivers can use dynamic imports,
|
|
125
|
+
* keeping the core driver tree-shakeable from @rivetkit/sqlite.
|
|
126
|
+
*/
|
|
127
|
+
createSqliteVfs?(): SqliteVfs | Promise<SqliteVfs>;
|
|
123
128
|
/**
|
|
124
129
|
* Requests the actor to go to sleep.
|
|
125
130
|
*
|
|
@@ -147,7 +152,7 @@ interface ActorDriver {
|
|
|
147
152
|
onAfterPersistConn?(conn: AnyConn): void;
|
|
148
153
|
}
|
|
149
154
|
|
|
150
|
-
declare const ActorsSchema: z.ZodRecord<z.ZodString, z.ZodCustom<ActorDefinition<any, any, any, any, any, any, any>, ActorDefinition<any, any, any, any, any, any, any>>>;
|
|
155
|
+
declare const ActorsSchema: z.ZodRecord<z.ZodString, z.ZodCustom<ActorDefinition<any, any, any, any, any, any, any, any, any>, ActorDefinition<any, any, any, any, any, any, any, any, any>>>;
|
|
151
156
|
type RegistryActors = z.infer<typeof ActorsSchema>;
|
|
152
157
|
declare const TestConfigSchema: z.ZodObject<{
|
|
153
158
|
enabled: z.ZodBoolean;
|
|
@@ -165,6 +170,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
165
170
|
actor: z.ZodCustom<ActorDriverBuilder, ActorDriverBuilder>;
|
|
166
171
|
autoStartActorDriver: z.ZodBoolean;
|
|
167
172
|
}, z.core.$strip>>;
|
|
173
|
+
storagePath: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
|
|
168
174
|
maxIncomingMessageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
169
175
|
maxOutgoingMessageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
170
176
|
noWelcome: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -263,6 +269,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
263
269
|
test: {
|
|
264
270
|
enabled: boolean;
|
|
265
271
|
};
|
|
272
|
+
storagePath: string | undefined;
|
|
266
273
|
maxIncomingMessageSize: number;
|
|
267
274
|
maxOutgoingMessageSize: number;
|
|
268
275
|
noWelcome: boolean;
|
|
@@ -292,6 +299,7 @@ declare const RegistryConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
292
299
|
test: {
|
|
293
300
|
enabled: boolean;
|
|
294
301
|
};
|
|
302
|
+
storagePath: string | undefined;
|
|
295
303
|
maxIncomingMessageSize: number;
|
|
296
304
|
maxOutgoingMessageSize: number;
|
|
297
305
|
noWelcome: boolean;
|
|
@@ -351,7 +359,7 @@ type RegistryConfigInput<A extends RegistryActors> = Omit<z.input<typeof Registr
|
|
|
351
359
|
use: A;
|
|
352
360
|
};
|
|
353
361
|
declare function buildActorNames(config: RegistryConfig): Record<string, {
|
|
354
|
-
metadata: Record<string,
|
|
362
|
+
metadata: Record<string, unknown>;
|
|
355
363
|
}>;
|
|
356
364
|
declare const DocInspectorConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
357
365
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -397,6 +405,7 @@ declare const DocRunnerConfigSchema: z.ZodObject<{
|
|
|
397
405
|
}, z.core.$strip>;
|
|
398
406
|
declare const DocRegistryConfigSchema: z.ZodObject<{
|
|
399
407
|
use: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
408
|
+
storagePath: z.ZodOptional<z.ZodString>;
|
|
400
409
|
maxIncomingMessageSize: z.ZodOptional<z.ZodNumber>;
|
|
401
410
|
maxOutgoingMessageSize: z.ZodOptional<z.ZodNumber>;
|
|
402
411
|
noWelcome: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -450,18 +459,69 @@ declare const DocRegistryConfigSchema: z.ZodObject<{
|
|
|
450
459
|
}, z.core.$strip>>;
|
|
451
460
|
}, z.core.$strip>;
|
|
452
461
|
|
|
453
|
-
type
|
|
454
|
-
|
|
462
|
+
type SchemaHookResult = boolean | Promise<boolean>;
|
|
463
|
+
type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
|
|
464
|
+
interface EventTypeToken<T, TContext = any> {
|
|
465
|
+
readonly _eventType?: T;
|
|
466
|
+
readonly canSubscribe?: SchemaHook<TContext>;
|
|
467
|
+
readonly schema?: PrimitiveSchema;
|
|
468
|
+
}
|
|
469
|
+
interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
|
|
470
|
+
readonly _queueMessage?: TMessage;
|
|
471
|
+
readonly _queueComplete?: TComplete;
|
|
472
|
+
readonly canPublish?: SchemaHook<TContext>;
|
|
473
|
+
readonly message?: PrimitiveSchema;
|
|
474
|
+
readonly complete?: PrimitiveSchema;
|
|
475
|
+
}
|
|
476
|
+
/** @deprecated Use `event<T>()`. */
|
|
477
|
+
type Type<T> = EventTypeToken<T, any>;
|
|
478
|
+
interface EventOptions<TContext = any> {
|
|
479
|
+
canSubscribe?: SchemaHook<TContext>;
|
|
480
|
+
schema?: PrimitiveSchema;
|
|
481
|
+
}
|
|
482
|
+
interface QueueOptions<TContext = any> {
|
|
483
|
+
canPublish?: SchemaHook<TContext>;
|
|
484
|
+
message?: PrimitiveSchema;
|
|
485
|
+
complete?: PrimitiveSchema;
|
|
486
|
+
}
|
|
487
|
+
declare function event<T, TContext = any>(options?: EventOptions<TContext>): EventTypeToken<T, TContext>;
|
|
488
|
+
declare function queue<TMessage, TComplete = never, TContext = any>(options?: QueueOptions<TContext>): QueueTypeToken<TMessage, TComplete, TContext>;
|
|
489
|
+
type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
|
|
490
|
+
interface EventSchemaDefinition<TContext = any> {
|
|
491
|
+
schema: PrimitiveSchema;
|
|
492
|
+
canSubscribe?: SchemaHook<TContext>;
|
|
493
|
+
}
|
|
494
|
+
interface QueueSchemaDefinition<TContext = any> {
|
|
495
|
+
message: PrimitiveSchema;
|
|
496
|
+
complete?: PrimitiveSchema;
|
|
497
|
+
canPublish?: SchemaHook<TContext>;
|
|
498
|
+
}
|
|
499
|
+
type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
|
|
500
|
+
type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
|
|
501
|
+
type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
|
|
502
|
+
type QueueSchemaConfig<TContext = any> = Record<string, QueueSchema>;
|
|
503
|
+
type InferSchema<T> = T extends QueueSchemaDefinition<any> ? InferSchema<T["message"]> : T extends QueueTypeToken<infer M, unknown, any> ? M : T extends EventSchemaDefinition<any> ? InferSchema<T["schema"]> : T extends StandardSchemaV1<any, infer O> ? O : T extends EventTypeToken<infer R, any> ? R : never;
|
|
504
|
+
type InferSchemaMap<T extends Record<string, unknown>> = {
|
|
505
|
+
[K in keyof T]: InferSchema<T[K]>;
|
|
506
|
+
};
|
|
507
|
+
type InferQueueComplete<T> = T extends QueueTypeToken<unknown, infer C, any> ? [C] extends [never] ? never : C : T extends QueueSchemaDefinition<any> ? T["complete"] extends PrimitiveSchema ? InferSchema<T["complete"]> : never : never;
|
|
508
|
+
type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
|
|
509
|
+
[K in keyof T]: InferQueueComplete<T[K]>;
|
|
510
|
+
};
|
|
511
|
+
type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
|
|
512
|
+
|
|
513
|
+
type AnyActorDefinition = ActorDefinition<any, any, any, any, any, any, any, any, any>;
|
|
514
|
+
declare class ActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>, R extends Actions<S, CP, CS, V, I, DB, E, Q> = Actions<S, CP, CS, V, I, DB, E, Q>> {
|
|
455
515
|
#private;
|
|
456
|
-
constructor(config: ActorConfig<S, CP, CS, V, I, DB>);
|
|
457
|
-
get config(): ActorConfig<S, CP, CS, V, I, DB>;
|
|
458
|
-
instantiate(): ActorInstance<S, CP, CS, V, I, DB>;
|
|
516
|
+
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
|
|
517
|
+
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
|
|
518
|
+
instantiate(): ActorInstance<S, CP, CS, V, I, DB, E, Q>;
|
|
459
519
|
}
|
|
460
520
|
declare function lookupInRegistry(config: RegistryConfig, name: string): AnyActorDefinition;
|
|
461
521
|
|
|
462
522
|
/** Data that's been serialized. */
|
|
463
523
|
type OutputData = string | Uint8Array;
|
|
464
|
-
declare const EncodingSchema: z.ZodEnum<{
|
|
524
|
+
declare const EncodingSchema: z$1.ZodEnum<{
|
|
465
525
|
json: "json";
|
|
466
526
|
cbor: "cbor";
|
|
467
527
|
bare: "bare";
|
|
@@ -469,45 +529,45 @@ declare const EncodingSchema: z.ZodEnum<{
|
|
|
469
529
|
/**
|
|
470
530
|
* Encoding used to communicate between the client & actor.
|
|
471
531
|
*/
|
|
472
|
-
type Encoding = z.infer<typeof EncodingSchema>;
|
|
532
|
+
type Encoding = z$1.infer<typeof EncodingSchema>;
|
|
473
533
|
/**
|
|
474
534
|
* Helper class that helps serialize data without re-serializing for the same encoding.
|
|
475
535
|
*/
|
|
476
536
|
declare class CachedSerializer<TBare, TJson, T = TBare> {
|
|
477
537
|
#private;
|
|
478
|
-
constructor(data: T, versionedDataHandler: VersionedDataHandler<TBare>, version: number, zodSchema: z.ZodType<TJson>, toJson: (value: T) => TJson, toBare: (value: T) => TBare);
|
|
538
|
+
constructor(data: T, versionedDataHandler: VersionedDataHandler<TBare>, version: number, zodSchema: z$1.ZodType<TJson>, toJson: (value: T) => TJson, toBare: (value: T) => TBare);
|
|
479
539
|
get rawData(): T;
|
|
480
540
|
serialize(encoding: Encoding): OutputData;
|
|
481
541
|
}
|
|
482
542
|
|
|
483
|
-
declare const LegacyRunnerConfigSchema: z.ZodDefault<z.ZodPipe<z.ZodObject<{
|
|
484
|
-
driver: z.ZodOptional<z.ZodObject<{
|
|
485
|
-
name: z.ZodString;
|
|
486
|
-
manager: z.ZodCustom<ManagerDriverBuilder, ManagerDriverBuilder>;
|
|
487
|
-
actor: z.ZodCustom<ActorDriverBuilder, ActorDriverBuilder>;
|
|
488
|
-
}, z.core.$strip>>;
|
|
489
|
-
maxIncomingMessageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
490
|
-
maxOutgoingMessageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
491
|
-
inspector: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
492
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
493
|
-
token: z.ZodDefault<z.ZodOptional<z.ZodCustom<() => string, () => string>>>;
|
|
494
|
-
defaultEndpoint: z.ZodOptional<z.ZodString>;
|
|
495
|
-
}, z.core.$strip>>>;
|
|
496
|
-
disableDefaultServer: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
497
|
-
defaultServerPort: z.ZodDefault<z.ZodNumber>;
|
|
498
|
-
runEngine: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
499
|
-
runEngineVersion: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
500
|
-
overrideServerAddress: z.ZodOptional<z.ZodString>;
|
|
501
|
-
disableActorDriver: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
502
|
-
runnerKind: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
543
|
+
declare const LegacyRunnerConfigSchema: z$1.ZodDefault<z$1.ZodPipe<z$1.ZodObject<{
|
|
544
|
+
driver: z$1.ZodOptional<z$1.ZodObject<{
|
|
545
|
+
name: z$1.ZodString;
|
|
546
|
+
manager: z$1.ZodCustom<ManagerDriverBuilder, ManagerDriverBuilder>;
|
|
547
|
+
actor: z$1.ZodCustom<ActorDriverBuilder, ActorDriverBuilder>;
|
|
548
|
+
}, z$1.core.$strip>>;
|
|
549
|
+
maxIncomingMessageSize: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
|
|
550
|
+
maxOutgoingMessageSize: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
|
|
551
|
+
inspector: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodObject<{
|
|
552
|
+
enabled: z$1.ZodDefault<z$1.ZodBoolean>;
|
|
553
|
+
token: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodCustom<() => string, () => string>>>;
|
|
554
|
+
defaultEndpoint: z$1.ZodOptional<z$1.ZodString>;
|
|
555
|
+
}, z$1.core.$strip>>>;
|
|
556
|
+
disableDefaultServer: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
|
|
557
|
+
defaultServerPort: z$1.ZodDefault<z$1.ZodNumber>;
|
|
558
|
+
runEngine: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
|
|
559
|
+
runEngineVersion: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
|
|
560
|
+
overrideServerAddress: z$1.ZodOptional<z$1.ZodString>;
|
|
561
|
+
disableActorDriver: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
|
|
562
|
+
runnerKind: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodEnum<{
|
|
503
563
|
serverless: "serverless";
|
|
504
564
|
normal: "normal";
|
|
505
565
|
}>>>;
|
|
506
|
-
basePath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
507
|
-
noWelcome: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
508
|
-
logging: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
509
|
-
baseLogger: z.ZodOptional<z.ZodCustom<Logger, Logger>>;
|
|
510
|
-
level: z.ZodOptional<z.ZodEnum<{
|
|
566
|
+
basePath: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
|
|
567
|
+
noWelcome: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
|
|
568
|
+
logging: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodObject<{
|
|
569
|
+
baseLogger: z$1.ZodOptional<z$1.ZodCustom<Logger, Logger>>;
|
|
570
|
+
level: z$1.ZodOptional<z$1.ZodEnum<{
|
|
511
571
|
error: "error";
|
|
512
572
|
trace: "trace";
|
|
513
573
|
fatal: "fatal";
|
|
@@ -516,33 +576,33 @@ declare const LegacyRunnerConfigSchema: z.ZodDefault<z.ZodPipe<z.ZodObject<{
|
|
|
516
576
|
debug: "debug";
|
|
517
577
|
silent: "silent";
|
|
518
578
|
}>>;
|
|
519
|
-
}, z.core.$strip>>>;
|
|
520
|
-
autoConfigureServerless: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
521
|
-
url: z.ZodOptional<z.ZodString>;
|
|
522
|
-
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
523
|
-
maxRunners: z.ZodOptional<z.ZodNumber>;
|
|
524
|
-
minRunners: z.ZodOptional<z.ZodNumber>;
|
|
525
|
-
requestLifespan: z.ZodOptional<z.ZodNumber>;
|
|
526
|
-
runnersMargin: z.ZodOptional<z.ZodNumber>;
|
|
527
|
-
slotsPerRunner: z.ZodOptional<z.ZodNumber>;
|
|
528
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
529
|
-
}, z.core.$strip>]>>;
|
|
530
|
-
endpoint: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string, string | undefined>>;
|
|
531
|
-
token: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
|
|
532
|
-
namespace: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
|
|
533
|
-
runnerName: z.ZodDefault<z.ZodString>;
|
|
534
|
-
encoding: z.ZodDefault<z.ZodEnum<{
|
|
579
|
+
}, z$1.core.$strip>>>;
|
|
580
|
+
autoConfigureServerless: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodBoolean, z$1.ZodObject<{
|
|
581
|
+
url: z$1.ZodOptional<z$1.ZodString>;
|
|
582
|
+
headers: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
583
|
+
maxRunners: z$1.ZodOptional<z$1.ZodNumber>;
|
|
584
|
+
minRunners: z$1.ZodOptional<z$1.ZodNumber>;
|
|
585
|
+
requestLifespan: z$1.ZodOptional<z$1.ZodNumber>;
|
|
586
|
+
runnersMargin: z$1.ZodOptional<z$1.ZodNumber>;
|
|
587
|
+
slotsPerRunner: z$1.ZodOptional<z$1.ZodNumber>;
|
|
588
|
+
metadata: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
589
|
+
}, z$1.core.$strip>]>>;
|
|
590
|
+
endpoint: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string, string | undefined>>;
|
|
591
|
+
token: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string | undefined, string | undefined>>;
|
|
592
|
+
namespace: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string | undefined, string | undefined>>;
|
|
593
|
+
runnerName: z$1.ZodDefault<z$1.ZodString>;
|
|
594
|
+
encoding: z$1.ZodDefault<z$1.ZodEnum<{
|
|
535
595
|
json: "json";
|
|
536
596
|
cbor: "cbor";
|
|
537
597
|
bare: "bare";
|
|
538
598
|
}>>;
|
|
539
|
-
headers: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
540
|
-
getUpgradeWebSocket: z.ZodOptional<z.ZodCustom<GetUpgradeWebSocket, GetUpgradeWebSocket>>;
|
|
541
|
-
disableMetadataLookup: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
542
|
-
devtools: z.ZodDefault<z.ZodBoolean>;
|
|
543
|
-
runnerKey: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
|
|
544
|
-
totalSlots: z.ZodDefault<z.ZodNumber>;
|
|
545
|
-
}, z.core.$strip>, z.ZodTransform<{
|
|
599
|
+
headers: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>>;
|
|
600
|
+
getUpgradeWebSocket: z$1.ZodOptional<z$1.ZodCustom<GetUpgradeWebSocket, GetUpgradeWebSocket>>;
|
|
601
|
+
disableMetadataLookup: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
|
|
602
|
+
devtools: z$1.ZodDefault<z$1.ZodBoolean>;
|
|
603
|
+
runnerKey: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string | undefined, string | undefined>>;
|
|
604
|
+
totalSlots: z$1.ZodDefault<z$1.ZodNumber>;
|
|
605
|
+
}, z$1.core.$strip>, z$1.ZodTransform<{
|
|
546
606
|
runnerKey: string | undefined;
|
|
547
607
|
endpoint: string | undefined;
|
|
548
608
|
namespace: string;
|
|
@@ -637,7 +697,7 @@ declare const LegacyRunnerConfigSchema: z.ZodDefault<z.ZodPipe<z.ZodObject<{
|
|
|
637
697
|
} | undefined;
|
|
638
698
|
getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
|
|
639
699
|
}>>>;
|
|
640
|
-
type LegacyRunnerConfigInput = z.input<typeof LegacyRunnerConfigSchema>;
|
|
700
|
+
type LegacyRunnerConfigInput = z$1.input<typeof LegacyRunnerConfigSchema>;
|
|
641
701
|
|
|
642
702
|
type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
|
|
643
703
|
interface ServerlessHandler {
|
|
@@ -687,44 +747,44 @@ declare class Registry<A extends RegistryActors> {
|
|
|
687
747
|
}
|
|
688
748
|
declare function setup<A extends RegistryActors>(input: RegistryConfigInput<A>): Registry<A>;
|
|
689
749
|
|
|
690
|
-
declare const ActorKeySchema: z.ZodArray<z.ZodString>;
|
|
691
|
-
type ActorKey = z.infer<typeof ActorKeySchema>;
|
|
692
|
-
declare const CreateRequestSchema: z.ZodObject<{
|
|
693
|
-
name: z.ZodString;
|
|
694
|
-
key: z.ZodArray<z.ZodString>;
|
|
695
|
-
input: z.ZodOptional<z.ZodUnknown>;
|
|
696
|
-
region: z.ZodOptional<z.ZodString>;
|
|
697
|
-
}, z.core.$strip>;
|
|
698
|
-
declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
699
|
-
getForId: z.ZodObject<{
|
|
700
|
-
name: z.ZodString;
|
|
701
|
-
actorId: z.ZodString;
|
|
702
|
-
}, z.core.$strip>;
|
|
703
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
704
|
-
getForKey: z.ZodObject<{
|
|
705
|
-
name: z.ZodString;
|
|
706
|
-
key: z.ZodArray<z.ZodString>;
|
|
707
|
-
}, z.core.$strip>;
|
|
708
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
709
|
-
getOrCreateForKey: z.ZodObject<{
|
|
710
|
-
name: z.ZodString;
|
|
711
|
-
key: z.ZodArray<z.ZodString>;
|
|
712
|
-
input: z.ZodOptional<z.ZodUnknown>;
|
|
713
|
-
region: z.ZodOptional<z.ZodString>;
|
|
714
|
-
}, z.core.$strip>;
|
|
715
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
716
|
-
create: z.ZodObject<{
|
|
717
|
-
name: z.ZodString;
|
|
718
|
-
key: z.ZodArray<z.ZodString>;
|
|
719
|
-
input: z.ZodOptional<z.ZodUnknown>;
|
|
720
|
-
region: z.ZodOptional<z.ZodString>;
|
|
721
|
-
}, z.core.$strip>;
|
|
722
|
-
}, z.core.$strip>]>;
|
|
723
|
-
type ActorQuery = z.infer<typeof ActorQuerySchema>;
|
|
750
|
+
declare const ActorKeySchema: z$1.ZodArray<z$1.ZodString>;
|
|
751
|
+
type ActorKey = z$1.infer<typeof ActorKeySchema>;
|
|
752
|
+
declare const CreateRequestSchema: z$1.ZodObject<{
|
|
753
|
+
name: z$1.ZodString;
|
|
754
|
+
key: z$1.ZodArray<z$1.ZodString>;
|
|
755
|
+
input: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
756
|
+
region: z$1.ZodOptional<z$1.ZodString>;
|
|
757
|
+
}, z$1.core.$strip>;
|
|
758
|
+
declare const ActorQuerySchema: z$1.ZodUnion<readonly [z$1.ZodObject<{
|
|
759
|
+
getForId: z$1.ZodObject<{
|
|
760
|
+
name: z$1.ZodString;
|
|
761
|
+
actorId: z$1.ZodString;
|
|
762
|
+
}, z$1.core.$strip>;
|
|
763
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
764
|
+
getForKey: z$1.ZodObject<{
|
|
765
|
+
name: z$1.ZodString;
|
|
766
|
+
key: z$1.ZodArray<z$1.ZodString>;
|
|
767
|
+
}, z$1.core.$strip>;
|
|
768
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
769
|
+
getOrCreateForKey: z$1.ZodObject<{
|
|
770
|
+
name: z$1.ZodString;
|
|
771
|
+
key: z$1.ZodArray<z$1.ZodString>;
|
|
772
|
+
input: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
773
|
+
region: z$1.ZodOptional<z$1.ZodString>;
|
|
774
|
+
}, z$1.core.$strip>;
|
|
775
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
776
|
+
create: z$1.ZodObject<{
|
|
777
|
+
name: z$1.ZodString;
|
|
778
|
+
key: z$1.ZodArray<z$1.ZodString>;
|
|
779
|
+
input: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
780
|
+
region: z$1.ZodOptional<z$1.ZodString>;
|
|
781
|
+
}, z$1.core.$strip>;
|
|
782
|
+
}, z$1.core.$strip>]>;
|
|
783
|
+
type ActorQuery = z$1.infer<typeof ActorQuerySchema>;
|
|
724
784
|
/**
|
|
725
785
|
* Interface representing a request to create a actor.
|
|
726
786
|
*/
|
|
727
|
-
type CreateRequest = z.infer<typeof CreateRequestSchema>;
|
|
787
|
+
type CreateRequest = z$1.infer<typeof CreateRequestSchema>;
|
|
728
788
|
|
|
729
789
|
/**
|
|
730
790
|
* Action function returned by Actor connections and handles.
|
|
@@ -739,7 +799,7 @@ type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unk
|
|
|
739
799
|
/**
|
|
740
800
|
* Maps action methods from actor definition to typed function signatures.
|
|
741
801
|
*/
|
|
742
|
-
type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends ActorDefinition<any, any, any, any, any, any, infer R> ? {
|
|
802
|
+
type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends ActorDefinition<any, any, any, any, any, any, any, any, infer R> ? {
|
|
743
803
|
[K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
|
|
744
804
|
} : never;
|
|
745
805
|
|
|
@@ -764,6 +824,21 @@ declare class ActorConnDisposed extends ActorClientError {
|
|
|
764
824
|
constructor();
|
|
765
825
|
}
|
|
766
826
|
|
|
827
|
+
interface QueueSendWaitOptions {
|
|
828
|
+
wait: true;
|
|
829
|
+
timeout?: number;
|
|
830
|
+
signal?: AbortSignal;
|
|
831
|
+
}
|
|
832
|
+
interface QueueSendNoWaitOptions {
|
|
833
|
+
wait?: false;
|
|
834
|
+
timeout?: never;
|
|
835
|
+
signal?: AbortSignal;
|
|
836
|
+
}
|
|
837
|
+
interface QueueSendResult {
|
|
838
|
+
status: "completed" | "timedOut";
|
|
839
|
+
response?: unknown;
|
|
840
|
+
}
|
|
841
|
+
|
|
767
842
|
/**
|
|
768
843
|
* Connection status for an actor connection.
|
|
769
844
|
*
|
|
@@ -813,6 +888,8 @@ declare class ActorConnRaw {
|
|
|
813
888
|
* @protected
|
|
814
889
|
*/
|
|
815
890
|
constructor(client: ClientRaw, driver: ManagerDriver, params: unknown, encoding: Encoding, actorQuery: ActorQuery);
|
|
891
|
+
send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
892
|
+
send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
816
893
|
/**
|
|
817
894
|
* Call a raw action connection. See {@link ActorConn} for type-safe action calls.
|
|
818
895
|
*
|
|
@@ -830,7 +907,6 @@ declare class ActorConnRaw {
|
|
|
830
907
|
}): Promise<Response>;
|
|
831
908
|
/**
|
|
832
909
|
* Do not call this directly.
|
|
833
|
-
enc
|
|
834
910
|
* Establishes a connection to the server using the specified endpoint & encoding & driver.
|
|
835
911
|
*
|
|
836
912
|
* @protected
|
|
@@ -944,6 +1020,8 @@ declare class ActorHandleRaw {
|
|
|
944
1020
|
* @protected
|
|
945
1021
|
*/
|
|
946
1022
|
constructor(client: any, driver: ManagerDriver, params: unknown, encoding: Encoding, actorQuery: ActorQuery);
|
|
1023
|
+
send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
1024
|
+
send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
947
1025
|
/**
|
|
948
1026
|
* Call a raw action. This method sends an HTTP request to invoke the named action.
|
|
949
1027
|
*
|
|
@@ -964,27 +1042,18 @@ declare class ActorHandleRaw {
|
|
|
964
1042
|
*/
|
|
965
1043
|
connect(): ActorConn<AnyActorDefinition>;
|
|
966
1044
|
/**
|
|
967
|
-
*
|
|
968
|
-
*
|
|
969
|
-
* @param input - The URL, path, or Request object
|
|
970
|
-
* @param init - Standard fetch RequestInit options
|
|
971
|
-
* @returns Promise<Response> - The raw HTTP response
|
|
1045
|
+
* Fetches a resource from this actor via the /request endpoint. This is a
|
|
1046
|
+
* convenience wrapper around the raw HTTP API.
|
|
972
1047
|
*/
|
|
973
1048
|
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
974
1049
|
/**
|
|
975
|
-
*
|
|
976
|
-
*
|
|
977
|
-
* @param path - The path for the WebSocket connection (e.g., "stream")
|
|
978
|
-
* @param protocols - Optional WebSocket subprotocols
|
|
979
|
-
* @returns WebSocket - A raw WebSocket connection
|
|
1050
|
+
* Opens a raw WebSocket connection to this actor.
|
|
980
1051
|
*/
|
|
981
|
-
|
|
1052
|
+
webSocket(path?: string, protocols?: string | string[]): Promise<any>;
|
|
982
1053
|
/**
|
|
983
1054
|
* Resolves the actor to get its unique actor ID.
|
|
984
1055
|
*/
|
|
985
|
-
resolve(
|
|
986
|
-
signal?: AbortSignal;
|
|
987
|
-
}): Promise<string>;
|
|
1056
|
+
resolve(): Promise<string>;
|
|
988
1057
|
/**
|
|
989
1058
|
* Returns the raw URL for routing traffic to the actor.
|
|
990
1059
|
*/
|
|
@@ -1203,32 +1272,9 @@ declare function createClientWithDriver<A extends Registry<any>>(driver: Manager
|
|
|
1203
1272
|
interface ActorInspectorEmitterEvents {
|
|
1204
1273
|
stateUpdated: (state: unknown) => void;
|
|
1205
1274
|
connectionsUpdated: () => void;
|
|
1206
|
-
|
|
1207
|
-
|
|
1275
|
+
queueUpdated: () => void;
|
|
1276
|
+
workflowHistoryUpdated: (history: WorkflowHistory) => void;
|
|
1208
1277
|
}
|
|
1209
|
-
type EventDetails = {
|
|
1210
|
-
type: "action";
|
|
1211
|
-
name: string;
|
|
1212
|
-
args: unknown[];
|
|
1213
|
-
connId: string;
|
|
1214
|
-
} | {
|
|
1215
|
-
type: "subscribe";
|
|
1216
|
-
eventName: string;
|
|
1217
|
-
connId: string;
|
|
1218
|
-
} | {
|
|
1219
|
-
type: "unsubscribe";
|
|
1220
|
-
eventName: string;
|
|
1221
|
-
connId: string;
|
|
1222
|
-
} | {
|
|
1223
|
-
type: "event";
|
|
1224
|
-
eventName: string;
|
|
1225
|
-
args: unknown[];
|
|
1226
|
-
connId: string;
|
|
1227
|
-
} | {
|
|
1228
|
-
type: "broadcast";
|
|
1229
|
-
eventName: string;
|
|
1230
|
-
args: unknown[];
|
|
1231
|
-
};
|
|
1232
1278
|
/**
|
|
1233
1279
|
* Provides a unified interface for inspecting actor external and internal state.
|
|
1234
1280
|
*/
|
|
@@ -1237,9 +1283,14 @@ declare class ActorInspector {
|
|
|
1237
1283
|
private readonly actor;
|
|
1238
1284
|
readonly emitter: nanoevents.Emitter<ActorInspectorEmitterEvents>;
|
|
1239
1285
|
constructor(actor: AnyActorInstance);
|
|
1240
|
-
|
|
1241
|
-
|
|
1286
|
+
getQueueSize(): number;
|
|
1287
|
+
getQueueStatus(limit: number): Promise<QueueStatus>;
|
|
1288
|
+
updateQueueSize(size: number): void;
|
|
1289
|
+
isWorkflowEnabled(): boolean;
|
|
1290
|
+
getWorkflowHistory(): WorkflowHistory | null;
|
|
1242
1291
|
isDatabaseEnabled(): boolean;
|
|
1292
|
+
getDatabaseSchema(): Promise<ArrayBuffer>;
|
|
1293
|
+
getDatabaseTableRows(table: string, limit: number, offset: number): Promise<ArrayBuffer>;
|
|
1243
1294
|
isStateEnabled(): boolean;
|
|
1244
1295
|
getState(): ArrayBuffer;
|
|
1245
1296
|
getRpcs(): string[];
|
|
@@ -1250,6 +1301,35 @@ declare class ActorInspector {
|
|
|
1250
1301
|
}[];
|
|
1251
1302
|
setState(state: ArrayBuffer): Promise<void>;
|
|
1252
1303
|
executeAction(name: string, params: ArrayBuffer): Promise<ArrayBuffer>;
|
|
1304
|
+
getStateJson(): unknown;
|
|
1305
|
+
setStateJson(state: unknown): Promise<void>;
|
|
1306
|
+
getConnectionsJson(): {
|
|
1307
|
+
id: string;
|
|
1308
|
+
details: unknown;
|
|
1309
|
+
}[];
|
|
1310
|
+
executeActionJson(name: string, args: unknown[]): Promise<unknown>;
|
|
1311
|
+
getTracesJson(options: {
|
|
1312
|
+
startMs: number;
|
|
1313
|
+
endMs: number;
|
|
1314
|
+
limit: number;
|
|
1315
|
+
}): Promise<{
|
|
1316
|
+
otlp: unknown;
|
|
1317
|
+
clamped: boolean;
|
|
1318
|
+
}>;
|
|
1319
|
+
getWorkflowHistoryJson(): {
|
|
1320
|
+
history: unknown | null;
|
|
1321
|
+
isWorkflowEnabled: boolean;
|
|
1322
|
+
};
|
|
1323
|
+
getQueueStatusJson(limit: number): Promise<{
|
|
1324
|
+
size: number;
|
|
1325
|
+
maxSize: number;
|
|
1326
|
+
truncated: boolean;
|
|
1327
|
+
messages: {
|
|
1328
|
+
id: number;
|
|
1329
|
+
name: string;
|
|
1330
|
+
createdAtMs: number;
|
|
1331
|
+
}[];
|
|
1332
|
+
}>;
|
|
1253
1333
|
}
|
|
1254
1334
|
|
|
1255
1335
|
/**
|
|
@@ -1307,6 +1387,95 @@ declare class ActorKv {
|
|
|
1307
1387
|
list<T extends KvValueType = "text", K extends KvKeyType = "text">(prefix: KvKeyTypeMap[K], options?: KvListOptions<T, K>): Promise<[KvKeyTypeMap[K], KvValueTypeMap[T]][]>;
|
|
1308
1388
|
}
|
|
1309
1389
|
|
|
1390
|
+
interface QueueMessage {
|
|
1391
|
+
id: bigint;
|
|
1392
|
+
name: string;
|
|
1393
|
+
body: unknown;
|
|
1394
|
+
createdAt: number;
|
|
1395
|
+
}
|
|
1396
|
+
declare class QueueManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
|
|
1397
|
+
#private;
|
|
1398
|
+
constructor(actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>, driver: ActorDriver);
|
|
1399
|
+
/** Returns the current number of messages in the queue. */
|
|
1400
|
+
get size(): number;
|
|
1401
|
+
/** Loads queue metadata from storage and initializes internal state. */
|
|
1402
|
+
initialize(): Promise<void>;
|
|
1403
|
+
/** Adds a message to the queue with the given name and body. */
|
|
1404
|
+
enqueue(name: string, body: unknown): Promise<QueueMessage>;
|
|
1405
|
+
/**
|
|
1406
|
+
* Adds a message and waits for completion.
|
|
1407
|
+
*/
|
|
1408
|
+
enqueueAndWait(name: string, body: unknown, timeout?: number): Promise<{
|
|
1409
|
+
status: "completed" | "timedOut";
|
|
1410
|
+
response?: unknown;
|
|
1411
|
+
}>;
|
|
1412
|
+
completeMessage(message: QueueMessage, response?: unknown): Promise<void>;
|
|
1413
|
+
completeMessageById(messageId: bigint, response?: unknown): Promise<void>;
|
|
1414
|
+
/** Receives messages from the queue matching the given names. Waits until messages are available or timeout is reached. */
|
|
1415
|
+
receive(names: string[] | undefined, count: number, timeout?: number, abortSignal?: AbortSignal, completable?: boolean): Promise<QueueMessage[]>;
|
|
1416
|
+
waitForNames(names: readonly string[] | undefined, abortSignal?: AbortSignal): Promise<void>;
|
|
1417
|
+
/** Returns all messages currently in the queue without removing them. */
|
|
1418
|
+
getMessages(): Promise<QueueMessage[]>;
|
|
1419
|
+
/** Deletes messages matching the provided IDs. Returns the IDs that were removed. */
|
|
1420
|
+
deleteMessagesById(ids: bigint[]): Promise<bigint[]>;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
type QueueMessageOf<Name extends string, Body> = Omit<QueueMessage, "name" | "body"> & {
|
|
1424
|
+
name: Name;
|
|
1425
|
+
body: Body;
|
|
1426
|
+
};
|
|
1427
|
+
type QueueName<TQueues extends QueueSchemaConfig> = keyof TQueues & string;
|
|
1428
|
+
type QueueFilterName<TQueues extends QueueSchemaConfig> = keyof TQueues extends never ? string : QueueName<TQueues>;
|
|
1429
|
+
type QueueMessageForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>> = keyof TQueues extends never ? QueueMessage : TName extends QueueName<TQueues> ? QueueMessageOf<TName, InferSchemaMap<TQueues>[TName]> : never;
|
|
1430
|
+
type QueueCompleteArgs<T> = undefined extends T ? [response?: T] : [response: T];
|
|
1431
|
+
type QueueCompleteArgsForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>> = keyof TQueues extends never ? [response?: unknown] : TName extends QueueName<TQueues> ? [InferQueueCompleteMap<TQueues>[TName]] extends [never] ? [response?: unknown] : QueueCompleteArgs<InferQueueCompleteMap<TQueues>[TName]> : [response?: unknown];
|
|
1432
|
+
type QueueCompletableMessageForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>> = QueueMessageForName<TQueues, TName> & {
|
|
1433
|
+
complete(...args: QueueCompleteArgsForName<TQueues, TName>): Promise<void>;
|
|
1434
|
+
};
|
|
1435
|
+
type QueueResultMessageForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>, TCompletable extends boolean> = TCompletable extends true ? QueueCompletableMessageForName<TQueues, TName> : QueueMessageForName<TQueues, TName>;
|
|
1436
|
+
/** Options for receiving queue messages. */
|
|
1437
|
+
interface QueueNextOptions<TName extends string = string, TCompletable extends boolean = boolean> {
|
|
1438
|
+
/** Queue names to receive from. If omitted, reads from all queue names. */
|
|
1439
|
+
names?: readonly TName[];
|
|
1440
|
+
/** Maximum number of messages to receive. Defaults to 1. */
|
|
1441
|
+
count?: number;
|
|
1442
|
+
/** Timeout in milliseconds. Omit to wait indefinitely. */
|
|
1443
|
+
timeout?: number;
|
|
1444
|
+
/** Optional abort signal for this receive call. */
|
|
1445
|
+
signal?: AbortSignal;
|
|
1446
|
+
/** Whether to return completable messages. */
|
|
1447
|
+
completable?: TCompletable;
|
|
1448
|
+
}
|
|
1449
|
+
/** Options for non-blocking queue reads. */
|
|
1450
|
+
interface QueueTryNextOptions<TName extends string = string, TCompletable extends boolean = boolean> {
|
|
1451
|
+
/** Queue names to receive from. If omitted, reads from all queue names. */
|
|
1452
|
+
names?: readonly TName[];
|
|
1453
|
+
/** Maximum number of messages to receive. Defaults to 1. */
|
|
1454
|
+
count?: number;
|
|
1455
|
+
/** Whether to return completable messages. */
|
|
1456
|
+
completable?: TCompletable;
|
|
1457
|
+
}
|
|
1458
|
+
/** Options for queue async iteration. */
|
|
1459
|
+
interface QueueIterOptions<TName extends string = string, TCompletable extends boolean = boolean> {
|
|
1460
|
+
/** Queue names to receive from. If omitted, reads from all queue names. */
|
|
1461
|
+
names?: readonly TName[];
|
|
1462
|
+
/** Optional abort signal for this iterator. */
|
|
1463
|
+
signal?: AbortSignal;
|
|
1464
|
+
/** Whether to return completable messages. */
|
|
1465
|
+
completable?: TCompletable;
|
|
1466
|
+
}
|
|
1467
|
+
/** User-facing queue interface exposed on ActorContext. */
|
|
1468
|
+
declare class ActorQueue<S, CP, CS, V, I, DB extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1469
|
+
#private;
|
|
1470
|
+
constructor(queueManager: QueueManager<S, CP, CS, V, I, DB, TEvents, TQueues>, abortSignal: AbortSignal);
|
|
1471
|
+
next<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextOptions<TName, TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, TName, TCompletable>>>;
|
|
1472
|
+
tryNext<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextOptions<TName, TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, TName, TCompletable>>>;
|
|
1473
|
+
iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterableIterator<QueueResultMessageForName<TQueues, TName, TCompletable>>;
|
|
1474
|
+
/** Sends a message to the specified queue. */
|
|
1475
|
+
send<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K]): Promise<QueueMessage>;
|
|
1476
|
+
send(name: keyof TQueues extends never ? string : never, body: unknown): Promise<QueueMessage>;
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1310
1479
|
declare class Schedule {
|
|
1311
1480
|
#private;
|
|
1312
1481
|
constructor(actor: AnyActorInstance);
|
|
@@ -1314,12 +1483,14 @@ declare class Schedule {
|
|
|
1314
1483
|
at(timestamp: number, fn: string, ...args: unknown[]): Promise<void>;
|
|
1315
1484
|
}
|
|
1316
1485
|
|
|
1486
|
+
declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
|
|
1317
1487
|
/**
|
|
1318
1488
|
* ActorContext class that provides access to actor methods and state
|
|
1319
1489
|
*/
|
|
1320
|
-
declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1490
|
+
declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1321
1491
|
#private;
|
|
1322
|
-
|
|
1492
|
+
[ACTOR_CONTEXT_INTERNAL_SYMBOL]: AnyActorInstance;
|
|
1493
|
+
constructor(actor: ActorInstance<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>);
|
|
1323
1494
|
/**
|
|
1324
1495
|
* Gets the KV storage interface.
|
|
1325
1496
|
*/
|
|
@@ -1344,11 +1515,16 @@ declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TData
|
|
|
1344
1515
|
* @param name - The name of the event.
|
|
1345
1516
|
* @param args - The arguments to send with the event.
|
|
1346
1517
|
*/
|
|
1347
|
-
broadcast<
|
|
1518
|
+
broadcast<K extends keyof TEvents & string>(name: K, ...args: InferEventArgs<InferSchemaMap<TEvents>[K]>): void;
|
|
1519
|
+
broadcast(name: keyof TEvents extends never ? string : never, ...args: Array<unknown>): void;
|
|
1348
1520
|
/**
|
|
1349
1521
|
* Gets the logger instance.
|
|
1350
1522
|
*/
|
|
1351
1523
|
get log(): Logger;
|
|
1524
|
+
/**
|
|
1525
|
+
* Access to queue receive helpers.
|
|
1526
|
+
*/
|
|
1527
|
+
get queue(): ActorQueue<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1352
1528
|
/**
|
|
1353
1529
|
* Gets actor ID.
|
|
1354
1530
|
*/
|
|
@@ -1372,7 +1548,7 @@ declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TData
|
|
|
1372
1548
|
/**
|
|
1373
1549
|
* Gets the map of connections.
|
|
1374
1550
|
*/
|
|
1375
|
-
get conns(): Map<ConnId, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>>;
|
|
1551
|
+
get conns(): Map<ConnId, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
|
|
1376
1552
|
/**
|
|
1377
1553
|
* Returns the client for the given registry.
|
|
1378
1554
|
*/
|
|
@@ -1396,10 +1572,26 @@ declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TData
|
|
|
1396
1572
|
* Prevents the actor from sleeping until promise is complete.
|
|
1397
1573
|
*/
|
|
1398
1574
|
waitUntil(promise: Promise<void>): void;
|
|
1575
|
+
/**
|
|
1576
|
+
* Prevents the actor from sleeping while the given promise is running.
|
|
1577
|
+
*
|
|
1578
|
+
* Use this when performing async operations in the `run` handler or other
|
|
1579
|
+
* background contexts where you need to ensure the actor stays awake.
|
|
1580
|
+
*
|
|
1581
|
+
* Returns the resolved value and resets the sleep timer on completion.
|
|
1582
|
+
* Errors are propagated to the caller.
|
|
1583
|
+
*/
|
|
1584
|
+
keepAwake<T>(promise: Promise<T>): Promise<T>;
|
|
1399
1585
|
/**
|
|
1400
1586
|
* AbortSignal that fires when the actor is stopping.
|
|
1401
1587
|
*/
|
|
1402
1588
|
get abortSignal(): AbortSignal;
|
|
1589
|
+
/**
|
|
1590
|
+
* True when the actor is stopping.
|
|
1591
|
+
*
|
|
1592
|
+
* Alias for `c.abortSignal.aborted`.
|
|
1593
|
+
*/
|
|
1594
|
+
get aborted(): boolean;
|
|
1403
1595
|
/**
|
|
1404
1596
|
* Forces the actor to sleep.
|
|
1405
1597
|
*
|
|
@@ -1417,141 +1609,153 @@ declare class ActorContext<TState, TConnParams, TConnState, TVars, TInput, TData
|
|
|
1417
1609
|
*/
|
|
1418
1610
|
destroy(): void;
|
|
1419
1611
|
}
|
|
1420
|
-
type ActorContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? ActorContext<S, CP, CS, V, I, DB> : never;
|
|
1612
|
+
type ActorContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? ActorContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
1421
1613
|
|
|
1422
1614
|
/**
|
|
1423
1615
|
* Base context for connection-based handlers.
|
|
1424
1616
|
* Extends ActorContext with connection-specific functionality.
|
|
1425
1617
|
*/
|
|
1426
|
-
declare abstract class ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1427
|
-
readonly conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
|
|
1618
|
+
declare abstract class ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1619
|
+
readonly conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1428
1620
|
}
|
|
1429
|
-
type ConnContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? ConnContext<S, CP, CS, V, I, DB> : never;
|
|
1621
|
+
type ConnContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? ConnContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
1622
|
+
|
|
1623
|
+
/**
|
|
1624
|
+
* Context for a remote procedure call.
|
|
1625
|
+
*/
|
|
1626
|
+
declare class ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1627
|
+
}
|
|
1628
|
+
/**
|
|
1629
|
+
* Extracts the ActionContext type from an ActorDefinition.
|
|
1630
|
+
*/
|
|
1631
|
+
type ActionContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? ActionContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
1430
1632
|
|
|
1431
1633
|
/**
|
|
1432
1634
|
* Base context for connection initialization handlers.
|
|
1433
1635
|
* Extends ActorContext with request-specific functionality for connection lifecycle events.
|
|
1434
1636
|
*/
|
|
1435
|
-
declare abstract class ConnInitContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1637
|
+
declare abstract class ConnInitContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, never, never, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1436
1638
|
/**
|
|
1437
1639
|
* The incoming request that initiated the connection.
|
|
1438
1640
|
* May be undefined for connections initiated without a direct HTTP request.
|
|
1439
1641
|
*/
|
|
1440
1642
|
readonly request: Request | undefined;
|
|
1441
1643
|
}
|
|
1442
|
-
type ConnInitContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? ConnInitContext<S, V, I, DB> : never;
|
|
1443
|
-
|
|
1444
|
-
/**
|
|
1445
|
-
* Context for a remote procedure call.
|
|
1446
|
-
*/
|
|
1447
|
-
declare class ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> extends ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase> {
|
|
1448
|
-
}
|
|
1449
|
-
/**
|
|
1450
|
-
* Extracts the ActionContext type from an ActorDefinition.
|
|
1451
|
-
*/
|
|
1452
|
-
type ActionContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? ActionContext<S, CP, CS, V, I, DB> : never;
|
|
1644
|
+
type ConnInitContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? ConnInitContext<S, V, I, DB, E, Q> : never;
|
|
1453
1645
|
|
|
1454
1646
|
/**
|
|
1455
1647
|
* Context for the onBeforeActionResponse lifecycle hook.
|
|
1456
1648
|
*/
|
|
1457
|
-
declare class BeforeActionResponseContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1649
|
+
declare class BeforeActionResponseContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1458
1650
|
}
|
|
1459
|
-
type BeforeActionResponseContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? BeforeActionResponseContext<S, CP, CS, V, I, DB> : never;
|
|
1651
|
+
type BeforeActionResponseContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? BeforeActionResponseContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
1460
1652
|
|
|
1461
1653
|
/**
|
|
1462
1654
|
* Context for the onBeforeConnect lifecycle hook.
|
|
1463
1655
|
*/
|
|
1464
|
-
declare class BeforeConnectContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1656
|
+
declare class BeforeConnectContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ConnInitContext<TState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1465
1657
|
}
|
|
1466
|
-
type BeforeConnectContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? BeforeConnectContext<S, V, I, DB> : never;
|
|
1658
|
+
type BeforeConnectContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? BeforeConnectContext<S, V, I, DB, E, Q> : never;
|
|
1467
1659
|
|
|
1468
1660
|
/**
|
|
1469
1661
|
* Context for the onConnect lifecycle hook.
|
|
1470
1662
|
*/
|
|
1471
|
-
declare class ConnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1663
|
+
declare class ConnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1472
1664
|
}
|
|
1473
|
-
type ConnectContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? ConnectContext<S, CP, CS, V, I, DB> : never;
|
|
1665
|
+
type ConnectContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? ConnectContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
1474
1666
|
|
|
1475
1667
|
/**
|
|
1476
1668
|
* Context for the onCreate lifecycle hook.
|
|
1477
1669
|
*/
|
|
1478
|
-
declare class CreateContext<TState, TInput, TDatabase extends AnyDatabaseProvider
|
|
1670
|
+
declare class CreateContext<TState, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, never, never, never, TInput, TDatabase, TEvents, TQueues> {
|
|
1479
1671
|
}
|
|
1480
|
-
type CreateContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, any, infer I, infer DB extends AnyDatabaseProvider, any> ? CreateContext<S, I, DB> : never;
|
|
1672
|
+
type CreateContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, any, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? CreateContext<S, I, DB, E, Q> : never;
|
|
1481
1673
|
|
|
1482
1674
|
/**
|
|
1483
1675
|
* Context for the createConnState lifecycle hook.
|
|
1484
1676
|
* Called to initialize connection-specific state when a connection is created.
|
|
1485
1677
|
*/
|
|
1486
|
-
declare class CreateConnStateContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1678
|
+
declare class CreateConnStateContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ConnInitContext<TState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1487
1679
|
}
|
|
1488
|
-
type CreateConnStateContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? CreateConnStateContext<S, V, I, DB> : never;
|
|
1680
|
+
type CreateConnStateContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? CreateConnStateContext<S, V, I, DB, E, Q> : never;
|
|
1489
1681
|
|
|
1490
1682
|
/**
|
|
1491
1683
|
* Context for the createVars lifecycle hook.
|
|
1492
1684
|
*/
|
|
1493
|
-
declare class CreateVarsContext<TState, TInput, TDatabase extends AnyDatabaseProvider
|
|
1685
|
+
declare class CreateVarsContext<TState, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, never, never, never, TInput, TDatabase, TEvents, TQueues> {
|
|
1494
1686
|
}
|
|
1495
|
-
type CreateVarsContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, any, infer I, infer DB extends AnyDatabaseProvider, any> ? CreateVarsContext<S, I, DB> : never;
|
|
1687
|
+
type CreateVarsContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, any, any, any, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? CreateVarsContext<S, I, DB, E, Q> : never;
|
|
1496
1688
|
|
|
1497
1689
|
/**
|
|
1498
1690
|
* Context for the onDestroy lifecycle hook.
|
|
1499
1691
|
*/
|
|
1500
|
-
declare class DestroyContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1692
|
+
declare class DestroyContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1501
1693
|
}
|
|
1502
|
-
type DestroyContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? DestroyContext<S, CP, CS, V, I, DB> : never;
|
|
1694
|
+
type DestroyContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? DestroyContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
1503
1695
|
|
|
1504
1696
|
/**
|
|
1505
1697
|
* Context for the onDisconnect lifecycle hook.
|
|
1506
1698
|
*/
|
|
1507
|
-
declare class DisconnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1699
|
+
declare class DisconnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1508
1700
|
}
|
|
1509
|
-
type DisconnectContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? DisconnectContext<S, CP, CS, V, I, DB> : never;
|
|
1701
|
+
type DisconnectContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? DisconnectContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
1510
1702
|
|
|
1511
1703
|
/**
|
|
1512
1704
|
* Context for raw HTTP request handlers (onRequest).
|
|
1513
1705
|
*/
|
|
1514
|
-
declare class RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1706
|
+
declare class RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1515
1707
|
/**
|
|
1516
1708
|
* The incoming HTTP request.
|
|
1517
1709
|
* May be undefined for request contexts initiated without a direct HTTP request.
|
|
1518
1710
|
*/
|
|
1519
1711
|
readonly request: Request | undefined;
|
|
1520
1712
|
}
|
|
1521
|
-
type RequestContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? RequestContext<S, CP, CS, V, I, DB> : never;
|
|
1713
|
+
type RequestContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? RequestContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
1714
|
+
|
|
1715
|
+
/**
|
|
1716
|
+
* Context for the run lifecycle hook.
|
|
1717
|
+
*
|
|
1718
|
+
* This context is passed to the `run` handler which executes after the actor
|
|
1719
|
+
* starts. It does not block actor startup and is intended for background tasks.
|
|
1720
|
+
*
|
|
1721
|
+
* Use `c.aborted` to detect when the actor is stopping and gracefully exit.
|
|
1722
|
+
*/
|
|
1723
|
+
declare class RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1724
|
+
}
|
|
1725
|
+
type RunContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? RunContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
1522
1726
|
|
|
1523
1727
|
/**
|
|
1524
1728
|
* Context for the onSleep lifecycle hook.
|
|
1525
1729
|
*/
|
|
1526
|
-
declare class SleepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1730
|
+
declare class SleepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1527
1731
|
}
|
|
1528
|
-
type SleepContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? SleepContext<S, CP, CS, V, I, DB> : never;
|
|
1732
|
+
type SleepContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? SleepContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
1529
1733
|
|
|
1530
1734
|
/**
|
|
1531
1735
|
* Context for the onStateChange lifecycle hook.
|
|
1532
1736
|
*/
|
|
1533
|
-
declare class StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1737
|
+
declare class StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1534
1738
|
}
|
|
1535
|
-
type StateChangeContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? StateChangeContext<S, CP, CS, V, I, DB> : never;
|
|
1739
|
+
type StateChangeContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? StateChangeContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
1536
1740
|
|
|
1537
1741
|
/**
|
|
1538
1742
|
* Context for the onWake lifecycle hook.
|
|
1539
1743
|
*/
|
|
1540
|
-
declare class WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1744
|
+
declare class WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1541
1745
|
}
|
|
1542
|
-
type WakeContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? WakeContext<S, CP, CS, V, I, DB> : never;
|
|
1746
|
+
type WakeContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? WakeContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
1543
1747
|
|
|
1544
1748
|
/**
|
|
1545
1749
|
* Context for raw WebSocket handlers (onWebSocket).
|
|
1546
1750
|
*/
|
|
1547
|
-
declare class WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
1751
|
+
declare class WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> extends ConnContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> {
|
|
1548
1752
|
/**
|
|
1549
1753
|
* The incoming HTTP request that initiated the WebSocket upgrade.
|
|
1550
1754
|
* May be undefined for WebSocket connections initiated without a direct HTTP request.
|
|
1551
1755
|
*/
|
|
1552
1756
|
readonly request: Request | undefined;
|
|
1553
1757
|
}
|
|
1554
|
-
type WebSocketContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, any> ? WebSocketContext<S, CP, CS, V, I, DB> : never;
|
|
1758
|
+
type WebSocketContextOf<AD extends AnyActorDefinition> = AD extends ActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? WebSocketContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
1555
1759
|
|
|
1556
1760
|
declare enum DriverReadyState {
|
|
1557
1761
|
UNKNOWN = -1,
|
|
@@ -1625,18 +1829,19 @@ interface PersistedConn<CP, CS> {
|
|
|
1625
1829
|
* Manages all connection-related operations for an actor instance.
|
|
1626
1830
|
* Handles connection creation, tracking, hibernation, and cleanup.
|
|
1627
1831
|
*/
|
|
1628
|
-
declare class ConnectionManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider
|
|
1832
|
+
declare class ConnectionManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
|
|
1629
1833
|
#private;
|
|
1630
|
-
constructor(actor: ActorInstance<S, CP, CS, V, I, DB>);
|
|
1631
|
-
get connections(): Map<ConnId, Conn<S, CP, CS, V, I, DB>>;
|
|
1632
|
-
getConnForId(id: string): Conn<S, CP, CS, V, I, DB> | undefined;
|
|
1834
|
+
constructor(actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>);
|
|
1835
|
+
get connections(): Map<ConnId, Conn<S, CP, CS, V, I, DB, E, Q>>;
|
|
1836
|
+
getConnForId(id: string): Conn<S, CP, CS, V, I, DB, E, Q> | undefined;
|
|
1633
1837
|
get connsWithPersistChanged(): Set<ConnId>;
|
|
1838
|
+
get pendingDisconnectCount(): number;
|
|
1634
1839
|
clearConnWithPersistChanged(): void;
|
|
1635
|
-
markConnWithPersistChanged(conn: Conn<S, CP, CS, V, I, DB>): void;
|
|
1840
|
+
markConnWithPersistChanged(conn: Conn<S, CP, CS, V, I, DB, E, Q>): void;
|
|
1636
1841
|
/**
|
|
1637
1842
|
* Handles pre-connection logic (i.e. auth & create state) before actually connecting the connection.
|
|
1638
1843
|
*/
|
|
1639
|
-
prepareConn(driver: ConnDriver, params: CP, request: Request | undefined, requestPath: string | undefined, requestHeaders: Record<string, string> | undefined, isHibernatable: boolean, isRestoringHibernatable: boolean): Promise<Conn<S, CP, CS, V, I, DB>>;
|
|
1844
|
+
prepareConn(driver: ConnDriver, params: CP, request: Request | undefined, requestPath: string | undefined, requestHeaders: Record<string, string> | undefined, isHibernatable: boolean, isRestoringHibernatable: boolean): Promise<Conn<S, CP, CS, V, I, DB, E, Q>>;
|
|
1640
1845
|
/**
|
|
1641
1846
|
* Adds a connection form prepareConn to the actor and calls onConnect.
|
|
1642
1847
|
*
|
|
@@ -1645,31 +1850,32 @@ declare class ConnectionManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider>
|
|
|
1645
1850
|
* be messed up and cause race conditions that can drop WebSocket messages.
|
|
1646
1851
|
* So all async work in prepareConn.
|
|
1647
1852
|
*/
|
|
1648
|
-
connectConn(conn: Conn<S, CP, CS, V, I, DB>): void;
|
|
1853
|
+
connectConn(conn: Conn<S, CP, CS, V, I, DB, E, Q>): void;
|
|
1649
1854
|
/**
|
|
1650
1855
|
* Handle connection disconnection.
|
|
1651
1856
|
*
|
|
1652
1857
|
* This is called by `Conn.disconnect`. This should not call `Conn.disconnect.`
|
|
1653
1858
|
*/
|
|
1654
|
-
connDisconnected(conn: Conn<S, CP, CS, V, I, DB>): Promise<void>;
|
|
1859
|
+
connDisconnected(conn: Conn<S, CP, CS, V, I, DB, E, Q>): Promise<void>;
|
|
1860
|
+
cleanupPersistedHibernatableConnections(reason?: string): Promise<number>;
|
|
1655
1861
|
/**
|
|
1656
1862
|
* Utilify function for call sites that don't need a separate prepare and connect phase.
|
|
1657
1863
|
*/
|
|
1658
|
-
prepareAndConnectConn(driver: ConnDriver, params: CP, request: Request | undefined, requestPath: string | undefined, requestHeaders: Record<string, string> | undefined): Promise<Conn<S, CP, CS, V, I, DB>>;
|
|
1864
|
+
prepareAndConnectConn(driver: ConnDriver, params: CP, request: Request | undefined, requestPath: string | undefined, requestHeaders: Record<string, string> | undefined): Promise<Conn<S, CP, CS, V, I, DB, E, Q>>;
|
|
1659
1865
|
/**
|
|
1660
1866
|
* Restores connections from persisted data during actor initialization.
|
|
1661
1867
|
*/
|
|
1662
1868
|
restoreConnections(connections: PersistedConn<CP, CS>[]): void;
|
|
1663
|
-
findHibernatableConn(gatewayIdBuf: ArrayBuffer, requestIdBuf: ArrayBuffer): Conn<S, CP, CS, V, I, DB> | undefined;
|
|
1869
|
+
findHibernatableConn(gatewayIdBuf: ArrayBuffer, requestIdBuf: ArrayBuffer): Conn<S, CP, CS, V, I, DB, E, Q> | undefined;
|
|
1664
1870
|
}
|
|
1665
1871
|
|
|
1666
1872
|
/**
|
|
1667
1873
|
* Manages event subscriptions and broadcasting for actor instances.
|
|
1668
1874
|
* Handles subscription tracking and efficient message distribution to connected clients.
|
|
1669
1875
|
*/
|
|
1670
|
-
declare class EventManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider
|
|
1876
|
+
declare class EventManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
|
|
1671
1877
|
#private;
|
|
1672
|
-
constructor(actor: ActorInstance<S, CP, CS, V, I, DB>);
|
|
1878
|
+
constructor(actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>);
|
|
1673
1879
|
/**
|
|
1674
1880
|
* Adds a subscription for a connection to an event.
|
|
1675
1881
|
*
|
|
@@ -1677,7 +1883,7 @@ declare class EventManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
1677
1883
|
* @param connection - The connection subscribing to the event
|
|
1678
1884
|
* @param fromPersist - Whether this subscription is being restored from persistence
|
|
1679
1885
|
*/
|
|
1680
|
-
addSubscription(eventName: string, connection: Conn<S, CP, CS, V, I, DB>, fromPersist: boolean): void;
|
|
1886
|
+
addSubscription(eventName: string, connection: Conn<S, CP, CS, V, I, DB, E, Q>, fromPersist: boolean): void;
|
|
1681
1887
|
/**
|
|
1682
1888
|
* Removes a subscription for a connection from an event.
|
|
1683
1889
|
*
|
|
@@ -1685,7 +1891,7 @@ declare class EventManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
1685
1891
|
* @param connection - The connection unsubscribing from the event
|
|
1686
1892
|
* @param fromRemoveConn - Whether this is being called as part of connection removal
|
|
1687
1893
|
*/
|
|
1688
|
-
removeSubscription(eventName: string, connection: Conn<S, CP, CS, V, I, DB>, fromRemoveConn: boolean): void;
|
|
1894
|
+
removeSubscription(eventName: string, connection: Conn<S, CP, CS, V, I, DB, E, Q>, fromRemoveConn: boolean): void;
|
|
1689
1895
|
/**
|
|
1690
1896
|
* Broadcasts an event to all subscribed connections.
|
|
1691
1897
|
*
|
|
@@ -1699,7 +1905,7 @@ declare class EventManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
1699
1905
|
* @param eventName - The name of the event
|
|
1700
1906
|
* @returns Set of connections subscribed to the event, or undefined if no subscribers
|
|
1701
1907
|
*/
|
|
1702
|
-
getSubscribers(eventName: string): Set<Conn<S, CP, CS, V, I, DB>> | undefined;
|
|
1908
|
+
getSubscribers(eventName: string): Set<Conn<S, CP, CS, V, I, DB, E, Q>> | undefined;
|
|
1703
1909
|
/**
|
|
1704
1910
|
* Gets all events and their subscriber counts.
|
|
1705
1911
|
*
|
|
@@ -1712,7 +1918,7 @@ declare class EventManager<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
1712
1918
|
*
|
|
1713
1919
|
* @param connection - The connection to clear subscriptions for
|
|
1714
1920
|
*/
|
|
1715
|
-
clearConnectionSubscriptions(connection: Conn<S, CP, CS, V, I, DB>): void;
|
|
1921
|
+
clearConnectionSubscriptions(connection: Conn<S, CP, CS, V, I, DB, E, Q>): void;
|
|
1716
1922
|
/**
|
|
1717
1923
|
* Gets the total number of unique events being subscribed to.
|
|
1718
1924
|
*/
|
|
@@ -1771,9 +1977,9 @@ interface SaveStateOptions {
|
|
|
1771
1977
|
* Manages actor state persistence, proxying, and synchronization.
|
|
1772
1978
|
* Handles automatic state change detection and throttled persistence to KV storage.
|
|
1773
1979
|
*/
|
|
1774
|
-
declare class StateManager$1<S, CP, CS, I
|
|
1980
|
+
declare class StateManager$1<S, CP, CS, I, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
|
|
1775
1981
|
#private;
|
|
1776
|
-
constructor(actor: ActorInstance<S, CP, CS, any, I, any>, actorDriver: ActorDriver, config: any);
|
|
1982
|
+
constructor(actor: ActorInstance<S, CP, CS, any, I, any, E, Q>, actorDriver: ActorDriver, config: any);
|
|
1777
1983
|
get persist(): PersistedActor<S, I>;
|
|
1778
1984
|
get persistRaw(): PersistedActor<S, I>;
|
|
1779
1985
|
get persistChanged(): boolean;
|
|
@@ -1810,15 +2016,16 @@ declare class StateManager$1<S, CP, CS, I> {
|
|
|
1810
2016
|
}
|
|
1811
2017
|
|
|
1812
2018
|
/** Actor type alias with all `any` types. Used for `extends` in classes referencing this actor. */
|
|
1813
|
-
type AnyActorInstance = ActorInstance<any, any, any, any, any, any>;
|
|
1814
|
-
declare class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider
|
|
2019
|
+
type AnyActorInstance = ActorInstance<any, any, any, any, any, any, any, any>;
|
|
2020
|
+
declare class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
|
|
1815
2021
|
#private;
|
|
1816
|
-
actorContext: ActorContext<S, CP, CS, V, I, DB>;
|
|
2022
|
+
actorContext: ActorContext<S, CP, CS, V, I, DB, E, Q>;
|
|
1817
2023
|
driver: ActorDriver;
|
|
1818
|
-
connectionManager: ConnectionManager<S, CP, CS, V, I, DB>;
|
|
1819
|
-
stateManager: StateManager$1<S, CP, CS, I>;
|
|
1820
|
-
eventManager: EventManager<S, CP, CS, V, I, DB>;
|
|
1821
|
-
|
|
2024
|
+
connectionManager: ConnectionManager<S, CP, CS, V, I, DB, E, Q>;
|
|
2025
|
+
stateManager: StateManager$1<S, CP, CS, I, E, Q>;
|
|
2026
|
+
eventManager: EventManager<S, CP, CS, V, I, DB, E, Q>;
|
|
2027
|
+
queueManager: QueueManager<S, CP, CS, V, I, DB, E, Q>;
|
|
2028
|
+
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
|
|
1822
2029
|
get log(): Logger;
|
|
1823
2030
|
get rLog(): Logger;
|
|
1824
2031
|
get isStopping(): boolean;
|
|
@@ -1828,12 +2035,18 @@ declare class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
1828
2035
|
get region(): string;
|
|
1829
2036
|
get inlineClient(): Client<Registry<any>>;
|
|
1830
2037
|
get inspector(): ActorInspector;
|
|
2038
|
+
get traces(): Traces<OtlpExportTraceServiceRequestJson>;
|
|
1831
2039
|
get inspectorToken(): string | undefined;
|
|
1832
|
-
|
|
2040
|
+
getCurrentTraceSpan(): SpanHandle | null;
|
|
2041
|
+
startTraceSpan(name: string, attributes?: Record<string, unknown>): SpanHandle;
|
|
2042
|
+
endTraceSpan(handle: SpanHandle, status?: SpanStatusInput): void;
|
|
2043
|
+
runInTraceSpan<T>(name: string, attributes: Record<string, unknown> | undefined, fn: () => T | Promise<T>): Promise<T>;
|
|
2044
|
+
emitTraceEvent(name: string, attributes?: Record<string, unknown>, handle?: SpanHandle): void;
|
|
2045
|
+
get conns(): Map<ConnId, Conn<S, CP, CS, V, I, DB, E, Q>>;
|
|
1833
2046
|
get schedule(): Schedule;
|
|
1834
2047
|
get abortSignal(): AbortSignal;
|
|
1835
2048
|
get actions(): string[];
|
|
1836
|
-
get config(): ActorConfig<S, CP, CS, V, I, DB>;
|
|
2049
|
+
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
|
|
1837
2050
|
get persist(): PersistedActor<S, I>;
|
|
1838
2051
|
get state(): S;
|
|
1839
2052
|
set state(value: S);
|
|
@@ -1844,6 +2057,7 @@ declare class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
1844
2057
|
start(actorDriver: ActorDriver, inlineClient: Client<Registry<any>>, actorId: string, name: string, key: ActorKey, region: string): Promise<void>;
|
|
1845
2058
|
isReady(): boolean;
|
|
1846
2059
|
assertReady(allowStoppingState?: boolean): void;
|
|
2060
|
+
cleanupPersistedConnections(reason?: string): Promise<number>;
|
|
1847
2061
|
onStop(mode: "sleep" | "destroy"): Promise<void>;
|
|
1848
2062
|
startSleep(): void;
|
|
1849
2063
|
startDestroy(): void;
|
|
@@ -1864,13 +2078,27 @@ declare class ActorInstance<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
1864
2078
|
subscribe: boolean;
|
|
1865
2079
|
};
|
|
1866
2080
|
};
|
|
1867
|
-
}, conn: Conn<S, CP, CS, V, I, DB>): Promise<void>;
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
2081
|
+
}, conn: Conn<S, CP, CS, V, I, DB, E, Q>): Promise<void>;
|
|
2082
|
+
assertCanSubscribe(ctx: ActionContext<S, CP, CS, V, I, DB, E, Q>, eventName: string): Promise<void>;
|
|
2083
|
+
assertCanPublish(ctx: ActionContext<S, CP, CS, V, I, DB, E, Q>, queueName: string): Promise<void>;
|
|
2084
|
+
executeAction(ctx: ActionContext<S, CP, CS, V, I, DB, E, Q>, actionName: string, args: unknown[]): Promise<unknown>;
|
|
2085
|
+
handleRawRequest(conn: Conn<S, CP, CS, V, I, DB, E, Q>, request: Request): Promise<Response>;
|
|
2086
|
+
handleRawWebSocket(conn: Conn<S, CP, CS, V, I, DB, E, Q>, websocket: UniversalWebSocket, request?: Request): void;
|
|
1871
2087
|
scheduleEvent(timestamp: number, action: string, args: unknown[]): Promise<void>;
|
|
1872
2088
|
onAlarm(): Promise<void>;
|
|
1873
2089
|
waitUntil(promise: Promise<void>): void;
|
|
2090
|
+
/**
|
|
2091
|
+
* Prevents the actor from sleeping while the given promise is running.
|
|
2092
|
+
*
|
|
2093
|
+
* Use this when performing async operations in the `run` handler or other
|
|
2094
|
+
* background contexts where you need to ensure the actor stays awake.
|
|
2095
|
+
*
|
|
2096
|
+
* Returns the resolved value and resets the sleep timer on completion.
|
|
2097
|
+
* Errors are propagated to the caller.
|
|
2098
|
+
*/
|
|
2099
|
+
keepAwake<T>(promise: Promise<T>): Promise<T>;
|
|
2100
|
+
beginQueueWait(): void;
|
|
2101
|
+
endQueueWait(): void;
|
|
1874
2102
|
resetSleepTimer(): void;
|
|
1875
2103
|
}
|
|
1876
2104
|
|
|
@@ -1887,7 +2115,7 @@ type ConnDataInput<CP, CS> = {
|
|
|
1887
2115
|
*/
|
|
1888
2116
|
declare class StateManager<CP, CS> {
|
|
1889
2117
|
#private;
|
|
1890
|
-
constructor(conn: Conn<any, CP, CS, any, any, any>, data: ConnDataInput<CP, CS>);
|
|
2118
|
+
constructor(conn: Conn<any, CP, CS, any, any, any, any, any>, data: ConnDataInput<CP, CS>);
|
|
1891
2119
|
/**
|
|
1892
2120
|
* Returns the ephemeral or persisted data for this connectioned.
|
|
1893
2121
|
*
|
|
@@ -1910,7 +2138,7 @@ declare class StateManager<CP, CS> {
|
|
|
1910
2138
|
}
|
|
1911
2139
|
|
|
1912
2140
|
type ConnId = string;
|
|
1913
|
-
type AnyConn = Conn<any, any, any, any, any, any>;
|
|
2141
|
+
type AnyConn = Conn<any, any, any, any, any, any, any, any>;
|
|
1914
2142
|
declare const CONN_CONNECTED_SYMBOL: unique symbol;
|
|
1915
2143
|
declare const CONN_SPEAKS_RIVETKIT_SYMBOL: unique symbol;
|
|
1916
2144
|
declare const CONN_DRIVER_SYMBOL: unique symbol;
|
|
@@ -1924,9 +2152,9 @@ declare const CONN_SEND_MESSAGE_SYMBOL: unique symbol;
|
|
|
1924
2152
|
*
|
|
1925
2153
|
* @see {@link https://rivet.dev/docs/connections|Connection Documentation}
|
|
1926
2154
|
*/
|
|
1927
|
-
declare class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider
|
|
2155
|
+
declare class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>> {
|
|
1928
2156
|
#private;
|
|
1929
|
-
get [CONN_ACTOR_SYMBOL](): ActorInstance<S, CP, CS, V, I, DB>;
|
|
2157
|
+
get [CONN_ACTOR_SYMBOL](): ActorInstance<S, CP, CS, V, I, DB, E, Q>;
|
|
1930
2158
|
get [CONN_STATE_MANAGER_SYMBOL](): StateManager<CP, CS>;
|
|
1931
2159
|
/**
|
|
1932
2160
|
* Connections exist before being connected to an actor. If true, this
|
|
@@ -1973,7 +2201,7 @@ declare class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
1973
2201
|
*
|
|
1974
2202
|
* @protected
|
|
1975
2203
|
*/
|
|
1976
|
-
constructor(actor: ActorInstance<S, CP, CS, V, I, DB>, data: ConnDataInput<CP, CS>);
|
|
2204
|
+
constructor(actor: ActorInstance<S, CP, CS, V, I, DB, E, Q>, data: ConnDataInput<CP, CS>);
|
|
1977
2205
|
/**
|
|
1978
2206
|
* Sends a raw message to the underlying connection.
|
|
1979
2207
|
*/
|
|
@@ -1985,7 +2213,8 @@ declare class Conn<S, CP, CS, V, I, DB extends AnyDatabaseProvider> {
|
|
|
1985
2213
|
* @param args - The arguments for the event.
|
|
1986
2214
|
* @see {@link https://rivet.dev/docs/events|Events Documentation}
|
|
1987
2215
|
*/
|
|
1988
|
-
send(eventName:
|
|
2216
|
+
send<K extends keyof E & string>(eventName: K, ...args: InferEventArgs<InferSchemaMap<E>[K]>): void;
|
|
2217
|
+
send(eventName: keyof E extends never ? string : never, ...args: unknown[]): void;
|
|
1989
2218
|
/**
|
|
1990
2219
|
* Disconnects the client with an optional reason.
|
|
1991
2220
|
*
|
|
@@ -2002,56 +2231,108 @@ interface ActorTypes<TState, TConnParams, TConnState, TVars, TInput, TDatabase e
|
|
|
2002
2231
|
input?: TInput;
|
|
2003
2232
|
database?: TDatabase;
|
|
2004
2233
|
}
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2234
|
+
type InspectorUnsubscribe = () => void;
|
|
2235
|
+
interface WorkflowInspectorConfig<THistory = unknown> {
|
|
2236
|
+
getHistory: () => THistory | null;
|
|
2237
|
+
onHistoryUpdated?: (listener: (history: THistory) => void) => InspectorUnsubscribe;
|
|
2238
|
+
}
|
|
2239
|
+
interface RunInspectorConfig<THistory = unknown> {
|
|
2240
|
+
workflow?: WorkflowInspectorConfig<THistory>;
|
|
2241
|
+
}
|
|
2242
|
+
declare const RunConfigSchema: z$1.ZodObject<{
|
|
2243
|
+
name: z$1.ZodOptional<z$1.ZodString>;
|
|
2244
|
+
icon: z$1.ZodOptional<z$1.ZodString>;
|
|
2245
|
+
run: z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>;
|
|
2246
|
+
inspector: z$1.ZodOptional<z$1.ZodOptional<z$1.ZodObject<{
|
|
2247
|
+
workflow: z$1.ZodOptional<z$1.ZodObject<{
|
|
2248
|
+
getHistory: z$1.ZodCustom<() => unknown, () => unknown>;
|
|
2249
|
+
onHistoryUpdated: z$1.ZodOptional<z$1.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
|
|
2250
|
+
}, z$1.core.$strip>>;
|
|
2251
|
+
}, z$1.core.$strip>>>;
|
|
2252
|
+
}, z$1.core.$strip>;
|
|
2253
|
+
type RunConfigRuntime = z$1.infer<typeof RunConfigSchema>;
|
|
2254
|
+
type RunConfig<TState = unknown, TConnParams = unknown, TConnState = unknown, TVars = unknown, TInput = unknown, TDatabase extends AnyDatabaseProvider = AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = Omit<RunConfigRuntime, "run"> & {
|
|
2255
|
+
run: (c: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
2256
|
+
};
|
|
2257
|
+
type AnyRunConfig = RunConfig<any, any, any, any, any, AnyDatabaseProvider, any, any>;
|
|
2258
|
+
declare const RUN_FUNCTION_CONFIG_SYMBOL: unique symbol;
|
|
2259
|
+
/** Extract the run function from either a function or RunConfig object. */
|
|
2260
|
+
declare function getRunFunction(run: ((...args: any[]) => any) | AnyRunConfig | undefined): ((...args: any[]) => any) | undefined;
|
|
2261
|
+
/** Extract run metadata (name/icon) from RunConfig if provided. */
|
|
2262
|
+
declare function getRunMetadata(run: ((...args: any[]) => any) | AnyRunConfig | undefined): {
|
|
2263
|
+
name?: string;
|
|
2264
|
+
icon?: string;
|
|
2265
|
+
};
|
|
2266
|
+
/** Extract run inspector configuration if provided. */
|
|
2267
|
+
declare function getRunInspectorConfig(run: ((...args: any[]) => any) | AnyRunConfig | undefined): RunInspectorConfig | undefined;
|
|
2268
|
+
declare const ActorConfigSchema: z$1.ZodObject<{
|
|
2269
|
+
onCreate: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2270
|
+
onDestroy: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2271
|
+
onWake: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2272
|
+
onSleep: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2273
|
+
run: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>, z$1.ZodObject<{
|
|
2274
|
+
name: z$1.ZodOptional<z$1.ZodString>;
|
|
2275
|
+
icon: z$1.ZodOptional<z$1.ZodString>;
|
|
2276
|
+
run: z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>;
|
|
2277
|
+
inspector: z$1.ZodOptional<z$1.ZodOptional<z$1.ZodObject<{
|
|
2278
|
+
workflow: z$1.ZodOptional<z$1.ZodObject<{
|
|
2279
|
+
getHistory: z$1.ZodCustom<() => unknown, () => unknown>;
|
|
2280
|
+
onHistoryUpdated: z$1.ZodOptional<z$1.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
|
|
2281
|
+
}, z$1.core.$strip>>;
|
|
2282
|
+
}, z$1.core.$strip>>>;
|
|
2283
|
+
}, z$1.core.$strip>]>>;
|
|
2284
|
+
onStateChange: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2285
|
+
onBeforeConnect: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2286
|
+
onConnect: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2287
|
+
onDisconnect: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2288
|
+
onBeforeActionResponse: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2289
|
+
onRequest: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2290
|
+
onWebSocket: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2291
|
+
actions: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>>;
|
|
2292
|
+
events: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
2293
|
+
queues: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
2294
|
+
state: z$1.ZodOptional<z$1.ZodAny>;
|
|
2295
|
+
createState: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2296
|
+
connState: z$1.ZodOptional<z$1.ZodAny>;
|
|
2297
|
+
createConnState: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2298
|
+
vars: z$1.ZodOptional<z$1.ZodAny>;
|
|
2299
|
+
db: z$1.ZodOptional<z$1.ZodAny>;
|
|
2300
|
+
createVars: z$1.ZodOptional<z$1.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2301
|
+
options: z$1.ZodPrefault<z$1.ZodObject<{
|
|
2302
|
+
name: z$1.ZodOptional<z$1.ZodString>;
|
|
2303
|
+
icon: z$1.ZodOptional<z$1.ZodString>;
|
|
2304
|
+
createVarsTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2305
|
+
createConnStateTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2306
|
+
onConnectTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2307
|
+
onSleepTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2308
|
+
onDestroyTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2309
|
+
stateSaveInterval: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2310
|
+
actionTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2311
|
+
waitUntilTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2312
|
+
runStopTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2313
|
+
connectionLivenessTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2314
|
+
connectionLivenessInterval: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2315
|
+
noSleep: z$1.ZodDefault<z$1.ZodBoolean>;
|
|
2316
|
+
sleepTimeout: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2317
|
+
maxQueueSize: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2318
|
+
maxQueueMessageSize: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2319
|
+
canHibernateWebSocket: z$1.ZodDefault<z$1.ZodUnion<readonly [z$1.ZodBoolean, z$1.ZodCustom<(request: Request) => boolean, (request: Request) => boolean>]>>;
|
|
2320
|
+
}, z$1.core.$strict>>;
|
|
2321
|
+
}, z$1.core.$strict>;
|
|
2322
|
+
type CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
2042
2323
|
state: TState;
|
|
2043
2324
|
} | {
|
|
2044
|
-
createState: (c: CreateContext<TState, TInput, TDatabase>, input: TInput) => TState | Promise<TState>;
|
|
2325
|
+
createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
|
|
2045
2326
|
} | Record<never, never>;
|
|
2046
|
-
type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> = {
|
|
2327
|
+
type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
2047
2328
|
connState: TConnState;
|
|
2048
2329
|
} | {
|
|
2049
|
-
createConnState: (c: CreateConnStateContext<TState, TVars, TInput, TDatabase>, params: TConnParams) => TConnState | Promise<TConnState>;
|
|
2330
|
+
createConnState: (c: CreateConnStateContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => TConnState | Promise<TConnState>;
|
|
2050
2331
|
} | Record<never, never>;
|
|
2051
2332
|
/**
|
|
2052
2333
|
* @experimental
|
|
2053
2334
|
*/
|
|
2054
|
-
type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider> = {
|
|
2335
|
+
type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
2055
2336
|
/**
|
|
2056
2337
|
* @experimental
|
|
2057
2338
|
*/
|
|
@@ -2060,27 +2341,27 @@ type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extend
|
|
|
2060
2341
|
/**
|
|
2061
2342
|
* @experimental
|
|
2062
2343
|
*/
|
|
2063
|
-
createVars: (c: CreateVarsContext<TState, TInput, TDatabase>, driverCtx: any) => TVars | Promise<TVars>;
|
|
2344
|
+
createVars: (c: CreateVarsContext<TState, TInput, TDatabase, TEvents, TQueues>, driverCtx: any) => TVars | Promise<TVars>;
|
|
2064
2345
|
} | Record<never, never>;
|
|
2065
|
-
interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
2066
|
-
[Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, ...args: any[]) => any;
|
|
2346
|
+
interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
2347
|
+
[Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any;
|
|
2067
2348
|
}
|
|
2068
2349
|
/**
|
|
2069
2350
|
* @experimental
|
|
2070
2351
|
*/
|
|
2071
2352
|
type AuthIntent = "get" | "create" | "connect" | "action" | "message";
|
|
2072
|
-
interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase>> {
|
|
2353
|
+
interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> {
|
|
2073
2354
|
/**
|
|
2074
2355
|
* Called when the actor is first initialized.
|
|
2075
2356
|
*
|
|
2076
2357
|
* Use this hook to initialize your actor's state.
|
|
2077
2358
|
* This is called before any other lifecycle hooks.
|
|
2078
2359
|
*/
|
|
2079
|
-
onCreate?: (c: CreateContext<TState, TInput, TDatabase>, input: TInput) => void | Promise<void>;
|
|
2360
|
+
onCreate?: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => void | Promise<void>;
|
|
2080
2361
|
/**
|
|
2081
2362
|
* Called when the actor is destroyed.
|
|
2082
2363
|
*/
|
|
2083
|
-
onDestroy?: (c: DestroyContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
|
|
2364
|
+
onDestroy?: (c: DestroyContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
2084
2365
|
/**
|
|
2085
2366
|
* Called when the actor is started and ready to receive connections and action.
|
|
2086
2367
|
*
|
|
@@ -2089,7 +2370,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
2089
2370
|
*
|
|
2090
2371
|
* @returns Void or a Promise that resolves when startup is complete
|
|
2091
2372
|
*/
|
|
2092
|
-
onWake?: (c: WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
|
|
2373
|
+
onWake?: (c: WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
2093
2374
|
/**
|
|
2094
2375
|
* Called when the actor is stopping or sleeping.
|
|
2095
2376
|
*
|
|
@@ -2100,7 +2381,31 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
2100
2381
|
*
|
|
2101
2382
|
* @returns Void or a Promise that resolves when shutdown is complete
|
|
2102
2383
|
*/
|
|
2103
|
-
onSleep?: (c: SleepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
|
|
2384
|
+
onSleep?: (c: SleepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
2385
|
+
/**
|
|
2386
|
+
* Called after the actor starts up. Does not block actor startup.
|
|
2387
|
+
*
|
|
2388
|
+
* Use this for background tasks like:
|
|
2389
|
+
* - Reading from queues in a loop
|
|
2390
|
+
* - Tick loops for periodic work
|
|
2391
|
+
* - Custom workflow logic
|
|
2392
|
+
*
|
|
2393
|
+
* **Important:** The actor may go to sleep at any time during the `run`
|
|
2394
|
+
* handler. Use `c.keepAwake(promise)` to wrap async operations that should
|
|
2395
|
+
* not be interrupted by sleep.
|
|
2396
|
+
*
|
|
2397
|
+
* The handler receives an abort signal via `c.abortSignal` and a
|
|
2398
|
+
* `c.aborted` alias for loop checks. Use these to gracefully exit.
|
|
2399
|
+
*
|
|
2400
|
+
* If this handler exits or throws, the actor will crash and reschedule.
|
|
2401
|
+
* On shutdown, the actor waits for this handler to complete with a
|
|
2402
|
+
* configurable timeout (options.runStopTimeout, default 15s).
|
|
2403
|
+
*
|
|
2404
|
+
* Can be either a function or a RunConfig object with optional name/icon metadata.
|
|
2405
|
+
*
|
|
2406
|
+
* @returns Void or a Promise. If the promise exits, the actor crashes.
|
|
2407
|
+
*/
|
|
2408
|
+
run?: ((c: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>) | RunConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
2104
2409
|
/**
|
|
2105
2410
|
* Called when the actor's state changes.
|
|
2106
2411
|
*
|
|
@@ -2112,7 +2417,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
2112
2417
|
*
|
|
2113
2418
|
* @param newState The updated state
|
|
2114
2419
|
*/
|
|
2115
|
-
onStateChange?: (c: StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, newState: TState) => void;
|
|
2420
|
+
onStateChange?: (c: StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, newState: TState) => void;
|
|
2116
2421
|
/**
|
|
2117
2422
|
* Called before a client connects to the actor.
|
|
2118
2423
|
*
|
|
@@ -2123,7 +2428,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
2123
2428
|
* @returns The initial connection state or a Promise that resolves to it
|
|
2124
2429
|
* @throws Throw an error to reject the connection
|
|
2125
2430
|
*/
|
|
2126
|
-
onBeforeConnect?: (c: BeforeConnectContext<TState, TVars, TInput, TDatabase>, params: TConnParams) => void | Promise<void>;
|
|
2431
|
+
onBeforeConnect?: (c: BeforeConnectContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => void | Promise<void>;
|
|
2127
2432
|
/**
|
|
2128
2433
|
* Called when a client successfully connects to the actor.
|
|
2129
2434
|
*
|
|
@@ -2133,7 +2438,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
2133
2438
|
* @param conn The connection object
|
|
2134
2439
|
* @returns Void or a Promise that resolves when connection handling is complete
|
|
2135
2440
|
*/
|
|
2136
|
-
onConnect?: (c: ConnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
|
|
2441
|
+
onConnect?: (c: ConnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
2137
2442
|
/**
|
|
2138
2443
|
* Called when a client disconnects from the actor.
|
|
2139
2444
|
*
|
|
@@ -2143,7 +2448,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
2143
2448
|
* @param conn The connection that is being closed
|
|
2144
2449
|
* @returns Void or a Promise that resolves when disconnect handling is complete
|
|
2145
2450
|
*/
|
|
2146
|
-
onDisconnect?: (c: DisconnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase>) => void | Promise<void>;
|
|
2451
|
+
onDisconnect?: (c: DisconnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
2147
2452
|
/**
|
|
2148
2453
|
* Called before sending an action response to the client.
|
|
2149
2454
|
*
|
|
@@ -2156,7 +2461,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
2156
2461
|
* @param output The output that will be sent to the client
|
|
2157
2462
|
* @returns The modified output to send to the client
|
|
2158
2463
|
*/
|
|
2159
|
-
onBeforeActionResponse?: <Out>(c: BeforeActionResponseContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, name: string, args: unknown[], output: Out) => Out | Promise<Out>;
|
|
2464
|
+
onBeforeActionResponse?: <Out>(c: BeforeActionResponseContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, name: string, args: unknown[], output: Out) => Out | Promise<Out>;
|
|
2160
2465
|
/**
|
|
2161
2466
|
* Called when a raw HTTP request is made to the actor.
|
|
2162
2467
|
*
|
|
@@ -2168,7 +2473,7 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
2168
2473
|
* @param opts Additional options
|
|
2169
2474
|
* @returns A Response object to send back, or void to continue with default routing
|
|
2170
2475
|
*/
|
|
2171
|
-
onRequest?: (c: RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, request: Request) => Response | Promise<Response>;
|
|
2476
|
+
onRequest?: (c: RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, request: Request) => Response | Promise<Response>;
|
|
2172
2477
|
/**
|
|
2173
2478
|
* Called when a raw WebSocket connection is established to the actor.
|
|
2174
2479
|
*
|
|
@@ -2179,8 +2484,16 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
2179
2484
|
* @param websocket The raw WebSocket connection
|
|
2180
2485
|
* @param opts Additional options including the original HTTP upgrade request
|
|
2181
2486
|
*/
|
|
2182
|
-
onWebSocket?: (c: WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase>, websocket: UniversalWebSocket) => void | Promise<void>;
|
|
2487
|
+
onWebSocket?: (c: WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, websocket: UniversalWebSocket) => void | Promise<void>;
|
|
2183
2488
|
actions?: TActions;
|
|
2489
|
+
/**
|
|
2490
|
+
* Schema map for events broadcasted by this actor.
|
|
2491
|
+
*/
|
|
2492
|
+
events?: TEvents;
|
|
2493
|
+
/**
|
|
2494
|
+
* Schema map for queue payloads sent by this actor.
|
|
2495
|
+
*/
|
|
2496
|
+
queues?: TQueues;
|
|
2184
2497
|
}
|
|
2185
2498
|
type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
|
|
2186
2499
|
/**
|
|
@@ -2188,61 +2501,74 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
|
|
|
2188
2501
|
*/
|
|
2189
2502
|
db: TDatabase;
|
|
2190
2503
|
} | Record<never, never>;
|
|
2191
|
-
type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider
|
|
2192
|
-
type ActorConfigInput<TState = undefined, TConnParams = undefined, TConnState = undefined, TVars = undefined, TInput = undefined, TDatabase extends AnyDatabaseProvider = undefined, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase> = Record<never, never>> = {
|
|
2504
|
+
type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = Omit<z$1.infer<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onWake" | "onSleep" | "run" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & ActorDatabaseConfig<TDatabase>;
|
|
2505
|
+
type ActorConfigInput<TState = undefined, TConnParams = undefined, TConnState = undefined, TVars = undefined, TInput = undefined, TDatabase extends AnyDatabaseProvider = undefined, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> = Record<never, never>> = {
|
|
2193
2506
|
types?: ActorTypes<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
|
|
2194
|
-
} & Omit<z.input<typeof ActorConfigSchema>, "actions" | "onCreate" | "onDestroy" | "onWake" | "onSleep" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TActions> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase> & ActorDatabaseConfig<TDatabase>;
|
|
2195
|
-
declare function test<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase>>(input: ActorConfigInput<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TActions>): ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase>;
|
|
2196
|
-
declare const DocActorOptionsSchema: z.ZodObject<{
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2507
|
+
} & Omit<z$1.input<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onWake" | "onSleep" | "run" | "onStateChange" | "onBeforeConnect" | "onConnect" | "onDisconnect" | "onBeforeActionResponse" | "onRequest" | "onWebSocket" | "state" | "createState" | "connState" | "createConnState" | "vars" | "createVars" | "db"> & BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, TActions> & CreateState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & ActorDatabaseConfig<TDatabase>;
|
|
2508
|
+
declare function test<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>(input: ActorConfigInput<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues, TActions>): ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
2509
|
+
declare const DocActorOptionsSchema: z$1.ZodObject<{
|
|
2510
|
+
name: z$1.ZodOptional<z$1.ZodString>;
|
|
2511
|
+
icon: z$1.ZodOptional<z$1.ZodString>;
|
|
2512
|
+
createVarsTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2513
|
+
createConnStateTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2514
|
+
onConnectTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2515
|
+
onSleepTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2516
|
+
onDestroyTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2517
|
+
stateSaveInterval: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2518
|
+
actionTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2519
|
+
waitUntilTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2520
|
+
runStopTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2521
|
+
connectionLivenessTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2522
|
+
connectionLivenessInterval: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2523
|
+
noSleep: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
2524
|
+
sleepTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2525
|
+
maxQueueSize: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2526
|
+
maxQueueMessageSize: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2527
|
+
canHibernateWebSocket: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
2528
|
+
}, z$1.core.$strip>;
|
|
2529
|
+
declare const DocActorConfigSchema: z$1.ZodObject<{
|
|
2530
|
+
state: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2531
|
+
createState: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2532
|
+
connState: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2533
|
+
createConnState: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2534
|
+
vars: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2535
|
+
createVars: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2536
|
+
db: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2537
|
+
onCreate: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2538
|
+
onDestroy: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2539
|
+
onWake: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2540
|
+
onSleep: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2541
|
+
run: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2542
|
+
onStateChange: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2543
|
+
onBeforeConnect: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2544
|
+
onConnect: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2545
|
+
onDisconnect: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2546
|
+
onBeforeActionResponse: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2547
|
+
onRequest: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2548
|
+
onWebSocket: z$1.ZodOptional<z$1.ZodUnknown>;
|
|
2549
|
+
actions: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
2550
|
+
events: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
2551
|
+
queues: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
2552
|
+
options: z$1.ZodOptional<z$1.ZodObject<{
|
|
2553
|
+
name: z$1.ZodOptional<z$1.ZodString>;
|
|
2554
|
+
icon: z$1.ZodOptional<z$1.ZodString>;
|
|
2555
|
+
createVarsTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2556
|
+
createConnStateTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2557
|
+
onConnectTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2558
|
+
onSleepTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2559
|
+
onDestroyTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2560
|
+
stateSaveInterval: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2561
|
+
actionTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2562
|
+
waitUntilTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2563
|
+
runStopTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2564
|
+
connectionLivenessTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2565
|
+
connectionLivenessInterval: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2566
|
+
noSleep: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
2567
|
+
sleepTimeout: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2568
|
+
maxQueueSize: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2569
|
+
maxQueueMessageSize: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2570
|
+
canHibernateWebSocket: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
2571
|
+
}, z$1.core.$strip>>;
|
|
2572
|
+
}, z$1.core.$strip>;
|
|
2247
2573
|
|
|
2248
|
-
export {
|
|
2574
|
+
export { DocRunnerConfigSchema as $, type ActorDriver as A, BeforeActionResponseContext as B, type Client as C, ConnContext as D, type Encoding as E, type ConnContextOf as F, ConnInitContext as G, type ConnInitContextOf as H, ConnectContext as I, type ConnectContextOf as J, CreateConnStateContext as K, type CreateConnStateContextOf as L, CreateContext as M, type CreateContextOf as N, CreateVarsContext as O, type CreateVarsContextOf as P, type QueueSchemaConfig as Q, type RegistryConfig as R, DestroyContext as S, type DestroyContextOf as T, DisconnectContext as U, type DisconnectContextOf as V, DocActorConfigSchema as W, DocActorOptionsSchema as X, DocConfigureRunnerPoolSchema as Y, DocInspectorConfigSchema as Z, DocRegistryConfigSchema as _, type AnyConn as a, ActorInstance as a$, DocServerlessConfigSchema as a0, type FetchHandler as a1, type InspectorUnsubscribe as a2, type LegacyStartServerOutput as a3, RUN_FUNCTION_CONFIG_SYMBOL as a4, Registry as a5, type RegistryActors as a6, type RegistryConfigInput as a7, RegistryConfigSchema as a8, RequestContext as a9, test as aA, type ActorAccessor as aB, type ActorActionFunction as aC, ActorClientError as aD, type ActorConn as aE, ActorConnDisposed as aF, ActorConnRaw as aG, type ActorConnStatus as aH, ActorError as aI, type ActorHandle as aJ, ActorHandleRaw as aK, ClientRaw as aL, type ConnectionStateCallback as aM, type CreateOptions as aN, type CreateRequest as aO, type EventUnsubscribe as aP, type ExtractActorsFromRegistry as aQ, type ExtractRegistryFromClient as aR, type GetOptions as aS, type GetWithIdOptions as aT, InternalError as aU, MalformedResponseMessage as aV, ManagerError as aW, type QueryOptions as aX, type Region as aY, type StatusChangeCallback as aZ, type ManagerDriver as a_, type RequestContextOf as aa, type RunConfig as ab, RunConfigSchema as ac, RunContext as ad, type RunContextOf as ae, type RunInspectorConfig as af, type ServerlessHandler as ag, SleepContext as ah, type SleepContextOf as ai, StateChangeContext as aj, type StateChangeContextOf as ak, type TestConfig as al, TestConfigSchema as am, type Type as an, WakeContext as ao, type WakeContextOf as ap, WebSocketContext as aq, type WebSocketContextOf as ar, type WorkflowInspectorConfig as as, buildActorNames as at, createClientWithDriver as au, getRunFunction as av, getRunInspectorConfig as aw, getRunMetadata as ax, lookupInRegistry as ay, setup as az, type AnyActorInstance as b, type ActorOutput as b0, type CreateInput as b1, type GetForIdInput as b2, type GetOrCreateWithKeyInput as b3, type GetWithKeyInput as b4, type ListActorsInput as b5, type ManagerDisplayInformation as b6, type ManagerDriverBuilder as b7, type ActorDriverBuilder as b8, type QueueFilterName as b9, type QueueNextOptions as ba, type QueueResultMessageForName as bb, type InferSchemaMap as bc, type InferDatabaseClient as bd, type InferEventArgs as be, type EventSchemaConfig as c, type Actions as d, type ActorConfigInput as e, ActorDefinition as f, event as g, ActionContext as h, type ActionContextOf as i, type ActorConfig as j, ActorConfigSchema as k, ActorContext as l, type ActorContextOf as m, type ActorKey as n, ActorKv as o, type ActorQuery as p, queue as q, type ActorTypes as r, ActorsSchema as s, type AnyActorDefinition as t, type AnyClient as u, type AuthIntent as v, type BeforeActionResponseContextOf as w, BeforeConnectContext as x, type BeforeConnectContextOf as y, Conn as z };
|