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
|
@@ -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 (e3) {
|
|
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 = _nullishCoalesce(((_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 = _nullishCoalesce(((_a = ctx.metrics) == null ? void 0 : _a.totalKvReads), () => ( 0));
|
|
1106
|
+
const kvWritesBefore = _nullishCoalesce(((_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)) {
|
|
@@ -1082,7 +1181,7 @@ function db({
|
|
|
1082
1181
|
} catch (error) {
|
|
1083
1182
|
try {
|
|
1084
1183
|
await transaction.rollback();
|
|
1085
|
-
} catch (
|
|
1184
|
+
} catch (e4) {
|
|
1086
1185
|
}
|
|
1087
1186
|
throw error;
|
|
1088
1187
|
}
|
|
@@ -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) => {
|