rivetkit 0.0.0-main.41efcce → 0.0.0-main.49693dc
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 +939 -104
- package/dist/browser/client.js +1867 -900
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +252 -129
- package/dist/browser/inspector/client.js +2079 -233
- 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 -74
- package/dist/tsup/actor/errors.d.ts +1 -74
- package/dist/tsup/actor/errors.js +5 -1
- package/dist/tsup/agent-os/index.cjs +2408 -2029
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +932 -114
- package/dist/tsup/agent-os/index.d.ts +932 -114
- package/dist/tsup/agent-os/index.js +2412 -2033
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-J27CEW6F.js → chunk-2OBVQZX6.js} +6 -6
- package/dist/tsup/chunk-2OBVQZX6.js.map +1 -0
- package/dist/tsup/chunk-3ZWHWMFJ.js +14 -0
- package/dist/tsup/chunk-3ZWHWMFJ.js.map +1 -0
- package/dist/tsup/{chunk-AK57AL7S.cjs → chunk-4KGXFC6M.cjs} +238 -22
- package/dist/tsup/chunk-4KGXFC6M.cjs.map +1 -0
- package/dist/tsup/{chunk-CVHUXINE.js → chunk-5IU3MI7X.js} +594 -72
- package/dist/tsup/chunk-5IU3MI7X.js.map +1 -0
- package/dist/tsup/{chunk-VD7AZIBR.js → chunk-6CXQMHZR.js} +1161 -361
- package/dist/tsup/chunk-6CXQMHZR.js.map +1 -0
- package/dist/tsup/{chunk-SBEFJ4IQ.js → chunk-6W2UIH3X.js} +70 -8
- package/dist/tsup/chunk-6W2UIH3X.js.map +1 -0
- package/dist/tsup/{chunk-7MRGNVSR.js → chunk-6W5VGLFT.js} +237 -21
- package/dist/tsup/chunk-6W5VGLFT.js.map +1 -0
- package/dist/tsup/{chunk-RF3MEJV6.cjs → chunk-B73TBMMG.cjs} +18 -11
- package/dist/tsup/chunk-B73TBMMG.cjs.map +1 -0
- package/dist/tsup/chunk-D6TORRA4.js +243 -0
- package/dist/tsup/chunk-D6TORRA4.js.map +1 -0
- package/dist/tsup/{chunk-PXLJOMJD.js → chunk-FXT3HN32.js} +2 -2
- package/dist/tsup/{chunk-ZGWSH7YV.js → chunk-IXBD7BXC.js} +48 -72
- package/dist/tsup/chunk-IXBD7BXC.js.map +1 -0
- package/dist/tsup/{chunk-3BFYSYRU.js → chunk-JI6GZ2C2.js} +4 -12
- package/dist/tsup/chunk-JI6GZ2C2.js.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JTHHCZCZ.js} +24 -1
- package/dist/tsup/chunk-JTHHCZCZ.js.map +1 -0
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-KVFIONKQ.cjs} +25 -2
- package/dist/tsup/chunk-KVFIONKQ.cjs.map +1 -0
- package/dist/tsup/{chunk-SPMMF6TR.cjs → chunk-LGOWPZJ5.cjs} +3 -3
- package/dist/tsup/chunk-LGOWPZJ5.cjs.map +1 -0
- package/dist/tsup/chunk-LYNWTX6R.cjs +14 -0
- package/dist/tsup/chunk-LYNWTX6R.cjs.map +1 -0
- package/dist/tsup/{chunk-LLD2D5LO.cjs → chunk-MYWZCDML.cjs} +4 -12
- package/dist/tsup/chunk-MYWZCDML.cjs.map +1 -0
- package/dist/tsup/{chunk-XSC2WWXD.js → chunk-NYDZLWHZ.js} +16 -9
- package/dist/tsup/chunk-NYDZLWHZ.js.map +1 -0
- package/dist/tsup/{chunk-AV54CVAG.cjs → chunk-RB7WUDX6.cjs} +1290 -490
- package/dist/tsup/chunk-RB7WUDX6.cjs.map +1 -0
- package/dist/tsup/{chunk-JTL6Y2UN.cjs → chunk-SPJORZMM.cjs} +49 -73
- package/dist/tsup/chunk-SPJORZMM.cjs.map +1 -0
- package/dist/tsup/chunk-SSMKIYEX.cjs +243 -0
- package/dist/tsup/chunk-SSMKIYEX.cjs.map +1 -0
- package/dist/tsup/{chunk-TQSL4NJ3.cjs → chunk-TQ4HSX2U.cjs} +72 -10
- package/dist/tsup/chunk-TQ4HSX2U.cjs.map +1 -0
- package/dist/tsup/{chunk-EVADNK6Z.cjs → chunk-U6ZQELGJ.cjs} +10 -10
- package/dist/tsup/chunk-U6ZQELGJ.cjs.map +1 -0
- package/dist/tsup/chunk-XLBMKZD3.cjs +1257 -0
- package/dist/tsup/chunk-XLBMKZD3.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +8 -9
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +18 -7
- package/dist/tsup/client/mod.d.ts +18 -7
- package/dist/tsup/client/mod.js +7 -8
- package/dist/tsup/common/log.cjs +5 -3
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.d.cts +5 -1
- package/dist/tsup/common/log.d.ts +5 -1
- package/dist/tsup/common/log.js +6 -4
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.cjs.map +1 -1
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-B3RIidaJ.d.ts → config-BXSV17G7.d.cts} +987 -72
- package/dist/tsup/{config-D6WxBYjV.d.cts → config-Bi1r6gI7.d.ts} +987 -72
- package/dist/tsup/{config-B9qUIHX4.d.ts → config-ey2I2zz5.d.cts} +82 -15
- package/dist/tsup/{config-B9qUIHX4.d.cts → config-ey2I2zz5.d.ts} +82 -15
- package/dist/tsup/context-4fJemY0D.d.cts +129 -0
- package/dist/tsup/context-D4sNYboo.d.ts +129 -0
- package/dist/tsup/db/drizzle.cjs +168 -103
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +8 -4
- package/dist/tsup/db/drizzle.d.ts +8 -4
- package/dist/tsup/db/drizzle.js +170 -105
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +6 -163
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.d.cts +12 -4
- package/dist/tsup/db/mod.d.ts +12 -4
- package/dist/tsup/db/mod.js +5 -162
- package/dist/tsup/db/mod.js.map +1 -1
- package/dist/tsup/dynamic/mod.cjs +24 -0
- package/dist/tsup/dynamic/mod.cjs.map +1 -0
- package/dist/tsup/dynamic/mod.d.cts +38 -0
- package/dist/tsup/dynamic/mod.d.ts +38 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +47 -12
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +26 -136
- package/dist/tsup/inspector/mod.d.ts +26 -136
- package/dist/tsup/inspector/mod.js +46 -11
- package/dist/tsup/inspector/mod.js.map +1 -1
- package/dist/tsup/inspector/workflow.cjs +21 -0
- package/dist/tsup/inspector/workflow.cjs.map +1 -0
- package/dist/tsup/inspector/workflow.d.cts +144 -0
- package/dist/tsup/inspector/workflow.d.ts +144 -0
- package/dist/tsup/inspector/workflow.js +21 -0
- package/dist/tsup/inspector/workflow.js.map +1 -0
- package/dist/tsup/inspector-tab/mod.cjs +162 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +241 -0
- package/dist/tsup/inspector-tab/mod.d.ts +241 -0
- package/dist/tsup/inspector-tab/mod.js +162 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +4268 -944
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +9 -8
- package/dist/tsup/mod.d.ts +9 -8
- package/dist/tsup/mod.js +4229 -905
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +26 -21
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +7 -6
- package/dist/tsup/test/mod.d.ts +7 -6
- package/dist/tsup/test/mod.js +25 -20
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/unstable/migrations.cjs +101 -0
- package/dist/tsup/unstable/migrations.cjs.map +1 -0
- package/dist/tsup/unstable/migrations.d.cts +29 -0
- package/dist/tsup/unstable/migrations.d.ts +29 -0
- package/dist/tsup/unstable/migrations.js +101 -0
- package/dist/tsup/unstable/migrations.js.map +1 -0
- package/dist/tsup/utils-Bbz-3411.d.cts +162 -0
- package/dist/tsup/utils-BqdWVlzm.d.ts +162 -0
- package/dist/tsup/utils-vvJQyygr.d.cts +109 -0
- package/dist/tsup/utils-vvJQyygr.d.ts +109 -0
- package/dist/tsup/utils.cjs +7 -3
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +4 -147
- package/dist/tsup/utils.d.ts +4 -147
- package/dist/tsup/utils.js +6 -2
- package/dist/tsup/workflow/mod.cjs +517 -412
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +11 -10
- package/dist/tsup/workflow/mod.d.ts +11 -10
- package/dist/tsup/workflow/mod.js +511 -406
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +62 -14
- package/src/actor/actions.ts +119 -0
- package/src/actor/config.test.ts +78 -0
- package/src/actor/config.ts +518 -96
- package/src/actor/contexts/index.ts +7 -2
- package/src/actor/definition.ts +38 -26
- package/src/actor/errors.ts +101 -89
- package/src/actor/keys.ts +2 -1
- package/src/actor/mod.ts +32 -21
- package/src/actor/schema.ts +2 -2
- package/src/agent-os/actor/cron.ts +37 -2
- package/src/agent-os/actor/index.ts +39 -19
- package/src/agent-os/actor/preview.ts +1 -2
- package/src/agent-os/actor/session.ts +2 -2
- package/src/agent-os/config.ts +1 -1
- package/src/agent-os/fs/database-vfs.ts +1 -1
- package/src/agent-os/index.ts +16 -15
- package/src/agent-os/types.ts +11 -0
- package/src/client/actor-common.ts +106 -53
- package/src/client/actor-conn.ts +94 -45
- package/src/client/actor-handle.ts +198 -79
- package/src/client/actor-query.ts +13 -6
- package/src/client/client.ts +43 -15
- package/src/client/config.ts +8 -0
- package/src/client/errors.ts +4 -2
- package/src/client/lifecycle-errors.ts +28 -4
- package/src/client/mod.ts +9 -4
- package/src/client/query.ts +3 -1
- package/src/client/queue.ts +8 -3
- package/src/client/raw-utils.ts +24 -16
- package/src/client/resolve-gateway-target.ts +3 -1
- package/src/client/utils.ts +36 -10
- package/src/common/actor-router-consts.ts +7 -0
- package/src/common/actor-websocket.ts +3 -1
- package/src/common/bare/actor-persist/v1.ts +205 -163
- package/src/common/bare/actor-persist/v2.ts +265 -213
- package/src/common/bare/actor-persist/v3.ts +176 -172
- package/src/common/bare/actor-persist/v4.ts +254 -253
- package/src/common/bare/generated/actor-runtime-socket-protocol/v1.ts +848 -0
- package/src/common/bare/generated/client-protocol/v4.ts +599 -0
- package/src/common/bare/generated/inspector/v5.ts +1016 -0
- package/src/common/bare/generated/inspector/v6.ts +1367 -0
- package/src/common/bare/transport/v1.ts +694 -542
- package/src/common/client-protocol-versioned.ts +176 -67
- package/src/common/client-protocol-zod.ts +7 -0
- package/src/common/client-protocol.ts +1 -1
- package/src/common/database/config.ts +103 -10
- package/src/common/database/mod.test.ts +364 -0
- package/src/common/database/mod.ts +278 -149
- package/src/common/database/native-database.test.ts +220 -0
- package/src/common/database/native-database.ts +394 -58
- package/src/common/database/shared.ts +25 -0
- package/src/common/encoding.ts +302 -38
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/fetch-like.ts +49 -0
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/inspector-transport.ts +12 -2
- package/src/common/log.ts +117 -14
- package/src/common/router.ts +49 -23
- package/src/common/utils.ts +23 -203
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/drizzle.test.ts +164 -0
- package/src/db/drizzle.ts +207 -121
- package/src/db/mod.ts +6 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +64 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-client/actor-http-client.ts +23 -4
- package/src/engine-client/actor-websocket-client.ts +32 -5
- package/src/engine-client/api-endpoints.ts +52 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +21 -17
- package/src/engine-client/mod.ts +116 -64
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/globals.d.ts +4 -0
- package/src/inspector/client.browser.ts +127 -15
- package/src/inspector/mod.ts +2 -4
- package/src/inspector/workflow.ts +61 -0
- package/src/inspector-tab/mod.ts +301 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +160 -53
- package/src/registry/config/serverless.ts +7 -1
- package/src/registry/index.ts +659 -96
- package/src/registry/napi-runtime.ts +1154 -0
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +2005 -955
- package/src/registry/process-metrics.ts +250 -0
- package/src/registry/run-handler-coordinator.test.ts +252 -0
- package/src/registry/run-handler-coordinator.ts +219 -0
- package/src/registry/runtime.test.ts +50 -0
- package/src/registry/runtime.ts +839 -0
- package/src/registry/wasm-runtime.ts +1283 -0
- package/src/registry/write-through-proxy.ts +141 -0
- package/src/serde.ts +8 -2
- package/src/serverless/configure.ts +102 -49
- package/src/test/mod.ts +2 -17
- package/src/test/ready.ts +22 -0
- package/src/unstable/migrations.test.ts +170 -0
- package/src/unstable/migrations.ts +141 -0
- package/src/utils/crypto.ts +14 -0
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +39 -0
- package/src/utils/node.ts +44 -28
- package/src/utils/router.ts +1 -1
- package/src/utils.ts +4 -2
- package/src/workflow/context.ts +683 -242
- package/src/workflow/driver.test.ts +62 -0
- package/src/workflow/driver.ts +246 -119
- package/src/workflow/inspector.ts +24 -24
- package/src/workflow/mod.ts +76 -84
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3BFYSYRU.js.map +0 -1
- package/dist/tsup/chunk-6AVUJ52Q.cjs +0 -253
- package/dist/tsup/chunk-6AVUJ52Q.cjs.map +0 -1
- package/dist/tsup/chunk-7MRGNVSR.js.map +0 -1
- package/dist/tsup/chunk-7X7RVTFF.cjs +0 -735
- package/dist/tsup/chunk-7X7RVTFF.cjs.map +0 -1
- package/dist/tsup/chunk-AK57AL7S.cjs.map +0 -1
- package/dist/tsup/chunk-AV54CVAG.cjs.map +0 -1
- package/dist/tsup/chunk-CVHUXINE.js.map +0 -1
- package/dist/tsup/chunk-EVADNK6Z.cjs.map +0 -1
- package/dist/tsup/chunk-J27CEW6F.js.map +0 -1
- package/dist/tsup/chunk-JTL6Y2UN.cjs.map +0 -1
- package/dist/tsup/chunk-LLD2D5LO.cjs.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-RF3MEJV6.cjs.map +0 -1
- package/dist/tsup/chunk-SB4MXRN2.js +0 -253
- package/dist/tsup/chunk-SB4MXRN2.js.map +0 -1
- package/dist/tsup/chunk-SBEFJ4IQ.js.map +0 -1
- package/dist/tsup/chunk-SPMMF6TR.cjs.map +0 -1
- package/dist/tsup/chunk-TQSL4NJ3.cjs.map +0 -1
- package/dist/tsup/chunk-VD7AZIBR.js.map +0 -1
- package/dist/tsup/chunk-XSC2WWXD.js.map +0 -1
- package/dist/tsup/chunk-ZGWSH7YV.js.map +0 -1
- package/dist/tsup/context-BxvHh9wi.d.cts +0 -92
- package/dist/tsup/context-CNIZBIKl.d.ts +0 -92
- package/dist/tsup/utils-fwx3o3K9.d.cts +0 -18
- package/dist/tsup/utils-fwx3o3K9.d.ts +0 -18
- package/src/actor/driver.ts +0 -141
- package/src/actor/instance/mod.ts +0 -2501
- package/src/drivers/engine/actor-driver.ts +0 -2470
- package/src/utils/serve.ts +0 -217
- /package/dist/tsup/{chunk-PXLJOMJD.js.map → chunk-FXT3HN32.js.map} +0 -0
|
@@ -1,32 +1,87 @@
|
|
|
1
|
-
interface SqliteVfsMetrics {
|
|
2
|
-
requestBuildNs: number;
|
|
3
|
-
serializeNs: number;
|
|
4
|
-
transportNs: number;
|
|
5
|
-
stateUpdateNs: number;
|
|
6
|
-
totalNs: number;
|
|
7
|
-
commitCount: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
1
|
type AnyDatabaseProvider = DatabaseProvider<any> | undefined;
|
|
11
2
|
interface ActorMetricsLike {
|
|
12
3
|
totalKvReads: number;
|
|
13
4
|
totalKvWrites: number;
|
|
14
5
|
trackSql(query: string, durationMs: number): void;
|
|
15
|
-
setSqliteVfsMetricsSource(source?: () => SqliteVfsMetrics | null): void;
|
|
16
6
|
}
|
|
17
|
-
type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> :
|
|
7
|
+
type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : RawAccess;
|
|
18
8
|
type SqliteBindings = unknown[] | Record<string, unknown>;
|
|
19
9
|
interface SqliteQueryResult {
|
|
20
10
|
columns: string[];
|
|
21
11
|
rows: unknown[][];
|
|
22
12
|
}
|
|
13
|
+
interface SqliteExecuteResult extends SqliteQueryResult {
|
|
14
|
+
changes: number;
|
|
15
|
+
lastInsertRowId?: number | null;
|
|
16
|
+
}
|
|
17
|
+
interface SqliteBatchStatement {
|
|
18
|
+
sql: string;
|
|
19
|
+
params?: SqliteBindings;
|
|
20
|
+
}
|
|
21
|
+
interface SqliteTransactionOptions {
|
|
22
|
+
/** Static operation name used to aggregate transaction performance. */
|
|
23
|
+
name?: string;
|
|
24
|
+
/** Deadlock-safety timeout in milliseconds. */
|
|
25
|
+
timeout?: number;
|
|
26
|
+
/** @experimental */
|
|
27
|
+
experimental?: {
|
|
28
|
+
/**
|
|
29
|
+
* Atomically includes actor and hibernatable connection state.
|
|
30
|
+
* Only single-statement `execute` calls are supported in the transaction.
|
|
31
|
+
* Concurrent actions that try to mutate state while the transaction is
|
|
32
|
+
* active fail with `actor.state_transaction_conflict`.
|
|
33
|
+
*/
|
|
34
|
+
includeState?: boolean;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* SQLite profiling configuration.
|
|
39
|
+
*
|
|
40
|
+
* @experimental This entire configuration surface is experimental and subject
|
|
41
|
+
* to change without notice.
|
|
42
|
+
*/
|
|
43
|
+
interface SqliteProfilingOptions {
|
|
44
|
+
enabled?: boolean;
|
|
45
|
+
maxTrackedStatementFingerprints?: number;
|
|
46
|
+
maxTrackedTransactionFingerprints?: number;
|
|
47
|
+
maxPrometheusSeries?: number;
|
|
48
|
+
maxStatementsPerTransactionTrace?: number;
|
|
49
|
+
maxGetPagesRequestsPerTrace?: number;
|
|
50
|
+
maxTransactionNameBytes?: number;
|
|
51
|
+
slowOperationThresholdMs?: number;
|
|
52
|
+
baselineSampleRate?: number;
|
|
53
|
+
maxDiagnosticEventsPerMinute?: number;
|
|
54
|
+
diagnosticEventQueueCapacity?: number;
|
|
55
|
+
}
|
|
56
|
+
interface SqliteNativeMetrics {
|
|
57
|
+
requestBuildNs: number;
|
|
58
|
+
serializeNs: number;
|
|
59
|
+
transportNs: number;
|
|
60
|
+
stateUpdateNs: number;
|
|
61
|
+
totalNs: number;
|
|
62
|
+
commitCount: number;
|
|
63
|
+
pageCacheEntries: number;
|
|
64
|
+
pageCacheWeightedSize: number;
|
|
65
|
+
pageCacheCapacityPages: number;
|
|
66
|
+
writeBufferDirtyPages: number;
|
|
67
|
+
dbSizePages: number;
|
|
68
|
+
}
|
|
23
69
|
interface SqliteDatabase {
|
|
24
70
|
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
71
|
+
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
72
|
+
executeBatch(statements: SqliteBatchStatement[]): Promise<SqliteExecuteResult[]>;
|
|
73
|
+
beginTransaction(timeoutMs?: number, name?: string): Promise<SqliteTransactionDatabase>;
|
|
25
74
|
run(sql: string, params?: SqliteBindings): Promise<void>;
|
|
26
75
|
query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
|
|
27
|
-
|
|
76
|
+
nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
|
|
28
77
|
close(): Promise<void>;
|
|
29
78
|
}
|
|
79
|
+
interface SqliteTransactionDatabase {
|
|
80
|
+
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
81
|
+
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
82
|
+
commit(): Promise<void>;
|
|
83
|
+
rollback(): Promise<void>;
|
|
84
|
+
}
|
|
30
85
|
/**
|
|
31
86
|
* Provider for opening native databases from the active runtime.
|
|
32
87
|
*/
|
|
@@ -70,6 +125,13 @@ interface DatabaseProviderContext {
|
|
|
70
125
|
nativeDatabaseProvider?: NativeDatabaseProvider;
|
|
71
126
|
}
|
|
72
127
|
type DatabaseProvider<DB extends RawAccess> = {
|
|
128
|
+
/**
|
|
129
|
+
* Local SQLite profiling controls consumed by the actor runtime.
|
|
130
|
+
*
|
|
131
|
+
* @experimental This entire configuration surface is experimental and
|
|
132
|
+
* subject to change without notice.
|
|
133
|
+
*/
|
|
134
|
+
sqliteProfiling?: SqliteProfilingOptions;
|
|
73
135
|
/**
|
|
74
136
|
* Creates a new database client for the actor.
|
|
75
137
|
* The result is passed to the actor context as `c.db`.
|
|
@@ -92,18 +154,23 @@ interface RawDatabaseClient {
|
|
|
92
154
|
/**
|
|
93
155
|
* Drizzle database client interface (will be extended by drizzle-orm types)
|
|
94
156
|
*/
|
|
95
|
-
|
|
96
|
-
}
|
|
157
|
+
type DrizzleDatabaseClient = {};
|
|
97
158
|
type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
|
|
98
159
|
type RawAccess = {
|
|
99
160
|
/**
|
|
100
161
|
* Executes a raw SQL query.
|
|
101
162
|
*/
|
|
102
163
|
execute: ExecuteFunction;
|
|
164
|
+
/** Runs a callback in an isolated SQLite transaction. */
|
|
165
|
+
transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T, options?: SqliteTransactionOptions) => Promise<T>;
|
|
166
|
+
/**
|
|
167
|
+
* Returns native SQLite metrics when the active runtime supports them.
|
|
168
|
+
*/
|
|
169
|
+
nativeMetrics?: () => SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
|
|
103
170
|
/**
|
|
104
171
|
* Closes the database connection and releases resources.
|
|
105
172
|
*/
|
|
106
173
|
close: () => Promise<void>;
|
|
107
174
|
};
|
|
108
175
|
|
|
109
|
-
export type { AnyDatabaseProvider as A, DatabaseProvider as D, InferDatabaseClient as I, NativeDatabaseProvider as N, RawAccess as R,
|
|
176
|
+
export type { AnyDatabaseProvider as A, DatabaseProvider as D, InferDatabaseClient as I, NativeDatabaseProvider as N, RawAccess as R, SqliteTransactionOptions as S, SqliteProfilingOptions as a, DatabaseProviderContext as b, RawDatabaseClient as c, SqliteBindings as d, SqliteDatabase as e, SqliteNativeMetrics as f, SqliteQueryResult as g };
|
|
@@ -1,32 +1,87 @@
|
|
|
1
|
-
interface SqliteVfsMetrics {
|
|
2
|
-
requestBuildNs: number;
|
|
3
|
-
serializeNs: number;
|
|
4
|
-
transportNs: number;
|
|
5
|
-
stateUpdateNs: number;
|
|
6
|
-
totalNs: number;
|
|
7
|
-
commitCount: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
1
|
type AnyDatabaseProvider = DatabaseProvider<any> | undefined;
|
|
11
2
|
interface ActorMetricsLike {
|
|
12
3
|
totalKvReads: number;
|
|
13
4
|
totalKvWrites: number;
|
|
14
5
|
trackSql(query: string, durationMs: number): void;
|
|
15
|
-
setSqliteVfsMetricsSource(source?: () => SqliteVfsMetrics | null): void;
|
|
16
6
|
}
|
|
17
|
-
type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> :
|
|
7
|
+
type InferDatabaseClient<DBProvider extends AnyDatabaseProvider> = DBProvider extends DatabaseProvider<any> ? Awaited<ReturnType<DBProvider["createClient"]>> : RawAccess;
|
|
18
8
|
type SqliteBindings = unknown[] | Record<string, unknown>;
|
|
19
9
|
interface SqliteQueryResult {
|
|
20
10
|
columns: string[];
|
|
21
11
|
rows: unknown[][];
|
|
22
12
|
}
|
|
13
|
+
interface SqliteExecuteResult extends SqliteQueryResult {
|
|
14
|
+
changes: number;
|
|
15
|
+
lastInsertRowId?: number | null;
|
|
16
|
+
}
|
|
17
|
+
interface SqliteBatchStatement {
|
|
18
|
+
sql: string;
|
|
19
|
+
params?: SqliteBindings;
|
|
20
|
+
}
|
|
21
|
+
interface SqliteTransactionOptions {
|
|
22
|
+
/** Static operation name used to aggregate transaction performance. */
|
|
23
|
+
name?: string;
|
|
24
|
+
/** Deadlock-safety timeout in milliseconds. */
|
|
25
|
+
timeout?: number;
|
|
26
|
+
/** @experimental */
|
|
27
|
+
experimental?: {
|
|
28
|
+
/**
|
|
29
|
+
* Atomically includes actor and hibernatable connection state.
|
|
30
|
+
* Only single-statement `execute` calls are supported in the transaction.
|
|
31
|
+
* Concurrent actions that try to mutate state while the transaction is
|
|
32
|
+
* active fail with `actor.state_transaction_conflict`.
|
|
33
|
+
*/
|
|
34
|
+
includeState?: boolean;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* SQLite profiling configuration.
|
|
39
|
+
*
|
|
40
|
+
* @experimental This entire configuration surface is experimental and subject
|
|
41
|
+
* to change without notice.
|
|
42
|
+
*/
|
|
43
|
+
interface SqliteProfilingOptions {
|
|
44
|
+
enabled?: boolean;
|
|
45
|
+
maxTrackedStatementFingerprints?: number;
|
|
46
|
+
maxTrackedTransactionFingerprints?: number;
|
|
47
|
+
maxPrometheusSeries?: number;
|
|
48
|
+
maxStatementsPerTransactionTrace?: number;
|
|
49
|
+
maxGetPagesRequestsPerTrace?: number;
|
|
50
|
+
maxTransactionNameBytes?: number;
|
|
51
|
+
slowOperationThresholdMs?: number;
|
|
52
|
+
baselineSampleRate?: number;
|
|
53
|
+
maxDiagnosticEventsPerMinute?: number;
|
|
54
|
+
diagnosticEventQueueCapacity?: number;
|
|
55
|
+
}
|
|
56
|
+
interface SqliteNativeMetrics {
|
|
57
|
+
requestBuildNs: number;
|
|
58
|
+
serializeNs: number;
|
|
59
|
+
transportNs: number;
|
|
60
|
+
stateUpdateNs: number;
|
|
61
|
+
totalNs: number;
|
|
62
|
+
commitCount: number;
|
|
63
|
+
pageCacheEntries: number;
|
|
64
|
+
pageCacheWeightedSize: number;
|
|
65
|
+
pageCacheCapacityPages: number;
|
|
66
|
+
writeBufferDirtyPages: number;
|
|
67
|
+
dbSizePages: number;
|
|
68
|
+
}
|
|
23
69
|
interface SqliteDatabase {
|
|
24
70
|
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
71
|
+
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
72
|
+
executeBatch(statements: SqliteBatchStatement[]): Promise<SqliteExecuteResult[]>;
|
|
73
|
+
beginTransaction(timeoutMs?: number, name?: string): Promise<SqliteTransactionDatabase>;
|
|
25
74
|
run(sql: string, params?: SqliteBindings): Promise<void>;
|
|
26
75
|
query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
|
|
27
|
-
|
|
76
|
+
nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
|
|
28
77
|
close(): Promise<void>;
|
|
29
78
|
}
|
|
79
|
+
interface SqliteTransactionDatabase {
|
|
80
|
+
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
81
|
+
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
82
|
+
commit(): Promise<void>;
|
|
83
|
+
rollback(): Promise<void>;
|
|
84
|
+
}
|
|
30
85
|
/**
|
|
31
86
|
* Provider for opening native databases from the active runtime.
|
|
32
87
|
*/
|
|
@@ -70,6 +125,13 @@ interface DatabaseProviderContext {
|
|
|
70
125
|
nativeDatabaseProvider?: NativeDatabaseProvider;
|
|
71
126
|
}
|
|
72
127
|
type DatabaseProvider<DB extends RawAccess> = {
|
|
128
|
+
/**
|
|
129
|
+
* Local SQLite profiling controls consumed by the actor runtime.
|
|
130
|
+
*
|
|
131
|
+
* @experimental This entire configuration surface is experimental and
|
|
132
|
+
* subject to change without notice.
|
|
133
|
+
*/
|
|
134
|
+
sqliteProfiling?: SqliteProfilingOptions;
|
|
73
135
|
/**
|
|
74
136
|
* Creates a new database client for the actor.
|
|
75
137
|
* The result is passed to the actor context as `c.db`.
|
|
@@ -92,18 +154,23 @@ interface RawDatabaseClient {
|
|
|
92
154
|
/**
|
|
93
155
|
* Drizzle database client interface (will be extended by drizzle-orm types)
|
|
94
156
|
*/
|
|
95
|
-
|
|
96
|
-
}
|
|
157
|
+
type DrizzleDatabaseClient = {};
|
|
97
158
|
type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
|
|
98
159
|
type RawAccess = {
|
|
99
160
|
/**
|
|
100
161
|
* Executes a raw SQL query.
|
|
101
162
|
*/
|
|
102
163
|
execute: ExecuteFunction;
|
|
164
|
+
/** Runs a callback in an isolated SQLite transaction. */
|
|
165
|
+
transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T, options?: SqliteTransactionOptions) => Promise<T>;
|
|
166
|
+
/**
|
|
167
|
+
* Returns native SQLite metrics when the active runtime supports them.
|
|
168
|
+
*/
|
|
169
|
+
nativeMetrics?: () => SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
|
|
103
170
|
/**
|
|
104
171
|
* Closes the database connection and releases resources.
|
|
105
172
|
*/
|
|
106
173
|
close: () => Promise<void>;
|
|
107
174
|
};
|
|
108
175
|
|
|
109
|
-
export type { AnyDatabaseProvider as A, DatabaseProvider as D, InferDatabaseClient as I, NativeDatabaseProvider as N, RawAccess as R,
|
|
176
|
+
export type { AnyDatabaseProvider as A, DatabaseProvider as D, InferDatabaseClient as I, NativeDatabaseProvider as N, RawAccess as R, SqliteTransactionOptions as S, SqliteProfilingOptions as a, DatabaseProviderContext as b, RawDatabaseClient as c, SqliteBindings as d, SqliteDatabase as e, SqliteNativeMetrics as f, SqliteQueryResult as g };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { A as AnyActorDefinition, B as BaseActorDefinition, E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext, F as ActorLogger, au as QueueFilterName, az as QueueNextOptions, aA as QueueResultMessageForName, ay as QueueNextBatchOptions, aF as Registry, a3 as Client, am as InferEventArgs, an as InferSchemaMap } from './config-BXSV17G7.cjs';
|
|
2
|
+
import { WorkflowContextInterface, StepConfig, TryStepResult, TryStepConfig, TryBlockResult, TryBlockConfig, LoopResult, LoopConfig, BranchConfig, BranchOutput, EntryKindType } from '@rivetkit/workflow-engine';
|
|
3
|
+
import { A as AnyDatabaseProvider, I as InferDatabaseClient } from './config-ey2I2zz5.cjs';
|
|
4
|
+
|
|
5
|
+
type WorkflowActorQueueNextOptions<TName extends string, TCompletable extends boolean> = Omit<QueueNextOptions<TName, TCompletable>, "signal">;
|
|
6
|
+
type WorkflowActorQueueNextOptionsFallback<TCompletable extends boolean> = Omit<QueueNextOptions<string, TCompletable>, "signal">;
|
|
7
|
+
type WorkflowActorQueueNextBatchOptions<TName extends string, TCompletable extends boolean> = Omit<QueueNextBatchOptions<TName, TCompletable>, "signal">;
|
|
8
|
+
type WorkflowActorQueueNextBatchOptionsFallback<TCompletable extends boolean> = Omit<QueueNextBatchOptions<string, TCompletable>, "signal">;
|
|
9
|
+
type WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = (step: WorkflowStepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<T>;
|
|
10
|
+
type WorkflowStepRollback<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = (step: WorkflowStepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, output: T) => Promise<void>;
|
|
11
|
+
type WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = (ctx: WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<T>;
|
|
12
|
+
type WorkflowStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<StepConfig<T>, "run" | "rollback"> & {
|
|
13
|
+
run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
14
|
+
rollback?: WorkflowStepRollback<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
15
|
+
};
|
|
16
|
+
type WorkflowTryStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<TryStepConfig<T>, "run" | "rollback"> & {
|
|
17
|
+
run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
18
|
+
rollback?: WorkflowStepRollback<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
19
|
+
};
|
|
20
|
+
type WorkflowTryConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<TryBlockConfig<T>, "run"> & {
|
|
21
|
+
run: WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
22
|
+
};
|
|
23
|
+
type WorkflowLoopConfig<S, T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<LoopConfig<S, T>, "run"> & {
|
|
24
|
+
run: (ctx: WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, state: S) => Promise<LoopResult<S, T> | (S extends undefined ? undefined | void : never)>;
|
|
25
|
+
};
|
|
26
|
+
type WorkflowBranchConfig<TOutput, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
27
|
+
run: WorkflowContextRun<TOutput, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
28
|
+
};
|
|
29
|
+
declare const DEACTIVATE_STEP: unique symbol;
|
|
30
|
+
/**
|
|
31
|
+
* The context handed to a workflow step (`step` / `tryStep` callbacks). This is
|
|
32
|
+
* the only scope where actor data (state, vars, db, client) and side effects
|
|
33
|
+
* (broadcast, queue.send) are reachable. It is valid only while its step is
|
|
34
|
+
* executing; using it after the step resolves throws.
|
|
35
|
+
*/
|
|
36
|
+
declare class WorkflowStepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
37
|
+
#private;
|
|
38
|
+
constructor(runCtx: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, onGuardViolation: () => void);
|
|
39
|
+
[DEACTIVATE_STEP](): void;
|
|
40
|
+
get actorId(): string;
|
|
41
|
+
get name(): string;
|
|
42
|
+
get key(): string[];
|
|
43
|
+
get log(): ActorLogger;
|
|
44
|
+
get abortSignal(): AbortSignal;
|
|
45
|
+
get state(): TState extends never ? never : TState;
|
|
46
|
+
get vars(): TVars extends never ? never : TVars;
|
|
47
|
+
get db(): TDatabase extends never ? never : InferDatabaseClient<TDatabase>;
|
|
48
|
+
client<R extends Registry<any> = Registry<any>>(): Client<R>;
|
|
49
|
+
broadcast<K extends keyof TEvents & string>(name: K, ...args: InferEventArgs<InferSchemaMap<TEvents>[K]>): void;
|
|
50
|
+
broadcast(name: keyof TEvents extends never ? string : never, ...args: Array<unknown>): void;
|
|
51
|
+
get queue(): {
|
|
52
|
+
send: {
|
|
53
|
+
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K]): Promise<void>;
|
|
54
|
+
(name: keyof TQueues extends never ? string : never, body: unknown): Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Holds the actor awake for the duration of the provided promise. The actor
|
|
59
|
+
* cannot idle-sleep or finalize the sleep grace period until the promise
|
|
60
|
+
* settles.
|
|
61
|
+
*/
|
|
62
|
+
keepAwake<T>(promise: Promise<T>): Promise<T>;
|
|
63
|
+
/**
|
|
64
|
+
* Registers a promise that the sleep grace period will wait on. Use this for
|
|
65
|
+
* best-effort flush/cleanup work that may complete inside the grace window.
|
|
66
|
+
*/
|
|
67
|
+
waitUntil(promise: Promise<void>): void;
|
|
68
|
+
destroy(): void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The context handed to the workflow function and to orchestration callbacks
|
|
72
|
+
* (`try` / `loop` / `race` / `join`). It exposes the deterministic, replayable
|
|
73
|
+
* workflow primitives (step, sleep, queue waits, control flow). It deliberately
|
|
74
|
+
* does NOT expose actor data; reach `state`, `db`, `vars`, `client`, and
|
|
75
|
+
* `broadcast` through the step context passed to `step` / `tryStep`.
|
|
76
|
+
*/
|
|
77
|
+
declare class WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
78
|
+
#private;
|
|
79
|
+
constructor(inner: WorkflowContextInterface, runCtx: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>);
|
|
80
|
+
get workflowId(): string;
|
|
81
|
+
get abortSignal(): AbortSignal;
|
|
82
|
+
get actorId(): string;
|
|
83
|
+
get name(): string;
|
|
84
|
+
get key(): string[];
|
|
85
|
+
get log(): ActorLogger;
|
|
86
|
+
get queue(): {
|
|
87
|
+
next: {
|
|
88
|
+
<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextOptions<TName, TCompletable>): Promise<QueueResultMessageForName<TQueues, TName, TCompletable>>;
|
|
89
|
+
<const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextOptionsFallback<TCompletable>): Promise<QueueResultMessageForName<TQueues, QueueFilterName<TQueues>, TCompletable>>;
|
|
90
|
+
};
|
|
91
|
+
nextBatch: {
|
|
92
|
+
<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextBatchOptions<TName, TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, TName, TCompletable>>>;
|
|
93
|
+
<const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextBatchOptionsFallback<TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, QueueFilterName<TQueues>, TCompletable>>>;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
step<T>(name: string, run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<T>;
|
|
97
|
+
step<T>(config: WorkflowStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<T>;
|
|
98
|
+
tryStep<T>(name: string, run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryStepResult<T>>;
|
|
99
|
+
tryStep<T>(config: WorkflowTryStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryStepResult<T>>;
|
|
100
|
+
try<T>(name: string, run: WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryBlockResult<T>>;
|
|
101
|
+
try<T>(config: WorkflowTryConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryBlockResult<T>>;
|
|
102
|
+
loop<T>(name: string, run: (ctx: WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<LoopResult<undefined, T> | undefined | void>): Promise<T>;
|
|
103
|
+
loop<S, T>(config: WorkflowLoopConfig<S, T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<T>;
|
|
104
|
+
sleep(name: string, durationMs: number): Promise<void>;
|
|
105
|
+
sleepUntil(name: string, timestampMs: number): Promise<void>;
|
|
106
|
+
rollbackCheckpoint(name: string): Promise<void>;
|
|
107
|
+
join<T extends Record<string, WorkflowBranchConfig<unknown, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>>(name: string, branches: T): Promise<{
|
|
108
|
+
[K in keyof T]: Awaited<ReturnType<T[K]["run"]>>;
|
|
109
|
+
}>;
|
|
110
|
+
join<T extends Record<string, BranchConfig<unknown>>>(name: string, branches: T): Promise<{
|
|
111
|
+
[K in keyof T]: BranchOutput<T[K]>;
|
|
112
|
+
}>;
|
|
113
|
+
race<T>(name: string, branches: Array<{
|
|
114
|
+
name: string;
|
|
115
|
+
run: WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
116
|
+
}>): Promise<{
|
|
117
|
+
winner: string;
|
|
118
|
+
value: T;
|
|
119
|
+
}>;
|
|
120
|
+
removed(name: string, originalType: EntryKindType): Promise<void>;
|
|
121
|
+
getVersion(name: string, latest: number): Promise<number>;
|
|
122
|
+
isEvicted(): boolean;
|
|
123
|
+
}
|
|
124
|
+
type WorkflowContextOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? WorkflowContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
125
|
+
type WorkflowLoopContextOf<AD extends AnyActorDefinition> = WorkflowContextOf<AD>;
|
|
126
|
+
type WorkflowBranchContextOf<AD extends AnyActorDefinition> = WorkflowContextOf<AD>;
|
|
127
|
+
type WorkflowStepContextOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? WorkflowStepContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
128
|
+
|
|
129
|
+
export { type WorkflowBranchContextOf as W, type WorkflowContextOf as a, type WorkflowLoopContextOf as b, type WorkflowStepContextOf as c, WorkflowContext as d, type WorkflowBranchConfig as e, type WorkflowLoopConfig as f, type WorkflowStepConfig as g, WorkflowStepContext as h, type WorkflowTryConfig as i, type WorkflowTryStepConfig as j };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { A as AnyActorDefinition, B as BaseActorDefinition, E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext, F as ActorLogger, au as QueueFilterName, az as QueueNextOptions, aA as QueueResultMessageForName, ay as QueueNextBatchOptions, aF as Registry, a3 as Client, am as InferEventArgs, an as InferSchemaMap } from './config-Bi1r6gI7.js';
|
|
2
|
+
import { WorkflowContextInterface, StepConfig, TryStepResult, TryStepConfig, TryBlockResult, TryBlockConfig, LoopResult, LoopConfig, BranchConfig, BranchOutput, EntryKindType } from '@rivetkit/workflow-engine';
|
|
3
|
+
import { A as AnyDatabaseProvider, I as InferDatabaseClient } from './config-ey2I2zz5.js';
|
|
4
|
+
|
|
5
|
+
type WorkflowActorQueueNextOptions<TName extends string, TCompletable extends boolean> = Omit<QueueNextOptions<TName, TCompletable>, "signal">;
|
|
6
|
+
type WorkflowActorQueueNextOptionsFallback<TCompletable extends boolean> = Omit<QueueNextOptions<string, TCompletable>, "signal">;
|
|
7
|
+
type WorkflowActorQueueNextBatchOptions<TName extends string, TCompletable extends boolean> = Omit<QueueNextBatchOptions<TName, TCompletable>, "signal">;
|
|
8
|
+
type WorkflowActorQueueNextBatchOptionsFallback<TCompletable extends boolean> = Omit<QueueNextBatchOptions<string, TCompletable>, "signal">;
|
|
9
|
+
type WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = (step: WorkflowStepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<T>;
|
|
10
|
+
type WorkflowStepRollback<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = (step: WorkflowStepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, output: T) => Promise<void>;
|
|
11
|
+
type WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = (ctx: WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<T>;
|
|
12
|
+
type WorkflowStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<StepConfig<T>, "run" | "rollback"> & {
|
|
13
|
+
run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
14
|
+
rollback?: WorkflowStepRollback<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
15
|
+
};
|
|
16
|
+
type WorkflowTryStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<TryStepConfig<T>, "run" | "rollback"> & {
|
|
17
|
+
run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
18
|
+
rollback?: WorkflowStepRollback<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
19
|
+
};
|
|
20
|
+
type WorkflowTryConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<TryBlockConfig<T>, "run"> & {
|
|
21
|
+
run: WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
22
|
+
};
|
|
23
|
+
type WorkflowLoopConfig<S, T, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = Omit<LoopConfig<S, T>, "run"> & {
|
|
24
|
+
run: (ctx: WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, state: S) => Promise<LoopResult<S, T> | (S extends undefined ? undefined | void : never)>;
|
|
25
|
+
};
|
|
26
|
+
type WorkflowBranchConfig<TOutput, TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig, TQueues extends QueueSchemaConfig> = {
|
|
27
|
+
run: WorkflowContextRun<TOutput, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
28
|
+
};
|
|
29
|
+
declare const DEACTIVATE_STEP: unique symbol;
|
|
30
|
+
/**
|
|
31
|
+
* The context handed to a workflow step (`step` / `tryStep` callbacks). This is
|
|
32
|
+
* the only scope where actor data (state, vars, db, client) and side effects
|
|
33
|
+
* (broadcast, queue.send) are reachable. It is valid only while its step is
|
|
34
|
+
* executing; using it after the step resolves throws.
|
|
35
|
+
*/
|
|
36
|
+
declare class WorkflowStepContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
37
|
+
#private;
|
|
38
|
+
constructor(runCtx: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>, onGuardViolation: () => void);
|
|
39
|
+
[DEACTIVATE_STEP](): void;
|
|
40
|
+
get actorId(): string;
|
|
41
|
+
get name(): string;
|
|
42
|
+
get key(): string[];
|
|
43
|
+
get log(): ActorLogger;
|
|
44
|
+
get abortSignal(): AbortSignal;
|
|
45
|
+
get state(): TState extends never ? never : TState;
|
|
46
|
+
get vars(): TVars extends never ? never : TVars;
|
|
47
|
+
get db(): TDatabase extends never ? never : InferDatabaseClient<TDatabase>;
|
|
48
|
+
client<R extends Registry<any> = Registry<any>>(): Client<R>;
|
|
49
|
+
broadcast<K extends keyof TEvents & string>(name: K, ...args: InferEventArgs<InferSchemaMap<TEvents>[K]>): void;
|
|
50
|
+
broadcast(name: keyof TEvents extends never ? string : never, ...args: Array<unknown>): void;
|
|
51
|
+
get queue(): {
|
|
52
|
+
send: {
|
|
53
|
+
<K extends keyof TQueues & string>(name: K, body: InferSchemaMap<TQueues>[K]): Promise<void>;
|
|
54
|
+
(name: keyof TQueues extends never ? string : never, body: unknown): Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Holds the actor awake for the duration of the provided promise. The actor
|
|
59
|
+
* cannot idle-sleep or finalize the sleep grace period until the promise
|
|
60
|
+
* settles.
|
|
61
|
+
*/
|
|
62
|
+
keepAwake<T>(promise: Promise<T>): Promise<T>;
|
|
63
|
+
/**
|
|
64
|
+
* Registers a promise that the sleep grace period will wait on. Use this for
|
|
65
|
+
* best-effort flush/cleanup work that may complete inside the grace window.
|
|
66
|
+
*/
|
|
67
|
+
waitUntil(promise: Promise<void>): void;
|
|
68
|
+
destroy(): void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The context handed to the workflow function and to orchestration callbacks
|
|
72
|
+
* (`try` / `loop` / `race` / `join`). It exposes the deterministic, replayable
|
|
73
|
+
* workflow primitives (step, sleep, queue waits, control flow). It deliberately
|
|
74
|
+
* does NOT expose actor data; reach `state`, `db`, `vars`, `client`, and
|
|
75
|
+
* `broadcast` through the step context passed to `step` / `tryStep`.
|
|
76
|
+
*/
|
|
77
|
+
declare class WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase extends AnyDatabaseProvider, TEvents extends EventSchemaConfig = Record<never, never>, TQueues extends QueueSchemaConfig = Record<never, never>> {
|
|
78
|
+
#private;
|
|
79
|
+
constructor(inner: WorkflowContextInterface, runCtx: RunContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>);
|
|
80
|
+
get workflowId(): string;
|
|
81
|
+
get abortSignal(): AbortSignal;
|
|
82
|
+
get actorId(): string;
|
|
83
|
+
get name(): string;
|
|
84
|
+
get key(): string[];
|
|
85
|
+
get log(): ActorLogger;
|
|
86
|
+
get queue(): {
|
|
87
|
+
next: {
|
|
88
|
+
<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextOptions<TName, TCompletable>): Promise<QueueResultMessageForName<TQueues, TName, TCompletable>>;
|
|
89
|
+
<const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextOptionsFallback<TCompletable>): Promise<QueueResultMessageForName<TQueues, QueueFilterName<TQueues>, TCompletable>>;
|
|
90
|
+
};
|
|
91
|
+
nextBatch: {
|
|
92
|
+
<const TName extends QueueFilterName<TQueues>, const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextBatchOptions<TName, TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, TName, TCompletable>>>;
|
|
93
|
+
<const TCompletable extends boolean = false>(name: string, opts?: WorkflowActorQueueNextBatchOptionsFallback<TCompletable>): Promise<Array<QueueResultMessageForName<TQueues, QueueFilterName<TQueues>, TCompletable>>>;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
step<T>(name: string, run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<T>;
|
|
97
|
+
step<T>(config: WorkflowStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<T>;
|
|
98
|
+
tryStep<T>(name: string, run: WorkflowStepRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryStepResult<T>>;
|
|
99
|
+
tryStep<T>(config: WorkflowTryStepConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryStepResult<T>>;
|
|
100
|
+
try<T>(name: string, run: WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryBlockResult<T>>;
|
|
101
|
+
try<T>(config: WorkflowTryConfig<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<TryBlockResult<T>>;
|
|
102
|
+
loop<T>(name: string, run: (ctx: WorkflowContext<TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>) => Promise<LoopResult<undefined, T> | undefined | void>): Promise<T>;
|
|
103
|
+
loop<S, T>(config: WorkflowLoopConfig<S, T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>): Promise<T>;
|
|
104
|
+
sleep(name: string, durationMs: number): Promise<void>;
|
|
105
|
+
sleepUntil(name: string, timestampMs: number): Promise<void>;
|
|
106
|
+
rollbackCheckpoint(name: string): Promise<void>;
|
|
107
|
+
join<T extends Record<string, WorkflowBranchConfig<unknown, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>>>(name: string, branches: T): Promise<{
|
|
108
|
+
[K in keyof T]: Awaited<ReturnType<T[K]["run"]>>;
|
|
109
|
+
}>;
|
|
110
|
+
join<T extends Record<string, BranchConfig<unknown>>>(name: string, branches: T): Promise<{
|
|
111
|
+
[K in keyof T]: BranchOutput<T[K]>;
|
|
112
|
+
}>;
|
|
113
|
+
race<T>(name: string, branches: Array<{
|
|
114
|
+
name: string;
|
|
115
|
+
run: WorkflowContextRun<T, TState, TConnParams, TConnState, TVars, TInput, TDatabase, TEvents, TQueues>;
|
|
116
|
+
}>): Promise<{
|
|
117
|
+
winner: string;
|
|
118
|
+
value: T;
|
|
119
|
+
}>;
|
|
120
|
+
removed(name: string, originalType: EntryKindType): Promise<void>;
|
|
121
|
+
getVersion(name: string, latest: number): Promise<number>;
|
|
122
|
+
isEvicted(): boolean;
|
|
123
|
+
}
|
|
124
|
+
type WorkflowContextOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? WorkflowContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
125
|
+
type WorkflowLoopContextOf<AD extends AnyActorDefinition> = WorkflowContextOf<AD>;
|
|
126
|
+
type WorkflowBranchContextOf<AD extends AnyActorDefinition> = WorkflowContextOf<AD>;
|
|
127
|
+
type WorkflowStepContextOf<AD extends AnyActorDefinition> = AD extends BaseActorDefinition<infer S, infer CP, infer CS, infer V, infer I, infer DB extends AnyDatabaseProvider, infer E extends EventSchemaConfig, infer Q extends QueueSchemaConfig, any> ? WorkflowStepContext<S, CP, CS, V, I, DB, E, Q> : never;
|
|
128
|
+
|
|
129
|
+
export { type WorkflowBranchContextOf as W, type WorkflowContextOf as a, type WorkflowLoopContextOf as b, type WorkflowStepContextOf as c, WorkflowContext as d, type WorkflowBranchConfig as e, type WorkflowLoopConfig as f, type WorkflowStepConfig as g, WorkflowStepContext as h, type WorkflowTryConfig as i, type WorkflowTryStepConfig as j };
|