@voltro/client 0.28.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +655 -0
- package/dist/index.d.ts +117 -7
- package/dist/index.js +512 -460
- 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,21 +392,21 @@ 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
|
});
|
|
383
|
-
},
|
|
399
|
+
}, I = (e, t) => {
|
|
384
400
|
if (Object.is(e, t)) return !0;
|
|
385
401
|
if (typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
|
|
386
402
|
let n = Object.keys(e), r = Object.keys(t);
|
|
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();
|
|
@@ -421,20 +437,20 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
421
437
|
if (typeof i?.then == "function") throw a === 1 && o !== void 0 && (n = o), --a, a === 0 && (o = void 0, s = void 0), Error(`defineStore: batch('${e}') was given an async function. A batch is synchronous — everything after the first await would land outside it. Await the work first, then batch the writes: \`const r = await load(); store.batch('${e}', () => { … })\`.`);
|
|
422
438
|
if (--a, a > 0) return;
|
|
423
439
|
let l = o, u = s;
|
|
424
|
-
o = void 0, s = void 0, !
|
|
440
|
+
o = void 0, s = void 0, !I(l, n) && (t(l, n, u), c());
|
|
425
441
|
},
|
|
426
442
|
set: (e, r) => {
|
|
427
443
|
let i = typeof e == "function" ? e(n) : {
|
|
428
444
|
...n,
|
|
429
445
|
...e
|
|
430
446
|
};
|
|
431
|
-
if (
|
|
447
|
+
if (I(i, n)) return;
|
|
432
448
|
let o = n;
|
|
433
449
|
n = i, !(a > 0) && (t(o, i, r), c());
|
|
434
450
|
},
|
|
435
451
|
reset: () => {
|
|
436
452
|
let r = e();
|
|
437
|
-
if (
|
|
453
|
+
if (I(r, n)) return;
|
|
438
454
|
let i = n;
|
|
439
455
|
n = r, !(a > 0) && (t(i, r, "reset"), c());
|
|
440
456
|
},
|
|
@@ -442,47 +458,47 @@ var w = /* @__PURE__ */ new Set(), T = (e) => {
|
|
|
442
458
|
r.delete(e);
|
|
443
459
|
})
|
|
444
460
|
};
|
|
445
|
-
},
|
|
446
|
-
|
|
447
|
-
}),
|
|
448
|
-
|
|
449
|
-
},
|
|
450
|
-
let n =
|
|
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) => {
|
|
466
|
+
let n = L[e];
|
|
451
467
|
if (n === void 0) return !1;
|
|
452
|
-
let r =
|
|
468
|
+
let r = V.get(n.store);
|
|
453
469
|
if (r === void 0) return !1;
|
|
454
470
|
let i = t === "before" ? n.prev : n.next;
|
|
455
|
-
|
|
471
|
+
B = !0;
|
|
456
472
|
try {
|
|
457
473
|
r.set(() => i, n.key, `travel:${t}`);
|
|
458
474
|
} finally {
|
|
459
|
-
|
|
475
|
+
B = !1;
|
|
460
476
|
}
|
|
461
477
|
return !0;
|
|
462
|
-
},
|
|
463
|
-
|
|
464
|
-
for (let e of [...
|
|
465
|
-
},
|
|
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,28 +534,28 @@ var Be = () => {
|
|
|
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,
|
|
528
544
|
...f() ?? {}
|
|
529
545
|
};
|
|
530
546
|
} : t, (t, n, r) => {
|
|
531
|
-
if (u !== void 0 && a === void 0 && p(n), !
|
|
547
|
+
if (u !== void 0 && a === void 0 && p(n), !z && !B) {
|
|
532
548
|
let e = v(a);
|
|
533
549
|
e.steps.length = e.cursor, e.steps.push({
|
|
534
550
|
prev: t,
|
|
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 },
|
|
542
|
-
...
|
|
558
|
+
...z || B ? { isUndo: !0 } : {},
|
|
543
559
|
prev: t,
|
|
544
560
|
next: n,
|
|
545
561
|
at: Date.now()
|
|
@@ -548,7 +564,7 @@ var Be = () => {
|
|
|
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 Be = () => {
|
|
|
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 &&
|
|
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 Be = () => {
|
|
|
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
|
|
@@ -614,11 +630,11 @@ var Be = () => {
|
|
|
614
630
|
undo: (e) => {
|
|
615
631
|
let t = v(e);
|
|
616
632
|
if (t.cursor === 0) return !1;
|
|
617
|
-
--t.cursor,
|
|
633
|
+
--t.cursor, z = !0;
|
|
618
634
|
try {
|
|
619
635
|
h(e).set(() => t.steps[t.cursor].prev, "undo");
|
|
620
636
|
} finally {
|
|
621
|
-
|
|
637
|
+
z = !1;
|
|
622
638
|
}
|
|
623
639
|
return !0;
|
|
624
640
|
},
|
|
@@ -626,11 +642,11 @@ var Be = () => {
|
|
|
626
642
|
let t = v(e);
|
|
627
643
|
if (t.cursor >= t.steps.length) return !1;
|
|
628
644
|
let n = t.steps[t.cursor];
|
|
629
|
-
t.cursor += 1,
|
|
645
|
+
t.cursor += 1, z = !0;
|
|
630
646
|
try {
|
|
631
647
|
h(e).set(() => n.next, "redo");
|
|
632
648
|
} finally {
|
|
633
|
-
|
|
649
|
+
z = !1;
|
|
634
650
|
}
|
|
635
651
|
return !0;
|
|
636
652
|
},
|
|
@@ -642,27 +658,27 @@ var Be = () => {
|
|
|
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
|
|
648
|
-
},
|
|
649
|
-
|
|
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
|
-
let e =
|
|
678
|
+
let e = V.get(t.store);
|
|
663
679
|
e !== void 0 && e.set(t.value, t.key);
|
|
664
680
|
}
|
|
665
|
-
},
|
|
681
|
+
}, H = (e, t) => {
|
|
666
682
|
let n = t.split("."), r = e;
|
|
667
683
|
for (let e = 0; e < n.length; e++) {
|
|
668
684
|
let i = n[e];
|
|
@@ -681,29 +697,29 @@ var Be = () => {
|
|
|
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
|
-
}),
|
|
691
|
-
function
|
|
706
|
+
}), et = () => $e;
|
|
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;
|
|
694
710
|
let h = s(d);
|
|
695
711
|
h.current = d;
|
|
696
|
-
let g = s(() =>
|
|
712
|
+
let g = s(() => H(h.current, t)(m.current)), _ = o(() => [t, m.current], [t, o(() => JSON.stringify(Object.entries(r).sort(([e], [t]) => e.localeCompare(t))), [r])]), v = l(n((e) => a ? () => {} : u.subscribe(_, g.current, c, e, p === void 0 ? {} : { source: p }).unsubscribe, [
|
|
697
713
|
u,
|
|
698
714
|
c,
|
|
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,
|
|
@@ -746,92 +762,125 @@ function H(e, t, r = {}, i = {}) {
|
|
|
746
762
|
};
|
|
747
763
|
}
|
|
748
764
|
//#endregion
|
|
765
|
+
//#region src/preloadSeed.ts
|
|
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;
|
|
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.)`);
|
|
771
|
+
i.seeds.push({
|
|
772
|
+
api: e,
|
|
773
|
+
key: O([t, n]),
|
|
774
|
+
value: r
|
|
775
|
+
});
|
|
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;
|
|
780
|
+
if (i !== null) {
|
|
781
|
+
for (let t of i.seeds) if (t.api === e && t.key === r) return t.value;
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
return it.get(at(e, r));
|
|
785
|
+
}, lt = () => {
|
|
786
|
+
it.clear();
|
|
787
|
+
};
|
|
788
|
+
//#endregion
|
|
789
|
+
//#region src/usePreloadedSubscription.ts
|
|
790
|
+
function ut(e, t, n = {}, r = {}) {
|
|
791
|
+
let i = ct(e, t, n);
|
|
792
|
+
return U(e, t, n, i === void 0 ? r : {
|
|
793
|
+
...r,
|
|
794
|
+
initialSnapshot: i
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
//#endregion
|
|
749
798
|
//#region src/useEvent.ts
|
|
750
|
-
var
|
|
799
|
+
var dt = {
|
|
751
800
|
status: "idle",
|
|
752
801
|
missed: 0,
|
|
753
802
|
lastMiss: void 0
|
|
754
|
-
},
|
|
803
|
+
}, ft = class {
|
|
755
804
|
_tag = "EventStreamClosed";
|
|
756
805
|
};
|
|
757
|
-
function
|
|
758
|
-
let { skip: o = !1, apiName: l = "app", onMissed: u } = i, d = P(l), { runtime:
|
|
759
|
-
|
|
760
|
-
let
|
|
761
|
-
|
|
762
|
-
let
|
|
763
|
-
|
|
764
|
-
let S = s(
|
|
765
|
-
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;
|
|
766
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);
|
|
767
816
|
T.current = t;
|
|
768
|
-
let
|
|
769
|
-
|
|
770
|
-
let
|
|
771
|
-
e <= 0 || (
|
|
817
|
+
let ee = s(null);
|
|
818
|
+
ee.current !== w && (ee.current = w, C.current = /* @__PURE__ */ new Map());
|
|
819
|
+
let te = n((e, t) => {
|
|
820
|
+
e <= 0 || (g((n) => ({
|
|
772
821
|
...n,
|
|
773
822
|
missed: n.missed + e,
|
|
774
823
|
lastMiss: {
|
|
775
824
|
count: e,
|
|
776
825
|
reason: t
|
|
777
826
|
}
|
|
778
|
-
})),
|
|
827
|
+
})), v.current?.({
|
|
779
828
|
count: e,
|
|
780
829
|
reason: t
|
|
781
830
|
}));
|
|
782
|
-
}, []),
|
|
831
|
+
}, []), E = !o && w !== null && !F(d);
|
|
783
832
|
return a(() => {
|
|
784
|
-
if (!
|
|
785
|
-
|
|
833
|
+
if (!E) {
|
|
834
|
+
g(dt);
|
|
786
835
|
return;
|
|
787
836
|
}
|
|
788
|
-
|
|
837
|
+
g((e) => ({
|
|
789
838
|
...e,
|
|
790
839
|
status: "connecting"
|
|
791
840
|
}));
|
|
792
|
-
let t = 0, n =
|
|
841
|
+
let t = 0, n = p.sync(() => {
|
|
793
842
|
let t = [...C.current].map(([e, t]) => ({
|
|
794
843
|
origin: e,
|
|
795
844
|
n: t
|
|
796
845
|
}));
|
|
797
|
-
return
|
|
846
|
+
return H(b.current, e.name)({
|
|
798
847
|
key: T.current,
|
|
799
848
|
...t.length > 0 ? { resume: t } : {}
|
|
800
849
|
});
|
|
801
|
-
}), r =
|
|
850
|
+
}), r = x.unwrap(n).pipe(x.tap(() => p.sync(() => {
|
|
802
851
|
t = 0;
|
|
803
|
-
})),
|
|
804
|
-
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) => ({
|
|
805
854
|
...e,
|
|
806
855
|
status: "connecting"
|
|
807
856
|
}));
|
|
808
|
-
}))))), i = S.current.runFork(
|
|
857
|
+
}))))), i = S.current.runFork(x.runForEach(r, (e) => p.sync(() => {
|
|
809
858
|
if (e._tag === "attached") {
|
|
810
|
-
|
|
859
|
+
g((e) => ({
|
|
811
860
|
...e,
|
|
812
861
|
status: "live"
|
|
813
862
|
}));
|
|
814
863
|
return;
|
|
815
864
|
}
|
|
816
865
|
if (e._tag === "gap") {
|
|
817
|
-
|
|
866
|
+
te(e.missed, e.reason);
|
|
818
867
|
return;
|
|
819
868
|
}
|
|
820
|
-
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);
|
|
821
870
|
})));
|
|
822
871
|
return () => {
|
|
823
872
|
S.current.runFork(i.interruptAsFork(i.id()));
|
|
824
873
|
};
|
|
825
874
|
}, [
|
|
826
|
-
|
|
875
|
+
E,
|
|
827
876
|
w,
|
|
828
877
|
e.name,
|
|
829
|
-
|
|
830
|
-
]),
|
|
878
|
+
te
|
|
879
|
+
]), E ? h : dt;
|
|
831
880
|
}
|
|
832
881
|
//#endregion
|
|
833
882
|
//#region src/sequence.ts
|
|
834
|
-
var
|
|
883
|
+
var mt = () => {
|
|
835
884
|
let e = (t) => ({
|
|
836
885
|
steps: t,
|
|
837
886
|
step: ((n, r, i) => e([...t, {
|
|
@@ -843,7 +892,7 @@ var Qe = () => {
|
|
|
843
892
|
}]))
|
|
844
893
|
});
|
|
845
894
|
return e([]);
|
|
846
|
-
},
|
|
895
|
+
}, ht = async (e, t = {}) => {
|
|
847
896
|
let n = {}, r = [];
|
|
848
897
|
for (let i of e.steps) {
|
|
849
898
|
if (i.when !== void 0 && !i.when(n)) {
|
|
@@ -903,13 +952,13 @@ var Qe = () => {
|
|
|
903
952
|
ok: !0,
|
|
904
953
|
data: n
|
|
905
954
|
};
|
|
906
|
-
},
|
|
955
|
+
}, gt = (e = {}) => {
|
|
907
956
|
let [t, r] = c(!1), [i, a] = c(void 0), [o, l] = c(void 0), u = s(e);
|
|
908
957
|
return u.current = e, {
|
|
909
958
|
run: n(async (e, t = {}) => {
|
|
910
959
|
r(!0), a(void 0), l(void 0);
|
|
911
960
|
try {
|
|
912
|
-
let n = await
|
|
961
|
+
let n = await ht(e, {
|
|
913
962
|
...u.current,
|
|
914
963
|
...t
|
|
915
964
|
});
|
|
@@ -922,21 +971,21 @@ var Qe = () => {
|
|
|
922
971
|
error: i,
|
|
923
972
|
failedStep: o
|
|
924
973
|
};
|
|
925
|
-
},
|
|
926
|
-
|
|
927
|
-
},
|
|
928
|
-
|
|
929
|
-
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 {
|
|
930
979
|
e();
|
|
931
980
|
} catch {}
|
|
932
|
-
},
|
|
981
|
+
}, xt = (e) => {
|
|
933
982
|
let t = {
|
|
934
983
|
...e,
|
|
935
984
|
status: "pending",
|
|
936
985
|
startedAt: Date.now()
|
|
937
986
|
};
|
|
938
|
-
W.unshift(t), W.length >
|
|
939
|
-
},
|
|
987
|
+
W.unshift(t), W.length > _t && (W.length = _t), bt();
|
|
988
|
+
}, K = (e, t) => {
|
|
940
989
|
let n = W.findIndex((t) => t.id === e);
|
|
941
990
|
if (n === -1) return;
|
|
942
991
|
let r = W[n], i = Date.now();
|
|
@@ -952,12 +1001,12 @@ var Qe = () => {
|
|
|
952
1001
|
error: t.error,
|
|
953
1002
|
settledAt: i,
|
|
954
1003
|
durationMs: i - r.startedAt
|
|
955
|
-
},
|
|
956
|
-
},
|
|
957
|
-
|
|
958
|
-
}),
|
|
959
|
-
W.length !== 0 && (W.length = 0,
|
|
960
|
-
},
|
|
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) => {
|
|
961
1010
|
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
962
1011
|
try {
|
|
963
1012
|
Object.defineProperty(e, "__voltroTraceId", {
|
|
@@ -967,18 +1016,18 @@ var Qe = () => {
|
|
|
967
1016
|
});
|
|
968
1017
|
} catch {}
|
|
969
1018
|
return e;
|
|
970
|
-
},
|
|
971
|
-
|
|
972
|
-
},
|
|
1019
|
+
}, q, Et = (e) => {
|
|
1020
|
+
q = e;
|
|
1021
|
+
}, Dt = () => q, Ot = (e, t, n) => typeof e == "function" ? e(t, n) : e, kt = 0, At = () => `mut_${++kt}`, jt = 0, Mt = () => {
|
|
973
1022
|
let e = typeof crypto < "u" ? crypto : void 0;
|
|
974
|
-
return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${
|
|
975
|
-
},
|
|
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) => ({
|
|
976
1025
|
update: (n, r) => {
|
|
977
1026
|
e.update(n, r, t);
|
|
978
1027
|
},
|
|
979
1028
|
forTag: (n, r) => e.forTag(n, r, t)
|
|
980
|
-
}),
|
|
981
|
-
let { runtime: r, cache: i, client: a, descriptors: l, errorBus: u } = P(e), d = l[t],
|
|
1029
|
+
}), J = (e, t) => {
|
|
1030
|
+
let { runtime: r, cache: i, client: a, descriptors: l, errorBus: u } = P(e), d = l[t], f = d?.targets;
|
|
982
1031
|
if (process.env.NODE_ENV !== "production") {
|
|
983
1032
|
let n = d?.kind;
|
|
984
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.`);
|
|
@@ -986,12 +1035,12 @@ var Qe = () => {
|
|
|
986
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) => {
|
|
987
1036
|
let s = o?.onError !== void 0 || o?.notify?.error !== void 0, c = (e) => {
|
|
988
1037
|
o?.onError?.(e, n);
|
|
989
|
-
let t =
|
|
990
|
-
t !== void 0 &&
|
|
1038
|
+
let t = Ot(o?.notify?.error, e, n);
|
|
1039
|
+
t !== void 0 && q?.error(t);
|
|
991
1040
|
};
|
|
992
1041
|
h(!0), _(void 0);
|
|
993
|
-
let l =
|
|
994
|
-
|
|
1042
|
+
let l = At(), d = o?.idempotencyKey ?? Mt();
|
|
1043
|
+
xt({
|
|
995
1044
|
id: l,
|
|
996
1045
|
apiName: e,
|
|
997
1046
|
tag: t,
|
|
@@ -999,38 +1048,38 @@ var Qe = () => {
|
|
|
999
1048
|
});
|
|
1000
1049
|
let m = b.current, g = x.current;
|
|
1001
1050
|
if (m) try {
|
|
1002
|
-
m(
|
|
1051
|
+
m(Pt(i, l), n);
|
|
1003
1052
|
} catch (e) {
|
|
1004
|
-
if (_(e), h(!1), i.revertByMutation(l),
|
|
1053
|
+
if (_(e), h(!1), i.revertByMutation(l), K(l, {
|
|
1005
1054
|
status: "error",
|
|
1006
1055
|
error: e
|
|
1007
1056
|
}), s) return c(e);
|
|
1008
1057
|
throw e;
|
|
1009
1058
|
}
|
|
1010
|
-
else !g &&
|
|
1059
|
+
else !g && f && f.length > 0 && i.autoApply(f, n, l);
|
|
1011
1060
|
let v;
|
|
1012
1061
|
try {
|
|
1013
|
-
let s =
|
|
1014
|
-
v = e.traceId,
|
|
1062
|
+
let s = H(a, t), c = p.currentSpan.pipe(p.tap((e) => p.sync(() => {
|
|
1063
|
+
v = e.traceId, D({
|
|
1015
1064
|
traceId: e.traceId,
|
|
1016
1065
|
spanId: e.spanId,
|
|
1017
1066
|
source: "mutation",
|
|
1018
1067
|
tag: t
|
|
1019
1068
|
});
|
|
1020
|
-
})),
|
|
1069
|
+
})), p.catchAll(() => p.void), p.zipRight(Nt(s(n), d))).pipe(p.withSpan(`client.mutation.${t}`, { attributes: {
|
|
1021
1070
|
"voltro.api": e,
|
|
1022
1071
|
"voltro.mutationId": l,
|
|
1023
1072
|
"rpc.tag": t
|
|
1024
1073
|
} })), u = await r.runPromise(c);
|
|
1025
|
-
y(u),
|
|
1074
|
+
y(u), K(l, {
|
|
1026
1075
|
status: "success",
|
|
1027
1076
|
output: u
|
|
1028
1077
|
}), i.confirmByMutation(l), o?.onSuccess?.(u, n);
|
|
1029
|
-
let
|
|
1030
|
-
return
|
|
1078
|
+
let f = Ot(o?.notify?.success, u, n);
|
|
1079
|
+
return f !== void 0 && q?.success(f), u;
|
|
1031
1080
|
} catch (e) {
|
|
1032
|
-
let n =
|
|
1033
|
-
if (_(n),
|
|
1081
|
+
let n = Tt(e, v);
|
|
1082
|
+
if (_(n), K(l, {
|
|
1034
1083
|
status: "error",
|
|
1035
1084
|
error: n
|
|
1036
1085
|
}), i.revertByMutation(l), u.emit({
|
|
@@ -1049,7 +1098,7 @@ var Qe = () => {
|
|
|
1049
1098
|
a,
|
|
1050
1099
|
e,
|
|
1051
1100
|
t,
|
|
1052
|
-
|
|
1101
|
+
f
|
|
1053
1102
|
]);
|
|
1054
1103
|
return o(() => {
|
|
1055
1104
|
let e = {
|
|
@@ -1067,7 +1116,7 @@ var Qe = () => {
|
|
|
1067
1116
|
g,
|
|
1068
1117
|
v
|
|
1069
1118
|
]);
|
|
1070
|
-
},
|
|
1119
|
+
}, Ft = (e, t) => {
|
|
1071
1120
|
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
1072
1121
|
try {
|
|
1073
1122
|
Object.defineProperty(e, "__voltroTraceId", {
|
|
@@ -1077,81 +1126,84 @@ var Qe = () => {
|
|
|
1077
1126
|
});
|
|
1078
1127
|
} catch {}
|
|
1079
1128
|
return e;
|
|
1080
|
-
},
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1129
|
+
}, It = (e, t, n) => typeof e == "function" ? e(t, n) : e, Lt = 0, Rt = () => `act_${++Lt}`, zt = 15e3, Bt = async (e, t, n) => {
|
|
1130
|
+
if (!F(e.current)) return e.current;
|
|
1131
|
+
let r = Date.now() + zt;
|
|
1132
|
+
for (; Date.now() < r;) if (await new Promise((e) => setTimeout(e, 16)), !F(e.current)) return e.current;
|
|
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.`);
|
|
1134
|
+
}, Y = (e, t) => {
|
|
1135
|
+
let r = P(e), { descriptors: i, errorBus: a } = r, l = s(r);
|
|
1136
|
+
if (l.current = r, process.env.NODE_ENV !== "production") {
|
|
1137
|
+
let n = i[t]?.kind;
|
|
1084
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.`);
|
|
1085
1139
|
}
|
|
1086
|
-
let [
|
|
1087
|
-
let
|
|
1088
|
-
|
|
1089
|
-
let
|
|
1090
|
-
|
|
1091
|
-
id:
|
|
1140
|
+
let [u, d] = c(!1), [f, m] = c(void 0), [h, g] = c(void 0), _ = n(async (n, r) => {
|
|
1141
|
+
let i = r?.onError !== void 0 || r?.notify?.error !== void 0;
|
|
1142
|
+
d(!0), m(void 0);
|
|
1143
|
+
let o = Rt(), s = r?.idempotencyKey ?? Mt();
|
|
1144
|
+
xt({
|
|
1145
|
+
id: o,
|
|
1092
1146
|
apiName: e,
|
|
1093
1147
|
tag: t,
|
|
1094
1148
|
input: n
|
|
1095
1149
|
});
|
|
1096
|
-
let
|
|
1150
|
+
let c;
|
|
1097
1151
|
try {
|
|
1098
|
-
let
|
|
1099
|
-
|
|
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({
|
|
1100
1154
|
traceId: e.traceId,
|
|
1101
1155
|
spanId: e.spanId,
|
|
1102
1156
|
source: "action",
|
|
1103
1157
|
tag: t
|
|
1104
1158
|
});
|
|
1105
|
-
})),
|
|
1159
|
+
})), p.catchAll(() => p.void), p.zipRight(Nt(u(n), s))).pipe(p.withSpan(`client.action.${t}`, { attributes: {
|
|
1106
1160
|
"voltro.api": e,
|
|
1107
|
-
"voltro.actionId":
|
|
1161
|
+
"voltro.actionId": o,
|
|
1108
1162
|
"rpc.tag": t
|
|
1109
|
-
} })),
|
|
1110
|
-
|
|
1163
|
+
} })), f = await i.runPromise(d);
|
|
1164
|
+
g(f), K(o, {
|
|
1111
1165
|
status: "success",
|
|
1112
|
-
output:
|
|
1113
|
-
}),
|
|
1114
|
-
let
|
|
1115
|
-
return
|
|
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;
|
|
1116
1170
|
} catch (e) {
|
|
1117
|
-
let
|
|
1118
|
-
if (
|
|
1171
|
+
let s = Ft(e, c);
|
|
1172
|
+
if (m(s), K(o, {
|
|
1119
1173
|
status: "error",
|
|
1120
|
-
error:
|
|
1121
|
-
}),
|
|
1174
|
+
error: s
|
|
1175
|
+
}), a.emit({
|
|
1122
1176
|
source: "action",
|
|
1123
1177
|
tag: t,
|
|
1124
|
-
error:
|
|
1125
|
-
...
|
|
1126
|
-
}),
|
|
1127
|
-
|
|
1128
|
-
let e =
|
|
1129
|
-
e !== void 0 &&
|
|
1178
|
+
error: s,
|
|
1179
|
+
...c === void 0 ? {} : { traceId: c }
|
|
1180
|
+
}), i) {
|
|
1181
|
+
r?.onError?.(s, n);
|
|
1182
|
+
let e = It(r?.notify?.error, s, n);
|
|
1183
|
+
e !== void 0 && Dt()?.error(e);
|
|
1130
1184
|
return;
|
|
1131
1185
|
}
|
|
1132
|
-
throw
|
|
1186
|
+
throw s;
|
|
1133
1187
|
} finally {
|
|
1134
|
-
|
|
1188
|
+
d(!1);
|
|
1135
1189
|
}
|
|
1136
1190
|
}, [
|
|
1137
|
-
r,
|
|
1138
|
-
i,
|
|
1139
1191
|
e,
|
|
1140
1192
|
t,
|
|
1141
|
-
|
|
1193
|
+
a
|
|
1142
1194
|
]);
|
|
1143
1195
|
return o(() => ({
|
|
1144
|
-
run:
|
|
1145
|
-
pending:
|
|
1146
|
-
error:
|
|
1147
|
-
lastResult:
|
|
1196
|
+
run: _,
|
|
1197
|
+
pending: u,
|
|
1198
|
+
error: f,
|
|
1199
|
+
lastResult: h
|
|
1148
1200
|
}), [
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1201
|
+
_,
|
|
1202
|
+
u,
|
|
1203
|
+
f,
|
|
1204
|
+
h
|
|
1153
1205
|
]);
|
|
1154
|
-
},
|
|
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) => {
|
|
1155
1207
|
let o = new XMLHttpRequest();
|
|
1156
1208
|
if (o.open("PUT", e), o.upload.onprogress = (e) => {
|
|
1157
1209
|
e.lengthComputable && n(e.loaded / e.total);
|
|
@@ -1165,7 +1217,7 @@ var Qe = () => {
|
|
|
1165
1217
|
return;
|
|
1166
1218
|
}
|
|
1167
1219
|
r.addEventListener("abort", () => o.abort(), { once: !0 }), o.send(t);
|
|
1168
|
-
}),
|
|
1220
|
+
}), Xt = (e, t, n, r, i, a) => new Promise((o, s) => {
|
|
1169
1221
|
let c = new XMLHttpRequest();
|
|
1170
1222
|
if (c.open("POST", e), c.setRequestHeader("content-type", t), c.upload.onprogress = (e) => {
|
|
1171
1223
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -1183,7 +1235,7 @@ var Qe = () => {
|
|
|
1183
1235
|
return;
|
|
1184
1236
|
}
|
|
1185
1237
|
i.addEventListener("abort", () => c.abort(), { once: !0 }), c.send(n);
|
|
1186
|
-
}),
|
|
1238
|
+
}), Zt = (e, t, n, r, i) => new Promise((a, o) => {
|
|
1187
1239
|
let s = new XMLHttpRequest();
|
|
1188
1240
|
if (s.open("PUT", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
1189
1241
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -1194,7 +1246,7 @@ var Qe = () => {
|
|
|
1194
1246
|
return;
|
|
1195
1247
|
}
|
|
1196
1248
|
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
1197
|
-
}),
|
|
1249
|
+
}), Qt = (e, t, n, r, i) => new Promise((a, o) => {
|
|
1198
1250
|
let s = new XMLHttpRequest();
|
|
1199
1251
|
if (s.open("POST", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
1200
1252
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -1210,7 +1262,7 @@ var Qe = () => {
|
|
|
1210
1262
|
return;
|
|
1211
1263
|
}
|
|
1212
1264
|
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
1213
|
-
}),
|
|
1265
|
+
}), $t = (e, t = {}) => {
|
|
1214
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(() => {
|
|
1215
1267
|
d(0), p("idle"), h(void 0);
|
|
1216
1268
|
}, []), v = n(() => {
|
|
@@ -1231,16 +1283,16 @@ var Qe = () => {
|
|
|
1231
1283
|
...e.width === void 0 ? {} : { width: e.width },
|
|
1232
1284
|
...e.height === void 0 ? {} : { height: e.height }
|
|
1233
1285
|
}), g = async () => {
|
|
1234
|
-
let s = n.mintTag ?? t.mintTag ??
|
|
1286
|
+
let s = n.mintTag ?? t.mintTag ?? Vt, l = H(i, s), u = await r.runPromise(l({
|
|
1235
1287
|
contentType: c,
|
|
1236
1288
|
...m,
|
|
1237
1289
|
...d ? { key: d } : {}
|
|
1238
|
-
})), f = await
|
|
1290
|
+
})), f = await Qt(y(u.uploadUrl), c, e, o, a);
|
|
1239
1291
|
return h(f);
|
|
1240
1292
|
}, _ = async () => {
|
|
1241
|
-
let s = n.presignMintTag ?? t.presignMintTag ??
|
|
1293
|
+
let s = n.presignMintTag ?? t.presignMintTag ?? Ht, l = n.finalizeTag ?? t.finalizeTag ?? Ut, u;
|
|
1242
1294
|
try {
|
|
1243
|
-
let e =
|
|
1295
|
+
let e = H(i, s);
|
|
1244
1296
|
u = await r.runPromise(e({
|
|
1245
1297
|
contentType: c,
|
|
1246
1298
|
...m
|
|
@@ -1248,11 +1300,11 @@ var Qe = () => {
|
|
|
1248
1300
|
} catch {
|
|
1249
1301
|
return null;
|
|
1250
1302
|
}
|
|
1251
|
-
await
|
|
1252
|
-
let d =
|
|
1303
|
+
await Zt(u.uploadUrl, c, e, o, a);
|
|
1304
|
+
let d = H(i, l), f = await r.runPromise(d({ finalizeToken: u.finalizeToken }));
|
|
1253
1305
|
return h(f);
|
|
1254
1306
|
}, v = async () => {
|
|
1255
|
-
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({
|
|
1256
1308
|
contentType: c,
|
|
1257
1309
|
size: u,
|
|
1258
1310
|
...m,
|
|
@@ -1263,7 +1315,7 @@ var Qe = () => {
|
|
|
1263
1315
|
for (;;) {
|
|
1264
1316
|
if (a.aborted) throw new DOMException("upload aborted", "AbortError");
|
|
1265
1317
|
try {
|
|
1266
|
-
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);
|
|
1267
1319
|
s && (x = e);
|
|
1268
1320
|
break;
|
|
1269
1321
|
} catch (e) {
|
|
@@ -1275,9 +1327,9 @@ var Qe = () => {
|
|
|
1275
1327
|
if (!x) throw Error("resumable upload produced no final reply");
|
|
1276
1328
|
return h(x);
|
|
1277
1329
|
}, b = async () => {
|
|
1278
|
-
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;
|
|
1279
1331
|
try {
|
|
1280
|
-
let e =
|
|
1332
|
+
let e = H(i, s);
|
|
1281
1333
|
g = await r.runPromise(e({
|
|
1282
1334
|
contentType: c,
|
|
1283
1335
|
size: p,
|
|
@@ -1287,7 +1339,7 @@ var Qe = () => {
|
|
|
1287
1339
|
} catch {
|
|
1288
1340
|
return null;
|
|
1289
1341
|
}
|
|
1290
|
-
let _ =
|
|
1342
|
+
let _ = H(i, u), v = H(i, d), b = H(i, f), x = Math.max(1, g.partSize), S = Math.max(1, Math.ceil(p / x)), C = Math.max(0, n.retries ?? t.retries ?? 1), w = [], T = 0;
|
|
1291
1343
|
try {
|
|
1292
1344
|
for (let t = 0; t < S; t++) {
|
|
1293
1345
|
let n = t * x, i = Math.min(p, n + x), s = e.slice(n, i), c = t + 1, l = i - n, u = 0;
|
|
@@ -1297,7 +1349,7 @@ var Qe = () => {
|
|
|
1297
1349
|
let { url: e } = await r.runPromise(_({
|
|
1298
1350
|
multipartToken: g.multipartToken,
|
|
1299
1351
|
partNumber: c
|
|
1300
|
-
})), t = await
|
|
1352
|
+
})), t = await Yt(e, s, (e) => o((T + e * l) / p), a);
|
|
1301
1353
|
w.push({
|
|
1302
1354
|
partNumber: c,
|
|
1303
1355
|
etag: t
|
|
@@ -1371,7 +1423,7 @@ var Qe = () => {
|
|
|
1371
1423
|
} catch (e) {
|
|
1372
1424
|
throw p("error"), h(e), e instanceof DOMException && e.name === "AbortError" || l.emit({
|
|
1373
1425
|
source: "action",
|
|
1374
|
-
tag: n.mintTag ?? t.mintTag ??
|
|
1426
|
+
tag: n.mintTag ?? t.mintTag ?? Vt,
|
|
1375
1427
|
error: e
|
|
1376
1428
|
}), e;
|
|
1377
1429
|
}
|
|
@@ -1397,7 +1449,7 @@ var Qe = () => {
|
|
|
1397
1449
|
} catch (e) {
|
|
1398
1450
|
throw r.abort(), p("error"), h(e), e instanceof DOMException && e.name === "AbortError" || l.emit({
|
|
1399
1451
|
source: "action",
|
|
1400
|
-
tag: n.mintTag ?? t.mintTag ??
|
|
1452
|
+
tag: n.mintTag ?? t.mintTag ?? Vt,
|
|
1401
1453
|
error: e
|
|
1402
1454
|
}), e;
|
|
1403
1455
|
}
|
|
@@ -1442,20 +1494,20 @@ var Qe = () => {
|
|
|
1442
1494
|
w,
|
|
1443
1495
|
T
|
|
1444
1496
|
]);
|
|
1445
|
-
},
|
|
1446
|
-
let t =
|
|
1447
|
-
|
|
1497
|
+
}, X = async (e) => {
|
|
1498
|
+
let t = H(e.client, e.tag), n = p.currentSpan.pipe(p.tap((t) => p.sync(() => {
|
|
1499
|
+
D({
|
|
1448
1500
|
traceId: t.traceId,
|
|
1449
1501
|
spanId: t.spanId,
|
|
1450
1502
|
source: "mutation",
|
|
1451
1503
|
tag: e.tag
|
|
1452
1504
|
});
|
|
1453
|
-
})),
|
|
1505
|
+
})), p.catchAll(() => p.void), p.zipRight(t(e.input)), p.withSpan(`${e.spanPrefix}.${e.tag}`, { attributes: {
|
|
1454
1506
|
"voltro.api": e.apiName,
|
|
1455
1507
|
"rpc.tag": e.tag
|
|
1456
1508
|
} }));
|
|
1457
1509
|
return e.runtime.runPromise(n);
|
|
1458
|
-
},
|
|
1510
|
+
}, en = (e, t) => {
|
|
1459
1511
|
let { runtime: r, client: i, descriptors: a } = P(e);
|
|
1460
1512
|
if (process.env.NODE_ENV !== "production") {
|
|
1461
1513
|
let n = a[t]?.kind;
|
|
@@ -1464,7 +1516,7 @@ var Qe = () => {
|
|
|
1464
1516
|
let [s, l] = c(!1), [u, d] = c(void 0), [f, p] = c(void 0), m = n(async (n) => {
|
|
1465
1517
|
l(!0), d(void 0);
|
|
1466
1518
|
try {
|
|
1467
|
-
let a = await
|
|
1519
|
+
let a = await X({
|
|
1468
1520
|
apiName: e,
|
|
1469
1521
|
runtime: r,
|
|
1470
1522
|
client: i,
|
|
@@ -1484,7 +1536,7 @@ var Qe = () => {
|
|
|
1484
1536
|
i,
|
|
1485
1537
|
t
|
|
1486
1538
|
]), h = n(async (t) => {
|
|
1487
|
-
await
|
|
1539
|
+
await X({
|
|
1488
1540
|
apiName: e,
|
|
1489
1541
|
runtime: r,
|
|
1490
1542
|
client: i,
|
|
@@ -1497,7 +1549,7 @@ var Qe = () => {
|
|
|
1497
1549
|
r,
|
|
1498
1550
|
i
|
|
1499
1551
|
]), g = n(async (t) => {
|
|
1500
|
-
await
|
|
1552
|
+
await X({
|
|
1501
1553
|
apiName: e,
|
|
1502
1554
|
runtime: r,
|
|
1503
1555
|
client: i,
|
|
@@ -1509,7 +1561,7 @@ var Qe = () => {
|
|
|
1509
1561
|
e,
|
|
1510
1562
|
r,
|
|
1511
1563
|
i
|
|
1512
|
-
]), _ = n(async (t, n, a) =>
|
|
1564
|
+
]), _ = n(async (t, n, a) => X({
|
|
1513
1565
|
apiName: e,
|
|
1514
1566
|
runtime: r,
|
|
1515
1567
|
client: i,
|
|
@@ -1524,7 +1576,7 @@ var Qe = () => {
|
|
|
1524
1576
|
e,
|
|
1525
1577
|
r,
|
|
1526
1578
|
i
|
|
1527
|
-
]), v = n(async (t, n, a, o) =>
|
|
1579
|
+
]), v = n(async (t, n, a, o) => X({
|
|
1528
1580
|
apiName: e,
|
|
1529
1581
|
runtime: r,
|
|
1530
1582
|
client: i,
|
|
@@ -1560,11 +1612,11 @@ var Qe = () => {
|
|
|
1560
1612
|
u,
|
|
1561
1613
|
f
|
|
1562
1614
|
]);
|
|
1563
|
-
},
|
|
1615
|
+
}, tn = (e) => {
|
|
1564
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) => {
|
|
1565
1617
|
a(!0), l(void 0);
|
|
1566
1618
|
try {
|
|
1567
|
-
let a = await
|
|
1619
|
+
let a = await X({
|
|
1568
1620
|
apiName: e,
|
|
1569
1621
|
runtime: t,
|
|
1570
1622
|
client: r,
|
|
@@ -1598,11 +1650,11 @@ var Qe = () => {
|
|
|
1598
1650
|
s,
|
|
1599
1651
|
u
|
|
1600
1652
|
]);
|
|
1601
|
-
},
|
|
1653
|
+
}, nn = (e) => {
|
|
1602
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) => {
|
|
1603
1655
|
a(!0), l(void 0);
|
|
1604
1656
|
try {
|
|
1605
|
-
let a = await
|
|
1657
|
+
let a = await X({
|
|
1606
1658
|
apiName: e,
|
|
1607
1659
|
runtime: t,
|
|
1608
1660
|
client: r,
|
|
@@ -1637,8 +1689,8 @@ var Qe = () => {
|
|
|
1637
1689
|
s,
|
|
1638
1690
|
u
|
|
1639
1691
|
]);
|
|
1640
|
-
},
|
|
1641
|
-
let n =
|
|
1692
|
+
}, rn = (e, t) => {
|
|
1693
|
+
let n = U(e, "__voltro.workflow.run", t ? { id: t } : {}, { skip: t === void 0 });
|
|
1642
1694
|
return n.loading || n.idle ? {
|
|
1643
1695
|
...n,
|
|
1644
1696
|
run: void 0
|
|
@@ -1646,8 +1698,8 @@ var Qe = () => {
|
|
|
1646
1698
|
...n,
|
|
1647
1699
|
run: n.data[0]
|
|
1648
1700
|
};
|
|
1649
|
-
},
|
|
1650
|
-
let r =
|
|
1701
|
+
}, an = (e, t = {}, n = {}) => {
|
|
1702
|
+
let r = U(e, "__voltro.workflow.runs", t, n);
|
|
1651
1703
|
return r.loading || r.idle ? {
|
|
1652
1704
|
...r,
|
|
1653
1705
|
runs: []
|
|
@@ -1655,8 +1707,8 @@ var Qe = () => {
|
|
|
1655
1707
|
...r,
|
|
1656
1708
|
runs: r.data
|
|
1657
1709
|
};
|
|
1658
|
-
},
|
|
1659
|
-
let n =
|
|
1710
|
+
}, on = (e, t) => {
|
|
1711
|
+
let n = U(e, "__voltro.workflow.run.steps", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
1660
1712
|
return n.loading || n.idle ? {
|
|
1661
1713
|
...n,
|
|
1662
1714
|
steps: []
|
|
@@ -1664,8 +1716,8 @@ var Qe = () => {
|
|
|
1664
1716
|
...n,
|
|
1665
1717
|
steps: n.data
|
|
1666
1718
|
};
|
|
1667
|
-
},
|
|
1668
|
-
let n =
|
|
1719
|
+
}, sn = (e, t) => {
|
|
1720
|
+
let n = U(e, "__voltro.workflow.run.events", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
1669
1721
|
return n.loading || n.idle ? {
|
|
1670
1722
|
...n,
|
|
1671
1723
|
events: []
|
|
@@ -1673,8 +1725,8 @@ var Qe = () => {
|
|
|
1673
1725
|
...n,
|
|
1674
1726
|
events: n.data
|
|
1675
1727
|
};
|
|
1676
|
-
},
|
|
1677
|
-
let r =
|
|
1728
|
+
}, cn = sn, ln = (e, t = {}, n = {}) => {
|
|
1729
|
+
let r = U(e, "__voltro.workflow.domainEvents", t, n);
|
|
1678
1730
|
return r.loading || r.idle ? {
|
|
1679
1731
|
...r,
|
|
1680
1732
|
events: []
|
|
@@ -1682,8 +1734,8 @@ var Qe = () => {
|
|
|
1682
1734
|
...r,
|
|
1683
1735
|
events: r.data
|
|
1684
1736
|
};
|
|
1685
|
-
},
|
|
1686
|
-
let n =
|
|
1737
|
+
}, un = (e, t) => {
|
|
1738
|
+
let n = U(e, "__voltro.workflow.event.deliveries", t ? { eventId: t } : {}, { skip: t === void 0 });
|
|
1687
1739
|
return n.loading || n.idle ? {
|
|
1688
1740
|
...n,
|
|
1689
1741
|
deliveries: []
|
|
@@ -1691,42 +1743,42 @@ var Qe = () => {
|
|
|
1691
1743
|
...n,
|
|
1692
1744
|
deliveries: n.data
|
|
1693
1745
|
};
|
|
1694
|
-
},
|
|
1746
|
+
}, dn = (e, t) => {
|
|
1695
1747
|
let n = e.payload;
|
|
1696
1748
|
if (!n || typeof n != "object") return;
|
|
1697
1749
|
let r = n[t];
|
|
1698
1750
|
return typeof r == "string" ? r : void 0;
|
|
1699
|
-
},
|
|
1751
|
+
}, fn = (e) => {
|
|
1700
1752
|
let t = e.payload;
|
|
1701
1753
|
if (!t || typeof t != "object") return;
|
|
1702
1754
|
let n = t.updateId;
|
|
1703
1755
|
return typeof n == "string" ? n : void 0;
|
|
1704
|
-
},
|
|
1756
|
+
}, pn = (e) => {
|
|
1705
1757
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
1706
1758
|
for (let r of e) if (r.eventType === "signal-received") {
|
|
1707
|
-
let e =
|
|
1759
|
+
let e = dn(r, "signalName");
|
|
1708
1760
|
e && t.add(e);
|
|
1709
1761
|
} else if (r.eventType === "update-completed" || r.eventType === "update-failed") {
|
|
1710
|
-
let e =
|
|
1762
|
+
let e = fn(r);
|
|
1711
1763
|
e && n.add(e);
|
|
1712
1764
|
}
|
|
1713
1765
|
for (let r = e.length - 1; r >= 0; --r) {
|
|
1714
1766
|
let i = e[r];
|
|
1715
1767
|
if (i.eventType === "signal-awaited") {
|
|
1716
|
-
let e =
|
|
1768
|
+
let e = dn(i, "signalName");
|
|
1717
1769
|
if (e && !t.has(e)) return {
|
|
1718
1770
|
name: e,
|
|
1719
1771
|
kind: "signal"
|
|
1720
1772
|
};
|
|
1721
1773
|
} else if (i.eventType === "update-requested") {
|
|
1722
|
-
let e =
|
|
1774
|
+
let e = fn(i), t = dn(i, "updateName");
|
|
1723
1775
|
if (t && (!e || !n.has(e))) return {
|
|
1724
1776
|
name: t,
|
|
1725
1777
|
kind: "update"
|
|
1726
1778
|
};
|
|
1727
1779
|
}
|
|
1728
1780
|
}
|
|
1729
|
-
},
|
|
1781
|
+
}, mn = (e) => e.find((e) => e.status === "running") || (e.length > 0 ? e[e.length - 1] : void 0), hn = (e, t) => {
|
|
1730
1782
|
if (!e || e.status !== "failed") return;
|
|
1731
1783
|
let n = t.find((e) => e.status === "failed");
|
|
1732
1784
|
return {
|
|
@@ -1734,8 +1786,8 @@ var Qe = () => {
|
|
|
1734
1786
|
message: e.errorMessage,
|
|
1735
1787
|
step: n?.stepName
|
|
1736
1788
|
};
|
|
1737
|
-
},
|
|
1738
|
-
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 () => {
|
|
1739
1791
|
if (!c) throw Error("useWorkflowRunState: no run loaded — cannot cancel");
|
|
1740
1792
|
await s.cancel({
|
|
1741
1793
|
workflowName: c.tag,
|
|
@@ -1759,9 +1811,9 @@ var Qe = () => {
|
|
|
1759
1811
|
status: c?.status,
|
|
1760
1812
|
steps: l,
|
|
1761
1813
|
events: u,
|
|
1762
|
-
currentStep:
|
|
1763
|
-
waitingFor: c?.status === "suspended" ?
|
|
1764
|
-
error:
|
|
1814
|
+
currentStep: mn(l),
|
|
1815
|
+
waitingFor: c?.status === "suspended" ? pn(u) : void 0,
|
|
1816
|
+
error: hn(c, l),
|
|
1765
1817
|
traceId: c?.traceId,
|
|
1766
1818
|
loading: r.data === void 0,
|
|
1767
1819
|
cancel: d,
|
|
@@ -1778,24 +1830,24 @@ var Qe = () => {
|
|
|
1778
1830
|
p,
|
|
1779
1831
|
m
|
|
1780
1832
|
]);
|
|
1781
|
-
},
|
|
1782
|
-
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(() => {
|
|
1783
1835
|
let e = g.current;
|
|
1784
|
-
e && (g.current = null, r.runFork(
|
|
1836
|
+
e && (g.current = null, r.runFork(h.interrupt(e)), d((e) => e === "streaming" ? "idle" : e));
|
|
1785
1837
|
}, [r]);
|
|
1786
1838
|
return {
|
|
1787
1839
|
events: a,
|
|
1788
1840
|
status: l,
|
|
1789
|
-
error:
|
|
1841
|
+
error: f,
|
|
1790
1842
|
start: n((e = {}) => {
|
|
1791
1843
|
let n = g.current;
|
|
1792
|
-
n && r.runFork(
|
|
1793
|
-
let a =
|
|
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({
|
|
1794
1846
|
onSuccess: () => {
|
|
1795
1847
|
d("done");
|
|
1796
1848
|
},
|
|
1797
1849
|
onFailure: (e) => {
|
|
1798
|
-
u.isInterruptedOnly(e) || (
|
|
1850
|
+
u.isInterruptedOnly(e) || (m(u.squash(e)), d("error"));
|
|
1799
1851
|
}
|
|
1800
1852
|
}));
|
|
1801
1853
|
g.current = r.runFork(s);
|
|
@@ -1806,57 +1858,57 @@ var Qe = () => {
|
|
|
1806
1858
|
]),
|
|
1807
1859
|
cancel: _
|
|
1808
1860
|
};
|
|
1809
|
-
},
|
|
1810
|
-
let i = 0, a = !1, o = (e) =>
|
|
1861
|
+
}, vn = (e, t, n, r) => {
|
|
1862
|
+
let i = 0, a = !1, o = (e) => p.sync(() => {
|
|
1811
1863
|
e.seq <= i || (i = e.seq, n.onEvent(e.event), r.isTerminal(e.event) && (a = !0));
|
|
1812
1864
|
}), s = (e, t, a) => {
|
|
1813
1865
|
let o = i > t ? 0 : e + 1;
|
|
1814
|
-
if (o > r.maxReconnects) return
|
|
1866
|
+
if (o > r.maxReconnects) return p.sync(() => {
|
|
1815
1867
|
n.onError(a ?? /* @__PURE__ */ Error("stream connection lost")), n.onStatus("error");
|
|
1816
1868
|
});
|
|
1817
1869
|
let s = Math.min(r.maxBackoffMs, r.backoffMs * 2 ** Math.max(0, o - 1));
|
|
1818
|
-
return
|
|
1870
|
+
return p.sync(() => {
|
|
1819
1871
|
n.onStatus("reconnecting"), n.onReconnect();
|
|
1820
|
-
}).pipe(
|
|
1821
|
-
}, 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(() => {
|
|
1822
1874
|
let c = i, l = e({
|
|
1823
1875
|
...t,
|
|
1824
1876
|
fromSeq: c
|
|
1825
1877
|
});
|
|
1826
|
-
return
|
|
1827
|
-
onSuccess: () => a ?
|
|
1828
|
-
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))
|
|
1829
1881
|
}));
|
|
1830
1882
|
});
|
|
1831
1883
|
return c(0);
|
|
1832
|
-
},
|
|
1884
|
+
}, yn = (e) => {
|
|
1833
1885
|
let t = e?._tag;
|
|
1834
1886
|
return t === "done" || t === "error";
|
|
1835
|
-
},
|
|
1836
|
-
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 = {
|
|
1837
1889
|
maxReconnects: r.maxReconnects ?? 6,
|
|
1838
1890
|
backoffMs: r.backoffMs ?? 400,
|
|
1839
1891
|
maxBackoffMs: r.maxBackoffMs ?? 8e3,
|
|
1840
|
-
isTerminal: r.isTerminal ??
|
|
1892
|
+
isTerminal: r.isTerminal ?? yn
|
|
1841
1893
|
}, y = n(() => {
|
|
1842
1894
|
let e = _.current;
|
|
1843
|
-
e && (_.current = null, i.runFork(
|
|
1895
|
+
e && (_.current = null, i.runFork(h.interrupt(e)), d((e) => e === "streaming" || e === "reconnecting" ? "idle" : e));
|
|
1844
1896
|
}, [i]);
|
|
1845
1897
|
return {
|
|
1846
1898
|
events: o,
|
|
1847
1899
|
status: u,
|
|
1848
1900
|
reconnects: f,
|
|
1849
|
-
error:
|
|
1901
|
+
error: m,
|
|
1850
1902
|
start: n((e = {}) => {
|
|
1851
1903
|
let n = _.current;
|
|
1852
|
-
n && i.runFork(
|
|
1853
|
-
let r =
|
|
1904
|
+
n && i.runFork(h.interrupt(n)), l([]), g(void 0), p(0), d("streaming");
|
|
1905
|
+
let r = H(a, t), o = {
|
|
1854
1906
|
onEvent: (e) => l((t) => [...t, e]),
|
|
1855
1907
|
onStatus: d,
|
|
1856
1908
|
onReconnect: () => p((e) => e + 1),
|
|
1857
1909
|
onError: g
|
|
1858
1910
|
};
|
|
1859
|
-
_.current = i.runFork(
|
|
1911
|
+
_.current = i.runFork(vn(r, e, o, v));
|
|
1860
1912
|
}, [
|
|
1861
1913
|
i,
|
|
1862
1914
|
a,
|
|
@@ -1868,13 +1920,13 @@ var Qe = () => {
|
|
|
1868
1920
|
]),
|
|
1869
1921
|
cancel: y
|
|
1870
1922
|
};
|
|
1871
|
-
},
|
|
1923
|
+
}, xn = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0), Sn = (e) => {
|
|
1872
1924
|
for (let t = e.length - 1; t >= 0; --t) {
|
|
1873
1925
|
let n = e[t];
|
|
1874
1926
|
if (n.role === "user" && n.content) return n.content;
|
|
1875
1927
|
}
|
|
1876
|
-
},
|
|
1877
|
-
let { threadId: i } = r, a =
|
|
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({
|
|
1878
1930
|
threadId: i,
|
|
1879
1931
|
order: a.data?.length ?? 0,
|
|
1880
1932
|
prompt: e,
|
|
@@ -1884,7 +1936,7 @@ var Qe = () => {
|
|
|
1884
1936
|
i,
|
|
1885
1937
|
a.data
|
|
1886
1938
|
]), u = n(() => {
|
|
1887
|
-
let e =
|
|
1939
|
+
let e = Sn(c);
|
|
1888
1940
|
return e === void 0 ? void 0 : l(e);
|
|
1889
1941
|
}, [c, l]);
|
|
1890
1942
|
return o(() => ({
|
|
@@ -1904,8 +1956,8 @@ var Qe = () => {
|
|
|
1904
1956
|
l,
|
|
1905
1957
|
u
|
|
1906
1958
|
]);
|
|
1907
|
-
},
|
|
1908
|
-
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]);
|
|
1909
1961
|
return a(() => {
|
|
1910
1962
|
if (i !== "done" || m.current === null) return;
|
|
1911
1963
|
let e = m.current;
|
|
@@ -1931,8 +1983,8 @@ var Qe = () => {
|
|
|
1931
1983
|
}, [u]),
|
|
1932
1984
|
cancel: d
|
|
1933
1985
|
};
|
|
1934
|
-
},
|
|
1935
|
-
let r =
|
|
1986
|
+
}, Tn = (e, t) => {
|
|
1987
|
+
let r = Y(e, t), [i, a] = c(void 0), s = n(async (e) => {
|
|
1936
1988
|
let t = await r.run({ question: e });
|
|
1937
1989
|
return a(t), t;
|
|
1938
1990
|
}, [r]), l = n(() => a(void 0), []);
|
|
@@ -1949,43 +2001,43 @@ var Qe = () => {
|
|
|
1949
2001
|
r.error,
|
|
1950
2002
|
l
|
|
1951
2003
|
]);
|
|
1952
|
-
},
|
|
2004
|
+
}, En = (e) => {
|
|
1953
2005
|
let { cache: t, runtime: r } = P(e);
|
|
1954
2006
|
return n(() => {
|
|
1955
2007
|
t.refreshAll(r);
|
|
1956
2008
|
}, [t, r]);
|
|
1957
|
-
},
|
|
1958
|
-
for (let t of
|
|
2009
|
+
}, Dn = /* @__PURE__ */ new Set(), On = (e) => {
|
|
2010
|
+
for (let t of Dn) try {
|
|
1959
2011
|
t(e);
|
|
1960
2012
|
} catch {}
|
|
1961
|
-
},
|
|
1962
|
-
|
|
1963
|
-
}),
|
|
1964
|
-
|
|
2013
|
+
}, kn = (e) => (Dn.add(e), () => {
|
|
2014
|
+
Dn.delete(e);
|
|
2015
|
+
}), An = (e, t) => {
|
|
2016
|
+
On({
|
|
1965
2017
|
error: e,
|
|
1966
2018
|
source: "manual",
|
|
1967
2019
|
...t ? { context: t } : {}
|
|
1968
2020
|
});
|
|
1969
|
-
},
|
|
2021
|
+
}, jn = (e, t) => {
|
|
1970
2022
|
let { errorBus: n } = P(e);
|
|
1971
2023
|
a(() => n.on(t), [n, t]);
|
|
1972
|
-
},
|
|
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) => {
|
|
1973
2025
|
let n = e;
|
|
1974
2026
|
for (let e = 0; e < 8; e += 1) {
|
|
1975
2027
|
let e = n.$ref;
|
|
1976
|
-
if (typeof e != "string" || !e.startsWith(
|
|
2028
|
+
if (typeof e != "string" || !e.startsWith(Mn)) return n;
|
|
1977
2029
|
let r = t[e.slice(8)];
|
|
1978
2030
|
if (!r || typeof r != "object") return n;
|
|
1979
2031
|
n = r;
|
|
1980
2032
|
}
|
|
1981
2033
|
return n;
|
|
1982
|
-
},
|
|
2034
|
+
}, Pn = (e) => {
|
|
1983
2035
|
if (!e || typeof e != "object") return !1;
|
|
1984
2036
|
let t = e;
|
|
1985
2037
|
if (t.type === "null" || t.const === null) return !0;
|
|
1986
2038
|
let n = t.enum;
|
|
1987
2039
|
return Array.isArray(n) && n.length === 1 && n[0] === null;
|
|
1988
|
-
},
|
|
2040
|
+
}, Fn = (e, t) => {
|
|
1989
2041
|
let n = e.type;
|
|
1990
2042
|
if (Array.isArray(n) && n.includes("null")) {
|
|
1991
2043
|
let t = n.filter((e) => e !== "null");
|
|
@@ -2000,7 +2052,7 @@ var Qe = () => {
|
|
|
2000
2052
|
for (let n of ["anyOf", "oneOf"]) {
|
|
2001
2053
|
let r = e[n];
|
|
2002
2054
|
if (!Array.isArray(r)) continue;
|
|
2003
|
-
let i = r.filter((e) => !
|
|
2055
|
+
let i = r.filter((e) => !Pn(e));
|
|
2004
2056
|
if (i.length !== r.length) return i.length === 1 ? {
|
|
2005
2057
|
node: Z(i[0], t),
|
|
2006
2058
|
nullable: !0
|
|
@@ -2016,14 +2068,14 @@ var Qe = () => {
|
|
|
2016
2068
|
node: e,
|
|
2017
2069
|
nullable: !1
|
|
2018
2070
|
};
|
|
2019
|
-
},
|
|
2071
|
+
}, In = (e) => e.map((e) => ({
|
|
2020
2072
|
value: String(e),
|
|
2021
|
-
label:
|
|
2022
|
-
})),
|
|
2073
|
+
label: Nn(String(e))
|
|
2074
|
+
})), Ln = (e) => {
|
|
2023
2075
|
let t = e.enum;
|
|
2024
2076
|
if (Array.isArray(t) && t.length > 0) return {
|
|
2025
2077
|
widget: "select",
|
|
2026
|
-
options:
|
|
2078
|
+
options: In(t)
|
|
2027
2079
|
};
|
|
2028
2080
|
let n = e.type, r = Array.isArray(n) ? n.find((e) => e !== "null") : n, i = e.format;
|
|
2029
2081
|
switch (r) {
|
|
@@ -2034,45 +2086,45 @@ var Qe = () => {
|
|
|
2034
2086
|
case "array": return { widget: "multi-select" };
|
|
2035
2087
|
default: return { widget: "custom" };
|
|
2036
2088
|
}
|
|
2037
|
-
},
|
|
2038
|
-
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);
|
|
2039
2091
|
return {
|
|
2040
2092
|
name: e,
|
|
2041
|
-
label:
|
|
2093
|
+
label: Nn(e),
|
|
2042
2094
|
widget: s,
|
|
2043
2095
|
required: t.has(e),
|
|
2044
2096
|
nullable: a,
|
|
2045
2097
|
...c ? { options: c } : {},
|
|
2046
2098
|
jsonSchema: o
|
|
2047
2099
|
};
|
|
2048
|
-
}),
|
|
2100
|
+
}), zn = (e) => {
|
|
2049
2101
|
try {
|
|
2050
|
-
return
|
|
2102
|
+
return g.make(e);
|
|
2051
2103
|
} catch {
|
|
2052
2104
|
return;
|
|
2053
2105
|
}
|
|
2054
2106
|
}, Q = (e) => {
|
|
2055
|
-
let t =
|
|
2107
|
+
let t = zn(e);
|
|
2056
2108
|
if (t === void 0) return [];
|
|
2057
2109
|
let n = t.$defs ?? {}, r = Z(t, n), i = r.properties;
|
|
2058
|
-
return i ?
|
|
2059
|
-
},
|
|
2060
|
-
let t =
|
|
2110
|
+
return i ? Rn(i, new Set(Array.isArray(r.required) ? r.required : []), n) : [];
|
|
2111
|
+
}, Bn = (e) => {
|
|
2112
|
+
let t = zn(e);
|
|
2061
2113
|
if (t === void 0) return [];
|
|
2062
2114
|
let n = t.$defs ?? {}, r = Z(t, n);
|
|
2063
2115
|
if (r.type !== "array") return [];
|
|
2064
2116
|
let i = r.items;
|
|
2065
2117
|
if (!i || typeof i != "object") return [];
|
|
2066
2118
|
let a = Z(i, n), o = a.properties;
|
|
2067
|
-
return o ?
|
|
2068
|
-
},
|
|
2069
|
-
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);
|
|
2070
2122
|
if (n._tag === "Right") return {
|
|
2071
2123
|
valid: !0,
|
|
2072
2124
|
errors: {}
|
|
2073
2125
|
};
|
|
2074
2126
|
let r = {};
|
|
2075
|
-
for (let e of
|
|
2127
|
+
for (let e of E.formatErrorSync(n.left)) {
|
|
2076
2128
|
let t = e.path.length === 0 ? "" : String(e.path[0]);
|
|
2077
2129
|
t !== "" && !(t in r) && (r[t] = e.message);
|
|
2078
2130
|
}
|
|
@@ -2080,8 +2132,8 @@ var Qe = () => {
|
|
|
2080
2132
|
valid: !1,
|
|
2081
2133
|
errors: r
|
|
2082
2134
|
};
|
|
2083
|
-
},
|
|
2084
|
-
let i = P(e), a =
|
|
2135
|
+
}, Hn = (e, t, r) => {
|
|
2136
|
+
let i = P(e), a = J(e, t), l = r.schema ?? i.descriptors[t]?.input;
|
|
2085
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.`);
|
|
2086
2138
|
let u = o(() => l ? Q(l) : [], [l]), d = s(r.defaults ?? {}), [f, p] = c(d.current), [m, h] = c({}), g = n((e, t) => {
|
|
2087
2139
|
p((n) => ({
|
|
@@ -2097,7 +2149,7 @@ var Qe = () => {
|
|
|
2097
2149
|
p(d.current), h({});
|
|
2098
2150
|
}, []), y = n(async () => {
|
|
2099
2151
|
if (l !== void 0) {
|
|
2100
|
-
let e =
|
|
2152
|
+
let e = Vn(l, f);
|
|
2101
2153
|
if (h(e.errors), !e.valid) return;
|
|
2102
2154
|
}
|
|
2103
2155
|
return a.mutate(f);
|
|
@@ -2110,7 +2162,7 @@ var Qe = () => {
|
|
|
2110
2162
|
fields: u,
|
|
2111
2163
|
values: f,
|
|
2112
2164
|
errors: m,
|
|
2113
|
-
isValid: o(() => l === void 0 ||
|
|
2165
|
+
isValid: o(() => l === void 0 || Vn(l, f).valid, [l, f]),
|
|
2114
2166
|
pending: a.pending,
|
|
2115
2167
|
submitError: a.error,
|
|
2116
2168
|
data: a.data,
|
|
@@ -2119,13 +2171,13 @@ var Qe = () => {
|
|
|
2119
2171
|
reset: v,
|
|
2120
2172
|
submit: y
|
|
2121
2173
|
};
|
|
2122
|
-
},
|
|
2174
|
+
}, Un = (e, t, n) => e.map((e) => {
|
|
2123
2175
|
let r = String(e[n] ?? ""), i = e[t];
|
|
2124
2176
|
return {
|
|
2125
2177
|
value: r,
|
|
2126
2178
|
label: i == null ? r : String(i)
|
|
2127
2179
|
};
|
|
2128
|
-
}),
|
|
2180
|
+
}), Wn = (e, t, r = {}) => {
|
|
2129
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);
|
|
2130
2182
|
a(() => {
|
|
2131
2183
|
if (d === p) return;
|
|
@@ -2136,7 +2188,7 @@ var Qe = () => {
|
|
|
2136
2188
|
p,
|
|
2137
2189
|
i
|
|
2138
2190
|
]);
|
|
2139
|
-
let h = r.skipUntilTerm === !0 && p.trim() === "", g =
|
|
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), [
|
|
2140
2192
|
g.data,
|
|
2141
2193
|
s,
|
|
2142
2194
|
l
|
|
@@ -2147,13 +2199,13 @@ var Qe = () => {
|
|
|
2147
2199
|
term: d,
|
|
2148
2200
|
search: v
|
|
2149
2201
|
};
|
|
2150
|
-
},
|
|
2151
|
-
let i = P(e), [a, s] = c(r.pageSize), l =
|
|
2202
|
+
}, Gn = (e, t) => e === t ? 0 : e == null ? 1 : t == null || e < t ? -1 : 1, Kn = (e, t, r = {}) => {
|
|
2203
|
+
let i = P(e), [a, s] = c(r.pageSize), l = U(e, t, o(() => a === void 0 ? r.input ?? {} : {
|
|
2152
2204
|
...r.input,
|
|
2153
2205
|
limit: a
|
|
2154
2206
|
}, [r.input, a])), u = i.descriptors[t]?.output, d = n(() => {
|
|
2155
2207
|
r.pageSize !== void 0 && s((e) => (e ?? r.pageSize) + r.pageSize);
|
|
2156
|
-
}, [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) => {
|
|
2157
2209
|
m((t) => t?.column === e ? {
|
|
2158
2210
|
column: e,
|
|
2159
2211
|
direction: t.direction === "asc" ? "desc" : "asc"
|
|
@@ -2168,7 +2220,7 @@ var Qe = () => {
|
|
|
2168
2220
|
let e = l.data ?? [];
|
|
2169
2221
|
if (p === void 0) return e;
|
|
2170
2222
|
let t = p.direction === "asc" ? 1 : -1;
|
|
2171
|
-
return [...e].sort((e, n) =>
|
|
2223
|
+
return [...e].sort((e, n) => Gn(e[p.column], n[p.column]) * t);
|
|
2172
2224
|
}, [l.data, p]),
|
|
2173
2225
|
loading: l.data === void 0,
|
|
2174
2226
|
error: l.error,
|
|
@@ -2177,13 +2229,13 @@ var Qe = () => {
|
|
|
2177
2229
|
loadMore: d,
|
|
2178
2230
|
hasMore: a !== void 0 && (l.data?.length ?? 0) >= a
|
|
2179
2231
|
};
|
|
2180
|
-
},
|
|
2232
|
+
}, qn = (e, t, n, r) => {
|
|
2181
2233
|
let i = e.replace(/\/$/, ""), a = new URLSearchParams({
|
|
2182
2234
|
table: t,
|
|
2183
2235
|
id: n
|
|
2184
2236
|
});
|
|
2185
2237
|
return r !== void 0 && a.set("column", r), `${i}/_voltro/inspect/provenance?${a.toString()}`;
|
|
2186
|
-
},
|
|
2238
|
+
}, Jn = qn, Yn = (e, t, n, r) => {
|
|
2187
2239
|
let { inspectBaseUrl: i } = P(e), [o, s] = c({
|
|
2188
2240
|
data: void 0,
|
|
2189
2241
|
loading: !0,
|
|
@@ -2196,7 +2248,7 @@ var Qe = () => {
|
|
|
2196
2248
|
loading: !0,
|
|
2197
2249
|
error: void 0
|
|
2198
2250
|
});
|
|
2199
|
-
let a =
|
|
2251
|
+
let a = qn(i ?? "", t, n, r);
|
|
2200
2252
|
return fetch(a).then(async (e) => {
|
|
2201
2253
|
if (!e.ok) throw Error(`provenance fetch failed: HTTP ${e.status}`);
|
|
2202
2254
|
return await e.json();
|
|
@@ -2222,7 +2274,7 @@ var Qe = () => {
|
|
|
2222
2274
|
n,
|
|
2223
2275
|
r
|
|
2224
2276
|
]), o;
|
|
2225
|
-
},
|
|
2277
|
+
}, Xn = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, Zn = (e) => {
|
|
2226
2278
|
let { inspectBaseUrl: t } = P(e), [n, r] = c({
|
|
2227
2279
|
manifest: void 0,
|
|
2228
2280
|
loading: !0,
|
|
@@ -2234,7 +2286,7 @@ var Qe = () => {
|
|
|
2234
2286
|
manifest: void 0,
|
|
2235
2287
|
loading: !0,
|
|
2236
2288
|
error: void 0
|
|
2237
|
-
}), fetch(
|
|
2289
|
+
}), fetch(Xn(t ?? "")).then(async (e) => {
|
|
2238
2290
|
if (!e.ok) throw Error(`manifest fetch failed: HTTP ${e.status}`);
|
|
2239
2291
|
return await e.json();
|
|
2240
2292
|
}).then((t) => {
|
|
@@ -2253,8 +2305,8 @@ var Qe = () => {
|
|
|
2253
2305
|
e = !0;
|
|
2254
2306
|
};
|
|
2255
2307
|
}, [e, t]), n;
|
|
2256
|
-
},
|
|
2257
|
-
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"));
|
|
2258
2310
|
return {
|
|
2259
2311
|
table: t.name,
|
|
2260
2312
|
columns: t.columns,
|
|
@@ -2267,7 +2319,7 @@ var Qe = () => {
|
|
|
2267
2319
|
writeScope: `${t.name}:write`,
|
|
2268
2320
|
deleteScope: `${t.name}:delete`
|
|
2269
2321
|
};
|
|
2270
|
-
}),
|
|
2322
|
+
}), tr = (e) => {
|
|
2271
2323
|
let [t, r] = c([]), [i, a] = c([]), s = n((e) => {
|
|
2272
2324
|
r((t) => [...t, e]), a([]);
|
|
2273
2325
|
}, []), l = n(async () => {
|
|
@@ -2295,8 +2347,8 @@ var Qe = () => {
|
|
|
2295
2347
|
l,
|
|
2296
2348
|
u
|
|
2297
2349
|
]);
|
|
2298
|
-
},
|
|
2299
|
-
let r = t?.limit, { data: i } =
|
|
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) => {
|
|
2300
2352
|
await a.mutate({ invocationId: e });
|
|
2301
2353
|
}, [a]), d = n(async (e) => {
|
|
2302
2354
|
await o.mutate({ invocationId: e });
|
|
@@ -2315,13 +2367,13 @@ var Qe = () => {
|
|
|
2315
2367
|
undoLast: f,
|
|
2316
2368
|
redoLast: p
|
|
2317
2369
|
};
|
|
2318
|
-
},
|
|
2370
|
+
}, or = (e, t) => ({
|
|
2319
2371
|
name: e,
|
|
2320
2372
|
map: t
|
|
2321
|
-
}), $ = (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) => {
|
|
2322
2374
|
let r = { ...t };
|
|
2323
2375
|
for (let [i, a] of Object.entries(e.map)) {
|
|
2324
|
-
if (
|
|
2376
|
+
if (sr.has(i) || a === void 0) continue;
|
|
2325
2377
|
let e = t[i];
|
|
2326
2378
|
r[i] = (...r) => {
|
|
2327
2379
|
let i = $(a, t);
|
|
@@ -2329,7 +2381,7 @@ var Qe = () => {
|
|
|
2329
2381
|
};
|
|
2330
2382
|
}
|
|
2331
2383
|
return r;
|
|
2332
|
-
},
|
|
2384
|
+
}, lr = (e, t, n) => {
|
|
2333
2385
|
let r = s({
|
|
2334
2386
|
spec: e,
|
|
2335
2387
|
props: t,
|
|
@@ -2345,45 +2397,45 @@ var Qe = () => {
|
|
|
2345
2397
|
let e = r.current, t = $(e.spec.map.onUnmount, e.props);
|
|
2346
2398
|
t !== null && e.sink(t);
|
|
2347
2399
|
};
|
|
2348
|
-
}, []), o(() =>
|
|
2400
|
+
}, []), o(() => cr(e, t, n), [
|
|
2349
2401
|
e,
|
|
2350
2402
|
t,
|
|
2351
2403
|
n
|
|
2352
2404
|
]);
|
|
2353
|
-
},
|
|
2405
|
+
}, ur = (e, t) => {
|
|
2354
2406
|
let n = P(e).descriptors[t]?.input;
|
|
2355
2407
|
return o(() => n === void 0 ? [] : Q(n), [n]);
|
|
2356
|
-
},
|
|
2408
|
+
}, dr = (e, t) => {
|
|
2357
2409
|
let n = P(e).descriptors[t]?.output;
|
|
2358
|
-
return o(() => n === void 0 ? [] :
|
|
2359
|
-
},
|
|
2410
|
+
return o(() => n === void 0 ? [] : Bn(n), [n]);
|
|
2411
|
+
}, fr = (e, t) => {
|
|
2360
2412
|
if (e === t) return !0;
|
|
2361
2413
|
if (e.length !== t.length) return !1;
|
|
2362
2414
|
for (let n = 0; n < e.length; n += 1) if (!Object.is(e[n], t[n])) return !1;
|
|
2363
2415
|
return !0;
|
|
2364
|
-
},
|
|
2365
|
-
let n = s(null), r =
|
|
2366
|
-
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 = {
|
|
2367
2419
|
key: r,
|
|
2368
2420
|
value: t(e)
|
|
2369
2421
|
}), n.current.value;
|
|
2370
|
-
},
|
|
2371
|
-
function
|
|
2372
|
-
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);
|
|
2373
2425
|
}
|
|
2374
|
-
var
|
|
2375
|
-
let i =
|
|
2426
|
+
var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes, e), Cr = (e, t, n, r = {}) => {
|
|
2427
|
+
let i = U(e, t, { ...n }, r);
|
|
2376
2428
|
return o(() => ({
|
|
2377
2429
|
allowed: i.data?.allowed === !0,
|
|
2378
2430
|
pending: i.data === void 0
|
|
2379
2431
|
}), [i.data]);
|
|
2380
|
-
},
|
|
2381
|
-
let i =
|
|
2432
|
+
}, wr = (e, t, n, r = {}) => {
|
|
2433
|
+
let i = U(e, t, { ...n }, r);
|
|
2382
2434
|
return o(() => ({
|
|
2383
2435
|
allowedIds: new Set(i.data?.allowedIds ?? []),
|
|
2384
2436
|
pending: i.data === void 0
|
|
2385
2437
|
}), [i.data]);
|
|
2386
|
-
},
|
|
2438
|
+
}, Tr = (e) => {
|
|
2387
2439
|
switch (e) {
|
|
2388
2440
|
case "select":
|
|
2389
2441
|
case "radio":
|
|
@@ -2399,25 +2451,25 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2399
2451
|
case "switch": return "boolean";
|
|
2400
2452
|
default: return null;
|
|
2401
2453
|
}
|
|
2402
|
-
},
|
|
2403
|
-
let t =
|
|
2454
|
+
}, Er = (e) => Q(e).map((e) => {
|
|
2455
|
+
let t = Tr(e.widget);
|
|
2404
2456
|
return t === null ? null : {
|
|
2405
2457
|
name: e.name,
|
|
2406
2458
|
label: e.label,
|
|
2407
2459
|
kind: t,
|
|
2408
2460
|
...e.options ? { options: e.options } : {}
|
|
2409
2461
|
};
|
|
2410
|
-
}).filter((e) => e !== null),
|
|
2462
|
+
}).filter((e) => e !== null), Dr = (e) => {
|
|
2411
2463
|
let t = {};
|
|
2412
2464
|
for (let [n, r] of Object.entries(e)) r === void 0 || r === "" || Array.isArray(r) && r.length === 0 || (t[n] = r);
|
|
2413
2465
|
return t;
|
|
2414
|
-
},
|
|
2415
|
-
let i = P(e).descriptors[t]?.input, a = o(() => i === void 0 ? [] :
|
|
2416
|
-
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({
|
|
2417
2469
|
...n,
|
|
2418
2470
|
[e]: t
|
|
2419
2471
|
}));
|
|
2420
|
-
}, []), d = n(() => l({}), []), f =
|
|
2472
|
+
}, []), d = n(() => l({}), []), f = U(e, t, o(() => Dr(s), [s]));
|
|
2421
2473
|
return {
|
|
2422
2474
|
filters: a,
|
|
2423
2475
|
values: s,
|
|
@@ -2428,20 +2480,20 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2428
2480
|
loading: f.data === void 0,
|
|
2429
2481
|
error: f.error
|
|
2430
2482
|
};
|
|
2431
|
-
},
|
|
2432
|
-
let r =
|
|
2483
|
+
}, kr = (e, t, n = {}) => {
|
|
2484
|
+
let r = U(e, t, n), i = r.data;
|
|
2433
2485
|
return {
|
|
2434
2486
|
record: Array.isArray(i) ? i[0] : i,
|
|
2435
2487
|
loading: i === void 0,
|
|
2436
2488
|
error: r.error
|
|
2437
2489
|
};
|
|
2438
|
-
},
|
|
2490
|
+
}, Ar = (e, t = 300) => {
|
|
2439
2491
|
let [n, r] = c(e);
|
|
2440
2492
|
return a(() => {
|
|
2441
2493
|
let n = setTimeout(() => r(e), t);
|
|
2442
2494
|
return () => clearTimeout(n);
|
|
2443
2495
|
}, [e, t]), n;
|
|
2444
|
-
},
|
|
2496
|
+
}, jr = (e) => {
|
|
2445
2497
|
let { value: t, debouncedValue: n, data: r, interpret: i, skipEmpty: a = !0 } = e;
|
|
2446
2498
|
if (a && t.trim() === "") return {
|
|
2447
2499
|
status: "idle",
|
|
@@ -2459,39 +2511,39 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2459
2511
|
valid: o.valid,
|
|
2460
2512
|
message: o.message
|
|
2461
2513
|
};
|
|
2462
|
-
},
|
|
2463
|
-
let { input: i, interpret: a, debounceMs: s = 300, skipEmpty: c = !0 } = r, l =
|
|
2464
|
-
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({
|
|
2465
2517
|
value: n,
|
|
2466
2518
|
debouncedValue: l,
|
|
2467
2519
|
data: u ? null : d.data,
|
|
2468
2520
|
interpret: a,
|
|
2469
2521
|
skipEmpty: c
|
|
2470
2522
|
});
|
|
2471
|
-
},
|
|
2523
|
+
}, Nr = (e, t) => ({
|
|
2472
2524
|
name: e,
|
|
2473
2525
|
payload: t
|
|
2474
|
-
}),
|
|
2475
|
-
let n =
|
|
2526
|
+
}), Pr = (e, t) => {
|
|
2527
|
+
let n = b.decodeUnknownEither(e.payload, { errors: "all" })(t);
|
|
2476
2528
|
if (n._tag === "Right") return {
|
|
2477
2529
|
valid: !0,
|
|
2478
2530
|
errors: {}
|
|
2479
2531
|
};
|
|
2480
2532
|
let r = {};
|
|
2481
|
-
for (let e of
|
|
2533
|
+
for (let e of E.formatErrorSync(n.left)) r[e.path.join(".") || "(root)"] = e.message;
|
|
2482
2534
|
return {
|
|
2483
2535
|
valid: !1,
|
|
2484
2536
|
errors: r
|
|
2485
2537
|
};
|
|
2486
|
-
},
|
|
2538
|
+
}, Fr = (e) => {
|
|
2487
2539
|
let t = new Map(e.map((e) => [e.name, e]));
|
|
2488
2540
|
return {
|
|
2489
2541
|
names: [...t.keys()].sort(),
|
|
2490
2542
|
get: (e) => t.get(e),
|
|
2491
2543
|
events: e
|
|
2492
2544
|
};
|
|
2493
|
-
},
|
|
2494
|
-
let n =
|
|
2545
|
+
}, Ir = (e, t) => {
|
|
2546
|
+
let n = Fr(e);
|
|
2495
2547
|
return {
|
|
2496
2548
|
track: (e, r) => {
|
|
2497
2549
|
let i = n.get(e);
|
|
@@ -2500,7 +2552,7 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2500
2552
|
return;
|
|
2501
2553
|
}
|
|
2502
2554
|
if (process.env.NODE_ENV !== "production") {
|
|
2503
|
-
let t =
|
|
2555
|
+
let t = Pr(i, r);
|
|
2504
2556
|
t.valid || console.error(`[@voltro/client] analytics.track('${e}'): payload failed its schema`, t.errors);
|
|
2505
2557
|
}
|
|
2506
2558
|
t({
|
|
@@ -2511,42 +2563,42 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2511
2563
|
names: n.names,
|
|
2512
2564
|
catalog: n
|
|
2513
2565
|
};
|
|
2514
|
-
},
|
|
2515
|
-
let r =
|
|
2566
|
+
}, Lr = (e, t) => {
|
|
2567
|
+
let r = Y(e, t);
|
|
2516
2568
|
return {
|
|
2517
2569
|
preview: n((e) => r.run(e), [r]),
|
|
2518
2570
|
diff: r.lastResult,
|
|
2519
2571
|
pending: r.pending,
|
|
2520
2572
|
error: r.error
|
|
2521
2573
|
};
|
|
2522
|
-
},
|
|
2574
|
+
}, Rr = (e, t, n, r) => [...e, {
|
|
2523
2575
|
id: t,
|
|
2524
2576
|
tag: n,
|
|
2525
2577
|
input: r,
|
|
2526
2578
|
status: "pending",
|
|
2527
2579
|
attempts: 0
|
|
2528
|
-
}],
|
|
2580
|
+
}], zr = (e, t, n) => e.map((e) => e.id === t ? {
|
|
2529
2581
|
...e,
|
|
2530
2582
|
...n
|
|
2531
|
-
} : e),
|
|
2583
|
+
} : e), Br = (e, t) => zr(e, t, { status: "sent" }), Vr = (e, t, n) => e.map((e) => e.id === t ? {
|
|
2532
2584
|
...e,
|
|
2533
2585
|
status: "failed",
|
|
2534
2586
|
error: n,
|
|
2535
2587
|
attempts: e.attempts + 1
|
|
2536
|
-
} : e),
|
|
2588
|
+
} : e), Hr = (e, t, n) => zr(e, t, {
|
|
2537
2589
|
status: "conflict",
|
|
2538
2590
|
error: n
|
|
2539
|
-
}),
|
|
2591
|
+
}), Ur = (e) => e.filter((e) => e.status !== "sent"), Wr = (e) => {
|
|
2540
2592
|
let t = [];
|
|
2541
2593
|
for (let n of e) {
|
|
2542
2594
|
if (n.status === "conflict") break;
|
|
2543
2595
|
(n.status === "pending" || n.status === "failed") && t.push(n);
|
|
2544
2596
|
}
|
|
2545
2597
|
return t;
|
|
2546
|
-
},
|
|
2598
|
+
}, Gr = (e) => {
|
|
2547
2599
|
let t = e;
|
|
2548
2600
|
return t?.conflict === !0 || t?._tag === "UndoBoundaryError" && t?.boundary === "conflict";
|
|
2549
|
-
},
|
|
2601
|
+
}, Kr = (e) => {
|
|
2550
2602
|
let [t, n] = c(e ?? (typeof navigator < "u" ? navigator.onLine : !0));
|
|
2551
2603
|
return a(() => {
|
|
2552
2604
|
if (e !== void 0) {
|
|
@@ -2559,21 +2611,21 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2559
2611
|
window.removeEventListener("online", t), window.removeEventListener("offline", r);
|
|
2560
2612
|
};
|
|
2561
2613
|
}, [e]), t;
|
|
2562
|
-
},
|
|
2563
|
-
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);
|
|
2564
2616
|
d.current = o;
|
|
2565
2617
|
let f = s(0), p = n((e, t) => {
|
|
2566
2618
|
let n = i?.() ?? `obx_${f.current++}_${e}`;
|
|
2567
|
-
l((r) =>
|
|
2619
|
+
l((r) => Rr(r, n, e, t));
|
|
2568
2620
|
}, [i]), m = n(async () => {
|
|
2569
|
-
for (let e of
|
|
2570
|
-
await t(e), l((t) =>
|
|
2621
|
+
for (let e of Wr(d.current)) try {
|
|
2622
|
+
await t(e), l((t) => Br(t, e.id));
|
|
2571
2623
|
} catch (t) {
|
|
2572
2624
|
if (r(t)) {
|
|
2573
|
-
l((n) =>
|
|
2625
|
+
l((n) => Hr(n, e.id, t));
|
|
2574
2626
|
break;
|
|
2575
2627
|
}
|
|
2576
|
-
l((n) =>
|
|
2628
|
+
l((n) => Vr(n, e.id, t));
|
|
2577
2629
|
}
|
|
2578
2630
|
}, [t, r]);
|
|
2579
2631
|
return a(() => {
|
|
@@ -2586,7 +2638,7 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2586
2638
|
pending: o.filter((e) => e.status === "pending" || e.status === "failed").length,
|
|
2587
2639
|
conflicts: o.filter((e) => e.status === "conflict")
|
|
2588
2640
|
};
|
|
2589
|
-
},
|
|
2641
|
+
}, Jr = (e) => {
|
|
2590
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);
|
|
2591
2643
|
return {
|
|
2592
2644
|
startIndex: l,
|
|
@@ -2596,8 +2648,8 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2596
2648
|
topSpacer: l * r,
|
|
2597
2649
|
bottomSpacer: a === void 0 ? 0 : Math.max(0, (a - d) * r)
|
|
2598
2650
|
};
|
|
2599
|
-
},
|
|
2600
|
-
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({
|
|
2601
2653
|
scrollTop: d,
|
|
2602
2654
|
viewportHeight: a,
|
|
2603
2655
|
rowHeight: i,
|
|
@@ -2609,7 +2661,7 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2609
2661
|
i,
|
|
2610
2662
|
s,
|
|
2611
2663
|
l
|
|
2612
|
-
]), m =
|
|
2664
|
+
]), m = U(e, t, o(() => ({
|
|
2613
2665
|
...u,
|
|
2614
2666
|
offset: p.offset,
|
|
2615
2667
|
limit: p.limit
|
|
@@ -2629,8 +2681,8 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2629
2681
|
loading: m.data === void 0,
|
|
2630
2682
|
error: m.error
|
|
2631
2683
|
};
|
|
2632
|
-
},
|
|
2633
|
-
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);
|
|
2634
2686
|
a(() => (f.current = !0, () => {
|
|
2635
2687
|
f.current = !1;
|
|
2636
2688
|
}), []), a(() => {
|
|
@@ -2656,7 +2708,7 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2656
2708
|
lastFailureAt: u,
|
|
2657
2709
|
reportSuccess: p
|
|
2658
2710
|
};
|
|
2659
|
-
},
|
|
2711
|
+
}, Qr = "__voltro.connections.list", $r = "__voltro.connections.start", ei = "__voltro.connections.submitToken", ti = "__voltro.connections.disconnect", ni = {
|
|
2660
2712
|
connectionId: "",
|
|
2661
2713
|
kind: "oauth2",
|
|
2662
2714
|
label: "",
|
|
@@ -2667,14 +2719,14 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2667
2719
|
expiresAt: null,
|
|
2668
2720
|
lastError: null,
|
|
2669
2721
|
connectedAt: null
|
|
2670
|
-
},
|
|
2722
|
+
}, ri = (e, t) => {
|
|
2671
2723
|
if (t === "redirect") {
|
|
2672
2724
|
globalThis.location.assign(e);
|
|
2673
2725
|
return;
|
|
2674
2726
|
}
|
|
2675
2727
|
globalThis.open(e, "voltro-connect", "width=620,height=760,menubar=no,toolbar=no") === null && globalThis.location.assign(e);
|
|
2676
|
-
},
|
|
2677
|
-
let { data: t } =
|
|
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) => ({
|
|
2678
2730
|
...e,
|
|
2679
2731
|
connected: e.status === "connected",
|
|
2680
2732
|
needsAttention: e.status === "expired" || e.status === "revoked" || e.status === "error",
|
|
@@ -2682,7 +2734,7 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2682
2734
|
connect: async (t) => {
|
|
2683
2735
|
if (e.kind !== "oauth2") throw Error(`connection "${e.connectionId}" is a personal-access-token connection — call submitToken(token), not connect().`);
|
|
2684
2736
|
let n = t?.redirectTo ?? `${globalThis.location.pathname}${globalThis.location.search}`;
|
|
2685
|
-
|
|
2737
|
+
ri((await r.run({
|
|
2686
2738
|
connectionId: e.connectionId,
|
|
2687
2739
|
redirectTo: n
|
|
2688
2740
|
})).authorizeUrl, t?.mode);
|
|
@@ -2712,10 +2764,10 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2712
2764
|
get: l,
|
|
2713
2765
|
pending: s
|
|
2714
2766
|
};
|
|
2715
|
-
},
|
|
2716
|
-
let n =
|
|
2767
|
+
}, ai = (e, t) => {
|
|
2768
|
+
let n = ii(e), r = n.get(t);
|
|
2717
2769
|
return o(() => r === void 0 ? {
|
|
2718
|
-
...
|
|
2770
|
+
...ni,
|
|
2719
2771
|
connectionId: t,
|
|
2720
2772
|
label: t,
|
|
2721
2773
|
connected: !1,
|
|
@@ -2740,6 +2792,6 @@ var nr = () => r(er), rr = (e) => Qn(nr().scopes, e), ir = (e) => $n(nr().scopes
|
|
|
2740
2792
|
n.loading,
|
|
2741
2793
|
n.pending
|
|
2742
2794
|
]);
|
|
2743
|
-
},
|
|
2795
|
+
}, oi = "framework-client";
|
|
2744
2796
|
//#endregion
|
|
2745
|
-
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 };
|