@dcupl/common 2.0.0-beta.0 → 2.0.0-beta.2

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,22 +1,22 @@
1
- import { cloneDeep as y, get as v, every as B, findIndex as C, size as W, isEqual as E, differenceBy as q, startsWith as L, endsWith as H, isEqualWith as b, isMatch as U, find as V } from "lodash-es";
2
- function I(o) {
3
- const e = K(o);
4
- return J(e);
1
+ import { cloneDeep as m, get as y, every as T, findIndex as E, size as L, isEqual as O, differenceBy as q, startsWith as H, endsWith as U, isEqualWith as D, isMatch as V, find as J } from "lodash-es";
2
+ function Q(o) {
3
+ const e = S(o);
4
+ return Z(e);
5
5
  }
6
- function K(o) {
6
+ function S(o) {
7
7
  if (typeof o != "object" || o === null)
8
8
  return String(o);
9
9
  if (Array.isArray(o))
10
- return "[" + o.map(K).join(",") + "]";
10
+ return "[" + o.map(S).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 + ":" + K(o[s]), r < e.length - 1 && (t += ",");
15
+ t += s + ":" + S(o[s]), r < e.length - 1 && (t += ",");
16
16
  }
17
17
  return t += "}", t;
18
18
  }
19
- function J(o) {
19
+ function Z(o) {
20
20
  let e = 0;
21
21
  for (let t = 0; t < o.length; t++) {
22
22
  const r = o.charCodeAt(t);
@@ -41,7 +41,7 @@ const x = {
41
41
  return performance.getEntriesByType(o);
42
42
  }
43
43
  };
44
- class De {
44
+ class Ke {
45
45
  data;
46
46
  enabled = !1;
47
47
  constructor() {
@@ -71,11 +71,11 @@ class De {
71
71
  return;
72
72
  const i = s.value - r.value, n = Math.round(i * 100) / 100, a = this.data.get(t);
73
73
  if (a && e.sum) {
74
- const c = a.value + n, f = {
74
+ const f = a.value + n, c = {
75
75
  ...a,
76
- value: c
76
+ value: f
77
77
  };
78
- return this.data.set(t, f), f;
78
+ return this.data.set(t, c), c;
79
79
  }
80
80
  const u = {
81
81
  name: e.name,
@@ -114,11 +114,11 @@ class De {
114
114
  getKey(e, t) {
115
115
  if (!t)
116
116
  return e;
117
- const r = I(t);
117
+ const r = Q(t);
118
118
  return e + "_" + r;
119
119
  }
120
120
  }
121
- let Z = class T {
121
+ let Y = class j {
122
122
  nodes;
123
123
  edges;
124
124
  nodeKinds = /* @__PURE__ */ new Map();
@@ -253,8 +253,8 @@ let Z = class T {
253
253
  r.add(a);
254
254
  const u = this.edges.get(a);
255
255
  if (u)
256
- for (let c of u)
257
- n(c);
256
+ for (let f of u)
257
+ n(f);
258
258
  r.delete(a), t.add(a), s.push(a);
259
259
  };
260
260
  for (let a of this.nodes)
@@ -340,8 +340,8 @@ let Z = class T {
340
340
  i.add(a);
341
341
  const u = this.edges.get(a);
342
342
  if (u)
343
- for (const c of u)
344
- t.set(c, (t.get(c) || 0) - 1), (t.get(c) || 0) === 0 && s.push(c);
343
+ for (const f of u)
344
+ t.set(f, (t.get(f) || 0) - 1), (t.get(f) || 0) === 0 && s.push(f);
345
345
  }
346
346
  }
347
347
  if (i.size !== this.nodes.size)
@@ -362,23 +362,23 @@ let Z = class T {
362
362
  * - 'both': union of upstream and downstream
363
363
  */
364
364
  getImpactedNodes(e, t = "downstream", r) {
365
- const s = new Set(e), i = (c) => !r || r.length === 0 || r.includes(this.nodeKinds.get(c) ?? void 0), n = () => {
366
- const c = /* @__PURE__ */ new Set(), f = Array.from(s);
367
- for (; f.length; ) {
368
- const d = f.shift();
365
+ const s = new Set(e), i = (f) => !r || r.length === 0 || r.includes(this.nodeKinds.get(f) ?? void 0), n = () => {
366
+ const f = /* @__PURE__ */ new Set(), c = Array.from(s);
367
+ for (; c.length; ) {
368
+ const d = c.shift();
369
369
  for (const [l, h] of this.edges)
370
- h.has(d) && !c.has(l) && (c.add(l), f.push(l));
370
+ h.has(d) && !f.has(l) && (f.add(l), c.push(l));
371
371
  }
372
- return c;
372
+ return f;
373
373
  }, a = () => {
374
- const c = /* @__PURE__ */ new Set(), f = Array.from(s);
375
- for (; f.length; ) {
376
- const d = f.shift(), l = this.edges.get(d);
374
+ const f = /* @__PURE__ */ new Set(), c = Array.from(s);
375
+ for (; c.length; ) {
376
+ const d = c.shift(), l = this.edges.get(d);
377
377
  if (l)
378
378
  for (const h of l)
379
- c.has(h) || (c.add(h), f.push(h));
379
+ f.has(h) || (f.add(h), c.push(h));
380
380
  }
381
- return c;
381
+ return f;
382
382
  };
383
383
  let u;
384
384
  return t === "both" ? u = /* @__PURE__ */ new Set([...n(), ...a()]) : t === "upstream" ? u = a() : u = n(), Array.from(u).filter(i);
@@ -392,7 +392,7 @@ let Z = 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 j();
396
396
  for (const r of e.nodes)
397
397
  t.addNode(r.name, { kind: r.kind, meta: r.meta });
398
398
  for (const r of e.edges)
@@ -400,19 +400,19 @@ let Z = 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 = [];
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("→")), f = Array.from(n).filter((d) => !a.has(d)).map((d) => d.split("→")), c = [];
404
404
  for (const d of /* @__PURE__ */ new Set([...t, ...r])) {
405
405
  const l = this.nodeKinds.get(d), h = e.nodeKinds.get(d);
406
- l !== h && f.push({ name: d, from: l, to: h });
406
+ l !== h && c.push({ name: d, from: l, to: h });
407
407
  }
408
- return { addedNodes: s, removedNodes: i, addedEdges: u, removedEdges: c, kindChanges: f };
408
+ return { addedNodes: s, removedNodes: i, addedEdges: u, removedEdges: f, kindChanges: c };
409
409
  }
410
410
  };
411
- class Ke {
411
+ class Se {
412
412
  graph;
413
413
  nodeIndex;
414
414
  constructor() {
415
- this.graph = new Z(), this.nodeIndex = /* @__PURE__ */ new Map();
415
+ this.graph = new Y(), this.nodeIndex = /* @__PURE__ */ new Map();
416
416
  }
417
417
  /**
418
418
  * Creates a unique ID for an attribute node
@@ -600,7 +600,7 @@ class Ke {
600
600
  };
601
601
  }
602
602
  }
603
- const O = {
603
+ const $ = {
604
604
  silent: 0,
605
605
  error: 1,
606
606
  warn: 2,
@@ -663,7 +663,7 @@ class p {
663
663
  }
664
664
  shouldLog(e) {
665
665
  const t = this.getEffectiveLevel();
666
- return O[e] <= O[t];
666
+ return $[e] <= $[t];
667
667
  }
668
668
  formatMessage(e) {
669
669
  if (this.config.format === "json") {
@@ -799,8 +799,8 @@ class p {
799
799
  Object.assign(this.config, e);
800
800
  }
801
801
  }
802
- const Y = new p();
803
- class Se {
802
+ const X = new p();
803
+ class Ie {
804
804
  constructor(e) {
805
805
  this.enabled = e, this.cache = /* @__PURE__ */ new Map(), this.cacheDependencies = /* @__PURE__ */ new Map();
806
806
  }
@@ -810,7 +810,7 @@ class Se {
810
810
  // Track cache hits and misses for statistics
811
811
  hitCount = 0;
812
812
  missCount = 0;
813
- log = Y.child({ prefix: "CacheController" });
813
+ log = X.child({ prefix: "CacheController" });
814
814
  get(e, t) {
815
815
  if (!this.enabled) return;
816
816
  const r = this.getCacheName(e, t);
@@ -842,8 +842,8 @@ class Se {
842
842
  if (s.models.has(n))
843
843
  if (s.modelAttributes.has(n)) {
844
844
  const u = s.modelAttributes.get(n);
845
- for (const c of a)
846
- if (u.has(c)) {
845
+ for (const f of a)
846
+ if (u.has(f)) {
847
847
  i = !0;
848
848
  break;
849
849
  }
@@ -915,13 +915,13 @@ class Se {
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
  }
922
922
  }
923
923
  getCacheName(e, t) {
924
- const r = I(t);
924
+ const r = Q(t);
925
925
  return e + "_" + r;
926
926
  }
927
927
  /**
@@ -939,7 +939,7 @@ class Se {
939
939
  };
940
940
  }
941
941
  }
942
- const Ie = (o, e = "") => `${o}#${e}`, Qe = (o) => `${o.gt}_${o.gte}_${o.lt}_${o.lte}_${o.eq}_${o.ne}`, Me = (o) => `${o.gt}_${o.gte}_${o.lt}_${o.lte}_${o.eq}_${o.ne}`, Ne = (o, e) => {
942
+ const Qe = (o, e = "") => `${o}#${e}`, Me = (o) => `${o.gt}_${o.gte}_${o.lt}_${o.lte}_${o.eq}_${o.ne}`, Ne = (o) => `${o.gt}_${o.gte}_${o.lt}_${o.lte}_${o.eq}_${o.ne}`, ke = (o, e) => {
943
943
  const t = typeof e == "function" ? e : (r) => r[e];
944
944
  return [
945
945
  ...o.reduce((r, s) => {
@@ -947,24 +947,24 @@ const Ie = (o, e = "") => `${o}#${e}`, Qe = (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
- }, ke = (o, e) => o.reduce(function(t, r) {
950
+ }, Ce = (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
  }, {});
954
- function X(o = 10) {
954
+ function ee(o = 10) {
955
955
  let e = "";
956
956
  const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
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 Ce = (o) => o.replace(/\/+$/, ""), ee = (o) => typeof o != "string" ? "" : o.replace(/[[\]{}()*+?.,\\^$|#]/g, "\\$&"), Ee = (o) => typeof o != "string" ? "" : o.replace(/\\([[\]{}()*+?.,\\^$|#])/g, "$1"), qe = (o, e) => {
960
+ const Ee = (o) => o.replace(/\/+$/, ""), te = (o) => typeof o != "string" ? "" : o.replace(/[[\]{}()*+?.,\\^$|#]/g, "\\$&"), Oe = (o) => typeof o != "string" ? "" : o.replace(/\\([[\]{}()*+?.,\\^$|#])/g, "$1"), qe = (o, e) => {
961
961
  try {
962
- return te(o, e) >= 0;
962
+ return re(o, e) >= 0;
963
963
  } catch {
964
964
  return !1;
965
965
  }
966
- }, te = (o, e) => {
967
- if (!$(o) || !$(e))
966
+ }, re = (o, e) => {
967
+ if (!F(o) || !F(e))
968
968
  throw new Error(`Invalid version format: v1="${o}", v2="${e}". Expected format: "x.y.z"`);
969
969
  const t = o.split(".").map(Number), r = e.split(".").map(Number);
970
970
  for (let s = 0; s < 3; s++) {
@@ -973,8 +973,8 @@ const Ce = (o) => o.replace(/\/+$/, ""), ee = (o) => typeof o != "string" ? "" :
973
973
  if (i < n) return -1;
974
974
  }
975
975
  return 0;
976
- }, $ = (o) => /^\d+(\.\d+){0,2}$/.test(o);
977
- class Oe {
976
+ }, F = (o) => /^\d+(\.\d+){0,2}$/.test(o);
977
+ class $e {
978
978
  key;
979
979
  parentCd;
980
980
  dcuplInitOptions;
@@ -1010,13 +1010,13 @@ class Oe {
1010
1010
  };
1011
1011
  }
1012
1012
  }
1013
- const j = (o, e) => e ? typeof structuredClone < "u" ? structuredClone(o) : y(o) : o, F = (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
- const n = !!e.dcuplInitOptions.performance?.clone?.enabled && !!t.cloneResult, a = j(i, n);
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;
1019
- t.duration = f, t.start = r, t.end = u;
1018
+ const u = x.now(), f = u - r, c = Math.round(f * 1e3) / 1e3;
1019
+ t.duration = c, t.start = r, t.end = u;
1020
1020
  const d = {
1021
1021
  duration: t.duration
1022
1022
  };
@@ -1033,57 +1033,57 @@ const j = (o, e) => e ? typeof structuredClone < "u" ? structuredClone(o) : y(o)
1033
1033
  } catch {
1034
1034
  return i;
1035
1035
  }
1036
- }, $e = (o) => (t, r, s) => {
1036
+ }, Fe = (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 = j(o, !0);
1040
- c.key || (u.increaseCounter(), c.key = u.getCounter());
1041
- const f = X();
1039
+ const a = x.now(), u = this.cdRef, f = P(o, !0);
1040
+ f.key || (u.increaseCounter(), f.key = u.getCounter());
1041
+ const c = ee();
1042
1042
  u.analyticsController.mark({
1043
- name: `${c.type}:start`,
1044
- context: f
1043
+ name: `${f.type}:start`,
1044
+ context: c
1045
1045
  });
1046
1046
  const d = this.model?.key;
1047
- !c.originCdRefKey && u.key && (c.originCdRefKey = u.key), d && (c.modelKey = d);
1047
+ !f.originCdRefKey && u.key && (f.originCdRefKey = u.key), d && (f.modelKey = d);
1048
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) => F(this, u, c, a, f, h)) : F(this, u, c, a, f, l);
1049
+ return f.method = r, f.args = n, l && typeof l == "object" && "then" in l ? l.then((h) => G(this, u, f, a, c, h)) : G(this, u, f, a, c, l);
1050
1050
  }, s;
1051
1051
  };
1052
- function Fe(o, e, t, r) {
1052
+ function Ge(o, e, t, r) {
1053
1053
  t.max || (t.max = 20);
1054
1054
  const s = [], i = t.transform ? r.transformValue(t.value, t.transform) : t.value;
1055
1055
  for (const [n, a] of e.entries()) {
1056
- const u = Array.from(a).some((f) => o.has(f)), c = t.transform ? r.transformValue(n, t.transform) : n;
1056
+ const u = Array.from(a).some((c) => o.has(c)), f = t.transform ? r.transformValue(n, t.transform) : n;
1057
1057
  if (!(t.excludeUndefineds && typeof n > "u") && !(t.excludeNulls && n === null)) {
1058
1058
  if (u && (i === "" || i === "//")) {
1059
- const f = {
1059
+ const c = {
1060
1060
  value: n,
1061
1061
  keys: t.calculateResultKeys ? Array.from(a) : []
1062
1062
  };
1063
- s.push(f);
1063
+ s.push(c);
1064
1064
  } else if (u && typeof i == "string" && i.startsWith("/") && i.endsWith("/")) {
1065
- if (r.queryFind(c, i, "some")) {
1066
- const f = {
1065
+ if (r.queryFind(f, i, "some")) {
1066
+ const c = {
1067
1067
  value: n,
1068
1068
  keys: t.calculateResultKeys ? Array.from(a) : []
1069
1069
  };
1070
- s.push(f);
1070
+ s.push(c);
1071
1071
  }
1072
1072
  } else if (u && typeof i == "string") {
1073
- const f = String(c ?? ""), d = i;
1074
- if (f.toLowerCase().startsWith(d.toLowerCase())) {
1073
+ const c = String(f ?? ""), d = i;
1074
+ if (c.toLowerCase().startsWith(d.toLowerCase())) {
1075
1075
  const l = {
1076
1076
  value: n,
1077
1077
  keys: t.calculateResultKeys ? Array.from(a) : []
1078
1078
  };
1079
1079
  s.push(l);
1080
1080
  }
1081
- } else if (u && r.queryFind(c, i, "some")) {
1082
- const f = {
1081
+ } else if (u && r.queryFind(f, i, "some")) {
1082
+ const c = {
1083
1083
  value: n,
1084
1084
  keys: t.calculateResultKeys ? Array.from(a) : []
1085
1085
  };
1086
- s.push(f);
1086
+ s.push(c);
1087
1087
  }
1088
1088
  if (s.length === t.max)
1089
1089
  break;
@@ -1091,13 +1091,13 @@ function Fe(o, e, t, r) {
1091
1091
  }
1092
1092
  return s;
1093
1093
  }
1094
- function re(o) {
1094
+ function se(o) {
1095
1095
  return o instanceof Date;
1096
1096
  }
1097
- function se(o) {
1097
+ function ne(o) {
1098
1098
  return o instanceof Date && !isNaN(o.getTime());
1099
1099
  }
1100
- const ne = {
1100
+ const ie = {
1101
1101
  yyyy: { type: "year", pattern: "yyyy", regex: "(\\d{4})" },
1102
1102
  yy: { type: "year", pattern: "yy", regex: "(\\d{2})" },
1103
1103
  MM: { type: "month", pattern: "MM", regex: "(\\d{2})" },
@@ -1112,11 +1112,11 @@ const ne = {
1112
1112
  s: { type: "second", pattern: "s", regex: "(\\d{1,2})" },
1113
1113
  SSS: { type: "millisecond", pattern: "SSS", regex: "(\\d{3})" }
1114
1114
  };
1115
- function ie(o) {
1115
+ function oe(o) {
1116
1116
  let e = "^";
1117
1117
  const t = [];
1118
1118
  let r = o;
1119
- const s = Object.entries(ne).sort((i, n) => n[0].length - i[0].length);
1119
+ const s = Object.entries(ie).sort((i, n) => n[0].length - i[0].length);
1120
1120
  for (; r.length > 0; ) {
1121
1121
  let i = !1;
1122
1122
  for (const [n, a] of s)
@@ -1133,7 +1133,7 @@ function ie(o) {
1133
1133
  }
1134
1134
  return e += "$", { regex: new RegExp(e), tokenOrder: t };
1135
1135
  }
1136
- function oe(o, e) {
1136
+ function ae(o, e) {
1137
1137
  const t = {
1138
1138
  year: 1970,
1139
1139
  month: 1,
@@ -1152,7 +1152,7 @@ function oe(o, e) {
1152
1152
  }
1153
1153
  return t;
1154
1154
  }
1155
- function ae(o) {
1155
+ function ue(o) {
1156
1156
  if (o.month < 1 || o.month > 12)
1157
1157
  return /* @__PURE__ */ new Date(NaN);
1158
1158
  if (o.day < 1 || o.day > 31)
@@ -1174,9 +1174,9 @@ function ae(o) {
1174
1174
  o.second,
1175
1175
  o.millisecond
1176
1176
  );
1177
- return se(e) ? e.getFullYear() !== o.year || e.getMonth() !== o.month - 1 || e.getDate() !== o.day ? /* @__PURE__ */ new Date(NaN) : e : /* @__PURE__ */ new Date(NaN);
1177
+ return ne(e) ? e.getFullYear() !== o.year || e.getMonth() !== o.month - 1 || e.getDate() !== o.day ? /* @__PURE__ */ new Date(NaN) : e : /* @__PURE__ */ new Date(NaN);
1178
1178
  }
1179
- function Ge(o, e, t) {
1179
+ function Be(o, e, t) {
1180
1180
  if (o = o.trim(), e === "t") {
1181
1181
  const a = Number(o);
1182
1182
  return isNaN(a) ? /* @__PURE__ */ new Date(NaN) : new Date(a * 1e3);
@@ -1185,13 +1185,13 @@ function Ge(o, e, t) {
1185
1185
  const a = Number(o);
1186
1186
  return isNaN(a) ? /* @__PURE__ */ new Date(NaN) : new Date(a);
1187
1187
  }
1188
- const { regex: r, tokenOrder: s } = ie(e), i = o.match(r);
1188
+ const { regex: r, tokenOrder: s } = oe(e), i = o.match(r);
1189
1189
  if (!i)
1190
1190
  return /* @__PURE__ */ new Date(NaN);
1191
- const n = oe(i, s);
1192
- return ae(n);
1191
+ const n = ae(i, s);
1192
+ return ue(n);
1193
1193
  }
1194
- class ue {
1194
+ class ce {
1195
1195
  cache;
1196
1196
  maxSize;
1197
1197
  accessOrder;
@@ -1234,7 +1234,7 @@ class ue {
1234
1234
  };
1235
1235
  }
1236
1236
  }
1237
- class ce {
1237
+ class fe {
1238
1238
  graph;
1239
1239
  constructor() {
1240
1240
  this.graph = /* @__PURE__ */ new Map();
@@ -1270,13 +1270,13 @@ class ce {
1270
1270
  this.graph.clear();
1271
1271
  }
1272
1272
  }
1273
- class fe {
1273
+ class de {
1274
1274
  parseCache;
1275
1275
  circularRefDetector;
1276
1276
  cacheHits = 0;
1277
1277
  cacheMisses = 0;
1278
1278
  constructor(e = 1e3) {
1279
- this.parseCache = new ue(e), this.circularRefDetector = new ce();
1279
+ this.parseCache = new ce(e), this.circularRefDetector = new fe();
1280
1280
  }
1281
1281
  /**
1282
1282
  * Parse an attribute string into its components
@@ -1306,8 +1306,8 @@ class fe {
1306
1306
  if (r = e.split(/[.[]/)[0], i) {
1307
1307
  const u = e.indexOf("]");
1308
1308
  if (u > -1) {
1309
- const c = e.indexOf(".", u + 1);
1310
- c > -1 ? t = e.substring(c + 1) : t = void 0;
1309
+ const f = e.indexOf(".", u + 1);
1310
+ f > -1 ? t = e.substring(f + 1) : t = void 0;
1311
1311
  } else s && (t = e.substring(e.indexOf(".") + 1));
1312
1312
  } else s && (t = e.substring(e.indexOf(".") + 1));
1313
1313
  const a = {
@@ -1370,13 +1370,13 @@ class fe {
1370
1370
  const n = /\[([^\]]+)\]/g;
1371
1371
  let a;
1372
1372
  for (; (a = n.exec(e)) !== null; ) {
1373
- const f = a[1];
1374
- f && f !== "*" && !/^\d+$/.test(f) && r.push(`Invalid bracket content: Must be a number or '*', got '${f}' in ${e}`);
1373
+ const c = a[1];
1374
+ c && c !== "*" && !/^\d+$/.test(c) && r.push(`Invalid bracket content: Must be a number or '*', got '${c}' in ${e}`);
1375
1375
  }
1376
1376
  const u = (e.match(/\./g) || []).length + 1;
1377
1377
  u > t && r.push(`Path too deep: Maximum depth is ${t}, got ${u} in ${e}`);
1378
- const c = e.match(/[^a-zA-Z0-9._[\]*-]/g);
1379
- return c && r.push(`Invalid characters in path: ${c.join(", ")} in ${e}`), {
1378
+ const f = e.match(/[^a-zA-Z0-9._[\]*-]/g);
1379
+ return f && r.push(`Invalid characters in path: ${f.join(", ")} in ${e}`), {
1380
1380
  valid: r.length === 0,
1381
1381
  errors: r.length > 0 ? r : void 0
1382
1382
  };
@@ -1435,8 +1435,20 @@ class fe {
1435
1435
  return this.getPathSegments(e).length;
1436
1436
  }
1437
1437
  }
1438
- const g = new fe();
1439
- function D(o) {
1438
+ const g = new de();
1439
+ function A(o, e) {
1440
+ if (!e.includes("[*]")) {
1441
+ const a = y(o, e);
1442
+ return a !== void 0 ? [a] : [];
1443
+ }
1444
+ const t = e.indexOf("[*]"), r = e.substring(0, t), s = e.substring(t + 3), i = r ? y(o, r) : o;
1445
+ if (!Array.isArray(i)) return [];
1446
+ const n = [];
1447
+ for (const a of i)
1448
+ !s || s === "" ? a !== void 0 && n.push(a) : s.startsWith(".") && n.push(...A(a, s.slice(1)));
1449
+ return n;
1450
+ }
1451
+ function K(o) {
1440
1452
  let e = 0;
1441
1453
  for (let t of o) {
1442
1454
  const r = t.toString().split(".")[1];
@@ -1444,13 +1456,13 @@ function D(o) {
1444
1456
  }
1445
1457
  return Math.pow(10, e);
1446
1458
  }
1447
- function G(o, e, t) {
1459
+ function B(o, e, t) {
1448
1460
  return (o * t + e * t) / t;
1449
1461
  }
1450
- function de(o, e, t) {
1462
+ function le(o, e, t) {
1451
1463
  return o * t / (e * t);
1452
1464
  }
1453
- const Q = (o, e, t, r) => {
1465
+ const M = (o, e, t, r) => {
1454
1466
  if (!r)
1455
1467
  throw new Error("Attribute not found");
1456
1468
  const s = {
@@ -1458,22 +1470,30 @@ const Q = (o, e, t, r) => {
1458
1470
  types: o.types
1459
1471
  };
1460
1472
  let i;
1461
- (s.types.includes("sum") || s.types.includes("avg") || s.types.includes("count")) && (i = pe(r, e));
1473
+ (s.types.includes("sum") || s.types.includes("avg") || s.types.includes("count")) && (i = ge(r, e));
1462
1474
  let n;
1463
- return (s.types.includes("min") || s.types.includes("max")) && (n = le(r, e)), o.types.forEach((a) => {
1464
- a === "sum" ? s.sum = i?.sum : a === "avg" ? s.avg = i?.average : a === "count" ? s.count = i?.count : a === "min" ? s.min = n && n[0] : a === "max" ? s.max = n && n[1] : a === "distinct" ? s.distinct = ge(o, e, t) : a === "group" && (s.group = he(o, e));
1475
+ return (s.types.includes("min") || s.types.includes("max")) && (n = he(r, e)), o.types.forEach((a) => {
1476
+ a === "sum" ? s.sum = i?.sum : a === "avg" ? s.avg = i?.average : a === "count" ? s.count = i?.count : a === "min" ? s.min = n && n[0] : a === "max" ? s.max = n && n[1] : a === "distinct" ? s.distinct = ye(o, e, t) : a === "group" && (s.group = pe(o, e));
1465
1477
  }), s;
1466
- }, le = (o, e) => {
1478
+ }, he = (o, e) => {
1467
1479
  let t, r;
1468
1480
  const i = g.parse(o).isDeepQuery;
1469
1481
  for (const n of e.values())
1470
1482
  if (n) {
1471
- const a = i ? v(n, o) : n[o];
1472
- (t === void 0 || a < t) && (t = a), (r === void 0 || a > r) && (r = a);
1483
+ let a;
1484
+ if (i && o.includes("[*]"))
1485
+ a = A(n, o);
1486
+ else if (i) {
1487
+ const u = y(n, o);
1488
+ a = u !== void 0 ? [u] : [];
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);
1473
1493
  }
1474
1494
  if (!(t === void 0 || r === void 0))
1475
1495
  return [t, r];
1476
- }, he = (o, e) => {
1496
+ }, pe = (o, e) => {
1477
1497
  const t = [];
1478
1498
  o.groupOptions?.groups?.forEach((n) => {
1479
1499
  t.push({
@@ -1488,28 +1508,46 @@ const Q = (o, e, t, r) => {
1488
1508
  keys: []
1489
1509
  }, i = g.parse(o.attribute).isDeepQuery;
1490
1510
  for (const n of e.values()) {
1491
- const a = i ? v(n, o.attribute) : n[o.attribute];
1492
- for (const u of t)
1493
- typeof u.option.value < "u" && u.option.value.includes(a) || typeof u.option.from < "u" && u.option.from < a && typeof u.option.to < "u" && u.option.to > a ? (u.count++, u.keys.push(n.key)) : o?.groupOptions?.calculateNotFound && (r.count++, r.keys.push(n.key));
1511
+ let a;
1512
+ if (i && o.attribute.includes("[*]"))
1513
+ a = A(n, o.attribute);
1514
+ else if (i) {
1515
+ const f = y(n, o.attribute);
1516
+ a = f !== void 0 ? [f] : [];
1517
+ } else
1518
+ a = [n[o.attribute]];
1519
+ let u = !1;
1520
+ for (const f of a)
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));
1494
1524
  }
1495
1525
  return o?.groupOptions?.calculateNotFound && t.push(r), t;
1496
- }, pe = (o, e) => {
1526
+ }, ge = (o, e) => {
1497
1527
  let t = 0, r = 0;
1498
1528
  const i = g.parse(o).isDeepQuery;
1499
1529
  for (const u of e.values()) {
1500
1530
  if (!u) continue;
1501
- const c = i ? v(u, o) : u[o];
1502
- if (Array.isArray(c))
1503
- for (const f of c)
1504
- typeof f == "number" && (t = G(t, f, D([t, f])), r++);
1505
- else typeof c == "number" && (t = G(t, c, D([t, c])), r++);
1506
- }
1507
- return r === 0 || r === 0 ? void 0 : {
1508
- average: de(t, r, D([t, r])),
1531
+ let f;
1532
+ if (i && o.includes("[*]"))
1533
+ f = A(u, o);
1534
+ else if (i) {
1535
+ const c = y(u, o);
1536
+ f = c !== void 0 ? [c] : [];
1537
+ } else
1538
+ f = u[o] !== void 0 ? [u[o]] : [];
1539
+ for (const c of f)
1540
+ if (Array.isArray(c))
1541
+ for (const d of c)
1542
+ typeof d == "number" && (t = B(t, d, K([t, d])), r++);
1543
+ else typeof c == "number" && (t = B(t, c, K([t, c])), r++);
1544
+ }
1545
+ return r === 0 ? void 0 : {
1546
+ average: le(t, r, K([t, r])),
1509
1547
  count: e.size,
1510
1548
  sum: t
1511
1549
  };
1512
- }, ge = (o, e, t) => {
1550
+ }, ye = (o, e, t) => {
1513
1551
  const r = [];
1514
1552
  for (const [s, i] of t)
1515
1553
  if (!(o.excludeUndefineds && typeof s > "u") && Array.from(i).find((n) => e.has(n))) {
@@ -1529,7 +1567,7 @@ class w extends Error {
1529
1567
  super(r), this.query = t, this.name = "DcuplQueryError";
1530
1568
  }
1531
1569
  }
1532
- class P {
1570
+ class R {
1533
1571
  _defaultQueryOptions = {
1534
1572
  modelKey: "",
1535
1573
  groupKey: "root",
@@ -1537,7 +1575,7 @@ class P {
1537
1575
  queries: []
1538
1576
  };
1539
1577
  _initOptions;
1540
- currentQuery = y(this._defaultQueryOptions);
1578
+ currentQuery = m(this._defaultQueryOptions);
1541
1579
  deepQueryService;
1542
1580
  constructor(e) {
1543
1581
  this.deepQueryService = e || g;
@@ -1566,7 +1604,7 @@ class P {
1566
1604
  * });
1567
1605
  */
1568
1606
  init(e) {
1569
- 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));
1607
+ 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));
1570
1608
  }
1571
1609
  reset() {
1572
1610
  return this.init(this._initOptions), this.getQuery();
@@ -1584,7 +1622,7 @@ class P {
1584
1622
  return this.currentQuery.queries.find((t) => this.isQueryGroup(t) && t.groupKey === e);
1585
1623
  }
1586
1624
  getQuery() {
1587
- return y(this.currentQuery);
1625
+ return m(this.currentQuery);
1588
1626
  }
1589
1627
  hasQueryGroup(e) {
1590
1628
  return this.currentQuery.queries.some((t) => this.isQueryGroup(t) && t.groupKey === e);
@@ -1600,7 +1638,7 @@ class P {
1600
1638
  }
1601
1639
  validate(e) {
1602
1640
  const t = e.queries.map((s) => this.validateQuery(s));
1603
- return { valid: B(t, (s) => s.valid), errors: t.map((s) => s.errors).flat() };
1641
+ return { valid: T(t, (s) => s.valid), errors: t.map((s) => s.errors).flat() };
1604
1642
  }
1605
1643
  applyOptions(e, t = "update") {
1606
1644
  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();
@@ -1682,7 +1720,7 @@ class P {
1682
1720
  (s) => this.isQueryGroup(s) && s.groupKey === e.attribute
1683
1721
  );
1684
1722
  if (r > -1) {
1685
- const s = t.queries[r], i = C(s.queries, e);
1723
+ const s = t.queries[r], i = E(s.queries, e);
1686
1724
  i > -1 && s.queries.splice(i, 1), s.queries.length === 0 && t.queries.splice(r, 1);
1687
1725
  }
1688
1726
  } else if (this.isQueryGroup(e)) {
@@ -1695,7 +1733,7 @@ class P {
1695
1733
  else {
1696
1734
  const s = t.queries[r];
1697
1735
  for (const i of e.queries) {
1698
- const n = C(s.queries, i);
1736
+ const n = E(s.queries, i);
1699
1737
  n > -1 && s.queries.splice(n, 1);
1700
1738
  }
1701
1739
  s.queries.length === 0 && t.queries.splice(r, 1);
@@ -2210,48 +2248,48 @@ class P {
2210
2248
  return e(this.currentQuery.queries);
2211
2249
  }
2212
2250
  }
2213
- const S = new P();
2214
- function Be(o, e, t, r, s, i, n) {
2215
- const a = [], u = S.removeQuery({ groupKey: s }, y(r)), c = n.queryData(o, u, !1, i), f = e ? [...e.keys()] : [], d = new Set(f), l = i.get(s);
2251
+ const I = new R();
2252
+ function Te(o, e, t, r, s, i, n) {
2253
+ const a = [], u = I.removeQuery({ groupKey: s }, m(r)), f = n.queryData(o, u, !1, i), c = e ? [...e.keys()] : [], d = new Set(c), l = i.get(s);
2216
2254
  if (!t.excludeUnresolved)
2217
2255
  for (const h of l.keys())
2218
2256
  d.add(h);
2219
2257
  t.excludeUndefineds ? d.delete(void 0) : d.add(void 0);
2220
2258
  for (const h of d.values()) {
2221
- const A = /* @__PURE__ */ new Map(), _ = l.get(h) || /* @__PURE__ */ new Set();
2222
- for (const N of _) {
2223
- const k = c.get(N);
2224
- if (k && (A.set(N, k), !t?.calculateFacets))
2259
+ const b = /* @__PURE__ */ new Map(), W = l.get(h) || /* @__PURE__ */ new Set();
2260
+ for (const k of W) {
2261
+ const C = f.get(k);
2262
+ if (C && (b.set(k, C), !t?.calculateFacets))
2225
2263
  break;
2226
2264
  }
2227
- const M = {
2265
+ const N = {
2228
2266
  key: String(h),
2229
2267
  value: h,
2230
- selected: ye(s, h, r),
2231
- enabled: A.size > 0,
2232
- size: A.size,
2268
+ selected: me(s, h, r),
2269
+ enabled: b.size > 0,
2270
+ size: b.size,
2233
2271
  entry: e.get(h),
2234
- resultKeys: Array.from(A.keys())
2272
+ resultKeys: Array.from(b.keys())
2235
2273
  };
2236
- if (!(t?.excludeZeros && M.size === 0)) {
2274
+ if (!(t?.excludeZeros && N.size === 0)) {
2237
2275
  if (t?.count && a.length === t?.count)
2238
2276
  return a;
2239
- a.push(M);
2277
+ a.push(N);
2240
2278
  }
2241
2279
  }
2242
2280
  return a;
2243
2281
  }
2244
- const ye = (o, e, t) => {
2245
- const r = t.queries.findIndex((s) => S.isQueryGroup(s) && s.groupKey === o);
2282
+ const me = (o, e, t) => {
2283
+ const r = t.queries.findIndex((s) => I.isQueryGroup(s) && s.groupKey === o);
2246
2284
  return r > -1 ? !!t.queries[r].queries.find((i) => {
2247
- if (S.isQuery(i)) {
2285
+ if (I.isQuery(i)) {
2248
2286
  const n = i.value?.key || i.value;
2249
2287
  return i.attribute === o && n === e;
2250
2288
  }
2251
2289
  return !1;
2252
2290
  }) : !1;
2253
2291
  };
2254
- class me {
2292
+ class ve {
2255
2293
  indexMap = /* @__PURE__ */ new Map();
2256
2294
  // Possible performance gain*
2257
2295
  dataMap = /* @__PURE__ */ new Map();
@@ -2321,16 +2359,16 @@ class me {
2321
2359
  if (!i) {
2322
2360
  this.reset(s), this.indexMap.set(s, /* @__PURE__ */ new Map());
2323
2361
  const u = g.parse(e).isDeepQuery;
2324
- for (const c of t.values()) {
2325
- const f = u ? v(c, e) : c[e];
2326
- this.fillInverseIndex(s, c.key, [f]), this.fillDataMap(s, [f]);
2362
+ for (const f of t.values()) {
2363
+ let c;
2364
+ u && e.includes("[*]") ? (c = A(f, e), c.length === 0 && (c = [void 0])) : u ? c = [y(f, e)] : c = [f[e]], this.fillInverseIndex(s, f.key, c), this.fillDataMap(s, c);
2327
2365
  }
2328
2366
  i = this.getIndex(s) || /* @__PURE__ */ new Map();
2329
2367
  }
2330
2368
  return i;
2331
2369
  }
2332
2370
  getIndexName(e, t) {
2333
- return t ? e + "_" + I(t) : e;
2371
+ return t ? e + "_" + Q(t) : e;
2334
2372
  }
2335
2373
  // ========== PARTIAL UPDATE METHODS ==========
2336
2374
  /**
@@ -2499,8 +2537,8 @@ class me {
2499
2537
  };
2500
2538
  }
2501
2539
  }
2502
- const m = "__";
2503
- function R(o, e, t = { key: "root" }, r = "root", s = new me(), i) {
2540
+ const v = "__";
2541
+ function z(o, e, t = { key: "root" }, r = "root", s = new ve(), i) {
2504
2542
  const n = i || o;
2505
2543
  for (const a of e.columns)
2506
2544
  a.attribute && (g.parse(a.attribute), s.getOrCreateIndex(a.attribute, n));
@@ -2510,93 +2548,93 @@ function R(o, e, t = { key: "root" }, r = "root", s = new me(), i) {
2510
2548
  a.attribute && (g.parse(a.attribute), s.getOrCreateIndex(a.attribute, n));
2511
2549
  if (e.rows && e.rows.length > 0) {
2512
2550
  t.rows = t.rows || [];
2513
- const a = ve(o, e.rows[0], e, s, r, i);
2551
+ const a = we(o, e.rows[0], e, s, r, i);
2514
2552
  t.rows.push(a);
2515
2553
  }
2516
2554
  if (e.columns && e.columns.length > 0) {
2517
2555
  t.columns = t.columns || [];
2518
- const a = z(o, e.columns[0], e, s, r, i);
2556
+ const a = _(o, e.columns[0], e, s, r, i);
2519
2557
  t.columns.push(a);
2520
2558
  }
2521
2559
  if (t.key === "root")
2522
2560
  for (const a of e.values) {
2523
2561
  if (t.values = t.values || [], r === "root" && e.options?.calculateTotals === !1)
2524
2562
  continue;
2525
- const u = Q(a, o, s.getIndex(a.attribute), a.attribute);
2563
+ const u = M(a, o, s.getIndex(a.attribute), a.attribute);
2526
2564
  t.values.push(u);
2527
2565
  }
2528
2566
  return t;
2529
2567
  }
2530
- function ve(o, e, t, r, s = "", i) {
2568
+ function we(o, e, t, r, s = "", i) {
2531
2569
  const n = { key: e.attribute }, a = r.getIndex(e.attribute);
2532
2570
  if (!a)
2533
2571
  return n;
2534
- for (const [u, c] of a.entries()) {
2535
- const f = {
2572
+ for (const [u, f] of a.entries()) {
2573
+ const c = {
2536
2574
  key: u,
2537
2575
  value: u
2538
2576
  }, d = /* @__PURE__ */ new Map();
2539
- for (const l of c)
2577
+ for (const l of f)
2540
2578
  o.has(l) && d.set(l, o.get(l));
2541
2579
  if (d.size) {
2542
2580
  for (const l of t.values) {
2543
- if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
2581
+ if (c.values = c.values || [], s === "root" && e?.calculateTotals === !1)
2544
2582
  continue;
2545
- const h = Q(l, d, r.getIndex(l.attribute), l.attribute);
2546
- f.values.push(h);
2583
+ const h = M(l, d, r.getIndex(l.attribute), l.attribute);
2584
+ c.values.push(h);
2547
2585
  }
2548
- if (n.rows = n.rows || [], n.rows.push(f), t.rows.length > 1) {
2586
+ if (n.rows = n.rows || [], n.rows.push(c), t.rows.length > 1) {
2549
2587
  const l = { ...t, rows: t.rows.slice(1) };
2550
- R(
2588
+ z(
2551
2589
  d,
2552
2590
  l,
2553
- f,
2554
- s + m + e.attribute + m + u,
2591
+ c,
2592
+ s + v + e.attribute + v + u,
2555
2593
  r,
2556
2594
  i
2557
2595
  );
2558
2596
  } else if (t.columns)
2559
2597
  for (const l of t.columns) {
2560
- f.columns = f.columns || [];
2561
- const h = z(
2598
+ c.columns = c.columns || [];
2599
+ const h = _(
2562
2600
  d,
2563
2601
  l,
2564
2602
  t,
2565
2603
  r,
2566
- s + m + e.attribute + m + u,
2604
+ s + v + e.attribute + v + u,
2567
2605
  i
2568
2606
  );
2569
- f.columns.push(h);
2607
+ c.columns.push(h);
2570
2608
  }
2571
2609
  }
2572
2610
  }
2573
2611
  return n;
2574
2612
  }
2575
- function z(o, e, t, r, s = "", i) {
2613
+ function _(o, e, t, r, s = "", i) {
2576
2614
  const n = { key: e.attribute }, a = r.getIndex(e.attribute);
2577
2615
  if (!a)
2578
2616
  return n;
2579
- for (const [u, c] of a.entries()) {
2580
- const f = {
2617
+ for (const [u, f] of a.entries()) {
2618
+ const c = {
2581
2619
  key: u,
2582
2620
  value: u
2583
2621
  }, d = /* @__PURE__ */ new Map();
2584
- for (const l of c)
2622
+ for (const l of f)
2585
2623
  o.has(l) && d.set(l, o.get(l));
2586
2624
  if (d.size) {
2587
2625
  for (const l of t.values) {
2588
- if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
2626
+ if (c.values = c.values || [], s === "root" && e?.calculateTotals === !1)
2589
2627
  continue;
2590
- const h = Q(l, d, r.getIndex(l.attribute), l.attribute);
2591
- f.values.push(h);
2628
+ const h = M(l, d, r.getIndex(l.attribute), l.attribute);
2629
+ c.values.push(h);
2592
2630
  }
2593
- if (n.columns = n.columns || [], n.columns.push(f), t.columns.length > 1) {
2631
+ if (n.columns = n.columns || [], n.columns.push(c), t.columns.length > 1) {
2594
2632
  const l = { ...t, columns: t.columns.slice(1) };
2595
- R(
2633
+ z(
2596
2634
  d,
2597
2635
  l,
2598
- f,
2599
- s + m + e.attribute + m + u,
2636
+ c,
2637
+ s + v + e.attribute + v + u,
2600
2638
  r,
2601
2639
  i
2602
2640
  );
@@ -2605,11 +2643,11 @@ function z(o, e, t, r, s = "", i) {
2605
2643
  }
2606
2644
  return n;
2607
2645
  }
2608
- const Te = (o, e) => {
2646
+ const je = (o, e) => {
2609
2647
  const t = [];
2610
2648
  for (const r of o) {
2611
2649
  for (const [s, i] of Object.entries(r)) {
2612
- const n = t.find((u) => u.key === s), a = Ae(i);
2650
+ const n = t.find((u) => u.key === s), a = be(i);
2613
2651
  if (n)
2614
2652
  n.type !== a && (n.type = "any");
2615
2653
  else {
@@ -2624,21 +2662,21 @@ const Te = (o, e) => {
2624
2662
  break;
2625
2663
  }
2626
2664
  return t;
2627
- }, we = (o) => Number(o) === o && o % 1 === 0, xe = (o) => Number(o) === o && o % 1 !== 0, Ae = (o) => {
2665
+ }, xe = (o) => Number(o) === o && o % 1 === 0, Ae = (o) => Number(o) === o && o % 1 !== 0, be = (o) => {
2628
2666
  switch (typeof o) {
2629
2667
  case "string":
2630
2668
  return "string";
2631
2669
  case "number":
2632
- return we(o) ? "int" : xe(o) ? "float" : "any";
2670
+ return xe(o) ? "int" : Ae(o) ? "float" : "any";
2633
2671
  case "boolean":
2634
2672
  return "boolean";
2635
2673
  case "object":
2636
- return re(o) ? "date" : "json";
2674
+ return se(o) ? "date" : "json";
2637
2675
  default:
2638
2676
  return "any";
2639
2677
  }
2640
- }, je = (o, e) => {
2641
- const t = ee(o.text || ""), r = e?.attributeKey || o.filterKey;
2678
+ }, Pe = (o, e) => {
2679
+ const t = te(o.text || ""), r = e?.attributeKey || o.filterKey;
2642
2680
  let s;
2643
2681
  const i = e?.comparisonType || "containsIgnoreCase";
2644
2682
  return i === "containsIgnoreCase" ? s = {
@@ -2701,7 +2739,7 @@ const Te = (o, e) => {
2701
2739
  }
2702
2740
  ]
2703
2741
  }), s;
2704
- }, Pe = (o, e) => {
2742
+ }, Re = (o, e) => {
2705
2743
  const t = e?.attributeKey || o.filterKey;
2706
2744
  return {
2707
2745
  groupKey: o.filterKey,
@@ -2714,7 +2752,7 @@ const Te = (o, e) => {
2714
2752
  }
2715
2753
  ]
2716
2754
  };
2717
- }, Re = (o, e) => {
2755
+ }, ze = (o, e) => {
2718
2756
  const t = e?.attributeKey || o.filterKey, r = {
2719
2757
  groupKey: o.filterKey,
2720
2758
  queries: []
@@ -2729,7 +2767,7 @@ const Te = (o, e) => {
2729
2767
  operator: "eq",
2730
2768
  options: { invert: !0 }
2731
2769
  })), 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;
2732
- }, ze = (o, e) => {
2770
+ }, _e = (o, e) => {
2733
2771
  const t = e?.attributeKey || o.filterKey, r = {
2734
2772
  groupKey: o.filterKey,
2735
2773
  queries: []
@@ -2742,13 +2780,13 @@ const Te = (o, e) => {
2742
2780
  operator: "eq"
2743
2781
  });
2744
2782
  }), r;
2745
- }, _e = (o) => !(typeof o.modelKey != "string" || !Array.isArray(o.queries));
2746
- class We {
2783
+ }, We = (o) => !(typeof o.modelKey != "string" || !Array.isArray(o.queries));
2784
+ class Le {
2747
2785
  constructor(e, t, r) {
2748
2786
  this.scriptController = e, this.globalItemService = t, this.modelParser = r;
2749
2787
  }
2750
2788
  registeredCustomOperator = /* @__PURE__ */ new Map();
2751
- queryBuilder = new P();
2789
+ queryBuilder = new R();
2752
2790
  registerCustomOperator(e, t) {
2753
2791
  this.registeredCustomOperator.set(e, t);
2754
2792
  }
@@ -2764,11 +2802,11 @@ class We {
2764
2802
  evaluateQuery(e, t) {
2765
2803
  let r, s = e.value;
2766
2804
  const i = e.options?.arrayValueHandling || "some";
2767
- 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 = v(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))
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 = y(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))
2768
2806
  return !1;
2769
2807
  switch (e.operator) {
2770
2808
  case "eq":
2771
- return e.options?.invert ? !E(r, s) : E(r, s);
2809
+ return e.options?.invert ? !O(r, s) : O(r, s);
2772
2810
  case "find":
2773
2811
  return e.options?.invert ? !this.queryFind(r, s, i) : this.queryFind(r, s, i);
2774
2812
  case "lt":
@@ -2784,7 +2822,7 @@ class We {
2784
2822
  case "isTruthy":
2785
2823
  return s === !0 ? Array.isArray(r) ? i === "some" ? r.some((n) => typeof !!n) : r.every((n) => typeof !!n) : !!r : !r;
2786
2824
  case "size":
2787
- return typeof r == "string" ? r.length === s : W(r) === s;
2825
+ return typeof r == "string" ? r.length === s : L(r) === s;
2788
2826
  default:
2789
2827
  if (this.scriptController.hasScript(e.operator))
2790
2828
  return this.scriptController.executeScript(e.operator, "operator", { query: e, item: t });
@@ -2803,25 +2841,25 @@ class We {
2803
2841
  if (typeof t.value == "string" ? a = t.value : t.value?.key && Object.keys(t.value).length === 1 && (a = t.value.key), typeof a < "u") {
2804
2842
  const u = n.get(a);
2805
2843
  if (u)
2806
- if (u.forEach((c) => {
2807
- r.has(c) && i.set(c, r.get(c));
2844
+ if (u.forEach((f) => {
2845
+ r.has(f) && i.set(f, r.get(f));
2808
2846
  }), t.options?.invert) {
2809
- const c = q(Array.from(r.values()), Array.from(i.values()), "key"), f = /* @__PURE__ */ new Map();
2810
- return c.forEach((d) => {
2811
- f.set(d.key, d);
2812
- }), f;
2847
+ const f = q(Array.from(r.values()), Array.from(i.values()), "key"), c = /* @__PURE__ */ new Map();
2848
+ return f.forEach((d) => {
2849
+ c.set(d.key, d);
2850
+ }), c;
2813
2851
  } else
2814
2852
  return i;
2815
2853
  }
2816
2854
  }
2817
2855
  for (let [a, u] of r) {
2818
- const c = this.queryBuilder.extractQueryAttributes({ queries: [t] });
2819
- if (c.some((f) => f.isDeepQuery)) {
2820
- const f = this.queryBuilder.getProjectionForAttributeEntries(
2821
- c.filter((d) => d.isDeepQuery)
2856
+ const f = this.queryBuilder.extractQueryAttributes({ queries: [t] });
2857
+ if (f.some((c) => c.isDeepQuery)) {
2858
+ const c = this.queryBuilder.getProjectionForAttributeEntries(
2859
+ f.filter((d) => d.isDeepQuery)
2822
2860
  );
2823
2861
  u = this.globalItemService.getProjectedData(
2824
- f,
2862
+ c,
2825
2863
  this.modelParser.models.get(e.modelKey),
2826
2864
  u
2827
2865
  );
@@ -2831,16 +2869,16 @@ class We {
2831
2869
  return i;
2832
2870
  }
2833
2871
  equalRegexFn(e, t) {
2834
- if (typeof t == "string" && L(t, "/") && H(t, "/"))
2872
+ if (typeof t == "string" && H(t, "/") && U(t, "/"))
2835
2873
  try {
2836
2874
  return new RegExp(t.slice(1, -1)).test(e);
2837
2875
  } catch {
2838
2876
  return !1;
2839
2877
  }
2840
- else return Array.isArray(e) ? !!e.find((r) => b(r, t, this.equalRegexFn)) : typeof t == "object" ? U(e, t) : e === t;
2878
+ else return Array.isArray(e) ? !!e.find((r) => D(r, t, this.equalRegexFn)) : typeof t == "object" ? V(e, t) : e === t;
2841
2879
  }
2842
2880
  queryFind(e, t, r) {
2843
- 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)) : !!V(e, t) : b(e, t, this.equalRegexFn);
2881
+ return Array.isArray(e) ? typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? r === "some" ? e.some((s) => D(s, t, this.equalRegexFn)) : e.every((s) => D(s, t, this.equalRegexFn)) : !!J(e, t) : D(e, t, this.equalRegexFn);
2844
2882
  }
2845
2883
  validateQuery(e) {
2846
2884
  if (this.queryBuilder.isQuery(e)) {
@@ -2851,40 +2889,51 @@ class We {
2851
2889
  return !0;
2852
2890
  } else {
2853
2891
  if (this.queryBuilder.isQueryGroup(e))
2854
- return B(e.queries, (t) => this.validateQuery(t));
2892
+ return T(e.queries, (t) => this.validateQuery(t));
2855
2893
  throw new Error("invalid query - missing query or attribute");
2856
2894
  }
2857
2895
  }
2858
2896
  getEvaluatedQueryDataset(e, t, r, s) {
2859
2897
  const i = /* @__PURE__ */ new Map();
2860
- if (t.attribute.includes("[*]"))
2861
- for (let n of r.values()) {
2862
- const a = this.queryBuilder.extractQueryAttributes({ queries: [t] });
2863
- if (a.some((c) => c.isDeepQuery)) {
2864
- const c = this.queryBuilder.getProjectionForAttributeEntries(
2865
- a.filter((f) => f.isDeepQuery)
2898
+ if (t.attribute.includes("[*]")) {
2899
+ const n = t.options?.invert === !0, a = /* @__PURE__ */ new Set();
2900
+ for (let u of r.values()) {
2901
+ const f = this.queryBuilder.extractQueryAttributes({ queries: [t] });
2902
+ if (f.some((l) => l.isDeepQuery)) {
2903
+ const l = this.queryBuilder.getProjectionForAttributeEntries(
2904
+ f.filter((h) => h.isDeepQuery)
2866
2905
  );
2867
- n = this.globalItemService.getProjectedData(
2868
- c,
2906
+ u = this.globalItemService.getProjectedData(
2907
+ l,
2869
2908
  this.modelParser.models.get(e.modelKey),
2870
- n
2909
+ u
2871
2910
  );
2872
2911
  }
2873
- const u = this.handleArrayStarQuery(t, n);
2874
- for (const c of u.queries)
2875
- this.evaluateQuery(c, n) && i.set(n.key, n);
2912
+ const c = this.handleArrayStarQuery(t, u);
2913
+ let d = !1;
2914
+ for (const l of c.queries) {
2915
+ const h = { ...l, options: { ...l.options, invert: !1 } };
2916
+ if (this.evaluateQuery(h, u)) {
2917
+ d = !0;
2918
+ break;
2919
+ }
2920
+ }
2921
+ d && (a.add(u.key), n || i.set(u.key, u));
2876
2922
  }
2877
- else {
2923
+ if (n)
2924
+ for (const [u, f] of r)
2925
+ a.has(u) || i.set(u, f);
2926
+ } else {
2878
2927
  if (t.operator === "eq")
2879
2928
  return this.evaluateEqOperator(e, t, r, s);
2880
2929
  for (let [n, a] of r) {
2881
2930
  const u = this.queryBuilder.extractQueryAttributes({ queries: [t] });
2882
- if (u.some((c) => c.isDeepQuery)) {
2883
- const c = this.queryBuilder.getProjectionForAttributeEntries(
2884
- u.filter((f) => f.isDeepQuery)
2931
+ if (u.some((f) => f.isDeepQuery)) {
2932
+ const f = this.queryBuilder.getProjectionForAttributeEntries(
2933
+ u.filter((c) => c.isDeepQuery)
2885
2934
  );
2886
2935
  a = this.globalItemService.getProjectedData(
2887
- c,
2936
+ f,
2888
2937
  this.modelParser.models.get(e.modelKey),
2889
2938
  a
2890
2939
  );
@@ -2901,14 +2950,15 @@ class We {
2901
2950
  queries: []
2902
2951
  };
2903
2952
  if (r !== -1) {
2904
- const i = e.attribute.substring(0, r), n = t[i];
2953
+ const i = e.attribute.substring(0, r), n = i.includes(".") ? y(t, i) : t[i];
2905
2954
  if (Array.isArray(n))
2906
2955
  for (let a = 0; a < n.length; a++) {
2907
2956
  const u = e.attribute.replace("[*]", `[${a}]`);
2908
2957
  s.queries.push({
2909
2958
  attribute: u,
2910
2959
  operator: e.operator,
2911
- value: e.value
2960
+ value: e.value,
2961
+ options: e.options
2912
2962
  });
2913
2963
  }
2914
2964
  }
@@ -2919,14 +2969,14 @@ class We {
2919
2969
  if (!t.queries || t.queries?.length === 0)
2920
2970
  return a;
2921
2971
  for (const u of t.queries) {
2922
- let c = /* @__PURE__ */ new Map();
2923
- if (this.queryBuilder.isQuery(u) ? c = this.getEvaluatedQueryDataset(e, u, a, i) : c = this.evaluateQueryGroup(e, u, a, s, i), n.size === 0 && (n = c), t.groupType === "or")
2924
- c.forEach((f) => {
2925
- n.set(f.key, f);
2972
+ let f = /* @__PURE__ */ new Map();
2973
+ if (this.queryBuilder.isQuery(u) ? f = this.getEvaluatedQueryDataset(e, u, a, i) : f = this.evaluateQueryGroup(e, u, a, s, i), n.size === 0 && (n = f), t.groupType === "or")
2974
+ f.forEach((c) => {
2975
+ n.set(c.key, c);
2926
2976
  });
2927
2977
  else {
2928
- const f = q(Array.from(n.values()), Array.from(c.values()), "key");
2929
- for (const d of f)
2978
+ const c = q(Array.from(n.values()), Array.from(f.values()), "key");
2979
+ for (const d of c)
2930
2980
  n.delete(d.key);
2931
2981
  }
2932
2982
  t.groupType === "and" ? a = n : a = r;
@@ -2971,7 +3021,7 @@ class We {
2971
3021
  // }
2972
3022
  // }
2973
3023
  }
2974
- class Le {
3024
+ class He {
2975
3025
  scripts = /* @__PURE__ */ new Map();
2976
3026
  scriptFunctions = /* @__PURE__ */ new Map();
2977
3027
  constructor() {
@@ -3014,10 +3064,10 @@ class Le {
3014
3064
  return this.getScriptAsFn(e, i)(t, ...n);
3015
3065
  }
3016
3066
  }
3017
- const He = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => v(e, r.trim(), ""))) : "", Ue = (o) => {
3067
+ const Ue = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => y(e, r.trim(), ""))) : "", Ve = (o) => {
3018
3068
  const e = /* @__PURE__ */ new Set();
3019
3069
  return o.replace(/\$\{(.*?)\}/g, (r, s) => (e.add(s.trim()), "")), { variables: Array.from(e).map((r) => ({ name: r })) };
3020
- }, Ve = [
3070
+ }, Je = [
3021
3071
  "any",
3022
3072
  "Array<date>",
3023
3073
  "Array<float>",
@@ -3029,7 +3079,7 @@ const He = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => v(e
3029
3079
  "int",
3030
3080
  "json",
3031
3081
  "string"
3032
- ], Je = ["int", "float", "Array<int>", "Array<float>"], Ze = ["date", "Array<date>"], Ye = [
3082
+ ], Ze = ["int", "float", "Array<int>", "Array<float>"], Ye = ["date", "Array<date>"], Xe = [
3033
3083
  "eq",
3034
3084
  "find",
3035
3085
  "gt",
@@ -3041,56 +3091,57 @@ const He = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => v(e
3041
3091
  "size"
3042
3092
  ];
3043
3093
  export {
3044
- De as AnalyticsController,
3045
- Ke as AttributeDependencyGraph,
3046
- Se as CacheController,
3047
- Oe as ChangeDetector,
3048
- Ze as DatePropertyTypes,
3049
- P as DcuplQueryBuilder,
3050
- Ye as DcuplQueryOperatorsAsArray,
3051
- fe as DeepQueryService,
3052
- Z as DependencyGraph,
3053
- me as IndicesController,
3094
+ Ke as AnalyticsController,
3095
+ Se as AttributeDependencyGraph,
3096
+ Ie as CacheController,
3097
+ $e as ChangeDetector,
3098
+ Ye as DatePropertyTypes,
3099
+ R as DcuplQueryBuilder,
3100
+ Xe as DcuplQueryOperatorsAsArray,
3101
+ de as DeepQueryService,
3102
+ Y as DependencyGraph,
3103
+ ve as IndicesController,
3054
3104
  p as Logger,
3055
- Je as NumberPropertyTypes,
3056
- Ve as PropertyTypesAsArray,
3057
- We as QueryManager,
3058
- Le as ScriptController,
3059
- j as clone,
3060
- te as compareVersions,
3061
- Fe as computeSuggestions,
3105
+ Ze as NumberPropertyTypes,
3106
+ Je as PropertyTypesAsArray,
3107
+ Le as QueryManager,
3108
+ He as ScriptController,
3109
+ P as clone,
3110
+ re as compareVersions,
3111
+ Ge as computeSuggestions,
3062
3112
  g as deepQueryService,
3063
- ee as escapeRegExp,
3064
- He as evaluateTemplate,
3065
- Pe as generateBooleanQuery,
3066
- X as generateKey,
3067
- Re as generateNumberAndDateQuery,
3068
- ze as generateReferenceQuery,
3069
- je as generateTextQuery,
3070
- Q as getAggregation,
3071
- Me as getDateConstraintUid,
3072
- Ae as getDcuplPropertyTypeForNativeType,
3073
- ge as getDistinct,
3074
- Be as getFacets,
3075
- Ie as getFilterEntryId,
3076
- Qe as getNumberConstraintUid,
3077
- Te as getPropertiesForData,
3078
- ke as groupBy,
3113
+ te as escapeRegExp,
3114
+ Ue as evaluateTemplate,
3115
+ Re as generateBooleanQuery,
3116
+ ee as generateKey,
3117
+ ze as generateNumberAndDateQuery,
3118
+ _e as generateReferenceQuery,
3119
+ Pe as generateTextQuery,
3120
+ M as getAggregation,
3121
+ Ne as getDateConstraintUid,
3122
+ be as getDcuplPropertyTypeForNativeType,
3123
+ A as getDeepPathValues,
3124
+ ye as getDistinct,
3125
+ Te as getFacets,
3126
+ Qe as getFilterEntryId,
3127
+ Me as getNumberConstraintUid,
3128
+ je as getPropertiesForData,
3129
+ Ce as groupBy,
3079
3130
  qe as hasMinimumVersion,
3080
- re as isDateInstance,
3081
- xe as isFloat,
3082
- we as isInt,
3083
- se as isValidDate,
3084
- _e as isValidQueryStatement,
3085
- $ as isValidVersion,
3086
- Y as logger,
3087
- Ge as parseDate,
3088
- Ue as parseTemplate,
3131
+ se as isDateInstance,
3132
+ Ae as isFloat,
3133
+ xe as isInt,
3134
+ ne as isValidDate,
3135
+ We as isValidQueryStatement,
3136
+ F as isValidVersion,
3137
+ X as logger,
3138
+ Be as parseDate,
3139
+ Ve as parseTemplate,
3089
3140
  x as perf,
3090
- R as pivot,
3091
- Ce as removeTrailingSlash,
3092
- $e as trigger,
3093
- Ee as unescapeRegExp,
3094
- Ne as uniqBy
3141
+ z as pivot,
3142
+ Ee as removeTrailingSlash,
3143
+ Fe as trigger,
3144
+ Oe as unescapeRegExp,
3145
+ ke as uniqBy
3095
3146
  };
3096
3147
  //# sourceMappingURL=index.js.map