@voltro/client 0.89.2 → 0.91.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 +1943 -0
- package/README.md +22 -0
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/analytics.d.ts +68 -0
- package/dist/analytics.js +1 -0
- package/dist/apiRuntime.js +50 -50
- package/dist/apiSupervisor.js +25 -25
- package/dist/awaitResolvedApi.js +42 -16
- package/dist/bootstrap.d.ts +0 -115
- package/dist/bootstrap.js +8 -8
- package/dist/connectionPrerequisite.js +18 -18
- package/dist/connectionSetupController.js +123 -91
- package/dist/createHooks.js +11 -11
- package/dist/form.js +7 -7
- package/dist/index.d.ts +148 -162
- package/dist/index.js +88 -86
- package/dist/invocationWait.js +14 -0
- package/dist/mutationsBus.js +92 -35
- package/dist/outbox.js +137 -108
- package/dist/outboxState.js +7 -0
- package/dist/platform.js +10 -10
- package/dist/query.js +3 -10
- package/dist/rpcCallOnce.js +30 -0
- package/dist/rpcDeclared.js +7 -0
- package/dist/runRpc.js +9 -6
- package/dist/runtime.d.ts +16 -116
- package/dist/runtime.js +16 -16
- package/dist/runtimeContext.js +1 -1
- package/dist/serviceClient.js +23 -23
- package/dist/store.js +3 -3
- package/dist/subscriptionCache.js +1 -1
- package/dist/traceBus.js +7 -1
- package/dist/unknownRpcTag.js +7 -0
- package/dist/uploadBytes.js +83 -0
- package/dist/uploadClient.js +153 -0
- package/dist/useAction.js +148 -74
- package/dist/useAgentChat.js +3 -3
- package/dist/useCapabilityManifest.js +7 -7
- package/dist/useConnectionStatus.js +5 -5
- package/dist/useDataTable.js +4 -4
- package/dist/useEvent.js +22 -22
- package/dist/useFormBinding.js +10 -10
- package/dist/useMutation.js +221 -134
- package/dist/useOnRpcError.js +5 -5
- package/dist/usePreloadedSubscription.js +6 -6
- package/dist/useRpcCaller.js +75 -13
- package/dist/useRpcInvocationOwner.js +29 -0
- package/dist/useSubscription.js +52 -49
- package/dist/useTranscription.js +112 -40
- package/dist/useUpload.js +160 -242
- package/dist/useWorkflow.js +111 -246
- package/dist/workflowClient.js +126 -0
- package/package.json +8 -3
package/dist/useWorkflow.js
CHANGED
|
@@ -1,241 +1,106 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useSubscription as r } from "./useSubscription.js";
|
|
5
|
-
import { runRpcPromise as i } from "./runRpc.js";
|
|
6
|
-
import { awaitResolvedApi as a } from "./awaitResolvedApi.js";
|
|
7
|
-
import { useCallback as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
8
|
-
import { Effect as u, Option as d, Stream as f } from "effect";
|
|
1
|
+
import { useWorkflowClient as e } from "./workflowClient.js";
|
|
2
|
+
import { useSubscription as t } from "./useSubscription.js";
|
|
3
|
+
import { useCallback as n, useMemo as r } from "react";
|
|
9
4
|
// src/useWorkflow.ts
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
} }));
|
|
22
|
-
return i(t.runtime, a);
|
|
23
|
-
}, m = (e, r) => {
|
|
24
|
-
let m = t(e), { descriptors: h } = m, g = c(m);
|
|
25
|
-
if (g.current = m, process.env.NODE_ENV !== "production") {
|
|
26
|
-
let t = h[r]?.kind;
|
|
27
|
-
t !== void 0 && t !== "workflow" && console.error(`[@voltro/client] useWorkflow('${e}', '${r}') targets a ${t}, not a workflow. Use ${t === "mutation" ? "useMutation" : t === "action" ? "useAction" : `the ${t} hook`} instead.`);
|
|
5
|
+
var i = (e) => ({
|
|
6
|
+
...e,
|
|
7
|
+
...e.cause === void 0 ? {} : { cause: {
|
|
8
|
+
...e.cause,
|
|
9
|
+
...e.cause.detail === void 0 ? {} : { detail: { ...e.cause.detail } }
|
|
10
|
+
} }
|
|
11
|
+
}), a = (t, a) => {
|
|
12
|
+
let { descriptors: o, runMethod: s, readMethod: c, tracked: l, pending: u, error: d, data: f } = e(t, a);
|
|
13
|
+
if (process.env.NODE_ENV !== "production") {
|
|
14
|
+
let e = o[a]?.kind;
|
|
15
|
+
e !== void 0 && e !== "workflow" && console.error(`[@voltro/client] useWorkflow('${t}', '${a}') targets a ${e}, not a workflow. Use ${e === "mutation" ? "useMutation" : e === "action" ? "useAction" : `the ${e} hook`} instead.`);
|
|
28
16
|
}
|
|
29
|
-
let [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
let r = "__voltro.workflow.queued.control", { runtime: o, client: s } = await a(g, e, r), c = n(s, r);
|
|
58
|
-
return i(o, f.runHead(c(t)).pipe(u.flatMap((e) => {
|
|
59
|
-
if (d.isSome(e)) {
|
|
60
|
-
if (e.value._tag === "snapshot") return u.succeed(e.value.data);
|
|
61
|
-
if (e.value._tag === "error") return u.fail(e.value.error);
|
|
62
|
-
}
|
|
63
|
-
return u.fail(/* @__PURE__ */ Error("queued workflow control query ended without a snapshot"));
|
|
64
|
-
})));
|
|
65
|
-
}, [e]), E = o(async (t) => {
|
|
66
|
-
let r = "__voltro.workflow.control", { runtime: o, client: s } = await a(g, e, r), c = n(s, r);
|
|
67
|
-
return i(o, f.runHead(c(t)).pipe(u.flatMap((e) => {
|
|
68
|
-
if (d.isSome(e)) {
|
|
69
|
-
if (e.value._tag === "snapshot") return u.succeed(e.value.data);
|
|
70
|
-
if (e.value._tag === "error") return u.fail(e.value.error);
|
|
71
|
-
}
|
|
72
|
-
return u.fail(/* @__PURE__ */ Error("workflow control query ended without a snapshot"));
|
|
73
|
-
})));
|
|
74
|
-
}, [e]), D = o(async (t, n) => {
|
|
75
|
-
let { runtime: r, client: i } = await a(g, e, "__voltro.workflow.cancel");
|
|
76
|
-
return p({
|
|
77
|
-
apiName: e,
|
|
78
|
-
runtime: r,
|
|
79
|
-
client: i,
|
|
80
|
-
tag: "__voltro.workflow.cancel",
|
|
81
|
-
input: {
|
|
82
|
-
...t,
|
|
83
|
-
...n === void 0 ? {} : { control: n }
|
|
84
|
-
},
|
|
85
|
-
spanPrefix: "client.workflow.cancel"
|
|
86
|
-
});
|
|
87
|
-
}, [e]), O = o(async (t, n) => {
|
|
88
|
-
let { runtime: r, client: i } = await a(g, e, "__voltro.workflow.resume");
|
|
89
|
-
return p({
|
|
90
|
-
apiName: e,
|
|
91
|
-
runtime: r,
|
|
92
|
-
client: i,
|
|
93
|
-
tag: "__voltro.workflow.resume",
|
|
94
|
-
input: {
|
|
95
|
-
...t,
|
|
96
|
-
...n === void 0 ? {} : { control: n }
|
|
97
|
-
},
|
|
98
|
-
spanPrefix: "client.workflow.resume"
|
|
99
|
-
});
|
|
100
|
-
}, [e]), k = o(async (t, n, r) => {
|
|
101
|
-
let { runtime: i, client: o } = await a(g, e, "__voltro.workflow.signal");
|
|
102
|
-
return p({
|
|
103
|
-
apiName: e,
|
|
104
|
-
runtime: i,
|
|
105
|
-
client: o,
|
|
106
|
-
tag: "__voltro.workflow.signal",
|
|
107
|
-
input: {
|
|
108
|
-
id: t.id,
|
|
109
|
-
signalName: n,
|
|
110
|
-
...r === void 0 ? {} : { payload: r }
|
|
111
|
-
},
|
|
112
|
-
spanPrefix: "client.workflow.signal"
|
|
113
|
-
});
|
|
114
|
-
}, [e]), A = o(async (t, n, r, i) => {
|
|
115
|
-
let { runtime: o, client: s } = await a(g, e, "__voltro.workflow.update");
|
|
116
|
-
return p({
|
|
117
|
-
apiName: e,
|
|
118
|
-
runtime: o,
|
|
119
|
-
client: s,
|
|
120
|
-
tag: "__voltro.workflow.update",
|
|
121
|
-
input: {
|
|
122
|
-
id: t.id,
|
|
123
|
-
updateName: n,
|
|
124
|
-
...r === void 0 ? {} : { payload: r },
|
|
125
|
-
...i?.timeoutMs === void 0 ? {} : { timeoutMs: i.timeoutMs }
|
|
126
|
-
},
|
|
127
|
-
spanPrefix: "client.workflow.update"
|
|
128
|
-
});
|
|
129
|
-
}, [e]);
|
|
130
|
-
return s(() => ({
|
|
131
|
-
start: C,
|
|
132
|
-
cancelQueued: w,
|
|
133
|
-
readQueuedCancellation: T,
|
|
134
|
-
cancel: D,
|
|
135
|
-
readControl: E,
|
|
136
|
-
resume: O,
|
|
137
|
-
signal: k,
|
|
138
|
-
update: A,
|
|
139
|
-
pending: _,
|
|
140
|
-
error: y,
|
|
141
|
-
data: x
|
|
17
|
+
let p = n((e) => l(a, e, "client.workflow.start"), [l, a]), m = n((e) => s("__voltro.workflow.queued.cancel", i(e), "client.workflow.queued.cancel"), [s]), h = n((e) => c("__voltro.workflow.queued.control", { ...e }, "queued workflow control query ended without a snapshot"), [c]), g = n((e) => c("__voltro.workflow.control", { ...e }, "workflow control query ended without a snapshot"), [c]), _ = n((e, t) => s("__voltro.workflow.cancel", {
|
|
18
|
+
...e,
|
|
19
|
+
...t === void 0 ? {} : { control: i(t) }
|
|
20
|
+
}, "client.workflow.cancel"), [s]), v = n((e, t) => s("__voltro.workflow.resume", {
|
|
21
|
+
...e,
|
|
22
|
+
...t === void 0 ? {} : { control: i(t) }
|
|
23
|
+
}, "client.workflow.resume"), [s]), y = n((e, t, n) => s("__voltro.workflow.signal", {
|
|
24
|
+
id: e.id,
|
|
25
|
+
signalName: t,
|
|
26
|
+
...n === void 0 ? {} : { payload: n }
|
|
27
|
+
}, "client.workflow.signal"), [s]), b = n((e, t, n, r) => s("__voltro.workflow.update", {
|
|
28
|
+
id: e.id,
|
|
29
|
+
updateName: t,
|
|
30
|
+
...n === void 0 ? {} : { payload: n },
|
|
31
|
+
...r?.timeoutMs === void 0 ? {} : { timeoutMs: r.timeoutMs }
|
|
32
|
+
}, "client.workflow.update"), [s]);
|
|
33
|
+
return r(() => ({
|
|
34
|
+
start: p,
|
|
35
|
+
cancelQueued: m,
|
|
36
|
+
readQueuedCancellation: h,
|
|
37
|
+
readControl: g,
|
|
38
|
+
cancel: _,
|
|
39
|
+
resume: v,
|
|
40
|
+
signal: y,
|
|
41
|
+
update: b,
|
|
42
|
+
pending: u,
|
|
43
|
+
error: d,
|
|
44
|
+
data: f
|
|
142
45
|
}), [
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
E,
|
|
148
|
-
O,
|
|
149
|
-
k,
|
|
150
|
-
A,
|
|
46
|
+
p,
|
|
47
|
+
m,
|
|
48
|
+
h,
|
|
49
|
+
g,
|
|
151
50
|
_,
|
|
51
|
+
v,
|
|
152
52
|
y,
|
|
153
|
-
|
|
53
|
+
b,
|
|
54
|
+
u,
|
|
55
|
+
d,
|
|
56
|
+
f
|
|
154
57
|
]);
|
|
155
|
-
},
|
|
156
|
-
let
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
input: {
|
|
167
|
-
id: t.id,
|
|
168
|
-
signalName: n,
|
|
169
|
-
...i === void 0 ? {} : { payload: i }
|
|
170
|
-
},
|
|
171
|
-
spanPrefix: "client.workflow.signal"
|
|
172
|
-
});
|
|
173
|
-
return h(c), c;
|
|
174
|
-
} catch (e) {
|
|
175
|
-
throw f(e), e;
|
|
176
|
-
} finally {
|
|
177
|
-
u(!1);
|
|
178
|
-
}
|
|
179
|
-
}, [e]);
|
|
180
|
-
return s(() => ({
|
|
181
|
-
signal: g,
|
|
182
|
-
pending: i,
|
|
183
|
-
error: d,
|
|
184
|
-
data: m
|
|
58
|
+
}, o = (t) => {
|
|
59
|
+
let { tracked: i, pending: a, error: o, data: s } = e(t, "__voltro.workflow.signal"), c = n((e, t, n) => i("__voltro.workflow.signal", {
|
|
60
|
+
id: e.id,
|
|
61
|
+
signalName: t,
|
|
62
|
+
...n === void 0 ? {} : { payload: n }
|
|
63
|
+
}, "client.workflow.signal"), [i]);
|
|
64
|
+
return r(() => ({
|
|
65
|
+
signal: c,
|
|
66
|
+
pending: a,
|
|
67
|
+
error: o,
|
|
68
|
+
data: s
|
|
185
69
|
}), [
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
70
|
+
c,
|
|
71
|
+
a,
|
|
72
|
+
o,
|
|
73
|
+
s
|
|
190
74
|
]);
|
|
191
|
-
},
|
|
192
|
-
let
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
id: t.id,
|
|
204
|
-
updateName: n,
|
|
205
|
-
...i === void 0 ? {} : { payload: i },
|
|
206
|
-
...o?.timeoutMs === void 0 ? {} : { timeoutMs: o.timeoutMs }
|
|
207
|
-
},
|
|
208
|
-
spanPrefix: "client.workflow.update"
|
|
209
|
-
});
|
|
210
|
-
return h(l), l;
|
|
211
|
-
} catch (e) {
|
|
212
|
-
throw f(e), e;
|
|
213
|
-
} finally {
|
|
214
|
-
u(!1);
|
|
215
|
-
}
|
|
216
|
-
}, [e]);
|
|
217
|
-
return s(() => ({
|
|
218
|
-
update: g,
|
|
219
|
-
pending: i,
|
|
220
|
-
error: d,
|
|
221
|
-
data: m
|
|
75
|
+
}, s = (t) => {
|
|
76
|
+
let { tracked: i, pending: a, error: o, data: s } = e(t, "__voltro.workflow.update"), c = n((e, t, n, r) => i("__voltro.workflow.update", {
|
|
77
|
+
id: e.id,
|
|
78
|
+
updateName: t,
|
|
79
|
+
...n === void 0 ? {} : { payload: n },
|
|
80
|
+
...r?.timeoutMs === void 0 ? {} : { timeoutMs: r.timeoutMs }
|
|
81
|
+
}, "client.workflow.update"), [i]);
|
|
82
|
+
return r(() => ({
|
|
83
|
+
update: c,
|
|
84
|
+
pending: a,
|
|
85
|
+
error: o,
|
|
86
|
+
data: s
|
|
222
87
|
}), [
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
88
|
+
c,
|
|
89
|
+
a,
|
|
90
|
+
o,
|
|
91
|
+
s
|
|
227
92
|
]);
|
|
228
|
-
},
|
|
229
|
-
let
|
|
230
|
-
return
|
|
231
|
-
...
|
|
93
|
+
}, c = (e, n) => {
|
|
94
|
+
let r = t(e, "__voltro.workflow.run", n ? { id: n } : {}, { skip: n === void 0 });
|
|
95
|
+
return r.loading || r.idle || r.failed ? {
|
|
96
|
+
...r,
|
|
232
97
|
run: void 0
|
|
233
98
|
} : {
|
|
234
|
-
...
|
|
235
|
-
run:
|
|
99
|
+
...r,
|
|
100
|
+
run: r.data[0]
|
|
236
101
|
};
|
|
237
|
-
},
|
|
238
|
-
let i =
|
|
102
|
+
}, l = (e, n = {}, r = {}) => {
|
|
103
|
+
let i = t(e, "__voltro.workflow.runs", n, r);
|
|
239
104
|
return i.loading || i.idle || i.failed ? {
|
|
240
105
|
...i,
|
|
241
106
|
runs: []
|
|
@@ -243,26 +108,26 @@ var p = async (t) => {
|
|
|
243
108
|
...i,
|
|
244
109
|
runs: i.data
|
|
245
110
|
};
|
|
246
|
-
},
|
|
247
|
-
let
|
|
248
|
-
return
|
|
249
|
-
...
|
|
111
|
+
}, u = (e, n) => {
|
|
112
|
+
let r = t(e, "__voltro.workflow.run.steps", n ? { runId: n } : {}, { skip: n === void 0 });
|
|
113
|
+
return r.loading || r.idle || r.failed ? {
|
|
114
|
+
...r,
|
|
250
115
|
steps: []
|
|
251
116
|
} : {
|
|
252
|
-
...
|
|
253
|
-
steps:
|
|
117
|
+
...r,
|
|
118
|
+
steps: r.data
|
|
254
119
|
};
|
|
255
|
-
},
|
|
256
|
-
let
|
|
257
|
-
return
|
|
258
|
-
...
|
|
120
|
+
}, d = (e, n) => {
|
|
121
|
+
let r = t(e, "__voltro.workflow.run.events", n ? { runId: n } : {}, { skip: n === void 0 });
|
|
122
|
+
return r.loading || r.idle || r.failed ? {
|
|
123
|
+
...r,
|
|
259
124
|
events: []
|
|
260
125
|
} : {
|
|
261
|
-
...
|
|
262
|
-
events:
|
|
126
|
+
...r,
|
|
127
|
+
events: r.data
|
|
263
128
|
};
|
|
264
|
-
},
|
|
265
|
-
let i =
|
|
129
|
+
}, f = d, p = (e, n = {}, r = {}) => {
|
|
130
|
+
let i = t(e, "__voltro.workflow.domainEvents", n, r);
|
|
266
131
|
return i.loading || i.idle || i.failed ? {
|
|
267
132
|
...i,
|
|
268
133
|
events: []
|
|
@@ -270,14 +135,14 @@ var p = async (t) => {
|
|
|
270
135
|
...i,
|
|
271
136
|
events: i.data
|
|
272
137
|
};
|
|
273
|
-
},
|
|
274
|
-
let
|
|
275
|
-
return
|
|
276
|
-
...
|
|
138
|
+
}, m = (e, n) => {
|
|
139
|
+
let r = t(e, "__voltro.workflow.event.deliveries", n ? { eventId: n } : {}, { skip: n === void 0 });
|
|
140
|
+
return r.loading || r.idle || r.failed ? {
|
|
141
|
+
...r,
|
|
277
142
|
deliveries: []
|
|
278
143
|
} : {
|
|
279
|
-
...
|
|
280
|
-
deliveries:
|
|
144
|
+
...r,
|
|
145
|
+
deliveries: r.data
|
|
281
146
|
};
|
|
282
147
|
};
|
|
283
|
-
export {
|
|
148
|
+
export { a as useWorkflow, p as useWorkflowDomainEvents, m as useWorkflowEventDeliveries, f as useWorkflowEvents, c as useWorkflowRun, d as useWorkflowRunEvents, u as useWorkflowRunSteps, l as useWorkflowRuns, o as useWorkflowSignal, s as useWorkflowUpdate };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
2
|
+
import { awaitReadyApi as t, bindResolvedRpcInvocationOwner as n } from "./awaitResolvedApi.js";
|
|
3
|
+
import { useRpcInvocationOwner as r } from "./useRpcInvocationOwner.js";
|
|
4
|
+
import { ConnectionPrerequisiteInvalidated as i } from "./connectionPrerequisite.js";
|
|
5
|
+
import { deferRpcMethod as a, runRpcPromise as o } from "./runRpc.js";
|
|
6
|
+
import { resolveByTag as s } from "./tagWalk.js";
|
|
7
|
+
import { publishClientTrace as c } from "./traceBus.js";
|
|
8
|
+
import { useCallback as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
|
|
9
|
+
import { Effect as m, Option as h, Stream as g } from "effect";
|
|
10
|
+
// src/workflowClient.ts
|
|
11
|
+
var _ = (_, v) => {
|
|
12
|
+
let y = e(_), b = f(y);
|
|
13
|
+
b.current = y;
|
|
14
|
+
let { owner: x, current: S, assertCurrent: C } = r(b, _, v), w = d(() => /* @__PURE__ */ new Set(), [x]), [T, E] = p(() => ({
|
|
15
|
+
owner: x,
|
|
16
|
+
pending: 0,
|
|
17
|
+
error: void 0,
|
|
18
|
+
data: void 0
|
|
19
|
+
}));
|
|
20
|
+
u(() => () => {
|
|
21
|
+
for (let e of w) e.abort();
|
|
22
|
+
w.clear(), E((e) => e.owner === x ? {
|
|
23
|
+
owner: x,
|
|
24
|
+
pending: 0,
|
|
25
|
+
error: void 0,
|
|
26
|
+
data: void 0
|
|
27
|
+
} : e);
|
|
28
|
+
}, [x, w]);
|
|
29
|
+
let D = l(async (e) => {
|
|
30
|
+
C();
|
|
31
|
+
let t = new AbortController();
|
|
32
|
+
w.add(t);
|
|
33
|
+
let n, r = () => t.abort(), a = () => {
|
|
34
|
+
n !== x.subject && (n?.removeEventListener("abort", r), n = x.subject, n.addEventListener("abort", r, { once: !0 })), n.aborted && r();
|
|
35
|
+
};
|
|
36
|
+
a();
|
|
37
|
+
let o = () => S() && !t.signal.aborted, s = {
|
|
38
|
+
signal: t.signal,
|
|
39
|
+
current: o,
|
|
40
|
+
refreshSubject: a,
|
|
41
|
+
assertCurrent: () => {
|
|
42
|
+
if (!o()) throw new i("inactive");
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
try {
|
|
46
|
+
s.assertCurrent();
|
|
47
|
+
let t = await e(s);
|
|
48
|
+
return s.assertCurrent(), t;
|
|
49
|
+
} catch (e) {
|
|
50
|
+
throw s.current() ? e : new i("inactive");
|
|
51
|
+
} finally {
|
|
52
|
+
n?.removeEventListener("abort", r), w.delete(t);
|
|
53
|
+
}
|
|
54
|
+
}, [
|
|
55
|
+
C,
|
|
56
|
+
S,
|
|
57
|
+
x,
|
|
58
|
+
w
|
|
59
|
+
]), O = l(async (e, r) => {
|
|
60
|
+
e.assertCurrent();
|
|
61
|
+
let i = await t(b, _, r, e.signal);
|
|
62
|
+
return n(x, i), e.refreshSubject(), e.assertCurrent(), i;
|
|
63
|
+
}, [_, x]), k = l(async (e, t, n, r) => {
|
|
64
|
+
let { runtime: i, client: l } = await O(e, t), u = s(l, t), d = m.currentSpan.pipe(m.tap((e) => m.sync(() => {
|
|
65
|
+
c({
|
|
66
|
+
traceId: e.traceId,
|
|
67
|
+
spanId: e.spanId,
|
|
68
|
+
source: "mutation",
|
|
69
|
+
tag: t
|
|
70
|
+
});
|
|
71
|
+
})), m.catch(() => m.void), m.andThen(a(() => (e.assertCurrent(), u(n)))), m.withSpan(`${r}.${t}`, { attributes: {
|
|
72
|
+
"voltro.api": _,
|
|
73
|
+
"rpc.tag": t
|
|
74
|
+
} })), f = await o(i, d);
|
|
75
|
+
return e.assertCurrent(), f;
|
|
76
|
+
}, [_, O]), A = l((e, t, n) => D((r) => k(r, e, t, n)), [D, k]), j = l((e, t, n) => D(async (r) => {
|
|
77
|
+
let { runtime: c, client: l } = await O(r, e), u = s(l, e), d = a(() => (r.assertCurrent(), g.runHead(u(t)).pipe(m.flatMap((e) => {
|
|
78
|
+
if (!r.current()) return m.fail(new i("inactive"));
|
|
79
|
+
if (h.isSome(e)) {
|
|
80
|
+
if (e.value._tag === "snapshot") return m.succeed(e.value.data);
|
|
81
|
+
if (e.value._tag === "error") return m.fail(e.value.error);
|
|
82
|
+
}
|
|
83
|
+
return m.fail(Error(n));
|
|
84
|
+
})))), f = await o(c, d, { signal: r.signal });
|
|
85
|
+
return r.assertCurrent(), f;
|
|
86
|
+
}), [D, O]), M = l((e, t, n) => D(async (r) => {
|
|
87
|
+
r.assertCurrent(), E((e) => ({
|
|
88
|
+
owner: x,
|
|
89
|
+
pending: e.owner === x ? e.pending + 1 : 1,
|
|
90
|
+
error: void 0,
|
|
91
|
+
data: e.owner === x ? e.data : void 0
|
|
92
|
+
}));
|
|
93
|
+
try {
|
|
94
|
+
let i = await k(r, e, t, n);
|
|
95
|
+
return r.assertCurrent(), E((e) => e.owner === x ? {
|
|
96
|
+
...e,
|
|
97
|
+
data: i,
|
|
98
|
+
error: void 0
|
|
99
|
+
} : e), i;
|
|
100
|
+
} catch (e) {
|
|
101
|
+
throw r.current() && E((t) => t.owner === x ? {
|
|
102
|
+
...t,
|
|
103
|
+
error: e
|
|
104
|
+
} : t), e;
|
|
105
|
+
} finally {
|
|
106
|
+
r.current() && E((e) => e.owner === x ? {
|
|
107
|
+
...e,
|
|
108
|
+
pending: Math.max(0, e.pending - 1)
|
|
109
|
+
} : e);
|
|
110
|
+
}
|
|
111
|
+
}), [
|
|
112
|
+
D,
|
|
113
|
+
x,
|
|
114
|
+
k
|
|
115
|
+
]), N = T.owner === x ? T : void 0;
|
|
116
|
+
return {
|
|
117
|
+
descriptors: y.descriptors,
|
|
118
|
+
runMethod: A,
|
|
119
|
+
readMethod: j,
|
|
120
|
+
tracked: M,
|
|
121
|
+
pending: (N?.pending ?? 0) > 0,
|
|
122
|
+
error: N?.error,
|
|
123
|
+
data: N?.data
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
export { _ as useWorkflowClient };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.91.0",
|
|
4
4
|
"description": "Framework-agnostic client bindings — the typed RpcClient, subscription cache, and reactive data layer the web hooks build on.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|
|
@@ -43,6 +43,11 @@
|
|
|
43
43
|
"types": "./dist/bootstrap.d.ts",
|
|
44
44
|
"import": "./dist/bootstrap.js",
|
|
45
45
|
"default": "./dist/bootstrap.js"
|
|
46
|
+
},
|
|
47
|
+
"./analytics": {
|
|
48
|
+
"types": "./dist/analytics.d.ts",
|
|
49
|
+
"import": "./dist/analytics.js",
|
|
50
|
+
"default": "./dist/analytics.js"
|
|
46
51
|
}
|
|
47
52
|
},
|
|
48
53
|
"main": "./dist/index.js",
|
|
@@ -55,10 +60,10 @@
|
|
|
55
60
|
"dependencies": {
|
|
56
61
|
"@tanstack/form-core": "^1.33.5",
|
|
57
62
|
"@tanstack/react-store": "^0.11.2",
|
|
58
|
-
"@voltro/protocol": "0.
|
|
63
|
+
"@voltro/protocol": "0.91.0"
|
|
59
64
|
},
|
|
60
65
|
"peerDependencies": {
|
|
61
|
-
"effect": "4.1.
|
|
66
|
+
"effect": "4.1.4",
|
|
62
67
|
"react": "^19.0.0"
|
|
63
68
|
},
|
|
64
69
|
"peerDependenciesMeta": {
|