@statezero/core 0.2.53 → 0.2.55
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/dist/adaptors/vue/components/StateZeroDebugPanel.js +1039 -1172
- package/dist/adaptors/vue/composables.js +5 -0
- package/dist/core.css +1 -1
- package/dist/syncEngine/metrics/metricOptCalcs.d.ts +9 -78
- package/dist/syncEngine/metrics/metricOptCalcs.js +24 -277
- package/dist/syncEngine/registries/metricRegistry.d.ts +3 -0
- package/dist/syncEngine/registries/metricRegistry.js +10 -0
- package/dist/syncEngine/stores/metricStore.d.ts +18 -18
- package/dist/syncEngine/stores/metricStore.js +52 -91
- package/dist/syncEngine/stores/modelStore.js +28 -12
- package/dist/syncEngine/stores/operationEventHandlers.js +83 -349
- package/dist/syncEngine/stores/querysetStore.d.ts +11 -5
- package/dist/syncEngine/stores/querysetStore.js +142 -57
- package/dist/syncEngine/sync.js +2 -2
- package/package.json +1 -1
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { ref as J, computed as
|
|
2
|
-
import { v7 as
|
|
3
|
-
import { isNil as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { z as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
1
|
+
import { ref as J, computed as I, onMounted as hs, onBeforeUnmount as fs, watch as ot, createElementBlock as M, openBlock as A, createElementVNode as f, createVNode as St, toDisplayString as S, createCommentVNode as L, Fragment as W, renderList as ce, normalizeClass as Tt, normalizeStyle as it, withDirectives as Ue, createTextVNode as Qe, vModelCheckbox as Mt, vModelSelect as At, Transition as Ot, withCtx as $t } from "vue";
|
|
2
|
+
import { v7 as B } from "uuid";
|
|
3
|
+
import { isNil as b, isEmpty as Te, trim as dt, isEqual as He } from "lodash-es";
|
|
4
|
+
import Oe from "mitt";
|
|
5
|
+
import Ft from "handlebars";
|
|
6
|
+
import Pt from "superjson";
|
|
7
|
+
import ps from "p-queue";
|
|
8
|
+
import ms from "axios";
|
|
9
|
+
import { z as $ } from "zod";
|
|
10
|
+
import ys from "pusher-js";
|
|
11
|
+
import Wt, { createEqualsOperation as ee } from "sift";
|
|
12
12
|
import { DateTime as _e } from "luxon";
|
|
13
|
-
import { parse as
|
|
14
|
-
import { Graph as
|
|
13
|
+
import { parse as gs, format as _s } from "date-fns";
|
|
14
|
+
import { Graph as Dt } from "graphlib";
|
|
15
15
|
import Le from "object-hash";
|
|
16
|
-
import * as
|
|
17
|
-
import
|
|
18
|
-
const se = /* @__PURE__ */ new Map(),
|
|
19
|
-
function
|
|
20
|
-
return
|
|
16
|
+
import * as Zt from "mathjs";
|
|
17
|
+
import ws from "rfdc";
|
|
18
|
+
const se = /* @__PURE__ */ new Map(), ut = /* @__PURE__ */ new Set();
|
|
19
|
+
function Cs(n) {
|
|
20
|
+
return ut.add(n), () => ut.delete(n);
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function qe(n) {
|
|
23
23
|
return typeof n == "string" && /\{\{\s*TempPK_[^}\s]+\s*\}\}/.test(n);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function zt(n) {
|
|
26
26
|
return `{{TempPK_${n}}}`;
|
|
27
27
|
}
|
|
28
28
|
function Rt(n, e) {
|
|
29
29
|
const t = `{{TempPK_${n}}}`, s = `"TempPK_${n}"`, r = typeof e == "string" ? `"${e}"` : String(e);
|
|
30
30
|
se.set(s, r);
|
|
31
|
-
for (const o of
|
|
31
|
+
for (const o of ut)
|
|
32
32
|
try {
|
|
33
33
|
o(t, e);
|
|
34
34
|
} catch (i) {
|
|
35
35
|
console.warn("[tempPk] onResolve callback error:", i);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
if (!
|
|
38
|
+
function vs(n) {
|
|
39
|
+
if (!qe(String(n))) return n;
|
|
40
40
|
const e = String(n).match(/\{\{\s*TempPK_([^}\s]+)\s*\}\}/);
|
|
41
41
|
if (!e) return n;
|
|
42
42
|
const t = `"TempPK_${e[1]}"`, s = se.get(t);
|
|
43
43
|
return s ? s.startsWith('"') && s.endsWith('"') ? s.slice(1, -1) : parseInt(s, 10) : n;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function Je(n) {
|
|
46
46
|
if (se.size === 0) return n;
|
|
47
47
|
const e = Object.fromEntries(se);
|
|
48
48
|
try {
|
|
49
49
|
if (typeof n == "string")
|
|
50
|
-
return
|
|
51
|
-
const t =
|
|
52
|
-
return
|
|
50
|
+
return Ft.compile(n, { noEscape: !0 })(e);
|
|
51
|
+
const t = Pt.stringify(n), r = Ft.compile(t, { noEscape: !0 })(e);
|
|
52
|
+
return Pt.parse(r);
|
|
53
53
|
} catch {
|
|
54
54
|
return n;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
const
|
|
58
|
-
class
|
|
57
|
+
const ks = Oe(), bs = Oe(), Kt = Oe(), at = /* @__PURE__ */ new Map();
|
|
58
|
+
class Es {
|
|
59
59
|
constructor(e, t = {}) {
|
|
60
60
|
this.dbName = e, this.storeName = t.storeName || "keyval-store", this.batchDelay = t.batchDelay || 50, this.version = t.version || 5, this.resetOnErrors = t.resetOnErrors || [
|
|
61
61
|
"VersionError",
|
|
@@ -236,9 +236,9 @@ class Ss {
|
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
class
|
|
239
|
+
class Ct {
|
|
240
240
|
constructor(e, t = {}, s = null) {
|
|
241
|
-
|
|
241
|
+
at.has(e) ? this.store = at.get(e) : (this.store = new Es(e, t), at.set(e, this.store)), this.localMap = /* @__PURE__ */ new Map(), this.hydrate().then((r) => {
|
|
242
242
|
typeof s == "function" && s(r);
|
|
243
243
|
}).catch((r) => {
|
|
244
244
|
console.error(`Cache hydration failed for "${e}":`, r);
|
|
@@ -288,13 +288,13 @@ class Et {
|
|
|
288
288
|
const ge = (n, e) => {
|
|
289
289
|
if (!e || !e.pks || e.pks.length === 0) return;
|
|
290
290
|
const t = e.pks.map((r) => n._lastRenderedData.get(r) ?? null), s = n.render(e.pks, !0, !1);
|
|
291
|
-
if (!
|
|
291
|
+
if (!He(s, t)) {
|
|
292
292
|
const r = n.pkField;
|
|
293
293
|
for (const o of s)
|
|
294
294
|
o && o[r] != null && n._lastRenderedData.set(o[r], o);
|
|
295
295
|
for (const o of e.pks)
|
|
296
296
|
s.some((i) => i && i[r] === o) || n._lastRenderedData.set(o, null);
|
|
297
|
-
|
|
297
|
+
ks.emit(
|
|
298
298
|
`${n.modelClass.configKey}::${n.modelClass.modelName}::render`,
|
|
299
299
|
e
|
|
300
300
|
), n.renderCallbacks.forEach((o) => {
|
|
@@ -340,14 +340,14 @@ class Y {
|
|
|
340
340
|
return r.size > 0 ? new Y(t, Array.from(r)) : null;
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
class
|
|
343
|
+
class Ss {
|
|
344
344
|
modelClass;
|
|
345
345
|
fetchFn;
|
|
346
346
|
groundTruthArray;
|
|
347
347
|
operationsMap;
|
|
348
348
|
isSyncing;
|
|
349
349
|
constructor(e, t, s = null, r = null, o = {}) {
|
|
350
|
-
this.modelClass = e, this.fetchFn = t, this.isSyncing = !1, this.pruneThreshold = o.pruneThreshold || 10, this.groundTruthArray = s || [], this.operationsMap = /* @__PURE__ */ new Map(), r && r.length > 0 && this._loadOperations(r), this.modelCache = new
|
|
350
|
+
this.modelClass = e, this.fetchFn = t, this.isSyncing = !1, this.pruneThreshold = o.pruneThreshold || 10, this.groundTruthArray = s || [], this.operationsMap = /* @__PURE__ */ new Map(), r && r.length > 0 && this._loadOperations(r), this.modelCache = new Ct("model-cache", {}, this.onHydrated.bind(this)), this._lastRenderedData = /* @__PURE__ */ new Map(), this.renderCallbacks = /* @__PURE__ */ new Set(), this._unsubscribeTempPk = Cs((i, l) => {
|
|
351
351
|
if (this._lastRenderedData.has(i)) {
|
|
352
352
|
const a = this._lastRenderedData.get(i);
|
|
353
353
|
a && typeof a == "object" && (a[this.pkField] = l), this._lastRenderedData.set(l, a), this._lastRenderedData.delete(i);
|
|
@@ -363,7 +363,7 @@ class Ts {
|
|
|
363
363
|
*/
|
|
364
364
|
_loadOperations(e) {
|
|
365
365
|
e.forEach((t) => {
|
|
366
|
-
const s =
|
|
366
|
+
const s = Fe.get(t.operationId);
|
|
367
367
|
s ? this.operationsMap.set(s.operationId, s) : this.operationsMap.set(t.operationId, new q(t, !0));
|
|
368
368
|
});
|
|
369
369
|
}
|
|
@@ -374,7 +374,7 @@ class Ts {
|
|
|
374
374
|
onHydrated() {
|
|
375
375
|
if (this.groundTruthArray.length === 0 && this.operationsMap.size === 0) {
|
|
376
376
|
let e = this.modelCache.get(this.cacheKey);
|
|
377
|
-
!
|
|
377
|
+
!b(e) && !Te(e) && this.setGroundTruth(e);
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
setCache(e) {
|
|
@@ -382,7 +382,7 @@ class Ts {
|
|
|
382
382
|
let s = [];
|
|
383
383
|
e.forEach((r) => {
|
|
384
384
|
let o = r[t];
|
|
385
|
-
if (!(typeof o == "string" &&
|
|
385
|
+
if (!(typeof o == "string" && qe(o) && (o = Je(r[t]), b(o) || Te(dt(o)))))
|
|
386
386
|
if (r && typeof r.serialize == "function") {
|
|
387
387
|
const i = r.serialize(!0);
|
|
388
388
|
i[t] = o, s.push(i);
|
|
@@ -397,14 +397,14 @@ class Ts {
|
|
|
397
397
|
const s = this.pkField;
|
|
398
398
|
let r = [];
|
|
399
399
|
if (e.forEach((c) => {
|
|
400
|
-
let
|
|
401
|
-
typeof
|
|
400
|
+
let h = c[s];
|
|
401
|
+
typeof h == "string" && qe(h) && (h = Je(c[s]), b(h) || Te(dt(h))) || (c[s] = h, r.push(c));
|
|
402
402
|
}), t === null) {
|
|
403
403
|
this.setCache(r);
|
|
404
404
|
return;
|
|
405
405
|
}
|
|
406
406
|
const i = (this.modelCache.get(this.cacheKey) || []).filter(
|
|
407
|
-
(c) => c && typeof c == "object" && s in c && (!t.has(c[s]) || r.some((
|
|
407
|
+
(c) => c && typeof c == "object" && s in c && (!t.has(c[s]) || r.some((h) => h[s] === c[s]))
|
|
408
408
|
), l = new Map(
|
|
409
409
|
i.map((c) => [c[s], c])
|
|
410
410
|
);
|
|
@@ -478,18 +478,28 @@ class Ts {
|
|
|
478
478
|
r.push(l);
|
|
479
479
|
}
|
|
480
480
|
if (r.push(...Array.from(s.values())), this.groundTruthArray = r, i.length > 0) {
|
|
481
|
-
const l = new
|
|
482
|
-
|
|
483
|
-
type
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
});
|
|
489
|
-
this.operationsMap.set(
|
|
490
|
-
l.operationId,
|
|
491
|
-
l
|
|
481
|
+
const l = /* @__PURE__ */ new Set();
|
|
482
|
+
for (const c of this.operations)
|
|
483
|
+
if ((c.type === P.UPDATE || c.type === P.UPDATE_INSTANCE) && c.status !== C.CONFIRMED && c.status !== C.REJECTED)
|
|
484
|
+
for (const h of c.instances)
|
|
485
|
+
h && h[t] != null && l.add(h[t]);
|
|
486
|
+
const a = i.filter(
|
|
487
|
+
(c) => !l.has(c[t])
|
|
492
488
|
);
|
|
489
|
+
if (a.length > 0) {
|
|
490
|
+
const c = new q({
|
|
491
|
+
operationId: `checkpoint_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
492
|
+
type: P.CHECKPOINT,
|
|
493
|
+
instances: a,
|
|
494
|
+
status: C.CONFIRMED,
|
|
495
|
+
timestamp: Date.now(),
|
|
496
|
+
queryset: this.modelClass.objects.all()
|
|
497
|
+
});
|
|
498
|
+
this.operationsMap.set(
|
|
499
|
+
c.operationId,
|
|
500
|
+
c
|
|
501
|
+
);
|
|
502
|
+
}
|
|
493
503
|
}
|
|
494
504
|
ge(
|
|
495
505
|
this,
|
|
@@ -543,21 +553,21 @@ class Ts {
|
|
|
543
553
|
}
|
|
544
554
|
let o = r[s];
|
|
545
555
|
switch (e.type) {
|
|
546
|
-
case
|
|
547
|
-
case
|
|
556
|
+
case P.CREATE:
|
|
557
|
+
case P.BULK_CREATE:
|
|
548
558
|
t.has(o) || t.set(o, r);
|
|
549
559
|
break;
|
|
550
|
-
case
|
|
551
|
-
case
|
|
552
|
-
case
|
|
560
|
+
case P.CHECKPOINT:
|
|
561
|
+
case P.UPDATE_INSTANCE:
|
|
562
|
+
case P.UPDATE: {
|
|
553
563
|
const i = t.get(o);
|
|
554
564
|
i ? t.set(o, { ...i, ...r }) : this.operations.some(
|
|
555
|
-
(a) => a.type ===
|
|
565
|
+
(a) => a.type === P.DELETE && a.status !== C.REJECTED && a.instances.some((c) => c && c[s] === o)
|
|
556
566
|
) || t.set(o, r);
|
|
557
567
|
break;
|
|
558
568
|
}
|
|
559
|
-
case
|
|
560
|
-
case
|
|
569
|
+
case P.DELETE_INSTANCE:
|
|
570
|
+
case P.DELETE:
|
|
561
571
|
t.delete(o);
|
|
562
572
|
break;
|
|
563
573
|
default:
|
|
@@ -593,24 +603,24 @@ class Ts {
|
|
|
593
603
|
pruneUnreferencedInstances(e) {
|
|
594
604
|
const t = this.pkField, s = this.modelClass.modelName, r = /* @__PURE__ */ new Set();
|
|
595
605
|
for (const [l, a] of e._stores.entries())
|
|
596
|
-
a.modelClass.modelName === s && a.groundTruthPks.forEach((c) => r.add(c)), a.includedPks.has(s) && a.includedPks.get(s).forEach((
|
|
606
|
+
a.modelClass.modelName === s && a.groundTruthPks.forEach((c) => r.add(c)), a.includedPks.has(s) && a.includedPks.get(s).forEach((h) => r.add(h));
|
|
597
607
|
const o = this.groundTruthArray.filter((l) => !l || typeof l != "object" || !(t in l) ? !1 : r.has(l[t]));
|
|
598
608
|
this.groundTruthArray.length - o.length > 0 && (this.groundTruthArray = o, this.setCache(o));
|
|
599
609
|
}
|
|
600
610
|
// Render methods
|
|
601
611
|
render(e = null, t = !0, s = !0) {
|
|
602
612
|
if (s && e !== null) {
|
|
603
|
-
const o = (Array.isArray(e) ? e : [e]).map((a) =>
|
|
613
|
+
const o = (Array.isArray(e) ? e : [e]).map((a) => vs(a)), i = [];
|
|
604
614
|
for (const a of o)
|
|
605
615
|
this._lastRenderedData.has(a) || i.push(a);
|
|
606
616
|
if (i.length === 0)
|
|
607
617
|
return this._renderFromCache(o);
|
|
608
618
|
const l = this.pkField;
|
|
609
619
|
if (i.length < o.length) {
|
|
610
|
-
const a = o.filter((p) => this._lastRenderedData.has(p)), c = this._renderFromCache(a),
|
|
611
|
-
for (const p of
|
|
620
|
+
const a = o.filter((p) => this._lastRenderedData.has(p)), c = this._renderFromCache(a), h = this._renderFresh(i, t);
|
|
621
|
+
for (const p of h)
|
|
612
622
|
p && p[l] != null && this._lastRenderedData.set(p[l], p);
|
|
613
|
-
return [...c, ...
|
|
623
|
+
return [...c, ...h];
|
|
614
624
|
} else {
|
|
615
625
|
const a = this._renderFresh(o, t);
|
|
616
626
|
for (const c of a)
|
|
@@ -634,7 +644,7 @@ class Ts {
|
|
|
634
644
|
for (const l of o)
|
|
635
645
|
l.status !== C.REJECTED && (t || l.status === C.CONFIRMED) && this.applyOperation(l, r);
|
|
636
646
|
let i = Array.from(r.values());
|
|
637
|
-
return e && this.updateCache(i, s),
|
|
647
|
+
return e && this.updateCache(i, s), b(e) && this.setCache(i), i;
|
|
638
648
|
}
|
|
639
649
|
async sync(e = null) {
|
|
640
650
|
const t = this.modelClass.modelName;
|
|
@@ -669,7 +679,7 @@ class Ts {
|
|
|
669
679
|
}
|
|
670
680
|
}
|
|
671
681
|
}
|
|
672
|
-
class
|
|
682
|
+
class Ve {
|
|
673
683
|
constructor() {
|
|
674
684
|
this._stores = /* @__PURE__ */ new Map(), this.syncManager = () => {
|
|
675
685
|
console.warn("SyncManager not set for ModelStoreRegistry");
|
|
@@ -688,41 +698,43 @@ class Ge {
|
|
|
688
698
|
const t = async ({ pks: s, modelClass: r }) => await r.objects.filter({
|
|
689
699
|
[`${r.primaryKeyField}__in`]: s
|
|
690
700
|
}).fetch().serialize();
|
|
691
|
-
this._stores.set(e, new
|
|
701
|
+
this._stores.set(e, new Ss(e, t, null, null)), this.syncManager.followModel(this, e);
|
|
692
702
|
}
|
|
693
703
|
return this._stores.get(e);
|
|
694
704
|
}
|
|
695
705
|
// Get a single entity from the store
|
|
696
706
|
getEntity(e, t) {
|
|
697
|
-
if (
|
|
707
|
+
if (b(e) || b(t)) return;
|
|
698
708
|
if (t[e.primaryKeyField]) throw new Error("getEntity should be called with a pk not an object");
|
|
699
709
|
return this.getStore(e).render([t])[0] || null;
|
|
700
710
|
}
|
|
701
711
|
// Add or update an entity ground truth in the store, not for operations!
|
|
702
712
|
setEntity(e, t, s) {
|
|
703
|
-
if (
|
|
713
|
+
if (b(e) || b(t)) return;
|
|
704
714
|
if (t[e.primaryKeyField]) throw new Error("getEntity should be called with a pk not an object");
|
|
705
715
|
return this.getStore(e).addToGroundTruth([s]), s;
|
|
706
716
|
}
|
|
707
717
|
// Batch add or update entities in the store ground truth
|
|
708
718
|
setEntities(e, t) {
|
|
709
|
-
if (
|
|
719
|
+
if (b(e) || !t?.length) return;
|
|
710
720
|
this.getStore(e).addToGroundTruth(t);
|
|
711
721
|
}
|
|
712
722
|
}
|
|
713
|
-
const
|
|
723
|
+
const j = new Ve(), ie = Oe(), C = {
|
|
714
724
|
CREATED: "operation:created",
|
|
715
725
|
CONFIRMED: "operation:confirmed",
|
|
716
726
|
REJECTED: "operation:rejected",
|
|
717
727
|
CLEAR: "clear:all",
|
|
718
728
|
MUTATED: "operation:mutated"
|
|
719
|
-
},
|
|
729
|
+
}, P = {
|
|
720
730
|
CREATE: "create",
|
|
721
731
|
BULK_CREATE: "bulk_create",
|
|
722
732
|
UPDATE: "update",
|
|
723
733
|
DELETE: "delete",
|
|
724
734
|
UPDATE_INSTANCE: "update_instance",
|
|
725
735
|
DELETE_INSTANCE: "delete_instance",
|
|
736
|
+
GET_OR_CREATE: "get_or_create",
|
|
737
|
+
UPDATE_OR_CREATE: "update_or_create",
|
|
726
738
|
CHECKPOINT: "checkpoint"
|
|
727
739
|
};
|
|
728
740
|
class q {
|
|
@@ -743,15 +755,15 @@ class q {
|
|
|
743
755
|
throw new Error("Operation data must include a 'type'.");
|
|
744
756
|
if (!e.instances)
|
|
745
757
|
throw new Error("Operation data must include 'instances'.");
|
|
746
|
-
this.operationId = e.operationId || `op_${
|
|
758
|
+
this.operationId = e.operationId || `op_${B()}`, this.type = e.type, this.status = e.status || C.CREATED, this.queryset = e.queryset, this.args = e.args, this.doNotPropagate = e.doNotPropagate || !1, this.localOnly = e.localOnly || !1;
|
|
747
759
|
let s = this.queryset.ModelClass, r = e.instances;
|
|
748
|
-
|
|
760
|
+
b(r) || (r = Array.isArray(e.instances) ? e.instances : [e.instances]);
|
|
749
761
|
let o = s.primaryKeyField;
|
|
750
|
-
if (r.some((a) =>
|
|
762
|
+
if (r.some((a) => b(a) || typeof a != "object" || !(o in a)))
|
|
751
763
|
throw new Error(`All operation instances must be objects with the '${o}' field`);
|
|
752
764
|
this.#e = r;
|
|
753
765
|
const i = r.map((a) => a[o]);
|
|
754
|
-
|
|
766
|
+
j.getStore(s).render(i, !0, !1), this.#t = r.map((a) => s.fromPk(a[o]).serialize()), this.timestamp = e.timestamp || Date.now(), !t && (Fe.register(this), ie.emit(C.CREATED, this));
|
|
755
767
|
}
|
|
756
768
|
/**
|
|
757
769
|
* Getter for instances that replaces any temporary PKs with real PKs
|
|
@@ -818,7 +830,7 @@ class q {
|
|
|
818
830
|
return e.instances && !Array.isArray(e.instances) && (e.instances = [e.instances]), Object.assign(this, e), this.timestamp = Date.now(), ie.emit(C.MUTATED, this), this;
|
|
819
831
|
}
|
|
820
832
|
}
|
|
821
|
-
class
|
|
833
|
+
class Ts {
|
|
822
834
|
constructor() {
|
|
823
835
|
this._operations = /* @__PURE__ */ new Map(), this._querysetStates = /* @__PURE__ */ new Map();
|
|
824
836
|
}
|
|
@@ -903,9 +915,9 @@ class Ms {
|
|
|
903
915
|
return t.length > 0 ? t[t.length - 1] : void 0;
|
|
904
916
|
}
|
|
905
917
|
}
|
|
906
|
-
const
|
|
918
|
+
const Fe = new Ts(), Ms = Oe();
|
|
907
919
|
function As(n) {
|
|
908
|
-
|
|
920
|
+
Ms.emit("error", n);
|
|
909
921
|
}
|
|
910
922
|
class fe extends Error {
|
|
911
923
|
/**
|
|
@@ -939,7 +951,7 @@ class fe extends Error {
|
|
|
939
951
|
return this.message;
|
|
940
952
|
}
|
|
941
953
|
}
|
|
942
|
-
class
|
|
954
|
+
class $e extends fe {
|
|
943
955
|
/**
|
|
944
956
|
* Creates a new ValidationError.
|
|
945
957
|
*
|
|
@@ -950,7 +962,7 @@ class Oe extends fe {
|
|
|
950
962
|
super("Validation error", "validation_error", e, t), this.name = "ValidationError";
|
|
951
963
|
}
|
|
952
964
|
}
|
|
953
|
-
class
|
|
965
|
+
class It extends fe {
|
|
954
966
|
/**
|
|
955
967
|
* Creates a new DoesNotExist error.
|
|
956
968
|
*
|
|
@@ -961,7 +973,7 @@ class xt extends fe {
|
|
|
961
973
|
super("DoesNotExist", "does_not_exist", e, t), this.name = "DoesNotExist";
|
|
962
974
|
}
|
|
963
975
|
}
|
|
964
|
-
class
|
|
976
|
+
class lt extends fe {
|
|
965
977
|
/**
|
|
966
978
|
* Creates a new PermissionDenied error.
|
|
967
979
|
*
|
|
@@ -983,7 +995,7 @@ class Os extends fe {
|
|
|
983
995
|
super("Multiple objects returned", "multiple_objects_returned", e, t), this.name = "MultipleObjectsReturned";
|
|
984
996
|
}
|
|
985
997
|
}
|
|
986
|
-
class
|
|
998
|
+
class Nt extends fe {
|
|
987
999
|
/**
|
|
988
1000
|
* Creates a new ConflictError.
|
|
989
1001
|
*
|
|
@@ -994,7 +1006,7 @@ class jt extends fe {
|
|
|
994
1006
|
super("Conflict", "conflict", e, t), this.name = "ConflictError";
|
|
995
1007
|
}
|
|
996
1008
|
}
|
|
997
|
-
class
|
|
1009
|
+
class $s extends fe {
|
|
998
1010
|
/**
|
|
999
1011
|
* Creates a new ASTValidationError.
|
|
1000
1012
|
*
|
|
@@ -1005,7 +1017,7 @@ class Ps extends fe {
|
|
|
1005
1017
|
super("Query syntax error", "ast_validation_error", e, t), this.name = "ASTValidationError";
|
|
1006
1018
|
}
|
|
1007
1019
|
}
|
|
1008
|
-
class
|
|
1020
|
+
class U extends fe {
|
|
1009
1021
|
/**
|
|
1010
1022
|
* Creates a new ConfigError.
|
|
1011
1023
|
*
|
|
@@ -1019,33 +1031,33 @@ class x extends fe {
|
|
|
1019
1031
|
function Fs(n) {
|
|
1020
1032
|
const { status: e, type: t, detail: s } = n;
|
|
1021
1033
|
if (t === void 0 && s === "Invalid token.")
|
|
1022
|
-
return new
|
|
1034
|
+
return new lt(s, 403);
|
|
1023
1035
|
switch (t) {
|
|
1024
1036
|
// Direct mappings
|
|
1025
1037
|
case "ValidationError":
|
|
1026
|
-
return new
|
|
1038
|
+
return new $e(s, e);
|
|
1027
1039
|
case "NotFound":
|
|
1028
|
-
return new
|
|
1040
|
+
return new It(s, e);
|
|
1029
1041
|
case "MultipleObjectsReturned":
|
|
1030
1042
|
return new Os(s, e);
|
|
1031
1043
|
case "PermissionDenied":
|
|
1032
|
-
return new
|
|
1044
|
+
return new lt(s, e);
|
|
1033
1045
|
case "ConflictError":
|
|
1034
|
-
return new
|
|
1046
|
+
return new Nt(s, e);
|
|
1035
1047
|
case "ASTValidationError":
|
|
1036
|
-
return new
|
|
1048
|
+
return new $s(s, e);
|
|
1037
1049
|
case "ConfigError":
|
|
1038
|
-
return new
|
|
1050
|
+
return new U(s, e);
|
|
1039
1051
|
// Django error types that map to our error classes
|
|
1040
1052
|
case "FieldError":
|
|
1041
|
-
return new
|
|
1053
|
+
return new $e(s, e);
|
|
1042
1054
|
case "ValueError":
|
|
1043
|
-
return new
|
|
1055
|
+
return new $e(s, e);
|
|
1044
1056
|
default:
|
|
1045
|
-
return e === 400 ? new
|
|
1057
|
+
return e === 400 ? new $e(s, e) : e === 403 ? new lt(s, e) : e === 404 ? new It(s, e) : e === 409 ? new Nt(s, e) : new fe("Unknown error", "unknown", s, e);
|
|
1046
1058
|
}
|
|
1047
1059
|
}
|
|
1048
|
-
const
|
|
1060
|
+
const xt = {
|
|
1049
1061
|
CREATE: "create",
|
|
1050
1062
|
UPDATE: "update",
|
|
1051
1063
|
DELETE: "delete",
|
|
@@ -1053,7 +1065,7 @@ const Ut = {
|
|
|
1053
1065
|
BULK_UPDATE: "bulk_update",
|
|
1054
1066
|
BULK_DELETE: "bulk_delete"
|
|
1055
1067
|
};
|
|
1056
|
-
class
|
|
1068
|
+
class Ps {
|
|
1057
1069
|
/**
|
|
1058
1070
|
* @param {PusherReceiverOptions} options
|
|
1059
1071
|
* @param {string} configKey - The backend configuration key
|
|
@@ -1063,7 +1075,7 @@ class Is {
|
|
|
1063
1075
|
this.configKey = t, this.connectionTimeoutId = null, s.appKey && /^\d+$/.test(s.appKey) && s.appKey.length < 15 && console.warn(
|
|
1064
1076
|
`%c[Pusher Warning] The provided appKey ("${s.appKey}") looks like a numeric app_id. Pusher requires the alphanumeric key, not the ID. Please verify your configuration for backend: "${this.configKey}".`,
|
|
1065
1077
|
"color: orange; font-weight: bold; font-size: 14px;"
|
|
1066
|
-
), this.pusherClient = new
|
|
1078
|
+
), this.pusherClient = new ys(s.appKey, {
|
|
1067
1079
|
cluster: s.cluster,
|
|
1068
1080
|
forceTLS: s.forceTLS ?? !0,
|
|
1069
1081
|
authEndpoint: s.authEndpoint,
|
|
@@ -1143,7 +1155,7 @@ Common causes:
|
|
|
1143
1155
|
`%cAuthentication failed for channel ${t}. Check your authEndpoint and server-side permissions.`,
|
|
1144
1156
|
"color: orange; font-weight: bold;"
|
|
1145
1157
|
);
|
|
1146
|
-
}), Object.values(
|
|
1158
|
+
}), Object.values(xt).forEach((r) => {
|
|
1147
1159
|
s.bind(r, (o) => {
|
|
1148
1160
|
const i = {
|
|
1149
1161
|
...o,
|
|
@@ -1158,7 +1170,7 @@ Common causes:
|
|
|
1158
1170
|
unsubscribe(e) {
|
|
1159
1171
|
const t = this.channels.get(e);
|
|
1160
1172
|
if (!t) return;
|
|
1161
|
-
Object.values(
|
|
1173
|
+
Object.values(xt).forEach((r) => {
|
|
1162
1174
|
t.unbind(r);
|
|
1163
1175
|
});
|
|
1164
1176
|
const s = e.startsWith("private-") ? e : this.formatChannelName(e);
|
|
@@ -1200,67 +1212,67 @@ Common causes:
|
|
|
1200
1212
|
return this.namespaceResolver(e);
|
|
1201
1213
|
}
|
|
1202
1214
|
}
|
|
1203
|
-
const
|
|
1215
|
+
const We = /* @__PURE__ */ new Map();
|
|
1204
1216
|
function Ds(n, e) {
|
|
1205
|
-
const t =
|
|
1206
|
-
t && t.disconnect(),
|
|
1217
|
+
const t = We.get(n);
|
|
1218
|
+
t && t.disconnect(), We.set(n, e), e.connect();
|
|
1207
1219
|
}
|
|
1208
|
-
function
|
|
1209
|
-
return
|
|
1220
|
+
function jt(n = "default") {
|
|
1221
|
+
return We.get(n);
|
|
1210
1222
|
}
|
|
1211
1223
|
function zs() {
|
|
1212
|
-
return
|
|
1224
|
+
return We;
|
|
1213
1225
|
}
|
|
1214
|
-
let
|
|
1226
|
+
let Ut = {
|
|
1215
1227
|
backendConfigs: {}
|
|
1216
1228
|
};
|
|
1217
|
-
const
|
|
1218
|
-
clientOptions:
|
|
1219
|
-
appKey:
|
|
1220
|
-
cluster:
|
|
1221
|
-
forceTLS:
|
|
1222
|
-
authEndpoint:
|
|
1223
|
-
getAuthHeaders:
|
|
1229
|
+
const Rs = $.object({
|
|
1230
|
+
clientOptions: $.object({
|
|
1231
|
+
appKey: $.string({ required_error: "Pusher appKey is required" }),
|
|
1232
|
+
cluster: $.string({ required_error: "Pusher cluster is required" }),
|
|
1233
|
+
forceTLS: $.boolean().optional(),
|
|
1234
|
+
authEndpoint: $.string().url("Pusher authentication endpoint URL is required"),
|
|
1235
|
+
getAuthHeaders: $.function().optional().refine(
|
|
1224
1236
|
(n) => n === void 0 || typeof n == "function",
|
|
1225
1237
|
"getAuthHeaders must be a function if provided"
|
|
1226
1238
|
)
|
|
1227
1239
|
})
|
|
1228
|
-
}),
|
|
1229
|
-
type:
|
|
1230
|
-
websocketUrl:
|
|
1231
|
-
pusher:
|
|
1232
|
-
hotpaths:
|
|
1240
|
+
}), Ks = $.object({
|
|
1241
|
+
type: $.enum(["websocket", "pusher", "none"]),
|
|
1242
|
+
websocketUrl: $.string().url().optional(),
|
|
1243
|
+
pusher: Rs.optional(),
|
|
1244
|
+
hotpaths: $.array($.string()).default(["default"])
|
|
1233
1245
|
}).superRefine((n, e) => {
|
|
1234
1246
|
n.type === "websocket" && (n.websocketUrl || e.addIssue({
|
|
1235
|
-
code:
|
|
1247
|
+
code: $.ZodIssueCode.custom,
|
|
1236
1248
|
path: ["websocketUrl"],
|
|
1237
1249
|
message: "WebSocket URL is required for WebSocket event receiver"
|
|
1238
1250
|
})), n.type === "pusher" && (n.pusher || e.addIssue({
|
|
1239
|
-
code:
|
|
1251
|
+
code: $.ZodIssueCode.custom,
|
|
1240
1252
|
path: ["pusher"],
|
|
1241
1253
|
message: "Pusher configuration is required for Pusher event receiver"
|
|
1242
1254
|
}));
|
|
1243
|
-
}), Be =
|
|
1244
|
-
API_URL:
|
|
1245
|
-
GENERATED_TYPES_DIR:
|
|
1255
|
+
}), Be = $.object({
|
|
1256
|
+
API_URL: $.string().url("API_URL must be a valid URL"),
|
|
1257
|
+
GENERATED_TYPES_DIR: $.string({
|
|
1246
1258
|
required_error: "GENERATED_TYPES_DIR is required"
|
|
1247
1259
|
}),
|
|
1248
|
-
GENERATED_ACTIONS_DIR:
|
|
1249
|
-
BACKEND_TZ:
|
|
1250
|
-
SYNC_TOKEN:
|
|
1251
|
-
fileRootURL:
|
|
1252
|
-
fileUploadMode:
|
|
1253
|
-
getAuthHeaders:
|
|
1260
|
+
GENERATED_ACTIONS_DIR: $.string().optional(),
|
|
1261
|
+
BACKEND_TZ: $.string().optional(),
|
|
1262
|
+
SYNC_TOKEN: $.string().optional(),
|
|
1263
|
+
fileRootURL: $.string().url("fileRootURL must be a valid URL").optional(),
|
|
1264
|
+
fileUploadMode: $.enum(["server", "s3"]).default("server"),
|
|
1265
|
+
getAuthHeaders: $.function().optional().refine(
|
|
1254
1266
|
(n) => n === void 0 || typeof n == "function",
|
|
1255
1267
|
"getAuthHeaders must be a function if provided"
|
|
1256
1268
|
),
|
|
1257
|
-
eventInterceptor:
|
|
1269
|
+
eventInterceptor: $.function().optional().refine(
|
|
1258
1270
|
(n) => n === void 0 || typeof n == "function",
|
|
1259
1271
|
"eventInterceptor must be a function if provided"
|
|
1260
1272
|
),
|
|
1261
|
-
events:
|
|
1262
|
-
}),
|
|
1263
|
-
backendConfigs:
|
|
1273
|
+
events: $.lazy(() => Ks.optional())
|
|
1274
|
+
}), Is = $.object({
|
|
1275
|
+
backendConfigs: $.record($.string(), Be).refine(
|
|
1264
1276
|
(n) => {
|
|
1265
1277
|
for (const [e, t] of Object.entries(n))
|
|
1266
1278
|
if (!Be.safeParse(t).success)
|
|
@@ -1279,43 +1291,43 @@ const Ks = P.object({
|
|
|
1279
1291
|
return { message: e.join("; ") };
|
|
1280
1292
|
}
|
|
1281
1293
|
),
|
|
1282
|
-
periodicSyncIntervalSeconds:
|
|
1294
|
+
periodicSyncIntervalSeconds: $.number().min(5).nullable().optional().default(null)
|
|
1283
1295
|
});
|
|
1284
|
-
let
|
|
1285
|
-
function
|
|
1286
|
-
|
|
1287
|
-
const e =
|
|
1296
|
+
let ht = null;
|
|
1297
|
+
function Ns(n) {
|
|
1298
|
+
Ut = n;
|
|
1299
|
+
const e = Is.safeParse(Ut);
|
|
1288
1300
|
if (!e.success) {
|
|
1289
1301
|
const t = e.error.errors.map((s) => s.message);
|
|
1290
|
-
throw new
|
|
1302
|
+
throw new U(`Error setting configuration: ${t.join(", ")}`);
|
|
1291
1303
|
}
|
|
1292
|
-
|
|
1304
|
+
ht = e.data;
|
|
1293
1305
|
}
|
|
1294
1306
|
function he() {
|
|
1295
|
-
if (!
|
|
1296
|
-
throw new
|
|
1297
|
-
return
|
|
1307
|
+
if (!ht)
|
|
1308
|
+
throw new U("Configuration not set. Please call setConfig() with a valid configuration.");
|
|
1309
|
+
return ht;
|
|
1298
1310
|
}
|
|
1299
|
-
function
|
|
1311
|
+
function xs(n, e) {
|
|
1300
1312
|
try {
|
|
1301
1313
|
const t = he();
|
|
1302
1314
|
if (!t.backendConfigs[n])
|
|
1303
|
-
throw new
|
|
1315
|
+
throw new U(`Backend "${n}" not found in configuration.`);
|
|
1304
1316
|
const s = { ...t.backendConfigs[n], ...e }, r = Be.safeParse(s);
|
|
1305
1317
|
if (!r.success) {
|
|
1306
1318
|
const o = r.error.errors.map((i) => i.message);
|
|
1307
|
-
throw new
|
|
1319
|
+
throw new U(`Invalid backend configuration: ${o.join(", ")}`);
|
|
1308
1320
|
}
|
|
1309
1321
|
t.backendConfigs[n] = r.data;
|
|
1310
1322
|
} catch (t) {
|
|
1311
|
-
throw t instanceof
|
|
1323
|
+
throw t instanceof U ? t : new U(t.message || "Invalid backend configuration");
|
|
1312
1324
|
}
|
|
1313
1325
|
}
|
|
1314
|
-
function
|
|
1326
|
+
function Yt(n = "default") {
|
|
1315
1327
|
try {
|
|
1316
1328
|
const e = he();
|
|
1317
1329
|
if (!e.backendConfigs[n])
|
|
1318
|
-
throw new
|
|
1330
|
+
throw new U(`Backend "${n}" not found in configuration.`);
|
|
1319
1331
|
const t = e.backendConfigs[n];
|
|
1320
1332
|
if (!t.events)
|
|
1321
1333
|
return null;
|
|
@@ -1323,9 +1335,9 @@ function es(n = "default") {
|
|
|
1323
1335
|
switch (t.events.type) {
|
|
1324
1336
|
case "pusher":
|
|
1325
1337
|
if (!t.events.pusher || !t.events.pusher.clientOptions)
|
|
1326
|
-
throw new
|
|
1338
|
+
throw new U("Pusher client options are required for Pusher event receiver.");
|
|
1327
1339
|
if (!t.events.pusher.clientOptions.authEndpoint)
|
|
1328
|
-
throw new
|
|
1340
|
+
throw new U("Pusher auth endpoint is required for Pusher event receiver.");
|
|
1329
1341
|
const r = t.events.pusher.clientOptions.getAuthHeaders || t.getAuthHeaders, o = t.SYNC_TOKEN, i = () => {
|
|
1330
1342
|
const a = r ? r() : {};
|
|
1331
1343
|
return o ? { ...a, "X-StateZero-Sync-Token": o } : a;
|
|
@@ -1333,70 +1345,70 @@ function es(n = "default") {
|
|
|
1333
1345
|
...t.events.pusher.clientOptions,
|
|
1334
1346
|
getAuthHeaders: i
|
|
1335
1347
|
};
|
|
1336
|
-
s = new
|
|
1348
|
+
s = new Ps({ clientOptions: l }, n);
|
|
1337
1349
|
break;
|
|
1338
1350
|
case "none":
|
|
1339
1351
|
return null;
|
|
1340
1352
|
default:
|
|
1341
|
-
throw new
|
|
1353
|
+
throw new U(`Unknown event receiver type: ${t.events.type}`);
|
|
1342
1354
|
}
|
|
1343
1355
|
return s && Ds(n, s), s;
|
|
1344
1356
|
} catch (e) {
|
|
1345
|
-
throw e instanceof
|
|
1357
|
+
throw e instanceof U ? e : new U(`Failed to initialize event receiver: ${e.message}`);
|
|
1346
1358
|
}
|
|
1347
1359
|
}
|
|
1348
|
-
function
|
|
1360
|
+
function js() {
|
|
1349
1361
|
try {
|
|
1350
1362
|
const n = he(), e = {};
|
|
1351
1363
|
return Object.keys(n.backendConfigs).forEach((t) => {
|
|
1352
1364
|
try {
|
|
1353
|
-
e[t] =
|
|
1365
|
+
e[t] = Yt(t);
|
|
1354
1366
|
} catch (s) {
|
|
1355
1367
|
console.warn(`Failed to initialize event receiver for backend "${t}": ${s.message}`);
|
|
1356
1368
|
}
|
|
1357
1369
|
}), e;
|
|
1358
1370
|
} catch (n) {
|
|
1359
|
-
throw new
|
|
1371
|
+
throw new U(`Failed to initialize event receivers: ${n.message}`);
|
|
1360
1372
|
}
|
|
1361
1373
|
}
|
|
1362
|
-
let
|
|
1363
|
-
function
|
|
1374
|
+
let ft = null;
|
|
1375
|
+
function Us(n) {
|
|
1364
1376
|
if (typeof n != "function")
|
|
1365
|
-
throw new
|
|
1366
|
-
|
|
1377
|
+
throw new U("Provided model getter must be a function.");
|
|
1378
|
+
ft = n;
|
|
1367
1379
|
}
|
|
1368
|
-
function
|
|
1380
|
+
function Qs(n, e = "default") {
|
|
1369
1381
|
if (n && n.startsWith("http"))
|
|
1370
1382
|
return n;
|
|
1371
1383
|
const s = he().backendConfigs[e];
|
|
1372
1384
|
if (!s)
|
|
1373
|
-
throw new
|
|
1385
|
+
throw new U(`Backend "${e}" not found in configuration.`);
|
|
1374
1386
|
return s.fileRootURL ? s.fileRootURL.replace(/\/$/, "") + n : n;
|
|
1375
1387
|
}
|
|
1376
|
-
function
|
|
1377
|
-
if (!
|
|
1378
|
-
throw new
|
|
1379
|
-
return
|
|
1388
|
+
function Xt(n, e) {
|
|
1389
|
+
if (!ft)
|
|
1390
|
+
throw new U("Model registry not registered. Please call registerModelGetter() with the function from model-registry.js during app initialization.");
|
|
1391
|
+
return ft(n, e);
|
|
1380
1392
|
}
|
|
1381
|
-
const
|
|
1382
|
-
setConfig:
|
|
1393
|
+
const De = {
|
|
1394
|
+
setConfig: Ns,
|
|
1383
1395
|
getConfig: he,
|
|
1384
|
-
setBackendConfig:
|
|
1385
|
-
initializeEventReceiver:
|
|
1386
|
-
registerModelGetter:
|
|
1387
|
-
getModelClass:
|
|
1388
|
-
buildFileUrl:
|
|
1389
|
-
},
|
|
1390
|
-
emitter:
|
|
1396
|
+
setBackendConfig: xs,
|
|
1397
|
+
initializeEventReceiver: Yt,
|
|
1398
|
+
registerModelGetter: Us,
|
|
1399
|
+
getModelClass: Xt,
|
|
1400
|
+
buildFileUrl: Qs
|
|
1401
|
+
}, es = "__STATEZERO_DEBUG__", X = globalThis[es] || {
|
|
1402
|
+
emitter: Oe(),
|
|
1391
1403
|
buffer: [],
|
|
1392
1404
|
enabled: !0,
|
|
1393
1405
|
started: !1,
|
|
1394
1406
|
maxEntries: 500,
|
|
1395
1407
|
nextId: 1
|
|
1396
1408
|
};
|
|
1397
|
-
globalThis[
|
|
1409
|
+
globalThis[es] = X;
|
|
1398
1410
|
const Me = X.emitter, ue = X.buffer;
|
|
1399
|
-
function
|
|
1411
|
+
function Se(n) {
|
|
1400
1412
|
if (!X.enabled) return;
|
|
1401
1413
|
const e = {
|
|
1402
1414
|
id: X.nextId++,
|
|
@@ -1405,28 +1417,28 @@ function Te(n) {
|
|
|
1405
1417
|
};
|
|
1406
1418
|
ue.push(e), ue.length > X.maxEntries && ue.shift(), Me.emit("record", e);
|
|
1407
1419
|
}
|
|
1408
|
-
function
|
|
1409
|
-
|
|
1420
|
+
function G(n) {
|
|
1421
|
+
Se(n);
|
|
1410
1422
|
}
|
|
1411
1423
|
function Ls(n) {
|
|
1412
1424
|
return Me.on("record", n), () => Me.off("record", n);
|
|
1413
1425
|
}
|
|
1414
|
-
function
|
|
1426
|
+
function Vs(n) {
|
|
1415
1427
|
return Me.on("clear", n), () => Me.off("clear", n);
|
|
1416
1428
|
}
|
|
1417
|
-
function
|
|
1429
|
+
function Qt() {
|
|
1418
1430
|
return ue.slice();
|
|
1419
1431
|
}
|
|
1420
1432
|
function Bs() {
|
|
1421
1433
|
ue.length = 0, Me.emit("clear");
|
|
1422
1434
|
}
|
|
1423
|
-
function
|
|
1435
|
+
function Lt(n) {
|
|
1424
1436
|
const e = Number(n);
|
|
1425
1437
|
!Number.isFinite(e) || e <= 0 || (X.maxEntries = Math.floor(e), ue.length > X.maxEntries && ue.splice(0, ue.length - X.maxEntries));
|
|
1426
1438
|
}
|
|
1427
|
-
function
|
|
1439
|
+
function Gs() {
|
|
1428
1440
|
X.started || (X.started = !0, ie.on(C.CREATED, (n) => {
|
|
1429
|
-
|
|
1441
|
+
Se({
|
|
1430
1442
|
type: "operation",
|
|
1431
1443
|
subtype: C.CREATED,
|
|
1432
1444
|
operationId: n.operationId,
|
|
@@ -1438,7 +1450,7 @@ function Hs() {
|
|
|
1438
1450
|
instanceCount: n.instances?.length ?? 0
|
|
1439
1451
|
});
|
|
1440
1452
|
}), ie.on(C.MUTATED, (n) => {
|
|
1441
|
-
|
|
1453
|
+
Se({
|
|
1442
1454
|
type: "operation",
|
|
1443
1455
|
subtype: C.MUTATED,
|
|
1444
1456
|
operationId: n.operationId,
|
|
@@ -1450,7 +1462,7 @@ function Hs() {
|
|
|
1450
1462
|
instanceCount: n.instances?.length ?? 0
|
|
1451
1463
|
});
|
|
1452
1464
|
}), ie.on(C.CONFIRMED, (n) => {
|
|
1453
|
-
|
|
1465
|
+
Se({
|
|
1454
1466
|
type: "operation",
|
|
1455
1467
|
subtype: C.CONFIRMED,
|
|
1456
1468
|
operationId: n.operationId,
|
|
@@ -1462,7 +1474,7 @@ function Hs() {
|
|
|
1462
1474
|
instanceCount: n.instances?.length ?? 0
|
|
1463
1475
|
});
|
|
1464
1476
|
}), ie.on(C.REJECTED, (n) => {
|
|
1465
|
-
|
|
1477
|
+
Se({
|
|
1466
1478
|
type: "operation",
|
|
1467
1479
|
subtype: C.REJECTED,
|
|
1468
1480
|
operationId: n.operationId,
|
|
@@ -1474,14 +1486,14 @@ function Hs() {
|
|
|
1474
1486
|
instanceCount: n.instances?.length ?? 0
|
|
1475
1487
|
});
|
|
1476
1488
|
}), ie.on(C.CLEAR, () => {
|
|
1477
|
-
|
|
1489
|
+
Se({ type: "operation", subtype: C.CLEAR });
|
|
1478
1490
|
}));
|
|
1479
1491
|
}
|
|
1480
|
-
const
|
|
1481
|
-
function
|
|
1482
|
-
return
|
|
1492
|
+
const ct = /* @__PURE__ */ new Map();
|
|
1493
|
+
function Hs(n = "default") {
|
|
1494
|
+
return ct.has(n) || ct.set(n, new ps({ concurrency: 1 })), ct.get(n);
|
|
1483
1495
|
}
|
|
1484
|
-
function
|
|
1496
|
+
function qs(n, e = 3e4) {
|
|
1485
1497
|
return Promise.race([
|
|
1486
1498
|
n,
|
|
1487
1499
|
new Promise(
|
|
@@ -1493,19 +1505,19 @@ function we(n, e, t, s = null) {
|
|
|
1493
1505
|
if (!e) return;
|
|
1494
1506
|
const r = t.configKey;
|
|
1495
1507
|
let o = null;
|
|
1496
|
-
s && (o =
|
|
1508
|
+
s && (o = x.getStore(s));
|
|
1497
1509
|
try {
|
|
1498
1510
|
for (const [i, l] of Object.entries(e)) {
|
|
1499
|
-
const a =
|
|
1511
|
+
const a = De.getModelClass(i, r);
|
|
1500
1512
|
if (!a)
|
|
1501
1513
|
throw console.error(
|
|
1502
1514
|
`Model class not found for ${i} in config ${r}`
|
|
1503
1515
|
), new Error(`Model class not found for ${i}`);
|
|
1504
1516
|
if (o) {
|
|
1505
1517
|
o.includedPks.has(i) || o.includedPks.set(i, /* @__PURE__ */ new Set());
|
|
1506
|
-
const
|
|
1518
|
+
const h = o.includedPks.get(i);
|
|
1507
1519
|
for (const p of Object.keys(l))
|
|
1508
|
-
|
|
1520
|
+
h.add(Number(p));
|
|
1509
1521
|
}
|
|
1510
1522
|
const c = Object.values(l);
|
|
1511
1523
|
n.setEntities(a, c);
|
|
@@ -1517,8 +1529,8 @@ function we(n, e, t, s = null) {
|
|
|
1517
1529
|
), new Error(`Failed to process included entities: ${i.message}`);
|
|
1518
1530
|
}
|
|
1519
1531
|
}
|
|
1520
|
-
async function
|
|
1521
|
-
const { namespace: l = "default", timeout: a } = i, c = n.ModelClass, p =
|
|
1532
|
+
async function V(n, e, t = {}, s, r = null, o = null, i = {}) {
|
|
1533
|
+
const { namespace: l = "default", timeout: a } = i, c = n.ModelClass, p = De.getConfig().backendConfigs[c.configKey];
|
|
1522
1534
|
if (!p)
|
|
1523
1535
|
throw new Error(
|
|
1524
1536
|
`No backend configuration found for key: ${c.configKey}`
|
|
@@ -1539,7 +1551,7 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
|
|
|
1539
1551
|
}
|
|
1540
1552
|
}, v = w?.ast?.serializerOptions?.limit, O = w?.ast?.serializerOptions?.overfetch || 10;
|
|
1541
1553
|
v && O && (w.ast.serializerOptions.limit = v + O);
|
|
1542
|
-
const
|
|
1554
|
+
const k = [
|
|
1543
1555
|
"create",
|
|
1544
1556
|
"bulk_create",
|
|
1545
1557
|
"update",
|
|
@@ -1548,11 +1560,11 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
|
|
|
1548
1560
|
"delete_instance",
|
|
1549
1561
|
"get_or_create",
|
|
1550
1562
|
"update_or_create"
|
|
1551
|
-
].includes(e),
|
|
1563
|
+
].includes(e), Q = `${p.API_URL.replace(/\/+$/, "")}/${c.modelName}/`, N = p.getAuthHeaders ? p.getAuthHeaders() : {}, F = n.semanticKey;
|
|
1552
1564
|
s && (N["X-Operation-ID"] = s), o && (N["X-Canonical-ID"] = o);
|
|
1553
1565
|
const re = async () => {
|
|
1554
1566
|
try {
|
|
1555
|
-
|
|
1567
|
+
G({
|
|
1556
1568
|
type: "request",
|
|
1557
1569
|
modelName: c.modelName,
|
|
1558
1570
|
configKey: c.configKey,
|
|
@@ -1560,25 +1572,25 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
|
|
|
1560
1572
|
operationType: e,
|
|
1561
1573
|
operationId: s,
|
|
1562
1574
|
canonicalId: o,
|
|
1563
|
-
url:
|
|
1575
|
+
url: Q,
|
|
1564
1576
|
payload: w,
|
|
1565
1577
|
namespace: l
|
|
1566
1578
|
});
|
|
1567
|
-
let
|
|
1568
|
-
typeof r == "function" &&
|
|
1569
|
-
const
|
|
1570
|
-
let
|
|
1579
|
+
let z = await ms.post(Q, Je(w), { headers: N });
|
|
1580
|
+
typeof r == "function" && z?.data && await r(z.data);
|
|
1581
|
+
const D = z?.data?.data, K = z?.data?.included, me = Array.isArray(D) ? D.length : D != null ? 1 : 0, Ze = K ? Object.keys(K).length : 0, ye = 100, Re = Array.isArray(D) && D.length > ye ? D.slice(0, ye) : D, Ye = Array.isArray(D) && D.length > ye;
|
|
1582
|
+
let Ke = K, ve = !1;
|
|
1571
1583
|
if (K && typeof K == "object") {
|
|
1572
|
-
const
|
|
1584
|
+
const Ie = {};
|
|
1573
1585
|
let ne = 0;
|
|
1574
|
-
for (const [
|
|
1575
|
-
if (Ne
|
|
1576
|
-
|
|
1586
|
+
for (const [Ne, xe] of Object.entries(K))
|
|
1587
|
+
if (Ie[Ne] = xe, ne += 1, ne >= ye) {
|
|
1588
|
+
ve = !0;
|
|
1577
1589
|
break;
|
|
1578
1590
|
}
|
|
1579
|
-
|
|
1591
|
+
Ke = ve ? Ie : K;
|
|
1580
1592
|
}
|
|
1581
|
-
return
|
|
1593
|
+
return G({
|
|
1582
1594
|
type: "response",
|
|
1583
1595
|
modelName: c.modelName,
|
|
1584
1596
|
configKey: c.configKey,
|
|
@@ -1586,17 +1598,17 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
|
|
|
1586
1598
|
operationType: e,
|
|
1587
1599
|
operationId: s,
|
|
1588
1600
|
canonicalId: o,
|
|
1589
|
-
url:
|
|
1590
|
-
status:
|
|
1601
|
+
url: Q,
|
|
1602
|
+
status: z.status,
|
|
1591
1603
|
dataCount: me,
|
|
1592
|
-
includedCount:
|
|
1593
|
-
data:
|
|
1594
|
-
included:
|
|
1595
|
-
dataTruncated:
|
|
1596
|
-
includedTruncated:
|
|
1597
|
-
}),
|
|
1598
|
-
} catch (
|
|
1599
|
-
if (
|
|
1604
|
+
includedCount: Ze,
|
|
1605
|
+
data: Re,
|
|
1606
|
+
included: Ke,
|
|
1607
|
+
dataTruncated: Ye,
|
|
1608
|
+
includedTruncated: ve
|
|
1609
|
+
}), z.data;
|
|
1610
|
+
} catch (z) {
|
|
1611
|
+
if (G({
|
|
1600
1612
|
type: "error",
|
|
1601
1613
|
modelName: c.modelName,
|
|
1602
1614
|
configKey: c.configKey,
|
|
@@ -1604,23 +1616,23 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
|
|
|
1604
1616
|
operationType: e,
|
|
1605
1617
|
operationId: s,
|
|
1606
1618
|
canonicalId: o,
|
|
1607
|
-
url:
|
|
1608
|
-
status:
|
|
1609
|
-
message:
|
|
1610
|
-
}),
|
|
1611
|
-
const
|
|
1612
|
-
throw new Error(`${
|
|
1619
|
+
url: Q,
|
|
1620
|
+
status: z?.response?.status,
|
|
1621
|
+
message: z?.message
|
|
1622
|
+
}), z?.code === "ECONNREFUSED") {
|
|
1623
|
+
const D = "Connection refused. If you're running tests, start the test server with `python manage.py statezero_testserver`.";
|
|
1624
|
+
throw new Error(`${D} (${Q})`);
|
|
1613
1625
|
}
|
|
1614
|
-
if (
|
|
1615
|
-
const
|
|
1616
|
-
throw Error.captureStackTrace && Error.captureStackTrace(
|
|
1626
|
+
if (z.response && z.response.data) {
|
|
1627
|
+
const D = Fs(z.response.data);
|
|
1628
|
+
throw Error.captureStackTrace && Error.captureStackTrace(D, V), D;
|
|
1617
1629
|
}
|
|
1618
|
-
throw new Error(`API call failed: ${
|
|
1630
|
+
throw new Error(`API call failed: ${z.message}`);
|
|
1619
1631
|
}
|
|
1620
|
-
}, pe =
|
|
1621
|
-
return a ?
|
|
1632
|
+
}, pe = Hs(l), ae = k ? pe.add(re) : re();
|
|
1633
|
+
return a ? qs(ae, a) : ae;
|
|
1622
1634
|
}
|
|
1623
|
-
class
|
|
1635
|
+
class Vt {
|
|
1624
1636
|
// Supported Django strftime formats and their date-fns equivalents
|
|
1625
1637
|
static SUPPORTED_FORMATS = {
|
|
1626
1638
|
"iso-8601": null,
|
|
@@ -1674,7 +1686,7 @@ class Bt {
|
|
|
1674
1686
|
return c.isValid ? c.toJSDate() : (console.error(`Failed to parse ISO date "${e}":`, c.invalidReason), null);
|
|
1675
1687
|
}
|
|
1676
1688
|
const a = this.SUPPORTED_FORMATS[l];
|
|
1677
|
-
return
|
|
1689
|
+
return gs(e, a, /* @__PURE__ */ new Date());
|
|
1678
1690
|
} catch (a) {
|
|
1679
1691
|
return console.error(`Failed to parse date "${e}" with format "${l}"`, a), null;
|
|
1680
1692
|
}
|
|
@@ -1706,24 +1718,24 @@ class Bt {
|
|
|
1706
1718
|
if (!i || i === "iso-8601")
|
|
1707
1719
|
return r === "date" ? e.toISOString().slice(0, 10) : e.toISOString();
|
|
1708
1720
|
const l = this.SUPPORTED_FORMATS[i];
|
|
1709
|
-
return
|
|
1721
|
+
return _s(e, l);
|
|
1710
1722
|
} catch (l) {
|
|
1711
1723
|
return console.error(`Failed to format date with format "${i}"`, l), e.toISOString();
|
|
1712
1724
|
}
|
|
1713
1725
|
}
|
|
1714
1726
|
}
|
|
1715
|
-
function
|
|
1727
|
+
function Js(n) {
|
|
1716
1728
|
if (!n || !n.configKey)
|
|
1717
1729
|
return "UTC";
|
|
1718
|
-
const e =
|
|
1730
|
+
const e = De.getConfig();
|
|
1719
1731
|
return (e.backendConfigs[n.configKey] || e.backendConfigs.default).BACKEND_TZ || "UTC";
|
|
1720
1732
|
}
|
|
1721
|
-
const
|
|
1733
|
+
const Bt = {
|
|
1722
1734
|
// Store backend snake_case format internally for consistency with API
|
|
1723
1735
|
toInternal: (n, e = {}) => {
|
|
1724
1736
|
if (typeof n == "string")
|
|
1725
1737
|
throw new Error("File field expects a file object, not a string path");
|
|
1726
|
-
if (
|
|
1738
|
+
if (b(n))
|
|
1727
1739
|
return null;
|
|
1728
1740
|
if (typeof n != "object" || Array.isArray(n))
|
|
1729
1741
|
throw new Error(`expected file object, got ${Array.isArray(n) ? "array" : typeof n}`);
|
|
@@ -1738,7 +1750,7 @@ const Ht = {
|
|
|
1738
1750
|
// Return object with both formats for maximum compatibility
|
|
1739
1751
|
toLive: (n, e = {}) => {
|
|
1740
1752
|
if (!n || typeof n != "object") return n;
|
|
1741
|
-
const t = e.model?.constructor?.configKey || "default", s = n.file_url ?
|
|
1753
|
+
const t = e.model?.constructor?.configKey || "default", s = n.file_url ? De.buildFileUrl(n.file_url, t) : null;
|
|
1742
1754
|
return {
|
|
1743
1755
|
// snake_case (backend format)
|
|
1744
1756
|
file_path: n.file_path,
|
|
@@ -1755,23 +1767,23 @@ const Ht = {
|
|
|
1755
1767
|
mimeType: n.mime_type
|
|
1756
1768
|
};
|
|
1757
1769
|
}
|
|
1758
|
-
},
|
|
1770
|
+
}, Gt = {
|
|
1759
1771
|
toInternal: (n, e = {}) => {
|
|
1760
|
-
if (
|
|
1772
|
+
if (b(n) || typeof n == "string") return n;
|
|
1761
1773
|
if (n instanceof Date) {
|
|
1762
1774
|
const { model: t, field: s, fieldSchema: r } = e, o = t?.schema || r?.format && {
|
|
1763
1775
|
properties: { [s]: { format: r.format } }
|
|
1764
1776
|
};
|
|
1765
|
-
return o ?
|
|
1777
|
+
return o ? Vt.serializeDate(n, s, o) : n.toISOString();
|
|
1766
1778
|
}
|
|
1767
1779
|
throw new Error(`expected string or Date, got ${typeof n}`);
|
|
1768
1780
|
},
|
|
1769
1781
|
toLive: (n, e = {}) => {
|
|
1770
|
-
if (
|
|
1782
|
+
if (b(n) || typeof n != "string") return n;
|
|
1771
1783
|
const { model: t, field: s } = e;
|
|
1772
1784
|
if (t?.schema) {
|
|
1773
|
-
const r =
|
|
1774
|
-
return
|
|
1785
|
+
const r = Js(t);
|
|
1786
|
+
return Vt.parseDate(n, s, t.schema, r);
|
|
1775
1787
|
}
|
|
1776
1788
|
try {
|
|
1777
1789
|
return new Date(n);
|
|
@@ -1779,9 +1791,9 @@ const Ht = {
|
|
|
1779
1791
|
return console.warn(`Failed to parse date: ${n}`), n;
|
|
1780
1792
|
}
|
|
1781
1793
|
}
|
|
1782
|
-
},
|
|
1794
|
+
}, be = {
|
|
1783
1795
|
toInternal: (n, e = {}) => {
|
|
1784
|
-
if (
|
|
1796
|
+
if (b(n)) return n;
|
|
1785
1797
|
const t = n.pk || n;
|
|
1786
1798
|
if (typeof t != "string" && typeof t != "number")
|
|
1787
1799
|
throw new Error(
|
|
@@ -1790,13 +1802,13 @@ const Ht = {
|
|
|
1790
1802
|
return t;
|
|
1791
1803
|
},
|
|
1792
1804
|
toLive: (n, e = {}) => {
|
|
1793
|
-
if (
|
|
1805
|
+
if (b(n)) return n;
|
|
1794
1806
|
const { model: t, field: s } = e;
|
|
1795
1807
|
return t.relationshipFields.has(s) && n ? t.relationshipFields.get(s).ModelClass().fromPk(n) : n;
|
|
1796
1808
|
}
|
|
1797
|
-
},
|
|
1809
|
+
}, Ws = {
|
|
1798
1810
|
toInternal: (n, e = {}) => {
|
|
1799
|
-
if (
|
|
1811
|
+
if (b(n)) return n;
|
|
1800
1812
|
if (!Array.isArray(n)) throw new Error(`expected array, got ${typeof n}`);
|
|
1801
1813
|
return n.map((t) => {
|
|
1802
1814
|
const s = t.pk || t;
|
|
@@ -1808,7 +1820,7 @@ const Ht = {
|
|
|
1808
1820
|
});
|
|
1809
1821
|
},
|
|
1810
1822
|
toLive: (n, e = {}) => {
|
|
1811
|
-
if (
|
|
1823
|
+
if (b(n)) return n;
|
|
1812
1824
|
const { model: t, field: s } = e;
|
|
1813
1825
|
if (t.relationshipFields.has(s) && n) {
|
|
1814
1826
|
const r = t.relationshipFields.get(s);
|
|
@@ -1820,35 +1832,35 @@ const Ht = {
|
|
|
1820
1832
|
}
|
|
1821
1833
|
return n;
|
|
1822
1834
|
}
|
|
1823
|
-
},
|
|
1835
|
+
}, Ee = {
|
|
1824
1836
|
string: {
|
|
1825
|
-
"file-path":
|
|
1826
|
-
"image-path":
|
|
1827
|
-
date:
|
|
1828
|
-
"date-time":
|
|
1829
|
-
"foreign-key":
|
|
1830
|
-
"one-to-one":
|
|
1837
|
+
"file-path": Bt,
|
|
1838
|
+
"image-path": Bt,
|
|
1839
|
+
date: Gt,
|
|
1840
|
+
"date-time": Gt,
|
|
1841
|
+
"foreign-key": be,
|
|
1842
|
+
"one-to-one": be
|
|
1831
1843
|
},
|
|
1832
1844
|
integer: {
|
|
1833
|
-
"foreign-key":
|
|
1834
|
-
"one-to-one":
|
|
1845
|
+
"foreign-key": be,
|
|
1846
|
+
"one-to-one": be
|
|
1835
1847
|
},
|
|
1836
1848
|
// Add other PK types as needed
|
|
1837
1849
|
uuid: {
|
|
1838
|
-
"foreign-key":
|
|
1839
|
-
"one-to-one":
|
|
1850
|
+
"foreign-key": be,
|
|
1851
|
+
"one-to-one": be
|
|
1840
1852
|
},
|
|
1841
1853
|
array: {
|
|
1842
|
-
"many-to-many":
|
|
1854
|
+
"many-to-many": Ws
|
|
1843
1855
|
}
|
|
1844
1856
|
};
|
|
1845
|
-
class
|
|
1857
|
+
class ts {
|
|
1846
1858
|
constructor(e) {
|
|
1847
1859
|
this.modelClass = e;
|
|
1848
1860
|
}
|
|
1849
1861
|
toInternalField(e, t, s = {}) {
|
|
1850
1862
|
const r = this.modelClass.schema?.properties[e]?.type, o = this.modelClass.schema?.properties[e]?.format;
|
|
1851
|
-
return
|
|
1863
|
+
return Ee[r] && Ee[r][o] ? Ee[r][o].toInternal(t, {
|
|
1852
1864
|
model: this.modelClass,
|
|
1853
1865
|
field: e,
|
|
1854
1866
|
...s
|
|
@@ -1862,8 +1874,8 @@ class rs {
|
|
|
1862
1874
|
}
|
|
1863
1875
|
toLiveField(e, t, s = {}) {
|
|
1864
1876
|
const r = this.modelClass.schema?.properties[e]?.type, o = this.modelClass.schema?.properties[e]?.format;
|
|
1865
|
-
if (
|
|
1866
|
-
return
|
|
1877
|
+
if (Ee[r] && Ee[r][o])
|
|
1878
|
+
return Ee[r][o].toLive(t, {
|
|
1867
1879
|
model: this.modelClass,
|
|
1868
1880
|
field: e,
|
|
1869
1881
|
...s
|
|
@@ -1897,18 +1909,18 @@ class rs {
|
|
|
1897
1909
|
return t;
|
|
1898
1910
|
}
|
|
1899
1911
|
}
|
|
1900
|
-
function
|
|
1912
|
+
function Zs(n) {
|
|
1901
1913
|
if (!n || !n.configKey)
|
|
1902
1914
|
return "UTC";
|
|
1903
|
-
const e =
|
|
1915
|
+
const e = De.getConfig();
|
|
1904
1916
|
return (e.backendConfigs[n.configKey] || e.backendConfigs.default).BACKEND_TZ || "UTC";
|
|
1905
1917
|
}
|
|
1906
|
-
function
|
|
1918
|
+
function Ys(n, e, t) {
|
|
1907
1919
|
if (!t?.schema || !n) return e;
|
|
1908
|
-
const s = new
|
|
1920
|
+
const s = new ts(t);
|
|
1909
1921
|
return Array.isArray(e) ? e.map((r) => s.toLiveField(n, r)) : s.toLiveField(n, e);
|
|
1910
1922
|
}
|
|
1911
|
-
function
|
|
1923
|
+
function ze(n, e, t, s = {}) {
|
|
1912
1924
|
const r = n.split("__"), o = [
|
|
1913
1925
|
"exact",
|
|
1914
1926
|
"iexact",
|
|
@@ -1936,74 +1948,74 @@ function De(n, e, t, s = {}) {
|
|
|
1936
1948
|
], i = ["year", "month", "day", "week_day", "hour", "minute", "second", "date", "time"], l = ["gt", "gte", "lt", "lte", "exact"];
|
|
1937
1949
|
let a = [], c = [...r];
|
|
1938
1950
|
if (r.length >= 3) {
|
|
1939
|
-
const
|
|
1940
|
-
i.includes(
|
|
1951
|
+
const k = r[r.length - 2], E = r[r.length - 1];
|
|
1952
|
+
i.includes(k) && l.includes(E) && (a = [k, E], c = r.slice(0, -2));
|
|
1941
1953
|
}
|
|
1942
|
-
let
|
|
1943
|
-
a.length === 0 && r.length > 1 && o.includes(r[r.length - 1]) && (
|
|
1954
|
+
let h = null;
|
|
1955
|
+
a.length === 0 && r.length > 1 && o.includes(r[r.length - 1]) && (h = r[r.length - 1], c = r.slice(0, -1));
|
|
1944
1956
|
let p = t, m = [], y = !1, _ = !1, w = null;
|
|
1945
|
-
for (let
|
|
1946
|
-
let
|
|
1947
|
-
|
|
1948
|
-
const
|
|
1949
|
-
if (p && p.relationshipFields && p.relationshipFields instanceof Map && p.relationshipFields.has(
|
|
1950
|
-
const N = p.relationshipFields.get(
|
|
1951
|
-
if (!
|
|
1952
|
-
let ae = c.slice(
|
|
1953
|
-
a.length > 0 ? ae += "__" + a.join("__") :
|
|
1954
|
-
const
|
|
1957
|
+
for (let k = 0; k < c.length; k++) {
|
|
1958
|
+
let E = c[k];
|
|
1959
|
+
E === "pk" && p && (E = p.primaryKeyField);
|
|
1960
|
+
const Q = k === c.length - 1;
|
|
1961
|
+
if (p && p.relationshipFields && p.relationshipFields instanceof Map && p.relationshipFields.has(E)) {
|
|
1962
|
+
const N = p.relationshipFields.get(E), F = N.ModelClass(), re = N.relationshipType;
|
|
1963
|
+
if (!Q && re === "many-to-many") {
|
|
1964
|
+
let ae = c.slice(k + 1).join("__");
|
|
1965
|
+
a.length > 0 ? ae += "__" + a.join("__") : h && (ae += "__" + h);
|
|
1966
|
+
const z = ze(ae, e, F, s), D = m.length > 0 ? m.join(".") + "." + E : E, K = z.requiredPath || z.field, me = `${D}.${K}`;
|
|
1955
1967
|
return {
|
|
1956
|
-
field:
|
|
1957
|
-
operator: { $elemMatch: { [
|
|
1968
|
+
field: D,
|
|
1969
|
+
operator: { $elemMatch: { [z.field]: z.operator } },
|
|
1958
1970
|
isM2M: !0,
|
|
1959
1971
|
requiredPath: me
|
|
1960
1972
|
// Full path for data picking
|
|
1961
1973
|
};
|
|
1962
1974
|
}
|
|
1963
|
-
if (m.push(
|
|
1975
|
+
if (m.push(E), !Q)
|
|
1964
1976
|
p = F;
|
|
1965
1977
|
else {
|
|
1966
1978
|
if (y = !0, re === "many-to-many")
|
|
1967
|
-
_ = !0, w =
|
|
1979
|
+
_ = !0, w = E;
|
|
1968
1980
|
else {
|
|
1969
1981
|
const pe = F.primaryKeyField || "id";
|
|
1970
1982
|
m.push(pe), w = pe;
|
|
1971
1983
|
}
|
|
1972
1984
|
p = F;
|
|
1973
1985
|
}
|
|
1974
|
-
} else if (p && p.fields && p.fields.includes(
|
|
1975
|
-
if (m.push(
|
|
1986
|
+
} else if (p && p.fields && p.fields.includes(E)) {
|
|
1987
|
+
if (m.push(E), w = E, Q)
|
|
1976
1988
|
break;
|
|
1977
|
-
const N = p.schema?.properties?.[
|
|
1989
|
+
const N = p.schema?.properties?.[E];
|
|
1978
1990
|
if (N && N.format === "json") {
|
|
1979
|
-
const F = c.slice(
|
|
1991
|
+
const F = c.slice(k + 1);
|
|
1980
1992
|
m.push(...F);
|
|
1981
1993
|
break;
|
|
1982
1994
|
}
|
|
1983
|
-
throw new Error(`Field '${
|
|
1995
|
+
throw new Error(`Field '${E}' in '${n}' is not a relationship field and cannot be traversed.`);
|
|
1984
1996
|
} else
|
|
1985
|
-
throw new Error(`Field '${
|
|
1997
|
+
throw new Error(`Field '${E}' in '${n}' not found in model ${p.modelName}.`);
|
|
1986
1998
|
}
|
|
1987
|
-
const v = m.join("."), T = i.includes(
|
|
1999
|
+
const v = m.join("."), T = i.includes(h) || a.length === 2 && i.includes(a[0]) ? e : Ys(w, e, p);
|
|
1988
2000
|
if (a.length === 2) {
|
|
1989
|
-
const [
|
|
1990
|
-
return
|
|
2001
|
+
const [k, E] = a;
|
|
2002
|
+
return Xs(v, k, E, T, y);
|
|
1991
2003
|
}
|
|
1992
|
-
if (
|
|
1993
|
-
return
|
|
2004
|
+
if (h)
|
|
2005
|
+
return er(v, h, T, y, p, w, _);
|
|
1994
2006
|
if (y) {
|
|
1995
|
-
let
|
|
1996
|
-
return T && typeof T == "object" && "pk" in T && (
|
|
2007
|
+
let k = T;
|
|
2008
|
+
return T && typeof T == "object" && "pk" in T && (k = T.pk), _ ? { field: v, operator: { $elemMatch: { pk: { $eq: k } } }, isM2M: !0 } : { field: v, operator: { $eq: k } };
|
|
1997
2009
|
}
|
|
1998
2010
|
return { field: v, operator: { $eq: T } };
|
|
1999
2011
|
}
|
|
2000
|
-
function
|
|
2012
|
+
function Xs(n, e, t, s, r) {
|
|
2001
2013
|
return r ? (console.warn(`Date part comparison on relationship fields may not work as expected: ${n}`), { field: n, operator: { $eq: s } }) : {
|
|
2002
2014
|
field: n,
|
|
2003
2015
|
operator: { [`$${e}_${t}`]: s }
|
|
2004
2016
|
};
|
|
2005
2017
|
}
|
|
2006
|
-
function
|
|
2018
|
+
function er(n, e, t, s, r, o, i = !1) {
|
|
2007
2019
|
function l(a) {
|
|
2008
2020
|
return a.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2009
2021
|
}
|
|
@@ -2016,8 +2028,8 @@ function tr(n, e, t, s, r, o, i = !1) {
|
|
|
2016
2028
|
// document-level operator
|
|
2017
2029
|
requiredPath: n,
|
|
2018
2030
|
// need the M2M field itself for data picking
|
|
2019
|
-
operator: function(
|
|
2020
|
-
const p =
|
|
2031
|
+
operator: function(h) {
|
|
2032
|
+
const p = h[a], m = p === null || Array.isArray(p) && p.length === 0;
|
|
2021
2033
|
return c ? m : !m;
|
|
2022
2034
|
}
|
|
2023
2035
|
};
|
|
@@ -2058,16 +2070,16 @@ function tr(n, e, t, s, r, o, i = !1) {
|
|
|
2058
2070
|
operator: { $regex: new RegExp(`${l(t)}$`, "i") }
|
|
2059
2071
|
} : e === "in" ? { field: n, operator: { $in: t } } : e === "gt" ? { field: n, operator: { $nin: [null, void 0], $gt: t } } : e === "gte" ? { field: n, operator: { $nin: [null, void 0], $gte: t } } : e === "lt" ? { field: n, operator: { $nin: [null, void 0], $lt: t } } : e === "lte" ? { field: n, operator: { $nin: [null, void 0], $lte: t } } : { field: n, operator: { $eq: t } };
|
|
2060
2072
|
}
|
|
2061
|
-
function
|
|
2062
|
-
const t = e ? new
|
|
2063
|
-
const p = s(a,
|
|
2073
|
+
function tr(n = "UTC", e = null) {
|
|
2074
|
+
const t = e ? new ts(e) : null, s = (a, c = null) => a ? a instanceof Date ? a : t && c && typeof a == "string" ? t.toLiveField(c, a) : (console.warn("Date conversion without serializer context:", a), null) : null, r = (a, c, h = null) => {
|
|
2075
|
+
const p = s(a, h);
|
|
2064
2076
|
if (!p || !(p instanceof Date) || isNaN(p.getTime()))
|
|
2065
2077
|
return null;
|
|
2066
2078
|
const m = _e.fromJSDate(p).setZone(n);
|
|
2067
2079
|
return c(m);
|
|
2068
2080
|
}, o = {
|
|
2069
2081
|
// Year - same in both
|
|
2070
|
-
$year(a, c,
|
|
2082
|
+
$year(a, c, h) {
|
|
2071
2083
|
const p = typeof a == "string" ? Number(a) : a;
|
|
2072
2084
|
return ee(
|
|
2073
2085
|
(m) => {
|
|
@@ -2075,11 +2087,11 @@ function sr(n = "UTC", e = null) {
|
|
|
2075
2087
|
return y !== null && y === p;
|
|
2076
2088
|
},
|
|
2077
2089
|
c,
|
|
2078
|
-
|
|
2090
|
+
h
|
|
2079
2091
|
);
|
|
2080
2092
|
},
|
|
2081
2093
|
// Month - Luxon is 1-indexed like Django
|
|
2082
|
-
$month(a, c,
|
|
2094
|
+
$month(a, c, h) {
|
|
2083
2095
|
const p = typeof a == "string" ? Number(a) : a;
|
|
2084
2096
|
return ee(
|
|
2085
2097
|
(m) => {
|
|
@@ -2087,11 +2099,11 @@ function sr(n = "UTC", e = null) {
|
|
|
2087
2099
|
return y !== null && y === p;
|
|
2088
2100
|
},
|
|
2089
2101
|
c,
|
|
2090
|
-
|
|
2102
|
+
h
|
|
2091
2103
|
);
|
|
2092
2104
|
},
|
|
2093
2105
|
// Day of month - same in both
|
|
2094
|
-
$day(a, c,
|
|
2106
|
+
$day(a, c, h) {
|
|
2095
2107
|
const p = typeof a == "string" ? Number(a) : a;
|
|
2096
2108
|
return ee(
|
|
2097
2109
|
(m) => {
|
|
@@ -2099,11 +2111,11 @@ function sr(n = "UTC", e = null) {
|
|
|
2099
2111
|
return y !== null && y === p;
|
|
2100
2112
|
},
|
|
2101
2113
|
c,
|
|
2102
|
-
|
|
2114
|
+
h
|
|
2103
2115
|
);
|
|
2104
2116
|
},
|
|
2105
2117
|
// Day of week - convert to Django's 1=Sunday format
|
|
2106
|
-
$week_day(a, c,
|
|
2118
|
+
$week_day(a, c, h) {
|
|
2107
2119
|
const p = typeof a == "string" ? Number(a) : a;
|
|
2108
2120
|
return ee(
|
|
2109
2121
|
(m) => {
|
|
@@ -2111,11 +2123,11 @@ function sr(n = "UTC", e = null) {
|
|
|
2111
2123
|
return y !== null && y === p;
|
|
2112
2124
|
},
|
|
2113
2125
|
c,
|
|
2114
|
-
|
|
2126
|
+
h
|
|
2115
2127
|
);
|
|
2116
2128
|
},
|
|
2117
2129
|
// Hour - same in both
|
|
2118
|
-
$hour(a, c,
|
|
2130
|
+
$hour(a, c, h) {
|
|
2119
2131
|
const p = typeof a == "string" ? Number(a) : a;
|
|
2120
2132
|
return ee(
|
|
2121
2133
|
(m) => {
|
|
@@ -2123,11 +2135,11 @@ function sr(n = "UTC", e = null) {
|
|
|
2123
2135
|
return y !== null && y === p;
|
|
2124
2136
|
},
|
|
2125
2137
|
c,
|
|
2126
|
-
|
|
2138
|
+
h
|
|
2127
2139
|
);
|
|
2128
2140
|
},
|
|
2129
2141
|
// Minute - same in both
|
|
2130
|
-
$minute(a, c,
|
|
2142
|
+
$minute(a, c, h) {
|
|
2131
2143
|
const p = typeof a == "string" ? Number(a) : a;
|
|
2132
2144
|
return ee(
|
|
2133
2145
|
(m) => {
|
|
@@ -2135,11 +2147,11 @@ function sr(n = "UTC", e = null) {
|
|
|
2135
2147
|
return y !== null && y === p;
|
|
2136
2148
|
},
|
|
2137
2149
|
c,
|
|
2138
|
-
|
|
2150
|
+
h
|
|
2139
2151
|
);
|
|
2140
2152
|
},
|
|
2141
2153
|
// Second - same in both
|
|
2142
|
-
$second(a, c,
|
|
2154
|
+
$second(a, c, h) {
|
|
2143
2155
|
const p = typeof a == "string" ? Number(a) : a;
|
|
2144
2156
|
return ee(
|
|
2145
2157
|
(m) => {
|
|
@@ -2147,11 +2159,11 @@ function sr(n = "UTC", e = null) {
|
|
|
2147
2159
|
return y !== null && y === p;
|
|
2148
2160
|
},
|
|
2149
2161
|
c,
|
|
2150
|
-
|
|
2162
|
+
h
|
|
2151
2163
|
);
|
|
2152
2164
|
},
|
|
2153
2165
|
// Date - extract date portion (ignore time)
|
|
2154
|
-
$date(a, c,
|
|
2166
|
+
$date(a, c, h) {
|
|
2155
2167
|
return ee(
|
|
2156
2168
|
(p, m) => {
|
|
2157
2169
|
const y = s(p, m);
|
|
@@ -2163,11 +2175,11 @@ function sr(n = "UTC", e = null) {
|
|
|
2163
2175
|
return w.year === v.year && w.month === v.month && w.day === v.day;
|
|
2164
2176
|
},
|
|
2165
2177
|
c,
|
|
2166
|
-
|
|
2178
|
+
h
|
|
2167
2179
|
);
|
|
2168
2180
|
},
|
|
2169
2181
|
// Time - extract time portion (ignore date)
|
|
2170
|
-
$time(a, c,
|
|
2182
|
+
$time(a, c, h) {
|
|
2171
2183
|
return ee(
|
|
2172
2184
|
(p, m) => {
|
|
2173
2185
|
const y = s(p, m);
|
|
@@ -2181,13 +2193,13 @@ function sr(n = "UTC", e = null) {
|
|
|
2181
2193
|
} else {
|
|
2182
2194
|
const T = s(a, m);
|
|
2183
2195
|
if (!T) return !1;
|
|
2184
|
-
const
|
|
2185
|
-
w =
|
|
2196
|
+
const k = _e.fromJSDate(T).setZone(n);
|
|
2197
|
+
w = k.hour, v = k.minute, O = k.second;
|
|
2186
2198
|
}
|
|
2187
2199
|
return _.hour === w && _.minute === v && _.second === O;
|
|
2188
2200
|
},
|
|
2189
2201
|
c,
|
|
2190
|
-
|
|
2202
|
+
h
|
|
2191
2203
|
);
|
|
2192
2204
|
}
|
|
2193
2205
|
}, i = {
|
|
@@ -2205,24 +2217,24 @@ function sr(n = "UTC", e = null) {
|
|
|
2205
2217
|
}, l = ["gt", "gte", "lt", "lte", "exact"];
|
|
2206
2218
|
return Object.keys(i).forEach((a) => {
|
|
2207
2219
|
const c = i[a];
|
|
2208
|
-
l.forEach((
|
|
2209
|
-
o[`$${a}_${
|
|
2220
|
+
l.forEach((h) => {
|
|
2221
|
+
o[`$${a}_${h}`] = (p, m, y) => ee(
|
|
2210
2222
|
(_, w) => {
|
|
2211
2223
|
const v = s(_, w);
|
|
2212
2224
|
if (!v || !(v instanceof Date) || isNaN(v.getTime()))
|
|
2213
2225
|
return !1;
|
|
2214
|
-
const O = _e.fromJSDate(v).setZone(n), T = c(O),
|
|
2215
|
-
switch (
|
|
2226
|
+
const O = _e.fromJSDate(v).setZone(n), T = c(O), k = a === "date" ? p : typeof p == "string" ? Number(p) : p;
|
|
2227
|
+
switch (h) {
|
|
2216
2228
|
case "gt":
|
|
2217
|
-
return T >
|
|
2229
|
+
return T > k;
|
|
2218
2230
|
case "gte":
|
|
2219
|
-
return T >=
|
|
2231
|
+
return T >= k;
|
|
2220
2232
|
case "lt":
|
|
2221
|
-
return T <
|
|
2233
|
+
return T < k;
|
|
2222
2234
|
case "lte":
|
|
2223
|
-
return T <=
|
|
2235
|
+
return T <= k;
|
|
2224
2236
|
case "exact":
|
|
2225
|
-
return T ===
|
|
2237
|
+
return T === k;
|
|
2226
2238
|
default:
|
|
2227
2239
|
return !1;
|
|
2228
2240
|
}
|
|
@@ -2233,20 +2245,20 @@ function sr(n = "UTC", e = null) {
|
|
|
2233
2245
|
});
|
|
2234
2246
|
}), o;
|
|
2235
2247
|
}
|
|
2236
|
-
function
|
|
2237
|
-
const t =
|
|
2238
|
-
return
|
|
2239
|
-
operations:
|
|
2248
|
+
function sr(n, e) {
|
|
2249
|
+
const t = Zs(e);
|
|
2250
|
+
return Wt(n, {
|
|
2251
|
+
operations: tr(t, e)
|
|
2240
2252
|
});
|
|
2241
2253
|
}
|
|
2242
|
-
function
|
|
2254
|
+
function pt(n, e) {
|
|
2243
2255
|
const t = {}, s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
2244
2256
|
for (const [o, i] of Object.entries(n))
|
|
2245
2257
|
try {
|
|
2246
|
-
const l =
|
|
2247
|
-
|
|
2258
|
+
const l = ze(o, i, e), { field: a, operator: c, isDatePart: h, isM2M: p } = l;
|
|
2259
|
+
h ? (s.has(a) || s.set(a, []), s.get(a).push({ [a]: c })) : p && c.$elemMatch ? (r.has(a) || r.set(a, []), r.get(a).push(c.$elemMatch)) : t[a] ? t[a] = { ...t[a], ...c } : t[a] = c;
|
|
2248
2260
|
} catch (l) {
|
|
2249
|
-
throw new
|
|
2261
|
+
throw new $e(`Failed to process field '${o}': ${l.message}`);
|
|
2250
2262
|
}
|
|
2251
2263
|
for (const [o, i] of r.entries())
|
|
2252
2264
|
i.length === 1 ? t[o] = { $elemMatch: i[0] } : t[o] = { $elemMatch: { $and: i } };
|
|
@@ -2267,38 +2279,38 @@ function mt(n, e) {
|
|
|
2267
2279
|
}
|
|
2268
2280
|
return t;
|
|
2269
2281
|
}
|
|
2270
|
-
function
|
|
2282
|
+
function rr(n, e) {
|
|
2271
2283
|
return !n || !n.length ? null : {
|
|
2272
|
-
$or: n.map((t) => "operator" in t && "conditions" in t ? { [t.operator === "AND" ? "$and" : "$or"]: t.conditions.map((r) =>
|
|
2284
|
+
$or: n.map((t) => "operator" in t && "conditions" in t ? { [t.operator === "AND" ? "$and" : "$or"]: t.conditions.map((r) => pt(r, e)) } : pt(t, e))
|
|
2273
2285
|
};
|
|
2274
2286
|
}
|
|
2275
|
-
function
|
|
2287
|
+
function Ge(n, e) {
|
|
2276
2288
|
if (!n) return null;
|
|
2277
2289
|
if (n.type === "filter") {
|
|
2278
2290
|
const { conditions: t, Q: s } = n;
|
|
2279
2291
|
let r = {};
|
|
2280
|
-
if (t && Object.keys(t).length > 0 && (r =
|
|
2281
|
-
const o =
|
|
2292
|
+
if (t && Object.keys(t).length > 0 && (r = pt(t, e)), s && s.length > 0) {
|
|
2293
|
+
const o = rr(s, e);
|
|
2282
2294
|
if (o)
|
|
2283
2295
|
return Object.keys(r).length > 0 ? { $and: [r, o] } : o;
|
|
2284
2296
|
}
|
|
2285
2297
|
return r;
|
|
2286
2298
|
}
|
|
2287
2299
|
if (n.type === "and" && n.children) {
|
|
2288
|
-
const t = n.children.map((s) =>
|
|
2300
|
+
const t = n.children.map((s) => Ge(s, e)).filter((s) => s != null);
|
|
2289
2301
|
return t.length === 0 ? null : t.length === 1 ? t[0] : { $and: t };
|
|
2290
2302
|
}
|
|
2291
2303
|
if (n.type === "or" && n.children) {
|
|
2292
|
-
const t = n.children.map((s) =>
|
|
2304
|
+
const t = n.children.map((s) => Ge(s, e)).filter((s) => s != null);
|
|
2293
2305
|
return t.length === 0 ? null : t.length === 1 ? t[0] : { $or: t };
|
|
2294
2306
|
}
|
|
2295
2307
|
if (n.type === "exclude" && n.child) {
|
|
2296
|
-
const t =
|
|
2308
|
+
const t = Ge(n.child, e);
|
|
2297
2309
|
return t ? { $not: t } : null;
|
|
2298
2310
|
}
|
|
2299
2311
|
return null;
|
|
2300
2312
|
}
|
|
2301
|
-
function
|
|
2313
|
+
function nr(n, e, t) {
|
|
2302
2314
|
if (!e || !e.searchQuery) return n;
|
|
2303
2315
|
const s = e.searchFields || (n[0] ? Object.keys(n[0]).filter((i) => typeof n[0][i] == "string") : []);
|
|
2304
2316
|
if (!s.length) return n;
|
|
@@ -2307,7 +2319,7 @@ function or(n, e, t) {
|
|
|
2307
2319
|
}
|
|
2308
2320
|
const o = s.map((i) => {
|
|
2309
2321
|
try {
|
|
2310
|
-
const { field: l } =
|
|
2322
|
+
const { field: l } = ze(i, "", t);
|
|
2311
2323
|
return {
|
|
2312
2324
|
[l]: {
|
|
2313
2325
|
$regex: new RegExp(r(e.searchQuery), "i")
|
|
@@ -2321,9 +2333,9 @@ function or(n, e, t) {
|
|
|
2321
2333
|
};
|
|
2322
2334
|
}
|
|
2323
2335
|
});
|
|
2324
|
-
return n.filter(
|
|
2336
|
+
return n.filter(Wt({ $or: o }));
|
|
2325
2337
|
}
|
|
2326
|
-
function
|
|
2338
|
+
function Ht(n, e) {
|
|
2327
2339
|
const t = e.split(".");
|
|
2328
2340
|
let s = n;
|
|
2329
2341
|
for (const r of t) {
|
|
@@ -2333,11 +2345,11 @@ function Jt(n, e) {
|
|
|
2333
2345
|
}
|
|
2334
2346
|
return s;
|
|
2335
2347
|
}
|
|
2336
|
-
function
|
|
2348
|
+
function or(n, e) {
|
|
2337
2349
|
return n.map((t) => {
|
|
2338
2350
|
const s = t.startsWith("-"), r = s ? t.substring(1) : t;
|
|
2339
2351
|
try {
|
|
2340
|
-
const { field: o } =
|
|
2352
|
+
const { field: o } = ze(r, "", e);
|
|
2341
2353
|
return {
|
|
2342
2354
|
field: o,
|
|
2343
2355
|
desc: s
|
|
@@ -2350,12 +2362,12 @@ function ir(n, e) {
|
|
|
2350
2362
|
}
|
|
2351
2363
|
});
|
|
2352
2364
|
}
|
|
2353
|
-
function
|
|
2365
|
+
function ir(n, e, t) {
|
|
2354
2366
|
if (!e || !e.length) return [...n];
|
|
2355
|
-
const s =
|
|
2367
|
+
const s = or(e, t);
|
|
2356
2368
|
return [...n].sort((r, o) => {
|
|
2357
2369
|
for (const { field: i, desc: l } of s) {
|
|
2358
|
-
const a =
|
|
2370
|
+
const a = Ht(r, i), c = Ht(o, i);
|
|
2359
2371
|
if (a !== c) {
|
|
2360
2372
|
if (a === null && c !== null) return l ? -1 : 1;
|
|
2361
2373
|
if (a !== null && c === null) return l ? 1 : -1;
|
|
@@ -2368,7 +2380,7 @@ function ar(n, e, t) {
|
|
|
2368
2380
|
return 0;
|
|
2369
2381
|
});
|
|
2370
2382
|
}
|
|
2371
|
-
function
|
|
2383
|
+
function mt(n, e, t) {
|
|
2372
2384
|
if (!Array.isArray(n) || n.length === 0)
|
|
2373
2385
|
return [];
|
|
2374
2386
|
if (!t)
|
|
@@ -2376,19 +2388,19 @@ function yt(n, e, t) {
|
|
|
2376
2388
|
const s = t.primaryKeyField;
|
|
2377
2389
|
let r = [...n];
|
|
2378
2390
|
if (e.filter) {
|
|
2379
|
-
const o =
|
|
2380
|
-
o && Object.keys(o).length && (r = r.filter(
|
|
2391
|
+
const o = Ge(e.filter, t);
|
|
2392
|
+
o && Object.keys(o).length && (r = r.filter(sr(o, t)));
|
|
2381
2393
|
}
|
|
2382
|
-
return e.search && e.search.searchQuery && (r =
|
|
2394
|
+
return e.search && e.search.searchQuery && (r = nr(r, e.search, t)), Array.isArray(e.orderBy) && e.orderBy.length && (r = ir(r, e.orderBy, t)), r.map((o) => o[s]);
|
|
2383
2395
|
}
|
|
2384
|
-
function
|
|
2396
|
+
function yt(n, e) {
|
|
2385
2397
|
const t = /* @__PURE__ */ new Set(), s = e.primaryKeyField;
|
|
2386
2398
|
t.add(s);
|
|
2387
2399
|
function r(i) {
|
|
2388
2400
|
try {
|
|
2389
|
-
const { field: l, isM2M: a, requiredPath: c } =
|
|
2390
|
-
let
|
|
2391
|
-
c ?
|
|
2401
|
+
const { field: l, isM2M: a, requiredPath: c } = ze(i, null, e);
|
|
2402
|
+
let h;
|
|
2403
|
+
c ? h = c : a ? h = `${l}.pk` : h = l, t.add(h);
|
|
2392
2404
|
} catch (l) {
|
|
2393
2405
|
console.warn(`getRequiredFields: couldn't process "${i}": ${l.message}`);
|
|
2394
2406
|
}
|
|
@@ -2414,36 +2426,36 @@ function gt(n, e) {
|
|
|
2414
2426
|
r(i.replace(/^-/, ""));
|
|
2415
2427
|
}), Array.from(t);
|
|
2416
2428
|
}
|
|
2417
|
-
function
|
|
2429
|
+
function gt(n, e, t) {
|
|
2418
2430
|
if (e == null || t.length === 0)
|
|
2419
2431
|
return;
|
|
2420
2432
|
const [s, ...r] = t, o = e[s];
|
|
2421
2433
|
o !== void 0 && (r.length === 0 ? n[s] = o : Array.isArray(o) ? (s in n || (n[s] = []), o.forEach((i, l) => {
|
|
2422
|
-
n[s][l] === void 0 && (n[s][l] = {}),
|
|
2423
|
-
})) : typeof o == "object" && (s in n || (n[s] = {}),
|
|
2434
|
+
n[s][l] === void 0 && (n[s][l] = {}), gt(n[s][l], i, r);
|
|
2435
|
+
})) : typeof o == "object" && (s in n || (n[s] = {}), gt(n[s], o, r)));
|
|
2424
2436
|
}
|
|
2425
|
-
function
|
|
2437
|
+
function _t(n, e) {
|
|
2426
2438
|
const t = {};
|
|
2427
2439
|
return n.forEach((s) => {
|
|
2428
2440
|
const r = s.split(".");
|
|
2429
|
-
|
|
2441
|
+
gt(t, e, r);
|
|
2430
2442
|
}), t;
|
|
2431
2443
|
}
|
|
2432
|
-
function
|
|
2444
|
+
function ss(n, e, t, s = !1) {
|
|
2433
2445
|
if (!Array.isArray(n) || n.length === 0)
|
|
2434
2446
|
return [];
|
|
2435
2447
|
if (!t)
|
|
2436
2448
|
throw new Error("ModelClass is required for proper relationship traversal");
|
|
2437
2449
|
const r = t.primaryKeyField || "id";
|
|
2438
|
-
let o =
|
|
2439
|
-
const l =
|
|
2450
|
+
let o = yt(e, t), i = n.map((a) => _t(o, a));
|
|
2451
|
+
const l = mt(i, e, t);
|
|
2440
2452
|
if (s) {
|
|
2441
2453
|
const a = new Map(n.map((c) => [c[r], c]));
|
|
2442
2454
|
return l.map((c) => a.get(c));
|
|
2443
2455
|
}
|
|
2444
2456
|
return l;
|
|
2445
2457
|
}
|
|
2446
|
-
class
|
|
2458
|
+
class ar {
|
|
2447
2459
|
modelClass;
|
|
2448
2460
|
fetchFn;
|
|
2449
2461
|
queryset;
|
|
@@ -2452,13 +2464,13 @@ class lr {
|
|
|
2452
2464
|
groundTruthPks;
|
|
2453
2465
|
isSyncing;
|
|
2454
2466
|
constructor(e, t, s, r = null, o = null, i = {}) {
|
|
2455
|
-
if (this.modelClass = e, this.fetchFn = t, this.queryset = s, this.isSyncing = !1, this.lastSync = null, this.isTemp = i.isTemp || !1, this.pruneThreshold = i.pruneThreshold || 10, this.groundTruthPks = r || [], this.operationsMap = /* @__PURE__ */ new Map(), this.includedPks = /* @__PURE__ */ new Map(), Array.isArray(o))
|
|
2467
|
+
if (this.modelClass = e, this.fetchFn = t, this.queryset = s, this.isSyncing = !1, this.lastSync = null, this.lastHydrated = null, this._createdAt = Date.now(), this.isTemp = i.isTemp || !1, this.pruneThreshold = i.pruneThreshold || 10, this.groundTruthPks = r || [], this.operationsMap = /* @__PURE__ */ new Map(), this.includedPks = /* @__PURE__ */ new Map(), Array.isArray(o))
|
|
2456
2468
|
for (const l of o) {
|
|
2457
|
-
const c =
|
|
2469
|
+
const c = Fe.get(l.operationId) || new q(l, !0);
|
|
2458
2470
|
this.operationsMap.set(c.operationId, c);
|
|
2459
2471
|
}
|
|
2460
|
-
if (this.qsCache = new
|
|
2461
|
-
const l =
|
|
2472
|
+
if (this.qsCache = new Ct("queryset-cache", {}, this.onHydrated.bind(this)), this._lastRenderedPks = null, this.renderCallbacks = /* @__PURE__ */ new Set(), !this.isTemp) {
|
|
2473
|
+
const l = j.getStore(this.modelClass);
|
|
2462
2474
|
this._modelStoreUnregister = l.registerRenderCallback(() => {
|
|
2463
2475
|
this._emitRenderEvent();
|
|
2464
2476
|
});
|
|
@@ -2471,12 +2483,13 @@ class lr {
|
|
|
2471
2483
|
onHydrated(e) {
|
|
2472
2484
|
if (this.lastSync !== null || this.groundTruthPks.length > 0 || this.operationsMap.size > 0) return;
|
|
2473
2485
|
const t = this.qsCache.get(this.cacheKey);
|
|
2474
|
-
|
|
2486
|
+
b(t) || (this.groundTruthPks = Array.isArray(t) ? t : [], this.lastHydrated = Date.now(), t.length > 0 && this._emitRenderEvent());
|
|
2475
2487
|
}
|
|
2476
2488
|
setCache(e) {
|
|
2489
|
+
if (this.lastSync === null) return;
|
|
2477
2490
|
let t = [];
|
|
2478
2491
|
e.forEach((s) => {
|
|
2479
|
-
typeof s == "string" &&
|
|
2492
|
+
typeof s == "string" && qe(s) && (s = Je(s), b(s) || Te(dt(s))) || t.push(s);
|
|
2480
2493
|
}), this.qsCache.set(this.cacheKey, t);
|
|
2481
2494
|
}
|
|
2482
2495
|
clearCache() {
|
|
@@ -2500,7 +2513,7 @@ class lr {
|
|
|
2500
2513
|
} catch (s) {
|
|
2501
2514
|
console.warn("Error in render callback:", s);
|
|
2502
2515
|
}
|
|
2503
|
-
}),
|
|
2516
|
+
}), He(e, this._lastRenderedPks) || (this._lastRenderedPks = e, bs.emit(
|
|
2504
2517
|
`${this.modelClass.configKey}::${this.modelClass.modelName}::queryset::render`,
|
|
2505
2518
|
{ ast: this.queryset.build(), ModelClass: this.modelClass }
|
|
2506
2519
|
));
|
|
@@ -2555,7 +2568,7 @@ class lr {
|
|
|
2555
2568
|
*/
|
|
2556
2569
|
registerWithModelStore() {
|
|
2557
2570
|
if (this._modelStoreUnregister) return;
|
|
2558
|
-
const e =
|
|
2571
|
+
const e = j.getStore(this.modelClass);
|
|
2559
2572
|
this._modelStoreUnregister = e.registerRenderCallback(() => {
|
|
2560
2573
|
this._emitRenderEvent();
|
|
2561
2574
|
});
|
|
@@ -2567,15 +2580,39 @@ class lr {
|
|
|
2567
2580
|
*/
|
|
2568
2581
|
_getValidatedAndFilteredPks(e) {
|
|
2569
2582
|
const t = Array.from(e).map((o) => this.modelClass.fromPk(o, this.queryset)).filter(
|
|
2570
|
-
(o) =>
|
|
2583
|
+
(o) => j.getEntity(this.modelClass, o.pk) !== null
|
|
2571
2584
|
), s = this.queryset.build();
|
|
2572
|
-
return
|
|
2585
|
+
return ss(t, s, this.modelClass, !1);
|
|
2586
|
+
}
|
|
2587
|
+
/**
|
|
2588
|
+
* For offset pages that aren't full, expand with creates from the model store
|
|
2589
|
+
* that sort after the first item on the page (direction-adjusted).
|
|
2590
|
+
*/
|
|
2591
|
+
_fillOffsetPage(e, t) {
|
|
2592
|
+
const s = j.getStore(this.modelClass);
|
|
2593
|
+
if (!s) return null;
|
|
2594
|
+
const r = this.queryset._orderBy;
|
|
2595
|
+
if (!r || r.length === 0) return null;
|
|
2596
|
+
const o = r[0].replace(/^-/, ""), i = r[0].startsWith("-"), l = this.modelClass.fromPk(e[0], this.queryset);
|
|
2597
|
+
if (!l) return null;
|
|
2598
|
+
const a = l[o];
|
|
2599
|
+
if (a == null) return null;
|
|
2600
|
+
const c = this.pkField, h = new Set(e), p = new Set(e);
|
|
2601
|
+
for (const m of s.operations)
|
|
2602
|
+
if (m.status !== C.REJECTED && !(!t && m.status !== C.CONFIRMED) && !(m.type !== P.CREATE && m.type !== P.BULK_CREATE && m.type !== P.GET_OR_CREATE && m.type !== P.UPDATE_OR_CREATE))
|
|
2603
|
+
for (const y of m.instances) {
|
|
2604
|
+
if (!y || y[c] == null || h.has(y[c])) continue;
|
|
2605
|
+
const _ = y[o];
|
|
2606
|
+
if (_ == null) continue;
|
|
2607
|
+
(i ? _ <= a : _ >= a) && p.add(y[c]);
|
|
2608
|
+
}
|
|
2609
|
+
return p.size === h.size ? null : this._getValidatedAndFilteredPks(Array.from(p));
|
|
2573
2610
|
}
|
|
2574
2611
|
render(e = !0, t = !1) {
|
|
2575
2612
|
if (t) {
|
|
2576
|
-
const
|
|
2577
|
-
if (Array.isArray(
|
|
2578
|
-
return
|
|
2613
|
+
const a = this.qsCache.get(this.cacheKey);
|
|
2614
|
+
if (Array.isArray(a))
|
|
2615
|
+
return G({
|
|
2579
2616
|
type: "render",
|
|
2580
2617
|
source: "cache",
|
|
2581
2618
|
semanticKey: this.queryset.semanticKey,
|
|
@@ -2584,40 +2621,70 @@ class lr {
|
|
|
2584
2621
|
optimistic: e,
|
|
2585
2622
|
groundTruthCount: this.groundTruthPks.length,
|
|
2586
2623
|
operationsCount: this.operationsMap.size,
|
|
2587
|
-
resultCount:
|
|
2588
|
-
}),
|
|
2624
|
+
resultCount: a.length
|
|
2625
|
+
}), a;
|
|
2589
2626
|
}
|
|
2590
|
-
const s = this.
|
|
2591
|
-
let
|
|
2592
|
-
const
|
|
2593
|
-
|
|
2627
|
+
const s = this.renderFromData(e);
|
|
2628
|
+
let r = this._getValidatedAndFilteredPks(s);
|
|
2629
|
+
const o = r.length, i = this.queryset.build().serializerOptions?.limit;
|
|
2630
|
+
if ((this.queryset._serializerOptions?.offset ?? 0) > 0 && i && r.length > 0 && r.length < i) {
|
|
2631
|
+
const a = this._fillOffsetPage(r, e);
|
|
2632
|
+
a && (r = a);
|
|
2633
|
+
}
|
|
2634
|
+
return i && (r = r.slice(0, i)), this.setCache(r), G({
|
|
2594
2635
|
type: "render",
|
|
2595
|
-
source:
|
|
2636
|
+
source: "groundTruth",
|
|
2596
2637
|
semanticKey: this.queryset.semanticKey,
|
|
2597
2638
|
modelName: this.modelClass.modelName,
|
|
2598
2639
|
configKey: this.modelClass.configKey,
|
|
2599
2640
|
optimistic: e,
|
|
2600
2641
|
groundTruthCount: this.groundTruthPks.length,
|
|
2601
2642
|
operationsCount: this.operationsMap.size,
|
|
2602
|
-
rawCount: Array.isArray(
|
|
2603
|
-
filteredCount:
|
|
2604
|
-
resultCount:
|
|
2605
|
-
limit:
|
|
2606
|
-
}),
|
|
2643
|
+
rawCount: Array.isArray(s) ? s.length : 0,
|
|
2644
|
+
filteredCount: o,
|
|
2645
|
+
resultCount: r.length,
|
|
2646
|
+
limit: i
|
|
2647
|
+
}), r;
|
|
2607
2648
|
}
|
|
2608
2649
|
renderFromData(e = !0) {
|
|
2609
|
-
const t = this.
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2650
|
+
const t = j.getStore(this.modelClass);
|
|
2651
|
+
if (this.isTemp && this.lastSync === null && t) {
|
|
2652
|
+
const i = this.pkField;
|
|
2653
|
+
return t.render().map((l) => l[i]).filter((l) => l != null);
|
|
2654
|
+
}
|
|
2655
|
+
if (!this.isTemp && this.lastSync === null && this.lastHydrated === null && t) {
|
|
2656
|
+
if (!((this.queryset._serializerOptions?.offset ?? 0) > 0)) {
|
|
2657
|
+
const c = this.pkField;
|
|
2658
|
+
return t.render().map((h) => h[c]).filter((h) => h != null);
|
|
2659
|
+
}
|
|
2660
|
+
const { root: l } = x.querysetStoreGraph.findRoot(this.queryset), a = l ? x._stores.get(l) : null;
|
|
2661
|
+
if (a && a !== this && a.lastSync !== null)
|
|
2662
|
+
return a.render();
|
|
2663
|
+
}
|
|
2664
|
+
if ((this.queryset._serializerOptions?.offset ?? 0) > 0)
|
|
2665
|
+
return Array.from(this.groundTruthSet);
|
|
2666
|
+
if (!t || !this._hasRecentOps(t))
|
|
2667
|
+
return Array.from(this.groundTruthSet);
|
|
2668
|
+
const r = this._buildFreshPks(t, e), o = this.groundTruthSet;
|
|
2669
|
+
for (const i of r) o.add(i);
|
|
2670
|
+
return Array.from(o);
|
|
2671
|
+
}
|
|
2672
|
+
/** Are there any inflight or recent confirmed ops in the model store? */
|
|
2673
|
+
_hasRecentOps(e) {
|
|
2674
|
+
const t = e.operations, s = this.lastSync ?? this._createdAt;
|
|
2675
|
+
for (let r = t.length - 1; r >= 0; r--)
|
|
2676
|
+
if (t[r].status !== C.REJECTED)
|
|
2677
|
+
return t[r].status !== C.CONFIRMED ? !0 : t[r].timestamp >= s;
|
|
2678
|
+
return !1;
|
|
2613
2679
|
}
|
|
2614
|
-
/**
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2680
|
+
/** Build set of PKs from ops newer than lastSync. Only used for no-offset querysets. */
|
|
2681
|
+
_buildFreshPks(e, t) {
|
|
2682
|
+
const s = /* @__PURE__ */ new Set(), r = this.pkField, o = this.lastSync ?? this._createdAt;
|
|
2683
|
+
for (const i of e.operations)
|
|
2684
|
+
if (i.status !== C.REJECTED && !(!t && i.status !== C.CONFIRMED) && !(i.status === C.CONFIRMED && i.timestamp < o))
|
|
2685
|
+
for (const l of i.instances)
|
|
2686
|
+
l && l[r] != null && s.add(l[r]);
|
|
2687
|
+
return s;
|
|
2621
2688
|
}
|
|
2622
2689
|
applyOperation(e, t) {
|
|
2623
2690
|
const s = this.pkField;
|
|
@@ -2629,26 +2696,7 @@ class lr {
|
|
|
2629
2696
|
continue;
|
|
2630
2697
|
}
|
|
2631
2698
|
let o = r[s];
|
|
2632
|
-
|
|
2633
|
-
case M.CREATE:
|
|
2634
|
-
case M.BULK_CREATE:
|
|
2635
|
-
t.add(o);
|
|
2636
|
-
break;
|
|
2637
|
-
case M.CHECKPOINT:
|
|
2638
|
-
break;
|
|
2639
|
-
case M.UPDATE:
|
|
2640
|
-
case M.UPDATE_INSTANCE:
|
|
2641
|
-
t.add(o);
|
|
2642
|
-
break;
|
|
2643
|
-
case M.DELETE:
|
|
2644
|
-
case M.DELETE_INSTANCE:
|
|
2645
|
-
t.delete(o);
|
|
2646
|
-
break;
|
|
2647
|
-
default:
|
|
2648
|
-
console.error(
|
|
2649
|
-
`[QuerysetStore ${this.modelClass.modelName}] Unknown operation type: ${e.type}`
|
|
2650
|
-
);
|
|
2651
|
-
}
|
|
2699
|
+
CREATE_TYPES.has(e.type) && t.add(o);
|
|
2652
2700
|
}
|
|
2653
2701
|
return t;
|
|
2654
2702
|
}
|
|
@@ -2662,7 +2710,7 @@ class lr {
|
|
|
2662
2710
|
console.warn(`[QuerysetStore ${t}] Already syncing, request ignored.`);
|
|
2663
2711
|
return;
|
|
2664
2712
|
}
|
|
2665
|
-
this.isSyncing = !0,
|
|
2713
|
+
this.isSyncing = !0, G({
|
|
2666
2714
|
type: "sync",
|
|
2667
2715
|
phase: "start",
|
|
2668
2716
|
semanticKey: this.queryset.semanticKey,
|
|
@@ -2676,7 +2724,7 @@ class lr {
|
|
|
2676
2724
|
modelClass: this.modelClass,
|
|
2677
2725
|
canonical_id: e
|
|
2678
2726
|
}), { data: r, included: o } = s;
|
|
2679
|
-
|
|
2727
|
+
b(r) || (this.includedPks.clear(), we(j, o, this.modelClass, this.queryset), this.setGroundTruth(r)), this.setOperations(this.getInflightOperations()), this.lastSync = Date.now(), G({
|
|
2680
2728
|
type: "sync",
|
|
2681
2729
|
phase: "success",
|
|
2682
2730
|
semanticKey: this.queryset.semanticKey,
|
|
@@ -2687,7 +2735,7 @@ class lr {
|
|
|
2687
2735
|
includedCount: o ? Object.keys(o).length : 0
|
|
2688
2736
|
});
|
|
2689
2737
|
} catch (s) {
|
|
2690
|
-
console.error(`[${t}] Failed to sync ground truth:`, s),
|
|
2738
|
+
console.error(`[${t}] Failed to sync ground truth:`, s), G({
|
|
2691
2739
|
type: "sync",
|
|
2692
2740
|
phase: "error",
|
|
2693
2741
|
semanticKey: this.queryset.semanticKey,
|
|
@@ -2701,9 +2749,9 @@ class lr {
|
|
|
2701
2749
|
}
|
|
2702
2750
|
}
|
|
2703
2751
|
}
|
|
2704
|
-
class
|
|
2752
|
+
class lr {
|
|
2705
2753
|
constructor() {
|
|
2706
|
-
this.graph = new
|
|
2754
|
+
this.graph = new Dt({ directed: !0 }), this.processedQuerysets = /* @__PURE__ */ new Set();
|
|
2707
2755
|
}
|
|
2708
2756
|
/**
|
|
2709
2757
|
* Add a queryset and its parent relationship to the graph
|
|
@@ -2789,16 +2837,16 @@ class cr {
|
|
|
2789
2837
|
return !e && !t ? !0 : !e || !t || e.length !== t.length ? !1 : e.every((s, r) => s === t[r]);
|
|
2790
2838
|
}
|
|
2791
2839
|
clear() {
|
|
2792
|
-
this.graph = new
|
|
2840
|
+
this.graph = new Dt({ directed: !0 }), this.processedQuerysets = /* @__PURE__ */ new Set();
|
|
2793
2841
|
}
|
|
2794
2842
|
}
|
|
2795
|
-
class
|
|
2843
|
+
class cr {
|
|
2796
2844
|
#e;
|
|
2797
2845
|
#t;
|
|
2798
|
-
#
|
|
2799
|
-
#
|
|
2846
|
+
#r;
|
|
2847
|
+
#s = [];
|
|
2800
2848
|
constructor(e) {
|
|
2801
|
-
return this.#e = e, this.#t = e.ModelClass, this.#
|
|
2849
|
+
return this.#e = e, this.#t = e.ModelClass, this.#s.queryset = e, this.#s.ModelClass = e.ModelClass, this.#r = new Proxy(this.#s, {
|
|
2802
2850
|
get: (t, s, r) => s === "touch" ? () => this.touch() : s === "serialize" ? () => this.serialize() : s === Symbol.iterator ? () => this.getCurrentItems()[Symbol.iterator]() : typeof s == "string" && [
|
|
2803
2851
|
"forEach",
|
|
2804
2852
|
"map",
|
|
@@ -2808,20 +2856,20 @@ class dr {
|
|
|
2808
2856
|
"every",
|
|
2809
2857
|
"find"
|
|
2810
2858
|
].includes(s) ? (...o) => this.getCurrentItems()[s](...o) : s === "length" ? this.getCurrentItems().length : typeof s == "string" && !isNaN(parseInt(s)) ? this.getCurrentItems()[s] : t[s]
|
|
2811
|
-
}), this.#
|
|
2859
|
+
}), this.#r;
|
|
2812
2860
|
}
|
|
2813
2861
|
/**
|
|
2814
2862
|
* Serializes the lqs as a simple array of objects, for freezing e.g in the metric stores
|
|
2815
2863
|
*/
|
|
2816
2864
|
serialize() {
|
|
2817
|
-
return
|
|
2865
|
+
return x.getStore(this.#e).render().map((s) => (this.#t.primaryKeyField, this.#t.fromPk(s, this.#e).serialize()));
|
|
2818
2866
|
}
|
|
2819
2867
|
/**
|
|
2820
2868
|
* Refresh the queryset data from the database
|
|
2821
2869
|
* Delegates to the underlying store's sync method
|
|
2822
2870
|
*/
|
|
2823
2871
|
refreshFromDb() {
|
|
2824
|
-
return
|
|
2872
|
+
return x.getStore(this.#e).sync(!0);
|
|
2825
2873
|
}
|
|
2826
2874
|
/**
|
|
2827
2875
|
* Get the current items from the store
|
|
@@ -2829,14 +2877,14 @@ class dr {
|
|
|
2829
2877
|
* @returns {Array} The current items in the queryset
|
|
2830
2878
|
*/
|
|
2831
2879
|
getCurrentItems() {
|
|
2832
|
-
return
|
|
2880
|
+
return x.getStore(this.#e).render().map((r) => (this.#t.primaryKeyField, this.#t.fromPk(r, this.#e)));
|
|
2833
2881
|
}
|
|
2834
2882
|
}
|
|
2835
2883
|
class Ce {
|
|
2836
2884
|
constructor() {
|
|
2837
2885
|
this._stores = /* @__PURE__ */ new Map(), this._tempStores = /* @__PURE__ */ new WeakMap(), this.followingQuerysets = /* @__PURE__ */ new Map(), this.syncManager = () => {
|
|
2838
2886
|
console.warn("SyncManager not set for QuerysetStoreRegistry");
|
|
2839
|
-
}, this.querysetStoreGraph = new
|
|
2887
|
+
}, this.querysetStoreGraph = new lr(), this._groupSyncCache = /* @__PURE__ */ new Map();
|
|
2840
2888
|
}
|
|
2841
2889
|
clear() {
|
|
2842
2890
|
this._stores.forEach((e) => {
|
|
@@ -2853,7 +2901,7 @@ class Ce {
|
|
|
2853
2901
|
this.followingQuerysets.has(e) || this.followingQuerysets.set(e, /* @__PURE__ */ new Set()), this.followingQuerysets.get(e).add(t);
|
|
2854
2902
|
}
|
|
2855
2903
|
getStore(e) {
|
|
2856
|
-
if (
|
|
2904
|
+
if (b(e) || b(e.ModelClass))
|
|
2857
2905
|
throw new Error("QuerysetStoreRegistry.getStore requires a valid queryset");
|
|
2858
2906
|
if (this.querysetStoreGraph.addQueryset(e), this._tempStores.has(e))
|
|
2859
2907
|
return this._tempStores.get(e);
|
|
@@ -2871,7 +2919,7 @@ class Ce {
|
|
|
2871
2919
|
...i,
|
|
2872
2920
|
type: "list"
|
|
2873
2921
|
};
|
|
2874
|
-
return (await
|
|
2922
|
+
return (await V(
|
|
2875
2923
|
e,
|
|
2876
2924
|
"list",
|
|
2877
2925
|
c,
|
|
@@ -2884,7 +2932,7 @@ class Ce {
|
|
|
2884
2932
|
{ namespace: "sync", timeout: 3e4 }
|
|
2885
2933
|
// Sync ops on separate queue
|
|
2886
2934
|
)).data;
|
|
2887
|
-
}, o = new
|
|
2935
|
+
}, o = new ar(
|
|
2888
2936
|
e.ModelClass,
|
|
2889
2937
|
r,
|
|
2890
2938
|
e,
|
|
@@ -2903,12 +2951,12 @@ class Ce {
|
|
|
2903
2951
|
* @returns {LiveQueryset} - A live view of the queryset
|
|
2904
2952
|
*/
|
|
2905
2953
|
getEntity(e, t = !1) {
|
|
2906
|
-
if (
|
|
2954
|
+
if (b(e)) throw new Error("qsStoreRegistry: getEntity cannot be called without a queryset");
|
|
2907
2955
|
const s = e.semanticKey;
|
|
2908
2956
|
this.addFollowingQueryset(s, e);
|
|
2909
2957
|
let r;
|
|
2910
2958
|
this._tempStores.has(e) ? (r = this._tempStores.get(e), r.isTemp = !1, r.registerWithModelStore(), this._stores.set(s, r), this.syncManager.followModel(this, e.ModelClass)) : this._stores.has(s) ? r = this._stores.get(s) : (r = this.getStore(e), r.isTemp = !1, r.registerWithModelStore(), this._stores.set(s, r), this.syncManager.followModel(this, e.ModelClass));
|
|
2911
|
-
const o = new
|
|
2959
|
+
const o = new cr(e);
|
|
2912
2960
|
return t && r.sync(), o;
|
|
2913
2961
|
}
|
|
2914
2962
|
/**
|
|
@@ -2918,7 +2966,7 @@ class Ce {
|
|
|
2918
2966
|
* @returns {Array} - The set instances
|
|
2919
2967
|
*/
|
|
2920
2968
|
setEntity(e, t) {
|
|
2921
|
-
if (
|
|
2969
|
+
if (b(e) || b(t)) return [];
|
|
2922
2970
|
const s = e.semanticKey;
|
|
2923
2971
|
this.addFollowingQueryset(s, e);
|
|
2924
2972
|
let r;
|
|
@@ -2945,20 +2993,20 @@ class Ce {
|
|
|
2945
2993
|
* @param {Set} dbSyncedKeys - Set of semanticKeys that are dbSynced (followedQuerysets)
|
|
2946
2994
|
*/
|
|
2947
2995
|
async groupSync(e, t, s, r = null) {
|
|
2948
|
-
if (
|
|
2996
|
+
if (b(e)) return;
|
|
2949
2997
|
const o = e.semanticKey, i = e.ModelClass, l = /* @__PURE__ */ new Set();
|
|
2950
2998
|
for (const y of s) {
|
|
2951
2999
|
const _ = typeof y == "string" ? y : y?.semanticKey;
|
|
2952
3000
|
_ && this._stores.has(_) && l.add(_);
|
|
2953
3001
|
}
|
|
2954
|
-
const { isRoot: a, root: c } = this.querysetStoreGraph.findRoot(e, l),
|
|
2955
|
-
if (
|
|
3002
|
+
const { isRoot: a, root: c } = this.querysetStoreGraph.findRoot(e, l), h = a || c === o;
|
|
3003
|
+
if (G({
|
|
2956
3004
|
type: "groupSync",
|
|
2957
3005
|
phase: "start",
|
|
2958
3006
|
operationId: t,
|
|
2959
3007
|
semanticKey: o,
|
|
2960
3008
|
rootKey: c,
|
|
2961
|
-
iAmRoot:
|
|
3009
|
+
iAmRoot: h,
|
|
2962
3010
|
modelName: i?.modelName,
|
|
2963
3011
|
configKey: i?.configKey
|
|
2964
3012
|
}), !this._groupSyncCache.has(t)) {
|
|
@@ -2973,8 +3021,8 @@ class Ce {
|
|
|
2973
3021
|
console.warn(`[groupSync] No store found for queryset: ${o}`);
|
|
2974
3022
|
return;
|
|
2975
3023
|
}
|
|
2976
|
-
if (
|
|
2977
|
-
await m.sync(r), p.pks = m.groundTruthPks, p.resolve(),
|
|
3024
|
+
if (h)
|
|
3025
|
+
await m.sync(r), p.pks = m.groundTruthPks, p.resolve(), G({
|
|
2978
3026
|
type: "groupSync",
|
|
2979
3027
|
phase: "rootSynced",
|
|
2980
3028
|
operationId: t,
|
|
@@ -2987,12 +3035,12 @@ class Ce {
|
|
|
2987
3035
|
else {
|
|
2988
3036
|
let y = 3e4;
|
|
2989
3037
|
try {
|
|
2990
|
-
const
|
|
2991
|
-
|
|
3038
|
+
const k = he();
|
|
3039
|
+
k.periodicSyncIntervalSeconds && (y = k.periodicSyncIntervalSeconds * 2e3);
|
|
2992
3040
|
} catch {
|
|
2993
3041
|
}
|
|
2994
|
-
const _ = new Promise((
|
|
2995
|
-
setTimeout(() =>
|
|
3042
|
+
const _ = new Promise((k, E) => {
|
|
3043
|
+
setTimeout(() => E(new Error("timeout")), y);
|
|
2996
3044
|
});
|
|
2997
3045
|
let w = !1;
|
|
2998
3046
|
try {
|
|
@@ -3001,7 +3049,7 @@ class Ce {
|
|
|
3001
3049
|
w = !0;
|
|
3002
3050
|
}
|
|
3003
3051
|
if (w || !p.pks) {
|
|
3004
|
-
console.warn(`[groupSync] Falling back to direct sync for: ${o.substring(0, 60)}`), await m.sync(r),
|
|
3052
|
+
console.warn(`[groupSync] Falling back to direct sync for: ${o.substring(0, 60)}`), await m.sync(r), G({
|
|
3005
3053
|
type: "groupSync",
|
|
3006
3054
|
phase: "fallbackSync",
|
|
3007
3055
|
operationId: t,
|
|
@@ -3012,8 +3060,8 @@ class Ce {
|
|
|
3012
3060
|
});
|
|
3013
3061
|
return;
|
|
3014
3062
|
}
|
|
3015
|
-
const v = p.pks.map((
|
|
3016
|
-
m.setGroundTruth(T), m.setOperations(m.getInflightOperations()), m.lastSync = Date.now(),
|
|
3063
|
+
const v = p.pks.map((k) => i.fromPk(k, e)), O = e.build(), T = ss(v, O, i, !1);
|
|
3064
|
+
m.setGroundTruth(T), m.setOperations(m.getInflightOperations()), m.lastSync = Date.now(), G({
|
|
3017
3065
|
type: "groupSync",
|
|
3018
3066
|
phase: "filteredFromRoot",
|
|
3019
3067
|
operationId: t,
|
|
@@ -3026,248 +3074,63 @@ class Ce {
|
|
|
3026
3074
|
}
|
|
3027
3075
|
}
|
|
3028
3076
|
}
|
|
3029
|
-
const
|
|
3030
|
-
class
|
|
3031
|
-
/**
|
|
3032
|
-
* Calculate metric based on ground truth and operations
|
|
3033
|
-
*/
|
|
3034
|
-
calculateWithOperations(e, t, s, r) {
|
|
3035
|
-
let o = e === null ? this.getInitialValue() : e;
|
|
3036
|
-
for (const i of t)
|
|
3037
|
-
i.status !== C.REJECTED && i.frozenInstances.forEach((l, a) => {
|
|
3038
|
-
l[r.primaryKeyField];
|
|
3039
|
-
const c = i.instances[a] || null, f = {
|
|
3040
|
-
originalData: l,
|
|
3041
|
-
// Pre-operation state
|
|
3042
|
-
updatedData: c,
|
|
3043
|
-
// Post-operation state (for updates)
|
|
3044
|
-
type: i.type,
|
|
3045
|
-
status: i.status
|
|
3046
|
-
};
|
|
3047
|
-
o = this.reduceOperation(o, f, s);
|
|
3048
|
-
});
|
|
3049
|
-
return o;
|
|
3050
|
-
}
|
|
3051
|
-
/**
|
|
3052
|
-
* Get initial value for the metric type
|
|
3053
|
-
* Override in subclasses if needed
|
|
3054
|
-
*/
|
|
3055
|
-
getInitialValue() {
|
|
3056
|
-
return 0;
|
|
3057
|
-
}
|
|
3058
|
-
/**
|
|
3059
|
-
* Process a single operation - implement in subclasses
|
|
3060
|
-
*/
|
|
3061
|
-
reduceOperation(e, t, s) {
|
|
3062
|
-
throw new Error("reduceOperation must be implemented by subclass");
|
|
3063
|
-
}
|
|
3064
|
-
/**
|
|
3065
|
-
* Safely get a numeric value from an object
|
|
3066
|
-
*/
|
|
3067
|
-
safeGetValue(e, t) {
|
|
3068
|
-
if (!e || !t) return 0;
|
|
3069
|
-
const s = e[t];
|
|
3070
|
-
if (E(s)) return 0;
|
|
3071
|
-
const r = parseFloat(s);
|
|
3072
|
-
return isNaN(r) ? 0 : r;
|
|
3073
|
-
}
|
|
3074
|
-
}
|
|
3075
|
-
class ur extends ze {
|
|
3076
|
-
reduceOperation(e, t, s) {
|
|
3077
|
-
if (t.status === C.REJECTED)
|
|
3078
|
-
return e;
|
|
3079
|
-
const { type: r } = t;
|
|
3080
|
-
return r === M.CREATE ? e + 1 : [M.DELETE, M.DELETE_INSTANCE].includes(r) ? Math.max(0, e - 1) : e;
|
|
3081
|
-
}
|
|
3082
|
-
}
|
|
3083
|
-
class hr extends ze {
|
|
3084
|
-
reduceOperation(e, t, s) {
|
|
3085
|
-
if (t.status === C.REJECTED)
|
|
3086
|
-
return e;
|
|
3087
|
-
if (!s)
|
|
3088
|
-
throw new Error("SumStrategy requires a field parameter");
|
|
3089
|
-
const { type: r, originalData: o, updatedData: i } = t;
|
|
3090
|
-
switch (r) {
|
|
3091
|
-
case M.CREATE:
|
|
3092
|
-
return e + this.safeGetValue(o, s);
|
|
3093
|
-
case M.CHECKPOINT:
|
|
3094
|
-
case M.UPDATE:
|
|
3095
|
-
if (i) {
|
|
3096
|
-
const l = this.safeGetValue(o, s), a = this.safeGetValue(i, s);
|
|
3097
|
-
return e - l + a;
|
|
3098
|
-
}
|
|
3099
|
-
return e;
|
|
3100
|
-
case M.DELETE:
|
|
3101
|
-
case M.DELETE_INSTANCE:
|
|
3102
|
-
return e - this.safeGetValue(o, s);
|
|
3103
|
-
default:
|
|
3104
|
-
return e;
|
|
3105
|
-
}
|
|
3106
|
-
}
|
|
3107
|
-
}
|
|
3108
|
-
class fr extends ze {
|
|
3109
|
-
getInitialValue() {
|
|
3110
|
-
return 1 / 0;
|
|
3111
|
-
}
|
|
3112
|
-
reduceOperation(e, t, s) {
|
|
3113
|
-
if (t.status === C.REJECTED)
|
|
3114
|
-
return e;
|
|
3115
|
-
if (!s)
|
|
3116
|
-
throw new Error("MinStrategy requires a field parameter");
|
|
3117
|
-
const { type: r, originalData: o, updatedData: i } = t;
|
|
3118
|
-
if (r === M.CREATE) {
|
|
3119
|
-
const l = this.safeGetValue(o, s);
|
|
3120
|
-
return Math.min(e, l);
|
|
3121
|
-
} else if ((r === M.UPDATE || r.CHECKPOINT) && i) {
|
|
3122
|
-
const l = this.safeGetValue(o, s), a = this.safeGetValue(i, s);
|
|
3123
|
-
if (l === e)
|
|
3124
|
-
return a <= l, a;
|
|
3125
|
-
if (a < e)
|
|
3126
|
-
return a;
|
|
3127
|
-
}
|
|
3128
|
-
return e;
|
|
3129
|
-
}
|
|
3130
|
-
}
|
|
3131
|
-
class pr extends ze {
|
|
3132
|
-
getInitialValue() {
|
|
3133
|
-
return -1 / 0;
|
|
3134
|
-
}
|
|
3135
|
-
reduceOperation(e, t, s) {
|
|
3136
|
-
if (t.status === C.REJECTED)
|
|
3137
|
-
return e;
|
|
3138
|
-
if (!s)
|
|
3139
|
-
throw new Error("MaxStrategy requires a field parameter");
|
|
3140
|
-
const { type: r, originalData: o, updatedData: i } = t;
|
|
3141
|
-
if (r === M.CREATE) {
|
|
3142
|
-
const l = this.safeGetValue(o, s);
|
|
3143
|
-
return Math.max(e, l);
|
|
3144
|
-
} else if ((r === M.UPDATE || r === M.CHECKPOINT) && i) {
|
|
3145
|
-
const l = this.safeGetValue(o, s), a = this.safeGetValue(i, s);
|
|
3146
|
-
if (l === e)
|
|
3147
|
-
return a >= l, a;
|
|
3148
|
-
if (a > e)
|
|
3149
|
-
return a;
|
|
3150
|
-
}
|
|
3151
|
-
return e;
|
|
3152
|
-
}
|
|
3153
|
-
}
|
|
3154
|
-
class mr {
|
|
3155
|
-
// Collection of custom strategy overrides
|
|
3156
|
-
static #e = /* @__PURE__ */ new Map();
|
|
3157
|
-
// Default strategy map
|
|
3158
|
-
static #t = /* @__PURE__ */ new Map([
|
|
3159
|
-
["count", () => new ur()],
|
|
3160
|
-
["sum", () => new hr()],
|
|
3161
|
-
["min", () => new fr()],
|
|
3162
|
-
["max", () => new pr()]
|
|
3163
|
-
]);
|
|
3164
|
-
/**
|
|
3165
|
-
* Clear all custom strategy overrides
|
|
3166
|
-
*/
|
|
3167
|
-
static clearCustomStrategies() {
|
|
3168
|
-
this.#e.clear();
|
|
3169
|
-
}
|
|
3170
|
-
/**
|
|
3171
|
-
* Generate a unique key for the strategy map
|
|
3172
|
-
* @private
|
|
3173
|
-
* @param {string} metricType - The type of metric (count, sum, min, max)
|
|
3174
|
-
* @param {Function} ModelClass - The model class
|
|
3175
|
-
* @returns {string} A unique key
|
|
3176
|
-
*/
|
|
3177
|
-
static #s(e, t) {
|
|
3178
|
-
return `${e}::${t.configKey}::${t.modelName}`;
|
|
3179
|
-
}
|
|
3180
|
-
/**
|
|
3181
|
-
* Override a strategy for a specific metric type and model class
|
|
3182
|
-
* @param {string} metricType - The type of metric (count, sum, min, max)
|
|
3183
|
-
* @param {Function|null} ModelClass - The model class or null for a generic override
|
|
3184
|
-
* @param {MetricCalculationStrategy} strategy - The strategy to use
|
|
3185
|
-
*/
|
|
3186
|
-
static overrideStrategy(e, t, s) {
|
|
3187
|
-
if (!e || !s)
|
|
3188
|
-
throw new Error("overrideStrategy requires metricType and strategy");
|
|
3189
|
-
if (!(s instanceof ze))
|
|
3190
|
-
throw new Error("strategy must be an instance of MetricCalculationStrategy");
|
|
3191
|
-
let r;
|
|
3192
|
-
t ? r = this.#s(e, t) : r = `${e}::*::*`, this.#e.set(r, s);
|
|
3193
|
-
}
|
|
3194
|
-
/**
|
|
3195
|
-
* Get the appropriate strategy for a model class and metric type
|
|
3196
|
-
* @param {string} metricType - The type of metric (count, sum, min, max)
|
|
3197
|
-
* @param {Function} ModelClass - The model class
|
|
3198
|
-
* @returns {MetricCalculationStrategy} The appropriate strategy
|
|
3199
|
-
*/
|
|
3200
|
-
static getStrategy(e, t) {
|
|
3201
|
-
const s = e.toLowerCase(), r = this.#s(s, t);
|
|
3202
|
-
if (this.#e.has(r))
|
|
3203
|
-
return this.#e.get(r);
|
|
3204
|
-
const o = `${s}::*::*`;
|
|
3205
|
-
return this.#e.has(o) ? this.#e.get(o) : (this.#t.get(s) || this.#t.get("count"))();
|
|
3206
|
-
}
|
|
3207
|
-
}
|
|
3208
|
-
class yr {
|
|
3077
|
+
const x = new Ce();
|
|
3078
|
+
class dr {
|
|
3209
3079
|
constructor(e, t, s, r = null, o = null, i) {
|
|
3210
|
-
this.metricType = e, this.modelClass = t, this.queryset = s, this.field = r, this.ast = o, this.fetchFn = i, this.groundTruthValue = null, this.isSyncing = !1, this.
|
|
3080
|
+
this.metricType = e, this.modelClass = t, this.queryset = s, this.field = r, this.ast = o, this.fetchFn = i, this.groundTruthValue = null, this.isSyncing = !1, this.deltas = /* @__PURE__ */ new Map(), this.metricCache = new Ct(
|
|
3211
3081
|
"metric-store-cache",
|
|
3212
3082
|
{},
|
|
3213
3083
|
this.onHydrated.bind(this)
|
|
3214
3084
|
), this._lastCalculatedValue = null;
|
|
3215
3085
|
}
|
|
3216
3086
|
reset() {
|
|
3217
|
-
this.groundTruthValue = null, this._lastCalculatedValue = null, this.
|
|
3087
|
+
this.groundTruthValue = null, this._lastCalculatedValue = null, this.deltas = /* @__PURE__ */ new Map(), this.isSyncing = !1, this.clearCache();
|
|
3218
3088
|
}
|
|
3219
3089
|
get cacheKey() {
|
|
3220
3090
|
return `${this.modelClass.configKey}::${this.modelClass.modelName}::metric::${this.metricType}::${this.field || "null"}::${this.ast ? Le(this.ast) : "global"}`;
|
|
3221
3091
|
}
|
|
3222
3092
|
/**
|
|
3223
|
-
* Add
|
|
3224
|
-
* @param {Operation} operation - The operation to add
|
|
3093
|
+
* Add a delta for an operation
|
|
3225
3094
|
*/
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
return;
|
|
3229
|
-
const t = this.operations.findIndex(
|
|
3230
|
-
(s) => s.operationId === e.operationId
|
|
3231
|
-
);
|
|
3232
|
-
t !== -1 ? this.operations[t] = e : this.operations.push(e), E(this.groundTruthValue) || this.render();
|
|
3095
|
+
addDelta(e, t) {
|
|
3096
|
+
this.deltas.set(e, { delta: t, confirmed: !1 }), this.render();
|
|
3233
3097
|
}
|
|
3234
3098
|
/**
|
|
3235
|
-
*
|
|
3236
|
-
* @param {Operation} operation - The operation to update
|
|
3099
|
+
* Mark a delta as confirmed
|
|
3237
3100
|
*/
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
const t = this.operations.findIndex(
|
|
3242
|
-
(s) => s.operationId === e.operationId
|
|
3243
|
-
);
|
|
3244
|
-
t !== -1 ? this.operations[t] = e : this.operations.push(e), E(this.groundTruthValue) || this.render();
|
|
3101
|
+
confirmDelta(e) {
|
|
3102
|
+
const t = this.deltas.get(e);
|
|
3103
|
+
t && (t.confirmed = !0, this.render());
|
|
3245
3104
|
}
|
|
3246
3105
|
/**
|
|
3247
|
-
*
|
|
3248
|
-
* @param {Operation} operation - The operation to confirm
|
|
3106
|
+
* Remove a rejected delta
|
|
3249
3107
|
*/
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
return;
|
|
3253
|
-
const t = this.operations.findIndex(
|
|
3254
|
-
(s) => s.operationId === e.operationId
|
|
3255
|
-
);
|
|
3256
|
-
t !== -1 && (this.operations[t] = e, this.confirmedOps.add(e.operationId)), this.render();
|
|
3108
|
+
rejectDelta(e) {
|
|
3109
|
+
this.deltas.delete(e) && this.render();
|
|
3257
3110
|
}
|
|
3258
3111
|
/**
|
|
3259
|
-
*
|
|
3260
|
-
* @param {Operation} operation - The operation to reject
|
|
3112
|
+
* Update a delta (e.g., when operation is mutated)
|
|
3261
3113
|
*/
|
|
3114
|
+
updateDelta(e, t) {
|
|
3115
|
+
const s = this.deltas.get(e);
|
|
3116
|
+
s ? (s.delta = t, this.render()) : this.addDelta(e, t);
|
|
3117
|
+
}
|
|
3118
|
+
// Legacy API — kept for backward compatibility with existing callers.
|
|
3119
|
+
// processMetricStores in operationEventHandlers still calls these.
|
|
3120
|
+
addOperation(e) {
|
|
3121
|
+
}
|
|
3122
|
+
updateOperation(e) {
|
|
3123
|
+
}
|
|
3124
|
+
confirm(e) {
|
|
3125
|
+
this.confirmDelta(e.operationId);
|
|
3126
|
+
}
|
|
3262
3127
|
reject(e) {
|
|
3263
|
-
|
|
3264
|
-
(t) => t.operationId !== e.operationId
|
|
3265
|
-
), this.confirmedOps.delete(e.operationId), E(this.groundTruthValue) || this.render());
|
|
3128
|
+
this.rejectDelta(e.operationId);
|
|
3266
3129
|
}
|
|
3267
3130
|
onHydrated() {
|
|
3268
3131
|
if (this.groundTruthValue === null) {
|
|
3269
3132
|
const e = this.metricCache.get(this.cacheKey);
|
|
3270
|
-
!
|
|
3133
|
+
!b(e) && !Te(e) && this.setGroundTruth(e?.value);
|
|
3271
3134
|
}
|
|
3272
3135
|
}
|
|
3273
3136
|
setCache() {
|
|
@@ -3280,8 +3143,8 @@ class yr {
|
|
|
3280
3143
|
this.metricCache.delete(this.cacheKey);
|
|
3281
3144
|
}
|
|
3282
3145
|
setGroundTruth(e) {
|
|
3283
|
-
const t = !
|
|
3284
|
-
this.groundTruthValue = e, this.setCache(), t &&
|
|
3146
|
+
const t = !He(this.groundTruthValue, e);
|
|
3147
|
+
this.groundTruthValue = e, this.setCache(), t && Kt.emit("metric::render", {
|
|
3285
3148
|
metricType: this.metricType,
|
|
3286
3149
|
ModelClass: this.modelClass,
|
|
3287
3150
|
field: this.field,
|
|
@@ -3290,19 +3153,15 @@ class yr {
|
|
|
3290
3153
|
});
|
|
3291
3154
|
}
|
|
3292
3155
|
/**
|
|
3293
|
-
* Render
|
|
3294
|
-
* @returns {any} Calculated metric value
|
|
3156
|
+
* Render: groundTruthValue + sum of all deltas
|
|
3295
3157
|
*/
|
|
3296
3158
|
render() {
|
|
3297
|
-
if (
|
|
3159
|
+
if (b(this.groundTruthValue))
|
|
3298
3160
|
return null;
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
this.modelClass
|
|
3304
|
-
);
|
|
3305
|
-
return qe(this._lastCalculatedValue, e) || (this._lastCalculatedValue = e, Nt.emit("metric::render", {
|
|
3161
|
+
let e = this.groundTruthValue;
|
|
3162
|
+
for (const { delta: t } of this.deltas.values())
|
|
3163
|
+
e += t;
|
|
3164
|
+
return He(this._lastCalculatedValue, e) || (this._lastCalculatedValue = e, Kt.emit("metric::render", {
|
|
3306
3165
|
metricType: this.metricType,
|
|
3307
3166
|
ModelClass: this.modelClass,
|
|
3308
3167
|
field: this.field,
|
|
@@ -3328,9 +3187,9 @@ class yr {
|
|
|
3328
3187
|
field: this.field,
|
|
3329
3188
|
ast: this.ast
|
|
3330
3189
|
});
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3190
|
+
for (const [t, s] of this.deltas)
|
|
3191
|
+
s.confirmed && this.deltas.delete(t);
|
|
3192
|
+
return this.setGroundTruth(e), e;
|
|
3334
3193
|
} catch (e) {
|
|
3335
3194
|
return console.error(
|
|
3336
3195
|
`[MetricStore] Failed to sync ${this.metricType} metric:`,
|
|
@@ -3347,13 +3206,13 @@ function te(n, e) {
|
|
|
3347
3206
|
function Z(n) {
|
|
3348
3207
|
return delete n.isOptimistic, delete n.then, delete n.catch, n;
|
|
3349
3208
|
}
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
function
|
|
3209
|
+
ws();
|
|
3210
|
+
Zt.create();
|
|
3211
|
+
function ur(n, e) {
|
|
3353
3212
|
if (!n || !n.__f_expr)
|
|
3354
3213
|
return n;
|
|
3355
3214
|
try {
|
|
3356
|
-
return
|
|
3215
|
+
return Zt.evaluate(n.original_expr, e);
|
|
3357
3216
|
} catch (t) {
|
|
3358
3217
|
return console.warn(`Error evaluating F expression: ${t.message}`), null;
|
|
3359
3218
|
}
|
|
@@ -3367,10 +3226,10 @@ class de {
|
|
|
3367
3226
|
* @returns {Operation} The created operation
|
|
3368
3227
|
*/
|
|
3369
3228
|
static createCreateOperation(e, t = {}, s = null) {
|
|
3370
|
-
const o = e.ModelClass.primaryKeyField, i = s || `${
|
|
3229
|
+
const o = e.ModelClass.primaryKeyField, i = s || `${B()}`, l = zt(i);
|
|
3371
3230
|
return new q({
|
|
3372
3231
|
operationId: i,
|
|
3373
|
-
type:
|
|
3232
|
+
type: P.CREATE,
|
|
3374
3233
|
instances: [{ ...t, [o]: l }],
|
|
3375
3234
|
queryset: e,
|
|
3376
3235
|
args: { data: t },
|
|
@@ -3385,13 +3244,13 @@ class de {
|
|
|
3385
3244
|
* @returns {Operation} The created operation
|
|
3386
3245
|
*/
|
|
3387
3246
|
static createBulkCreateOperation(e, t = [], s = null) {
|
|
3388
|
-
const o = e.ModelClass.primaryKeyField, i = s || `${
|
|
3389
|
-
const
|
|
3390
|
-
return { ...a, [o]:
|
|
3247
|
+
const o = e.ModelClass.primaryKeyField, i = s || `${B()}`, l = t.map((a, c) => {
|
|
3248
|
+
const h = zt(`${i}_${c}`);
|
|
3249
|
+
return { ...a, [o]: h };
|
|
3391
3250
|
});
|
|
3392
3251
|
return new q({
|
|
3393
3252
|
operationId: i,
|
|
3394
|
-
type:
|
|
3253
|
+
type: P.BULK_CREATE,
|
|
3395
3254
|
instances: l,
|
|
3396
3255
|
queryset: e,
|
|
3397
3256
|
args: { data: t },
|
|
@@ -3407,12 +3266,12 @@ class de {
|
|
|
3407
3266
|
* @returns {Operation} The created operation
|
|
3408
3267
|
*/
|
|
3409
3268
|
static createUpdateOperation(e, t = {}, s = null, r = null) {
|
|
3410
|
-
const o = e.ModelClass, i = o.primaryKeyField, a =
|
|
3411
|
-
const m =
|
|
3269
|
+
const o = e.ModelClass, i = o.primaryKeyField, a = x.getStore(e).render(), c = r || `${B()}`, h = a.map((p) => {
|
|
3270
|
+
const m = j.getEntity(o, p), y = { ...m };
|
|
3412
3271
|
y[i] = p;
|
|
3413
3272
|
for (const [_, w] of Object.entries(t))
|
|
3414
3273
|
if (w && typeof w == "object" && w.__f_expr) {
|
|
3415
|
-
const v =
|
|
3274
|
+
const v = ur(w, m);
|
|
3416
3275
|
v !== null ? y[_] = v : y[_] = m[_];
|
|
3417
3276
|
} else
|
|
3418
3277
|
y[_] = w;
|
|
@@ -3420,8 +3279,8 @@ class de {
|
|
|
3420
3279
|
});
|
|
3421
3280
|
return new q({
|
|
3422
3281
|
operationId: c,
|
|
3423
|
-
type:
|
|
3424
|
-
instances:
|
|
3282
|
+
type: P.UPDATE,
|
|
3283
|
+
instances: h,
|
|
3425
3284
|
queryset: e,
|
|
3426
3285
|
args: { filter: s, data: t },
|
|
3427
3286
|
localOnly: e._optimisticOnly || !1
|
|
@@ -3434,10 +3293,10 @@ class de {
|
|
|
3434
3293
|
* @returns {Operation} The created operation
|
|
3435
3294
|
*/
|
|
3436
3295
|
static createDeleteOperation(e, t = null) {
|
|
3437
|
-
const r = e.ModelClass.primaryKeyField, i =
|
|
3296
|
+
const r = e.ModelClass.primaryKeyField, i = x.getStore(e).render(), l = t || `${B()}`, a = i.map((c) => ({ [r]: c }));
|
|
3438
3297
|
return new q({
|
|
3439
3298
|
operationId: l,
|
|
3440
|
-
type:
|
|
3299
|
+
type: P.DELETE,
|
|
3441
3300
|
instances: a,
|
|
3442
3301
|
queryset: e,
|
|
3443
3302
|
args: {},
|
|
@@ -3452,10 +3311,10 @@ class de {
|
|
|
3452
3311
|
* @returns {Operation} The created operation
|
|
3453
3312
|
*/
|
|
3454
3313
|
static createUpdateInstanceOperation(e, t = {}, s = null) {
|
|
3455
|
-
const o = e.ModelClass.primaryKeyField, l =
|
|
3314
|
+
const o = e.ModelClass.primaryKeyField, l = x.getStore(e).render(), a = s || `${B()}`, c = l.map((h) => ({ ...t, [o]: h }));
|
|
3456
3315
|
return new q({
|
|
3457
3316
|
operationId: a,
|
|
3458
|
-
type:
|
|
3317
|
+
type: P.UPDATE_INSTANCE,
|
|
3459
3318
|
instances: c,
|
|
3460
3319
|
queryset: e,
|
|
3461
3320
|
args: { data: t },
|
|
@@ -3470,10 +3329,10 @@ class de {
|
|
|
3470
3329
|
* @returns {Operation} The created operation
|
|
3471
3330
|
*/
|
|
3472
3331
|
static createDeleteInstanceOperation(e, t, s = null) {
|
|
3473
|
-
const r = s || `${
|
|
3332
|
+
const r = s || `${B()}`;
|
|
3474
3333
|
return new q({
|
|
3475
3334
|
operationId: r,
|
|
3476
|
-
type:
|
|
3335
|
+
type: P.DELETE_INSTANCE,
|
|
3477
3336
|
instances: [t],
|
|
3478
3337
|
queryset: e,
|
|
3479
3338
|
args: t,
|
|
@@ -3489,15 +3348,15 @@ class de {
|
|
|
3489
3348
|
* @returns {Operation} The created operation
|
|
3490
3349
|
*/
|
|
3491
3350
|
static createGetOrCreateOperation(e, t = {}, s = {}, r = null) {
|
|
3492
|
-
const o = e.ModelClass, i = o.primaryKeyField, l = r || `${
|
|
3493
|
-
(
|
|
3494
|
-
), w =
|
|
3495
|
-
(
|
|
3496
|
-
), O = v.length === 0, T = O ?
|
|
3351
|
+
const o = e.ModelClass, i = o.primaryKeyField, l = r || `${B()}`, c = j.getStore(o).render(), h = { ...t }, m = new e.constructor(o).filter(h).build(), y = yt(m, o), _ = c.map(
|
|
3352
|
+
(E) => _t(y, o.fromPk(E[i], e))
|
|
3353
|
+
), w = mt(_, m, o), v = c.filter(
|
|
3354
|
+
(E) => w.includes(E[i])
|
|
3355
|
+
), O = v.length === 0, T = O ? P.CREATE : P.UPDATE, k = O ? { ...t, ...s, [i]: l } : v[0];
|
|
3497
3356
|
return new q({
|
|
3498
3357
|
operationId: l,
|
|
3499
3358
|
type: T,
|
|
3500
|
-
instances: [
|
|
3359
|
+
instances: [k],
|
|
3501
3360
|
queryset: e,
|
|
3502
3361
|
args: { lookup: t, defaults: s },
|
|
3503
3362
|
localOnly: e._optimisticOnly || !1
|
|
@@ -3512,22 +3371,22 @@ class de {
|
|
|
3512
3371
|
* @returns {Operation} The created operation
|
|
3513
3372
|
*/
|
|
3514
3373
|
static createUpdateOrCreateOperation(e, t = {}, s = {}, r = null) {
|
|
3515
|
-
const o = e.ModelClass, i = o.primaryKeyField, l = r || `${
|
|
3516
|
-
(
|
|
3517
|
-
), w =
|
|
3518
|
-
(
|
|
3519
|
-
), O = v.length === 0, T = O ?
|
|
3374
|
+
const o = e.ModelClass, i = o.primaryKeyField, l = r || `${B()}`, c = j.getStore(o).render(), h = { ...t }, m = new e.constructor(o).filter(h).build(), y = yt(m, o), _ = c.map(
|
|
3375
|
+
(E) => _t(y, o.fromPk(E[i], e))
|
|
3376
|
+
), w = mt(_, m, o), v = c.filter(
|
|
3377
|
+
(E) => w.includes(E[i])
|
|
3378
|
+
), O = v.length === 0, T = O ? P.CREATE : P.UPDATE, k = O ? { ...t, ...s, [i]: l } : { ...v[0], ...s };
|
|
3520
3379
|
return new q({
|
|
3521
3380
|
operationId: l,
|
|
3522
3381
|
type: T,
|
|
3523
|
-
instances: [
|
|
3382
|
+
instances: [k],
|
|
3524
3383
|
queryset: e,
|
|
3525
3384
|
args: { lookup: t, defaults: s },
|
|
3526
3385
|
localOnly: e._optimisticOnly || !1
|
|
3527
3386
|
});
|
|
3528
3387
|
}
|
|
3529
3388
|
}
|
|
3530
|
-
class
|
|
3389
|
+
class qt extends Array {
|
|
3531
3390
|
/**
|
|
3532
3391
|
* Creates a new ResultTuple.
|
|
3533
3392
|
*
|
|
@@ -3538,7 +3397,7 @@ class Wt extends Array {
|
|
|
3538
3397
|
super(2), this[0] = e, this[1] = t, this.instance = e, this.created = t;
|
|
3539
3398
|
}
|
|
3540
3399
|
}
|
|
3541
|
-
class
|
|
3400
|
+
class hr {
|
|
3542
3401
|
/**
|
|
3543
3402
|
* Executes a get operation (get, first, last) with the QuerySet.
|
|
3544
3403
|
*
|
|
@@ -3548,12 +3407,12 @@ class _r {
|
|
|
3548
3407
|
* @returns {Promise<Object>} The model instance.
|
|
3549
3408
|
*/
|
|
3550
3409
|
static executeGet(e, t, s = {}) {
|
|
3551
|
-
const r = e.ModelClass, i =
|
|
3552
|
-
(
|
|
3553
|
-
const { data: p, included: m, model_name: y } =
|
|
3554
|
-
if (
|
|
3410
|
+
const r = e.ModelClass, i = x.getStore(e).render(), l = Array.isArray(i) && i.length === 1 ? i[0] : null, a = r.fromPk(l, e), c = V(e, t, s).then(
|
|
3411
|
+
(h) => {
|
|
3412
|
+
const { data: p, included: m, model_name: y } = h.data;
|
|
3413
|
+
if (b(p) || Array.isArray(p) && p.length === 0)
|
|
3555
3414
|
return null;
|
|
3556
|
-
we(
|
|
3415
|
+
we(j, m, r, e);
|
|
3557
3416
|
const _ = Array.isArray(p) ? p[0] : p;
|
|
3558
3417
|
return a.pk = _, Z(a), a;
|
|
3559
3418
|
}
|
|
@@ -3576,11 +3435,11 @@ class _r {
|
|
|
3576
3435
|
* synchronized with the in‑memory store.
|
|
3577
3436
|
*/
|
|
3578
3437
|
static executeList(e, t = "list", s = {}) {
|
|
3579
|
-
const r =
|
|
3438
|
+
const r = x.getEntity(e), o = V(e, t, s).then((i) => {
|
|
3580
3439
|
const { data: l, included: a } = i.data;
|
|
3581
|
-
we(
|
|
3440
|
+
we(j, a, e.ModelClass, e);
|
|
3582
3441
|
const c = Array.isArray(l) ? l : [];
|
|
3583
|
-
return
|
|
3442
|
+
return x.setEntity(e, c), Z(r), r;
|
|
3584
3443
|
});
|
|
3585
3444
|
return te(r, o);
|
|
3586
3445
|
}
|
|
@@ -3597,28 +3456,28 @@ class _r {
|
|
|
3597
3456
|
lookup: s.lookup || {},
|
|
3598
3457
|
defaults: s.defaults || {}
|
|
3599
3458
|
}, l = t === "get_or_create" ? de.createGetOrCreateOperation(e, i.lookup, i.defaults) : de.createUpdateOrCreateOperation(e, i.lookup, i.defaults), a = l.type === "create", c = r.fromPk(l.instances[0][o], e);
|
|
3600
|
-
let
|
|
3459
|
+
let h = new qt(c, a);
|
|
3601
3460
|
if (l.localOnly)
|
|
3602
|
-
return l.updateStatus(C.CONFIRMED, l.instances),
|
|
3603
|
-
const p =
|
|
3461
|
+
return l.updateStatus(C.CONFIRMED, l.instances), h;
|
|
3462
|
+
const p = V(
|
|
3604
3463
|
e,
|
|
3605
3464
|
t,
|
|
3606
3465
|
i,
|
|
3607
3466
|
l.operationId
|
|
3608
3467
|
).then((m) => {
|
|
3609
3468
|
const { data: y, included: _, model_name: w } = m.data, v = m.metadata.created;
|
|
3610
|
-
we(
|
|
3469
|
+
we(j, _, r, e);
|
|
3611
3470
|
const O = Array.isArray(y) ? y[0] : y;
|
|
3612
3471
|
a && (c.pk = O);
|
|
3613
|
-
const
|
|
3614
|
-
return
|
|
3615
|
-
instances: [
|
|
3472
|
+
const k = (_[w] || {})[O];
|
|
3473
|
+
return k && l.mutate({
|
|
3474
|
+
instances: [k],
|
|
3616
3475
|
status: C.CONFIRMED
|
|
3617
|
-
}),
|
|
3476
|
+
}), h = new qt(c, v), Z(h), h;
|
|
3618
3477
|
}).catch((m) => {
|
|
3619
3478
|
throw l.updateStatus(C.REJECTED), m;
|
|
3620
3479
|
});
|
|
3621
|
-
return te(
|
|
3480
|
+
return te(h, p);
|
|
3622
3481
|
}
|
|
3623
3482
|
/**
|
|
3624
3483
|
* Executes an aggregation operation with the QuerySet.
|
|
@@ -3634,15 +3493,15 @@ class _r {
|
|
|
3634
3493
|
throw new Error(
|
|
3635
3494
|
`Field parameter is required for ${t} operation`
|
|
3636
3495
|
);
|
|
3637
|
-
const i =
|
|
3496
|
+
const i = Pe.getEntity(t, e, o), l = {};
|
|
3638
3497
|
t !== "exists" && (l.field = o);
|
|
3639
|
-
const a =
|
|
3498
|
+
const a = V(
|
|
3640
3499
|
e,
|
|
3641
3500
|
t,
|
|
3642
3501
|
l
|
|
3643
3502
|
).then((c) => {
|
|
3644
|
-
const
|
|
3645
|
-
return
|
|
3503
|
+
const h = c.data, p = x.getEntity(e);
|
|
3504
|
+
return Pe.setEntity(t, e, o, h, p), Z(i), h;
|
|
3646
3505
|
});
|
|
3647
3506
|
return te(i, a);
|
|
3648
3507
|
}
|
|
@@ -3655,7 +3514,7 @@ class _r {
|
|
|
3655
3514
|
* @returns {Promise<boolean>} Whether records exist.
|
|
3656
3515
|
*/
|
|
3657
3516
|
static async executeExists(e, t = "exists", s = {}) {
|
|
3658
|
-
return (await
|
|
3517
|
+
return (await V(
|
|
3659
3518
|
e,
|
|
3660
3519
|
t,
|
|
3661
3520
|
{}
|
|
@@ -3680,7 +3539,7 @@ class _r {
|
|
|
3680
3539
|
let c = [a, { [o]: a }, l.instances];
|
|
3681
3540
|
if (l.localOnly)
|
|
3682
3541
|
return l.updateStatus(C.CONFIRMED, l.instances), c;
|
|
3683
|
-
const
|
|
3542
|
+
const h = V(
|
|
3684
3543
|
e,
|
|
3685
3544
|
t,
|
|
3686
3545
|
i,
|
|
@@ -3693,7 +3552,7 @@ class _r {
|
|
|
3693
3552
|
}).catch((p) => {
|
|
3694
3553
|
throw l.updateStatus(C.REJECTED), p;
|
|
3695
3554
|
});
|
|
3696
|
-
return te(c,
|
|
3555
|
+
return te(c, h);
|
|
3697
3556
|
}
|
|
3698
3557
|
/**
|
|
3699
3558
|
* Executes a delete operation with the QuerySet.
|
|
@@ -3708,16 +3567,16 @@ class _r {
|
|
|
3708
3567
|
let a = [l, { [o]: l }, i.instances];
|
|
3709
3568
|
if (i.localOnly)
|
|
3710
3569
|
return i.updateStatus(C.CONFIRMED, i.instances), a;
|
|
3711
|
-
const c =
|
|
3570
|
+
const c = V(
|
|
3712
3571
|
e,
|
|
3713
3572
|
t,
|
|
3714
3573
|
{},
|
|
3715
3574
|
i.operationId
|
|
3716
|
-
).then((
|
|
3717
|
-
const p =
|
|
3575
|
+
).then((h) => {
|
|
3576
|
+
const p = h.metadata.deleted_count, m = h.metadata.rows_deleted;
|
|
3718
3577
|
return i.updateStatus(C.CONFIRMED, m), a = [p, { [o]: p }, m || []], Z(a), a;
|
|
3719
|
-
}).catch((
|
|
3720
|
-
throw i.updateStatus(C.REJECTED),
|
|
3578
|
+
}).catch((h) => {
|
|
3579
|
+
throw i.updateStatus(C.REJECTED), h;
|
|
3721
3580
|
});
|
|
3722
3581
|
return te(a, c);
|
|
3723
3582
|
}
|
|
@@ -3730,14 +3589,14 @@ class _r {
|
|
|
3730
3589
|
* @returns {LiveThenable<Object>} The live Model instance which resolves to the created model.
|
|
3731
3590
|
*/
|
|
3732
3591
|
static executeCreate(e, t = "create", s = {}) {
|
|
3733
|
-
const r = e.ModelClass, o = `${
|
|
3592
|
+
const r = e.ModelClass, o = `${B()}`, i = {
|
|
3734
3593
|
data: s.data || {}
|
|
3735
3594
|
};
|
|
3736
|
-
|
|
3595
|
+
b(s.data) && (console.warn("executeCreate was called with null data"), s.data = {});
|
|
3737
3596
|
const l = de.createCreateOperation(e, i.data, o), a = l.instances[0][r.primaryKeyField], c = r.fromPk(a, e);
|
|
3738
3597
|
if (l.localOnly)
|
|
3739
3598
|
return l.updateStatus(C.CONFIRMED, l.instances), c;
|
|
3740
|
-
const
|
|
3599
|
+
const h = V(
|
|
3741
3600
|
e,
|
|
3742
3601
|
t,
|
|
3743
3602
|
i,
|
|
@@ -3748,7 +3607,7 @@ class _r {
|
|
|
3748
3607
|
}
|
|
3749
3608
|
).then((p) => {
|
|
3750
3609
|
const { data: m, included: y, model_name: _ } = p.data;
|
|
3751
|
-
we(
|
|
3610
|
+
we(j, y, r, e);
|
|
3752
3611
|
const w = Array.isArray(m) ? m[0] : m;
|
|
3753
3612
|
c.pk = w;
|
|
3754
3613
|
const O = (y[_] || {})[w];
|
|
@@ -3763,7 +3622,7 @@ class _r {
|
|
|
3763
3622
|
}).catch((p) => {
|
|
3764
3623
|
throw l.updateStatus(C.REJECTED), p;
|
|
3765
3624
|
});
|
|
3766
|
-
return te(c,
|
|
3625
|
+
return te(c, h);
|
|
3767
3626
|
}
|
|
3768
3627
|
/**
|
|
3769
3628
|
* Executes a bulk_create operation with the QuerySet.
|
|
@@ -3774,10 +3633,10 @@ class _r {
|
|
|
3774
3633
|
* @returns {LiveThenable<Array>} Array of live Model instances.
|
|
3775
3634
|
*/
|
|
3776
3635
|
static executeBulkCreate(e, t = "bulk_create", s = {}) {
|
|
3777
|
-
const r = e.ModelClass, o = `${
|
|
3636
|
+
const r = e.ModelClass, o = `${B()}`, i = r.primaryKeyField, l = {
|
|
3778
3637
|
data: s.data || []
|
|
3779
3638
|
};
|
|
3780
|
-
if (
|
|
3639
|
+
if (b(s.data) || !Array.isArray(s.data))
|
|
3781
3640
|
return console.warn("executeBulkCreate was called with invalid data"), Promise.resolve([]);
|
|
3782
3641
|
const a = de.createBulkCreateOperation(e, l.data, o), c = a.instances.map((p) => {
|
|
3783
3642
|
const m = p[i];
|
|
@@ -3785,7 +3644,7 @@ class _r {
|
|
|
3785
3644
|
});
|
|
3786
3645
|
if (a.localOnly)
|
|
3787
3646
|
return a.updateStatus(C.CONFIRMED, a.instances), c;
|
|
3788
|
-
const
|
|
3647
|
+
const h = V(
|
|
3789
3648
|
e,
|
|
3790
3649
|
t,
|
|
3791
3650
|
l,
|
|
@@ -3799,10 +3658,10 @@ class _r {
|
|
|
3799
3658
|
}
|
|
3800
3659
|
).then((p) => {
|
|
3801
3660
|
const { data: m, included: y, model_name: _ } = p.data;
|
|
3802
|
-
we(
|
|
3661
|
+
we(j, y, r, e);
|
|
3803
3662
|
const w = Array.isArray(m) ? m : [];
|
|
3804
|
-
w.forEach((T,
|
|
3805
|
-
c[
|
|
3663
|
+
w.forEach((T, k) => {
|
|
3664
|
+
c[k] && (c[k].pk = T);
|
|
3806
3665
|
});
|
|
3807
3666
|
const v = y[_] || {}, O = w.map((T) => v[T]).filter(Boolean);
|
|
3808
3667
|
return a.mutate({
|
|
@@ -3812,7 +3671,7 @@ class _r {
|
|
|
3812
3671
|
}).catch((p) => {
|
|
3813
3672
|
throw a.updateStatus(C.REJECTED), p;
|
|
3814
3673
|
});
|
|
3815
|
-
return te(c,
|
|
3674
|
+
return te(c, h);
|
|
3816
3675
|
}
|
|
3817
3676
|
/**
|
|
3818
3677
|
* Executes an update_instance operation with the QuerySet.
|
|
@@ -3825,29 +3684,29 @@ class _r {
|
|
|
3825
3684
|
static executeUpdateInstance(e, t = "update_instance", s = {}) {
|
|
3826
3685
|
const r = e.ModelClass;
|
|
3827
3686
|
r.primaryKeyField;
|
|
3828
|
-
const i =
|
|
3687
|
+
const i = x.getStore(e).render(), l = s.data || {}, a = de.createUpdateInstanceOperation(e, l), c = Array.isArray(i) ? i[0] : null, h = r.fromPk(c, e);
|
|
3829
3688
|
if (a.localOnly)
|
|
3830
|
-
return a.updateStatus(C.CONFIRMED, a.instances),
|
|
3831
|
-
const p =
|
|
3689
|
+
return a.updateStatus(C.CONFIRMED, a.instances), h;
|
|
3690
|
+
const p = V(
|
|
3832
3691
|
e,
|
|
3833
3692
|
t,
|
|
3834
3693
|
{ data: l },
|
|
3835
3694
|
a.operationId
|
|
3836
3695
|
).then((m) => {
|
|
3837
3696
|
const { data: y, included: _, model_name: w } = m.data;
|
|
3838
|
-
we(
|
|
3697
|
+
we(j, _, r, e);
|
|
3839
3698
|
const v = Array.isArray(y) ? y[0] : y;
|
|
3840
|
-
|
|
3699
|
+
h.pk = v;
|
|
3841
3700
|
const T = (_[w] || {})[v];
|
|
3842
3701
|
if (!T)
|
|
3843
3702
|
throw new Error(
|
|
3844
3703
|
`Entity data not found for ${w} with pk ${v}`
|
|
3845
3704
|
);
|
|
3846
|
-
return a.updateStatus(C.CONFIRMED, [T]), Z(
|
|
3705
|
+
return a.updateStatus(C.CONFIRMED, [T]), Z(h), h;
|
|
3847
3706
|
}).catch((m) => {
|
|
3848
3707
|
throw a.updateStatus(C.REJECTED), m;
|
|
3849
3708
|
});
|
|
3850
|
-
return te(
|
|
3709
|
+
return te(h, p);
|
|
3851
3710
|
}
|
|
3852
3711
|
/**
|
|
3853
3712
|
* Executes a delete_instance operation with the QuerySet.
|
|
@@ -3865,18 +3724,18 @@ class _r {
|
|
|
3865
3724
|
let a = [1, { [o]: 1 }, l.instances];
|
|
3866
3725
|
if (l.localOnly)
|
|
3867
3726
|
return l.updateStatus(C.CONFIRMED, l.instances), a;
|
|
3868
|
-
const c =
|
|
3727
|
+
const c = V(
|
|
3869
3728
|
e,
|
|
3870
3729
|
t,
|
|
3871
3730
|
s,
|
|
3872
3731
|
l.operationId
|
|
3873
|
-
).then((
|
|
3732
|
+
).then((h) => {
|
|
3874
3733
|
let p = 1;
|
|
3875
|
-
typeof
|
|
3876
|
-
const m =
|
|
3734
|
+
typeof h.data == "number" && (p = h.data);
|
|
3735
|
+
const m = h.metadata?.rows_deleted || [s];
|
|
3877
3736
|
return l.updateStatus(C.CONFIRMED, [s]), a = [p, { [o]: p }, m], Z(a), a;
|
|
3878
|
-
}).catch((
|
|
3879
|
-
throw l.updateStatus(C.REJECTED),
|
|
3737
|
+
}).catch((h) => {
|
|
3738
|
+
throw l.updateStatus(C.REJECTED), h;
|
|
3880
3739
|
});
|
|
3881
3740
|
return te(a, c);
|
|
3882
3741
|
}
|
|
@@ -3933,22 +3792,22 @@ class _r {
|
|
|
3933
3792
|
* @returns {Promise<any>} The raw API response data.
|
|
3934
3793
|
*/
|
|
3935
3794
|
static executeRemote(e, t = "list", s = {}) {
|
|
3936
|
-
return
|
|
3795
|
+
return V(e, t, s);
|
|
3937
3796
|
}
|
|
3938
3797
|
}
|
|
3939
|
-
class
|
|
3798
|
+
class fr {
|
|
3940
3799
|
constructor(e, t, s = null) {
|
|
3941
3800
|
this.queryset = e, this.metricType = t, this.field = s;
|
|
3942
3801
|
}
|
|
3943
3802
|
get lqs() {
|
|
3944
|
-
return
|
|
3803
|
+
return x.getEntity(this.queryset);
|
|
3945
3804
|
}
|
|
3946
3805
|
/**
|
|
3947
3806
|
* Refresh the metric data from the database
|
|
3948
3807
|
* Delegates to the underlying store's sync method
|
|
3949
3808
|
*/
|
|
3950
3809
|
refreshFromDb() {
|
|
3951
|
-
return
|
|
3810
|
+
return Pe.getStore(
|
|
3952
3811
|
this.metricType,
|
|
3953
3812
|
this.queryset,
|
|
3954
3813
|
this.field
|
|
@@ -3959,7 +3818,7 @@ class wr {
|
|
|
3959
3818
|
* Called implicitly by JS when coercing to a primitive (arithmetic, template literals, etc.)
|
|
3960
3819
|
*/
|
|
3961
3820
|
valueOf() {
|
|
3962
|
-
const e =
|
|
3821
|
+
const e = Pe.getStore(
|
|
3963
3822
|
this.metricType,
|
|
3964
3823
|
this.queryset,
|
|
3965
3824
|
this.field
|
|
@@ -3975,14 +3834,22 @@ class wr {
|
|
|
3975
3834
|
return this.valueOf();
|
|
3976
3835
|
}
|
|
3977
3836
|
}
|
|
3978
|
-
class
|
|
3837
|
+
class wt {
|
|
3979
3838
|
constructor() {
|
|
3980
|
-
this._stores = /* @__PURE__ */ new Map(), this.syncManager = null;
|
|
3839
|
+
this._stores = /* @__PURE__ */ new Map(), this.followedMetrics = /* @__PURE__ */ new Set(), this.syncManager = null;
|
|
3981
3840
|
}
|
|
3982
3841
|
clear() {
|
|
3983
3842
|
for (const e of this._stores.values())
|
|
3984
3843
|
this.syncManager.unfollowModel(this, e.store.modelClass);
|
|
3985
|
-
this._stores = /* @__PURE__ */ new Map();
|
|
3844
|
+
this._stores = /* @__PURE__ */ new Map(), this.followedMetrics = /* @__PURE__ */ new Set();
|
|
3845
|
+
}
|
|
3846
|
+
followMetric(e, t, s = null) {
|
|
3847
|
+
const r = this._makeKey(e, t, s);
|
|
3848
|
+
this.followedMetrics.add(r);
|
|
3849
|
+
}
|
|
3850
|
+
unfollowMetric(e, t, s = null) {
|
|
3851
|
+
const r = this._makeKey(e, t, s);
|
|
3852
|
+
this.followedMetrics.delete(r);
|
|
3986
3853
|
}
|
|
3987
3854
|
setSyncManager(e) {
|
|
3988
3855
|
this.syncManager = e;
|
|
@@ -3993,7 +3860,7 @@ class vt {
|
|
|
3993
3860
|
* @returns {Array} Array of metric stores
|
|
3994
3861
|
*/
|
|
3995
3862
|
getAllStoresForQueryset(e) {
|
|
3996
|
-
if (
|
|
3863
|
+
if (b(e) || b(e.ModelClass))
|
|
3997
3864
|
return [];
|
|
3998
3865
|
const t = [], s = e.ModelClass;
|
|
3999
3866
|
for (const [r, o] of this._stores.entries()) {
|
|
@@ -4010,14 +3877,14 @@ class vt {
|
|
|
4010
3877
|
* Get a metric store for a specific queryset and metric type
|
|
4011
3878
|
*/
|
|
4012
3879
|
getStore(e, t, s = null) {
|
|
4013
|
-
if (
|
|
3880
|
+
if (b(e) || b(t) || b(t.ModelClass))
|
|
4014
3881
|
return null;
|
|
4015
3882
|
const r = t.ModelClass, o = t.build(), i = this._makeKey(e, t, s);
|
|
4016
3883
|
if (!this._stores.has(i)) {
|
|
4017
|
-
const l = async ({ metricType: c, modelClass:
|
|
3884
|
+
const l = async ({ metricType: c, modelClass: h, field: p, ast: m }) => {
|
|
4018
3885
|
const y = t.clone();
|
|
4019
|
-
return await
|
|
4020
|
-
}, a = new
|
|
3886
|
+
return await hr.executeAgg(y, c, { field: p });
|
|
3887
|
+
}, a = new dr(
|
|
4021
3888
|
e,
|
|
4022
3889
|
r,
|
|
4023
3890
|
t,
|
|
@@ -4037,20 +3904,20 @@ class vt {
|
|
|
4037
3904
|
* Get a metric value for a specific queryset
|
|
4038
3905
|
*/
|
|
4039
3906
|
getEntity(e, t, s = null) {
|
|
4040
|
-
if (
|
|
3907
|
+
if (b(e) || b(t) || b(t.ModelClass))
|
|
4041
3908
|
return null;
|
|
4042
3909
|
this.getStore(e, t, s);
|
|
4043
|
-
const r = new
|
|
3910
|
+
const r = new fr(t, e, s);
|
|
4044
3911
|
return r;
|
|
4045
3912
|
}
|
|
4046
3913
|
/**
|
|
4047
3914
|
* Set metric ground truth value
|
|
4048
3915
|
*/
|
|
4049
3916
|
setEntity(e, t, s, r) {
|
|
4050
|
-
if (
|
|
3917
|
+
if (b(e) || b(t) || b(t.ModelClass))
|
|
4051
3918
|
return null;
|
|
4052
3919
|
const o = this.getStore(e, t, s);
|
|
4053
|
-
return o ? ((!
|
|
3920
|
+
return o ? ((!b(o.groundTruthValue) || !Te(o.operations)) && o.reset(), o.setGroundTruth(r), r) : null;
|
|
4054
3921
|
}
|
|
4055
3922
|
/**
|
|
4056
3923
|
* Sync a specific metric with the server
|
|
@@ -4067,8 +3934,8 @@ class vt {
|
|
|
4067
3934
|
return this._stores.has(e) ? this._stores.get(e).queryset : null;
|
|
4068
3935
|
}
|
|
4069
3936
|
}
|
|
4070
|
-
const
|
|
4071
|
-
class
|
|
3937
|
+
const Pe = new wt();
|
|
3938
|
+
class pr {
|
|
4072
3939
|
constructor(e) {
|
|
4073
3940
|
this.event = e.event, this.model = e.model, this.operation_id = e.operation_id, this.pk_field_name = e.pk_field_name, this.configKey = e.configKey, this.canonical_id = e.canonical_id || null, this.server_ts_ms = e.server_ts_ms || null, this.instances = e.instances?.map((t) => t && this.pk_field_name && t[this.pk_field_name] != null ? {
|
|
4074
3941
|
...t,
|
|
@@ -4076,21 +3943,21 @@ class Cr {
|
|
|
4076
3943
|
} : t) || e.instances, this._cachedInstances = null;
|
|
4077
3944
|
}
|
|
4078
3945
|
get modelClass() {
|
|
4079
|
-
return
|
|
3946
|
+
return Xt(this.model, this.configKey);
|
|
4080
3947
|
}
|
|
4081
3948
|
async getFullInstances() {
|
|
4082
3949
|
if (this.event === "delete")
|
|
4083
3950
|
throw new Error(
|
|
4084
3951
|
"Cannot fetch full instances for delete operation bozo..."
|
|
4085
3952
|
);
|
|
4086
|
-
return
|
|
3953
|
+
return b(this._cachedInstances) && (this._cachedInstances = await this.modelClass.objects.filter({
|
|
4087
3954
|
[`${this.modelClass.primaryKeyField}__in`]: this.instances.map(
|
|
4088
3955
|
(e) => e[this.modelClass.primaryKeyField]
|
|
4089
3956
|
)
|
|
4090
3957
|
}).fetch()), this._cachedInstances;
|
|
4091
3958
|
}
|
|
4092
3959
|
}
|
|
4093
|
-
class
|
|
3960
|
+
class mr {
|
|
4094
3961
|
constructor() {
|
|
4095
3962
|
this.registries = /* @__PURE__ */ new Map(), this.followedModels = /* @__PURE__ */ new Map(), this.followAllQuerysets = !0, this.followedQuerysets = /* @__PURE__ */ new Map(), this.periodicSyncTimer = null, this.eventBatch = /* @__PURE__ */ new Map(), this.debounceTimer = null, this.maxWaitTimer = null, this.debounceMs = 100, this.maxWaitMs = 2e3, this.batchStartTime = null;
|
|
4096
3963
|
}
|
|
@@ -4113,7 +3980,7 @@ class vr {
|
|
|
4113
3980
|
* Initialize event handlers for all event receivers
|
|
4114
3981
|
*/
|
|
4115
3982
|
initialize() {
|
|
4116
|
-
|
|
3983
|
+
js(), zs().forEach((t, s) => {
|
|
4117
3984
|
t && t.addModelEventHandler(this.handleEvent.bind(this));
|
|
4118
3985
|
}), this.startPeriodicSync();
|
|
4119
3986
|
}
|
|
@@ -4133,7 +4000,7 @@ class vr {
|
|
|
4133
4000
|
async syncStaleQuerysets() {
|
|
4134
4001
|
const e = this.registries.get(Ce);
|
|
4135
4002
|
if (!e) return;
|
|
4136
|
-
const t = `periodic-sync-${
|
|
4003
|
+
const t = `periodic-sync-${B()}`, s = new Set(
|
|
4137
4004
|
[...this.followedQuerysets].map((o) => o.semanticKey).filter((o) => e._stores.has(o))
|
|
4138
4005
|
), r = [];
|
|
4139
4006
|
for (const [o, i] of e._stores.entries()) {
|
|
@@ -4147,7 +4014,7 @@ class vr {
|
|
|
4147
4014
|
), this.pruneUnreferencedModels();
|
|
4148
4015
|
}
|
|
4149
4016
|
pruneUnreferencedModels() {
|
|
4150
|
-
const e = this.registries.get(
|
|
4017
|
+
const e = this.registries.get(Ve), t = this.registries.get(Ce);
|
|
4151
4018
|
if (!(!e || !t))
|
|
4152
4019
|
for (const [s, r] of e._stores.entries())
|
|
4153
4020
|
r.pruneUnreferencedInstances(t);
|
|
@@ -4165,7 +4032,7 @@ class vr {
|
|
|
4165
4032
|
const r = [...this.followedModels.values()].some(
|
|
4166
4033
|
(o) => o.has(t)
|
|
4167
4034
|
);
|
|
4168
|
-
s.add(t), r ||
|
|
4035
|
+
s.add(t), r || jt(t.configKey)?.subscribe(
|
|
4169
4036
|
t.modelName,
|
|
4170
4037
|
this.handleEvent
|
|
4171
4038
|
);
|
|
@@ -4175,7 +4042,7 @@ class vr {
|
|
|
4175
4042
|
if (!s) return;
|
|
4176
4043
|
s.delete(t), [...this.followedModels.values()].some(
|
|
4177
4044
|
(o) => o.has(t)
|
|
4178
|
-
) ||
|
|
4045
|
+
) || jt(t.configKey)?.unsubscribe(
|
|
4179
4046
|
t.modelName,
|
|
4180
4047
|
this.handleEvent
|
|
4181
4048
|
);
|
|
@@ -4192,7 +4059,7 @@ class vr {
|
|
|
4192
4059
|
* Checks the `verify` flag on membership state to determine which querysets need syncing.
|
|
4193
4060
|
*/
|
|
4194
4061
|
syncQuerysetsNeedingVerification(e) {
|
|
4195
|
-
const t =
|
|
4062
|
+
const t = Fe.getQuerysetStates(e);
|
|
4196
4063
|
if (!t) return;
|
|
4197
4064
|
const s = this.registries.get(Ce);
|
|
4198
4065
|
if (!s) return;
|
|
@@ -4203,7 +4070,7 @@ class vr {
|
|
|
4203
4070
|
c && r.push(c);
|
|
4204
4071
|
}
|
|
4205
4072
|
if (r.length === 0) return;
|
|
4206
|
-
const o = `maybe-sync-${
|
|
4073
|
+
const o = `maybe-sync-${B()}`, i = new Set(
|
|
4207
4074
|
[...this.followedQuerysets].map((l) => l.semanticKey).filter((l) => s._stores.has(l))
|
|
4208
4075
|
);
|
|
4209
4076
|
Promise.all(
|
|
@@ -4213,7 +4080,7 @@ class vr {
|
|
|
4213
4080
|
);
|
|
4214
4081
|
}
|
|
4215
4082
|
handleEvent = (e) => {
|
|
4216
|
-
|
|
4083
|
+
G({
|
|
4217
4084
|
type: "event",
|
|
4218
4085
|
modelName: e.model,
|
|
4219
4086
|
configKey: e.configKey,
|
|
@@ -4223,8 +4090,8 @@ class vr {
|
|
|
4223
4090
|
operationId: e.operation_id,
|
|
4224
4091
|
socketId: e.socket_id
|
|
4225
4092
|
});
|
|
4226
|
-
let t = new
|
|
4227
|
-
if (this.registries.has(
|
|
4093
|
+
let t = new pr(e), s = Fe.has(t.operation_id);
|
|
4094
|
+
if (this.registries.has(wt) && this.processMetrics(t), s) {
|
|
4228
4095
|
this.syncQuerysetsNeedingVerification(t.operation_id);
|
|
4229
4096
|
return;
|
|
4230
4097
|
}
|
|
@@ -4251,7 +4118,7 @@ class vr {
|
|
|
4251
4118
|
s.has(o) || s.set(o, []), s.get(o).push(r);
|
|
4252
4119
|
}), s.forEach((r, o) => {
|
|
4253
4120
|
const i = r[0];
|
|
4254
|
-
this.registries.has(Ce) && this.processQuerysetsBatch(i, r), this.registries.has(
|
|
4121
|
+
this.registries.has(Ce) && this.processQuerysetsBatch(i, r), this.registries.has(Ve) && this.processModels(i);
|
|
4255
4122
|
});
|
|
4256
4123
|
}
|
|
4257
4124
|
isQuerysetFollowed(e) {
|
|
@@ -4268,20 +4135,20 @@ class vr {
|
|
|
4268
4135
|
}
|
|
4269
4136
|
processQuerysetsBatch(e, t) {
|
|
4270
4137
|
const s = this.registries.get(Ce), r = [];
|
|
4271
|
-
for (const [c,
|
|
4272
|
-
if (
|
|
4138
|
+
for (const [c, h] of s._stores.entries())
|
|
4139
|
+
if (h.modelClass.modelName === e.model && h.modelClass.configKey === e.configKey) {
|
|
4273
4140
|
if (this.followAllQuerysets) {
|
|
4274
|
-
r.push(
|
|
4141
|
+
r.push(h);
|
|
4275
4142
|
continue;
|
|
4276
4143
|
}
|
|
4277
4144
|
const p = s.followingQuerysets.get(c);
|
|
4278
|
-
p && [...p].some((y) => this.isQuerysetFollowed(y)) && r.push(
|
|
4145
|
+
p && [...p].some((y) => this.isQuerysetFollowed(y)) && r.push(h);
|
|
4279
4146
|
}
|
|
4280
4147
|
if (r.length === 0) return;
|
|
4281
4148
|
const i = t.reduce(
|
|
4282
|
-
(c,
|
|
4149
|
+
(c, h) => (h.server_ts_ms || 0) > (c.server_ts_ms || 0) ? h : c,
|
|
4283
4150
|
t[0]
|
|
4284
|
-
).canonical_id, l = `remote-event-${
|
|
4151
|
+
).canonical_id, l = `remote-event-${B()}`, a = new Set(
|
|
4285
4152
|
[...this.followedQuerysets].map((c) => c.semanticKey).filter((c) => s._stores.has(c))
|
|
4286
4153
|
);
|
|
4287
4154
|
Promise.all(
|
|
@@ -4291,18 +4158,18 @@ class vr {
|
|
|
4291
4158
|
);
|
|
4292
4159
|
}
|
|
4293
4160
|
processMetrics(e) {
|
|
4294
|
-
const t = this.registries.get(
|
|
4161
|
+
const t = this.registries.get(wt);
|
|
4295
4162
|
for (const [s, r] of t._stores.entries())
|
|
4296
4163
|
if (r.queryset && r.queryset.modelClass.modelName === e.model && r.queryset.modelClass.configKey === e.configKey) {
|
|
4297
4164
|
if (this.followAllQuerysets) {
|
|
4298
4165
|
r.store.sync();
|
|
4299
4166
|
continue;
|
|
4300
4167
|
}
|
|
4301
|
-
this.isQuerysetFollowed(r.queryset) && r.store.sync();
|
|
4168
|
+
(t.followedMetrics.has(s) || this.isQuerysetFollowed(r.queryset)) && r.store.sync();
|
|
4302
4169
|
}
|
|
4303
4170
|
}
|
|
4304
4171
|
processModels(e) {
|
|
4305
|
-
const t = this.registries.get(
|
|
4172
|
+
const t = this.registries.get(Ve);
|
|
4306
4173
|
if (!t) return;
|
|
4307
4174
|
const s = t.getStore(e.modelClass);
|
|
4308
4175
|
if (!s) return;
|
|
@@ -4312,105 +4179,105 @@ class vr {
|
|
|
4312
4179
|
if (r.size === 0) return;
|
|
4313
4180
|
const o = new Set(s.groundTruthPks), i = this.registries.get(Ce), l = /* @__PURE__ */ new Set();
|
|
4314
4181
|
if (i)
|
|
4315
|
-
for (const [c,
|
|
4316
|
-
|
|
4182
|
+
for (const [c, h] of i._stores.entries())
|
|
4183
|
+
h.modelClass.modelName === e.model && h.modelClass.configKey === e.configKey && h.groundTruthPks.forEach((p) => l.add(p));
|
|
4317
4184
|
const a = [];
|
|
4318
4185
|
r.forEach((c) => {
|
|
4319
4186
|
o.has(c) && !l.has(c) && a.push(c);
|
|
4320
4187
|
}), a.length > 0 && s.sync(a);
|
|
4321
4188
|
}
|
|
4322
4189
|
}
|
|
4323
|
-
const
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
const
|
|
4328
|
-
function
|
|
4329
|
-
typeof n == "function" &&
|
|
4190
|
+
const Ae = new mr();
|
|
4191
|
+
Ae.manageRegistry(x);
|
|
4192
|
+
Ae.manageRegistry(j);
|
|
4193
|
+
Ae.manageRegistry(Pe);
|
|
4194
|
+
const yr = /* @__PURE__ */ new Set();
|
|
4195
|
+
function gr(n) {
|
|
4196
|
+
typeof n == "function" && yr.add(n);
|
|
4330
4197
|
}
|
|
4331
|
-
|
|
4332
|
-
const
|
|
4333
|
-
|
|
4334
|
-
|
|
4198
|
+
Ae.followAllQuerysets = !1;
|
|
4199
|
+
const rs = /* @__PURE__ */ new Map();
|
|
4200
|
+
gr(() => {
|
|
4201
|
+
rs.clear(), Ae.followAllQuerysets = !0, Ae.followedQuerysets.clear();
|
|
4335
4202
|
});
|
|
4336
|
-
const
|
|
4203
|
+
const _r = (n, e) => {
|
|
4337
4204
|
const t = n.__vccOpts || n;
|
|
4338
4205
|
for (const [s, r] of e)
|
|
4339
4206
|
t[s] = r;
|
|
4340
4207
|
return t;
|
|
4341
|
-
},
|
|
4208
|
+
}, wr = { class: "szd" }, Cr = { class: "szd-header" }, vr = { class: "szd-header__top" }, kr = { class: "szd-header__left" }, br = {
|
|
4342
4209
|
key: 0,
|
|
4343
4210
|
class: "szd-header__model"
|
|
4344
|
-
},
|
|
4211
|
+
}, Er = {
|
|
4345
4212
|
key: 1,
|
|
4346
4213
|
class: "szd-header__model szd-header__model--empty"
|
|
4347
|
-
},
|
|
4214
|
+
}, Sr = { class: "szd-header__right" }, Tr = {
|
|
4348
4215
|
key: 0,
|
|
4349
4216
|
class: "szd-header__badge szd-header__badge--syncing"
|
|
4350
|
-
},
|
|
4217
|
+
}, Mr = {
|
|
4351
4218
|
key: 1,
|
|
4352
4219
|
class: "szd-header__badge"
|
|
4353
|
-
},
|
|
4220
|
+
}, Ar = { class: "szd-header__badge" }, Or = { class: "szd-tabs" }, $r = ["onClick"], Fr = { class: "szd-content" }, Pr = {
|
|
4354
4221
|
key: 0,
|
|
4355
4222
|
class: "szd-panel"
|
|
4356
|
-
},
|
|
4223
|
+
}, Dr = { class: "szd-panel__section" }, zr = { class: "szd-kv" }, Rr = { class: "szd-kv__row" }, Kr = { class: "szd-kv__value" }, Ir = { class: "szd-kv__row" }, Nr = { class: "szd-kv__value" }, xr = { class: "szd-kv__row" }, jr = { class: "szd-kv__value" }, Ur = { class: "szd-kv__row" }, Qr = { class: "szd-kv__value" }, Lr = { class: "szd-panel__section" }, Vr = { class: "szd-stats" }, Br = { class: "szd-stat" }, Gr = { class: "szd-stat__value" }, Hr = { class: "szd-stat" }, qr = { class: "szd-stat__value" }, Jr = { class: "szd-stat" }, Wr = { class: "szd-stat__value" }, Zr = { class: "szd-stat" }, Yr = { class: "szd-stat__value" }, Xr = {
|
|
4357
4224
|
class: "szd-kv",
|
|
4358
4225
|
style: { "margin-top": "12px" }
|
|
4359
|
-
},
|
|
4226
|
+
}, en = { class: "szd-kv__row" }, tn = { class: "szd-kv__value" }, sn = {
|
|
4360
4227
|
key: 0,
|
|
4361
4228
|
class: "szd-panel__section"
|
|
4362
|
-
},
|
|
4229
|
+
}, rn = { class: "szd-event-preview__text" }, nn = { class: "szd-event-preview__time" }, on = {
|
|
4363
4230
|
key: 1,
|
|
4364
4231
|
class: "szd-panel"
|
|
4365
|
-
},
|
|
4232
|
+
}, an = { class: "szd-timeline-filters" }, ln = ["onUpdate:modelValue"], cn = { class: "szd-timeline" }, dn = ["onClick"], un = { class: "szd-timeline__time" }, hn = { class: "szd-timeline__text" }, fn = {
|
|
4366
4233
|
key: 0,
|
|
4367
4234
|
class: "szd-empty"
|
|
4368
|
-
},
|
|
4235
|
+
}, pn = {
|
|
4369
4236
|
key: 2,
|
|
4370
4237
|
class: "szd-panel"
|
|
4371
|
-
},
|
|
4238
|
+
}, mn = { class: "szd-pipeline" }, yn = ["onClick"], gn = { class: "szd-pipeline__label" }, _n = { class: "szd-pipeline__count" }, wn = {
|
|
4372
4239
|
key: 0,
|
|
4373
4240
|
class: "szd-pipeline__arrow"
|
|
4374
|
-
},
|
|
4241
|
+
}, Cn = {
|
|
4375
4242
|
class: "szd-panel__section",
|
|
4376
4243
|
style: { "margin-top": "20px" }
|
|
4377
|
-
},
|
|
4244
|
+
}, vn = { class: "szd-preview-header" }, kn = ["value"], bn = {
|
|
4378
4245
|
key: 0,
|
|
4379
4246
|
class: "szd-data-grid"
|
|
4380
|
-
},
|
|
4247
|
+
}, En = { class: "szd-data-card__header" }, Sn = {
|
|
4381
4248
|
key: 0,
|
|
4382
4249
|
class: "szd-data-card__badge"
|
|
4383
|
-
},
|
|
4250
|
+
}, Tn = {
|
|
4384
4251
|
key: 1,
|
|
4385
4252
|
class: "szd-data-card__badge szd-data-card__badge--absent"
|
|
4386
|
-
},
|
|
4253
|
+
}, Mn = { class: "szd-data-card__content" }, An = {
|
|
4387
4254
|
key: 1,
|
|
4388
4255
|
class: "szd-empty"
|
|
4389
|
-
},
|
|
4256
|
+
}, On = {
|
|
4390
4257
|
key: 3,
|
|
4391
4258
|
class: "szd-panel"
|
|
4392
|
-
},
|
|
4259
|
+
}, $n = {
|
|
4393
4260
|
class: "szd-kv",
|
|
4394
4261
|
style: { "margin-bottom": "16px" }
|
|
4395
|
-
},
|
|
4262
|
+
}, Fn = { class: "szd-kv__row" }, Pn = { class: "szd-kv__value szd-kv__value--mono" }, Dn = { class: "szd-ast" }, zn = {
|
|
4396
4263
|
key: 0,
|
|
4397
4264
|
class: "szd-detail"
|
|
4398
|
-
},
|
|
4265
|
+
}, Rn = { class: "szd-detail__panel szd-detail__panel--sm" }, Kn = { class: "szd-detail__header" }, In = { class: "szd-detail__body" }, Nn = { class: "szd-settings-section" }, xn = ["value"], jn = {
|
|
4399
4266
|
key: 0,
|
|
4400
4267
|
class: "szd-settings-section"
|
|
4401
|
-
},
|
|
4268
|
+
}, Un = { class: "szd-settings-row" }, Qn = { class: "szd-settings-code" }, Ln = { class: "szd-settings-section" }, Vn = { class: "szd-settings-actions" }, Bn = ["disabled"], Gn = { class: "szd-settings-section" }, Hn = { class: "szd-toggle" }, qn = {
|
|
4402
4269
|
key: 1,
|
|
4403
4270
|
class: "szd-settings-section"
|
|
4404
|
-
},
|
|
4271
|
+
}, Jn = { class: "szd-kv" }, Wn = { class: "szd-kv__row" }, Zn = { class: "szd-kv__value" }, Yn = { class: "szd-kv__row" }, Xn = { class: "szd-kv__value" }, eo = { class: "szd-kv__row" }, to = { class: "szd-kv__value" }, so = { class: "szd-kv__row" }, ro = { class: "szd-kv__value" }, no = { class: "szd-kv__row" }, oo = { class: "szd-kv__value" }, io = {
|
|
4405
4272
|
key: 0,
|
|
4406
4273
|
class: "szd-detail"
|
|
4407
|
-
},
|
|
4274
|
+
}, ao = { class: "szd-detail__panel" }, lo = { class: "szd-detail__header" }, co = { class: "szd-detail__title" }, uo = { class: "szd-detail__body" }, ho = { class: "szd-kv" }, fo = { class: "szd-kv__key" }, po = { class: "szd-kv__value" }, mo = { class: "szd-ast" }, yo = {
|
|
4408
4275
|
class: "szd-kv",
|
|
4409
4276
|
style: { "margin-bottom": "16px" }
|
|
4410
|
-
},
|
|
4277
|
+
}, go = { class: "szd-kv__row" }, _o = { class: "szd-kv__value" }, wo = { class: "szd-kv__row" }, Co = { class: "szd-kv__value" }, vo = {
|
|
4411
4278
|
key: 0,
|
|
4412
4279
|
class: "szd-kv__note"
|
|
4413
|
-
},
|
|
4280
|
+
}, ko = { class: "szd-ast" }, Jt = 100, bo = {
|
|
4414
4281
|
__name: "StateZeroDebugPanel",
|
|
4415
4282
|
props: {
|
|
4416
4283
|
queryset: { type: [Object, String], default: null },
|
|
@@ -4424,7 +4291,7 @@ const kr = (n, e) => {
|
|
|
4424
4291
|
{ id: "timeline", label: "Timeline" },
|
|
4425
4292
|
{ id: "data", label: "Data" },
|
|
4426
4293
|
{ id: "ast", label: "AST" }
|
|
4427
|
-
], r = J(""), o = J(e.useQueryset), i = J(!0), l = J(
|
|
4294
|
+
], r = J(""), o = J(e.useQueryset), i = J(!0), l = J(Qt()), a = J(0), c = J(!1), h = J(null), p = J(!1), m = J(null), y = J({
|
|
4428
4295
|
request: !0,
|
|
4429
4296
|
response: !0,
|
|
4430
4297
|
render: !0,
|
|
@@ -4440,12 +4307,12 @@ const kr = (n, e) => {
|
|
|
4440
4307
|
let g = u;
|
|
4441
4308
|
return d && g && typeof g == "object" && "value" in g && (g = g.value), g?.original?.queryset ? g.original.queryset : g?.queryset ? g.queryset : g?.semanticKey ? g : null;
|
|
4442
4309
|
}
|
|
4443
|
-
const w =
|
|
4310
|
+
const w = I(
|
|
4444
4311
|
() => _(e.queryset, o.value)
|
|
4445
|
-
), v =
|
|
4312
|
+
), v = I(() => {
|
|
4446
4313
|
a.value;
|
|
4447
4314
|
const u = [];
|
|
4448
|
-
return
|
|
4315
|
+
return rs.forEach((d) => {
|
|
4449
4316
|
d?.semanticKey && u.push({
|
|
4450
4317
|
semanticKey: d.semanticKey,
|
|
4451
4318
|
modelName: d.ModelClass?.modelName,
|
|
@@ -4453,50 +4320,50 @@ const kr = (n, e) => {
|
|
|
4453
4320
|
queryset: d
|
|
4454
4321
|
});
|
|
4455
4322
|
}), u;
|
|
4456
|
-
}), O =
|
|
4323
|
+
}), O = I(() => (a.value, Array.from(x._stores.entries()).map(
|
|
4457
4324
|
([u, d]) => ({
|
|
4458
4325
|
semanticKey: u,
|
|
4459
4326
|
modelName: d?.modelClass?.modelName,
|
|
4460
4327
|
configKey: d?.modelClass?.configKey,
|
|
4461
4328
|
store: d
|
|
4462
4329
|
})
|
|
4463
|
-
))), T =
|
|
4330
|
+
))), T = I(() => {
|
|
4464
4331
|
const u = /* @__PURE__ */ new Map();
|
|
4465
4332
|
return v.value.forEach((d) => {
|
|
4466
4333
|
u.set(d.semanticKey, d.queryset);
|
|
4467
4334
|
}), u;
|
|
4468
|
-
}),
|
|
4335
|
+
}), k = I(() => {
|
|
4469
4336
|
const u = /* @__PURE__ */ new Map();
|
|
4470
4337
|
return v.value.forEach((d) => {
|
|
4471
4338
|
u.set(d.semanticKey, d);
|
|
4472
4339
|
}), O.value.forEach((d) => {
|
|
4473
4340
|
u.has(d.semanticKey) || u.set(d.semanticKey, d);
|
|
4474
4341
|
}), Array.from(u.values());
|
|
4475
|
-
}),
|
|
4476
|
-
if (
|
|
4342
|
+
}), E = I(() => w.value?.semanticKey ? w.value.semanticKey : r.value ? r.value : ""), Q = I(() => w.value ? w.value : r.value && T.value.get(r.value) || null), N = I(() => {
|
|
4343
|
+
if (Q.value)
|
|
4477
4344
|
try {
|
|
4478
|
-
return
|
|
4345
|
+
return x.getStore(Q.value);
|
|
4479
4346
|
} catch {
|
|
4480
4347
|
return null;
|
|
4481
4348
|
}
|
|
4482
|
-
return
|
|
4483
|
-
}), F =
|
|
4349
|
+
return E.value && x._stores.get(E.value) || null;
|
|
4350
|
+
}), F = I(() => {
|
|
4484
4351
|
a.value;
|
|
4485
|
-
const u = N.value, d =
|
|
4352
|
+
const u = N.value, d = Q.value, g = u?.modelClass?.modelName || d?.ModelClass?.modelName, R = u?.modelClass?.configKey || d?.ModelClass?.configKey, H = u?.groundTruthPks?.length ?? 0, oe = u?.operationsMap?.size ?? 0, le = u?.getInflightOperations?.() || [], ke = u?.isSyncing ?? !1, je = u?.lastSync ? new Date(u.lastSync).toLocaleString() : "—", nt = u && Array.isArray(u._lastRenderedPks) ? u._lastRenderedPks.length : null, cs = u?.groundTruthPks?.length ?? 0, ds = u ? u.lastSync === null ? "model store" : "ground truth" : "—", us = ke ? "Sync in progress — results may change." : oe > 0 ? "Optimistic operations are applied to results." : u?.lastSync === null ? "No ground truth yet — rendering from model store." : "Using ground truth + local filters.";
|
|
4486
4353
|
return {
|
|
4487
4354
|
modelName: g,
|
|
4488
|
-
configKey:
|
|
4355
|
+
configKey: R,
|
|
4489
4356
|
groundTruthCount: H,
|
|
4490
4357
|
opsCount: oe,
|
|
4491
4358
|
inFlightCount: le.length,
|
|
4492
|
-
isSyncing:
|
|
4493
|
-
lastSync:
|
|
4494
|
-
optimisticCount:
|
|
4495
|
-
confirmedCount:
|
|
4496
|
-
source:
|
|
4497
|
-
reason:
|
|
4359
|
+
isSyncing: ke,
|
|
4360
|
+
lastSync: je,
|
|
4361
|
+
optimisticCount: nt,
|
|
4362
|
+
confirmedCount: cs,
|
|
4363
|
+
source: ds,
|
|
4364
|
+
reason: us
|
|
4498
4365
|
};
|
|
4499
|
-
}), re =
|
|
4366
|
+
}), re = I(() => {
|
|
4500
4367
|
a.value;
|
|
4501
4368
|
try {
|
|
4502
4369
|
return N.value?.queryset?.build?.() || null;
|
|
@@ -4507,13 +4374,13 @@ const kr = (n, e) => {
|
|
|
4507
4374
|
function pe(u) {
|
|
4508
4375
|
if (!u?.filter?.conditions) return "—";
|
|
4509
4376
|
const d = u.filter.conditions;
|
|
4510
|
-
return typeof d != "object" ? String(d) : Object.entries(d).map(([
|
|
4377
|
+
return typeof d != "object" ? String(d) : Object.entries(d).map(([R, H]) => H === null ? `${R}: null` : typeof H == "object" ? `${R}: ${JSON.stringify(H)}` : `${R}: ${H}`).join(", ");
|
|
4511
4378
|
}
|
|
4512
4379
|
function ae(u) {
|
|
4513
4380
|
const d = u?.orderBy;
|
|
4514
4381
|
return !d || Array.isArray(d) && d.length === 0 ? "—" : Array.isArray(d) ? d.join(", ") : String(d);
|
|
4515
4382
|
}
|
|
4516
|
-
const
|
|
4383
|
+
const z = I(() => {
|
|
4517
4384
|
const u = re.value;
|
|
4518
4385
|
return {
|
|
4519
4386
|
filter: pe(u),
|
|
@@ -4521,10 +4388,10 @@ const kr = (n, e) => {
|
|
|
4521
4388
|
limit: u?.serializerOptions?.limit ?? "—"
|
|
4522
4389
|
};
|
|
4523
4390
|
});
|
|
4524
|
-
function
|
|
4391
|
+
function D(u, d, g, R) {
|
|
4525
4392
|
if (!u || !Array.isArray(g)) return [];
|
|
4526
4393
|
const H = [];
|
|
4527
|
-
for (const oe of g.slice(0,
|
|
4394
|
+
for (const oe of g.slice(0, R))
|
|
4528
4395
|
try {
|
|
4529
4396
|
const le = u.fromPk(oe, d);
|
|
4530
4397
|
le && H.push(le.serialize());
|
|
@@ -4532,9 +4399,9 @@ const kr = (n, e) => {
|
|
|
4532
4399
|
}
|
|
4533
4400
|
return H;
|
|
4534
4401
|
}
|
|
4535
|
-
const K =
|
|
4402
|
+
const K = I(() => {
|
|
4536
4403
|
a.value;
|
|
4537
|
-
const u = N.value, d =
|
|
4404
|
+
const u = N.value, d = Q.value;
|
|
4538
4405
|
if (!u || !d)
|
|
4539
4406
|
return {
|
|
4540
4407
|
modelStoreFiltered: [],
|
|
@@ -4549,7 +4416,7 @@ const kr = (n, e) => {
|
|
|
4549
4416
|
finalSample: [],
|
|
4550
4417
|
limit: null
|
|
4551
4418
|
};
|
|
4552
|
-
const g = Array.isArray(u.groundTruthPks) ? [...u.groundTruthPks] : [],
|
|
4419
|
+
const g = Array.isArray(u.groundTruthPks) ? [...u.groundTruthPks] : [], R = u.renderFromData(!0), H = u.renderFromData(!1), oe = u._getValidatedAndFilteredPks(R), le = [], ke = d.build()?.serializerOptions?.limit ?? null, je = ke ? oe.slice(0, ke) : oe, nt = le.length > 0 ? D(
|
|
4553
4420
|
u.modelClass,
|
|
4554
4421
|
d,
|
|
4555
4422
|
le,
|
|
@@ -4558,66 +4425,66 @@ const kr = (n, e) => {
|
|
|
4558
4425
|
return {
|
|
4559
4426
|
modelStoreFiltered: le,
|
|
4560
4427
|
groundTruth: g,
|
|
4561
|
-
optimistic:
|
|
4428
|
+
optimistic: R,
|
|
4562
4429
|
filtered: oe,
|
|
4563
|
-
final:
|
|
4564
|
-
modelStoreSample:
|
|
4565
|
-
groundTruthSample:
|
|
4430
|
+
final: je,
|
|
4431
|
+
modelStoreSample: nt,
|
|
4432
|
+
groundTruthSample: D(
|
|
4566
4433
|
u.modelClass,
|
|
4567
4434
|
d,
|
|
4568
4435
|
g,
|
|
4569
4436
|
e.sampleSize
|
|
4570
4437
|
),
|
|
4571
|
-
optimisticSample:
|
|
4438
|
+
optimisticSample: D(
|
|
4572
4439
|
u.modelClass,
|
|
4573
4440
|
d,
|
|
4574
|
-
|
|
4441
|
+
R,
|
|
4575
4442
|
e.sampleSize
|
|
4576
4443
|
),
|
|
4577
|
-
filteredSample:
|
|
4444
|
+
filteredSample: D(
|
|
4578
4445
|
u.modelClass,
|
|
4579
4446
|
d,
|
|
4580
4447
|
oe,
|
|
4581
4448
|
e.sampleSize
|
|
4582
4449
|
),
|
|
4583
|
-
finalSample:
|
|
4450
|
+
finalSample: D(
|
|
4584
4451
|
u.modelClass,
|
|
4585
4452
|
d,
|
|
4586
|
-
|
|
4453
|
+
je,
|
|
4587
4454
|
e.sampleSize
|
|
4588
4455
|
),
|
|
4589
|
-
limit:
|
|
4456
|
+
limit: ke,
|
|
4590
4457
|
confirmed: H
|
|
4591
4458
|
};
|
|
4592
|
-
}), me =
|
|
4459
|
+
}), me = I(() => [
|
|
4593
4460
|
{ id: "model-store", label: "Model Store", count: K.value.modelStoreFiltered.length, pks: K.value.modelStoreFiltered },
|
|
4594
4461
|
{ id: "ground-truth", label: "Ground Truth", count: K.value.groundTruth.length, pks: K.value.groundTruth },
|
|
4595
4462
|
{ id: "optimistic", label: "Optimistic", count: K.value.optimistic.length, pks: K.value.optimistic },
|
|
4596
4463
|
{ id: "filtered", label: "Filtered", count: K.value.filtered.length, pks: K.value.filtered },
|
|
4597
4464
|
{ id: "final", label: "Final", count: K.value.final.length, pks: K.value.final }
|
|
4598
|
-
]),
|
|
4465
|
+
]), Ze = I(() => K.value.final || []);
|
|
4599
4466
|
function ye(u) {
|
|
4600
|
-
const d = N.value, g =
|
|
4467
|
+
const d = N.value, g = Q.value;
|
|
4601
4468
|
if (!d || !g || u == null) return null;
|
|
4602
4469
|
try {
|
|
4603
|
-
const
|
|
4604
|
-
return
|
|
4470
|
+
const R = d.modelClass.fromPk(u, g);
|
|
4471
|
+
return R ? R.serialize() : null;
|
|
4605
4472
|
} catch {
|
|
4606
4473
|
return null;
|
|
4607
4474
|
}
|
|
4608
4475
|
}
|
|
4609
|
-
|
|
4610
|
-
const
|
|
4611
|
-
if (!
|
|
4612
|
-
const u =
|
|
4613
|
-
return !d || !g || !u.pks ? [] :
|
|
4614
|
-
}),
|
|
4615
|
-
if (!
|
|
4476
|
+
I(() => m.value == null ? null : ye(m.value));
|
|
4477
|
+
const Re = I(() => {
|
|
4478
|
+
if (!h.value || h.value.type !== "snapshot") return [];
|
|
4479
|
+
const u = h.value.data, d = N.value, g = Q.value;
|
|
4480
|
+
return !d || !g || !u.pks ? [] : D(d.modelClass, g, u.pks, Jt);
|
|
4481
|
+
}), Ye = I(() => !h.value || h.value.type !== "snapshot" ? !1 : h.value.data.count > Jt), Ke = I(() => {
|
|
4482
|
+
if (!E.value) return l.value;
|
|
4616
4483
|
const u = N.value;
|
|
4617
|
-
return l.value.filter((d) => d.semanticKey ===
|
|
4618
|
-
}),
|
|
4484
|
+
return l.value.filter((d) => d.semanticKey === E.value ? !0 : u ? d.modelName === u.modelClass?.modelName && d.configKey === u.modelClass?.configKey : !1);
|
|
4485
|
+
}), ve = I(() => Ke.value.filter((u) => y.value[u.type])), Ie = I(() => l.value.length), ne = I(
|
|
4619
4486
|
() => l.value.length ? l.value[l.value.length - 1] : null
|
|
4620
|
-
),
|
|
4487
|
+
), Ne = [
|
|
4621
4488
|
{ id: "request", label: "Requests", color: "#3b82f6" },
|
|
4622
4489
|
{ id: "response", label: "Responses", color: "#22c55e" },
|
|
4623
4490
|
{ id: "render", label: "Renders", color: "#a855f7" },
|
|
@@ -4628,10 +4495,10 @@ const kr = (n, e) => {
|
|
|
4628
4495
|
{ id: "groupSync", label: "Group Sync", color: "#8b5cf6" },
|
|
4629
4496
|
{ id: "error", label: "Errors", color: "#ef4444" }
|
|
4630
4497
|
];
|
|
4631
|
-
function
|
|
4632
|
-
return
|
|
4498
|
+
function xe(u) {
|
|
4499
|
+
return Ne.find((d) => d.id === u)?.color || "#6b7280";
|
|
4633
4500
|
}
|
|
4634
|
-
function
|
|
4501
|
+
function Xe(u) {
|
|
4635
4502
|
if (!u) return "";
|
|
4636
4503
|
try {
|
|
4637
4504
|
return new Date(u).toLocaleTimeString();
|
|
@@ -4639,7 +4506,7 @@ const kr = (n, e) => {
|
|
|
4639
4506
|
return "";
|
|
4640
4507
|
}
|
|
4641
4508
|
}
|
|
4642
|
-
function
|
|
4509
|
+
function vt(u) {
|
|
4643
4510
|
if (!u) return "";
|
|
4644
4511
|
switch (u.type) {
|
|
4645
4512
|
case "request":
|
|
@@ -4664,11 +4531,11 @@ const kr = (n, e) => {
|
|
|
4664
4531
|
return u.type;
|
|
4665
4532
|
}
|
|
4666
4533
|
}
|
|
4667
|
-
function
|
|
4534
|
+
function ns(u) {
|
|
4668
4535
|
if (!u) return null;
|
|
4669
4536
|
const d = {
|
|
4670
4537
|
type: u.type,
|
|
4671
|
-
time:
|
|
4538
|
+
time: Xe(u.ts),
|
|
4672
4539
|
model: u.modelName,
|
|
4673
4540
|
config: u.configKey,
|
|
4674
4541
|
semanticKey: u.semanticKey
|
|
@@ -4696,13 +4563,13 @@ const kr = (n, e) => {
|
|
|
4696
4563
|
return d;
|
|
4697
4564
|
}
|
|
4698
4565
|
}
|
|
4699
|
-
function
|
|
4566
|
+
function os() {
|
|
4700
4567
|
Bs(), l.value = [];
|
|
4701
4568
|
}
|
|
4702
|
-
function
|
|
4703
|
-
!
|
|
4569
|
+
function is() {
|
|
4570
|
+
!E.value || !navigator?.clipboard || navigator.clipboard.writeText(E.value);
|
|
4704
4571
|
}
|
|
4705
|
-
async function
|
|
4572
|
+
async function as() {
|
|
4706
4573
|
if (!(!N.value || c.value)) {
|
|
4707
4574
|
c.value = !0;
|
|
4708
4575
|
try {
|
|
@@ -4714,59 +4581,59 @@ const kr = (n, e) => {
|
|
|
4714
4581
|
}
|
|
4715
4582
|
}
|
|
4716
4583
|
function kt(u) {
|
|
4717
|
-
|
|
4584
|
+
h.value = { type: "entry", data: u };
|
|
4718
4585
|
}
|
|
4719
|
-
function
|
|
4720
|
-
|
|
4586
|
+
function ls(u) {
|
|
4587
|
+
h.value = { type: "snapshot", data: u };
|
|
4721
4588
|
}
|
|
4722
|
-
function
|
|
4723
|
-
|
|
4589
|
+
function bt() {
|
|
4590
|
+
h.value = null;
|
|
4724
4591
|
}
|
|
4725
|
-
function
|
|
4592
|
+
function Et(u) {
|
|
4726
4593
|
Object.keys(y.value).forEach((d) => {
|
|
4727
4594
|
y.value[d] = u;
|
|
4728
4595
|
});
|
|
4729
4596
|
}
|
|
4730
|
-
let
|
|
4731
|
-
return
|
|
4732
|
-
|
|
4597
|
+
let et = null, tt = null, st = null, rt = null;
|
|
4598
|
+
return hs(() => {
|
|
4599
|
+
Gs(), Lt(e.maxEntries), et = Ls((u) => {
|
|
4733
4600
|
i.value && (l.value = [...l.value, u], l.value.length > e.maxEntries && (l.value = l.value.slice(-e.maxEntries)));
|
|
4734
|
-
}),
|
|
4601
|
+
}), tt = Vs(() => {
|
|
4735
4602
|
l.value = [];
|
|
4736
|
-
}),
|
|
4603
|
+
}), st = setInterval(() => {
|
|
4737
4604
|
a.value += 1;
|
|
4738
|
-
}, 2e3),
|
|
4739
|
-
l.value =
|
|
4605
|
+
}, 2e3), rt = setInterval(() => {
|
|
4606
|
+
l.value = Qt();
|
|
4740
4607
|
}, 1e3);
|
|
4741
|
-
}),
|
|
4742
|
-
|
|
4743
|
-
}),
|
|
4608
|
+
}), fs(() => {
|
|
4609
|
+
et && et(), tt && tt(), st && clearInterval(st), rt && clearInterval(rt);
|
|
4610
|
+
}), ot(
|
|
4744
4611
|
() => e.maxEntries,
|
|
4745
|
-
(u) =>
|
|
4746
|
-
),
|
|
4612
|
+
(u) => Lt(u)
|
|
4613
|
+
), ot(
|
|
4747
4614
|
() => e.useQueryset,
|
|
4748
4615
|
(u) => {
|
|
4749
4616
|
o.value = u;
|
|
4750
4617
|
}
|
|
4751
|
-
),
|
|
4618
|
+
), ot(E, () => {
|
|
4752
4619
|
m.value = null;
|
|
4753
|
-
}), (u, d) => (A(),
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
d[9] || (d[9] =
|
|
4758
|
-
|
|
4620
|
+
}), (u, d) => (A(), M("section", wr, [
|
|
4621
|
+
f("header", Cr, [
|
|
4622
|
+
f("div", vr, [
|
|
4623
|
+
f("div", kr, [
|
|
4624
|
+
d[9] || (d[9] = f("div", { class: "szd-header__title" }, "StateZero", -1)),
|
|
4625
|
+
E.value ? (A(), M("span", br, S(F.value.modelName || "?"), 1)) : (A(), M("span", Er, "No queryset"))
|
|
4759
4626
|
]),
|
|
4760
|
-
|
|
4761
|
-
F.value.isSyncing ? (A(),
|
|
4762
|
-
F.value.opsCount > 0 ? (A(),
|
|
4763
|
-
|
|
4764
|
-
|
|
4627
|
+
f("div", Sr, [
|
|
4628
|
+
F.value.isSyncing ? (A(), M("span", Tr, "Syncing")) : L("", !0),
|
|
4629
|
+
F.value.opsCount > 0 ? (A(), M("span", Mr, S(F.value.opsCount) + " ops", 1)) : L("", !0),
|
|
4630
|
+
f("span", Ar, S(Ie.value) + " events", 1),
|
|
4631
|
+
f("button", {
|
|
4765
4632
|
class: "szd-btn szd-btn--icon",
|
|
4766
4633
|
onClick: d[0] || (d[0] = (g) => p.value = !0),
|
|
4767
4634
|
title: "Settings"
|
|
4768
4635
|
}, [...d[10] || (d[10] = [
|
|
4769
|
-
|
|
4636
|
+
f("svg", {
|
|
4770
4637
|
width: "16",
|
|
4771
4638
|
height: "16",
|
|
4772
4639
|
viewBox: "0 0 24 24",
|
|
@@ -4774,339 +4641,339 @@ const kr = (n, e) => {
|
|
|
4774
4641
|
stroke: "currentColor",
|
|
4775
4642
|
"stroke-width": "2"
|
|
4776
4643
|
}, [
|
|
4777
|
-
|
|
4644
|
+
f("circle", {
|
|
4778
4645
|
cx: "12",
|
|
4779
4646
|
cy: "12",
|
|
4780
4647
|
r: "3"
|
|
4781
4648
|
}),
|
|
4782
|
-
|
|
4649
|
+
f("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" })
|
|
4783
4650
|
], -1)
|
|
4784
4651
|
])])
|
|
4785
4652
|
])
|
|
4786
4653
|
]),
|
|
4787
|
-
|
|
4788
|
-
(A(),
|
|
4654
|
+
f("nav", Or, [
|
|
4655
|
+
(A(), M(W, null, ce(s, (g) => f("button", {
|
|
4789
4656
|
key: g.id,
|
|
4790
|
-
class:
|
|
4791
|
-
onClick: (
|
|
4792
|
-
}, S(g.label), 11,
|
|
4657
|
+
class: Tt(["szd-tabs__tab", { "szd-tabs__tab--active": t.value === g.id }]),
|
|
4658
|
+
onClick: (R) => t.value = g.id
|
|
4659
|
+
}, S(g.label), 11, $r)), 64))
|
|
4793
4660
|
])
|
|
4794
4661
|
]),
|
|
4795
|
-
|
|
4796
|
-
t.value === "overview" ? (A(),
|
|
4797
|
-
|
|
4798
|
-
d[15] || (d[15] =
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
d[11] || (d[11] =
|
|
4802
|
-
|
|
4662
|
+
f("main", Fr, [
|
|
4663
|
+
t.value === "overview" ? (A(), M("div", Pr, [
|
|
4664
|
+
f("div", Dr, [
|
|
4665
|
+
d[15] || (d[15] = f("h3", { class: "szd-panel__heading" }, "Why This View?", -1)),
|
|
4666
|
+
f("div", zr, [
|
|
4667
|
+
f("div", Rr, [
|
|
4668
|
+
d[11] || (d[11] = f("span", { class: "szd-kv__key" }, "Filter:", -1)),
|
|
4669
|
+
f("span", Kr, S(z.value.filter), 1)
|
|
4803
4670
|
]),
|
|
4804
|
-
|
|
4805
|
-
d[12] || (d[12] =
|
|
4806
|
-
|
|
4671
|
+
f("div", Ir, [
|
|
4672
|
+
d[12] || (d[12] = f("span", { class: "szd-kv__key" }, "Order:", -1)),
|
|
4673
|
+
f("span", Nr, S(z.value.orderBy), 1)
|
|
4807
4674
|
]),
|
|
4808
|
-
|
|
4809
|
-
d[13] || (d[13] =
|
|
4810
|
-
|
|
4675
|
+
f("div", xr, [
|
|
4676
|
+
d[13] || (d[13] = f("span", { class: "szd-kv__key" }, "Limit:", -1)),
|
|
4677
|
+
f("span", jr, S(z.value.limit), 1)
|
|
4811
4678
|
]),
|
|
4812
|
-
|
|
4813
|
-
d[14] || (d[14] =
|
|
4814
|
-
|
|
4679
|
+
f("div", Ur, [
|
|
4680
|
+
d[14] || (d[14] = f("span", { class: "szd-kv__key" }, "Reason:", -1)),
|
|
4681
|
+
f("span", Qr, S(F.value.reason), 1)
|
|
4815
4682
|
])
|
|
4816
4683
|
])
|
|
4817
4684
|
]),
|
|
4818
|
-
|
|
4819
|
-
d[21] || (d[21] =
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
d[16] || (d[16] =
|
|
4685
|
+
f("div", Lr, [
|
|
4686
|
+
d[21] || (d[21] = f("h3", { class: "szd-panel__heading" }, "Current State", -1)),
|
|
4687
|
+
f("div", Vr, [
|
|
4688
|
+
f("div", Br, [
|
|
4689
|
+
f("div", Gr, S(F.value.optimisticCount ?? "—"), 1),
|
|
4690
|
+
d[16] || (d[16] = f("div", { class: "szd-stat__label" }, "Optimistic", -1))
|
|
4824
4691
|
]),
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
d[17] || (d[17] =
|
|
4692
|
+
f("div", Hr, [
|
|
4693
|
+
f("div", qr, S(F.value.confirmedCount), 1),
|
|
4694
|
+
d[17] || (d[17] = f("div", { class: "szd-stat__label" }, "Confirmed", -1))
|
|
4828
4695
|
]),
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
d[18] || (d[18] =
|
|
4696
|
+
f("div", Jr, [
|
|
4697
|
+
f("div", Wr, S(F.value.groundTruthCount), 1),
|
|
4698
|
+
d[18] || (d[18] = f("div", { class: "szd-stat__label" }, "Ground Truth", -1))
|
|
4832
4699
|
]),
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
d[19] || (d[19] =
|
|
4700
|
+
f("div", Zr, [
|
|
4701
|
+
f("div", Yr, S(F.value.inFlightCount), 1),
|
|
4702
|
+
d[19] || (d[19] = f("div", { class: "szd-stat__label" }, "In-Flight", -1))
|
|
4836
4703
|
])
|
|
4837
4704
|
]),
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
d[20] || (d[20] =
|
|
4841
|
-
|
|
4705
|
+
f("div", Xr, [
|
|
4706
|
+
f("div", en, [
|
|
4707
|
+
d[20] || (d[20] = f("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
|
|
4708
|
+
f("span", tn, S(F.value.lastSync), 1)
|
|
4842
4709
|
])
|
|
4843
4710
|
])
|
|
4844
4711
|
]),
|
|
4845
|
-
ne.value ? (A(),
|
|
4846
|
-
d[22] || (d[22] =
|
|
4847
|
-
|
|
4712
|
+
ne.value ? (A(), M("div", sn, [
|
|
4713
|
+
d[22] || (d[22] = f("h3", { class: "szd-panel__heading" }, "Last Event", -1)),
|
|
4714
|
+
f("button", {
|
|
4848
4715
|
class: "szd-event-preview",
|
|
4849
4716
|
onClick: d[1] || (d[1] = (g) => kt(ne.value))
|
|
4850
4717
|
}, [
|
|
4851
|
-
|
|
4718
|
+
f("span", {
|
|
4852
4719
|
class: "szd-event-preview__badge",
|
|
4853
|
-
style:
|
|
4720
|
+
style: it({ background: xe(ne.value.type) })
|
|
4854
4721
|
}, S(ne.value.type), 5),
|
|
4855
|
-
|
|
4856
|
-
|
|
4722
|
+
f("span", rn, S(vt(ne.value)), 1),
|
|
4723
|
+
f("span", nn, S(Xe(ne.value.ts)), 1)
|
|
4857
4724
|
])
|
|
4858
|
-
])) :
|
|
4859
|
-
])) :
|
|
4860
|
-
t.value === "timeline" ? (A(),
|
|
4861
|
-
|
|
4862
|
-
|
|
4725
|
+
])) : L("", !0)
|
|
4726
|
+
])) : L("", !0),
|
|
4727
|
+
t.value === "timeline" ? (A(), M("div", on, [
|
|
4728
|
+
f("div", an, [
|
|
4729
|
+
f("button", {
|
|
4863
4730
|
class: "szd-btn szd-btn--sm",
|
|
4864
|
-
onClick: d[2] || (d[2] = (g) =>
|
|
4731
|
+
onClick: d[2] || (d[2] = (g) => Et(!0))
|
|
4865
4732
|
}, "All"),
|
|
4866
|
-
|
|
4733
|
+
f("button", {
|
|
4867
4734
|
class: "szd-btn szd-btn--sm",
|
|
4868
|
-
onClick: d[3] || (d[3] = (g) =>
|
|
4735
|
+
onClick: d[3] || (d[3] = (g) => Et(!1))
|
|
4869
4736
|
}, "None"),
|
|
4870
|
-
(A(),
|
|
4737
|
+
(A(), M(W, null, ce(Ne, (g) => f("label", {
|
|
4871
4738
|
key: g.id,
|
|
4872
|
-
class:
|
|
4873
|
-
style:
|
|
4739
|
+
class: Tt(["szd-filter-chip", { "szd-filter-chip--active": y.value[g.id] }]),
|
|
4740
|
+
style: it(y.value[g.id] ? { background: g.color, borderColor: g.color } : {})
|
|
4874
4741
|
}, [
|
|
4875
|
-
|
|
4742
|
+
Ue(f("input", {
|
|
4876
4743
|
type: "checkbox",
|
|
4877
|
-
"onUpdate:modelValue": (
|
|
4744
|
+
"onUpdate:modelValue": (R) => y.value[g.id] = R,
|
|
4878
4745
|
class: "szd-filter-chip__input"
|
|
4879
|
-
}, null, 8,
|
|
4880
|
-
[
|
|
4746
|
+
}, null, 8, ln), [
|
|
4747
|
+
[Mt, y.value[g.id]]
|
|
4881
4748
|
]),
|
|
4882
|
-
|
|
4749
|
+
Qe(" " + S(g.label), 1)
|
|
4883
4750
|
], 6)), 64))
|
|
4884
4751
|
]),
|
|
4885
|
-
|
|
4886
|
-
(A(!0),
|
|
4752
|
+
f("div", cn, [
|
|
4753
|
+
(A(!0), M(W, null, ce(ve.value, (g) => (A(), M("div", {
|
|
4887
4754
|
key: g.id,
|
|
4888
4755
|
class: "szd-timeline__item",
|
|
4889
|
-
onClick: (
|
|
4756
|
+
onClick: (R) => kt(g)
|
|
4890
4757
|
}, [
|
|
4891
|
-
|
|
4892
|
-
|
|
4758
|
+
f("span", un, S(Xe(g.ts)), 1),
|
|
4759
|
+
f("span", {
|
|
4893
4760
|
class: "szd-timeline__badge",
|
|
4894
|
-
style:
|
|
4761
|
+
style: it({ background: xe(g.type) })
|
|
4895
4762
|
}, S(g.type), 5),
|
|
4896
|
-
|
|
4897
|
-
], 8,
|
|
4898
|
-
|
|
4763
|
+
f("span", hn, S(vt(g)), 1)
|
|
4764
|
+
], 8, dn))), 128)),
|
|
4765
|
+
ve.value.length ? L("", !0) : (A(), M("div", fn, " No events match current filters "))
|
|
4899
4766
|
])
|
|
4900
|
-
])) :
|
|
4901
|
-
t.value === "data" ? (A(),
|
|
4902
|
-
d[25] || (d[25] =
|
|
4903
|
-
|
|
4904
|
-
(A(!0),
|
|
4767
|
+
])) : L("", !0),
|
|
4768
|
+
t.value === "data" ? (A(), M("div", pn, [
|
|
4769
|
+
d[25] || (d[25] = f("h3", { class: "szd-panel__heading" }, "Data Pipeline", -1)),
|
|
4770
|
+
f("div", mn, [
|
|
4771
|
+
(A(!0), M(W, null, ce(me.value, (g, R) => (A(), M(W, {
|
|
4905
4772
|
key: g.id
|
|
4906
4773
|
}, [
|
|
4907
|
-
|
|
4774
|
+
f("div", {
|
|
4908
4775
|
class: "szd-pipeline__stage",
|
|
4909
|
-
onClick: (H) =>
|
|
4776
|
+
onClick: (H) => ls(g)
|
|
4910
4777
|
}, [
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
], 8,
|
|
4914
|
-
|
|
4778
|
+
f("div", gn, S(g.label), 1),
|
|
4779
|
+
f("div", _n, S(g.count), 1)
|
|
4780
|
+
], 8, yn),
|
|
4781
|
+
R < me.value.length - 1 ? (A(), M("div", wn, "→")) : L("", !0)
|
|
4915
4782
|
], 64))), 128))
|
|
4916
4783
|
]),
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
d[24] || (d[24] =
|
|
4920
|
-
|
|
4784
|
+
f("div", Cn, [
|
|
4785
|
+
f("div", vn, [
|
|
4786
|
+
d[24] || (d[24] = f("h3", { class: "szd-panel__heading" }, "Instance Preview", -1)),
|
|
4787
|
+
Ue(f("select", {
|
|
4921
4788
|
"onUpdate:modelValue": d[4] || (d[4] = (g) => m.value = g),
|
|
4922
4789
|
class: "szd-select"
|
|
4923
4790
|
}, [
|
|
4924
|
-
d[23] || (d[23] =
|
|
4925
|
-
(A(!0),
|
|
4791
|
+
d[23] || (d[23] = f("option", { value: null }, "Select instance...", -1)),
|
|
4792
|
+
(A(!0), M(W, null, ce(Ze.value, (g) => (A(), M("option", {
|
|
4926
4793
|
key: g,
|
|
4927
4794
|
value: g
|
|
4928
|
-
}, S(g), 9,
|
|
4795
|
+
}, S(g), 9, kn))), 128))
|
|
4929
4796
|
], 512), [
|
|
4930
|
-
[
|
|
4797
|
+
[At, m.value]
|
|
4931
4798
|
])
|
|
4932
4799
|
]),
|
|
4933
|
-
m.value != null ? (A(),
|
|
4934
|
-
(A(!0),
|
|
4800
|
+
m.value != null ? (A(), M("div", bn, [
|
|
4801
|
+
(A(!0), M(W, null, ce(me.value, (g) => (A(), M("div", {
|
|
4935
4802
|
key: g.id,
|
|
4936
4803
|
class: "szd-data-card"
|
|
4937
4804
|
}, [
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
g.pks.includes(m.value) ? (A(),
|
|
4805
|
+
f("div", En, [
|
|
4806
|
+
Qe(S(g.label) + " ", 1),
|
|
4807
|
+
g.pks.includes(m.value) ? (A(), M("span", Sn, "Present")) : (A(), M("span", Tn, "Absent"))
|
|
4941
4808
|
]),
|
|
4942
|
-
|
|
4809
|
+
f("pre", Mn, S(g.pks.includes(m.value) ? JSON.stringify(ye(m.value), null, 2) : "—"), 1)
|
|
4943
4810
|
]))), 128))
|
|
4944
|
-
])) : (A(),
|
|
4811
|
+
])) : (A(), M("div", An, "Select an instance to preview"))
|
|
4945
4812
|
])
|
|
4946
|
-
])) :
|
|
4947
|
-
t.value === "ast" ? (A(),
|
|
4948
|
-
d[27] || (d[27] =
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
d[26] || (d[26] =
|
|
4952
|
-
|
|
4813
|
+
])) : L("", !0),
|
|
4814
|
+
t.value === "ast" ? (A(), M("div", On, [
|
|
4815
|
+
d[27] || (d[27] = f("h3", { class: "szd-panel__heading" }, "Query AST", -1)),
|
|
4816
|
+
f("div", $n, [
|
|
4817
|
+
f("div", Fn, [
|
|
4818
|
+
d[26] || (d[26] = f("span", { class: "szd-kv__key" }, "Semantic Key:", -1)),
|
|
4819
|
+
f("code", Pn, S(E.value || "—"), 1)
|
|
4953
4820
|
])
|
|
4954
4821
|
]),
|
|
4955
|
-
|
|
4956
|
-
])) :
|
|
4822
|
+
f("pre", Dn, S(re.value ? JSON.stringify(re.value, null, 2) : "Select a queryset to view AST"), 1)
|
|
4823
|
+
])) : L("", !0)
|
|
4957
4824
|
]),
|
|
4958
|
-
|
|
4959
|
-
default:
|
|
4960
|
-
p.value ? (A(),
|
|
4961
|
-
|
|
4825
|
+
St(Ot, { name: "szd-slide" }, {
|
|
4826
|
+
default: $t(() => [
|
|
4827
|
+
p.value ? (A(), M("div", zn, [
|
|
4828
|
+
f("div", {
|
|
4962
4829
|
class: "szd-detail__backdrop",
|
|
4963
4830
|
onClick: d[5] || (d[5] = (g) => p.value = !1)
|
|
4964
4831
|
}),
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
d[28] || (d[28] =
|
|
4968
|
-
|
|
4832
|
+
f("div", Rn, [
|
|
4833
|
+
f("div", Kn, [
|
|
4834
|
+
d[28] || (d[28] = f("h3", { class: "szd-detail__title" }, "Debug Settings", -1)),
|
|
4835
|
+
f("button", {
|
|
4969
4836
|
class: "szd-btn",
|
|
4970
4837
|
onClick: d[6] || (d[6] = (g) => p.value = !1)
|
|
4971
4838
|
}, "Close")
|
|
4972
4839
|
]),
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
d[30] || (d[30] =
|
|
4976
|
-
|
|
4840
|
+
f("div", In, [
|
|
4841
|
+
f("div", Nn, [
|
|
4842
|
+
d[30] || (d[30] = f("label", { class: "szd-settings-label" }, "Queryset", -1)),
|
|
4843
|
+
Ue(f("select", {
|
|
4977
4844
|
"onUpdate:modelValue": d[7] || (d[7] = (g) => r.value = g),
|
|
4978
4845
|
class: "szd-select szd-select--full"
|
|
4979
4846
|
}, [
|
|
4980
|
-
d[29] || (d[29] =
|
|
4981
|
-
(A(!0),
|
|
4847
|
+
d[29] || (d[29] = f("option", { value: "" }, "Select queryset...", -1)),
|
|
4848
|
+
(A(!0), M(W, null, ce(k.value, (g) => (A(), M("option", {
|
|
4982
4849
|
key: g.semanticKey,
|
|
4983
4850
|
value: g.semanticKey
|
|
4984
|
-
}, S(g.modelName || "?") + " · " + S(g.semanticKey), 9,
|
|
4851
|
+
}, S(g.modelName || "?") + " · " + S(g.semanticKey), 9, xn))), 128))
|
|
4985
4852
|
], 512), [
|
|
4986
|
-
[
|
|
4853
|
+
[At, r.value]
|
|
4987
4854
|
])
|
|
4988
4855
|
]),
|
|
4989
|
-
|
|
4990
|
-
d[31] || (d[31] =
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4856
|
+
E.value ? (A(), M("div", jn, [
|
|
4857
|
+
d[31] || (d[31] = f("label", { class: "szd-settings-label" }, "Semantic Key", -1)),
|
|
4858
|
+
f("div", Un, [
|
|
4859
|
+
f("code", Qn, S(E.value), 1),
|
|
4860
|
+
f("button", {
|
|
4994
4861
|
class: "szd-btn szd-btn--sm",
|
|
4995
|
-
onClick:
|
|
4862
|
+
onClick: is
|
|
4996
4863
|
}, "Copy")
|
|
4997
4864
|
])
|
|
4998
|
-
])) :
|
|
4999
|
-
|
|
5000
|
-
d[32] || (d[32] =
|
|
5001
|
-
|
|
5002
|
-
|
|
4865
|
+
])) : L("", !0),
|
|
4866
|
+
f("div", Ln, [
|
|
4867
|
+
d[32] || (d[32] = f("label", { class: "szd-settings-label" }, "Actions", -1)),
|
|
4868
|
+
f("div", Vn, [
|
|
4869
|
+
f("button", {
|
|
5003
4870
|
class: "szd-btn",
|
|
5004
|
-
onClick:
|
|
4871
|
+
onClick: as,
|
|
5005
4872
|
disabled: !N.value || c.value
|
|
5006
|
-
}, S(c.value ? "Syncing..." : "Sync Now"), 9,
|
|
5007
|
-
|
|
4873
|
+
}, S(c.value ? "Syncing..." : "Sync Now"), 9, Bn),
|
|
4874
|
+
f("button", {
|
|
5008
4875
|
class: "szd-btn",
|
|
5009
|
-
onClick:
|
|
4876
|
+
onClick: os
|
|
5010
4877
|
}, "Clear Events")
|
|
5011
4878
|
])
|
|
5012
4879
|
]),
|
|
5013
|
-
|
|
5014
|
-
d[34] || (d[34] =
|
|
5015
|
-
|
|
5016
|
-
|
|
4880
|
+
f("div", Gn, [
|
|
4881
|
+
d[34] || (d[34] = f("label", { class: "szd-settings-label" }, "Options", -1)),
|
|
4882
|
+
f("label", Hn, [
|
|
4883
|
+
Ue(f("input", {
|
|
5017
4884
|
type: "checkbox",
|
|
5018
4885
|
"onUpdate:modelValue": d[8] || (d[8] = (g) => i.value = g)
|
|
5019
4886
|
}, null, 512), [
|
|
5020
|
-
[
|
|
4887
|
+
[Mt, i.value]
|
|
5021
4888
|
]),
|
|
5022
|
-
d[33] || (d[33] =
|
|
4889
|
+
d[33] || (d[33] = Qe(" Live updates ", -1))
|
|
5023
4890
|
])
|
|
5024
4891
|
]),
|
|
5025
|
-
|
|
5026
|
-
d[40] || (d[40] =
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
d[35] || (d[35] =
|
|
5030
|
-
|
|
4892
|
+
E.value ? (A(), M("div", qn, [
|
|
4893
|
+
d[40] || (d[40] = f("label", { class: "szd-settings-label" }, "Current State", -1)),
|
|
4894
|
+
f("div", Jn, [
|
|
4895
|
+
f("div", Wn, [
|
|
4896
|
+
d[35] || (d[35] = f("span", { class: "szd-kv__key" }, "Model:", -1)),
|
|
4897
|
+
f("span", Zn, S(F.value.modelName || "—"), 1)
|
|
5031
4898
|
]),
|
|
5032
|
-
|
|
5033
|
-
d[36] || (d[36] =
|
|
5034
|
-
|
|
4899
|
+
f("div", Yn, [
|
|
4900
|
+
d[36] || (d[36] = f("span", { class: "szd-kv__key" }, "Source:", -1)),
|
|
4901
|
+
f("span", Xn, S(F.value.source), 1)
|
|
5035
4902
|
]),
|
|
5036
|
-
|
|
5037
|
-
d[37] || (d[37] =
|
|
5038
|
-
|
|
4903
|
+
f("div", eo, [
|
|
4904
|
+
d[37] || (d[37] = f("span", { class: "szd-kv__key" }, "Syncing:", -1)),
|
|
4905
|
+
f("span", to, S(F.value.isSyncing ? "Yes" : "No"), 1)
|
|
5039
4906
|
]),
|
|
5040
|
-
|
|
5041
|
-
d[38] || (d[38] =
|
|
5042
|
-
|
|
4907
|
+
f("div", so, [
|
|
4908
|
+
d[38] || (d[38] = f("span", { class: "szd-kv__key" }, "Operations:", -1)),
|
|
4909
|
+
f("span", ro, S(F.value.opsCount), 1)
|
|
5043
4910
|
]),
|
|
5044
|
-
|
|
5045
|
-
d[39] || (d[39] =
|
|
5046
|
-
|
|
4911
|
+
f("div", no, [
|
|
4912
|
+
d[39] || (d[39] = f("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
|
|
4913
|
+
f("span", oo, S(F.value.lastSync), 1)
|
|
5047
4914
|
])
|
|
5048
4915
|
])
|
|
5049
|
-
])) :
|
|
4916
|
+
])) : L("", !0)
|
|
5050
4917
|
])
|
|
5051
4918
|
])
|
|
5052
|
-
])) :
|
|
4919
|
+
])) : L("", !0)
|
|
5053
4920
|
]),
|
|
5054
4921
|
_: 1
|
|
5055
4922
|
}),
|
|
5056
|
-
|
|
5057
|
-
default:
|
|
5058
|
-
|
|
5059
|
-
|
|
4923
|
+
St(Ot, { name: "szd-slide" }, {
|
|
4924
|
+
default: $t(() => [
|
|
4925
|
+
h.value ? (A(), M("div", io, [
|
|
4926
|
+
f("div", {
|
|
5060
4927
|
class: "szd-detail__backdrop",
|
|
5061
|
-
onClick:
|
|
4928
|
+
onClick: bt
|
|
5062
4929
|
}),
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
4930
|
+
f("div", ao, [
|
|
4931
|
+
f("div", lo, [
|
|
4932
|
+
f("h3", co, S(h.value.type === "entry" ? "Event Detail" : "Snapshot: " + h.value.data.label), 1),
|
|
4933
|
+
f("button", {
|
|
5067
4934
|
class: "szd-btn",
|
|
5068
|
-
onClick:
|
|
4935
|
+
onClick: bt
|
|
5069
4936
|
}, "Close")
|
|
5070
4937
|
]),
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
(A(!0),
|
|
5075
|
-
key:
|
|
4938
|
+
f("div", uo, [
|
|
4939
|
+
h.value.type === "entry" ? (A(), M(W, { key: 0 }, [
|
|
4940
|
+
f("div", ho, [
|
|
4941
|
+
(A(!0), M(W, null, ce(ns(h.value.data), (g, R) => (A(), M("div", {
|
|
4942
|
+
key: R,
|
|
5076
4943
|
class: "szd-kv__row"
|
|
5077
4944
|
}, [
|
|
5078
|
-
|
|
5079
|
-
|
|
4945
|
+
f("span", fo, S(R) + ":", 1),
|
|
4946
|
+
f("span", po, S(g ?? "—"), 1)
|
|
5080
4947
|
]))), 128))
|
|
5081
4948
|
]),
|
|
5082
|
-
d[41] || (d[41] =
|
|
5083
|
-
|
|
5084
|
-
], 64)) : (A(),
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
d[42] || (d[42] =
|
|
5088
|
-
|
|
4949
|
+
d[41] || (d[41] = f("h4", { style: { margin: "16px 0 8px" } }, "Raw JSON", -1)),
|
|
4950
|
+
f("pre", mo, S(JSON.stringify(h.value.data, null, 2)), 1)
|
|
4951
|
+
], 64)) : (A(), M(W, { key: 1 }, [
|
|
4952
|
+
f("div", yo, [
|
|
4953
|
+
f("div", go, [
|
|
4954
|
+
d[42] || (d[42] = f("span", { class: "szd-kv__key" }, "Total Count:", -1)),
|
|
4955
|
+
f("span", _o, S(h.value.data.count), 1)
|
|
5089
4956
|
]),
|
|
5090
|
-
|
|
5091
|
-
d[43] || (d[43] =
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
4957
|
+
f("div", wo, [
|
|
4958
|
+
d[43] || (d[43] = f("span", { class: "szd-kv__key" }, "Showing:", -1)),
|
|
4959
|
+
f("span", Co, [
|
|
4960
|
+
Qe(S(Re.value.length) + " items ", 1),
|
|
4961
|
+
Ye.value ? (A(), M("span", vo, "(limited to first 100)")) : L("", !0)
|
|
5095
4962
|
])
|
|
5096
4963
|
])
|
|
5097
4964
|
]),
|
|
5098
|
-
d[44] || (d[44] =
|
|
5099
|
-
|
|
4965
|
+
d[44] || (d[44] = f("h4", { style: { margin: "0 0 8px" } }, "Data", -1)),
|
|
4966
|
+
f("pre", ko, S(JSON.stringify(Re.value, null, 2)), 1)
|
|
5100
4967
|
], 64))
|
|
5101
4968
|
])
|
|
5102
4969
|
])
|
|
5103
|
-
])) :
|
|
4970
|
+
])) : L("", !0)
|
|
5104
4971
|
]),
|
|
5105
4972
|
_: 1
|
|
5106
4973
|
})
|
|
5107
4974
|
]));
|
|
5108
4975
|
}
|
|
5109
|
-
},
|
|
4976
|
+
}, jo = /* @__PURE__ */ _r(bo, [["__scopeId", "data-v-cf94aafd"]]);
|
|
5110
4977
|
export {
|
|
5111
|
-
|
|
4978
|
+
jo as default
|
|
5112
4979
|
};
|