@voltro/client 0.29.0 → 0.30.1
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 +448 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +412 -396
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,41 +1,42 @@
|
|
|
1
1
|
import { createContext as e, createElement as t, useCallback as n, useContext as r, useDebugValue as i, useEffect as a, useMemo as o, useRef as s, useState as c, useSyncExternalStore as l } from "react";
|
|
2
|
-
import { Cause as u,
|
|
3
|
-
import { applyRowPatch as
|
|
4
|
-
import
|
|
5
|
-
import * as
|
|
6
|
-
import { RpcClient as
|
|
7
|
-
import {
|
|
2
|
+
import { Cause as u, Context as d, Duration as f, Effect as p, Exit as m, Fiber as h, JSONSchema as g, Layer as _, ManagedRuntime as v, Schedule as y, Schema as b, Stream as x } from "effect";
|
|
3
|
+
import { applyRowPatch as S } from "@voltro/protocol";
|
|
4
|
+
import * as C from "@effect/platform/Socket";
|
|
5
|
+
import * as w from "@effect/platform/Headers";
|
|
6
|
+
import { RpcClient as T, RpcSerialization as ee } from "@effect/rpc";
|
|
7
|
+
import { jsx as te } from "react/jsx-runtime";
|
|
8
|
+
import { ArrayFormatter as E } from "effect/ParseResult";
|
|
8
9
|
//#region src/traceBus.ts
|
|
9
|
-
var
|
|
10
|
-
for (let t of
|
|
10
|
+
var ne = /* @__PURE__ */ new Set(), D = (e) => {
|
|
11
|
+
for (let t of ne) try {
|
|
11
12
|
t(e);
|
|
12
13
|
} catch {}
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
}),
|
|
14
|
+
}, re = (e) => (ne.add(e), () => {
|
|
15
|
+
ne.delete(e);
|
|
16
|
+
}), O = (e) => {
|
|
16
17
|
let t = (e) => e == null ? "null" : typeof e == "string" ? JSON.stringify(e) : typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) ? `[${e.map(t).join(",")}]` : typeof e == "object" ? `{${Object.keys(e).sort().map((n) => `${JSON.stringify(n)}:${t(e[n])}`).join(",")}}` : String(e);
|
|
17
18
|
return t(e);
|
|
18
|
-
},
|
|
19
|
+
}, ie = Object.freeze({
|
|
19
20
|
data: void 0,
|
|
20
21
|
revision: -1,
|
|
21
22
|
emittedAt: void 0,
|
|
22
23
|
error: void 0,
|
|
23
24
|
pendingPatches: 0
|
|
24
|
-
}),
|
|
25
|
+
}), ae = 5e3, oe = 0, se = () => `patch_${++oe}`, k = (e, t) => {
|
|
25
26
|
let n = e;
|
|
26
27
|
for (let e of t.split(".")) {
|
|
27
28
|
if (typeof n != "object" || !n) return;
|
|
28
29
|
n = n[e];
|
|
29
30
|
}
|
|
30
31
|
return n;
|
|
31
|
-
},
|
|
32
|
+
}, ce = (e, t, n) => {
|
|
32
33
|
let r = t.split("."), i = (e) => typeof e == "object" && e && !Array.isArray(e) ? { ...e } : {}, a = i(e), o = a;
|
|
33
34
|
for (let e = 0; e < r.length - 1; e += 1) o[r[e]] = i(o[r[e]]), o = o[r[e]];
|
|
34
35
|
return o[r[r.length - 1]] = n, a;
|
|
35
|
-
},
|
|
36
|
+
}, le = (e, t) => {
|
|
36
37
|
let n = e.by ?? "id", r = e.identify ? e.identify(t) : typeof t[n] == "string" ? t[n] : typeof t.id == "string" ? t.id : void 0, i = r === void 0 ? [] : Array.isArray(r) ? r : [r];
|
|
37
38
|
return i.length === 0 ? null : new Set(i);
|
|
38
|
-
},
|
|
39
|
+
}, ue = (e, t, n) => {
|
|
39
40
|
let r = e.path, i = e.by ?? "id";
|
|
40
41
|
if (e.op === "insert") {
|
|
41
42
|
let a = e.shapeItem ?? e.shape, o = a ? {
|
|
@@ -48,11 +49,11 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
48
49
|
optimistic: !0
|
|
49
50
|
}, s = e.order ?? "append";
|
|
50
51
|
return (e) => {
|
|
51
|
-
let t = Array.isArray(
|
|
52
|
-
return
|
|
52
|
+
let t = Array.isArray(k(e, r)) ? k(e, r) : [];
|
|
53
|
+
return ce(e ?? {}, r, s === "append" ? [...t, o] : [o, ...t]);
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
|
-
let a =
|
|
56
|
+
let a = le(e, t);
|
|
56
57
|
if (a === null) return null;
|
|
57
58
|
if (e.op === "update") {
|
|
58
59
|
let n = e.shapeItem ?? e.shape, o = n ? (e) => ({
|
|
@@ -66,16 +67,16 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
66
67
|
optimistic: !0
|
|
67
68
|
});
|
|
68
69
|
return (e) => {
|
|
69
|
-
let t = Array.isArray(
|
|
70
|
-
return
|
|
70
|
+
let t = Array.isArray(k(e, r)) ? k(e, r) : [];
|
|
71
|
+
return ce(e, r, t.map((e) => a.has(e[i]) ? o(e) : e));
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
74
|
return (e) => {
|
|
74
|
-
let t = Array.isArray(
|
|
75
|
-
return
|
|
75
|
+
let t = Array.isArray(k(e, r)) ? k(e, r) : [];
|
|
76
|
+
return ce(e, r, t.filter((e) => !a.has(e[i])));
|
|
76
77
|
};
|
|
77
|
-
},
|
|
78
|
-
if (e.path !== void 0) return
|
|
78
|
+
}, de = (e, t, n) => {
|
|
79
|
+
if (e.path !== void 0) return ue(e, t, n);
|
|
79
80
|
switch (e.op) {
|
|
80
81
|
case "insert": {
|
|
81
82
|
let r = e.shape ? {
|
|
@@ -93,7 +94,7 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
93
94
|
};
|
|
94
95
|
}
|
|
95
96
|
case "update": {
|
|
96
|
-
let n =
|
|
97
|
+
let n = le(e, t);
|
|
97
98
|
if (n === null) return null;
|
|
98
99
|
let r = e.shape, i = r ? (e) => ({
|
|
99
100
|
...r(t, e),
|
|
@@ -110,30 +111,30 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
case "delete": {
|
|
113
|
-
let n =
|
|
114
|
+
let n = le(e, t);
|
|
114
115
|
return n === null ? null : (e) => (Array.isArray(e) ? e : []).filter((e) => !n.has(e.id));
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
|
-
},
|
|
118
|
+
}, fe = 5e3, A = class {
|
|
118
119
|
entries = /* @__PURE__ */ new Map();
|
|
119
120
|
inactiveTtlMs;
|
|
120
121
|
onChangeHook;
|
|
121
122
|
errorBus;
|
|
122
123
|
constructor(e = {}) {
|
|
123
|
-
this.inactiveTtlMs = e.inactiveTtlMs ??
|
|
124
|
+
this.inactiveTtlMs = e.inactiveTtlMs ?? fe, this.onChangeHook = e.onChange, this.errorBus = e.errorBus;
|
|
124
125
|
}
|
|
125
126
|
subscribe(e, t, n, r, i = {}) {
|
|
126
|
-
let a =
|
|
127
|
+
let a = O(e), o = typeof e[0] == "string" ? e[0] : void 0, s = this.entries.get(a);
|
|
127
128
|
return s && s.evictionTimer !== null && (clearTimeout(s.evictionTimer), s.evictionTimer = null), s ? (s.fiber === null && (s.fetch = t, this.startFiber(s, t, n)), s.source === void 0 && i.source !== void 0 && (s.source = i.source)) : s = this.create(a, o, t, n, i.source), s.subscribers.add(r), {
|
|
128
129
|
getSnapshot: () => this.getSnapshot(a),
|
|
129
130
|
unsubscribe: () => this.unsubscribe(a, r)
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
133
|
update(e, t, n) {
|
|
133
|
-
let r =
|
|
134
|
+
let r = O(e), i = typeof e[0] == "string" ? e[0] : void 0, a = this.entries.get(r);
|
|
134
135
|
a ||= this.createStub(r, i);
|
|
135
136
|
let o = {
|
|
136
|
-
id:
|
|
137
|
+
id: se(),
|
|
137
138
|
mutationId: n,
|
|
138
139
|
reducer: t
|
|
139
140
|
};
|
|
@@ -147,7 +148,7 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
147
148
|
for (let i of this.entries.values()) {
|
|
148
149
|
if (i.tag !== e) continue;
|
|
149
150
|
let a = {
|
|
150
|
-
id: `forTag-${++
|
|
151
|
+
id: `forTag-${++oe}`,
|
|
151
152
|
mutationId: n,
|
|
152
153
|
reducer: t
|
|
153
154
|
};
|
|
@@ -164,10 +165,10 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
164
165
|
confirmByMutation(e) {
|
|
165
166
|
let t = !1;
|
|
166
167
|
for (let n of this.entries.values()) for (let r of n.state.patches) r.mutationId === e && r.confirmed !== !0 && (r.confirmed = !0, t = !0);
|
|
167
|
-
t && setTimeout(() => this.revertByMutation(e),
|
|
168
|
+
t && setTimeout(() => this.revertByMutation(e), ae);
|
|
168
169
|
}
|
|
169
170
|
autoApply(e, t, n) {
|
|
170
|
-
let r = `optimistic-${n}-${++
|
|
171
|
+
let r = `optimistic-${n}-${++oe}`;
|
|
171
172
|
for (let i of e) for (let e of this.entries.values()) {
|
|
172
173
|
if (!(Array.isArray(e.source) ? e.source.includes(i.table) : e.source === i.table)) continue;
|
|
173
174
|
if (i.match !== void 0) {
|
|
@@ -180,7 +181,7 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
180
181
|
if (!n) continue;
|
|
181
182
|
}
|
|
182
183
|
if (e.computed && i.op === "insert" && i.path === void 0) continue;
|
|
183
|
-
let a =
|
|
184
|
+
let a = de(i, t, r);
|
|
184
185
|
if (a === null) continue;
|
|
185
186
|
let o = {
|
|
186
187
|
id: `${r}-${e.key}`,
|
|
@@ -197,10 +198,10 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
197
198
|
n.state.patches = n.state.patches.filter((e) => e.id !== t), n.state.patches.length !== r && this.invalidate(n);
|
|
198
199
|
}
|
|
199
200
|
peek(e) {
|
|
200
|
-
return this.getSnapshot(
|
|
201
|
+
return this.getSnapshot(O(e));
|
|
201
202
|
}
|
|
202
203
|
getEntry(e) {
|
|
203
|
-
return this.entries.get(
|
|
204
|
+
return this.entries.get(O(e));
|
|
204
205
|
}
|
|
205
206
|
size() {
|
|
206
207
|
return this.entries.size;
|
|
@@ -219,13 +220,13 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
219
220
|
return e;
|
|
220
221
|
}
|
|
221
222
|
destroy(e) {
|
|
222
|
-
for (let t of this.entries.values()) t.evictionTimer !== null && clearTimeout(t.evictionTimer), t.fiber && e.runFork(
|
|
223
|
+
for (let t of this.entries.values()) t.evictionTimer !== null && clearTimeout(t.evictionTimer), t.fiber && e.runFork(h.interrupt(t.fiber));
|
|
223
224
|
this.entries.clear();
|
|
224
225
|
}
|
|
225
226
|
refreshAll(e) {
|
|
226
227
|
for (let t of this.entries.values()) {
|
|
227
228
|
if (!t.fetch) continue;
|
|
228
|
-
t.fiber && e.runFork(
|
|
229
|
+
t.fiber && e.runFork(h.interrupt(t.fiber)), t.fiber = null;
|
|
229
230
|
let n = t.state.patches;
|
|
230
231
|
t.state = this.freshState(), t.state.patches = n, this.startFiber(t, t.fetch, e);
|
|
231
232
|
}
|
|
@@ -269,22 +270,22 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
269
270
|
};
|
|
270
271
|
}
|
|
271
272
|
startFiber(e, t, n) {
|
|
272
|
-
let r = e.tag ?? e.key, i = t(), a =
|
|
273
|
+
let r = e.tag ?? e.key, i = t(), a = x.unwrapScoped(p.currentSpan.pipe(p.catchAll(() => p.succeed(void 0)), p.map((t) => (t && (e.traceId = t.traceId, D({
|
|
273
274
|
traceId: t.traceId,
|
|
274
275
|
spanId: t.spanId,
|
|
275
276
|
source: "subscription",
|
|
276
277
|
tag: r
|
|
277
|
-
})), i)))).pipe(
|
|
278
|
-
e.fiber = n.runFork(a.pipe(
|
|
278
|
+
})), i)))).pipe(x.withSpan(`client.subscription.${r}`, { attributes: { "rpc.tag": r } }));
|
|
279
|
+
e.fiber = n.runFork(a.pipe(x.runForEach((t) => p.sync(() => {
|
|
279
280
|
if (t._tag === "snapshot") e.state.base = t.data, e.state.baseRevision = t.revision, e.state.baseEmittedAt = void 0, e.state.baseError = void 0, t.computed === !0 && (e.computed = !0);
|
|
280
281
|
else if (t._tag === "error") e.state.baseError = u.fail(t.error), typeof t.revision == "number" && (e.state.baseRevision = t.revision);
|
|
281
282
|
else {
|
|
282
283
|
let n = e.state.base;
|
|
283
|
-
Array.isArray(n) && (e.state.base =
|
|
284
|
+
Array.isArray(n) && (e.state.base = S(n, t.patch)), e.state.baseRevision = t.revision, e.state.baseEmittedAt = t.emittedAt, e.state.baseError = void 0;
|
|
284
285
|
}
|
|
285
286
|
e.state.patches.some((e) => e.confirmed === !0) && (e.state.patches = e.state.patches.filter((e) => e.confirmed !== !0)), this.invalidate(e);
|
|
286
287
|
})))), e.fiber.addObserver((t) => {
|
|
287
|
-
if (
|
|
288
|
+
if (m.isFailure(t) && !m.isInterrupted(t) && (e.state.baseRevision === -1 && (e.state.baseError = t.cause, this.invalidate(e)), this.errorBus)) {
|
|
288
289
|
let n = u.squash(t.cause);
|
|
289
290
|
this.errorBus.emit({
|
|
290
291
|
source: "subscription",
|
|
@@ -302,7 +303,7 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
302
303
|
}
|
|
303
304
|
getSnapshot(e) {
|
|
304
305
|
let t = this.entries.get(e);
|
|
305
|
-
if (!t) return
|
|
306
|
+
if (!t) return ie;
|
|
306
307
|
if (t.state.cachedSnapshot !== null) return t.state.cachedSnapshot;
|
|
307
308
|
let n = t.state.base;
|
|
308
309
|
if (n !== void 0 && t.state.patches.length > 0) for (let e of t.state.patches) n = e.reducer(n);
|
|
@@ -319,17 +320,17 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
319
320
|
let n = this.entries.get(e);
|
|
320
321
|
n && (n.subscribers.delete(t), !(n.subscribers.size > 0) && (n.evictionTimer !== null && clearTimeout(n.evictionTimer), n.evictionTimer = setTimeout(() => {
|
|
321
322
|
let t = this.entries.get(e);
|
|
322
|
-
t && t.subscribers.size === 0 && (t.fiber &&
|
|
323
|
+
t && t.subscribers.size === 0 && (t.fiber && p.runFork(h.interrupt(t.fiber)), this.entries.delete(e));
|
|
323
324
|
}, this.inactiveTtlMs)));
|
|
324
325
|
}
|
|
325
|
-
},
|
|
326
|
+
}, pe = class extends A {
|
|
326
327
|
subscribe(e, t, n, r, i = {}) {
|
|
327
328
|
return {
|
|
328
329
|
getSnapshot: () => this.peek(e),
|
|
329
330
|
unsubscribe: () => {}
|
|
330
331
|
};
|
|
331
332
|
}
|
|
332
|
-
},
|
|
333
|
+
}, me = class {
|
|
333
334
|
#e = /* @__PURE__ */ new Set();
|
|
334
335
|
on(e) {
|
|
335
336
|
return this.#e.add(e), () => {
|
|
@@ -341,30 +342,45 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
341
342
|
t(e);
|
|
342
343
|
} catch {}
|
|
343
344
|
}
|
|
344
|
-
},
|
|
345
|
+
}, he = e(null), ge = () => {
|
|
345
346
|
throw Error("Voltro: rpc / cache calls are not invokable on a not-yet-resolved api — either during SSR, or in the client boot window before the api client resolves");
|
|
346
|
-
},
|
|
347
|
-
get: (e, t) =>
|
|
347
|
+
}, _e = new Proxy(() => ge(), {
|
|
348
|
+
get: (e, t) => _e,
|
|
348
349
|
has: () => !0,
|
|
349
|
-
apply: () =>
|
|
350
|
-
}),
|
|
350
|
+
apply: () => ge()
|
|
351
|
+
}), ve = {
|
|
351
352
|
runtime: { runPromise: () => Promise.reject(/* @__PURE__ */ Error("Voltro: mutations are not invokable during SSR")) },
|
|
352
|
-
cache: new
|
|
353
|
-
client:
|
|
353
|
+
cache: new pe(),
|
|
354
|
+
client: _e,
|
|
354
355
|
descriptors: {},
|
|
355
356
|
inspectBaseUrl: "",
|
|
356
|
-
errorBus: new
|
|
357
|
-
},
|
|
358
|
-
get: () =>
|
|
357
|
+
errorBus: new me()
|
|
358
|
+
}, ye = {
|
|
359
|
+
get: () => ve,
|
|
359
360
|
names: []
|
|
360
|
-
}, j = !1, M = !1, N = null,
|
|
361
|
+
}, j = !1, M = !1, N = null, be = () => {
|
|
361
362
|
j = !1, M = !1, N !== null && (clearTimeout(N), N = null);
|
|
362
|
-
},
|
|
363
|
-
let e = r(
|
|
363
|
+
}, xe = () => {
|
|
364
|
+
let e = r(he);
|
|
364
365
|
return e ? (M || (M = !0, N !== null && (clearTimeout(N), N = null)), e) : (typeof window < "u" && !j && !M && N === null && process.env.NODE_ENV !== "production" && (N = setTimeout(() => {
|
|
365
366
|
N = null, !(j || M) && (j = !0, console.warn("useFrameworkRuntimes: no <FrameworkRuntimesProvider> in the tree — returning a loading baseline (subscriptions read `undefined`, mutations are no-ops). If this is not an intentional lazy/conditional mount, mount your app via @voltro/web mount() or wrap the subtree in <VoltroRuntimeProvider>."));
|
|
366
|
-
}, 0)),
|
|
367
|
-
}, P = (e) =>
|
|
367
|
+
}, 0)), ye);
|
|
368
|
+
}, P = (e) => xe().get(e), F = (e) => typeof e.runtime?.runFork != "function", Se = async (e) => {
|
|
369
|
+
let { name: t, wsUrl: n, group: r, headers: i, webSocketConstructor: a } = e;
|
|
370
|
+
class o extends d.Tag(`@voltro/client/AppClient/${t}`)() {}
|
|
371
|
+
let s = _.succeed(C.WebSocketConstructor, (e, t) => a(e, t)), c = T.layerProtocolSocket().pipe(_.provide(ee.layerJson), _.provide(C.layerWebSocket(n)), _.provide(s)), l = typeof i == "function" ? await i() : i, u = _.scoped(o, T.make(r)).pipe(_.provide(c)), f = l ? _.locallyScoped(T.currentHeaders, w.fromInput(l)) : _.empty, p = v.make(_.merge(u, f));
|
|
372
|
+
try {
|
|
373
|
+
let e = await p.runPromise(o), t = new me();
|
|
374
|
+
return {
|
|
375
|
+
runtime: p,
|
|
376
|
+
client: e,
|
|
377
|
+
cache: new A({ errorBus: t }),
|
|
378
|
+
errorBus: t
|
|
379
|
+
};
|
|
380
|
+
} catch (e) {
|
|
381
|
+
throw p.dispose(), e;
|
|
382
|
+
}
|
|
383
|
+
}, Ce = ({ apis: e, children: t }) => {
|
|
368
384
|
let n = o(() => ({
|
|
369
385
|
get: (t) => {
|
|
370
386
|
let n = e.get(t);
|
|
@@ -376,7 +392,7 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
376
392
|
},
|
|
377
393
|
names: Array.from(e.keys())
|
|
378
394
|
}), [e]);
|
|
379
|
-
return /* @__PURE__ */
|
|
395
|
+
return /* @__PURE__ */ te(he.Provider, {
|
|
380
396
|
value: n,
|
|
381
397
|
children: t
|
|
382
398
|
});
|
|
@@ -387,10 +403,10 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
387
403
|
if (n.length !== r.length) return !1;
|
|
388
404
|
for (let r of n) if (!Object.prototype.hasOwnProperty.call(t, r) || !Object.is(e[r], t[r])) return !1;
|
|
389
405
|
return !0;
|
|
390
|
-
},
|
|
391
|
-
|
|
392
|
-
},
|
|
393
|
-
let r =
|
|
406
|
+
}, we = 50, Te = /* @__PURE__ */ new Set(), Ee = (e, t) => {
|
|
407
|
+
Te.has(e) || (Te.add(e), console.warn(t));
|
|
408
|
+
}, De = "\0global", Oe = null, ke = (e, t, n) => {
|
|
409
|
+
let r = Oe?.() ?? null;
|
|
394
410
|
if (r === null) return n;
|
|
395
411
|
let i = n;
|
|
396
412
|
for (let n of r.seeds) n.store !== e || n.key !== t || (i = {
|
|
@@ -398,9 +414,9 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
398
414
|
...n.value
|
|
399
415
|
});
|
|
400
416
|
return i;
|
|
401
|
-
},
|
|
417
|
+
}, Ae = (e, t) => {
|
|
402
418
|
let n = e(), r = /* @__PURE__ */ new Set(), i = 0, a = 0, o, s, c = () => {
|
|
403
|
-
if (i >=
|
|
419
|
+
if (i >= we) throw i = 0, Error(`defineStore: notification depth exceeded ${we} — a subscriber writes a NEW value every time it is notified, so the store can never settle. Look for a listener calling set() with something derived from the current state without converging.`);
|
|
404
420
|
i += 1;
|
|
405
421
|
try {
|
|
406
422
|
for (let e of [...r]) e();
|
|
@@ -442,11 +458,11 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
442
458
|
r.delete(e);
|
|
443
459
|
})
|
|
444
460
|
};
|
|
445
|
-
},
|
|
446
|
-
|
|
447
|
-
}),
|
|
448
|
-
L.length = 0,
|
|
449
|
-
},
|
|
461
|
+
}, je = 200, L = [], R = /* @__PURE__ */ new Set(), Me = [], Ne = () => Me, Pe = (e) => (R.add(e), () => {
|
|
462
|
+
R.delete(e);
|
|
463
|
+
}), Fe = () => {
|
|
464
|
+
L.length = 0, Me = [];
|
|
465
|
+
}, Ie = (e, t) => {
|
|
450
466
|
let n = L[e];
|
|
451
467
|
if (n === void 0) return !1;
|
|
452
468
|
let r = V.get(n.store);
|
|
@@ -459,30 +475,30 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
459
475
|
B = !1;
|
|
460
476
|
}
|
|
461
477
|
return !0;
|
|
462
|
-
}, z = !1, B = !1,
|
|
463
|
-
L.push(e), L.length >
|
|
464
|
-
for (let e of [...
|
|
465
|
-
}, V = /* @__PURE__ */ new Map(),
|
|
466
|
-
|
|
467
|
-
})),
|
|
468
|
-
function
|
|
478
|
+
}, z = !1, B = !1, Le = (e) => {
|
|
479
|
+
L.push(e), L.length > je && L.shift(), Me = [...L];
|
|
480
|
+
for (let e of [...R]) e();
|
|
481
|
+
}, V = /* @__PURE__ */ new Map(), Re = /* @__PURE__ */ new Map(), ze = 0, Be = !1, Ve = /* @__PURE__ */ new Map(), He = () => (Be || (Be = !0, queueMicrotask(() => {
|
|
482
|
+
ze += 1, Be = !1;
|
|
483
|
+
})), ze), Ue = We(((/* @__PURE__ */ Error()).stack ?? "").split("\n")[1] ?? "") ?? "";
|
|
484
|
+
function We(e) {
|
|
469
485
|
let t = e.trim().replace(/^at\s+/, ""), n = /\(([^()]+)\)\s*$/.exec(t)?.[1] ?? t;
|
|
470
486
|
return n.length > 0 ? n : void 0;
|
|
471
487
|
}
|
|
472
|
-
var
|
|
488
|
+
var Ge = () => {
|
|
473
489
|
let e = (/* @__PURE__ */ Error()).stack;
|
|
474
490
|
if (typeof e != "string") return "<unknown>";
|
|
475
491
|
for (let t of e.split("\n").slice(1)) {
|
|
476
|
-
let e =
|
|
492
|
+
let e = We(t);
|
|
477
493
|
if (e === void 0) continue;
|
|
478
494
|
let n = e.replace(/:\d+:\d+$/, "");
|
|
479
|
-
if (!(
|
|
495
|
+
if (!(Ue !== "" && n === Ue.replace(/:\d+:\d+$/, ""))) return n;
|
|
480
496
|
}
|
|
481
497
|
return "<unknown>";
|
|
482
|
-
},
|
|
483
|
-
let a =
|
|
498
|
+
}, Ke = () => [...V.values()], qe = (e, t, r) => {
|
|
499
|
+
let a = Ge(), o = He(), c = V.get(e);
|
|
484
500
|
if (c !== void 0) {
|
|
485
|
-
let t =
|
|
501
|
+
let t = Re.get(e) ?? "<unknown>", n = Ve.get(e) === o;
|
|
486
502
|
if (a !== "<unknown>" && a === t && !n) return c;
|
|
487
503
|
throw Error(`defineStore: '${e}' is already defined. Store names are the devtools + seed key, so two stores sharing one name would silently share state. Rename one.\n first: ${t}\n second: ${a}`);
|
|
488
504
|
}
|
|
@@ -518,10 +534,10 @@ var ze = () => {
|
|
|
518
534
|
t.setItem(u.key, JSON.stringify(n));
|
|
519
535
|
} catch {}
|
|
520
536
|
}, m = /* @__PURE__ */ new Map(), h = (n) => {
|
|
521
|
-
let r = n ??
|
|
537
|
+
let r = n ?? De, i = m.get(r);
|
|
522
538
|
if (i === void 0) {
|
|
523
539
|
let a = n;
|
|
524
|
-
i =
|
|
540
|
+
i = Ae(u !== void 0 && n === void 0 ? () => {
|
|
525
541
|
let e = t();
|
|
526
542
|
return g = e, {
|
|
527
543
|
...e,
|
|
@@ -535,7 +551,7 @@ var ze = () => {
|
|
|
535
551
|
next: n
|
|
536
552
|
}), e.steps.length > y && e.steps.shift(), e.cursor = e.steps.length;
|
|
537
553
|
}
|
|
538
|
-
|
|
554
|
+
Le({
|
|
539
555
|
store: e,
|
|
540
556
|
...a === void 0 ? {} : { key: a },
|
|
541
557
|
...r === void 0 ? {} : { label: r },
|
|
@@ -548,7 +564,7 @@ var ze = () => {
|
|
|
548
564
|
}
|
|
549
565
|
return i;
|
|
550
566
|
}, g, _ = /* @__PURE__ */ new Map(), v = (e) => {
|
|
551
|
-
let t = e ??
|
|
567
|
+
let t = e ?? De, n = _.get(t);
|
|
552
568
|
return n === void 0 && (n = {
|
|
553
569
|
steps: [],
|
|
554
570
|
cursor: 0
|
|
@@ -580,7 +596,7 @@ var ze = () => {
|
|
|
580
596
|
let n = u.current;
|
|
581
597
|
if (n.has && Object.is(n.state, t)) return n.value;
|
|
582
598
|
let r = o.current(t), i = c.current, a = n.has && (i ? i(n.value, r) : Object.is(n.value, r));
|
|
583
|
-
process.env.NODE_ENV !== "production" && i === void 0 && n.has && !a && typeof r == "object" && r && I(n.value, r) &&
|
|
599
|
+
process.env.NODE_ENV !== "production" && i === void 0 && n.has && !a && typeof r == "object" && r && I(n.value, r) && Ee(e, `[@voltro/client] ${e}.use(): the selector returns a NEW object each call, so the default identity check never sees it as unchanged and this component re-renders on EVERY store change.\n Pass \`{ equals: shallow }\` (exported from @voltro/client), or select a primitive.`);
|
|
584
600
|
let s = a ? n.value : r;
|
|
585
601
|
return u.current = {
|
|
586
602
|
state: t,
|
|
@@ -596,7 +612,7 @@ var ze = () => {
|
|
|
596
612
|
a,
|
|
597
613
|
f,
|
|
598
614
|
p
|
|
599
|
-
]), n(() => d(a.get()), [a, d]), n(() => d(
|
|
615
|
+
]), n(() => d(a.get()), [a, d]), n(() => d(ke(e, r?.key, r?.key === void 0 && g !== void 0 ? g : a.get())), [
|
|
600
616
|
a,
|
|
601
617
|
r?.key,
|
|
602
618
|
d
|
|
@@ -642,22 +658,22 @@ var ze = () => {
|
|
|
642
658
|
release: (e) => {
|
|
643
659
|
m.delete(e), _.delete(e);
|
|
644
660
|
},
|
|
645
|
-
keys: () => [...m.keys()].filter((e) => e !==
|
|
661
|
+
keys: () => [...m.keys()].filter((e) => e !== De)
|
|
646
662
|
};
|
|
647
|
-
return V.set(e, w),
|
|
648
|
-
},
|
|
649
|
-
V.clear(),
|
|
650
|
-
},
|
|
651
|
-
|
|
652
|
-
},
|
|
653
|
-
let r =
|
|
663
|
+
return V.set(e, w), Re.set(e, a), Ve.set(e, o), w;
|
|
664
|
+
}, Je = () => {
|
|
665
|
+
V.clear(), Re.clear(), Ve.clear(), Te.clear();
|
|
666
|
+
}, Ye = () => ({ seeds: [] }), Xe = (e) => {
|
|
667
|
+
Oe = e;
|
|
668
|
+
}, Ze = (e, t, n) => {
|
|
669
|
+
let r = Oe?.() ?? null;
|
|
654
670
|
if (r === null) throw Error(`seedStore('${e.name}') was called outside a server render. Seeding exists to put a value into the SSR hydration payload; on the client, set the store directly instead. (If this IS server code, the render did not install a seed bag — that is a framework bug.)`);
|
|
655
671
|
r.seeds.push({
|
|
656
672
|
store: e.name,
|
|
657
673
|
...n?.key === void 0 ? {} : { key: n.key },
|
|
658
674
|
value: t
|
|
659
675
|
});
|
|
660
|
-
},
|
|
676
|
+
}, Qe = (e) => {
|
|
661
677
|
if (e !== void 0) for (let t of e) {
|
|
662
678
|
let e = V.get(t.store);
|
|
663
679
|
e !== void 0 && e.set(t.value, t.key);
|
|
@@ -681,13 +697,13 @@ var ze = () => {
|
|
|
681
697
|
}
|
|
682
698
|
if (typeof r != "function") throw Error(`@voltro/client: rpc tag ${JSON.stringify(t)} did not resolve to a callable method.`);
|
|
683
699
|
return r;
|
|
684
|
-
},
|
|
700
|
+
}, $e = Object.freeze({
|
|
685
701
|
data: void 0,
|
|
686
702
|
revision: -1,
|
|
687
703
|
emittedAt: void 0,
|
|
688
704
|
error: void 0,
|
|
689
705
|
pendingPatches: 0
|
|
690
|
-
}),
|
|
706
|
+
}), et = () => $e;
|
|
691
707
|
function U(e, t, r = {}, i = {}) {
|
|
692
708
|
let a = i.skip === !0, { runtime: c, cache: u, client: d, descriptors: f } = P(e), p = f[t]?.source, m = s(r);
|
|
693
709
|
m.current = r;
|
|
@@ -699,11 +715,11 @@ function U(e, t, r = {}, i = {}) {
|
|
|
699
715
|
p,
|
|
700
716
|
a,
|
|
701
717
|
_
|
|
702
|
-
]), n(() => a ?
|
|
718
|
+
]), n(() => a ? $e : u.peek(_), [
|
|
703
719
|
u,
|
|
704
720
|
a,
|
|
705
721
|
_
|
|
706
|
-
]),
|
|
722
|
+
]), et), y = v.data !== void 0, b = y && (Array.isArray(v.data) ? v.data.length === 0 : v.data === null), x = {
|
|
707
723
|
revision: v.revision,
|
|
708
724
|
emittedAt: v.emittedAt,
|
|
709
725
|
error: v.error,
|
|
@@ -747,32 +763,32 @@ function U(e, t, r = {}, i = {}) {
|
|
|
747
763
|
}
|
|
748
764
|
//#endregion
|
|
749
765
|
//#region src/preloadSeed.ts
|
|
750
|
-
var
|
|
751
|
-
|
|
752
|
-
},
|
|
753
|
-
let i =
|
|
766
|
+
var tt = () => ({ seeds: [] }), nt = null, rt = (e) => {
|
|
767
|
+
nt = e;
|
|
768
|
+
}, it = /* @__PURE__ */ new Map(), at = (e, t) => `${e}\u0000${t}`, ot = (e, t, n, r) => {
|
|
769
|
+
let i = nt?.() ?? null;
|
|
754
770
|
if (i === null) throw Error(`seedPreloadedSubscription('${e}', '${t}') was called outside a server render. Preload seeds exist to put a subscription's first value into the SSR hydration payload; on the client the live subscription already provides it. (If this IS server code, the render did not install a seed bag — that is a framework bug.)`);
|
|
755
771
|
i.seeds.push({
|
|
756
772
|
api: e,
|
|
757
|
-
key:
|
|
773
|
+
key: O([t, n]),
|
|
758
774
|
value: r
|
|
759
775
|
});
|
|
760
|
-
},
|
|
761
|
-
if (e !== void 0) for (let t of e)
|
|
762
|
-
},
|
|
763
|
-
let r =
|
|
776
|
+
}, st = (e) => {
|
|
777
|
+
if (e !== void 0) for (let t of e) it.set(at(t.api, t.key), t.value);
|
|
778
|
+
}, ct = (e, t, n) => {
|
|
779
|
+
let r = O([t, n]), i = nt?.() ?? null;
|
|
764
780
|
if (i !== null) {
|
|
765
781
|
for (let t of i.seeds) if (t.api === e && t.key === r) return t.value;
|
|
766
782
|
return;
|
|
767
783
|
}
|
|
768
|
-
return
|
|
769
|
-
},
|
|
770
|
-
|
|
784
|
+
return it.get(at(e, r));
|
|
785
|
+
}, lt = () => {
|
|
786
|
+
it.clear();
|
|
771
787
|
};
|
|
772
788
|
//#endregion
|
|
773
789
|
//#region src/usePreloadedSubscription.ts
|
|
774
|
-
function
|
|
775
|
-
let i =
|
|
790
|
+
function ut(e, t, n = {}, r = {}) {
|
|
791
|
+
let i = ct(e, t, n);
|
|
776
792
|
return U(e, t, n, i === void 0 ? r : {
|
|
777
793
|
...r,
|
|
778
794
|
initialSnapshot: i
|
|
@@ -780,91 +796,91 @@ function it(e, t, n = {}, r = {}) {
|
|
|
780
796
|
}
|
|
781
797
|
//#endregion
|
|
782
798
|
//#region src/useEvent.ts
|
|
783
|
-
var
|
|
799
|
+
var dt = {
|
|
784
800
|
status: "idle",
|
|
785
801
|
missed: 0,
|
|
786
802
|
lastMiss: void 0
|
|
787
|
-
},
|
|
803
|
+
}, ft = class {
|
|
788
804
|
_tag = "EventStreamClosed";
|
|
789
805
|
};
|
|
790
|
-
function
|
|
791
|
-
let { skip: o = !1, apiName: l = "app", onMissed: u } = i, d = P(l), { runtime:
|
|
792
|
-
|
|
793
|
-
let
|
|
794
|
-
|
|
795
|
-
let
|
|
796
|
-
|
|
797
|
-
let S = s(
|
|
798
|
-
S.current =
|
|
806
|
+
function pt(e, t, r, i = {}) {
|
|
807
|
+
let { skip: o = !1, apiName: l = "app", onMissed: u } = i, d = P(l), { runtime: f, client: m } = d, [h, g] = c(dt), _ = s(r);
|
|
808
|
+
_.current = r;
|
|
809
|
+
let v = s(u);
|
|
810
|
+
v.current = u;
|
|
811
|
+
let b = s(m);
|
|
812
|
+
b.current = m;
|
|
813
|
+
let S = s(f);
|
|
814
|
+
S.current = f;
|
|
799
815
|
let C = s(/* @__PURE__ */ new Map()), w = t === null ? null : JSON.stringify(Object.entries(t).sort(([e], [t]) => e < t ? -1 : 1)), T = s(t);
|
|
800
816
|
T.current = t;
|
|
801
817
|
let ee = s(null);
|
|
802
818
|
ee.current !== w && (ee.current = w, C.current = /* @__PURE__ */ new Map());
|
|
803
|
-
let
|
|
804
|
-
e <= 0 || (
|
|
819
|
+
let te = n((e, t) => {
|
|
820
|
+
e <= 0 || (g((n) => ({
|
|
805
821
|
...n,
|
|
806
822
|
missed: n.missed + e,
|
|
807
823
|
lastMiss: {
|
|
808
824
|
count: e,
|
|
809
825
|
reason: t
|
|
810
826
|
}
|
|
811
|
-
})),
|
|
827
|
+
})), v.current?.({
|
|
812
828
|
count: e,
|
|
813
829
|
reason: t
|
|
814
830
|
}));
|
|
815
|
-
}, []),
|
|
831
|
+
}, []), E = !o && w !== null && !F(d);
|
|
816
832
|
return a(() => {
|
|
817
|
-
if (!
|
|
818
|
-
|
|
833
|
+
if (!E) {
|
|
834
|
+
g(dt);
|
|
819
835
|
return;
|
|
820
836
|
}
|
|
821
|
-
|
|
837
|
+
g((e) => ({
|
|
822
838
|
...e,
|
|
823
839
|
status: "connecting"
|
|
824
840
|
}));
|
|
825
|
-
let t = 0, n =
|
|
841
|
+
let t = 0, n = p.sync(() => {
|
|
826
842
|
let t = [...C.current].map(([e, t]) => ({
|
|
827
843
|
origin: e,
|
|
828
844
|
n: t
|
|
829
845
|
}));
|
|
830
|
-
return H(
|
|
846
|
+
return H(b.current, e.name)({
|
|
831
847
|
key: T.current,
|
|
832
848
|
...t.length > 0 ? { resume: t } : {}
|
|
833
849
|
});
|
|
834
|
-
}), r =
|
|
850
|
+
}), r = x.unwrap(n).pipe(x.tap(() => p.sync(() => {
|
|
835
851
|
t = 0;
|
|
836
|
-
})),
|
|
837
|
-
t += 1,
|
|
852
|
+
})), x.concat(x.fail(new ft())), x.retry(y.exponential("250 millis", 2).pipe(y.either(y.spaced("30 seconds")), y.jittered, y.tapOutput(() => p.sync(() => {
|
|
853
|
+
t += 1, g((e) => ({
|
|
838
854
|
...e,
|
|
839
855
|
status: "connecting"
|
|
840
856
|
}));
|
|
841
|
-
}))))), i = S.current.runFork(
|
|
857
|
+
}))))), i = S.current.runFork(x.runForEach(r, (e) => p.sync(() => {
|
|
842
858
|
if (e._tag === "attached") {
|
|
843
|
-
|
|
859
|
+
g((e) => ({
|
|
844
860
|
...e,
|
|
845
861
|
status: "live"
|
|
846
862
|
}));
|
|
847
863
|
return;
|
|
848
864
|
}
|
|
849
865
|
if (e._tag === "gap") {
|
|
850
|
-
|
|
866
|
+
te(e.missed, e.reason);
|
|
851
867
|
return;
|
|
852
868
|
}
|
|
853
|
-
C.current.set(e.origin, Math.max(C.current.get(e.origin) ?? 0, e.n)),
|
|
869
|
+
C.current.set(e.origin, Math.max(C.current.get(e.origin) ?? 0, e.n)), _.current(e.payload);
|
|
854
870
|
})));
|
|
855
871
|
return () => {
|
|
856
872
|
S.current.runFork(i.interruptAsFork(i.id()));
|
|
857
873
|
};
|
|
858
874
|
}, [
|
|
859
|
-
|
|
875
|
+
E,
|
|
860
876
|
w,
|
|
861
877
|
e.name,
|
|
862
|
-
|
|
863
|
-
]),
|
|
878
|
+
te
|
|
879
|
+
]), E ? h : dt;
|
|
864
880
|
}
|
|
865
881
|
//#endregion
|
|
866
882
|
//#region src/sequence.ts
|
|
867
|
-
var
|
|
883
|
+
var mt = () => {
|
|
868
884
|
let e = (t) => ({
|
|
869
885
|
steps: t,
|
|
870
886
|
step: ((n, r, i) => e([...t, {
|
|
@@ -876,7 +892,7 @@ var ct = () => {
|
|
|
876
892
|
}]))
|
|
877
893
|
});
|
|
878
894
|
return e([]);
|
|
879
|
-
},
|
|
895
|
+
}, ht = async (e, t = {}) => {
|
|
880
896
|
let n = {}, r = [];
|
|
881
897
|
for (let i of e.steps) {
|
|
882
898
|
if (i.when !== void 0 && !i.when(n)) {
|
|
@@ -936,13 +952,13 @@ var ct = () => {
|
|
|
936
952
|
ok: !0,
|
|
937
953
|
data: n
|
|
938
954
|
};
|
|
939
|
-
},
|
|
955
|
+
}, gt = (e = {}) => {
|
|
940
956
|
let [t, r] = c(!1), [i, a] = c(void 0), [o, l] = c(void 0), u = s(e);
|
|
941
957
|
return u.current = e, {
|
|
942
958
|
run: n(async (e, t = {}) => {
|
|
943
959
|
r(!0), a(void 0), l(void 0);
|
|
944
960
|
try {
|
|
945
|
-
let n = await
|
|
961
|
+
let n = await ht(e, {
|
|
946
962
|
...u.current,
|
|
947
963
|
...t
|
|
948
964
|
});
|
|
@@ -955,20 +971,20 @@ var ct = () => {
|
|
|
955
971
|
error: i,
|
|
956
972
|
failedStep: o
|
|
957
973
|
};
|
|
958
|
-
},
|
|
959
|
-
|
|
960
|
-
},
|
|
961
|
-
|
|
962
|
-
for (let e of
|
|
974
|
+
}, _t = 100, W = [], G = /* @__PURE__ */ new Set(), vt = [], yt = () => {
|
|
975
|
+
vt = W.slice();
|
|
976
|
+
}, bt = () => {
|
|
977
|
+
yt();
|
|
978
|
+
for (let e of G) try {
|
|
963
979
|
e();
|
|
964
980
|
} catch {}
|
|
965
|
-
},
|
|
981
|
+
}, xt = (e) => {
|
|
966
982
|
let t = {
|
|
967
983
|
...e,
|
|
968
984
|
status: "pending",
|
|
969
985
|
startedAt: Date.now()
|
|
970
986
|
};
|
|
971
|
-
W.unshift(t), W.length >
|
|
987
|
+
W.unshift(t), W.length > _t && (W.length = _t), bt();
|
|
972
988
|
}, K = (e, t) => {
|
|
973
989
|
let n = W.findIndex((t) => t.id === e);
|
|
974
990
|
if (n === -1) return;
|
|
@@ -985,12 +1001,12 @@ var ct = () => {
|
|
|
985
1001
|
error: t.error,
|
|
986
1002
|
settledAt: i,
|
|
987
1003
|
durationMs: i - r.startedAt
|
|
988
|
-
},
|
|
989
|
-
},
|
|
990
|
-
|
|
991
|
-
}),
|
|
992
|
-
W.length !== 0 && (W.length = 0,
|
|
993
|
-
},
|
|
1004
|
+
}, bt();
|
|
1005
|
+
}, St = () => vt, Ct = (e) => (G.add(e), () => {
|
|
1006
|
+
G.delete(e);
|
|
1007
|
+
}), wt = () => {
|
|
1008
|
+
W.length !== 0 && (W.length = 0, bt());
|
|
1009
|
+
}, Tt = (e, t) => {
|
|
994
1010
|
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
995
1011
|
try {
|
|
996
1012
|
Object.defineProperty(e, "__voltroTraceId", {
|
|
@@ -1000,18 +1016,18 @@ var ct = () => {
|
|
|
1000
1016
|
});
|
|
1001
1017
|
} catch {}
|
|
1002
1018
|
return e;
|
|
1003
|
-
}, q,
|
|
1019
|
+
}, q, Et = (e) => {
|
|
1004
1020
|
q = e;
|
|
1005
|
-
},
|
|
1021
|
+
}, Dt = () => q, Ot = (e, t, n) => typeof e == "function" ? e(t, n) : e, kt = 0, At = () => `mut_${++kt}`, jt = 0, Mt = () => {
|
|
1006
1022
|
let e = typeof crypto < "u" ? crypto : void 0;
|
|
1007
|
-
return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${
|
|
1008
|
-
},
|
|
1023
|
+
return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${jt += 1}`;
|
|
1024
|
+
}, Nt = (e, t) => e.pipe(p.locallyWith(T.currentHeaders, (e) => w.set(e, "idempotency-key", t))), Pt = (e, t) => ({
|
|
1009
1025
|
update: (n, r) => {
|
|
1010
1026
|
e.update(n, r, t);
|
|
1011
1027
|
},
|
|
1012
1028
|
forTag: (n, r) => e.forTag(n, r, t)
|
|
1013
1029
|
}), J = (e, t) => {
|
|
1014
|
-
let { runtime: r, cache: i, client: a, descriptors: l, errorBus: u } = P(e), d = l[t],
|
|
1030
|
+
let { runtime: r, cache: i, client: a, descriptors: l, errorBus: u } = P(e), d = l[t], f = d?.targets;
|
|
1015
1031
|
if (process.env.NODE_ENV !== "production") {
|
|
1016
1032
|
let n = d?.kind;
|
|
1017
1033
|
n !== void 0 && n !== "mutation" && console.error(`[@voltro/client] useMutation('${e}', '${t}') targets a ${n}, not a mutation. Use ${n === "action" ? "useAction" : n === "workflow" ? "useWorkflow" : `the ${n} hook`} instead.`);
|
|
@@ -1019,12 +1035,12 @@ var ct = () => {
|
|
|
1019
1035
|
let [m, h] = c(!1), [g, _] = c(void 0), [v, y] = c(void 0), b = s(null), x = s(!1), S = n(async (n, o) => {
|
|
1020
1036
|
let s = o?.onError !== void 0 || o?.notify?.error !== void 0, c = (e) => {
|
|
1021
1037
|
o?.onError?.(e, n);
|
|
1022
|
-
let t =
|
|
1038
|
+
let t = Ot(o?.notify?.error, e, n);
|
|
1023
1039
|
t !== void 0 && q?.error(t);
|
|
1024
1040
|
};
|
|
1025
1041
|
h(!0), _(void 0);
|
|
1026
|
-
let l =
|
|
1027
|
-
|
|
1042
|
+
let l = At(), d = o?.idempotencyKey ?? Mt();
|
|
1043
|
+
xt({
|
|
1028
1044
|
id: l,
|
|
1029
1045
|
apiName: e,
|
|
1030
1046
|
tag: t,
|
|
@@ -1032,7 +1048,7 @@ var ct = () => {
|
|
|
1032
1048
|
});
|
|
1033
1049
|
let m = b.current, g = x.current;
|
|
1034
1050
|
if (m) try {
|
|
1035
|
-
m(
|
|
1051
|
+
m(Pt(i, l), n);
|
|
1036
1052
|
} catch (e) {
|
|
1037
1053
|
if (_(e), h(!1), i.revertByMutation(l), K(l, {
|
|
1038
1054
|
status: "error",
|
|
@@ -1040,17 +1056,17 @@ var ct = () => {
|
|
|
1040
1056
|
}), s) return c(e);
|
|
1041
1057
|
throw e;
|
|
1042
1058
|
}
|
|
1043
|
-
else !g &&
|
|
1059
|
+
else !g && f && f.length > 0 && i.autoApply(f, n, l);
|
|
1044
1060
|
let v;
|
|
1045
1061
|
try {
|
|
1046
|
-
let s = H(a, t), c =
|
|
1047
|
-
v = e.traceId,
|
|
1062
|
+
let s = H(a, t), c = p.currentSpan.pipe(p.tap((e) => p.sync(() => {
|
|
1063
|
+
v = e.traceId, D({
|
|
1048
1064
|
traceId: e.traceId,
|
|
1049
1065
|
spanId: e.spanId,
|
|
1050
1066
|
source: "mutation",
|
|
1051
1067
|
tag: t
|
|
1052
1068
|
});
|
|
1053
|
-
})),
|
|
1069
|
+
})), p.catchAll(() => p.void), p.zipRight(Nt(s(n), d))).pipe(p.withSpan(`client.mutation.${t}`, { attributes: {
|
|
1054
1070
|
"voltro.api": e,
|
|
1055
1071
|
"voltro.mutationId": l,
|
|
1056
1072
|
"rpc.tag": t
|
|
@@ -1059,10 +1075,10 @@ var ct = () => {
|
|
|
1059
1075
|
status: "success",
|
|
1060
1076
|
output: u
|
|
1061
1077
|
}), i.confirmByMutation(l), o?.onSuccess?.(u, n);
|
|
1062
|
-
let
|
|
1063
|
-
return
|
|
1078
|
+
let f = Ot(o?.notify?.success, u, n);
|
|
1079
|
+
return f !== void 0 && q?.success(f), u;
|
|
1064
1080
|
} catch (e) {
|
|
1065
|
-
let n =
|
|
1081
|
+
let n = Tt(e, v);
|
|
1066
1082
|
if (_(n), K(l, {
|
|
1067
1083
|
status: "error",
|
|
1068
1084
|
error: n
|
|
@@ -1082,7 +1098,7 @@ var ct = () => {
|
|
|
1082
1098
|
a,
|
|
1083
1099
|
e,
|
|
1084
1100
|
t,
|
|
1085
|
-
|
|
1101
|
+
f
|
|
1086
1102
|
]);
|
|
1087
1103
|
return o(() => {
|
|
1088
1104
|
let e = {
|
|
@@ -1100,7 +1116,7 @@ var ct = () => {
|
|
|
1100
1116
|
g,
|
|
1101
1117
|
v
|
|
1102
1118
|
]);
|
|
1103
|
-
},
|
|
1119
|
+
}, Ft = (e, t) => {
|
|
1104
1120
|
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
1105
1121
|
try {
|
|
1106
1122
|
Object.defineProperty(e, "__voltroTraceId", {
|
|
@@ -1110,22 +1126,22 @@ var ct = () => {
|
|
|
1110
1126
|
});
|
|
1111
1127
|
} catch {}
|
|
1112
1128
|
return e;
|
|
1113
|
-
},
|
|
1129
|
+
}, It = (e, t, n) => typeof e == "function" ? e(t, n) : e, Lt = 0, Rt = () => `act_${++Lt}`, zt = 15e3, Bt = async (e, t, n) => {
|
|
1114
1130
|
if (!F(e.current)) return e.current;
|
|
1115
|
-
let r = Date.now() +
|
|
1131
|
+
let r = Date.now() + zt;
|
|
1116
1132
|
for (; Date.now() < r;) if (await new Promise((e) => setTimeout(e, 16)), !F(e.current)) return e.current;
|
|
1117
|
-
throw Error(`Voltro: the api "${t}" did not resolve within ${
|
|
1133
|
+
throw Error(`Voltro: the api "${t}" did not resolve within ${zt}ms, so ${n} was never sent. This is not the boot window — that is waited out. Check that "${t}" is a configured api name and that its client could connect.`);
|
|
1118
1134
|
}, Y = (e, t) => {
|
|
1119
1135
|
let r = P(e), { descriptors: i, errorBus: a } = r, l = s(r);
|
|
1120
1136
|
if (l.current = r, process.env.NODE_ENV !== "production") {
|
|
1121
1137
|
let n = i[t]?.kind;
|
|
1122
1138
|
n !== void 0 && n !== "action" && console.error(`[@voltro/client] useAction('${e}', '${t}') targets a ${n}, not an action. Use ${n === "mutation" ? "useMutation" : n === "workflow" ? "useWorkflow" : `the ${n} hook`} instead.`);
|
|
1123
1139
|
}
|
|
1124
|
-
let [u, d] = c(!1), [
|
|
1140
|
+
let [u, d] = c(!1), [f, m] = c(void 0), [h, g] = c(void 0), _ = n(async (n, r) => {
|
|
1125
1141
|
let i = r?.onError !== void 0 || r?.notify?.error !== void 0;
|
|
1126
1142
|
d(!0), m(void 0);
|
|
1127
|
-
let o =
|
|
1128
|
-
|
|
1143
|
+
let o = Rt(), s = r?.idempotencyKey ?? Mt();
|
|
1144
|
+
xt({
|
|
1129
1145
|
id: o,
|
|
1130
1146
|
apiName: e,
|
|
1131
1147
|
tag: t,
|
|
@@ -1133,26 +1149,26 @@ var ct = () => {
|
|
|
1133
1149
|
});
|
|
1134
1150
|
let c;
|
|
1135
1151
|
try {
|
|
1136
|
-
let { runtime: i, client: a } = await
|
|
1137
|
-
c = e.traceId,
|
|
1152
|
+
let { runtime: i, client: a } = await Bt(l, e, t), u = H(a, t), d = p.currentSpan.pipe(p.tap((e) => p.sync(() => {
|
|
1153
|
+
c = e.traceId, D({
|
|
1138
1154
|
traceId: e.traceId,
|
|
1139
1155
|
spanId: e.spanId,
|
|
1140
1156
|
source: "action",
|
|
1141
1157
|
tag: t
|
|
1142
1158
|
});
|
|
1143
|
-
})),
|
|
1159
|
+
})), p.catchAll(() => p.void), p.zipRight(Nt(u(n), s))).pipe(p.withSpan(`client.action.${t}`, { attributes: {
|
|
1144
1160
|
"voltro.api": e,
|
|
1145
1161
|
"voltro.actionId": o,
|
|
1146
1162
|
"rpc.tag": t
|
|
1147
|
-
} })),
|
|
1148
|
-
g(
|
|
1163
|
+
} })), f = await i.runPromise(d);
|
|
1164
|
+
g(f), K(o, {
|
|
1149
1165
|
status: "success",
|
|
1150
|
-
output:
|
|
1151
|
-
}), r?.onSuccess?.(
|
|
1152
|
-
let m =
|
|
1153
|
-
return m !== void 0 &&
|
|
1166
|
+
output: f
|
|
1167
|
+
}), r?.onSuccess?.(f, n);
|
|
1168
|
+
let m = It(r?.notify?.success, f, n);
|
|
1169
|
+
return m !== void 0 && Dt()?.success(m), f;
|
|
1154
1170
|
} catch (e) {
|
|
1155
|
-
let s =
|
|
1171
|
+
let s = Ft(e, c);
|
|
1156
1172
|
if (m(s), K(o, {
|
|
1157
1173
|
status: "error",
|
|
1158
1174
|
error: s
|
|
@@ -1163,8 +1179,8 @@ var ct = () => {
|
|
|
1163
1179
|
...c === void 0 ? {} : { traceId: c }
|
|
1164
1180
|
}), i) {
|
|
1165
1181
|
r?.onError?.(s, n);
|
|
1166
|
-
let e =
|
|
1167
|
-
e !== void 0 &&
|
|
1182
|
+
let e = It(r?.notify?.error, s, n);
|
|
1183
|
+
e !== void 0 && Dt()?.error(e);
|
|
1168
1184
|
return;
|
|
1169
1185
|
}
|
|
1170
1186
|
throw s;
|
|
@@ -1179,15 +1195,15 @@ var ct = () => {
|
|
|
1179
1195
|
return o(() => ({
|
|
1180
1196
|
run: _,
|
|
1181
1197
|
pending: u,
|
|
1182
|
-
error:
|
|
1198
|
+
error: f,
|
|
1183
1199
|
lastResult: h
|
|
1184
1200
|
}), [
|
|
1185
1201
|
_,
|
|
1186
1202
|
u,
|
|
1187
|
-
|
|
1203
|
+
f,
|
|
1188
1204
|
h
|
|
1189
1205
|
]);
|
|
1190
|
-
},
|
|
1206
|
+
}, Vt = "storage.mintUploadTicket", Ht = "storage.mintPresignedUpload", Ut = "storage.finalizeUpload", Wt = "storage.beginResumableUpload", Gt = "storage.beginMultipartUpload", Kt = "storage.signMultipartPart", qt = "storage.completeMultipartUpload", Jt = "storage.abortMultipartUpload", Yt = (e, t, n, r) => new Promise((i, a) => {
|
|
1191
1207
|
let o = new XMLHttpRequest();
|
|
1192
1208
|
if (o.open("PUT", e), o.upload.onprogress = (e) => {
|
|
1193
1209
|
e.lengthComputable && n(e.loaded / e.total);
|
|
@@ -1201,7 +1217,7 @@ var ct = () => {
|
|
|
1201
1217
|
return;
|
|
1202
1218
|
}
|
|
1203
1219
|
r.addEventListener("abort", () => o.abort(), { once: !0 }), o.send(t);
|
|
1204
|
-
}),
|
|
1220
|
+
}), Xt = (e, t, n, r, i, a) => new Promise((o, s) => {
|
|
1205
1221
|
let c = new XMLHttpRequest();
|
|
1206
1222
|
if (c.open("POST", e), c.setRequestHeader("content-type", t), c.upload.onprogress = (e) => {
|
|
1207
1223
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -1219,7 +1235,7 @@ var ct = () => {
|
|
|
1219
1235
|
return;
|
|
1220
1236
|
}
|
|
1221
1237
|
i.addEventListener("abort", () => c.abort(), { once: !0 }), c.send(n);
|
|
1222
|
-
}),
|
|
1238
|
+
}), Zt = (e, t, n, r, i) => new Promise((a, o) => {
|
|
1223
1239
|
let s = new XMLHttpRequest();
|
|
1224
1240
|
if (s.open("PUT", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
1225
1241
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -1230,7 +1246,7 @@ var ct = () => {
|
|
|
1230
1246
|
return;
|
|
1231
1247
|
}
|
|
1232
1248
|
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
1233
|
-
}),
|
|
1249
|
+
}), Qt = (e, t, n, r, i) => new Promise((a, o) => {
|
|
1234
1250
|
let s = new XMLHttpRequest();
|
|
1235
1251
|
if (s.open("POST", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
1236
1252
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -1246,7 +1262,7 @@ var ct = () => {
|
|
|
1246
1262
|
return;
|
|
1247
1263
|
}
|
|
1248
1264
|
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
1249
|
-
}),
|
|
1265
|
+
}), $t = (e, t = {}) => {
|
|
1250
1266
|
let { runtime: r, client: i, inspectBaseUrl: a, errorBus: l } = P(e), [u, d] = c(0), [f, p] = c("idle"), [m, h] = c(void 0), g = s(null), _ = n(() => {
|
|
1251
1267
|
d(0), p("idle"), h(void 0);
|
|
1252
1268
|
}, []), v = n(() => {
|
|
@@ -1267,14 +1283,14 @@ var ct = () => {
|
|
|
1267
1283
|
...e.width === void 0 ? {} : { width: e.width },
|
|
1268
1284
|
...e.height === void 0 ? {} : { height: e.height }
|
|
1269
1285
|
}), g = async () => {
|
|
1270
|
-
let s = n.mintTag ?? t.mintTag ??
|
|
1286
|
+
let s = n.mintTag ?? t.mintTag ?? Vt, l = H(i, s), u = await r.runPromise(l({
|
|
1271
1287
|
contentType: c,
|
|
1272
1288
|
...m,
|
|
1273
1289
|
...d ? { key: d } : {}
|
|
1274
|
-
})), f = await
|
|
1290
|
+
})), f = await Qt(y(u.uploadUrl), c, e, o, a);
|
|
1275
1291
|
return h(f);
|
|
1276
1292
|
}, _ = async () => {
|
|
1277
|
-
let s = n.presignMintTag ?? t.presignMintTag ??
|
|
1293
|
+
let s = n.presignMintTag ?? t.presignMintTag ?? Ht, l = n.finalizeTag ?? t.finalizeTag ?? Ut, u;
|
|
1278
1294
|
try {
|
|
1279
1295
|
let e = H(i, s);
|
|
1280
1296
|
u = await r.runPromise(e({
|
|
@@ -1284,11 +1300,11 @@ var ct = () => {
|
|
|
1284
1300
|
} catch {
|
|
1285
1301
|
return null;
|
|
1286
1302
|
}
|
|
1287
|
-
await
|
|
1303
|
+
await Zt(u.uploadUrl, c, e, o, a);
|
|
1288
1304
|
let d = H(i, l), f = await r.runPromise(d({ finalizeToken: u.finalizeToken }));
|
|
1289
1305
|
return h(f);
|
|
1290
1306
|
}, v = async () => {
|
|
1291
|
-
let s = n.beginResumableTag ?? t.beginResumableTag ??
|
|
1307
|
+
let s = n.beginResumableTag ?? t.beginResumableTag ?? Wt, l = H(i, s), u = e.size, d = n.chunkSize ?? t.chunkSize, f = await r.runPromise(l({
|
|
1292
1308
|
contentType: c,
|
|
1293
1309
|
size: u,
|
|
1294
1310
|
...m,
|
|
@@ -1299,7 +1315,7 @@ var ct = () => {
|
|
|
1299
1315
|
for (;;) {
|
|
1300
1316
|
if (a.aborted) throw new DOMException("upload aborted", "AbortError");
|
|
1301
1317
|
try {
|
|
1302
|
-
let e = await
|
|
1318
|
+
let e = await Xt(`${p}?${`token=${encodeURIComponent(f.resumableToken)}&index=${t}${s ? "&final=1" : ""}`}`, c, i, (e) => o((b + e * l) / u), a, s);
|
|
1303
1319
|
s && (x = e);
|
|
1304
1320
|
break;
|
|
1305
1321
|
} catch (e) {
|
|
@@ -1311,7 +1327,7 @@ var ct = () => {
|
|
|
1311
1327
|
if (!x) throw Error("resumable upload produced no final reply");
|
|
1312
1328
|
return h(x);
|
|
1313
1329
|
}, b = async () => {
|
|
1314
|
-
let s = n.multipartBeginTag ?? t.multipartBeginTag ??
|
|
1330
|
+
let s = n.multipartBeginTag ?? t.multipartBeginTag ?? Gt, u = n.multipartSignTag ?? t.multipartSignTag ?? Kt, d = n.multipartCompleteTag ?? t.multipartCompleteTag ?? qt, f = n.multipartAbortTag ?? t.multipartAbortTag ?? Jt, p = e.size, h = n.chunkSize ?? t.chunkSize, g;
|
|
1315
1331
|
try {
|
|
1316
1332
|
let e = H(i, s);
|
|
1317
1333
|
g = await r.runPromise(e({
|
|
@@ -1333,7 +1349,7 @@ var ct = () => {
|
|
|
1333
1349
|
let { url: e } = await r.runPromise(_({
|
|
1334
1350
|
multipartToken: g.multipartToken,
|
|
1335
1351
|
partNumber: c
|
|
1336
|
-
})), t = await
|
|
1352
|
+
})), t = await Yt(e, s, (e) => o((T + e * l) / p), a);
|
|
1337
1353
|
w.push({
|
|
1338
1354
|
partNumber: c,
|
|
1339
1355
|
etag: t
|
|
@@ -1407,7 +1423,7 @@ var ct = () => {
|
|
|
1407
1423
|
} catch (e) {
|
|
1408
1424
|
throw p("error"), h(e), e instanceof DOMException && e.name === "AbortError" || l.emit({
|
|
1409
1425
|
source: "action",
|
|
1410
|
-
tag: n.mintTag ?? t.mintTag ??
|
|
1426
|
+
tag: n.mintTag ?? t.mintTag ?? Vt,
|
|
1411
1427
|
error: e
|
|
1412
1428
|
}), e;
|
|
1413
1429
|
}
|
|
@@ -1433,7 +1449,7 @@ var ct = () => {
|
|
|
1433
1449
|
} catch (e) {
|
|
1434
1450
|
throw r.abort(), p("error"), h(e), e instanceof DOMException && e.name === "AbortError" || l.emit({
|
|
1435
1451
|
source: "action",
|
|
1436
|
-
tag: n.mintTag ?? t.mintTag ??
|
|
1452
|
+
tag: n.mintTag ?? t.mintTag ?? Vt,
|
|
1437
1453
|
error: e
|
|
1438
1454
|
}), e;
|
|
1439
1455
|
}
|
|
@@ -1479,19 +1495,19 @@ var ct = () => {
|
|
|
1479
1495
|
T
|
|
1480
1496
|
]);
|
|
1481
1497
|
}, X = async (e) => {
|
|
1482
|
-
let t = H(e.client, e.tag), n =
|
|
1483
|
-
|
|
1498
|
+
let t = H(e.client, e.tag), n = p.currentSpan.pipe(p.tap((t) => p.sync(() => {
|
|
1499
|
+
D({
|
|
1484
1500
|
traceId: t.traceId,
|
|
1485
1501
|
spanId: t.spanId,
|
|
1486
1502
|
source: "mutation",
|
|
1487
1503
|
tag: e.tag
|
|
1488
1504
|
});
|
|
1489
|
-
})),
|
|
1505
|
+
})), p.catchAll(() => p.void), p.zipRight(t(e.input)), p.withSpan(`${e.spanPrefix}.${e.tag}`, { attributes: {
|
|
1490
1506
|
"voltro.api": e.apiName,
|
|
1491
1507
|
"rpc.tag": e.tag
|
|
1492
1508
|
} }));
|
|
1493
1509
|
return e.runtime.runPromise(n);
|
|
1494
|
-
},
|
|
1510
|
+
}, en = (e, t) => {
|
|
1495
1511
|
let { runtime: r, client: i, descriptors: a } = P(e);
|
|
1496
1512
|
if (process.env.NODE_ENV !== "production") {
|
|
1497
1513
|
let n = a[t]?.kind;
|
|
@@ -1596,7 +1612,7 @@ var ct = () => {
|
|
|
1596
1612
|
u,
|
|
1597
1613
|
f
|
|
1598
1614
|
]);
|
|
1599
|
-
},
|
|
1615
|
+
}, tn = (e) => {
|
|
1600
1616
|
let { runtime: t, client: r } = P(e), [i, a] = c(!1), [s, l] = c(void 0), [u, d] = c(void 0), f = n(async (n, i, o) => {
|
|
1601
1617
|
a(!0), l(void 0);
|
|
1602
1618
|
try {
|
|
@@ -1634,7 +1650,7 @@ var ct = () => {
|
|
|
1634
1650
|
s,
|
|
1635
1651
|
u
|
|
1636
1652
|
]);
|
|
1637
|
-
},
|
|
1653
|
+
}, nn = (e) => {
|
|
1638
1654
|
let { runtime: t, client: r } = P(e), [i, a] = c(!1), [s, l] = c(void 0), [u, d] = c(void 0), f = n(async (n, i, o, s) => {
|
|
1639
1655
|
a(!0), l(void 0);
|
|
1640
1656
|
try {
|
|
@@ -1673,7 +1689,7 @@ var ct = () => {
|
|
|
1673
1689
|
s,
|
|
1674
1690
|
u
|
|
1675
1691
|
]);
|
|
1676
|
-
},
|
|
1692
|
+
}, rn = (e, t) => {
|
|
1677
1693
|
let n = U(e, "__voltro.workflow.run", t ? { id: t } : {}, { skip: t === void 0 });
|
|
1678
1694
|
return n.loading || n.idle ? {
|
|
1679
1695
|
...n,
|
|
@@ -1682,7 +1698,7 @@ var ct = () => {
|
|
|
1682
1698
|
...n,
|
|
1683
1699
|
run: n.data[0]
|
|
1684
1700
|
};
|
|
1685
|
-
},
|
|
1701
|
+
}, an = (e, t = {}, n = {}) => {
|
|
1686
1702
|
let r = U(e, "__voltro.workflow.runs", t, n);
|
|
1687
1703
|
return r.loading || r.idle ? {
|
|
1688
1704
|
...r,
|
|
@@ -1691,7 +1707,7 @@ var ct = () => {
|
|
|
1691
1707
|
...r,
|
|
1692
1708
|
runs: r.data
|
|
1693
1709
|
};
|
|
1694
|
-
},
|
|
1710
|
+
}, on = (e, t) => {
|
|
1695
1711
|
let n = U(e, "__voltro.workflow.run.steps", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
1696
1712
|
return n.loading || n.idle ? {
|
|
1697
1713
|
...n,
|
|
@@ -1700,7 +1716,7 @@ var ct = () => {
|
|
|
1700
1716
|
...n,
|
|
1701
1717
|
steps: n.data
|
|
1702
1718
|
};
|
|
1703
|
-
},
|
|
1719
|
+
}, sn = (e, t) => {
|
|
1704
1720
|
let n = U(e, "__voltro.workflow.run.events", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
1705
1721
|
return n.loading || n.idle ? {
|
|
1706
1722
|
...n,
|
|
@@ -1709,7 +1725,7 @@ var ct = () => {
|
|
|
1709
1725
|
...n,
|
|
1710
1726
|
events: n.data
|
|
1711
1727
|
};
|
|
1712
|
-
},
|
|
1728
|
+
}, cn = sn, ln = (e, t = {}, n = {}) => {
|
|
1713
1729
|
let r = U(e, "__voltro.workflow.domainEvents", t, n);
|
|
1714
1730
|
return r.loading || r.idle ? {
|
|
1715
1731
|
...r,
|
|
@@ -1718,7 +1734,7 @@ var ct = () => {
|
|
|
1718
1734
|
...r,
|
|
1719
1735
|
events: r.data
|
|
1720
1736
|
};
|
|
1721
|
-
},
|
|
1737
|
+
}, un = (e, t) => {
|
|
1722
1738
|
let n = U(e, "__voltro.workflow.event.deliveries", t ? { eventId: t } : {}, { skip: t === void 0 });
|
|
1723
1739
|
return n.loading || n.idle ? {
|
|
1724
1740
|
...n,
|
|
@@ -1727,42 +1743,42 @@ var ct = () => {
|
|
|
1727
1743
|
...n,
|
|
1728
1744
|
deliveries: n.data
|
|
1729
1745
|
};
|
|
1730
|
-
},
|
|
1746
|
+
}, dn = (e, t) => {
|
|
1731
1747
|
let n = e.payload;
|
|
1732
1748
|
if (!n || typeof n != "object") return;
|
|
1733
1749
|
let r = n[t];
|
|
1734
1750
|
return typeof r == "string" ? r : void 0;
|
|
1735
|
-
},
|
|
1751
|
+
}, fn = (e) => {
|
|
1736
1752
|
let t = e.payload;
|
|
1737
1753
|
if (!t || typeof t != "object") return;
|
|
1738
1754
|
let n = t.updateId;
|
|
1739
1755
|
return typeof n == "string" ? n : void 0;
|
|
1740
|
-
},
|
|
1756
|
+
}, pn = (e) => {
|
|
1741
1757
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
1742
1758
|
for (let r of e) if (r.eventType === "signal-received") {
|
|
1743
|
-
let e =
|
|
1759
|
+
let e = dn(r, "signalName");
|
|
1744
1760
|
e && t.add(e);
|
|
1745
1761
|
} else if (r.eventType === "update-completed" || r.eventType === "update-failed") {
|
|
1746
|
-
let e =
|
|
1762
|
+
let e = fn(r);
|
|
1747
1763
|
e && n.add(e);
|
|
1748
1764
|
}
|
|
1749
1765
|
for (let r = e.length - 1; r >= 0; --r) {
|
|
1750
1766
|
let i = e[r];
|
|
1751
1767
|
if (i.eventType === "signal-awaited") {
|
|
1752
|
-
let e =
|
|
1768
|
+
let e = dn(i, "signalName");
|
|
1753
1769
|
if (e && !t.has(e)) return {
|
|
1754
1770
|
name: e,
|
|
1755
1771
|
kind: "signal"
|
|
1756
1772
|
};
|
|
1757
1773
|
} else if (i.eventType === "update-requested") {
|
|
1758
|
-
let e =
|
|
1774
|
+
let e = fn(i), t = dn(i, "updateName");
|
|
1759
1775
|
if (t && (!e || !n.has(e))) return {
|
|
1760
1776
|
name: t,
|
|
1761
1777
|
kind: "update"
|
|
1762
1778
|
};
|
|
1763
1779
|
}
|
|
1764
1780
|
}
|
|
1765
|
-
},
|
|
1781
|
+
}, mn = (e) => e.find((e) => e.status === "running") || (e.length > 0 ? e[e.length - 1] : void 0), hn = (e, t) => {
|
|
1766
1782
|
if (!e || e.status !== "failed") return;
|
|
1767
1783
|
let n = t.find((e) => e.status === "failed");
|
|
1768
1784
|
return {
|
|
@@ -1770,8 +1786,8 @@ var ct = () => {
|
|
|
1770
1786
|
message: e.errorMessage,
|
|
1771
1787
|
step: n?.stepName
|
|
1772
1788
|
};
|
|
1773
|
-
},
|
|
1774
|
-
let r =
|
|
1789
|
+
}, gn = (e, t) => {
|
|
1790
|
+
let r = rn(e, t), i = on(e, t), a = sn(e, t), s = en(e, r.run?.tag ?? ""), c = r.run, l = i.steps, u = a.events, d = n(async () => {
|
|
1775
1791
|
if (!c) throw Error("useWorkflowRunState: no run loaded — cannot cancel");
|
|
1776
1792
|
await s.cancel({
|
|
1777
1793
|
workflowName: c.tag,
|
|
@@ -1795,9 +1811,9 @@ var ct = () => {
|
|
|
1795
1811
|
status: c?.status,
|
|
1796
1812
|
steps: l,
|
|
1797
1813
|
events: u,
|
|
1798
|
-
currentStep:
|
|
1799
|
-
waitingFor: c?.status === "suspended" ?
|
|
1800
|
-
error:
|
|
1814
|
+
currentStep: mn(l),
|
|
1815
|
+
waitingFor: c?.status === "suspended" ? pn(u) : void 0,
|
|
1816
|
+
error: hn(c, l),
|
|
1801
1817
|
traceId: c?.traceId,
|
|
1802
1818
|
loading: r.data === void 0,
|
|
1803
1819
|
cancel: d,
|
|
@@ -1814,24 +1830,24 @@ var ct = () => {
|
|
|
1814
1830
|
p,
|
|
1815
1831
|
m
|
|
1816
1832
|
]);
|
|
1817
|
-
},
|
|
1818
|
-
let { runtime: r, client: i } = P(e), [a, o] = c([]), [l, d] = c("idle"), [
|
|
1833
|
+
}, _n = (e, t) => {
|
|
1834
|
+
let { runtime: r, client: i } = P(e), [a, o] = c([]), [l, d] = c("idle"), [f, m] = c(void 0), g = s(null), _ = n(() => {
|
|
1819
1835
|
let e = g.current;
|
|
1820
|
-
e && (g.current = null, r.runFork(
|
|
1836
|
+
e && (g.current = null, r.runFork(h.interrupt(e)), d((e) => e === "streaming" ? "idle" : e));
|
|
1821
1837
|
}, [r]);
|
|
1822
1838
|
return {
|
|
1823
1839
|
events: a,
|
|
1824
1840
|
status: l,
|
|
1825
|
-
error:
|
|
1841
|
+
error: f,
|
|
1826
1842
|
start: n((e = {}) => {
|
|
1827
1843
|
let n = g.current;
|
|
1828
|
-
n && r.runFork(
|
|
1829
|
-
let a = H(i, t)(e), s =
|
|
1844
|
+
n && r.runFork(h.interrupt(n)), o([]), m(void 0), d("streaming");
|
|
1845
|
+
let a = H(i, t)(e), s = x.runForEach(a, (e) => p.sync(() => o((t) => [...t, e]))).pipe(p.matchCause({
|
|
1830
1846
|
onSuccess: () => {
|
|
1831
1847
|
d("done");
|
|
1832
1848
|
},
|
|
1833
1849
|
onFailure: (e) => {
|
|
1834
|
-
u.isInterruptedOnly(e) || (
|
|
1850
|
+
u.isInterruptedOnly(e) || (m(u.squash(e)), d("error"));
|
|
1835
1851
|
}
|
|
1836
1852
|
}));
|
|
1837
1853
|
g.current = r.runFork(s);
|
|
@@ -1842,57 +1858,57 @@ var ct = () => {
|
|
|
1842
1858
|
]),
|
|
1843
1859
|
cancel: _
|
|
1844
1860
|
};
|
|
1845
|
-
},
|
|
1846
|
-
let i = 0, a = !1, o = (e) =>
|
|
1861
|
+
}, vn = (e, t, n, r) => {
|
|
1862
|
+
let i = 0, a = !1, o = (e) => p.sync(() => {
|
|
1847
1863
|
e.seq <= i || (i = e.seq, n.onEvent(e.event), r.isTerminal(e.event) && (a = !0));
|
|
1848
1864
|
}), s = (e, t, a) => {
|
|
1849
1865
|
let o = i > t ? 0 : e + 1;
|
|
1850
|
-
if (o > r.maxReconnects) return
|
|
1866
|
+
if (o > r.maxReconnects) return p.sync(() => {
|
|
1851
1867
|
n.onError(a ?? /* @__PURE__ */ Error("stream connection lost")), n.onStatus("error");
|
|
1852
1868
|
});
|
|
1853
1869
|
let s = Math.min(r.maxBackoffMs, r.backoffMs * 2 ** Math.max(0, o - 1));
|
|
1854
|
-
return
|
|
1870
|
+
return p.sync(() => {
|
|
1855
1871
|
n.onStatus("reconnecting"), n.onReconnect();
|
|
1856
|
-
}).pipe(
|
|
1857
|
-
}, c = (r) =>
|
|
1872
|
+
}).pipe(p.zipRight(p.sleep(f.millis(s))), p.zipRight(p.sync(() => n.onStatus("streaming"))), p.zipRight(c(o)));
|
|
1873
|
+
}, c = (r) => p.suspend(() => {
|
|
1858
1874
|
let c = i, l = e({
|
|
1859
1875
|
...t,
|
|
1860
1876
|
fromSeq: c
|
|
1861
1877
|
});
|
|
1862
|
-
return
|
|
1863
|
-
onSuccess: () => a ?
|
|
1864
|
-
onFailure: (e) => u.isInterruptedOnly(e) ?
|
|
1878
|
+
return x.runForEach(l, o).pipe(p.matchCauseEffect({
|
|
1879
|
+
onSuccess: () => a ? p.sync(() => n.onStatus("done")) : s(r, c, void 0),
|
|
1880
|
+
onFailure: (e) => u.isInterruptedOnly(e) ? p.void : a ? p.sync(() => n.onStatus("done")) : s(r, c, u.squash(e))
|
|
1865
1881
|
}));
|
|
1866
1882
|
});
|
|
1867
1883
|
return c(0);
|
|
1868
|
-
},
|
|
1884
|
+
}, yn = (e) => {
|
|
1869
1885
|
let t = e?._tag;
|
|
1870
1886
|
return t === "done" || t === "error";
|
|
1871
|
-
},
|
|
1872
|
-
let { runtime: i, client: a } = P(e), [o, l] = c([]), [u, d] = c("idle"), [f, p] = c(0), [
|
|
1887
|
+
}, bn = (e, t, r = {}) => {
|
|
1888
|
+
let { runtime: i, client: a } = P(e), [o, l] = c([]), [u, d] = c("idle"), [f, p] = c(0), [m, g] = c(void 0), _ = s(null), v = {
|
|
1873
1889
|
maxReconnects: r.maxReconnects ?? 6,
|
|
1874
1890
|
backoffMs: r.backoffMs ?? 400,
|
|
1875
1891
|
maxBackoffMs: r.maxBackoffMs ?? 8e3,
|
|
1876
|
-
isTerminal: r.isTerminal ??
|
|
1892
|
+
isTerminal: r.isTerminal ?? yn
|
|
1877
1893
|
}, y = n(() => {
|
|
1878
1894
|
let e = _.current;
|
|
1879
|
-
e && (_.current = null, i.runFork(
|
|
1895
|
+
e && (_.current = null, i.runFork(h.interrupt(e)), d((e) => e === "streaming" || e === "reconnecting" ? "idle" : e));
|
|
1880
1896
|
}, [i]);
|
|
1881
1897
|
return {
|
|
1882
1898
|
events: o,
|
|
1883
1899
|
status: u,
|
|
1884
1900
|
reconnects: f,
|
|
1885
|
-
error:
|
|
1901
|
+
error: m,
|
|
1886
1902
|
start: n((e = {}) => {
|
|
1887
1903
|
let n = _.current;
|
|
1888
|
-
n && i.runFork(
|
|
1904
|
+
n && i.runFork(h.interrupt(n)), l([]), g(void 0), p(0), d("streaming");
|
|
1889
1905
|
let r = H(a, t), o = {
|
|
1890
1906
|
onEvent: (e) => l((t) => [...t, e]),
|
|
1891
1907
|
onStatus: d,
|
|
1892
1908
|
onReconnect: () => p((e) => e + 1),
|
|
1893
1909
|
onError: g
|
|
1894
1910
|
};
|
|
1895
|
-
_.current = i.runFork(
|
|
1911
|
+
_.current = i.runFork(vn(r, e, o, v));
|
|
1896
1912
|
}, [
|
|
1897
1913
|
i,
|
|
1898
1914
|
a,
|
|
@@ -1904,13 +1920,13 @@ var ct = () => {
|
|
|
1904
1920
|
]),
|
|
1905
1921
|
cancel: y
|
|
1906
1922
|
};
|
|
1907
|
-
},
|
|
1923
|
+
}, xn = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0), Sn = (e) => {
|
|
1908
1924
|
for (let t = e.length - 1; t >= 0; --t) {
|
|
1909
1925
|
let n = e[t];
|
|
1910
1926
|
if (n.role === "user" && n.content) return n.content;
|
|
1911
1927
|
}
|
|
1912
|
-
},
|
|
1913
|
-
let { threadId: i } = r, a = U(e, `${t}.messages`, { threadId: i }), s = Y(e, `${t}.send`), c = o(() => [...a.data ?? []].sort(
|
|
1928
|
+
}, Cn = (e, t, r) => {
|
|
1929
|
+
let { threadId: i } = r, a = U(e, `${t}.messages`, { threadId: i }), s = Y(e, `${t}.send`), c = o(() => [...a.data ?? []].sort(xn), [a.data]), l = n((e, t = {}) => s.run({
|
|
1914
1930
|
threadId: i,
|
|
1915
1931
|
order: a.data?.length ?? 0,
|
|
1916
1932
|
prompt: e,
|
|
@@ -1920,7 +1936,7 @@ var ct = () => {
|
|
|
1920
1936
|
i,
|
|
1921
1937
|
a.data
|
|
1922
1938
|
]), u = n(() => {
|
|
1923
|
-
let e =
|
|
1939
|
+
let e = Sn(c);
|
|
1924
1940
|
return e === void 0 ? void 0 : l(e);
|
|
1925
1941
|
}, [c, l]);
|
|
1926
1942
|
return o(() => ({
|
|
@@ -1940,8 +1956,8 @@ var ct = () => {
|
|
|
1940
1956
|
l,
|
|
1941
1957
|
u
|
|
1942
1958
|
]);
|
|
1943
|
-
},
|
|
1944
|
-
let { events: r, status: i, error: l, start: u, cancel: d } =
|
|
1959
|
+
}, wn = (e, t) => {
|
|
1960
|
+
let { events: r, status: i, error: l, start: u, cancel: d } = _n(e, t), [f, p] = c([]), m = s(null), h = o(() => r.filter((e) => e._tag === "token").map((e) => e.text ?? "").join(""), [r]);
|
|
1945
1961
|
return a(() => {
|
|
1946
1962
|
if (i !== "done" || m.current === null) return;
|
|
1947
1963
|
let e = m.current;
|
|
@@ -1967,7 +1983,7 @@ var ct = () => {
|
|
|
1967
1983
|
}, [u]),
|
|
1968
1984
|
cancel: d
|
|
1969
1985
|
};
|
|
1970
|
-
},
|
|
1986
|
+
}, Tn = (e, t) => {
|
|
1971
1987
|
let r = Y(e, t), [i, a] = c(void 0), s = n(async (e) => {
|
|
1972
1988
|
let t = await r.run({ question: e });
|
|
1973
1989
|
return a(t), t;
|
|
@@ -1985,43 +2001,43 @@ var ct = () => {
|
|
|
1985
2001
|
r.error,
|
|
1986
2002
|
l
|
|
1987
2003
|
]);
|
|
1988
|
-
},
|
|
2004
|
+
}, En = (e) => {
|
|
1989
2005
|
let { cache: t, runtime: r } = P(e);
|
|
1990
2006
|
return n(() => {
|
|
1991
2007
|
t.refreshAll(r);
|
|
1992
2008
|
}, [t, r]);
|
|
1993
|
-
},
|
|
1994
|
-
for (let t of
|
|
2009
|
+
}, Dn = /* @__PURE__ */ new Set(), On = (e) => {
|
|
2010
|
+
for (let t of Dn) try {
|
|
1995
2011
|
t(e);
|
|
1996
2012
|
} catch {}
|
|
1997
|
-
},
|
|
1998
|
-
|
|
1999
|
-
}),
|
|
2000
|
-
|
|
2013
|
+
}, kn = (e) => (Dn.add(e), () => {
|
|
2014
|
+
Dn.delete(e);
|
|
2015
|
+
}), An = (e, t) => {
|
|
2016
|
+
On({
|
|
2001
2017
|
error: e,
|
|
2002
2018
|
source: "manual",
|
|
2003
2019
|
...t ? { context: t } : {}
|
|
2004
2020
|
});
|
|
2005
|
-
},
|
|
2021
|
+
}, jn = (e, t) => {
|
|
2006
2022
|
let { errorBus: n } = P(e);
|
|
2007
2023
|
a(() => n.on(t), [n, t]);
|
|
2008
|
-
},
|
|
2024
|
+
}, Mn = "#/$defs/", Nn = (e) => e.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\s+/g, " ").trim().replace(/^./, (e) => e.toUpperCase()), Z = (e, t) => {
|
|
2009
2025
|
let n = e;
|
|
2010
2026
|
for (let e = 0; e < 8; e += 1) {
|
|
2011
2027
|
let e = n.$ref;
|
|
2012
|
-
if (typeof e != "string" || !e.startsWith(
|
|
2028
|
+
if (typeof e != "string" || !e.startsWith(Mn)) return n;
|
|
2013
2029
|
let r = t[e.slice(8)];
|
|
2014
2030
|
if (!r || typeof r != "object") return n;
|
|
2015
2031
|
n = r;
|
|
2016
2032
|
}
|
|
2017
2033
|
return n;
|
|
2018
|
-
},
|
|
2034
|
+
}, Pn = (e) => {
|
|
2019
2035
|
if (!e || typeof e != "object") return !1;
|
|
2020
2036
|
let t = e;
|
|
2021
2037
|
if (t.type === "null" || t.const === null) return !0;
|
|
2022
2038
|
let n = t.enum;
|
|
2023
2039
|
return Array.isArray(n) && n.length === 1 && n[0] === null;
|
|
2024
|
-
},
|
|
2040
|
+
}, Fn = (e, t) => {
|
|
2025
2041
|
let n = e.type;
|
|
2026
2042
|
if (Array.isArray(n) && n.includes("null")) {
|
|
2027
2043
|
let t = n.filter((e) => e !== "null");
|
|
@@ -2036,7 +2052,7 @@ var ct = () => {
|
|
|
2036
2052
|
for (let n of ["anyOf", "oneOf"]) {
|
|
2037
2053
|
let r = e[n];
|
|
2038
2054
|
if (!Array.isArray(r)) continue;
|
|
2039
|
-
let i = r.filter((e) => !
|
|
2055
|
+
let i = r.filter((e) => !Pn(e));
|
|
2040
2056
|
if (i.length !== r.length) return i.length === 1 ? {
|
|
2041
2057
|
node: Z(i[0], t),
|
|
2042
2058
|
nullable: !0
|
|
@@ -2052,14 +2068,14 @@ var ct = () => {
|
|
|
2052
2068
|
node: e,
|
|
2053
2069
|
nullable: !1
|
|
2054
2070
|
};
|
|
2055
|
-
},
|
|
2071
|
+
}, In = (e) => e.map((e) => ({
|
|
2056
2072
|
value: String(e),
|
|
2057
|
-
label:
|
|
2058
|
-
})),
|
|
2073
|
+
label: Nn(String(e))
|
|
2074
|
+
})), Ln = (e) => {
|
|
2059
2075
|
let t = e.enum;
|
|
2060
2076
|
if (Array.isArray(t) && t.length > 0) return {
|
|
2061
2077
|
widget: "select",
|
|
2062
|
-
options:
|
|
2078
|
+
options: In(t)
|
|
2063
2079
|
};
|
|
2064
2080
|
let n = e.type, r = Array.isArray(n) ? n.find((e) => e !== "null") : n, i = e.format;
|
|
2065
2081
|
switch (r) {
|
|
@@ -2070,45 +2086,45 @@ var ct = () => {
|
|
|
2070
2086
|
case "array": return { widget: "multi-select" };
|
|
2071
2087
|
default: return { widget: "custom" };
|
|
2072
2088
|
}
|
|
2073
|
-
},
|
|
2074
|
-
let { node: i, nullable: a } =
|
|
2089
|
+
}, Rn = (e, t, n) => Object.entries(e).map(([e, r]) => {
|
|
2090
|
+
let { node: i, nullable: a } = Fn(Z(r, n), n), o = Z(i, n), { widget: s, options: c } = Ln(o);
|
|
2075
2091
|
return {
|
|
2076
2092
|
name: e,
|
|
2077
|
-
label:
|
|
2093
|
+
label: Nn(e),
|
|
2078
2094
|
widget: s,
|
|
2079
2095
|
required: t.has(e),
|
|
2080
2096
|
nullable: a,
|
|
2081
2097
|
...c ? { options: c } : {},
|
|
2082
2098
|
jsonSchema: o
|
|
2083
2099
|
};
|
|
2084
|
-
}),
|
|
2100
|
+
}), zn = (e) => {
|
|
2085
2101
|
try {
|
|
2086
|
-
return
|
|
2102
|
+
return g.make(e);
|
|
2087
2103
|
} catch {
|
|
2088
2104
|
return;
|
|
2089
2105
|
}
|
|
2090
2106
|
}, Q = (e) => {
|
|
2091
|
-
let t =
|
|
2107
|
+
let t = zn(e);
|
|
2092
2108
|
if (t === void 0) return [];
|
|
2093
2109
|
let n = t.$defs ?? {}, r = Z(t, n), i = r.properties;
|
|
2094
|
-
return i ?
|
|
2095
|
-
},
|
|
2096
|
-
let t =
|
|
2110
|
+
return i ? Rn(i, new Set(Array.isArray(r.required) ? r.required : []), n) : [];
|
|
2111
|
+
}, Bn = (e) => {
|
|
2112
|
+
let t = zn(e);
|
|
2097
2113
|
if (t === void 0) return [];
|
|
2098
2114
|
let n = t.$defs ?? {}, r = Z(t, n);
|
|
2099
2115
|
if (r.type !== "array") return [];
|
|
2100
2116
|
let i = r.items;
|
|
2101
2117
|
if (!i || typeof i != "object") return [];
|
|
2102
2118
|
let a = Z(i, n), o = a.properties;
|
|
2103
|
-
return o ?
|
|
2104
|
-
},
|
|
2105
|
-
let n =
|
|
2119
|
+
return o ? Rn(o, new Set(Array.isArray(a.required) ? a.required : []), n) : [];
|
|
2120
|
+
}, Vn = (e, t) => {
|
|
2121
|
+
let n = b.decodeUnknownEither(e, { errors: "all" })(t);
|
|
2106
2122
|
if (n._tag === "Right") return {
|
|
2107
2123
|
valid: !0,
|
|
2108
2124
|
errors: {}
|
|
2109
2125
|
};
|
|
2110
2126
|
let r = {};
|
|
2111
|
-
for (let e of
|
|
2127
|
+
for (let e of E.formatErrorSync(n.left)) {
|
|
2112
2128
|
let t = e.path.length === 0 ? "" : String(e.path[0]);
|
|
2113
2129
|
t !== "" && !(t in r) && (r[t] = e.message);
|
|
2114
2130
|
}
|
|
@@ -2116,7 +2132,7 @@ var ct = () => {
|
|
|
2116
2132
|
valid: !1,
|
|
2117
2133
|
errors: r
|
|
2118
2134
|
};
|
|
2119
|
-
},
|
|
2135
|
+
}, Hn = (e, t, r) => {
|
|
2120
2136
|
let i = P(e), a = J(e, t), l = r.schema ?? i.descriptors[t]?.input;
|
|
2121
2137
|
process.env.NODE_ENV !== "production" && l === void 0 && console.error(`[@voltro/client] useFormBinding('${e}', '${t}'): no input schema. Pass options.schema, or mount the descriptor so its input reaches the client. Rendering no fields; submit skips client-side validation.`);
|
|
2122
2138
|
let u = o(() => l ? Q(l) : [], [l]), d = s(r.defaults ?? {}), [f, p] = c(d.current), [m, h] = c({}), g = n((e, t) => {
|
|
@@ -2133,7 +2149,7 @@ var ct = () => {
|
|
|
2133
2149
|
p(d.current), h({});
|
|
2134
2150
|
}, []), y = n(async () => {
|
|
2135
2151
|
if (l !== void 0) {
|
|
2136
|
-
let e =
|
|
2152
|
+
let e = Vn(l, f);
|
|
2137
2153
|
if (h(e.errors), !e.valid) return;
|
|
2138
2154
|
}
|
|
2139
2155
|
return a.mutate(f);
|
|
@@ -2146,7 +2162,7 @@ var ct = () => {
|
|
|
2146
2162
|
fields: u,
|
|
2147
2163
|
values: f,
|
|
2148
2164
|
errors: m,
|
|
2149
|
-
isValid: o(() => l === void 0 ||
|
|
2165
|
+
isValid: o(() => l === void 0 || Vn(l, f).valid, [l, f]),
|
|
2150
2166
|
pending: a.pending,
|
|
2151
2167
|
submitError: a.error,
|
|
2152
2168
|
data: a.data,
|
|
@@ -2155,13 +2171,13 @@ var ct = () => {
|
|
|
2155
2171
|
reset: v,
|
|
2156
2172
|
submit: y
|
|
2157
2173
|
};
|
|
2158
|
-
},
|
|
2174
|
+
}, Un = (e, t, n) => e.map((e) => {
|
|
2159
2175
|
let r = String(e[n] ?? ""), i = e[t];
|
|
2160
2176
|
return {
|
|
2161
2177
|
value: r,
|
|
2162
2178
|
label: i == null ? r : String(i)
|
|
2163
2179
|
};
|
|
2164
|
-
}),
|
|
2180
|
+
}), Wn = (e, t, r = {}) => {
|
|
2165
2181
|
let i = r.debounceMs ?? 200, s = r.labelField ?? "name", l = r.valueField ?? "id", u = r.input ?? ((e) => ({ q: e })), [d, f] = c(r.initialTerm ?? ""), [p, m] = c(d);
|
|
2166
2182
|
a(() => {
|
|
2167
2183
|
if (d === p) return;
|
|
@@ -2172,7 +2188,7 @@ var ct = () => {
|
|
|
2172
2188
|
p,
|
|
2173
2189
|
i
|
|
2174
2190
|
]);
|
|
2175
|
-
let h = r.skipUntilTerm === !0 && p.trim() === "", g = U(e, t, o(() => u(p), [u, p]), { skip: h }), _ = o(() =>
|
|
2191
|
+
let h = r.skipUntilTerm === !0 && p.trim() === "", g = U(e, t, o(() => u(p), [u, p]), { skip: h }), _ = o(() => Un(g.data ?? [], s, l), [
|
|
2176
2192
|
g.data,
|
|
2177
2193
|
s,
|
|
2178
2194
|
l
|
|
@@ -2183,13 +2199,13 @@ var ct = () => {
|
|
|
2183
2199
|
term: d,
|
|
2184
2200
|
search: v
|
|
2185
2201
|
};
|
|
2186
|
-
},
|
|
2202
|
+
}, Gn = (e, t) => e === t ? 0 : e == null ? 1 : t == null || e < t ? -1 : 1, Kn = (e, t, r = {}) => {
|
|
2187
2203
|
let i = P(e), [a, s] = c(r.pageSize), l = U(e, t, o(() => a === void 0 ? r.input ?? {} : {
|
|
2188
2204
|
...r.input,
|
|
2189
2205
|
limit: a
|
|
2190
2206
|
}, [r.input, a])), u = i.descriptors[t]?.output, d = n(() => {
|
|
2191
2207
|
r.pageSize !== void 0 && s((e) => (e ?? r.pageSize) + r.pageSize);
|
|
2192
|
-
}, [r.pageSize]), f = o(() => r.columns ?? (u === void 0 ? [] :
|
|
2208
|
+
}, [r.pageSize]), f = o(() => r.columns ?? (u === void 0 ? [] : Bn(u)), [r.columns, u]), [p, m] = c(r.initialSort), h = n((e) => {
|
|
2193
2209
|
m((t) => t?.column === e ? {
|
|
2194
2210
|
column: e,
|
|
2195
2211
|
direction: t.direction === "asc" ? "desc" : "asc"
|
|
@@ -2204,7 +2220,7 @@ var ct = () => {
|
|
|
2204
2220
|
let e = l.data ?? [];
|
|
2205
2221
|
if (p === void 0) return e;
|
|
2206
2222
|
let t = p.direction === "asc" ? 1 : -1;
|
|
2207
|
-
return [...e].sort((e, n) =>
|
|
2223
|
+
return [...e].sort((e, n) => Gn(e[p.column], n[p.column]) * t);
|
|
2208
2224
|
}, [l.data, p]),
|
|
2209
2225
|
loading: l.data === void 0,
|
|
2210
2226
|
error: l.error,
|
|
@@ -2213,13 +2229,13 @@ var ct = () => {
|
|
|
2213
2229
|
loadMore: d,
|
|
2214
2230
|
hasMore: a !== void 0 && (l.data?.length ?? 0) >= a
|
|
2215
2231
|
};
|
|
2216
|
-
},
|
|
2232
|
+
}, qn = (e, t, n, r) => {
|
|
2217
2233
|
let i = e.replace(/\/$/, ""), a = new URLSearchParams({
|
|
2218
2234
|
table: t,
|
|
2219
2235
|
id: n
|
|
2220
2236
|
});
|
|
2221
2237
|
return r !== void 0 && a.set("column", r), `${i}/_voltro/inspect/provenance?${a.toString()}`;
|
|
2222
|
-
},
|
|
2238
|
+
}, Jn = qn, Yn = (e, t, n, r) => {
|
|
2223
2239
|
let { inspectBaseUrl: i } = P(e), [o, s] = c({
|
|
2224
2240
|
data: void 0,
|
|
2225
2241
|
loading: !0,
|
|
@@ -2232,7 +2248,7 @@ var ct = () => {
|
|
|
2232
2248
|
loading: !0,
|
|
2233
2249
|
error: void 0
|
|
2234
2250
|
});
|
|
2235
|
-
let a =
|
|
2251
|
+
let a = qn(i ?? "", t, n, r);
|
|
2236
2252
|
return fetch(a).then(async (e) => {
|
|
2237
2253
|
if (!e.ok) throw Error(`provenance fetch failed: HTTP ${e.status}`);
|
|
2238
2254
|
return await e.json();
|
|
@@ -2258,7 +2274,7 @@ var ct = () => {
|
|
|
2258
2274
|
n,
|
|
2259
2275
|
r
|
|
2260
2276
|
]), o;
|
|
2261
|
-
},
|
|
2277
|
+
}, Xn = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, Zn = (e) => {
|
|
2262
2278
|
let { inspectBaseUrl: t } = P(e), [n, r] = c({
|
|
2263
2279
|
manifest: void 0,
|
|
2264
2280
|
loading: !0,
|
|
@@ -2270,7 +2286,7 @@ var ct = () => {
|
|
|
2270
2286
|
manifest: void 0,
|
|
2271
2287
|
loading: !0,
|
|
2272
2288
|
error: void 0
|
|
2273
|
-
}), fetch(
|
|
2289
|
+
}), fetch(Xn(t ?? "")).then(async (e) => {
|
|
2274
2290
|
if (!e.ok) throw Error(`manifest fetch failed: HTTP ${e.status}`);
|
|
2275
2291
|
return await e.json();
|
|
2276
2292
|
}).then((t) => {
|
|
@@ -2289,8 +2305,8 @@ var ct = () => {
|
|
|
2289
2305
|
e = !0;
|
|
2290
2306
|
};
|
|
2291
2307
|
}, [e, t]), n;
|
|
2292
|
-
},
|
|
2293
|
-
let n = e.procedures.find((e) => e.kind === "query" &&
|
|
2308
|
+
}, Qn = (e, t) => Array.isArray(e) ? e.includes(t) : e === t, $n = (e, t, n) => e.targets?.some((e) => e.table === t && e.op === n) ?? !1, er = (e) => e.tables.filter((e) => !e.framework).map((t) => {
|
|
2309
|
+
let n = e.procedures.find((e) => e.kind === "query" && Qn(e.source, t.name)), r = e.procedures.find((e) => e.kind === "mutation" && $n(e, t.name, "insert")), i = e.procedures.find((e) => e.kind === "mutation" && $n(e, t.name, "update")), a = e.procedures.find((e) => e.kind === "mutation" && $n(e, t.name, "delete"));
|
|
2294
2310
|
return {
|
|
2295
2311
|
table: t.name,
|
|
2296
2312
|
columns: t.columns,
|
|
@@ -2303,7 +2319,7 @@ var ct = () => {
|
|
|
2303
2319
|
writeScope: `${t.name}:write`,
|
|
2304
2320
|
deleteScope: `${t.name}:delete`
|
|
2305
2321
|
};
|
|
2306
|
-
}),
|
|
2322
|
+
}), tr = (e) => {
|
|
2307
2323
|
let [t, r] = c([]), [i, a] = c([]), s = n((e) => {
|
|
2308
2324
|
r((t) => [...t, e]), a([]);
|
|
2309
2325
|
}, []), l = n(async () => {
|
|
@@ -2331,8 +2347,8 @@ var ct = () => {
|
|
|
2331
2347
|
l,
|
|
2332
2348
|
u
|
|
2333
2349
|
]);
|
|
2334
|
-
},
|
|
2335
|
-
let r = t?.limit, { data: i } = U(e,
|
|
2350
|
+
}, nr = "__voltro.undo.log", rr = "__voltro.undo.apply", ir = "__voltro.undo.redo", ar = (e, t) => {
|
|
2351
|
+
let r = t?.limit, { data: i } = U(e, nr, r === void 0 ? {} : { limit: r }), a = J(e, rr), o = J(e, ir), s = i ?? [], c = s.find((e) => !e.undone && !e.crossesAction), l = s.find((e) => e.undone), u = n(async (e) => {
|
|
2336
2352
|
await a.mutate({ invocationId: e });
|
|
2337
2353
|
}, [a]), d = n(async (e) => {
|
|
2338
2354
|
await o.mutate({ invocationId: e });
|
|
@@ -2351,13 +2367,13 @@ var ct = () => {
|
|
|
2351
2367
|
undoLast: f,
|
|
2352
2368
|
redoLast: p
|
|
2353
2369
|
};
|
|
2354
|
-
},
|
|
2370
|
+
}, or = (e, t) => ({
|
|
2355
2371
|
name: e,
|
|
2356
2372
|
map: t
|
|
2357
|
-
}), $ = (e, t) => e === void 0 ? null : typeof e == "string" ? { event: e } : e(t),
|
|
2373
|
+
}), $ = (e, t) => e === void 0 ? null : typeof e == "string" ? { event: e } : e(t), sr = /* @__PURE__ */ new Set(["onMount", "onUnmount"]), cr = (e, t, n) => {
|
|
2358
2374
|
let r = { ...t };
|
|
2359
2375
|
for (let [i, a] of Object.entries(e.map)) {
|
|
2360
|
-
if (
|
|
2376
|
+
if (sr.has(i) || a === void 0) continue;
|
|
2361
2377
|
let e = t[i];
|
|
2362
2378
|
r[i] = (...r) => {
|
|
2363
2379
|
let i = $(a, t);
|
|
@@ -2365,7 +2381,7 @@ var ct = () => {
|
|
|
2365
2381
|
};
|
|
2366
2382
|
}
|
|
2367
2383
|
return r;
|
|
2368
|
-
},
|
|
2384
|
+
}, lr = (e, t, n) => {
|
|
2369
2385
|
let r = s({
|
|
2370
2386
|
spec: e,
|
|
2371
2387
|
props: t,
|
|
@@ -2381,45 +2397,45 @@ var ct = () => {
|
|
|
2381
2397
|
let e = r.current, t = $(e.spec.map.onUnmount, e.props);
|
|
2382
2398
|
t !== null && e.sink(t);
|
|
2383
2399
|
};
|
|
2384
|
-
}, []), o(() =>
|
|
2400
|
+
}, []), o(() => cr(e, t, n), [
|
|
2385
2401
|
e,
|
|
2386
2402
|
t,
|
|
2387
2403
|
n
|
|
2388
2404
|
]);
|
|
2389
|
-
},
|
|
2405
|
+
}, ur = (e, t) => {
|
|
2390
2406
|
let n = P(e).descriptors[t]?.input;
|
|
2391
2407
|
return o(() => n === void 0 ? [] : Q(n), [n]);
|
|
2392
|
-
},
|
|
2408
|
+
}, dr = (e, t) => {
|
|
2393
2409
|
let n = P(e).descriptors[t]?.output;
|
|
2394
|
-
return o(() => n === void 0 ? [] :
|
|
2395
|
-
},
|
|
2410
|
+
return o(() => n === void 0 ? [] : Bn(n), [n]);
|
|
2411
|
+
}, fr = (e, t) => {
|
|
2396
2412
|
if (e === t) return !0;
|
|
2397
2413
|
if (e.length !== t.length) return !1;
|
|
2398
2414
|
for (let n = 0; n < e.length; n += 1) if (!Object.is(e[n], t[n])) return !1;
|
|
2399
2415
|
return !0;
|
|
2400
|
-
},
|
|
2401
|
-
let n = s(null), r =
|
|
2402
|
-
return (n.current === null || !
|
|
2416
|
+
}, pr = (e) => Object.keys(e).sort().map((t) => e[t]), mr = (e, t) => {
|
|
2417
|
+
let n = s(null), r = pr(e);
|
|
2418
|
+
return (n.current === null || !fr(n.current.key, r)) && (n.current = {
|
|
2403
2419
|
key: r,
|
|
2404
2420
|
value: t(e)
|
|
2405
2421
|
}), n.current.value;
|
|
2406
|
-
},
|
|
2407
|
-
function
|
|
2408
|
-
return t(
|
|
2422
|
+
}, hr = "admin:full", gr = (e, t) => e.includes("admin:full") ? !0 : (typeof t == "string" ? [t] : t).every((t) => e.includes(t)), _r = (e, t) => t.length === 0 || e.includes("admin:full") ? !0 : t.some((t) => e.includes(t)), vr = e({ scopes: [] });
|
|
2423
|
+
function yr(e) {
|
|
2424
|
+
return t(vr.Provider, { value: { scopes: e.scopes } }, e.children);
|
|
2409
2425
|
}
|
|
2410
|
-
var
|
|
2426
|
+
var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes, e), Cr = (e, t, n, r = {}) => {
|
|
2411
2427
|
let i = U(e, t, { ...n }, r);
|
|
2412
2428
|
return o(() => ({
|
|
2413
2429
|
allowed: i.data?.allowed === !0,
|
|
2414
2430
|
pending: i.data === void 0
|
|
2415
2431
|
}), [i.data]);
|
|
2416
|
-
},
|
|
2432
|
+
}, wr = (e, t, n, r = {}) => {
|
|
2417
2433
|
let i = U(e, t, { ...n }, r);
|
|
2418
2434
|
return o(() => ({
|
|
2419
2435
|
allowedIds: new Set(i.data?.allowedIds ?? []),
|
|
2420
2436
|
pending: i.data === void 0
|
|
2421
2437
|
}), [i.data]);
|
|
2422
|
-
},
|
|
2438
|
+
}, Tr = (e) => {
|
|
2423
2439
|
switch (e) {
|
|
2424
2440
|
case "select":
|
|
2425
2441
|
case "radio":
|
|
@@ -2435,25 +2451,25 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2435
2451
|
case "switch": return "boolean";
|
|
2436
2452
|
default: return null;
|
|
2437
2453
|
}
|
|
2438
|
-
},
|
|
2439
|
-
let t =
|
|
2454
|
+
}, Er = (e) => Q(e).map((e) => {
|
|
2455
|
+
let t = Tr(e.widget);
|
|
2440
2456
|
return t === null ? null : {
|
|
2441
2457
|
name: e.name,
|
|
2442
2458
|
label: e.label,
|
|
2443
2459
|
kind: t,
|
|
2444
2460
|
...e.options ? { options: e.options } : {}
|
|
2445
2461
|
};
|
|
2446
|
-
}).filter((e) => e !== null),
|
|
2462
|
+
}).filter((e) => e !== null), Dr = (e) => {
|
|
2447
2463
|
let t = {};
|
|
2448
2464
|
for (let [n, r] of Object.entries(e)) r === void 0 || r === "" || Array.isArray(r) && r.length === 0 || (t[n] = r);
|
|
2449
2465
|
return t;
|
|
2450
|
-
},
|
|
2451
|
-
let i = P(e).descriptors[t]?.input, a = o(() => i === void 0 ? [] :
|
|
2452
|
-
l((n) =>
|
|
2466
|
+
}, Or = (e, t, r = {}) => {
|
|
2467
|
+
let i = P(e).descriptors[t]?.input, a = o(() => i === void 0 ? [] : Er(i), [i]), [s, l] = c(r.initial ?? {}), u = n((e, t) => {
|
|
2468
|
+
l((n) => Dr({
|
|
2453
2469
|
...n,
|
|
2454
2470
|
[e]: t
|
|
2455
2471
|
}));
|
|
2456
|
-
}, []), d = n(() => l({}), []), f = U(e, t, o(() =>
|
|
2472
|
+
}, []), d = n(() => l({}), []), f = U(e, t, o(() => Dr(s), [s]));
|
|
2457
2473
|
return {
|
|
2458
2474
|
filters: a,
|
|
2459
2475
|
values: s,
|
|
@@ -2464,20 +2480,20 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2464
2480
|
loading: f.data === void 0,
|
|
2465
2481
|
error: f.error
|
|
2466
2482
|
};
|
|
2467
|
-
},
|
|
2483
|
+
}, kr = (e, t, n = {}) => {
|
|
2468
2484
|
let r = U(e, t, n), i = r.data;
|
|
2469
2485
|
return {
|
|
2470
2486
|
record: Array.isArray(i) ? i[0] : i,
|
|
2471
2487
|
loading: i === void 0,
|
|
2472
2488
|
error: r.error
|
|
2473
2489
|
};
|
|
2474
|
-
},
|
|
2490
|
+
}, Ar = (e, t = 300) => {
|
|
2475
2491
|
let [n, r] = c(e);
|
|
2476
2492
|
return a(() => {
|
|
2477
2493
|
let n = setTimeout(() => r(e), t);
|
|
2478
2494
|
return () => clearTimeout(n);
|
|
2479
2495
|
}, [e, t]), n;
|
|
2480
|
-
},
|
|
2496
|
+
}, jr = (e) => {
|
|
2481
2497
|
let { value: t, debouncedValue: n, data: r, interpret: i, skipEmpty: a = !0 } = e;
|
|
2482
2498
|
if (a && t.trim() === "") return {
|
|
2483
2499
|
status: "idle",
|
|
@@ -2495,39 +2511,39 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2495
2511
|
valid: o.valid,
|
|
2496
2512
|
message: o.message
|
|
2497
2513
|
};
|
|
2498
|
-
},
|
|
2499
|
-
let { input: i, interpret: a, debounceMs: s = 300, skipEmpty: c = !0 } = r, l =
|
|
2500
|
-
return
|
|
2514
|
+
}, Mr = (e, t, n, r) => {
|
|
2515
|
+
let { input: i, interpret: a, debounceMs: s = 300, skipEmpty: c = !0 } = r, l = Ar(n, s), u = c && l.trim() === "", d = U(e, t, o(() => i ? i(l) : { value: l }, [i, l]), { skip: u });
|
|
2516
|
+
return jr({
|
|
2501
2517
|
value: n,
|
|
2502
2518
|
debouncedValue: l,
|
|
2503
2519
|
data: u ? null : d.data,
|
|
2504
2520
|
interpret: a,
|
|
2505
2521
|
skipEmpty: c
|
|
2506
2522
|
});
|
|
2507
|
-
},
|
|
2523
|
+
}, Nr = (e, t) => ({
|
|
2508
2524
|
name: e,
|
|
2509
2525
|
payload: t
|
|
2510
|
-
}),
|
|
2511
|
-
let n =
|
|
2526
|
+
}), Pr = (e, t) => {
|
|
2527
|
+
let n = b.decodeUnknownEither(e.payload, { errors: "all" })(t);
|
|
2512
2528
|
if (n._tag === "Right") return {
|
|
2513
2529
|
valid: !0,
|
|
2514
2530
|
errors: {}
|
|
2515
2531
|
};
|
|
2516
2532
|
let r = {};
|
|
2517
|
-
for (let e of
|
|
2533
|
+
for (let e of E.formatErrorSync(n.left)) r[e.path.join(".") || "(root)"] = e.message;
|
|
2518
2534
|
return {
|
|
2519
2535
|
valid: !1,
|
|
2520
2536
|
errors: r
|
|
2521
2537
|
};
|
|
2522
|
-
},
|
|
2538
|
+
}, Fr = (e) => {
|
|
2523
2539
|
let t = new Map(e.map((e) => [e.name, e]));
|
|
2524
2540
|
return {
|
|
2525
2541
|
names: [...t.keys()].sort(),
|
|
2526
2542
|
get: (e) => t.get(e),
|
|
2527
2543
|
events: e
|
|
2528
2544
|
};
|
|
2529
|
-
},
|
|
2530
|
-
let n =
|
|
2545
|
+
}, Ir = (e, t) => {
|
|
2546
|
+
let n = Fr(e);
|
|
2531
2547
|
return {
|
|
2532
2548
|
track: (e, r) => {
|
|
2533
2549
|
let i = n.get(e);
|
|
@@ -2536,7 +2552,7 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2536
2552
|
return;
|
|
2537
2553
|
}
|
|
2538
2554
|
if (process.env.NODE_ENV !== "production") {
|
|
2539
|
-
let t =
|
|
2555
|
+
let t = Pr(i, r);
|
|
2540
2556
|
t.valid || console.error(`[@voltro/client] analytics.track('${e}'): payload failed its schema`, t.errors);
|
|
2541
2557
|
}
|
|
2542
2558
|
t({
|
|
@@ -2547,7 +2563,7 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2547
2563
|
names: n.names,
|
|
2548
2564
|
catalog: n
|
|
2549
2565
|
};
|
|
2550
|
-
},
|
|
2566
|
+
}, Lr = (e, t) => {
|
|
2551
2567
|
let r = Y(e, t);
|
|
2552
2568
|
return {
|
|
2553
2569
|
preview: n((e) => r.run(e), [r]),
|
|
@@ -2555,34 +2571,34 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2555
2571
|
pending: r.pending,
|
|
2556
2572
|
error: r.error
|
|
2557
2573
|
};
|
|
2558
|
-
},
|
|
2574
|
+
}, Rr = (e, t, n, r) => [...e, {
|
|
2559
2575
|
id: t,
|
|
2560
2576
|
tag: n,
|
|
2561
2577
|
input: r,
|
|
2562
2578
|
status: "pending",
|
|
2563
2579
|
attempts: 0
|
|
2564
|
-
}],
|
|
2580
|
+
}], zr = (e, t, n) => e.map((e) => e.id === t ? {
|
|
2565
2581
|
...e,
|
|
2566
2582
|
...n
|
|
2567
|
-
} : e),
|
|
2583
|
+
} : e), Br = (e, t) => zr(e, t, { status: "sent" }), Vr = (e, t, n) => e.map((e) => e.id === t ? {
|
|
2568
2584
|
...e,
|
|
2569
2585
|
status: "failed",
|
|
2570
2586
|
error: n,
|
|
2571
2587
|
attempts: e.attempts + 1
|
|
2572
|
-
} : e),
|
|
2588
|
+
} : e), Hr = (e, t, n) => zr(e, t, {
|
|
2573
2589
|
status: "conflict",
|
|
2574
2590
|
error: n
|
|
2575
|
-
}),
|
|
2591
|
+
}), Ur = (e) => e.filter((e) => e.status !== "sent"), Wr = (e) => {
|
|
2576
2592
|
let t = [];
|
|
2577
2593
|
for (let n of e) {
|
|
2578
2594
|
if (n.status === "conflict") break;
|
|
2579
2595
|
(n.status === "pending" || n.status === "failed") && t.push(n);
|
|
2580
2596
|
}
|
|
2581
2597
|
return t;
|
|
2582
|
-
},
|
|
2598
|
+
}, Gr = (e) => {
|
|
2583
2599
|
let t = e;
|
|
2584
2600
|
return t?.conflict === !0 || t?._tag === "UndoBoundaryError" && t?.boundary === "conflict";
|
|
2585
|
-
},
|
|
2601
|
+
}, Kr = (e) => {
|
|
2586
2602
|
let [t, n] = c(e ?? (typeof navigator < "u" ? navigator.onLine : !0));
|
|
2587
2603
|
return a(() => {
|
|
2588
2604
|
if (e !== void 0) {
|
|
@@ -2595,21 +2611,21 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2595
2611
|
window.removeEventListener("online", t), window.removeEventListener("offline", r);
|
|
2596
2612
|
};
|
|
2597
2613
|
}, [e]), t;
|
|
2598
|
-
},
|
|
2599
|
-
let { send: t, isConflict: r =
|
|
2614
|
+
}, qr = (e) => {
|
|
2615
|
+
let { send: t, isConflict: r = Gr, idFor: i } = e, [o, l] = c([]), u = Kr(e.online), d = s(o);
|
|
2600
2616
|
d.current = o;
|
|
2601
2617
|
let f = s(0), p = n((e, t) => {
|
|
2602
2618
|
let n = i?.() ?? `obx_${f.current++}_${e}`;
|
|
2603
|
-
l((r) =>
|
|
2619
|
+
l((r) => Rr(r, n, e, t));
|
|
2604
2620
|
}, [i]), m = n(async () => {
|
|
2605
|
-
for (let e of
|
|
2606
|
-
await t(e), l((t) =>
|
|
2621
|
+
for (let e of Wr(d.current)) try {
|
|
2622
|
+
await t(e), l((t) => Br(t, e.id));
|
|
2607
2623
|
} catch (t) {
|
|
2608
2624
|
if (r(t)) {
|
|
2609
|
-
l((n) =>
|
|
2625
|
+
l((n) => Hr(n, e.id, t));
|
|
2610
2626
|
break;
|
|
2611
2627
|
}
|
|
2612
|
-
l((n) =>
|
|
2628
|
+
l((n) => Vr(n, e.id, t));
|
|
2613
2629
|
}
|
|
2614
2630
|
}, [t, r]);
|
|
2615
2631
|
return a(() => {
|
|
@@ -2622,7 +2638,7 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2622
2638
|
pending: o.filter((e) => e.status === "pending" || e.status === "failed").length,
|
|
2623
2639
|
conflicts: o.filter((e) => e.status === "conflict")
|
|
2624
2640
|
};
|
|
2625
|
-
},
|
|
2641
|
+
}, Jr = (e) => {
|
|
2626
2642
|
let { scrollTop: t, viewportHeight: n, rowHeight: r, overscan: i = 5, total: a } = e, o = r > 0 ? r : 1, s = Math.max(0, Math.floor(t / o)), c = Math.ceil(n / o), l = Math.max(0, s - i), u = s + c + i, d = a === void 0 ? u : Math.min(u, a);
|
|
2627
2643
|
return {
|
|
2628
2644
|
startIndex: l,
|
|
@@ -2632,8 +2648,8 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2632
2648
|
topSpacer: l * r,
|
|
2633
2649
|
bottomSpacer: a === void 0 ? 0 : Math.max(0, (a - d) * r)
|
|
2634
2650
|
};
|
|
2635
|
-
},
|
|
2636
|
-
let { rowHeight: i, viewportHeight: a, overscan: s, total: l, input: u } = r, [d, f] = c(0), p = o(() =>
|
|
2651
|
+
}, Yr = (e, t, r) => {
|
|
2652
|
+
let { rowHeight: i, viewportHeight: a, overscan: s, total: l, input: u } = r, [d, f] = c(0), p = o(() => Jr({
|
|
2637
2653
|
scrollTop: d,
|
|
2638
2654
|
viewportHeight: a,
|
|
2639
2655
|
rowHeight: i,
|
|
@@ -2665,8 +2681,8 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2665
2681
|
loading: m.data === void 0,
|
|
2666
2682
|
error: m.error
|
|
2667
2683
|
};
|
|
2668
|
-
},
|
|
2669
|
-
let { errorBus: t } = P(e), [r, i] = c(
|
|
2684
|
+
}, Xr = () => typeof navigator > "u" || navigator.onLine, Zr = (e) => {
|
|
2685
|
+
let { errorBus: t } = P(e), [r, i] = c(Xr), [o, l] = c(0), [u, d] = c(void 0), f = s(!0);
|
|
2670
2686
|
a(() => (f.current = !0, () => {
|
|
2671
2687
|
f.current = !1;
|
|
2672
2688
|
}), []), a(() => {
|
|
@@ -2692,7 +2708,7 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2692
2708
|
lastFailureAt: u,
|
|
2693
2709
|
reportSuccess: p
|
|
2694
2710
|
};
|
|
2695
|
-
},
|
|
2711
|
+
}, Qr = "__voltro.connections.list", $r = "__voltro.connections.start", ei = "__voltro.connections.submitToken", ti = "__voltro.connections.disconnect", ni = {
|
|
2696
2712
|
connectionId: "",
|
|
2697
2713
|
kind: "oauth2",
|
|
2698
2714
|
label: "",
|
|
@@ -2703,14 +2719,14 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2703
2719
|
expiresAt: null,
|
|
2704
2720
|
lastError: null,
|
|
2705
2721
|
connectedAt: null
|
|
2706
|
-
},
|
|
2722
|
+
}, ri = (e, t) => {
|
|
2707
2723
|
if (t === "redirect") {
|
|
2708
2724
|
globalThis.location.assign(e);
|
|
2709
2725
|
return;
|
|
2710
2726
|
}
|
|
2711
2727
|
globalThis.open(e, "voltro-connect", "width=620,height=760,menubar=no,toolbar=no") === null && globalThis.location.assign(e);
|
|
2712
|
-
},
|
|
2713
|
-
let { data: t } = U(e,
|
|
2728
|
+
}, ii = (e) => {
|
|
2729
|
+
let { data: t } = U(e, Qr, {}), r = Y(e, $r), i = J(e, ei), a = J(e, ti), o = t ?? [], s = r.pending || i.pending || a.pending, c = n((e) => ({
|
|
2714
2730
|
...e,
|
|
2715
2731
|
connected: e.status === "connected",
|
|
2716
2732
|
needsAttention: e.status === "expired" || e.status === "revoked" || e.status === "error",
|
|
@@ -2718,7 +2734,7 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2718
2734
|
connect: async (t) => {
|
|
2719
2735
|
if (e.kind !== "oauth2") throw Error(`connection "${e.connectionId}" is a personal-access-token connection — call submitToken(token), not connect().`);
|
|
2720
2736
|
let n = t?.redirectTo ?? `${globalThis.location.pathname}${globalThis.location.search}`;
|
|
2721
|
-
|
|
2737
|
+
ri((await r.run({
|
|
2722
2738
|
connectionId: e.connectionId,
|
|
2723
2739
|
redirectTo: n
|
|
2724
2740
|
})).authorizeUrl, t?.mode);
|
|
@@ -2748,10 +2764,10 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2748
2764
|
get: l,
|
|
2749
2765
|
pending: s
|
|
2750
2766
|
};
|
|
2751
|
-
},
|
|
2752
|
-
let n =
|
|
2767
|
+
}, ai = (e, t) => {
|
|
2768
|
+
let n = ii(e), r = n.get(t);
|
|
2753
2769
|
return o(() => r === void 0 ? {
|
|
2754
|
-
...
|
|
2770
|
+
...ni,
|
|
2755
2771
|
connectionId: t,
|
|
2756
2772
|
label: t,
|
|
2757
2773
|
connected: !1,
|
|
@@ -2776,6 +2792,6 @@ var mr = () => r(fr), hr = (e) => ur(mr().scopes, e), gr = (e) => dr(mr().scopes
|
|
|
2776
2792
|
n.loading,
|
|
2777
2793
|
n.pending
|
|
2778
2794
|
]);
|
|
2779
|
-
},
|
|
2795
|
+
}, oi = "framework-client";
|
|
2780
2796
|
//#endregion
|
|
2781
|
-
export {
|
|
2797
|
+
export { hr as ADMIN_SCOPE, oi as CLIENT_NAME, Qr as CONNECTIONS_LIST_TAG, ti as CONNECTION_DISCONNECT_TAG, $r as CONNECTION_START_TAG, ei as CONNECTION_SUBMIT_TOKEN_TAG, he as FrameworkRuntimesContext, Ce as FrameworkRuntimesProvider, pe as LoadingSubscriptionCache, yr as PermissionProvider, me as RpcErrorBus, A as SubscriptionCache, rr as UNDO_APPLY_TAG, nr as UNDO_LOG_TAG, ir as UNDO_REDO_TAG, be as _resetFrameworkRuntimesWarning, st as applyPreloadSeeds, Qe as applyStoreSeeds, Se as buildApiRuntime, gr as canCall, _r as canCallAny, wt as clearMutations, Ur as clearSent, Fe as clearStoreHistory, Jr as computeWindow, Ir as createAnalytics, Nr as defineEvent, qe as defineStore, or as defineTracking, Ke as definedStores, er as deriveEntityAdmins, Rr as enqueueEntry, Fr as eventCatalog, Er as filtersFromSchema, Mt as freshIdempotencyKey, Dt as getMutationNotifier, St as getMutations, F as isUnresolvedApi, tt as makePreloadSeedBag, Ye as makeStoreSeedBag, Xn as manifestUrl, Hr as markConflict, Vr as markFailed, Br as markSent, Jn as provenanceUrl, On as publishClientError, D as publishClientTrace, ct as readPreloadedSnapshot, Wr as replayable, An as reportClientError, lt as resetPreloadSeeds, Je as resetStoreRegistryForTests, H as resolveByTag, $ as resolveTrackingEvent, vn as resumableConsumeProgram, Un as rowsToOptions, ht as runSequence, Bn as schemaToColumns, Q as schemaToFields, ot as seedPreloadedSubscription, Ze as seedStore, mt as sequence, Et as setMutationNotifier, rt as setPreloadSeedResolver, Xe as setStoreSeedResolver, K as settleMutation, I as shallow, fr as shallowArrayEqual, pr as sourceValues, _e as ssrClientProxy, ve as ssrStubHandle, O as stableKey, xt as startMutation, Ne as storeHistory, kn as subscribeClientErrors, re as subscribeClientTraces, Ct as subscribeMutations, Pe as subscribeStoreHistory, Ie as travelToStoreState, Y as useAction, wn as useAgent, Cn as useAgentChat, _n as useAgentStream, Mr as useAsyncValidation, xr as useCan, Sr as useCanAny, Zn as useCapabilityManifest, ai as useConnection, Zr as useConnectionStatus, ii as useConnections, Tn as useDataCopilot, Kn as useDataTable, Ar as useDebounced, mr as useDerived, pt as useEvent, Hn as useFormBinding, ur as useFormSkeleton, P as useFrameworkApi, xe as useFrameworkRuntimes, J as useMutation, jn as useOnRpcError, qr as useOutbox, br as usePermissions, ut as usePreloadedSubscription, Lr as usePreview, Yn as useProvenance, Wn as useQueryField, Or as useQueryFilters, kr as useRecord, En as useRefreshSubscriptions, Cr as useResourceCan, wr as useResourceCans, bn as useResumableAgentStream, gt as useSequence, U as useSubscription, dr as useTableSkeleton, lr as useTracking, tr as useUndo, ar as useUndoLog, $t as useUpload, Yr as useWindowedSubscription, en as useWorkflow, ln as useWorkflowDomainEvents, un as useWorkflowEventDeliveries, cn as useWorkflowEvents, rn as useWorkflowRun, sn as useWorkflowRunEvents, gn as useWorkflowRunState, on as useWorkflowRunSteps, an as useWorkflowRuns, tn as useWorkflowSignal, nn as useWorkflowUpdate, Pr as validateEventPayload, Vn as validateFields, jr as validationStatus, Nt as withIdempotencyKey, cr as wrapTrackedCallbacks };
|