@dcupl/common 2.0.0-beta.2 → 2.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/analytics.controller.d.ts +1 -1
- package/dist/esm/changeDetection.d.ts +2 -2
- package/dist/esm/computeSuggestions.d.ts +2 -2
- package/dist/esm/deep-query.service.d.ts +1 -1
- package/dist/esm/getAggregation.d.ts +1 -1
- package/dist/esm/getFacets.d.ts +26 -3
- package/dist/esm/helper.d.ts +1 -1
- package/dist/esm/index.d.ts +24 -22
- package/dist/esm/index.js +797 -658
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/indices.controller.d.ts +7 -1
- package/dist/esm/logger/index.d.ts +2 -2
- package/dist/esm/pivot.d.ts +2 -2
- package/dist/esm/property-parser.d.ts +27 -2
- package/dist/esm/query-builder.d.ts +2 -2
- package/dist/esm/query.helper.d.ts +1 -1
- package/dist/esm/queryData.d.ts +2 -2
- package/dist/esm/resource-id.d.ts +43 -0
- package/dist/esm/scheduling.d.ts +17 -0
- package/dist/esm/types/app-loader.types.d.ts +94 -4
- package/dist/esm/types/data.types.d.ts +7 -3
- package/dist/esm/types/dcupl.types.d.ts +26 -12
- package/dist/esm/types/facets.types.d.ts +6 -1
- package/dist/esm/types/filter.types.d.ts +3 -3
- package/dist/esm/types/group-by.types.d.ts +2 -2
- package/dist/esm/types/index.d.ts +17 -16
- package/dist/esm/types/internal.types.d.ts +1 -1
- package/dist/esm/types/key-property.types.d.ts +11 -0
- package/dist/esm/types/list.types.d.ts +20 -4
- package/dist/esm/types/model.types.d.ts +54 -5
- package/dist/esm/types/quality.types.d.ts +87 -1
- package/dist/esm/types/query.types.d.ts +19 -10
- package/dist/esm/types/section.types.d.ts +2 -2
- package/dist/esm/types/suggestion.types.d.ts +1 -1
- package/dist/node/index.cjs +2 -2
- package/dist/node/index.cjs.map +1 -1
- package/package.json +2 -4
package/dist/esm/index.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { cloneDeep as
|
|
2
|
-
function
|
|
3
|
-
const e =
|
|
1
|
+
import { cloneDeep as v, get as I, every as z, findIndex as E, size as W, isEqual as $, differenceBy as O, startsWith as H, endsWith as U, isEqualWith as S, isMatch as V, find as J } from "lodash-es";
|
|
2
|
+
function K(n) {
|
|
3
|
+
const e = k(n);
|
|
4
4
|
return Z(e);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
if (typeof
|
|
8
|
-
return String(
|
|
9
|
-
if (Array.isArray(
|
|
10
|
-
return "[" +
|
|
11
|
-
const e = Object.keys(
|
|
6
|
+
function k(n) {
|
|
7
|
+
if (typeof n != "object" || n === null)
|
|
8
|
+
return String(n);
|
|
9
|
+
if (Array.isArray(n))
|
|
10
|
+
return "[" + n.map(k).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 + ":" + k(n[s]), r < e.length - 1 && (t += ",");
|
|
16
16
|
}
|
|
17
17
|
return t += "}", t;
|
|
18
18
|
}
|
|
19
|
-
function Z(
|
|
19
|
+
function Z(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 Te {
|
|
45
45
|
data;
|
|
46
46
|
enabled = !1;
|
|
47
47
|
constructor() {
|
|
@@ -59,7 +59,7 @@ class Ke {
|
|
|
59
59
|
const t = this.getKey(e.name, e.context), r = {
|
|
60
60
|
name: e.name,
|
|
61
61
|
type: "mark",
|
|
62
|
-
value:
|
|
62
|
+
value: b.now(),
|
|
63
63
|
createdAt: Date.now()
|
|
64
64
|
};
|
|
65
65
|
return this.data.set(t, r), r;
|
|
@@ -69,21 +69,21 @@ class Ke {
|
|
|
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 i = s.value - r.value,
|
|
72
|
+
const i = s.value - r.value, o = Math.round(i * 100) / 100, a = this.data.get(t);
|
|
73
73
|
if (a && e.sum) {
|
|
74
|
-
const
|
|
74
|
+
const u = a.value + o, f = {
|
|
75
75
|
...a,
|
|
76
|
-
value:
|
|
76
|
+
value: u
|
|
77
77
|
};
|
|
78
|
-
return this.data.set(t,
|
|
78
|
+
return this.data.set(t, f), f;
|
|
79
79
|
}
|
|
80
|
-
const
|
|
80
|
+
const c = {
|
|
81
81
|
name: e.name,
|
|
82
82
|
type: "measure",
|
|
83
|
-
value:
|
|
83
|
+
value: o,
|
|
84
84
|
createdAt: Date.now()
|
|
85
85
|
};
|
|
86
|
-
return e.detail && (
|
|
86
|
+
return e.detail && (c.detail = e.detail), this.data.set(t, c), c;
|
|
87
87
|
}
|
|
88
88
|
update(e) {
|
|
89
89
|
if (!this.enabled) return e.value;
|
|
@@ -96,7 +96,7 @@ class Ke {
|
|
|
96
96
|
return this.data.get(t);
|
|
97
97
|
}
|
|
98
98
|
getResourceInfosFromPerformanceAPI() {
|
|
99
|
-
return typeof performance > "u" ? [] :
|
|
99
|
+
return typeof performance > "u" ? [] : b.getEntriesByType("resource");
|
|
100
100
|
}
|
|
101
101
|
get(e) {
|
|
102
102
|
const t = this.getKey(e.name, e.context);
|
|
@@ -114,11 +114,11 @@ class Ke {
|
|
|
114
114
|
getKey(e, t) {
|
|
115
115
|
if (!t)
|
|
116
116
|
return e;
|
|
117
|
-
const r =
|
|
117
|
+
const r = K(t);
|
|
118
118
|
return e + "_" + r;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
let
|
|
121
|
+
let X = class _ {
|
|
122
122
|
nodes;
|
|
123
123
|
edges;
|
|
124
124
|
nodeKinds = /* @__PURE__ */ new Map();
|
|
@@ -200,8 +200,8 @@ let Y = class j {
|
|
|
200
200
|
t.add(s);
|
|
201
201
|
const i = this.edges.get(s);
|
|
202
202
|
if (i) {
|
|
203
|
-
for (let
|
|
204
|
-
if (r(
|
|
203
|
+
for (let o of i)
|
|
204
|
+
if (r(o))
|
|
205
205
|
return !0;
|
|
206
206
|
}
|
|
207
207
|
return t.delete(s), e.add(s), !1;
|
|
@@ -225,24 +225,24 @@ let Y = class j {
|
|
|
225
225
|
return r.slice(a).concat([i]);
|
|
226
226
|
}
|
|
227
227
|
t.add(i), r.push(i);
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
230
|
-
for (let a of
|
|
231
|
-
const
|
|
232
|
-
if (
|
|
233
|
-
return
|
|
228
|
+
const o = this.edges.get(i);
|
|
229
|
+
if (o)
|
|
230
|
+
for (let a of o) {
|
|
231
|
+
const c = s(a);
|
|
232
|
+
if (c)
|
|
233
|
+
return c;
|
|
234
234
|
}
|
|
235
235
|
return r.pop(), t.delete(i), e.add(i), null;
|
|
236
236
|
};
|
|
237
237
|
for (let i of this.nodes) {
|
|
238
|
-
const
|
|
239
|
-
if (
|
|
240
|
-
return { hasCycle: !0, path:
|
|
238
|
+
const o = s(i);
|
|
239
|
+
if (o)
|
|
240
|
+
return { hasCycle: !0, path: o };
|
|
241
241
|
}
|
|
242
242
|
return { hasCycle: !1 };
|
|
243
243
|
}
|
|
244
244
|
order(e) {
|
|
245
|
-
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = [], i = e?.allowCycles ?? !1,
|
|
245
|
+
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = [], i = e?.allowCycles ?? !1, o = (a) => {
|
|
246
246
|
if (t.has(a))
|
|
247
247
|
return;
|
|
248
248
|
if (r.has(a)) {
|
|
@@ -251,14 +251,14 @@ let Y = class j {
|
|
|
251
251
|
throw new Error("Graph has a cycle.");
|
|
252
252
|
}
|
|
253
253
|
r.add(a);
|
|
254
|
-
const
|
|
255
|
-
if (
|
|
256
|
-
for (let
|
|
257
|
-
|
|
254
|
+
const c = this.edges.get(a);
|
|
255
|
+
if (c)
|
|
256
|
+
for (let u of c)
|
|
257
|
+
o(u);
|
|
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) || o(a);
|
|
262
262
|
return s;
|
|
263
263
|
}
|
|
264
264
|
clear() {
|
|
@@ -326,30 +326,30 @@ let Y = class j {
|
|
|
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 o of this.nodes) t.set(o, 0);
|
|
330
|
+
for (const o of this.edges.values())
|
|
331
|
+
for (const a of o) t.set(a, (t.get(a) || 0) + 1);
|
|
332
332
|
const r = [];
|
|
333
|
-
let s = Array.from(this.nodes).filter((
|
|
333
|
+
let s = Array.from(this.nodes).filter((o) => (t.get(o) || 0) === 0);
|
|
334
334
|
const i = /* @__PURE__ */ new Set();
|
|
335
335
|
for (; s.length > 0; ) {
|
|
336
|
-
const
|
|
337
|
-
r.push(
|
|
338
|
-
for (const a of
|
|
336
|
+
const o = s.slice();
|
|
337
|
+
r.push(o), s = [];
|
|
338
|
+
for (const a of o) {
|
|
339
339
|
if (i.has(a)) continue;
|
|
340
340
|
i.add(a);
|
|
341
|
-
const
|
|
342
|
-
if (
|
|
343
|
-
for (const
|
|
344
|
-
t.set(
|
|
341
|
+
const c = this.edges.get(a);
|
|
342
|
+
if (c)
|
|
343
|
+
for (const u of c)
|
|
344
|
+
t.set(u, (t.get(u) || 0) - 1), (t.get(u) || 0) === 0 && s.push(u);
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
if (i.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 o = new Set(e.filterKinds);
|
|
351
351
|
return {
|
|
352
|
-
batches: r.map((a) => a.filter((
|
|
352
|
+
batches: r.map((a) => a.filter((c) => o.has(this.nodeKinds.get(c))))
|
|
353
353
|
};
|
|
354
354
|
}
|
|
355
355
|
return { batches: r };
|
|
@@ -362,26 +362,26 @@ let Y = class j {
|
|
|
362
362
|
* - 'both': union of upstream and downstream
|
|
363
363
|
*/
|
|
364
364
|
getImpactedNodes(e, t = "downstream", r) {
|
|
365
|
-
const s = new Set(e), i = (
|
|
366
|
-
const
|
|
367
|
-
for (;
|
|
368
|
-
const
|
|
369
|
-
for (const [
|
|
370
|
-
h.has(
|
|
365
|
+
const s = new Set(e), i = (u) => !r || r.length === 0 || r.includes(this.nodeKinds.get(u) ?? void 0), o = () => {
|
|
366
|
+
const u = /* @__PURE__ */ new Set(), f = Array.from(s);
|
|
367
|
+
for (; f.length; ) {
|
|
368
|
+
const l = f.shift();
|
|
369
|
+
for (const [d, h] of this.edges)
|
|
370
|
+
h.has(l) && !u.has(d) && (u.add(d), f.push(d));
|
|
371
371
|
}
|
|
372
|
-
return
|
|
372
|
+
return u;
|
|
373
373
|
}, a = () => {
|
|
374
|
-
const
|
|
375
|
-
for (;
|
|
376
|
-
const
|
|
377
|
-
if (
|
|
378
|
-
for (const h of
|
|
379
|
-
|
|
374
|
+
const u = /* @__PURE__ */ new Set(), f = Array.from(s);
|
|
375
|
+
for (; f.length; ) {
|
|
376
|
+
const l = f.shift(), d = this.edges.get(l);
|
|
377
|
+
if (d)
|
|
378
|
+
for (const h of d)
|
|
379
|
+
u.has(h) || (u.add(h), f.push(h));
|
|
380
380
|
}
|
|
381
|
-
return
|
|
381
|
+
return u;
|
|
382
382
|
};
|
|
383
|
-
let
|
|
384
|
-
return t === "both" ?
|
|
383
|
+
let c;
|
|
384
|
+
return t === "both" ? c = /* @__PURE__ */ new Set([...o(), ...a()]) : t === "upstream" ? c = a() : c = o(), Array.from(c).filter(i);
|
|
385
385
|
}
|
|
386
386
|
toJSON() {
|
|
387
387
|
const e = Array.from(this.nodes).map((r) => ({
|
|
@@ -392,7 +392,7 @@ let Y = class j {
|
|
|
392
392
|
return { nodes: e, edges: t };
|
|
393
393
|
}
|
|
394
394
|
static fromJSON(e) {
|
|
395
|
-
const t = new
|
|
395
|
+
const t = new _();
|
|
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 j {
|
|
|
400
400
|
return t;
|
|
401
401
|
}
|
|
402
402
|
diff(e) {
|
|
403
|
-
const t = new Set(this.getNodes()), r = new Set(e.getNodes()), s = Array.from(r).filter((
|
|
404
|
-
for (const
|
|
405
|
-
const
|
|
406
|
-
|
|
403
|
+
const t = new Set(this.getNodes()), r = new Set(e.getNodes()), s = Array.from(r).filter((l) => !t.has(l)), i = Array.from(t).filter((l) => !r.has(l)), o = new Set(this.getAllEdges().map((l) => l.join("→"))), a = new Set(e.getAllEdges().map((l) => l.join("→"))), c = Array.from(a).filter((l) => !o.has(l)).map((l) => l.split("→")), u = Array.from(o).filter((l) => !a.has(l)).map((l) => l.split("→")), f = [];
|
|
404
|
+
for (const l of /* @__PURE__ */ new Set([...t, ...r])) {
|
|
405
|
+
const d = this.nodeKinds.get(l), h = e.nodeKinds.get(l);
|
|
406
|
+
d !== h && f.push({ name: l, from: d, to: h });
|
|
407
407
|
}
|
|
408
|
-
return { addedNodes: s, removedNodes: i, addedEdges:
|
|
408
|
+
return { addedNodes: s, removedNodes: i, addedEdges: c, removedEdges: u, kindChanges: f };
|
|
409
409
|
}
|
|
410
410
|
};
|
|
411
|
-
class
|
|
411
|
+
class Re {
|
|
412
412
|
graph;
|
|
413
413
|
nodeIndex;
|
|
414
414
|
constructor() {
|
|
415
|
-
this.graph = new
|
|
415
|
+
this.graph = new X(), this.nodeIndex = /* @__PURE__ */ new Map();
|
|
416
416
|
}
|
|
417
417
|
/**
|
|
418
418
|
* Creates a unique ID for an attribute node
|
|
@@ -454,10 +454,10 @@ class Se {
|
|
|
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), i = [...e, ...s],
|
|
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), i = [...e, ...s], o = /* @__PURE__ */ new Set();
|
|
458
458
|
return i.filter((a) => {
|
|
459
|
-
const
|
|
460
|
-
return
|
|
459
|
+
const c = this.getNodeId(a.modelKey, a.attributeKey);
|
|
460
|
+
return o.has(c) ? !1 : (o.add(c), !0);
|
|
461
461
|
});
|
|
462
462
|
}
|
|
463
463
|
/**
|
|
@@ -470,10 +470,10 @@ class Se {
|
|
|
470
470
|
getProcessingOrder(e) {
|
|
471
471
|
const t = /* @__PURE__ */ new Map(), r = [...e].sort((s, i) => s.processingStep - i.processingStep);
|
|
472
472
|
for (const s of r) {
|
|
473
|
-
const { modelKey: i, attributeKey:
|
|
473
|
+
const { modelKey: i, attributeKey: o, processingStep: a } = s;
|
|
474
474
|
t.has(i) || t.set(i, /* @__PURE__ */ new Map());
|
|
475
|
-
const
|
|
476
|
-
|
|
475
|
+
const c = t.get(i);
|
|
476
|
+
c.has(a) || c.set(a, /* @__PURE__ */ new Set()), c.get(a).add(o);
|
|
477
477
|
}
|
|
478
478
|
return t;
|
|
479
479
|
}
|
|
@@ -530,12 +530,12 @@ class Se {
|
|
|
530
530
|
s.add(r);
|
|
531
531
|
const i = this.graph.getDependencies(r);
|
|
532
532
|
if (i.length === 0) return 1;
|
|
533
|
-
let
|
|
533
|
+
let o = 0;
|
|
534
534
|
for (const a of i) {
|
|
535
|
-
const
|
|
536
|
-
|
|
535
|
+
const c = t(a, new Set(s));
|
|
536
|
+
o = Math.max(o, c);
|
|
537
537
|
}
|
|
538
|
-
return
|
|
538
|
+
return o + 1;
|
|
539
539
|
};
|
|
540
540
|
for (const r of this.graph.getNodes()) {
|
|
541
541
|
const s = t(r);
|
|
@@ -555,8 +555,8 @@ class Se {
|
|
|
555
555
|
const t = [];
|
|
556
556
|
for (const [r, s] of e)
|
|
557
557
|
for (const i of s) {
|
|
558
|
-
const
|
|
559
|
-
this.hasNode(
|
|
558
|
+
const o = this.getNodeId(r, i);
|
|
559
|
+
this.hasNode(o) || t.push({ modelKey: r, attributeKey: i });
|
|
560
560
|
}
|
|
561
561
|
return {
|
|
562
562
|
isComplete: t.length === 0,
|
|
@@ -600,7 +600,7 @@ class Se {
|
|
|
600
600
|
};
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
|
-
const
|
|
603
|
+
const q = {
|
|
604
604
|
silent: 0,
|
|
605
605
|
error: 1,
|
|
606
606
|
warn: 2,
|
|
@@ -663,20 +663,20 @@ 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 o = {
|
|
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 && (o.module = e.prefix), e.context && (o.context = e.context), e.error && (o.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(o);
|
|
680
680
|
}
|
|
681
681
|
const t = new Date(e.timestamp).toISOString().substring(11, 23), r = e.prefix ? `[${e.prefix}]` : "", s = this.getLevelIcon(e.level), i = e.context ? ` ${JSON.stringify(e.context)}` : "";
|
|
682
682
|
return `${t} ${s} ${r} ${e.message}${i}`.trim();
|
|
@@ -710,20 +710,20 @@ class p {
|
|
|
710
710
|
this.config.onLog(i);
|
|
711
711
|
return;
|
|
712
712
|
}
|
|
713
|
-
const
|
|
713
|
+
const o = this.formatMessage(i);
|
|
714
714
|
if (typeof console < "u")
|
|
715
715
|
switch (e) {
|
|
716
716
|
case "error":
|
|
717
|
-
s ? console.error(
|
|
717
|
+
s ? console.error(o, s) : console.error(o);
|
|
718
718
|
break;
|
|
719
719
|
case "warn":
|
|
720
|
-
console.warn(
|
|
720
|
+
console.warn(o);
|
|
721
721
|
break;
|
|
722
722
|
case "debug":
|
|
723
|
-
console.debug ? console.debug(
|
|
723
|
+
console.debug ? console.debug(o) : console.log(o);
|
|
724
724
|
break;
|
|
725
725
|
default:
|
|
726
|
-
console.log(
|
|
726
|
+
console.log(o);
|
|
727
727
|
}
|
|
728
728
|
}
|
|
729
729
|
/**
|
|
@@ -799,18 +799,19 @@ class p {
|
|
|
799
799
|
Object.assign(this.config, e);
|
|
800
800
|
}
|
|
801
801
|
}
|
|
802
|
-
const
|
|
803
|
-
class
|
|
802
|
+
const Y = new p();
|
|
803
|
+
class Ge {
|
|
804
804
|
constructor(e) {
|
|
805
805
|
this.enabled = e, this.cache = /* @__PURE__ */ new Map(), this.cacheDependencies = /* @__PURE__ */ new Map();
|
|
806
806
|
}
|
|
807
|
+
enabled;
|
|
807
808
|
cache;
|
|
808
809
|
// Track which models and attributes each cache entry depends on
|
|
809
810
|
cacheDependencies;
|
|
810
811
|
// Track cache hits and misses for statistics
|
|
811
812
|
hitCount = 0;
|
|
812
813
|
missCount = 0;
|
|
813
|
-
log =
|
|
814
|
+
log = Y.child({ prefix: "CacheController" });
|
|
814
815
|
get(e, t) {
|
|
815
816
|
if (!this.enabled) return;
|
|
816
817
|
const r = this.getCacheName(e, t);
|
|
@@ -838,12 +839,12 @@ class Ie {
|
|
|
838
839
|
const t = [];
|
|
839
840
|
for (const [r, s] of this.cacheDependencies) {
|
|
840
841
|
let i = !1;
|
|
841
|
-
for (const [
|
|
842
|
-
if (s.models.has(
|
|
843
|
-
if (s.modelAttributes.has(
|
|
844
|
-
const
|
|
845
|
-
for (const
|
|
846
|
-
if (
|
|
842
|
+
for (const [o, a] of e) {
|
|
843
|
+
if (s.models.has(o))
|
|
844
|
+
if (s.modelAttributes.has(o)) {
|
|
845
|
+
const c = s.modelAttributes.get(o);
|
|
846
|
+
for (const u of a)
|
|
847
|
+
if (c.has(u)) {
|
|
847
848
|
i = !0;
|
|
848
849
|
break;
|
|
849
850
|
}
|
|
@@ -864,8 +865,8 @@ class Ie {
|
|
|
864
865
|
if (!this.enabled) return;
|
|
865
866
|
const t = new Set(e), r = [];
|
|
866
867
|
for (const [s, i] of this.cacheDependencies)
|
|
867
|
-
for (const
|
|
868
|
-
if (i.models.has(
|
|
868
|
+
for (const o of t)
|
|
869
|
+
if (i.models.has(o)) {
|
|
869
870
|
r.push(s);
|
|
870
871
|
break;
|
|
871
872
|
}
|
|
@@ -915,13 +916,13 @@ class Ie {
|
|
|
915
916
|
}
|
|
916
917
|
generateContext(e) {
|
|
917
918
|
try {
|
|
918
|
-
return
|
|
919
|
+
return v(e);
|
|
919
920
|
} catch (t) {
|
|
920
921
|
return this.log.error("Error in cache generateContext", t), e;
|
|
921
922
|
}
|
|
922
923
|
}
|
|
923
924
|
getCacheName(e, t) {
|
|
924
|
-
const r =
|
|
925
|
+
const r = K(t);
|
|
925
926
|
return e + "_" + r;
|
|
926
927
|
}
|
|
927
928
|
/**
|
|
@@ -939,42 +940,42 @@ class Ie {
|
|
|
939
940
|
};
|
|
940
941
|
}
|
|
941
942
|
}
|
|
942
|
-
const
|
|
943
|
+
const ze = (n, e = "") => `${n}#${e}`, _e = (n) => `${n.gt}_${n.gte}_${n.lt}_${n.lte}_${n.eq}_${n.ne}`, Pe = (n) => `${n.gt}_${n.gte}_${n.lt}_${n.lte}_${n.eq}_${n.ne}`, Be = (n, e) => {
|
|
943
944
|
const t = typeof e == "function" ? e : (r) => r[e];
|
|
944
945
|
return [
|
|
945
|
-
...
|
|
946
|
+
...n.reduce((r, s) => {
|
|
946
947
|
const i = s == null ? s : t(s);
|
|
947
948
|
return r.has(i) || r.set(i, s), r;
|
|
948
949
|
}, /* @__PURE__ */ new Map()).values()
|
|
949
950
|
];
|
|
950
|
-
},
|
|
951
|
+
}, je = (n, e) => n.reduce(function(t, r) {
|
|
951
952
|
const s = typeof e == "function" ? e(r) : r[e];
|
|
952
953
|
return Object.prototype.hasOwnProperty.call(t, s) || (t[s] = []), t[s].push(r), t;
|
|
953
954
|
}, {});
|
|
954
|
-
function ee(
|
|
955
|
+
function ee(n = 10) {
|
|
955
956
|
let e = "";
|
|
956
957
|
const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
957
|
-
for (let r = 0; r <
|
|
958
|
+
for (let r = 0; r < n; r++) e += t.charAt(Math.floor(Math.random() * t.length));
|
|
958
959
|
return e;
|
|
959
960
|
}
|
|
960
|
-
const
|
|
961
|
+
const Le = (n) => n.replace(/\/+$/, ""), te = (n) => typeof n != "string" ? "" : n.replace(/[[\]{}()*+?.,\\^$|#]/g, "\\$&"), We = (n) => typeof n != "string" ? "" : n.replace(/\\([[\]{}()*+?.,\\^$|#])/g, "$1"), He = (n, e) => {
|
|
961
962
|
try {
|
|
962
|
-
return re(
|
|
963
|
+
return re(n, e) >= 0;
|
|
963
964
|
} catch {
|
|
964
965
|
return !1;
|
|
965
966
|
}
|
|
966
|
-
}, re = (
|
|
967
|
-
if (!F(
|
|
968
|
-
throw new Error(`Invalid version format: v1="${
|
|
969
|
-
const t =
|
|
967
|
+
}, re = (n, e) => {
|
|
968
|
+
if (!F(n) || !F(e))
|
|
969
|
+
throw new Error(`Invalid version format: v1="${n}", v2="${e}". Expected format: "x.y.z"`);
|
|
970
|
+
const t = n.split(".").map(Number), r = e.split(".").map(Number);
|
|
970
971
|
for (let s = 0; s < 3; s++) {
|
|
971
|
-
const i = t[s] || 0,
|
|
972
|
-
if (i >
|
|
973
|
-
if (i <
|
|
972
|
+
const i = t[s] || 0, o = r[s] || 0;
|
|
973
|
+
if (i > o) return 1;
|
|
974
|
+
if (i < o) return -1;
|
|
974
975
|
}
|
|
975
976
|
return 0;
|
|
976
|
-
}, F = (
|
|
977
|
-
class
|
|
977
|
+
}, F = (n) => /^\d+(\.\d+){0,2}$/.test(n);
|
|
978
|
+
class Ue {
|
|
978
979
|
key;
|
|
979
980
|
parentCd;
|
|
980
981
|
dcuplInitOptions;
|
|
@@ -1000,7 +1001,7 @@ class $e {
|
|
|
1000
1001
|
this.off && this.off();
|
|
1001
1002
|
}
|
|
1002
1003
|
trigger(e) {
|
|
1003
|
-
e.originCdRefKey || (e.originCdRefKey = this.key), e.key || (this.increaseCounter(), e.key = this.getCounter()), e.end || (e.end =
|
|
1004
|
+
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
1005
|
t(e);
|
|
1005
1006
|
});
|
|
1006
1007
|
}
|
|
@@ -1010,17 +1011,17 @@ class $e {
|
|
|
1010
1011
|
};
|
|
1011
1012
|
}
|
|
1012
1013
|
}
|
|
1013
|
-
const P = (
|
|
1014
|
+
const P = (n, e) => e ? typeof structuredClone < "u" ? structuredClone(n) : v(n) : n, T = (n, e, t, r, s, i) => {
|
|
1014
1015
|
try {
|
|
1015
|
-
const
|
|
1016
|
-
if (t.scope === "list" && (t.listKey =
|
|
1016
|
+
const o = !!e.dcuplInitOptions.performance?.clone?.enabled && !!t.cloneResult, a = P(i, o);
|
|
1017
|
+
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
1018
|
return a;
|
|
1018
|
-
const
|
|
1019
|
-
t.duration =
|
|
1020
|
-
const
|
|
1019
|
+
const c = b.now(), u = c - r, f = Math.round(u * 1e3) / 1e3;
|
|
1020
|
+
t.duration = f, t.start = r, t.end = c;
|
|
1021
|
+
const l = {
|
|
1021
1022
|
duration: t.duration
|
|
1022
1023
|
};
|
|
1023
|
-
return t.modelKey && (
|
|
1024
|
+
return t.modelKey && (l.model = t.modelKey), t.connectMessageResult && (t.result = a), t.args && (l.args = t.args), e?.trigger(t), e.analyticsController.mark({
|
|
1024
1025
|
name: `${t.type}:end`,
|
|
1025
1026
|
context: s
|
|
1026
1027
|
}), e.analyticsController.measure({
|
|
@@ -1028,62 +1029,62 @@ const P = (o, e) => e ? typeof structuredClone < "u" ? structuredClone(o) : m(o)
|
|
|
1028
1029
|
start: `${t.type}:start`,
|
|
1029
1030
|
end: `${t.type}:end`,
|
|
1030
1031
|
context: s,
|
|
1031
|
-
detail:
|
|
1032
|
+
detail: l
|
|
1032
1033
|
}), a;
|
|
1033
1034
|
} catch {
|
|
1034
1035
|
return i;
|
|
1035
1036
|
}
|
|
1036
|
-
},
|
|
1037
|
+
}, Ve = (n) => (t, r, s) => {
|
|
1037
1038
|
const i = s.value;
|
|
1038
|
-
return s.value = function(...
|
|
1039
|
-
const a =
|
|
1040
|
-
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1043
|
-
name: `${
|
|
1044
|
-
context:
|
|
1039
|
+
return s.value = function(...o) {
|
|
1040
|
+
const a = b.now(), c = this.cdRef, u = P(n, !0);
|
|
1041
|
+
u.key || (c.increaseCounter(), u.key = c.getCounter());
|
|
1042
|
+
const f = ee();
|
|
1043
|
+
c.analyticsController.mark({
|
|
1044
|
+
name: `${u.type}:start`,
|
|
1045
|
+
context: f
|
|
1045
1046
|
});
|
|
1046
|
-
const
|
|
1047
|
-
!
|
|
1048
|
-
const
|
|
1049
|
-
return
|
|
1047
|
+
const l = this.model?.key;
|
|
1048
|
+
!u.originCdRefKey && c.key && (u.originCdRefKey = c.key), l && (u.modelKey = l);
|
|
1049
|
+
const d = i.apply(this, o);
|
|
1050
|
+
return u.method = r, u.args = o, d && typeof d == "object" && "then" in d ? d.then((h) => T(this, c, u, a, f, h)) : T(this, c, u, a, f, d);
|
|
1050
1051
|
}, s;
|
|
1051
1052
|
};
|
|
1052
|
-
function
|
|
1053
|
+
function Je(n, e, t, r) {
|
|
1053
1054
|
t.max || (t.max = 20);
|
|
1054
1055
|
const s = [], i = t.transform ? r.transformValue(t.value, t.transform) : t.value;
|
|
1055
|
-
for (const [
|
|
1056
|
-
const
|
|
1057
|
-
if (!(t.excludeUndefineds && typeof
|
|
1058
|
-
if (
|
|
1059
|
-
const
|
|
1060
|
-
value:
|
|
1056
|
+
for (const [o, a] of e.entries()) {
|
|
1057
|
+
const c = Array.from(a).some((f) => n.has(f)), u = t.transform ? r.transformValue(o, t.transform) : o;
|
|
1058
|
+
if (!(t.excludeUndefineds && typeof o > "u") && !(t.excludeNulls && o === null)) {
|
|
1059
|
+
if (c && (i === "" || i === "//")) {
|
|
1060
|
+
const f = {
|
|
1061
|
+
value: o,
|
|
1061
1062
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1062
1063
|
};
|
|
1063
|
-
s.push(
|
|
1064
|
-
} else if (
|
|
1065
|
-
if (r.queryFind(
|
|
1066
|
-
const
|
|
1067
|
-
value:
|
|
1064
|
+
s.push(f);
|
|
1065
|
+
} else if (c && typeof i == "string" && i.startsWith("/") && i.endsWith("/")) {
|
|
1066
|
+
if (r.queryFind(u, i, "some")) {
|
|
1067
|
+
const f = {
|
|
1068
|
+
value: o,
|
|
1068
1069
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1069
1070
|
};
|
|
1070
|
-
s.push(
|
|
1071
|
+
s.push(f);
|
|
1071
1072
|
}
|
|
1072
|
-
} else if (
|
|
1073
|
-
const
|
|
1074
|
-
if (
|
|
1075
|
-
const
|
|
1076
|
-
value:
|
|
1073
|
+
} else if (c && typeof i == "string") {
|
|
1074
|
+
const f = String(u ?? ""), l = i;
|
|
1075
|
+
if (f.toLowerCase().startsWith(l.toLowerCase())) {
|
|
1076
|
+
const d = {
|
|
1077
|
+
value: o,
|
|
1077
1078
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1078
1079
|
};
|
|
1079
|
-
s.push(
|
|
1080
|
+
s.push(d);
|
|
1080
1081
|
}
|
|
1081
|
-
} else if (
|
|
1082
|
-
const
|
|
1083
|
-
value:
|
|
1082
|
+
} else if (c && r.queryFind(u, i, "some")) {
|
|
1083
|
+
const f = {
|
|
1084
|
+
value: o,
|
|
1084
1085
|
keys: t.calculateResultKeys ? Array.from(a) : []
|
|
1085
1086
|
};
|
|
1086
|
-
s.push(
|
|
1087
|
+
s.push(f);
|
|
1087
1088
|
}
|
|
1088
1089
|
if (s.length === t.max)
|
|
1089
1090
|
break;
|
|
@@ -1091,11 +1092,11 @@ function Ge(o, e, t, r) {
|
|
|
1091
1092
|
}
|
|
1092
1093
|
return s;
|
|
1093
1094
|
}
|
|
1094
|
-
function se(
|
|
1095
|
-
return
|
|
1095
|
+
function se(n) {
|
|
1096
|
+
return n instanceof Date;
|
|
1096
1097
|
}
|
|
1097
|
-
function ne(
|
|
1098
|
-
return
|
|
1098
|
+
function ne(n) {
|
|
1099
|
+
return n instanceof Date && !isNaN(n.getTime());
|
|
1099
1100
|
}
|
|
1100
1101
|
const ie = {
|
|
1101
1102
|
yyyy: { type: "year", pattern: "yyyy", regex: "(\\d{4})" },
|
|
@@ -1112,28 +1113,28 @@ const ie = {
|
|
|
1112
1113
|
s: { type: "second", pattern: "s", regex: "(\\d{1,2})" },
|
|
1113
1114
|
SSS: { type: "millisecond", pattern: "SSS", regex: "(\\d{3})" }
|
|
1114
1115
|
};
|
|
1115
|
-
function oe(
|
|
1116
|
+
function oe(n) {
|
|
1116
1117
|
let e = "^";
|
|
1117
1118
|
const t = [];
|
|
1118
|
-
let r =
|
|
1119
|
-
const s = Object.entries(ie).sort((i,
|
|
1119
|
+
let r = n;
|
|
1120
|
+
const s = Object.entries(ie).sort((i, o) => o[0].length - i[0].length);
|
|
1120
1121
|
for (; r.length > 0; ) {
|
|
1121
1122
|
let i = !1;
|
|
1122
|
-
for (const [
|
|
1123
|
-
if (r.startsWith(
|
|
1124
|
-
e += a.regex, t.push({ type: a.type, pattern:
|
|
1123
|
+
for (const [o, a] of s)
|
|
1124
|
+
if (r.startsWith(o)) {
|
|
1125
|
+
e += a.regex, t.push({ type: a.type, pattern: o }), r = r.slice(o.length), i = !0;
|
|
1125
1126
|
break;
|
|
1126
1127
|
}
|
|
1127
1128
|
if (!i) {
|
|
1128
|
-
const
|
|
1129
|
-
if (!
|
|
1129
|
+
const o = r[0];
|
|
1130
|
+
if (!o)
|
|
1130
1131
|
break;
|
|
1131
|
-
e +=
|
|
1132
|
+
e += o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), r = r.slice(1);
|
|
1132
1133
|
}
|
|
1133
1134
|
}
|
|
1134
1135
|
return e += "$", { regex: new RegExp(e), tokenOrder: t };
|
|
1135
1136
|
}
|
|
1136
|
-
function ae(
|
|
1137
|
+
function ae(n, e) {
|
|
1137
1138
|
const t = {
|
|
1138
1139
|
year: 1970,
|
|
1139
1140
|
month: 1,
|
|
@@ -1144,54 +1145,54 @@ function ae(o, e) {
|
|
|
1144
1145
|
millisecond: 0
|
|
1145
1146
|
};
|
|
1146
1147
|
for (let r = 0; r < e.length; r++) {
|
|
1147
|
-
const s =
|
|
1148
|
+
const s = n[r + 1];
|
|
1148
1149
|
if (!s)
|
|
1149
1150
|
continue;
|
|
1150
|
-
const i = parseInt(s, 10),
|
|
1151
|
-
|
|
1151
|
+
const i = parseInt(s, 10), o = e[r];
|
|
1152
|
+
o && (o.type === "year" && o.pattern === "yy" ? t.year = 2e3 + i : t[o.type] = i);
|
|
1152
1153
|
}
|
|
1153
1154
|
return t;
|
|
1154
1155
|
}
|
|
1155
|
-
function
|
|
1156
|
-
if (
|
|
1156
|
+
function ce(n) {
|
|
1157
|
+
if (n.month < 1 || n.month > 12)
|
|
1157
1158
|
return /* @__PURE__ */ new Date(NaN);
|
|
1158
|
-
if (
|
|
1159
|
+
if (n.day < 1 || n.day > 31)
|
|
1159
1160
|
return /* @__PURE__ */ new Date(NaN);
|
|
1160
|
-
if (
|
|
1161
|
+
if (n.hour < 0 || n.hour > 23)
|
|
1161
1162
|
return /* @__PURE__ */ new Date(NaN);
|
|
1162
|
-
if (
|
|
1163
|
+
if (n.minute < 0 || n.minute > 59)
|
|
1163
1164
|
return /* @__PURE__ */ new Date(NaN);
|
|
1164
|
-
if (
|
|
1165
|
+
if (n.second < 0 || n.second > 59)
|
|
1165
1166
|
return /* @__PURE__ */ new Date(NaN);
|
|
1166
|
-
if (
|
|
1167
|
+
if (n.millisecond < 0 || n.millisecond > 999)
|
|
1167
1168
|
return /* @__PURE__ */ new Date(NaN);
|
|
1168
1169
|
const e = new Date(
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1170
|
+
n.year,
|
|
1171
|
+
n.month - 1,
|
|
1172
|
+
n.day,
|
|
1173
|
+
n.hour,
|
|
1174
|
+
n.minute,
|
|
1175
|
+
n.second,
|
|
1176
|
+
n.millisecond
|
|
1176
1177
|
);
|
|
1177
|
-
return ne(e) ? e.getFullYear() !==
|
|
1178
|
+
return ne(e) ? e.getFullYear() !== n.year || e.getMonth() !== n.month - 1 || e.getDate() !== n.day ? /* @__PURE__ */ new Date(NaN) : e : /* @__PURE__ */ new Date(NaN);
|
|
1178
1179
|
}
|
|
1179
|
-
function
|
|
1180
|
-
if (
|
|
1181
|
-
const a = Number(
|
|
1180
|
+
function Ze(n, e, t) {
|
|
1181
|
+
if (n = n.trim(), e === "t") {
|
|
1182
|
+
const a = Number(n);
|
|
1182
1183
|
return isNaN(a) ? /* @__PURE__ */ new Date(NaN) : new Date(a * 1e3);
|
|
1183
1184
|
}
|
|
1184
1185
|
if (e === "T") {
|
|
1185
|
-
const a = Number(
|
|
1186
|
+
const a = Number(n);
|
|
1186
1187
|
return isNaN(a) ? /* @__PURE__ */ new Date(NaN) : new Date(a);
|
|
1187
1188
|
}
|
|
1188
|
-
const { regex: r, tokenOrder: s } = oe(e), i =
|
|
1189
|
+
const { regex: r, tokenOrder: s } = oe(e), i = n.match(r);
|
|
1189
1190
|
if (!i)
|
|
1190
1191
|
return /* @__PURE__ */ new Date(NaN);
|
|
1191
|
-
const
|
|
1192
|
-
return
|
|
1192
|
+
const o = ae(i, s);
|
|
1193
|
+
return ce(o);
|
|
1193
1194
|
}
|
|
1194
|
-
class
|
|
1195
|
+
class ue {
|
|
1195
1196
|
cache;
|
|
1196
1197
|
maxSize;
|
|
1197
1198
|
accessOrder;
|
|
@@ -1246,9 +1247,9 @@ class fe {
|
|
|
1246
1247
|
if (e.length === 0) return !1;
|
|
1247
1248
|
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = (i) => {
|
|
1248
1249
|
t.add(i), r.add(i);
|
|
1249
|
-
const
|
|
1250
|
-
if (
|
|
1251
|
-
for (const a of
|
|
1250
|
+
const o = this.graph.get(i);
|
|
1251
|
+
if (o) {
|
|
1252
|
+
for (const a of o)
|
|
1252
1253
|
if (t.has(a)) {
|
|
1253
1254
|
if (r.has(a))
|
|
1254
1255
|
return !0;
|
|
@@ -1258,8 +1259,8 @@ class fe {
|
|
|
1258
1259
|
return r.delete(i), !1;
|
|
1259
1260
|
};
|
|
1260
1261
|
for (let i = 0; i < e.length - 1; i++) {
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1262
|
+
const o = e[i], a = e[i + 1];
|
|
1263
|
+
o && a && this.addDependency(o, a);
|
|
1263
1264
|
}
|
|
1264
1265
|
for (const i of e)
|
|
1265
1266
|
if (!t.has(i) && s(i))
|
|
@@ -1270,13 +1271,13 @@ class fe {
|
|
|
1270
1271
|
this.graph.clear();
|
|
1271
1272
|
}
|
|
1272
1273
|
}
|
|
1273
|
-
class
|
|
1274
|
+
class le {
|
|
1274
1275
|
parseCache;
|
|
1275
1276
|
circularRefDetector;
|
|
1276
1277
|
cacheHits = 0;
|
|
1277
1278
|
cacheMisses = 0;
|
|
1278
1279
|
constructor(e = 1e3) {
|
|
1279
|
-
this.parseCache = new
|
|
1280
|
+
this.parseCache = new ue(e), this.circularRefDetector = new fe();
|
|
1280
1281
|
}
|
|
1281
1282
|
/**
|
|
1282
1283
|
* Parse an attribute string into its components
|
|
@@ -1301,18 +1302,21 @@ class de {
|
|
|
1301
1302
|
return this.cacheHits++, this.parseCache.get(e);
|
|
1302
1303
|
this.cacheMisses++;
|
|
1303
1304
|
let t, r;
|
|
1304
|
-
const s = e.includes("."), i = e.includes("["),
|
|
1305
|
-
if (
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1305
|
+
const s = e.includes("."), i = e.includes("["), o = s || i;
|
|
1306
|
+
if (o) {
|
|
1307
|
+
r = e.split(/[.[]/)[0];
|
|
1308
|
+
const c = e.indexOf("."), u = e.indexOf("[");
|
|
1309
|
+
if (i && (c === -1 || u < c)) {
|
|
1310
|
+
const l = e.indexOf("]");
|
|
1311
|
+
if (l > -1) {
|
|
1312
|
+
const d = e.indexOf(".", l + 1);
|
|
1313
|
+
d > -1 ? t = e.substring(d + 1) : t = void 0;
|
|
1314
|
+
} else s && (t = e.substring(c + 1));
|
|
1315
|
+
} else s && (t = e.substring(c + 1));
|
|
1316
|
+
}
|
|
1313
1317
|
const a = {
|
|
1314
1318
|
attribute: e,
|
|
1315
|
-
isDeepQuery:
|
|
1319
|
+
isDeepQuery: o
|
|
1316
1320
|
};
|
|
1317
1321
|
return r && (a.reference = r), typeof t < "u" && t !== "" && (a.referenceAttribute = t), this.parseCache.set(e, a), a;
|
|
1318
1322
|
}
|
|
@@ -1367,16 +1371,16 @@ class de {
|
|
|
1367
1371
|
(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
1372
|
const s = (e.match(/\[/g) || []).length, i = (e.match(/]/g) || []).length;
|
|
1369
1373
|
s !== i && r.push(`Invalid bracket notation: Mismatched brackets in ${e}`), e.includes("[]") && r.push(`Invalid bracket notation: Empty brackets not allowed: ${e}`);
|
|
1370
|
-
const
|
|
1374
|
+
const o = /\[([^\]]+)\]/g;
|
|
1371
1375
|
let a;
|
|
1372
|
-
for (; (a =
|
|
1373
|
-
const
|
|
1374
|
-
|
|
1376
|
+
for (; (a = o.exec(e)) !== null; ) {
|
|
1377
|
+
const f = a[1];
|
|
1378
|
+
f && f !== "*" && !/^\d+$/.test(f) && r.push(`Invalid bracket content: Must be a number or '*', got '${f}' in ${e}`);
|
|
1375
1379
|
}
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1378
|
-
const
|
|
1379
|
-
return
|
|
1380
|
+
const c = (e.match(/\./g) || []).length + 1;
|
|
1381
|
+
c > t && r.push(`Path too deep: Maximum depth is ${t}, got ${c} in ${e}`);
|
|
1382
|
+
const u = e.match(/[^a-zA-Z0-9._[\]*-]/g);
|
|
1383
|
+
return u && r.push(`Invalid characters in path: ${u.join(", ")} in ${e}`), {
|
|
1380
1384
|
valid: r.length === 0,
|
|
1381
1385
|
errors: r.length > 0 ? r : void 0
|
|
1382
1386
|
};
|
|
@@ -1435,69 +1439,103 @@ class de {
|
|
|
1435
1439
|
return this.getPathSegments(e).length;
|
|
1436
1440
|
}
|
|
1437
1441
|
}
|
|
1438
|
-
const
|
|
1439
|
-
function
|
|
1440
|
-
if (
|
|
1441
|
-
const
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1442
|
+
const y = new le();
|
|
1443
|
+
function x(n, e) {
|
|
1444
|
+
if (e.includes("[*]")) {
|
|
1445
|
+
const i = e.indexOf("[*]"), o = e.substring(0, i), a = e.substring(i + 3), c = o ? I(n, o) : n;
|
|
1446
|
+
if (!Array.isArray(c)) return [];
|
|
1447
|
+
const u = [];
|
|
1448
|
+
for (const f of c)
|
|
1449
|
+
!a || a === "" ? f !== void 0 && u.push(f) : a.startsWith(".") && u.push(...x(f, a.slice(1)));
|
|
1450
|
+
return u;
|
|
1451
|
+
}
|
|
1452
|
+
const t = e.split(".");
|
|
1453
|
+
let r = [n];
|
|
1454
|
+
for (const i of t) {
|
|
1455
|
+
const o = [];
|
|
1456
|
+
for (const a of r)
|
|
1457
|
+
if (a != null)
|
|
1458
|
+
if (Array.isArray(a))
|
|
1459
|
+
for (const c of a) {
|
|
1460
|
+
if (c == null) continue;
|
|
1461
|
+
const u = c[i];
|
|
1462
|
+
u !== void 0 && o.push(u);
|
|
1463
|
+
}
|
|
1464
|
+
else {
|
|
1465
|
+
const c = a[i];
|
|
1466
|
+
c !== void 0 && o.push(c);
|
|
1467
|
+
}
|
|
1468
|
+
if (r = o, r.length === 0) return [];
|
|
1469
|
+
}
|
|
1470
|
+
const s = [];
|
|
1471
|
+
for (const i of r)
|
|
1472
|
+
if (Array.isArray(i))
|
|
1473
|
+
for (const o of i) o !== void 0 && s.push(o);
|
|
1474
|
+
else i !== void 0 && s.push(i);
|
|
1475
|
+
return s;
|
|
1450
1476
|
}
|
|
1451
|
-
function
|
|
1477
|
+
function M(n) {
|
|
1452
1478
|
let e = 0;
|
|
1453
|
-
for (let t of
|
|
1479
|
+
for (let t of n) {
|
|
1454
1480
|
const r = t.toString().split(".")[1];
|
|
1455
1481
|
r && (e = Math.max(e, r.length));
|
|
1456
1482
|
}
|
|
1457
1483
|
return Math.pow(10, e);
|
|
1458
1484
|
}
|
|
1459
|
-
function
|
|
1460
|
-
return (
|
|
1485
|
+
function R(n, e, t) {
|
|
1486
|
+
return (n * t + e * t) / t;
|
|
1461
1487
|
}
|
|
1462
|
-
function
|
|
1463
|
-
return
|
|
1488
|
+
function de(n, e, t) {
|
|
1489
|
+
return n * t / (e * t);
|
|
1464
1490
|
}
|
|
1465
|
-
const
|
|
1491
|
+
const C = (n, e, t, r) => {
|
|
1466
1492
|
if (!r)
|
|
1467
1493
|
throw new Error("Attribute not found");
|
|
1468
1494
|
const s = {
|
|
1469
1495
|
attribute: r,
|
|
1470
|
-
types:
|
|
1496
|
+
types: n.types
|
|
1471
1497
|
};
|
|
1472
1498
|
let i;
|
|
1473
|
-
(s.types.includes("sum") || s.types.includes("avg")
|
|
1474
|
-
let
|
|
1475
|
-
return (s.types.includes("min") || s.types.includes("max")) && (
|
|
1476
|
-
a === "sum" ? s.sum = i?.sum : a === "avg" ? s.avg = i?.average : a === "count" ? s.count =
|
|
1499
|
+
(s.types.includes("sum") || s.types.includes("avg")) && (i = ye(r, e));
|
|
1500
|
+
let o;
|
|
1501
|
+
return (s.types.includes("min") || s.types.includes("max")) && (o = pe(r, e)), n.types.forEach((a) => {
|
|
1502
|
+
a === "sum" ? s.sum = i?.sum : a === "avg" ? s.avg = i?.average : a === "count" ? s.count = he(r, e) : a === "min" ? s.min = o && o[0] : a === "max" ? s.max = o && o[1] : a === "distinct" ? s.distinct = me(n, e, t) : a === "group" && (s.group = ge(n, e));
|
|
1477
1503
|
}), s;
|
|
1478
|
-
}, he = (
|
|
1504
|
+
}, he = (n, e) => {
|
|
1505
|
+
const r = y.parse(n).isDeepQuery;
|
|
1506
|
+
let s = 0;
|
|
1507
|
+
for (const i of e.values())
|
|
1508
|
+
if (i)
|
|
1509
|
+
if (r)
|
|
1510
|
+
s += x(i, n).filter((o) => o != null).length;
|
|
1511
|
+
else {
|
|
1512
|
+
const o = i[n];
|
|
1513
|
+
if (o == null) continue;
|
|
1514
|
+
Array.isArray(o) ? s += o.filter((a) => a != null).length : s++;
|
|
1515
|
+
}
|
|
1516
|
+
return s;
|
|
1517
|
+
}, pe = (n, e) => {
|
|
1479
1518
|
let t, r;
|
|
1480
|
-
const i =
|
|
1481
|
-
for (const
|
|
1482
|
-
if (
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
} else
|
|
1490
|
-
a = n[o] !== void 0 ? [n[o]] : [];
|
|
1491
|
-
for (const u of a)
|
|
1492
|
-
(t === void 0 || u < t) && (t = u), (r === void 0 || u > r) && (r = u);
|
|
1519
|
+
const i = y.parse(n).isDeepQuery;
|
|
1520
|
+
for (const o of e.values()) {
|
|
1521
|
+
if (!o) continue;
|
|
1522
|
+
let a;
|
|
1523
|
+
if (i)
|
|
1524
|
+
a = x(o, n);
|
|
1525
|
+
else {
|
|
1526
|
+
const c = o[n];
|
|
1527
|
+
c === void 0 ? a = [] : Array.isArray(c) ? a = c.filter((u) => u !== void 0) : a = [c];
|
|
1493
1528
|
}
|
|
1529
|
+
for (const c of a)
|
|
1530
|
+
c == null || typeof c == "object" || ((t === void 0 || c < t) && (t = c), (r === void 0 || c > r) && (r = c));
|
|
1531
|
+
}
|
|
1494
1532
|
if (!(t === void 0 || r === void 0))
|
|
1495
1533
|
return [t, r];
|
|
1496
|
-
},
|
|
1534
|
+
}, ge = (n, e) => {
|
|
1497
1535
|
const t = [];
|
|
1498
|
-
|
|
1536
|
+
n.groupOptions?.groups?.forEach((o) => {
|
|
1499
1537
|
t.push({
|
|
1500
|
-
option:
|
|
1538
|
+
option: o,
|
|
1501
1539
|
count: 0,
|
|
1502
1540
|
keys: []
|
|
1503
1541
|
});
|
|
@@ -1506,68 +1544,61 @@ const M = (o, e, t, r) => {
|
|
|
1506
1544
|
option: { value: ["$dcupl_not_found"] },
|
|
1507
1545
|
count: 0,
|
|
1508
1546
|
keys: []
|
|
1509
|
-
}, i =
|
|
1510
|
-
for (const
|
|
1547
|
+
}, i = y.parse(n.attribute).isDeepQuery;
|
|
1548
|
+
for (const o of e.values()) {
|
|
1511
1549
|
let a;
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
const f
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
for (const c of t)
|
|
1522
|
-
(typeof c.option.value < "u" && c.option.value.includes(f) || typeof c.option.from < "u" && c.option.from < f && typeof c.option.to < "u" && c.option.to > f) && (c.keys.includes(n.key) || (c.count++, c.keys.push(n.key)), u = !0);
|
|
1523
|
-
!u && o?.groupOptions?.calculateNotFound && (r.count++, r.keys.push(n.key));
|
|
1524
|
-
}
|
|
1525
|
-
return o?.groupOptions?.calculateNotFound && t.push(r), t;
|
|
1526
|
-
}, ge = (o, e) => {
|
|
1550
|
+
i ? a = x(o, n.attribute) : a = [o[n.attribute]];
|
|
1551
|
+
let c = !1;
|
|
1552
|
+
for (const u of a)
|
|
1553
|
+
for (const f of t)
|
|
1554
|
+
(typeof f.option.value < "u" && f.option.value.includes(u) || typeof f.option.from < "u" && f.option.from < u && typeof f.option.to < "u" && f.option.to > u) && (f.keys.includes(o.key) || (f.count++, f.keys.push(o.key)), c = !0);
|
|
1555
|
+
!c && n?.groupOptions?.calculateNotFound && (r.count++, r.keys.push(o.key));
|
|
1556
|
+
}
|
|
1557
|
+
return n?.groupOptions?.calculateNotFound && t.push(r), t;
|
|
1558
|
+
}, ye = (n, e) => {
|
|
1527
1559
|
let t = 0, r = 0;
|
|
1528
|
-
const i =
|
|
1529
|
-
for (const
|
|
1530
|
-
if (!
|
|
1531
|
-
let
|
|
1532
|
-
if (i
|
|
1533
|
-
|
|
1534
|
-
else
|
|
1535
|
-
const
|
|
1536
|
-
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
else typeof c == "number" && (t = B(t, c, K([t, c])), r++);
|
|
1560
|
+
const i = y.parse(n).isDeepQuery;
|
|
1561
|
+
for (const a of e.values()) {
|
|
1562
|
+
if (!a) continue;
|
|
1563
|
+
let c;
|
|
1564
|
+
if (i)
|
|
1565
|
+
c = x(a, n);
|
|
1566
|
+
else {
|
|
1567
|
+
const u = a[n];
|
|
1568
|
+
u === void 0 ? c = [] : Array.isArray(u) ? c = u : c = [u];
|
|
1569
|
+
}
|
|
1570
|
+
for (const u of c)
|
|
1571
|
+
if (Array.isArray(u))
|
|
1572
|
+
for (const f of u)
|
|
1573
|
+
typeof f == "number" && (t = R(t, f, M([t, f])), r++);
|
|
1574
|
+
else typeof u == "number" && (t = R(t, u, M([t, u])), r++);
|
|
1544
1575
|
}
|
|
1545
1576
|
return r === 0 ? void 0 : {
|
|
1546
|
-
average:
|
|
1547
|
-
count:
|
|
1577
|
+
average: de(t, r, M([t, r])),
|
|
1578
|
+
count: r,
|
|
1548
1579
|
sum: t
|
|
1549
1580
|
};
|
|
1550
|
-
},
|
|
1581
|
+
}, me = (n, e, t) => {
|
|
1551
1582
|
const r = [];
|
|
1552
1583
|
for (const [s, i] of t)
|
|
1553
|
-
if (!(
|
|
1554
|
-
const
|
|
1584
|
+
if (!(n.excludeUndefineds && typeof s > "u") && Array.from(i).find((o) => e.has(o))) {
|
|
1585
|
+
const o = {
|
|
1555
1586
|
value: s,
|
|
1556
1587
|
count: i.size
|
|
1557
1588
|
};
|
|
1558
|
-
if (
|
|
1589
|
+
if (n.distinctOptions?.skipKeys || (o.keys = Array.from(i)), r.push(o), n.distinctOptions?.limit && r.length >= n.distinctOptions.limit)
|
|
1559
1590
|
break;
|
|
1560
1591
|
}
|
|
1561
1592
|
return r;
|
|
1562
1593
|
};
|
|
1563
|
-
class
|
|
1594
|
+
class A extends Error {
|
|
1564
1595
|
query;
|
|
1565
1596
|
constructor(e, t) {
|
|
1566
1597
|
const r = `Query Error: ${e} in ${JSON.stringify(t, null, 2)}`;
|
|
1567
1598
|
super(r), this.query = t, this.name = "DcuplQueryError";
|
|
1568
1599
|
}
|
|
1569
1600
|
}
|
|
1570
|
-
class
|
|
1601
|
+
class B {
|
|
1571
1602
|
_defaultQueryOptions = {
|
|
1572
1603
|
modelKey: "",
|
|
1573
1604
|
groupKey: "root",
|
|
@@ -1575,10 +1606,10 @@ class R {
|
|
|
1575
1606
|
queries: []
|
|
1576
1607
|
};
|
|
1577
1608
|
_initOptions;
|
|
1578
|
-
currentQuery =
|
|
1609
|
+
currentQuery = v(this._defaultQueryOptions);
|
|
1579
1610
|
deepQueryService;
|
|
1580
1611
|
constructor(e) {
|
|
1581
|
-
this.deepQueryService = e ||
|
|
1612
|
+
this.deepQueryService = e || y;
|
|
1582
1613
|
}
|
|
1583
1614
|
/**
|
|
1584
1615
|
* Initialize the query builder.
|
|
@@ -1604,7 +1635,7 @@ class R {
|
|
|
1604
1635
|
* });
|
|
1605
1636
|
*/
|
|
1606
1637
|
init(e) {
|
|
1607
|
-
this._initOptions =
|
|
1638
|
+
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));
|
|
1608
1639
|
}
|
|
1609
1640
|
reset() {
|
|
1610
1641
|
return this.init(this._initOptions), this.getQuery();
|
|
@@ -1613,7 +1644,7 @@ class R {
|
|
|
1613
1644
|
return "attribute" in e;
|
|
1614
1645
|
}
|
|
1615
1646
|
isQueryGroup(e) {
|
|
1616
|
-
return "groupKey" in e;
|
|
1647
|
+
return "queries" in e || "groupKey" in e;
|
|
1617
1648
|
}
|
|
1618
1649
|
isRootQueryGroup(e) {
|
|
1619
1650
|
return this.isQueryGroup(e) && e.groupKey === "root";
|
|
@@ -1622,7 +1653,7 @@ class R {
|
|
|
1622
1653
|
return this.currentQuery.queries.find((t) => this.isQueryGroup(t) && t.groupKey === e);
|
|
1623
1654
|
}
|
|
1624
1655
|
getQuery() {
|
|
1625
|
-
return
|
|
1656
|
+
return v(this.currentQuery);
|
|
1626
1657
|
}
|
|
1627
1658
|
hasQueryGroup(e) {
|
|
1628
1659
|
return this.currentQuery.queries.some((t) => this.isQueryGroup(t) && t.groupKey === e);
|
|
@@ -1638,7 +1669,7 @@ class R {
|
|
|
1638
1669
|
}
|
|
1639
1670
|
validate(e) {
|
|
1640
1671
|
const t = e.queries.map((s) => this.validateQuery(s));
|
|
1641
|
-
return { valid:
|
|
1672
|
+
return { valid: z(t, (s) => s.valid), errors: t.map((s) => s.errors).flat() };
|
|
1642
1673
|
}
|
|
1643
1674
|
applyOptions(e, t = "update") {
|
|
1644
1675
|
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();
|
|
@@ -1733,8 +1764,8 @@ class R {
|
|
|
1733
1764
|
else {
|
|
1734
1765
|
const s = t.queries[r];
|
|
1735
1766
|
for (const i of e.queries) {
|
|
1736
|
-
const
|
|
1737
|
-
|
|
1767
|
+
const o = E(s.queries, i);
|
|
1768
|
+
o > -1 && s.queries.splice(o, 1);
|
|
1738
1769
|
}
|
|
1739
1770
|
s.queries.length === 0 && t.queries.splice(r, 1);
|
|
1740
1771
|
}
|
|
@@ -1744,12 +1775,12 @@ class R {
|
|
|
1744
1775
|
validateQuery(e) {
|
|
1745
1776
|
const t = [];
|
|
1746
1777
|
if (this.isQuery(e))
|
|
1747
|
-
return e.attribute || t.push(new
|
|
1778
|
+
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 };
|
|
1748
1779
|
if (this.isQueryGroup(e)) {
|
|
1749
|
-
const i = e.queries.map((
|
|
1780
|
+
const i = e.queries.map((o) => this.validateQuery(o)).filter((o) => !o.valid).map((o) => o.errors).flat();
|
|
1750
1781
|
return i.length > 0 ? { valid: !1, errors: i } : { valid: !0 };
|
|
1751
1782
|
}
|
|
1752
|
-
return t.push(new
|
|
1783
|
+
return t.push(new A("Invalid query definition", e)), { valid: !1, errors: t };
|
|
1753
1784
|
}
|
|
1754
1785
|
/**
|
|
1755
1786
|
* Get all attribute names used in the query.
|
|
@@ -1760,8 +1791,8 @@ class R {
|
|
|
1760
1791
|
*/
|
|
1761
1792
|
getQueryAttributes(e) {
|
|
1762
1793
|
const t = [], r = /* @__PURE__ */ new Set(), s = (i) => {
|
|
1763
|
-
for (const
|
|
1764
|
-
this.isQuery(
|
|
1794
|
+
for (const o of i)
|
|
1795
|
+
this.isQuery(o) ? o.attribute && !r.has(o.attribute) && (t.push(o.attribute), r.add(o.attribute)) : this.isQueryGroup(o) && s(o.queries);
|
|
1765
1796
|
};
|
|
1766
1797
|
return s(e?.queries || this.currentQuery.queries), t;
|
|
1767
1798
|
}
|
|
@@ -1774,13 +1805,13 @@ class R {
|
|
|
1774
1805
|
*/
|
|
1775
1806
|
extractQueryAttributes(e) {
|
|
1776
1807
|
const t = [], r = /* @__PURE__ */ new Set(), s = (i) => {
|
|
1777
|
-
for (const
|
|
1778
|
-
if (this.isQuery(
|
|
1779
|
-
if (
|
|
1780
|
-
const a = this.getQueryAttributeForString(
|
|
1781
|
-
t.push(a), r.add(
|
|
1808
|
+
for (const o of i)
|
|
1809
|
+
if (this.isQuery(o)) {
|
|
1810
|
+
if (o.attribute && !r.has(o.attribute)) {
|
|
1811
|
+
const a = this.getQueryAttributeForString(o.attribute);
|
|
1812
|
+
t.push(a), r.add(o.attribute);
|
|
1782
1813
|
}
|
|
1783
|
-
} else this.isQueryGroup(
|
|
1814
|
+
} else this.isQueryGroup(o) && s(o.queries);
|
|
1784
1815
|
};
|
|
1785
1816
|
return s(e?.queries || this.currentQuery.queries), t;
|
|
1786
1817
|
}
|
|
@@ -1822,8 +1853,8 @@ class R {
|
|
|
1822
1853
|
const s = this.deepQueryService.parse(r.referenceAttribute);
|
|
1823
1854
|
if (s.isDeepQuery && r.reference) {
|
|
1824
1855
|
const i = this.getProjectionForAttributeEntries([s]);
|
|
1825
|
-
Object.keys(i).forEach((
|
|
1826
|
-
|
|
1856
|
+
Object.keys(i).forEach((o) => {
|
|
1857
|
+
o !== "$" && r.reference && (t[r.reference][o] = i[o]);
|
|
1827
1858
|
});
|
|
1828
1859
|
} else r.reference && (t[r.reference][r.referenceAttribute] = !0);
|
|
1829
1860
|
} else
|
|
@@ -2122,8 +2153,8 @@ class R {
|
|
|
2122
2153
|
for (const s of r)
|
|
2123
2154
|
if (this.isQuery(s)) {
|
|
2124
2155
|
let i = !0;
|
|
2125
|
-
for (const
|
|
2126
|
-
if (s[
|
|
2156
|
+
for (const o in e)
|
|
2157
|
+
if (s[o] !== e[o]) {
|
|
2127
2158
|
i = !1;
|
|
2128
2159
|
break;
|
|
2129
2160
|
}
|
|
@@ -2248,48 +2279,91 @@ class R {
|
|
|
2248
2279
|
return e(this.currentQuery.queries);
|
|
2249
2280
|
}
|
|
2250
2281
|
}
|
|
2251
|
-
const
|
|
2252
|
-
function
|
|
2253
|
-
const a =
|
|
2282
|
+
const N = new B();
|
|
2283
|
+
function Xe(n, e, t, r, s, i, o) {
|
|
2284
|
+
const a = N.removeQuery({ groupKey: s }, v(r)), c = o.queryData(n, a, !1, i), u = e ? [...e.keys()] : [], f = new Set(u), l = i.get(s) ?? /* @__PURE__ */ new Map();
|
|
2254
2285
|
if (!t.excludeUnresolved)
|
|
2255
2286
|
for (const h of l.keys())
|
|
2256
|
-
|
|
2257
|
-
t.excludeUndefineds ?
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2287
|
+
f.add(h);
|
|
2288
|
+
if (t.excludeUndefineds ? f.delete(void 0) : f.add(void 0), t.sort) {
|
|
2289
|
+
const h = [];
|
|
2290
|
+
for (const m of f.values())
|
|
2291
|
+
h.push(
|
|
2292
|
+
G(m, l, c, e, s, r, !0)
|
|
2293
|
+
);
|
|
2294
|
+
const g = t.excludeZeros ? h.filter((m) => m.size > 0) : h;
|
|
2295
|
+
return g.sort(ve(t.sort)), t.count ? g.slice(0, t.count) : g;
|
|
2296
|
+
}
|
|
2297
|
+
const d = [];
|
|
2298
|
+
for (const h of f.values()) {
|
|
2299
|
+
const g = G(
|
|
2300
|
+
h,
|
|
2301
|
+
l,
|
|
2302
|
+
c,
|
|
2303
|
+
e,
|
|
2304
|
+
s,
|
|
2305
|
+
r,
|
|
2306
|
+
!!t?.calculateFacets
|
|
2307
|
+
);
|
|
2308
|
+
if (!(t?.excludeZeros && g.size === 0)) {
|
|
2309
|
+
if (t?.count && d.length === t?.count)
|
|
2310
|
+
return d;
|
|
2311
|
+
d.push(g);
|
|
2278
2312
|
}
|
|
2279
2313
|
}
|
|
2280
|
-
return
|
|
2314
|
+
return d;
|
|
2315
|
+
}
|
|
2316
|
+
function G(n, e, t, r, s, i, o) {
|
|
2317
|
+
const a = /* @__PURE__ */ new Map(), c = e.get(n) || /* @__PURE__ */ new Set();
|
|
2318
|
+
for (const u of c) {
|
|
2319
|
+
const f = t.get(u);
|
|
2320
|
+
if (f && (a.set(u, f), !o))
|
|
2321
|
+
break;
|
|
2322
|
+
}
|
|
2323
|
+
return {
|
|
2324
|
+
key: String(n),
|
|
2325
|
+
value: n,
|
|
2326
|
+
selected: we(s, n, i),
|
|
2327
|
+
enabled: a.size > 0,
|
|
2328
|
+
size: a.size,
|
|
2329
|
+
entry: r?.get(n),
|
|
2330
|
+
resultKeys: Array.from(a.keys())
|
|
2331
|
+
};
|
|
2332
|
+
}
|
|
2333
|
+
function D(n, e) {
|
|
2334
|
+
if (n === void 0 && e === void 0) return 0;
|
|
2335
|
+
if (n === void 0) return 1;
|
|
2336
|
+
if (e === void 0) return -1;
|
|
2337
|
+
const t = typeof n, r = typeof e;
|
|
2338
|
+
if (t !== r) return t < r ? -1 : 1;
|
|
2339
|
+
if (t === "number") return n - e;
|
|
2340
|
+
if (t === "string") return n.localeCompare(e);
|
|
2341
|
+
const s = String(n), i = String(e);
|
|
2342
|
+
return s < i ? -1 : s > i ? 1 : 0;
|
|
2343
|
+
}
|
|
2344
|
+
function ve(n) {
|
|
2345
|
+
switch (n) {
|
|
2346
|
+
case "size-desc":
|
|
2347
|
+
return (e, t) => t.size - e.size || D(e.value, t.value);
|
|
2348
|
+
case "size-asc":
|
|
2349
|
+
return (e, t) => e.size - t.size || D(e.value, t.value);
|
|
2350
|
+
case "value-asc":
|
|
2351
|
+
return (e, t) => D(e.value, t.value);
|
|
2352
|
+
case "value-desc":
|
|
2353
|
+
return (e, t) => e.value === void 0 && t.value === void 0 ? 0 : e.value === void 0 ? 1 : t.value === void 0 ? -1 : -D(e.value, t.value);
|
|
2354
|
+
}
|
|
2281
2355
|
}
|
|
2282
|
-
const
|
|
2283
|
-
const r = t.queries.findIndex((s) =>
|
|
2356
|
+
const we = (n, e, t) => {
|
|
2357
|
+
const r = t.queries.findIndex((s) => N.isQueryGroup(s) && s.groupKey === n);
|
|
2284
2358
|
return r > -1 ? !!t.queries[r].queries.find((i) => {
|
|
2285
|
-
if (
|
|
2286
|
-
const
|
|
2287
|
-
return i.attribute ===
|
|
2359
|
+
if (N.isQuery(i)) {
|
|
2360
|
+
const o = i.value?.key || i.value;
|
|
2361
|
+
return i.attribute === n && o === e;
|
|
2288
2362
|
}
|
|
2289
2363
|
return !1;
|
|
2290
2364
|
}) : !1;
|
|
2291
2365
|
};
|
|
2292
|
-
class
|
|
2366
|
+
class xe {
|
|
2293
2367
|
indexMap = /* @__PURE__ */ new Map();
|
|
2294
2368
|
// Possible performance gain*
|
|
2295
2369
|
dataMap = /* @__PURE__ */ new Map();
|
|
@@ -2299,6 +2373,15 @@ class ve {
|
|
|
2299
2373
|
reset(e) {
|
|
2300
2374
|
e ? (this.indexMap.delete(e), this.dataMap.delete(e), this.indexMetadata.delete(e)) : (this.indexMap.clear(), this.dataMap.clear(), this.indexMetadata.clear());
|
|
2301
2375
|
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Removes every index the predicate selects. Used to drop indices that
|
|
2378
|
+
* were built from now-stale data; the next read lazily rebuilds them via
|
|
2379
|
+
* {@link getOrCreateIndex}.
|
|
2380
|
+
*/
|
|
2381
|
+
resetIndicesWhere(e) {
|
|
2382
|
+
for (const t of Array.from(this.indexMap.keys()))
|
|
2383
|
+
e(t) && this.reset(t);
|
|
2384
|
+
}
|
|
2302
2385
|
fillDataMap(e, t) {
|
|
2303
2386
|
let r = this.dataMap.get(e);
|
|
2304
2387
|
r || (r = /* @__PURE__ */ new Map(), this.dataMap.set(e, r));
|
|
@@ -2311,8 +2394,8 @@ class ve {
|
|
|
2311
2394
|
this.fillDataMap(e, [a]);
|
|
2312
2395
|
return;
|
|
2313
2396
|
} else s instanceof Date ? i = s.toISOString() : i = s;
|
|
2314
|
-
let
|
|
2315
|
-
|
|
2397
|
+
let o = r.get(i);
|
|
2398
|
+
o || (o = { key: i }, this.dataMap.get(e)?.set(i, o));
|
|
2316
2399
|
}
|
|
2317
2400
|
}
|
|
2318
2401
|
fillInverseIndex(e, t, r) {
|
|
@@ -2320,16 +2403,16 @@ class ve {
|
|
|
2320
2403
|
return;
|
|
2321
2404
|
const s = this.indexMap.get(e) || /* @__PURE__ */ new Map();
|
|
2322
2405
|
for (const i of r) {
|
|
2323
|
-
let
|
|
2406
|
+
let o;
|
|
2324
2407
|
if (typeof i == "object" && i && i.key)
|
|
2325
|
-
|
|
2408
|
+
o = i.key;
|
|
2326
2409
|
else if (Array.isArray(i)) {
|
|
2327
|
-
for (const
|
|
2328
|
-
this.fillInverseIndex(e, t, [
|
|
2410
|
+
for (const c of i)
|
|
2411
|
+
this.fillInverseIndex(e, t, [c]);
|
|
2329
2412
|
return;
|
|
2330
|
-
} else i instanceof Date ?
|
|
2331
|
-
let a = s.get(
|
|
2332
|
-
a || (a = /* @__PURE__ */ new Set(), s.set(
|
|
2413
|
+
} else i instanceof Date ? o = i.toISOString() : o = i;
|
|
2414
|
+
let a = s.get(o);
|
|
2415
|
+
a || (a = /* @__PURE__ */ new Set(), s.set(o, a)), a.add(t);
|
|
2333
2416
|
}
|
|
2334
2417
|
this.indexMap.set(e, s);
|
|
2335
2418
|
}
|
|
@@ -2344,31 +2427,31 @@ class ve {
|
|
|
2344
2427
|
getOrCreateIndex(e, t, r) {
|
|
2345
2428
|
const s = this.getIndexName(e, r);
|
|
2346
2429
|
let i = this.getIndex(s);
|
|
2347
|
-
const
|
|
2348
|
-
if (
|
|
2349
|
-
|
|
2430
|
+
const o = this.indexMetadata.get(s);
|
|
2431
|
+
if (o)
|
|
2432
|
+
o.lastAccessedAt = Date.now();
|
|
2350
2433
|
else if (!i) {
|
|
2351
|
-
const
|
|
2434
|
+
const c = y.parse(e).isDeepQuery ?? !1;
|
|
2352
2435
|
this.indexMetadata.set(s, {
|
|
2353
2436
|
createdAt: Date.now(),
|
|
2354
2437
|
lastAccessedAt: Date.now(),
|
|
2355
2438
|
context: r,
|
|
2356
|
-
type:
|
|
2439
|
+
type: c ? "deep" : "shallow"
|
|
2357
2440
|
});
|
|
2358
2441
|
}
|
|
2359
2442
|
if (!i) {
|
|
2360
2443
|
this.reset(s), this.indexMap.set(s, /* @__PURE__ */ new Map());
|
|
2361
|
-
const
|
|
2362
|
-
for (const
|
|
2363
|
-
let
|
|
2364
|
-
|
|
2444
|
+
const c = y.parse(e).isDeepQuery;
|
|
2445
|
+
for (const u of t.values()) {
|
|
2446
|
+
let f;
|
|
2447
|
+
c ? (f = x(u, e), f.length === 0 && (f = [void 0])) : f = [u[e]], this.fillInverseIndex(s, u.key, f), this.fillDataMap(s, f);
|
|
2365
2448
|
}
|
|
2366
2449
|
i = this.getIndex(s) || /* @__PURE__ */ new Map();
|
|
2367
2450
|
}
|
|
2368
2451
|
return i;
|
|
2369
2452
|
}
|
|
2370
2453
|
getIndexName(e, t) {
|
|
2371
|
-
return t ? e + "_" +
|
|
2454
|
+
return t ? e + "_" + K(t) : e;
|
|
2372
2455
|
}
|
|
2373
2456
|
// ========== PARTIAL UPDATE METHODS ==========
|
|
2374
2457
|
/**
|
|
@@ -2381,16 +2464,16 @@ class ve {
|
|
|
2381
2464
|
const s = this.indexMap.get(e);
|
|
2382
2465
|
if (s)
|
|
2383
2466
|
for (const i of r) {
|
|
2384
|
-
let
|
|
2467
|
+
let o;
|
|
2385
2468
|
if (typeof i == "object" && i && i.key)
|
|
2386
|
-
|
|
2469
|
+
o = i.key;
|
|
2387
2470
|
else if (Array.isArray(i)) {
|
|
2388
|
-
for (const
|
|
2389
|
-
this.removeFromInverseIndex(e, t, [
|
|
2471
|
+
for (const c of i)
|
|
2472
|
+
this.removeFromInverseIndex(e, t, [c]);
|
|
2390
2473
|
return;
|
|
2391
|
-
} else i instanceof Date ?
|
|
2392
|
-
const a = s.get(
|
|
2393
|
-
a && (a.delete(t), a.size === 0 && s.delete(
|
|
2474
|
+
} else i instanceof Date ? o = i.toISOString() : o = i;
|
|
2475
|
+
const a = s.get(o);
|
|
2476
|
+
a && (a.delete(t), a.size === 0 && s.delete(o));
|
|
2394
2477
|
}
|
|
2395
2478
|
}
|
|
2396
2479
|
/**
|
|
@@ -2416,8 +2499,8 @@ class ve {
|
|
|
2416
2499
|
if (typeof s == "object" && s && s.key)
|
|
2417
2500
|
i = s.key;
|
|
2418
2501
|
else if (Array.isArray(s)) {
|
|
2419
|
-
for (const
|
|
2420
|
-
this.removeFromDataMap(e, [
|
|
2502
|
+
for (const o of s)
|
|
2503
|
+
this.removeFromDataMap(e, [o]);
|
|
2421
2504
|
return;
|
|
2422
2505
|
} else s instanceof Date ? i = s.toISOString() : i = s;
|
|
2423
2506
|
r.delete(i);
|
|
@@ -2462,7 +2545,7 @@ class ve {
|
|
|
2462
2545
|
isDeepQueryIndex(e) {
|
|
2463
2546
|
const t = e.includes("_") ? e.split("_")[0] : e;
|
|
2464
2547
|
try {
|
|
2465
|
-
return
|
|
2548
|
+
return y.parse(t).isDeepQuery ?? !1;
|
|
2466
2549
|
} catch {
|
|
2467
2550
|
return !1;
|
|
2468
2551
|
}
|
|
@@ -2523,8 +2606,8 @@ class ve {
|
|
|
2523
2606
|
getStats() {
|
|
2524
2607
|
const e = this.getIndexCount(), t = Date.now();
|
|
2525
2608
|
let r = 0, s = 0;
|
|
2526
|
-
for (const
|
|
2527
|
-
const a = t -
|
|
2609
|
+
for (const o of this.indexMetadata.values()) {
|
|
2610
|
+
const a = t - o.createdAt;
|
|
2528
2611
|
r += a, a > s && (s = a);
|
|
2529
2612
|
}
|
|
2530
2613
|
const i = this.indexMetadata.size > 0 ? r / this.indexMetadata.size : 0;
|
|
@@ -2537,153 +2620,165 @@ class ve {
|
|
|
2537
2620
|
};
|
|
2538
2621
|
}
|
|
2539
2622
|
}
|
|
2540
|
-
const
|
|
2541
|
-
function
|
|
2542
|
-
const
|
|
2623
|
+
const w = "__";
|
|
2624
|
+
function j(n, e, t = { key: "root" }, r = "root", s = new xe(), i) {
|
|
2625
|
+
const o = i || n;
|
|
2543
2626
|
for (const a of e.columns)
|
|
2544
|
-
a.attribute && (
|
|
2627
|
+
a.attribute && (y.parse(a.attribute), s.getOrCreateIndex(a.attribute, o));
|
|
2545
2628
|
for (const a of e.rows)
|
|
2546
|
-
a.attribute && (
|
|
2629
|
+
a.attribute && (y.parse(a.attribute), s.getOrCreateIndex(a.attribute, o));
|
|
2547
2630
|
for (const a of e.values)
|
|
2548
|
-
a.attribute && (
|
|
2631
|
+
a.attribute && (y.parse(a.attribute), s.getOrCreateIndex(a.attribute, o));
|
|
2549
2632
|
if (e.rows && e.rows.length > 0) {
|
|
2550
2633
|
t.rows = t.rows || [];
|
|
2551
|
-
const a =
|
|
2634
|
+
const a = Ae(n, e.rows[0], e, s, r, i);
|
|
2552
2635
|
t.rows.push(a);
|
|
2553
2636
|
}
|
|
2554
2637
|
if (e.columns && e.columns.length > 0) {
|
|
2555
2638
|
t.columns = t.columns || [];
|
|
2556
|
-
const a =
|
|
2639
|
+
const a = L(n, e.columns[0], e, s, r, i);
|
|
2557
2640
|
t.columns.push(a);
|
|
2558
2641
|
}
|
|
2559
2642
|
if (t.key === "root")
|
|
2560
2643
|
for (const a of e.values) {
|
|
2561
2644
|
if (t.values = t.values || [], r === "root" && e.options?.calculateTotals === !1)
|
|
2562
2645
|
continue;
|
|
2563
|
-
const
|
|
2564
|
-
t.values.push(
|
|
2646
|
+
const c = C(a, n, s.getIndex(a.attribute), a.attribute);
|
|
2647
|
+
t.values.push(c);
|
|
2565
2648
|
}
|
|
2566
2649
|
return t;
|
|
2567
2650
|
}
|
|
2568
|
-
function
|
|
2569
|
-
const
|
|
2651
|
+
function Ae(n, e, t, r, s = "", i) {
|
|
2652
|
+
const o = { key: e.attribute }, a = r.getIndex(e.attribute);
|
|
2570
2653
|
if (!a)
|
|
2571
|
-
return
|
|
2572
|
-
for (const [
|
|
2573
|
-
const
|
|
2574
|
-
key:
|
|
2575
|
-
value:
|
|
2576
|
-
},
|
|
2577
|
-
for (const
|
|
2578
|
-
|
|
2579
|
-
if (
|
|
2580
|
-
for (const
|
|
2581
|
-
if (
|
|
2654
|
+
return o;
|
|
2655
|
+
for (const [c, u] of a.entries()) {
|
|
2656
|
+
const f = {
|
|
2657
|
+
key: c,
|
|
2658
|
+
value: c
|
|
2659
|
+
}, l = /* @__PURE__ */ new Map();
|
|
2660
|
+
for (const d of u)
|
|
2661
|
+
n.has(d) && l.set(d, n.get(d));
|
|
2662
|
+
if (l.size) {
|
|
2663
|
+
for (const d of t.values) {
|
|
2664
|
+
if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
|
|
2582
2665
|
continue;
|
|
2583
|
-
const h =
|
|
2584
|
-
|
|
2666
|
+
const h = C(d, l, r.getIndex(d.attribute), d.attribute);
|
|
2667
|
+
f.values.push(h);
|
|
2585
2668
|
}
|
|
2586
|
-
if (
|
|
2587
|
-
const
|
|
2588
|
-
|
|
2589
|
-
d,
|
|
2669
|
+
if (o.rows = o.rows || [], o.rows.push(f), t.rows.length > 1) {
|
|
2670
|
+
const d = { ...t, rows: t.rows.slice(1) };
|
|
2671
|
+
j(
|
|
2590
2672
|
l,
|
|
2591
|
-
|
|
2592
|
-
|
|
2673
|
+
d,
|
|
2674
|
+
f,
|
|
2675
|
+
s + w + e.attribute + w + c,
|
|
2593
2676
|
r,
|
|
2594
2677
|
i
|
|
2595
2678
|
);
|
|
2596
2679
|
} else if (t.columns)
|
|
2597
|
-
for (const
|
|
2598
|
-
|
|
2599
|
-
const h =
|
|
2600
|
-
d,
|
|
2680
|
+
for (const d of t.columns) {
|
|
2681
|
+
f.columns = f.columns || [];
|
|
2682
|
+
const h = L(
|
|
2601
2683
|
l,
|
|
2684
|
+
d,
|
|
2602
2685
|
t,
|
|
2603
2686
|
r,
|
|
2604
|
-
s +
|
|
2687
|
+
s + w + e.attribute + w + c,
|
|
2605
2688
|
i
|
|
2606
2689
|
);
|
|
2607
|
-
|
|
2690
|
+
f.columns.push(h);
|
|
2608
2691
|
}
|
|
2609
2692
|
}
|
|
2610
2693
|
}
|
|
2611
|
-
return
|
|
2694
|
+
return o;
|
|
2612
2695
|
}
|
|
2613
|
-
function
|
|
2614
|
-
const
|
|
2696
|
+
function L(n, e, t, r, s = "", i) {
|
|
2697
|
+
const o = { key: e.attribute }, a = r.getIndex(e.attribute);
|
|
2615
2698
|
if (!a)
|
|
2616
|
-
return
|
|
2617
|
-
for (const [
|
|
2618
|
-
const
|
|
2619
|
-
key:
|
|
2620
|
-
value:
|
|
2621
|
-
},
|
|
2622
|
-
for (const
|
|
2623
|
-
|
|
2624
|
-
if (
|
|
2625
|
-
for (const
|
|
2626
|
-
if (
|
|
2699
|
+
return o;
|
|
2700
|
+
for (const [c, u] of a.entries()) {
|
|
2701
|
+
const f = {
|
|
2702
|
+
key: c,
|
|
2703
|
+
value: c
|
|
2704
|
+
}, l = /* @__PURE__ */ new Map();
|
|
2705
|
+
for (const d of u)
|
|
2706
|
+
n.has(d) && l.set(d, n.get(d));
|
|
2707
|
+
if (l.size) {
|
|
2708
|
+
for (const d of t.values) {
|
|
2709
|
+
if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
|
|
2627
2710
|
continue;
|
|
2628
|
-
const h =
|
|
2629
|
-
|
|
2711
|
+
const h = C(d, l, r.getIndex(d.attribute), d.attribute);
|
|
2712
|
+
f.values.push(h);
|
|
2630
2713
|
}
|
|
2631
|
-
if (
|
|
2632
|
-
const
|
|
2633
|
-
|
|
2634
|
-
d,
|
|
2714
|
+
if (o.columns = o.columns || [], o.columns.push(f), t.columns.length > 1) {
|
|
2715
|
+
const d = { ...t, columns: t.columns.slice(1) };
|
|
2716
|
+
j(
|
|
2635
2717
|
l,
|
|
2636
|
-
|
|
2637
|
-
|
|
2718
|
+
d,
|
|
2719
|
+
f,
|
|
2720
|
+
s + w + e.attribute + w + c,
|
|
2638
2721
|
r,
|
|
2639
2722
|
i
|
|
2640
2723
|
);
|
|
2641
2724
|
}
|
|
2642
2725
|
}
|
|
2643
2726
|
}
|
|
2644
|
-
return
|
|
2727
|
+
return o;
|
|
2645
2728
|
}
|
|
2646
|
-
const
|
|
2647
|
-
const
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2729
|
+
const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/, Se = /^-?\d+$/, De = /^-?\d+\.\d+$/, Ie = /^\d{1,2}([/.-])\d{1,2}\1\d{2,4}$/, Ke = (n) => n === "true" || n === "false" ? "boolean" : Se.test(n) ? "int" : De.test(n) ? "float" : be.test(n) && !Number.isNaN(Date.parse(n)) ? "date" : "string", Me = (n) => Ie.test(n), Qe = (n) => n == null || n === "", ke = (n) => {
|
|
2730
|
+
const e = [...n];
|
|
2731
|
+
return e.length <= 1 ? { type: e[0] ?? "any", conflict: !1 } : e.every((t) => t === "int" || t === "float") ? { type: "float", conflict: !1 } : { type: "any", conflict: !0 };
|
|
2732
|
+
}, Ne = (n, e = {}) => {
|
|
2733
|
+
const r = e.deep ?? (e.sampleSize !== void 0 && e.sampleSize > 1) ? e.sampleSize ?? 1 / 0 : 1, s = e.coerceStrings ?? !0, i = /* @__PURE__ */ new Map(), o = [], a = Math.min(n.length, r);
|
|
2734
|
+
for (let f = 0; f < a; f++) {
|
|
2735
|
+
const l = n[f];
|
|
2736
|
+
if (l)
|
|
2737
|
+
for (const [d, h] of Object.entries(l)) {
|
|
2738
|
+
let g = i.get(d);
|
|
2739
|
+
if (g || (g = { observed: /* @__PURE__ */ new Set(), empty: 0, scanned: 0 }, i.set(d, g), o.push(d)), g.scanned++, Qe(h)) {
|
|
2740
|
+
g.empty++;
|
|
2741
|
+
continue;
|
|
2742
|
+
}
|
|
2743
|
+
let m;
|
|
2744
|
+
typeof h == "string" && s ? (m = Ke(h), m === "string" && !g.hint && Me(h) && (g.hint = "column looks date-like (non-ISO) — review manually")) : m = $e(h), g.observed.add(m);
|
|
2659
2745
|
}
|
|
2660
|
-
}
|
|
2661
|
-
if (!e)
|
|
2662
|
-
break;
|
|
2663
2746
|
}
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2747
|
+
const c = [], u = [];
|
|
2748
|
+
for (const f of o) {
|
|
2749
|
+
const l = i.get(f), { type: d, conflict: h } = ke(l.observed.size ? l.observed : /* @__PURE__ */ new Set(["string"]));
|
|
2750
|
+
c.push({ key: f, type: d }), u.push({
|
|
2751
|
+
column: f,
|
|
2752
|
+
inferredType: d,
|
|
2753
|
+
observedTypes: [...l.observed].sort(),
|
|
2754
|
+
emptyRate: l.scanned === 0 ? 0 : l.empty / l.scanned,
|
|
2755
|
+
conflict: h,
|
|
2756
|
+
hint: l.hint
|
|
2757
|
+
});
|
|
2758
|
+
}
|
|
2759
|
+
return { properties: c, diagnostics: u };
|
|
2760
|
+
}, Ye = (n, e = !1) => Ne(n, typeof e == "boolean" ? { deep: e } : e).properties, Ce = (n) => Number(n) === n && n % 1 === 0, Ee = (n) => Number(n) === n && n % 1 !== 0, $e = (n) => {
|
|
2761
|
+
switch (typeof n) {
|
|
2667
2762
|
case "string":
|
|
2668
2763
|
return "string";
|
|
2669
2764
|
case "number":
|
|
2670
|
-
return
|
|
2765
|
+
return Ce(n) ? "int" : Ee(n) ? "float" : "any";
|
|
2671
2766
|
case "boolean":
|
|
2672
2767
|
return "boolean";
|
|
2673
2768
|
case "object":
|
|
2674
|
-
return se(
|
|
2769
|
+
return se(n) ? "date" : "json";
|
|
2675
2770
|
default:
|
|
2676
2771
|
return "any";
|
|
2677
2772
|
}
|
|
2678
|
-
},
|
|
2679
|
-
const t = te(
|
|
2773
|
+
}, et = (n, e) => {
|
|
2774
|
+
const t = te(n.text || ""), r = e?.attributeKey || n.filterKey;
|
|
2680
2775
|
let s;
|
|
2681
2776
|
const i = e?.comparisonType || "containsIgnoreCase";
|
|
2682
2777
|
return i === "containsIgnoreCase" ? s = {
|
|
2683
|
-
groupKey:
|
|
2778
|
+
groupKey: n.filterKey,
|
|
2684
2779
|
queries: [
|
|
2685
2780
|
{
|
|
2686
|
-
queryKey:
|
|
2781
|
+
queryKey: n.text,
|
|
2687
2782
|
attribute: r,
|
|
2688
2783
|
value: `/${t}/`,
|
|
2689
2784
|
operator: "find",
|
|
@@ -2693,10 +2788,10 @@ const je = (o, e) => {
|
|
|
2693
2788
|
}
|
|
2694
2789
|
]
|
|
2695
2790
|
} : i === "containsIgnoreCaseAndWhitespace" ? s = {
|
|
2696
|
-
groupKey:
|
|
2791
|
+
groupKey: n.filterKey,
|
|
2697
2792
|
queries: [
|
|
2698
2793
|
{
|
|
2699
|
-
queryKey:
|
|
2794
|
+
queryKey: n.text,
|
|
2700
2795
|
attribute: r,
|
|
2701
2796
|
value: `/${t}/`,
|
|
2702
2797
|
operator: "find",
|
|
@@ -2706,32 +2801,32 @@ const je = (o, e) => {
|
|
|
2706
2801
|
}
|
|
2707
2802
|
]
|
|
2708
2803
|
} : i === "contains" ? s = {
|
|
2709
|
-
groupKey:
|
|
2804
|
+
groupKey: n.filterKey,
|
|
2710
2805
|
queries: [
|
|
2711
2806
|
{
|
|
2712
|
-
queryKey:
|
|
2807
|
+
queryKey: n.text,
|
|
2713
2808
|
attribute: r,
|
|
2714
2809
|
value: `/${t}/`,
|
|
2715
2810
|
operator: "find"
|
|
2716
2811
|
}
|
|
2717
2812
|
]
|
|
2718
2813
|
} : i === "equal" ? s = {
|
|
2719
|
-
groupKey:
|
|
2814
|
+
groupKey: n.filterKey,
|
|
2720
2815
|
queries: [
|
|
2721
2816
|
{
|
|
2722
|
-
queryKey:
|
|
2817
|
+
queryKey: n.text,
|
|
2723
2818
|
attribute: r,
|
|
2724
|
-
value:
|
|
2819
|
+
value: n.text,
|
|
2725
2820
|
operator: "eq"
|
|
2726
2821
|
}
|
|
2727
2822
|
]
|
|
2728
2823
|
} : i === "equalIgnoreCase" && (s = {
|
|
2729
|
-
groupKey:
|
|
2824
|
+
groupKey: n.filterKey,
|
|
2730
2825
|
queries: [
|
|
2731
2826
|
{
|
|
2732
|
-
queryKey:
|
|
2827
|
+
queryKey: n.text,
|
|
2733
2828
|
attribute: r,
|
|
2734
|
-
value:
|
|
2829
|
+
value: n.text,
|
|
2735
2830
|
operator: "eq",
|
|
2736
2831
|
options: {
|
|
2737
2832
|
transform: ["lowercase"]
|
|
@@ -2739,40 +2834,40 @@ const je = (o, e) => {
|
|
|
2739
2834
|
}
|
|
2740
2835
|
]
|
|
2741
2836
|
}), s;
|
|
2742
|
-
},
|
|
2743
|
-
const t = e?.attributeKey ||
|
|
2837
|
+
}, tt = (n, e) => {
|
|
2838
|
+
const t = e?.attributeKey || n.filterKey;
|
|
2744
2839
|
return {
|
|
2745
|
-
groupKey:
|
|
2840
|
+
groupKey: n.filterKey,
|
|
2746
2841
|
queries: [
|
|
2747
2842
|
{
|
|
2748
|
-
queryKey:
|
|
2843
|
+
queryKey: n.value,
|
|
2749
2844
|
attribute: t,
|
|
2750
|
-
value:
|
|
2845
|
+
value: n.value,
|
|
2751
2846
|
operator: "eq"
|
|
2752
2847
|
}
|
|
2753
2848
|
]
|
|
2754
2849
|
};
|
|
2755
|
-
},
|
|
2756
|
-
const t = e?.attributeKey ||
|
|
2757
|
-
groupKey:
|
|
2850
|
+
}, rt = (n, e) => {
|
|
2851
|
+
const t = e?.attributeKey || n.filterKey, r = {
|
|
2852
|
+
groupKey: n.filterKey,
|
|
2758
2853
|
queries: []
|
|
2759
2854
|
};
|
|
2760
|
-
return typeof
|
|
2855
|
+
return typeof n.eq < "u" && (r.groupType = "or", Array.isArray(n.eq) ? n.eq.forEach((s) => {
|
|
2761
2856
|
r.queries.push({ attribute: t, value: s, operator: "eq" });
|
|
2762
|
-
}) : r.queries.push({ attribute: t, value:
|
|
2857
|
+
}) : 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) => {
|
|
2763
2858
|
r.queries.push({ attribute: t, value: s, operator: "eq", options: { invert: !0 } });
|
|
2764
2859
|
}) : r.queries.push({
|
|
2765
2860
|
attribute: t,
|
|
2766
|
-
value:
|
|
2861
|
+
value: n.ne,
|
|
2767
2862
|
operator: "eq",
|
|
2768
2863
|
options: { invert: !0 }
|
|
2769
|
-
})), typeof
|
|
2770
|
-
},
|
|
2771
|
-
const t = e?.attributeKey ||
|
|
2772
|
-
groupKey:
|
|
2864
|
+
})), typeof n.gt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: n.gt, operator: "gt" })), typeof n.lt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: n.lt, operator: "lt" })), typeof n.gte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: n.gte, operator: "gte" })), typeof n.lte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: n.lte, operator: "lte" })), r;
|
|
2865
|
+
}, st = (n, e) => {
|
|
2866
|
+
const t = e?.attributeKey || n.filterKey, r = {
|
|
2867
|
+
groupKey: n.filterKey,
|
|
2773
2868
|
queries: []
|
|
2774
2869
|
};
|
|
2775
|
-
return
|
|
2870
|
+
return n.itemKeys.forEach((s) => {
|
|
2776
2871
|
r.queries.push({
|
|
2777
2872
|
queryKey: s,
|
|
2778
2873
|
attribute: t,
|
|
@@ -2780,13 +2875,16 @@ const je = (o, e) => {
|
|
|
2780
2875
|
operator: "eq"
|
|
2781
2876
|
});
|
|
2782
2877
|
}), r;
|
|
2783
|
-
},
|
|
2784
|
-
class
|
|
2878
|
+
}, nt = (n) => !(typeof n.modelKey != "string" || !Array.isArray(n.queries));
|
|
2879
|
+
class it {
|
|
2785
2880
|
constructor(e, t, r) {
|
|
2786
2881
|
this.scriptController = e, this.globalItemService = t, this.modelParser = r;
|
|
2787
2882
|
}
|
|
2883
|
+
scriptController;
|
|
2884
|
+
globalItemService;
|
|
2885
|
+
modelParser;
|
|
2788
2886
|
registeredCustomOperator = /* @__PURE__ */ new Map();
|
|
2789
|
-
queryBuilder = new
|
|
2887
|
+
queryBuilder = new B();
|
|
2790
2888
|
registerCustomOperator(e, t) {
|
|
2791
2889
|
this.registeredCustomOperator.set(e, t);
|
|
2792
2890
|
}
|
|
@@ -2802,69 +2900,69 @@ class Le {
|
|
|
2802
2900
|
evaluateQuery(e, t) {
|
|
2803
2901
|
let r, s = e.value;
|
|
2804
2902
|
const i = e.options?.arrayValueHandling || "some";
|
|
2805
|
-
if (Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (s = this.transformValue(s, e.options.transform)), e.attribute.includes(".") || e.attribute.includes("[") ? r =
|
|
2903
|
+
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 = I(t, e.attribute) : r = t[e.attribute], Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (r = this.transformValue(r, e.options.transform)), (typeof r > "u" || r === null) && !["typeof", "isTruthy", "eq"].includes(e.operator))
|
|
2806
2904
|
return !1;
|
|
2807
2905
|
switch (e.operator) {
|
|
2808
2906
|
case "eq":
|
|
2809
|
-
return e.options?.invert ?
|
|
2907
|
+
return e.options?.invert ? !$(r, s) : $(r, s);
|
|
2810
2908
|
case "find":
|
|
2811
2909
|
return e.options?.invert ? !this.queryFind(r, s, i) : this.queryFind(r, s, i);
|
|
2812
2910
|
case "lt":
|
|
2813
|
-
return Array.isArray(r) ? i === "some" ? r.some((
|
|
2911
|
+
return Array.isArray(r) ? i === "some" ? r.some((o) => o < s) : r.every((o) => o < s) : r < s;
|
|
2814
2912
|
case "gt":
|
|
2815
|
-
return Array.isArray(r) ? i === "some" ? r.some((
|
|
2913
|
+
return Array.isArray(r) ? i === "some" ? r.some((o) => o > s) : r.every((o) => o > s) : r > s;
|
|
2816
2914
|
case "lte":
|
|
2817
|
-
return Array.isArray(r) ? i === "some" ? r.some((
|
|
2915
|
+
return Array.isArray(r) ? i === "some" ? r.some((o) => o <= s) : r.every((o) => o <= s) : r <= s;
|
|
2818
2916
|
case "gte":
|
|
2819
|
-
return Array.isArray(r) ? i === "some" ? r.some((
|
|
2917
|
+
return Array.isArray(r) ? i === "some" ? r.some((o) => o >= s) : r.every((o) => o >= s) : r >= s;
|
|
2820
2918
|
case "typeof":
|
|
2821
|
-
return e.options?.invert ? typeof r !== s : Array.isArray(r) ? i === "some" ? r.some((
|
|
2919
|
+
return e.options?.invert ? typeof r !== s : Array.isArray(r) ? i === "some" ? r.some((o) => typeof o === s) : r.every((o) => typeof o === s) : typeof r === s;
|
|
2822
2920
|
case "isTruthy":
|
|
2823
|
-
return s === !0 ? Array.isArray(r) ? i === "some" ? r.some((
|
|
2921
|
+
return s === !0 ? Array.isArray(r) ? i === "some" ? r.some((o) => typeof !!o) : r.every((o) => typeof !!o) : !!r : !r;
|
|
2824
2922
|
case "size":
|
|
2825
|
-
return typeof r == "string" ? r.length === s :
|
|
2923
|
+
return typeof r == "string" ? r.length === s : W(r) === s;
|
|
2826
2924
|
default:
|
|
2827
2925
|
if (this.scriptController.hasScript(e.operator))
|
|
2828
2926
|
return this.scriptController.executeScript(e.operator, "operator", { query: e, item: t });
|
|
2829
2927
|
if (this.registeredCustomOperator.has(e.operator)) {
|
|
2830
|
-
const
|
|
2831
|
-
if (typeof
|
|
2832
|
-
return
|
|
2928
|
+
const o = this.registeredCustomOperator.get(e.operator);
|
|
2929
|
+
if (typeof o == "function")
|
|
2930
|
+
return o(e, t);
|
|
2833
2931
|
}
|
|
2834
2932
|
}
|
|
2835
2933
|
return !1;
|
|
2836
2934
|
}
|
|
2837
2935
|
evaluateEqOperator(e, t, r, s) {
|
|
2838
|
-
const i = /* @__PURE__ */ new Map(),
|
|
2839
|
-
if (
|
|
2936
|
+
const i = /* @__PURE__ */ new Map(), o = s.get(t.attribute);
|
|
2937
|
+
if (o) {
|
|
2840
2938
|
let a;
|
|
2841
2939
|
if (typeof t.value == "string" ? a = t.value : t.value?.key && Object.keys(t.value).length === 1 && (a = t.value.key), typeof a < "u") {
|
|
2842
|
-
const
|
|
2843
|
-
if (
|
|
2844
|
-
if (
|
|
2845
|
-
r.has(
|
|
2940
|
+
const c = o.get(a);
|
|
2941
|
+
if (c)
|
|
2942
|
+
if (c.forEach((u) => {
|
|
2943
|
+
r.has(u) && i.set(u, r.get(u));
|
|
2846
2944
|
}), t.options?.invert) {
|
|
2847
|
-
const
|
|
2848
|
-
return
|
|
2849
|
-
|
|
2850
|
-
}),
|
|
2945
|
+
const u = O(Array.from(r.values()), Array.from(i.values()), "key"), f = /* @__PURE__ */ new Map();
|
|
2946
|
+
return u.forEach((l) => {
|
|
2947
|
+
f.set(l.key, l);
|
|
2948
|
+
}), f;
|
|
2851
2949
|
} else
|
|
2852
2950
|
return i;
|
|
2853
2951
|
}
|
|
2854
2952
|
}
|
|
2855
|
-
for (let [a,
|
|
2856
|
-
const
|
|
2857
|
-
if (
|
|
2858
|
-
const
|
|
2859
|
-
|
|
2953
|
+
for (let [a, c] of r) {
|
|
2954
|
+
const u = this.queryBuilder.extractQueryAttributes({ queries: [t] });
|
|
2955
|
+
if (u.some((f) => f.isDeepQuery)) {
|
|
2956
|
+
const f = this.queryBuilder.getProjectionForAttributeEntries(
|
|
2957
|
+
u.filter((l) => l.isDeepQuery)
|
|
2860
2958
|
);
|
|
2861
|
-
|
|
2862
|
-
|
|
2959
|
+
c = this.globalItemService.getProjectedData(
|
|
2960
|
+
f,
|
|
2863
2961
|
this.modelParser.models.get(e.modelKey),
|
|
2864
|
-
|
|
2962
|
+
c
|
|
2865
2963
|
);
|
|
2866
2964
|
}
|
|
2867
|
-
this.evaluateQuery(t,
|
|
2965
|
+
this.evaluateQuery(t, c) && i.set(a, c);
|
|
2868
2966
|
}
|
|
2869
2967
|
return i;
|
|
2870
2968
|
}
|
|
@@ -2875,10 +2973,10 @@ class Le {
|
|
|
2875
2973
|
} catch {
|
|
2876
2974
|
return !1;
|
|
2877
2975
|
}
|
|
2878
|
-
else return Array.isArray(e) ? !!e.find((r) =>
|
|
2976
|
+
else return Array.isArray(e) ? !!e.find((r) => S(r, t, this.equalRegexFn)) : typeof t == "object" ? V(e, t) : e === t;
|
|
2879
2977
|
}
|
|
2880
2978
|
queryFind(e, t, r) {
|
|
2881
|
-
return Array.isArray(e) ? typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? r === "some" ? e.some((s) =>
|
|
2979
|
+
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)) : !!J(e, t) : S(e, t, this.equalRegexFn);
|
|
2882
2980
|
}
|
|
2883
2981
|
validateQuery(e) {
|
|
2884
2982
|
if (this.queryBuilder.isQuery(e)) {
|
|
@@ -2889,56 +2987,56 @@ class Le {
|
|
|
2889
2987
|
return !0;
|
|
2890
2988
|
} else {
|
|
2891
2989
|
if (this.queryBuilder.isQueryGroup(e))
|
|
2892
|
-
return
|
|
2990
|
+
return z(e.queries, (t) => this.validateQuery(t));
|
|
2893
2991
|
throw new Error("invalid query - missing query or attribute");
|
|
2894
2992
|
}
|
|
2895
2993
|
}
|
|
2896
2994
|
getEvaluatedQueryDataset(e, t, r, s) {
|
|
2897
2995
|
const i = /* @__PURE__ */ new Map();
|
|
2898
2996
|
if (t.attribute.includes("[*]")) {
|
|
2899
|
-
const
|
|
2900
|
-
for (let
|
|
2901
|
-
const
|
|
2902
|
-
if (
|
|
2903
|
-
const
|
|
2904
|
-
|
|
2997
|
+
const o = t.options?.invert === !0, a = /* @__PURE__ */ new Set();
|
|
2998
|
+
for (let c of r.values()) {
|
|
2999
|
+
const u = this.queryBuilder.extractQueryAttributes({ queries: [t] });
|
|
3000
|
+
if (u.some((d) => d.isDeepQuery)) {
|
|
3001
|
+
const d = this.queryBuilder.getProjectionForAttributeEntries(
|
|
3002
|
+
u.filter((h) => h.isDeepQuery)
|
|
2905
3003
|
);
|
|
2906
|
-
|
|
2907
|
-
|
|
3004
|
+
c = this.globalItemService.getProjectedData(
|
|
3005
|
+
d,
|
|
2908
3006
|
this.modelParser.models.get(e.modelKey),
|
|
2909
|
-
|
|
3007
|
+
c
|
|
2910
3008
|
);
|
|
2911
3009
|
}
|
|
2912
|
-
const
|
|
2913
|
-
let
|
|
2914
|
-
for (const
|
|
2915
|
-
const h = { ...
|
|
2916
|
-
if (this.evaluateQuery(h,
|
|
2917
|
-
|
|
3010
|
+
const f = this.handleArrayStarQuery(t, c);
|
|
3011
|
+
let l = !1;
|
|
3012
|
+
for (const d of f.queries) {
|
|
3013
|
+
const h = { ...d, options: { ...d.options, invert: !1 } };
|
|
3014
|
+
if (this.evaluateQuery(h, c)) {
|
|
3015
|
+
l = !0;
|
|
2918
3016
|
break;
|
|
2919
3017
|
}
|
|
2920
3018
|
}
|
|
2921
|
-
|
|
3019
|
+
l && (a.add(c.key), o || i.set(c.key, c));
|
|
2922
3020
|
}
|
|
2923
|
-
if (
|
|
2924
|
-
for (const [
|
|
2925
|
-
a.has(
|
|
3021
|
+
if (o)
|
|
3022
|
+
for (const [c, u] of r)
|
|
3023
|
+
a.has(c) || i.set(c, u);
|
|
2926
3024
|
} else {
|
|
2927
3025
|
if (t.operator === "eq")
|
|
2928
3026
|
return this.evaluateEqOperator(e, t, r, s);
|
|
2929
|
-
for (let [
|
|
2930
|
-
const
|
|
2931
|
-
if (
|
|
2932
|
-
const
|
|
2933
|
-
|
|
3027
|
+
for (let [o, a] of r) {
|
|
3028
|
+
const c = this.queryBuilder.extractQueryAttributes({ queries: [t] });
|
|
3029
|
+
if (c.some((u) => u.isDeepQuery)) {
|
|
3030
|
+
const u = this.queryBuilder.getProjectionForAttributeEntries(
|
|
3031
|
+
c.filter((f) => f.isDeepQuery)
|
|
2934
3032
|
);
|
|
2935
3033
|
a = this.globalItemService.getProjectedData(
|
|
2936
|
-
|
|
3034
|
+
u,
|
|
2937
3035
|
this.modelParser.models.get(e.modelKey),
|
|
2938
3036
|
a
|
|
2939
3037
|
);
|
|
2940
3038
|
}
|
|
2941
|
-
this.evaluateQuery(t, a) && i.set(
|
|
3039
|
+
this.evaluateQuery(t, a) && i.set(o, a);
|
|
2942
3040
|
}
|
|
2943
3041
|
}
|
|
2944
3042
|
return i;
|
|
@@ -2950,12 +3048,12 @@ class Le {
|
|
|
2950
3048
|
queries: []
|
|
2951
3049
|
};
|
|
2952
3050
|
if (r !== -1) {
|
|
2953
|
-
const i = e.attribute.substring(0, r),
|
|
2954
|
-
if (Array.isArray(
|
|
2955
|
-
for (let a = 0; a <
|
|
2956
|
-
const
|
|
3051
|
+
const i = e.attribute.substring(0, r), o = i.includes(".") ? I(t, i) : t[i];
|
|
3052
|
+
if (Array.isArray(o))
|
|
3053
|
+
for (let a = 0; a < o.length; a++) {
|
|
3054
|
+
const c = e.attribute.replace("[*]", `[${a}]`);
|
|
2957
3055
|
s.queries.push({
|
|
2958
|
-
attribute:
|
|
3056
|
+
attribute: c,
|
|
2959
3057
|
operator: e.operator,
|
|
2960
3058
|
value: e.value,
|
|
2961
3059
|
options: e.options
|
|
@@ -2965,27 +3063,29 @@ class Le {
|
|
|
2965
3063
|
return s;
|
|
2966
3064
|
}
|
|
2967
3065
|
evaluateQueryGroup(e, t, r, s, i) {
|
|
2968
|
-
let
|
|
3066
|
+
let o = /* @__PURE__ */ new Map(), a = r;
|
|
2969
3067
|
if (!t.queries || t.queries?.length === 0)
|
|
2970
3068
|
return a;
|
|
2971
|
-
for (const
|
|
2972
|
-
let
|
|
2973
|
-
if (this.queryBuilder.isQuery(
|
|
2974
|
-
|
|
2975
|
-
|
|
3069
|
+
for (const c of t.queries) {
|
|
3070
|
+
let u = /* @__PURE__ */ new Map();
|
|
3071
|
+
if (this.queryBuilder.isQuery(c) ? u = this.getEvaluatedQueryDataset(e, c, a, i) : u = this.evaluateQueryGroup(e, c, a, s, i), o.size === 0 && (o = u), t.groupType === "or")
|
|
3072
|
+
u.forEach((f) => {
|
|
3073
|
+
o.set(f.key, f);
|
|
2976
3074
|
});
|
|
2977
3075
|
else {
|
|
2978
|
-
const
|
|
2979
|
-
for (const
|
|
2980
|
-
|
|
3076
|
+
const f = O(Array.from(o.values()), Array.from(u.values()), "key");
|
|
3077
|
+
for (const l of f)
|
|
3078
|
+
o.delete(l.key);
|
|
2981
3079
|
}
|
|
2982
|
-
t.groupType === "and" ? a =
|
|
3080
|
+
t.groupType === "and" ? a = o : a = r;
|
|
2983
3081
|
}
|
|
2984
|
-
return
|
|
3082
|
+
return o;
|
|
2985
3083
|
}
|
|
2986
3084
|
queryData(e, t, r, s) {
|
|
3085
|
+
if (t.queries.length === 0)
|
|
3086
|
+
return e;
|
|
2987
3087
|
const i = new Map(e);
|
|
2988
|
-
return t.
|
|
3088
|
+
return t.groupKey || (t.groupKey = "root"), t.groupType || (t.groupType = "and"), t.queries || (t.queries = []), this.validateQuery(t), this.evaluateQueryGroup(t, t, i, r, s);
|
|
2989
3089
|
}
|
|
2990
3090
|
// public getRelevantQueryData(data: any, options: DcuplGlobalQueryOptions<any>, model: DcuplModel<ListItem>) {
|
|
2991
3091
|
// // detect if any of the query attributes are a deep query.
|
|
@@ -3021,7 +3121,38 @@ class Le {
|
|
|
3021
3121
|
// }
|
|
3022
3122
|
// }
|
|
3023
3123
|
}
|
|
3024
|
-
|
|
3124
|
+
const Oe = "k:", qe = "h:";
|
|
3125
|
+
function Q(n, e = 0) {
|
|
3126
|
+
if (n.key)
|
|
3127
|
+
return `${Oe}${n.key}`;
|
|
3128
|
+
const t = K({
|
|
3129
|
+
type: n.type,
|
|
3130
|
+
url: n.rawUrl ?? n.url,
|
|
3131
|
+
model: n.model ?? "",
|
|
3132
|
+
occurrence: e
|
|
3133
|
+
});
|
|
3134
|
+
return `${qe}${t}`;
|
|
3135
|
+
}
|
|
3136
|
+
function ot(n) {
|
|
3137
|
+
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
|
|
3138
|
+
return n.map((r) => {
|
|
3139
|
+
const s = `${r.key ?? ""}|${r.type}|${r.rawUrl ?? r.url}|${r.model ?? ""}`;
|
|
3140
|
+
let i = e.get(s) ?? 0, o = Q(r, i);
|
|
3141
|
+
for (; t.has(o); )
|
|
3142
|
+
i += 1, o = r.key ? `${Q(r)}#${i}` : Q(r, i);
|
|
3143
|
+
return e.set(s, i + 1), t.add(o), o;
|
|
3144
|
+
});
|
|
3145
|
+
}
|
|
3146
|
+
function at() {
|
|
3147
|
+
const n = globalThis;
|
|
3148
|
+
return typeof n.scheduler?.yield == "function" ? n.scheduler.yield() : typeof n.setImmediate == "function" ? new Promise((e) => n.setImmediate(() => e())) : typeof n.MessageChannel == "function" ? new Promise((e) => {
|
|
3149
|
+
const t = new n.MessageChannel();
|
|
3150
|
+
t.port1.onmessage = () => {
|
|
3151
|
+
t.port1.close(), e();
|
|
3152
|
+
}, t.port2.postMessage(null);
|
|
3153
|
+
}) : new Promise((e) => setTimeout(e, 0));
|
|
3154
|
+
}
|
|
3155
|
+
class ct {
|
|
3025
3156
|
scripts = /* @__PURE__ */ new Map();
|
|
3026
3157
|
scriptFunctions = /* @__PURE__ */ new Map();
|
|
3027
3158
|
constructor() {
|
|
@@ -3060,14 +3191,14 @@ class He {
|
|
|
3060
3191
|
if (!this.getScript(e))
|
|
3061
3192
|
throw new Error(`Script ${e} not found`);
|
|
3062
3193
|
r.context || (r.context = r.options || {});
|
|
3063
|
-
const i = Object.keys(r),
|
|
3064
|
-
return this.getScriptAsFn(e, i)(t, ...
|
|
3194
|
+
const i = Object.keys(r), o = Object.values(r);
|
|
3195
|
+
return this.getScriptAsFn(e, i)(t, ...o);
|
|
3065
3196
|
}
|
|
3066
3197
|
}
|
|
3067
|
-
const
|
|
3198
|
+
const ut = (n, e) => n ? (e || (e = {}), n.replace(/\$\{(.*?)\}/g, (t, r) => I(e, r.trim(), ""))) : "", ft = (n) => {
|
|
3068
3199
|
const e = /* @__PURE__ */ new Set();
|
|
3069
|
-
return
|
|
3070
|
-
},
|
|
3200
|
+
return n.replace(/\$\{(.*?)\}/g, (r, s) => (e.add(s.trim()), "")), { variables: Array.from(e).map((r) => ({ name: r })) };
|
|
3201
|
+
}, lt = [
|
|
3071
3202
|
"any",
|
|
3072
3203
|
"Array<date>",
|
|
3073
3204
|
"Array<float>",
|
|
@@ -3079,7 +3210,7 @@ const Ue = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => y(e
|
|
|
3079
3210
|
"int",
|
|
3080
3211
|
"json",
|
|
3081
3212
|
"string"
|
|
3082
|
-
],
|
|
3213
|
+
], dt = ["int", "float", "Array<int>", "Array<float>"], ht = ["date", "Array<date>"], pt = [
|
|
3083
3214
|
"eq",
|
|
3084
3215
|
"find",
|
|
3085
3216
|
"gt",
|
|
@@ -3091,57 +3222,65 @@ const Ue = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => y(e
|
|
|
3091
3222
|
"size"
|
|
3092
3223
|
];
|
|
3093
3224
|
export {
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3225
|
+
Oe as AUTHORED_RESOURCE_ID_PREFIX,
|
|
3226
|
+
Te as AnalyticsController,
|
|
3227
|
+
Re as AttributeDependencyGraph,
|
|
3228
|
+
Ge as CacheController,
|
|
3229
|
+
Ue as ChangeDetector,
|
|
3230
|
+
qe as DERIVED_RESOURCE_ID_PREFIX,
|
|
3231
|
+
ht as DatePropertyTypes,
|
|
3232
|
+
B as DcuplQueryBuilder,
|
|
3233
|
+
pt as DcuplQueryOperatorsAsArray,
|
|
3234
|
+
le as DeepQueryService,
|
|
3235
|
+
X as DependencyGraph,
|
|
3236
|
+
xe as IndicesController,
|
|
3104
3237
|
p as Logger,
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3238
|
+
dt as NumberPropertyTypes,
|
|
3239
|
+
lt as PropertyTypesAsArray,
|
|
3240
|
+
it as QueryManager,
|
|
3241
|
+
ct as ScriptController,
|
|
3109
3242
|
P as clone,
|
|
3243
|
+
Ke as coerceStringType,
|
|
3110
3244
|
re as compareVersions,
|
|
3111
|
-
|
|
3112
|
-
|
|
3245
|
+
Je as computeSuggestions,
|
|
3246
|
+
y as deepQueryService,
|
|
3113
3247
|
te as escapeRegExp,
|
|
3114
|
-
|
|
3115
|
-
|
|
3248
|
+
ut as evaluateTemplate,
|
|
3249
|
+
tt as generateBooleanQuery,
|
|
3116
3250
|
ee as generateKey,
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3251
|
+
rt as generateNumberAndDateQuery,
|
|
3252
|
+
st as generateReferenceQuery,
|
|
3253
|
+
et as generateTextQuery,
|
|
3254
|
+
C as getAggregation,
|
|
3255
|
+
Pe as getDateConstraintUid,
|
|
3256
|
+
$e as getDcuplPropertyTypeForNativeType,
|
|
3257
|
+
x as getDeepPathValues,
|
|
3258
|
+
me as getDistinct,
|
|
3259
|
+
Xe as getFacets,
|
|
3260
|
+
ze as getFilterEntryId,
|
|
3261
|
+
_e as getNumberConstraintUid,
|
|
3262
|
+
Ye as getPropertiesForData,
|
|
3263
|
+
je as groupBy,
|
|
3264
|
+
He as hasMinimumVersion,
|
|
3265
|
+
Ne as inferModel,
|
|
3131
3266
|
se as isDateInstance,
|
|
3132
|
-
|
|
3133
|
-
|
|
3267
|
+
Ee as isFloat,
|
|
3268
|
+
Ce as isInt,
|
|
3134
3269
|
ne as isValidDate,
|
|
3135
|
-
|
|
3270
|
+
nt as isValidQueryStatement,
|
|
3136
3271
|
F as isValidVersion,
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3272
|
+
Y as logger,
|
|
3273
|
+
Me as looksDateLike,
|
|
3274
|
+
Ze as parseDate,
|
|
3275
|
+
ft as parseTemplate,
|
|
3276
|
+
b as perf,
|
|
3277
|
+
j as pivot,
|
|
3278
|
+
Le as removeTrailingSlash,
|
|
3279
|
+
Q as resolveResourceId,
|
|
3280
|
+
ot as resolveResourceIds,
|
|
3281
|
+
Ve as trigger,
|
|
3282
|
+
We as unescapeRegExp,
|
|
3283
|
+
Be as uniqBy,
|
|
3284
|
+
at as yieldToEventLoop
|
|
3146
3285
|
};
|
|
3147
3286
|
//# sourceMappingURL=index.js.map
|