@milaboratories/pl-model-common 1.10.1 → 1.10.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
@@ -1,60 +1,60 @@
1
- import { z as s } from "zod";
2
- function R(t) {
1
+ import { z as a } from "zod";
2
+ function Z(t) {
3
3
  return t !== void 0 && t.startsWith("log+live://log/");
4
4
  }
5
- function f(t) {
5
+ function b(t) {
6
6
  throw new Error("Unexpected object: " + t);
7
7
  }
8
- const p = "upload://upload/", l = "index://index/";
9
- function b(t) {
10
- return t.startsWith(p);
8
+ const w = "upload://upload/", h = "index://index/";
9
+ function E(t) {
10
+ return t.startsWith(w);
11
11
  }
12
- function y(t) {
13
- return t.startsWith(l);
12
+ function I(t) {
13
+ return t.startsWith(h);
14
14
  }
15
- function g(t) {
16
- if (y(t)) {
17
- const n = t.slice(l.length);
15
+ function C(t) {
16
+ if (I(t)) {
17
+ const n = t.slice(h.length);
18
18
  return JSON.parse(decodeURIComponent(n)).path;
19
- } else if (b(t)) {
20
- const n = t.slice(p.length);
19
+ } else if (E(t)) {
20
+ const n = t.slice(w.length);
21
21
  return JSON.parse(decodeURIComponent(n)).localPath;
22
22
  }
23
- f(t);
23
+ b(t);
24
24
  }
25
- function w(t) {
25
+ function V(t) {
26
26
  return t.replace(/^.*[\\/]/, "");
27
27
  }
28
- function O(t) {
29
- return w(g(t));
28
+ function z(t) {
29
+ return V(C(t));
30
30
  }
31
- const N = -2147483648, d = -9007199254740991n, h = NaN, P = NaN, x = null, E = null;
32
- function a(t, n) {
31
+ const F = -2147483648, g = -9007199254740991n, x = NaN, R = NaN, U = null, k = null;
32
+ function d(t, n) {
33
33
  switch (n) {
34
34
  case "Int":
35
- return t === N;
35
+ return t === F;
36
36
  case "Long":
37
- return t === Number(d) || t === d;
37
+ return t === Number(g) || t === g;
38
38
  case "Float":
39
- return t === h;
39
+ return t === x;
40
40
  case "Double":
41
- return t === P;
41
+ return t === R;
42
42
  case "String":
43
- return t === x;
43
+ return t === U;
44
44
  case "Bytes":
45
- return t === E;
45
+ return t === k;
46
46
  default:
47
47
  throw Error(`unsupported data type: ${n}`);
48
48
  }
49
49
  }
50
- function _(t) {
51
- if (!V(t)) throw new Error(`Expected not-NA PValue, got ${t}`);
50
+ function q(t) {
51
+ if (!B(t)) throw new Error(`Expected not-NA PValue, got ${t}`);
52
52
  return t;
53
53
  }
54
- function V(t, n) {
54
+ function B(t, n) {
55
55
  if (!n)
56
56
  return typeof t == "string" || typeof t == "number" && isFinite(t) || typeof t == "bigint";
57
- if (a(t, n)) return !1;
57
+ if (d(t, n)) return !1;
58
58
  switch (n) {
59
59
  case "Int":
60
60
  return typeof t == "number";
@@ -72,10 +72,10 @@ function V(t, n) {
72
72
  throw Error(`unsupported data type: ${n}`);
73
73
  }
74
74
  }
75
- function I(t, n) {
75
+ function S(t, n) {
76
76
  if (!n)
77
77
  return t === null || typeof t == "string" || typeof t == "number" || typeof t == "bigint";
78
- if (a(t, n)) return !0;
78
+ if (d(t, n)) return !0;
79
79
  switch (n) {
80
80
  case "Int":
81
81
  return typeof t == "number";
@@ -93,14 +93,14 @@ function I(t, n) {
93
93
  throw Error(`unsupported data type: ${n}`);
94
94
  }
95
95
  }
96
- function j(t) {
96
+ function v(t) {
97
97
  if (t === null || typeof t == "string" || typeof t == "number") return t;
98
98
  if (typeof t == "bigint") return { bigint: t.toString() };
99
99
  throw new Error(`Type ${typeof t} (value ${t}) not yet supported.`);
100
100
  }
101
- function A(t, n) {
101
+ function D(t, n) {
102
102
  if (t === null || typeof t == "string" || typeof t == "number" || typeof t == "bigint") {
103
- if (n && !a(t, n) && !I(t, n))
103
+ if (n && !d(t, n) && !S(t, n))
104
104
  throw new Error(`Unexpected value type, got ${typeof t}, expected ${n}`);
105
105
  return t;
106
106
  }
@@ -111,12 +111,12 @@ function A(t, n) {
111
111
  }
112
112
  throw new Error(`Unsupported type ${typeof t} (value ${t}).`);
113
113
  }
114
- function H(t) {
114
+ function tt(t) {
115
115
  if (t = $(t), t === null) throw new Error("Value is null");
116
116
  return t;
117
117
  }
118
118
  function $(t) {
119
- if (t = A(t), t === null) return null;
119
+ if (t = D(t), t === null) return null;
120
120
  if (typeof t == "string") return t;
121
121
  if (typeof t == "number") {
122
122
  if (!isFinite(t)) throw new Error(`Value is not finite (${t})`);
@@ -126,16 +126,20 @@ function $(t) {
126
126
  return Number(t);
127
127
  throw new Error(`Unexpected value type: ${typeof t}`);
128
128
  }
129
- function k(t, n) {
130
- const r = Math.floor(n / 8), e = 1 << 7 - n % 8;
131
- return (t[r] & e) > 0;
129
+ function L(t, n) {
130
+ const e = Math.floor(n / 8), r = 1 << 7 - n % 8;
131
+ return (t[e] & r) > 0;
132
+ }
133
+ const O = { type: "absent" }, H = null;
134
+ function nt(t) {
135
+ return typeof t == "object" && t !== null && t.type === "absent";
132
136
  }
133
- const F = { type: "absent" }, C = null;
134
- function J(t, n) {
135
- if (k(t.absent, n)) return F;
136
- const r = t.data[n], e = t.type;
137
- if (a(r, e)) return C;
138
- switch (e) {
137
+ function et(t, n, e = {}) {
138
+ if (L(t.absent, n))
139
+ return e.absent === void 0 ? O : e.absent;
140
+ const r = t.data[n], o = t.type;
141
+ if (d(r, o)) return e.na === void 0 ? H : e.na;
142
+ switch (o) {
139
143
  case "Int":
140
144
  return r;
141
145
  case "Long":
@@ -149,30 +153,30 @@ function J(t, n) {
149
153
  case "Bytes":
150
154
  throw Error("Bytes not yet supported");
151
155
  default:
152
- throw Error(`unsupported data type: ${e}`);
156
+ throw Error(`unsupported data type: ${o}`);
153
157
  }
154
158
  }
155
- function S(t) {
156
- const { type: n, name: r, domain: e } = t;
157
- return { type: n, name: r, ...e && { domain: e } };
159
+ function J(t) {
160
+ const { type: n, name: e, domain: r } = t;
161
+ return { type: n, name: e, ...r && { domain: r } };
158
162
  }
159
- function W(t) {
160
- return t.map(S);
163
+ function rt(t) {
164
+ return t.map(J);
161
165
  }
162
- function B(t, n) {
166
+ function _(t, n) {
163
167
  if (t === void 0) return n === void 0;
164
168
  if (n === void 0) return !0;
165
- for (const r in n)
166
- if (t[r] !== n[r]) return !1;
169
+ for (const e in n)
170
+ if (t[e] !== n[e]) return !1;
167
171
  return !0;
168
172
  }
169
- function z(t, n) {
170
- return t.name === n.name && B(t.domain, n.domain);
173
+ function ot(t, n) {
174
+ return t.name === n.name && _(t.domain, n.domain);
171
175
  }
172
- function M(t, n) {
173
- return { ...t, src: u(t.src, n) };
176
+ function it(t, n) {
177
+ return { ...t, src: f(t.src, n) };
174
178
  }
175
- function u(t, n) {
179
+ function f(t, n) {
176
180
  switch (t.type) {
177
181
  case "column":
178
182
  return {
@@ -183,148 +187,204 @@ function u(t, n) {
183
187
  case "full":
184
188
  return {
185
189
  type: t.type,
186
- entries: t.entries.map((r) => u(r, n))
190
+ entries: t.entries.map((e) => f(e, n))
187
191
  };
188
192
  case "outer":
189
193
  return {
190
194
  type: "outer",
191
- primary: u(t.primary, n),
192
- secondary: t.secondary.map((r) => u(r, n))
195
+ primary: f(t.primary, n),
196
+ secondary: t.secondary.map((e) => f(e, n))
193
197
  };
194
198
  default:
195
- f(t);
199
+ b(t);
196
200
  }
197
201
  }
198
- const q = { href: "/" }, G = s.object({
199
- __isRef: s.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
200
- blockId: s.string().describe("Upstream block id"),
201
- name: s.string().describe("Name of the output provided to the upstream block's output context")
202
+ const st = { href: "/" }, ut = a.object({
203
+ __isRef: a.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
204
+ blockId: a.string().describe("Upstream block id"),
205
+ name: a.string().describe("Name of the output provided to the upstream block's output context")
202
206
  }).describe(
203
207
  "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."
204
208
  ).strict().readonly();
205
- function K(t, n) {
209
+ function at(t, n) {
206
210
  return t.blockId === n.blockId && t.name === n.name;
207
211
  }
208
- function o(t) {
212
+ function i(t) {
209
213
  return t.kind === "PColumn";
210
214
  }
211
- function U(t) {
212
- return o(t.spec);
215
+ function W(t) {
216
+ return i(t.spec);
213
217
  }
214
- function Q(t) {
215
- return o(t.obj);
218
+ function ct(t) {
219
+ return i(t.obj);
216
220
  }
217
- function X(t) {
218
- return o(t.obj.spec);
221
+ function ft(t) {
222
+ return i(t.obj.spec);
219
223
  }
220
- function Y(t) {
221
- if (!U(t)) throw new Error(`not a PColumn (kind = ${t.spec.kind})`);
224
+ function dt(t) {
225
+ if (!W(t)) throw new Error(`not a PColumn (kind = ${t.spec.kind})`);
222
226
  return t;
223
227
  }
224
- function Z(t, n) {
228
+ function lt(t, n) {
225
229
  return t === void 0 ? void 0 : {
226
230
  ...t,
227
231
  data: n(t.data)
228
232
  };
229
233
  }
230
- function T(t) {
231
- const n = /* @__PURE__ */ new Map(), r = (e) => {
232
- switch (e.type) {
234
+ function pt(t) {
235
+ const n = /* @__PURE__ */ new Map(), e = (r) => {
236
+ switch (r.type) {
233
237
  case "column":
234
- n.set(e.column.id, e.column);
238
+ n.set(r.column.id, r.column);
235
239
  return;
236
240
  case "full":
237
241
  case "inner":
238
- for (const i of e.entries) r(i);
242
+ for (const o of r.entries) e(o);
239
243
  return;
240
244
  case "outer":
241
- r(e.primary);
242
- for (const i of e.secondary) r(i);
245
+ e(r.primary);
246
+ for (const o of r.secondary) e(o);
243
247
  return;
244
248
  default:
245
- f(e);
249
+ b(r);
246
250
  }
247
251
  };
248
- return r(t), [...n.values()];
252
+ return e(t), [...n.values()];
249
253
  }
250
- function D(t) {
254
+ function j(t) {
251
255
  throw new Error("Unexpected object: " + t);
252
256
  }
253
- function c(t, n) {
257
+ function m(t, n) {
254
258
  switch (t.type) {
255
259
  case "and":
256
- for (const r of t.operands)
257
- if (!c(r, n)) return !1;
260
+ for (const e of t.operands)
261
+ if (!m(e, n)) return !1;
258
262
  return !0;
259
263
  case "or":
260
- for (const r of t.operands)
261
- if (c(r, n)) return !0;
264
+ for (const e of t.operands)
265
+ if (m(e, n)) return !0;
262
266
  return !1;
263
267
  case "not":
264
- return !c(t.operand, n);
268
+ return !m(t.operand, n);
265
269
  case "name":
266
- return o(n) && n.name === t.name;
270
+ return i(n) && n.name === t.name;
267
271
  case "name_pattern":
268
- return o(n) && !!n.name.match(t.pattern);
272
+ return i(n) && !!n.name.match(t.pattern);
269
273
  case "annotation":
270
- return o(n) && n.annotations !== void 0 && n.annotations[t.annotation] === t.value;
274
+ return i(n) && n.annotations !== void 0 && n.annotations[t.annotation] === t.value;
271
275
  case "annotation_pattern":
272
- return o(n) && n.annotations !== void 0 && n.annotations[t.annotation] !== void 0 && !!n.annotations[t.annotation].match(t.pattern);
276
+ return i(n) && n.annotations !== void 0 && n.annotations[t.annotation] !== void 0 && !!n.annotations[t.annotation].match(t.pattern);
273
277
  case "has_axes":
274
- return o(n) && t.axes.every(
275
- (r) => n.axesSpec.some(
276
- (e) => (r.type === void 0 || r.type === e.type) && (r.name === void 0 || r.name === e.name) && (r.domain === void 0 || Object.keys(r.domain).length === 0 || e.domain !== void 0 && Object.entries(r.domain).every(
277
- ([i, m]) => e.domain[i] === m
278
+ return i(n) && t.axes.every(
279
+ (e) => n.axesSpec.some(
280
+ (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(
281
+ ([o, l]) => r.domain[o] === l
278
282
  ))
279
283
  )
280
284
  );
281
285
  default:
282
- D(t);
286
+ j(t);
283
287
  }
284
288
  }
285
- function v(t, n) {
289
+ function mt(t, n) {
286
290
  return t.ok ? { ok: !0, value: n(t.value) } : t;
287
291
  }
292
+ function M(t) {
293
+ if (t instanceof Int8Array || t instanceof Uint8Array || t instanceof Uint8ClampedArray)
294
+ return new DataView(t.buffer, t.byteOffset, t.byteLength);
295
+ if (t instanceof ArrayBuffer) return new DataView(t);
296
+ throw new TypeError(
297
+ "Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray"
298
+ );
299
+ }
300
+ const K = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", X = "0123456789ABCDEFGHIJKLMNOPQRSTUV", G = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
301
+ function P(t, n, e) {
302
+ e = e || {};
303
+ let r, o;
304
+ switch (n) {
305
+ case "RFC3548":
306
+ case "RFC4648":
307
+ r = K, o = !0;
308
+ break;
309
+ case "RFC4648-HEX":
310
+ r = X, o = !0;
311
+ break;
312
+ case "Crockford":
313
+ r = G, o = !1;
314
+ break;
315
+ default:
316
+ throw new Error("Unknown base32 variant: " + n);
317
+ }
318
+ const l = e.padding !== void 0 ? e.padding : o, y = M(t);
319
+ let s = 0, c = 0, u = "";
320
+ for (let p = 0; p < y.byteLength; p++)
321
+ for (c = c << 8 | y.getUint8(p), s += 8; s >= 5; )
322
+ u += r[c >>> s - 5 & 31], s -= 5;
323
+ if (s > 0 && (u += r[c << 5 - s & 31]), l)
324
+ for (; u.length % 8 !== 0; )
325
+ u += "=";
326
+ return u;
327
+ }
328
+ const N = 15, Q = 24, A = a.string().length(Q).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
329
+ function bt() {
330
+ const t = new Uint8Array(N);
331
+ return crypto.getRandomValues(t), A.parse(P(t, "RFC4648"));
332
+ }
333
+ function T(t) {
334
+ if (t.length !== N) throw new Error(`Wrong number of bytes: ${t.length}`);
335
+ return A.parse(P(t, "RFC4648"));
336
+ }
337
+ async function yt(t) {
338
+ const n = new TextEncoder(), e = await crypto.subtle.digest("SHA-256", n.encode(t));
339
+ return T(new Uint8Array(e.slice(0, 15)));
340
+ }
288
341
  export {
289
- q as DefaultNavigationState,
290
- C as PTableNA,
291
- F as PTableNull,
292
- E as PValueBytesNA,
293
- P as PValueDoubleNA,
294
- h as PValueFloatNA,
295
- N as PValueIntNA,
296
- d as PValueLongNA,
297
- x as PValueStringNA,
298
- G as PlRef,
299
- _ as ensureNotNAPValue,
300
- Y as ensurePColumn,
301
- c as executePSpecPredicate,
302
- T as extractAllColumns,
303
- W as getAxesId,
304
- S as getAxisId,
305
- O as getFileNameFromHandle,
306
- g as getFilePathFromHandle,
307
- y as isImportFileHandleIndex,
308
- b as isImportFileHandleUpload,
309
- R as isLiveLog,
310
- V as isNotNAPValue,
311
- U as isPColumn,
312
- X as isPColumnResult,
313
- o as isPColumnSpec,
314
- Q as isPColumnSpecResult,
315
- I as isPValue,
316
- k as isValueAbsent,
317
- a as isValueNA,
318
- u as mapJoinEntry,
319
- Z as mapPObjectData,
320
- M as mapPTableDef,
321
- v as mapValueInVOE,
322
- z as matchAxisId,
323
- J as pTableValue,
324
- H as pValueToStringOrNumber,
342
+ st as DefaultNavigationState,
343
+ O as PTableAbsent,
344
+ H as PTableNA,
345
+ k as PValueBytesNA,
346
+ R as PValueDoubleNA,
347
+ x as PValueFloatNA,
348
+ F as PValueIntNA,
349
+ g as PValueLongNA,
350
+ U as PValueStringNA,
351
+ A as PlId,
352
+ N as PlIdBytes,
353
+ Q as PlIdLength,
354
+ ut as PlRef,
355
+ yt as digestPlId,
356
+ q as ensureNotNAPValue,
357
+ dt as ensurePColumn,
358
+ m as executePSpecPredicate,
359
+ pt as extractAllColumns,
360
+ rt as getAxesId,
361
+ J as getAxisId,
362
+ z as getFileNameFromHandle,
363
+ C as getFilePathFromHandle,
364
+ I as isImportFileHandleIndex,
365
+ E as isImportFileHandleUpload,
366
+ Z as isLiveLog,
367
+ B as isNotNAPValue,
368
+ W as isPColumn,
369
+ ft as isPColumnResult,
370
+ i as isPColumnSpec,
371
+ ct as isPColumnSpecResult,
372
+ nt as isPTableAbsent,
373
+ S as isPValue,
374
+ L as isValueAbsent,
375
+ d as isValueNA,
376
+ f as mapJoinEntry,
377
+ lt as mapPObjectData,
378
+ it as mapPTableDef,
379
+ mt as mapValueInVOE,
380
+ ot as matchAxisId,
381
+ et as pTableValue,
382
+ tt as pValueToStringOrNumber,
325
383
  $ as pValueToStringOrNumberOrNull,
326
- K as plRefsEqual,
327
- A as safeConvertToPValue,
328
- j as toJsonSafePValue
384
+ T as plId,
385
+ at as plRefsEqual,
386
+ D as safeConvertToPValue,
387
+ v as toJsonSafePValue,
388
+ bt as uniquePlId
329
389
  };
330
390
  //# sourceMappingURL=index.mjs.map