@voltro/sql-mssql 0.2.0 → 0.2.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,30 @@ _Changes staged for the next release accumulate here (rolled up from
39
39
 
40
40
  ---
41
41
 
42
+ ## [0.2.2] — 2026-07-17
43
+
44
+ ### Added
45
+
46
+ - **@voltro/cli** — `voltro build` now precompiles the whole serve path (framework + effect + `@voltro` inlined, app modules as lazy chunks) into a single **serve bundle** (`.framework/dist-api/serveBundle/serveEntry.js`), and `voltro serve` boots from it in-process — no child `node --import tsx`, no CLI command graph, no per-module resolution of the ~2700-module framework graph. This cuts `serve: ready` from ~1000 ms to ~180 ms (~5–6×) on both driverless (memory) and driver-backed (postgres) apps; the win is larger on a cold scale-to-zero container where module resolution dominates. The app's declared SQL driver is inlined into the bundle so it shares the framework's single effect instance (only the native leaf like `pg` stays external, resolved at runtime so it survives the deploy relocation). Fully fallback-safe: a missing, stale, or corrupt bundle degrades to the standard tsx serve path, so it can never stop `voltro serve` from booting. Nothing to configure — building an API app produces the bundle and serving prefers it automatically.
47
+
48
+ ### Fixed
49
+
50
+ - **@voltro/database** — The core-table registry (`registerCoreTables` / `requireActors` / `requireTenants`) now stores its state on a process-global `Symbol.for` singleton, the same mechanism the main table registry already uses — instead of module-local `let` bindings. Module-local state splits when the `@voltro/database` module is duplicated in a process (e.g. resolved through both the `.` and `./sql` entry points, or a bundled framework copy alongside an externally-resolved one): one instance's `registerCoreTables` becomes invisible to the instance that reads it, surfacing as a spurious `core 'actors' table not registered` at store construction. Pinning it to `globalThis` makes every copy share one store, matching the table registry's already-global behaviour.
51
+
52
+ ### Internal (no consumer-facing effect)
53
+
54
+ - **@voltro/cli** — `appModuleLoader` now accepts lazy `() => import()` loaders alongside eager module namespaces (the eager path — today's `apiEntry.js` bundle — is unchanged). Groundwork for the serve bundle: app modules registered as lazy loaders evaluate on first `importAppModule` (during `runServe`, after `registerCoreTables`) rather than eagerly at bundle-import time. No consumer-facing effect on its own.
55
+
56
+ ---
57
+
58
+ ## [0.2.1] — 2026-07-17
59
+
60
+ ### Fixed
61
+
62
+ - **@voltro/cli, @voltro/database** — `voltro codegen` / `dev` / `serve` / `build` no longer crash with `Cannot find package '@voltro/sql-mysql'` on an app that doesn't declare that driver (e.g. a memory-store app, or a postgres app for the mysql/mssql drivers). The CLI's framework-table assembly statically imported the CDC-offsets table schema from `@voltro/sql-mysql` / `@voltro/sql-mssql` (`import { _voltroCdcOffsetsTable } from '@voltro/sql-mysql'`), so merely LOADING the CLI resolved those driver packages — failing whenever one wasn't installed. This surfaced only in a production install where the drivers aren't present (0.2.0's app-declared-driver change), not in the workspace where all drivers are devDependencies. The two CDC-offsets table schemas (pure schema, no driver runtime) move to `@voltro/database` — the driver-agnostic package both the CLI and the drivers already depend on; the drivers re-export them so their public API + CDC readers are unchanged. The CLI now references a SQL driver only through the runtime `importDriver()` lookup (lazy, and only for the dialect actually in use). The lazily-imported driver modules are also typed with local structural interfaces instead of `typeof import('@voltro/sql-*')`, so no driver package is referenced in a type position either.
63
+
64
+ ---
65
+
42
66
  ## [0.2.0] — 2026-07-17
43
67
 
44
68
  ### ⚠ BREAKING
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { CDC_OFFSETS_TABLE } from '@voltro/database';
1
2
  import { CdcConfig } from '@voltro/database';
2
3
  import { ChangeEvent } from '@voltro/database';
3
4
  import { ChangeStrategy } from '@voltro/database';
@@ -21,10 +22,10 @@ import { SqlClient } from '@effect/sql';
21
22
  import { SqlClient as SqlClient_2 } from '@effect/sql/SqlClient';
22
23
  import { SqlDialect } from '@voltro/database';
23
24
  import { SqlError } from '@effect/sql';
24
- import { TableLike } from '@voltro/database';
25
25
  import { TransactionConnection } from '@effect/sql/SqlClient';
26
+ import { _voltroMssqlCdcOffsetsTable } from '@voltro/database';
26
27
 
27
- export declare const CDC_OFFSETS_TABLE = "_voltro_cdc_offsets";
28
+ export { CDC_OFFSETS_TABLE }
28
29
 
29
30
  export declare interface ChangeTrackingCdcHandle {
30
31
  readonly stop: () => Promise<void>;
@@ -247,6 +248,6 @@ export declare const startChangeTrackingCdc: (opts: ChangeTrackingCdcOptions) =>
247
248
 
248
249
  declare type TxnContext = Context.Tag.Service<typeof TransactionConnection>;
249
250
 
250
- export declare const _voltroMssqlCdcOffsetsTable: TableLike;
251
+ export { _voltroMssqlCdcOffsetsTable }
251
252
 
252
253
  export { }
package/dist/index.js CHANGED
@@ -3,14 +3,14 @@ import { Config as t, Effect as n, Layer as r, ManagedRuntime as i, Option as a,
3
3
  import { EventEmitter as c } from "node:events";
4
4
  import { createLogger as l } from "@voltro/logger";
5
5
  import { SqlClient as u, TransactionConnection as d } from "@effect/sql/SqlClient";
6
- import { attachEagerLoads as f, compileEagerJson as p, compilePredicate as m, compileRawFragment as h, compileSelect as g, decodeRowsFromSchema as _, hasEagerLoads as v, id as y, qualifyTable as b, requireTable as x, table as S, text as C, timestamp as w } from "@voltro/database";
6
+ import { CDC_OFFSETS_TABLE as f, _voltroMssqlCdcOffsetsTable as p, attachEagerLoads as m, compileEagerJson as h, compilePredicate as g, compileRawFragment as _, compileSelect as v, decodeRowsFromSchema as y, hasEagerLoads as b, qualifyTable as x, requireTable as S } from "@voltro/database";
7
7
  //#region src/sqlLayer.ts
8
- var T = {
8
+ var C = {
9
9
  ...e.defaultParameterTypes,
10
10
  null: e.defaultParameterTypes.object
11
- }, E = (n) => e.layerConfig({
11
+ }, w = (n) => e.layerConfig({
12
12
  server: t.succeed(n.server),
13
- parameterTypes: t.succeed(T),
13
+ parameterTypes: t.succeed(C),
14
14
  ...n.port === void 0 ? {} : { port: t.succeed(n.port) },
15
15
  ...n.database === void 0 ? {} : { database: t.succeed(n.database) },
16
16
  ...n.username === void 0 ? {} : { username: t.succeed(n.username) },
@@ -18,7 +18,7 @@ var T = {
18
18
  ...n.encrypt === void 0 ? {} : { encrypt: t.succeed(n.encrypt) },
19
19
  ...n.trustServer === void 0 ? {} : { trustServer: t.succeed(n.trustServer) },
20
20
  ...n.maxConnections === void 0 ? {} : { maxConnections: t.succeed(n.maxConnections) }
21
- }), D = (e) => {
21
+ }), T = (e) => {
22
22
  if (e.url) {
23
23
  let t = new URL(e.url);
24
24
  return {
@@ -40,7 +40,7 @@ var T = {
40
40
  trustServer: !0,
41
41
  ...e.maxConnections === void 0 ? {} : { maxConnections: e.maxConnections }
42
42
  };
43
- }, O = (e) => E(D(e)), k = /* @__PURE__ */ new Set(["1205"]), A = (e) => {
43
+ }, E = (e) => w(T(e)), D = /* @__PURE__ */ new Set(["1205"]), O = (e) => {
44
44
  let t = e;
45
45
  for (let e = 0; e < 5 && typeof t == "object" && t; e++) {
46
46
  let e = t.number;
@@ -49,17 +49,17 @@ var T = {
49
49
  if (typeof n == "string") return n;
50
50
  t = t.cause;
51
51
  }
52
- }, j = (e) => {
53
- let t = A(e);
54
- return t !== void 0 && k.has(t);
55
- }, M = /* @__PURE__ */ new Set(["2601", "2627"]), N = (e) => {
56
- let t = A(e);
57
- return t !== void 0 && M.has(t);
58
- }, P = (e) => j(e) ? "retry" : "noRetry", F = {
52
+ }, k = (e) => {
53
+ let t = O(e);
54
+ return t !== void 0 && D.has(t);
55
+ }, A = /* @__PURE__ */ new Set(["2601", "2627"]), j = (e) => {
56
+ let t = O(e);
57
+ return t !== void 0 && A.has(t);
58
+ }, M = (e) => k(e) ? "retry" : "noRetry", N = {
59
59
  I: "insert",
60
60
  U: "update",
61
61
  D: "delete"
62
- }, I = (e, t) => e(n.gen(function* () {
62
+ }, P = (e, t) => e(n.gen(function* () {
63
63
  let e = yield* u;
64
64
  if (((yield* e`
65
65
  SELECT COUNT(*) AS ${e("on")}
@@ -67,18 +67,18 @@ var T = {
67
67
  WHERE database_id = DB_ID()`)[0]?.on ?? 0) === 0) return yield* n.fail(/* @__PURE__ */ Error("mssql Change Tracking CDC requires CT enabled on the database. Run `ALTER DATABASE <db> SET CHANGE_TRACKING = ON (CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON)`, or set CDC=0 for inline emit."));
68
68
  for (let n of t) yield* e.unsafe(`IF NOT EXISTS (
69
69
  SELECT 1 FROM sys.change_tracking_tables
70
- WHERE object_id = OBJECT_ID(${L(n)})
70
+ WHERE object_id = OBJECT_ID(${F(n)})
71
71
  )
72
- ALTER TABLE ${R(n)} ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = OFF)`);
73
- })).then(() => void 0), L = (e) => `'${e.replace(/'/g, "''")}'`, R = (e) => `[${e.replace(/\]/g, "]]")}]`, z = async (e) => {
72
+ ALTER TABLE ${I(n)} ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = OFF)`);
73
+ })).then(() => void 0), F = (e) => `'${e.replace(/'/g, "''")}'`, I = (e) => `[${e.replace(/\]/g, "]]")}]`, L = async (e) => {
74
74
  let t = l({ scope: "voltro:mssql:cdc" }), r = e.pollIntervalMs ?? 500;
75
- await I(e.run, e.tables);
75
+ await P(e.run, e.tables);
76
76
  let i = async () => (await e.run(n.gen(function* () {
77
77
  return yield* (yield* u)`SELECT CONVERT(VARCHAR(40), CHANGE_TRACKING_CURRENT_VERSION()) AS v`;
78
78
  })))[0]?.v ?? "0", a = e.startVersion ?? await i(), o = !1, s = null, c = !1, d = (e, t) => BigInt(e) > BigInt(t), f = async (r, o) => {
79
79
  let s = await e.run(n.gen(function* () {
80
- let e = yield* u, t = e.unsafe(R(r)), n = (yield* e`
81
- SELECT CONVERT(VARCHAR(40), CHANGE_TRACKING_MIN_VALID_VERSION(OBJECT_ID(${e.unsafe(L(r))}))) AS floor`)[0]?.floor;
80
+ let e = yield* u, t = e.unsafe(I(r)), n = (yield* e`
81
+ SELECT CONVERT(VARCHAR(40), CHANGE_TRACKING_MIN_VALID_VERSION(OBJECT_ID(${e.unsafe(F(r))}))) AS floor`)[0]?.floor;
82
82
  return n != null && BigInt(o) < BigInt(n) ? {
83
83
  resync: !0,
84
84
  rows: []
@@ -96,7 +96,7 @@ var T = {
96
96
  return;
97
97
  }
98
98
  for (let t of s.rows) {
99
- let n = F[t.__ct_op];
99
+ let n = N[t.__ct_op];
100
100
  if (!n) continue;
101
101
  let { __ct_op: i, __ct_id: a, ...o } = t;
102
102
  if (n === "delete") e.onChange({
@@ -106,7 +106,7 @@ var T = {
106
106
  new: null
107
107
  });
108
108
  else {
109
- let t = _([o], r, "mssql")[0];
109
+ let t = y([o], r, "mssql")[0];
110
110
  e.onChange({
111
111
  table: r,
112
112
  op: n,
@@ -147,18 +147,12 @@ var T = {
147
147
  },
148
148
  currentVersion: () => a
149
149
  };
150
- }, B = "_voltro_cdc_offsets", V = S(B, {
151
- id: y({ prefix: "cdcoff" }),
152
- replicaId: C(),
153
- streamName: C(),
154
- ctVersion: C(),
155
- updatedAt: w()
156
- }).index(["replicaId"]), H = l({ scope: "voltro:mssql" }), U = async (e) => {
150
+ }, R = l({ scope: "voltro:mssql" }), z = async (e) => {
157
151
  let t = e.changeStrategy ?? "inline", n = t;
158
- t === "cdc" && !e.cdcConfig && (H.warn("changeStrategy='cdc' requires cdcConfig (replicaId + includeTables); falling back to 'inline'."), n = "inline");
159
- let a = e.tracerLayer ? r.mergeAll(e.sqlLayer, e.tracerLayer) : e.sqlLayer, o = i.make(a), s = new W(await o.runPromise(u), o, n);
152
+ t === "cdc" && !e.cdcConfig && (R.warn("changeStrategy='cdc' requires cdcConfig (replicaId + includeTables); falling back to 'inline'."), n = "inline");
153
+ let a = e.tracerLayer ? r.mergeAll(e.sqlLayer, e.tracerLayer) : e.sqlLayer, o = i.make(a), s = new B(await o.runPromise(u), o, n);
160
154
  return n === "cdc" && e.cdcConfig && await s.startCdcConsumer(e.cdcConfig), s;
161
- }, W = class e {
155
+ }, B = class e {
162
156
  sql;
163
157
  runtime;
164
158
  changeStrategy;
@@ -180,12 +174,12 @@ var T = {
180
174
  return t === this.namespace ? this : new e(this.sql, this.runtime, this.changeStrategy, t, this.emitter);
181
175
  }
182
176
  nsT(e) {
183
- return b(this.namespace, e);
177
+ return x(this.namespace, e);
184
178
  }
185
179
  __mssqlReplicationFriend = { runEffect: (e) => this.runtime.runPromise(e) };
186
180
  async executeQuery(e, t) {
187
- let r = g(e, this.sql, this.namespace), i = t ? n.provideService(r, d, t) : r;
188
- return _(await this.runtime.runPromise(i), e.table, "mssql");
181
+ let r = v(e, this.sql, this.namespace), i = t ? n.provideService(r, d, t) : r;
182
+ return y(await this.runtime.runPromise(i), e.table, "mssql");
189
183
  }
190
184
  async executeInsert(e, t, r, i) {
191
185
  let a = this.sql, o = a`INSERT INTO ${a(this.nsT(e))} ${a.insert(t).returning("*")}`, s = r ? n.provideService(o, d, r) : o, c = (await this.runtime.runPromise(s))[0];
@@ -242,19 +236,19 @@ var T = {
242
236
  return this.runWithEager(e, null);
243
237
  }
244
238
  raw(e, t) {
245
- let n = h(e, this.sql);
239
+ let n = _(e, this.sql);
246
240
  return this.runtime.runPromise(n);
247
241
  }
248
242
  async runWithEager(e, t) {
249
- if (!v(e)) return this.executeQuery(e, t);
250
- let r = this.namespace === null ? p(e, this.sql, "mssql") : null;
243
+ if (!b(e)) return this.executeQuery(e, t);
244
+ let r = this.namespace === null ? h(e, this.sql, "mssql") : null;
251
245
  if (r !== null) try {
252
246
  let e = t ? n.provideService(r.fragment, d, t) : r.fragment, i = await this.runtime.runPromise(e);
253
247
  return r.decode(i);
254
248
  } catch (e) {
255
- H.warn("mssql JSON-agg eager-load failed; falling back to walker", { err: e });
249
+ R.warn("mssql JSON-agg eager-load failed; falling back to walker", { err: e });
256
250
  }
257
- return f(await this.executeQuery(e, t), e.eager, e.sourceTable ?? x(e.table), (e) => this.executeQuery(e, t));
251
+ return m(await this.executeQuery(e, t), e.eager, e.sourceTable ?? S(e.table), (e) => this.executeQuery(e, t));
258
252
  }
259
253
  getInternalRunWithEager() {
260
254
  return this.runWithEager.bind(this);
@@ -275,7 +269,7 @@ var T = {
275
269
  return this.executeDelete(e, t, null, null);
276
270
  }
277
271
  async updateMany(e, t, n) {
278
- let r = this.sql, i = m(n.where, r, this.namespace), a = r`UPDATE ${r(this.nsT(e))} SET ${r.update(t)} OUTPUT INSERTED.* WHERE ${i}`, o = await this.runtime.runPromise(a);
272
+ let r = this.sql, i = g(n.where, r, this.namespace), a = r`UPDATE ${r(this.nsT(e))} SET ${r.update(t)} OUTPUT INSERTED.* WHERE ${i}`, o = await this.runtime.runPromise(a);
279
273
  for (let t of o) this.routeEvent({
280
274
  table: e,
281
275
  op: "update",
@@ -285,7 +279,7 @@ var T = {
285
279
  return o.length;
286
280
  }
287
281
  async deleteMany(e, t) {
288
- let n = this.sql, r = m(t.where, n, this.namespace), i = n`DELETE FROM ${n(this.nsT(e))} OUTPUT DELETED.* WHERE ${r}`, a = await this.runtime.runPromise(i);
282
+ let n = this.sql, r = g(t.where, n, this.namespace), i = n`DELETE FROM ${n(this.nsT(e))} OUTPUT DELETED.* WHERE ${r}`, a = await this.runtime.runPromise(i);
289
283
  for (let t of a) this.routeEvent({
290
284
  table: e,
291
285
  op: "delete",
@@ -321,7 +315,7 @@ var T = {
321
315
  try {
322
316
  return await this.executeInsert(e, t, r, i);
323
317
  } catch (a) {
324
- if (!N(a)) throw a;
318
+ if (!j(a)) throw a;
325
319
  let o = await this.findByConflict(e, t, n.conflictColumns, r);
326
320
  if (!o) throw a;
327
321
  return await this.executeUpdate(e, o.id, this.upsertPatch(t, o, n), r, i) ?? o;
@@ -350,7 +344,7 @@ var T = {
350
344
  try {
351
345
  return await this.executeInsert(e, t, r, i);
352
346
  } catch (i) {
353
- if (!N(i)) throw i;
347
+ if (!j(i)) throw i;
354
348
  let a = await this.findByConflict(e, t, n.conflictColumns, r);
355
349
  if (!a) throw i;
356
350
  return a;
@@ -368,9 +362,9 @@ var T = {
368
362
  if (this.cdcHandle) return;
369
363
  this.cdcReplicaId = e.replicaId;
370
364
  let t = e.includeTables ?? [];
371
- t.length === 0 && H.warn("cdc: no reactive tables to tail; Change Tracking reader idle. Set includeTables to enable.");
365
+ t.length === 0 && R.warn("cdc: no reactive tables to tail; Change Tracking reader idle. Set includeTables to enable.");
372
366
  let n = await this.readCdcOffset(e.replicaId);
373
- this.cdcHandle = await z({
367
+ this.cdcHandle = await L({
374
368
  run: this.__mssqlReplicationFriend.runEffect,
375
369
  tables: t,
376
370
  startVersion: n,
@@ -378,9 +372,9 @@ var T = {
378
372
  onVersion: (e) => {
379
373
  this.cdcPendingVersion = e;
380
374
  },
381
- onError: (e) => H.warn("cdc: consumer error", {}, e),
375
+ onError: (e) => R.warn("cdc: consumer error", {}, e),
382
376
  onResync: () => {
383
- H.warn("cdc: resynced to current CT version after retention gap — subscriptions self-heal on the next change");
377
+ R.warn("cdc: resynced to current CT version after retention gap — subscriptions self-heal on the next change");
384
378
  }
385
379
  }), this.cdcCheckpointTimer = setInterval(() => {
386
380
  this.flushCdcOffset();
@@ -389,14 +383,14 @@ var T = {
389
383
  async readCdcOffset(e) {
390
384
  try {
391
385
  let t = this.sql, n = (await this.runtime.runPromise(t`
392
- SELECT TOP 1 ${t("ctVersion")} FROM ${t(B)}
386
+ SELECT TOP 1 ${t("ctVersion")} FROM ${t(f)}
393
387
  WHERE ${t("id")} = ${e}`))[0]?.ctVersion;
394
- return n ? (H.info("cdc: resuming from persisted CT version", {
388
+ return n ? (R.info("cdc: resuming from persisted CT version", {
395
389
  replicaId: e,
396
390
  version: n
397
391
  }), n) : null;
398
392
  } catch (t) {
399
- return H.warn("cdc: no readable offset; starting at current CT version", { replicaId: e }, t), null;
393
+ return R.warn("cdc: no readable offset; starting at current CT version", { replicaId: e }, t), null;
400
394
  }
401
395
  }
402
396
  async flushCdcOffset() {
@@ -405,7 +399,7 @@ var T = {
405
399
  this.cdcPendingVersion = null;
406
400
  try {
407
401
  let t = this.cdcReplicaId;
408
- await this.executeUpsert(B, {
402
+ await this.executeUpsert(f, {
409
403
  id: t,
410
404
  replicaId: t,
411
405
  streamName: this.cdcStreamName,
@@ -416,7 +410,7 @@ var T = {
416
410
  update: ["ctVersion", "updatedAt"]
417
411
  }, null, null);
418
412
  } catch (t) {
419
- this.cdcPendingVersion = e, H.warn("cdc: checkpoint write failed", {}, t);
413
+ this.cdcPendingVersion = e, R.warn("cdc: checkpoint write failed", {}, t);
420
414
  }
421
415
  }
422
416
  }
@@ -450,7 +444,7 @@ var T = {
450
444
  let r = ++t;
451
445
  return this.sql.withTransaction(n.flatMap(n.serviceOption(d), (t) => {
452
446
  if (a.isNone(t)) return n.fail(/* @__PURE__ */ Error("MssqlStore.transactional: TransactionConnection missing."));
453
- let i = new G(this, t.value);
447
+ let i = new V(this, t.value);
454
448
  return n.tryPromise({
455
449
  try: () => e(i).then((e) => ({
456
450
  result: e,
@@ -460,7 +454,7 @@ var T = {
460
454
  catch: (e) => e
461
455
  });
462
456
  }));
463
- }), i = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(j)), o = r.pipe(n.retry(i), n.withSpan("store.transactional", { attributes: {
457
+ }), i = s.exponential("10 millis").pipe(s.compose(s.recurs(3)), s.whileInput(k)), o = r.pipe(n.retry(i), n.withSpan("store.transactional", { attributes: {
464
458
  "db.system": "mssql",
465
459
  "db.operation": "transaction"
466
460
  } }));
@@ -496,7 +490,7 @@ var T = {
496
490
  if (this.inflightTxns > 0) {
497
491
  let t = Date.now() + e;
498
492
  for (; this.inflightTxns > 0 && Date.now() < t;) await new Promise((e) => setTimeout(e, 25));
499
- this.inflightTxns > 0 && H.warn("close: grace period expired with in-flight transactions", {
493
+ this.inflightTxns > 0 && R.warn("close: grace period expired with in-flight transactions", {
500
494
  gracePeriodMs: e,
501
495
  inflight: this.inflightTxns
502
496
  });
@@ -506,7 +500,7 @@ var T = {
506
500
  async ping() {
507
501
  await this.runtime.runPromise(this.sql`SELECT 1`);
508
502
  }
509
- }, G = class {
503
+ }, V = class {
510
504
  parent;
511
505
  txn;
512
506
  events = [];
@@ -578,9 +572,9 @@ var T = {
578
572
  this.events.length = 0;
579
573
  }
580
574
  }
581
- }, K = (e) => e.__mssqlReplicationFriend ?? null, q = (e, t) => e === t ? 0 : e < t ? -1 : 1, J = () => ({
575
+ }, H = (e) => e.__mssqlReplicationFriend ?? null, U = (e, t) => e === t ? 0 : e < t ? -1 : 1, W = () => ({
582
576
  async capturePrimaryPosition(e) {
583
- let t = K(e);
577
+ let t = H(e);
584
578
  if (t === null) throw Error("mssqlReplicationAdapter: primary is not an MssqlStore (missing __mssqlReplicationFriend).");
585
579
  return t.runEffect(n.gen(function* () {
586
580
  return (yield* (yield* u)`
@@ -593,7 +587,7 @@ var T = {
593
587
  }));
594
588
  },
595
589
  async probeReplicaPosition(e) {
596
- let t = K(e);
590
+ let t = H(e);
597
591
  if (t === null) throw Error("mssqlReplicationAdapter: replica is not an MssqlStore.");
598
592
  return t.runEffect(n.gen(function* () {
599
593
  return (yield* (yield* u)`
@@ -605,14 +599,14 @@ var T = {
605
599
  }));
606
600
  },
607
601
  compare(e, t) {
608
- return q(t, e) >= 0 ? "caught-up" : "behind";
602
+ return U(t, e) >= 0 ? "caught-up" : "behind";
609
603
  }
610
- }), Y = {
604
+ }), G = {
611
605
  id: "mssql",
612
- makeSqlLayer: (e) => O(e),
613
- makeStore: (e) => U(e),
606
+ makeSqlLayer: (e) => E(e),
607
+ makeStore: (e) => z(e),
614
608
  compileContains: (e, t, n) => n`${e} LIKE ${`%${t.replace(/[\\%_[\]]/g, (e) => `\\${e}`)}%`} ESCAPE '\\'`,
615
- retryFilter: P
609
+ retryFilter: M
616
610
  };
617
611
  //#endregion
618
- export { B as CDC_OFFSETS_TABLE, e as MssqlClient, V as _voltroMssqlCdcOffsetsTable, D as connectionFromConfig, I as ensureChangeTracking, E as makeMssqlSqlLayer, O as makeMssqlSqlLayerFromConfig, U as makeMssqlStore, Y as mssqlDialect, J as mssqlReplicationAdapter, P as mssqlRetryFilter, z as startChangeTrackingCdc };
612
+ export { f as CDC_OFFSETS_TABLE, e as MssqlClient, p as _voltroMssqlCdcOffsetsTable, T as connectionFromConfig, P as ensureChangeTracking, w as makeMssqlSqlLayer, E as makeMssqlSqlLayerFromConfig, z as makeMssqlStore, G as mssqlDialect, W as mssqlReplicationAdapter, M as mssqlRetryFilter, L as startChangeTrackingCdc };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/sql-mssql",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "SQL Server (mssql) dialect adapter for Voltro's cross-dialect DataStore (OUTPUT-clause returning, OFFSET/FETCH paging, inline reactivity).",
5
5
  "keywords": [
6
6
  "voltro",
@@ -34,8 +34,8 @@
34
34
  "dependencies": {
35
35
  "@effect/sql": "^0.51.1",
36
36
  "@effect/sql-mssql": "^0.52.0",
37
- "@voltro/database": "0.2.0",
38
- "@voltro/logger": "0.2.0"
37
+ "@voltro/database": "0.2.2",
38
+ "@voltro/logger": "0.2.2"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "effect": "^3.21.4"