@dcupl/common 2.0.0-beta.3 → 2.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,18 +1,18 @@
1
- import { cloneDeep as y, get as D, every as B, findIndex as E, size as L, isEqual as O, differenceBy as q, startsWith as H, endsWith as U, isEqualWith as b, isMatch as V, find as J } from "lodash-es";
1
+ import { cloneDeep as m, get as D, every as j, findIndex as E, size as L, isEqual as q, differenceBy as O, startsWith as H, endsWith as V, isEqualWith as b, isMatch as U, find as J } from "lodash-es";
2
2
  function Q(o) {
3
- const e = S(o);
3
+ const e = K(o);
4
4
  return Z(e);
5
5
  }
6
- function S(o) {
6
+ function K(o) {
7
7
  if (typeof o != "object" || o === null)
8
8
  return String(o);
9
9
  if (Array.isArray(o))
10
- return "[" + o.map(S).join(",") + "]";
10
+ return "[" + o.map(K).join(",") + "]";
11
11
  const e = Object.keys(o).sort();
12
12
  let t = "{";
13
13
  for (let r = 0; r < e.length; r++) {
14
14
  const s = e[r];
15
- t += s + ":" + S(o[s]), r < e.length - 1 && (t += ",");
15
+ t += s + ":" + K(o[s]), r < e.length - 1 && (t += ",");
16
16
  }
17
17
  return t += "}", t;
18
18
  }
@@ -24,7 +24,7 @@ function Z(o) {
24
24
  }
25
25
  return e.toString(16);
26
26
  }
27
- const x = {
27
+ const A = {
28
28
  now: () => typeof performance < "u" && performance.now ? performance.now() : (/* @__PURE__ */ new Date()).getTime(),
29
29
  mark: (o) => {
30
30
  typeof performance < "u" && performance.mark && performance.mark(o);
@@ -41,7 +41,7 @@ const x = {
41
41
  return performance.getEntriesByType(o);
42
42
  }
43
43
  };
44
- class Se {
44
+ class Ie {
45
45
  data;
46
46
  enabled = !1;
47
47
  constructor() {
@@ -59,7 +59,7 @@ class Se {
59
59
  const t = this.getKey(e.name, e.context), r = {
60
60
  name: e.name,
61
61
  type: "mark",
62
- value: x.now(),
62
+ value: A.now(),
63
63
  createdAt: Date.now()
64
64
  };
65
65
  return this.data.set(t, r), r;
@@ -96,7 +96,7 @@ class Se {
96
96
  return this.data.get(t);
97
97
  }
98
98
  getResourceInfosFromPerformanceAPI() {
99
- return typeof performance > "u" ? [] : x.getEntriesByType("resource");
99
+ return typeof performance > "u" ? [] : A.getEntriesByType("resource");
100
100
  }
101
101
  get(e) {
102
102
  const t = this.getKey(e.name, e.context);
@@ -118,7 +118,7 @@ class Se {
118
118
  return e + "_" + r;
119
119
  }
120
120
  }
121
- let Y = class T {
121
+ let Y = class B {
122
122
  nodes;
123
123
  edges;
124
124
  nodeKinds = /* @__PURE__ */ new Map();
@@ -365,17 +365,17 @@ let Y = class T {
365
365
  const s = new Set(e), i = (c) => !r || r.length === 0 || r.includes(this.nodeKinds.get(c) ?? void 0), n = () => {
366
366
  const c = /* @__PURE__ */ new Set(), f = Array.from(s);
367
367
  for (; f.length; ) {
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));
368
+ const l = f.shift();
369
+ for (const [d, h] of this.edges)
370
+ h.has(l) && !c.has(d) && (c.add(d), f.push(d));
371
371
  }
372
372
  return c;
373
373
  }, a = () => {
374
374
  const c = /* @__PURE__ */ new Set(), f = Array.from(s);
375
375
  for (; f.length; ) {
376
- const d = f.shift(), l = this.edges.get(d);
377
- if (l)
378
- for (const h of l)
376
+ const l = f.shift(), d = this.edges.get(l);
377
+ if (d)
378
+ for (const h of d)
379
379
  c.has(h) || (c.add(h), f.push(h));
380
380
  }
381
381
  return c;
@@ -392,7 +392,7 @@ let Y = class T {
392
392
  return { nodes: e, edges: t };
393
393
  }
394
394
  static fromJSON(e) {
395
- const t = new T();
395
+ const t = new B();
396
396
  for (const r of e.nodes)
397
397
  t.addNode(r.name, { kind: r.kind, meta: r.meta });
398
398
  for (const r of e.edges)
@@ -400,15 +400,15 @@ let Y = class T {
400
400
  return t;
401
401
  }
402
402
  diff(e) {
403
- const t = new Set(this.getNodes()), r = new Set(e.getNodes()), s = Array.from(r).filter((d) => !t.has(d)), i = Array.from(t).filter((d) => !r.has(d)), n = new Set(this.getAllEdges().map((d) => d.join("→"))), a = new Set(e.getAllEdges().map((d) => d.join("→"))), u = Array.from(a).filter((d) => !n.has(d)).map((d) => d.split("→")), c = Array.from(n).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 });
403
+ const t = new Set(this.getNodes()), r = new Set(e.getNodes()), s = Array.from(r).filter((l) => !t.has(l)), i = Array.from(t).filter((l) => !r.has(l)), n = new Set(this.getAllEdges().map((l) => l.join("→"))), a = new Set(e.getAllEdges().map((l) => l.join("→"))), u = Array.from(a).filter((l) => !n.has(l)).map((l) => l.split("→")), c = Array.from(n).filter((l) => !a.has(l)).map((l) => l.split("→")), f = [];
404
+ for (const l of /* @__PURE__ */ new Set([...t, ...r])) {
405
+ const d = this.nodeKinds.get(l), h = e.nodeKinds.get(l);
406
+ d !== h && f.push({ name: l, from: d, to: h });
407
407
  }
408
408
  return { addedNodes: s, removedNodes: i, addedEdges: u, removedEdges: c, kindChanges: f };
409
409
  }
410
410
  };
411
- class Ie {
411
+ class Qe {
412
412
  graph;
413
413
  nodeIndex;
414
414
  constructor() {
@@ -800,7 +800,7 @@ class p {
800
800
  }
801
801
  }
802
802
  const X = new p();
803
- class Qe {
803
+ class Me {
804
804
  constructor(e) {
805
805
  this.enabled = e, this.cache = /* @__PURE__ */ new Map(), this.cacheDependencies = /* @__PURE__ */ new Map();
806
806
  }
@@ -915,7 +915,7 @@ class Qe {
915
915
  }
916
916
  generateContext(e) {
917
917
  try {
918
- return y(e);
918
+ return m(e);
919
919
  } catch (t) {
920
920
  return this.log.error("Error in cache generateContext", t), e;
921
921
  }
@@ -939,7 +939,7 @@ class Qe {
939
939
  };
940
940
  }
941
941
  }
942
- const Me = (o, e = "") => `${o}#${e}`, Ne = (o) => `${o.gt}_${o.gte}_${o.lt}_${o.lte}_${o.eq}_${o.ne}`, ke = (o) => `${o.gt}_${o.gte}_${o.lt}_${o.lte}_${o.eq}_${o.ne}`, Ce = (o, e) => {
942
+ const Ne = (o, e = "") => `${o}#${e}`, ke = (o) => `${o.gt}_${o.gte}_${o.lt}_${o.lte}_${o.eq}_${o.ne}`, Ce = (o) => `${o.gt}_${o.gte}_${o.lt}_${o.lte}_${o.eq}_${o.ne}`, Ee = (o, e) => {
943
943
  const t = typeof e == "function" ? e : (r) => r[e];
944
944
  return [
945
945
  ...o.reduce((r, s) => {
@@ -947,7 +947,7 @@ const Me = (o, e = "") => `${o}#${e}`, Ne = (o) => `${o.gt}_${o.gte}_${o.lt}_${o
947
947
  return r.has(i) || r.set(i, s), r;
948
948
  }, /* @__PURE__ */ new Map()).values()
949
949
  ];
950
- }, Ee = (o, e) => o.reduce(function(t, r) {
950
+ }, qe = (o, e) => o.reduce(function(t, r) {
951
951
  const s = typeof e == "function" ? e(r) : r[e];
952
952
  return Object.prototype.hasOwnProperty.call(t, s) || (t[s] = []), t[s].push(r), t;
953
953
  }, {});
@@ -957,7 +957,7 @@ function ee(o = 10) {
957
957
  for (let r = 0; r < o; r++) e += t.charAt(Math.floor(Math.random() * t.length));
958
958
  return e;
959
959
  }
960
- const Oe = (o) => o.replace(/\/+$/, ""), te = (o) => typeof o != "string" ? "" : o.replace(/[[\]{}()*+?.,\\^$|#]/g, "\\$&"), qe = (o) => typeof o != "string" ? "" : o.replace(/\\([[\]{}()*+?.,\\^$|#])/g, "$1"), $e = (o, e) => {
960
+ const Oe = (o) => o.replace(/\/+$/, ""), te = (o) => typeof o != "string" ? "" : o.replace(/[[\]{}()*+?.,\\^$|#]/g, "\\$&"), $e = (o) => typeof o != "string" ? "" : o.replace(/\\([[\]{}()*+?.,\\^$|#])/g, "$1"), Fe = (o, e) => {
961
961
  try {
962
962
  return re(o, e) >= 0;
963
963
  } catch {
@@ -974,7 +974,7 @@ const Oe = (o) => o.replace(/\/+$/, ""), te = (o) => typeof o != "string" ? "" :
974
974
  }
975
975
  return 0;
976
976
  }, F = (o) => /^\d+(\.\d+){0,2}$/.test(o);
977
- class Fe {
977
+ class Ge {
978
978
  key;
979
979
  parentCd;
980
980
  dcuplInitOptions;
@@ -1000,7 +1000,7 @@ class Fe {
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 = x.now(), e.duration = e.start - e.end), this.updateListener.forEach((t) => {
1003
+ e.originCdRefKey || (e.originCdRefKey = this.key), e.key || (this.increaseCounter(), e.key = this.getCounter()), e.end || (e.end = A.now(), e.duration = e.start - e.end), this.updateListener.forEach((t) => {
1004
1004
  t(e);
1005
1005
  });
1006
1006
  }
@@ -1010,17 +1010,17 @@ class Fe {
1010
1010
  };
1011
1011
  }
1012
1012
  }
1013
- const P = (o, e) => e ? typeof structuredClone < "u" ? structuredClone(o) : y(o) : o, G = (o, e, t, r, s, i) => {
1013
+ const P = (o, e) => e ? typeof structuredClone < "u" ? structuredClone(o) : m(o) : o, G = (o, e, t, r, s, i) => {
1014
1014
  try {
1015
1015
  const n = !!e.dcuplInitOptions.performance?.clone?.enabled && !!t.cloneResult, a = P(i, n);
1016
1016
  if (t.scope === "list" && (t.listKey = o.cdRef?.key || o.key, t.modelKey = o.model?.key || o.modelKey), t.type === "list_created" && t.args[0].listKey.startsWith("__global_list__") || t.listKey?.startsWith("__global_list__"))
1017
1017
  return a;
1018
- const u = x.now(), c = u - r, f = Math.round(c * 1e3) / 1e3;
1018
+ const u = A.now(), c = u - r, f = Math.round(c * 1e3) / 1e3;
1019
1019
  t.duration = f, t.start = r, t.end = u;
1020
- const d = {
1020
+ const l = {
1021
1021
  duration: t.duration
1022
1022
  };
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({
1023
+ return t.modelKey && (l.model = t.modelKey), t.connectMessageResult && (t.result = a), t.args && (l.args = t.args), e?.trigger(t), e.analyticsController.mark({
1024
1024
  name: `${t.type}:end`,
1025
1025
  context: s
1026
1026
  }), e.analyticsController.measure({
@@ -1028,25 +1028,25 @@ const P = (o, e) => e ? typeof structuredClone < "u" ? structuredClone(o) : y(o)
1028
1028
  start: `${t.type}:start`,
1029
1029
  end: `${t.type}:end`,
1030
1030
  context: s,
1031
- detail: d
1031
+ detail: l
1032
1032
  }), a;
1033
1033
  } catch {
1034
1034
  return i;
1035
1035
  }
1036
- }, Ge = (o) => (t, r, s) => {
1036
+ }, Te = (o) => (t, r, s) => {
1037
1037
  const i = s.value;
1038
1038
  return s.value = function(...n) {
1039
- const a = x.now(), u = this.cdRef, c = P(o, !0);
1039
+ const a = A.now(), u = this.cdRef, c = P(o, !0);
1040
1040
  c.key || (u.increaseCounter(), c.key = u.getCounter());
1041
1041
  const f = ee();
1042
1042
  u.analyticsController.mark({
1043
1043
  name: `${c.type}:start`,
1044
1044
  context: f
1045
1045
  });
1046
- const d = this.model?.key;
1047
- !c.originCdRefKey && u.key && (c.originCdRefKey = u.key), d && (c.modelKey = d);
1048
- const l = i.apply(this, n);
1049
- return c.method = r, c.args = n, l && typeof l == "object" && "then" in l ? l.then((h) => G(this, u, c, a, f, h)) : G(this, u, c, a, f, l);
1046
+ const l = this.model?.key;
1047
+ !c.originCdRefKey && u.key && (c.originCdRefKey = u.key), l && (c.modelKey = l);
1048
+ const d = i.apply(this, n);
1049
+ return c.method = r, c.args = n, d && typeof d == "object" && "then" in d ? d.then((h) => G(this, u, c, a, f, h)) : G(this, u, c, a, f, d);
1050
1050
  }, s;
1051
1051
  };
1052
1052
  function je(o, e, t, r) {
@@ -1070,13 +1070,13 @@ function je(o, e, t, r) {
1070
1070
  s.push(f);
1071
1071
  }
1072
1072
  } else if (u && typeof i == "string") {
1073
- const f = String(c ?? ""), d = i;
1074
- if (f.toLowerCase().startsWith(d.toLowerCase())) {
1075
- const l = {
1073
+ const f = String(c ?? ""), l = i;
1074
+ if (f.toLowerCase().startsWith(l.toLowerCase())) {
1075
+ const d = {
1076
1076
  value: n,
1077
1077
  keys: t.calculateResultKeys ? Array.from(a) : []
1078
1078
  };
1079
- s.push(l);
1079
+ s.push(d);
1080
1080
  }
1081
1081
  } else if (u && r.queryFind(c, i, "some")) {
1082
1082
  const f = {
@@ -1270,7 +1270,7 @@ class fe {
1270
1270
  this.graph.clear();
1271
1271
  }
1272
1272
  }
1273
- class de {
1273
+ class le {
1274
1274
  parseCache;
1275
1275
  circularRefDetector;
1276
1276
  cacheHits = 0;
@@ -1435,14 +1435,14 @@ class de {
1435
1435
  return this.getPathSegments(e).length;
1436
1436
  }
1437
1437
  }
1438
- const g = new de();
1439
- function v(o, e) {
1438
+ const g = new le();
1439
+ function w(o, e) {
1440
1440
  if (e.includes("[*]")) {
1441
1441
  const i = e.indexOf("[*]"), n = e.substring(0, i), a = e.substring(i + 3), u = n ? D(o, n) : o;
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(...v(f, a.slice(1)));
1445
+ !a || a === "" ? f !== void 0 && c.push(f) : a.startsWith(".") && c.push(...w(f, a.slice(1)));
1446
1446
  return c;
1447
1447
  }
1448
1448
  const t = e.split(".");
@@ -1470,7 +1470,7 @@ function v(o, e) {
1470
1470
  else i !== void 0 && s.push(i);
1471
1471
  return s;
1472
1472
  }
1473
- function K(o) {
1473
+ function S(o) {
1474
1474
  let e = 0;
1475
1475
  for (let t of o) {
1476
1476
  const r = t.toString().split(".")[1];
@@ -1478,10 +1478,10 @@ function K(o) {
1478
1478
  }
1479
1479
  return Math.pow(10, e);
1480
1480
  }
1481
- function j(o, e, t) {
1481
+ function T(o, e, t) {
1482
1482
  return (o * t + e * t) / t;
1483
1483
  }
1484
- function le(o, e, t) {
1484
+ function de(o, e, t) {
1485
1485
  return o * t / (e * t);
1486
1486
  }
1487
1487
  const M = (o, e, t, r) => {
@@ -1503,7 +1503,7 @@ const M = (o, e, t, r) => {
1503
1503
  for (const i of e.values())
1504
1504
  if (i)
1505
1505
  if (r)
1506
- s += v(i, o).filter((n) => n != null).length;
1506
+ s += w(i, o).filter((n) => n != null).length;
1507
1507
  else {
1508
1508
  const n = i[o];
1509
1509
  if (n == null) continue;
@@ -1517,7 +1517,7 @@ const M = (o, e, t, r) => {
1517
1517
  if (!n) continue;
1518
1518
  let a;
1519
1519
  if (i)
1520
- a = v(n, o);
1520
+ a = w(n, o);
1521
1521
  else {
1522
1522
  const u = n[o];
1523
1523
  u === void 0 ? a = [] : Array.isArray(u) ? a = u.filter((c) => c !== void 0) : a = [u];
@@ -1543,7 +1543,7 @@ const M = (o, e, t, r) => {
1543
1543
  }, i = g.parse(o.attribute).isDeepQuery;
1544
1544
  for (const n of e.values()) {
1545
1545
  let a;
1546
- i ? a = v(n, o.attribute) : a = [n[o.attribute]];
1546
+ i ? a = w(n, o.attribute) : a = [n[o.attribute]];
1547
1547
  let u = !1;
1548
1548
  for (const c of a)
1549
1549
  for (const f of t)
@@ -1558,7 +1558,7 @@ const M = (o, e, t, r) => {
1558
1558
  if (!a) continue;
1559
1559
  let u;
1560
1560
  if (i)
1561
- u = v(a, o);
1561
+ u = w(a, o);
1562
1562
  else {
1563
1563
  const c = a[o];
1564
1564
  c === void 0 ? u = [] : Array.isArray(c) ? u = c : u = [c];
@@ -1566,11 +1566,11 @@ const M = (o, e, t, r) => {
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 = j(t, f, K([t, f])), r++);
1570
- else typeof c == "number" && (t = j(t, c, K([t, c])), r++);
1569
+ typeof f == "number" && (t = T(t, f, S([t, f])), r++);
1570
+ else typeof c == "number" && (t = T(t, c, S([t, c])), r++);
1571
1571
  }
1572
1572
  return r === 0 ? void 0 : {
1573
- average: le(t, r, K([t, r])),
1573
+ average: de(t, r, S([t, r])),
1574
1574
  count: r,
1575
1575
  sum: t
1576
1576
  };
@@ -1587,14 +1587,14 @@ const M = (o, e, t, r) => {
1587
1587
  }
1588
1588
  return r;
1589
1589
  };
1590
- class w extends Error {
1590
+ class x 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 R {
1597
+ class z {
1598
1598
  _defaultQueryOptions = {
1599
1599
  modelKey: "",
1600
1600
  groupKey: "root",
@@ -1602,7 +1602,7 @@ class R {
1602
1602
  queries: []
1603
1603
  };
1604
1604
  _initOptions;
1605
- currentQuery = y(this._defaultQueryOptions);
1605
+ currentQuery = m(this._defaultQueryOptions);
1606
1606
  deepQueryService;
1607
1607
  constructor(e) {
1608
1608
  this.deepQueryService = e || g;
@@ -1631,7 +1631,7 @@ class R {
1631
1631
  * });
1632
1632
  */
1633
1633
  init(e) {
1634
- this._initOptions = y(e), this.currentQuery = y(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 = y(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));
1634
+ this._initOptions = m(e), this.currentQuery = m(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 = m(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 R {
1649
1649
  return this.currentQuery.queries.find((t) => this.isQueryGroup(t) && t.groupKey === e);
1650
1650
  }
1651
1651
  getQuery() {
1652
- return y(this.currentQuery);
1652
+ return m(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 R {
1665
1665
  }
1666
1666
  validate(e) {
1667
1667
  const t = e.queries.map((s) => this.validateQuery(s));
1668
- return { valid: B(t, (s) => s.valid), errors: t.map((s) => s.errors).flat() };
1668
+ return { valid: j(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();
@@ -1771,12 +1771,12 @@ class R {
1771
1771
  validateQuery(e) {
1772
1772
  const t = [];
1773
1773
  if (this.isQuery(e))
1774
- return e.attribute || t.push(new w("Missing attribute", e)), e.operator || t.push(new w("Missing operator", e)), typeof e.value > "u" && t.push(new w("Missing value", e)), e.operator === "find" && Array.isArray(e.value) && t.push(new w("find operator cannot have array value", e)), t.length > 0 ? { valid: !1, errors: t } : { valid: !0 };
1774
+ return e.attribute || t.push(new x("Missing attribute", e)), e.operator || t.push(new x("Missing operator", e)), typeof e.value > "u" && t.push(new x("Missing value", e)), e.operator === "find" && Array.isArray(e.value) && t.push(new x("find operator cannot have array value", e)), t.length > 0 ? { valid: !1, errors: t } : { valid: !0 };
1775
1775
  if (this.isQueryGroup(e)) {
1776
1776
  const i = e.queries.map((n) => this.validateQuery(n)).filter((n) => !n.valid).map((n) => n.errors).flat();
1777
1777
  return i.length > 0 ? { valid: !1, errors: i } : { valid: !0 };
1778
1778
  }
1779
- return t.push(new w("Invalid query definition", e)), { valid: !1, errors: t };
1779
+ return t.push(new x("Invalid query definition", e)), { valid: !1, errors: t };
1780
1780
  }
1781
1781
  /**
1782
1782
  * Get all attribute names used in the query.
@@ -2275,28 +2275,28 @@ class R {
2275
2275
  return e(this.currentQuery.queries);
2276
2276
  }
2277
2277
  }
2278
- const I = new R();
2279
- function Te(o, e, t, r, s, i, n) {
2280
- const a = [], u = I.removeQuery({ groupKey: s }, y(r)), c = n.queryData(o, u, !1, i), f = e ? [...e.keys()] : [], d = new Set(f), l = i.get(s);
2278
+ const I = new z();
2279
+ function Pe(o, e, t, r, s, i, n) {
2280
+ const a = [], u = I.removeQuery({ groupKey: s }, m(r)), c = n.queryData(o, u, !1, i), f = e ? [...e.keys()] : [], l = new Set(f), d = i.get(s);
2281
2281
  if (!t.excludeUnresolved)
2282
- for (const h of l.keys())
2283
- d.add(h);
2284
- t.excludeUndefineds ? d.delete(void 0) : d.add(void 0);
2285
- for (const h of d.values()) {
2286
- const A = /* @__PURE__ */ new Map(), W = l.get(h) || /* @__PURE__ */ new Set();
2282
+ for (const h of d.keys())
2283
+ l.add(h);
2284
+ t.excludeUndefineds ? l.delete(void 0) : l.add(void 0);
2285
+ for (const h of l.values()) {
2286
+ const y = /* @__PURE__ */ new Map(), W = d.get(h) || /* @__PURE__ */ new Set();
2287
2287
  for (const k of W) {
2288
2288
  const C = c.get(k);
2289
- if (C && (A.set(k, C), !t?.calculateFacets))
2289
+ if (C && (y.set(k, C), !t?.calculateFacets))
2290
2290
  break;
2291
2291
  }
2292
2292
  const N = {
2293
2293
  key: String(h),
2294
2294
  value: h,
2295
2295
  selected: ve(s, h, r),
2296
- enabled: A.size > 0,
2297
- size: A.size,
2296
+ enabled: y.size > 0,
2297
+ size: y.size,
2298
2298
  entry: e.get(h),
2299
- resultKeys: Array.from(A.keys())
2299
+ resultKeys: Array.from(y.keys())
2300
2300
  };
2301
2301
  if (!(t?.excludeZeros && N.size === 0)) {
2302
2302
  if (t?.count && a.length === t?.count)
@@ -2388,7 +2388,7 @@ class we {
2388
2388
  const u = g.parse(e).isDeepQuery;
2389
2389
  for (const c of t.values()) {
2390
2390
  let f;
2391
- u ? (f = v(c, e), f.length === 0 && (f = [void 0])) : f = [c[e]], this.fillInverseIndex(s, c.key, f), this.fillDataMap(s, f);
2391
+ u ? (f = w(c, e), f.length === 0 && (f = [void 0])) : f = [c[e]], this.fillInverseIndex(s, c.key, f), this.fillDataMap(s, f);
2392
2392
  }
2393
2393
  i = this.getIndex(s) || /* @__PURE__ */ new Map();
2394
2394
  }
@@ -2564,8 +2564,8 @@ class we {
2564
2564
  };
2565
2565
  }
2566
2566
  }
2567
- const m = "__";
2568
- function z(o, e, t = { key: "root" }, r = "root", s = new we(), i) {
2567
+ const v = "__";
2568
+ function R(o, e, t = { key: "root" }, r = "root", s = new we(), i) {
2569
2569
  const n = i || o;
2570
2570
  for (const a of e.columns)
2571
2571
  a.attribute && (g.parse(a.attribute), s.getOrCreateIndex(a.attribute, n));
@@ -2600,35 +2600,35 @@ function xe(o, e, t, r, s = "", i) {
2600
2600
  const f = {
2601
2601
  key: u,
2602
2602
  value: u
2603
- }, d = /* @__PURE__ */ new Map();
2604
- for (const l of c)
2605
- o.has(l) && d.set(l, o.get(l));
2606
- if (d.size) {
2607
- for (const l of t.values) {
2603
+ }, l = /* @__PURE__ */ new Map();
2604
+ for (const d of c)
2605
+ o.has(d) && l.set(d, o.get(d));
2606
+ if (l.size) {
2607
+ for (const d of t.values) {
2608
2608
  if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
2609
2609
  continue;
2610
- const h = M(l, d, r.getIndex(l.attribute), l.attribute);
2610
+ const h = M(d, l, r.getIndex(d.attribute), d.attribute);
2611
2611
  f.values.push(h);
2612
2612
  }
2613
2613
  if (n.rows = n.rows || [], n.rows.push(f), t.rows.length > 1) {
2614
- const l = { ...t, rows: t.rows.slice(1) };
2615
- z(
2616
- d,
2614
+ const d = { ...t, rows: t.rows.slice(1) };
2615
+ R(
2617
2616
  l,
2617
+ d,
2618
2618
  f,
2619
- s + m + e.attribute + m + u,
2619
+ s + v + e.attribute + v + u,
2620
2620
  r,
2621
2621
  i
2622
2622
  );
2623
2623
  } else if (t.columns)
2624
- for (const l of t.columns) {
2624
+ for (const d of t.columns) {
2625
2625
  f.columns = f.columns || [];
2626
2626
  const h = _(
2627
- d,
2628
2627
  l,
2628
+ d,
2629
2629
  t,
2630
2630
  r,
2631
- s + m + e.attribute + m + u,
2631
+ s + v + e.attribute + v + u,
2632
2632
  i
2633
2633
  );
2634
2634
  f.columns.push(h);
@@ -2645,23 +2645,23 @@ function _(o, e, t, r, s = "", i) {
2645
2645
  const f = {
2646
2646
  key: u,
2647
2647
  value: u
2648
- }, d = /* @__PURE__ */ new Map();
2649
- for (const l of c)
2650
- o.has(l) && d.set(l, o.get(l));
2651
- if (d.size) {
2652
- for (const l of t.values) {
2648
+ }, l = /* @__PURE__ */ new Map();
2649
+ for (const d of c)
2650
+ o.has(d) && l.set(d, o.get(d));
2651
+ if (l.size) {
2652
+ for (const d of t.values) {
2653
2653
  if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
2654
2654
  continue;
2655
- const h = M(l, d, r.getIndex(l.attribute), l.attribute);
2655
+ const h = M(d, l, r.getIndex(d.attribute), d.attribute);
2656
2656
  f.values.push(h);
2657
2657
  }
2658
2658
  if (n.columns = n.columns || [], n.columns.push(f), t.columns.length > 1) {
2659
- const l = { ...t, columns: t.columns.slice(1) };
2660
- z(
2661
- d,
2659
+ const d = { ...t, columns: t.columns.slice(1) };
2660
+ R(
2662
2661
  l,
2662
+ d,
2663
2663
  f,
2664
- s + m + e.attribute + m + u,
2664
+ s + v + e.attribute + v + u,
2665
2665
  r,
2666
2666
  i
2667
2667
  );
@@ -2670,31 +2670,32 @@ function _(o, e, t, r, s = "", i) {
2670
2670
  }
2671
2671
  return n;
2672
2672
  }
2673
- const Pe = (o, e) => {
2674
- const t = [];
2675
- for (const r of o) {
2676
- for (const [s, i] of Object.entries(r)) {
2677
- const n = t.find((u) => u.key === s), a = De(i);
2678
- if (n)
2679
- n.type !== a && (n.type = "any");
2680
- else {
2681
- const u = {
2682
- key: s,
2683
- type: a
2684
- };
2685
- t.push(u);
2673
+ const Ae = (o) => o == null || o === "", ze = (o, e = !1) => {
2674
+ const t = typeof e == "boolean" ? { deep: e } : e, s = t.deep ?? (t.sampleSize !== void 0 && t.sampleSize > 1) ? t.sampleSize ?? 1 / 0 : 1, i = t.ignoreEmpty ?? s > 1, n = [], a = Math.min(o.length, s);
2675
+ for (let u = 0; u < a; u++) {
2676
+ const c = o[u];
2677
+ if (c)
2678
+ for (const [f, l] of Object.entries(c)) {
2679
+ if (i && Ae(l)) continue;
2680
+ const d = Se(l), h = n.find((y) => y.key === f);
2681
+ if (h)
2682
+ h.type !== d && (h.type = "any");
2683
+ else {
2684
+ const y = {
2685
+ key: f,
2686
+ type: d
2687
+ };
2688
+ n.push(y);
2689
+ }
2686
2690
  }
2687
- }
2688
- if (!e)
2689
- break;
2690
2691
  }
2691
- return t;
2692
- }, Ae = (o) => Number(o) === o && o % 1 === 0, be = (o) => Number(o) === o && o % 1 !== 0, De = (o) => {
2692
+ return n;
2693
+ }, be = (o) => Number(o) === o && o % 1 === 0, De = (o) => Number(o) === o && o % 1 !== 0, Se = (o) => {
2693
2694
  switch (typeof o) {
2694
2695
  case "string":
2695
2696
  return "string";
2696
2697
  case "number":
2697
- return Ae(o) ? "int" : be(o) ? "float" : "any";
2698
+ return be(o) ? "int" : De(o) ? "float" : "any";
2698
2699
  case "boolean":
2699
2700
  return "boolean";
2700
2701
  case "object":
@@ -2766,7 +2767,7 @@ const Pe = (o, e) => {
2766
2767
  }
2767
2768
  ]
2768
2769
  }), s;
2769
- }, ze = (o, e) => {
2770
+ }, _e = (o, e) => {
2770
2771
  const t = e?.attributeKey || o.filterKey;
2771
2772
  return {
2772
2773
  groupKey: o.filterKey,
@@ -2779,7 +2780,7 @@ const Pe = (o, e) => {
2779
2780
  }
2780
2781
  ]
2781
2782
  };
2782
- }, _e = (o, e) => {
2783
+ }, We = (o, e) => {
2783
2784
  const t = e?.attributeKey || o.filterKey, r = {
2784
2785
  groupKey: o.filterKey,
2785
2786
  queries: []
@@ -2794,7 +2795,7 @@ const Pe = (o, e) => {
2794
2795
  operator: "eq",
2795
2796
  options: { invert: !0 }
2796
2797
  })), typeof o.gt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: o.gt, operator: "gt" })), typeof o.lt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: o.lt, operator: "lt" })), typeof o.gte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: o.gte, operator: "gte" })), typeof o.lte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: o.lte, operator: "lte" })), r;
2797
- }, We = (o, e) => {
2798
+ }, Le = (o, e) => {
2798
2799
  const t = e?.attributeKey || o.filterKey, r = {
2799
2800
  groupKey: o.filterKey,
2800
2801
  queries: []
@@ -2807,13 +2808,13 @@ const Pe = (o, e) => {
2807
2808
  operator: "eq"
2808
2809
  });
2809
2810
  }), r;
2810
- }, Le = (o) => !(typeof o.modelKey != "string" || !Array.isArray(o.queries));
2811
- class He {
2811
+ }, He = (o) => !(typeof o.modelKey != "string" || !Array.isArray(o.queries));
2812
+ class Ve {
2812
2813
  constructor(e, t, r) {
2813
2814
  this.scriptController = e, this.globalItemService = t, this.modelParser = r;
2814
2815
  }
2815
2816
  registeredCustomOperator = /* @__PURE__ */ new Map();
2816
- queryBuilder = new R();
2817
+ queryBuilder = new z();
2817
2818
  registerCustomOperator(e, t) {
2818
2819
  this.registeredCustomOperator.set(e, t);
2819
2820
  }
@@ -2833,7 +2834,7 @@ class He {
2833
2834
  return !1;
2834
2835
  switch (e.operator) {
2835
2836
  case "eq":
2836
- return e.options?.invert ? !O(r, s) : O(r, s);
2837
+ return e.options?.invert ? !q(r, s) : q(r, s);
2837
2838
  case "find":
2838
2839
  return e.options?.invert ? !this.queryFind(r, s, i) : this.queryFind(r, s, i);
2839
2840
  case "lt":
@@ -2871,9 +2872,9 @@ class He {
2871
2872
  if (u.forEach((c) => {
2872
2873
  r.has(c) && i.set(c, r.get(c));
2873
2874
  }), t.options?.invert) {
2874
- const c = q(Array.from(r.values()), Array.from(i.values()), "key"), f = /* @__PURE__ */ new Map();
2875
- return c.forEach((d) => {
2876
- f.set(d.key, d);
2875
+ const c = O(Array.from(r.values()), Array.from(i.values()), "key"), f = /* @__PURE__ */ new Map();
2876
+ return c.forEach((l) => {
2877
+ f.set(l.key, l);
2877
2878
  }), f;
2878
2879
  } else
2879
2880
  return i;
@@ -2883,7 +2884,7 @@ class He {
2883
2884
  const c = this.queryBuilder.extractQueryAttributes({ queries: [t] });
2884
2885
  if (c.some((f) => f.isDeepQuery)) {
2885
2886
  const f = this.queryBuilder.getProjectionForAttributeEntries(
2886
- c.filter((d) => d.isDeepQuery)
2887
+ c.filter((l) => l.isDeepQuery)
2887
2888
  );
2888
2889
  u = this.globalItemService.getProjectedData(
2889
2890
  f,
@@ -2896,13 +2897,13 @@ class He {
2896
2897
  return i;
2897
2898
  }
2898
2899
  equalRegexFn(e, t) {
2899
- if (typeof t == "string" && H(t, "/") && U(t, "/"))
2900
+ if (typeof t == "string" && H(t, "/") && V(t, "/"))
2900
2901
  try {
2901
2902
  return new RegExp(t.slice(1, -1)).test(e);
2902
2903
  } catch {
2903
2904
  return !1;
2904
2905
  }
2905
- else return Array.isArray(e) ? !!e.find((r) => b(r, t, this.equalRegexFn)) : typeof t == "object" ? V(e, t) : e === t;
2906
+ else return Array.isArray(e) ? !!e.find((r) => b(r, t, this.equalRegexFn)) : typeof t == "object" ? U(e, t) : e === t;
2906
2907
  }
2907
2908
  queryFind(e, t, r) {
2908
2909
  return Array.isArray(e) ? typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? r === "some" ? e.some((s) => b(s, t, this.equalRegexFn)) : e.every((s) => b(s, t, this.equalRegexFn)) : !!J(e, t) : b(e, t, this.equalRegexFn);
@@ -2916,7 +2917,7 @@ class He {
2916
2917
  return !0;
2917
2918
  } else {
2918
2919
  if (this.queryBuilder.isQueryGroup(e))
2919
- return B(e.queries, (t) => this.validateQuery(t));
2920
+ return j(e.queries, (t) => this.validateQuery(t));
2920
2921
  throw new Error("invalid query - missing query or attribute");
2921
2922
  }
2922
2923
  }
@@ -2926,26 +2927,26 @@ class He {
2926
2927
  const n = t.options?.invert === !0, a = /* @__PURE__ */ new Set();
2927
2928
  for (let u of r.values()) {
2928
2929
  const c = this.queryBuilder.extractQueryAttributes({ queries: [t] });
2929
- if (c.some((l) => l.isDeepQuery)) {
2930
- const l = this.queryBuilder.getProjectionForAttributeEntries(
2930
+ if (c.some((d) => d.isDeepQuery)) {
2931
+ const d = this.queryBuilder.getProjectionForAttributeEntries(
2931
2932
  c.filter((h) => h.isDeepQuery)
2932
2933
  );
2933
2934
  u = this.globalItemService.getProjectedData(
2934
- l,
2935
+ d,
2935
2936
  this.modelParser.models.get(e.modelKey),
2936
2937
  u
2937
2938
  );
2938
2939
  }
2939
2940
  const f = this.handleArrayStarQuery(t, u);
2940
- let d = !1;
2941
- for (const l of f.queries) {
2942
- const h = { ...l, options: { ...l.options, invert: !1 } };
2941
+ let l = !1;
2942
+ for (const d of f.queries) {
2943
+ const h = { ...d, options: { ...d.options, invert: !1 } };
2943
2944
  if (this.evaluateQuery(h, u)) {
2944
- d = !0;
2945
+ l = !0;
2945
2946
  break;
2946
2947
  }
2947
2948
  }
2948
- d && (a.add(u.key), n || i.set(u.key, u));
2949
+ l && (a.add(u.key), n || i.set(u.key, u));
2949
2950
  }
2950
2951
  if (n)
2951
2952
  for (const [u, c] of r)
@@ -3002,9 +3003,9 @@ class He {
3002
3003
  n.set(f.key, f);
3003
3004
  });
3004
3005
  else {
3005
- const f = q(Array.from(n.values()), Array.from(c.values()), "key");
3006
- for (const d of f)
3007
- n.delete(d.key);
3006
+ const f = O(Array.from(n.values()), Array.from(c.values()), "key");
3007
+ for (const l of f)
3008
+ n.delete(l.key);
3008
3009
  }
3009
3010
  t.groupType === "and" ? a = n : a = r;
3010
3011
  }
@@ -3091,10 +3092,10 @@ class Ue {
3091
3092
  return this.getScriptAsFn(e, i)(t, ...n);
3092
3093
  }
3093
3094
  }
3094
- const Ve = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => D(e, r.trim(), ""))) : "", Je = (o) => {
3095
+ const Je = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => D(e, r.trim(), ""))) : "", Ze = (o) => {
3095
3096
  const e = /* @__PURE__ */ new Set();
3096
3097
  return o.replace(/\$\{(.*?)\}/g, (r, s) => (e.add(s.trim()), "")), { variables: Array.from(e).map((r) => ({ name: r })) };
3097
- }, Ze = [
3098
+ }, Ye = [
3098
3099
  "any",
3099
3100
  "Array<date>",
3100
3101
  "Array<float>",
@@ -3106,7 +3107,7 @@ const Ve = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => D(e
3106
3107
  "int",
3107
3108
  "json",
3108
3109
  "string"
3109
- ], Ye = ["int", "float", "Array<int>", "Array<float>"], Xe = ["date", "Array<date>"], et = [
3110
+ ], Xe = ["int", "float", "Array<int>", "Array<float>"], et = ["date", "Array<date>"], tt = [
3110
3111
  "eq",
3111
3112
  "find",
3112
3113
  "gt",
@@ -3118,57 +3119,57 @@ const Ve = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => D(e
3118
3119
  "size"
3119
3120
  ];
3120
3121
  export {
3121
- Se as AnalyticsController,
3122
- Ie as AttributeDependencyGraph,
3123
- Qe as CacheController,
3124
- Fe as ChangeDetector,
3125
- Xe as DatePropertyTypes,
3126
- R as DcuplQueryBuilder,
3127
- et as DcuplQueryOperatorsAsArray,
3128
- de as DeepQueryService,
3122
+ Ie as AnalyticsController,
3123
+ Qe as AttributeDependencyGraph,
3124
+ Me as CacheController,
3125
+ Ge as ChangeDetector,
3126
+ et as DatePropertyTypes,
3127
+ z as DcuplQueryBuilder,
3128
+ tt as DcuplQueryOperatorsAsArray,
3129
+ le as DeepQueryService,
3129
3130
  Y as DependencyGraph,
3130
3131
  we as IndicesController,
3131
3132
  p as Logger,
3132
- Ye as NumberPropertyTypes,
3133
- Ze as PropertyTypesAsArray,
3134
- He as QueryManager,
3133
+ Xe as NumberPropertyTypes,
3134
+ Ye as PropertyTypesAsArray,
3135
+ Ve as QueryManager,
3135
3136
  Ue as ScriptController,
3136
3137
  P as clone,
3137
3138
  re as compareVersions,
3138
3139
  je as computeSuggestions,
3139
3140
  g as deepQueryService,
3140
3141
  te as escapeRegExp,
3141
- Ve as evaluateTemplate,
3142
- ze as generateBooleanQuery,
3142
+ Je as evaluateTemplate,
3143
+ _e as generateBooleanQuery,
3143
3144
  ee as generateKey,
3144
- _e as generateNumberAndDateQuery,
3145
- We as generateReferenceQuery,
3145
+ We as generateNumberAndDateQuery,
3146
+ Le as generateReferenceQuery,
3146
3147
  Re as generateTextQuery,
3147
3148
  M as getAggregation,
3148
- ke as getDateConstraintUid,
3149
- De as getDcuplPropertyTypeForNativeType,
3150
- v as getDeepPathValues,
3149
+ Ce as getDateConstraintUid,
3150
+ Se as getDcuplPropertyTypeForNativeType,
3151
+ w as getDeepPathValues,
3151
3152
  me as getDistinct,
3152
- Te as getFacets,
3153
- Me as getFilterEntryId,
3154
- Ne as getNumberConstraintUid,
3155
- Pe as getPropertiesForData,
3156
- Ee as groupBy,
3157
- $e as hasMinimumVersion,
3153
+ Pe as getFacets,
3154
+ Ne as getFilterEntryId,
3155
+ ke as getNumberConstraintUid,
3156
+ ze as getPropertiesForData,
3157
+ qe as groupBy,
3158
+ Fe as hasMinimumVersion,
3158
3159
  se as isDateInstance,
3159
- be as isFloat,
3160
- Ae as isInt,
3160
+ De as isFloat,
3161
+ be as isInt,
3161
3162
  ne as isValidDate,
3162
- Le as isValidQueryStatement,
3163
+ He as isValidQueryStatement,
3163
3164
  F as isValidVersion,
3164
3165
  X as logger,
3165
3166
  Be as parseDate,
3166
- Je as parseTemplate,
3167
- x as perf,
3168
- z as pivot,
3167
+ Ze as parseTemplate,
3168
+ A as perf,
3169
+ R as pivot,
3169
3170
  Oe as removeTrailingSlash,
3170
- Ge as trigger,
3171
- qe as unescapeRegExp,
3172
- Ce as uniqBy
3171
+ Te as trigger,
3172
+ $e as unescapeRegExp,
3173
+ Ee as uniqBy
3173
3174
  };
3174
3175
  //# sourceMappingURL=index.js.map