@platforma-sdk/model 1.10.2 → 1.10.12
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/components/PlDataTable.d.ts +9 -9
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/PlDataTable.ts +12 -12
|
@@ -68,30 +68,30 @@ export type PlTableFilterNumberNotEquals = {
|
|
|
68
68
|
reference: number;
|
|
69
69
|
};
|
|
70
70
|
/** PlTableFilters numeric filter entry */
|
|
71
|
-
export type
|
|
71
|
+
export type PlTableFilterNumberGreaterThan = {
|
|
72
72
|
/** Predicate type */
|
|
73
|
-
type: '
|
|
73
|
+
type: 'number_greaterThan';
|
|
74
74
|
/** Referense value */
|
|
75
75
|
reference: number;
|
|
76
76
|
};
|
|
77
77
|
/** PlTableFilters numeric filter entry */
|
|
78
|
-
export type
|
|
78
|
+
export type PlTableFilterNumberGreaterThanOrEqualTo = {
|
|
79
79
|
/** Predicate type */
|
|
80
|
-
type: '
|
|
80
|
+
type: 'number_greaterThanOrEqualTo';
|
|
81
81
|
/** Referense value */
|
|
82
82
|
reference: number;
|
|
83
83
|
};
|
|
84
84
|
/** PlTableFilters numeric filter entry */
|
|
85
|
-
export type
|
|
85
|
+
export type PlTableFilterNumberLessThan = {
|
|
86
86
|
/** Predicate type */
|
|
87
|
-
type: '
|
|
87
|
+
type: 'number_lessThan';
|
|
88
88
|
/** Referense value */
|
|
89
89
|
reference: number;
|
|
90
90
|
};
|
|
91
91
|
/** PlTableFilters numeric filter entry */
|
|
92
|
-
export type
|
|
92
|
+
export type PlTableFilterNumberLessThanOrEqualTo = {
|
|
93
93
|
/** Predicate type */
|
|
94
|
-
type: '
|
|
94
|
+
type: 'number_lessThanOrEqualTo';
|
|
95
95
|
/** Referense value */
|
|
96
96
|
reference: number;
|
|
97
97
|
};
|
|
@@ -109,7 +109,7 @@ export type PlTableFilterNumberBetween = {
|
|
|
109
109
|
includeUpperBound: boolean;
|
|
110
110
|
};
|
|
111
111
|
/** All PlTableFilters numeric filter entries */
|
|
112
|
-
export type PlTableFilterNumber = PlTableFilterCommon | PlTableFilterNumberEquals | PlTableFilterNumberNotEquals |
|
|
112
|
+
export type PlTableFilterNumber = PlTableFilterCommon | PlTableFilterNumberEquals | PlTableFilterNumberNotEquals | PlTableFilterNumberGreaterThan | PlTableFilterNumberGreaterThanOrEqualTo | PlTableFilterNumberLessThan | PlTableFilterNumberLessThanOrEqualTo | PlTableFilterNumberBetween;
|
|
113
113
|
/** All types of PlTableFilters numeric filter entries */
|
|
114
114
|
export type PlTableFilterNumberType = PlTableFilterNumber['type'];
|
|
115
115
|
/** PlTableFilters string filter entry */
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var $=Object.defineProperty;var H=(e,t,n)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var f=(e,t,n)=>H(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@milaboratories/pl-model-common");class V extends Error{constructor(t,n){super(`${t.length}${n?"+":""} errors, first error: `+t[0]),this.errors=t,this.moreErrors=n}}function k(e){if(!e.ok)throw new V(e.errors,e.moreErrors);return e.value}function G(e){return new Proxy(e,{get(t,n){return k(t[n])}})}function c(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null?w(e):e}function v(e){return{type:"GetFromCtx",variable:e}}function K(e){return{type:"Isolate",cfg:e}}const W=v("$args"),q=v("$it"),z=v("$prod"),Q=v("$staging"),X=v("$ui");function w(e){return{type:"Immediate",value:e}}function R(e){const t={};for(const[n,r]of Object.entries(e))t[n]=c(r);return{type:"MakeObject",template:t}}function Y(...e){const t=[];for(const n of e)t.push(c(n));return{type:"MakeArray",template:t}}function A(e,t){return{type:"GetJsonField",source:c(e),field:c(t)}}function Z(e,t,n="$it"){return{type:"MapRecordValues",source:e,mapping:t,itVar:n}}function tt(e,t,n="$it"){return{type:"MapArrayValues",source:e,mapping:t,itVar:n}}function et(e){return{type:"Flatten",source:e}}function nt(e){return{type:"IsEmpty",arg:e}}function rt(e){return{type:"Not",operand:e}}function it(e,t){return{type:"And",operand1:e,operand2:t}}function st(e,t){return{type:"Or",operand1:e,operand2:t}}function ot(e,t){return{type:"GetResourceField",source:c(e),field:c(t)}}function at(){return function(e){return{type:"GetResourceValueAsJson",source:c(e)}}}function ut(e,t,n="$it"){return{type:"MapResourceFields",source:e,mapping:t,itVar:n}}function lt(e){return{type:"GetBlobContent",source:c(e)}}function ct(e){return{type:"GetBlobContentAsString",source:c(e)}}function dt(){return function(e){return{type:"GetBlobContentAsJson",source:c(e)}}}function pt(e){return{type:"GetDownloadedBlobContent",source:c(e)}}function gt(e){return{type:"GetOnDemandBlobContent",source:c(e)}}function ht(e){return{type:"GetImportProgress",source:c(e)}}function ft(e,t){return{type:"GetLastLogs",source:c(e),lines:t}}function mt(e,t){return{type:"GetProgressLog",source:c(e),patternToSearch:t}}function yt(e){return{type:"GetLogHandle",source:c(e)}}function bt(){return typeof globalThis.getPlatforma<"u"||typeof globalThis.platforma<"u"}function L(e){if(e&&typeof globalThis.getPlatforma=="function")return globalThis.getPlatforma(e);if(typeof globalThis.platforma<"u")return globalThis.platforma;throw new Error("Can't get platforma instance.")}function vt(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx}function o(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx;throw new Error("Not in config rendering context")}function S(e,t){const n=vt();if(n===void 0)return!1;if(e in n.callbackRegistry)throw new Error(`Callback with key ${e} already registered.`);return n.callbackRegistry[e]=t,!0}const O=new Map;function _t(e,t){e in o().callbackRegistry||(o().callbackRegistry[e]=n=>{for(const r of O.get(e))r(n)},O.set(e,[])),O.get(e).push(t)}class h{constructor(t,n=r=>r){f(this,"isResolved",!1);f(this,"resolvedValue");this.handle=t,this.postProcess=n,_t(t,r=>{this.resolvedValue=n(r),this.isResolved=!0})}map(t){return new h(this.handle,n=>t(this.postProcess(n)))}mapDefined(t){return new h(this.handle,n=>{const r=this.postProcess(n);return r?t(r):void 0})}toJSON(){return this.isResolved?this.resolvedValue:{__awaited_futures__:[this.handle]}}}function I(e){return e===void 0?void 0:new y(e)}class y{constructor(t){this.handle=t}resolve(...t){const n=t.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveOutput(...t){const n=t.map(r=>({assertFieldType:"Output",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveInput(...t){const n=t.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveAny(...t){return this.resolveWithCommon({},...t)}resolveWithCommon(t,...n){return I(o().resolveWithCommon(this.handle,t,...n))}get resourceType(){return o().getResourceType(this.handle)}getInputsLocked(){return o().getInputsLocked(this.handle)}getOutputsLocked(){return o().getOutputsLocked(this.handle)}getIsReadyOrError(){return o().getIsReadyOrError(this.handle)}getIsFinal(){return o().getIsFinal(this.handle)}getError(){return I(o().getError(this.handle))}listInputFields(){return o().listInputFields(this.handle)}listOutputFields(){return o().listOutputFields(this.handle)}listDynamicFields(){return o().listDynamicFields(this.handle)}getKeyValueBase64(t){return o().getKeyValueBase64(this.handle,t)}getKeyValueAsString(t){return o().getKeyValueAsString(this.handle,t)}getKeyValueAsJson(t){const n=this.getKeyValueAsString(t);if(n==null)throw new Error("Resource has no content.");return JSON.parse(n)}getDataBase64(){return o().getDataBase64(this.handle)}getDataAsString(){return o().getDataAsString(this.handle)}getDataAsJson(){const t=this.getDataAsString();if(t==null)throw new Error("Resource has no content.");return JSON.parse(t)}getPColumns(t=!1,n=""){const r=this.parsePObjectCollection(t,n);return r===void 0?void 0:Object.entries(r).map(([,s])=>{if(!p.isPColumn(s))throw new Error(`not a PColumn (kind = ${s.spec.kind})`);return s})}parsePObjectCollection(t=!1,n=""){const r=o().parsePObjectCollection(this.handle,t,n);if(r===void 0)return;const i={};for(const[s,u]of Object.entries(r))i[s]=p.mapPObjectData(u,a=>new y(a));return i}getFileContentAsBase64(){return new h(o().getBlobContentAsBase64(this.handle))}getFileContentAsString(){return new h(o().getBlobContentAsString(this.handle))}getFileContentAsJson(){return new h(o().getBlobContentAsString(this.handle)).mapDefined(t=>JSON.parse(t))}getBlobContentAsBase64(){return this.getFileContentAsBase64()}getBlobContentAsString(){return this.getFileContentAsString()}getFileHandle(){return new h(o().getDownloadedBlobContentHandle(this.handle))}getDownloadedBlobHandle(){return this.getFileHandle()}getRemoteFileHandle(){return new h(o().getOnDemandBlobContentHandle(this.handle))}getOnDemandBlobHandle(){return this.getRemoteFileHandle()}getImportProgress(){return new h(o().getImportProgress(this.handle))}getLastLogs(t){return new h(o().getLastLogs(this.handle,t))}getProgressLog(t){return new h(o().getProgressLog(this.handle,t))}getLogHandle(){return new h(o().getLogHandle(this.handle))}allFieldsResolved(t="Input"){switch(t){case"Input":return this.getInputsLocked()&&this.listInputFields().every(n=>this.resolve({field:n,assertFieldType:"Input"})!==void 0);case"Output":return this.getOutputsLocked()&&this.listOutputFields().every(n=>this.resolve({field:n,assertFieldType:"Output"})!==void 0)}}mapFields(t,n){const{fieldType:r,requireLocked:i,skipUnresolved:s}={fieldType:"Input",requireLocked:!0,skipUnresolved:!1,...n},u=t;if(i&&(r==="Input"&&!this.getInputsLocked()||r==="Output"&&!this.getOutputsLocked()))return;let d=(r==="Input"?this.listInputFields():r==="Output"?this.listOutputFields():this.listDynamicFields()).map(l=>[l,this.resolve({field:l,assertFieldType:r})]);return s&&(d=d.filter(l=>l[1]!==void 0)),d.map(([l,m])=>u(l,m))}}const x="staging",T="main";function j(e){return typeof e=="object"&&e!==null&&"__awaited_futures__"in e}function P(e,t,n){if(t.has(n))return;if(t.add(n),typeof n==="object")if(j(n))n.__awaited_futures__.forEach(i=>e.add(i));else if(Array.isArray(n))for(const i of n)P(e,t,i);else for(const[,i]of Object.entries(n))i!==n&&P(e,t,i)}function wt(e){const t=new Set;return P(t,new Set,e),t}const Ct=Object.freeze(Object.defineProperty({__proto__:null,MainAccessorName:T,StagingAccessorName:x,getAllFutureAwaits:wt,isFutureAwait:j},Symbol.toStringTag,{value:"Module"}));class E{constructor(){f(this,"ctx",o());f(this,"defaultLabelFn",(t,n)=>{var r;return((r=t.annotations)==null?void 0:r["pl7.app/label"])??"Unlabelled"})}calculateOptions(t){return this.ctx.calculateOptions(t)}getOptions(t,n=this.defaultLabelFn){return this.getSpecs().entries.filter(r=>t(r.obj)).map(r=>({ref:r.ref,label:n(r.obj,r.ref)}))}getDataFromResultPool(){return this.getData()}getData(){const t=this.ctx.getDataFromResultPool();return{isComplete:t.isComplete,entries:t.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:new y(n.obj.data)}}))}}getDataWithErrorsFromResultPool(){return this.getDataWithErrors()}getDataWithErrors(){const t=this.ctx.getDataWithErrorsFromResultPool();return{isComplete:t.isComplete,entries:t.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:p.mapValueInVOE(n.obj.data,r=>new y(r))}}))}}getSpecsFromResultPool(){return this.getSpecs()}getSpecs(){return this.ctx.getSpecsFromResultPool()}getDataByRef(t){var n;return typeof this.ctx.getDataFromResultPoolByRef>"u"?(n=this.getData().entries.find(r=>r.ref.blockId===t.blockId&&r.ref.name===t.name))==null?void 0:n.obj:p.mapPObjectData(this.ctx.getDataFromResultPoolByRef(t.blockId,t.name),r=>new y(r))}getSpecByRef(t){var n;return typeof this.ctx.getSpecFromResultPoolByRef>"u"?(n=this.getSpecs().entries.find(r=>r.ref.blockId===t.blockId&&r.ref.name===t.name))==null?void 0:n.obj:this.ctx.getSpecFromResultPoolByRef(t.blockId,t.name)}findDataWithCompatibleSpec(t){const n=[];t:for(const r of this.getData().entries){if(!p.isPColumnSpec(r.obj.spec))continue;const i=r.obj.spec;if(t.name===i.name&&t.valueType===i.valueType&&t.axesSpec.length===i.axesSpec.length&&D(t.domain,i.domain)){for(let s=0;s<t.axesSpec.length;++s){const u=t.axesSpec[s],a=i.axesSpec[s];if(u.name!==a.name||u.type!==a.type||!D(u.domain,a.domain))continue t}n.push(r.obj)}}return n}}function D(e,t){if(e===void 0)return t===void 0;if(t===void 0)return!0;for(const n in t)if(e[n]!==t[n])return!1;return!0}class _{constructor(){f(this,"ctx");f(this,"args");f(this,"uiState");f(this,"resultPool",new E);this.ctx=o(),this.args=JSON.parse(this.ctx.args),this.uiState=this.ctx.uiState!==void 0?JSON.parse(this.ctx.uiState):void 0}getNamedAccessor(t){const n=this.ctx.getAccessorHandleByName(t);return n?new y(n):void 0}get prerun(){return this.getNamedAccessor(x)}get precalc(){return this.prerun}get stagingOutput(){return this.precalc}get outputs(){return this.getNamedAccessor(T)}get mainOutput(){return this.outputs}createPFrame(t){return this.ctx.createPFrame(t.map(n=>p.mapPObjectData(n,r=>r.handle)))}createPTable(t){var n;return"columns"in t?n={src:{type:"inner",entries:t.columns.map(r=>({type:"column",column:r}))},filters:t.filters??[],sorting:t.sorting??[]}:n=t,this.ctx.createPTable(p.mapPTableDef(n,r=>p.mapPObjectData(r,i=>i.handle)))}getBlockLabel(t){return this.ctx.getBlockLabel(t)}getCurrentUnstableMarker(){if(!(typeof this.ctx.getCurrentUnstableMarker>"u"))return this.ctx.getCurrentUnstableMarker()}}const M="PColumnData/ResourceMap",B="PColumnData/Partitioned/ResourceMap";function U(e,t,n,r=[],i){if(e===void 0)return!1;switch(e.resourceType.name){case M:{let s=e.getInputsLocked();for(const u of e.listInputFields()){const a=e.resolve({field:u,assertFieldType:"Input"}),d=[...r,...JSON.parse(u)],l=a===void 0?void 0:t(a);l===void 0&&(s=!1),(l!==void 0||i)&&n.push({key:d,value:l})}return s}case B:{let s=e.getInputsLocked();for(const u of e.listInputFields()){const a=e.resolve({field:u,assertFieldType:"Input"});if(a===void 0)s=!1;else{const d=[...r,...JSON.parse(u)],l=U(a,t,n,d,i);s=s&&l}}return s}default:throw new Error(`Unknown resource type: ${e.resourceType.name}`)}}function At(e,t,n=!1){const r=[];return{isComplete:U(e,t,r,[],n),data:r}}const C="1.10.2";function J(e){return e.__renderLambda===!0}function F(e){if(e!==void 0)return J(e)?e.handle:e}function b(e){if(e!==void 0)return typeof e=="string"?{__renderLambda:!0,handle:e,retentive:!1}:e}function St(e){if(e.v3!==void 0){const{initialArgs:t,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:u,sections:a,title:d}=e.v3,{code:l}=e;return{initialArgs:t,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:u,sections:a,title:d,code:l}}else if(e.inputsValid!==void 0){const{sdkVersion:t,renderingMode:n,outputs:r,inputsValid:i,sections:s,initialArgs:u,code:a}=e,d=Object.keys(e);if(t===void 0||n===void 0||r===void 0||i===void 0||s===void 0||u===void 0)throw new Error(`Malformed config v2. SDK version ${t}; Fields = ${d.join(", ")}`);return{sdkVersion:t,renderingMode:n,initialArgs:u,outputs:Object.fromEntries(Object.entries(r).map(([l,m])=>[l,b(m)])),inputsValid:b(i),sections:b(s),initialUiState:void 0,code:a}}else if(e.renderingMode!==void 0){const{sdkVersion:t,canRun:n,renderingMode:r,outputs:i,sections:s,initialArgs:u,code:a}=e,d=Object.keys(e);if(r===void 0||i===void 0||n===void 0||s===void 0||u===void 0)throw new Error(`Malformed config v1. SDK version ${t}; Fields = ${d.join(", ")}`);return{sdkVersion:t??"unknown",renderingMode:r,initialArgs:u,outputs:Object.fromEntries(Object.entries(i).map(([l,m])=>[l,b(m)])),inputsValid:b(n),sections:b(s),initialUiState:void 0,code:a}}else{const{sdkVersion:t}=e,n=Object.keys(e);throw new Error(`Config format not supported: SDK = ${t}; Fields = ${n.join(", ")}`)}}class g{constructor(t,n,r,i,s,u,a){this._renderingMode=t,this._initialArgs=n,this._initialUiState=r,this._outputs=i,this._inputsValid=s,this._sections=u,this._title=a}static create(t="Heavy"){return new g(t,void 0,{},{},w(!0),w([]),void 0)}output(t,n,r={}){if(typeof n=="function"){const i=`output#${t}`;return S(i,()=>n(new _)),new g(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[t]:{__renderLambda:!0,handle:i,...r}},this._inputsValid,this._sections,this._title)}else return new g(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[t]:n},this._inputsValid,this._sections,this._title)}retentiveOutput(t,n){return this.output(t,n,{retentive:!0})}canRun(t){return this.inputsValid(t)}argsValid(t){return typeof t=="function"?(S("inputsValid",()=>t(new _)),new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,{__renderLambda:!0,handle:"inputsValid"},this._sections,this._title)):new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,t,this._sections,this._title)}inputsValid(t){return this.argsValid(t)}sections(t){return Array.isArray(t)?this.sections(w(t)):typeof t=="function"?(S("sections",()=>t(new _)),new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,{__renderLambda:!0,handle:"sections"},this._title)):new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,t,this._title)}title(t){return S("title",()=>t(new _)),new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,this._sections,{__renderLambda:!0,handle:"title"})}initialArgs(t){return new g(this._renderingMode,t,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withArgs(t){return new g(this._renderingMode,t,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withUiState(t){return new g(this._renderingMode,this._initialArgs,t,this._outputs,this._inputsValid,this._sections,this._title)}done(){if(this._initialArgs===void 0)throw new Error("Initial arguments not set.");const t={v3:{sdkVersion:C,renderingMode:this._renderingMode,initialArgs:this._initialArgs,initialUiState:this._initialUiState,inputsValid:this._inputsValid,sections:this._sections,title:this._title,outputs:this._outputs},sdkVersion:C,renderingMode:this._renderingMode,initialArgs:this._initialArgs,inputsValid:F(this._inputsValid),sections:F(this._sections),outputs:Object.fromEntries(Object.entries(this._outputs).map(([n,r])=>[n,F(r)]))};return bt()?L({sdkVersion:C}):{config:t}}}function Ft(e,t,n){var s,u;const r=e.resultPool.getData().entries.map(a=>a.obj).filter(p.isPColumn).filter(a=>a.spec.name==="pl7.app/label"&&a.spec.axesSpec.length===1),i=[];for(const a of t)for(const d of a.spec.axesSpec){const l=p.getAxisId(d);for(const m of r)p.matchAxisId(l,p.getAxisId(m.spec.axesSpec[0]))&&i.push(m)}return e.createPTable({columns:[...t,...i],filters:(s=n==null?void 0:n.pTableParams)==null?void 0:s.filters,sorting:(u=n==null?void 0:n.pTableParams)==null?void 0:u.sorting})}class Ot{constructor(t){this.handle=t}async findColumns(t){return await platforma.pFrameDriver.findColumns(this.handle,t)}async getColumnSpec(t){return await platforma.pFrameDriver.getColumnSpec(this.handle,t)}async listColumns(){return await platforma.pFrameDriver.listColumns(this.handle)}async calculateTableData(t){return await platforma.pFrameDriver.calculateTableData(this.handle,t)}async getUniqueValues(t){return await platforma.pFrameDriver.getUniqueValues(this.handle,t)}}function N(e){return R({__isRef:!0,blockId:A(e,"blockId"),name:A(e,"name")})}function Pt(e){return R({ref:N(A(e,"ref")),label:A(e,"label")})}const Rt={sdkVersion:C};function It(){return L({sdkVersion:C})}function Dt(e){if(typeof globalThis.getEnvironmentValue=="function")return globalThis.getEnvironmentValue(e)}exports.Args=W;exports.BlockModel=g;exports.CurrentSdkInfo=Rt;exports.FutureRef=h;exports.It=q;exports.JsRenderInternal=Ct;exports.MainOutputs=z;exports.OutputError=V;exports.PFrameImpl=Ot;exports.RenderCtx=_;exports.ResourceMapResourcePartitionedTypeName=B;exports.ResourceMapResourceTypeName=M;exports.ResultPool=E;exports.StagingOutputs=Q;exports.TreeNodeAccessor=y;exports.UiState=X;exports.and=it;exports.createPlDataTable=Ft;exports.downgradeCfgOrLambda=F;exports.extractConfig=St;exports.flatten=et;exports.fromPlOption=Pt;exports.fromPlRef=N;exports.getBlobContent=lt;exports.getBlobContentAsJson=dt;exports.getBlobContentAsString=ct;exports.getDownloadedBlobContent=pt;exports.getEnvironmentValue=Dt;exports.getFromCfg=v;exports.getImmediate=w;exports.getImportProgress=ht;exports.getJsonField=A;exports.getLastLogs=ft;exports.getLogHandle=yt;exports.getOnDemandBlobContent=gt;exports.getProgressLog=mt;exports.getRawPlatformaInstance=It;exports.getResourceField=ot;exports.getResourceValueAsJson=at;exports.isConfigLambda=J;exports.isEmpty=nt;exports.isolate=K;exports.makeArray=Y;exports.makeObject=R;exports.mapArrayValues=tt;exports.mapRecordValues=Z;exports.mapResourceFields=ut;exports.not=rt;exports.or=st;exports.parseResourceMap=At;exports.readOutput=k;exports.wrapOutputs=G;Object.keys(p).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>p[e]})});
|
|
1
|
+
"use strict";var $=Object.defineProperty;var H=(e,t,n)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var f=(e,t,n)=>H(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@milaboratories/pl-model-common");class V extends Error{constructor(t,n){super(`${t.length}${n?"+":""} errors, first error: `+t[0]),this.errors=t,this.moreErrors=n}}function k(e){if(!e.ok)throw new V(e.errors,e.moreErrors);return e.value}function G(e){return new Proxy(e,{get(t,n){return k(t[n])}})}function c(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null?w(e):e}function v(e){return{type:"GetFromCtx",variable:e}}function K(e){return{type:"Isolate",cfg:e}}const W=v("$args"),q=v("$it"),z=v("$prod"),Q=v("$staging"),X=v("$ui");function w(e){return{type:"Immediate",value:e}}function R(e){const t={};for(const[n,r]of Object.entries(e))t[n]=c(r);return{type:"MakeObject",template:t}}function Y(...e){const t=[];for(const n of e)t.push(c(n));return{type:"MakeArray",template:t}}function A(e,t){return{type:"GetJsonField",source:c(e),field:c(t)}}function Z(e,t,n="$it"){return{type:"MapRecordValues",source:e,mapping:t,itVar:n}}function tt(e,t,n="$it"){return{type:"MapArrayValues",source:e,mapping:t,itVar:n}}function et(e){return{type:"Flatten",source:e}}function nt(e){return{type:"IsEmpty",arg:e}}function rt(e){return{type:"Not",operand:e}}function it(e,t){return{type:"And",operand1:e,operand2:t}}function st(e,t){return{type:"Or",operand1:e,operand2:t}}function ot(e,t){return{type:"GetResourceField",source:c(e),field:c(t)}}function at(){return function(e){return{type:"GetResourceValueAsJson",source:c(e)}}}function ut(e,t,n="$it"){return{type:"MapResourceFields",source:e,mapping:t,itVar:n}}function lt(e){return{type:"GetBlobContent",source:c(e)}}function ct(e){return{type:"GetBlobContentAsString",source:c(e)}}function dt(){return function(e){return{type:"GetBlobContentAsJson",source:c(e)}}}function pt(e){return{type:"GetDownloadedBlobContent",source:c(e)}}function gt(e){return{type:"GetOnDemandBlobContent",source:c(e)}}function ht(e){return{type:"GetImportProgress",source:c(e)}}function ft(e,t){return{type:"GetLastLogs",source:c(e),lines:t}}function mt(e,t){return{type:"GetProgressLog",source:c(e),patternToSearch:t}}function yt(e){return{type:"GetLogHandle",source:c(e)}}function bt(){return typeof globalThis.getPlatforma<"u"||typeof globalThis.platforma<"u"}function L(e){if(e&&typeof globalThis.getPlatforma=="function")return globalThis.getPlatforma(e);if(typeof globalThis.platforma<"u")return globalThis.platforma;throw new Error("Can't get platforma instance.")}function vt(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx}function o(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx;throw new Error("Not in config rendering context")}function S(e,t){const n=vt();if(n===void 0)return!1;if(e in n.callbackRegistry)throw new Error(`Callback with key ${e} already registered.`);return n.callbackRegistry[e]=t,!0}const O=new Map;function _t(e,t){e in o().callbackRegistry||(o().callbackRegistry[e]=n=>{for(const r of O.get(e))r(n)},O.set(e,[])),O.get(e).push(t)}class h{constructor(t,n=r=>r){f(this,"isResolved",!1);f(this,"resolvedValue");this.handle=t,this.postProcess=n,_t(t,r=>{this.resolvedValue=n(r),this.isResolved=!0})}map(t){return new h(this.handle,n=>t(this.postProcess(n)))}mapDefined(t){return new h(this.handle,n=>{const r=this.postProcess(n);return r?t(r):void 0})}toJSON(){return this.isResolved?this.resolvedValue:{__awaited_futures__:[this.handle]}}}function I(e){return e===void 0?void 0:new y(e)}class y{constructor(t){this.handle=t}resolve(...t){const n=t.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveOutput(...t){const n=t.map(r=>({assertFieldType:"Output",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveInput(...t){const n=t.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveAny(...t){return this.resolveWithCommon({},...t)}resolveWithCommon(t,...n){return I(o().resolveWithCommon(this.handle,t,...n))}get resourceType(){return o().getResourceType(this.handle)}getInputsLocked(){return o().getInputsLocked(this.handle)}getOutputsLocked(){return o().getOutputsLocked(this.handle)}getIsReadyOrError(){return o().getIsReadyOrError(this.handle)}getIsFinal(){return o().getIsFinal(this.handle)}getError(){return I(o().getError(this.handle))}listInputFields(){return o().listInputFields(this.handle)}listOutputFields(){return o().listOutputFields(this.handle)}listDynamicFields(){return o().listDynamicFields(this.handle)}getKeyValueBase64(t){return o().getKeyValueBase64(this.handle,t)}getKeyValueAsString(t){return o().getKeyValueAsString(this.handle,t)}getKeyValueAsJson(t){const n=this.getKeyValueAsString(t);if(n==null)throw new Error("Resource has no content.");return JSON.parse(n)}getDataBase64(){return o().getDataBase64(this.handle)}getDataAsString(){return o().getDataAsString(this.handle)}getDataAsJson(){const t=this.getDataAsString();if(t==null)throw new Error("Resource has no content.");return JSON.parse(t)}getPColumns(t=!1,n=""){const r=this.parsePObjectCollection(t,n);return r===void 0?void 0:Object.entries(r).map(([,s])=>{if(!p.isPColumn(s))throw new Error(`not a PColumn (kind = ${s.spec.kind})`);return s})}parsePObjectCollection(t=!1,n=""){const r=o().parsePObjectCollection(this.handle,t,n);if(r===void 0)return;const i={};for(const[s,u]of Object.entries(r))i[s]=p.mapPObjectData(u,a=>new y(a));return i}getFileContentAsBase64(){return new h(o().getBlobContentAsBase64(this.handle))}getFileContentAsString(){return new h(o().getBlobContentAsString(this.handle))}getFileContentAsJson(){return new h(o().getBlobContentAsString(this.handle)).mapDefined(t=>JSON.parse(t))}getBlobContentAsBase64(){return this.getFileContentAsBase64()}getBlobContentAsString(){return this.getFileContentAsString()}getFileHandle(){return new h(o().getDownloadedBlobContentHandle(this.handle))}getDownloadedBlobHandle(){return this.getFileHandle()}getRemoteFileHandle(){return new h(o().getOnDemandBlobContentHandle(this.handle))}getOnDemandBlobHandle(){return this.getRemoteFileHandle()}getImportProgress(){return new h(o().getImportProgress(this.handle))}getLastLogs(t){return new h(o().getLastLogs(this.handle,t))}getProgressLog(t){return new h(o().getProgressLog(this.handle,t))}getLogHandle(){return new h(o().getLogHandle(this.handle))}allFieldsResolved(t="Input"){switch(t){case"Input":return this.getInputsLocked()&&this.listInputFields().every(n=>this.resolve({field:n,assertFieldType:"Input"})!==void 0);case"Output":return this.getOutputsLocked()&&this.listOutputFields().every(n=>this.resolve({field:n,assertFieldType:"Output"})!==void 0)}}mapFields(t,n){const{fieldType:r,requireLocked:i,skipUnresolved:s}={fieldType:"Input",requireLocked:!0,skipUnresolved:!1,...n},u=t;if(i&&(r==="Input"&&!this.getInputsLocked()||r==="Output"&&!this.getOutputsLocked()))return;let d=(r==="Input"?this.listInputFields():r==="Output"?this.listOutputFields():this.listDynamicFields()).map(l=>[l,this.resolve({field:l,assertFieldType:r})]);return s&&(d=d.filter(l=>l[1]!==void 0)),d.map(([l,m])=>u(l,m))}}const x="staging",T="main";function j(e){return typeof e=="object"&&e!==null&&"__awaited_futures__"in e}function P(e,t,n){if(t.has(n))return;if(t.add(n),typeof n==="object")if(j(n))n.__awaited_futures__.forEach(i=>e.add(i));else if(Array.isArray(n))for(const i of n)P(e,t,i);else for(const[,i]of Object.entries(n))i!==n&&P(e,t,i)}function wt(e){const t=new Set;return P(t,new Set,e),t}const Ct=Object.freeze(Object.defineProperty({__proto__:null,MainAccessorName:T,StagingAccessorName:x,getAllFutureAwaits:wt,isFutureAwait:j},Symbol.toStringTag,{value:"Module"}));class E{constructor(){f(this,"ctx",o());f(this,"defaultLabelFn",(t,n)=>{var r;return((r=t.annotations)==null?void 0:r["pl7.app/label"])??"Unlabelled"})}calculateOptions(t){return this.ctx.calculateOptions(t)}getOptions(t,n=this.defaultLabelFn){return this.getSpecs().entries.filter(r=>t(r.obj)).map(r=>({ref:r.ref,label:n(r.obj,r.ref)}))}getDataFromResultPool(){return this.getData()}getData(){const t=this.ctx.getDataFromResultPool();return{isComplete:t.isComplete,entries:t.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:new y(n.obj.data)}}))}}getDataWithErrorsFromResultPool(){return this.getDataWithErrors()}getDataWithErrors(){const t=this.ctx.getDataWithErrorsFromResultPool();return{isComplete:t.isComplete,entries:t.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:p.mapValueInVOE(n.obj.data,r=>new y(r))}}))}}getSpecsFromResultPool(){return this.getSpecs()}getSpecs(){return this.ctx.getSpecsFromResultPool()}getDataByRef(t){var n;return typeof this.ctx.getDataFromResultPoolByRef>"u"?(n=this.getData().entries.find(r=>r.ref.blockId===t.blockId&&r.ref.name===t.name))==null?void 0:n.obj:p.mapPObjectData(this.ctx.getDataFromResultPoolByRef(t.blockId,t.name),r=>new y(r))}getSpecByRef(t){var n;return typeof this.ctx.getSpecFromResultPoolByRef>"u"?(n=this.getSpecs().entries.find(r=>r.ref.blockId===t.blockId&&r.ref.name===t.name))==null?void 0:n.obj:this.ctx.getSpecFromResultPoolByRef(t.blockId,t.name)}findDataWithCompatibleSpec(t){const n=[];t:for(const r of this.getData().entries){if(!p.isPColumnSpec(r.obj.spec))continue;const i=r.obj.spec;if(t.name===i.name&&t.valueType===i.valueType&&t.axesSpec.length===i.axesSpec.length&&D(t.domain,i.domain)){for(let s=0;s<t.axesSpec.length;++s){const u=t.axesSpec[s],a=i.axesSpec[s];if(u.name!==a.name||u.type!==a.type||!D(u.domain,a.domain))continue t}n.push(r.obj)}}return n}}function D(e,t){if(e===void 0)return t===void 0;if(t===void 0)return!0;for(const n in t)if(e[n]!==t[n])return!1;return!0}class _{constructor(){f(this,"ctx");f(this,"args");f(this,"uiState");f(this,"resultPool",new E);this.ctx=o(),this.args=JSON.parse(this.ctx.args),this.uiState=this.ctx.uiState!==void 0?JSON.parse(this.ctx.uiState):void 0}getNamedAccessor(t){const n=this.ctx.getAccessorHandleByName(t);return n?new y(n):void 0}get prerun(){return this.getNamedAccessor(x)}get precalc(){return this.prerun}get stagingOutput(){return this.precalc}get outputs(){return this.getNamedAccessor(T)}get mainOutput(){return this.outputs}createPFrame(t){return this.ctx.createPFrame(t.map(n=>p.mapPObjectData(n,r=>r.handle)))}createPTable(t){var n;return"columns"in t?n={src:{type:"inner",entries:t.columns.map(r=>({type:"column",column:r}))},filters:t.filters??[],sorting:t.sorting??[]}:n=t,this.ctx.createPTable(p.mapPTableDef(n,r=>p.mapPObjectData(r,i=>i.handle)))}getBlockLabel(t){return this.ctx.getBlockLabel(t)}getCurrentUnstableMarker(){if(!(typeof this.ctx.getCurrentUnstableMarker>"u"))return this.ctx.getCurrentUnstableMarker()}}const M="PColumnData/ResourceMap",B="PColumnData/Partitioned/ResourceMap";function U(e,t,n,r=[],i){if(e===void 0)return!1;switch(e.resourceType.name){case M:{let s=e.getInputsLocked();for(const u of e.listInputFields()){const a=e.resolve({field:u,assertFieldType:"Input"}),d=[...r,...JSON.parse(u)],l=a===void 0?void 0:t(a);l===void 0&&(s=!1),(l!==void 0||i)&&n.push({key:d,value:l})}return s}case B:{let s=e.getInputsLocked();for(const u of e.listInputFields()){const a=e.resolve({field:u,assertFieldType:"Input"});if(a===void 0)s=!1;else{const d=[...r,...JSON.parse(u)],l=U(a,t,n,d,i);s=s&&l}}return s}default:throw new Error(`Unknown resource type: ${e.resourceType.name}`)}}function At(e,t,n=!1){const r=[];return{isComplete:U(e,t,r,[],n),data:r}}const C="1.10.12";function J(e){return e.__renderLambda===!0}function F(e){if(e!==void 0)return J(e)?e.handle:e}function b(e){if(e!==void 0)return typeof e=="string"?{__renderLambda:!0,handle:e,retentive:!1}:e}function St(e){if(e.v3!==void 0){const{initialArgs:t,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:u,sections:a,title:d}=e.v3,{code:l}=e;return{initialArgs:t,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:u,sections:a,title:d,code:l}}else if(e.inputsValid!==void 0){const{sdkVersion:t,renderingMode:n,outputs:r,inputsValid:i,sections:s,initialArgs:u,code:a}=e,d=Object.keys(e);if(t===void 0||n===void 0||r===void 0||i===void 0||s===void 0||u===void 0)throw new Error(`Malformed config v2. SDK version ${t}; Fields = ${d.join(", ")}`);return{sdkVersion:t,renderingMode:n,initialArgs:u,outputs:Object.fromEntries(Object.entries(r).map(([l,m])=>[l,b(m)])),inputsValid:b(i),sections:b(s),initialUiState:void 0,code:a}}else if(e.renderingMode!==void 0){const{sdkVersion:t,canRun:n,renderingMode:r,outputs:i,sections:s,initialArgs:u,code:a}=e,d=Object.keys(e);if(r===void 0||i===void 0||n===void 0||s===void 0||u===void 0)throw new Error(`Malformed config v1. SDK version ${t}; Fields = ${d.join(", ")}`);return{sdkVersion:t??"unknown",renderingMode:r,initialArgs:u,outputs:Object.fromEntries(Object.entries(i).map(([l,m])=>[l,b(m)])),inputsValid:b(n),sections:b(s),initialUiState:void 0,code:a}}else{const{sdkVersion:t}=e,n=Object.keys(e);throw new Error(`Config format not supported: SDK = ${t}; Fields = ${n.join(", ")}`)}}class g{constructor(t,n,r,i,s,u,a){this._renderingMode=t,this._initialArgs=n,this._initialUiState=r,this._outputs=i,this._inputsValid=s,this._sections=u,this._title=a}static create(t="Heavy"){return new g(t,void 0,{},{},w(!0),w([]),void 0)}output(t,n,r={}){if(typeof n=="function"){const i=`output#${t}`;return S(i,()=>n(new _)),new g(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[t]:{__renderLambda:!0,handle:i,...r}},this._inputsValid,this._sections,this._title)}else return new g(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[t]:n},this._inputsValid,this._sections,this._title)}retentiveOutput(t,n){return this.output(t,n,{retentive:!0})}canRun(t){return this.inputsValid(t)}argsValid(t){return typeof t=="function"?(S("inputsValid",()=>t(new _)),new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,{__renderLambda:!0,handle:"inputsValid"},this._sections,this._title)):new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,t,this._sections,this._title)}inputsValid(t){return this.argsValid(t)}sections(t){return Array.isArray(t)?this.sections(w(t)):typeof t=="function"?(S("sections",()=>t(new _)),new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,{__renderLambda:!0,handle:"sections"},this._title)):new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,t,this._title)}title(t){return S("title",()=>t(new _)),new g(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,this._sections,{__renderLambda:!0,handle:"title"})}initialArgs(t){return new g(this._renderingMode,t,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withArgs(t){return new g(this._renderingMode,t,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withUiState(t){return new g(this._renderingMode,this._initialArgs,t,this._outputs,this._inputsValid,this._sections,this._title)}done(){if(this._initialArgs===void 0)throw new Error("Initial arguments not set.");const t={v3:{sdkVersion:C,renderingMode:this._renderingMode,initialArgs:this._initialArgs,initialUiState:this._initialUiState,inputsValid:this._inputsValid,sections:this._sections,title:this._title,outputs:this._outputs},sdkVersion:C,renderingMode:this._renderingMode,initialArgs:this._initialArgs,inputsValid:F(this._inputsValid),sections:F(this._sections),outputs:Object.fromEntries(Object.entries(this._outputs).map(([n,r])=>[n,F(r)]))};return bt()?L({sdkVersion:C}):{config:t}}}function Ft(e,t,n){var s,u;const r=e.resultPool.getData().entries.map(a=>a.obj).filter(p.isPColumn).filter(a=>a.spec.name==="pl7.app/label"&&a.spec.axesSpec.length===1),i=[];for(const a of t)for(const d of a.spec.axesSpec){const l=p.getAxisId(d);for(const m of r)p.matchAxisId(l,p.getAxisId(m.spec.axesSpec[0]))&&i.push(m)}return e.createPTable({columns:[...t,...i],filters:(s=n==null?void 0:n.pTableParams)==null?void 0:s.filters,sorting:(u=n==null?void 0:n.pTableParams)==null?void 0:u.sorting})}class Ot{constructor(t){this.handle=t}async findColumns(t){return await platforma.pFrameDriver.findColumns(this.handle,t)}async getColumnSpec(t){return await platforma.pFrameDriver.getColumnSpec(this.handle,t)}async listColumns(){return await platforma.pFrameDriver.listColumns(this.handle)}async calculateTableData(t){return await platforma.pFrameDriver.calculateTableData(this.handle,t)}async getUniqueValues(t){return await platforma.pFrameDriver.getUniqueValues(this.handle,t)}}function N(e){return R({__isRef:!0,blockId:A(e,"blockId"),name:A(e,"name")})}function Pt(e){return R({ref:N(A(e,"ref")),label:A(e,"label")})}const Rt={sdkVersion:C};function It(){return L({sdkVersion:C})}function Dt(e){if(typeof globalThis.getEnvironmentValue=="function")return globalThis.getEnvironmentValue(e)}exports.Args=W;exports.BlockModel=g;exports.CurrentSdkInfo=Rt;exports.FutureRef=h;exports.It=q;exports.JsRenderInternal=Ct;exports.MainOutputs=z;exports.OutputError=V;exports.PFrameImpl=Ot;exports.RenderCtx=_;exports.ResourceMapResourcePartitionedTypeName=B;exports.ResourceMapResourceTypeName=M;exports.ResultPool=E;exports.StagingOutputs=Q;exports.TreeNodeAccessor=y;exports.UiState=X;exports.and=it;exports.createPlDataTable=Ft;exports.downgradeCfgOrLambda=F;exports.extractConfig=St;exports.flatten=et;exports.fromPlOption=Pt;exports.fromPlRef=N;exports.getBlobContent=lt;exports.getBlobContentAsJson=dt;exports.getBlobContentAsString=ct;exports.getDownloadedBlobContent=pt;exports.getEnvironmentValue=Dt;exports.getFromCfg=v;exports.getImmediate=w;exports.getImportProgress=ht;exports.getJsonField=A;exports.getLastLogs=ft;exports.getLogHandle=yt;exports.getOnDemandBlobContent=gt;exports.getProgressLog=mt;exports.getRawPlatformaInstance=It;exports.getResourceField=ot;exports.getResourceValueAsJson=at;exports.isConfigLambda=J;exports.isEmpty=nt;exports.isolate=K;exports.makeArray=Y;exports.makeObject=R;exports.mapArrayValues=tt;exports.mapRecordValues=Z;exports.mapResourceFields=ut;exports.not=rt;exports.or=st;exports.parseResourceMap=At;exports.readOutput=k;exports.wrapOutputs=G;Object.keys(p).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>p[e]})});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|