@milaboratories/pl-model-common 1.13.4 → 1.13.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/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  var $ = Object.defineProperty;
2
- var L = (n, t, e) => t in n ? $(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var p = (n, t, e) => L(n, typeof t != "symbol" ? t + "" : t, e);
4
- import g from "canonicalize";
5
- import { z as m } from "zod";
2
+ var D = (n, t, e) => t in n ? $(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var m = (n, t, e) => D(n, typeof t != "symbol" ? t + "" : t, e);
4
+ import b from "canonicalize";
5
+ import { z as y } from "zod";
6
6
  function fn(n) {
7
7
  return n !== void 0 && n.startsWith("log+live://log/");
8
8
  }
@@ -10,17 +10,17 @@ function w(n) {
10
10
  throw new Error("Unexpected object: " + n);
11
11
  }
12
12
  const S = "upload://upload/", E = "index://index/";
13
- function V(n) {
13
+ function L(n) {
14
14
  return n.startsWith(S);
15
15
  }
16
- function D(n) {
16
+ function V(n) {
17
17
  return n.startsWith(E);
18
18
  }
19
19
  function I(n) {
20
- if (D(n)) {
20
+ if (V(n)) {
21
21
  const t = n.slice(E.length);
22
22
  return JSON.parse(decodeURIComponent(t)).path;
23
- } else if (V(n)) {
23
+ } else if (L(n)) {
24
24
  const t = n.slice(S.length);
25
25
  return JSON.parse(decodeURIComponent(t)).localPath;
26
26
  }
@@ -159,7 +159,7 @@ function hn(n) {
159
159
  }
160
160
  }
161
161
  }
162
- function bn(n, t) {
162
+ function gn(n, t) {
163
163
  if (n !== void 0)
164
164
  switch (n.type) {
165
165
  case "Json":
@@ -189,7 +189,7 @@ function bn(n, t) {
189
189
  }
190
190
  }
191
191
  }
192
- const F = -2147483648, P = -9007199254740991n, gn = NaN, wn = NaN, U = null, K = null;
192
+ const F = -2147483648, P = -9007199254740991n, bn = NaN, wn = NaN, U = null, K = null;
193
193
  function h(n, t) {
194
194
  switch (t) {
195
195
  case "Int":
@@ -317,15 +317,15 @@ function Nn(n, t, e = {}) {
317
317
  throw Error(`unsupported data type: ${o}`);
318
318
  }
319
319
  }
320
- function y(n) {
320
+ function p(n) {
321
321
  const { type: t, name: e, domain: r } = n;
322
322
  return { type: t, name: e, ...r && { domain: r } };
323
323
  }
324
324
  function Sn(n) {
325
- return n.map(y);
325
+ return n.map(p);
326
326
  }
327
327
  function En(n) {
328
- return g(y(n));
328
+ return b(p(n));
329
329
  }
330
330
  function X(n, t) {
331
331
  if (n === void 0) return t === void 0;
@@ -371,13 +371,13 @@ function l(n, t) {
371
371
  }
372
372
  }
373
373
  function G(n) {
374
- return g(n);
374
+ return b(n);
375
375
  }
376
376
  function Jn(n) {
377
377
  return JSON.parse(n);
378
378
  }
379
379
  function A(n) {
380
- return g(y(n));
380
+ return b(p(n));
381
381
  }
382
382
  function x(n, t) {
383
383
  return JSON.stringify([n, t]);
@@ -388,30 +388,30 @@ class On {
388
388
  * @param anchors Record of anchor column specifications indexed by anchor ID
389
389
  */
390
390
  constructor(t) {
391
- p(this, "domains", /* @__PURE__ */ new Map());
392
- p(this, "axes", /* @__PURE__ */ new Map());
391
+ m(this, "domains", /* @__PURE__ */ new Map());
392
+ m(this, "axes", /* @__PURE__ */ new Map());
393
393
  /**
394
394
  * Domain packs are used to group domain keys that can be anchored to the same anchor
395
395
  * This is used to optimize the lookup of domain anchors
396
396
  */
397
- p(this, "domainPacks", []);
397
+ m(this, "domainPacks", []);
398
398
  /**
399
399
  * Maps domain packs to anchors
400
400
  */
401
- p(this, "domainPackToAnchor", /* @__PURE__ */ new Map());
401
+ m(this, "domainPackToAnchor", /* @__PURE__ */ new Map());
402
402
  this.anchors = t;
403
403
  const e = Object.entries(t);
404
404
  e.sort((r, o) => r[0].localeCompare(o[0]));
405
405
  for (const [r, o] of e) {
406
- for (let i = 0; i < o.axesSpec.length; i++) {
407
- const a = o.axesSpec[i], s = A(a);
408
- this.axes.set(s, { anchor: r, idx: i });
406
+ for (let s = 0; s < o.axesSpec.length; s++) {
407
+ const a = o.axesSpec[s], i = A(a);
408
+ this.axes.set(i, { anchor: r, idx: s });
409
409
  }
410
410
  if (o.domain !== void 0) {
411
- const i = Object.entries(o.domain);
412
- i.sort((a, s) => a[0].localeCompare(s[0])), this.domainPackToAnchor.set(JSON.stringify(i), r), this.domainPacks.push(i.map(([a]) => a));
413
- for (const [a, s] of i) {
414
- const u = x(a, s);
411
+ const s = Object.entries(o.domain);
412
+ s.sort((a, i) => a[0].localeCompare(i[0])), this.domainPackToAnchor.set(JSON.stringify(s), r), this.domainPacks.push(s.map(([a]) => a));
413
+ for (const [a, i] of s) {
414
+ const u = x(a, i);
415
415
  this.domains.set(u, r);
416
416
  }
417
417
  }
@@ -429,48 +429,48 @@ class On {
429
429
  if (t.domain !== void 0)
430
430
  n:
431
431
  for (const a of this.domainPacks) {
432
- const s = [];
432
+ const i = [];
433
433
  for (const c of a) {
434
434
  const d = t.domain[c];
435
435
  if (d !== void 0)
436
- s.push([c, d]);
436
+ i.push([c, d]);
437
437
  else
438
438
  break n;
439
439
  }
440
- const u = this.domainPackToAnchor.get(JSON.stringify(s));
440
+ const u = this.domainPackToAnchor.get(JSON.stringify(i));
441
441
  if (u !== void 0) {
442
442
  r.domainAnchor = u, o = new Set(a);
443
443
  break;
444
444
  }
445
445
  }
446
- for (const [a, s] of Object.entries(t.domain ?? {})) {
446
+ for (const [a, i] of Object.entries(t.domain ?? {})) {
447
447
  if (o !== void 0 && o.has(a))
448
448
  continue;
449
- const u = x(a, s), c = this.domains.get(u);
450
- r.domain ?? (r.domain = {}), r.domain[a] = c ? { anchor: c } : s;
449
+ const u = x(a, i), c = this.domains.get(u);
450
+ r.domain ?? (r.domain = {}), r.domain[a] = c ? { anchor: c } : i;
451
451
  }
452
452
  if (r.axes = t.axesSpec.map((a) => {
453
- const s = A(a);
454
- return this.axes.get(s) ?? a;
453
+ const i = A(a), u = this.axes.get(i);
454
+ return u === void 0 ? p(a) : u;
455
455
  }), !e || e.length === 0)
456
456
  return r;
457
- const i = [];
457
+ const s = [];
458
458
  for (const a of e) {
459
- const [s, u] = a;
460
- if (typeof s == "number") {
461
- if (s < 0 || s >= t.axesSpec.length)
462
- throw new Error(`Axis index ${s} is out of bounds (0-${t.axesSpec.length - 1})`);
463
- i.push([s, u]);
459
+ const [i, u] = a;
460
+ if (typeof i == "number") {
461
+ if (i < 0 || i >= t.axesSpec.length)
462
+ throw new Error(`Axis index ${i} is out of bounds (0-${t.axesSpec.length - 1})`);
463
+ s.push([i, u]);
464
464
  } else {
465
- const c = t.axesSpec.findIndex((d) => d.name === s);
465
+ const c = t.axesSpec.findIndex((d) => d.name === i);
466
466
  if (c === -1)
467
- throw new Error(`Axis with name "${s}" not found in the column specification`);
468
- i.push([c, u]);
467
+ throw new Error(`Axis with name "${i}" not found in the column specification`);
468
+ s.push([c, u]);
469
469
  }
470
470
  }
471
- return i.sort((a, s) => a[0] - s[0]), {
471
+ return s.sort((a, i) => a[0] - i[0]), {
472
472
  source: r,
473
- axisFilters: i
473
+ axisFilters: s
474
474
  };
475
475
  }
476
476
  /**
@@ -483,31 +483,34 @@ class On {
483
483
  return G(this.derive(t, e));
484
484
  }
485
485
  }
486
- function $n(n, t) {
487
- const e = { ...t };
488
- if (e.domainAnchor !== void 0) {
489
- const r = n[e.domainAnchor];
490
- if (!r)
491
- throw new Error(`Anchor "${e.domainAnchor}" not found`);
492
- const o = r.domain || {};
493
- e.domain = { ...o, ...e.domain }, delete e.domainAnchor;
486
+ function $n(n, t, e) {
487
+ const r = { ...t }, o = (e == null ? void 0 : e.ignoreMissingDomains) ?? !1;
488
+ if (r.domainAnchor !== void 0) {
489
+ const s = n[r.domainAnchor];
490
+ if (!s)
491
+ throw new Error(`Anchor "${r.domainAnchor}" not found`);
492
+ const a = s.domain || {};
493
+ r.domain = { ...a, ...r.domain }, delete r.domainAnchor;
494
494
  }
495
- if (e.domain) {
496
- const r = {};
497
- for (const [o, i] of Object.entries(e.domain))
495
+ if (r.domain) {
496
+ const s = {};
497
+ for (const [a, i] of Object.entries(r.domain))
498
498
  if (typeof i == "string")
499
- r[o] = i;
499
+ s[a] = i;
500
500
  else {
501
- const a = n[i.anchor];
502
- if (!a)
503
- throw new Error(`Anchor "${i.anchor}" not found for domain key "${o}"`);
504
- if (!a.domain || a.domain[o] === void 0)
505
- throw new Error(`Domain key "${o}" not found in anchor "${i.anchor}"`);
506
- r[o] = a.domain[o];
501
+ const u = n[i.anchor];
502
+ if (!u)
503
+ throw new Error(`Anchor "${i.anchor}" not found for domain key "${a}"`);
504
+ if (!u.domain || u.domain[a] === void 0) {
505
+ if (!o)
506
+ throw new Error(`Domain key "${a}" not found in anchor "${i.anchor}"`);
507
+ continue;
508
+ }
509
+ s[a] = u.domain[a];
507
510
  }
508
- e.domain = r;
511
+ r.domain = s;
509
512
  }
510
- return e.axes && (e.axes = e.axes.map((r) => Q(n, r))), e;
513
+ return r.axes && (r.axes = r.axes.map((s) => Q(n, s))), r;
511
514
  }
512
515
  function Q(n, t) {
513
516
  if (!Y(t))
@@ -520,14 +523,14 @@ function Q(n, t) {
520
523
  throw new Error(`Axis index ${t.idx} out of bounds for anchor "${e}"`);
521
524
  return r.axesSpec[t.idx];
522
525
  } else if ("name" in t) {
523
- const o = r.axesSpec.filter((i) => i.name === t.name);
526
+ const o = r.axesSpec.filter((s) => s.name === t.name);
524
527
  if (o.length > 1)
525
528
  throw new Error(`Multiple axes with name "${t.name}" found in anchor "${e}"`);
526
529
  if (o.length === 0)
527
530
  throw new Error(`Axis with name "${t.name}" not found in anchor "${e}"`);
528
531
  return o[0];
529
532
  } else if ("id" in t) {
530
- const o = r.axesSpec.filter((i) => z(t.id, y(i)));
533
+ const o = r.axesSpec.filter((s) => z(t.id, p(s)));
531
534
  if (o.length > 1)
532
535
  throw new Error(`Multiple matching axes found for matcher in anchor "${e}"`);
533
536
  if (o.length === 0)
@@ -539,7 +542,7 @@ function Q(n, t) {
539
542
  function Y(n) {
540
543
  return typeof n == "object" && "anchor" in n;
541
544
  }
542
- function Ln(n) {
545
+ function Dn(n) {
543
546
  return typeof n == "object" && n !== null && "source" in n && "axisFilters" in n;
544
547
  }
545
548
  function f(n) {
@@ -548,10 +551,10 @@ function f(n) {
548
551
  function Z(n) {
549
552
  return f(n.spec);
550
553
  }
551
- function Vn(n) {
554
+ function Ln(n) {
552
555
  return f(n.obj);
553
556
  }
554
- function Dn(n) {
557
+ function Vn(n) {
555
558
  return f(n.obj.spec);
556
559
  }
557
560
  function In(n) {
@@ -590,18 +593,18 @@ function jn(n) {
590
593
  function q(n) {
591
594
  throw new Error("Unexpected object: " + n);
592
595
  }
593
- function b(n, t) {
596
+ function g(n, t) {
594
597
  switch (n.type) {
595
598
  case "and":
596
599
  for (const e of n.operands)
597
- if (!b(e, t)) return !1;
600
+ if (!g(e, t)) return !1;
598
601
  return !0;
599
602
  case "or":
600
603
  for (const e of n.operands)
601
- if (b(e, t)) return !0;
604
+ if (g(e, t)) return !0;
602
605
  return !1;
603
606
  case "not":
604
- return !b(n.operand, t);
607
+ return !g(n.operand, t);
605
608
  case "name":
606
609
  return f(t) && t.name === n.name;
607
610
  case "name_pattern":
@@ -614,7 +617,7 @@ function b(n, t) {
614
617
  return f(t) && n.axes.every(
615
618
  (e) => t.axesSpec.some(
616
619
  (r) => (e.type === void 0 || e.type === r.type) && (e.name === void 0 || e.name === r.name) && (e.domain === void 0 || Object.keys(e.domain).length === 0 || r.domain !== void 0 && Object.entries(e.domain).every(
617
- ([o, i]) => r.domain[o] === i
620
+ ([o, s]) => r.domain[o] === s
618
621
  ))
619
622
  )
620
623
  );
@@ -657,7 +660,7 @@ function N(n, t) {
657
660
  return !1;
658
661
  }
659
662
  if (t.axes !== void 0) {
660
- const e = n.axesSpec.map(y);
663
+ const e = n.axesSpec.map(p);
661
664
  if (t.partialAxesMatch) {
662
665
  for (const r of t.axes)
663
666
  if (!e.some((o) => k(r, o)))
@@ -679,8 +682,8 @@ function N(n, t) {
679
682
  if (t.annotationPatterns !== void 0) {
680
683
  const e = n.annotations || {};
681
684
  for (const [r, o] of Object.entries(t.annotationPatterns)) {
682
- const i = e[r];
683
- if (i === void 0 || !new RegExp(o).test(i))
685
+ const s = e[r];
686
+ if (s === void 0 || !new RegExp(o).test(s))
684
687
  return !1;
685
688
  }
686
689
  }
@@ -689,10 +692,10 @@ function N(n, t) {
689
692
  function Fn(n) {
690
693
  return Array.isArray(n) ? (t) => n.some((e) => f(t) && N(t, e)) : (t) => f(t) && N(t, n);
691
694
  }
692
- const Un = { href: "/" }, Kn = m.object({
693
- __isRef: m.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
694
- blockId: m.string().describe("Upstream block id"),
695
- name: m.string().describe("Name of the output provided to the upstream block's output context")
695
+ const Un = { href: "/" }, Kn = y.object({
696
+ __isRef: y.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
697
+ blockId: y.string().describe("Upstream block id"),
698
+ name: y.string().describe("Name of the output provided to the upstream block's output context")
696
699
  }).describe(
697
700
  "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."
698
701
  ).strict().readonly();
@@ -731,17 +734,17 @@ function C(n, t, e) {
731
734
  default:
732
735
  throw new Error("Unknown base32 variant: " + String(t));
733
736
  }
734
- const i = e.padding !== void 0 ? e.padding : o, a = nn(n);
735
- let s = 0, u = 0, c = "";
737
+ const s = e.padding !== void 0 ? e.padding : o, a = nn(n);
738
+ let i = 0, u = 0, c = "";
736
739
  for (let d = 0; d < a.byteLength; d++)
737
- for (u = u << 8 | a.getUint8(d), s += 8; s >= 5; )
738
- c += r[u >>> s - 5 & 31], s -= 5;
739
- if (s > 0 && (c += r[u << 5 - s & 31]), i)
740
+ for (u = u << 8 | a.getUint8(d), i += 8; i >= 5; )
741
+ c += r[u >>> i - 5 & 31], i -= 5;
742
+ if (i > 0 && (c += r[u << 5 - i & 31]), s)
740
743
  for (; c.length % 8 !== 0; )
741
744
  c += "=";
742
745
  return c;
743
746
  }
744
- const J = 15, on = 24, O = m.string().length(on).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
747
+ const J = 15, on = 24, O = y.string().length(on).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
745
748
  function Hn() {
746
749
  const n = new Uint8Array(J);
747
750
  return crypto.getRandomValues(n), O.parse(C(n, "RFC4648"));
@@ -761,7 +764,7 @@ export {
761
764
  W as PTableNA,
762
765
  K as PValueBytesNA,
763
766
  wn as PValueDoubleNA,
764
- gn as PValueFloatNA,
767
+ bn as PValueFloatNA,
765
768
  F as PValueIntNA,
766
769
  P as PValueLongNA,
767
770
  U as PValueStringNA,
@@ -775,23 +778,23 @@ export {
775
778
  Pn as ensureNotNAPValue,
776
779
  In as ensurePColumn,
777
780
  hn as entriesToDataInfo,
778
- b as executePSpecPredicate,
781
+ g as executePSpecPredicate,
779
782
  jn as extractAllColumns,
780
783
  Sn as getAxesId,
781
- y as getAxisId,
784
+ p as getAxisId,
782
785
  dn as getFileNameFromHandle,
783
786
  I as getFilePathFromHandle,
784
787
  pn as isDataInfo,
785
788
  j as isDataInfoEntries,
786
- Ln as isFilteredPColumn,
787
- D as isImportFileHandleIndex,
788
- V as isImportFileHandleUpload,
789
+ Dn as isFilteredPColumn,
790
+ V as isImportFileHandleIndex,
791
+ L as isImportFileHandleUpload,
789
792
  fn as isLiveLog,
790
793
  R as isNotNAPValue,
791
794
  Z as isPColumn,
792
- Dn as isPColumnResult,
795
+ Vn as isPColumnResult,
793
796
  f as isPColumnSpec,
794
- Vn as isPColumnSpecResult,
797
+ Ln as isPColumnSpecResult,
795
798
  kn as isPTableAbsent,
796
799
  M as isPValue,
797
800
  yn as isPartitionedDataInfoEntries,
@@ -799,7 +802,7 @@ export {
799
802
  T as isValueAbsent,
800
803
  h as isValueNA,
801
804
  mn as mapDataInfo,
802
- bn as mapDataInfoEntries,
805
+ gn as mapDataInfoEntries,
803
806
  l as mapJoinEntry,
804
807
  Bn as mapPObjectData,
805
808
  Cn as mapPTableDef,