@rivetkit/supabase 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.
Files changed (3) hide show
  1. package/dist/mod.js +428 -66
  2. package/dist/mod.mjs +428 -66
  3. package/package.json +3 -3
package/dist/mod.mjs CHANGED
@@ -481,7 +481,7 @@ function unsupportedFeature(feature) {
481
481
  );
482
482
  }
483
483
 
484
- // ../rivetkit/dist/tsup/chunk-GPD77M3M.js
484
+ // ../rivetkit/dist/tsup/chunk-NNPIJLBE.js
485
485
  import {
486
486
  pino,
487
487
  stdTimeFunctions
@@ -13157,7 +13157,7 @@ var classic_default = external_exports;
13157
13157
  // ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/index.js
13158
13158
  var v4_default = classic_default;
13159
13159
 
13160
- // ../rivetkit/dist/tsup/chunk-GPD77M3M.js
13160
+ // ../rivetkit/dist/tsup/chunk-NNPIJLBE.js
13161
13161
  var import_invariant = __toESM(require_invariant(), 1);
13162
13162
  import * as cbor from "cbor-x";
13163
13163
  var getRivetEngine = () => getEnvUniversal("RIVET_ENGINE");
@@ -13331,7 +13331,7 @@ function noopNext() {
13331
13331
  }
13332
13332
  var package_default = {
13333
13333
  name: "rivetkit",
13334
- version: "0.0.0-stack-chore-sync-engine-changes-from-enterprise-mszropyy.677d526",
13334
+ version: "0.0.0-sync-sqlite.0ed739a",
13335
13335
  description: "Lightweight libraries for building stateful actors on edge platforms",
13336
13336
  license: "Apache-2.0",
13337
13337
  keywords: [
@@ -14635,7 +14635,7 @@ function Config({ initialBufferLength = 1024, maxBufferLength = 1024 * 1024 * 32
14635
14635
  };
14636
14636
  }
14637
14637
 
14638
- // ../rivetkit/dist/tsup/chunk-M4RSGECU.js
14638
+ // ../rivetkit/dist/tsup/chunk-EHAGZJ34.js
14639
14639
  var config2 = /* @__PURE__ */ Config({});
14640
14640
  function readWorkflowCbor(bc) {
14641
14641
  return readData(bc);
@@ -15514,45 +15514,7 @@ function removePrefixFromKey(prefixedKey) {
15514
15514
  return prefixedKey.slice(KEYS.KV.length);
15515
15515
  }
15516
15516
 
15517
- // ../rivetkit/dist/tsup/chunk-L6DNN72S.js
15518
- function logger() {
15519
- return getLogger("actor-client");
15520
- }
15521
- var webSocketPromise = null;
15522
- async function importWebSocket() {
15523
- if (webSocketPromise !== null) {
15524
- return webSocketPromise;
15525
- }
15526
- webSocketPromise = (async () => {
15527
- let _WebSocket;
15528
- if (typeof WebSocket !== "undefined") {
15529
- _WebSocket = WebSocket;
15530
- } else {
15531
- try {
15532
- const moduleName = "ws";
15533
- const ws = await import(
15534
- /* webpackIgnore: true */
15535
- moduleName
15536
- );
15537
- _WebSocket = ws.default;
15538
- logger().debug("using websocket from npm");
15539
- } catch {
15540
- _WebSocket = class MockWebSocket {
15541
- constructor() {
15542
- throw new Error(
15543
- 'WebSocket support requires installing the "ws" peer dependency.'
15544
- );
15545
- }
15546
- };
15547
- logger().debug("using mock websocket");
15548
- }
15549
- }
15550
- return _WebSocket;
15551
- })();
15552
- return webSocketPromise;
15553
- }
15554
-
15555
- // ../rivetkit/dist/tsup/chunk-JTHHCZCZ.js
15517
+ // ../rivetkit/dist/tsup/chunk-WCEJTJHO.js
15556
15518
  var MIGRATION_TRANSACTION_TIMEOUT_MS = 5 * 6e4;
15557
15519
  function isManualTransactionControl(query) {
15558
15520
  return /^\s*(?:BEGIN|SAVEPOINT|COMMIT|END|ROLLBACK)\b/i.test(query);
@@ -15572,6 +15534,38 @@ function validateTransactionName(name) {
15572
15534
  throw new Error("db.transaction() name must not be empty");
15573
15535
  }
15574
15536
  }
15537
+ function isPromiseLike(value) {
15538
+ return typeof value === "object" && value !== null || typeof value === "function" ? typeof value.then === "function" : false;
15539
+ }
15540
+ function runSqliteTransactionSync(database, callback, options) {
15541
+ validateTransactionTimeout(options == null ? void 0 : options.timeout);
15542
+ validateTransactionName(options == null ? void 0 : options.name);
15543
+ if (!database.beginTransactionSync) {
15544
+ throw new Error(
15545
+ "Synchronous SQLite transactions are only available in the Node.js native runtime."
15546
+ );
15547
+ }
15548
+ const transaction = database.beginTransactionSync(
15549
+ options == null ? void 0 : options.timeout,
15550
+ options == null ? void 0 : options.name
15551
+ );
15552
+ try {
15553
+ const result = callback(transaction);
15554
+ if (isPromiseLike(result)) {
15555
+ throw new Error(
15556
+ "db.transactionSync() callback must complete synchronously and must not return a promise."
15557
+ );
15558
+ }
15559
+ transaction.commitSync();
15560
+ return result;
15561
+ } catch (error46) {
15562
+ try {
15563
+ transaction.rollbackSync();
15564
+ } catch {
15565
+ }
15566
+ throw error46;
15567
+ }
15568
+ }
15575
15569
  function isSqliteBindingValue(value) {
15576
15570
  if (value === null || typeof value === "number" || typeof value === "string" || typeof value === "bigint" || value instanceof Uint8Array) {
15577
15571
  return true;
@@ -15635,7 +15629,45 @@ var AsyncMutex = class {
15635
15629
  }
15636
15630
  };
15637
15631
 
15638
- // ../rivetkit/dist/tsup/chunk-OWSXJF7Z.js
15632
+ // ../rivetkit/dist/tsup/chunk-SLAKWYOH.js
15633
+ function logger() {
15634
+ return getLogger("actor-client");
15635
+ }
15636
+ var webSocketPromise = null;
15637
+ async function importWebSocket() {
15638
+ if (webSocketPromise !== null) {
15639
+ return webSocketPromise;
15640
+ }
15641
+ webSocketPromise = (async () => {
15642
+ let _WebSocket;
15643
+ if (typeof WebSocket !== "undefined") {
15644
+ _WebSocket = WebSocket;
15645
+ } else {
15646
+ try {
15647
+ const moduleName = "ws";
15648
+ const ws = await import(
15649
+ /* webpackIgnore: true */
15650
+ moduleName
15651
+ );
15652
+ _WebSocket = ws.default;
15653
+ logger().debug("using websocket from npm");
15654
+ } catch {
15655
+ _WebSocket = class MockWebSocket {
15656
+ constructor() {
15657
+ throw new Error(
15658
+ 'WebSocket support requires installing the "ws" peer dependency.'
15659
+ );
15660
+ }
15661
+ };
15662
+ logger().debug("using mock websocket");
15663
+ }
15664
+ }
15665
+ return _WebSocket;
15666
+ })();
15667
+ return webSocketPromise;
15668
+ }
15669
+
15670
+ // ../rivetkit/dist/tsup/chunk-BERJKIW5.js
15639
15671
  var import_invariant2 = __toESM(require_invariant(), 1);
15640
15672
 
15641
15673
  // ../../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
@@ -15813,7 +15845,7 @@ function createVersionedDataHandler(config3) {
15813
15845
  return new VersionedDataHandler(config3);
15814
15846
  }
15815
15847
 
15816
- // ../rivetkit/dist/tsup/chunk-OWSXJF7Z.js
15848
+ // ../rivetkit/dist/tsup/chunk-BERJKIW5.js
15817
15849
  var import_invariant3 = __toESM(require_invariant(), 1);
15818
15850
  var import_invariant4 = __toESM(require_invariant(), 1);
15819
15851
  var PATH_CONNECT = "/connect";
@@ -18318,6 +18350,15 @@ function createQueueSender(senderOptions) {
18318
18350
  send
18319
18351
  };
18320
18352
  }
18353
+ async function prepareRetryableInit(init) {
18354
+ if (init.body instanceof ReadableStream) {
18355
+ return {
18356
+ ...init,
18357
+ body: new Uint8Array(await new Response(init.body).arrayBuffer())
18358
+ };
18359
+ }
18360
+ return init;
18361
+ }
18321
18362
  async function rawHttpFetch(driver, target, params, input, init, options = {}) {
18322
18363
  let path2;
18323
18364
  let originalUrl;
@@ -18852,9 +18893,10 @@ var ActorHandleRaw = class {
18852
18893
  return this.#fetchWithResolvedActor(input, init);
18853
18894
  }
18854
18895
  async #fetchWithResolvedActor(input, init) {
18855
- const { skipReadyWait, ...requestInit } = init ?? {};
18856
- const hasBody = requestInit.body !== void 0 ? requestInit.body !== null : isRequestLike(input) && input.body !== null;
18857
- const maxAttempts = hasBody ? 1 : this.#getDynamicQueryMaxAttempts();
18896
+ const { skipReadyWait, ...restInit } = init ?? {};
18897
+ const maxAttempts = this.#getDynamicQueryMaxAttempts();
18898
+ const requestInit = maxAttempts > 1 ? await prepareRetryableInit(restInit) : restInit;
18899
+ const clonesInputBody = requestInit.body === void 0 && isRequestLike(input) && input.body !== null;
18858
18900
  let useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
18859
18901
  const gatewayOptions = resolveActorGatewayOptions(
18860
18902
  this.#gatewayOptions,
@@ -18874,7 +18916,9 @@ var ActorHandleRaw = class {
18874
18916
  this.#driver,
18875
18917
  target,
18876
18918
  this.#params,
18877
- input,
18919
+ // Clone a body-bearing Request so retries don't reuse a consumed stream.
18920
+ // NOTE: This holds the body in memory until GC (unavoidable).
18921
+ clonesInputBody ? input.clone() : input,
18878
18922
  requestInit,
18879
18923
  gatewayOptions
18880
18924
  );
@@ -21585,7 +21629,7 @@ function apiActorToOutput(actor2) {
21585
21629
  };
21586
21630
  }
21587
21631
 
21588
- // ../rivetkit/dist/tsup/chunk-LHT3TRDM.js
21632
+ // ../rivetkit/dist/tsup/chunk-J7WM3KL5.js
21589
21633
  var nativeStateTransactionOpeners = /* @__PURE__ */ new WeakMap();
21590
21634
  var nativeStateTransactionClientBinders = /* @__PURE__ */ new WeakMap();
21591
21635
  function registerNativeStateTransactionOpener(provider, opener) {
@@ -21620,6 +21664,7 @@ function db({
21620
21664
  const db2 = await nativeDatabaseProvider.open(ctx.actorId);
21621
21665
  let closed = false;
21622
21666
  let manualTransactionWarned = false;
21667
+ let synchronousTransactionActive = false;
21623
21668
  const ensureOpen = () => {
21624
21669
  if (closed) {
21625
21670
  throw new Error(
@@ -21627,16 +21672,24 @@ function db({
21627
21672
  );
21628
21673
  }
21629
21674
  };
21675
+ const ensureSynchronousTransactionClient = (transactionScoped) => {
21676
+ if (!transactionScoped && synchronousTransactionActive) {
21677
+ throw new Error(
21678
+ "Use the transaction callback's tx value for queries inside db.transactionSync()."
21679
+ );
21680
+ }
21681
+ };
21630
21682
  const createClient = (target, transactionScoped = false, stateTransactionContext) => {
21631
21683
  const client2 = {
21632
21684
  execute: async (query, ...args) => {
21633
21685
  var _a2, _b, _c, _d;
21634
21686
  ensureOpen();
21687
+ ensureSynchronousTransactionClient(transactionScoped);
21635
21688
  if (!transactionScoped && warnOnManualTransactions && !manualTransactionWarned && !hasMultipleStatements(query) && isManualTransactionControl(query)) {
21636
21689
  manualTransactionWarned = true;
21637
21690
  getLogger("database").warn(
21638
21691
  { actorId: ctx.actorId },
21639
- "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."
21692
+ "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."
21640
21693
  );
21641
21694
  }
21642
21695
  const kvReadsBefore = ((_a2 = ctx.metrics) == null ? void 0 : _a2.totalKvReads) ?? 0;
@@ -21682,8 +21735,66 @@ function db({
21682
21735
  }
21683
21736
  }
21684
21737
  },
21738
+ executeSync: (query, ...args) => {
21739
+ var _a2, _b, _c, _d;
21740
+ ensureOpen();
21741
+ ensureSynchronousTransactionClient(transactionScoped);
21742
+ if (!target.executeSync) {
21743
+ throw new Error(
21744
+ "Synchronous SQLite queries are only available in the Node.js native runtime."
21745
+ );
21746
+ }
21747
+ if (!transactionScoped && warnOnManualTransactions && !manualTransactionWarned && !hasMultipleStatements(query) && isManualTransactionControl(query)) {
21748
+ manualTransactionWarned = true;
21749
+ getLogger("database").warn(
21750
+ { actorId: ctx.actorId },
21751
+ "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."
21752
+ );
21753
+ }
21754
+ const kvReadsBefore = ((_a2 = ctx.metrics) == null ? void 0 : _a2.totalKvReads) ?? 0;
21755
+ const kvWritesBefore = ((_b = ctx.metrics) == null ? void 0 : _b.totalKvWrites) ?? 0;
21756
+ const start = performance.now();
21757
+ try {
21758
+ if (args.length > 0) {
21759
+ const bindings = args.length === 1 && isSqliteBindingObject(args[0]) ? toSqliteBindings(args[0]) : toSqliteBindings(args);
21760
+ const { rows, columns } = target.executeSync(
21761
+ query,
21762
+ bindings
21763
+ );
21764
+ return rows.map(
21765
+ (row) => rowToObject(row, columns)
21766
+ );
21767
+ }
21768
+ if (!hasMultipleStatements(query)) {
21769
+ const { rows, columns } = target.executeSync(
21770
+ query,
21771
+ void 0
21772
+ );
21773
+ return rows.map(
21774
+ (row) => rowToObject(row, columns)
21775
+ );
21776
+ }
21777
+ return execMultiStatementSync(target, query);
21778
+ } finally {
21779
+ const durationMs = performance.now() - start;
21780
+ (_c = ctx.metrics) == null ? void 0 : _c.trackSql(query, durationMs);
21781
+ if (ctx.metrics) {
21782
+ const kvReads = ctx.metrics.totalKvReads - kvReadsBefore;
21783
+ const kvWrites = ctx.metrics.totalKvWrites - kvWritesBefore;
21784
+ (_d = ctx.log) == null ? void 0 : _d.debug({
21785
+ msg: "sql query",
21786
+ query: query.slice(0, 120),
21787
+ durationMs,
21788
+ kvReads,
21789
+ kvWrites
21790
+ });
21791
+ }
21792
+ }
21793
+ },
21685
21794
  transaction: async (callback, options) => {
21686
21795
  var _a2, _b;
21796
+ ensureOpen();
21797
+ ensureSynchronousTransactionClient(transactionScoped);
21687
21798
  validateTransactionTimeout(options == null ? void 0 : options.timeout);
21688
21799
  validateTransactionName(options == null ? void 0 : options.name);
21689
21800
  if (transactionScoped && ((_a2 = options == null ? void 0 : options.experimental) == null ? void 0 : _a2.includeState)) {
@@ -21729,6 +21840,33 @@ function db({
21729
21840
  }
21730
21841
  }
21731
21842
  },
21843
+ transactionSync: (callback, options) => {
21844
+ ensureOpen();
21845
+ if (transactionScoped || synchronousTransactionActive) {
21846
+ throw new Error(
21847
+ "Nested synchronous SQLite transactions are not supported."
21848
+ );
21849
+ }
21850
+ return runSqliteTransactionSync(
21851
+ db2,
21852
+ (transaction) => {
21853
+ const transactionClient = createClient(
21854
+ transaction,
21855
+ true
21856
+ );
21857
+ const tx = {
21858
+ executeSync: transactionClient.executeSync
21859
+ };
21860
+ synchronousTransactionActive = true;
21861
+ try {
21862
+ return callback(tx);
21863
+ } finally {
21864
+ synchronousTransactionActive = false;
21865
+ }
21866
+ },
21867
+ options
21868
+ );
21869
+ },
21732
21870
  close: async () => {
21733
21871
  if (!closed) {
21734
21872
  closed = true;
@@ -21780,6 +21918,22 @@ async function execMultiStatement(db2, query) {
21780
21918
  });
21781
21919
  return results;
21782
21920
  }
21921
+ function execMultiStatementSync(db2, query) {
21922
+ if (!db2.execSync) {
21923
+ throw new Error(
21924
+ "Synchronous SQLite queries are only available in the Node.js native runtime."
21925
+ );
21926
+ }
21927
+ const results = [];
21928
+ let columnNames = null;
21929
+ db2.execSync(query, (row, columns) => {
21930
+ if (!columnNames) {
21931
+ columnNames = columns;
21932
+ }
21933
+ results.push(rowToObject(row, columnNames));
21934
+ });
21935
+ return results;
21936
+ }
21783
21937
  async function withMigrationSavepoint(client, callback) {
21784
21938
  return await client.transaction(
21785
21939
  async (transaction) => {
@@ -23152,7 +23306,7 @@ function getValidationSchema(schema) {
23152
23306
  }
23153
23307
  return schema;
23154
23308
  }
23155
- function isPromiseLike(value) {
23309
+ function isPromiseLike2(value) {
23156
23310
  return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
23157
23311
  }
23158
23312
  function validateSchemaSync(schemas, key, data) {
@@ -23162,7 +23316,7 @@ function validateSchemaSync(schemas, key, data) {
23162
23316
  }
23163
23317
  if (isStandardSchema(schema)) {
23164
23318
  const result = schema["~standard"].validate(data);
23165
- if (isPromiseLike(result)) {
23319
+ if (isPromiseLike2(result)) {
23166
23320
  throw unsupportedFeature("async schema validation");
23167
23321
  }
23168
23322
  if (result.issues) {
@@ -23894,6 +24048,10 @@ var DocRegistryConfigSchema = external_exports.object({
23894
24048
  serverless: DocServerlessConfigSchema.optional(),
23895
24049
  envoy: DocEnvoyConfigSchema.optional()
23896
24050
  }).describe("RivetKit registry configuration.");
24051
+ function isSynchronousTransaction(transaction) {
24052
+ const candidate = transaction;
24053
+ return typeof candidate.commitSync === "function" && typeof candidate.rollbackSync === "function";
24054
+ }
23897
24055
  function shouldAttachNativeKvError(message) {
23898
24056
  return /i\/o error|unable to open database file/i.test(message);
23899
24057
  }
@@ -24081,6 +24239,30 @@ function wrapJsNativeDatabase(database) {
24081
24239
  release();
24082
24240
  }
24083
24241
  };
24242
+ const executeNativeSync = (sql, params) => {
24243
+ const lastInsertRowIdColumn = lastInsertRowIdColumnName(sql);
24244
+ if (lastInsertRowIdColumn) {
24245
+ return {
24246
+ columns: [lastInsertRowIdColumn],
24247
+ rows: [[lastInsertRowId ?? 0]],
24248
+ changes: 0,
24249
+ lastInsertRowId
24250
+ };
24251
+ }
24252
+ const release = gate.enter();
24253
+ try {
24254
+ const nativeParams = toNativeBindings(sql, params);
24255
+ const result = database.executeSync(sql, nativeParams);
24256
+ if (result.lastInsertRowId !== void 0) {
24257
+ lastInsertRowId = result.lastInsertRowId;
24258
+ }
24259
+ return result;
24260
+ } catch (error46) {
24261
+ enrichNativeDatabaseError(database, error46);
24262
+ } finally {
24263
+ release();
24264
+ }
24265
+ };
24084
24266
  return {
24085
24267
  async exec(sql, callback) {
24086
24268
  const release = gate.enter();
@@ -24099,9 +24281,28 @@ function wrapJsNativeDatabase(database) {
24099
24281
  callback(row, result.columns);
24100
24282
  }
24101
24283
  },
24284
+ execSync(sql, callback) {
24285
+ const release = gate.enter();
24286
+ let result;
24287
+ try {
24288
+ result = database.execSync(sql);
24289
+ } catch (error46) {
24290
+ enrichNativeDatabaseError(database, error46);
24291
+ } finally {
24292
+ release();
24293
+ }
24294
+ if (callback) {
24295
+ for (const row of result.rows) {
24296
+ callback(row, result.columns);
24297
+ }
24298
+ }
24299
+ },
24102
24300
  async execute(sql, params) {
24103
24301
  return await executeNative(sql, params);
24104
24302
  },
24303
+ executeSync(sql, params) {
24304
+ return executeNativeSync(sql, params);
24305
+ },
24105
24306
  async executeBatch(statements) {
24106
24307
  const nativeStatements = statements.map(toNativeBatchStatement);
24107
24308
  const release = gate.enter();
@@ -24156,6 +24357,22 @@ function wrapJsNativeDatabase(database) {
24156
24357
  }
24157
24358
  });
24158
24359
  },
24360
+ beginTransactionSync(timeoutMs, name) {
24361
+ const release = gate.enter();
24362
+ let transaction;
24363
+ try {
24364
+ transaction = database.beginTransactionSync(timeoutMs, name);
24365
+ } catch (error46) {
24366
+ enrichNativeDatabaseError(database, error46);
24367
+ } finally {
24368
+ release();
24369
+ }
24370
+ return wrapTransaction(database, transaction, gate, (result) => {
24371
+ if (result.lastInsertRowId !== void 0) {
24372
+ lastInsertRowId = result.lastInsertRowId;
24373
+ }
24374
+ });
24375
+ },
24159
24376
  async beginStateTransaction(timeoutMs, context) {
24160
24377
  if (!database.beginStateTransaction) {
24161
24378
  throw new Error("actor state transactions are not configured");
@@ -24196,7 +24413,7 @@ function wrapJsNativeDatabase(database) {
24196
24413
  };
24197
24414
  }
24198
24415
  function wrapTransaction(database, transaction, gate, onExecute) {
24199
- return {
24416
+ const wrapped = {
24200
24417
  async exec(sql, callback) {
24201
24418
  const release = gate.enter();
24202
24419
  let result;
@@ -24211,6 +24428,20 @@ function wrapTransaction(database, transaction, gate, onExecute) {
24211
24428
  for (const row of result.rows) callback(row, result.columns);
24212
24429
  }
24213
24430
  },
24431
+ execSync(sql, callback) {
24432
+ const release = gate.enter();
24433
+ let result;
24434
+ try {
24435
+ result = transaction.execSync(sql);
24436
+ } catch (error46) {
24437
+ enrichNativeDatabaseError(database, error46);
24438
+ } finally {
24439
+ release();
24440
+ }
24441
+ if (callback) {
24442
+ for (const row of result.rows) callback(row, result.columns);
24443
+ }
24444
+ },
24214
24445
  async execute(sql, params) {
24215
24446
  const release = gate.enter();
24216
24447
  try {
@@ -24226,6 +24457,21 @@ function wrapTransaction(database, transaction, gate, onExecute) {
24226
24457
  release();
24227
24458
  }
24228
24459
  },
24460
+ executeSync(sql, params) {
24461
+ const release = gate.enter();
24462
+ try {
24463
+ const result = transaction.executeSync(
24464
+ sql,
24465
+ toNativeBindings(sql, params)
24466
+ );
24467
+ onExecute(result);
24468
+ return result;
24469
+ } catch (error46) {
24470
+ enrichNativeDatabaseError(database, error46);
24471
+ } finally {
24472
+ release();
24473
+ }
24474
+ },
24229
24475
  async commit() {
24230
24476
  const release = gate.enter();
24231
24477
  try {
@@ -24247,6 +24493,31 @@ function wrapTransaction(database, transaction, gate, onExecute) {
24247
24493
  }
24248
24494
  }
24249
24495
  };
24496
+ if (isSynchronousTransaction(transaction)) {
24497
+ return Object.assign(wrapped, {
24498
+ commitSync() {
24499
+ const release = gate.enter();
24500
+ try {
24501
+ transaction.commitSync();
24502
+ } catch (error46) {
24503
+ enrichNativeDatabaseError(database, error46);
24504
+ } finally {
24505
+ release();
24506
+ }
24507
+ },
24508
+ rollbackSync() {
24509
+ const release = gate.enter();
24510
+ try {
24511
+ transaction.rollbackSync();
24512
+ } catch (error46) {
24513
+ enrichNativeDatabaseError(database, error46);
24514
+ } finally {
24515
+ release();
24516
+ }
24517
+ }
24518
+ });
24519
+ }
24520
+ return wrapped;
24250
24521
  }
24251
24522
  function lastInsertRowIdColumnName(sql) {
24252
24523
  const match = sql.match(
@@ -24740,6 +25011,9 @@ var NapiCoreRuntime = class {
24740
25011
  async actorSqlExec(ctx, sql) {
24741
25012
  return await this.#actorSql(ctx).exec(sql);
24742
25013
  }
25014
+ actorSqlExecSync(ctx, sql) {
25015
+ return this.#actorSql(ctx).execSync(sql);
25016
+ }
24743
25017
  async actorSqlExecute(ctx, sql, params) {
24744
25018
  const result = await this.#actorSql(ctx).execute(
24745
25019
  sql,
@@ -24747,6 +25021,13 @@ var NapiCoreRuntime = class {
24747
25021
  );
24748
25022
  return normalizeRuntimeSqlExecuteResult(result);
24749
25023
  }
25024
+ actorSqlExecuteSync(ctx, sql, params) {
25025
+ const result = this.#actorSql(ctx).executeSync(
25026
+ sql,
25027
+ toNapiSqlBindParams(params)
25028
+ );
25029
+ return normalizeRuntimeSqlExecuteResult(result);
25030
+ }
24750
25031
  async actorSqlExecuteBatch(ctx, statements) {
24751
25032
  const results = await this.#actorSql(ctx).executeBatch(
24752
25033
  statements.map(toNapiSqlBatchStatement)
@@ -24759,9 +25040,18 @@ var NapiCoreRuntime = class {
24759
25040
  name
24760
25041
  );
24761
25042
  }
25043
+ actorSqlBeginTransactionSync(ctx, timeoutMs, name) {
25044
+ return this.#actorSql(ctx).beginTransactionSync(
25045
+ timeoutMs,
25046
+ name
25047
+ );
25048
+ }
24762
25049
  async actorSqlTransactionExec(transaction, sql) {
24763
25050
  return await asNativeSqlTransaction(transaction).exec(sql);
24764
25051
  }
25052
+ actorSqlTransactionExecSync(transaction, sql) {
25053
+ return asNativeSqlTransaction(transaction).execSync(sql);
25054
+ }
24765
25055
  async actorSqlTransactionExecute(transaction, sql, params) {
24766
25056
  const result = await asNativeSqlTransaction(transaction).execute(
24767
25057
  sql,
@@ -24769,12 +25059,25 @@ var NapiCoreRuntime = class {
24769
25059
  );
24770
25060
  return normalizeRuntimeSqlExecuteResult(result);
24771
25061
  }
25062
+ actorSqlTransactionExecuteSync(transaction, sql, params) {
25063
+ const result = asNativeSqlTransaction(transaction).executeSync(
25064
+ sql,
25065
+ toNapiSqlBindParams(params)
25066
+ );
25067
+ return normalizeRuntimeSqlExecuteResult(result);
25068
+ }
24772
25069
  async actorSqlTransactionCommit(transaction) {
24773
25070
  await asNativeSqlTransaction(transaction).commit();
24774
25071
  }
25072
+ actorSqlTransactionCommitSync(transaction) {
25073
+ asNativeSqlTransaction(transaction).commitSync();
25074
+ }
24775
25075
  async actorSqlTransactionRollback(transaction) {
24776
25076
  await asNativeSqlTransaction(transaction).rollback();
24777
25077
  }
25078
+ actorSqlTransactionRollbackSync(transaction) {
25079
+ asNativeSqlTransaction(transaction).rollbackSync();
25080
+ }
24778
25081
  async actorBeginStateTransaction(ctx, timeoutMs) {
24779
25082
  return await asNativeActorContext(ctx).beginStateTransaction(
24780
25083
  timeoutMs
@@ -24787,6 +25090,13 @@ var NapiCoreRuntime = class {
24787
25090
  );
24788
25091
  return normalizeRuntimeSqlExecuteResult(result);
24789
25092
  }
25093
+ actorStateTransactionExecuteSync(transaction, sql, params) {
25094
+ const result = asNativeActorStateTransaction(transaction).executeSync(
25095
+ sql,
25096
+ toNapiSqlBindParams(params)
25097
+ );
25098
+ return normalizeRuntimeSqlExecuteResult(result);
25099
+ }
24790
25100
  async actorStateTransactionCommit(transaction, payload) {
24791
25101
  await asNativeActorStateTransaction(transaction).commit(
24792
25102
  toNapiStateDeltaPayload(payload)
@@ -25386,6 +25696,11 @@ function optionalWasmNumber(value) {
25386
25696
  function wasmNumber(value) {
25387
25697
  return typeof value === "bigint" ? Number(value) : value;
25388
25698
  }
25699
+ function synchronousSqliteUnavailable() {
25700
+ throw new Error(
25701
+ "Synchronous SQLite operations are only available in the Node.js native runtime."
25702
+ );
25703
+ }
25389
25704
  function normalizeKvEntry(entry) {
25390
25705
  return {
25391
25706
  key: toBytes(entry.key),
@@ -25789,12 +26104,18 @@ var WasmCoreRuntime = class {
25789
26104
  async actorSqlExec(ctx, sql) {
25790
26105
  return await callWasm(() => this.#actorSql(ctx).exec(sql));
25791
26106
  }
26107
+ actorSqlExecSync(_ctx, _sql) {
26108
+ return synchronousSqliteUnavailable();
26109
+ }
25792
26110
  async actorSqlExecute(ctx, sql, params) {
25793
26111
  const result = await callWasm(
25794
26112
  () => this.#actorSql(ctx).execute(sql, params)
25795
26113
  );
25796
26114
  return normalizeRuntimeSqlExecuteResult(result);
25797
26115
  }
26116
+ actorSqlExecuteSync(_ctx, _sql, _params) {
26117
+ return synchronousSqliteUnavailable();
26118
+ }
25798
26119
  async actorSqlExecuteBatch(ctx, statements) {
25799
26120
  const results = await callWasm(
25800
26121
  () => this.#actorSql(ctx).executeBatch(statements)
@@ -25806,27 +26127,42 @@ var WasmCoreRuntime = class {
25806
26127
  () => this.#actorSql(ctx).beginTransaction(timeoutMs, name)
25807
26128
  );
25808
26129
  }
26130
+ actorSqlBeginTransactionSync(_ctx, _timeoutMs, _name) {
26131
+ return synchronousSqliteUnavailable();
26132
+ }
25809
26133
  async actorSqlTransactionExec(transaction, sql) {
25810
26134
  return await callWasm(
25811
26135
  () => transaction.exec(sql)
25812
26136
  );
25813
26137
  }
26138
+ actorSqlTransactionExecSync(_transaction, _sql) {
26139
+ return synchronousSqliteUnavailable();
26140
+ }
25814
26141
  async actorSqlTransactionExecute(transaction, sql, params) {
25815
26142
  const result = await callWasm(
25816
26143
  () => transaction.execute(sql, params)
25817
26144
  );
25818
26145
  return normalizeRuntimeSqlExecuteResult(result);
25819
26146
  }
26147
+ actorSqlTransactionExecuteSync(_transaction, _sql, _params) {
26148
+ return synchronousSqliteUnavailable();
26149
+ }
25820
26150
  async actorSqlTransactionCommit(transaction) {
25821
26151
  await callWasm(
25822
26152
  () => transaction.commit()
25823
26153
  );
25824
26154
  }
26155
+ actorSqlTransactionCommitSync(_transaction) {
26156
+ synchronousSqliteUnavailable();
26157
+ }
25825
26158
  async actorSqlTransactionRollback(transaction) {
25826
26159
  await callWasm(
25827
26160
  () => transaction.rollback()
25828
26161
  );
25829
26162
  }
26163
+ actorSqlTransactionRollbackSync(_transaction) {
26164
+ synchronousSqliteUnavailable();
26165
+ }
25830
26166
  async actorBeginStateTransaction(ctx, timeoutMs) {
25831
26167
  return await callWasm(
25832
26168
  () => asWasmActorContext(ctx).beginStateTransaction(timeoutMs)
@@ -25838,6 +26174,9 @@ var WasmCoreRuntime = class {
25838
26174
  );
25839
26175
  return normalizeRuntimeSqlExecuteResult(result);
25840
26176
  }
26177
+ actorStateTransactionExecuteSync(_transaction, _sql, _params) {
26178
+ return synchronousSqliteUnavailable();
26179
+ }
25841
26180
  async actorStateTransactionCommit(transaction, payload) {
25842
26181
  await callWasm(
25843
26182
  () => transaction.commit(payload)
@@ -26326,7 +26665,7 @@ function getNativePersistState(runtime, ctx) {
26326
26665
  }
26327
26666
  return persistState;
26328
26667
  }
26329
- function isPromiseLike2(value) {
26668
+ function isPromiseLike22(value) {
26330
26669
  return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
26331
26670
  }
26332
26671
  function getNativeConnPersistState(runtime, ctx, conn) {
@@ -26472,6 +26811,18 @@ async function closeNativeDatabaseClient(runtime, ctx) {
26472
26811
  await entry.client.close();
26473
26812
  }
26474
26813
  }
26814
+ function createNativeSqlTransaction(runtime, transaction) {
26815
+ return {
26816
+ exec: (sql) => runtime.actorSqlTransactionExec(transaction, sql),
26817
+ execSync: (sql) => runtime.actorSqlTransactionExecSync(transaction, sql),
26818
+ execute: (sql, params) => runtime.actorSqlTransactionExecute(transaction, sql, params),
26819
+ executeSync: (sql, params) => runtime.actorSqlTransactionExecuteSync(transaction, sql, params),
26820
+ commit: () => runtime.actorSqlTransactionCommit(transaction),
26821
+ commitSync: () => runtime.actorSqlTransactionCommitSync(transaction),
26822
+ rollback: () => runtime.actorSqlTransactionRollback(transaction),
26823
+ rollbackSync: () => runtime.actorSqlTransactionRollbackSync(transaction)
26824
+ };
26825
+ }
26475
26826
  function getOrCreateNativeSqlDatabase(runtime, ctx) {
26476
26827
  const runtimeState = getNativeRuntimeState(runtime, ctx);
26477
26828
  const cachedDatabase = runtimeState.sql;
@@ -26480,7 +26831,9 @@ function getOrCreateNativeSqlDatabase(runtime, ctx) {
26480
26831
  }
26481
26832
  const database = wrapJsNativeDatabase({
26482
26833
  exec: (sql) => runtime.actorSqlExec(ctx, sql),
26834
+ execSync: (sql) => runtime.actorSqlExecSync(ctx, sql),
26483
26835
  execute: (sql, params) => runtime.actorSqlExecute(ctx, sql, params),
26836
+ executeSync: (sql, params) => runtime.actorSqlExecuteSync(ctx, sql, params),
26484
26837
  executeBatch: (statements) => runtime.actorSqlExecuteBatch(ctx, statements),
26485
26838
  beginTransaction: async (timeoutMs, name) => {
26486
26839
  const transaction = await runtime.actorSqlBeginTransaction(
@@ -26488,16 +26841,15 @@ function getOrCreateNativeSqlDatabase(runtime, ctx) {
26488
26841
  timeoutMs,
26489
26842
  name
26490
26843
  );
26491
- return {
26492
- exec: (sql) => runtime.actorSqlTransactionExec(transaction, sql),
26493
- execute: (sql, params) => runtime.actorSqlTransactionExecute(
26494
- transaction,
26495
- sql,
26496
- params
26497
- ),
26498
- commit: () => runtime.actorSqlTransactionCommit(transaction),
26499
- rollback: () => runtime.actorSqlTransactionRollback(transaction)
26500
- };
26844
+ return createNativeSqlTransaction(runtime, transaction);
26845
+ },
26846
+ beginTransactionSync: (timeoutMs, name) => {
26847
+ const transaction = runtime.actorSqlBeginTransactionSync(
26848
+ ctx,
26849
+ timeoutMs,
26850
+ name
26851
+ );
26852
+ return createNativeSqlTransaction(runtime, transaction);
26501
26853
  },
26502
26854
  beginStateTransaction: async (timeoutMs, context) => {
26503
26855
  const scope = context;
@@ -26516,11 +26868,21 @@ function getOrCreateNativeSqlDatabase(runtime, ctx) {
26516
26868
  "actor state transactions only support single-statement execute calls"
26517
26869
  );
26518
26870
  },
26871
+ execSync: () => {
26872
+ throw new Error(
26873
+ "actor state transactions only support single-statement execute calls"
26874
+ );
26875
+ },
26519
26876
  execute: (sql, params) => runtime.actorStateTransactionExecute(
26520
26877
  transaction,
26521
26878
  sql,
26522
26879
  params
26523
26880
  ),
26881
+ executeSync: (sql, params) => runtime.actorStateTransactionExecuteSync(
26882
+ transaction,
26883
+ sql,
26884
+ params
26885
+ ),
26524
26886
  commit: async () => {
26525
26887
  await runtime.actorStateTransactionCommit(
26526
26888
  transaction,
@@ -28648,7 +29010,7 @@ var ActorContextHandleAdapter = class {
28648
29010
  this,
28649
29011
  actorState.state
28650
29012
  );
28651
- if (isPromiseLike2(result)) {
29013
+ if (isPromiseLike22(result)) {
28652
29014
  shouldFinish = false;
28653
29015
  void Promise.resolve(result).catch((error46) => {
28654
29016
  logger22().error({