@voltro/sql-sqlite 0.86.0 → 0.88.0

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/store.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import { isRetryableSqliteFailure as e } from "./retry.js";
2
2
  import { Effect as t, Layer as n, ManagedRuntime as r, Option as i } from "effect";
3
- import { EagerCardinalityError as a, attachEagerLoads as o, attributionFields as s, bulkInsertLimitsFor as c, chunkRowsForInsert as l, coercePredicateForSqlite as u, compileEagerJson as d, compileJsonPatch as f, compilePredicate as p, compileRawFragment as m, compileRowProjection as h, compileSelect as g, decodeRowsFromSchema as _, emitCommittedChanges as v, encodeRowForSchema as y, externalChangeEvent as b, hasEagerLoads as x, isTableReactive as S, jsonPatchAssignments as C, makeEagerFallbackReporter as w, makeTransactionAbortTracker as T, observeDbOp as E, onTransaction as D, qualifyTable as O, quoteIdent as k, raiseChangeListenerCeiling as A, recordsTable as j, requireTable as M, rowKeyColumns as N, runSavepoint as P, runStoreTransaction as F, runWriteRecorders as I, stampGeneratedId as L, stampGeneratedIds as R, upsertUpdatePatch as z, upsertUpdateValues as B, withCapturedAttribution as V } from "@voltro/database";
4
- import { EventEmitter as H } from "node:events";
5
- import { createLogger as U } from "@voltro/logger";
6
- import { SqlClient as W } from "effect/sql/SqlClient";
7
- //#region src/store.ts
8
- var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
3
+ import { EagerCardinalityError as a, attachEagerLoads as o, attributionFields as s, bulkInsertLimitsFor as c, chunkRowsForInsert as l, coercePredicateForSqlite as u, compileEagerJson as d, compileJsonPatch as f, compilePredicate as p, compileRawFragment as m, compileRowProjection as h, compileSelect as g, decodeRowsFromSchema as _, emitCommittedChanges as v, encodeRowForSchema as y, externalChangeEvent as b, hasEagerLoads as x, isTableReactive as S, jsonPatchAssignments as C, makeEagerFallbackReporter as w, makeTransactionAbortTracker as T, observeDbOp as E, onTransaction as D, qualifyTable as O, quoteIdent as k, raiseChangeListenerCeiling as A, recordsTable as j, requireTable as M, rowKeyColumns as N, runSavepoint as P, runStoreTransaction as F, runWriteRecorders as I, stampGeneratedId as L, stampGeneratedIds as R, upsertUpdatePatch as z, upsertUpdateValues as B, withCapturedAttribution as V, writeImagesObserved as H } from "@voltro/database";
4
+ import { EventEmitter as U } from "node:events";
5
+ import { createLogger as W } from "@voltro/logger";
6
+ import { SqlClient as G } from "effect/sql/SqlClient";
7
+ // src/store.ts
8
+ var K = W({ scope: "voltro:sqlite" }), q = async (t) => {
9
9
  let i = t.tracerLayer ? n.mergeAll(t.sqlLayer, t.tracerLayer) : t.sqlLayer, a = r.make(i);
10
- return new Z(await a.runPromise(W), a, null, void 0, t.isRetryable ?? e, t.systemName ?? "sqlite", t.wrapTransaction, t.fullText ?? "fts5");
11
- }, q = (e) => e, J = (e) => u(e), Y = (e) => e.predicate === void 0 || e.predicate === null ? e : {
10
+ return new Q(await a.runPromise(G), a, null, void 0, t.isRetryable ?? e, t.systemName ?? "sqlite", t.wrapTransaction, t.fullText ?? "fts5");
11
+ }, J = (e) => e, Y = (e) => u(e), X = (e) => e.predicate === void 0 || e.predicate === null ? e : {
12
12
  ...e,
13
- predicate: J(e.predicate)
14
- }, X = (e, t) => {
13
+ predicate: Y(e.predicate)
14
+ }, Z = (e, t) => {
15
15
  let n = y(e, t, [
16
16
  "json",
17
17
  "array",
@@ -19,7 +19,7 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
19
19
  ]), r = {};
20
20
  for (let [e, t] of Object.entries(n)) r[e] = t instanceof Date ? t.toISOString() : typeof t == "boolean" ? +!!t : t;
21
21
  return r;
22
- }, Z = class n {
22
+ }, Q = class n {
23
23
  sql;
24
24
  runtime;
25
25
  namespace;
@@ -30,8 +30,8 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
30
30
  emitter;
31
31
  inflightTxns = 0;
32
32
  reportEagerFallback;
33
- constructor(t, n, r = null, i, a = e, o = "sqlite", s = q, c = "fts5") {
34
- this.sql = t, this.runtime = n, this.namespace = r, this.isRetryable = a, this.systemName = o, this.wrapTransaction = s, this.fullText = c, this.emitter = i ?? new H(), A(this.emitter), this.reportEagerFallback = w(G);
33
+ constructor(t, n, r = null, i, a = e, o = "sqlite", s = J, c = "fts5") {
34
+ this.sql = t, this.runtime = n, this.namespace = r, this.isRetryable = a, this.systemName = o, this.wrapTransaction = s, this.fullText = c, this.emitter = i ?? new U(), A(this.emitter), this.reportEagerFallback = w(K);
35
35
  }
36
36
  withNamespace(e) {
37
37
  return e === this.namespace ? this : new n(this.sql, this.runtime, e, this.emitter, this.isRetryable, this.systemName, this.wrapTransaction, this.fullText);
@@ -53,16 +53,16 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
53
53
  await this.runtime.runPromise(n`ATTACH DATABASE ${r} AS ${n(e)}`);
54
54
  }
55
55
  async executeQuery(e, n, r) {
56
- let i = g(Y(this.withFullTextMode(e)), this.sql, this.namespace), a = n ? t.provideService(i, this.sql.transactionService, n) : i, o = await E(this.systemName, "select", () => this.runtime.runPromise(a));
56
+ let i = g(X(this.withFullTextMode(e)), this.sql, this.namespace), a = n ? t.provideService(i, this.sql.transactionService, n) : i, o = await E(this.systemName, "select", () => this.runtime.runPromise(a));
57
57
  return _(o, e.table, "sqlite", e);
58
58
  }
59
59
  keyWhere(e, t) {
60
- let n = this.sql, r = X(Object.fromEntries(N(t)), e);
60
+ let n = this.sql, r = Z(Object.fromEntries(N(t)), e);
61
61
  return n.and(Object.entries(r).map(([e, t]) => n`${n(e)} = ${t}`));
62
62
  }
63
63
  async executeInsert(e, n, r, i, a) {
64
64
  n = L(e, n);
65
- let o = this.sql, s = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(X(n, e))} RETURNING ${h(e, o)}`, c = r ? t.provideService(s, this.sql.transactionService, r) : s, l = await this.runtime.runPromise(c), u = _(l, e, "sqlite")[0];
65
+ let o = this.sql, s = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(Z(n, e))} RETURNING ${h(e, o)}`, c = r ? t.provideService(s, this.sql.transactionService, r) : s, l = await this.runtime.runPromise(c), u = _(l, e, "sqlite")[0];
66
66
  if (!u) throw Error(`SqliteStore.insert: no row returned for table '${e}'`);
67
67
  return await this.routeEvent({
68
68
  table: e,
@@ -72,7 +72,7 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
72
72
  }, i, r, a), u;
73
73
  }
74
74
  async executeUpdate(e, n, r, i, a, o) {
75
- let s = this.sql, c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(X(r, e))} WHERE ${this.keyWhere(e, n)} RETURNING ${h(e, s)}`, l = i ? t.provideService(c, this.sql.transactionService, i) : c, u = await this.runtime.runPromise(l), d = _(u, e, "sqlite")[0];
75
+ let s = this.sql, c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(Z(r, e))} WHERE ${this.keyWhere(e, n)} RETURNING ${h(e, s)}`, l = i ? t.provideService(c, this.sql.transactionService, i) : c, u = await this.runtime.runPromise(l), d = _(u, e, "sqlite")[0];
76
76
  return d ? (await this.routeEvent({
77
77
  table: e,
78
78
  op: "update",
@@ -80,28 +80,29 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
80
80
  new: d
81
81
  }, a, i, o), d) : null;
82
82
  }
83
- async executeInsertMany(e, n, r, i, a) {
83
+ async executeInsertMany(e, n, r, i, a, o) {
84
84
  if (n = R(e, n), n.length === 0) return [];
85
- let o = this.sql, s = n.map((t) => X(t, e)), u = l(s, c("sqlite")), d = (t) => o`INSERT INTO ${o(this.nsT(e))} ${o.insert(t)} RETURNING ${h(e, o)}`, f;
86
- if (u.length === 1) {
87
- let e = d(u[0]), n = r ? t.provideService(e, this.sql.transactionService, r) : e;
88
- f = await this.runtime.runPromise(n);
85
+ let s = this.sql, u = o?.returning === "none", d = u && !H(e), f = n.map((t) => Z(t, e)), p = l(f, c("sqlite")), m = (t) => d ? s`INSERT INTO ${s(this.nsT(e))} ${s.insert(t)}` : s`INSERT INTO ${s(this.nsT(e))} ${s.insert(t)} RETURNING ${h(e, s)}`, g;
86
+ if (p.length === 1) {
87
+ let e = m(p[0]), n = r ? t.provideService(e, this.sql.transactionService, r) : e;
88
+ g = await this.runtime.runPromise(n);
89
89
  } else if (r) {
90
90
  let e = [];
91
- for (let n of u) e.push(...await this.runtime.runPromise(t.provideService(d(n), this.sql.transactionService, r)));
92
- f = e;
93
- } else f = await this.runtime.runPromise(o.withTransaction(t.map(t.forEach(u, d, { concurrency: 1 }), (e) => e.flat())));
94
- let p = _(f, e, "sqlite");
95
- for (let t of p) await this.routeEvent({
91
+ for (let n of p) e.push(...await this.runtime.runPromise(t.provideService(m(n), this.sql.transactionService, r)));
92
+ g = e;
93
+ } else g = await this.runtime.runPromise(s.withTransaction(t.map(t.forEach(p, m, { concurrency: 1 }), (e) => e.flat())));
94
+ if (d) return [];
95
+ let v = _(g, e, "sqlite");
96
+ for (let t of v) await this.routeEvent({
96
97
  table: e,
97
98
  op: "insert",
98
99
  old: null,
99
100
  new: t
100
101
  }, i, r, a);
101
- return p;
102
+ return u ? [] : v;
102
103
  }
103
104
  async executePatchJson(e, n, r, i, a, o, s, c) {
104
- let l = this.sql, u = X(C(n, r, c), e), d = l.csv([f(l, "sqlite", r, i, l`${l(this.nsT(e))}.${l(r.split(".")[0])}`), ...Object.entries(u).map(([e, t]) => l`${l(e)} = ${t}`)]), p = l`UPDATE ${l(this.nsT(e))} SET ${d} WHERE ${this.keyWhere(e, n)} RETURNING ${h(e, l)}`, m = a ? t.provideService(p, this.sql.transactionService, a) : p, g = await this.runtime.runPromise(m), v = _(g, e, "sqlite")[0];
105
+ let l = this.sql, u = Z(C(n, r, c), e), d = l.csv([f(l, "sqlite", r, i, l`${l(this.nsT(e))}.${l(r.split(".")[0])}`), ...Object.entries(u).map(([e, t]) => l`${l(e)} = ${t}`)]), p = l`UPDATE ${l(this.nsT(e))} SET ${d} WHERE ${this.keyWhere(e, n)} RETURNING ${h(e, l)}`, m = a ? t.provideService(p, this.sql.transactionService, a) : p, g = await this.runtime.runPromise(m), v = _(g, e, "sqlite")[0];
105
106
  return v ? (await this.routeEvent({
106
107
  table: e,
107
108
  op: "update",
@@ -119,7 +120,7 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
119
120
  }, i, r, a), !0) : !1;
120
121
  }
121
122
  async appendInTxn(e, n, r) {
122
- let i = this.sql, a = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(X(n, e))}`;
123
+ let i = this.sql, a = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(Z(n, e))}`;
123
124
  await this.runtime.runPromise(r ? t.provideService(a, this.sql.transactionService, r) : a);
124
125
  }
125
126
  async maxInTxn(e, n, r, i) {
@@ -152,7 +153,7 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
152
153
  }
153
154
  return this.executeInsert(e, n, i, a, o);
154
155
  }
155
- let c = this.sql, l = r.conflictColumns.map((e) => c`${c(e)}`), u = Object.keys(n).filter((e) => n[e] !== void 0), d = r.update === void 0 ? u.filter((e) => e !== "id" && !r.conflictColumns.includes(e)) : r.update, f = X(s, e), p = [...d.filter((e) => !Object.hasOwn(s, e)).map((e) => c`${c(e)} = excluded.${c(e)}`), ...Object.entries(f).map(([e, t]) => c`${c(e)} = ${t}`)], m = p.length > 0 ? c.csv(p) : c`${c(r.conflictColumns[0])} = excluded.${c(r.conflictColumns[0])}`, g = c`INSERT INTO ${c(this.nsT(e))} ${c.insert(X(n, e))} ON CONFLICT (${c.csv(l)}) DO UPDATE SET ${m} RETURNING ${h(e, c)}`, v = i ? t.provideService(g, this.sql.transactionService, i) : g, y = await this.runtime.runPromise(v), b = _(y, e, "sqlite")[0];
156
+ let c = this.sql, l = r.conflictColumns.map((e) => c`${c(e)}`), u = Object.keys(n).filter((e) => n[e] !== void 0), d = r.update === void 0 ? u.filter((e) => e !== "id" && !r.conflictColumns.includes(e)) : r.update, f = Z(s, e), p = [...d.filter((e) => !Object.hasOwn(s, e)).map((e) => c`${c(e)} = excluded.${c(e)}`), ...Object.entries(f).map(([e, t]) => c`${c(e)} = ${t}`)], m = p.length > 0 ? c.csv(p) : c`${c(r.conflictColumns[0])} = excluded.${c(r.conflictColumns[0])}`, g = c`INSERT INTO ${c(this.nsT(e))} ${c.insert(Z(n, e))} ON CONFLICT (${c.csv(l)}) DO UPDATE SET ${m} RETURNING ${h(e, c)}`, v = i ? t.provideService(g, this.sql.transactionService, i) : g, y = await this.runtime.runPromise(v), b = _(y, e, "sqlite")[0];
156
157
  if (!b) throw Error(`SqliteStore.upsert: no row returned for table '${e}'`);
157
158
  let x = n.id !== void 0 && n.id === b.id ? "insert" : "update";
158
159
  return await this.routeEvent({
@@ -164,7 +165,7 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
164
165
  }
165
166
  async executeInsertIgnore(e, n, r, i, a, o) {
166
167
  n = L(e, n);
167
- let s = this.sql, c = r.conflictColumns.map((e) => s`${s(e)}`), l = s`INSERT INTO ${s(this.nsT(e))} ${s.insert(X(n, e))} ON CONFLICT (${s.csv(c)}) DO NOTHING RETURNING ${h(e, s)}`, u = i ? t.provideService(l, this.sql.transactionService, i) : l, d = await this.runtime.runPromise(u), f = _(d, e, "sqlite")[0];
168
+ let s = this.sql, c = r.conflictColumns.map((e) => s`${s(e)}`), l = s`INSERT INTO ${s(this.nsT(e))} ${s.insert(Z(n, e))} ON CONFLICT (${s.csv(c)}) DO NOTHING RETURNING ${h(e, s)}`, u = i ? t.provideService(l, this.sql.transactionService, i) : l, d = await this.runtime.runPromise(u), f = _(d, e, "sqlite")[0];
168
169
  if (f) return await this.routeEvent({
169
170
  table: e,
170
171
  op: "insert",
@@ -183,15 +184,26 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
183
184
  }
184
185
  async findByConflict(e, n, r, i) {
185
186
  if (r.length === 0) return;
186
- let a = this.sql, o = X(Object.fromEntries(r.map((e) => [e, n[e]])), e), s = r.map((e) => a`${a(e)} = ${o[e]}`), c = a`SELECT ${h(e, a)} FROM ${a(this.nsT(e))} WHERE ${a.and(s)} LIMIT 1`, l = i ? t.provideService(c, this.sql.transactionService, i) : c, u = await this.runtime.runPromise(l);
187
+ let a = this.sql, o = Z(Object.fromEntries(r.map((e) => [e, n[e]])), e), s = r.map((e) => a`${a(e)} = ${o[e]}`), c = a`SELECT ${h(e, a)} FROM ${a(this.nsT(e))} WHERE ${a.and(s)} LIMIT 1`, l = i ? t.provideService(c, this.sql.transactionService, i) : c, u = await this.runtime.runPromise(l);
187
188
  return _(u, e, "sqlite")[0];
188
189
  }
190
+ integrityQuery(e) {
191
+ return this.query(e);
192
+ }
189
193
  query(e) {
190
194
  return this.runWithEager(e, null);
191
195
  }
192
196
  raw(e, t) {
193
197
  return this.rawOn(e, null);
194
198
  }
199
+ async lockRowsOn(e, n) {
200
+ if (e.lock !== "update" || e.alias !== void 0 || e.joins?.length) return;
201
+ let r = this.sql, i = e.predicate ? r` WHERE ${p(Y(e.predicate), r, this.namespace, e.table)}` : r``, a = r`UPDATE ${r(this.nsT(e.table))} SET rowid = rowid${i}`;
202
+ await E(this.systemName, "update", () => this.runtime.runPromise(t.provideService(a, this.sql.transactionService, n)));
203
+ }
204
+ async queryOn(e, t) {
205
+ return await this.lockRowsOn(e, t), this.runWithEager(e, t);
206
+ }
195
207
  rawOn(e, n) {
196
208
  let r = m(e, this.sql), i = n ? t.provideService(r, this.sql.transactionService, n) : r;
197
209
  return E(this.systemName, "raw", () => this.runtime.runPromise(i));
@@ -236,8 +248,8 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
236
248
  insert(e, t) {
237
249
  return this.localWrite("insert", e, (n, r, i) => this.executeInsert(e, t, r, i, n));
238
250
  }
239
- insertMany(e, t) {
240
- return this.localWrite("insert", e, (n, r, i) => this.executeInsertMany(e, t, r, i, n));
251
+ insertMany(e, t, n) {
252
+ return this.localWrite("insert", e, (r, i, a) => this.executeInsertMany(e, t, i, a, r, n));
241
253
  }
242
254
  patchJson(e, t, n, r, i) {
243
255
  return this.localWrite("update", e, (a, o, s) => this.executePatchJson(e, t, n, r, o, s, a, i));
@@ -255,24 +267,26 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
255
267
  return this.executeDeleteMany(e, t, null, null);
256
268
  }
257
269
  async executeUpdateMany(e, n, r, i, a, o) {
258
- let s = this.sql, c = p(J(r.where), s, this.namespace, e), l = s`UPDATE ${s(this.nsT(e))} SET ${s.update(X(n, e))} WHERE ${c} RETURNING ${h(e, s)}`, u = i ? t.provideService(l, this.sql.transactionService, i) : l, d = await E(this.systemName, "update", () => this.runtime.runPromise(u));
259
- for (let t of _(d, e, "sqlite")) await this.routeEvent({
270
+ let s = this.sql, c = p(Y(r.where), s, this.namespace, e), l = H(e), u = l ? h(e, s) : s.literal("1"), d = s`UPDATE ${s(this.nsT(e))} SET ${s.update(Z(n, e))} WHERE ${c} RETURNING ${u}`, f = i ? t.provideService(d, this.sql.transactionService, i) : d, m = await E(this.systemName, "update", () => this.runtime.runPromise(f));
271
+ if (!l) return m.length;
272
+ for (let t of _(m, e, "sqlite")) await this.routeEvent({
260
273
  table: e,
261
274
  op: "update",
262
275
  old: null,
263
276
  new: t
264
277
  }, a, i, o);
265
- return d.length;
278
+ return m.length;
266
279
  }
267
280
  async executeDeleteMany(e, n, r, i, a) {
268
- let o = this.sql, s = p(J(n.where), o, this.namespace, e), c = o`DELETE FROM ${o(this.nsT(e))} WHERE ${s} RETURNING ${h(e, o)}`, l = r ? t.provideService(c, this.sql.transactionService, r) : c, u = await E(this.systemName, "delete", () => this.runtime.runPromise(l));
269
- for (let t of _(u, e, "sqlite")) await this.routeEvent({
281
+ let o = this.sql, s = p(Y(n.where), o, this.namespace, e), c = H(e), l = c ? h(e, o) : o.literal("1"), u = o`DELETE FROM ${o(this.nsT(e))} WHERE ${s} RETURNING ${l}`, d = r ? t.provideService(u, this.sql.transactionService, r) : u, f = await E(this.systemName, "delete", () => this.runtime.runPromise(d));
282
+ if (!c) return f.length;
283
+ for (let t of _(f, e, "sqlite")) await this.routeEvent({
270
284
  table: e,
271
285
  op: "delete",
272
286
  old: t,
273
287
  new: null
274
288
  }, i, r, a);
275
- return u.length;
289
+ return f.length;
276
290
  }
277
291
  upsert(e, t, n) {
278
292
  return this.localWrite("upsert", e, (r, i, a) => this.executeUpsert(e, t, n, i, a, r));
@@ -347,7 +361,7 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
347
361
  return await F({
348
362
  ...this.txnSpec("SqliteStore.transactional"),
349
363
  work: e,
350
- makeView: (e, t) => new Q(this, e, t)
364
+ makeView: (e, t) => new $(this, e, t)
351
365
  });
352
366
  } finally {
353
367
  this.inflightTxns--;
@@ -389,7 +403,7 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
389
403
  if (this.inflightTxns > 0) {
390
404
  let t = Date.now() + e;
391
405
  for (; this.inflightTxns > 0 && Date.now() < t;) await new Promise((e) => setTimeout(e, 25));
392
- this.inflightTxns > 0 && G.warn("close: grace period expired with in-flight transactions", {
406
+ this.inflightTxns > 0 && K.warn("close: grace period expired with in-flight transactions", {
393
407
  gracePeriodMs: e,
394
408
  inflight: this.inflightTxns
395
409
  });
@@ -399,7 +413,7 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
399
413
  async ping() {
400
414
  await this.runtime.runPromise(this.sql`SELECT 1`);
401
415
  }
402
- }, Q = class {
416
+ }, $ = class {
403
417
  parent;
404
418
  txn;
405
419
  attr;
@@ -409,13 +423,18 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
409
423
  constructor(e, t, n = void 0) {
410
424
  this.parent = e, this.txn = t, this.attr = n;
411
425
  }
412
- savepoint(e) {
413
- return P({
414
- tracker: this.aborts,
415
- name: `voltro_sp_${++this.savepointCounter}`,
416
- spelling: "standard",
417
- exec: (e) => this.parent.run(t.provideService(W.pipe(t.flatMap((t) => t.unsafe(e))), this.parent.transactionService, this.txn))
418
- }, e);
426
+ async savepoint(e) {
427
+ let n = this.events.length;
428
+ try {
429
+ return await P({
430
+ tracker: this.aborts,
431
+ name: `voltro_sp_${++this.savepointCounter}`,
432
+ spelling: "standard",
433
+ exec: (e) => this.parent.run(t.provideService(G.pipe(t.flatMap((t) => t.unsafe(e))), this.parent.transactionService, this.txn))
434
+ }, e);
435
+ } catch (e) {
436
+ throw this.events.length = n, e;
437
+ }
419
438
  }
420
439
  savepointCounter = 0;
421
440
  run(e) {
@@ -427,8 +446,11 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
427
446
  raw(e, t) {
428
447
  return this.aborts.track(() => this.parent.rawOn(e, this.txn));
429
448
  }
449
+ integrityQuery(e) {
450
+ return this.query(e);
451
+ }
430
452
  query(e) {
431
- return this.aborts.track(() => this.parent.getInternalRunWithEager()(e, this.txn));
453
+ return this.aborts.track(() => this.parent.queryOn(e, this.txn));
432
454
  }
433
455
  emptyTables(e) {
434
456
  return this.aborts.track(() => this.parent.emptyTablesOn(e, this.txn));
@@ -436,8 +458,8 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
436
458
  insert(e, t) {
437
459
  return this.aborts.track(() => this.parent.getInternalExecuteInsert()(e, t, this.txn, this.events, this.attr));
438
460
  }
439
- insertMany(e, t) {
440
- return this.aborts.track(() => this.parent.getInternalExecuteInsertMany()(e, t, this.txn, this.events, this.attr));
461
+ insertMany(e, t, n) {
462
+ return this.aborts.track(() => this.parent.getInternalExecuteInsertMany()(e, t, this.txn, this.events, this.attr, n));
441
463
  }
442
464
  patchJson(e, t, n, r, i) {
443
465
  return this.aborts.track(() => this.parent.getInternalExecutePatchJson()(e, t, n, r, this.txn, this.events, this.attr, i));
@@ -476,5 +498,4 @@ var G = U({ scope: "voltro:sqlite" }), K = async (t) => {
476
498
  this.committed || (this.committed = !0, v(this.events, (e) => this.parent.emitChange(e)), this.events.length = 0);
477
499
  }
478
500
  };
479
- //#endregion
480
- export { Z as SqliteStore, K as makeSqliteStore };
501
+ export { Q as SqliteStore, q as makeSqliteStore };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/sql-sqlite",
3
- "version": "0.86.0",
3
+ "version": "0.88.0",
4
4
  "description": "SQLite dialect adapter for Voltro's cross-dialect DataStore (single-process; in-process change events).",
5
5
  "keywords": [
6
6
  "voltro",
@@ -33,12 +33,12 @@
33
33
  "node": ">=24.0.0"
34
34
  },
35
35
  "dependencies": {
36
- "@effect/sql-sqlite-node": "4.0.1",
37
- "@voltro/database": "0.86.0",
38
- "@voltro/logger": "0.86.0"
36
+ "@effect/sql-sqlite-node": "4.1.0",
37
+ "@voltro/database": "0.88.0",
38
+ "@voltro/logger": "0.88.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "effect": "4.0.1"
41
+ "effect": "4.1.0"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public"