@voltro/client 0.85.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 +666 -0
- package/THIRD-PARTY-NOTICES.md +5 -33
- 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.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 +53 -7
- package/dist/index.js +83 -4121
- 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 +32 -1
- package/dist/runtime.js +16 -126
- 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 +7 -2
- package/dist/authRefresh-DmfSoCca.js +0 -360
- package/dist/formData-BfpBt7BQ.js +0 -769
- package/dist/queryOnce-D5Y4V1SB.js +0 -55
- package/dist/runRpc-Zfz3w709.js +0 -1172
package/dist/tagWalk.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/tagWalk.ts
|
|
2
|
+
var e = (e, t) => {
|
|
3
|
+
let n = t.split("."), r = e, i = 0;
|
|
4
|
+
for (let e = 0; e < n.length; e++) {
|
|
5
|
+
let a = n[e];
|
|
6
|
+
if (r === null || typeof r != "object" && typeof r != "function") throw Error(`@voltro/client: rpc tag ${JSON.stringify(t)} not reachable on client. Stopped at segment ${JSON.stringify(a)}. The api's descriptor map is likely out of sync with the rpc group; restart \`voltro dev\` to regenerate.`);
|
|
7
|
+
let o = r;
|
|
8
|
+
if (a in o) {
|
|
9
|
+
r = o[a], i += a.length + 1;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
let s = t.slice(i);
|
|
13
|
+
if (s in o) {
|
|
14
|
+
r = o[s];
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
throw Error(`@voltro/client: rpc tag ${JSON.stringify(t)} not reachable on client. Stopped at segment ${JSON.stringify(a)}. The api's descriptor map is likely out of sync with the rpc group; restart \`voltro dev\` to regenerate.`);
|
|
18
|
+
}
|
|
19
|
+
if (typeof r != "function") throw Error(`@voltro/client: rpc tag ${JSON.stringify(t)} did not resolve to a callable method.`);
|
|
20
|
+
return r;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { e as resolveByTag };
|
package/dist/traceBus.js
ADDED
package/dist/tracking.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useEffect as e, useMemo as t, useRef as n } from "react";
|
|
2
|
+
//#region src/tracking.ts
|
|
3
|
+
var r = (e, t) => ({
|
|
4
|
+
name: e,
|
|
5
|
+
map: t
|
|
6
|
+
}), i = (e, t) => e === void 0 ? null : typeof e == "string" ? { event: e } : e(t), a = /* @__PURE__ */ new Set(["onMount", "onUnmount"]), o = (e, t, n) => {
|
|
7
|
+
let r = { ...t };
|
|
8
|
+
for (let [o, s] of Object.entries(e.map)) {
|
|
9
|
+
if (a.has(o) || s === void 0) continue;
|
|
10
|
+
let e = t[o];
|
|
11
|
+
r[o] = (...r) => {
|
|
12
|
+
let a = i(s, t);
|
|
13
|
+
if (a !== null && n(a), typeof e == "function") return e(...r);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return r;
|
|
17
|
+
}, s = (r, a, s) => {
|
|
18
|
+
let c = n({
|
|
19
|
+
spec: r,
|
|
20
|
+
props: a,
|
|
21
|
+
sink: s
|
|
22
|
+
});
|
|
23
|
+
return c.current = {
|
|
24
|
+
spec: r,
|
|
25
|
+
props: a,
|
|
26
|
+
sink: s
|
|
27
|
+
}, e(() => {
|
|
28
|
+
let e = c.current, t = i(e.spec.map.onMount, e.props);
|
|
29
|
+
return t !== null && e.sink(t), () => {
|
|
30
|
+
let e = c.current, t = i(e.spec.map.onUnmount, e.props);
|
|
31
|
+
t !== null && e.sink(t);
|
|
32
|
+
};
|
|
33
|
+
}, []), t(() => o(r, a, s), [
|
|
34
|
+
r,
|
|
35
|
+
a,
|
|
36
|
+
s
|
|
37
|
+
]);
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { r as defineTracking, i as resolveTrackingEvent, s as useTracking, o as wrapTrackedCallbacks };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/uploadProgress.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
let t = 1;
|
|
4
|
+
for (; t < e;) t *= 2;
|
|
5
|
+
let n = new Float64Array(t * 2);
|
|
6
|
+
return (r, i, a = e) => {
|
|
7
|
+
if (r >= t) {
|
|
8
|
+
let e = t;
|
|
9
|
+
for (; t <= r;) t *= 2;
|
|
10
|
+
let i = new Float64Array(t * 2);
|
|
11
|
+
i.set(n.subarray(e), t);
|
|
12
|
+
for (let e = t - 1; e > 0; e--) i[e] = i[e * 2] + i[e * 2 + 1];
|
|
13
|
+
n = i;
|
|
14
|
+
}
|
|
15
|
+
let o = t + r;
|
|
16
|
+
for (n[o] = i; o > 1;) o = Math.floor(o / 2), n[o] = n[o * 2] + n[o * 2 + 1];
|
|
17
|
+
return n[1] / a;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { e as createUploadProgress };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { publishClientTrace as e } from "./traceBus.js";
|
|
2
|
+
import { rpcErrorKind as t } from "./rpcErrorKind.js";
|
|
3
|
+
import { useFrameworkApi as n } from "./runtimeContext.js";
|
|
4
|
+
import { resolveByTag as r } from "./tagWalk.js";
|
|
5
|
+
import { runRpcPromise as i } from "./runRpc.js";
|
|
6
|
+
import { awaitReadyApi as a } from "./awaitResolvedApi.js";
|
|
7
|
+
import { settleMutation as o, startMutation as s } from "./mutationsBus.js";
|
|
8
|
+
import { freshIdempotencyKey as c, withIdempotencyKey as l } from "./mutationIdentity.js";
|
|
9
|
+
import { getMutationNotifier as u } from "./useMutation.js";
|
|
10
|
+
import { useCallback as d, useMemo as f, useRef as p, useState as m } from "react";
|
|
11
|
+
import { Effect as h } from "effect";
|
|
12
|
+
//#region src/useAction.ts
|
|
13
|
+
var g = (e, t) => {
|
|
14
|
+
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
15
|
+
try {
|
|
16
|
+
Object.defineProperty(e, "__voltroTraceId", {
|
|
17
|
+
value: t,
|
|
18
|
+
enumerable: !1,
|
|
19
|
+
configurable: !0
|
|
20
|
+
});
|
|
21
|
+
} catch {}
|
|
22
|
+
return e;
|
|
23
|
+
}, _ = (e, t, n) => typeof e == "function" ? e(t, n) : e, v = 0, y = () => `act_${++v}`, b = (v, b) => {
|
|
24
|
+
let x = n(v), { descriptors: S } = x, C = p(x);
|
|
25
|
+
if (C.current = x, process.env.NODE_ENV !== "production") {
|
|
26
|
+
let e = S[b]?.kind;
|
|
27
|
+
e !== void 0 && e !== "action" && console.error(`[@voltro/client] useAction('${v}', '${b}') targets a ${e}, not an action. Use ${e === "mutation" ? "useMutation" : e === "workflow" ? "useWorkflow" : `the ${e} hook`} instead.`);
|
|
28
|
+
}
|
|
29
|
+
let [w, T] = m(!1), [E, D] = m(void 0), [O, k] = m(void 0), A = d(async (n, d) => {
|
|
30
|
+
let f = d?.onError !== void 0 || d?.notify?.error !== void 0;
|
|
31
|
+
T(!0), D(void 0);
|
|
32
|
+
let p = y(), m = d?.idempotencyKey ?? c();
|
|
33
|
+
s({
|
|
34
|
+
id: p,
|
|
35
|
+
apiName: v,
|
|
36
|
+
tag: b,
|
|
37
|
+
input: n,
|
|
38
|
+
kind: "action"
|
|
39
|
+
});
|
|
40
|
+
let x, S = !1;
|
|
41
|
+
try {
|
|
42
|
+
let { runtime: t, client: s } = await a(C, v, b), c = r(s, b), f = h.currentSpan.pipe(h.tap((t) => h.sync(() => {
|
|
43
|
+
x = t.traceId, e({
|
|
44
|
+
traceId: t.traceId,
|
|
45
|
+
spanId: t.spanId,
|
|
46
|
+
source: "action",
|
|
47
|
+
tag: b
|
|
48
|
+
});
|
|
49
|
+
})), h.catch(() => h.void), h.andThen(l(c(n), m))).pipe(h.withSpan(`client.action.${b}`, { attributes: {
|
|
50
|
+
"voltro.api": v,
|
|
51
|
+
"voltro.actionId": p,
|
|
52
|
+
"rpc.tag": b
|
|
53
|
+
} }));
|
|
54
|
+
S = !0;
|
|
55
|
+
let g = await i(t, f);
|
|
56
|
+
k(g), o(p, {
|
|
57
|
+
status: "success",
|
|
58
|
+
output: g
|
|
59
|
+
}), C.current.errorBus.emitSuccess({
|
|
60
|
+
source: "action",
|
|
61
|
+
tag: b
|
|
62
|
+
}), d?.onSuccess?.(g, n);
|
|
63
|
+
let y = _(d?.notify?.success, g, n);
|
|
64
|
+
return y !== void 0 && u()?.success(y), g;
|
|
65
|
+
} catch (e) {
|
|
66
|
+
let r = g(e, x);
|
|
67
|
+
if (D(r), o(p, {
|
|
68
|
+
status: "error",
|
|
69
|
+
error: r
|
|
70
|
+
}), C.current.errorBus.emit({
|
|
71
|
+
source: "action",
|
|
72
|
+
tag: b,
|
|
73
|
+
error: r,
|
|
74
|
+
kind: S ? t(e, "handler") : "client",
|
|
75
|
+
outcome: S && t(e, "handler") === "transport" ? "unknown" : S ? "known" : "not-started",
|
|
76
|
+
...x === void 0 ? {} : { traceId: x }
|
|
77
|
+
}), f) {
|
|
78
|
+
d?.onError?.(r, n);
|
|
79
|
+
let e = _(d?.notify?.error, r, n);
|
|
80
|
+
e !== void 0 && u()?.error(e);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
throw r;
|
|
84
|
+
} finally {
|
|
85
|
+
T(!1);
|
|
86
|
+
}
|
|
87
|
+
}, [v, b]);
|
|
88
|
+
return f(() => ({
|
|
89
|
+
run: A,
|
|
90
|
+
pending: w,
|
|
91
|
+
error: E,
|
|
92
|
+
lastResult: O
|
|
93
|
+
}), [
|
|
94
|
+
A,
|
|
95
|
+
w,
|
|
96
|
+
E,
|
|
97
|
+
O
|
|
98
|
+
]);
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
export { b as useAction };
|
package/dist/useAgent.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useAgentStream as e } from "./useAgentStream.js";
|
|
2
|
+
import { useCallback as t, useEffect as n, useMemo as r, useRef as i, useState as a } from "react";
|
|
3
|
+
//#region src/useAgent.ts
|
|
4
|
+
var o = (o, s) => {
|
|
5
|
+
let { events: c, status: l, error: u, start: d, cancel: f } = e(o, s), [p, m] = a([]), h = i(null), g = i({
|
|
6
|
+
events: [],
|
|
7
|
+
count: 0,
|
|
8
|
+
text: ""
|
|
9
|
+
}), _ = r(() => {
|
|
10
|
+
let e = g.current, t = c.length >= e.count && (e.count === 0 || c[0] === e.events[0] && c[e.count - 1] === e.events[e.count - 1]), n = t ? e.text : "";
|
|
11
|
+
for (let r = t ? e.count : 0; r < c.length; r++) {
|
|
12
|
+
let e = c[r];
|
|
13
|
+
e._tag === "token" && (n += e.text ?? "");
|
|
14
|
+
}
|
|
15
|
+
return g.current = {
|
|
16
|
+
events: c,
|
|
17
|
+
count: c.length,
|
|
18
|
+
text: n
|
|
19
|
+
}, n;
|
|
20
|
+
}, [c]);
|
|
21
|
+
return n(() => {
|
|
22
|
+
if (l !== "done" || h.current === null) return;
|
|
23
|
+
let e = h.current;
|
|
24
|
+
h.current = null, m((t) => [
|
|
25
|
+
...t,
|
|
26
|
+
{
|
|
27
|
+
role: "user",
|
|
28
|
+
content: e
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
role: "assistant",
|
|
32
|
+
content: _
|
|
33
|
+
}
|
|
34
|
+
]);
|
|
35
|
+
}, [l, _]), {
|
|
36
|
+
tokens: _,
|
|
37
|
+
history: p,
|
|
38
|
+
status: l,
|
|
39
|
+
error: u,
|
|
40
|
+
send: t((e = {}) => {
|
|
41
|
+
g.current = {
|
|
42
|
+
events: [],
|
|
43
|
+
count: 0,
|
|
44
|
+
text: ""
|
|
45
|
+
};
|
|
46
|
+
let t = e.message;
|
|
47
|
+
h.current = typeof t == "string" ? t : "", d(e);
|
|
48
|
+
}, [d]),
|
|
49
|
+
cancel: f
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
export { o as useAgent };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useSubscription as e } from "./useSubscription.js";
|
|
2
|
+
import { useAction as t } from "./useAction.js";
|
|
3
|
+
import { useCallback as n, useMemo as r } from "react";
|
|
4
|
+
//#region src/useAgentChat.ts
|
|
5
|
+
var i = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0), a = (e) => {
|
|
6
|
+
for (let t = e.length - 1; t >= 0; --t) {
|
|
7
|
+
let n = e[t];
|
|
8
|
+
if (n.role === "user" && n.content) return n.content;
|
|
9
|
+
}
|
|
10
|
+
}, o = (o, s, c) => {
|
|
11
|
+
let { threadId: l } = c, u = `${s}.messages`, d = e(o, u, { threadId: l }), f = t(o, `${s}.send`), p = r(() => [...d.data ?? []].sort(i), [d.data]), m = n((e, t = {}) => f.run({
|
|
12
|
+
threadId: l,
|
|
13
|
+
order: d.data?.length ?? 0,
|
|
14
|
+
prompt: e,
|
|
15
|
+
...t
|
|
16
|
+
}), [
|
|
17
|
+
f,
|
|
18
|
+
l,
|
|
19
|
+
d.data
|
|
20
|
+
]), h = n(() => {
|
|
21
|
+
let e = a(p);
|
|
22
|
+
return e === void 0 ? void 0 : m(e);
|
|
23
|
+
}, [p, m]);
|
|
24
|
+
return r(() => ({
|
|
25
|
+
messages: p,
|
|
26
|
+
streaming: p.some((e) => e.streaming),
|
|
27
|
+
loading: d.data === void 0,
|
|
28
|
+
error: d.error ?? f.error,
|
|
29
|
+
send: m,
|
|
30
|
+
regenerate: h,
|
|
31
|
+
sending: f.pending
|
|
32
|
+
}), [
|
|
33
|
+
p,
|
|
34
|
+
d.data,
|
|
35
|
+
d.error,
|
|
36
|
+
f.error,
|
|
37
|
+
f.pending,
|
|
38
|
+
m,
|
|
39
|
+
h
|
|
40
|
+
]);
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { o as useAgentChat };
|
|
@@ -0,0 +1,64 @@
|
|
|
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, useEffect as i, useRef as a, useState as o } from "react";
|
|
5
|
+
import { Cause as s, Effect as c, Fiber as l, Stream as u } from "effect";
|
|
6
|
+
//#region src/useAgentStream.ts
|
|
7
|
+
var d = (d, f) => {
|
|
8
|
+
let { runtime: p, client: m } = t(d), [h, g] = o([]), [_, v] = o("idle"), [y, b] = o(void 0), x = a(null), S = a(null);
|
|
9
|
+
i(() => () => {
|
|
10
|
+
let e = S.current;
|
|
11
|
+
e?.timer !== void 0 && clearTimeout(e.timer), S.current = null;
|
|
12
|
+
let t = x.current;
|
|
13
|
+
x.current = null, t !== null && p.runFork(l.interrupt(t));
|
|
14
|
+
}, [
|
|
15
|
+
p,
|
|
16
|
+
m,
|
|
17
|
+
f
|
|
18
|
+
]);
|
|
19
|
+
let C = r(() => {
|
|
20
|
+
let e = S.current;
|
|
21
|
+
e !== null && (e.timer !== void 0 && clearTimeout(e.timer), g(e.events.slice()), S.current = null);
|
|
22
|
+
let t = x.current;
|
|
23
|
+
t && (x.current = null, p.runFork(l.interrupt(t)), v((e) => e === "streaming" ? "idle" : e));
|
|
24
|
+
}, [p]);
|
|
25
|
+
return {
|
|
26
|
+
events: h,
|
|
27
|
+
status: _,
|
|
28
|
+
error: y,
|
|
29
|
+
start: r((t = {}) => {
|
|
30
|
+
let r = x.current;
|
|
31
|
+
r && p.runFork(l.interrupt(r));
|
|
32
|
+
let i = S.current;
|
|
33
|
+
i?.timer !== void 0 && clearTimeout(i.timer);
|
|
34
|
+
let a = {
|
|
35
|
+
events: [],
|
|
36
|
+
timer: void 0
|
|
37
|
+
};
|
|
38
|
+
S.current = a, g([]), b(void 0), v("streaming");
|
|
39
|
+
let o = n(m, f)(t), d = () => {
|
|
40
|
+
a.timer !== void 0 && clearTimeout(a.timer), a.timer = void 0, S.current === a && g(a.events.slice());
|
|
41
|
+
}, h = u.runForEachArray(o, (e) => c.sync(() => {
|
|
42
|
+
if (S.current === a) {
|
|
43
|
+
for (let t of e) a.events.push(t);
|
|
44
|
+
a.timer ??= setTimeout(d, 16);
|
|
45
|
+
}
|
|
46
|
+
})).pipe(c.matchCause({
|
|
47
|
+
onSuccess: () => {
|
|
48
|
+
S.current === a && (d(), S.current = null, x.current = null, v("done"));
|
|
49
|
+
},
|
|
50
|
+
onFailure: (t) => {
|
|
51
|
+
s.hasInterruptsOnly(t) || S.current === a && (d(), S.current = null, x.current = null, b(e(t)), v("error"));
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
x.current = p.runFork(h);
|
|
55
|
+
}, [
|
|
56
|
+
p,
|
|
57
|
+
m,
|
|
58
|
+
f
|
|
59
|
+
]),
|
|
60
|
+
cancel: C
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { d as useAgentStream };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { apiConnectivity as e } from "./apiConnectivity.js";
|
|
2
|
+
import { useCallback as t, useSyncExternalStore as n } from "react";
|
|
3
|
+
//#region src/useApiOnline.ts
|
|
4
|
+
var r = () => globalThis.navigator?.onLine !== !1, i = (t) => r() && (e().online(t) ?? !0), a = (t) => {
|
|
5
|
+
let n = e().subscribe(t);
|
|
6
|
+
return typeof window > "u" ? n : (window.addEventListener("online", t), window.addEventListener("offline", t), () => {
|
|
7
|
+
n(), window.removeEventListener("online", t), window.removeEventListener("offline", t);
|
|
8
|
+
});
|
|
9
|
+
}, o = (e) => {
|
|
10
|
+
let r = t(() => i(e), [e]);
|
|
11
|
+
return n(a, r, () => !0);
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { i as readApiOnline, a as subscribeApiOnline, o as useApiOnline };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
2
|
+
import { scopeMembership as t } from "./scopeMembership.js";
|
|
3
|
+
import { usePermissions as n } from "./permissions.js";
|
|
4
|
+
import { useEffect as r, useState as i } from "react";
|
|
5
|
+
//#region src/useCapabilityManifest.ts
|
|
6
|
+
var a = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, o = (t) => {
|
|
7
|
+
let { inspectBaseUrl: n } = e(t), [o, s] = i({
|
|
8
|
+
manifest: void 0,
|
|
9
|
+
loading: !0,
|
|
10
|
+
error: void 0
|
|
11
|
+
});
|
|
12
|
+
return r(() => {
|
|
13
|
+
let e = !1;
|
|
14
|
+
return s({
|
|
15
|
+
manifest: void 0,
|
|
16
|
+
loading: !0,
|
|
17
|
+
error: void 0
|
|
18
|
+
}), fetch(a(n ?? "")).then(async (e) => {
|
|
19
|
+
if (!e.ok) throw Error(`manifest fetch failed: HTTP ${e.status}`);
|
|
20
|
+
return await e.json();
|
|
21
|
+
}).then((t) => {
|
|
22
|
+
e || s({
|
|
23
|
+
manifest: t,
|
|
24
|
+
loading: !1,
|
|
25
|
+
error: void 0
|
|
26
|
+
});
|
|
27
|
+
}).catch((t) => {
|
|
28
|
+
e || s({
|
|
29
|
+
manifest: void 0,
|
|
30
|
+
loading: !1,
|
|
31
|
+
error: t
|
|
32
|
+
});
|
|
33
|
+
}), () => {
|
|
34
|
+
e = !0;
|
|
35
|
+
};
|
|
36
|
+
}, [t, n]), o;
|
|
37
|
+
}, s = (e) => {
|
|
38
|
+
if (Object.getPrototypeOf(e) !== Array.prototype || Object.hasOwn(e, Symbol.iterator)) return !1;
|
|
39
|
+
for (let t = 0; t < e.length; t++) {
|
|
40
|
+
let n = Object.getOwnPropertyDescriptor(e, String(t));
|
|
41
|
+
if (!n || !("value" in n)) return !1;
|
|
42
|
+
let r = n.value;
|
|
43
|
+
if (Object.getPrototypeOf(r) !== Object.prototype || Object.values(Object.getOwnPropertyDescriptors(r)).some((e) => !("value" in e))) return !1;
|
|
44
|
+
if (r.kind !== "scope") continue;
|
|
45
|
+
let i = r.scope;
|
|
46
|
+
if (Object.getPrototypeOf(i) !== Array.prototype || [
|
|
47
|
+
Symbol.iterator,
|
|
48
|
+
"some",
|
|
49
|
+
"every"
|
|
50
|
+
].some((e) => Object.hasOwn(i, e))) return !1;
|
|
51
|
+
for (let e = 0; e < i.length; e++) {
|
|
52
|
+
let t = Object.getOwnPropertyDescriptor(i, String(e));
|
|
53
|
+
if (!t || !("value" in t) || typeof t.value != "string") return !1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return !0;
|
|
57
|
+
}, c = (e, t, n) => t.scope.length === 0 || (t.mode === "any" ? t.scope.some((t) => n?.has(t) ?? e.includes(t)) : t.scope.every((t) => n?.has(t) ?? e.includes(t))), l = (e, n) => {
|
|
58
|
+
if (e === void 0) return "unknown";
|
|
59
|
+
if (n.includes("admin:full") || e.length === 0) return "allowed";
|
|
60
|
+
let r = e.length >= 32 && n.length >= 32 && !Object.hasOwn(n, "includes") && !Object.hasOwn(n, Symbol.iterator) && s(e) ? t(n) : void 0, i = !1;
|
|
61
|
+
for (let t of e) if (t.kind !== "open") {
|
|
62
|
+
if (t.kind === "policy") i = !0;
|
|
63
|
+
else if (!c(n, t, r)) {
|
|
64
|
+
if (t.resourceScoped) i = !0;
|
|
65
|
+
else return "denied";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return i ? "unknown" : "allowed";
|
|
69
|
+
}, u = (e) => (e ?? []).flatMap((e) => e.kind === "scope" ? [...e.scope] : []), d = (e) => {
|
|
70
|
+
for (let t of e ?? []) if (t.kind === "open") return t.reason;
|
|
71
|
+
}, f = (e) => l(e, n().scopes), p = (e) => e === void 0 ? {} : {
|
|
72
|
+
tag: e.tag,
|
|
73
|
+
...e.guards === void 0 ? {} : { guards: e.guards }
|
|
74
|
+
}, m = (e) => {
|
|
75
|
+
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
76
|
+
for (let r of e.procedures) if (r.kind === "query") {
|
|
77
|
+
let e = Array.isArray(r.source) ? r.source : [r.source];
|
|
78
|
+
for (let n of e) typeof n == "string" && !t.has(n) && t.set(n, r);
|
|
79
|
+
} else if (r.kind === "mutation") for (let e of r.targets ?? []) {
|
|
80
|
+
let t = n.get(e.table);
|
|
81
|
+
t === void 0 && (t = /* @__PURE__ */ new Map(), n.set(e.table, t)), t.has(e.op) || t.set(e.op, r);
|
|
82
|
+
}
|
|
83
|
+
return e.tables.filter((e) => !e.framework).map((e) => {
|
|
84
|
+
let r = t.get(e.name), i = n.get(e.name), a = i?.get("insert"), o = i?.get("update"), s = i?.get("delete"), c = e.pkColumn ?? (e.columns.some((e) => e.name === "id") ? "id" : void 0);
|
|
85
|
+
return {
|
|
86
|
+
table: e.name,
|
|
87
|
+
columns: e.columns.filter((e) => e.serverOnly !== !0),
|
|
88
|
+
serverOnlyColumns: e.columns.filter((e) => e.serverOnly === !0).map((e) => e.name),
|
|
89
|
+
sensitiveColumns: e.columns.filter((e) => e.sensitive !== void 0).map((e) => e.name),
|
|
90
|
+
reactive: e.reactive,
|
|
91
|
+
...c === void 0 ? {} : { pkColumn: c },
|
|
92
|
+
editable: (e.editable ?? !0) && c !== void 0,
|
|
93
|
+
list: p(r),
|
|
94
|
+
create: p(a),
|
|
95
|
+
update: p(o),
|
|
96
|
+
delete: p(s)
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
export { l as decideAccess, m as deriveEntityAdmins, a as manifestUrl, d as openAccessReason, u as requiredScopes, f as useAccessDecision, o as useCapabilityManifest };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useFrameworkApi as e } from "./runtimeContext.js";
|
|
2
|
+
import { awaitResolvedApi as t } from "./awaitResolvedApi.js";
|
|
3
|
+
import { ConnectionSetupController as n } from "./connectionSetupController.js";
|
|
4
|
+
import { useCallback as r, useEffect as i, useMemo as a, useRef as o, useSyncExternalStore as s } from "react";
|
|
5
|
+
//#region src/useConnectionSetup.ts
|
|
6
|
+
var c = (c, l) => {
|
|
7
|
+
let u = e(c), d = o(u);
|
|
8
|
+
d.current = u;
|
|
9
|
+
let f = a(() => new n(c, l, () => d.current), [c, l]), p = r((e) => f.activate(e, () => t(d, c, l)), [
|
|
10
|
+
f,
|
|
11
|
+
c,
|
|
12
|
+
l
|
|
13
|
+
]), m = s(f.subscribe, f.getSnapshot, f.getSnapshot);
|
|
14
|
+
return i(() => f.watch(d.current), [
|
|
15
|
+
f,
|
|
16
|
+
u.runtime,
|
|
17
|
+
u.client,
|
|
18
|
+
u.recovery
|
|
19
|
+
]), i(() => () => f.clear(), [f]), {
|
|
20
|
+
...m,
|
|
21
|
+
handle: f.handle,
|
|
22
|
+
activate: p,
|
|
23
|
+
clear: f.clear,
|
|
24
|
+
ready: m.status === "ready"
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { c as useConnectionSetup };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { recordClientDiagnostic as e } from "./clientDiagnostics.js";
|
|
2
|
+
import { INITIAL_RECOVERY_SNAPSHOT as t, recoveryCoordinatorFor as n } from "./recoveryCoordinator.js";
|
|
3
|
+
import { useFrameworkApi as r } from "./runtimeContext.js";
|
|
4
|
+
import { useCallback as i, useEffect as a, useSyncExternalStore as o } from "react";
|
|
5
|
+
//#region src/useConnectionStatus.ts
|
|
6
|
+
var s = () => typeof navigator > "u" || navigator.onLine, c = () => !0, l = (e) => typeof window > "u" ? () => {} : (window.addEventListener("online", e), window.addEventListener("offline", e), () => {
|
|
7
|
+
window.removeEventListener("online", e), window.removeEventListener("offline", e);
|
|
8
|
+
}), u = (u) => {
|
|
9
|
+
let d = r(u), f = d.recovery ?? n(d.errorBus, u), p = o(f.subscribe, f.getSnapshot, f.getServerSnapshot ?? (() => t)), m = o(l, s, c), h = i(() => f.reportExternalSuccess(), [f]), g = m ? p.status : "offline";
|
|
10
|
+
return a(() => {
|
|
11
|
+
e(u, "connection.status", {
|
|
12
|
+
status: g,
|
|
13
|
+
rawTransport: p.rawTransport,
|
|
14
|
+
online: m,
|
|
15
|
+
failureCount: p.failureCount,
|
|
16
|
+
failedSubscriptions: p.failedSubscriptions.length,
|
|
17
|
+
pendingMutationReplays: p.pendingMutationReplays,
|
|
18
|
+
mutationReplay: p.mutationReplay
|
|
19
|
+
});
|
|
20
|
+
}, [
|
|
21
|
+
u,
|
|
22
|
+
g,
|
|
23
|
+
m,
|
|
24
|
+
p
|
|
25
|
+
]), {
|
|
26
|
+
status: g,
|
|
27
|
+
rawTransport: p.rawTransport,
|
|
28
|
+
online: m,
|
|
29
|
+
failureCount: p.failureCount,
|
|
30
|
+
lastFailureAt: p.lastFailureAt,
|
|
31
|
+
failedSubscriptions: p.failedSubscriptions,
|
|
32
|
+
pendingMutationReplays: p.pendingMutationReplays,
|
|
33
|
+
mutationReplay: p.mutationReplay,
|
|
34
|
+
reportSuccess: h
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { u as useConnectionStatus };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { useSubscription as e } from "./useSubscription.js";
|
|
2
|
+
import { useMutation as t } from "./useMutation.js";
|
|
3
|
+
import { useAction as n } from "./useAction.js";
|
|
4
|
+
import { useCallback as r, useMemo as i } from "react";
|
|
5
|
+
//#region src/useConnections.ts
|
|
6
|
+
var a = "__voltro.connections.list", o = "__voltro.connections.start", s = "__voltro.connections.submitToken", c = "__voltro.connections.disconnect", l = {
|
|
7
|
+
connectionId: "",
|
|
8
|
+
kind: "oauth2",
|
|
9
|
+
label: "",
|
|
10
|
+
status: "disconnected",
|
|
11
|
+
accountId: null,
|
|
12
|
+
accountLabel: null,
|
|
13
|
+
scopes: [],
|
|
14
|
+
expiresAt: null,
|
|
15
|
+
lastError: null,
|
|
16
|
+
connectedAt: null
|
|
17
|
+
}, u = (e, t) => {
|
|
18
|
+
(t === "redirect" || globalThis.open(e, "voltro-connect", "width=620,height=760,menubar=no,toolbar=no") === null) && globalThis.location.assign(e);
|
|
19
|
+
}, d = (e) => {
|
|
20
|
+
if (e.length < 32 || Object.getPrototypeOf(e) !== Array.prototype || Object.hasOwn(e, "find")) return;
|
|
21
|
+
let t = /* @__PURE__ */ new Map();
|
|
22
|
+
for (let n = 0; n < e.length; n += 1) {
|
|
23
|
+
let r = Object.getOwnPropertyDescriptor(e, String(n)), i = r !== void 0 && "value" in r ? r.value : void 0;
|
|
24
|
+
if (typeof i != "object" || !i) return;
|
|
25
|
+
let a = Object.getOwnPropertyDescriptor(i, "connectionId");
|
|
26
|
+
if (a === void 0 || !("value" in a) || typeof a.value != "string") return;
|
|
27
|
+
t.has(a.value) || t.set(a.value, i);
|
|
28
|
+
}
|
|
29
|
+
return t;
|
|
30
|
+
}, f = (l) => {
|
|
31
|
+
let { data: f } = e(l, a, {}), p = n(l, o), m = t(l, s), h = t(l, c), g = f ?? [], _ = i(() => ({
|
|
32
|
+
calls: 0,
|
|
33
|
+
byId: void 0
|
|
34
|
+
}), [g]), v = p.pending || m.pending || h.pending, y = r((e) => ({
|
|
35
|
+
...e,
|
|
36
|
+
connected: e.status === "connected",
|
|
37
|
+
needsAttention: e.status === "expired" || e.status === "revoked" || e.status === "error",
|
|
38
|
+
pending: v,
|
|
39
|
+
connect: async (t) => {
|
|
40
|
+
if (e.kind !== "oauth2") throw Error(`connection "${e.connectionId}" is a personal-access-token connection — call submitToken(token), not connect().`);
|
|
41
|
+
let n = t?.redirectTo ?? `${globalThis.location.pathname}${globalThis.location.search}`;
|
|
42
|
+
u((await p.run({
|
|
43
|
+
connectionId: e.connectionId,
|
|
44
|
+
redirectTo: n
|
|
45
|
+
})).authorizeUrl, t?.mode);
|
|
46
|
+
},
|
|
47
|
+
submitToken: async (t) => {
|
|
48
|
+
if (e.kind !== "pat") throw Error(`connection "${e.connectionId}" uses OAuth — call connect(), not submitToken().`);
|
|
49
|
+
await m.mutate({
|
|
50
|
+
connectionId: e.connectionId,
|
|
51
|
+
token: t
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
disconnect: async () => {
|
|
55
|
+
await h.mutate({ connectionId: e.connectionId });
|
|
56
|
+
}
|
|
57
|
+
}), [
|
|
58
|
+
v,
|
|
59
|
+
p,
|
|
60
|
+
m,
|
|
61
|
+
h
|
|
62
|
+
]), b = r((e) => {
|
|
63
|
+
_.calls === 4 && (_.byId = d(g)), _.calls <= 4 && (_.calls += 1);
|
|
64
|
+
let t = _.byId === void 0 ? g.find((t) => t.connectionId === e) : _.byId.get(e);
|
|
65
|
+
return t === void 0 ? void 0 : y(t);
|
|
66
|
+
}, [
|
|
67
|
+
_,
|
|
68
|
+
g,
|
|
69
|
+
y
|
|
70
|
+
]);
|
|
71
|
+
return {
|
|
72
|
+
connections: g,
|
|
73
|
+
loading: f === void 0,
|
|
74
|
+
get: b,
|
|
75
|
+
pending: v
|
|
76
|
+
};
|
|
77
|
+
}, p = (e, t) => {
|
|
78
|
+
let n = f(e), r = n.get(t);
|
|
79
|
+
return i(() => r === void 0 ? {
|
|
80
|
+
...l,
|
|
81
|
+
connectionId: t,
|
|
82
|
+
label: t,
|
|
83
|
+
connected: !1,
|
|
84
|
+
needsAttention: !1,
|
|
85
|
+
pending: n.pending,
|
|
86
|
+
loading: n.loading,
|
|
87
|
+
connect: async () => {
|
|
88
|
+
throw Error(`connection "${t}" is not declared by this app.`);
|
|
89
|
+
},
|
|
90
|
+
submitToken: async () => {
|
|
91
|
+
throw Error(`connection "${t}" is not declared by this app.`);
|
|
92
|
+
},
|
|
93
|
+
disconnect: async () => {
|
|
94
|
+
throw Error(`connection "${t}" is not declared by this app.`);
|
|
95
|
+
}
|
|
96
|
+
} : {
|
|
97
|
+
...r,
|
|
98
|
+
loading: n.loading
|
|
99
|
+
}, [
|
|
100
|
+
r,
|
|
101
|
+
t,
|
|
102
|
+
n.loading,
|
|
103
|
+
n.pending
|
|
104
|
+
]);
|
|
105
|
+
};
|
|
106
|
+
//#endregion
|
|
107
|
+
export { a as CONNECTIONS_LIST_TAG, c as CONNECTION_DISCONNECT_TAG, o as CONNECTION_START_TAG, s as CONNECTION_SUBMIT_TOKEN_TAG, p as useConnection, f as useConnections };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useAction as e } from "./useAction.js";
|
|
2
|
+
import { useCallback as t, useMemo as n, useState as r } from "react";
|
|
3
|
+
//#region src/useDataCopilot.ts
|
|
4
|
+
var i = (i, a) => {
|
|
5
|
+
let o = e(i, a), [s, c] = r(void 0), l = t(async (e) => {
|
|
6
|
+
let t = await o.run({ question: e });
|
|
7
|
+
return c(t), t;
|
|
8
|
+
}, [o]), u = t(() => c(void 0), []);
|
|
9
|
+
return n(() => ({
|
|
10
|
+
ask: l,
|
|
11
|
+
answer: s,
|
|
12
|
+
pending: o.pending,
|
|
13
|
+
error: o.error,
|
|
14
|
+
reset: u
|
|
15
|
+
}), [
|
|
16
|
+
l,
|
|
17
|
+
s,
|
|
18
|
+
o.pending,
|
|
19
|
+
o.error,
|
|
20
|
+
u
|
|
21
|
+
]);
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { i as useDataCopilot };
|