rivetkit 0.0.0-active-actors-fix-active-count.253e406 → 0.0.0-bisect-sync-sqlite-1.910d1c7
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 +1286 -89
- package/dist/browser/client.js +1699 -704
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.d.ts +252 -129
- package/dist/browser/inspector/client.js +2083 -236
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +8 -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 +7 -1
- package/dist/tsup/agent-os/index.cjs +3 -2289
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +1 -1813
- package/dist/tsup/agent-os/index.d.ts +1 -1813
- package/dist/tsup/agent-os/index.js +3 -2289
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/chunk-2JJU7IQ7.cjs +14 -0
- package/dist/tsup/chunk-2JJU7IQ7.cjs.map +1 -0
- package/dist/tsup/{chunk-DZJZLZ4R.js → chunk-2MXBZGUP.js} +2 -2
- package/dist/tsup/{chunk-L4FVS7GY.js → chunk-47IS5ZFI.js} +6 -6
- package/dist/tsup/chunk-47IS5ZFI.js.map +1 -0
- package/dist/tsup/{chunk-DXWOGCZY.js → chunk-5XWY5CBA.js} +70 -8
- package/dist/tsup/chunk-5XWY5CBA.js.map +1 -0
- package/dist/tsup/{chunk-OQEEZDIK.cjs → chunk-6XVNZKKP.cjs} +506 -31
- package/dist/tsup/chunk-6XVNZKKP.cjs.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-A2CF6PFH.js} +20 -12
- package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
- package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-AQJFKHBK.cjs} +276 -27
- package/dist/tsup/chunk-AQJFKHBK.cjs.map +1 -0
- package/dist/tsup/chunk-DPWLASMC.cjs +244 -0
- package/dist/tsup/chunk-DPWLASMC.cjs.map +1 -0
- package/dist/tsup/{chunk-VUF2YEF4.cjs → chunk-DYJOU3MF.cjs} +10 -10
- package/dist/tsup/chunk-DYJOU3MF.cjs.map +1 -0
- package/dist/tsup/{chunk-7WXCRV25.cjs → chunk-ELZ6MT3V.cjs} +18 -11
- package/dist/tsup/chunk-ELZ6MT3V.cjs.map +1 -0
- package/dist/tsup/chunk-HYIVSH5X.js +244 -0
- package/dist/tsup/chunk-HYIVSH5X.js.map +1 -0
- package/dist/tsup/{chunk-T6YVRM4K.js → chunk-IHEO5OT3.js} +275 -26
- package/dist/tsup/chunk-IHEO5OT3.js.map +1 -0
- package/dist/tsup/chunk-IWACVNN5.js +14 -0
- package/dist/tsup/chunk-IWACVNN5.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-V4JUWAT6.js → chunk-K3AJOPSF.js} +498 -23
- package/dist/tsup/chunk-K3AJOPSF.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-QAZLM4WT.cjs → chunk-MGI2VVF6.cjs} +45 -9
- package/dist/tsup/chunk-MGI2VVF6.cjs.map +1 -0
- package/dist/tsup/{chunk-QNLGOTQP.js → chunk-NPHTIUUJ.js} +1291 -420
- package/dist/tsup/chunk-NPHTIUUJ.js.map +1 -0
- package/dist/tsup/{chunk-7GKQJFSB.cjs → chunk-POCSZXPQ.cjs} +72 -10
- package/dist/tsup/chunk-POCSZXPQ.cjs.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-RTWH3AX3.cjs} +19 -11
- package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
- package/dist/tsup/{chunk-ARRBQTAR.cjs → chunk-X76BM5JS.cjs} +1420 -549
- package/dist/tsup/chunk-X76BM5JS.cjs.map +1 -0
- package/dist/tsup/{chunk-AGBP757I.js → chunk-X7SYKFPM.js} +16 -9
- package/dist/tsup/chunk-X7SYKFPM.js.map +1 -0
- package/dist/tsup/{chunk-GKAMEBTZ.cjs → chunk-XLDJSZ3B.cjs} +3 -3
- package/dist/tsup/{chunk-GKAMEBTZ.cjs.map → chunk-XLDJSZ3B.cjs.map} +1 -1
- package/dist/tsup/{chunk-KIWH5H3K.js → chunk-ZOVJDAOW.js} +44 -8
- package/dist/tsup/chunk-ZOVJDAOW.js.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 +33 -7
- package/dist/tsup/client/mod.d.ts +33 -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.js +3 -3
- package/dist/tsup/{config-nlTlOKaE.d.cts → config-BMGUEKMZ.d.cts} +1252 -75
- package/dist/tsup/config-CBTr4IhE.d.cts +224 -0
- package/dist/tsup/config-CBTr4IhE.d.ts +224 -0
- package/dist/tsup/{config-D7ykAntK.d.ts → config-iBpXyITj.d.ts} +1252 -75
- package/dist/tsup/context-hyVakgnU.d.ts +136 -0
- package/dist/tsup/context-qfvLuF0P.d.cts +136 -0
- package/dist/tsup/db/drizzle.cjs +127 -67
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +8 -4
- package/dist/tsup/db/drizzle.d.ts +8 -4
- package/dist/tsup/db/drizzle.js +127 -67
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +6 -124
- package/dist/tsup/db/mod.cjs.map +1 -1
- package/dist/tsup/db/mod.d.cts +12 -4
- package/dist/tsup/db/mod.d.ts +12 -4
- package/dist/tsup/db/mod.js +5 -123
- package/dist/tsup/db/mod.js.map +1 -1
- package/dist/tsup/dynamic/mod.cjs +24 -0
- package/dist/tsup/dynamic/mod.cjs.map +1 -0
- package/dist/tsup/dynamic/mod.d.cts +39 -0
- package/dist/tsup/dynamic/mod.d.ts +39 -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 +242 -0
- package/dist/tsup/inspector-tab/mod.d.ts +242 -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 +3527 -753
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +11 -7
- package/dist/tsup/mod.d.ts +11 -7
- package/dist/tsup/mod.js +3468 -694
- 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 -5
- package/dist/tsup/test/mod.d.ts +7 -5
- package/dist/tsup/test/mod.js +25 -20
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/unstable/migrations.cjs +101 -0
- package/dist/tsup/unstable/migrations.cjs.map +1 -0
- package/dist/tsup/unstable/migrations.d.cts +29 -0
- package/dist/tsup/unstable/migrations.d.ts +29 -0
- package/dist/tsup/unstable/migrations.js +101 -0
- package/dist/tsup/unstable/migrations.js.map +1 -0
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-3rsE0JvI.d.cts} +26 -2
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-3rsE0JvI.d.ts} +26 -2
- package/dist/tsup/utils-C1O-SklO.d.ts +162 -0
- package/dist/tsup/utils-C6b0aYUM.d.cts +162 -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 +557 -410
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +11 -9
- package/dist/tsup/workflow/mod.d.ts +11 -9
- package/dist/tsup/workflow/mod.js +551 -404
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +67 -18
- package/src/actor/actions.ts +155 -0
- package/src/actor/config.ts +679 -101
- package/src/actor/contexts/index.ts +9 -2
- package/src/actor/definition.ts +75 -26
- package/src/actor/errors.ts +107 -8
- package/src/actor/keys.ts +87 -1
- package/src/actor/mod.ts +36 -20
- package/src/actor/schema.ts +6 -2
- package/src/actor/tracing.ts +28 -0
- package/src/agent-os/index.ts +5 -64
- package/src/client/actor-common.ts +84 -54
- package/src/client/actor-conn.ts +231 -68
- package/src/client/actor-handle.ts +283 -89
- package/src/client/actor-query.ts +13 -6
- package/src/client/auth.ts +37 -0
- package/src/client/client.ts +182 -21
- package/src/client/config.ts +28 -3
- package/src/client/errors.ts +15 -2
- package/src/client/lifecycle-errors.ts +63 -5
- package/src/client/mod.ts +10 -0
- package/src/client/outbound-telemetry.ts +66 -0
- package/src/client/query.ts +3 -1
- package/src/client/queue.ts +13 -3
- package/src/client/raw-utils.ts +59 -14
- package/src/client/resolve-gateway-target.ts +3 -1
- package/src/client/retry-budget.ts +81 -0
- package/src/client/token-provider.ts +93 -0
- package/src/client/utils.ts +22 -9
- package/src/common/actor-router-consts.ts +6 -0
- package/src/common/actor-telemetry-context.ts +19 -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/inspector/v5.ts +1016 -0
- package/src/common/bare/generated/inspector/v6.ts +1367 -0
- package/src/common/bare/transport/v1.ts +694 -542
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +175 -9
- package/src/common/database/mod.ts +262 -77
- package/src/common/database/native-database.ts +442 -20
- package/src/common/database/shared.ts +25 -0
- package/src/common/encoding.ts +278 -34
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/fetch-like.ts +63 -0
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/inspector-transport.ts +12 -2
- package/src/common/log.ts +15 -8
- package/src/common/otel-context.ts +99 -0
- package/src/common/router.ts +14 -18
- package/src/common/utils.ts +8 -169
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/drizzle.ts +182 -80
- package/src/db/mod.ts +5 -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-api/actors.ts +15 -3
- package/src/engine-client/actor-http-client.ts +37 -22
- package/src/engine-client/actor-websocket-client.ts +37 -9
- package/src/engine-client/api-endpoints.ts +128 -5
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +21 -16
- package/src/engine-client/mod.ts +280 -111
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +127 -15
- package/src/inspector/mod.ts +2 -4
- package/src/inspector/workflow.ts +61 -0
- package/src/inspector-tab/mod.ts +301 -0
- package/src/registry/config/envoy.ts +3 -20
- package/src/registry/config/index.ts +91 -74
- package/src/registry/index.ts +702 -80
- package/src/registry/napi-runtime.ts +643 -42
- package/src/registry/native-http.ts +225 -0
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +1881 -582
- package/src/registry/run-handler-coordinator.ts +219 -0
- package/src/registry/runtime.ts +441 -7
- package/src/registry/wasm-runtime.ts +516 -23
- package/src/registry/write-through-proxy.ts +141 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +2 -17
- package/src/test/ready.ts +22 -0
- package/src/unstable/migrations.ts +141 -0
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +50 -2
- 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 +703 -242
- package/src/workflow/driver.ts +284 -125
- package/src/workflow/inspector.ts +24 -24
- package/src/workflow/mod.ts +76 -84
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-6NT2LIFN.cjs +0 -268
- package/dist/tsup/chunk-6NT2LIFN.cjs.map +0 -1
- package/dist/tsup/chunk-7GKQJFSB.cjs.map +0 -1
- package/dist/tsup/chunk-7WXCRV25.cjs.map +0 -1
- package/dist/tsup/chunk-AGBP757I.js.map +0 -1
- package/dist/tsup/chunk-ARRBQTAR.cjs.map +0 -1
- package/dist/tsup/chunk-DXWOGCZY.js.map +0 -1
- package/dist/tsup/chunk-JGIPV3QU.js +0 -268
- package/dist/tsup/chunk-JGIPV3QU.js.map +0 -1
- package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
- package/dist/tsup/chunk-L4FVS7GY.js.map +0 -1
- package/dist/tsup/chunk-LD5YASJU.cjs.map +0 -1
- package/dist/tsup/chunk-OQEEZDIK.cjs.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-QAZLM4WT.cjs.map +0 -1
- package/dist/tsup/chunk-QNLGOTQP.js.map +0 -1
- package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
- package/dist/tsup/chunk-V4JUWAT6.js.map +0 -1
- package/dist/tsup/chunk-VUF2YEF4.cjs.map +0 -1
- package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
- package/dist/tsup/config-CxjGYf4K.d.cts +0 -121
- package/dist/tsup/config-CxjGYf4K.d.ts +0 -121
- package/dist/tsup/context-88opQsfZ.d.cts +0 -92
- package/dist/tsup/context-CVEG5zfg.d.ts +0 -92
- package/src/actor/driver.ts +0 -141
- package/src/actor/instance/mod.ts +0 -2492
- package/src/actor/keys.test.ts +0 -275
- package/src/actor/utils.test.ts +0 -48
- package/src/agent-os/actor/cron.ts +0 -84
- package/src/agent-os/actor/db.ts +0 -54
- package/src/agent-os/actor/filesystem.ts +0 -131
- package/src/agent-os/actor/index.ts +0 -265
- package/src/agent-os/actor/network.ts +0 -58
- package/src/agent-os/actor/preview.ts +0 -191
- package/src/agent-os/actor/process.ts +0 -177
- package/src/agent-os/actor/session.ts +0 -518
- package/src/agent-os/actor/shell.ts +0 -60
- package/src/agent-os/config.ts +0 -79
- package/src/agent-os/fs/database-vfs.ts +0 -624
- package/src/agent-os/types.ts +0 -148
- package/src/client/test.ts +0 -44
- package/src/common/database/mod.test.ts +0 -137
- package/src/common/database/native-database.test.ts +0 -211
- package/src/common/inline-websocket-adapter.test.ts +0 -51
- package/src/drivers/engine/actor-driver.ts +0 -2460
- package/src/registry/runtime.test.ts +0 -50
- package/src/utils/endpoint-parser.test.ts +0 -206
- package/src/utils/serve.ts +0 -217
- package/src/utils.test.ts +0 -34
- /package/dist/tsup/{chunk-DZJZLZ4R.js.map → chunk-2MXBZGUP.js.map} +0 -0
package/src/db/drizzle.ts
CHANGED
|
@@ -7,9 +7,19 @@ import type {
|
|
|
7
7
|
DatabaseProvider,
|
|
8
8
|
DatabaseProviderContext,
|
|
9
9
|
RawAccess,
|
|
10
|
+
SqliteProfilingOptions,
|
|
11
|
+
SqliteTransactionOptions,
|
|
10
12
|
SqliteDatabase,
|
|
13
|
+
SqliteTransactionDatabase,
|
|
11
14
|
} from "@/common/database/config";
|
|
12
|
-
import {
|
|
15
|
+
import { getLogger } from "@/common/log";
|
|
16
|
+
import {
|
|
17
|
+
isManualTransactionControl,
|
|
18
|
+
MIGRATION_TRANSACTION_TIMEOUT_MS,
|
|
19
|
+
toSqliteBindings,
|
|
20
|
+
validateTransactionName,
|
|
21
|
+
validateTransactionTimeout,
|
|
22
|
+
} from "@/common/database/shared";
|
|
13
23
|
import { sha256Hex } from "@/utils/crypto";
|
|
14
24
|
|
|
15
25
|
export type { SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
@@ -28,8 +38,16 @@ export {
|
|
|
28
38
|
} from "drizzle-orm/sqlite-core";
|
|
29
39
|
|
|
30
40
|
type DrizzleSchema = Record<string, unknown>;
|
|
31
|
-
type DrizzleDatabase<TSchema extends DrizzleSchema> =
|
|
32
|
-
SqliteRemoteDatabase<TSchema
|
|
41
|
+
type DrizzleDatabase<TSchema extends DrizzleSchema> = Omit<
|
|
42
|
+
SqliteRemoteDatabase<TSchema>,
|
|
43
|
+
"transaction"
|
|
44
|
+
> &
|
|
45
|
+
Omit<RawAccess, "transaction"> & {
|
|
46
|
+
transaction: <T>(
|
|
47
|
+
callback: (tx: DrizzleDatabase<TSchema>) => Promise<T> | T,
|
|
48
|
+
options?: SqliteTransactionOptions,
|
|
49
|
+
) => Promise<T>;
|
|
50
|
+
};
|
|
33
51
|
|
|
34
52
|
interface DrizzleMigrationJournalEntry {
|
|
35
53
|
idx: number;
|
|
@@ -43,10 +61,12 @@ interface DrizzleMigrations {
|
|
|
43
61
|
migrations: Record<string, string>;
|
|
44
62
|
}
|
|
45
63
|
|
|
46
|
-
interface DrizzleDatabaseFactoryConfig<TSchema extends DrizzleSchema> {
|
|
64
|
+
export interface DrizzleDatabaseFactoryConfig<TSchema extends DrizzleSchema> {
|
|
47
65
|
schema?: TSchema;
|
|
48
66
|
migrations?: DrizzleMigrations;
|
|
49
67
|
onMigrate?: (db: DrizzleDatabase<TSchema>) => Promise<void> | void;
|
|
68
|
+
warnOnManualTransactions?: boolean;
|
|
69
|
+
profiling?: SqliteProfilingOptions;
|
|
50
70
|
}
|
|
51
71
|
|
|
52
72
|
interface DrizzleKitConfig {
|
|
@@ -69,10 +89,13 @@ export function db<TSchema extends DrizzleSchema = Record<string, never>>({
|
|
|
69
89
|
schema,
|
|
70
90
|
migrations,
|
|
71
91
|
onMigrate,
|
|
92
|
+
warnOnManualTransactions = true,
|
|
93
|
+
profiling,
|
|
72
94
|
}: DrizzleDatabaseFactoryConfig<TSchema> = {}): DatabaseProvider<
|
|
73
95
|
DrizzleDatabase<TSchema>
|
|
74
96
|
> {
|
|
75
97
|
return {
|
|
98
|
+
sqliteProfiling: profiling,
|
|
76
99
|
createClient: async (ctx) => {
|
|
77
100
|
const override = ctx.overrideDrizzleDatabaseClient
|
|
78
101
|
? await ctx.overrideDrizzleDatabaseClient()
|
|
@@ -90,6 +113,7 @@ export function db<TSchema extends DrizzleSchema = Record<string, never>>({
|
|
|
90
113
|
|
|
91
114
|
const nativeDb = await nativeDatabaseProvider.open(ctx.actorId);
|
|
92
115
|
let closed = false;
|
|
116
|
+
let manualTransactionWarned = false;
|
|
93
117
|
const ensureOpen = () => {
|
|
94
118
|
if (closed) {
|
|
95
119
|
throw new Error(
|
|
@@ -98,107 +122,183 @@ export function db<TSchema extends DrizzleSchema = Record<string, never>>({
|
|
|
98
122
|
}
|
|
99
123
|
};
|
|
100
124
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
125
|
+
const createDrizzleClient = (
|
|
126
|
+
target: SqliteDatabase | SqliteTransactionDatabase,
|
|
127
|
+
transactionScoped = false,
|
|
128
|
+
): DrizzleDatabase<TSchema> => {
|
|
129
|
+
const runSql = async (
|
|
130
|
+
query: string,
|
|
131
|
+
params: unknown[],
|
|
132
|
+
method: "run" | "all" | "values" | "get",
|
|
133
|
+
) => {
|
|
134
|
+
ensureOpen();
|
|
135
|
+
warnForManualTransaction(query, transactionScoped);
|
|
107
136
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
137
|
+
const start = performance.now();
|
|
138
|
+
const kvReadsBefore = ctx.metrics?.totalKvReads ?? 0;
|
|
139
|
+
const kvWritesBefore = ctx.metrics?.totalKvWrites ?? 0;
|
|
140
|
+
try {
|
|
141
|
+
const { rows } = await target.execute(
|
|
142
|
+
query,
|
|
143
|
+
toSqliteBindings(params),
|
|
144
|
+
);
|
|
145
|
+
if (method === "run") {
|
|
146
|
+
return { rows: [] };
|
|
147
|
+
}
|
|
148
|
+
if (method === "get") {
|
|
149
|
+
return { rows: rows[0] };
|
|
150
|
+
}
|
|
151
|
+
return { rows };
|
|
152
|
+
} finally {
|
|
153
|
+
const durationMs = performance.now() - start;
|
|
154
|
+
ctx.metrics?.trackSql(query, durationMs);
|
|
155
|
+
if (ctx.metrics) {
|
|
156
|
+
ctx.log?.debug({
|
|
157
|
+
msg: "sql query",
|
|
158
|
+
query: query.slice(0, 120),
|
|
159
|
+
durationMs,
|
|
160
|
+
kvReads:
|
|
161
|
+
ctx.metrics.totalKvReads - kvReadsBefore,
|
|
162
|
+
kvWrites:
|
|
163
|
+
ctx.metrics.totalKvWrites - kvWritesBefore,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const callback: RemoteCallback = async (
|
|
170
|
+
query,
|
|
171
|
+
params,
|
|
172
|
+
method,
|
|
173
|
+
) => {
|
|
174
|
+
return await runSql(query, params, method);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const drizzleDb = drizzle(callback, {
|
|
178
|
+
schema,
|
|
179
|
+
}) as unknown as DrizzleDatabase<TSchema>;
|
|
180
|
+
drizzleDb.execute = async <
|
|
181
|
+
TRow extends Record<string, unknown> = Record<
|
|
182
|
+
string,
|
|
183
|
+
unknown
|
|
184
|
+
>,
|
|
185
|
+
>(
|
|
186
|
+
query: string,
|
|
187
|
+
...args: unknown[]
|
|
188
|
+
): Promise<TRow[]> => {
|
|
189
|
+
return await executeRaw<TRow>(
|
|
190
|
+
target,
|
|
191
|
+
ctx,
|
|
192
|
+
ensureOpen,
|
|
113
193
|
query,
|
|
114
|
-
|
|
194
|
+
args,
|
|
195
|
+
() =>
|
|
196
|
+
warnForManualTransaction(query, transactionScoped),
|
|
115
197
|
);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
198
|
+
};
|
|
199
|
+
drizzleDb.transaction = async <T>(
|
|
200
|
+
transactionCallback: (
|
|
201
|
+
tx: DrizzleDatabase<TSchema>,
|
|
202
|
+
) => Promise<T> | T,
|
|
203
|
+
options?: SqliteTransactionOptions,
|
|
204
|
+
): Promise<T> => {
|
|
205
|
+
validateTransactionTimeout(options?.timeout);
|
|
206
|
+
validateTransactionName(options?.name);
|
|
207
|
+
const transaction = await nativeDb.beginTransaction(
|
|
208
|
+
options?.timeout,
|
|
209
|
+
options?.name,
|
|
210
|
+
);
|
|
211
|
+
const tx = createDrizzleClient(transaction, true);
|
|
212
|
+
try {
|
|
213
|
+
const result = await transactionCallback(tx);
|
|
214
|
+
await transaction.commit();
|
|
215
|
+
return result;
|
|
216
|
+
} catch (error) {
|
|
217
|
+
try {
|
|
218
|
+
await transaction.rollback();
|
|
219
|
+
} catch {
|
|
220
|
+
// Preserve the callback or commit error after expiry cleanup.
|
|
221
|
+
}
|
|
222
|
+
throw error;
|
|
121
223
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
ctx.log?.debug({
|
|
128
|
-
msg: "sql query",
|
|
129
|
-
query: query.slice(0, 120),
|
|
130
|
-
durationMs,
|
|
131
|
-
kvReads: ctx.metrics.totalKvReads - kvReadsBefore,
|
|
132
|
-
kvWrites:
|
|
133
|
-
ctx.metrics.totalKvWrites - kvWritesBefore,
|
|
134
|
-
});
|
|
224
|
+
};
|
|
225
|
+
drizzleDb.close = async () => {
|
|
226
|
+
if (!closed) {
|
|
227
|
+
closed = true;
|
|
228
|
+
await nativeDb.close();
|
|
135
229
|
}
|
|
136
|
-
}
|
|
137
|
-
};
|
|
230
|
+
};
|
|
138
231
|
|
|
139
|
-
|
|
140
|
-
return await runSql(query, params, method);
|
|
232
|
+
return drizzleDb;
|
|
141
233
|
};
|
|
142
234
|
|
|
143
|
-
const
|
|
144
|
-
schema,
|
|
145
|
-
}) as DrizzleDatabase<TSchema>;
|
|
146
|
-
drizzleDb.execute = async <
|
|
147
|
-
TRow extends Record<string, unknown> = Record<string, unknown>,
|
|
148
|
-
>(
|
|
235
|
+
const warnForManualTransaction = (
|
|
149
236
|
query: string,
|
|
150
|
-
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
query
|
|
157
|
-
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
drizzleDb.close = async () => {
|
|
161
|
-
if (!closed) {
|
|
162
|
-
closed = true;
|
|
163
|
-
await nativeDb.close();
|
|
237
|
+
transactionScoped: boolean,
|
|
238
|
+
) => {
|
|
239
|
+
if (
|
|
240
|
+
transactionScoped ||
|
|
241
|
+
!warnOnManualTransactions ||
|
|
242
|
+
manualTransactionWarned ||
|
|
243
|
+
hasMultipleStatements(query) ||
|
|
244
|
+
!isManualTransactionControl(query)
|
|
245
|
+
) {
|
|
246
|
+
return;
|
|
164
247
|
}
|
|
248
|
+
manualTransactionWarned = true;
|
|
249
|
+
getLogger("database").warn(
|
|
250
|
+
{ actorId: ctx.actorId },
|
|
251
|
+
"Manual cross-call SQLite transactions can interleave with other actor work. Use db.transaction() for coordinated transactions. Set warnOnManualTransactions: false in your db(...) configuration to disable this warning.",
|
|
252
|
+
);
|
|
165
253
|
};
|
|
166
254
|
|
|
167
|
-
return
|
|
255
|
+
return createDrizzleClient(nativeDb);
|
|
168
256
|
},
|
|
169
257
|
onMigrate: async (client) => {
|
|
170
258
|
if (!migrations && !onMigrate) {
|
|
171
259
|
return;
|
|
172
260
|
}
|
|
173
|
-
await withMigrationSavepoint(client, async () => {
|
|
261
|
+
await withMigrationSavepoint(client, async (leased) => {
|
|
174
262
|
if (migrations) {
|
|
175
|
-
await runMigrations(
|
|
263
|
+
await runMigrations(leased, migrations);
|
|
176
264
|
}
|
|
177
265
|
if (onMigrate) {
|
|
178
|
-
await onMigrate(
|
|
266
|
+
await onMigrate(leased);
|
|
179
267
|
}
|
|
180
268
|
});
|
|
181
269
|
},
|
|
182
270
|
};
|
|
183
271
|
}
|
|
184
272
|
|
|
185
|
-
async function withMigrationSavepoint<T>(
|
|
186
|
-
client:
|
|
187
|
-
callback: () => Promise<T> | T,
|
|
273
|
+
async function withMigrationSavepoint<TSchema extends DrizzleSchema, T>(
|
|
274
|
+
client: DrizzleDatabase<TSchema>,
|
|
275
|
+
callback: (leased: DrizzleDatabase<TSchema>) => Promise<T> | T,
|
|
188
276
|
): Promise<T> {
|
|
189
|
-
await client.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
277
|
+
return await client.transaction(
|
|
278
|
+
async (leased) => {
|
|
279
|
+
await leased.execute("SAVEPOINT __rivet_on_migrate");
|
|
280
|
+
try {
|
|
281
|
+
const result = await callback(leased);
|
|
282
|
+
await leased.execute("RELEASE SAVEPOINT __rivet_on_migrate");
|
|
283
|
+
return result;
|
|
284
|
+
} catch (error) {
|
|
285
|
+
try {
|
|
286
|
+
await leased.execute(
|
|
287
|
+
"ROLLBACK TO SAVEPOINT __rivet_on_migrate",
|
|
288
|
+
);
|
|
289
|
+
} finally {
|
|
290
|
+
await leased.execute(
|
|
291
|
+
"RELEASE SAVEPOINT __rivet_on_migrate",
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
throw error;
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: "rivetkit-drizzle-migration",
|
|
299
|
+
timeout: MIGRATION_TRANSACTION_TIMEOUT_MS,
|
|
300
|
+
},
|
|
301
|
+
);
|
|
202
302
|
}
|
|
203
303
|
|
|
204
304
|
async function runMigrations<TSchema extends DrizzleSchema>(
|
|
@@ -281,13 +381,15 @@ function rowToObject<TRow extends Record<string, unknown>>(
|
|
|
281
381
|
}
|
|
282
382
|
|
|
283
383
|
async function executeRaw<TRow extends Record<string, unknown>>(
|
|
284
|
-
db: SqliteDatabase,
|
|
384
|
+
db: SqliteDatabase | SqliteTransactionDatabase,
|
|
285
385
|
ctx: DatabaseProviderContext,
|
|
286
386
|
ensureOpen: () => void,
|
|
287
387
|
query: string,
|
|
288
388
|
args: unknown[],
|
|
389
|
+
warnForManualTransaction: () => void,
|
|
289
390
|
): Promise<TRow[]> {
|
|
290
391
|
ensureOpen();
|
|
392
|
+
warnForManualTransaction();
|
|
291
393
|
|
|
292
394
|
const start = performance.now();
|
|
293
395
|
const kvReadsBefore = ctx.metrics?.totalKvReads ?? 0;
|
|
@@ -302,7 +404,7 @@ async function executeRaw<TRow extends Record<string, unknown>>(
|
|
|
302
404
|
}
|
|
303
405
|
|
|
304
406
|
if (!hasMultipleStatements(query)) {
|
|
305
|
-
const { rows, columns } = await db.execute(query);
|
|
407
|
+
const { rows, columns } = await db.execute(query, undefined);
|
|
306
408
|
return rows.map((row) => rowToObject<TRow>(row, columns));
|
|
307
409
|
}
|
|
308
410
|
|
package/src/db/mod.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
export { db } from "@/common/database/mod";
|
|
2
1
|
export type {
|
|
3
2
|
AnyDatabaseProvider,
|
|
4
3
|
DatabaseProvider,
|
|
5
4
|
DatabaseProviderContext,
|
|
5
|
+
InferDatabaseClient,
|
|
6
6
|
NativeDatabaseProvider,
|
|
7
7
|
RawAccess,
|
|
8
8
|
RawDatabaseClient,
|
|
9
9
|
SqliteBindings,
|
|
10
10
|
SqliteDatabase,
|
|
11
11
|
SqliteNativeMetrics,
|
|
12
|
+
SqliteProfilingOptions,
|
|
13
|
+
SqliteProfilingMetricsOptions,
|
|
12
14
|
SqliteQueryResult,
|
|
15
|
+
SqliteTransactionOptions,
|
|
13
16
|
} from "@/common/database/config";
|
|
17
|
+
export { db } from "@/common/database/mod";
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import type { ClientConfigInput } from "@/client/client";
|
|
2
|
-
import { VERSION } from "@/utils";
|
|
3
2
|
import { logger } from "./log";
|
|
4
3
|
|
|
5
4
|
declare global {
|
|
6
5
|
// Injected via tsup config
|
|
7
|
-
// biome-ignore lint/style/noVar: required for global declaration
|
|
8
6
|
var CUSTOM_RIVETKIT_DEVTOOLS_URL: string | undefined;
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
const DEFAULT_DEVTOOLS_URL = (version = VERSION) =>
|
|
12
|
-
`https://releases.rivet.dev/rivet/latest/devtools/mod.js?v=${version}`;
|
|
13
|
-
|
|
14
9
|
const scriptId = "rivetkit-devtools-script";
|
|
15
10
|
|
|
16
11
|
export function injectDevtools(config: ClientConfigInput) {
|
|
@@ -20,10 +15,12 @@ export function injectDevtools(config: ClientConfigInput) {
|
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
if (!document.getElementById(scriptId)) {
|
|
18
|
+
const src =
|
|
19
|
+
globalThis.CUSTOM_RIVETKIT_DEVTOOLS_URL ||
|
|
20
|
+
`${config.endpoint?.replace(/\/$/, "")}/devtools/mod.js`;
|
|
23
21
|
const script = document.createElement("script");
|
|
24
22
|
script.id = scriptId;
|
|
25
|
-
script.src =
|
|
26
|
-
globalThis.CUSTOM_RIVETKIT_DEVTOOLS_URL || DEFAULT_DEVTOOLS_URL();
|
|
23
|
+
script.src = src;
|
|
27
24
|
script.async = true;
|
|
28
25
|
document.head.appendChild(script);
|
|
29
26
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getNodeFs, getNodePath, getNodeUrl } from "@/utils/node";
|
|
2
|
+
|
|
3
|
+
export async function getDevtoolsPath(): Promise<string> {
|
|
4
|
+
const url = getNodeUrl();
|
|
5
|
+
const path = getNodePath();
|
|
6
|
+
|
|
7
|
+
const devtoolsPath = path.join(
|
|
8
|
+
path.dirname(url.fileURLToPath(import.meta.url)),
|
|
9
|
+
"../../dist/devtools/mod.js",
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
await getNodeFs().access(devtoolsPath);
|
|
14
|
+
} catch {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Devtools bundle not found at ${devtoolsPath}. Run 'pnpm build:pack-devtools' first.`,
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return devtoolsPath;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function readDevtoolsBundle(): Promise<Buffer> {
|
|
24
|
+
const devtoolsPath = await getDevtoolsPath();
|
|
25
|
+
return getNodeFs().readFile(devtoolsPath);
|
|
26
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DynamicActorIsolateRuntime } from "./isolate-runtime";
|
|
2
|
+
|
|
3
|
+
export class DynamicActorInstance {
|
|
4
|
+
constructor(
|
|
5
|
+
public readonly id: string,
|
|
6
|
+
private readonly runtime: DynamicActorIsolateRuntime,
|
|
7
|
+
) {}
|
|
8
|
+
|
|
9
|
+
get isStopping(): boolean {
|
|
10
|
+
return this.runtime.isStopping;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async onStop(mode: "sleep" | "destroy"): Promise<void> {
|
|
14
|
+
await this.runtime.stop(mode);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async onAlarm(): Promise<void> {
|
|
18
|
+
await this.runtime.onAlarm();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async cleanupPersistedConnections(reason?: string): Promise<number> {
|
|
22
|
+
return await this.runtime.cleanupPersistedConnections(reason);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async getHibernatingWebSockets() {
|
|
26
|
+
return await this.runtime.getHibernatingWebSockets();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getHibernatingWebSocketMetadata() {
|
|
30
|
+
return this.runtime.getHibernatingWebSocketMetadata();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AnyActorDefinition,
|
|
3
|
+
BaseActorDefinition,
|
|
4
|
+
} from "@/actor/definition";
|
|
5
|
+
|
|
6
|
+
export const DYNAMIC_ACTOR_DEFINITION_SYMBOL = Symbol.for(
|
|
7
|
+
"rivetkit.dynamic_actor_definition",
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export interface DynamicActorSource {
|
|
11
|
+
source: string;
|
|
12
|
+
nodeProcess?: {
|
|
13
|
+
memoryLimit?: number;
|
|
14
|
+
cpuTimeLimitMs?: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface DynamicActorLoadContext {
|
|
19
|
+
key: string[];
|
|
20
|
+
client(): Promise<any>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type DynamicActorLoader = (
|
|
24
|
+
c: DynamicActorLoadContext,
|
|
25
|
+
) => DynamicActorSource | Promise<DynamicActorSource>;
|
|
26
|
+
|
|
27
|
+
export interface DynamicActorDefinition extends AnyActorDefinition {
|
|
28
|
+
readonly [DYNAMIC_ACTOR_DEFINITION_SYMBOL]: true;
|
|
29
|
+
readonly loader: DynamicActorLoader;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function isDynamicActorDefinition(
|
|
33
|
+
definition: BaseActorDefinition<
|
|
34
|
+
any,
|
|
35
|
+
any,
|
|
36
|
+
any,
|
|
37
|
+
any,
|
|
38
|
+
any,
|
|
39
|
+
any,
|
|
40
|
+
any,
|
|
41
|
+
any,
|
|
42
|
+
any
|
|
43
|
+
>,
|
|
44
|
+
): definition is DynamicActorDefinition {
|
|
45
|
+
return (
|
|
46
|
+
(definition as Partial<DynamicActorDefinition>)[
|
|
47
|
+
DYNAMIC_ACTOR_DEFINITION_SYMBOL
|
|
48
|
+
] === true
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Client } from "@/client/client";
|
|
2
|
+
import type { RegistryConfig } from "@/registry/config";
|
|
3
|
+
import type { DynamicActorLoader } from "./internal";
|
|
4
|
+
|
|
5
|
+
export interface DynamicActorIsolateRuntimeConfig {
|
|
6
|
+
actorId: string;
|
|
7
|
+
actorName: string;
|
|
8
|
+
actorKey: string[];
|
|
9
|
+
input: unknown;
|
|
10
|
+
region: string;
|
|
11
|
+
loader: DynamicActorLoader;
|
|
12
|
+
inlineClient: Client<any>;
|
|
13
|
+
test: RegistryConfig["test"];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface DynamicHibernatingWebSocketMetadata {
|
|
17
|
+
gatewayId: ArrayBuffer;
|
|
18
|
+
requestId: ArrayBuffer;
|
|
19
|
+
serverMessageIndex: number;
|
|
20
|
+
clientMessageIndex: number;
|
|
21
|
+
path: string;
|
|
22
|
+
headers: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class DynamicActorIsolateRuntime {
|
|
26
|
+
#isStopping = false;
|
|
27
|
+
|
|
28
|
+
constructor(private readonly config: DynamicActorIsolateRuntimeConfig) {}
|
|
29
|
+
|
|
30
|
+
get isStopping(): boolean {
|
|
31
|
+
return this.#isStopping;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async start(): Promise<void> {
|
|
35
|
+
await this.config.loader({
|
|
36
|
+
key: this.config.actorKey,
|
|
37
|
+
client: async () => this.config.inlineClient,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async stop(_mode: "sleep" | "destroy"): Promise<void> {
|
|
42
|
+
this.#isStopping = true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async dispose(): Promise<void> {
|
|
46
|
+
this.#isStopping = true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async onAlarm(): Promise<void> {}
|
|
50
|
+
|
|
51
|
+
async cleanupPersistedConnections(_reason?: string): Promise<number> {
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async getHibernatingWebSockets(): Promise<
|
|
56
|
+
DynamicHibernatingWebSocketMetadata[]
|
|
57
|
+
> {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
getHibernatingWebSocketMetadata(): DynamicHibernatingWebSocketMetadata[] {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ActorConfigSchema } from "@/actor/config";
|
|
2
|
+
import type { AnyActorDefinition } from "@/actor/definition";
|
|
3
|
+
import {
|
|
4
|
+
DYNAMIC_ACTOR_DEFINITION_SYMBOL,
|
|
5
|
+
type DynamicActorDefinition,
|
|
6
|
+
type DynamicActorLoader,
|
|
7
|
+
} from "./internal";
|
|
8
|
+
|
|
9
|
+
export interface DynamicActorConfig {
|
|
10
|
+
load: DynamicActorLoader;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function dynamicActor(
|
|
14
|
+
input: DynamicActorConfig,
|
|
15
|
+
): DynamicActorDefinition {
|
|
16
|
+
const config = ActorConfigSchema.parse({
|
|
17
|
+
actions: {},
|
|
18
|
+
}) as unknown as AnyActorDefinition["config"];
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
[DYNAMIC_ACTOR_DEFINITION_SYMBOL]: true,
|
|
22
|
+
config,
|
|
23
|
+
loader: input.load,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type {
|
|
28
|
+
DynamicActorDefinition,
|
|
29
|
+
DynamicActorLoadContext,
|
|
30
|
+
DynamicActorLoader,
|
|
31
|
+
DynamicActorSource,
|
|
32
|
+
} from "./internal";
|
package/src/engine-api/actors.ts
CHANGED
|
@@ -6,7 +6,7 @@ export const ActorSchema = z.object({
|
|
|
6
6
|
name: z.string(),
|
|
7
7
|
key: z.string(),
|
|
8
8
|
namespace_id: RivetIdSchema,
|
|
9
|
-
|
|
9
|
+
pool: z.string(),
|
|
10
10
|
create_ts: z.number(),
|
|
11
11
|
connectable_ts: z.number().nullable().optional(),
|
|
12
12
|
destroy_ts: z.number().nullable().optional(),
|
|
@@ -31,7 +31,7 @@ export type ActorsListResponse = z.infer<typeof ActorsListResponseSchema>;
|
|
|
31
31
|
export const ActorsCreateRequestSchema = z.object({
|
|
32
32
|
datacenter: z.string().optional(),
|
|
33
33
|
name: z.string(),
|
|
34
|
-
|
|
34
|
+
pool: z.string(),
|
|
35
35
|
crash_policy: z.string(),
|
|
36
36
|
key: z.string().nullable().optional(),
|
|
37
37
|
input: z.string().nullable().optional(),
|
|
@@ -43,12 +43,24 @@ export const ActorsCreateResponseSchema = z.object({
|
|
|
43
43
|
});
|
|
44
44
|
export type ActorsCreateResponse = z.infer<typeof ActorsCreateResponseSchema>;
|
|
45
45
|
|
|
46
|
+
// MARK: POST /actors/{actor_id}/fork
|
|
47
|
+
export const ActorsForkRequestSchema = z.object({
|
|
48
|
+
key: z.string().nullable().optional(),
|
|
49
|
+
input: z.string().nullable().optional(),
|
|
50
|
+
});
|
|
51
|
+
export type ActorsForkRequest = z.infer<typeof ActorsForkRequestSchema>;
|
|
52
|
+
|
|
53
|
+
export const ActorsForkResponseSchema = z.object({
|
|
54
|
+
actor: ActorSchema,
|
|
55
|
+
});
|
|
56
|
+
export type ActorsForkResponse = z.infer<typeof ActorsForkResponseSchema>;
|
|
57
|
+
|
|
46
58
|
// MARK: PUT /actors
|
|
47
59
|
export const ActorsGetOrCreateRequestSchema = z.object({
|
|
48
60
|
datacenter: z.string().optional(),
|
|
49
61
|
name: z.string(),
|
|
50
62
|
key: z.string(),
|
|
51
|
-
|
|
63
|
+
pool: z.string(),
|
|
52
64
|
crash_policy: z.string(),
|
|
53
65
|
input: z.string().nullable().optional(),
|
|
54
66
|
});
|