@platforma-sdk/model 1.2.30 → 1.2.32

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,21 +1,21 @@
1
- var D = Object.defineProperty;
2
- var I = (e, t, n) => t in e ? D(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var l = (e, t, n) => I(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { isPColumn as O, mapPObjectData as w, mapValueInVOE as x, mapPTableDef as B } from "@milaboratories/pl-model-common";
1
+ var V = Object.defineProperty;
2
+ var I = (e, t, n) => t in e ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var u = (e, t, n) => I(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { isPColumn as O, mapPObjectData as b, mapValueInVOE as x, mapPTableDef as B } from "@milaboratories/pl-model-common";
5
5
  export * from "@milaboratories/pl-model-common";
6
6
  class E 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 T(e) {
11
+ function L(e) {
12
12
  if (!e.ok) throw new E(e.errors, e.moreErrors);
13
13
  return e.value;
14
14
  }
15
15
  function M(e) {
16
16
  return new Proxy(e, {
17
17
  get(t, n) {
18
- return T(t[n]);
18
+ return L(t[n]);
19
19
  }
20
20
  });
21
21
  }
@@ -31,7 +31,7 @@ function K(e) {
31
31
  cfg: e
32
32
  };
33
33
  }
34
- const W = d("$args"), z = d("$it"), U = d("$prod"), q = d("$staging"), Q = d("$ui");
34
+ const W = d("$args"), U = d("$it"), z = d("$prod"), q = d("$staging"), Q = d("$ui");
35
35
  function h(e) {
36
36
  return { type: "Immediate", value: e };
37
37
  }
@@ -187,7 +187,7 @@ function mt(e) {
187
187
  source: i(e)
188
188
  };
189
189
  }
190
- function L() {
190
+ function T() {
191
191
  return typeof globalThis.getPlatforma < "u" || typeof globalThis.platforma < "u";
192
192
  }
193
193
  function _(e) {
@@ -218,8 +218,8 @@ function j(e, t) {
218
218
  }
219
219
  class a {
220
220
  constructor(t, n = (r) => r) {
221
- l(this, "isResolved", !1);
222
- l(this, "resolvedValue");
221
+ u(this, "isResolved", !1);
222
+ u(this, "resolvedValue");
223
223
  this.handle = t, this.postProcess = n, j(t, (r) => {
224
224
  this.resolvedValue = n(r), this.isResolved = !0;
225
225
  });
@@ -320,8 +320,8 @@ class g {
320
320
  );
321
321
  if (r === void 0) return;
322
322
  const o = {};
323
- for (const [c, R] of Object.entries(r))
324
- o[c] = w(R, (S) => new g(S));
323
+ for (const [c, v] of Object.entries(r))
324
+ o[c] = b(v, (R) => new g(R));
325
325
  return o;
326
326
  }
327
327
  getFileContentAsBase64() {
@@ -384,39 +384,58 @@ class g {
384
384
  return new a(s().getLogHandle(this.handle));
385
385
  }
386
386
  }
387
- const F = "staging", P = "main";
388
- function v(e) {
387
+ const F = "staging", S = "main";
388
+ function P(e) {
389
389
  return typeof e == "object" && e !== null && "__awaited_futures__" in e;
390
390
  }
391
- function b(e, t, n) {
391
+ function w(e, t, n) {
392
392
  if (t.has(n)) return;
393
393
  if (t.add(n), typeof n === "object")
394
- if (v(n)) n.__awaited_futures__.forEach((o) => e.add(o));
394
+ if (P(n)) n.__awaited_futures__.forEach((o) => e.add(o));
395
395
  else if (Array.isArray(n))
396
- for (const o of n) b(e, t, o);
396
+ for (const o of n) w(e, t, o);
397
397
  else
398
398
  for (const [, o] of Object.entries(n))
399
- o !== n && b(e, t, o);
399
+ o !== n && w(e, t, o);
400
400
  }
401
401
  function H(e) {
402
402
  const t = /* @__PURE__ */ new Set();
403
- return b(t, /* @__PURE__ */ new Set(), e), t;
403
+ return w(t, /* @__PURE__ */ new Set(), e), t;
404
404
  }
405
405
  const yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
406
406
  __proto__: null,
407
- MainAccessorName: P,
407
+ MainAccessorName: S,
408
408
  StagingAccessorName: F,
409
409
  getAllFutureAwaits: H,
410
- isFutureAwait: v
410
+ isFutureAwait: P
411
411
  }, Symbol.toStringTag, { value: "Module" }));
412
412
  class J {
413
413
  constructor() {
414
- l(this, "ctx", s());
414
+ u(this, "ctx", s());
415
+ u(this, "defaultLabelFn", (t, n) => {
416
+ var r;
417
+ return ((r = t.annotations) == null ? void 0 : r["pl7.app/label"]) ?? "Unlabelled";
418
+ });
415
419
  }
420
+ /**
421
+ * @deprecated use getOptions()
422
+ */
416
423
  calculateOptions(t) {
417
424
  return this.ctx.calculateOptions(t);
418
425
  }
426
+ 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)
430
+ }));
431
+ }
432
+ /**
433
+ * @deprecated use getData()
434
+ */
419
435
  getDataFromResultPool() {
436
+ return this.getData();
437
+ }
438
+ getData() {
420
439
  const t = this.ctx.getDataFromResultPool();
421
440
  return {
422
441
  isComplete: t.isComplete,
@@ -429,7 +448,13 @@ class J {
429
448
  }))
430
449
  };
431
450
  }
451
+ /**
452
+ * @deprecated use getDataWithErrors()
453
+ */
432
454
  getDataWithErrorsFromResultPool() {
455
+ return this.getDataWithErrors();
456
+ }
457
+ getDataWithErrors() {
433
458
  const t = this.ctx.getDataWithErrorsFromResultPool();
434
459
  return {
435
460
  isComplete: t.isComplete,
@@ -442,16 +467,38 @@ class J {
442
467
  }))
443
468
  };
444
469
  }
470
+ /**
471
+ * @deprecated use getSpecs()
472
+ */
445
473
  getSpecsFromResultPool() {
474
+ return this.getSpecs();
475
+ }
476
+ getSpecs() {
446
477
  return this.ctx.getSpecsFromResultPool();
447
478
  }
479
+ /**
480
+ * @param ref a Ref
481
+ * @returns data associated with the ref
482
+ */
483
+ getDataByRef(t) {
484
+ var n;
485
+ return (n = this.getData().entries.find((r) => r.ref.blockId === t.blockId && r.ref.name === t.name)) == null ? void 0 : n.obj;
486
+ }
487
+ /**
488
+ * @param ref a Ref
489
+ * @returns object spec associated with the ref
490
+ */
491
+ getSpecByRef(t) {
492
+ var n;
493
+ return (n = this.getSpecs().entries.find((r) => r.ref.blockId === t.blockId && r.ref.name === t.name)) == null ? void 0 : n.obj;
494
+ }
448
495
  }
449
496
  class y {
450
497
  constructor() {
451
- l(this, "ctx");
452
- l(this, "args");
453
- l(this, "uiState");
454
- l(this, "resultPool", new J());
498
+ u(this, "ctx");
499
+ u(this, "args");
500
+ u(this, "uiState");
501
+ u(this, "resultPool", new J());
455
502
  this.ctx = s(), this.args = JSON.parse(this.ctx.args), this.uiState = this.ctx.uiState !== void 0 ? JSON.parse(this.ctx.uiState) : void 0;
456
503
  }
457
504
  getNamedAccessor(t) {
@@ -474,7 +521,7 @@ class y {
474
521
  return this.precalc;
475
522
  }
476
523
  get outputs() {
477
- return this.getNamedAccessor(P);
524
+ return this.getNamedAccessor(S);
478
525
  }
479
526
  /**
480
527
  * @deprecated use outputs
@@ -483,7 +530,7 @@ class y {
483
530
  return this.outputs;
484
531
  }
485
532
  createPFrame(t) {
486
- return this.ctx.createPFrame(t.map((n) => w(n, (r) => r.handle)));
533
+ return this.ctx.createPFrame(t.map((n) => b(n, (r) => r.handle)));
487
534
  }
488
535
  createPTable(t) {
489
536
  var n;
@@ -494,17 +541,17 @@ class y {
494
541
  },
495
542
  filters: t.filters ?? [],
496
543
  sorting: t.sorting ?? []
497
- } : n = t, this.ctx.createPTable(B(n, (r) => w(r, (o) => o.handle)));
544
+ } : n = t, this.ctx.createPTable(B(n, (r) => b(r, (o) => o.handle)));
498
545
  }
499
546
  getBlockLabel(t) {
500
547
  return this.ctx.getBlockLabel(t);
501
548
  }
502
549
  }
503
- const V = "1.2.30";
504
- function wt(e) {
550
+ const D = "1.2.32";
551
+ function bt(e) {
505
552
  return typeof e == "string";
506
553
  }
507
- function bt(e) {
554
+ function wt(e) {
508
555
  if (e.inputsValid !== void 0) return e;
509
556
  {
510
557
  if (e.canRun === void 0)
@@ -513,13 +560,13 @@ function bt(e) {
513
560
  return delete t.canRun, t;
514
561
  }
515
562
  }
516
- class u {
563
+ class l {
517
564
  constructor(t, n, r, o, c) {
518
565
  this._renderingMode = t, this._initialArgs = n, this._outputs = r, this._inputsValid = o, this._sections = c;
519
566
  }
520
567
  /** Initiates configuration builder */
521
568
  static create(t = "Heavy") {
522
- return new u(
569
+ return new l(
523
570
  t,
524
571
  void 0,
525
572
  {},
@@ -530,7 +577,7 @@ class u {
530
577
  output(t, n) {
531
578
  if (typeof n == "function") {
532
579
  const r = `output#${t}`;
533
- return f(r, () => n(new y())), new u(
580
+ return f(r, () => n(new y())), new l(
534
581
  this._renderingMode,
535
582
  this._initialArgs,
536
583
  {
@@ -541,7 +588,7 @@ class u {
541
588
  this._sections
542
589
  );
543
590
  } else
544
- return new u(
591
+ return new l(
545
592
  this._renderingMode,
546
593
  this._initialArgs,
547
594
  {
@@ -557,13 +604,13 @@ class u {
557
604
  return this.inputsValid(t);
558
605
  }
559
606
  argsValid(t) {
560
- return typeof t == "function" ? (f("inputsValid", () => t(new y())), new u(
607
+ return typeof t == "function" ? (f("inputsValid", () => t(new y())), new l(
561
608
  this._renderingMode,
562
609
  this._initialArgs,
563
610
  this._outputs,
564
611
  "inputsValid",
565
612
  this._sections
566
- )) : new u(
613
+ )) : new l(
567
614
  this._renderingMode,
568
615
  this._initialArgs,
569
616
  this._outputs,
@@ -575,13 +622,13 @@ class u {
575
622
  return this.argsValid(t);
576
623
  }
577
624
  sections(t) {
578
- return Array.isArray(t) ? this.sections(h(t)) : typeof t == "function" ? (f("sections", () => t(new y())), new u(
625
+ return Array.isArray(t) ? this.sections(h(t)) : typeof t == "function" ? (f("sections", () => t(new y())), new l(
579
626
  this._renderingMode,
580
627
  this._initialArgs,
581
628
  this._outputs,
582
629
  this._inputsValid,
583
630
  "sections"
584
- )) : new u(
631
+ )) : new l(
585
632
  this._renderingMode,
586
633
  this._initialArgs,
587
634
  this._outputs,
@@ -591,7 +638,7 @@ class u {
591
638
  }
592
639
  /** Sets initial args for the block, this value must be specified. */
593
640
  initialArgs(t) {
594
- return new u(
641
+ return new l(
595
642
  this._renderingMode,
596
643
  t,
597
644
  this._outputs,
@@ -605,14 +652,14 @@ class u {
605
652
  done() {
606
653
  if (this._initialArgs === void 0) throw new Error("Initial arguments not set.");
607
654
  const t = {
608
- sdkVersion: V,
655
+ sdkVersion: D,
609
656
  renderingMode: this._renderingMode,
610
657
  initialArgs: this._initialArgs,
611
658
  inputsValid: this._inputsValid,
612
659
  sections: this._sections,
613
660
  outputs: this._outputs
614
661
  };
615
- return L() ? _(t) : { config: t };
662
+ return T() ? _(t) : { config: t };
616
663
  }
617
664
  }
618
665
  class At {
@@ -649,23 +696,23 @@ function Ct(e) {
649
696
  });
650
697
  }
651
698
  const _t = {
652
- sdkVersion: V
699
+ sdkVersion: D
653
700
  };
654
701
  function Ft() {
655
702
  return _();
656
703
  }
657
- function Pt(e) {
704
+ function St(e) {
658
705
  if (typeof globalThis.getEnvironmentValue == "function")
659
706
  return globalThis.getEnvironmentValue(e);
660
707
  }
661
708
  export {
662
709
  W as Args,
663
- u as BlockModel,
710
+ l as BlockModel,
664
711
  _t as CurrentSdkInfo,
665
712
  a as FutureRef,
666
- z as It,
713
+ U as It,
667
714
  yt as JsRenderInternal,
668
- U as MainOutputs,
715
+ z as MainOutputs,
669
716
  E as OutputError,
670
717
  At as PFrameImpl,
671
718
  y as RenderCtx,
@@ -681,7 +728,7 @@ export {
681
728
  ct as getBlobContentAsJson,
682
729
  lt as getBlobContentAsString,
683
730
  gt as getDownloadedBlobContent,
684
- Pt as getEnvironmentValue,
731
+ St as getEnvironmentValue,
685
732
  d as getFromCfg,
686
733
  h as getImmediate,
687
734
  ht as getImportProgress,
@@ -694,17 +741,17 @@ export {
694
741
  it as getResourceField,
695
742
  ot as getResourceValueAsJson,
696
743
  et as isEmpty,
697
- wt as isFunctionHandle,
744
+ bt as isFunctionHandle,
698
745
  K as isolate,
699
746
  X as makeArray,
700
747
  C as makeObject,
701
748
  Z as mapArrayValues,
702
749
  Y as mapRecordValues,
703
750
  at as mapResourceFields,
704
- bt as normalizeBlockConfig,
751
+ wt as normalizeBlockConfig,
705
752
  nt as not,
706
753
  st as or,
707
- T as readOutput,
754
+ L as readOutput,
708
755
  M as wrapOutputs
709
756
  };
710
757
  //# sourceMappingURL=index.mjs.map