@voltro/client 0.33.0 → 0.35.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 +1968 -0
- package/dist/index.d.ts +328 -26
- package/dist/index.js +646 -579
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -115,7 +115,7 @@ var ne = /* @__PURE__ */ new Set(), D = (e) => {
|
|
|
115
115
|
return n === null ? null : (e) => (Array.isArray(e) ? e : []).filter((e) => !n.has(e.id));
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
}, fe = 5e3,
|
|
118
|
+
}, fe = 5e3, pe = class {
|
|
119
119
|
entries = /* @__PURE__ */ new Map();
|
|
120
120
|
inactiveTtlMs;
|
|
121
121
|
onChangeHook;
|
|
@@ -231,6 +231,32 @@ var ne = /* @__PURE__ */ new Set(), D = (e) => {
|
|
|
231
231
|
t.state = this.freshState(), t.state.patches = n, this.startFiber(t, t.fetch, e);
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
|
+
seedStaleFrom(e) {
|
|
235
|
+
let t = 0;
|
|
236
|
+
for (let n of e.entries.values()) {
|
|
237
|
+
if (n.state.base === void 0 || this.entries.has(n.key)) continue;
|
|
238
|
+
let e = {
|
|
239
|
+
key: n.key,
|
|
240
|
+
tag: n.tag,
|
|
241
|
+
state: {
|
|
242
|
+
base: n.state.base,
|
|
243
|
+
baseRevision: n.state.baseRevision,
|
|
244
|
+
baseEmittedAt: n.state.baseEmittedAt,
|
|
245
|
+
baseError: void 0,
|
|
246
|
+
patches: [],
|
|
247
|
+
cachedSnapshot: null
|
|
248
|
+
},
|
|
249
|
+
subscribers: /* @__PURE__ */ new Set(),
|
|
250
|
+
fiber: null,
|
|
251
|
+
evictionTimer: null,
|
|
252
|
+
source: n.source,
|
|
253
|
+
computed: n.computed,
|
|
254
|
+
fetch: null
|
|
255
|
+
};
|
|
256
|
+
this.entries.set(e.key, e), this.scheduleEviction(e), t += 1;
|
|
257
|
+
}
|
|
258
|
+
return t;
|
|
259
|
+
}
|
|
234
260
|
create(e, t, n, r, i) {
|
|
235
261
|
let a = {
|
|
236
262
|
key: e,
|
|
@@ -318,19 +344,22 @@ var ne = /* @__PURE__ */ new Set(), D = (e) => {
|
|
|
318
344
|
}
|
|
319
345
|
unsubscribe(e, t) {
|
|
320
346
|
let n = this.entries.get(e);
|
|
321
|
-
n && (n.subscribers.delete(t), !(n.subscribers.size > 0) &&
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
347
|
+
n && (n.subscribers.delete(t), !(n.subscribers.size > 0) && this.scheduleEviction(n));
|
|
348
|
+
}
|
|
349
|
+
scheduleEviction(e) {
|
|
350
|
+
e.evictionTimer !== null && clearTimeout(e.evictionTimer), e.evictionTimer = setTimeout(() => {
|
|
351
|
+
let t = this.entries.get(e.key);
|
|
352
|
+
t && t.subscribers.size === 0 && (t.fiber && p.runFork(h.interrupt(t.fiber)), this.entries.delete(e.key));
|
|
353
|
+
}, this.inactiveTtlMs);
|
|
325
354
|
}
|
|
326
|
-
},
|
|
355
|
+
}, me = class extends pe {
|
|
327
356
|
subscribe(e, t, n, r, i = {}) {
|
|
328
357
|
return {
|
|
329
358
|
getSnapshot: () => this.peek(e),
|
|
330
359
|
unsubscribe: () => {}
|
|
331
360
|
};
|
|
332
361
|
}
|
|
333
|
-
},
|
|
362
|
+
}, he = class {
|
|
334
363
|
#e = /* @__PURE__ */ new Set();
|
|
335
364
|
on(e) {
|
|
336
365
|
return this.#e.add(e), () => {
|
|
@@ -342,45 +371,45 @@ var ne = /* @__PURE__ */ new Set(), D = (e) => {
|
|
|
342
371
|
t(e);
|
|
343
372
|
} catch {}
|
|
344
373
|
}
|
|
345
|
-
},
|
|
374
|
+
}, ge = e(null), _e = () => {
|
|
346
375
|
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");
|
|
347
|
-
},
|
|
348
|
-
get: (e, t) =>
|
|
376
|
+
}, ve = new Proxy(() => _e(), {
|
|
377
|
+
get: (e, t) => ve,
|
|
349
378
|
has: () => !0,
|
|
350
|
-
apply: () =>
|
|
351
|
-
}),
|
|
352
|
-
runtime: {
|
|
353
|
-
cache: new
|
|
354
|
-
client:
|
|
379
|
+
apply: () => _e()
|
|
380
|
+
}), ye = {
|
|
381
|
+
runtime: { runPromiseExit: () => Promise.resolve(m.die(/* @__PURE__ */ Error("Voltro: mutations are not invokable during SSR"))) },
|
|
382
|
+
cache: new me(),
|
|
383
|
+
client: ve,
|
|
355
384
|
descriptors: {},
|
|
356
385
|
inspectBaseUrl: "",
|
|
357
|
-
errorBus: new
|
|
358
|
-
},
|
|
359
|
-
get: () =>
|
|
386
|
+
errorBus: new he()
|
|
387
|
+
}, be = {
|
|
388
|
+
get: () => ye,
|
|
360
389
|
names: []
|
|
361
|
-
},
|
|
362
|
-
|
|
363
|
-
},
|
|
364
|
-
let e = r(
|
|
365
|
-
return e ? (
|
|
366
|
-
|
|
367
|
-
}, 0)),
|
|
368
|
-
},
|
|
390
|
+
}, A = !1, j = !1, M = null, xe = () => {
|
|
391
|
+
A = !1, j = !1, M !== null && (clearTimeout(M), M = null);
|
|
392
|
+
}, Se = () => {
|
|
393
|
+
let e = r(ge);
|
|
394
|
+
return e ? (j || (j = !0, M !== null && (clearTimeout(M), M = null)), e) : (typeof window < "u" && !A && !j && M === null && process.env.NODE_ENV !== "production" && (M = setTimeout(() => {
|
|
395
|
+
M = null, !(A || j) && (A = !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>."));
|
|
396
|
+
}, 0)), be);
|
|
397
|
+
}, N = (e) => Se().get(e), P = (e) => typeof e.runtime?.runFork != "function", Ce = async (e) => {
|
|
369
398
|
let { name: t, wsUrl: n, group: r, headers: i, webSocketConstructor: a } = e;
|
|
370
399
|
class o extends d.Tag(`@voltro/client/AppClient/${t}`)() {}
|
|
371
400
|
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
401
|
try {
|
|
373
|
-
let e = await p.runPromise(o), t = new
|
|
402
|
+
let e = await p.runPromise(o), t = new he();
|
|
374
403
|
return {
|
|
375
404
|
runtime: p,
|
|
376
405
|
client: e,
|
|
377
|
-
cache: new
|
|
406
|
+
cache: new pe({ errorBus: t }),
|
|
378
407
|
errorBus: t
|
|
379
408
|
};
|
|
380
409
|
} catch (e) {
|
|
381
410
|
throw p.dispose(), e;
|
|
382
411
|
}
|
|
383
|
-
},
|
|
412
|
+
}, we = ({ apis: e, children: t }) => {
|
|
384
413
|
let n = o(() => ({
|
|
385
414
|
get: (t) => {
|
|
386
415
|
let n = e.get(t);
|
|
@@ -392,21 +421,21 @@ var ne = /* @__PURE__ */ new Set(), D = (e) => {
|
|
|
392
421
|
},
|
|
393
422
|
names: Array.from(e.keys())
|
|
394
423
|
}), [e]);
|
|
395
|
-
return /* @__PURE__ */ te(
|
|
424
|
+
return /* @__PURE__ */ te(ge.Provider, {
|
|
396
425
|
value: n,
|
|
397
426
|
children: t
|
|
398
427
|
});
|
|
399
|
-
},
|
|
428
|
+
}, F = (e, t) => {
|
|
400
429
|
if (Object.is(e, t)) return !0;
|
|
401
430
|
if (typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
|
|
402
431
|
let n = Object.keys(e), r = Object.keys(t);
|
|
403
432
|
if (n.length !== r.length) return !1;
|
|
404
433
|
for (let r of n) if (!Object.prototype.hasOwnProperty.call(t, r) || !Object.is(e[r], t[r])) return !1;
|
|
405
434
|
return !0;
|
|
406
|
-
},
|
|
407
|
-
|
|
408
|
-
},
|
|
409
|
-
let r =
|
|
435
|
+
}, Te = 50, Ee = /* @__PURE__ */ new Set(), De = (e, t) => {
|
|
436
|
+
Ee.has(e) || (Ee.add(e), console.warn(t));
|
|
437
|
+
}, Oe = "\0global", ke = null, Ae = (e, t, n) => {
|
|
438
|
+
let r = ke?.() ?? null;
|
|
410
439
|
if (r === null) return n;
|
|
411
440
|
let i = n;
|
|
412
441
|
for (let n of r.seeds) n.store !== e || n.key !== t || (i = {
|
|
@@ -414,9 +443,9 @@ var ne = /* @__PURE__ */ new Set(), D = (e) => {
|
|
|
414
443
|
...n.value
|
|
415
444
|
});
|
|
416
445
|
return i;
|
|
417
|
-
},
|
|
446
|
+
}, je = (e, t) => {
|
|
418
447
|
let n = e(), r = /* @__PURE__ */ new Set(), i = 0, a = 0, o, s, c = () => {
|
|
419
|
-
if (i >=
|
|
448
|
+
if (i >= Te) throw i = 0, Error(`defineStore: notification depth exceeded ${Te} — 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.`);
|
|
420
449
|
i += 1;
|
|
421
450
|
try {
|
|
422
451
|
for (let e of [...r]) e();
|
|
@@ -437,20 +466,20 @@ var ne = /* @__PURE__ */ new Set(), D = (e) => {
|
|
|
437
466
|
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}', () => { … })\`.`);
|
|
438
467
|
if (--a, a > 0) return;
|
|
439
468
|
let l = o, u = s;
|
|
440
|
-
o = void 0, s = void 0, !
|
|
469
|
+
o = void 0, s = void 0, !F(l, n) && (t(l, n, u), c());
|
|
441
470
|
},
|
|
442
471
|
set: (e, r) => {
|
|
443
472
|
let i = typeof e == "function" ? e(n) : {
|
|
444
473
|
...n,
|
|
445
474
|
...e
|
|
446
475
|
};
|
|
447
|
-
if (
|
|
476
|
+
if (F(i, n)) return;
|
|
448
477
|
let o = n;
|
|
449
478
|
n = i, !(a > 0) && (t(o, i, r), c());
|
|
450
479
|
},
|
|
451
480
|
reset: () => {
|
|
452
481
|
let r = e();
|
|
453
|
-
if (
|
|
482
|
+
if (F(r, n)) return;
|
|
454
483
|
let i = n;
|
|
455
484
|
n = r, !(a > 0) && (t(i, r, "reset"), c());
|
|
456
485
|
},
|
|
@@ -458,47 +487,47 @@ var ne = /* @__PURE__ */ new Set(), D = (e) => {
|
|
|
458
487
|
r.delete(e);
|
|
459
488
|
})
|
|
460
489
|
};
|
|
461
|
-
},
|
|
462
|
-
|
|
463
|
-
}),
|
|
464
|
-
|
|
465
|
-
},
|
|
466
|
-
let n =
|
|
490
|
+
}, Me = 200, I = [], Ne = /* @__PURE__ */ new Set(), Pe = [], Fe = () => Pe, Ie = (e) => (Ne.add(e), () => {
|
|
491
|
+
Ne.delete(e);
|
|
492
|
+
}), Le = () => {
|
|
493
|
+
I.length = 0, Pe = [];
|
|
494
|
+
}, Re = (e, t) => {
|
|
495
|
+
let n = I[e];
|
|
467
496
|
if (n === void 0) return !1;
|
|
468
|
-
let r =
|
|
497
|
+
let r = z.get(n.store);
|
|
469
498
|
if (r === void 0) return !1;
|
|
470
499
|
let i = t === "before" ? n.prev : n.next;
|
|
471
|
-
|
|
500
|
+
R = !0;
|
|
472
501
|
try {
|
|
473
502
|
r.set(() => i, n.key, `travel:${t}`);
|
|
474
503
|
} finally {
|
|
475
|
-
|
|
504
|
+
R = !1;
|
|
476
505
|
}
|
|
477
506
|
return !0;
|
|
478
|
-
},
|
|
479
|
-
|
|
480
|
-
for (let e of [...
|
|
481
|
-
},
|
|
482
|
-
|
|
483
|
-
})),
|
|
484
|
-
function
|
|
507
|
+
}, L = !1, R = !1, ze = (e) => {
|
|
508
|
+
I.push(e), I.length > Me && I.shift(), Pe = [...I];
|
|
509
|
+
for (let e of [...Ne]) e();
|
|
510
|
+
}, z = /* @__PURE__ */ new Map(), Be = /* @__PURE__ */ new Map(), Ve = 0, He = !1, Ue = /* @__PURE__ */ new Map(), We = () => (He || (He = !0, queueMicrotask(() => {
|
|
511
|
+
Ve += 1, He = !1;
|
|
512
|
+
})), Ve), Ge = Ke(((/* @__PURE__ */ Error()).stack ?? "").split("\n")[1] ?? "") ?? "";
|
|
513
|
+
function Ke(e) {
|
|
485
514
|
let t = e.trim().replace(/^at\s+/, ""), n = /\(([^()]+)\)\s*$/.exec(t)?.[1] ?? t;
|
|
486
515
|
return n.length > 0 ? n : void 0;
|
|
487
516
|
}
|
|
488
|
-
var
|
|
517
|
+
var qe = () => {
|
|
489
518
|
let e = (/* @__PURE__ */ Error()).stack;
|
|
490
519
|
if (typeof e != "string") return "<unknown>";
|
|
491
520
|
for (let t of e.split("\n").slice(1)) {
|
|
492
|
-
let e =
|
|
521
|
+
let e = Ke(t);
|
|
493
522
|
if (e === void 0) continue;
|
|
494
523
|
let n = e.replace(/:\d+:\d+$/, "");
|
|
495
|
-
if (!(
|
|
524
|
+
if (!(Ge !== "" && n === Ge.replace(/:\d+:\d+$/, ""))) return n;
|
|
496
525
|
}
|
|
497
526
|
return "<unknown>";
|
|
498
|
-
},
|
|
499
|
-
let a =
|
|
527
|
+
}, Je = () => [...z.values()], Ye = (e, t, r) => {
|
|
528
|
+
let a = qe(), o = We(), c = z.get(e);
|
|
500
529
|
if (c !== void 0) {
|
|
501
|
-
let t =
|
|
530
|
+
let t = Be.get(e) ?? "<unknown>", n = Ue.get(e) === o;
|
|
502
531
|
if (a !== "<unknown>" && a === t && !n) return c;
|
|
503
532
|
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}`);
|
|
504
533
|
}
|
|
@@ -534,28 +563,28 @@ var Ge = () => {
|
|
|
534
563
|
t.setItem(u.key, JSON.stringify(n));
|
|
535
564
|
} catch {}
|
|
536
565
|
}, m = /* @__PURE__ */ new Map(), h = (n) => {
|
|
537
|
-
let r = n ??
|
|
566
|
+
let r = n ?? Oe, i = m.get(r);
|
|
538
567
|
if (i === void 0) {
|
|
539
568
|
let a = n;
|
|
540
|
-
i =
|
|
569
|
+
i = je(u !== void 0 && n === void 0 ? () => {
|
|
541
570
|
let e = t();
|
|
542
571
|
return g = e, {
|
|
543
572
|
...e,
|
|
544
573
|
...f() ?? {}
|
|
545
574
|
};
|
|
546
575
|
} : t, (t, n, r) => {
|
|
547
|
-
if (u !== void 0 && a === void 0 && p(n), !
|
|
576
|
+
if (u !== void 0 && a === void 0 && p(n), !L && !R) {
|
|
548
577
|
let e = v(a);
|
|
549
578
|
e.steps.length = e.cursor, e.steps.push({
|
|
550
579
|
prev: t,
|
|
551
580
|
next: n
|
|
552
581
|
}), e.steps.length > y && e.steps.shift(), e.cursor = e.steps.length;
|
|
553
582
|
}
|
|
554
|
-
|
|
583
|
+
ze({
|
|
555
584
|
store: e,
|
|
556
585
|
...a === void 0 ? {} : { key: a },
|
|
557
586
|
...r === void 0 ? {} : { label: r },
|
|
558
|
-
...
|
|
587
|
+
...L || R ? { isUndo: !0 } : {},
|
|
559
588
|
prev: t,
|
|
560
589
|
next: n,
|
|
561
590
|
at: Date.now()
|
|
@@ -564,7 +593,7 @@ var Ge = () => {
|
|
|
564
593
|
}
|
|
565
594
|
return i;
|
|
566
595
|
}, g, _ = /* @__PURE__ */ new Map(), v = (e) => {
|
|
567
|
-
let t = e ??
|
|
596
|
+
let t = e ?? Oe, n = _.get(t);
|
|
568
597
|
return n === void 0 && (n = {
|
|
569
598
|
steps: [],
|
|
570
599
|
cursor: 0
|
|
@@ -596,7 +625,7 @@ var Ge = () => {
|
|
|
596
625
|
let n = u.current;
|
|
597
626
|
if (n.has && Object.is(n.state, t)) return n.value;
|
|
598
627
|
let r = o.current(t), i = c.current, a = n.has && (i ? i(n.value, r) : Object.is(n.value, r));
|
|
599
|
-
process.env.NODE_ENV !== "production" && i === void 0 && n.has && !a && typeof r == "object" && r &&
|
|
628
|
+
process.env.NODE_ENV !== "production" && i === void 0 && n.has && !a && typeof r == "object" && r && F(n.value, r) && De(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.`);
|
|
600
629
|
let s = a ? n.value : r;
|
|
601
630
|
return u.current = {
|
|
602
631
|
state: t,
|
|
@@ -612,7 +641,7 @@ var Ge = () => {
|
|
|
612
641
|
a,
|
|
613
642
|
f,
|
|
614
643
|
p
|
|
615
|
-
]), n(() => d(a.get()), [a, d]), n(() => d(
|
|
644
|
+
]), n(() => d(a.get()), [a, d]), n(() => d(Ae(e, r?.key, r?.key === void 0 && g !== void 0 ? g : a.get())), [
|
|
616
645
|
a,
|
|
617
646
|
r?.key,
|
|
618
647
|
d
|
|
@@ -630,11 +659,11 @@ var Ge = () => {
|
|
|
630
659
|
undo: (e) => {
|
|
631
660
|
let t = v(e);
|
|
632
661
|
if (t.cursor === 0) return !1;
|
|
633
|
-
--t.cursor,
|
|
662
|
+
--t.cursor, L = !0;
|
|
634
663
|
try {
|
|
635
664
|
h(e).set(() => t.steps[t.cursor].prev, "undo");
|
|
636
665
|
} finally {
|
|
637
|
-
|
|
666
|
+
L = !1;
|
|
638
667
|
}
|
|
639
668
|
return !0;
|
|
640
669
|
},
|
|
@@ -642,11 +671,11 @@ var Ge = () => {
|
|
|
642
671
|
let t = v(e);
|
|
643
672
|
if (t.cursor >= t.steps.length) return !1;
|
|
644
673
|
let n = t.steps[t.cursor];
|
|
645
|
-
t.cursor += 1,
|
|
674
|
+
t.cursor += 1, L = !0;
|
|
646
675
|
try {
|
|
647
676
|
h(e).set(() => n.next, "redo");
|
|
648
677
|
} finally {
|
|
649
|
-
|
|
678
|
+
L = !1;
|
|
650
679
|
}
|
|
651
680
|
return !0;
|
|
652
681
|
},
|
|
@@ -658,27 +687,27 @@ var Ge = () => {
|
|
|
658
687
|
release: (e) => {
|
|
659
688
|
m.delete(e), _.delete(e);
|
|
660
689
|
},
|
|
661
|
-
keys: () => [...m.keys()].filter((e) => e !==
|
|
690
|
+
keys: () => [...m.keys()].filter((e) => e !== Oe)
|
|
662
691
|
};
|
|
663
|
-
return
|
|
664
|
-
},
|
|
665
|
-
|
|
666
|
-
},
|
|
667
|
-
|
|
668
|
-
},
|
|
669
|
-
let r =
|
|
692
|
+
return z.set(e, w), Be.set(e, a), Ue.set(e, o), w;
|
|
693
|
+
}, Xe = () => {
|
|
694
|
+
z.clear(), Be.clear(), Ue.clear(), Ee.clear();
|
|
695
|
+
}, Ze = () => ({ seeds: [] }), Qe = (e) => {
|
|
696
|
+
ke = e;
|
|
697
|
+
}, $e = (e, t, n) => {
|
|
698
|
+
let r = ke?.() ?? null;
|
|
670
699
|
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.)`);
|
|
671
700
|
r.seeds.push({
|
|
672
701
|
store: e.name,
|
|
673
702
|
...n?.key === void 0 ? {} : { key: n.key },
|
|
674
703
|
value: t
|
|
675
704
|
});
|
|
676
|
-
},
|
|
705
|
+
}, et = (e) => {
|
|
677
706
|
if (e !== void 0) for (let t of e) {
|
|
678
|
-
let e =
|
|
707
|
+
let e = z.get(t.store);
|
|
679
708
|
e !== void 0 && e.set(t.value, t.key);
|
|
680
709
|
}
|
|
681
|
-
},
|
|
710
|
+
}, B = (e, t) => {
|
|
682
711
|
let n = t.split("."), r = e;
|
|
683
712
|
for (let e = 0; e < n.length; e++) {
|
|
684
713
|
let i = n[e];
|
|
@@ -697,29 +726,35 @@ var Ge = () => {
|
|
|
697
726
|
}
|
|
698
727
|
if (typeof r != "function") throw Error(`@voltro/client: rpc tag ${JSON.stringify(t)} did not resolve to a callable method.`);
|
|
699
728
|
return r;
|
|
700
|
-
},
|
|
729
|
+
}, tt = Object.freeze({
|
|
701
730
|
data: void 0,
|
|
702
731
|
revision: -1,
|
|
703
732
|
emittedAt: void 0,
|
|
704
733
|
error: void 0,
|
|
705
734
|
pendingPatches: 0
|
|
706
|
-
}),
|
|
707
|
-
function
|
|
708
|
-
let a = i.skip === !0, { runtime: c, cache: u, client: d, descriptors: f } =
|
|
735
|
+
}), nt = () => tt;
|
|
736
|
+
function V(e, t, r = {}, i = {}) {
|
|
737
|
+
let a = i.skip === !0, { runtime: c, cache: u, client: d, descriptors: f } = N(e), p = f[t]?.source, m = s(r);
|
|
709
738
|
m.current = r;
|
|
710
739
|
let h = s(d);
|
|
711
740
|
h.current = d;
|
|
712
|
-
let g =
|
|
741
|
+
let g = o(() => {
|
|
742
|
+
let e = m.current;
|
|
743
|
+
return {
|
|
744
|
+
queryKey: [t, e],
|
|
745
|
+
fetch: () => B(h.current, t)(e)
|
|
746
|
+
};
|
|
747
|
+
}, [t, o(() => JSON.stringify(Object.entries(r).sort(([e], [t]) => e.localeCompare(t))), [r])]), _ = g.queryKey, v = l(n((e) => a ? () => {} : u.subscribe(g.queryKey, g.fetch, c, e, p === void 0 ? {} : { source: p }).unsubscribe, [
|
|
713
748
|
u,
|
|
714
749
|
c,
|
|
715
750
|
p,
|
|
716
751
|
a,
|
|
717
|
-
|
|
718
|
-
]), n(() => a ?
|
|
752
|
+
g
|
|
753
|
+
]), n(() => a ? tt : u.peek(_), [
|
|
719
754
|
u,
|
|
720
755
|
a,
|
|
721
756
|
_
|
|
722
|
-
]),
|
|
757
|
+
]), nt), y = v.data !== void 0, b = y && (Array.isArray(v.data) ? v.data.length === 0 : v.data === null), x = {
|
|
723
758
|
revision: v.revision,
|
|
724
759
|
emittedAt: v.emittedAt,
|
|
725
760
|
error: v.error,
|
|
@@ -762,49 +797,289 @@ function U(e, t, r = {}, i = {}) {
|
|
|
762
797
|
};
|
|
763
798
|
}
|
|
764
799
|
//#endregion
|
|
765
|
-
//#region src/
|
|
766
|
-
var
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
800
|
+
//#region src/runRpc.ts
|
|
801
|
+
var H = async (e, t) => {
|
|
802
|
+
let n = await e.runPromiseExit(t);
|
|
803
|
+
if (m.isSuccess(n)) return n.value;
|
|
804
|
+
throw u.squash(n.cause);
|
|
805
|
+
}, rt = 100, U = [], it = /* @__PURE__ */ new Set(), at = [], ot = () => {
|
|
806
|
+
at = U.slice();
|
|
807
|
+
}, st = () => {
|
|
808
|
+
ot();
|
|
809
|
+
for (let e of it) try {
|
|
810
|
+
e();
|
|
811
|
+
} catch {}
|
|
812
|
+
}, ct = (e) => {
|
|
813
|
+
let t = {
|
|
814
|
+
...e,
|
|
815
|
+
status: "pending",
|
|
816
|
+
startedAt: Date.now()
|
|
817
|
+
};
|
|
818
|
+
U.unshift(t), U.length > rt && (U.length = rt), st();
|
|
819
|
+
}, W = (e, t) => {
|
|
820
|
+
let n = U.findIndex((t) => t.id === e);
|
|
821
|
+
if (n === -1) return;
|
|
822
|
+
let r = U[n], i = Date.now();
|
|
823
|
+
U[n] = t.status === "success" ? {
|
|
824
|
+
...r,
|
|
825
|
+
status: "success",
|
|
826
|
+
output: t.output,
|
|
827
|
+
settledAt: i,
|
|
828
|
+
durationMs: i - r.startedAt
|
|
829
|
+
} : {
|
|
830
|
+
...r,
|
|
831
|
+
status: "error",
|
|
832
|
+
error: t.error,
|
|
833
|
+
settledAt: i,
|
|
834
|
+
durationMs: i - r.startedAt
|
|
835
|
+
}, st();
|
|
836
|
+
}, lt = () => at, ut = (e) => (it.add(e), () => {
|
|
837
|
+
it.delete(e);
|
|
838
|
+
}), dt = () => {
|
|
839
|
+
U.length !== 0 && (U.length = 0, st());
|
|
840
|
+
}, ft = (e, t) => {
|
|
841
|
+
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
842
|
+
try {
|
|
843
|
+
Object.defineProperty(e, "__voltroTraceId", {
|
|
844
|
+
value: t,
|
|
845
|
+
enumerable: !1,
|
|
846
|
+
configurable: !0
|
|
847
|
+
});
|
|
848
|
+
} catch {}
|
|
849
|
+
return e;
|
|
850
|
+
}, G, pt = (e) => {
|
|
851
|
+
G = e;
|
|
852
|
+
}, mt = () => G, ht = (e, t, n) => typeof e == "function" ? e(t, n) : e, gt = 0, _t = () => `mut_${++gt}`, vt = 0, yt = () => {
|
|
853
|
+
let e = typeof crypto < "u" ? crypto : void 0;
|
|
854
|
+
return e && typeof e.randomUUID == "function" ? e.randomUUID() : `idem_${Date.now().toString(36)}_${vt += 1}`;
|
|
855
|
+
}, bt = (e, t) => e.pipe(p.locallyWith(T.currentHeaders, (e) => w.set(e, "idempotency-key", t))), xt = (e, t) => ({
|
|
856
|
+
update: (n, r) => {
|
|
857
|
+
e.update(n, r, t);
|
|
858
|
+
},
|
|
859
|
+
forTag: (n, r) => e.forTag(n, r, t)
|
|
860
|
+
}), K = (e, t) => {
|
|
861
|
+
let { runtime: r, cache: i, client: a, descriptors: l, errorBus: u } = N(e), d = l[t], f = d?.targets;
|
|
862
|
+
if (process.env.NODE_ENV !== "production") {
|
|
863
|
+
let n = d?.kind;
|
|
864
|
+
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.`);
|
|
865
|
+
}
|
|
866
|
+
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) => {
|
|
867
|
+
let s = o?.onError !== void 0 || o?.notify?.error !== void 0, c = (e) => {
|
|
868
|
+
o?.onError?.(e, n);
|
|
869
|
+
let t = ht(o?.notify?.error, e, n);
|
|
870
|
+
t !== void 0 && G?.error(t);
|
|
871
|
+
};
|
|
872
|
+
h(!0), _(void 0);
|
|
873
|
+
let l = _t(), d = o?.idempotencyKey ?? yt();
|
|
874
|
+
ct({
|
|
875
|
+
id: l,
|
|
876
|
+
apiName: e,
|
|
877
|
+
tag: t,
|
|
878
|
+
input: n
|
|
879
|
+
});
|
|
880
|
+
let m = b.current, g = x.current;
|
|
881
|
+
if (m) try {
|
|
882
|
+
m(xt(i, l), n);
|
|
883
|
+
} catch (e) {
|
|
884
|
+
if (_(e), h(!1), i.revertByMutation(l), W(l, {
|
|
885
|
+
status: "error",
|
|
886
|
+
error: e
|
|
887
|
+
}), s) return c(e);
|
|
888
|
+
throw e;
|
|
889
|
+
}
|
|
890
|
+
else !g && f && f.length > 0 && i.autoApply(f, n, l);
|
|
891
|
+
let v;
|
|
892
|
+
try {
|
|
893
|
+
let s = B(a, t), c = p.currentSpan.pipe(p.tap((e) => p.sync(() => {
|
|
894
|
+
v = e.traceId, D({
|
|
895
|
+
traceId: e.traceId,
|
|
896
|
+
spanId: e.spanId,
|
|
897
|
+
source: "mutation",
|
|
898
|
+
tag: t
|
|
899
|
+
});
|
|
900
|
+
})), p.catchAll(() => p.void), p.zipRight(bt(s(n), d))).pipe(p.withSpan(`client.mutation.${t}`, { attributes: {
|
|
901
|
+
"voltro.api": e,
|
|
902
|
+
"voltro.mutationId": l,
|
|
903
|
+
"rpc.tag": t
|
|
904
|
+
} })), u = await H(r, c);
|
|
905
|
+
y(u), W(l, {
|
|
906
|
+
status: "success",
|
|
907
|
+
output: u
|
|
908
|
+
}), i.confirmByMutation(l), o?.onSuccess?.(u, n);
|
|
909
|
+
let f = ht(o?.notify?.success, u, n);
|
|
910
|
+
return f !== void 0 && G?.success(f), u;
|
|
911
|
+
} catch (e) {
|
|
912
|
+
let n = ft(e, v);
|
|
913
|
+
if (_(n), W(l, {
|
|
914
|
+
status: "error",
|
|
915
|
+
error: n
|
|
916
|
+
}), i.revertByMutation(l), u.emit({
|
|
917
|
+
source: "mutation",
|
|
918
|
+
tag: t,
|
|
919
|
+
error: n,
|
|
920
|
+
...v === void 0 ? {} : { traceId: v }
|
|
921
|
+
}), s) return c(n);
|
|
922
|
+
throw n;
|
|
923
|
+
} finally {
|
|
924
|
+
h(!1);
|
|
925
|
+
}
|
|
926
|
+
}, [
|
|
927
|
+
r,
|
|
928
|
+
i,
|
|
929
|
+
a,
|
|
930
|
+
e,
|
|
931
|
+
t,
|
|
932
|
+
f
|
|
933
|
+
]);
|
|
934
|
+
return o(() => {
|
|
935
|
+
let e = {
|
|
936
|
+
mutate: S,
|
|
937
|
+
pending: m,
|
|
938
|
+
error: g,
|
|
939
|
+
data: v,
|
|
940
|
+
withOptimistic: (t) => (b.current = t, e),
|
|
941
|
+
withoutOptimistic: () => (x.current = !0, e)
|
|
942
|
+
};
|
|
943
|
+
return e;
|
|
944
|
+
}, [
|
|
945
|
+
S,
|
|
946
|
+
m,
|
|
947
|
+
g,
|
|
948
|
+
v
|
|
949
|
+
]);
|
|
950
|
+
}, St = (e, t) => {
|
|
951
|
+
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
952
|
+
try {
|
|
953
|
+
Object.defineProperty(e, "__voltroTraceId", {
|
|
954
|
+
value: t,
|
|
955
|
+
enumerable: !1,
|
|
956
|
+
configurable: !0
|
|
957
|
+
});
|
|
958
|
+
} catch {}
|
|
959
|
+
return e;
|
|
960
|
+
}, Ct = (e, t, n) => typeof e == "function" ? e(t, n) : e, wt = 0, Tt = () => `act_${++wt}`, Et = 15e3, Dt = async (e, t, n) => {
|
|
961
|
+
if (!P(e.current)) return e.current;
|
|
962
|
+
let r = Date.now() + Et;
|
|
963
|
+
for (; Date.now() < r;) if (await new Promise((e) => setTimeout(e, 16)), !P(e.current)) return e.current;
|
|
964
|
+
throw Error(`Voltro: the api "${t}" did not resolve within ${Et}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.`);
|
|
965
|
+
}, q = (e, t) => {
|
|
966
|
+
let r = N(e), { descriptors: i, errorBus: a } = r, l = s(r);
|
|
967
|
+
if (l.current = r, process.env.NODE_ENV !== "production") {
|
|
968
|
+
let n = i[t]?.kind;
|
|
969
|
+
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.`);
|
|
970
|
+
}
|
|
971
|
+
let [u, d] = c(!1), [f, m] = c(void 0), [h, g] = c(void 0), _ = n(async (n, r) => {
|
|
972
|
+
let i = r?.onError !== void 0 || r?.notify?.error !== void 0;
|
|
973
|
+
d(!0), m(void 0);
|
|
974
|
+
let o = Tt(), s = r?.idempotencyKey ?? yt();
|
|
975
|
+
ct({
|
|
976
|
+
id: o,
|
|
977
|
+
apiName: e,
|
|
978
|
+
tag: t,
|
|
979
|
+
input: n
|
|
980
|
+
});
|
|
981
|
+
let c;
|
|
982
|
+
try {
|
|
983
|
+
let { runtime: i, client: a } = await Dt(l, e, t), u = B(a, t), d = await H(i, p.currentSpan.pipe(p.tap((e) => p.sync(() => {
|
|
984
|
+
c = e.traceId, D({
|
|
985
|
+
traceId: e.traceId,
|
|
986
|
+
spanId: e.spanId,
|
|
987
|
+
source: "action",
|
|
988
|
+
tag: t
|
|
989
|
+
});
|
|
990
|
+
})), p.catchAll(() => p.void), p.zipRight(bt(u(n), s))).pipe(p.withSpan(`client.action.${t}`, { attributes: {
|
|
991
|
+
"voltro.api": e,
|
|
992
|
+
"voltro.actionId": o,
|
|
993
|
+
"rpc.tag": t
|
|
994
|
+
} })));
|
|
995
|
+
g(d), W(o, {
|
|
996
|
+
status: "success",
|
|
997
|
+
output: d
|
|
998
|
+
}), r?.onSuccess?.(d, n);
|
|
999
|
+
let f = Ct(r?.notify?.success, d, n);
|
|
1000
|
+
return f !== void 0 && mt()?.success(f), d;
|
|
1001
|
+
} catch (e) {
|
|
1002
|
+
let s = St(e, c);
|
|
1003
|
+
if (m(s), W(o, {
|
|
1004
|
+
status: "error",
|
|
1005
|
+
error: s
|
|
1006
|
+
}), a.emit({
|
|
1007
|
+
source: "action",
|
|
1008
|
+
tag: t,
|
|
1009
|
+
error: s,
|
|
1010
|
+
...c === void 0 ? {} : { traceId: c }
|
|
1011
|
+
}), i) {
|
|
1012
|
+
r?.onError?.(s, n);
|
|
1013
|
+
let e = Ct(r?.notify?.error, s, n);
|
|
1014
|
+
e !== void 0 && mt()?.error(e);
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
throw s;
|
|
1018
|
+
} finally {
|
|
1019
|
+
d(!1);
|
|
1020
|
+
}
|
|
1021
|
+
}, [
|
|
1022
|
+
e,
|
|
1023
|
+
t,
|
|
1024
|
+
a
|
|
1025
|
+
]);
|
|
1026
|
+
return o(() => ({
|
|
1027
|
+
run: _,
|
|
1028
|
+
pending: u,
|
|
1029
|
+
error: f,
|
|
1030
|
+
lastResult: h
|
|
1031
|
+
}), [
|
|
1032
|
+
_,
|
|
1033
|
+
u,
|
|
1034
|
+
f,
|
|
1035
|
+
h
|
|
1036
|
+
]);
|
|
1037
|
+
}, Ot = V, kt = (e) => ({
|
|
1038
|
+
useSubscription: (t, n, r) => Ot(e, t, n, r),
|
|
1039
|
+
useMutation: (t) => K(e, t),
|
|
1040
|
+
useAction: (t) => q(e, t)
|
|
1041
|
+
}), At = () => ({ seeds: [] }), jt = null, Mt = (e) => {
|
|
1042
|
+
jt = e;
|
|
1043
|
+
}, Nt = /* @__PURE__ */ new Map(), Pt = (e, t) => `${e}\u0000${t}`, Ft = (e, t, n, r) => {
|
|
1044
|
+
let i = jt?.() ?? null;
|
|
770
1045
|
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
1046
|
i.seeds.push({
|
|
772
1047
|
api: e,
|
|
773
1048
|
key: O([t, n]),
|
|
774
1049
|
value: r
|
|
775
1050
|
});
|
|
776
|
-
},
|
|
777
|
-
if (e !== void 0) for (let t of e)
|
|
778
|
-
},
|
|
779
|
-
let r = O([t, n]), i =
|
|
1051
|
+
}, It = (e) => {
|
|
1052
|
+
if (e !== void 0) for (let t of e) Nt.set(Pt(t.api, t.key), t.value);
|
|
1053
|
+
}, Lt = (e, t, n) => {
|
|
1054
|
+
let r = O([t, n]), i = jt?.() ?? null;
|
|
780
1055
|
if (i !== null) {
|
|
781
1056
|
for (let t of i.seeds) if (t.api === e && t.key === r) return t.value;
|
|
782
1057
|
return;
|
|
783
1058
|
}
|
|
784
|
-
return
|
|
785
|
-
},
|
|
786
|
-
|
|
1059
|
+
return Nt.get(Pt(e, r));
|
|
1060
|
+
}, Rt = () => {
|
|
1061
|
+
Nt.clear();
|
|
787
1062
|
};
|
|
788
1063
|
//#endregion
|
|
789
1064
|
//#region src/usePreloadedSubscription.ts
|
|
790
|
-
function
|
|
791
|
-
let i =
|
|
792
|
-
return
|
|
1065
|
+
function zt(e, t, n = {}, r = {}) {
|
|
1066
|
+
let i = Lt(e, t, n);
|
|
1067
|
+
return V(e, t, n, i === void 0 ? r : {
|
|
793
1068
|
...r,
|
|
794
1069
|
initialSnapshot: i
|
|
795
1070
|
});
|
|
796
1071
|
}
|
|
797
1072
|
//#endregion
|
|
798
1073
|
//#region src/useEvent.ts
|
|
799
|
-
var
|
|
1074
|
+
var Bt = {
|
|
800
1075
|
status: "idle",
|
|
801
1076
|
missed: 0,
|
|
802
1077
|
lastMiss: void 0
|
|
803
|
-
},
|
|
1078
|
+
}, Vt = class {
|
|
804
1079
|
_tag = "EventStreamClosed";
|
|
805
1080
|
};
|
|
806
|
-
function
|
|
807
|
-
let { skip: o = !1, apiName: l = "app", onMissed: u } = i, d =
|
|
1081
|
+
function Ht(e, t, r, i = {}) {
|
|
1082
|
+
let { skip: o = !1, apiName: l = "app", onMissed: u } = i, d = N(l), { runtime: f, client: m } = d, [h, g] = c(Bt), _ = s(r);
|
|
808
1083
|
_.current = r;
|
|
809
1084
|
let v = s(u);
|
|
810
1085
|
v.current = u;
|
|
@@ -828,10 +1103,10 @@ function pt(e, t, r, i = {}) {
|
|
|
828
1103
|
count: e,
|
|
829
1104
|
reason: t
|
|
830
1105
|
}));
|
|
831
|
-
}, []), E = !o && w !== null && !
|
|
1106
|
+
}, []), E = !o && w !== null && !P(d);
|
|
832
1107
|
return a(() => {
|
|
833
1108
|
if (!E) {
|
|
834
|
-
g(
|
|
1109
|
+
g(Bt);
|
|
835
1110
|
return;
|
|
836
1111
|
}
|
|
837
1112
|
g((e) => ({
|
|
@@ -843,13 +1118,13 @@ function pt(e, t, r, i = {}) {
|
|
|
843
1118
|
origin: e,
|
|
844
1119
|
n: t
|
|
845
1120
|
}));
|
|
846
|
-
return
|
|
1121
|
+
return B(b.current, e.name)({
|
|
847
1122
|
key: T.current,
|
|
848
1123
|
...t.length > 0 ? { resume: t } : {}
|
|
849
1124
|
});
|
|
850
1125
|
}), r = x.unwrap(n).pipe(x.tap(() => p.sync(() => {
|
|
851
1126
|
t = 0;
|
|
852
|
-
})), x.concat(x.fail(new
|
|
1127
|
+
})), x.concat(x.fail(new Vt())), x.retry(y.exponential("250 millis", 2).pipe(y.either(y.spaced("30 seconds")), y.jittered, y.tapOutput(() => p.sync(() => {
|
|
853
1128
|
t += 1, g((e) => ({
|
|
854
1129
|
...e,
|
|
855
1130
|
status: "connecting"
|
|
@@ -876,11 +1151,11 @@ function pt(e, t, r, i = {}) {
|
|
|
876
1151
|
w,
|
|
877
1152
|
e.name,
|
|
878
1153
|
te
|
|
879
|
-
]), E ? h :
|
|
1154
|
+
]), E ? h : Bt;
|
|
880
1155
|
}
|
|
881
1156
|
//#endregion
|
|
882
1157
|
//#region src/sequence.ts
|
|
883
|
-
var
|
|
1158
|
+
var Ut = () => {
|
|
884
1159
|
let e = (t) => ({
|
|
885
1160
|
steps: t,
|
|
886
1161
|
step: ((n, r, i) => e([...t, {
|
|
@@ -892,7 +1167,7 @@ var mt = () => {
|
|
|
892
1167
|
}]))
|
|
893
1168
|
});
|
|
894
1169
|
return e([]);
|
|
895
|
-
},
|
|
1170
|
+
}, Wt = async (e, t = {}) => {
|
|
896
1171
|
let n = {}, r = [];
|
|
897
1172
|
for (let i of e.steps) {
|
|
898
1173
|
if (i.when !== void 0 && !i.when(n)) {
|
|
@@ -952,13 +1227,13 @@ var mt = () => {
|
|
|
952
1227
|
ok: !0,
|
|
953
1228
|
data: n
|
|
954
1229
|
};
|
|
955
|
-
},
|
|
1230
|
+
}, Gt = (e = {}) => {
|
|
956
1231
|
let [t, r] = c(!1), [i, a] = c(void 0), [o, l] = c(void 0), u = s(e);
|
|
957
1232
|
return u.current = e, {
|
|
958
1233
|
run: n(async (e, t = {}) => {
|
|
959
1234
|
r(!0), a(void 0), l(void 0);
|
|
960
1235
|
try {
|
|
961
|
-
let n = await
|
|
1236
|
+
let n = await Wt(e, {
|
|
962
1237
|
...u.current,
|
|
963
1238
|
...t
|
|
964
1239
|
});
|
|
@@ -971,239 +1246,7 @@ var mt = () => {
|
|
|
971
1246
|
error: i,
|
|
972
1247
|
failedStep: o
|
|
973
1248
|
};
|
|
974
|
-
},
|
|
975
|
-
vt = W.slice();
|
|
976
|
-
}, bt = () => {
|
|
977
|
-
yt();
|
|
978
|
-
for (let e of G) try {
|
|
979
|
-
e();
|
|
980
|
-
} catch {}
|
|
981
|
-
}, xt = (e) => {
|
|
982
|
-
let t = {
|
|
983
|
-
...e,
|
|
984
|
-
status: "pending",
|
|
985
|
-
startedAt: Date.now()
|
|
986
|
-
};
|
|
987
|
-
W.unshift(t), W.length > _t && (W.length = _t), bt();
|
|
988
|
-
}, K = (e, t) => {
|
|
989
|
-
let n = W.findIndex((t) => t.id === e);
|
|
990
|
-
if (n === -1) return;
|
|
991
|
-
let r = W[n], i = Date.now();
|
|
992
|
-
W[n] = t.status === "success" ? {
|
|
993
|
-
...r,
|
|
994
|
-
status: "success",
|
|
995
|
-
output: t.output,
|
|
996
|
-
settledAt: i,
|
|
997
|
-
durationMs: i - r.startedAt
|
|
998
|
-
} : {
|
|
999
|
-
...r,
|
|
1000
|
-
status: "error",
|
|
1001
|
-
error: t.error,
|
|
1002
|
-
settledAt: i,
|
|
1003
|
-
durationMs: i - r.startedAt
|
|
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) => {
|
|
1010
|
-
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
1011
|
-
try {
|
|
1012
|
-
Object.defineProperty(e, "__voltroTraceId", {
|
|
1013
|
-
value: t,
|
|
1014
|
-
enumerable: !1,
|
|
1015
|
-
configurable: !0
|
|
1016
|
-
});
|
|
1017
|
-
} catch {}
|
|
1018
|
-
return e;
|
|
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 = () => {
|
|
1022
|
-
let e = typeof crypto < "u" ? crypto : void 0;
|
|
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) => ({
|
|
1025
|
-
update: (n, r) => {
|
|
1026
|
-
e.update(n, r, t);
|
|
1027
|
-
},
|
|
1028
|
-
forTag: (n, r) => e.forTag(n, r, 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;
|
|
1031
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1032
|
-
let n = d?.kind;
|
|
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.`);
|
|
1034
|
-
}
|
|
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) => {
|
|
1036
|
-
let s = o?.onError !== void 0 || o?.notify?.error !== void 0, c = (e) => {
|
|
1037
|
-
o?.onError?.(e, n);
|
|
1038
|
-
let t = Ot(o?.notify?.error, e, n);
|
|
1039
|
-
t !== void 0 && q?.error(t);
|
|
1040
|
-
};
|
|
1041
|
-
h(!0), _(void 0);
|
|
1042
|
-
let l = At(), d = o?.idempotencyKey ?? Mt();
|
|
1043
|
-
xt({
|
|
1044
|
-
id: l,
|
|
1045
|
-
apiName: e,
|
|
1046
|
-
tag: t,
|
|
1047
|
-
input: n
|
|
1048
|
-
});
|
|
1049
|
-
let m = b.current, g = x.current;
|
|
1050
|
-
if (m) try {
|
|
1051
|
-
m(Pt(i, l), n);
|
|
1052
|
-
} catch (e) {
|
|
1053
|
-
if (_(e), h(!1), i.revertByMutation(l), K(l, {
|
|
1054
|
-
status: "error",
|
|
1055
|
-
error: e
|
|
1056
|
-
}), s) return c(e);
|
|
1057
|
-
throw e;
|
|
1058
|
-
}
|
|
1059
|
-
else !g && f && f.length > 0 && i.autoApply(f, n, l);
|
|
1060
|
-
let v;
|
|
1061
|
-
try {
|
|
1062
|
-
let s = H(a, t), c = p.currentSpan.pipe(p.tap((e) => p.sync(() => {
|
|
1063
|
-
v = e.traceId, D({
|
|
1064
|
-
traceId: e.traceId,
|
|
1065
|
-
spanId: e.spanId,
|
|
1066
|
-
source: "mutation",
|
|
1067
|
-
tag: t
|
|
1068
|
-
});
|
|
1069
|
-
})), p.catchAll(() => p.void), p.zipRight(Nt(s(n), d))).pipe(p.withSpan(`client.mutation.${t}`, { attributes: {
|
|
1070
|
-
"voltro.api": e,
|
|
1071
|
-
"voltro.mutationId": l,
|
|
1072
|
-
"rpc.tag": t
|
|
1073
|
-
} })), u = await r.runPromise(c);
|
|
1074
|
-
y(u), K(l, {
|
|
1075
|
-
status: "success",
|
|
1076
|
-
output: u
|
|
1077
|
-
}), i.confirmByMutation(l), o?.onSuccess?.(u, n);
|
|
1078
|
-
let f = Ot(o?.notify?.success, u, n);
|
|
1079
|
-
return f !== void 0 && q?.success(f), u;
|
|
1080
|
-
} catch (e) {
|
|
1081
|
-
let n = Tt(e, v);
|
|
1082
|
-
if (_(n), K(l, {
|
|
1083
|
-
status: "error",
|
|
1084
|
-
error: n
|
|
1085
|
-
}), i.revertByMutation(l), u.emit({
|
|
1086
|
-
source: "mutation",
|
|
1087
|
-
tag: t,
|
|
1088
|
-
error: n,
|
|
1089
|
-
...v === void 0 ? {} : { traceId: v }
|
|
1090
|
-
}), s) return c(n);
|
|
1091
|
-
throw n;
|
|
1092
|
-
} finally {
|
|
1093
|
-
h(!1);
|
|
1094
|
-
}
|
|
1095
|
-
}, [
|
|
1096
|
-
r,
|
|
1097
|
-
i,
|
|
1098
|
-
a,
|
|
1099
|
-
e,
|
|
1100
|
-
t,
|
|
1101
|
-
f
|
|
1102
|
-
]);
|
|
1103
|
-
return o(() => {
|
|
1104
|
-
let e = {
|
|
1105
|
-
mutate: S,
|
|
1106
|
-
pending: m,
|
|
1107
|
-
error: g,
|
|
1108
|
-
data: v,
|
|
1109
|
-
withOptimistic: (t) => (b.current = t, e),
|
|
1110
|
-
withoutOptimistic: () => (x.current = !0, e)
|
|
1111
|
-
};
|
|
1112
|
-
return e;
|
|
1113
|
-
}, [
|
|
1114
|
-
S,
|
|
1115
|
-
m,
|
|
1116
|
-
g,
|
|
1117
|
-
v
|
|
1118
|
-
]);
|
|
1119
|
-
}, Ft = (e, t) => {
|
|
1120
|
-
if (t === void 0 || typeof e != "object" || !e) return e;
|
|
1121
|
-
try {
|
|
1122
|
-
Object.defineProperty(e, "__voltroTraceId", {
|
|
1123
|
-
value: t,
|
|
1124
|
-
enumerable: !1,
|
|
1125
|
-
configurable: !0
|
|
1126
|
-
});
|
|
1127
|
-
} catch {}
|
|
1128
|
-
return e;
|
|
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;
|
|
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.`);
|
|
1139
|
-
}
|
|
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,
|
|
1146
|
-
apiName: e,
|
|
1147
|
-
tag: t,
|
|
1148
|
-
input: n
|
|
1149
|
-
});
|
|
1150
|
-
let c;
|
|
1151
|
-
try {
|
|
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({
|
|
1154
|
-
traceId: e.traceId,
|
|
1155
|
-
spanId: e.spanId,
|
|
1156
|
-
source: "action",
|
|
1157
|
-
tag: t
|
|
1158
|
-
});
|
|
1159
|
-
})), p.catchAll(() => p.void), p.zipRight(Nt(u(n), s))).pipe(p.withSpan(`client.action.${t}`, { attributes: {
|
|
1160
|
-
"voltro.api": e,
|
|
1161
|
-
"voltro.actionId": o,
|
|
1162
|
-
"rpc.tag": t
|
|
1163
|
-
} })), f = await i.runPromise(d);
|
|
1164
|
-
g(f), K(o, {
|
|
1165
|
-
status: "success",
|
|
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;
|
|
1170
|
-
} catch (e) {
|
|
1171
|
-
let s = Ft(e, c);
|
|
1172
|
-
if (m(s), K(o, {
|
|
1173
|
-
status: "error",
|
|
1174
|
-
error: s
|
|
1175
|
-
}), a.emit({
|
|
1176
|
-
source: "action",
|
|
1177
|
-
tag: t,
|
|
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);
|
|
1184
|
-
return;
|
|
1185
|
-
}
|
|
1186
|
-
throw s;
|
|
1187
|
-
} finally {
|
|
1188
|
-
d(!1);
|
|
1189
|
-
}
|
|
1190
|
-
}, [
|
|
1191
|
-
e,
|
|
1192
|
-
t,
|
|
1193
|
-
a
|
|
1194
|
-
]);
|
|
1195
|
-
return o(() => ({
|
|
1196
|
-
run: _,
|
|
1197
|
-
pending: u,
|
|
1198
|
-
error: f,
|
|
1199
|
-
lastResult: h
|
|
1200
|
-
}), [
|
|
1201
|
-
_,
|
|
1202
|
-
u,
|
|
1203
|
-
f,
|
|
1204
|
-
h
|
|
1205
|
-
]);
|
|
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) => {
|
|
1249
|
+
}, Kt = "storage.mintUploadTicket", qt = "storage.mintPresignedUpload", Jt = "storage.finalizeUpload", Yt = "storage.beginResumableUpload", Xt = "storage.beginMultipartUpload", Zt = "storage.signMultipartPart", Qt = "storage.completeMultipartUpload", $t = "storage.abortMultipartUpload", en = (e, t, n, r) => new Promise((i, a) => {
|
|
1207
1250
|
let o = new XMLHttpRequest();
|
|
1208
1251
|
if (o.open("PUT", e), o.upload.onprogress = (e) => {
|
|
1209
1252
|
e.lengthComputable && n(e.loaded / e.total);
|
|
@@ -1217,7 +1260,7 @@ var mt = () => {
|
|
|
1217
1260
|
return;
|
|
1218
1261
|
}
|
|
1219
1262
|
r.addEventListener("abort", () => o.abort(), { once: !0 }), o.send(t);
|
|
1220
|
-
}),
|
|
1263
|
+
}), tn = (e, t, n, r, i, a) => new Promise((o, s) => {
|
|
1221
1264
|
let c = new XMLHttpRequest();
|
|
1222
1265
|
if (c.open("POST", e), c.setRequestHeader("content-type", t), c.upload.onprogress = (e) => {
|
|
1223
1266
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -1235,7 +1278,7 @@ var mt = () => {
|
|
|
1235
1278
|
return;
|
|
1236
1279
|
}
|
|
1237
1280
|
i.addEventListener("abort", () => c.abort(), { once: !0 }), c.send(n);
|
|
1238
|
-
}),
|
|
1281
|
+
}), nn = (e, t, n, r, i) => new Promise((a, o) => {
|
|
1239
1282
|
let s = new XMLHttpRequest();
|
|
1240
1283
|
if (s.open("PUT", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
1241
1284
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -1246,7 +1289,7 @@ var mt = () => {
|
|
|
1246
1289
|
return;
|
|
1247
1290
|
}
|
|
1248
1291
|
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
1249
|
-
}),
|
|
1292
|
+
}), rn = (e, t, n, r, i) => new Promise((a, o) => {
|
|
1250
1293
|
let s = new XMLHttpRequest();
|
|
1251
1294
|
if (s.open("POST", e), s.setRequestHeader("content-type", t), s.upload.onprogress = (e) => {
|
|
1252
1295
|
e.lengthComputable && r(e.loaded / e.total);
|
|
@@ -1262,8 +1305,8 @@ var mt = () => {
|
|
|
1262
1305
|
return;
|
|
1263
1306
|
}
|
|
1264
1307
|
i.addEventListener("abort", () => s.abort(), { once: !0 }), s.send(n);
|
|
1265
|
-
}),
|
|
1266
|
-
let { runtime: r, client: i, inspectBaseUrl: a, errorBus: l } =
|
|
1308
|
+
}), an = (e, t = {}) => {
|
|
1309
|
+
let { runtime: r, client: i, inspectBaseUrl: a, errorBus: l } = N(e), [u, d] = c(0), [f, p] = c("idle"), [m, h] = c(void 0), g = s(null), _ = n(() => {
|
|
1267
1310
|
d(0), p("idle"), h(void 0);
|
|
1268
1311
|
}, []), v = n(() => {
|
|
1269
1312
|
g.current?.abort();
|
|
@@ -1283,28 +1326,28 @@ var mt = () => {
|
|
|
1283
1326
|
...e.width === void 0 ? {} : { width: e.width },
|
|
1284
1327
|
...e.height === void 0 ? {} : { height: e.height }
|
|
1285
1328
|
}), g = async () => {
|
|
1286
|
-
let s = n.mintTag ?? t.mintTag ??
|
|
1329
|
+
let s = n.mintTag ?? t.mintTag ?? Kt, l = B(i, s), u = await H(r, l({
|
|
1287
1330
|
contentType: c,
|
|
1288
1331
|
...m,
|
|
1289
1332
|
...d ? { key: d } : {}
|
|
1290
|
-
})), f = await
|
|
1333
|
+
})), f = await rn(y(u.uploadUrl), c, e, o, a);
|
|
1291
1334
|
return h(f);
|
|
1292
1335
|
}, _ = async () => {
|
|
1293
|
-
let s = n.presignMintTag ?? t.presignMintTag ??
|
|
1336
|
+
let s = n.presignMintTag ?? t.presignMintTag ?? qt, l = n.finalizeTag ?? t.finalizeTag ?? Jt, u;
|
|
1294
1337
|
try {
|
|
1295
|
-
let e =
|
|
1296
|
-
u = await r
|
|
1338
|
+
let e = B(i, s);
|
|
1339
|
+
u = await H(r, e({
|
|
1297
1340
|
contentType: c,
|
|
1298
1341
|
...m
|
|
1299
1342
|
}));
|
|
1300
1343
|
} catch {
|
|
1301
1344
|
return null;
|
|
1302
1345
|
}
|
|
1303
|
-
await
|
|
1304
|
-
let d =
|
|
1346
|
+
await nn(u.uploadUrl, c, e, o, a);
|
|
1347
|
+
let d = B(i, l), f = await H(r, d({ finalizeToken: u.finalizeToken }));
|
|
1305
1348
|
return h(f);
|
|
1306
1349
|
}, v = async () => {
|
|
1307
|
-
let s = n.beginResumableTag ?? t.beginResumableTag ??
|
|
1350
|
+
let s = n.beginResumableTag ?? t.beginResumableTag ?? Yt, l = B(i, s), u = e.size, d = n.chunkSize ?? t.chunkSize, f = await H(r, l({
|
|
1308
1351
|
contentType: c,
|
|
1309
1352
|
size: u,
|
|
1310
1353
|
...m,
|
|
@@ -1315,7 +1358,7 @@ var mt = () => {
|
|
|
1315
1358
|
for (;;) {
|
|
1316
1359
|
if (a.aborted) throw new DOMException("upload aborted", "AbortError");
|
|
1317
1360
|
try {
|
|
1318
|
-
let e = await
|
|
1361
|
+
let e = await tn(`${p}?${`token=${encodeURIComponent(f.resumableToken)}&index=${t}${s ? "&final=1" : ""}`}`, c, i, (e) => o((b + e * l) / u), a, s);
|
|
1319
1362
|
s && (x = e);
|
|
1320
1363
|
break;
|
|
1321
1364
|
} catch (e) {
|
|
@@ -1327,10 +1370,10 @@ var mt = () => {
|
|
|
1327
1370
|
if (!x) throw Error("resumable upload produced no final reply");
|
|
1328
1371
|
return h(x);
|
|
1329
1372
|
}, b = async () => {
|
|
1330
|
-
let s = n.multipartBeginTag ?? t.multipartBeginTag ??
|
|
1373
|
+
let s = n.multipartBeginTag ?? t.multipartBeginTag ?? Xt, u = n.multipartSignTag ?? t.multipartSignTag ?? Zt, d = n.multipartCompleteTag ?? t.multipartCompleteTag ?? Qt, f = n.multipartAbortTag ?? t.multipartAbortTag ?? $t, p = e.size, h = n.chunkSize ?? t.chunkSize, g;
|
|
1331
1374
|
try {
|
|
1332
|
-
let e =
|
|
1333
|
-
g = await r
|
|
1375
|
+
let e = B(i, s);
|
|
1376
|
+
g = await H(r, e({
|
|
1334
1377
|
contentType: c,
|
|
1335
1378
|
size: p,
|
|
1336
1379
|
...m,
|
|
@@ -1339,17 +1382,17 @@ var mt = () => {
|
|
|
1339
1382
|
} catch {
|
|
1340
1383
|
return null;
|
|
1341
1384
|
}
|
|
1342
|
-
let _ =
|
|
1385
|
+
let _ = B(i, u), v = B(i, d), b = B(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;
|
|
1343
1386
|
try {
|
|
1344
1387
|
for (let t = 0; t < S; t++) {
|
|
1345
1388
|
let n = t * x, i = Math.min(p, n + x), s = e.slice(n, i), c = t + 1, l = i - n, u = 0;
|
|
1346
1389
|
for (;;) {
|
|
1347
1390
|
if (a.aborted) throw new DOMException("upload aborted", "AbortError");
|
|
1348
1391
|
try {
|
|
1349
|
-
let { url: e } = await r
|
|
1392
|
+
let { url: e } = await H(r, _({
|
|
1350
1393
|
multipartToken: g.multipartToken,
|
|
1351
1394
|
partNumber: c
|
|
1352
|
-
})), t = await
|
|
1395
|
+
})), t = await en(e, s, (e) => o((T + e * l) / p), a);
|
|
1353
1396
|
w.push({
|
|
1354
1397
|
partNumber: c,
|
|
1355
1398
|
etag: t
|
|
@@ -1361,7 +1404,7 @@ var mt = () => {
|
|
|
1361
1404
|
}
|
|
1362
1405
|
T += l, o(T / p);
|
|
1363
1406
|
}
|
|
1364
|
-
let t = await r
|
|
1407
|
+
let t = await H(r, v({
|
|
1365
1408
|
multipartToken: g.multipartToken,
|
|
1366
1409
|
parts: w
|
|
1367
1410
|
}));
|
|
@@ -1374,7 +1417,7 @@ var mt = () => {
|
|
|
1374
1417
|
};
|
|
1375
1418
|
} catch (e) {
|
|
1376
1419
|
try {
|
|
1377
|
-
await r
|
|
1420
|
+
await H(r, b({ multipartToken: g.multipartToken }));
|
|
1378
1421
|
} catch {}
|
|
1379
1422
|
throw e;
|
|
1380
1423
|
}
|
|
@@ -1423,7 +1466,7 @@ var mt = () => {
|
|
|
1423
1466
|
} catch (e) {
|
|
1424
1467
|
throw p("error"), h(e), e instanceof DOMException && e.name === "AbortError" || l.emit({
|
|
1425
1468
|
source: "action",
|
|
1426
|
-
tag: n.mintTag ?? t.mintTag ??
|
|
1469
|
+
tag: n.mintTag ?? t.mintTag ?? Kt,
|
|
1427
1470
|
error: e
|
|
1428
1471
|
}), e;
|
|
1429
1472
|
}
|
|
@@ -1449,7 +1492,7 @@ var mt = () => {
|
|
|
1449
1492
|
} catch (e) {
|
|
1450
1493
|
throw r.abort(), p("error"), h(e), e instanceof DOMException && e.name === "AbortError" || l.emit({
|
|
1451
1494
|
source: "action",
|
|
1452
|
-
tag: n.mintTag ?? t.mintTag ??
|
|
1495
|
+
tag: n.mintTag ?? t.mintTag ?? Kt,
|
|
1453
1496
|
error: e
|
|
1454
1497
|
}), e;
|
|
1455
1498
|
}
|
|
@@ -1494,8 +1537,8 @@ var mt = () => {
|
|
|
1494
1537
|
w,
|
|
1495
1538
|
T
|
|
1496
1539
|
]);
|
|
1497
|
-
},
|
|
1498
|
-
let t =
|
|
1540
|
+
}, J = async (e) => {
|
|
1541
|
+
let t = B(e.client, e.tag), n = p.currentSpan.pipe(p.tap((t) => p.sync(() => {
|
|
1499
1542
|
D({
|
|
1500
1543
|
traceId: t.traceId,
|
|
1501
1544
|
spanId: t.spanId,
|
|
@@ -1506,9 +1549,9 @@ var mt = () => {
|
|
|
1506
1549
|
"voltro.api": e.apiName,
|
|
1507
1550
|
"rpc.tag": e.tag
|
|
1508
1551
|
} }));
|
|
1509
|
-
return e.runtime
|
|
1510
|
-
},
|
|
1511
|
-
let { runtime: r, client: i, descriptors: a } =
|
|
1552
|
+
return H(e.runtime, n);
|
|
1553
|
+
}, on = (e, t) => {
|
|
1554
|
+
let { runtime: r, client: i, descriptors: a } = N(e);
|
|
1512
1555
|
if (process.env.NODE_ENV !== "production") {
|
|
1513
1556
|
let n = a[t]?.kind;
|
|
1514
1557
|
n !== void 0 && n !== "workflow" && console.error(`[@voltro/client] useWorkflow('${e}', '${t}') targets a ${n}, not a workflow. Use ${n === "mutation" ? "useMutation" : n === "action" ? "useAction" : `the ${n} hook`} instead.`);
|
|
@@ -1516,7 +1559,7 @@ var mt = () => {
|
|
|
1516
1559
|
let [s, l] = c(!1), [u, d] = c(void 0), [f, p] = c(void 0), m = n(async (n) => {
|
|
1517
1560
|
l(!0), d(void 0);
|
|
1518
1561
|
try {
|
|
1519
|
-
let a = await
|
|
1562
|
+
let a = await J({
|
|
1520
1563
|
apiName: e,
|
|
1521
1564
|
runtime: r,
|
|
1522
1565
|
client: i,
|
|
@@ -1536,7 +1579,7 @@ var mt = () => {
|
|
|
1536
1579
|
i,
|
|
1537
1580
|
t
|
|
1538
1581
|
]), h = n(async (t) => {
|
|
1539
|
-
await
|
|
1582
|
+
await J({
|
|
1540
1583
|
apiName: e,
|
|
1541
1584
|
runtime: r,
|
|
1542
1585
|
client: i,
|
|
@@ -1549,7 +1592,7 @@ var mt = () => {
|
|
|
1549
1592
|
r,
|
|
1550
1593
|
i
|
|
1551
1594
|
]), g = n(async (t) => {
|
|
1552
|
-
await
|
|
1595
|
+
await J({
|
|
1553
1596
|
apiName: e,
|
|
1554
1597
|
runtime: r,
|
|
1555
1598
|
client: i,
|
|
@@ -1561,7 +1604,7 @@ var mt = () => {
|
|
|
1561
1604
|
e,
|
|
1562
1605
|
r,
|
|
1563
1606
|
i
|
|
1564
|
-
]), _ = n(async (t, n, a) =>
|
|
1607
|
+
]), _ = n(async (t, n, a) => J({
|
|
1565
1608
|
apiName: e,
|
|
1566
1609
|
runtime: r,
|
|
1567
1610
|
client: i,
|
|
@@ -1576,7 +1619,7 @@ var mt = () => {
|
|
|
1576
1619
|
e,
|
|
1577
1620
|
r,
|
|
1578
1621
|
i
|
|
1579
|
-
]), v = n(async (t, n, a, o) =>
|
|
1622
|
+
]), v = n(async (t, n, a, o) => J({
|
|
1580
1623
|
apiName: e,
|
|
1581
1624
|
runtime: r,
|
|
1582
1625
|
client: i,
|
|
@@ -1612,11 +1655,11 @@ var mt = () => {
|
|
|
1612
1655
|
u,
|
|
1613
1656
|
f
|
|
1614
1657
|
]);
|
|
1615
|
-
},
|
|
1616
|
-
let { runtime: t, client: r } =
|
|
1658
|
+
}, sn = (e) => {
|
|
1659
|
+
let { runtime: t, client: r } = N(e), [i, a] = c(!1), [s, l] = c(void 0), [u, d] = c(void 0), f = n(async (n, i, o) => {
|
|
1617
1660
|
a(!0), l(void 0);
|
|
1618
1661
|
try {
|
|
1619
|
-
let a = await
|
|
1662
|
+
let a = await J({
|
|
1620
1663
|
apiName: e,
|
|
1621
1664
|
runtime: t,
|
|
1622
1665
|
client: r,
|
|
@@ -1650,11 +1693,11 @@ var mt = () => {
|
|
|
1650
1693
|
s,
|
|
1651
1694
|
u
|
|
1652
1695
|
]);
|
|
1653
|
-
},
|
|
1654
|
-
let { runtime: t, client: r } =
|
|
1696
|
+
}, cn = (e) => {
|
|
1697
|
+
let { runtime: t, client: r } = N(e), [i, a] = c(!1), [s, l] = c(void 0), [u, d] = c(void 0), f = n(async (n, i, o, s) => {
|
|
1655
1698
|
a(!0), l(void 0);
|
|
1656
1699
|
try {
|
|
1657
|
-
let a = await
|
|
1700
|
+
let a = await J({
|
|
1658
1701
|
apiName: e,
|
|
1659
1702
|
runtime: t,
|
|
1660
1703
|
client: r,
|
|
@@ -1689,8 +1732,8 @@ var mt = () => {
|
|
|
1689
1732
|
s,
|
|
1690
1733
|
u
|
|
1691
1734
|
]);
|
|
1692
|
-
},
|
|
1693
|
-
let n =
|
|
1735
|
+
}, ln = (e, t) => {
|
|
1736
|
+
let n = V(e, "__voltro.workflow.run", t ? { id: t } : {}, { skip: t === void 0 });
|
|
1694
1737
|
return n.loading || n.idle ? {
|
|
1695
1738
|
...n,
|
|
1696
1739
|
run: void 0
|
|
@@ -1698,8 +1741,8 @@ var mt = () => {
|
|
|
1698
1741
|
...n,
|
|
1699
1742
|
run: n.data[0]
|
|
1700
1743
|
};
|
|
1701
|
-
},
|
|
1702
|
-
let r =
|
|
1744
|
+
}, un = (e, t = {}, n = {}) => {
|
|
1745
|
+
let r = V(e, "__voltro.workflow.runs", t, n);
|
|
1703
1746
|
return r.loading || r.idle ? {
|
|
1704
1747
|
...r,
|
|
1705
1748
|
runs: []
|
|
@@ -1707,8 +1750,8 @@ var mt = () => {
|
|
|
1707
1750
|
...r,
|
|
1708
1751
|
runs: r.data
|
|
1709
1752
|
};
|
|
1710
|
-
},
|
|
1711
|
-
let n =
|
|
1753
|
+
}, dn = (e, t) => {
|
|
1754
|
+
let n = V(e, "__voltro.workflow.run.steps", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
1712
1755
|
return n.loading || n.idle ? {
|
|
1713
1756
|
...n,
|
|
1714
1757
|
steps: []
|
|
@@ -1716,8 +1759,8 @@ var mt = () => {
|
|
|
1716
1759
|
...n,
|
|
1717
1760
|
steps: n.data
|
|
1718
1761
|
};
|
|
1719
|
-
},
|
|
1720
|
-
let n =
|
|
1762
|
+
}, fn = (e, t) => {
|
|
1763
|
+
let n = V(e, "__voltro.workflow.run.events", t ? { runId: t } : {}, { skip: t === void 0 });
|
|
1721
1764
|
return n.loading || n.idle ? {
|
|
1722
1765
|
...n,
|
|
1723
1766
|
events: []
|
|
@@ -1725,8 +1768,8 @@ var mt = () => {
|
|
|
1725
1768
|
...n,
|
|
1726
1769
|
events: n.data
|
|
1727
1770
|
};
|
|
1728
|
-
},
|
|
1729
|
-
let r =
|
|
1771
|
+
}, pn = fn, mn = (e, t = {}, n = {}) => {
|
|
1772
|
+
let r = V(e, "__voltro.workflow.domainEvents", t, n);
|
|
1730
1773
|
return r.loading || r.idle ? {
|
|
1731
1774
|
...r,
|
|
1732
1775
|
events: []
|
|
@@ -1734,8 +1777,8 @@ var mt = () => {
|
|
|
1734
1777
|
...r,
|
|
1735
1778
|
events: r.data
|
|
1736
1779
|
};
|
|
1737
|
-
},
|
|
1738
|
-
let n =
|
|
1780
|
+
}, hn = (e, t) => {
|
|
1781
|
+
let n = V(e, "__voltro.workflow.event.deliveries", t ? { eventId: t } : {}, { skip: t === void 0 });
|
|
1739
1782
|
return n.loading || n.idle ? {
|
|
1740
1783
|
...n,
|
|
1741
1784
|
deliveries: []
|
|
@@ -1743,42 +1786,42 @@ var mt = () => {
|
|
|
1743
1786
|
...n,
|
|
1744
1787
|
deliveries: n.data
|
|
1745
1788
|
};
|
|
1746
|
-
},
|
|
1789
|
+
}, gn = (e, t) => {
|
|
1747
1790
|
let n = e.payload;
|
|
1748
1791
|
if (!n || typeof n != "object") return;
|
|
1749
1792
|
let r = n[t];
|
|
1750
1793
|
return typeof r == "string" ? r : void 0;
|
|
1751
|
-
},
|
|
1794
|
+
}, _n = (e) => {
|
|
1752
1795
|
let t = e.payload;
|
|
1753
1796
|
if (!t || typeof t != "object") return;
|
|
1754
1797
|
let n = t.updateId;
|
|
1755
1798
|
return typeof n == "string" ? n : void 0;
|
|
1756
|
-
},
|
|
1799
|
+
}, vn = (e) => {
|
|
1757
1800
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
1758
1801
|
for (let r of e) if (r.eventType === "signal-received") {
|
|
1759
|
-
let e =
|
|
1802
|
+
let e = gn(r, "signalName");
|
|
1760
1803
|
e && t.add(e);
|
|
1761
1804
|
} else if (r.eventType === "update-completed" || r.eventType === "update-failed") {
|
|
1762
|
-
let e =
|
|
1805
|
+
let e = _n(r);
|
|
1763
1806
|
e && n.add(e);
|
|
1764
1807
|
}
|
|
1765
1808
|
for (let r = e.length - 1; r >= 0; --r) {
|
|
1766
1809
|
let i = e[r];
|
|
1767
1810
|
if (i.eventType === "signal-awaited") {
|
|
1768
|
-
let e =
|
|
1811
|
+
let e = gn(i, "signalName");
|
|
1769
1812
|
if (e && !t.has(e)) return {
|
|
1770
1813
|
name: e,
|
|
1771
1814
|
kind: "signal"
|
|
1772
1815
|
};
|
|
1773
1816
|
} else if (i.eventType === "update-requested") {
|
|
1774
|
-
let e =
|
|
1817
|
+
let e = _n(i), t = gn(i, "updateName");
|
|
1775
1818
|
if (t && (!e || !n.has(e))) return {
|
|
1776
1819
|
name: t,
|
|
1777
1820
|
kind: "update"
|
|
1778
1821
|
};
|
|
1779
1822
|
}
|
|
1780
1823
|
}
|
|
1781
|
-
},
|
|
1824
|
+
}, yn = (e) => e.find((e) => e.status === "running") || (e.length > 0 ? e[e.length - 1] : void 0), bn = (e, t) => {
|
|
1782
1825
|
if (!e || e.status !== "failed") return;
|
|
1783
1826
|
let n = t.find((e) => e.status === "failed");
|
|
1784
1827
|
return {
|
|
@@ -1786,8 +1829,8 @@ var mt = () => {
|
|
|
1786
1829
|
message: e.errorMessage,
|
|
1787
1830
|
step: n?.stepName
|
|
1788
1831
|
};
|
|
1789
|
-
},
|
|
1790
|
-
let r =
|
|
1832
|
+
}, xn = (e, t) => {
|
|
1833
|
+
let r = ln(e, t), i = dn(e, t), a = fn(e, t), s = on(e, r.run?.tag ?? ""), c = r.run, l = i.steps, u = a.events, d = n(async () => {
|
|
1791
1834
|
if (!c) throw Error("useWorkflowRunState: no run loaded — cannot cancel");
|
|
1792
1835
|
await s.cancel({
|
|
1793
1836
|
workflowName: c.tag,
|
|
@@ -1811,9 +1854,9 @@ var mt = () => {
|
|
|
1811
1854
|
status: c?.status,
|
|
1812
1855
|
steps: l,
|
|
1813
1856
|
events: u,
|
|
1814
|
-
currentStep:
|
|
1815
|
-
waitingFor: c?.status === "suspended" ?
|
|
1816
|
-
error:
|
|
1857
|
+
currentStep: yn(l),
|
|
1858
|
+
waitingFor: c?.status === "suspended" ? vn(u) : void 0,
|
|
1859
|
+
error: bn(c, l),
|
|
1817
1860
|
traceId: c?.traceId,
|
|
1818
1861
|
loading: r.data === void 0,
|
|
1819
1862
|
cancel: d,
|
|
@@ -1830,8 +1873,8 @@ var mt = () => {
|
|
|
1830
1873
|
p,
|
|
1831
1874
|
m
|
|
1832
1875
|
]);
|
|
1833
|
-
},
|
|
1834
|
-
let { runtime: r, client: i } =
|
|
1876
|
+
}, Sn = (e, t) => {
|
|
1877
|
+
let { runtime: r, client: i } = N(e), [a, o] = c([]), [l, d] = c("idle"), [f, m] = c(void 0), g = s(null), _ = n(() => {
|
|
1835
1878
|
let e = g.current;
|
|
1836
1879
|
e && (g.current = null, r.runFork(h.interrupt(e)), d((e) => e === "streaming" ? "idle" : e));
|
|
1837
1880
|
}, [r]);
|
|
@@ -1842,7 +1885,7 @@ var mt = () => {
|
|
|
1842
1885
|
start: n((e = {}) => {
|
|
1843
1886
|
let n = g.current;
|
|
1844
1887
|
n && r.runFork(h.interrupt(n)), o([]), m(void 0), d("streaming");
|
|
1845
|
-
let a =
|
|
1888
|
+
let a = B(i, t)(e), s = x.runForEach(a, (e) => p.sync(() => o((t) => [...t, e]))).pipe(p.matchCause({
|
|
1846
1889
|
onSuccess: () => {
|
|
1847
1890
|
d("done");
|
|
1848
1891
|
},
|
|
@@ -1858,7 +1901,7 @@ var mt = () => {
|
|
|
1858
1901
|
]),
|
|
1859
1902
|
cancel: _
|
|
1860
1903
|
};
|
|
1861
|
-
},
|
|
1904
|
+
}, Cn = (e, t, n, r) => {
|
|
1862
1905
|
let i = 0, a = !1, o = (e) => p.sync(() => {
|
|
1863
1906
|
e.seq <= i || (i = e.seq, n.onEvent(e.event), r.isTerminal(e.event) && (a = !0));
|
|
1864
1907
|
}), s = (e, t, a) => {
|
|
@@ -1881,15 +1924,15 @@ var mt = () => {
|
|
|
1881
1924
|
}));
|
|
1882
1925
|
});
|
|
1883
1926
|
return c(0);
|
|
1884
|
-
},
|
|
1927
|
+
}, wn = (e) => {
|
|
1885
1928
|
let t = e?._tag;
|
|
1886
1929
|
return t === "done" || t === "error";
|
|
1887
|
-
},
|
|
1888
|
-
let { runtime: i, client: a } =
|
|
1930
|
+
}, Tn = (e, t, r = {}) => {
|
|
1931
|
+
let { runtime: i, client: a } = N(e), [o, l] = c([]), [u, d] = c("idle"), [f, p] = c(0), [m, g] = c(void 0), _ = s(null), v = {
|
|
1889
1932
|
maxReconnects: r.maxReconnects ?? 6,
|
|
1890
1933
|
backoffMs: r.backoffMs ?? 400,
|
|
1891
1934
|
maxBackoffMs: r.maxBackoffMs ?? 8e3,
|
|
1892
|
-
isTerminal: r.isTerminal ??
|
|
1935
|
+
isTerminal: r.isTerminal ?? wn
|
|
1893
1936
|
}, y = n(() => {
|
|
1894
1937
|
let e = _.current;
|
|
1895
1938
|
e && (_.current = null, i.runFork(h.interrupt(e)), d((e) => e === "streaming" || e === "reconnecting" ? "idle" : e));
|
|
@@ -1902,13 +1945,13 @@ var mt = () => {
|
|
|
1902
1945
|
start: n((e = {}) => {
|
|
1903
1946
|
let n = _.current;
|
|
1904
1947
|
n && i.runFork(h.interrupt(n)), l([]), g(void 0), p(0), d("streaming");
|
|
1905
|
-
let r =
|
|
1948
|
+
let r = B(a, t), o = {
|
|
1906
1949
|
onEvent: (e) => l((t) => [...t, e]),
|
|
1907
1950
|
onStatus: d,
|
|
1908
1951
|
onReconnect: () => p((e) => e + 1),
|
|
1909
1952
|
onError: g
|
|
1910
1953
|
};
|
|
1911
|
-
_.current = i.runFork(
|
|
1954
|
+
_.current = i.runFork(Cn(r, e, o, v));
|
|
1912
1955
|
}, [
|
|
1913
1956
|
i,
|
|
1914
1957
|
a,
|
|
@@ -1920,13 +1963,13 @@ var mt = () => {
|
|
|
1920
1963
|
]),
|
|
1921
1964
|
cancel: y
|
|
1922
1965
|
};
|
|
1923
|
-
},
|
|
1966
|
+
}, En = (e, t) => e.order - t.order || (e.stepOrder ?? 0) - (t.stepOrder ?? 0), Dn = (e) => {
|
|
1924
1967
|
for (let t = e.length - 1; t >= 0; --t) {
|
|
1925
1968
|
let n = e[t];
|
|
1926
1969
|
if (n.role === "user" && n.content) return n.content;
|
|
1927
1970
|
}
|
|
1928
|
-
},
|
|
1929
|
-
let { threadId: i } = r, a =
|
|
1971
|
+
}, On = (e, t, r) => {
|
|
1972
|
+
let { threadId: i } = r, a = V(e, `${t}.messages`, { threadId: i }), s = q(e, `${t}.send`), c = o(() => [...a.data ?? []].sort(En), [a.data]), l = n((e, t = {}) => s.run({
|
|
1930
1973
|
threadId: i,
|
|
1931
1974
|
order: a.data?.length ?? 0,
|
|
1932
1975
|
prompt: e,
|
|
@@ -1936,7 +1979,7 @@ var mt = () => {
|
|
|
1936
1979
|
i,
|
|
1937
1980
|
a.data
|
|
1938
1981
|
]), u = n(() => {
|
|
1939
|
-
let e =
|
|
1982
|
+
let e = Dn(c);
|
|
1940
1983
|
return e === void 0 ? void 0 : l(e);
|
|
1941
1984
|
}, [c, l]);
|
|
1942
1985
|
return o(() => ({
|
|
@@ -1956,8 +1999,8 @@ var mt = () => {
|
|
|
1956
1999
|
l,
|
|
1957
2000
|
u
|
|
1958
2001
|
]);
|
|
1959
|
-
},
|
|
1960
|
-
let { events: r, status: i, error: l, start: u, cancel: d } =
|
|
2002
|
+
}, kn = (e, t) => {
|
|
2003
|
+
let { events: r, status: i, error: l, start: u, cancel: d } = Sn(e, t), [f, p] = c([]), m = s(null), h = o(() => r.filter((e) => e._tag === "token").map((e) => e.text ?? "").join(""), [r]);
|
|
1961
2004
|
return a(() => {
|
|
1962
2005
|
if (i !== "done" || m.current === null) return;
|
|
1963
2006
|
let e = m.current;
|
|
@@ -1983,8 +2026,8 @@ var mt = () => {
|
|
|
1983
2026
|
}, [u]),
|
|
1984
2027
|
cancel: d
|
|
1985
2028
|
};
|
|
1986
|
-
},
|
|
1987
|
-
let r =
|
|
2029
|
+
}, An = (e, t) => {
|
|
2030
|
+
let r = q(e, t), [i, a] = c(void 0), s = n(async (e) => {
|
|
1988
2031
|
let t = await r.run({ question: e });
|
|
1989
2032
|
return a(t), t;
|
|
1990
2033
|
}, [r]), l = n(() => a(void 0), []);
|
|
@@ -2001,43 +2044,43 @@ var mt = () => {
|
|
|
2001
2044
|
r.error,
|
|
2002
2045
|
l
|
|
2003
2046
|
]);
|
|
2004
|
-
},
|
|
2005
|
-
let { cache: t, runtime: r } =
|
|
2047
|
+
}, jn = (e) => {
|
|
2048
|
+
let { cache: t, runtime: r } = N(e);
|
|
2006
2049
|
return n(() => {
|
|
2007
2050
|
t.refreshAll(r);
|
|
2008
2051
|
}, [t, r]);
|
|
2009
|
-
},
|
|
2010
|
-
for (let t of
|
|
2052
|
+
}, Mn = /* @__PURE__ */ new Set(), Nn = (e) => {
|
|
2053
|
+
for (let t of Mn) try {
|
|
2011
2054
|
t(e);
|
|
2012
2055
|
} catch {}
|
|
2013
|
-
},
|
|
2014
|
-
|
|
2015
|
-
}),
|
|
2016
|
-
|
|
2056
|
+
}, Pn = (e) => (Mn.add(e), () => {
|
|
2057
|
+
Mn.delete(e);
|
|
2058
|
+
}), Fn = (e, t) => {
|
|
2059
|
+
Nn({
|
|
2017
2060
|
error: e,
|
|
2018
2061
|
source: "manual",
|
|
2019
2062
|
...t ? { context: t } : {}
|
|
2020
2063
|
});
|
|
2021
|
-
},
|
|
2022
|
-
let { errorBus: n } =
|
|
2064
|
+
}, In = (e, t) => {
|
|
2065
|
+
let { errorBus: n } = N(e);
|
|
2023
2066
|
a(() => n.on(t), [n, t]);
|
|
2024
|
-
},
|
|
2067
|
+
}, Ln = "#/$defs/", Rn = (e) => e.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\s+/g, " ").trim().replace(/^./, (e) => e.toUpperCase()), Y = (e, t) => {
|
|
2025
2068
|
let n = e;
|
|
2026
2069
|
for (let e = 0; e < 8; e += 1) {
|
|
2027
2070
|
let e = n.$ref;
|
|
2028
|
-
if (typeof e != "string" || !e.startsWith(
|
|
2071
|
+
if (typeof e != "string" || !e.startsWith(Ln)) return n;
|
|
2029
2072
|
let r = t[e.slice(8)];
|
|
2030
2073
|
if (!r || typeof r != "object") return n;
|
|
2031
2074
|
n = r;
|
|
2032
2075
|
}
|
|
2033
2076
|
return n;
|
|
2034
|
-
},
|
|
2077
|
+
}, zn = (e) => {
|
|
2035
2078
|
if (!e || typeof e != "object") return !1;
|
|
2036
2079
|
let t = e;
|
|
2037
2080
|
if (t.type === "null" || t.const === null) return !0;
|
|
2038
2081
|
let n = t.enum;
|
|
2039
2082
|
return Array.isArray(n) && n.length === 1 && n[0] === null;
|
|
2040
|
-
},
|
|
2083
|
+
}, Bn = (e, t) => {
|
|
2041
2084
|
let n = e.type;
|
|
2042
2085
|
if (Array.isArray(n) && n.includes("null")) {
|
|
2043
2086
|
let t = n.filter((e) => e !== "null");
|
|
@@ -2052,9 +2095,9 @@ var mt = () => {
|
|
|
2052
2095
|
for (let n of ["anyOf", "oneOf"]) {
|
|
2053
2096
|
let r = e[n];
|
|
2054
2097
|
if (!Array.isArray(r)) continue;
|
|
2055
|
-
let i = r.filter((e) => !
|
|
2098
|
+
let i = r.filter((e) => !zn(e));
|
|
2056
2099
|
if (i.length !== r.length) return i.length === 1 ? {
|
|
2057
|
-
node:
|
|
2100
|
+
node: Y(i[0], t),
|
|
2058
2101
|
nullable: !0
|
|
2059
2102
|
} : {
|
|
2060
2103
|
node: {
|
|
@@ -2068,14 +2111,14 @@ var mt = () => {
|
|
|
2068
2111
|
node: e,
|
|
2069
2112
|
nullable: !1
|
|
2070
2113
|
};
|
|
2071
|
-
},
|
|
2114
|
+
}, Vn = (e) => e.map((e) => ({
|
|
2072
2115
|
value: String(e),
|
|
2073
|
-
label:
|
|
2074
|
-
})),
|
|
2116
|
+
label: Rn(String(e))
|
|
2117
|
+
})), Hn = (e) => {
|
|
2075
2118
|
let t = e.enum;
|
|
2076
2119
|
if (Array.isArray(t) && t.length > 0) return {
|
|
2077
2120
|
widget: "select",
|
|
2078
|
-
options:
|
|
2121
|
+
options: Vn(t)
|
|
2079
2122
|
};
|
|
2080
2123
|
let n = e.type, r = Array.isArray(n) ? n.find((e) => e !== "null") : n, i = e.format;
|
|
2081
2124
|
switch (r) {
|
|
@@ -2086,38 +2129,38 @@ var mt = () => {
|
|
|
2086
2129
|
case "array": return { widget: "multi-select" };
|
|
2087
2130
|
default: return { widget: "custom" };
|
|
2088
2131
|
}
|
|
2089
|
-
},
|
|
2090
|
-
let { node: i, nullable: a } =
|
|
2132
|
+
}, Un = (e, t, n) => Object.entries(e).map(([e, r]) => {
|
|
2133
|
+
let { node: i, nullable: a } = Bn(Y(r, n), n), o = Y(i, n), { widget: s, options: c } = Hn(o);
|
|
2091
2134
|
return {
|
|
2092
2135
|
name: e,
|
|
2093
|
-
label:
|
|
2136
|
+
label: Rn(e),
|
|
2094
2137
|
widget: s,
|
|
2095
2138
|
required: t.has(e),
|
|
2096
2139
|
nullable: a,
|
|
2097
2140
|
...c ? { options: c } : {},
|
|
2098
2141
|
jsonSchema: o
|
|
2099
2142
|
};
|
|
2100
|
-
}),
|
|
2143
|
+
}), Wn = (e) => {
|
|
2101
2144
|
try {
|
|
2102
2145
|
return g.make(e);
|
|
2103
2146
|
} catch {
|
|
2104
2147
|
return;
|
|
2105
2148
|
}
|
|
2106
|
-
},
|
|
2107
|
-
let t =
|
|
2149
|
+
}, X = (e) => {
|
|
2150
|
+
let t = Wn(e);
|
|
2108
2151
|
if (t === void 0) return [];
|
|
2109
|
-
let n = t.$defs ?? {}, r =
|
|
2110
|
-
return i ?
|
|
2111
|
-
},
|
|
2112
|
-
let t =
|
|
2152
|
+
let n = t.$defs ?? {}, r = Y(t, n), i = r.properties;
|
|
2153
|
+
return i ? Un(i, new Set(Array.isArray(r.required) ? r.required : []), n) : [];
|
|
2154
|
+
}, Gn = (e) => {
|
|
2155
|
+
let t = Wn(e);
|
|
2113
2156
|
if (t === void 0) return [];
|
|
2114
|
-
let n = t.$defs ?? {}, r =
|
|
2157
|
+
let n = t.$defs ?? {}, r = Y(t, n);
|
|
2115
2158
|
if (r.type !== "array") return [];
|
|
2116
2159
|
let i = r.items;
|
|
2117
2160
|
if (!i || typeof i != "object") return [];
|
|
2118
|
-
let a =
|
|
2119
|
-
return o ?
|
|
2120
|
-
},
|
|
2161
|
+
let a = Y(i, n), o = a.properties;
|
|
2162
|
+
return o ? Un(o, new Set(Array.isArray(a.required) ? a.required : []), n) : [];
|
|
2163
|
+
}, Kn = (e, t) => {
|
|
2121
2164
|
let n = b.decodeUnknownEither(e, { errors: "all" })(t);
|
|
2122
2165
|
if (n._tag === "Right") return {
|
|
2123
2166
|
valid: !0,
|
|
@@ -2132,10 +2175,10 @@ var mt = () => {
|
|
|
2132
2175
|
valid: !1,
|
|
2133
2176
|
errors: r
|
|
2134
2177
|
};
|
|
2135
|
-
},
|
|
2136
|
-
let i =
|
|
2178
|
+
}, qn = (e, t, r) => {
|
|
2179
|
+
let i = N(e), a = K(e, t), l = r.schema ?? i.descriptors[t]?.input;
|
|
2137
2180
|
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.`);
|
|
2138
|
-
let u = o(() => l ?
|
|
2181
|
+
let u = o(() => l ? X(l) : [], [l]), d = s(r.defaults ?? {}), [f, p] = c(d.current), [m, h] = c({}), g = n((e, t) => {
|
|
2139
2182
|
p((n) => ({
|
|
2140
2183
|
...n,
|
|
2141
2184
|
[e]: t
|
|
@@ -2149,7 +2192,7 @@ var mt = () => {
|
|
|
2149
2192
|
p(d.current), h({});
|
|
2150
2193
|
}, []), y = n(async () => {
|
|
2151
2194
|
if (l !== void 0) {
|
|
2152
|
-
let e =
|
|
2195
|
+
let e = Kn(l, f);
|
|
2153
2196
|
if (h(e.errors), !e.valid) return;
|
|
2154
2197
|
}
|
|
2155
2198
|
return a.mutate(f);
|
|
@@ -2162,7 +2205,7 @@ var mt = () => {
|
|
|
2162
2205
|
fields: u,
|
|
2163
2206
|
values: f,
|
|
2164
2207
|
errors: m,
|
|
2165
|
-
isValid: o(() => l === void 0 ||
|
|
2208
|
+
isValid: o(() => l === void 0 || Kn(l, f).valid, [l, f]),
|
|
2166
2209
|
pending: a.pending,
|
|
2167
2210
|
submitError: a.error,
|
|
2168
2211
|
data: a.data,
|
|
@@ -2171,13 +2214,13 @@ var mt = () => {
|
|
|
2171
2214
|
reset: v,
|
|
2172
2215
|
submit: y
|
|
2173
2216
|
};
|
|
2174
|
-
},
|
|
2217
|
+
}, Jn = (e, t, n) => e.map((e) => {
|
|
2175
2218
|
let r = String(e[n] ?? ""), i = e[t];
|
|
2176
2219
|
return {
|
|
2177
2220
|
value: r,
|
|
2178
2221
|
label: i == null ? r : String(i)
|
|
2179
2222
|
};
|
|
2180
|
-
}),
|
|
2223
|
+
}), Yn = (e, t, r = {}) => {
|
|
2181
2224
|
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);
|
|
2182
2225
|
a(() => {
|
|
2183
2226
|
if (d === p) return;
|
|
@@ -2188,7 +2231,7 @@ var mt = () => {
|
|
|
2188
2231
|
p,
|
|
2189
2232
|
i
|
|
2190
2233
|
]);
|
|
2191
|
-
let h = r.skipUntilTerm === !0 && p.trim() === "", g =
|
|
2234
|
+
let h = r.skipUntilTerm === !0 && p.trim() === "", g = V(e, t, o(() => u(p), [u, p]), { skip: h }), _ = o(() => Jn(g.data ?? [], s, l), [
|
|
2192
2235
|
g.data,
|
|
2193
2236
|
s,
|
|
2194
2237
|
l
|
|
@@ -2199,13 +2242,13 @@ var mt = () => {
|
|
|
2199
2242
|
term: d,
|
|
2200
2243
|
search: v
|
|
2201
2244
|
};
|
|
2202
|
-
},
|
|
2203
|
-
let i =
|
|
2245
|
+
}, Xn = (e, t) => e === t ? 0 : e == null ? 1 : t == null || e < t ? -1 : 1, Zn = (e, t, r = {}) => {
|
|
2246
|
+
let i = N(e), [a, s] = c(r.pageSize), l = V(e, t, o(() => a === void 0 ? r.input ?? {} : {
|
|
2204
2247
|
...r.input,
|
|
2205
2248
|
limit: a
|
|
2206
2249
|
}, [r.input, a])), u = i.descriptors[t]?.output, d = n(() => {
|
|
2207
2250
|
r.pageSize !== void 0 && s((e) => (e ?? r.pageSize) + r.pageSize);
|
|
2208
|
-
}, [r.pageSize]), f = o(() => r.columns ?? (u === void 0 ? [] :
|
|
2251
|
+
}, [r.pageSize]), f = o(() => r.columns ?? (u === void 0 ? [] : Gn(u)), [r.columns, u]), [p, m] = c(r.initialSort), h = n((e) => {
|
|
2209
2252
|
m((t) => t?.column === e ? {
|
|
2210
2253
|
column: e,
|
|
2211
2254
|
direction: t.direction === "asc" ? "desc" : "asc"
|
|
@@ -2220,7 +2263,7 @@ var mt = () => {
|
|
|
2220
2263
|
let e = l.data ?? [];
|
|
2221
2264
|
if (p === void 0) return e;
|
|
2222
2265
|
let t = p.direction === "asc" ? 1 : -1;
|
|
2223
|
-
return [...e].sort((e, n) =>
|
|
2266
|
+
return [...e].sort((e, n) => Xn(e[p.column], n[p.column]) * t);
|
|
2224
2267
|
}, [l.data, p]),
|
|
2225
2268
|
loading: l.data === void 0,
|
|
2226
2269
|
error: l.error,
|
|
@@ -2229,14 +2272,14 @@ var mt = () => {
|
|
|
2229
2272
|
loadMore: d,
|
|
2230
2273
|
hasMore: a !== void 0 && (l.data?.length ?? 0) >= a
|
|
2231
2274
|
};
|
|
2232
|
-
},
|
|
2275
|
+
}, Qn = (e, t, n, r) => {
|
|
2233
2276
|
let i = e.replace(/\/$/, ""), a = new URLSearchParams({
|
|
2234
2277
|
table: t,
|
|
2235
2278
|
id: n
|
|
2236
2279
|
});
|
|
2237
2280
|
return r !== void 0 && a.set("column", r), `${i}/_voltro/inspect/provenance?${a.toString()}`;
|
|
2238
|
-
},
|
|
2239
|
-
let { inspectBaseUrl: i } =
|
|
2281
|
+
}, $n = Qn, er = (e, t, n, r) => {
|
|
2282
|
+
let { inspectBaseUrl: i } = N(e), [o, s] = c({
|
|
2240
2283
|
data: void 0,
|
|
2241
2284
|
loading: !0,
|
|
2242
2285
|
error: void 0
|
|
@@ -2248,7 +2291,7 @@ var mt = () => {
|
|
|
2248
2291
|
loading: !0,
|
|
2249
2292
|
error: void 0
|
|
2250
2293
|
});
|
|
2251
|
-
let a =
|
|
2294
|
+
let a = Qn(i ?? "", t, n, r);
|
|
2252
2295
|
return fetch(a).then(async (e) => {
|
|
2253
2296
|
if (!e.ok) throw Error(`provenance fetch failed: HTTP ${e.status}`);
|
|
2254
2297
|
return await e.json();
|
|
@@ -2274,8 +2317,12 @@ var mt = () => {
|
|
|
2274
2317
|
n,
|
|
2275
2318
|
r
|
|
2276
2319
|
]), o;
|
|
2277
|
-
},
|
|
2278
|
-
|
|
2320
|
+
}, tr = "admin:full", nr = (e, t) => e.includes("admin:full") ? !0 : (typeof t == "string" ? [t] : t).every((t) => e.includes(t)), rr = (e, t) => t.length === 0 || e.includes("admin:full") ? !0 : t.some((t) => e.includes(t)), ir = e({ scopes: [] });
|
|
2321
|
+
function ar(e) {
|
|
2322
|
+
return t(ir.Provider, { value: { scopes: e.scopes } }, e.children);
|
|
2323
|
+
}
|
|
2324
|
+
var Z = () => r(ir), or = (e) => nr(Z().scopes, e), sr = (e) => rr(Z().scopes, e), cr = (e) => `${e.replace(/\/$/, "")}/_voltro/inspect/manifest`, lr = (e) => {
|
|
2325
|
+
let { inspectBaseUrl: t } = N(e), [n, r] = c({
|
|
2279
2326
|
manifest: void 0,
|
|
2280
2327
|
loading: !0,
|
|
2281
2328
|
error: void 0
|
|
@@ -2286,7 +2333,7 @@ var mt = () => {
|
|
|
2286
2333
|
manifest: void 0,
|
|
2287
2334
|
loading: !0,
|
|
2288
2335
|
error: void 0
|
|
2289
|
-
}), fetch(
|
|
2336
|
+
}), fetch(cr(t ?? "")).then(async (e) => {
|
|
2290
2337
|
if (!e.ok) throw Error(`manifest fetch failed: HTTP ${e.status}`);
|
|
2291
2338
|
return await e.json();
|
|
2292
2339
|
}).then((t) => {
|
|
@@ -2305,21 +2352,45 @@ var mt = () => {
|
|
|
2305
2352
|
e = !0;
|
|
2306
2353
|
};
|
|
2307
2354
|
}, [e, t]), n;
|
|
2308
|
-
},
|
|
2309
|
-
|
|
2355
|
+
}, ur = (e, t) => t.scope.length === 0 || (t.mode === "any" ? t.scope.some((t) => e.includes(t)) : t.scope.every((t) => e.includes(t))), dr = (e, t) => {
|
|
2356
|
+
if (e === void 0) return "unknown";
|
|
2357
|
+
if (t.includes("admin:full") || e.length === 0) return "allowed";
|
|
2358
|
+
let n = !1;
|
|
2359
|
+
for (let r of e) if (r.kind !== "open") {
|
|
2360
|
+
if (r.kind === "policy") {
|
|
2361
|
+
n = !0;
|
|
2362
|
+
continue;
|
|
2363
|
+
}
|
|
2364
|
+
if (!ur(t, r)) {
|
|
2365
|
+
if (r.resourceScoped) {
|
|
2366
|
+
n = !0;
|
|
2367
|
+
continue;
|
|
2368
|
+
}
|
|
2369
|
+
return "denied";
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
return n ? "unknown" : "allowed";
|
|
2373
|
+
}, fr = (e) => (e ?? []).flatMap((e) => e.kind === "scope" ? [...e.scope] : []), pr = (e) => {
|
|
2374
|
+
for (let t of e ?? []) if (t.kind === "open") return t.reason;
|
|
2375
|
+
}, mr = (e) => dr(e, Z().scopes), hr = (e, t) => Array.isArray(e) ? e.includes(t) : e === t, gr = (e, t, n) => e.targets?.some((e) => e.table === t && e.op === n) ?? !1, Q = (e) => e === void 0 ? {} : {
|
|
2376
|
+
tag: e.tag,
|
|
2377
|
+
...e.guards === void 0 ? {} : { guards: e.guards }
|
|
2378
|
+
}, _r = (e) => e.tables.filter((e) => !e.framework).map((t) => {
|
|
2379
|
+
let n = e.procedures.find((e) => e.kind === "query" && hr(e.source, t.name)), r = e.procedures.find((e) => e.kind === "mutation" && gr(e, t.name, "insert")), i = e.procedures.find((e) => e.kind === "mutation" && gr(e, t.name, "update")), a = e.procedures.find((e) => e.kind === "mutation" && gr(e, t.name, "delete")), o = t.pkColumn ?? (t.columns.some((e) => e.name === "id") ? "id" : void 0);
|
|
2310
2380
|
return {
|
|
2311
2381
|
table: t.name,
|
|
2312
|
-
columns: t.columns,
|
|
2382
|
+
columns: t.columns.filter((e) => e.serverOnly !== !0),
|
|
2383
|
+
serverOnlyColumns: t.columns.filter((e) => e.serverOnly === !0).map((e) => e.name),
|
|
2384
|
+
sensitiveColumns: t.columns.filter((e) => e.sensitive !== void 0).map((e) => e.name),
|
|
2313
2385
|
reactive: t.reactive,
|
|
2314
|
-
...
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
deleteScope: `${t.name}:delete`
|
|
2386
|
+
...o === void 0 ? {} : { pkColumn: o },
|
|
2387
|
+
editable: (t.editable ?? !0) && o !== void 0,
|
|
2388
|
+
list: Q(n),
|
|
2389
|
+
create: Q(r),
|
|
2390
|
+
update: Q(i),
|
|
2391
|
+
delete: Q(a)
|
|
2321
2392
|
};
|
|
2322
|
-
}),
|
|
2393
|
+
}), vr = (e) => {
|
|
2323
2394
|
let [t, r] = c([]), [i, a] = c([]), s = n((e) => {
|
|
2324
2395
|
r((t) => [...t, e]), a([]);
|
|
2325
2396
|
}, []), l = n(async () => {
|
|
@@ -2347,8 +2418,8 @@ var mt = () => {
|
|
|
2347
2418
|
l,
|
|
2348
2419
|
u
|
|
2349
2420
|
]);
|
|
2350
|
-
},
|
|
2351
|
-
let r = t?.limit, { data: i } =
|
|
2421
|
+
}, yr = "__voltro.undo.log", br = "__voltro.undo.apply", xr = "__voltro.undo.redo", Sr = (e, t) => {
|
|
2422
|
+
let r = t?.limit, { data: i } = V(e, yr, r === void 0 ? {} : { limit: r }), a = K(e, br), o = K(e, xr), s = i ?? [], c = s.find((e) => !e.undone && !e.crossesAction), l = s.find((e) => e.undone), u = n(async (e) => {
|
|
2352
2423
|
await a.mutate({ invocationId: e });
|
|
2353
2424
|
}, [a]), d = n(async (e) => {
|
|
2354
2425
|
await o.mutate({ invocationId: e });
|
|
@@ -2367,13 +2438,13 @@ var mt = () => {
|
|
|
2367
2438
|
undoLast: f,
|
|
2368
2439
|
redoLast: p
|
|
2369
2440
|
};
|
|
2370
|
-
},
|
|
2441
|
+
}, Cr = (e, t) => ({
|
|
2371
2442
|
name: e,
|
|
2372
2443
|
map: t
|
|
2373
|
-
}), $ = (e, t) => e === void 0 ? null : typeof e == "string" ? { event: e } : e(t),
|
|
2444
|
+
}), $ = (e, t) => e === void 0 ? null : typeof e == "string" ? { event: e } : e(t), wr = /* @__PURE__ */ new Set(["onMount", "onUnmount"]), Tr = (e, t, n) => {
|
|
2374
2445
|
let r = { ...t };
|
|
2375
2446
|
for (let [i, a] of Object.entries(e.map)) {
|
|
2376
|
-
if (
|
|
2447
|
+
if (wr.has(i) || a === void 0) continue;
|
|
2377
2448
|
let e = t[i];
|
|
2378
2449
|
r[i] = (...r) => {
|
|
2379
2450
|
let i = $(a, t);
|
|
@@ -2381,7 +2452,7 @@ var mt = () => {
|
|
|
2381
2452
|
};
|
|
2382
2453
|
}
|
|
2383
2454
|
return r;
|
|
2384
|
-
},
|
|
2455
|
+
}, Er = (e, t, n) => {
|
|
2385
2456
|
let r = s({
|
|
2386
2457
|
spec: e,
|
|
2387
2458
|
props: t,
|
|
@@ -2397,45 +2468,41 @@ var mt = () => {
|
|
|
2397
2468
|
let e = r.current, t = $(e.spec.map.onUnmount, e.props);
|
|
2398
2469
|
t !== null && e.sink(t);
|
|
2399
2470
|
};
|
|
2400
|
-
}, []), o(() =>
|
|
2471
|
+
}, []), o(() => Tr(e, t, n), [
|
|
2401
2472
|
e,
|
|
2402
2473
|
t,
|
|
2403
2474
|
n
|
|
2404
2475
|
]);
|
|
2405
|
-
},
|
|
2406
|
-
let n =
|
|
2407
|
-
return o(() => n === void 0 ? [] :
|
|
2408
|
-
},
|
|
2409
|
-
let n =
|
|
2410
|
-
return o(() => n === void 0 ? [] :
|
|
2411
|
-
},
|
|
2476
|
+
}, Dr = (e, t) => {
|
|
2477
|
+
let n = N(e).descriptors[t]?.input;
|
|
2478
|
+
return o(() => n === void 0 ? [] : X(n), [n]);
|
|
2479
|
+
}, Or = (e, t) => {
|
|
2480
|
+
let n = N(e).descriptors[t]?.output;
|
|
2481
|
+
return o(() => n === void 0 ? [] : Gn(n), [n]);
|
|
2482
|
+
}, kr = (e, t) => {
|
|
2412
2483
|
if (e === t) return !0;
|
|
2413
2484
|
if (e.length !== t.length) return !1;
|
|
2414
2485
|
for (let n = 0; n < e.length; n += 1) if (!Object.is(e[n], t[n])) return !1;
|
|
2415
2486
|
return !0;
|
|
2416
|
-
},
|
|
2417
|
-
let n = s(null), r =
|
|
2418
|
-
return (n.current === null || !
|
|
2487
|
+
}, Ar = (e) => Object.keys(e).sort().map((t) => e[t]), jr = (e, t) => {
|
|
2488
|
+
let n = s(null), r = Ar(e);
|
|
2489
|
+
return (n.current === null || !kr(n.current.key, r)) && (n.current = {
|
|
2419
2490
|
key: r,
|
|
2420
2491
|
value: t(e)
|
|
2421
2492
|
}), n.current.value;
|
|
2422
|
-
},
|
|
2423
|
-
|
|
2424
|
-
return t(vr.Provider, { value: { scopes: e.scopes } }, e.children);
|
|
2425
|
-
}
|
|
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);
|
|
2493
|
+
}, Mr = (e, t, n, r = {}) => {
|
|
2494
|
+
let i = V(e, t, { ...n }, r);
|
|
2428
2495
|
return o(() => ({
|
|
2429
2496
|
allowed: i.data?.allowed === !0,
|
|
2430
2497
|
pending: i.data === void 0
|
|
2431
2498
|
}), [i.data]);
|
|
2432
|
-
},
|
|
2433
|
-
let i =
|
|
2499
|
+
}, Nr = (e, t, n, r = {}) => {
|
|
2500
|
+
let i = V(e, t, { ...n }, r);
|
|
2434
2501
|
return o(() => ({
|
|
2435
2502
|
allowedIds: new Set(i.data?.allowedIds ?? []),
|
|
2436
2503
|
pending: i.data === void 0
|
|
2437
2504
|
}), [i.data]);
|
|
2438
|
-
},
|
|
2505
|
+
}, Pr = (e) => {
|
|
2439
2506
|
switch (e) {
|
|
2440
2507
|
case "select":
|
|
2441
2508
|
case "radio":
|
|
@@ -2451,25 +2518,25 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2451
2518
|
case "switch": return "boolean";
|
|
2452
2519
|
default: return null;
|
|
2453
2520
|
}
|
|
2454
|
-
},
|
|
2455
|
-
let t =
|
|
2521
|
+
}, Fr = (e) => X(e).map((e) => {
|
|
2522
|
+
let t = Pr(e.widget);
|
|
2456
2523
|
return t === null ? null : {
|
|
2457
2524
|
name: e.name,
|
|
2458
2525
|
label: e.label,
|
|
2459
2526
|
kind: t,
|
|
2460
2527
|
...e.options ? { options: e.options } : {}
|
|
2461
2528
|
};
|
|
2462
|
-
}).filter((e) => e !== null),
|
|
2529
|
+
}).filter((e) => e !== null), Ir = (e) => {
|
|
2463
2530
|
let t = {};
|
|
2464
2531
|
for (let [n, r] of Object.entries(e)) r === void 0 || r === "" || Array.isArray(r) && r.length === 0 || (t[n] = r);
|
|
2465
2532
|
return t;
|
|
2466
|
-
},
|
|
2467
|
-
let i =
|
|
2468
|
-
l((n) =>
|
|
2533
|
+
}, Lr = (e, t, r = {}) => {
|
|
2534
|
+
let i = N(e).descriptors[t]?.input, a = o(() => i === void 0 ? [] : Fr(i), [i]), [s, l] = c(r.initial ?? {}), u = n((e, t) => {
|
|
2535
|
+
l((n) => Ir({
|
|
2469
2536
|
...n,
|
|
2470
2537
|
[e]: t
|
|
2471
2538
|
}));
|
|
2472
|
-
}, []), d = n(() => l({}), []), f =
|
|
2539
|
+
}, []), d = n(() => l({}), []), f = V(e, t, o(() => Ir(s), [s]));
|
|
2473
2540
|
return {
|
|
2474
2541
|
filters: a,
|
|
2475
2542
|
values: s,
|
|
@@ -2480,20 +2547,20 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2480
2547
|
loading: f.data === void 0,
|
|
2481
2548
|
error: f.error
|
|
2482
2549
|
};
|
|
2483
|
-
},
|
|
2484
|
-
let r =
|
|
2550
|
+
}, Rr = (e, t, n = {}) => {
|
|
2551
|
+
let r = V(e, t, n), i = r.data;
|
|
2485
2552
|
return {
|
|
2486
2553
|
record: Array.isArray(i) ? i[0] : i,
|
|
2487
2554
|
loading: i === void 0,
|
|
2488
2555
|
error: r.error
|
|
2489
2556
|
};
|
|
2490
|
-
},
|
|
2557
|
+
}, zr = (e, t = 300) => {
|
|
2491
2558
|
let [n, r] = c(e);
|
|
2492
2559
|
return a(() => {
|
|
2493
2560
|
let n = setTimeout(() => r(e), t);
|
|
2494
2561
|
return () => clearTimeout(n);
|
|
2495
2562
|
}, [e, t]), n;
|
|
2496
|
-
},
|
|
2563
|
+
}, Br = (e) => {
|
|
2497
2564
|
let { value: t, debouncedValue: n, data: r, interpret: i, skipEmpty: a = !0 } = e;
|
|
2498
2565
|
if (a && t.trim() === "") return {
|
|
2499
2566
|
status: "idle",
|
|
@@ -2511,19 +2578,19 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2511
2578
|
valid: o.valid,
|
|
2512
2579
|
message: o.message
|
|
2513
2580
|
};
|
|
2514
|
-
},
|
|
2515
|
-
let { input: i, interpret: a, debounceMs: s = 300, skipEmpty: c = !0 } = r, l =
|
|
2516
|
-
return
|
|
2581
|
+
}, Vr = (e, t, n, r) => {
|
|
2582
|
+
let { input: i, interpret: a, debounceMs: s = 300, skipEmpty: c = !0 } = r, l = zr(n, s), u = c && l.trim() === "", d = V(e, t, o(() => i ? i(l) : { value: l }, [i, l]), { skip: u });
|
|
2583
|
+
return Br({
|
|
2517
2584
|
value: n,
|
|
2518
2585
|
debouncedValue: l,
|
|
2519
2586
|
data: u ? null : d.data,
|
|
2520
2587
|
interpret: a,
|
|
2521
2588
|
skipEmpty: c
|
|
2522
2589
|
});
|
|
2523
|
-
},
|
|
2590
|
+
}, Hr = (e, t) => ({
|
|
2524
2591
|
name: e,
|
|
2525
2592
|
payload: t
|
|
2526
|
-
}),
|
|
2593
|
+
}), Ur = (e, t) => {
|
|
2527
2594
|
let n = b.decodeUnknownEither(e.payload, { errors: "all" })(t);
|
|
2528
2595
|
if (n._tag === "Right") return {
|
|
2529
2596
|
valid: !0,
|
|
@@ -2535,15 +2602,15 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2535
2602
|
valid: !1,
|
|
2536
2603
|
errors: r
|
|
2537
2604
|
};
|
|
2538
|
-
},
|
|
2605
|
+
}, Wr = (e) => {
|
|
2539
2606
|
let t = new Map(e.map((e) => [e.name, e]));
|
|
2540
2607
|
return {
|
|
2541
2608
|
names: [...t.keys()].sort(),
|
|
2542
2609
|
get: (e) => t.get(e),
|
|
2543
2610
|
events: e
|
|
2544
2611
|
};
|
|
2545
|
-
},
|
|
2546
|
-
let n =
|
|
2612
|
+
}, Gr = (e, t) => {
|
|
2613
|
+
let n = Wr(e);
|
|
2547
2614
|
return {
|
|
2548
2615
|
track: (e, r) => {
|
|
2549
2616
|
let i = n.get(e);
|
|
@@ -2552,7 +2619,7 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2552
2619
|
return;
|
|
2553
2620
|
}
|
|
2554
2621
|
if (process.env.NODE_ENV !== "production") {
|
|
2555
|
-
let t =
|
|
2622
|
+
let t = Ur(i, r);
|
|
2556
2623
|
t.valid || console.error(`[@voltro/client] analytics.track('${e}'): payload failed its schema`, t.errors);
|
|
2557
2624
|
}
|
|
2558
2625
|
t({
|
|
@@ -2563,42 +2630,42 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2563
2630
|
names: n.names,
|
|
2564
2631
|
catalog: n
|
|
2565
2632
|
};
|
|
2566
|
-
},
|
|
2567
|
-
let r =
|
|
2633
|
+
}, Kr = (e, t) => {
|
|
2634
|
+
let r = q(e, t);
|
|
2568
2635
|
return {
|
|
2569
2636
|
preview: n((e) => r.run(e), [r]),
|
|
2570
2637
|
diff: r.lastResult,
|
|
2571
2638
|
pending: r.pending,
|
|
2572
2639
|
error: r.error
|
|
2573
2640
|
};
|
|
2574
|
-
},
|
|
2641
|
+
}, qr = (e, t, n, r) => [...e, {
|
|
2575
2642
|
id: t,
|
|
2576
2643
|
tag: n,
|
|
2577
2644
|
input: r,
|
|
2578
2645
|
status: "pending",
|
|
2579
2646
|
attempts: 0
|
|
2580
|
-
}],
|
|
2647
|
+
}], Jr = (e, t, n) => e.map((e) => e.id === t ? {
|
|
2581
2648
|
...e,
|
|
2582
2649
|
...n
|
|
2583
|
-
} : e),
|
|
2650
|
+
} : e), Yr = (e, t) => Jr(e, t, { status: "sent" }), Xr = (e, t, n) => e.map((e) => e.id === t ? {
|
|
2584
2651
|
...e,
|
|
2585
2652
|
status: "failed",
|
|
2586
2653
|
error: n,
|
|
2587
2654
|
attempts: e.attempts + 1
|
|
2588
|
-
} : e),
|
|
2655
|
+
} : e), Zr = (e, t, n) => Jr(e, t, {
|
|
2589
2656
|
status: "conflict",
|
|
2590
2657
|
error: n
|
|
2591
|
-
}),
|
|
2658
|
+
}), Qr = (e) => e.filter((e) => e.status !== "sent"), $r = (e) => {
|
|
2592
2659
|
let t = [];
|
|
2593
2660
|
for (let n of e) {
|
|
2594
2661
|
if (n.status === "conflict") break;
|
|
2595
2662
|
(n.status === "pending" || n.status === "failed") && t.push(n);
|
|
2596
2663
|
}
|
|
2597
2664
|
return t;
|
|
2598
|
-
},
|
|
2665
|
+
}, ei = (e) => {
|
|
2599
2666
|
let t = e;
|
|
2600
2667
|
return t?.conflict === !0 || t?._tag === "UndoBoundaryError" && t?.boundary === "conflict";
|
|
2601
|
-
},
|
|
2668
|
+
}, ti = (e) => {
|
|
2602
2669
|
let [t, n] = c(e ?? (typeof navigator < "u" ? navigator.onLine : !0));
|
|
2603
2670
|
return a(() => {
|
|
2604
2671
|
if (e !== void 0) {
|
|
@@ -2611,21 +2678,21 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2611
2678
|
window.removeEventListener("online", t), window.removeEventListener("offline", r);
|
|
2612
2679
|
};
|
|
2613
2680
|
}, [e]), t;
|
|
2614
|
-
},
|
|
2615
|
-
let { send: t, isConflict: r =
|
|
2681
|
+
}, ni = (e) => {
|
|
2682
|
+
let { send: t, isConflict: r = ei, idFor: i } = e, [o, l] = c([]), u = ti(e.online), d = s(o);
|
|
2616
2683
|
d.current = o;
|
|
2617
2684
|
let f = s(0), p = n((e, t) => {
|
|
2618
2685
|
let n = i?.() ?? `obx_${f.current++}_${e}`;
|
|
2619
|
-
l((r) =>
|
|
2686
|
+
l((r) => qr(r, n, e, t));
|
|
2620
2687
|
}, [i]), m = n(async () => {
|
|
2621
|
-
for (let e of
|
|
2622
|
-
await t(e), l((t) =>
|
|
2688
|
+
for (let e of $r(d.current)) try {
|
|
2689
|
+
await t(e), l((t) => Yr(t, e.id));
|
|
2623
2690
|
} catch (t) {
|
|
2624
2691
|
if (r(t)) {
|
|
2625
|
-
l((n) =>
|
|
2692
|
+
l((n) => Zr(n, e.id, t));
|
|
2626
2693
|
break;
|
|
2627
2694
|
}
|
|
2628
|
-
l((n) =>
|
|
2695
|
+
l((n) => Xr(n, e.id, t));
|
|
2629
2696
|
}
|
|
2630
2697
|
}, [t, r]);
|
|
2631
2698
|
return a(() => {
|
|
@@ -2638,7 +2705,7 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2638
2705
|
pending: o.filter((e) => e.status === "pending" || e.status === "failed").length,
|
|
2639
2706
|
conflicts: o.filter((e) => e.status === "conflict")
|
|
2640
2707
|
};
|
|
2641
|
-
},
|
|
2708
|
+
}, ri = (e) => {
|
|
2642
2709
|
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);
|
|
2643
2710
|
return {
|
|
2644
2711
|
startIndex: l,
|
|
@@ -2648,8 +2715,8 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2648
2715
|
topSpacer: l * r,
|
|
2649
2716
|
bottomSpacer: a === void 0 ? 0 : Math.max(0, (a - d) * r)
|
|
2650
2717
|
};
|
|
2651
|
-
},
|
|
2652
|
-
let { rowHeight: i, viewportHeight: a, overscan: s, total: l, input: u } = r, [d, f] = c(0), p = o(() =>
|
|
2718
|
+
}, ii = (e, t, r) => {
|
|
2719
|
+
let { rowHeight: i, viewportHeight: a, overscan: s, total: l, input: u } = r, [d, f] = c(0), p = o(() => ri({
|
|
2653
2720
|
scrollTop: d,
|
|
2654
2721
|
viewportHeight: a,
|
|
2655
2722
|
rowHeight: i,
|
|
@@ -2661,7 +2728,7 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2661
2728
|
i,
|
|
2662
2729
|
s,
|
|
2663
2730
|
l
|
|
2664
|
-
]), m =
|
|
2731
|
+
]), m = V(e, t, o(() => ({
|
|
2665
2732
|
...u,
|
|
2666
2733
|
offset: p.offset,
|
|
2667
2734
|
limit: p.limit
|
|
@@ -2681,8 +2748,8 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2681
2748
|
loading: m.data === void 0,
|
|
2682
2749
|
error: m.error
|
|
2683
2750
|
};
|
|
2684
|
-
},
|
|
2685
|
-
let { errorBus: t } =
|
|
2751
|
+
}, ai = () => typeof navigator > "u" || navigator.onLine, oi = (e) => {
|
|
2752
|
+
let { errorBus: t } = N(e), [r, i] = c(ai), [o, l] = c(0), [u, d] = c(void 0), f = s(!0);
|
|
2686
2753
|
a(() => (f.current = !0, () => {
|
|
2687
2754
|
f.current = !1;
|
|
2688
2755
|
}), []), a(() => {
|
|
@@ -2708,7 +2775,7 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2708
2775
|
lastFailureAt: u,
|
|
2709
2776
|
reportSuccess: p
|
|
2710
2777
|
};
|
|
2711
|
-
},
|
|
2778
|
+
}, si = "__voltro.connections.list", ci = "__voltro.connections.start", li = "__voltro.connections.submitToken", ui = "__voltro.connections.disconnect", di = {
|
|
2712
2779
|
connectionId: "",
|
|
2713
2780
|
kind: "oauth2",
|
|
2714
2781
|
label: "",
|
|
@@ -2719,14 +2786,14 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2719
2786
|
expiresAt: null,
|
|
2720
2787
|
lastError: null,
|
|
2721
2788
|
connectedAt: null
|
|
2722
|
-
},
|
|
2789
|
+
}, fi = (e, t) => {
|
|
2723
2790
|
if (t === "redirect") {
|
|
2724
2791
|
globalThis.location.assign(e);
|
|
2725
2792
|
return;
|
|
2726
2793
|
}
|
|
2727
2794
|
globalThis.open(e, "voltro-connect", "width=620,height=760,menubar=no,toolbar=no") === null && globalThis.location.assign(e);
|
|
2728
|
-
},
|
|
2729
|
-
let { data: t } =
|
|
2795
|
+
}, pi = (e) => {
|
|
2796
|
+
let { data: t } = V(e, si, {}), r = q(e, ci), i = K(e, li), a = K(e, ui), o = t ?? [], s = r.pending || i.pending || a.pending, c = n((e) => ({
|
|
2730
2797
|
...e,
|
|
2731
2798
|
connected: e.status === "connected",
|
|
2732
2799
|
needsAttention: e.status === "expired" || e.status === "revoked" || e.status === "error",
|
|
@@ -2734,7 +2801,7 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2734
2801
|
connect: async (t) => {
|
|
2735
2802
|
if (e.kind !== "oauth2") throw Error(`connection "${e.connectionId}" is a personal-access-token connection — call submitToken(token), not connect().`);
|
|
2736
2803
|
let n = t?.redirectTo ?? `${globalThis.location.pathname}${globalThis.location.search}`;
|
|
2737
|
-
|
|
2804
|
+
fi((await r.run({
|
|
2738
2805
|
connectionId: e.connectionId,
|
|
2739
2806
|
redirectTo: n
|
|
2740
2807
|
})).authorizeUrl, t?.mode);
|
|
@@ -2764,10 +2831,10 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2764
2831
|
get: l,
|
|
2765
2832
|
pending: s
|
|
2766
2833
|
};
|
|
2767
|
-
},
|
|
2768
|
-
let n =
|
|
2834
|
+
}, mi = (e, t) => {
|
|
2835
|
+
let n = pi(e), r = n.get(t);
|
|
2769
2836
|
return o(() => r === void 0 ? {
|
|
2770
|
-
...
|
|
2837
|
+
...di,
|
|
2771
2838
|
connectionId: t,
|
|
2772
2839
|
label: t,
|
|
2773
2840
|
connected: !1,
|
|
@@ -2792,6 +2859,6 @@ var br = () => r(vr), xr = (e) => gr(br().scopes, e), Sr = (e) => _r(br().scopes
|
|
|
2792
2859
|
n.loading,
|
|
2793
2860
|
n.pending
|
|
2794
2861
|
]);
|
|
2795
|
-
},
|
|
2862
|
+
}, hi = "framework-client";
|
|
2796
2863
|
//#endregion
|
|
2797
|
-
export {
|
|
2864
|
+
export { tr as ADMIN_SCOPE, hi as CLIENT_NAME, si as CONNECTIONS_LIST_TAG, ui as CONNECTION_DISCONNECT_TAG, ci as CONNECTION_START_TAG, li as CONNECTION_SUBMIT_TOKEN_TAG, ge as FrameworkRuntimesContext, we as FrameworkRuntimesProvider, me as LoadingSubscriptionCache, ar as PermissionProvider, he as RpcErrorBus, pe as SubscriptionCache, br as UNDO_APPLY_TAG, yr as UNDO_LOG_TAG, xr as UNDO_REDO_TAG, xe as _resetFrameworkRuntimesWarning, It as applyPreloadSeeds, et as applyStoreSeeds, Ce as buildApiRuntime, nr as canCall, rr as canCallAny, dt as clearMutations, Qr as clearSent, Le as clearStoreHistory, ri as computeWindow, Gr as createAnalytics, kt as createHooks, dr as decideAccess, Hr as defineEvent, Ye as defineStore, Cr as defineTracking, Je as definedStores, _r as deriveEntityAdmins, qr as enqueueEntry, Wr as eventCatalog, Fr as filtersFromSchema, yt as freshIdempotencyKey, mt as getMutationNotifier, lt as getMutations, P as isUnresolvedApi, At as makePreloadSeedBag, Ze as makeStoreSeedBag, cr as manifestUrl, Zr as markConflict, Xr as markFailed, Yr as markSent, pr as openAccessReason, $n as provenanceUrl, Nn as publishClientError, D as publishClientTrace, Lt as readPreloadedSnapshot, $r as replayable, Fn as reportClientError, fr as requiredScopes, Rt as resetPreloadSeeds, Xe as resetStoreRegistryForTests, B as resolveByTag, $ as resolveTrackingEvent, Cn as resumableConsumeProgram, Jn as rowsToOptions, Wt as runSequence, Gn as schemaToColumns, X as schemaToFields, Ft as seedPreloadedSubscription, $e as seedStore, Ut as sequence, pt as setMutationNotifier, Mt as setPreloadSeedResolver, Qe as setStoreSeedResolver, W as settleMutation, F as shallow, kr as shallowArrayEqual, Ar as sourceValues, ve as ssrClientProxy, ye as ssrStubHandle, O as stableKey, ct as startMutation, Fe as storeHistory, Pn as subscribeClientErrors, re as subscribeClientTraces, ut as subscribeMutations, Ie as subscribeStoreHistory, Re as travelToStoreState, mr as useAccessDecision, q as useAction, kn as useAgent, On as useAgentChat, Sn as useAgentStream, Vr as useAsyncValidation, or as useCan, sr as useCanAny, lr as useCapabilityManifest, mi as useConnection, oi as useConnectionStatus, pi as useConnections, An as useDataCopilot, Zn as useDataTable, zr as useDebounced, jr as useDerived, Ht as useEvent, qn as useFormBinding, Dr as useFormSkeleton, N as useFrameworkApi, Se as useFrameworkRuntimes, K as useMutation, In as useOnRpcError, ni as useOutbox, Z as usePermissions, zt as usePreloadedSubscription, Kr as usePreview, er as useProvenance, Yn as useQueryField, Lr as useQueryFilters, Rr as useRecord, jn as useRefreshSubscriptions, Mr as useResourceCan, Nr as useResourceCans, Tn as useResumableAgentStream, Gt as useSequence, V as useSubscription, Or as useTableSkeleton, Er as useTracking, vr as useUndo, Sr as useUndoLog, an as useUpload, ii as useWindowedSubscription, on as useWorkflow, mn as useWorkflowDomainEvents, hn as useWorkflowEventDeliveries, pn as useWorkflowEvents, ln as useWorkflowRun, fn as useWorkflowRunEvents, xn as useWorkflowRunState, dn as useWorkflowRunSteps, un as useWorkflowRuns, sn as useWorkflowSignal, cn as useWorkflowUpdate, Ur as validateEventPayload, Kn as validateFields, Br as validationStatus, bt as withIdempotencyKey, Tr as wrapTrackedCallbacks };
|