@voltro/testing 0.86.0 → 0.88.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 +5484 -0
- package/README.md +11 -0
- package/THIRD-PARTY-NOTICES.md +1511 -276
- package/dist/client.d.ts +5 -0
- package/dist/client.js +70 -58
- package/dist/crdt.js +1 -2
- package/dist/dialect.d.ts +20 -0
- package/dist/dialect.js +992 -694
- package/dist/factory.js +1 -2
- package/dist/fieldKeys.js +72 -0
- package/dist/fieldKeysSql.js +13 -0
- package/dist/fixtureRow.js +1 -2
- package/dist/formBindingHarness.js +1 -2
- package/dist/hotStoreSqlParity.js +135 -0
- package/dist/hydrateFixtureRows.js +1 -2
- package/dist/index.d.ts +119 -1
- package/dist/index.js +18 -16
- package/dist/invoke.js +77 -40
- package/dist/mockClock.js +1 -2
- package/dist/mockLLM.js +1 -2
- package/dist/mockWebhooks.js +1 -2
- package/dist/platform.js +1 -2
- package/dist/reachable.js +1 -2
- package/dist/serviceApiMock.js +1 -2
- package/dist/subject.js +1 -2
- package/dist/subscribeContext.js +1 -2
- package/dist/system.d.ts +99 -0
- package/dist/system.js +93 -0
- package/dist/testApps.js +1 -2
- package/dist/testContext.js +133 -113
- package/dist/testEventBus.js +1 -2
- package/dist/testRequest.js +56 -55
- package/dist/withConnections.js +25 -0
- package/dist/workflowRunner.js +1 -2
- package/package.json +17 -10
package/dist/testEventBus.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect as e, Result as t } from "effect";
|
|
2
2
|
import { eventRoute as n } from "@voltro/protocol";
|
|
3
3
|
import { EventBus as r, publishEvent as i } from "@voltro/runtime";
|
|
4
|
-
|
|
4
|
+
// src/testEventBus.ts
|
|
5
5
|
var a = (a = {}) => {
|
|
6
6
|
let o = a.tenantId ?? null, s = new r({
|
|
7
7
|
origin: a.origin ?? "test",
|
|
@@ -69,5 +69,4 @@ var a = (a = {}) => {
|
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
-
//#endregion
|
|
73
72
|
export { a as testEventBus };
|
package/dist/testRequest.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { markRestInvocation as e, pluginsOf as t } from "./testContext.js";
|
|
2
2
|
import { invoke as n } from "./invoke.js";
|
|
3
3
|
import { Effect as r } from "effect";
|
|
4
|
-
import { composeAuthStrategies as i } from "@voltro/protocol";
|
|
5
|
-
import { resolveRequestClientAddress as
|
|
6
|
-
import { collectPublicApiRoutes as
|
|
7
|
-
|
|
8
|
-
var
|
|
4
|
+
import { composeAuthStrategies as i, composeReplayAuthorityBindings as a } from "@voltro/protocol";
|
|
5
|
+
import { resolveRequestClientAddress as o, resolveTrustedProxies as s } from "@voltro/runtime";
|
|
6
|
+
import { collectPublicApiRoutes as c, dispatchSharedPath as l, restRoutesToHttpRoutes as u } from "@voltro/protocol/rest";
|
|
7
|
+
// src/testRequest.ts
|
|
8
|
+
var d = "127.0.0.1", f = (e) => {
|
|
9
9
|
let t = e.indexOf("?");
|
|
10
10
|
return t === -1 ? {
|
|
11
11
|
path: e,
|
|
@@ -14,64 +14,66 @@ var u = "127.0.0.1", d = (e) => {
|
|
|
14
14
|
path: e.slice(0, t),
|
|
15
15
|
query: e.slice(t + 1)
|
|
16
16
|
};
|
|
17
|
-
},
|
|
17
|
+
}, p = (e, t) => {
|
|
18
18
|
let n = e.split("/").filter((e) => e.length > 0), r = t.split("/").filter((e) => e.length > 0);
|
|
19
19
|
return n.length === r.length && n.every((e, t) => e.startsWith(":") || e === r[t]);
|
|
20
|
-
},
|
|
20
|
+
}, m = (e) => {
|
|
21
21
|
let t = {};
|
|
22
22
|
for (let [n, r] of Object.entries(e)) t[n.toLowerCase()] = r;
|
|
23
23
|
return t;
|
|
24
|
-
},
|
|
25
|
-
let
|
|
24
|
+
}, h = (e) => e === void 0 ? /* @__PURE__ */ new Uint8Array() : new TextEncoder().encode(JSON.stringify(e)), g = (e) => e === void 0 ? "" : typeof e == "string" ? e : new TextDecoder().decode(e), _ = (_) => {
|
|
25
|
+
let v = s(_.security?.trustedProxies, process.env, _.security?.clientAddressHeader), { ctx: y } = _, b = c((_.publicApi ?? []).map((t) => ({
|
|
26
26
|
descriptor: t.descriptor,
|
|
27
|
-
invoke: (r, i) =>
|
|
27
|
+
invoke: (r, i) => y.withSubject(i.subject, (a) => (t.descriptor.publicApi !== void 0 && e(a, t.descriptor.publicApi, i.remoteAddr), n(t.descriptor, t.handler, r, a)))
|
|
28
28
|
})), {
|
|
29
|
-
pluginErrors: t(
|
|
30
|
-
...
|
|
31
|
-
}),
|
|
32
|
-
anonymous:
|
|
33
|
-
getStore: () =>
|
|
34
|
-
}),
|
|
35
|
-
let i = {
|
|
36
|
-
store:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
pluginErrors: t(y).flatMap((e) => e.errorSchemas ?? []),
|
|
30
|
+
..._.publicApiProfile === void 0 ? {} : { profile: _.publicApiProfile }
|
|
31
|
+
}), x = [..._.restRoutes ?? [], ...b], S = i(_.strategies ?? [], {
|
|
32
|
+
anonymous: _.anonymous ?? { headerOrTenant: "acme" },
|
|
33
|
+
getStore: () => y.store
|
|
34
|
+
}), C = (e, n) => {
|
|
35
|
+
let i = a(t(y)), s = {
|
|
36
|
+
store: y.store,
|
|
37
|
+
traceId: () => y.request.traceId,
|
|
38
|
+
...i === void 0 ? {} : { bindReplayAuthority: i },
|
|
39
|
+
...t(y).some((e) => e.restRateLimit !== void 0) ? { rateLimit: (e, n, i) => r.forEach(t(y), (t) => t.restRateLimit?.(e, n, i) ?? r.void, { discard: !0 }) } : {},
|
|
40
|
+
buildContext: (e) => y.asSubject(e),
|
|
41
|
+
resolveSubject: e === void 0 ? async (e) => (await S({
|
|
40
42
|
headers: e,
|
|
41
43
|
clientId: -1
|
|
42
44
|
})).subject : () => e,
|
|
43
|
-
...
|
|
44
|
-
},
|
|
45
|
-
pattern:
|
|
45
|
+
..._.idempotency === void 0 ? {} : { idempotency: _.idempotency }
|
|
46
|
+
}, c = u(x, s).map((e, t) => ({
|
|
47
|
+
pattern: x[t].path,
|
|
46
48
|
route: e
|
|
47
|
-
})),
|
|
48
|
-
let { path: i, query:
|
|
49
|
-
if (
|
|
49
|
+
})), b = async (e, t, r = {}) => {
|
|
50
|
+
let { path: i, query: a } = f(t), s = c.filter((e) => p(e.pattern, i)).map((e) => e.route);
|
|
51
|
+
if (s.length === 0) return {
|
|
50
52
|
status: 404,
|
|
51
53
|
headers: {},
|
|
52
54
|
text: "",
|
|
53
55
|
body: {
|
|
54
56
|
error: "No route mounted for this path",
|
|
55
|
-
mounted:
|
|
57
|
+
mounted: x.map((e) => e.path)
|
|
56
58
|
},
|
|
57
59
|
stream: !1
|
|
58
60
|
};
|
|
59
|
-
let
|
|
60
|
-
...
|
|
61
|
-
...
|
|
62
|
-
},
|
|
63
|
-
socketAddress: r.remoteAddr ??
|
|
64
|
-
headers:
|
|
65
|
-
config:
|
|
66
|
-
}),
|
|
61
|
+
let u = {
|
|
62
|
+
...m(n),
|
|
63
|
+
...m(r.headers ?? {})
|
|
64
|
+
}, _ = o({
|
|
65
|
+
socketAddress: r.remoteAddr ?? d,
|
|
66
|
+
headers: u,
|
|
67
|
+
config: v
|
|
68
|
+
}), b = {
|
|
67
69
|
method: e.toUpperCase(),
|
|
68
70
|
path: i,
|
|
69
|
-
query:
|
|
70
|
-
headers:
|
|
71
|
-
rawBody:
|
|
72
|
-
store:
|
|
73
|
-
...
|
|
74
|
-
}, S = await
|
|
71
|
+
query: a,
|
|
72
|
+
headers: u,
|
|
73
|
+
rawBody: h(r.body),
|
|
74
|
+
store: y.store,
|
|
75
|
+
..._ === void 0 ? {} : { remoteAddr: _ }
|
|
76
|
+
}, S = await l(s, b), C = {};
|
|
75
77
|
for (let [e, t] of Object.entries(S.headers ?? {})) C[e.toLowerCase()] = t;
|
|
76
78
|
S.contentType !== void 0 && (C["content-type"] = S.contentType);
|
|
77
79
|
let w = typeof S.body == "string" ? new TextEncoder().encode(S.body) : S.body ?? /* @__PURE__ */ new Uint8Array();
|
|
@@ -79,7 +81,7 @@ var u = "127.0.0.1", d = (e) => {
|
|
|
79
81
|
let e = S.byteStream.stream, t = typeof e == "function" ? e() : e;
|
|
80
82
|
w = new Uint8Array(await new Response(t).arrayBuffer());
|
|
81
83
|
}
|
|
82
|
-
let T =
|
|
84
|
+
let T = g(w), E = (S.contentType ?? "").includes("json");
|
|
83
85
|
return {
|
|
84
86
|
status: S.status,
|
|
85
87
|
headers: C,
|
|
@@ -90,30 +92,29 @@ var u = "127.0.0.1", d = (e) => {
|
|
|
90
92
|
};
|
|
91
93
|
};
|
|
92
94
|
return {
|
|
93
|
-
actingAs: (e) =>
|
|
94
|
-
withHeaders: (t) =>
|
|
95
|
+
actingAs: (e) => C(e, n),
|
|
96
|
+
withHeaders: (t) => C(e, {
|
|
95
97
|
...n,
|
|
96
98
|
...t
|
|
97
99
|
}),
|
|
98
|
-
get: (e, t) =>
|
|
99
|
-
delete: (e, t) =>
|
|
100
|
-
post: (e, t, n) =>
|
|
100
|
+
get: (e, t) => b("GET", e, t ?? {}),
|
|
101
|
+
delete: (e, t) => b("DELETE", e, t ?? {}),
|
|
102
|
+
post: (e, t, n) => b("POST", e, {
|
|
101
103
|
...n ?? {},
|
|
102
104
|
body: t
|
|
103
105
|
}),
|
|
104
|
-
put: (e, t, n) =>
|
|
106
|
+
put: (e, t, n) => b("PUT", e, {
|
|
105
107
|
...n ?? {},
|
|
106
108
|
body: t
|
|
107
109
|
}),
|
|
108
|
-
patch: (e, t, n) =>
|
|
110
|
+
patch: (e, t, n) => b("PATCH", e, {
|
|
109
111
|
...n ?? {},
|
|
110
112
|
body: t
|
|
111
113
|
}),
|
|
112
|
-
request: (e, t, n) =>
|
|
113
|
-
paths:
|
|
114
|
+
request: (e, t, n) => b(e, t, n ?? {}),
|
|
115
|
+
paths: x.map((e) => e.path)
|
|
114
116
|
};
|
|
115
117
|
};
|
|
116
|
-
return
|
|
118
|
+
return C(void 0, {});
|
|
117
119
|
};
|
|
118
|
-
|
|
119
|
-
export { g as makeTestApp };
|
|
120
|
+
export { _ as makeTestApp };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Layer as e } from "effect";
|
|
2
|
+
import { layerConfiguredConnections as t } from "@voltro/kv/connection";
|
|
3
|
+
// src/withConnections.ts
|
|
4
|
+
var n = (n, r = {}) => {
|
|
5
|
+
let i = r.connections ?? {}, a = { ...i.redis };
|
|
6
|
+
for (let [e, t] of Object.entries(n)) {
|
|
7
|
+
if (!/^redis:[A-Za-z][A-Za-z0-9_-]*$/.test(e)) throw Error("Connection test overrides require redis:name references");
|
|
8
|
+
let n = e.slice(6);
|
|
9
|
+
if (i.redis !== void 0 && !Object.hasOwn(i.redis, n)) throw Error("Connection test override must name a declared app entry");
|
|
10
|
+
if (t._tag !== "MemoryRedisConnection") throw Error("Connection test overrides require memory() entries");
|
|
11
|
+
a[n] = t;
|
|
12
|
+
}
|
|
13
|
+
let o = {
|
|
14
|
+
...i,
|
|
15
|
+
redis: a,
|
|
16
|
+
...i.nats === void 0 ? {} : { nats: { ...i.nats } },
|
|
17
|
+
...i.defaults === void 0 ? {} : { defaults: { ...i.defaults } },
|
|
18
|
+
...i.bindings === void 0 ? {} : { bindings: Object.fromEntries(Object.entries(i.bindings).map(([e, t]) => [e, { ...t }])) }
|
|
19
|
+
};
|
|
20
|
+
return t({
|
|
21
|
+
connections: o,
|
|
22
|
+
...r.connectAnalytics === void 0 ? {} : { connectAnalytics: r.connectAnalytics }
|
|
23
|
+
}).pipe(e.orDie);
|
|
24
|
+
};
|
|
25
|
+
export { n as withConnections };
|
package/dist/workflowRunner.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Effect as e, Layer as t, Result as n } from "effect";
|
|
|
2
2
|
import { getFieldCipher as r, makeEffectStoreLayer as i, makeFieldCipher as a } from "@voltro/runtime";
|
|
3
3
|
import { randomBytes as o } from "node:crypto";
|
|
4
4
|
import { CurrentWorkflowRunId as s, failureMessage as c, getWorkflowJournalCipher as l, inMemoryWorkflowEngineLayer as u, makeInMemoryRecorder as d, setWorkflowJournalCipher as f } from "@voltro/workflow";
|
|
5
|
-
|
|
5
|
+
// src/workflowRunner.ts
|
|
6
6
|
var p = (e) => {
|
|
7
7
|
let t = /* @__PURE__ */ new Map();
|
|
8
8
|
for (let n of e) {
|
|
@@ -81,5 +81,4 @@ var p = (e) => {
|
|
|
81
81
|
inspect: async (e) => o.get(e) ?? null
|
|
82
82
|
};
|
|
83
83
|
};
|
|
84
|
-
//#endregion
|
|
85
84
|
export { h as makeWorkflowRunner };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.88.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,6 +43,11 @@
|
|
|
43
43
|
"import": "./dist/crdt.js",
|
|
44
44
|
"default": "./dist/crdt.js"
|
|
45
45
|
},
|
|
46
|
+
"./system": {
|
|
47
|
+
"types": "./dist/system.d.ts",
|
|
48
|
+
"import": "./dist/system.js",
|
|
49
|
+
"default": "./dist/system.js"
|
|
50
|
+
},
|
|
46
51
|
"./package.json": "./package.json"
|
|
47
52
|
},
|
|
48
53
|
"main": "./dist/index.js",
|
|
@@ -53,17 +58,19 @@
|
|
|
53
58
|
"node": ">=24.0.0"
|
|
54
59
|
},
|
|
55
60
|
"dependencies": {
|
|
56
|
-
"@voltro/
|
|
57
|
-
"@voltro/
|
|
58
|
-
"@voltro/
|
|
59
|
-
"@voltro/
|
|
60
|
-
"@voltro/
|
|
61
|
-
"@voltro/
|
|
62
|
-
"@voltro/
|
|
61
|
+
"@voltro/cache": "0.88.0",
|
|
62
|
+
"@voltro/database": "0.88.0",
|
|
63
|
+
"@voltro/env": "0.88.0",
|
|
64
|
+
"@voltro/kv": "0.88.0",
|
|
65
|
+
"@voltro/local-first": "0.88.0",
|
|
66
|
+
"@voltro/logger": "0.88.0",
|
|
67
|
+
"@voltro/protocol": "0.88.0",
|
|
68
|
+
"@voltro/runtime": "0.88.0",
|
|
69
|
+
"@voltro/workflow": "0.88.0"
|
|
63
70
|
},
|
|
64
71
|
"peerDependencies": {
|
|
65
|
-
"@voltro/client": "0.
|
|
66
|
-
"effect": "4.0
|
|
72
|
+
"@voltro/client": "0.88.0",
|
|
73
|
+
"effect": "4.1.0",
|
|
67
74
|
"react": "^19.0.0",
|
|
68
75
|
"react-dom": "^19.0.0",
|
|
69
76
|
"vitest": ">=3.0.0"
|