@voltro/sql-sqlite 0.84.0 → 0.86.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 ADDED
@@ -0,0 +1,480 @@
1
+ import { isRetryableSqliteFailure as e } from "./retry.js";
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) => {
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 : {
12
+ ...e,
13
+ predicate: J(e.predicate)
14
+ }, X = (e, t) => {
15
+ let n = y(e, t, [
16
+ "json",
17
+ "array",
18
+ "decimal"
19
+ ]), r = {};
20
+ for (let [e, t] of Object.entries(n)) r[e] = t instanceof Date ? t.toISOString() : typeof t == "boolean" ? +!!t : t;
21
+ return r;
22
+ }, Z = class n {
23
+ sql;
24
+ runtime;
25
+ namespace;
26
+ isRetryable;
27
+ systemName;
28
+ wrapTransaction;
29
+ fullText;
30
+ emitter;
31
+ inflightTxns = 0;
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);
35
+ }
36
+ withNamespace(e) {
37
+ return e === this.namespace ? this : new n(this.sql, this.runtime, e, this.emitter, this.isRetryable, this.systemName, this.wrapTransaction, this.fullText);
38
+ }
39
+ withFullTextMode(e) {
40
+ return this.fullText === "like" && e.fullTextSearch !== void 0 ? {
41
+ ...e,
42
+ fullTextSearch: {
43
+ ...e.fullTextSearch,
44
+ fallback: "like"
45
+ }
46
+ } : e;
47
+ }
48
+ nsT(e) {
49
+ return O(this.namespace, e);
50
+ }
51
+ async attachNamespace(e, t) {
52
+ let n = this.sql, r = t ?? `${e}.db`;
53
+ await this.runtime.runPromise(n`ATTACH DATABASE ${r} AS ${n(e)}`);
54
+ }
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));
57
+ return _(o, e.table, "sqlite", e);
58
+ }
59
+ keyWhere(e, t) {
60
+ let n = this.sql, r = X(Object.fromEntries(N(t)), e);
61
+ return n.and(Object.entries(r).map(([e, t]) => n`${n(e)} = ${t}`));
62
+ }
63
+ async executeInsert(e, n, r, i, a) {
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];
66
+ if (!u) throw Error(`SqliteStore.insert: no row returned for table '${e}'`);
67
+ return await this.routeEvent({
68
+ table: e,
69
+ op: "insert",
70
+ old: null,
71
+ new: u
72
+ }, i, r, a), u;
73
+ }
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];
76
+ return d ? (await this.routeEvent({
77
+ table: e,
78
+ op: "update",
79
+ old: null,
80
+ new: d
81
+ }, a, i, o), d) : null;
82
+ }
83
+ async executeInsertMany(e, n, r, i, a) {
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);
89
+ } else if (r) {
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({
96
+ table: e,
97
+ op: "insert",
98
+ old: null,
99
+ new: t
100
+ }, i, r, a);
101
+ return p;
102
+ }
103
+ 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
+ return v ? (await this.routeEvent({
106
+ table: e,
107
+ op: "update",
108
+ old: null,
109
+ new: v
110
+ }, o, a, s), v) : null;
111
+ }
112
+ async executeDelete(e, n, r, i, a) {
113
+ let o = this.sql, s = o`DELETE FROM ${o(this.nsT(e))} WHERE ${this.keyWhere(e, n)} 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];
114
+ return u ? (await this.routeEvent({
115
+ table: e,
116
+ op: "delete",
117
+ old: u,
118
+ new: null
119
+ }, i, r, a), !0) : !1;
120
+ }
121
+ async appendInTxn(e, n, r) {
122
+ let i = this.sql, a = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(X(n, e))}`;
123
+ await this.runtime.runPromise(r ? t.provideService(a, this.sql.transactionService, r) : a);
124
+ }
125
+ async maxInTxn(e, n, r, i) {
126
+ let a = this.sql, o = Object.entries(r).map(([e, t]) => a`${a(e)} = ${t}`), s = a`SELECT MAX(${a(n)}) AS ${a("m")} FROM ${a(this.nsT(e))} WHERE ${a.and(o)}`, c = (await this.runtime.runPromise(i ? t.provideService(s, this.sql.transactionService, i) : s))[0]?.m;
127
+ return c == null ? null : Number(c);
128
+ }
129
+ async routeEvent(e, t, n = null, r) {
130
+ e = {
131
+ ...s(r),
132
+ ...e
133
+ }, j(e.table) && await I({
134
+ append: (e, t) => this.appendInTxn(e, t, n),
135
+ maxOf: (e, t, r) => this.maxInTxn(e, t, r, n)
136
+ }, {
137
+ table: e.table,
138
+ op: e.op,
139
+ next: e.new,
140
+ prev: e.old,
141
+ traceId: e.traceId,
142
+ subjectId: e.subjectId
143
+ }), S(e.table) && (t === null ? this.emitter.emit("change", e) : t.push(e));
144
+ }
145
+ async executeUpsert(e, n, r, i, a, o) {
146
+ let s = B(r);
147
+ if (n = L(e, n), typeof r.update == "function") {
148
+ let t = await this.findByConflict(e, n, r.conflictColumns, i);
149
+ if (t) {
150
+ let s = Object.fromEntries(r.conflictColumns.map((e) => [e, t[e]]));
151
+ return await this.executeUpdate(e, s, z(n, t, r), i, a, o) ?? t;
152
+ }
153
+ return this.executeInsert(e, n, i, a, o);
154
+ }
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
+ if (!b) throw Error(`SqliteStore.upsert: no row returned for table '${e}'`);
157
+ let x = n.id !== void 0 && n.id === b.id ? "insert" : "update";
158
+ return await this.routeEvent({
159
+ table: e,
160
+ op: x,
161
+ old: null,
162
+ new: b
163
+ }, a, i, o), b;
164
+ }
165
+ async executeInsertIgnore(e, n, r, i, a, o) {
166
+ 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
+ if (f) return await this.routeEvent({
169
+ table: e,
170
+ op: "insert",
171
+ old: null,
172
+ new: f
173
+ }, a, i, o), {
174
+ row: f,
175
+ outcome: "inserted"
176
+ };
177
+ let p = await this.findByConflict(e, n, r.conflictColumns, i);
178
+ if (!p) throw Error(`SqliteStore.insertIgnore: conflict fired but no existing row found in '${e}'`);
179
+ return {
180
+ row: p,
181
+ outcome: "ignored"
182
+ };
183
+ }
184
+ async findByConflict(e, n, r, i) {
185
+ 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
+ return _(u, e, "sqlite")[0];
188
+ }
189
+ query(e) {
190
+ return this.runWithEager(e, null);
191
+ }
192
+ raw(e, t) {
193
+ return this.rawOn(e, null);
194
+ }
195
+ rawOn(e, n) {
196
+ let r = m(e, this.sql), i = n ? t.provideService(r, this.sql.transactionService, n) : r;
197
+ return E(this.systemName, "raw", () => this.runtime.runPromise(i));
198
+ }
199
+ async runWithEager(e, n) {
200
+ if (!x(e)) return this.executeQuery(e, n);
201
+ let r = this.namespace === null ? d(e, this.sql, "sqlite") : null;
202
+ if (r !== null) try {
203
+ let e = n ? t.provideService(r.fragment, this.sql.transactionService, n) : r.fragment, i = await E(this.systemName, "select", () => this.runtime.runPromise(e));
204
+ return r.decode(i);
205
+ } catch (t) {
206
+ if (t instanceof a) throw t;
207
+ this.reportEagerFallback({
208
+ dialect: this.systemName,
209
+ table: e.table,
210
+ reason: "execute-failed",
211
+ error: t
212
+ });
213
+ }
214
+ else this.reportEagerFallback({
215
+ dialect: this.systemName,
216
+ table: e.table,
217
+ reason: "not-compilable"
218
+ });
219
+ let i = await this.executeQuery(e, n);
220
+ return o(i, e.eager, e.sourceTable ?? M(e.table), (e) => this.executeQuery(e, n));
221
+ }
222
+ getInternalRunWithEager() {
223
+ return (e, t) => this.runWithEager(e, t);
224
+ }
225
+ localWrite(e, t, n) {
226
+ let r = (e) => j(t) ? this.writeWithRecorders(n, e) : n(e, null, null);
227
+ return E(this.systemName, e, () => V(r));
228
+ }
229
+ async writeWithRecorders(e, n) {
230
+ let r = [], a = this.sql, o = await this.runtime.runPromise(a.withTransaction(t.flatMap(t.serviceOption(this.sql.transactionService), (a) => i.isNone(a) ? t.fail(/* @__PURE__ */ Error("SqliteStore.write: TransactionConnection missing.")) : t.tryPromise({
231
+ try: () => e(n, a.value, r),
232
+ catch: (e) => e
233
+ }))));
234
+ return v(r, (e) => this.emitChange(e)), o;
235
+ }
236
+ insert(e, t) {
237
+ return this.localWrite("insert", e, (n, r, i) => this.executeInsert(e, t, r, i, n));
238
+ }
239
+ insertMany(e, t) {
240
+ return this.localWrite("insert", e, (n, r, i) => this.executeInsertMany(e, t, r, i, n));
241
+ }
242
+ patchJson(e, t, n, r, i) {
243
+ return this.localWrite("update", e, (a, o, s) => this.executePatchJson(e, t, n, r, o, s, a, i));
244
+ }
245
+ update(e, t, n) {
246
+ return this.localWrite("update", e, (r, i, a) => this.executeUpdate(e, t, n, i, a, r));
247
+ }
248
+ delete(e, t) {
249
+ return this.localWrite("delete", e, (n, r, i) => this.executeDelete(e, t, r, i, n));
250
+ }
251
+ updateMany(e, t, n) {
252
+ return this.executeUpdateMany(e, t, n, null, null);
253
+ }
254
+ deleteMany(e, t) {
255
+ return this.executeDeleteMany(e, t, null, null);
256
+ }
257
+ 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({
260
+ table: e,
261
+ op: "update",
262
+ old: null,
263
+ new: t
264
+ }, a, i, o);
265
+ return d.length;
266
+ }
267
+ 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({
270
+ table: e,
271
+ op: "delete",
272
+ old: t,
273
+ new: null
274
+ }, i, r, a);
275
+ return u.length;
276
+ }
277
+ upsert(e, t, n) {
278
+ return this.localWrite("upsert", e, (r, i, a) => this.executeUpsert(e, t, n, i, a, r));
279
+ }
280
+ insertIgnore(e, t, n) {
281
+ return this.insertIgnoreWithOutcome(e, t, n).then((e) => e.row);
282
+ }
283
+ insertIgnoreWithOutcome(e, t, n) {
284
+ return this.localWrite("upsert", e, (r, i, a) => this.executeInsertIgnore(e, t, n, i, a, r));
285
+ }
286
+ emitChange(e) {
287
+ this.emitter.emit("change", e);
288
+ }
289
+ getInternalExecuteQuery() {
290
+ return this.executeQuery.bind(this);
291
+ }
292
+ getInternalExecuteInsert() {
293
+ return this.executeInsert.bind(this);
294
+ }
295
+ getInternalExecuteInsertMany() {
296
+ return this.executeInsertMany.bind(this);
297
+ }
298
+ getInternalExecutePatchJson() {
299
+ return this.executePatchJson.bind(this);
300
+ }
301
+ getInternalExecuteUpdate() {
302
+ return this.executeUpdate.bind(this);
303
+ }
304
+ getInternalExecuteUpdateMany() {
305
+ return this.executeUpdateMany.bind(this);
306
+ }
307
+ getInternalExecuteDeleteMany() {
308
+ return this.executeDeleteMany.bind(this);
309
+ }
310
+ getInternalExecuteDelete() {
311
+ return this.executeDelete.bind(this);
312
+ }
313
+ getInternalExecuteUpsert() {
314
+ return this.executeUpsert.bind(this);
315
+ }
316
+ getInternalExecuteInsertIgnore() {
317
+ return this.executeInsertIgnore.bind(this);
318
+ }
319
+ async emptyTables(e) {
320
+ await this.emptyTablesOn(e, null);
321
+ }
322
+ async incomingForeignKeys(e) {
323
+ if (e.length === 0) return [];
324
+ let t = this.sql, n = new Set(e), r = await this.runtime.runPromise(t`SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%'`), i = [];
325
+ for (let e of r) {
326
+ if (n.has(e.name)) continue;
327
+ let r = await this.runtime.runPromise(t`${t.unsafe(`PRAGMA foreign_key_list(${k(e.name, "sqlite")})`)}`).catch(() => []);
328
+ for (let t of r) n.has(t.table) && i.push({
329
+ from: e.name,
330
+ column: t.from,
331
+ to: t.table
332
+ });
333
+ }
334
+ return i;
335
+ }
336
+ async emptyTablesOn(e, n) {
337
+ if (e.length === 0) return;
338
+ let r = this.sql, i = (e) => this.nsT(e), a = t.acquireUseRelease(r.unsafe("PRAGMA defer_foreign_keys = ON"), () => t.forEach(e, (e) => r`DELETE FROM ${r(i(e))}`, { discard: !0 }), () => t.orDie(t.ignore(r.unsafe("PRAGMA defer_foreign_keys = OFF")))), o = n === null ? r.withTransaction(a) : t.provideService(a, this.sql.transactionService, n);
339
+ await this.runtime.runPromise(o);
340
+ }
341
+ transactionEndingFailure(e) {
342
+ return this.isRetryable(e);
343
+ }
344
+ async transactional(e) {
345
+ this.inflightTxns++;
346
+ try {
347
+ return await F({
348
+ ...this.txnSpec("SqliteStore.transactional"),
349
+ work: e,
350
+ makeView: (e, t) => new Q(this, e, t)
351
+ });
352
+ } finally {
353
+ this.inflightTxns--;
354
+ }
355
+ }
356
+ get transactionService() {
357
+ return this.sql.transactionService;
358
+ }
359
+ txnSpec(e) {
360
+ return {
361
+ label: e,
362
+ dialect: this.systemName === "turso" ? "turso" : "sqlite",
363
+ withTransaction: (e) => this.sql.withTransaction(e),
364
+ transactionService: this.sql.transactionService,
365
+ runPromiseExit: (e) => this.runtime.runPromiseExit(e),
366
+ isRetryable: this.isRetryable,
367
+ wrapProgram: (e) => this.wrapTransaction(e),
368
+ span: {
369
+ name: "store.transactional",
370
+ attributes: {
371
+ "db.system": this.systemName,
372
+ "db.operation": "transaction"
373
+ }
374
+ }
375
+ };
376
+ }
377
+ onChange(e) {
378
+ return this.emitter.on("change", e), () => {
379
+ this.emitter.off("change", e);
380
+ };
381
+ }
382
+ injectExternalChange(e) {
383
+ S(e.table) && this.emitter.emit("change", b(e));
384
+ }
385
+ run(e) {
386
+ return this.runtime.runPromise(e);
387
+ }
388
+ async close(e = 5e3) {
389
+ if (this.inflightTxns > 0) {
390
+ let t = Date.now() + e;
391
+ 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", {
393
+ gracePeriodMs: e,
394
+ inflight: this.inflightTxns
395
+ });
396
+ }
397
+ await this.runtime.dispose();
398
+ }
399
+ async ping() {
400
+ await this.runtime.runPromise(this.sql`SELECT 1`);
401
+ }
402
+ }, Q = class {
403
+ parent;
404
+ txn;
405
+ attr;
406
+ events = [];
407
+ aborts = T((e) => this.parent.transactionEndingFailure(e));
408
+ committed = !1;
409
+ constructor(e, t, n = void 0) {
410
+ this.parent = e, this.txn = t, this.attr = n;
411
+ }
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);
419
+ }
420
+ savepointCounter = 0;
421
+ run(e) {
422
+ return this.aborts.track(() => this.parent.run(D(e, this.parent.transactionService, this.txn)));
423
+ }
424
+ abortedBy() {
425
+ return this.aborts.abortedBy();
426
+ }
427
+ raw(e, t) {
428
+ return this.aborts.track(() => this.parent.rawOn(e, this.txn));
429
+ }
430
+ query(e) {
431
+ return this.aborts.track(() => this.parent.getInternalRunWithEager()(e, this.txn));
432
+ }
433
+ emptyTables(e) {
434
+ return this.aborts.track(() => this.parent.emptyTablesOn(e, this.txn));
435
+ }
436
+ insert(e, t) {
437
+ return this.aborts.track(() => this.parent.getInternalExecuteInsert()(e, t, this.txn, this.events, this.attr));
438
+ }
439
+ insertMany(e, t) {
440
+ return this.aborts.track(() => this.parent.getInternalExecuteInsertMany()(e, t, this.txn, this.events, this.attr));
441
+ }
442
+ patchJson(e, t, n, r, i) {
443
+ return this.aborts.track(() => this.parent.getInternalExecutePatchJson()(e, t, n, r, this.txn, this.events, this.attr, i));
444
+ }
445
+ update(e, t, n) {
446
+ return this.aborts.track(() => this.parent.getInternalExecuteUpdate()(e, t, n, this.txn, this.events, this.attr));
447
+ }
448
+ delete(e, t) {
449
+ return this.aborts.track(() => this.parent.getInternalExecuteDelete()(e, t, this.txn, this.events, this.attr));
450
+ }
451
+ updateMany(e, t, n) {
452
+ return this.aborts.track(() => this.parent.getInternalExecuteUpdateMany()(e, t, n, this.txn, this.events, this.attr));
453
+ }
454
+ deleteMany(e, t) {
455
+ return this.aborts.track(() => this.parent.getInternalExecuteDeleteMany()(e, t, this.txn, this.events, this.attr));
456
+ }
457
+ upsert(e, t, n) {
458
+ return this.aborts.track(() => this.parent.getInternalExecuteUpsert()(e, t, n, this.txn, this.events, this.attr));
459
+ }
460
+ insertIgnore(e, t, n) {
461
+ return this.insertIgnoreWithOutcome(e, t, n).then((e) => e.row);
462
+ }
463
+ insertIgnoreWithOutcome(e, t, n) {
464
+ return this.aborts.track(() => this.parent.getInternalExecuteInsertIgnore()(e, t, n, this.txn, this.events, this.attr));
465
+ }
466
+ transactional(e) {
467
+ return Promise.reject(/* @__PURE__ */ Error("SqliteStore.transactional: nested transactions are not supported. Mutations should execute a single top-level transaction."));
468
+ }
469
+ onChange(e) {
470
+ throw Error("SqliteTransactionalView.onChange: subscribing from inside a transaction is not supported.");
471
+ }
472
+ injectExternalChange(e) {
473
+ throw Error("SqliteTransactionalView.injectExternalChange: injecting external changes from inside a transaction is not supported.");
474
+ }
475
+ commitEvents() {
476
+ this.committed || (this.committed = !0, v(this.events, (e) => this.parent.emitChange(e)), this.events.length = 0);
477
+ }
478
+ };
479
+ //#endregion
480
+ export { Z as SqliteStore, K as makeSqliteStore };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/sql-sqlite",
3
- "version": "0.84.0",
3
+ "version": "0.86.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,13 +33,12 @@
33
33
  "node": ">=24.0.0"
34
34
  },
35
35
  "dependencies": {
36
- "@effect/sql": "^0.52.1",
37
- "@effect/sql-sqlite-node": "^0.53.0",
38
- "@voltro/database": "0.84.0",
39
- "@voltro/logger": "0.84.0"
36
+ "@effect/sql-sqlite-node": "4.0.1",
37
+ "@voltro/database": "0.86.0",
38
+ "@voltro/logger": "0.86.0"
40
39
  },
41
40
  "peerDependencies": {
42
- "effect": "^3.22.2"
41
+ "effect": "4.0.1"
43
42
  },
44
43
  "publishConfig": {
45
44
  "access": "public"