@milaboratories/pl-model-common 1.16.1 → 1.16.2
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/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/errors.ts +8 -0
package/dist/errors.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ export declare function isAbortError(error: unknown): error is Error & {
|
|
|
15
15
|
};
|
|
16
16
|
export declare function hasAbortError(error: unknown): boolean;
|
|
17
17
|
export declare function isAggregateError(error: unknown): error is AggregateError;
|
|
18
|
+
export declare class PFrameError extends Error {
|
|
19
|
+
name: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function isPFrameError(error: unknown): error is PFrameError;
|
|
18
22
|
export declare function ensureError(value: unknown): Error;
|
|
19
23
|
export type SerializedError = {
|
|
20
24
|
name: string;
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,IAAI,SAAgB;CACrB;AAED;;GAEG;AACH,qBAAa,OAAQ,SAAQ,KAAK;IAChC,IAAI,SAAa;CAClB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,GAAG;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAEpF;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMrD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAmBD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAMjD;AAID,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,GAAG,KAAK,CAQ5D;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,eAAe,CAU1D;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI;IACxC,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,GAAG;IACF,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAK3D;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,eAAe,CAAC,CAK9F;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,EAAE,eAAe,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAKhG;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAOnE;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAOhG;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,eAAe,CAAC,CAGxF;AAED,wBAAsB,qBAAqB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAGrH"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,IAAI,SAAgB;CACrB;AAED;;GAEG;AACH,qBAAa,OAAQ,SAAQ,KAAK;IAChC,IAAI,SAAa;CAClB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,GAAG;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAEpF;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMrD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAED,qBAAa,WAAY,SAAQ,KAAK;IACpC,IAAI,SAAiB;CACtB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAmBD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAMjD;AAID,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,GAAG,KAAK,CAQ5D;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,eAAe,CAU1D;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI;IACxC,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,GAAG;IACF,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAK3D;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,eAAe,CAAC,CAK9F;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,EAAE,eAAe,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAKhG;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAOnE;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAOhG;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,eAAe,CAAC,CAGxF;AAED,wBAAsB,qBAAqB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAGrH"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var se=Object.defineProperty;var ae=(e,n,t)=>n in e?se(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var l=(e,n,t)=>ae(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("zod"),g=require("canonicalize");function ue(e){if(e.code!==void 0)return{code:e.code,sdkVersion:e.sdkVersion,featureFlags:e.featureFlags}}function y(e){if(e!==void 0)return typeof e=="string"?{__renderLambda:!0,handle:e,retentive:!1}:e}function ce(e){if(e.v3!==void 0){const{initialArgs:n,initialUiState:t,inputsValid:r,outputs:o,renderingMode:i,sdkVersion:a,featureFlags:s,sections:u,title:c,enrichmentTargets:f}=e.v3,{code:ie}=e;return{initialArgs:n,initialUiState:t,inputsValid:r,outputs:o,renderingMode:i,sdkVersion:a,featureFlags:s,sections:u,title:c,code:ie,enrichmentTargets:f}}else if(e.inputsValid!==void 0){const{sdkVersion:n,renderingMode:t,outputs:r,inputsValid:o,sections:i,initialArgs:a,code:s}=e,u=Object.keys(e);if(n===void 0||t===void 0||r===void 0||o===void 0||i===void 0||a===void 0)throw new Error(`Malformed config v2. SDK version ${n}; Fields = ${u.join(", ")}`);return{sdkVersion:n,renderingMode:t,initialArgs:a,outputs:Object.fromEntries(Object.entries(r).map(([c,f])=>[c,y(f)])),inputsValid:y(o),sections:y(i),initialUiState:void 0,code:s}}else if(e.renderingMode!==void 0){const{sdkVersion:n,canRun:t,renderingMode:r,outputs:o,sections:i,initialArgs:a,code:s}=e,u=Object.keys(e);if(r===void 0||o===void 0||t===void 0||i===void 0||a===void 0)throw new Error(`Malformed config v1. SDK version ${n}; Fields = ${u.join(", ")}`);return{sdkVersion:n??"unknown",renderingMode:r,initialArgs:a,outputs:Object.fromEntries(Object.entries(o).map(([c,f])=>[c,y(f)])),inputsValid:y(t),sections:y(i),initialUiState:void 0,code:s}}else{const{sdkVersion:n}=e,t=Object.keys(e);throw new Error(`Config format not supported: SDK = ${n}; Fields = ${t.join(", ")}`)}}const fe=p.z.object({from:p.z.number(),to:p.z.number()});function de(e,n){if(!(e==null||n==null))return{from:e,to:n}}function le(e,n){if(e.from<0||e.to<0||e.from>=e.to)throw new Error(`${n}: invalid bytes range: ${e}`)}function pe(e){return e!==void 0&&e.startsWith("log+live://log/")}function k(e){throw new Error("Unexpected object: "+e)}const R="upload://upload/",$="index://index/";function J(e){return e.startsWith(R)}function j(e){return e.startsWith($)}function D(e){if(j(e)){const n=e.slice($.length);return JSON.parse(decodeURIComponent(n)).path}else if(J(e)){const n=e.slice(R.length);return JSON.parse(decodeURIComponent(n)).localPath}k(e)}function me(e){return e.replace(/^.*[\\/]/,"")}function ye(e){return me(D(e))}function he(e){if(!e||typeof e!="object")return!1;const n=e;if(!("type"in n))return!1;switch(n.type){case"Json":return typeof n.keyLength=="number"&&n.data!==void 0&&typeof n.data=="object";case"JsonPartitioned":return typeof n.partitionKeyLength=="number"&&n.parts!==void 0&&typeof n.parts=="object";case"BinaryPartitioned":return typeof n.partitionKeyLength=="number"&&n.parts!==void 0&&typeof n.parts=="object";default:return!1}}function ge(e,n){if(e!==void 0)switch(e.type){case"Json":return e;case"JsonPartitioned":{const t={};for(const[r,o]of Object.entries(e.parts))t[r]=n(o);return{...e,parts:t}}case"BinaryPartitioned":{const t={};for(const[r,o]of Object.entries(e.parts))t[r]={index:n(o.index),values:n(o.values)};return{...e,parts:t}}}}function L(e){if(!e||typeof e!="object")return!1;const n=e;if(!("type"in n))return!1;switch(n.type){case"Json":return typeof n.keyLength=="number"&&Array.isArray(n.data);case"JsonPartitioned":return typeof n.partitionKeyLength=="number"&&Array.isArray(n.parts);case"BinaryPartitioned":return typeof n.partitionKeyLength=="number"&&Array.isArray(n.parts);default:return!1}}function be(e){return L(e)?e.type==="JsonPartitioned"||e.type==="BinaryPartitioned":!1}function we(e){switch(e.type){case"Json":{const n=Object.entries(e.data).map(([t,r])=>({key:JSON.parse(t),value:r}));return{type:"Json",keyLength:e.keyLength,data:n}}case"JsonPartitioned":{const n=Object.entries(e.parts).map(([t,r])=>({key:JSON.parse(t),value:r}));return{type:"JsonPartitioned",partitionKeyLength:e.partitionKeyLength,parts:n}}case"BinaryPartitioned":{const n=Object.entries(e.parts).map(([t,r])=>({key:JSON.parse(t),value:r}));return{type:"BinaryPartitioned",partitionKeyLength:e.partitionKeyLength,parts:n}}}}function Ae(e){switch(e.type){case"Json":{const n={};for(const t of e.data)n[JSON.stringify(t.key)]=t.value;return{type:"Json",keyLength:e.keyLength,data:n}}case"JsonPartitioned":{const n={};for(const t of e.parts)n[JSON.stringify(t.key)]=t.value;return{type:"JsonPartitioned",partitionKeyLength:e.partitionKeyLength,parts:n}}case"BinaryPartitioned":{const n={};for(const t of e.parts)n[JSON.stringify(t.key)]=t.value;return{type:"BinaryPartitioned",partitionKeyLength:e.partitionKeyLength,parts:n}}}}function Pe(e,n){if(e!==void 0)switch(e.type){case"Json":return e;case"JsonPartitioned":{const t=e.parts.map(r=>({key:r.key,value:n(r.value)}));return{...e,parts:t}}case"BinaryPartitioned":{const t=e.parts.map(r=>({key:r.key,value:{index:n(r.value.index),values:n(r.value.values)}}));return{...e,parts:t}}}}const B=-2147483648,P=-9007199254740991n,xe=NaN,Ee=NaN,z=null,U=null;function b(e,n){switch(n){case"Int":return e===B;case"Long":return e===Number(P)||e===P;case"Float":return Number.isNaN(e);case"Double":return Number.isNaN(e);case"String":return e===z;case"Bytes":return e===U;default:throw Error(`unsupported data type: ${n}`)}}function ke(e){if(!T(e))throw new Error(`Expected not-NA PValue, got ${e}`);return e}function T(e,n){if(!n)return typeof e=="string"||typeof e=="number"&&isFinite(e)||typeof e=="bigint";if(b(e,n))return!1;switch(n){case"Int":return typeof e=="number";case"Long":return typeof e=="number"||typeof e=="bigint";case"Float":return typeof e=="number";case"Double":return typeof e=="number";case"String":return typeof e=="string";case"Bytes":throw Error("Bytes not yet supported");default:throw Error(`unsupported data type: ${n}`)}}function M(e,n){if(!n)return e===null||typeof e=="string"||typeof e=="number"||typeof e=="bigint";if(b(e,n))return!0;switch(n){case"Int":return typeof e=="number";case"Long":return typeof e=="number"||typeof e=="bigint";case"Float":return typeof e=="number";case"Double":return typeof e=="number";case"String":return typeof e=="string";case"Bytes":throw Error("Bytes not yet supported");default:throw Error(`unsupported data type: ${n}`)}}function Se(e){if(e===null||typeof e=="string"||typeof e=="number")return e;if(typeof e=="bigint")return{bigint:e.toString()};throw new Error(`Type ${typeof e} (value ${e}) not yet supported.`)}function K(e,n){if(e===null||typeof e=="string"||typeof e=="number"||typeof e=="bigint"){if(n&&!b(e,n)&&!M(e,n))throw new Error(`Unexpected value type, got ${typeof e}, expected ${n}`);return e}if(typeof e=="object"&&e!==null&&"bigint"in e&&typeof e.bigint=="string"){if(n&&n!=="Long")throw new Error(`Unexpected value type, got serialized bigint, expected ${n}`);return BigInt(e.bigint)}throw new Error(`Unsupported type ${typeof e} (value ${e}).`)}function Ie(e){if(e=q(e),e===null)throw new Error("Value is null");return e}function q(e){if(e=K(e),e===null)return null;if(typeof e=="string")return e;if(typeof e=="number"){if(!isFinite(e))throw new Error(`Value is not finite (${e})`);return e}if(typeof e=="bigint")return Number(e);throw new Error(`Unexpected value type: ${typeof e}`)}function _(e,n){const t=Math.floor(n/8),r=1<<7-n%8;return(e[t]&r)>0}const H={type:"absent"},W=null;function Ne(e){return typeof e=="object"&&e!==null&&e.type==="absent"}function ve(e,n,t={}){if(_(e.absent,n))return t.absent===void 0?H:t.absent;const r=e.data[n],o=e.type;if(b(r,o))return t.na===void 0?W:t.na;switch(o){case"Int":return r;case"Long":return Number(r);case"Float":return r;case"Double":return r;case"String":return r;case"Bytes":throw Error("Bytes not yet supported");default:throw Error(`unsupported data type: ${o}`)}}function Ce(e){return{kind:e.kind,valueType:e.valueType,name:e.name,domain:e.domain,parentAxes:e.parentAxes,axesId:S(e.axesSpec)}}function Ve(e){return{columnId:e.id,spec:e.spec}}function m(e){const{type:n,name:t,domain:r}=e,o={type:n,name:t};return r&&Object.entries(r).length>0&&Object.assign(o,{domain:r}),o}function S(e){return e.map(m)}function Oe(e){return g(m(e))}function Fe(e,n){if(e===void 0)return n===void 0;if(n===void 0)return!0;for(const t in n)if(e[t]!==n[t])return!1;return!0}function G(e,n){return e.name===n.name&&Fe(e.domain,n.domain)}function Re(e,n){return{...e,src:h(e.src,n)}}function h(e,n){switch(e.type){case"column":return{type:"column",column:n(e.column)};case"slicedColumn":return{type:"slicedColumn",column:n(e.column),newId:e.newId,axisFilters:e.axisFilters};case"inlineColumn":return e;case"inner":case"full":return{type:e.type,entries:e.entries.map(t=>h(t,n))};case"outer":return{type:"outer",primary:h(e.primary,n),secondary:e.secondary.map(t=>h(t,n))};default:k(e)}}function $e(e){switch(e.type){case"axis":return{type:"axis",id:e.id};case"column":return{type:"column",id:e.id}}}function X(e){return g(e)}function Je(e){return JSON.parse(e)}function O(e){return g(m(e))}function F(e,n){return JSON.stringify([e,n])}class je{constructor(n){l(this,"domains",new Map);l(this,"axes",new Map);l(this,"domainPacks",[]);l(this,"domainPackToAnchor",new Map);this.anchors=n;const t=Object.entries(n);t.sort((r,o)=>r[0].localeCompare(o[0]));for(const[r,o]of t){for(let i=0;i<o.axesSpec.length;i++){const a=o.axesSpec[i],s=O(a);this.axes.set(s,{anchor:r,idx:i})}if(o.domain!==void 0){const i=Object.entries(o.domain);i.sort((a,s)=>a[0].localeCompare(s[0])),this.domainPackToAnchor.set(JSON.stringify(i),r),this.domainPacks.push(i.map(([a])=>a));for(const[a,s]of i){const u=F(a,s);this.domains.set(u,r)}}}}derive(n,t){const r={name:n.name,axes:[]};let o;if(n.domain!==void 0)e:for(const a of this.domainPacks){const s=[];for(const c of a){const f=n.domain[c];if(f!==void 0)s.push([c,f]);else break e}const u=this.domainPackToAnchor.get(JSON.stringify(s));if(u!==void 0){r.domainAnchor=u,o=new Set(a);break}}for(const[a,s]of Object.entries(n.domain??{})){if(o!==void 0&&o.has(a))continue;const u=F(a,s),c=this.domains.get(u);r.domain??(r.domain={}),r.domain[a]=c?{anchor:c}:s}if(r.axes=n.axesSpec.map(a=>{const s=O(a),u=this.axes.get(s);return u===void 0?m(a):u}),!t||t.length===0)return r;const i=[];for(const a of t){const[s,u]=a;if(typeof s=="number"){if(s<0||s>=n.axesSpec.length)throw new Error(`Axis index ${s} is out of bounds (0-${n.axesSpec.length-1})`);i.push([s,u])}else{const c=n.axesSpec.findIndex(f=>f.name===s);if(c===-1)throw new Error(`Axis with name "${s}" not found in the column specification`);i.push([c,u])}}return i.sort((a,s)=>a[0]-s[0]),{source:r,axisFilters:i}}deriveS(n,t){return X(this.derive(n,t))}}function De(e,n,t){const r={...n},o=(t==null?void 0:t.ignoreMissingDomains)??!1;if(r.domainAnchor!==void 0){const i=e[r.domainAnchor];if(!i)throw new Error(`Anchor "${r.domainAnchor}" not found`);const a=i.domain||{};r.domain={...a,...r.domain},delete r.domainAnchor}if(r.domain){const i={};for(const[a,s]of Object.entries(r.domain))if(typeof s=="string")i[a]=s;else{const u=e[s.anchor];if(!u)throw new Error(`Anchor "${s.anchor}" not found for domain key "${a}"`);if(!u.domain||u.domain[a]===void 0){if(!o)throw new Error(`Domain key "${a}" not found in anchor "${s.anchor}"`);continue}i[a]=u.domain[a]}r.domain=i}return r.axes&&(r.axes=r.axes.map(i=>Le(e,i))),r}function Le(e,n){if(!Be(n))return n;const t=n.anchor,r=e[t];if(!r)throw new Error(`Anchor "${t}" not found for axis reference`);if("idx"in n){if(n.idx<0||n.idx>=r.axesSpec.length)throw new Error(`Axis index ${n.idx} out of bounds for anchor "${t}"`);return r.axesSpec[n.idx]}else if("name"in n){const o=r.axesSpec.filter(i=>i.name===n.name);if(o.length>1)throw new Error(`Multiple axes with name "${n.name}" found in anchor "${t}"`);if(o.length===0)throw new Error(`Axis with name "${n.name}" not found in anchor "${t}"`);return o[0]}else if("id"in n){const o=r.axesSpec.filter(i=>G(n.id,m(i)));if(o.length>1)throw new Error(`Multiple matching axes found for matcher in anchor "${t}"`);if(o.length===0)throw new Error(`No matching axis found for matcher in anchor "${t}"`);return o[0]}throw new Error("Unsupported axis reference type")}function Be(e){return typeof e=="object"&&"anchor"in e}function ze(e){return typeof e=="object"&&e!==null&&"source"in e&&"axisFilters"in e}function d(e){return e.kind==="PColumn"}function Q(e){return d(e.spec)}function Ue(e){return d(e.obj)}function Te(e){return d(e.obj.spec)}function Me(e){if(!Q(e))throw new Error(`not a PColumn (kind = ${e.spec.kind})`);return e}function Ke(e,n){return e===void 0?void 0:{...e,data:n(e.data)}}function qe(e){const n=new Map,t=r=>{switch(r.type){case"column":n.set(r.column.id,r.column);return;case"slicedColumn":n.set(r.column.id,r.column);return;case"inlineColumn":return;case"full":case"inner":for(const o of r.entries)t(o);return;case"outer":t(r.primary);for(const o of r.secondary)t(o);return;default:k(r)}};return t(e),[...n.values()]}function _e(e){throw new Error("Unexpected object: "+e)}function w(e,n){switch(e.type){case"and":for(const t of e.operands)if(!w(t,n))return!1;return!0;case"or":for(const t of e.operands)if(w(t,n))return!0;return!1;case"not":return!w(e.operand,n);case"name":return d(n)&&n.name===e.name;case"name_pattern":return d(n)&&!!n.name.match(e.pattern);case"annotation":return d(n)&&n.annotations!==void 0&&n.annotations[e.annotation]===e.value;case"annotation_pattern":return d(n)&&n.annotations!==void 0&&n.annotations[e.annotation]!==void 0&&!!n.annotations[e.annotation].match(e.pattern);case"has_axes":return d(n)&&e.axes.every(t=>n.axesSpec.some(r=>(t.type===void 0||t.type===r.type)&&(t.name===void 0||t.name===r.name)&&(t.domain===void 0||Object.keys(t.domain).length===0||r.domain!==void 0&&Object.entries(t.domain).every(([o,i])=>r.domain[o]===i))));default:_e(e)}}function x(e,n){if(e.name!==void 0&&e.name!==n.name)return!1;if(e.type!==void 0){if(Array.isArray(e.type)){if(!e.type.includes(n.type))return!1}else if(e.type!==n.type)return!1}if(e.domain!==void 0){const t=n.domain||{};for(const[r,o]of Object.entries(e.domain))if(t[r]!==o)return!1}return!0}function E(e,n){if(n.name!==void 0&&e.name!==n.name||n.namePattern!==void 0&&!new RegExp(n.namePattern).test(e.name))return!1;if(n.type!==void 0){if(Array.isArray(n.type)){if(!n.type.includes(e.valueType))return!1}else if(n.type!==e.valueType)return!1}if(n.domain!==void 0){const t=e.domain||{};for(const[r,o]of Object.entries(n.domain))if(t[r]!==o)return!1}if(n.axes!==void 0){const t=e.axesSpec.map(m);if(n.partialAxesMatch){for(const r of n.axes)if(!t.some(o=>x(r,o)))return!1}else{if(t.length!==n.axes.length)return!1;for(let r=0;r<n.axes.length;r++)if(!x(n.axes[r],t[r]))return!1}}if(n.annotations!==void 0){const t=e.annotations||{};for(const[r,o]of Object.entries(n.annotations))if(t[r]!==o)return!1}if(n.annotationPatterns!==void 0){const t=e.annotations||{};for(const[r,o]of Object.entries(n.annotationPatterns)){const i=t[r];if(i===void 0||!new RegExp(o).test(i))return!1}}return!0}function He(e){return Array.isArray(e)?n=>e.some(t=>d(n)&&E(n,t)):n=>d(n)&&E(n,e)}function We(e){const n={kind:e.kind,name:e.name};return e.domain!==void 0&&(n.domain=e.domain),d(e)&&(n.axesSpec=S(e.axesSpec)),g(n)}const Ge={href:"/"},Xe=p.z.object({__isRef:p.z.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),blockId:p.z.string().describe("Upstream block id"),name:p.z.string().describe("Name of the output provided to the upstream block's output context"),requireEnrichments:p.z.literal(!0).optional().describe("True if current block that stores this reference in its args, may need enrichments for the references value originating from the blocks in between current and referenced block")}).describe("Universal reference type, allowing to set block connections. It is crucial that {@link __isRef} is present and equal to true, internal logic relies on this marker to build block dependency trees.").readonly();function Qe(e){return typeof e=="object"&&e!==null&&"__isRef"in e&&e.__isRef===!0&&"blockId"in e&&"name"in e}function Ye(e,n,t=!1){return t?{__isRef:!0,blockId:e,name:n,requireEnrichments:!0}:{__isRef:!0,blockId:e,name:n}}function Ze(e,n=!0){if(n)return{...e,requireEnrichments:!0};{const{requireEnrichments:t,...r}=e;return r}}function en(e,n,t=!1){return e.blockId===n.blockId&&e.name===n.name&&(t||e.requireEnrichments===n.requireEnrichments)}function nn(e,n){return e.ok?{ok:!0,value:n(e.value)}:e}function tn(e){if(e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray)return new DataView(e.buffer,e.byteOffset,e.byteLength);if(e instanceof ArrayBuffer)return new DataView(e);throw new TypeError("Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray")}const rn="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",on="0123456789ABCDEFGHIJKLMNOPQRSTUV",sn="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function Y(e,n,t){t=t||{};let r,o;switch(n){case"RFC3548":case"RFC4648":r=rn,o=!0;break;case"RFC4648-HEX":r=on,o=!0;break;case"Crockford":r=sn,o=!1;break;default:throw new Error("Unknown base32 variant: "+String(n))}const i=t.padding!==void 0?t.padding:o,a=tn(e);let s=0,u=0,c="";for(let f=0;f<a.byteLength;f++)for(u=u<<8|a.getUint8(f),s+=8;s>=5;)c+=r[u>>>s-5&31],s-=5;if(s>0&&(c+=r[u<<5-s&31]),i)for(;c.length%8!==0;)c+="=";return c}const I=15,Z=24,N=p.z.string().length(Z).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");function an(){const e=new Uint8Array(I);return crypto.getRandomValues(e),N.parse(Y(e,"RFC4648"))}function ee(e){if(e.length!==I)throw new Error(`Wrong number of bytes: ${e.length}`);return N.parse(Y(e,"RFC4648"))}async function un(e){const n=new TextEncoder,t=await crypto.subtle.digest("SHA-256",n.encode(e));return ee(new Uint8Array(t.slice(0,15)))}function cn(e){return JSON.stringify(e)}function fn(e){return g(e)}function dn(e){return JSON.parse(e)}class ln extends Error{constructor(){super(...arguments);l(this,"name","AbortError")}}class pn extends Error{constructor(){super(...arguments);l(this,"name","UiError")}}function mn(e){return e instanceof Error&&e.name==="AbortError"}function ne(e){return e instanceof Error?e.name==="AbortError"||ne(e.cause):!1}function yn(e){return e instanceof Error&&e.name==="AggregateError"}function hn(e){if(typeof e=="string")return`String value was thrown: ${e}`;if(e&&typeof e=="object")try{return`Plain object was thrown: ${JSON.stringify(e)}`}catch(n){return`Non-serializable object was thrown (JSON.stringify failed: ${n instanceof Error?n.message:String(n)}): ${String(e)}`}return`Non-Error value (${typeof e}) was thrown: ${e}`}function A(e){return e instanceof Error?e:new Error(hn(e))}function v(e){const n=e.cause?v(e.cause):void 0,t=new Error(e.message,n!==void 0?{cause:n}:void 0);return t.name=e.name||"Error",t.stack=e.stack,t}function C(e){const n=A(e),t=n.cause?C(n.cause):void 0;return{name:n.name,message:n.message,stack:n.stack,...n.cause!==void 0&&{cause:t}}}function gn(e){if(e.error)throw e.error;return e.value}function V(e){return e.error?{error:C(e.error)}:{value:e.value}}function bn(e){return e.error?{error:v(e.error)}:{value:e.value}}function te(e){try{return{value:e()}}catch(n){return{error:A(n)}}}async function re(e){try{return{value:await e()}}catch(n){return{error:A(n)}}}function wn(e){const n=te(e);return V(n)}async function An(e){const n=await re(e);return V(n)}const Pn=["supportsLazyState"],xn=["requiresUIAPIVersion","requiresModelAPIVersion"];function En(e,n,t=!0){return e===void 0?!1:e[n]===t}function kn(e){return e===void 0?new Set:new Set(Object.entries(e).filter(([n,t])=>n.startsWith("requires")&&t===!0).map(([n])=>n))}function Sn(e){return e===void 0?new Set:new Set(Object.entries(e).filter(([n,t])=>n.startsWith("supports")&&t===!0).map(([n])=>n))}class oe extends Error{constructor(t){super(`Some of the block requirements are not supported by the runtime: ${Array.from(t.entries()).map(([r,o])=>`${r}: ${o}`).join(", ")}`);l(this,"name","IncompatibleFlagsError");this.incompatibleFlags=t}}class In{constructor(){l(this,"supportedRequirements",new Map)}addSupportedRequirement(n,t=!0){return this.supportedRequirements.has(n)||this.supportedRequirements.set(n,new Set),this.supportedRequirements.get(n).add(t),this}getIncompatibleFlags(n){if(n===void 0)return;const t=new Map;for(const[r,o]of Object.entries(n))if(r.startsWith("requires")){if(o===void 0)continue;const i=this.supportedRequirements.get(r);(i===void 0||!i.has(o))&&t.set(r,o)}return t.size===0?void 0:t}checkCompatibility(n){return this.getIncompatibleFlags(n)===void 0}throwIfIncompatible(n){const t=this.getIncompatibleFlags(n);if(t!==void 0)throw new oe(t)}}exports.AbortError=ln;exports.AllRequiresFeatureFlags=xn;exports.AllSupportsFeatureFlags=Pn;exports.AnchoredIdDeriver=je;exports.DefaultNavigationState=Ge;exports.IncompatibleFlagsError=oe;exports.PTableAbsent=H;exports.PTableNA=W;exports.PValueBytesNA=U;exports.PValueDoubleNA=Ee;exports.PValueFloatNA=xe;exports.PValueIntNA=B;exports.PValueLongNA=P;exports.PValueStringNA=z;exports.PlId=N;exports.PlIdBytes=I;exports.PlIdLength=Z;exports.PlRef=Xe;exports.RangeBytes=fe;exports.RuntimeCapabilities=In;exports.UiError=pn;exports.canonicalizeAxisId=Oe;exports.canonicalizeJson=fn;exports.checkBlockFlag=En;exports.createPlRef=Ye;exports.dataInfoToEntries=we;exports.deriveNativeId=We;exports.deserializeError=v;exports.deserializeResult=bn;exports.digestPlId=un;exports.ensureError=A;exports.ensureNotNAPValue=ke;exports.ensurePColumn=Me;exports.entriesToDataInfo=Ae;exports.executePSpecPredicate=w;exports.extractAllColumns=qe;exports.extractAllRequirements=kn;exports.extractAllSupports=Sn;exports.extractCodeWithInfo=ue;exports.extractConfigGeneric=ce;exports.getAxesId=S;exports.getAxisId=m;exports.getColumnIdAndSpec=Ve;exports.getFileNameFromHandle=ye;exports.getFilePathFromHandle=D;exports.getPColumnSpecId=Ce;exports.getPTableColumnId=$e;exports.hasAbortError=ne;exports.isAbortError=mn;exports.isAggregateError=yn;exports.isDataInfo=he;exports.isDataInfoEntries=L;exports.isFilteredPColumn=ze;exports.isImportFileHandleIndex=j;exports.isImportFileHandleUpload=J;exports.isLiveLog=pe;exports.isNotNAPValue=T;exports.isPColumn=Q;exports.isPColumnResult=Te;exports.isPColumnSpec=d;exports.isPColumnSpecResult=Ue;exports.isPTableAbsent=Ne;exports.isPValue=M;exports.isPartitionedDataInfoEntries=be;exports.isPlRef=Qe;exports.isValueAbsent=_;exports.isValueNA=b;exports.mapDataInfo=ge;exports.mapDataInfoEntries=Pe;exports.mapJoinEntry=h;exports.mapPObjectData=Ke;exports.mapPTableDef=Re;exports.mapValueInVOE=nn;exports.matchAxis=x;exports.matchAxisId=G;exports.matchPColumn=E;exports.newRangeBytesOpt=de;exports.pTableValue=ve;exports.pValueToStringOrNumber=Ie;exports.pValueToStringOrNumberOrNull=q;exports.parseColumnId=Je;exports.parseJson=dn;exports.plId=ee;exports.plRefsEqual=en;exports.resolveAnchors=De;exports.safeConvertToPValue=K;exports.selectorsToPredicate=He;exports.serializeError=C;exports.serializeResult=V;exports.stringifyColumnId=X;exports.stringifyJson=cn;exports.toJsonSafePValue=Se;exports.uniquePlId=an;exports.unwrapResult=gn;exports.validateRangeBytes=le;exports.withEnrichments=Ze;exports.wrapAndSerialize=wn;exports.wrapAndSerializeAsync=An;exports.wrapAsyncCallback=re;exports.wrapCallback=te;
|
|
1
|
+
"use strict";var se=Object.defineProperty;var ae=(e,n,t)=>n in e?se(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var l=(e,n,t)=>ae(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("zod"),g=require("canonicalize");function ue(e){if(e.code!==void 0)return{code:e.code,sdkVersion:e.sdkVersion,featureFlags:e.featureFlags}}function y(e){if(e!==void 0)return typeof e=="string"?{__renderLambda:!0,handle:e,retentive:!1}:e}function ce(e){if(e.v3!==void 0){const{initialArgs:n,initialUiState:t,inputsValid:r,outputs:o,renderingMode:i,sdkVersion:a,featureFlags:s,sections:u,title:c,enrichmentTargets:f}=e.v3,{code:ie}=e;return{initialArgs:n,initialUiState:t,inputsValid:r,outputs:o,renderingMode:i,sdkVersion:a,featureFlags:s,sections:u,title:c,code:ie,enrichmentTargets:f}}else if(e.inputsValid!==void 0){const{sdkVersion:n,renderingMode:t,outputs:r,inputsValid:o,sections:i,initialArgs:a,code:s}=e,u=Object.keys(e);if(n===void 0||t===void 0||r===void 0||o===void 0||i===void 0||a===void 0)throw new Error(`Malformed config v2. SDK version ${n}; Fields = ${u.join(", ")}`);return{sdkVersion:n,renderingMode:t,initialArgs:a,outputs:Object.fromEntries(Object.entries(r).map(([c,f])=>[c,y(f)])),inputsValid:y(o),sections:y(i),initialUiState:void 0,code:s}}else if(e.renderingMode!==void 0){const{sdkVersion:n,canRun:t,renderingMode:r,outputs:o,sections:i,initialArgs:a,code:s}=e,u=Object.keys(e);if(r===void 0||o===void 0||t===void 0||i===void 0||a===void 0)throw new Error(`Malformed config v1. SDK version ${n}; Fields = ${u.join(", ")}`);return{sdkVersion:n??"unknown",renderingMode:r,initialArgs:a,outputs:Object.fromEntries(Object.entries(o).map(([c,f])=>[c,y(f)])),inputsValid:y(t),sections:y(i),initialUiState:void 0,code:s}}else{const{sdkVersion:n}=e,t=Object.keys(e);throw new Error(`Config format not supported: SDK = ${n}; Fields = ${t.join(", ")}`)}}const fe=m.z.object({from:m.z.number(),to:m.z.number()});function de(e,n){if(!(e==null||n==null))return{from:e,to:n}}function le(e,n){if(e.from<0||e.to<0||e.from>=e.to)throw new Error(`${n}: invalid bytes range: ${e}`)}function me(e){return e!==void 0&&e.startsWith("log+live://log/")}function k(e){throw new Error("Unexpected object: "+e)}const R="upload://upload/",$="index://index/";function J(e){return e.startsWith(R)}function j(e){return e.startsWith($)}function D(e){if(j(e)){const n=e.slice($.length);return JSON.parse(decodeURIComponent(n)).path}else if(J(e)){const n=e.slice(R.length);return JSON.parse(decodeURIComponent(n)).localPath}k(e)}function pe(e){return e.replace(/^.*[\\/]/,"")}function ye(e){return pe(D(e))}function he(e){if(!e||typeof e!="object")return!1;const n=e;if(!("type"in n))return!1;switch(n.type){case"Json":return typeof n.keyLength=="number"&&n.data!==void 0&&typeof n.data=="object";case"JsonPartitioned":return typeof n.partitionKeyLength=="number"&&n.parts!==void 0&&typeof n.parts=="object";case"BinaryPartitioned":return typeof n.partitionKeyLength=="number"&&n.parts!==void 0&&typeof n.parts=="object";default:return!1}}function ge(e,n){if(e!==void 0)switch(e.type){case"Json":return e;case"JsonPartitioned":{const t={};for(const[r,o]of Object.entries(e.parts))t[r]=n(o);return{...e,parts:t}}case"BinaryPartitioned":{const t={};for(const[r,o]of Object.entries(e.parts))t[r]={index:n(o.index),values:n(o.values)};return{...e,parts:t}}}}function L(e){if(!e||typeof e!="object")return!1;const n=e;if(!("type"in n))return!1;switch(n.type){case"Json":return typeof n.keyLength=="number"&&Array.isArray(n.data);case"JsonPartitioned":return typeof n.partitionKeyLength=="number"&&Array.isArray(n.parts);case"BinaryPartitioned":return typeof n.partitionKeyLength=="number"&&Array.isArray(n.parts);default:return!1}}function be(e){return L(e)?e.type==="JsonPartitioned"||e.type==="BinaryPartitioned":!1}function we(e){switch(e.type){case"Json":{const n=Object.entries(e.data).map(([t,r])=>({key:JSON.parse(t),value:r}));return{type:"Json",keyLength:e.keyLength,data:n}}case"JsonPartitioned":{const n=Object.entries(e.parts).map(([t,r])=>({key:JSON.parse(t),value:r}));return{type:"JsonPartitioned",partitionKeyLength:e.partitionKeyLength,parts:n}}case"BinaryPartitioned":{const n=Object.entries(e.parts).map(([t,r])=>({key:JSON.parse(t),value:r}));return{type:"BinaryPartitioned",partitionKeyLength:e.partitionKeyLength,parts:n}}}}function Ae(e){switch(e.type){case"Json":{const n={};for(const t of e.data)n[JSON.stringify(t.key)]=t.value;return{type:"Json",keyLength:e.keyLength,data:n}}case"JsonPartitioned":{const n={};for(const t of e.parts)n[JSON.stringify(t.key)]=t.value;return{type:"JsonPartitioned",partitionKeyLength:e.partitionKeyLength,parts:n}}case"BinaryPartitioned":{const n={};for(const t of e.parts)n[JSON.stringify(t.key)]=t.value;return{type:"BinaryPartitioned",partitionKeyLength:e.partitionKeyLength,parts:n}}}}function Pe(e,n){if(e!==void 0)switch(e.type){case"Json":return e;case"JsonPartitioned":{const t=e.parts.map(r=>({key:r.key,value:n(r.value)}));return{...e,parts:t}}case"BinaryPartitioned":{const t=e.parts.map(r=>({key:r.key,value:{index:n(r.value.index),values:n(r.value.values)}}));return{...e,parts:t}}}}const B=-2147483648,P=-9007199254740991n,Ee=NaN,xe=NaN,z=null,U=null;function b(e,n){switch(n){case"Int":return e===B;case"Long":return e===Number(P)||e===P;case"Float":return Number.isNaN(e);case"Double":return Number.isNaN(e);case"String":return e===z;case"Bytes":return e===U;default:throw Error(`unsupported data type: ${n}`)}}function ke(e){if(!T(e))throw new Error(`Expected not-NA PValue, got ${e}`);return e}function T(e,n){if(!n)return typeof e=="string"||typeof e=="number"&&isFinite(e)||typeof e=="bigint";if(b(e,n))return!1;switch(n){case"Int":return typeof e=="number";case"Long":return typeof e=="number"||typeof e=="bigint";case"Float":return typeof e=="number";case"Double":return typeof e=="number";case"String":return typeof e=="string";case"Bytes":throw Error("Bytes not yet supported");default:throw Error(`unsupported data type: ${n}`)}}function M(e,n){if(!n)return e===null||typeof e=="string"||typeof e=="number"||typeof e=="bigint";if(b(e,n))return!0;switch(n){case"Int":return typeof e=="number";case"Long":return typeof e=="number"||typeof e=="bigint";case"Float":return typeof e=="number";case"Double":return typeof e=="number";case"String":return typeof e=="string";case"Bytes":throw Error("Bytes not yet supported");default:throw Error(`unsupported data type: ${n}`)}}function Se(e){if(e===null||typeof e=="string"||typeof e=="number")return e;if(typeof e=="bigint")return{bigint:e.toString()};throw new Error(`Type ${typeof e} (value ${e}) not yet supported.`)}function K(e,n){if(e===null||typeof e=="string"||typeof e=="number"||typeof e=="bigint"){if(n&&!b(e,n)&&!M(e,n))throw new Error(`Unexpected value type, got ${typeof e}, expected ${n}`);return e}if(typeof e=="object"&&e!==null&&"bigint"in e&&typeof e.bigint=="string"){if(n&&n!=="Long")throw new Error(`Unexpected value type, got serialized bigint, expected ${n}`);return BigInt(e.bigint)}throw new Error(`Unsupported type ${typeof e} (value ${e}).`)}function Ie(e){if(e=q(e),e===null)throw new Error("Value is null");return e}function q(e){if(e=K(e),e===null)return null;if(typeof e=="string")return e;if(typeof e=="number"){if(!isFinite(e))throw new Error(`Value is not finite (${e})`);return e}if(typeof e=="bigint")return Number(e);throw new Error(`Unexpected value type: ${typeof e}`)}function _(e,n){const t=Math.floor(n/8),r=1<<7-n%8;return(e[t]&r)>0}const H={type:"absent"},W=null;function Ne(e){return typeof e=="object"&&e!==null&&e.type==="absent"}function ve(e,n,t={}){if(_(e.absent,n))return t.absent===void 0?H:t.absent;const r=e.data[n],o=e.type;if(b(r,o))return t.na===void 0?W:t.na;switch(o){case"Int":return r;case"Long":return Number(r);case"Float":return r;case"Double":return r;case"String":return r;case"Bytes":throw Error("Bytes not yet supported");default:throw Error(`unsupported data type: ${o}`)}}function Ce(e){return{kind:e.kind,valueType:e.valueType,name:e.name,domain:e.domain,parentAxes:e.parentAxes,axesId:S(e.axesSpec)}}function Ve(e){return{columnId:e.id,spec:e.spec}}function p(e){const{type:n,name:t,domain:r}=e,o={type:n,name:t};return r&&Object.entries(r).length>0&&Object.assign(o,{domain:r}),o}function S(e){return e.map(p)}function Fe(e){return g(p(e))}function Oe(e,n){if(e===void 0)return n===void 0;if(n===void 0)return!0;for(const t in n)if(e[t]!==n[t])return!1;return!0}function G(e,n){return e.name===n.name&&Oe(e.domain,n.domain)}function Re(e,n){return{...e,src:h(e.src,n)}}function h(e,n){switch(e.type){case"column":return{type:"column",column:n(e.column)};case"slicedColumn":return{type:"slicedColumn",column:n(e.column),newId:e.newId,axisFilters:e.axisFilters};case"inlineColumn":return e;case"inner":case"full":return{type:e.type,entries:e.entries.map(t=>h(t,n))};case"outer":return{type:"outer",primary:h(e.primary,n),secondary:e.secondary.map(t=>h(t,n))};default:k(e)}}function $e(e){switch(e.type){case"axis":return{type:"axis",id:e.id};case"column":return{type:"column",id:e.id}}}function X(e){return g(e)}function Je(e){return JSON.parse(e)}function F(e){return g(p(e))}function O(e,n){return JSON.stringify([e,n])}class je{constructor(n){l(this,"domains",new Map);l(this,"axes",new Map);l(this,"domainPacks",[]);l(this,"domainPackToAnchor",new Map);this.anchors=n;const t=Object.entries(n);t.sort((r,o)=>r[0].localeCompare(o[0]));for(const[r,o]of t){for(let i=0;i<o.axesSpec.length;i++){const a=o.axesSpec[i],s=F(a);this.axes.set(s,{anchor:r,idx:i})}if(o.domain!==void 0){const i=Object.entries(o.domain);i.sort((a,s)=>a[0].localeCompare(s[0])),this.domainPackToAnchor.set(JSON.stringify(i),r),this.domainPacks.push(i.map(([a])=>a));for(const[a,s]of i){const u=O(a,s);this.domains.set(u,r)}}}}derive(n,t){const r={name:n.name,axes:[]};let o;if(n.domain!==void 0)e:for(const a of this.domainPacks){const s=[];for(const c of a){const f=n.domain[c];if(f!==void 0)s.push([c,f]);else break e}const u=this.domainPackToAnchor.get(JSON.stringify(s));if(u!==void 0){r.domainAnchor=u,o=new Set(a);break}}for(const[a,s]of Object.entries(n.domain??{})){if(o!==void 0&&o.has(a))continue;const u=O(a,s),c=this.domains.get(u);r.domain??(r.domain={}),r.domain[a]=c?{anchor:c}:s}if(r.axes=n.axesSpec.map(a=>{const s=F(a),u=this.axes.get(s);return u===void 0?p(a):u}),!t||t.length===0)return r;const i=[];for(const a of t){const[s,u]=a;if(typeof s=="number"){if(s<0||s>=n.axesSpec.length)throw new Error(`Axis index ${s} is out of bounds (0-${n.axesSpec.length-1})`);i.push([s,u])}else{const c=n.axesSpec.findIndex(f=>f.name===s);if(c===-1)throw new Error(`Axis with name "${s}" not found in the column specification`);i.push([c,u])}}return i.sort((a,s)=>a[0]-s[0]),{source:r,axisFilters:i}}deriveS(n,t){return X(this.derive(n,t))}}function De(e,n,t){const r={...n},o=(t==null?void 0:t.ignoreMissingDomains)??!1;if(r.domainAnchor!==void 0){const i=e[r.domainAnchor];if(!i)throw new Error(`Anchor "${r.domainAnchor}" not found`);const a=i.domain||{};r.domain={...a,...r.domain},delete r.domainAnchor}if(r.domain){const i={};for(const[a,s]of Object.entries(r.domain))if(typeof s=="string")i[a]=s;else{const u=e[s.anchor];if(!u)throw new Error(`Anchor "${s.anchor}" not found for domain key "${a}"`);if(!u.domain||u.domain[a]===void 0){if(!o)throw new Error(`Domain key "${a}" not found in anchor "${s.anchor}"`);continue}i[a]=u.domain[a]}r.domain=i}return r.axes&&(r.axes=r.axes.map(i=>Le(e,i))),r}function Le(e,n){if(!Be(n))return n;const t=n.anchor,r=e[t];if(!r)throw new Error(`Anchor "${t}" not found for axis reference`);if("idx"in n){if(n.idx<0||n.idx>=r.axesSpec.length)throw new Error(`Axis index ${n.idx} out of bounds for anchor "${t}"`);return r.axesSpec[n.idx]}else if("name"in n){const o=r.axesSpec.filter(i=>i.name===n.name);if(o.length>1)throw new Error(`Multiple axes with name "${n.name}" found in anchor "${t}"`);if(o.length===0)throw new Error(`Axis with name "${n.name}" not found in anchor "${t}"`);return o[0]}else if("id"in n){const o=r.axesSpec.filter(i=>G(n.id,p(i)));if(o.length>1)throw new Error(`Multiple matching axes found for matcher in anchor "${t}"`);if(o.length===0)throw new Error(`No matching axis found for matcher in anchor "${t}"`);return o[0]}throw new Error("Unsupported axis reference type")}function Be(e){return typeof e=="object"&&"anchor"in e}function ze(e){return typeof e=="object"&&e!==null&&"source"in e&&"axisFilters"in e}function d(e){return e.kind==="PColumn"}function Q(e){return d(e.spec)}function Ue(e){return d(e.obj)}function Te(e){return d(e.obj.spec)}function Me(e){if(!Q(e))throw new Error(`not a PColumn (kind = ${e.spec.kind})`);return e}function Ke(e,n){return e===void 0?void 0:{...e,data:n(e.data)}}function qe(e){const n=new Map,t=r=>{switch(r.type){case"column":n.set(r.column.id,r.column);return;case"slicedColumn":n.set(r.column.id,r.column);return;case"inlineColumn":return;case"full":case"inner":for(const o of r.entries)t(o);return;case"outer":t(r.primary);for(const o of r.secondary)t(o);return;default:k(r)}};return t(e),[...n.values()]}function _e(e){throw new Error("Unexpected object: "+e)}function w(e,n){switch(e.type){case"and":for(const t of e.operands)if(!w(t,n))return!1;return!0;case"or":for(const t of e.operands)if(w(t,n))return!0;return!1;case"not":return!w(e.operand,n);case"name":return d(n)&&n.name===e.name;case"name_pattern":return d(n)&&!!n.name.match(e.pattern);case"annotation":return d(n)&&n.annotations!==void 0&&n.annotations[e.annotation]===e.value;case"annotation_pattern":return d(n)&&n.annotations!==void 0&&n.annotations[e.annotation]!==void 0&&!!n.annotations[e.annotation].match(e.pattern);case"has_axes":return d(n)&&e.axes.every(t=>n.axesSpec.some(r=>(t.type===void 0||t.type===r.type)&&(t.name===void 0||t.name===r.name)&&(t.domain===void 0||Object.keys(t.domain).length===0||r.domain!==void 0&&Object.entries(t.domain).every(([o,i])=>r.domain[o]===i))));default:_e(e)}}function E(e,n){if(e.name!==void 0&&e.name!==n.name)return!1;if(e.type!==void 0){if(Array.isArray(e.type)){if(!e.type.includes(n.type))return!1}else if(e.type!==n.type)return!1}if(e.domain!==void 0){const t=n.domain||{};for(const[r,o]of Object.entries(e.domain))if(t[r]!==o)return!1}return!0}function x(e,n){if(n.name!==void 0&&e.name!==n.name||n.namePattern!==void 0&&!new RegExp(n.namePattern).test(e.name))return!1;if(n.type!==void 0){if(Array.isArray(n.type)){if(!n.type.includes(e.valueType))return!1}else if(n.type!==e.valueType)return!1}if(n.domain!==void 0){const t=e.domain||{};for(const[r,o]of Object.entries(n.domain))if(t[r]!==o)return!1}if(n.axes!==void 0){const t=e.axesSpec.map(p);if(n.partialAxesMatch){for(const r of n.axes)if(!t.some(o=>E(r,o)))return!1}else{if(t.length!==n.axes.length)return!1;for(let r=0;r<n.axes.length;r++)if(!E(n.axes[r],t[r]))return!1}}if(n.annotations!==void 0){const t=e.annotations||{};for(const[r,o]of Object.entries(n.annotations))if(t[r]!==o)return!1}if(n.annotationPatterns!==void 0){const t=e.annotations||{};for(const[r,o]of Object.entries(n.annotationPatterns)){const i=t[r];if(i===void 0||!new RegExp(o).test(i))return!1}}return!0}function He(e){return Array.isArray(e)?n=>e.some(t=>d(n)&&x(n,t)):n=>d(n)&&x(n,e)}function We(e){const n={kind:e.kind,name:e.name};return e.domain!==void 0&&(n.domain=e.domain),d(e)&&(n.axesSpec=S(e.axesSpec)),g(n)}const Ge={href:"/"},Xe=m.z.object({__isRef:m.z.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),blockId:m.z.string().describe("Upstream block id"),name:m.z.string().describe("Name of the output provided to the upstream block's output context"),requireEnrichments:m.z.literal(!0).optional().describe("True if current block that stores this reference in its args, may need enrichments for the references value originating from the blocks in between current and referenced block")}).describe("Universal reference type, allowing to set block connections. It is crucial that {@link __isRef} is present and equal to true, internal logic relies on this marker to build block dependency trees.").readonly();function Qe(e){return typeof e=="object"&&e!==null&&"__isRef"in e&&e.__isRef===!0&&"blockId"in e&&"name"in e}function Ye(e,n,t=!1){return t?{__isRef:!0,blockId:e,name:n,requireEnrichments:!0}:{__isRef:!0,blockId:e,name:n}}function Ze(e,n=!0){if(n)return{...e,requireEnrichments:!0};{const{requireEnrichments:t,...r}=e;return r}}function en(e,n,t=!1){return e.blockId===n.blockId&&e.name===n.name&&(t||e.requireEnrichments===n.requireEnrichments)}function nn(e,n){return e.ok?{ok:!0,value:n(e.value)}:e}function tn(e){if(e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray)return new DataView(e.buffer,e.byteOffset,e.byteLength);if(e instanceof ArrayBuffer)return new DataView(e);throw new TypeError("Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray")}const rn="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",on="0123456789ABCDEFGHIJKLMNOPQRSTUV",sn="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function Y(e,n,t){t=t||{};let r,o;switch(n){case"RFC3548":case"RFC4648":r=rn,o=!0;break;case"RFC4648-HEX":r=on,o=!0;break;case"Crockford":r=sn,o=!1;break;default:throw new Error("Unknown base32 variant: "+String(n))}const i=t.padding!==void 0?t.padding:o,a=tn(e);let s=0,u=0,c="";for(let f=0;f<a.byteLength;f++)for(u=u<<8|a.getUint8(f),s+=8;s>=5;)c+=r[u>>>s-5&31],s-=5;if(s>0&&(c+=r[u<<5-s&31]),i)for(;c.length%8!==0;)c+="=";return c}const I=15,Z=24,N=m.z.string().length(Z).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");function an(){const e=new Uint8Array(I);return crypto.getRandomValues(e),N.parse(Y(e,"RFC4648"))}function ee(e){if(e.length!==I)throw new Error(`Wrong number of bytes: ${e.length}`);return N.parse(Y(e,"RFC4648"))}async function un(e){const n=new TextEncoder,t=await crypto.subtle.digest("SHA-256",n.encode(e));return ee(new Uint8Array(t.slice(0,15)))}function cn(e){return JSON.stringify(e)}function fn(e){return g(e)}function dn(e){return JSON.parse(e)}class ln extends Error{constructor(){super(...arguments);l(this,"name","AbortError")}}class mn extends Error{constructor(){super(...arguments);l(this,"name","UiError")}}function pn(e){return e instanceof Error&&e.name==="AbortError"}function ne(e){return e instanceof Error?e.name==="AbortError"||ne(e.cause):!1}function yn(e){return e instanceof Error&&e.name==="AggregateError"}class hn extends Error{constructor(){super(...arguments);l(this,"name","PFrameError")}}function gn(e){return e instanceof Error&&e.name==="PFrameError"}function bn(e){if(typeof e=="string")return`String value was thrown: ${e}`;if(e&&typeof e=="object")try{return`Plain object was thrown: ${JSON.stringify(e)}`}catch(n){return`Non-serializable object was thrown (JSON.stringify failed: ${n instanceof Error?n.message:String(n)}): ${String(e)}`}return`Non-Error value (${typeof e}) was thrown: ${e}`}function A(e){return e instanceof Error?e:new Error(bn(e))}function v(e){const n=e.cause?v(e.cause):void 0,t=new Error(e.message,n!==void 0?{cause:n}:void 0);return t.name=e.name||"Error",t.stack=e.stack,t}function C(e){const n=A(e),t=n.cause?C(n.cause):void 0;return{name:n.name,message:n.message,stack:n.stack,...n.cause!==void 0&&{cause:t}}}function wn(e){if(e.error)throw e.error;return e.value}function V(e){return e.error?{error:C(e.error)}:{value:e.value}}function An(e){return e.error?{error:v(e.error)}:{value:e.value}}function te(e){try{return{value:e()}}catch(n){return{error:A(n)}}}async function re(e){try{return{value:await e()}}catch(n){return{error:A(n)}}}function Pn(e){const n=te(e);return V(n)}async function En(e){const n=await re(e);return V(n)}const xn=["supportsLazyState"],kn=["requiresUIAPIVersion","requiresModelAPIVersion"];function Sn(e,n,t=!0){return e===void 0?!1:e[n]===t}function In(e){return e===void 0?new Set:new Set(Object.entries(e).filter(([n,t])=>n.startsWith("requires")&&t===!0).map(([n])=>n))}function Nn(e){return e===void 0?new Set:new Set(Object.entries(e).filter(([n,t])=>n.startsWith("supports")&&t===!0).map(([n])=>n))}class oe extends Error{constructor(t){super(`Some of the block requirements are not supported by the runtime: ${Array.from(t.entries()).map(([r,o])=>`${r}: ${o}`).join(", ")}`);l(this,"name","IncompatibleFlagsError");this.incompatibleFlags=t}}class vn{constructor(){l(this,"supportedRequirements",new Map)}addSupportedRequirement(n,t=!0){return this.supportedRequirements.has(n)||this.supportedRequirements.set(n,new Set),this.supportedRequirements.get(n).add(t),this}getIncompatibleFlags(n){if(n===void 0)return;const t=new Map;for(const[r,o]of Object.entries(n))if(r.startsWith("requires")){if(o===void 0)continue;const i=this.supportedRequirements.get(r);(i===void 0||!i.has(o))&&t.set(r,o)}return t.size===0?void 0:t}checkCompatibility(n){return this.getIncompatibleFlags(n)===void 0}throwIfIncompatible(n){const t=this.getIncompatibleFlags(n);if(t!==void 0)throw new oe(t)}}exports.AbortError=ln;exports.AllRequiresFeatureFlags=kn;exports.AllSupportsFeatureFlags=xn;exports.AnchoredIdDeriver=je;exports.DefaultNavigationState=Ge;exports.IncompatibleFlagsError=oe;exports.PFrameError=hn;exports.PTableAbsent=H;exports.PTableNA=W;exports.PValueBytesNA=U;exports.PValueDoubleNA=xe;exports.PValueFloatNA=Ee;exports.PValueIntNA=B;exports.PValueLongNA=P;exports.PValueStringNA=z;exports.PlId=N;exports.PlIdBytes=I;exports.PlIdLength=Z;exports.PlRef=Xe;exports.RangeBytes=fe;exports.RuntimeCapabilities=vn;exports.UiError=mn;exports.canonicalizeAxisId=Fe;exports.canonicalizeJson=fn;exports.checkBlockFlag=Sn;exports.createPlRef=Ye;exports.dataInfoToEntries=we;exports.deriveNativeId=We;exports.deserializeError=v;exports.deserializeResult=An;exports.digestPlId=un;exports.ensureError=A;exports.ensureNotNAPValue=ke;exports.ensurePColumn=Me;exports.entriesToDataInfo=Ae;exports.executePSpecPredicate=w;exports.extractAllColumns=qe;exports.extractAllRequirements=In;exports.extractAllSupports=Nn;exports.extractCodeWithInfo=ue;exports.extractConfigGeneric=ce;exports.getAxesId=S;exports.getAxisId=p;exports.getColumnIdAndSpec=Ve;exports.getFileNameFromHandle=ye;exports.getFilePathFromHandle=D;exports.getPColumnSpecId=Ce;exports.getPTableColumnId=$e;exports.hasAbortError=ne;exports.isAbortError=pn;exports.isAggregateError=yn;exports.isDataInfo=he;exports.isDataInfoEntries=L;exports.isFilteredPColumn=ze;exports.isImportFileHandleIndex=j;exports.isImportFileHandleUpload=J;exports.isLiveLog=me;exports.isNotNAPValue=T;exports.isPColumn=Q;exports.isPColumnResult=Te;exports.isPColumnSpec=d;exports.isPColumnSpecResult=Ue;exports.isPFrameError=gn;exports.isPTableAbsent=Ne;exports.isPValue=M;exports.isPartitionedDataInfoEntries=be;exports.isPlRef=Qe;exports.isValueAbsent=_;exports.isValueNA=b;exports.mapDataInfo=ge;exports.mapDataInfoEntries=Pe;exports.mapJoinEntry=h;exports.mapPObjectData=Ke;exports.mapPTableDef=Re;exports.mapValueInVOE=nn;exports.matchAxis=E;exports.matchAxisId=G;exports.matchPColumn=x;exports.newRangeBytesOpt=de;exports.pTableValue=ve;exports.pValueToStringOrNumber=Ie;exports.pValueToStringOrNumberOrNull=q;exports.parseColumnId=Je;exports.parseJson=dn;exports.plId=ee;exports.plRefsEqual=en;exports.resolveAnchors=De;exports.safeConvertToPValue=K;exports.selectorsToPredicate=He;exports.serializeError=C;exports.serializeResult=V;exports.stringifyColumnId=X;exports.stringifyJson=cn;exports.toJsonSafePValue=Se;exports.uniquePlId=an;exports.unwrapResult=wn;exports.validateRangeBytes=le;exports.withEnrichments=Ze;exports.wrapAndSerialize=Pn;exports.wrapAndSerializeAsync=En;exports.wrapAsyncCallback=re;exports.wrapCallback=te;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|