@voltro/sql-mysql 0.32.0 → 0.34.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/index.js CHANGED
@@ -1,27 +1,60 @@
1
1
  import { MysqlClient as e } from "@effect/sql-mysql2";
2
2
  import { Config as t, Effect as n, Layer as r, ManagedRuntime as i, Option as a, Redacted as o, Schedule as s } from "effect";
3
- import { EventEmitter as c } from "node:events";
4
- import { createLogger as l } from "@voltro/logger";
5
- import { SqlClient as u, TransactionConnection as d } from "@effect/sql/SqlClient";
6
- import { CDC_OFFSETS_TABLE as f, EagerCardinalityError as p, _voltroCdcOffsetsTable as m, attachEagerLoads as h, attributionFields as g, attributionKey as _, beginLocalWrite as v, compileEagerJson as y, compilePredicate as b, compileRawFragment as x, compileSelect as S, currentWriteAttribution as C, decodeRowsFromSchema as w, encodeRowForSchema as T, endLocalWrite as E, hasEagerLoads as D, isTableReactive as O, qualifyTable as ee, raiseChangeListenerCeiling as te, recordsTable as ne, registerPendingAttribution as re, requireTable as k, resolveEchoAttribution as A, runWithWriteAttribution as ie, runWriteRecorders as ae, settleTransactionExit as oe, stampGeneratedId as j, stampGeneratedIds as se, withCapturedAttribution as M } from "@voltro/database";
3
+ import { CDC_OFFSETS_TABLE as c, DEFAULT_ACQUIRE_TIMEOUT_MS as l, EagerCardinalityError as u, _voltroCdcOffsetsTable as d, attachEagerLoads as f, attributionFields as p, attributionKey as m, beginLocalWrite as h, bulkInsertLimitsFor as g, chunkRowsForInsert as _, compileEagerJson as v, compilePredicate as y, compileRawFragment as b, compileSelect as x, decodeRowsFromSchema as S, encodeRowForSchema as C, endLocalWrite as w, hasEagerLoads as T, isTableReactive as E, makeEagerFallbackReporter as D, observeDbOp as O, qualifyTable as ee, raiseChangeListenerCeiling as k, recordsTable as te, registerPendingAttribution as ne, requireTable as re, resolveEchoAttribution as ie, runStoreTransaction as ae, runWriteRecorders as oe, stampGeneratedId as A, stampGeneratedIds as se, withCapturedAttribution as j } from "@voltro/database";
4
+ import { EventEmitter as M } from "node:events";
5
+ import { createLogger as N } from "@voltro/logger";
6
+ import { SqlClient as P, TransactionConnection as F } from "@effect/sql/SqlClient";
7
7
  //#region src/sqlLayer.ts
8
- var N = (n) => e.layerConfig({
8
+ var ce = (e) => e ? { rejectUnauthorized: !1 } : void 0, le = (e) => {
9
+ let t = e.acquireTimeoutMs ?? l;
10
+ return t > 0 ? t : void 0;
11
+ }, I = (e) => {
12
+ let t = e.acquireQueueLimit;
13
+ return t !== void 0 && t > 0 ? t : void 0;
14
+ }, L = (e) => {
15
+ let t = e.ssl === void 0 ? void 0 : ce(e.ssl), n = le(e), r = I(e);
16
+ return {
17
+ ...t === void 0 ? {} : { ssl: t },
18
+ ...n === void 0 ? {} : { connectTimeout: n },
19
+ ...r === void 0 ? {} : { queueLimit: r }
20
+ };
21
+ }, R = (n) => e.layerConfig({
9
22
  host: t.succeed(n.host),
10
23
  port: t.succeed(n.port),
11
24
  username: t.succeed(n.username),
12
25
  password: t.succeed(o.make(n.password)),
13
26
  database: t.succeed(n.database),
27
+ poolConfig: t.succeed(L(n)),
14
28
  ...n.maxConnections === void 0 ? {} : { maxConnections: t.succeed(n.maxConnections) }
15
- }), P = (e) => {
29
+ }), z = (e) => {
30
+ let t = e.get("sslmode");
31
+ if (t !== null) {
32
+ if (t === "require") return !0;
33
+ if (t === "disable") return !1;
34
+ throw Error(`DB_URL '?sslmode=${t}' is not supported by the mysql/mariadb dialect — use 'require' (TLS without certificate verification) or 'disable' (plaintext).`);
35
+ }
36
+ let n = e.get("ssl");
37
+ if (n !== null) {
38
+ if (n === "true" || n === "1") return !0;
39
+ if (n === "false" || n === "0") return !1;
40
+ throw Error(`DB_URL '?ssl=${n}' is not supported by the mysql/mariadb dialect — use 'true'/'1' or 'false'/'0'.`);
41
+ }
42
+ }, B = (e) => {
43
+ let t = {
44
+ ...e.acquireTimeoutMs === void 0 ? {} : { acquireTimeoutMs: e.acquireTimeoutMs },
45
+ ...e.acquireQueueLimit === void 0 ? {} : { acquireQueueLimit: e.acquireQueueLimit }
46
+ };
16
47
  if (e.url) {
17
- let t = new URL(e.url);
48
+ let n = new URL(e.url), r = e.ssl ?? z(n.searchParams);
18
49
  return {
19
- host: t.hostname || "localhost",
20
- port: t.port ? Number(t.port) : 3306,
21
- username: decodeURIComponent(t.username || "app"),
22
- password: decodeURIComponent(t.password || "app"),
23
- database: t.pathname.replace(/^\//, "") || "app",
24
- ...e.maxConnections === void 0 ? {} : { maxConnections: e.maxConnections }
50
+ host: n.hostname || "localhost",
51
+ port: n.port ? Number(n.port) : 3306,
52
+ username: decodeURIComponent(n.username || "app"),
53
+ password: decodeURIComponent(n.password || "app"),
54
+ database: n.pathname.replace(/^\//, "") || "app",
55
+ ...e.maxConnections === void 0 ? {} : { maxConnections: e.maxConnections },
56
+ ...r === void 0 ? {} : { ssl: r },
57
+ ...t
25
58
  };
26
59
  }
27
60
  return {
@@ -30,48 +63,50 @@ var N = (n) => e.layerConfig({
30
63
  username: e.username ?? "app",
31
64
  password: e.password ?? "app",
32
65
  database: e.database ?? "app",
33
- ...e.maxConnections === void 0 ? {} : { maxConnections: e.maxConnections }
66
+ ...e.maxConnections === void 0 ? {} : { maxConnections: e.maxConnections },
67
+ ...e.ssl === void 0 ? {} : { ssl: e.ssl },
68
+ ...t
34
69
  };
35
- }, F = (e) => N(P(e)), I = (e, t) => e === null ? !1 : t === null ? !0 : e.filename === t.filename ? e.position > t.position : e.filename > t.filename, L = (e) => e.msSinceProgress < e.stallThresholdMs ? "healthy" : e.primary !== null && !I(e.primary, e.reader) ? "idle-caught-up" : "reconnect", R = (e) => (e instanceof Error ? e.message : String(e ?? "")).includes("schema changed between binlog event and metadata fetch"), z = (e) => {
70
+ }, V = (e) => R(B(e)), H = (e, t) => e === null ? !1 : t === null ? !0 : e.filename === t.filename ? e.position > t.position : e.filename > t.filename, U = (e) => e.msSinceProgress < e.stallThresholdMs ? "healthy" : e.primary !== null && !H(e.primary, e.reader) ? "idle-caught-up" : "reconnect", W = (e) => (e instanceof Error ? e.message : String(e ?? "")).includes("schema changed between binlog event and metadata fetch"), ue = (e) => {
36
71
  let t = e instanceof Error ? e.message : String(e ?? "");
37
72
  return /Table\s+[^\s.]+\.(\S+)\s+schema changed between binlog event and metadata fetch/.exec(t)?.[1] ?? null;
38
- }, B = "\n SELECT DISTINCT s.TABLE_NAME AS tableName\n FROM information_schema.STATISTICS s\n JOIN information_schema.COLUMNS c\n ON c.TABLE_SCHEMA = s.TABLE_SCHEMA\n AND c.TABLE_NAME = s.TABLE_NAME\n AND c.COLUMN_NAME = s.COLUMN_NAME\n WHERE s.TABLE_SCHEMA = DATABASE()\n AND s.NON_UNIQUE = 0\n AND s.SUB_PART IS NULL\n AND c.DATA_TYPE IN ('text','tinytext','mediumtext','longtext','blob','tinyblob','mediumblob','longblob')\n", V = (e) => `cdc: table '${e}' is EXCLUDED from binlog capture — its row image carries a hidden column the reader cannot account for. Cause: a UNIQUE constraint on an UNBOUNDED text column, which MariaDB backs with a HASH long-unique index; that index adds a hidden DB_ROW_HASH_n column to the row, present in the binlog and absent from information_schema.COLUMNS. Remedy: bound the column — text().maxLength(n) — so the constraint becomes an ordinary B-tree index with no hidden column. ALTER TABLE FORCE does NOT help: the rebuild recreates the index and the hidden column. Until then, cross-instance change events for this table are lost; own-node reactivity is unaffected (writes still emit inline).`, H = 5 * 6e4, U = 3, W = (e, t) => {
39
- let n = [...e.filter((e) => t - e < H), t];
73
+ }, G = "\n SELECT DISTINCT s.TABLE_NAME AS tableName\n FROM information_schema.STATISTICS s\n JOIN information_schema.COLUMNS c\n ON c.TABLE_SCHEMA = s.TABLE_SCHEMA\n AND c.TABLE_NAME = s.TABLE_NAME\n AND c.COLUMN_NAME = s.COLUMN_NAME\n WHERE s.TABLE_SCHEMA = DATABASE()\n AND s.NON_UNIQUE = 0\n AND s.SUB_PART IS NULL\n AND c.DATA_TYPE IN ('text','tinytext','mediumtext','longtext','blob','tinyblob','mediumblob','longblob')\n", K = (e) => `cdc: table '${e}' is EXCLUDED from binlog capture — its row image carries a hidden column the reader cannot account for. Cause: a UNIQUE constraint on an UNBOUNDED text column, which MariaDB backs with a HASH long-unique index; that index adds a hidden DB_ROW_HASH_n column to the row, present in the binlog and absent from information_schema.COLUMNS. Remedy: bound the column — text().maxLength(n) — so the constraint becomes an ordinary B-tree index with no hidden column. ALTER TABLE FORCE does NOT help: the rebuild recreates the index and the hidden column. Until then, cross-instance change events for this table are lost; own-node reactivity is unaffected (writes still emit inline).`, de = 5 * 6e4, fe = 3, pe = (e, t) => {
74
+ let n = [...e.filter((e) => t - e < de), t];
40
75
  return {
41
- verdict: n.length >= U ? "persistent" : "backlog",
76
+ verdict: n.length >= fe ? "persistent" : "backlog",
42
77
  hits: n
43
78
  };
44
- }, G = /* @__PURE__ */ new Set([
79
+ }, me = /* @__PURE__ */ new Set([
45
80
  "writerows",
46
81
  "updaterows",
47
82
  "deleterows"
48
- ]), ce = /\b(alter|rename|drop|create)\s+(table|column)?/i, K = (e) => new Promise((t) => setTimeout(t, e)), q = async (e) => {
49
- let t = l({ scope: `voltro:${e.variant}:cdc` }), n;
83
+ ]), he = /\b(alter|rename|drop|create)\s+(table|column)?/i, q = (e) => new Promise((t) => setTimeout(t, e)), J = async (e) => {
84
+ let t = N({ scope: `voltro:${e.variant}:cdc` }), n;
50
85
  try {
51
86
  n = (await import("@vlasky/zongji")).default;
52
87
  } catch (t) {
53
88
  throw Error(`changeStrategy='cdc' on ${e.variant} requires the '@vlasky/zongji' optional dependency. Install it (it ships as an optionalDependency of @voltro/sql-mysql) to enable binlog CDC.`, { cause: t });
54
89
  }
55
- let r = new Set(e.undecodableTables ?? []), i = e.includeTables ? new Set(e.includeTables.filter((e) => !r.has(e))) : null, a = e.connection.database, o = e.startPosition?.filename ?? null, s = e.startPosition ?? null, c = (t, n) => w([n], t, e.variant)[0], u = null, d = !1, f = 0, p = Date.now(), m = !1, h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(), _ = null, v = e.stallThresholdMs ?? 25e3, y = e.watchdogIntervalMs ?? 15e3, b = () => {
56
- p = Date.now();
57
- }, x = (n) => {
58
- b();
90
+ let r = new Set(e.undecodableTables ?? []), i = e.includeTables ? new Set(e.includeTables.filter((e) => !r.has(e))) : null, a = e.connection.database, o = e.startPosition?.filename ?? null, s = e.startPosition ?? null, c = (t, n) => S([n], t, e.variant)[0], l = null, u = !1, d = 0, f = Date.now(), p = !1, m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Set(), g = null, _ = e.stallThresholdMs ?? 25e3, v = e.watchdogIntervalMs ?? 15e3, y = () => {
91
+ f = Date.now();
92
+ }, b = (n) => {
93
+ y();
59
94
  let r = n.getEventName();
60
95
  if (r === "rotate" && n.binlogName) {
61
96
  o = n.binlogName;
62
97
  return;
63
98
  }
64
- if (r === "query" && n.query && ce.test(n.query)) {
65
- u && (u.tableMap = {});
99
+ if (r === "query" && n.query && he.test(n.query)) {
100
+ l && (l.tableMap = {});
66
101
  return;
67
102
  }
68
103
  if (n.nextPosition && o && (s = {
69
104
  filename: o,
70
105
  position: n.nextPosition
71
- }, e.onPosition?.(s)), !G.has(r)) return;
72
- let l = n.tableMap[n.tableId];
73
- if (!l || l.parentSchema !== a) return;
74
- let d = l.tableName;
106
+ }, e.onPosition?.(s)), !me.has(r)) return;
107
+ let u = n.tableMap[n.tableId];
108
+ if (!u || u.parentSchema !== a) return;
109
+ let d = u.tableName;
75
110
  if (!d.startsWith("_voltro_") && !(i && !i.has(d))) try {
76
111
  if (r === "writerows") for (let t of n.rows) e.onChange({
77
112
  table: d,
@@ -97,7 +132,7 @@ var N = (n) => e.layerConfig({
97
132
  name: r
98
133
  }, n), e.onError?.(n);
99
134
  }
100
- }, S = (t) => {
135
+ }, x = (t) => {
101
136
  let n = {
102
137
  serverId: e.serverId,
103
138
  includeEvents: [
@@ -114,7 +149,7 @@ var N = (n) => e.layerConfig({
114
149
  }, C = (e) => {
115
150
  let t = e;
116
151
  return t?.errno === 1236 || String(t?.code ?? "").includes("ER_MASTER_FATAL_ERROR_READING_BINLOG");
117
- }, T = (r) => new Promise((i, a) => {
152
+ }, w = (r) => new Promise((i, a) => {
118
153
  let o = new n({
119
154
  host: e.connection.host,
120
155
  port: e.connection.port,
@@ -123,10 +158,10 @@ var N = (n) => e.layerConfig({
123
158
  enableKeepAlive: !0,
124
159
  keepAliveInitialDelay: e.keepAliveInitialDelayMs ?? 1e4
125
160
  });
126
- u = o;
161
+ l = o;
127
162
  let s = !1;
128
- o.on("binlog", x), o.on("ready", () => {
129
- b(), !s && (s = !0, f = 0, t.info("cdc: binlog reader attached", {
163
+ o.on("binlog", b), o.on("ready", () => {
164
+ y(), !s && (s = !0, d = 0, t.info("cdc: binlog reader attached", {
130
165
  serverId: e.serverId,
131
166
  from: r ?? "current-end"
132
167
  }), i());
@@ -135,82 +170,82 @@ var N = (n) => e.layerConfig({
135
170
  s = !0, a(e instanceof Error ? e : Error(String(e)));
136
171
  return;
137
172
  }
138
- E("binlog reader error", e);
139
- }), o.start(S(r));
140
- }), E = async (n, i) => {
141
- if (!(d || m)) {
142
- m = !0, t.warn(`cdc: reconnecting — ${n}`, {}, i instanceof Error ? i : void 0), e.onError?.(i);
173
+ T("binlog reader error", e);
174
+ }), o.start(x(r));
175
+ }), T = async (n, i) => {
176
+ if (!(u || p)) {
177
+ p = !0, t.warn(`cdc: reconnecting — ${n}`, {}, i instanceof Error ? i : void 0), e.onError?.(i);
143
178
  try {
144
179
  let n = i;
145
- for (; !d;) {
180
+ for (; !u;) {
146
181
  try {
147
- u?.stop();
182
+ l?.stop();
148
183
  } catch {}
149
- if (f++, await K(Math.min(3e4, 500 * 2 ** Math.min(f, 6))), d) return;
150
- let i = s, a = C(n), c = !a && R(n), l = !1;
184
+ if (d++, await q(Math.min(3e4, 500 * 2 ** Math.min(d, 6))), u) return;
185
+ let i = s, a = C(n), c = !a && W(n), f = !1;
151
186
  if (c) {
152
- let e = z(n), i = e ?? "<unknown>", { verdict: a, hits: o } = W(h.get(i) ?? [], Date.now());
153
- h.set(i, o), l = a === "persistent", l && !g.has(i) && (g.add(i), e !== null && r.add(e), t.error(V(i)));
187
+ let e = ue(n), i = e ?? "<unknown>", { verdict: a, hits: o } = pe(m.get(i) ?? [], Date.now());
188
+ m.set(i, o), f = a === "persistent", f && !h.has(i) && (h.add(i), e !== null && r.add(e), t.error(K(i)));
154
189
  }
155
- (a || c) && (l || t.warn(c ? "cdc: un-replayable backlog event (schema moved past it) — jumping to current end + self-heal" : "cdc: binlog gap (purged/failover) — jumping to current end + self-heal"), i = e.resolveStartPosition ? await e.resolveStartPosition().catch(() => null) : null, o = i?.filename ?? null, l || e.onResync?.());
190
+ (a || c) && (f || t.warn(c ? "cdc: un-replayable backlog event (schema moved past it) — jumping to current end + self-heal" : "cdc: binlog gap (purged/failover) — jumping to current end + self-heal"), i = e.resolveStartPosition ? await e.resolveStartPosition().catch(() => null) : null, o = i?.filename ?? null, f || e.onResync?.());
156
191
  try {
157
- await T(i), f = 0, b();
192
+ await w(i), d = 0, y();
158
193
  return;
159
194
  } catch (e) {
160
195
  n = e;
161
196
  }
162
197
  }
163
198
  } finally {
164
- m = !1;
199
+ p = !1;
165
200
  }
166
201
  }
167
202
  };
168
203
  try {
169
- await T(e.startPosition ?? null);
204
+ await w(e.startPosition ?? null);
170
205
  } catch (n) {
171
206
  if (C(n) && e.startPosition) {
172
207
  t.warn("cdc: persisted offset purged — starting at current end + self-heal");
173
208
  try {
174
- u?.stop();
209
+ l?.stop();
175
210
  } catch {}
176
211
  let n = e.resolveStartPosition ? await e.resolveStartPosition().catch(() => null) : null;
177
- o = n?.filename ?? null, e.onResync?.(), await K(500), await T(n);
212
+ o = n?.filename ?? null, e.onResync?.(), await q(500), await w(n);
178
213
  } else throw n;
179
214
  }
180
- let D = async () => {
181
- if (d || m || Date.now() - p < v) return;
215
+ let E = async () => {
216
+ if (u || p || Date.now() - f < _) return;
182
217
  let n = null;
183
- if (e.resolveStartPosition && (n = await e.resolveStartPosition().catch(() => null)), d || m) return;
184
- let r = L({
185
- msSinceProgress: Date.now() - p,
186
- stallThresholdMs: v,
218
+ if (e.resolveStartPosition && (n = await e.resolveStartPosition().catch(() => null)), u || p) return;
219
+ let r = U({
220
+ msSinceProgress: Date.now() - f,
221
+ stallThresholdMs: _,
187
222
  primary: n,
188
223
  reader: s
189
224
  });
190
225
  if (r !== "reconnect") {
191
- r === "idle-caught-up" && b();
226
+ r === "idle-caught-up" && y();
192
227
  return;
193
228
  }
194
229
  t.warn("cdc: watchdog detected a stalled reader — forcing reconnect", {
195
230
  reader: s,
196
231
  primary: n,
197
- stalledForMs: Date.now() - p
198
- }), E("watchdog: stream stalled (no events while primary advanced)", /* @__PURE__ */ Error("cdc watchdog stall"));
232
+ stalledForMs: Date.now() - f
233
+ }), T("watchdog: stream stalled (no events while primary advanced)", /* @__PURE__ */ Error("cdc watchdog stall"));
199
234
  };
200
- return _ = setInterval(() => {
201
- D();
202
- }, y), _.unref && _.unref(), {
235
+ return g = setInterval(() => {
236
+ E();
237
+ }, v), g.unref && g.unref(), {
203
238
  stop: async () => {
204
- d = !0, _ &&= (clearInterval(_), null);
239
+ u = !0, g &&= (clearInterval(g), null);
205
240
  try {
206
- u?.stop();
241
+ l?.stop();
207
242
  } catch (e) {
208
243
  t.warn("cdc: error stopping binlog reader", {}, e);
209
244
  }
210
245
  },
211
246
  currentPosition: () => s
212
247
  };
213
- }, le = /* @__PURE__ */ new Set(["1213", "1205"]), ue = (e) => {
248
+ }, ge = /* @__PURE__ */ new Set(["1213", "1205"]), _e = (e) => {
214
249
  let t = e;
215
250
  for (let e = 0; e < 5 && typeof t == "object" && t; e++) {
216
251
  let e = t.errno;
@@ -219,31 +254,31 @@ var N = (n) => e.layerConfig({
219
254
  if (typeof n == "string") return n;
220
255
  t = t.cause;
221
256
  }
222
- }, J = (e) => {
223
- let t = ue(e);
224
- return t !== void 0 && le.has(t);
225
- }, Y = (e) => J(e) ? "retry" : "noRetry", X = (e) => {
257
+ }, Y = (e) => {
258
+ let t = _e(e);
259
+ return t !== void 0 && ge.has(t);
260
+ }, X = (e) => Y(e) ? "retry" : "noRetry", Z = (e) => {
226
261
  if (e == null) return "null";
227
262
  let t = typeof e;
228
263
  if (t === "bigint") return `${e}n`;
229
264
  if (t !== "object") return JSON.stringify(e);
230
265
  if (e instanceof Date) return `"${e.toISOString()}"`;
231
- if (Array.isArray(e)) return `[${e.map(X).join(",")}]`;
266
+ if (Array.isArray(e)) return `[${e.map(Z).join(",")}]`;
232
267
  let n = e;
233
- return `{${Object.keys(n).sort().map((e) => `${JSON.stringify(e)}:${X(n[e])}`).join(",")}}`;
234
- }, Z = (e) => {
235
- let t = X(e), n = 2166136261;
268
+ return `{${Object.keys(n).sort().map((e) => `${JSON.stringify(e)}:${Z(n[e])}`).join(",")}}`;
269
+ }, ve = (e) => {
270
+ let t = Z(e), n = 2166136261;
236
271
  for (let e = 0; e < t.length; e++) n ^= t.charCodeAt(e), n = Math.imul(n, 16777619);
237
272
  return (n >>> 0).toString(36);
238
- }, de = (e, t) => {
273
+ }, ye = (e, t) => {
239
274
  let n = setTimeout(e, t);
240
275
  typeof n.unref == "function" && n.unref();
241
- }, fe = class {
276
+ }, be = class {
242
277
  variant;
243
278
  ttlMs;
244
279
  schedule;
245
280
  seen = /* @__PURE__ */ new Map();
246
- constructor(e, t = 6e4, n = de) {
281
+ constructor(e, t = 6e4, n = ye) {
247
282
  this.variant = e, this.ttlMs = t, this.schedule = n;
248
283
  }
249
284
  key(e) {
@@ -253,11 +288,11 @@ var N = (n) => e.layerConfig({
253
288
  if (n == null) return null;
254
289
  let r = t;
255
290
  try {
256
- r = w([t], e.table, this.variant)[0] ?? t;
291
+ r = S([t], e.table, this.variant)[0] ?? t;
257
292
  } catch {
258
293
  r = t;
259
294
  }
260
- return `${e.table} ${e.op} ${String(n)} ${Z(r)}`;
295
+ return `${e.table} ${e.op} ${String(n)} ${ve(r)}`;
261
296
  }
262
297
  admit(e) {
263
298
  let t = this.key(e);
@@ -272,19 +307,16 @@ var N = (n) => e.layerConfig({
272
307
  get pending() {
273
308
  return this.seen.size;
274
309
  }
275
- }, pe = /* @__PURE__ */ new Set([
310
+ }, xe = /* @__PURE__ */ new Set([
276
311
  1022,
277
312
  1062,
278
313
  1586
279
314
  ]), Q = async (e) => {
280
- let t = e.variant ?? "mysql", n = l({ scope: `voltro:${t}` }), a = e.changeStrategy ?? "inline", o = a;
315
+ let t = e.variant ?? "mysql", n = N({ scope: `voltro:${t}` }), a = e.changeStrategy ?? "inline", o = a;
281
316
  a === "cdc" && !e.cdcConfig && (n.warn("changeStrategy='cdc' requires cdcConfig (serverId + connection); falling back to 'inline'."), o = "inline");
282
- let s = e.tracerLayer ? r.mergeAll(e.sqlLayer, e.tracerLayer) : e.sqlLayer, c = i.make(s), d = new he(await c.runPromise(u), c, t, o);
283
- return o === "cdc" && e.cdcConfig && await d.startCdcConsumer(e.cdcConfig), d;
284
- }, me = () => {
285
- let e = C();
286
- return e === void 0 ? (e) => e() : (t) => ie(e, t);
287
- }, he = class e {
317
+ let s = e.tracerLayer ? r.mergeAll(e.sqlLayer, e.tracerLayer) : e.sqlLayer, c = i.make(s), l = new Se(await c.runPromise(P), c, t, o);
318
+ return o === "cdc" && e.cdcConfig && await l.startCdcConsumer(e.cdcConfig), l;
319
+ }, Se = class e {
288
320
  sql;
289
321
  runtime;
290
322
  variant;
@@ -299,8 +331,9 @@ var N = (n) => e.layerConfig({
299
331
  cdcReplicaId = "";
300
332
  cdcStreamName = "default";
301
333
  cdcGate;
334
+ reportEagerFallback;
302
335
  constructor(e, t, n, r = "inline", i = null, a, o) {
303
- this.sql = e, this.runtime = t, this.variant = n, this.changeStrategy = r, this.namespace = i, this.log = l({ scope: `voltro:${n}` }), this.emitter = a ?? new c(), te(this.emitter), this.cdcGate = o ?? new fe(n);
336
+ this.sql = e, this.runtime = t, this.variant = n, this.changeStrategy = r, this.namespace = i, this.log = N({ scope: `voltro:${n}` }), this.reportEagerFallback = D(this.log), this.emitter = a ?? new M(), k(this.emitter), this.cdcGate = o ?? new be(n);
304
337
  }
305
338
  withNamespace(t) {
306
339
  return t === this.namespace ? this : new e(this.sql, this.runtime, this.variant, this.changeStrategy, t, this.emitter, this.cdcGate);
@@ -318,8 +351,8 @@ var N = (n) => e.layerConfig({
318
351
  };
319
352
  }
320
353
  async executeQuery(e, t, r) {
321
- let i = S(e, this.sql, this.namespace), a = t ? n.provideService(i, d, t) : i;
322
- return w(await this.runtime.runPromise(a), e.table, this.variant);
354
+ let i = x(e, this.sql, this.namespace), a = t ? n.provideService(i, F, t) : i;
355
+ return S(await O(this.variant, "select", () => this.runtime.runPromise(a)), e.table, this.variant);
323
356
  }
324
357
  get supportsInsertReturning() {
325
358
  return this.variant === "mariadb";
@@ -331,10 +364,10 @@ var N = (n) => e.layerConfig({
331
364
  return !1;
332
365
  }
333
366
  async executeInsert(e, t, r, i, a) {
334
- t = j(e, t);
367
+ t = A(e, t);
335
368
  let o = this.sql;
336
369
  if (this.supportsInsertReturning) {
337
- let s = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(T(t, e))} RETURNING *`, c = r ? n.provideService(s, d, r) : s, l = (await this.runtime.runPromise(c))[0];
370
+ let s = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(C(t, e))} RETURNING *`, c = r ? n.provideService(s, F, r) : s, l = (await this.runtime.runPromise(c))[0];
338
371
  if (!l) throw Error(`MysqlStore.insert: no row returned for table '${e}'`);
339
372
  return await this.routeEvent({
340
373
  table: e,
@@ -343,7 +376,7 @@ var N = (n) => e.layerConfig({
343
376
  new: l
344
377
  }, i, r, a), l;
345
378
  }
346
- let s = T(t, e), c = t.id;
379
+ let s = C(t, e), c = t.id;
347
380
  if (c === void 0) {
348
381
  let t = await this.insertRecoverAutoId(e, s, r);
349
382
  return await this.routeEvent({
@@ -353,31 +386,31 @@ var N = (n) => e.layerConfig({
353
386
  new: t
354
387
  }, i, r, a), t;
355
388
  }
356
- let l = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(s)}`, u = r ? n.provideService(l, d, r) : l;
389
+ let l = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(s)}`, u = r ? n.provideService(l, F, r) : l;
357
390
  await this.runtime.runPromise(u);
358
- let f = o`SELECT * FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${c}`, p = r ? n.provideService(f, d, r) : f, m = (await this.runtime.runPromise(p))[0];
359
- if (!m) throw Error(`MysqlStore.insert: row not found post-insert in '${e}'`);
391
+ let d = o`SELECT * FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${c}`, f = r ? n.provideService(d, F, r) : d, p = (await this.runtime.runPromise(f))[0];
392
+ if (!p) throw Error(`MysqlStore.insert: row not found post-insert in '${e}'`);
360
393
  return await this.routeEvent({
361
394
  table: e,
362
395
  op: "insert",
363
396
  old: null,
364
- new: m
365
- }, i, r, a), m;
397
+ new: p
398
+ }, i, r, a), p;
366
399
  }
367
400
  async insertRecoverAutoId(e, t, r) {
368
401
  let i = this.sql;
369
402
  return this.runPinned(r, (r) => n.gen(this, function* () {
370
403
  let a = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(t)}`;
371
- yield* n.provideService(a, d, r);
372
- let o = (yield* n.provideService(i`SELECT LAST_INSERT_ID() AS ${i("lastId")}`, d, r))[0]?.lastId;
373
- return o === void 0 || Number(o) === 0 ? yield* n.fail(/* @__PURE__ */ Error(`MysqlStore.insert: LAST_INSERT_ID() returned no id for '${e}' — is the primary key AUTO_INCREMENT?`)) : (yield* n.provideService(i`SELECT * FROM ${i(this.nsT(e))} WHERE ${i("id")} = ${o}`, d, r))[0] || (yield* n.fail(/* @__PURE__ */ Error(`MysqlStore.insert: row not found post-insert in '${e}'`)));
404
+ yield* n.provideService(a, F, r);
405
+ let o = (yield* n.provideService(i`SELECT LAST_INSERT_ID() AS ${i("lastId")}`, F, r))[0]?.lastId;
406
+ return o === void 0 || Number(o) === 0 ? yield* n.fail(/* @__PURE__ */ Error(`MysqlStore.insert: LAST_INSERT_ID() returned no id for '${e}' — is the primary key AUTO_INCREMENT?`)) : (yield* n.provideService(i`SELECT * FROM ${i(this.nsT(e))} WHERE ${i("id")} = ${o}`, F, r))[0] || (yield* n.fail(/* @__PURE__ */ Error(`MysqlStore.insert: row not found post-insert in '${e}'`)));
374
407
  }), "insert");
375
408
  }
376
409
  async runPinned(e, t, r) {
377
410
  if (e) return this.runtime.runPromise(t(e));
378
411
  this.inflightTxns++;
379
412
  try {
380
- let e = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(d), (e) => a.isNone(e) ? n.fail(/* @__PURE__ */ Error("MysqlStore.insert: TransactionConnection missing.")) : t(e.value)))), i = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(J)), o = e.pipe(n.retry(i), n.withSpan("store.insert", { attributes: {
413
+ let e = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(F), (e) => a.isNone(e) ? n.fail(/* @__PURE__ */ Error("MysqlStore.insert: TransactionConnection missing.")) : t(e.value)))), i = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(Y)), o = e.pipe(n.retry(i), n.withSpan("store.insert", { attributes: {
381
414
  "db.system": this.variant,
382
415
  "db.operation": r
383
416
  } }));
@@ -388,16 +421,24 @@ var N = (n) => e.layerConfig({
388
421
  }
389
422
  async executeInsertMany(e, t, r, i, a) {
390
423
  if (t = se(e, t), t.length === 0) return [];
391
- let o = this.sql, s = t.map((t) => T(t, e));
424
+ let o = this.sql, s = _(t.map((t) => C(t, e)), g(this.variant));
392
425
  if (this.supportsInsertReturning) {
393
- let t = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(s)} RETURNING *`, c = r ? n.provideService(t, d, r) : t, l = await this.runtime.runPromise(c);
394
- for (let t of l) await this.routeEvent({
426
+ let t = (t) => o`INSERT INTO ${o(this.nsT(e))} ${o.insert(t)} RETURNING *`, c;
427
+ if (s.length === 1) {
428
+ let e = t(s[0]), i = r ? n.provideService(e, F, r) : e;
429
+ c = await this.runtime.runPromise(i);
430
+ } else if (r) {
431
+ let e = [];
432
+ for (let i of s) e.push(...await this.runtime.runPromise(n.provideService(t(i), F, r)));
433
+ c = e;
434
+ } else c = await this.runtime.runPromise(o.withTransaction(n.map(n.forEach(s, t, { concurrency: 1 }), (e) => e.flat())));
435
+ for (let t of c) await this.routeEvent({
395
436
  table: e,
396
437
  op: "insert",
397
438
  old: null,
398
439
  new: t
399
440
  }, i, r, a);
400
- return l;
441
+ return c;
401
442
  }
402
443
  let c = t.map((e) => e.id);
403
444
  if (c.every((e) => e === void 0)) {
@@ -411,43 +452,59 @@ var N = (n) => e.layerConfig({
411
452
  return t;
412
453
  }
413
454
  if (c.some((e) => e === void 0)) throw Error("MysqlStore.insertMany: rows mix client-supplied and missing 'id's — supply an id for every row or none (AUTO_INCREMENT recovery).");
414
- let l = o`INSERT INTO ${o(this.nsT(e))} ${o.insert(s)}`, u = r ? n.provideService(l, d, r) : l;
415
- await this.runtime.runPromise(u);
416
- let f = o`SELECT * FROM ${o(this.nsT(e))} WHERE ${o("id")} IN ${o.in(c)}`, p = r ? n.provideService(f, d, r) : f, m = await this.runtime.runPromise(p), h = new Map(m.map((e) => [e.id, e])), g = c.map((e) => h.get(e)).filter((e) => e !== void 0);
417
- for (let t of g) await this.routeEvent({
455
+ let l = (t) => o`INSERT INTO ${o(this.nsT(e))} ${o.insert(t)}`;
456
+ if (s.length === 1) {
457
+ let e = r ? n.provideService(l(s[0]), F, r) : l(s[0]);
458
+ await this.runtime.runPromise(e);
459
+ } else if (r) for (let e of s) await this.runtime.runPromise(n.provideService(l(e), F, r));
460
+ else await this.runtime.runPromise(o.withTransaction(n.forEach(s, l, {
461
+ concurrency: 1,
462
+ discard: !0
463
+ })));
464
+ let u = _(c.map((e) => ({ id: e })), g(this.variant)), d = [];
465
+ for (let t of u) {
466
+ let i = o`SELECT * FROM ${o(this.nsT(e))} WHERE ${o("id")} IN ${o.in(t.map((e) => e.id))}`, a = r ? n.provideService(i, F, r) : i;
467
+ d.push(...await this.runtime.runPromise(a));
468
+ }
469
+ let f = new Map(d.map((e) => [e.id, e])), p = c.map((e) => f.get(e)).filter((e) => e !== void 0);
470
+ for (let t of p) await this.routeEvent({
418
471
  table: e,
419
472
  op: "insert",
420
473
  old: null,
421
474
  new: t
422
475
  }, i, r, a);
423
- return g;
476
+ return p;
424
477
  }
425
478
  async insertManyRecoverAutoIds(e, t, r) {
426
- let i = this.sql, a = t.length;
479
+ let i = this.sql;
427
480
  return this.runPinned(r, (r) => n.gen(this, function* () {
428
- let o = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(t)}`;
429
- yield* n.provideService(o, d, r);
430
- let s = (yield* n.provideService(i`SELECT LAST_INSERT_ID() AS ${i("firstId")}`, d, r))[0]?.firstId;
431
- if (s === void 0 || Number(s) === 0) return yield* n.fail(/* @__PURE__ */ Error(`MysqlStore.insertMany: LAST_INSERT_ID() returned no id for '${e}' — is the primary key AUTO_INCREMENT?`));
432
- let c = Number(s);
433
- return yield* n.provideService(i`SELECT * FROM ${i(this.nsT(e))} WHERE ${i("id")} BETWEEN ${c} AND ${c + a - 1} ORDER BY ${i("id")} ASC`, d, r);
481
+ let a = [];
482
+ for (let o of t) {
483
+ let t = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(o)}`;
484
+ yield* n.provideService(t, F, r);
485
+ let s = (yield* n.provideService(i`SELECT LAST_INSERT_ID() AS ${i("firstId")}`, F, r))[0]?.firstId;
486
+ if (s === void 0 || Number(s) === 0) return yield* n.fail(/* @__PURE__ */ Error(`MysqlStore.insertMany: LAST_INSERT_ID() returned no id for '${e}' is the primary key AUTO_INCREMENT?`));
487
+ let c = Number(s), l = yield* n.provideService(i`SELECT * FROM ${i(this.nsT(e))} WHERE ${i("id")} BETWEEN ${c} AND ${c + o.length - 1} ORDER BY ${i("id")} ASC`, F, r);
488
+ a.push(...l);
489
+ }
490
+ return a;
434
491
  }), "insert");
435
492
  }
436
493
  async executePatchJson(e, t, r, i, a, o, s) {
437
- let c = this.sql, l = r.split("."), u = l[0], f = l.slice(1), p = JSON.stringify(i ?? null), m = f.length === 0 ? "$" : `$.${f.join(".")}`, h = c`UPDATE ${c(this.nsT(e))} SET ${c(u)} = JSON_SET(COALESCE(${c(u)}, '{}'), ${m}, CAST(${p} AS JSON)) WHERE ${c("id")} = ${t}`, g = a ? n.provideService(h, d, a) : h, _ = await this.runtime.runPromise(g);
438
- if (_ && typeof _.affectedRows == "number" && _.affectedRows === 0) return null;
439
- let v = c`SELECT * FROM ${c(this.nsT(e))} WHERE ${c("id")} = ${t}`, y = a ? n.provideService(v, d, a) : v, b = (await this.runtime.runPromise(y))[0];
440
- return b ? (await this.routeEvent({
494
+ let c = this.sql, l = r.split("."), u = l[0], d = l.slice(1), f = JSON.stringify(i ?? null), p = d.length === 0 ? "$" : `$.${d.join(".")}`, m = c`UPDATE ${c(this.nsT(e))} SET ${c(u)} = JSON_SET(COALESCE(${c(u)}, '{}'), ${p}, CAST(${f} AS JSON)) WHERE ${c("id")} = ${t}`, h = a ? n.provideService(m, F, a) : m, g = await this.runtime.runPromise(h);
495
+ if (g && typeof g.affectedRows == "number" && g.affectedRows === 0) return null;
496
+ let _ = c`SELECT * FROM ${c(this.nsT(e))} WHERE ${c("id")} = ${t}`, v = a ? n.provideService(_, F, a) : _, y = (await this.runtime.runPromise(v))[0];
497
+ return y ? (await this.routeEvent({
441
498
  table: e,
442
499
  op: "update",
443
500
  old: null,
444
- new: b
445
- }, o, a, s), b) : null;
501
+ new: y
502
+ }, o, a, s), y) : null;
446
503
  }
447
504
  async executeUpdate(e, t, r, i, a, o) {
448
505
  let s = this.sql;
449
506
  if (this.supportsUpdateReturning) {
450
- let c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(T(r, e))} WHERE ${s("id")} = ${t} RETURNING *`, l = i ? n.provideService(c, d, i) : c, u = (await this.runtime.runPromise(l))[0];
507
+ let c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(C(r, e))} WHERE ${s("id")} = ${t} RETURNING *`, l = i ? n.provideService(c, F, i) : c, u = (await this.runtime.runPromise(l))[0];
451
508
  return u ? (await this.routeEvent({
452
509
  table: e,
453
510
  op: "update",
@@ -455,20 +512,20 @@ var N = (n) => e.layerConfig({
455
512
  new: u
456
513
  }, a, i, o), u) : null;
457
514
  }
458
- let c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(T(r, e))} WHERE ${s("id")} = ${t}`, l = i ? n.provideService(c, d, i) : c, u = await this.runtime.runPromise(l);
515
+ let c = s`UPDATE ${s(this.nsT(e))} SET ${s.update(C(r, e))} WHERE ${s("id")} = ${t}`, l = i ? n.provideService(c, F, i) : c, u = await this.runtime.runPromise(l);
459
516
  if (u && typeof u.affectedRows == "number" && u.affectedRows === 0) return null;
460
- let f = s`SELECT * FROM ${s(this.nsT(e))} WHERE ${s("id")} = ${t}`, p = i ? n.provideService(f, d, i) : f, m = (await this.runtime.runPromise(p))[0];
461
- return m ? (await this.routeEvent({
517
+ let d = s`SELECT * FROM ${s(this.nsT(e))} WHERE ${s("id")} = ${t}`, f = i ? n.provideService(d, F, i) : d, p = (await this.runtime.runPromise(f))[0];
518
+ return p ? (await this.routeEvent({
462
519
  table: e,
463
520
  op: "update",
464
521
  old: null,
465
- new: m
466
- }, a, i, o), m) : null;
522
+ new: p
523
+ }, a, i, o), p) : null;
467
524
  }
468
525
  async executeDelete(e, t, r, i, a) {
469
526
  let o = this.sql;
470
527
  if (this.supportsDeleteReturning) {
471
- let s = o`DELETE FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t} RETURNING *`, c = r ? n.provideService(s, d, r) : s, l = (await this.runtime.runPromise(c))[0];
528
+ let s = o`DELETE FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t} RETURNING *`, c = r ? n.provideService(s, F, r) : s, l = (await this.runtime.runPromise(c))[0];
472
529
  return l ? (await this.routeEvent({
473
530
  table: e,
474
531
  op: "delete",
@@ -476,10 +533,10 @@ var N = (n) => e.layerConfig({
476
533
  new: null
477
534
  }, i, r, a), !0) : !1;
478
535
  }
479
- let s = o`SELECT * FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t}`, c = r ? n.provideService(s, d, r) : s, l = (await this.runtime.runPromise(c))[0];
536
+ let s = o`SELECT * FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t}`, c = r ? n.provideService(s, F, r) : s, l = (await this.runtime.runPromise(c))[0];
480
537
  if (!l) return !1;
481
- let u = o`DELETE FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t}`, f = r ? n.provideService(u, d, r) : u;
482
- return await this.runtime.runPromise(f), await this.routeEvent({
538
+ let u = o`DELETE FROM ${o(this.nsT(e))} WHERE ${o("id")} = ${t}`, d = r ? n.provideService(u, F, r) : u;
539
+ return await this.runtime.runPromise(d), await this.routeEvent({
483
540
  table: e,
484
541
  op: "delete",
485
542
  old: l,
@@ -487,18 +544,18 @@ var N = (n) => e.layerConfig({
487
544
  }, i, r, a), !0;
488
545
  }
489
546
  async appendInTxn(e, t, r) {
490
- let i = this.sql, a = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(T(t, e))}`;
491
- await this.runtime.runPromise(r ? n.provideService(a, d, r) : a);
547
+ let i = this.sql, a = i`INSERT INTO ${i(this.nsT(e))} ${i.insert(C(t, e))}`;
548
+ await this.runtime.runPromise(r ? n.provideService(a, F, r) : a);
492
549
  }
493
550
  async maxInTxn(e, t, r, i) {
494
- let a = this.sql, o = Object.entries(r).map(([e, t]) => a`${a(e)} = ${t}`), s = a`SELECT MAX(${a(t)}) AS ${a("m")} FROM ${a(this.nsT(e))} WHERE ${a.and(o)}`, c = (await this.runtime.runPromise(i ? n.provideService(s, d, i) : s))[0]?.m;
551
+ let a = this.sql, o = Object.entries(r).map(([e, t]) => a`${a(e)} = ${t}`), s = a`SELECT MAX(${a(t)}) AS ${a("m")} FROM ${a(this.nsT(e))} WHERE ${a.and(o)}`, c = (await this.runtime.runPromise(i ? n.provideService(s, F, i) : s))[0]?.m;
495
552
  return c == null ? null : Number(c);
496
553
  }
497
554
  async routeEvent(e, t, n = null, r) {
498
555
  if (e = {
499
- ...g(r),
556
+ ...p(r),
500
557
  ...e
501
- }, ne(e.table) && await ae({
558
+ }, te(e.table) && await oe({
502
559
  append: (e, t) => this.appendInTxn(e, t, n),
503
560
  maxOf: (e, t, r) => this.maxInTxn(e, t, r, n)
504
561
  }, {
@@ -510,7 +567,7 @@ var N = (n) => e.layerConfig({
510
567
  subjectId: e.subjectId
511
568
  }), this.changeStrategy === "cdc") {
512
569
  let t = (e.op === "delete" ? e.old : e.new)?.id;
513
- t != null && re(_(e.table, e.op, t), {
570
+ t != null && ne(m(e.table, e.op, t), {
514
571
  ...e.traceId === void 0 ? {} : { traceId: e.traceId },
515
572
  ...e.subjectId === void 0 ? {} : { subjectId: e.subjectId }
516
573
  });
@@ -541,41 +598,41 @@ var N = (n) => e.layerConfig({
541
598
  }
542
599
  return await this.executeUpdate(e, o.id, a, r, i) ?? o;
543
600
  }
544
- return M((n) => this.executeInsert(e, t, r, i, n));
601
+ return j((n) => this.executeInsert(e, t, r, i, n));
545
602
  }
546
603
  async executeMariadbUpsert(e, t, r, i, a, o) {
547
- let s = this.sql, c = T(t, e), l = Object.keys(c).filter((e) => c[e] !== void 0), u = r.update === void 0 ? l.filter((e) => e !== "id" && !r.conflictColumns.includes(e)) : r.update, f = u.length > 0 ? s.csv(u.map((e) => s`${s(e)} = VALUES(${s(e)})`)) : s`${s(r.conflictColumns[0])} = VALUES(${s(r.conflictColumns[0])})`, p = s`INSERT INTO ${s(this.nsT(e))} ${s.insert(c)} ON DUPLICATE KEY UPDATE ${f} RETURNING *`, m = i ? n.provideService(p, d, i) : p, h = (await this.runtime.runPromise(m))[0];
548
- if (!h) throw Error(`MysqlStore.upsert: no row returned for table '${e}'`);
549
- let g = t.id !== void 0 && t.id === h.id ? "insert" : "update";
604
+ let s = this.sql, c = C(t, e), l = Object.keys(c).filter((e) => c[e] !== void 0), u = r.update === void 0 ? l.filter((e) => e !== "id" && !r.conflictColumns.includes(e)) : r.update, d = u.length > 0 ? s.csv(u.map((e) => s`${s(e)} = VALUES(${s(e)})`)) : s`${s(r.conflictColumns[0])} = VALUES(${s(r.conflictColumns[0])})`, f = s`INSERT INTO ${s(this.nsT(e))} ${s.insert(c)} ON DUPLICATE KEY UPDATE ${d} RETURNING *`, p = i ? n.provideService(f, F, i) : f, m = (await this.runtime.runPromise(p))[0];
605
+ if (!m) throw Error(`MysqlStore.upsert: no row returned for table '${e}'`);
606
+ let h = t.id !== void 0 && t.id === m.id ? "insert" : "update";
550
607
  return await this.routeEvent({
551
608
  table: e,
552
- op: g,
609
+ op: h,
553
610
  old: null,
554
- new: h
555
- }, a, i, o), h;
611
+ new: m
612
+ }, a, i, o), m;
556
613
  }
557
614
  async executeInsertIgnore(e, t, r, i, a, o) {
558
- if (t = j(e, t), this.variant === "mariadb") {
559
- let s = this.sql, c = s`INSERT IGNORE INTO ${s(this.nsT(e))} ${s.insert(T(t, e))} RETURNING *`, l = i ? n.provideService(c, d, i) : c, u = (await this.runtime.runPromise(l))[0];
615
+ if (t = A(e, t), this.variant === "mariadb") {
616
+ let s = this.sql, c = s`INSERT IGNORE INTO ${s(this.nsT(e))} ${s.insert(C(t, e))} RETURNING *`, l = i ? n.provideService(c, F, i) : c, u = (await this.runtime.runPromise(l))[0];
560
617
  if (u) return await this.routeEvent({
561
618
  table: e,
562
619
  op: "insert",
563
620
  old: null,
564
621
  new: u
565
622
  }, a, i, o), u;
566
- let f = await this.readWarnings(i), p = f.find((e) => !pe.has(e.code));
567
- if (p !== void 0) throw Error(`MysqlStore.insertIgnore: the insert into '${e}' was REJECTED, not skipped as a conflict. INSERT IGNORE downgrades every error to a warning, and the warning was: [${p.code}] ${p.message}. Nothing was written and nothing conflicted — fix the cause above.`);
568
- let m = await this.findByConflict(e, t, r.conflictColumns, i);
569
- if (m) return m;
570
- let h = f[0];
571
- throw Error(`MysqlStore.insertIgnore: the insert was skipped as a conflict, but no existing row matches conflictColumns [${r.conflictColumns.join(", ")}] on '${e}'. ` + (h === void 0 ? "The warning could not be read on this connection, so the constraint that fired is unknown — it may be a second unique index, or the primary key under another name. " : `The constraint that actually fired: [${h.code}] ${h.message}. `) + "insertIgnore models ONE conflict target: name the columns of the constraint that actually collides, or handle the violation yourself.");
623
+ let d = await this.readWarnings(i), f = d.find((e) => !xe.has(e.code));
624
+ if (f !== void 0) throw Error(`MysqlStore.insertIgnore: the insert into '${e}' was REJECTED, not skipped as a conflict. INSERT IGNORE downgrades every error to a warning, and the warning was: [${f.code}] ${f.message}. Nothing was written and nothing conflicted — fix the cause above.`);
625
+ let p = await this.findByConflict(e, t, r.conflictColumns, i);
626
+ if (p) return p;
627
+ let m = d[0];
628
+ throw Error(`MysqlStore.insertIgnore: the insert was skipped as a conflict, but no existing row matches conflictColumns [${r.conflictColumns.join(", ")}] on '${e}'. ` + (m === void 0 ? "The warning could not be read on this connection, so the constraint that fired is unknown — it may be a second unique index, or the primary key under another name. " : `The constraint that actually fired: [${m.code}] ${m.message}. `) + "insertIgnore models ONE conflict target: name the columns of the constraint that actually collides, or handle the violation yourself.");
572
629
  }
573
- return await this.findByConflict(e, t, r.conflictColumns, i) || M((n) => this.executeInsert(e, t, i, a, n));
630
+ return await this.findByConflict(e, t, r.conflictColumns, i) || j((n) => this.executeInsert(e, t, i, a, n));
574
631
  }
575
632
  async findUndecodableCdcTables(e) {
576
633
  if (this.variant !== "mariadb") return [];
577
634
  try {
578
- let t = (await this.runtime.runPromise(this.sql.unsafe(B))).map((e) => String(e.tableName ?? e.TABLE_NAME ?? "")).filter((e) => e !== "");
635
+ let t = (await this.runtime.runPromise(this.sql.unsafe(G))).map((e) => String(e.tableName ?? e.TABLE_NAME ?? "")).filter((e) => e !== "");
579
636
  return e === void 0 ? t : t.filter((t) => e.includes(t));
580
637
  } catch (e) {
581
638
  return this.log.debug(`cdc: could not probe for undecodable tables — ${e?.message ?? String(e)}`), [];
@@ -585,7 +642,7 @@ var N = (n) => e.layerConfig({
585
642
  if (e === null) return [];
586
643
  try {
587
644
  let t = this.sql`SHOW WARNINGS`;
588
- return (await this.runtime.runPromise(n.provideService(t, d, e))).map((e) => ({
645
+ return (await this.runtime.runPromise(n.provideService(t, F, e))).map((e) => ({
589
646
  code: Number(e.Code ?? e.code ?? 0),
590
647
  message: String(e.Message ?? e.message ?? "")
591
648
  }));
@@ -595,64 +652,76 @@ var N = (n) => e.layerConfig({
595
652
  }
596
653
  async findByConflict(e, t, r, i) {
597
654
  if (r.length === 0) return;
598
- let a = this.sql, o = r.map((e) => a`${a(e)} = ${t[e]}`), s = a`SELECT * FROM ${a(this.nsT(e))} WHERE ${a.and(o)} LIMIT 1`, c = i ? n.provideService(s, d, i) : s;
655
+ let a = this.sql, o = r.map((e) => a`${a(e)} = ${t[e]}`), s = a`SELECT * FROM ${a(this.nsT(e))} WHERE ${a.and(o)} LIMIT 1`, c = i ? n.provideService(s, F, i) : s;
599
656
  return (await this.runtime.runPromise(c))[0];
600
657
  }
601
658
  query(e) {
602
659
  return this.runWithEager(e, null);
603
660
  }
604
661
  raw(e, t) {
605
- let n = x(e, this.sql);
606
- return this.runtime.runPromise(n);
662
+ let n = b(e, this.sql);
663
+ return O(this.variant, "raw", () => this.runtime.runPromise(n));
607
664
  }
608
665
  async runWithEager(e, t) {
609
- if (!D(e)) return this.executeQuery(e, t);
610
- let r = this.variant === "mariadb" ? "mariadb" : "mysql", i = this.namespace === null ? y(e, this.sql, r) : null;
666
+ if (!T(e)) return this.executeQuery(e, t);
667
+ let r = this.variant === "mariadb" ? "mariadb" : "mysql", i = this.namespace === null ? v(e, this.sql, r) : null;
611
668
  if (i !== null) try {
612
- let e = t ? n.provideService(i.fragment, d, t) : i.fragment, r = await this.runtime.runPromise(e);
669
+ let e = t ? n.provideService(i.fragment, F, t) : i.fragment, r = await O(this.variant, "select", () => this.runtime.runPromise(e));
613
670
  return i.decode(r);
614
- } catch (e) {
615
- if (e instanceof p) throw e;
616
- this.log.warn(`${this.variant} JSON-agg eager-load failed; falling back to walker`, { err: e });
671
+ } catch (t) {
672
+ if (t instanceof u) throw t;
673
+ this.reportEagerFallback({
674
+ dialect: r,
675
+ table: e.table,
676
+ reason: "execute-failed",
677
+ error: t
678
+ });
617
679
  }
618
- return h(await this.executeQuery(e, t), e.eager, e.sourceTable ?? k(e.table), (e) => this.executeQuery(e, t));
680
+ else this.reportEagerFallback({
681
+ dialect: r,
682
+ table: e.table,
683
+ reason: "not-compilable"
684
+ });
685
+ return f(await this.executeQuery(e, t), e.eager, e.sourceTable ?? re(e.table), (e) => this.executeQuery(e, t));
619
686
  }
620
687
  getInternalRunWithEager() {
621
688
  return this.runWithEager.bind(this);
622
689
  }
623
- async localWrite(e, t) {
624
- if (this.changeStrategy !== "cdc") return M(t);
625
- v(e);
626
- try {
627
- return await M(t);
628
- } finally {
629
- E(e);
630
- }
690
+ async localWrite(e, t, n) {
691
+ return O(this.variant, e, async () => {
692
+ if (this.changeStrategy !== "cdc") return j(n);
693
+ h(t);
694
+ try {
695
+ return await j(n);
696
+ } finally {
697
+ w(t);
698
+ }
699
+ });
631
700
  }
632
701
  insert(e, t) {
633
- return this.localWrite(e, (n) => this.executeInsert(e, t, null, null, n));
702
+ return this.localWrite("insert", e, (n) => this.executeInsert(e, t, null, null, n));
634
703
  }
635
704
  insertMany(e, t) {
636
- return this.localWrite(e, (n) => this.executeInsertMany(e, t, null, null, n));
705
+ return this.localWrite("insert", e, (n) => this.executeInsertMany(e, t, null, null, n));
637
706
  }
638
707
  patchJson(e, t, n, r) {
639
- return this.localWrite(e, (i) => this.executePatchJson(e, t, n, r, null, null, i));
708
+ return this.localWrite("update", e, (i) => this.executePatchJson(e, t, n, r, null, null, i));
640
709
  }
641
710
  upsert(e, t, n) {
642
- return this.localWrite(e, (r) => this.executeUpsert(e, t, n, null, null, r));
711
+ return this.localWrite("upsert", e, (r) => this.executeUpsert(e, t, n, null, null, r));
643
712
  }
644
713
  insertIgnore(e, t, n) {
645
- return this.localWrite(e, (r) => this.executeInsertIgnore(e, t, n, null, null, r));
714
+ return this.localWrite("upsert", e, (r) => this.executeInsertIgnore(e, t, n, null, null, r));
646
715
  }
647
716
  update(e, t, n) {
648
- return this.localWrite(e, (r) => this.executeUpdate(e, t, n, null, null, r));
717
+ return this.localWrite("update", e, (r) => this.executeUpdate(e, t, n, null, null, r));
649
718
  }
650
719
  delete(e, t) {
651
- return this.localWrite(e, (n) => this.executeDelete(e, t, null, null, n));
720
+ return this.localWrite("delete", e, (n) => this.executeDelete(e, t, null, null, n));
652
721
  }
653
722
  async updateMany(e, t, r) {
654
723
  if (this.supportsUpdateReturning) {
655
- let n = this.sql, i = b(r.where, n, this.namespace), a = n`UPDATE ${n(this.nsT(e))} SET ${n.update(T(t, e))} WHERE ${i} RETURNING *`, o = await this.runtime.runPromise(a);
724
+ let n = this.sql, i = y(r.where, n, this.namespace), a = n`UPDATE ${n(this.nsT(e))} SET ${n.update(C(t, e))} WHERE ${i} RETURNING *`, o = await this.runtime.runPromise(a);
656
725
  for (let t of o) await this.routeEvent({
657
726
  table: e,
658
727
  op: "update",
@@ -661,38 +730,38 @@ var N = (n) => e.layerConfig({
661
730
  }, null, null);
662
731
  return o.length;
663
732
  }
664
- let i = this.sql, o = b(r.where, i, this.namespace);
665
- this.changeStrategy === "cdc" && v(e), this.inflightTxns++;
733
+ let i = this.sql, o = y(r.where, i, this.namespace);
734
+ this.changeStrategy === "cdc" && h(e), this.inflightTxns++;
666
735
  try {
667
- let r = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(d), (r) => {
736
+ let r = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(F), (r) => {
668
737
  if (a.isNone(r)) return n.fail(/* @__PURE__ */ Error("MysqlStore.updateMany: TransactionConnection missing."));
669
- let s = r.value, c = i`SELECT id FROM ${i(this.nsT(e))} WHERE ${o} FOR UPDATE`, l = i`UPDATE ${i(this.nsT(e))} SET ${i.update(T(t, e))} WHERE ${o}`;
670
- return n.flatMap(n.provideService(c, d, s), (t) => {
738
+ let s = r.value, c = i`SELECT id FROM ${i(this.nsT(e))} WHERE ${o} FOR UPDATE`, l = i`UPDATE ${i(this.nsT(e))} SET ${i.update(C(t, e))} WHERE ${o}`;
739
+ return n.flatMap(n.provideService(c, F, s), (t) => {
671
740
  if (t.length === 0) return n.succeed([]);
672
741
  let r = t.map((e) => e.id), a = i`SELECT * FROM ${i(this.nsT(e))} WHERE ${i("id")} IN ${i.in(r)}`;
673
- return n.flatMap(n.provideService(l, d, s), () => n.provideService(a, d, s));
742
+ return n.flatMap(n.provideService(l, F, s), () => n.provideService(a, F, s));
674
743
  });
675
- }))), c = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(J)), l = r.pipe(n.retry(c), n.withSpan("store.updateMany", { attributes: {
744
+ }))), c = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(Y)), l = r.pipe(n.retry(c), n.withSpan("store.updateMany", { attributes: {
676
745
  "db.system": this.variant,
677
746
  "db.operation": "update"
678
747
  } })), u = await this.runtime.runPromise(l);
679
748
  if (u.length === 0) return 0;
680
- let f = w(u, e, this.variant);
681
- for (let t of f) await this.routeEvent({
749
+ let d = S(u, e, this.variant);
750
+ for (let t of d) await this.routeEvent({
682
751
  table: e,
683
752
  op: "update",
684
753
  old: null,
685
754
  new: t
686
755
  }, null, null);
687
- return f.length;
756
+ return d.length;
688
757
  } finally {
689
- this.inflightTxns--, this.changeStrategy === "cdc" && E(e);
758
+ this.inflightTxns--, this.changeStrategy === "cdc" && w(e);
690
759
  }
691
760
  }
692
761
  async deleteMany(e, t) {
693
- let r = this.sql, i = b(t.where, r, this.namespace);
762
+ let r = this.sql, i = y(t.where, r, this.namespace);
694
763
  if (this.supportsDeleteReturning) {
695
- let t = r`DELETE FROM ${r(this.nsT(e))} WHERE ${i} RETURNING *`, n = w(await this.runtime.runPromise(t), e, this.variant);
764
+ let t = r`DELETE FROM ${r(this.nsT(e))} WHERE ${i} RETURNING *`, n = S(await this.runtime.runPromise(t), e, this.variant);
696
765
  for (let t of n) await this.routeEvent({
697
766
  table: e,
698
767
  op: "delete",
@@ -701,18 +770,18 @@ var N = (n) => e.layerConfig({
701
770
  }, null, null);
702
771
  return n.length;
703
772
  }
704
- this.changeStrategy === "cdc" && v(e), this.inflightTxns++;
773
+ this.changeStrategy === "cdc" && h(e), this.inflightTxns++;
705
774
  try {
706
- let t = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(d), (t) => {
775
+ let t = n.suspend(() => this.sql.withTransaction(n.flatMap(n.serviceOption(F), (t) => {
707
776
  if (a.isNone(t)) return n.fail(/* @__PURE__ */ Error("MysqlStore.deleteMany: TransactionConnection missing."));
708
777
  let o = t.value, s = r`SELECT * FROM ${r(this.nsT(e))} WHERE ${i} FOR UPDATE`, c = r`DELETE FROM ${r(this.nsT(e))} WHERE ${i}`;
709
- return n.flatMap(n.provideService(s, d, o), (e) => e.length === 0 ? n.succeed(e) : n.as(n.provideService(c, d, o), e));
710
- }))), o = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(J)), c = t.pipe(n.retry(o), n.withSpan("store.deleteMany", { attributes: {
778
+ return n.flatMap(n.provideService(s, F, o), (e) => e.length === 0 ? n.succeed(e) : n.as(n.provideService(c, F, o), e));
779
+ }))), o = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(Y)), c = t.pipe(n.retry(o), n.withSpan("store.deleteMany", { attributes: {
711
780
  "db.system": this.variant,
712
781
  "db.operation": "delete"
713
782
  } })), l = await this.runtime.runPromise(c);
714
783
  if (l.length === 0) return 0;
715
- let u = w(l, e, this.variant);
784
+ let u = S(l, e, this.variant);
716
785
  for (let t of u) await this.routeEvent({
717
786
  table: e,
718
787
  op: "delete",
@@ -721,18 +790,18 @@ var N = (n) => e.layerConfig({
721
790
  }, null, null);
722
791
  return u.length;
723
792
  } finally {
724
- this.inflightTxns--, this.changeStrategy === "cdc" && E(e);
793
+ this.inflightTxns--, this.changeStrategy === "cdc" && w(e);
725
794
  }
726
795
  }
727
796
  emitChange(e) {
728
- O(e.table) && (this.changeStrategy === "cdc" && !this.cdcGate.admit(e) || this.emitter.emit("change", e));
797
+ E(e.table) && (this.changeStrategy === "cdc" && !this.cdcGate.admit(e) || this.emitter.emit("change", e));
729
798
  }
730
799
  async startCdcConsumer(e) {
731
800
  if (this.cdcHandle) return;
732
801
  await this.assertBinlogConfig(), this.cdcReplicaId = e.replicaId;
733
802
  let t = await this.readCdcOffset(e.replicaId) ?? await this.resolveBinlogEnd(), n = await this.findUndecodableCdcTables(e.includeTables);
734
- for (let e of n) this.log.error(V(e));
735
- this.cdcHandle = await q({
803
+ for (let e of n) this.log.error(K(e));
804
+ this.cdcHandle = await J({
736
805
  connection: e.connection,
737
806
  serverId: e.serverId,
738
807
  variant: this.variant,
@@ -784,7 +853,7 @@ var N = (n) => e.layerConfig({
784
853
  try {
785
854
  let t = this.sql, n = (await this.runtime.runPromise(t`
786
855
  SELECT ${t("binlogFile")}, ${t("binlogPosition")}
787
- FROM ${t(f)}
856
+ FROM ${t(c)}
788
857
  WHERE ${t("id")} = ${e} LIMIT 1`))[0];
789
858
  if (!n) return null;
790
859
  let r = Number(n.binlogPosition);
@@ -806,7 +875,7 @@ var N = (n) => e.layerConfig({
806
875
  this.cdcPendingPosition = null;
807
876
  try {
808
877
  let t = this.sql, n = this.cdcReplicaId;
809
- await this.runtime.runPromise(t`INSERT INTO ${t(f)} ${t.insert({
878
+ await this.runtime.runPromise(t`INSERT INTO ${t(c)} ${t.insert({
810
879
  id: n,
811
880
  replicaId: n,
812
881
  streamName: this.cdcStreamName,
@@ -849,31 +918,32 @@ var N = (n) => e.layerConfig({
849
918
  }
850
919
  async transactional(e) {
851
920
  this.inflightTxns++;
852
- let t = C(), r = me(), i = 0, o = n.suspend(() => {
853
- let o = ++i;
854
- return this.sql.withTransaction(n.flatMap(n.serviceOption(d), (i) => {
855
- if (a.isNone(i)) return n.fail(/* @__PURE__ */ Error("MysqlStore.transactional: TransactionConnection missing."));
856
- let s = new ge(this, i.value, t);
857
- return n.tryPromise({
858
- try: () => r(() => e(s)).then((e) => ({
859
- result: e,
860
- view: s,
861
- attempt: o
862
- })),
863
- catch: (e) => e
864
- });
865
- }));
866
- }), c = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(J)), l = o.pipe(n.retry(c), n.withSpan("store.transactional", { attributes: {
867
- "db.system": this.variant,
868
- "db.operation": "transaction"
869
- } }));
870
921
  try {
871
- let e = oe(await this.runtime.runPromiseExit(l));
872
- return e.view.commitEvents(), e.result;
922
+ return await ae({
923
+ ...this.txnSpec("MysqlStore.transactional"),
924
+ work: e,
925
+ makeView: (e, t) => new Ce(this, e, t)
926
+ });
873
927
  } finally {
874
928
  this.inflightTxns--;
875
929
  }
876
930
  }
931
+ txnSpec(e) {
932
+ return {
933
+ label: e,
934
+ dialect: this.variant === "mariadb" ? "mariadb" : "mysql",
935
+ withTransaction: (e) => this.sql.withTransaction(e),
936
+ runPromiseExit: (e) => this.runtime.runPromiseExit(e),
937
+ isRetryable: Y,
938
+ span: {
939
+ name: "store.transactional",
940
+ attributes: {
941
+ "db.system": this.variant,
942
+ "db.operation": "transaction"
943
+ }
944
+ }
945
+ };
946
+ }
877
947
  onChange(e) {
878
948
  return this.emitter.on("change", e), () => {
879
949
  this.emitter.off("change", e);
@@ -883,9 +953,9 @@ var N = (n) => e.layerConfig({
883
953
  return this.changeStrategy === "cdc" ? "fleet" : "local";
884
954
  }
885
955
  injectExternalChange(e) {
886
- if (this.changeStrategy === "cdc" && !this.cdcGate.admit(e) || !O(e.table)) return;
956
+ if (this.changeStrategy === "cdc" && !this.cdcGate.admit(e) || !E(e.table)) return;
887
957
  let t = (e.op === "delete" ? e.old : e.new)?.id;
888
- A(e.table, e.op, t, (t) => {
958
+ ie(e.table, e.op, t, (t) => {
889
959
  this.emitter.emit("change", {
890
960
  ...t,
891
961
  ...e,
@@ -914,7 +984,7 @@ var N = (n) => e.layerConfig({
914
984
  async ping() {
915
985
  await this.runtime.runPromise(this.sql`SELECT 1`);
916
986
  }
917
- }, ge = class {
987
+ }, Ce = class {
918
988
  parent;
919
989
  txn;
920
990
  attr;
@@ -987,12 +1057,12 @@ var N = (n) => e.layerConfig({
987
1057
  this.events.length = 0;
988
1058
  }
989
1059
  }
990
- }, $ = (e) => e.__mysqlReplicationFriend ?? null, _e = () => ({
1060
+ }, $ = (e) => e.__mysqlReplicationFriend ?? null, we = () => ({
991
1061
  async capturePrimaryPosition(e) {
992
1062
  let t = $(e);
993
1063
  if (t === null) throw Error("mysqlReplicationAdapter: primary is not a MysqlStore (missing __mysqlReplicationFriend).");
994
1064
  return t.runEffect(n.gen(function* () {
995
- let e = yield* u, r = (t.variant === "mariadb" ? yield* e`SELECT @@global.gtid_current_pos AS gtid` : yield* e`SELECT @@global.gtid_executed AS gtid`)[0]?.gtid;
1065
+ let e = yield* P, r = (t.variant === "mariadb" ? yield* e`SELECT @@global.gtid_current_pos AS gtid` : yield* e`SELECT @@global.gtid_executed AS gtid`)[0]?.gtid;
996
1066
  return typeof r == "string" ? r : yield* n.die("mysql/mariadb did not return a GTID set");
997
1067
  }));
998
1068
  },
@@ -1000,31 +1070,31 @@ var N = (n) => e.layerConfig({
1000
1070
  let t = $(e);
1001
1071
  if (t === null) throw Error("mysqlReplicationAdapter: replica is not a MysqlStore.");
1002
1072
  return t.runEffect(n.gen(function* () {
1003
- let e = yield* u, r = (t.variant === "mariadb" ? yield* e`SELECT @@global.gtid_current_pos AS gtid` : yield* e`SELECT @@global.gtid_executed AS gtid`)[0]?.gtid;
1073
+ let e = yield* P, r = (t.variant === "mariadb" ? yield* e`SELECT @@global.gtid_current_pos AS gtid` : yield* e`SELECT @@global.gtid_executed AS gtid`)[0]?.gtid;
1004
1074
  return typeof r == "string" ? r : yield* n.die("mysql/mariadb replica did not return a GTID set");
1005
1075
  }));
1006
1076
  },
1007
1077
  compare(e, t) {
1008
1078
  return "behind";
1009
1079
  }
1010
- }), ve = {
1080
+ }), Te = {
1011
1081
  id: "mysql",
1012
- makeSqlLayer: (e) => F(e),
1082
+ makeSqlLayer: (e) => V(e),
1013
1083
  makeStore: (e) => Q({
1014
1084
  ...e,
1015
1085
  variant: "mysql"
1016
1086
  }),
1017
1087
  compileContains: (e, t, n) => n`${e} LIKE ${`%${t.replace(/[\\%_]/g, (e) => `\\${e}`)}%`} ESCAPE '\\'`,
1018
- retryFilter: Y
1019
- }, ye = {
1088
+ retryFilter: X
1089
+ }, Ee = {
1020
1090
  id: "mariadb",
1021
- makeSqlLayer: (e) => F(e),
1091
+ makeSqlLayer: (e) => V(e),
1022
1092
  makeStore: (e) => Q({
1023
1093
  ...e,
1024
1094
  variant: "mariadb"
1025
1095
  }),
1026
1096
  compileContains: (e, t, n) => n`${e} LIKE ${`%${t.replace(/[\\%_]/g, (e) => `\\${e}`)}%`} ESCAPE '\\'`,
1027
- retryFilter: Y
1097
+ retryFilter: X
1028
1098
  };
1029
1099
  //#endregion
1030
- export { f as CDC_OFFSETS_TABLE, e as MysqlClient, m as _voltroCdcOffsetsTable, P as connectionFromConfig, N as makeMysqlSqlLayer, F as makeMysqlSqlLayerFromConfig, Q as makeMysqlStore, ye as mariadbDialect, ve as mysqlDialect, _e as mysqlReplicationAdapter, Y as mysqlRetryFilter, q as startBinlogCdc };
1100
+ export { c as CDC_OFFSETS_TABLE, e as MysqlClient, d as _voltroCdcOffsetsTable, B as connectionFromConfig, R as makeMysqlSqlLayer, V as makeMysqlSqlLayerFromConfig, Q as makeMysqlStore, Ee as mariadbDialect, Te as mysqlDialect, we as mysqlReplicationAdapter, X as mysqlRetryFilter, J as startBinlogCdc };