@voltro/testing 0.84.0 → 0.86.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 +1215 -0
- package/THIRD-PARTY-NOTICES.md +118 -600
- package/dist/client.d.ts +4 -9
- package/dist/client.js +73 -98
- package/dist/dialect.d.ts +1 -1
- package/dist/dialect.js +244 -145
- package/dist/factory.js +65 -0
- package/dist/fixtureRow.js +30 -0
- package/dist/formBindingHarness.js +46 -0
- package/dist/hydrateFixtureRows.js +22 -0
- package/dist/index.d.ts +13 -13
- package/dist/index.js +19 -933
- package/dist/invoke.js +44 -0
- package/dist/mockClock.js +78 -0
- package/dist/mockLLM.js +19 -0
- package/dist/mockWebhooks.js +26 -0
- package/dist/platform.js +1 -5
- package/dist/reachable.js +27 -0
- package/dist/serviceApiMock.js +53 -0
- package/dist/subject.js +11 -0
- package/dist/subscribeContext.js +16 -0
- package/dist/testApps.js +111 -0
- package/dist/testContext.js +248 -0
- package/dist/testEventBus.js +73 -0
- package/dist/testRequest.js +119 -0
- package/dist/workflowRunner.js +85 -0
- package/package.json +10 -11
package/dist/client.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
2
|
import { Exit } from 'effect/Exit';
|
|
3
|
+
import { Fiber } from 'effect/Fiber';
|
|
3
4
|
import { FieldErrors } from '@voltro/client';
|
|
4
5
|
import { FormBinding } from '@voltro/client';
|
|
5
6
|
import { FormStateSnapshot } from '@voltro/client';
|
|
6
7
|
import { ReactElement } from 'react';
|
|
7
8
|
import { ReactNode } from 'react';
|
|
8
|
-
import { RunForkOptions } from 'effect/Runtime';
|
|
9
|
-
import { RuntimeFiber } from 'effect/Fiber';
|
|
10
9
|
import { UseFormBindingOptions } from '@voltro/client';
|
|
11
10
|
|
|
12
11
|
/** The snapshot shape `useConnectionStatus` subscribes to. */
|
|
@@ -38,13 +37,9 @@ declare interface ConnectionFacts {
|
|
|
38
37
|
* starts calling goes red here instead of in whichever hook reaches it first.
|
|
39
38
|
*/
|
|
40
39
|
export declare const FAKE_RUNTIME: {
|
|
41
|
-
runPromise: <A, E>(effect: Effect.Effect<A, E
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, never>, options?: {
|
|
45
|
-
readonly signal?: AbortSignal;
|
|
46
|
-
} | undefined) => Promise< Exit<A, E>>;
|
|
47
|
-
runFork: <A, E>(effect: Effect.Effect<A, E>, options?: RunForkOptions) => RuntimeFiber<A, E>;
|
|
40
|
+
runPromise: <A, E>(effect: Effect.Effect<A, E>, options?: Effect.RunOptions | undefined) => Promise<A>;
|
|
41
|
+
runPromiseExit: <A, E>(effect: Effect.Effect<A, E>, options?: Effect.RunOptions | undefined) => Promise< Exit<A, E>>;
|
|
42
|
+
runFork: <A, E>(effect: Effect.Effect<A, E, never>, options?: Effect.RunOptions | undefined) => Fiber<A, E>;
|
|
48
43
|
dispose: () => Effect.Effect<void, never, never>;
|
|
49
44
|
};
|
|
50
45
|
|
package/dist/client.js
CHANGED
|
@@ -1,85 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}), l, u = () => (l = a(o, e, r.binding ?? {}), null), d = i(globalThis.document.createElement("div"));
|
|
15
|
-
return await t(async () => {
|
|
16
|
-
d.render(n(s.Provider, null, n(u)));
|
|
17
|
-
}), {
|
|
18
|
-
binding: () => l,
|
|
19
|
-
fill: (e, n) => {
|
|
20
|
-
t(() => {
|
|
21
|
-
l.field(e).setValue(n);
|
|
22
|
-
});
|
|
23
|
-
},
|
|
24
|
-
blur: (e) => {
|
|
25
|
-
t(() => {
|
|
26
|
-
l.field(e).onBlur();
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
submit: async () => {
|
|
30
|
-
let e;
|
|
31
|
-
return await t(async () => {
|
|
32
|
-
e = await l.submit();
|
|
33
|
-
}), e;
|
|
34
|
-
},
|
|
35
|
-
errors: () => l.errors,
|
|
36
|
-
state: () => l.state,
|
|
37
|
-
client: s,
|
|
38
|
-
unmount: () => {
|
|
39
|
-
t(() => {
|
|
40
|
-
d.unmount();
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}, s = {
|
|
45
|
-
runPromise: e.runPromise,
|
|
46
|
-
runPromiseExit: e.runPromiseExit,
|
|
47
|
-
runFork: e.runFork,
|
|
48
|
-
dispose: () => e.void
|
|
49
|
-
}, c = (t = {}) => {
|
|
50
|
-
let a = t.apiName ?? "app", o = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = [];
|
|
51
|
-
for (let [e, n] of Object.entries(t.subscriptions ?? {})) o.set(e, {
|
|
1
|
+
import { renderFormBinding as e } from "./formBindingHarness.js";
|
|
2
|
+
import { Effect as t } from "effect";
|
|
3
|
+
import { createElement as n } from "react";
|
|
4
|
+
import { FrameworkRuntimesContext as r, INITIAL_RECOVERY_SNAPSHOT as i, RpcErrorBus as a } from "@voltro/client";
|
|
5
|
+
//#region src/client.tsx
|
|
6
|
+
var o = {
|
|
7
|
+
runPromise: t.runPromise,
|
|
8
|
+
runPromiseExit: t.runPromiseExit,
|
|
9
|
+
runFork: t.runFork,
|
|
10
|
+
dispose: () => t.void
|
|
11
|
+
}, s = (e = {}) => {
|
|
12
|
+
let s = e.apiName ?? "app", c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), d = [];
|
|
13
|
+
for (let [t, n] of Object.entries(e.subscriptions ?? {})) c.set(t, {
|
|
52
14
|
data: n,
|
|
53
15
|
error: void 0,
|
|
54
16
|
revision: 0,
|
|
55
17
|
pendingPatches: 0,
|
|
56
18
|
emittedAt: void 0
|
|
57
19
|
});
|
|
58
|
-
let
|
|
20
|
+
let f = (e) => c.get(e) ?? {
|
|
59
21
|
data: void 0,
|
|
60
22
|
error: void 0,
|
|
61
23
|
revision: -1,
|
|
62
24
|
pendingPatches: 0,
|
|
63
25
|
emittedAt: void 0
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
for (let t of
|
|
67
|
-
},
|
|
26
|
+
}, p = (e) => {
|
|
27
|
+
u.delete(e);
|
|
28
|
+
for (let t of l.get(e) ?? []) t();
|
|
29
|
+
}, m = (e) => String(e[0] ?? ""), h = {
|
|
68
30
|
peek: (e) => {
|
|
69
|
-
let t =
|
|
31
|
+
let t = m(e), n = u.get(t);
|
|
70
32
|
if (n) return n;
|
|
71
|
-
let r =
|
|
33
|
+
let r = f(t), i = {
|
|
72
34
|
data: r.data,
|
|
73
35
|
revision: r.revision,
|
|
74
36
|
emittedAt: r.emittedAt,
|
|
75
37
|
error: r.error,
|
|
76
38
|
pendingPatches: r.pendingPatches
|
|
77
39
|
};
|
|
78
|
-
return
|
|
40
|
+
return u.set(t, i), i;
|
|
79
41
|
},
|
|
80
42
|
subscribe: (e, t, n, r) => {
|
|
81
|
-
let i =
|
|
82
|
-
return a.add(r),
|
|
43
|
+
let i = m(e), a = l.get(i) ?? /* @__PURE__ */ new Set();
|
|
44
|
+
return a.add(r), l.set(i, a), { unsubscribe: () => {
|
|
83
45
|
a.delete(r);
|
|
84
46
|
} };
|
|
85
47
|
},
|
|
@@ -92,9 +54,9 @@ var o = async (e, r = {}) => {
|
|
|
92
54
|
update: () => {},
|
|
93
55
|
forTag: () => ({ patchedCount: 0 }),
|
|
94
56
|
refreshAll: () => {
|
|
95
|
-
|
|
57
|
+
g += 1;
|
|
96
58
|
}
|
|
97
|
-
},
|
|
59
|
+
}, g = 0, _ = {
|
|
98
60
|
rawTransport: "connected",
|
|
99
61
|
status: "connected",
|
|
100
62
|
failureCount: 0,
|
|
@@ -102,83 +64,96 @@ var o = async (e, r = {}) => {
|
|
|
102
64
|
failedSubscriptions: [],
|
|
103
65
|
pendingMutationReplays: 0,
|
|
104
66
|
mutationReplay: "unknown"
|
|
105
|
-
},
|
|
106
|
-
subscribe: (e) => (
|
|
107
|
-
|
|
67
|
+
}, v = /* @__PURE__ */ new Set(), y = new a(), b = !0, x = {
|
|
68
|
+
subscribe: (e) => (v.add(e), () => {
|
|
69
|
+
v.delete(e);
|
|
108
70
|
}),
|
|
109
|
-
getSnapshot: () =>
|
|
71
|
+
getSnapshot: () => _,
|
|
72
|
+
getServerSnapshot: () => i,
|
|
73
|
+
getPreloadSeedPermission: () => b,
|
|
74
|
+
invalidatePreloadSeeds: () => {
|
|
75
|
+
if (b) {
|
|
76
|
+
b = !1;
|
|
77
|
+
for (let e of v) e();
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
onVisibleError: (e) => y.on(e),
|
|
81
|
+
waitForProtocolReady: async (e, t) => !t?.aborted && _.rawTransport === "connected",
|
|
82
|
+
reserveMutationReplay: () => void 0,
|
|
83
|
+
waitForMutationReplaySupport: async () => !1,
|
|
84
|
+
replayWindowRemaining: () => 0,
|
|
110
85
|
reportExternalSuccess: () => {},
|
|
111
86
|
subjectSignal: new AbortController().signal
|
|
112
|
-
},
|
|
113
|
-
let i =
|
|
87
|
+
}, S = {}, C = (e, n, r) => {
|
|
88
|
+
let i = e.split("."), a = S;
|
|
114
89
|
for (let e of i.slice(0, -1)) a[e] = a[e] ?? {}, a = a[e];
|
|
115
|
-
a[i[i.length - 1]] = (i) =>
|
|
116
|
-
try: async () => (
|
|
90
|
+
a[i[i.length - 1]] = (i) => t.tryPromise({
|
|
91
|
+
try: async () => (d.push({
|
|
117
92
|
kind: n,
|
|
118
|
-
tag:
|
|
93
|
+
tag: e,
|
|
119
94
|
input: i
|
|
120
95
|
}), await r(i)),
|
|
121
96
|
catch: (e) => e
|
|
122
97
|
});
|
|
123
98
|
};
|
|
124
|
-
for (let [
|
|
125
|
-
for (let [
|
|
126
|
-
let
|
|
127
|
-
runtime:
|
|
128
|
-
cache:
|
|
129
|
-
recovery:
|
|
130
|
-
client:
|
|
99
|
+
for (let [t, n] of Object.entries(e.mutations ?? {})) C(t, "mutation", n);
|
|
100
|
+
for (let [t, n] of Object.entries(e.actions ?? {})) C(t, "action", n);
|
|
101
|
+
let w = {
|
|
102
|
+
runtime: o,
|
|
103
|
+
cache: h,
|
|
104
|
+
recovery: x,
|
|
105
|
+
client: S,
|
|
131
106
|
descriptors: {},
|
|
132
107
|
inspectBaseUrl: "http://test.local",
|
|
133
|
-
errorBus:
|
|
134
|
-
},
|
|
108
|
+
errorBus: y
|
|
109
|
+
}, T = {
|
|
135
110
|
get: (e) => {
|
|
136
|
-
if (e !==
|
|
137
|
-
return
|
|
111
|
+
if (e !== s) throw Error(`makeVoltroTestClient: component asked for api '${e}' but the harness was built for '${s}'. Pass { apiName: '${e}' }.`);
|
|
112
|
+
return w;
|
|
138
113
|
},
|
|
139
|
-
names: [
|
|
114
|
+
names: [s]
|
|
140
115
|
};
|
|
141
116
|
return {
|
|
142
|
-
Provider: ({ children: e }) => n(r.Provider, { value:
|
|
117
|
+
Provider: ({ children: e }) => n(r.Provider, { value: T }, e),
|
|
143
118
|
setSubscription: (e, t, n) => {
|
|
144
|
-
let r =
|
|
145
|
-
|
|
119
|
+
let r = f(e);
|
|
120
|
+
c.set(e, {
|
|
146
121
|
data: t,
|
|
147
122
|
error: void 0,
|
|
148
123
|
revision: r.revision + 1,
|
|
149
124
|
pendingPatches: n?.pendingPatches ?? 0,
|
|
150
125
|
emittedAt: n?.emittedAt
|
|
151
|
-
}),
|
|
126
|
+
}), p(e);
|
|
152
127
|
},
|
|
153
128
|
failSubscription: (e, t) => {
|
|
154
|
-
|
|
129
|
+
c.set(e, {
|
|
155
130
|
data: void 0,
|
|
156
131
|
error: t,
|
|
157
132
|
revision: -1,
|
|
158
133
|
pendingPatches: 0,
|
|
159
134
|
emittedAt: void 0
|
|
160
|
-
}),
|
|
135
|
+
}), p(e);
|
|
161
136
|
},
|
|
162
137
|
resetSubscription: (e) => {
|
|
163
|
-
|
|
138
|
+
c.delete(e), p(e);
|
|
164
139
|
},
|
|
165
|
-
calls:
|
|
140
|
+
calls: d,
|
|
166
141
|
setConnectionStatus: (e, t) => {
|
|
167
|
-
|
|
168
|
-
...
|
|
142
|
+
_ = {
|
|
143
|
+
..._,
|
|
169
144
|
...t,
|
|
170
145
|
status: e,
|
|
171
146
|
rawTransport: t?.rawTransport ?? (e === "connected" ? "connected" : "disconnected")
|
|
172
147
|
};
|
|
173
|
-
for (let e of
|
|
148
|
+
for (let e of v) e();
|
|
174
149
|
},
|
|
175
150
|
get refreshes() {
|
|
176
|
-
return
|
|
151
|
+
return g;
|
|
177
152
|
},
|
|
178
153
|
emitRpcError: (e) => {
|
|
179
|
-
|
|
154
|
+
w.errorBus.emit(e);
|
|
180
155
|
}
|
|
181
156
|
};
|
|
182
157
|
};
|
|
183
158
|
//#endregion
|
|
184
|
-
export {
|
|
159
|
+
export { o as FAKE_RUNTIME, s as makeVoltroTestClient, e as renderFormBinding };
|
package/dist/dialect.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { applySchema } from '@voltro/database/sql';
|
|
2
2
|
import { DataStore } from '@voltro/database';
|
|
3
3
|
import { Effect } from 'effect';
|
|
4
|
-
import { SqlClient } from '
|
|
4
|
+
import { SqlClient } from 'effect/sql';
|
|
5
5
|
import { SqlDialect } from '@voltro/database';
|
|
6
6
|
|
|
7
7
|
export { applySchema }
|