@milaboratories/pl-model-common 1.13.7 → 1.14.0

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,28 +1,28 @@
1
- var I = Object.defineProperty;
2
- var $ = (n, t, e) => t in n ? I(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var m = (n, t, e) => $(n, typeof t != "symbol" ? t + "" : t, e);
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
4
  import h from "canonicalize";
5
- import { z as y } from "zod";
5
+ import { z as p } from "zod";
6
6
  function dn(n) {
7
7
  return n !== void 0 && n.startsWith("log+live://log/");
8
8
  }
9
9
  function w(n) {
10
10
  throw new Error("Unexpected object: " + n);
11
11
  }
12
- const S = "upload://upload/", E = "index://index/";
12
+ const E = "upload://upload/", S = "index://index/";
13
13
  function D(n) {
14
- return n.startsWith(S);
14
+ return n.startsWith(E);
15
15
  }
16
16
  function L(n) {
17
- return n.startsWith(E);
17
+ return n.startsWith(S);
18
18
  }
19
19
  function V(n) {
20
20
  if (L(n)) {
21
- const t = n.slice(E.length);
22
- return JSON.parse(decodeURIComponent(t)).path;
21
+ const e = n.slice(S.length);
22
+ return JSON.parse(decodeURIComponent(e)).path;
23
23
  } else if (D(n)) {
24
- const t = n.slice(S.length);
25
- return JSON.parse(decodeURIComponent(t)).localPath;
24
+ const e = n.slice(E.length);
25
+ return JSON.parse(decodeURIComponent(e)).localPath;
26
26
  }
27
27
  w(n);
28
28
  }
@@ -35,44 +35,44 @@ function pn(n) {
35
35
  function mn(n) {
36
36
  if (!n || typeof n != "object")
37
37
  return !1;
38
- const t = n;
39
- if (!("type" in t))
38
+ const e = n;
39
+ if (!("type" in e))
40
40
  return !1;
41
- switch (t.type) {
41
+ switch (e.type) {
42
42
  case "Json":
43
- return typeof t.keyLength == "number" && t.data !== void 0 && typeof t.data == "object";
43
+ return typeof e.keyLength == "number" && e.data !== void 0 && typeof e.data == "object";
44
44
  case "JsonPartitioned":
45
- return typeof t.partitionKeyLength == "number" && t.parts !== void 0 && typeof t.parts == "object";
45
+ return typeof e.partitionKeyLength == "number" && e.parts !== void 0 && typeof e.parts == "object";
46
46
  case "BinaryPartitioned":
47
- return typeof t.partitionKeyLength == "number" && t.parts !== void 0 && typeof t.parts == "object";
47
+ return typeof e.partitionKeyLength == "number" && e.parts !== void 0 && typeof e.parts == "object";
48
48
  default:
49
49
  return !1;
50
50
  }
51
51
  }
52
- function yn(n, t) {
52
+ function ln(n, e) {
53
53
  if (n !== void 0)
54
54
  switch (n.type) {
55
55
  case "Json":
56
56
  return n;
57
57
  case "JsonPartitioned": {
58
- const e = {};
58
+ const t = {};
59
59
  for (const [r, o] of Object.entries(n.parts))
60
- e[r] = t(o);
60
+ t[r] = e(o);
61
61
  return {
62
62
  ...n,
63
- parts: e
63
+ parts: t
64
64
  };
65
65
  }
66
66
  case "BinaryPartitioned": {
67
- const e = {};
67
+ const t = {};
68
68
  for (const [r, o] of Object.entries(n.parts))
69
- e[r] = {
70
- index: t(o.index),
71
- values: t(o.values)
69
+ t[r] = {
70
+ index: e(o.index),
71
+ values: e(o.values)
72
72
  };
73
73
  return {
74
74
  ...n,
75
- parts: e
75
+ parts: t
76
76
  };
77
77
  }
78
78
  }
@@ -80,47 +80,47 @@ function yn(n, t) {
80
80
  function j(n) {
81
81
  if (!n || typeof n != "object")
82
82
  return !1;
83
- const t = n;
84
- if (!("type" in t))
83
+ const e = n;
84
+ if (!("type" in e))
85
85
  return !1;
86
- switch (t.type) {
86
+ switch (e.type) {
87
87
  case "Json":
88
- return typeof t.keyLength == "number" && Array.isArray(t.data);
88
+ return typeof e.keyLength == "number" && Array.isArray(e.data);
89
89
  case "JsonPartitioned":
90
- return typeof t.partitionKeyLength == "number" && Array.isArray(t.parts);
90
+ return typeof e.partitionKeyLength == "number" && Array.isArray(e.parts);
91
91
  case "BinaryPartitioned":
92
- return typeof t.partitionKeyLength == "number" && Array.isArray(t.parts);
92
+ return typeof e.partitionKeyLength == "number" && Array.isArray(e.parts);
93
93
  default:
94
94
  return !1;
95
95
  }
96
96
  }
97
- function ln(n) {
97
+ function yn(n) {
98
98
  return j(n) ? n.type === "JsonPartitioned" || n.type === "BinaryPartitioned" : !1;
99
99
  }
100
100
  function hn(n) {
101
101
  switch (n.type) {
102
102
  case "Json": {
103
- const t = Object.entries(n.data).map(([e, r]) => ({ key: JSON.parse(e), value: r }));
103
+ const e = Object.entries(n.data).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
104
104
  return {
105
105
  type: "Json",
106
106
  keyLength: n.keyLength,
107
- data: t
107
+ data: e
108
108
  };
109
109
  }
110
110
  case "JsonPartitioned": {
111
- const t = Object.entries(n.parts).map(([e, r]) => ({ key: JSON.parse(e), value: r }));
111
+ const e = Object.entries(n.parts).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
112
112
  return {
113
113
  type: "JsonPartitioned",
114
114
  partitionKeyLength: n.partitionKeyLength,
115
- parts: t
115
+ parts: e
116
116
  };
117
117
  }
118
118
  case "BinaryPartitioned": {
119
- const t = Object.entries(n.parts).map(([e, r]) => ({ key: JSON.parse(e), value: r }));
119
+ const e = Object.entries(n.parts).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
120
120
  return {
121
121
  type: "BinaryPartitioned",
122
122
  partitionKeyLength: n.partitionKeyLength,
123
- parts: t
123
+ parts: e
124
124
  };
125
125
  }
126
126
  }
@@ -128,70 +128,70 @@ function hn(n) {
128
128
  function gn(n) {
129
129
  switch (n.type) {
130
130
  case "Json": {
131
- const t = {};
132
- for (const e of n.data)
133
- t[JSON.stringify(e.key)] = e.value;
131
+ const e = {};
132
+ for (const t of n.data)
133
+ e[JSON.stringify(t.key)] = t.value;
134
134
  return {
135
135
  type: "Json",
136
136
  keyLength: n.keyLength,
137
- data: t
137
+ data: e
138
138
  };
139
139
  }
140
140
  case "JsonPartitioned": {
141
- const t = {};
142
- for (const e of n.parts)
143
- t[JSON.stringify(e.key)] = e.value;
141
+ const e = {};
142
+ for (const t of n.parts)
143
+ e[JSON.stringify(t.key)] = t.value;
144
144
  return {
145
145
  type: "JsonPartitioned",
146
146
  partitionKeyLength: n.partitionKeyLength,
147
- parts: t
147
+ parts: e
148
148
  };
149
149
  }
150
150
  case "BinaryPartitioned": {
151
- const t = {};
152
- for (const e of n.parts)
153
- t[JSON.stringify(e.key)] = e.value;
151
+ const e = {};
152
+ for (const t of n.parts)
153
+ e[JSON.stringify(t.key)] = t.value;
154
154
  return {
155
155
  type: "BinaryPartitioned",
156
156
  partitionKeyLength: n.partitionKeyLength,
157
- parts: t
157
+ parts: e
158
158
  };
159
159
  }
160
160
  }
161
161
  }
162
- function bn(n, t) {
162
+ function bn(n, e) {
163
163
  if (n !== void 0)
164
164
  switch (n.type) {
165
165
  case "Json":
166
166
  return n;
167
167
  case "JsonPartitioned": {
168
- const e = n.parts.map((r) => ({
168
+ const t = n.parts.map((r) => ({
169
169
  key: r.key,
170
- value: t(r.value)
170
+ value: e(r.value)
171
171
  }));
172
172
  return {
173
173
  ...n,
174
- parts: e
174
+ parts: t
175
175
  };
176
176
  }
177
177
  case "BinaryPartitioned": {
178
- const e = n.parts.map((r) => ({
178
+ const t = n.parts.map((r) => ({
179
179
  key: r.key,
180
180
  value: {
181
- index: t(r.value.index),
182
- values: t(r.value.values)
181
+ index: e(r.value.index),
182
+ values: e(r.value.values)
183
183
  }
184
184
  }));
185
185
  return {
186
186
  ...n,
187
- parts: e
187
+ parts: t
188
188
  };
189
189
  }
190
190
  }
191
191
  }
192
192
  const F = -2147483648, P = -9007199254740991n, wn = NaN, Pn = NaN, U = null, K = null;
193
- function g(n, t) {
194
- switch (t) {
193
+ function g(n, e) {
194
+ switch (e) {
195
195
  case "Int":
196
196
  return n === F;
197
197
  case "Long":
@@ -205,18 +205,18 @@ function g(n, t) {
205
205
  case "Bytes":
206
206
  return n === K;
207
207
  default:
208
- throw Error(`unsupported data type: ${t}`);
208
+ throw Error(`unsupported data type: ${e}`);
209
209
  }
210
210
  }
211
211
  function xn(n) {
212
212
  if (!R(n)) throw new Error(`Expected not-NA PValue, got ${n}`);
213
213
  return n;
214
214
  }
215
- function R(n, t) {
216
- if (!t)
215
+ function R(n, e) {
216
+ if (!e)
217
217
  return typeof n == "string" || typeof n == "number" && isFinite(n) || typeof n == "bigint";
218
- if (g(n, t)) return !1;
219
- switch (t) {
218
+ if (g(n, e)) return !1;
219
+ switch (e) {
220
220
  case "Int":
221
221
  return typeof n == "number";
222
222
  case "Long":
@@ -230,14 +230,14 @@ function R(n, t) {
230
230
  case "Bytes":
231
231
  throw Error("Bytes not yet supported");
232
232
  default:
233
- throw Error(`unsupported data type: ${t}`);
233
+ throw Error(`unsupported data type: ${e}`);
234
234
  }
235
235
  }
236
- function M(n, t) {
237
- if (!t)
236
+ function _(n, e) {
237
+ if (!e)
238
238
  return n === null || typeof n == "string" || typeof n == "number" || typeof n == "bigint";
239
- if (g(n, t)) return !0;
240
- switch (t) {
239
+ if (g(n, e)) return !0;
240
+ switch (e) {
241
241
  case "Int":
242
242
  return typeof n == "number";
243
243
  case "Long":
@@ -251,7 +251,7 @@ function M(n, t) {
251
251
  case "Bytes":
252
252
  throw Error("Bytes not yet supported");
253
253
  default:
254
- throw Error(`unsupported data type: ${t}`);
254
+ throw Error(`unsupported data type: ${e}`);
255
255
  }
256
256
  }
257
257
  function An(n) {
@@ -259,25 +259,25 @@ function An(n) {
259
259
  if (typeof n == "bigint") return { bigint: n.toString() };
260
260
  throw new Error(`Type ${typeof n} (value ${n}) not yet supported.`);
261
261
  }
262
- function T(n, t) {
262
+ function M(n, e) {
263
263
  if (n === null || typeof n == "string" || typeof n == "number" || typeof n == "bigint") {
264
- if (t && !g(n, t) && !M(n, t))
265
- throw new Error(`Unexpected value type, got ${typeof n}, expected ${t}`);
264
+ if (e && !g(n, e) && !_(n, e))
265
+ throw new Error(`Unexpected value type, got ${typeof n}, expected ${e}`);
266
266
  return n;
267
267
  }
268
268
  if (typeof n == "object" && n !== null && "bigint" in n && typeof n.bigint == "string") {
269
- if (t && t !== "Long")
270
- throw new Error(`Unexpected value type, got serialized bigint, expected ${t}`);
269
+ if (e && e !== "Long")
270
+ throw new Error(`Unexpected value type, got serialized bigint, expected ${e}`);
271
271
  return BigInt(n.bigint);
272
272
  }
273
273
  throw new Error(`Unsupported type ${typeof n} (value ${n}).`);
274
274
  }
275
275
  function kn(n) {
276
- if (n = v(n), n === null) throw new Error("Value is null");
276
+ if (n = T(n), n === null) throw new Error("Value is null");
277
277
  return n;
278
278
  }
279
- function v(n) {
280
- if (n = T(n), n === null) return null;
279
+ function T(n) {
280
+ if (n = M(n), n === null) return null;
281
281
  if (typeof n == "string") return n;
282
282
  if (typeof n == "number") {
283
283
  if (!isFinite(n)) throw new Error(`Value is not finite (${n})`);
@@ -287,19 +287,19 @@ function v(n) {
287
287
  return Number(n);
288
288
  throw new Error(`Unexpected value type: ${typeof n}`);
289
289
  }
290
- function _(n, t) {
291
- const e = Math.floor(t / 8), r = 1 << 7 - t % 8;
292
- return (n[e] & r) > 0;
290
+ function v(n, e) {
291
+ const t = Math.floor(e / 8), r = 1 << 7 - e % 8;
292
+ return (n[t] & r) > 0;
293
293
  }
294
- const H = { type: "absent" }, W = null;
294
+ const H = { type: "absent" }, q = null;
295
295
  function Nn(n) {
296
296
  return typeof n == "object" && n !== null && n.type === "absent";
297
297
  }
298
- function Sn(n, t, e = {}) {
299
- if (_(n.absent, t))
300
- return e.absent === void 0 ? H : e.absent;
301
- const r = n.data[t], o = n.type;
302
- if (g(r, o)) return e.na === void 0 ? W : e.na;
298
+ function En(n, e, t = {}) {
299
+ if (v(n.absent, e))
300
+ return t.absent === void 0 ? H : t.absent;
301
+ const r = n.data[e], o = n.type;
302
+ if (g(r, o)) return t.na === void 0 ? q : t.na;
303
303
  switch (o) {
304
304
  case "Int":
305
305
  return r;
@@ -317,14 +317,14 @@ function Sn(n, t, e = {}) {
317
317
  throw Error(`unsupported data type: ${o}`);
318
318
  }
319
319
  }
320
- function En(n) {
320
+ function Sn(n) {
321
321
  return {
322
322
  kind: n.kind,
323
323
  valueType: n.valueType,
324
324
  name: n.name,
325
325
  domain: n.domain,
326
326
  parentAxes: n.parentAxes,
327
- axesId: z(n.axesSpec)
327
+ axesId: W(n.axesSpec)
328
328
  };
329
329
  }
330
330
  function Cn(n) {
@@ -333,40 +333,40 @@ function Cn(n) {
333
333
  spec: n.spec
334
334
  };
335
335
  }
336
- function p(n) {
337
- const { type: t, name: e, domain: r } = n;
338
- return { type: t, name: e, ...r && { domain: r } };
336
+ function m(n) {
337
+ const { type: e, name: t, domain: r } = n;
338
+ return { type: e, name: t, ...r && { domain: r } };
339
339
  }
340
- function z(n) {
341
- return n.map(p);
340
+ function W(n) {
341
+ return n.map(m);
342
342
  }
343
343
  function Jn(n) {
344
- return h(p(n));
344
+ return h(m(n));
345
345
  }
346
- function X(n, t) {
347
- if (n === void 0) return t === void 0;
348
- if (t === void 0) return !0;
349
- for (const e in t)
350
- if (n[e] !== t[e]) return !1;
346
+ function z(n, e) {
347
+ if (n === void 0) return e === void 0;
348
+ if (e === void 0) return !0;
349
+ for (const t in e)
350
+ if (n[t] !== e[t]) return !1;
351
351
  return !0;
352
352
  }
353
- function G(n, t) {
354
- return n.name === t.name && X(n.domain, t.domain);
353
+ function X(n, e) {
354
+ return n.name === e.name && z(n.domain, e.domain);
355
355
  }
356
- function On(n, t) {
357
- return { ...n, src: l(n.src, t) };
356
+ function On(n, e) {
357
+ return { ...n, src: y(n.src, e) };
358
358
  }
359
- function l(n, t) {
359
+ function y(n, e) {
360
360
  switch (n.type) {
361
361
  case "column":
362
362
  return {
363
363
  type: "column",
364
- column: t(n.column)
364
+ column: e(n.column)
365
365
  };
366
366
  case "slicedColumn":
367
367
  return {
368
368
  type: "slicedColumn",
369
- column: t(n.column),
369
+ column: e(n.column),
370
370
  newId: n.newId,
371
371
  axisFilters: n.axisFilters
372
372
  };
@@ -374,51 +374,51 @@ function l(n, t) {
374
374
  case "full":
375
375
  return {
376
376
  type: n.type,
377
- entries: n.entries.map((e) => l(e, t))
377
+ entries: n.entries.map((t) => y(t, e))
378
378
  };
379
379
  case "outer":
380
380
  return {
381
381
  type: "outer",
382
- primary: l(n.primary, t),
383
- secondary: n.secondary.map((e) => l(e, t))
382
+ primary: y(n.primary, e),
383
+ secondary: n.secondary.map((t) => y(t, e))
384
384
  };
385
385
  default:
386
386
  w(n);
387
387
  }
388
388
  }
389
- function Q(n) {
389
+ function G(n) {
390
390
  return h(n);
391
391
  }
392
- function In(n) {
392
+ function $n(n) {
393
393
  return JSON.parse(n);
394
394
  }
395
395
  function x(n) {
396
- return h(p(n));
396
+ return h(m(n));
397
397
  }
398
- function A(n, t) {
399
- return JSON.stringify([n, t]);
398
+ function A(n, e) {
399
+ return JSON.stringify([n, e]);
400
400
  }
401
- class $n {
401
+ class In {
402
402
  /**
403
403
  * Creates a new anchor context from a set of anchor column specifications
404
404
  * @param anchors Record of anchor column specifications indexed by anchor ID
405
405
  */
406
- constructor(t) {
407
- m(this, "domains", /* @__PURE__ */ new Map());
408
- m(this, "axes", /* @__PURE__ */ new Map());
406
+ constructor(e) {
407
+ l(this, "domains", /* @__PURE__ */ new Map());
408
+ l(this, "axes", /* @__PURE__ */ new Map());
409
409
  /**
410
410
  * Domain packs are used to group domain keys that can be anchored to the same anchor
411
411
  * This is used to optimize the lookup of domain anchors
412
412
  */
413
- m(this, "domainPacks", []);
413
+ l(this, "domainPacks", []);
414
414
  /**
415
415
  * Maps domain packs to anchors
416
416
  */
417
- m(this, "domainPackToAnchor", /* @__PURE__ */ new Map());
418
- this.anchors = t;
419
- const e = Object.entries(t);
420
- e.sort((r, o) => r[0].localeCompare(o[0]));
421
- for (const [r, o] of e) {
417
+ l(this, "domainPackToAnchor", /* @__PURE__ */ new Map());
418
+ this.anchors = e;
419
+ const t = Object.entries(e);
420
+ t.sort((r, o) => r[0].localeCompare(o[0]));
421
+ for (const [r, o] of t) {
422
422
  for (let s = 0; s < o.axesSpec.length; s++) {
423
423
  const a = o.axesSpec[s], i = x(a);
424
424
  this.axes.set(i, { anchor: r, idx: s });
@@ -436,18 +436,18 @@ class $n {
436
436
  /**
437
437
  * Implementation of derive method
438
438
  */
439
- derive(t, e) {
439
+ derive(e, t) {
440
440
  const r = {
441
- name: t.name,
441
+ name: e.name,
442
442
  axes: []
443
443
  };
444
444
  let o;
445
- if (t.domain !== void 0)
445
+ if (e.domain !== void 0)
446
446
  n:
447
447
  for (const a of this.domainPacks) {
448
448
  const i = [];
449
449
  for (const c of a) {
450
- const d = t.domain[c];
450
+ const d = e.domain[c];
451
451
  if (d !== void 0)
452
452
  i.push([c, d]);
453
453
  else
@@ -459,26 +459,26 @@ class $n {
459
459
  break;
460
460
  }
461
461
  }
462
- for (const [a, i] of Object.entries(t.domain ?? {})) {
462
+ for (const [a, i] of Object.entries(e.domain ?? {})) {
463
463
  if (o !== void 0 && o.has(a))
464
464
  continue;
465
465
  const u = A(a, i), c = this.domains.get(u);
466
466
  r.domain ?? (r.domain = {}), r.domain[a] = c ? { anchor: c } : i;
467
467
  }
468
- if (r.axes = t.axesSpec.map((a) => {
468
+ if (r.axes = e.axesSpec.map((a) => {
469
469
  const i = x(a), u = this.axes.get(i);
470
- return u === void 0 ? p(a) : u;
471
- }), !e || e.length === 0)
470
+ return u === void 0 ? m(a) : u;
471
+ }), !t || t.length === 0)
472
472
  return r;
473
473
  const s = [];
474
- for (const a of e) {
474
+ for (const a of t) {
475
475
  const [i, u] = a;
476
476
  if (typeof i == "number") {
477
- if (i < 0 || i >= t.axesSpec.length)
478
- throw new Error(`Axis index ${i} is out of bounds (0-${t.axesSpec.length - 1})`);
477
+ if (i < 0 || i >= e.axesSpec.length)
478
+ throw new Error(`Axis index ${i} is out of bounds (0-${e.axesSpec.length - 1})`);
479
479
  s.push([i, u]);
480
480
  } else {
481
- const c = t.axesSpec.findIndex((d) => d.name === i);
481
+ const c = e.axesSpec.findIndex((d) => d.name === i);
482
482
  if (c === -1)
483
483
  throw new Error(`Axis with name "${i}" not found in the column specification`);
484
484
  s.push([c, u]);
@@ -495,12 +495,12 @@ class $n {
495
495
  * @param axisFilters Optional axis filters to apply to the column
496
496
  * @returns A canonicalized string representation of the anchored column identifier
497
497
  */
498
- deriveS(t, e) {
499
- return Q(this.derive(t, e));
498
+ deriveS(e, t) {
499
+ return G(this.derive(e, t));
500
500
  }
501
501
  }
502
- function Dn(n, t, e) {
503
- const r = { ...t }, o = (e == null ? void 0 : e.ignoreMissingDomains) ?? !1;
502
+ function Dn(n, e, t) {
503
+ const r = { ...e }, o = (t == null ? void 0 : t.ignoreMissingDomains) ?? !1;
504
504
  if (r.domainAnchor !== void 0) {
505
505
  const s = n[r.domainAnchor];
506
506
  if (!s)
@@ -526,36 +526,36 @@ function Dn(n, t, e) {
526
526
  }
527
527
  r.domain = s;
528
528
  }
529
- return r.axes && (r.axes = r.axes.map((s) => Y(n, s))), r;
529
+ return r.axes && (r.axes = r.axes.map((s) => Q(n, s))), r;
530
530
  }
531
- function Y(n, t) {
532
- if (!Z(t))
533
- return t;
534
- const e = t.anchor, r = n[e];
531
+ function Q(n, e) {
532
+ if (!Y(e))
533
+ return e;
534
+ const t = e.anchor, r = n[t];
535
535
  if (!r)
536
- throw new Error(`Anchor "${e}" not found for axis reference`);
537
- if ("idx" in t) {
538
- if (t.idx < 0 || t.idx >= r.axesSpec.length)
539
- throw new Error(`Axis index ${t.idx} out of bounds for anchor "${e}"`);
540
- return r.axesSpec[t.idx];
541
- } else if ("name" in t) {
542
- const o = r.axesSpec.filter((s) => s.name === t.name);
536
+ throw new Error(`Anchor "${t}" not found for axis reference`);
537
+ if ("idx" in e) {
538
+ if (e.idx < 0 || e.idx >= r.axesSpec.length)
539
+ throw new Error(`Axis index ${e.idx} out of bounds for anchor "${t}"`);
540
+ return r.axesSpec[e.idx];
541
+ } else if ("name" in e) {
542
+ const o = r.axesSpec.filter((s) => s.name === e.name);
543
543
  if (o.length > 1)
544
- throw new Error(`Multiple axes with name "${t.name}" found in anchor "${e}"`);
544
+ throw new Error(`Multiple axes with name "${e.name}" found in anchor "${t}"`);
545
545
  if (o.length === 0)
546
- throw new Error(`Axis with name "${t.name}" not found in anchor "${e}"`);
546
+ throw new Error(`Axis with name "${e.name}" not found in anchor "${t}"`);
547
547
  return o[0];
548
- } else if ("id" in t) {
549
- const o = r.axesSpec.filter((s) => G(t.id, p(s)));
548
+ } else if ("id" in e) {
549
+ const o = r.axesSpec.filter((s) => X(e.id, m(s)));
550
550
  if (o.length > 1)
551
- throw new Error(`Multiple matching axes found for matcher in anchor "${e}"`);
551
+ throw new Error(`Multiple matching axes found for matcher in anchor "${t}"`);
552
552
  if (o.length === 0)
553
- throw new Error(`No matching axis found for matcher in anchor "${e}"`);
553
+ throw new Error(`No matching axis found for matcher in anchor "${t}"`);
554
554
  return o[0];
555
555
  }
556
556
  throw new Error("Unsupported axis reference type");
557
557
  }
558
- function Z(n) {
558
+ function Y(n) {
559
559
  return typeof n == "object" && "anchor" in n;
560
560
  }
561
561
  function Ln(n) {
@@ -564,7 +564,7 @@ function Ln(n) {
564
564
  function f(n) {
565
565
  return n.kind === "PColumn";
566
566
  }
567
- function q(n) {
567
+ function Z(n) {
568
568
  return f(n.spec);
569
569
  }
570
570
  function Vn(n) {
@@ -574,65 +574,65 @@ function Bn(n) {
574
574
  return f(n.obj.spec);
575
575
  }
576
576
  function jn(n) {
577
- if (!q(n)) throw new Error(`not a PColumn (kind = ${n.spec.kind})`);
577
+ if (!Z(n)) throw new Error(`not a PColumn (kind = ${n.spec.kind})`);
578
578
  return n;
579
579
  }
580
- function Fn(n, t) {
580
+ function Fn(n, e) {
581
581
  return n === void 0 ? void 0 : {
582
582
  ...n,
583
- data: t(n.data)
583
+ data: e(n.data)
584
584
  };
585
585
  }
586
586
  function Un(n) {
587
- const t = /* @__PURE__ */ new Map(), e = (r) => {
587
+ const e = /* @__PURE__ */ new Map(), t = (r) => {
588
588
  switch (r.type) {
589
589
  case "column":
590
- t.set(r.column.id, r.column);
590
+ e.set(r.column.id, r.column);
591
591
  return;
592
592
  case "slicedColumn":
593
- t.set(r.column.id, r.column);
593
+ e.set(r.column.id, r.column);
594
594
  return;
595
595
  case "full":
596
596
  case "inner":
597
- for (const o of r.entries) e(o);
597
+ for (const o of r.entries) t(o);
598
598
  return;
599
599
  case "outer":
600
- e(r.primary);
601
- for (const o of r.secondary) e(o);
600
+ t(r.primary);
601
+ for (const o of r.secondary) t(o);
602
602
  return;
603
603
  default:
604
604
  w(r);
605
605
  }
606
606
  };
607
- return e(n), [...t.values()];
607
+ return t(n), [...e.values()];
608
608
  }
609
609
  function nn(n) {
610
610
  throw new Error("Unexpected object: " + n);
611
611
  }
612
- function b(n, t) {
612
+ function b(n, e) {
613
613
  switch (n.type) {
614
614
  case "and":
615
- for (const e of n.operands)
616
- if (!b(e, t)) return !1;
615
+ for (const t of n.operands)
616
+ if (!b(t, e)) return !1;
617
617
  return !0;
618
618
  case "or":
619
- for (const e of n.operands)
620
- if (b(e, t)) return !0;
619
+ for (const t of n.operands)
620
+ if (b(t, e)) return !0;
621
621
  return !1;
622
622
  case "not":
623
- return !b(n.operand, t);
623
+ return !b(n.operand, e);
624
624
  case "name":
625
- return f(t) && t.name === n.name;
625
+ return f(e) && e.name === n.name;
626
626
  case "name_pattern":
627
- return f(t) && !!t.name.match(n.pattern);
627
+ return f(e) && !!e.name.match(n.pattern);
628
628
  case "annotation":
629
- return f(t) && t.annotations !== void 0 && t.annotations[n.annotation] === n.value;
629
+ return f(e) && e.annotations !== void 0 && e.annotations[n.annotation] === n.value;
630
630
  case "annotation_pattern":
631
- return f(t) && t.annotations !== void 0 && t.annotations[n.annotation] !== void 0 && !!t.annotations[n.annotation].match(n.pattern);
631
+ return f(e) && e.annotations !== void 0 && e.annotations[n.annotation] !== void 0 && !!e.annotations[n.annotation].match(n.pattern);
632
632
  case "has_axes":
633
- return f(t) && n.axes.every(
634
- (e) => t.axesSpec.some(
635
- (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(
633
+ return f(e) && n.axes.every(
634
+ (t) => e.axesSpec.some(
635
+ (r) => (t.type === void 0 || t.type === r.type) && (t.name === void 0 || t.name === r.name) && (t.domain === void 0 || Object.keys(t.domain).length === 0 || r.domain !== void 0 && Object.entries(t.domain).every(
636
636
  ([o, s]) => r.domain[o] === s
637
637
  ))
638
638
  )
@@ -641,64 +641,64 @@ function b(n, t) {
641
641
  nn(n);
642
642
  }
643
643
  }
644
- function k(n, t) {
645
- if (n.name !== void 0 && n.name !== t.name)
644
+ function k(n, e) {
645
+ if (n.name !== void 0 && n.name !== e.name)
646
646
  return !1;
647
647
  if (n.type !== void 0) {
648
648
  if (Array.isArray(n.type)) {
649
- if (!n.type.includes(t.type))
649
+ if (!n.type.includes(e.type))
650
650
  return !1;
651
- } else if (n.type !== t.type)
651
+ } else if (n.type !== e.type)
652
652
  return !1;
653
653
  }
654
654
  if (n.domain !== void 0) {
655
- const e = t.domain || {};
655
+ const t = e.domain || {};
656
656
  for (const [r, o] of Object.entries(n.domain))
657
- if (e[r] !== o)
657
+ if (t[r] !== o)
658
658
  return !1;
659
659
  }
660
660
  return !0;
661
661
  }
662
- function N(n, t) {
663
- if (t.name !== void 0 && n.name !== t.name || t.namePattern !== void 0 && !new RegExp(t.namePattern).test(n.name))
662
+ function N(n, e) {
663
+ if (e.name !== void 0 && n.name !== e.name || e.namePattern !== void 0 && !new RegExp(e.namePattern).test(n.name))
664
664
  return !1;
665
- if (t.type !== void 0) {
666
- if (Array.isArray(t.type)) {
667
- if (!t.type.includes(n.valueType))
665
+ if (e.type !== void 0) {
666
+ if (Array.isArray(e.type)) {
667
+ if (!e.type.includes(n.valueType))
668
668
  return !1;
669
- } else if (t.type !== n.valueType)
669
+ } else if (e.type !== n.valueType)
670
670
  return !1;
671
671
  }
672
- if (t.domain !== void 0) {
673
- const e = n.domain || {};
674
- for (const [r, o] of Object.entries(t.domain))
675
- if (e[r] !== o)
672
+ if (e.domain !== void 0) {
673
+ const t = n.domain || {};
674
+ for (const [r, o] of Object.entries(e.domain))
675
+ if (t[r] !== o)
676
676
  return !1;
677
677
  }
678
- if (t.axes !== void 0) {
679
- const e = n.axesSpec.map(p);
680
- if (t.partialAxesMatch) {
681
- for (const r of t.axes)
682
- if (!e.some((o) => k(r, o)))
678
+ if (e.axes !== void 0) {
679
+ const t = n.axesSpec.map(m);
680
+ if (e.partialAxesMatch) {
681
+ for (const r of e.axes)
682
+ if (!t.some((o) => k(r, o)))
683
683
  return !1;
684
684
  } else {
685
- if (e.length !== t.axes.length)
685
+ if (t.length !== e.axes.length)
686
686
  return !1;
687
- for (let r = 0; r < t.axes.length; r++)
688
- if (!k(t.axes[r], e[r]))
687
+ for (let r = 0; r < e.axes.length; r++)
688
+ if (!k(e.axes[r], t[r]))
689
689
  return !1;
690
690
  }
691
691
  }
692
- if (t.annotations !== void 0) {
693
- const e = n.annotations || {};
694
- for (const [r, o] of Object.entries(t.annotations))
695
- if (e[r] !== o)
692
+ if (e.annotations !== void 0) {
693
+ const t = n.annotations || {};
694
+ for (const [r, o] of Object.entries(e.annotations))
695
+ if (t[r] !== o)
696
696
  return !1;
697
697
  }
698
- if (t.annotationPatterns !== void 0) {
699
- const e = n.annotations || {};
700
- for (const [r, o] of Object.entries(t.annotationPatterns)) {
701
- const s = e[r];
698
+ if (e.annotationPatterns !== void 0) {
699
+ const t = n.annotations || {};
700
+ for (const [r, o] of Object.entries(e.annotationPatterns)) {
701
+ const s = t[r];
702
702
  if (s === void 0 || !new RegExp(o).test(s))
703
703
  return !1;
704
704
  }
@@ -706,25 +706,49 @@ function N(n, t) {
706
706
  return !0;
707
707
  }
708
708
  function Kn(n) {
709
- return Array.isArray(n) ? (t) => n.some((e) => f(t) && N(t, e)) : (t) => f(t) && N(t, n);
709
+ return Array.isArray(n) ? (e) => n.some((t) => f(e) && N(e, t)) : (e) => f(e) && N(e, n);
710
710
  }
711
- const Rn = { href: "/" }, Mn = y.object({
712
- __isRef: y.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
713
- blockId: y.string().describe("Upstream block id"),
714
- name: y.string().describe("Name of the output provided to the upstream block's output context")
711
+ const Rn = { href: "/" }, _n = p.object({
712
+ __isRef: p.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
713
+ blockId: p.string().describe("Upstream block id"),
714
+ name: p.string().describe("Name of the output provided to the upstream block's output context"),
715
+ 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")
715
716
  }).describe(
716
717
  "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."
717
- ).strict().readonly();
718
- function Tn(n) {
718
+ ).readonly();
719
+ function Mn(n) {
719
720
  return typeof n == "object" && n !== null && "__isRef" in n && n.__isRef === !0 && "blockId" in n && "name" in n;
720
721
  }
721
- function vn(n, t) {
722
- return n.blockId === t.blockId && n.name === t.name;
722
+ function Tn(n, e, t = !1) {
723
+ return t ? {
724
+ __isRef: !0,
725
+ blockId: n,
726
+ name: e,
727
+ requireEnrichments: !0
728
+ } : {
729
+ __isRef: !0,
730
+ blockId: n,
731
+ name: e
732
+ };
723
733
  }
724
- function _n(n, t) {
725
- return n.ok ? { ok: !0, value: t(n.value) } : n;
734
+ function vn(n, e = !0) {
735
+ if (e)
736
+ return {
737
+ ...n,
738
+ requireEnrichments: !0
739
+ };
740
+ {
741
+ const { requireEnrichments: t, ...r } = n;
742
+ return r;
743
+ }
744
+ }
745
+ function Hn(n, e, t = !1) {
746
+ return n.blockId === e.blockId && n.name === e.name && (t || n.requireEnrichments === e.requireEnrichments);
726
747
  }
727
- function tn(n) {
748
+ function qn(n, e) {
749
+ return n.ok ? { ok: !0, value: e(n.value) } : n;
750
+ }
751
+ function en(n) {
728
752
  if (n instanceof Int8Array || n instanceof Uint8Array || n instanceof Uint8ClampedArray)
729
753
  return new DataView(n.buffer, n.byteOffset, n.byteLength);
730
754
  if (n instanceof ArrayBuffer) return new DataView(n);
@@ -732,14 +756,14 @@ function tn(n) {
732
756
  "Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray"
733
757
  );
734
758
  }
735
- const en = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", rn = "0123456789ABCDEFGHIJKLMNOPQRSTUV", on = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
736
- function C(n, t, e) {
737
- e = e || {};
759
+ const tn = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", rn = "0123456789ABCDEFGHIJKLMNOPQRSTUV", on = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
760
+ function C(n, e, t) {
761
+ t = t || {};
738
762
  let r, o;
739
- switch (t) {
763
+ switch (e) {
740
764
  case "RFC3548":
741
765
  case "RFC4648":
742
- r = en, o = !0;
766
+ r = tn, o = !0;
743
767
  break;
744
768
  case "RFC4648-HEX":
745
769
  r = rn, o = !0;
@@ -748,9 +772,9 @@ function C(n, t, e) {
748
772
  r = on, o = !1;
749
773
  break;
750
774
  default:
751
- throw new Error("Unknown base32 variant: " + String(t));
775
+ throw new Error("Unknown base32 variant: " + String(e));
752
776
  }
753
- const s = e.padding !== void 0 ? e.padding : o, a = tn(n);
777
+ const s = t.padding !== void 0 ? t.padding : o, a = en(n);
754
778
  let i = 0, u = 0, c = "";
755
779
  for (let d = 0; d < a.byteLength; d++)
756
780
  for (u = u << 8 | a.getUint8(d), i += 8; i >= 5; )
@@ -760,8 +784,8 @@ function C(n, t, e) {
760
784
  c += "=";
761
785
  return c;
762
786
  }
763
- const J = 15, sn = 24, O = y.string().length(sn).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
764
- function Hn() {
787
+ const J = 15, sn = 24, O = p.string().length(sn).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
788
+ function Wn() {
765
789
  const n = new Uint8Array(J);
766
790
  return crypto.getRandomValues(n), O.parse(C(n, "RFC4648"));
767
791
  }
@@ -769,24 +793,24 @@ function an(n) {
769
793
  if (n.length !== J) throw new Error(`Wrong number of bytes: ${n.length}`);
770
794
  return O.parse(C(n, "RFC4648"));
771
795
  }
772
- async function Wn(n) {
773
- const t = new TextEncoder(), e = await crypto.subtle.digest("SHA-256", t.encode(n));
774
- return an(new Uint8Array(e.slice(0, 15)));
796
+ async function zn(n) {
797
+ const e = new TextEncoder(), t = await crypto.subtle.digest("SHA-256", e.encode(n));
798
+ return an(new Uint8Array(t.slice(0, 15)));
775
799
  }
776
- function zn(n) {
800
+ function Xn(n) {
777
801
  return JSON.stringify(n);
778
802
  }
779
- function Xn(n) {
803
+ function Gn(n) {
780
804
  return h(n);
781
805
  }
782
- function Gn(n) {
806
+ function Qn(n) {
783
807
  return JSON.parse(n);
784
808
  }
785
809
  export {
786
- $n as AnchoredIdDeriver,
810
+ In as AnchoredIdDeriver,
787
811
  Rn as DefaultNavigationState,
788
812
  H as PTableAbsent,
789
- W as PTableNA,
813
+ q as PTableNA,
790
814
  K as PValueBytesNA,
791
815
  Pn as PValueDoubleNA,
792
816
  wn as PValueFloatNA,
@@ -796,22 +820,23 @@ export {
796
820
  O as PlId,
797
821
  J as PlIdBytes,
798
822
  sn as PlIdLength,
799
- Mn as PlRef,
823
+ _n as PlRef,
800
824
  Jn as canonicalizeAxisId,
801
- Xn as canonicalizeJson,
825
+ Gn as canonicalizeJson,
826
+ Tn as createPlRef,
802
827
  hn as dataInfoToEntries,
803
- Wn as digestPlId,
828
+ zn as digestPlId,
804
829
  xn as ensureNotNAPValue,
805
830
  jn as ensurePColumn,
806
831
  gn as entriesToDataInfo,
807
832
  b as executePSpecPredicate,
808
833
  Un as extractAllColumns,
809
- z as getAxesId,
810
- p as getAxisId,
834
+ W as getAxesId,
835
+ m as getAxisId,
811
836
  Cn as getColumnIdAndSpec,
812
837
  pn as getFileNameFromHandle,
813
838
  V as getFilePathFromHandle,
814
- En as getPColumnSpecId,
839
+ Sn as getPColumnSpecId,
815
840
  mn as isDataInfo,
816
841
  j as isDataInfoEntries,
817
842
  Ln as isFilteredPColumn,
@@ -819,38 +844,39 @@ export {
819
844
  D as isImportFileHandleUpload,
820
845
  dn as isLiveLog,
821
846
  R as isNotNAPValue,
822
- q as isPColumn,
847
+ Z as isPColumn,
823
848
  Bn as isPColumnResult,
824
849
  f as isPColumnSpec,
825
850
  Vn as isPColumnSpecResult,
826
851
  Nn as isPTableAbsent,
827
- M as isPValue,
828
- ln as isPartitionedDataInfoEntries,
829
- Tn as isPlRef,
830
- _ as isValueAbsent,
852
+ _ as isPValue,
853
+ yn as isPartitionedDataInfoEntries,
854
+ Mn as isPlRef,
855
+ v as isValueAbsent,
831
856
  g as isValueNA,
832
- yn as mapDataInfo,
857
+ ln as mapDataInfo,
833
858
  bn as mapDataInfoEntries,
834
- l as mapJoinEntry,
859
+ y as mapJoinEntry,
835
860
  Fn as mapPObjectData,
836
861
  On as mapPTableDef,
837
- _n as mapValueInVOE,
862
+ qn as mapValueInVOE,
838
863
  k as matchAxis,
839
- G as matchAxisId,
864
+ X as matchAxisId,
840
865
  N as matchPColumn,
841
- Sn as pTableValue,
866
+ En as pTableValue,
842
867
  kn as pValueToStringOrNumber,
843
- v as pValueToStringOrNumberOrNull,
844
- In as parseColumnId,
845
- Gn as parseJson,
868
+ T as pValueToStringOrNumberOrNull,
869
+ $n as parseColumnId,
870
+ Qn as parseJson,
846
871
  an as plId,
847
- vn as plRefsEqual,
872
+ Hn as plRefsEqual,
848
873
  Dn as resolveAnchors,
849
- T as safeConvertToPValue,
874
+ M as safeConvertToPValue,
850
875
  Kn as selectorsToPredicate,
851
- Q as stringifyColumnId,
852
- zn as stringifyJson,
876
+ G as stringifyColumnId,
877
+ Xn as stringifyJson,
853
878
  An as toJsonSafePValue,
854
- Hn as uniquePlId
879
+ Wn as uniquePlId,
880
+ vn as withEnrichments
855
881
  };
856
882
  //# sourceMappingURL=index.mjs.map