@voltro/testing 0.86.0 → 0.87.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 +5321 -0
- package/README.md +11 -0
- package/THIRD-PARTY-NOTICES.md +860 -221
- package/dist/client.d.ts +5 -0
- package/dist/client.js +69 -56
- package/dist/dialect.d.ts +20 -0
- package/dist/dialect.js +991 -692
- package/dist/fieldKeys.js +73 -0
- package/dist/fieldKeysSql.js +14 -0
- package/dist/hotStoreSqlParity.js +132 -0
- package/dist/index.d.ts +119 -1
- package/dist/index.js +17 -14
- package/dist/invoke.js +76 -38
- package/dist/system.d.ts +99 -0
- package/dist/system.js +94 -0
- package/dist/testContext.js +132 -111
- package/dist/testRequest.js +55 -53
- package/dist/withConnections.js +26 -0
- package/package.json +16 -9
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
|
|
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
7
|
//#region src/testRequest.ts
|
|
8
|
-
var
|
|
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,30 @@ 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
120
|
//#endregion
|
|
119
|
-
export {
|
|
121
|
+
export { _ as makeTestApp };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Layer as e } from "effect";
|
|
2
|
+
import { layerConfiguredConnections as t } from "@voltro/kv/connection";
|
|
3
|
+
//#region 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
|
+
//#endregion
|
|
26
|
+
export { n as withConnections };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.87.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,16 +58,18 @@
|
|
|
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.87.0",
|
|
62
|
+
"@voltro/database": "0.87.0",
|
|
63
|
+
"@voltro/env": "0.87.0",
|
|
64
|
+
"@voltro/kv": "0.87.0",
|
|
65
|
+
"@voltro/local-first": "0.87.0",
|
|
66
|
+
"@voltro/logger": "0.87.0",
|
|
67
|
+
"@voltro/protocol": "0.87.0",
|
|
68
|
+
"@voltro/runtime": "0.87.0",
|
|
69
|
+
"@voltro/workflow": "0.87.0"
|
|
63
70
|
},
|
|
64
71
|
"peerDependencies": {
|
|
65
|
-
"@voltro/client": "0.
|
|
72
|
+
"@voltro/client": "0.87.0",
|
|
66
73
|
"effect": "4.0.1",
|
|
67
74
|
"react": "^19.0.0",
|
|
68
75
|
"react-dom": "^19.0.0",
|