@voltro/client 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 +5 -89
- package/dist/analyticsCatalog.js +47 -0
- package/dist/apiConnectivity.js +33 -0
- package/dist/apiRuntime.js +135 -0
- package/dist/apiSupervisor.js +125 -0
- package/dist/authRefresh.js +20 -0
- package/dist/awaitResolvedApi.js +23 -0
- package/dist/bootstrap.d.ts +1144 -0
- package/dist/bootstrap.js +8 -0
- package/dist/cellMerger.js +6 -0
- package/dist/clientDiagnostics.js +94 -0
- package/dist/clientErrorBus.js +16 -0
- package/dist/clientScheduler.js +31 -0
- package/dist/connectionPrerequisite.js +70 -0
- package/dist/connectionScope.js +35 -0
- package/dist/connectionSetupController.js +206 -0
- package/dist/createHooks.js +15 -0
- package/dist/deepLink.js +69 -0
- package/dist/filters.js +58 -0
- package/dist/form.d.ts +8 -11
- package/dist/form.js +5 -2
- package/dist/formBinding.js +325 -0
- package/dist/formData.js +65 -0
- package/dist/formFlashId.js +4 -0
- package/dist/frameworkRuntimesContext.js +8 -0
- package/dist/globalContext.js +10 -0
- package/dist/index.d.ts +285 -279
- package/dist/index.js +83 -3686
- package/dist/liveRowSort.js +66 -0
- package/dist/mutationConnectionSetup.js +16 -0
- package/dist/mutationIdentity.js +10 -0
- package/dist/mutationSerialExecution.js +53 -0
- package/dist/mutationsBus.js +40 -0
- package/dist/onlineSource.js +13 -0
- package/dist/outbox.js +213 -0
- package/dist/outboxHttp.js +104 -0
- package/dist/outboxState.js +43 -0
- package/dist/permissions.js +20 -0
- package/dist/platform.js +121 -0
- package/dist/preloadSeed.js +47 -0
- package/dist/provider.js +22 -0
- package/dist/query.js +12 -2
- package/dist/recoveryCoordinator.js +195 -0
- package/dist/recoveryRetry.js +24 -0
- package/dist/richText.js +176 -0
- package/dist/rpcErrorBus.js +39 -0
- package/dist/rpcErrorKind.js +13 -0
- package/dist/runRpc.js +12 -0
- package/dist/runtime.d.ts +79 -15
- package/dist/runtime.js +16 -129
- package/dist/runtimeCapabilities.js +44 -0
- package/dist/runtimeContext.js +49 -0
- package/dist/schemaFields.js +219 -0
- package/dist/scopeMembership.js +12 -0
- package/dist/seedResolvers.js +7 -0
- package/dist/sequence.js +65 -0
- package/dist/serverRequest.js +24 -0
- package/dist/serviceClient.js +128 -0
- package/dist/squashRpcCause.js +8 -0
- package/dist/stableKey.js +21 -0
- package/dist/store.js +288 -0
- package/dist/storeStorage.js +28 -0
- package/dist/subscriptionCache.js +724 -0
- package/dist/tagWalk.js +23 -0
- package/dist/traceBus.js +10 -0
- package/dist/tracking.js +40 -0
- package/dist/uploadProgress.js +21 -0
- package/dist/useAction.js +101 -0
- package/dist/useAgent.js +53 -0
- package/dist/useAgentChat.js +43 -0
- package/dist/useAgentStream.js +64 -0
- package/dist/useApiOnline.js +14 -0
- package/dist/useCapabilityManifest.js +101 -0
- package/dist/useConnectionSetup.js +28 -0
- package/dist/useConnectionStatus.js +38 -0
- package/dist/useConnections.js +107 -0
- package/dist/useDataCopilot.js +24 -0
- package/dist/useDataTable.js +34 -0
- package/dist/useDerived.js +22 -0
- package/dist/useEvent.js +88 -0
- package/dist/useFormBinding.js +476 -0
- package/dist/useLocalQuery.js +59 -0
- package/dist/useMutation.js +214 -0
- package/dist/useOnRpcError.js +13 -0
- package/dist/usePreloadedSubscription.js +18 -0
- package/dist/usePreview.js +14 -0
- package/dist/useProvenance.js +51 -0
- package/dist/useQueryField.js +34 -0
- package/dist/useRecord.js +12 -0
- package/dist/useRefreshSubscriptions.js +22 -0
- package/dist/useResourceCan.js +18 -0
- package/dist/useResumableAgentStream.js +75 -0
- package/dist/useSequence.js +25 -0
- package/dist/useSkeleton.js +13 -0
- package/dist/useSubscription.js +89 -0
- package/dist/useSubscriptionHealth.js +32 -0
- package/dist/useTranscription.js +51 -0
- package/dist/useUndo.js +33 -0
- package/dist/useUndoLog.js +44 -0
- package/dist/useUpload.js +296 -0
- package/dist/useWindowedSubscription.js +65 -0
- package/dist/useWorkflow.js +284 -0
- package/dist/useWorkflowRunState.js +93 -0
- package/dist/validation.js +39 -0
- package/dist/validationMessages.js +5 -0
- package/package.json +8 -5
- package/dist/authRefresh-C4Ow8HH7.js +0 -346
- package/dist/formData-dGz5aoUR.js +0 -649
- package/dist/queryOnce-CvdopzOj.js +0 -55
- package/dist/runRpc-DvHpFZAZ.js +0 -1034
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { publishClientTrace as e } from "./traceBus.js";
|
|
2
|
+
import { rpcErrorKind as t } from "./rpcErrorKind.js";
|
|
3
|
+
import { recoveryCoordinatorFor as n } from "./recoveryCoordinator.js";
|
|
4
|
+
import { useFrameworkApi as r } from "./runtimeContext.js";
|
|
5
|
+
import { connectionScopeForRuntime as i } from "./connectionScope.js";
|
|
6
|
+
import { resolveByTag as a } from "./tagWalk.js";
|
|
7
|
+
import { runRpcPromise as o } from "./runRpc.js";
|
|
8
|
+
import { awaitResolvedApi as s } from "./awaitResolvedApi.js";
|
|
9
|
+
import { settleMutation as c, startMutation as l } from "./mutationsBus.js";
|
|
10
|
+
import { bindMutationConnectionSetup as u, captureMutationConnectionSetup as d, connectionSetupOwner as f } from "./mutationConnectionSetup.js";
|
|
11
|
+
import { freshIdempotencyKey as p, withIdempotencyKey as m } from "./mutationIdentity.js";
|
|
12
|
+
import { MutationSerialExecutionError as h, makeMutationSerialExecution as g } from "./mutationSerialExecution.js";
|
|
13
|
+
import { useCallback as _, useMemo as v, useRef as y, useState as b } from "react";
|
|
14
|
+
import { Effect as x } from "effect";
|
|
15
|
+
//#region src/useMutation.ts
|
|
16
|
+
var S = /* @__PURE__ */ new WeakMap(), C = (e, t, n) => {
|
|
17
|
+
let r = S.get(e);
|
|
18
|
+
r === void 0 && (r = /* @__PURE__ */ new Map(), S.set(e, r));
|
|
19
|
+
let i = r.get(t);
|
|
20
|
+
return i === void 0 && (i = g(n), r.set(t, i)), i;
|
|
21
|
+
}, w = (e, t) => {
|
|
22
|
+
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
23
|
+
try {
|
|
24
|
+
Object.defineProperty(e, "__voltroTraceId", {
|
|
25
|
+
value: t,
|
|
26
|
+
enumerable: !1,
|
|
27
|
+
configurable: !0
|
|
28
|
+
});
|
|
29
|
+
} catch {}
|
|
30
|
+
return e;
|
|
31
|
+
}, T, E = (e) => {
|
|
32
|
+
T = e;
|
|
33
|
+
}, D = () => T, O = (e, t, n) => typeof e == "function" ? e(t, n) : e, k = 0, A = () => `mut_${++k}`, j = (e, t) => ({
|
|
34
|
+
update: (n, r) => {
|
|
35
|
+
e.update(n, r, t);
|
|
36
|
+
},
|
|
37
|
+
forTag: (n, r) => e.forTag(n, r, t)
|
|
38
|
+
}), M = (h, g) => {
|
|
39
|
+
let S = r(h), { descriptors: E } = S, D = y(S);
|
|
40
|
+
D.current = S;
|
|
41
|
+
let k = E[g], M = k?.targets;
|
|
42
|
+
if (process.env.NODE_ENV !== "production") {
|
|
43
|
+
let e = k?.kind;
|
|
44
|
+
e !== void 0 && e !== "mutation" && console.error(`[@voltro/client] useMutation('${h}', '${g}') targets a ${e}, not a mutation. Use ${e === "action" ? "useAction" : e === "workflow" ? "useWorkflow" : `the ${e} hook`} instead.`);
|
|
45
|
+
}
|
|
46
|
+
let [N, P] = b(!1), [F, I] = b(void 0), [L, R] = b(void 0), z = y(null), B = y(!1), V = y(0), H = _(async (r, u) => {
|
|
47
|
+
let f = u?.onError !== void 0 || u?.notify?.error !== void 0, _ = (e) => {
|
|
48
|
+
u?.onError?.(e, r);
|
|
49
|
+
let t = O(u?.notify?.error, e, r);
|
|
50
|
+
t !== void 0 && T?.error(t);
|
|
51
|
+
};
|
|
52
|
+
V.current += 1;
|
|
53
|
+
let v = () => P(--V.current > 0);
|
|
54
|
+
P(!0), I(void 0);
|
|
55
|
+
let y, b, S, E, k;
|
|
56
|
+
try {
|
|
57
|
+
E = d(H);
|
|
58
|
+
let e = D.current.descriptors[g]?.serialize;
|
|
59
|
+
if (e !== void 0) {
|
|
60
|
+
let t = D.current, i = t.recovery ?? n(t.errorBus, h);
|
|
61
|
+
k = C(t.descriptors, g, e.maxPending ?? 32).reserve(e.key(r), i.subjectSignal);
|
|
62
|
+
}
|
|
63
|
+
({runtime: y, cache: b, client: S} = await s(D, h, g));
|
|
64
|
+
} catch (e) {
|
|
65
|
+
if (k?.release(), v(), I(e), D.current.errorBus.emit({
|
|
66
|
+
source: "mutation",
|
|
67
|
+
tag: g,
|
|
68
|
+
error: e,
|
|
69
|
+
kind: "client",
|
|
70
|
+
outcome: "not-started"
|
|
71
|
+
}), f) return _(e);
|
|
72
|
+
throw e;
|
|
73
|
+
}
|
|
74
|
+
let N = A(), F = u?.idempotencyKey ?? p();
|
|
75
|
+
l({
|
|
76
|
+
id: N,
|
|
77
|
+
apiName: h,
|
|
78
|
+
tag: g,
|
|
79
|
+
input: r
|
|
80
|
+
});
|
|
81
|
+
let L = z.current, U = B.current;
|
|
82
|
+
try {
|
|
83
|
+
L ? L(j(b, N), r) : !U && M && M.length > 0 && b.autoApply(M, r, N);
|
|
84
|
+
} catch (e) {
|
|
85
|
+
if (k?.release(), I(e), v(), b.revertByMutation(N), c(N, {
|
|
86
|
+
status: "error",
|
|
87
|
+
error: e
|
|
88
|
+
}), f) return _(e);
|
|
89
|
+
throw e;
|
|
90
|
+
}
|
|
91
|
+
let W, G = !1, K, q, J, Y = Date.now();
|
|
92
|
+
try {
|
|
93
|
+
if (k) {
|
|
94
|
+
await k.ready, k.assertActive();
|
|
95
|
+
let e = await s(D, h, g);
|
|
96
|
+
y = e.runtime, S = e.client;
|
|
97
|
+
}
|
|
98
|
+
let l = async (t, n, s, c) => {
|
|
99
|
+
let l = i(t), u = l?.getSnapshot();
|
|
100
|
+
q = l === void 0 ? void 0 : () => D.current.runtime === t && u !== void 0 && l.getSnapshot() === u, c?.(), k?.assertActive();
|
|
101
|
+
let d = E === void 0 ? void 0 : await E.prepare(t, n);
|
|
102
|
+
u = l?.getSnapshot(), c?.();
|
|
103
|
+
let f = a(n, g), p = m(f(r), F), _ = x.currentSpan.pipe(x.tap((t) => x.sync(() => {
|
|
104
|
+
W = t.traceId, e({
|
|
105
|
+
traceId: t.traceId,
|
|
106
|
+
spanId: t.spanId,
|
|
107
|
+
source: "mutation",
|
|
108
|
+
tag: g
|
|
109
|
+
});
|
|
110
|
+
})), x.catch(() => x.void), x.andThen(x.try({
|
|
111
|
+
try: () => {
|
|
112
|
+
c?.(), k?.assertActive(), G = !0;
|
|
113
|
+
},
|
|
114
|
+
catch: (e) => e
|
|
115
|
+
})), x.andThen(p)).pipe(x.withSpan(`client.mutation.${g}`, { attributes: {
|
|
116
|
+
"voltro.api": h,
|
|
117
|
+
"voltro.mutationId": N,
|
|
118
|
+
"rpc.tag": g,
|
|
119
|
+
"voltro.replay": s
|
|
120
|
+
} }));
|
|
121
|
+
return d === void 0 ? o(t, _) : d.run(_);
|
|
122
|
+
}, d;
|
|
123
|
+
try {
|
|
124
|
+
d = await l(y, S, !1);
|
|
125
|
+
} catch (e) {
|
|
126
|
+
let r = t(e, G ? "handler" : "client"), i = w(e, W);
|
|
127
|
+
r === "transport" && (D.current.errorBus.emit({
|
|
128
|
+
source: "mutation",
|
|
129
|
+
tag: g,
|
|
130
|
+
error: i,
|
|
131
|
+
kind: r,
|
|
132
|
+
...q === void 0 ? {} : { affectsTransport: q() },
|
|
133
|
+
outcome: G ? "unknown" : "not-started",
|
|
134
|
+
...W === void 0 ? {} : { traceId: W }
|
|
135
|
+
}), K = i);
|
|
136
|
+
let a = D.current, o = a.recovery ?? n(a.errorBus, h), c = r === "transport" ? o.reserveMutationReplay(Y) : void 0;
|
|
137
|
+
if (c === void 0) throw i;
|
|
138
|
+
try {
|
|
139
|
+
if (!await o.waitForMutationReplaySupport(Y) || !await o.waitForProtocolReady(Y) || !c.isValid()) throw i;
|
|
140
|
+
let e = () => {
|
|
141
|
+
if (!c.isValid()) throw i;
|
|
142
|
+
};
|
|
143
|
+
for (;;) {
|
|
144
|
+
e();
|
|
145
|
+
let t = await s(D, h, g);
|
|
146
|
+
try {
|
|
147
|
+
d = await l(t.runtime, t.client, !0, e);
|
|
148
|
+
break;
|
|
149
|
+
} catch (t) {
|
|
150
|
+
let n = t;
|
|
151
|
+
if (n?._tag !== "MutationInFlight") throw t;
|
|
152
|
+
let r = typeof n.retryAfterMs == "number" && Number.isFinite(n.retryAfterMs) && n.retryAfterMs > 0 ? n.retryAfterMs : 1e3;
|
|
153
|
+
if (r >= o.replayWindowRemaining(Y)) throw t;
|
|
154
|
+
await new Promise((e) => setTimeout(e, r)), e();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
} finally {
|
|
158
|
+
c.release();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
R(d), c(N, {
|
|
162
|
+
status: "success",
|
|
163
|
+
output: d
|
|
164
|
+
}), D.current.errorBus.emitSuccess({
|
|
165
|
+
source: "mutation",
|
|
166
|
+
tag: g
|
|
167
|
+
}), b.confirmByMutation(N), u?.onSuccess?.(d, r);
|
|
168
|
+
let f = O(u?.notify?.success, d, r);
|
|
169
|
+
return f !== void 0 && T?.success(f), d;
|
|
170
|
+
} catch (e) {
|
|
171
|
+
G && (K !== void 0 || t(e, "handler") === "transport") && (J = "unknown");
|
|
172
|
+
let n = w(e, W);
|
|
173
|
+
if (I(n), c(N, {
|
|
174
|
+
status: "error",
|
|
175
|
+
error: n
|
|
176
|
+
}), b.revertByMutation(N), Object.is(K, n) || D.current.errorBus.emit({
|
|
177
|
+
source: "mutation",
|
|
178
|
+
tag: g,
|
|
179
|
+
error: n,
|
|
180
|
+
kind: G ? t(e, "handler") : "client",
|
|
181
|
+
...q === void 0 ? {} : { affectsTransport: q() },
|
|
182
|
+
outcome: G && t(e, "handler") === "transport" ? "unknown" : G ? "known" : "not-started",
|
|
183
|
+
...W === void 0 ? {} : { traceId: W }
|
|
184
|
+
}), f) return _(n);
|
|
185
|
+
throw n;
|
|
186
|
+
} finally {
|
|
187
|
+
k?.release(J), v();
|
|
188
|
+
}
|
|
189
|
+
}, [
|
|
190
|
+
h,
|
|
191
|
+
g,
|
|
192
|
+
M
|
|
193
|
+
]);
|
|
194
|
+
return v(() => {
|
|
195
|
+
let e = {
|
|
196
|
+
mutate: H,
|
|
197
|
+
pending: N,
|
|
198
|
+
error: F,
|
|
199
|
+
data: L,
|
|
200
|
+
withOptimistic: (t) => (z.current = t, e),
|
|
201
|
+
withoutOptimistic: () => (B.current = !0, e),
|
|
202
|
+
withConnectionSetup: (t) => (u(H, f(t, h)), e)
|
|
203
|
+
};
|
|
204
|
+
return e;
|
|
205
|
+
}, [
|
|
206
|
+
H,
|
|
207
|
+
N,
|
|
208
|
+
F,
|
|
209
|
+
L,
|
|
210
|
+
h
|
|
211
|
+
]);
|
|
212
|
+
};
|
|
213
|
+
//#endregion
|
|
214
|
+
export { h as MutationSerialExecutionError, p as freshIdempotencyKey, D as getMutationNotifier, E as setMutationNotifier, M as useMutation, m as withIdempotencyKey };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { recoveryCoordinatorFor as e } from "./recoveryCoordinator.js";
|
|
2
|
+
import { useFrameworkApi as t } from "./runtimeContext.js";
|
|
3
|
+
import { useEffect as n, useRef as r } from "react";
|
|
4
|
+
//#region src/useOnRpcError.ts
|
|
5
|
+
var i = (i, a) => {
|
|
6
|
+
let o = t(i), s = o.recovery ?? e(o.errorBus, i), c = r(a);
|
|
7
|
+
c.current = a, n(() => s.onVisibleError((e) => c.current(e)), [s]);
|
|
8
|
+
}, a = (e, i) => {
|
|
9
|
+
let { errorBus: a } = t(e), o = r(i);
|
|
10
|
+
o.current = i, n(() => a.on((e) => o.current(e)), [a]);
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { a as useOnRawRpcError, i as useOnRpcError };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
2
|
+
import { useSubscription as t } from "./useSubscription.js";
|
|
3
|
+
import { readPreloadedSeedOutcome as n, readPreloadedSnapshot as r } from "./preloadSeed.js";
|
|
4
|
+
import { useSyncExternalStore as i } from "react";
|
|
5
|
+
//#region src/usePreloadedSubscription.ts
|
|
6
|
+
var a = () => !0, o = (e) => () => {};
|
|
7
|
+
function s(s, c, l = {}, u = {}) {
|
|
8
|
+
let { recovery: d } = e(s), f = i(d?.subscribe ?? o, d?.getPreloadSeedPermission ?? a, a), p = f ? r(s, c, l) : void 0, m = p === void 0 ? u : {
|
|
9
|
+
...u,
|
|
10
|
+
initialSnapshot: p
|
|
11
|
+
}, h = t(s, c, l, m);
|
|
12
|
+
return f && n(s, c, l) === "failed" ? {
|
|
13
|
+
...h,
|
|
14
|
+
preloadFailed: !0
|
|
15
|
+
} : h;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { s as usePreloadedSubscription };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useAction as e } from "./useAction.js";
|
|
2
|
+
import { useCallback as t } from "react";
|
|
3
|
+
//#region src/usePreview.ts
|
|
4
|
+
var n = (n, r) => {
|
|
5
|
+
let i = e(n, r);
|
|
6
|
+
return {
|
|
7
|
+
preview: t((e) => i.run(e), [i]),
|
|
8
|
+
diff: i.lastResult,
|
|
9
|
+
pending: i.pending,
|
|
10
|
+
error: i.error
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { n as usePreview };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
2
|
+
import { useEffect as t, useState as n } from "react";
|
|
3
|
+
//#region src/useProvenance.ts
|
|
4
|
+
var r = (e, t, n, r) => {
|
|
5
|
+
let i = e.replace(/\/$/, ""), a = new URLSearchParams({
|
|
6
|
+
table: t,
|
|
7
|
+
id: n
|
|
8
|
+
});
|
|
9
|
+
return r !== void 0 && a.set("column", r), `${i}/_voltro/inspect/provenance?${a.toString()}`;
|
|
10
|
+
}, i = r, a = (i, a, o, s) => {
|
|
11
|
+
let { inspectBaseUrl: c } = e(i), [l, u] = n({
|
|
12
|
+
data: void 0,
|
|
13
|
+
loading: !0,
|
|
14
|
+
error: void 0
|
|
15
|
+
});
|
|
16
|
+
return t(() => {
|
|
17
|
+
let e = !1;
|
|
18
|
+
u({
|
|
19
|
+
data: void 0,
|
|
20
|
+
loading: !0,
|
|
21
|
+
error: void 0
|
|
22
|
+
});
|
|
23
|
+
let t = r(c ?? "", a, o, s);
|
|
24
|
+
return fetch(t).then(async (e) => {
|
|
25
|
+
if (!e.ok) throw Error(`provenance fetch failed: HTTP ${e.status}`);
|
|
26
|
+
return await e.json();
|
|
27
|
+
}).then((t) => {
|
|
28
|
+
e || u({
|
|
29
|
+
data: t,
|
|
30
|
+
loading: !1,
|
|
31
|
+
error: void 0
|
|
32
|
+
});
|
|
33
|
+
}).catch((t) => {
|
|
34
|
+
e || u({
|
|
35
|
+
data: void 0,
|
|
36
|
+
loading: !1,
|
|
37
|
+
error: t
|
|
38
|
+
});
|
|
39
|
+
}), () => {
|
|
40
|
+
e = !0;
|
|
41
|
+
};
|
|
42
|
+
}, [
|
|
43
|
+
i,
|
|
44
|
+
c,
|
|
45
|
+
a,
|
|
46
|
+
o,
|
|
47
|
+
s
|
|
48
|
+
]), l;
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { i as provenanceUrl, a as useProvenance };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useSubscription as e } from "./useSubscription.js";
|
|
2
|
+
import { useCallback as t, useEffect as n, useMemo as r, useState as i } from "react";
|
|
3
|
+
//#region src/useQueryField.ts
|
|
4
|
+
var a = (e, t, n) => e.map((e) => {
|
|
5
|
+
let r = String(e[n] ?? ""), i = e[t];
|
|
6
|
+
return {
|
|
7
|
+
value: r,
|
|
8
|
+
label: i == null ? r : String(i)
|
|
9
|
+
};
|
|
10
|
+
}), o = (e) => ({ q: e }), s = (s, c, l = {}) => {
|
|
11
|
+
let u = l.debounceMs ?? 200, d = l.labelField ?? "name", f = l.valueField ?? "id", p = l.input ?? o, [m, h] = i(l.initialTerm ?? ""), [g, _] = i(m);
|
|
12
|
+
n(() => {
|
|
13
|
+
if (m === g) return;
|
|
14
|
+
let e = setTimeout(() => _(m), u);
|
|
15
|
+
return () => clearTimeout(e);
|
|
16
|
+
}, [
|
|
17
|
+
m,
|
|
18
|
+
g,
|
|
19
|
+
u
|
|
20
|
+
]);
|
|
21
|
+
let v = l.skipUntilTerm === !0 && g.trim() === "", y = r(() => p(g), [p, g]), b = e(s, c, y, { skip: v }), x = r(() => a(b.data ?? [], d, f), [
|
|
22
|
+
b.data,
|
|
23
|
+
d,
|
|
24
|
+
f
|
|
25
|
+
]), S = t((e) => h(e), []);
|
|
26
|
+
return {
|
|
27
|
+
options: x,
|
|
28
|
+
loading: !v && b.data === void 0,
|
|
29
|
+
term: m,
|
|
30
|
+
search: S
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { a as rowsToOptions, s as useQueryField };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useSubscription as e } from "./useSubscription.js";
|
|
2
|
+
//#region src/useRecord.ts
|
|
3
|
+
var t = (t, n, r = {}) => {
|
|
4
|
+
let i = e(t, n, r), a = i.data;
|
|
5
|
+
return {
|
|
6
|
+
record: Array.isArray(a) ? a[0] : a,
|
|
7
|
+
loading: a === void 0,
|
|
8
|
+
error: i.error
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as useRecord };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { stableKey as e } from "./stableKey.js";
|
|
2
|
+
import { useFrameworkApi as t } from "./runtimeContext.js";
|
|
3
|
+
import { useCallback as n, useMemo as r, useRef as i } from "react";
|
|
4
|
+
//#region src/useRefreshSubscriptions.ts
|
|
5
|
+
var a = (e) => {
|
|
6
|
+
let { cache: r, runtime: i, recovery: a } = t(e);
|
|
7
|
+
return n(() => {
|
|
8
|
+
a?.invalidatePreloadSeeds(), r.refreshAll(i);
|
|
9
|
+
}, [
|
|
10
|
+
r,
|
|
11
|
+
i,
|
|
12
|
+
a
|
|
13
|
+
]);
|
|
14
|
+
}, o = (n, a, o) => {
|
|
15
|
+
let { cache: s } = t(n), c = e([a, o]), l = i([a, o]);
|
|
16
|
+
return l.current = [a, o], r(() => {
|
|
17
|
+
let e = l.current;
|
|
18
|
+
return () => s.refresh(e);
|
|
19
|
+
}, [s, c]);
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { o as useRefreshSubscription, a as useRefreshSubscriptions };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useSubscription as e } from "./useSubscription.js";
|
|
2
|
+
import { useMemo as t } from "react";
|
|
3
|
+
//#region src/useResourceCan.ts
|
|
4
|
+
var n = (n, r, i, a = {}) => {
|
|
5
|
+
let o = e(n, r, { ...i }, a);
|
|
6
|
+
return t(() => ({
|
|
7
|
+
allowed: o.data?.allowed === !0,
|
|
8
|
+
pending: o.data === void 0
|
|
9
|
+
}), [o.data]);
|
|
10
|
+
}, r = (n, r, i, a = {}) => {
|
|
11
|
+
let o = e(n, r, { ...i }, a);
|
|
12
|
+
return t(() => ({
|
|
13
|
+
allowedIds: new Set(o.data?.allowedIds ?? []),
|
|
14
|
+
pending: o.data === void 0
|
|
15
|
+
}), [o.data]);
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { n as useResourceCan, r as useResourceCans };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { squashRpcCause as e } from "./squashRpcCause.js";
|
|
2
|
+
import { useFrameworkApi as t } from "./runtimeContext.js";
|
|
3
|
+
import { resolveByTag as n } from "./tagWalk.js";
|
|
4
|
+
import { useCallback as r, useRef as i, useState as a } from "react";
|
|
5
|
+
import { Cause as o, Duration as s, Effect as c, Fiber as l, Stream as u } from "effect";
|
|
6
|
+
//#region src/useResumableAgentStream.ts
|
|
7
|
+
var d = (t, n, r, i) => {
|
|
8
|
+
let a = 0, l = !1, d = (e) => c.sync(() => {
|
|
9
|
+
e.seq <= a || (a = e.seq, r.onEvent(e.event), i.isTerminal(e.event) && (l = !0));
|
|
10
|
+
}), f = (e) => {
|
|
11
|
+
if (typeof e != "object" || !e) return;
|
|
12
|
+
let t = e.name, n = e.message;
|
|
13
|
+
if (typeof t == "string" || typeof n == "string") return `${typeof t == "string" ? t : ""}::${typeof n == "string" ? n : ""}`;
|
|
14
|
+
}, p, m = (e, t, n) => {
|
|
15
|
+
let o = a > t, l = o ? 0 : e + 1, u = n === void 0 ? void 0 : f(n), d = u !== void 0 && u === p && !o;
|
|
16
|
+
if (p = o ? void 0 : u, d || l > i.maxReconnects) return c.sync(() => {
|
|
17
|
+
r.onError(n ?? /* @__PURE__ */ Error("stream connection lost")), r.onStatus("error");
|
|
18
|
+
});
|
|
19
|
+
let m = Math.min(i.maxBackoffMs, i.backoffMs * 2 ** Math.max(0, l - 1));
|
|
20
|
+
return c.sync(() => {
|
|
21
|
+
r.onStatus("reconnecting"), r.onReconnect();
|
|
22
|
+
}).pipe(c.andThen(c.sleep(s.millis(m))), c.andThen(c.sync(() => r.onStatus("streaming"))), c.andThen(h(l)));
|
|
23
|
+
}, h = (i) => c.suspend(() => {
|
|
24
|
+
let s = a, f = t({
|
|
25
|
+
...n,
|
|
26
|
+
fromSeq: s
|
|
27
|
+
});
|
|
28
|
+
return u.runForEach(f, d).pipe(c.matchCauseEffect({
|
|
29
|
+
onSuccess: () => l ? c.sync(() => r.onStatus("done")) : m(i, s, void 0),
|
|
30
|
+
onFailure: (t) => o.hasInterruptsOnly(t) ? c.void : l ? c.sync(() => r.onStatus("done")) : m(i, s, e(t))
|
|
31
|
+
}));
|
|
32
|
+
});
|
|
33
|
+
return h(0);
|
|
34
|
+
}, f = (e) => {
|
|
35
|
+
let t = e?._tag;
|
|
36
|
+
return t === "done" || t === "error";
|
|
37
|
+
}, p = (e, o, s = {}) => {
|
|
38
|
+
let { runtime: c, client: u } = t(e), [p, m] = a([]), [h, g] = a("idle"), [_, v] = a(0), [y, b] = a(void 0), x = i(null), S = {
|
|
39
|
+
maxReconnects: s.maxReconnects ?? 6,
|
|
40
|
+
backoffMs: s.backoffMs ?? 400,
|
|
41
|
+
maxBackoffMs: s.maxBackoffMs ?? 8e3,
|
|
42
|
+
isTerminal: s.isTerminal ?? f
|
|
43
|
+
}, C = r(() => {
|
|
44
|
+
let e = x.current;
|
|
45
|
+
e && (x.current = null, c.runFork(l.interrupt(e)), g((e) => e === "streaming" || e === "reconnecting" ? "idle" : e));
|
|
46
|
+
}, [c]);
|
|
47
|
+
return {
|
|
48
|
+
events: p,
|
|
49
|
+
status: h,
|
|
50
|
+
reconnects: _,
|
|
51
|
+
error: y,
|
|
52
|
+
start: r((e = {}) => {
|
|
53
|
+
let t = x.current;
|
|
54
|
+
t && c.runFork(l.interrupt(t)), m([]), b(void 0), v(0), g("streaming");
|
|
55
|
+
let r = n(u, o), i = {
|
|
56
|
+
onEvent: (e) => m((t) => [...t, e]),
|
|
57
|
+
onStatus: g,
|
|
58
|
+
onReconnect: () => v((e) => e + 1),
|
|
59
|
+
onError: b
|
|
60
|
+
};
|
|
61
|
+
x.current = c.runFork(d(r, e, i, S));
|
|
62
|
+
}, [
|
|
63
|
+
c,
|
|
64
|
+
u,
|
|
65
|
+
o,
|
|
66
|
+
S.maxReconnects,
|
|
67
|
+
S.backoffMs,
|
|
68
|
+
S.maxBackoffMs,
|
|
69
|
+
S.isTerminal
|
|
70
|
+
]),
|
|
71
|
+
cancel: C
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
export { d as resumableConsumeProgram, p as useResumableAgentStream };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { runSequence as e } from "./sequence.js";
|
|
2
|
+
import { useCallback as t, useRef as n, useState as r } from "react";
|
|
3
|
+
//#region src/useSequence.ts
|
|
4
|
+
var i = (i = {}) => {
|
|
5
|
+
let [a, o] = r(!1), [s, c] = r(void 0), [l, u] = r(void 0), d = n(i);
|
|
6
|
+
return d.current = i, {
|
|
7
|
+
run: t(async (t, n = {}) => {
|
|
8
|
+
o(!0), c(void 0), u(void 0);
|
|
9
|
+
try {
|
|
10
|
+
let r = {
|
|
11
|
+
...d.current,
|
|
12
|
+
...n
|
|
13
|
+
}, i = await e(t, r);
|
|
14
|
+
return i.ok || (c(i.error), u(i.failedStep)), i;
|
|
15
|
+
} finally {
|
|
16
|
+
o(!1);
|
|
17
|
+
}
|
|
18
|
+
}, []),
|
|
19
|
+
pending: a,
|
|
20
|
+
error: s,
|
|
21
|
+
failedStep: l
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { i as useSequence };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
2
|
+
import { schemaToColumns as t, schemaToFields as n } from "./schemaFields.js";
|
|
3
|
+
import { useMemo as r } from "react";
|
|
4
|
+
//#region src/useSkeleton.ts
|
|
5
|
+
var i = (t, i) => {
|
|
6
|
+
let a = e(t).descriptors[i]?.input;
|
|
7
|
+
return r(() => a === void 0 ? [] : n(a), [a]);
|
|
8
|
+
}, a = (n, i) => {
|
|
9
|
+
let a = e(n).descriptors[i]?.output;
|
|
10
|
+
return r(() => a === void 0 ? [] : t(a), [a]);
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { i as useFormSkeleton, a as useTableSkeleton };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
2
|
+
import { resolveByTag as t } from "./tagWalk.js";
|
|
3
|
+
import { useCallback as n, useMemo as r, useRef as i, useSyncExternalStore as a } from "react";
|
|
4
|
+
//#region src/useSubscription.ts
|
|
5
|
+
var o = Object.freeze({
|
|
6
|
+
data: void 0,
|
|
7
|
+
revision: -1,
|
|
8
|
+
emittedAt: void 0,
|
|
9
|
+
error: void 0,
|
|
10
|
+
pendingPatches: 0
|
|
11
|
+
}), s = () => o;
|
|
12
|
+
function c(c, l, u = {}, d = {}) {
|
|
13
|
+
let f = d.skip === !0, { runtime: p, cache: m, client: h, descriptors: g } = e(c), _ = g[l]?.source, v = i(u);
|
|
14
|
+
v.current = u;
|
|
15
|
+
let y = i(h);
|
|
16
|
+
y.current = h;
|
|
17
|
+
let b = r(() => JSON.stringify(Object.entries(u).sort(([e], [t]) => e.localeCompare(t))), [u]), x = r(() => {
|
|
18
|
+
let e = v.current;
|
|
19
|
+
return {
|
|
20
|
+
queryKey: [l, e],
|
|
21
|
+
fetch: () => t(y.current, l)(e)
|
|
22
|
+
};
|
|
23
|
+
}, [l, b]), S = x.queryKey, C = n((e) => f ? () => {} : m.subscribe(x.queryKey, x.fetch, p, e, _ === void 0 ? {} : { source: _ }).unsubscribe, [
|
|
24
|
+
m,
|
|
25
|
+
p,
|
|
26
|
+
_,
|
|
27
|
+
f,
|
|
28
|
+
x
|
|
29
|
+
]), w = n(() => f ? o : m.peek(S), [
|
|
30
|
+
m,
|
|
31
|
+
f,
|
|
32
|
+
S
|
|
33
|
+
]), T = a(C, w, s), E = T.data !== void 0, D = E && (Array.isArray(T.data) ? T.data.length === 0 : T.data === null), O = {
|
|
34
|
+
revision: T.revision,
|
|
35
|
+
emittedAt: T.emittedAt,
|
|
36
|
+
error: T.error,
|
|
37
|
+
pendingPatches: T.pendingPatches
|
|
38
|
+
};
|
|
39
|
+
if (d.initialSnapshot !== void 0) {
|
|
40
|
+
let e = Array.isArray(d.initialSnapshot) ? d.initialSnapshot.length === 0 : d.initialSnapshot === null;
|
|
41
|
+
return {
|
|
42
|
+
...O,
|
|
43
|
+
data: E ? T.data : d.initialSnapshot,
|
|
44
|
+
loading: !1,
|
|
45
|
+
idle: f,
|
|
46
|
+
isEmpty: E ? D : e,
|
|
47
|
+
failed: !1
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return d.fallback === void 0 ? f ? {
|
|
51
|
+
...O,
|
|
52
|
+
data: void 0,
|
|
53
|
+
loading: !1,
|
|
54
|
+
isEmpty: !1,
|
|
55
|
+
idle: !0,
|
|
56
|
+
failed: !1
|
|
57
|
+
} : E ? {
|
|
58
|
+
...O,
|
|
59
|
+
data: T.data,
|
|
60
|
+
loading: !1,
|
|
61
|
+
isEmpty: D,
|
|
62
|
+
idle: !1,
|
|
63
|
+
failed: !1
|
|
64
|
+
} : O.error === void 0 ? {
|
|
65
|
+
...O,
|
|
66
|
+
data: void 0,
|
|
67
|
+
loading: !0,
|
|
68
|
+
isEmpty: !1,
|
|
69
|
+
idle: !1,
|
|
70
|
+
failed: !1
|
|
71
|
+
} : {
|
|
72
|
+
...O,
|
|
73
|
+
data: void 0,
|
|
74
|
+
loading: !1,
|
|
75
|
+
isEmpty: !1,
|
|
76
|
+
idle: !1,
|
|
77
|
+
failed: !0,
|
|
78
|
+
error: O.error
|
|
79
|
+
} : {
|
|
80
|
+
...O,
|
|
81
|
+
data: E ? T.data : d.fallback,
|
|
82
|
+
loading: !E && !f,
|
|
83
|
+
idle: f,
|
|
84
|
+
isEmpty: D,
|
|
85
|
+
failed: !E && O.error !== void 0
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
export { c as useSubscription };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
2
|
+
import { useEffect as t, useState as n } from "react";
|
|
3
|
+
//#region src/useSubscriptionHealth.ts
|
|
4
|
+
var r = {
|
|
5
|
+
failed: [],
|
|
6
|
+
healthy: !0
|
|
7
|
+
}, i = (i) => {
|
|
8
|
+
let { errorBus: a } = e(i), [o, s] = n(r);
|
|
9
|
+
return t(() => {
|
|
10
|
+
let e = /* @__PURE__ */ new Map(), t = () => {
|
|
11
|
+
let t = [...e.values()].sort((e, t) => t.at - e.at);
|
|
12
|
+
s(t.length === 0 ? r : {
|
|
13
|
+
failed: t,
|
|
14
|
+
healthy: !1
|
|
15
|
+
});
|
|
16
|
+
}, n = a.on((n) => {
|
|
17
|
+
e.set(n.tag, {
|
|
18
|
+
tag: n.tag,
|
|
19
|
+
source: n.source,
|
|
20
|
+
error: n.error,
|
|
21
|
+
at: Date.now()
|
|
22
|
+
}), t();
|
|
23
|
+
}), i = a.onSuccess((n) => {
|
|
24
|
+
e.delete(n.tag) && t();
|
|
25
|
+
});
|
|
26
|
+
return () => {
|
|
27
|
+
n(), i();
|
|
28
|
+
};
|
|
29
|
+
}, [a]), o;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { i as useSubscriptionHealth };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useAction as e } from "./useAction.js";
|
|
2
|
+
import { useUpload as t } from "./useUpload.js";
|
|
3
|
+
import { useCallback as n, useMemo as r, useRef as i, useState as a } from "react";
|
|
4
|
+
//#region src/useTranscription.ts
|
|
5
|
+
var o = (o, s) => {
|
|
6
|
+
let c = t(o), l = e(o, s.action), [u, d] = a("idle"), [f, p] = a(void 0), [m, h] = a(void 0), g = i(s.extra);
|
|
7
|
+
g.current = s.extra;
|
|
8
|
+
let _ = n(async (e) => {
|
|
9
|
+
h(void 0), p(void 0), d("uploading");
|
|
10
|
+
let t;
|
|
11
|
+
try {
|
|
12
|
+
t = await c.upload(e);
|
|
13
|
+
} catch (e) {
|
|
14
|
+
throw d("error"), h(e), e;
|
|
15
|
+
}
|
|
16
|
+
d("transcribing");
|
|
17
|
+
try {
|
|
18
|
+
let e = await l.run({
|
|
19
|
+
storageRef: t.id,
|
|
20
|
+
...g.current ?? {}
|
|
21
|
+
});
|
|
22
|
+
return p(e), d("done"), e;
|
|
23
|
+
} catch (e) {
|
|
24
|
+
throw d("error"), h(e), e;
|
|
25
|
+
}
|
|
26
|
+
}, [c, l]), v = n(() => {
|
|
27
|
+
c.cancel(), d("idle");
|
|
28
|
+
}, [c]), y = n(() => {
|
|
29
|
+
c.reset(), d("idle"), p(void 0), h(void 0);
|
|
30
|
+
}, [c]);
|
|
31
|
+
return r(() => ({
|
|
32
|
+
phase: u,
|
|
33
|
+
progress: u === "uploading" ? c.progress : void 0,
|
|
34
|
+
result: f,
|
|
35
|
+
error: m ?? c.error,
|
|
36
|
+
transcribe: _,
|
|
37
|
+
cancel: v,
|
|
38
|
+
reset: y
|
|
39
|
+
}), [
|
|
40
|
+
u,
|
|
41
|
+
c.progress,
|
|
42
|
+
c.error,
|
|
43
|
+
f,
|
|
44
|
+
m,
|
|
45
|
+
_,
|
|
46
|
+
v,
|
|
47
|
+
y
|
|
48
|
+
]);
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { o as useTranscription };
|