@milaboratories/pl-model-common 1.14.1 → 1.15.1

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,38 +1,46 @@
1
- var $ = Object.defineProperty;
2
- var I = (n, e, t) => e in n ? $(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var l = (n, e, t) => I(n, typeof e != "symbol" ? e + "" : e, t);
4
- import h from "canonicalize";
5
- import { z as p } from "zod";
6
- function dn(n) {
1
+ var I = Object.defineProperty;
2
+ var D = (n, e, t) => e in n ? I(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var l = (n, e, t) => D(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import y from "canonicalize";
5
+ import { z as m } from "zod";
6
+ function dn(n, e) {
7
+ if (!(n == null || e == null))
8
+ return { from: n, to: e };
9
+ }
10
+ function mn(n, e) {
11
+ if (n.from < 0 || n.to < 0 || n.from >= n.to)
12
+ throw new Error(`${e}: invalid bytes range: ${n}`);
13
+ }
14
+ function pn(n) {
7
15
  return n !== void 0 && n.startsWith("log+live://log/");
8
16
  }
9
17
  function w(n) {
10
18
  throw new Error("Unexpected object: " + n);
11
19
  }
12
20
  const E = "upload://upload/", S = "index://index/";
13
- function D(n) {
21
+ function L(n) {
14
22
  return n.startsWith(E);
15
23
  }
16
- function L(n) {
24
+ function V(n) {
17
25
  return n.startsWith(S);
18
26
  }
19
- function V(n) {
20
- if (L(n)) {
27
+ function B(n) {
28
+ if (V(n)) {
21
29
  const e = n.slice(S.length);
22
30
  return JSON.parse(decodeURIComponent(e)).path;
23
- } else if (D(n)) {
31
+ } else if (L(n)) {
24
32
  const e = n.slice(E.length);
25
33
  return JSON.parse(decodeURIComponent(e)).localPath;
26
34
  }
27
35
  w(n);
28
36
  }
29
- function B(n) {
37
+ function j(n) {
30
38
  return n.replace(/^.*[\\/]/, "");
31
39
  }
32
- function pn(n) {
33
- return B(V(n));
40
+ function ln(n) {
41
+ return j(B(n));
34
42
  }
35
- function mn(n) {
43
+ function yn(n) {
36
44
  if (!n || typeof n != "object")
37
45
  return !1;
38
46
  const e = n;
@@ -49,7 +57,7 @@ function mn(n) {
49
57
  return !1;
50
58
  }
51
59
  }
52
- function ln(n, e) {
60
+ function hn(n, e) {
53
61
  if (n !== void 0)
54
62
  switch (n.type) {
55
63
  case "Json":
@@ -77,7 +85,7 @@ function ln(n, e) {
77
85
  }
78
86
  }
79
87
  }
80
- function j(n) {
88
+ function F(n) {
81
89
  if (!n || typeof n != "object")
82
90
  return !1;
83
91
  const e = n;
@@ -94,10 +102,10 @@ function j(n) {
94
102
  return !1;
95
103
  }
96
104
  }
97
- function yn(n) {
98
- return j(n) ? n.type === "JsonPartitioned" || n.type === "BinaryPartitioned" : !1;
105
+ function gn(n) {
106
+ return F(n) ? n.type === "JsonPartitioned" || n.type === "BinaryPartitioned" : !1;
99
107
  }
100
- function hn(n) {
108
+ function bn(n) {
101
109
  switch (n.type) {
102
110
  case "Json": {
103
111
  const e = Object.entries(n.data).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
@@ -125,7 +133,7 @@ function hn(n) {
125
133
  }
126
134
  }
127
135
  }
128
- function gn(n) {
136
+ function wn(n) {
129
137
  switch (n.type) {
130
138
  case "Json": {
131
139
  const e = {};
@@ -159,7 +167,7 @@ function gn(n) {
159
167
  }
160
168
  }
161
169
  }
162
- function bn(n, e) {
170
+ function Pn(n, e) {
163
171
  if (n !== void 0)
164
172
  switch (n.type) {
165
173
  case "Json":
@@ -189,11 +197,11 @@ function bn(n, e) {
189
197
  }
190
198
  }
191
199
  }
192
- const F = -2147483648, P = -9007199254740991n, wn = NaN, Pn = NaN, U = null, K = null;
200
+ const U = -2147483648, P = -9007199254740991n, xn = NaN, An = NaN, K = null, R = null;
193
201
  function g(n, e) {
194
202
  switch (e) {
195
203
  case "Int":
196
- return n === F;
204
+ return n === U;
197
205
  case "Long":
198
206
  return n === Number(P) || n === P;
199
207
  case "Float":
@@ -201,18 +209,18 @@ function g(n, e) {
201
209
  case "Double":
202
210
  return Number.isNaN(n);
203
211
  case "String":
204
- return n === U;
205
- case "Bytes":
206
212
  return n === K;
213
+ case "Bytes":
214
+ return n === R;
207
215
  default:
208
216
  throw Error(`unsupported data type: ${e}`);
209
217
  }
210
218
  }
211
- function xn(n) {
212
- if (!R(n)) throw new Error(`Expected not-NA PValue, got ${n}`);
219
+ function kn(n) {
220
+ if (!v(n)) throw new Error(`Expected not-NA PValue, got ${n}`);
213
221
  return n;
214
222
  }
215
- function R(n, e) {
223
+ function v(n, e) {
216
224
  if (!e)
217
225
  return typeof n == "string" || typeof n == "number" && isFinite(n) || typeof n == "bigint";
218
226
  if (g(n, e)) return !1;
@@ -254,7 +262,7 @@ function _(n, e) {
254
262
  throw Error(`unsupported data type: ${e}`);
255
263
  }
256
264
  }
257
- function An(n) {
265
+ function Nn(n) {
258
266
  if (n === null || typeof n == "string" || typeof n == "number") return n;
259
267
  if (typeof n == "bigint") return { bigint: n.toString() };
260
268
  throw new Error(`Type ${typeof n} (value ${n}) not yet supported.`);
@@ -272,7 +280,7 @@ function M(n, e) {
272
280
  }
273
281
  throw new Error(`Unsupported type ${typeof n} (value ${n}).`);
274
282
  }
275
- function kn(n) {
283
+ function En(n) {
276
284
  if (n = T(n), n === null) throw new Error("Value is null");
277
285
  return n;
278
286
  }
@@ -287,19 +295,19 @@ function T(n) {
287
295
  return Number(n);
288
296
  throw new Error(`Unexpected value type: ${typeof n}`);
289
297
  }
290
- function v(n, e) {
298
+ function H(n, e) {
291
299
  const t = Math.floor(e / 8), r = 1 << 7 - e % 8;
292
300
  return (n[t] & r) > 0;
293
301
  }
294
- const H = { type: "absent" }, q = null;
295
- function Nn(n) {
302
+ const q = { type: "absent" }, W = null;
303
+ function Sn(n) {
296
304
  return typeof n == "object" && n !== null && n.type === "absent";
297
305
  }
298
- function En(n, e, t = {}) {
299
- if (v(n.absent, e))
300
- return t.absent === void 0 ? H : t.absent;
306
+ function Cn(n, e, t = {}) {
307
+ if (H(n.absent, e))
308
+ return t.absent === void 0 ? q : t.absent;
301
309
  const r = n.data[e], o = n.type;
302
- if (g(r, o)) return t.na === void 0 ? q : t.na;
310
+ if (g(r, o)) return t.na === void 0 ? W : t.na;
303
311
  switch (o) {
304
312
  case "Int":
305
313
  return r;
@@ -317,31 +325,31 @@ function En(n, e, t = {}) {
317
325
  throw Error(`unsupported data type: ${o}`);
318
326
  }
319
327
  }
320
- function Sn(n) {
328
+ function Jn(n) {
321
329
  return {
322
330
  kind: n.kind,
323
331
  valueType: n.valueType,
324
332
  name: n.name,
325
333
  domain: n.domain,
326
334
  parentAxes: n.parentAxes,
327
- axesId: W(n.axesSpec)
335
+ axesId: C(n.axesSpec)
328
336
  };
329
337
  }
330
- function Cn(n) {
338
+ function On(n) {
331
339
  return {
332
340
  columnId: n.id,
333
341
  spec: n.spec
334
342
  };
335
343
  }
336
- function m(n) {
344
+ function p(n) {
337
345
  const { type: e, name: t, domain: r } = n;
338
346
  return { type: e, name: t, ...r && { domain: r } };
339
347
  }
340
- function W(n) {
341
- return n.map(m);
348
+ function C(n) {
349
+ return n.map(p);
342
350
  }
343
- function Jn(n) {
344
- return h(m(n));
351
+ function $n(n) {
352
+ return y(p(n));
345
353
  }
346
354
  function z(n, e) {
347
355
  if (n === void 0) return e === void 0;
@@ -353,10 +361,10 @@ function z(n, e) {
353
361
  function X(n, e) {
354
362
  return n.name === e.name && z(n.domain, e.domain);
355
363
  }
356
- function On(n, e) {
357
- return { ...n, src: y(n.src, e) };
364
+ function In(n, e) {
365
+ return { ...n, src: h(n.src, e) };
358
366
  }
359
- function y(n, e) {
367
+ function h(n, e) {
360
368
  switch (n.type) {
361
369
  case "column":
362
370
  return {
@@ -376,31 +384,31 @@ function y(n, e) {
376
384
  case "full":
377
385
  return {
378
386
  type: n.type,
379
- entries: n.entries.map((t) => y(t, e))
387
+ entries: n.entries.map((t) => h(t, e))
380
388
  };
381
389
  case "outer":
382
390
  return {
383
391
  type: "outer",
384
- primary: y(n.primary, e),
385
- secondary: n.secondary.map((t) => y(t, e))
392
+ primary: h(n.primary, e),
393
+ secondary: n.secondary.map((t) => h(t, e))
386
394
  };
387
395
  default:
388
396
  w(n);
389
397
  }
390
398
  }
391
399
  function G(n) {
392
- return h(n);
400
+ return y(n);
393
401
  }
394
- function $n(n) {
402
+ function Dn(n) {
395
403
  return JSON.parse(n);
396
404
  }
397
405
  function x(n) {
398
- return h(m(n));
406
+ return y(p(n));
399
407
  }
400
408
  function A(n, e) {
401
409
  return JSON.stringify([n, e]);
402
410
  }
403
- class In {
411
+ class Ln {
404
412
  /**
405
413
  * Creates a new anchor context from a set of anchor column specifications
406
414
  * @param anchors Record of anchor column specifications indexed by anchor ID
@@ -469,7 +477,7 @@ class In {
469
477
  }
470
478
  if (r.axes = e.axesSpec.map((a) => {
471
479
  const i = x(a), u = this.axes.get(i);
472
- return u === void 0 ? m(a) : u;
480
+ return u === void 0 ? p(a) : u;
473
481
  }), !t || t.length === 0)
474
482
  return r;
475
483
  const s = [];
@@ -501,7 +509,7 @@ class In {
501
509
  return G(this.derive(e, t));
502
510
  }
503
511
  }
504
- function Dn(n, e, t) {
512
+ function Vn(n, e, t) {
505
513
  const r = { ...e }, o = (t == null ? void 0 : t.ignoreMissingDomains) ?? !1;
506
514
  if (r.domainAnchor !== void 0) {
507
515
  const s = n[r.domainAnchor];
@@ -548,7 +556,7 @@ function Q(n, e) {
548
556
  throw new Error(`Axis with name "${e.name}" not found in anchor "${t}"`);
549
557
  return o[0];
550
558
  } else if ("id" in e) {
551
- const o = r.axesSpec.filter((s) => X(e.id, m(s)));
559
+ const o = r.axesSpec.filter((s) => X(e.id, p(s)));
552
560
  if (o.length > 1)
553
561
  throw new Error(`Multiple matching axes found for matcher in anchor "${t}"`);
554
562
  if (o.length === 0)
@@ -560,7 +568,7 @@ function Q(n, e) {
560
568
  function Y(n) {
561
569
  return typeof n == "object" && "anchor" in n;
562
570
  }
563
- function Ln(n) {
571
+ function Bn(n) {
564
572
  return typeof n == "object" && n !== null && "source" in n && "axisFilters" in n;
565
573
  }
566
574
  function f(n) {
@@ -569,23 +577,23 @@ function f(n) {
569
577
  function Z(n) {
570
578
  return f(n.spec);
571
579
  }
572
- function Vn(n) {
580
+ function jn(n) {
573
581
  return f(n.obj);
574
582
  }
575
- function Bn(n) {
583
+ function Fn(n) {
576
584
  return f(n.obj.spec);
577
585
  }
578
- function jn(n) {
586
+ function Un(n) {
579
587
  if (!Z(n)) throw new Error(`not a PColumn (kind = ${n.spec.kind})`);
580
588
  return n;
581
589
  }
582
- function Fn(n, e) {
590
+ function Kn(n, e) {
583
591
  return n === void 0 ? void 0 : {
584
592
  ...n,
585
593
  data: e(n.data)
586
594
  };
587
595
  }
588
- function Un(n) {
596
+ function Rn(n) {
589
597
  const e = /* @__PURE__ */ new Map(), t = (r) => {
590
598
  switch (r.type) {
591
599
  case "column":
@@ -680,7 +688,7 @@ function N(n, e) {
680
688
  return !1;
681
689
  }
682
690
  if (e.axes !== void 0) {
683
- const t = n.axesSpec.map(m);
691
+ const t = n.axesSpec.map(p);
684
692
  if (e.partialAxesMatch) {
685
693
  for (const r of e.axes)
686
694
  if (!t.some((o) => k(r, o)))
@@ -709,21 +717,28 @@ function N(n, e) {
709
717
  }
710
718
  return !0;
711
719
  }
712
- function Kn(n) {
720
+ function vn(n) {
713
721
  return Array.isArray(n) ? (e) => n.some((t) => f(e) && N(e, t)) : (e) => f(e) && N(e, n);
714
722
  }
715
- const Rn = { href: "/" }, _n = p.object({
716
- __isRef: p.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
717
- blockId: p.string().describe("Upstream block id"),
718
- name: p.string().describe("Name of the output provided to the upstream block's output context"),
719
- requireEnrichments: p.literal(!0).optional().describe("True if current block that stores this reference in its args, may need enrichments for the references value originating from the blocks in between current and referenced block")
723
+ function _n(n) {
724
+ const e = {
725
+ kind: n.kind,
726
+ name: n.name
727
+ };
728
+ return n.domain !== void 0 && (e.domain = n.domain), f(n) && (e.axesSpec = C(n.axesSpec)), y(e);
729
+ }
730
+ const Mn = { href: "/" }, Tn = m.object({
731
+ __isRef: m.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
732
+ blockId: m.string().describe("Upstream block id"),
733
+ name: m.string().describe("Name of the output provided to the upstream block's output context"),
734
+ requireEnrichments: m.literal(!0).optional().describe("True if current block that stores this reference in its args, may need enrichments for the references value originating from the blocks in between current and referenced block")
720
735
  }).describe(
721
736
  "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."
722
737
  ).readonly();
723
- function Mn(n) {
738
+ function Hn(n) {
724
739
  return typeof n == "object" && n !== null && "__isRef" in n && n.__isRef === !0 && "blockId" in n && "name" in n;
725
740
  }
726
- function Tn(n, e, t = !1) {
741
+ function qn(n, e, t = !1) {
727
742
  return t ? {
728
743
  __isRef: !0,
729
744
  blockId: n,
@@ -735,7 +750,7 @@ function Tn(n, e, t = !1) {
735
750
  name: e
736
751
  };
737
752
  }
738
- function vn(n, e = !0) {
753
+ function Wn(n, e = !0) {
739
754
  if (e)
740
755
  return {
741
756
  ...n,
@@ -746,10 +761,10 @@ function vn(n, e = !0) {
746
761
  return r;
747
762
  }
748
763
  }
749
- function Hn(n, e, t = !1) {
764
+ function zn(n, e, t = !1) {
750
765
  return n.blockId === e.blockId && n.name === e.name && (t || n.requireEnrichments === e.requireEnrichments);
751
766
  }
752
- function qn(n, e) {
767
+ function Xn(n, e) {
753
768
  return n.ok ? { ok: !0, value: e(n.value) } : n;
754
769
  }
755
770
  function en(n) {
@@ -761,7 +776,7 @@ function en(n) {
761
776
  );
762
777
  }
763
778
  const tn = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", rn = "0123456789ABCDEFGHIJKLMNOPQRSTUV", on = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
764
- function C(n, e, t) {
779
+ function J(n, e, t) {
765
780
  t = t || {};
766
781
  let r, o;
767
782
  switch (e) {
@@ -788,99 +803,102 @@ function C(n, e, t) {
788
803
  c += "=";
789
804
  return c;
790
805
  }
791
- const J = 15, sn = 24, O = p.string().length(sn).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
792
- function Wn() {
793
- const n = new Uint8Array(J);
794
- return crypto.getRandomValues(n), O.parse(C(n, "RFC4648"));
806
+ const O = 15, sn = 24, $ = m.string().length(sn).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
807
+ function Gn() {
808
+ const n = new Uint8Array(O);
809
+ return crypto.getRandomValues(n), $.parse(J(n, "RFC4648"));
795
810
  }
796
811
  function an(n) {
797
- if (n.length !== J) throw new Error(`Wrong number of bytes: ${n.length}`);
798
- return O.parse(C(n, "RFC4648"));
812
+ if (n.length !== O) throw new Error(`Wrong number of bytes: ${n.length}`);
813
+ return $.parse(J(n, "RFC4648"));
799
814
  }
800
- async function zn(n) {
815
+ async function Qn(n) {
801
816
  const e = new TextEncoder(), t = await crypto.subtle.digest("SHA-256", e.encode(n));
802
817
  return an(new Uint8Array(t.slice(0, 15)));
803
818
  }
804
- function Xn(n) {
819
+ function Yn(n) {
805
820
  return JSON.stringify(n);
806
821
  }
807
- function Gn(n) {
808
- return h(n);
822
+ function Zn(n) {
823
+ return y(n);
809
824
  }
810
- function Qn(n) {
825
+ function ne(n) {
811
826
  return JSON.parse(n);
812
827
  }
813
828
  export {
814
- In as AnchoredIdDeriver,
815
- Rn as DefaultNavigationState,
816
- H as PTableAbsent,
817
- q as PTableNA,
818
- K as PValueBytesNA,
819
- Pn as PValueDoubleNA,
820
- wn as PValueFloatNA,
821
- F as PValueIntNA,
829
+ Ln as AnchoredIdDeriver,
830
+ Mn as DefaultNavigationState,
831
+ q as PTableAbsent,
832
+ W as PTableNA,
833
+ R as PValueBytesNA,
834
+ An as PValueDoubleNA,
835
+ xn as PValueFloatNA,
836
+ U as PValueIntNA,
822
837
  P as PValueLongNA,
823
- U as PValueStringNA,
824
- O as PlId,
825
- J as PlIdBytes,
838
+ K as PValueStringNA,
839
+ $ as PlId,
840
+ O as PlIdBytes,
826
841
  sn as PlIdLength,
827
- _n as PlRef,
828
- Jn as canonicalizeAxisId,
829
- Gn as canonicalizeJson,
830
- Tn as createPlRef,
831
- hn as dataInfoToEntries,
832
- zn as digestPlId,
833
- xn as ensureNotNAPValue,
834
- jn as ensurePColumn,
835
- gn as entriesToDataInfo,
842
+ Tn as PlRef,
843
+ $n as canonicalizeAxisId,
844
+ Zn as canonicalizeJson,
845
+ qn as createPlRef,
846
+ bn as dataInfoToEntries,
847
+ _n as deriveNativeId,
848
+ Qn as digestPlId,
849
+ kn as ensureNotNAPValue,
850
+ Un as ensurePColumn,
851
+ wn as entriesToDataInfo,
836
852
  b as executePSpecPredicate,
837
- Un as extractAllColumns,
838
- W as getAxesId,
839
- m as getAxisId,
840
- Cn as getColumnIdAndSpec,
841
- pn as getFileNameFromHandle,
842
- V as getFilePathFromHandle,
843
- Sn as getPColumnSpecId,
844
- mn as isDataInfo,
845
- j as isDataInfoEntries,
846
- Ln as isFilteredPColumn,
847
- L as isImportFileHandleIndex,
848
- D as isImportFileHandleUpload,
849
- dn as isLiveLog,
850
- R as isNotNAPValue,
853
+ Rn as extractAllColumns,
854
+ C as getAxesId,
855
+ p as getAxisId,
856
+ On as getColumnIdAndSpec,
857
+ ln as getFileNameFromHandle,
858
+ B as getFilePathFromHandle,
859
+ Jn as getPColumnSpecId,
860
+ yn as isDataInfo,
861
+ F as isDataInfoEntries,
862
+ Bn as isFilteredPColumn,
863
+ V as isImportFileHandleIndex,
864
+ L as isImportFileHandleUpload,
865
+ pn as isLiveLog,
866
+ v as isNotNAPValue,
851
867
  Z as isPColumn,
852
- Bn as isPColumnResult,
868
+ Fn as isPColumnResult,
853
869
  f as isPColumnSpec,
854
- Vn as isPColumnSpecResult,
855
- Nn as isPTableAbsent,
870
+ jn as isPColumnSpecResult,
871
+ Sn as isPTableAbsent,
856
872
  _ as isPValue,
857
- yn as isPartitionedDataInfoEntries,
858
- Mn as isPlRef,
859
- v as isValueAbsent,
873
+ gn as isPartitionedDataInfoEntries,
874
+ Hn as isPlRef,
875
+ H as isValueAbsent,
860
876
  g as isValueNA,
861
- ln as mapDataInfo,
862
- bn as mapDataInfoEntries,
863
- y as mapJoinEntry,
864
- Fn as mapPObjectData,
865
- On as mapPTableDef,
866
- qn as mapValueInVOE,
877
+ hn as mapDataInfo,
878
+ Pn as mapDataInfoEntries,
879
+ h as mapJoinEntry,
880
+ Kn as mapPObjectData,
881
+ In as mapPTableDef,
882
+ Xn as mapValueInVOE,
867
883
  k as matchAxis,
868
884
  X as matchAxisId,
869
885
  N as matchPColumn,
870
- En as pTableValue,
871
- kn as pValueToStringOrNumber,
886
+ dn as newRangeBytesOpt,
887
+ Cn as pTableValue,
888
+ En as pValueToStringOrNumber,
872
889
  T as pValueToStringOrNumberOrNull,
873
- $n as parseColumnId,
874
- Qn as parseJson,
890
+ Dn as parseColumnId,
891
+ ne as parseJson,
875
892
  an as plId,
876
- Hn as plRefsEqual,
877
- Dn as resolveAnchors,
893
+ zn as plRefsEqual,
894
+ Vn as resolveAnchors,
878
895
  M as safeConvertToPValue,
879
- Kn as selectorsToPredicate,
896
+ vn as selectorsToPredicate,
880
897
  G as stringifyColumnId,
881
- Xn as stringifyJson,
882
- An as toJsonSafePValue,
883
- Wn as uniquePlId,
884
- vn as withEnrichments
898
+ Yn as stringifyJson,
899
+ Nn as toJsonSafePValue,
900
+ Gn as uniquePlId,
901
+ mn as validateRangeBytes,
902
+ Wn as withEnrichments
885
903
  };
886
904
  //# sourceMappingURL=index.mjs.map