@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.
@@ -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
- //#region src/testEventBus.ts
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 };
@@ -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 a, resolveTrustedProxies as o } from "@voltro/runtime";
6
- import { collectPublicApiRoutes as s, dispatchSharedPath as c, restRoutesToHttpRoutes as l } from "@voltro/protocol/rest";
7
- //#region src/testRequest.ts
8
- var u = "127.0.0.1", d = (e) => {
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
- }, f = (e, t) => {
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
- }, p = (e) => {
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
- }, m = (e) => e === void 0 ? /* @__PURE__ */ new Uint8Array() : new TextEncoder().encode(JSON.stringify(e)), h = (e) => e === void 0 ? "" : typeof e == "string" ? e : new TextDecoder().decode(e), g = (g) => {
25
- let _ = o(g.security?.trustedProxies, process.env, g.security?.clientAddressHeader), { ctx: v } = g, y = s((g.publicApi ?? []).map((t) => ({
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) => v.withSubject(i.subject, (a) => (t.descriptor.publicApi !== void 0 && e(a, t.descriptor.publicApi, i.remoteAddr), n(t.descriptor, t.handler, r, a)))
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(v).flatMap((e) => e.errorSchemas ?? []),
30
- ...g.publicApiProfile === void 0 ? {} : { profile: g.publicApiProfile }
31
- }), b = [...g.restRoutes ?? [], ...y], x = i(g.strategies ?? [], {
32
- anonymous: g.anonymous ?? { headerOrTenant: "acme" },
33
- getStore: () => v.store
34
- }), S = (e, n) => {
35
- let i = {
36
- store: v.store,
37
- ...t(v).some((e) => e.restRateLimit !== void 0) ? { rateLimit: (e, n, i) => r.forEach(t(v), (t) => t.restRateLimit?.(e, n, i) ?? r.void, { discard: !0 }) } : {},
38
- buildContext: () => v,
39
- resolveSubject: e === void 0 ? async (e) => (await x({
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
- ...g.idempotency === void 0 ? {} : { idempotency: g.idempotency }
44
- }, o = l(b, i).map((e, t) => ({
45
- pattern: b[t].path,
45
+ ..._.idempotency === void 0 ? {} : { idempotency: _.idempotency }
46
+ }, c = u(x, s).map((e, t) => ({
47
+ pattern: x[t].path,
46
48
  route: e
47
- })), s = async (e, t, r = {}) => {
48
- let { path: i, query: s } = d(t), l = o.filter((e) => f(e.pattern, i)).map((e) => e.route);
49
- if (l.length === 0) return {
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: b.map((e) => e.path)
57
+ mounted: x.map((e) => e.path)
56
58
  },
57
59
  stream: !1
58
60
  };
59
- let g = {
60
- ...p(n),
61
- ...p(r.headers ?? {})
62
- }, y = a({
63
- socketAddress: r.remoteAddr ?? u,
64
- headers: g,
65
- config: _
66
- }), x = {
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: s,
70
- headers: g,
71
- rawBody: m(r.body),
72
- store: v.store,
73
- ...y === void 0 ? {} : { remoteAddr: y }
74
- }, S = await c(l, x), C = {};
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 = h(w), E = (S.contentType ?? "").includes("json");
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) => S(e, n),
94
- withHeaders: (t) => S(e, {
95
+ actingAs: (e) => C(e, n),
96
+ withHeaders: (t) => C(e, {
95
97
  ...n,
96
98
  ...t
97
99
  }),
98
- get: (e, t) => s("GET", e, t ?? {}),
99
- delete: (e, t) => s("DELETE", e, t ?? {}),
100
- post: (e, t, n) => s("POST", e, {
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) => s("PUT", e, {
106
+ put: (e, t, n) => b("PUT", e, {
105
107
  ...n ?? {},
106
108
  body: t
107
109
  }),
108
- patch: (e, t, n) => s("PATCH", e, {
110
+ patch: (e, t, n) => b("PATCH", e, {
109
111
  ...n ?? {},
110
112
  body: t
111
113
  }),
112
- request: (e, t, n) => s(e, t, n ?? {}),
113
- paths: b.map((e) => e.path)
114
+ request: (e, t, n) => b(e, t, n ?? {}),
115
+ paths: x.map((e) => e.path)
114
116
  };
115
117
  };
116
- return S(void 0, {});
118
+ return C(void 0, {});
117
119
  };
118
- //#endregion
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 };
@@ -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
- //#region src/workflowRunner.ts
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.86.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/database": "0.86.0",
57
- "@voltro/env": "0.86.0",
58
- "@voltro/local-first": "0.86.0",
59
- "@voltro/logger": "0.86.0",
60
- "@voltro/protocol": "0.86.0",
61
- "@voltro/runtime": "0.86.0",
62
- "@voltro/workflow": "0.86.0"
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.86.0",
66
- "effect": "4.0.1",
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"