@dcupl/common 2.0.0-beta.22 → 2.0.0-beta.24
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/esm/index.d.ts +1 -0
- package/dist/esm/index.js +577 -486
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/query-builder.d.ts +69 -7
- package/dist/esm/script-compiler.d.ts +11 -0
- package/dist/esm/script.controller.d.ts +5 -0
- package/dist/esm/types/dcupl.types.d.ts +18 -0
- package/dist/esm/types/quality.types.d.ts +1 -1
- package/dist/esm/types/query.types.d.ts +11 -11
- package/dist/node/index.cjs +2 -2
- package/dist/node/index.cjs.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { cloneDeep as v, get as I, every as
|
|
2
|
-
function D(
|
|
3
|
-
const e =
|
|
1
|
+
import { cloneDeep as v, get as I, every as _, findIndex as $, size as V, isEqual as H, differenceBy as O, isEqualWith as k, isMatch as G, find as J } from "lodash-es";
|
|
2
|
+
function D(i) {
|
|
3
|
+
const e = E(i);
|
|
4
4
|
return Z(e);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
if (typeof
|
|
8
|
-
return String(
|
|
9
|
-
if (Array.isArray(
|
|
10
|
-
return "[" +
|
|
11
|
-
const e = Object.keys(
|
|
6
|
+
function E(i) {
|
|
7
|
+
if (typeof i != "object" || i === null)
|
|
8
|
+
return String(i);
|
|
9
|
+
if (Array.isArray(i))
|
|
10
|
+
return "[" + i.map(E).join(",") + "]";
|
|
11
|
+
const e = Object.keys(i).sort();
|
|
12
12
|
let t = "{";
|
|
13
13
|
for (let r = 0; r < e.length; r++) {
|
|
14
14
|
const s = e[r];
|
|
15
|
-
t += s + ":" +
|
|
15
|
+
t += s + ":" + E(i[s]), r < e.length - 1 && (t += ",");
|
|
16
16
|
}
|
|
17
17
|
return t += "}", t;
|
|
18
18
|
}
|
|
19
|
-
function Z(
|
|
19
|
+
function Z(i) {
|
|
20
20
|
let e = 0;
|
|
21
|
-
for (let t = 0; t <
|
|
22
|
-
const r =
|
|
21
|
+
for (let t = 0; t < i.length; t++) {
|
|
22
|
+
const r = i.charCodeAt(t);
|
|
23
23
|
e = (e << 5) - e + r, e |= 0;
|
|
24
24
|
}
|
|
25
25
|
return e.toString(16);
|
|
26
26
|
}
|
|
27
27
|
const b = {
|
|
28
28
|
now: () => typeof performance < "u" && performance.now ? performance.now() : (/* @__PURE__ */ new Date()).getTime(),
|
|
29
|
-
mark: (
|
|
30
|
-
typeof performance < "u" && performance.mark && performance.mark(
|
|
29
|
+
mark: (i) => {
|
|
30
|
+
typeof performance < "u" && performance.mark && performance.mark(i);
|
|
31
31
|
},
|
|
32
|
-
measure: (
|
|
33
|
-
typeof performance < "u" && performance.measure && performance.measure(
|
|
32
|
+
measure: (i, e, t) => {
|
|
33
|
+
typeof performance < "u" && performance.measure && performance.measure(i, e, t);
|
|
34
34
|
},
|
|
35
|
-
getEntriesByName(
|
|
35
|
+
getEntriesByName(i) {
|
|
36
36
|
if (typeof performance < "u" && performance.getEntriesByName)
|
|
37
|
-
return performance.getEntriesByName(
|
|
37
|
+
return performance.getEntriesByName(i);
|
|
38
38
|
},
|
|
39
|
-
getEntriesByType(
|
|
39
|
+
getEntriesByType(i) {
|
|
40
40
|
if (typeof performance < "u" && performance.getEntriesByType)
|
|
41
|
-
return performance.getEntriesByType(
|
|
41
|
+
return performance.getEntriesByType(i);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
class Fe {
|
|
@@ -69,7 +69,7 @@ class Fe {
|
|
|
69
69
|
const t = this.getKey(e.name, e.context), r = this.data.get(this.getKey(e.start, e.context)), s = this.data.get(this.getKey(e.end, e.context));
|
|
70
70
|
if (!r || !s)
|
|
71
71
|
return;
|
|
72
|
-
const
|
|
72
|
+
const n = s.value - r.value, o = Math.round(n * 100) / 100, a = this.data.get(t);
|
|
73
73
|
if (a && e.sum) {
|
|
74
74
|
const u = a.value + o, f = {
|
|
75
75
|
...a,
|
|
@@ -118,7 +118,7 @@ class Fe {
|
|
|
118
118
|
return e + "_" + r;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
let X = class
|
|
121
|
+
let X = class z {
|
|
122
122
|
nodes;
|
|
123
123
|
edges;
|
|
124
124
|
nodeKinds = /* @__PURE__ */ new Map();
|
|
@@ -198,9 +198,9 @@ let X = class j {
|
|
|
198
198
|
if (t.has(s))
|
|
199
199
|
return !0;
|
|
200
200
|
t.add(s);
|
|
201
|
-
const
|
|
202
|
-
if (
|
|
203
|
-
for (let o of
|
|
201
|
+
const n = this.edges.get(s);
|
|
202
|
+
if (n) {
|
|
203
|
+
for (let o of n)
|
|
204
204
|
if (r(o))
|
|
205
205
|
return !0;
|
|
206
206
|
}
|
|
@@ -217,36 +217,36 @@ let X = class j {
|
|
|
217
217
|
* @returns {hasCycle: boolean, path?: string[]} - hasCycle is true if a cycle exists, path contains the cycle nodes
|
|
218
218
|
*/
|
|
219
219
|
validateNoCycles() {
|
|
220
|
-
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), r = [], s = (
|
|
221
|
-
if (e.has(
|
|
220
|
+
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), r = [], s = (n) => {
|
|
221
|
+
if (e.has(n))
|
|
222
222
|
return null;
|
|
223
|
-
if (t.has(
|
|
224
|
-
const a = r.indexOf(
|
|
225
|
-
return r.slice(a).concat([
|
|
223
|
+
if (t.has(n)) {
|
|
224
|
+
const a = r.indexOf(n);
|
|
225
|
+
return r.slice(a).concat([n]);
|
|
226
226
|
}
|
|
227
|
-
t.add(
|
|
228
|
-
const o = this.edges.get(
|
|
227
|
+
t.add(n), r.push(n);
|
|
228
|
+
const o = this.edges.get(n);
|
|
229
229
|
if (o)
|
|
230
230
|
for (let a of o) {
|
|
231
231
|
const c = s(a);
|
|
232
232
|
if (c)
|
|
233
233
|
return c;
|
|
234
234
|
}
|
|
235
|
-
return r.pop(), t.delete(
|
|
235
|
+
return r.pop(), t.delete(n), e.add(n), null;
|
|
236
236
|
};
|
|
237
|
-
for (let
|
|
238
|
-
const o = s(
|
|
237
|
+
for (let n of this.nodes) {
|
|
238
|
+
const o = s(n);
|
|
239
239
|
if (o)
|
|
240
240
|
return { hasCycle: !0, path: o };
|
|
241
241
|
}
|
|
242
242
|
return { hasCycle: !1 };
|
|
243
243
|
}
|
|
244
244
|
order(e) {
|
|
245
|
-
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = [],
|
|
245
|
+
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = [], n = e?.allowCycles ?? !1, o = (a) => {
|
|
246
246
|
if (t.has(a))
|
|
247
247
|
return;
|
|
248
248
|
if (r.has(a)) {
|
|
249
|
-
if (
|
|
249
|
+
if (n)
|
|
250
250
|
return;
|
|
251
251
|
throw new Error("Graph has a cycle.");
|
|
252
252
|
}
|
|
@@ -331,20 +331,20 @@ let X = class j {
|
|
|
331
331
|
for (const a of o) t.set(a, (t.get(a) || 0) + 1);
|
|
332
332
|
const r = [];
|
|
333
333
|
let s = Array.from(this.nodes).filter((o) => (t.get(o) || 0) === 0);
|
|
334
|
-
const
|
|
334
|
+
const n = /* @__PURE__ */ new Set();
|
|
335
335
|
for (; s.length > 0; ) {
|
|
336
336
|
const o = s.slice();
|
|
337
337
|
r.push(o), s = [];
|
|
338
338
|
for (const a of o) {
|
|
339
|
-
if (
|
|
340
|
-
|
|
339
|
+
if (n.has(a)) continue;
|
|
340
|
+
n.add(a);
|
|
341
341
|
const c = this.edges.get(a);
|
|
342
342
|
if (c)
|
|
343
343
|
for (const u of c)
|
|
344
344
|
t.set(u, (t.get(u) || 0) - 1), (t.get(u) || 0) === 0 && s.push(u);
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
if (
|
|
347
|
+
if (n.size !== this.nodes.size)
|
|
348
348
|
throw new Error("Graph has a cycle.");
|
|
349
349
|
if (e?.filterKinds && e.filterKinds.length > 0) {
|
|
350
350
|
const o = new Set(e.filterKinds);
|
|
@@ -362,7 +362,7 @@ let X = class j {
|
|
|
362
362
|
* - 'both': union of upstream and downstream
|
|
363
363
|
*/
|
|
364
364
|
getImpactedNodes(e, t = "downstream", r) {
|
|
365
|
-
const s = new Set(e),
|
|
365
|
+
const s = new Set(e), n = (u) => !r || r.length === 0 || r.includes(this.nodeKinds.get(u) ?? void 0), o = () => {
|
|
366
366
|
const u = /* @__PURE__ */ new Set(), f = Array.from(s);
|
|
367
367
|
for (; f.length; ) {
|
|
368
368
|
const d = f.shift();
|
|
@@ -381,7 +381,7 @@ let X = class j {
|
|
|
381
381
|
return u;
|
|
382
382
|
};
|
|
383
383
|
let c;
|
|
384
|
-
return t === "both" ? c = /* @__PURE__ */ new Set([...o(), ...a()]) : t === "upstream" ? c = a() : c = o(), Array.from(c).filter(
|
|
384
|
+
return t === "both" ? c = /* @__PURE__ */ new Set([...o(), ...a()]) : t === "upstream" ? c = a() : c = o(), Array.from(c).filter(n);
|
|
385
385
|
}
|
|
386
386
|
toJSON() {
|
|
387
387
|
const e = Array.from(this.nodes).map((r) => ({
|
|
@@ -392,7 +392,7 @@ let X = class j {
|
|
|
392
392
|
return { nodes: e, edges: t };
|
|
393
393
|
}
|
|
394
394
|
static fromJSON(e) {
|
|
395
|
-
const t = new
|
|
395
|
+
const t = new z();
|
|
396
396
|
for (const r of e.nodes)
|
|
397
397
|
t.addNode(r.name, { kind: r.kind, meta: r.meta });
|
|
398
398
|
for (const r of e.edges)
|
|
@@ -400,15 +400,15 @@ let X = class j {
|
|
|
400
400
|
return t;
|
|
401
401
|
}
|
|
402
402
|
diff(e) {
|
|
403
|
-
const t = new Set(this.getNodes()), r = new Set(e.getNodes()), s = Array.from(r).filter((d) => !t.has(d)),
|
|
403
|
+
const t = new Set(this.getNodes()), r = new Set(e.getNodes()), s = Array.from(r).filter((d) => !t.has(d)), n = Array.from(t).filter((d) => !r.has(d)), o = new Set(this.getAllEdges().map((d) => d.join("→"))), a = new Set(e.getAllEdges().map((d) => d.join("→"))), c = Array.from(a).filter((d) => !o.has(d)).map((d) => d.split("→")), u = Array.from(o).filter((d) => !a.has(d)).map((d) => d.split("→")), f = [];
|
|
404
404
|
for (const d of /* @__PURE__ */ new Set([...t, ...r])) {
|
|
405
405
|
const l = this.nodeKinds.get(d), h = e.nodeKinds.get(d);
|
|
406
406
|
l !== h && f.push({ name: d, from: l, to: h });
|
|
407
407
|
}
|
|
408
|
-
return { addedNodes: s, removedNodes:
|
|
408
|
+
return { addedNodes: s, removedNodes: n, addedEdges: c, removedEdges: u, kindChanges: f };
|
|
409
409
|
}
|
|
410
410
|
};
|
|
411
|
-
class
|
|
411
|
+
class Pe {
|
|
412
412
|
graph;
|
|
413
413
|
nodeIndex;
|
|
414
414
|
constructor() {
|
|
@@ -454,8 +454,8 @@ class Ge {
|
|
|
454
454
|
* @returns Array of all impacted attribute nodes (including the changed ones)
|
|
455
455
|
*/
|
|
456
456
|
getImpactedAttributes(e) {
|
|
457
|
-
const t = e.map((a) => this.getNodeId(a.modelKey, a.attributeKey)), s = this.graph.getImpactedNodes(t, "downstream").map((a) => this.nodeIndex.get(a)).filter((a) => a !== void 0),
|
|
458
|
-
return
|
|
457
|
+
const t = e.map((a) => this.getNodeId(a.modelKey, a.attributeKey)), s = this.graph.getImpactedNodes(t, "downstream").map((a) => this.nodeIndex.get(a)).filter((a) => a !== void 0), n = [...e, ...s], o = /* @__PURE__ */ new Set();
|
|
458
|
+
return n.filter((a) => {
|
|
459
459
|
const c = this.getNodeId(a.modelKey, a.attributeKey);
|
|
460
460
|
return o.has(c) ? !1 : (o.add(c), !0);
|
|
461
461
|
});
|
|
@@ -468,11 +468,11 @@ class Ge {
|
|
|
468
468
|
* @returns Map<modelKey, Map<processingStep, Set<attributeKeys>>>
|
|
469
469
|
*/
|
|
470
470
|
getProcessingOrder(e) {
|
|
471
|
-
const t = /* @__PURE__ */ new Map(), r = [...e].sort((s,
|
|
471
|
+
const t = /* @__PURE__ */ new Map(), r = [...e].sort((s, n) => s.processingStep - n.processingStep);
|
|
472
472
|
for (const s of r) {
|
|
473
|
-
const { modelKey:
|
|
474
|
-
t.has(
|
|
475
|
-
const c = t.get(
|
|
473
|
+
const { modelKey: n, attributeKey: o, processingStep: a } = s;
|
|
474
|
+
t.has(n) || t.set(n, /* @__PURE__ */ new Map());
|
|
475
|
+
const c = t.get(n);
|
|
476
476
|
c.has(a) || c.set(a, /* @__PURE__ */ new Set()), c.get(a).add(o);
|
|
477
477
|
}
|
|
478
478
|
return t;
|
|
@@ -528,10 +528,10 @@ class Ge {
|
|
|
528
528
|
const t = (r, s = /* @__PURE__ */ new Set()) => {
|
|
529
529
|
if (s.has(r)) return 0;
|
|
530
530
|
s.add(r);
|
|
531
|
-
const
|
|
532
|
-
if (
|
|
531
|
+
const n = this.graph.getDependencies(r);
|
|
532
|
+
if (n.length === 0) return 1;
|
|
533
533
|
let o = 0;
|
|
534
|
-
for (const a of
|
|
534
|
+
for (const a of n) {
|
|
535
535
|
const c = t(a, new Set(s));
|
|
536
536
|
o = Math.max(o, c);
|
|
537
537
|
}
|
|
@@ -554,9 +554,9 @@ class Ge {
|
|
|
554
554
|
validateCompleteness(e) {
|
|
555
555
|
const t = [];
|
|
556
556
|
for (const [r, s] of e)
|
|
557
|
-
for (const
|
|
558
|
-
const o = this.getNodeId(r,
|
|
559
|
-
this.hasNode(o) || t.push({ modelKey: r, attributeKey:
|
|
557
|
+
for (const n of s) {
|
|
558
|
+
const o = this.getNodeId(r, n);
|
|
559
|
+
this.hasNode(o) || t.push({ modelKey: r, attributeKey: n });
|
|
560
560
|
}
|
|
561
561
|
return {
|
|
562
562
|
isComplete: t.length === 0,
|
|
@@ -678,8 +678,8 @@ class g {
|
|
|
678
678
|
stack: e.error.stack
|
|
679
679
|
}), JSON.stringify(o);
|
|
680
680
|
}
|
|
681
|
-
const t = new Date(e.timestamp).toISOString().substring(11, 23), r = e.prefix ? `[${e.prefix}]` : "", s = this.getLevelIcon(e.level),
|
|
682
|
-
return `${t} ${s} ${r} ${e.message}${
|
|
681
|
+
const t = new Date(e.timestamp).toISOString().substring(11, 23), r = e.prefix ? `[${e.prefix}]` : "", s = this.getLevelIcon(e.level), n = e.context ? ` ${JSON.stringify(e.context)}` : "";
|
|
682
|
+
return `${t} ${s} ${r} ${e.message}${n}`.trim();
|
|
683
683
|
}
|
|
684
684
|
getLevelIcon(e) {
|
|
685
685
|
switch (e) {
|
|
@@ -698,7 +698,7 @@ class g {
|
|
|
698
698
|
log(e, t, r, s) {
|
|
699
699
|
if (!this.shouldLog(e))
|
|
700
700
|
return;
|
|
701
|
-
const
|
|
701
|
+
const n = {
|
|
702
702
|
level: e,
|
|
703
703
|
message: t,
|
|
704
704
|
timestamp: Date.now(),
|
|
@@ -707,10 +707,10 @@ class g {
|
|
|
707
707
|
error: s
|
|
708
708
|
};
|
|
709
709
|
if (this.config.onLog) {
|
|
710
|
-
this.config.onLog(
|
|
710
|
+
this.config.onLog(n);
|
|
711
711
|
return;
|
|
712
712
|
}
|
|
713
|
-
const o = this.formatMessage(
|
|
713
|
+
const o = this.formatMessage(n);
|
|
714
714
|
if (typeof console < "u")
|
|
715
715
|
switch (e) {
|
|
716
716
|
case "error":
|
|
@@ -730,8 +730,8 @@ class g {
|
|
|
730
730
|
* Log an error message
|
|
731
731
|
*/
|
|
732
732
|
error(e, t, r) {
|
|
733
|
-
const s = t instanceof Error ? t : void 0,
|
|
734
|
-
this.log("error", e,
|
|
733
|
+
const s = t instanceof Error ? t : void 0, n = t instanceof Error ? r : t;
|
|
734
|
+
this.log("error", e, n, s);
|
|
735
735
|
}
|
|
736
736
|
/**
|
|
737
737
|
* Log and track an error (integrates with QualityController)
|
|
@@ -819,8 +819,8 @@ class _e {
|
|
|
819
819
|
}
|
|
820
820
|
set(e, t, r, s) {
|
|
821
821
|
if (!this.enabled) return;
|
|
822
|
-
const
|
|
823
|
-
this.cache.set(
|
|
822
|
+
const n = this.getCacheName(e, t);
|
|
823
|
+
this.cache.set(n, r), s ? this.cacheDependencies.set(n, s) : this.log.debug(
|
|
824
824
|
`Cache entry '${e}' stored without dependencies. This prevents granular invalidation and may cause stale data.`
|
|
825
825
|
);
|
|
826
826
|
}
|
|
@@ -838,21 +838,21 @@ class _e {
|
|
|
838
838
|
if (!this.enabled) return;
|
|
839
839
|
const t = [];
|
|
840
840
|
for (const [r, s] of this.cacheDependencies) {
|
|
841
|
-
let
|
|
841
|
+
let n = !1;
|
|
842
842
|
for (const [o, a] of e) {
|
|
843
843
|
if (s.models.has(o))
|
|
844
844
|
if (s.modelAttributes.has(o)) {
|
|
845
845
|
const c = s.modelAttributes.get(o);
|
|
846
846
|
for (const u of a)
|
|
847
847
|
if (c.has(u)) {
|
|
848
|
-
|
|
848
|
+
n = !0;
|
|
849
849
|
break;
|
|
850
850
|
}
|
|
851
851
|
} else
|
|
852
|
-
|
|
853
|
-
if (
|
|
852
|
+
n = !0;
|
|
853
|
+
if (n) break;
|
|
854
854
|
}
|
|
855
|
-
|
|
855
|
+
n && t.push(r);
|
|
856
856
|
}
|
|
857
857
|
for (const r of t)
|
|
858
858
|
this.cache.delete(r), this.cacheDependencies.delete(r);
|
|
@@ -864,9 +864,9 @@ class _e {
|
|
|
864
864
|
invalidateByModels(e) {
|
|
865
865
|
if (!this.enabled) return;
|
|
866
866
|
const t = new Set(e), r = [];
|
|
867
|
-
for (const [s,
|
|
867
|
+
for (const [s, n] of this.cacheDependencies)
|
|
868
868
|
for (const o of t)
|
|
869
|
-
if (
|
|
869
|
+
if (n.models.has(o)) {
|
|
870
870
|
r.push(s);
|
|
871
871
|
break;
|
|
872
872
|
}
|
|
@@ -940,45 +940,45 @@ class _e {
|
|
|
940
940
|
};
|
|
941
941
|
}
|
|
942
942
|
}
|
|
943
|
-
const
|
|
944
|
-
if (!(typeof
|
|
945
|
-
return { pattern:
|
|
946
|
-
}, ze = (
|
|
943
|
+
const j = (i, e = "") => {
|
|
944
|
+
if (!(typeof i != "string" || !i.startsWith("/") || !i.endsWith("/")))
|
|
945
|
+
return { pattern: i.slice(1, -1), flags: e };
|
|
946
|
+
}, ze = (i, e = "") => `${i}#${e}`, je = (i) => `${i.gt}_${i.gte}_${i.lt}_${i.lte}_${i.eq}_${i.ne}`, Be = (i) => `${i.gt}_${i.gte}_${i.lt}_${i.lte}_${i.eq}_${i.ne}`, Le = (i, e) => {
|
|
947
947
|
const t = typeof e == "function" ? e : (r) => r[e];
|
|
948
948
|
return [
|
|
949
|
-
...
|
|
950
|
-
const
|
|
951
|
-
return r.has(
|
|
949
|
+
...i.reduce((r, s) => {
|
|
950
|
+
const n = s == null ? s : t(s);
|
|
951
|
+
return r.has(n) || r.set(n, s), r;
|
|
952
952
|
}, /* @__PURE__ */ new Map()).values()
|
|
953
953
|
];
|
|
954
|
-
},
|
|
954
|
+
}, Ue = (i, e) => i.reduce(function(t, r) {
|
|
955
955
|
const s = typeof e == "function" ? e(r) : r[e];
|
|
956
956
|
return Object.prototype.hasOwnProperty.call(t, s) || (t[s] = []), t[s].push(r), t;
|
|
957
957
|
}, {});
|
|
958
|
-
function ee(
|
|
958
|
+
function ee(i = 10) {
|
|
959
959
|
let e = "";
|
|
960
960
|
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
961
|
-
for (let r = 0; r <
|
|
961
|
+
for (let r = 0; r < i; r++) e += t.charAt(Math.floor(Math.random() * t.length));
|
|
962
962
|
return e;
|
|
963
963
|
}
|
|
964
|
-
const
|
|
964
|
+
const We = (i) => i.replace(/\/+$/, ""), te = (i) => typeof i != "string" ? "" : i.replace(/[[\]{}()*+?.,\\^$|#]/g, "\\$&"), Ve = (i) => typeof i != "string" ? "" : i.replace(/\\([[\]{}()*+?.,\\^$|#])/g, "$1"), He = (i, e) => {
|
|
965
965
|
try {
|
|
966
|
-
return re(
|
|
966
|
+
return re(i, e) >= 0;
|
|
967
967
|
} catch {
|
|
968
968
|
return !1;
|
|
969
969
|
}
|
|
970
|
-
}, re = (
|
|
971
|
-
if (!T(
|
|
972
|
-
throw new Error(`Invalid version format: v1="${
|
|
973
|
-
const t =
|
|
970
|
+
}, re = (i, e) => {
|
|
971
|
+
if (!T(i) || !T(e))
|
|
972
|
+
throw new Error(`Invalid version format: v1="${i}", v2="${e}". Expected format: "x.y.z"`);
|
|
973
|
+
const t = i.split(".").map(Number), r = e.split(".").map(Number);
|
|
974
974
|
for (let s = 0; s < 3; s++) {
|
|
975
|
-
const
|
|
976
|
-
if (
|
|
977
|
-
if (
|
|
975
|
+
const n = t[s] || 0, o = r[s] || 0;
|
|
976
|
+
if (n > o) return 1;
|
|
977
|
+
if (n < o) return -1;
|
|
978
978
|
}
|
|
979
979
|
return 0;
|
|
980
|
-
}, T = (
|
|
981
|
-
class
|
|
980
|
+
}, T = (i) => /^\d+(\.\d+){0,2}$/.test(i);
|
|
981
|
+
class Je {
|
|
982
982
|
key;
|
|
983
983
|
parentCd;
|
|
984
984
|
dcuplInitOptions;
|
|
@@ -1014,10 +1014,10 @@ class He {
|
|
|
1014
1014
|
};
|
|
1015
1015
|
}
|
|
1016
1016
|
}
|
|
1017
|
-
const B = (
|
|
1017
|
+
const B = (i, e) => e ? typeof structuredClone < "u" ? structuredClone(i) : v(i) : i, q = (i, e, t, r, s, n) => {
|
|
1018
1018
|
try {
|
|
1019
|
-
const o = !!e.dcuplInitOptions.performance?.clone?.enabled && !!t.cloneResult, a = B(
|
|
1020
|
-
if (t.scope === "list" && (t.listKey =
|
|
1019
|
+
const o = !!e.dcuplInitOptions.performance?.clone?.enabled && !!t.cloneResult, a = B(n, o);
|
|
1020
|
+
if (t.scope === "list" && (t.listKey = i.cdRef?.key || i.key, t.modelKey = i.model?.key || i.modelKey), t.type === "list_created" && t.args[0].listKey.startsWith("__global_list__") || t.listKey?.startsWith("__global_list__"))
|
|
1021
1021
|
return a;
|
|
1022
1022
|
const c = b.now(), u = c - r, f = Math.round(u * 1e3) / 1e3;
|
|
1023
1023
|
t.duration = f, t.start = r, t.end = c;
|
|
@@ -1035,12 +1035,12 @@ const B = (n, e) => e ? typeof structuredClone < "u" ? structuredClone(n) : v(n)
|
|
|
1035
1035
|
detail: d
|
|
1036
1036
|
}), a;
|
|
1037
1037
|
} catch {
|
|
1038
|
-
return
|
|
1038
|
+
return n;
|
|
1039
1039
|
}
|
|
1040
|
-
},
|
|
1041
|
-
const
|
|
1040
|
+
}, Ze = (i) => (t, r, s) => {
|
|
1041
|
+
const n = s.value;
|
|
1042
1042
|
return s.value = function(...o) {
|
|
1043
|
-
const a = b.now(), c = this.cdRef, u = B(
|
|
1043
|
+
const a = b.now(), c = this.cdRef, u = B(i, !0);
|
|
1044
1044
|
u.key || (c.increaseCounter(), u.key = c.getCounter());
|
|
1045
1045
|
const f = ee();
|
|
1046
1046
|
c.analyticsController.mark({
|
|
@@ -1049,32 +1049,32 @@ const B = (n, e) => e ? typeof structuredClone < "u" ? structuredClone(n) : v(n)
|
|
|
1049
1049
|
});
|
|
1050
1050
|
const d = this.model?.key;
|
|
1051
1051
|
!u.originCdRefKey && c.key && (u.originCdRefKey = c.key), d && (u.modelKey = d);
|
|
1052
|
-
const l =
|
|
1053
|
-
return u.method = r, u.args = o, l && typeof l == "object" && "then" in l ? l.then((h) =>
|
|
1052
|
+
const l = n.apply(this, o);
|
|
1053
|
+
return u.method = r, u.args = o, l && typeof l == "object" && "then" in l ? l.then((h) => q(this, c, u, a, f, h)) : q(this, c, u, a, f, l);
|
|
1054
1054
|
}, s;
|
|
1055
1055
|
};
|
|
1056
|
-
function
|
|
1056
|
+
function Xe(i, e, t, r) {
|
|
1057
1057
|
t.max || (t.max = 20);
|
|
1058
|
-
const s = [],
|
|
1058
|
+
const s = [], n = t.transform ? r.transformValue(t.value, t.transform) : t.value;
|
|
1059
1059
|
for (const [o, a] of e.entries()) {
|
|
1060
|
-
const c = Array.from(a).some((f) =>
|
|
1060
|
+
const c = Array.from(a).some((f) => i.has(f)), u = t.transform ? r.transformValue(o, t.transform) : o;
|
|
1061
1061
|
if (!(t.excludeUndefineds && typeof o > "u") && !(t.excludeNulls && o === null)) {
|
|
1062
|
-
if (c && (
|
|
1062
|
+
if (c && (n === "" || n === "//")) {
|
|
1063
1063
|
const f = {
|
|
1064
1064
|
value: o,
|
|
1065
1065
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1066
1066
|
};
|
|
1067
1067
|
s.push(f);
|
|
1068
|
-
} else if (c &&
|
|
1069
|
-
if (r.queryFind(u,
|
|
1068
|
+
} else if (c && j(n)) {
|
|
1069
|
+
if (r.queryFind(u, n, "some", t.regexFlags)) {
|
|
1070
1070
|
const f = {
|
|
1071
1071
|
value: o,
|
|
1072
1072
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1073
1073
|
};
|
|
1074
1074
|
s.push(f);
|
|
1075
1075
|
}
|
|
1076
|
-
} else if (c && typeof
|
|
1077
|
-
const f = String(u ?? ""), d =
|
|
1076
|
+
} else if (c && typeof n == "string") {
|
|
1077
|
+
const f = String(u ?? ""), d = n;
|
|
1078
1078
|
if (f.toLowerCase().startsWith(d.toLowerCase())) {
|
|
1079
1079
|
const l = {
|
|
1080
1080
|
value: o,
|
|
@@ -1082,7 +1082,7 @@ function Ze(n, e, t, r) {
|
|
|
1082
1082
|
};
|
|
1083
1083
|
s.push(l);
|
|
1084
1084
|
}
|
|
1085
|
-
} else if (c && r.queryFind(u,
|
|
1085
|
+
} else if (c && r.queryFind(u, n, "some")) {
|
|
1086
1086
|
const f = {
|
|
1087
1087
|
value: o,
|
|
1088
1088
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
@@ -1095,11 +1095,11 @@ function Ze(n, e, t, r) {
|
|
|
1095
1095
|
}
|
|
1096
1096
|
return s;
|
|
1097
1097
|
}
|
|
1098
|
-
function se(
|
|
1099
|
-
return
|
|
1098
|
+
function se(i) {
|
|
1099
|
+
return i instanceof Date;
|
|
1100
1100
|
}
|
|
1101
|
-
function ne(
|
|
1102
|
-
return
|
|
1101
|
+
function ne(i) {
|
|
1102
|
+
return i instanceof Date && !isNaN(i.getTime());
|
|
1103
1103
|
}
|
|
1104
1104
|
const ie = {
|
|
1105
1105
|
yyyy: { type: "year", pattern: "yyyy", regex: "(\\d{4})" },
|
|
@@ -1116,19 +1116,19 @@ const ie = {
|
|
|
1116
1116
|
s: { type: "second", pattern: "s", regex: "(\\d{1,2})" },
|
|
1117
1117
|
SSS: { type: "millisecond", pattern: "SSS", regex: "(\\d{3})" }
|
|
1118
1118
|
};
|
|
1119
|
-
function oe(
|
|
1119
|
+
function oe(i) {
|
|
1120
1120
|
let e = "^";
|
|
1121
1121
|
const t = [];
|
|
1122
|
-
let r =
|
|
1123
|
-
const s = Object.entries(ie).sort((
|
|
1122
|
+
let r = i;
|
|
1123
|
+
const s = Object.entries(ie).sort((n, o) => o[0].length - n[0].length);
|
|
1124
1124
|
for (; r.length > 0; ) {
|
|
1125
|
-
let
|
|
1125
|
+
let n = !1;
|
|
1126
1126
|
for (const [o, a] of s)
|
|
1127
1127
|
if (r.startsWith(o)) {
|
|
1128
|
-
e += a.regex, t.push({ type: a.type, pattern: o }), r = r.slice(o.length),
|
|
1128
|
+
e += a.regex, t.push({ type: a.type, pattern: o }), r = r.slice(o.length), n = !0;
|
|
1129
1129
|
break;
|
|
1130
1130
|
}
|
|
1131
|
-
if (!
|
|
1131
|
+
if (!n) {
|
|
1132
1132
|
const o = r[0];
|
|
1133
1133
|
if (!o)
|
|
1134
1134
|
break;
|
|
@@ -1137,7 +1137,7 @@ function oe(n) {
|
|
|
1137
1137
|
}
|
|
1138
1138
|
return e += "$", { regex: new RegExp(e), tokenOrder: t };
|
|
1139
1139
|
}
|
|
1140
|
-
function ae(
|
|
1140
|
+
function ae(i, e) {
|
|
1141
1141
|
const t = {
|
|
1142
1142
|
year: 1970,
|
|
1143
1143
|
month: 1,
|
|
@@ -1148,51 +1148,51 @@ function ae(n, e) {
|
|
|
1148
1148
|
millisecond: 0
|
|
1149
1149
|
};
|
|
1150
1150
|
for (let r = 0; r < e.length; r++) {
|
|
1151
|
-
const s =
|
|
1151
|
+
const s = i[r + 1];
|
|
1152
1152
|
if (!s)
|
|
1153
1153
|
continue;
|
|
1154
|
-
const
|
|
1155
|
-
o && (o.type === "year" && o.pattern === "yy" ? t.year = 2e3 +
|
|
1154
|
+
const n = parseInt(s, 10), o = e[r];
|
|
1155
|
+
o && (o.type === "year" && o.pattern === "yy" ? t.year = 2e3 + n : t[o.type] = n);
|
|
1156
1156
|
}
|
|
1157
1157
|
return t;
|
|
1158
1158
|
}
|
|
1159
|
-
function ce(
|
|
1160
|
-
if (
|
|
1159
|
+
function ce(i) {
|
|
1160
|
+
if (i.month < 1 || i.month > 12)
|
|
1161
1161
|
return /* @__PURE__ */ new Date(NaN);
|
|
1162
|
-
if (
|
|
1162
|
+
if (i.day < 1 || i.day > 31)
|
|
1163
1163
|
return /* @__PURE__ */ new Date(NaN);
|
|
1164
|
-
if (
|
|
1164
|
+
if (i.hour < 0 || i.hour > 23)
|
|
1165
1165
|
return /* @__PURE__ */ new Date(NaN);
|
|
1166
|
-
if (
|
|
1166
|
+
if (i.minute < 0 || i.minute > 59)
|
|
1167
1167
|
return /* @__PURE__ */ new Date(NaN);
|
|
1168
|
-
if (
|
|
1168
|
+
if (i.second < 0 || i.second > 59)
|
|
1169
1169
|
return /* @__PURE__ */ new Date(NaN);
|
|
1170
|
-
if (
|
|
1170
|
+
if (i.millisecond < 0 || i.millisecond > 999)
|
|
1171
1171
|
return /* @__PURE__ */ new Date(NaN);
|
|
1172
1172
|
const e = new Date(
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1173
|
+
i.year,
|
|
1174
|
+
i.month - 1,
|
|
1175
|
+
i.day,
|
|
1176
|
+
i.hour,
|
|
1177
|
+
i.minute,
|
|
1178
|
+
i.second,
|
|
1179
|
+
i.millisecond
|
|
1180
1180
|
);
|
|
1181
|
-
return ne(e) ? e.getFullYear() !==
|
|
1181
|
+
return ne(e) ? e.getFullYear() !== i.year || e.getMonth() !== i.month - 1 || e.getDate() !== i.day ? /* @__PURE__ */ new Date(NaN) : e : /* @__PURE__ */ new Date(NaN);
|
|
1182
1182
|
}
|
|
1183
|
-
function
|
|
1184
|
-
if (
|
|
1185
|
-
const a = Number(
|
|
1183
|
+
function Ye(i, e, t) {
|
|
1184
|
+
if (i = i.trim(), e === "t") {
|
|
1185
|
+
const a = Number(i);
|
|
1186
1186
|
return isNaN(a) ? /* @__PURE__ */ new Date(NaN) : new Date(a * 1e3);
|
|
1187
1187
|
}
|
|
1188
1188
|
if (e === "T") {
|
|
1189
|
-
const a = Number(
|
|
1189
|
+
const a = Number(i);
|
|
1190
1190
|
return isNaN(a) ? /* @__PURE__ */ new Date(NaN) : new Date(a);
|
|
1191
1191
|
}
|
|
1192
|
-
const { regex: r, tokenOrder: s } = oe(e),
|
|
1193
|
-
if (!
|
|
1192
|
+
const { regex: r, tokenOrder: s } = oe(e), n = i.match(r);
|
|
1193
|
+
if (!n)
|
|
1194
1194
|
return /* @__PURE__ */ new Date(NaN);
|
|
1195
|
-
const o = ae(
|
|
1195
|
+
const o = ae(n, s);
|
|
1196
1196
|
return ce(o);
|
|
1197
1197
|
}
|
|
1198
1198
|
class ue {
|
|
@@ -1248,9 +1248,9 @@ class fe {
|
|
|
1248
1248
|
}
|
|
1249
1249
|
hasCycle(e) {
|
|
1250
1250
|
if (e.length === 0) return !1;
|
|
1251
|
-
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = (
|
|
1252
|
-
t.add(
|
|
1253
|
-
const o = this.graph.get(
|
|
1251
|
+
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = (n) => {
|
|
1252
|
+
t.add(n), r.add(n);
|
|
1253
|
+
const o = this.graph.get(n);
|
|
1254
1254
|
if (o) {
|
|
1255
1255
|
for (const a of o)
|
|
1256
1256
|
if (t.has(a)) {
|
|
@@ -1259,14 +1259,14 @@ class fe {
|
|
|
1259
1259
|
} else if (s(a))
|
|
1260
1260
|
return !0;
|
|
1261
1261
|
}
|
|
1262
|
-
return r.delete(
|
|
1262
|
+
return r.delete(n), !1;
|
|
1263
1263
|
};
|
|
1264
|
-
for (let
|
|
1265
|
-
const o = e[
|
|
1264
|
+
for (let n = 0; n < e.length - 1; n++) {
|
|
1265
|
+
const o = e[n], a = e[n + 1];
|
|
1266
1266
|
o && a && this.addDependency(o, a);
|
|
1267
1267
|
}
|
|
1268
|
-
for (const
|
|
1269
|
-
if (!t.has(
|
|
1268
|
+
for (const n of e)
|
|
1269
|
+
if (!t.has(n) && s(n))
|
|
1270
1270
|
return !0;
|
|
1271
1271
|
return !1;
|
|
1272
1272
|
}
|
|
@@ -1305,11 +1305,11 @@ class de {
|
|
|
1305
1305
|
return this.cacheHits++, this.parseCache.get(e);
|
|
1306
1306
|
this.cacheMisses++;
|
|
1307
1307
|
let t, r;
|
|
1308
|
-
const s = e.includes("."),
|
|
1308
|
+
const s = e.includes("."), n = e.includes("["), o = s || n;
|
|
1309
1309
|
if (o) {
|
|
1310
1310
|
r = e.split(/[.[]/)[0];
|
|
1311
1311
|
const c = e.indexOf("."), u = e.indexOf("[");
|
|
1312
|
-
if (
|
|
1312
|
+
if (n && (c === -1 || u < c)) {
|
|
1313
1313
|
const d = e.indexOf("]");
|
|
1314
1314
|
if (d > -1) {
|
|
1315
1315
|
const l = e.indexOf(".", d + 1);
|
|
@@ -1372,8 +1372,8 @@ class de {
|
|
|
1372
1372
|
if (!e || e.trim().length === 0)
|
|
1373
1373
|
return r.push("Attribute path cannot be empty"), { valid: !1, errors: r };
|
|
1374
1374
|
(e.startsWith(".") || e.endsWith(".")) && r.push(`Invalid path: Leading or trailing dots are not allowed: ${e}`), e.includes("..") && r.push(`Invalid path: Consecutive dots are not allowed: ${e}`);
|
|
1375
|
-
const s = (e.match(/\[/g) || []).length,
|
|
1376
|
-
s !==
|
|
1375
|
+
const s = (e.match(/\[/g) || []).length, n = (e.match(/]/g) || []).length;
|
|
1376
|
+
s !== n && r.push(`Invalid bracket notation: Mismatched brackets in ${e}`), e.includes("[]") && r.push(`Invalid bracket notation: Empty brackets not allowed: ${e}`);
|
|
1377
1377
|
const o = /\[([^\]]+)\]/g;
|
|
1378
1378
|
let a;
|
|
1379
1379
|
for (; (a = o.exec(e)) !== null; ) {
|
|
@@ -1443,9 +1443,9 @@ class de {
|
|
|
1443
1443
|
}
|
|
1444
1444
|
}
|
|
1445
1445
|
const m = new de();
|
|
1446
|
-
function w(
|
|
1446
|
+
function w(i, e) {
|
|
1447
1447
|
if (e.includes("[*]")) {
|
|
1448
|
-
const
|
|
1448
|
+
const n = e.indexOf("[*]"), o = e.substring(0, n), a = e.substring(n + 3), c = o ? I(i, o) : i;
|
|
1449
1449
|
if (!Array.isArray(c)) return [];
|
|
1450
1450
|
const u = [];
|
|
1451
1451
|
for (const f of c)
|
|
@@ -1453,80 +1453,80 @@ function w(n, e) {
|
|
|
1453
1453
|
return u;
|
|
1454
1454
|
}
|
|
1455
1455
|
const t = e.split(".");
|
|
1456
|
-
let r = [
|
|
1457
|
-
for (const
|
|
1456
|
+
let r = [i];
|
|
1457
|
+
for (const n of t) {
|
|
1458
1458
|
const o = [];
|
|
1459
1459
|
for (const a of r)
|
|
1460
1460
|
if (a != null)
|
|
1461
1461
|
if (Array.isArray(a))
|
|
1462
1462
|
for (const c of a) {
|
|
1463
1463
|
if (c == null) continue;
|
|
1464
|
-
const u = c[
|
|
1464
|
+
const u = c[n];
|
|
1465
1465
|
u !== void 0 && o.push(u);
|
|
1466
1466
|
}
|
|
1467
1467
|
else {
|
|
1468
|
-
const c = a[
|
|
1468
|
+
const c = a[n];
|
|
1469
1469
|
c !== void 0 && o.push(c);
|
|
1470
1470
|
}
|
|
1471
1471
|
if (r = o, r.length === 0) return [];
|
|
1472
1472
|
}
|
|
1473
1473
|
const s = [];
|
|
1474
|
-
for (const
|
|
1475
|
-
if (Array.isArray(
|
|
1476
|
-
for (const o of
|
|
1477
|
-
else
|
|
1474
|
+
for (const n of r)
|
|
1475
|
+
if (Array.isArray(n))
|
|
1476
|
+
for (const o of n) o !== void 0 && s.push(o);
|
|
1477
|
+
else n !== void 0 && s.push(n);
|
|
1478
1478
|
return s;
|
|
1479
1479
|
}
|
|
1480
|
-
function
|
|
1480
|
+
function Q(i) {
|
|
1481
1481
|
let e = 0;
|
|
1482
|
-
for (let t of
|
|
1482
|
+
for (let t of i) {
|
|
1483
1483
|
const r = t.toString().split(".")[1];
|
|
1484
1484
|
r && (e = Math.max(e, r.length));
|
|
1485
1485
|
}
|
|
1486
1486
|
return Math.pow(10, e);
|
|
1487
1487
|
}
|
|
1488
|
-
function
|
|
1489
|
-
return (
|
|
1488
|
+
function F(i, e, t) {
|
|
1489
|
+
return (i * t + e * t) / t;
|
|
1490
1490
|
}
|
|
1491
|
-
function le(
|
|
1492
|
-
return
|
|
1491
|
+
function le(i, e, t) {
|
|
1492
|
+
return i * t / (e * t);
|
|
1493
1493
|
}
|
|
1494
|
-
const C = (
|
|
1494
|
+
const C = (i, e, t, r) => {
|
|
1495
1495
|
if (!r)
|
|
1496
1496
|
throw new Error("Attribute not found");
|
|
1497
1497
|
const s = {
|
|
1498
1498
|
attribute: r,
|
|
1499
|
-
types:
|
|
1499
|
+
types: i.types
|
|
1500
1500
|
};
|
|
1501
|
-
let
|
|
1502
|
-
(s.types.includes("sum") || s.types.includes("avg")) && (
|
|
1501
|
+
let n;
|
|
1502
|
+
(s.types.includes("sum") || s.types.includes("avg")) && (n = ye(r, e));
|
|
1503
1503
|
let o;
|
|
1504
|
-
return (s.types.includes("min") || s.types.includes("max")) && (o = pe(r, e)),
|
|
1505
|
-
a === "sum" ? s.sum =
|
|
1504
|
+
return (s.types.includes("min") || s.types.includes("max")) && (o = pe(r, e)), i.types.forEach((a) => {
|
|
1505
|
+
a === "sum" ? s.sum = n?.sum : a === "avg" ? s.avg = n?.average : a === "count" ? s.count = he(r, e) : a === "min" ? s.min = o && o[0] : a === "max" ? s.max = o && o[1] : a === "distinct" ? s.distinct = me(i, e, t) : a === "group" && (s.group = ge(i, e));
|
|
1506
1506
|
}), s;
|
|
1507
|
-
}, he = (
|
|
1508
|
-
const r = m.parse(
|
|
1507
|
+
}, he = (i, e) => {
|
|
1508
|
+
const r = m.parse(i).isDeepQuery;
|
|
1509
1509
|
let s = 0;
|
|
1510
|
-
for (const
|
|
1511
|
-
if (
|
|
1510
|
+
for (const n of e.values())
|
|
1511
|
+
if (n)
|
|
1512
1512
|
if (r)
|
|
1513
|
-
s += w(
|
|
1513
|
+
s += w(n, i).filter((o) => o != null).length;
|
|
1514
1514
|
else {
|
|
1515
|
-
const o = i
|
|
1515
|
+
const o = n[i];
|
|
1516
1516
|
if (o == null) continue;
|
|
1517
1517
|
Array.isArray(o) ? s += o.filter((a) => a != null).length : s++;
|
|
1518
1518
|
}
|
|
1519
1519
|
return s;
|
|
1520
|
-
}, pe = (
|
|
1520
|
+
}, pe = (i, e) => {
|
|
1521
1521
|
let t, r;
|
|
1522
|
-
const
|
|
1522
|
+
const n = m.parse(i).isDeepQuery;
|
|
1523
1523
|
for (const o of e.values()) {
|
|
1524
1524
|
if (!o) continue;
|
|
1525
1525
|
let a;
|
|
1526
|
-
if (
|
|
1527
|
-
a = w(o,
|
|
1526
|
+
if (n)
|
|
1527
|
+
a = w(o, i);
|
|
1528
1528
|
else {
|
|
1529
|
-
const c = o[
|
|
1529
|
+
const c = o[i];
|
|
1530
1530
|
c === void 0 ? a = [] : Array.isArray(c) ? a = c.filter((u) => u !== void 0) : a = [c];
|
|
1531
1531
|
}
|
|
1532
1532
|
for (const c of a)
|
|
@@ -1534,9 +1534,9 @@ const C = (n, e, t, r) => {
|
|
|
1534
1534
|
}
|
|
1535
1535
|
if (!(t === void 0 || r === void 0))
|
|
1536
1536
|
return [t, r];
|
|
1537
|
-
}, ge = (
|
|
1537
|
+
}, ge = (i, e) => {
|
|
1538
1538
|
const t = [];
|
|
1539
|
-
|
|
1539
|
+
i.groupOptions?.groups?.forEach((o) => {
|
|
1540
1540
|
t.push({
|
|
1541
1541
|
option: o,
|
|
1542
1542
|
count: 0,
|
|
@@ -1547,49 +1547,49 @@ const C = (n, e, t, r) => {
|
|
|
1547
1547
|
option: { value: ["$dcupl_not_found"] },
|
|
1548
1548
|
count: 0,
|
|
1549
1549
|
keys: []
|
|
1550
|
-
},
|
|
1550
|
+
}, n = m.parse(i.attribute).isDeepQuery;
|
|
1551
1551
|
for (const o of e.values()) {
|
|
1552
1552
|
let a;
|
|
1553
|
-
|
|
1553
|
+
n ? a = w(o, i.attribute) : a = [o[i.attribute]];
|
|
1554
1554
|
let c = !1;
|
|
1555
1555
|
for (const u of a)
|
|
1556
1556
|
for (const f of t)
|
|
1557
1557
|
(typeof f.option.value < "u" && f.option.value.includes(u) || typeof f.option.from < "u" && f.option.from < u && typeof f.option.to < "u" && f.option.to > u) && (f.keys.includes(o.key) || (f.count++, f.keys.push(o.key)), c = !0);
|
|
1558
|
-
!c &&
|
|
1558
|
+
!c && i?.groupOptions?.calculateNotFound && (r.count++, r.keys.push(o.key));
|
|
1559
1559
|
}
|
|
1560
|
-
return
|
|
1561
|
-
}, ye = (
|
|
1560
|
+
return i?.groupOptions?.calculateNotFound && t.push(r), t;
|
|
1561
|
+
}, ye = (i, e) => {
|
|
1562
1562
|
let t = 0, r = 0;
|
|
1563
|
-
const
|
|
1563
|
+
const n = m.parse(i).isDeepQuery;
|
|
1564
1564
|
for (const a of e.values()) {
|
|
1565
1565
|
if (!a) continue;
|
|
1566
1566
|
let c;
|
|
1567
|
-
if (
|
|
1568
|
-
c = w(a,
|
|
1567
|
+
if (n)
|
|
1568
|
+
c = w(a, i);
|
|
1569
1569
|
else {
|
|
1570
|
-
const u = a[
|
|
1570
|
+
const u = a[i];
|
|
1571
1571
|
u === void 0 ? c = [] : Array.isArray(u) ? c = u : c = [u];
|
|
1572
1572
|
}
|
|
1573
1573
|
for (const u of c)
|
|
1574
1574
|
if (Array.isArray(u))
|
|
1575
1575
|
for (const f of u)
|
|
1576
|
-
typeof f == "number" && (t =
|
|
1577
|
-
else typeof u == "number" && (t =
|
|
1576
|
+
typeof f == "number" && (t = F(t, f, Q([t, f])), r++);
|
|
1577
|
+
else typeof u == "number" && (t = F(t, u, Q([t, u])), r++);
|
|
1578
1578
|
}
|
|
1579
1579
|
return r === 0 ? void 0 : {
|
|
1580
|
-
average: le(t, r,
|
|
1580
|
+
average: le(t, r, Q([t, r])),
|
|
1581
1581
|
count: r,
|
|
1582
1582
|
sum: t
|
|
1583
1583
|
};
|
|
1584
|
-
}, me = (
|
|
1584
|
+
}, me = (i, e, t) => {
|
|
1585
1585
|
const r = [];
|
|
1586
|
-
for (const [s,
|
|
1587
|
-
if (!(
|
|
1586
|
+
for (const [s, n] of t)
|
|
1587
|
+
if (!(i.excludeUndefineds && typeof s > "u") && Array.from(n).find((o) => e.has(o))) {
|
|
1588
1588
|
const o = {
|
|
1589
1589
|
value: s,
|
|
1590
|
-
count:
|
|
1590
|
+
count: n.size
|
|
1591
1591
|
};
|
|
1592
|
-
if (
|
|
1592
|
+
if (i.distinctOptions?.skipKeys || (o.keys = Array.from(n)), r.push(o), i.distinctOptions?.limit && r.length >= i.distinctOptions.limit)
|
|
1593
1593
|
break;
|
|
1594
1594
|
}
|
|
1595
1595
|
return r;
|
|
@@ -1655,6 +1655,57 @@ class L {
|
|
|
1655
1655
|
getQueryGroup(e) {
|
|
1656
1656
|
return this.currentQuery.queries.find((t) => this.isQueryGroup(t) && t.groupKey === e);
|
|
1657
1657
|
}
|
|
1658
|
+
/**
|
|
1659
|
+
* Find the group with the given `groupKey` at any nesting depth (#294).
|
|
1660
|
+
*
|
|
1661
|
+
* Unlike {@link getQueryGroup}, which only looks at the top level, this also finds a
|
|
1662
|
+
* keyed group that sits inside a keyless wrapper group — the shape
|
|
1663
|
+
* `apply({ groupType: 'and', queries: [{ groupKey: 'plan', ... }] }, { mode: 'set' })`
|
|
1664
|
+
* produces. Groups on one level are checked before their children, so a top-level
|
|
1665
|
+
* match wins over a nested one; otherwise the first match in query order wins
|
|
1666
|
+
* (groupKeys are expected to be unique).
|
|
1667
|
+
*
|
|
1668
|
+
* @param groupKey - Key of the group to find
|
|
1669
|
+
* @param relevantQuery - Query to search (defaults to the current query)
|
|
1670
|
+
* @returns The matching group, or undefined
|
|
1671
|
+
*/
|
|
1672
|
+
findQueryGroup(e, t) {
|
|
1673
|
+
const r = this.locateQueryGroup(e, (t ?? this.currentQuery).queries);
|
|
1674
|
+
return r ? this.groupAtPath(r) : void 0;
|
|
1675
|
+
}
|
|
1676
|
+
/**
|
|
1677
|
+
* Path from the root `queries` array down to a group: each step names the array that
|
|
1678
|
+
* holds a node and the node's index in it; the last step is the group itself.
|
|
1679
|
+
*/
|
|
1680
|
+
locateQueryGroup(e, t) {
|
|
1681
|
+
const r = t.findIndex((s) => this.isQueryGroup(s) && s.groupKey === e);
|
|
1682
|
+
if (r > -1)
|
|
1683
|
+
return [{ queries: t, idx: r }];
|
|
1684
|
+
for (const [s, n] of t.entries())
|
|
1685
|
+
if (this.isQueryGroup(n)) {
|
|
1686
|
+
const o = this.locateQueryGroup(e, n.queries);
|
|
1687
|
+
if (o)
|
|
1688
|
+
return [{ queries: t, idx: s }, ...o];
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
groupAtPath(e) {
|
|
1692
|
+
const t = e[e.length - 1];
|
|
1693
|
+
return t.queries[t.idx];
|
|
1694
|
+
}
|
|
1695
|
+
/**
|
|
1696
|
+
* Walk a path upwards from its last group and splice every group that has no
|
|
1697
|
+
* queries left, stopping at the first non-empty one. Mirrors the existing
|
|
1698
|
+
* "remove the group when its queries are empty" behaviour for nested wrappers, so
|
|
1699
|
+
* removing the only group inside a keyless wrapper also removes the wrapper.
|
|
1700
|
+
*/
|
|
1701
|
+
pruneEmptyGroups(e) {
|
|
1702
|
+
for (let t = e.length - 1; t >= 0; t--) {
|
|
1703
|
+
const { queries: r, idx: s } = e[t];
|
|
1704
|
+
if (r[s].queries.length > 0)
|
|
1705
|
+
break;
|
|
1706
|
+
r.splice(s, 1);
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1658
1709
|
getQuery() {
|
|
1659
1710
|
return v(this.currentQuery);
|
|
1660
1711
|
}
|
|
@@ -1672,7 +1723,7 @@ class L {
|
|
|
1672
1723
|
}
|
|
1673
1724
|
validate(e) {
|
|
1674
1725
|
const t = e.queries.map((s) => this.validateQuery(s));
|
|
1675
|
-
return { valid:
|
|
1726
|
+
return { valid: _(t, (s) => s.valid), errors: t.map((s) => s.errors).flat() };
|
|
1676
1727
|
}
|
|
1677
1728
|
applyOptions(e, t = "update") {
|
|
1678
1729
|
return t === "set" ? (this.currentQuery.count = e.count, this.currentQuery.start = e.start, this.currentQuery.sort = e.sort, this.currentQuery.projection = e.projection) : (typeof e?.sort < "u" && (this.currentQuery.sort = e.sort), typeof e?.count < "u" && (this.currentQuery.count = e.count), typeof e?.start < "u" && (this.currentQuery.start = e?.start), typeof e?.projection < "u" && (this.currentQuery.projection = e?.projection)), this.getQuery();
|
|
@@ -1692,8 +1743,20 @@ class L {
|
|
|
1692
1743
|
* - {@link replaceQuery} - Replace complete query
|
|
1693
1744
|
*
|
|
1694
1745
|
* @param queryToApply - Query, condition, or array to apply
|
|
1695
|
-
* @param options - Mode: 'add' (default) or 'set'
|
|
1696
|
-
*
|
|
1746
|
+
* @param options - Mode: 'add' (default) or 'set'. `set` works per group, not per query:
|
|
1747
|
+
* - Root group (`groupKey: 'root'`): replaces the whole query — all groups plus
|
|
1748
|
+
* `count`/`start`/`sort`/`projection` (the only input that does).
|
|
1749
|
+
* - Keyed group, or an array of groups: each group replaces the group with the same
|
|
1750
|
+
* `groupKey`; every other group is kept. Same as {@link setGroup}.
|
|
1751
|
+
* - Condition: replaces the conditions of the group keyed by its attribute.
|
|
1752
|
+
*
|
|
1753
|
+
* A group without `groupKey` is not the root, even if it carries a `queries` array:
|
|
1754
|
+
* `apply({ groupType: 'and', queries: [...] }, { mode: 'set' })` stores it as a keyless
|
|
1755
|
+
* wrapper group that replaces the first keyless top-level group, and the keyed groups
|
|
1756
|
+
* inside it stay nested there. {@link removeQuery} and `fn.facets` still find them by
|
|
1757
|
+
* `groupKey` at any depth (#294). To replace the whole query, pass `groupKey: 'root'`
|
|
1758
|
+
* or use {@link replaceQuery}. In 'add' mode a group without `groupKey` is always
|
|
1759
|
+
* appended as a new group, never merged into another.
|
|
1697
1760
|
* @param relevantQuery - Target query (defaults to current)
|
|
1698
1761
|
* @returns Updated query
|
|
1699
1762
|
*/
|
|
@@ -1705,11 +1768,11 @@ class L {
|
|
|
1705
1768
|
e.groupType && (r.groupType = e.groupType), t?.mode === "set" ? r.queries = e.queries : r.queries = [...r.queries, ...e.queries], this.applyOptions(e, "set");
|
|
1706
1769
|
else if (this.isQuery(e)) {
|
|
1707
1770
|
const s = r.queries.findIndex(
|
|
1708
|
-
(
|
|
1771
|
+
(n) => this.isQueryGroup(n) && n.groupKey === e.attribute
|
|
1709
1772
|
);
|
|
1710
1773
|
if (s > -1) {
|
|
1711
|
-
const
|
|
1712
|
-
t?.mode === "set" ?
|
|
1774
|
+
const n = r.queries[s];
|
|
1775
|
+
t?.mode === "set" ? n.queries = [e] : n.queries.push(e);
|
|
1713
1776
|
} else
|
|
1714
1777
|
r.queries.push({
|
|
1715
1778
|
groupKey: e.attribute,
|
|
@@ -1717,12 +1780,12 @@ class L {
|
|
|
1717
1780
|
queries: [e]
|
|
1718
1781
|
});
|
|
1719
1782
|
} else if (this.isQueryGroup(e)) {
|
|
1720
|
-
const
|
|
1783
|
+
const n = e.groupKey === void 0 && t?.mode !== "set" ? -1 : r.queries.findIndex(
|
|
1721
1784
|
(o) => this.isQueryGroup(o) && o.groupKey === e.groupKey
|
|
1722
1785
|
);
|
|
1723
|
-
if (
|
|
1724
|
-
const o = r.queries[
|
|
1725
|
-
e.groupType && (o.groupType = e.groupType), t?.mode === "set" ? r.queries[
|
|
1786
|
+
if (n > -1) {
|
|
1787
|
+
const o = r.queries[n];
|
|
1788
|
+
e.groupType && (o.groupType = e.groupType), t?.mode === "set" ? r.queries[n] = e : o.queries = [...o.queries, ...e.queries];
|
|
1726
1789
|
} else
|
|
1727
1790
|
r.queries.push({
|
|
1728
1791
|
groupKey: e.groupKey,
|
|
@@ -1745,33 +1808,39 @@ class L {
|
|
|
1745
1808
|
/**
|
|
1746
1809
|
* Remove a specific query or query group.
|
|
1747
1810
|
*
|
|
1811
|
+
* - A condition (`attribute` set) is removed from the group keyed by its attribute.
|
|
1812
|
+
* - A group with `groupKey` but no `queries` is removed entirely.
|
|
1813
|
+
* - A group with `groupKey` and `queries` has those conditions removed from it.
|
|
1814
|
+
*
|
|
1815
|
+
* The target group is looked up by `groupKey` at any nesting depth (see
|
|
1816
|
+
* {@link findQueryGroup}), so a keyed group inside a keyless wrapper group is found
|
|
1817
|
+
* too (#294). A group left without queries is removed, and so is every wrapper
|
|
1818
|
+
* group that becomes empty as a result.
|
|
1819
|
+
*
|
|
1748
1820
|
* @param queryToRemove - Query or group to remove (partial match)
|
|
1749
1821
|
* @param relevantQuery - Target query (defaults to current)
|
|
1750
1822
|
* @returns Updated query
|
|
1751
1823
|
*/
|
|
1752
1824
|
removeQuery(e, t) {
|
|
1753
1825
|
if (t || (t = this.currentQuery), this.isQuery(e)) {
|
|
1754
|
-
const r = t.queries
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
const s = t.queries[r], i = $(s.queries, e);
|
|
1759
|
-
i > -1 && s.queries.splice(i, 1), s.queries.length === 0 && t.queries.splice(r, 1);
|
|
1826
|
+
const r = this.locateQueryGroup(e.attribute, t.queries);
|
|
1827
|
+
if (r) {
|
|
1828
|
+
const s = this.groupAtPath(r), n = $(s.queries, e);
|
|
1829
|
+
n > -1 && s.queries.splice(n, 1), this.pruneEmptyGroups(r);
|
|
1760
1830
|
}
|
|
1761
1831
|
} else if (this.isQueryGroup(e)) {
|
|
1762
|
-
const r = t.queries
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
else {
|
|
1769
|
-
const s = t.queries[r];
|
|
1770
|
-
for (const i of e.queries) {
|
|
1771
|
-
const o = $(s.queries, i);
|
|
1832
|
+
const r = this.locateQueryGroup(e.groupKey, t.queries);
|
|
1833
|
+
if (r)
|
|
1834
|
+
if (e.queries) {
|
|
1835
|
+
const s = this.groupAtPath(r);
|
|
1836
|
+
for (const n of e.queries) {
|
|
1837
|
+
const o = $(s.queries, n);
|
|
1772
1838
|
o > -1 && s.queries.splice(o, 1);
|
|
1773
1839
|
}
|
|
1774
|
-
|
|
1840
|
+
this.pruneEmptyGroups(r);
|
|
1841
|
+
} else {
|
|
1842
|
+
const s = r[r.length - 1];
|
|
1843
|
+
s.queries.splice(s.idx, 1), this.pruneEmptyGroups(r.slice(0, -1));
|
|
1775
1844
|
}
|
|
1776
1845
|
}
|
|
1777
1846
|
return t;
|
|
@@ -1781,8 +1850,8 @@ class L {
|
|
|
1781
1850
|
if (this.isQuery(e))
|
|
1782
1851
|
return e.attribute || t.push(new x("Missing attribute", e)), e.operator || t.push(new x("Missing operator", e)), typeof e.value > "u" && t.push(new x("Missing value", e)), e.operator === "find" && Array.isArray(e.value) && t.push(new x("find operator cannot have array value", e)), e.operator === "in" && typeof e.value < "u" && !Array.isArray(e.value) && t.push(new x("in operator needs an array value", e)), t.length > 0 ? { valid: !1, errors: t } : { valid: !0 };
|
|
1783
1852
|
if (this.isQueryGroup(e)) {
|
|
1784
|
-
const
|
|
1785
|
-
return
|
|
1853
|
+
const n = e.queries.map((o) => this.validateQuery(o)).filter((o) => !o.valid).map((o) => o.errors).flat();
|
|
1854
|
+
return n.length > 0 ? { valid: !1, errors: n } : { valid: !0 };
|
|
1786
1855
|
}
|
|
1787
1856
|
return t.push(new x("Invalid query definition", e)), { valid: !1, errors: t };
|
|
1788
1857
|
}
|
|
@@ -1794,8 +1863,8 @@ class L {
|
|
|
1794
1863
|
* @returns Array of attribute names
|
|
1795
1864
|
*/
|
|
1796
1865
|
getQueryAttributes(e) {
|
|
1797
|
-
const t = [], r = /* @__PURE__ */ new Set(), s = (
|
|
1798
|
-
for (const o of
|
|
1866
|
+
const t = [], r = /* @__PURE__ */ new Set(), s = (n) => {
|
|
1867
|
+
for (const o of n)
|
|
1799
1868
|
this.isQuery(o) ? o.attribute && !r.has(o.attribute) && (t.push(o.attribute), r.add(o.attribute)) : this.isQueryGroup(o) && s(o.queries);
|
|
1800
1869
|
};
|
|
1801
1870
|
return s(e?.queries || this.currentQuery.queries), t;
|
|
@@ -1808,8 +1877,8 @@ class L {
|
|
|
1808
1877
|
* @returns Array of QueryAttributeEntry objects
|
|
1809
1878
|
*/
|
|
1810
1879
|
extractQueryAttributes(e) {
|
|
1811
|
-
const t = [], r = /* @__PURE__ */ new Set(), s = (
|
|
1812
|
-
for (const o of
|
|
1880
|
+
const t = [], r = /* @__PURE__ */ new Set(), s = (n) => {
|
|
1881
|
+
for (const o of n)
|
|
1813
1882
|
if (this.isQuery(o)) {
|
|
1814
1883
|
if (o.attribute && !r.has(o.attribute)) {
|
|
1815
1884
|
const a = this.getQueryAttributeForString(o.attribute);
|
|
@@ -1856,9 +1925,9 @@ class L {
|
|
|
1856
1925
|
t[r.reference] || (t[r.reference] = { $: !0 });
|
|
1857
1926
|
const s = this.deepQueryService.parse(r.referenceAttribute);
|
|
1858
1927
|
if (s.isDeepQuery && r.reference) {
|
|
1859
|
-
const
|
|
1860
|
-
Object.keys(
|
|
1861
|
-
o !== "$" && r.reference && (t[r.reference][o] =
|
|
1928
|
+
const n = this.getProjectionForAttributeEntries([s]);
|
|
1929
|
+
Object.keys(n).forEach((o) => {
|
|
1930
|
+
o !== "$" && r.reference && (t[r.reference][o] = n[o]);
|
|
1862
1931
|
});
|
|
1863
1932
|
} else r.reference && (t[r.reference][r.referenceAttribute] = !0);
|
|
1864
1933
|
} else
|
|
@@ -1996,9 +2065,11 @@ class L {
|
|
|
1996
2065
|
return this.applyQuery(e, { mode: "add" });
|
|
1997
2066
|
}
|
|
1998
2067
|
/**
|
|
1999
|
-
* Replace
|
|
2068
|
+
* Replace the conditions of an attribute group with new condition(s).
|
|
2000
2069
|
* Accepts single condition or array of conditions.
|
|
2001
|
-
* Each condition replaces all existing conditions
|
|
2070
|
+
* Each condition replaces all existing conditions of the group keyed by its attribute
|
|
2071
|
+
* (created if missing); groups for other attributes and the query options are kept.
|
|
2072
|
+
* This does not replace the whole query — see {@link replaceQuery} for that.
|
|
2002
2073
|
*
|
|
2003
2074
|
* Clearer alternative to `applyQuery(condition, { mode: 'set' })`.
|
|
2004
2075
|
*
|
|
@@ -2021,8 +2092,16 @@ class L {
|
|
|
2021
2092
|
return this.applyQuery(e, { mode: "set" });
|
|
2022
2093
|
}
|
|
2023
2094
|
/**
|
|
2024
|
-
* Replace
|
|
2025
|
-
*
|
|
2095
|
+
* Replace one query group by key (per-group `set`).
|
|
2096
|
+
* The group with the same `groupKey` is replaced by the given definition; if none exists
|
|
2097
|
+
* the group is appended. All other groups and the query options (`count`, `start`,
|
|
2098
|
+
* `sort`, `projection`) are kept. An unkeyed group replaces the first unkeyed top-level
|
|
2099
|
+
* group. Only a group with `groupKey: 'root'` replaces the whole query — equivalent to
|
|
2100
|
+
* `applyQuery(rootGroup, { mode: 'set' })` / {@link replaceQuery}.
|
|
2101
|
+
*
|
|
2102
|
+
* A group without `groupKey` whose `queries` hold keyed groups is stored as a keyless
|
|
2103
|
+
* wrapper; the keyed groups inside it stay nested and are still found by `groupKey`
|
|
2104
|
+
* via {@link findQueryGroup}, {@link removeQuery} and `fn.facets` (#294).
|
|
2026
2105
|
*
|
|
2027
2106
|
* @param group - Query group to set
|
|
2028
2107
|
* @returns Updated query
|
|
@@ -2069,7 +2148,10 @@ class L {
|
|
|
2069
2148
|
}
|
|
2070
2149
|
/**
|
|
2071
2150
|
* Replace the entire current query with a new query.
|
|
2072
|
-
*
|
|
2151
|
+
* Replaces all conditions and groups, and the root `groupType` when given. The query
|
|
2152
|
+
* options (`count`, `start`, `sort`, `projection`) are kept — use {@link applyOptions}
|
|
2153
|
+
* or `applyQuery({ groupKey: 'root', ... }, { mode: 'set' })` to replace those too.
|
|
2154
|
+
* To replace a single group by key, use {@link setGroup}.
|
|
2073
2155
|
*
|
|
2074
2156
|
* @param query - Complete query to replace with
|
|
2075
2157
|
* @returns Updated query
|
|
@@ -2165,13 +2247,13 @@ class L {
|
|
|
2165
2247
|
const t = (r) => {
|
|
2166
2248
|
for (const s of r)
|
|
2167
2249
|
if (this.isQuery(s)) {
|
|
2168
|
-
let
|
|
2250
|
+
let n = !0;
|
|
2169
2251
|
for (const o in e)
|
|
2170
2252
|
if (s[o] !== e[o]) {
|
|
2171
|
-
|
|
2253
|
+
n = !1;
|
|
2172
2254
|
break;
|
|
2173
2255
|
}
|
|
2174
|
-
if (
|
|
2256
|
+
if (n) return !0;
|
|
2175
2257
|
} else if (this.isQueryGroup(s) && t(s.queries))
|
|
2176
2258
|
return !0;
|
|
2177
2259
|
return !1;
|
|
@@ -2292,9 +2374,9 @@ class L {
|
|
|
2292
2374
|
return e(this.currentQuery.queries);
|
|
2293
2375
|
}
|
|
2294
2376
|
}
|
|
2295
|
-
const
|
|
2296
|
-
function
|
|
2297
|
-
const a = t.excludeGroup ?? s, c =
|
|
2377
|
+
const N = new L();
|
|
2378
|
+
function et(i, e, t, r, s, n, o) {
|
|
2379
|
+
const a = t.excludeGroup ?? s, c = N.removeQuery({ groupKey: a }, v(r)), u = o.queryData(i, c, !1, n), f = e ? [...e.keys()] : [], d = new Set(f), l = n.get(s) ?? /* @__PURE__ */ new Map();
|
|
2298
2380
|
if (!t.excludeUnresolved)
|
|
2299
2381
|
for (const p of l.keys())
|
|
2300
2382
|
d.add(p);
|
|
@@ -2302,7 +2384,7 @@ function Ye(n, e, t, r, s, i, o) {
|
|
|
2302
2384
|
const p = [];
|
|
2303
2385
|
for (const K of d.values())
|
|
2304
2386
|
p.push(
|
|
2305
|
-
|
|
2387
|
+
P(
|
|
2306
2388
|
K,
|
|
2307
2389
|
l,
|
|
2308
2390
|
u,
|
|
@@ -2318,7 +2400,7 @@ function Ye(n, e, t, r, s, i, o) {
|
|
|
2318
2400
|
}
|
|
2319
2401
|
const h = [];
|
|
2320
2402
|
for (const p of d.values()) {
|
|
2321
|
-
const y =
|
|
2403
|
+
const y = P(
|
|
2322
2404
|
p,
|
|
2323
2405
|
l,
|
|
2324
2406
|
u,
|
|
@@ -2336,36 +2418,36 @@ function Ye(n, e, t, r, s, i, o) {
|
|
|
2336
2418
|
}
|
|
2337
2419
|
return h;
|
|
2338
2420
|
}
|
|
2339
|
-
function
|
|
2340
|
-
const c = /* @__PURE__ */ new Map(), u = e.get(
|
|
2421
|
+
function P(i, e, t, r, s, n, o, a) {
|
|
2422
|
+
const c = /* @__PURE__ */ new Map(), u = e.get(i) || /* @__PURE__ */ new Set();
|
|
2341
2423
|
for (const f of u) {
|
|
2342
2424
|
const d = t.get(f);
|
|
2343
2425
|
if (d && (c.set(f, d), !a))
|
|
2344
2426
|
break;
|
|
2345
2427
|
}
|
|
2346
2428
|
return {
|
|
2347
|
-
key: String(
|
|
2348
|
-
value:
|
|
2349
|
-
selected: we(
|
|
2429
|
+
key: String(i),
|
|
2430
|
+
value: i,
|
|
2431
|
+
selected: we(n, s, i, o),
|
|
2350
2432
|
enabled: c.size > 0,
|
|
2351
2433
|
size: c.size,
|
|
2352
|
-
entry: r?.get(
|
|
2434
|
+
entry: r?.get(i),
|
|
2353
2435
|
resultKeys: Array.from(c.keys())
|
|
2354
2436
|
};
|
|
2355
2437
|
}
|
|
2356
|
-
function S(
|
|
2357
|
-
if (
|
|
2358
|
-
if (
|
|
2438
|
+
function S(i, e) {
|
|
2439
|
+
if (i === void 0 && e === void 0) return 0;
|
|
2440
|
+
if (i === void 0) return 1;
|
|
2359
2441
|
if (e === void 0) return -1;
|
|
2360
|
-
const t = typeof
|
|
2442
|
+
const t = typeof i, r = typeof e;
|
|
2361
2443
|
if (t !== r) return t < r ? -1 : 1;
|
|
2362
|
-
if (t === "number") return
|
|
2363
|
-
if (t === "string") return
|
|
2364
|
-
const s = String(
|
|
2365
|
-
return s <
|
|
2444
|
+
if (t === "number") return i - e;
|
|
2445
|
+
if (t === "string") return i.localeCompare(e);
|
|
2446
|
+
const s = String(i), n = String(e);
|
|
2447
|
+
return s < n ? -1 : s > n ? 1 : 0;
|
|
2366
2448
|
}
|
|
2367
|
-
function ve(
|
|
2368
|
-
switch (
|
|
2449
|
+
function ve(i) {
|
|
2450
|
+
switch (i) {
|
|
2369
2451
|
case "size-desc":
|
|
2370
2452
|
return (e, t) => t.size - e.size || S(e.value, t.value);
|
|
2371
2453
|
case "size-asc":
|
|
@@ -2376,9 +2458,9 @@ function ve(n) {
|
|
|
2376
2458
|
return (e, t) => e.value === void 0 && t.value === void 0 ? 0 : e.value === void 0 ? 1 : t.value === void 0 ? -1 : -S(e.value, t.value);
|
|
2377
2459
|
}
|
|
2378
2460
|
}
|
|
2379
|
-
const we = (
|
|
2380
|
-
const s =
|
|
2381
|
-
return s
|
|
2461
|
+
const we = (i, e, t, r) => {
|
|
2462
|
+
const s = N.findQueryGroup(i, r);
|
|
2463
|
+
return s ? !!s.queries.find((n) => N.isQuery(n) ? n.attribute !== e ? !1 : (n.operator === "in" && Array.isArray(n.value) ? n.value : [n.value]).some((a) => (a?.key || a) === t) : !1) : !1;
|
|
2382
2464
|
};
|
|
2383
2465
|
class xe {
|
|
2384
2466
|
indexMap = /* @__PURE__ */ new Map();
|
|
@@ -2403,31 +2485,31 @@ class xe {
|
|
|
2403
2485
|
let r = this.dataMap.get(e);
|
|
2404
2486
|
r || (r = /* @__PURE__ */ new Map(), this.dataMap.set(e, r));
|
|
2405
2487
|
for (const s of t) {
|
|
2406
|
-
let
|
|
2488
|
+
let n;
|
|
2407
2489
|
if (typeof s == "object" && s && s.key)
|
|
2408
|
-
|
|
2490
|
+
n = s.key;
|
|
2409
2491
|
else if (Array.isArray(s)) {
|
|
2410
2492
|
for (const a of s)
|
|
2411
2493
|
this.fillDataMap(e, [a]);
|
|
2412
2494
|
return;
|
|
2413
|
-
} else s instanceof Date ?
|
|
2414
|
-
let o = r.get(
|
|
2415
|
-
o || (o = { key:
|
|
2495
|
+
} else s instanceof Date ? n = s.toISOString() : n = s;
|
|
2496
|
+
let o = r.get(n);
|
|
2497
|
+
o || (o = { key: n }, this.dataMap.get(e)?.set(n, o));
|
|
2416
2498
|
}
|
|
2417
2499
|
}
|
|
2418
2500
|
fillInverseIndex(e, t, r) {
|
|
2419
2501
|
if (!e || !t || !r || !Array.isArray(r))
|
|
2420
2502
|
return;
|
|
2421
2503
|
const s = this.indexMap.get(e) || /* @__PURE__ */ new Map();
|
|
2422
|
-
for (const
|
|
2504
|
+
for (const n of r) {
|
|
2423
2505
|
let o;
|
|
2424
|
-
if (typeof
|
|
2425
|
-
o =
|
|
2426
|
-
else if (Array.isArray(
|
|
2427
|
-
for (const c of
|
|
2506
|
+
if (typeof n == "object" && n && n.key)
|
|
2507
|
+
o = n.key;
|
|
2508
|
+
else if (Array.isArray(n)) {
|
|
2509
|
+
for (const c of n)
|
|
2428
2510
|
this.fillInverseIndex(e, t, [c]);
|
|
2429
2511
|
return;
|
|
2430
|
-
} else
|
|
2512
|
+
} else n instanceof Date ? o = n.toISOString() : o = n;
|
|
2431
2513
|
let a = s.get(o);
|
|
2432
2514
|
a || (a = /* @__PURE__ */ new Set(), s.set(o, a)), a.add(t);
|
|
2433
2515
|
}
|
|
@@ -2443,11 +2525,11 @@ class xe {
|
|
|
2443
2525
|
}
|
|
2444
2526
|
getOrCreateIndex(e, t, r) {
|
|
2445
2527
|
const s = this.getIndexName(e, r);
|
|
2446
|
-
let
|
|
2528
|
+
let n = this.getIndex(s);
|
|
2447
2529
|
const o = this.indexMetadata.get(s);
|
|
2448
2530
|
if (o)
|
|
2449
2531
|
o.lastAccessedAt = Date.now();
|
|
2450
|
-
else if (!
|
|
2532
|
+
else if (!n) {
|
|
2451
2533
|
const c = m.parse(e).isDeepQuery ?? !1;
|
|
2452
2534
|
this.indexMetadata.set(s, {
|
|
2453
2535
|
createdAt: Date.now(),
|
|
@@ -2456,16 +2538,16 @@ class xe {
|
|
|
2456
2538
|
type: c ? "deep" : "shallow"
|
|
2457
2539
|
});
|
|
2458
2540
|
}
|
|
2459
|
-
if (!
|
|
2541
|
+
if (!n) {
|
|
2460
2542
|
this.reset(s), this.indexMap.set(s, /* @__PURE__ */ new Map());
|
|
2461
2543
|
const c = m.parse(e).isDeepQuery;
|
|
2462
2544
|
for (const u of t.values()) {
|
|
2463
2545
|
let f;
|
|
2464
2546
|
c ? (f = w(u, e), f.length === 0 && (f = [void 0])) : f = [u[e]], this.fillInverseIndex(s, u.key, f), this.fillDataMap(s, f);
|
|
2465
2547
|
}
|
|
2466
|
-
|
|
2548
|
+
n = this.getIndex(s) || /* @__PURE__ */ new Map();
|
|
2467
2549
|
}
|
|
2468
|
-
return
|
|
2550
|
+
return n;
|
|
2469
2551
|
}
|
|
2470
2552
|
getIndexName(e, t) {
|
|
2471
2553
|
return t ? e + "_" + D(t) : e;
|
|
@@ -2480,15 +2562,15 @@ class xe {
|
|
|
2480
2562
|
removeFromInverseIndex(e, t, r) {
|
|
2481
2563
|
const s = this.indexMap.get(e);
|
|
2482
2564
|
if (s)
|
|
2483
|
-
for (const
|
|
2565
|
+
for (const n of r) {
|
|
2484
2566
|
let o;
|
|
2485
|
-
if (typeof
|
|
2486
|
-
o =
|
|
2487
|
-
else if (Array.isArray(
|
|
2488
|
-
for (const c of
|
|
2567
|
+
if (typeof n == "object" && n && n.key)
|
|
2568
|
+
o = n.key;
|
|
2569
|
+
else if (Array.isArray(n)) {
|
|
2570
|
+
for (const c of n)
|
|
2489
2571
|
this.removeFromInverseIndex(e, t, [c]);
|
|
2490
2572
|
return;
|
|
2491
|
-
} else
|
|
2573
|
+
} else n instanceof Date ? o = n.toISOString() : o = n;
|
|
2492
2574
|
const a = s.get(o);
|
|
2493
2575
|
a && (a.delete(t), a.size === 0 && s.delete(o));
|
|
2494
2576
|
}
|
|
@@ -2512,15 +2594,15 @@ class xe {
|
|
|
2512
2594
|
const r = this.dataMap.get(e);
|
|
2513
2595
|
if (r)
|
|
2514
2596
|
for (const s of t) {
|
|
2515
|
-
let
|
|
2597
|
+
let n;
|
|
2516
2598
|
if (typeof s == "object" && s && s.key)
|
|
2517
|
-
|
|
2599
|
+
n = s.key;
|
|
2518
2600
|
else if (Array.isArray(s)) {
|
|
2519
2601
|
for (const o of s)
|
|
2520
2602
|
this.removeFromDataMap(e, [o]);
|
|
2521
2603
|
return;
|
|
2522
|
-
} else s instanceof Date ?
|
|
2523
|
-
r.delete(
|
|
2604
|
+
} else s instanceof Date ? n = s.toISOString() : n = s;
|
|
2605
|
+
r.delete(n);
|
|
2524
2606
|
}
|
|
2525
2607
|
}
|
|
2526
2608
|
/**
|
|
@@ -2612,8 +2694,8 @@ class xe {
|
|
|
2612
2694
|
cleanupStaleIndices(e = 300 * 1e3) {
|
|
2613
2695
|
const t = Date.now();
|
|
2614
2696
|
let r = 0;
|
|
2615
|
-
for (const [s,
|
|
2616
|
-
t -
|
|
2697
|
+
for (const [s, n] of this.indexMetadata)
|
|
2698
|
+
t - n.lastAccessedAt > e && (this.reset(s), r++);
|
|
2617
2699
|
return r;
|
|
2618
2700
|
}
|
|
2619
2701
|
/**
|
|
@@ -2627,19 +2709,19 @@ class xe {
|
|
|
2627
2709
|
const a = t - o.createdAt;
|
|
2628
2710
|
r += a, a > s && (s = a);
|
|
2629
2711
|
}
|
|
2630
|
-
const
|
|
2712
|
+
const n = this.indexMetadata.size > 0 ? r / this.indexMetadata.size : 0;
|
|
2631
2713
|
return {
|
|
2632
2714
|
shallow: e.shallow,
|
|
2633
2715
|
deep: e.deep,
|
|
2634
2716
|
total: e.total,
|
|
2635
2717
|
oldestAge: s,
|
|
2636
|
-
avgAge:
|
|
2718
|
+
avgAge: n
|
|
2637
2719
|
};
|
|
2638
2720
|
}
|
|
2639
2721
|
}
|
|
2640
2722
|
const A = "__";
|
|
2641
|
-
function U(
|
|
2642
|
-
const o =
|
|
2723
|
+
function U(i, e, t = { key: "root" }, r = "root", s = new xe(), n) {
|
|
2724
|
+
const o = n || i;
|
|
2643
2725
|
for (const a of e.columns)
|
|
2644
2726
|
a.attribute && (m.parse(a.attribute), s.getOrCreateIndex(a.attribute, o));
|
|
2645
2727
|
for (const a of e.rows)
|
|
@@ -2648,24 +2730,24 @@ function U(n, e, t = { key: "root" }, r = "root", s = new xe(), i) {
|
|
|
2648
2730
|
a.attribute && (m.parse(a.attribute), s.getOrCreateIndex(a.attribute, o));
|
|
2649
2731
|
if (e.rows && e.rows.length > 0) {
|
|
2650
2732
|
t.rows = t.rows || [];
|
|
2651
|
-
const a = Ae(
|
|
2733
|
+
const a = Ae(i, e.rows[0], e, s, r, n);
|
|
2652
2734
|
t.rows.push(a);
|
|
2653
2735
|
}
|
|
2654
2736
|
if (e.columns && e.columns.length > 0) {
|
|
2655
2737
|
t.columns = t.columns || [];
|
|
2656
|
-
const a = W(
|
|
2738
|
+
const a = W(i, e.columns[0], e, s, r, n);
|
|
2657
2739
|
t.columns.push(a);
|
|
2658
2740
|
}
|
|
2659
2741
|
if (t.key === "root")
|
|
2660
2742
|
for (const a of e.values) {
|
|
2661
2743
|
if (t.values = t.values || [], r === "root" && e.options?.calculateTotals === !1)
|
|
2662
2744
|
continue;
|
|
2663
|
-
const c = C(a,
|
|
2745
|
+
const c = C(a, i, s.getIndex(a.attribute), a.attribute);
|
|
2664
2746
|
t.values.push(c);
|
|
2665
2747
|
}
|
|
2666
2748
|
return t;
|
|
2667
2749
|
}
|
|
2668
|
-
function Ae(
|
|
2750
|
+
function Ae(i, e, t, r, s = "", n) {
|
|
2669
2751
|
const o = { key: e.attribute }, a = r.getIndex(e.attribute);
|
|
2670
2752
|
if (!a)
|
|
2671
2753
|
return o;
|
|
@@ -2675,7 +2757,7 @@ function Ae(n, e, t, r, s = "", i) {
|
|
|
2675
2757
|
value: c
|
|
2676
2758
|
}, d = /* @__PURE__ */ new Map();
|
|
2677
2759
|
for (const l of u)
|
|
2678
|
-
|
|
2760
|
+
i.has(l) && d.set(l, i.get(l));
|
|
2679
2761
|
if (d.size) {
|
|
2680
2762
|
for (const l of t.values) {
|
|
2681
2763
|
if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
|
|
@@ -2691,7 +2773,7 @@ function Ae(n, e, t, r, s = "", i) {
|
|
|
2691
2773
|
f,
|
|
2692
2774
|
s + A + e.attribute + A + c,
|
|
2693
2775
|
r,
|
|
2694
|
-
|
|
2776
|
+
n
|
|
2695
2777
|
);
|
|
2696
2778
|
} else if (t.columns)
|
|
2697
2779
|
for (const l of t.columns) {
|
|
@@ -2702,7 +2784,7 @@ function Ae(n, e, t, r, s = "", i) {
|
|
|
2702
2784
|
t,
|
|
2703
2785
|
r,
|
|
2704
2786
|
s + A + e.attribute + A + c,
|
|
2705
|
-
|
|
2787
|
+
n
|
|
2706
2788
|
);
|
|
2707
2789
|
f.columns.push(h);
|
|
2708
2790
|
}
|
|
@@ -2710,7 +2792,7 @@ function Ae(n, e, t, r, s = "", i) {
|
|
|
2710
2792
|
}
|
|
2711
2793
|
return o;
|
|
2712
2794
|
}
|
|
2713
|
-
function W(
|
|
2795
|
+
function W(i, e, t, r, s = "", n) {
|
|
2714
2796
|
const o = { key: e.attribute }, a = r.getIndex(e.attribute);
|
|
2715
2797
|
if (!a)
|
|
2716
2798
|
return o;
|
|
@@ -2720,7 +2802,7 @@ function W(n, e, t, r, s = "", i) {
|
|
|
2720
2802
|
value: c
|
|
2721
2803
|
}, d = /* @__PURE__ */ new Map();
|
|
2722
2804
|
for (const l of u)
|
|
2723
|
-
|
|
2805
|
+
i.has(l) && d.set(l, i.get(l));
|
|
2724
2806
|
if (d.size) {
|
|
2725
2807
|
for (const l of t.values) {
|
|
2726
2808
|
if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
|
|
@@ -2736,24 +2818,24 @@ function W(n, e, t, r, s = "", i) {
|
|
|
2736
2818
|
f,
|
|
2737
2819
|
s + A + e.attribute + A + c,
|
|
2738
2820
|
r,
|
|
2739
|
-
|
|
2821
|
+
n
|
|
2740
2822
|
);
|
|
2741
2823
|
}
|
|
2742
2824
|
}
|
|
2743
2825
|
}
|
|
2744
2826
|
return o;
|
|
2745
2827
|
}
|
|
2746
|
-
const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/, Se = /^-?\d+$/, Ie = /^-?\d+\.\d+$/, De = /^\d{1,2}([/.-])\d{1,2}\1\d{2,4}$/, Ke = (
|
|
2747
|
-
const e = [...
|
|
2828
|
+
const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/, Se = /^-?\d+$/, Ie = /^-?\d+\.\d+$/, De = /^\d{1,2}([/.-])\d{1,2}\1\d{2,4}$/, Ke = (i) => i === "true" || i === "false" ? "boolean" : Se.test(i) ? "int" : Ie.test(i) ? "float" : be.test(i) && !Number.isNaN(Date.parse(i)) ? "date" : "string", ke = (i) => De.test(i), Qe = (i) => i == null || i === "", Me = (i) => {
|
|
2829
|
+
const e = [...i];
|
|
2748
2830
|
return e.length <= 1 ? { type: e[0] ?? "any", conflict: !1 } : e.every((t) => t === "int" || t === "float") ? { type: "float", conflict: !1 } : { type: "any", conflict: !0 };
|
|
2749
|
-
},
|
|
2750
|
-
const r = e.deep ?? (e.sampleSize !== void 0 && e.sampleSize > 1) ? e.sampleSize ?? 1 / 0 : 1, s = e.coerceStrings ?? !0,
|
|
2831
|
+
}, Ee = (i, e = {}) => {
|
|
2832
|
+
const r = e.deep ?? (e.sampleSize !== void 0 && e.sampleSize > 1) ? e.sampleSize ?? 1 / 0 : 1, s = e.coerceStrings ?? !0, n = /* @__PURE__ */ new Map(), o = [], a = Math.min(i.length, r);
|
|
2751
2833
|
for (let f = 0; f < a; f++) {
|
|
2752
|
-
const d =
|
|
2834
|
+
const d = i[f];
|
|
2753
2835
|
if (d)
|
|
2754
2836
|
for (const [l, h] of Object.entries(d)) {
|
|
2755
|
-
let p =
|
|
2756
|
-
if (p || (p = { observed: /* @__PURE__ */ new Set(), empty: 0, scanned: 0 },
|
|
2837
|
+
let p = n.get(l);
|
|
2838
|
+
if (p || (p = { observed: /* @__PURE__ */ new Set(), empty: 0, scanned: 0 }, n.set(l, p), o.push(l)), p.scanned++, Qe(h)) {
|
|
2757
2839
|
p.empty++;
|
|
2758
2840
|
continue;
|
|
2759
2841
|
}
|
|
@@ -2763,7 +2845,7 @@ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?
|
|
|
2763
2845
|
}
|
|
2764
2846
|
const c = [], u = [];
|
|
2765
2847
|
for (const f of o) {
|
|
2766
|
-
const d =
|
|
2848
|
+
const d = n.get(f), { type: l, conflict: h } = Me(d.observed.size ? d.observed : /* @__PURE__ */ new Set(["string"]));
|
|
2767
2849
|
c.push({ key: f, type: l }), u.push({
|
|
2768
2850
|
column: f,
|
|
2769
2851
|
inferredType: l,
|
|
@@ -2774,28 +2856,28 @@ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?
|
|
|
2774
2856
|
});
|
|
2775
2857
|
}
|
|
2776
2858
|
return { properties: c, diagnostics: u };
|
|
2777
|
-
},
|
|
2778
|
-
switch (typeof
|
|
2859
|
+
}, tt = (i, e = !1) => Ee(i, typeof e == "boolean" ? { deep: e } : e).properties, Ne = (i) => Number(i) === i && i % 1 === 0, Ce = (i) => Number(i) === i && i % 1 !== 0, $e = (i) => {
|
|
2860
|
+
switch (typeof i) {
|
|
2779
2861
|
case "string":
|
|
2780
2862
|
return "string";
|
|
2781
2863
|
case "number":
|
|
2782
|
-
return
|
|
2864
|
+
return Ne(i) ? "int" : Ce(i) ? "float" : "any";
|
|
2783
2865
|
case "boolean":
|
|
2784
2866
|
return "boolean";
|
|
2785
2867
|
case "object":
|
|
2786
|
-
return se(
|
|
2868
|
+
return se(i) ? "date" : "json";
|
|
2787
2869
|
default:
|
|
2788
2870
|
return "any";
|
|
2789
2871
|
}
|
|
2790
|
-
},
|
|
2791
|
-
const t = te(
|
|
2872
|
+
}, rt = (i, e) => {
|
|
2873
|
+
const t = te(i.text || ""), r = e?.attributeKey || i.filterKey;
|
|
2792
2874
|
let s;
|
|
2793
|
-
const
|
|
2794
|
-
return
|
|
2795
|
-
groupKey:
|
|
2875
|
+
const n = e?.comparisonType || "containsIgnoreCase";
|
|
2876
|
+
return n === "containsIgnoreCase" ? s = {
|
|
2877
|
+
groupKey: i.filterKey,
|
|
2796
2878
|
queries: [
|
|
2797
2879
|
{
|
|
2798
|
-
queryKey:
|
|
2880
|
+
queryKey: i.text,
|
|
2799
2881
|
attribute: r,
|
|
2800
2882
|
value: `/${t}/`,
|
|
2801
2883
|
operator: "find",
|
|
@@ -2804,11 +2886,11 @@ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?
|
|
|
2804
2886
|
}
|
|
2805
2887
|
}
|
|
2806
2888
|
]
|
|
2807
|
-
} :
|
|
2808
|
-
groupKey:
|
|
2889
|
+
} : n === "containsIgnoreCaseAndWhitespace" ? s = {
|
|
2890
|
+
groupKey: i.filterKey,
|
|
2809
2891
|
queries: [
|
|
2810
2892
|
{
|
|
2811
|
-
queryKey:
|
|
2893
|
+
queryKey: i.text,
|
|
2812
2894
|
attribute: r,
|
|
2813
2895
|
value: `/${t}/`,
|
|
2814
2896
|
operator: "find",
|
|
@@ -2817,33 +2899,33 @@ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?
|
|
|
2817
2899
|
}
|
|
2818
2900
|
}
|
|
2819
2901
|
]
|
|
2820
|
-
} :
|
|
2821
|
-
groupKey:
|
|
2902
|
+
} : n === "contains" ? s = {
|
|
2903
|
+
groupKey: i.filterKey,
|
|
2822
2904
|
queries: [
|
|
2823
2905
|
{
|
|
2824
|
-
queryKey:
|
|
2906
|
+
queryKey: i.text,
|
|
2825
2907
|
attribute: r,
|
|
2826
2908
|
value: `/${t}/`,
|
|
2827
2909
|
operator: "find"
|
|
2828
2910
|
}
|
|
2829
2911
|
]
|
|
2830
|
-
} :
|
|
2831
|
-
groupKey:
|
|
2912
|
+
} : n === "equal" ? s = {
|
|
2913
|
+
groupKey: i.filterKey,
|
|
2832
2914
|
queries: [
|
|
2833
2915
|
{
|
|
2834
|
-
queryKey:
|
|
2916
|
+
queryKey: i.text,
|
|
2835
2917
|
attribute: r,
|
|
2836
|
-
value:
|
|
2918
|
+
value: i.text,
|
|
2837
2919
|
operator: "eq"
|
|
2838
2920
|
}
|
|
2839
2921
|
]
|
|
2840
|
-
} :
|
|
2841
|
-
groupKey:
|
|
2922
|
+
} : n === "equalIgnoreCase" && (s = {
|
|
2923
|
+
groupKey: i.filterKey,
|
|
2842
2924
|
queries: [
|
|
2843
2925
|
{
|
|
2844
|
-
queryKey:
|
|
2926
|
+
queryKey: i.text,
|
|
2845
2927
|
attribute: r,
|
|
2846
|
-
value:
|
|
2928
|
+
value: i.text,
|
|
2847
2929
|
operator: "eq",
|
|
2848
2930
|
options: {
|
|
2849
2931
|
transform: ["lowercase"]
|
|
@@ -2851,40 +2933,40 @@ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?
|
|
|
2851
2933
|
}
|
|
2852
2934
|
]
|
|
2853
2935
|
}), s;
|
|
2854
|
-
},
|
|
2855
|
-
const t = e?.attributeKey ||
|
|
2936
|
+
}, st = (i, e) => {
|
|
2937
|
+
const t = e?.attributeKey || i.filterKey;
|
|
2856
2938
|
return {
|
|
2857
|
-
groupKey:
|
|
2939
|
+
groupKey: i.filterKey,
|
|
2858
2940
|
queries: [
|
|
2859
2941
|
{
|
|
2860
|
-
queryKey:
|
|
2942
|
+
queryKey: i.value,
|
|
2861
2943
|
attribute: t,
|
|
2862
|
-
value:
|
|
2944
|
+
value: i.value,
|
|
2863
2945
|
operator: "eq"
|
|
2864
2946
|
}
|
|
2865
2947
|
]
|
|
2866
2948
|
};
|
|
2867
|
-
},
|
|
2868
|
-
const t = e?.attributeKey ||
|
|
2869
|
-
groupKey:
|
|
2949
|
+
}, nt = (i, e) => {
|
|
2950
|
+
const t = e?.attributeKey || i.filterKey, r = {
|
|
2951
|
+
groupKey: i.filterKey,
|
|
2870
2952
|
queries: []
|
|
2871
2953
|
};
|
|
2872
|
-
return typeof
|
|
2954
|
+
return typeof i.eq < "u" && (r.groupType = "or", Array.isArray(i.eq) ? i.eq.forEach((s) => {
|
|
2873
2955
|
r.queries.push({ attribute: t, value: s, operator: "eq" });
|
|
2874
|
-
}) : r.queries.push({ attribute: t, value:
|
|
2956
|
+
}) : r.queries.push({ attribute: t, value: i.eq, operator: "eq" })), typeof i.ne < "u" && (r.groupType = "and", Array.isArray(i.ne) ? i.ne.forEach((s) => {
|
|
2875
2957
|
r.queries.push({ attribute: t, value: s, operator: "eq", options: { invert: !0 } });
|
|
2876
2958
|
}) : r.queries.push({
|
|
2877
2959
|
attribute: t,
|
|
2878
|
-
value:
|
|
2960
|
+
value: i.ne,
|
|
2879
2961
|
operator: "eq",
|
|
2880
2962
|
options: { invert: !0 }
|
|
2881
|
-
})), typeof
|
|
2882
|
-
},
|
|
2883
|
-
const t = e?.attributeKey ||
|
|
2884
|
-
groupKey:
|
|
2963
|
+
})), typeof i.gt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: i.gt, operator: "gt" })), typeof i.lt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: i.lt, operator: "lt" })), typeof i.gte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: i.gte, operator: "gte" })), typeof i.lte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: i.lte, operator: "lte" })), r;
|
|
2964
|
+
}, it = (i, e) => {
|
|
2965
|
+
const t = e?.attributeKey || i.filterKey, r = {
|
|
2966
|
+
groupKey: i.filterKey,
|
|
2885
2967
|
queries: []
|
|
2886
2968
|
};
|
|
2887
|
-
return
|
|
2969
|
+
return i.itemKeys.forEach((s) => {
|
|
2888
2970
|
r.queries.push({
|
|
2889
2971
|
queryKey: s,
|
|
2890
2972
|
attribute: t,
|
|
@@ -2892,8 +2974,8 @@ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?
|
|
|
2892
2974
|
operator: "eq"
|
|
2893
2975
|
});
|
|
2894
2976
|
}), r;
|
|
2895
|
-
},
|
|
2896
|
-
class
|
|
2977
|
+
}, ot = (i) => !(typeof i.modelKey != "string" || !Array.isArray(i.queries));
|
|
2978
|
+
class at {
|
|
2897
2979
|
constructor(e, t, r) {
|
|
2898
2980
|
this.scriptController = e, this.globalItemService = t, this.modelParser = r;
|
|
2899
2981
|
}
|
|
@@ -2918,19 +3000,19 @@ class ot {
|
|
|
2918
3000
|
let r = e.value;
|
|
2919
3001
|
const s = e.options?.arrayValueHandling || "some";
|
|
2920
3002
|
Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (r = this.transformValue(r, e.options.transform));
|
|
2921
|
-
let
|
|
2922
|
-
if (Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (
|
|
3003
|
+
let n = this.getAttributeValue(t, e.attribute);
|
|
3004
|
+
if (Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (n = this.transformValue(n, e.options.transform)), (typeof n > "u" || n === null) && !["typeof", "isTruthy", "eq", "in"].includes(e.operator))
|
|
2923
3005
|
return !1;
|
|
2924
3006
|
let o;
|
|
2925
3007
|
switch (e.operator) {
|
|
2926
3008
|
case "eq":
|
|
2927
|
-
o = this.queryEq(
|
|
3009
|
+
o = this.queryEq(n, r, s);
|
|
2928
3010
|
break;
|
|
2929
3011
|
case "in":
|
|
2930
|
-
o = this.queryIn(
|
|
3012
|
+
o = this.queryIn(n, r, s);
|
|
2931
3013
|
break;
|
|
2932
3014
|
case "find":
|
|
2933
|
-
o = this.queryFind(
|
|
3015
|
+
o = this.queryFind(n, r, s, e.options?.regexFlags);
|
|
2934
3016
|
break;
|
|
2935
3017
|
case "lt":
|
|
2936
3018
|
case "gt":
|
|
@@ -2938,22 +3020,22 @@ class ot {
|
|
|
2938
3020
|
case "gte": {
|
|
2939
3021
|
const a = e.operator;
|
|
2940
3022
|
o = this.matchValues(
|
|
2941
|
-
|
|
3023
|
+
n,
|
|
2942
3024
|
s,
|
|
2943
3025
|
(c) => this.compareValue(a, c, r)
|
|
2944
3026
|
);
|
|
2945
3027
|
break;
|
|
2946
3028
|
}
|
|
2947
3029
|
case "typeof":
|
|
2948
|
-
o = this.matchValues(
|
|
3030
|
+
o = this.matchValues(n, s, (a) => typeof a === r);
|
|
2949
3031
|
break;
|
|
2950
3032
|
case "isTruthy": {
|
|
2951
3033
|
const a = r === !0;
|
|
2952
|
-
o = this.matchValues(
|
|
3034
|
+
o = this.matchValues(n, s, (c) => !!c === a);
|
|
2953
3035
|
break;
|
|
2954
3036
|
}
|
|
2955
3037
|
case "size":
|
|
2956
|
-
typeof
|
|
3038
|
+
typeof n == "string" ? o = n.length === r : o = V(n) === r;
|
|
2957
3039
|
break;
|
|
2958
3040
|
default:
|
|
2959
3041
|
if (this.scriptController.hasScript(e.operator))
|
|
@@ -2996,12 +3078,12 @@ class ot {
|
|
|
2996
3078
|
return I(e, t);
|
|
2997
3079
|
const r = t.split(".");
|
|
2998
3080
|
let s = e;
|
|
2999
|
-
for (let
|
|
3000
|
-
const o = r[
|
|
3081
|
+
for (let n = 0; n < r.length; n++) {
|
|
3082
|
+
const o = r[n];
|
|
3001
3083
|
if (s == null)
|
|
3002
3084
|
return;
|
|
3003
3085
|
if (Array.isArray(s) && o !== "length" && !/^\d+$/.test(o))
|
|
3004
|
-
return w(s, r.slice(
|
|
3086
|
+
return w(s, r.slice(n).join("."));
|
|
3005
3087
|
s = s[o];
|
|
3006
3088
|
}
|
|
3007
3089
|
return s;
|
|
@@ -3029,7 +3111,7 @@ class ot {
|
|
|
3029
3111
|
return !Array.isArray(t) || t.length === 0 ? !1 : this.matchValues(
|
|
3030
3112
|
e,
|
|
3031
3113
|
r,
|
|
3032
|
-
(s) => t.some((
|
|
3114
|
+
(s) => t.some((n) => this.equalsQueryValue(s, n))
|
|
3033
3115
|
);
|
|
3034
3116
|
}
|
|
3035
3117
|
/**
|
|
@@ -3058,21 +3140,21 @@ class ot {
|
|
|
3058
3140
|
return e.options?.arrayValueHandling !== "every" && !e.options?.transform?.length;
|
|
3059
3141
|
}
|
|
3060
3142
|
evaluateEqOperator(e, t, r, s) {
|
|
3061
|
-
const
|
|
3143
|
+
const n = /* @__PURE__ */ new Map(), o = this.canUseIndex(t) ? s.get(t.attribute) : void 0;
|
|
3062
3144
|
if (o) {
|
|
3063
3145
|
const a = this.getIndexKey(t.value);
|
|
3064
3146
|
if (typeof a < "u") {
|
|
3065
3147
|
const c = o.get(a);
|
|
3066
3148
|
if (c)
|
|
3067
3149
|
if (c.forEach((u) => {
|
|
3068
|
-
r.has(u) &&
|
|
3150
|
+
r.has(u) && n.set(u, r.get(u));
|
|
3069
3151
|
}), t.options?.invert) {
|
|
3070
|
-
const u = O(Array.from(r.values()), Array.from(
|
|
3152
|
+
const u = O(Array.from(r.values()), Array.from(n.values()), "key"), f = /* @__PURE__ */ new Map();
|
|
3071
3153
|
return u.forEach((d) => {
|
|
3072
3154
|
f.set(d.key, d);
|
|
3073
3155
|
}), f;
|
|
3074
3156
|
} else
|
|
3075
|
-
return
|
|
3157
|
+
return n;
|
|
3076
3158
|
}
|
|
3077
3159
|
}
|
|
3078
3160
|
return this.scanDataset(e, t, r);
|
|
@@ -3084,12 +3166,12 @@ class ot {
|
|
|
3084
3166
|
* the result equals the scan's.
|
|
3085
3167
|
*/
|
|
3086
3168
|
evaluateInOperator(e, t, r, s) {
|
|
3087
|
-
const
|
|
3088
|
-
if (!
|
|
3169
|
+
const n = this.canUseIndex(t) ? s.get(t.attribute) : void 0;
|
|
3170
|
+
if (!n)
|
|
3089
3171
|
return this.scanDataset(e, t, r);
|
|
3090
3172
|
const o = /* @__PURE__ */ new Map(), a = [];
|
|
3091
3173
|
for (const u of t.value) {
|
|
3092
|
-
const f = this.getIndexKey(u), d = typeof f < "u" ?
|
|
3174
|
+
const f = this.getIndexKey(u), d = typeof f < "u" ? n.get(f) : void 0;
|
|
3093
3175
|
if (!d) {
|
|
3094
3176
|
a.push(u);
|
|
3095
3177
|
continue;
|
|
@@ -3120,7 +3202,7 @@ class ot {
|
|
|
3120
3202
|
}
|
|
3121
3203
|
/** Evaluates `query` on each item, resolving a deep path's references first. */
|
|
3122
3204
|
scanDataset(e, t, r) {
|
|
3123
|
-
const s = /* @__PURE__ */ new Map(),
|
|
3205
|
+
const s = /* @__PURE__ */ new Map(), n = this.queryBuilder.extractQueryAttributes({ queries: [t] }).filter((a) => a.isDeepQuery), o = n.length > 0 ? this.queryBuilder.getProjectionForAttributeEntries(n) : void 0;
|
|
3124
3206
|
for (let [a, c] of r)
|
|
3125
3207
|
o && (c = this.globalItemService.getProjectedData(
|
|
3126
3208
|
o,
|
|
@@ -3130,7 +3212,7 @@ class ot {
|
|
|
3130
3212
|
return s;
|
|
3131
3213
|
}
|
|
3132
3214
|
equalRegexFn(e, t, r) {
|
|
3133
|
-
const s =
|
|
3215
|
+
const s = j(t, r);
|
|
3134
3216
|
if (s)
|
|
3135
3217
|
try {
|
|
3136
3218
|
return new RegExp(s.pattern, s.flags).test(e);
|
|
@@ -3138,12 +3220,12 @@ class ot {
|
|
|
3138
3220
|
return !1;
|
|
3139
3221
|
}
|
|
3140
3222
|
else return Array.isArray(e) ? !!e.find(
|
|
3141
|
-
(
|
|
3142
|
-
) : typeof t == "object" ?
|
|
3223
|
+
(n) => k(n, t, (o, a) => this.equalRegexFn(o, a, r))
|
|
3224
|
+
) : typeof t == "object" ? G(e, t) : e === t;
|
|
3143
3225
|
}
|
|
3144
3226
|
queryFind(e, t, r, s) {
|
|
3145
|
-
const
|
|
3146
|
-
return Array.isArray(e) ? typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? this.matchValues(e, r, (o) => k(o, t,
|
|
3227
|
+
const n = (o, a) => this.equalRegexFn(o, a, s);
|
|
3228
|
+
return Array.isArray(e) ? typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? this.matchValues(e, r, (o) => k(o, t, n)) : t !== null && typeof t == "object" ? this.matchValues(e, r, (o) => G(o, t)) : !!J(e, t) : k(e, t, n);
|
|
3147
3229
|
}
|
|
3148
3230
|
validateQuery(e) {
|
|
3149
3231
|
if (this.queryBuilder.isQuery(e)) {
|
|
@@ -3156,12 +3238,12 @@ class ot {
|
|
|
3156
3238
|
return !0;
|
|
3157
3239
|
} else {
|
|
3158
3240
|
if (this.queryBuilder.isQueryGroup(e))
|
|
3159
|
-
return
|
|
3241
|
+
return _(e.queries, (t) => this.validateQuery(t));
|
|
3160
3242
|
throw new Error("invalid query - missing query or attribute");
|
|
3161
3243
|
}
|
|
3162
3244
|
}
|
|
3163
3245
|
getEvaluatedQueryDataset(e, t, r, s) {
|
|
3164
|
-
const
|
|
3246
|
+
const n = /* @__PURE__ */ new Map();
|
|
3165
3247
|
if (t.attribute.includes("[*]")) {
|
|
3166
3248
|
const o = t.options?.invert === !0, a = /* @__PURE__ */ new Set();
|
|
3167
3249
|
for (let c of r.values()) {
|
|
@@ -3184,13 +3266,13 @@ class ot {
|
|
|
3184
3266
|
d,
|
|
3185
3267
|
t.options?.arrayValueHandling || "some",
|
|
3186
3268
|
(h) => this.evaluateQuery(h, c)
|
|
3187
|
-
) && (a.add(c.key), o ||
|
|
3269
|
+
) && (a.add(c.key), o || n.set(c.key, c));
|
|
3188
3270
|
}
|
|
3189
3271
|
if (o)
|
|
3190
3272
|
for (const [c, u] of r)
|
|
3191
|
-
a.has(c) ||
|
|
3273
|
+
a.has(c) || n.set(c, u);
|
|
3192
3274
|
} else return t.operator === "eq" ? this.evaluateEqOperator(e, t, r, s) : t.operator === "in" ? this.evaluateInOperator(e, t, r, s) : this.scanDataset(e, t, r);
|
|
3193
|
-
return
|
|
3275
|
+
return n;
|
|
3194
3276
|
}
|
|
3195
3277
|
handleArrayStarQuery(e, t) {
|
|
3196
3278
|
const r = e.attribute.indexOf("[*]"), s = {
|
|
@@ -3199,7 +3281,7 @@ class ot {
|
|
|
3199
3281
|
queries: []
|
|
3200
3282
|
};
|
|
3201
3283
|
if (r !== -1) {
|
|
3202
|
-
const
|
|
3284
|
+
const n = e.attribute.substring(0, r), o = n.includes(".") ? I(t, n) : t[n];
|
|
3203
3285
|
if (Array.isArray(o))
|
|
3204
3286
|
for (let a = 0; a < o.length; a++) {
|
|
3205
3287
|
const c = e.attribute.replace("[*]", `[${a}]`);
|
|
@@ -3213,30 +3295,31 @@ class ot {
|
|
|
3213
3295
|
}
|
|
3214
3296
|
return s;
|
|
3215
3297
|
}
|
|
3216
|
-
evaluateQueryGroup(e, t, r, s,
|
|
3298
|
+
evaluateQueryGroup(e, t, r, s, n) {
|
|
3217
3299
|
let o = /* @__PURE__ */ new Map(), a = r;
|
|
3218
3300
|
if (!t.queries || t.queries?.length === 0)
|
|
3219
3301
|
return a;
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3302
|
+
const c = t.groupType === "or";
|
|
3303
|
+
for (const u of t.queries) {
|
|
3304
|
+
let f = /* @__PURE__ */ new Map();
|
|
3305
|
+
if (this.queryBuilder.isQuery(u) ? f = this.getEvaluatedQueryDataset(e, u, a, n) : f = this.evaluateQueryGroup(e, u, a, s, n), o.size === 0 && (o = f), c)
|
|
3306
|
+
f.forEach((d) => {
|
|
3307
|
+
o.set(d.key, d);
|
|
3308
|
+
}), a = r;
|
|
3226
3309
|
else {
|
|
3227
|
-
const
|
|
3228
|
-
for (const
|
|
3229
|
-
o.delete(
|
|
3310
|
+
const d = O(Array.from(o.values()), Array.from(f.values()), "key");
|
|
3311
|
+
for (const l of d)
|
|
3312
|
+
o.delete(l.key);
|
|
3313
|
+
a = o;
|
|
3230
3314
|
}
|
|
3231
|
-
t.groupType === "and" ? a = o : a = r;
|
|
3232
3315
|
}
|
|
3233
3316
|
return o;
|
|
3234
3317
|
}
|
|
3235
3318
|
queryData(e, t, r, s) {
|
|
3236
3319
|
if (t.queries.length === 0)
|
|
3237
3320
|
return e;
|
|
3238
|
-
const
|
|
3239
|
-
return t.groupKey || (t.groupKey = "root"), t.groupType || (t.groupType = "and"), t.queries || (t.queries = []), this.validateQuery(t), this.evaluateQueryGroup(t, t,
|
|
3321
|
+
const n = new Map(e);
|
|
3322
|
+
return t.groupKey || (t.groupKey = "root"), t.groupType || (t.groupType = "and"), t.queries || (t.queries = []), this.validateQuery(t), this.evaluateQueryGroup(t, t, n, r, s);
|
|
3240
3323
|
}
|
|
3241
3324
|
// public getRelevantQueryData(data: any, options: DcuplGlobalQueryOptions<any>, model: DcuplModel<ListItem>) {
|
|
3242
3325
|
// // detect if any of the query attributes are a deep query.
|
|
@@ -3282,51 +3365,56 @@ const Oe = /* @__PURE__ */ new Set([
|
|
|
3282
3365
|
"manager-key",
|
|
3283
3366
|
"sdk-key"
|
|
3284
3367
|
]);
|
|
3285
|
-
function
|
|
3286
|
-
const e =
|
|
3287
|
-
if (e < 0) return
|
|
3288
|
-
const t =
|
|
3368
|
+
function ct(i) {
|
|
3369
|
+
const e = i.indexOf("?");
|
|
3370
|
+
if (e < 0) return i;
|
|
3371
|
+
const t = i.slice(e + 1).split("&").map((r) => {
|
|
3289
3372
|
const s = r.indexOf("=");
|
|
3290
3373
|
if (s < 0) return r;
|
|
3291
|
-
const
|
|
3292
|
-
return Oe.has(
|
|
3374
|
+
const n = r.slice(0, s);
|
|
3375
|
+
return Oe.has(n.toLowerCase()) ? `${n}=<redacted>` : r;
|
|
3293
3376
|
}).join("&");
|
|
3294
|
-
return `${
|
|
3377
|
+
return `${i.slice(0, e)}?${t}`;
|
|
3295
3378
|
}
|
|
3296
|
-
const
|
|
3297
|
-
function
|
|
3298
|
-
if (
|
|
3299
|
-
return `${
|
|
3379
|
+
const Ge = "k:", Re = "h:";
|
|
3380
|
+
function M(i, e = 0) {
|
|
3381
|
+
if (i.key)
|
|
3382
|
+
return `${Ge}${i.key}`;
|
|
3300
3383
|
const t = D({
|
|
3301
|
-
type:
|
|
3302
|
-
url:
|
|
3303
|
-
model:
|
|
3384
|
+
type: i.type,
|
|
3385
|
+
url: i.rawUrl ?? i.url,
|
|
3386
|
+
model: i.model ?? "",
|
|
3304
3387
|
occurrence: e
|
|
3305
3388
|
});
|
|
3306
3389
|
return `${Re}${t}`;
|
|
3307
3390
|
}
|
|
3308
|
-
function
|
|
3391
|
+
function ut(i) {
|
|
3309
3392
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
|
|
3310
|
-
return
|
|
3393
|
+
return i.map((r) => {
|
|
3311
3394
|
const s = `${r.key ?? ""}|${r.type}|${r.rawUrl ?? r.url}|${r.model ?? ""}`;
|
|
3312
|
-
let
|
|
3395
|
+
let n = e.get(s) ?? 0, o = M(r, n);
|
|
3313
3396
|
for (; t.has(o); )
|
|
3314
|
-
|
|
3315
|
-
return e.set(s,
|
|
3397
|
+
n += 1, o = r.key ? `${M(r)}#${n}` : M(r, n);
|
|
3398
|
+
return e.set(s, n + 1), t.add(o), o;
|
|
3316
3399
|
});
|
|
3317
3400
|
}
|
|
3318
|
-
function
|
|
3319
|
-
const
|
|
3320
|
-
return typeof
|
|
3321
|
-
const t = new
|
|
3401
|
+
function ft() {
|
|
3402
|
+
const i = globalThis;
|
|
3403
|
+
return typeof i.scheduler?.yield == "function" ? i.scheduler.yield() : typeof i.setImmediate == "function" ? new Promise((e) => i.setImmediate(() => e())) : typeof i.MessageChannel == "function" ? new Promise((e) => {
|
|
3404
|
+
const t = new i.MessageChannel();
|
|
3322
3405
|
t.port1.onmessage = () => {
|
|
3323
3406
|
t.port1.close(), e();
|
|
3324
3407
|
}, t.port2.postMessage(null);
|
|
3325
3408
|
}) : new Promise((e) => setTimeout(e, 0));
|
|
3326
3409
|
}
|
|
3327
|
-
|
|
3410
|
+
const Te = (i, e) => new Function(...e, i);
|
|
3411
|
+
class dt {
|
|
3328
3412
|
scripts = /* @__PURE__ */ new Map();
|
|
3329
3413
|
scriptFunctions = /* @__PURE__ */ new Map();
|
|
3414
|
+
/** How script text becomes a function; hosts running untrusted code swap in a sandboxed compiler. */
|
|
3415
|
+
compiler = Te;
|
|
3416
|
+
/** `false` refuses to run any script; set from `DcuplInitOptions.scripting.enabled`. */
|
|
3417
|
+
enabled = !0;
|
|
3330
3418
|
constructor() {
|
|
3331
3419
|
}
|
|
3332
3420
|
keys() {
|
|
@@ -3350,8 +3438,8 @@ class ft {
|
|
|
3350
3438
|
const r = this.getScript(e);
|
|
3351
3439
|
if (!r)
|
|
3352
3440
|
throw new Error(`Script ${e} not found`);
|
|
3353
|
-
const s = this.getWrapperScript(r),
|
|
3354
|
-
return this.scriptFunctions.set(e,
|
|
3441
|
+
const s = this.getWrapperScript(r), n = this.compiler(s, ["script_type", ...t]);
|
|
3442
|
+
return this.scriptFunctions.set(e, n), n;
|
|
3355
3443
|
}
|
|
3356
3444
|
getWrapperScript(e) {
|
|
3357
3445
|
return `
|
|
@@ -3360,17 +3448,19 @@ class ft {
|
|
|
3360
3448
|
`;
|
|
3361
3449
|
}
|
|
3362
3450
|
executeScript(e, t, r) {
|
|
3451
|
+
if (!this.enabled)
|
|
3452
|
+
throw new Error("Scripting is disabled for this dcupl instance");
|
|
3363
3453
|
if (!this.getScript(e))
|
|
3364
3454
|
throw new Error(`Script ${e} not found`);
|
|
3365
3455
|
r.context || (r.context = r.options || {});
|
|
3366
|
-
const
|
|
3367
|
-
return this.getScriptAsFn(e,
|
|
3456
|
+
const n = Object.keys(r), o = Object.values(r);
|
|
3457
|
+
return this.getScriptAsFn(e, n)(t, ...o);
|
|
3368
3458
|
}
|
|
3369
3459
|
}
|
|
3370
|
-
const
|
|
3460
|
+
const lt = (i, e) => i ? (e || (e = {}), i.replace(/\$\{(.*?)\}/g, (t, r) => I(e, r.trim(), ""))) : "", ht = (i) => {
|
|
3371
3461
|
const e = /* @__PURE__ */ new Set();
|
|
3372
|
-
return
|
|
3373
|
-
},
|
|
3462
|
+
return i.replace(/\$\{(.*?)\}/g, (r, s) => (e.add(s.trim()), "")), { variables: Array.from(e).map((r) => ({ name: r })) };
|
|
3463
|
+
}, pt = [
|
|
3374
3464
|
"any",
|
|
3375
3465
|
"Array<date>",
|
|
3376
3466
|
"Array<float>",
|
|
@@ -3382,7 +3472,7 @@ const dt = (n, e) => n ? (e || (e = {}), n.replace(/\$\{(.*?)\}/g, (t, r) => I(e
|
|
|
3382
3472
|
"int",
|
|
3383
3473
|
"json",
|
|
3384
3474
|
"string"
|
|
3385
|
-
],
|
|
3475
|
+
], gt = ["int", "float", "Array<int>", "Array<float>"], yt = ["date", "Array<date>"], mt = [
|
|
3386
3476
|
"eq",
|
|
3387
3477
|
"in",
|
|
3388
3478
|
"find",
|
|
@@ -3395,67 +3485,68 @@ const dt = (n, e) => n ? (e || (e = {}), n.replace(/\$\{(.*?)\}/g, (t, r) => I(e
|
|
|
3395
3485
|
"size"
|
|
3396
3486
|
];
|
|
3397
3487
|
export {
|
|
3398
|
-
|
|
3488
|
+
Ge as AUTHORED_RESOURCE_ID_PREFIX,
|
|
3399
3489
|
Fe as AnalyticsController,
|
|
3400
|
-
|
|
3490
|
+
Pe as AttributeDependencyGraph,
|
|
3401
3491
|
_e as CacheController,
|
|
3402
|
-
|
|
3492
|
+
Je as ChangeDetector,
|
|
3403
3493
|
Re as DERIVED_RESOURCE_ID_PREFIX,
|
|
3404
|
-
|
|
3494
|
+
yt as DatePropertyTypes,
|
|
3405
3495
|
L as DcuplQueryBuilder,
|
|
3406
|
-
|
|
3496
|
+
mt as DcuplQueryOperatorsAsArray,
|
|
3407
3497
|
de as DeepQueryService,
|
|
3408
3498
|
X as DependencyGraph,
|
|
3409
3499
|
xe as IndicesController,
|
|
3410
3500
|
g as Logger,
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3501
|
+
gt as NumberPropertyTypes,
|
|
3502
|
+
pt as PropertyTypesAsArray,
|
|
3503
|
+
at as QueryManager,
|
|
3504
|
+
dt as ScriptController,
|
|
3415
3505
|
B as clone,
|
|
3416
3506
|
Ke as coerceStringType,
|
|
3417
3507
|
re as compareVersions,
|
|
3418
|
-
|
|
3508
|
+
Xe as computeSuggestions,
|
|
3419
3509
|
m as deepQueryService,
|
|
3510
|
+
Te as defaultScriptCompiler,
|
|
3420
3511
|
te as escapeRegExp,
|
|
3421
|
-
|
|
3422
|
-
|
|
3512
|
+
lt as evaluateTemplate,
|
|
3513
|
+
st as generateBooleanQuery,
|
|
3423
3514
|
ee as generateKey,
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3515
|
+
nt as generateNumberAndDateQuery,
|
|
3516
|
+
it as generateReferenceQuery,
|
|
3517
|
+
rt as generateTextQuery,
|
|
3427
3518
|
C as getAggregation,
|
|
3428
|
-
|
|
3519
|
+
Be as getDateConstraintUid,
|
|
3429
3520
|
$e as getDcuplPropertyTypeForNativeType,
|
|
3430
3521
|
w as getDeepPathValues,
|
|
3431
3522
|
me as getDistinct,
|
|
3432
|
-
|
|
3523
|
+
et as getFacets,
|
|
3433
3524
|
ze as getFilterEntryId,
|
|
3434
3525
|
je as getNumberConstraintUid,
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3526
|
+
tt as getPropertiesForData,
|
|
3527
|
+
Ue as groupBy,
|
|
3528
|
+
He as hasMinimumVersion,
|
|
3529
|
+
Ee as inferModel,
|
|
3439
3530
|
se as isDateInstance,
|
|
3440
3531
|
Ce as isFloat,
|
|
3441
|
-
|
|
3532
|
+
Ne as isInt,
|
|
3442
3533
|
ne as isValidDate,
|
|
3443
|
-
|
|
3534
|
+
ot as isValidQueryStatement,
|
|
3444
3535
|
T as isValidVersion,
|
|
3445
3536
|
Y as logger,
|
|
3446
3537
|
ke as looksDateLike,
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3538
|
+
Ye as parseDate,
|
|
3539
|
+
j as parseRegexLiteral,
|
|
3540
|
+
ht as parseTemplate,
|
|
3450
3541
|
b as perf,
|
|
3451
3542
|
U as pivot,
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3543
|
+
ct as redactUrl,
|
|
3544
|
+
We as removeTrailingSlash,
|
|
3545
|
+
M as resolveResourceId,
|
|
3546
|
+
ut as resolveResourceIds,
|
|
3547
|
+
Ze as trigger,
|
|
3548
|
+
Ve as unescapeRegExp,
|
|
3549
|
+
Le as uniqBy,
|
|
3550
|
+
ft as yieldToEventLoop
|
|
3460
3551
|
};
|
|
3461
3552
|
//# sourceMappingURL=index.js.map
|