rivetkit 0.0.0-feat-workflows-public-host-apis.1550fe4 → 0.0.0-feat-sqlite-sync.18dce02
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 +1982 -1691
- package/dist/browser/client.js +676 -164
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +5 -1
- package/dist/browser/inspector/client.js +9 -3
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +6 -2
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +5 -1
- package/dist/tsup/agent-os/index.cjs +170 -94
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +295 -25
- package/dist/tsup/agent-os/index.d.ts +295 -25
- package/dist/tsup/agent-os/index.js +170 -94
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-UI3KTGX2.js → chunk-3E3LWFAZ.js} +20 -8
- package/dist/tsup/chunk-3E3LWFAZ.js.map +1 -0
- package/dist/tsup/{chunk-WYIY6NLQ.js → chunk-52HQXSMQ.js} +4 -4
- package/dist/tsup/chunk-52HQXSMQ.js.map +1 -0
- package/dist/tsup/{chunk-IL57RG2I.cjs → chunk-5OLUEVR4.cjs} +826 -323
- package/dist/tsup/chunk-5OLUEVR4.cjs.map +1 -0
- package/dist/tsup/{chunk-CBAYYACD.js → chunk-6FEYCVZC.js} +37 -5
- package/dist/tsup/chunk-6FEYCVZC.js.map +1 -0
- package/dist/tsup/{chunk-PZ4JOJEN.cjs → chunk-7V7XONO4.cjs} +7 -7
- package/dist/tsup/chunk-7V7XONO4.cjs.map +1 -0
- package/dist/tsup/{chunk-CLN6C2OJ.js → chunk-7VZRBST6.js} +5 -3
- package/dist/tsup/{chunk-CLN6C2OJ.js.map → chunk-7VZRBST6.js.map} +1 -1
- package/dist/tsup/chunk-AT6KBTSZ.js +243 -0
- package/dist/tsup/chunk-AT6KBTSZ.js.map +1 -0
- package/dist/tsup/{chunk-YCSFVPRX.cjs → chunk-C6DFTFDH.cjs} +27 -15
- package/dist/tsup/chunk-C6DFTFDH.cjs.map +1 -0
- package/dist/tsup/{chunk-6REVLVUF.cjs → chunk-CH2DXUSV.cjs} +3 -3
- package/dist/tsup/chunk-CH2DXUSV.cjs.map +1 -0
- package/dist/tsup/{chunk-SUJ42TGT.js → chunk-CW3RLSJO.js} +673 -170
- package/dist/tsup/chunk-CW3RLSJO.js.map +1 -0
- package/dist/tsup/{chunk-YAXFZTGV.cjs → chunk-HDVZ6YZG.cjs} +38 -6
- package/dist/tsup/chunk-HDVZ6YZG.cjs.map +1 -0
- package/dist/tsup/{chunk-WT3O5SZH.cjs → chunk-I2SMBJA5.cjs} +10 -10
- package/dist/tsup/chunk-I2SMBJA5.cjs.map +1 -0
- package/dist/tsup/{chunk-7AFZMFPQ.js → chunk-JTHHCZCZ.js} +10 -1
- package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
- package/dist/tsup/{chunk-UEULFXUI.cjs → chunk-KVFIONKQ.cjs} +11 -2
- package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
- package/dist/tsup/{chunk-3FTIAFTA.js → chunk-M334VZYU.js} +3 -3
- package/dist/tsup/chunk-M334VZYU.js.map +1 -0
- package/dist/tsup/{chunk-SPWPOCJD.js → chunk-M4DBJOKU.js} +2 -2
- package/dist/tsup/chunk-M4DBJOKU.js.map +1 -0
- package/dist/tsup/{chunk-4FC7TVS6.cjs → chunk-MGI2VVF6.cjs} +39 -7
- package/dist/tsup/chunk-MGI2VVF6.cjs.map +1 -0
- package/dist/tsup/chunk-MYWZCDML.cjs.map +1 -1
- package/dist/tsup/{chunk-BF2LUZFK.js → chunk-OHSZYIQ2.js} +2 -2
- package/dist/tsup/chunk-S2WGWO6T.cjs +243 -0
- package/dist/tsup/chunk-S2WGWO6T.cjs.map +1 -0
- package/dist/tsup/{chunk-FGLJEDYG.cjs → chunk-SMZVRN4A.cjs} +6 -4
- package/dist/tsup/chunk-SMZVRN4A.cjs.map +1 -0
- package/dist/tsup/{chunk-2BIGFLEO.cjs → chunk-Y65LBKWK.cjs} +3 -3
- package/dist/tsup/chunk-Y65LBKWK.cjs.map +1 -0
- package/dist/tsup/{chunk-ZZ3WBRPD.js → chunk-ZOVJDAOW.js} +38 -6
- package/dist/tsup/chunk-ZOVJDAOW.js.map +1 -0
- package/dist/tsup/client/mod.cjs +7 -7
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +19 -7
- package/dist/tsup/client/mod.d.ts +19 -7
- package/dist/tsup/client/mod.js +6 -6
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.js +2 -2
- 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-CNCQeJ9f.d.cts → config-BaUctMNL.d.cts} +71 -13
- package/dist/tsup/{config-CNCQeJ9f.d.ts → config-BaUctMNL.d.ts} +71 -13
- package/dist/tsup/{config-G-iBi0Xi.d.cts → config-D6T6Ud_V.d.cts} +233 -22
- package/dist/tsup/{config-BAab5w6E.d.ts → config-DfVrAigH.d.ts} +233 -22
- package/dist/tsup/{context-C0MgmUax.d.ts → context-BsFWwi3i.d.ts} +2 -2
- package/dist/tsup/{context-DUwKqttW.d.cts → context-CowF_zyQ.d.cts} +2 -2
- package/dist/tsup/db/drizzle.cjs +19 -11
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +5 -6
- package/dist/tsup/db/drizzle.d.ts +5 -6
- package/dist/tsup/db/drizzle.js +14 -6
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +5 -5
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.d.cts +11 -4
- package/dist/tsup/db/mod.d.ts +11 -4
- package/dist/tsup/db/mod.js +4 -4
- package/dist/tsup/dynamic/mod.cjs +2 -2
- package/dist/tsup/dynamic/mod.cjs.map +1 -1
- package/dist/tsup/dynamic/mod.d.cts +5 -4
- package/dist/tsup/dynamic/mod.d.ts +5 -4
- package/dist/tsup/dynamic/mod.js +1 -1
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +2 -2
- package/dist/tsup/inspector/mod.d.ts +2 -2
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/inspector/workflow.cjs +5 -5
- package/dist/tsup/inspector/workflow.cjs.map +1 -1
- package/dist/tsup/inspector/workflow.d.cts +9 -5
- package/dist/tsup/inspector/workflow.d.ts +9 -5
- package/dist/tsup/inspector/workflow.js +4 -4
- package/dist/tsup/inspector-tab/mod.cjs +2 -2
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -1
- package/dist/tsup/inspector-tab/mod.d.cts +6 -5
- package/dist/tsup/inspector-tab/mod.d.ts +6 -5
- package/dist/tsup/inspector-tab/mod.js +1 -1
- package/dist/tsup/mod.cjs +1521 -556
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +7 -6
- package/dist/tsup/mod.d.ts +7 -6
- package/dist/tsup/mod.js +1413 -448
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +8 -8
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +5 -4
- package/dist/tsup/test/mod.d.ts +5 -4
- package/dist/tsup/test/mod.js +6 -6
- package/dist/tsup/unstable/migrations.cjs.map +1 -1
- package/dist/tsup/unstable/migrations.d.cts +1 -1
- package/dist/tsup/unstable/migrations.d.ts +1 -1
- package/dist/tsup/{utils-CqDnC_PS.d.cts → utils-3rsE0JvI.d.cts} +25 -2
- package/dist/tsup/{utils-CqDnC_PS.d.ts → utils-3rsE0JvI.d.ts} +25 -2
- package/dist/tsup/{utils-CV0akuDD.d.ts → utils-C1O-SklO.d.ts} +1 -1
- package/dist/tsup/{utils-DQDCphrl.d.cts → utils-C6b0aYUM.d.cts} +1 -1
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +2 -2
- package/dist/tsup/utils.d.ts +2 -2
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +42 -26
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +7 -6
- package/dist/tsup/workflow/mod.d.ts +7 -6
- package/dist/tsup/workflow/mod.js +34 -18
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +14 -10
- package/src/actor/actions.ts +36 -0
- package/src/actor/config.ts +78 -7
- package/src/actor/definition.ts +6 -1
- package/src/actor/errors.ts +87 -5
- package/src/actor/mod.ts +7 -2
- package/src/actor/tracing.ts +28 -0
- package/src/client/actor-conn.ts +46 -5
- package/src/client/actor-handle.ts +158 -40
- package/src/client/actor-query.ts +8 -1
- package/src/client/auth.ts +37 -0
- package/src/client/client.ts +42 -8
- package/src/client/config.ts +15 -1
- package/src/client/errors.ts +2 -1
- package/src/client/mod.ts +9 -0
- package/src/client/outbound-telemetry.ts +66 -0
- package/src/client/queue.ts +3 -0
- package/src/client/raw-utils.ts +35 -7
- package/src/client/token-provider.test.ts +86 -0
- package/src/client/token-provider.ts +93 -0
- package/src/client/utils.ts +3 -0
- package/src/common/actor-router-consts.ts +5 -0
- package/src/common/actor-telemetry-context.ts +19 -0
- package/src/common/database/config.ts +88 -12
- package/src/common/database/mod.test.ts +49 -10
- package/src/common/database/mod.ts +190 -123
- package/src/common/database/native-database.test.ts +21 -0
- package/src/common/database/native-database.ts +247 -26
- package/src/common/database/shared.ts +9 -0
- package/src/common/fetch-like.ts +14 -0
- package/src/common/inspector-transport.ts +12 -2
- package/src/common/otel-context.ts +99 -0
- package/src/common/utils.ts +7 -19
- package/src/db/drizzle.test.ts +8 -1
- package/src/db/drizzle.ts +15 -4
- package/src/db/mod.ts +2 -0
- package/src/engine-client/actor-http-client.ts +29 -20
- package/src/engine-client/actor-websocket-client.ts +2 -1
- package/src/engine-client/api-endpoints.ts +28 -0
- package/src/engine-client/driver.ts +4 -0
- package/src/engine-client/mod.ts +239 -71
- package/src/inspector/workflow.ts +7 -3
- package/src/registry/config/envoy.ts +1 -17
- package/src/registry/config/index.test.ts +25 -0
- package/src/registry/config/index.ts +33 -2
- package/src/registry/index.ts +82 -14
- package/src/registry/napi-runtime.ts +268 -50
- package/src/registry/native-http.ts +225 -0
- package/src/registry/native.ts +824 -325
- package/src/registry/run-handler-coordinator.test.ts +24 -4
- package/src/registry/run-handler-coordinator.ts +15 -10
- package/src/registry/runtime.test.ts +74 -0
- package/src/registry/runtime.ts +164 -8
- package/src/registry/wasm-runtime.ts +167 -31
- package/src/registry/write-through-proxy.ts +101 -0
- package/src/utils/env-vars.ts +4 -0
- package/src/utils/node.ts +44 -23
- package/src/workflow/driver.ts +32 -11
- package/src/workflow/inspector.ts +10 -8
- package/dist/tsup/chunk-2BIGFLEO.cjs.map +0 -1
- package/dist/tsup/chunk-3FTIAFTA.js.map +0 -1
- package/dist/tsup/chunk-4FC7TVS6.cjs.map +0 -1
- package/dist/tsup/chunk-6REVLVUF.cjs.map +0 -1
- package/dist/tsup/chunk-7AFZMFPQ.js.map +0 -1
- package/dist/tsup/chunk-CBAYYACD.js.map +0 -1
- package/dist/tsup/chunk-FGLJEDYG.cjs.map +0 -1
- package/dist/tsup/chunk-IL57RG2I.cjs.map +0 -1
- package/dist/tsup/chunk-KENM7UCH.cjs +0 -207
- package/dist/tsup/chunk-KENM7UCH.cjs.map +0 -1
- package/dist/tsup/chunk-PZ4JOJEN.cjs.map +0 -1
- package/dist/tsup/chunk-SPWPOCJD.js.map +0 -1
- package/dist/tsup/chunk-SUJ42TGT.js.map +0 -1
- package/dist/tsup/chunk-UEULFXUI.cjs.map +0 -1
- package/dist/tsup/chunk-UI3KTGX2.js.map +0 -1
- package/dist/tsup/chunk-WFNDJRB7.js +0 -207
- package/dist/tsup/chunk-WFNDJRB7.js.map +0 -1
- package/dist/tsup/chunk-WT3O5SZH.cjs.map +0 -1
- package/dist/tsup/chunk-WYIY6NLQ.js.map +0 -1
- package/dist/tsup/chunk-YAXFZTGV.cjs.map +0 -1
- package/dist/tsup/chunk-YCSFVPRX.cjs.map +0 -1
- package/dist/tsup/chunk-ZZ3WBRPD.js.map +0 -1
- package/src/registry/process-metrics.ts +0 -250
- /package/dist/tsup/{chunk-BF2LUZFK.js.map → chunk-OHSZYIQ2.js.map} +0 -0
package/dist/browser/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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 { Rivet } from '@rivetkit/engine-api-full';
|
|
4
5
|
import { Context, Handler, Hono } from 'hono';
|
|
5
6
|
import { UniversalWebSocket } from '@rivetkit/virtual-websocket';
|
|
6
7
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
@@ -27,6 +28,41 @@ interface SqliteBatchStatement {
|
|
|
27
28
|
sql: string;
|
|
28
29
|
params?: SqliteBindings;
|
|
29
30
|
}
|
|
31
|
+
interface SqliteTransactionOptions {
|
|
32
|
+
/** Static operation name used to aggregate transaction performance. */
|
|
33
|
+
name?: string;
|
|
34
|
+
/** Deadlock-safety timeout in milliseconds. */
|
|
35
|
+
timeout?: number;
|
|
36
|
+
/** @experimental */
|
|
37
|
+
experimental?: {
|
|
38
|
+
/**
|
|
39
|
+
* Atomically includes actor and hibernatable connection state.
|
|
40
|
+
* Only single-statement `execute` calls are supported in the transaction.
|
|
41
|
+
* Concurrent actions that try to mutate state while the transaction is
|
|
42
|
+
* active fail with `actor.state_transaction_conflict`.
|
|
43
|
+
*/
|
|
44
|
+
includeState?: boolean;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* SQLite profiling configuration.
|
|
49
|
+
*
|
|
50
|
+
* @experimental This entire configuration surface is experimental and subject
|
|
51
|
+
* to change without notice.
|
|
52
|
+
*/
|
|
53
|
+
interface SqliteProfilingOptions {
|
|
54
|
+
enabled?: boolean;
|
|
55
|
+
maxTrackedStatementFingerprints?: number;
|
|
56
|
+
maxTrackedTransactionFingerprints?: number;
|
|
57
|
+
maxPrometheusSeries?: number;
|
|
58
|
+
maxStatementsPerTransactionTrace?: number;
|
|
59
|
+
maxGetPagesRequestsPerTrace?: number;
|
|
60
|
+
maxTransactionNameBytes?: number;
|
|
61
|
+
slowOperationThresholdMs?: number;
|
|
62
|
+
baselineSampleRate?: number;
|
|
63
|
+
maxDiagnosticEventsPerMinute?: number;
|
|
64
|
+
diagnosticEventQueueCapacity?: number;
|
|
65
|
+
}
|
|
30
66
|
interface SqliteNativeMetrics {
|
|
31
67
|
requestBuildNs: number;
|
|
32
68
|
serializeNs: number;
|
|
@@ -42,20 +78,46 @@ interface SqliteNativeMetrics {
|
|
|
42
78
|
}
|
|
43
79
|
interface SqliteDatabase {
|
|
44
80
|
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
81
|
+
execSync?(sql: string, callback?: (row: unknown[], columns: string[]) => void): void;
|
|
45
82
|
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
83
|
+
executeSync?(sql: string, params?: SqliteBindings): SqliteExecuteResult;
|
|
46
84
|
executeBatch(statements: SqliteBatchStatement[]): Promise<SqliteExecuteResult[]>;
|
|
47
|
-
beginTransaction(timeoutMs?: number): Promise<SqliteTransactionDatabase>;
|
|
85
|
+
beginTransaction(timeoutMs?: number, name?: string): Promise<SqliteTransactionDatabase>;
|
|
86
|
+
beginTransactionSync?(timeoutMs?: number, name?: string): SynchronousSqliteTransactionDatabase;
|
|
48
87
|
run(sql: string, params?: SqliteBindings): Promise<void>;
|
|
49
88
|
query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
|
|
50
89
|
nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the ticket of the latest local commit. Synchronous writes return before they are
|
|
92
|
+
* durable; pass the ticket to `whenDurable` before releasing output that depends on them.
|
|
93
|
+
*/
|
|
94
|
+
commitTicket?(): number;
|
|
95
|
+
/**
|
|
96
|
+
* Resolves once the commit `ticket` names and every earlier commit are durable. Rejects with
|
|
97
|
+
* `sqlite.durability_failed` once the database broke and the actor is restarting.
|
|
98
|
+
*/
|
|
99
|
+
whenDurable?(ticket: number): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Restarts the owning actor from durable state. Every later write fails, including the final
|
|
102
|
+
* state save. For native database providers whose in-memory state can no longer be trusted.
|
|
103
|
+
*/
|
|
104
|
+
abortGeneration?(reason: string): void;
|
|
51
105
|
close(): Promise<void>;
|
|
52
106
|
}
|
|
53
107
|
interface SqliteTransactionDatabase {
|
|
54
108
|
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
109
|
+
execSync?(sql: string, callback?: (row: unknown[], columns: string[]) => void): void;
|
|
55
110
|
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
111
|
+
executeSync?(sql: string, params?: SqliteBindings): SqliteExecuteResult;
|
|
56
112
|
commit(): Promise<void>;
|
|
57
113
|
rollback(): Promise<void>;
|
|
58
114
|
}
|
|
115
|
+
type SynchronousSqliteTransactionDatabase = SqliteTransactionDatabase & {
|
|
116
|
+
execSync(sql: string, callback?: (row: unknown[], columns: string[]) => void): void;
|
|
117
|
+
executeSync(sql: string, params?: SqliteBindings): SqliteExecuteResult;
|
|
118
|
+
commitSync(): void;
|
|
119
|
+
rollbackSync(): void;
|
|
120
|
+
};
|
|
59
121
|
/**
|
|
60
122
|
* Provider for opening native databases from the active runtime.
|
|
61
123
|
*/
|
|
@@ -99,6 +161,13 @@ interface DatabaseProviderContext {
|
|
|
99
161
|
nativeDatabaseProvider?: NativeDatabaseProvider;
|
|
100
162
|
}
|
|
101
163
|
type DatabaseProvider<DB extends RawAccess> = {
|
|
164
|
+
/**
|
|
165
|
+
* Local SQLite profiling controls consumed by the actor runtime.
|
|
166
|
+
*
|
|
167
|
+
* @experimental This entire configuration surface is experimental and
|
|
168
|
+
* subject to change without notice.
|
|
169
|
+
*/
|
|
170
|
+
sqliteProfiling?: SqliteProfilingOptions;
|
|
102
171
|
/**
|
|
103
172
|
* Creates a new database client for the actor.
|
|
104
173
|
* The result is passed to the actor context as `c.db`.
|
|
@@ -123,17 +192,7 @@ type RawAccess = {
|
|
|
123
192
|
*/
|
|
124
193
|
execute: ExecuteFunction;
|
|
125
194
|
/** Runs a callback in an isolated SQLite transaction. */
|
|
126
|
-
transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T, options?:
|
|
127
|
-
timeout?: number;
|
|
128
|
-
/** @experimental */
|
|
129
|
-
experimental?: {
|
|
130
|
-
/**
|
|
131
|
-
* Atomically includes actor and hibernatable connection state.
|
|
132
|
-
* Only single-statement `execute` calls are supported in the transaction.
|
|
133
|
-
*/
|
|
134
|
-
includeState?: boolean;
|
|
135
|
-
};
|
|
136
|
-
}) => Promise<T>;
|
|
195
|
+
transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T, options?: SqliteTransactionOptions) => Promise<T>;
|
|
137
196
|
/**
|
|
138
197
|
* Returns native SQLite metrics when the active runtime supports them.
|
|
139
198
|
*/
|
|
@@ -144,6 +203,26 @@ type RawAccess = {
|
|
|
144
203
|
close: () => Promise<void>;
|
|
145
204
|
};
|
|
146
205
|
|
|
206
|
+
/** A namespace-scoped Engine grant. The caller must provide every grant explicitly. */
|
|
207
|
+
type TokenGrant = Rivet.AuthTokenGrant;
|
|
208
|
+
/** Options for `client.auth.issueToken()`. `expiresIn` is in seconds. */
|
|
209
|
+
type IssueTokenOptions = Pick<Rivet.AuthTokenCreateRequest, "subject" | "grants"> & {
|
|
210
|
+
expiresIn?: Rivet.AuthTokenCreateRequest["duration"];
|
|
211
|
+
};
|
|
212
|
+
/** Token timestamps are Unix milliseconds. */
|
|
213
|
+
interface IssuedToken {
|
|
214
|
+
token: Rivet.AuthTokenCreateResponse["token"];
|
|
215
|
+
issuedAt: Rivet.AuthTokenCreateResponse["issuedTs"];
|
|
216
|
+
expiresAt: Rivet.AuthTokenCreateResponse["expiresTs"];
|
|
217
|
+
}
|
|
218
|
+
/** Resources that can be scoped to a single actor ID. */
|
|
219
|
+
type ActorTokenResource = Extract<Rivet.AuthTokenGrant["resource"], "actor_gateway" | "actor" | "actor_kv">;
|
|
220
|
+
type ActorTokenPermissions = Partial<Record<ActorTokenResource, Rivet.AuthTokenGrant["operations"]>>;
|
|
221
|
+
/** Options for `actor.issueToken()`. Omit permissions for gateway read access only. */
|
|
222
|
+
type ActorIssueTokenOptions = Pick<IssueTokenOptions, "subject" | "expiresIn"> & {
|
|
223
|
+
permissions?: ActorTokenPermissions;
|
|
224
|
+
};
|
|
225
|
+
|
|
147
226
|
declare const EncodingSchema: z.ZodEnum<{
|
|
148
227
|
json: "json";
|
|
149
228
|
cbor: "cbor";
|
|
@@ -254,6 +333,7 @@ interface DeconstructedError {
|
|
|
254
333
|
code: string;
|
|
255
334
|
message: string;
|
|
256
335
|
metadata?: unknown;
|
|
336
|
+
rayId?: string;
|
|
257
337
|
actor?: ActorSpecifier;
|
|
258
338
|
}
|
|
259
339
|
|
|
@@ -262,6 +342,8 @@ interface RivetErrorOptions extends ErrorOptions {
|
|
|
262
342
|
public?: boolean;
|
|
263
343
|
/** Metadata associated with this error. */
|
|
264
344
|
metadata?: unknown;
|
|
345
|
+
/** Request identifier used to correlate this error with engine logs. */
|
|
346
|
+
rayId?: string;
|
|
265
347
|
/** Explicit HTTP status override for router responses. */
|
|
266
348
|
statusCode?: number;
|
|
267
349
|
/** Actor context associated with this error. */
|
|
@@ -289,6 +371,7 @@ declare class RivetError extends Error {
|
|
|
289
371
|
__type: "RivetError";
|
|
290
372
|
public: boolean;
|
|
291
373
|
metadata?: unknown;
|
|
374
|
+
readonly rayId?: string;
|
|
292
375
|
statusCode: number;
|
|
293
376
|
actor?: ActorSpecifier;
|
|
294
377
|
readonly group: string;
|
|
@@ -303,6 +386,29 @@ declare class UserError extends RivetError {
|
|
|
303
386
|
constructor(message: string, options?: UserErrorOptions);
|
|
304
387
|
}
|
|
305
388
|
|
|
389
|
+
/** Sample rates keyed by action name, nested like the actor's action groups. */
|
|
390
|
+
interface ActionSampleRates {
|
|
391
|
+
readonly [name: string]: number | ActionSampleRates;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* {@link ActionSampleRates} limited to the actions of one actor, so a rate for
|
|
395
|
+
* an action that does not exist is a compile error.
|
|
396
|
+
*/
|
|
397
|
+
type ActionTraceSamplers<TActions> = {
|
|
398
|
+
readonly [K in keyof TActions]?: TActions[K] extends (...args: never[]) => unknown ? number : ActionTraceSamplers<TActions[K]>;
|
|
399
|
+
};
|
|
400
|
+
/** Trace sampling for one actor definition. */
|
|
401
|
+
interface ActorTracingOptions<TActions> {
|
|
402
|
+
/**
|
|
403
|
+
* Share of this actor's invocations that are recorded, from 0 to 1. A rate
|
|
404
|
+
* lowers what is recorded and never raises it, so an invocation inside a
|
|
405
|
+
* trace the caller did not record is not recorded at any rate.
|
|
406
|
+
*/
|
|
407
|
+
readonly sampler?: number;
|
|
408
|
+
/** Rates that replace `sampler` for single actions. */
|
|
409
|
+
readonly actions?: ActionTraceSamplers<TActions>;
|
|
410
|
+
}
|
|
411
|
+
|
|
306
412
|
type UpgradeWebSocket = (createEvents: (c: Context) => any) => Handler;
|
|
307
413
|
type GetUpgradeWebSocket = () => UpgradeWebSocket;
|
|
308
414
|
|
|
@@ -313,6 +419,7 @@ interface GatewayRequestOptions {
|
|
|
313
419
|
skipReadyWait?: boolean;
|
|
314
420
|
}
|
|
315
421
|
interface EngineControlClient {
|
|
422
|
+
issueToken(options: IssueTokenOptions): Promise<IssuedToken>;
|
|
316
423
|
getForId(input: GetForIdInput): Promise<ActorOutput | undefined>;
|
|
317
424
|
getWithKey(input: GetWithKeyInput): Promise<ActorOutput | undefined>;
|
|
318
425
|
getOrCreateWithKey(input: GetOrCreateWithKeyInput): Promise<ActorOutput>;
|
|
@@ -320,6 +427,8 @@ interface EngineControlClient {
|
|
|
320
427
|
listActors(input: ListActorsInput): Promise<ActorOutput[]>;
|
|
321
428
|
sendRequest(target: GatewayTarget, actorRequest: Request, options?: GatewayRequestOptions): Promise<Response>;
|
|
322
429
|
openWebSocket(path: string, target: GatewayTarget, encoding: Encoding, params: unknown, options?: GatewayRequestOptions): Promise<UniversalWebSocket>;
|
|
430
|
+
/** Refresh a credential rejected during this WebSocket handshake, if supported. */
|
|
431
|
+
refreshAuthToken?(ws: UniversalWebSocket): Promise<boolean>;
|
|
323
432
|
proxyRequest(c: Context, actorRequest: Request, actorId: string): Promise<Response>;
|
|
324
433
|
proxyWebSocket(c: Context, path: string, actorId: string, encoding: Encoding, params: unknown): Promise<Response>;
|
|
325
434
|
buildGatewayUrl(target: GatewayTarget, options?: GatewayRequestOptions): Promise<string>;
|
|
@@ -384,1823 +493,2005 @@ interface ActorOutput {
|
|
|
384
493
|
error?: unknown;
|
|
385
494
|
}
|
|
386
495
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
496
|
+
/** Correlation owned by the currently executing Core actor invocation. */
|
|
497
|
+
interface ActorInvocationTraceContext {
|
|
498
|
+
/** Ray ID the invocation received, absent when nothing upstream supplied one. */
|
|
499
|
+
readonly rayId?: string;
|
|
500
|
+
/** Core-owned invocation span context, absent when tracing is disabled. */
|
|
501
|
+
readonly span?: ActorInvocationSpanContext;
|
|
502
|
+
}
|
|
503
|
+
/** W3C span context of the Core invocation span. */
|
|
504
|
+
interface ActorInvocationSpanContext {
|
|
505
|
+
/** W3C trace identifier. */
|
|
506
|
+
readonly traceId: string;
|
|
507
|
+
/** W3C span identifier for the Core invocation. */
|
|
508
|
+
readonly spanId: string;
|
|
509
|
+
/** OpenTelemetry trace flags encoded as an integer. */
|
|
510
|
+
readonly traceFlags: number;
|
|
511
|
+
/** Optional vendor trace state inherited by the Core invocation. */
|
|
512
|
+
readonly tracestate?: string;
|
|
400
513
|
}
|
|
401
514
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
* @typedef {Function} ActorActionFunction
|
|
406
|
-
* @template Args
|
|
407
|
-
* @template Response
|
|
408
|
-
* @param {...Args} args - Arguments for the action function.
|
|
409
|
-
* @returns {Promise<Response>}
|
|
410
|
-
*/
|
|
411
|
-
type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
|
|
412
|
-
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
413
|
-
type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
|
|
414
|
-
type ActorActionMap<R> = {
|
|
415
|
-
[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;
|
|
515
|
+
declare const handleBrand: unique symbol;
|
|
516
|
+
type OpaqueHandle<Name extends string> = {
|
|
517
|
+
readonly [handleBrand]: Name;
|
|
416
518
|
};
|
|
417
|
-
type
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
519
|
+
type RegistryHandle = OpaqueHandle<"registry">;
|
|
520
|
+
type ActorFactoryHandle = OpaqueHandle<"actorFactory">;
|
|
521
|
+
type ActorContextHandle = OpaqueHandle<"actorContext">;
|
|
522
|
+
type ConnHandle = OpaqueHandle<"conn">;
|
|
523
|
+
type WebSocketHandle = OpaqueHandle<"webSocket">;
|
|
524
|
+
type CancellationTokenHandle = OpaqueHandle<"cancellationToken">;
|
|
525
|
+
type ActorStateTransactionHandle = OpaqueHandle<"actorStateTransaction">;
|
|
526
|
+
type SqliteTransactionHandle = OpaqueHandle<"sqliteTransaction">;
|
|
527
|
+
type RuntimeBytes = Uint8Array;
|
|
528
|
+
interface RuntimeActorKeySegment {
|
|
529
|
+
kind: string;
|
|
530
|
+
stringValue?: string;
|
|
531
|
+
numberValue?: number;
|
|
422
532
|
}
|
|
423
|
-
|
|
424
|
-
|
|
533
|
+
/** Resolves correlation at operation time so retained clients cannot freeze stale context. */
|
|
534
|
+
type CurrentActorInvocation = () => ActorInvocationTraceContext | undefined;
|
|
535
|
+
/** One open call from an actor out to another actor. */
|
|
536
|
+
interface RuntimeOutboundCall {
|
|
537
|
+
/**
|
|
538
|
+
* W3C context of the call's own span, to send to the callee so it parents to
|
|
539
|
+
* the call. Absent when tracing is disabled.
|
|
540
|
+
*/
|
|
541
|
+
readonly span?: ActorInvocationSpanContext;
|
|
542
|
+
/**
|
|
543
|
+
* Records the call's outcome. `error` is the failure encoded the way the
|
|
544
|
+
* bridge encodes errors, so a structured error keeps its group and code.
|
|
545
|
+
*/
|
|
546
|
+
finish(error?: string): void;
|
|
425
547
|
}
|
|
426
|
-
type ActorConnectOptions = ActorGatewayOptions;
|
|
427
|
-
type ActorFetchInit = RequestInit & ActorGatewayOptions;
|
|
428
|
-
type ActorWebSocketOptions = ActorGatewayOptions;
|
|
429
548
|
/**
|
|
430
|
-
*
|
|
549
|
+
* Opens the span covering one call out to another actor, or returns `undefined`
|
|
550
|
+
* outside an invocation or on a runtime without invocation telemetry. Callers
|
|
551
|
+
* send their own context when it returns nothing.
|
|
431
552
|
*/
|
|
432
|
-
type
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
};
|
|
439
|
-
type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
|
|
440
|
-
<K extends keyof TEvents & string>(eventName: K, callback: (...args: InferEventArgs<InferSchemaMap<TEvents>[K]>) => void): () => void;
|
|
441
|
-
(eventName: keyof TEvents extends never ? string : never, callback: (...args: any[]) => void): () => void;
|
|
442
|
-
};
|
|
443
|
-
type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
444
|
-
send: ActorQueueSend<Record<string, any>>;
|
|
445
|
-
} : AD extends {
|
|
446
|
-
config: {
|
|
447
|
-
queues?: infer Q;
|
|
448
|
-
};
|
|
449
|
-
} ? Q extends QueueSchemaConfig ? {
|
|
450
|
-
send: ActorQueueSend<Q>;
|
|
451
|
-
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
|
|
452
|
-
send: ActorQueueSend<Q>;
|
|
453
|
-
} : {} : {};
|
|
454
|
-
type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
455
|
-
on: LooseEventSubscribe;
|
|
456
|
-
once: LooseEventSubscribe;
|
|
457
|
-
} : AD extends {
|
|
458
|
-
config: {
|
|
459
|
-
events?: infer E;
|
|
460
|
-
};
|
|
461
|
-
} ? E extends EventSchemaConfig ? {
|
|
462
|
-
on: ActorEventSubscribe<E>;
|
|
463
|
-
once: ActorEventSubscribe<E>;
|
|
464
|
-
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
|
|
465
|
-
on: ActorEventSubscribe<E>;
|
|
466
|
-
once: ActorEventSubscribe<E>;
|
|
467
|
-
} : {} : {};
|
|
468
|
-
|
|
469
|
-
declare class ActorClientError extends Error {
|
|
553
|
+
type StartCallSpan = (actorName: string, actionName: string) => RuntimeOutboundCall | undefined;
|
|
554
|
+
interface RuntimeHttpRequest {
|
|
555
|
+
method: string;
|
|
556
|
+
uri: string;
|
|
557
|
+
headers?: Record<string, string>;
|
|
558
|
+
body?: RuntimeBytes;
|
|
470
559
|
}
|
|
471
|
-
|
|
472
|
-
|
|
560
|
+
interface RuntimeHttpResponseBodyStream {
|
|
561
|
+
cancelled(): Promise<void>;
|
|
562
|
+
write(chunk: Uint8Array): Promise<void>;
|
|
563
|
+
end(): Promise<void>;
|
|
564
|
+
error(message: string): Promise<void>;
|
|
473
565
|
}
|
|
474
|
-
|
|
475
|
-
|
|
566
|
+
interface RuntimeStateDeltaPayload {
|
|
567
|
+
state?: RuntimeBytes;
|
|
568
|
+
connHibernation: Array<{
|
|
569
|
+
connId: string;
|
|
570
|
+
bytes: RuntimeBytes;
|
|
571
|
+
}>;
|
|
572
|
+
connHibernationRemoved: string[];
|
|
476
573
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
574
|
+
interface RuntimeWorkflowKvWrite {
|
|
575
|
+
key: RuntimeBytes;
|
|
576
|
+
value: RuntimeBytes;
|
|
480
577
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Connection status for an actor connection.
|
|
486
|
-
*
|
|
487
|
-
* - `"idle"`: Not connected, no auto-reconnect (initial state, after dispose, or disabled)
|
|
488
|
-
* - `"connecting"`: Attempting to establish connection
|
|
489
|
-
* - `"connected"`: Connection is active
|
|
490
|
-
* - `"disconnected"`: Connection was lost, will auto-reconnect
|
|
491
|
-
*/
|
|
492
|
-
type ActorConnStatus = "idle" | "connecting" | "connected" | "disconnected";
|
|
493
|
-
/**
|
|
494
|
-
* A function that unsubscribes from an event.
|
|
495
|
-
*
|
|
496
|
-
* @typedef {Function} EventUnsubscribe
|
|
497
|
-
*/
|
|
498
|
-
type EventUnsubscribe = () => void;
|
|
499
|
-
/**
|
|
500
|
-
* A function that handles connection errors.
|
|
501
|
-
*
|
|
502
|
-
* @typedef {Function} ActorErrorCallback
|
|
503
|
-
*/
|
|
504
|
-
type ActorErrorCallback = (error: RivetError) => void;
|
|
505
|
-
/**
|
|
506
|
-
* A callback for connection state changes.
|
|
507
|
-
*
|
|
508
|
-
* @typedef {Function} ConnectionStateCallback
|
|
509
|
-
*/
|
|
510
|
-
type ConnectionStateCallback = () => void;
|
|
511
|
-
/**
|
|
512
|
-
* A callback for connection status changes.
|
|
513
|
-
*
|
|
514
|
-
* @typedef {Function} StatusChangeCallback
|
|
515
|
-
*/
|
|
516
|
-
type StatusChangeCallback = (status: ActorConnStatus) => void;
|
|
517
|
-
declare const CONNECT_SYMBOL: unique symbol;
|
|
518
|
-
/**
|
|
519
|
-
* Provides underlying functions for {@link ActorConn}. See {@link ActorConn} for using type-safe remote procedure calls.
|
|
520
|
-
*
|
|
521
|
-
* @see {@link ActorConn}
|
|
522
|
-
*/
|
|
523
|
-
declare class ActorConnRaw {
|
|
524
|
-
#private;
|
|
525
|
-
/**
|
|
526
|
-
* Do not call this directly.
|
|
527
|
-
*
|
|
528
|
-
* Creates an instance of ActorConnRaw.
|
|
529
|
-
*
|
|
530
|
-
* @protected
|
|
531
|
-
*/
|
|
532
|
-
constructor(client: ClientRaw, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions);
|
|
533
|
-
send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
534
|
-
send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
535
|
-
/**
|
|
536
|
-
* Call a raw action connection. See {@link ActorConn} for type-safe action calls.
|
|
537
|
-
*
|
|
538
|
-
* @see {@link ActorConn}
|
|
539
|
-
* @template Args - The type of arguments to pass to the action function.
|
|
540
|
-
* @template Response - The type of the response returned by the action function.
|
|
541
|
-
* @param {string} name - The name of the action function to call.
|
|
542
|
-
* @param {...Args} args - The arguments to pass to the action function.
|
|
543
|
-
* @returns {Promise<Response>} - A promise that resolves to the response of the action function.
|
|
544
|
-
*/
|
|
545
|
-
action<Args extends Array<unknown> = unknown[], Response = unknown>(opts: {
|
|
546
|
-
name: string;
|
|
547
|
-
args: Args;
|
|
548
|
-
signal?: AbortSignal;
|
|
549
|
-
}): Promise<Response>;
|
|
550
|
-
/**
|
|
551
|
-
* Do not call this directly.
|
|
552
|
-
* Establishes a connection to the server using the specified endpoint & encoding & driver.
|
|
553
|
-
*
|
|
554
|
-
* @protected
|
|
555
|
-
*/
|
|
556
|
-
[CONNECT_SYMBOL](): void;
|
|
557
|
-
/**
|
|
558
|
-
* Subscribes to an event that will happen repeatedly.
|
|
559
|
-
*
|
|
560
|
-
* @template Args - The type of arguments the event callback will receive.
|
|
561
|
-
* @param {string} eventName - The name of the event to subscribe to.
|
|
562
|
-
* @param {(...args: Args) => void} callback - The callback function to execute when the event is triggered.
|
|
563
|
-
* @returns {EventUnsubscribe} - A function to unsubscribe from the event.
|
|
564
|
-
* @see {@link https://rivet.dev/docs/events|Events Documentation}
|
|
565
|
-
*/
|
|
566
|
-
on<Args extends Array<unknown> = unknown[]>(eventName: string, callback: (...args: Args) => void): EventUnsubscribe;
|
|
567
|
-
/**
|
|
568
|
-
* Subscribes to an event that will be triggered only once.
|
|
569
|
-
*
|
|
570
|
-
* @template Args - The type of arguments the event callback will receive.
|
|
571
|
-
* @param {string} eventName - The name of the event to subscribe to.
|
|
572
|
-
* @param {(...args: Args) => void} callback - The callback function to execute when the event is triggered.
|
|
573
|
-
* @returns {EventUnsubscribe} - A function to unsubscribe from the event.
|
|
574
|
-
* @see {@link https://rivet.dev/docs/events|Events Documentation}
|
|
575
|
-
*/
|
|
576
|
-
once<Args extends Array<unknown> = unknown[]>(eventName: string, callback: (...args: Args) => void): EventUnsubscribe;
|
|
577
|
-
/**
|
|
578
|
-
* Subscribes to connection errors.
|
|
579
|
-
*
|
|
580
|
-
* @param {ActorErrorCallback} callback - The callback function to execute when a connection error occurs.
|
|
581
|
-
* @returns {() => void} - A function to unsubscribe from the error handler.
|
|
582
|
-
*/
|
|
583
|
-
onError(callback: ActorErrorCallback): () => void;
|
|
584
|
-
/**
|
|
585
|
-
* Returns the current connection status.
|
|
586
|
-
*
|
|
587
|
-
* @returns {ActorConnStatus} - The current connection status.
|
|
588
|
-
*/
|
|
589
|
-
get connStatus(): ActorConnStatus;
|
|
590
|
-
/**
|
|
591
|
-
* Returns whether the connection is currently open.
|
|
592
|
-
*
|
|
593
|
-
* @deprecated Use `connStatus` instead.
|
|
594
|
-
* @returns {boolean} - True if the connection is open, false otherwise.
|
|
595
|
-
*/
|
|
596
|
-
get isConnected(): boolean;
|
|
597
|
-
/**
|
|
598
|
-
* Resolves when this connection first reaches the connected state.
|
|
599
|
-
*/
|
|
600
|
-
get ready(): Promise<void>;
|
|
601
|
-
/**
|
|
602
|
-
* Subscribes to connection open events.
|
|
603
|
-
*
|
|
604
|
-
* This is called when the WebSocket connection is established and the Init message is received.
|
|
605
|
-
*
|
|
606
|
-
* @param {ConnectionStateCallback} callback - The callback function to execute when the connection opens.
|
|
607
|
-
* @returns {() => void} - A function to unsubscribe from the open handler.
|
|
608
|
-
*/
|
|
609
|
-
onOpen(callback: ConnectionStateCallback): () => void;
|
|
610
|
-
/**
|
|
611
|
-
* Subscribes to connection close events.
|
|
612
|
-
*
|
|
613
|
-
* This is called when the WebSocket connection is closed. The connection will automatically
|
|
614
|
-
* attempt to reconnect unless disposed.
|
|
615
|
-
*
|
|
616
|
-
* @param {ConnectionStateCallback} callback - The callback function to execute when the connection closes.
|
|
617
|
-
* @returns {() => void} - A function to unsubscribe from the close handler.
|
|
618
|
-
*/
|
|
619
|
-
onClose(callback: ConnectionStateCallback): () => void;
|
|
620
|
-
/**
|
|
621
|
-
* Subscribes to connection status changes.
|
|
622
|
-
*
|
|
623
|
-
* This is called whenever the connection status changes between Disconnected, Connecting, and Connected.
|
|
624
|
-
*
|
|
625
|
-
* @param {StatusChangeCallback} callback - The callback function to execute when the status changes.
|
|
626
|
-
* @returns {() => void} - A function to unsubscribe from the status change handler.
|
|
627
|
-
*/
|
|
628
|
-
onStatusChange(callback: StatusChangeCallback): () => void;
|
|
629
|
-
/**
|
|
630
|
-
* Disconnects from the actor.
|
|
631
|
-
*
|
|
632
|
-
* @returns {Promise<void>} A promise that resolves when the socket is gracefully closed.
|
|
633
|
-
*/
|
|
634
|
-
dispose(): Promise<void>;
|
|
635
|
-
}
|
|
636
|
-
/**
|
|
637
|
-
* Connection to a actor. Allows calling actor's remote procedure calls with inferred types. See {@link ActorConnRaw} for underlying methods.
|
|
638
|
-
*
|
|
639
|
-
* @example
|
|
640
|
-
* ```
|
|
641
|
-
* const room = client.connect<ChatRoom>(...etc...);
|
|
642
|
-
* // This calls the action named `sendMessage` on the `ChatRoom` actor.
|
|
643
|
-
* await room.sendMessage('Hello, world!');
|
|
644
|
-
* ```
|
|
645
|
-
*
|
|
646
|
-
* Private methods (e.g. those starting with `_`) are automatically excluded.
|
|
647
|
-
*
|
|
648
|
-
* @template AD The actor class that this connection is for.
|
|
649
|
-
* @see {@link ActorConnRaw}
|
|
650
|
-
*/
|
|
651
|
-
type ActorConn<AD extends AnyActorDefinition> = Omit<ActorConnRaw, "send" | "on" | "once"> & ActorDefinitionQueueSend<AD> & ActorDefinitionEventSubscriptions<AD> & ActorDefinitionActions<AD>;
|
|
652
|
-
|
|
653
|
-
/**
|
|
654
|
-
* Provides underlying functions for stateless {@link ActorHandle} for action calls.
|
|
655
|
-
* Similar to ActorConnRaw but doesn't maintain a connection.
|
|
656
|
-
*
|
|
657
|
-
* @see {@link ActorHandle}
|
|
658
|
-
*/
|
|
659
|
-
declare class ActorHandleRaw {
|
|
660
|
-
#private;
|
|
661
|
-
/**
|
|
662
|
-
* Do not call this directly.
|
|
663
|
-
*
|
|
664
|
-
* Creates an instance of ActorHandleRaw.
|
|
665
|
-
*
|
|
666
|
-
* @protected
|
|
667
|
-
*/
|
|
668
|
-
constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions);
|
|
669
|
-
send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
670
|
-
send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
671
|
-
/**
|
|
672
|
-
* Call a raw action. This method sends an HTTP request to invoke the named action.
|
|
673
|
-
*
|
|
674
|
-
* @see {@link ActorHandle}
|
|
675
|
-
* @template Args - The type of arguments to pass to the action function.
|
|
676
|
-
* @template Response - The type of the response returned by the action function.
|
|
677
|
-
*/
|
|
678
|
-
action<Args extends Array<unknown> = unknown[], Response = unknown>(opts: {
|
|
679
|
-
name: string;
|
|
680
|
-
args: Args;
|
|
681
|
-
} & ActorActionOptions): Promise<Response>;
|
|
682
|
-
/**
|
|
683
|
-
* Establishes a persistent connection to the actor.
|
|
684
|
-
*
|
|
685
|
-
* @template AD The actor class that this connection is for.
|
|
686
|
-
* @returns {ActorConn<AD>} A connection to the actor.
|
|
687
|
-
*/
|
|
688
|
-
connect(params?: unknown, options?: ActorConnectOptions): ActorConn<AnyActorDefinition>;
|
|
689
|
-
/**
|
|
690
|
-
* Fetches a resource from this actor via the /request endpoint. This is a
|
|
691
|
-
* convenience wrapper around the raw HTTP API.
|
|
692
|
-
*/
|
|
693
|
-
fetch(input: string | URL | Request, init?: ActorFetchInit): Promise<Response>;
|
|
694
|
-
/**
|
|
695
|
-
* Opens a raw WebSocket connection to this actor.
|
|
696
|
-
*/
|
|
697
|
-
webSocket(path?: string, protocols?: string | string[], options?: ActorWebSocketOptions): Promise<any>;
|
|
698
|
-
/**
|
|
699
|
-
* Resolves the actor to get its unique actor ID.
|
|
700
|
-
*/
|
|
701
|
-
resolve(): Promise<string>;
|
|
702
|
-
/**
|
|
703
|
-
* Returns the raw URL for routing traffic to the actor.
|
|
704
|
-
*/
|
|
705
|
-
getGatewayUrl(): Promise<string>;
|
|
706
|
-
reload(): Promise<void>;
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* Stateless handle to a actor. Allows calling actor's remote procedure calls with inferred types
|
|
710
|
-
* without establishing a persistent connection.
|
|
711
|
-
*
|
|
712
|
-
* @example
|
|
713
|
-
* ```
|
|
714
|
-
* const room = client.get<ChatRoom>(...etc...);
|
|
715
|
-
* // This calls the action named `sendMessage` on the `ChatRoom` actor without a connection.
|
|
716
|
-
* await room.sendMessage('Hello, world!');
|
|
717
|
-
* ```
|
|
718
|
-
*
|
|
719
|
-
* Private methods (e.g. those starting with `_`) are automatically excluded.
|
|
720
|
-
*
|
|
721
|
-
* @template AD The actor class that this handle is for.
|
|
722
|
-
* @see {@link ActorHandleRaw}
|
|
723
|
-
*/
|
|
724
|
-
type ActorHandle<AD extends AnyActorDefinition> = Omit<ActorHandleRaw, "connect" | "send"> & {
|
|
725
|
-
connect(params?: unknown, options?: ActorConnectOptions): ActorConn<AD>;
|
|
726
|
-
resolve(): Promise<string>;
|
|
727
|
-
} & ActorDefinitionQueueSend<AD> & ActorDefinitionActions<AD>;
|
|
728
|
-
|
|
729
|
-
declare const ClientConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
|
|
730
|
-
endpoint: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string, string | undefined>>;
|
|
731
|
-
token: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string | undefined, string | undefined>>;
|
|
732
|
-
namespace: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string | undefined, string | undefined>>;
|
|
733
|
-
poolName: z$1.ZodDefault<z$1.ZodString>;
|
|
734
|
-
encoding: z$1.ZodDefault<z$1.ZodEnum<{
|
|
735
|
-
json: "json";
|
|
736
|
-
cbor: "cbor";
|
|
737
|
-
bare: "bare";
|
|
738
|
-
}>>;
|
|
739
|
-
headers: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>>;
|
|
740
|
-
gateway: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodObject<{
|
|
741
|
-
skipReadyWait: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
|
|
742
|
-
}, z$1.core.$strip>>>;
|
|
743
|
-
getUpgradeWebSocket: z$1.ZodOptional<z$1.ZodCustom<GetUpgradeWebSocket, GetUpgradeWebSocket>>;
|
|
744
|
-
disableMetadataLookup: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
|
|
745
|
-
maxInputSize: z$1.ZodDefault<z$1.ZodNumber>;
|
|
746
|
-
devtools: z$1.ZodDefault<z$1.ZodBoolean>;
|
|
747
|
-
}, z$1.core.$strip>, z$1.ZodTransform<{
|
|
748
|
-
endpoint: string | undefined;
|
|
749
|
-
namespace: string;
|
|
750
|
-
token: string | undefined;
|
|
751
|
-
poolName: string;
|
|
752
|
-
encoding: "json" | "cbor" | "bare";
|
|
753
|
-
headers: Record<string, string>;
|
|
754
|
-
gateway: {
|
|
755
|
-
skipReadyWait: boolean;
|
|
756
|
-
};
|
|
757
|
-
disableMetadataLookup: boolean;
|
|
758
|
-
maxInputSize: number;
|
|
759
|
-
devtools: boolean;
|
|
760
|
-
getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
|
|
761
|
-
}, {
|
|
762
|
-
endpoint: string;
|
|
763
|
-
token: string | undefined;
|
|
764
|
-
namespace: string | undefined;
|
|
765
|
-
poolName: string;
|
|
766
|
-
encoding: "json" | "cbor" | "bare";
|
|
767
|
-
headers: Record<string, string>;
|
|
768
|
-
gateway: {
|
|
769
|
-
skipReadyWait: boolean;
|
|
770
|
-
};
|
|
771
|
-
disableMetadataLookup: boolean;
|
|
772
|
-
maxInputSize: number;
|
|
773
|
-
devtools: boolean;
|
|
774
|
-
getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
|
|
775
|
-
}>>;
|
|
776
|
-
type ClientConfigInput = z$1.input<typeof ClientConfigSchema>;
|
|
777
|
-
|
|
778
|
-
/** Extract the actor registry from the registry definition. */
|
|
779
|
-
type ExtractActorsFromRegistry<A extends Registry<any>> = A extends Registry<infer Actors> ? Actors : never;
|
|
780
|
-
/** Extract the registry definition from the client. */
|
|
781
|
-
type ExtractRegistryFromClient<C extends Client<Registry<{}>>> = C extends Client<infer A> ? A : never;
|
|
782
|
-
/**
|
|
783
|
-
* Represents a actor accessor that provides methods to interact with a specific actor.
|
|
784
|
-
*/
|
|
785
|
-
interface ActorAccessor<AD extends AnyActorDefinition> {
|
|
786
|
-
/**
|
|
787
|
-
* Gets a stateless handle to a actor by its key, but does not create the actor if it doesn't exist.
|
|
788
|
-
* The actor name is automatically injected from the property accessor.
|
|
789
|
-
*
|
|
790
|
-
* Each operation resolves the current actor for the key before sending the
|
|
791
|
-
* request.
|
|
792
|
-
*
|
|
793
|
-
* @template AD The actor class that this handle is for.
|
|
794
|
-
* @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
|
|
795
|
-
* @param {GetWithIdOptions} [opts] - Options for getting the actor.
|
|
796
|
-
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
797
|
-
*/
|
|
798
|
-
get(key?: string | string[], opts?: GetWithIdOptions): ActorHandle<AD>;
|
|
799
|
-
/**
|
|
800
|
-
* Gets a stateless handle to a actor by its key, creating it if necessary.
|
|
801
|
-
* The actor name is automatically injected from the property accessor.
|
|
802
|
-
*
|
|
803
|
-
* Each operation resolves the current actor for the key before sending the
|
|
804
|
-
* request.
|
|
805
|
-
*
|
|
806
|
-
* @template AD The actor class that this handle is for.
|
|
807
|
-
* @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
|
|
808
|
-
* @param {GetOptions} [opts] - Options for getting the actor.
|
|
809
|
-
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
810
|
-
*/
|
|
811
|
-
getOrCreate(key?: string | string[], opts?: GetOrCreateOptions): ActorHandle<AD>;
|
|
812
|
-
/**
|
|
813
|
-
* Gets a stateless handle to a actor by its ID.
|
|
814
|
-
*
|
|
815
|
-
* If the actor is destroyed, operations will throw without retrying since
|
|
816
|
-
* there is no key to re-resolve.
|
|
817
|
-
*
|
|
818
|
-
* @template AD The actor class that this handle is for.
|
|
819
|
-
* @param {string} actorId - The ID of the actor.
|
|
820
|
-
* @param {GetWithIdOptions} [opts] - Options for getting the actor.
|
|
821
|
-
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
822
|
-
*/
|
|
823
|
-
getForId(actorId: string, opts?: GetWithIdOptions): ActorHandle<AD>;
|
|
824
|
-
/**
|
|
825
|
-
* Creates a new actor with the name automatically injected from the property accessor,
|
|
826
|
-
* and returns a stateless handle to it with the actor ID resolved.
|
|
827
|
-
*
|
|
828
|
-
* If the actor is destroyed, operations will throw without retrying since
|
|
829
|
-
* creation is a one-shot operation.
|
|
830
|
-
*
|
|
831
|
-
* @template AD The actor class that this handle is for.
|
|
832
|
-
* @param {string | string[]} key - The key to identify the actor. Can be a single string or an array of strings.
|
|
833
|
-
* @param {CreateOptions} [opts] - Options for creating the actor (excluding name and key).
|
|
834
|
-
* @returns {Promise<ActorHandle<AD>>} - A promise that resolves to a handle to the actor.
|
|
835
|
-
*/
|
|
836
|
-
create(key?: string | string[], opts?: CreateOptions): Promise<ActorHandle<AD>>;
|
|
837
|
-
}
|
|
838
|
-
/**
|
|
839
|
-
* Options for querying actors.
|
|
840
|
-
* @typedef {Object} QueryOptions
|
|
841
|
-
* @property {unknown} [parameters] - Parameters to pass to the connection.
|
|
842
|
-
*/
|
|
843
|
-
interface QueryOptions {
|
|
844
|
-
/** Parameters to pass to the connection. */
|
|
845
|
-
params?: unknown;
|
|
846
|
-
/**
|
|
847
|
-
* Lazily resolves connection parameters for `.connect()` and `.webSocket()`.
|
|
848
|
-
* This is called each time a new connection is opened.
|
|
849
|
-
*/
|
|
850
|
-
getParams?: () => Promise<unknown>;
|
|
851
|
-
/** Signal to abort the request. */
|
|
852
|
-
signal?: AbortSignal;
|
|
853
|
-
}
|
|
854
|
-
/**
|
|
855
|
-
* Options for getting a actor by ID.
|
|
856
|
-
* @typedef {QueryOptions} GetWithIdOptions
|
|
857
|
-
*/
|
|
858
|
-
interface GetWithIdOptions extends QueryOptions {
|
|
859
|
-
}
|
|
860
|
-
/**
|
|
861
|
-
* Options for getting a actor.
|
|
862
|
-
* @typedef {QueryOptions} GetOptions
|
|
863
|
-
*/
|
|
864
|
-
interface GetOptions extends QueryOptions {
|
|
865
|
-
}
|
|
866
|
-
/**
|
|
867
|
-
* Options for getting or creating a actor.
|
|
868
|
-
* @typedef {QueryOptions} GetOrCreateOptions
|
|
869
|
-
* @property {string} [createInRegion] - Region to create the actor in if it doesn't exist.
|
|
870
|
-
*/
|
|
871
|
-
interface GetOrCreateOptions extends QueryOptions {
|
|
872
|
-
/** Region to create the actor in if it doesn't exist. */
|
|
873
|
-
createInRegion?: string;
|
|
874
|
-
/** Input data to pass to the actor. */
|
|
875
|
-
createWithInput?: unknown;
|
|
876
|
-
/**
|
|
877
|
-
* Name of the envoy pool to select for this actor if it is created.
|
|
878
|
-
* Overrides the client's configured `poolName` for this call.
|
|
879
|
-
*/
|
|
880
|
-
poolName?: string;
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* Options for creating a actor.
|
|
884
|
-
* @typedef {QueryOptions} CreateOptions
|
|
885
|
-
* @property {string} [region] - The region to create the actor in.
|
|
886
|
-
*/
|
|
887
|
-
interface CreateOptions extends QueryOptions {
|
|
888
|
-
/** The region to create the actor in. */
|
|
889
|
-
region?: string;
|
|
890
|
-
/** Input data to pass to the actor. */
|
|
891
|
-
input?: unknown;
|
|
892
|
-
/**
|
|
893
|
-
* Name of the envoy pool to select for this actor.
|
|
894
|
-
* Overrides the client's configured `poolName` for this call.
|
|
895
|
-
*/
|
|
896
|
-
poolName?: string;
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* Represents a region to connect to.
|
|
900
|
-
* @typedef {Object} Region
|
|
901
|
-
* @property {string} id - The region ID.
|
|
902
|
-
* @property {string} name - The region name.
|
|
903
|
-
* @see {@link https://rivet.dev/docs/edge|Edge Networking}
|
|
904
|
-
* @see {@link https://rivet.dev/docs/regions|Available Regions}
|
|
905
|
-
*/
|
|
906
|
-
interface Region {
|
|
907
|
-
/**
|
|
908
|
-
* The region slug.
|
|
909
|
-
*/
|
|
910
|
-
id: string;
|
|
911
|
-
/**
|
|
912
|
-
* The human-friendly region name.
|
|
913
|
-
*/
|
|
914
|
-
name: string;
|
|
578
|
+
interface RuntimeRequestSaveOpts {
|
|
579
|
+
immediate?: boolean;
|
|
580
|
+
maxWaitMs?: number;
|
|
915
581
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
*/
|
|
924
|
-
declare class ClientRaw {
|
|
925
|
-
#private;
|
|
926
|
-
[ACTOR_CONNS_SYMBOL]: Set<ActorConnRaw>;
|
|
927
|
-
/**
|
|
928
|
-
* Creates an instance of Client.
|
|
929
|
-
*/
|
|
930
|
-
constructor(driver: EngineControlClient, encoding: Encoding | undefined, gatewayOptions?: ActorGatewayOptions);
|
|
931
|
-
/**
|
|
932
|
-
* Gets a stateless handle to a actor by its ID.
|
|
933
|
-
*
|
|
934
|
-
* @template AD The actor class that this handle is for.
|
|
935
|
-
* @param {string} name - The name of the actor.
|
|
936
|
-
* @param {string} actorId - The ID of the actor.
|
|
937
|
-
* @param {GetWithIdOptions} [opts] - Options for getting the actor.
|
|
938
|
-
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
939
|
-
*/
|
|
940
|
-
getForId<AD extends AnyActorDefinition>(name: string, actorId: string, opts?: GetWithIdOptions): ActorHandle<AD>;
|
|
941
|
-
/**
|
|
942
|
-
* Gets a stateless handle to a actor by its key, but does not create the actor if it doesn't exist.
|
|
943
|
-
*
|
|
944
|
-
* @template AD The actor class that this handle is for.
|
|
945
|
-
* @param {string} name - The name of the actor.
|
|
946
|
-
* @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
|
|
947
|
-
* @param {GetWithIdOptions} [opts] - Options for getting the actor.
|
|
948
|
-
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
949
|
-
*/
|
|
950
|
-
get<AD extends AnyActorDefinition>(name: string, key?: string | string[], opts?: GetWithIdOptions): ActorHandle<AD>;
|
|
951
|
-
/**
|
|
952
|
-
* Gets a stateless handle to a actor by its key, creating it if necessary.
|
|
953
|
-
*
|
|
954
|
-
* @template AD The actor class that this handle is for.
|
|
955
|
-
* @param {string} name - The name of the actor.
|
|
956
|
-
* @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
|
|
957
|
-
* @param {GetOptions} [opts] - Options for getting the actor.
|
|
958
|
-
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
959
|
-
*/
|
|
960
|
-
getOrCreate<AD extends AnyActorDefinition>(name: string, key?: string | string[], opts?: GetOrCreateOptions): ActorHandle<AD>;
|
|
961
|
-
/**
|
|
962
|
-
* Creates a new actor with the provided key and returns a stateless handle to it.
|
|
963
|
-
* Resolves the actor ID and returns a handle with getForId query.
|
|
964
|
-
*
|
|
965
|
-
* @template AD The actor class that this handle is for.
|
|
966
|
-
* @param {string} name - The name of the actor.
|
|
967
|
-
* @param {string | string[]} key - The key to identify the actor. Can be a single string or an array of strings.
|
|
968
|
-
* @param {CreateOptions} [opts] - Options for creating the actor (excluding name and key).
|
|
969
|
-
* @returns {Promise<ActorHandle<AD>>} - A promise that resolves to a handle to the actor.
|
|
970
|
-
*/
|
|
971
|
-
create<AD extends AnyActorDefinition>(name: string, key?: string | string[], opts?: CreateOptions): Promise<ActorHandle<AD>>;
|
|
972
|
-
[CREATE_ACTOR_CONN_PROXY]<AD extends AnyActorDefinition>(conn: ActorConnRaw): ActorConn<AD>;
|
|
973
|
-
/**
|
|
974
|
-
* Disconnects from all actors.
|
|
975
|
-
*
|
|
976
|
-
* @returns {Promise<void>} A promise that resolves when all connections are closed.
|
|
977
|
-
*/
|
|
978
|
-
dispose(): Promise<void>;
|
|
582
|
+
interface RuntimeInspectorSnapshot {
|
|
583
|
+
stateRevision: number;
|
|
584
|
+
connectionsRevision: number;
|
|
585
|
+
queueRevision: number;
|
|
586
|
+
activeConnections: number;
|
|
587
|
+
queueSize: number;
|
|
588
|
+
connectedClients: number;
|
|
979
589
|
}
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
[K in keyof ExtractActorsFromRegistry<A>]: ActorAccessor<ExtractActorsFromRegistry<A>[K]>;
|
|
988
|
-
};
|
|
989
|
-
|
|
990
|
-
/** @experimental State exposed by a durable workflow run handler to the Inspector. */
|
|
991
|
-
type WorkflowState = "pending" | "running" | "sleeping" | "failed" | "completed" | "cancelled" | "rolling_back";
|
|
992
|
-
|
|
993
|
-
declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
|
|
994
|
-
declare const RAW_STATE_SYMBOL: unique symbol;
|
|
995
|
-
interface ActorLogger {
|
|
996
|
-
level: any;
|
|
997
|
-
fatal: any;
|
|
998
|
-
trace: any;
|
|
999
|
-
silent: any;
|
|
1000
|
-
msgPrefix: any;
|
|
1001
|
-
debug: any;
|
|
1002
|
-
info: any;
|
|
1003
|
-
warn: any;
|
|
1004
|
-
error: any;
|
|
1005
|
-
[key: string]: any;
|
|
590
|
+
interface RuntimeQueueMessage {
|
|
591
|
+
id(): bigint;
|
|
592
|
+
name(): string;
|
|
593
|
+
body(): RuntimeBytes;
|
|
594
|
+
createdAt(): number;
|
|
595
|
+
isCompletable(): boolean;
|
|
596
|
+
complete(response?: RuntimeBytes | undefined | null): Promise<void>;
|
|
1006
597
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
arrayBuffer: ArrayBuffer;
|
|
1012
|
-
binary: Uint8Array;
|
|
1013
|
-
};
|
|
1014
|
-
type ActorKvKeyTypeMap = {
|
|
1015
|
-
text: string;
|
|
1016
|
-
binary: Uint8Array;
|
|
1017
|
-
};
|
|
1018
|
-
type ActorKvValueOptions<T extends ActorKvValueType = "text"> = {
|
|
1019
|
-
type?: T;
|
|
1020
|
-
};
|
|
1021
|
-
type ActorKvListOptions<T extends ActorKvValueType = "text", K extends ActorKvKeyType = "text"> = ActorKvValueOptions<T> & {
|
|
1022
|
-
keyType?: K;
|
|
1023
|
-
reverse?: boolean;
|
|
1024
|
-
limit?: number;
|
|
1025
|
-
};
|
|
1026
|
-
type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
|
|
1027
|
-
/**
|
|
1028
|
-
* @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db`)
|
|
1029
|
-
* or actor state instead.
|
|
1030
|
-
*/
|
|
1031
|
-
interface ActorKv {
|
|
1032
|
-
get<T extends ActorKvValueType = "text">(key: Uint8Array | string, options?: ActorKvValueOptions<T>): Promise<ActorKvValueTypeMap[T] | null>;
|
|
1033
|
-
put<T extends ActorKvValueType = "text">(key: Uint8Array | string, value: Uint8Array | string | ArrayBuffer, options?: ActorKvValueOptions<T>): Promise<void>;
|
|
1034
|
-
delete(key: Uint8Array | string): Promise<void>;
|
|
1035
|
-
batchPut(entries: [Uint8Array, Uint8Array][]): Promise<void>;
|
|
1036
|
-
batchGet(keys: Uint8Array[]): Promise<(Uint8Array | null)[]>;
|
|
1037
|
-
batchDelete(keys: Uint8Array[]): Promise<void>;
|
|
1038
|
-
deleteRange(start: Uint8Array, end: Uint8Array): Promise<void>;
|
|
1039
|
-
listPrefix<T extends ActorKvValueType = "text", K extends ActorKvKeyType = "text">(prefix: Uint8Array | string, options?: ActorKvListOptions<T, K>): Promise<Array<[ActorKvKeyTypeMap[K], ActorKvValueTypeMap[T]]>>;
|
|
1040
|
-
listRange<T extends ActorKvValueType = "text", K extends ActorKvKeyType = "text">(start: Uint8Array | string, end: Uint8Array | string, options?: ActorKvListOptions<T, K>): Promise<Array<[ActorKvKeyTypeMap[K], ActorKvValueTypeMap[T]]>>;
|
|
1041
|
-
list<T extends ActorKvValueType = "text", K extends ActorKvKeyType = "text">(prefix: Uint8Array | string, options?: ActorKvListOptions<T, K>): Promise<Array<[ActorKvKeyTypeMap[K], ActorKvValueTypeMap[T]]>>;
|
|
1042
|
-
[key: string]: any;
|
|
598
|
+
interface RuntimeQueueInspectMessage {
|
|
599
|
+
id: number;
|
|
600
|
+
name: string;
|
|
601
|
+
createdAtMs: number;
|
|
1043
602
|
}
|
|
1044
|
-
interface
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
list(): Promise<ScheduledEventInfo[]>;
|
|
1050
|
-
[key: string]: any;
|
|
603
|
+
interface RuntimeScheduledEventInfo {
|
|
604
|
+
id: string;
|
|
605
|
+
action: string;
|
|
606
|
+
args: RuntimeBytes;
|
|
607
|
+
runAt: number;
|
|
1051
608
|
}
|
|
1052
|
-
interface
|
|
609
|
+
interface RuntimeCronJobInfo {
|
|
1053
610
|
name: string;
|
|
1054
|
-
|
|
611
|
+
kind: "cron" | "every";
|
|
1055
612
|
action: string;
|
|
1056
|
-
args
|
|
613
|
+
args: RuntimeBytes;
|
|
614
|
+
nextRunAt: number;
|
|
615
|
+
lastRunAt?: number;
|
|
616
|
+
expression?: string;
|
|
1057
617
|
timezone?: string;
|
|
1058
|
-
|
|
1059
|
-
maxHistory
|
|
618
|
+
intervalMs?: number;
|
|
619
|
+
maxHistory: number;
|
|
1060
620
|
}
|
|
1061
|
-
interface
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
621
|
+
interface RuntimeScheduleErrorInfo {
|
|
622
|
+
group: string;
|
|
623
|
+
code: string;
|
|
624
|
+
message: string;
|
|
625
|
+
metadata?: unknown;
|
|
626
|
+
}
|
|
627
|
+
interface RuntimeCronFire {
|
|
1065
628
|
action: string;
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
629
|
+
scheduledAt: number;
|
|
630
|
+
firedAt: number;
|
|
631
|
+
finishedAt?: number;
|
|
632
|
+
result: "running" | "ok" | "error" | "skipped";
|
|
633
|
+
error?: RuntimeScheduleErrorInfo;
|
|
634
|
+
}
|
|
635
|
+
interface RuntimeQueueNextBatchOptions {
|
|
636
|
+
names?: string[];
|
|
637
|
+
count?: number;
|
|
638
|
+
timeoutMs?: number;
|
|
639
|
+
completable?: boolean;
|
|
640
|
+
}
|
|
641
|
+
interface RuntimeQueueWaitOptions {
|
|
642
|
+
timeoutMs?: number;
|
|
643
|
+
completable?: boolean;
|
|
644
|
+
}
|
|
645
|
+
interface RuntimeQueueEnqueueAndWaitOptions {
|
|
646
|
+
timeoutMs?: number;
|
|
647
|
+
}
|
|
648
|
+
interface RuntimeQueueTryNextBatchOptions {
|
|
649
|
+
names?: string[];
|
|
650
|
+
count?: number;
|
|
651
|
+
completable?: boolean;
|
|
652
|
+
}
|
|
653
|
+
interface RuntimeKvListOptions {
|
|
654
|
+
reverse?: boolean;
|
|
655
|
+
limit?: number;
|
|
656
|
+
}
|
|
657
|
+
interface RuntimeKvEntry {
|
|
658
|
+
key: RuntimeBytes;
|
|
659
|
+
value: RuntimeBytes;
|
|
660
|
+
}
|
|
661
|
+
type RuntimeSqlBindNoValues = {
|
|
662
|
+
intValue?: never;
|
|
663
|
+
floatValue?: never;
|
|
664
|
+
textValue?: never;
|
|
665
|
+
blobValue?: never;
|
|
666
|
+
};
|
|
667
|
+
type RuntimeSqlBindParam = ({
|
|
668
|
+
kind: "null";
|
|
669
|
+
} & RuntimeSqlBindNoValues) | {
|
|
670
|
+
kind: "int";
|
|
671
|
+
intValue: number;
|
|
672
|
+
floatValue?: never;
|
|
673
|
+
textValue?: never;
|
|
674
|
+
blobValue?: never;
|
|
675
|
+
} | {
|
|
676
|
+
kind: "float";
|
|
677
|
+
intValue?: never;
|
|
678
|
+
floatValue: number;
|
|
679
|
+
textValue?: never;
|
|
680
|
+
blobValue?: never;
|
|
681
|
+
} | {
|
|
682
|
+
kind: "text";
|
|
683
|
+
intValue?: never;
|
|
684
|
+
floatValue?: never;
|
|
685
|
+
textValue: string;
|
|
686
|
+
blobValue?: never;
|
|
687
|
+
} | {
|
|
688
|
+
kind: "blob";
|
|
689
|
+
intValue?: never;
|
|
690
|
+
floatValue?: never;
|
|
691
|
+
textValue?: never;
|
|
692
|
+
blobValue: RuntimeBytes;
|
|
693
|
+
};
|
|
694
|
+
type RuntimeSqlBindParams = RuntimeSqlBindParam[] | null;
|
|
695
|
+
interface RuntimeActorRuntimeSocketEndpointInfo {
|
|
696
|
+
path: string;
|
|
1069
697
|
}
|
|
1070
|
-
interface
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
get(name: string): Promise<CronJobInfo | undefined>;
|
|
1074
|
-
list(): Promise<CronJobInfo[]>;
|
|
1075
|
-
delete(name: string): Promise<boolean>;
|
|
1076
|
-
history(name: string, options?: {
|
|
1077
|
-
limit?: number;
|
|
1078
|
-
}): Promise<CronFire[]>;
|
|
1079
|
-
[key: string]: any;
|
|
698
|
+
interface RuntimeSqlQueryResult {
|
|
699
|
+
columns: string[];
|
|
700
|
+
rows: unknown[][];
|
|
1080
701
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
runAt: number;
|
|
702
|
+
type RuntimeSqlExecResult = RuntimeSqlQueryResult;
|
|
703
|
+
interface RuntimeSqlExecuteResult extends RuntimeSqlQueryResult {
|
|
704
|
+
changes: number;
|
|
705
|
+
lastInsertRowId?: number | null;
|
|
1086
706
|
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
args: unknown[];
|
|
1091
|
-
nextRunAt: number;
|
|
1092
|
-
lastRunAt?: number;
|
|
1093
|
-
maxHistory: number;
|
|
1094
|
-
} & ({
|
|
1095
|
-
kind: "cron";
|
|
1096
|
-
expression: string;
|
|
1097
|
-
timezone: string;
|
|
1098
|
-
} | {
|
|
1099
|
-
kind: "every";
|
|
1100
|
-
interval: number;
|
|
1101
|
-
});
|
|
1102
|
-
interface CronFire {
|
|
1103
|
-
action: string;
|
|
1104
|
-
scheduledAt: number;
|
|
1105
|
-
firedAt: number;
|
|
1106
|
-
finishedAt?: number;
|
|
1107
|
-
result: "running" | "ok" | "error" | "skipped";
|
|
1108
|
-
error?: {
|
|
1109
|
-
group: string;
|
|
1110
|
-
code: string;
|
|
1111
|
-
message: string;
|
|
1112
|
-
metadata?: unknown;
|
|
1113
|
-
};
|
|
707
|
+
interface RuntimeSqlBatchStatement {
|
|
708
|
+
sql: string;
|
|
709
|
+
params?: RuntimeSqlBindParams;
|
|
1114
710
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
name: Name;
|
|
1118
|
-
body: Body;
|
|
1119
|
-
createdAt: number;
|
|
1120
|
-
[key: string]: unknown;
|
|
1121
|
-
};
|
|
1122
|
-
type QueueName<TQueues extends QueueSchemaConfig> = keyof TQueues & string;
|
|
1123
|
-
type QueueFilterName<TQueues extends QueueSchemaConfig> = keyof TQueues extends never ? string : QueueName<TQueues>;
|
|
1124
|
-
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;
|
|
1125
|
-
type QueueCompleteArgs<T> = undefined extends T ? [response?: T] : [response: T];
|
|
1126
|
-
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];
|
|
1127
|
-
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;
|
|
1128
|
-
interface QueueNextOptions<TName extends string = string, TCompletable extends boolean = boolean> {
|
|
1129
|
-
names?: readonly TName[];
|
|
1130
|
-
timeout?: number;
|
|
1131
|
-
signal?: AbortSignal;
|
|
1132
|
-
completable?: TCompletable;
|
|
711
|
+
interface RuntimeSqlRunResult {
|
|
712
|
+
changes: number;
|
|
1133
713
|
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
completable?: TCompletable;
|
|
714
|
+
/** Sample rates for the traces an actor starts, in the shape core takes. */
|
|
715
|
+
interface RuntimeActorTracingConfig {
|
|
716
|
+
sampler?: number;
|
|
717
|
+
/** Keyed by flattened, dot-separated action name. */
|
|
718
|
+
actions?: Record<string, number>;
|
|
1140
719
|
}
|
|
1141
|
-
interface
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
720
|
+
interface RuntimeActorConfig {
|
|
721
|
+
name?: string;
|
|
722
|
+
icon?: string;
|
|
723
|
+
hasDatabase?: boolean;
|
|
724
|
+
remoteSqlite?: boolean;
|
|
725
|
+
sqliteDeferredCommits?: boolean;
|
|
726
|
+
sqliteProfiling?: SqliteProfilingOptions;
|
|
727
|
+
tracing?: RuntimeActorTracingConfig;
|
|
728
|
+
enableActorRuntimeSocket?: boolean;
|
|
729
|
+
hasState?: boolean;
|
|
730
|
+
canHibernateWebsocket?: boolean;
|
|
731
|
+
stateSaveIntervalMs?: number;
|
|
732
|
+
createStateTimeoutMs?: number;
|
|
733
|
+
onCreateTimeoutMs?: number;
|
|
734
|
+
createVarsTimeoutMs?: number;
|
|
735
|
+
createConnStateTimeoutMs?: number;
|
|
736
|
+
onBeforeConnectTimeoutMs?: number;
|
|
737
|
+
onConnectTimeoutMs?: number;
|
|
738
|
+
onMigrateTimeoutMs?: number;
|
|
739
|
+
onWakeTimeoutMs?: number;
|
|
740
|
+
onBeforeActorStartTimeoutMs?: number;
|
|
741
|
+
actionTimeoutMs?: number;
|
|
742
|
+
onRequestTimeoutMs?: number;
|
|
743
|
+
sleepTimeoutMs?: number;
|
|
744
|
+
noSleep?: boolean;
|
|
745
|
+
sleepGracePeriodMs?: number;
|
|
746
|
+
connectionLivenessTimeoutMs?: number;
|
|
747
|
+
connectionLivenessIntervalMs?: number;
|
|
748
|
+
maxQueueSize?: number;
|
|
749
|
+
maxSchedules?: number;
|
|
750
|
+
maxQueueMessageSize?: number;
|
|
751
|
+
maxIncomingMessageSize?: number;
|
|
752
|
+
maxOutgoingMessageSize?: number;
|
|
753
|
+
preloadMaxWorkflowBytes?: number;
|
|
754
|
+
preloadMaxConnectionsBytes?: number;
|
|
755
|
+
actions?: Array<{
|
|
756
|
+
name: string;
|
|
757
|
+
}>;
|
|
758
|
+
inspectorTabs?: Array<RuntimeInspectorTabEntry>;
|
|
1145
759
|
}
|
|
1146
|
-
interface
|
|
1147
|
-
|
|
1148
|
-
|
|
760
|
+
interface RuntimeInspectorTabEntry {
|
|
761
|
+
id: string;
|
|
762
|
+
/** Required for custom entries; omitted for built-in hides. */
|
|
763
|
+
label?: string;
|
|
764
|
+
/**
|
|
765
|
+
* Required for custom entries — absolute path to the source directory.
|
|
766
|
+
* Resolved on the TS side before being handed to the runtime.
|
|
767
|
+
*/
|
|
768
|
+
source?: string;
|
|
769
|
+
/** Optional icon id for custom entries. */
|
|
770
|
+
icon?: string;
|
|
771
|
+
/** Set to true for built-in hide entries. */
|
|
772
|
+
hidden?: boolean;
|
|
1149
773
|
}
|
|
1150
|
-
interface
|
|
1151
|
-
|
|
1152
|
-
|
|
774
|
+
interface RuntimeServeConfig {
|
|
775
|
+
version: number;
|
|
776
|
+
endpoint: string;
|
|
777
|
+
token?: string;
|
|
778
|
+
namespace: string;
|
|
779
|
+
poolName: string;
|
|
780
|
+
engineBinaryPath?: string;
|
|
781
|
+
startServices?: boolean;
|
|
782
|
+
servicesBinaryPath?: string;
|
|
783
|
+
engineHost?: string;
|
|
784
|
+
enginePort?: number;
|
|
785
|
+
handleInspectorHttpInRuntime?: boolean;
|
|
786
|
+
inspectorTestToken?: string;
|
|
787
|
+
serverlessBasePath?: string;
|
|
788
|
+
serverlessPackageVersion: string;
|
|
789
|
+
serverlessClientEndpoint?: string;
|
|
790
|
+
serverlessClientNamespace?: string;
|
|
791
|
+
serverlessClientToken?: string;
|
|
792
|
+
serverlessValidateEndpoint: boolean;
|
|
793
|
+
serverlessMaxStartPayloadBytes: number;
|
|
1153
794
|
}
|
|
1154
|
-
interface
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
795
|
+
interface RuntimeListenerConfig {
|
|
796
|
+
port: number;
|
|
797
|
+
host?: string;
|
|
798
|
+
publicDir?: string;
|
|
799
|
+
application?: RuntimeApplicationFetch;
|
|
1158
800
|
}
|
|
1159
|
-
interface
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
801
|
+
interface RuntimeServerlessRequest {
|
|
802
|
+
method: string;
|
|
803
|
+
url: string;
|
|
804
|
+
headers: Record<string, string>;
|
|
805
|
+
body: RuntimeBytes;
|
|
1163
806
|
}
|
|
1164
|
-
interface
|
|
1165
|
-
|
|
1166
|
-
next<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextOptions<TName, TCompletable>): Promise<any>;
|
|
1167
|
-
nextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextBatchOptions<TName, TCompletable>): Promise<any[]>;
|
|
1168
|
-
waitForNames<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(names: readonly TName[], opts?: QueueWaitOptions<TCompletable>): Promise<any>;
|
|
1169
|
-
/** @experimental */
|
|
1170
|
-
waitForAvailable<const TName extends QueueFilterName<TQueues>>(names?: readonly TName[], opts?: Omit<QueueWaitOptions<false>, "completable">): Promise<void>;
|
|
1171
|
-
/** @experimental */
|
|
1172
|
-
complete<const TName extends QueueFilterName<TQueues>>(message: {
|
|
1173
|
-
id: bigint;
|
|
1174
|
-
name: TName;
|
|
1175
|
-
}, ...args: QueueCompleteArgsForName<TQueues, TName>): Promise<void>;
|
|
1176
|
-
enqueueAndWait<const TName extends QueueFilterName<TQueues>>(name: TName, body: QueueMessageForName<TQueues, TName>["body"], opts?: QueueEnqueueAndWaitOptions): Promise<QueueCompletionResultForName<TQueues, TName>>;
|
|
1177
|
-
tryNext<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextOptions<TName, TCompletable>): Promise<any>;
|
|
1178
|
-
tryNextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextBatchOptions<TName, TCompletable>): Promise<any[]>;
|
|
1179
|
-
iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
|
|
1180
|
-
[key: string]: any;
|
|
807
|
+
interface RuntimeApplicationRequest extends RuntimeServerlessRequest {
|
|
808
|
+
cancelToken?: CancellationTokenHandle;
|
|
1181
809
|
}
|
|
1182
|
-
interface
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
send(name: string, ...args: any[]): void;
|
|
1188
|
-
disconnect(reason?: string): Promise<void>;
|
|
1189
|
-
[key: string]: any;
|
|
810
|
+
interface RuntimeApplicationResponse {
|
|
811
|
+
status: number;
|
|
812
|
+
headers: Record<string, string>;
|
|
813
|
+
body?: RuntimeBytes;
|
|
814
|
+
stream?: boolean;
|
|
1190
815
|
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
[RAW_STATE_SYMBOL](): TState;
|
|
1195
|
-
state: TState;
|
|
1196
|
-
vars: TVars;
|
|
1197
|
-
/**
|
|
1198
|
-
* @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db`)
|
|
1199
|
-
* or actor state instead.
|
|
1200
|
-
*/
|
|
1201
|
-
readonly kv: ActorKv;
|
|
1202
|
-
readonly db: InferDatabaseClient<TDatabase>;
|
|
1203
|
-
readonly schedule: ActorSchedule;
|
|
1204
|
-
readonly cron: ActorCron;
|
|
1205
|
-
readonly queue: ActorQueue<TQueues>;
|
|
1206
|
-
/** @experimental */
|
|
1207
|
-
readonly run: ActorRun;
|
|
1208
|
-
readonly actorId: string;
|
|
1209
|
-
readonly name: string;
|
|
1210
|
-
readonly key: string[];
|
|
1211
|
-
readonly region: string;
|
|
1212
|
-
/** Provisions the experimental Actor Runtime Socket for this actor generation. */
|
|
1213
|
-
actorRuntimeSocket(): Promise<{
|
|
1214
|
-
path: string;
|
|
1215
|
-
}>;
|
|
1216
|
-
readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
|
|
1217
|
-
readonly log: ActorLogger;
|
|
1218
|
-
readonly abortSignal: AbortSignal;
|
|
1219
|
-
readonly aborted: boolean;
|
|
1220
|
-
readonly request?: Request;
|
|
1221
|
-
/** @deprecated No-op. Always returns `false`. Use `keepAwake(promise)` or `waitUntil(promise)` instead. Will be removed in 2.2.0. */
|
|
1222
|
-
readonly preventSleep: boolean;
|
|
1223
|
-
broadcast(name: string, ...args: any[]): void;
|
|
1224
|
-
saveState(opts?: {
|
|
1225
|
-
immediate?: boolean;
|
|
1226
|
-
maxWait?: number;
|
|
1227
|
-
}): Promise<void>;
|
|
1228
|
-
keepAwake<T>(promise: Promise<T>): Promise<T>;
|
|
1229
|
-
waitUntil(promise: Promise<unknown>): void;
|
|
1230
|
-
/** @deprecated No-op. Use `keepAwake(promise)` to hold the actor awake for a specific promise. Will be removed in 2.2.0. */
|
|
1231
|
-
setPreventSleep(preventSleep: boolean): void;
|
|
1232
|
-
sleep(): void;
|
|
1233
|
-
destroy(): void;
|
|
1234
|
-
client<T = any>(): ActorClientFor<T>;
|
|
1235
|
-
[key: string]: any;
|
|
816
|
+
type RuntimeApplicationFetch = (request: RuntimeApplicationRequest, responseBodyStream?: RuntimeHttpResponseBodyStream) => Promise<RuntimeApplicationResponse>;
|
|
817
|
+
interface RuntimeApplicationListenerConfig extends RuntimeListenerConfig {
|
|
818
|
+
application: RuntimeApplicationFetch;
|
|
1236
819
|
}
|
|
1237
|
-
interface
|
|
1238
|
-
|
|
1239
|
-
|
|
820
|
+
interface RuntimeServerlessResponseHead {
|
|
821
|
+
status: number;
|
|
822
|
+
headers: Record<string, string>;
|
|
1240
823
|
}
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
type
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
type CreateVarsContext<TState, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = CreateContext<TState, TInput, TDatabase, TEvents, TQueues>;
|
|
1250
|
-
type DestroyContext<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>;
|
|
1251
|
-
type DisconnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1252
|
-
type RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1253
|
-
type RunContext<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>;
|
|
1254
|
-
type SleepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1255
|
-
type StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1256
|
-
type WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1257
|
-
type MigrateContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1258
|
-
type WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1259
|
-
type InspectorUnsubscribe = () => void;
|
|
1260
|
-
declare const RunConfigSchema: z.ZodObject<{
|
|
1261
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1262
|
-
icon: z.ZodOptional<z.ZodString>;
|
|
1263
|
-
run: z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>;
|
|
1264
|
-
inspector: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1265
|
-
workflow: z.ZodOptional<z.ZodObject<{
|
|
1266
|
-
getHistory: z.ZodCustom<() => unknown, () => unknown>;
|
|
1267
|
-
getState: z.ZodOptional<z.ZodCustom<() => Promise<WorkflowState | null>, () => Promise<WorkflowState | null>>>;
|
|
1268
|
-
onHistoryUpdated: z.ZodOptional<z.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
|
|
1269
|
-
replayFromStep: z.ZodOptional<z.ZodCustom<(entryId?: string) => Promise<unknown>, (entryId?: string) => Promise<unknown>>>;
|
|
1270
|
-
}, z.core.$strip>>;
|
|
1271
|
-
}, z.core.$strip>>>;
|
|
1272
|
-
}, z.core.$strip>;
|
|
1273
|
-
type RunConfigRuntime = z.infer<typeof RunConfigSchema>;
|
|
1274
|
-
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"> & {
|
|
1275
|
-
run: (c: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
1276
|
-
};
|
|
1277
|
-
declare const ActorConfigSchema: z.ZodObject<{
|
|
1278
|
-
onCreate: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1279
|
-
onDestroy: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1280
|
-
onMigrate: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1281
|
-
onWake: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1282
|
-
onSleep: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1283
|
-
run: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>, z.ZodObject<{
|
|
1284
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1285
|
-
icon: z.ZodOptional<z.ZodString>;
|
|
1286
|
-
run: z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>;
|
|
1287
|
-
inspector: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1288
|
-
workflow: z.ZodOptional<z.ZodObject<{
|
|
1289
|
-
getHistory: z.ZodCustom<() => unknown, () => unknown>;
|
|
1290
|
-
getState: z.ZodOptional<z.ZodCustom<() => Promise<WorkflowState | null>, () => Promise<WorkflowState | null>>>;
|
|
1291
|
-
onHistoryUpdated: z.ZodOptional<z.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
|
|
1292
|
-
replayFromStep: z.ZodOptional<z.ZodCustom<(entryId?: string) => Promise<unknown>, (entryId?: string) => Promise<unknown>>>;
|
|
1293
|
-
}, z.core.$strip>>;
|
|
1294
|
-
}, z.core.$strip>>>;
|
|
1295
|
-
}, z.core.$strip>]>>;
|
|
1296
|
-
onStateChange: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1297
|
-
onBeforeConnect: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1298
|
-
onConnect: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1299
|
-
onDisconnect: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1300
|
-
onBeforeActionResponse: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1301
|
-
onRequest: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1302
|
-
onWebSocket: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1303
|
-
actions: z.ZodDefault<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
1304
|
-
actionInputSchemas: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
1305
|
-
connParamsSchema: z.ZodOptional<z.ZodAny>;
|
|
1306
|
-
events: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
1307
|
-
queues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
1308
|
-
state: z.ZodOptional<z.ZodAny>;
|
|
1309
|
-
createState: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1310
|
-
connState: z.ZodOptional<z.ZodAny>;
|
|
1311
|
-
createConnState: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1312
|
-
vars: z.ZodOptional<z.ZodAny>;
|
|
1313
|
-
db: z.ZodOptional<z.ZodAny>;
|
|
1314
|
-
createVars: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1315
|
-
options: z.ZodPrefault<z.ZodObject<{
|
|
1316
|
-
name: z.ZodOptional<z.ZodString>;
|
|
1317
|
-
icon: z.ZodOptional<z.ZodString>;
|
|
1318
|
-
enableActorRuntimeSocket: z.ZodDefault<z.ZodBoolean>;
|
|
1319
|
-
canHibernateWebSocket: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodCustom<(request: Request) => boolean, (request: Request) => boolean>]>>;
|
|
1320
|
-
createVarsTimeout: z.ZodDefault<z.ZodNumber>;
|
|
1321
|
-
createConnStateTimeout: z.ZodDefault<z.ZodNumber>;
|
|
1322
|
-
onBeforeConnectTimeout: z.ZodDefault<z.ZodNumber>;
|
|
1323
|
-
onConnectTimeout: z.ZodDefault<z.ZodNumber>;
|
|
1324
|
-
onMigrateTimeout: z.ZodDefault<z.ZodNumber>;
|
|
1325
|
-
sleepGracePeriod: z.ZodDefault<z.ZodNumber>;
|
|
1326
|
-
onDestroyTimeout: z.ZodOptional<z.ZodNumber>;
|
|
1327
|
-
waitUntilTimeout: z.ZodOptional<z.ZodNumber>;
|
|
1328
|
-
stateSaveInterval: z.ZodDefault<z.ZodNumber>;
|
|
1329
|
-
actionTimeout: z.ZodDefault<z.ZodNumber>;
|
|
1330
|
-
connectionLivenessTimeout: z.ZodDefault<z.ZodNumber>;
|
|
1331
|
-
connectionLivenessInterval: z.ZodDefault<z.ZodNumber>;
|
|
1332
|
-
noSleep: z.ZodDefault<z.ZodBoolean>;
|
|
1333
|
-
sleepTimeout: z.ZodDefault<z.ZodNumber>;
|
|
1334
|
-
maxQueueSize: z.ZodDefault<z.ZodNumber>;
|
|
1335
|
-
maxSchedules: z.ZodDefault<z.ZodNumber>;
|
|
1336
|
-
maxQueueMessageSize: z.ZodDefault<z.ZodNumber>;
|
|
1337
|
-
preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
|
|
1338
|
-
preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
|
|
1339
|
-
}, z.core.$strict>>;
|
|
1340
|
-
inspector: z.ZodOptional<z.ZodObject<{
|
|
1341
|
-
tabs: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
1342
|
-
id: z.ZodString;
|
|
1343
|
-
label: z.ZodString;
|
|
1344
|
-
source: z.ZodString;
|
|
1345
|
-
icon: z.ZodOptional<z.ZodString>;
|
|
1346
|
-
hidden: z.ZodOptional<z.ZodLiteral<false>>;
|
|
1347
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1348
|
-
id: z.ZodEnum<{
|
|
1349
|
-
state: "state";
|
|
1350
|
-
database: "database";
|
|
1351
|
-
workflow: "workflow";
|
|
1352
|
-
queue: "queue";
|
|
1353
|
-
schedules: "schedules";
|
|
1354
|
-
connections: "connections";
|
|
1355
|
-
console: "console";
|
|
1356
|
-
}>;
|
|
1357
|
-
hidden: z.ZodLiteral<true>;
|
|
1358
|
-
}, z.core.$strict>]>>>;
|
|
1359
|
-
}, z.core.$strict>>;
|
|
1360
|
-
}, z.core.$strict>;
|
|
1361
|
-
type CreateState<TState, _TConnParams, _TConnState, _TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
1362
|
-
state: TState;
|
|
824
|
+
interface RuntimeRegistryRouteResponse {
|
|
825
|
+
status: number;
|
|
826
|
+
headers: Record<string, string>;
|
|
827
|
+
body: RuntimeBytes;
|
|
828
|
+
}
|
|
829
|
+
type RuntimeServerlessStreamEvent = {
|
|
830
|
+
kind: "chunk";
|
|
831
|
+
chunk?: RuntimeBytes;
|
|
1363
832
|
} | {
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
833
|
+
kind: "end";
|
|
834
|
+
error?: {
|
|
835
|
+
group: string;
|
|
836
|
+
code: string;
|
|
837
|
+
message: string;
|
|
838
|
+
};
|
|
839
|
+
};
|
|
840
|
+
type RuntimeServerlessStreamCallback = (error: unknown, event?: RuntimeServerlessStreamEvent) => unknown;
|
|
841
|
+
type RuntimeWebSocketEvent = {
|
|
842
|
+
kind: "message";
|
|
843
|
+
data: string | RuntimeBytes;
|
|
844
|
+
binary: boolean;
|
|
845
|
+
messageIndex?: number;
|
|
1368
846
|
} | {
|
|
1369
|
-
|
|
1370
|
-
|
|
847
|
+
kind: "close";
|
|
848
|
+
code: number;
|
|
849
|
+
reason: string;
|
|
850
|
+
wasClean: boolean;
|
|
851
|
+
};
|
|
852
|
+
interface CoreRuntime {
|
|
853
|
+
readonly kind: "napi" | "wasm";
|
|
854
|
+
createRegistry(): RegistryHandle;
|
|
855
|
+
registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
|
|
856
|
+
serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
|
|
857
|
+
waitRegistryReady(registry: RegistryHandle): Promise<void>;
|
|
858
|
+
shutdownRegistry(registry: RegistryHandle): Promise<void>;
|
|
859
|
+
shutdownTelemetry?(): Promise<void>;
|
|
860
|
+
registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
|
|
861
|
+
handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
|
|
862
|
+
serveListener(registry: RegistryHandle, listener: RuntimeListenerConfig, config: RuntimeServeConfig): Promise<void>;
|
|
863
|
+
serveApplicationListener(registry: RegistryHandle, listener: RuntimeApplicationListenerConfig, config: RuntimeServeConfig): Promise<void>;
|
|
864
|
+
registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
865
|
+
registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
866
|
+
registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
867
|
+
createActorFactory(callbacks: object, config?: RuntimeActorConfig | undefined | null): ActorFactoryHandle;
|
|
868
|
+
createCancellationToken(): CancellationTokenHandle;
|
|
869
|
+
cancellationTokenAborted(token: CancellationTokenHandle): boolean;
|
|
870
|
+
cancelCancellationToken(token: CancellationTokenHandle): void;
|
|
871
|
+
onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): void;
|
|
872
|
+
actorState(ctx: ActorContextHandle): RuntimeBytes;
|
|
873
|
+
actorBeginOnStateChange(ctx: ActorContextHandle): void;
|
|
874
|
+
actorEndOnStateChange(ctx: ActorContextHandle): void;
|
|
875
|
+
actorSetAlarm(ctx: ActorContextHandle, timestampMs?: number | undefined | null): void;
|
|
876
|
+
actorSetRunWakeAt(ctx: ActorContextHandle, timestampMs?: number | undefined | null): Promise<void>;
|
|
877
|
+
actorRequestSave(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): void;
|
|
878
|
+
actorRequestSaveAndWait(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): Promise<void>;
|
|
879
|
+
actorInspectorSnapshot(ctx: ActorContextHandle): RuntimeInspectorSnapshot;
|
|
880
|
+
actorDecodeInspectorRequest(ctx: ActorContextHandle, bytes: RuntimeBytes, advertisedVersion: number): RuntimeBytes;
|
|
881
|
+
actorEncodeInspectorResponse(ctx: ActorContextHandle, bytes: RuntimeBytes, targetVersion: number): RuntimeBytes;
|
|
882
|
+
actorVerifyInspectorAuth(ctx: ActorContextHandle, bearerToken?: string | undefined | null): Promise<void>;
|
|
883
|
+
actorQueueHibernationRemoval(ctx: ActorContextHandle, connId: string): void;
|
|
884
|
+
actorTakePendingHibernationChanges(ctx: ActorContextHandle): string[];
|
|
885
|
+
actorDirtyHibernatableConns(ctx: ActorContextHandle): ConnHandle[];
|
|
886
|
+
actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
887
|
+
actorSaveStateAndWorkflowBatch(ctx: ActorContextHandle, writes: RuntimeWorkflowKvWrite[]): Promise<void>;
|
|
888
|
+
actorId(ctx: ActorContextHandle): string;
|
|
889
|
+
/**
|
|
890
|
+
* Runs one actor callback with `ctx` as the current invocation: operations
|
|
891
|
+
* on retained handles for the same actor resolve to it, and its Core span
|
|
892
|
+
* is the active OpenTelemetry span for the duration of `run`. Only actions,
|
|
893
|
+
* raw requests, and queue dispatch run this way; other callbacks have no
|
|
894
|
+
* invocation span.
|
|
895
|
+
*/
|
|
896
|
+
runWithActorInvocationContext<T>(ctx: ActorContextHandle, run: () => T): T;
|
|
897
|
+
/**
|
|
898
|
+
* Correlation of the invocation currently executing for this actor, or
|
|
899
|
+
* `undefined` outside an invocation or after it finished. A sampled-out
|
|
900
|
+
* invocation can still expose valid span context for propagation.
|
|
901
|
+
*/
|
|
902
|
+
actorInvocationTraceContext(ctx: ActorContextHandle): ActorInvocationTraceContext | undefined;
|
|
903
|
+
/**
|
|
904
|
+
* Opens the span covering one call this actor makes to another actor. See
|
|
905
|
+
* `StartCallSpan` for when this returns nothing.
|
|
906
|
+
*/
|
|
907
|
+
startCallSpan(ctx: ActorContextHandle, actorName: string, actionName: string): RuntimeOutboundCall | undefined;
|
|
908
|
+
/** Backs `ActorRun.startWorkflowSpan`. */
|
|
909
|
+
startWorkflowSpan(ctx: ActorContextHandle): Promise<WorkflowSpan>;
|
|
910
|
+
/** Backs `ActorRun.runOutsideWorkflowSpan`. */
|
|
911
|
+
runOutsideActorInvocationContext<T>(run: () => T): T;
|
|
912
|
+
/** Identity of the invocation the caller runs in, usable as a cache key. */
|
|
913
|
+
currentInvocationScope(): object | undefined;
|
|
914
|
+
actorName(ctx: ActorContextHandle): string;
|
|
915
|
+
actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
|
|
916
|
+
actorRegion(ctx: ActorContextHandle): string;
|
|
917
|
+
actorSleep(ctx: ActorContextHandle): void;
|
|
918
|
+
actorDestroy(ctx: ActorContextHandle): void;
|
|
919
|
+
actorAbortSignal(ctx: ActorContextHandle): AbortSignal;
|
|
920
|
+
actorConns(ctx: ActorContextHandle): ConnHandle[];
|
|
921
|
+
actorConnectConn(ctx: ActorContextHandle, params: RuntimeBytes, request?: RuntimeHttpRequest | undefined | null): Promise<ConnHandle>;
|
|
922
|
+
actorBroadcast(ctx: ActorContextHandle, name: string, args: RuntimeBytes): void;
|
|
923
|
+
actorWaitUntil(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
924
|
+
actorWaitForTrackedShutdownWork(ctx: ActorContextHandle): Promise<boolean>;
|
|
925
|
+
actorWaitForTrackedShutdownWorkUnbounded(ctx: ActorContextHandle): Promise<void>;
|
|
926
|
+
actorKeepAwake(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
927
|
+
actorBeginKeepAwake(ctx: ActorContextHandle): number;
|
|
928
|
+
actorEndKeepAwake(ctx: ActorContextHandle, regionId: number): void;
|
|
929
|
+
actorRegisterTask(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
930
|
+
actorRuntimeState(ctx: ActorContextHandle): object;
|
|
931
|
+
actorClearRuntimeState(ctx: ActorContextHandle): void;
|
|
932
|
+
actorRestartRunHandler(ctx: ActorContextHandle): void;
|
|
933
|
+
actorBeginWebsocketCallback(ctx: ActorContextHandle): number;
|
|
934
|
+
actorEndWebsocketCallback(ctx: ActorContextHandle, regionId: number): void;
|
|
935
|
+
actorKvGet(ctx: ActorContextHandle, key: RuntimeBytes): Promise<RuntimeBytes | null>;
|
|
936
|
+
actorKvPut(ctx: ActorContextHandle, key: RuntimeBytes, value: RuntimeBytes): Promise<void>;
|
|
937
|
+
actorKvDelete(ctx: ActorContextHandle, key: RuntimeBytes): Promise<void>;
|
|
938
|
+
actorKvDeleteRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes): Promise<void>;
|
|
939
|
+
actorKvListPrefix(ctx: ActorContextHandle, prefix: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
|
|
940
|
+
actorKvListRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
|
|
941
|
+
actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
|
|
942
|
+
actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
|
|
943
|
+
actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
|
|
944
|
+
actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
945
|
+
actorSqlExecSync(ctx: ActorContextHandle, sql: string): RuntimeSqlExecResult;
|
|
946
|
+
actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
947
|
+
actorSqlExecuteSync(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): RuntimeSqlExecuteResult;
|
|
948
|
+
actorSqlExecuteBatch(ctx: ActorContextHandle, statements: RuntimeSqlBatchStatement[]): Promise<RuntimeSqlExecuteResult[]>;
|
|
949
|
+
actorSqlBeginTransaction(ctx: ActorContextHandle, timeoutMs?: number, name?: string): Promise<SqliteTransactionHandle>;
|
|
950
|
+
actorSqlBeginTransactionSync(ctx: ActorContextHandle, timeoutMs?: number, name?: string): SqliteTransactionHandle;
|
|
951
|
+
actorSqlTransactionExec(transaction: SqliteTransactionHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
952
|
+
actorSqlTransactionExecSync(transaction: SqliteTransactionHandle, sql: string): RuntimeSqlExecResult;
|
|
953
|
+
actorSqlTransactionExecute(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
954
|
+
actorSqlTransactionExecuteSync(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): RuntimeSqlExecuteResult;
|
|
955
|
+
actorSqlTransactionCommit(transaction: SqliteTransactionHandle): Promise<void>;
|
|
956
|
+
actorSqlTransactionCommitSync(transaction: SqliteTransactionHandle): void;
|
|
957
|
+
actorSqlTransactionRollback(transaction: SqliteTransactionHandle): Promise<void>;
|
|
958
|
+
actorSqlTransactionRollbackSync(transaction: SqliteTransactionHandle): void;
|
|
959
|
+
actorBeginStateTransaction(ctx: ActorContextHandle, timeoutMs?: number): Promise<ActorStateTransactionHandle>;
|
|
960
|
+
actorStateTransactionExecute(transaction: ActorStateTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
961
|
+
actorStateTransactionCommit(transaction: ActorStateTransactionHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
962
|
+
actorStateTransactionRollback(transaction: ActorStateTransactionHandle): Promise<void>;
|
|
963
|
+
actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
|
|
964
|
+
actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
|
|
965
|
+
actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
|
|
966
|
+
actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
|
|
967
|
+
/** Opens the actor database so later synchronous calls never fetch its first pages. */
|
|
968
|
+
actorSqlOpen(ctx: ActorContextHandle): Promise<void>;
|
|
969
|
+
/** Returns the ticket of the latest local commit. */
|
|
970
|
+
actorSqlCommitTicket(ctx: ActorContextHandle): number;
|
|
971
|
+
/** Resolves once the commit `ticket` names and every earlier commit are durable. */
|
|
972
|
+
actorSqlWhenDurable(ctx: ActorContextHandle, ticket: number): Promise<void>;
|
|
973
|
+
actorSqlAbortGeneration(ctx: ActorContextHandle, reason: string): void;
|
|
974
|
+
actorSqlClose(ctx: ActorContextHandle): Promise<void>;
|
|
975
|
+
actorRuntimeSocketProvision(ctx: ActorContextHandle): Promise<RuntimeActorRuntimeSocketEndpointInfo>;
|
|
976
|
+
actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
|
|
977
|
+
actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
|
|
978
|
+
actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
|
|
979
|
+
actorQueueWaitForNamesAvailable(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<void>;
|
|
980
|
+
actorQueueCompletePersisted(ctx: ActorContextHandle, messageId: bigint, expectedName: string, response?: RuntimeBytes | undefined | null): Promise<boolean>;
|
|
981
|
+
actorQueueEnqueueAndWait(ctx: ActorContextHandle, name: string, body: RuntimeBytes, options?: RuntimeQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeBytes | null>;
|
|
982
|
+
actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
|
|
983
|
+
actorQueueMaxSize(ctx: ActorContextHandle): number;
|
|
984
|
+
actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
|
|
985
|
+
actorQueueReset(ctx: ActorContextHandle): Promise<void>;
|
|
986
|
+
actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
|
|
987
|
+
actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
|
|
988
|
+
actorScheduleCancel(ctx: ActorContextHandle, id: string): Promise<boolean>;
|
|
989
|
+
actorScheduleGet(ctx: ActorContextHandle, id: string): Promise<RuntimeScheduledEventInfo | undefined>;
|
|
990
|
+
actorScheduleList(ctx: ActorContextHandle): Promise<RuntimeScheduledEventInfo[]>;
|
|
991
|
+
actorCronSet(ctx: ActorContextHandle, name: string, expression: string, timezone: string | undefined, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
|
|
992
|
+
actorCronEvery(ctx: ActorContextHandle, name: string, intervalMs: number, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
|
|
993
|
+
actorCronGet(ctx: ActorContextHandle, name: string): Promise<RuntimeCronJobInfo | undefined>;
|
|
994
|
+
actorCronList(ctx: ActorContextHandle): Promise<RuntimeCronJobInfo[]>;
|
|
995
|
+
actorCronDelete(ctx: ActorContextHandle, name: string): Promise<boolean>;
|
|
996
|
+
actorCronHistory(ctx: ActorContextHandle, name: string, limit: number | undefined): Promise<RuntimeCronFire[]>;
|
|
997
|
+
connId(conn: ConnHandle): string;
|
|
998
|
+
connParams(conn: ConnHandle): RuntimeBytes;
|
|
999
|
+
connState(conn: ConnHandle): RuntimeBytes;
|
|
1000
|
+
connSetState(conn: ConnHandle, state: RuntimeBytes): void;
|
|
1001
|
+
connIsHibernatable(conn: ConnHandle): boolean;
|
|
1002
|
+
connSend(conn: ConnHandle, name: string, args: RuntimeBytes): void;
|
|
1003
|
+
connDisconnect(conn: ConnHandle, reason?: string | undefined | null): Promise<void>;
|
|
1004
|
+
webSocketSend(ws: WebSocketHandle, data: RuntimeBytes, binary: boolean): void;
|
|
1005
|
+
webSocketClose(ws: WebSocketHandle, code?: number | undefined | null, reason?: string | undefined | null): Promise<void>;
|
|
1006
|
+
webSocketSetEventCallback(ws: WebSocketHandle, callback: (event: RuntimeWebSocketEvent) => void): void;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
interface QueueSendWaitOptions {
|
|
1010
|
+
wait: true;
|
|
1011
|
+
timeout?: number;
|
|
1012
|
+
signal?: AbortSignal;
|
|
1013
|
+
}
|
|
1014
|
+
interface QueueSendNoWaitOptions {
|
|
1015
|
+
wait?: false;
|
|
1016
|
+
timeout?: never;
|
|
1017
|
+
signal?: AbortSignal;
|
|
1018
|
+
}
|
|
1019
|
+
interface QueueSendResult<TResponse = unknown> {
|
|
1020
|
+
status: "completed" | "timedOut";
|
|
1021
|
+
response?: TResponse;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1371
1024
|
/**
|
|
1372
|
-
*
|
|
1025
|
+
* Action function returned by Actor connections and handles.
|
|
1026
|
+
*
|
|
1027
|
+
* @typedef {Function} ActorActionFunction
|
|
1028
|
+
* @template Args
|
|
1029
|
+
* @template Response
|
|
1030
|
+
* @param {...Args} args - Arguments for the action function.
|
|
1031
|
+
* @returns {Promise<Response>}
|
|
1373
1032
|
*/
|
|
1374
|
-
type
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1386
|
-
[Action: string]: ((c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any) | Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1033
|
+
type ActorActionFunction<Args extends Array<unknown> = unknown[], Response = unknown> = (...args: Args extends [unknown, ...infer Rest] ? Rest : Args) => Promise<Response>;
|
|
1034
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
1035
|
+
type LooseEventSubscribe = (eventName: string, callback: (...args: any[]) => void) => () => void;
|
|
1036
|
+
type ActorActionMap<R> = {
|
|
1037
|
+
[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;
|
|
1038
|
+
};
|
|
1039
|
+
type ActionsOf<AD extends AnyActorDefinition> = AD["config"] extends {
|
|
1040
|
+
actions?: infer R;
|
|
1041
|
+
} ? R : never;
|
|
1042
|
+
interface ActorGatewayOptions {
|
|
1043
|
+
skipReadyWait?: boolean;
|
|
1387
1044
|
}
|
|
1388
|
-
interface
|
|
1389
|
-
|
|
1045
|
+
interface ActorActionOptions extends ActorGatewayOptions {
|
|
1046
|
+
signal?: AbortSignal;
|
|
1390
1047
|
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1048
|
+
type ActorConnectOptions = ActorGatewayOptions;
|
|
1049
|
+
type ActorFetchInit = RequestInit & ActorGatewayOptions;
|
|
1050
|
+
type ActorWebSocketOptions = ActorGatewayOptions;
|
|
1051
|
+
/**
|
|
1052
|
+
* Maps action methods from actor definition to typed function signatures.
|
|
1053
|
+
*/
|
|
1054
|
+
type ActorDefinitionActions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? Record<string, ActorActionFunction<any[], any>> : ActorActionMap<ActionsOf<AD>>;
|
|
1055
|
+
type ActorQueueSend<TQueues extends QueueSchemaConfig> = {
|
|
1056
|
+
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options: QueueSendWaitOptions): Promise<QueueSendResult<InferQueueCompleteMap<TQueues>[K]>>;
|
|
1057
|
+
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K], options?: QueueSendNoWaitOptions): Promise<void>;
|
|
1058
|
+
(name: keyof TQueues extends never ? string : never, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
1059
|
+
(name: keyof TQueues extends never ? string : never, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
1060
|
+
};
|
|
1061
|
+
type ActorEventSubscribe<TEvents extends EventSchemaConfig> = {
|
|
1062
|
+
<K extends keyof TEvents & string>(eventName: K, callback: (...args: InferEventArgs<InferSchemaMap<TEvents>[K]>) => void): () => void;
|
|
1063
|
+
(eventName: keyof TEvents extends never ? string : never, callback: (...args: any[]) => void): () => void;
|
|
1064
|
+
};
|
|
1065
|
+
type ActorDefinitionQueueSend<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
1066
|
+
send: ActorQueueSend<Record<string, any>>;
|
|
1067
|
+
} : AD extends {
|
|
1068
|
+
config: {
|
|
1069
|
+
queues?: infer Q;
|
|
1070
|
+
};
|
|
1071
|
+
} ? Q extends QueueSchemaConfig ? {
|
|
1072
|
+
send: ActorQueueSend<Q>;
|
|
1073
|
+
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, any, infer Q, any> ? Q extends QueueSchemaConfig ? {
|
|
1074
|
+
send: ActorQueueSend<Q>;
|
|
1075
|
+
} : {} : {};
|
|
1076
|
+
type ActorDefinitionEventSubscriptions<AD extends AnyActorDefinition> = IsAny<AD> extends true ? {
|
|
1077
|
+
on: LooseEventSubscribe;
|
|
1078
|
+
once: LooseEventSubscribe;
|
|
1079
|
+
} : AD extends {
|
|
1080
|
+
config: {
|
|
1081
|
+
events?: infer E;
|
|
1082
|
+
};
|
|
1083
|
+
} ? E extends EventSchemaConfig ? {
|
|
1084
|
+
on: ActorEventSubscribe<E>;
|
|
1085
|
+
once: ActorEventSubscribe<E>;
|
|
1086
|
+
} : {} : AD extends BaseActorDefinition<any, any, any, any, any, any, infer E, any, any> ? E extends EventSchemaConfig ? {
|
|
1087
|
+
on: ActorEventSubscribe<E>;
|
|
1088
|
+
once: ActorEventSubscribe<E>;
|
|
1089
|
+
} : {} : {};
|
|
1090
|
+
|
|
1091
|
+
declare class ActorClientError extends Error {
|
|
1092
|
+
}
|
|
1093
|
+
declare class ManagerError extends ActorClientError {
|
|
1094
|
+
constructor(error: string, opts?: ErrorOptions);
|
|
1095
|
+
}
|
|
1096
|
+
declare class MalformedResponseMessage extends ActorClientError {
|
|
1097
|
+
constructor(cause?: unknown);
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
declare class ActorConnDisposed extends ActorClientError {
|
|
1101
|
+
constructor();
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
type ActorResolutionState = ActorQuery;
|
|
1105
|
+
|
|
1106
|
+
/**
|
|
1107
|
+
* Connection status for an actor connection.
|
|
1108
|
+
*
|
|
1109
|
+
* - `"idle"`: Not connected, no auto-reconnect (initial state, after dispose, or disabled)
|
|
1110
|
+
* - `"connecting"`: Attempting to establish connection
|
|
1111
|
+
* - `"connected"`: Connection is active
|
|
1112
|
+
* - `"disconnected"`: Connection was lost, will auto-reconnect
|
|
1113
|
+
*/
|
|
1114
|
+
type ActorConnStatus = "idle" | "connecting" | "connected" | "disconnected";
|
|
1115
|
+
/**
|
|
1116
|
+
* A function that unsubscribes from an event.
|
|
1117
|
+
*
|
|
1118
|
+
* @typedef {Function} EventUnsubscribe
|
|
1119
|
+
*/
|
|
1120
|
+
type EventUnsubscribe = () => void;
|
|
1121
|
+
/**
|
|
1122
|
+
* A function that handles connection errors.
|
|
1123
|
+
*
|
|
1124
|
+
* @typedef {Function} ActorErrorCallback
|
|
1125
|
+
*/
|
|
1126
|
+
type ActorErrorCallback = (error: RivetError) => void;
|
|
1127
|
+
/**
|
|
1128
|
+
* A callback for connection state changes.
|
|
1129
|
+
*
|
|
1130
|
+
* @typedef {Function} ConnectionStateCallback
|
|
1131
|
+
*/
|
|
1132
|
+
type ConnectionStateCallback = () => void;
|
|
1133
|
+
/**
|
|
1134
|
+
* A callback for connection status changes.
|
|
1135
|
+
*
|
|
1136
|
+
* @typedef {Function} StatusChangeCallback
|
|
1137
|
+
*/
|
|
1138
|
+
type StatusChangeCallback = (status: ActorConnStatus) => void;
|
|
1139
|
+
declare const CONNECT_SYMBOL: unique symbol;
|
|
1140
|
+
/**
|
|
1141
|
+
* Provides underlying functions for {@link ActorConn}. See {@link ActorConn} for using type-safe remote procedure calls.
|
|
1142
|
+
*
|
|
1143
|
+
* @see {@link ActorConn}
|
|
1144
|
+
*/
|
|
1145
|
+
declare class ActorConnRaw {
|
|
1146
|
+
#private;
|
|
1430
1147
|
/**
|
|
1431
|
-
*
|
|
1432
|
-
*
|
|
1433
|
-
* Use this for background tasks like:
|
|
1434
|
-
* - Reading from queues in a loop
|
|
1435
|
-
* - Tick loops for periodic work
|
|
1436
|
-
* - Custom workflow logic
|
|
1437
|
-
*
|
|
1438
|
-
* **Important:** The actor may go to sleep at any time during the `run`
|
|
1439
|
-
* handler. Wrap work that must keep the actor awake with
|
|
1440
|
-
* `c.keepAwake(promise)` to block idle sleep and shutdown finalize until
|
|
1441
|
-
* the promise settles, or use `c.waitUntil(promise)` to let the graceful
|
|
1442
|
-
* shutdown window (`sleepGracePeriod`) cover deferred work.
|
|
1443
|
-
*
|
|
1444
|
-
* The handler receives an abort signal via `c.abortSignal` and a
|
|
1445
|
-
* `c.aborted` alias. Use these to gracefully exit when shutdown starts.
|
|
1446
|
-
*
|
|
1447
|
-
* If this handler exits, the actor will follow the normal idle sleep timeout
|
|
1448
|
-
* once it becomes idle.
|
|
1449
|
-
* If this handler throws, the actor logs the error and then sleeps once it
|
|
1450
|
-
* becomes idle.
|
|
1451
|
-
* Call `c.destroy()` explicitly if a run handler should destroy the actor.
|
|
1148
|
+
* Do not call this directly.
|
|
1452
1149
|
*
|
|
1453
|
-
*
|
|
1150
|
+
* Creates an instance of ActorConnRaw.
|
|
1454
1151
|
*
|
|
1455
|
-
* @
|
|
1152
|
+
* @protected
|
|
1456
1153
|
*/
|
|
1457
|
-
|
|
1154
|
+
constructor(client: ClientRaw, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions, currentActorInvocation?: CurrentActorInvocation);
|
|
1155
|
+
send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
1156
|
+
send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
1458
1157
|
/**
|
|
1459
|
-
*
|
|
1460
|
-
*
|
|
1461
|
-
* Use this hook to react to state changes, such as updating
|
|
1462
|
-
* external systems or triggering events.
|
|
1463
|
-
*
|
|
1464
|
-
* State changes made within this hook will NOT trigger
|
|
1465
|
-
* another onStateChange call, preventing infinite recursion.
|
|
1158
|
+
* Call a raw action connection. See {@link ActorConn} for type-safe action calls.
|
|
1466
1159
|
*
|
|
1467
|
-
* @
|
|
1160
|
+
* @see {@link ActorConn}
|
|
1161
|
+
* @template Args - The type of arguments to pass to the action function.
|
|
1162
|
+
* @template Response - The type of the response returned by the action function.
|
|
1163
|
+
* @param {string} name - The name of the action function to call.
|
|
1164
|
+
* @param {...Args} args - The arguments to pass to the action function.
|
|
1165
|
+
* @returns {Promise<Response>} - A promise that resolves to the response of the action function.
|
|
1468
1166
|
*/
|
|
1469
|
-
|
|
1167
|
+
action<Args extends Array<unknown> = unknown[], Response = unknown>(opts: {
|
|
1168
|
+
name: string;
|
|
1169
|
+
args: Args;
|
|
1170
|
+
signal?: AbortSignal;
|
|
1171
|
+
}): Promise<Response>;
|
|
1470
1172
|
/**
|
|
1471
|
-
*
|
|
1472
|
-
*
|
|
1473
|
-
* Use this hook to determine if a connection should be accepted
|
|
1474
|
-
* and to validate client-provided parameters. The pending connection
|
|
1475
|
-
* is not visible in `c.conns` while this hook runs.
|
|
1173
|
+
* Do not call this directly.
|
|
1174
|
+
* Establishes a connection to the server using the specified endpoint & encoding & driver.
|
|
1476
1175
|
*
|
|
1477
|
-
* @
|
|
1478
|
-
* @returns Void or a Promise.
|
|
1479
|
-
* @throws Throw an error to reject the connection
|
|
1176
|
+
* @protected
|
|
1480
1177
|
*/
|
|
1481
|
-
|
|
1178
|
+
[CONNECT_SYMBOL](): void;
|
|
1482
1179
|
/**
|
|
1483
|
-
*
|
|
1484
|
-
*
|
|
1485
|
-
* Use this hook to perform actions when a connection is established,
|
|
1486
|
-
* such as sending initial data or updating the actor's state. The
|
|
1487
|
-
* connection is visible in `c.conns` before this hook runs.
|
|
1180
|
+
* Subscribes to an event that will happen repeatedly.
|
|
1488
1181
|
*
|
|
1489
|
-
* @
|
|
1490
|
-
* @
|
|
1182
|
+
* @template Args - The type of arguments the event callback will receive.
|
|
1183
|
+
* @param {string} eventName - The name of the event to subscribe to.
|
|
1184
|
+
* @param {(...args: Args) => void} callback - The callback function to execute when the event is triggered.
|
|
1185
|
+
* @returns {EventUnsubscribe} - A function to unsubscribe from the event.
|
|
1186
|
+
* @see {@link https://rivet.dev/docs/events|Events Documentation}
|
|
1491
1187
|
*/
|
|
1492
|
-
|
|
1188
|
+
on<Args extends Array<unknown> = unknown[]>(eventName: string, callback: (...args: Args) => void): EventUnsubscribe;
|
|
1493
1189
|
/**
|
|
1494
|
-
*
|
|
1495
|
-
*
|
|
1496
|
-
* Use this hook to clean up resources associated with the connection
|
|
1497
|
-
* or update the actor's state.
|
|
1190
|
+
* Subscribes to an event that will be triggered only once.
|
|
1498
1191
|
*
|
|
1499
|
-
* @
|
|
1500
|
-
* @
|
|
1192
|
+
* @template Args - The type of arguments the event callback will receive.
|
|
1193
|
+
* @param {string} eventName - The name of the event to subscribe to.
|
|
1194
|
+
* @param {(...args: Args) => void} callback - The callback function to execute when the event is triggered.
|
|
1195
|
+
* @returns {EventUnsubscribe} - A function to unsubscribe from the event.
|
|
1196
|
+
* @see {@link https://rivet.dev/docs/events|Events Documentation}
|
|
1501
1197
|
*/
|
|
1502
|
-
|
|
1198
|
+
once<Args extends Array<unknown> = unknown[]>(eventName: string, callback: (...args: Args) => void): EventUnsubscribe;
|
|
1503
1199
|
/**
|
|
1504
|
-
*
|
|
1505
|
-
*
|
|
1506
|
-
* Use this hook to modify or transform the output of an action before it's sent
|
|
1507
|
-
* to the client. This is useful for formatting responses, adding metadata,
|
|
1508
|
-
* or applying transformations to the output.
|
|
1200
|
+
* Subscribes to connection errors.
|
|
1509
1201
|
*
|
|
1510
|
-
* @param
|
|
1511
|
-
* @
|
|
1512
|
-
* @param output The output that will be sent to the client
|
|
1513
|
-
* @returns The modified output to send to the client
|
|
1202
|
+
* @param {ActorErrorCallback} callback - The callback function to execute when a connection error occurs.
|
|
1203
|
+
* @returns {() => void} - A function to unsubscribe from the error handler.
|
|
1514
1204
|
*/
|
|
1515
|
-
|
|
1205
|
+
onError(callback: ActorErrorCallback): () => void;
|
|
1516
1206
|
/**
|
|
1517
|
-
*
|
|
1518
|
-
*
|
|
1519
|
-
* This handler receives raw HTTP requests made to `/actors/{actorName}/http/*` endpoints.
|
|
1520
|
-
* Use this hook to handle custom HTTP patterns, REST APIs, or other HTTP-based protocols.
|
|
1207
|
+
* Returns the current connection status.
|
|
1521
1208
|
*
|
|
1522
|
-
* @
|
|
1523
|
-
* @param request The raw HTTP request object
|
|
1524
|
-
* @param opts Additional options
|
|
1525
|
-
* @returns A Response object to send back, or void to continue with default routing
|
|
1209
|
+
* @returns {ActorConnStatus} - The current connection status.
|
|
1526
1210
|
*/
|
|
1527
|
-
|
|
1211
|
+
get connStatus(): ActorConnStatus;
|
|
1528
1212
|
/**
|
|
1529
|
-
*
|
|
1530
|
-
*
|
|
1531
|
-
* This handler receives WebSocket connections made to `/actors/{actorName}/websocket/*` endpoints.
|
|
1532
|
-
* Use this hook to handle custom WebSocket protocols, binary streams, or other WebSocket-based communication.
|
|
1213
|
+
* Returns whether the connection is currently open.
|
|
1533
1214
|
*
|
|
1534
|
-
* @
|
|
1535
|
-
* @
|
|
1536
|
-
* @param opts Additional options including the original HTTP upgrade request
|
|
1215
|
+
* @deprecated Use `connStatus` instead.
|
|
1216
|
+
* @returns {boolean} - True if the connection is open, false otherwise.
|
|
1537
1217
|
*/
|
|
1538
|
-
|
|
1539
|
-
actions?: TActions;
|
|
1218
|
+
get isConnected(): boolean;
|
|
1540
1219
|
/**
|
|
1541
|
-
*
|
|
1542
|
-
* May mirror nested action groups or use dot-separated low-level action names.
|
|
1220
|
+
* Resolves when this connection first reaches the connected state.
|
|
1543
1221
|
*/
|
|
1544
|
-
|
|
1222
|
+
get ready(): Promise<void>;
|
|
1545
1223
|
/**
|
|
1546
|
-
*
|
|
1224
|
+
* Subscribes to connection open events.
|
|
1225
|
+
*
|
|
1226
|
+
* This is called when the WebSocket connection is established and the Init message is received.
|
|
1227
|
+
*
|
|
1228
|
+
* @param {ConnectionStateCallback} callback - The callback function to execute when the connection opens.
|
|
1229
|
+
* @returns {() => void} - A function to unsubscribe from the open handler.
|
|
1547
1230
|
*/
|
|
1548
|
-
|
|
1231
|
+
onOpen(callback: ConnectionStateCallback): () => void;
|
|
1549
1232
|
/**
|
|
1550
|
-
*
|
|
1233
|
+
* Subscribes to connection close events.
|
|
1234
|
+
*
|
|
1235
|
+
* This is called when the WebSocket connection is closed. The connection will automatically
|
|
1236
|
+
* attempt to reconnect unless disposed.
|
|
1237
|
+
*
|
|
1238
|
+
* @param {ConnectionStateCallback} callback - The callback function to execute when the connection closes.
|
|
1239
|
+
* @returns {() => void} - A function to unsubscribe from the close handler.
|
|
1551
1240
|
*/
|
|
1552
|
-
|
|
1241
|
+
onClose(callback: ConnectionStateCallback): () => void;
|
|
1553
1242
|
/**
|
|
1554
|
-
*
|
|
1243
|
+
* Subscribes to connection status changes.
|
|
1244
|
+
*
|
|
1245
|
+
* This is called whenever the connection status changes between Disconnected, Connecting, and Connected.
|
|
1246
|
+
*
|
|
1247
|
+
* @param {StatusChangeCallback} callback - The callback function to execute when the status changes.
|
|
1248
|
+
* @returns {() => void} - A function to unsubscribe from the status change handler.
|
|
1555
1249
|
*/
|
|
1556
|
-
|
|
1557
|
-
}
|
|
1558
|
-
type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
|
|
1250
|
+
onStatusChange(callback: StatusChangeCallback): () => void;
|
|
1559
1251
|
/**
|
|
1560
|
-
*
|
|
1252
|
+
* Disconnects from the actor.
|
|
1253
|
+
*
|
|
1254
|
+
* @returns {Promise<void>} A promise that resolves when the socket is gracefully closed.
|
|
1561
1255
|
*/
|
|
1562
|
-
|
|
1563
|
-
} | Record<never, never>;
|
|
1564
|
-
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>;
|
|
1565
|
-
|
|
1566
|
-
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>> {
|
|
1567
|
-
readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q, _R>;
|
|
1568
|
-
}
|
|
1569
|
-
interface AnyActorDefinition {
|
|
1570
|
-
readonly config: any;
|
|
1571
|
-
}
|
|
1572
|
-
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> {
|
|
1573
|
-
#private;
|
|
1574
|
-
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>);
|
|
1575
|
-
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
|
|
1256
|
+
dispose(): Promise<void>;
|
|
1576
1257
|
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Connection to a actor. Allows calling actor's remote procedure calls with inferred types. See {@link ActorConnRaw} for underlying methods.
|
|
1260
|
+
*
|
|
1261
|
+
* @example
|
|
1262
|
+
* ```
|
|
1263
|
+
* const room = client.connect<ChatRoom>(...etc...);
|
|
1264
|
+
* // This calls the action named `sendMessage` on the `ChatRoom` actor.
|
|
1265
|
+
* await room.sendMessage('Hello, world!');
|
|
1266
|
+
* ```
|
|
1267
|
+
*
|
|
1268
|
+
* Private methods (e.g. those starting with `_`) are automatically excluded.
|
|
1269
|
+
*
|
|
1270
|
+
* @template AD The actor class that this connection is for.
|
|
1271
|
+
* @see {@link ActorConnRaw}
|
|
1272
|
+
*/
|
|
1273
|
+
type ActorConn<AD extends AnyActorDefinition> = Omit<ActorConnRaw, "send" | "on" | "once"> & ActorDefinitionQueueSend<AD> & ActorDefinitionEventSubscriptions<AD> & ActorDefinitionActions<AD>;
|
|
1577
1274
|
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
token
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1275
|
+
/**
|
|
1276
|
+
* Provides underlying functions for stateless {@link ActorHandle} for action calls.
|
|
1277
|
+
* Similar to ActorConnRaw but doesn't maintain a connection.
|
|
1278
|
+
*
|
|
1279
|
+
* @see {@link ActorHandle}
|
|
1280
|
+
*/
|
|
1281
|
+
declare class ActorHandleRaw {
|
|
1282
|
+
#private;
|
|
1283
|
+
/**
|
|
1284
|
+
* Do not call this directly.
|
|
1285
|
+
*
|
|
1286
|
+
* Creates an instance of ActorHandleRaw.
|
|
1287
|
+
*
|
|
1288
|
+
* @protected
|
|
1289
|
+
*/
|
|
1290
|
+
constructor(client: any, driver: EngineControlClient, params: unknown, getParams: (() => Promise<unknown>) | undefined, encoding: Encoding, actorResolutionState: ActorResolutionState, gatewayOptions?: ActorGatewayOptions, signal?: AbortSignal, currentActorInvocation?: CurrentActorInvocation, startCallSpan?: StartCallSpan);
|
|
1291
|
+
send(name: string, body: unknown, options: QueueSendWaitOptions): Promise<QueueSendResult>;
|
|
1292
|
+
send(name: string, body: unknown, options?: QueueSendNoWaitOptions): Promise<void>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Call a raw action. This method sends an HTTP request to invoke the named action.
|
|
1295
|
+
*
|
|
1296
|
+
* @see {@link ActorHandle}
|
|
1297
|
+
* @template Args - The type of arguments to pass to the action function.
|
|
1298
|
+
* @template Response - The type of the response returned by the action function.
|
|
1299
|
+
*/
|
|
1300
|
+
action<Args extends Array<unknown> = unknown[], Response = unknown>(opts: {
|
|
1301
|
+
name: string;
|
|
1302
|
+
args: Args;
|
|
1303
|
+
} & ActorActionOptions): Promise<Response>;
|
|
1304
|
+
/**
|
|
1305
|
+
* Establishes a persistent connection to the actor.
|
|
1306
|
+
*
|
|
1307
|
+
* @template AD The actor class that this connection is for.
|
|
1308
|
+
* @returns {ActorConn<AD>} A connection to the actor.
|
|
1309
|
+
*/
|
|
1310
|
+
connect(params?: unknown, options?: ActorConnectOptions): ActorConn<AnyActorDefinition>;
|
|
1311
|
+
/**
|
|
1312
|
+
* Fetches a resource from this actor via the /request endpoint. This is a
|
|
1313
|
+
* convenience wrapper around the raw HTTP API.
|
|
1314
|
+
*/
|
|
1315
|
+
fetch(input: string | URL | Request, init?: ActorFetchInit): Promise<Response>;
|
|
1316
|
+
/**
|
|
1317
|
+
* Opens a raw WebSocket connection to this actor.
|
|
1318
|
+
*/
|
|
1319
|
+
webSocket(path?: string, protocols?: string | string[], options?: ActorWebSocketOptions): Promise<any>;
|
|
1320
|
+
/**
|
|
1321
|
+
* Resolves the actor to get its unique actor ID.
|
|
1322
|
+
*/
|
|
1323
|
+
resolve(): Promise<string>;
|
|
1324
|
+
/** Issue a token scoped to this actor. Defaults to actor gateway read access. */
|
|
1325
|
+
issueToken(options?: ActorIssueTokenOptions): Promise<IssuedToken>;
|
|
1326
|
+
/**
|
|
1327
|
+
* Returns the raw URL for routing traffic to the actor.
|
|
1328
|
+
*/
|
|
1329
|
+
getGatewayUrl(): Promise<string>;
|
|
1330
|
+
reload(): Promise<void>;
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Stateless handle to a actor. Allows calling actor's remote procedure calls with inferred types
|
|
1334
|
+
* without establishing a persistent connection.
|
|
1335
|
+
*
|
|
1336
|
+
* @example
|
|
1337
|
+
* ```
|
|
1338
|
+
* const room = client.get<ChatRoom>(...etc...);
|
|
1339
|
+
* // This calls the action named `sendMessage` on the `ChatRoom` actor without a connection.
|
|
1340
|
+
* await room.sendMessage('Hello, world!');
|
|
1341
|
+
* ```
|
|
1342
|
+
*
|
|
1343
|
+
* Private methods (e.g. those starting with `_`) are automatically excluded.
|
|
1344
|
+
*
|
|
1345
|
+
* @template AD The actor class that this handle is for.
|
|
1346
|
+
* @see {@link ActorHandleRaw}
|
|
1347
|
+
*/
|
|
1348
|
+
type ActorHandle<AD extends AnyActorDefinition> = Omit<ActorHandleRaw, "connect" | "send"> & {
|
|
1349
|
+
connect(params?: unknown, options?: ActorConnectOptions): ActorConn<AD>;
|
|
1350
|
+
resolve(): Promise<string>;
|
|
1351
|
+
} & ActorDefinitionQueueSend<AD> & Omit<ActorDefinitionActions<AD>, keyof ActorHandleRaw>;
|
|
1352
|
+
|
|
1353
|
+
/** Called when RivetKit needs a credential. Keep issuer secrets on your backend. */
|
|
1354
|
+
type GetToken = (options: {
|
|
1355
|
+
forceRefresh: boolean;
|
|
1356
|
+
}) => Promise<string>;
|
|
1357
|
+
|
|
1358
|
+
declare const ClientConfigSchema: z$1.ZodPipe<z$1.ZodObject<{
|
|
1359
|
+
endpoint: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string, string | undefined>>;
|
|
1360
|
+
token: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string | undefined, string | undefined>>;
|
|
1361
|
+
getToken: z$1.ZodOptional<z$1.ZodCustom<GetToken, GetToken>>;
|
|
1362
|
+
namespace: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string | undefined, string | undefined>>;
|
|
1363
|
+
poolName: z$1.ZodDefault<z$1.ZodString>;
|
|
1364
|
+
encoding: z$1.ZodDefault<z$1.ZodEnum<{
|
|
1365
|
+
json: "json";
|
|
1366
|
+
cbor: "cbor";
|
|
1367
|
+
bare: "bare";
|
|
1368
|
+
}>>;
|
|
1369
|
+
headers: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>>;
|
|
1370
|
+
gateway: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodObject<{
|
|
1371
|
+
skipReadyWait: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
|
|
1372
|
+
}, z$1.core.$strip>>>;
|
|
1373
|
+
getUpgradeWebSocket: z$1.ZodOptional<z$1.ZodCustom<GetUpgradeWebSocket, GetUpgradeWebSocket>>;
|
|
1374
|
+
fetch: z$1.ZodOptional<z$1.ZodCustom<typeof fetch, typeof fetch>>;
|
|
1375
|
+
disableMetadataLookup: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
|
|
1376
|
+
maxInputSize: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1377
|
+
devtools: z$1.ZodDefault<z$1.ZodBoolean>;
|
|
1378
|
+
}, z$1.core.$strip>, z$1.ZodTransform<{
|
|
1668
1379
|
endpoint: string | undefined;
|
|
1669
1380
|
namespace: string;
|
|
1670
1381
|
token: string | undefined;
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
publicToken: string | undefined;
|
|
1674
|
-
validateServerlessEndpoint: boolean;
|
|
1675
|
-
serverless: {
|
|
1676
|
-
publicEndpoint: string | undefined;
|
|
1677
|
-
basePath: string;
|
|
1678
|
-
maxStartPayloadBytes: number;
|
|
1679
|
-
publicToken: string | undefined;
|
|
1680
|
-
};
|
|
1681
|
-
use: Record<string, AnyActorDefinition>;
|
|
1682
|
-
test: {
|
|
1683
|
-
enabled: boolean;
|
|
1684
|
-
sqliteBackend?: "local" | "remote" | undefined;
|
|
1685
|
-
};
|
|
1686
|
-
maxIncomingMessageSize: number;
|
|
1687
|
-
maxOutgoingMessageSize: number;
|
|
1688
|
-
runtime: "auto" | "native" | "wasm";
|
|
1689
|
-
wasm: {
|
|
1690
|
-
bindings?: typeof _rivetkit_rivetkit_wasm | undefined;
|
|
1691
|
-
initInput?: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
|
|
1692
|
-
};
|
|
1693
|
-
noWelcome: boolean;
|
|
1694
|
-
logging: {
|
|
1695
|
-
baseLogger?: Logger | undefined;
|
|
1696
|
-
level?: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent" | undefined;
|
|
1697
|
-
};
|
|
1382
|
+
poolName: string;
|
|
1383
|
+
encoding: "json" | "cbor" | "bare";
|
|
1698
1384
|
headers: Record<string, string>;
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
startEngine: boolean;
|
|
1702
|
-
engineHost: string;
|
|
1703
|
-
enginePort: number;
|
|
1704
|
-
engineVersion: string;
|
|
1705
|
-
envoy: {
|
|
1706
|
-
poolName: string;
|
|
1707
|
-
version: number;
|
|
1708
|
-
totalSlots: number;
|
|
1709
|
-
envoyKey?: string | undefined;
|
|
1710
|
-
};
|
|
1711
|
-
shutdown: {
|
|
1712
|
-
disableSignalHandlers: boolean;
|
|
1713
|
-
gracePeriodMs?: number | undefined;
|
|
1385
|
+
gateway: {
|
|
1386
|
+
skipReadyWait: boolean;
|
|
1714
1387
|
};
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
requestLifespan?: number | undefined;
|
|
1722
|
-
drainGracePeriod?: number | undefined;
|
|
1723
|
-
metadata?: Record<string, unknown> | undefined;
|
|
1724
|
-
metadataPollInterval?: number | undefined;
|
|
1725
|
-
drainOnVersionUpgrade?: boolean | undefined;
|
|
1726
|
-
} | undefined;
|
|
1388
|
+
disableMetadataLookup: boolean;
|
|
1389
|
+
maxInputSize: number;
|
|
1390
|
+
devtools: boolean;
|
|
1391
|
+
getToken?: GetToken | undefined;
|
|
1392
|
+
getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
|
|
1393
|
+
fetch?: typeof fetch | undefined;
|
|
1727
1394
|
}, {
|
|
1728
|
-
|
|
1729
|
-
test: {
|
|
1730
|
-
enabled: boolean;
|
|
1731
|
-
sqliteBackend?: "local" | "remote" | undefined;
|
|
1732
|
-
};
|
|
1733
|
-
maxIncomingMessageSize: number;
|
|
1734
|
-
maxOutgoingMessageSize: number;
|
|
1735
|
-
runtime: "auto" | "native" | "wasm";
|
|
1736
|
-
wasm: {
|
|
1737
|
-
bindings?: typeof _rivetkit_rivetkit_wasm | undefined;
|
|
1738
|
-
initInput?: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
|
|
1739
|
-
};
|
|
1740
|
-
sqlite: {
|
|
1741
|
-
backend: "local" | "remote";
|
|
1742
|
-
} | undefined;
|
|
1743
|
-
noWelcome: boolean;
|
|
1744
|
-
logging: {
|
|
1745
|
-
baseLogger?: Logger | undefined;
|
|
1746
|
-
level?: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent" | undefined;
|
|
1747
|
-
};
|
|
1748
|
-
endpoint: string | undefined;
|
|
1395
|
+
endpoint: string;
|
|
1749
1396
|
token: string | undefined;
|
|
1750
1397
|
namespace: string | undefined;
|
|
1398
|
+
poolName: string;
|
|
1399
|
+
encoding: "json" | "cbor" | "bare";
|
|
1751
1400
|
headers: Record<string, string>;
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
startEngine: boolean;
|
|
1755
|
-
engineHost: string;
|
|
1756
|
-
enginePort: number;
|
|
1757
|
-
engineVersion: string;
|
|
1758
|
-
serverless: {
|
|
1759
|
-
basePath: string;
|
|
1760
|
-
maxStartPayloadBytes: number;
|
|
1761
|
-
publicEndpoint: string | undefined;
|
|
1762
|
-
publicToken: string | undefined;
|
|
1763
|
-
};
|
|
1764
|
-
envoy: {
|
|
1765
|
-
poolName: string;
|
|
1766
|
-
version: number;
|
|
1767
|
-
totalSlots: number;
|
|
1768
|
-
envoyKey?: string | undefined;
|
|
1769
|
-
};
|
|
1770
|
-
shutdown: {
|
|
1771
|
-
disableSignalHandlers: boolean;
|
|
1772
|
-
gracePeriodMs?: number | undefined;
|
|
1401
|
+
gateway: {
|
|
1402
|
+
skipReadyWait: boolean;
|
|
1773
1403
|
};
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
requestLifespan?: number | undefined;
|
|
1781
|
-
drainGracePeriod?: number | undefined;
|
|
1782
|
-
metadata?: Record<string, unknown> | undefined;
|
|
1783
|
-
metadataPollInterval?: number | undefined;
|
|
1784
|
-
drainOnVersionUpgrade?: boolean | undefined;
|
|
1785
|
-
} | undefined;
|
|
1404
|
+
disableMetadataLookup: boolean;
|
|
1405
|
+
maxInputSize: number;
|
|
1406
|
+
devtools: boolean;
|
|
1407
|
+
getToken?: GetToken | undefined;
|
|
1408
|
+
getUpgradeWebSocket?: GetUpgradeWebSocket | undefined;
|
|
1409
|
+
fetch?: typeof fetch | undefined;
|
|
1786
1410
|
}>>;
|
|
1787
|
-
type
|
|
1788
|
-
type RegistryConfigInput<A extends RegistryActors> = Omit<z$2.input<typeof RegistryConfigSchema>, "use"> & {
|
|
1789
|
-
use: A;
|
|
1790
|
-
};
|
|
1411
|
+
type ClientConfigInput = z$1.input<typeof ClientConfigSchema>;
|
|
1791
1412
|
|
|
1792
|
-
|
|
1793
|
-
type
|
|
1794
|
-
|
|
1795
|
-
};
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1413
|
+
/** Extract the actor registry from the registry definition. */
|
|
1414
|
+
type ExtractActorsFromRegistry<A extends Registry<any>> = A extends Registry<infer Actors> ? Actors : never;
|
|
1415
|
+
/** Extract the registry definition from the client. */
|
|
1416
|
+
type ExtractRegistryFromClient<C extends Client<Registry<{}>>> = C extends Client<infer A> ? A : never;
|
|
1417
|
+
/**
|
|
1418
|
+
* Represents a actor accessor that provides methods to interact with a specific actor.
|
|
1419
|
+
*/
|
|
1420
|
+
interface ActorAccessor<AD extends AnyActorDefinition> {
|
|
1421
|
+
/**
|
|
1422
|
+
* Gets a stateless handle to a actor by its key, but does not create the actor if it doesn't exist.
|
|
1423
|
+
* The actor name is automatically injected from the property accessor.
|
|
1424
|
+
*
|
|
1425
|
+
* Each operation resolves the current actor for the key before sending the
|
|
1426
|
+
* request.
|
|
1427
|
+
*
|
|
1428
|
+
* @template AD The actor class that this handle is for.
|
|
1429
|
+
* @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
|
|
1430
|
+
* @param {GetWithIdOptions} [opts] - Options for getting the actor.
|
|
1431
|
+
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
1432
|
+
*/
|
|
1433
|
+
get(key?: string | string[], opts?: GetWithIdOptions): ActorHandle<AD>;
|
|
1434
|
+
/**
|
|
1435
|
+
* Gets a stateless handle to a actor by its key, creating it if necessary.
|
|
1436
|
+
* The actor name is automatically injected from the property accessor.
|
|
1437
|
+
*
|
|
1438
|
+
* Each operation resolves the current actor for the key before sending the
|
|
1439
|
+
* request.
|
|
1440
|
+
*
|
|
1441
|
+
* @template AD The actor class that this handle is for.
|
|
1442
|
+
* @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
|
|
1443
|
+
* @param {GetOptions} [opts] - Options for getting the actor.
|
|
1444
|
+
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
1445
|
+
*/
|
|
1446
|
+
getOrCreate(key?: string | string[], opts?: GetOrCreateOptions): ActorHandle<AD>;
|
|
1447
|
+
/**
|
|
1448
|
+
* Gets a stateless handle to a actor by its ID.
|
|
1449
|
+
*
|
|
1450
|
+
* If the actor is destroyed, operations will throw without retrying since
|
|
1451
|
+
* there is no key to re-resolve.
|
|
1452
|
+
*
|
|
1453
|
+
* @template AD The actor class that this handle is for.
|
|
1454
|
+
* @param {string} actorId - The ID of the actor.
|
|
1455
|
+
* @param {GetWithIdOptions} [opts] - Options for getting the actor.
|
|
1456
|
+
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
1457
|
+
*/
|
|
1458
|
+
getForId(actorId: string, opts?: GetWithIdOptions): ActorHandle<AD>;
|
|
1459
|
+
/**
|
|
1460
|
+
* Creates a new actor with the name automatically injected from the property accessor,
|
|
1461
|
+
* and returns a stateless handle to it with the actor ID resolved.
|
|
1462
|
+
*
|
|
1463
|
+
* If the actor is destroyed, operations will throw without retrying since
|
|
1464
|
+
* creation is a one-shot operation.
|
|
1465
|
+
*
|
|
1466
|
+
* @template AD The actor class that this handle is for.
|
|
1467
|
+
* @param {string | string[]} key - The key to identify the actor. Can be a single string or an array of strings.
|
|
1468
|
+
* @param {CreateOptions} [opts] - Options for creating the actor (excluding name and key).
|
|
1469
|
+
* @returns {Promise<ActorHandle<AD>>} - A promise that resolves to a handle to the actor.
|
|
1470
|
+
*/
|
|
1471
|
+
create(key?: string | string[], opts?: CreateOptions): Promise<ActorHandle<AD>>;
|
|
1809
1472
|
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1473
|
+
/**
|
|
1474
|
+
* Options for querying actors.
|
|
1475
|
+
* @typedef {Object} QueryOptions
|
|
1476
|
+
* @property {unknown} [parameters] - Parameters to pass to the connection.
|
|
1477
|
+
*/
|
|
1478
|
+
interface QueryOptions {
|
|
1479
|
+
/** Parameters to pass to the connection. */
|
|
1480
|
+
params?: unknown;
|
|
1481
|
+
/**
|
|
1482
|
+
* Lazily resolves connection parameters for `.connect()` and `.webSocket()`.
|
|
1483
|
+
* This is called each time a new connection is opened.
|
|
1484
|
+
*/
|
|
1485
|
+
getParams?: () => Promise<unknown>;
|
|
1486
|
+
/** Signal to abort the request. */
|
|
1487
|
+
signal?: AbortSignal;
|
|
1815
1488
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
}>;
|
|
1822
|
-
connHibernationRemoved: string[];
|
|
1489
|
+
/**
|
|
1490
|
+
* Options for getting a actor by ID.
|
|
1491
|
+
* @typedef {QueryOptions} GetWithIdOptions
|
|
1492
|
+
*/
|
|
1493
|
+
interface GetWithIdOptions extends QueryOptions {
|
|
1823
1494
|
}
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1495
|
+
/**
|
|
1496
|
+
* Options for getting a actor.
|
|
1497
|
+
* @typedef {QueryOptions} GetOptions
|
|
1498
|
+
*/
|
|
1499
|
+
interface GetOptions extends QueryOptions {
|
|
1827
1500
|
}
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1501
|
+
/**
|
|
1502
|
+
* Options for getting or creating a actor.
|
|
1503
|
+
* @typedef {QueryOptions} GetOrCreateOptions
|
|
1504
|
+
* @property {string} [createInRegion] - Region to create the actor in if it doesn't exist.
|
|
1505
|
+
*/
|
|
1506
|
+
interface GetOrCreateOptions extends QueryOptions {
|
|
1507
|
+
/** Region to create the actor in if it doesn't exist. */
|
|
1508
|
+
createInRegion?: string;
|
|
1509
|
+
/** Input data to pass to the actor. */
|
|
1510
|
+
createWithInput?: unknown;
|
|
1511
|
+
/**
|
|
1512
|
+
* Name of the envoy pool to select for this actor if it is created.
|
|
1513
|
+
* Overrides the client's configured `poolName` for this call.
|
|
1514
|
+
*/
|
|
1515
|
+
poolName?: string;
|
|
1831
1516
|
}
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1517
|
+
/**
|
|
1518
|
+
* Options for creating a actor.
|
|
1519
|
+
* @typedef {QueryOptions} CreateOptions
|
|
1520
|
+
* @property {string} [region] - The region to create the actor in.
|
|
1521
|
+
*/
|
|
1522
|
+
interface CreateOptions extends QueryOptions {
|
|
1523
|
+
/** The region to create the actor in. */
|
|
1524
|
+
region?: string;
|
|
1525
|
+
/** Input data to pass to the actor. */
|
|
1526
|
+
input?: unknown;
|
|
1527
|
+
/**
|
|
1528
|
+
* Name of the envoy pool to select for this actor.
|
|
1529
|
+
* Overrides the client's configured `poolName` for this call.
|
|
1530
|
+
*/
|
|
1531
|
+
poolName?: string;
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* Represents a region to connect to.
|
|
1535
|
+
* @typedef {Object} Region
|
|
1536
|
+
* @property {string} id - The region ID.
|
|
1537
|
+
* @property {string} name - The region name.
|
|
1538
|
+
* @see {@link https://rivet.dev/docs/edge|Edge Networking}
|
|
1539
|
+
* @see {@link https://rivet.dev/docs/regions|Available Regions}
|
|
1540
|
+
*/
|
|
1541
|
+
interface Region {
|
|
1542
|
+
/**
|
|
1543
|
+
* The region slug.
|
|
1544
|
+
*/
|
|
1545
|
+
id: string;
|
|
1546
|
+
/**
|
|
1547
|
+
* The human-friendly region name.
|
|
1548
|
+
*/
|
|
1549
|
+
name: string;
|
|
1550
|
+
}
|
|
1551
|
+
declare const ACTOR_CONNS_SYMBOL: unique symbol;
|
|
1552
|
+
declare const CREATE_ACTOR_CONN_PROXY: unique symbol;
|
|
1553
|
+
/** Options for constructing a raw actor client. */
|
|
1554
|
+
interface ClientRawOptions {
|
|
1555
|
+
encoding?: Encoding;
|
|
1556
|
+
gateway?: ActorGatewayOptions;
|
|
1557
|
+
}
|
|
1558
|
+
/** Runtime-supplied wiring for clients created inside an actor. Set only by the native runtime. */
|
|
1559
|
+
interface ActorClientRuntimeOptions {
|
|
1560
|
+
/** Supplies the calling actor's invocation so actor-to-actor clients propagate its trace and ray ID. */
|
|
1561
|
+
currentActorInvocation?: CurrentActorInvocation;
|
|
1562
|
+
/** Opens and finishes the Core span covering an actor-to-actor call. */
|
|
1563
|
+
startCallSpan?: StartCallSpan;
|
|
1564
|
+
}
|
|
1565
|
+
/**
|
|
1566
|
+
* Client for managing & connecting to actors.
|
|
1567
|
+
*
|
|
1568
|
+
* @template A The actors map type that defines the available actors.
|
|
1569
|
+
* @see {@link https://rivet.dev/docs/manage|Create & Manage Actors}
|
|
1570
|
+
*/
|
|
1571
|
+
declare class ClientRaw {
|
|
1572
|
+
#private;
|
|
1573
|
+
/** Issue namespace-scoped tokens with an explicit grant list. */
|
|
1574
|
+
readonly auth: {
|
|
1575
|
+
issueToken(options: IssueTokenOptions): Promise<IssuedToken>;
|
|
1576
|
+
};
|
|
1577
|
+
[ACTOR_CONNS_SYMBOL]: Set<ActorConnRaw>;
|
|
1578
|
+
/**
|
|
1579
|
+
* Creates an instance of Client.
|
|
1580
|
+
*/
|
|
1581
|
+
constructor(driver: EngineControlClient, options?: ClientRawOptions & ActorClientRuntimeOptions);
|
|
1582
|
+
/**
|
|
1583
|
+
* Gets a stateless handle to a actor by its ID.
|
|
1584
|
+
*
|
|
1585
|
+
* @template AD The actor class that this handle is for.
|
|
1586
|
+
* @param {string} name - The name of the actor.
|
|
1587
|
+
* @param {string} actorId - The ID of the actor.
|
|
1588
|
+
* @param {GetWithIdOptions} [opts] - Options for getting the actor.
|
|
1589
|
+
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
1590
|
+
*/
|
|
1591
|
+
getForId<AD extends AnyActorDefinition>(name: string, actorId: string, opts?: GetWithIdOptions): ActorHandle<AD>;
|
|
1592
|
+
/**
|
|
1593
|
+
* Gets a stateless handle to a actor by its key, but does not create the actor if it doesn't exist.
|
|
1594
|
+
*
|
|
1595
|
+
* @template AD The actor class that this handle is for.
|
|
1596
|
+
* @param {string} name - The name of the actor.
|
|
1597
|
+
* @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
|
|
1598
|
+
* @param {GetWithIdOptions} [opts] - Options for getting the actor.
|
|
1599
|
+
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
1600
|
+
*/
|
|
1601
|
+
get<AD extends AnyActorDefinition>(name: string, key?: string | string[], opts?: GetWithIdOptions): ActorHandle<AD>;
|
|
1602
|
+
/**
|
|
1603
|
+
* Gets a stateless handle to a actor by its key, creating it if necessary.
|
|
1604
|
+
*
|
|
1605
|
+
* @template AD The actor class that this handle is for.
|
|
1606
|
+
* @param {string} name - The name of the actor.
|
|
1607
|
+
* @param {string | string[]} [key=[]] - The key to identify the actor. Can be a single string or an array of strings.
|
|
1608
|
+
* @param {GetOptions} [opts] - Options for getting the actor.
|
|
1609
|
+
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
1610
|
+
*/
|
|
1611
|
+
getOrCreate<AD extends AnyActorDefinition>(name: string, key?: string | string[], opts?: GetOrCreateOptions): ActorHandle<AD>;
|
|
1612
|
+
/**
|
|
1613
|
+
* Creates a new actor with the provided key and returns a stateless handle to it.
|
|
1614
|
+
* Resolves the actor ID and returns a handle with getForId query.
|
|
1615
|
+
*
|
|
1616
|
+
* @template AD The actor class that this handle is for.
|
|
1617
|
+
* @param {string} name - The name of the actor.
|
|
1618
|
+
* @param {string | string[]} key - The key to identify the actor. Can be a single string or an array of strings.
|
|
1619
|
+
* @param {CreateOptions} [opts] - Options for creating the actor (excluding name and key).
|
|
1620
|
+
* @returns {Promise<ActorHandle<AD>>} - A promise that resolves to a handle to the actor.
|
|
1621
|
+
*/
|
|
1622
|
+
create<AD extends AnyActorDefinition>(name: string, key?: string | string[], opts?: CreateOptions): Promise<ActorHandle<AD>>;
|
|
1623
|
+
[CREATE_ACTOR_CONN_PROXY]<AD extends AnyActorDefinition>(conn: ActorConnRaw): ActorConn<AD>;
|
|
1624
|
+
/**
|
|
1625
|
+
* Disconnects from all actors.
|
|
1626
|
+
*
|
|
1627
|
+
* @returns {Promise<void>} A promise that resolves when all connections are closed.
|
|
1628
|
+
*/
|
|
1629
|
+
dispose(): Promise<void>;
|
|
1630
|
+
}
|
|
1631
|
+
/**
|
|
1632
|
+
* Client type with actor accessors.
|
|
1633
|
+
* This adds property accessors for actor names to the ClientRaw base class.
|
|
1634
|
+
*
|
|
1635
|
+
* @template A The actor registry type.
|
|
1636
|
+
*/
|
|
1637
|
+
type Client<A extends Registry<any>> = ClientRaw & Omit<{
|
|
1638
|
+
[K in keyof ExtractActorsFromRegistry<A>]: ActorAccessor<ExtractActorsFromRegistry<A>[K]>;
|
|
1639
|
+
}, keyof ClientRaw>;
|
|
1640
|
+
|
|
1641
|
+
/** @experimental State exposed by a durable workflow run handler to the Inspector. */
|
|
1642
|
+
type WorkflowState = "pending" | "running" | "sleeping" | "failed" | "completed" | "cancelled" | "rolling_back";
|
|
1643
|
+
|
|
1644
|
+
declare const ACTOR_CONTEXT_INTERNAL_SYMBOL: unique symbol;
|
|
1645
|
+
declare const RAW_STATE_SYMBOL: unique symbol;
|
|
1646
|
+
interface ActorLogger {
|
|
1647
|
+
level: any;
|
|
1648
|
+
fatal: any;
|
|
1649
|
+
trace: any;
|
|
1650
|
+
silent: any;
|
|
1651
|
+
msgPrefix: any;
|
|
1652
|
+
debug: any;
|
|
1653
|
+
info: any;
|
|
1654
|
+
warn: any;
|
|
1655
|
+
error: any;
|
|
1656
|
+
[key: string]: any;
|
|
1657
|
+
}
|
|
1658
|
+
type ActorKvValueType = "text" | "arrayBuffer" | "binary";
|
|
1659
|
+
type ActorKvKeyType = "text" | "binary";
|
|
1660
|
+
type ActorKvValueTypeMap = {
|
|
1661
|
+
text: string;
|
|
1662
|
+
arrayBuffer: ArrayBuffer;
|
|
1663
|
+
binary: Uint8Array;
|
|
1664
|
+
};
|
|
1665
|
+
type ActorKvKeyTypeMap = {
|
|
1666
|
+
text: string;
|
|
1667
|
+
binary: Uint8Array;
|
|
1668
|
+
};
|
|
1669
|
+
type ActorKvValueOptions<T extends ActorKvValueType = "text"> = {
|
|
1670
|
+
type?: T;
|
|
1671
|
+
};
|
|
1672
|
+
type ActorKvListOptions<T extends ActorKvValueType = "text", K extends ActorKvKeyType = "text"> = ActorKvValueOptions<T> & {
|
|
1673
|
+
keyType?: K;
|
|
1674
|
+
reverse?: boolean;
|
|
1675
|
+
limit?: number;
|
|
1676
|
+
};
|
|
1677
|
+
type ActorClientFor<T> = T extends Registry<any> ? Client<T> : T;
|
|
1678
|
+
/**
|
|
1679
|
+
* @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db`)
|
|
1680
|
+
* or actor state instead.
|
|
1681
|
+
*/
|
|
1682
|
+
interface ActorKv {
|
|
1683
|
+
get<T extends ActorKvValueType = "text">(key: Uint8Array | string, options?: ActorKvValueOptions<T>): Promise<ActorKvValueTypeMap[T] | null>;
|
|
1684
|
+
put<T extends ActorKvValueType = "text">(key: Uint8Array | string, value: Uint8Array | string | ArrayBuffer, options?: ActorKvValueOptions<T>): Promise<void>;
|
|
1685
|
+
delete(key: Uint8Array | string): Promise<void>;
|
|
1686
|
+
batchPut(entries: [Uint8Array, Uint8Array][]): Promise<void>;
|
|
1687
|
+
batchGet(keys: Uint8Array[]): Promise<(Uint8Array | null)[]>;
|
|
1688
|
+
batchDelete(keys: Uint8Array[]): Promise<void>;
|
|
1689
|
+
deleteRange(start: Uint8Array, end: Uint8Array): Promise<void>;
|
|
1690
|
+
listPrefix<T extends ActorKvValueType = "text", K extends ActorKvKeyType = "text">(prefix: Uint8Array | string, options?: ActorKvListOptions<T, K>): Promise<Array<[ActorKvKeyTypeMap[K], ActorKvValueTypeMap[T]]>>;
|
|
1691
|
+
listRange<T extends ActorKvValueType = "text", K extends ActorKvKeyType = "text">(start: Uint8Array | string, end: Uint8Array | string, options?: ActorKvListOptions<T, K>): Promise<Array<[ActorKvKeyTypeMap[K], ActorKvValueTypeMap[T]]>>;
|
|
1692
|
+
list<T extends ActorKvValueType = "text", K extends ActorKvKeyType = "text">(prefix: Uint8Array | string, options?: ActorKvListOptions<T, K>): Promise<Array<[ActorKvKeyTypeMap[K], ActorKvValueTypeMap[T]]>>;
|
|
1693
|
+
[key: string]: any;
|
|
1694
|
+
}
|
|
1695
|
+
interface ActorSchedule {
|
|
1696
|
+
after(duration: number, action: string, ...args: unknown[]): Promise<string>;
|
|
1697
|
+
at(timestamp: number, action: string, ...args: unknown[]): Promise<string>;
|
|
1698
|
+
cancel(id: string): Promise<boolean>;
|
|
1699
|
+
get(id: string): Promise<ScheduledEventInfo | undefined>;
|
|
1700
|
+
list(): Promise<ScheduledEventInfo[]>;
|
|
1701
|
+
[key: string]: any;
|
|
1839
1702
|
}
|
|
1840
|
-
interface
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1703
|
+
interface ActorCronSetOptions {
|
|
1704
|
+
name: string;
|
|
1705
|
+
expression: string;
|
|
1706
|
+
action: string;
|
|
1707
|
+
args?: unknown[];
|
|
1708
|
+
timezone?: string;
|
|
1709
|
+
/** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
|
|
1710
|
+
maxHistory?: number;
|
|
1847
1711
|
}
|
|
1848
|
-
interface
|
|
1849
|
-
id: number;
|
|
1712
|
+
interface ActorCronEveryOptions {
|
|
1850
1713
|
name: string;
|
|
1851
|
-
|
|
1714
|
+
/** Fixed interval in milliseconds. Minimum 5,000. */
|
|
1715
|
+
interval: number;
|
|
1716
|
+
action: string;
|
|
1717
|
+
args?: unknown[];
|
|
1718
|
+
/** Defaults to 100. Set to 0 to disable and clear history. Maximum 1,000. */
|
|
1719
|
+
maxHistory?: number;
|
|
1852
1720
|
}
|
|
1853
|
-
interface
|
|
1721
|
+
interface ActorCron {
|
|
1722
|
+
set(options: ActorCronSetOptions): Promise<void>;
|
|
1723
|
+
every(options: ActorCronEveryOptions): Promise<void>;
|
|
1724
|
+
get(name: string): Promise<CronJobInfo | undefined>;
|
|
1725
|
+
list(): Promise<CronJobInfo[]>;
|
|
1726
|
+
delete(name: string): Promise<boolean>;
|
|
1727
|
+
history(name: string, options?: {
|
|
1728
|
+
limit?: number;
|
|
1729
|
+
}): Promise<CronFire[]>;
|
|
1730
|
+
[key: string]: any;
|
|
1731
|
+
}
|
|
1732
|
+
interface ScheduledEventInfo {
|
|
1854
1733
|
id: string;
|
|
1855
1734
|
action: string;
|
|
1856
|
-
args:
|
|
1735
|
+
args: unknown[];
|
|
1857
1736
|
runAt: number;
|
|
1858
1737
|
}
|
|
1859
|
-
|
|
1738
|
+
type CronJobInfo = {
|
|
1860
1739
|
name: string;
|
|
1861
|
-
kind: "cron" | "every";
|
|
1862
1740
|
action: string;
|
|
1863
|
-
args:
|
|
1741
|
+
args: unknown[];
|
|
1864
1742
|
nextRunAt: number;
|
|
1865
1743
|
lastRunAt?: number;
|
|
1866
|
-
expression?: string;
|
|
1867
|
-
timezone?: string;
|
|
1868
|
-
intervalMs?: number;
|
|
1869
1744
|
maxHistory: number;
|
|
1870
|
-
}
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1745
|
+
} & ({
|
|
1746
|
+
kind: "cron";
|
|
1747
|
+
expression: string;
|
|
1748
|
+
timezone: string;
|
|
1749
|
+
} | {
|
|
1750
|
+
kind: "every";
|
|
1751
|
+
interval: number;
|
|
1752
|
+
});
|
|
1753
|
+
interface CronFire {
|
|
1878
1754
|
action: string;
|
|
1879
1755
|
scheduledAt: number;
|
|
1880
1756
|
firedAt: number;
|
|
1881
1757
|
finishedAt?: number;
|
|
1882
1758
|
result: "running" | "ok" | "error" | "skipped";
|
|
1883
|
-
error?:
|
|
1759
|
+
error?: {
|
|
1760
|
+
group: string;
|
|
1761
|
+
code: string;
|
|
1762
|
+
message: string;
|
|
1763
|
+
metadata?: unknown;
|
|
1764
|
+
};
|
|
1884
1765
|
}
|
|
1885
|
-
|
|
1886
|
-
|
|
1766
|
+
type QueueMessageOf<Name extends string, Body> = {
|
|
1767
|
+
id: number | bigint;
|
|
1768
|
+
name: Name;
|
|
1769
|
+
body: Body;
|
|
1770
|
+
createdAt: number;
|
|
1771
|
+
[key: string]: unknown;
|
|
1772
|
+
};
|
|
1773
|
+
type QueueName<TQueues extends QueueSchemaConfig> = keyof TQueues & string;
|
|
1774
|
+
type QueueFilterName<TQueues extends QueueSchemaConfig> = keyof TQueues extends never ? string : QueueName<TQueues>;
|
|
1775
|
+
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;
|
|
1776
|
+
type QueueCompleteArgs<T> = undefined extends T ? [response?: T] : [response: T];
|
|
1777
|
+
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];
|
|
1778
|
+
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;
|
|
1779
|
+
interface QueueNextOptions<TName extends string = string, TCompletable extends boolean = boolean> {
|
|
1780
|
+
names?: readonly TName[];
|
|
1781
|
+
timeout?: number;
|
|
1782
|
+
signal?: AbortSignal;
|
|
1783
|
+
completable?: TCompletable;
|
|
1784
|
+
}
|
|
1785
|
+
interface QueueNextBatchOptions<TName extends string = string, TCompletable extends boolean = boolean> {
|
|
1786
|
+
names?: readonly TName[];
|
|
1887
1787
|
count?: number;
|
|
1888
|
-
|
|
1889
|
-
|
|
1788
|
+
timeout?: number;
|
|
1789
|
+
signal?: AbortSignal;
|
|
1790
|
+
completable?: TCompletable;
|
|
1890
1791
|
}
|
|
1891
|
-
interface
|
|
1892
|
-
|
|
1893
|
-
|
|
1792
|
+
interface QueueWaitOptions<TCompletable extends boolean = boolean> {
|
|
1793
|
+
timeout?: number;
|
|
1794
|
+
signal?: AbortSignal;
|
|
1795
|
+
completable?: TCompletable;
|
|
1894
1796
|
}
|
|
1895
|
-
interface
|
|
1896
|
-
|
|
1797
|
+
interface QueueEnqueueAndWaitOptions {
|
|
1798
|
+
timeout?: number;
|
|
1799
|
+
signal?: AbortSignal;
|
|
1897
1800
|
}
|
|
1898
|
-
interface
|
|
1899
|
-
names?:
|
|
1801
|
+
interface QueueTryNextOptions<TName extends string = string, TCompletable extends boolean = boolean> {
|
|
1802
|
+
names?: readonly TName[];
|
|
1803
|
+
completable?: TCompletable;
|
|
1804
|
+
}
|
|
1805
|
+
interface QueueTryNextBatchOptions<TName extends string = string, TCompletable extends boolean = boolean> {
|
|
1806
|
+
names?: readonly TName[];
|
|
1900
1807
|
count?: number;
|
|
1901
|
-
completable?:
|
|
1808
|
+
completable?: TCompletable;
|
|
1902
1809
|
}
|
|
1903
|
-
interface
|
|
1904
|
-
|
|
1905
|
-
|
|
1810
|
+
interface QueueIterOptions<TName extends string = string, TCompletable extends boolean = boolean> {
|
|
1811
|
+
names?: readonly TName[];
|
|
1812
|
+
signal?: AbortSignal;
|
|
1813
|
+
completable?: TCompletable;
|
|
1906
1814
|
}
|
|
1907
|
-
interface
|
|
1908
|
-
|
|
1909
|
-
|
|
1815
|
+
interface ActorQueue<TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1816
|
+
send<TName extends QueueFilterName<TQueues>>(name: TName, body: QueueMessageForName<TQueues, TName>["body"]): Promise<any>;
|
|
1817
|
+
next<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextOptions<TName, TCompletable>): Promise<any>;
|
|
1818
|
+
nextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueNextBatchOptions<TName, TCompletable>): Promise<any[]>;
|
|
1819
|
+
waitForNames<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(names: readonly TName[], opts?: QueueWaitOptions<TCompletable>): Promise<any>;
|
|
1820
|
+
/** @experimental */
|
|
1821
|
+
waitForAvailable<const TName extends QueueFilterName<TQueues>>(names?: readonly TName[], opts?: Omit<QueueWaitOptions<false>, "completable">): Promise<void>;
|
|
1822
|
+
/** @experimental */
|
|
1823
|
+
complete<const TName extends QueueFilterName<TQueues>>(message: {
|
|
1824
|
+
id: number | bigint;
|
|
1825
|
+
name: TName;
|
|
1826
|
+
}, ...args: QueueCompleteArgsForName<TQueues, TName>): Promise<void>;
|
|
1827
|
+
enqueueAndWait<const TName extends QueueFilterName<TQueues>>(name: TName, body: QueueMessageForName<TQueues, TName>["body"], opts?: QueueEnqueueAndWaitOptions): Promise<QueueCompletionResultForName<TQueues, TName>>;
|
|
1828
|
+
tryNext<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextOptions<TName, TCompletable>): Promise<any>;
|
|
1829
|
+
tryNextBatch<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueTryNextBatchOptions<TName, TCompletable>): Promise<any[]>;
|
|
1830
|
+
iter<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(opts?: QueueIterOptions<TName, TCompletable>): AsyncIterable<any>;
|
|
1831
|
+
[key: string]: any;
|
|
1910
1832
|
}
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1833
|
+
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>> {
|
|
1834
|
+
id: string;
|
|
1835
|
+
params: TConnParams;
|
|
1836
|
+
state: TConnState;
|
|
1837
|
+
isHibernatable: boolean;
|
|
1838
|
+
send(name: string, ...args: any[]): void;
|
|
1839
|
+
disconnect(reason?: string): Promise<void>;
|
|
1840
|
+
[key: string]: any;
|
|
1841
|
+
}
|
|
1842
|
+
interface ActorContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
1843
|
+
[ACTOR_CONTEXT_INTERNAL_SYMBOL]?: unknown;
|
|
1844
|
+
/** Returns the raw unwrapped state without the write-through proxy. */
|
|
1845
|
+
[RAW_STATE_SYMBOL](): TState;
|
|
1846
|
+
state: TState;
|
|
1847
|
+
vars: TVars;
|
|
1848
|
+
/**
|
|
1849
|
+
* @deprecated Actor KV is deprecated. Use embedded SQLite (`c.db`)
|
|
1850
|
+
* or actor state instead.
|
|
1851
|
+
*/
|
|
1852
|
+
readonly kv: ActorKv;
|
|
1853
|
+
readonly db: InferDatabaseClient<TDatabase>;
|
|
1854
|
+
readonly schedule: ActorSchedule;
|
|
1855
|
+
readonly cron: ActorCron;
|
|
1856
|
+
readonly queue: ActorQueue<TQueues>;
|
|
1857
|
+
/** @experimental */
|
|
1858
|
+
readonly run: ActorRun;
|
|
1859
|
+
readonly actorId: string;
|
|
1860
|
+
readonly name: string;
|
|
1861
|
+
readonly key: string[];
|
|
1862
|
+
readonly region: string;
|
|
1863
|
+
/** Provisions the experimental Actor Runtime Socket for this actor generation. */
|
|
1864
|
+
actorRuntimeSocket(): Promise<{
|
|
1865
|
+
path: string;
|
|
1866
|
+
}>;
|
|
1867
|
+
readonly conns: Map<string, Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>;
|
|
1868
|
+
readonly log: ActorLogger;
|
|
1869
|
+
readonly abortSignal: AbortSignal;
|
|
1870
|
+
readonly aborted: boolean;
|
|
1871
|
+
readonly request?: Request;
|
|
1872
|
+
/** @deprecated No-op. Always returns `false`. Use `keepAwake(promise)` or `waitUntil(promise)` instead. Will be removed in 2.2.0. */
|
|
1873
|
+
readonly preventSleep: boolean;
|
|
1874
|
+
broadcast(name: string, ...args: any[]): void;
|
|
1875
|
+
saveState(opts?: {
|
|
1876
|
+
immediate?: boolean;
|
|
1877
|
+
maxWait?: number;
|
|
1878
|
+
}): Promise<void>;
|
|
1879
|
+
keepAwake<T>(promise: Promise<T>): Promise<T>;
|
|
1880
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
1881
|
+
/** @deprecated No-op. Use `keepAwake(promise)` to hold the actor awake for a specific promise. Will be removed in 2.2.0. */
|
|
1882
|
+
setPreventSleep(preventSleep: boolean): void;
|
|
1883
|
+
sleep(): void;
|
|
1884
|
+
destroy(): void;
|
|
1885
|
+
client<T = any>(): ActorClientFor<T>;
|
|
1886
|
+
[key: string]: any;
|
|
1887
|
+
}
|
|
1888
|
+
/** @experimental How one run of a workflow function ended. */
|
|
1889
|
+
type WorkflowOutcome = "completed" | "sleeping" | "evicted" | "failed" | "cancelled";
|
|
1890
|
+
/** @experimental How one workflow step attempt ended. `retry` will be tried again, `failed` will not. */
|
|
1891
|
+
type WorkflowStepOutcome = "ok" | "retry" | "failed";
|
|
1892
|
+
/** @experimental One open run of a workflow function, traced as its own invocation. */
|
|
1893
|
+
interface WorkflowSpan {
|
|
1894
|
+
/** Runs `body` attributed to this run. */
|
|
1895
|
+
run<T>(body: () => Promise<T>): Promise<T>;
|
|
1896
|
+
/**
|
|
1897
|
+
* Called by a workflow engine before each attempt at a step. Returns
|
|
1898
|
+
* nothing when tracing is off.
|
|
1899
|
+
*/
|
|
1900
|
+
startStep(name: string, attempt: number): WorkflowStepSpan | undefined;
|
|
1901
|
+
finish(outcome: WorkflowOutcome): Promise<void>;
|
|
1902
|
+
}
|
|
1903
|
+
/** @experimental One open attempt at one workflow step. */
|
|
1904
|
+
interface WorkflowStepSpan {
|
|
1905
|
+
/** Runs `body` attributed to this attempt. */
|
|
1906
|
+
run<T>(body: () => Promise<T>): Promise<T>;
|
|
1907
|
+
/** `error` is what the step callback threw. */
|
|
1908
|
+
finish(outcome: WorkflowStepOutcome, error?: unknown): void;
|
|
1909
|
+
}
|
|
1910
|
+
/** @experimental */
|
|
1911
|
+
interface ActorRun {
|
|
1912
|
+
/**
|
|
1913
|
+
* @experimental Sets or clears the durable Unix-millisecond deadline that
|
|
1914
|
+
* ensures this actor's run handler is active, starting it if inactive.
|
|
1915
|
+
*/
|
|
1916
|
+
setWakeAt(timestamp: number | null): Promise<void>;
|
|
1917
|
+
/** @experimental Called by a workflow engine each time it runs the workflow function. */
|
|
1918
|
+
startWorkflowSpan(): Promise<WorkflowSpan>;
|
|
1919
|
+
/**
|
|
1920
|
+
* @experimental Runs `body` outside the current workflow run, so a workflow
|
|
1921
|
+
* engine's own history storage stays out of the trace.
|
|
1922
|
+
*/
|
|
1923
|
+
runOutsideWorkflowSpan<T>(body: () => T): T;
|
|
1924
|
+
}
|
|
1925
|
+
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> & {
|
|
1926
|
+
conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1927
|
+
};
|
|
1928
|
+
type BeforeActionResponseContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1929
|
+
type BeforeConnectContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActorContext<TState, unknown, unknown, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1930
|
+
type ConnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1931
|
+
type CreateConnStateContext<TState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActorContext<TState, unknown, unknown, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1932
|
+
type CreateContext<TState, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActorContext<TState, unknown, unknown, unknown, TInput, TDatabase, TEvents, TQueues>;
|
|
1933
|
+
type CreateVarsContext<TState, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = CreateContext<TState, TInput, TDatabase, TEvents, TQueues>;
|
|
1934
|
+
type DestroyContext<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>;
|
|
1935
|
+
type DisconnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1936
|
+
type RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1937
|
+
type RunContext<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>;
|
|
1938
|
+
type SleepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1939
|
+
type StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1940
|
+
type WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1941
|
+
type MigrateContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1942
|
+
type WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> = ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1943
|
+
type InspectorUnsubscribe = () => void;
|
|
1944
|
+
declare const RunConfigSchema: z.ZodObject<{
|
|
1945
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1946
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
1947
|
+
run: z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>;
|
|
1948
|
+
inspector: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1949
|
+
workflow: z.ZodOptional<z.ZodObject<{
|
|
1950
|
+
getHistory: z.ZodCustom<() => unknown, () => unknown>;
|
|
1951
|
+
getState: z.ZodOptional<z.ZodCustom<() => Promise<WorkflowState | null>, () => Promise<WorkflowState | null>>>;
|
|
1952
|
+
onHistoryUpdated: z.ZodOptional<z.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
|
|
1953
|
+
replayFromStep: z.ZodOptional<z.ZodCustom<(entryId?: string) => Promise<unknown>, (entryId?: string) => Promise<unknown>>>;
|
|
1954
|
+
}, z.core.$strip>>;
|
|
1955
|
+
}, z.core.$strip>>>;
|
|
1956
|
+
}, z.core.$strip>;
|
|
1957
|
+
type RunConfigRuntime = z.infer<typeof RunConfigSchema>;
|
|
1958
|
+
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"> & {
|
|
1959
|
+
run: (c: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
1916
1960
|
};
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1961
|
+
declare const ActorConfigSchema: z.ZodObject<{
|
|
1962
|
+
onCreate: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1963
|
+
onDestroy: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1964
|
+
onMigrate: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1965
|
+
onWake: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1966
|
+
onSleep: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1967
|
+
run: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>, z.ZodObject<{
|
|
1968
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1969
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
1970
|
+
run: z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>;
|
|
1971
|
+
inspector: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
1972
|
+
workflow: z.ZodOptional<z.ZodObject<{
|
|
1973
|
+
getHistory: z.ZodCustom<() => unknown, () => unknown>;
|
|
1974
|
+
getState: z.ZodOptional<z.ZodCustom<() => Promise<WorkflowState | null>, () => Promise<WorkflowState | null>>>;
|
|
1975
|
+
onHistoryUpdated: z.ZodOptional<z.ZodCustom<(listener: (history: unknown) => void) => InspectorUnsubscribe, (listener: (history: unknown) => void) => InspectorUnsubscribe>>;
|
|
1976
|
+
replayFromStep: z.ZodOptional<z.ZodCustom<(entryId?: string) => Promise<unknown>, (entryId?: string) => Promise<unknown>>>;
|
|
1977
|
+
}, z.core.$strip>>;
|
|
1978
|
+
}, z.core.$strip>>>;
|
|
1979
|
+
}, z.core.$strip>]>>;
|
|
1980
|
+
onStateChange: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1981
|
+
onBeforeConnect: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1982
|
+
onConnect: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1983
|
+
onDisconnect: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1984
|
+
onBeforeActionResponse: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1985
|
+
onRequest: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1986
|
+
onWebSocket: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1987
|
+
actions: z.ZodDefault<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
1988
|
+
actionInputSchemas: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
1989
|
+
tracing: z.ZodOptional<z.ZodObject<{
|
|
1990
|
+
sampler: z.ZodOptional<z.ZodNumber>;
|
|
1991
|
+
actions: z.ZodOptional<z.ZodType<ActionSampleRates, unknown, z.core.$ZodTypeInternals<ActionSampleRates, unknown>>>;
|
|
1992
|
+
}, z.core.$strict>>;
|
|
1993
|
+
connParamsSchema: z.ZodOptional<z.ZodAny>;
|
|
1994
|
+
events: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
1995
|
+
queues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
1996
|
+
state: z.ZodOptional<z.ZodAny>;
|
|
1997
|
+
createState: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
1998
|
+
connState: z.ZodOptional<z.ZodAny>;
|
|
1999
|
+
createConnState: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2000
|
+
vars: z.ZodOptional<z.ZodAny>;
|
|
2001
|
+
db: z.ZodOptional<z.ZodAny>;
|
|
2002
|
+
createVars: z.ZodOptional<z.ZodCustom<(...args: unknown[]) => unknown, (...args: unknown[]) => unknown>>;
|
|
2003
|
+
options: z.ZodPrefault<z.ZodObject<{
|
|
2004
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2005
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
2006
|
+
enableActorRuntimeSocket: z.ZodDefault<z.ZodBoolean>;
|
|
2007
|
+
canHibernateWebSocket: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodCustom<(request: Request) => boolean, (request: Request) => boolean>]>>;
|
|
2008
|
+
createVarsTimeout: z.ZodDefault<z.ZodNumber>;
|
|
2009
|
+
createConnStateTimeout: z.ZodDefault<z.ZodNumber>;
|
|
2010
|
+
onBeforeConnectTimeout: z.ZodDefault<z.ZodNumber>;
|
|
2011
|
+
onConnectTimeout: z.ZodDefault<z.ZodNumber>;
|
|
2012
|
+
onMigrateTimeout: z.ZodDefault<z.ZodNumber>;
|
|
2013
|
+
sleepGracePeriod: z.ZodDefault<z.ZodNumber>;
|
|
2014
|
+
onDestroyTimeout: z.ZodOptional<z.ZodNumber>;
|
|
2015
|
+
waitUntilTimeout: z.ZodOptional<z.ZodNumber>;
|
|
2016
|
+
stateSaveInterval: z.ZodDefault<z.ZodNumber>;
|
|
2017
|
+
actionTimeout: z.ZodDefault<z.ZodNumber>;
|
|
2018
|
+
connectionLivenessTimeout: z.ZodDefault<z.ZodNumber>;
|
|
2019
|
+
connectionLivenessInterval: z.ZodDefault<z.ZodNumber>;
|
|
2020
|
+
noSleep: z.ZodDefault<z.ZodBoolean>;
|
|
2021
|
+
sleepTimeout: z.ZodDefault<z.ZodNumber>;
|
|
2022
|
+
maxQueueSize: z.ZodDefault<z.ZodNumber>;
|
|
2023
|
+
maxSchedules: z.ZodDefault<z.ZodNumber>;
|
|
2024
|
+
maxQueueMessageSize: z.ZodDefault<z.ZodNumber>;
|
|
2025
|
+
preloadMaxWorkflowBytes: z.ZodOptional<z.ZodNumber>;
|
|
2026
|
+
preloadMaxConnectionsBytes: z.ZodOptional<z.ZodNumber>;
|
|
2027
|
+
}, z.core.$strict>>;
|
|
2028
|
+
inspector: z.ZodOptional<z.ZodObject<{
|
|
2029
|
+
tabs: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
2030
|
+
id: z.ZodString;
|
|
2031
|
+
label: z.ZodString;
|
|
2032
|
+
source: z.ZodString;
|
|
2033
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
2034
|
+
hidden: z.ZodOptional<z.ZodLiteral<false>>;
|
|
2035
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2036
|
+
id: z.ZodEnum<{
|
|
2037
|
+
state: "state";
|
|
2038
|
+
database: "database";
|
|
2039
|
+
console: "console";
|
|
2040
|
+
queue: "queue";
|
|
2041
|
+
workflow: "workflow";
|
|
2042
|
+
schedules: "schedules";
|
|
2043
|
+
connections: "connections";
|
|
2044
|
+
}>;
|
|
2045
|
+
hidden: z.ZodLiteral<true>;
|
|
2046
|
+
}, z.core.$strict>]>>>;
|
|
2047
|
+
}, z.core.$strict>>;
|
|
2048
|
+
}, z.core.$strict>;
|
|
2049
|
+
type CreateState<TState, _TConnParams, _TConnState, _TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
2050
|
+
state: TState;
|
|
1925
2051
|
} | {
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
blobValue?: never;
|
|
2052
|
+
createState: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => TState | Promise<TState>;
|
|
2053
|
+
} | Record<never, never>;
|
|
2054
|
+
type CreateConnState<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
2055
|
+
connState: TConnState;
|
|
1931
2056
|
} | {
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
2057
|
+
createConnState: (c: CreateConnStateContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => TConnState | Promise<TConnState>;
|
|
2058
|
+
} | Record<never, never>;
|
|
2059
|
+
/**
|
|
2060
|
+
* @experimental
|
|
2061
|
+
*/
|
|
2062
|
+
type CreateVars<TState, _TConnParams, _TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
2063
|
+
/**
|
|
2064
|
+
* @experimental
|
|
2065
|
+
*/
|
|
2066
|
+
vars: TVars;
|
|
1937
2067
|
} | {
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
interface RuntimeActorRuntimeSocketEndpointInfo {
|
|
1946
|
-
path: string;
|
|
1947
|
-
}
|
|
1948
|
-
interface RuntimeSqlQueryResult {
|
|
1949
|
-
columns: string[];
|
|
1950
|
-
rows: unknown[][];
|
|
1951
|
-
}
|
|
1952
|
-
type RuntimeSqlExecResult = RuntimeSqlQueryResult;
|
|
1953
|
-
interface RuntimeSqlExecuteResult extends RuntimeSqlQueryResult {
|
|
1954
|
-
changes: number;
|
|
1955
|
-
lastInsertRowId?: number | null;
|
|
1956
|
-
}
|
|
1957
|
-
interface RuntimeSqlBatchStatement {
|
|
1958
|
-
sql: string;
|
|
1959
|
-
params?: RuntimeSqlBindParams;
|
|
1960
|
-
}
|
|
1961
|
-
interface RuntimeSqlRunResult {
|
|
1962
|
-
changes: number;
|
|
2068
|
+
/**
|
|
2069
|
+
* @experimental
|
|
2070
|
+
*/
|
|
2071
|
+
createVars: (c: CreateVarsContext<TState, TInput, TDatabase, TEvents, TQueues>, driverCtx: any) => TVars | Promise<TVars>;
|
|
2072
|
+
} | Record<never, never>;
|
|
2073
|
+
interface Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
2074
|
+
[Action: string]: ((c: ActionContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, ...args: any[]) => any) | Actions<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
1963
2075
|
}
|
|
1964
|
-
interface
|
|
1965
|
-
|
|
1966
|
-
icon?: string;
|
|
1967
|
-
hasDatabase?: boolean;
|
|
1968
|
-
remoteSqlite?: boolean;
|
|
1969
|
-
enableActorRuntimeSocket?: boolean;
|
|
1970
|
-
hasState?: boolean;
|
|
1971
|
-
canHibernateWebsocket?: boolean;
|
|
1972
|
-
stateSaveIntervalMs?: number;
|
|
1973
|
-
createStateTimeoutMs?: number;
|
|
1974
|
-
onCreateTimeoutMs?: number;
|
|
1975
|
-
createVarsTimeoutMs?: number;
|
|
1976
|
-
createConnStateTimeoutMs?: number;
|
|
1977
|
-
onBeforeConnectTimeoutMs?: number;
|
|
1978
|
-
onConnectTimeoutMs?: number;
|
|
1979
|
-
onMigrateTimeoutMs?: number;
|
|
1980
|
-
onWakeTimeoutMs?: number;
|
|
1981
|
-
onBeforeActorStartTimeoutMs?: number;
|
|
1982
|
-
actionTimeoutMs?: number;
|
|
1983
|
-
onRequestTimeoutMs?: number;
|
|
1984
|
-
sleepTimeoutMs?: number;
|
|
1985
|
-
noSleep?: boolean;
|
|
1986
|
-
sleepGracePeriodMs?: number;
|
|
1987
|
-
connectionLivenessTimeoutMs?: number;
|
|
1988
|
-
connectionLivenessIntervalMs?: number;
|
|
1989
|
-
maxQueueSize?: number;
|
|
1990
|
-
maxSchedules?: number;
|
|
1991
|
-
maxQueueMessageSize?: number;
|
|
1992
|
-
maxIncomingMessageSize?: number;
|
|
1993
|
-
maxOutgoingMessageSize?: number;
|
|
1994
|
-
preloadMaxWorkflowBytes?: number;
|
|
1995
|
-
preloadMaxConnectionsBytes?: number;
|
|
1996
|
-
actions?: Array<{
|
|
1997
|
-
name: string;
|
|
1998
|
-
}>;
|
|
1999
|
-
inspectorTabs?: Array<RuntimeInspectorTabEntry>;
|
|
2076
|
+
interface ActionInputSchemas {
|
|
2077
|
+
[Action: string]: PrimitiveSchema | ActionInputSchemas;
|
|
2000
2078
|
}
|
|
2001
|
-
interface
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2079
|
+
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>> {
|
|
2080
|
+
/**
|
|
2081
|
+
* Called when the actor is first initialized.
|
|
2082
|
+
*
|
|
2083
|
+
* Use this hook to initialize your actor's state.
|
|
2084
|
+
* This is called before any other lifecycle hooks.
|
|
2085
|
+
*/
|
|
2086
|
+
onCreate?: (c: CreateContext<TState, TInput, TDatabase, TEvents, TQueues>, input: TInput) => void | Promise<void>;
|
|
2087
|
+
/**
|
|
2088
|
+
* Called when the actor is destroyed.
|
|
2089
|
+
*/
|
|
2090
|
+
onDestroy?: (c: DestroyContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
2091
|
+
/**
|
|
2092
|
+
* Called on every actor start after persisted state loads and before onWake.
|
|
2093
|
+
*
|
|
2094
|
+
* Use this hook for repeatable schema migrations or other startup work that
|
|
2095
|
+
* must run on both first boot and wake.
|
|
2096
|
+
*/
|
|
2097
|
+
onMigrate?: (c: MigrateContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, isNew: boolean) => void | Promise<void>;
|
|
2098
|
+
/**
|
|
2099
|
+
* Called when the actor is started and ready to receive connections and action.
|
|
2100
|
+
*
|
|
2101
|
+
* Use this hook to initialize resources needed for the actor's operation
|
|
2102
|
+
* (timers, external connections, etc.)
|
|
2103
|
+
*
|
|
2104
|
+
* @returns Void or a Promise that resolves when startup is complete
|
|
2105
|
+
*/
|
|
2106
|
+
onWake?: (c: WakeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
2107
|
+
/**
|
|
2108
|
+
* Called when the actor is stopping or sleeping.
|
|
2109
|
+
*
|
|
2110
|
+
* Use this hook to clean up resources, save state, or perform
|
|
2111
|
+
* any shutdown operations before the actor sleeps or stops.
|
|
2112
|
+
*
|
|
2113
|
+
* Not supported on all platforms.
|
|
2114
|
+
*
|
|
2115
|
+
* @returns Void or a Promise that resolves when shutdown is complete
|
|
2116
|
+
*/
|
|
2117
|
+
onSleep?: (c: SleepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
2118
|
+
/**
|
|
2119
|
+
* Called after the actor starts up. Does not block actor startup.
|
|
2120
|
+
*
|
|
2121
|
+
* Use this for background tasks like:
|
|
2122
|
+
* - Reading from queues in a loop
|
|
2123
|
+
* - Tick loops for periodic work
|
|
2124
|
+
* - Custom workflow logic
|
|
2125
|
+
*
|
|
2126
|
+
* **Important:** The actor may go to sleep at any time during the `run`
|
|
2127
|
+
* handler. Wrap work that must keep the actor awake with
|
|
2128
|
+
* `c.keepAwake(promise)` to block idle sleep and shutdown finalize until
|
|
2129
|
+
* the promise settles, or use `c.waitUntil(promise)` to let the graceful
|
|
2130
|
+
* shutdown window (`sleepGracePeriod`) cover deferred work.
|
|
2131
|
+
*
|
|
2132
|
+
* The handler receives an abort signal via `c.abortSignal` and a
|
|
2133
|
+
* `c.aborted` alias. Use these to gracefully exit when shutdown starts.
|
|
2134
|
+
*
|
|
2135
|
+
* If this handler exits, the actor will follow the normal idle sleep timeout
|
|
2136
|
+
* once it becomes idle.
|
|
2137
|
+
* If this handler throws, the actor logs the error and then sleeps once it
|
|
2138
|
+
* becomes idle.
|
|
2139
|
+
* Call `c.destroy()` explicitly if a run handler should destroy the actor.
|
|
2140
|
+
*
|
|
2141
|
+
* Can be either a function or a RunConfig object with optional name/icon metadata.
|
|
2142
|
+
*
|
|
2143
|
+
* @returns Void or a Promise.
|
|
2144
|
+
*/
|
|
2145
|
+
run?: ((c: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>) | RunConfig<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
2005
2146
|
/**
|
|
2006
|
-
*
|
|
2007
|
-
*
|
|
2147
|
+
* Called when the actor's state changes.
|
|
2148
|
+
*
|
|
2149
|
+
* Use this hook to react to state changes, such as updating
|
|
2150
|
+
* external systems or triggering events.
|
|
2151
|
+
*
|
|
2152
|
+
* State changes made within this hook will NOT trigger
|
|
2153
|
+
* another onStateChange call, preventing infinite recursion.
|
|
2154
|
+
*
|
|
2155
|
+
* @param newState The updated state
|
|
2008
2156
|
*/
|
|
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
|
-
|
|
2157
|
+
onStateChange?: (c: StateChangeContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, newState: TState) => void;
|
|
2158
|
+
/**
|
|
2159
|
+
* Called before a client connects to the actor.
|
|
2160
|
+
*
|
|
2161
|
+
* Use this hook to determine if a connection should be accepted
|
|
2162
|
+
* and to validate client-provided parameters. The pending connection
|
|
2163
|
+
* is not visible in `c.conns` while this hook runs.
|
|
2164
|
+
*
|
|
2165
|
+
* @param opts Connection parameters including client-provided data
|
|
2166
|
+
* @returns Void or a Promise.
|
|
2167
|
+
* @throws Throw an error to reject the connection
|
|
2168
|
+
*/
|
|
2169
|
+
onBeforeConnect?: (c: BeforeConnectContext<TState, TVars, TInput, TDatabase, TEvents, TQueues>, params: TConnParams) => void | Promise<void>;
|
|
2170
|
+
/**
|
|
2171
|
+
* Called when a client successfully connects to the actor.
|
|
2172
|
+
*
|
|
2173
|
+
* Use this hook to perform actions when a connection is established,
|
|
2174
|
+
* such as sending initial data or updating the actor's state. The
|
|
2175
|
+
* connection is visible in `c.conns` before this hook runs.
|
|
2176
|
+
*
|
|
2177
|
+
* @param conn The connection object
|
|
2178
|
+
* @returns Void or a Promise that resolves when connection handling is complete
|
|
2179
|
+
*/
|
|
2180
|
+
onConnect?: (c: ConnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
2181
|
+
/**
|
|
2182
|
+
* Called when a client disconnects from the actor.
|
|
2183
|
+
*
|
|
2184
|
+
* Use this hook to clean up resources associated with the connection
|
|
2185
|
+
* or update the actor's state.
|
|
2186
|
+
*
|
|
2187
|
+
* @param conn The connection that is being closed
|
|
2188
|
+
* @returns Void or a Promise that resolves when disconnect handling is complete
|
|
2189
|
+
*/
|
|
2190
|
+
onDisconnect?: (c: DisconnectContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, conn: Conn<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => void | Promise<void>;
|
|
2191
|
+
/**
|
|
2192
|
+
* Called before sending an action response to the client.
|
|
2193
|
+
*
|
|
2194
|
+
* Use this hook to modify or transform the output of an action before it's sent
|
|
2195
|
+
* to the client. This is useful for formatting responses, adding metadata,
|
|
2196
|
+
* or applying transformations to the output.
|
|
2197
|
+
*
|
|
2198
|
+
* @param name The name of the action that was called
|
|
2199
|
+
* @param args The arguments that were passed to the action
|
|
2200
|
+
* @param output The output that will be sent to the client
|
|
2201
|
+
* @returns The modified output to send to the client
|
|
2202
|
+
*/
|
|
2203
|
+
onBeforeActionResponse?: <Out>(c: BeforeActionResponseContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, name: string, args: unknown[], output: Out) => Out | Promise<Out>;
|
|
2204
|
+
/**
|
|
2205
|
+
* Called when a raw HTTP request is made to the actor.
|
|
2206
|
+
*
|
|
2207
|
+
* This handler receives raw HTTP requests made to `/actors/{actorName}/http/*` endpoints.
|
|
2208
|
+
* Use this hook to handle custom HTTP patterns, REST APIs, or other HTTP-based protocols.
|
|
2209
|
+
*
|
|
2210
|
+
* @param c The request context with access to the connection
|
|
2211
|
+
* @param request The raw HTTP request object
|
|
2212
|
+
* @param opts Additional options
|
|
2213
|
+
* @returns A Response object to send back, or void to continue with default routing
|
|
2214
|
+
*/
|
|
2215
|
+
onRequest?: (c: RequestContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, request: Request) => Response | Promise<Response>;
|
|
2216
|
+
/**
|
|
2217
|
+
* Called when a raw WebSocket connection is established to the actor.
|
|
2218
|
+
*
|
|
2219
|
+
* This handler receives WebSocket connections made to `/actors/{actorName}/websocket/*` endpoints.
|
|
2220
|
+
* Use this hook to handle custom WebSocket protocols, binary streams, or other WebSocket-based communication.
|
|
2221
|
+
*
|
|
2222
|
+
* @param c The WebSocket context with access to the connection
|
|
2223
|
+
* @param websocket The actor-facing raw WebSocket connection
|
|
2224
|
+
* @param opts Additional options including the original HTTP upgrade request
|
|
2225
|
+
*/
|
|
2226
|
+
onWebSocket?: (c: WebSocketContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, websocket: UniversalWebSocket) => void | Promise<void>;
|
|
2227
|
+
actions?: TActions;
|
|
2228
|
+
/**
|
|
2229
|
+
* Optional schemas for validating action argument tuples in native runtimes.
|
|
2230
|
+
* May mirror nested action groups or use dot-separated low-level action names.
|
|
2231
|
+
*/
|
|
2232
|
+
actionInputSchemas?: ActionInputSchemas;
|
|
2233
|
+
/**
|
|
2234
|
+
* How much of this actor's work is recorded in traces. Defaults to the
|
|
2235
|
+
* process sampler from `OTEL_TRACES_SAMPLER`.
|
|
2236
|
+
*/
|
|
2237
|
+
tracing?: ActorTracingOptions<TActions>;
|
|
2238
|
+
/**
|
|
2239
|
+
* Optional schema for validating connection params in native runtimes.
|
|
2240
|
+
*/
|
|
2241
|
+
connParamsSchema?: PrimitiveSchema;
|
|
2242
|
+
/**
|
|
2243
|
+
* Schema map for events broadcasted by this actor.
|
|
2244
|
+
*/
|
|
2245
|
+
events?: TEvents;
|
|
2246
|
+
/**
|
|
2247
|
+
* Schema map for queue payloads sent by this actor.
|
|
2248
|
+
*/
|
|
2249
|
+
queues?: TQueues;
|
|
2039
2250
|
}
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2251
|
+
type ActorDatabaseConfig<TDatabase extends AnyDatabaseProvider> = {
|
|
2252
|
+
/**
|
|
2253
|
+
* @experimental
|
|
2254
|
+
*/
|
|
2255
|
+
db: TDatabase;
|
|
2256
|
+
} | Record<never, never>;
|
|
2257
|
+
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>;
|
|
2258
|
+
|
|
2259
|
+
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>> {
|
|
2260
|
+
readonly config: ActorConfig<S, CP, CS, V, I, DB, E, Q, _R>;
|
|
2045
2261
|
}
|
|
2046
|
-
interface
|
|
2047
|
-
|
|
2048
|
-
headers: Record<string, string>;
|
|
2049
|
-
body: RuntimeBytes;
|
|
2262
|
+
interface AnyActorDefinition {
|
|
2263
|
+
readonly config: any;
|
|
2050
2264
|
}
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2265
|
+
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> {
|
|
2266
|
+
#private;
|
|
2267
|
+
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q, R>);
|
|
2268
|
+
get config(): ActorConfig<S, CP, CS, V, I, DB, E, Q, R>;
|
|
2054
2269
|
}
|
|
2055
|
-
|
|
2056
|
-
|
|
2270
|
+
|
|
2271
|
+
declare const ActorsSchema: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
|
|
2272
|
+
type RegistryActors = z$2.infer<typeof ActorsSchema>;
|
|
2273
|
+
declare const RegistryConfigSchema: z$2.ZodPipe<z$2.ZodObject<{
|
|
2274
|
+
use: z$2.ZodRecord<z$2.ZodString, z$2.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
|
|
2275
|
+
test: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
|
|
2276
|
+
enabled: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
|
|
2277
|
+
sqliteBackend: z$2.ZodOptional<z$2.ZodEnum<{
|
|
2278
|
+
local: "local";
|
|
2279
|
+
remote: "remote";
|
|
2280
|
+
}>>;
|
|
2281
|
+
}, z$2.core.$strip>>>;
|
|
2282
|
+
maxIncomingMessageSize: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
|
|
2283
|
+
maxOutgoingMessageSize: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
|
|
2284
|
+
runtime: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodEnum<{
|
|
2285
|
+
auto: "auto";
|
|
2286
|
+
native: "native";
|
|
2287
|
+
wasm: "wasm";
|
|
2288
|
+
}>>, z$2.ZodTransform<"auto" | "native" | "wasm", "auto" | "native" | "wasm" | undefined>>;
|
|
2289
|
+
wasm: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
|
|
2290
|
+
bindings: z$2.ZodOptional<z$2.ZodCustom<typeof _rivetkit_rivetkit_wasm, typeof _rivetkit_rivetkit_wasm>>;
|
|
2291
|
+
initInput: z$2.ZodOptional<z$2.ZodCustom<{
|
|
2292
|
+
module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
|
|
2293
|
+
} | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined, {
|
|
2294
|
+
module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
|
|
2295
|
+
} | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined>>;
|
|
2296
|
+
}, z$2.core.$strip>>>;
|
|
2297
|
+
sqlite: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodUnion<readonly [z$2.ZodEnum<{
|
|
2298
|
+
local: "local";
|
|
2299
|
+
remote: "remote";
|
|
2300
|
+
}>, z$2.ZodObject<{
|
|
2301
|
+
backend: z$2.ZodEnum<{
|
|
2302
|
+
local: "local";
|
|
2303
|
+
remote: "remote";
|
|
2304
|
+
}>;
|
|
2305
|
+
}, z$2.core.$strip>]>>, z$2.ZodTransform<{
|
|
2306
|
+
backend: "local" | "remote";
|
|
2307
|
+
} | undefined, "local" | "remote" | {
|
|
2308
|
+
backend: "local" | "remote";
|
|
2309
|
+
} | undefined>>;
|
|
2310
|
+
noWelcome: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
|
|
2311
|
+
logging: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
|
|
2312
|
+
baseLogger: z$2.ZodOptional<z$2.ZodCustom<Logger, Logger>>;
|
|
2313
|
+
level: z$2.ZodOptional<z$2.ZodEnum<{
|
|
2314
|
+
fatal: "fatal";
|
|
2315
|
+
error: "error";
|
|
2316
|
+
warn: "warn";
|
|
2317
|
+
info: "info";
|
|
2318
|
+
debug: "debug";
|
|
2319
|
+
trace: "trace";
|
|
2320
|
+
silent: "silent";
|
|
2321
|
+
}>>;
|
|
2322
|
+
}, z$2.core.$strip>>>;
|
|
2323
|
+
endpoint: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodString>, z$2.ZodTransform<string | undefined, string | undefined>>;
|
|
2324
|
+
token: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodString>, z$2.ZodTransform<string | undefined, string | undefined>>;
|
|
2325
|
+
namespace: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodString>, z$2.ZodTransform<string | undefined, string | undefined>>;
|
|
2326
|
+
headers: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodString>>>;
|
|
2327
|
+
staticDir: z$2.ZodOptional<z$2.ZodString>;
|
|
2328
|
+
httpBasePath: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
|
|
2329
|
+
httpPort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
|
|
2330
|
+
httpHost: z$2.ZodOptional<z$2.ZodString>;
|
|
2331
|
+
startEngine: z$2.ZodDefault<z$2.ZodBoolean>;
|
|
2332
|
+
engineHost: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
|
|
2333
|
+
enginePort: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
|
|
2334
|
+
engineVersion: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
|
|
2335
|
+
startServices: z$2.ZodOptional<z$2.ZodBoolean>;
|
|
2336
|
+
configurePool: z$2.ZodOptional<z$2.ZodOptional<z$2.ZodObject<{
|
|
2337
|
+
name: z$2.ZodOptional<z$2.ZodString>;
|
|
2338
|
+
url: z$2.ZodString;
|
|
2339
|
+
headers: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodString>>;
|
|
2340
|
+
requestLifespan: z$2.ZodOptional<z$2.ZodNumber>;
|
|
2341
|
+
drainGracePeriod: z$2.ZodOptional<z$2.ZodNumber>;
|
|
2342
|
+
metadata: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>>;
|
|
2343
|
+
metadataPollInterval: z$2.ZodOptional<z$2.ZodNumber>;
|
|
2344
|
+
drainOnVersionUpgrade: z$2.ZodOptional<z$2.ZodBoolean>;
|
|
2345
|
+
}, z$2.core.$strip>>>;
|
|
2346
|
+
serverless: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
|
|
2347
|
+
basePath: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodString>>;
|
|
2348
|
+
maxStartPayloadBytes: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodNumber>>;
|
|
2349
|
+
publicEndpoint: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodString>, z$2.ZodTransform<string | undefined, string | undefined>>;
|
|
2350
|
+
publicToken: z$2.ZodPipe<z$2.ZodOptional<z$2.ZodString>, z$2.ZodTransform<string | undefined, string | undefined>>;
|
|
2351
|
+
}, z$2.core.$strip>>>;
|
|
2352
|
+
envoy: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
|
|
2353
|
+
poolName: z$2.ZodDefault<z$2.ZodString>;
|
|
2354
|
+
version: z$2.ZodDefault<z$2.ZodNumber>;
|
|
2355
|
+
totalSlots: z$2.ZodDefault<z$2.ZodNumber>;
|
|
2356
|
+
envoyKey: z$2.ZodOptional<z$2.ZodString>;
|
|
2357
|
+
}, z$2.core.$strip>>>;
|
|
2358
|
+
shutdown: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodObject<{
|
|
2359
|
+
gracePeriodMs: z$2.ZodOptional<z$2.ZodNumber>;
|
|
2360
|
+
disableSignalHandlers: z$2.ZodDefault<z$2.ZodOptional<z$2.ZodBoolean>>;
|
|
2361
|
+
}, z$2.core.$strip>>>;
|
|
2362
|
+
}, z$2.core.$strip>, z$2.ZodTransform<{
|
|
2363
|
+
sqlite: {
|
|
2364
|
+
backend: "local" | "remote";
|
|
2365
|
+
} | undefined;
|
|
2366
|
+
endpoint: string | undefined;
|
|
2367
|
+
startServices: boolean;
|
|
2368
|
+
namespace: string;
|
|
2369
|
+
token: string | undefined;
|
|
2370
|
+
publicEndpoint: string | undefined;
|
|
2371
|
+
publicNamespace: string | undefined;
|
|
2372
|
+
publicToken: string | undefined;
|
|
2373
|
+
validateServerlessEndpoint: boolean;
|
|
2374
|
+
serverless: {
|
|
2375
|
+
publicEndpoint: string | undefined;
|
|
2376
|
+
basePath: string;
|
|
2377
|
+
maxStartPayloadBytes: number;
|
|
2378
|
+
publicToken: string | undefined;
|
|
2379
|
+
};
|
|
2380
|
+
use: Record<string, AnyActorDefinition>;
|
|
2381
|
+
test: {
|
|
2382
|
+
enabled: boolean;
|
|
2383
|
+
sqliteBackend?: "local" | "remote" | undefined;
|
|
2384
|
+
};
|
|
2385
|
+
maxIncomingMessageSize: number;
|
|
2386
|
+
maxOutgoingMessageSize: number;
|
|
2387
|
+
runtime: "auto" | "native" | "wasm";
|
|
2388
|
+
wasm: {
|
|
2389
|
+
bindings?: typeof _rivetkit_rivetkit_wasm | undefined;
|
|
2390
|
+
initInput?: {
|
|
2391
|
+
module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
|
|
2392
|
+
} | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
|
|
2393
|
+
};
|
|
2394
|
+
noWelcome: boolean;
|
|
2395
|
+
logging: {
|
|
2396
|
+
baseLogger?: Logger | undefined;
|
|
2397
|
+
level?: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent" | undefined;
|
|
2398
|
+
};
|
|
2057
2399
|
headers: Record<string, string>;
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2400
|
+
httpBasePath: string;
|
|
2401
|
+
httpPort: number;
|
|
2402
|
+
startEngine: boolean;
|
|
2403
|
+
engineHost: string;
|
|
2404
|
+
enginePort: number;
|
|
2405
|
+
engineVersion: string;
|
|
2406
|
+
envoy: {
|
|
2407
|
+
poolName: string;
|
|
2408
|
+
version: number;
|
|
2409
|
+
totalSlots: number;
|
|
2410
|
+
envoyKey?: string | undefined;
|
|
2411
|
+
};
|
|
2412
|
+
shutdown: {
|
|
2413
|
+
disableSignalHandlers: boolean;
|
|
2414
|
+
gracePeriodMs?: number | undefined;
|
|
2415
|
+
};
|
|
2416
|
+
staticDir?: string | undefined;
|
|
2417
|
+
httpHost?: string | undefined;
|
|
2418
|
+
configurePool?: {
|
|
2419
|
+
url: string;
|
|
2420
|
+
name?: string | undefined;
|
|
2421
|
+
headers?: Record<string, string> | undefined;
|
|
2422
|
+
requestLifespan?: number | undefined;
|
|
2423
|
+
drainGracePeriod?: number | undefined;
|
|
2424
|
+
metadata?: Record<string, unknown> | undefined;
|
|
2425
|
+
metadataPollInterval?: number | undefined;
|
|
2426
|
+
drainOnVersionUpgrade?: boolean | undefined;
|
|
2427
|
+
} | undefined;
|
|
2428
|
+
}, {
|
|
2429
|
+
use: Record<string, AnyActorDefinition>;
|
|
2430
|
+
test: {
|
|
2431
|
+
enabled: boolean;
|
|
2432
|
+
sqliteBackend?: "local" | "remote" | undefined;
|
|
2433
|
+
};
|
|
2434
|
+
maxIncomingMessageSize: number;
|
|
2435
|
+
maxOutgoingMessageSize: number;
|
|
2436
|
+
runtime: "auto" | "native" | "wasm";
|
|
2437
|
+
wasm: {
|
|
2438
|
+
bindings?: typeof _rivetkit_rivetkit_wasm | undefined;
|
|
2439
|
+
initInput?: {
|
|
2440
|
+
module_or_path: _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput>;
|
|
2441
|
+
} | _rivetkit_rivetkit_wasm.InitInput | Promise<_rivetkit_rivetkit_wasm.InitInput> | undefined;
|
|
2442
|
+
};
|
|
2443
|
+
sqlite: {
|
|
2444
|
+
backend: "local" | "remote";
|
|
2445
|
+
} | undefined;
|
|
2446
|
+
noWelcome: boolean;
|
|
2447
|
+
logging: {
|
|
2448
|
+
baseLogger?: Logger | undefined;
|
|
2449
|
+
level?: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent" | undefined;
|
|
2450
|
+
};
|
|
2451
|
+
endpoint: string | undefined;
|
|
2452
|
+
token: string | undefined;
|
|
2453
|
+
namespace: string | undefined;
|
|
2061
2454
|
headers: Record<string, string>;
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2455
|
+
httpBasePath: string;
|
|
2456
|
+
httpPort: number;
|
|
2457
|
+
startEngine: boolean;
|
|
2458
|
+
engineHost: string;
|
|
2459
|
+
enginePort: number;
|
|
2460
|
+
engineVersion: string;
|
|
2461
|
+
serverless: {
|
|
2462
|
+
basePath: string;
|
|
2463
|
+
maxStartPayloadBytes: number;
|
|
2464
|
+
publicEndpoint: string | undefined;
|
|
2465
|
+
publicToken: string | undefined;
|
|
2073
2466
|
};
|
|
2467
|
+
envoy: {
|
|
2468
|
+
poolName: string;
|
|
2469
|
+
version: number;
|
|
2470
|
+
totalSlots: number;
|
|
2471
|
+
envoyKey?: string | undefined;
|
|
2472
|
+
};
|
|
2473
|
+
shutdown: {
|
|
2474
|
+
disableSignalHandlers: boolean;
|
|
2475
|
+
gracePeriodMs?: number | undefined;
|
|
2476
|
+
};
|
|
2477
|
+
staticDir?: string | undefined;
|
|
2478
|
+
httpHost?: string | undefined;
|
|
2479
|
+
startServices?: boolean | undefined;
|
|
2480
|
+
configurePool?: {
|
|
2481
|
+
url: string;
|
|
2482
|
+
name?: string | undefined;
|
|
2483
|
+
headers?: Record<string, string> | undefined;
|
|
2484
|
+
requestLifespan?: number | undefined;
|
|
2485
|
+
drainGracePeriod?: number | undefined;
|
|
2486
|
+
metadata?: Record<string, unknown> | undefined;
|
|
2487
|
+
metadataPollInterval?: number | undefined;
|
|
2488
|
+
drainOnVersionUpgrade?: boolean | undefined;
|
|
2489
|
+
} | undefined;
|
|
2490
|
+
}>>;
|
|
2491
|
+
type RegistryConfig = z$2.infer<typeof RegistryConfigSchema>;
|
|
2492
|
+
type RegistryConfigInput<A extends RegistryActors> = Omit<z$2.input<typeof RegistryConfigSchema>, "use"> & {
|
|
2493
|
+
use: A;
|
|
2074
2494
|
};
|
|
2075
|
-
type RuntimeServerlessStreamCallback = (error: unknown, event?: RuntimeServerlessStreamEvent) => unknown;
|
|
2076
|
-
type RuntimeWebSocketEvent = {
|
|
2077
|
-
kind: "message";
|
|
2078
|
-
data: string | RuntimeBytes;
|
|
2079
|
-
binary: boolean;
|
|
2080
|
-
messageIndex?: number;
|
|
2081
|
-
} | {
|
|
2082
|
-
kind: "close";
|
|
2083
|
-
code: number;
|
|
2084
|
-
reason: string;
|
|
2085
|
-
wasClean: boolean;
|
|
2086
|
-
};
|
|
2087
|
-
interface CoreRuntime {
|
|
2088
|
-
readonly kind: "napi" | "wasm";
|
|
2089
|
-
createRegistry(): RegistryHandle;
|
|
2090
|
-
registerActor(registry: RegistryHandle, name: string, factory: ActorFactoryHandle): void;
|
|
2091
|
-
serveRegistry(registry: RegistryHandle, config: RuntimeServeConfig): Promise<void>;
|
|
2092
|
-
waitRegistryReady(registry: RegistryHandle): Promise<void>;
|
|
2093
|
-
shutdownRegistry(registry: RegistryHandle): Promise<void>;
|
|
2094
|
-
registryActorStopThresholdMs?(registry: RegistryHandle): Promise<number | undefined>;
|
|
2095
|
-
handleServerlessRequest(registry: RegistryHandle, req: RuntimeServerlessRequest, onStreamEvent: RuntimeServerlessStreamCallback, cancelToken: CancellationTokenHandle, config: RuntimeServeConfig): Promise<RuntimeServerlessResponseHead>;
|
|
2096
|
-
serveListener(registry: RegistryHandle, listener: RuntimeListenerConfig, config: RuntimeServeConfig): Promise<void>;
|
|
2097
|
-
serveApplicationListener(registry: RegistryHandle, listener: RuntimeApplicationListenerConfig, config: RuntimeServeConfig): Promise<void>;
|
|
2098
|
-
registryHealth?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
2099
|
-
registryMetadata?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
2100
|
-
registryMetrics?(registry: RegistryHandle): Promise<RuntimeRegistryRouteResponse>;
|
|
2101
|
-
createActorFactory(callbacks: object, config?: RuntimeActorConfig | undefined | null): ActorFactoryHandle;
|
|
2102
|
-
createCancellationToken(): CancellationTokenHandle;
|
|
2103
|
-
cancellationTokenAborted(token: CancellationTokenHandle): boolean;
|
|
2104
|
-
cancelCancellationToken(token: CancellationTokenHandle): void;
|
|
2105
|
-
onCancellationTokenCancelled(token: CancellationTokenHandle, callback: (...args: unknown[]) => unknown): void;
|
|
2106
|
-
actorState(ctx: ActorContextHandle): RuntimeBytes;
|
|
2107
|
-
actorBeginOnStateChange(ctx: ActorContextHandle): void;
|
|
2108
|
-
actorEndOnStateChange(ctx: ActorContextHandle): void;
|
|
2109
|
-
actorSetAlarm(ctx: ActorContextHandle, timestampMs?: number | undefined | null): void;
|
|
2110
|
-
actorSetRunWakeAt(ctx: ActorContextHandle, timestampMs?: number | undefined | null): Promise<void>;
|
|
2111
|
-
actorRequestSave(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): void;
|
|
2112
|
-
actorRequestSaveAndWait(ctx: ActorContextHandle, opts?: RuntimeRequestSaveOpts | undefined | null): Promise<void>;
|
|
2113
|
-
actorInspectorSnapshot(ctx: ActorContextHandle): RuntimeInspectorSnapshot;
|
|
2114
|
-
actorDecodeInspectorRequest(ctx: ActorContextHandle, bytes: RuntimeBytes, advertisedVersion: number): RuntimeBytes;
|
|
2115
|
-
actorEncodeInspectorResponse(ctx: ActorContextHandle, bytes: RuntimeBytes, targetVersion: number): RuntimeBytes;
|
|
2116
|
-
actorVerifyInspectorAuth(ctx: ActorContextHandle, bearerToken?: string | undefined | null): Promise<void>;
|
|
2117
|
-
actorQueueHibernationRemoval(ctx: ActorContextHandle, connId: string): void;
|
|
2118
|
-
actorTakePendingHibernationChanges(ctx: ActorContextHandle): string[];
|
|
2119
|
-
actorDirtyHibernatableConns(ctx: ActorContextHandle): ConnHandle[];
|
|
2120
|
-
actorSaveState(ctx: ActorContextHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
2121
|
-
actorSaveStateAndWorkflowBatch(ctx: ActorContextHandle, writes: RuntimeWorkflowKvWrite[]): Promise<void>;
|
|
2122
|
-
actorId(ctx: ActorContextHandle): string;
|
|
2123
|
-
actorName(ctx: ActorContextHandle): string;
|
|
2124
|
-
actorKey(ctx: ActorContextHandle): RuntimeActorKeySegment[];
|
|
2125
|
-
actorRegion(ctx: ActorContextHandle): string;
|
|
2126
|
-
actorSleep(ctx: ActorContextHandle): void;
|
|
2127
|
-
actorDestroy(ctx: ActorContextHandle): void;
|
|
2128
|
-
actorAbortSignal(ctx: ActorContextHandle): AbortSignal;
|
|
2129
|
-
actorConns(ctx: ActorContextHandle): ConnHandle[];
|
|
2130
|
-
actorConnectConn(ctx: ActorContextHandle, params: RuntimeBytes, request?: RuntimeHttpRequest | undefined | null): Promise<ConnHandle>;
|
|
2131
|
-
actorBroadcast(ctx: ActorContextHandle, name: string, args: RuntimeBytes): void;
|
|
2132
|
-
actorWaitUntil(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
2133
|
-
actorWaitForTrackedShutdownWork(ctx: ActorContextHandle): Promise<boolean>;
|
|
2134
|
-
actorWaitForTrackedShutdownWorkUnbounded(ctx: ActorContextHandle): Promise<void>;
|
|
2135
|
-
actorKeepAwake(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
2136
|
-
actorBeginKeepAwake(ctx: ActorContextHandle): number;
|
|
2137
|
-
actorEndKeepAwake(ctx: ActorContextHandle, regionId: number): void;
|
|
2138
|
-
actorRegisterTask(ctx: ActorContextHandle, promise: Promise<unknown>): void;
|
|
2139
|
-
actorRuntimeState(ctx: ActorContextHandle): object;
|
|
2140
|
-
actorClearRuntimeState(ctx: ActorContextHandle): void;
|
|
2141
|
-
actorRestartRunHandler(ctx: ActorContextHandle): void;
|
|
2142
|
-
actorBeginWebsocketCallback(ctx: ActorContextHandle): number;
|
|
2143
|
-
actorEndWebsocketCallback(ctx: ActorContextHandle, regionId: number): void;
|
|
2144
|
-
actorKvGet(ctx: ActorContextHandle, key: RuntimeBytes): Promise<RuntimeBytes | null>;
|
|
2145
|
-
actorKvPut(ctx: ActorContextHandle, key: RuntimeBytes, value: RuntimeBytes): Promise<void>;
|
|
2146
|
-
actorKvDelete(ctx: ActorContextHandle, key: RuntimeBytes): Promise<void>;
|
|
2147
|
-
actorKvDeleteRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes): Promise<void>;
|
|
2148
|
-
actorKvListPrefix(ctx: ActorContextHandle, prefix: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
|
|
2149
|
-
actorKvListRange(ctx: ActorContextHandle, start: RuntimeBytes, end: RuntimeBytes, options?: RuntimeKvListOptions | undefined | null): Promise<RuntimeKvEntry[]>;
|
|
2150
|
-
actorKvBatchGet(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<Array<RuntimeBytes | undefined | null>>;
|
|
2151
|
-
actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
|
|
2152
|
-
actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
|
|
2153
|
-
actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
2154
|
-
actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
2155
|
-
actorSqlExecuteBatch(ctx: ActorContextHandle, statements: RuntimeSqlBatchStatement[]): Promise<RuntimeSqlExecuteResult[]>;
|
|
2156
|
-
actorSqlBeginTransaction(ctx: ActorContextHandle, timeoutMs?: number): Promise<SqliteTransactionHandle>;
|
|
2157
|
-
actorSqlTransactionExec(transaction: SqliteTransactionHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
2158
|
-
actorSqlTransactionExecute(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
2159
|
-
actorSqlTransactionCommit(transaction: SqliteTransactionHandle): Promise<void>;
|
|
2160
|
-
actorSqlTransactionRollback(transaction: SqliteTransactionHandle): Promise<void>;
|
|
2161
|
-
actorBeginStateTransaction(ctx: ActorContextHandle, timeoutMs?: number): Promise<ActorStateTransactionHandle>;
|
|
2162
|
-
actorStateTransactionExec(transaction: ActorStateTransactionHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
2163
|
-
actorStateTransactionExecute(transaction: ActorStateTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
2164
|
-
actorStateTransactionCommit(transaction: ActorStateTransactionHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
2165
|
-
actorStateTransactionRollback(transaction: ActorStateTransactionHandle): Promise<void>;
|
|
2166
|
-
actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
|
|
2167
|
-
actorSqlRun(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlRunResult>;
|
|
2168
|
-
actorSqlMetrics(ctx: ActorContextHandle): SqliteNativeMetrics | null;
|
|
2169
|
-
actorSqlTakeLastKvError(ctx: ActorContextHandle): string | null;
|
|
2170
|
-
actorSqlClose(ctx: ActorContextHandle): Promise<void>;
|
|
2171
|
-
actorRuntimeSocketProvision(ctx: ActorContextHandle): Promise<RuntimeActorRuntimeSocketEndpointInfo>;
|
|
2172
|
-
actorQueueSend(ctx: ActorContextHandle, name: string, body: RuntimeBytes): Promise<RuntimeQueueMessage>;
|
|
2173
|
-
actorQueueNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueNextBatchOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage[]>;
|
|
2174
|
-
actorQueueWaitForNames(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeQueueMessage>;
|
|
2175
|
-
actorQueueWaitForNamesAvailable(ctx: ActorContextHandle, names: string[], options?: RuntimeQueueWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<void>;
|
|
2176
|
-
actorQueueCompletePersisted(ctx: ActorContextHandle, messageId: bigint, expectedName: string, response?: RuntimeBytes | undefined | null): Promise<boolean>;
|
|
2177
|
-
actorQueueEnqueueAndWait(ctx: ActorContextHandle, name: string, body: RuntimeBytes, options?: RuntimeQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationTokenHandle | undefined | null): Promise<RuntimeBytes | null>;
|
|
2178
|
-
actorQueueTryNextBatch(ctx: ActorContextHandle, options?: RuntimeQueueTryNextBatchOptions | undefined | null): RuntimeQueueMessage[];
|
|
2179
|
-
actorQueueMaxSize(ctx: ActorContextHandle): number;
|
|
2180
|
-
actorQueueInspectMessages(ctx: ActorContextHandle): Promise<RuntimeQueueInspectMessage[]>;
|
|
2181
|
-
actorQueueReset(ctx: ActorContextHandle): Promise<void>;
|
|
2182
|
-
actorScheduleAfter(ctx: ActorContextHandle, durationMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
|
|
2183
|
-
actorScheduleAt(ctx: ActorContextHandle, timestampMs: number, actionName: string, args: RuntimeBytes): Promise<string>;
|
|
2184
|
-
actorScheduleCancel(ctx: ActorContextHandle, id: string): Promise<boolean>;
|
|
2185
|
-
actorScheduleGet(ctx: ActorContextHandle, id: string): Promise<RuntimeScheduledEventInfo | undefined>;
|
|
2186
|
-
actorScheduleList(ctx: ActorContextHandle): Promise<RuntimeScheduledEventInfo[]>;
|
|
2187
|
-
actorCronSet(ctx: ActorContextHandle, name: string, expression: string, timezone: string | undefined, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
|
|
2188
|
-
actorCronEvery(ctx: ActorContextHandle, name: string, intervalMs: number, actionName: string, args: RuntimeBytes, maxHistory: number | undefined): Promise<void>;
|
|
2189
|
-
actorCronGet(ctx: ActorContextHandle, name: string): Promise<RuntimeCronJobInfo | undefined>;
|
|
2190
|
-
actorCronList(ctx: ActorContextHandle): Promise<RuntimeCronJobInfo[]>;
|
|
2191
|
-
actorCronDelete(ctx: ActorContextHandle, name: string): Promise<boolean>;
|
|
2192
|
-
actorCronHistory(ctx: ActorContextHandle, name: string, limit: number | undefined): Promise<RuntimeCronFire[]>;
|
|
2193
|
-
connId(conn: ConnHandle): string;
|
|
2194
|
-
connParams(conn: ConnHandle): RuntimeBytes;
|
|
2195
|
-
connState(conn: ConnHandle): RuntimeBytes;
|
|
2196
|
-
connSetState(conn: ConnHandle, state: RuntimeBytes): void;
|
|
2197
|
-
connIsHibernatable(conn: ConnHandle): boolean;
|
|
2198
|
-
connSend(conn: ConnHandle, name: string, args: RuntimeBytes): void;
|
|
2199
|
-
connDisconnect(conn: ConnHandle, reason?: string | undefined | null): Promise<void>;
|
|
2200
|
-
webSocketSend(ws: WebSocketHandle, data: RuntimeBytes, binary: boolean): void;
|
|
2201
|
-
webSocketClose(ws: WebSocketHandle, code?: number | undefined | null, reason?: string | undefined | null): Promise<void>;
|
|
2202
|
-
webSocketSetEventCallback(ws: WebSocketHandle, callback: (event: RuntimeWebSocketEvent) => void): void;
|
|
2203
|
-
}
|
|
2204
2495
|
|
|
2205
2496
|
declare function buildConfiguredRegistry(config: RegistryConfig): Promise<{
|
|
2206
2497
|
runtime: CoreRuntime;
|
|
@@ -2332,4 +2623,4 @@ declare class Registry<A extends RegistryActors> {
|
|
|
2332
2623
|
*/
|
|
2333
2624
|
declare function createClient<A extends Registry<any>>(endpointOrConfig?: string | ClientConfigInput): Client<A>;
|
|
2334
2625
|
|
|
2335
|
-
export { type ActorAccessor, type ActorActionFunction, type ActorActionOptions, ActorClientError, type ActorConn, ActorConnDisposed, ActorConnRaw, type ActorConnStatus, type ActorConnectOptions, ActorDefinition, RivetError as ActorError, type ActorGatewayOptions, type ActorHandle, ActorHandleRaw, type AnyActorDefinition, type Client, type ClientConfigInput, ClientRaw, type ConnectionStateCallback, type CreateOptions, type CreateRequest, type Encoding, type EventUnsubscribe, type ExtractActorsFromRegistry, type ExtractRegistryFromClient, type GetOptions, type GetWithIdOptions, MalformedResponseMessage, ManagerError, type QueryOptions, type Region, RivetError, type StatusChangeCallback, UserError, createClient };
|
|
2626
|
+
export { type ActorAccessor, type ActorActionFunction, type ActorActionOptions, ActorClientError, type ActorConn, ActorConnDisposed, ActorConnRaw, type ActorConnStatus, type ActorConnectOptions, ActorDefinition, RivetError as ActorError, type ActorGatewayOptions, type ActorHandle, ActorHandleRaw, type ActorIssueTokenOptions, type ActorTokenPermissions, type ActorTokenResource, type AnyActorDefinition, type Client, type ClientConfigInput, ClientRaw, type ConnectionStateCallback, type CreateOptions, type CreateRequest, type Encoding, type EventUnsubscribe, type ExtractActorsFromRegistry, type ExtractRegistryFromClient, type GetOptions, type GetToken, type GetWithIdOptions, type IssueTokenOptions, type IssuedToken, MalformedResponseMessage, ManagerError, type QueryOptions, type Region, RivetError, type StatusChangeCallback, type TokenGrant, UserError, createClient };
|