@voltro/testing 0.83.1 → 0.85.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/CHANGELOG.md +1191 -0
- package/THIRD-PARTY-NOTICES.md +71 -525
- package/dist/client.d.ts +4 -9
- package/dist/client.js +5 -1
- package/dist/crdt.d.ts +11 -0
- package/dist/crdt.js +77 -0
- package/dist/dialect.d.ts +1 -1
- package/dist/dialect.js +400 -380
- package/dist/index.d.ts +7 -7
- package/dist/index.js +116 -116
- package/package.json +15 -10
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
-
import { Cause as l, Effect as u,
|
|
2
|
+
import { Cause as l, Effect as u, Exit as d, Layer as f, Result as p, Schema as m } from "effect";
|
|
3
3
|
import { ApiUnavailable as h, SubjectService as g, anonymousSubject as _, checkGuardsEffect as v, composeAuthStrategies as y, composeRpcInterceptors as b, eventRoute as x, systemSubject as S, tenantScopedSubject as ee } from "@voltro/protocol";
|
|
4
4
|
import { EventBus as te, InMemoryDataStore as ne, NO_ROW_FILTER as C, apiBindingTokenEnv as re, apiBindingUrlEnv as ie, appValidation as ae, applyRowFilterToDescriptor as oe, clearSystemStoreHandle as se, getFieldCipher as ce, getRowFilter as w, getSystemStoreHandle as le, makeAppAccess as ue, makeConnectionState as de, makeDataLoader as fe, makeEffectStoreLayer as T, makeEventPublisher as pe, makeFieldCipher as me, makeOutboxFacade as he, makeSchemaRegistry as ge, mintServiceToken as _e, publishEvent as ve, resolveRequestClientAddress as ye, resolveRowFilterScopeFor as be, resolveTransactionSubject as xe, resolveTrustedProxies as Se, runProvidedEffect as E, runWithDeadlockRetry as Ce, serviceCallerTokenEnv as we, setFieldCipher as Te, setSystemStoreHandle as D, wrapStoreWithMixinBehaviour as O } from "@voltro/runtime";
|
|
5
5
|
import { installEnvSnapshot as Ee } from "@voltro/env";
|
|
@@ -8,12 +8,12 @@ import { describe as De } from "vitest";
|
|
|
8
8
|
import { collectPublicApiRoutes as Oe, dispatchSharedPath as ke, restRoutesToHttpRoutes as Ae } from "@voltro/protocol/rest";
|
|
9
9
|
import { createLogger as je } from "@voltro/logger";
|
|
10
10
|
import { randomBytes as Me } from "node:crypto";
|
|
11
|
-
import { CurrentWorkflowRunId as Ne,
|
|
12
|
-
import { spawn as
|
|
13
|
-
import { createRequire as
|
|
14
|
-
import { dirname as
|
|
11
|
+
import { CurrentWorkflowRunId as Ne, failureMessage as Pe, getWorkflowJournalCipher as Fe, inMemoryWorkflowEngineLayer as Ie, makeInMemoryRecorder as Le, setWorkflowJournalCipher as Re } from "@voltro/workflow";
|
|
12
|
+
import { spawn as ze } from "node:child_process";
|
|
13
|
+
import { createRequire as Be } from "node:module";
|
|
14
|
+
import { dirname as Ve, join as A } from "node:path";
|
|
15
15
|
//#region src/fixtureRow.ts
|
|
16
|
-
var
|
|
16
|
+
var He = new Set(e), j = 0, M = () => ++j, Ue = (e, t) => {
|
|
17
17
|
if (t.oneOf && t.oneOf.length > 0) return t.oneOf[0];
|
|
18
18
|
if (t.enumValues && t.enumValues.length > 0) return t.enumValues[0];
|
|
19
19
|
let n = t.unique === !0;
|
|
@@ -33,16 +33,16 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
33
33
|
}
|
|
34
34
|
}, N = (e, t = {}) => {
|
|
35
35
|
let n = {};
|
|
36
|
-
for (let r of s(e, t))
|
|
36
|
+
for (let r of s(e, t)) He.has(r) || (n[r] = Ue(r, e.fields[r]));
|
|
37
37
|
return {
|
|
38
38
|
...n,
|
|
39
39
|
...t
|
|
40
40
|
};
|
|
41
|
-
}, P = m.
|
|
42
|
-
if (typeof e != "string" || !
|
|
41
|
+
}, P = m.decodeUnknownResult(m.DateFromString), We = /^\d{4}-\d{2}-\d{2}$/, Ge = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/, Ke = (e, t) => {
|
|
42
|
+
if (typeof e != "string" || !Ge.test(e) && !(t === "date" && We.test(e))) return !1;
|
|
43
43
|
let n = e.slice(0, 10), r = P(n);
|
|
44
|
-
return
|
|
45
|
-
},
|
|
44
|
+
return p.isSuccess(r) && Number.isFinite(r.success.getTime()) && r.success.toISOString().slice(0, 10) === n;
|
|
45
|
+
}, qe = (e, t) => {
|
|
46
46
|
let n = Object.entries(e.fields).filter(([, e]) => e.type === "timestamp" || e.type === "date");
|
|
47
47
|
return t.map((t, r) => {
|
|
48
48
|
let i = { ...t };
|
|
@@ -50,19 +50,19 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
50
50
|
let n = t[a];
|
|
51
51
|
if (n == null || n instanceof Date && Number.isFinite(n.getTime())) continue;
|
|
52
52
|
let s = P(n);
|
|
53
|
-
if (!
|
|
54
|
-
i[a] = s.
|
|
53
|
+
if (!Ke(n, o.type) || p.isFailure(s) || !Number.isFinite(s.success.getTime())) throw TypeError(`hydrateFixtureRows: table '${e.tableName}', row ${r}, column '${a}' requires a valid Date or ISO date-time with Z or an offset${o.type === "date" ? " (YYYY-MM-DD is also accepted as UTC midnight)" : ""}.`);
|
|
54
|
+
i[a] = s.success;
|
|
55
55
|
}
|
|
56
56
|
return i;
|
|
57
57
|
});
|
|
58
|
-
},
|
|
58
|
+
}, Je = (e) => {
|
|
59
59
|
let t = {};
|
|
60
60
|
for (let [n, r] of Object.entries(e)) t[n] = typeof r == "function" ? r(M()) : r;
|
|
61
61
|
return t;
|
|
62
|
-
},
|
|
62
|
+
}, Ye = (e) => {
|
|
63
63
|
for (let [t, n] of Object.entries(e.fields)) if (n.type === "id") return t;
|
|
64
64
|
return "id";
|
|
65
|
-
},
|
|
65
|
+
}, Xe = async (e, t, n, r, i) => {
|
|
66
66
|
let a = {};
|
|
67
67
|
for (let o of s(t, n)) {
|
|
68
68
|
let n = t.fields[o];
|
|
@@ -70,29 +70,29 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
70
70
|
let s = n.references();
|
|
71
71
|
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 }).`);
|
|
72
72
|
let c = r[o];
|
|
73
|
-
a[o] = (c === void 0 ? await F(e, s, {}, {}, [...i, s.tableName]) : await c.create(e, {}))[n.referenceColumn ??
|
|
73
|
+
a[o] = (c === void 0 ? await F(e, s, {}, {}, [...i, s.tableName]) : await c.create(e, {}))[n.referenceColumn ?? Ye(s)];
|
|
74
74
|
}
|
|
75
75
|
return a;
|
|
76
76
|
}, F = async (e, t, n, r, i) => {
|
|
77
77
|
let a = {
|
|
78
|
-
...await
|
|
78
|
+
...await Xe(e, t, n, r, i),
|
|
79
79
|
...n
|
|
80
80
|
};
|
|
81
81
|
return e.insert(t.tableName, N(t, a));
|
|
82
|
-
},
|
|
82
|
+
}, Ze = (e, t) => typeof e == "function" ? e(t) : e ?? {}, Qe = (e, t = {}) => {
|
|
83
83
|
let n = t.traits ?? {}, r = t.associations ?? {}, i = (t) => {
|
|
84
84
|
let a = (e = {}) => ({
|
|
85
|
-
...
|
|
85
|
+
...Je(t),
|
|
86
86
|
...e
|
|
87
87
|
}), o = (t = {}) => N(e, a(t));
|
|
88
88
|
return {
|
|
89
89
|
table: e,
|
|
90
90
|
build: o,
|
|
91
|
-
buildList: (e, t) => Array.from({ length: e }, (e, n) => o(
|
|
91
|
+
buildList: (e, t) => Array.from({ length: e }, (e, n) => o(Ze(t, n))),
|
|
92
92
|
create: (t, n = {}) => F(t, e, a(n), r, [e.tableName]),
|
|
93
93
|
createList: async (t, n, i) => {
|
|
94
94
|
let o = [];
|
|
95
|
-
for (let s = 0; s < n; s++) o.push(await F(t, e, a(
|
|
95
|
+
for (let s = 0; s < n; s++) o.push(await F(t, e, a(Ze(i, s)), r, [e.tableName]));
|
|
96
96
|
return o;
|
|
97
97
|
},
|
|
98
98
|
with: (...r) => {
|
|
@@ -114,7 +114,7 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
114
114
|
};
|
|
115
115
|
};
|
|
116
116
|
return i(t.defaults ?? {});
|
|
117
|
-
}, I = Symbol.for("voltro/testing/mockClock.installed"), L = () => globalThis,
|
|
117
|
+
}, I = Symbol.for("voltro/testing/mockClock.installed"), L = () => globalThis, $e = (e, t) => new Proxy(e, {
|
|
118
118
|
construct: (e, n, r) => Reflect.construct(e, n.length === 0 ? [t()] : n, r),
|
|
119
119
|
apply: () => new e(t()).toString(),
|
|
120
120
|
get: (e, n, r) => n === "now" ? () => t() : Reflect.get(e, n, r)
|
|
@@ -135,7 +135,7 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
135
135
|
return new Date(this.currentMs);
|
|
136
136
|
}
|
|
137
137
|
advance(e) {
|
|
138
|
-
this.currentMs += typeof e == "number" ? e :
|
|
138
|
+
this.currentMs += typeof e == "number" ? e : rt(e);
|
|
139
139
|
}
|
|
140
140
|
set(e) {
|
|
141
141
|
this.currentMs = R(e);
|
|
@@ -150,7 +150,7 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
150
150
|
return e[I] = {
|
|
151
151
|
realDate: n,
|
|
152
152
|
clock: this
|
|
153
|
-
}, globalThis.Date =
|
|
153
|
+
}, globalThis.Date = $e(n, () => this.currentMs), () => {
|
|
154
154
|
this.uninstall();
|
|
155
155
|
};
|
|
156
156
|
}
|
|
@@ -158,24 +158,24 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
158
158
|
let e = L(), t = e[I];
|
|
159
159
|
t !== void 0 && t.clock === this && (globalThis.Date = t.realDate, delete e[I]);
|
|
160
160
|
}
|
|
161
|
-
},
|
|
161
|
+
}, et = (e) => typeof e == "object" && !!e && typeof e.then == "function", tt = (e, t) => {
|
|
162
162
|
let n = e instanceof z ? e : new z(e);
|
|
163
163
|
n.install();
|
|
164
164
|
let r = !1;
|
|
165
165
|
try {
|
|
166
166
|
let e = t(n);
|
|
167
|
-
return
|
|
167
|
+
return et(e) ? (r = !0, e.then((e) => (n.uninstall(), e), (e) => {
|
|
168
168
|
throw n.uninstall(), e;
|
|
169
169
|
})) : e;
|
|
170
170
|
} finally {
|
|
171
171
|
r || n.uninstall();
|
|
172
172
|
}
|
|
173
|
-
},
|
|
173
|
+
}, nt = (e) => u.acquireRelease(u.sync(() => {
|
|
174
174
|
let t = e instanceof z ? e : new z(e);
|
|
175
175
|
return t.install(), t;
|
|
176
176
|
}), (e) => u.sync(() => {
|
|
177
177
|
e.uninstall();
|
|
178
|
-
})),
|
|
178
|
+
})), rt = (e) => {
|
|
179
179
|
let t = /^\s*(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)\s*$/.exec(e);
|
|
180
180
|
if (!t) throw Error(`mockClock: cannot parse duration '${e}'`);
|
|
181
181
|
let n = Number(t[1]), r = t[2];
|
|
@@ -216,15 +216,15 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
216
216
|
});
|
|
217
217
|
return {
|
|
218
218
|
publish: async (e, r, i) => {
|
|
219
|
-
let a = await u.runPromise(u.
|
|
219
|
+
let a = await u.runPromise(u.result(ve({
|
|
220
220
|
bus: n,
|
|
221
221
|
tenantId: t
|
|
222
222
|
}, e, r, i)));
|
|
223
|
-
if (a
|
|
224
|
-
let t = a.
|
|
223
|
+
if (p.isFailure(a)) {
|
|
224
|
+
let t = a.failure;
|
|
225
225
|
throw Error(`testEventBus.publish(${e.name}) was rejected: ${t._tag}`, { cause: t });
|
|
226
226
|
}
|
|
227
|
-
return { n: a.
|
|
227
|
+
return { n: a.success.n };
|
|
228
228
|
},
|
|
229
229
|
subscribe: (e, r, i) => {
|
|
230
230
|
let a = [], o = [];
|
|
@@ -294,7 +294,7 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
294
294
|
remaining() {
|
|
295
295
|
return this.queue.length;
|
|
296
296
|
}
|
|
297
|
-
},
|
|
297
|
+
}, it = (e) => e, U = "00000000000000000000000000000000", W = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), at = (e, t) => {
|
|
298
298
|
let n = G.get(e);
|
|
299
299
|
if (n === void 0) throw Error("withRpcConnection requires a context created by makeTestContext");
|
|
300
300
|
return n(t);
|
|
@@ -303,17 +303,17 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
303
303
|
publicApi: t,
|
|
304
304
|
...n === void 0 ? {} : { remoteAddr: n }
|
|
305
305
|
});
|
|
306
|
-
},
|
|
306
|
+
}, ot = (e) => X.get(e), st = /* @__PURE__ */ new WeakMap(), ct = (e, t) => {
|
|
307
307
|
let n = J.get(e) ?? [], r = t === "mutation" ? "interceptMutation" : t === "query" ? "interceptQuery" : "interceptAction", i = [];
|
|
308
308
|
for (let e of n) {
|
|
309
309
|
let t = e[r];
|
|
310
310
|
typeof t == "function" && i.push(t);
|
|
311
311
|
}
|
|
312
312
|
return b(i);
|
|
313
|
-
}, ct = (e) => {
|
|
314
|
-
let t = (J.get(e) ?? []).map((e) => e.services).filter((e) => e !== void 0), n = ot.get(e) ?? [], r = [...t, ...n];
|
|
315
|
-
if (r.length !== 0) return p.mergeAll(...r);
|
|
316
313
|
}, lt = (e) => {
|
|
314
|
+
let t = (J.get(e) ?? []).map((e) => e.services).filter((e) => e !== void 0), n = st.get(e) ?? [], r = [...t, ...n];
|
|
315
|
+
if (r.length !== 0) return f.mergeAll(...r);
|
|
316
|
+
}, ut = (e) => {
|
|
317
317
|
let t = K.get(e);
|
|
318
318
|
t !== void 0 && (t.length = 0);
|
|
319
319
|
}, Q = async (e) => {
|
|
@@ -322,13 +322,13 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
322
322
|
let n = [...t];
|
|
323
323
|
t.length = 0;
|
|
324
324
|
for (let e of n) await e();
|
|
325
|
-
},
|
|
325
|
+
}, dt = (e) => q.get(e) ?? [], ft = async (e, t) => {
|
|
326
326
|
let n = W.get(e);
|
|
327
327
|
return n === void 0 ? e.store.transactional(async (n) => t({
|
|
328
328
|
...e,
|
|
329
329
|
store: n
|
|
330
330
|
})) : n(t);
|
|
331
|
-
},
|
|
331
|
+
}, pt = (e) => {
|
|
332
332
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = (n) => {
|
|
333
333
|
let r = t.get(n);
|
|
334
334
|
return r === void 0 ? !1 : r.expiresAt !== null && r.expiresAt <= e() ? (t.delete(n), !1) : !0;
|
|
@@ -367,7 +367,7 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
367
367
|
return i(e, o, n.ttlMs, n.tags), o;
|
|
368
368
|
}
|
|
369
369
|
};
|
|
370
|
-
},
|
|
370
|
+
}, mt = (e) => {
|
|
371
371
|
let t = /* @__PURE__ */ new Map(), n = (n) => {
|
|
372
372
|
let r = t.get(n);
|
|
373
373
|
return r === void 0 ? !1 : r.expiresAt !== null && r.expiresAt <= e() ? (t.delete(n), !1) : !0;
|
|
@@ -395,7 +395,7 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
395
395
|
t.clear();
|
|
396
396
|
}
|
|
397
397
|
};
|
|
398
|
-
},
|
|
398
|
+
}, ht = async (e, t) => {
|
|
399
399
|
let n = le();
|
|
400
400
|
D(e);
|
|
401
401
|
try {
|
|
@@ -403,21 +403,21 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
403
403
|
} finally {
|
|
404
404
|
n === void 0 ? se() : D(n);
|
|
405
405
|
}
|
|
406
|
-
},
|
|
407
|
-
|
|
408
|
-
},
|
|
409
|
-
let r =
|
|
406
|
+
}, gt = /* @__PURE__ */ new Set(), _t = (e) => {
|
|
407
|
+
gt.has(e) || (gt.add(e), console.warn(e));
|
|
408
|
+
}, vt = (e, t, n) => {
|
|
409
|
+
let r = yt, i;
|
|
410
410
|
return () => {
|
|
411
411
|
let a = t ?? w();
|
|
412
|
-
return t !== void 0 && w() !== void 0 && t !== w() &&
|
|
412
|
+
return t !== void 0 && w() !== void 0 && t !== w() && _t("[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 = ht(n, () => E(be(a, e, (e) => {
|
|
413
413
|
console.error("[voltro:testing] row filter failed to load — reads refused for this subject", e);
|
|
414
414
|
})))), i;
|
|
415
415
|
};
|
|
416
|
-
},
|
|
416
|
+
}, yt = Symbol("unresolved"), bt = (e, t) => new Proxy(e, { get: (e, n) => {
|
|
417
417
|
if (n === "query") return async (n) => e.query(oe(await t(), n));
|
|
418
418
|
let r = Reflect.get(e, n, e);
|
|
419
419
|
return typeof r == "function" ? r.bind(e) : r;
|
|
420
|
-
} }),
|
|
420
|
+
} }), xt = (e = {}) => {
|
|
421
421
|
if (Ee({
|
|
422
422
|
...process.env,
|
|
423
423
|
...e.env ?? {}
|
|
@@ -432,7 +432,7 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
432
432
|
schemaRegistry: r
|
|
433
433
|
};
|
|
434
434
|
D(a);
|
|
435
|
-
let s = new z(e.clockStart), l = new B(), u = V(), d = new H(e.llmResponses ?? []), f =
|
|
435
|
+
let s = new z(e.clockStart), l = new B(), u = V(), d = new H(e.llmResponses ?? []), f = pt(() => s.now()), p = mt(() => s.now()), m = (t, n, o = i, c, h = !1) => {
|
|
436
436
|
let g = {
|
|
437
437
|
subject: t,
|
|
438
438
|
traceId: U,
|
|
@@ -445,7 +445,7 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
445
445
|
e();
|
|
446
446
|
});
|
|
447
447
|
} }
|
|
448
|
-
}), b = fe({ store: o }), x = h ? async () => C :
|
|
448
|
+
}), b = fe({ store: o }), x = h ? async () => C : vt(t, e.rowFilter, a), S = {
|
|
449
449
|
apis: e.apis ?? Object.freeze({}),
|
|
450
450
|
transaction: async (e, r) => {
|
|
451
451
|
let a = xe(t, r?.tenantId, o !== i);
|
|
@@ -458,7 +458,7 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
458
458
|
}, h), a = await e(i);
|
|
459
459
|
return s = i, a;
|
|
460
460
|
});
|
|
461
|
-
return s !== void 0 && (await Q(s), v.push(...
|
|
461
|
+
return s !== void 0 && (await Q(s), v.push(...dt(s))), c;
|
|
462
462
|
},
|
|
463
463
|
clock: s,
|
|
464
464
|
webhooks: l,
|
|
@@ -474,12 +474,12 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
474
474
|
access: ue(t),
|
|
475
475
|
cache: f,
|
|
476
476
|
kv: p,
|
|
477
|
-
store: O(
|
|
477
|
+
store: O(bt(o, x), {
|
|
478
478
|
subject: t,
|
|
479
479
|
schemaRegistry: r,
|
|
480
480
|
rowFilter: C
|
|
481
481
|
}),
|
|
482
|
-
storeForTenant: (e) => O(
|
|
482
|
+
storeForTenant: (e) => O(bt(o, x), {
|
|
483
483
|
subject: ee(t, e),
|
|
484
484
|
schemaRegistry: r,
|
|
485
485
|
rowFilter: C
|
|
@@ -523,19 +523,19 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
523
523
|
return K.set(S, _), G.set(S, (e) => m(t, e, o, {
|
|
524
524
|
queued: _,
|
|
525
525
|
nudges: v
|
|
526
|
-
})), q.set(S, v), J.set(S, e.plugins ?? []),
|
|
526
|
+
})), q.set(S, v), J.set(S, e.plugins ?? []), st.set(S, e.layers ?? []), W.set(S, (e) => o.transactional((r) => e(m(t, n, r, {
|
|
527
527
|
queued: _,
|
|
528
528
|
nudges: v
|
|
529
529
|
})))), S;
|
|
530
530
|
};
|
|
531
531
|
return m(e.subject ?? _(null), e.connection);
|
|
532
|
-
},
|
|
533
|
-
let n =
|
|
532
|
+
}, St = (e, t) => {
|
|
533
|
+
let n = lt(t);
|
|
534
534
|
return (n === void 0 ? e : u.provide(e, n)).pipe(u.provide(T(t.store)), u.provideService(g, t.request.subject));
|
|
535
|
-
},
|
|
535
|
+
}, Ct = async (e, t, n, r) => {
|
|
536
536
|
let i = e.input, a = await m.decodeUnknownPromise(i)(n), o = e.kind, s = async (e) => {
|
|
537
537
|
let n = t(a, e);
|
|
538
|
-
return u.isEffect(n) ? E(
|
|
538
|
+
return u.isEffect(n) ? E(St(n, e)) : n;
|
|
539
539
|
}, c = async () => {
|
|
540
540
|
let t = e.guards;
|
|
541
541
|
if (t !== void 0 && t.length > 0) {
|
|
@@ -543,16 +543,16 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
543
543
|
if (e !== null) throw e;
|
|
544
544
|
}
|
|
545
545
|
if (o !== "mutation") return s(r);
|
|
546
|
-
let n = await Ce(async () =>
|
|
546
|
+
let n = await Ce(async () => ft(r, async (e) => (ut(r), s(e))), { delay: () => Promise.resolve() });
|
|
547
547
|
return await Q(r), n;
|
|
548
|
-
},
|
|
549
|
-
if (p === void 0 ||
|
|
548
|
+
}, f = o === "mutation" || o === "query" || o === "action" ? o : void 0, p = f === void 0 ? void 0 : ct(r, f);
|
|
549
|
+
if (p === void 0 || f === void 0) return await c();
|
|
550
550
|
let h = u.tryPromise({
|
|
551
551
|
try: () => c(),
|
|
552
552
|
catch: (e) => e
|
|
553
|
-
}), g =
|
|
553
|
+
}), g = ot(r), _ = p(h, {
|
|
554
554
|
tag: e.name ?? "",
|
|
555
|
-
kind:
|
|
555
|
+
kind: f,
|
|
556
556
|
input: a,
|
|
557
557
|
subject: r.request.subject,
|
|
558
558
|
traceId: r.request.traceId,
|
|
@@ -563,14 +563,14 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
563
563
|
},
|
|
564
564
|
...g?.remoteAddr === void 0 ? {} : { remoteAddr: g.remoteAddr }
|
|
565
565
|
}), y = await u.runPromiseExit(_);
|
|
566
|
-
if (
|
|
566
|
+
if (d.isSuccess(y)) return y.value;
|
|
567
567
|
throw l.squash(y.cause);
|
|
568
|
-
},
|
|
568
|
+
}, wt = (e) => new Promise((t) => {
|
|
569
569
|
let n = new k.Socket(), r = (e) => {
|
|
570
570
|
clearTimeout(i), n.destroy(), t(e);
|
|
571
571
|
}, i = setTimeout(() => r(!1), e.timeoutMs ?? 750);
|
|
572
572
|
n.once("connect", () => r(!0)), n.once("error", () => r(!1)), n.connect(e.port, e.host);
|
|
573
|
-
}),
|
|
573
|
+
}), Tt = async (e, t, n, r) => {
|
|
574
574
|
if (typeof t != "string" || typeof n != "function" || typeof r != "function") throw TypeError(`describeIfAvailable('${e}', ...): expected (label, dependency, probe, suite) — got dependency: ${typeof t}, probe: ${typeof n}, suite: ${typeof r}. Three arguments means the suite body is being used as the probe: it would run at file scope, unconditionally, and the skip would silently do nothing.`);
|
|
575
575
|
let i = !1;
|
|
576
576
|
try {
|
|
@@ -579,20 +579,20 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
579
579
|
i = !1;
|
|
580
580
|
}
|
|
581
581
|
De.skipIf(!i)(i ? e : `${e} [SKIPPED: needs ${t}]`, r);
|
|
582
|
-
},
|
|
583
|
-
await
|
|
584
|
-
},
|
|
582
|
+
}, Et = async (e, t, n) => {
|
|
583
|
+
await Tt(e, `${t.name} at ${t.host}:${t.port}`, () => wt(t), n);
|
|
584
|
+
}, Dt = async (e, t) => {
|
|
585
585
|
try {
|
|
586
586
|
let n = await t();
|
|
587
587
|
n !== void 0 && n !== "" && console.log(`[engine] ${e}: ${n}`);
|
|
588
588
|
} catch {}
|
|
589
|
-
},
|
|
589
|
+
}, Ot = "test-tenant", $ = (e, t, n) => ({
|
|
590
590
|
type: e,
|
|
591
591
|
id: t,
|
|
592
592
|
tenantId: n.tenantId ?? "test-tenant",
|
|
593
593
|
scopes: n.scopes ?? [],
|
|
594
594
|
...n.metadata === void 0 ? {} : { metadata: n.metadata }
|
|
595
|
-
}),
|
|
595
|
+
}), kt = (e, t = {}) => $("user", e, t), At = (e, t = {}) => $("apiKey", e, t), jt = (e, t = {}) => $("serviceAccount", e, t), Mt = (e = null) => _(e), Nt = (e = "job:test", t) => t === void 0 ? S(e) : S(e, t), Pt = "127.0.0.1", Ft = (e) => {
|
|
596
596
|
let t = e.indexOf("?");
|
|
597
597
|
return t === -1 ? {
|
|
598
598
|
path: e,
|
|
@@ -601,17 +601,17 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
601
601
|
path: e.slice(0, t),
|
|
602
602
|
query: e.slice(t + 1)
|
|
603
603
|
};
|
|
604
|
-
},
|
|
604
|
+
}, It = (e, t) => {
|
|
605
605
|
let n = e.split("/").filter((e) => e.length > 0), r = t.split("/").filter((e) => e.length > 0);
|
|
606
606
|
return n.length === r.length && n.every((e, t) => e.startsWith(":") || e === r[t]);
|
|
607
|
-
},
|
|
607
|
+
}, Lt = (e) => {
|
|
608
608
|
let t = {};
|
|
609
609
|
for (let [n, r] of Object.entries(e)) t[n.toLowerCase()] = r;
|
|
610
610
|
return t;
|
|
611
|
-
},
|
|
611
|
+
}, Rt = (e) => e === void 0 ? /* @__PURE__ */ new Uint8Array() : new TextEncoder().encode(JSON.stringify(e)), zt = (e) => e === void 0 ? "" : typeof e == "string" ? e : new TextDecoder().decode(e), Bt = (e) => {
|
|
612
612
|
let t = Se(e.security?.trustedProxies, process.env, e.security?.clientAddressHeader), { ctx: n } = e, r = Oe((e.publicApi ?? []).map((e) => ({
|
|
613
613
|
descriptor: e.descriptor,
|
|
614
|
-
invoke: (t, r) => n.withSubject(r.subject, (n) => (e.descriptor.publicApi !== void 0 && Z(n, e.descriptor.publicApi, r.remoteAddr),
|
|
614
|
+
invoke: (t, r) => n.withSubject(r.subject, (n) => (e.descriptor.publicApi !== void 0 && Z(n, e.descriptor.publicApi, r.remoteAddr), Ct(e.descriptor, e.handler, t, n)))
|
|
615
615
|
})), {
|
|
616
616
|
pluginErrors: Y(n).flatMap((e) => e.errorSchemas ?? []),
|
|
617
617
|
...e.publicApiProfile === void 0 ? {} : { profile: e.publicApiProfile }
|
|
@@ -631,7 +631,7 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
631
631
|
pattern: i[t].path,
|
|
632
632
|
route: e
|
|
633
633
|
})), u = async (e, r, a = {}) => {
|
|
634
|
-
let { path: o, query: c } =
|
|
634
|
+
let { path: o, query: c } = Ft(r), u = l.filter((e) => It(e.pattern, o)).map((e) => e.route);
|
|
635
635
|
if (u.length === 0) return {
|
|
636
636
|
status: 404,
|
|
637
637
|
headers: {},
|
|
@@ -643,10 +643,10 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
643
643
|
stream: !1
|
|
644
644
|
};
|
|
645
645
|
let d = {
|
|
646
|
-
...
|
|
647
|
-
...
|
|
646
|
+
...Lt(s),
|
|
647
|
+
...Lt(a.headers ?? {})
|
|
648
648
|
}, f = ye({
|
|
649
|
-
socketAddress: a.remoteAddr ??
|
|
649
|
+
socketAddress: a.remoteAddr ?? Pt,
|
|
650
650
|
headers: d,
|
|
651
651
|
config: t
|
|
652
652
|
}), p = {
|
|
@@ -654,13 +654,13 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
654
654
|
path: o,
|
|
655
655
|
query: c,
|
|
656
656
|
headers: d,
|
|
657
|
-
rawBody:
|
|
657
|
+
rawBody: Rt(a.body),
|
|
658
658
|
store: n.store,
|
|
659
659
|
...f === void 0 ? {} : { remoteAddr: f }
|
|
660
660
|
}, m = await ke(u, p), h = {};
|
|
661
661
|
for (let [e, t] of Object.entries(m.headers ?? {})) h[e.toLowerCase()] = t;
|
|
662
662
|
m.contentType !== void 0 && (h["content-type"] = m.contentType);
|
|
663
|
-
let g =
|
|
663
|
+
let g = zt(m.body), _ = (m.contentType ?? "").includes("json");
|
|
664
664
|
return {
|
|
665
665
|
status: m.status,
|
|
666
666
|
headers: h,
|
|
@@ -694,7 +694,7 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
694
694
|
};
|
|
695
695
|
};
|
|
696
696
|
return o(void 0, {});
|
|
697
|
-
},
|
|
697
|
+
}, Vt = (e = {}) => {
|
|
698
698
|
let t = e.id ?? "test", n = e.store ?? new Proxy({}, { get: (e, t) => {
|
|
699
699
|
throw Error(`makeSubscribeContext: this subscriber reached ctx.store.${String(t)} and the test passed no store. Pass \`{ store: makeTestContext().store }\` so the subscriber and the code under test share one — an empty stand-in would let a read of the wrong table pass.`);
|
|
700
700
|
} });
|
|
@@ -704,7 +704,7 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
704
704
|
store: n,
|
|
705
705
|
...e.publish === void 0 ? {} : { publish: e.publish }
|
|
706
706
|
};
|
|
707
|
-
},
|
|
707
|
+
}, Ht = (e) => {
|
|
708
708
|
let t = /* @__PURE__ */ new Map();
|
|
709
709
|
for (let n of e) {
|
|
710
710
|
let e = t.get(n.stepName);
|
|
@@ -730,35 +730,35 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
730
730
|
});
|
|
731
731
|
}
|
|
732
732
|
return n.sort((e, t) => e._startedAt - t._startedAt), n.map(({ _startedAt: e, ...t }) => t);
|
|
733
|
-
},
|
|
734
|
-
if (
|
|
733
|
+
}, Ut = () => {
|
|
734
|
+
if (Fe() !== void 0) return;
|
|
735
735
|
let e = me(Me(32).toString("hex"));
|
|
736
|
-
|
|
737
|
-
},
|
|
738
|
-
|
|
736
|
+
Re(() => ce() ?? e);
|
|
737
|
+
}, Wt = (e) => {
|
|
738
|
+
Ut();
|
|
739
739
|
let t = e.workflows ?? [], n = /* @__PURE__ */ new Map(), r = 0;
|
|
740
740
|
return {
|
|
741
741
|
start: async (i, a) => {
|
|
742
742
|
let o = t.find((e) => e.workflow.name === i);
|
|
743
743
|
if (o === void 0) throw Error(`makeWorkflowRunner: no workflow named '${i}' — pass it in makeWorkflowRunner({ ctx, workflows: [{ workflow, execute }] }).`);
|
|
744
|
-
let s = `wfrun_test_${++r}`, c =
|
|
745
|
-
if (
|
|
744
|
+
let s = `wfrun_test_${++r}`, c = Le(), l = o.workflow.toLayer(o.execute).pipe(f.provideMerge(Ie)), d = /* @__PURE__ */ new Date(), m = o.workflow.execute(a).pipe(u.provideService(Ne, s), u.provide(c.layer), u.provide(l)), h = (e.ctx.store === void 0 ? m : u.provide(m, T(e.ctx.store))).pipe(u.result), g = await u.runPromise(h), _ = Ht(c.readSteps()), v = /* @__PURE__ */ new Date(), y;
|
|
745
|
+
if (p.isSuccess(g)) y = {
|
|
746
746
|
status: "succeeded",
|
|
747
|
-
output:
|
|
747
|
+
output: g.success,
|
|
748
748
|
error: null,
|
|
749
|
-
steps:
|
|
749
|
+
steps: _,
|
|
750
750
|
runId: s
|
|
751
751
|
};
|
|
752
752
|
else {
|
|
753
|
-
let e =
|
|
754
|
-
|
|
753
|
+
let e = g.failure;
|
|
754
|
+
y = {
|
|
755
755
|
status: "failed",
|
|
756
756
|
output: null,
|
|
757
757
|
error: {
|
|
758
758
|
tag: e && typeof e == "object" && "_tag" in e ? String(e._tag) : null,
|
|
759
|
-
message:
|
|
759
|
+
message: Pe(g.failure)
|
|
760
760
|
},
|
|
761
|
-
steps:
|
|
761
|
+
steps: _,
|
|
762
762
|
runId: s
|
|
763
763
|
};
|
|
764
764
|
}
|
|
@@ -766,22 +766,22 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
766
766
|
id: s,
|
|
767
767
|
executionId: s,
|
|
768
768
|
name: i,
|
|
769
|
-
status:
|
|
769
|
+
status: y.status,
|
|
770
770
|
input: a,
|
|
771
|
-
output:
|
|
771
|
+
output: y.output,
|
|
772
772
|
subject: e.ctx.request.subject,
|
|
773
773
|
source: "test-runner",
|
|
774
|
-
steps:
|
|
774
|
+
steps: _,
|
|
775
775
|
startedAt: d,
|
|
776
|
-
finishedAt:
|
|
776
|
+
finishedAt: v,
|
|
777
777
|
traceId: null,
|
|
778
778
|
parentExecutionId: null,
|
|
779
779
|
parentClosePolicy: null
|
|
780
|
-
}),
|
|
780
|
+
}), y;
|
|
781
781
|
},
|
|
782
782
|
inspect: async (e) => n.get(e) ?? null
|
|
783
783
|
};
|
|
784
|
-
},
|
|
784
|
+
}, Gt = (e, t, n = {}) => {
|
|
785
785
|
let r = n.name ?? "mock", i = [], a = /* @__PURE__ */ new Map(), o = (e, t) => `${e}\u0000${JSON.stringify(t)}`, s = async (n, a, o) => {
|
|
786
786
|
let s = e[n];
|
|
787
787
|
if (s === void 0) throw Error(`makeServiceApiMock: '${n}' is not a service procedure of this api`);
|
|
@@ -828,31 +828,31 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
828
828
|
for (let e of a.get(o(t, n)) ?? []) e(s);
|
|
829
829
|
}
|
|
830
830
|
};
|
|
831
|
-
},
|
|
831
|
+
}, Kt = () => new Promise((e, t) => {
|
|
832
832
|
let n = k.createServer();
|
|
833
833
|
n.once("error", t), n.listen(0, "127.0.0.1", () => {
|
|
834
834
|
let t = n.address(), r = typeof t == "object" && t ? t.port : 0;
|
|
835
835
|
n.close(() => e(r));
|
|
836
836
|
});
|
|
837
|
-
}),
|
|
837
|
+
}), qt = async (e) => {
|
|
838
838
|
try {
|
|
839
839
|
return (await fetch(`http://127.0.0.1:${e}/internal/readiness`)).status === 200;
|
|
840
840
|
} catch {
|
|
841
841
|
return !1;
|
|
842
842
|
}
|
|
843
|
-
},
|
|
843
|
+
}, Jt = (e) => A(Ve(Be(A(e, "package.json")).resolve("@voltro/cli/package.json")), "bin", "voltro.mjs"), Yt = 1e4, Xt = (e) => new Promise((t) => {
|
|
844
844
|
if (e.exitCode !== null || e.signalCode !== null) return t();
|
|
845
845
|
let n = setTimeout(() => {
|
|
846
846
|
e.kill("SIGKILL");
|
|
847
|
-
},
|
|
847
|
+
}, Yt);
|
|
848
848
|
e.once("exit", () => {
|
|
849
849
|
clearTimeout(n), t();
|
|
850
850
|
}), e.kill("SIGTERM");
|
|
851
|
-
}),
|
|
851
|
+
}), Zt = async (e) => {
|
|
852
852
|
let t = Object.keys(e.apps);
|
|
853
853
|
if (t.length === 0) throw Error("startTestApps: no apps given");
|
|
854
|
-
let n = e.mode ?? "dev", r = e.bootTimeoutMs ?? 3e5, i = e.cli ??
|
|
855
|
-
for (let e of t) a.set(e, await
|
|
854
|
+
let n = e.mode ?? "dev", r = e.bootTimeoutMs ?? 3e5, i = e.cli ?? Jt(e.apps[t[0]].root), a = /* @__PURE__ */ new Map();
|
|
855
|
+
for (let e of t) a.set(e, await Kt());
|
|
856
856
|
let o = /* @__PURE__ */ new Map(), s = new Map(t.map((e) => [e, {}]));
|
|
857
857
|
for (let n of e.edges ?? []) {
|
|
858
858
|
for (let e of [n.caller, n.callee]) if (!t.includes(e)) throw Error(`startTestApps: edge names '${e}', which is not among the apps (${t.join(", ")})`);
|
|
@@ -872,10 +872,10 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
872
872
|
};
|
|
873
873
|
for (let e of t) u(e);
|
|
874
874
|
let d = [], f = /* @__PURE__ */ new Map(), p = async () => {
|
|
875
|
-
await Promise.all(d.map(
|
|
875
|
+
await Promise.all(d.map(Xt));
|
|
876
876
|
};
|
|
877
877
|
for (let t of c) {
|
|
878
|
-
let o = e.apps[t], c = a.get(t), l = "", u =
|
|
878
|
+
let o = e.apps[t], c = a.get(t), l = "", u = ze(process.execPath, [
|
|
879
879
|
i,
|
|
880
880
|
n,
|
|
881
881
|
...n === "serve" ? ["."] : []
|
|
@@ -907,11 +907,11 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
907
907
|
url: `http://127.0.0.1:${c}`,
|
|
908
908
|
wsUrl: `ws://127.0.0.1:${c}/ws`,
|
|
909
909
|
log: () => l,
|
|
910
|
-
stop: () =>
|
|
910
|
+
stop: () => Xt(u)
|
|
911
911
|
};
|
|
912
912
|
f.set(t, m);
|
|
913
913
|
let h = Date.now() + r;
|
|
914
|
-
for (; !await
|
|
914
|
+
for (; !await qt(c);) {
|
|
915
915
|
if (u.exitCode !== null || u.signalCode !== null || Date.now() > h) {
|
|
916
916
|
await p();
|
|
917
917
|
let e = u.exitCode !== null || u.signalCode !== null ? "exited before it was ready" : `was not ready within ${r} ms`;
|
|
@@ -929,6 +929,6 @@ var Ve = new Set(e), j = 0, M = () => ++j, He = (e, t) => {
|
|
|
929
929
|
},
|
|
930
930
|
stop: p
|
|
931
931
|
};
|
|
932
|
-
},
|
|
932
|
+
}, Qt = 1;
|
|
933
933
|
//#endregion
|
|
934
|
-
export { z as MockClock, H as MockLLM, B as MockWebhooks,
|
|
934
|
+
export { z as MockClock, H as MockLLM, B as MockWebhooks, Qt as TESTING_PRESET_VERSION, Ot as TEST_TENANT_ID, Mt as anonymous, At as apiKey, n as changeDelete, r as changeInsert, i as changeSoftDelete, a as changeUpdate, Qe as defineFactory, Tt as describeIfAvailable, Et as describeIfReachable, N as fixtureRow, nt as frozenTime, qe as hydrateFixtureRows, Ct as invoke, wt as isTcpReachable, Gt as makeServiceApiMock, Vt as makeSubscribeContext, Bt as makeTestApp, xt as makeTestContext, Wt as makeWorkflowRunner, Z as markRestInvocation, it as mockStore, M as nextSequence, dt as outboxNudgesOf, Y as pluginsOf, Dt as reportEngineVersion, ut as resetAfterCommit, ot as restInvocationOf, ct as rpcInterceptorFor, Q as runAfterCommit, ft as runInStoreTransaction, jt as serviceAccount, lt as serviceLayerFor, Zt as startTestApps, Nt as system, V as testEventBus, kt as user, tt as withFrozenTime, at as withRpcConnection };
|