@milaboratories/pl-model-common 1.7.0 → 1.8.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,198 +1,284 @@
1
- import { z as a } from "zod";
2
- function V(n) {
3
- return n !== void 0 && n.startsWith("log+live://log/");
4
- }
5
- function c(n) {
6
- throw new Error("Unexpected object: " + n);
7
- }
8
- const l = "upload://upload/", d = "index://index/";
9
- function p(n) {
10
- return n.startsWith(l);
11
- }
12
- function P(n) {
13
- return n.startsWith(d);
14
- }
15
- function k(n) {
16
- if (P(n)) {
17
- const t = n.slice(d.length);
18
- return JSON.parse(decodeURIComponent(t)).path;
19
- } else if (p(n)) {
20
- const t = n.slice(l.length);
21
- return JSON.parse(decodeURIComponent(t)).localPath;
1
+ import { z as i } from "zod";
2
+ function B(t) {
3
+ return t !== void 0 && t.startsWith("log+live://log/");
4
+ }
5
+ function c(t) {
6
+ throw new Error("Unexpected object: " + t);
7
+ }
8
+ const d = "upload://upload/", m = "index://index/";
9
+ function y(t) {
10
+ return t.startsWith(d);
11
+ }
12
+ function b(t) {
13
+ return t.startsWith(m);
14
+ }
15
+ function g(t) {
16
+ if (b(t)) {
17
+ const n = t.slice(m.length);
18
+ return JSON.parse(decodeURIComponent(n)).path;
19
+ } else if (y(t)) {
20
+ const n = t.slice(d.length);
21
+ return JSON.parse(decodeURIComponent(n)).localPath;
22
+ }
23
+ c(t);
24
+ }
25
+ function w(t) {
26
+ return t.replace(/^.*[\\/]/, "");
27
+ }
28
+ function D(t) {
29
+ return w(g(t));
30
+ }
31
+ const N = -2147483648, a = -9007199254740991n, P = NaN, h = NaN, x = null, E = null;
32
+ function f(t, n) {
33
+ switch (n) {
34
+ case "Int":
35
+ return t === N;
36
+ case "Long":
37
+ return t === Number(a) || t === a;
38
+ case "Float":
39
+ return t === P;
40
+ case "Double":
41
+ return t === h;
42
+ case "String":
43
+ return t === x;
44
+ case "Bytes":
45
+ return t === E;
46
+ default:
47
+ throw Error(`unsupported data type: ${n}`);
22
48
  }
23
- c(n);
24
49
  }
25
- function N(n) {
26
- return n.replace(/^.*[\\/]/, "");
50
+ function R(t) {
51
+ if (!V(t)) throw new Error(`Expected not-NA PValue, got ${t}`);
52
+ return t;
27
53
  }
28
- function F(n) {
29
- return N(k(n));
54
+ function V(t, n) {
55
+ if (!n)
56
+ return typeof t == "string" || typeof t == "number" && isFinite(t) || typeof t == "bigint";
57
+ if (f(t, n)) return !1;
58
+ switch (n) {
59
+ case "Int":
60
+ return typeof t == "number";
61
+ case "Long":
62
+ return typeof t == "number" || typeof t == "bigint";
63
+ case "Float":
64
+ return typeof t == "number";
65
+ case "Double":
66
+ return typeof t == "number";
67
+ case "String":
68
+ return typeof t == "string";
69
+ case "Bytes":
70
+ throw Error("Bytes not yet supported");
71
+ default:
72
+ throw Error(`unsupported data type: ${n}`);
73
+ }
30
74
  }
31
- const b = -2147483648, s = -9007199254740991n, h = NaN, v = NaN, y = null, I = null;
32
- function R(n, t) {
33
- switch (t) {
75
+ function I(t, n) {
76
+ if (!n)
77
+ return t === null || typeof t == "string" || typeof t == "number" || typeof t == "bigint";
78
+ if (f(t, n)) return !0;
79
+ switch (n) {
34
80
  case "Int":
35
- return n === b;
81
+ return typeof t == "number";
36
82
  case "Long":
37
- return n === Number(s) || n === s;
83
+ return typeof t == "number" || typeof t == "bigint";
38
84
  case "Float":
39
- return n === h;
85
+ return typeof t == "number";
40
86
  case "Double":
41
- return n === v;
87
+ return typeof t == "number";
42
88
  case "String":
43
- return n === y;
89
+ return typeof t == "string";
44
90
  case "Bytes":
45
- return n === I;
91
+ throw Error("Bytes not yet supported");
46
92
  default:
47
- throw Error(`unsupported data type: ${t}`);
93
+ throw Error(`unsupported data type: ${n}`);
94
+ }
95
+ }
96
+ function L(t) {
97
+ if (t === null || typeof t == "string" || typeof t == "number") return t;
98
+ if (typeof t == "bigint") return { bigint: t.toString() };
99
+ throw new Error(`Type ${typeof t} (value ${t}) not yet supported.`);
100
+ }
101
+ function $(t, n) {
102
+ if (t === null || typeof t == "string" || typeof t == "number" || typeof t == "bigint") {
103
+ if (n && !f(t, n) && !I(t, n))
104
+ throw new Error(`Unexpected value type, got ${typeof t}, expected ${n}`);
105
+ return t;
106
+ }
107
+ if (typeof t == "object" && t !== null && "bigint" in t && typeof t.bigint == "string") {
108
+ if (n && n !== "Long")
109
+ throw new Error(`Unexpected value type, got serialized bigint, expected ${n}`);
110
+ return BigInt(t.bigint);
111
+ }
112
+ throw new Error(`Unsupported type ${typeof t} (value ${t}).`);
113
+ }
114
+ function O(t) {
115
+ if (t = k(t), t === null) throw new Error("Value is null");
116
+ return t;
117
+ }
118
+ function k(t) {
119
+ if (t = $(t), t === null) return null;
120
+ if (typeof t == "string") return t;
121
+ if (typeof t == "number") {
122
+ if (!isFinite(t)) throw new Error(`Value is not finite (${t})`);
123
+ return t;
48
124
  }
125
+ if (typeof t == "bigint")
126
+ return Number(t);
127
+ throw new Error(`Unexpected value type: ${typeof t}`);
49
128
  }
50
- function E(n, t) {
51
- const e = Math.floor(t / 8), o = 1 << 7 - t % 8;
52
- return (n[e] & o) > 0;
129
+ function _(t, n) {
130
+ const r = Math.floor(n / 8), e = 1 << 7 - n % 8;
131
+ return (t[r] & e) > 0;
53
132
  }
54
- function g(n) {
55
- const { type: t, name: e, domain: o } = n;
56
- return { type: t, name: e, ...o && { domain: o } };
133
+ function A(t) {
134
+ const { type: n, name: r, domain: e } = t;
135
+ return { type: n, name: r, ...e && { domain: e } };
57
136
  }
58
- function U(n) {
59
- return n.map(g);
137
+ function j(t) {
138
+ return t.map(A);
60
139
  }
61
- function x(n, t) {
62
- if (n === void 0) return t === void 0;
63
- if (t === void 0) return !0;
64
- for (const e in t)
65
- if (n[e] !== t[e]) return !1;
140
+ function F(t, n) {
141
+ if (t === void 0) return n === void 0;
142
+ if (n === void 0) return !0;
143
+ for (const r in n)
144
+ if (t[r] !== n[r]) return !1;
66
145
  return !0;
67
146
  }
68
- function _(n, t) {
69
- return n.name === t.name && x(n.domain, t.domain);
147
+ function H(t, n) {
148
+ return t.name === n.name && F(t.domain, n.domain);
70
149
  }
71
- function D(n, t) {
72
- return { ...n, src: i(n.src, t) };
150
+ function J(t, n) {
151
+ return { ...t, src: s(t.src, n) };
73
152
  }
74
- function i(n, t) {
75
- switch (n.type) {
153
+ function s(t, n) {
154
+ switch (t.type) {
76
155
  case "column":
77
156
  return {
78
157
  type: "column",
79
- column: t(n.column)
158
+ column: n(t.column)
80
159
  };
81
160
  case "inner":
82
161
  case "full":
83
162
  return {
84
- type: n.type,
85
- entries: n.entries.map((e) => i(e, t))
163
+ type: t.type,
164
+ entries: t.entries.map((r) => s(r, n))
86
165
  };
87
166
  case "outer":
88
167
  return {
89
168
  type: "outer",
90
- primary: i(n.primary, t),
91
- secondary: n.secondary.map((e) => i(e, t))
169
+ primary: s(t.primary, n),
170
+ secondary: t.secondary.map((r) => s(r, n))
92
171
  };
93
172
  default:
94
- c(n);
173
+ c(t);
95
174
  }
96
175
  }
97
- const S = { href: "/" }, j = a.object({
98
- __isRef: a.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
99
- blockId: a.string().describe("Upstream block id"),
100
- name: a.string().describe("Name of the output provided to the upstream block's output context")
176
+ const W = { href: "/" }, z = i.object({
177
+ __isRef: i.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
178
+ blockId: i.string().describe("Upstream block id"),
179
+ name: i.string().describe("Name of the output provided to the upstream block's output context")
101
180
  }).describe(
102
181
  "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."
103
182
  ).strict().readonly();
104
- function B(n, t) {
105
- return n.blockId === t.blockId && n.name === t.name;
183
+ function M(t, n) {
184
+ return t.blockId === n.blockId && t.name === n.name;
106
185
  }
107
- function r(n) {
108
- return n.kind === "PColumn";
186
+ function o(t) {
187
+ return t.kind === "PColumn";
109
188
  }
110
- function w(n) {
111
- return r(n.spec);
189
+ function S(t) {
190
+ return o(t.spec);
112
191
  }
113
- function H(n) {
114
- return r(n.obj);
192
+ function q(t) {
193
+ return o(t.obj);
115
194
  }
116
- function L(n) {
117
- return r(n.obj.spec);
195
+ function G(t) {
196
+ return o(t.obj.spec);
118
197
  }
119
- function O(n) {
120
- if (!w(n)) throw new Error(`not a PColumn (kind = ${n.spec.kind})`);
121
- return n;
198
+ function K(t) {
199
+ if (!S(t)) throw new Error(`not a PColumn (kind = ${t.spec.kind})`);
200
+ return t;
122
201
  }
123
- function J(n, t) {
124
- return n === void 0 ? void 0 : {
125
- ...n,
126
- data: t(n.data)
202
+ function Q(t, n) {
203
+ return t === void 0 ? void 0 : {
204
+ ...t,
205
+ data: n(t.data)
127
206
  };
128
207
  }
129
- function A(n) {
130
- throw new Error("Unexpected object: " + n);
208
+ function C(t) {
209
+ throw new Error("Unexpected object: " + t);
131
210
  }
132
- function u(n, t) {
133
- switch (n.type) {
211
+ function u(t, n) {
212
+ switch (t.type) {
134
213
  case "and":
135
- for (const e of n.operands)
136
- if (!u(e, t)) return !1;
214
+ for (const r of t.operands)
215
+ if (!u(r, n)) return !1;
137
216
  return !0;
138
217
  case "or":
139
- for (const e of n.operands)
140
- if (u(e, t)) return !0;
218
+ for (const r of t.operands)
219
+ if (u(r, n)) return !0;
141
220
  return !1;
142
221
  case "not":
143
- return !u(n.operand, t);
222
+ return !u(t.operand, n);
144
223
  case "name":
145
- return r(t) && t.name === n.name;
224
+ return o(n) && n.name === t.name;
146
225
  case "name_pattern":
147
- return r(t) && !!t.name.match(n.pattern);
226
+ return o(n) && !!n.name.match(t.pattern);
148
227
  case "annotation":
149
- return r(t) && t.annotations !== void 0 && t.annotations[n.annotation] === n.value;
228
+ return o(n) && n.annotations !== void 0 && n.annotations[t.annotation] === t.value;
150
229
  case "annotation_pattern":
151
- return r(t) && t.annotations !== void 0 && t.annotations[n.annotation] !== void 0 && !!t.annotations[n.annotation].match(n.pattern);
230
+ return o(n) && n.annotations !== void 0 && n.annotations[t.annotation] !== void 0 && !!n.annotations[t.annotation].match(t.pattern);
152
231
  case "has_axes":
153
- return r(t) && n.axes.every(
154
- (e) => t.axesSpec.some(
155
- (o) => (e.type === void 0 || e.type === o.type) && (e.name === void 0 || e.name === o.name) && (e.domain === void 0 || Object.keys(e.domain).length === 0 || o.domain !== void 0 && Object.entries(e.domain).every(
156
- ([m, f]) => o.domain[m] === f
232
+ return o(n) && t.axes.every(
233
+ (r) => n.axesSpec.some(
234
+ (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(
235
+ ([p, l]) => e.domain[p] === l
157
236
  ))
158
237
  )
159
238
  );
160
239
  default:
161
- A(n);
240
+ C(t);
162
241
  }
163
242
  }
164
- function W(n, t) {
165
- return n.ok ? { ok: !0, value: t(n.value) } : n;
243
+ function X(t, n) {
244
+ return t.ok ? { ok: !0, value: n(t.value) } : t;
166
245
  }
167
246
  export {
168
- S as DefaultNavigationState,
169
- I as PValueBytesNA,
170
- v as PValueDoubleNA,
171
- h as PValueFloatNA,
172
- b as PValueIntNA,
173
- s as PValueLongNA,
174
- y as PValueStringNA,
175
- j as PlRef,
176
- O as ensurePColumn,
247
+ W as DefaultNavigationState,
248
+ E as PValueBytesNA,
249
+ h as PValueDoubleNA,
250
+ P as PValueFloatNA,
251
+ N as PValueIntNA,
252
+ a as PValueLongNA,
253
+ x as PValueStringNA,
254
+ z as PlRef,
255
+ R as ensureNotNAPValue,
256
+ K as ensurePColumn,
177
257
  u as executePSpecPredicate,
178
- U as getAxesId,
179
- g as getAxisId,
180
- F as getFileNameFromHandle,
181
- k as getFilePathFromHandle,
182
- P as isImportFileHandleIndex,
183
- p as isImportFileHandleUpload,
184
- V as isLiveLog,
185
- w as isPColumn,
186
- L as isPColumnResult,
187
- r as isPColumnSpec,
188
- H as isPColumnSpecResult,
189
- E as isValueAbsent,
190
- R as isValueNA,
191
- i as mapJoinEntry,
192
- J as mapPObjectData,
193
- D as mapPTableDef,
194
- W as mapValueInVOE,
195
- _ as matchAxisId,
196
- B as plRefsEqual
258
+ j as getAxesId,
259
+ A as getAxisId,
260
+ D as getFileNameFromHandle,
261
+ g as getFilePathFromHandle,
262
+ b as isImportFileHandleIndex,
263
+ y as isImportFileHandleUpload,
264
+ B as isLiveLog,
265
+ V as isNotNAPValue,
266
+ S as isPColumn,
267
+ G as isPColumnResult,
268
+ o as isPColumnSpec,
269
+ q as isPColumnSpecResult,
270
+ I as isPValue,
271
+ _ as isValueAbsent,
272
+ f as isValueNA,
273
+ s as mapJoinEntry,
274
+ Q as mapPObjectData,
275
+ J as mapPTableDef,
276
+ X as mapValueInVOE,
277
+ H as matchAxisId,
278
+ O as pValueToStringOrNumber,
279
+ k as pValueToStringOrNumberOrNull,
280
+ M as plRefsEqual,
281
+ $ as safeConvertToPValue,
282
+ L as toJsonSafePValue
197
283
  };
198
284
  //# sourceMappingURL=index.mjs.map