rivetkit 0.0.0-main.72cbc7c → 0.0.0-main.78336a1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/client.d.ts +821 -80
- package/dist/browser/client.js +852 -670
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +252 -129
- package/dist/browser/inspector/client.js +2079 -234
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +4 -2
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +3 -1
- package/dist/tsup/agent-os/index.cjs +2420 -2093
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +821 -90
- package/dist/tsup/agent-os/index.d.ts +821 -90
- package/dist/tsup/agent-os/index.js +2405 -2078
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-2JSYYH6P.cjs} +22 -7
- package/dist/tsup/chunk-2JSYYH6P.cjs.map +1 -0
- package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-4KGXFC6M.cjs} +232 -18
- package/dist/tsup/chunk-4KGXFC6M.cjs.map +1 -0
- package/dist/tsup/{chunk-GDKM56PU.js → chunk-5NBLGMI2.js} +488 -16
- package/dist/tsup/chunk-5NBLGMI2.js.map +1 -0
- package/dist/tsup/{chunk-WDO5Y6PO.cjs → chunk-635UPRVQ.cjs} +18 -11
- package/dist/tsup/chunk-635UPRVQ.cjs.map +1 -0
- package/dist/tsup/{chunk-T6YVRM4K.js → chunk-6W5VGLFT.js} +231 -17
- package/dist/tsup/chunk-6W5VGLFT.js.map +1 -0
- package/dist/tsup/{chunk-YQQ2ZDKT.cjs → chunk-AIL267JK.cjs} +525 -451
- package/dist/tsup/chunk-AIL267JK.cjs.map +1 -0
- package/dist/tsup/chunk-BHXSPZ5M.cjs +243 -0
- package/dist/tsup/chunk-BHXSPZ5M.cjs.map +1 -0
- package/dist/tsup/{chunk-O25KOT5C.cjs → chunk-EHZH3KUW.cjs} +497 -25
- package/dist/tsup/chunk-EHZH3KUW.cjs.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-JI6GZ2C2.js} +3 -12
- package/dist/tsup/chunk-JI6GZ2C2.js.map +1 -0
- package/dist/tsup/chunk-JRHFO6UE.js +14 -0
- package/dist/tsup/chunk-JRHFO6UE.js.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JTHHCZCZ.js} +24 -1
- package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-KVFIONKQ.cjs} +25 -2
- package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
- package/dist/tsup/{chunk-PJSE5ZGN.js → chunk-MIM5VMS6.js} +6 -6
- package/dist/tsup/chunk-MIM5VMS6.js.map +1 -0
- package/dist/tsup/chunk-MLT7XFEF.js +243 -0
- package/dist/tsup/chunk-MLT7XFEF.js.map +1 -0
- package/dist/tsup/{chunk-OFP533QU.cjs → chunk-MPEC2UFV.cjs} +3 -3
- package/dist/tsup/chunk-MPEC2UFV.cjs.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-MYWZCDML.cjs} +3 -12
- package/dist/tsup/chunk-MYWZCDML.cjs.map +1 -0
- package/dist/tsup/{chunk-KIWH5H3K.js → chunk-OUQUIBVW.js} +21 -6
- package/dist/tsup/chunk-OUQUIBVW.js.map +1 -0
- package/dist/tsup/{chunk-HSTK7OBI.js → chunk-PUMX2WHE.js} +16 -9
- package/dist/tsup/chunk-PUMX2WHE.js.map +1 -0
- package/dist/tsup/{chunk-5DGOZZKE.cjs → chunk-Q6BQS3UL.cjs} +72 -10
- package/dist/tsup/chunk-Q6BQS3UL.cjs.map +1 -0
- package/dist/tsup/{chunk-OQSBGFIB.cjs → chunk-QAWP2MIM.cjs} +10 -10
- package/dist/tsup/chunk-QAWP2MIM.cjs.map +1 -0
- package/dist/tsup/{chunk-EI55QOUB.js → chunk-QU5UOJLK.js} +390 -316
- package/dist/tsup/chunk-QU5UOJLK.js.map +1 -0
- package/dist/tsup/chunk-TX5AVHTL.cjs +14 -0
- package/dist/tsup/chunk-TX5AVHTL.cjs.map +1 -0
- package/dist/tsup/{chunk-DFHHCPH7.js → chunk-XCSZTG4H.js} +70 -8
- package/dist/tsup/chunk-XCSZTG4H.js.map +1 -0
- package/dist/tsup/{chunk-4KSYSQHX.js → chunk-XKVQ3AMZ.js} +2 -2
- package/dist/tsup/client/mod.cjs +8 -9
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +8 -6
- package/dist/tsup/client/mod.d.ts +8 -6
- package/dist/tsup/client/mod.js +7 -8
- package/dist/tsup/common/log.cjs +5 -3
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.d.cts +5 -1
- package/dist/tsup/common/log.d.ts +5 -1
- package/dist/tsup/common/log.js +6 -4
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.cjs.map +1 -1
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-voObiSep.d.cts → config-Ug5M2MOr.d.ts} +869 -59
- package/dist/tsup/{config-CxjGYf4K.d.ts → config-ey2I2zz5.d.cts} +59 -4
- package/dist/tsup/{config-CxjGYf4K.d.cts → config-ey2I2zz5.d.ts} +59 -4
- package/dist/tsup/{config-CRwCN3Ok.d.ts → config-gvHwMas-.d.cts} +869 -59
- package/dist/tsup/context-BSCBvbfM.d.cts +129 -0
- package/dist/tsup/context-DererUCI.d.ts +129 -0
- package/dist/tsup/db/drizzle.cjs +127 -67
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +8 -4
- package/dist/tsup/db/drizzle.d.ts +8 -4
- package/dist/tsup/db/drizzle.js +127 -67
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +6 -124
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.d.cts +12 -4
- package/dist/tsup/db/mod.d.ts +12 -4
- package/dist/tsup/db/mod.js +5 -123
- package/dist/tsup/db/mod.js.map +1 -1
- package/dist/tsup/dynamic/mod.cjs +24 -0
- package/dist/tsup/dynamic/mod.cjs.map +1 -0
- package/dist/tsup/dynamic/mod.d.cts +38 -0
- package/dist/tsup/dynamic/mod.d.ts +38 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +47 -12
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +26 -136
- package/dist/tsup/inspector/mod.d.ts +26 -136
- package/dist/tsup/inspector/mod.js +46 -11
- package/dist/tsup/inspector/mod.js.map +1 -1
- package/dist/tsup/inspector/workflow.cjs +21 -0
- package/dist/tsup/inspector/workflow.cjs.map +1 -0
- package/dist/tsup/inspector/workflow.d.cts +144 -0
- package/dist/tsup/inspector/workflow.d.ts +144 -0
- package/dist/tsup/inspector/workflow.js +21 -0
- package/dist/tsup/inspector/workflow.js.map +1 -0
- package/dist/tsup/inspector-tab/mod.cjs +162 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +241 -0
- package/dist/tsup/inspector-tab/mod.d.ts +241 -0
- package/dist/tsup/inspector-tab/mod.js +162 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +2754 -607
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +8 -7
- package/dist/tsup/mod.d.ts +8 -7
- package/dist/tsup/mod.js +2688 -541
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +26 -21
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +6 -5
- package/dist/tsup/test/mod.d.ts +6 -5
- package/dist/tsup/test/mod.js +25 -20
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/unstable/migrations.cjs +101 -0
- package/dist/tsup/unstable/migrations.cjs.map +1 -0
- package/dist/tsup/unstable/migrations.d.cts +29 -0
- package/dist/tsup/unstable/migrations.d.ts +29 -0
- package/dist/tsup/unstable/migrations.js +101 -0
- package/dist/tsup/unstable/migrations.js.map +1 -0
- package/dist/tsup/utils-Bbz-3411.d.cts +162 -0
- package/dist/tsup/utils-BqdWVlzm.d.ts +162 -0
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-vvJQyygr.d.cts} +7 -1
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-vvJQyygr.d.ts} +7 -1
- package/dist/tsup/utils.cjs +7 -3
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +4 -147
- package/dist/tsup/utils.d.ts +4 -147
- package/dist/tsup/utils.js +6 -2
- package/dist/tsup/workflow/mod.cjs +539 -424
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +10 -9
- package/dist/tsup/workflow/mod.d.ts +10 -9
- package/dist/tsup/workflow/mod.js +521 -406
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +63 -16
- package/src/actor/actions.ts +119 -0
- package/src/actor/config.test.ts +78 -0
- package/src/actor/config.ts +505 -88
- package/src/actor/contexts/index.ts +7 -2
- package/src/actor/definition.ts +38 -26
- package/src/actor/errors.ts +50 -5
- package/src/actor/keys.ts +1 -1
- package/src/actor/mod.ts +32 -21
- package/src/actor/schema.ts +2 -2
- package/src/agent-os/actor/index.ts +39 -19
- package/src/agent-os/actor/preview.ts +1 -2
- package/src/agent-os/actor/session.ts +2 -2
- package/src/agent-os/config.ts +1 -1
- package/src/agent-os/fs/database-vfs.ts +1 -1
- package/src/agent-os/index.ts +16 -15
- package/src/client/actor-common.ts +80 -54
- package/src/client/actor-conn.ts +17 -41
- package/src/client/actor-handle.ts +140 -72
- package/src/client/actor-query.ts +13 -6
- package/src/client/client.ts +41 -11
- package/src/client/errors.ts +3 -2
- package/src/client/lifecycle-errors.ts +2 -4
- package/src/client/query.ts +3 -1
- package/src/client/queue.ts +8 -3
- package/src/client/raw-utils.ts +36 -13
- package/src/client/resolve-gateway-target.ts +3 -1
- package/src/client/utils.ts +4 -7
- package/src/common/actor-router-consts.ts +2 -0
- package/src/common/actor-websocket.ts +3 -1
- package/src/common/bare/actor-persist/v1.ts +205 -163
- package/src/common/bare/actor-persist/v2.ts +265 -213
- package/src/common/bare/actor-persist/v3.ts +176 -172
- package/src/common/bare/actor-persist/v4.ts +254 -253
- package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +848 -0
- package/src/common/bare/generated/inspector/v5.ts +1016 -0
- package/src/common/bare/generated/inspector/v6.ts +1367 -0
- package/src/common/bare/transport/v1.ts +694 -542
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +74 -9
- package/src/common/database/mod.test.ts +285 -58
- package/src/common/database/mod.ts +259 -77
- package/src/common/database/native-database.test.ts +9 -0
- package/src/common/database/native-database.ts +192 -2
- package/src/common/database/shared.ts +25 -0
- package/src/common/encoding.ts +278 -34
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/fetch-like.ts +49 -0
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/inspector-transport.ts +12 -2
- package/src/common/log.ts +15 -8
- package/src/common/router.ts +13 -17
- package/src/common/utils.ts +7 -150
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/drizzle.test.ts +164 -0
- package/src/db/drizzle.ts +182 -80
- package/src/db/mod.ts +4 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +64 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-client/actor-http-client.ts +8 -24
- package/src/engine-client/actor-websocket-client.ts +6 -5
- package/src/engine-client/api-endpoints.ts +51 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +5 -16
- package/src/engine-client/mod.ts +66 -64
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +127 -15
- package/src/inspector/mod.ts +2 -4
- package/src/inspector/workflow.ts +61 -0
- package/src/inspector-tab/mod.ts +301 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.test.ts +25 -0
- package/src/registry/config/index.ts +68 -56
- package/src/registry/index.ts +588 -91
- package/src/registry/napi-runtime.ts +427 -23
- package/src/registry/native-http.ts +225 -0
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +1435 -459
- package/src/registry/process-metrics.ts +250 -0
- package/src/registry/run-handler-coordinator.test.ts +252 -0
- package/src/registry/run-handler-coordinator.ts +219 -0
- package/src/registry/runtime.test.ts +74 -0
- package/src/registry/runtime.ts +297 -9
- package/src/registry/wasm-runtime.ts +398 -22
- package/src/registry/write-through-proxy.ts +141 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +2 -17
- package/src/test/ready.ts +22 -0
- package/src/unstable/migrations.test.ts +170 -0
- package/src/unstable/migrations.ts +141 -0
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +41 -0
- package/src/utils/node.ts +44 -28
- package/src/utils/router.ts +1 -1
- package/src/utils.ts +4 -2
- package/src/workflow/context.ts +683 -242
- package/src/workflow/driver.test.ts +62 -0
- package/src/workflow/driver.ts +259 -119
- package/src/workflow/inspector.ts +24 -24
- package/src/workflow/mod.ts +76 -84
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-5DGOZZKE.cjs.map +0 -1
- package/dist/tsup/chunk-DFHHCPH7.js.map +0 -1
- package/dist/tsup/chunk-EI55QOUB.js.map +0 -1
- package/dist/tsup/chunk-GDKM56PU.js.map +0 -1
- package/dist/tsup/chunk-HSTK7OBI.js.map +0 -1
- package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
- package/dist/tsup/chunk-LD5YASJU.cjs.map +0 -1
- package/dist/tsup/chunk-LI5MR5BD.js +0 -268
- package/dist/tsup/chunk-LI5MR5BD.js.map +0 -1
- package/dist/tsup/chunk-NDY6IZJ3.cjs +0 -268
- package/dist/tsup/chunk-NDY6IZJ3.cjs.map +0 -1
- package/dist/tsup/chunk-O25KOT5C.cjs.map +0 -1
- package/dist/tsup/chunk-OFP533QU.cjs.map +0 -1
- package/dist/tsup/chunk-OQSBGFIB.cjs.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-PJSE5ZGN.js.map +0 -1
- package/dist/tsup/chunk-QAZLM4WT.cjs.map +0 -1
- package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
- package/dist/tsup/chunk-WDO5Y6PO.cjs.map +0 -1
- package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
- package/dist/tsup/chunk-YQQ2ZDKT.cjs.map +0 -1
- package/dist/tsup/context-BPFYVZ5g.d.ts +0 -92
- package/dist/tsup/context-D0YF1MQq.d.cts +0 -92
- package/src/actor/driver.ts +0 -141
- package/src/actor/instance/mod.ts +0 -2492
- package/src/drivers/engine/actor-driver.ts +0 -2460
- package/src/utils/serve.ts +0 -217
- /package/dist/tsup/{chunk-4KSYSQHX.js.map → chunk-XKVQ3AMZ.js.map} +0 -0
package/dist/browser/client.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _rivetkit_rivetkit_wasm from '@rivetkit/rivetkit-wasm';
|
|
2
2
|
import { z as z$2 } from 'zod';
|
|
3
3
|
import z$1, { z } from 'zod/v4';
|
|
4
|
-
import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
5
4
|
import { Context, Handler, Hono } from 'hono';
|
|
5
|
+
import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
6
6
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
7
7
|
import { ContentfulStatusCode } from 'hono/utils/http-status';
|
|
8
8
|
import { Logger } from 'pino';
|
|
@@ -13,7 +13,7 @@ interface ActorMetricsLike {
|
|
|
13
13
|
totalKvWrites: number;
|
|
14
14
|
trackSql(query: string, durationMs: number): void;
|
|
15
15
|
}
|
|
16
|
-
type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> :
|
|
16
|
+
type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : RawAccess;
|
|
17
17
|
type SqliteBindings = unknown[] | Record<string, unknown>;
|
|
18
18
|
interface SqliteQueryResult {
|
|
19
19
|
columns: string[];
|
|
@@ -23,6 +23,45 @@ interface SqliteExecuteResult extends SqliteQueryResult {
|
|
|
23
23
|
changes: number;
|
|
24
24
|
lastInsertRowId?: number | null;
|
|
25
25
|
}
|
|
26
|
+
interface SqliteBatchStatement {
|
|
27
|
+
sql: string;
|
|
28
|
+
params?: SqliteBindings;
|
|
29
|
+
}
|
|
30
|
+
interface SqliteTransactionOptions {
|
|
31
|
+
/** Static operation name used to aggregate transaction performance. */
|
|
32
|
+
name?: string;
|
|
33
|
+
/** Deadlock-safety timeout in milliseconds. */
|
|
34
|
+
timeout?: number;
|
|
35
|
+
/** @experimental */
|
|
36
|
+
experimental?: {
|
|
37
|
+
/**
|
|
38
|
+
* Atomically includes actor and hibernatable connection state.
|
|
39
|
+
* Only single-statement `execute` calls are supported in the transaction.
|
|
40
|
+
* Concurrent actions that try to mutate state while the transaction is
|
|
41
|
+
* active fail with `actor.state_transaction_conflict`.
|
|
42
|
+
*/
|
|
43
|
+
includeState?: boolean;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* SQLite profiling configuration.
|
|
48
|
+
*
|
|
49
|
+
* @experimental This entire configuration surface is experimental and subject
|
|
50
|
+
* to change without notice.
|
|
51
|
+
*/
|
|
52
|
+
interface SqliteProfilingOptions {
|
|
53
|
+
enabled?: boolean;
|
|
54
|
+
maxTrackedStatementFingerprints?: number;
|
|
55
|
+
maxTrackedTransactionFingerprints?: number;
|
|
56
|
+
maxPrometheusSeries?: number;
|
|
57
|
+
maxStatementsPerTransactionTrace?: number;
|
|
58
|
+
maxGetPagesRequestsPerTrace?: number;
|
|
59
|
+
maxTransactionNameBytes?: number;
|
|
60
|
+
slowOperationThresholdMs?: number;
|
|
61
|
+
baselineSampleRate?: number;
|
|
62
|
+
maxDiagnosticEventsPerMinute?: number;
|
|
63
|
+
diagnosticEventQueueCapacity?: number;
|
|
64
|
+
}
|
|
26
65
|
interface SqliteNativeMetrics {
|
|
27
66
|
requestBuildNs: number;
|
|
28
67
|
serializeNs: number;
|
|
@@ -39,11 +78,19 @@ interface SqliteNativeMetrics {
|
|
|
39
78
|
interface SqliteDatabase {
|
|
40
79
|
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
41
80
|
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
81
|
+
executeBatch(statements: SqliteBatchStatement[]): Promise<SqliteExecuteResult[]>;
|
|
82
|
+
beginTransaction(timeoutMs?: number, name?: string): Promise<SqliteTransactionDatabase>;
|
|
42
83
|
run(sql: string, params?: SqliteBindings): Promise<void>;
|
|
43
84
|
query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
|
|
44
85
|
nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
|
|
45
86
|
close(): Promise<void>;
|
|
46
87
|
}
|
|
88
|
+
interface SqliteTransactionDatabase {
|
|
89
|
+
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
90
|
+
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
91
|
+
commit(): Promise<void>;
|
|
92
|
+
rollback(): Promise<void>;
|
|
93
|
+
}
|
|
47
94
|
/**
|
|
48
95
|
* Provider for opening native databases from the active runtime.
|
|
49
96
|
*/
|
|
@@ -87,6 +134,13 @@ interface DatabaseProviderContext {
|
|
|
87
134
|
nativeDatabaseProvider?: NativeDatabaseProvider;
|
|
88
135
|
}
|
|
89
136
|
type DatabaseProvider<DB extends RawAccess> = {
|
|
137
|
+
/**
|
|
138
|
+
* Local SQLite profiling controls consumed by the actor runtime.
|
|
139
|
+
*
|
|
140
|
+
* @experimental This entire configuration surface is experimental and
|
|
141
|
+
* subject to change without notice.
|
|
142
|
+
*/
|
|
143
|
+
sqliteProfiling?: SqliteProfilingOptions;
|
|
90
144
|
/**
|
|
91
145
|
* Creates a new database client for the actor.
|
|
92
146
|
* The result is passed to the actor context as `c.db`.
|
|
@@ -103,14 +157,15 @@ type DatabaseProvider<DB extends RawAccess> = {
|
|
|
103
157
|
/**
|
|
104
158
|
* Drizzle database client interface (will be extended by drizzle-orm types)
|
|
105
159
|
*/
|
|
106
|
-
|
|
107
|
-
}
|
|
160
|
+
type DrizzleDatabaseClient = {};
|
|
108
161
|
type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
|
|
109
162
|
type RawAccess = {
|
|
110
163
|
/**
|
|
111
164
|
* Executes a raw SQL query.
|
|
112
165
|
*/
|
|
113
166
|
execute: ExecuteFunction;
|
|
167
|
+
/** Runs a callback in an isolated SQLite transaction. */
|
|
168
|
+
transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T, options?: SqliteTransactionOptions) => Promise<T>;
|
|
114
169
|
/**
|
|
115
170
|
* Returns native SQLite metrics when the active runtime supports them.
|
|
116
171
|
*/
|
|
@@ -150,6 +205,7 @@ declare const CreateRequestSchema: z.ZodObject<{
|
|
|
150
205
|
key: z.ZodArray<z.ZodString>;
|
|
151
206
|
input: z.ZodOptional<z.ZodUnknown>;
|
|
152
207
|
region: z.ZodOptional<z.ZodString>;
|
|
208
|
+
poolName: z.ZodOptional<z.ZodString>;
|
|
153
209
|
}, z.core.$strip>;
|
|
154
210
|
declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
155
211
|
getForId: z.ZodObject<{
|
|
@@ -167,6 +223,7 @@ declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
167
223
|
key: z.ZodArray<z.ZodString>;
|
|
168
224
|
input: z.ZodOptional<z.ZodUnknown>;
|
|
169
225
|
region: z.ZodOptional<z.ZodString>;
|
|
226
|
+
poolName: z.ZodOptional<z.ZodString>;
|
|
170
227
|
}, z.core.$strip>;
|
|
171
228
|
}, z.core.$strip>, z.ZodObject<{
|
|
172
229
|
create: z.ZodObject<{
|
|
@@ -174,6 +231,7 @@ declare const ActorQuerySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
174
231
|
key: z.ZodArray<z.ZodString>;
|
|
175
232
|
input: z.ZodOptional<z.ZodUnknown>;
|
|
176
233
|
region: z.ZodOptional<z.ZodString>;
|
|
234
|
+
poolName: z.ZodOptional<z.ZodString>;
|
|
177
235
|
}, z.core.$strip>;
|
|
178
236
|
}, z.core.$strip>]>;
|
|
179
237
|
type ActorQuery = z.infer<typeof ActorQuerySchema>;
|
|
@@ -182,6 +240,44 @@ type ActorQuery = z.infer<typeof ActorQuerySchema>;
|
|
|
182
240
|
*/
|
|
183
241
|
type CreateRequest = z.infer<typeof CreateRequestSchema>;
|
|
184
242
|
|
|
243
|
+
type SchemaHookResult = boolean | Promise<boolean>;
|
|
244
|
+
type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
|
|
245
|
+
interface EventTypeToken<T, TContext = any> {
|
|
246
|
+
readonly _eventType?: T;
|
|
247
|
+
readonly canSubscribe?: SchemaHook<TContext>;
|
|
248
|
+
readonly schema?: PrimitiveSchema;
|
|
249
|
+
}
|
|
250
|
+
interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
|
|
251
|
+
readonly _queueMessage?: TMessage;
|
|
252
|
+
readonly _queueComplete?: TComplete;
|
|
253
|
+
readonly canPublish?: SchemaHook<TContext>;
|
|
254
|
+
readonly message?: PrimitiveSchema;
|
|
255
|
+
readonly complete?: PrimitiveSchema;
|
|
256
|
+
}
|
|
257
|
+
type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
|
|
258
|
+
interface EventSchemaDefinition<TContext = any> {
|
|
259
|
+
schema: PrimitiveSchema;
|
|
260
|
+
canSubscribe?: SchemaHook<TContext>;
|
|
261
|
+
}
|
|
262
|
+
interface QueueSchemaDefinition<TContext = any> {
|
|
263
|
+
message: PrimitiveSchema;
|
|
264
|
+
complete?: PrimitiveSchema;
|
|
265
|
+
canPublish?: SchemaHook<TContext>;
|
|
266
|
+
}
|
|
267
|
+
type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
|
|
268
|
+
type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
|
|
269
|
+
type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
|
|
270
|
+
type QueueSchemaConfig<_TContext = any> = Record<string, QueueSchema>;
|
|
271
|
+
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;
|
|
272
|
+
type InferSchemaMap<T extends Record<string, unknown>> = {
|
|
273
|
+
[K in keyof T]: InferSchema<T[K]>;
|
|
274
|
+
};
|
|
275
|
+
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;
|
|
276
|
+
type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
|
|
277
|
+
[K in keyof T]: InferQueueComplete<T[K]>;
|
|
278
|
+
};
|
|
279
|
+
type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
|
|
280
|
+
|
|
185
281
|
interface DeconstructedError {
|
|
186
282
|
__type: "ActorError";
|
|
187
283
|
statusCode: ContentfulStatusCode;
|
|
@@ -190,6 +286,7 @@ interface DeconstructedError {
|
|
|
190
286
|
code: string;
|
|
191
287
|
message: string;
|
|
192
288
|
metadata?: unknown;
|
|
289
|
+
rayId?: string;
|
|
193
290
|
actor?: ActorSpecifier;
|
|
194
291
|
}
|
|
195
292
|
|
|
@@ -198,6 +295,8 @@ interface RivetErrorOptions extends ErrorOptions {
|
|
|
198
295
|
public?: boolean;
|
|
199
296
|
/** Metadata associated with this error. */
|
|
200
297
|
metadata?: unknown;
|
|
298
|
+
/** Request identifier used to correlate this error with engine logs. */
|
|
299
|
+
rayId?: string;
|
|
201
300
|
/** Explicit HTTP status override for router responses. */
|
|
202
301
|
statusCode?: number;
|
|
203
302
|
/** Actor context associated with this error. */
|
|
@@ -225,6 +324,7 @@ declare class RivetError extends Error {
|
|
|
225
324
|
__type: "RivetError";
|
|
226
325
|
public: boolean;
|
|
227
326
|
metadata?: unknown;
|
|
327
|
+
readonly rayId?: string;
|
|
228
328
|
statusCode: number;
|
|
229
329
|
actor?: ActorSpecifier;
|
|
230
330
|
readonly group: string;
|
|
@@ -239,44 +339,6 @@ declare class UserError extends RivetError {
|
|
|
239
339
|
constructor(message: string, options?: UserErrorOptions);
|
|
240
340
|
}
|
|
241
341
|
|
|
242
|
-
type SchemaHookResult = boolean | Promise<boolean>;
|
|
243
|
-
type SchemaHook<TContext = any> = (ctx: TContext) => SchemaHookResult;
|
|
244
|
-
interface EventTypeToken<T, TContext = any> {
|
|
245
|
-
readonly _eventType?: T;
|
|
246
|
-
readonly canSubscribe?: SchemaHook<TContext>;
|
|
247
|
-
readonly schema?: PrimitiveSchema;
|
|
248
|
-
}
|
|
249
|
-
interface QueueTypeToken<TMessage, TComplete = never, TContext = any> {
|
|
250
|
-
readonly _queueMessage?: TMessage;
|
|
251
|
-
readonly _queueComplete?: TComplete;
|
|
252
|
-
readonly canPublish?: SchemaHook<TContext>;
|
|
253
|
-
readonly message?: PrimitiveSchema;
|
|
254
|
-
readonly complete?: PrimitiveSchema;
|
|
255
|
-
}
|
|
256
|
-
type PrimitiveSchema = StandardSchemaV1 | EventTypeToken<unknown, any>;
|
|
257
|
-
interface EventSchemaDefinition<TContext = any> {
|
|
258
|
-
schema: PrimitiveSchema;
|
|
259
|
-
canSubscribe?: SchemaHook<TContext>;
|
|
260
|
-
}
|
|
261
|
-
interface QueueSchemaDefinition<TContext = any> {
|
|
262
|
-
message: PrimitiveSchema;
|
|
263
|
-
complete?: PrimitiveSchema;
|
|
264
|
-
canPublish?: SchemaHook<TContext>;
|
|
265
|
-
}
|
|
266
|
-
type EventSchema<TContext = any> = PrimitiveSchema | EventSchemaDefinition<TContext>;
|
|
267
|
-
type QueueSchema = PrimitiveSchema | QueueSchemaDefinition<any> | QueueTypeToken<unknown, unknown, any>;
|
|
268
|
-
type EventSchemaConfig<TContext = any> = Record<string, EventSchema<TContext>>;
|
|
269
|
-
type QueueSchemaConfig<TContext = any> = Record<string, QueueSchema>;
|
|
270
|
-
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;
|
|
271
|
-
type InferSchemaMap<T extends Record<string, unknown>> = {
|
|
272
|
-
[K in keyof T]: InferSchema<T[K]>;
|
|
273
|
-
};
|
|
274
|
-
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;
|
|
275
|
-
type InferQueueCompleteMap<T extends QueueSchemaConfig> = {
|
|
276
|
-
[K in keyof T]: InferQueueComplete<T[K]>;
|
|
277
|
-
};
|
|
278
|
-
type InferEventArgs<T> = T extends readonly unknown[] ? number extends T["length"] ? [T] : T : [T];
|
|
279
|
-
|
|
280
342
|
type UpgradeWebSocket = (createEvents: (c: Context) => any) => Handler;
|
|
281
343
|
type GetUpgradeWebSocket = () => UpgradeWebSocket;
|
|
282
344
|
|
|
@@ -306,11 +368,6 @@ interface EngineControlClient {
|
|
|
306
368
|
* Test-only helper that simulates an abrupt actor crash.
|
|
307
369
|
*/
|
|
308
370
|
hardCrashActor?(actorId: string): Promise<void>;
|
|
309
|
-
kvGet(actorId: string, key: Uint8Array): Promise<string | null>;
|
|
310
|
-
kvBatchGet(actorId: string, keys: Uint8Array[]): Promise<(Uint8Array | null)[]>;
|
|
311
|
-
kvBatchPut(actorId: string, entries: [Uint8Array, Uint8Array][]): Promise<void>;
|
|
312
|
-
kvBatchDelete(actorId: string, keys: Uint8Array[]): Promise<void>;
|
|
313
|
-
kvDeleteRange(actorId: string, start: Uint8Array, end: Uint8Array): Promise<void>;
|
|
314
371
|
}
|
|
315
372
|
interface RuntimeDisplayInformation {
|
|
316
373
|
properties: Record<string, string>;
|
|
@@ -332,6 +389,8 @@ interface GetOrCreateWithKeyInput {
|
|
|
332
389
|
input?: unknown;
|
|
333
390
|
region?: string;
|
|
334
391
|
crashPolicy?: CrashPolicy;
|
|
392
|
+
/** Overrides the client's configured pool name for this actor. */
|
|
393
|
+
poolName?: string;
|
|
335
394
|
}
|
|
336
395
|
interface CreateInput {
|
|
337
396
|
c?: Context | undefined;
|
|
@@ -340,6 +399,8 @@ interface CreateInput {
|
|
|
340
399
|
input?: unknown;
|
|
341
400
|
region?: string;
|
|
342
401
|
crashPolicy?: CrashPolicy;
|
|
402
|
+
/** Overrides the client's configured pool name for this actor. */
|
|
403
|
+
poolName?: string;
|
|
343
404
|
}
|
|
344
405
|
interface ListActorsInput {
|
|
345
406
|
c?: Context | undefined;
|
|
@@ -384,6 +445,14 @@ interface QueueSendResult<TResponse = unknown> {
|
|
|
384
445
|
* @returns {Promise<Response>}
|
|
385
446
|
*/
|
|
386
447
|
type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
|
|
448
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
449
|
+
type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
|
|
450
|
+
type ActorActionMap<R> = {
|
|
451
|
+
[K in keyof NonNullable<R>]: NonNullable<R>[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Awaited<Return>> : NonNullable<R>[K] extends Record<string, unknown> ? ActorActionMap<NonNullable<R>[K]> : never;
|
|
452
|
+
};
|
|
453
|
+
type ActionsOf<AD extends AnyActorDefinition> = AD["config"] extends {
|
|
454
|
+
actions?: infer R;
|
|
455
|
+
} ? R : never;
|
|
387
456
|
interface ActorGatewayOptions {
|
|
388
457
|
skipReadyWait?: boolean;
|
|
389
458
|
}
|
|
@@ -396,9 +465,7 @@ type ActorWebSocketOptions = ActorGatewayOptions;
|
|
|
396
465
|
/**
|
|
397
466
|
* Maps action methods from actor definition to typed function signatures.
|
|
398
467
|
*/
|
|
399
|
-
type ActorDefinitionActions<AD extends AnyActorDefinition> = AD extends
|
|
400
|
-
[K in keyof R]: R[K] extends (...args: infer Args) => infer Return ? ActorActionFunction<Args, Return> : never;
|
|
401
|
-
} : never;
|
|
468
|
+
type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : ActorActionMap<ActionsOf<AD>>;
|
|
402
469
|
type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
|
|
403
470
|
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options: QueueSendWaitOptions): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
|
|
404
471
|
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options?: QueueSendNoWaitOptions): Promise<void>;
|
|
@@ -409,13 +476,31 @@ type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
|
|
|
409
476
|
<K extends keyof TEvents & string>(eventName: K, callback: (...args: InferEventArgs<InferSchemaMap<TEvents>[K]>) => void): () => void;
|
|
410
477
|
(eventName: keyof TEvents extends never ? string : never, callback: (...args: any[]) => void): () => void;
|
|
411
478
|
};
|
|
412
|
-
type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = AD
|
|
479
|
+
type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
480
|
+
send: ActorQueueSend<Record<string, any>>;
|
|
481
|
+
} : AD extends {
|
|
482
|
+
config: {
|
|
483
|
+
queues?: infer Q;
|
|
484
|
+
};
|
|
485
|
+
} ? Q extends QueueSchemaConfig ? {
|
|
486
|
+
send: ActorQueueSend<Q>;
|
|
487
|
+
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
|
|
413
488
|
send: ActorQueueSend<Q>;
|
|
414
|
-
} :
|
|
415
|
-
type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = AD
|
|
489
|
+
} : {} : {};
|
|
490
|
+
type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
491
|
+
on: LooseEventSubscribe;
|
|
492
|
+
once: LooseEventSubscribe;
|
|
493
|
+
} : AD extends {
|
|
494
|
+
config: {
|
|
495
|
+
events?: infer E;
|
|
496
|
+
};
|
|
497
|
+
} ? E extends EventSchemaConfig ? {
|
|
416
498
|
on: ActorEventSubscribe<E>;
|
|
417
499
|
once: ActorEventSubscribe<E>;
|
|
418
|
-
} :
|
|
500
|
+
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
|
|
501
|
+
on: ActorEventSubscribe<E>;
|
|
502
|
+
once: ActorEventSubscribe<E>;
|
|
503
|
+
} : {} : {};
|
|
419
504
|
|
|
420
505
|
declare class ActorClientError extends Error {
|
|
421
506
|
}
|
|
@@ -616,7 +701,7 @@ declare class ActorHandleRaw {
|
|
|
616
701
|
*
|
|
617
702
|
* @protected
|
|
618
703
|
*/
|
|
619
|
-
constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions);
|
|
704
|
+
constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions, signal?: AbortSignal);
|
|
620
705
|
send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
621
706
|
send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
622
707
|
/**
|
|
@@ -824,6 +909,11 @@ interface GetOrCreateOptions extends QueryOptions {
|
|
|
824
909
|
createInRegion?: string;
|
|
825
910
|
/** Input data to pass to the actor. */
|
|
826
911
|
createWithInput?: unknown;
|
|
912
|
+
/**
|
|
913
|
+
* Name of the envoy pool to select for this actor if it is created.
|
|
914
|
+
* Overrides the client's configured `poolName` for this call.
|
|
915
|
+
*/
|
|
916
|
+
poolName?: string;
|
|
827
917
|
}
|
|
828
918
|
/**
|
|
829
919
|
* Options for creating a actor.
|
|
@@ -835,6 +925,11 @@ interface CreateOptions extends QueryOptions {
|
|
|
835
925
|
region?: string;
|
|
836
926
|
/** Input data to pass to the actor. */
|
|
837
927
|
input?: unknown;
|
|
928
|
+
/**
|
|
929
|
+
* Name of the envoy pool to select for this actor.
|
|
930
|
+
* Overrides the client's configured `poolName` for this call.
|
|
931
|
+
*/
|
|
932
|
+
poolName?: string;
|
|
838
933
|
}
|
|
839
934
|
/**
|
|
840
935
|
* Represents a region to connect to.
|
|
@@ -928,7 +1023,11 @@ type Client<A extends Registry<any>> = ClientRaw & {
|
|
|
928
1023
|
[K in keyof ExtractActorsFromRegistry<A>]: ActorAccessor<ExtractActorsFromRegistry<A>[K]>;
|
|
929
1024
|
};
|
|
930
1025
|
|
|
1026
|
+
/** @experimental State exposed by a durable workflow run handler to the Inspector. */
|
|
1027
|
+
type WorkflowState = "pending" | "running" | "sleeping" | "failed" | "completed" | "cancelled" | "rolling_back";
|
|
1028
|
+
|
|
931
1029
|
declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
|
|
1030
|
+
declare const RAW_STATE_SYMBOL: unique symbol;
|
|
932
1031
|
interface ActorLogger {
|
|
933
1032
|
level: any;
|
|
934
1033
|
fatal: any;
|
|
@@ -961,6 +1060,10 @@ type ActorKvListOptions<T extends ActorKvValueType = "text", K extends ActorKvKe
|
|
|
961
1060
|
limit?: number;
|
|
962
1061
|
};
|
|
963
1062
|
type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
|
|
1063
|
+
/**
|
|
1064
|
+
* @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db`)
|
|
1065
|
+
* or actor state instead.
|
|
1066
|
+
*/
|
|
964
1067
|
interface ActorKv {
|
|
965
1068
|
get<T extends ActorKvValueType = "text">(key: Uint8Array | string, options?: ActorKvValueOptions<T>): Promise<ActorKvValueTypeMap[T] | null>;
|
|
966
1069
|
put<T extends ActorKvValueType = "text">(key: Uint8Array | string, value: Uint8Array | string | ArrayBuffer, options?: ActorKvValueOptions<T>): Promise<void>;
|
|
@@ -975,10 +1078,76 @@ interface ActorKv {
|
|
|
975
1078
|
[key: string]: any;
|
|
976
1079
|
}
|
|
977
1080
|
interface ActorSchedule {
|
|
978
|
-
after(duration: number, action: string, ...args: unknown[]): Promise<
|
|
979
|
-
at(timestamp: number, action: string, ...args: unknown[]): Promise<
|
|
1081
|
+
after(duration: number, action: string, ...args: unknown[]): Promise<string>;
|
|
1082
|
+
at(timestamp: number, action: string, ...args: unknown[]): Promise<string>;
|
|
1083
|
+
cancel(id: string): Promise<boolean>;
|
|
1084
|
+
get(id: string): Promise<ScheduledEventInfo | undefined>;
|
|
1085
|
+
list(): Promise<ScheduledEventInfo[]>;
|
|
1086
|
+
[key: string]: any;
|
|
1087
|
+
}
|
|
1088
|
+
interface ActorCronSetOptions {
|
|
1089
|
+
name: string;
|
|
1090
|
+
expression: string;
|
|
1091
|
+
action: string;
|
|
1092
|
+
args?: unknown[];
|
|
1093
|
+
timezone?: string;
|
|
1094
|
+
/** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
|
|
1095
|
+
maxHistory?: number;
|
|
1096
|
+
}
|
|
1097
|
+
interface ActorCronEveryOptions {
|
|
1098
|
+
name: string;
|
|
1099
|
+
/** Fixed interval in milliseconds. Minimum 5,000. */
|
|
1100
|
+
interval: number;
|
|
1101
|
+
action: string;
|
|
1102
|
+
args?: unknown[];
|
|
1103
|
+
/** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
|
|
1104
|
+
maxHistory?: number;
|
|
1105
|
+
}
|
|
1106
|
+
interface ActorCron {
|
|
1107
|
+
set(options: ActorCronSetOptions): Promise<void>;
|
|
1108
|
+
every(options: ActorCronEveryOptions): Promise<void>;
|
|
1109
|
+
get(name: string): Promise<CronJobInfo | undefined>;
|
|
1110
|
+
list(): Promise<CronJobInfo[]>;
|
|
1111
|
+
delete(name: string): Promise<boolean>;
|
|
1112
|
+
history(name: string, options?: {
|
|
1113
|
+
limit?: number;
|
|
1114
|
+
}): Promise<CronFire[]>;
|
|
980
1115
|
[key: string]: any;
|
|
981
1116
|
}
|
|
1117
|
+
interface ScheduledEventInfo {
|
|
1118
|
+
id: string;
|
|
1119
|
+
action: string;
|
|
1120
|
+
args: unknown[];
|
|
1121
|
+
runAt: number;
|
|
1122
|
+
}
|
|
1123
|
+
type CronJobInfo = {
|
|
1124
|
+
name: string;
|
|
1125
|
+
action: string;
|
|
1126
|
+
args: unknown[];
|
|
1127
|
+
nextRunAt: number;
|
|
1128
|
+
lastRunAt?: number;
|
|
1129
|
+
maxHistory: number;
|
|
1130
|
+
} & ({
|
|
1131
|
+
kind: "cron";
|
|
1132
|
+
expression: string;
|
|
1133
|
+
timezone: string;
|
|
1134
|
+
} | {
|
|
1135
|
+
kind: "every";
|
|
1136
|
+
interval: number;
|
|
1137
|
+
});
|
|
1138
|
+
interface CronFire {
|
|
1139
|
+
action: string;
|
|
1140
|
+
scheduledAt: number;
|
|
1141
|
+
firedAt: number;
|
|
1142
|
+
finishedAt?: number;
|
|
1143
|
+
result: "running" | "ok" | "error" | "skipped";
|
|
1144
|
+
error?: {
|
|
1145
|
+
group: string;
|
|
1146
|
+
code: string;
|
|
1147
|
+
message: string;
|
|
1148
|
+
metadata?: unknown;
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
982
1151
|
type QueueMessageOf<Name extends string, Body> = {
|
|
983
1152
|
id: number | bigint;
|
|
984
1153
|
name: Name;
|
|
@@ -989,6 +1158,8 @@ type QueueMessageOf<Name extends string, Body> = {
|
|
|
989
1158
|
type QueueName<TQueues extends QueueSchemaConfig> = keyof TQueues & string;
|
|
990
1159
|
type QueueFilterName<TQueues extends QueueSchemaConfig> = keyof TQueues extends never ? string : QueueName<TQueues>;
|
|
991
1160
|
type QueueMessageForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>> = keyof TQueues extends never ? QueueMessageOf<string, unknown> : TName extends QueueName<TQueues> ? QueueMessageOf<TName, InferSchemaMap<TQueues>[TName]> : never;
|
|
1161
|
+
type QueueCompleteArgs<T> = undefined extends T ? [response?: T] : [response: T];
|
|
1162
|
+
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];
|
|
992
1163
|
type QueueCompletionResultForName<TQueues extends QueueSchemaConfig, TName extends QueueFilterName<TQueues>> = keyof TQueues extends never ? unknown | undefined : TName extends QueueName<TQueues> ? InferQueueCompleteMap<TQueues>[TName] | undefined : unknown | undefined;
|
|
993
1164
|
interface QueueNextOptions<TName extends string = string, TCompletable extends boolean = boolean> {
|
|
994
1165
|
names?: readonly TName[];
|
|
@@ -1031,13 +1202,20 @@ interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
|
1031
1202
|
next<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextOptions<TName, TCompletable>): Promise<any>;
|
|
1032
1203
|
nextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextBatchOptions<TName, TCompletable>): Promise<any[]>;
|
|
1033
1204
|
waitForNames<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(names: readonly TName[], opts?: QueueWaitOptions<TCompletable>): Promise<any>;
|
|
1205
|
+
/** @experimental */
|
|
1206
|
+
waitForAvailable<const TName extends QueueFilterName<TQueues>>(names?: readonly TName[], opts?: Omit<QueueWaitOptions<false>, "completable">): Promise<void>;
|
|
1207
|
+
/** @experimental */
|
|
1208
|
+
complete<const TName extends QueueFilterName<TQueues>>(message: {
|
|
1209
|
+
id: number | bigint;
|
|
1210
|
+
name: TName;
|
|
1211
|
+
}, ...args: QueueCompleteArgsForName<TQueues, TName>): Promise<void>;
|
|
1034
1212
|
enqueueAndWait<const TName extends QueueFilterName<TQueues>>(name: TName, body: QueueMessageForName<TQueues, TName>["body"], opts?: QueueEnqueueAndWaitOptions): Promise<QueueCompletionResultForName<TQueues, TName>>;
|
|
1035
1213
|
tryNext<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextOptions<TName, TCompletable>): Promise<any>;
|
|
1036
1214
|
tryNextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextBatchOptions<TName, TCompletable>): Promise<any[]>;
|
|
1037
1215
|
iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
|
|
1038
1216
|
[key: string]: any;
|
|
1039
1217
|
}
|
|
1040
|
-
interface Conn<
|
|
1218
|
+
interface Conn<_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>> {
|
|
1041
1219
|
id: string;
|
|
1042
1220
|
params: TConnParams;
|
|
1043
1221
|
state: TConnState;
|
|
@@ -1048,16 +1226,29 @@ interface Conn<TState = unknown, TConnParams = unknown, TConnState = unknown, TV
|
|
|
1048
1226
|
}
|
|
1049
1227
|
interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1050
1228
|
[ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
|
|
1229
|
+
/** Returns the raw unwrapped state without the write-through proxy. */
|
|
1230
|
+
[RAW_STATE_SYMBOL](): TState;
|
|
1051
1231
|
state: TState;
|
|
1052
1232
|
vars: TVars;
|
|
1233
|
+
/**
|
|
1234
|
+
* @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db`)
|
|
1235
|
+
* or actor state instead.
|
|
1236
|
+
*/
|
|
1053
1237
|
readonly kv: ActorKv;
|
|
1054
1238
|
readonly db: InferDatabaseClient<TDatabase>;
|
|
1055
1239
|
readonly schedule: ActorSchedule;
|
|
1240
|
+
readonly cron: ActorCron;
|
|
1056
1241
|
readonly queue: ActorQueue<TQueues>;
|
|
1242
|
+
/** @experimental */
|
|
1243
|
+
readonly run: ActorRun;
|
|
1057
1244
|
readonly actorId: string;
|
|
1058
1245
|
readonly name: string;
|
|
1059
1246
|
readonly key: string[];
|
|
1060
1247
|
readonly region: string;
|
|
1248
|
+
/** Provisions the experimental Actor Runtime Socket for this actor generation. */
|
|
1249
|
+
actorRuntimeSocket(): Promise<{
|
|
1250
|
+
path: string;
|
|
1251
|
+
}>;
|
|
1061
1252
|
readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
|
|
1062
1253
|
readonly log: ActorLogger;
|
|
1063
1254
|
readonly abortSignal: AbortSignal;
|
|
@@ -1079,6 +1270,14 @@ interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase
|
|
|
1079
1270
|
client<T = any>(): ActorClientFor<T>;
|
|
1080
1271
|
[key: string]: any;
|
|
1081
1272
|
}
|
|
1273
|
+
/** @experimental */
|
|
1274
|
+
interface ActorRun {
|
|
1275
|
+
/**
|
|
1276
|
+
* @experimental Sets or clears the durable Unix-millisecond deadline that
|
|
1277
|
+
* ensures this actor's run handler is active, starting it if inactive.
|
|
1278
|
+
*/
|
|
1279
|
+
setWakeAt(timestamp: number | null): Promise<void>;
|
|
1280
|
+
}
|
|
1082
1281
|
type ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> & {
|
|
1083
1282
|
conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1084
1283
|
};
|
|
@@ -1105,6 +1304,7 @@ declare const RunConfigSchema: z.ZodObject<{
|
|
|
1105
1304
|
inspector: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1106
1305
|
workflow: z.ZodOptional<z.ZodObject<{
|
|
1107
1306
|
getHistory: z.ZodCustom<() => unknown, () => unknown>;
|
|
1307
|
+
getState: z.ZodOptional<z.ZodCustom<() => Promise<WorkflowState | null>, () => Promise<WorkflowState | null>>>;
|
|
1108
1308
|
onHistoryUpdated: z.ZodOptional<z.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
|
|
1109
1309
|
replayFromStep: z.ZodOptional<z.ZodCustom<(entryId?: string) => Promise<unknown>, (entryId?: string) => Promise<unknown>>>;
|
|
1110
1310
|
}, z.core.$strip>>;
|
|
@@ -1127,6 +1327,7 @@ declare const ActorConfigSchema: z.ZodObject<{
|
|
|
1127
1327
|
inspector: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1128
1328
|
workflow: z.ZodOptional<z.ZodObject<{
|
|
1129
1329
|
getHistory: z.ZodCustom<() => unknown, () => unknown>;
|
|
1330
|
+
getState: z.ZodOptional<z.ZodCustom<() => Promise<WorkflowState | null>, () => Promise<WorkflowState | null>>>;
|
|
1130
1331
|
onHistoryUpdated: z.ZodOptional<z.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
|
|
1131
1332
|
replayFromStep: z.ZodOptional<z.ZodCustom<(entryId?: string) => Promise<unknown>, (entryId?: string) => Promise<unknown>>>;
|
|
1132
1333
|
}, z.core.$strip>>;
|
|
@@ -1139,7 +1340,7 @@ declare const ActorConfigSchema: z.ZodObject<{
|
|
|
1139
1340
|
onBeforeActionResponse: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1140
1341
|
onRequest: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1141
1342
|
onWebSocket: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1142
|
-
actions: z.ZodDefault<z.
|
|
1343
|
+
actions: z.ZodDefault<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
1143
1344
|
actionInputSchemas: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
1144
1345
|
connParamsSchema: z.ZodOptional<z.ZodAny>;
|
|
1145
1346
|
events: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
@@ -1154,6 +1355,7 @@ declare const ActorConfigSchema: z.ZodObject<{
|
|
|
1154
1355
|
options: z.ZodPrefault<z.ZodObject<{
|
|
1155
1356
|
name: z.ZodOptional<z.ZodString>;
|
|
1156
1357
|
icon: z.ZodOptional<z.ZodString>;
|
|
1358
|
+
enableActorRuntimeSocket: z.ZodDefault<z.ZodBoolean>;
|
|
1157
1359
|
canHibernateWebSocket: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodCustom<(request: Request) => boolean, (request: Request) => boolean>]>>;
|
|
1158
1360
|
createVarsTimeout: z.ZodDefault<z.ZodNumber>;
|
|
1159
1361
|
createConnStateTimeout: z.ZodDefault<z.ZodNumber>;
|
|
@@ -1170,12 +1372,33 @@ declare const ActorConfigSchema: z.ZodObject<{
|
|
|
1170
1372
|
noSleep: z.ZodDefault<z.ZodBoolean>;
|
|
1171
1373
|
sleepTimeout: z.ZodDefault<z.ZodNumber>;
|
|
1172
1374
|
maxQueueSize: z.ZodDefault<z.ZodNumber>;
|
|
1375
|
+
maxSchedules: z.ZodDefault<z.ZodNumber>;
|
|
1173
1376
|
maxQueueMessageSize: z.ZodDefault<z.ZodNumber>;
|
|
1174
1377
|
preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
|
|
1175
1378
|
preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
|
|
1176
1379
|
}, z.core.$strict>>;
|
|
1380
|
+
inspector: z.ZodOptional<z.ZodObject<{
|
|
1381
|
+
tabs: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
1382
|
+
id: z.ZodString;
|
|
1383
|
+
label: z.ZodString;
|
|
1384
|
+
source: z.ZodString;
|
|
1385
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
1386
|
+
hidden: z.ZodOptional<z.ZodLiteral<false>>;
|
|
1387
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1388
|
+
id: z.ZodEnum<{
|
|
1389
|
+
state: "state";
|
|
1390
|
+
database: "database";
|
|
1391
|
+
console: "console";
|
|
1392
|
+
workflow: "workflow";
|
|
1393
|
+
queue: "queue";
|
|
1394
|
+
schedules: "schedules";
|
|
1395
|
+
connections: "connections";
|
|
1396
|
+
}>;
|
|
1397
|
+
hidden: z.ZodLiteral<true>;
|
|
1398
|
+
}, z.core.$strict>]>>>;
|
|
1399
|
+
}, z.core.$strict>>;
|
|
1177
1400
|
}, z.core.$strict>;
|
|
1178
|
-
type CreateState<TState,
|
|
1401
|
+
type CreateState<TState, _TConnParams, _TConnState, _TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
1179
1402
|
state: TState;
|
|
1180
1403
|
} | {
|
|
1181
1404
|
createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
|
|
@@ -1188,7 +1411,7 @@ type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase e
|
|
|
1188
1411
|
/**
|
|
1189
1412
|
* @experimental
|
|
1190
1413
|
*/
|
|
1191
|
-
type CreateVars<TState,
|
|
1414
|
+
type CreateVars<TState, _TConnParams, _TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
1192
1415
|
/**
|
|
1193
1416
|
* @experimental
|
|
1194
1417
|
*/
|
|
@@ -1200,7 +1423,10 @@ type CreateVars<TState, TConnParams, TConnState, TVars, TInput, TDatabase extend
|
|
|
1200
1423
|
createVars: (c: CreateVarsContext<TState, TInput, TDatabase, TEvents, TQueues>, driverCtx: any) => TVars | Promise<TVars>;
|
|
1201
1424
|
} | Record<never, never>;
|
|
1202
1425
|
interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1203
|
-
[Action: string]: (c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any
|
|
1426
|
+
[Action: string]: ((c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any) | Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1427
|
+
}
|
|
1428
|
+
interface ActionInputSchemas {
|
|
1429
|
+
[Action: string]: PrimitiveSchema | ActionInputSchemas;
|
|
1204
1430
|
}
|
|
1205
1431
|
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>> {
|
|
1206
1432
|
/**
|
|
@@ -1352,9 +1578,10 @@ interface BaseActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatab
|
|
|
1352
1578
|
onWebSocket?: (c: WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, websocket: UniversalWebSocket) => void | Promise<void>;
|
|
1353
1579
|
actions?: TActions;
|
|
1354
1580
|
/**
|
|
1355
|
-
* Optional
|
|
1581
|
+
* Optional schemas for validating action argument tuples in native runtimes.
|
|
1582
|
+
* May mirror nested action groups or use dot-separated low-level action names.
|
|
1356
1583
|
*/
|
|
1357
|
-
actionInputSchemas?:
|
|
1584
|
+
actionInputSchemas?: ActionInputSchemas;
|
|
1358
1585
|
/**
|
|
1359
1586
|
* Optional schema for validating connection params in native runtimes.
|
|
1360
1587
|
*/
|
|
@@ -1374,19 +1601,21 @@ type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
|
|
|
1374
1601
|
*/
|
|
1375
1602
|
db: TDatabase;
|
|
1376
1603
|
} | Record<never, never>;
|
|
1377
|
-
type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = Omit<z.infer<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onMigrate" | "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,
|
|
1604
|
+
type ActorConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>, TActions extends Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues> = Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>> = Omit<z.infer<typeof ActorConfigSchema>, "actions" | "events" | "queues" | "onCreate" | "onDestroy" | "onMigrate" | "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>;
|
|
1378
1605
|
|
|
1379
|
-
interface BaseActorDefinition<S, CP, CS, V, I, DB extends AnyDatabaseProvider, E extends EventSchemaConfig = Record<never, never>, Q extends QueueSchemaConfig = Record<never, never>,
|
|
1380
|
-
readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q>;
|
|
1606
|
+
interface BaseActorDefinition<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>> {
|
|
1607
|
+
readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q, _R>;
|
|
1608
|
+
}
|
|
1609
|
+
interface AnyActorDefinition {
|
|
1610
|
+
readonly config: any;
|
|
1381
1611
|
}
|
|
1382
|
-
type AnyActorDefinition = BaseActorDefinition<any, any, any, any, any, any, any, any, any>;
|
|
1383
1612
|
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>> implements BaseActorDefinition<S, CP, CS, V, I, DB, E, Q, R> {
|
|
1384
1613
|
#private;
|
|
1385
|
-
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>);
|
|
1386
|
-
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q>;
|
|
1614
|
+
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>);
|
|
1615
|
+
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
|
|
1387
1616
|
}
|
|
1388
1617
|
|
|
1389
|
-
declare const ActorsSchema: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<
|
|
1618
|
+
declare const ActorsSchema: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
|
|
1390
1619
|
type RegistryActors = z$2.infer<typeof ActorsSchema>;
|
|
1391
1620
|
declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
|
|
1392
1621
|
use: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
|
|
@@ -1447,7 +1676,10 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
|
|
|
1447
1676
|
httpPort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
|
|
1448
1677
|
httpHost: z$2.ZodOptional<z$2.ZodString>;
|
|
1449
1678
|
startEngine: z$2.ZodDefault<z$2.ZodBoolean>;
|
|
1679
|
+
engineHost: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
|
|
1680
|
+
enginePort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
|
|
1450
1681
|
engineVersion: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
|
|
1682
|
+
startServices: z$2.ZodOptional<z$2.ZodBoolean>;
|
|
1451
1683
|
configurePool: z$2.ZodOptional<z$2.ZodOptional<z$2.ZodObject<{
|
|
1452
1684
|
name: z$2.ZodOptional<z$2.ZodString>;
|
|
1453
1685
|
url: z$2.ZodString;
|
|
@@ -1471,7 +1703,7 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
|
|
|
1471
1703
|
envoyKey: z$2.ZodOptional<z$2.ZodString>;
|
|
1472
1704
|
}, z$2.core.$strip>>>;
|
|
1473
1705
|
shutdown: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
|
|
1474
|
-
gracePeriodMs: z$2.
|
|
1706
|
+
gracePeriodMs: z$2.ZodOptional<z$2.ZodNumber>;
|
|
1475
1707
|
disableSignalHandlers: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
|
|
1476
1708
|
}, z$2.core.$strip>>>;
|
|
1477
1709
|
}, z$2.core.$strip>, z$2.ZodTransform<{
|
|
@@ -1479,8 +1711,9 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
|
|
|
1479
1711
|
backend: "local" | "remote";
|
|
1480
1712
|
} | undefined;
|
|
1481
1713
|
endpoint: string | undefined;
|
|
1714
|
+
startServices: boolean;
|
|
1482
1715
|
namespace: string;
|
|
1483
|
-
token: string
|
|
1716
|
+
token: string;
|
|
1484
1717
|
publicEndpoint: string | undefined;
|
|
1485
1718
|
publicNamespace: string | undefined;
|
|
1486
1719
|
publicToken: string | undefined;
|
|
@@ -1514,6 +1747,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
|
|
|
1514
1747
|
httpBasePath: string;
|
|
1515
1748
|
httpPort: number;
|
|
1516
1749
|
startEngine: boolean;
|
|
1750
|
+
engineHost: string;
|
|
1751
|
+
enginePort: number;
|
|
1517
1752
|
engineVersion: string;
|
|
1518
1753
|
envoy: {
|
|
1519
1754
|
poolName: string;
|
|
@@ -1522,8 +1757,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
|
|
|
1522
1757
|
envoyKey?: string | undefined;
|
|
1523
1758
|
};
|
|
1524
1759
|
shutdown: {
|
|
1525
|
-
gracePeriodMs: number;
|
|
1526
1760
|
disableSignalHandlers: boolean;
|
|
1761
|
+
gracePeriodMs?: number | undefined;
|
|
1527
1762
|
};
|
|
1528
1763
|
staticDir?: string | undefined;
|
|
1529
1764
|
httpHost?: string | undefined;
|
|
@@ -1567,6 +1802,8 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
|
|
|
1567
1802
|
httpBasePath: string;
|
|
1568
1803
|
httpPort: number;
|
|
1569
1804
|
startEngine: boolean;
|
|
1805
|
+
engineHost: string;
|
|
1806
|
+
enginePort: number;
|
|
1570
1807
|
engineVersion: string;
|
|
1571
1808
|
serverless: {
|
|
1572
1809
|
basePath: string;
|
|
@@ -1581,11 +1818,12 @@ declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
|
|
|
1581
1818
|
envoyKey?: string | undefined;
|
|
1582
1819
|
};
|
|
1583
1820
|
shutdown: {
|
|
1584
|
-
gracePeriodMs: number;
|
|
1585
1821
|
disableSignalHandlers: boolean;
|
|
1822
|
+
gracePeriodMs?: number | undefined;
|
|
1586
1823
|
};
|
|
1587
1824
|
staticDir?: string | undefined;
|
|
1588
1825
|
httpHost?: string | undefined;
|
|
1826
|
+
startServices?: boolean | undefined;
|
|
1589
1827
|
configurePool?: {
|
|
1590
1828
|
url: string;
|
|
1591
1829
|
name?: string | undefined;
|
|
@@ -1602,19 +1840,469 @@ type RegistryConfigInput<A extends RegistryActors> = Omit<z$2.input<typeof Regis
|
|
|
1602
1840
|
use: A;
|
|
1603
1841
|
};
|
|
1604
1842
|
|
|
1843
|
+
declare const handleBrand: unique symbol;
|
|
1844
|
+
type OpaqueHandle<Name extends string> = {
|
|
1845
|
+
readonly [handleBrand]: Name;
|
|
1846
|
+
};
|
|
1847
|
+
type RegistryHandle = OpaqueHandle<"registry">;
|
|
1848
|
+
type ActorFactoryHandle = OpaqueHandle<"actorFactory">;
|
|
1849
|
+
type ActorContextHandle = OpaqueHandle<"actorContext">;
|
|
1850
|
+
type ConnHandle = OpaqueHandle<"conn">;
|
|
1851
|
+
type WebSocketHandle = OpaqueHandle<"webSocket">;
|
|
1852
|
+
type CancellationTokenHandle = OpaqueHandle<"cancellationToken">;
|
|
1853
|
+
type ActorStateTransactionHandle = OpaqueHandle<"actorStateTransaction">;
|
|
1854
|
+
type SqliteTransactionHandle = OpaqueHandle<"sqliteTransaction">;
|
|
1855
|
+
type RuntimeBytes = Uint8Array;
|
|
1856
|
+
interface RuntimeActorKeySegment {
|
|
1857
|
+
kind: string;
|
|
1858
|
+
stringValue?: string;
|
|
1859
|
+
numberValue?: number;
|
|
1860
|
+
}
|
|
1861
|
+
interface RuntimeHttpRequest {
|
|
1862
|
+
method: string;
|
|
1863
|
+
uri: string;
|
|
1864
|
+
headers?: Record<string, string>;
|
|
1865
|
+
body?: RuntimeBytes;
|
|
1866
|
+
}
|
|
1867
|
+
interface RuntimeHttpResponseBodyStream {
|
|
1868
|
+
cancelled(): Promise<void>;
|
|
1869
|
+
write(chunk: Uint8Array): Promise<void>;
|
|
1870
|
+
end(): Promise<void>;
|
|
1871
|
+
error(message: string): Promise<void>;
|
|
1872
|
+
}
|
|
1873
|
+
interface RuntimeStateDeltaPayload {
|
|
1874
|
+
state?: RuntimeBytes;
|
|
1875
|
+
connHibernation: Array<{
|
|
1876
|
+
connId: string;
|
|
1877
|
+
bytes: RuntimeBytes;
|
|
1878
|
+
}>;
|
|
1879
|
+
connHibernationRemoved: string[];
|
|
1880
|
+
}
|
|
1881
|
+
interface RuntimeWorkflowKvWrite {
|
|
1882
|
+
key: RuntimeBytes;
|
|
1883
|
+
value: RuntimeBytes;
|
|
1884
|
+
}
|
|
1885
|
+
interface RuntimeRequestSaveOpts {
|
|
1886
|
+
immediate?: boolean;
|
|
1887
|
+
maxWaitMs?: number;
|
|
1888
|
+
}
|
|
1889
|
+
interface RuntimeInspectorSnapshot {
|
|
1890
|
+
stateRevision: number;
|
|
1891
|
+
connectionsRevision: number;
|
|
1892
|
+
queueRevision: number;
|
|
1893
|
+
activeConnections: number;
|
|
1894
|
+
queueSize: number;
|
|
1895
|
+
connectedClients: number;
|
|
1896
|
+
}
|
|
1897
|
+
interface RuntimeQueueMessage {
|
|
1898
|
+
id(): bigint;
|
|
1899
|
+
name(): string;
|
|
1900
|
+
body(): RuntimeBytes;
|
|
1901
|
+
createdAt(): number;
|
|
1902
|
+
isCompletable(): boolean;
|
|
1903
|
+
complete(response?: RuntimeBytes | undefined | null): Promise<void>;
|
|
1904
|
+
}
|
|
1905
|
+
interface RuntimeQueueInspectMessage {
|
|
1906
|
+
id: number;
|
|
1907
|
+
name: string;
|
|
1908
|
+
createdAtMs: number;
|
|
1909
|
+
}
|
|
1910
|
+
interface RuntimeScheduledEventInfo {
|
|
1911
|
+
id: string;
|
|
1912
|
+
action: string;
|
|
1913
|
+
args: RuntimeBytes;
|
|
1914
|
+
runAt: number;
|
|
1915
|
+
}
|
|
1916
|
+
interface RuntimeCronJobInfo {
|
|
1917
|
+
name: string;
|
|
1918
|
+
kind: "cron" | "every";
|
|
1919
|
+
action: string;
|
|
1920
|
+
args: RuntimeBytes;
|
|
1921
|
+
nextRunAt: number;
|
|
1922
|
+
lastRunAt?: number;
|
|
1923
|
+
expression?: string;
|
|
1924
|
+
timezone?: string;
|
|
1925
|
+
intervalMs?: number;
|
|
1926
|
+
maxHistory: number;
|
|
1927
|
+
}
|
|
1928
|
+
interface RuntimeScheduleErrorInfo {
|
|
1929
|
+
group: string;
|
|
1930
|
+
code: string;
|
|
1931
|
+
message: string;
|
|
1932
|
+
metadata?: unknown;
|
|
1933
|
+
}
|
|
1934
|
+
interface RuntimeCronFire {
|
|
1935
|
+
action: string;
|
|
1936
|
+
scheduledAt: number;
|
|
1937
|
+
firedAt: number;
|
|
1938
|
+
finishedAt?: number;
|
|
1939
|
+
result: "running" | "ok" | "error" | "skipped";
|
|
1940
|
+
error?: RuntimeScheduleErrorInfo;
|
|
1941
|
+
}
|
|
1942
|
+
interface RuntimeQueueNextBatchOptions {
|
|
1943
|
+
names?: string[];
|
|
1944
|
+
count?: number;
|
|
1945
|
+
timeoutMs?: number;
|
|
1946
|
+
completable?: boolean;
|
|
1947
|
+
}
|
|
1948
|
+
interface RuntimeQueueWaitOptions {
|
|
1949
|
+
timeoutMs?: number;
|
|
1950
|
+
completable?: boolean;
|
|
1951
|
+
}
|
|
1952
|
+
interface RuntimeQueueEnqueueAndWaitOptions {
|
|
1953
|
+
timeoutMs?: number;
|
|
1954
|
+
}
|
|
1955
|
+
interface RuntimeQueueTryNextBatchOptions {
|
|
1956
|
+
names?: string[];
|
|
1957
|
+
count?: number;
|
|
1958
|
+
completable?: boolean;
|
|
1959
|
+
}
|
|
1960
|
+
interface RuntimeKvListOptions {
|
|
1961
|
+
reverse?: boolean;
|
|
1962
|
+
limit?: number;
|
|
1963
|
+
}
|
|
1964
|
+
interface RuntimeKvEntry {
|
|
1965
|
+
key: RuntimeBytes;
|
|
1966
|
+
value: RuntimeBytes;
|
|
1967
|
+
}
|
|
1968
|
+
type RuntimeSqlBindNoValues = {
|
|
1969
|
+
intValue?: never;
|
|
1970
|
+
floatValue?: never;
|
|
1971
|
+
textValue?: never;
|
|
1972
|
+
blobValue?: never;
|
|
1973
|
+
};
|
|
1974
|
+
type RuntimeSqlBindParam = ({
|
|
1975
|
+
kind: "null";
|
|
1976
|
+
} & RuntimeSqlBindNoValues) | {
|
|
1977
|
+
kind: "int";
|
|
1978
|
+
intValue: number;
|
|
1979
|
+
floatValue?: never;
|
|
1980
|
+
textValue?: never;
|
|
1981
|
+
blobValue?: never;
|
|
1982
|
+
} | {
|
|
1983
|
+
kind: "float";
|
|
1984
|
+
intValue?: never;
|
|
1985
|
+
floatValue: number;
|
|
1986
|
+
textValue?: never;
|
|
1987
|
+
blobValue?: never;
|
|
1988
|
+
} | {
|
|
1989
|
+
kind: "text";
|
|
1990
|
+
intValue?: never;
|
|
1991
|
+
floatValue?: never;
|
|
1992
|
+
textValue: string;
|
|
1993
|
+
blobValue?: never;
|
|
1994
|
+
} | {
|
|
1995
|
+
kind: "blob";
|
|
1996
|
+
intValue?: never;
|
|
1997
|
+
floatValue?: never;
|
|
1998
|
+
textValue?: never;
|
|
1999
|
+
blobValue: RuntimeBytes;
|
|
2000
|
+
};
|
|
2001
|
+
type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
|
|
2002
|
+
interface RuntimeActorRuntimeSocketEndpointInfo {
|
|
2003
|
+
path: string;
|
|
2004
|
+
}
|
|
2005
|
+
interface RuntimeSqlQueryResult {
|
|
2006
|
+
columns: string[];
|
|
2007
|
+
rows: unknown[][];
|
|
2008
|
+
}
|
|
2009
|
+
type RuntimeSqlExecResult = RuntimeSqlQueryResult;
|
|
2010
|
+
interface RuntimeSqlExecuteResult extends RuntimeSqlQueryResult {
|
|
2011
|
+
changes: number;
|
|
2012
|
+
lastInsertRowId?: number | null;
|
|
2013
|
+
}
|
|
2014
|
+
interface RuntimeSqlBatchStatement {
|
|
2015
|
+
sql: string;
|
|
2016
|
+
params?: RuntimeSqlBindParams;
|
|
2017
|
+
}
|
|
2018
|
+
interface RuntimeSqlRunResult {
|
|
2019
|
+
changes: number;
|
|
2020
|
+
}
|
|
2021
|
+
interface RuntimeActorConfig {
|
|
2022
|
+
name?: string;
|
|
2023
|
+
icon?: string;
|
|
2024
|
+
hasDatabase?: boolean;
|
|
2025
|
+
remoteSqlite?: boolean;
|
|
2026
|
+
sqliteProfiling?: SqliteProfilingOptions;
|
|
2027
|
+
enableActorRuntimeSocket?: boolean;
|
|
2028
|
+
hasState?: boolean;
|
|
2029
|
+
canHibernateWebsocket?: boolean;
|
|
2030
|
+
stateSaveIntervalMs?: number;
|
|
2031
|
+
createStateTimeoutMs?: number;
|
|
2032
|
+
onCreateTimeoutMs?: number;
|
|
2033
|
+
createVarsTimeoutMs?: number;
|
|
2034
|
+
createConnStateTimeoutMs?: number;
|
|
2035
|
+
onBeforeConnectTimeoutMs?: number;
|
|
2036
|
+
onConnectTimeoutMs?: number;
|
|
2037
|
+
onMigrateTimeoutMs?: number;
|
|
2038
|
+
onWakeTimeoutMs?: number;
|
|
2039
|
+
onBeforeActorStartTimeoutMs?: number;
|
|
2040
|
+
actionTimeoutMs?: number;
|
|
2041
|
+
onRequestTimeoutMs?: number;
|
|
2042
|
+
sleepTimeoutMs?: number;
|
|
2043
|
+
noSleep?: boolean;
|
|
2044
|
+
sleepGracePeriodMs?: number;
|
|
2045
|
+
connectionLivenessTimeoutMs?: number;
|
|
2046
|
+
connectionLivenessIntervalMs?: number;
|
|
2047
|
+
maxQueueSize?: number;
|
|
2048
|
+
maxSchedules?: number;
|
|
2049
|
+
maxQueueMessageSize?: number;
|
|
2050
|
+
maxIncomingMessageSize?: number;
|
|
2051
|
+
maxOutgoingMessageSize?: number;
|
|
2052
|
+
preloadMaxWorkflowBytes?: number;
|
|
2053
|
+
preloadMaxConnectionsBytes?: number;
|
|
2054
|
+
actions?: Array<{
|
|
2055
|
+
name: string;
|
|
2056
|
+
}>;
|
|
2057
|
+
inspectorTabs?: Array<RuntimeInspectorTabEntry>;
|
|
2058
|
+
}
|
|
2059
|
+
interface RuntimeInspectorTabEntry {
|
|
2060
|
+
id: string;
|
|
2061
|
+
/** Required for custom entries; omitted for built-in hides. */
|
|
2062
|
+
label?: string;
|
|
2063
|
+
/**
|
|
2064
|
+
* Required for custom entries — absolute path to the source directory.
|
|
2065
|
+
* Resolved on the TS side before being handed to the runtime.
|
|
2066
|
+
*/
|
|
2067
|
+
source?: string;
|
|
2068
|
+
/** Optional icon id for custom entries. */
|
|
2069
|
+
icon?: string;
|
|
2070
|
+
/** Set to true for built-in hide entries. */
|
|
2071
|
+
hidden?: boolean;
|
|
2072
|
+
}
|
|
2073
|
+
interface RuntimeServeConfig {
|
|
2074
|
+
version: number;
|
|
2075
|
+
endpoint: string;
|
|
2076
|
+
token?: string;
|
|
2077
|
+
namespace: string;
|
|
2078
|
+
poolName: string;
|
|
2079
|
+
engineBinaryPath?: string;
|
|
2080
|
+
startServices?: boolean;
|
|
2081
|
+
servicesBinaryPath?: string;
|
|
2082
|
+
engineHost?: string;
|
|
2083
|
+
enginePort?: number;
|
|
2084
|
+
handleInspectorHttpInRuntime?: boolean;
|
|
2085
|
+
inspectorTestToken?: string;
|
|
2086
|
+
serverlessBasePath?: string;
|
|
2087
|
+
serverlessPackageVersion: string;
|
|
2088
|
+
serverlessClientEndpoint?: string;
|
|
2089
|
+
serverlessClientNamespace?: string;
|
|
2090
|
+
serverlessClientToken?: string;
|
|
2091
|
+
serverlessValidateEndpoint: boolean;
|
|
2092
|
+
serverlessMaxStartPayloadBytes: number;
|
|
2093
|
+
}
|
|
2094
|
+
interface RuntimeListenerConfig {
|
|
2095
|
+
port: number;
|
|
2096
|
+
host?: string;
|
|
2097
|
+
publicDir?: string;
|
|
2098
|
+
application?: RuntimeApplicationFetch;
|
|
2099
|
+
}
|
|
2100
|
+
interface RuntimeServerlessRequest {
|
|
2101
|
+
method: string;
|
|
2102
|
+
url: string;
|
|
2103
|
+
headers: Record<string, string>;
|
|
2104
|
+
body: RuntimeBytes;
|
|
2105
|
+
}
|
|
2106
|
+
interface RuntimeApplicationRequest extends RuntimeServerlessRequest {
|
|
2107
|
+
cancelToken?: CancellationTokenHandle;
|
|
2108
|
+
}
|
|
2109
|
+
interface RuntimeApplicationResponse {
|
|
2110
|
+
status: number;
|
|
2111
|
+
headers: Record<string, string>;
|
|
2112
|
+
body?: RuntimeBytes;
|
|
2113
|
+
stream?: boolean;
|
|
2114
|
+
}
|
|
2115
|
+
type RuntimeApplicationFetch = (request: RuntimeApplicationRequest, responseBodyStream?: RuntimeHttpResponseBodyStream) => Promise<RuntimeApplicationResponse>;
|
|
2116
|
+
interface RuntimeApplicationListenerConfig extends RuntimeListenerConfig {
|
|
2117
|
+
application: RuntimeApplicationFetch;
|
|
2118
|
+
}
|
|
2119
|
+
interface RuntimeServerlessResponseHead {
|
|
2120
|
+
status: number;
|
|
2121
|
+
headers: Record<string, string>;
|
|
2122
|
+
}
|
|
2123
|
+
interface RuntimeRegistryRouteResponse {
|
|
2124
|
+
status: number;
|
|
2125
|
+
headers: Record<string, string>;
|
|
2126
|
+
body: RuntimeBytes;
|
|
2127
|
+
}
|
|
2128
|
+
type RuntimeServerlessStreamEvent = {
|
|
2129
|
+
kind: "chunk";
|
|
2130
|
+
chunk?: RuntimeBytes;
|
|
2131
|
+
} | {
|
|
2132
|
+
kind: "end";
|
|
2133
|
+
error?: {
|
|
2134
|
+
group: string;
|
|
2135
|
+
code: string;
|
|
2136
|
+
message: string;
|
|
2137
|
+
};
|
|
2138
|
+
};
|
|
2139
|
+
type RuntimeServerlessStreamCallback = (error: unknown, event?: RuntimeServerlessStreamEvent) => unknown;
|
|
2140
|
+
type RuntimeWebSocketEvent = {
|
|
2141
|
+
kind: "message";
|
|
2142
|
+
data: string | RuntimeBytes;
|
|
2143
|
+
binary: boolean;
|
|
2144
|
+
messageIndex?: number;
|
|
2145
|
+
} | {
|
|
2146
|
+
kind: "close";
|
|
2147
|
+
code: number;
|
|
2148
|
+
reason: string;
|
|
2149
|
+
wasClean: boolean;
|
|
2150
|
+
};
|
|
2151
|
+
interface CoreRuntime {
|
|
2152
|
+
readonly kind: "napi" | "wasm";
|
|
2153
|
+
createRegistry(): RegistryHandle;
|
|
2154
|
+
registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
|
|
2155
|
+
serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
|
|
2156
|
+
waitRegistryReady(registry: RegistryHandle): Promise<void>;
|
|
2157
|
+
shutdownRegistry(registry: RegistryHandle): Promise<void>;
|
|
2158
|
+
registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
|
|
2159
|
+
handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
|
|
2160
|
+
serveListener(registry: RegistryHandle, listener: RuntimeListenerConfig, config: RuntimeServeConfig): Promise<void>;
|
|
2161
|
+
serveApplicationListener(registry: RegistryHandle, listener: RuntimeApplicationListenerConfig, config: RuntimeServeConfig): Promise<void>;
|
|
2162
|
+
registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
2163
|
+
registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
2164
|
+
registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
2165
|
+
createActorFactory(callbacks: object, config?: RuntimeActorConfig | undefined | null): ActorFactoryHandle;
|
|
2166
|
+
createCancellationToken(): CancellationTokenHandle;
|
|
2167
|
+
cancellationTokenAborted(token: CancellationTokenHandle): boolean;
|
|
2168
|
+
cancelCancellationToken(token: CancellationTokenHandle): void;
|
|
2169
|
+
onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): void;
|
|
2170
|
+
actorState(ctx: ActorContextHandle): RuntimeBytes;
|
|
2171
|
+
actorBeginOnStateChange(ctx: ActorContextHandle): void;
|
|
2172
|
+
actorEndOnStateChange(ctx: ActorContextHandle): void;
|
|
2173
|
+
actorSetAlarm(ctx: ActorContextHandle, timestampMs?: number | undefined | null): void;
|
|
2174
|
+
actorSetRunWakeAt(ctx: ActorContextHandle, timestampMs?: number | undefined | null): Promise<void>;
|
|
2175
|
+
actorRequestSave(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): void;
|
|
2176
|
+
actorRequestSaveAndWait(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): Promise<void>;
|
|
2177
|
+
actorInspectorSnapshot(ctx: ActorContextHandle): RuntimeInspectorSnapshot;
|
|
2178
|
+
actorDecodeInspectorRequest(ctx: ActorContextHandle, bytes: RuntimeBytes, advertisedVersion: number): RuntimeBytes;
|
|
2179
|
+
actorEncodeInspectorResponse(ctx: ActorContextHandle, bytes: RuntimeBytes, targetVersion: number): RuntimeBytes;
|
|
2180
|
+
actorVerifyInspectorAuth(ctx: ActorContextHandle, bearerToken?: string | undefined | null): Promise<void>;
|
|
2181
|
+
actorQueueHibernationRemoval(ctx: ActorContextHandle, connId: string): void;
|
|
2182
|
+
actorTakePendingHibernationChanges(ctx: ActorContextHandle): string[];
|
|
2183
|
+
actorDirtyHibernatableConns(ctx: ActorContextHandle): ConnHandle[];
|
|
2184
|
+
actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
2185
|
+
actorSaveStateAndWorkflowBatch(ctx: ActorContextHandle, writes: RuntimeWorkflowKvWrite[]): Promise<void>;
|
|
2186
|
+
actorId(ctx: ActorContextHandle): string;
|
|
2187
|
+
actorName(ctx: ActorContextHandle): string;
|
|
2188
|
+
actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
|
|
2189
|
+
actorRegion(ctx: ActorContextHandle): string;
|
|
2190
|
+
actorSleep(ctx: ActorContextHandle): void;
|
|
2191
|
+
actorDestroy(ctx: ActorContextHandle): void;
|
|
2192
|
+
actorAbortSignal(ctx: ActorContextHandle): AbortSignal;
|
|
2193
|
+
actorConns(ctx: ActorContextHandle): ConnHandle[];
|
|
2194
|
+
actorConnectConn(ctx: ActorContextHandle, params: RuntimeBytes, request?: RuntimeHttpRequest | undefined | null): Promise<ConnHandle>;
|
|
2195
|
+
actorBroadcast(ctx: ActorContextHandle, name: string, args: RuntimeBytes): void;
|
|
2196
|
+
actorWaitUntil(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
2197
|
+
actorWaitForTrackedShutdownWork(ctx: ActorContextHandle): Promise<boolean>;
|
|
2198
|
+
actorWaitForTrackedShutdownWorkUnbounded(ctx: ActorContextHandle): Promise<void>;
|
|
2199
|
+
actorKeepAwake(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
2200
|
+
actorBeginKeepAwake(ctx: ActorContextHandle): number;
|
|
2201
|
+
actorEndKeepAwake(ctx: ActorContextHandle, regionId: number): void;
|
|
2202
|
+
actorRegisterTask(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
2203
|
+
actorRuntimeState(ctx: ActorContextHandle): object;
|
|
2204
|
+
actorClearRuntimeState(ctx: ActorContextHandle): void;
|
|
2205
|
+
actorRestartRunHandler(ctx: ActorContextHandle): void;
|
|
2206
|
+
actorBeginWebsocketCallback(ctx: ActorContextHandle): number;
|
|
2207
|
+
actorEndWebsocketCallback(ctx: ActorContextHandle, regionId: number): void;
|
|
2208
|
+
actorKvGet(ctx: ActorContextHandle, key: RuntimeBytes): Promise<RuntimeBytes | null>;
|
|
2209
|
+
actorKvPut(ctx: ActorContextHandle, key: RuntimeBytes, value: RuntimeBytes): Promise<void>;
|
|
2210
|
+
actorKvDelete(ctx: ActorContextHandle, key: RuntimeBytes): Promise<void>;
|
|
2211
|
+
actorKvDeleteRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes): Promise<void>;
|
|
2212
|
+
actorKvListPrefix(ctx: ActorContextHandle, prefix: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
|
|
2213
|
+
actorKvListRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
|
|
2214
|
+
actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
|
|
2215
|
+
actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
|
|
2216
|
+
actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
|
|
2217
|
+
actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
2218
|
+
actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
2219
|
+
actorSqlExecuteBatch(ctx: ActorContextHandle, statements: RuntimeSqlBatchStatement[]): Promise<RuntimeSqlExecuteResult[]>;
|
|
2220
|
+
actorSqlBeginTransaction(ctx: ActorContextHandle, timeoutMs?: number, name?: string): Promise<SqliteTransactionHandle>;
|
|
2221
|
+
actorSqlTransactionExec(transaction: SqliteTransactionHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
2222
|
+
actorSqlTransactionExecute(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
2223
|
+
actorSqlTransactionCommit(transaction: SqliteTransactionHandle): Promise<void>;
|
|
2224
|
+
actorSqlTransactionRollback(transaction: SqliteTransactionHandle): Promise<void>;
|
|
2225
|
+
actorBeginStateTransaction(ctx: ActorContextHandle, timeoutMs?: number): Promise<ActorStateTransactionHandle>;
|
|
2226
|
+
actorStateTransactionExecute(transaction: ActorStateTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
2227
|
+
actorStateTransactionCommit(transaction: ActorStateTransactionHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
2228
|
+
actorStateTransactionRollback(transaction: ActorStateTransactionHandle): Promise<void>;
|
|
2229
|
+
actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
|
|
2230
|
+
actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
|
|
2231
|
+
actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
|
|
2232
|
+
actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
|
|
2233
|
+
actorSqlClose(ctx: ActorContextHandle): Promise<void>;
|
|
2234
|
+
actorRuntimeSocketProvision(ctx: ActorContextHandle): Promise<RuntimeActorRuntimeSocketEndpointInfo>;
|
|
2235
|
+
actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
|
|
2236
|
+
actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
|
|
2237
|
+
actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
|
|
2238
|
+
actorQueueWaitForNamesAvailable(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<void>;
|
|
2239
|
+
actorQueueCompletePersisted(ctx: ActorContextHandle, messageId: bigint, expectedName: string, response?: RuntimeBytes | undefined | null): Promise<boolean>;
|
|
2240
|
+
actorQueueEnqueueAndWait(ctx: ActorContextHandle, name: string, body: RuntimeBytes, options?: RuntimeQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeBytes | null>;
|
|
2241
|
+
actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
|
|
2242
|
+
actorQueueMaxSize(ctx: ActorContextHandle): number;
|
|
2243
|
+
actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
|
|
2244
|
+
actorQueueReset(ctx: ActorContextHandle): Promise<void>;
|
|
2245
|
+
actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
|
|
2246
|
+
actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
|
|
2247
|
+
actorScheduleCancel(ctx: ActorContextHandle, id: string): Promise<boolean>;
|
|
2248
|
+
actorScheduleGet(ctx: ActorContextHandle, id: string): Promise<RuntimeScheduledEventInfo | undefined>;
|
|
2249
|
+
actorScheduleList(ctx: ActorContextHandle): Promise<RuntimeScheduledEventInfo[]>;
|
|
2250
|
+
actorCronSet(ctx: ActorContextHandle, name: string, expression: string, timezone: string | undefined, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
|
|
2251
|
+
actorCronEvery(ctx: ActorContextHandle, name: string, intervalMs: number, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
|
|
2252
|
+
actorCronGet(ctx: ActorContextHandle, name: string): Promise<RuntimeCronJobInfo | undefined>;
|
|
2253
|
+
actorCronList(ctx: ActorContextHandle): Promise<RuntimeCronJobInfo[]>;
|
|
2254
|
+
actorCronDelete(ctx: ActorContextHandle, name: string): Promise<boolean>;
|
|
2255
|
+
actorCronHistory(ctx: ActorContextHandle, name: string, limit: number | undefined): Promise<RuntimeCronFire[]>;
|
|
2256
|
+
connId(conn: ConnHandle): string;
|
|
2257
|
+
connParams(conn: ConnHandle): RuntimeBytes;
|
|
2258
|
+
connState(conn: ConnHandle): RuntimeBytes;
|
|
2259
|
+
connSetState(conn: ConnHandle, state: RuntimeBytes): void;
|
|
2260
|
+
connIsHibernatable(conn: ConnHandle): boolean;
|
|
2261
|
+
connSend(conn: ConnHandle, name: string, args: RuntimeBytes): void;
|
|
2262
|
+
connDisconnect(conn: ConnHandle, reason?: string | undefined | null): Promise<void>;
|
|
2263
|
+
webSocketSend(ws: WebSocketHandle, data: RuntimeBytes, binary: boolean): void;
|
|
2264
|
+
webSocketClose(ws: WebSocketHandle, code?: number | undefined | null, reason?: string | undefined | null): Promise<void>;
|
|
2265
|
+
webSocketSetEventCallback(ws: WebSocketHandle, callback: (event: RuntimeWebSocketEvent) => void): void;
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
declare function buildConfiguredRegistry(config: RegistryConfig): Promise<{
|
|
2269
|
+
runtime: CoreRuntime;
|
|
2270
|
+
registry: RegistryHandle;
|
|
2271
|
+
serveConfig: RuntimeServeConfig;
|
|
2272
|
+
}>;
|
|
2273
|
+
|
|
1605
2274
|
type FetchHandler = (request: Request, ...args: any) => Response | Promise<Response>;
|
|
1606
2275
|
interface ServerlessHandler {
|
|
1607
2276
|
fetch: FetchHandler;
|
|
1608
2277
|
}
|
|
1609
|
-
interface
|
|
1610
|
-
|
|
1611
|
-
|
|
2278
|
+
interface RegistryApplication {
|
|
2279
|
+
fetch: FetchHandler;
|
|
2280
|
+
}
|
|
2281
|
+
interface RegistryListenOptions {
|
|
2282
|
+
port?: number;
|
|
2283
|
+
host?: string;
|
|
2284
|
+
publicDir?: string;
|
|
2285
|
+
application?: RegistryApplication;
|
|
2286
|
+
}
|
|
2287
|
+
interface RegistryRoutes {
|
|
2288
|
+
health(): Promise<Response>;
|
|
2289
|
+
metadata(): Promise<Response>;
|
|
2290
|
+
prometheusMetrics(request?: Request): Promise<Response>;
|
|
2291
|
+
}
|
|
2292
|
+
/**
|
|
2293
|
+
* Injectable dependencies for {@link Registry}. Production code uses the
|
|
2294
|
+
* defaults. Tests override `buildConfiguredRegistry` to drive lifecycle
|
|
2295
|
+
* orchestration against a fake `CoreRuntime` without an engine.
|
|
2296
|
+
*/
|
|
2297
|
+
interface RegistryDeps {
|
|
2298
|
+
buildConfiguredRegistry: typeof buildConfiguredRegistry;
|
|
1612
2299
|
}
|
|
1613
2300
|
declare class Registry<A extends RegistryActors> {
|
|
1614
2301
|
#private;
|
|
2302
|
+
readonly routes: RegistryRoutes;
|
|
1615
2303
|
get config(): RegistryConfigInput<A>;
|
|
1616
2304
|
parseConfig(): RegistryConfig;
|
|
1617
|
-
constructor(config: RegistryConfigInput<A>);
|
|
2305
|
+
constructor(config: RegistryConfigInput<A>, deps?: Partial<RegistryDeps>);
|
|
1618
2306
|
/**
|
|
1619
2307
|
* Handle an incoming HTTP request for serverless deployments.
|
|
1620
2308
|
*
|
|
@@ -1635,11 +2323,64 @@ declare class Registry<A extends RegistryActors> {
|
|
|
1635
2323
|
* ```
|
|
1636
2324
|
*/
|
|
1637
2325
|
serve(): ServerlessHandler;
|
|
1638
|
-
|
|
2326
|
+
/**
|
|
2327
|
+
* Bind an HTTP listener provided by the native (Rust) runtime and serve
|
|
2328
|
+
* the registry's serverless endpoints over it. Resolves only after the
|
|
2329
|
+
* registry is shut down (SIGINT/SIGTERM or `nativeRegistry.shutdown()`).
|
|
2330
|
+
*
|
|
2331
|
+
* @param opts.port Port to listen on. Defaults to `process.env.RIVET_PORT`
|
|
2332
|
+
* if set, otherwise 3000.
|
|
2333
|
+
* @param opts.host Address to bind. Defaults to `0.0.0.0`.
|
|
2334
|
+
* @param opts.publicDir If set, serves static files from this directory
|
|
2335
|
+
* as a fallback below the framework routes.
|
|
2336
|
+
* @param opts.application If set, handles requests that do not match a
|
|
2337
|
+
* framework route.
|
|
2338
|
+
*
|
|
2339
|
+
* @example
|
|
2340
|
+
* ```ts
|
|
2341
|
+
* await registry.listen();
|
|
2342
|
+
* await registry.listen({ application: app });
|
|
2343
|
+
* ```
|
|
2344
|
+
*/
|
|
2345
|
+
listen(opts?: RegistryListenOptions): Promise<void>;
|
|
2346
|
+
/**
|
|
2347
|
+
* Gracefully drains all live registries.
|
|
2348
|
+
*
|
|
2349
|
+
* Programmatic counterpart to the SIGINT/SIGTERM handlers: tears down
|
|
2350
|
+
* every live `CoreRegistry` (both `start()` and `handler()` modes) and
|
|
2351
|
+
* waits for the serve promise to resolve, all bounded by the shutdown
|
|
2352
|
+
* grace period. Unlike a signal-driven shutdown, this does not re-raise a
|
|
2353
|
+
* signal or exit the process. The caller owns process lifetime.
|
|
2354
|
+
*
|
|
2355
|
+
* Idempotent: concurrent or repeated calls share a single drain. Safe to
|
|
2356
|
+
* call even if nothing has been started.
|
|
2357
|
+
*
|
|
2358
|
+
* @example
|
|
2359
|
+
* ```ts
|
|
2360
|
+
* const registry = setup({ use: { counter } });
|
|
2361
|
+
* registry.start();
|
|
2362
|
+
* // ...later, on your own shutdown trigger:
|
|
2363
|
+
* await registry.shutdown();
|
|
2364
|
+
* ```
|
|
2365
|
+
*/
|
|
2366
|
+
shutdown(): Promise<void>;
|
|
1639
2367
|
startEnvoy(): void;
|
|
2368
|
+
/**
|
|
2369
|
+
* Starts the serverful registry if needed and waits until its envoy has
|
|
2370
|
+
* registered with the Engine. Repeated and concurrent calls share one
|
|
2371
|
+
* startup lifecycle and readiness promise.
|
|
2372
|
+
*
|
|
2373
|
+
* Unlike {@link start}, this reports startup failures and does not resolve
|
|
2374
|
+
* merely because an HTTP health endpoint is listening.
|
|
2375
|
+
*/
|
|
2376
|
+
startAndWait(): Promise<void>;
|
|
1640
2377
|
/**
|
|
1641
2378
|
* Starts the actor envoy for standalone server deployments.
|
|
1642
2379
|
*
|
|
2380
|
+
* Set `RIVETKIT_RUNTIME_MODE=serverless` to instead bind an HTTP listener
|
|
2381
|
+
* via `listen()` (Mode B). Mode A (envoy) and Mode B (listener) are
|
|
2382
|
+
* mutually exclusive per registry instance.
|
|
2383
|
+
*
|
|
1643
2384
|
* @example
|
|
1644
2385
|
* ```ts
|
|
1645
2386
|
* const registry = setup({ use: { counter } });
|