@platforma-sdk/model 1.15.4 → 1.18.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.
- package/dist/components/PlDataTable.d.ts +5 -6
- package/dist/components/PlDataTable.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -30
- package/dist/index.mjs.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/PlDataTable.ts +6 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxisSpec, JoinEntry, PColumn, PColumnIdAndSpec, PTableHandle, PTableRecordFilter, PTableSorting } from '@milaboratories/pl-model-common';
|
|
2
2
|
import { RenderCtx, TreeNodeAccessor } from '../render';
|
|
3
3
|
/** Data table state */
|
|
4
4
|
export type PlDataTableGridState = {
|
|
@@ -26,10 +26,8 @@ export type PlDataTableGridState = {
|
|
|
26
26
|
sheets?: Record<string, string | number>;
|
|
27
27
|
};
|
|
28
28
|
export type PlDataTableSheet = {
|
|
29
|
-
/**
|
|
30
|
-
axis:
|
|
31
|
-
/** id of label column to use in filter instead of axis */
|
|
32
|
-
column?: PObjectId;
|
|
29
|
+
/** spec of the axis to use */
|
|
30
|
+
axis: AxisSpec;
|
|
33
31
|
/** options to show in the filter tan */
|
|
34
32
|
options: {
|
|
35
33
|
/** value of the option (should be one of the values in the axis or column) */
|
|
@@ -232,5 +230,6 @@ export type PlTableFiltersModel = {
|
|
|
232
230
|
* @returns
|
|
233
231
|
*/
|
|
234
232
|
export declare function createPlDataTable<A, U>(ctx: RenderCtx<A, U>, columns: PColumn<TreeNodeAccessor>[], tableState?: PlDataTableState, filters?: PTableRecordFilter[]): PTableHandle | undefined;
|
|
235
|
-
|
|
233
|
+
/** Create sheet entries for PlDataTable */
|
|
234
|
+
export declare function createPlDataTableSheet<A, U>(ctx: RenderCtx<A, U>, axis: AxisSpec, values: (string | number)[]): PlDataTableSheet;
|
|
236
235
|
//# sourceMappingURL=PlDataTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlDataTable.d.ts","sourceRoot":"","sources":["../../src/components/PlDataTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"PlDataTable.d.ts","sourceRoot":"","sources":["../../src/components/PlDataTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,SAAS,EAET,OAAO,EACP,gBAAgB,EAEhB,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAExD,uBAAuB;AACvB,MAAM,MAAM,oBAAoB,GAAG;IACjC,+BAA+B;IAC/B,WAAW,CAAC,EAAE;QACZ,0BAA0B;QAC1B,aAAa,EAAE,MAAM,EAAE,CAAC;KACzB,CAAC;IACF,kDAAkD;IAClD,IAAI,CAAC,EAAE;QACL,6CAA6C;QAC7C,SAAS,EAAE;YACT,sCAAsC;YACtC,KAAK,EAAE,MAAM,CAAC;YACd,qBAAqB;YACrB,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;SACtB,EAAE,CAAC;KACL,CAAC;IACF,iCAAiC;IACjC,gBAAgB,CAAC,EAAE;QACjB,mCAAmC;QACnC,YAAY,EAAE,MAAM,EAAE,CAAC;KACxB,CAAC;IAEF,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,8BAA8B;IAC9B,IAAI,EAAE,QAAQ,CAAC;IACf,wCAAwC;IACxC,OAAO,EAAE;QACP,8EAA8E;QAC9E,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QACvB,0BAA0B;QAC1B,KAAK,EAAE,MAAM,CAAC;KACf,EA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,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@milaboratories/pl-model-common"),R=require("zod");class te extends Error{constructor(e,n){super(`${e.length}${n?"+":""} errors, first error: `+e[0]),this.errors=e,this.moreErrors=n}}function ne(t){if(!t.ok)throw new te(t.errors,t.moreErrors);return t.value}function Pe(t){return new Proxy(t,{get(e,n){return ne(e[n])}})}function f(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null?C(t):t}function I(t){return{type:"GetFromCtx",variable:t}}function we(t){return{type:"Isolate",cfg:t}}const Ae=I("$args"),Se=I("$it"),Re=I("$prod"),Ie=I("$staging"),Te=I("$ui");function C(t){return{type:"Immediate",value:t}}function z(t){const e={};for(const[n,r]of Object.entries(t))e[n]=f(r);return{type:"MakeObject",template:e}}function Oe(...t){const e=[];for(const n of t)e.push(f(n));return{type:"MakeArray",template:e}}function D(t,e){return{type:"GetJsonField",source:f(t),field:f(e)}}function Ce(t,e,n="$it"){return{type:"MapRecordValues",source:t,mapping:e,itVar:n}}function Fe(t,e,n="$it"){return{type:"MapArrayValues",source:t,mapping:e,itVar:n}}function De(t){return{type:"Flatten",source:t}}function Ee(t){return{type:"IsEmpty",arg:t}}function Le(t){return{type:"Not",operand:t}}function ke(t,e){return{type:"And",operand1:t,operand2:e}}function xe(t,e){return{type:"Or",operand1:t,operand2:e}}function Ve(t,e){return{type:"GetResourceField",source:f(t),field:f(e)}}function je(){return function(t){return{type:"GetResourceValueAsJson",source:f(t)}}}function Ne(t,e,n="$it"){return{type:"MapResourceFields",source:t,mapping:e,itVar:n}}function Be(t){return{type:"GetBlobContent",source:f(t)}}function Me(t){return{type:"GetBlobContentAsString",source:f(t)}}function Ue(){return function(t){return{type:"GetBlobContentAsJson",source:f(t)}}}function Je(t){return{type:"GetDownloadedBlobContent",source:f(t)}}function $e(t){return{type:"GetOnDemandBlobContent",source:f(t)}}function Ke(t){return{type:"GetImportProgress",source:f(t)}}function Ge(t,e){return{type:"GetLastLogs",source:f(t),lines:e}}function He(t,e){return{type:"GetProgressLog",source:f(t),patternToSearch:e}}function We(t){return{type:"GetLogHandle",source:f(t)}}function ze(){return typeof globalThis.getPlatforma<"u"||typeof globalThis.platforma<"u"}function re(t){if(t&&typeof globalThis.getPlatforma=="function")return globalThis.getPlatforma(t);if(typeof globalThis.platforma<"u")return globalThis.platforma;throw new Error("Can't get platforma instance.")}function qe(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx}function u(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx;throw new Error("Not in config rendering context")}function k(t,e){const n=qe();if(n===void 0)return!1;if(t in n.callbackRegistry)throw new Error(`Callback with key ${t} already registered.`);return n.callbackRegistry[t]=e,!0}const $=new Map;function Ye(t,e){t in u().callbackRegistry||(u().callbackRegistry[t]=n=>{for(const r of $.get(t))r(n)},$.set(t,[])),$.get(t).push(e)}class m{constructor(e,n=r=>r){P(this,"isResolved",!1);P(this,"resolvedValue");this.handle=e,this.postProcess=n,Ye(e,r=>{this.resolvedValue=n(r),this.isResolved=!0})}map(e){return new m(this.handle,n=>e(this.postProcess(n)))}mapDefined(e){return new m(this.handle,n=>{const r=this.postProcess(n);return r?e(r):void 0})}toJSON(){return this.isResolved?this.resolvedValue:{__awaited_futures__:[this.handle]}}}function Q(t){return t===void 0?void 0:new A(t)}class A{constructor(e){this.handle=e}resolve(...e){const n=e.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveOutput(...e){const n=e.map(r=>({assertFieldType:"Output",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveInput(...e){const n=e.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveAny(...e){return this.resolveWithCommon({},...e)}resolveWithCommon(e,...n){return Q(u().resolveWithCommon(this.handle,e,...n))}get resourceType(){return u().getResourceType(this.handle)}getInputsLocked(){return u().getInputsLocked(this.handle)}getOutputsLocked(){return u().getOutputsLocked(this.handle)}getIsReadyOrError(){return u().getIsReadyOrError(this.handle)}getIsFinal(){return u().getIsFinal(this.handle)}getError(){return Q(u().getError(this.handle))}listInputFields(){return u().listInputFields(this.handle)}listOutputFields(){return u().listOutputFields(this.handle)}listDynamicFields(){return u().listDynamicFields(this.handle)}getKeyValueBase64(e){return u().getKeyValueBase64(this.handle,e)}getKeyValueAsString(e){return u().getKeyValueAsString(this.handle,e)}getKeyValueAsJson(e){const n=this.getKeyValueAsString(e);if(n==null)throw new Error("Resource has no content.");return JSON.parse(n)}getDataBase64(){return u().getDataBase64(this.handle)}getDataAsString(){return u().getDataAsString(this.handle)}getDataAsJson(){const e=this.getDataAsString();if(e==null)throw new Error("Resource has no content.");return JSON.parse(e)}getPColumns(e=!1,n=""){const r=this.parsePObjectCollection(e,n);return r===void 0?void 0:Object.entries(r).map(([,i])=>{if(!d.isPColumn(i))throw new Error(`not a PColumn (kind = ${i.spec.kind})`);return i})}parsePObjectCollection(e=!1,n=""){const r=u().parsePObjectCollection(this.handle,e,n);if(r===void 0)return;const s={};for(const[i,o]of Object.entries(r))s[i]=d.mapPObjectData(o,a=>new A(a));return s}getFileContentAsBase64(){return new m(u().getBlobContentAsBase64(this.handle))}getFileContentAsString(){return new m(u().getBlobContentAsString(this.handle))}getFileContentAsJson(){return new m(u().getBlobContentAsString(this.handle)).mapDefined(e=>JSON.parse(e))}getBlobContentAsBase64(){return this.getFileContentAsBase64()}getBlobContentAsString(){return this.getFileContentAsString()}getFileHandle(){return new m(u().getDownloadedBlobContentHandle(this.handle))}getDownloadedBlobHandle(){return this.getFileHandle()}getRemoteFileHandle(){return new m(u().getOnDemandBlobContentHandle(this.handle))}getOnDemandBlobHandle(){return this.getRemoteFileHandle()}getImportProgress(){return new m(u().getImportProgress(this.handle))}getLastLogs(e){return new m(u().getLastLogs(this.handle,e))}getProgressLog(e){return new m(u().getProgressLog(this.handle,e))}getLogHandle(){return new m(u().getLogHandle(this.handle))}allFieldsResolved(e="Input"){switch(e){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(e,n){const{fieldType:r,requireLocked:s,skipUnresolved:i}={fieldType:"Input",requireLocked:!0,skipUnresolved:!1,...n},o=e;if(s&&(r==="Input"&&!this.getInputsLocked()||r==="Output"&&!this.getOutputsLocked()))return;let l=(r==="Input"?this.listInputFields():r==="Output"?this.listOutputFields():this.listDynamicFields()).map(c=>[c,this.resolve({field:c,assertFieldType:r})]);return i&&(l=l.filter(c=>c[1]!==void 0)),l.map(([c,g])=>o(c,g))}}const se="staging",ie="main";function oe(t){return typeof t=="object"&&t!==null&&"__awaited_futures__"in t}function K(t,e,n){if(e.has(n))return;if(e.add(n),typeof n==="object")if(oe(n))n.__awaited_futures__.forEach(s=>t.add(s));else if(Array.isArray(n))for(const s of n)K(t,e,s);else for(const[,s]of Object.entries(n))s!==n&&K(t,e,s)}function Xe(t){const e=new Set;return K(e,new Set,t),e}const Qe=Object.freeze(Object.defineProperty({__proto__:null,MainAccessorName:ie,StagingAccessorName:se,getAllFutureAwaits:Xe,isFutureAwait:oe},Symbol.toStringTag,{value:"Module"})),ae="pl7.app/label",le="pl7.app/trace",ue=R.z.object({type:R.z.string(),importance:R.z.number().optional(),id:R.z.string().optional(),label:R.z.string()}),ce=R.z.array(ue),Ze=.001,et="__LABEL__",Z="__LABEL__@1";function de(t,e,n={}){const r=new Map,s=new Map,i=t.map(p=>{var Y,X;const y=e(p),b=(Y=y.annotations)==null?void 0:Y[ae],L=(X=y.annotations)==null?void 0:X[le],_=(L?ce.safeParse(JSON.parse(L)).data:void 0)??[];if(b){const v={label:b,type:et,importance:-2};n.addLabelAsSuffix?_.push(v):_.splice(0,0,v)}const M=[],q=new Map;for(let v=_.length-1;v>=0;--v){const{type:U}=_[v],be=_[v].importance??0,J=(q.get(U)??0)+1;q.set(U,J);const T=`${U}@${J}`;s.set(T,(s.get(T)??0)+1),r.set(T,Math.max(r.get(T)??Number.NEGATIVE_INFINITY,be-(_.length-v)*Ze)),M.push({..._[v],fullType:T,occurenceIndex:J})}return M.reverse(),{value:p,spec:y,label:b,fullTrace:M}}),o=[],a=[],l=[...r];l.sort(([,p],[,y])=>y-p);for(const[p]of l)p.endsWith("@1")||s.get(p)===t.length?o.push(p):a.push(p);const c=p=>i.map(y=>{const b=y.fullTrace.filter(_=>p.has(_.fullType)).map(_=>_.label),L=n.separator??" / ";return{label:b.join(L),value:y.value}});if(o.length===0){if(a.length!==0)throw new Error("Assertion error.");return c(new Set(Z))}let g=0,w=0;for(;g<o.length;){const p=new Set;n.includeNativeLabel&&p.add(Z);for(let b=0;b<g;++b)p.add(o[b]);p.add(o[w]);const y=c(p);if(new Set(y.map(b=>b.label)).size===t.length)return y;w++,w==o.length&&(g++,w=g)}return c(new Set([...o,...a]))}class pe{constructor(){P(this,"ctx",u());P(this,"defaultLabelFn",(e,n)=>{var r;return((r=e.annotations)==null?void 0:r["pl7.app/label"])??"Unlabelled"})}calculateOptions(e){return this.ctx.calculateOptions(e)}getOptions(e,n){const r=this.getSpecs().entries.filter(s=>e(s.obj));return typeof n=="object"||typeof n>"u"?de(r,s=>s.obj,n??{}).map(({value:{ref:s},label:i})=>({ref:s,label:i})):r.map(s=>({ref:s.ref,label:n(s.obj,s.ref)}))}getDataFromResultPool(){return this.getData()}getData(){const e=this.ctx.getDataFromResultPool();return{isComplete:e.isComplete,entries:e.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:new A(n.obj.data)}}))}}getDataWithErrorsFromResultPool(){return this.getDataWithErrors()}getDataWithErrors(){const e=this.ctx.getDataWithErrorsFromResultPool();return{isComplete:e.isComplete,entries:e.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:d.mapValueInVOE(n.obj.data,r=>new A(r))}}))}}getSpecsFromResultPool(){return this.getSpecs()}getSpecs(){return this.ctx.getSpecsFromResultPool()}getDataByRef(e){var n;return typeof this.ctx.getDataFromResultPoolByRef>"u"?(n=this.getData().entries.find(r=>r.ref.blockId===e.blockId&&r.ref.name===e.name))==null?void 0:n.obj:d.mapPObjectData(this.ctx.getDataFromResultPoolByRef(e.blockId,e.name),r=>new A(r))}getPColumnByRef(e){const n=this.getDataByRef(e);if(n)return d.ensurePColumn(n)}getSpecByRef(e){var n;return typeof this.ctx.getSpecFromResultPoolByRef>"u"?(n=this.getSpecs().entries.find(r=>r.ref.blockId===e.blockId&&r.ref.name===e.name))==null?void 0:n.obj:this.ctx.getSpecFromResultPoolByRef(e.blockId,e.name)}findDataWithCompatibleSpec(e){const n=[];e:for(const r of this.getData().entries){if(!d.isPColumnSpec(r.obj.spec))continue;const s=r.obj.spec;if(e.name===s.name&&e.valueType===s.valueType&&e.axesSpec.length===s.axesSpec.length&&G(e.domain,s.domain)){for(let i=0;i<e.axesSpec.length;++i){const o=e.axesSpec[i],a=s.axesSpec[i];if(o.name!==a.name||o.type!==a.type||!G(o.domain,a.domain))continue e}n.push(r.obj)}}return n}}function G(t,e){if(t===void 0)return e===void 0;if(e===void 0)return!0;for(const n in e)if(t[n]!==e[n])return!1;return!0}class O{constructor(){P(this,"ctx");P(this,"args");P(this,"uiState");P(this,"resultPool",new pe);this.ctx=u(),this.args=JSON.parse(this.ctx.args),this.uiState=this.ctx.uiState!==void 0?JSON.parse(this.ctx.uiState):void 0}getNamedAccessor(e){const n=this.ctx.getAccessorHandleByName(e);return n?new A(n):void 0}get prerun(){return this.getNamedAccessor(se)}get precalc(){return this.prerun}get stagingOutput(){return this.precalc}get outputs(){return this.getNamedAccessor(ie)}get mainOutput(){return this.outputs}findLabels(e){const n=this.resultPool.getData();for(const r of n.entries){if(!d.isPColumn(r.obj))continue;const s=r.obj.spec;if(s.name==="pl7.app/label"&&s.axesSpec.length===1&&s.axesSpec[0].name===e.name&&s.axesSpec[0].type===e.type&&G(e.domain,s.axesSpec[0].domain)){if(r.obj.data.resourceType.name!=="PColumnData/Json")throw Error(`Expected JSON column for labels, got: ${r.obj.data.resourceType.name}`);return new Map(Object.entries(r.obj.data.getDataAsJson().data).map(o=>[JSON.parse(o[0])[0],o[1]]))}}}createPFrame(e){return this.ctx.createPFrame(e.map(n=>d.mapPObjectData(n,r=>r.handle)))}createPTable(e){var n;return"columns"in e?n={src:{type:"full",entries:e.columns.map(r=>({type:"column",column:r}))},filters:e.filters??[],sorting:e.sorting??[]}:n=e,this.ctx.createPTable(d.mapPTableDef(n,r=>d.mapPObjectData(r,s=>s.handle)))}getBlockLabel(e){return this.ctx.getBlockLabel(e)}getCurrentUnstableMarker(){if(!(typeof this.ctx.getCurrentUnstableMarker>"u"))return this.ctx.getCurrentUnstableMarker()}}const E="PColumnData/",N=E+"ResourceMap",B=E+"Partitioned/ResourceMap",H=E+"JsonPartitioned",x=E+"BinaryPartitioned",fe=E+"Partitioned/",W=fe+"JsonPartitioned",V=fe+"BinaryPartitioned";function ge(t,e,n,r=[],s){if(t===void 0)return!1;switch(t.resourceType.name){case N:{let i=t.getInputsLocked();for(const o of t.listInputFields()){const a=t.resolve({field:o,assertFieldType:"Input"}),l=[...r,...JSON.parse(o)],c=a===void 0?void 0:e(a);c===void 0&&(i=!1),(c!==void 0||s)&&n.push({key:l,value:c})}return i}case B:{let i=t.getInputsLocked();for(const o of t.listInputFields()){const a=t.resolve({field:o,assertFieldType:"Input"});if(a===void 0)i=!1;else{const l=[...r,...JSON.parse(o)],c=ge(a,e,n,l,s);i=i&&c}}return i}default:throw new Error(`Unknown resource type: ${t.resourceType.name}`)}}function tt(t,e,n=!1){const r=[];return{isComplete:ge(t,e,r,[],n),data:r}}const ee=t=>{if(!t.endsWith(".index")){if(t.endsWith(".values"))return t.substring(0,t.length-7);throw Error(`key must ends on .index/.values for binary p-column, got: ${t}`)}};function he(t){if(!t)return;const e=t.resourceType.name,n=t.getDataAsJson(),r=[];let s=0;switch(e){case N:s=n.keyLength;break;case B:s=n.partitionKeyLength+n.keyLength;break;case H:case x:s=n.partitionKeyLength;break;case V:case W:s=n.superPartitionKeyLength+n.partitionKeyLength;break}switch(e){case N:case H:case x:for(let i of t.listInputFields()){if(e===x){const a=ee(i);if(a)i=a;else continue}const o=[...JSON.parse(i)];r.push(o)}break;case B:case V:case W:for(const i of t.listInputFields()){const o=[...JSON.parse(i)],a=t.resolve({field:i,assertFieldType:"Input"});if(a!==void 0)for(let l of a.listInputFields()){if(e===V){const g=ee(l);if(g)l=g;else continue}const c=[...o,...JSON.parse(l)];r.push(c)}}break}return{data:r,keyLength:s}}function nt(t){const e=he(t);if(!e)return;const{data:n,keyLength:r}=e,s=[];for(let i=0;i<r;++i)s.push(new Set);for(const i of n){if(i.length!==r)throw new Error("key length does not match partition length");for(let o=0;o<r;++o)s[o].add(i[o])}return s.map(i=>Array.from(i.values()))}const F="1.15.4";function me(t){return t.__renderLambda===!0}function j(t){if(t!==void 0)return me(t)?t.handle:t}function S(t){if(t!==void 0)return typeof t=="string"?{__renderLambda:!0,handle:t,retentive:!1}:t}function rt(t){if(t.v3!==void 0){const{initialArgs:e,initialUiState:n,inputsValid:r,outputs:s,renderingMode:i,sdkVersion:o,sections:a,title:l}=t.v3,{code:c}=t;return{initialArgs:e,initialUiState:n,inputsValid:r,outputs:s,renderingMode:i,sdkVersion:o,sections:a,title:l,code:c}}else if(t.inputsValid!==void 0){const{sdkVersion:e,renderingMode:n,outputs:r,inputsValid:s,sections:i,initialArgs:o,code:a}=t,l=Object.keys(t);if(e===void 0||n===void 0||r===void 0||s===void 0||i===void 0||o===void 0)throw new Error(`Malformed config v2. SDK version ${e}; Fields = ${l.join(", ")}`);return{sdkVersion:e,renderingMode:n,initialArgs:o,outputs:Object.fromEntries(Object.entries(r).map(([c,g])=>[c,S(g)])),inputsValid:S(s),sections:S(i),initialUiState:void 0,code:a}}else if(t.renderingMode!==void 0){const{sdkVersion:e,canRun:n,renderingMode:r,outputs:s,sections:i,initialArgs:o,code:a}=t,l=Object.keys(t);if(r===void 0||s===void 0||n===void 0||i===void 0||o===void 0)throw new Error(`Malformed config v1. SDK version ${e}; Fields = ${l.join(", ")}`);return{sdkVersion:e??"unknown",renderingMode:r,initialArgs:o,outputs:Object.fromEntries(Object.entries(s).map(([c,g])=>[c,S(g)])),inputsValid:S(n),sections:S(i),initialUiState:void 0,code:a}}else{const{sdkVersion:e}=t,n=Object.keys(t);throw new Error(`Config format not supported: SDK = ${e}; Fields = ${n.join(", ")}`)}}class h{constructor(e,n,r,s,i,o,a){this._renderingMode=e,this._initialArgs=n,this._initialUiState=r,this._outputs=s,this._inputsValid=i,this._sections=o,this._title=a}static create(e="Heavy"){return new h(e,void 0,{},{},C(!0),C([]),void 0)}output(e,n,r={}){if(typeof n=="function"){const s=`output#${e}`;return k(s,()=>n(new O)),new h(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[e]:{__renderLambda:!0,handle:s,...r}},this._inputsValid,this._sections,this._title)}else return new h(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[e]:n},this._inputsValid,this._sections,this._title)}retentiveOutput(e,n){return this.output(e,n,{retentive:!0})}canRun(e){return this.inputsValid(e)}argsValid(e){return typeof e=="function"?(k("inputsValid",()=>e(new O)),new h(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,{__renderLambda:!0,handle:"inputsValid"},this._sections,this._title)):new h(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,e,this._sections,this._title)}inputsValid(e){return this.argsValid(e)}sections(e){return Array.isArray(e)?this.sections(C(e)):typeof e=="function"?(k("sections",()=>e(new O)),new h(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,{__renderLambda:!0,handle:"sections"},this._title)):new h(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,e,this._title)}title(e){return k("title",()=>e(new O)),new h(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,this._sections,{__renderLambda:!0,handle:"title"})}initialArgs(e){return new h(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withArgs(e){return new h(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withUiState(e){return new h(this._renderingMode,this._initialArgs,e,this._outputs,this._inputsValid,this._sections,this._title)}done(){if(this._initialArgs===void 0)throw new Error("Initial arguments not set.");const e={v3:{sdkVersion:F,renderingMode:this._renderingMode,initialArgs:this._initialArgs,initialUiState:this._initialUiState,inputsValid:this._inputsValid,sections:this._sections,title:this._title,outputs:this._outputs},sdkVersion:F,renderingMode:this._renderingMode,initialArgs:this._initialArgs,inputsValid:j(this._inputsValid),sections:j(this._sections),outputs:Object.fromEntries(Object.entries(this._outputs).map(([n,r])=>[n,j(r)]))};return ze()?re({sdkVersion:F}):{config:e}}}function st(t,e,n,r){var o,a;const s=t.resultPool.getData().entries.map(l=>l.obj).filter(d.isPColumn).filter(l=>l.spec.name==="pl7.app/label"&&l.spec.axesSpec.length===1),i=new Map;for(const l of e)for(const c of l.spec.axesSpec){const g=d.getAxisId(c);for(const w of s)d.matchAxisId(g,d.getAxisId(w.spec.axesSpec[0]))&&i.set(w.id,w)}if(![...e,...i.values()].find(l=>!l.data.getIsReadyOrError()))return t.createPTable({src:{type:"outer",primary:{type:"full",entries:e.map(l=>({type:"column",column:l}))},secondary:Array.from(i.values()).map(l=>({type:"column",column:l}))},filters:[...((o=n==null?void 0:n.pTableParams)==null?void 0:o.filters)??[],...r??[]],sorting:((a=n==null?void 0:n.pTableParams)==null?void 0:a.sorting)??[]})}function it(t,e,n){const r=t.findLabels(e);return{axis:d.getAxisId(e),options:n.map(s=>({value:s,label:(r==null?void 0:r.get(s))??s.toString()})),defaultValue:n[0]}}class ot{constructor(e){this.handle=e}async findColumns(e){return await platforma.pFrameDriver.findColumns(this.handle,e)}async getColumnSpec(e){return await platforma.pFrameDriver.getColumnSpec(this.handle,e)}async listColumns(){return await platforma.pFrameDriver.listColumns(this.handle)}async calculateTableData(e){return await platforma.pFrameDriver.calculateTableData(this.handle,e)}async getUniqueValues(e){return await platforma.pFrameDriver.getUniqueValues(this.handle,e)}}function ye(t){return z({__isRef:!0,blockId:D(t,"blockId"),name:D(t,"name")})}function at(t){return z({ref:ye(D(t,"ref")),label:D(t,"label")})}const lt={sdkVersion:F};function ut(){return re({sdkVersion:F})}function ct(t){if(typeof globalThis.getEnvironmentValue=="function")return globalThis.getEnvironmentValue(t)}exports.Args=Ae;exports.BlockModel=h;exports.CurrentSdkInfo=lt;exports.FutureRef=m;exports.It=Se;exports.JsRenderInternal=Qe;exports.MainOutputs=Re;exports.OutputError=te;exports.PAnnotationLabel=ae;exports.PAnnotationTrace=le;exports.PFrameImpl=ot;exports.RT_BINARY_PARTITIONED=x;exports.RT_BINARY_SUPER_PARTITIONED=V;exports.RT_JSON_PARTITIONED=H;exports.RT_JSON_SUPER_PARTITIONED=W;exports.RT_RESOURCE_MAP=N;exports.RT_RESOURCE_MAP_PARTITIONED=B;exports.RenderCtx=O;exports.ResultPool=pe;exports.StagingOutputs=Ie;exports.Trace=ce;exports.TraceEntry=ue;exports.TreeNodeAccessor=A;exports.UiState=Te;exports.and=ke;exports.createPlDataTable=st;exports.createPlDataTableSheet=it;exports.deriveLabels=de;exports.downgradeCfgOrLambda=j;exports.extractConfig=rt;exports.flatten=De;exports.fromPlOption=at;exports.fromPlRef=ye;exports.getBlobContent=Be;exports.getBlobContentAsJson=Ue;exports.getBlobContentAsString=Me;exports.getDownloadedBlobContent=Je;exports.getEnvironmentValue=ct;exports.getFromCfg=I;exports.getImmediate=C;exports.getImportProgress=Ke;exports.getJsonField=D;exports.getLastLogs=Ge;exports.getLogHandle=We;exports.getOnDemandBlobContent=$e;exports.getPartitionKeysList=he;exports.getProgressLog=He;exports.getRawPlatformaInstance=ut;exports.getResourceField=Ve;exports.getResourceValueAsJson=je;exports.getUniquePartitionKeys=nt;exports.isConfigLambda=me;exports.isEmpty=Ee;exports.isolate=we;exports.makeArray=Oe;exports.makeObject=z;exports.mapArrayValues=Fe;exports.mapRecordValues=Ce;exports.mapResourceFields=Ne;exports.not=Le;exports.or=xe;exports.parseResourceMap=tt;exports.readOutput=ne;exports.wrapOutputs=Pe;Object.keys(d).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>d[t]})});
|
|
1
|
+
"use strict";var _e=Object.defineProperty;var ve=(t,e,n)=>e in t?_e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var P=(t,e,n)=>ve(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@milaboratories/pl-model-common"),R=require("zod");class te extends Error{constructor(e,n){super(`${e.length}${n?"+":""} errors, first error: `+e[0]),this.errors=e,this.moreErrors=n}}function ne(t){if(!t.ok)throw new te(t.errors,t.moreErrors);return t.value}function Pe(t){return new Proxy(t,{get(e,n){return ne(e[n])}})}function f(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null?C(t):t}function T(t){return{type:"GetFromCtx",variable:t}}function we(t){return{type:"Isolate",cfg:t}}const Se=T("$args"),Ae=T("$it"),Re=T("$prod"),Te=T("$staging"),Ie=T("$ui");function C(t){return{type:"Immediate",value:t}}function z(t){const e={};for(const[n,r]of Object.entries(t))e[n]=f(r);return{type:"MakeObject",template:e}}function Oe(...t){const e=[];for(const n of t)e.push(f(n));return{type:"MakeArray",template:e}}function D(t,e){return{type:"GetJsonField",source:f(t),field:f(e)}}function Ce(t,e,n="$it"){return{type:"MapRecordValues",source:t,mapping:e,itVar:n}}function Fe(t,e,n="$it"){return{type:"MapArrayValues",source:t,mapping:e,itVar:n}}function De(t){return{type:"Flatten",source:t}}function Ee(t){return{type:"IsEmpty",arg:t}}function Le(t){return{type:"Not",operand:t}}function ke(t,e){return{type:"And",operand1:t,operand2:e}}function Ve(t,e){return{type:"Or",operand1:t,operand2:e}}function xe(t,e){return{type:"GetResourceField",source:f(t),field:f(e)}}function je(){return function(t){return{type:"GetResourceValueAsJson",source:f(t)}}}function Ne(t,e,n="$it"){return{type:"MapResourceFields",source:t,mapping:e,itVar:n}}function Be(t){return{type:"GetBlobContent",source:f(t)}}function Me(t){return{type:"GetBlobContentAsString",source:f(t)}}function Ue(){return function(t){return{type:"GetBlobContentAsJson",source:f(t)}}}function Je(t){return{type:"GetDownloadedBlobContent",source:f(t)}}function $e(t){return{type:"GetOnDemandBlobContent",source:f(t)}}function Ke(t){return{type:"GetImportProgress",source:f(t)}}function Ge(t,e){return{type:"GetLastLogs",source:f(t),lines:e}}function He(t,e){return{type:"GetProgressLog",source:f(t),patternToSearch:e}}function We(t){return{type:"GetLogHandle",source:f(t)}}function ze(){return typeof globalThis.getPlatforma<"u"||typeof globalThis.platforma<"u"}function re(t){if(t&&typeof globalThis.getPlatforma=="function")return globalThis.getPlatforma(t);if(typeof globalThis.platforma<"u")return globalThis.platforma;throw new Error("Can't get platforma instance.")}function qe(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx}function u(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx;throw new Error("Not in config rendering context")}function k(t,e){const n=qe();if(n===void 0)return!1;if(t in n.callbackRegistry)throw new Error(`Callback with key ${t} already registered.`);return n.callbackRegistry[t]=e,!0}const $=new Map;function Ye(t,e){t in u().callbackRegistry||(u().callbackRegistry[t]=n=>{for(const r of $.get(t))r(n)},$.set(t,[])),$.get(t).push(e)}class m{constructor(e,n=r=>r){P(this,"isResolved",!1);P(this,"resolvedValue");this.handle=e,this.postProcess=n,Ye(e,r=>{this.resolvedValue=n(r),this.isResolved=!0})}map(e){return new m(this.handle,n=>e(this.postProcess(n)))}mapDefined(e){return new m(this.handle,n=>{const r=this.postProcess(n);return r?e(r):void 0})}toJSON(){return this.isResolved?this.resolvedValue:{__awaited_futures__:[this.handle]}}}function Q(t){return t===void 0?void 0:new S(t)}class S{constructor(e){this.handle=e}resolve(...e){const n=e.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveOutput(...e){const n=e.map(r=>({assertFieldType:"Output",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveInput(...e){const n=e.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveAny(...e){return this.resolveWithCommon({},...e)}resolveWithCommon(e,...n){return Q(u().resolveWithCommon(this.handle,e,...n))}get resourceType(){return u().getResourceType(this.handle)}getInputsLocked(){return u().getInputsLocked(this.handle)}getOutputsLocked(){return u().getOutputsLocked(this.handle)}getIsReadyOrError(){return u().getIsReadyOrError(this.handle)}getIsFinal(){return u().getIsFinal(this.handle)}getError(){return Q(u().getError(this.handle))}listInputFields(){return u().listInputFields(this.handle)}listOutputFields(){return u().listOutputFields(this.handle)}listDynamicFields(){return u().listDynamicFields(this.handle)}getKeyValueBase64(e){return u().getKeyValueBase64(this.handle,e)}getKeyValueAsString(e){return u().getKeyValueAsString(this.handle,e)}getKeyValueAsJson(e){const n=this.getKeyValueAsString(e);if(n==null)throw new Error("Resource has no content.");return JSON.parse(n)}getDataBase64(){return u().getDataBase64(this.handle)}getDataAsString(){return u().getDataAsString(this.handle)}getDataAsJson(){const e=this.getDataAsString();if(e==null)throw new Error("Resource has no content.");return JSON.parse(e)}getPColumns(e=!1,n=""){const r=this.parsePObjectCollection(e,n);return r===void 0?void 0:Object.entries(r).map(([,i])=>{if(!p.isPColumn(i))throw new Error(`not a PColumn (kind = ${i.spec.kind})`);return i})}parsePObjectCollection(e=!1,n=""){const r=u().parsePObjectCollection(this.handle,e,n);if(r===void 0)return;const s={};for(const[i,o]of Object.entries(r))s[i]=p.mapPObjectData(o,a=>new S(a));return s}getFileContentAsBase64(){return new m(u().getBlobContentAsBase64(this.handle))}getFileContentAsString(){return new m(u().getBlobContentAsString(this.handle))}getFileContentAsJson(){return new m(u().getBlobContentAsString(this.handle)).mapDefined(e=>JSON.parse(e))}getBlobContentAsBase64(){return this.getFileContentAsBase64()}getBlobContentAsString(){return this.getFileContentAsString()}getFileHandle(){return new m(u().getDownloadedBlobContentHandle(this.handle))}getDownloadedBlobHandle(){return this.getFileHandle()}getRemoteFileHandle(){return new m(u().getOnDemandBlobContentHandle(this.handle))}getOnDemandBlobHandle(){return this.getRemoteFileHandle()}getImportProgress(){return new m(u().getImportProgress(this.handle))}getLastLogs(e){return new m(u().getLastLogs(this.handle,e))}getProgressLog(e){return new m(u().getProgressLog(this.handle,e))}getLogHandle(){return new m(u().getLogHandle(this.handle))}allFieldsResolved(e="Input"){switch(e){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(e,n){const{fieldType:r,requireLocked:s,skipUnresolved:i}={fieldType:"Input",requireLocked:!0,skipUnresolved:!1,...n},o=e;if(s&&(r==="Input"&&!this.getInputsLocked()||r==="Output"&&!this.getOutputsLocked()))return;let l=(r==="Input"?this.listInputFields():r==="Output"?this.listOutputFields():this.listDynamicFields()).map(c=>[c,this.resolve({field:c,assertFieldType:r})]);return i&&(l=l.filter(c=>c[1]!==void 0)),l.map(([c,g])=>o(c,g))}}const se="staging",ie="main";function oe(t){return typeof t=="object"&&t!==null&&"__awaited_futures__"in t}function K(t,e,n){if(e.has(n))return;if(e.add(n),typeof n==="object")if(oe(n))n.__awaited_futures__.forEach(s=>t.add(s));else if(Array.isArray(n))for(const s of n)K(t,e,s);else for(const[,s]of Object.entries(n))s!==n&&K(t,e,s)}function Xe(t){const e=new Set;return K(e,new Set,t),e}const Qe=Object.freeze(Object.defineProperty({__proto__:null,MainAccessorName:ie,StagingAccessorName:se,getAllFutureAwaits:Xe,isFutureAwait:oe},Symbol.toStringTag,{value:"Module"})),ae="pl7.app/label",le="pl7.app/trace",ue=R.z.object({type:R.z.string(),importance:R.z.number().optional(),id:R.z.string().optional(),label:R.z.string()}),ce=R.z.array(ue),Ze=.001,et="__LABEL__",Z="__LABEL__@1";function de(t,e,n={}){const r=new Map,s=new Map,i=t.map(d=>{var Y,X;const y=e(d),b=(Y=y.annotations)==null?void 0:Y[ae],L=(X=y.annotations)==null?void 0:X[le],_=(L?ce.safeParse(JSON.parse(L)).data:void 0)??[];if(b){const v={label:b,type:et,importance:-2};n.addLabelAsSuffix?_.push(v):_.splice(0,0,v)}const M=[],q=new Map;for(let v=_.length-1;v>=0;--v){const{type:U}=_[v],be=_[v].importance??0,J=(q.get(U)??0)+1;q.set(U,J);const I=`${U}@${J}`;s.set(I,(s.get(I)??0)+1),r.set(I,Math.max(r.get(I)??Number.NEGATIVE_INFINITY,be-(_.length-v)*Ze)),M.push({..._[v],fullType:I,occurenceIndex:J})}return M.reverse(),{value:d,spec:y,label:b,fullTrace:M}}),o=[],a=[],l=[...r];l.sort(([,d],[,y])=>y-d);for(const[d]of l)d.endsWith("@1")||s.get(d)===t.length?o.push(d):a.push(d);const c=d=>i.map(y=>{const b=y.fullTrace.filter(_=>d.has(_.fullType)).map(_=>_.label),L=n.separator??" / ";return{label:b.join(L),value:y.value}});if(o.length===0){if(a.length!==0)throw new Error("Assertion error.");return c(new Set(Z))}let g=0,w=0;for(;g<o.length;){const d=new Set;n.includeNativeLabel&&d.add(Z);for(let b=0;b<g;++b)d.add(o[b]);d.add(o[w]);const y=c(d);if(new Set(y.map(b=>b.label)).size===t.length)return y;w++,w==o.length&&(g++,w=g)}return c(new Set([...o,...a]))}class pe{constructor(){P(this,"ctx",u());P(this,"defaultLabelFn",(e,n)=>{var r;return((r=e.annotations)==null?void 0:r["pl7.app/label"])??"Unlabelled"})}calculateOptions(e){return this.ctx.calculateOptions(e)}getOptions(e,n){const r=this.getSpecs().entries.filter(s=>e(s.obj));return typeof n=="object"||typeof n>"u"?de(r,s=>s.obj,n??{}).map(({value:{ref:s},label:i})=>({ref:s,label:i})):r.map(s=>({ref:s.ref,label:n(s.obj,s.ref)}))}getDataFromResultPool(){return this.getData()}getData(){const e=this.ctx.getDataFromResultPool();return{isComplete:e.isComplete,entries:e.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:new S(n.obj.data)}}))}}getDataWithErrorsFromResultPool(){return this.getDataWithErrors()}getDataWithErrors(){const e=this.ctx.getDataWithErrorsFromResultPool();return{isComplete:e.isComplete,entries:e.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:p.mapValueInVOE(n.obj.data,r=>new S(r))}}))}}getSpecsFromResultPool(){return this.getSpecs()}getSpecs(){return this.ctx.getSpecsFromResultPool()}getDataByRef(e){var n;return typeof this.ctx.getDataFromResultPoolByRef>"u"?(n=this.getData().entries.find(r=>r.ref.blockId===e.blockId&&r.ref.name===e.name))==null?void 0:n.obj:p.mapPObjectData(this.ctx.getDataFromResultPoolByRef(e.blockId,e.name),r=>new S(r))}getPColumnByRef(e){const n=this.getDataByRef(e);if(n)return p.ensurePColumn(n)}getSpecByRef(e){var n;return typeof this.ctx.getSpecFromResultPoolByRef>"u"?(n=this.getSpecs().entries.find(r=>r.ref.blockId===e.blockId&&r.ref.name===e.name))==null?void 0:n.obj:this.ctx.getSpecFromResultPoolByRef(e.blockId,e.name)}findDataWithCompatibleSpec(e){const n=[];e:for(const r of this.getData().entries){if(!p.isPColumnSpec(r.obj.spec))continue;const s=r.obj.spec;if(e.name===s.name&&e.valueType===s.valueType&&e.axesSpec.length===s.axesSpec.length&&G(e.domain,s.domain)){for(let i=0;i<e.axesSpec.length;++i){const o=e.axesSpec[i],a=s.axesSpec[i];if(o.name!==a.name||o.type!==a.type||!G(o.domain,a.domain))continue e}n.push(r.obj)}}return n}}function G(t,e){if(t===void 0)return e===void 0;if(e===void 0)return!0;for(const n in e)if(t[n]!==e[n])return!1;return!0}class O{constructor(){P(this,"ctx");P(this,"args");P(this,"uiState");P(this,"resultPool",new pe);this.ctx=u(),this.args=JSON.parse(this.ctx.args),this.uiState=this.ctx.uiState!==void 0?JSON.parse(this.ctx.uiState):void 0}getNamedAccessor(e){const n=this.ctx.getAccessorHandleByName(e);return n?new S(n):void 0}get prerun(){return this.getNamedAccessor(se)}get precalc(){return this.prerun}get stagingOutput(){return this.precalc}get outputs(){return this.getNamedAccessor(ie)}get mainOutput(){return this.outputs}findLabels(e){const n=this.resultPool.getData();for(const r of n.entries){if(!p.isPColumn(r.obj))continue;const s=r.obj.spec;if(s.name==="pl7.app/label"&&s.axesSpec.length===1&&s.axesSpec[0].name===e.name&&s.axesSpec[0].type===e.type&&G(e.domain,s.axesSpec[0].domain)){if(r.obj.data.resourceType.name!=="PColumnData/Json")throw Error(`Expected JSON column for labels, got: ${r.obj.data.resourceType.name}`);return new Map(Object.entries(r.obj.data.getDataAsJson().data).map(o=>[JSON.parse(o[0])[0],o[1]]))}}}createPFrame(e){return this.ctx.createPFrame(e.map(n=>p.mapPObjectData(n,r=>r.handle)))}createPTable(e){var n;return"columns"in e?n={src:{type:"full",entries:e.columns.map(r=>({type:"column",column:r}))},filters:e.filters??[],sorting:e.sorting??[]}:n=e,this.ctx.createPTable(p.mapPTableDef(n,r=>p.mapPObjectData(r,s=>s.handle)))}getBlockLabel(e){return this.ctx.getBlockLabel(e)}getCurrentUnstableMarker(){if(!(typeof this.ctx.getCurrentUnstableMarker>"u"))return this.ctx.getCurrentUnstableMarker()}}const E="PColumnData/",N=E+"ResourceMap",B=E+"Partitioned/ResourceMap",H=E+"JsonPartitioned",V=E+"BinaryPartitioned",fe=E+"Partitioned/",W=fe+"JsonPartitioned",x=fe+"BinaryPartitioned";function ge(t,e,n,r=[],s){if(t===void 0)return!1;switch(t.resourceType.name){case N:{let i=t.getInputsLocked();for(const o of t.listInputFields()){const a=t.resolve({field:o,assertFieldType:"Input"}),l=[...r,...JSON.parse(o)],c=a===void 0?void 0:e(a);c===void 0&&(i=!1),(c!==void 0||s)&&n.push({key:l,value:c})}return i}case B:{let i=t.getInputsLocked();for(const o of t.listInputFields()){const a=t.resolve({field:o,assertFieldType:"Input"});if(a===void 0)i=!1;else{const l=[...r,...JSON.parse(o)],c=ge(a,e,n,l,s);i=i&&c}}return i}default:throw new Error(`Unknown resource type: ${t.resourceType.name}`)}}function tt(t,e,n=!1){const r=[];return{isComplete:ge(t,e,r,[],n),data:r}}const ee=t=>{if(!t.endsWith(".index")){if(t.endsWith(".values"))return t.substring(0,t.length-7);throw Error(`key must ends on .index/.values for binary p-column, got: ${t}`)}};function he(t){if(!t)return;const e=t.resourceType.name,n=t.getDataAsJson(),r=[];let s=0;switch(e){case N:s=n.keyLength;break;case B:s=n.partitionKeyLength+n.keyLength;break;case H:case V:s=n.partitionKeyLength;break;case x:case W:s=n.superPartitionKeyLength+n.partitionKeyLength;break}switch(e){case N:case H:case V:for(let i of t.listInputFields()){if(e===V){const a=ee(i);if(a)i=a;else continue}const o=[...JSON.parse(i)];r.push(o)}break;case B:case x:case W:for(const i of t.listInputFields()){const o=[...JSON.parse(i)],a=t.resolve({field:i,assertFieldType:"Input"});if(a!==void 0)for(let l of a.listInputFields()){if(e===x){const g=ee(l);if(g)l=g;else continue}const c=[...o,...JSON.parse(l)];r.push(c)}}break}return{data:r,keyLength:s}}function nt(t){const e=he(t);if(!e)return;const{data:n,keyLength:r}=e,s=[];for(let i=0;i<r;++i)s.push(new Set);for(const i of n){if(i.length!==r)throw new Error("key length does not match partition length");for(let o=0;o<r;++o)s[o].add(i[o])}return s.map(i=>Array.from(i.values()))}const F="1.18.0";function me(t){return t.__renderLambda===!0}function j(t){if(t!==void 0)return me(t)?t.handle:t}function A(t){if(t!==void 0)return typeof t=="string"?{__renderLambda:!0,handle:t,retentive:!1}:t}function rt(t){if(t.v3!==void 0){const{initialArgs:e,initialUiState:n,inputsValid:r,outputs:s,renderingMode:i,sdkVersion:o,sections:a,title:l}=t.v3,{code:c}=t;return{initialArgs:e,initialUiState:n,inputsValid:r,outputs:s,renderingMode:i,sdkVersion:o,sections:a,title:l,code:c}}else if(t.inputsValid!==void 0){const{sdkVersion:e,renderingMode:n,outputs:r,inputsValid:s,sections:i,initialArgs:o,code:a}=t,l=Object.keys(t);if(e===void 0||n===void 0||r===void 0||s===void 0||i===void 0||o===void 0)throw new Error(`Malformed config v2. SDK version ${e}; Fields = ${l.join(", ")}`);return{sdkVersion:e,renderingMode:n,initialArgs:o,outputs:Object.fromEntries(Object.entries(r).map(([c,g])=>[c,A(g)])),inputsValid:A(s),sections:A(i),initialUiState:void 0,code:a}}else if(t.renderingMode!==void 0){const{sdkVersion:e,canRun:n,renderingMode:r,outputs:s,sections:i,initialArgs:o,code:a}=t,l=Object.keys(t);if(r===void 0||s===void 0||n===void 0||i===void 0||o===void 0)throw new Error(`Malformed config v1. SDK version ${e}; Fields = ${l.join(", ")}`);return{sdkVersion:e??"unknown",renderingMode:r,initialArgs:o,outputs:Object.fromEntries(Object.entries(s).map(([c,g])=>[c,A(g)])),inputsValid:A(n),sections:A(i),initialUiState:void 0,code:a}}else{const{sdkVersion:e}=t,n=Object.keys(t);throw new Error(`Config format not supported: SDK = ${e}; Fields = ${n.join(", ")}`)}}class h{constructor(e,n,r,s,i,o,a){this._renderingMode=e,this._initialArgs=n,this._initialUiState=r,this._outputs=s,this._inputsValid=i,this._sections=o,this._title=a}static create(e="Heavy"){return new h(e,void 0,{},{},C(!0),C([]),void 0)}output(e,n,r={}){if(typeof n=="function"){const s=`output#${e}`;return k(s,()=>n(new O)),new h(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[e]:{__renderLambda:!0,handle:s,...r}},this._inputsValid,this._sections,this._title)}else return new h(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[e]:n},this._inputsValid,this._sections,this._title)}retentiveOutput(e,n){return this.output(e,n,{retentive:!0})}canRun(e){return this.inputsValid(e)}argsValid(e){return typeof e=="function"?(k("inputsValid",()=>e(new O)),new h(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,{__renderLambda:!0,handle:"inputsValid"},this._sections,this._title)):new h(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,e,this._sections,this._title)}inputsValid(e){return this.argsValid(e)}sections(e){return Array.isArray(e)?this.sections(C(e)):typeof e=="function"?(k("sections",()=>e(new O)),new h(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,{__renderLambda:!0,handle:"sections"},this._title)):new h(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,e,this._title)}title(e){return k("title",()=>e(new O)),new h(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,this._sections,{__renderLambda:!0,handle:"title"})}initialArgs(e){return new h(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withArgs(e){return new h(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title)}withUiState(e){return new h(this._renderingMode,this._initialArgs,e,this._outputs,this._inputsValid,this._sections,this._title)}done(){if(this._initialArgs===void 0)throw new Error("Initial arguments not set.");const e={v3:{sdkVersion:F,renderingMode:this._renderingMode,initialArgs:this._initialArgs,initialUiState:this._initialUiState,inputsValid:this._inputsValid,sections:this._sections,title:this._title,outputs:this._outputs},sdkVersion:F,renderingMode:this._renderingMode,initialArgs:this._initialArgs,inputsValid:j(this._inputsValid),sections:j(this._sections),outputs:Object.fromEntries(Object.entries(this._outputs).map(([n,r])=>[n,j(r)]))};return ze()?re({sdkVersion:F}):{config:e}}}function st(t,e,n,r){var o,a;const s=t.resultPool.getData().entries.map(l=>l.obj).filter(p.isPColumn).filter(l=>l.spec.name==="pl7.app/label"&&l.spec.axesSpec.length===1),i=new Map;for(const l of e)for(const c of l.spec.axesSpec){const g=p.getAxisId(c);for(const w of s)p.matchAxisId(g,p.getAxisId(w.spec.axesSpec[0]))&&i.set(w.id,w)}if(![...e,...i.values()].find(l=>!l.data.getIsReadyOrError()))return t.createPTable({src:{type:"outer",primary:{type:"full",entries:e.map(l=>({type:"column",column:l}))},secondary:Array.from(i.values()).map(l=>({type:"column",column:l}))},filters:[...((o=n==null?void 0:n.pTableParams)==null?void 0:o.filters)??[],...r??[]],sorting:((a=n==null?void 0:n.pTableParams)==null?void 0:a.sorting)??[]})}function it(t,e,n){const r=t.findLabels(e);return{axis:e,options:n.map(s=>({value:s,label:(r==null?void 0:r.get(s))??s.toString()})),defaultValue:n[0]}}class ot{constructor(e){this.handle=e}async findColumns(e){return await platforma.pFrameDriver.findColumns(this.handle,e)}async getColumnSpec(e){return await platforma.pFrameDriver.getColumnSpec(this.handle,e)}async listColumns(){return await platforma.pFrameDriver.listColumns(this.handle)}async calculateTableData(e){return await platforma.pFrameDriver.calculateTableData(this.handle,e)}async getUniqueValues(e){return await platforma.pFrameDriver.getUniqueValues(this.handle,e)}}function ye(t){return z({__isRef:!0,blockId:D(t,"blockId"),name:D(t,"name")})}function at(t){return z({ref:ye(D(t,"ref")),label:D(t,"label")})}const lt={sdkVersion:F};function ut(){return re({sdkVersion:F})}function ct(t){if(typeof globalThis.getEnvironmentValue=="function")return globalThis.getEnvironmentValue(t)}exports.Args=Se;exports.BlockModel=h;exports.CurrentSdkInfo=lt;exports.FutureRef=m;exports.It=Ae;exports.JsRenderInternal=Qe;exports.MainOutputs=Re;exports.OutputError=te;exports.PAnnotationLabel=ae;exports.PAnnotationTrace=le;exports.PFrameImpl=ot;exports.RT_BINARY_PARTITIONED=V;exports.RT_BINARY_SUPER_PARTITIONED=x;exports.RT_JSON_PARTITIONED=H;exports.RT_JSON_SUPER_PARTITIONED=W;exports.RT_RESOURCE_MAP=N;exports.RT_RESOURCE_MAP_PARTITIONED=B;exports.RenderCtx=O;exports.ResultPool=pe;exports.StagingOutputs=Te;exports.Trace=ce;exports.TraceEntry=ue;exports.TreeNodeAccessor=S;exports.UiState=Ie;exports.and=ke;exports.createPlDataTable=st;exports.createPlDataTableSheet=it;exports.deriveLabels=de;exports.downgradeCfgOrLambda=j;exports.extractConfig=rt;exports.flatten=De;exports.fromPlOption=at;exports.fromPlRef=ye;exports.getBlobContent=Be;exports.getBlobContentAsJson=Ue;exports.getBlobContentAsString=Me;exports.getDownloadedBlobContent=Je;exports.getEnvironmentValue=ct;exports.getFromCfg=T;exports.getImmediate=C;exports.getImportProgress=Ke;exports.getJsonField=D;exports.getLastLogs=Ge;exports.getLogHandle=We;exports.getOnDemandBlobContent=$e;exports.getPartitionKeysList=he;exports.getProgressLog=He;exports.getRawPlatformaInstance=ut;exports.getResourceField=xe;exports.getResourceValueAsJson=je;exports.getUniquePartitionKeys=nt;exports.isConfigLambda=me;exports.isEmpty=Ee;exports.isolate=we;exports.makeArray=Oe;exports.makeObject=z;exports.mapArrayValues=Fe;exports.mapRecordValues=Ce;exports.mapResourceFields=Ne;exports.not=Le;exports.or=Ve;exports.parseResourceMap=tt;exports.readOutput=ne;exports.wrapOutputs=Pe;Object.keys(p).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>p[t]})});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|