@voltro/sql-sqlite 0.43.1 → 0.43.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.
package/CHANGELOG.md CHANGED
@@ -39,6 +39,37 @@ _Changes staged for the next release accumulate here (rolled up from
39
39
 
40
40
  ---
41
41
 
42
+ ## [0.43.2] — 2026-08-18
43
+
44
+ ### Fixed
45
+
46
+ - **@voltro/sql-mysql, @voltro/database, @voltro/cli** — The mysql-family binlog reader no longer keeps a table excluded after the very migration that fixed it.
47
+
48
+ A UNIQUE on an unbounded text column is a MariaDB hash long-unique, whose hidden `DB_ROW_HASH_n` column the reader can never account for — so the table is held out of binlog capture and the exclusion is reported. `voltro dev` builds its store BEFORE it migrates (kv, cross-replica broadcast and the analytics mirror all need one), so on a boot whose own auto-migration bounds the column, that finding was drawn from a schema that stopped existing about a second later. The exclusion then outlived its cause for the life of the process, and the message — correct when written, and typically the only error line in the boot log — went on describing the pre-migration database.
49
+
50
+ Three changes:
51
+
52
+ - `DataStore.refreshChangeCaptureExclusions()` (optional; implemented by the mysql-family store) re-runs the probe and re-points the LIVE reader, in both directions — schema work that CREATES the condition now excludes the table immediately instead of after three failed writes. `voltro dev` calls it once, after all its schema work. `voltro serve` needs no equivalent: it builds its store after every schema step and never applies DDL itself. - The definitive message now states its own durability — that it is the schema as read at reader attach, and that applying the remedy does not by itself lift the exclusion. - On a boot that will re-check, the finding is reported as a provisional note rather than as a verdict, so a boot that fixes the condition leaves no error line about it. The note escalates to the full verdict on its own if the re-check never runs. - Two reader fixes the re-check depended on: applying a new exclusion set now WAITS for a reconnect already in flight (it is what applies the set, so resolving before it landed meant the caller's next write hit the old filter), and the reconnect loop no longer keeps resuming from an offset it has just jumped away from — that turned one purged offset into a reconnect every watchdog interval, forever, delivering nothing.
53
+ - **@voltro/data-transfer, @voltro/database, @voltro/sql-mysql, @voltro/sql-postgres, @voltro/sql-sqlite, @voltro/sql-mssql, @voltro/cli** — `voltro data import --mode replace` no longer leaves a target in neither state, and now works against schemas that have foreign keys.
54
+
55
+ The delete step ran table by table and stopped at the first refusal, so a run that could not finish left dozens of tables emptied and nothing loaded — and a second attempt destroyed more than the first, because it got further before hitting the same wall. The wall itself was not exotic: MySQL, MariaDB and SQL Server check a foreign key as each ROW is deleted, so a table that references ITSELF cannot be emptied by any ordering of the tables. `createdBy → actors` on the `actors` table is exactly that shape, and it is what an audit mixin on an actor table produces.
56
+
57
+ - `DataStore.emptyTables()` (per dialect) empties the whole set as one unit, in one transaction, with referential integrity suspended for the duration — `FOREIGN_KEY_CHECKS` on the mysql family, a multi-table `TRUNCATE` on postgres, `defer_foreign_keys` on sqlite, per-table `NOCHECK`/`WITH CHECK CHECK` on mssql. All-or-nothing on every engine, including under `--atomic`, where it runs on the transaction the import already holds. - A **pre-flight refusal**: if a table OUTSIDE the bundle holds rows referencing one inside it, the import refuses before deleting anything and names the tables, the columns and the row counts. Those rows cannot be restored from the bundle, so forcing it is not an option. An EMPTY outside table blocks nothing. - Table-level failures carry the driver's own reason and code, the way row-level failures already did. `truncate <table> failed: Failed to execute statement` fits every plausible cause equally; the classification that produced `foreign key <name>: … [ER_NO_REFERENCED_ROW_2/1452]` one level down now applies one level up. The word "truncate" is gone from the message too — the step issues DELETE, and naming a statement it does not run sends whoever reads it to reproduce the wrong thing. - A typed refusal reaching the `--target api` transport keeps its text: the admin import endpoint answers `409` with the reason instead of flattening it to `import failed`, on the one transport where the operator has no other way to see it.
58
+
59
+ The bulk empty emits no change events, where the per-table loop emitted one per row. An import through `--target api` now asks every live subscription to re-read once it lands — the coarse refresh the framework already uses after a broadcast gap — so neither the missing deletes nor a table the bundle carries EMPTY leaves a subscriber holding rows that are gone. Wired where the route is mounted, which is the one place both boot paths share.
60
+
61
+ On postgres the emptying is a `DELETE` per table, not a `TRUNCATE`, and the difference is not performance: postgres refuses `TRUNCATE` on a table with ANY incoming foreign key, rows or not, while the mysql family refuses a DELETE only when rows actually reference the doomed ones. A `TRUNCATE` version made an EMPTY table outside the bundle block a replace on postgres and not on mariadb — one import, refused on one engine and accepted on the other, over a table holding nothing.
62
+
63
+ `--target api` also no longer times out on a full bundle. Both api-target calls went through `fetch`, whose undici default gives up after 300 s — a bound on the caller's database size, on a call whose response arrives only when the import does. They wait as long as the instance needs now, stream the body instead of buffering the whole bundle, and take `--timeout <seconds>` when a deadline is wanted. If one is hit, the message says the instance is probably still importing — and gives different advice for `replace` than for the idempotent modes, since re-running the first while it is mid-flight would empty the target under it.
64
+
65
+ Two more, found by measuring rather than by reading:
66
+
67
+ - **`--atomic` on postgres could not import a bundle that needed the deferred-FK repair at all.** A failed statement aborts the transaction there, and that repair depends on a row whose parent has not loaded yet failing, being held, and being retried — so the first such row poisoned every write after it. Every tolerated write now runs inside a savepoint. Per-row savepoints measured 2.40x the time of none on 5 000 rows, so they are amortised: one savepoint per batch of 200, and a batch that fails rolls back whole and replays row by row. The mysql family and sqlite leave a transaction usable after a failed statement and pay nothing for any of this. - **The replace pre-flight asked the caller's snapshot.** Over `--target api` that is the app's DECLARED schema, which cannot show a table the app stopped declaring but the database still has — and rows in a table nobody declares are exactly the rows nobody is watching. `DataStore.incomingForeignKeys()` reads the live catalog per dialect; the snapshot remains the fallback for stores without one.
68
+
69
+ A bundle bigger than one chunk is now uploaded as a series of short requests, so a proxy body cap or an ingress read timeout has nothing large to choke on, and the switch is automatic — the packer's stream is buffered one chunk ahead, so a small bundle is sent exactly as before and nobody has to know in advance which table is the big one. The import still runs ONCE, at the end, over the whole bundle. Resume is byte-exact (`packBundle` is deterministic over a directory, which this package now asserts), guarded by a bundle key so a different bundle under the same upload id is refused rather than spliced into the partial one, and by a contiguity check so a mis-ordered append cannot produce an archive that only fails later during decode. `--chunk-size <mb>` overrides the 16 MiB default.
70
+
71
+ ---
72
+
42
73
  ## [0.43.1] — 2026-08-18
43
74
 
44
75
  ### Fixed
package/dist/index.d.ts CHANGED
@@ -179,6 +179,30 @@ export declare class SqliteStore implements DataStore {
179
179
  * defect, preserving crash semantics). Without this the Turso MVCC
180
180
  * retry — the whole point of `BEGIN CONCURRENT` — would never fire.
181
181
  */
182
+ /**
183
+ * Empty `tables` as one unit — see `DataStore.emptyTables`.
184
+ *
185
+ * SQLite ships the exact switch for this: `defer_foreign_keys` holds every
186
+ * foreign-key check until COMMIT, and unlike `PRAGMA foreign_keys` it is
187
+ * settable INSIDE a transaction (that one is a silent no-op there, which is
188
+ * the trap to avoid). So the whole set empties in any order and integrity is
189
+ * verified once, at the end — which is what makes a self-referencing table
190
+ * possible to clear at all.
191
+ *
192
+ * The pragma resets itself at COMMIT, so there is nothing to restore; the
193
+ * explicit reset below covers the ROLLBACK path, where it does not.
194
+ */
195
+ emptyTables(tables: ReadonlyArray<string>): Promise<void>;
196
+ /** See `DataStore.incomingForeignKeys`. SQLite has no catalog VIEW of foreign
197
+ * keys — `PRAGMA foreign_key_list(t)` answers per table — so this walks the
198
+ * table list once. That is fine at the one call site (a pre-flight, once per
199
+ * import) and is why it is not a general-purpose helper. */
200
+ incomingForeignKeys(tables: ReadonlyArray<string>): Promise<ReadonlyArray<{
201
+ from: string;
202
+ column: string;
203
+ to: string;
204
+ }>>;
205
+ /* Excluded from this release type: emptyTablesOn */
182
206
  transactional<T>(work: (tx: DataStore) => Promise<T>): Promise<T>;
183
207
  /**
184
208
  * The DIALECT half of the shared transaction bracket
package/dist/index.js CHANGED
@@ -3,12 +3,12 @@ import { Config as t, Context as n, Effect as r, Layer as i, ManagedRuntime as a
3
3
  import { EventEmitter as o } from "node:events";
4
4
  import { createLogger as s } from "@voltro/logger";
5
5
  import { SqlClient as c, TransactionConnection as l } from "@effect/sql/SqlClient";
6
- import { EagerCardinalityError as u, attachEagerLoads as d, attributionFields as f, bulkInsertLimitsFor as p, chunkRowsForInsert as m, compileEagerJson as h, compilePredicate as g, compileRawFragment as _, compileSelect as v, decodeRowsFromSchema as y, externalChangeEvent as b, hasEagerLoads as x, isTableReactive as S, makeEagerFallbackReporter as C, observeDbOp as w, qualifyTable as T, raiseChangeListenerCeiling as E, recordsTable as D, requireTable as O, runStoreTransaction as k, runWriteRecorders as A, stampGeneratedId as j, stampGeneratedIds as M, withCapturedAttribution as N } from "@voltro/database";
6
+ import { EagerCardinalityError as u, attachEagerLoads as d, attributionFields as f, bulkInsertLimitsFor as p, chunkRowsForInsert as m, compileEagerJson as h, compilePredicate as g, compileRawFragment as _, compileSelect as v, decodeRowsFromSchema as y, externalChangeEvent as b, hasEagerLoads as x, isTableReactive as S, makeEagerFallbackReporter as C, observeDbOp as w, qualifyTable as T, quoteIdent as E, raiseChangeListenerCeiling as D, recordsTable as O, requireTable as k, runStoreTransaction as A, runWriteRecorders as j, stampGeneratedId as M, stampGeneratedIds as N, withCapturedAttribution as P } from "@voltro/database";
7
7
  //#region src/sqlLayer.ts
8
- var P = (r) => e.layerConfig({
8
+ var F = (r) => e.layerConfig({
9
9
  filename: t.succeed(r.filename),
10
10
  ...r.readonly === void 0 ? {} : { readonly: t.succeed(r.readonly) }
11
- }).pipe(i.tap((t) => n.get(t, e.SqliteClient)`PRAGMA foreign_keys = ON`)), F = (e) => {
11
+ }).pipe(i.tap((t) => n.get(t, e.SqliteClient)`PRAGMA foreign_keys = ON`)), I = (e) => {
12
12
  if (e.url) {
13
13
  if (e.url === ":memory:") return { filename: ":memory:" };
14
14
  if (e.url.startsWith("file:")) return { filename: e.url.slice(5) };
@@ -16,12 +16,12 @@ var P = (r) => e.layerConfig({
16
16
  }
17
17
  if (e.database) return { filename: e.database };
18
18
  throw Error("@voltro/sql-sqlite: no filename supplied. Set DB_URL=file:./db.sqlite or DB_DATABASE=path/to/db.sqlite.");
19
- }, I = (e) => P(F(e)), L = /* @__PURE__ */ new Set([
19
+ }, L = (e) => F(I(e)), R = /* @__PURE__ */ new Set([
20
20
  "SQLITE_BUSY",
21
21
  "SQLITE_LOCKED",
22
22
  "5",
23
23
  "6"
24
- ]), R = (e) => {
24
+ ]), z = (e) => {
25
25
  let t = e;
26
26
  for (let e = 0; e < 5 && typeof t == "object" && t; e++) {
27
27
  let e = t.code;
@@ -29,18 +29,18 @@ var P = (r) => e.layerConfig({
29
29
  if (typeof e == "number") return String(e);
30
30
  t = t.cause;
31
31
  }
32
- }, z = (e) => {
33
- let t = R(e);
34
- return t !== void 0 && L.has(t);
35
- }, B = (e) => z(e) ? "retry" : "noRetry", V = s({ scope: "voltro:sqlite" }), H = async (e) => {
32
+ }, B = (e) => {
33
+ let t = z(e);
34
+ return t !== void 0 && R.has(t);
35
+ }, V = (e) => B(e) ? "retry" : "noRetry", H = s({ scope: "voltro:sqlite" }), U = async (e) => {
36
36
  let t = e.tracerLayer ? i.mergeAll(e.sqlLayer, e.tracerLayer) : e.sqlLayer, n = a.make(t);
37
- return new G(await n.runPromise(c), n, null, void 0, e.isRetryable ?? z, e.systemName ?? "sqlite", e.wrapTransaction);
38
- }, U = (e) => e, W = (e) => {
37
+ return new K(await n.runPromise(c), n, null, void 0, e.isRetryable ?? B, e.systemName ?? "sqlite", e.wrapTransaction);
38
+ }, W = (e) => e, G = (e) => {
39
39
  if (typeof e != "object" || !e) return e;
40
40
  let t = {};
41
41
  for (let [n, r] of Object.entries(e)) t[n] = r instanceof Date ? r.toISOString() : typeof r == "boolean" ? +!!r : r;
42
42
  return t;
43
- }, G = class e {
43
+ }, K = class e {
44
44
  sql;
45
45
  runtime;
46
46
  namespace;
@@ -50,8 +50,8 @@ var P = (r) => e.layerConfig({
50
50
  emitter;
51
51
  inflightTxns = 0;
52
52
  reportEagerFallback;
53
- constructor(e, t, n = null, r, i = z, a = "sqlite", s = U) {
54
- this.sql = e, this.runtime = t, this.namespace = n, this.isRetryable = i, this.systemName = a, this.wrapTransaction = s, this.emitter = r ?? new o(), E(this.emitter), this.reportEagerFallback = C(V);
53
+ constructor(e, t, n = null, r, i = B, a = "sqlite", s = W) {
54
+ this.sql = e, this.runtime = t, this.namespace = n, this.isRetryable = i, this.systemName = a, this.wrapTransaction = s, this.emitter = r ?? new o(), D(this.emitter), this.reportEagerFallback = C(H);
55
55
  }
56
56
  withNamespace(t) {
57
57
  return t === this.namespace ? this : new e(this.sql, this.runtime, t, this.emitter, this.isRetryable, this.systemName, this.wrapTransaction);
@@ -68,8 +68,8 @@ var P = (r) => e.layerConfig({
68
68
  return y(o, e.table, "sqlite");
69
69
  }
70
70
  async executeInsert(e, t, n, i, a) {
71
- t = j(e, t);
72
- let o = this.sql, s = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(W(t))} RETURNING *`, c = n ? r.provideService(s, l, n) : s, u = (await this.runtime.runPromise(c))[0];
71
+ t = M(e, t);
72
+ let o = this.sql, s = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(G(t))} RETURNING *`, c = n ? r.provideService(s, l, n) : s, u = (await this.runtime.runPromise(c))[0];
73
73
  if (!u) throw Error(`SqliteStore.insert: no row returned for table '${e}'`);
74
74
  return await this.routeEvent({
75
75
  table: e,
@@ -79,7 +79,7 @@ var P = (r) => e.layerConfig({
79
79
  }, i, n, a), u;
80
80
  }
81
81
  async executeUpdate(e, t, n, i, a, o) {
82
- let s = this.sql, c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(W(n))} WHERE ${s("id")} = ${t} RETURNING *`, u = i ? r.provideService(c, l, i) : c, d = (await this.runtime.runPromise(u))[0];
82
+ let s = this.sql, c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(G(n))} WHERE ${s("id")} = ${t} RETURNING *`, u = i ? r.provideService(c, l, i) : c, d = (await this.runtime.runPromise(u))[0];
83
83
  return d ? (await this.routeEvent({
84
84
  table: e,
85
85
  op: "update",
@@ -88,8 +88,8 @@ var P = (r) => e.layerConfig({
88
88
  }, a, i, o), d) : null;
89
89
  }
90
90
  async executeInsertMany(e, t, n, i, a) {
91
- if (t = M(e, t), t.length === 0) return [];
92
- let o = this.sql, s = t.map((e) => W(e)), c = m(s, p("sqlite")), u = (t) => o`INSERT INTO ${o(this.nsT(e))} ${o.insert(t)} RETURNING *`, d;
91
+ if (t = N(e, t), t.length === 0) return [];
92
+ let o = this.sql, s = t.map((e) => G(e)), c = m(s, p("sqlite")), u = (t) => o`INSERT INTO ${o(this.nsT(e))} ${o.insert(t)} RETURNING *`, d;
93
93
  if (c.length === 1) {
94
94
  let e = u(c[0]), t = n ? r.provideService(e, l, n) : e;
95
95
  d = await this.runtime.runPromise(t);
@@ -125,7 +125,7 @@ var P = (r) => e.layerConfig({
125
125
  }, i, n, a), !0) : !1;
126
126
  }
127
127
  async appendInTxn(e, t, n) {
128
- let i = this.sql, a = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(W(t))}`;
128
+ let i = this.sql, a = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(G(t))}`;
129
129
  await this.runtime.runPromise(n ? r.provideService(a, l, n) : a);
130
130
  }
131
131
  async maxInTxn(e, t, n, i) {
@@ -136,7 +136,7 @@ var P = (r) => e.layerConfig({
136
136
  e = {
137
137
  ...f(r),
138
138
  ...e
139
- }, D(e.table) && await A({
139
+ }, O(e.table) && await j({
140
140
  append: (e, t) => this.appendInTxn(e, t, n),
141
141
  maxOf: (e, t, r) => this.maxInTxn(e, t, r, n)
142
142
  }, {
@@ -153,7 +153,7 @@ var P = (r) => e.layerConfig({
153
153
  let r = await this.findByConflict(e, t, n.conflictColumns, i);
154
154
  return r ? await this.executeUpdate(e, r.id, n.update(r), i, a) ?? r : this.executeInsert(e, t, i, a);
155
155
  }
156
- let s = this.sql, c = n.conflictColumns.map((e) => s`${s(e)}`), u = Object.keys(t).filter((e) => t[e] !== void 0), d = n.update === void 0 ? u.filter((e) => e !== "id" && !n.conflictColumns.includes(e)) : n.update, f = d.length > 0 ? s.csv(d.map((e) => s`${s(e)} = excluded.${s(e)}`)) : s`${s(n.conflictColumns[0])} = excluded.${s(n.conflictColumns[0])}`, p = s`INSERT INTO ${s(this.nsT(e))} ${s.insert(W(t))} ON CONFLICT (${s.csv(c)}) DO UPDATE SET ${f} RETURNING *`, m = i ? r.provideService(p, l, i) : p, h = (await this.runtime.runPromise(m))[0];
156
+ let s = this.sql, c = n.conflictColumns.map((e) => s`${s(e)}`), u = Object.keys(t).filter((e) => t[e] !== void 0), d = n.update === void 0 ? u.filter((e) => e !== "id" && !n.conflictColumns.includes(e)) : n.update, f = d.length > 0 ? s.csv(d.map((e) => s`${s(e)} = excluded.${s(e)}`)) : s`${s(n.conflictColumns[0])} = excluded.${s(n.conflictColumns[0])}`, p = s`INSERT INTO ${s(this.nsT(e))} ${s.insert(G(t))} ON CONFLICT (${s.csv(c)}) DO UPDATE SET ${f} RETURNING *`, m = i ? r.provideService(p, l, i) : p, h = (await this.runtime.runPromise(m))[0];
157
157
  if (!h) throw Error(`SqliteStore.upsert: no row returned for table '${e}'`);
158
158
  let g = t.id !== void 0 && t.id === h.id ? "insert" : "update";
159
159
  return await this.routeEvent({
@@ -164,8 +164,8 @@ var P = (r) => e.layerConfig({
164
164
  }, a, i, o), h;
165
165
  }
166
166
  async executeInsertIgnore(e, t, n, i, a, o) {
167
- t = j(e, t);
168
- let s = this.sql, c = n.conflictColumns.map((e) => s`${s(e)}`), u = s`INSERT INTO ${s(this.nsT(e))} ${s.insert(W(t))} ON CONFLICT (${s.csv(c)}) DO NOTHING RETURNING *`, d = i ? r.provideService(u, l, i) : u, f = (await this.runtime.runPromise(d))[0];
167
+ t = M(e, t);
168
+ let s = this.sql, c = n.conflictColumns.map((e) => s`${s(e)}`), u = s`INSERT INTO ${s(this.nsT(e))} ${s.insert(G(t))} ON CONFLICT (${s.csv(c)}) DO NOTHING RETURNING *`, d = i ? r.provideService(u, l, i) : u, f = (await this.runtime.runPromise(d))[0];
169
169
  if (f) return await this.routeEvent({
170
170
  table: e,
171
171
  op: "insert",
@@ -209,13 +209,13 @@ var P = (r) => e.layerConfig({
209
209
  reason: "not-compilable"
210
210
  });
211
211
  let i = await this.executeQuery(e, t);
212
- return d(i, e.eager, e.sourceTable ?? O(e.table), (e) => this.executeQuery(e, t));
212
+ return d(i, e.eager, e.sourceTable ?? k(e.table), (e) => this.executeQuery(e, t));
213
213
  }
214
214
  getInternalRunWithEager() {
215
215
  return (e, t) => this.runWithEager(e, t);
216
216
  }
217
217
  localWrite(e, t) {
218
- return w(this.systemName, e, () => N(t));
218
+ return w(this.systemName, e, () => P(t));
219
219
  }
220
220
  insert(e, t) {
221
221
  return this.localWrite("insert", (n) => this.executeInsert(e, t, null, null, n));
@@ -233,7 +233,7 @@ var P = (r) => e.layerConfig({
233
233
  return this.localWrite("delete", (n) => this.executeDelete(e, t, null, null, n));
234
234
  }
235
235
  async updateMany(e, t, n) {
236
- let r = this.sql, i = g(n.where, r, this.namespace), a = r`UPDATE ${r(this.nsT(e))} SET ${r.update(W(t))} WHERE ${i} RETURNING *`, o = await w(this.systemName, "update", () => this.runtime.runPromise(a));
236
+ let r = this.sql, i = g(n.where, r, this.namespace), a = r`UPDATE ${r(this.nsT(e))} SET ${r.update(G(t))} WHERE ${i} RETURNING *`, o = await w(this.systemName, "update", () => this.runtime.runPromise(a));
237
237
  for (let t of o) await this.routeEvent({
238
238
  table: e,
239
239
  op: "update",
@@ -285,13 +285,35 @@ var P = (r) => e.layerConfig({
285
285
  getInternalExecuteInsertIgnore() {
286
286
  return this.executeInsertIgnore.bind(this);
287
287
  }
288
+ async emptyTables(e) {
289
+ await this.emptyTablesOn(e, null);
290
+ }
291
+ async incomingForeignKeys(e) {
292
+ if (e.length === 0) return [];
293
+ 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 = [];
294
+ for (let e of r) {
295
+ if (n.has(e.name)) continue;
296
+ let r = await this.runtime.runPromise(t`${t.unsafe(`PRAGMA foreign_key_list(${E(e.name, "sqlite")})`)}`).catch(() => []);
297
+ for (let t of r) n.has(t.table) && i.push({
298
+ from: e.name,
299
+ column: t.from,
300
+ to: t.table
301
+ });
302
+ }
303
+ return i;
304
+ }
305
+ async emptyTablesOn(e, t) {
306
+ if (e.length === 0) return;
307
+ let n = this.sql, i = (e) => this.nsT(e), a = r.acquireUseRelease(n.unsafe("PRAGMA defer_foreign_keys = ON"), () => r.forEach(e, (e) => n`DELETE FROM ${n(i(e))}`, { discard: !0 }), () => r.orDie(r.ignore(n.unsafe("PRAGMA defer_foreign_keys = OFF")))), o = t === null ? n.withTransaction(a) : r.provideService(a, l, t);
308
+ await this.runtime.runPromise(o);
309
+ }
288
310
  async transactional(e) {
289
311
  this.inflightTxns++;
290
312
  try {
291
- return await k({
313
+ return await A({
292
314
  ...this.txnSpec("SqliteStore.transactional"),
293
315
  work: e,
294
- makeView: (e, t) => new K(this, e, t)
316
+ makeView: (e, t) => new q(this, e, t)
295
317
  });
296
318
  } finally {
297
319
  this.inflightTxns--;
@@ -329,7 +351,7 @@ var P = (r) => e.layerConfig({
329
351
  if (this.inflightTxns > 0) {
330
352
  let t = Date.now() + e;
331
353
  for (; this.inflightTxns > 0 && Date.now() < t;) await new Promise((e) => setTimeout(e, 25));
332
- this.inflightTxns > 0 && V.warn("close: grace period expired with in-flight transactions", {
354
+ this.inflightTxns > 0 && H.warn("close: grace period expired with in-flight transactions", {
333
355
  gracePeriodMs: e,
334
356
  inflight: this.inflightTxns
335
357
  });
@@ -339,7 +361,7 @@ var P = (r) => e.layerConfig({
339
361
  async ping() {
340
362
  await this.runtime.runPromise(this.sql`SELECT 1`);
341
363
  }
342
- }, K = class {
364
+ }, q = class {
343
365
  parent;
344
366
  txn;
345
367
  attr;
@@ -351,6 +373,9 @@ var P = (r) => e.layerConfig({
351
373
  query(e) {
352
374
  return this.parent.getInternalRunWithEager()(e, this.txn);
353
375
  }
376
+ emptyTables(e) {
377
+ return this.parent.emptyTablesOn(e, this.txn);
378
+ }
354
379
  insert(e, t) {
355
380
  return this.parent.getInternalExecuteInsert()(e, t, this.txn, this.events, this.attr);
356
381
  }
@@ -412,12 +437,12 @@ var P = (r) => e.layerConfig({
412
437
  this.events.length = 0;
413
438
  }
414
439
  }
415
- }, q = {
440
+ }, J = {
416
441
  id: "sqlite",
417
- makeSqlLayer: (e) => I(e),
418
- makeStore: (e) => H(e),
442
+ makeSqlLayer: (e) => L(e),
443
+ makeStore: (e) => U(e),
419
444
  compileContains: (e, t, n) => n`${e} LIKE ${`%${t.replace(/[\\%_]/g, (e) => `\\${e}`)}%`} ESCAPE '\\'`,
420
- retryFilter: B
445
+ retryFilter: V
421
446
  };
422
447
  //#endregion
423
- export { e as SqliteClient, F as connectionFromConfig, P as makeSqliteSqlLayer, I as makeSqliteSqlLayerFromConfig, H as makeSqliteStore, q as sqliteDialect, B as sqliteRetryFilter };
448
+ export { e as SqliteClient, I as connectionFromConfig, F as makeSqliteSqlLayer, L as makeSqliteSqlLayerFromConfig, U as makeSqliteStore, J as sqliteDialect, V as sqliteRetryFilter };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/sql-sqlite",
3
- "version": "0.43.1",
3
+ "version": "0.43.2",
4
4
  "description": "SQLite dialect adapter for Voltro's cross-dialect DataStore (single-process; in-process change events).",
5
5
  "keywords": [
6
6
  "voltro",
@@ -35,8 +35,8 @@
35
35
  "dependencies": {
36
36
  "@effect/sql": "^0.52.0",
37
37
  "@effect/sql-sqlite-node": "^0.53.0",
38
- "@voltro/database": "0.43.1",
39
- "@voltro/logger": "0.43.1"
38
+ "@voltro/database": "0.43.2",
39
+ "@voltro/logger": "0.43.2"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "effect": "^3.22.0"