@dcupl/common 2.0.0-beta.5 → 2.0.0-beta.6
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/getFacets.d.ts +23 -0
- package/dist/esm/index.js +718 -663
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/property-parser.d.ts +20 -0
- package/dist/esm/types/app-loader.types.d.ts +18 -1
- package/dist/esm/types/data.types.d.ts +5 -2
- package/dist/esm/types/dcupl.types.d.ts +12 -0
- package/dist/esm/types/facets.types.d.ts +5 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/types/key-property.types.d.ts +11 -0
- package/dist/esm/types/list.types.d.ts +16 -0
- package/dist/esm/types/model.types.d.ts +10 -1
- package/dist/esm/types/quality.types.d.ts +55 -1
- package/dist/esm/types/query.types.d.ts +17 -8
- package/dist/node/index.cjs +2 -2
- package/dist/node/index.cjs.map +1 -1
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { cloneDeep as
|
|
2
|
-
function
|
|
3
|
-
const e =
|
|
4
|
-
return
|
|
1
|
+
import { cloneDeep as v, get as K, every as z, findIndex as C, size as W, isEqual as E, differenceBy as O, startsWith as L, endsWith as H, isEqualWith as S, isMatch as V, find as U } from "lodash-es";
|
|
2
|
+
function N(n) {
|
|
3
|
+
const e = Q(n);
|
|
4
|
+
return J(e);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
if (typeof
|
|
8
|
-
return String(
|
|
9
|
-
if (Array.isArray(
|
|
10
|
-
return "[" +
|
|
11
|
-
const e = Object.keys(
|
|
6
|
+
function Q(n) {
|
|
7
|
+
if (typeof n != "object" || n === null)
|
|
8
|
+
return String(n);
|
|
9
|
+
if (Array.isArray(n))
|
|
10
|
+
return "[" + n.map(Q).join(",") + "]";
|
|
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 + ":" + Q(n[s]), r < e.length - 1 && (t += ",");
|
|
16
16
|
}
|
|
17
17
|
return t += "}", t;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function J(n) {
|
|
20
20
|
let e = 0;
|
|
21
|
-
for (let t = 0; t <
|
|
22
|
-
const r =
|
|
21
|
+
for (let t = 0; t < n.length; t++) {
|
|
22
|
+
const r = n.charCodeAt(t);
|
|
23
23
|
e = (e << 5) - e + r, e |= 0;
|
|
24
24
|
}
|
|
25
25
|
return e.toString(16);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const b = {
|
|
28
28
|
now: () => typeof performance < "u" && performance.now ? performance.now() : (/* @__PURE__ */ new Date()).getTime(),
|
|
29
|
-
mark: (
|
|
30
|
-
typeof performance < "u" && performance.mark && performance.mark(
|
|
29
|
+
mark: (n) => {
|
|
30
|
+
typeof performance < "u" && performance.mark && performance.mark(n);
|
|
31
31
|
},
|
|
32
|
-
measure: (
|
|
33
|
-
typeof performance < "u" && performance.measure && performance.measure(
|
|
32
|
+
measure: (n, e, t) => {
|
|
33
|
+
typeof performance < "u" && performance.measure && performance.measure(n, e, t);
|
|
34
34
|
},
|
|
35
|
-
getEntriesByName(
|
|
35
|
+
getEntriesByName(n) {
|
|
36
36
|
if (typeof performance < "u" && performance.getEntriesByName)
|
|
37
|
-
return performance.getEntriesByName(
|
|
37
|
+
return performance.getEntriesByName(n);
|
|
38
38
|
},
|
|
39
|
-
getEntriesByType(
|
|
39
|
+
getEntriesByType(n) {
|
|
40
40
|
if (typeof performance < "u" && performance.getEntriesByType)
|
|
41
|
-
return performance.getEntriesByType(
|
|
41
|
+
return performance.getEntriesByType(n);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
class
|
|
44
|
+
class qe {
|
|
45
45
|
data;
|
|
46
46
|
enabled = !1;
|
|
47
47
|
constructor() {
|
|
@@ -59,7 +59,7 @@ class Ie {
|
|
|
59
59
|
const t = this.getKey(e.name, e.context), r = {
|
|
60
60
|
name: e.name,
|
|
61
61
|
type: "mark",
|
|
62
|
-
value:
|
|
62
|
+
value: b.now(),
|
|
63
63
|
createdAt: Date.now()
|
|
64
64
|
};
|
|
65
65
|
return this.data.set(t, r), r;
|
|
@@ -69,9 +69,9 @@ class Ie {
|
|
|
69
69
|
const t = this.getKey(e.name, e.context), r = this.data.get(this.getKey(e.start, e.context)), s = this.data.get(this.getKey(e.end, e.context));
|
|
70
70
|
if (!r || !s)
|
|
71
71
|
return;
|
|
72
|
-
const
|
|
72
|
+
const o = s.value - r.value, i = Math.round(o * 100) / 100, a = this.data.get(t);
|
|
73
73
|
if (a && e.sum) {
|
|
74
|
-
const c = a.value +
|
|
74
|
+
const c = a.value + i, f = {
|
|
75
75
|
...a,
|
|
76
76
|
value: c
|
|
77
77
|
};
|
|
@@ -80,7 +80,7 @@ class Ie {
|
|
|
80
80
|
const u = {
|
|
81
81
|
name: e.name,
|
|
82
82
|
type: "measure",
|
|
83
|
-
value:
|
|
83
|
+
value: i,
|
|
84
84
|
createdAt: Date.now()
|
|
85
85
|
};
|
|
86
86
|
return e.detail && (u.detail = e.detail), this.data.set(t, u), u;
|
|
@@ -96,7 +96,7 @@ class Ie {
|
|
|
96
96
|
return this.data.get(t);
|
|
97
97
|
}
|
|
98
98
|
getResourceInfosFromPerformanceAPI() {
|
|
99
|
-
return typeof performance > "u" ? [] :
|
|
99
|
+
return typeof performance > "u" ? [] : b.getEntriesByType("resource");
|
|
100
100
|
}
|
|
101
101
|
get(e) {
|
|
102
102
|
const t = this.getKey(e.name, e.context);
|
|
@@ -114,11 +114,11 @@ class Ie {
|
|
|
114
114
|
getKey(e, t) {
|
|
115
115
|
if (!t)
|
|
116
116
|
return e;
|
|
117
|
-
const r =
|
|
117
|
+
const r = N(t);
|
|
118
118
|
return e + "_" + r;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
let
|
|
121
|
+
let Z = class R {
|
|
122
122
|
nodes;
|
|
123
123
|
edges;
|
|
124
124
|
nodeKinds = /* @__PURE__ */ new Map();
|
|
@@ -198,10 +198,10 @@ let Y = class B {
|
|
|
198
198
|
if (t.has(s))
|
|
199
199
|
return !0;
|
|
200
200
|
t.add(s);
|
|
201
|
-
const
|
|
202
|
-
if (
|
|
203
|
-
for (let
|
|
204
|
-
if (r(
|
|
201
|
+
const o = this.edges.get(s);
|
|
202
|
+
if (o) {
|
|
203
|
+
for (let i of o)
|
|
204
|
+
if (r(i))
|
|
205
205
|
return !0;
|
|
206
206
|
}
|
|
207
207
|
return t.delete(s), e.add(s), !1;
|
|
@@ -217,36 +217,36 @@ let Y = class B {
|
|
|
217
217
|
* @returns {hasCycle: boolean, path?: string[]} - hasCycle is true if a cycle exists, path contains the cycle nodes
|
|
218
218
|
*/
|
|
219
219
|
validateNoCycles() {
|
|
220
|
-
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), r = [], s = (
|
|
221
|
-
if (e.has(
|
|
220
|
+
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), r = [], s = (o) => {
|
|
221
|
+
if (e.has(o))
|
|
222
222
|
return null;
|
|
223
|
-
if (t.has(
|
|
224
|
-
const a = r.indexOf(
|
|
225
|
-
return r.slice(a).concat([
|
|
223
|
+
if (t.has(o)) {
|
|
224
|
+
const a = r.indexOf(o);
|
|
225
|
+
return r.slice(a).concat([o]);
|
|
226
226
|
}
|
|
227
|
-
t.add(
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
230
|
-
for (let a of
|
|
227
|
+
t.add(o), r.push(o);
|
|
228
|
+
const i = this.edges.get(o);
|
|
229
|
+
if (i)
|
|
230
|
+
for (let a of i) {
|
|
231
231
|
const u = s(a);
|
|
232
232
|
if (u)
|
|
233
233
|
return u;
|
|
234
234
|
}
|
|
235
|
-
return r.pop(), t.delete(
|
|
235
|
+
return r.pop(), t.delete(o), e.add(o), null;
|
|
236
236
|
};
|
|
237
|
-
for (let
|
|
238
|
-
const
|
|
239
|
-
if (
|
|
240
|
-
return { hasCycle: !0, path:
|
|
237
|
+
for (let o of this.nodes) {
|
|
238
|
+
const i = s(o);
|
|
239
|
+
if (i)
|
|
240
|
+
return { hasCycle: !0, path: i };
|
|
241
241
|
}
|
|
242
242
|
return { hasCycle: !1 };
|
|
243
243
|
}
|
|
244
244
|
order(e) {
|
|
245
|
-
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = [],
|
|
245
|
+
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = [], o = e?.allowCycles ?? !1, i = (a) => {
|
|
246
246
|
if (t.has(a))
|
|
247
247
|
return;
|
|
248
248
|
if (r.has(a)) {
|
|
249
|
-
if (
|
|
249
|
+
if (o)
|
|
250
250
|
return;
|
|
251
251
|
throw new Error("Graph has a cycle.");
|
|
252
252
|
}
|
|
@@ -254,11 +254,11 @@ let Y = class B {
|
|
|
254
254
|
const u = this.edges.get(a);
|
|
255
255
|
if (u)
|
|
256
256
|
for (let c of u)
|
|
257
|
-
|
|
257
|
+
i(c);
|
|
258
258
|
r.delete(a), t.add(a), s.push(a);
|
|
259
259
|
};
|
|
260
260
|
for (let a of this.nodes)
|
|
261
|
-
t.has(a) ||
|
|
261
|
+
t.has(a) || i(a);
|
|
262
262
|
return s;
|
|
263
263
|
}
|
|
264
264
|
clear() {
|
|
@@ -326,30 +326,30 @@ let Y = class B {
|
|
|
326
326
|
*/
|
|
327
327
|
plan(e) {
|
|
328
328
|
const t = /* @__PURE__ */ new Map();
|
|
329
|
-
for (const
|
|
330
|
-
for (const
|
|
331
|
-
for (const a of
|
|
329
|
+
for (const i of this.nodes) t.set(i, 0);
|
|
330
|
+
for (const i of this.edges.values())
|
|
331
|
+
for (const a of i) t.set(a, (t.get(a) || 0) + 1);
|
|
332
332
|
const r = [];
|
|
333
|
-
let s = Array.from(this.nodes).filter((
|
|
334
|
-
const
|
|
333
|
+
let s = Array.from(this.nodes).filter((i) => (t.get(i) || 0) === 0);
|
|
334
|
+
const o = /* @__PURE__ */ new Set();
|
|
335
335
|
for (; s.length > 0; ) {
|
|
336
|
-
const
|
|
337
|
-
r.push(
|
|
338
|
-
for (const a of
|
|
339
|
-
if (
|
|
340
|
-
|
|
336
|
+
const i = s.slice();
|
|
337
|
+
r.push(i), s = [];
|
|
338
|
+
for (const a of i) {
|
|
339
|
+
if (o.has(a)) continue;
|
|
340
|
+
o.add(a);
|
|
341
341
|
const u = this.edges.get(a);
|
|
342
342
|
if (u)
|
|
343
343
|
for (const c of u)
|
|
344
344
|
t.set(c, (t.get(c) || 0) - 1), (t.get(c) || 0) === 0 && s.push(c);
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
if (
|
|
347
|
+
if (o.size !== this.nodes.size)
|
|
348
348
|
throw new Error("Graph has a cycle.");
|
|
349
349
|
if (e?.filterKinds && e.filterKinds.length > 0) {
|
|
350
|
-
const
|
|
350
|
+
const i = new Set(e.filterKinds);
|
|
351
351
|
return {
|
|
352
|
-
batches: r.map((a) => a.filter((u) =>
|
|
352
|
+
batches: r.map((a) => a.filter((u) => i.has(this.nodeKinds.get(u))))
|
|
353
353
|
};
|
|
354
354
|
}
|
|
355
355
|
return { batches: r };
|
|
@@ -362,26 +362,26 @@ let Y = class B {
|
|
|
362
362
|
* - 'both': union of upstream and downstream
|
|
363
363
|
*/
|
|
364
364
|
getImpactedNodes(e, t = "downstream", r) {
|
|
365
|
-
const s = new Set(e),
|
|
365
|
+
const s = new Set(e), o = (c) => !r || r.length === 0 || r.includes(this.nodeKinds.get(c) ?? void 0), i = () => {
|
|
366
366
|
const c = /* @__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) && !c.has(l) && (c.add(l), f.push(l));
|
|
371
371
|
}
|
|
372
372
|
return c;
|
|
373
373
|
}, a = () => {
|
|
374
374
|
const c = /* @__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
|
c.has(h) || (c.add(h), f.push(h));
|
|
380
380
|
}
|
|
381
381
|
return c;
|
|
382
382
|
};
|
|
383
383
|
let u;
|
|
384
|
-
return t === "both" ? u = /* @__PURE__ */ new Set([...
|
|
384
|
+
return t === "both" ? u = /* @__PURE__ */ new Set([...i(), ...a()]) : t === "upstream" ? u = a() : u = i(), Array.from(u).filter(o);
|
|
385
385
|
}
|
|
386
386
|
toJSON() {
|
|
387
387
|
const e = Array.from(this.nodes).map((r) => ({
|
|
@@ -392,7 +392,7 @@ let Y = class B {
|
|
|
392
392
|
return { nodes: e, edges: t };
|
|
393
393
|
}
|
|
394
394
|
static fromJSON(e) {
|
|
395
|
-
const t = new
|
|
395
|
+
const t = new R();
|
|
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,19 +400,19 @@ let Y = class B {
|
|
|
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)), o = Array.from(t).filter((d) => !r.has(d)), i = new Set(this.getAllEdges().map((d) => d.join("→"))), a = new Set(e.getAllEdges().map((d) => d.join("→"))), u = Array.from(a).filter((d) => !i.has(d)).map((d) => d.split("→")), c = Array.from(i).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
|
-
return { addedNodes: s, removedNodes:
|
|
408
|
+
return { addedNodes: s, removedNodes: o, addedEdges: u, removedEdges: c, kindChanges: f };
|
|
409
409
|
}
|
|
410
410
|
};
|
|
411
|
-
class
|
|
411
|
+
class $e {
|
|
412
412
|
graph;
|
|
413
413
|
nodeIndex;
|
|
414
414
|
constructor() {
|
|
415
|
-
this.graph = new
|
|
415
|
+
this.graph = new Z(), this.nodeIndex = /* @__PURE__ */ new Map();
|
|
416
416
|
}
|
|
417
417
|
/**
|
|
418
418
|
* Creates a unique ID for an attribute node
|
|
@@ -454,10 +454,10 @@ class Qe {
|
|
|
454
454
|
* @returns Array of all impacted attribute nodes (including the changed ones)
|
|
455
455
|
*/
|
|
456
456
|
getImpactedAttributes(e) {
|
|
457
|
-
const t = e.map((a) => this.getNodeId(a.modelKey, a.attributeKey)), s = this.graph.getImpactedNodes(t, "downstream").map((a) => this.nodeIndex.get(a)).filter((a) => a !== void 0),
|
|
458
|
-
return
|
|
457
|
+
const t = e.map((a) => this.getNodeId(a.modelKey, a.attributeKey)), s = this.graph.getImpactedNodes(t, "downstream").map((a) => this.nodeIndex.get(a)).filter((a) => a !== void 0), o = [...e, ...s], i = /* @__PURE__ */ new Set();
|
|
458
|
+
return o.filter((a) => {
|
|
459
459
|
const u = this.getNodeId(a.modelKey, a.attributeKey);
|
|
460
|
-
return
|
|
460
|
+
return i.has(u) ? !1 : (i.add(u), !0);
|
|
461
461
|
});
|
|
462
462
|
}
|
|
463
463
|
/**
|
|
@@ -468,12 +468,12 @@ class Qe {
|
|
|
468
468
|
* @returns Map<modelKey, Map<processingStep, Set<attributeKeys>>>
|
|
469
469
|
*/
|
|
470
470
|
getProcessingOrder(e) {
|
|
471
|
-
const t = /* @__PURE__ */ new Map(), r = [...e].sort((s,
|
|
471
|
+
const t = /* @__PURE__ */ new Map(), r = [...e].sort((s, o) => s.processingStep - o.processingStep);
|
|
472
472
|
for (const s of r) {
|
|
473
|
-
const { modelKey:
|
|
474
|
-
t.has(
|
|
475
|
-
const u = t.get(
|
|
476
|
-
u.has(a) || u.set(a, /* @__PURE__ */ new Set()), u.get(a).add(
|
|
473
|
+
const { modelKey: o, attributeKey: i, processingStep: a } = s;
|
|
474
|
+
t.has(o) || t.set(o, /* @__PURE__ */ new Map());
|
|
475
|
+
const u = t.get(o);
|
|
476
|
+
u.has(a) || u.set(a, /* @__PURE__ */ new Set()), u.get(a).add(i);
|
|
477
477
|
}
|
|
478
478
|
return t;
|
|
479
479
|
}
|
|
@@ -528,14 +528,14 @@ class Qe {
|
|
|
528
528
|
const t = (r, s = /* @__PURE__ */ new Set()) => {
|
|
529
529
|
if (s.has(r)) return 0;
|
|
530
530
|
s.add(r);
|
|
531
|
-
const
|
|
532
|
-
if (
|
|
533
|
-
let
|
|
534
|
-
for (const a of
|
|
531
|
+
const o = this.graph.getDependencies(r);
|
|
532
|
+
if (o.length === 0) return 1;
|
|
533
|
+
let i = 0;
|
|
534
|
+
for (const a of o) {
|
|
535
535
|
const u = t(a, new Set(s));
|
|
536
|
-
|
|
536
|
+
i = Math.max(i, u);
|
|
537
537
|
}
|
|
538
|
-
return
|
|
538
|
+
return i + 1;
|
|
539
539
|
};
|
|
540
540
|
for (const r of this.graph.getNodes()) {
|
|
541
541
|
const s = t(r);
|
|
@@ -554,9 +554,9 @@ class Qe {
|
|
|
554
554
|
validateCompleteness(e) {
|
|
555
555
|
const t = [];
|
|
556
556
|
for (const [r, s] of e)
|
|
557
|
-
for (const
|
|
558
|
-
const
|
|
559
|
-
this.hasNode(
|
|
557
|
+
for (const o of s) {
|
|
558
|
+
const i = this.getNodeId(r, o);
|
|
559
|
+
this.hasNode(i) || t.push({ modelKey: r, attributeKey: o });
|
|
560
560
|
}
|
|
561
561
|
return {
|
|
562
562
|
isComplete: t.length === 0,
|
|
@@ -600,7 +600,7 @@ class Qe {
|
|
|
600
600
|
};
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
|
-
const
|
|
603
|
+
const q = {
|
|
604
604
|
silent: 0,
|
|
605
605
|
error: 1,
|
|
606
606
|
warn: 2,
|
|
@@ -663,23 +663,23 @@ class p {
|
|
|
663
663
|
}
|
|
664
664
|
shouldLog(e) {
|
|
665
665
|
const t = this.getEffectiveLevel();
|
|
666
|
-
return
|
|
666
|
+
return q[e] <= q[t];
|
|
667
667
|
}
|
|
668
668
|
formatMessage(e) {
|
|
669
669
|
if (this.config.format === "json") {
|
|
670
|
-
const
|
|
670
|
+
const i = {
|
|
671
671
|
timestamp: new Date(e.timestamp).toISOString(),
|
|
672
672
|
level: e.level,
|
|
673
673
|
message: e.message
|
|
674
674
|
};
|
|
675
|
-
return e.prefix && (
|
|
675
|
+
return e.prefix && (i.module = e.prefix), e.context && (i.context = e.context), e.error && (i.error = {
|
|
676
676
|
name: e.error.name,
|
|
677
677
|
message: e.error.message,
|
|
678
678
|
stack: e.error.stack
|
|
679
|
-
}), JSON.stringify(
|
|
679
|
+
}), JSON.stringify(i);
|
|
680
680
|
}
|
|
681
|
-
const t = new Date(e.timestamp).toISOString().substring(11, 23), r = e.prefix ? `[${e.prefix}]` : "", s = this.getLevelIcon(e.level),
|
|
682
|
-
return `${t} ${s} ${r} ${e.message}${
|
|
681
|
+
const t = new Date(e.timestamp).toISOString().substring(11, 23), r = e.prefix ? `[${e.prefix}]` : "", s = this.getLevelIcon(e.level), o = e.context ? ` ${JSON.stringify(e.context)}` : "";
|
|
682
|
+
return `${t} ${s} ${r} ${e.message}${o}`.trim();
|
|
683
683
|
}
|
|
684
684
|
getLevelIcon(e) {
|
|
685
685
|
switch (e) {
|
|
@@ -698,7 +698,7 @@ class p {
|
|
|
698
698
|
log(e, t, r, s) {
|
|
699
699
|
if (!this.shouldLog(e))
|
|
700
700
|
return;
|
|
701
|
-
const
|
|
701
|
+
const o = {
|
|
702
702
|
level: e,
|
|
703
703
|
message: t,
|
|
704
704
|
timestamp: Date.now(),
|
|
@@ -707,31 +707,31 @@ class p {
|
|
|
707
707
|
error: s
|
|
708
708
|
};
|
|
709
709
|
if (this.config.onLog) {
|
|
710
|
-
this.config.onLog(
|
|
710
|
+
this.config.onLog(o);
|
|
711
711
|
return;
|
|
712
712
|
}
|
|
713
|
-
const
|
|
713
|
+
const i = this.formatMessage(o);
|
|
714
714
|
if (typeof console < "u")
|
|
715
715
|
switch (e) {
|
|
716
716
|
case "error":
|
|
717
|
-
s ? console.error(
|
|
717
|
+
s ? console.error(i, s) : console.error(i);
|
|
718
718
|
break;
|
|
719
719
|
case "warn":
|
|
720
|
-
console.warn(
|
|
720
|
+
console.warn(i);
|
|
721
721
|
break;
|
|
722
722
|
case "debug":
|
|
723
|
-
console.debug ? console.debug(
|
|
723
|
+
console.debug ? console.debug(i) : console.log(i);
|
|
724
724
|
break;
|
|
725
725
|
default:
|
|
726
|
-
console.log(
|
|
726
|
+
console.log(i);
|
|
727
727
|
}
|
|
728
728
|
}
|
|
729
729
|
/**
|
|
730
730
|
* Log an error message
|
|
731
731
|
*/
|
|
732
732
|
error(e, t, r) {
|
|
733
|
-
const s = t instanceof Error ? t : void 0,
|
|
734
|
-
this.log("error", e,
|
|
733
|
+
const s = t instanceof Error ? t : void 0, o = t instanceof Error ? r : t;
|
|
734
|
+
this.log("error", e, o, s);
|
|
735
735
|
}
|
|
736
736
|
/**
|
|
737
737
|
* Log and track an error (integrates with QualityController)
|
|
@@ -799,8 +799,8 @@ class p {
|
|
|
799
799
|
Object.assign(this.config, e);
|
|
800
800
|
}
|
|
801
801
|
}
|
|
802
|
-
const
|
|
803
|
-
class
|
|
802
|
+
const Y = new p();
|
|
803
|
+
class Fe {
|
|
804
804
|
constructor(e) {
|
|
805
805
|
this.enabled = e, this.cache = /* @__PURE__ */ new Map(), this.cacheDependencies = /* @__PURE__ */ new Map();
|
|
806
806
|
}
|
|
@@ -810,7 +810,7 @@ class Me {
|
|
|
810
810
|
// Track cache hits and misses for statistics
|
|
811
811
|
hitCount = 0;
|
|
812
812
|
missCount = 0;
|
|
813
|
-
log =
|
|
813
|
+
log = Y.child({ prefix: "CacheController" });
|
|
814
814
|
get(e, t) {
|
|
815
815
|
if (!this.enabled) return;
|
|
816
816
|
const r = this.getCacheName(e, t);
|
|
@@ -818,8 +818,8 @@ class Me {
|
|
|
818
818
|
}
|
|
819
819
|
set(e, t, r, s) {
|
|
820
820
|
if (!this.enabled) return;
|
|
821
|
-
const
|
|
822
|
-
this.cache.set(
|
|
821
|
+
const o = this.getCacheName(e, t);
|
|
822
|
+
this.cache.set(o, r), s ? this.cacheDependencies.set(o, s) : this.log.debug(
|
|
823
823
|
`Cache entry '${e}' stored without dependencies. This prevents granular invalidation and may cause stale data.`
|
|
824
824
|
);
|
|
825
825
|
}
|
|
@@ -837,21 +837,21 @@ class Me {
|
|
|
837
837
|
if (!this.enabled) return;
|
|
838
838
|
const t = [];
|
|
839
839
|
for (const [r, s] of this.cacheDependencies) {
|
|
840
|
-
let
|
|
841
|
-
for (const [
|
|
842
|
-
if (s.models.has(
|
|
843
|
-
if (s.modelAttributes.has(
|
|
844
|
-
const u = s.modelAttributes.get(
|
|
840
|
+
let o = !1;
|
|
841
|
+
for (const [i, a] of e) {
|
|
842
|
+
if (s.models.has(i))
|
|
843
|
+
if (s.modelAttributes.has(i)) {
|
|
844
|
+
const u = s.modelAttributes.get(i);
|
|
845
845
|
for (const c of a)
|
|
846
846
|
if (u.has(c)) {
|
|
847
|
-
|
|
847
|
+
o = !0;
|
|
848
848
|
break;
|
|
849
849
|
}
|
|
850
850
|
} else
|
|
851
|
-
|
|
852
|
-
if (
|
|
851
|
+
o = !0;
|
|
852
|
+
if (o) break;
|
|
853
853
|
}
|
|
854
|
-
|
|
854
|
+
o && t.push(r);
|
|
855
855
|
}
|
|
856
856
|
for (const r of t)
|
|
857
857
|
this.cache.delete(r), this.cacheDependencies.delete(r);
|
|
@@ -863,9 +863,9 @@ class Me {
|
|
|
863
863
|
invalidateByModels(e) {
|
|
864
864
|
if (!this.enabled) return;
|
|
865
865
|
const t = new Set(e), r = [];
|
|
866
|
-
for (const [s,
|
|
867
|
-
for (const
|
|
868
|
-
if (
|
|
866
|
+
for (const [s, o] of this.cacheDependencies)
|
|
867
|
+
for (const i of t)
|
|
868
|
+
if (o.models.has(i)) {
|
|
869
869
|
r.push(s);
|
|
870
870
|
break;
|
|
871
871
|
}
|
|
@@ -915,13 +915,13 @@ class Me {
|
|
|
915
915
|
}
|
|
916
916
|
generateContext(e) {
|
|
917
917
|
try {
|
|
918
|
-
return
|
|
918
|
+
return v(e);
|
|
919
919
|
} catch (t) {
|
|
920
920
|
return this.log.error("Error in cache generateContext", t), e;
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
923
|
getCacheName(e, t) {
|
|
924
|
-
const r =
|
|
924
|
+
const r = N(t);
|
|
925
925
|
return e + "_" + r;
|
|
926
926
|
}
|
|
927
927
|
/**
|
|
@@ -939,42 +939,42 @@ class Me {
|
|
|
939
939
|
};
|
|
940
940
|
}
|
|
941
941
|
}
|
|
942
|
-
const
|
|
942
|
+
const Te = (n, e = "") => `${n}#${e}`, Ge = (n) => `${n.gt}_${n.gte}_${n.lt}_${n.lte}_${n.eq}_${n.ne}`, ze = (n) => `${n.gt}_${n.gte}_${n.lt}_${n.lte}_${n.eq}_${n.ne}`, Re = (n, e) => {
|
|
943
943
|
const t = typeof e == "function" ? e : (r) => r[e];
|
|
944
944
|
return [
|
|
945
|
-
...
|
|
946
|
-
const
|
|
947
|
-
return r.has(
|
|
945
|
+
...n.reduce((r, s) => {
|
|
946
|
+
const o = s == null ? s : t(s);
|
|
947
|
+
return r.has(o) || r.set(o, s), r;
|
|
948
948
|
}, /* @__PURE__ */ new Map()).values()
|
|
949
949
|
];
|
|
950
|
-
},
|
|
950
|
+
}, je = (n, e) => n.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
|
}, {});
|
|
954
|
-
function
|
|
954
|
+
function X(n = 10) {
|
|
955
955
|
let e = "";
|
|
956
956
|
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
957
|
-
for (let r = 0; r <
|
|
957
|
+
for (let r = 0; r < n; r++) e += t.charAt(Math.floor(Math.random() * t.length));
|
|
958
958
|
return e;
|
|
959
959
|
}
|
|
960
|
-
const
|
|
960
|
+
const Be = (n) => n.replace(/\/+$/, ""), ee = (n) => typeof n != "string" ? "" : n.replace(/[[\]{}()*+?.,\\^$|#]/g, "\\$&"), _e = (n) => typeof n != "string" ? "" : n.replace(/\\([[\]{}()*+?.,\\^$|#])/g, "$1"), Pe = (n, e) => {
|
|
961
961
|
try {
|
|
962
|
-
return
|
|
962
|
+
return te(n, e) >= 0;
|
|
963
963
|
} catch {
|
|
964
964
|
return !1;
|
|
965
965
|
}
|
|
966
|
-
},
|
|
967
|
-
if (
|
|
968
|
-
throw new Error(`Invalid version format: v1="${
|
|
969
|
-
const t =
|
|
966
|
+
}, te = (n, e) => {
|
|
967
|
+
if (!$(n) || !$(e))
|
|
968
|
+
throw new Error(`Invalid version format: v1="${n}", v2="${e}". Expected format: "x.y.z"`);
|
|
969
|
+
const t = n.split(".").map(Number), r = e.split(".").map(Number);
|
|
970
970
|
for (let s = 0; s < 3; s++) {
|
|
971
|
-
const
|
|
972
|
-
if (
|
|
973
|
-
if (
|
|
971
|
+
const o = t[s] || 0, i = r[s] || 0;
|
|
972
|
+
if (o > i) return 1;
|
|
973
|
+
if (o < i) return -1;
|
|
974
974
|
}
|
|
975
975
|
return 0;
|
|
976
|
-
},
|
|
977
|
-
class
|
|
976
|
+
}, $ = (n) => /^\d+(\.\d+){0,2}$/.test(n);
|
|
977
|
+
class We {
|
|
978
978
|
key;
|
|
979
979
|
parentCd;
|
|
980
980
|
dcuplInitOptions;
|
|
@@ -1000,7 +1000,7 @@ class Ge {
|
|
|
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 = b.now(), e.duration = e.start - e.end), this.updateListener.forEach((t) => {
|
|
1004
1004
|
t(e);
|
|
1005
1005
|
});
|
|
1006
1006
|
}
|
|
@@ -1010,17 +1010,17 @@ class Ge {
|
|
|
1010
1010
|
};
|
|
1011
1011
|
}
|
|
1012
1012
|
}
|
|
1013
|
-
const
|
|
1013
|
+
const j = (n, e) => e ? typeof structuredClone < "u" ? structuredClone(n) : v(n) : n, F = (n, e, t, r, s, o) => {
|
|
1014
1014
|
try {
|
|
1015
|
-
const
|
|
1016
|
-
if (t.scope === "list" && (t.listKey =
|
|
1015
|
+
const i = !!e.dcuplInitOptions.performance?.clone?.enabled && !!t.cloneResult, a = j(o, i);
|
|
1016
|
+
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__"))
|
|
1017
1017
|
return a;
|
|
1018
|
-
const u =
|
|
1018
|
+
const u = b.now(), c = u - r, f = Math.round(c * 1e3) / 1e3;
|
|
1019
1019
|
t.duration = f, t.start = r, t.end = u;
|
|
1020
|
-
const
|
|
1020
|
+
const d = {
|
|
1021
1021
|
duration: t.duration
|
|
1022
1022
|
};
|
|
1023
|
-
return t.modelKey && (
|
|
1023
|
+
return t.modelKey && (d.model = t.modelKey), t.connectMessageResult && (t.result = a), t.args && (d.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,59 +1028,59 @@ 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: d
|
|
1032
1032
|
}), a;
|
|
1033
1033
|
} catch {
|
|
1034
|
-
return
|
|
1034
|
+
return o;
|
|
1035
1035
|
}
|
|
1036
|
-
},
|
|
1037
|
-
const
|
|
1038
|
-
return s.value = function(...
|
|
1039
|
-
const a =
|
|
1036
|
+
}, Le = (n) => (t, r, s) => {
|
|
1037
|
+
const o = s.value;
|
|
1038
|
+
return s.value = function(...i) {
|
|
1039
|
+
const a = b.now(), u = this.cdRef, c = j(n, !0);
|
|
1040
1040
|
c.key || (u.increaseCounter(), c.key = u.getCounter());
|
|
1041
|
-
const f =
|
|
1041
|
+
const f = X();
|
|
1042
1042
|
u.analyticsController.mark({
|
|
1043
1043
|
name: `${c.type}:start`,
|
|
1044
1044
|
context: f
|
|
1045
1045
|
});
|
|
1046
|
-
const
|
|
1047
|
-
!c.originCdRefKey && u.key && (c.originCdRefKey = u.key),
|
|
1048
|
-
const
|
|
1049
|
-
return c.method = r, c.args =
|
|
1046
|
+
const d = this.model?.key;
|
|
1047
|
+
!c.originCdRefKey && u.key && (c.originCdRefKey = u.key), d && (c.modelKey = d);
|
|
1048
|
+
const l = o.apply(this, i);
|
|
1049
|
+
return c.method = r, c.args = i, l && typeof l == "object" && "then" in l ? l.then((h) => F(this, u, c, a, f, h)) : F(this, u, c, a, f, l);
|
|
1050
1050
|
}, s;
|
|
1051
1051
|
};
|
|
1052
|
-
function
|
|
1052
|
+
function He(n, e, t, r) {
|
|
1053
1053
|
t.max || (t.max = 20);
|
|
1054
|
-
const s = [],
|
|
1055
|
-
for (const [
|
|
1056
|
-
const u = Array.from(a).some((f) =>
|
|
1057
|
-
if (!(t.excludeUndefineds && typeof
|
|
1058
|
-
if (u && (
|
|
1054
|
+
const s = [], o = t.transform ? r.transformValue(t.value, t.transform) : t.value;
|
|
1055
|
+
for (const [i, a] of e.entries()) {
|
|
1056
|
+
const u = Array.from(a).some((f) => n.has(f)), c = t.transform ? r.transformValue(i, t.transform) : i;
|
|
1057
|
+
if (!(t.excludeUndefineds && typeof i > "u") && !(t.excludeNulls && i === null)) {
|
|
1058
|
+
if (u && (o === "" || o === "//")) {
|
|
1059
1059
|
const f = {
|
|
1060
|
-
value:
|
|
1060
|
+
value: i,
|
|
1061
1061
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1062
1062
|
};
|
|
1063
1063
|
s.push(f);
|
|
1064
|
-
} else if (u && typeof
|
|
1065
|
-
if (r.queryFind(c,
|
|
1064
|
+
} else if (u && typeof o == "string" && o.startsWith("/") && o.endsWith("/")) {
|
|
1065
|
+
if (r.queryFind(c, o, "some")) {
|
|
1066
1066
|
const f = {
|
|
1067
|
-
value:
|
|
1067
|
+
value: i,
|
|
1068
1068
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1069
1069
|
};
|
|
1070
1070
|
s.push(f);
|
|
1071
1071
|
}
|
|
1072
|
-
} else if (u && typeof
|
|
1073
|
-
const f = String(c ?? ""),
|
|
1074
|
-
if (f.toLowerCase().startsWith(
|
|
1075
|
-
const
|
|
1076
|
-
value:
|
|
1072
|
+
} else if (u && typeof o == "string") {
|
|
1073
|
+
const f = String(c ?? ""), d = o;
|
|
1074
|
+
if (f.toLowerCase().startsWith(d.toLowerCase())) {
|
|
1075
|
+
const l = {
|
|
1076
|
+
value: i,
|
|
1077
1077
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1078
1078
|
};
|
|
1079
|
-
s.push(
|
|
1079
|
+
s.push(l);
|
|
1080
1080
|
}
|
|
1081
|
-
} else if (u && r.queryFind(c,
|
|
1081
|
+
} else if (u && r.queryFind(c, o, "some")) {
|
|
1082
1082
|
const f = {
|
|
1083
|
-
value:
|
|
1083
|
+
value: i,
|
|
1084
1084
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1085
1085
|
};
|
|
1086
1086
|
s.push(f);
|
|
@@ -1091,13 +1091,13 @@ function je(o, e, t, r) {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
return s;
|
|
1093
1093
|
}
|
|
1094
|
-
function
|
|
1095
|
-
return
|
|
1094
|
+
function re(n) {
|
|
1095
|
+
return n instanceof Date;
|
|
1096
1096
|
}
|
|
1097
|
-
function
|
|
1098
|
-
return
|
|
1097
|
+
function se(n) {
|
|
1098
|
+
return n instanceof Date && !isNaN(n.getTime());
|
|
1099
1099
|
}
|
|
1100
|
-
const
|
|
1100
|
+
const ne = {
|
|
1101
1101
|
yyyy: { type: "year", pattern: "yyyy", regex: "(\\d{4})" },
|
|
1102
1102
|
yy: { type: "year", pattern: "yy", regex: "(\\d{2})" },
|
|
1103
1103
|
MM: { type: "month", pattern: "MM", regex: "(\\d{2})" },
|
|
@@ -1112,28 +1112,28 @@ const ie = {
|
|
|
1112
1112
|
s: { type: "second", pattern: "s", regex: "(\\d{1,2})" },
|
|
1113
1113
|
SSS: { type: "millisecond", pattern: "SSS", regex: "(\\d{3})" }
|
|
1114
1114
|
};
|
|
1115
|
-
function
|
|
1115
|
+
function ie(n) {
|
|
1116
1116
|
let e = "^";
|
|
1117
1117
|
const t = [];
|
|
1118
|
-
let r =
|
|
1119
|
-
const s = Object.entries(
|
|
1118
|
+
let r = n;
|
|
1119
|
+
const s = Object.entries(ne).sort((o, i) => i[0].length - o[0].length);
|
|
1120
1120
|
for (; r.length > 0; ) {
|
|
1121
|
-
let
|
|
1122
|
-
for (const [
|
|
1123
|
-
if (r.startsWith(
|
|
1124
|
-
e += a.regex, t.push({ type: a.type, pattern:
|
|
1121
|
+
let o = !1;
|
|
1122
|
+
for (const [i, a] of s)
|
|
1123
|
+
if (r.startsWith(i)) {
|
|
1124
|
+
e += a.regex, t.push({ type: a.type, pattern: i }), r = r.slice(i.length), o = !0;
|
|
1125
1125
|
break;
|
|
1126
1126
|
}
|
|
1127
|
-
if (!
|
|
1128
|
-
const
|
|
1129
|
-
if (!
|
|
1127
|
+
if (!o) {
|
|
1128
|
+
const i = r[0];
|
|
1129
|
+
if (!i)
|
|
1130
1130
|
break;
|
|
1131
|
-
e +=
|
|
1131
|
+
e += i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), r = r.slice(1);
|
|
1132
1132
|
}
|
|
1133
1133
|
}
|
|
1134
1134
|
return e += "$", { regex: new RegExp(e), tokenOrder: t };
|
|
1135
1135
|
}
|
|
1136
|
-
function
|
|
1136
|
+
function oe(n, e) {
|
|
1137
1137
|
const t = {
|
|
1138
1138
|
year: 1970,
|
|
1139
1139
|
month: 1,
|
|
@@ -1144,54 +1144,54 @@ function ae(o, e) {
|
|
|
1144
1144
|
millisecond: 0
|
|
1145
1145
|
};
|
|
1146
1146
|
for (let r = 0; r < e.length; r++) {
|
|
1147
|
-
const s =
|
|
1147
|
+
const s = n[r + 1];
|
|
1148
1148
|
if (!s)
|
|
1149
1149
|
continue;
|
|
1150
|
-
const
|
|
1151
|
-
|
|
1150
|
+
const o = parseInt(s, 10), i = e[r];
|
|
1151
|
+
i && (i.type === "year" && i.pattern === "yy" ? t.year = 2e3 + o : t[i.type] = o);
|
|
1152
1152
|
}
|
|
1153
1153
|
return t;
|
|
1154
1154
|
}
|
|
1155
|
-
function
|
|
1156
|
-
if (
|
|
1155
|
+
function ae(n) {
|
|
1156
|
+
if (n.month < 1 || n.month > 12)
|
|
1157
1157
|
return /* @__PURE__ */ new Date(NaN);
|
|
1158
|
-
if (
|
|
1158
|
+
if (n.day < 1 || n.day > 31)
|
|
1159
1159
|
return /* @__PURE__ */ new Date(NaN);
|
|
1160
|
-
if (
|
|
1160
|
+
if (n.hour < 0 || n.hour > 23)
|
|
1161
1161
|
return /* @__PURE__ */ new Date(NaN);
|
|
1162
|
-
if (
|
|
1162
|
+
if (n.minute < 0 || n.minute > 59)
|
|
1163
1163
|
return /* @__PURE__ */ new Date(NaN);
|
|
1164
|
-
if (
|
|
1164
|
+
if (n.second < 0 || n.second > 59)
|
|
1165
1165
|
return /* @__PURE__ */ new Date(NaN);
|
|
1166
|
-
if (
|
|
1166
|
+
if (n.millisecond < 0 || n.millisecond > 999)
|
|
1167
1167
|
return /* @__PURE__ */ new Date(NaN);
|
|
1168
1168
|
const e = new Date(
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1169
|
+
n.year,
|
|
1170
|
+
n.month - 1,
|
|
1171
|
+
n.day,
|
|
1172
|
+
n.hour,
|
|
1173
|
+
n.minute,
|
|
1174
|
+
n.second,
|
|
1175
|
+
n.millisecond
|
|
1176
1176
|
);
|
|
1177
|
-
return
|
|
1177
|
+
return se(e) ? e.getFullYear() !== n.year || e.getMonth() !== n.month - 1 || e.getDate() !== n.day ? /* @__PURE__ */ new Date(NaN) : e : /* @__PURE__ */ new Date(NaN);
|
|
1178
1178
|
}
|
|
1179
|
-
function
|
|
1180
|
-
if (
|
|
1181
|
-
const a = Number(
|
|
1179
|
+
function Ve(n, e, t) {
|
|
1180
|
+
if (n = n.trim(), e === "t") {
|
|
1181
|
+
const a = Number(n);
|
|
1182
1182
|
return isNaN(a) ? /* @__PURE__ */ new Date(NaN) : new Date(a * 1e3);
|
|
1183
1183
|
}
|
|
1184
1184
|
if (e === "T") {
|
|
1185
|
-
const a = Number(
|
|
1185
|
+
const a = Number(n);
|
|
1186
1186
|
return isNaN(a) ? /* @__PURE__ */ new Date(NaN) : new Date(a);
|
|
1187
1187
|
}
|
|
1188
|
-
const { regex: r, tokenOrder: s } =
|
|
1189
|
-
if (!
|
|
1188
|
+
const { regex: r, tokenOrder: s } = ie(e), o = n.match(r);
|
|
1189
|
+
if (!o)
|
|
1190
1190
|
return /* @__PURE__ */ new Date(NaN);
|
|
1191
|
-
const
|
|
1192
|
-
return
|
|
1191
|
+
const i = oe(o, s);
|
|
1192
|
+
return ae(i);
|
|
1193
1193
|
}
|
|
1194
|
-
class
|
|
1194
|
+
class ue {
|
|
1195
1195
|
cache;
|
|
1196
1196
|
maxSize;
|
|
1197
1197
|
accessOrder;
|
|
@@ -1234,7 +1234,7 @@ class ce {
|
|
|
1234
1234
|
};
|
|
1235
1235
|
}
|
|
1236
1236
|
}
|
|
1237
|
-
class
|
|
1237
|
+
class ce {
|
|
1238
1238
|
graph;
|
|
1239
1239
|
constructor() {
|
|
1240
1240
|
this.graph = /* @__PURE__ */ new Map();
|
|
@@ -1244,25 +1244,25 @@ class fe {
|
|
|
1244
1244
|
}
|
|
1245
1245
|
hasCycle(e) {
|
|
1246
1246
|
if (e.length === 0) return !1;
|
|
1247
|
-
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = (
|
|
1248
|
-
t.add(
|
|
1249
|
-
const
|
|
1250
|
-
if (
|
|
1251
|
-
for (const a of
|
|
1247
|
+
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = (o) => {
|
|
1248
|
+
t.add(o), r.add(o);
|
|
1249
|
+
const i = this.graph.get(o);
|
|
1250
|
+
if (i) {
|
|
1251
|
+
for (const a of i)
|
|
1252
1252
|
if (t.has(a)) {
|
|
1253
1253
|
if (r.has(a))
|
|
1254
1254
|
return !0;
|
|
1255
1255
|
} else if (s(a))
|
|
1256
1256
|
return !0;
|
|
1257
1257
|
}
|
|
1258
|
-
return r.delete(
|
|
1258
|
+
return r.delete(o), !1;
|
|
1259
1259
|
};
|
|
1260
|
-
for (let
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1260
|
+
for (let o = 0; o < e.length - 1; o++) {
|
|
1261
|
+
const i = e[o], a = e[o + 1];
|
|
1262
|
+
i && a && this.addDependency(i, a);
|
|
1263
1263
|
}
|
|
1264
|
-
for (const
|
|
1265
|
-
if (!t.has(
|
|
1264
|
+
for (const o of e)
|
|
1265
|
+
if (!t.has(o) && s(o))
|
|
1266
1266
|
return !0;
|
|
1267
1267
|
return !1;
|
|
1268
1268
|
}
|
|
@@ -1270,13 +1270,13 @@ class fe {
|
|
|
1270
1270
|
this.graph.clear();
|
|
1271
1271
|
}
|
|
1272
1272
|
}
|
|
1273
|
-
class
|
|
1273
|
+
class fe {
|
|
1274
1274
|
parseCache;
|
|
1275
1275
|
circularRefDetector;
|
|
1276
1276
|
cacheHits = 0;
|
|
1277
1277
|
cacheMisses = 0;
|
|
1278
1278
|
constructor(e = 1e3) {
|
|
1279
|
-
this.parseCache = new
|
|
1279
|
+
this.parseCache = new ue(e), this.circularRefDetector = new ce();
|
|
1280
1280
|
}
|
|
1281
1281
|
/**
|
|
1282
1282
|
* Parse an attribute string into its components
|
|
@@ -1301,9 +1301,9 @@ class le {
|
|
|
1301
1301
|
return this.cacheHits++, this.parseCache.get(e);
|
|
1302
1302
|
this.cacheMisses++;
|
|
1303
1303
|
let t, r;
|
|
1304
|
-
const s = e.includes("."),
|
|
1305
|
-
if (
|
|
1306
|
-
if (r = e.split(/[.[]/)[0],
|
|
1304
|
+
const s = e.includes("."), o = e.includes("["), i = s || o;
|
|
1305
|
+
if (i)
|
|
1306
|
+
if (r = e.split(/[.[]/)[0], o) {
|
|
1307
1307
|
const u = e.indexOf("]");
|
|
1308
1308
|
if (u > -1) {
|
|
1309
1309
|
const c = e.indexOf(".", u + 1);
|
|
@@ -1312,7 +1312,7 @@ class le {
|
|
|
1312
1312
|
} else s && (t = e.substring(e.indexOf(".") + 1));
|
|
1313
1313
|
const a = {
|
|
1314
1314
|
attribute: e,
|
|
1315
|
-
isDeepQuery:
|
|
1315
|
+
isDeepQuery: i
|
|
1316
1316
|
};
|
|
1317
1317
|
return r && (a.reference = r), typeof t < "u" && t !== "" && (a.referenceAttribute = t), this.parseCache.set(e, a), a;
|
|
1318
1318
|
}
|
|
@@ -1365,11 +1365,11 @@ class le {
|
|
|
1365
1365
|
if (!e || e.trim().length === 0)
|
|
1366
1366
|
return r.push("Attribute path cannot be empty"), { valid: !1, errors: r };
|
|
1367
1367
|
(e.startsWith(".") || e.endsWith(".")) && r.push(`Invalid path: Leading or trailing dots are not allowed: ${e}`), e.includes("..") && r.push(`Invalid path: Consecutive dots are not allowed: ${e}`);
|
|
1368
|
-
const s = (e.match(/\[/g) || []).length,
|
|
1369
|
-
s !==
|
|
1370
|
-
const
|
|
1368
|
+
const s = (e.match(/\[/g) || []).length, o = (e.match(/]/g) || []).length;
|
|
1369
|
+
s !== o && r.push(`Invalid bracket notation: Mismatched brackets in ${e}`), e.includes("[]") && r.push(`Invalid bracket notation: Empty brackets not allowed: ${e}`);
|
|
1370
|
+
const i = /\[([^\]]+)\]/g;
|
|
1371
1371
|
let a;
|
|
1372
|
-
for (; (a =
|
|
1372
|
+
for (; (a = i.exec(e)) !== null; ) {
|
|
1373
1373
|
const f = a[1];
|
|
1374
1374
|
f && f !== "*" && !/^\d+$/.test(f) && r.push(`Invalid bracket content: Must be a number or '*', got '${f}' in ${e}`);
|
|
1375
1375
|
}
|
|
@@ -1435,91 +1435,91 @@ class le {
|
|
|
1435
1435
|
return this.getPathSegments(e).length;
|
|
1436
1436
|
}
|
|
1437
1437
|
}
|
|
1438
|
-
const
|
|
1439
|
-
function
|
|
1438
|
+
const y = new fe();
|
|
1439
|
+
function x(n, e) {
|
|
1440
1440
|
if (e.includes("[*]")) {
|
|
1441
|
-
const
|
|
1441
|
+
const o = e.indexOf("[*]"), i = e.substring(0, o), a = e.substring(o + 3), u = i ? K(n, i) : n;
|
|
1442
1442
|
if (!Array.isArray(u)) return [];
|
|
1443
1443
|
const c = [];
|
|
1444
1444
|
for (const f of u)
|
|
1445
|
-
!a || a === "" ? f !== void 0 && c.push(f) : a.startsWith(".") && c.push(...
|
|
1445
|
+
!a || a === "" ? f !== void 0 && c.push(f) : a.startsWith(".") && c.push(...x(f, a.slice(1)));
|
|
1446
1446
|
return c;
|
|
1447
1447
|
}
|
|
1448
1448
|
const t = e.split(".");
|
|
1449
|
-
let r = [
|
|
1450
|
-
for (const
|
|
1451
|
-
const
|
|
1449
|
+
let r = [n];
|
|
1450
|
+
for (const o of t) {
|
|
1451
|
+
const i = [];
|
|
1452
1452
|
for (const a of r)
|
|
1453
1453
|
if (a != null)
|
|
1454
1454
|
if (Array.isArray(a))
|
|
1455
1455
|
for (const u of a) {
|
|
1456
1456
|
if (u == null) continue;
|
|
1457
|
-
const c = u[
|
|
1458
|
-
c !== void 0 &&
|
|
1457
|
+
const c = u[o];
|
|
1458
|
+
c !== void 0 && i.push(c);
|
|
1459
1459
|
}
|
|
1460
1460
|
else {
|
|
1461
|
-
const u = a[
|
|
1462
|
-
u !== void 0 &&
|
|
1461
|
+
const u = a[o];
|
|
1462
|
+
u !== void 0 && i.push(u);
|
|
1463
1463
|
}
|
|
1464
|
-
if (r =
|
|
1464
|
+
if (r = i, r.length === 0) return [];
|
|
1465
1465
|
}
|
|
1466
1466
|
const s = [];
|
|
1467
|
-
for (const
|
|
1468
|
-
if (Array.isArray(
|
|
1469
|
-
for (const
|
|
1470
|
-
else
|
|
1467
|
+
for (const o of r)
|
|
1468
|
+
if (Array.isArray(o))
|
|
1469
|
+
for (const i of o) i !== void 0 && s.push(i);
|
|
1470
|
+
else o !== void 0 && s.push(o);
|
|
1471
1471
|
return s;
|
|
1472
1472
|
}
|
|
1473
|
-
function
|
|
1473
|
+
function I(n) {
|
|
1474
1474
|
let e = 0;
|
|
1475
|
-
for (let t of
|
|
1475
|
+
for (let t of n) {
|
|
1476
1476
|
const r = t.toString().split(".")[1];
|
|
1477
1477
|
r && (e = Math.max(e, r.length));
|
|
1478
1478
|
}
|
|
1479
1479
|
return Math.pow(10, e);
|
|
1480
1480
|
}
|
|
1481
|
-
function T(
|
|
1482
|
-
return (
|
|
1481
|
+
function T(n, e, t) {
|
|
1482
|
+
return (n * t + e * t) / t;
|
|
1483
1483
|
}
|
|
1484
|
-
function de(
|
|
1485
|
-
return
|
|
1484
|
+
function de(n, e, t) {
|
|
1485
|
+
return n * t / (e * t);
|
|
1486
1486
|
}
|
|
1487
|
-
const
|
|
1487
|
+
const k = (n, e, t, r) => {
|
|
1488
1488
|
if (!r)
|
|
1489
1489
|
throw new Error("Attribute not found");
|
|
1490
1490
|
const s = {
|
|
1491
1491
|
attribute: r,
|
|
1492
|
-
types:
|
|
1492
|
+
types: n.types
|
|
1493
1493
|
};
|
|
1494
|
+
let o;
|
|
1495
|
+
(s.types.includes("sum") || s.types.includes("avg")) && (o = ge(r, e));
|
|
1494
1496
|
let i;
|
|
1495
|
-
(s.types.includes("
|
|
1496
|
-
|
|
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));
|
|
1497
|
+
return (s.types.includes("min") || s.types.includes("max")) && (i = he(r, e)), n.types.forEach((a) => {
|
|
1498
|
+
a === "sum" ? s.sum = o?.sum : a === "avg" ? s.avg = o?.average : a === "count" ? s.count = le(r, e) : a === "min" ? s.min = i && i[0] : a === "max" ? s.max = i && i[1] : a === "distinct" ? s.distinct = ye(n, e, t) : a === "group" && (s.group = pe(n, e));
|
|
1499
1499
|
}), s;
|
|
1500
|
-
},
|
|
1501
|
-
const r =
|
|
1500
|
+
}, le = (n, e) => {
|
|
1501
|
+
const r = y.parse(n).isDeepQuery;
|
|
1502
1502
|
let s = 0;
|
|
1503
|
-
for (const
|
|
1504
|
-
if (
|
|
1503
|
+
for (const o of e.values())
|
|
1504
|
+
if (o)
|
|
1505
1505
|
if (r)
|
|
1506
|
-
s +=
|
|
1506
|
+
s += x(o, n).filter((i) => i != null).length;
|
|
1507
1507
|
else {
|
|
1508
|
-
const
|
|
1509
|
-
if (
|
|
1510
|
-
Array.isArray(
|
|
1508
|
+
const i = o[n];
|
|
1509
|
+
if (i == null) continue;
|
|
1510
|
+
Array.isArray(i) ? s += i.filter((a) => a != null).length : s++;
|
|
1511
1511
|
}
|
|
1512
1512
|
return s;
|
|
1513
|
-
},
|
|
1513
|
+
}, he = (n, e) => {
|
|
1514
1514
|
let t, r;
|
|
1515
|
-
const
|
|
1516
|
-
for (const
|
|
1517
|
-
if (!
|
|
1515
|
+
const o = y.parse(n).isDeepQuery;
|
|
1516
|
+
for (const i of e.values()) {
|
|
1517
|
+
if (!i) continue;
|
|
1518
1518
|
let a;
|
|
1519
|
-
if (
|
|
1520
|
-
a =
|
|
1519
|
+
if (o)
|
|
1520
|
+
a = x(i, n);
|
|
1521
1521
|
else {
|
|
1522
|
-
const u = n
|
|
1522
|
+
const u = i[n];
|
|
1523
1523
|
u === void 0 ? a = [] : Array.isArray(u) ? a = u.filter((c) => c !== void 0) : a = [u];
|
|
1524
1524
|
}
|
|
1525
1525
|
for (const u of a)
|
|
@@ -1527,11 +1527,11 @@ const M = (o, e, t, r) => {
|
|
|
1527
1527
|
}
|
|
1528
1528
|
if (!(t === void 0 || r === void 0))
|
|
1529
1529
|
return [t, r];
|
|
1530
|
-
},
|
|
1530
|
+
}, pe = (n, e) => {
|
|
1531
1531
|
const t = [];
|
|
1532
|
-
|
|
1532
|
+
n.groupOptions?.groups?.forEach((i) => {
|
|
1533
1533
|
t.push({
|
|
1534
|
-
option:
|
|
1534
|
+
option: i,
|
|
1535
1535
|
count: 0,
|
|
1536
1536
|
keys: []
|
|
1537
1537
|
});
|
|
@@ -1540,61 +1540,61 @@ const M = (o, e, t, r) => {
|
|
|
1540
1540
|
option: { value: ["$dcupl_not_found"] },
|
|
1541
1541
|
count: 0,
|
|
1542
1542
|
keys: []
|
|
1543
|
-
},
|
|
1544
|
-
for (const
|
|
1543
|
+
}, o = y.parse(n.attribute).isDeepQuery;
|
|
1544
|
+
for (const i of e.values()) {
|
|
1545
1545
|
let a;
|
|
1546
|
-
|
|
1546
|
+
o ? a = x(i, n.attribute) : a = [i[n.attribute]];
|
|
1547
1547
|
let u = !1;
|
|
1548
1548
|
for (const c of a)
|
|
1549
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(
|
|
1551
|
-
!u &&
|
|
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(i.key) || (f.count++, f.keys.push(i.key)), u = !0);
|
|
1551
|
+
!u && n?.groupOptions?.calculateNotFound && (r.count++, r.keys.push(i.key));
|
|
1552
1552
|
}
|
|
1553
|
-
return
|
|
1554
|
-
},
|
|
1553
|
+
return n?.groupOptions?.calculateNotFound && t.push(r), t;
|
|
1554
|
+
}, ge = (n, e) => {
|
|
1555
1555
|
let t = 0, r = 0;
|
|
1556
|
-
const
|
|
1556
|
+
const o = y.parse(n).isDeepQuery;
|
|
1557
1557
|
for (const a of e.values()) {
|
|
1558
1558
|
if (!a) continue;
|
|
1559
1559
|
let u;
|
|
1560
|
-
if (
|
|
1561
|
-
u =
|
|
1560
|
+
if (o)
|
|
1561
|
+
u = x(a, n);
|
|
1562
1562
|
else {
|
|
1563
|
-
const c = a[
|
|
1563
|
+
const c = a[n];
|
|
1564
1564
|
c === void 0 ? u = [] : Array.isArray(c) ? u = c : u = [c];
|
|
1565
1565
|
}
|
|
1566
1566
|
for (const c of u)
|
|
1567
1567
|
if (Array.isArray(c))
|
|
1568
1568
|
for (const f of c)
|
|
1569
|
-
typeof f == "number" && (t = T(t, f,
|
|
1570
|
-
else typeof c == "number" && (t = T(t, c,
|
|
1569
|
+
typeof f == "number" && (t = T(t, f, I([t, f])), r++);
|
|
1570
|
+
else typeof c == "number" && (t = T(t, c, I([t, c])), r++);
|
|
1571
1571
|
}
|
|
1572
1572
|
return r === 0 ? void 0 : {
|
|
1573
|
-
average: de(t, r,
|
|
1573
|
+
average: de(t, r, I([t, r])),
|
|
1574
1574
|
count: r,
|
|
1575
1575
|
sum: t
|
|
1576
1576
|
};
|
|
1577
|
-
},
|
|
1577
|
+
}, ye = (n, e, t) => {
|
|
1578
1578
|
const r = [];
|
|
1579
|
-
for (const [s,
|
|
1580
|
-
if (!(
|
|
1581
|
-
const
|
|
1579
|
+
for (const [s, o] of t)
|
|
1580
|
+
if (!(n.excludeUndefineds && typeof s > "u") && Array.from(o).find((i) => e.has(i))) {
|
|
1581
|
+
const i = {
|
|
1582
1582
|
value: s,
|
|
1583
|
-
count:
|
|
1583
|
+
count: o.size
|
|
1584
1584
|
};
|
|
1585
|
-
if (
|
|
1585
|
+
if (n.distinctOptions?.skipKeys || (i.keys = Array.from(o)), r.push(i), n.distinctOptions?.limit && r.length >= n.distinctOptions.limit)
|
|
1586
1586
|
break;
|
|
1587
1587
|
}
|
|
1588
1588
|
return r;
|
|
1589
1589
|
};
|
|
1590
|
-
class
|
|
1590
|
+
class A extends Error {
|
|
1591
1591
|
query;
|
|
1592
1592
|
constructor(e, t) {
|
|
1593
1593
|
const r = `Query Error: ${e} in ${JSON.stringify(t, null, 2)}`;
|
|
1594
1594
|
super(r), this.query = t, this.name = "DcuplQueryError";
|
|
1595
1595
|
}
|
|
1596
1596
|
}
|
|
1597
|
-
class
|
|
1597
|
+
class B {
|
|
1598
1598
|
_defaultQueryOptions = {
|
|
1599
1599
|
modelKey: "",
|
|
1600
1600
|
groupKey: "root",
|
|
@@ -1602,10 +1602,10 @@ class z {
|
|
|
1602
1602
|
queries: []
|
|
1603
1603
|
};
|
|
1604
1604
|
_initOptions;
|
|
1605
|
-
currentQuery =
|
|
1605
|
+
currentQuery = v(this._defaultQueryOptions);
|
|
1606
1606
|
deepQueryService;
|
|
1607
1607
|
constructor(e) {
|
|
1608
|
-
this.deepQueryService = e ||
|
|
1608
|
+
this.deepQueryService = e || y;
|
|
1609
1609
|
}
|
|
1610
1610
|
/**
|
|
1611
1611
|
* Initialize the query builder.
|
|
@@ -1631,7 +1631,7 @@ class z {
|
|
|
1631
1631
|
* });
|
|
1632
1632
|
*/
|
|
1633
1633
|
init(e) {
|
|
1634
|
-
this._initOptions =
|
|
1634
|
+
this._initOptions = v(e), this.currentQuery = v(this._defaultQueryOptions), this.currentQuery.modelKey = e.modelKey, "queries" in e && Array.isArray(e.queries) && (e.groupType && (this.currentQuery.groupType = e.groupType), e.queries && (this.currentQuery.queries = v(e.queries)), e.count !== void 0 && (this.currentQuery.count = e.count), e.start !== void 0 && (this.currentQuery.start = e.start), e.sort && (this.currentQuery.sort = e.sort), e.projection && (this.currentQuery.projection = e.projection));
|
|
1635
1635
|
}
|
|
1636
1636
|
reset() {
|
|
1637
1637
|
return this.init(this._initOptions), this.getQuery();
|
|
@@ -1649,7 +1649,7 @@ class z {
|
|
|
1649
1649
|
return this.currentQuery.queries.find((t) => this.isQueryGroup(t) && t.groupKey === e);
|
|
1650
1650
|
}
|
|
1651
1651
|
getQuery() {
|
|
1652
|
-
return
|
|
1652
|
+
return v(this.currentQuery);
|
|
1653
1653
|
}
|
|
1654
1654
|
hasQueryGroup(e) {
|
|
1655
1655
|
return this.currentQuery.queries.some((t) => this.isQueryGroup(t) && t.groupKey === e);
|
|
@@ -1665,7 +1665,7 @@ class z {
|
|
|
1665
1665
|
}
|
|
1666
1666
|
validate(e) {
|
|
1667
1667
|
const t = e.queries.map((s) => this.validateQuery(s));
|
|
1668
|
-
return { valid:
|
|
1668
|
+
return { valid: z(t, (s) => s.valid), errors: t.map((s) => s.errors).flat() };
|
|
1669
1669
|
}
|
|
1670
1670
|
applyOptions(e, t = "update") {
|
|
1671
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();
|
|
@@ -1697,11 +1697,11 @@ class z {
|
|
|
1697
1697
|
e.groupType && (r.groupType = e.groupType), t?.mode === "set" ? r.queries = e.queries : r.queries = [...r.queries, ...e.queries], this.applyOptions(e, "set");
|
|
1698
1698
|
else if (this.isQuery(e)) {
|
|
1699
1699
|
const s = r.queries.findIndex(
|
|
1700
|
-
(
|
|
1700
|
+
(o) => this.isQueryGroup(o) && o.groupKey === e.attribute
|
|
1701
1701
|
);
|
|
1702
1702
|
if (s > -1) {
|
|
1703
|
-
const
|
|
1704
|
-
t?.mode === "set" ?
|
|
1703
|
+
const o = r.queries[s];
|
|
1704
|
+
t?.mode === "set" ? o.queries = [e] : o.queries.push(e);
|
|
1705
1705
|
} else
|
|
1706
1706
|
r.queries.push({
|
|
1707
1707
|
groupKey: e.attribute,
|
|
@@ -1710,11 +1710,11 @@ class z {
|
|
|
1710
1710
|
});
|
|
1711
1711
|
} else if (this.isQueryGroup(e)) {
|
|
1712
1712
|
const s = r.queries.findIndex(
|
|
1713
|
-
(
|
|
1713
|
+
(o) => this.isQueryGroup(o) && o.groupKey === e.groupKey
|
|
1714
1714
|
);
|
|
1715
1715
|
if (s > -1) {
|
|
1716
|
-
const
|
|
1717
|
-
e.groupType && (
|
|
1716
|
+
const o = r.queries[s];
|
|
1717
|
+
e.groupType && (o.groupType = e.groupType), t?.mode === "set" ? r.queries[s] = e : o.queries = [...o.queries, ...e.queries];
|
|
1718
1718
|
} else
|
|
1719
1719
|
r.queries.push({
|
|
1720
1720
|
groupKey: e.groupKey,
|
|
@@ -1747,8 +1747,8 @@ class z {
|
|
|
1747
1747
|
(s) => this.isQueryGroup(s) && s.groupKey === e.attribute
|
|
1748
1748
|
);
|
|
1749
1749
|
if (r > -1) {
|
|
1750
|
-
const s = t.queries[r],
|
|
1751
|
-
|
|
1750
|
+
const s = t.queries[r], o = C(s.queries, e);
|
|
1751
|
+
o > -1 && s.queries.splice(o, 1), s.queries.length === 0 && t.queries.splice(r, 1);
|
|
1752
1752
|
}
|
|
1753
1753
|
} else if (this.isQueryGroup(e)) {
|
|
1754
1754
|
const r = t.queries.findIndex(
|
|
@@ -1759,9 +1759,9 @@ class z {
|
|
|
1759
1759
|
t.queries.splice(r, 1);
|
|
1760
1760
|
else {
|
|
1761
1761
|
const s = t.queries[r];
|
|
1762
|
-
for (const
|
|
1763
|
-
const
|
|
1764
|
-
|
|
1762
|
+
for (const o of e.queries) {
|
|
1763
|
+
const i = C(s.queries, o);
|
|
1764
|
+
i > -1 && s.queries.splice(i, 1);
|
|
1765
1765
|
}
|
|
1766
1766
|
s.queries.length === 0 && t.queries.splice(r, 1);
|
|
1767
1767
|
}
|
|
@@ -1771,12 +1771,12 @@ class z {
|
|
|
1771
1771
|
validateQuery(e) {
|
|
1772
1772
|
const t = [];
|
|
1773
1773
|
if (this.isQuery(e))
|
|
1774
|
-
return e.attribute || t.push(new
|
|
1774
|
+
return e.attribute || t.push(new A("Missing attribute", e)), e.operator || t.push(new A("Missing operator", e)), typeof e.value > "u" && t.push(new A("Missing value", e)), e.operator === "find" && Array.isArray(e.value) && t.push(new A("find operator cannot have array value", e)), t.length > 0 ? { valid: !1, errors: t } : { valid: !0 };
|
|
1775
1775
|
if (this.isQueryGroup(e)) {
|
|
1776
|
-
const
|
|
1777
|
-
return
|
|
1776
|
+
const o = e.queries.map((i) => this.validateQuery(i)).filter((i) => !i.valid).map((i) => i.errors).flat();
|
|
1777
|
+
return o.length > 0 ? { valid: !1, errors: o } : { valid: !0 };
|
|
1778
1778
|
}
|
|
1779
|
-
return t.push(new
|
|
1779
|
+
return t.push(new A("Invalid query definition", e)), { valid: !1, errors: t };
|
|
1780
1780
|
}
|
|
1781
1781
|
/**
|
|
1782
1782
|
* Get all attribute names used in the query.
|
|
@@ -1786,9 +1786,9 @@ class z {
|
|
|
1786
1786
|
* @returns Array of attribute names
|
|
1787
1787
|
*/
|
|
1788
1788
|
getQueryAttributes(e) {
|
|
1789
|
-
const t = [], r = /* @__PURE__ */ new Set(), s = (
|
|
1790
|
-
for (const
|
|
1791
|
-
this.isQuery(
|
|
1789
|
+
const t = [], r = /* @__PURE__ */ new Set(), s = (o) => {
|
|
1790
|
+
for (const i of o)
|
|
1791
|
+
this.isQuery(i) ? i.attribute && !r.has(i.attribute) && (t.push(i.attribute), r.add(i.attribute)) : this.isQueryGroup(i) && s(i.queries);
|
|
1792
1792
|
};
|
|
1793
1793
|
return s(e?.queries || this.currentQuery.queries), t;
|
|
1794
1794
|
}
|
|
@@ -1800,14 +1800,14 @@ class z {
|
|
|
1800
1800
|
* @returns Array of QueryAttributeEntry objects
|
|
1801
1801
|
*/
|
|
1802
1802
|
extractQueryAttributes(e) {
|
|
1803
|
-
const t = [], r = /* @__PURE__ */ new Set(), s = (
|
|
1804
|
-
for (const
|
|
1805
|
-
if (this.isQuery(
|
|
1806
|
-
if (
|
|
1807
|
-
const a = this.getQueryAttributeForString(
|
|
1808
|
-
t.push(a), r.add(
|
|
1803
|
+
const t = [], r = /* @__PURE__ */ new Set(), s = (o) => {
|
|
1804
|
+
for (const i of o)
|
|
1805
|
+
if (this.isQuery(i)) {
|
|
1806
|
+
if (i.attribute && !r.has(i.attribute)) {
|
|
1807
|
+
const a = this.getQueryAttributeForString(i.attribute);
|
|
1808
|
+
t.push(a), r.add(i.attribute);
|
|
1809
1809
|
}
|
|
1810
|
-
} else this.isQueryGroup(
|
|
1810
|
+
} else this.isQueryGroup(i) && s(i.queries);
|
|
1811
1811
|
};
|
|
1812
1812
|
return s(e?.queries || this.currentQuery.queries), t;
|
|
1813
1813
|
}
|
|
@@ -1848,9 +1848,9 @@ class z {
|
|
|
1848
1848
|
t[r.reference] || (t[r.reference] = { $: !0 });
|
|
1849
1849
|
const s = this.deepQueryService.parse(r.referenceAttribute);
|
|
1850
1850
|
if (s.isDeepQuery && r.reference) {
|
|
1851
|
-
const
|
|
1852
|
-
Object.keys(
|
|
1853
|
-
|
|
1851
|
+
const o = this.getProjectionForAttributeEntries([s]);
|
|
1852
|
+
Object.keys(o).forEach((i) => {
|
|
1853
|
+
i !== "$" && r.reference && (t[r.reference][i] = o[i]);
|
|
1854
1854
|
});
|
|
1855
1855
|
} else r.reference && (t[r.reference][r.referenceAttribute] = !0);
|
|
1856
1856
|
} else
|
|
@@ -2148,13 +2148,13 @@ class z {
|
|
|
2148
2148
|
const t = (r) => {
|
|
2149
2149
|
for (const s of r)
|
|
2150
2150
|
if (this.isQuery(s)) {
|
|
2151
|
-
let
|
|
2152
|
-
for (const
|
|
2153
|
-
if (s[
|
|
2154
|
-
|
|
2151
|
+
let o = !0;
|
|
2152
|
+
for (const i in e)
|
|
2153
|
+
if (s[i] !== e[i]) {
|
|
2154
|
+
o = !1;
|
|
2155
2155
|
break;
|
|
2156
2156
|
}
|
|
2157
|
-
if (
|
|
2157
|
+
if (o) return !0;
|
|
2158
2158
|
} else if (this.isQueryGroup(s) && t(s.queries))
|
|
2159
2159
|
return !0;
|
|
2160
2160
|
return !1;
|
|
@@ -2275,43 +2275,84 @@ class z {
|
|
|
2275
2275
|
return e(this.currentQuery.queries);
|
|
2276
2276
|
}
|
|
2277
2277
|
}
|
|
2278
|
-
const
|
|
2279
|
-
function
|
|
2280
|
-
const a =
|
|
2278
|
+
const M = new B();
|
|
2279
|
+
function Ue(n, e, t, r, s, o, i) {
|
|
2280
|
+
const a = M.removeQuery({ groupKey: s }, v(r)), u = i.queryData(n, a, !1, o), c = e ? [...e.keys()] : [], f = new Set(c), d = o.get(s);
|
|
2281
2281
|
if (!t.excludeUnresolved)
|
|
2282
2282
|
for (const h of d.keys())
|
|
2283
|
-
|
|
2284
|
-
t.excludeUndefineds ?
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2283
|
+
f.add(h);
|
|
2284
|
+
if (t.excludeUndefineds ? f.delete(void 0) : f.add(void 0), t.sort) {
|
|
2285
|
+
const h = [];
|
|
2286
|
+
for (const m of f.values())
|
|
2287
|
+
h.push(G(m, d, u, e, s, r, !0));
|
|
2288
|
+
const g = t.excludeZeros ? h.filter((m) => m.size > 0) : h;
|
|
2289
|
+
return g.sort(me(t.sort)), t.count ? g.slice(0, t.count) : g;
|
|
2290
|
+
}
|
|
2291
|
+
const l = [];
|
|
2292
|
+
for (const h of f.values()) {
|
|
2293
|
+
const g = G(
|
|
2294
|
+
h,
|
|
2295
|
+
d,
|
|
2296
|
+
u,
|
|
2297
|
+
e,
|
|
2298
|
+
s,
|
|
2299
|
+
r,
|
|
2300
|
+
!!t?.calculateFacets
|
|
2301
|
+
);
|
|
2302
|
+
if (!(t?.excludeZeros && g.size === 0)) {
|
|
2303
|
+
if (t?.count && l.length === t?.count)
|
|
2304
|
+
return l;
|
|
2305
|
+
l.push(g);
|
|
2305
2306
|
}
|
|
2306
2307
|
}
|
|
2307
|
-
return
|
|
2308
|
+
return l;
|
|
2309
|
+
}
|
|
2310
|
+
function G(n, e, t, r, s, o, i) {
|
|
2311
|
+
const a = /* @__PURE__ */ new Map(), u = e.get(n) || /* @__PURE__ */ new Set();
|
|
2312
|
+
for (const c of u) {
|
|
2313
|
+
const f = t.get(c);
|
|
2314
|
+
if (f && (a.set(c, f), !i))
|
|
2315
|
+
break;
|
|
2316
|
+
}
|
|
2317
|
+
return {
|
|
2318
|
+
key: String(n),
|
|
2319
|
+
value: n,
|
|
2320
|
+
selected: ve(s, n, o),
|
|
2321
|
+
enabled: a.size > 0,
|
|
2322
|
+
size: a.size,
|
|
2323
|
+
entry: r.get(n),
|
|
2324
|
+
resultKeys: Array.from(a.keys())
|
|
2325
|
+
};
|
|
2326
|
+
}
|
|
2327
|
+
function D(n, e) {
|
|
2328
|
+
if (n === void 0 && e === void 0) return 0;
|
|
2329
|
+
if (n === void 0) return 1;
|
|
2330
|
+
if (e === void 0) return -1;
|
|
2331
|
+
const t = typeof n, r = typeof e;
|
|
2332
|
+
if (t !== r) return t < r ? -1 : 1;
|
|
2333
|
+
if (t === "number") return n - e;
|
|
2334
|
+
if (t === "string") return n.localeCompare(e);
|
|
2335
|
+
const s = String(n), o = String(e);
|
|
2336
|
+
return s < o ? -1 : s > o ? 1 : 0;
|
|
2337
|
+
}
|
|
2338
|
+
function me(n) {
|
|
2339
|
+
switch (n) {
|
|
2340
|
+
case "size-desc":
|
|
2341
|
+
return (e, t) => t.size - e.size || D(e.value, t.value);
|
|
2342
|
+
case "size-asc":
|
|
2343
|
+
return (e, t) => e.size - t.size || D(e.value, t.value);
|
|
2344
|
+
case "value-asc":
|
|
2345
|
+
return (e, t) => D(e.value, t.value);
|
|
2346
|
+
case "value-desc":
|
|
2347
|
+
return (e, t) => e.value === void 0 && t.value === void 0 ? 0 : e.value === void 0 ? 1 : t.value === void 0 ? -1 : -D(e.value, t.value);
|
|
2348
|
+
}
|
|
2308
2349
|
}
|
|
2309
|
-
const ve = (
|
|
2310
|
-
const r = t.queries.findIndex((s) =>
|
|
2311
|
-
return r > -1 ? !!t.queries[r].queries.find((
|
|
2312
|
-
if (
|
|
2313
|
-
const
|
|
2314
|
-
return
|
|
2350
|
+
const ve = (n, e, t) => {
|
|
2351
|
+
const r = t.queries.findIndex((s) => M.isQueryGroup(s) && s.groupKey === n);
|
|
2352
|
+
return r > -1 ? !!t.queries[r].queries.find((o) => {
|
|
2353
|
+
if (M.isQuery(o)) {
|
|
2354
|
+
const i = o.value?.key || o.value;
|
|
2355
|
+
return o.attribute === n && i === e;
|
|
2315
2356
|
}
|
|
2316
2357
|
return !1;
|
|
2317
2358
|
}) : !1;
|
|
@@ -2330,33 +2371,33 @@ class we {
|
|
|
2330
2371
|
let r = this.dataMap.get(e);
|
|
2331
2372
|
r || (r = /* @__PURE__ */ new Map(), this.dataMap.set(e, r));
|
|
2332
2373
|
for (const s of t) {
|
|
2333
|
-
let
|
|
2374
|
+
let o;
|
|
2334
2375
|
if (typeof s == "object" && s && s.key)
|
|
2335
|
-
|
|
2376
|
+
o = s.key;
|
|
2336
2377
|
else if (Array.isArray(s)) {
|
|
2337
2378
|
for (const a of s)
|
|
2338
2379
|
this.fillDataMap(e, [a]);
|
|
2339
2380
|
return;
|
|
2340
|
-
} else s instanceof Date ?
|
|
2341
|
-
let
|
|
2342
|
-
|
|
2381
|
+
} else s instanceof Date ? o = s.toISOString() : o = s;
|
|
2382
|
+
let i = r.get(o);
|
|
2383
|
+
i || (i = { key: o }, this.dataMap.get(e)?.set(o, i));
|
|
2343
2384
|
}
|
|
2344
2385
|
}
|
|
2345
2386
|
fillInverseIndex(e, t, r) {
|
|
2346
2387
|
if (!e || !t || !r || !Array.isArray(r))
|
|
2347
2388
|
return;
|
|
2348
2389
|
const s = this.indexMap.get(e) || /* @__PURE__ */ new Map();
|
|
2349
|
-
for (const
|
|
2350
|
-
let
|
|
2351
|
-
if (typeof
|
|
2352
|
-
|
|
2353
|
-
else if (Array.isArray(
|
|
2354
|
-
for (const u of
|
|
2390
|
+
for (const o of r) {
|
|
2391
|
+
let i;
|
|
2392
|
+
if (typeof o == "object" && o && o.key)
|
|
2393
|
+
i = o.key;
|
|
2394
|
+
else if (Array.isArray(o)) {
|
|
2395
|
+
for (const u of o)
|
|
2355
2396
|
this.fillInverseIndex(e, t, [u]);
|
|
2356
2397
|
return;
|
|
2357
|
-
} else
|
|
2358
|
-
let a = s.get(
|
|
2359
|
-
a || (a = /* @__PURE__ */ new Set(), s.set(
|
|
2398
|
+
} else o instanceof Date ? i = o.toISOString() : i = o;
|
|
2399
|
+
let a = s.get(i);
|
|
2400
|
+
a || (a = /* @__PURE__ */ new Set(), s.set(i, a)), a.add(t);
|
|
2360
2401
|
}
|
|
2361
2402
|
this.indexMap.set(e, s);
|
|
2362
2403
|
}
|
|
@@ -2370,12 +2411,12 @@ class we {
|
|
|
2370
2411
|
}
|
|
2371
2412
|
getOrCreateIndex(e, t, r) {
|
|
2372
2413
|
const s = this.getIndexName(e, r);
|
|
2373
|
-
let
|
|
2374
|
-
const
|
|
2375
|
-
if (
|
|
2376
|
-
|
|
2377
|
-
else if (!
|
|
2378
|
-
const u =
|
|
2414
|
+
let o = this.getIndex(s);
|
|
2415
|
+
const i = this.indexMetadata.get(s);
|
|
2416
|
+
if (i)
|
|
2417
|
+
i.lastAccessedAt = Date.now();
|
|
2418
|
+
else if (!o) {
|
|
2419
|
+
const u = y.parse(e).isDeepQuery ?? !1;
|
|
2379
2420
|
this.indexMetadata.set(s, {
|
|
2380
2421
|
createdAt: Date.now(),
|
|
2381
2422
|
lastAccessedAt: Date.now(),
|
|
@@ -2383,19 +2424,19 @@ class we {
|
|
|
2383
2424
|
type: u ? "deep" : "shallow"
|
|
2384
2425
|
});
|
|
2385
2426
|
}
|
|
2386
|
-
if (!
|
|
2427
|
+
if (!o) {
|
|
2387
2428
|
this.reset(s), this.indexMap.set(s, /* @__PURE__ */ new Map());
|
|
2388
|
-
const u =
|
|
2429
|
+
const u = y.parse(e).isDeepQuery;
|
|
2389
2430
|
for (const c of t.values()) {
|
|
2390
2431
|
let f;
|
|
2391
|
-
u ? (f =
|
|
2432
|
+
u ? (f = x(c, e), f.length === 0 && (f = [void 0])) : f = [c[e]], this.fillInverseIndex(s, c.key, f), this.fillDataMap(s, f);
|
|
2392
2433
|
}
|
|
2393
|
-
|
|
2434
|
+
o = this.getIndex(s) || /* @__PURE__ */ new Map();
|
|
2394
2435
|
}
|
|
2395
|
-
return
|
|
2436
|
+
return o;
|
|
2396
2437
|
}
|
|
2397
2438
|
getIndexName(e, t) {
|
|
2398
|
-
return t ? e + "_" +
|
|
2439
|
+
return t ? e + "_" + N(t) : e;
|
|
2399
2440
|
}
|
|
2400
2441
|
// ========== PARTIAL UPDATE METHODS ==========
|
|
2401
2442
|
/**
|
|
@@ -2407,17 +2448,17 @@ class we {
|
|
|
2407
2448
|
removeFromInverseIndex(e, t, r) {
|
|
2408
2449
|
const s = this.indexMap.get(e);
|
|
2409
2450
|
if (s)
|
|
2410
|
-
for (const
|
|
2411
|
-
let
|
|
2412
|
-
if (typeof
|
|
2413
|
-
|
|
2414
|
-
else if (Array.isArray(
|
|
2415
|
-
for (const u of
|
|
2451
|
+
for (const o of r) {
|
|
2452
|
+
let i;
|
|
2453
|
+
if (typeof o == "object" && o && o.key)
|
|
2454
|
+
i = o.key;
|
|
2455
|
+
else if (Array.isArray(o)) {
|
|
2456
|
+
for (const u of o)
|
|
2416
2457
|
this.removeFromInverseIndex(e, t, [u]);
|
|
2417
2458
|
return;
|
|
2418
|
-
} else
|
|
2419
|
-
const a = s.get(
|
|
2420
|
-
a && (a.delete(t), a.size === 0 && s.delete(
|
|
2459
|
+
} else o instanceof Date ? i = o.toISOString() : i = o;
|
|
2460
|
+
const a = s.get(i);
|
|
2461
|
+
a && (a.delete(t), a.size === 0 && s.delete(i));
|
|
2421
2462
|
}
|
|
2422
2463
|
}
|
|
2423
2464
|
/**
|
|
@@ -2439,15 +2480,15 @@ class we {
|
|
|
2439
2480
|
const r = this.dataMap.get(e);
|
|
2440
2481
|
if (r)
|
|
2441
2482
|
for (const s of t) {
|
|
2442
|
-
let
|
|
2483
|
+
let o;
|
|
2443
2484
|
if (typeof s == "object" && s && s.key)
|
|
2444
|
-
|
|
2485
|
+
o = s.key;
|
|
2445
2486
|
else if (Array.isArray(s)) {
|
|
2446
|
-
for (const
|
|
2447
|
-
this.removeFromDataMap(e, [
|
|
2487
|
+
for (const i of s)
|
|
2488
|
+
this.removeFromDataMap(e, [i]);
|
|
2448
2489
|
return;
|
|
2449
|
-
} else s instanceof Date ?
|
|
2450
|
-
r.delete(
|
|
2490
|
+
} else s instanceof Date ? o = s.toISOString() : o = s;
|
|
2491
|
+
r.delete(o);
|
|
2451
2492
|
}
|
|
2452
2493
|
}
|
|
2453
2494
|
/**
|
|
@@ -2489,7 +2530,7 @@ class we {
|
|
|
2489
2530
|
isDeepQueryIndex(e) {
|
|
2490
2531
|
const t = e.includes("_") ? e.split("_")[0] : e;
|
|
2491
2532
|
try {
|
|
2492
|
-
return
|
|
2533
|
+
return y.parse(t).isDeepQuery ?? !1;
|
|
2493
2534
|
} catch {
|
|
2494
2535
|
return !1;
|
|
2495
2536
|
}
|
|
@@ -2539,8 +2580,8 @@ class we {
|
|
|
2539
2580
|
cleanupStaleIndices(e = 300 * 1e3) {
|
|
2540
2581
|
const t = Date.now();
|
|
2541
2582
|
let r = 0;
|
|
2542
|
-
for (const [s,
|
|
2543
|
-
t -
|
|
2583
|
+
for (const [s, o] of this.indexMetadata)
|
|
2584
|
+
t - o.lastAccessedAt > e && (this.reset(s), r++);
|
|
2544
2585
|
return r;
|
|
2545
2586
|
}
|
|
2546
2587
|
/**
|
|
@@ -2550,168 +2591,179 @@ class we {
|
|
|
2550
2591
|
getStats() {
|
|
2551
2592
|
const e = this.getIndexCount(), t = Date.now();
|
|
2552
2593
|
let r = 0, s = 0;
|
|
2553
|
-
for (const
|
|
2554
|
-
const a = t -
|
|
2594
|
+
for (const i of this.indexMetadata.values()) {
|
|
2595
|
+
const a = t - i.createdAt;
|
|
2555
2596
|
r += a, a > s && (s = a);
|
|
2556
2597
|
}
|
|
2557
|
-
const
|
|
2598
|
+
const o = this.indexMetadata.size > 0 ? r / this.indexMetadata.size : 0;
|
|
2558
2599
|
return {
|
|
2559
2600
|
shallow: e.shallow,
|
|
2560
2601
|
deep: e.deep,
|
|
2561
2602
|
total: e.total,
|
|
2562
2603
|
oldestAge: s,
|
|
2563
|
-
avgAge:
|
|
2604
|
+
avgAge: o
|
|
2564
2605
|
};
|
|
2565
2606
|
}
|
|
2566
2607
|
}
|
|
2567
|
-
const
|
|
2568
|
-
function
|
|
2569
|
-
const
|
|
2608
|
+
const w = "__";
|
|
2609
|
+
function _(n, e, t = { key: "root" }, r = "root", s = new we(), o) {
|
|
2610
|
+
const i = o || n;
|
|
2570
2611
|
for (const a of e.columns)
|
|
2571
|
-
a.attribute && (
|
|
2612
|
+
a.attribute && (y.parse(a.attribute), s.getOrCreateIndex(a.attribute, i));
|
|
2572
2613
|
for (const a of e.rows)
|
|
2573
|
-
a.attribute && (
|
|
2614
|
+
a.attribute && (y.parse(a.attribute), s.getOrCreateIndex(a.attribute, i));
|
|
2574
2615
|
for (const a of e.values)
|
|
2575
|
-
a.attribute && (
|
|
2616
|
+
a.attribute && (y.parse(a.attribute), s.getOrCreateIndex(a.attribute, i));
|
|
2576
2617
|
if (e.rows && e.rows.length > 0) {
|
|
2577
2618
|
t.rows = t.rows || [];
|
|
2578
|
-
const a = xe(
|
|
2619
|
+
const a = xe(n, e.rows[0], e, s, r, o);
|
|
2579
2620
|
t.rows.push(a);
|
|
2580
2621
|
}
|
|
2581
2622
|
if (e.columns && e.columns.length > 0) {
|
|
2582
2623
|
t.columns = t.columns || [];
|
|
2583
|
-
const a =
|
|
2624
|
+
const a = P(n, e.columns[0], e, s, r, o);
|
|
2584
2625
|
t.columns.push(a);
|
|
2585
2626
|
}
|
|
2586
2627
|
if (t.key === "root")
|
|
2587
2628
|
for (const a of e.values) {
|
|
2588
2629
|
if (t.values = t.values || [], r === "root" && e.options?.calculateTotals === !1)
|
|
2589
2630
|
continue;
|
|
2590
|
-
const u =
|
|
2631
|
+
const u = k(a, n, s.getIndex(a.attribute), a.attribute);
|
|
2591
2632
|
t.values.push(u);
|
|
2592
2633
|
}
|
|
2593
2634
|
return t;
|
|
2594
2635
|
}
|
|
2595
|
-
function xe(
|
|
2596
|
-
const
|
|
2636
|
+
function xe(n, e, t, r, s = "", o) {
|
|
2637
|
+
const i = { key: e.attribute }, a = r.getIndex(e.attribute);
|
|
2597
2638
|
if (!a)
|
|
2598
|
-
return
|
|
2639
|
+
return i;
|
|
2599
2640
|
for (const [u, c] of a.entries()) {
|
|
2600
2641
|
const f = {
|
|
2601
2642
|
key: u,
|
|
2602
2643
|
value: u
|
|
2603
|
-
},
|
|
2604
|
-
for (const
|
|
2605
|
-
|
|
2606
|
-
if (
|
|
2607
|
-
for (const
|
|
2644
|
+
}, d = /* @__PURE__ */ new Map();
|
|
2645
|
+
for (const l of c)
|
|
2646
|
+
n.has(l) && d.set(l, n.get(l));
|
|
2647
|
+
if (d.size) {
|
|
2648
|
+
for (const l of t.values) {
|
|
2608
2649
|
if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
|
|
2609
2650
|
continue;
|
|
2610
|
-
const h =
|
|
2651
|
+
const h = k(l, d, r.getIndex(l.attribute), l.attribute);
|
|
2611
2652
|
f.values.push(h);
|
|
2612
2653
|
}
|
|
2613
|
-
if (
|
|
2614
|
-
const
|
|
2615
|
-
|
|
2616
|
-
l,
|
|
2654
|
+
if (i.rows = i.rows || [], i.rows.push(f), t.rows.length > 1) {
|
|
2655
|
+
const l = { ...t, rows: t.rows.slice(1) };
|
|
2656
|
+
_(
|
|
2617
2657
|
d,
|
|
2658
|
+
l,
|
|
2618
2659
|
f,
|
|
2619
|
-
s +
|
|
2660
|
+
s + w + e.attribute + w + u,
|
|
2620
2661
|
r,
|
|
2621
|
-
|
|
2662
|
+
o
|
|
2622
2663
|
);
|
|
2623
2664
|
} else if (t.columns)
|
|
2624
|
-
for (const
|
|
2665
|
+
for (const l of t.columns) {
|
|
2625
2666
|
f.columns = f.columns || [];
|
|
2626
|
-
const h =
|
|
2627
|
-
l,
|
|
2667
|
+
const h = P(
|
|
2628
2668
|
d,
|
|
2669
|
+
l,
|
|
2629
2670
|
t,
|
|
2630
2671
|
r,
|
|
2631
|
-
s +
|
|
2632
|
-
|
|
2672
|
+
s + w + e.attribute + w + u,
|
|
2673
|
+
o
|
|
2633
2674
|
);
|
|
2634
2675
|
f.columns.push(h);
|
|
2635
2676
|
}
|
|
2636
2677
|
}
|
|
2637
2678
|
}
|
|
2638
|
-
return
|
|
2679
|
+
return i;
|
|
2639
2680
|
}
|
|
2640
|
-
function
|
|
2641
|
-
const
|
|
2681
|
+
function P(n, e, t, r, s = "", o) {
|
|
2682
|
+
const i = { key: e.attribute }, a = r.getIndex(e.attribute);
|
|
2642
2683
|
if (!a)
|
|
2643
|
-
return
|
|
2684
|
+
return i;
|
|
2644
2685
|
for (const [u, c] of a.entries()) {
|
|
2645
2686
|
const f = {
|
|
2646
2687
|
key: u,
|
|
2647
2688
|
value: u
|
|
2648
|
-
},
|
|
2649
|
-
for (const
|
|
2650
|
-
|
|
2651
|
-
if (
|
|
2652
|
-
for (const
|
|
2689
|
+
}, d = /* @__PURE__ */ new Map();
|
|
2690
|
+
for (const l of c)
|
|
2691
|
+
n.has(l) && d.set(l, n.get(l));
|
|
2692
|
+
if (d.size) {
|
|
2693
|
+
for (const l of t.values) {
|
|
2653
2694
|
if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
|
|
2654
2695
|
continue;
|
|
2655
|
-
const h =
|
|
2696
|
+
const h = k(l, d, r.getIndex(l.attribute), l.attribute);
|
|
2656
2697
|
f.values.push(h);
|
|
2657
2698
|
}
|
|
2658
|
-
if (
|
|
2659
|
-
const
|
|
2660
|
-
|
|
2661
|
-
l,
|
|
2699
|
+
if (i.columns = i.columns || [], i.columns.push(f), t.columns.length > 1) {
|
|
2700
|
+
const l = { ...t, columns: t.columns.slice(1) };
|
|
2701
|
+
_(
|
|
2662
2702
|
d,
|
|
2703
|
+
l,
|
|
2663
2704
|
f,
|
|
2664
|
-
s +
|
|
2705
|
+
s + w + e.attribute + w + u,
|
|
2665
2706
|
r,
|
|
2666
|
-
|
|
2707
|
+
o
|
|
2667
2708
|
);
|
|
2668
2709
|
}
|
|
2669
2710
|
}
|
|
2670
2711
|
}
|
|
2671
|
-
return
|
|
2712
|
+
return i;
|
|
2672
2713
|
}
|
|
2673
|
-
const Ae = (
|
|
2674
|
-
const
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
type: d
|
|
2687
|
-
};
|
|
2688
|
-
n.push(y);
|
|
2714
|
+
const Ae = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/, be = /^-?\d+$/, Se = /^-?\d+\.\d+$/, De = /^\d{1,2}([/.-])\d{1,2}\1\d{2,4}$/, Ke = (n) => n === "true" || n === "false" ? "boolean" : be.test(n) ? "int" : Se.test(n) ? "float" : Ae.test(n) && !Number.isNaN(Date.parse(n)) ? "date" : "string", Ie = (n) => De.test(n), Qe = (n) => n == null || n === "", Me = (n) => {
|
|
2715
|
+
const e = [...n];
|
|
2716
|
+
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 };
|
|
2717
|
+
}, Ne = (n, e = {}) => {
|
|
2718
|
+
const r = e.deep ?? (e.sampleSize !== void 0 && e.sampleSize > 1) ? e.sampleSize ?? 1 / 0 : 1, s = e.coerceStrings ?? !0, o = /* @__PURE__ */ new Map(), i = [], a = Math.min(n.length, r);
|
|
2719
|
+
for (let f = 0; f < a; f++) {
|
|
2720
|
+
const d = n[f];
|
|
2721
|
+
if (d)
|
|
2722
|
+
for (const [l, h] of Object.entries(d)) {
|
|
2723
|
+
let g = o.get(l);
|
|
2724
|
+
if (g || (g = { observed: /* @__PURE__ */ new Set(), empty: 0, scanned: 0 }, o.set(l, g), i.push(l)), g.scanned++, Qe(h)) {
|
|
2725
|
+
g.empty++;
|
|
2726
|
+
continue;
|
|
2689
2727
|
}
|
|
2728
|
+
let m;
|
|
2729
|
+
typeof h == "string" && s ? (m = Ke(h), m === "string" && !g.hint && Ie(h) && (g.hint = "column looks date-like (non-ISO) — review manually")) : m = Ee(h), g.observed.add(m);
|
|
2690
2730
|
}
|
|
2691
2731
|
}
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2732
|
+
const u = [], c = [];
|
|
2733
|
+
for (const f of i) {
|
|
2734
|
+
const d = o.get(f), { type: l, conflict: h } = Me(d.observed.size ? d.observed : /* @__PURE__ */ new Set(["string"]));
|
|
2735
|
+
u.push({ key: f, type: l }), c.push({
|
|
2736
|
+
column: f,
|
|
2737
|
+
inferredType: l,
|
|
2738
|
+
observedTypes: [...d.observed].sort(),
|
|
2739
|
+
emptyRate: d.scanned === 0 ? 0 : d.empty / d.scanned,
|
|
2740
|
+
conflict: h,
|
|
2741
|
+
hint: d.hint
|
|
2742
|
+
});
|
|
2743
|
+
}
|
|
2744
|
+
return { properties: u, diagnostics: c };
|
|
2745
|
+
}, Je = (n, e = !1) => Ne(n, typeof e == "boolean" ? { deep: e } : e).properties, ke = (n) => Number(n) === n && n % 1 === 0, Ce = (n) => Number(n) === n && n % 1 !== 0, Ee = (n) => {
|
|
2746
|
+
switch (typeof n) {
|
|
2695
2747
|
case "string":
|
|
2696
2748
|
return "string";
|
|
2697
2749
|
case "number":
|
|
2698
|
-
return
|
|
2750
|
+
return ke(n) ? "int" : Ce(n) ? "float" : "any";
|
|
2699
2751
|
case "boolean":
|
|
2700
2752
|
return "boolean";
|
|
2701
2753
|
case "object":
|
|
2702
|
-
return
|
|
2754
|
+
return re(n) ? "date" : "json";
|
|
2703
2755
|
default:
|
|
2704
2756
|
return "any";
|
|
2705
2757
|
}
|
|
2706
|
-
},
|
|
2707
|
-
const t =
|
|
2758
|
+
}, Ze = (n, e) => {
|
|
2759
|
+
const t = ee(n.text || ""), r = e?.attributeKey || n.filterKey;
|
|
2708
2760
|
let s;
|
|
2709
|
-
const
|
|
2710
|
-
return
|
|
2711
|
-
groupKey:
|
|
2761
|
+
const o = e?.comparisonType || "containsIgnoreCase";
|
|
2762
|
+
return o === "containsIgnoreCase" ? s = {
|
|
2763
|
+
groupKey: n.filterKey,
|
|
2712
2764
|
queries: [
|
|
2713
2765
|
{
|
|
2714
|
-
queryKey:
|
|
2766
|
+
queryKey: n.text,
|
|
2715
2767
|
attribute: r,
|
|
2716
2768
|
value: `/${t}/`,
|
|
2717
2769
|
operator: "find",
|
|
@@ -2720,11 +2772,11 @@ const Ae = (o) => o == null || o === "", ze = (o, e = !1) => {
|
|
|
2720
2772
|
}
|
|
2721
2773
|
}
|
|
2722
2774
|
]
|
|
2723
|
-
} :
|
|
2724
|
-
groupKey:
|
|
2775
|
+
} : o === "containsIgnoreCaseAndWhitespace" ? s = {
|
|
2776
|
+
groupKey: n.filterKey,
|
|
2725
2777
|
queries: [
|
|
2726
2778
|
{
|
|
2727
|
-
queryKey:
|
|
2779
|
+
queryKey: n.text,
|
|
2728
2780
|
attribute: r,
|
|
2729
2781
|
value: `/${t}/`,
|
|
2730
2782
|
operator: "find",
|
|
@@ -2733,33 +2785,33 @@ const Ae = (o) => o == null || o === "", ze = (o, e = !1) => {
|
|
|
2733
2785
|
}
|
|
2734
2786
|
}
|
|
2735
2787
|
]
|
|
2736
|
-
} :
|
|
2737
|
-
groupKey:
|
|
2788
|
+
} : o === "contains" ? s = {
|
|
2789
|
+
groupKey: n.filterKey,
|
|
2738
2790
|
queries: [
|
|
2739
2791
|
{
|
|
2740
|
-
queryKey:
|
|
2792
|
+
queryKey: n.text,
|
|
2741
2793
|
attribute: r,
|
|
2742
2794
|
value: `/${t}/`,
|
|
2743
2795
|
operator: "find"
|
|
2744
2796
|
}
|
|
2745
2797
|
]
|
|
2746
|
-
} :
|
|
2747
|
-
groupKey:
|
|
2798
|
+
} : o === "equal" ? s = {
|
|
2799
|
+
groupKey: n.filterKey,
|
|
2748
2800
|
queries: [
|
|
2749
2801
|
{
|
|
2750
|
-
queryKey:
|
|
2802
|
+
queryKey: n.text,
|
|
2751
2803
|
attribute: r,
|
|
2752
|
-
value:
|
|
2804
|
+
value: n.text,
|
|
2753
2805
|
operator: "eq"
|
|
2754
2806
|
}
|
|
2755
2807
|
]
|
|
2756
|
-
} :
|
|
2757
|
-
groupKey:
|
|
2808
|
+
} : o === "equalIgnoreCase" && (s = {
|
|
2809
|
+
groupKey: n.filterKey,
|
|
2758
2810
|
queries: [
|
|
2759
2811
|
{
|
|
2760
|
-
queryKey:
|
|
2812
|
+
queryKey: n.text,
|
|
2761
2813
|
attribute: r,
|
|
2762
|
-
value:
|
|
2814
|
+
value: n.text,
|
|
2763
2815
|
operator: "eq",
|
|
2764
2816
|
options: {
|
|
2765
2817
|
transform: ["lowercase"]
|
|
@@ -2767,40 +2819,40 @@ const Ae = (o) => o == null || o === "", ze = (o, e = !1) => {
|
|
|
2767
2819
|
}
|
|
2768
2820
|
]
|
|
2769
2821
|
}), s;
|
|
2770
|
-
},
|
|
2771
|
-
const t = e?.attributeKey ||
|
|
2822
|
+
}, Ye = (n, e) => {
|
|
2823
|
+
const t = e?.attributeKey || n.filterKey;
|
|
2772
2824
|
return {
|
|
2773
|
-
groupKey:
|
|
2825
|
+
groupKey: n.filterKey,
|
|
2774
2826
|
queries: [
|
|
2775
2827
|
{
|
|
2776
|
-
queryKey:
|
|
2828
|
+
queryKey: n.value,
|
|
2777
2829
|
attribute: t,
|
|
2778
|
-
value:
|
|
2830
|
+
value: n.value,
|
|
2779
2831
|
operator: "eq"
|
|
2780
2832
|
}
|
|
2781
2833
|
]
|
|
2782
2834
|
};
|
|
2783
|
-
},
|
|
2784
|
-
const t = e?.attributeKey ||
|
|
2785
|
-
groupKey:
|
|
2835
|
+
}, Xe = (n, e) => {
|
|
2836
|
+
const t = e?.attributeKey || n.filterKey, r = {
|
|
2837
|
+
groupKey: n.filterKey,
|
|
2786
2838
|
queries: []
|
|
2787
2839
|
};
|
|
2788
|
-
return typeof
|
|
2840
|
+
return typeof n.eq < "u" && (r.groupType = "or", Array.isArray(n.eq) ? n.eq.forEach((s) => {
|
|
2789
2841
|
r.queries.push({ attribute: t, value: s, operator: "eq" });
|
|
2790
|
-
}) : r.queries.push({ attribute: t, value:
|
|
2842
|
+
}) : r.queries.push({ attribute: t, value: n.eq, operator: "eq" })), typeof n.ne < "u" && (r.groupType = "and", Array.isArray(n.ne) ? n.ne.forEach((s) => {
|
|
2791
2843
|
r.queries.push({ attribute: t, value: s, operator: "eq", options: { invert: !0 } });
|
|
2792
2844
|
}) : r.queries.push({
|
|
2793
2845
|
attribute: t,
|
|
2794
|
-
value:
|
|
2846
|
+
value: n.ne,
|
|
2795
2847
|
operator: "eq",
|
|
2796
2848
|
options: { invert: !0 }
|
|
2797
|
-
})), typeof
|
|
2798
|
-
},
|
|
2799
|
-
const t = e?.attributeKey ||
|
|
2800
|
-
groupKey:
|
|
2849
|
+
})), 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;
|
|
2850
|
+
}, et = (n, e) => {
|
|
2851
|
+
const t = e?.attributeKey || n.filterKey, r = {
|
|
2852
|
+
groupKey: n.filterKey,
|
|
2801
2853
|
queries: []
|
|
2802
2854
|
};
|
|
2803
|
-
return
|
|
2855
|
+
return n.itemKeys.forEach((s) => {
|
|
2804
2856
|
r.queries.push({
|
|
2805
2857
|
queryKey: s,
|
|
2806
2858
|
attribute: t,
|
|
@@ -2808,13 +2860,13 @@ const Ae = (o) => o == null || o === "", ze = (o, e = !1) => {
|
|
|
2808
2860
|
operator: "eq"
|
|
2809
2861
|
});
|
|
2810
2862
|
}), r;
|
|
2811
|
-
},
|
|
2812
|
-
class
|
|
2863
|
+
}, tt = (n) => !(typeof n.modelKey != "string" || !Array.isArray(n.queries));
|
|
2864
|
+
class rt {
|
|
2813
2865
|
constructor(e, t, r) {
|
|
2814
2866
|
this.scriptController = e, this.globalItemService = t, this.modelParser = r;
|
|
2815
2867
|
}
|
|
2816
2868
|
registeredCustomOperator = /* @__PURE__ */ new Map();
|
|
2817
|
-
queryBuilder = new
|
|
2869
|
+
queryBuilder = new B();
|
|
2818
2870
|
registerCustomOperator(e, t) {
|
|
2819
2871
|
this.registeredCustomOperator.set(e, t);
|
|
2820
2872
|
}
|
|
@@ -2829,62 +2881,62 @@ class Ve {
|
|
|
2829
2881
|
}
|
|
2830
2882
|
evaluateQuery(e, t) {
|
|
2831
2883
|
let r, s = e.value;
|
|
2832
|
-
const
|
|
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 =
|
|
2884
|
+
const o = e.options?.arrayValueHandling || "some";
|
|
2885
|
+
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 = K(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))
|
|
2834
2886
|
return !1;
|
|
2835
2887
|
switch (e.operator) {
|
|
2836
2888
|
case "eq":
|
|
2837
|
-
return e.options?.invert ? !
|
|
2889
|
+
return e.options?.invert ? !E(r, s) : E(r, s);
|
|
2838
2890
|
case "find":
|
|
2839
|
-
return e.options?.invert ? !this.queryFind(r, s,
|
|
2891
|
+
return e.options?.invert ? !this.queryFind(r, s, o) : this.queryFind(r, s, o);
|
|
2840
2892
|
case "lt":
|
|
2841
|
-
return Array.isArray(r) ?
|
|
2893
|
+
return Array.isArray(r) ? o === "some" ? r.some((i) => i < s) : r.every((i) => i < s) : r < s;
|
|
2842
2894
|
case "gt":
|
|
2843
|
-
return Array.isArray(r) ?
|
|
2895
|
+
return Array.isArray(r) ? o === "some" ? r.some((i) => i > s) : r.every((i) => i > s) : r > s;
|
|
2844
2896
|
case "lte":
|
|
2845
|
-
return Array.isArray(r) ?
|
|
2897
|
+
return Array.isArray(r) ? o === "some" ? r.some((i) => i <= s) : r.every((i) => i <= s) : r <= s;
|
|
2846
2898
|
case "gte":
|
|
2847
|
-
return Array.isArray(r) ?
|
|
2899
|
+
return Array.isArray(r) ? o === "some" ? r.some((i) => i >= s) : r.every((i) => i >= s) : r >= s;
|
|
2848
2900
|
case "typeof":
|
|
2849
|
-
return e.options?.invert ? typeof r !== s : Array.isArray(r) ?
|
|
2901
|
+
return e.options?.invert ? typeof r !== s : Array.isArray(r) ? o === "some" ? r.some((i) => typeof i === s) : r.every((i) => typeof i === s) : typeof r === s;
|
|
2850
2902
|
case "isTruthy":
|
|
2851
|
-
return s === !0 ? Array.isArray(r) ?
|
|
2903
|
+
return s === !0 ? Array.isArray(r) ? o === "some" ? r.some((i) => typeof !!i) : r.every((i) => typeof !!i) : !!r : !r;
|
|
2852
2904
|
case "size":
|
|
2853
|
-
return typeof r == "string" ? r.length === s :
|
|
2905
|
+
return typeof r == "string" ? r.length === s : W(r) === s;
|
|
2854
2906
|
default:
|
|
2855
2907
|
if (this.scriptController.hasScript(e.operator))
|
|
2856
2908
|
return this.scriptController.executeScript(e.operator, "operator", { query: e, item: t });
|
|
2857
2909
|
if (this.registeredCustomOperator.has(e.operator)) {
|
|
2858
|
-
const
|
|
2859
|
-
if (typeof
|
|
2860
|
-
return
|
|
2910
|
+
const i = this.registeredCustomOperator.get(e.operator);
|
|
2911
|
+
if (typeof i == "function")
|
|
2912
|
+
return i(e, t);
|
|
2861
2913
|
}
|
|
2862
2914
|
}
|
|
2863
2915
|
return !1;
|
|
2864
2916
|
}
|
|
2865
2917
|
evaluateEqOperator(e, t, r, s) {
|
|
2866
|
-
const
|
|
2867
|
-
if (
|
|
2918
|
+
const o = /* @__PURE__ */ new Map(), i = s.get(t.attribute);
|
|
2919
|
+
if (i) {
|
|
2868
2920
|
let a;
|
|
2869
2921
|
if (typeof t.value == "string" ? a = t.value : t.value?.key && Object.keys(t.value).length === 1 && (a = t.value.key), typeof a < "u") {
|
|
2870
|
-
const u =
|
|
2922
|
+
const u = i.get(a);
|
|
2871
2923
|
if (u)
|
|
2872
2924
|
if (u.forEach((c) => {
|
|
2873
|
-
r.has(c) &&
|
|
2925
|
+
r.has(c) && o.set(c, r.get(c));
|
|
2874
2926
|
}), t.options?.invert) {
|
|
2875
|
-
const c = O(Array.from(r.values()), Array.from(
|
|
2876
|
-
return c.forEach((
|
|
2877
|
-
f.set(
|
|
2927
|
+
const c = O(Array.from(r.values()), Array.from(o.values()), "key"), f = /* @__PURE__ */ new Map();
|
|
2928
|
+
return c.forEach((d) => {
|
|
2929
|
+
f.set(d.key, d);
|
|
2878
2930
|
}), f;
|
|
2879
2931
|
} else
|
|
2880
|
-
return
|
|
2932
|
+
return o;
|
|
2881
2933
|
}
|
|
2882
2934
|
}
|
|
2883
2935
|
for (let [a, u] of r) {
|
|
2884
2936
|
const c = this.queryBuilder.extractQueryAttributes({ queries: [t] });
|
|
2885
2937
|
if (c.some((f) => f.isDeepQuery)) {
|
|
2886
2938
|
const f = this.queryBuilder.getProjectionForAttributeEntries(
|
|
2887
|
-
c.filter((
|
|
2939
|
+
c.filter((d) => d.isDeepQuery)
|
|
2888
2940
|
);
|
|
2889
2941
|
u = this.globalItemService.getProjectedData(
|
|
2890
2942
|
f,
|
|
@@ -2892,21 +2944,21 @@ class Ve {
|
|
|
2892
2944
|
u
|
|
2893
2945
|
);
|
|
2894
2946
|
}
|
|
2895
|
-
this.evaluateQuery(t, u) &&
|
|
2947
|
+
this.evaluateQuery(t, u) && o.set(a, u);
|
|
2896
2948
|
}
|
|
2897
|
-
return
|
|
2949
|
+
return o;
|
|
2898
2950
|
}
|
|
2899
2951
|
equalRegexFn(e, t) {
|
|
2900
|
-
if (typeof t == "string" &&
|
|
2952
|
+
if (typeof t == "string" && L(t, "/") && H(t, "/"))
|
|
2901
2953
|
try {
|
|
2902
2954
|
return new RegExp(t.slice(1, -1)).test(e);
|
|
2903
2955
|
} catch {
|
|
2904
2956
|
return !1;
|
|
2905
2957
|
}
|
|
2906
|
-
else return Array.isArray(e) ? !!e.find((r) =>
|
|
2958
|
+
else return Array.isArray(e) ? !!e.find((r) => S(r, t, this.equalRegexFn)) : typeof t == "object" ? V(e, t) : e === t;
|
|
2907
2959
|
}
|
|
2908
2960
|
queryFind(e, t, r) {
|
|
2909
|
-
return Array.isArray(e) ? typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? r === "some" ? e.some((s) =>
|
|
2961
|
+
return Array.isArray(e) ? typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? r === "some" ? e.some((s) => S(s, t, this.equalRegexFn)) : e.every((s) => S(s, t, this.equalRegexFn)) : !!U(e, t) : S(e, t, this.equalRegexFn);
|
|
2910
2962
|
}
|
|
2911
2963
|
validateQuery(e) {
|
|
2912
2964
|
if (this.queryBuilder.isQuery(e)) {
|
|
@@ -2917,44 +2969,44 @@ class Ve {
|
|
|
2917
2969
|
return !0;
|
|
2918
2970
|
} else {
|
|
2919
2971
|
if (this.queryBuilder.isQueryGroup(e))
|
|
2920
|
-
return
|
|
2972
|
+
return z(e.queries, (t) => this.validateQuery(t));
|
|
2921
2973
|
throw new Error("invalid query - missing query or attribute");
|
|
2922
2974
|
}
|
|
2923
2975
|
}
|
|
2924
2976
|
getEvaluatedQueryDataset(e, t, r, s) {
|
|
2925
|
-
const
|
|
2977
|
+
const o = /* @__PURE__ */ new Map();
|
|
2926
2978
|
if (t.attribute.includes("[*]")) {
|
|
2927
|
-
const
|
|
2979
|
+
const i = t.options?.invert === !0, a = /* @__PURE__ */ new Set();
|
|
2928
2980
|
for (let u of r.values()) {
|
|
2929
2981
|
const c = this.queryBuilder.extractQueryAttributes({ queries: [t] });
|
|
2930
|
-
if (c.some((
|
|
2931
|
-
const
|
|
2982
|
+
if (c.some((l) => l.isDeepQuery)) {
|
|
2983
|
+
const l = this.queryBuilder.getProjectionForAttributeEntries(
|
|
2932
2984
|
c.filter((h) => h.isDeepQuery)
|
|
2933
2985
|
);
|
|
2934
2986
|
u = this.globalItemService.getProjectedData(
|
|
2935
|
-
|
|
2987
|
+
l,
|
|
2936
2988
|
this.modelParser.models.get(e.modelKey),
|
|
2937
2989
|
u
|
|
2938
2990
|
);
|
|
2939
2991
|
}
|
|
2940
2992
|
const f = this.handleArrayStarQuery(t, u);
|
|
2941
|
-
let
|
|
2942
|
-
for (const
|
|
2943
|
-
const h = { ...
|
|
2993
|
+
let d = !1;
|
|
2994
|
+
for (const l of f.queries) {
|
|
2995
|
+
const h = { ...l, options: { ...l.options, invert: !1 } };
|
|
2944
2996
|
if (this.evaluateQuery(h, u)) {
|
|
2945
|
-
|
|
2997
|
+
d = !0;
|
|
2946
2998
|
break;
|
|
2947
2999
|
}
|
|
2948
3000
|
}
|
|
2949
|
-
|
|
3001
|
+
d && (a.add(u.key), i || o.set(u.key, u));
|
|
2950
3002
|
}
|
|
2951
|
-
if (
|
|
3003
|
+
if (i)
|
|
2952
3004
|
for (const [u, c] of r)
|
|
2953
|
-
a.has(u) ||
|
|
3005
|
+
a.has(u) || o.set(u, c);
|
|
2954
3006
|
} else {
|
|
2955
3007
|
if (t.operator === "eq")
|
|
2956
3008
|
return this.evaluateEqOperator(e, t, r, s);
|
|
2957
|
-
for (let [
|
|
3009
|
+
for (let [i, a] of r) {
|
|
2958
3010
|
const u = this.queryBuilder.extractQueryAttributes({ queries: [t] });
|
|
2959
3011
|
if (u.some((c) => c.isDeepQuery)) {
|
|
2960
3012
|
const c = this.queryBuilder.getProjectionForAttributeEntries(
|
|
@@ -2966,10 +3018,10 @@ class Ve {
|
|
|
2966
3018
|
a
|
|
2967
3019
|
);
|
|
2968
3020
|
}
|
|
2969
|
-
this.evaluateQuery(t, a) &&
|
|
3021
|
+
this.evaluateQuery(t, a) && o.set(i, a);
|
|
2970
3022
|
}
|
|
2971
3023
|
}
|
|
2972
|
-
return
|
|
3024
|
+
return o;
|
|
2973
3025
|
}
|
|
2974
3026
|
handleArrayStarQuery(e, t) {
|
|
2975
3027
|
const r = e.attribute.indexOf("[*]"), s = {
|
|
@@ -2978,9 +3030,9 @@ class Ve {
|
|
|
2978
3030
|
queries: []
|
|
2979
3031
|
};
|
|
2980
3032
|
if (r !== -1) {
|
|
2981
|
-
const
|
|
2982
|
-
if (Array.isArray(
|
|
2983
|
-
for (let a = 0; a <
|
|
3033
|
+
const o = e.attribute.substring(0, r), i = o.includes(".") ? K(t, o) : t[o];
|
|
3034
|
+
if (Array.isArray(i))
|
|
3035
|
+
for (let a = 0; a < i.length; a++) {
|
|
2984
3036
|
const u = e.attribute.replace("[*]", `[${a}]`);
|
|
2985
3037
|
s.queries.push({
|
|
2986
3038
|
attribute: u,
|
|
@@ -2992,28 +3044,28 @@ class Ve {
|
|
|
2992
3044
|
}
|
|
2993
3045
|
return s;
|
|
2994
3046
|
}
|
|
2995
|
-
evaluateQueryGroup(e, t, r, s,
|
|
2996
|
-
let
|
|
3047
|
+
evaluateQueryGroup(e, t, r, s, o) {
|
|
3048
|
+
let i = /* @__PURE__ */ new Map(), a = r;
|
|
2997
3049
|
if (!t.queries || t.queries?.length === 0)
|
|
2998
3050
|
return a;
|
|
2999
3051
|
for (const u of t.queries) {
|
|
3000
3052
|
let c = /* @__PURE__ */ new Map();
|
|
3001
|
-
if (this.queryBuilder.isQuery(u) ? c = this.getEvaluatedQueryDataset(e, u, a,
|
|
3053
|
+
if (this.queryBuilder.isQuery(u) ? c = this.getEvaluatedQueryDataset(e, u, a, o) : c = this.evaluateQueryGroup(e, u, a, s, o), i.size === 0 && (i = c), t.groupType === "or")
|
|
3002
3054
|
c.forEach((f) => {
|
|
3003
|
-
|
|
3055
|
+
i.set(f.key, f);
|
|
3004
3056
|
});
|
|
3005
3057
|
else {
|
|
3006
|
-
const f = O(Array.from(
|
|
3007
|
-
for (const
|
|
3008
|
-
|
|
3058
|
+
const f = O(Array.from(i.values()), Array.from(c.values()), "key");
|
|
3059
|
+
for (const d of f)
|
|
3060
|
+
i.delete(d.key);
|
|
3009
3061
|
}
|
|
3010
|
-
t.groupType === "and" ? a =
|
|
3062
|
+
t.groupType === "and" ? a = i : a = r;
|
|
3011
3063
|
}
|
|
3012
|
-
return
|
|
3064
|
+
return i;
|
|
3013
3065
|
}
|
|
3014
3066
|
queryData(e, t, r, s) {
|
|
3015
|
-
const
|
|
3016
|
-
return t.queries.length === 0 ? e : (t.groupKey || (t.groupKey = "root"), t.groupType || (t.groupType = "and"), t.queries || (t.queries = []), this.validateQuery(t), this.evaluateQueryGroup(t, t,
|
|
3067
|
+
const o = new Map(e);
|
|
3068
|
+
return t.queries.length === 0 ? e : (t.groupKey || (t.groupKey = "root"), t.groupType || (t.groupType = "and"), t.queries || (t.queries = []), this.validateQuery(t), this.evaluateQueryGroup(t, t, o, r, s));
|
|
3017
3069
|
}
|
|
3018
3070
|
// public getRelevantQueryData(data: any, options: DcuplGlobalQueryOptions<any>, model: DcuplModel<ListItem>) {
|
|
3019
3071
|
// // detect if any of the query attributes are a deep query.
|
|
@@ -3049,7 +3101,7 @@ class Ve {
|
|
|
3049
3101
|
// }
|
|
3050
3102
|
// }
|
|
3051
3103
|
}
|
|
3052
|
-
class
|
|
3104
|
+
class st {
|
|
3053
3105
|
scripts = /* @__PURE__ */ new Map();
|
|
3054
3106
|
scriptFunctions = /* @__PURE__ */ new Map();
|
|
3055
3107
|
constructor() {
|
|
@@ -3075,8 +3127,8 @@ class Ue {
|
|
|
3075
3127
|
const r = this.getScript(e);
|
|
3076
3128
|
if (!r)
|
|
3077
3129
|
throw new Error(`Script ${e} not found`);
|
|
3078
|
-
const s = this.getWrapperScript(r),
|
|
3079
|
-
return this.scriptFunctions.set(e,
|
|
3130
|
+
const s = this.getWrapperScript(r), o = new Function("script_type", ...t, s);
|
|
3131
|
+
return this.scriptFunctions.set(e, o), o;
|
|
3080
3132
|
}
|
|
3081
3133
|
getWrapperScript(e) {
|
|
3082
3134
|
return `
|
|
@@ -3088,14 +3140,14 @@ class Ue {
|
|
|
3088
3140
|
if (!this.getScript(e))
|
|
3089
3141
|
throw new Error(`Script ${e} not found`);
|
|
3090
3142
|
r.context || (r.context = r.options || {});
|
|
3091
|
-
const
|
|
3092
|
-
return this.getScriptAsFn(e,
|
|
3143
|
+
const o = Object.keys(r), i = Object.values(r);
|
|
3144
|
+
return this.getScriptAsFn(e, o)(t, ...i);
|
|
3093
3145
|
}
|
|
3094
3146
|
}
|
|
3095
|
-
const
|
|
3147
|
+
const nt = (n, e) => n ? (e || (e = {}), n.replace(/\$\{(.*?)\}/g, (t, r) => K(e, r.trim(), ""))) : "", it = (n) => {
|
|
3096
3148
|
const e = /* @__PURE__ */ new Set();
|
|
3097
|
-
return
|
|
3098
|
-
},
|
|
3149
|
+
return n.replace(/\$\{(.*?)\}/g, (r, s) => (e.add(s.trim()), "")), { variables: Array.from(e).map((r) => ({ name: r })) };
|
|
3150
|
+
}, ot = [
|
|
3099
3151
|
"any",
|
|
3100
3152
|
"Array<date>",
|
|
3101
3153
|
"Array<float>",
|
|
@@ -3107,7 +3159,7 @@ const Je = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => D(e
|
|
|
3107
3159
|
"int",
|
|
3108
3160
|
"json",
|
|
3109
3161
|
"string"
|
|
3110
|
-
],
|
|
3162
|
+
], at = ["int", "float", "Array<int>", "Array<float>"], ut = ["date", "Array<date>"], ct = [
|
|
3111
3163
|
"eq",
|
|
3112
3164
|
"find",
|
|
3113
3165
|
"gt",
|
|
@@ -3119,57 +3171,60 @@ const Je = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => D(e
|
|
|
3119
3171
|
"size"
|
|
3120
3172
|
];
|
|
3121
3173
|
export {
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3174
|
+
qe as AnalyticsController,
|
|
3175
|
+
$e as AttributeDependencyGraph,
|
|
3176
|
+
Fe as CacheController,
|
|
3177
|
+
We as ChangeDetector,
|
|
3178
|
+
ut as DatePropertyTypes,
|
|
3179
|
+
B as DcuplQueryBuilder,
|
|
3180
|
+
ct as DcuplQueryOperatorsAsArray,
|
|
3181
|
+
fe as DeepQueryService,
|
|
3182
|
+
Z as DependencyGraph,
|
|
3131
3183
|
we as IndicesController,
|
|
3132
3184
|
p as Logger,
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3185
|
+
at as NumberPropertyTypes,
|
|
3186
|
+
ot as PropertyTypesAsArray,
|
|
3187
|
+
rt as QueryManager,
|
|
3188
|
+
st as ScriptController,
|
|
3189
|
+
j as clone,
|
|
3190
|
+
Ke as coerceStringType,
|
|
3191
|
+
te as compareVersions,
|
|
3192
|
+
He as computeSuggestions,
|
|
3193
|
+
y as deepQueryService,
|
|
3194
|
+
ee as escapeRegExp,
|
|
3195
|
+
nt as evaluateTemplate,
|
|
3196
|
+
Ye as generateBooleanQuery,
|
|
3197
|
+
X as generateKey,
|
|
3198
|
+
Xe as generateNumberAndDateQuery,
|
|
3199
|
+
et as generateReferenceQuery,
|
|
3200
|
+
Ze as generateTextQuery,
|
|
3201
|
+
k as getAggregation,
|
|
3202
|
+
ze as getDateConstraintUid,
|
|
3203
|
+
Ee as getDcuplPropertyTypeForNativeType,
|
|
3204
|
+
x as getDeepPathValues,
|
|
3205
|
+
ye as getDistinct,
|
|
3206
|
+
Ue as getFacets,
|
|
3207
|
+
Te as getFilterEntryId,
|
|
3208
|
+
Ge as getNumberConstraintUid,
|
|
3209
|
+
Je as getPropertiesForData,
|
|
3210
|
+
je as groupBy,
|
|
3211
|
+
Pe as hasMinimumVersion,
|
|
3212
|
+
Ne as inferModel,
|
|
3213
|
+
re as isDateInstance,
|
|
3214
|
+
Ce as isFloat,
|
|
3215
|
+
ke as isInt,
|
|
3216
|
+
se as isValidDate,
|
|
3217
|
+
tt as isValidQueryStatement,
|
|
3218
|
+
$ as isValidVersion,
|
|
3219
|
+
Y as logger,
|
|
3220
|
+
Ie as looksDateLike,
|
|
3221
|
+
Ve as parseDate,
|
|
3222
|
+
it as parseTemplate,
|
|
3223
|
+
b as perf,
|
|
3224
|
+
_ as pivot,
|
|
3225
|
+
Be as removeTrailingSlash,
|
|
3226
|
+
Le as trigger,
|
|
3227
|
+
_e as unescapeRegExp,
|
|
3228
|
+
Re as uniqBy
|
|
3174
3229
|
};
|
|
3175
3230
|
//# sourceMappingURL=index.js.map
|