@milaboratories/pl-model-common 1.13.1 → 1.13.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/index.mjs CHANGED
@@ -2,8 +2,8 @@ var $ = Object.defineProperty;
2
2
  var L = (n, t, e) => t in n ? $(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
3
  var p = (n, t, e) => L(n, typeof t != "symbol" ? t + "" : t, e);
4
4
  import g from "canonicalize";
5
- import { z as y } from "zod";
6
- function un(n) {
5
+ import { z as m } from "zod";
6
+ function cn(n) {
7
7
  return n !== void 0 && n.startsWith("log+live://log/");
8
8
  }
9
9
  function w(n) {
@@ -16,7 +16,7 @@ function V(n) {
16
16
  function D(n) {
17
17
  return n.startsWith(E);
18
18
  }
19
- function j(n) {
19
+ function I(n) {
20
20
  if (D(n)) {
21
21
  const t = n.slice(E.length);
22
22
  return JSON.parse(decodeURIComponent(t)).path;
@@ -26,11 +26,11 @@ function j(n) {
26
26
  }
27
27
  w(n);
28
28
  }
29
- function B(n) {
29
+ function j(n) {
30
30
  return n.replace(/^.*[\\/]/, "");
31
31
  }
32
32
  function fn(n) {
33
- return B(j(n));
33
+ return j(I(n));
34
34
  }
35
35
  function dn(n) {
36
36
  if (!n || typeof n != "object")
@@ -77,7 +77,7 @@ function pn(n, t) {
77
77
  }
78
78
  }
79
79
  }
80
- function yn(n) {
80
+ function mn(n) {
81
81
  if (!n || typeof n != "object")
82
82
  return !1;
83
83
  const t = n;
@@ -94,7 +94,7 @@ function yn(n) {
94
94
  return !1;
95
95
  }
96
96
  }
97
- function mn(n) {
97
+ function yn(n) {
98
98
  switch (n.type) {
99
99
  case "Json": {
100
100
  const t = Object.entries(n.data).map(([e, r]) => ({ key: JSON.parse(e), value: r }));
@@ -186,11 +186,11 @@ function hn(n, t) {
186
186
  }
187
187
  }
188
188
  }
189
- const I = -2147483648, A = -9007199254740991n, bn = NaN, gn = NaN, F = null, U = null;
189
+ const B = -2147483648, A = -9007199254740991n, bn = NaN, gn = NaN, F = null, U = null;
190
190
  function h(n, t) {
191
191
  switch (t) {
192
192
  case "Int":
193
- return n === I;
193
+ return n === B;
194
194
  case "Long":
195
195
  return n === Number(A) || n === A;
196
196
  case "Float":
@@ -314,15 +314,15 @@ function kn(n, t, e = {}) {
314
314
  throw Error(`unsupported data type: ${o}`);
315
315
  }
316
316
  }
317
- function m(n) {
317
+ function y(n) {
318
318
  const { type: t, name: e, domain: r } = n;
319
319
  return { type: t, name: e, ...r && { domain: r } };
320
320
  }
321
321
  function Nn(n) {
322
- return n.map(m);
322
+ return n.map(y);
323
323
  }
324
324
  function Sn(n) {
325
- return g(m(n));
325
+ return g(y(n));
326
326
  }
327
327
  function W(n, t) {
328
328
  if (n === void 0) return t === void 0;
@@ -344,6 +344,13 @@ function l(n, t) {
344
344
  type: "column",
345
345
  column: t(n.column)
346
346
  };
347
+ case "slicedColumn":
348
+ return {
349
+ type: "slicedColumn",
350
+ column: t(n.column),
351
+ newId: n.newId,
352
+ axisFilters: n.axisFilters
353
+ };
347
354
  case "inner":
348
355
  case "full":
349
356
  return {
@@ -367,7 +374,7 @@ function Cn(n) {
367
374
  return JSON.parse(n);
368
375
  }
369
376
  function P(n) {
370
- return g(m(n));
377
+ return g(y(n));
371
378
  }
372
379
  function x(n, t) {
373
380
  return JSON.stringify([n, t]);
@@ -394,15 +401,15 @@ class On {
394
401
  e.sort((r, o) => r[0].localeCompare(o[0]));
395
402
  for (const [r, o] of e) {
396
403
  for (let i = 0; i < o.axesSpec.length; i++) {
397
- const s = o.axesSpec[i], a = P(s);
398
- this.axes.set(a, { anchor: r, idx: i });
404
+ const a = o.axesSpec[i], s = P(a);
405
+ this.axes.set(s, { anchor: r, idx: i });
399
406
  }
400
407
  if (o.domain !== void 0) {
401
408
  const i = Object.entries(o.domain);
402
- i.sort((s, a) => s[0].localeCompare(a[0])), this.domainPackToAnchor.set(JSON.stringify(i), r), this.domainPacks.push(i.map(([s]) => s));
403
- for (const [s, a] of i) {
404
- const c = x(s, a);
405
- this.domains.set(c, r);
409
+ i.sort((a, s) => a[0].localeCompare(s[0])), this.domainPackToAnchor.set(JSON.stringify(i), r), this.domainPacks.push(i.map(([a]) => a));
410
+ for (const [a, s] of i) {
411
+ const u = x(a, s);
412
+ this.domains.set(u, r);
406
413
  }
407
414
  }
408
415
  }
@@ -418,47 +425,47 @@ class On {
418
425
  let o;
419
426
  if (t.domain !== void 0)
420
427
  n:
421
- for (const s of this.domainPacks) {
422
- const a = [];
423
- for (const u of s) {
424
- const d = t.domain[u];
428
+ for (const a of this.domainPacks) {
429
+ const s = [];
430
+ for (const c of a) {
431
+ const d = t.domain[c];
425
432
  if (d !== void 0)
426
- a.push([u, d]);
433
+ s.push([c, d]);
427
434
  else
428
435
  break n;
429
436
  }
430
- const c = this.domainPackToAnchor.get(JSON.stringify(a));
431
- if (c !== void 0) {
432
- r.domainAnchor = c, o = new Set(s);
437
+ const u = this.domainPackToAnchor.get(JSON.stringify(s));
438
+ if (u !== void 0) {
439
+ r.domainAnchor = u, o = new Set(a);
433
440
  break;
434
441
  }
435
442
  }
436
- for (const [s, a] of Object.entries(t.domain ?? {})) {
437
- if (o !== void 0 && o.has(s))
443
+ for (const [a, s] of Object.entries(t.domain ?? {})) {
444
+ if (o !== void 0 && o.has(a))
438
445
  continue;
439
- const c = x(s, a), u = this.domains.get(c);
440
- r.domain ?? (r.domain = {}), r.domain[s] = u ? { anchor: u } : a;
446
+ const u = x(a, s), c = this.domains.get(u);
447
+ r.domain ?? (r.domain = {}), r.domain[a] = c ? { anchor: c } : s;
441
448
  }
442
- if (r.axes = t.axesSpec.map((s) => {
443
- const a = P(s);
444
- return this.axes.get(a) ?? s;
449
+ if (r.axes = t.axesSpec.map((a) => {
450
+ const s = P(a);
451
+ return this.axes.get(s) ?? a;
445
452
  }), !e || e.length === 0)
446
453
  return r;
447
454
  const i = [];
448
- for (const s of e) {
449
- const [a, c] = s;
450
- if (typeof a == "number") {
451
- if (a < 0 || a >= t.axesSpec.length)
452
- throw new Error(`Axis index ${a} is out of bounds (0-${t.axesSpec.length - 1})`);
453
- i.push([a, c]);
455
+ for (const a of e) {
456
+ const [s, u] = a;
457
+ if (typeof s == "number") {
458
+ if (s < 0 || s >= t.axesSpec.length)
459
+ throw new Error(`Axis index ${s} is out of bounds (0-${t.axesSpec.length - 1})`);
460
+ i.push([s, u]);
454
461
  } else {
455
- const u = t.axesSpec.findIndex((d) => d.name === a);
456
- if (u === -1)
457
- throw new Error(`Axis with name "${a}" not found in the column specification`);
458
- i.push([u, c]);
462
+ const c = t.axesSpec.findIndex((d) => d.name === s);
463
+ if (c === -1)
464
+ throw new Error(`Axis with name "${s}" not found in the column specification`);
465
+ i.push([c, u]);
459
466
  }
460
467
  }
461
- return i.sort((s, a) => s[0] - a[0]), {
468
+ return i.sort((a, s) => a[0] - s[0]), {
462
469
  source: r,
463
470
  axisFilters: i
464
471
  };
@@ -488,12 +495,12 @@ function Jn(n, t) {
488
495
  if (typeof i == "string")
489
496
  r[o] = i;
490
497
  else {
491
- const s = n[i.anchor];
492
- if (!s)
498
+ const a = n[i.anchor];
499
+ if (!a)
493
500
  throw new Error(`Anchor "${i.anchor}" not found for domain key "${o}"`);
494
- if (!s.domain || s.domain[o] === void 0)
501
+ if (!a.domain || a.domain[o] === void 0)
495
502
  throw new Error(`Domain key "${o}" not found in anchor "${i.anchor}"`);
496
- r[o] = s.domain[o];
503
+ r[o] = a.domain[o];
497
504
  }
498
505
  e.domain = r;
499
506
  }
@@ -517,7 +524,7 @@ function G(n, t) {
517
524
  throw new Error(`Axis with name "${t.name}" not found in anchor "${e}"`);
518
525
  return o[0];
519
526
  } else if ("id" in t) {
520
- const o = r.axesSpec.filter((i) => X(t.id, m(i)));
527
+ const o = r.axesSpec.filter((i) => X(t.id, y(i)));
521
528
  if (o.length > 1)
522
529
  throw new Error(`Multiple matching axes found for matcher in anchor "${e}"`);
523
530
  if (o.length === 0)
@@ -548,18 +555,21 @@ function Dn(n) {
548
555
  if (!Y(n)) throw new Error(`not a PColumn (kind = ${n.spec.kind})`);
549
556
  return n;
550
557
  }
551
- function jn(n, t) {
558
+ function In(n, t) {
552
559
  return n === void 0 ? void 0 : {
553
560
  ...n,
554
561
  data: t(n.data)
555
562
  };
556
563
  }
557
- function Bn(n) {
564
+ function jn(n) {
558
565
  const t = /* @__PURE__ */ new Map(), e = (r) => {
559
566
  switch (r.type) {
560
567
  case "column":
561
568
  t.set(r.column.id, r.column);
562
569
  return;
570
+ case "slicedColumn":
571
+ t.set(r.column.id, r.column);
572
+ return;
563
573
  case "full":
564
574
  case "inner":
565
575
  for (const o of r.entries) e(o);
@@ -644,7 +654,7 @@ function N(n, t) {
644
654
  return !1;
645
655
  }
646
656
  if (t.axes !== void 0) {
647
- const e = n.axesSpec.map(m);
657
+ const e = n.axesSpec.map(y);
648
658
  if (t.partialAxesMatch) {
649
659
  for (const r of t.axes)
650
660
  if (!e.some((o) => k(r, o)))
@@ -673,13 +683,13 @@ function N(n, t) {
673
683
  }
674
684
  return !0;
675
685
  }
676
- function In(n) {
686
+ function Bn(n) {
677
687
  return Array.isArray(n) ? (t) => n.some((e) => f(t) && N(t, e)) : (t) => f(t) && N(t, n);
678
688
  }
679
- const Fn = { href: "/" }, Un = y.object({
680
- __isRef: y.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
681
- blockId: y.string().describe("Upstream block id"),
682
- name: y.string().describe("Name of the output provided to the upstream block's output context")
689
+ const Fn = { href: "/" }, Un = m.object({
690
+ __isRef: m.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
691
+ blockId: m.string().describe("Upstream block id"),
692
+ name: m.string().describe("Name of the output provided to the upstream block's output context")
683
693
  }).describe(
684
694
  "Universal reference type, allowing to set block connections. It is crucial that {@link __isRef} is present and equal to true, internal logic relies on this marker to build block dependency trees."
685
695
  ).strict().readonly();
@@ -718,17 +728,17 @@ function C(n, t, e) {
718
728
  default:
719
729
  throw new Error("Unknown base32 variant: " + String(t));
720
730
  }
721
- const i = e.padding !== void 0 ? e.padding : o, s = q(n);
722
- let a = 0, c = 0, u = "";
723
- for (let d = 0; d < s.byteLength; d++)
724
- for (c = c << 8 | s.getUint8(d), a += 8; a >= 5; )
725
- u += r[c >>> a - 5 & 31], a -= 5;
726
- if (a > 0 && (u += r[c << 5 - a & 31]), i)
727
- for (; u.length % 8 !== 0; )
728
- u += "=";
729
- return u;
730
- }
731
- const O = 15, rn = 24, J = y.string().length(rn).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
731
+ const i = e.padding !== void 0 ? e.padding : o, a = q(n);
732
+ let s = 0, u = 0, c = "";
733
+ for (let d = 0; d < a.byteLength; d++)
734
+ for (u = u << 8 | a.getUint8(d), s += 8; s >= 5; )
735
+ c += r[u >>> s - 5 & 31], s -= 5;
736
+ if (s > 0 && (c += r[u << 5 - s & 31]), i)
737
+ for (; c.length % 8 !== 0; )
738
+ c += "=";
739
+ return c;
740
+ }
741
+ const O = 15, rn = 24, J = m.string().length(rn).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
732
742
  function _n() {
733
743
  const n = new Uint8Array(O);
734
744
  return crypto.getRandomValues(n), J.parse(C(n, "RFC4648"));
@@ -749,7 +759,7 @@ export {
749
759
  U as PValueBytesNA,
750
760
  gn as PValueDoubleNA,
751
761
  bn as PValueFloatNA,
752
- I as PValueIntNA,
762
+ B as PValueIntNA,
753
763
  A as PValueLongNA,
754
764
  F as PValueStringNA,
755
765
  J as PlId,
@@ -757,23 +767,23 @@ export {
757
767
  rn as PlIdLength,
758
768
  Un as PlRef,
759
769
  Sn as canonicalizeAxisId,
760
- mn as dataInfoToEntries,
770
+ yn as dataInfoToEntries,
761
771
  vn as digestPlId,
762
772
  wn as ensureNotNAPValue,
763
773
  Dn as ensurePColumn,
764
774
  ln as entriesToDataInfo,
765
775
  b as executePSpecPredicate,
766
- Bn as extractAllColumns,
776
+ jn as extractAllColumns,
767
777
  Nn as getAxesId,
768
- m as getAxisId,
778
+ y as getAxisId,
769
779
  fn as getFileNameFromHandle,
770
- j as getFilePathFromHandle,
780
+ I as getFilePathFromHandle,
771
781
  dn as isDataInfo,
772
- yn as isDataInfoEntries,
782
+ mn as isDataInfoEntries,
773
783
  $n as isFilteredPColumn,
774
784
  D as isImportFileHandleIndex,
775
785
  V as isImportFileHandleUpload,
776
- un as isLiveLog,
786
+ cn as isLiveLog,
777
787
  K as isNotNAPValue,
778
788
  Y as isPColumn,
779
789
  Vn as isPColumnResult,
@@ -787,7 +797,7 @@ export {
787
797
  pn as mapDataInfo,
788
798
  hn as mapDataInfoEntries,
789
799
  l as mapJoinEntry,
790
- jn as mapPObjectData,
800
+ In as mapPObjectData,
791
801
  En as mapPTableDef,
792
802
  Mn as mapValueInVOE,
793
803
  k as matchAxis,
@@ -801,7 +811,7 @@ export {
801
811
  Rn as plRefsEqual,
802
812
  Jn as resolveAnchors,
803
813
  M as safeConvertToPValue,
804
- In as selectorsToPredicate,
814
+ Bn as selectorsToPredicate,
805
815
  z as stringifyColumnId,
806
816
  An as toJsonSafePValue,
807
817
  _n as uniquePlId