@dcupl/common 2.0.0-beta.11 → 2.0.0-beta.13

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.
@@ -18,6 +18,7 @@ export * from './query-builder.js';
18
18
  export * from './query.helper.js';
19
19
  export * from './queryData.js';
20
20
  export * from './resource-id.js';
21
+ export * from './scheduling.js';
21
22
  export * from './script.controller.js';
22
23
  export * from './template-parser.js';
23
24
  export * from './types/index.js';
package/dist/esm/index.js CHANGED
@@ -41,7 +41,7 @@ const b = {
41
41
  return performance.getEntriesByType(n);
42
42
  }
43
43
  };
44
- class Re {
44
+ class Te {
45
45
  data;
46
46
  enabled = !1;
47
47
  constructor() {
@@ -408,7 +408,7 @@ let X = class _ {
408
408
  return { addedNodes: s, removedNodes: i, addedEdges: c, removedEdges: u, kindChanges: f };
409
409
  }
410
410
  };
411
- class Te {
411
+ class Re {
412
412
  graph;
413
413
  nodeIndex;
414
414
  constructor() {
@@ -940,7 +940,7 @@ class Ge {
940
940
  };
941
941
  }
942
942
  }
943
- const ze = (n, e = "") => `${n}#${e}`, _e = (n) => `${n.gt}_${n.gte}_${n.lt}_${n.lte}_${n.eq}_${n.ne}`, Be = (n) => `${n.gt}_${n.gte}_${n.lt}_${n.lte}_${n.eq}_${n.ne}`, je = (n, e) => {
943
+ const ze = (n, e = "") => `${n}#${e}`, _e = (n) => `${n.gt}_${n.gte}_${n.lt}_${n.lte}_${n.eq}_${n.ne}`, Pe = (n) => `${n.gt}_${n.gte}_${n.lt}_${n.lte}_${n.eq}_${n.ne}`, Be = (n, e) => {
944
944
  const t = typeof e == "function" ? e : (r) => r[e];
945
945
  return [
946
946
  ...n.reduce((r, s) => {
@@ -948,7 +948,7 @@ const ze = (n, e = "") => `${n}#${e}`, _e = (n) => `${n.gt}_${n.gte}_${n.lt}_${n
948
948
  return r.has(i) || r.set(i, s), r;
949
949
  }, /* @__PURE__ */ new Map()).values()
950
950
  ];
951
- }, Pe = (n, e) => n.reduce(function(t, r) {
951
+ }, je = (n, e) => n.reduce(function(t, r) {
952
952
  const s = typeof e == "function" ? e(r) : r[e];
953
953
  return Object.prototype.hasOwnProperty.call(t, s) || (t[s] = []), t[s].push(r), t;
954
954
  }, {});
@@ -1011,9 +1011,9 @@ class Ue {
1011
1011
  };
1012
1012
  }
1013
1013
  }
1014
- const B = (n, e) => e ? typeof structuredClone < "u" ? structuredClone(n) : v(n) : n, R = (n, e, t, r, s, i) => {
1014
+ const P = (n, e) => e ? typeof structuredClone < "u" ? structuredClone(n) : v(n) : n, T = (n, e, t, r, s, i) => {
1015
1015
  try {
1016
- const o = !!e.dcuplInitOptions.performance?.clone?.enabled && !!t.cloneResult, a = B(i, o);
1016
+ const o = !!e.dcuplInitOptions.performance?.clone?.enabled && !!t.cloneResult, a = P(i, o);
1017
1017
  if (t.scope === "list" && (t.listKey = n.cdRef?.key || n.key, t.modelKey = n.model?.key || n.modelKey), t.type === "list_created" && t.args[0].listKey.startsWith("__global_list__") || t.listKey?.startsWith("__global_list__"))
1018
1018
  return a;
1019
1019
  const c = b.now(), u = c - r, f = Math.round(u * 1e3) / 1e3;
@@ -1037,7 +1037,7 @@ const B = (n, e) => e ? typeof structuredClone < "u" ? structuredClone(n) : v(n)
1037
1037
  }, Ve = (n) => (t, r, s) => {
1038
1038
  const i = s.value;
1039
1039
  return s.value = function(...o) {
1040
- const a = b.now(), c = this.cdRef, u = B(n, !0);
1040
+ const a = b.now(), c = this.cdRef, u = P(n, !0);
1041
1041
  u.key || (c.increaseCounter(), u.key = c.getCounter());
1042
1042
  const f = ee();
1043
1043
  c.analyticsController.mark({
@@ -1047,7 +1047,7 @@ const B = (n, e) => e ? typeof structuredClone < "u" ? structuredClone(n) : v(n)
1047
1047
  const l = this.model?.key;
1048
1048
  !u.originCdRefKey && c.key && (u.originCdRefKey = c.key), l && (u.modelKey = l);
1049
1049
  const d = i.apply(this, o);
1050
- return u.method = r, u.args = o, d && typeof d == "object" && "then" in d ? d.then((h) => R(this, c, u, a, f, h)) : R(this, c, u, a, f, d);
1050
+ return u.method = r, u.args = o, d && typeof d == "object" && "then" in d ? d.then((h) => T(this, c, u, a, f, h)) : T(this, c, u, a, f, d);
1051
1051
  }, s;
1052
1052
  };
1053
1053
  function Je(n, e, t, r) {
@@ -1474,7 +1474,7 @@ function x(n, e) {
1474
1474
  else i !== void 0 && s.push(i);
1475
1475
  return s;
1476
1476
  }
1477
- function Q(n) {
1477
+ function M(n) {
1478
1478
  let e = 0;
1479
1479
  for (let t of n) {
1480
1480
  const r = t.toString().split(".")[1];
@@ -1482,7 +1482,7 @@ function Q(n) {
1482
1482
  }
1483
1483
  return Math.pow(10, e);
1484
1484
  }
1485
- function T(n, e, t) {
1485
+ function R(n, e, t) {
1486
1486
  return (n * t + e * t) / t;
1487
1487
  }
1488
1488
  function de(n, e, t) {
@@ -1570,11 +1570,11 @@ const C = (n, e, t, r) => {
1570
1570
  for (const u of c)
1571
1571
  if (Array.isArray(u))
1572
1572
  for (const f of u)
1573
- typeof f == "number" && (t = T(t, f, Q([t, f])), r++);
1574
- else typeof u == "number" && (t = T(t, u, Q([t, u])), r++);
1573
+ typeof f == "number" && (t = R(t, f, M([t, f])), r++);
1574
+ else typeof u == "number" && (t = R(t, u, M([t, u])), r++);
1575
1575
  }
1576
1576
  return r === 0 ? void 0 : {
1577
- average: de(t, r, Q([t, r])),
1577
+ average: de(t, r, M([t, r])),
1578
1578
  count: r,
1579
1579
  sum: t
1580
1580
  };
@@ -1598,7 +1598,7 @@ class A extends Error {
1598
1598
  super(r), this.query = t, this.name = "DcuplQueryError";
1599
1599
  }
1600
1600
  }
1601
- class j {
1601
+ class B {
1602
1602
  _defaultQueryOptions = {
1603
1603
  modelKey: "",
1604
1604
  groupKey: "root",
@@ -2279,7 +2279,7 @@ class j {
2279
2279
  return e(this.currentQuery.queries);
2280
2280
  }
2281
2281
  }
2282
- const N = new j();
2282
+ const N = new B();
2283
2283
  function Xe(n, e, t, r, s, i, o) {
2284
2284
  const a = N.removeQuery({ groupKey: s }, v(r)), c = o.queryData(n, a, !1, i), u = e ? [...e.keys()] : [], f = new Set(u), l = i.get(s) ?? /* @__PURE__ */ new Map();
2285
2285
  if (!t.excludeUnresolved)
@@ -2619,7 +2619,7 @@ class xe {
2619
2619
  }
2620
2620
  }
2621
2621
  const w = "__";
2622
- function P(n, e, t = { key: "root" }, r = "root", s = new xe(), i) {
2622
+ function j(n, e, t = { key: "root" }, r = "root", s = new xe(), i) {
2623
2623
  const o = i || n;
2624
2624
  for (const a of e.columns)
2625
2625
  a.attribute && (y.parse(a.attribute), s.getOrCreateIndex(a.attribute, o));
@@ -2666,7 +2666,7 @@ function Ae(n, e, t, r, s = "", i) {
2666
2666
  }
2667
2667
  if (o.rows = o.rows || [], o.rows.push(f), t.rows.length > 1) {
2668
2668
  const d = { ...t, rows: t.rows.slice(1) };
2669
- P(
2669
+ j(
2670
2670
  l,
2671
2671
  d,
2672
2672
  f,
@@ -2711,7 +2711,7 @@ function L(n, e, t, r, s = "", i) {
2711
2711
  }
2712
2712
  if (o.columns = o.columns || [], o.columns.push(f), t.columns.length > 1) {
2713
2713
  const d = { ...t, columns: t.columns.slice(1) };
2714
- P(
2714
+ j(
2715
2715
  l,
2716
2716
  d,
2717
2717
  f,
@@ -2724,7 +2724,7 @@ function L(n, e, t, r, s = "", i) {
2724
2724
  }
2725
2725
  return o;
2726
2726
  }
2727
- const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/, Se = /^-?\d+$/, De = /^-?\d+\.\d+$/, Ie = /^\d{1,2}([/.-])\d{1,2}\1\d{2,4}$/, Ke = (n) => n === "true" || n === "false" ? "boolean" : Se.test(n) ? "int" : De.test(n) ? "float" : be.test(n) && !Number.isNaN(Date.parse(n)) ? "date" : "string", Qe = (n) => Ie.test(n), Me = (n) => n == null || n === "", ke = (n) => {
2727
+ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/, Se = /^-?\d+$/, De = /^-?\d+\.\d+$/, Ie = /^\d{1,2}([/.-])\d{1,2}\1\d{2,4}$/, Ke = (n) => n === "true" || n === "false" ? "boolean" : Se.test(n) ? "int" : De.test(n) ? "float" : be.test(n) && !Number.isNaN(Date.parse(n)) ? "date" : "string", Me = (n) => Ie.test(n), Qe = (n) => n == null || n === "", ke = (n) => {
2728
2728
  const e = [...n];
2729
2729
  return e.length <= 1 ? { type: e[0] ?? "any", conflict: !1 } : e.every((t) => t === "int" || t === "float") ? { type: "float", conflict: !1 } : { type: "any", conflict: !0 };
2730
2730
  }, Ne = (n, e = {}) => {
@@ -2734,12 +2734,12 @@ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?
2734
2734
  if (l)
2735
2735
  for (const [d, h] of Object.entries(l)) {
2736
2736
  let g = i.get(d);
2737
- if (g || (g = { observed: /* @__PURE__ */ new Set(), empty: 0, scanned: 0 }, i.set(d, g), o.push(d)), g.scanned++, Me(h)) {
2737
+ if (g || (g = { observed: /* @__PURE__ */ new Set(), empty: 0, scanned: 0 }, i.set(d, g), o.push(d)), g.scanned++, Qe(h)) {
2738
2738
  g.empty++;
2739
2739
  continue;
2740
2740
  }
2741
2741
  let m;
2742
- typeof h == "string" && s ? (m = Ke(h), m === "string" && !g.hint && Qe(h) && (g.hint = "column looks date-like (non-ISO) — review manually")) : m = $e(h), g.observed.add(m);
2742
+ typeof h == "string" && s ? (m = Ke(h), m === "string" && !g.hint && Me(h) && (g.hint = "column looks date-like (non-ISO) — review manually")) : m = $e(h), g.observed.add(m);
2743
2743
  }
2744
2744
  }
2745
2745
  const c = [], u = [];
@@ -2882,7 +2882,7 @@ class it {
2882
2882
  globalItemService;
2883
2883
  modelParser;
2884
2884
  registeredCustomOperator = /* @__PURE__ */ new Map();
2885
- queryBuilder = new j();
2885
+ queryBuilder = new B();
2886
2886
  registerCustomOperator(e, t) {
2887
2887
  this.registeredCustomOperator.set(e, t);
2888
2888
  }
@@ -3120,7 +3120,7 @@ class it {
3120
3120
  // }
3121
3121
  }
3122
3122
  const Oe = "k:", qe = "h:";
3123
- function M(n, e = 0) {
3123
+ function Q(n, e = 0) {
3124
3124
  if (n.key)
3125
3125
  return `${Oe}${n.key}`;
3126
3126
  const t = K({
@@ -3135,13 +3135,22 @@ function ot(n) {
3135
3135
  const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
3136
3136
  return n.map((r) => {
3137
3137
  const s = `${r.key ?? ""}|${r.type}|${r.rawUrl ?? r.url}|${r.model ?? ""}`;
3138
- let i = e.get(s) ?? 0, o = M(r, i);
3138
+ let i = e.get(s) ?? 0, o = Q(r, i);
3139
3139
  for (; t.has(o); )
3140
- i += 1, o = r.key ? `${M(r)}#${i}` : M(r, i);
3140
+ i += 1, o = r.key ? `${Q(r)}#${i}` : Q(r, i);
3141
3141
  return e.set(s, i + 1), t.add(o), o;
3142
3142
  });
3143
3143
  }
3144
- class at {
3144
+ function at() {
3145
+ const n = globalThis;
3146
+ return typeof n.scheduler?.yield == "function" ? n.scheduler.yield() : typeof n.setImmediate == "function" ? new Promise((e) => n.setImmediate(() => e())) : typeof n.MessageChannel == "function" ? new Promise((e) => {
3147
+ const t = new n.MessageChannel();
3148
+ t.port1.onmessage = () => {
3149
+ t.port1.close(), e();
3150
+ }, t.port2.postMessage(null);
3151
+ }) : new Promise((e) => setTimeout(e, 0));
3152
+ }
3153
+ class ct {
3145
3154
  scripts = /* @__PURE__ */ new Map();
3146
3155
  scriptFunctions = /* @__PURE__ */ new Map();
3147
3156
  constructor() {
@@ -3184,10 +3193,10 @@ class at {
3184
3193
  return this.getScriptAsFn(e, i)(t, ...o);
3185
3194
  }
3186
3195
  }
3187
- const ct = (n, e) => n ? (e || (e = {}), n.replace(/\$\{(.*?)\}/g, (t, r) => I(e, r.trim(), ""))) : "", ut = (n) => {
3196
+ const ut = (n, e) => n ? (e || (e = {}), n.replace(/\$\{(.*?)\}/g, (t, r) => I(e, r.trim(), ""))) : "", ft = (n) => {
3188
3197
  const e = /* @__PURE__ */ new Set();
3189
3198
  return n.replace(/\$\{(.*?)\}/g, (r, s) => (e.add(s.trim()), "")), { variables: Array.from(e).map((r) => ({ name: r })) };
3190
- }, ft = [
3199
+ }, lt = [
3191
3200
  "any",
3192
3201
  "Array<date>",
3193
3202
  "Array<float>",
@@ -3199,7 +3208,7 @@ const ct = (n, e) => n ? (e || (e = {}), n.replace(/\$\{(.*?)\}/g, (t, r) => I(e
3199
3208
  "int",
3200
3209
  "json",
3201
3210
  "string"
3202
- ], lt = ["int", "float", "Array<int>", "Array<float>"], dt = ["date", "Array<date>"], ht = [
3211
+ ], dt = ["int", "float", "Array<int>", "Array<float>"], ht = ["date", "Array<date>"], pt = [
3203
3212
  "eq",
3204
3213
  "find",
3205
3214
  "gt",
@@ -3212,36 +3221,36 @@ const ct = (n, e) => n ? (e || (e = {}), n.replace(/\$\{(.*?)\}/g, (t, r) => I(e
3212
3221
  ];
3213
3222
  export {
3214
3223
  Oe as AUTHORED_RESOURCE_ID_PREFIX,
3215
- Re as AnalyticsController,
3216
- Te as AttributeDependencyGraph,
3224
+ Te as AnalyticsController,
3225
+ Re as AttributeDependencyGraph,
3217
3226
  Ge as CacheController,
3218
3227
  Ue as ChangeDetector,
3219
3228
  qe as DERIVED_RESOURCE_ID_PREFIX,
3220
- dt as DatePropertyTypes,
3221
- j as DcuplQueryBuilder,
3222
- ht as DcuplQueryOperatorsAsArray,
3229
+ ht as DatePropertyTypes,
3230
+ B as DcuplQueryBuilder,
3231
+ pt as DcuplQueryOperatorsAsArray,
3223
3232
  le as DeepQueryService,
3224
3233
  X as DependencyGraph,
3225
3234
  xe as IndicesController,
3226
3235
  p as Logger,
3227
- lt as NumberPropertyTypes,
3228
- ft as PropertyTypesAsArray,
3236
+ dt as NumberPropertyTypes,
3237
+ lt as PropertyTypesAsArray,
3229
3238
  it as QueryManager,
3230
- at as ScriptController,
3231
- B as clone,
3239
+ ct as ScriptController,
3240
+ P as clone,
3232
3241
  Ke as coerceStringType,
3233
3242
  re as compareVersions,
3234
3243
  Je as computeSuggestions,
3235
3244
  y as deepQueryService,
3236
3245
  te as escapeRegExp,
3237
- ct as evaluateTemplate,
3246
+ ut as evaluateTemplate,
3238
3247
  tt as generateBooleanQuery,
3239
3248
  ee as generateKey,
3240
3249
  rt as generateNumberAndDateQuery,
3241
3250
  st as generateReferenceQuery,
3242
3251
  et as generateTextQuery,
3243
3252
  C as getAggregation,
3244
- Be as getDateConstraintUid,
3253
+ Pe as getDateConstraintUid,
3245
3254
  $e as getDcuplPropertyTypeForNativeType,
3246
3255
  x as getDeepPathValues,
3247
3256
  me as getDistinct,
@@ -3249,7 +3258,7 @@ export {
3249
3258
  ze as getFilterEntryId,
3250
3259
  _e as getNumberConstraintUid,
3251
3260
  Ye as getPropertiesForData,
3252
- Pe as groupBy,
3261
+ je as groupBy,
3253
3262
  He as hasMinimumVersion,
3254
3263
  Ne as inferModel,
3255
3264
  se as isDateInstance,
@@ -3259,16 +3268,17 @@ export {
3259
3268
  nt as isValidQueryStatement,
3260
3269
  F as isValidVersion,
3261
3270
  Y as logger,
3262
- Qe as looksDateLike,
3271
+ Me as looksDateLike,
3263
3272
  Ze as parseDate,
3264
- ut as parseTemplate,
3273
+ ft as parseTemplate,
3265
3274
  b as perf,
3266
- P as pivot,
3275
+ j as pivot,
3267
3276
  Le as removeTrailingSlash,
3268
- M as resolveResourceId,
3277
+ Q as resolveResourceId,
3269
3278
  ot as resolveResourceIds,
3270
3279
  Ve as trigger,
3271
3280
  We as unescapeRegExp,
3272
- je as uniqBy
3281
+ Be as uniqBy,
3282
+ at as yieldToEventLoop
3273
3283
  };
3274
3284
  //# sourceMappingURL=index.js.map