@dcupl/common 2.0.0-beta.20 → 2.0.0-beta.21
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/helper.d.ts +10 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +506 -331
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/query-builder.d.ts +13 -3
- package/dist/esm/queryData.d.ts +51 -1
- package/dist/esm/redact-url.d.ts +9 -0
- package/dist/esm/types/facets.types.d.ts +8 -0
- package/dist/esm/types/list.types.d.ts +5 -0
- package/dist/esm/types/query.types.d.ts +98 -12
- package/dist/esm/types/suggestion.types.d.ts +5 -0
- 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 v, get as I, every as z, findIndex as
|
|
2
|
-
function
|
|
3
|
-
const e =
|
|
1
|
+
import { cloneDeep as v, get as I, every as z, findIndex as $, size as V, isEqual as H, differenceBy as O, isEqualWith as k, isMatch as q, find as J } from "lodash-es";
|
|
2
|
+
function D(n) {
|
|
3
|
+
const e = N(n);
|
|
4
4
|
return Z(e);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function N(n) {
|
|
7
7
|
if (typeof n != "object" || n === null)
|
|
8
8
|
return String(n);
|
|
9
9
|
if (Array.isArray(n))
|
|
10
|
-
return "[" + n.map(
|
|
10
|
+
return "[" + n.map(N).join(",") + "]";
|
|
11
11
|
const e = Object.keys(n).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 + ":" + N(n[s]), r < e.length - 1 && (t += ",");
|
|
16
16
|
}
|
|
17
17
|
return t += "}", t;
|
|
18
18
|
}
|
|
@@ -41,7 +41,7 @@ const b = {
|
|
|
41
41
|
return performance.getEntriesByType(n);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
class
|
|
44
|
+
class Fe {
|
|
45
45
|
data;
|
|
46
46
|
enabled = !1;
|
|
47
47
|
constructor() {
|
|
@@ -114,11 +114,11 @@ class Te {
|
|
|
114
114
|
getKey(e, t) {
|
|
115
115
|
if (!t)
|
|
116
116
|
return e;
|
|
117
|
-
const r =
|
|
117
|
+
const r = D(t);
|
|
118
118
|
return e + "_" + r;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
let X = class
|
|
121
|
+
let X = class j {
|
|
122
122
|
nodes;
|
|
123
123
|
edges;
|
|
124
124
|
nodeKinds = /* @__PURE__ */ new Map();
|
|
@@ -365,17 +365,17 @@ let X = class _ {
|
|
|
365
365
|
const s = new Set(e), i = (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
|
-
const
|
|
369
|
-
for (const [
|
|
370
|
-
h.has(
|
|
368
|
+
const d = f.shift();
|
|
369
|
+
for (const [l, h] of this.edges)
|
|
370
|
+
h.has(d) && !u.has(l) && (u.add(l), f.push(l));
|
|
371
371
|
}
|
|
372
372
|
return u;
|
|
373
373
|
}, a = () => {
|
|
374
374
|
const u = /* @__PURE__ */ new Set(), f = Array.from(s);
|
|
375
375
|
for (; f.length; ) {
|
|
376
|
-
const
|
|
377
|
-
if (
|
|
378
|
-
for (const h of
|
|
376
|
+
const d = f.shift(), l = this.edges.get(d);
|
|
377
|
+
if (l)
|
|
378
|
+
for (const h of l)
|
|
379
379
|
u.has(h) || (u.add(h), f.push(h));
|
|
380
380
|
}
|
|
381
381
|
return u;
|
|
@@ -392,7 +392,7 @@ let X = class _ {
|
|
|
392
392
|
return { nodes: e, edges: t };
|
|
393
393
|
}
|
|
394
394
|
static fromJSON(e) {
|
|
395
|
-
const t = new
|
|
395
|
+
const t = new j();
|
|
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 _ {
|
|
|
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((d) => !t.has(d)), i = 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
|
+
for (const d of /* @__PURE__ */ new Set([...t, ...r])) {
|
|
405
|
+
const l = this.nodeKinds.get(d), h = e.nodeKinds.get(d);
|
|
406
|
+
l !== h && f.push({ name: d, from: l, to: h });
|
|
407
407
|
}
|
|
408
408
|
return { addedNodes: s, removedNodes: i, addedEdges: c, removedEdges: u, kindChanges: f };
|
|
409
409
|
}
|
|
410
410
|
};
|
|
411
|
-
class
|
|
411
|
+
class Ge {
|
|
412
412
|
graph;
|
|
413
413
|
nodeIndex;
|
|
414
414
|
constructor() {
|
|
@@ -600,36 +600,36 @@ class Re {
|
|
|
600
600
|
};
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
|
-
const
|
|
603
|
+
const R = {
|
|
604
604
|
silent: 0,
|
|
605
605
|
error: 1,
|
|
606
606
|
warn: 2,
|
|
607
607
|
info: 3,
|
|
608
608
|
debug: 4
|
|
609
609
|
};
|
|
610
|
-
class
|
|
610
|
+
class g {
|
|
611
611
|
config;
|
|
612
612
|
static globalConfig = {};
|
|
613
613
|
constructor(e = {}) {
|
|
614
614
|
this.config = {
|
|
615
|
-
level: e.level ??
|
|
616
|
-
format: e.format ??
|
|
615
|
+
level: e.level ?? g.globalConfig.level ?? this.getDefaultLevel(),
|
|
616
|
+
format: e.format ?? g.globalConfig.format ?? this.getDefaultFormat(),
|
|
617
617
|
prefix: e.prefix,
|
|
618
|
-
onLog: e.onLog ??
|
|
619
|
-
onTrackError: e.onTrackError ??
|
|
618
|
+
onLog: e.onLog ?? g.globalConfig.onLog,
|
|
619
|
+
onTrackError: e.onTrackError ?? g.globalConfig.onTrackError
|
|
620
620
|
};
|
|
621
621
|
}
|
|
622
622
|
/**
|
|
623
623
|
* Set global logger configuration (affects all logger instances)
|
|
624
624
|
*/
|
|
625
625
|
static setGlobalConfig(e) {
|
|
626
|
-
|
|
626
|
+
g.globalConfig = { ...g.globalConfig, ...e };
|
|
627
627
|
}
|
|
628
628
|
/**
|
|
629
629
|
* Get the global logger configuration
|
|
630
630
|
*/
|
|
631
631
|
static getGlobalConfig() {
|
|
632
|
-
return { ...
|
|
632
|
+
return { ...g.globalConfig };
|
|
633
633
|
}
|
|
634
634
|
/**
|
|
635
635
|
* Configure module-specific log levels
|
|
@@ -638,14 +638,14 @@ class p {
|
|
|
638
638
|
* logger.setModuleLevel('Catalog', 'warn');
|
|
639
639
|
*/
|
|
640
640
|
static setModuleLevel(e, t) {
|
|
641
|
-
|
|
641
|
+
g.globalConfig.onLog || (g.globalConfig.onLog = void 0), g._moduleOverrides || (g._moduleOverrides = /* @__PURE__ */ new Map()), g._moduleOverrides.set(e, t);
|
|
642
642
|
}
|
|
643
643
|
/**
|
|
644
644
|
* Get module-specific log level
|
|
645
645
|
*/
|
|
646
646
|
static getModuleLevel(e) {
|
|
647
|
-
if (!(!e || !
|
|
648
|
-
return
|
|
647
|
+
if (!(!e || !g._moduleOverrides))
|
|
648
|
+
return g._moduleOverrides.get(e);
|
|
649
649
|
}
|
|
650
650
|
getDefaultLevel() {
|
|
651
651
|
return "info";
|
|
@@ -655,7 +655,7 @@ class p {
|
|
|
655
655
|
}
|
|
656
656
|
getEffectiveLevel() {
|
|
657
657
|
if (this.config.prefix) {
|
|
658
|
-
const e =
|
|
658
|
+
const e = g.getModuleLevel(this.config.prefix);
|
|
659
659
|
if (e)
|
|
660
660
|
return e;
|
|
661
661
|
}
|
|
@@ -663,7 +663,7 @@ class p {
|
|
|
663
663
|
}
|
|
664
664
|
shouldLog(e) {
|
|
665
665
|
const t = this.getEffectiveLevel();
|
|
666
|
-
return
|
|
666
|
+
return R[e] <= R[t];
|
|
667
667
|
}
|
|
668
668
|
formatMessage(e) {
|
|
669
669
|
if (this.config.format === "json") {
|
|
@@ -790,7 +790,7 @@ class p {
|
|
|
790
790
|
// Handle prefix concatenation for nested children
|
|
791
791
|
prefix: e.prefix ? this.config.prefix ? `${this.config.prefix}:${e.prefix}` : e.prefix : this.config.prefix
|
|
792
792
|
};
|
|
793
|
-
return new
|
|
793
|
+
return new g(t);
|
|
794
794
|
}
|
|
795
795
|
/**
|
|
796
796
|
* Update this logger's configuration
|
|
@@ -799,8 +799,8 @@ class p {
|
|
|
799
799
|
Object.assign(this.config, e);
|
|
800
800
|
}
|
|
801
801
|
}
|
|
802
|
-
const Y = new
|
|
803
|
-
class
|
|
802
|
+
const Y = new g();
|
|
803
|
+
class _e {
|
|
804
804
|
constructor(e) {
|
|
805
805
|
this.enabled = e, this.cache = /* @__PURE__ */ new Map(), this.cacheDependencies = /* @__PURE__ */ new Map();
|
|
806
806
|
}
|
|
@@ -922,7 +922,7 @@ class Ge {
|
|
|
922
922
|
}
|
|
923
923
|
}
|
|
924
924
|
getCacheName(e, t) {
|
|
925
|
-
const r =
|
|
925
|
+
const r = D(t);
|
|
926
926
|
return e + "_" + r;
|
|
927
927
|
}
|
|
928
928
|
/**
|
|
@@ -940,7 +940,10 @@ class Ge {
|
|
|
940
940
|
};
|
|
941
941
|
}
|
|
942
942
|
}
|
|
943
|
-
const
|
|
943
|
+
const P = (n, e = "") => {
|
|
944
|
+
if (!(typeof n != "string" || !n.startsWith("/") || !n.endsWith("/")))
|
|
945
|
+
return { pattern: n.slice(1, -1), flags: e };
|
|
946
|
+
}, ze = (n, e = "") => `${n}#${e}`, je = (n) => `${n.gt}_${n.gte}_${n.lt}_${n.lte}_${n.eq}_${n.ne}`, Pe = (n) => `${n.gt}_${n.gte}_${n.lt}_${n.lte}_${n.eq}_${n.ne}`, Be = (n, e) => {
|
|
944
947
|
const t = typeof e == "function" ? e : (r) => r[e];
|
|
945
948
|
return [
|
|
946
949
|
...n.reduce((r, s) => {
|
|
@@ -948,7 +951,7 @@ const ze = (n, e = "") => `${n}#${e}`, _e = (n) => `${n.gt}_${n.gte}_${n.lt}_${n
|
|
|
948
951
|
return r.has(i) || r.set(i, s), r;
|
|
949
952
|
}, /* @__PURE__ */ new Map()).values()
|
|
950
953
|
];
|
|
951
|
-
},
|
|
954
|
+
}, Le = (n, e) => n.reduce(function(t, r) {
|
|
952
955
|
const s = typeof e == "function" ? e(r) : r[e];
|
|
953
956
|
return Object.prototype.hasOwnProperty.call(t, s) || (t[s] = []), t[s].push(r), t;
|
|
954
957
|
}, {});
|
|
@@ -958,14 +961,14 @@ function ee(n = 10) {
|
|
|
958
961
|
for (let r = 0; r < n; r++) e += t.charAt(Math.floor(Math.random() * t.length));
|
|
959
962
|
return e;
|
|
960
963
|
}
|
|
961
|
-
const
|
|
964
|
+
const Ue = (n) => n.replace(/\/+$/, ""), te = (n) => typeof n != "string" ? "" : n.replace(/[[\]{}()*+?.,\\^$|#]/g, "\\$&"), We = (n) => typeof n != "string" ? "" : n.replace(/\\([[\]{}()*+?.,\\^$|#])/g, "$1"), Ve = (n, e) => {
|
|
962
965
|
try {
|
|
963
966
|
return re(n, e) >= 0;
|
|
964
967
|
} catch {
|
|
965
968
|
return !1;
|
|
966
969
|
}
|
|
967
970
|
}, re = (n, e) => {
|
|
968
|
-
if (!
|
|
971
|
+
if (!T(n) || !T(e))
|
|
969
972
|
throw new Error(`Invalid version format: v1="${n}", v2="${e}". Expected format: "x.y.z"`);
|
|
970
973
|
const t = n.split(".").map(Number), r = e.split(".").map(Number);
|
|
971
974
|
for (let s = 0; s < 3; s++) {
|
|
@@ -974,8 +977,8 @@ const Le = (n) => n.replace(/\/+$/, ""), te = (n) => typeof n != "string" ? "" :
|
|
|
974
977
|
if (i < o) return -1;
|
|
975
978
|
}
|
|
976
979
|
return 0;
|
|
977
|
-
},
|
|
978
|
-
class
|
|
980
|
+
}, T = (n) => /^\d+(\.\d+){0,2}$/.test(n);
|
|
981
|
+
class He {
|
|
979
982
|
key;
|
|
980
983
|
parentCd;
|
|
981
984
|
dcuplInitOptions;
|
|
@@ -1011,17 +1014,17 @@ class Ue {
|
|
|
1011
1014
|
};
|
|
1012
1015
|
}
|
|
1013
1016
|
}
|
|
1014
|
-
const
|
|
1017
|
+
const B = (n, e) => e ? typeof structuredClone < "u" ? structuredClone(n) : v(n) : n, F = (n, e, t, r, s, i) => {
|
|
1015
1018
|
try {
|
|
1016
|
-
const o = !!e.dcuplInitOptions.performance?.clone?.enabled && !!t.cloneResult, a =
|
|
1019
|
+
const o = !!e.dcuplInitOptions.performance?.clone?.enabled && !!t.cloneResult, a = B(i, o);
|
|
1017
1020
|
if (t.scope === "list" && (t.listKey = n.cdRef?.key || n.key, t.modelKey = n.model?.key || n.modelKey), t.type === "list_created" && t.args[0].listKey.startsWith("__global_list__") || t.listKey?.startsWith("__global_list__"))
|
|
1018
1021
|
return a;
|
|
1019
1022
|
const c = b.now(), u = c - r, f = Math.round(u * 1e3) / 1e3;
|
|
1020
1023
|
t.duration = f, t.start = r, t.end = c;
|
|
1021
|
-
const
|
|
1024
|
+
const d = {
|
|
1022
1025
|
duration: t.duration
|
|
1023
1026
|
};
|
|
1024
|
-
return t.modelKey && (
|
|
1027
|
+
return t.modelKey && (d.model = t.modelKey), t.connectMessageResult && (t.result = a), t.args && (d.args = t.args), e?.trigger(t), e.analyticsController.mark({
|
|
1025
1028
|
name: `${t.type}:end`,
|
|
1026
1029
|
context: s
|
|
1027
1030
|
}), e.analyticsController.measure({
|
|
@@ -1029,28 +1032,28 @@ const P = (n, e) => e ? typeof structuredClone < "u" ? structuredClone(n) : v(n)
|
|
|
1029
1032
|
start: `${t.type}:start`,
|
|
1030
1033
|
end: `${t.type}:end`,
|
|
1031
1034
|
context: s,
|
|
1032
|
-
detail:
|
|
1035
|
+
detail: d
|
|
1033
1036
|
}), a;
|
|
1034
1037
|
} catch {
|
|
1035
1038
|
return i;
|
|
1036
1039
|
}
|
|
1037
|
-
},
|
|
1040
|
+
}, Je = (n) => (t, r, s) => {
|
|
1038
1041
|
const i = s.value;
|
|
1039
1042
|
return s.value = function(...o) {
|
|
1040
|
-
const a = b.now(), c = this.cdRef, u =
|
|
1043
|
+
const a = b.now(), c = this.cdRef, u = B(n, !0);
|
|
1041
1044
|
u.key || (c.increaseCounter(), u.key = c.getCounter());
|
|
1042
1045
|
const f = ee();
|
|
1043
1046
|
c.analyticsController.mark({
|
|
1044
1047
|
name: `${u.type}:start`,
|
|
1045
1048
|
context: f
|
|
1046
1049
|
});
|
|
1047
|
-
const
|
|
1048
|
-
!u.originCdRefKey && c.key && (u.originCdRefKey = c.key),
|
|
1049
|
-
const
|
|
1050
|
-
return u.method = r, u.args = o,
|
|
1050
|
+
const d = this.model?.key;
|
|
1051
|
+
!u.originCdRefKey && c.key && (u.originCdRefKey = c.key), d && (u.modelKey = d);
|
|
1052
|
+
const l = i.apply(this, o);
|
|
1053
|
+
return u.method = r, u.args = o, l && typeof l == "object" && "then" in l ? l.then((h) => F(this, c, u, a, f, h)) : F(this, c, u, a, f, l);
|
|
1051
1054
|
}, s;
|
|
1052
1055
|
};
|
|
1053
|
-
function
|
|
1056
|
+
function Ze(n, e, t, r) {
|
|
1054
1057
|
t.max || (t.max = 20);
|
|
1055
1058
|
const s = [], i = t.transform ? r.transformValue(t.value, t.transform) : t.value;
|
|
1056
1059
|
for (const [o, a] of e.entries()) {
|
|
@@ -1062,8 +1065,8 @@ function Je(n, e, t, r) {
|
|
|
1062
1065
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1063
1066
|
};
|
|
1064
1067
|
s.push(f);
|
|
1065
|
-
} else if (c &&
|
|
1066
|
-
if (r.queryFind(u, i, "some")) {
|
|
1068
|
+
} else if (c && P(i)) {
|
|
1069
|
+
if (r.queryFind(u, i, "some", t.regexFlags)) {
|
|
1067
1070
|
const f = {
|
|
1068
1071
|
value: o,
|
|
1069
1072
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
@@ -1071,13 +1074,13 @@ function Je(n, e, t, r) {
|
|
|
1071
1074
|
s.push(f);
|
|
1072
1075
|
}
|
|
1073
1076
|
} else if (c && typeof i == "string") {
|
|
1074
|
-
const f = String(u ?? ""),
|
|
1075
|
-
if (f.toLowerCase().startsWith(
|
|
1076
|
-
const
|
|
1077
|
+
const f = String(u ?? ""), d = i;
|
|
1078
|
+
if (f.toLowerCase().startsWith(d.toLowerCase())) {
|
|
1079
|
+
const l = {
|
|
1077
1080
|
value: o,
|
|
1078
1081
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1079
1082
|
};
|
|
1080
|
-
s.push(
|
|
1083
|
+
s.push(l);
|
|
1081
1084
|
}
|
|
1082
1085
|
} else if (c && r.queryFind(u, i, "some")) {
|
|
1083
1086
|
const f = {
|
|
@@ -1177,7 +1180,7 @@ function ce(n) {
|
|
|
1177
1180
|
);
|
|
1178
1181
|
return ne(e) ? e.getFullYear() !== n.year || e.getMonth() !== n.month - 1 || e.getDate() !== n.day ? /* @__PURE__ */ new Date(NaN) : e : /* @__PURE__ */ new Date(NaN);
|
|
1179
1182
|
}
|
|
1180
|
-
function
|
|
1183
|
+
function Xe(n, e, t) {
|
|
1181
1184
|
if (n = n.trim(), e === "t") {
|
|
1182
1185
|
const a = Number(n);
|
|
1183
1186
|
return isNaN(a) ? /* @__PURE__ */ new Date(NaN) : new Date(a * 1e3);
|
|
@@ -1271,7 +1274,7 @@ class fe {
|
|
|
1271
1274
|
this.graph.clear();
|
|
1272
1275
|
}
|
|
1273
1276
|
}
|
|
1274
|
-
class
|
|
1277
|
+
class de {
|
|
1275
1278
|
parseCache;
|
|
1276
1279
|
circularRefDetector;
|
|
1277
1280
|
cacheHits = 0;
|
|
@@ -1307,10 +1310,10 @@ class le {
|
|
|
1307
1310
|
r = e.split(/[.[]/)[0];
|
|
1308
1311
|
const c = e.indexOf("."), u = e.indexOf("[");
|
|
1309
1312
|
if (i && (c === -1 || u < c)) {
|
|
1310
|
-
const
|
|
1311
|
-
if (
|
|
1312
|
-
const
|
|
1313
|
-
|
|
1313
|
+
const d = e.indexOf("]");
|
|
1314
|
+
if (d > -1) {
|
|
1315
|
+
const l = e.indexOf(".", d + 1);
|
|
1316
|
+
l > -1 ? t = e.substring(l + 1) : t = void 0;
|
|
1314
1317
|
} else s && (t = e.substring(c + 1));
|
|
1315
1318
|
} else s && (t = e.substring(c + 1));
|
|
1316
1319
|
}
|
|
@@ -1439,14 +1442,14 @@ class le {
|
|
|
1439
1442
|
return this.getPathSegments(e).length;
|
|
1440
1443
|
}
|
|
1441
1444
|
}
|
|
1442
|
-
const
|
|
1443
|
-
function
|
|
1445
|
+
const m = new de();
|
|
1446
|
+
function w(n, e) {
|
|
1444
1447
|
if (e.includes("[*]")) {
|
|
1445
1448
|
const i = e.indexOf("[*]"), o = e.substring(0, i), a = e.substring(i + 3), c = o ? I(n, o) : n;
|
|
1446
1449
|
if (!Array.isArray(c)) return [];
|
|
1447
1450
|
const u = [];
|
|
1448
1451
|
for (const f of c)
|
|
1449
|
-
!a || a === "" ? f !== void 0 && u.push(f) : a.startsWith(".") && u.push(...
|
|
1452
|
+
!a || a === "" ? f !== void 0 && u.push(f) : a.startsWith(".") && u.push(...w(f, a.slice(1)));
|
|
1450
1453
|
return u;
|
|
1451
1454
|
}
|
|
1452
1455
|
const t = e.split(".");
|
|
@@ -1482,10 +1485,10 @@ function M(n) {
|
|
|
1482
1485
|
}
|
|
1483
1486
|
return Math.pow(10, e);
|
|
1484
1487
|
}
|
|
1485
|
-
function
|
|
1488
|
+
function G(n, e, t) {
|
|
1486
1489
|
return (n * t + e * t) / t;
|
|
1487
1490
|
}
|
|
1488
|
-
function
|
|
1491
|
+
function le(n, e, t) {
|
|
1489
1492
|
return n * t / (e * t);
|
|
1490
1493
|
}
|
|
1491
1494
|
const C = (n, e, t, r) => {
|
|
@@ -1502,12 +1505,12 @@ const C = (n, e, t, r) => {
|
|
|
1502
1505
|
a === "sum" ? s.sum = i?.sum : a === "avg" ? s.avg = i?.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(n, e, t) : a === "group" && (s.group = ge(n, e));
|
|
1503
1506
|
}), s;
|
|
1504
1507
|
}, he = (n, e) => {
|
|
1505
|
-
const r =
|
|
1508
|
+
const r = m.parse(n).isDeepQuery;
|
|
1506
1509
|
let s = 0;
|
|
1507
1510
|
for (const i of e.values())
|
|
1508
1511
|
if (i)
|
|
1509
1512
|
if (r)
|
|
1510
|
-
s +=
|
|
1513
|
+
s += w(i, n).filter((o) => o != null).length;
|
|
1511
1514
|
else {
|
|
1512
1515
|
const o = i[n];
|
|
1513
1516
|
if (o == null) continue;
|
|
@@ -1516,12 +1519,12 @@ const C = (n, e, t, r) => {
|
|
|
1516
1519
|
return s;
|
|
1517
1520
|
}, pe = (n, e) => {
|
|
1518
1521
|
let t, r;
|
|
1519
|
-
const i =
|
|
1522
|
+
const i = m.parse(n).isDeepQuery;
|
|
1520
1523
|
for (const o of e.values()) {
|
|
1521
1524
|
if (!o) continue;
|
|
1522
1525
|
let a;
|
|
1523
1526
|
if (i)
|
|
1524
|
-
a =
|
|
1527
|
+
a = w(o, n);
|
|
1525
1528
|
else {
|
|
1526
1529
|
const c = o[n];
|
|
1527
1530
|
c === void 0 ? a = [] : Array.isArray(c) ? a = c.filter((u) => u !== void 0) : a = [c];
|
|
@@ -1544,10 +1547,10 @@ const C = (n, e, t, r) => {
|
|
|
1544
1547
|
option: { value: ["$dcupl_not_found"] },
|
|
1545
1548
|
count: 0,
|
|
1546
1549
|
keys: []
|
|
1547
|
-
}, i =
|
|
1550
|
+
}, i = m.parse(n.attribute).isDeepQuery;
|
|
1548
1551
|
for (const o of e.values()) {
|
|
1549
1552
|
let a;
|
|
1550
|
-
i ? a =
|
|
1553
|
+
i ? a = w(o, n.attribute) : a = [o[n.attribute]];
|
|
1551
1554
|
let c = !1;
|
|
1552
1555
|
for (const u of a)
|
|
1553
1556
|
for (const f of t)
|
|
@@ -1557,12 +1560,12 @@ const C = (n, e, t, r) => {
|
|
|
1557
1560
|
return n?.groupOptions?.calculateNotFound && t.push(r), t;
|
|
1558
1561
|
}, ye = (n, e) => {
|
|
1559
1562
|
let t = 0, r = 0;
|
|
1560
|
-
const i =
|
|
1563
|
+
const i = m.parse(n).isDeepQuery;
|
|
1561
1564
|
for (const a of e.values()) {
|
|
1562
1565
|
if (!a) continue;
|
|
1563
1566
|
let c;
|
|
1564
1567
|
if (i)
|
|
1565
|
-
c =
|
|
1568
|
+
c = w(a, n);
|
|
1566
1569
|
else {
|
|
1567
1570
|
const u = a[n];
|
|
1568
1571
|
u === void 0 ? c = [] : Array.isArray(u) ? c = u : c = [u];
|
|
@@ -1570,11 +1573,11 @@ const C = (n, e, t, r) => {
|
|
|
1570
1573
|
for (const u of c)
|
|
1571
1574
|
if (Array.isArray(u))
|
|
1572
1575
|
for (const f of u)
|
|
1573
|
-
typeof f == "number" && (t =
|
|
1574
|
-
else typeof u == "number" && (t =
|
|
1576
|
+
typeof f == "number" && (t = G(t, f, M([t, f])), r++);
|
|
1577
|
+
else typeof u == "number" && (t = G(t, u, M([t, u])), r++);
|
|
1575
1578
|
}
|
|
1576
1579
|
return r === 0 ? void 0 : {
|
|
1577
|
-
average:
|
|
1580
|
+
average: le(t, r, M([t, r])),
|
|
1578
1581
|
count: r,
|
|
1579
1582
|
sum: t
|
|
1580
1583
|
};
|
|
@@ -1591,14 +1594,14 @@ const C = (n, e, t, r) => {
|
|
|
1591
1594
|
}
|
|
1592
1595
|
return r;
|
|
1593
1596
|
};
|
|
1594
|
-
class
|
|
1597
|
+
class x extends Error {
|
|
1595
1598
|
query;
|
|
1596
1599
|
constructor(e, t) {
|
|
1597
1600
|
const r = `Query Error: ${e} in ${JSON.stringify(t, null, 2)}`;
|
|
1598
1601
|
super(r), this.query = t, this.name = "DcuplQueryError";
|
|
1599
1602
|
}
|
|
1600
1603
|
}
|
|
1601
|
-
class
|
|
1604
|
+
class L {
|
|
1602
1605
|
_defaultQueryOptions = {
|
|
1603
1606
|
modelKey: "",
|
|
1604
1607
|
groupKey: "root",
|
|
@@ -1609,7 +1612,7 @@ class B {
|
|
|
1609
1612
|
currentQuery = v(this._defaultQueryOptions);
|
|
1610
1613
|
deepQueryService;
|
|
1611
1614
|
constructor(e) {
|
|
1612
|
-
this.deepQueryService = e ||
|
|
1615
|
+
this.deepQueryService = e || m;
|
|
1613
1616
|
}
|
|
1614
1617
|
/**
|
|
1615
1618
|
* Initialize the query builder.
|
|
@@ -1689,7 +1692,8 @@ class B {
|
|
|
1689
1692
|
* - {@link replaceQuery} - Replace complete query
|
|
1690
1693
|
*
|
|
1691
1694
|
* @param queryToApply - Query, condition, or array to apply
|
|
1692
|
-
* @param options - Mode: 'add' (default) or 'set' (replace)
|
|
1695
|
+
* @param options - Mode: 'add' (default) or 'set' (replace). In 'add' mode a group
|
|
1696
|
+
* without `groupKey` is always appended as a new group, never merged into another.
|
|
1693
1697
|
* @param relevantQuery - Target query (defaults to current)
|
|
1694
1698
|
* @returns Updated query
|
|
1695
1699
|
*/
|
|
@@ -1713,12 +1717,12 @@ class B {
|
|
|
1713
1717
|
queries: [e]
|
|
1714
1718
|
});
|
|
1715
1719
|
} else if (this.isQueryGroup(e)) {
|
|
1716
|
-
const
|
|
1717
|
-
(
|
|
1720
|
+
const i = e.groupKey === void 0 && t?.mode !== "set" ? -1 : r.queries.findIndex(
|
|
1721
|
+
(o) => this.isQueryGroup(o) && o.groupKey === e.groupKey
|
|
1718
1722
|
);
|
|
1719
|
-
if (
|
|
1720
|
-
const
|
|
1721
|
-
e.groupType && (
|
|
1723
|
+
if (i > -1) {
|
|
1724
|
+
const o = r.queries[i];
|
|
1725
|
+
e.groupType && (o.groupType = e.groupType), t?.mode === "set" ? r.queries[i] = e : o.queries = [...o.queries, ...e.queries];
|
|
1722
1726
|
} else
|
|
1723
1727
|
r.queries.push({
|
|
1724
1728
|
groupKey: e.groupKey,
|
|
@@ -1751,7 +1755,7 @@ class B {
|
|
|
1751
1755
|
(s) => this.isQueryGroup(s) && s.groupKey === e.attribute
|
|
1752
1756
|
);
|
|
1753
1757
|
if (r > -1) {
|
|
1754
|
-
const s = t.queries[r], i =
|
|
1758
|
+
const s = t.queries[r], i = $(s.queries, e);
|
|
1755
1759
|
i > -1 && s.queries.splice(i, 1), s.queries.length === 0 && t.queries.splice(r, 1);
|
|
1756
1760
|
}
|
|
1757
1761
|
} else if (this.isQueryGroup(e)) {
|
|
@@ -1764,7 +1768,7 @@ class B {
|
|
|
1764
1768
|
else {
|
|
1765
1769
|
const s = t.queries[r];
|
|
1766
1770
|
for (const i of e.queries) {
|
|
1767
|
-
const o =
|
|
1771
|
+
const o = $(s.queries, i);
|
|
1768
1772
|
o > -1 && s.queries.splice(o, 1);
|
|
1769
1773
|
}
|
|
1770
1774
|
s.queries.length === 0 && t.queries.splice(r, 1);
|
|
@@ -1775,12 +1779,12 @@ class B {
|
|
|
1775
1779
|
validateQuery(e) {
|
|
1776
1780
|
const t = [];
|
|
1777
1781
|
if (this.isQuery(e))
|
|
1778
|
-
return e.attribute || t.push(new
|
|
1782
|
+
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 };
|
|
1779
1783
|
if (this.isQueryGroup(e)) {
|
|
1780
1784
|
const i = e.queries.map((o) => this.validateQuery(o)).filter((o) => !o.valid).map((o) => o.errors).flat();
|
|
1781
1785
|
return i.length > 0 ? { valid: !1, errors: i } : { valid: !0 };
|
|
1782
1786
|
}
|
|
1783
|
-
return t.push(new
|
|
1787
|
+
return t.push(new x("Invalid query definition", e)), { valid: !1, errors: t };
|
|
1784
1788
|
}
|
|
1785
1789
|
/**
|
|
1786
1790
|
* Get all attribute names used in the query.
|
|
@@ -1938,7 +1942,10 @@ class B {
|
|
|
1938
1942
|
/**
|
|
1939
1943
|
* Add query condition(s) to the current query.
|
|
1940
1944
|
* Accepts single condition or array of conditions.
|
|
1941
|
-
* Each condition is added to its respective attribute group
|
|
1945
|
+
* Each condition is added to its respective attribute group (the group whose
|
|
1946
|
+
* groupKey equals the condition's attribute; created as an `'or'` group if missing).
|
|
1947
|
+
* To combine conditions in an unkeyed group, use {@link addGroup} — unkeyed groups
|
|
1948
|
+
* are always appended as new groups and never merged.
|
|
1942
1949
|
*
|
|
1943
1950
|
* Clearer alternative to `applyQuery(condition, { mode: 'add' })`.
|
|
1944
1951
|
*
|
|
@@ -1962,7 +1969,13 @@ class B {
|
|
|
1962
1969
|
}
|
|
1963
1970
|
/**
|
|
1964
1971
|
* Add a query group to the current query.
|
|
1965
|
-
*
|
|
1972
|
+
* - Keyed group (`groupKey` set): if a group with the same groupKey exists, its queries
|
|
1973
|
+
* are extended and its groupType is replaced by the given one (if set); otherwise a new
|
|
1974
|
+
* group is created.
|
|
1975
|
+
* - Unkeyed group (no `groupKey`): always appended as a new group; it is never merged
|
|
1976
|
+
* into another group, so each unkeyed group keeps its own groupType.
|
|
1977
|
+
*
|
|
1978
|
+
* A newly created group without `groupType` is stored as `'or'`.
|
|
1966
1979
|
*
|
|
1967
1980
|
* @param group - Query group to add
|
|
1968
1981
|
* @returns Updated query
|
|
@@ -2279,58 +2292,68 @@ class B {
|
|
|
2279
2292
|
return e(this.currentQuery.queries);
|
|
2280
2293
|
}
|
|
2281
2294
|
}
|
|
2282
|
-
const
|
|
2283
|
-
function
|
|
2284
|
-
const a =
|
|
2295
|
+
const E = new L();
|
|
2296
|
+
function Ye(n, e, t, r, s, i, o) {
|
|
2297
|
+
const a = t.excludeGroup ?? s, c = E.removeQuery({ groupKey: a }, v(r)), u = o.queryData(n, c, !1, i), f = e ? [...e.keys()] : [], d = new Set(f), l = i.get(s) ?? /* @__PURE__ */ new Map();
|
|
2285
2298
|
if (!t.excludeUnresolved)
|
|
2286
|
-
for (const
|
|
2287
|
-
|
|
2288
|
-
if (t.excludeUndefineds ?
|
|
2289
|
-
const
|
|
2290
|
-
for (const
|
|
2291
|
-
|
|
2292
|
-
|
|
2299
|
+
for (const p of l.keys())
|
|
2300
|
+
d.add(p);
|
|
2301
|
+
if (t.excludeUndefineds ? d.delete(void 0) : d.add(void 0), t.sort) {
|
|
2302
|
+
const p = [];
|
|
2303
|
+
for (const K of d.values())
|
|
2304
|
+
p.push(
|
|
2305
|
+
_(
|
|
2306
|
+
K,
|
|
2307
|
+
l,
|
|
2308
|
+
u,
|
|
2309
|
+
e,
|
|
2310
|
+
s,
|
|
2311
|
+
a,
|
|
2312
|
+
r,
|
|
2313
|
+
!0
|
|
2314
|
+
)
|
|
2293
2315
|
);
|
|
2294
|
-
const
|
|
2295
|
-
return
|
|
2316
|
+
const y = t.excludeZeros ? p.filter((K) => K.size > 0) : p;
|
|
2317
|
+
return y.sort(ve(t.sort)), t.count ? y.slice(0, t.count) : y;
|
|
2296
2318
|
}
|
|
2297
|
-
const
|
|
2298
|
-
for (const
|
|
2299
|
-
const
|
|
2300
|
-
|
|
2319
|
+
const h = [];
|
|
2320
|
+
for (const p of d.values()) {
|
|
2321
|
+
const y = _(
|
|
2322
|
+
p,
|
|
2301
2323
|
l,
|
|
2302
|
-
|
|
2324
|
+
u,
|
|
2303
2325
|
e,
|
|
2304
2326
|
s,
|
|
2327
|
+
a,
|
|
2305
2328
|
r,
|
|
2306
2329
|
!!t?.calculateFacets
|
|
2307
2330
|
);
|
|
2308
|
-
if (!(t?.excludeZeros &&
|
|
2309
|
-
if (t?.count &&
|
|
2310
|
-
return
|
|
2311
|
-
|
|
2331
|
+
if (!(t?.excludeZeros && y.size === 0)) {
|
|
2332
|
+
if (t?.count && h.length === t?.count)
|
|
2333
|
+
return h;
|
|
2334
|
+
h.push(y);
|
|
2312
2335
|
}
|
|
2313
2336
|
}
|
|
2314
|
-
return
|
|
2337
|
+
return h;
|
|
2315
2338
|
}
|
|
2316
|
-
function
|
|
2317
|
-
const
|
|
2318
|
-
for (const
|
|
2319
|
-
const
|
|
2320
|
-
if (
|
|
2339
|
+
function _(n, e, t, r, s, i, o, a) {
|
|
2340
|
+
const c = /* @__PURE__ */ new Map(), u = e.get(n) || /* @__PURE__ */ new Set();
|
|
2341
|
+
for (const f of u) {
|
|
2342
|
+
const d = t.get(f);
|
|
2343
|
+
if (d && (c.set(f, d), !a))
|
|
2321
2344
|
break;
|
|
2322
2345
|
}
|
|
2323
2346
|
return {
|
|
2324
2347
|
key: String(n),
|
|
2325
2348
|
value: n,
|
|
2326
|
-
selected: we(s, n,
|
|
2327
|
-
enabled:
|
|
2328
|
-
size:
|
|
2349
|
+
selected: we(i, s, n, o),
|
|
2350
|
+
enabled: c.size > 0,
|
|
2351
|
+
size: c.size,
|
|
2329
2352
|
entry: r?.get(n),
|
|
2330
|
-
resultKeys: Array.from(
|
|
2353
|
+
resultKeys: Array.from(c.keys())
|
|
2331
2354
|
};
|
|
2332
2355
|
}
|
|
2333
|
-
function
|
|
2356
|
+
function S(n, e) {
|
|
2334
2357
|
if (n === void 0 && e === void 0) return 0;
|
|
2335
2358
|
if (n === void 0) return 1;
|
|
2336
2359
|
if (e === void 0) return -1;
|
|
@@ -2344,24 +2367,18 @@ function D(n, e) {
|
|
|
2344
2367
|
function ve(n) {
|
|
2345
2368
|
switch (n) {
|
|
2346
2369
|
case "size-desc":
|
|
2347
|
-
return (e, t) => t.size - e.size ||
|
|
2370
|
+
return (e, t) => t.size - e.size || S(e.value, t.value);
|
|
2348
2371
|
case "size-asc":
|
|
2349
|
-
return (e, t) => e.size - t.size ||
|
|
2372
|
+
return (e, t) => e.size - t.size || S(e.value, t.value);
|
|
2350
2373
|
case "value-asc":
|
|
2351
|
-
return (e, t) =>
|
|
2374
|
+
return (e, t) => S(e.value, t.value);
|
|
2352
2375
|
case "value-desc":
|
|
2353
|
-
return (e, t) => e.value === void 0 && t.value === void 0 ? 0 : e.value === void 0 ? 1 : t.value === void 0 ? -1 : -
|
|
2376
|
+
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);
|
|
2354
2377
|
}
|
|
2355
2378
|
}
|
|
2356
|
-
const we = (n, e, t) => {
|
|
2357
|
-
const
|
|
2358
|
-
return
|
|
2359
|
-
if (N.isQuery(i)) {
|
|
2360
|
-
const o = i.value?.key || i.value;
|
|
2361
|
-
return i.attribute === n && o === e;
|
|
2362
|
-
}
|
|
2363
|
-
return !1;
|
|
2364
|
-
}) : !1;
|
|
2379
|
+
const we = (n, e, t, r) => {
|
|
2380
|
+
const s = r.queries.findIndex((i) => E.isQueryGroup(i) && i.groupKey === n);
|
|
2381
|
+
return s > -1 ? !!r.queries[s].queries.find((o) => E.isQuery(o) ? o.attribute !== e ? !1 : (o.operator === "in" && Array.isArray(o.value) ? o.value : [o.value]).some((c) => (c?.key || c) === t) : !1) : !1;
|
|
2365
2382
|
};
|
|
2366
2383
|
class xe {
|
|
2367
2384
|
indexMap = /* @__PURE__ */ new Map();
|
|
@@ -2431,7 +2448,7 @@ class xe {
|
|
|
2431
2448
|
if (o)
|
|
2432
2449
|
o.lastAccessedAt = Date.now();
|
|
2433
2450
|
else if (!i) {
|
|
2434
|
-
const c =
|
|
2451
|
+
const c = m.parse(e).isDeepQuery ?? !1;
|
|
2435
2452
|
this.indexMetadata.set(s, {
|
|
2436
2453
|
createdAt: Date.now(),
|
|
2437
2454
|
lastAccessedAt: Date.now(),
|
|
@@ -2441,17 +2458,17 @@ class xe {
|
|
|
2441
2458
|
}
|
|
2442
2459
|
if (!i) {
|
|
2443
2460
|
this.reset(s), this.indexMap.set(s, /* @__PURE__ */ new Map());
|
|
2444
|
-
const c =
|
|
2461
|
+
const c = m.parse(e).isDeepQuery;
|
|
2445
2462
|
for (const u of t.values()) {
|
|
2446
2463
|
let f;
|
|
2447
|
-
c ? (f =
|
|
2464
|
+
c ? (f = w(u, e), f.length === 0 && (f = [void 0])) : f = [u[e]], this.fillInverseIndex(s, u.key, f), this.fillDataMap(s, f);
|
|
2448
2465
|
}
|
|
2449
2466
|
i = this.getIndex(s) || /* @__PURE__ */ new Map();
|
|
2450
2467
|
}
|
|
2451
2468
|
return i;
|
|
2452
2469
|
}
|
|
2453
2470
|
getIndexName(e, t) {
|
|
2454
|
-
return t ? e + "_" +
|
|
2471
|
+
return t ? e + "_" + D(t) : e;
|
|
2455
2472
|
}
|
|
2456
2473
|
// ========== PARTIAL UPDATE METHODS ==========
|
|
2457
2474
|
/**
|
|
@@ -2545,7 +2562,7 @@ class xe {
|
|
|
2545
2562
|
isDeepQueryIndex(e) {
|
|
2546
2563
|
const t = e.includes("_") ? e.split("_")[0] : e;
|
|
2547
2564
|
try {
|
|
2548
|
-
return
|
|
2565
|
+
return m.parse(t).isDeepQuery ?? !1;
|
|
2549
2566
|
} catch {
|
|
2550
2567
|
return !1;
|
|
2551
2568
|
}
|
|
@@ -2620,15 +2637,15 @@ class xe {
|
|
|
2620
2637
|
};
|
|
2621
2638
|
}
|
|
2622
2639
|
}
|
|
2623
|
-
const
|
|
2624
|
-
function
|
|
2640
|
+
const A = "__";
|
|
2641
|
+
function U(n, e, t = { key: "root" }, r = "root", s = new xe(), i) {
|
|
2625
2642
|
const o = i || n;
|
|
2626
2643
|
for (const a of e.columns)
|
|
2627
|
-
a.attribute && (
|
|
2644
|
+
a.attribute && (m.parse(a.attribute), s.getOrCreateIndex(a.attribute, o));
|
|
2628
2645
|
for (const a of e.rows)
|
|
2629
|
-
a.attribute && (
|
|
2646
|
+
a.attribute && (m.parse(a.attribute), s.getOrCreateIndex(a.attribute, o));
|
|
2630
2647
|
for (const a of e.values)
|
|
2631
|
-
a.attribute && (
|
|
2648
|
+
a.attribute && (m.parse(a.attribute), s.getOrCreateIndex(a.attribute, o));
|
|
2632
2649
|
if (e.rows && e.rows.length > 0) {
|
|
2633
2650
|
t.rows = t.rows || [];
|
|
2634
2651
|
const a = Ae(n, e.rows[0], e, s, r, i);
|
|
@@ -2636,7 +2653,7 @@ function j(n, e, t = { key: "root" }, r = "root", s = new xe(), i) {
|
|
|
2636
2653
|
}
|
|
2637
2654
|
if (e.columns && e.columns.length > 0) {
|
|
2638
2655
|
t.columns = t.columns || [];
|
|
2639
|
-
const a =
|
|
2656
|
+
const a = W(n, e.columns[0], e, s, r, i);
|
|
2640
2657
|
t.columns.push(a);
|
|
2641
2658
|
}
|
|
2642
2659
|
if (t.key === "root")
|
|
@@ -2656,35 +2673,35 @@ function Ae(n, e, t, r, s = "", i) {
|
|
|
2656
2673
|
const f = {
|
|
2657
2674
|
key: c,
|
|
2658
2675
|
value: c
|
|
2659
|
-
},
|
|
2660
|
-
for (const
|
|
2661
|
-
n.has(
|
|
2662
|
-
if (
|
|
2663
|
-
for (const
|
|
2676
|
+
}, d = /* @__PURE__ */ new Map();
|
|
2677
|
+
for (const l of u)
|
|
2678
|
+
n.has(l) && d.set(l, n.get(l));
|
|
2679
|
+
if (d.size) {
|
|
2680
|
+
for (const l of t.values) {
|
|
2664
2681
|
if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
|
|
2665
2682
|
continue;
|
|
2666
|
-
const h = C(
|
|
2683
|
+
const h = C(l, d, r.getIndex(l.attribute), l.attribute);
|
|
2667
2684
|
f.values.push(h);
|
|
2668
2685
|
}
|
|
2669
2686
|
if (o.rows = o.rows || [], o.rows.push(f), t.rows.length > 1) {
|
|
2670
|
-
const
|
|
2671
|
-
|
|
2672
|
-
l,
|
|
2687
|
+
const l = { ...t, rows: t.rows.slice(1) };
|
|
2688
|
+
U(
|
|
2673
2689
|
d,
|
|
2690
|
+
l,
|
|
2674
2691
|
f,
|
|
2675
|
-
s +
|
|
2692
|
+
s + A + e.attribute + A + c,
|
|
2676
2693
|
r,
|
|
2677
2694
|
i
|
|
2678
2695
|
);
|
|
2679
2696
|
} else if (t.columns)
|
|
2680
|
-
for (const
|
|
2697
|
+
for (const l of t.columns) {
|
|
2681
2698
|
f.columns = f.columns || [];
|
|
2682
|
-
const h =
|
|
2683
|
-
l,
|
|
2699
|
+
const h = W(
|
|
2684
2700
|
d,
|
|
2701
|
+
l,
|
|
2685
2702
|
t,
|
|
2686
2703
|
r,
|
|
2687
|
-
s +
|
|
2704
|
+
s + A + e.attribute + A + c,
|
|
2688
2705
|
i
|
|
2689
2706
|
);
|
|
2690
2707
|
f.columns.push(h);
|
|
@@ -2693,7 +2710,7 @@ function Ae(n, e, t, r, s = "", i) {
|
|
|
2693
2710
|
}
|
|
2694
2711
|
return o;
|
|
2695
2712
|
}
|
|
2696
|
-
function
|
|
2713
|
+
function W(n, e, t, r, s = "", i) {
|
|
2697
2714
|
const o = { key: e.attribute }, a = r.getIndex(e.attribute);
|
|
2698
2715
|
if (!a)
|
|
2699
2716
|
return o;
|
|
@@ -2701,23 +2718,23 @@ function L(n, e, t, r, s = "", i) {
|
|
|
2701
2718
|
const f = {
|
|
2702
2719
|
key: c,
|
|
2703
2720
|
value: c
|
|
2704
|
-
},
|
|
2705
|
-
for (const
|
|
2706
|
-
n.has(
|
|
2707
|
-
if (
|
|
2708
|
-
for (const
|
|
2721
|
+
}, d = /* @__PURE__ */ new Map();
|
|
2722
|
+
for (const l of u)
|
|
2723
|
+
n.has(l) && d.set(l, n.get(l));
|
|
2724
|
+
if (d.size) {
|
|
2725
|
+
for (const l of t.values) {
|
|
2709
2726
|
if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
|
|
2710
2727
|
continue;
|
|
2711
|
-
const h = C(
|
|
2728
|
+
const h = C(l, d, r.getIndex(l.attribute), l.attribute);
|
|
2712
2729
|
f.values.push(h);
|
|
2713
2730
|
}
|
|
2714
2731
|
if (o.columns = o.columns || [], o.columns.push(f), t.columns.length > 1) {
|
|
2715
|
-
const
|
|
2716
|
-
|
|
2717
|
-
l,
|
|
2732
|
+
const l = { ...t, columns: t.columns.slice(1) };
|
|
2733
|
+
U(
|
|
2718
2734
|
d,
|
|
2735
|
+
l,
|
|
2719
2736
|
f,
|
|
2720
|
-
s +
|
|
2737
|
+
s + A + e.attribute + A + c,
|
|
2721
2738
|
r,
|
|
2722
2739
|
i
|
|
2723
2740
|
);
|
|
@@ -2726,43 +2743,43 @@ function L(n, e, t, r, s = "", i) {
|
|
|
2726
2743
|
}
|
|
2727
2744
|
return o;
|
|
2728
2745
|
}
|
|
2729
|
-
const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/, Se = /^-?\d+$/,
|
|
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 = (n) => n === "true" || n === "false" ? "boolean" : Se.test(n) ? "int" : Ie.test(n) ? "float" : be.test(n) && !Number.isNaN(Date.parse(n)) ? "date" : "string", ke = (n) => De.test(n), Me = (n) => n == null || n === "", Qe = (n) => {
|
|
2730
2747
|
const e = [...n];
|
|
2731
2748
|
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 };
|
|
2732
2749
|
}, Ne = (n, e = {}) => {
|
|
2733
2750
|
const r = e.deep ?? (e.sampleSize !== void 0 && e.sampleSize > 1) ? e.sampleSize ?? 1 / 0 : 1, s = e.coerceStrings ?? !0, i = /* @__PURE__ */ new Map(), o = [], a = Math.min(n.length, r);
|
|
2734
2751
|
for (let f = 0; f < a; f++) {
|
|
2735
|
-
const
|
|
2736
|
-
if (
|
|
2737
|
-
for (const [
|
|
2738
|
-
let
|
|
2739
|
-
if (
|
|
2740
|
-
|
|
2752
|
+
const d = n[f];
|
|
2753
|
+
if (d)
|
|
2754
|
+
for (const [l, h] of Object.entries(d)) {
|
|
2755
|
+
let p = i.get(l);
|
|
2756
|
+
if (p || (p = { observed: /* @__PURE__ */ new Set(), empty: 0, scanned: 0 }, i.set(l, p), o.push(l)), p.scanned++, Me(h)) {
|
|
2757
|
+
p.empty++;
|
|
2741
2758
|
continue;
|
|
2742
2759
|
}
|
|
2743
|
-
let
|
|
2744
|
-
typeof h == "string" && s ? (
|
|
2760
|
+
let y;
|
|
2761
|
+
typeof h == "string" && s ? (y = Ke(h), y === "string" && !p.hint && ke(h) && (p.hint = "column looks date-like (non-ISO) — review manually")) : y = $e(h), p.observed.add(y);
|
|
2745
2762
|
}
|
|
2746
2763
|
}
|
|
2747
2764
|
const c = [], u = [];
|
|
2748
2765
|
for (const f of o) {
|
|
2749
|
-
const
|
|
2750
|
-
c.push({ key: f, type:
|
|
2766
|
+
const d = i.get(f), { type: l, conflict: h } = Qe(d.observed.size ? d.observed : /* @__PURE__ */ new Set(["string"]));
|
|
2767
|
+
c.push({ key: f, type: l }), u.push({
|
|
2751
2768
|
column: f,
|
|
2752
|
-
inferredType:
|
|
2753
|
-
observedTypes: [...
|
|
2754
|
-
emptyRate:
|
|
2769
|
+
inferredType: l,
|
|
2770
|
+
observedTypes: [...d.observed].sort(),
|
|
2771
|
+
emptyRate: d.scanned === 0 ? 0 : d.empty / d.scanned,
|
|
2755
2772
|
conflict: h,
|
|
2756
|
-
hint:
|
|
2773
|
+
hint: d.hint
|
|
2757
2774
|
});
|
|
2758
2775
|
}
|
|
2759
2776
|
return { properties: c, diagnostics: u };
|
|
2760
|
-
},
|
|
2777
|
+
}, et = (n, e = !1) => Ne(n, typeof e == "boolean" ? { deep: e } : e).properties, Ee = (n) => Number(n) === n && n % 1 === 0, Ce = (n) => Number(n) === n && n % 1 !== 0, $e = (n) => {
|
|
2761
2778
|
switch (typeof n) {
|
|
2762
2779
|
case "string":
|
|
2763
2780
|
return "string";
|
|
2764
2781
|
case "number":
|
|
2765
|
-
return
|
|
2782
|
+
return Ee(n) ? "int" : Ce(n) ? "float" : "any";
|
|
2766
2783
|
case "boolean":
|
|
2767
2784
|
return "boolean";
|
|
2768
2785
|
case "object":
|
|
@@ -2770,7 +2787,7 @@ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?
|
|
|
2770
2787
|
default:
|
|
2771
2788
|
return "any";
|
|
2772
2789
|
}
|
|
2773
|
-
},
|
|
2790
|
+
}, tt = (n, e) => {
|
|
2774
2791
|
const t = te(n.text || ""), r = e?.attributeKey || n.filterKey;
|
|
2775
2792
|
let s;
|
|
2776
2793
|
const i = e?.comparisonType || "containsIgnoreCase";
|
|
@@ -2834,7 +2851,7 @@ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?
|
|
|
2834
2851
|
}
|
|
2835
2852
|
]
|
|
2836
2853
|
}), s;
|
|
2837
|
-
},
|
|
2854
|
+
}, rt = (n, e) => {
|
|
2838
2855
|
const t = e?.attributeKey || n.filterKey;
|
|
2839
2856
|
return {
|
|
2840
2857
|
groupKey: n.filterKey,
|
|
@@ -2847,7 +2864,7 @@ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?
|
|
|
2847
2864
|
}
|
|
2848
2865
|
]
|
|
2849
2866
|
};
|
|
2850
|
-
},
|
|
2867
|
+
}, st = (n, e) => {
|
|
2851
2868
|
const t = e?.attributeKey || n.filterKey, r = {
|
|
2852
2869
|
groupKey: n.filterKey,
|
|
2853
2870
|
queries: []
|
|
@@ -2862,7 +2879,7 @@ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?
|
|
|
2862
2879
|
operator: "eq",
|
|
2863
2880
|
options: { invert: !0 }
|
|
2864
2881
|
})), typeof n.gt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: n.gt, operator: "gt" })), typeof n.lt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: n.lt, operator: "lt" })), typeof n.gte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: n.gte, operator: "gte" })), typeof n.lte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: n.lte, operator: "lte" })), r;
|
|
2865
|
-
},
|
|
2882
|
+
}, nt = (n, e) => {
|
|
2866
2883
|
const t = e?.attributeKey || n.filterKey, r = {
|
|
2867
2884
|
groupKey: n.filterKey,
|
|
2868
2885
|
queries: []
|
|
@@ -2875,8 +2892,8 @@ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?
|
|
|
2875
2892
|
operator: "eq"
|
|
2876
2893
|
});
|
|
2877
2894
|
}), r;
|
|
2878
|
-
},
|
|
2879
|
-
class
|
|
2895
|
+
}, it = (n) => !(typeof n.modelKey != "string" || !Array.isArray(n.queries));
|
|
2896
|
+
class ot {
|
|
2880
2897
|
constructor(e, t, r) {
|
|
2881
2898
|
this.scriptController = e, this.globalItemService = t, this.modelParser = r;
|
|
2882
2899
|
}
|
|
@@ -2884,7 +2901,7 @@ class it {
|
|
|
2884
2901
|
globalItemService;
|
|
2885
2902
|
modelParser;
|
|
2886
2903
|
registeredCustomOperator = /* @__PURE__ */ new Map();
|
|
2887
|
-
queryBuilder = new
|
|
2904
|
+
queryBuilder = new L();
|
|
2888
2905
|
registerCustomOperator(e, t) {
|
|
2889
2906
|
this.registeredCustomOperator.set(e, t);
|
|
2890
2907
|
}
|
|
@@ -2898,85 +2915,235 @@ class it {
|
|
|
2898
2915
|
return e;
|
|
2899
2916
|
}
|
|
2900
2917
|
evaluateQuery(e, t) {
|
|
2901
|
-
let r
|
|
2902
|
-
const
|
|
2903
|
-
|
|
2918
|
+
let r = e.value;
|
|
2919
|
+
const s = e.options?.arrayValueHandling || "some";
|
|
2920
|
+
Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (r = this.transformValue(r, e.options.transform));
|
|
2921
|
+
let i = this.getAttributeValue(t, e.attribute);
|
|
2922
|
+
if (Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (i = this.transformValue(i, e.options.transform)), (typeof i > "u" || i === null) && !["typeof", "isTruthy", "eq", "in"].includes(e.operator))
|
|
2904
2923
|
return !1;
|
|
2924
|
+
let o;
|
|
2905
2925
|
switch (e.operator) {
|
|
2906
2926
|
case "eq":
|
|
2907
|
-
|
|
2927
|
+
o = this.queryEq(i, r, s);
|
|
2928
|
+
break;
|
|
2929
|
+
case "in":
|
|
2930
|
+
o = this.queryIn(i, r, s);
|
|
2931
|
+
break;
|
|
2908
2932
|
case "find":
|
|
2909
|
-
|
|
2933
|
+
o = this.queryFind(i, r, s, e.options?.regexFlags);
|
|
2934
|
+
break;
|
|
2910
2935
|
case "lt":
|
|
2911
|
-
return Array.isArray(r) ? i === "some" ? r.some((o) => o < s) : r.every((o) => o < s) : r < s;
|
|
2912
2936
|
case "gt":
|
|
2913
|
-
return Array.isArray(r) ? i === "some" ? r.some((o) => o > s) : r.every((o) => o > s) : r > s;
|
|
2914
2937
|
case "lte":
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2938
|
+
case "gte": {
|
|
2939
|
+
const a = e.operator;
|
|
2940
|
+
o = this.matchValues(
|
|
2941
|
+
i,
|
|
2942
|
+
s,
|
|
2943
|
+
(c) => this.compareValue(a, c, r)
|
|
2944
|
+
);
|
|
2945
|
+
break;
|
|
2946
|
+
}
|
|
2918
2947
|
case "typeof":
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2948
|
+
o = this.matchValues(i, s, (a) => typeof a === r);
|
|
2949
|
+
break;
|
|
2950
|
+
case "isTruthy": {
|
|
2951
|
+
const a = r === !0;
|
|
2952
|
+
o = this.matchValues(i, s, (c) => !!c === a);
|
|
2953
|
+
break;
|
|
2954
|
+
}
|
|
2922
2955
|
case "size":
|
|
2923
|
-
|
|
2956
|
+
typeof i == "string" ? o = i.length === r : o = V(i) === r;
|
|
2957
|
+
break;
|
|
2924
2958
|
default:
|
|
2925
2959
|
if (this.scriptController.hasScript(e.operator))
|
|
2926
2960
|
return this.scriptController.executeScript(e.operator, "operator", { query: e, item: t });
|
|
2927
2961
|
if (this.registeredCustomOperator.has(e.operator)) {
|
|
2928
|
-
const
|
|
2929
|
-
if (typeof
|
|
2930
|
-
return
|
|
2962
|
+
const a = this.registeredCustomOperator.get(e.operator);
|
|
2963
|
+
if (typeof a == "function")
|
|
2964
|
+
return a(e, t);
|
|
2931
2965
|
}
|
|
2966
|
+
return !1;
|
|
2932
2967
|
}
|
|
2933
|
-
return !
|
|
2968
|
+
return e.options?.invert ? !o : o;
|
|
2969
|
+
}
|
|
2970
|
+
/** A missing value never compares — in JS `null >= 0` is true. */
|
|
2971
|
+
compareValue(e, t, r) {
|
|
2972
|
+
if (t == null)
|
|
2973
|
+
return !1;
|
|
2974
|
+
switch (e) {
|
|
2975
|
+
case "lt":
|
|
2976
|
+
return t < r;
|
|
2977
|
+
case "gt":
|
|
2978
|
+
return t > r;
|
|
2979
|
+
case "lte":
|
|
2980
|
+
return t <= r;
|
|
2981
|
+
case "gte":
|
|
2982
|
+
return t >= r;
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
/**
|
|
2986
|
+
* The value a condition compares against. A dotted path that runs through a
|
|
2987
|
+
* list (a multi-valued reference, e.g. `memberships.role`) fans out into the
|
|
2988
|
+
* list of leaf values, the same values the attribute's inverse index holds —
|
|
2989
|
+
* `lodash.get` cannot step into an array and would answer `undefined`. An
|
|
2990
|
+
* index (`tags.0`) or `length` still reads the list itself, as with `get`.
|
|
2991
|
+
*/
|
|
2992
|
+
getAttributeValue(e, t) {
|
|
2993
|
+
if (t in e || !(t.includes(".") || t.includes("[")))
|
|
2994
|
+
return e[t];
|
|
2995
|
+
if (t.includes("["))
|
|
2996
|
+
return I(e, t);
|
|
2997
|
+
const r = t.split(".");
|
|
2998
|
+
let s = e;
|
|
2999
|
+
for (let i = 0; i < r.length; i++) {
|
|
3000
|
+
const o = r[i];
|
|
3001
|
+
if (s == null)
|
|
3002
|
+
return;
|
|
3003
|
+
if (Array.isArray(s) && o !== "length" && !/^\d+$/.test(o))
|
|
3004
|
+
return w(s, r.slice(i).join("."));
|
|
3005
|
+
s = s[o];
|
|
3006
|
+
}
|
|
3007
|
+
return s;
|
|
3008
|
+
}
|
|
3009
|
+
/**
|
|
3010
|
+
* Applies `predicate` to a single value, or to each value of a list per
|
|
3011
|
+
* `arrayValueHandling`. `every` needs at least one value: an empty list
|
|
3012
|
+
* matches nothing (and so matches under `invert`).
|
|
3013
|
+
*/
|
|
3014
|
+
matchValues(e, t, r) {
|
|
3015
|
+
return Array.isArray(e) ? t === "every" ? e.length > 0 && e.every(r) : e.some(r) : r(e);
|
|
3016
|
+
}
|
|
3017
|
+
/**
|
|
3018
|
+
* `eq` against a list compares each value, as the inverse index does; a
|
|
3019
|
+
* query value that is itself a list still compares the whole list.
|
|
3020
|
+
*/
|
|
3021
|
+
queryEq(e, t, r) {
|
|
3022
|
+
return Array.isArray(e) && !Array.isArray(t) ? this.matchValues(e, r, (s) => this.equalsQueryValue(s, t)) : this.equalsQueryValue(e, t);
|
|
3023
|
+
}
|
|
3024
|
+
/**
|
|
3025
|
+
* `in`: a value matches if it equals (as `eq` compares) any listed value; a
|
|
3026
|
+
* list of values matches per `arrayValueHandling`. An empty list matches nothing.
|
|
3027
|
+
*/
|
|
3028
|
+
queryIn(e, t, r) {
|
|
3029
|
+
return !Array.isArray(t) || t.length === 0 ? !1 : this.matchValues(
|
|
3030
|
+
e,
|
|
3031
|
+
r,
|
|
3032
|
+
(s) => t.some((i) => this.equalsQueryValue(s, i))
|
|
3033
|
+
);
|
|
3034
|
+
}
|
|
3035
|
+
/**
|
|
3036
|
+
* The inverse-index key a query value looks up: a string, or the key of a
|
|
3037
|
+
* `{ key }` object. Anything else has no key and is compared by a scan.
|
|
3038
|
+
*/
|
|
3039
|
+
getIndexKey(e) {
|
|
3040
|
+
if (typeof e == "string")
|
|
3041
|
+
return e;
|
|
3042
|
+
if (e?.key && Object.keys(e).length === 1)
|
|
3043
|
+
return e.key;
|
|
3044
|
+
}
|
|
3045
|
+
/**
|
|
3046
|
+
* Equality the way the inverse index keys values: a string (or `{ key }`)
|
|
3047
|
+
* query value matches a reference by its key and a date by its ISO string.
|
|
3048
|
+
*/
|
|
3049
|
+
equalsQueryValue(e, t) {
|
|
3050
|
+
const r = this.getIndexKey(t);
|
|
3051
|
+
return typeof r > "u" ? H(e, t) : e instanceof Date ? !isNaN(e.getTime()) && e.toISOString() === r : typeof e == "object" && e?.key ? e.key === r : e === r;
|
|
3052
|
+
}
|
|
3053
|
+
/**
|
|
3054
|
+
* An inverse index answers `eq` as "some value equals", untransformed — only
|
|
3055
|
+
* use it when that is the question.
|
|
3056
|
+
*/
|
|
3057
|
+
canUseIndex(e) {
|
|
3058
|
+
return e.options?.arrayValueHandling !== "every" && !e.options?.transform?.length;
|
|
2934
3059
|
}
|
|
2935
3060
|
evaluateEqOperator(e, t, r, s) {
|
|
2936
|
-
const i = /* @__PURE__ */ new Map(), o = s.get(t.attribute);
|
|
3061
|
+
const i = /* @__PURE__ */ new Map(), o = this.canUseIndex(t) ? s.get(t.attribute) : void 0;
|
|
2937
3062
|
if (o) {
|
|
2938
|
-
|
|
2939
|
-
if (typeof
|
|
3063
|
+
const a = this.getIndexKey(t.value);
|
|
3064
|
+
if (typeof a < "u") {
|
|
2940
3065
|
const c = o.get(a);
|
|
2941
3066
|
if (c)
|
|
2942
3067
|
if (c.forEach((u) => {
|
|
2943
3068
|
r.has(u) && i.set(u, r.get(u));
|
|
2944
3069
|
}), t.options?.invert) {
|
|
2945
3070
|
const u = O(Array.from(r.values()), Array.from(i.values()), "key"), f = /* @__PURE__ */ new Map();
|
|
2946
|
-
return u.forEach((
|
|
2947
|
-
f.set(
|
|
3071
|
+
return u.forEach((d) => {
|
|
3072
|
+
f.set(d.key, d);
|
|
2948
3073
|
}), f;
|
|
2949
3074
|
} else
|
|
2950
3075
|
return i;
|
|
2951
3076
|
}
|
|
2952
3077
|
}
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
3078
|
+
return this.scanDataset(e, t, r);
|
|
3079
|
+
}
|
|
3080
|
+
/**
|
|
3081
|
+
* `in` from the inverse index when it can answer: the union of the index
|
|
3082
|
+
* sets of the listed values. A value the index cannot look up (not a string
|
|
3083
|
+
* or `{ key }`, or not in the index) is answered by a scan of the rest, so
|
|
3084
|
+
* the result equals the scan's.
|
|
3085
|
+
*/
|
|
3086
|
+
evaluateInOperator(e, t, r, s) {
|
|
3087
|
+
const i = this.canUseIndex(t) ? s.get(t.attribute) : void 0;
|
|
3088
|
+
if (!i)
|
|
3089
|
+
return this.scanDataset(e, t, r);
|
|
3090
|
+
const o = /* @__PURE__ */ new Map(), a = [];
|
|
3091
|
+
for (const u of t.value) {
|
|
3092
|
+
const f = this.getIndexKey(u), d = typeof f < "u" ? i.get(f) : void 0;
|
|
3093
|
+
if (!d) {
|
|
3094
|
+
a.push(u);
|
|
3095
|
+
continue;
|
|
2964
3096
|
}
|
|
2965
|
-
|
|
3097
|
+
d.forEach((l) => {
|
|
3098
|
+
const h = r.get(l);
|
|
3099
|
+
h && o.set(l, h);
|
|
3100
|
+
});
|
|
2966
3101
|
}
|
|
2967
|
-
|
|
3102
|
+
if (a.length > 0) {
|
|
3103
|
+
const u = /* @__PURE__ */ new Map();
|
|
3104
|
+
r.forEach((d, l) => {
|
|
3105
|
+
o.has(l) || u.set(l, d);
|
|
3106
|
+
});
|
|
3107
|
+
const f = {
|
|
3108
|
+
...t,
|
|
3109
|
+
value: a,
|
|
3110
|
+
options: { ...t.options, invert: !1 }
|
|
3111
|
+
};
|
|
3112
|
+
this.scanDataset(e, f, u).forEach((d, l) => o.set(l, d));
|
|
3113
|
+
}
|
|
3114
|
+
if (!t.options?.invert)
|
|
3115
|
+
return o;
|
|
3116
|
+
const c = /* @__PURE__ */ new Map();
|
|
3117
|
+
return r.forEach((u, f) => {
|
|
3118
|
+
o.has(f) || c.set(f, u);
|
|
3119
|
+
}), c;
|
|
3120
|
+
}
|
|
3121
|
+
/** Evaluates `query` on each item, resolving a deep path's references first. */
|
|
3122
|
+
scanDataset(e, t, r) {
|
|
3123
|
+
const s = /* @__PURE__ */ new Map(), i = this.queryBuilder.extractQueryAttributes({ queries: [t] }).filter((a) => a.isDeepQuery), o = i.length > 0 ? this.queryBuilder.getProjectionForAttributeEntries(i) : void 0;
|
|
3124
|
+
for (let [a, c] of r)
|
|
3125
|
+
o && (c = this.globalItemService.getProjectedData(
|
|
3126
|
+
o,
|
|
3127
|
+
this.modelParser.models.get(e.modelKey),
|
|
3128
|
+
c
|
|
3129
|
+
)), this.evaluateQuery(t, c) && s.set(a, c);
|
|
3130
|
+
return s;
|
|
2968
3131
|
}
|
|
2969
|
-
equalRegexFn(e, t) {
|
|
2970
|
-
|
|
3132
|
+
equalRegexFn(e, t, r) {
|
|
3133
|
+
const s = P(t, r);
|
|
3134
|
+
if (s)
|
|
2971
3135
|
try {
|
|
2972
|
-
return new RegExp(
|
|
3136
|
+
return new RegExp(s.pattern, s.flags).test(e);
|
|
2973
3137
|
} catch {
|
|
2974
3138
|
return !1;
|
|
2975
3139
|
}
|
|
2976
|
-
else return Array.isArray(e) ? !!e.find(
|
|
3140
|
+
else return Array.isArray(e) ? !!e.find(
|
|
3141
|
+
(i) => k(i, t, (o, a) => this.equalRegexFn(o, a, r))
|
|
3142
|
+
) : typeof t == "object" ? q(e, t) : e === t;
|
|
2977
3143
|
}
|
|
2978
|
-
queryFind(e, t, r) {
|
|
2979
|
-
|
|
3144
|
+
queryFind(e, t, r, s) {
|
|
3145
|
+
const i = (o, a) => this.equalRegexFn(o, a, s);
|
|
3146
|
+
return Array.isArray(e) ? typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? this.matchValues(e, r, (o) => k(o, t, i)) : t !== null && typeof t == "object" ? this.matchValues(e, r, (o) => q(o, t)) : !!J(e, t) : k(e, t, i);
|
|
2980
3147
|
}
|
|
2981
3148
|
validateQuery(e) {
|
|
2982
3149
|
if (this.queryBuilder.isQuery(e)) {
|
|
@@ -2984,6 +3151,8 @@ class it {
|
|
|
2984
3151
|
throw new Error("invalid query - missing attribute or operator");
|
|
2985
3152
|
if (e.operator === "find" && Array.isArray(e.value))
|
|
2986
3153
|
throw new Error("invalid query - find operator cannot have array value");
|
|
3154
|
+
if (e.operator === "in" && !Array.isArray(e.value))
|
|
3155
|
+
throw new Error("invalid query - in operator needs an array value");
|
|
2987
3156
|
return !0;
|
|
2988
3157
|
} else {
|
|
2989
3158
|
if (this.queryBuilder.isQueryGroup(e))
|
|
@@ -2997,48 +3166,30 @@ class it {
|
|
|
2997
3166
|
const o = t.options?.invert === !0, a = /* @__PURE__ */ new Set();
|
|
2998
3167
|
for (let c of r.values()) {
|
|
2999
3168
|
const u = this.queryBuilder.extractQueryAttributes({ queries: [t] });
|
|
3000
|
-
if (u.some((
|
|
3001
|
-
const
|
|
3002
|
-
u.filter((
|
|
3169
|
+
if (u.some((h) => h.isDeepQuery)) {
|
|
3170
|
+
const h = this.queryBuilder.getProjectionForAttributeEntries(
|
|
3171
|
+
u.filter((p) => p.isDeepQuery)
|
|
3003
3172
|
);
|
|
3004
3173
|
c = this.globalItemService.getProjectedData(
|
|
3005
|
-
|
|
3174
|
+
h,
|
|
3006
3175
|
this.modelParser.models.get(e.modelKey),
|
|
3007
3176
|
c
|
|
3008
3177
|
);
|
|
3009
3178
|
}
|
|
3010
|
-
const
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
l && (a.add(c.key), o || i.set(c.key, c));
|
|
3179
|
+
const d = this.handleArrayStarQuery(t, c).queries.map((h) => ({
|
|
3180
|
+
...h,
|
|
3181
|
+
options: { ...h.options, invert: !1 }
|
|
3182
|
+
}));
|
|
3183
|
+
this.matchValues(
|
|
3184
|
+
d,
|
|
3185
|
+
t.options?.arrayValueHandling || "some",
|
|
3186
|
+
(h) => this.evaluateQuery(h, c)
|
|
3187
|
+
) && (a.add(c.key), o || i.set(c.key, c));
|
|
3020
3188
|
}
|
|
3021
3189
|
if (o)
|
|
3022
3190
|
for (const [c, u] of r)
|
|
3023
3191
|
a.has(c) || i.set(c, u);
|
|
3024
|
-
} else
|
|
3025
|
-
if (t.operator === "eq")
|
|
3026
|
-
return this.evaluateEqOperator(e, t, r, s);
|
|
3027
|
-
for (let [o, a] of r) {
|
|
3028
|
-
const c = this.queryBuilder.extractQueryAttributes({ queries: [t] });
|
|
3029
|
-
if (c.some((u) => u.isDeepQuery)) {
|
|
3030
|
-
const u = this.queryBuilder.getProjectionForAttributeEntries(
|
|
3031
|
-
c.filter((f) => f.isDeepQuery)
|
|
3032
|
-
);
|
|
3033
|
-
a = this.globalItemService.getProjectedData(
|
|
3034
|
-
u,
|
|
3035
|
-
this.modelParser.models.get(e.modelKey),
|
|
3036
|
-
a
|
|
3037
|
-
);
|
|
3038
|
-
}
|
|
3039
|
-
this.evaluateQuery(t, a) && i.set(o, a);
|
|
3040
|
-
}
|
|
3041
|
-
}
|
|
3192
|
+
} 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);
|
|
3042
3193
|
return i;
|
|
3043
3194
|
}
|
|
3044
3195
|
handleArrayStarQuery(e, t) {
|
|
@@ -3074,8 +3225,8 @@ class it {
|
|
|
3074
3225
|
});
|
|
3075
3226
|
else {
|
|
3076
3227
|
const f = O(Array.from(o.values()), Array.from(u.values()), "key");
|
|
3077
|
-
for (const
|
|
3078
|
-
o.delete(
|
|
3228
|
+
for (const d of f)
|
|
3229
|
+
o.delete(d.key);
|
|
3079
3230
|
}
|
|
3080
3231
|
t.groupType === "and" ? a = o : a = r;
|
|
3081
3232
|
}
|
|
@@ -3121,19 +3272,40 @@ class it {
|
|
|
3121
3272
|
// }
|
|
3122
3273
|
// }
|
|
3123
3274
|
}
|
|
3124
|
-
const Oe =
|
|
3275
|
+
const Oe = /* @__PURE__ */ new Set([
|
|
3276
|
+
"apikey",
|
|
3277
|
+
"api-key",
|
|
3278
|
+
"managerkey",
|
|
3279
|
+
"token",
|
|
3280
|
+
"proxy-key",
|
|
3281
|
+
"proxykey",
|
|
3282
|
+
"manager-key",
|
|
3283
|
+
"sdk-key"
|
|
3284
|
+
]);
|
|
3285
|
+
function at(n) {
|
|
3286
|
+
const e = n.indexOf("?");
|
|
3287
|
+
if (e < 0) return n;
|
|
3288
|
+
const t = n.slice(e + 1).split("&").map((r) => {
|
|
3289
|
+
const s = r.indexOf("=");
|
|
3290
|
+
if (s < 0) return r;
|
|
3291
|
+
const i = r.slice(0, s);
|
|
3292
|
+
return Oe.has(i.toLowerCase()) ? `${i}=<redacted>` : r;
|
|
3293
|
+
}).join("&");
|
|
3294
|
+
return `${n.slice(0, e)}?${t}`;
|
|
3295
|
+
}
|
|
3296
|
+
const qe = "k:", Re = "h:";
|
|
3125
3297
|
function Q(n, e = 0) {
|
|
3126
3298
|
if (n.key)
|
|
3127
|
-
return `${
|
|
3128
|
-
const t =
|
|
3299
|
+
return `${qe}${n.key}`;
|
|
3300
|
+
const t = D({
|
|
3129
3301
|
type: n.type,
|
|
3130
3302
|
url: n.rawUrl ?? n.url,
|
|
3131
3303
|
model: n.model ?? "",
|
|
3132
3304
|
occurrence: e
|
|
3133
3305
|
});
|
|
3134
|
-
return `${
|
|
3306
|
+
return `${Re}${t}`;
|
|
3135
3307
|
}
|
|
3136
|
-
function
|
|
3308
|
+
function ct(n) {
|
|
3137
3309
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
|
|
3138
3310
|
return n.map((r) => {
|
|
3139
3311
|
const s = `${r.key ?? ""}|${r.type}|${r.rawUrl ?? r.url}|${r.model ?? ""}`;
|
|
@@ -3143,7 +3315,7 @@ function ot(n) {
|
|
|
3143
3315
|
return e.set(s, i + 1), t.add(o), o;
|
|
3144
3316
|
});
|
|
3145
3317
|
}
|
|
3146
|
-
function
|
|
3318
|
+
function ut() {
|
|
3147
3319
|
const n = globalThis;
|
|
3148
3320
|
return typeof n.scheduler?.yield == "function" ? n.scheduler.yield() : typeof n.setImmediate == "function" ? new Promise((e) => n.setImmediate(() => e())) : typeof n.MessageChannel == "function" ? new Promise((e) => {
|
|
3149
3321
|
const t = new n.MessageChannel();
|
|
@@ -3152,7 +3324,7 @@ function at() {
|
|
|
3152
3324
|
}, t.port2.postMessage(null);
|
|
3153
3325
|
}) : new Promise((e) => setTimeout(e, 0));
|
|
3154
3326
|
}
|
|
3155
|
-
class
|
|
3327
|
+
class ft {
|
|
3156
3328
|
scripts = /* @__PURE__ */ new Map();
|
|
3157
3329
|
scriptFunctions = /* @__PURE__ */ new Map();
|
|
3158
3330
|
constructor() {
|
|
@@ -3195,10 +3367,10 @@ class ct {
|
|
|
3195
3367
|
return this.getScriptAsFn(e, i)(t, ...o);
|
|
3196
3368
|
}
|
|
3197
3369
|
}
|
|
3198
|
-
const
|
|
3370
|
+
const dt = (n, e) => n ? (e || (e = {}), n.replace(/\$\{(.*?)\}/g, (t, r) => I(e, r.trim(), ""))) : "", lt = (n) => {
|
|
3199
3371
|
const e = /* @__PURE__ */ new Set();
|
|
3200
3372
|
return n.replace(/\$\{(.*?)\}/g, (r, s) => (e.add(s.trim()), "")), { variables: Array.from(e).map((r) => ({ name: r })) };
|
|
3201
|
-
},
|
|
3373
|
+
}, ht = [
|
|
3202
3374
|
"any",
|
|
3203
3375
|
"Array<date>",
|
|
3204
3376
|
"Array<float>",
|
|
@@ -3210,8 +3382,9 @@ const ut = (n, e) => n ? (e || (e = {}), n.replace(/\$\{(.*?)\}/g, (t, r) => I(e
|
|
|
3210
3382
|
"int",
|
|
3211
3383
|
"json",
|
|
3212
3384
|
"string"
|
|
3213
|
-
],
|
|
3385
|
+
], pt = ["int", "float", "Array<int>", "Array<float>"], gt = ["date", "Array<date>"], yt = [
|
|
3214
3386
|
"eq",
|
|
3387
|
+
"in",
|
|
3215
3388
|
"find",
|
|
3216
3389
|
"gt",
|
|
3217
3390
|
"gte",
|
|
@@ -3222,65 +3395,67 @@ const ut = (n, e) => n ? (e || (e = {}), n.replace(/\$\{(.*?)\}/g, (t, r) => I(e
|
|
|
3222
3395
|
"size"
|
|
3223
3396
|
];
|
|
3224
3397
|
export {
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3398
|
+
qe as AUTHORED_RESOURCE_ID_PREFIX,
|
|
3399
|
+
Fe as AnalyticsController,
|
|
3400
|
+
Ge as AttributeDependencyGraph,
|
|
3401
|
+
_e as CacheController,
|
|
3402
|
+
He as ChangeDetector,
|
|
3403
|
+
Re as DERIVED_RESOURCE_ID_PREFIX,
|
|
3404
|
+
gt as DatePropertyTypes,
|
|
3405
|
+
L as DcuplQueryBuilder,
|
|
3406
|
+
yt as DcuplQueryOperatorsAsArray,
|
|
3407
|
+
de as DeepQueryService,
|
|
3235
3408
|
X as DependencyGraph,
|
|
3236
3409
|
xe as IndicesController,
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3410
|
+
g as Logger,
|
|
3411
|
+
pt as NumberPropertyTypes,
|
|
3412
|
+
ht as PropertyTypesAsArray,
|
|
3413
|
+
ot as QueryManager,
|
|
3414
|
+
ft as ScriptController,
|
|
3415
|
+
B as clone,
|
|
3243
3416
|
Ke as coerceStringType,
|
|
3244
3417
|
re as compareVersions,
|
|
3245
|
-
|
|
3246
|
-
|
|
3418
|
+
Ze as computeSuggestions,
|
|
3419
|
+
m as deepQueryService,
|
|
3247
3420
|
te as escapeRegExp,
|
|
3248
|
-
|
|
3249
|
-
|
|
3421
|
+
dt as evaluateTemplate,
|
|
3422
|
+
rt as generateBooleanQuery,
|
|
3250
3423
|
ee as generateKey,
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3424
|
+
st as generateNumberAndDateQuery,
|
|
3425
|
+
nt as generateReferenceQuery,
|
|
3426
|
+
tt as generateTextQuery,
|
|
3254
3427
|
C as getAggregation,
|
|
3255
3428
|
Pe as getDateConstraintUid,
|
|
3256
3429
|
$e as getDcuplPropertyTypeForNativeType,
|
|
3257
|
-
|
|
3430
|
+
w as getDeepPathValues,
|
|
3258
3431
|
me as getDistinct,
|
|
3259
|
-
|
|
3432
|
+
Ye as getFacets,
|
|
3260
3433
|
ze as getFilterEntryId,
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3434
|
+
je as getNumberConstraintUid,
|
|
3435
|
+
et as getPropertiesForData,
|
|
3436
|
+
Le as groupBy,
|
|
3437
|
+
Ve as hasMinimumVersion,
|
|
3265
3438
|
Ne as inferModel,
|
|
3266
3439
|
se as isDateInstance,
|
|
3267
|
-
|
|
3268
|
-
|
|
3440
|
+
Ce as isFloat,
|
|
3441
|
+
Ee as isInt,
|
|
3269
3442
|
ne as isValidDate,
|
|
3270
|
-
|
|
3271
|
-
|
|
3443
|
+
it as isValidQueryStatement,
|
|
3444
|
+
T as isValidVersion,
|
|
3272
3445
|
Y as logger,
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3446
|
+
ke as looksDateLike,
|
|
3447
|
+
Xe as parseDate,
|
|
3448
|
+
P as parseRegexLiteral,
|
|
3449
|
+
lt as parseTemplate,
|
|
3276
3450
|
b as perf,
|
|
3277
|
-
|
|
3278
|
-
|
|
3451
|
+
U as pivot,
|
|
3452
|
+
at as redactUrl,
|
|
3453
|
+
Ue as removeTrailingSlash,
|
|
3279
3454
|
Q as resolveResourceId,
|
|
3280
|
-
|
|
3281
|
-
|
|
3455
|
+
ct as resolveResourceIds,
|
|
3456
|
+
Je as trigger,
|
|
3282
3457
|
We as unescapeRegExp,
|
|
3283
3458
|
Be as uniqBy,
|
|
3284
|
-
|
|
3459
|
+
ut as yieldToEventLoop
|
|
3285
3460
|
};
|
|
3286
3461
|
//# sourceMappingURL=index.js.map
|