rivetkit 3.1.1 → 3.1.2-rc.2

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 (92) hide show
  1. package/dist/browser/client.d.ts +16 -1
  2. package/dist/browser/client.js +1 -1
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +1 -1
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/{chunk-SPSBNPLC.cjs → chunk-6BGQCMIF.cjs} +3 -3
  7. package/dist/tsup/{chunk-SPSBNPLC.cjs.map → chunk-6BGQCMIF.cjs.map} +1 -1
  8. package/dist/tsup/{chunk-FBRWBUUV.js → chunk-6MJSWO33.js} +4 -4
  9. package/dist/tsup/{chunk-C4U5WWM6.js → chunk-6NHRZU52.js} +2 -2
  10. package/dist/tsup/{chunk-IROHORSE.cjs → chunk-A3N3LJC6.cjs} +10 -10
  11. package/dist/tsup/{chunk-IROHORSE.cjs.map → chunk-A3N3LJC6.cjs.map} +1 -1
  12. package/dist/tsup/{chunk-HPVDAB3Q.js → chunk-D2CCGHEJ.js} +4 -3
  13. package/dist/tsup/chunk-D2CCGHEJ.js.map +1 -0
  14. package/dist/tsup/{chunk-62DUEJF5.cjs → chunk-DDF35AIK.cjs} +2 -2
  15. package/dist/tsup/chunk-DDF35AIK.cjs.map +1 -0
  16. package/dist/tsup/{chunk-JWREVWQL.js → chunk-I6P2AHO6.js} +2 -2
  17. package/dist/tsup/{chunk-HXFGYYOA.js → chunk-JGMXY4GD.js} +3 -3
  18. package/dist/tsup/{chunk-ZZQFX3FC.cjs → chunk-L2XH4EXJ.cjs} +146 -146
  19. package/dist/tsup/{chunk-ZZQFX3FC.cjs.map → chunk-L2XH4EXJ.cjs.map} +1 -1
  20. package/dist/tsup/{chunk-O4QOORVK.cjs → chunk-LBYX466L.cjs} +3 -3
  21. package/dist/tsup/{chunk-O4QOORVK.cjs.map → chunk-LBYX466L.cjs.map} +1 -1
  22. package/dist/tsup/{chunk-RROV4JN4.js → chunk-MRWI2HTU.js} +2 -2
  23. package/dist/tsup/{chunk-CSYHVROJ.js → chunk-MVOIZGVC.js} +2 -2
  24. package/dist/tsup/chunk-MVOIZGVC.js.map +1 -0
  25. package/dist/tsup/{chunk-IULKFTST.js → chunk-N2SQDK2F.js} +3 -3
  26. package/dist/tsup/{chunk-KTZWFOBF.cjs → chunk-QJ7MIAFD.cjs} +7 -7
  27. package/dist/tsup/{chunk-KTZWFOBF.cjs.map → chunk-QJ7MIAFD.cjs.map} +1 -1
  28. package/dist/tsup/{chunk-2X7ZRXPW.cjs → chunk-TAK6KRMJ.cjs} +5 -4
  29. package/dist/tsup/chunk-TAK6KRMJ.cjs.map +1 -0
  30. package/dist/tsup/{chunk-AGFOGGFH.cjs → chunk-YAGP66QF.cjs} +4 -4
  31. package/dist/tsup/{chunk-AGFOGGFH.cjs.map → chunk-YAGP66QF.cjs.map} +1 -1
  32. package/dist/tsup/client/mod.cjs +5 -5
  33. package/dist/tsup/client/mod.d.cts +2 -2
  34. package/dist/tsup/client/mod.d.ts +2 -2
  35. package/dist/tsup/client/mod.js +4 -4
  36. package/dist/tsup/common/log.cjs +2 -2
  37. package/dist/tsup/common/log.js +1 -1
  38. package/dist/tsup/common/websocket.cjs +3 -3
  39. package/dist/tsup/common/websocket.js +2 -2
  40. package/dist/tsup/{config-BDdeBoxX.d.cts → config-BMGUEKMZ.d.cts} +16 -1
  41. package/dist/tsup/{config-Ch-SMJ-n.d.ts → config-iBpXyITj.d.ts} +16 -1
  42. package/dist/tsup/{context-B-wRuYrf.d.ts → context-hyVakgnU.d.ts} +1 -1
  43. package/dist/tsup/{context-NzsxAAoN.d.cts → context-qfvLuF0P.d.cts} +1 -1
  44. package/dist/tsup/db/drizzle.cjs +2 -2
  45. package/dist/tsup/db/drizzle.js +1 -1
  46. package/dist/tsup/db/mod.cjs +3 -3
  47. package/dist/tsup/db/mod.js +2 -2
  48. package/dist/tsup/dynamic/mod.d.cts +1 -1
  49. package/dist/tsup/dynamic/mod.d.ts +1 -1
  50. package/dist/tsup/inspector/mod.cjs +5 -5
  51. package/dist/tsup/inspector/mod.js +4 -4
  52. package/dist/tsup/inspector/workflow.cjs +4 -4
  53. package/dist/tsup/inspector/workflow.js +3 -3
  54. package/dist/tsup/inspector-tab/mod.d.cts +2 -2
  55. package/dist/tsup/inspector-tab/mod.d.ts +2 -2
  56. package/dist/tsup/mod.cjs +399 -126
  57. package/dist/tsup/mod.cjs.map +1 -1
  58. package/dist/tsup/mod.d.cts +3 -3
  59. package/dist/tsup/mod.d.ts +3 -3
  60. package/dist/tsup/mod.js +319 -46
  61. package/dist/tsup/mod.js.map +1 -1
  62. package/dist/tsup/test/mod.cjs +6 -6
  63. package/dist/tsup/test/mod.d.cts +1 -1
  64. package/dist/tsup/test/mod.d.ts +1 -1
  65. package/dist/tsup/test/mod.js +4 -4
  66. package/dist/tsup/utils.cjs +2 -2
  67. package/dist/tsup/utils.js +1 -1
  68. package/dist/tsup/workflow/mod.cjs +35 -27
  69. package/dist/tsup/workflow/mod.cjs.map +1 -1
  70. package/dist/tsup/workflow/mod.d.cts +3 -3
  71. package/dist/tsup/workflow/mod.d.ts +3 -3
  72. package/dist/tsup/workflow/mod.js +32 -24
  73. package/dist/tsup/workflow/mod.js.map +1 -1
  74. package/package.json +9 -9
  75. package/src/common/database/config.ts +52 -0
  76. package/src/common/database/mod.ts +3 -0
  77. package/src/common/database/native-database.ts +240 -19
  78. package/src/registry/napi-runtime.ts +80 -0
  79. package/src/registry/native.ts +70 -20
  80. package/src/registry/runtime.ts +53 -0
  81. package/src/registry/wasm-runtime.ts +91 -1
  82. package/src/workflow/driver.ts +29 -20
  83. package/dist/tsup/chunk-2X7ZRXPW.cjs.map +0 -1
  84. package/dist/tsup/chunk-62DUEJF5.cjs.map +0 -1
  85. package/dist/tsup/chunk-CSYHVROJ.js.map +0 -1
  86. package/dist/tsup/chunk-HPVDAB3Q.js.map +0 -1
  87. /package/dist/tsup/{chunk-FBRWBUUV.js.map → chunk-6MJSWO33.js.map} +0 -0
  88. /package/dist/tsup/{chunk-C4U5WWM6.js.map → chunk-6NHRZU52.js.map} +0 -0
  89. /package/dist/tsup/{chunk-JWREVWQL.js.map → chunk-I6P2AHO6.js.map} +0 -0
  90. /package/dist/tsup/{chunk-HXFGYYOA.js.map → chunk-JGMXY4GD.js.map} +0 -0
  91. /package/dist/tsup/{chunk-RROV4JN4.js.map → chunk-MRWI2HTU.js.map} +0 -0
  92. /package/dist/tsup/{chunk-IULKFTST.js.map → chunk-N2SQDK2F.js.map} +0 -0
@@ -1,13 +1,17 @@
1
1
  import { decodeBridgeRivetError } from "@/actor/errors";
2
2
  import type {
3
+ DeferredSqliteDatabase,
3
4
  SqliteBatchStatement,
4
5
  SqliteBindings,
5
- SqliteDatabase,
6
6
  SqliteExecuteResult,
7
7
  SqliteNativeMetrics,
8
8
  SqliteTransactionDatabase,
9
+ SynchronousSqliteTransactionDatabase,
9
10
  } from "./config";
10
11
 
12
+ // Matches the name core uses for the transaction behind a native executeBatch call.
13
+ const EXECUTE_BATCH_TRANSACTION_NAME = "rivetkit-execute-batch";
14
+
11
15
  type NativeBindNoValues = {
12
16
  intValue?: never;
13
17
  floatValue?: never;
@@ -74,21 +78,31 @@ interface NativeBatchStatement {
74
78
 
75
79
  export interface JsNativeDatabaseLike {
76
80
  exec(sql: string): Promise<NativeExecResult>;
81
+ execSync(sql: string): NativeExecResult;
77
82
  execute(
78
83
  sql: string,
79
84
  params?: NativeBindParam[] | null,
80
85
  ): Promise<NativeExecuteResult>;
86
+ executeSync(
87
+ sql: string,
88
+ params?: NativeBindParam[] | null,
89
+ ): NativeExecuteResult;
81
90
  executeBatch?(
82
91
  statements: NativeBatchStatement[],
83
92
  ): Promise<NativeExecuteResult[]>;
84
93
  beginStateTransaction?(
85
94
  timeoutMs?: number,
86
95
  context?: unknown,
96
+ name?: string,
87
97
  ): Promise<JsNativeTransactionLike>;
88
98
  beginTransaction(
89
99
  timeoutMs?: number,
90
100
  name?: string,
91
101
  ): Promise<JsNativeTransactionLike>;
102
+ beginTransactionSync(
103
+ timeoutMs?: number,
104
+ name?: string,
105
+ ): JsNativeSynchronousTransactionLike;
92
106
  query(
93
107
  sql: string,
94
108
  params?: NativeBindParam[] | null,
@@ -99,12 +113,18 @@ export interface JsNativeDatabaseLike {
99
113
  ): Promise<NativeRunResult>;
100
114
  metrics?(): SqliteNativeMetrics | null;
101
115
  takeLastKvError?(): string | null;
116
+ open(): Promise<void>;
117
+ commitTicket(): number;
118
+ whenDurable(ticket: number): Promise<void>;
119
+ abortGeneration(reason: string): void;
102
120
  close(): Promise<void>;
103
121
  }
104
- export type StateAwareSqliteDatabase = SqliteDatabase & {
122
+ export type StateAwareSqliteDatabase = DeferredSqliteDatabase & {
123
+ open(): Promise<void>;
105
124
  beginStateTransaction(
106
125
  timeoutMs?: number,
107
126
  context?: unknown,
127
+ name?: string,
108
128
  ): Promise<SqliteTransactionDatabase>;
109
129
  };
110
130
 
@@ -123,6 +143,28 @@ export interface JsNativeTransactionLike {
123
143
  rollback(): Promise<void>;
124
144
  }
125
145
 
146
+ export interface JsNativeSynchronousTransactionLike
147
+ extends JsNativeTransactionLike {
148
+ execSync(sql: string): NativeExecResult;
149
+ executeSync(
150
+ sql: string,
151
+ params?: NativeBindParam[] | null,
152
+ ): NativeExecuteResult;
153
+ commitSync(): void;
154
+ rollbackSync(): void;
155
+ }
156
+
157
+ function isSynchronousTransaction(
158
+ transaction: JsNativeTransactionLike,
159
+ ): transaction is JsNativeSynchronousTransactionLike {
160
+ const candidate =
161
+ transaction as Partial<JsNativeSynchronousTransactionLike>;
162
+ return (
163
+ typeof candidate.commitSync === "function" &&
164
+ typeof candidate.rollbackSync === "function"
165
+ );
166
+ }
167
+
126
168
  function shouldAttachNativeKvError(message: string): boolean {
127
169
  return /i\/o error|unable to open database file/i.test(message);
128
170
  }
@@ -162,6 +204,16 @@ function toNativeBinding(arg: unknown): NativeBindParam {
162
204
  return { kind: "null" };
163
205
  }
164
206
  if (typeof arg === "bigint") {
207
+ // Integers cross to native code as JavaScript numbers, which round a bigint past the
208
+ // safe range. Refuse instead of writing a different value.
209
+ if (
210
+ arg > BigInt(Number.MAX_SAFE_INTEGER) ||
211
+ arg < BigInt(Number.MIN_SAFE_INTEGER)
212
+ ) {
213
+ throw new RangeError(
214
+ "SQLite bigint bindings must be within the JavaScript safe integer range.",
215
+ );
216
+ }
165
217
  return { kind: "int", intValue: Number(arg) };
166
218
  }
167
219
  if (typeof arg === "number") {
@@ -185,9 +237,13 @@ function toNativeBinding(arg: unknown): NativeBindParam {
185
237
  function extractNamedSqliteParameters(sql: string): string[] {
186
238
  const orderedNames: string[] = [];
187
239
  const seen = new Set<string>();
188
- const pattern = /([:@$][A-Za-z_][A-Za-z0-9_]*)/g;
240
+ // SQLite identifiers may contain "$" and any non-ASCII character. Consume
241
+ // whole identifiers so their suffixes cannot be mistaken for parameters.
242
+ const pattern =
243
+ /'(?:''|[^'])*'|"(?:""|[^"])*"|`(?:``|[^`])*`|\[[^\]]*\]|--[^\n]*|\/\*[\s\S]*?(?:\*\/|$)|([:@$][\w$\u0080-\u{10FFFF}]+(?:::[\w$\u0080-\u{10FFFF}]+)*(?:\([^)]*\))?)|[A-Za-z_\u0080-\u{10FFFF}][\w$\u0080-\u{10FFFF}]*/gu;
189
244
  for (const match of sql.matchAll(pattern)) {
190
245
  const name = match[1];
246
+ if (!name) continue;
191
247
  if (seen.has(name)) {
192
248
  continue;
193
249
  }
@@ -341,21 +397,49 @@ export function wrapJsNativeDatabase(
341
397
  sql: string,
342
398
  params?: SqliteBindings,
343
399
  ): Promise<SqliteExecuteResult> => {
344
- const lastInsertRowIdColumn = lastInsertRowIdColumnName(sql);
345
- if (lastInsertRowIdColumn) {
346
- return {
347
- columns: [lastInsertRowIdColumn],
348
- rows: [[lastInsertRowId ?? 0]],
349
- changes: 0,
350
- lastInsertRowId,
351
- };
352
- }
353
-
354
400
  const release = gate.enter();
355
401
  try {
402
+ const lastInsertRowIdColumn = lastInsertRowIdColumnName(sql);
403
+ if (lastInsertRowIdColumn) {
404
+ return {
405
+ columns: [lastInsertRowIdColumn],
406
+ rows: [[lastInsertRowId ?? 0]],
407
+ changes: 0,
408
+ lastInsertRowId,
409
+ };
410
+ }
411
+
356
412
  const nativeParams = toNativeBindings(sql, params);
357
413
  const result = await database.execute(sql, nativeParams);
358
- if (result.lastInsertRowId !== undefined) {
414
+ if (result.lastInsertRowId != null) {
415
+ lastInsertRowId = result.lastInsertRowId;
416
+ }
417
+ return result;
418
+ } catch (error) {
419
+ enrichNativeDatabaseError(database, error);
420
+ } finally {
421
+ release();
422
+ }
423
+ };
424
+ const executeNativeSync = (
425
+ sql: string,
426
+ params?: SqliteBindings,
427
+ ): SqliteExecuteResult => {
428
+ const release = gate.enter();
429
+ try {
430
+ const nativeParams = toNativeBindings(sql, params);
431
+ const result = database.executeSync(sql, nativeParams);
432
+ // Execute first so runtime availability and transaction admission are enforced.
433
+ const rowIdColumn = lastInsertRowIdColumnName(sql);
434
+ if (rowIdColumn) {
435
+ return {
436
+ columns: [rowIdColumn],
437
+ rows: [[lastInsertRowId ?? 0]],
438
+ changes: 0,
439
+ lastInsertRowId,
440
+ };
441
+ }
442
+ if (result.lastInsertRowId != null) {
359
443
  lastInsertRowId = result.lastInsertRowId;
360
444
  }
361
445
  return result;
@@ -387,12 +471,34 @@ export function wrapJsNativeDatabase(
387
471
  callback(row, result.columns);
388
472
  }
389
473
  },
474
+ execSync(
475
+ sql: string,
476
+ callback?: (row: unknown[], columns: string[]) => void,
477
+ ): void {
478
+ const release = gate.enter();
479
+ let result: NativeExecResult;
480
+ try {
481
+ result = database.execSync(sql);
482
+ } catch (error) {
483
+ enrichNativeDatabaseError(database, error);
484
+ } finally {
485
+ release();
486
+ }
487
+ if (callback) {
488
+ for (const row of result.rows) {
489
+ callback(row, result.columns);
490
+ }
491
+ }
492
+ },
390
493
  async execute(
391
494
  sql: string,
392
495
  params?: SqliteBindings,
393
496
  ): Promise<SqliteExecuteResult> {
394
497
  return await executeNative(sql, params);
395
498
  },
499
+ executeSync(sql: string, params?: SqliteBindings): SqliteExecuteResult {
500
+ return executeNativeSync(sql, params);
501
+ },
396
502
  async executeBatch(
397
503
  statements: SqliteBatchStatement[],
398
504
  ): Promise<SqliteExecuteResult[]> {
@@ -403,7 +509,10 @@ export function wrapJsNativeDatabase(
403
509
  const results = database.executeBatch
404
510
  ? await database.executeBatch(nativeStatements)
405
511
  : await (async () => {
406
- transaction = await database.beginTransaction();
512
+ transaction = await database.beginTransaction(
513
+ undefined,
514
+ EXECUTE_BATCH_TRANSACTION_NAME,
515
+ );
407
516
  const transactionResults: NativeExecuteResult[] =
408
517
  [];
409
518
  for (const statement of nativeStatements) {
@@ -419,7 +528,7 @@ export function wrapJsNativeDatabase(
419
528
  return transactionResults;
420
529
  })();
421
530
  for (const result of results) {
422
- if (result.lastInsertRowId !== undefined) {
531
+ if (result.lastInsertRowId != null) {
423
532
  lastInsertRowId = result.lastInsertRowId;
424
533
  }
425
534
  }
@@ -451,7 +560,26 @@ export function wrapJsNativeDatabase(
451
560
  release();
452
561
  }
453
562
  return wrapTransaction(database, transaction, gate, (result) => {
454
- if (result.lastInsertRowId !== undefined) {
563
+ if (result.lastInsertRowId != null) {
564
+ lastInsertRowId = result.lastInsertRowId;
565
+ }
566
+ });
567
+ },
568
+ beginTransactionSync(
569
+ timeoutMs?: number,
570
+ name?: string,
571
+ ): SynchronousSqliteTransactionDatabase {
572
+ const release = gate.enter();
573
+ let transaction: JsNativeSynchronousTransactionLike;
574
+ try {
575
+ transaction = database.beginTransactionSync(timeoutMs, name);
576
+ } catch (error) {
577
+ enrichNativeDatabaseError(database, error);
578
+ } finally {
579
+ release();
580
+ }
581
+ return wrapTransaction(database, transaction, gate, (result) => {
582
+ if (result.lastInsertRowId != null) {
455
583
  lastInsertRowId = result.lastInsertRowId;
456
584
  }
457
585
  });
@@ -459,6 +587,7 @@ export function wrapJsNativeDatabase(
459
587
  async beginStateTransaction(
460
588
  timeoutMs?: number,
461
589
  context?: unknown,
590
+ name?: string,
462
591
  ): Promise<SqliteTransactionDatabase> {
463
592
  if (!database.beginStateTransaction) {
464
593
  throw new Error("actor state transactions are not configured");
@@ -469,6 +598,7 @@ export function wrapJsNativeDatabase(
469
598
  transaction = await database.beginStateTransaction(
470
599
  timeoutMs,
471
600
  context,
601
+ name,
472
602
  );
473
603
  } catch (error) {
474
604
  enrichNativeDatabaseError(database, error);
@@ -476,7 +606,7 @@ export function wrapJsNativeDatabase(
476
606
  release();
477
607
  }
478
608
  return wrapTransaction(database, transaction, gate, (result) => {
479
- if (result.lastInsertRowId !== undefined) {
609
+ if (result.lastInsertRowId != null) {
480
610
  lastInsertRowId = result.lastInsertRowId;
481
611
  }
482
612
  });
@@ -491,6 +621,25 @@ export function wrapJsNativeDatabase(
491
621
  nativeMetrics(): SqliteNativeMetrics | null {
492
622
  return normalizeNativeMetrics(database.metrics?.());
493
623
  },
624
+ async open(): Promise<void> {
625
+ const release = gate.enter();
626
+ try {
627
+ await database.open();
628
+ } catch (error) {
629
+ enrichNativeDatabaseError(database, error);
630
+ } finally {
631
+ release();
632
+ }
633
+ },
634
+ commitTicket(): number {
635
+ return database.commitTicket();
636
+ },
637
+ async whenDurable(ticket: number): Promise<void> {
638
+ await database.whenDurable(ticket);
639
+ },
640
+ abortGeneration(reason: string): void {
641
+ database.abortGeneration(reason);
642
+ },
494
643
  async close(): Promise<void> {
495
644
  terminalPromise ??= gate.close(() => database.close());
496
645
  await terminalPromise;
@@ -502,13 +651,25 @@ export function wrapJsNativeDatabase(
502
651
  };
503
652
  }
504
653
 
654
+ function wrapTransaction(
655
+ database: JsNativeDatabaseLike,
656
+ transaction: JsNativeSynchronousTransactionLike,
657
+ gate: NativeCloseGate,
658
+ onExecute: (result: NativeExecuteResult) => void,
659
+ ): SynchronousSqliteTransactionDatabase;
660
+ function wrapTransaction(
661
+ database: JsNativeDatabaseLike,
662
+ transaction: JsNativeTransactionLike,
663
+ gate: NativeCloseGate,
664
+ onExecute: (result: NativeExecuteResult) => void,
665
+ ): SqliteTransactionDatabase;
505
666
  function wrapTransaction(
506
667
  database: JsNativeDatabaseLike,
507
668
  transaction: JsNativeTransactionLike,
508
669
  gate: NativeCloseGate,
509
670
  onExecute: (result: NativeExecuteResult) => void,
510
671
  ): SqliteTransactionDatabase {
511
- return {
672
+ const wrapped: SqliteTransactionDatabase = {
512
673
  async exec(sql, callback) {
513
674
  const release = gate.enter();
514
675
  let result: NativeExecResult;
@@ -559,6 +720,66 @@ function wrapTransaction(
559
720
  }
560
721
  },
561
722
  };
723
+
724
+ if (isSynchronousTransaction(transaction)) {
725
+ return Object.assign(wrapped, {
726
+ execSync(
727
+ sql: string,
728
+ callback?: (row: unknown[], columns: string[]) => void,
729
+ ) {
730
+ const release = gate.enter();
731
+ let result: NativeExecResult;
732
+ try {
733
+ result = transaction.execSync(sql);
734
+ } catch (error) {
735
+ enrichNativeDatabaseError(database, error);
736
+ } finally {
737
+ release();
738
+ }
739
+ if (callback) {
740
+ for (const row of result.rows)
741
+ callback(row, result.columns);
742
+ }
743
+ },
744
+ executeSync(sql: string, params?: SqliteBindings) {
745
+ const release = gate.enter();
746
+ try {
747
+ const result = transaction.executeSync(
748
+ sql,
749
+ toNativeBindings(sql, params),
750
+ );
751
+ onExecute(result);
752
+ return result;
753
+ } catch (error) {
754
+ enrichNativeDatabaseError(database, error);
755
+ } finally {
756
+ release();
757
+ }
758
+ },
759
+ commitSync() {
760
+ const release = gate.enter();
761
+ try {
762
+ transaction.commitSync();
763
+ } catch (error) {
764
+ enrichNativeDatabaseError(database, error);
765
+ } finally {
766
+ release();
767
+ }
768
+ },
769
+ rollbackSync() {
770
+ const release = gate.enter();
771
+ try {
772
+ transaction.rollbackSync();
773
+ } catch (error) {
774
+ enrichNativeDatabaseError(database, error);
775
+ } finally {
776
+ release();
777
+ }
778
+ },
779
+ }) as SynchronousSqliteTransactionDatabase;
780
+ }
781
+
782
+ return wrapped;
562
783
  }
563
784
 
564
785
  function lastInsertRowIdColumnName(sql: string): string | undefined {
@@ -883,6 +883,13 @@ export class NapiCoreRuntime implements CoreRuntime {
883
883
  return await this.#actorSql(ctx).exec(sql);
884
884
  }
885
885
 
886
+ actorSqlExecSync(
887
+ ctx: ActorContextHandle,
888
+ sql: string,
889
+ ): RuntimeSqlExecResult {
890
+ return this.#actorSql(ctx).execSync(sql);
891
+ }
892
+
886
893
  async actorSqlExecute(
887
894
  ctx: ActorContextHandle,
888
895
  sql: string,
@@ -895,6 +902,18 @@ export class NapiCoreRuntime implements CoreRuntime {
895
902
  return normalizeRuntimeSqlExecuteResult(result);
896
903
  }
897
904
 
905
+ actorSqlExecuteSync(
906
+ ctx: ActorContextHandle,
907
+ sql: string,
908
+ params?: RuntimeSqlBindParams,
909
+ ): RuntimeSqlExecuteResult {
910
+ const result = this.#actorSql(ctx).executeSync(
911
+ sql,
912
+ toNapiSqlBindParams(params),
913
+ );
914
+ return normalizeRuntimeSqlExecuteResult(result);
915
+ }
916
+
898
917
  async actorSqlExecuteBatch(
899
918
  ctx: ActorContextHandle,
900
919
  statements: RuntimeSqlBatchStatement[],
@@ -916,6 +935,17 @@ export class NapiCoreRuntime implements CoreRuntime {
916
935
  )) as unknown as SqliteTransactionHandle;
917
936
  }
918
937
 
938
+ actorSqlBeginTransactionSync(
939
+ ctx: ActorContextHandle,
940
+ timeoutMs?: number,
941
+ name?: string,
942
+ ): SqliteTransactionHandle {
943
+ return this.#actorSql(ctx).beginTransactionSync(
944
+ timeoutMs,
945
+ name,
946
+ ) as unknown as SqliteTransactionHandle;
947
+ }
948
+
919
949
  async actorSqlTransactionExec(
920
950
  transaction: SqliteTransactionHandle,
921
951
  sql: string,
@@ -923,6 +953,13 @@ export class NapiCoreRuntime implements CoreRuntime {
923
953
  return await asNativeSqlTransaction(transaction).exec(sql);
924
954
  }
925
955
 
956
+ actorSqlTransactionExecSync(
957
+ transaction: SqliteTransactionHandle,
958
+ sql: string,
959
+ ): RuntimeSqlExecResult {
960
+ return asNativeSqlTransaction(transaction).execSync(sql);
961
+ }
962
+
926
963
  async actorSqlTransactionExecute(
927
964
  transaction: SqliteTransactionHandle,
928
965
  sql: string,
@@ -935,23 +972,47 @@ export class NapiCoreRuntime implements CoreRuntime {
935
972
  return normalizeRuntimeSqlExecuteResult(result);
936
973
  }
937
974
 
975
+ actorSqlTransactionExecuteSync(
976
+ transaction: SqliteTransactionHandle,
977
+ sql: string,
978
+ params?: RuntimeSqlBindParams,
979
+ ): RuntimeSqlExecuteResult {
980
+ const result = asNativeSqlTransaction(transaction).executeSync(
981
+ sql,
982
+ toNapiSqlBindParams(params),
983
+ );
984
+ return normalizeRuntimeSqlExecuteResult(result);
985
+ }
986
+
938
987
  async actorSqlTransactionCommit(
939
988
  transaction: SqliteTransactionHandle,
940
989
  ): Promise<void> {
941
990
  await asNativeSqlTransaction(transaction).commit();
942
991
  }
943
992
 
993
+ actorSqlTransactionCommitSync(transaction: SqliteTransactionHandle): void {
994
+ asNativeSqlTransaction(transaction).commitSync();
995
+ }
996
+
944
997
  async actorSqlTransactionRollback(
945
998
  transaction: SqliteTransactionHandle,
946
999
  ): Promise<void> {
947
1000
  await asNativeSqlTransaction(transaction).rollback();
948
1001
  }
1002
+
1003
+ actorSqlTransactionRollbackSync(
1004
+ transaction: SqliteTransactionHandle,
1005
+ ): void {
1006
+ asNativeSqlTransaction(transaction).rollbackSync();
1007
+ }
949
1008
  async actorBeginStateTransaction(
950
1009
  ctx: ActorContextHandle,
951
1010
  timeoutMs?: number,
1011
+ name?: string,
952
1012
  ): Promise<ActorStateTransactionHandle> {
953
1013
  return (await this.#actorContextForOperation(ctx).beginStateTransaction(
954
1014
  timeoutMs,
1015
+ name,
955
1016
  )) as unknown as ActorStateTransactionHandle;
956
1017
  }
957
1018
 
@@ -1009,6 +1070,25 @@ export class NapiCoreRuntime implements CoreRuntime {
1009
1070
  return this.#actorSql(ctx).takeLastKvError?.() ?? null;
1010
1071
  }
1011
1072
 
1073
+ async actorSqlOpen(ctx: ActorContextHandle): Promise<void> {
1074
+ await this.#actorSql(ctx).open();
1075
+ }
1076
+
1077
+ actorSqlCommitTicket(ctx: ActorContextHandle): number {
1078
+ return this.#actorSql(ctx).commitTicket();
1079
+ }
1080
+
1081
+ actorSqlAbortGeneration(ctx: ActorContextHandle, reason: string): void {
1082
+ this.#actorSql(ctx).abortGeneration(reason);
1083
+ }
1084
+
1085
+ async actorSqlWhenDurable(
1086
+ ctx: ActorContextHandle,
1087
+ ticket: number,
1088
+ ): Promise<void> {
1089
+ await this.#actorSql(ctx).whenDurable(ticket);
1090
+ }
1091
+
1012
1092
  async actorSqlClose(ctx: ActorContextHandle): Promise<void> {
1013
1093
  const nativeCtx = asNativeActorContext(ctx);
1014
1094
  if (!this.#sqlOpened.delete(nativeCtx)) {