@dcupl/common 2.0.0-beta.2 → 2.0.0-beta.5
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/analytics.controller.d.ts +1 -1
- package/dist/esm/changeDetection.d.ts +2 -2
- package/dist/esm/computeSuggestions.d.ts +2 -2
- package/dist/esm/deep-query.service.d.ts +1 -1
- package/dist/esm/getAggregation.d.ts +1 -1
- package/dist/esm/getFacets.d.ts +2 -2
- package/dist/esm/helper.d.ts +1 -1
- package/dist/esm/index.d.ts +22 -22
- package/dist/esm/index.js +341 -313
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/indices.controller.d.ts +1 -1
- package/dist/esm/logger/index.d.ts +2 -2
- package/dist/esm/pivot.d.ts +2 -2
- package/dist/esm/property-parser.d.ts +7 -2
- package/dist/esm/query-builder.d.ts +2 -2
- package/dist/esm/query.helper.d.ts +1 -1
- package/dist/esm/queryData.d.ts +2 -2
- package/dist/esm/types/app-loader.types.d.ts +3 -3
- package/dist/esm/types/data.types.d.ts +2 -1
- package/dist/esm/types/dcupl.types.d.ts +9 -9
- package/dist/esm/types/facets.types.d.ts +1 -1
- package/dist/esm/types/filter.types.d.ts +3 -3
- package/dist/esm/types/group-by.types.d.ts +2 -2
- package/dist/esm/types/index.d.ts +16 -16
- package/dist/esm/types/internal.types.d.ts +1 -1
- package/dist/esm/types/list.types.d.ts +4 -4
- package/dist/esm/types/model.types.d.ts +20 -3
- package/dist/esm/types/query.types.d.ts +2 -2
- package/dist/esm/types/section.types.d.ts +2 -2
- package/dist/esm/types/suggestion.types.d.ts +1 -1
- 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,18 +1,18 @@
|
|
|
1
|
-
import { cloneDeep as m, get as
|
|
1
|
+
import { cloneDeep as m, get as D, every as j, findIndex as E, size as L, isEqual as q, differenceBy as O, startsWith as H, endsWith as V, isEqualWith as b, isMatch as U, find as J } from "lodash-es";
|
|
2
2
|
function Q(o) {
|
|
3
|
-
const e =
|
|
3
|
+
const e = K(o);
|
|
4
4
|
return Z(e);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function K(o) {
|
|
7
7
|
if (typeof o != "object" || o === null)
|
|
8
8
|
return String(o);
|
|
9
9
|
if (Array.isArray(o))
|
|
10
|
-
return "[" + o.map(
|
|
10
|
+
return "[" + o.map(K).join(",") + "]";
|
|
11
11
|
const e = Object.keys(o).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 + ":" + K(o[s]), r < e.length - 1 && (t += ",");
|
|
16
16
|
}
|
|
17
17
|
return t += "}", t;
|
|
18
18
|
}
|
|
@@ -24,7 +24,7 @@ function Z(o) {
|
|
|
24
24
|
}
|
|
25
25
|
return e.toString(16);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const A = {
|
|
28
28
|
now: () => typeof performance < "u" && performance.now ? performance.now() : (/* @__PURE__ */ new Date()).getTime(),
|
|
29
29
|
mark: (o) => {
|
|
30
30
|
typeof performance < "u" && performance.mark && performance.mark(o);
|
|
@@ -41,7 +41,7 @@ const x = {
|
|
|
41
41
|
return performance.getEntriesByType(o);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
class
|
|
44
|
+
class Ie {
|
|
45
45
|
data;
|
|
46
46
|
enabled = !1;
|
|
47
47
|
constructor() {
|
|
@@ -59,7 +59,7 @@ class Ke {
|
|
|
59
59
|
const t = this.getKey(e.name, e.context), r = {
|
|
60
60
|
name: e.name,
|
|
61
61
|
type: "mark",
|
|
62
|
-
value:
|
|
62
|
+
value: A.now(),
|
|
63
63
|
createdAt: Date.now()
|
|
64
64
|
};
|
|
65
65
|
return this.data.set(t, r), r;
|
|
@@ -71,11 +71,11 @@ class Ke {
|
|
|
71
71
|
return;
|
|
72
72
|
const i = s.value - r.value, n = Math.round(i * 100) / 100, a = this.data.get(t);
|
|
73
73
|
if (a && e.sum) {
|
|
74
|
-
const
|
|
74
|
+
const c = a.value + n, f = {
|
|
75
75
|
...a,
|
|
76
|
-
value:
|
|
76
|
+
value: c
|
|
77
77
|
};
|
|
78
|
-
return this.data.set(t,
|
|
78
|
+
return this.data.set(t, f), f;
|
|
79
79
|
}
|
|
80
80
|
const u = {
|
|
81
81
|
name: e.name,
|
|
@@ -96,7 +96,7 @@ class Ke {
|
|
|
96
96
|
return this.data.get(t);
|
|
97
97
|
}
|
|
98
98
|
getResourceInfosFromPerformanceAPI() {
|
|
99
|
-
return typeof performance > "u" ? [] :
|
|
99
|
+
return typeof performance > "u" ? [] : A.getEntriesByType("resource");
|
|
100
100
|
}
|
|
101
101
|
get(e) {
|
|
102
102
|
const t = this.getKey(e.name, e.context);
|
|
@@ -118,7 +118,7 @@ class Ke {
|
|
|
118
118
|
return e + "_" + r;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
let Y = class
|
|
121
|
+
let Y = class B {
|
|
122
122
|
nodes;
|
|
123
123
|
edges;
|
|
124
124
|
nodeKinds = /* @__PURE__ */ new Map();
|
|
@@ -253,8 +253,8 @@ let Y = class j {
|
|
|
253
253
|
r.add(a);
|
|
254
254
|
const u = this.edges.get(a);
|
|
255
255
|
if (u)
|
|
256
|
-
for (let
|
|
257
|
-
n(
|
|
256
|
+
for (let c of u)
|
|
257
|
+
n(c);
|
|
258
258
|
r.delete(a), t.add(a), s.push(a);
|
|
259
259
|
};
|
|
260
260
|
for (let a of this.nodes)
|
|
@@ -340,8 +340,8 @@ let Y = class j {
|
|
|
340
340
|
i.add(a);
|
|
341
341
|
const u = this.edges.get(a);
|
|
342
342
|
if (u)
|
|
343
|
-
for (const
|
|
344
|
-
t.set(
|
|
343
|
+
for (const c of u)
|
|
344
|
+
t.set(c, (t.get(c) || 0) - 1), (t.get(c) || 0) === 0 && s.push(c);
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
if (i.size !== this.nodes.size)
|
|
@@ -362,23 +362,23 @@ let Y = 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), i = (
|
|
366
|
-
const
|
|
367
|
-
for (;
|
|
368
|
-
const
|
|
369
|
-
for (const [
|
|
370
|
-
h.has(
|
|
365
|
+
const s = new Set(e), i = (c) => !r || r.length === 0 || r.includes(this.nodeKinds.get(c) ?? void 0), n = () => {
|
|
366
|
+
const c = /* @__PURE__ */ new Set(), f = Array.from(s);
|
|
367
|
+
for (; f.length; ) {
|
|
368
|
+
const l = f.shift();
|
|
369
|
+
for (const [d, h] of this.edges)
|
|
370
|
+
h.has(l) && !c.has(d) && (c.add(d), f.push(d));
|
|
371
371
|
}
|
|
372
|
-
return
|
|
372
|
+
return c;
|
|
373
373
|
}, a = () => {
|
|
374
|
-
const
|
|
375
|
-
for (;
|
|
376
|
-
const
|
|
377
|
-
if (
|
|
378
|
-
for (const h of
|
|
379
|
-
|
|
374
|
+
const c = /* @__PURE__ */ new Set(), f = Array.from(s);
|
|
375
|
+
for (; f.length; ) {
|
|
376
|
+
const l = f.shift(), d = this.edges.get(l);
|
|
377
|
+
if (d)
|
|
378
|
+
for (const h of d)
|
|
379
|
+
c.has(h) || (c.add(h), f.push(h));
|
|
380
380
|
}
|
|
381
|
-
return
|
|
381
|
+
return c;
|
|
382
382
|
};
|
|
383
383
|
let u;
|
|
384
384
|
return t === "both" ? u = /* @__PURE__ */ new Set([...n(), ...a()]) : t === "upstream" ? u = a() : u = n(), Array.from(u).filter(i);
|
|
@@ -392,7 +392,7 @@ let Y = class j {
|
|
|
392
392
|
return { nodes: e, edges: t };
|
|
393
393
|
}
|
|
394
394
|
static fromJSON(e) {
|
|
395
|
-
const t = new
|
|
395
|
+
const t = new B();
|
|
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 Y = 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((
|
|
404
|
-
for (const
|
|
405
|
-
const
|
|
406
|
-
|
|
403
|
+
const t = new Set(this.getNodes()), r = new Set(e.getNodes()), s = Array.from(r).filter((l) => !t.has(l)), i = Array.from(t).filter((l) => !r.has(l)), n = new Set(this.getAllEdges().map((l) => l.join("→"))), a = new Set(e.getAllEdges().map((l) => l.join("→"))), u = Array.from(a).filter((l) => !n.has(l)).map((l) => l.split("→")), c = Array.from(n).filter((l) => !a.has(l)).map((l) => l.split("→")), f = [];
|
|
404
|
+
for (const l of /* @__PURE__ */ new Set([...t, ...r])) {
|
|
405
|
+
const d = this.nodeKinds.get(l), h = e.nodeKinds.get(l);
|
|
406
|
+
d !== h && f.push({ name: l, from: d, to: h });
|
|
407
407
|
}
|
|
408
|
-
return { addedNodes: s, removedNodes: i, addedEdges: u, removedEdges:
|
|
408
|
+
return { addedNodes: s, removedNodes: i, addedEdges: u, removedEdges: c, kindChanges: f };
|
|
409
409
|
}
|
|
410
410
|
};
|
|
411
|
-
class
|
|
411
|
+
class Qe {
|
|
412
412
|
graph;
|
|
413
413
|
nodeIndex;
|
|
414
414
|
constructor() {
|
|
@@ -800,7 +800,7 @@ class p {
|
|
|
800
800
|
}
|
|
801
801
|
}
|
|
802
802
|
const X = new p();
|
|
803
|
-
class
|
|
803
|
+
class Me {
|
|
804
804
|
constructor(e) {
|
|
805
805
|
this.enabled = e, this.cache = /* @__PURE__ */ new Map(), this.cacheDependencies = /* @__PURE__ */ new Map();
|
|
806
806
|
}
|
|
@@ -842,8 +842,8 @@ class Ie {
|
|
|
842
842
|
if (s.models.has(n))
|
|
843
843
|
if (s.modelAttributes.has(n)) {
|
|
844
844
|
const u = s.modelAttributes.get(n);
|
|
845
|
-
for (const
|
|
846
|
-
if (u.has(
|
|
845
|
+
for (const c of a)
|
|
846
|
+
if (u.has(c)) {
|
|
847
847
|
i = !0;
|
|
848
848
|
break;
|
|
849
849
|
}
|
|
@@ -939,7 +939,7 @@ class Ie {
|
|
|
939
939
|
};
|
|
940
940
|
}
|
|
941
941
|
}
|
|
942
|
-
const
|
|
942
|
+
const Ne = (o, e = "") => `${o}#${e}`, ke = (o) => `${o.gt}_${o.gte}_${o.lt}_${o.lte}_${o.eq}_${o.ne}`, Ce = (o) => `${o.gt}_${o.gte}_${o.lt}_${o.lte}_${o.eq}_${o.ne}`, Ee = (o, e) => {
|
|
943
943
|
const t = typeof e == "function" ? e : (r) => r[e];
|
|
944
944
|
return [
|
|
945
945
|
...o.reduce((r, s) => {
|
|
@@ -947,7 +947,7 @@ const Qe = (o, e = "") => `${o}#${e}`, Me = (o) => `${o.gt}_${o.gte}_${o.lt}_${o
|
|
|
947
947
|
return r.has(i) || r.set(i, s), r;
|
|
948
948
|
}, /* @__PURE__ */ new Map()).values()
|
|
949
949
|
];
|
|
950
|
-
},
|
|
950
|
+
}, qe = (o, e) => o.reduce(function(t, r) {
|
|
951
951
|
const s = typeof e == "function" ? e(r) : r[e];
|
|
952
952
|
return Object.prototype.hasOwnProperty.call(t, s) || (t[s] = []), t[s].push(r), t;
|
|
953
953
|
}, {});
|
|
@@ -957,7 +957,7 @@ function ee(o = 10) {
|
|
|
957
957
|
for (let r = 0; r < o; r++) e += t.charAt(Math.floor(Math.random() * t.length));
|
|
958
958
|
return e;
|
|
959
959
|
}
|
|
960
|
-
const
|
|
960
|
+
const Oe = (o) => o.replace(/\/+$/, ""), te = (o) => typeof o != "string" ? "" : o.replace(/[[\]{}()*+?.,\\^$|#]/g, "\\$&"), $e = (o) => typeof o != "string" ? "" : o.replace(/\\([[\]{}()*+?.,\\^$|#])/g, "$1"), Fe = (o, e) => {
|
|
961
961
|
try {
|
|
962
962
|
return re(o, e) >= 0;
|
|
963
963
|
} catch {
|
|
@@ -974,7 +974,7 @@ const Ee = (o) => o.replace(/\/+$/, ""), te = (o) => typeof o != "string" ? "" :
|
|
|
974
974
|
}
|
|
975
975
|
return 0;
|
|
976
976
|
}, F = (o) => /^\d+(\.\d+){0,2}$/.test(o);
|
|
977
|
-
class
|
|
977
|
+
class Ge {
|
|
978
978
|
key;
|
|
979
979
|
parentCd;
|
|
980
980
|
dcuplInitOptions;
|
|
@@ -1000,7 +1000,7 @@ class $e {
|
|
|
1000
1000
|
this.off && this.off();
|
|
1001
1001
|
}
|
|
1002
1002
|
trigger(e) {
|
|
1003
|
-
e.originCdRefKey || (e.originCdRefKey = this.key), e.key || (this.increaseCounter(), e.key = this.getCounter()), e.end || (e.end =
|
|
1003
|
+
e.originCdRefKey || (e.originCdRefKey = this.key), e.key || (this.increaseCounter(), e.key = this.getCounter()), e.end || (e.end = A.now(), e.duration = e.start - e.end), this.updateListener.forEach((t) => {
|
|
1004
1004
|
t(e);
|
|
1005
1005
|
});
|
|
1006
1006
|
}
|
|
@@ -1015,12 +1015,12 @@ const P = (o, e) => e ? typeof structuredClone < "u" ? structuredClone(o) : m(o)
|
|
|
1015
1015
|
const n = !!e.dcuplInitOptions.performance?.clone?.enabled && !!t.cloneResult, a = P(i, n);
|
|
1016
1016
|
if (t.scope === "list" && (t.listKey = o.cdRef?.key || o.key, t.modelKey = o.model?.key || o.modelKey), t.type === "list_created" && t.args[0].listKey.startsWith("__global_list__") || t.listKey?.startsWith("__global_list__"))
|
|
1017
1017
|
return a;
|
|
1018
|
-
const u =
|
|
1019
|
-
t.duration =
|
|
1020
|
-
const
|
|
1018
|
+
const u = A.now(), c = u - r, f = Math.round(c * 1e3) / 1e3;
|
|
1019
|
+
t.duration = f, t.start = r, t.end = u;
|
|
1020
|
+
const l = {
|
|
1021
1021
|
duration: t.duration
|
|
1022
1022
|
};
|
|
1023
|
-
return t.modelKey && (
|
|
1023
|
+
return t.modelKey && (l.model = t.modelKey), t.connectMessageResult && (t.result = a), t.args && (l.args = t.args), e?.trigger(t), e.analyticsController.mark({
|
|
1024
1024
|
name: `${t.type}:end`,
|
|
1025
1025
|
context: s
|
|
1026
1026
|
}), e.analyticsController.measure({
|
|
@@ -1028,62 +1028,62 @@ const P = (o, e) => e ? typeof structuredClone < "u" ? structuredClone(o) : m(o)
|
|
|
1028
1028
|
start: `${t.type}:start`,
|
|
1029
1029
|
end: `${t.type}:end`,
|
|
1030
1030
|
context: s,
|
|
1031
|
-
detail:
|
|
1031
|
+
detail: l
|
|
1032
1032
|
}), a;
|
|
1033
1033
|
} catch {
|
|
1034
1034
|
return i;
|
|
1035
1035
|
}
|
|
1036
|
-
},
|
|
1036
|
+
}, Te = (o) => (t, r, s) => {
|
|
1037
1037
|
const i = s.value;
|
|
1038
1038
|
return s.value = function(...n) {
|
|
1039
|
-
const a =
|
|
1040
|
-
|
|
1041
|
-
const
|
|
1039
|
+
const a = A.now(), u = this.cdRef, c = P(o, !0);
|
|
1040
|
+
c.key || (u.increaseCounter(), c.key = u.getCounter());
|
|
1041
|
+
const f = ee();
|
|
1042
1042
|
u.analyticsController.mark({
|
|
1043
|
-
name: `${
|
|
1044
|
-
context:
|
|
1043
|
+
name: `${c.type}:start`,
|
|
1044
|
+
context: f
|
|
1045
1045
|
});
|
|
1046
|
-
const
|
|
1047
|
-
!
|
|
1048
|
-
const
|
|
1049
|
-
return
|
|
1046
|
+
const l = this.model?.key;
|
|
1047
|
+
!c.originCdRefKey && u.key && (c.originCdRefKey = u.key), l && (c.modelKey = l);
|
|
1048
|
+
const d = i.apply(this, n);
|
|
1049
|
+
return c.method = r, c.args = n, d && typeof d == "object" && "then" in d ? d.then((h) => G(this, u, c, a, f, h)) : G(this, u, c, a, f, d);
|
|
1050
1050
|
}, s;
|
|
1051
1051
|
};
|
|
1052
|
-
function
|
|
1052
|
+
function je(o, e, t, r) {
|
|
1053
1053
|
t.max || (t.max = 20);
|
|
1054
1054
|
const s = [], i = t.transform ? r.transformValue(t.value, t.transform) : t.value;
|
|
1055
1055
|
for (const [n, a] of e.entries()) {
|
|
1056
|
-
const u = Array.from(a).some((
|
|
1056
|
+
const u = Array.from(a).some((f) => o.has(f)), c = t.transform ? r.transformValue(n, t.transform) : n;
|
|
1057
1057
|
if (!(t.excludeUndefineds && typeof n > "u") && !(t.excludeNulls && n === null)) {
|
|
1058
1058
|
if (u && (i === "" || i === "//")) {
|
|
1059
|
-
const
|
|
1059
|
+
const f = {
|
|
1060
1060
|
value: n,
|
|
1061
1061
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1062
1062
|
};
|
|
1063
|
-
s.push(
|
|
1063
|
+
s.push(f);
|
|
1064
1064
|
} else if (u && typeof i == "string" && i.startsWith("/") && i.endsWith("/")) {
|
|
1065
|
-
if (r.queryFind(
|
|
1066
|
-
const
|
|
1065
|
+
if (r.queryFind(c, i, "some")) {
|
|
1066
|
+
const f = {
|
|
1067
1067
|
value: n,
|
|
1068
1068
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1069
1069
|
};
|
|
1070
|
-
s.push(
|
|
1070
|
+
s.push(f);
|
|
1071
1071
|
}
|
|
1072
1072
|
} else if (u && typeof i == "string") {
|
|
1073
|
-
const
|
|
1074
|
-
if (
|
|
1075
|
-
const
|
|
1073
|
+
const f = String(c ?? ""), l = i;
|
|
1074
|
+
if (f.toLowerCase().startsWith(l.toLowerCase())) {
|
|
1075
|
+
const d = {
|
|
1076
1076
|
value: n,
|
|
1077
1077
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1078
1078
|
};
|
|
1079
|
-
s.push(
|
|
1079
|
+
s.push(d);
|
|
1080
1080
|
}
|
|
1081
|
-
} else if (u && r.queryFind(
|
|
1082
|
-
const
|
|
1081
|
+
} else if (u && r.queryFind(c, i, "some")) {
|
|
1082
|
+
const f = {
|
|
1083
1083
|
value: n,
|
|
1084
1084
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1085
1085
|
};
|
|
1086
|
-
s.push(
|
|
1086
|
+
s.push(f);
|
|
1087
1087
|
}
|
|
1088
1088
|
if (s.length === t.max)
|
|
1089
1089
|
break;
|
|
@@ -1270,7 +1270,7 @@ class fe {
|
|
|
1270
1270
|
this.graph.clear();
|
|
1271
1271
|
}
|
|
1272
1272
|
}
|
|
1273
|
-
class
|
|
1273
|
+
class le {
|
|
1274
1274
|
parseCache;
|
|
1275
1275
|
circularRefDetector;
|
|
1276
1276
|
cacheHits = 0;
|
|
@@ -1306,8 +1306,8 @@ class de {
|
|
|
1306
1306
|
if (r = e.split(/[.[]/)[0], i) {
|
|
1307
1307
|
const u = e.indexOf("]");
|
|
1308
1308
|
if (u > -1) {
|
|
1309
|
-
const
|
|
1310
|
-
|
|
1309
|
+
const c = e.indexOf(".", u + 1);
|
|
1310
|
+
c > -1 ? t = e.substring(c + 1) : t = void 0;
|
|
1311
1311
|
} else s && (t = e.substring(e.indexOf(".") + 1));
|
|
1312
1312
|
} else s && (t = e.substring(e.indexOf(".") + 1));
|
|
1313
1313
|
const a = {
|
|
@@ -1370,13 +1370,13 @@ class de {
|
|
|
1370
1370
|
const n = /\[([^\]]+)\]/g;
|
|
1371
1371
|
let a;
|
|
1372
1372
|
for (; (a = n.exec(e)) !== null; ) {
|
|
1373
|
-
const
|
|
1374
|
-
|
|
1373
|
+
const f = a[1];
|
|
1374
|
+
f && f !== "*" && !/^\d+$/.test(f) && r.push(`Invalid bracket content: Must be a number or '*', got '${f}' in ${e}`);
|
|
1375
1375
|
}
|
|
1376
1376
|
const u = (e.match(/\./g) || []).length + 1;
|
|
1377
1377
|
u > t && r.push(`Path too deep: Maximum depth is ${t}, got ${u} in ${e}`);
|
|
1378
|
-
const
|
|
1379
|
-
return
|
|
1378
|
+
const c = e.match(/[^a-zA-Z0-9._[\]*-]/g);
|
|
1379
|
+
return c && r.push(`Invalid characters in path: ${c.join(", ")} in ${e}`), {
|
|
1380
1380
|
valid: r.length === 0,
|
|
1381
1381
|
errors: r.length > 0 ? r : void 0
|
|
1382
1382
|
};
|
|
@@ -1435,20 +1435,42 @@ class de {
|
|
|
1435
1435
|
return this.getPathSegments(e).length;
|
|
1436
1436
|
}
|
|
1437
1437
|
}
|
|
1438
|
-
const g = new
|
|
1439
|
-
function
|
|
1440
|
-
if (
|
|
1441
|
-
const a =
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1438
|
+
const g = new le();
|
|
1439
|
+
function w(o, e) {
|
|
1440
|
+
if (e.includes("[*]")) {
|
|
1441
|
+
const i = e.indexOf("[*]"), n = e.substring(0, i), a = e.substring(i + 3), u = n ? D(o, n) : o;
|
|
1442
|
+
if (!Array.isArray(u)) return [];
|
|
1443
|
+
const c = [];
|
|
1444
|
+
for (const f of u)
|
|
1445
|
+
!a || a === "" ? f !== void 0 && c.push(f) : a.startsWith(".") && c.push(...w(f, a.slice(1)));
|
|
1446
|
+
return c;
|
|
1447
|
+
}
|
|
1448
|
+
const t = e.split(".");
|
|
1449
|
+
let r = [o];
|
|
1450
|
+
for (const i of t) {
|
|
1451
|
+
const n = [];
|
|
1452
|
+
for (const a of r)
|
|
1453
|
+
if (a != null)
|
|
1454
|
+
if (Array.isArray(a))
|
|
1455
|
+
for (const u of a) {
|
|
1456
|
+
if (u == null) continue;
|
|
1457
|
+
const c = u[i];
|
|
1458
|
+
c !== void 0 && n.push(c);
|
|
1459
|
+
}
|
|
1460
|
+
else {
|
|
1461
|
+
const u = a[i];
|
|
1462
|
+
u !== void 0 && n.push(u);
|
|
1463
|
+
}
|
|
1464
|
+
if (r = n, r.length === 0) return [];
|
|
1465
|
+
}
|
|
1466
|
+
const s = [];
|
|
1467
|
+
for (const i of r)
|
|
1468
|
+
if (Array.isArray(i))
|
|
1469
|
+
for (const n of i) n !== void 0 && s.push(n);
|
|
1470
|
+
else i !== void 0 && s.push(i);
|
|
1471
|
+
return s;
|
|
1450
1472
|
}
|
|
1451
|
-
function
|
|
1473
|
+
function S(o) {
|
|
1452
1474
|
let e = 0;
|
|
1453
1475
|
for (let t of o) {
|
|
1454
1476
|
const r = t.toString().split(".")[1];
|
|
@@ -1456,10 +1478,10 @@ function K(o) {
|
|
|
1456
1478
|
}
|
|
1457
1479
|
return Math.pow(10, e);
|
|
1458
1480
|
}
|
|
1459
|
-
function
|
|
1481
|
+
function T(o, e, t) {
|
|
1460
1482
|
return (o * t + e * t) / t;
|
|
1461
1483
|
}
|
|
1462
|
-
function
|
|
1484
|
+
function de(o, e, t) {
|
|
1463
1485
|
return o * t / (e * t);
|
|
1464
1486
|
}
|
|
1465
1487
|
const M = (o, e, t, r) => {
|
|
@@ -1470,30 +1492,42 @@ const M = (o, e, t, r) => {
|
|
|
1470
1492
|
types: o.types
|
|
1471
1493
|
};
|
|
1472
1494
|
let i;
|
|
1473
|
-
(s.types.includes("sum") || s.types.includes("avg")
|
|
1495
|
+
(s.types.includes("sum") || s.types.includes("avg")) && (i = ye(r, e));
|
|
1474
1496
|
let n;
|
|
1475
|
-
return (s.types.includes("min") || s.types.includes("max")) && (n =
|
|
1476
|
-
a === "sum" ? s.sum = i?.sum : a === "avg" ? s.avg = i?.average : a === "count" ? s.count =
|
|
1497
|
+
return (s.types.includes("min") || s.types.includes("max")) && (n = pe(r, e)), o.types.forEach((a) => {
|
|
1498
|
+
a === "sum" ? s.sum = i?.sum : a === "avg" ? s.avg = i?.average : a === "count" ? s.count = he(r, e) : a === "min" ? s.min = n && n[0] : a === "max" ? s.max = n && n[1] : a === "distinct" ? s.distinct = me(o, e, t) : a === "group" && (s.group = ge(o, e));
|
|
1477
1499
|
}), s;
|
|
1478
1500
|
}, he = (o, e) => {
|
|
1501
|
+
const r = g.parse(o).isDeepQuery;
|
|
1502
|
+
let s = 0;
|
|
1503
|
+
for (const i of e.values())
|
|
1504
|
+
if (i)
|
|
1505
|
+
if (r)
|
|
1506
|
+
s += w(i, o).filter((n) => n != null).length;
|
|
1507
|
+
else {
|
|
1508
|
+
const n = i[o];
|
|
1509
|
+
if (n == null) continue;
|
|
1510
|
+
Array.isArray(n) ? s += n.filter((a) => a != null).length : s++;
|
|
1511
|
+
}
|
|
1512
|
+
return s;
|
|
1513
|
+
}, pe = (o, e) => {
|
|
1479
1514
|
let t, r;
|
|
1480
1515
|
const i = g.parse(o).isDeepQuery;
|
|
1481
|
-
for (const n of e.values())
|
|
1482
|
-
if (n)
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
} else
|
|
1490
|
-
a = n[o] !== void 0 ? [n[o]] : [];
|
|
1491
|
-
for (const u of a)
|
|
1492
|
-
(t === void 0 || u < t) && (t = u), (r === void 0 || u > r) && (r = u);
|
|
1516
|
+
for (const n of e.values()) {
|
|
1517
|
+
if (!n) continue;
|
|
1518
|
+
let a;
|
|
1519
|
+
if (i)
|
|
1520
|
+
a = w(n, o);
|
|
1521
|
+
else {
|
|
1522
|
+
const u = n[o];
|
|
1523
|
+
u === void 0 ? a = [] : Array.isArray(u) ? a = u.filter((c) => c !== void 0) : a = [u];
|
|
1493
1524
|
}
|
|
1525
|
+
for (const u of a)
|
|
1526
|
+
u == null || typeof u == "object" || ((t === void 0 || u < t) && (t = u), (r === void 0 || u > r) && (r = u));
|
|
1527
|
+
}
|
|
1494
1528
|
if (!(t === void 0 || r === void 0))
|
|
1495
1529
|
return [t, r];
|
|
1496
|
-
},
|
|
1530
|
+
}, ge = (o, e) => {
|
|
1497
1531
|
const t = [];
|
|
1498
1532
|
o.groupOptions?.groups?.forEach((n) => {
|
|
1499
1533
|
t.push({
|
|
@@ -1509,45 +1543,38 @@ const M = (o, e, t, r) => {
|
|
|
1509
1543
|
}, i = g.parse(o.attribute).isDeepQuery;
|
|
1510
1544
|
for (const n of e.values()) {
|
|
1511
1545
|
let a;
|
|
1512
|
-
|
|
1513
|
-
a = A(n, o.attribute);
|
|
1514
|
-
else if (i) {
|
|
1515
|
-
const f = y(n, o.attribute);
|
|
1516
|
-
a = f !== void 0 ? [f] : [];
|
|
1517
|
-
} else
|
|
1518
|
-
a = [n[o.attribute]];
|
|
1546
|
+
i ? a = w(n, o.attribute) : a = [n[o.attribute]];
|
|
1519
1547
|
let u = !1;
|
|
1520
|
-
for (const
|
|
1521
|
-
for (const
|
|
1522
|
-
(typeof
|
|
1548
|
+
for (const c of a)
|
|
1549
|
+
for (const f of t)
|
|
1550
|
+
(typeof f.option.value < "u" && f.option.value.includes(c) || typeof f.option.from < "u" && f.option.from < c && typeof f.option.to < "u" && f.option.to > c) && (f.keys.includes(n.key) || (f.count++, f.keys.push(n.key)), u = !0);
|
|
1523
1551
|
!u && o?.groupOptions?.calculateNotFound && (r.count++, r.keys.push(n.key));
|
|
1524
1552
|
}
|
|
1525
1553
|
return o?.groupOptions?.calculateNotFound && t.push(r), t;
|
|
1526
|
-
},
|
|
1554
|
+
}, ye = (o, e) => {
|
|
1527
1555
|
let t = 0, r = 0;
|
|
1528
1556
|
const i = g.parse(o).isDeepQuery;
|
|
1529
|
-
for (const
|
|
1530
|
-
if (!
|
|
1531
|
-
let
|
|
1532
|
-
if (i
|
|
1533
|
-
|
|
1534
|
-
else
|
|
1535
|
-
const c =
|
|
1536
|
-
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
for (const c of f)
|
|
1557
|
+
for (const a of e.values()) {
|
|
1558
|
+
if (!a) continue;
|
|
1559
|
+
let u;
|
|
1560
|
+
if (i)
|
|
1561
|
+
u = w(a, o);
|
|
1562
|
+
else {
|
|
1563
|
+
const c = a[o];
|
|
1564
|
+
c === void 0 ? u = [] : Array.isArray(c) ? u = c : u = [c];
|
|
1565
|
+
}
|
|
1566
|
+
for (const c of u)
|
|
1540
1567
|
if (Array.isArray(c))
|
|
1541
|
-
for (const
|
|
1542
|
-
typeof
|
|
1543
|
-
else typeof c == "number" && (t =
|
|
1568
|
+
for (const f of c)
|
|
1569
|
+
typeof f == "number" && (t = T(t, f, S([t, f])), r++);
|
|
1570
|
+
else typeof c == "number" && (t = T(t, c, S([t, c])), r++);
|
|
1544
1571
|
}
|
|
1545
1572
|
return r === 0 ? void 0 : {
|
|
1546
|
-
average:
|
|
1547
|
-
count:
|
|
1573
|
+
average: de(t, r, S([t, r])),
|
|
1574
|
+
count: r,
|
|
1548
1575
|
sum: t
|
|
1549
1576
|
};
|
|
1550
|
-
},
|
|
1577
|
+
}, me = (o, e, t) => {
|
|
1551
1578
|
const r = [];
|
|
1552
1579
|
for (const [s, i] of t)
|
|
1553
1580
|
if (!(o.excludeUndefineds && typeof s > "u") && Array.from(i).find((n) => e.has(n))) {
|
|
@@ -1560,14 +1587,14 @@ const M = (o, e, t, r) => {
|
|
|
1560
1587
|
}
|
|
1561
1588
|
return r;
|
|
1562
1589
|
};
|
|
1563
|
-
class
|
|
1590
|
+
class x extends Error {
|
|
1564
1591
|
query;
|
|
1565
1592
|
constructor(e, t) {
|
|
1566
1593
|
const r = `Query Error: ${e} in ${JSON.stringify(t, null, 2)}`;
|
|
1567
1594
|
super(r), this.query = t, this.name = "DcuplQueryError";
|
|
1568
1595
|
}
|
|
1569
1596
|
}
|
|
1570
|
-
class
|
|
1597
|
+
class z {
|
|
1571
1598
|
_defaultQueryOptions = {
|
|
1572
1599
|
modelKey: "",
|
|
1573
1600
|
groupKey: "root",
|
|
@@ -1638,7 +1665,7 @@ class R {
|
|
|
1638
1665
|
}
|
|
1639
1666
|
validate(e) {
|
|
1640
1667
|
const t = e.queries.map((s) => this.validateQuery(s));
|
|
1641
|
-
return { valid:
|
|
1668
|
+
return { valid: j(t, (s) => s.valid), errors: t.map((s) => s.errors).flat() };
|
|
1642
1669
|
}
|
|
1643
1670
|
applyOptions(e, t = "update") {
|
|
1644
1671
|
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();
|
|
@@ -1744,12 +1771,12 @@ class R {
|
|
|
1744
1771
|
validateQuery(e) {
|
|
1745
1772
|
const t = [];
|
|
1746
1773
|
if (this.isQuery(e))
|
|
1747
|
-
return e.attribute || t.push(new
|
|
1774
|
+
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)), t.length > 0 ? { valid: !1, errors: t } : { valid: !0 };
|
|
1748
1775
|
if (this.isQueryGroup(e)) {
|
|
1749
1776
|
const i = e.queries.map((n) => this.validateQuery(n)).filter((n) => !n.valid).map((n) => n.errors).flat();
|
|
1750
1777
|
return i.length > 0 ? { valid: !1, errors: i } : { valid: !0 };
|
|
1751
1778
|
}
|
|
1752
|
-
return t.push(new
|
|
1779
|
+
return t.push(new x("Invalid query definition", e)), { valid: !1, errors: t };
|
|
1753
1780
|
}
|
|
1754
1781
|
/**
|
|
1755
1782
|
* Get all attribute names used in the query.
|
|
@@ -2248,28 +2275,28 @@ class R {
|
|
|
2248
2275
|
return e(this.currentQuery.queries);
|
|
2249
2276
|
}
|
|
2250
2277
|
}
|
|
2251
|
-
const I = new
|
|
2252
|
-
function
|
|
2253
|
-
const a = [], u = I.removeQuery({ groupKey: s }, m(r)),
|
|
2278
|
+
const I = new z();
|
|
2279
|
+
function Pe(o, e, t, r, s, i, n) {
|
|
2280
|
+
const a = [], u = I.removeQuery({ groupKey: s }, m(r)), c = n.queryData(o, u, !1, i), f = e ? [...e.keys()] : [], l = new Set(f), d = i.get(s);
|
|
2254
2281
|
if (!t.excludeUnresolved)
|
|
2255
|
-
for (const h of
|
|
2256
|
-
|
|
2257
|
-
t.excludeUndefineds ?
|
|
2258
|
-
for (const h of
|
|
2259
|
-
const
|
|
2282
|
+
for (const h of d.keys())
|
|
2283
|
+
l.add(h);
|
|
2284
|
+
t.excludeUndefineds ? l.delete(void 0) : l.add(void 0);
|
|
2285
|
+
for (const h of l.values()) {
|
|
2286
|
+
const y = /* @__PURE__ */ new Map(), W = d.get(h) || /* @__PURE__ */ new Set();
|
|
2260
2287
|
for (const k of W) {
|
|
2261
|
-
const C =
|
|
2262
|
-
if (C && (
|
|
2288
|
+
const C = c.get(k);
|
|
2289
|
+
if (C && (y.set(k, C), !t?.calculateFacets))
|
|
2263
2290
|
break;
|
|
2264
2291
|
}
|
|
2265
2292
|
const N = {
|
|
2266
2293
|
key: String(h),
|
|
2267
2294
|
value: h,
|
|
2268
|
-
selected:
|
|
2269
|
-
enabled:
|
|
2270
|
-
size:
|
|
2295
|
+
selected: ve(s, h, r),
|
|
2296
|
+
enabled: y.size > 0,
|
|
2297
|
+
size: y.size,
|
|
2271
2298
|
entry: e.get(h),
|
|
2272
|
-
resultKeys: Array.from(
|
|
2299
|
+
resultKeys: Array.from(y.keys())
|
|
2273
2300
|
};
|
|
2274
2301
|
if (!(t?.excludeZeros && N.size === 0)) {
|
|
2275
2302
|
if (t?.count && a.length === t?.count)
|
|
@@ -2279,7 +2306,7 @@ function Te(o, e, t, r, s, i, n) {
|
|
|
2279
2306
|
}
|
|
2280
2307
|
return a;
|
|
2281
2308
|
}
|
|
2282
|
-
const
|
|
2309
|
+
const ve = (o, e, t) => {
|
|
2283
2310
|
const r = t.queries.findIndex((s) => I.isQueryGroup(s) && s.groupKey === o);
|
|
2284
2311
|
return r > -1 ? !!t.queries[r].queries.find((i) => {
|
|
2285
2312
|
if (I.isQuery(i)) {
|
|
@@ -2289,7 +2316,7 @@ const me = (o, e, t) => {
|
|
|
2289
2316
|
return !1;
|
|
2290
2317
|
}) : !1;
|
|
2291
2318
|
};
|
|
2292
|
-
class
|
|
2319
|
+
class we {
|
|
2293
2320
|
indexMap = /* @__PURE__ */ new Map();
|
|
2294
2321
|
// Possible performance gain*
|
|
2295
2322
|
dataMap = /* @__PURE__ */ new Map();
|
|
@@ -2359,9 +2386,9 @@ class ve {
|
|
|
2359
2386
|
if (!i) {
|
|
2360
2387
|
this.reset(s), this.indexMap.set(s, /* @__PURE__ */ new Map());
|
|
2361
2388
|
const u = g.parse(e).isDeepQuery;
|
|
2362
|
-
for (const
|
|
2363
|
-
let
|
|
2364
|
-
u
|
|
2389
|
+
for (const c of t.values()) {
|
|
2390
|
+
let f;
|
|
2391
|
+
u ? (f = w(c, e), f.length === 0 && (f = [void 0])) : f = [c[e]], this.fillInverseIndex(s, c.key, f), this.fillDataMap(s, f);
|
|
2365
2392
|
}
|
|
2366
2393
|
i = this.getIndex(s) || /* @__PURE__ */ new Map();
|
|
2367
2394
|
}
|
|
@@ -2538,7 +2565,7 @@ class ve {
|
|
|
2538
2565
|
}
|
|
2539
2566
|
}
|
|
2540
2567
|
const v = "__";
|
|
2541
|
-
function
|
|
2568
|
+
function R(o, e, t = { key: "root" }, r = "root", s = new we(), i) {
|
|
2542
2569
|
const n = i || o;
|
|
2543
2570
|
for (const a of e.columns)
|
|
2544
2571
|
a.attribute && (g.parse(a.attribute), s.getOrCreateIndex(a.attribute, n));
|
|
@@ -2548,7 +2575,7 @@ function z(o, e, t = { key: "root" }, r = "root", s = new ve(), i) {
|
|
|
2548
2575
|
a.attribute && (g.parse(a.attribute), s.getOrCreateIndex(a.attribute, n));
|
|
2549
2576
|
if (e.rows && e.rows.length > 0) {
|
|
2550
2577
|
t.rows = t.rows || [];
|
|
2551
|
-
const a =
|
|
2578
|
+
const a = xe(o, e.rows[0], e, s, r, i);
|
|
2552
2579
|
t.rows.push(a);
|
|
2553
2580
|
}
|
|
2554
2581
|
if (e.columns && e.columns.length > 0) {
|
|
@@ -2565,46 +2592,46 @@ function z(o, e, t = { key: "root" }, r = "root", s = new ve(), i) {
|
|
|
2565
2592
|
}
|
|
2566
2593
|
return t;
|
|
2567
2594
|
}
|
|
2568
|
-
function
|
|
2595
|
+
function xe(o, e, t, r, s = "", i) {
|
|
2569
2596
|
const n = { key: e.attribute }, a = r.getIndex(e.attribute);
|
|
2570
2597
|
if (!a)
|
|
2571
2598
|
return n;
|
|
2572
|
-
for (const [u,
|
|
2573
|
-
const
|
|
2599
|
+
for (const [u, c] of a.entries()) {
|
|
2600
|
+
const f = {
|
|
2574
2601
|
key: u,
|
|
2575
2602
|
value: u
|
|
2576
|
-
},
|
|
2577
|
-
for (const
|
|
2578
|
-
o.has(
|
|
2579
|
-
if (
|
|
2580
|
-
for (const
|
|
2581
|
-
if (
|
|
2603
|
+
}, l = /* @__PURE__ */ new Map();
|
|
2604
|
+
for (const d of c)
|
|
2605
|
+
o.has(d) && l.set(d, o.get(d));
|
|
2606
|
+
if (l.size) {
|
|
2607
|
+
for (const d of t.values) {
|
|
2608
|
+
if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
|
|
2582
2609
|
continue;
|
|
2583
|
-
const h = M(
|
|
2584
|
-
|
|
2610
|
+
const h = M(d, l, r.getIndex(d.attribute), d.attribute);
|
|
2611
|
+
f.values.push(h);
|
|
2585
2612
|
}
|
|
2586
|
-
if (n.rows = n.rows || [], n.rows.push(
|
|
2587
|
-
const
|
|
2588
|
-
|
|
2589
|
-
d,
|
|
2613
|
+
if (n.rows = n.rows || [], n.rows.push(f), t.rows.length > 1) {
|
|
2614
|
+
const d = { ...t, rows: t.rows.slice(1) };
|
|
2615
|
+
R(
|
|
2590
2616
|
l,
|
|
2591
|
-
|
|
2617
|
+
d,
|
|
2618
|
+
f,
|
|
2592
2619
|
s + v + e.attribute + v + u,
|
|
2593
2620
|
r,
|
|
2594
2621
|
i
|
|
2595
2622
|
);
|
|
2596
2623
|
} else if (t.columns)
|
|
2597
|
-
for (const
|
|
2598
|
-
|
|
2624
|
+
for (const d of t.columns) {
|
|
2625
|
+
f.columns = f.columns || [];
|
|
2599
2626
|
const h = _(
|
|
2600
|
-
d,
|
|
2601
2627
|
l,
|
|
2628
|
+
d,
|
|
2602
2629
|
t,
|
|
2603
2630
|
r,
|
|
2604
2631
|
s + v + e.attribute + v + u,
|
|
2605
2632
|
i
|
|
2606
2633
|
);
|
|
2607
|
-
|
|
2634
|
+
f.columns.push(h);
|
|
2608
2635
|
}
|
|
2609
2636
|
}
|
|
2610
2637
|
}
|
|
@@ -2614,26 +2641,26 @@ function _(o, e, t, r, s = "", i) {
|
|
|
2614
2641
|
const n = { key: e.attribute }, a = r.getIndex(e.attribute);
|
|
2615
2642
|
if (!a)
|
|
2616
2643
|
return n;
|
|
2617
|
-
for (const [u,
|
|
2618
|
-
const
|
|
2644
|
+
for (const [u, c] of a.entries()) {
|
|
2645
|
+
const f = {
|
|
2619
2646
|
key: u,
|
|
2620
2647
|
value: u
|
|
2621
|
-
},
|
|
2622
|
-
for (const
|
|
2623
|
-
o.has(
|
|
2624
|
-
if (
|
|
2625
|
-
for (const
|
|
2626
|
-
if (
|
|
2648
|
+
}, l = /* @__PURE__ */ new Map();
|
|
2649
|
+
for (const d of c)
|
|
2650
|
+
o.has(d) && l.set(d, o.get(d));
|
|
2651
|
+
if (l.size) {
|
|
2652
|
+
for (const d of t.values) {
|
|
2653
|
+
if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
|
|
2627
2654
|
continue;
|
|
2628
|
-
const h = M(
|
|
2629
|
-
|
|
2655
|
+
const h = M(d, l, r.getIndex(d.attribute), d.attribute);
|
|
2656
|
+
f.values.push(h);
|
|
2630
2657
|
}
|
|
2631
|
-
if (n.columns = n.columns || [], n.columns.push(
|
|
2632
|
-
const
|
|
2633
|
-
|
|
2634
|
-
d,
|
|
2658
|
+
if (n.columns = n.columns || [], n.columns.push(f), t.columns.length > 1) {
|
|
2659
|
+
const d = { ...t, columns: t.columns.slice(1) };
|
|
2660
|
+
R(
|
|
2635
2661
|
l,
|
|
2636
|
-
|
|
2662
|
+
d,
|
|
2663
|
+
f,
|
|
2637
2664
|
s + v + e.attribute + v + u,
|
|
2638
2665
|
r,
|
|
2639
2666
|
i
|
|
@@ -2643,31 +2670,32 @@ function _(o, e, t, r, s = "", i) {
|
|
|
2643
2670
|
}
|
|
2644
2671
|
return n;
|
|
2645
2672
|
}
|
|
2646
|
-
const
|
|
2647
|
-
const t = [];
|
|
2648
|
-
for (
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2673
|
+
const Ae = (o) => o == null || o === "", ze = (o, e = !1) => {
|
|
2674
|
+
const t = typeof e == "boolean" ? { deep: e } : e, s = t.deep ?? (t.sampleSize !== void 0 && t.sampleSize > 1) ? t.sampleSize ?? 1 / 0 : 1, i = t.ignoreEmpty ?? s > 1, n = [], a = Math.min(o.length, s);
|
|
2675
|
+
for (let u = 0; u < a; u++) {
|
|
2676
|
+
const c = o[u];
|
|
2677
|
+
if (c)
|
|
2678
|
+
for (const [f, l] of Object.entries(c)) {
|
|
2679
|
+
if (i && Ae(l)) continue;
|
|
2680
|
+
const d = Se(l), h = n.find((y) => y.key === f);
|
|
2681
|
+
if (h)
|
|
2682
|
+
h.type !== d && (h.type = "any");
|
|
2683
|
+
else {
|
|
2684
|
+
const y = {
|
|
2685
|
+
key: f,
|
|
2686
|
+
type: d
|
|
2687
|
+
};
|
|
2688
|
+
n.push(y);
|
|
2689
|
+
}
|
|
2659
2690
|
}
|
|
2660
|
-
}
|
|
2661
|
-
if (!e)
|
|
2662
|
-
break;
|
|
2663
2691
|
}
|
|
2664
|
-
return
|
|
2665
|
-
},
|
|
2692
|
+
return n;
|
|
2693
|
+
}, be = (o) => Number(o) === o && o % 1 === 0, De = (o) => Number(o) === o && o % 1 !== 0, Se = (o) => {
|
|
2666
2694
|
switch (typeof o) {
|
|
2667
2695
|
case "string":
|
|
2668
2696
|
return "string";
|
|
2669
2697
|
case "number":
|
|
2670
|
-
return
|
|
2698
|
+
return be(o) ? "int" : De(o) ? "float" : "any";
|
|
2671
2699
|
case "boolean":
|
|
2672
2700
|
return "boolean";
|
|
2673
2701
|
case "object":
|
|
@@ -2675,7 +2703,7 @@ const je = (o, e) => {
|
|
|
2675
2703
|
default:
|
|
2676
2704
|
return "any";
|
|
2677
2705
|
}
|
|
2678
|
-
},
|
|
2706
|
+
}, Re = (o, e) => {
|
|
2679
2707
|
const t = te(o.text || ""), r = e?.attributeKey || o.filterKey;
|
|
2680
2708
|
let s;
|
|
2681
2709
|
const i = e?.comparisonType || "containsIgnoreCase";
|
|
@@ -2739,7 +2767,7 @@ const je = (o, e) => {
|
|
|
2739
2767
|
}
|
|
2740
2768
|
]
|
|
2741
2769
|
}), s;
|
|
2742
|
-
},
|
|
2770
|
+
}, _e = (o, e) => {
|
|
2743
2771
|
const t = e?.attributeKey || o.filterKey;
|
|
2744
2772
|
return {
|
|
2745
2773
|
groupKey: o.filterKey,
|
|
@@ -2752,7 +2780,7 @@ const je = (o, e) => {
|
|
|
2752
2780
|
}
|
|
2753
2781
|
]
|
|
2754
2782
|
};
|
|
2755
|
-
},
|
|
2783
|
+
}, We = (o, e) => {
|
|
2756
2784
|
const t = e?.attributeKey || o.filterKey, r = {
|
|
2757
2785
|
groupKey: o.filterKey,
|
|
2758
2786
|
queries: []
|
|
@@ -2767,7 +2795,7 @@ const je = (o, e) => {
|
|
|
2767
2795
|
operator: "eq",
|
|
2768
2796
|
options: { invert: !0 }
|
|
2769
2797
|
})), typeof o.gt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: o.gt, operator: "gt" })), typeof o.lt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: o.lt, operator: "lt" })), typeof o.gte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: o.gte, operator: "gte" })), typeof o.lte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: o.lte, operator: "lte" })), r;
|
|
2770
|
-
},
|
|
2798
|
+
}, Le = (o, e) => {
|
|
2771
2799
|
const t = e?.attributeKey || o.filterKey, r = {
|
|
2772
2800
|
groupKey: o.filterKey,
|
|
2773
2801
|
queries: []
|
|
@@ -2780,13 +2808,13 @@ const je = (o, e) => {
|
|
|
2780
2808
|
operator: "eq"
|
|
2781
2809
|
});
|
|
2782
2810
|
}), r;
|
|
2783
|
-
},
|
|
2784
|
-
class
|
|
2811
|
+
}, He = (o) => !(typeof o.modelKey != "string" || !Array.isArray(o.queries));
|
|
2812
|
+
class Ve {
|
|
2785
2813
|
constructor(e, t, r) {
|
|
2786
2814
|
this.scriptController = e, this.globalItemService = t, this.modelParser = r;
|
|
2787
2815
|
}
|
|
2788
2816
|
registeredCustomOperator = /* @__PURE__ */ new Map();
|
|
2789
|
-
queryBuilder = new
|
|
2817
|
+
queryBuilder = new z();
|
|
2790
2818
|
registerCustomOperator(e, t) {
|
|
2791
2819
|
this.registeredCustomOperator.set(e, t);
|
|
2792
2820
|
}
|
|
@@ -2802,11 +2830,11 @@ class Le {
|
|
|
2802
2830
|
evaluateQuery(e, t) {
|
|
2803
2831
|
let r, s = e.value;
|
|
2804
2832
|
const i = e.options?.arrayValueHandling || "some";
|
|
2805
|
-
if (Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (s = this.transformValue(s, e.options.transform)), e.attribute.includes(".") || e.attribute.includes("[") ? r =
|
|
2833
|
+
if (Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (s = this.transformValue(s, e.options.transform)), e.attribute.includes(".") || e.attribute.includes("[") ? r = D(t, e.attribute) : r = t[e.attribute], Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (r = this.transformValue(r, e.options.transform)), (typeof r > "u" || r === null) && !["typeof", "isTruthy", "eq"].includes(e.operator))
|
|
2806
2834
|
return !1;
|
|
2807
2835
|
switch (e.operator) {
|
|
2808
2836
|
case "eq":
|
|
2809
|
-
return e.options?.invert ? !
|
|
2837
|
+
return e.options?.invert ? !q(r, s) : q(r, s);
|
|
2810
2838
|
case "find":
|
|
2811
2839
|
return e.options?.invert ? !this.queryFind(r, s, i) : this.queryFind(r, s, i);
|
|
2812
2840
|
case "lt":
|
|
@@ -2841,25 +2869,25 @@ class Le {
|
|
|
2841
2869
|
if (typeof t.value == "string" ? a = t.value : t.value?.key && Object.keys(t.value).length === 1 && (a = t.value.key), typeof a < "u") {
|
|
2842
2870
|
const u = n.get(a);
|
|
2843
2871
|
if (u)
|
|
2844
|
-
if (u.forEach((
|
|
2845
|
-
r.has(
|
|
2872
|
+
if (u.forEach((c) => {
|
|
2873
|
+
r.has(c) && i.set(c, r.get(c));
|
|
2846
2874
|
}), t.options?.invert) {
|
|
2847
|
-
const
|
|
2848
|
-
return
|
|
2849
|
-
|
|
2850
|
-
}),
|
|
2875
|
+
const c = O(Array.from(r.values()), Array.from(i.values()), "key"), f = /* @__PURE__ */ new Map();
|
|
2876
|
+
return c.forEach((l) => {
|
|
2877
|
+
f.set(l.key, l);
|
|
2878
|
+
}), f;
|
|
2851
2879
|
} else
|
|
2852
2880
|
return i;
|
|
2853
2881
|
}
|
|
2854
2882
|
}
|
|
2855
2883
|
for (let [a, u] of r) {
|
|
2856
|
-
const
|
|
2857
|
-
if (
|
|
2858
|
-
const
|
|
2859
|
-
|
|
2884
|
+
const c = this.queryBuilder.extractQueryAttributes({ queries: [t] });
|
|
2885
|
+
if (c.some((f) => f.isDeepQuery)) {
|
|
2886
|
+
const f = this.queryBuilder.getProjectionForAttributeEntries(
|
|
2887
|
+
c.filter((l) => l.isDeepQuery)
|
|
2860
2888
|
);
|
|
2861
2889
|
u = this.globalItemService.getProjectedData(
|
|
2862
|
-
|
|
2890
|
+
f,
|
|
2863
2891
|
this.modelParser.models.get(e.modelKey),
|
|
2864
2892
|
u
|
|
2865
2893
|
);
|
|
@@ -2869,16 +2897,16 @@ class Le {
|
|
|
2869
2897
|
return i;
|
|
2870
2898
|
}
|
|
2871
2899
|
equalRegexFn(e, t) {
|
|
2872
|
-
if (typeof t == "string" && H(t, "/") &&
|
|
2900
|
+
if (typeof t == "string" && H(t, "/") && V(t, "/"))
|
|
2873
2901
|
try {
|
|
2874
2902
|
return new RegExp(t.slice(1, -1)).test(e);
|
|
2875
2903
|
} catch {
|
|
2876
2904
|
return !1;
|
|
2877
2905
|
}
|
|
2878
|
-
else return Array.isArray(e) ? !!e.find((r) =>
|
|
2906
|
+
else return Array.isArray(e) ? !!e.find((r) => b(r, t, this.equalRegexFn)) : typeof t == "object" ? U(e, t) : e === t;
|
|
2879
2907
|
}
|
|
2880
2908
|
queryFind(e, t, r) {
|
|
2881
|
-
return Array.isArray(e) ? typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? r === "some" ? e.some((s) =>
|
|
2909
|
+
return Array.isArray(e) ? typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? r === "some" ? e.some((s) => b(s, t, this.equalRegexFn)) : e.every((s) => b(s, t, this.equalRegexFn)) : !!J(e, t) : b(e, t, this.equalRegexFn);
|
|
2882
2910
|
}
|
|
2883
2911
|
validateQuery(e) {
|
|
2884
2912
|
if (this.queryBuilder.isQuery(e)) {
|
|
@@ -2889,7 +2917,7 @@ class Le {
|
|
|
2889
2917
|
return !0;
|
|
2890
2918
|
} else {
|
|
2891
2919
|
if (this.queryBuilder.isQueryGroup(e))
|
|
2892
|
-
return
|
|
2920
|
+
return j(e.queries, (t) => this.validateQuery(t));
|
|
2893
2921
|
throw new Error("invalid query - missing query or attribute");
|
|
2894
2922
|
}
|
|
2895
2923
|
}
|
|
@@ -2898,42 +2926,42 @@ class Le {
|
|
|
2898
2926
|
if (t.attribute.includes("[*]")) {
|
|
2899
2927
|
const n = t.options?.invert === !0, a = /* @__PURE__ */ new Set();
|
|
2900
2928
|
for (let u of r.values()) {
|
|
2901
|
-
const
|
|
2902
|
-
if (
|
|
2903
|
-
const
|
|
2904
|
-
|
|
2929
|
+
const c = this.queryBuilder.extractQueryAttributes({ queries: [t] });
|
|
2930
|
+
if (c.some((d) => d.isDeepQuery)) {
|
|
2931
|
+
const d = this.queryBuilder.getProjectionForAttributeEntries(
|
|
2932
|
+
c.filter((h) => h.isDeepQuery)
|
|
2905
2933
|
);
|
|
2906
2934
|
u = this.globalItemService.getProjectedData(
|
|
2907
|
-
|
|
2935
|
+
d,
|
|
2908
2936
|
this.modelParser.models.get(e.modelKey),
|
|
2909
2937
|
u
|
|
2910
2938
|
);
|
|
2911
2939
|
}
|
|
2912
|
-
const
|
|
2913
|
-
let
|
|
2914
|
-
for (const
|
|
2915
|
-
const h = { ...
|
|
2940
|
+
const f = this.handleArrayStarQuery(t, u);
|
|
2941
|
+
let l = !1;
|
|
2942
|
+
for (const d of f.queries) {
|
|
2943
|
+
const h = { ...d, options: { ...d.options, invert: !1 } };
|
|
2916
2944
|
if (this.evaluateQuery(h, u)) {
|
|
2917
|
-
|
|
2945
|
+
l = !0;
|
|
2918
2946
|
break;
|
|
2919
2947
|
}
|
|
2920
2948
|
}
|
|
2921
|
-
|
|
2949
|
+
l && (a.add(u.key), n || i.set(u.key, u));
|
|
2922
2950
|
}
|
|
2923
2951
|
if (n)
|
|
2924
|
-
for (const [u,
|
|
2925
|
-
a.has(u) || i.set(u,
|
|
2952
|
+
for (const [u, c] of r)
|
|
2953
|
+
a.has(u) || i.set(u, c);
|
|
2926
2954
|
} else {
|
|
2927
2955
|
if (t.operator === "eq")
|
|
2928
2956
|
return this.evaluateEqOperator(e, t, r, s);
|
|
2929
2957
|
for (let [n, a] of r) {
|
|
2930
2958
|
const u = this.queryBuilder.extractQueryAttributes({ queries: [t] });
|
|
2931
|
-
if (u.some((
|
|
2932
|
-
const
|
|
2933
|
-
u.filter((
|
|
2959
|
+
if (u.some((c) => c.isDeepQuery)) {
|
|
2960
|
+
const c = this.queryBuilder.getProjectionForAttributeEntries(
|
|
2961
|
+
u.filter((f) => f.isDeepQuery)
|
|
2934
2962
|
);
|
|
2935
2963
|
a = this.globalItemService.getProjectedData(
|
|
2936
|
-
|
|
2964
|
+
c,
|
|
2937
2965
|
this.modelParser.models.get(e.modelKey),
|
|
2938
2966
|
a
|
|
2939
2967
|
);
|
|
@@ -2950,7 +2978,7 @@ class Le {
|
|
|
2950
2978
|
queries: []
|
|
2951
2979
|
};
|
|
2952
2980
|
if (r !== -1) {
|
|
2953
|
-
const i = e.attribute.substring(0, r), n = i.includes(".") ?
|
|
2981
|
+
const i = e.attribute.substring(0, r), n = i.includes(".") ? D(t, i) : t[i];
|
|
2954
2982
|
if (Array.isArray(n))
|
|
2955
2983
|
for (let a = 0; a < n.length; a++) {
|
|
2956
2984
|
const u = e.attribute.replace("[*]", `[${a}]`);
|
|
@@ -2969,15 +2997,15 @@ class Le {
|
|
|
2969
2997
|
if (!t.queries || t.queries?.length === 0)
|
|
2970
2998
|
return a;
|
|
2971
2999
|
for (const u of t.queries) {
|
|
2972
|
-
let
|
|
2973
|
-
if (this.queryBuilder.isQuery(u) ?
|
|
2974
|
-
|
|
2975
|
-
n.set(
|
|
3000
|
+
let c = /* @__PURE__ */ new Map();
|
|
3001
|
+
if (this.queryBuilder.isQuery(u) ? c = this.getEvaluatedQueryDataset(e, u, a, i) : c = this.evaluateQueryGroup(e, u, a, s, i), n.size === 0 && (n = c), t.groupType === "or")
|
|
3002
|
+
c.forEach((f) => {
|
|
3003
|
+
n.set(f.key, f);
|
|
2976
3004
|
});
|
|
2977
3005
|
else {
|
|
2978
|
-
const
|
|
2979
|
-
for (const
|
|
2980
|
-
n.delete(
|
|
3006
|
+
const f = O(Array.from(n.values()), Array.from(c.values()), "key");
|
|
3007
|
+
for (const l of f)
|
|
3008
|
+
n.delete(l.key);
|
|
2981
3009
|
}
|
|
2982
3010
|
t.groupType === "and" ? a = n : a = r;
|
|
2983
3011
|
}
|
|
@@ -3021,7 +3049,7 @@ class Le {
|
|
|
3021
3049
|
// }
|
|
3022
3050
|
// }
|
|
3023
3051
|
}
|
|
3024
|
-
class
|
|
3052
|
+
class Ue {
|
|
3025
3053
|
scripts = /* @__PURE__ */ new Map();
|
|
3026
3054
|
scriptFunctions = /* @__PURE__ */ new Map();
|
|
3027
3055
|
constructor() {
|
|
@@ -3064,10 +3092,10 @@ class He {
|
|
|
3064
3092
|
return this.getScriptAsFn(e, i)(t, ...n);
|
|
3065
3093
|
}
|
|
3066
3094
|
}
|
|
3067
|
-
const
|
|
3095
|
+
const Je = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => D(e, r.trim(), ""))) : "", Ze = (o) => {
|
|
3068
3096
|
const e = /* @__PURE__ */ new Set();
|
|
3069
3097
|
return o.replace(/\$\{(.*?)\}/g, (r, s) => (e.add(s.trim()), "")), { variables: Array.from(e).map((r) => ({ name: r })) };
|
|
3070
|
-
},
|
|
3098
|
+
}, Ye = [
|
|
3071
3099
|
"any",
|
|
3072
3100
|
"Array<date>",
|
|
3073
3101
|
"Array<float>",
|
|
@@ -3079,7 +3107,7 @@ const Ue = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => y(e
|
|
|
3079
3107
|
"int",
|
|
3080
3108
|
"json",
|
|
3081
3109
|
"string"
|
|
3082
|
-
],
|
|
3110
|
+
], Xe = ["int", "float", "Array<int>", "Array<float>"], et = ["date", "Array<date>"], tt = [
|
|
3083
3111
|
"eq",
|
|
3084
3112
|
"find",
|
|
3085
3113
|
"gt",
|
|
@@ -3091,57 +3119,57 @@ const Ue = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => y(e
|
|
|
3091
3119
|
"size"
|
|
3092
3120
|
];
|
|
3093
3121
|
export {
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3122
|
+
Ie as AnalyticsController,
|
|
3123
|
+
Qe as AttributeDependencyGraph,
|
|
3124
|
+
Me as CacheController,
|
|
3125
|
+
Ge as ChangeDetector,
|
|
3126
|
+
et as DatePropertyTypes,
|
|
3127
|
+
z as DcuplQueryBuilder,
|
|
3128
|
+
tt as DcuplQueryOperatorsAsArray,
|
|
3129
|
+
le as DeepQueryService,
|
|
3102
3130
|
Y as DependencyGraph,
|
|
3103
|
-
|
|
3131
|
+
we as IndicesController,
|
|
3104
3132
|
p as Logger,
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3133
|
+
Xe as NumberPropertyTypes,
|
|
3134
|
+
Ye as PropertyTypesAsArray,
|
|
3135
|
+
Ve as QueryManager,
|
|
3136
|
+
Ue as ScriptController,
|
|
3109
3137
|
P as clone,
|
|
3110
3138
|
re as compareVersions,
|
|
3111
|
-
|
|
3139
|
+
je as computeSuggestions,
|
|
3112
3140
|
g as deepQueryService,
|
|
3113
3141
|
te as escapeRegExp,
|
|
3114
|
-
|
|
3115
|
-
|
|
3142
|
+
Je as evaluateTemplate,
|
|
3143
|
+
_e as generateBooleanQuery,
|
|
3116
3144
|
ee as generateKey,
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3145
|
+
We as generateNumberAndDateQuery,
|
|
3146
|
+
Le as generateReferenceQuery,
|
|
3147
|
+
Re as generateTextQuery,
|
|
3120
3148
|
M as getAggregation,
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3149
|
+
Ce as getDateConstraintUid,
|
|
3150
|
+
Se as getDcuplPropertyTypeForNativeType,
|
|
3151
|
+
w as getDeepPathValues,
|
|
3152
|
+
me as getDistinct,
|
|
3153
|
+
Pe as getFacets,
|
|
3154
|
+
Ne as getFilterEntryId,
|
|
3155
|
+
ke as getNumberConstraintUid,
|
|
3156
|
+
ze as getPropertiesForData,
|
|
3157
|
+
qe as groupBy,
|
|
3158
|
+
Fe as hasMinimumVersion,
|
|
3131
3159
|
se as isDateInstance,
|
|
3132
|
-
|
|
3133
|
-
|
|
3160
|
+
De as isFloat,
|
|
3161
|
+
be as isInt,
|
|
3134
3162
|
ne as isValidDate,
|
|
3135
|
-
|
|
3163
|
+
He as isValidQueryStatement,
|
|
3136
3164
|
F as isValidVersion,
|
|
3137
3165
|
X as logger,
|
|
3138
3166
|
Be as parseDate,
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3167
|
+
Ze as parseTemplate,
|
|
3168
|
+
A as perf,
|
|
3169
|
+
R as pivot,
|
|
3170
|
+
Oe as removeTrailingSlash,
|
|
3171
|
+
Te as trigger,
|
|
3172
|
+
$e as unescapeRegExp,
|
|
3173
|
+
Ee as uniqBy
|
|
3146
3174
|
};
|
|
3147
3175
|
//# sourceMappingURL=index.js.map
|