rivetkit 0.0.0-stack-chore-sync-engine-changes-from-enterprise-mszropyy.677d526 → 0.0.0-sync-sqlite.0ed739a
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 +25 -0
- package/dist/browser/client.js +17 -5
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/agent-os/index.cjs +145 -3
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +40 -2
- package/dist/tsup/agent-os/index.d.ts +40 -2
- package/dist/tsup/agent-os/index.js +144 -2
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-FSD52J3H.cjs → chunk-24PL45D7.cjs} +3 -3
- package/dist/tsup/{chunk-FSD52J3H.cjs.map → chunk-24PL45D7.cjs.map} +1 -1
- package/dist/tsup/{chunk-7ZPRFCTV.cjs → chunk-3TNKROAF.cjs} +156 -144
- package/dist/tsup/chunk-3TNKROAF.cjs.map +1 -0
- package/dist/tsup/{chunk-ZYHZOZUQ.js → chunk-75H2CLHI.js} +2 -2
- package/dist/tsup/{chunk-OWSXJF7Z.js → chunk-BERJKIW5.js} +22 -10
- package/dist/tsup/chunk-BERJKIW5.js.map +1 -0
- package/dist/tsup/{chunk-XPT7SGBW.js → chunk-BZOI63CT.js} +4 -4
- package/dist/tsup/{chunk-M4RSGECU.js → chunk-EHAGZJ34.js} +2 -2
- package/dist/tsup/{chunk-VXJ26VPL.cjs → chunk-FZIA3IQ2.cjs} +10 -10
- package/dist/tsup/{chunk-VXJ26VPL.cjs.map → chunk-FZIA3IQ2.cjs.map} +1 -1
- package/dist/tsup/{chunk-LHT3TRDM.js → chunk-J7WM3KL5.js} +115 -4
- package/dist/tsup/chunk-J7WM3KL5.js.map +1 -0
- package/dist/tsup/{chunk-XNLSA7TO.cjs → chunk-JJMBATG7.cjs} +4 -4
- package/dist/tsup/{chunk-XNLSA7TO.cjs.map → chunk-JJMBATG7.cjs.map} +1 -1
- package/dist/tsup/{chunk-ZXV3CG4Y.cjs → chunk-K3DXAJQ2.cjs} +7 -7
- package/dist/tsup/{chunk-ZXV3CG4Y.cjs.map → chunk-K3DXAJQ2.cjs.map} +1 -1
- package/dist/tsup/{chunk-YHYNYVNZ.js → chunk-M7FOORLQ.js} +3 -3
- package/dist/tsup/{chunk-2TAUHMAC.cjs → chunk-MRFLWAPE.cjs} +2 -2
- package/dist/tsup/chunk-MRFLWAPE.cjs.map +1 -0
- package/dist/tsup/{chunk-GPD77M3M.js → chunk-NNPIJLBE.js} +2 -2
- package/dist/tsup/chunk-NNPIJLBE.js.map +1 -0
- package/dist/tsup/{chunk-TFACXNOP.cjs → chunk-R75W2PPM.cjs} +121 -10
- package/dist/tsup/chunk-R75W2PPM.cjs.map +1 -0
- package/dist/tsup/{chunk-UBGN2UE2.cjs → chunk-SHAZSNYB.cjs} +3 -3
- package/dist/tsup/{chunk-UBGN2UE2.cjs.map → chunk-SHAZSNYB.cjs.map} +1 -1
- package/dist/tsup/{chunk-L6DNN72S.js → chunk-SLAKWYOH.js} +2 -2
- package/dist/tsup/{chunk-JTHHCZCZ.js → chunk-WCEJTJHO.js} +34 -1
- package/dist/tsup/chunk-WCEJTJHO.js.map +1 -0
- package/dist/tsup/{chunk-KVFIONKQ.cjs → chunk-XMNL3AE2.cjs} +35 -2
- package/dist/tsup/chunk-XMNL3AE2.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +6 -6
- package/dist/tsup/client/mod.d.cts +3 -3
- package/dist/tsup/client/mod.d.ts +3 -3
- package/dist/tsup/client/mod.js +5 -5
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-ey2I2zz5.d.cts → config-B0q37XhG.d.cts} +31 -1
- package/dist/tsup/{config-ey2I2zz5.d.ts → config-B0q37XhG.d.ts} +31 -1
- package/dist/tsup/{config-BGTanB_3.d.ts → config-BPJQ0mDo.d.ts} +9 -1
- package/dist/tsup/{config-NHz6oMb9.d.cts → config-CGUJyT5L.d.cts} +9 -1
- package/dist/tsup/{context-SHomdVV8.d.ts → context-DZ_lu12i.d.ts} +2 -2
- package/dist/tsup/{context-DB8zG_Ib.d.cts → context-WLBsDXrQ.d.cts} +2 -2
- package/dist/tsup/db/drizzle.cjs +113 -10
- package/dist/tsup/db/drizzle.cjs.map +1 -1
- package/dist/tsup/db/drizzle.d.cts +2 -2
- package/dist/tsup/db/drizzle.d.ts +2 -2
- package/dist/tsup/db/drizzle.js +106 -3
- package/dist/tsup/db/drizzle.js.map +1 -1
- package/dist/tsup/db/mod.cjs +4 -4
- package/dist/tsup/db/mod.d.cts +4 -4
- package/dist/tsup/db/mod.d.ts +4 -4
- package/dist/tsup/db/mod.js +3 -3
- package/dist/tsup/dynamic/mod.d.cts +2 -2
- package/dist/tsup/dynamic/mod.d.ts +2 -2
- package/dist/tsup/inspector/mod.cjs +5 -5
- package/dist/tsup/inspector/mod.js +4 -4
- package/dist/tsup/inspector/workflow.cjs +4 -4
- package/dist/tsup/inspector/workflow.js +3 -3
- package/dist/tsup/inspector-tab/mod.d.cts +3 -3
- package/dist/tsup/inspector-tab/mod.d.ts +3 -3
- package/dist/tsup/mod.cjs +296 -88
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -4
- package/dist/tsup/mod.d.ts +4 -4
- package/dist/tsup/mod.js +225 -17
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +7 -7
- package/dist/tsup/test/mod.d.cts +2 -2
- package/dist/tsup/test/mod.d.ts +2 -2
- package/dist/tsup/test/mod.js +5 -5
- package/dist/tsup/unstable/migrations.d.cts +1 -1
- package/dist/tsup/unstable/migrations.d.ts +1 -1
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +7 -7
- package/dist/tsup/workflow/mod.d.cts +4 -4
- package/dist/tsup/workflow/mod.d.ts +4 -4
- package/dist/tsup/workflow/mod.js +4 -4
- package/package.json +9 -9
- package/src/agent-os/actor/index.ts +6 -3
- package/src/agent-os/actor/preview.ts +5 -2
- package/src/client/actor-handle.ts +15 -8
- package/src/client/raw-utils.ts +14 -0
- package/src/common/database/config.ts +54 -0
- package/src/common/database/mod.test.ts +162 -1
- package/src/common/database/mod.ts +154 -6
- package/src/common/database/native-database.test.ts +81 -2
- package/src/common/database/native-database.ts +172 -3
- package/src/common/database/shared.ts +49 -1
- package/src/db/drizzle.test.ts +82 -1
- package/src/db/drizzle.ts +136 -6
- package/src/db/mod.ts +2 -0
- package/src/registry/napi-runtime.ts +71 -0
- package/src/registry/native.ts +48 -14
- package/src/registry/runtime.ts +46 -0
- package/src/registry/wasm-runtime.ts +63 -0
- package/dist/tsup/chunk-2TAUHMAC.cjs.map +0 -1
- package/dist/tsup/chunk-7ZPRFCTV.cjs.map +0 -1
- package/dist/tsup/chunk-GPD77M3M.js.map +0 -1
- package/dist/tsup/chunk-JTHHCZCZ.js.map +0 -1
- package/dist/tsup/chunk-KVFIONKQ.cjs.map +0 -1
- package/dist/tsup/chunk-LHT3TRDM.js.map +0 -1
- package/dist/tsup/chunk-OWSXJF7Z.js.map +0 -1
- package/dist/tsup/chunk-TFACXNOP.cjs.map +0 -1
- /package/dist/tsup/{chunk-ZYHZOZUQ.js.map → chunk-75H2CLHI.js.map} +0 -0
- /package/dist/tsup/{chunk-XPT7SGBW.js.map → chunk-BZOI63CT.js.map} +0 -0
- /package/dist/tsup/{chunk-M4RSGECU.js.map → chunk-EHAGZJ34.js.map} +0 -0
- /package/dist/tsup/{chunk-YHYNYVNZ.js.map → chunk-M7FOORLQ.js.map} +0 -0
- /package/dist/tsup/{chunk-L6DNN72S.js.map → chunk-SLAKWYOH.js.map} +0 -0
|
@@ -79,9 +79,12 @@ interface SqliteNativeMetrics {
|
|
|
79
79
|
}
|
|
80
80
|
interface SqliteDatabase {
|
|
81
81
|
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
82
|
+
execSync?(sql: string, callback?: (row: unknown[], columns: string[]) => void): void;
|
|
82
83
|
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
84
|
+
executeSync?(sql: string, params?: SqliteBindings): SqliteExecuteResult;
|
|
83
85
|
executeBatch(statements: SqliteBatchStatement[]): Promise<SqliteExecuteResult[]>;
|
|
84
86
|
beginTransaction(timeoutMs?: number, name?: string): Promise<SqliteTransactionDatabase>;
|
|
87
|
+
beginTransactionSync?(timeoutMs?: number, name?: string): SynchronousSqliteTransactionDatabase;
|
|
85
88
|
run(sql: string, params?: SqliteBindings): Promise<void>;
|
|
86
89
|
query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
|
|
87
90
|
nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
|
|
@@ -89,10 +92,18 @@ interface SqliteDatabase {
|
|
|
89
92
|
}
|
|
90
93
|
interface SqliteTransactionDatabase {
|
|
91
94
|
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
95
|
+
execSync?(sql: string, callback?: (row: unknown[], columns: string[]) => void): void;
|
|
92
96
|
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
97
|
+
executeSync?(sql: string, params?: SqliteBindings): SqliteExecuteResult;
|
|
93
98
|
commit(): Promise<void>;
|
|
94
99
|
rollback(): Promise<void>;
|
|
95
100
|
}
|
|
101
|
+
type SynchronousSqliteTransactionDatabase = SqliteTransactionDatabase & {
|
|
102
|
+
execSync(sql: string, callback?: (row: unknown[], columns: string[]) => void): void;
|
|
103
|
+
executeSync(sql: string, params?: SqliteBindings): SqliteExecuteResult;
|
|
104
|
+
commitSync(): void;
|
|
105
|
+
rollbackSync(): void;
|
|
106
|
+
};
|
|
96
107
|
/**
|
|
97
108
|
* Provider for opening native databases from the active runtime.
|
|
98
109
|
*/
|
|
@@ -161,11 +172,21 @@ type DatabaseProvider<DB extends RawAccess> = {
|
|
|
161
172
|
*/
|
|
162
173
|
type DrizzleDatabaseClient = {};
|
|
163
174
|
type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
|
|
175
|
+
type ExecuteSyncFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => TRow[];
|
|
176
|
+
/** SQL operations available inside a synchronous transaction callback. */
|
|
177
|
+
type SynchronousTransactionAccess = {
|
|
178
|
+
executeSync: ExecuteSyncFunction;
|
|
179
|
+
};
|
|
164
180
|
type RawAccess = {
|
|
165
181
|
/**
|
|
166
182
|
* Executes a raw SQL query.
|
|
167
183
|
*/
|
|
168
184
|
execute: ExecuteFunction;
|
|
185
|
+
/**
|
|
186
|
+
* Executes a raw SQL query synchronously when supported by the runtime.
|
|
187
|
+
* This blocks the Node.js event loop. Prefer `execute` for normal use.
|
|
188
|
+
*/
|
|
189
|
+
executeSync?: ExecuteSyncFunction;
|
|
169
190
|
/** Runs a callback in an isolated SQLite transaction. */
|
|
170
191
|
transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T, options?: SqliteTransactionOptions) => Promise<T>;
|
|
171
192
|
/**
|
|
@@ -177,6 +198,15 @@ type RawAccess = {
|
|
|
177
198
|
*/
|
|
178
199
|
close: () => Promise<void>;
|
|
179
200
|
};
|
|
201
|
+
/** Raw database access with synchronous operations provided by the Node.js runtime. */
|
|
202
|
+
type SynchronousRawAccess = RawAccess & {
|
|
203
|
+
executeSync: ExecuteSyncFunction;
|
|
204
|
+
/**
|
|
205
|
+
* Runs a synchronous callback in an isolated SQLite transaction.
|
|
206
|
+
* The callback must not return a promise.
|
|
207
|
+
*/
|
|
208
|
+
transactionSync: <T>(callback: (tx: SynchronousTransactionAccess) => T, options?: Omit<SqliteTransactionOptions, "experimental">) => T;
|
|
209
|
+
};
|
|
180
210
|
|
|
181
211
|
declare const ActorsSchema: z.ZodRecord<z.ZodString, z.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
|
|
182
212
|
type RegistryActors = z.infer<typeof ActorsSchema>;
|
|
@@ -999,15 +1029,23 @@ interface CoreRuntime {
|
|
|
999
1029
|
actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
|
|
1000
1030
|
actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
|
|
1001
1031
|
actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
1032
|
+
actorSqlExecSync(ctx: ActorContextHandle, sql: string): RuntimeSqlExecResult;
|
|
1002
1033
|
actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
1034
|
+
actorSqlExecuteSync(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): RuntimeSqlExecuteResult;
|
|
1003
1035
|
actorSqlExecuteBatch(ctx: ActorContextHandle, statements: RuntimeSqlBatchStatement[]): Promise<RuntimeSqlExecuteResult[]>;
|
|
1004
1036
|
actorSqlBeginTransaction(ctx: ActorContextHandle, timeoutMs?: number, name?: string): Promise<SqliteTransactionHandle>;
|
|
1037
|
+
actorSqlBeginTransactionSync(ctx: ActorContextHandle, timeoutMs?: number, name?: string): SqliteTransactionHandle;
|
|
1005
1038
|
actorSqlTransactionExec(transaction: SqliteTransactionHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
1039
|
+
actorSqlTransactionExecSync(transaction: SqliteTransactionHandle, sql: string): RuntimeSqlExecResult;
|
|
1006
1040
|
actorSqlTransactionExecute(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
1041
|
+
actorSqlTransactionExecuteSync(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): RuntimeSqlExecuteResult;
|
|
1007
1042
|
actorSqlTransactionCommit(transaction: SqliteTransactionHandle): Promise<void>;
|
|
1043
|
+
actorSqlTransactionCommitSync(transaction: SqliteTransactionHandle): void;
|
|
1008
1044
|
actorSqlTransactionRollback(transaction: SqliteTransactionHandle): Promise<void>;
|
|
1045
|
+
actorSqlTransactionRollbackSync(transaction: SqliteTransactionHandle): void;
|
|
1009
1046
|
actorBeginStateTransaction(ctx: ActorContextHandle, timeoutMs?: number): Promise<ActorStateTransactionHandle>;
|
|
1010
1047
|
actorStateTransactionExecute(transaction: ActorStateTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
1048
|
+
actorStateTransactionExecuteSync(transaction: ActorStateTransactionHandle, sql: string, params?: RuntimeSqlBindParams): RuntimeSqlExecuteResult;
|
|
1011
1049
|
actorStateTransactionCommit(transaction: ActorStateTransactionHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
1012
1050
|
actorStateTransactionRollback(transaction: ActorStateTransactionHandle): Promise<void>;
|
|
1013
1051
|
actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
|
|
@@ -2421,7 +2459,7 @@ declare function buildFilesystemActions<TConnParams>(config: AgentOsActorConfig<
|
|
|
2421
2459
|
declare function ensureVm<TConnParams>(c: AgentOsActionContext<TConnParams>, config: AgentOsActorConfig<TConnParams>): Promise<AgentOs>;
|
|
2422
2460
|
declare function syncPreventSleep<TConnParams>(c: AgentOsActionContext<TConnParams>): void;
|
|
2423
2461
|
declare function runHook<TConnParams>(c: AgentOsActionContext<TConnParams>, name: string, callback: () => void | Promise<void>): void;
|
|
2424
|
-
declare function agentOs<TConnParams = undefined>(config: AgentOsActorConfigInput<TConnParams>): ActorDefinition<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, DatabaseProvider<
|
|
2462
|
+
declare function agentOs<TConnParams = undefined>(config: AgentOsActorConfigInput<TConnParams>): ActorDefinition<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, DatabaseProvider<SynchronousRawAccess>, {
|
|
2425
2463
|
sessionEvent: typeof sessionEventToken;
|
|
2426
2464
|
permissionRequest: typeof permissionRequestToken;
|
|
2427
2465
|
vmBooted: typeof vmBootedToken;
|
|
@@ -2456,7 +2494,7 @@ declare function buildNetworkActions<TConnParams>(config: AgentOsActorConfig<TCo
|
|
|
2456
2494
|
};
|
|
2457
2495
|
|
|
2458
2496
|
declare function generateToken(): string;
|
|
2459
|
-
type AgentOsRequestContext<TConnParams> = RequestContext<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, DatabaseProvider<
|
|
2497
|
+
type AgentOsRequestContext<TConnParams> = RequestContext<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, DatabaseProvider<SynchronousRawAccess>>;
|
|
2460
2498
|
declare function buildOnRequestHandler<TConnParams>(config: AgentOsActorConfig<TConnParams>): (c: AgentOsRequestContext<TConnParams>, request: Request) => Promise<Response>;
|
|
2461
2499
|
declare function buildPreviewActions<TConnParams>(config: AgentOsActorConfig<TConnParams>): {
|
|
2462
2500
|
createSignedPreviewUrl: (c: AgentOsActionContext<TConnParams>, port: number, expiresInSeconds?: number) => Promise<{
|
|
@@ -79,9 +79,12 @@ interface SqliteNativeMetrics {
|
|
|
79
79
|
}
|
|
80
80
|
interface SqliteDatabase {
|
|
81
81
|
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
82
|
+
execSync?(sql: string, callback?: (row: unknown[], columns: string[]) => void): void;
|
|
82
83
|
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
84
|
+
executeSync?(sql: string, params?: SqliteBindings): SqliteExecuteResult;
|
|
83
85
|
executeBatch(statements: SqliteBatchStatement[]): Promise<SqliteExecuteResult[]>;
|
|
84
86
|
beginTransaction(timeoutMs?: number, name?: string): Promise<SqliteTransactionDatabase>;
|
|
87
|
+
beginTransactionSync?(timeoutMs?: number, name?: string): SynchronousSqliteTransactionDatabase;
|
|
85
88
|
run(sql: string, params?: SqliteBindings): Promise<void>;
|
|
86
89
|
query(sql: string, params?: SqliteBindings): Promise<SqliteQueryResult>;
|
|
87
90
|
nativeMetrics?(): SqliteNativeMetrics | Promise<SqliteNativeMetrics | null> | null;
|
|
@@ -89,10 +92,18 @@ interface SqliteDatabase {
|
|
|
89
92
|
}
|
|
90
93
|
interface SqliteTransactionDatabase {
|
|
91
94
|
exec(sql: string, callback?: (row: unknown[], columns: string[]) => void): Promise<void>;
|
|
95
|
+
execSync?(sql: string, callback?: (row: unknown[], columns: string[]) => void): void;
|
|
92
96
|
execute(sql: string, params?: SqliteBindings): Promise<SqliteExecuteResult>;
|
|
97
|
+
executeSync?(sql: string, params?: SqliteBindings): SqliteExecuteResult;
|
|
93
98
|
commit(): Promise<void>;
|
|
94
99
|
rollback(): Promise<void>;
|
|
95
100
|
}
|
|
101
|
+
type SynchronousSqliteTransactionDatabase = SqliteTransactionDatabase & {
|
|
102
|
+
execSync(sql: string, callback?: (row: unknown[], columns: string[]) => void): void;
|
|
103
|
+
executeSync(sql: string, params?: SqliteBindings): SqliteExecuteResult;
|
|
104
|
+
commitSync(): void;
|
|
105
|
+
rollbackSync(): void;
|
|
106
|
+
};
|
|
96
107
|
/**
|
|
97
108
|
* Provider for opening native databases from the active runtime.
|
|
98
109
|
*/
|
|
@@ -161,11 +172,21 @@ type DatabaseProvider<DB extends RawAccess> = {
|
|
|
161
172
|
*/
|
|
162
173
|
type DrizzleDatabaseClient = {};
|
|
163
174
|
type ExecuteFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => Promise<TRow[]>;
|
|
175
|
+
type ExecuteSyncFunction = <TRow extends Record<string, unknown> = Record<string, unknown>>(query: string, ...args: unknown[]) => TRow[];
|
|
176
|
+
/** SQL operations available inside a synchronous transaction callback. */
|
|
177
|
+
type SynchronousTransactionAccess = {
|
|
178
|
+
executeSync: ExecuteSyncFunction;
|
|
179
|
+
};
|
|
164
180
|
type RawAccess = {
|
|
165
181
|
/**
|
|
166
182
|
* Executes a raw SQL query.
|
|
167
183
|
*/
|
|
168
184
|
execute: ExecuteFunction;
|
|
185
|
+
/**
|
|
186
|
+
* Executes a raw SQL query synchronously when supported by the runtime.
|
|
187
|
+
* This blocks the Node.js event loop. Prefer `execute` for normal use.
|
|
188
|
+
*/
|
|
189
|
+
executeSync?: ExecuteSyncFunction;
|
|
169
190
|
/** Runs a callback in an isolated SQLite transaction. */
|
|
170
191
|
transaction: <T>(callback: (tx: RawAccess) => Promise<T> | T, options?: SqliteTransactionOptions) => Promise<T>;
|
|
171
192
|
/**
|
|
@@ -177,6 +198,15 @@ type RawAccess = {
|
|
|
177
198
|
*/
|
|
178
199
|
close: () => Promise<void>;
|
|
179
200
|
};
|
|
201
|
+
/** Raw database access with synchronous operations provided by the Node.js runtime. */
|
|
202
|
+
type SynchronousRawAccess = RawAccess & {
|
|
203
|
+
executeSync: ExecuteSyncFunction;
|
|
204
|
+
/**
|
|
205
|
+
* Runs a synchronous callback in an isolated SQLite transaction.
|
|
206
|
+
* The callback must not return a promise.
|
|
207
|
+
*/
|
|
208
|
+
transactionSync: <T>(callback: (tx: SynchronousTransactionAccess) => T, options?: Omit<SqliteTransactionOptions, "experimental">) => T;
|
|
209
|
+
};
|
|
180
210
|
|
|
181
211
|
declare const ActorsSchema: z.ZodRecord<z.ZodString, z.ZodCustom<AnyActorDefinition, AnyActorDefinition>>;
|
|
182
212
|
type RegistryActors = z.infer<typeof ActorsSchema>;
|
|
@@ -999,15 +1029,23 @@ interface CoreRuntime {
|
|
|
999
1029
|
actorKvBatchPut(ctx: ActorContextHandle, entries: RuntimeKvEntry[]): Promise<void>;
|
|
1000
1030
|
actorKvBatchDelete(ctx: ActorContextHandle, keys: RuntimeBytes[]): Promise<void>;
|
|
1001
1031
|
actorSqlExec(ctx: ActorContextHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
1032
|
+
actorSqlExecSync(ctx: ActorContextHandle, sql: string): RuntimeSqlExecResult;
|
|
1002
1033
|
actorSqlExecute(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
1034
|
+
actorSqlExecuteSync(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): RuntimeSqlExecuteResult;
|
|
1003
1035
|
actorSqlExecuteBatch(ctx: ActorContextHandle, statements: RuntimeSqlBatchStatement[]): Promise<RuntimeSqlExecuteResult[]>;
|
|
1004
1036
|
actorSqlBeginTransaction(ctx: ActorContextHandle, timeoutMs?: number, name?: string): Promise<SqliteTransactionHandle>;
|
|
1037
|
+
actorSqlBeginTransactionSync(ctx: ActorContextHandle, timeoutMs?: number, name?: string): SqliteTransactionHandle;
|
|
1005
1038
|
actorSqlTransactionExec(transaction: SqliteTransactionHandle, sql: string): Promise<RuntimeSqlExecResult>;
|
|
1039
|
+
actorSqlTransactionExecSync(transaction: SqliteTransactionHandle, sql: string): RuntimeSqlExecResult;
|
|
1006
1040
|
actorSqlTransactionExecute(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
1041
|
+
actorSqlTransactionExecuteSync(transaction: SqliteTransactionHandle, sql: string, params?: RuntimeSqlBindParams): RuntimeSqlExecuteResult;
|
|
1007
1042
|
actorSqlTransactionCommit(transaction: SqliteTransactionHandle): Promise<void>;
|
|
1043
|
+
actorSqlTransactionCommitSync(transaction: SqliteTransactionHandle): void;
|
|
1008
1044
|
actorSqlTransactionRollback(transaction: SqliteTransactionHandle): Promise<void>;
|
|
1045
|
+
actorSqlTransactionRollbackSync(transaction: SqliteTransactionHandle): void;
|
|
1009
1046
|
actorBeginStateTransaction(ctx: ActorContextHandle, timeoutMs?: number): Promise<ActorStateTransactionHandle>;
|
|
1010
1047
|
actorStateTransactionExecute(transaction: ActorStateTransactionHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlExecuteResult>;
|
|
1048
|
+
actorStateTransactionExecuteSync(transaction: ActorStateTransactionHandle, sql: string, params?: RuntimeSqlBindParams): RuntimeSqlExecuteResult;
|
|
1011
1049
|
actorStateTransactionCommit(transaction: ActorStateTransactionHandle, payload: RuntimeStateDeltaPayload): Promise<void>;
|
|
1012
1050
|
actorStateTransactionRollback(transaction: ActorStateTransactionHandle): Promise<void>;
|
|
1013
1051
|
actorSqlQuery(ctx: ActorContextHandle, sql: string, params?: RuntimeSqlBindParams): Promise<RuntimeSqlQueryResult>;
|
|
@@ -2421,7 +2459,7 @@ declare function buildFilesystemActions<TConnParams>(config: AgentOsActorConfig<
|
|
|
2421
2459
|
declare function ensureVm<TConnParams>(c: AgentOsActionContext<TConnParams>, config: AgentOsActorConfig<TConnParams>): Promise<AgentOs>;
|
|
2422
2460
|
declare function syncPreventSleep<TConnParams>(c: AgentOsActionContext<TConnParams>): void;
|
|
2423
2461
|
declare function runHook<TConnParams>(c: AgentOsActionContext<TConnParams>, name: string, callback: () => void | Promise<void>): void;
|
|
2424
|
-
declare function agentOs<TConnParams = undefined>(config: AgentOsActorConfigInput<TConnParams>): ActorDefinition<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, DatabaseProvider<
|
|
2462
|
+
declare function agentOs<TConnParams = undefined>(config: AgentOsActorConfigInput<TConnParams>): ActorDefinition<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, DatabaseProvider<SynchronousRawAccess>, {
|
|
2425
2463
|
sessionEvent: typeof sessionEventToken;
|
|
2426
2464
|
permissionRequest: typeof permissionRequestToken;
|
|
2427
2465
|
vmBooted: typeof vmBootedToken;
|
|
@@ -2456,7 +2494,7 @@ declare function buildNetworkActions<TConnParams>(config: AgentOsActorConfig<TCo
|
|
|
2456
2494
|
};
|
|
2457
2495
|
|
|
2458
2496
|
declare function generateToken(): string;
|
|
2459
|
-
type AgentOsRequestContext<TConnParams> = RequestContext<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, DatabaseProvider<
|
|
2497
|
+
type AgentOsRequestContext<TConnParams> = RequestContext<AgentOsActorState, TConnParams, undefined, AgentOsActorVars, undefined, DatabaseProvider<SynchronousRawAccess>>;
|
|
2460
2498
|
declare function buildOnRequestHandler<TConnParams>(config: AgentOsActorConfig<TConnParams>): (c: AgentOsRequestContext<TConnParams>, request: Request) => Promise<Response>;
|
|
2461
2499
|
declare function buildPreviewActions<TConnParams>(config: AgentOsActorConfig<TConnParams>): {
|
|
2462
2500
|
createSignedPreviewUrl: (c: AgentOsActionContext<TConnParams>, port: number, expiresInSeconds?: number) => Promise<{
|
|
@@ -420,7 +420,7 @@ function isRivetErrorCode(error, group, code) {
|
|
|
420
420
|
// package.json
|
|
421
421
|
var package_default = {
|
|
422
422
|
name: "rivetkit",
|
|
423
|
-
version: "0.0.0-
|
|
423
|
+
version: "0.0.0-sync-sqlite.0ed739a",
|
|
424
424
|
description: "Lightweight libraries for building stateful actors on edge platforms",
|
|
425
425
|
license: "Apache-2.0",
|
|
426
426
|
keywords: [
|
|
@@ -921,6 +921,38 @@ function validateTransactionName(name) {
|
|
|
921
921
|
throw new Error("db.transaction() name must not be empty");
|
|
922
922
|
}
|
|
923
923
|
}
|
|
924
|
+
function isPromiseLike(value) {
|
|
925
|
+
return typeof value === "object" && value !== null || typeof value === "function" ? typeof value.then === "function" : false;
|
|
926
|
+
}
|
|
927
|
+
function runSqliteTransactionSync(database, callback, options) {
|
|
928
|
+
validateTransactionTimeout(options == null ? void 0 : options.timeout);
|
|
929
|
+
validateTransactionName(options == null ? void 0 : options.name);
|
|
930
|
+
if (!database.beginTransactionSync) {
|
|
931
|
+
throw new Error(
|
|
932
|
+
"Synchronous SQLite transactions are only available in the Node.js native runtime."
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
const transaction = database.beginTransactionSync(
|
|
936
|
+
options == null ? void 0 : options.timeout,
|
|
937
|
+
options == null ? void 0 : options.name
|
|
938
|
+
);
|
|
939
|
+
try {
|
|
940
|
+
const result = callback(transaction);
|
|
941
|
+
if (isPromiseLike(result)) {
|
|
942
|
+
throw new Error(
|
|
943
|
+
"db.transactionSync() callback must complete synchronously and must not return a promise."
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
transaction.commitSync();
|
|
947
|
+
return result;
|
|
948
|
+
} catch (error) {
|
|
949
|
+
try {
|
|
950
|
+
transaction.rollbackSync();
|
|
951
|
+
} catch {
|
|
952
|
+
}
|
|
953
|
+
throw error;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
924
956
|
function isSqliteBindingValue(value) {
|
|
925
957
|
if (value === null || typeof value === "number" || typeof value === "string" || typeof value === "bigint" || value instanceof Uint8Array) {
|
|
926
958
|
return true;
|
|
@@ -983,6 +1015,7 @@ function db({
|
|
|
983
1015
|
const db2 = await nativeDatabaseProvider.open(ctx.actorId);
|
|
984
1016
|
let closed = false;
|
|
985
1017
|
let manualTransactionWarned = false;
|
|
1018
|
+
let synchronousTransactionActive = false;
|
|
986
1019
|
const ensureOpen = () => {
|
|
987
1020
|
if (closed) {
|
|
988
1021
|
throw new Error(
|
|
@@ -990,16 +1023,24 @@ function db({
|
|
|
990
1023
|
);
|
|
991
1024
|
}
|
|
992
1025
|
};
|
|
1026
|
+
const ensureSynchronousTransactionClient = (transactionScoped) => {
|
|
1027
|
+
if (!transactionScoped && synchronousTransactionActive) {
|
|
1028
|
+
throw new Error(
|
|
1029
|
+
"Use the transaction callback's tx value for queries inside db.transactionSync()."
|
|
1030
|
+
);
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
993
1033
|
const createClient = (target, transactionScoped = false, stateTransactionContext) => {
|
|
994
1034
|
const client2 = {
|
|
995
1035
|
execute: async (query, ...args) => {
|
|
996
1036
|
var _a, _b, _c, _d;
|
|
997
1037
|
ensureOpen();
|
|
1038
|
+
ensureSynchronousTransactionClient(transactionScoped);
|
|
998
1039
|
if (!transactionScoped && warnOnManualTransactions && !manualTransactionWarned && !hasMultipleStatements(query) && isManualTransactionControl(query)) {
|
|
999
1040
|
manualTransactionWarned = true;
|
|
1000
1041
|
getLogger("database").warn(
|
|
1001
1042
|
{ actorId: ctx.actorId },
|
|
1002
|
-
"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."
|
|
1043
|
+
"Manual cross-call SQLite transactions can interleave with other actor work. Use db.transaction() or db.transactionSync() for coordinated transactions. Set warnOnManualTransactions: false in your db(...) configuration to disable this warning."
|
|
1003
1044
|
);
|
|
1004
1045
|
}
|
|
1005
1046
|
const kvReadsBefore = ((_a = ctx.metrics) == null ? void 0 : _a.totalKvReads) ?? 0;
|
|
@@ -1045,8 +1086,66 @@ function db({
|
|
|
1045
1086
|
}
|
|
1046
1087
|
}
|
|
1047
1088
|
},
|
|
1089
|
+
executeSync: (query, ...args) => {
|
|
1090
|
+
var _a, _b, _c, _d;
|
|
1091
|
+
ensureOpen();
|
|
1092
|
+
ensureSynchronousTransactionClient(transactionScoped);
|
|
1093
|
+
if (!target.executeSync) {
|
|
1094
|
+
throw new Error(
|
|
1095
|
+
"Synchronous SQLite queries are only available in the Node.js native runtime."
|
|
1096
|
+
);
|
|
1097
|
+
}
|
|
1098
|
+
if (!transactionScoped && warnOnManualTransactions && !manualTransactionWarned && !hasMultipleStatements(query) && isManualTransactionControl(query)) {
|
|
1099
|
+
manualTransactionWarned = true;
|
|
1100
|
+
getLogger("database").warn(
|
|
1101
|
+
{ actorId: ctx.actorId },
|
|
1102
|
+
"Manual cross-call SQLite transactions can interleave with other actor work. Use db.transaction() or db.transactionSync() for coordinated transactions. Set warnOnManualTransactions: false in your db(...) configuration to disable this warning."
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
const kvReadsBefore = ((_a = ctx.metrics) == null ? void 0 : _a.totalKvReads) ?? 0;
|
|
1106
|
+
const kvWritesBefore = ((_b = ctx.metrics) == null ? void 0 : _b.totalKvWrites) ?? 0;
|
|
1107
|
+
const start = performance.now();
|
|
1108
|
+
try {
|
|
1109
|
+
if (args.length > 0) {
|
|
1110
|
+
const bindings = args.length === 1 && isSqliteBindingObject(args[0]) ? toSqliteBindings(args[0]) : toSqliteBindings(args);
|
|
1111
|
+
const { rows, columns } = target.executeSync(
|
|
1112
|
+
query,
|
|
1113
|
+
bindings
|
|
1114
|
+
);
|
|
1115
|
+
return rows.map(
|
|
1116
|
+
(row) => rowToObject(row, columns)
|
|
1117
|
+
);
|
|
1118
|
+
}
|
|
1119
|
+
if (!hasMultipleStatements(query)) {
|
|
1120
|
+
const { rows, columns } = target.executeSync(
|
|
1121
|
+
query,
|
|
1122
|
+
void 0
|
|
1123
|
+
);
|
|
1124
|
+
return rows.map(
|
|
1125
|
+
(row) => rowToObject(row, columns)
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
return execMultiStatementSync(target, query);
|
|
1129
|
+
} finally {
|
|
1130
|
+
const durationMs = performance.now() - start;
|
|
1131
|
+
(_c = ctx.metrics) == null ? void 0 : _c.trackSql(query, durationMs);
|
|
1132
|
+
if (ctx.metrics) {
|
|
1133
|
+
const kvReads = ctx.metrics.totalKvReads - kvReadsBefore;
|
|
1134
|
+
const kvWrites = ctx.metrics.totalKvWrites - kvWritesBefore;
|
|
1135
|
+
(_d = ctx.log) == null ? void 0 : _d.debug({
|
|
1136
|
+
msg: "sql query",
|
|
1137
|
+
query: query.slice(0, 120),
|
|
1138
|
+
durationMs,
|
|
1139
|
+
kvReads,
|
|
1140
|
+
kvWrites
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
},
|
|
1048
1145
|
transaction: async (callback, options) => {
|
|
1049
1146
|
var _a, _b;
|
|
1147
|
+
ensureOpen();
|
|
1148
|
+
ensureSynchronousTransactionClient(transactionScoped);
|
|
1050
1149
|
validateTransactionTimeout(options == null ? void 0 : options.timeout);
|
|
1051
1150
|
validateTransactionName(options == null ? void 0 : options.name);
|
|
1052
1151
|
if (transactionScoped && ((_a = options == null ? void 0 : options.experimental) == null ? void 0 : _a.includeState)) {
|
|
@@ -1092,6 +1191,33 @@ function db({
|
|
|
1092
1191
|
}
|
|
1093
1192
|
}
|
|
1094
1193
|
},
|
|
1194
|
+
transactionSync: (callback, options) => {
|
|
1195
|
+
ensureOpen();
|
|
1196
|
+
if (transactionScoped || synchronousTransactionActive) {
|
|
1197
|
+
throw new Error(
|
|
1198
|
+
"Nested synchronous SQLite transactions are not supported."
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
return runSqliteTransactionSync(
|
|
1202
|
+
db2,
|
|
1203
|
+
(transaction) => {
|
|
1204
|
+
const transactionClient = createClient(
|
|
1205
|
+
transaction,
|
|
1206
|
+
true
|
|
1207
|
+
);
|
|
1208
|
+
const tx = {
|
|
1209
|
+
executeSync: transactionClient.executeSync
|
|
1210
|
+
};
|
|
1211
|
+
synchronousTransactionActive = true;
|
|
1212
|
+
try {
|
|
1213
|
+
return callback(tx);
|
|
1214
|
+
} finally {
|
|
1215
|
+
synchronousTransactionActive = false;
|
|
1216
|
+
}
|
|
1217
|
+
},
|
|
1218
|
+
options
|
|
1219
|
+
);
|
|
1220
|
+
},
|
|
1095
1221
|
close: async () => {
|
|
1096
1222
|
if (!closed) {
|
|
1097
1223
|
closed = true;
|
|
@@ -1143,6 +1269,22 @@ async function execMultiStatement(db2, query) {
|
|
|
1143
1269
|
});
|
|
1144
1270
|
return results;
|
|
1145
1271
|
}
|
|
1272
|
+
function execMultiStatementSync(db2, query) {
|
|
1273
|
+
if (!db2.execSync) {
|
|
1274
|
+
throw new Error(
|
|
1275
|
+
"Synchronous SQLite queries are only available in the Node.js native runtime."
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
const results = [];
|
|
1279
|
+
let columnNames = null;
|
|
1280
|
+
db2.execSync(query, (row, columns) => {
|
|
1281
|
+
if (!columnNames) {
|
|
1282
|
+
columnNames = columns;
|
|
1283
|
+
}
|
|
1284
|
+
results.push(rowToObject(row, columnNames));
|
|
1285
|
+
});
|
|
1286
|
+
return results;
|
|
1287
|
+
}
|
|
1146
1288
|
async function withMigrationSavepoint(client, callback) {
|
|
1147
1289
|
return await client.transaction(
|
|
1148
1290
|
async (transaction) => {
|