@platforma-sdk/model 1.8.0 → 1.9.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.
Files changed (55) hide show
  1. package/dist/bconfig/container.d.ts +46 -0
  2. package/dist/bconfig/container.d.ts.map +1 -0
  3. package/dist/bconfig/index.d.ts +7 -0
  4. package/dist/bconfig/index.d.ts.map +1 -0
  5. package/dist/bconfig/lambdas.d.ts +33 -0
  6. package/dist/bconfig/lambdas.d.ts.map +1 -0
  7. package/dist/bconfig/normalization.d.ts +13 -0
  8. package/dist/bconfig/normalization.d.ts.map +1 -0
  9. package/dist/bconfig/types.d.ts +11 -0
  10. package/dist/bconfig/types.d.ts.map +1 -0
  11. package/dist/bconfig/utils.d.ts +7 -0
  12. package/dist/bconfig/utils.d.ts.map +1 -0
  13. package/dist/bconfig/v3.d.ts +30 -0
  14. package/dist/bconfig/v3.d.ts.map +1 -0
  15. package/dist/builder.d.ts +45 -65
  16. package/dist/builder.d.ts.map +1 -1
  17. package/dist/components/PlDataTable.d.ts +3 -0
  18. package/dist/components/PlDataTable.d.ts.map +1 -1
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +428 -251
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/internal.d.ts +3 -2
  26. package/dist/internal.d.ts.map +1 -1
  27. package/dist/platforma.d.ts +3 -2
  28. package/dist/platforma.d.ts.map +1 -1
  29. package/dist/raw_globals.d.ts.map +1 -1
  30. package/dist/render/accessor.d.ts +23 -0
  31. package/dist/render/accessor.d.ts.map +1 -1
  32. package/dist/render/api.d.ts +2 -0
  33. package/dist/render/api.d.ts.map +1 -1
  34. package/dist/render/internal.d.ts +4 -0
  35. package/dist/render/internal.d.ts.map +1 -1
  36. package/dist/version.d.ts +1 -1
  37. package/package.json +3 -3
  38. package/src/bconfig/container.ts +58 -0
  39. package/src/bconfig/index.ts +6 -0
  40. package/src/bconfig/lambdas.ts +44 -0
  41. package/src/bconfig/normalization.ts +120 -0
  42. package/src/bconfig/types.ts +18 -0
  43. package/src/bconfig/utils.ts +8 -0
  44. package/src/bconfig/v3.ts +46 -0
  45. package/src/builder.ts +165 -141
  46. package/src/components/PlDataTable.ts +3 -0
  47. package/src/global.d.ts +1 -1
  48. package/src/index.ts +1 -0
  49. package/src/internal.ts +1 -2
  50. package/src/platforma.ts +1 -2
  51. package/src/raw_globals.ts +2 -1
  52. package/src/render/accessor.ts +73 -0
  53. package/src/render/api.ts +22 -10
  54. package/src/render/internal.ts +12 -0
  55. package/src/typing.test.ts +5 -4
package/dist/index.mjs CHANGED
@@ -1,64 +1,64 @@
1
1
  var E = Object.defineProperty;
2
- var j = (e, t, n) => t in e ? E(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var c = (e, t, n) => j(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { isPColumn as v, mapPObjectData as A, mapValueInVOE as L, isPColumnSpec as k, mapPTableDef as H, getAxisId as P, matchAxisId as J } from "@milaboratories/pl-model-common";
2
+ var B = (e, t, n) => t in e ? E(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var g = (e, t, n) => B(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { isPColumn as I, mapPObjectData as C, mapValueInVOE as U, isPColumnSpec as M, mapPTableDef as $, getAxisId as D, matchAxisId as J } from "@milaboratories/pl-model-common";
5
5
  export * from "@milaboratories/pl-model-common";
6
6
  class G extends Error {
7
7
  constructor(t, n) {
8
8
  super(`${t.length}${n ? "+" : ""} errors, first error: ` + t[0]), this.errors = t, this.moreErrors = n;
9
9
  }
10
10
  }
11
- function N(e) {
11
+ function H(e) {
12
12
  if (!e.ok) throw new G(e.errors, e.moreErrors);
13
13
  return e.value;
14
14
  }
15
- function X(e) {
15
+ function tt(e) {
16
16
  return new Proxy(e, {
17
17
  get(t, n) {
18
- return N(t[n]);
18
+ return H(t[n]);
19
19
  }
20
20
  });
21
21
  }
22
- function o(e) {
23
- return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null ? f(e) : e;
22
+ function l(e) {
23
+ return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null ? A(e) : e;
24
24
  }
25
- function h(e) {
25
+ function _(e) {
26
26
  return { type: "GetFromCtx", variable: e };
27
27
  }
28
- function Y(e) {
28
+ function et(e) {
29
29
  return {
30
30
  type: "Isolate",
31
31
  cfg: e
32
32
  };
33
33
  }
34
- const Z = h("$args"), tt = h("$it"), et = h("$prod"), nt = h("$staging"), rt = h("$ui");
35
- function f(e) {
34
+ const nt = _("$args"), it = _("$it"), rt = _("$prod"), st = _("$staging"), ot = _("$ui");
35
+ function A(e) {
36
36
  return { type: "Immediate", value: e };
37
37
  }
38
- function S(e) {
38
+ function R(e) {
39
39
  const t = {};
40
- for (const [n, r] of Object.entries(e)) t[n] = o(r);
40
+ for (const [n, i] of Object.entries(e)) t[n] = l(i);
41
41
  return {
42
42
  type: "MakeObject",
43
43
  template: t
44
44
  };
45
45
  }
46
- function st(...e) {
46
+ function at(...e) {
47
47
  const t = [];
48
- for (const n of e) t.push(o(n));
48
+ for (const n of e) t.push(l(n));
49
49
  return {
50
50
  type: "MakeArray",
51
51
  template: t
52
52
  };
53
53
  }
54
- function m(e, t) {
54
+ function S(e, t) {
55
55
  return {
56
56
  type: "GetJsonField",
57
- source: o(e),
58
- field: o(t)
57
+ source: l(e),
58
+ field: l(t)
59
59
  };
60
60
  }
61
- function it(e, t, n = "$it") {
61
+ function ut(e, t, n = "$it") {
62
62
  return {
63
63
  type: "MapRecordValues",
64
64
  source: e,
@@ -66,7 +66,7 @@ function it(e, t, n = "$it") {
66
66
  itVar: n
67
67
  };
68
68
  }
69
- function ot(e, t, n = "$it") {
69
+ function lt(e, t, n = "$it") {
70
70
  return {
71
71
  type: "MapArrayValues",
72
72
  source: e,
@@ -74,25 +74,25 @@ function ot(e, t, n = "$it") {
74
74
  itVar: n
75
75
  };
76
76
  }
77
- function at(e) {
77
+ function ct(e) {
78
78
  return {
79
79
  type: "Flatten",
80
80
  source: e
81
81
  };
82
82
  }
83
- function ut(e) {
83
+ function dt(e) {
84
84
  return {
85
85
  type: "IsEmpty",
86
86
  arg: e
87
87
  };
88
88
  }
89
- function lt(e) {
89
+ function ht(e) {
90
90
  return {
91
91
  type: "Not",
92
92
  operand: e
93
93
  };
94
94
  }
95
- function ct(e, t) {
95
+ function pt(e, t) {
96
96
  return {
97
97
  type: "And",
98
98
  operand1: e,
@@ -106,22 +106,22 @@ function gt(e, t) {
106
106
  operand2: t
107
107
  };
108
108
  }
109
- function dt(e, t) {
109
+ function ft(e, t) {
110
110
  return {
111
111
  type: "GetResourceField",
112
- source: o(e),
113
- field: o(t)
112
+ source: l(e),
113
+ field: l(t)
114
114
  };
115
115
  }
116
- function pt() {
116
+ function mt() {
117
117
  return function(e) {
118
118
  return {
119
119
  type: "GetResourceValueAsJson",
120
- source: o(e)
120
+ source: l(e)
121
121
  };
122
122
  };
123
123
  }
124
- function ht(e, t, n = "$it") {
124
+ function bt(e, t, n = "$it") {
125
125
  return {
126
126
  type: "MapResourceFields",
127
127
  source: e,
@@ -129,118 +129,118 @@ function ht(e, t, n = "$it") {
129
129
  itVar: n
130
130
  };
131
131
  }
132
- function ft(e) {
132
+ function yt(e) {
133
133
  return {
134
134
  type: "GetBlobContent",
135
- source: o(e)
135
+ source: l(e)
136
136
  };
137
137
  }
138
- function mt(e) {
138
+ function _t(e) {
139
139
  return {
140
140
  type: "GetBlobContentAsString",
141
- source: o(e)
141
+ source: l(e)
142
142
  };
143
143
  }
144
- function yt() {
144
+ function vt() {
145
145
  return function(e) {
146
146
  return {
147
147
  type: "GetBlobContentAsJson",
148
- source: o(e)
148
+ source: l(e)
149
149
  };
150
150
  };
151
151
  }
152
- function bt(e) {
152
+ function wt(e) {
153
153
  return {
154
154
  type: "GetDownloadedBlobContent",
155
- source: o(e)
155
+ source: l(e)
156
156
  };
157
157
  }
158
- function wt(e) {
158
+ function At(e) {
159
159
  return {
160
160
  type: "GetOnDemandBlobContent",
161
- source: o(e)
161
+ source: l(e)
162
162
  };
163
163
  }
164
- function At(e) {
164
+ function Ct(e) {
165
165
  return {
166
166
  type: "GetImportProgress",
167
- source: o(e)
167
+ source: l(e)
168
168
  };
169
169
  }
170
- function Ct(e, t) {
170
+ function St(e, t) {
171
171
  return {
172
172
  type: "GetLastLogs",
173
- source: o(e),
173
+ source: l(e),
174
174
  lines: t
175
175
  };
176
176
  }
177
- function _t(e, t) {
177
+ function Ft(e, t) {
178
178
  return {
179
179
  type: "GetProgressLog",
180
- source: o(e),
180
+ source: l(e),
181
181
  patternToSearch: t
182
182
  };
183
183
  }
184
- function Pt(e) {
184
+ function Vt(e) {
185
185
  return {
186
186
  type: "GetLogHandle",
187
- source: o(e)
187
+ source: l(e)
188
188
  };
189
189
  }
190
- function $() {
190
+ function N() {
191
191
  return typeof globalThis.getPlatforma < "u" || typeof globalThis.platforma < "u";
192
192
  }
193
- function x(e) {
193
+ function k(e) {
194
194
  if (e && typeof globalThis.getPlatforma == "function")
195
195
  return globalThis.getPlatforma(e);
196
196
  if (typeof globalThis.platforma < "u") return globalThis.platforma;
197
197
  throw new Error("Can't get platforma instance.");
198
198
  }
199
- function M() {
199
+ function K() {
200
200
  if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
201
201
  }
202
202
  function s() {
203
203
  if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
204
204
  throw new Error("Not in config rendering context");
205
205
  }
206
- function y(e, t) {
207
- const n = M();
206
+ function v(e, t) {
207
+ const n = K();
208
208
  if (n === void 0) return !1;
209
209
  if (e in n.callbackRegistry) throw new Error(`Callback with key ${e} already registered.`);
210
210
  return n.callbackRegistry[e] = t, !0;
211
211
  }
212
- const b = /* @__PURE__ */ new Map();
213
- function K(e, t) {
212
+ const F = /* @__PURE__ */ new Map();
213
+ function W(e, t) {
214
214
  e in s().callbackRegistry || (s().callbackRegistry[e] = (n) => {
215
- for (const r of b.get(e))
216
- r(n);
217
- }, b.set(e, [])), b.get(e).push(t);
218
- }
219
- class l {
220
- constructor(t, n = (r) => r) {
221
- c(this, "isResolved", !1);
222
- c(this, "resolvedValue");
223
- this.handle = t, this.postProcess = n, K(t, (r) => {
224
- this.resolvedValue = n(r), this.isResolved = !0;
215
+ for (const i of F.get(e))
216
+ i(n);
217
+ }, F.set(e, [])), F.get(e).push(t);
218
+ }
219
+ class h {
220
+ constructor(t, n = (i) => i) {
221
+ g(this, "isResolved", !1);
222
+ g(this, "resolvedValue");
223
+ this.handle = t, this.postProcess = n, W(t, (i) => {
224
+ this.resolvedValue = n(i), this.isResolved = !0;
225
225
  });
226
226
  }
227
227
  map(t) {
228
- return new l(this.handle, (n) => t(this.postProcess(n)));
228
+ return new h(this.handle, (n) => t(this.postProcess(n)));
229
229
  }
230
230
  mapDefined(t) {
231
- return new l(this.handle, (n) => {
232
- const r = this.postProcess(n);
233
- return r ? t(r) : void 0;
231
+ return new h(this.handle, (n) => {
232
+ const i = this.postProcess(n);
233
+ return i ? t(i) : void 0;
234
234
  });
235
235
  }
236
236
  toJSON() {
237
237
  return this.isResolved ? this.resolvedValue : { __awaited_futures__: [this.handle] };
238
238
  }
239
239
  }
240
- function F(e) {
241
- return e === void 0 ? void 0 : new p(e);
240
+ function O(e) {
241
+ return e === void 0 ? void 0 : new m(e);
242
242
  }
243
- class p {
243
+ class m {
244
244
  constructor(t) {
245
245
  this.handle = t;
246
246
  }
@@ -248,7 +248,7 @@ class p {
248
248
  return this.resolveWithCommon({}, ...t);
249
249
  }
250
250
  resolveWithCommon(t, ...n) {
251
- return F(s().resolveWithCommon(this.handle, t, ...n));
251
+ return O(s().resolveWithCommon(this.handle, t, ...n));
252
252
  }
253
253
  get resourceType() {
254
254
  return s().getResourceType(this.handle);
@@ -266,7 +266,7 @@ class p {
266
266
  return s().getIsFinal(this.handle);
267
267
  }
268
268
  getError() {
269
- return F(s().getError(this.handle));
269
+ return O(s().getError(this.handle));
270
270
  }
271
271
  listInputFields() {
272
272
  return s().listInputFields(this.handle);
@@ -303,35 +303,35 @@ class p {
303
303
  *
304
304
  */
305
305
  getPColumns(t = !1, n = "") {
306
- const r = this.parsePObjectCollection(t, n);
307
- return r === void 0 ? void 0 : Object.entries(r).map(([, a]) => {
308
- if (!v(a)) throw new Error(`not a PColumn (kind = ${a.spec.kind})`);
309
- return a;
306
+ const i = this.parsePObjectCollection(t, n);
307
+ return i === void 0 ? void 0 : Object.entries(i).map(([, o]) => {
308
+ if (!I(o)) throw new Error(`not a PColumn (kind = ${o.spec.kind})`);
309
+ return o;
310
310
  });
311
311
  }
312
312
  /**
313
313
  *
314
314
  */
315
315
  parsePObjectCollection(t = !1, n = "") {
316
- const r = s().parsePObjectCollection(
316
+ const i = s().parsePObjectCollection(
317
317
  this.handle,
318
318
  t,
319
319
  n
320
320
  );
321
- if (r === void 0) return;
322
- const i = {};
323
- for (const [a, d] of Object.entries(r))
324
- i[a] = A(d, (u) => new p(u));
325
- return i;
321
+ if (i === void 0) return;
322
+ const r = {};
323
+ for (const [o, u] of Object.entries(i))
324
+ r[o] = C(u, (a) => new m(a));
325
+ return r;
326
326
  }
327
327
  getFileContentAsBase64() {
328
- return new l(s().getBlobContentAsBase64(this.handle));
328
+ return new h(s().getBlobContentAsBase64(this.handle));
329
329
  }
330
330
  getFileContentAsString() {
331
- return new l(s().getBlobContentAsString(this.handle));
331
+ return new h(s().getBlobContentAsString(this.handle));
332
332
  }
333
333
  getFileContentAsJson() {
334
- return new l(
334
+ return new h(
335
335
  s().getBlobContentAsString(this.handle)
336
336
  ).mapDefined((t) => JSON.parse(t));
337
337
  }
@@ -351,7 +351,7 @@ class p {
351
351
  * @returns downloaded file handle
352
352
  */
353
353
  getFileHandle() {
354
- return new l(s().getDownloadedBlobContentHandle(this.handle));
354
+ return new h(s().getDownloadedBlobContentHandle(this.handle));
355
355
  }
356
356
  /**
357
357
  * @deprecated use getFileHandle
@@ -363,7 +363,7 @@ class p {
363
363
  * @returns downloaded file handle
364
364
  */
365
365
  getRemoteFileHandle() {
366
- return new l(s().getOnDemandBlobContentHandle(this.handle));
366
+ return new h(s().getOnDemandBlobContentHandle(this.handle));
367
367
  }
368
368
  /**
369
369
  * @deprecated use getRemoteFileHandle
@@ -372,49 +372,75 @@ class p {
372
372
  return this.getRemoteFileHandle();
373
373
  }
374
374
  getImportProgress() {
375
- return new l(s().getImportProgress(this.handle));
375
+ return new h(s().getImportProgress(this.handle));
376
376
  }
377
377
  getLastLogs(t) {
378
- return new l(s().getLastLogs(this.handle, t));
378
+ return new h(s().getLastLogs(this.handle, t));
379
379
  }
380
380
  getProgressLog(t) {
381
- return new l(s().getProgressLog(this.handle, t));
381
+ return new h(s().getProgressLog(this.handle, t));
382
382
  }
383
383
  getLogHandle() {
384
- return new l(s().getLogHandle(this.handle));
384
+ return new h(s().getLogHandle(this.handle));
385
+ }
386
+ allFieldsResolved(t = "Input") {
387
+ switch (t) {
388
+ case "Input":
389
+ return this.getInputsLocked() && this.listInputFields().every(
390
+ (n) => this.resolve({ field: n, assertFieldType: "Input" }) !== void 0
391
+ );
392
+ case "Output":
393
+ return this.getOutputsLocked() && this.listOutputFields().every(
394
+ (n) => this.resolve({ field: n, assertFieldType: "Output" }) !== void 0
395
+ );
396
+ }
397
+ }
398
+ mapFields(t, n) {
399
+ const { fieldType: i, requireLocked: r, skipUnresolved: o } = {
400
+ fieldType: "Input",
401
+ requireLocked: !0,
402
+ skipUnresolved: !1,
403
+ ...n
404
+ }, u = t;
405
+ if (r && (i === "Input" && !this.getInputsLocked() || i === "Output" && !this.getOutputsLocked()))
406
+ return;
407
+ let p = (i === "Input" ? this.listInputFields() : i === "Output" ? this.listOutputFields() : this.listDynamicFields()).map(
408
+ (c) => [c, this.resolve({ field: c, assertFieldType: i })]
409
+ );
410
+ return o && (p = p.filter((c) => c[1] !== void 0)), p.map(([c, f]) => u(c, f));
385
411
  }
386
412
  }
387
- const R = "staging", V = "main";
388
- function I(e) {
413
+ const L = "staging", j = "main";
414
+ function T(e) {
389
415
  return typeof e == "object" && e !== null && "__awaited_futures__" in e;
390
416
  }
391
- function C(e, t, n) {
417
+ function P(e, t, n) {
392
418
  if (t.has(n)) return;
393
419
  if (t.add(n), typeof n === "object")
394
- if (I(n)) n.__awaited_futures__.forEach((i) => e.add(i));
420
+ if (T(n)) n.__awaited_futures__.forEach((r) => e.add(r));
395
421
  else if (Array.isArray(n))
396
- for (const i of n) C(e, t, i);
422
+ for (const r of n) P(e, t, r);
397
423
  else
398
- for (const [, i] of Object.entries(n))
399
- i !== n && C(e, t, i);
424
+ for (const [, r] of Object.entries(n))
425
+ r !== n && P(e, t, r);
400
426
  }
401
- function W(e) {
427
+ function q(e) {
402
428
  const t = /* @__PURE__ */ new Set();
403
- return C(t, /* @__PURE__ */ new Set(), e), t;
429
+ return P(t, /* @__PURE__ */ new Set(), e), t;
404
430
  }
405
- const Ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
431
+ const Pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
406
432
  __proto__: null,
407
- MainAccessorName: V,
408
- StagingAccessorName: R,
409
- getAllFutureAwaits: W,
410
- isFutureAwait: I
433
+ MainAccessorName: j,
434
+ StagingAccessorName: L,
435
+ getAllFutureAwaits: q,
436
+ isFutureAwait: T
411
437
  }, Symbol.toStringTag, { value: "Module" }));
412
- class U {
438
+ class z {
413
439
  constructor() {
414
- c(this, "ctx", s());
415
- c(this, "defaultLabelFn", (t, n) => {
416
- var r;
417
- return ((r = t.annotations) == null ? void 0 : r["pl7.app/label"]) ?? "Unlabelled";
440
+ g(this, "ctx", s());
441
+ g(this, "defaultLabelFn", (t, n) => {
442
+ var i;
443
+ return ((i = t.annotations) == null ? void 0 : i["pl7.app/label"]) ?? "Unlabelled";
418
444
  });
419
445
  }
420
446
  /**
@@ -424,9 +450,9 @@ class U {
424
450
  return this.ctx.calculateOptions(t);
425
451
  }
426
452
  getOptions(t, n = this.defaultLabelFn) {
427
- return this.getSpecs().entries.filter((r) => t(r.obj)).map((r) => ({
428
- ref: r.ref,
429
- label: n(r.obj, r.ref)
453
+ return this.getSpecs().entries.filter((i) => t(i.obj)).map((i) => ({
454
+ ref: i.ref,
455
+ label: n(i.obj, i.ref)
430
456
  }));
431
457
  }
432
458
  /**
@@ -443,7 +469,7 @@ class U {
443
469
  ref: n.ref,
444
470
  obj: {
445
471
  ...n.obj,
446
- data: new p(n.obj.data)
472
+ data: new m(n.obj.data)
447
473
  }
448
474
  }))
449
475
  };
@@ -462,7 +488,7 @@ class U {
462
488
  ref: n.ref,
463
489
  obj: {
464
490
  ...n.obj,
465
- data: L(n.obj.data, (r) => new p(r))
491
+ data: U(n.obj.data, (i) => new m(i))
466
492
  }
467
493
  }))
468
494
  };
@@ -482,9 +508,12 @@ class U {
482
508
  */
483
509
  getDataByRef(t) {
484
510
  var n;
485
- return (n = this.getData().entries.find(
486
- (r) => r.ref.blockId === t.blockId && r.ref.name === t.name
487
- )) == null ? void 0 : n.obj;
511
+ return typeof this.ctx.getDataFromResultPoolByRef > "u" ? (n = this.getData().entries.find(
512
+ (i) => i.ref.blockId === t.blockId && i.ref.name === t.name
513
+ )) == null ? void 0 : n.obj : C(
514
+ this.ctx.getDataFromResultPoolByRef(t.blockId, t.name),
515
+ (i) => new m(i)
516
+ );
488
517
  }
489
518
  /**
490
519
  * @param ref a Ref
@@ -492,9 +521,9 @@ class U {
492
521
  */
493
522
  getSpecByRef(t) {
494
523
  var n;
495
- return (n = this.getSpecs().entries.find(
496
- (r) => r.ref.blockId === t.blockId && r.ref.name === t.name
497
- )) == null ? void 0 : n.obj;
524
+ return typeof this.ctx.getSpecFromResultPoolByRef > "u" ? (n = this.getSpecs().entries.find(
525
+ (i) => i.ref.blockId === t.blockId && i.ref.name === t.name
526
+ )) == null ? void 0 : n.obj : this.ctx.getSpecFromResultPoolByRef(t.blockId, t.name);
498
527
  }
499
528
  /**
500
529
  * @param spec object specification
@@ -502,23 +531,23 @@ class U {
502
531
  */
503
532
  findDataWithCompatibleSpec(t) {
504
533
  const n = [];
505
- t: for (const r of this.getData().entries) {
506
- if (!k(r.obj.spec))
534
+ t: for (const i of this.getData().entries) {
535
+ if (!M(i.obj.spec))
507
536
  continue;
508
- const i = r.obj.spec;
509
- if (t.name === i.name && t.valueType === i.valueType && t.axesSpec.length === i.axesSpec.length && D(t.domain, i.domain)) {
510
- for (let a = 0; a < t.axesSpec.length; ++a) {
511
- const d = t.axesSpec[a], u = i.axesSpec[a];
512
- if (d.name !== u.name || d.type !== u.type || !D(d.domain, u.domain))
537
+ const r = i.obj.spec;
538
+ if (t.name === r.name && t.valueType === r.valueType && t.axesSpec.length === r.axesSpec.length && x(t.domain, r.domain)) {
539
+ for (let o = 0; o < t.axesSpec.length; ++o) {
540
+ const u = t.axesSpec[o], a = r.axesSpec[o];
541
+ if (u.name !== a.name || u.type !== a.type || !x(u.domain, a.domain))
513
542
  continue t;
514
543
  }
515
- n.push(r.obj);
544
+ n.push(i.obj);
516
545
  }
517
546
  }
518
547
  return n;
519
548
  }
520
549
  }
521
- function D(e, t) {
550
+ function x(e, t) {
522
551
  if (e === void 0) return t === void 0;
523
552
  if (t === void 0) return !0;
524
553
  for (const n in t)
@@ -527,18 +556,18 @@ function D(e, t) {
527
556
  }
528
557
  class w {
529
558
  constructor() {
530
- c(this, "ctx");
531
- c(this, "args");
532
- c(this, "uiState");
533
- c(this, "resultPool", new U());
559
+ g(this, "ctx");
560
+ g(this, "args");
561
+ g(this, "uiState");
562
+ g(this, "resultPool", new z());
534
563
  this.ctx = s(), this.args = JSON.parse(this.ctx.args), this.uiState = this.ctx.uiState !== void 0 ? JSON.parse(this.ctx.uiState) : void 0;
535
564
  }
536
565
  getNamedAccessor(t) {
537
566
  const n = this.ctx.getAccessorHandleByName(t);
538
- return n ? new p(n) : void 0;
567
+ return n ? new m(n) : void 0;
539
568
  }
540
569
  get prerun() {
541
- return this.getNamedAccessor(R);
570
+ return this.getNamedAccessor(L);
542
571
  }
543
572
  /**
544
573
  * @deprecated use prerun
@@ -553,7 +582,7 @@ class w {
553
582
  return this.precalc;
554
583
  }
555
584
  get outputs() {
556
- return this.getNamedAccessor(V);
585
+ return this.getNamedAccessor(j);
557
586
  }
558
587
  /**
559
588
  * @deprecated use outputs
@@ -562,120 +591,254 @@ class w {
562
591
  return this.outputs;
563
592
  }
564
593
  createPFrame(t) {
565
- return this.ctx.createPFrame(t.map((n) => A(n, (r) => r.handle)));
594
+ return this.ctx.createPFrame(t.map((n) => C(n, (i) => i.handle)));
566
595
  }
567
596
  createPTable(t) {
568
597
  var n;
569
598
  return "columns" in t ? n = {
570
599
  src: {
571
600
  type: "inner",
572
- entries: t.columns.map((r) => ({ type: "column", column: r }))
601
+ entries: t.columns.map((i) => ({ type: "column", column: i }))
573
602
  },
574
603
  filters: t.filters ?? [],
575
604
  sorting: t.sorting ?? []
576
- } : n = t, this.ctx.createPTable(H(n, (r) => A(r, (i) => i.handle)));
605
+ } : n = t, this.ctx.createPTable($(n, (i) => C(i, (r) => r.handle)));
577
606
  }
607
+ /** @deprecated scheduled for removal from SDK */
578
608
  getBlockLabel(t) {
579
609
  return this.ctx.getBlockLabel(t);
580
610
  }
611
+ getCurrentUnstableMarker() {
612
+ if (!(typeof this.ctx.getCurrentUnstableMarker > "u"))
613
+ return this.ctx.getCurrentUnstableMarker();
614
+ }
581
615
  }
582
- const O = "1.8.0";
583
- function Dt(e) {
584
- return typeof e == "string";
616
+ const y = "1.9.0";
617
+ function Q(e) {
618
+ return e.__renderLambda === !0;
619
+ }
620
+ function V(e) {
621
+ if (e !== void 0)
622
+ return Q(e) ? e.handle : e;
623
+ }
624
+ function b(e) {
625
+ if (e !== void 0)
626
+ return typeof e == "string" ? { __renderLambda: !0, handle: e, retentive: !1 } : e;
585
627
  }
586
- function vt(e) {
587
- if (e.inputsValid !== void 0) return e;
588
- {
589
- if (e.canRun === void 0)
590
- throw new Error(`Malformed config, SDK version ${e.sdkVersion}`);
591
- const t = { ...e, inputsValid: e.canRun };
592
- return delete t.canRun, t;
628
+ function Dt(e) {
629
+ if (e.v3 !== void 0) {
630
+ const {
631
+ initialArgs: t,
632
+ initialUiState: n,
633
+ inputsValid: i,
634
+ outputs: r,
635
+ renderingMode: o,
636
+ sdkVersion: u,
637
+ sections: a,
638
+ title: p
639
+ } = e.v3, { code: c } = e;
640
+ return {
641
+ initialArgs: t,
642
+ initialUiState: n,
643
+ inputsValid: i,
644
+ outputs: r,
645
+ renderingMode: o,
646
+ sdkVersion: u,
647
+ sections: a,
648
+ title: p,
649
+ code: c
650
+ };
651
+ } else if (e.inputsValid !== void 0) {
652
+ const { sdkVersion: t, renderingMode: n, outputs: i, inputsValid: r, sections: o, initialArgs: u, code: a } = e, p = Object.keys(e);
653
+ if (t === void 0 || n === void 0 || i === void 0 || r === void 0 || o === void 0 || u === void 0)
654
+ throw new Error(
655
+ `Malformed config v2. SDK version ${t}; Fields = ${p.join(", ")}`
656
+ );
657
+ return {
658
+ sdkVersion: t,
659
+ renderingMode: n,
660
+ initialArgs: u,
661
+ outputs: Object.fromEntries(
662
+ Object.entries(i).map(([c, f]) => [c, b(f)])
663
+ ),
664
+ inputsValid: b(r),
665
+ sections: b(o),
666
+ initialUiState: void 0,
667
+ code: a
668
+ };
669
+ } else if (e.renderingMode !== void 0) {
670
+ const { sdkVersion: t, canRun: n, renderingMode: i, outputs: r, sections: o, initialArgs: u, code: a } = e, p = Object.keys(e);
671
+ if (i === void 0 || r === void 0 || n === void 0 || o === void 0 || u === void 0)
672
+ throw new Error(
673
+ `Malformed config v1. SDK version ${t}; Fields = ${p.join(", ")}`
674
+ );
675
+ return {
676
+ sdkVersion: t ?? "unknown",
677
+ renderingMode: i,
678
+ initialArgs: u,
679
+ outputs: Object.fromEntries(
680
+ Object.entries(r).map(([c, f]) => [c, b(f)])
681
+ ),
682
+ inputsValid: b(n),
683
+ sections: b(o),
684
+ initialUiState: void 0,
685
+ code: a
686
+ };
687
+ } else {
688
+ const { sdkVersion: t } = e, n = Object.keys(e);
689
+ throw new Error(
690
+ `Config format not supported: SDK = ${t}; Fields = ${n.join(", ")}`
691
+ );
593
692
  }
594
693
  }
595
- class g {
596
- constructor(t, n, r, i, a) {
597
- this._renderingMode = t, this._initialArgs = n, this._outputs = r, this._inputsValid = i, this._sections = a;
694
+ class d {
695
+ constructor(t, n, i, r, o, u, a) {
696
+ this._renderingMode = t, this._initialArgs = n, this._initialUiState = i, this._outputs = r, this._inputsValid = o, this._sections = u, this._title = a;
598
697
  }
599
- /** Initiates configuration builder */
600
698
  static create(t = "Heavy") {
601
- return new g(
699
+ return new d(
602
700
  t,
603
701
  void 0,
604
702
  {},
605
- f(!0),
606
- f([])
703
+ {},
704
+ A(!0),
705
+ A([]),
706
+ void 0
607
707
  );
608
708
  }
609
- output(t, n) {
709
+ output(t, n, i = {}) {
610
710
  if (typeof n == "function") {
611
711
  const r = `output#${t}`;
612
- return y(r, () => n(new w())), new g(
712
+ return v(r, () => n(new w())), new d(
613
713
  this._renderingMode,
614
714
  this._initialArgs,
715
+ this._initialUiState,
615
716
  {
616
717
  ...this._outputs,
617
- [t]: r
718
+ [t]: {
719
+ __renderLambda: !0,
720
+ handle: r,
721
+ ...i
722
+ }
618
723
  },
619
724
  this._inputsValid,
620
- this._sections
725
+ this._sections,
726
+ this._title
621
727
  );
622
728
  } else
623
- return new g(
729
+ return new d(
624
730
  this._renderingMode,
625
731
  this._initialArgs,
732
+ this._initialUiState,
626
733
  {
627
734
  ...this._outputs,
628
735
  [t]: n
629
736
  },
630
737
  this._inputsValid,
631
- this._sections
738
+ this._sections,
739
+ this._title
632
740
  );
633
741
  }
742
+ /** Shortcut for {@link output} with retentive flag set to true. */
743
+ retentiveOutput(t, n) {
744
+ return this.output(t, n, { retentive: !0 });
745
+ }
634
746
  /** @deprecated */
635
747
  canRun(t) {
636
748
  return this.inputsValid(t);
637
749
  }
638
750
  argsValid(t) {
639
- return typeof t == "function" ? (y("inputsValid", () => t(new w())), new g(
751
+ return typeof t == "function" ? (v("inputsValid", () => t(new w())), new d(
640
752
  this._renderingMode,
641
753
  this._initialArgs,
754
+ this._initialUiState,
642
755
  this._outputs,
643
- "inputsValid",
644
- this._sections
645
- )) : new g(
756
+ {
757
+ __renderLambda: !0,
758
+ handle: "inputsValid"
759
+ },
760
+ this._sections,
761
+ this._title
762
+ )) : new d(
646
763
  this._renderingMode,
647
764
  this._initialArgs,
765
+ this._initialUiState,
648
766
  this._outputs,
649
767
  t,
650
- this._sections
768
+ this._sections,
769
+ this._title
651
770
  );
652
771
  }
653
772
  inputsValid(t) {
654
773
  return this.argsValid(t);
655
774
  }
656
775
  sections(t) {
657
- return Array.isArray(t) ? this.sections(f(t)) : typeof t == "function" ? (y("sections", () => t(new w())), new g(
776
+ return Array.isArray(t) ? this.sections(A(t)) : typeof t == "function" ? (v("sections", () => t(new w())), new d(
658
777
  this._renderingMode,
659
778
  this._initialArgs,
779
+ this._initialUiState,
660
780
  this._outputs,
661
781
  this._inputsValid,
662
- "sections"
663
- )) : new g(
782
+ { __renderLambda: !0, handle: "sections" },
783
+ this._title
784
+ )) : new d(
664
785
  this._renderingMode,
665
786
  this._initialArgs,
787
+ this._initialUiState,
666
788
  this._outputs,
667
789
  this._inputsValid,
668
- t
790
+ t,
791
+ this._title
669
792
  );
670
793
  }
671
- /** Sets initial args for the block, this value must be specified. */
794
+ title(t) {
795
+ return v("title", () => t(new w())), new d(
796
+ this._renderingMode,
797
+ this._initialArgs,
798
+ this._initialUiState,
799
+ this._outputs,
800
+ this._inputsValid,
801
+ this._sections,
802
+ { __renderLambda: !0, handle: "title" }
803
+ );
804
+ }
805
+ /**
806
+ * Sets initial args for the block, this value must be specified.
807
+ * @deprecated use {@link withArgs}
808
+ * */
672
809
  initialArgs(t) {
673
- return new g(
810
+ return new d(
674
811
  this._renderingMode,
675
812
  t,
813
+ this._initialUiState,
676
814
  this._outputs,
677
815
  this._inputsValid,
678
- this._sections
816
+ this._sections,
817
+ this._title
818
+ );
819
+ }
820
+ /** Sets initial args for the block, this value must be specified. */
821
+ withArgs(t) {
822
+ return new d(
823
+ this._renderingMode,
824
+ t,
825
+ this._initialUiState,
826
+ this._outputs,
827
+ this._inputsValid,
828
+ this._sections,
829
+ this._title
830
+ );
831
+ }
832
+ /** Defines type and sets initial value for block UiState. */
833
+ withUiState(t) {
834
+ return new d(
835
+ this._renderingMode,
836
+ this._initialArgs,
837
+ t,
838
+ this._outputs,
839
+ this._inputsValid,
840
+ this._sections,
841
+ this._title
679
842
  );
680
843
  }
681
844
  /** Renders all provided block settings into a pre-configured platforma API
@@ -684,29 +847,42 @@ class g {
684
847
  done() {
685
848
  if (this._initialArgs === void 0) throw new Error("Initial arguments not set.");
686
849
  const t = {
687
- sdkVersion: O,
850
+ v3: {
851
+ sdkVersion: y,
852
+ renderingMode: this._renderingMode,
853
+ initialArgs: this._initialArgs,
854
+ initialUiState: this._initialUiState,
855
+ inputsValid: this._inputsValid,
856
+ sections: this._sections,
857
+ title: this._title,
858
+ outputs: this._outputs
859
+ },
860
+ // fields below are added to allow previous desktop versions read generated configs
861
+ sdkVersion: y,
688
862
  renderingMode: this._renderingMode,
689
863
  initialArgs: this._initialArgs,
690
- inputsValid: this._inputsValid,
691
- sections: this._sections,
692
- outputs: this._outputs
864
+ inputsValid: V(this._inputsValid),
865
+ sections: V(this._sections),
866
+ outputs: Object.fromEntries(
867
+ Object.entries(this._outputs).map(([n, i]) => [n, V(i)])
868
+ )
693
869
  };
694
- return $() ? x(t) : { config: t };
870
+ return N() ? k({ sdkVersion: y }) : { config: t };
695
871
  }
696
872
  }
697
- function St(e, t, n) {
698
- var a, d;
699
- const r = e.resultPool.getData().entries.map((u) => u.obj).filter(v).filter((u) => u.spec.name === "pl7.app/label" && u.spec.axesSpec.length === 1), i = [];
700
- for (const u of t)
701
- for (const T of u.spec.axesSpec) {
702
- const B = P(T);
703
- for (const _ of r)
704
- J(B, P(_.spec.axesSpec[0])) && i.push(_);
873
+ function Ot(e, t, n) {
874
+ var o, u;
875
+ const i = e.resultPool.getData().entries.map((a) => a.obj).filter(I).filter((a) => a.spec.name === "pl7.app/label" && a.spec.axesSpec.length === 1), r = [];
876
+ for (const a of t)
877
+ for (const p of a.spec.axesSpec) {
878
+ const c = D(p);
879
+ for (const f of i)
880
+ J(c, D(f.spec.axesSpec[0])) && r.push(f);
705
881
  }
706
882
  return e.createPTable({
707
- columns: [...t, ...i],
708
- filters: (a = n == null ? void 0 : n.pTableParams) == null ? void 0 : a.filters,
709
- sorting: (d = n == null ? void 0 : n.pTableParams) == null ? void 0 : d.sorting
883
+ columns: [...t, ...r],
884
+ filters: (o = n == null ? void 0 : n.pTableParams) == null ? void 0 : o.filters,
885
+ sorting: (u = n == null ? void 0 : n.pTableParams) == null ? void 0 : u.sorting
710
886
  });
711
887
  }
712
888
  class xt {
@@ -729,77 +905,78 @@ class xt {
729
905
  return await platforma.pFrameDriver.getUniqueValues(this.handle, t);
730
906
  }
731
907
  }
732
- function z(e) {
733
- return S({
908
+ function X(e) {
909
+ return R({
734
910
  __isRef: !0,
735
- blockId: m(e, "blockId"),
736
- name: m(e, "name")
911
+ blockId: S(e, "blockId"),
912
+ name: S(e, "name")
737
913
  });
738
914
  }
739
- function Rt(e) {
740
- return S({
741
- ref: z(m(e, "ref")),
742
- label: m(e, "label")
915
+ function It(e) {
916
+ return R({
917
+ ref: X(S(e, "ref")),
918
+ label: S(e, "label")
743
919
  });
744
920
  }
745
- const Vt = {
746
- sdkVersion: O
921
+ const Rt = {
922
+ sdkVersion: y
747
923
  };
748
- function It() {
749
- return x();
924
+ function kt() {
925
+ return k({ sdkVersion: y });
750
926
  }
751
- function Ot(e) {
927
+ function Lt(e) {
752
928
  if (typeof globalThis.getEnvironmentValue == "function")
753
929
  return globalThis.getEnvironmentValue(e);
754
930
  }
755
931
  export {
756
- Z as Args,
757
- g as BlockModel,
758
- Vt as CurrentSdkInfo,
759
- l as FutureRef,
760
- tt as It,
761
- Ft as JsRenderInternal,
762
- et as MainOutputs,
932
+ nt as Args,
933
+ d as BlockModel,
934
+ Rt as CurrentSdkInfo,
935
+ h as FutureRef,
936
+ it as It,
937
+ Pt as JsRenderInternal,
938
+ rt as MainOutputs,
763
939
  G as OutputError,
764
940
  xt as PFrameImpl,
765
941
  w as RenderCtx,
766
- U as ResultPool,
767
- nt as StagingOutputs,
768
- p as TreeNodeAccessor,
769
- rt as UiState,
770
- ct as and,
771
- St as createPlDataTable,
772
- at as flatten,
773
- Rt as fromPlOption,
774
- z as fromPlRef,
775
- ft as getBlobContent,
776
- yt as getBlobContentAsJson,
777
- mt as getBlobContentAsString,
778
- bt as getDownloadedBlobContent,
779
- Ot as getEnvironmentValue,
780
- h as getFromCfg,
781
- f as getImmediate,
782
- At as getImportProgress,
783
- m as getJsonField,
784
- Ct as getLastLogs,
785
- Pt as getLogHandle,
786
- wt as getOnDemandBlobContent,
787
- _t as getProgressLog,
788
- It as getRawPlatformaInstance,
789
- dt as getResourceField,
790
- pt as getResourceValueAsJson,
791
- ut as isEmpty,
792
- Dt as isFunctionHandle,
793
- Y as isolate,
794
- st as makeArray,
795
- S as makeObject,
796
- ot as mapArrayValues,
797
- it as mapRecordValues,
798
- ht as mapResourceFields,
799
- vt as normalizeBlockConfig,
800
- lt as not,
942
+ z as ResultPool,
943
+ st as StagingOutputs,
944
+ m as TreeNodeAccessor,
945
+ ot as UiState,
946
+ pt as and,
947
+ Ot as createPlDataTable,
948
+ V as downgradeCfgOrLambda,
949
+ Dt as extractConfig,
950
+ ct as flatten,
951
+ It as fromPlOption,
952
+ X as fromPlRef,
953
+ yt as getBlobContent,
954
+ vt as getBlobContentAsJson,
955
+ _t as getBlobContentAsString,
956
+ wt as getDownloadedBlobContent,
957
+ Lt as getEnvironmentValue,
958
+ _ as getFromCfg,
959
+ A as getImmediate,
960
+ Ct as getImportProgress,
961
+ S as getJsonField,
962
+ St as getLastLogs,
963
+ Vt as getLogHandle,
964
+ At as getOnDemandBlobContent,
965
+ Ft as getProgressLog,
966
+ kt as getRawPlatformaInstance,
967
+ ft as getResourceField,
968
+ mt as getResourceValueAsJson,
969
+ Q as isConfigLambda,
970
+ dt as isEmpty,
971
+ et as isolate,
972
+ at as makeArray,
973
+ R as makeObject,
974
+ lt as mapArrayValues,
975
+ ut as mapRecordValues,
976
+ bt as mapResourceFields,
977
+ ht as not,
801
978
  gt as or,
802
- N as readOutput,
803
- X as wrapOutputs
979
+ H as readOutput,
980
+ tt as wrapOutputs
804
981
  };
805
982
  //# sourceMappingURL=index.mjs.map