@voltro/testing 0.72.0 → 0.73.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/dist/index.js +105 -105
  3. package/package.json +8 -8
package/CHANGELOG.md CHANGED
@@ -39,6 +39,91 @@ _Changes staged for the next release accumulate here (rolled up from
39
39
 
40
40
  ---
41
41
 
42
+ ## [0.73.0] — 2026-09-17
43
+
44
+ ### Added
45
+
46
+ - **Typed writes on the Effect channel — the row check and StoreError compose** — `@voltro/runtime`
47
+
48
+ `insertRow`, `insertManyRows`, `upsertRow`, `upsertRowOutcome` and `insertIgnoreRowOutcome` check their payload against the table — a required column the row omits is a compile error at the call site — and return a `Promise`. `EffectStore` carries every one of those operations on the typed error channel and takes `(table, row)` with an unchecked `Row`.
49
+
50
+ So the two properties excluded each other. A handler that wanted the row checked gave up `StoreError`; one that wanted the channel passed an unchecked row. There was no third option: wrapping a typed helper in `Effect.promise` runs the write outside the Effect and discards exactly the channel at issue.
51
+
52
+ Five helpers close it, with the same signatures over a store whose methods return Effects:
53
+
54
+ ```ts
55
+ const store = yield* EffectStore
56
+ const saved = yield* insertRowEffect(store, players, { tenantId, name })
57
+ const { row, outcome } = yield* upsertRowOutcomeEffect(store, players, player, {
58
+ conflictColumns: ['tenantId', 'externalId'],
59
+ update: ['name', 'score'],
60
+ })
61
+ ```
62
+
63
+ `EffectStore` satisfies each helper's store parameter structurally, so it is the argument at every call site. The row type, the conflict-key constraint and the return type are spelled as the Promise forms spell them, so moving between the two families means reading one signature rather than two.
64
+
65
+ One deliberate difference: `upsertRowOutcome` throws when a hand-written `DataStore` lacks `upsertWithOutcome`. `EffectStore` always provides it, so the Effect form does not carry that failure — an error case for an unreachable condition is one every caller must handle and none can trigger.
66
+
67
+ ### Fixed
68
+
69
+ - **A module that re-exports the generated route builder is not a hand-roll** — `@voltro/cli`
70
+
71
+ `voltro doctor`'s `hand-route-module` rule read the importing file and asked whether it mentioned `.framework/routes.generated`. An app that keeps exactly one module importing the generated builder and re-exports it — so that a single file owns the dependency — therefore had every consumer of that alias reported, while using the typed builders the rule recommends.
72
+
73
+ The rule now resolves the imported module and stays silent when it re-exports the generated builder. A genuinely hand-maintained route or url module is reported as before.
74
+
75
+ An alias onto a generated artefact is the adoption of this rule, and a finding that fires on the adoption is an argument for deleting the seam that made it clean.
76
+ - **The migration codemod no longer re-indents the body it rewrites** — `@voltro/cli`
77
+
78
+ `0.72.0/01_migration-context-raw` rewrites two lines per migration and produced diffs of 85 to 133 changed lines. Two causes, both removed.
79
+
80
+ A migration whose body is an expression — `up: (ctx) => Effect.gen(function* () { … })`, the common shape — was hoisted into a block so the `raw(reason)` binding had somewhere to live, which indented the entire body one level. The binding is placed inside the generator instead, so the body keeps its position and the change is the two lines it actually is.
81
+
82
+ Separately, every node any codemod inserted was printed with four-space indentation while this framework's own templates use two. That is fixed for all codemods, not just this one.
83
+
84
+ Neither changes what the codemod means. It changes whether the diff can be read — which matters here more than most, because every `raw(reason)` it writes is a placeholder its author has to fill in before committing.
85
+ - **voltro serve refuses a serve bundle built by a different framework version** — `@voltro/cli`
86
+
87
+ `voltro serve` loads the precompiled serve bundle, and a bundle built before an upgrade imports perfectly — it simply runs the previous version's code. Nothing said so. Updating `@voltro/*` without re-running `voltro build` therefore left a process serving the old framework while the installed one had moved on, and the only way to notice was to recognise a log line's shape as belonging to the older release.
88
+
89
+ The bundle already carries the version that built it. `voltro serve` now reads it before importing and refuses when it disagrees with the installed CLI, naming both versions and the command that fixes it:
90
+
91
+ ```
92
+ FATAL: the serve bundle was built by @voltro/cli 0.71.1, but 0.72.0 is installed.
93
+ Serving it would run 0.71.1's code against 0.72.0's dependencies.
94
+ Rebuild it: voltro build .
95
+ ```
96
+
97
+ A mismatch refuses rather than falling back to the slower boot path: it is a build error of the deployment, and quietly running a different version is the failure being fixed. A bundle carrying no version marker is left alone — those predate the marker and are not evidence of anything.
98
+ - **A workflow step can reach the store under the test runner** — `@voltro/testing`
99
+
100
+ A workflow step may `yield* EffectStore`, and in production it gets one: the runtime provides the layer from the context's store. `makeWorkflowRunner` provided the step recorder and the workflow's own layer and nothing else, so the step died under test with
101
+
102
+ ```
103
+ Service not found: @voltro/EffectStore
104
+ ```
105
+
106
+ while the identical code ran in production. The only supported way to drive a workflow in a test could not run the form the framework documents, which left `Effect.promise` as the shape people shipped instead.
107
+
108
+ The runner now provides the same layer from the same place production does, from the context it already receives. A context without a store stays runnable, so a test that never touches the store does not acquire a requirement.
109
+ - **The AI usage receipt key no longer refuses to migrate an existing ledger** — `@voltro/ai`, `@voltro/cli`
110
+
111
+ `_voltro_ai_usage.receiptKey` arrived NOT NULL with neither a default nor a backfill, so adding it to a database that already holds usage rows was refused:
112
+
113
+ ```
114
+ auto-migrate: REFUSED — 1 blocked operation(s):
115
+ - add-column [_voltro_ai_usage]: NOT NULL column on a table whose row count is unknown
116
+ auto-migrate failed — aborting boot
117
+ ```
118
+
119
+ The refusal was correct and its advice was not reachable: it asks whoever owns the declaration to add `.backfill()` or `.default()`, and this table is the framework's, not the app's. `VOLTRO_AUTO_MIGRATE=0` left the app on the previous schema and `voltro db apply` refused the same way before a deploy, so an upgrade could not be rolled out at all.
120
+
121
+ The column now derives a per-row value from the row's own id. A literal default could not do this job — the column is UNIQUE, so one value for every existing row collides on the second — and the derivation is computed per row rather than in SQL because string concatenation has no dialect-neutral spelling and this table ships on five.
122
+
123
+ A guard now plans every framework table against a populated database and fails on any column added since the last release that an app could not migrate onto. Two earlier shapes of that check were built and discarded, each disproved by its own measurement: both asked every framework column to be addable, and a column created together with its table never is.
124
+
125
+ ---
126
+
42
127
  ## [0.72.0] — 2026-09-16
43
128
 
44
129
  ### ⚠ BREAKING
package/dist/index.js CHANGED
@@ -1,47 +1,47 @@
1
1
  import { AUTO_FILLED_COLUMNS as e, allRegisteredTables as t, changeDelete as n, changeInsert as r, changeSoftDelete as i, changeUpdate as a, clearRelationsRegistry as o, missingRequiredColumns as s, registerRelations as c } from "@voltro/database";
2
2
  import { Cause as l, Effect as u, Exit as d, Layer as f, Schema as p } from "effect";
3
3
  import { SubjectService as m, anonymousSubject as h, checkGuardsEffect as g, composeAuthStrategies as _, composeRpcInterceptors as v, eventRoute as y, systemSubject as b, tenantScopedSubject as ee } from "@voltro/protocol";
4
- import { EventBus as x, InMemoryDataStore as S, NO_ROW_FILTER as C, appValidation as te, applyRowFilterToDescriptor as ne, clearSystemStoreHandle as re, getRowFilter as w, getSystemStoreHandle as ie, makeAppAccess as ae, makeConnectionState as oe, makeDataLoader as se, makeEffectStoreLayer as ce, makeEventPublisher as le, makeFieldCipher as ue, makeOutboxFacade as de, makeSchemaRegistry as fe, publishEvent as pe, resolveRowFilterScopeFor as me, resolveTransactionSubject as he, runProvidedEffect as T, runWithDeadlockRetry as ge, setFieldCipher as _e, setSystemStoreHandle as E, wrapStoreWithMixinBehaviour as D } from "@voltro/runtime";
5
- import { installEnvSnapshot as ve } from "@voltro/env";
6
- import ye from "node:net";
7
- import { describe as be } from "vitest";
8
- import { collectPublicApiRoutes as xe, dispatchSharedPath as Se, restRoutesToHttpRoutes as Ce } from "@voltro/protocol/rest";
9
- import { createLogger as we } from "@voltro/logger";
10
- import { CurrentWorkflowRunId as Te, inMemoryWorkflowEngineLayer as Ee, makeInMemoryRecorder as De } from "@voltro/workflow";
4
+ import { EventBus as x, InMemoryDataStore as S, NO_ROW_FILTER as C, appValidation as te, applyRowFilterToDescriptor as ne, clearSystemStoreHandle as re, getRowFilter as w, getSystemStoreHandle as ie, makeAppAccess as ae, makeConnectionState as oe, makeDataLoader as se, makeEffectStoreLayer as T, makeEventPublisher as ce, makeFieldCipher as le, makeOutboxFacade as ue, makeSchemaRegistry as de, publishEvent as fe, resolveRowFilterScopeFor as pe, resolveTransactionSubject as me, runProvidedEffect as E, runWithDeadlockRetry as he, setFieldCipher as ge, setSystemStoreHandle as D, wrapStoreWithMixinBehaviour as O } from "@voltro/runtime";
5
+ import { installEnvSnapshot as _e } from "@voltro/env";
6
+ import ve from "node:net";
7
+ import { describe as ye } from "vitest";
8
+ import { collectPublicApiRoutes as be, dispatchSharedPath as xe, restRoutesToHttpRoutes as Se } from "@voltro/protocol/rest";
9
+ import { createLogger as Ce } from "@voltro/logger";
10
+ import { CurrentWorkflowRunId as we, inMemoryWorkflowEngineLayer as Te, makeInMemoryRecorder as Ee } from "@voltro/workflow";
11
11
  //#region src/fixtureRow.ts
12
- var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
12
+ var De = new Set(e), k = 0, A = () => ++k, Oe = (e, t) => {
13
13
  if (t.oneOf && t.oneOf.length > 0) return t.oneOf[0];
14
14
  if (t.enumValues && t.enumValues.length > 0) return t.enumValues[0];
15
15
  let n = t.unique === !0;
16
16
  switch (t.type) {
17
17
  case "text":
18
18
  case "id":
19
- case "enum": return n ? `${e}-${++O}` : e;
20
- case "reference": return t.referenceStorage === "numeric" ? n ? ++O : 0 : n ? `${e}-${++O}` : e;
19
+ case "enum": return n ? `${e}-${++k}` : e;
20
+ case "reference": return t.referenceStorage === "numeric" ? n ? ++k : 0 : n ? `${e}-${++k}` : e;
21
21
  case "integer":
22
- case "real": return n ? ++O : 0;
22
+ case "real": return n ? ++k : 0;
23
23
  case "decimal":
24
- case "bigint": return n ? String(++O) : "0";
24
+ case "bigint": return n ? String(++k) : "0";
25
25
  case "boolean": return !1;
26
26
  case "timestamp":
27
27
  case "date": return /* @__PURE__ */ new Date(0);
28
28
  default: throw Error(`fixtureRow: column '${e}' is a required '${t.type}' with no default, and fixtureRow can't synthesize a safe placeholder for that type. Pass it explicitly: fixtureRow(table, { ${e}: … }).`);
29
29
  }
30
- }, A = (e, t = {}) => {
30
+ }, j = (e, t = {}) => {
31
31
  let n = {};
32
- for (let r of s(e, t)) Oe.has(r) || (n[r] = ke(r, e.fields[r]));
32
+ for (let r of s(e, t)) De.has(r) || (n[r] = Oe(r, e.fields[r]));
33
33
  return {
34
34
  ...n,
35
35
  ...t
36
36
  };
37
- }, Ae = (e) => {
37
+ }, ke = (e) => {
38
38
  let t = {};
39
- for (let [n, r] of Object.entries(e)) t[n] = typeof r == "function" ? r(k()) : r;
39
+ for (let [n, r] of Object.entries(e)) t[n] = typeof r == "function" ? r(A()) : r;
40
40
  return t;
41
- }, je = (e) => {
41
+ }, Ae = (e) => {
42
42
  for (let [t, n] of Object.entries(e.fields)) if (n.type === "id") return t;
43
43
  return "id";
44
- }, Me = async (e, t, n, r, i) => {
44
+ }, je = async (e, t, n, r, i) => {
45
45
  let a = {};
46
46
  for (let o of s(t, n)) {
47
47
  let n = t.fields[o];
@@ -49,29 +49,29 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
49
49
  let s = n.references();
50
50
  if (i.includes(s.tableName)) throw Error(`defineFactory: creating '${t.tableName}' requires '${s.tableName}' via '${o}', and that reference is cyclic (${[...i, s.tableName].join(" → ")}). Insert one side first and pass the id: create(store, { ${o}: existing.id }).`);
51
51
  let c = r[o];
52
- a[o] = (c === void 0 ? await j(e, s, {}, {}, [...i, s.tableName]) : await c.create(e, {}))[n.referenceColumn ?? je(s)];
52
+ a[o] = (c === void 0 ? await M(e, s, {}, {}, [...i, s.tableName]) : await c.create(e, {}))[n.referenceColumn ?? Ae(s)];
53
53
  }
54
54
  return a;
55
- }, j = async (e, t, n, r, i) => {
55
+ }, M = async (e, t, n, r, i) => {
56
56
  let a = {
57
- ...await Me(e, t, n, r, i),
57
+ ...await je(e, t, n, r, i),
58
58
  ...n
59
59
  };
60
- return e.insert(t.tableName, A(t, a));
61
- }, M = (e, t) => typeof e == "function" ? e(t) : e ?? {}, Ne = (e, t = {}) => {
60
+ return e.insert(t.tableName, j(t, a));
61
+ }, N = (e, t) => typeof e == "function" ? e(t) : e ?? {}, Me = (e, t = {}) => {
62
62
  let n = t.traits ?? {}, r = t.associations ?? {}, i = (t) => {
63
63
  let a = (e = {}) => ({
64
- ...Ae(t),
64
+ ...ke(t),
65
65
  ...e
66
- }), o = (t = {}) => A(e, a(t));
66
+ }), o = (t = {}) => j(e, a(t));
67
67
  return {
68
68
  table: e,
69
69
  build: o,
70
- buildList: (e, t) => Array.from({ length: e }, (e, n) => o(M(t, n))),
71
- create: (t, n = {}) => j(t, e, a(n), r, [e.tableName]),
70
+ buildList: (e, t) => Array.from({ length: e }, (e, n) => o(N(t, n))),
71
+ create: (t, n = {}) => M(t, e, a(n), r, [e.tableName]),
72
72
  createList: async (t, n, i) => {
73
73
  let o = [];
74
- for (let s = 0; s < n; s++) o.push(await j(t, e, a(M(i, s)), r, [e.tableName]));
74
+ for (let s = 0; s < n; s++) o.push(await M(t, e, a(N(i, s)), r, [e.tableName]));
75
75
  return o;
76
76
  },
77
77
  with: (...r) => {
@@ -93,19 +93,19 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
93
93
  };
94
94
  };
95
95
  return i(t.defaults ?? {});
96
- }, N = Symbol.for("voltro/testing/mockClock.installed"), P = () => globalThis, Pe = (e, t) => new Proxy(e, {
96
+ }, P = Symbol.for("voltro/testing/mockClock.installed"), F = () => globalThis, Ne = (e, t) => new Proxy(e, {
97
97
  construct: (e, n, r) => Reflect.construct(e, n.length === 0 ? [t()] : n, r),
98
98
  apply: () => new e(t()).toString(),
99
99
  get: (e, n, r) => n === "now" ? () => t() : Reflect.get(e, n, r)
100
- }), F = (e) => {
100
+ }), I = (e) => {
101
101
  if (typeof e == "number") return e;
102
102
  let t = e instanceof Date ? e.getTime() : Date.parse(e);
103
103
  if (Number.isNaN(t)) throw Error(`mockClock: cannot read an instant from '${String(e)}'`);
104
104
  return t;
105
- }, I = class {
105
+ }, L = class {
106
106
  currentMs;
107
107
  constructor(e = "2026-01-01T00:00:00Z") {
108
- this.currentMs = F(e);
108
+ this.currentMs = I(e);
109
109
  }
110
110
  now() {
111
111
  return this.currentMs;
@@ -114,47 +114,47 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
114
114
  return new Date(this.currentMs);
115
115
  }
116
116
  advance(e) {
117
- this.currentMs += typeof e == "number" ? e : Re(e);
117
+ this.currentMs += typeof e == "number" ? e : Le(e);
118
118
  }
119
119
  set(e) {
120
- this.currentMs = F(e);
120
+ this.currentMs = I(e);
121
121
  }
122
122
  get installed() {
123
- return P()[N]?.clock === this;
123
+ return F()[P]?.clock === this;
124
124
  }
125
125
  install() {
126
- let e = P(), t = e[N];
126
+ let e = F(), t = e[P];
127
127
  if (t !== void 0) throw Error("mockClock: global time is already faked" + (t.clock === this ? " by this same clock" : " by another MockClock") + ". Uninstall it before installing again — a nested install restores the outer fake on the way out, which leaves the realm frozen with nothing pointing at why. `withFrozenTime` always restores, including on a throw.");
128
128
  let n = globalThis.Date;
129
- return e[N] = {
129
+ return e[P] = {
130
130
  realDate: n,
131
131
  clock: this
132
- }, globalThis.Date = Pe(n, () => this.currentMs), () => {
132
+ }, globalThis.Date = Ne(n, () => this.currentMs), () => {
133
133
  this.uninstall();
134
134
  };
135
135
  }
136
136
  uninstall() {
137
- let e = P(), t = e[N];
138
- t !== void 0 && t.clock === this && (globalThis.Date = t.realDate, delete e[N]);
137
+ let e = F(), t = e[P];
138
+ t !== void 0 && t.clock === this && (globalThis.Date = t.realDate, delete e[P]);
139
139
  }
140
- }, Fe = (e) => typeof e == "object" && !!e && typeof e.then == "function", Ie = (e, t) => {
141
- let n = e instanceof I ? e : new I(e);
140
+ }, Pe = (e) => typeof e == "object" && !!e && typeof e.then == "function", Fe = (e, t) => {
141
+ let n = e instanceof L ? e : new L(e);
142
142
  n.install();
143
143
  let r = !1;
144
144
  try {
145
145
  let e = t(n);
146
- return Fe(e) ? (r = !0, e.then((e) => (n.uninstall(), e), (e) => {
146
+ return Pe(e) ? (r = !0, e.then((e) => (n.uninstall(), e), (e) => {
147
147
  throw n.uninstall(), e;
148
148
  })) : e;
149
149
  } finally {
150
150
  r || n.uninstall();
151
151
  }
152
- }, Le = (e) => u.acquireRelease(u.sync(() => {
153
- let t = e instanceof I ? e : new I(e);
152
+ }, Ie = (e) => u.acquireRelease(u.sync(() => {
153
+ let t = e instanceof L ? e : new L(e);
154
154
  return t.install(), t;
155
155
  }), (e) => u.sync(() => {
156
156
  e.uninstall();
157
- })), Re = (e) => {
157
+ })), Le = (e) => {
158
158
  let t = /^\s*(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)\s*$/.exec(e);
159
159
  if (!t) throw Error(`mockClock: cannot parse duration '${e}'`);
160
160
  let n = Number(t[1]), r = t[2];
@@ -166,7 +166,7 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
166
166
  case "d": return n * 864e5;
167
167
  default: throw Error(`mockClock: unknown unit '${r}'`);
168
168
  }
169
- }, L = class {
169
+ }, R = class {
170
170
  emitted = [];
171
171
  async emit(e, t) {
172
172
  let n = typeof e == "string" ? e : e.id ?? e.event ?? "(unnamed event)";
@@ -185,14 +185,14 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
185
185
  clear() {
186
186
  this.emitted.length = 0;
187
187
  }
188
- }, R = (e = {}) => {
188
+ }, z = (e = {}) => {
189
189
  let t = e.tenantId ?? null, n = new x({
190
190
  origin: e.origin ?? "test",
191
191
  ...e.ringSize === void 0 ? {} : { ringSize: e.ringSize }
192
192
  });
193
193
  return {
194
194
  publish: async (e, r, i) => {
195
- let a = await u.runPromise(u.either(pe({
195
+ let a = await u.runPromise(u.either(fe({
196
196
  bus: n,
197
197
  tenantId: t
198
198
  }, e, r, i)));
@@ -255,7 +255,7 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
255
255
  n.clear();
256
256
  }
257
257
  };
258
- }, z = class {
258
+ }, B = class {
259
259
  queue;
260
260
  calls = [];
261
261
  constructor(e) {
@@ -270,33 +270,33 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
270
270
  remaining() {
271
271
  return this.queue.length;
272
272
  }
273
- }, ze = (e) => e, B = "00000000000000000000000000000000", V = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), Be = (e, t) => {
274
- let n = H.get(e);
273
+ }, Re = (e) => e, V = "00000000000000000000000000000000", H = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), ze = (e, t) => {
274
+ let n = U.get(e);
275
275
  if (n === void 0) throw Error("withRpcConnection requires a context created by makeTestContext");
276
276
  return n(t);
277
- }, U = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), K = (e) => G.get(e) ?? [], q = /* @__PURE__ */ new WeakMap(), J = (e, t) => {
278
- q.set(e, { publicApi: t });
279
- }, Y = (e) => q.get(e), X = /* @__PURE__ */ new WeakMap(), Ve = (e, t) => {
280
- let n = G.get(e) ?? [], r = t === "mutation" ? "interceptMutation" : t === "query" ? "interceptQuery" : "interceptAction", i = [];
277
+ }, W = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), q = (e) => K.get(e) ?? [], J = /* @__PURE__ */ new WeakMap(), Y = (e, t) => {
278
+ J.set(e, { publicApi: t });
279
+ }, X = (e) => J.get(e), Be = /* @__PURE__ */ new WeakMap(), Ve = (e, t) => {
280
+ let n = K.get(e) ?? [], r = t === "mutation" ? "interceptMutation" : t === "query" ? "interceptQuery" : "interceptAction", i = [];
281
281
  for (let e of n) {
282
282
  let t = e[r];
283
283
  typeof t == "function" && i.push(t);
284
284
  }
285
285
  return v(i);
286
286
  }, He = (e) => {
287
- let t = (G.get(e) ?? []).map((e) => e.services).filter((e) => e !== void 0), n = X.get(e) ?? [], r = [...t, ...n];
287
+ let t = (K.get(e) ?? []).map((e) => e.services).filter((e) => e !== void 0), n = Be.get(e) ?? [], r = [...t, ...n];
288
288
  if (r.length !== 0) return f.mergeAll(...r);
289
289
  }, Ue = (e) => {
290
- let t = U.get(e);
290
+ let t = W.get(e);
291
291
  t !== void 0 && (t.length = 0);
292
292
  }, Z = async (e) => {
293
- let t = U.get(e);
293
+ let t = W.get(e);
294
294
  if (t === void 0 || t.length === 0) return;
295
295
  let n = [...t];
296
296
  t.length = 0;
297
297
  for (let e of n) await e();
298
- }, We = (e) => W.get(e) ?? [], Ge = async (e, t) => {
299
- let n = V.get(e);
298
+ }, We = (e) => G.get(e) ?? [], Ge = async (e, t) => {
299
+ let n = H.get(e);
300
300
  return n === void 0 ? e.store.transactional(async (n) => t({
301
301
  ...e,
302
302
  store: n
@@ -370,11 +370,11 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
370
370
  };
371
371
  }, Je = async (e, t) => {
372
372
  let n = ie();
373
- E(e);
373
+ D(e);
374
374
  try {
375
375
  return await t();
376
376
  } finally {
377
- n === void 0 ? re() : E(n);
377
+ n === void 0 ? re() : D(n);
378
378
  }
379
379
  }, Ye = /* @__PURE__ */ new Set(), Xe = (e) => {
380
380
  Ye.has(e) || (Ye.add(e), console.warn(e));
@@ -382,7 +382,7 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
382
382
  let r = Qe, i;
383
383
  return () => {
384
384
  let a = t ?? w();
385
- return t !== void 0 && w() !== void 0 && t !== w() && Xe("[voltro:testing] this test passes `rowFilter:` while a DIFFERENT filter is registered via `setRowFilter`. The option wins, so this test does not exercise your app's registration. Drop `rowFilter:` to run the real process-global one."), (i === void 0 || a !== r) && (r = a, i = Je(n, () => T(me(a, e, (e) => {
385
+ return t !== void 0 && w() !== void 0 && t !== w() && Xe("[voltro:testing] this test passes `rowFilter:` while a DIFFERENT filter is registered via `setRowFilter`. The option wins, so this test does not exercise your app's registration. Drop `rowFilter:` to run the real process-global one."), (i === void 0 || a !== r) && (r = a, i = Je(n, () => E(pe(a, e, (e) => {
386
386
  console.error("[voltro:testing] row filter failed to load — reads refused for this subject", e);
387
387
  })))), i;
388
388
  };
@@ -391,24 +391,24 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
391
391
  let r = Reflect.get(e, n, e);
392
392
  return typeof r == "function" ? r.bind(e) : r;
393
393
  } }), et = (e = {}) => {
394
- if (ve({
394
+ if (_e({
395
395
  ...process.env,
396
396
  ...e.env ?? {}
397
- }), e.fieldEncryptionKey !== void 0 && _e(ue(e.fieldEncryptionKey)), e.relations !== void 0) {
397
+ }), e.fieldEncryptionKey !== void 0 && ge(le(e.fieldEncryptionKey)), e.relations !== void 0) {
398
398
  o();
399
399
  for (let t of e.relations) c(t);
400
400
  }
401
- let n = e.tables ?? t(), r = fe(n), i = new S(e.store ?? {}), a = {
401
+ let n = e.tables ?? t(), r = de(n), i = new S(e.store ?? {}), a = {
402
402
  dataStore: i,
403
403
  schemaRegistry: r
404
404
  };
405
- E(a);
406
- let s = new I(e.clockStart), l = new L(), u = R(), d = new z(e.llmResponses ?? []), f = Ke(() => s.now()), p = qe(() => s.now()), m = (t, n, o = i, c, h = !1) => {
405
+ D(a);
406
+ let s = new L(e.clockStart), l = new R(), u = z(), d = new B(e.llmResponses ?? []), f = Ke(() => s.now()), p = qe(() => s.now()), m = (t, n, o = i, c, h = !1) => {
407
407
  let g = {
408
408
  subject: t,
409
- traceId: B,
409
+ traceId: V,
410
410
  ...n === void 0 ? {} : { connection: n }
411
- }, _ = c?.queued ?? [], v = c?.nudges ?? [], y = le({
411
+ }, _ = c?.queued ?? [], v = c?.nudges ?? [], y = ce({
412
412
  bus: u.bus,
413
413
  tenantId: t.tenantId ?? null,
414
414
  ...o === i ? {} : { deferToCommit: (e) => {
@@ -418,7 +418,7 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
418
418
  } }
419
419
  }), b = se({ store: o }), x = h ? async () => C : Ze(t, e.rowFilter, a), S = {
420
420
  transaction: async (e, r) => {
421
- let a = he(t, r?.tenantId, o !== i);
421
+ let a = me(t, r?.tenantId, o !== i);
422
422
  if (a !== t) return m(a, n, i, void 0, !0).transaction(e);
423
423
  if (o !== i) return e(S);
424
424
  let s, c = await o.transactional(async (r) => {
@@ -444,22 +444,22 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
444
444
  access: ae(t),
445
445
  cache: f,
446
446
  kv: p,
447
- store: D($e(o, x), {
447
+ store: O($e(o, x), {
448
448
  subject: t,
449
449
  schemaRegistry: r,
450
450
  rowFilter: C
451
451
  }),
452
- storeForTenant: (e) => D($e(o, x), {
452
+ storeForTenant: (e) => O($e(o, x), {
453
453
  subject: ee(t, e),
454
454
  schemaRegistry: r,
455
455
  rowFilter: C
456
456
  }),
457
- outbox: de({
457
+ outbox: ue({
458
458
  store: o,
459
459
  subject: t,
460
- traceId: B,
460
+ traceId: V,
461
461
  nudge: () => {
462
- v.push(B);
462
+ v.push(V);
463
463
  },
464
464
  afterCommit: (e) => {
465
465
  _.push(e);
@@ -490,10 +490,10 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
490
490
  nudges: v
491
491
  })
492
492
  };
493
- return U.set(S, _), H.set(S, (e) => m(t, e, o, {
493
+ return W.set(S, _), U.set(S, (e) => m(t, e, o, {
494
494
  queued: _,
495
495
  nudges: v
496
- })), W.set(S, v), G.set(S, e.plugins ?? []), X.set(S, e.layers ?? []), V.set(S, (e) => o.transactional((r) => e(m(t, n, r, {
496
+ })), G.set(S, v), K.set(S, e.plugins ?? []), Be.set(S, e.layers ?? []), H.set(S, (e) => o.transactional((r) => e(m(t, n, r, {
497
497
  queued: _,
498
498
  nudges: v
499
499
  })))), S;
@@ -501,11 +501,11 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
501
501
  return m(e.subject ?? h(null), e.connection);
502
502
  }, tt = (e, t) => {
503
503
  let n = He(t);
504
- return (n === void 0 ? e : u.provide(e, n)).pipe(u.provide(ce(t.store)), u.provideService(m, t.request.subject));
504
+ return (n === void 0 ? e : u.provide(e, n)).pipe(u.provide(T(t.store)), u.provideService(m, t.request.subject));
505
505
  }, nt = async (e, t, n, r) => {
506
506
  let i = e.input, a = await p.decodeUnknownPromise(i)(n), o = e.kind, s = async (e) => {
507
507
  let n = t(a, e);
508
- return u.isEffect(n) ? T(tt(n, e)) : n;
508
+ return u.isEffect(n) ? E(tt(n, e)) : n;
509
509
  }, c = async () => {
510
510
  let t = e.guards;
511
511
  if (t !== void 0 && t.length > 0) {
@@ -513,14 +513,14 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
513
513
  if (e !== null) throw e;
514
514
  }
515
515
  if (o !== "mutation") return s(r);
516
- let n = await ge(async () => Ge(r, async (e) => (Ue(r), s(e))), { delay: () => Promise.resolve() });
516
+ let n = await he(async () => Ge(r, async (e) => (Ue(r), s(e))), { delay: () => Promise.resolve() });
517
517
  return await Z(r), n;
518
518
  }, f = o === "mutation" || o === "query" || o === "action" ? o : void 0, m = f === void 0 ? void 0 : Ve(r, f);
519
519
  if (m === void 0 || f === void 0) return await c();
520
520
  let h = u.tryPromise({
521
521
  try: () => c(),
522
522
  catch: (e) => e
523
- }), _ = Y(r), v = m(h, {
523
+ }), _ = X(r), v = m(h, {
524
524
  tag: e.name ?? "",
525
525
  kind: f,
526
526
  input: a,
@@ -535,7 +535,7 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
535
535
  if (d.isSuccess(y)) return y.value;
536
536
  throw l.squash(y.cause);
537
537
  }, rt = (e) => new Promise((t) => {
538
- let n = new ye.Socket(), r = (e) => {
538
+ let n = new ve.Socket(), r = (e) => {
539
539
  clearTimeout(i), n.destroy(), t(e);
540
540
  }, i = setTimeout(() => r(!1), e.timeoutMs ?? 750);
541
541
  n.once("connect", () => r(!0)), n.once("error", () => r(!1)), n.connect(e.port, e.host);
@@ -547,7 +547,7 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
547
547
  } catch {
548
548
  i = !1;
549
549
  }
550
- be.skipIf(!i)(i ? e : `${e} [SKIPPED: needs ${t}]`, r);
550
+ ye.skipIf(!i)(i ? e : `${e} [SKIPPED: needs ${t}]`, r);
551
551
  }, at = async (e, t, n) => {
552
552
  await it(e, `${t.name} at ${t.host}:${t.port}`, () => rt(t), n);
553
553
  }, ot = async (e, t) => {
@@ -578,11 +578,11 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
578
578
  for (let [n, r] of Object.entries(e)) t[n.toLowerCase()] = r;
579
579
  return t;
580
580
  }, ht = (e) => e === void 0 ? /* @__PURE__ */ new Uint8Array() : new TextEncoder().encode(JSON.stringify(e)), gt = (e) => e === void 0 ? "" : typeof e == "string" ? e : new TextDecoder().decode(e), _t = (e) => {
581
- let { ctx: t } = e, n = xe((e.publicApi ?? []).map((e) => ({
581
+ let { ctx: t } = e, n = be((e.publicApi ?? []).map((e) => ({
582
582
  descriptor: e.descriptor,
583
- invoke: (n, r) => t.withSubject(r.subject, (t) => (e.descriptor.publicApi !== void 0 && J(t, e.descriptor.publicApi), nt(e.descriptor, e.handler, n, t)))
583
+ invoke: (n, r) => t.withSubject(r.subject, (t) => (e.descriptor.publicApi !== void 0 && Y(t, e.descriptor.publicApi), nt(e.descriptor, e.handler, n, t)))
584
584
  })), {
585
- pluginErrors: K(t).flatMap((e) => e.errorSchemas ?? []),
585
+ pluginErrors: q(t).flatMap((e) => e.errorSchemas ?? []),
586
586
  ...e.publicApiProfile === void 0 ? {} : { profile: e.publicApiProfile }
587
587
  }), r = [...e.restRoutes ?? [], ...n], i = _(e.strategies ?? [], {
588
588
  ...e.anonymousTenantRequired === void 0 ? {} : { anonymousTenantRequired: e.anonymousTenantRequired },
@@ -596,7 +596,7 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
596
596
  clientId: -1
597
597
  })).subject : () => n,
598
598
  ...e.idempotency === void 0 ? {} : { idempotency: e.idempotency }
599
- }, c = Ce(r, s).map((e, t) => ({
599
+ }, c = Se(r, s).map((e, t) => ({
600
600
  pattern: r[t].path,
601
601
  route: e
602
602
  })), l = async (e, n, i = {}) => {
@@ -621,7 +621,7 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
621
621
  },
622
622
  rawBody: ht(i.body),
623
623
  store: t.store
624
- }, d = await Se(l, u), f = {};
624
+ }, d = await xe(l, u), f = {};
625
625
  for (let [e, t] of Object.entries(d.headers ?? {})) f[e.toLowerCase()] = t;
626
626
  d.contentType !== void 0 && (f["content-type"] = d.contentType);
627
627
  let p = gt(d.body), m = (d.contentType ?? "").includes("json");
@@ -664,7 +664,7 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
664
664
  } });
665
665
  return {
666
666
  id: t,
667
- log: e.log ?? we({ scope: `subscribe:${t}` }),
667
+ log: e.log ?? Ce({ scope: `subscribe:${t}` }),
668
668
  store: n,
669
669
  ...e.publish === void 0 ? {} : { publish: e.publish }
670
670
  };
@@ -700,24 +700,24 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
700
700
  start: async (i, a) => {
701
701
  let o = t.find((e) => e.workflow.name === i);
702
702
  if (o === void 0) throw Error(`makeWorkflowRunner: no workflow named '${i}' — pass it in makeWorkflowRunner({ ctx, workflows: [{ workflow, execute }] }).`);
703
- let s = `wfrun_test_${++r}`, c = De(), l = o.workflow.toLayer(o.execute).pipe(f.provideMerge(Ee)), d = /* @__PURE__ */ new Date(), p = o.workflow.execute(a).pipe(u.locally(Te, s), u.provide(c.layer), u.provide(l), u.either), m = await u.runPromise(p), h = yt(c.readSteps()), g = /* @__PURE__ */ new Date(), _;
704
- if (m._tag === "Right") _ = {
703
+ let s = `wfrun_test_${++r}`, c = Ee(), l = o.workflow.toLayer(o.execute).pipe(f.provideMerge(Te)), d = /* @__PURE__ */ new Date(), p = o.workflow.execute(a).pipe(u.locally(we, s), u.provide(c.layer), u.provide(l)), m = (e.ctx.store === void 0 ? p : u.provide(p, T(e.ctx.store))).pipe(u.either), h = await u.runPromise(m), g = yt(c.readSteps()), _ = /* @__PURE__ */ new Date(), v;
704
+ if (h._tag === "Right") v = {
705
705
  status: "succeeded",
706
- output: m.right,
706
+ output: h.right,
707
707
  error: null,
708
- steps: h,
708
+ steps: g,
709
709
  runId: s
710
710
  };
711
711
  else {
712
- let e = m.left;
713
- _ = {
712
+ let e = h.left;
713
+ v = {
714
714
  status: "failed",
715
715
  output: null,
716
716
  error: {
717
717
  tag: e && typeof e == "object" && "_tag" in e ? String(e._tag) : null,
718
- message: e && typeof e == "object" && "message" in e && typeof e.message == "string" ? e.message : String(m.left)
718
+ message: e && typeof e == "object" && "message" in e && typeof e.message == "string" ? e.message : String(h.left)
719
719
  },
720
- steps: h,
720
+ steps: g,
721
721
  runId: s
722
722
  };
723
723
  }
@@ -725,21 +725,21 @@ var Oe = new Set(e), O = 0, k = () => ++O, ke = (e, t) => {
725
725
  id: s,
726
726
  executionId: s,
727
727
  name: i,
728
- status: _.status,
728
+ status: v.status,
729
729
  input: a,
730
- output: _.output,
730
+ output: v.output,
731
731
  subject: e.ctx.request.subject,
732
732
  source: "test-runner",
733
- steps: h,
733
+ steps: g,
734
734
  startedAt: d,
735
- finishedAt: g,
735
+ finishedAt: _,
736
736
  traceId: null,
737
737
  parentExecutionId: null,
738
738
  parentClosePolicy: null
739
- }), _;
739
+ }), v;
740
740
  },
741
741
  inspect: async (e) => n.get(e) ?? null
742
742
  };
743
743
  }, xt = 1;
744
744
  //#endregion
745
- export { I as MockClock, z as MockLLM, L as MockWebhooks, xt as TESTING_PRESET_VERSION, st as TEST_TENANT_ID, dt as anonymous, lt as apiKey, n as changeDelete, r as changeInsert, i as changeSoftDelete, a as changeUpdate, Ne as defineFactory, it as describeIfAvailable, at as describeIfReachable, A as fixtureRow, Le as frozenTime, nt as invoke, rt as isTcpReachable, vt as makeSubscribeContext, _t as makeTestApp, et as makeTestContext, bt as makeWorkflowRunner, J as markRestInvocation, ze as mockStore, k as nextSequence, We as outboxNudgesOf, K as pluginsOf, ot as reportEngineVersion, Ue as resetAfterCommit, Y as restInvocationOf, Ve as rpcInterceptorFor, Z as runAfterCommit, Ge as runInStoreTransaction, ut as serviceAccount, He as serviceLayerFor, ft as system, R as testEventBus, ct as user, Ie as withFrozenTime, Be as withRpcConnection };
745
+ export { L as MockClock, B as MockLLM, R as MockWebhooks, xt as TESTING_PRESET_VERSION, st as TEST_TENANT_ID, dt as anonymous, lt as apiKey, n as changeDelete, r as changeInsert, i as changeSoftDelete, a as changeUpdate, Me as defineFactory, it as describeIfAvailable, at as describeIfReachable, j as fixtureRow, Ie as frozenTime, nt as invoke, rt as isTcpReachable, vt as makeSubscribeContext, _t as makeTestApp, et as makeTestContext, bt as makeWorkflowRunner, Y as markRestInvocation, Re as mockStore, A as nextSequence, We as outboxNudgesOf, q as pluginsOf, ot as reportEngineVersion, Ue as resetAfterCommit, X as restInvocationOf, Ve as rpcInterceptorFor, Z as runAfterCommit, Ge as runInStoreTransaction, ut as serviceAccount, He as serviceLayerFor, ft as system, z as testEventBus, ct as user, Fe as withFrozenTime, ze as withRpcConnection };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/testing",
3
- "version": "0.72.0",
3
+ "version": "0.73.0",
4
4
  "description": "Test utilities for Voltro apps — deterministic clock, subject and row factories, a handler-level invoke and a request-level app harness, queued LLM responses, scoped subject/tenant runners, and a cross-dialect parity harness.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -43,16 +43,16 @@
43
43
  "node": ">=24.0.0"
44
44
  },
45
45
  "dependencies": {
46
- "@voltro/database": "0.72.0",
47
- "@voltro/env": "0.72.0",
48
- "@voltro/logger": "0.72.0",
49
- "@voltro/protocol": "0.72.0",
50
- "@voltro/runtime": "0.72.0",
51
- "@voltro/workflow": "0.72.0"
46
+ "@voltro/database": "0.73.0",
47
+ "@voltro/env": "0.73.0",
48
+ "@voltro/logger": "0.73.0",
49
+ "@voltro/protocol": "0.73.0",
50
+ "@voltro/runtime": "0.73.0",
51
+ "@voltro/workflow": "0.73.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@effect/sql": "^0.52.1",
55
- "@voltro/client": "0.72.0",
55
+ "@voltro/client": "0.73.0",
56
56
  "effect": "^3.22.1",
57
57
  "react": "^19.0.0"
58
58
  },