@milaboratories/pl-model-common 1.13.4 → 1.13.6

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 I(n) {
14
14
  return n.startsWith(S);
15
15
  }
16
- function D(n) {
16
+ function L(n) {
17
17
  return n.startsWith(E);
18
18
  }
19
- function I(n) {
20
- if (D(n)) {
19
+ function V(n) {
20
+ if (L(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 (I(n)) {
24
24
  const t = n.slice(S.length);
25
25
  return JSON.parse(decodeURIComponent(t)).localPath;
26
26
  }
@@ -30,7 +30,7 @@ function B(n) {
30
30
  return n.replace(/^.*[\\/]/, "");
31
31
  }
32
32
  function dn(n) {
33
- return B(I(n));
33
+ return B(V(n));
34
34
  }
35
35
  function pn(n) {
36
36
  if (!n || typeof n != "object")
@@ -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,21 @@ function Nn(n, t, e = {}) {
317
317
  throw Error(`unsupported data type: ${o}`);
318
318
  }
319
319
  }
320
- function y(n) {
320
+ function Sn(n) {
321
+ return {
322
+ columnId: n.id,
323
+ spec: n.spec
324
+ };
325
+ }
326
+ function p(n) {
321
327
  const { type: t, name: e, domain: r } = n;
322
328
  return { type: t, name: e, ...r && { domain: r } };
323
329
  }
324
- function Sn(n) {
325
- return n.map(y);
326
- }
327
330
  function En(n) {
328
- return g(y(n));
331
+ return n.map(p);
332
+ }
333
+ function Cn(n) {
334
+ return b(p(n));
329
335
  }
330
336
  function X(n, t) {
331
337
  if (n === void 0) return t === void 0;
@@ -337,7 +343,7 @@ function X(n, t) {
337
343
  function z(n, t) {
338
344
  return n.name === t.name && X(n.domain, t.domain);
339
345
  }
340
- function Cn(n, t) {
346
+ function Jn(n, t) {
341
347
  return { ...n, src: l(n.src, t) };
342
348
  }
343
349
  function l(n, t) {
@@ -371,47 +377,47 @@ function l(n, t) {
371
377
  }
372
378
  }
373
379
  function G(n) {
374
- return g(n);
380
+ return b(n);
375
381
  }
376
- function Jn(n) {
382
+ function On(n) {
377
383
  return JSON.parse(n);
378
384
  }
379
385
  function A(n) {
380
- return g(y(n));
386
+ return b(p(n));
381
387
  }
382
388
  function x(n, t) {
383
389
  return JSON.stringify([n, t]);
384
390
  }
385
- class On {
391
+ class $n {
386
392
  /**
387
393
  * Creates a new anchor context from a set of anchor column specifications
388
394
  * @param anchors Record of anchor column specifications indexed by anchor ID
389
395
  */
390
396
  constructor(t) {
391
- p(this, "domains", /* @__PURE__ */ new Map());
392
- p(this, "axes", /* @__PURE__ */ new Map());
397
+ m(this, "domains", /* @__PURE__ */ new Map());
398
+ m(this, "axes", /* @__PURE__ */ new Map());
393
399
  /**
394
400
  * Domain packs are used to group domain keys that can be anchored to the same anchor
395
401
  * This is used to optimize the lookup of domain anchors
396
402
  */
397
- p(this, "domainPacks", []);
403
+ m(this, "domainPacks", []);
398
404
  /**
399
405
  * Maps domain packs to anchors
400
406
  */
401
- p(this, "domainPackToAnchor", /* @__PURE__ */ new Map());
407
+ m(this, "domainPackToAnchor", /* @__PURE__ */ new Map());
402
408
  this.anchors = t;
403
409
  const e = Object.entries(t);
404
410
  e.sort((r, o) => r[0].localeCompare(o[0]));
405
411
  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 });
412
+ for (let s = 0; s < o.axesSpec.length; s++) {
413
+ const a = o.axesSpec[s], i = A(a);
414
+ this.axes.set(i, { anchor: r, idx: s });
409
415
  }
410
416
  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);
417
+ const s = Object.entries(o.domain);
418
+ s.sort((a, i) => a[0].localeCompare(i[0])), this.domainPackToAnchor.set(JSON.stringify(s), r), this.domainPacks.push(s.map(([a]) => a));
419
+ for (const [a, i] of s) {
420
+ const u = x(a, i);
415
421
  this.domains.set(u, r);
416
422
  }
417
423
  }
@@ -429,48 +435,48 @@ class On {
429
435
  if (t.domain !== void 0)
430
436
  n:
431
437
  for (const a of this.domainPacks) {
432
- const s = [];
438
+ const i = [];
433
439
  for (const c of a) {
434
440
  const d = t.domain[c];
435
441
  if (d !== void 0)
436
- s.push([c, d]);
442
+ i.push([c, d]);
437
443
  else
438
444
  break n;
439
445
  }
440
- const u = this.domainPackToAnchor.get(JSON.stringify(s));
446
+ const u = this.domainPackToAnchor.get(JSON.stringify(i));
441
447
  if (u !== void 0) {
442
448
  r.domainAnchor = u, o = new Set(a);
443
449
  break;
444
450
  }
445
451
  }
446
- for (const [a, s] of Object.entries(t.domain ?? {})) {
452
+ for (const [a, i] of Object.entries(t.domain ?? {})) {
447
453
  if (o !== void 0 && o.has(a))
448
454
  continue;
449
- const u = x(a, s), c = this.domains.get(u);
450
- r.domain ?? (r.domain = {}), r.domain[a] = c ? { anchor: c } : s;
455
+ const u = x(a, i), c = this.domains.get(u);
456
+ r.domain ?? (r.domain = {}), r.domain[a] = c ? { anchor: c } : i;
451
457
  }
452
458
  if (r.axes = t.axesSpec.map((a) => {
453
- const s = A(a);
454
- return this.axes.get(s) ?? a;
459
+ const i = A(a), u = this.axes.get(i);
460
+ return u === void 0 ? p(a) : u;
455
461
  }), !e || e.length === 0)
456
462
  return r;
457
- const i = [];
463
+ const s = [];
458
464
  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]);
465
+ const [i, u] = a;
466
+ if (typeof i == "number") {
467
+ if (i < 0 || i >= t.axesSpec.length)
468
+ throw new Error(`Axis index ${i} is out of bounds (0-${t.axesSpec.length - 1})`);
469
+ s.push([i, u]);
464
470
  } else {
465
- const c = t.axesSpec.findIndex((d) => d.name === s);
471
+ const c = t.axesSpec.findIndex((d) => d.name === i);
466
472
  if (c === -1)
467
- throw new Error(`Axis with name "${s}" not found in the column specification`);
468
- i.push([c, u]);
473
+ throw new Error(`Axis with name "${i}" not found in the column specification`);
474
+ s.push([c, u]);
469
475
  }
470
476
  }
471
- return i.sort((a, s) => a[0] - s[0]), {
477
+ return s.sort((a, i) => a[0] - i[0]), {
472
478
  source: r,
473
- axisFilters: i
479
+ axisFilters: s
474
480
  };
475
481
  }
476
482
  /**
@@ -483,31 +489,34 @@ class On {
483
489
  return G(this.derive(t, e));
484
490
  }
485
491
  }
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;
492
+ function Dn(n, t, e) {
493
+ const r = { ...t }, o = (e == null ? void 0 : e.ignoreMissingDomains) ?? !1;
494
+ if (r.domainAnchor !== void 0) {
495
+ const s = n[r.domainAnchor];
496
+ if (!s)
497
+ throw new Error(`Anchor "${r.domainAnchor}" not found`);
498
+ const a = s.domain || {};
499
+ r.domain = { ...a, ...r.domain }, delete r.domainAnchor;
494
500
  }
495
- if (e.domain) {
496
- const r = {};
497
- for (const [o, i] of Object.entries(e.domain))
501
+ if (r.domain) {
502
+ const s = {};
503
+ for (const [a, i] of Object.entries(r.domain))
498
504
  if (typeof i == "string")
499
- r[o] = i;
505
+ s[a] = i;
500
506
  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];
507
+ const u = n[i.anchor];
508
+ if (!u)
509
+ throw new Error(`Anchor "${i.anchor}" not found for domain key "${a}"`);
510
+ if (!u.domain || u.domain[a] === void 0) {
511
+ if (!o)
512
+ throw new Error(`Domain key "${a}" not found in anchor "${i.anchor}"`);
513
+ continue;
514
+ }
515
+ s[a] = u.domain[a];
507
516
  }
508
- e.domain = r;
517
+ r.domain = s;
509
518
  }
510
- return e.axes && (e.axes = e.axes.map((r) => Q(n, r))), e;
519
+ return r.axes && (r.axes = r.axes.map((s) => Q(n, s))), r;
511
520
  }
512
521
  function Q(n, t) {
513
522
  if (!Y(t))
@@ -520,14 +529,14 @@ function Q(n, t) {
520
529
  throw new Error(`Axis index ${t.idx} out of bounds for anchor "${e}"`);
521
530
  return r.axesSpec[t.idx];
522
531
  } else if ("name" in t) {
523
- const o = r.axesSpec.filter((i) => i.name === t.name);
532
+ const o = r.axesSpec.filter((s) => s.name === t.name);
524
533
  if (o.length > 1)
525
534
  throw new Error(`Multiple axes with name "${t.name}" found in anchor "${e}"`);
526
535
  if (o.length === 0)
527
536
  throw new Error(`Axis with name "${t.name}" not found in anchor "${e}"`);
528
537
  return o[0];
529
538
  } else if ("id" in t) {
530
- const o = r.axesSpec.filter((i) => z(t.id, y(i)));
539
+ const o = r.axesSpec.filter((s) => z(t.id, p(s)));
531
540
  if (o.length > 1)
532
541
  throw new Error(`Multiple matching axes found for matcher in anchor "${e}"`);
533
542
  if (o.length === 0)
@@ -539,7 +548,7 @@ function Q(n, t) {
539
548
  function Y(n) {
540
549
  return typeof n == "object" && "anchor" in n;
541
550
  }
542
- function Ln(n) {
551
+ function In(n) {
543
552
  return typeof n == "object" && n !== null && "source" in n && "axisFilters" in n;
544
553
  }
545
554
  function f(n) {
@@ -548,23 +557,23 @@ function f(n) {
548
557
  function Z(n) {
549
558
  return f(n.spec);
550
559
  }
551
- function Vn(n) {
560
+ function Ln(n) {
552
561
  return f(n.obj);
553
562
  }
554
- function Dn(n) {
563
+ function Vn(n) {
555
564
  return f(n.obj.spec);
556
565
  }
557
- function In(n) {
566
+ function Bn(n) {
558
567
  if (!Z(n)) throw new Error(`not a PColumn (kind = ${n.spec.kind})`);
559
568
  return n;
560
569
  }
561
- function Bn(n, t) {
570
+ function jn(n, t) {
562
571
  return n === void 0 ? void 0 : {
563
572
  ...n,
564
573
  data: t(n.data)
565
574
  };
566
575
  }
567
- function jn(n) {
576
+ function Fn(n) {
568
577
  const t = /* @__PURE__ */ new Map(), e = (r) => {
569
578
  switch (r.type) {
570
579
  case "column":
@@ -590,18 +599,18 @@ function jn(n) {
590
599
  function q(n) {
591
600
  throw new Error("Unexpected object: " + n);
592
601
  }
593
- function b(n, t) {
602
+ function g(n, t) {
594
603
  switch (n.type) {
595
604
  case "and":
596
605
  for (const e of n.operands)
597
- if (!b(e, t)) return !1;
606
+ if (!g(e, t)) return !1;
598
607
  return !0;
599
608
  case "or":
600
609
  for (const e of n.operands)
601
- if (b(e, t)) return !0;
610
+ if (g(e, t)) return !0;
602
611
  return !1;
603
612
  case "not":
604
- return !b(n.operand, t);
613
+ return !g(n.operand, t);
605
614
  case "name":
606
615
  return f(t) && t.name === n.name;
607
616
  case "name_pattern":
@@ -614,7 +623,7 @@ function b(n, t) {
614
623
  return f(t) && n.axes.every(
615
624
  (e) => t.axesSpec.some(
616
625
  (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
626
+ ([o, s]) => r.domain[o] === s
618
627
  ))
619
628
  )
620
629
  );
@@ -657,7 +666,7 @@ function N(n, t) {
657
666
  return !1;
658
667
  }
659
668
  if (t.axes !== void 0) {
660
- const e = n.axesSpec.map(y);
669
+ const e = n.axesSpec.map(p);
661
670
  if (t.partialAxesMatch) {
662
671
  for (const r of t.axes)
663
672
  if (!e.some((o) => k(r, o)))
@@ -679,30 +688,30 @@ function N(n, t) {
679
688
  if (t.annotationPatterns !== void 0) {
680
689
  const e = n.annotations || {};
681
690
  for (const [r, o] of Object.entries(t.annotationPatterns)) {
682
- const i = e[r];
683
- if (i === void 0 || !new RegExp(o).test(i))
691
+ const s = e[r];
692
+ if (s === void 0 || !new RegExp(o).test(s))
684
693
  return !1;
685
694
  }
686
695
  }
687
696
  return !0;
688
697
  }
689
- function Fn(n) {
698
+ function Un(n) {
690
699
  return Array.isArray(n) ? (t) => n.some((e) => f(t) && N(t, e)) : (t) => f(t) && N(t, n);
691
700
  }
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")
701
+ const Kn = { href: "/" }, Rn = y.object({
702
+ __isRef: y.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
703
+ blockId: y.string().describe("Upstream block id"),
704
+ name: y.string().describe("Name of the output provided to the upstream block's output context")
696
705
  }).describe(
697
706
  "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
707
  ).strict().readonly();
699
- function Rn(n) {
708
+ function Mn(n) {
700
709
  return typeof n == "object" && n !== null && "__isRef" in n && n.__isRef === !0 && "blockId" in n && "name" in n;
701
710
  }
702
- function Mn(n, t) {
711
+ function _n(n, t) {
703
712
  return n.blockId === t.blockId && n.name === t.name;
704
713
  }
705
- function _n(n, t) {
714
+ function Hn(n, t) {
706
715
  return n.ok ? { ok: !0, value: t(n.value) } : n;
707
716
  }
708
717
  function nn(n) {
@@ -731,18 +740,18 @@ function C(n, t, e) {
731
740
  default:
732
741
  throw new Error("Unknown base32 variant: " + String(t));
733
742
  }
734
- const i = e.padding !== void 0 ? e.padding : o, a = nn(n);
735
- let s = 0, u = 0, c = "";
743
+ const s = e.padding !== void 0 ? e.padding : o, a = nn(n);
744
+ let i = 0, u = 0, c = "";
736
745
  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)
746
+ for (u = u << 8 | a.getUint8(d), i += 8; i >= 5; )
747
+ c += r[u >>> i - 5 & 31], i -= 5;
748
+ if (i > 0 && (c += r[u << 5 - i & 31]), s)
740
749
  for (; c.length % 8 !== 0; )
741
750
  c += "=";
742
751
  return c;
743
752
  }
744
- const J = 15, on = 24, O = m.string().length(on).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
745
- function Hn() {
753
+ const J = 15, on = 24, O = y.string().length(on).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
754
+ function Tn() {
746
755
  const n = new Uint8Array(J);
747
756
  return crypto.getRandomValues(n), O.parse(C(n, "RFC4648"));
748
757
  }
@@ -750,74 +759,75 @@ function sn(n) {
750
759
  if (n.length !== J) throw new Error(`Wrong number of bytes: ${n.length}`);
751
760
  return O.parse(C(n, "RFC4648"));
752
761
  }
753
- async function Tn(n) {
762
+ async function vn(n) {
754
763
  const t = new TextEncoder(), e = await crypto.subtle.digest("SHA-256", t.encode(n));
755
764
  return sn(new Uint8Array(e.slice(0, 15)));
756
765
  }
757
766
  export {
758
- On as AnchoredIdDeriver,
759
- Un as DefaultNavigationState,
767
+ $n as AnchoredIdDeriver,
768
+ Kn as DefaultNavigationState,
760
769
  v as PTableAbsent,
761
770
  W as PTableNA,
762
771
  K as PValueBytesNA,
763
772
  wn as PValueDoubleNA,
764
- gn as PValueFloatNA,
773
+ bn as PValueFloatNA,
765
774
  F as PValueIntNA,
766
775
  P as PValueLongNA,
767
776
  U as PValueStringNA,
768
777
  O as PlId,
769
778
  J as PlIdBytes,
770
779
  on as PlIdLength,
771
- Kn as PlRef,
772
- En as canonicalizeAxisId,
780
+ Rn as PlRef,
781
+ Cn as canonicalizeAxisId,
773
782
  ln as dataInfoToEntries,
774
- Tn as digestPlId,
783
+ vn as digestPlId,
775
784
  Pn as ensureNotNAPValue,
776
- In as ensurePColumn,
785
+ Bn as ensurePColumn,
777
786
  hn as entriesToDataInfo,
778
- b as executePSpecPredicate,
779
- jn as extractAllColumns,
780
- Sn as getAxesId,
781
- y as getAxisId,
787
+ g as executePSpecPredicate,
788
+ Fn as extractAllColumns,
789
+ En as getAxesId,
790
+ p as getAxisId,
791
+ Sn as getColumnIdAndSpec,
782
792
  dn as getFileNameFromHandle,
783
- I as getFilePathFromHandle,
793
+ V as getFilePathFromHandle,
784
794
  pn as isDataInfo,
785
795
  j as isDataInfoEntries,
786
- Ln as isFilteredPColumn,
787
- D as isImportFileHandleIndex,
788
- V as isImportFileHandleUpload,
796
+ In as isFilteredPColumn,
797
+ L as isImportFileHandleIndex,
798
+ I as isImportFileHandleUpload,
789
799
  fn as isLiveLog,
790
800
  R as isNotNAPValue,
791
801
  Z as isPColumn,
792
- Dn as isPColumnResult,
802
+ Vn as isPColumnResult,
793
803
  f as isPColumnSpec,
794
- Vn as isPColumnSpecResult,
804
+ Ln as isPColumnSpecResult,
795
805
  kn as isPTableAbsent,
796
806
  M as isPValue,
797
807
  yn as isPartitionedDataInfoEntries,
798
- Rn as isPlRef,
808
+ Mn as isPlRef,
799
809
  T as isValueAbsent,
800
810
  h as isValueNA,
801
811
  mn as mapDataInfo,
802
- bn as mapDataInfoEntries,
812
+ gn as mapDataInfoEntries,
803
813
  l as mapJoinEntry,
804
- Bn as mapPObjectData,
805
- Cn as mapPTableDef,
806
- _n as mapValueInVOE,
814
+ jn as mapPObjectData,
815
+ Jn as mapPTableDef,
816
+ Hn as mapValueInVOE,
807
817
  k as matchAxis,
808
818
  z as matchAxisId,
809
819
  N as matchPColumn,
810
820
  Nn as pTableValue,
811
821
  xn as pValueToStringOrNumber,
812
822
  H as pValueToStringOrNumberOrNull,
813
- Jn as parseColumnId,
823
+ On as parseColumnId,
814
824
  sn as plId,
815
- Mn as plRefsEqual,
816
- $n as resolveAnchors,
825
+ _n as plRefsEqual,
826
+ Dn as resolveAnchors,
817
827
  _ as safeConvertToPValue,
818
- Fn as selectorsToPredicate,
828
+ Un as selectorsToPredicate,
819
829
  G as stringifyColumnId,
820
830
  An as toJsonSafePValue,
821
- Hn as uniquePlId
831
+ Tn as uniquePlId
822
832
  };
823
833
  //# sourceMappingURL=index.mjs.map