@milaboratories/pl-model-common 1.9.0 → 1.10.1

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.
@@ -81,6 +81,12 @@ export interface PTableVector {
81
81
  }
82
82
  /** Used to read bit array with value absence information */
83
83
  export declare function isValueAbsent(absent: Uint8Array, index: number): boolean;
84
+ export type PColumnValue = null | number | string;
85
+ export type PColumnValuesEntry = {
86
+ key: PColumnValue[];
87
+ val: PColumnValue;
88
+ };
89
+ export type PColumnValues = PColumnValuesEntry[];
84
90
  export declare const PTableNull: {
85
91
  type: string;
86
92
  };
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/drivers/pframe/data.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,eAAO,MAAM,WAAW,cAAc,CAAC;AACvC,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAC/C,eAAO,MAAM,aAAa,QAAM,CAAC;AACjC,eAAO,MAAM,cAAc,QAAM,CAAC;AAClC,eAAO,MAAM,cAAc,MAAO,CAAC;AACnC,eAAO,MAAM,aAAa,MAAO,CAAC;AAElC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AACzC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AACjC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,IAAI,CAAC;AACzC,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,IAAI,CAAC;AAE5C,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AACpC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AAC9C,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACtC,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACvC,MA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AAkB,EAAE,CAAC;AAEjD,eAAO,MAAM,UAAU;;CAAqB,CAAC;AAC7C,eAAO,MAAM,QAAQ,MAAO,CAAC;AAE7B,2BAA2B;AAC3B,MAAM,MAAM,WAAW,GACnB,OAAO,UAAU,GACjB,OAAO,QAAQ,GACf,MAAM,GAAG,MAAM,CAAC;AAEpB,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,CAuB1E;AAED,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG;IACvB,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,mBAAmB;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,WAAW,GAAG;IACxB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAEhB,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("zod");function D(t){return t!==void 0&&t.startsWith("log+live://log/")}function c(t){throw new Error("Unexpected object: "+t)}const l="upload://upload/",p="index://index/";function d(t){return t.startsWith(l)}function m(t){return t.startsWith(p)}function b(t){if(m(t)){const n=t.slice(p.length);return JSON.parse(decodeURIComponent(n)).path}else if(d(t)){const n=t.slice(l.length);return JSON.parse(decodeURIComponent(n)).localPath}c(t)}function O(t){return t.replace(/^.*[\\/]/,"")}function B(t){return O(b(t))}const y=-2147483648,f=-9007199254740991n,g=NaN,P=NaN,N=null,V=null;function u(t,n){switch(n){case"Int":return t===y;case"Long":return t===Number(f)||t===f;case"Float":return t===g;case"Double":return t===P;case"String":return t===N;case"Bytes":return t===V;default:throw Error(`unsupported data type: ${n}`)}}function R(t){if(!w(t))throw new Error(`Expected not-NA PValue, got ${t}`);return t}function w(t,n){if(!n)return typeof t=="string"||typeof t=="number"&&isFinite(t)||typeof t=="bigint";if(u(t,n))return!1;switch(n){case"Int":return typeof t=="number";case"Long":return typeof t=="number"||typeof t=="bigint";case"Float":return typeof t=="number";case"Double":return typeof t=="number";case"String":return typeof t=="string";case"Bytes":throw Error("Bytes not yet supported");default:throw Error(`unsupported data type: ${n}`)}}function h(t,n){if(!n)return t===null||typeof t=="string"||typeof t=="number"||typeof t=="bigint";if(u(t,n))return!0;switch(n){case"Int":return typeof t=="number";case"Long":return typeof t=="number"||typeof t=="bigint";case"Float":return typeof t=="number";case"Double":return typeof t=="number";case"String":return typeof t=="string";case"Bytes":throw Error("Bytes not yet supported");default:throw Error(`unsupported data type: ${n}`)}}function U(t){if(t===null||typeof t=="string"||typeof t=="number")return t;if(typeof t=="bigint")return{bigint:t.toString()};throw new Error(`Type ${typeof t} (value ${t}) not yet supported.`)}function A(t,n){if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="bigint"){if(n&&!u(t,n)&&!h(t,n))throw new Error(`Unexpected value type, got ${typeof t}, expected ${n}`);return t}if(typeof t=="object"&&t!==null&&"bigint"in t&&typeof t.bigint=="string"){if(n&&n!=="Long")throw new Error(`Unexpected value type, got serialized bigint, expected ${n}`);return BigInt(t.bigint)}throw new Error(`Unsupported type ${typeof t} (value ${t}).`)}function L(t){if(t=I(t),t===null)throw new Error("Value is null");return t}function I(t){if(t=A(t),t===null)return null;if(typeof t=="string")return t;if(typeof t=="number"){if(!isFinite(t))throw new Error(`Value is not finite (${t})`);return t}if(typeof t=="bigint")return Number(t);throw new Error(`Unexpected value type: ${typeof t}`)}function x(t,n){const e=Math.floor(n/8),r=1<<7-n%8;return(t[e]&r)>0}const E={type:"absent"},S=null;function H(t,n){if(x(t.absent,n))return E;const e=t.data[n],r=t.type;if(u(e,r))return S;switch(r){case"Int":return e;case"Long":return Number(e);case"Float":return e;case"Double":return e;case"String":return e;case"Bytes":throw Error("Bytes not yet supported");default:throw Error(`unsupported data type: ${r}`)}}function F(t){const{type:n,name:e,domain:r}=t;return{type:n,name:e,...r&&{domain:r}}}function j(t){return t.map(F)}function _(t,n){if(t===void 0)return n===void 0;if(n===void 0)return!0;for(const e in n)if(t[e]!==n[e])return!1;return!0}function z(t,n){return t.name===n.name&&_(t.domain,n.domain)}function J(t,n){return{...t,src:i(t.src,n)}}function i(t,n){switch(t.type){case"column":return{type:"column",column:n(t.column)};case"inner":case"full":return{type:t.type,entries:t.entries.map(e=>i(e,n))};case"outer":return{type:"outer",primary:i(t.primary,n),secondary:t.secondary.map(e=>i(e,n))};default:c(t)}}const T={href:"/"},W=s.z.object({__isRef:s.z.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),blockId:s.z.string().describe("Upstream block id"),name:s.z.string().describe("Name of the output provided to the upstream block's output context")}).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.").strict().readonly();function q(t,n){return t.blockId===n.blockId&&t.name===n.name}function o(t){return t.kind==="PColumn"}function C(t){return o(t.spec)}function M(t){return o(t.obj)}function G(t){return o(t.obj.spec)}function K(t){if(!C(t))throw new Error(`not a PColumn (kind = ${t.spec.kind})`);return t}function Q(t,n){return t===void 0?void 0:{...t,data:n(t.data)}}function X(t){throw new Error("Unexpected object: "+t)}function a(t,n){switch(t.type){case"and":for(const e of t.operands)if(!a(e,n))return!1;return!0;case"or":for(const e of t.operands)if(a(e,n))return!0;return!1;case"not":return!a(t.operand,n);case"name":return o(n)&&n.name===t.name;case"name_pattern":return o(n)&&!!n.name.match(t.pattern);case"annotation":return o(n)&&n.annotations!==void 0&&n.annotations[t.annotation]===t.value;case"annotation_pattern":return o(n)&&n.annotations!==void 0&&n.annotations[t.annotation]!==void 0&&!!n.annotations[t.annotation].match(t.pattern);case"has_axes":return o(n)&&t.axes.every(e=>n.axesSpec.some(r=>(e.type===void 0||e.type===r.type)&&(e.name===void 0||e.name===r.name)&&(e.domain===void 0||Object.keys(e.domain).length===0||r.domain!==void 0&&Object.entries(e.domain).every(([$,k])=>r.domain[$]===k))));default:X(t)}}function Y(t,n){return t.ok?{ok:!0,value:n(t.value)}:t}exports.DefaultNavigationState=T;exports.PTableNA=S;exports.PTableNull=E;exports.PValueBytesNA=V;exports.PValueDoubleNA=P;exports.PValueFloatNA=g;exports.PValueIntNA=y;exports.PValueLongNA=f;exports.PValueStringNA=N;exports.PlRef=W;exports.ensureNotNAPValue=R;exports.ensurePColumn=K;exports.executePSpecPredicate=a;exports.getAxesId=j;exports.getAxisId=F;exports.getFileNameFromHandle=B;exports.getFilePathFromHandle=b;exports.isImportFileHandleIndex=m;exports.isImportFileHandleUpload=d;exports.isLiveLog=D;exports.isNotNAPValue=w;exports.isPColumn=C;exports.isPColumnResult=G;exports.isPColumnSpec=o;exports.isPColumnSpecResult=M;exports.isPValue=h;exports.isValueAbsent=x;exports.isValueNA=u;exports.mapJoinEntry=i;exports.mapPObjectData=Q;exports.mapPTableDef=J;exports.mapValueInVOE=Y;exports.matchAxisId=z;exports.pTableValue=H;exports.pValueToStringOrNumber=L;exports.pValueToStringOrNumberOrNull=I;exports.plRefsEqual=q;exports.safeConvertToPValue=A;exports.toJsonSafePValue=U;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("zod");function D(t){return t!==void 0&&t.startsWith("log+live://log/")}function f(t){throw new Error("Unexpected object: "+t)}const d="upload://upload/",p="index://index/";function m(t){return t.startsWith(d)}function b(t){return t.startsWith(p)}function g(t){if(b(t)){const n=t.slice(p.length);return JSON.parse(decodeURIComponent(n)).path}else if(m(t)){const n=t.slice(d.length);return JSON.parse(decodeURIComponent(n)).localPath}f(t)}function O(t){return t.replace(/^.*[\\/]/,"")}function B(t){return O(g(t))}const y=-2147483648,l=-9007199254740991n,P=NaN,N=NaN,V=null,w=null;function s(t,n){switch(n){case"Int":return t===y;case"Long":return t===Number(l)||t===l;case"Float":return t===P;case"Double":return t===N;case"String":return t===V;case"Bytes":return t===w;default:throw Error(`unsupported data type: ${n}`)}}function R(t){if(!h(t))throw new Error(`Expected not-NA PValue, got ${t}`);return t}function h(t,n){if(!n)return typeof t=="string"||typeof t=="number"&&isFinite(t)||typeof t=="bigint";if(s(t,n))return!1;switch(n){case"Int":return typeof t=="number";case"Long":return typeof t=="number"||typeof t=="bigint";case"Float":return typeof t=="number";case"Double":return typeof t=="number";case"String":return typeof t=="string";case"Bytes":throw Error("Bytes not yet supported");default:throw Error(`unsupported data type: ${n}`)}}function A(t,n){if(!n)return t===null||typeof t=="string"||typeof t=="number"||typeof t=="bigint";if(s(t,n))return!0;switch(n){case"Int":return typeof t=="number";case"Long":return typeof t=="number"||typeof t=="bigint";case"Float":return typeof t=="number";case"Double":return typeof t=="number";case"String":return typeof t=="string";case"Bytes":throw Error("Bytes not yet supported");default:throw Error(`unsupported data type: ${n}`)}}function U(t){if(t===null||typeof t=="string"||typeof t=="number")return t;if(typeof t=="bigint")return{bigint:t.toString()};throw new Error(`Type ${typeof t} (value ${t}) not yet supported.`)}function I(t,n){if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="bigint"){if(n&&!s(t,n)&&!A(t,n))throw new Error(`Unexpected value type, got ${typeof t}, expected ${n}`);return t}if(typeof t=="object"&&t!==null&&"bigint"in t&&typeof t.bigint=="string"){if(n&&n!=="Long")throw new Error(`Unexpected value type, got serialized bigint, expected ${n}`);return BigInt(t.bigint)}throw new Error(`Unsupported type ${typeof t} (value ${t}).`)}function L(t){if(t=x(t),t===null)throw new Error("Value is null");return t}function x(t){if(t=I(t),t===null)return null;if(typeof t=="string")return t;if(typeof t=="number"){if(!isFinite(t))throw new Error(`Value is not finite (${t})`);return t}if(typeof t=="bigint")return Number(t);throw new Error(`Unexpected value type: ${typeof t}`)}function E(t,n){const e=Math.floor(n/8),r=1<<7-n%8;return(t[e]&r)>0}const S={type:"absent"},F=null;function H(t,n){if(E(t.absent,n))return S;const e=t.data[n],r=t.type;if(s(e,r))return F;switch(r){case"Int":return e;case"Long":return Number(e);case"Float":return e;case"Double":return e;case"String":return e;case"Bytes":throw Error("Bytes not yet supported");default:throw Error(`unsupported data type: ${r}`)}}function C(t){const{type:n,name:e,domain:r}=t;return{type:n,name:e,...r&&{domain:r}}}function j(t){return t.map(C)}function _(t,n){if(t===void 0)return n===void 0;if(n===void 0)return!0;for(const e in n)if(t[e]!==n[e])return!1;return!0}function z(t,n){return t.name===n.name&&_(t.domain,n.domain)}function J(t,n){return{...t,src:u(t.src,n)}}function u(t,n){switch(t.type){case"column":return{type:"column",column:n(t.column)};case"inner":case"full":return{type:t.type,entries:t.entries.map(e=>u(e,n))};case"outer":return{type:"outer",primary:u(t.primary,n),secondary:t.secondary.map(e=>u(e,n))};default:f(t)}}const T={href:"/"},M=a.z.object({__isRef:a.z.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),blockId:a.z.string().describe("Upstream block id"),name:a.z.string().describe("Name of the output provided to the upstream block's output context")}).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.").strict().readonly();function W(t,n){return t.blockId===n.blockId&&t.name===n.name}function o(t){return t.kind==="PColumn"}function $(t){return o(t.spec)}function q(t){return o(t.obj)}function G(t){return o(t.obj.spec)}function K(t){if(!$(t))throw new Error(`not a PColumn (kind = ${t.spec.kind})`);return t}function Q(t,n){return t===void 0?void 0:{...t,data:n(t.data)}}function X(t){const n=new Map,e=r=>{switch(r.type){case"column":n.set(r.column.id,r.column);return;case"full":case"inner":for(const i of r.entries)e(i);return;case"outer":e(r.primary);for(const i of r.secondary)e(i);return;default:f(r)}};return e(t),[...n.values()]}function Y(t){throw new Error("Unexpected object: "+t)}function c(t,n){switch(t.type){case"and":for(const e of t.operands)if(!c(e,n))return!1;return!0;case"or":for(const e of t.operands)if(c(e,n))return!0;return!1;case"not":return!c(t.operand,n);case"name":return o(n)&&n.name===t.name;case"name_pattern":return o(n)&&!!n.name.match(t.pattern);case"annotation":return o(n)&&n.annotations!==void 0&&n.annotations[t.annotation]===t.value;case"annotation_pattern":return o(n)&&n.annotations!==void 0&&n.annotations[t.annotation]!==void 0&&!!n.annotations[t.annotation].match(t.pattern);case"has_axes":return o(n)&&t.axes.every(e=>n.axesSpec.some(r=>(e.type===void 0||e.type===r.type)&&(e.name===void 0||e.name===r.name)&&(e.domain===void 0||Object.keys(e.domain).length===0||r.domain!==void 0&&Object.entries(e.domain).every(([i,k])=>r.domain[i]===k))));default:Y(t)}}function Z(t,n){return t.ok?{ok:!0,value:n(t.value)}:t}exports.DefaultNavigationState=T;exports.PTableNA=F;exports.PTableNull=S;exports.PValueBytesNA=w;exports.PValueDoubleNA=N;exports.PValueFloatNA=P;exports.PValueIntNA=y;exports.PValueLongNA=l;exports.PValueStringNA=V;exports.PlRef=M;exports.ensureNotNAPValue=R;exports.ensurePColumn=K;exports.executePSpecPredicate=c;exports.extractAllColumns=X;exports.getAxesId=j;exports.getAxisId=C;exports.getFileNameFromHandle=B;exports.getFilePathFromHandle=g;exports.isImportFileHandleIndex=b;exports.isImportFileHandleUpload=m;exports.isLiveLog=D;exports.isNotNAPValue=h;exports.isPColumn=$;exports.isPColumnResult=G;exports.isPColumnSpec=o;exports.isPColumnSpecResult=q;exports.isPValue=A;exports.isValueAbsent=E;exports.isValueNA=s;exports.mapJoinEntry=u;exports.mapPObjectData=Q;exports.mapPTableDef=J;exports.mapValueInVOE=Z;exports.matchAxisId=z;exports.pTableValue=H;exports.pValueToStringOrNumber=L;exports.pValueToStringOrNumberOrNull=x;exports.plRefsEqual=W;exports.safeConvertToPValue=I;exports.toJsonSafePValue=U;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/drivers/log.ts","../src/util.ts","../src/drivers/ls.ts","../src/drivers/pframe/data.ts","../src/drivers/pframe/spec.ts","../src/drivers/pframe/table_calculate.ts","../src/navigation.ts","../src/ref.ts","../src/pool/spec.ts","../src/pool/query.ts","../src/value_or_error.ts"],"sourcesContent":["/** Handle of logs. This handle should be passed\n * to the driver for retrieving logs. */\nexport type AnyLogHandle = LiveLogHandle | ReadyLogHandle;\n\n/** Handle of the live logs of a program.\n * The resource that represents a log can be deleted,\n * in this case the handle should be refreshed. */\nexport type LiveLogHandle = `log+live://log/${string}`;\n\n/** Handle of the ready logs of a program. */\nexport type ReadyLogHandle = `log+ready://log/${string}`;\n\n/** Type guard to check if log is live, and corresponding porcess is not finished. */\nexport function isLiveLog(handle: AnyLogHandle | undefined): handle is LiveLogHandle {\n return handle !== undefined && handle.startsWith('log+live://log/');\n}\n\n/** Driver to retrieve logs given log handle */\nexport interface LogsDriver {\n lastLines(\n /** A handle that was issued previously. */\n handle: AnyLogHandle,\n\n /** Allows client to limit total data sent from server. */\n lineCount: number,\n\n /** Makes streamer to perform seek operation to given offset before sending the contents.\n * Client can just use the <new_offset> value of the last response from server to continue streaming after reconnection.\n * If undefined, then starts from the end. */\n offsetBytes?: number,\n\n /** Is substring for line search pattern.\n * This option makes controller to send to the client only lines, that\n * have given substring. */\n searchStr?: string\n ): Promise<StreamingApiResponse>;\n\n readText(\n /** A handle that was issued previously. */\n handle: AnyLogHandle,\n\n /** Allows client to limit total data sent from server. */\n lineCount: number,\n\n /** Makes streamer to perform seek operation to given offset before sending the contents.\n * Client can just use the <new_offset> value of the last response from server to continue streaming after reconnection.\n * If undefined of 0, then starts from the beginning. */\n offsetBytes?: number,\n\n /** Is substring for line search pattern.\n * This option makes controller to send to the client only lines, that\n * have given substring. */\n searchStr?: string\n ): Promise<StreamingApiResponse>;\n}\n\n/** Response of the driver.\n * The caller should give a handle to retrieve it.\n * It can be OK or outdated, in which case the handle\n * should be issued again. */\nexport type StreamingApiResponse = StreamingApiResponseOk | StreamingApiResponseHandleOutdated;\n\nexport type StreamingApiResponseOk = {\n /** The handle don't have to be updated,\n * the response is OK. */\n shouldUpdateHandle: false;\n\n /** Whether the log can still grow or it's in a final state. */\n live: boolean;\n\n /** Data of the response, in bytes. */\n data: Uint8Array;\n /** Current size of the file. It can grow if it's still live. */\n size: number;\n /** Offset in bytes from the beginning of a file. */\n newOffset: number;\n};\n\n/** The handle should be issued again, this one is done. */\nexport type StreamingApiResponseHandleOutdated = {\n shouldUpdateHandle: true;\n};\n","export function assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x);\n}\n","import { assertNever } from '../util';\nimport { Branded } from '../branding';\nimport { TableRange } from './pframe';\nimport { FileLike } from './interfaces';\n\nconst uploadPrefix = 'upload://upload/';\nconst indexPrefix = 'index://index/';\n\nexport type ImportFileHandleUpload = `upload://upload/${string}`;\nexport type ImportFileHandleIndex = `index://index/${string}`;\n\nexport type ImportFileHandle = ImportFileHandleUpload | ImportFileHandleIndex;\n\nexport type LocalImportFileHandle = Branded<ImportFileHandle, 'Local'>;\n\nexport function isImportFileHandleUpload(\n handle: ImportFileHandle\n): handle is ImportFileHandleUpload {\n return handle.startsWith(uploadPrefix);\n}\n\nexport function isImportFileHandleIndex(handle: ImportFileHandle): handle is ImportFileHandleIndex {\n return handle.startsWith(indexPrefix);\n}\n\n/** Results in upload */\nexport type StorageHandleLocal = `local://${string}`;\n\n/** Results in index */\nexport type StorageHandleRemote = `remote://${string}`;\n\nexport type StorageHandle = StorageHandleLocal | StorageHandleRemote;\n\nexport type StorageEntry = {\n name: string;\n handle: StorageHandle;\n initialFullPath: string;\n\n // TODO\n // pathStartsWithDisk\n};\n\nexport type ListFilesResult = {\n parent?: string;\n entries: LsEntry[];\n};\n\nexport type LsEntry =\n | {\n type: 'dir';\n name: string;\n fullPath: string;\n }\n | {\n type: 'file';\n name: string;\n fullPath: string;\n\n /** This handle should be set to args... */\n handle: ImportFileHandle;\n };\n\nexport type OpenDialogFilter = {\n /** Human-readable file type name */\n readonly name: string;\n /** File extensions */\n readonly extensions: string[];\n};\n\nexport type OpenDialogOps = {\n /** Open dialog window title */\n readonly title?: string;\n /** Custom label for the confirmation button, when left empty the default label will be used. */\n readonly buttonLabel?: string;\n /** Limits of file types user can select */\n readonly filters?: OpenDialogFilter[];\n};\n\nexport type OpenSingleFileResponse = {\n /** Contains local file handle, allowing file importing or content reading. If user canceled\n * the dialog, field will be undefined. */\n readonly file?: LocalImportFileHandle;\n};\n\nexport type OpenMultipleFilesResponse = {\n /** Contains local file handles, allowing file importing or content reading. If user canceled\n * the dialog, field will be undefined. */\n readonly files?: LocalImportFileHandle[];\n};\n\n/** Can be used to limit request for local file content to a certain bytes range */\nexport type FileRange = {\n /** From byte index (inclusive) */\n readonly from: number;\n /** To byte index (exclusive) */\n readonly to: number;\n};\n\nexport interface LsDriver {\n /** remote and local storages */\n getStorageList(): Promise<StorageEntry[]>;\n\n listFiles(storage: StorageHandle, fullPath: string): Promise<ListFilesResult>;\n\n /** Opens system file open dialog allowing to select single file and awaits user action */\n showOpenSingleFileDialog(ops: OpenDialogOps): Promise<OpenSingleFileResponse>;\n\n /** Opens system file open dialog allowing to multiple files and awaits user action */\n showOpenMultipleFilesDialog(ops: OpenDialogOps): Promise<OpenMultipleFilesResponse>;\n\n /** Given a handle to a local file, allows to get file size */\n getLocalFileSize(file: LocalImportFileHandle): Promise<number>;\n\n /** Given a handle to a local file, allows to get its content */\n getLocalFileContent(file: LocalImportFileHandle, range?: TableRange): Promise<Uint8Array>;\n\n /**\n * Resolves browser's File object into platforma's import file handle.\n *\n * This method is useful among other things for implementation of UI\n * components, that handle file Drag&Drop.\n * */\n fileToImportHandle(file: FileLike): Promise<ImportFileHandle>;\n}\n\n/** Gets a file path from an import handle. */\nexport function getFilePathFromHandle(handle: ImportFileHandle): string {\n if (isImportFileHandleIndex(handle)) {\n const trimmed = handle.slice(indexPrefix.length);\n const data = JSON.parse(decodeURIComponent(trimmed));\n return data.path;\n } else if (isImportFileHandleUpload(handle)) {\n const trimmed = handle.slice(uploadPrefix.length);\n const data = JSON.parse(decodeURIComponent(trimmed));\n return data.localPath;\n }\n\n assertNever(handle);\n}\n\nfunction extractFileName(filePath: string) {\n return filePath.replace(/^.*[\\\\/]/, '');\n}\n\n/** Gets a file name from an import handle. */\nexport function getFileNameFromHandle(handle: ImportFileHandle): string {\n return extractFileName(getFilePathFromHandle(handle));\n}\n","import { number } from 'zod';\nimport { ValueType } from './spec';\n\nexport const PValueIntNA = -2147483648;\nexport const PValueLongNA = -9007199254740991n;\nexport const PValueFloatNA = NaN;\nexport const PValueDoubleNA = NaN;\nexport const PValueStringNA = null;\nexport const PValueBytesNA = null;\n\nexport type PValueInt = number;\nexport type PValueLong = number | bigint; // use bigint only if extra integer precision is needed\nexport type PValueFloat = number;\nexport type PValueDouble = number;\nexport type PValueString = string | null;\nexport type PValueBytes = Uint8Array | null;\n\nexport type NotNAPValueInt = number;\nexport type NotNAPValueLong = number | bigint; // use bigint only if extra integer precision is needed\nexport type NotNAPValueFloat = number;\nexport type NotNAPValueDouble = number;\nexport type NotNAPValueString = string;\n\nexport type NotNAPValue = number | bigint | string;\n\nexport type PValue =\n | PValueInt\n | PValueLong\n | PValueFloat\n | PValueDouble\n | PValueString\n | PValueBytes;\n\nexport function isValueNA(value: unknown, valueType: ValueType): boolean {\n switch (valueType) {\n case 'Int':\n return value === PValueIntNA;\n case 'Long':\n return value === Number(PValueLongNA) || value === PValueLongNA;\n case 'Float':\n return value === PValueFloatNA;\n case 'Double':\n return value === PValueDoubleNA;\n case 'String':\n return value === PValueStringNA;\n case 'Bytes':\n return value === PValueBytesNA;\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\nexport function ensureNotNAPValue(value: string): string;\nexport function ensureNotNAPValue(value: number): number;\nexport function ensureNotNAPValue(value: bigint): bigint;\nexport function ensureNotNAPValue(value: unknown): NotNAPValue;\nexport function ensureNotNAPValue(value: unknown): NotNAPValue {\n if (!isNotNAPValue(value)) throw new Error(`Expected not-NA PValue, got ${value}`);\n return value;\n}\n\nexport function isNotNAPValue(value: unknown, valueType: 'Int'): value is number;\nexport function isNotNAPValue(value: unknown, valueType: 'Long'): value is number | bigint;\nexport function isNotNAPValue(value: unknown, valueType: 'Float'): value is number;\nexport function isNotNAPValue(value: unknown, valueType: 'Double'): value is number;\nexport function isNotNAPValue(value: unknown, valueType: 'String'): value is string;\nexport function isNotNAPValue(value: unknown, valueType: ValueType): value is NotNAPValue;\nexport function isNotNAPValue(value: unknown): value is NotNAPValue;\nexport function isNotNAPValue(value: unknown, valueType?: ValueType): boolean {\n if (!valueType)\n return (\n typeof value === 'string' ||\n (typeof value === 'number' && isFinite(value)) ||\n typeof value === 'bigint'\n );\n if (isValueNA(value, valueType)) return false;\n switch (valueType) {\n case 'Int':\n return typeof value === 'number';\n case 'Long':\n return typeof value === 'number' || typeof value === 'bigint';\n case 'Float':\n return typeof value === 'number';\n case 'Double':\n return typeof value === 'number';\n case 'String':\n return typeof value === 'string';\n case 'Bytes':\n throw Error(`Bytes not yet supported`);\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\nexport function isPValue(value: unknown, valueType: 'Int'): value is PValueInt;\nexport function isPValue(value: unknown, valueType: 'Long'): value is PValueLong;\nexport function isPValue(value: unknown, valueType: 'Float'): value is PValueFloat;\nexport function isPValue(value: unknown, valueType: 'Double'): value is PValueDouble;\nexport function isPValue(value: unknown, valueType: 'String'): value is PValueString;\nexport function isPValue(value: unknown, valueType: ValueType): value is PValue;\nexport function isPValue(value: unknown): value is PValue;\nexport function isPValue(value: unknown, valueType?: ValueType): boolean {\n if (!valueType)\n return (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'bigint'\n );\n if (isValueNA(value, valueType)) return true;\n switch (valueType) {\n case 'Int':\n return typeof value === 'number';\n case 'Long':\n return typeof value === 'number' || typeof value === 'bigint';\n case 'Float':\n return typeof value === 'number';\n case 'Double':\n return typeof value === 'number';\n case 'String':\n return typeof value === 'string';\n case 'Bytes':\n throw Error(`Bytes not yet supported`);\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\nexport type PValueLongJsonSafe = { bigint: string };\nexport type PValueJsonSafe = number | string | null | PValueLongJsonSafe;\n\n/**\n * Converts PValue to value that can be safely serialized by standard JSON.stringify\n * method. Use {@link safeConvertToPValue} to \"deserialize\" the value back to runtime\n * PValue representation.\n */\nexport function toJsonSafePValue(value: PValue): PValueJsonSafe {\n if (value === null || typeof value === 'string' || typeof value === 'number') return value;\n if (typeof value === 'bigint') return { bigint: value.toString() };\n throw new Error(`Type ${typeof value} (value ${value}) not yet supported.`);\n}\n\n/**\n * Can be used to \"deserialize\" result of {@link toJsonSafePValue} or to\n * safely cast any unknown value to actual runtime PValue representation.\n */\nexport function safeConvertToPValue(value: unknown, checkType?: ValueType): PValue {\n if (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'bigint'\n ) {\n if (checkType && !isValueNA(value, checkType) && !isPValue(value, checkType))\n throw new Error(`Unexpected value type, got ${typeof value}, expected ${checkType}`);\n return value;\n }\n\n if (\n typeof value === 'object' &&\n value !== null &&\n 'bigint' in value &&\n typeof value.bigint === 'string'\n ) {\n if (checkType && checkType !== 'Long')\n throw new Error(`Unexpected value type, got serialized bigint, expected ${checkType}`);\n\n return BigInt(value.bigint);\n }\n\n throw new Error(`Unsupported type ${typeof value} (value ${value}).`);\n}\n\nexport function pValueToStringOrNumber(value: string): string;\nexport function pValueToStringOrNumber(value: number | bigint): number;\nexport function pValueToStringOrNumber(value: PValue | PValueJsonSafe): string | number;\nexport function pValueToStringOrNumber(value: PValue | PValueJsonSafe): string | number {\n value = pValueToStringOrNumberOrNull(value);\n if (value === null) throw new Error('Value is null');\n return value;\n}\n\nexport function pValueToStringOrNumberOrNull(value: string | null): string;\nexport function pValueToStringOrNumberOrNull(value: number | bigint | null): number;\nexport function pValueToStringOrNumberOrNull(\n value: PValue | PValueJsonSafe\n): string | number | null;\nexport function pValueToStringOrNumberOrNull(\n value: PValue | PValueJsonSafe\n): string | number | null {\n value = safeConvertToPValue(value);\n if (value === null) return null;\n if (typeof value === 'string') return value;\n if (typeof value === 'number') {\n if (!isFinite(value)) throw new Error(`Value is not finite (${value})`);\n return value;\n }\n if (typeof value === 'bigint') {\n // @TODO add range check\n return Number(value);\n }\n throw new Error(`Unexpected value type: ${typeof value}`);\n}\n\nexport type PVectorDataInt = Int32Array;\nexport type PVectorDataLong = BigInt64Array;\nexport type PVectorDataFloat = Float32Array;\nexport type PVectorDataDouble = Float64Array;\nexport type PVectorDataString = PValueString[];\nexport type PVectorDataBytes = PValueBytes[];\n\nexport type PVectorData =\n | PVectorDataInt\n | PVectorDataLong\n | PVectorDataFloat\n | PVectorDataDouble\n | PVectorDataString\n | PVectorDataBytes;\n\n/** Table column data in comparison to the data stored in a separate PColumn\n * may have some of the values \"absent\", i.e. as a result of missing record in\n * outer join operation. This information is encoded in {@link absent} field. */\nexport interface PTableVector {\n /** Stored data type */\n readonly type: ValueType;\n\n /** Values for present positions, absent positions have NA values */\n readonly data: PVectorData;\n\n /**\n * Encoded bit array marking some elements of this vector as absent,\n * call {@link isValueAbsent} to read the data.\n * */\n readonly absent: Uint8Array;\n}\n\n/** Used to read bit array with value absence information */\nexport function isValueAbsent(absent: Uint8Array, index: number): boolean {\n const chunkIndex = Math.floor(index / 8);\n const mask = 1 << (7 - (index % 8));\n return (absent[chunkIndex] & mask) > 0;\n}\n\nexport const PTableNull = { type: 'absent' };\nexport const PTableNA = null;\n\n/** Decoded PTable value */\nexport type PTableValue =\n | typeof PTableNull\n | typeof PTableNA\n | number | string;\n\n/** Read PTableValue from PTable column at specified row */\nexport function pTableValue(column: PTableVector, row: number): PTableValue {\n if (isValueAbsent(column.absent, row)) return PTableNull;\n\n const value = column.data[row];\n const valueType = column.type;\n if (isValueNA(value, valueType)) return PTableNA;\n\n switch (valueType) {\n case 'Int':\n return value as PVectorDataInt[number];\n case 'Long':\n return Number(value as PVectorDataLong[number]);\n case 'Float':\n return value as PVectorDataFloat[number];\n case 'Double':\n return value as PVectorDataDouble[number];\n case 'String':\n return value as PVectorDataString[number];\n case 'Bytes':\n throw Error(`Bytes not yet supported`);\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\n/** Used in requests to partially retrieve table's data */\nexport type TableRange = {\n /** Index of the first record to retrieve */\n readonly offset: number;\n\n /** Block length */\n readonly length: number;\n};\n\n/** Unified information about table shape */\nexport type PTableShape = {\n /** Number of unified table columns, including all axes and PColumn values */\n columns: number;\n\n /** Number of rows */\n rows: number;\n};\n","import { PObject, PObjectId, PObjectSpec } from '../../pool';\n\n/** PFrame columns and axes within them may store one of these types. */\nexport type ValueType = 'Int' | 'Long' | 'Float' | 'Double' | 'String' | 'Bytes';\n\n/**\n * Specification of an individual axis.\n *\n * Each axis is a part of a composite key that addresses data inside the PColumn.\n *\n * Each record inside a PColumn is addressed by a unique tuple of values set for\n * all the axes specified in the column spec.\n * */\nexport interface AxisSpec {\n /** Type of the axis value. Should not use non-key types like float or double. */\n readonly type: ValueType;\n\n /** Name of the axis */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Any additional information attached to the axis that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /**\n * Parent axes provide contextual grouping for the axis in question, establishing\n * a hierarchy where the current axis is dependent on one or more axes for its\n * full definition and meaning. For instance, in a data structure where each\n * \"container\" axis may contain multiple \"item\" axes, the `item` axis would\n * list the index of the `container` axis in this field to denote its dependency.\n *\n * This means that the identity or significance of the `item` axis is only\n * interpretable when combined with its parent `container` axis. An `item` axis\n * index by itself may be non-unique and only gains uniqueness within the context\n * of its parent `container`. Therefore, the `parentAxes` field is essential for\n * mapping these relationships and ensuring data coherence across nested or\n * multi-level data models.\n *\n * A list of zero-based indices of parent axes in the overall axes specification\n * from the column spec. Each index corresponds to the position of a parent axis\n * in the list that defines the structure of the data model.\n */\n readonly parentAxes?: number[];\n}\n\n/** Common type representing spec for all the axes in a column */\nexport type AxesSpec = AxisSpec[];\n\n/**\n * Full column specification including all axes specs and specs of the column\n * itself.\n *\n * A PColumn in its essence represents a mapping from a fixed size, explicitly\n * typed tuple to an explicitly typed value.\n *\n * (axis1Value1, axis2Value1, ...) -> columnValue\n *\n * Each element in tuple correspond to the axis having the same index in axesSpec.\n * */\nexport interface PColumnSpec extends PObjectSpec {\n /** Defines specific type of BObject, the most generic type of unit of\n * information in Platforma Project. */\n readonly kind: 'PColumn';\n\n /** Type of column values */\n readonly valueType: ValueType;\n\n /** Column name */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Any additional information attached to the column that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /** A list of zero-based indices of parent axes from the {@link axesSpec} array. */\n readonly parentAxes?: number[];\n\n /** Axes specifications */\n readonly axesSpec: AxesSpec;\n}\n\nexport interface PColumn<Data> extends PObject<Data> {\n /** PColumn spec, allowing it to be found among other PObjects */\n readonly spec: PColumnSpec;\n}\n\n/** Columns in a PFrame also have internal identifier, this object represents\n * combination of specs and such id */\nexport interface PColumnIdAndSpec {\n /** Internal column id within the PFrame */\n readonly columnId: PObjectId;\n\n /** Column spec */\n readonly spec: PColumnSpec;\n}\n\n/** Information returned by {@link PFrame.listColumns} method */\nexport interface PColumnInfo extends PColumnIdAndSpec {\n /** True if data was associated with this PColumn */\n readonly hasData: boolean;\n}\n\nexport interface AxisId {\n /** Type of the axis or column value. For an axis should not use non-key\n * types like float or double. */\n readonly type: ValueType;\n\n /** Name of the axis or column */\n readonly name: string;\n\n /** Adds auxiliary information to the axis or column name and type to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n}\n\n/** Array of axis ids */\nexport type AxesId = AxisId[];\n\n/** Extracts axis ids from axis spec */\nexport function getAxisId(spec: AxisSpec): AxisId {\n const { type, name, domain } = spec;\n return { type, name, ...(domain && { domain }) };\n}\n\n/** Extracts axes ids from axes spec array from column spec */\nexport function getAxesId(spec: AxesSpec): AxesId {\n return spec.map(getAxisId);\n}\n\n/** Returns true if all domains from query are found in target */\nfunction matchDomain(query?: Record<string, string>, target?: Record<string, string>) {\n if (query === undefined) return target === undefined;\n if (target === undefined) return true;\n for (const k in target) {\n if (query[k] !== target[k]) return false;\n }\n return true;\n}\n\n/** Returns whether \"match\" axis id is compatible with the \"query\" */\nexport function matchAxisId(query: AxisId, target: AxisId): boolean {\n return query.name === target.name && matchDomain(query.domain, target.domain);\n}\n","import { PTableColumnId, PTableColumnSpec } from './table_common';\nimport { PTableVector } from './data';\nimport { assertNever } from '../../util';\n\n/** Defines a terminal column node in the join request tree */\nexport interface ColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: 'column';\n\n /** Local column */\n readonly column: Col;\n}\n\n/**\n * Defines a join request tree node that will output only records present in\n * all child nodes ({@link entries}).\n * */\nexport interface InnerJoin<Col> {\n /** Node type discriminator */\n readonly type: 'inner';\n\n /** Child nodes to be inner joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present at\n * least in one of the child nodes ({@link entries}), values for those PColumns\n * that lacks corresponding combinations of axis values will be marked as absent,\n * see {@link PTableVector.absent}.\n * */\nexport interface FullJoin<Col> {\n /** Node type discriminator */\n readonly type: 'full';\n\n /** Child nodes to be fully outer joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present in\n * {@link primary} child node, and records from the {@link secondary} nodes will\n * be added to the output only if present, values for those PColumns from the\n * {@link secondary} list, that lacks corresponding combinations of axis values\n * will be marked as absent, see {@link PTableVector.absent}.\n *\n * This node can be thought as a chain of SQL LEFT JOIN operations starting from\n * the {@link primary} node and adding {@link secondary} nodes one by one.\n * */\nexport interface OuterJoin<Col> {\n /** Node type discriminator */\n readonly type: 'outer';\n\n /** Primes the join operation. Left part of LEFT JOIN. */\n readonly primary: JoinEntry<Col>;\n\n /** Driven nodes, giving their values only if primary node have corresponding\n * nodes. Right parts of LEFT JOIN chain. */\n readonly secondary: JoinEntry<Col>[];\n}\n\n/**\n * Base type of all join request tree nodes. Join request tree allows to combine\n * information from multiple PColumns into a PTable. Correlation between records\n * is performed by looking for records with the same values in common axis between\n * the PColumns. Common axis are those axis which have equal {@link AxisId} derived\n * from the columns axes spec.\n * */\nexport type JoinEntry<Col> =\n | ColumnJoinEntry<Col>\n | InnerJoin<Col>\n | FullJoin<Col>\n | OuterJoin<Col>;\n\n/** Container representing whole data stored in specific PTable column. */\nexport interface FullPTableColumnData {\n /** Unified spec */\n readonly spec: PTableColumnSpec;\n\n /** Data */\n readonly data: PTableVector;\n}\n\nexport interface SingleValueIsNAPredicate {\n /** Comparison operator */\n readonly operator: 'IsNA';\n}\n\nexport interface SingleValueEqualPredicate {\n /** Comparison operator */\n readonly operator: 'Equal';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueIEqualPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'IEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string;\n}\n\nexport interface SingleValueLessPredicate {\n /** Comparison operator */\n readonly operator: 'Less';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueLessOrEqualPredicate {\n /** Comparison operator */\n readonly operator: 'LessOrEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterPredicate {\n /** Comparison operator */\n readonly operator: 'Greater';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterOrEqualPredicate {\n /** Comparison operator */\n readonly operator: 'GreaterOrEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueStringContainsPredicate {\n /** Comparison operator */\n readonly operator: 'StringContains';\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueStringIContainsPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'StringIContains';\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueMatchesPredicate {\n /** Comparison operator */\n readonly operator: 'Matches';\n\n /** Regular expression, NA values are skipped */\n readonly regex: string;\n}\n\nexport interface SingleValueStringContainsFuzzyPredicate {\n /** Comparison operator */\n readonly operator: 'StringContainsFuzzy';\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueStringIContainsFuzzyPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'StringIContainsFuzzy';\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueNotPredicateV2 {\n /** Comparison operator */\n readonly operator: 'Not';\n\n /** Operand to negate */\n readonly operand: SingleValuePredicateV2;\n}\n\nexport interface SingleValueAndPredicateV2 {\n /** Comparison operator */\n readonly operator: 'And';\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\nexport interface SingleValueOrPredicateV2 {\n /** Comparison operator */\n readonly operator: 'Or';\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\n/** Filtering predicate for a single axis or column value */\nexport type SingleValuePredicateV2 =\n | SingleValueIsNAPredicate\n | SingleValueEqualPredicate\n | SingleValueLessPredicate\n | SingleValueLessOrEqualPredicate\n | SingleValueGreaterPredicate\n | SingleValueGreaterOrEqualPredicate\n | SingleValueStringContainsPredicate\n | SingleValueMatchesPredicate\n | SingleValueStringContainsFuzzyPredicate\n | SingleValueNotPredicateV2\n | SingleValueAndPredicateV2\n | SingleValueOrPredicateV2\n | SingleValueIEqualPredicate\n | SingleValueStringIContainsPredicate\n | SingleValueStringIContainsFuzzyPredicate;\n\n/**\n * Filter PTable records based on specific axis or column value. If this is an\n * axis value filter and the axis is part of a partitioning key in some of the\n * source PColumns, the filter will be pushed down to those columns, so only\n * specific partitions will be retrieved from the remote storage.\n * */\nexport interface PTableRecordSingleValueFilterV2 {\n /** Filter type discriminator */\n readonly type: 'bySingleColumnV2';\n\n /** Target axis selector to examine values from */\n readonly column: PTableColumnId;\n\n /** Value predicate */\n readonly predicate: SingleValuePredicateV2;\n}\n\n/** Generic PTable records filter */\nexport type PTableRecordFilter = PTableRecordSingleValueFilterV2;\n\n/** Sorting parameters for a PTable. */\nexport type PTableSorting = {\n /** Unified column identifier */\n readonly column: PTableColumnId;\n\n /** Sorting order */\n readonly ascending: boolean;\n\n /** Sorting in respect to NA and absent values */\n readonly naAndAbsentAreLeastValues: boolean;\n};\n\n/** Information required to instantiate a PTable. */\nexport interface PTableDef<Col> {\n /** Join tree to populate the PTable */\n readonly src: JoinEntry<Col>;\n\n /** Record filters */\n readonly filters: PTableRecordFilter[];\n\n /** Table sorting */\n readonly sorting: PTableSorting[];\n}\n\n/** Request to create and retrieve entirety of data of PTable. */\nexport type CalculateTableDataRequest<Col> = PTableDef<Col>;\n\n/** Response for {@link CalculateTableDataRequest} */\nexport type CalculateTableDataResponse = FullPTableColumnData[];\n\nexport function mapPTableDef<C1, C2>(\n def: PTableDef<C1>,\n cb: (c: C1) => C2\n): PTableDef<C2> {\n return { ...def, src: mapJoinEntry(def.src, cb) };\n}\n\nexport function mapJoinEntry<C1, C2>(\n entry: JoinEntry<C1>,\n cb: (c: C1) => C2\n): JoinEntry<C2> {\n switch (entry.type) {\n case 'column':\n return {\n type: 'column',\n column: cb(entry.column)\n };\n case 'inner':\n case 'full':\n return {\n type: entry.type,\n entries: entry.entries.map((col) => mapJoinEntry(col, cb))\n };\n case 'outer':\n return {\n type: 'outer',\n primary: mapJoinEntry(entry.primary, cb),\n secondary: entry.secondary.map((col) => mapJoinEntry(col, cb))\n };\n default:\n assertNever(entry);\n }\n}\n","/** Block section visualized as items in left panel block overview */\nexport type BlockSection = BlockSectionLink | BlockSectionDelimiter;\n\n/** Tells the system that specific section from the main UI of this block should\n * be opened */\nexport type BlockSectionLink = {\n /** Potentially there may be multiple section types, i.e. for \"+\" rows and for\n * sections directly opening html from the outputs. */\n readonly type: 'link';\n\n /** Internal block section identifier */\n readonly href: `/${string}`;\n\n /** Visible section title, can also be used in the window header. */\n readonly label: string;\n};\n\n/** Create a horisontal line between sections */\nexport type BlockSectionDelimiter = {\n readonly type: 'delimiter';\n};\n\n/**\n * Part of the block state, representing current navigation information\n * (i.e. currently selected section)\n * */\nexport type NavigationState<Href extends `/${string}` = `/${string}`> = {\n readonly href: Href;\n};\n\nexport const DefaultNavigationState: NavigationState = { href: '/' };\n","import { z } from 'zod';\n\nexport const PlRef = z\n .object({\n __isRef: z\n .literal(true)\n .describe('Crucial marker for the block dependency tree reconstruction'),\n blockId: z.string().describe('Upstream block id'),\n name: z.string().describe(\"Name of the output provided to the upstream block's output context\")\n })\n .describe(\n 'Universal reference type, allowing to set block connections. It is crucial that ' +\n '{@link __isRef} is present and equal to true, internal logic relies on this marker ' +\n 'to build block dependency trees.'\n )\n .strict()\n .readonly();\nexport type PlRef = z.infer<typeof PlRef>;\n/** @deprecated use {@link PlRef} */\nexport type Ref = PlRef;\n\n/** Standard way how to communicate possible connections given specific\n * requirements for incoming data. */\nexport type Option = {\n /** Fully rendered reference to be assigned for the intended field in block's\n * args */\n readonly ref: PlRef;\n\n /** Label to be present for the user in i.e. drop-down list */\n readonly label: string;\n};\n\n/** Compare two PlRefs and returns true if they are qual */\nexport function plRefsEqual(ref1: PlRef, ref2: PlRef) {\n return ref1.blockId === ref2.blockId && ref1.name === ref2.name;\n}\n","import { Branded } from '../branding';\nimport { PColumn, PColumnSpec } from '../drivers';\nimport { ResultPoolEntry } from './entry';\n\n/** Any object exported into the result pool by the block always have spec attached to it */\nexport interface PObjectSpec {\n /** PObject kind discriminator */\n readonly kind: string;\n\n /** Additional information attached to the object */\n readonly annotations?: Record<string, string>;\n}\n\n/** Stable PObject id */\nexport type PObjectId = Branded<string, 'PColumnId'>;\n\n/**\n * Full PObject representation.\n *\n * @template Data type of the object referencing or describing the \"data\" part of the PObject\n * */\nexport interface PObject<Data> {\n /** Fully rendered PObjects are assigned a stable identifier. */\n readonly id: PObjectId;\n\n /** PObject spec, allowing it to be found among other PObjects */\n readonly spec: PObjectSpec;\n\n /** A handle to data object */\n readonly data: Data;\n}\n\nexport function isPColumnSpec(spec: PObjectSpec): spec is PColumnSpec {\n return spec.kind === 'PColumn';\n}\n\nexport function isPColumn<T>(obj: PObject<T>): obj is PColumn<T> {\n return isPColumnSpec(obj.spec);\n}\n\nexport function isPColumnSpecResult(\n r: ResultPoolEntry<PObjectSpec>\n): r is ResultPoolEntry<PColumnSpec> {\n return isPColumnSpec(r.obj);\n}\n\nexport function isPColumnResult<T>(\n r: ResultPoolEntry<PObject<T>>\n): r is ResultPoolEntry<PColumn<T>> {\n return isPColumnSpec(r.obj.spec);\n}\n\nexport function ensurePColumn<T>(obj: PObject<T>): PColumn<T> {\n if (!isPColumn(obj)) throw new Error(`not a PColumn (kind = ${obj.spec.kind})`);\n return obj;\n}\n\nexport function mapPObjectData<D1, D2>(pObj: PColumn<D1>, cb: (d: D1) => D2): PColumn<D2>;\nexport function mapPObjectData<D1, D2>(\n pObj: PColumn<D1> | undefined,\n cb: (d: D1) => D2\n): PColumn<D2> | undefined;\nexport function mapPObjectData<D1, D2>(pObj: PObject<D1>, cb: (d: D1) => D2): PObject<D2>;\nexport function mapPObjectData<D1, D2>(\n pObj: PObject<D1> | undefined,\n cb: (d: D1) => D2\n): PObject<D2> | undefined;\nexport function mapPObjectData<D1, D2>(\n pObj: PObject<D1> | undefined,\n cb: (d: D1) => D2\n): PObject<D2> | undefined {\n return pObj === undefined\n ? undefined\n : {\n ...pObj,\n data: cb(pObj.data)\n };\n}\n","import { AxisId } from '../drivers';\nimport { PObjectSpec, isPColumnSpec } from './spec';\n\nexport type PSpecPredicate =\n | {\n type: 'and' | 'or';\n operands: PSpecPredicate[];\n }\n | {\n type: 'not';\n operand: PSpecPredicate;\n }\n | {\n type: 'name';\n name: string;\n }\n | {\n type: 'name_pattern';\n pattern: string;\n }\n | {\n type: 'annotation';\n annotation: string;\n value: string;\n }\n | {\n type: 'annotation_pattern';\n annotation: string;\n pattern: string;\n }\n | {\n type: 'has_axes';\n axes: Partial<AxisId>[];\n };\n\nfunction assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x);\n}\n\nexport function executePSpecPredicate(\n predicate: PSpecPredicate,\n spec: PObjectSpec\n): boolean {\n switch (predicate.type) {\n case 'and':\n for (const operator of predicate.operands)\n if (!executePSpecPredicate(operator, spec)) return false;\n return true;\n case 'or':\n for (const operator of predicate.operands)\n if (executePSpecPredicate(operator, spec)) return true;\n return false;\n case 'not':\n return !executePSpecPredicate(predicate.operand, spec);\n case 'name':\n return isPColumnSpec(spec) && spec.name === predicate.name;\n case 'name_pattern':\n return isPColumnSpec(spec) && Boolean(spec.name.match(predicate.pattern));\n case 'annotation':\n return (\n isPColumnSpec(spec) &&\n spec.annotations !== undefined &&\n spec.annotations[predicate.annotation] === predicate.value\n );\n case 'annotation_pattern':\n return (\n isPColumnSpec(spec) &&\n spec.annotations !== undefined &&\n spec.annotations[predicate.annotation] !== undefined &&\n Boolean(spec.annotations[predicate.annotation].match(predicate.pattern))\n );\n case 'has_axes':\n return (\n isPColumnSpec(spec) &&\n predicate.axes.every((matcher) =>\n spec.axesSpec.some(\n (axisSpec) =>\n (matcher.type === undefined || matcher.type === axisSpec.type) &&\n (matcher.name === undefined || matcher.name === axisSpec.name) &&\n (matcher.domain === undefined ||\n Object.keys(matcher.domain).length === 0 ||\n (axisSpec.domain !== undefined &&\n Object.entries(matcher.domain).every(\n ([domain, domainValue]) =>\n axisSpec.domain![domain] === domainValue\n )))\n )\n )\n );\n default:\n assertNever(predicate);\n }\n}\n","export type ValueOrError<V, E> =\n | {\n ok: true;\n value: V;\n }\n | {\n ok: false;\n error: E;\n };\n\nexport function mapValueInVOE<V1, V2, E>(\n voe: ValueOrError<V1, E>,\n cb: (value: V1) => V2\n): ValueOrError<V2, E> {\n return voe.ok ? { ok: true, value: cb(voe.value) } : voe;\n}\n"],"names":["isLiveLog","handle","assertNever","x","uploadPrefix","indexPrefix","isImportFileHandleUpload","isImportFileHandleIndex","getFilePathFromHandle","trimmed","extractFileName","filePath","getFileNameFromHandle","PValueIntNA","PValueLongNA","PValueFloatNA","PValueDoubleNA","PValueStringNA","PValueBytesNA","isValueNA","value","valueType","ensureNotNAPValue","isNotNAPValue","isPValue","toJsonSafePValue","safeConvertToPValue","checkType","pValueToStringOrNumber","pValueToStringOrNumberOrNull","isValueAbsent","absent","index","chunkIndex","mask","PTableNull","PTableNA","pTableValue","column","row","getAxisId","spec","type","name","domain","getAxesId","matchDomain","query","target","k","matchAxisId","mapPTableDef","def","cb","mapJoinEntry","entry","col","DefaultNavigationState","PlRef","z","plRefsEqual","ref1","ref2","isPColumnSpec","isPColumn","obj","isPColumnSpecResult","r","isPColumnResult","ensurePColumn","mapPObjectData","pObj","executePSpecPredicate","predicate","operator","matcher","axisSpec","domainValue","mapValueInVOE","voe"],"mappings":"uGAaO,SAASA,EAAUC,EAA2D,CACnF,OAAOA,IAAW,QAAaA,EAAO,WAA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CAEV,EAEJ,QACE3E,EAAYuE,CAAS,CAAA,CAE3B,CClFgB,SAAAK,EACdC,EACA1B,EACqB,CACd,OAAA0B,EAAI,GAAK,CAAE,GAAI,GAAM,MAAO1B,EAAG0B,EAAI,KAAK,CAAA,EAAMA,CACvD"}
1
+ {"version":3,"file":"index.js","sources":["../src/drivers/log.ts","../src/util.ts","../src/drivers/ls.ts","../src/drivers/pframe/data.ts","../src/drivers/pframe/spec.ts","../src/drivers/pframe/table_calculate.ts","../src/navigation.ts","../src/ref.ts","../src/pool/spec.ts","../src/pool/query.ts","../src/value_or_error.ts"],"sourcesContent":["/** Handle of logs. This handle should be passed\n * to the driver for retrieving logs. */\nexport type AnyLogHandle = LiveLogHandle | ReadyLogHandle;\n\n/** Handle of the live logs of a program.\n * The resource that represents a log can be deleted,\n * in this case the handle should be refreshed. */\nexport type LiveLogHandle = `log+live://log/${string}`;\n\n/** Handle of the ready logs of a program. */\nexport type ReadyLogHandle = `log+ready://log/${string}`;\n\n/** Type guard to check if log is live, and corresponding porcess is not finished. */\nexport function isLiveLog(handle: AnyLogHandle | undefined): handle is LiveLogHandle {\n return handle !== undefined && handle.startsWith('log+live://log/');\n}\n\n/** Driver to retrieve logs given log handle */\nexport interface LogsDriver {\n lastLines(\n /** A handle that was issued previously. */\n handle: AnyLogHandle,\n\n /** Allows client to limit total data sent from server. */\n lineCount: number,\n\n /** Makes streamer to perform seek operation to given offset before sending the contents.\n * Client can just use the <new_offset> value of the last response from server to continue streaming after reconnection.\n * If undefined, then starts from the end. */\n offsetBytes?: number,\n\n /** Is substring for line search pattern.\n * This option makes controller to send to the client only lines, that\n * have given substring. */\n searchStr?: string\n ): Promise<StreamingApiResponse>;\n\n readText(\n /** A handle that was issued previously. */\n handle: AnyLogHandle,\n\n /** Allows client to limit total data sent from server. */\n lineCount: number,\n\n /** Makes streamer to perform seek operation to given offset before sending the contents.\n * Client can just use the <new_offset> value of the last response from server to continue streaming after reconnection.\n * If undefined of 0, then starts from the beginning. */\n offsetBytes?: number,\n\n /** Is substring for line search pattern.\n * This option makes controller to send to the client only lines, that\n * have given substring. */\n searchStr?: string\n ): Promise<StreamingApiResponse>;\n}\n\n/** Response of the driver.\n * The caller should give a handle to retrieve it.\n * It can be OK or outdated, in which case the handle\n * should be issued again. */\nexport type StreamingApiResponse = StreamingApiResponseOk | StreamingApiResponseHandleOutdated;\n\nexport type StreamingApiResponseOk = {\n /** The handle don't have to be updated,\n * the response is OK. */\n shouldUpdateHandle: false;\n\n /** Whether the log can still grow or it's in a final state. */\n live: boolean;\n\n /** Data of the response, in bytes. */\n data: Uint8Array;\n /** Current size of the file. It can grow if it's still live. */\n size: number;\n /** Offset in bytes from the beginning of a file. */\n newOffset: number;\n};\n\n/** The handle should be issued again, this one is done. */\nexport type StreamingApiResponseHandleOutdated = {\n shouldUpdateHandle: true;\n};\n","export function assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x);\n}\n","import { assertNever } from '../util';\nimport { Branded } from '../branding';\nimport { TableRange } from './pframe';\nimport { FileLike } from './interfaces';\n\nconst uploadPrefix = 'upload://upload/';\nconst indexPrefix = 'index://index/';\n\nexport type ImportFileHandleUpload = `upload://upload/${string}`;\nexport type ImportFileHandleIndex = `index://index/${string}`;\n\nexport type ImportFileHandle = ImportFileHandleUpload | ImportFileHandleIndex;\n\nexport type LocalImportFileHandle = Branded<ImportFileHandle, 'Local'>;\n\nexport function isImportFileHandleUpload(\n handle: ImportFileHandle\n): handle is ImportFileHandleUpload {\n return handle.startsWith(uploadPrefix);\n}\n\nexport function isImportFileHandleIndex(handle: ImportFileHandle): handle is ImportFileHandleIndex {\n return handle.startsWith(indexPrefix);\n}\n\n/** Results in upload */\nexport type StorageHandleLocal = `local://${string}`;\n\n/** Results in index */\nexport type StorageHandleRemote = `remote://${string}`;\n\nexport type StorageHandle = StorageHandleLocal | StorageHandleRemote;\n\nexport type StorageEntry = {\n name: string;\n handle: StorageHandle;\n initialFullPath: string;\n\n // TODO\n // pathStartsWithDisk\n};\n\nexport type ListFilesResult = {\n parent?: string;\n entries: LsEntry[];\n};\n\nexport type LsEntry =\n | {\n type: 'dir';\n name: string;\n fullPath: string;\n }\n | {\n type: 'file';\n name: string;\n fullPath: string;\n\n /** This handle should be set to args... */\n handle: ImportFileHandle;\n };\n\nexport type OpenDialogFilter = {\n /** Human-readable file type name */\n readonly name: string;\n /** File extensions */\n readonly extensions: string[];\n};\n\nexport type OpenDialogOps = {\n /** Open dialog window title */\n readonly title?: string;\n /** Custom label for the confirmation button, when left empty the default label will be used. */\n readonly buttonLabel?: string;\n /** Limits of file types user can select */\n readonly filters?: OpenDialogFilter[];\n};\n\nexport type OpenSingleFileResponse = {\n /** Contains local file handle, allowing file importing or content reading. If user canceled\n * the dialog, field will be undefined. */\n readonly file?: LocalImportFileHandle;\n};\n\nexport type OpenMultipleFilesResponse = {\n /** Contains local file handles, allowing file importing or content reading. If user canceled\n * the dialog, field will be undefined. */\n readonly files?: LocalImportFileHandle[];\n};\n\n/** Can be used to limit request for local file content to a certain bytes range */\nexport type FileRange = {\n /** From byte index (inclusive) */\n readonly from: number;\n /** To byte index (exclusive) */\n readonly to: number;\n};\n\nexport interface LsDriver {\n /** remote and local storages */\n getStorageList(): Promise<StorageEntry[]>;\n\n listFiles(storage: StorageHandle, fullPath: string): Promise<ListFilesResult>;\n\n /** Opens system file open dialog allowing to select single file and awaits user action */\n showOpenSingleFileDialog(ops: OpenDialogOps): Promise<OpenSingleFileResponse>;\n\n /** Opens system file open dialog allowing to multiple files and awaits user action */\n showOpenMultipleFilesDialog(ops: OpenDialogOps): Promise<OpenMultipleFilesResponse>;\n\n /** Given a handle to a local file, allows to get file size */\n getLocalFileSize(file: LocalImportFileHandle): Promise<number>;\n\n /** Given a handle to a local file, allows to get its content */\n getLocalFileContent(file: LocalImportFileHandle, range?: TableRange): Promise<Uint8Array>;\n\n /**\n * Resolves browser's File object into platforma's import file handle.\n *\n * This method is useful among other things for implementation of UI\n * components, that handle file Drag&Drop.\n * */\n fileToImportHandle(file: FileLike): Promise<ImportFileHandle>;\n}\n\n/** Gets a file path from an import handle. */\nexport function getFilePathFromHandle(handle: ImportFileHandle): string {\n if (isImportFileHandleIndex(handle)) {\n const trimmed = handle.slice(indexPrefix.length);\n const data = JSON.parse(decodeURIComponent(trimmed));\n return data.path;\n } else if (isImportFileHandleUpload(handle)) {\n const trimmed = handle.slice(uploadPrefix.length);\n const data = JSON.parse(decodeURIComponent(trimmed));\n return data.localPath;\n }\n\n assertNever(handle);\n}\n\nfunction extractFileName(filePath: string) {\n return filePath.replace(/^.*[\\\\/]/, '');\n}\n\n/** Gets a file name from an import handle. */\nexport function getFileNameFromHandle(handle: ImportFileHandle): string {\n return extractFileName(getFilePathFromHandle(handle));\n}\n","import { number } from 'zod';\nimport { ValueType } from './spec';\n\nexport const PValueIntNA = -2147483648;\nexport const PValueLongNA = -9007199254740991n;\nexport const PValueFloatNA = NaN;\nexport const PValueDoubleNA = NaN;\nexport const PValueStringNA = null;\nexport const PValueBytesNA = null;\n\nexport type PValueInt = number;\nexport type PValueLong = number | bigint; // use bigint only if extra integer precision is needed\nexport type PValueFloat = number;\nexport type PValueDouble = number;\nexport type PValueString = string | null;\nexport type PValueBytes = Uint8Array | null;\n\nexport type NotNAPValueInt = number;\nexport type NotNAPValueLong = number | bigint; // use bigint only if extra integer precision is needed\nexport type NotNAPValueFloat = number;\nexport type NotNAPValueDouble = number;\nexport type NotNAPValueString = string;\n\nexport type NotNAPValue = number | bigint | string;\n\nexport type PValue =\n | PValueInt\n | PValueLong\n | PValueFloat\n | PValueDouble\n | PValueString\n | PValueBytes;\n\nexport function isValueNA(value: unknown, valueType: ValueType): boolean {\n switch (valueType) {\n case 'Int':\n return value === PValueIntNA;\n case 'Long':\n return value === Number(PValueLongNA) || value === PValueLongNA;\n case 'Float':\n return value === PValueFloatNA;\n case 'Double':\n return value === PValueDoubleNA;\n case 'String':\n return value === PValueStringNA;\n case 'Bytes':\n return value === PValueBytesNA;\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\nexport function ensureNotNAPValue(value: string): string;\nexport function ensureNotNAPValue(value: number): number;\nexport function ensureNotNAPValue(value: bigint): bigint;\nexport function ensureNotNAPValue(value: unknown): NotNAPValue;\nexport function ensureNotNAPValue(value: unknown): NotNAPValue {\n if (!isNotNAPValue(value)) throw new Error(`Expected not-NA PValue, got ${value}`);\n return value;\n}\n\nexport function isNotNAPValue(value: unknown, valueType: 'Int'): value is number;\nexport function isNotNAPValue(value: unknown, valueType: 'Long'): value is number | bigint;\nexport function isNotNAPValue(value: unknown, valueType: 'Float'): value is number;\nexport function isNotNAPValue(value: unknown, valueType: 'Double'): value is number;\nexport function isNotNAPValue(value: unknown, valueType: 'String'): value is string;\nexport function isNotNAPValue(value: unknown, valueType: ValueType): value is NotNAPValue;\nexport function isNotNAPValue(value: unknown): value is NotNAPValue;\nexport function isNotNAPValue(value: unknown, valueType?: ValueType): boolean {\n if (!valueType)\n return (\n typeof value === 'string' ||\n (typeof value === 'number' && isFinite(value)) ||\n typeof value === 'bigint'\n );\n if (isValueNA(value, valueType)) return false;\n switch (valueType) {\n case 'Int':\n return typeof value === 'number';\n case 'Long':\n return typeof value === 'number' || typeof value === 'bigint';\n case 'Float':\n return typeof value === 'number';\n case 'Double':\n return typeof value === 'number';\n case 'String':\n return typeof value === 'string';\n case 'Bytes':\n throw Error(`Bytes not yet supported`);\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\nexport function isPValue(value: unknown, valueType: 'Int'): value is PValueInt;\nexport function isPValue(value: unknown, valueType: 'Long'): value is PValueLong;\nexport function isPValue(value: unknown, valueType: 'Float'): value is PValueFloat;\nexport function isPValue(value: unknown, valueType: 'Double'): value is PValueDouble;\nexport function isPValue(value: unknown, valueType: 'String'): value is PValueString;\nexport function isPValue(value: unknown, valueType: ValueType): value is PValue;\nexport function isPValue(value: unknown): value is PValue;\nexport function isPValue(value: unknown, valueType?: ValueType): boolean {\n if (!valueType)\n return (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'bigint'\n );\n if (isValueNA(value, valueType)) return true;\n switch (valueType) {\n case 'Int':\n return typeof value === 'number';\n case 'Long':\n return typeof value === 'number' || typeof value === 'bigint';\n case 'Float':\n return typeof value === 'number';\n case 'Double':\n return typeof value === 'number';\n case 'String':\n return typeof value === 'string';\n case 'Bytes':\n throw Error(`Bytes not yet supported`);\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\nexport type PValueLongJsonSafe = { bigint: string };\nexport type PValueJsonSafe = number | string | null | PValueLongJsonSafe;\n\n/**\n * Converts PValue to value that can be safely serialized by standard JSON.stringify\n * method. Use {@link safeConvertToPValue} to \"deserialize\" the value back to runtime\n * PValue representation.\n */\nexport function toJsonSafePValue(value: PValue): PValueJsonSafe {\n if (value === null || typeof value === 'string' || typeof value === 'number') return value;\n if (typeof value === 'bigint') return { bigint: value.toString() };\n throw new Error(`Type ${typeof value} (value ${value}) not yet supported.`);\n}\n\n/**\n * Can be used to \"deserialize\" result of {@link toJsonSafePValue} or to\n * safely cast any unknown value to actual runtime PValue representation.\n */\nexport function safeConvertToPValue(value: unknown, checkType?: ValueType): PValue {\n if (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'bigint'\n ) {\n if (checkType && !isValueNA(value, checkType) && !isPValue(value, checkType))\n throw new Error(`Unexpected value type, got ${typeof value}, expected ${checkType}`);\n return value;\n }\n\n if (\n typeof value === 'object' &&\n value !== null &&\n 'bigint' in value &&\n typeof value.bigint === 'string'\n ) {\n if (checkType && checkType !== 'Long')\n throw new Error(`Unexpected value type, got serialized bigint, expected ${checkType}`);\n\n return BigInt(value.bigint);\n }\n\n throw new Error(`Unsupported type ${typeof value} (value ${value}).`);\n}\n\nexport function pValueToStringOrNumber(value: string): string;\nexport function pValueToStringOrNumber(value: number | bigint): number;\nexport function pValueToStringOrNumber(value: PValue | PValueJsonSafe): string | number;\nexport function pValueToStringOrNumber(value: PValue | PValueJsonSafe): string | number {\n value = pValueToStringOrNumberOrNull(value);\n if (value === null) throw new Error('Value is null');\n return value;\n}\n\nexport function pValueToStringOrNumberOrNull(value: string | null): string;\nexport function pValueToStringOrNumberOrNull(value: number | bigint | null): number;\nexport function pValueToStringOrNumberOrNull(\n value: PValue | PValueJsonSafe\n): string | number | null;\nexport function pValueToStringOrNumberOrNull(\n value: PValue | PValueJsonSafe\n): string | number | null {\n value = safeConvertToPValue(value);\n if (value === null) return null;\n if (typeof value === 'string') return value;\n if (typeof value === 'number') {\n if (!isFinite(value)) throw new Error(`Value is not finite (${value})`);\n return value;\n }\n if (typeof value === 'bigint') {\n // @TODO add range check\n return Number(value);\n }\n throw new Error(`Unexpected value type: ${typeof value}`);\n}\n\nexport type PVectorDataInt = Int32Array;\nexport type PVectorDataLong = BigInt64Array;\nexport type PVectorDataFloat = Float32Array;\nexport type PVectorDataDouble = Float64Array;\nexport type PVectorDataString = PValueString[];\nexport type PVectorDataBytes = PValueBytes[];\n\nexport type PVectorData =\n | PVectorDataInt\n | PVectorDataLong\n | PVectorDataFloat\n | PVectorDataDouble\n | PVectorDataString\n | PVectorDataBytes;\n\n/** Table column data in comparison to the data stored in a separate PColumn\n * may have some of the values \"absent\", i.e. as a result of missing record in\n * outer join operation. This information is encoded in {@link absent} field. */\nexport interface PTableVector {\n /** Stored data type */\n readonly type: ValueType;\n\n /** Values for present positions, absent positions have NA values */\n readonly data: PVectorData;\n\n /**\n * Encoded bit array marking some elements of this vector as absent,\n * call {@link isValueAbsent} to read the data.\n * */\n readonly absent: Uint8Array;\n}\n\n/** Used to read bit array with value absence information */\nexport function isValueAbsent(absent: Uint8Array, index: number): boolean {\n const chunkIndex = Math.floor(index / 8);\n const mask = 1 << (7 - (index % 8));\n return (absent[chunkIndex] & mask) > 0;\n}\n\nexport type PColumnValue = null | number | string;\nexport type PColumnValuesEntry = {\n key: PColumnValue[];\n val: PColumnValue;\n};\nexport type PColumnValues = PColumnValuesEntry[];\n\nexport const PTableNull = { type: 'absent' };\nexport const PTableNA = null;\n\n/** Decoded PTable value */\nexport type PTableValue =\n | typeof PTableNull\n | typeof PTableNA\n | number | string;\n\n/** Read PTableValue from PTable column at specified row */\nexport function pTableValue(column: PTableVector, row: number): PTableValue {\n if (isValueAbsent(column.absent, row)) return PTableNull;\n\n const value = column.data[row];\n const valueType = column.type;\n if (isValueNA(value, valueType)) return PTableNA;\n\n switch (valueType) {\n case 'Int':\n return value as PVectorDataInt[number];\n case 'Long':\n return Number(value as PVectorDataLong[number]);\n case 'Float':\n return value as PVectorDataFloat[number];\n case 'Double':\n return value as PVectorDataDouble[number];\n case 'String':\n return value as PVectorDataString[number];\n case 'Bytes':\n throw Error(`Bytes not yet supported`);\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\n/** Used in requests to partially retrieve table's data */\nexport type TableRange = {\n /** Index of the first record to retrieve */\n readonly offset: number;\n\n /** Block length */\n readonly length: number;\n};\n\n/** Unified information about table shape */\nexport type PTableShape = {\n /** Number of unified table columns, including all axes and PColumn values */\n columns: number;\n\n /** Number of rows */\n rows: number;\n};\n","import { PObject, PObjectId, PObjectSpec } from '../../pool';\n\n/** PFrame columns and axes within them may store one of these types. */\nexport type ValueType = 'Int' | 'Long' | 'Float' | 'Double' | 'String' | 'Bytes';\n\n/**\n * Specification of an individual axis.\n *\n * Each axis is a part of a composite key that addresses data inside the PColumn.\n *\n * Each record inside a PColumn is addressed by a unique tuple of values set for\n * all the axes specified in the column spec.\n * */\nexport interface AxisSpec {\n /** Type of the axis value. Should not use non-key types like float or double. */\n readonly type: ValueType;\n\n /** Name of the axis */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Any additional information attached to the axis that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /**\n * Parent axes provide contextual grouping for the axis in question, establishing\n * a hierarchy where the current axis is dependent on one or more axes for its\n * full definition and meaning. For instance, in a data structure where each\n * \"container\" axis may contain multiple \"item\" axes, the `item` axis would\n * list the index of the `container` axis in this field to denote its dependency.\n *\n * This means that the identity or significance of the `item` axis is only\n * interpretable when combined with its parent `container` axis. An `item` axis\n * index by itself may be non-unique and only gains uniqueness within the context\n * of its parent `container`. Therefore, the `parentAxes` field is essential for\n * mapping these relationships and ensuring data coherence across nested or\n * multi-level data models.\n *\n * A list of zero-based indices of parent axes in the overall axes specification\n * from the column spec. Each index corresponds to the position of a parent axis\n * in the list that defines the structure of the data model.\n */\n readonly parentAxes?: number[];\n}\n\n/** Common type representing spec for all the axes in a column */\nexport type AxesSpec = AxisSpec[];\n\n/**\n * Full column specification including all axes specs and specs of the column\n * itself.\n *\n * A PColumn in its essence represents a mapping from a fixed size, explicitly\n * typed tuple to an explicitly typed value.\n *\n * (axis1Value1, axis2Value1, ...) -> columnValue\n *\n * Each element in tuple correspond to the axis having the same index in axesSpec.\n * */\nexport interface PColumnSpec extends PObjectSpec {\n /** Defines specific type of BObject, the most generic type of unit of\n * information in Platforma Project. */\n readonly kind: 'PColumn';\n\n /** Type of column values */\n readonly valueType: ValueType;\n\n /** Column name */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Any additional information attached to the column that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /** A list of zero-based indices of parent axes from the {@link axesSpec} array. */\n readonly parentAxes?: number[];\n\n /** Axes specifications */\n readonly axesSpec: AxesSpec;\n}\n\nexport interface PColumn<Data> extends PObject<Data> {\n /** PColumn spec, allowing it to be found among other PObjects */\n readonly spec: PColumnSpec;\n}\n\n/** Columns in a PFrame also have internal identifier, this object represents\n * combination of specs and such id */\nexport interface PColumnIdAndSpec {\n /** Internal column id within the PFrame */\n readonly columnId: PObjectId;\n\n /** Column spec */\n readonly spec: PColumnSpec;\n}\n\n/** Information returned by {@link PFrame.listColumns} method */\nexport interface PColumnInfo extends PColumnIdAndSpec {\n /** True if data was associated with this PColumn */\n readonly hasData: boolean;\n}\n\nexport interface AxisId {\n /** Type of the axis or column value. For an axis should not use non-key\n * types like float or double. */\n readonly type: ValueType;\n\n /** Name of the axis or column */\n readonly name: string;\n\n /** Adds auxiliary information to the axis or column name and type to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n}\n\n/** Array of axis ids */\nexport type AxesId = AxisId[];\n\n/** Extracts axis ids from axis spec */\nexport function getAxisId(spec: AxisSpec): AxisId {\n const { type, name, domain } = spec;\n return { type, name, ...(domain && { domain }) };\n}\n\n/** Extracts axes ids from axes spec array from column spec */\nexport function getAxesId(spec: AxesSpec): AxesId {\n return spec.map(getAxisId);\n}\n\n/** Returns true if all domains from query are found in target */\nfunction matchDomain(query?: Record<string, string>, target?: Record<string, string>) {\n if (query === undefined) return target === undefined;\n if (target === undefined) return true;\n for (const k in target) {\n if (query[k] !== target[k]) return false;\n }\n return true;\n}\n\n/** Returns whether \"match\" axis id is compatible with the \"query\" */\nexport function matchAxisId(query: AxisId, target: AxisId): boolean {\n return query.name === target.name && matchDomain(query.domain, target.domain);\n}\n","import { PTableColumnId, PTableColumnSpec } from './table_common';\nimport { PTableVector } from './data';\nimport { assertNever } from '../../util';\n\n/** Defines a terminal column node in the join request tree */\nexport interface ColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: 'column';\n\n /** Local column */\n readonly column: Col;\n}\n\n/**\n * Defines a join request tree node that will output only records present in\n * all child nodes ({@link entries}).\n * */\nexport interface InnerJoin<Col> {\n /** Node type discriminator */\n readonly type: 'inner';\n\n /** Child nodes to be inner joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present at\n * least in one of the child nodes ({@link entries}), values for those PColumns\n * that lacks corresponding combinations of axis values will be marked as absent,\n * see {@link PTableVector.absent}.\n * */\nexport interface FullJoin<Col> {\n /** Node type discriminator */\n readonly type: 'full';\n\n /** Child nodes to be fully outer joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present in\n * {@link primary} child node, and records from the {@link secondary} nodes will\n * be added to the output only if present, values for those PColumns from the\n * {@link secondary} list, that lacks corresponding combinations of axis values\n * will be marked as absent, see {@link PTableVector.absent}.\n *\n * This node can be thought as a chain of SQL LEFT JOIN operations starting from\n * the {@link primary} node and adding {@link secondary} nodes one by one.\n * */\nexport interface OuterJoin<Col> {\n /** Node type discriminator */\n readonly type: 'outer';\n\n /** Primes the join operation. Left part of LEFT JOIN. */\n readonly primary: JoinEntry<Col>;\n\n /** Driven nodes, giving their values only if primary node have corresponding\n * nodes. Right parts of LEFT JOIN chain. */\n readonly secondary: JoinEntry<Col>[];\n}\n\n/**\n * Base type of all join request tree nodes. Join request tree allows to combine\n * information from multiple PColumns into a PTable. Correlation between records\n * is performed by looking for records with the same values in common axis between\n * the PColumns. Common axis are those axis which have equal {@link AxisId} derived\n * from the columns axes spec.\n * */\nexport type JoinEntry<Col> =\n | ColumnJoinEntry<Col>\n | InnerJoin<Col>\n | FullJoin<Col>\n | OuterJoin<Col>;\n\n/** Container representing whole data stored in specific PTable column. */\nexport interface FullPTableColumnData {\n /** Unified spec */\n readonly spec: PTableColumnSpec;\n\n /** Data */\n readonly data: PTableVector;\n}\n\nexport interface SingleValueIsNAPredicate {\n /** Comparison operator */\n readonly operator: 'IsNA';\n}\n\nexport interface SingleValueEqualPredicate {\n /** Comparison operator */\n readonly operator: 'Equal';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueIEqualPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'IEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string;\n}\n\nexport interface SingleValueLessPredicate {\n /** Comparison operator */\n readonly operator: 'Less';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueLessOrEqualPredicate {\n /** Comparison operator */\n readonly operator: 'LessOrEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterPredicate {\n /** Comparison operator */\n readonly operator: 'Greater';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterOrEqualPredicate {\n /** Comparison operator */\n readonly operator: 'GreaterOrEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueStringContainsPredicate {\n /** Comparison operator */\n readonly operator: 'StringContains';\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueStringIContainsPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'StringIContains';\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueMatchesPredicate {\n /** Comparison operator */\n readonly operator: 'Matches';\n\n /** Regular expression, NA values are skipped */\n readonly regex: string;\n}\n\nexport interface SingleValueStringContainsFuzzyPredicate {\n /** Comparison operator */\n readonly operator: 'StringContainsFuzzy';\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueStringIContainsFuzzyPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'StringIContainsFuzzy';\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueNotPredicateV2 {\n /** Comparison operator */\n readonly operator: 'Not';\n\n /** Operand to negate */\n readonly operand: SingleValuePredicateV2;\n}\n\nexport interface SingleValueAndPredicateV2 {\n /** Comparison operator */\n readonly operator: 'And';\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\nexport interface SingleValueOrPredicateV2 {\n /** Comparison operator */\n readonly operator: 'Or';\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\n/** Filtering predicate for a single axis or column value */\nexport type SingleValuePredicateV2 =\n | SingleValueIsNAPredicate\n | SingleValueEqualPredicate\n | SingleValueLessPredicate\n | SingleValueLessOrEqualPredicate\n | SingleValueGreaterPredicate\n | SingleValueGreaterOrEqualPredicate\n | SingleValueStringContainsPredicate\n | SingleValueMatchesPredicate\n | SingleValueStringContainsFuzzyPredicate\n | SingleValueNotPredicateV2\n | SingleValueAndPredicateV2\n | SingleValueOrPredicateV2\n | SingleValueIEqualPredicate\n | SingleValueStringIContainsPredicate\n | SingleValueStringIContainsFuzzyPredicate;\n\n/**\n * Filter PTable records based on specific axis or column value. If this is an\n * axis value filter and the axis is part of a partitioning key in some of the\n * source PColumns, the filter will be pushed down to those columns, so only\n * specific partitions will be retrieved from the remote storage.\n * */\nexport interface PTableRecordSingleValueFilterV2 {\n /** Filter type discriminator */\n readonly type: 'bySingleColumnV2';\n\n /** Target axis selector to examine values from */\n readonly column: PTableColumnId;\n\n /** Value predicate */\n readonly predicate: SingleValuePredicateV2;\n}\n\n/** Generic PTable records filter */\nexport type PTableRecordFilter = PTableRecordSingleValueFilterV2;\n\n/** Sorting parameters for a PTable. */\nexport type PTableSorting = {\n /** Unified column identifier */\n readonly column: PTableColumnId;\n\n /** Sorting order */\n readonly ascending: boolean;\n\n /** Sorting in respect to NA and absent values */\n readonly naAndAbsentAreLeastValues: boolean;\n};\n\n/** Information required to instantiate a PTable. */\nexport interface PTableDef<Col> {\n /** Join tree to populate the PTable */\n readonly src: JoinEntry<Col>;\n\n /** Record filters */\n readonly filters: PTableRecordFilter[];\n\n /** Table sorting */\n readonly sorting: PTableSorting[];\n}\n\n/** Request to create and retrieve entirety of data of PTable. */\nexport type CalculateTableDataRequest<Col> = PTableDef<Col>;\n\n/** Response for {@link CalculateTableDataRequest} */\nexport type CalculateTableDataResponse = FullPTableColumnData[];\n\nexport function mapPTableDef<C1, C2>(\n def: PTableDef<C1>,\n cb: (c: C1) => C2\n): PTableDef<C2> {\n return { ...def, src: mapJoinEntry(def.src, cb) };\n}\n\nexport function mapJoinEntry<C1, C2>(\n entry: JoinEntry<C1>,\n cb: (c: C1) => C2\n): JoinEntry<C2> {\n switch (entry.type) {\n case 'column':\n return {\n type: 'column',\n column: cb(entry.column)\n };\n case 'inner':\n case 'full':\n return {\n type: entry.type,\n entries: entry.entries.map((col) => mapJoinEntry(col, cb))\n };\n case 'outer':\n return {\n type: 'outer',\n primary: mapJoinEntry(entry.primary, cb),\n secondary: entry.secondary.map((col) => mapJoinEntry(col, cb))\n };\n default:\n assertNever(entry);\n }\n}\n","/** Block section visualized as items in left panel block overview */\nexport type BlockSection = BlockSectionLink | BlockSectionDelimiter;\n\n/** Tells the system that specific section from the main UI of this block should\n * be opened */\nexport type BlockSectionLink = {\n /** Potentially there may be multiple section types, i.e. for \"+\" rows and for\n * sections directly opening html from the outputs. */\n readonly type: 'link';\n\n /** Internal block section identifier */\n readonly href: `/${string}`;\n\n /** Visible section title, can also be used in the window header. */\n readonly label: string;\n};\n\n/** Create a horisontal line between sections */\nexport type BlockSectionDelimiter = {\n readonly type: 'delimiter';\n};\n\n/**\n * Part of the block state, representing current navigation information\n * (i.e. currently selected section)\n * */\nexport type NavigationState<Href extends `/${string}` = `/${string}`> = {\n readonly href: Href;\n};\n\nexport const DefaultNavigationState: NavigationState = { href: '/' };\n","import { z } from 'zod';\n\nexport const PlRef = z\n .object({\n __isRef: z\n .literal(true)\n .describe('Crucial marker for the block dependency tree reconstruction'),\n blockId: z.string().describe('Upstream block id'),\n name: z.string().describe(\"Name of the output provided to the upstream block's output context\")\n })\n .describe(\n 'Universal reference type, allowing to set block connections. It is crucial that ' +\n '{@link __isRef} is present and equal to true, internal logic relies on this marker ' +\n 'to build block dependency trees.'\n )\n .strict()\n .readonly();\nexport type PlRef = z.infer<typeof PlRef>;\n/** @deprecated use {@link PlRef} */\nexport type Ref = PlRef;\n\n/** Standard way how to communicate possible connections given specific\n * requirements for incoming data. */\nexport type Option = {\n /** Fully rendered reference to be assigned for the intended field in block's\n * args */\n readonly ref: PlRef;\n\n /** Label to be present for the user in i.e. drop-down list */\n readonly label: string;\n};\n\n/** Compare two PlRefs and returns true if they are qual */\nexport function plRefsEqual(ref1: PlRef, ref2: PlRef) {\n return ref1.blockId === ref2.blockId && ref1.name === ref2.name;\n}\n","import { Branded } from '../branding';\nimport { JoinEntry, PColumn, PColumnSpec } from '../drivers';\nimport { assertNever } from '../util';\nimport { ResultPoolEntry } from './entry';\n\n/** Any object exported into the result pool by the block always have spec attached to it */\nexport interface PObjectSpec {\n /** PObject kind discriminator */\n readonly kind: string;\n\n /** Additional information attached to the object */\n readonly annotations?: Record<string, string>;\n}\n\n/** Stable PObject id */\nexport type PObjectId = Branded<string, 'PColumnId'>;\n\n/**\n * Full PObject representation.\n *\n * @template Data type of the object referencing or describing the \"data\" part of the PObject\n * */\nexport interface PObject<Data> {\n /** Fully rendered PObjects are assigned a stable identifier. */\n readonly id: PObjectId;\n\n /** PObject spec, allowing it to be found among other PObjects */\n readonly spec: PObjectSpec;\n\n /** A handle to data object */\n readonly data: Data;\n}\n\nexport function isPColumnSpec(spec: PObjectSpec): spec is PColumnSpec {\n return spec.kind === 'PColumn';\n}\n\nexport function isPColumn<T>(obj: PObject<T>): obj is PColumn<T> {\n return isPColumnSpec(obj.spec);\n}\n\nexport function isPColumnSpecResult(\n r: ResultPoolEntry<PObjectSpec>\n): r is ResultPoolEntry<PColumnSpec> {\n return isPColumnSpec(r.obj);\n}\n\nexport function isPColumnResult<T>(\n r: ResultPoolEntry<PObject<T>>\n): r is ResultPoolEntry<PColumn<T>> {\n return isPColumnSpec(r.obj.spec);\n}\n\nexport function ensurePColumn<T>(obj: PObject<T>): PColumn<T> {\n if (!isPColumn(obj)) throw new Error(`not a PColumn (kind = ${obj.spec.kind})`);\n return obj;\n}\n\nexport function mapPObjectData<D1, D2>(pObj: PColumn<D1>, cb: (d: D1) => D2): PColumn<D2>;\nexport function mapPObjectData<D1, D2>(\n pObj: PColumn<D1> | undefined,\n cb: (d: D1) => D2\n): PColumn<D2> | undefined;\nexport function mapPObjectData<D1, D2>(pObj: PObject<D1>, cb: (d: D1) => D2): PObject<D2>;\nexport function mapPObjectData<D1, D2>(\n pObj: PObject<D1> | undefined,\n cb: (d: D1) => D2\n): PObject<D2> | undefined;\nexport function mapPObjectData<D1, D2>(\n pObj: PObject<D1> | undefined,\n cb: (d: D1) => D2\n): PObject<D2> | undefined {\n return pObj === undefined\n ? undefined\n : {\n ...pObj,\n data: cb(pObj.data)\n };\n}\n\nexport function extractAllColumns<D>(entry: JoinEntry<PColumn<D>>): PColumn<D>[] {\n const columns = new Map<PObjectId, PColumn<D>>();\n const addAllColumns = (entry: JoinEntry<PColumn<D>>) => {\n switch (entry.type) {\n case 'column':\n columns.set(entry.column.id, entry.column);\n return;\n case 'full':\n case 'inner':\n for (const e of entry.entries) addAllColumns(e);\n return;\n case 'outer':\n addAllColumns(entry.primary);\n for (const e of entry.secondary) addAllColumns(e);\n return;\n default:\n assertNever(entry);\n }\n };\n addAllColumns(entry);\n return [...columns.values()];\n}\n","import { AxisId } from '../drivers';\nimport { PObjectSpec, isPColumnSpec } from './spec';\n\nexport type PSpecPredicate =\n | {\n type: 'and' | 'or';\n operands: PSpecPredicate[];\n }\n | {\n type: 'not';\n operand: PSpecPredicate;\n }\n | {\n type: 'name';\n name: string;\n }\n | {\n type: 'name_pattern';\n pattern: string;\n }\n | {\n type: 'annotation';\n annotation: string;\n value: string;\n }\n | {\n type: 'annotation_pattern';\n annotation: string;\n pattern: string;\n }\n | {\n type: 'has_axes';\n axes: Partial<AxisId>[];\n };\n\nfunction assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x);\n}\n\nexport function executePSpecPredicate(\n predicate: PSpecPredicate,\n spec: PObjectSpec\n): boolean {\n switch (predicate.type) {\n case 'and':\n for (const operator of predicate.operands)\n if (!executePSpecPredicate(operator, spec)) return false;\n return true;\n case 'or':\n for (const operator of predicate.operands)\n if (executePSpecPredicate(operator, spec)) return true;\n return false;\n case 'not':\n return !executePSpecPredicate(predicate.operand, spec);\n case 'name':\n return isPColumnSpec(spec) && spec.name === predicate.name;\n case 'name_pattern':\n return isPColumnSpec(spec) && Boolean(spec.name.match(predicate.pattern));\n case 'annotation':\n return (\n isPColumnSpec(spec) &&\n spec.annotations !== undefined &&\n spec.annotations[predicate.annotation] === predicate.value\n );\n case 'annotation_pattern':\n return (\n isPColumnSpec(spec) &&\n spec.annotations !== undefined &&\n spec.annotations[predicate.annotation] !== undefined &&\n Boolean(spec.annotations[predicate.annotation].match(predicate.pattern))\n );\n case 'has_axes':\n return (\n isPColumnSpec(spec) &&\n predicate.axes.every((matcher) =>\n spec.axesSpec.some(\n (axisSpec) =>\n (matcher.type === undefined || matcher.type === axisSpec.type) &&\n (matcher.name === undefined || matcher.name === axisSpec.name) &&\n (matcher.domain === undefined ||\n Object.keys(matcher.domain).length === 0 ||\n (axisSpec.domain !== undefined &&\n Object.entries(matcher.domain).every(\n ([domain, domainValue]) =>\n axisSpec.domain![domain] === domainValue\n )))\n )\n )\n );\n default:\n assertNever(predicate);\n }\n}\n","export type ValueOrError<V, E> =\n | {\n ok: true;\n value: V;\n }\n | {\n ok: false;\n error: E;\n };\n\nexport function mapValueInVOE<V1, V2, E>(\n voe: ValueOrError<V1, E>,\n cb: (value: V1) => V2\n): ValueOrError<V2, E> {\n return voe.ok ? { ok: true, value: cb(voe.value) } : voe;\n}\n"],"names":["isLiveLog","handle","assertNever","x","uploadPrefix","indexPrefix","isImportFileHandleUpload","isImportFileHandleIndex","getFilePathFromHandle","trimmed","extractFileName","filePath","getFileNameFromHandle","PValueIntNA","PValueLongNA","PValueFloatNA","PValueDoubleNA","PValueStringNA","PValueBytesNA","isValueNA","value","valueType","ensureNotNAPValue","isNotNAPValue","isPValue","toJsonSafePValue","safeConvertToPValue","checkType","pValueToStringOrNumber","pValueToStringOrNumberOrNull","isValueAbsent","absent","index","chunkIndex","mask","PTableNull","PTableNA","pTableValue","column","row","getAxisId","spec","type","name","domain","getAxesId","matchDomain","query","target","k","matchAxisId","mapPTableDef","def","cb","mapJoinEntry","entry","col","DefaultNavigationState","PlRef","z","plRefsEqual","ref1","ref2","isPColumnSpec","isPColumn","obj","isPColumnSpecResult","r","isPColumnResult","ensurePColumn","mapPObjectData","pObj","extractAllColumns","columns","addAllColumns","e","executePSpecPredicate","predicate","operator","matcher","axisSpec","domainValue","mapValueInVOE","voe"],"mappings":"uGAaO,SAASA,EAAUC,EAA2D,CACnF,OAAOA,IAAW,QAAaA,EAAO,WAAW,iBAAiB,CACpE,CCfO,SAASC,EAAYC,EAAiB,CACrC,MAAA,IAAI,MAAM,sBAAwBA,CAAC,CAC3C,CCGA,MAAMC,EAAe,mBACfC,EAAc,iBASb,SAASC,EACdL,EACkC,CAC3B,OAAAA,EAAO,WAAWG,CAAY,CACvC,CAEO,SAASG,EAAwBN,EAA2D,CAC1F,OAAAA,EAAO,WAAWI,CAAW,CACtC,CAuGO,SAASG,EAAsBP,EAAkC,CAClE,GAAAM,EAAwBN,CAAM,EAAG,CACnC,MAAMQ,EAAUR,EAAO,MAAMI,EAAY,MAAM,EAE/C,OADa,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CAACnC,EAAQqC,CAAW,IACnBD,EAAS,OAAQpC,CAAM,IAAMqC,CACjC,EAAA,CAEV,EAEJ,QACE/E,EAAY2E,CAAS,CAAA,CAE3B,CClFgB,SAAAK,EACdC,EACA9B,EACqB,CACd,OAAA8B,EAAI,GAAK,CAAE,GAAI,GAAM,MAAO9B,EAAG8B,EAAI,KAAK,CAAA,EAAMA,CACvD"}
package/dist/index.mjs CHANGED
@@ -1,26 +1,26 @@
1
- import { z as i } from "zod";
1
+ import { z as s } from "zod";
2
2
  function R(t) {
3
3
  return t !== void 0 && t.startsWith("log+live://log/");
4
4
  }
5
- function c(t) {
5
+ function f(t) {
6
6
  throw new Error("Unexpected object: " + t);
7
7
  }
8
- const p = "upload://upload/", d = "index://index/";
9
- function y(t) {
8
+ const p = "upload://upload/", l = "index://index/";
9
+ function b(t) {
10
10
  return t.startsWith(p);
11
11
  }
12
- function b(t) {
13
- return t.startsWith(d);
12
+ function y(t) {
13
+ return t.startsWith(l);
14
14
  }
15
15
  function g(t) {
16
- if (b(t)) {
17
- const n = t.slice(d.length);
16
+ if (y(t)) {
17
+ const n = t.slice(l.length);
18
18
  return JSON.parse(decodeURIComponent(n)).path;
19
- } else if (y(t)) {
19
+ } else if (b(t)) {
20
20
  const n = t.slice(p.length);
21
21
  return JSON.parse(decodeURIComponent(n)).localPath;
22
22
  }
23
- c(t);
23
+ f(t);
24
24
  }
25
25
  function w(t) {
26
26
  return t.replace(/^.*[\\/]/, "");
@@ -28,21 +28,21 @@ function w(t) {
28
28
  function O(t) {
29
29
  return w(g(t));
30
30
  }
31
- const N = -2147483648, f = -9007199254740991n, P = NaN, h = NaN, E = null, x = null;
32
- function u(t, n) {
31
+ const N = -2147483648, d = -9007199254740991n, h = NaN, P = NaN, x = null, E = null;
32
+ function a(t, n) {
33
33
  switch (n) {
34
34
  case "Int":
35
35
  return t === N;
36
36
  case "Long":
37
- return t === Number(f) || t === f;
37
+ return t === Number(d) || t === d;
38
38
  case "Float":
39
- return t === P;
40
- case "Double":
41
39
  return t === h;
40
+ case "Double":
41
+ return t === P;
42
42
  case "String":
43
- return t === E;
44
- case "Bytes":
45
43
  return t === x;
44
+ case "Bytes":
45
+ return t === E;
46
46
  default:
47
47
  throw Error(`unsupported data type: ${n}`);
48
48
  }
@@ -54,7 +54,7 @@ function _(t) {
54
54
  function V(t, n) {
55
55
  if (!n)
56
56
  return typeof t == "string" || typeof t == "number" && isFinite(t) || typeof t == "bigint";
57
- if (u(t, n)) return !1;
57
+ if (a(t, n)) return !1;
58
58
  switch (n) {
59
59
  case "Int":
60
60
  return typeof t == "number";
@@ -75,7 +75,7 @@ function V(t, n) {
75
75
  function I(t, n) {
76
76
  if (!n)
77
77
  return t === null || typeof t == "string" || typeof t == "number" || typeof t == "bigint";
78
- if (u(t, n)) return !0;
78
+ if (a(t, n)) return !0;
79
79
  switch (n) {
80
80
  case "Int":
81
81
  return typeof t == "number";
@@ -98,9 +98,9 @@ function j(t) {
98
98
  if (typeof t == "bigint") return { bigint: t.toString() };
99
99
  throw new Error(`Type ${typeof t} (value ${t}) not yet supported.`);
100
100
  }
101
- function $(t, n) {
101
+ function A(t, n) {
102
102
  if (t === null || typeof t == "string" || typeof t == "number" || typeof t == "bigint") {
103
- if (n && !u(t, n) && !I(t, n))
103
+ if (n && !a(t, n) && !I(t, n))
104
104
  throw new Error(`Unexpected value type, got ${typeof t}, expected ${n}`);
105
105
  return t;
106
106
  }
@@ -112,11 +112,11 @@ function $(t, n) {
112
112
  throw new Error(`Unsupported type ${typeof t} (value ${t}).`);
113
113
  }
114
114
  function H(t) {
115
- if (t = A(t), t === null) throw new Error("Value is null");
115
+ if (t = $(t), t === null) throw new Error("Value is null");
116
116
  return t;
117
117
  }
118
- function A(t) {
119
- if (t = $(t), t === null) return null;
118
+ function $(t) {
119
+ if (t = A(t), t === null) return null;
120
120
  if (typeof t == "string") return t;
121
121
  if (typeof t == "number") {
122
122
  if (!isFinite(t)) throw new Error(`Value is not finite (${t})`);
@@ -130,11 +130,11 @@ function k(t, n) {
130
130
  const r = Math.floor(n / 8), e = 1 << 7 - n % 8;
131
131
  return (t[r] & e) > 0;
132
132
  }
133
- const F = { type: "absent" }, S = null;
133
+ const F = { type: "absent" }, C = null;
134
134
  function J(t, n) {
135
135
  if (k(t.absent, n)) return F;
136
136
  const r = t.data[n], e = t.type;
137
- if (u(r, e)) return S;
137
+ if (a(r, e)) return C;
138
138
  switch (e) {
139
139
  case "Int":
140
140
  return r;
@@ -152,14 +152,14 @@ function J(t, n) {
152
152
  throw Error(`unsupported data type: ${e}`);
153
153
  }
154
154
  }
155
- function B(t) {
155
+ function S(t) {
156
156
  const { type: n, name: r, domain: e } = t;
157
157
  return { type: n, name: r, ...e && { domain: e } };
158
158
  }
159
159
  function W(t) {
160
- return t.map(B);
160
+ return t.map(S);
161
161
  }
162
- function C(t, n) {
162
+ function B(t, n) {
163
163
  if (t === void 0) return n === void 0;
164
164
  if (n === void 0) return !0;
165
165
  for (const r in n)
@@ -167,12 +167,12 @@ function C(t, n) {
167
167
  return !0;
168
168
  }
169
169
  function z(t, n) {
170
- return t.name === n.name && C(t.domain, n.domain);
170
+ return t.name === n.name && B(t.domain, n.domain);
171
171
  }
172
172
  function M(t, n) {
173
- return { ...t, src: s(t.src, n) };
173
+ return { ...t, src: u(t.src, n) };
174
174
  }
175
- function s(t, n) {
175
+ function u(t, n) {
176
176
  switch (t.type) {
177
177
  case "column":
178
178
  return {
@@ -183,22 +183,22 @@ function s(t, n) {
183
183
  case "full":
184
184
  return {
185
185
  type: t.type,
186
- entries: t.entries.map((r) => s(r, n))
186
+ entries: t.entries.map((r) => u(r, n))
187
187
  };
188
188
  case "outer":
189
189
  return {
190
190
  type: "outer",
191
- primary: s(t.primary, n),
192
- secondary: t.secondary.map((r) => s(r, n))
191
+ primary: u(t.primary, n),
192
+ secondary: t.secondary.map((r) => u(r, n))
193
193
  };
194
194
  default:
195
- c(t);
195
+ f(t);
196
196
  }
197
197
  }
198
- const q = { href: "/" }, G = i.object({
199
- __isRef: i.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
200
- blockId: i.string().describe("Upstream block id"),
201
- name: i.string().describe("Name of the output provided to the upstream block's output context")
198
+ const q = { href: "/" }, G = s.object({
199
+ __isRef: s.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
200
+ blockId: s.string().describe("Upstream block id"),
201
+ name: s.string().describe("Name of the output provided to the upstream block's output context")
202
202
  }).describe(
203
203
  "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."
204
204
  ).strict().readonly();
@@ -227,21 +227,41 @@ function Z(t, n) {
227
227
  data: n(t.data)
228
228
  };
229
229
  }
230
+ function T(t) {
231
+ const n = /* @__PURE__ */ new Map(), r = (e) => {
232
+ switch (e.type) {
233
+ case "column":
234
+ n.set(e.column.id, e.column);
235
+ return;
236
+ case "full":
237
+ case "inner":
238
+ for (const i of e.entries) r(i);
239
+ return;
240
+ case "outer":
241
+ r(e.primary);
242
+ for (const i of e.secondary) r(i);
243
+ return;
244
+ default:
245
+ f(e);
246
+ }
247
+ };
248
+ return r(t), [...n.values()];
249
+ }
230
250
  function D(t) {
231
251
  throw new Error("Unexpected object: " + t);
232
252
  }
233
- function a(t, n) {
253
+ function c(t, n) {
234
254
  switch (t.type) {
235
255
  case "and":
236
256
  for (const r of t.operands)
237
- if (!a(r, n)) return !1;
257
+ if (!c(r, n)) return !1;
238
258
  return !0;
239
259
  case "or":
240
260
  for (const r of t.operands)
241
- if (a(r, n)) return !0;
261
+ if (c(r, n)) return !0;
242
262
  return !1;
243
263
  case "not":
244
- return !a(t.operand, n);
264
+ return !c(t.operand, n);
245
265
  case "name":
246
266
  return o(n) && n.name === t.name;
247
267
  case "name_pattern":
@@ -254,7 +274,7 @@ function a(t, n) {
254
274
  return o(n) && t.axes.every(
255
275
  (r) => n.axesSpec.some(
256
276
  (e) => (r.type === void 0 || r.type === e.type) && (r.name === void 0 || r.name === e.name) && (r.domain === void 0 || Object.keys(r.domain).length === 0 || e.domain !== void 0 && Object.entries(r.domain).every(
257
- ([m, l]) => e.domain[m] === l
277
+ ([i, m]) => e.domain[i] === m
258
278
  ))
259
279
  )
260
280
  );
@@ -262,29 +282,30 @@ function a(t, n) {
262
282
  D(t);
263
283
  }
264
284
  }
265
- function T(t, n) {
285
+ function v(t, n) {
266
286
  return t.ok ? { ok: !0, value: n(t.value) } : t;
267
287
  }
268
288
  export {
269
289
  q as DefaultNavigationState,
270
- S as PTableNA,
290
+ C as PTableNA,
271
291
  F as PTableNull,
272
- x as PValueBytesNA,
273
- h as PValueDoubleNA,
274
- P as PValueFloatNA,
292
+ E as PValueBytesNA,
293
+ P as PValueDoubleNA,
294
+ h as PValueFloatNA,
275
295
  N as PValueIntNA,
276
- f as PValueLongNA,
277
- E as PValueStringNA,
296
+ d as PValueLongNA,
297
+ x as PValueStringNA,
278
298
  G as PlRef,
279
299
  _ as ensureNotNAPValue,
280
300
  Y as ensurePColumn,
281
- a as executePSpecPredicate,
301
+ c as executePSpecPredicate,
302
+ T as extractAllColumns,
282
303
  W as getAxesId,
283
- B as getAxisId,
304
+ S as getAxisId,
284
305
  O as getFileNameFromHandle,
285
306
  g as getFilePathFromHandle,
286
- b as isImportFileHandleIndex,
287
- y as isImportFileHandleUpload,
307
+ y as isImportFileHandleIndex,
308
+ b as isImportFileHandleUpload,
288
309
  R as isLiveLog,
289
310
  V as isNotNAPValue,
290
311
  U as isPColumn,
@@ -293,17 +314,17 @@ export {
293
314
  Q as isPColumnSpecResult,
294
315
  I as isPValue,
295
316
  k as isValueAbsent,
296
- u as isValueNA,
297
- s as mapJoinEntry,
317
+ a as isValueNA,
318
+ u as mapJoinEntry,
298
319
  Z as mapPObjectData,
299
320
  M as mapPTableDef,
300
- T as mapValueInVOE,
321
+ v as mapValueInVOE,
301
322
  z as matchAxisId,
302
323
  J as pTableValue,
303
324
  H as pValueToStringOrNumber,
304
- A as pValueToStringOrNumberOrNull,
325
+ $ as pValueToStringOrNumberOrNull,
305
326
  K as plRefsEqual,
306
- $ as safeConvertToPValue,
327
+ A as safeConvertToPValue,
307
328
  j as toJsonSafePValue
308
329
  };
309
330
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/drivers/log.ts","../src/util.ts","../src/drivers/ls.ts","../src/drivers/pframe/data.ts","../src/drivers/pframe/spec.ts","../src/drivers/pframe/table_calculate.ts","../src/navigation.ts","../src/ref.ts","../src/pool/spec.ts","../src/pool/query.ts","../src/value_or_error.ts"],"sourcesContent":["/** Handle of logs. This handle should be passed\n * to the driver for retrieving logs. */\nexport type AnyLogHandle = LiveLogHandle | ReadyLogHandle;\n\n/** Handle of the live logs of a program.\n * The resource that represents a log can be deleted,\n * in this case the handle should be refreshed. */\nexport type LiveLogHandle = `log+live://log/${string}`;\n\n/** Handle of the ready logs of a program. */\nexport type ReadyLogHandle = `log+ready://log/${string}`;\n\n/** Type guard to check if log is live, and corresponding porcess is not finished. */\nexport function isLiveLog(handle: AnyLogHandle | undefined): handle is LiveLogHandle {\n return handle !== undefined && handle.startsWith('log+live://log/');\n}\n\n/** Driver to retrieve logs given log handle */\nexport interface LogsDriver {\n lastLines(\n /** A handle that was issued previously. */\n handle: AnyLogHandle,\n\n /** Allows client to limit total data sent from server. */\n lineCount: number,\n\n /** Makes streamer to perform seek operation to given offset before sending the contents.\n * Client can just use the <new_offset> value of the last response from server to continue streaming after reconnection.\n * If undefined, then starts from the end. */\n offsetBytes?: number,\n\n /** Is substring for line search pattern.\n * This option makes controller to send to the client only lines, that\n * have given substring. */\n searchStr?: string\n ): Promise<StreamingApiResponse>;\n\n readText(\n /** A handle that was issued previously. */\n handle: AnyLogHandle,\n\n /** Allows client to limit total data sent from server. */\n lineCount: number,\n\n /** Makes streamer to perform seek operation to given offset before sending the contents.\n * Client can just use the <new_offset> value of the last response from server to continue streaming after reconnection.\n * If undefined of 0, then starts from the beginning. */\n offsetBytes?: number,\n\n /** Is substring for line search pattern.\n * This option makes controller to send to the client only lines, that\n * have given substring. */\n searchStr?: string\n ): Promise<StreamingApiResponse>;\n}\n\n/** Response of the driver.\n * The caller should give a handle to retrieve it.\n * It can be OK or outdated, in which case the handle\n * should be issued again. */\nexport type StreamingApiResponse = StreamingApiResponseOk | StreamingApiResponseHandleOutdated;\n\nexport type StreamingApiResponseOk = {\n /** The handle don't have to be updated,\n * the response is OK. */\n shouldUpdateHandle: false;\n\n /** Whether the log can still grow or it's in a final state. */\n live: boolean;\n\n /** Data of the response, in bytes. */\n data: Uint8Array;\n /** Current size of the file. It can grow if it's still live. */\n size: number;\n /** Offset in bytes from the beginning of a file. */\n newOffset: number;\n};\n\n/** The handle should be issued again, this one is done. */\nexport type StreamingApiResponseHandleOutdated = {\n shouldUpdateHandle: true;\n};\n","export function assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x);\n}\n","import { assertNever } from '../util';\nimport { Branded } from '../branding';\nimport { TableRange } from './pframe';\nimport { FileLike } from './interfaces';\n\nconst uploadPrefix = 'upload://upload/';\nconst indexPrefix = 'index://index/';\n\nexport type ImportFileHandleUpload = `upload://upload/${string}`;\nexport type ImportFileHandleIndex = `index://index/${string}`;\n\nexport type ImportFileHandle = ImportFileHandleUpload | ImportFileHandleIndex;\n\nexport type LocalImportFileHandle = Branded<ImportFileHandle, 'Local'>;\n\nexport function isImportFileHandleUpload(\n handle: ImportFileHandle\n): handle is ImportFileHandleUpload {\n return handle.startsWith(uploadPrefix);\n}\n\nexport function isImportFileHandleIndex(handle: ImportFileHandle): handle is ImportFileHandleIndex {\n return handle.startsWith(indexPrefix);\n}\n\n/** Results in upload */\nexport type StorageHandleLocal = `local://${string}`;\n\n/** Results in index */\nexport type StorageHandleRemote = `remote://${string}`;\n\nexport type StorageHandle = StorageHandleLocal | StorageHandleRemote;\n\nexport type StorageEntry = {\n name: string;\n handle: StorageHandle;\n initialFullPath: string;\n\n // TODO\n // pathStartsWithDisk\n};\n\nexport type ListFilesResult = {\n parent?: string;\n entries: LsEntry[];\n};\n\nexport type LsEntry =\n | {\n type: 'dir';\n name: string;\n fullPath: string;\n }\n | {\n type: 'file';\n name: string;\n fullPath: string;\n\n /** This handle should be set to args... */\n handle: ImportFileHandle;\n };\n\nexport type OpenDialogFilter = {\n /** Human-readable file type name */\n readonly name: string;\n /** File extensions */\n readonly extensions: string[];\n};\n\nexport type OpenDialogOps = {\n /** Open dialog window title */\n readonly title?: string;\n /** Custom label for the confirmation button, when left empty the default label will be used. */\n readonly buttonLabel?: string;\n /** Limits of file types user can select */\n readonly filters?: OpenDialogFilter[];\n};\n\nexport type OpenSingleFileResponse = {\n /** Contains local file handle, allowing file importing or content reading. If user canceled\n * the dialog, field will be undefined. */\n readonly file?: LocalImportFileHandle;\n};\n\nexport type OpenMultipleFilesResponse = {\n /** Contains local file handles, allowing file importing or content reading. If user canceled\n * the dialog, field will be undefined. */\n readonly files?: LocalImportFileHandle[];\n};\n\n/** Can be used to limit request for local file content to a certain bytes range */\nexport type FileRange = {\n /** From byte index (inclusive) */\n readonly from: number;\n /** To byte index (exclusive) */\n readonly to: number;\n};\n\nexport interface LsDriver {\n /** remote and local storages */\n getStorageList(): Promise<StorageEntry[]>;\n\n listFiles(storage: StorageHandle, fullPath: string): Promise<ListFilesResult>;\n\n /** Opens system file open dialog allowing to select single file and awaits user action */\n showOpenSingleFileDialog(ops: OpenDialogOps): Promise<OpenSingleFileResponse>;\n\n /** Opens system file open dialog allowing to multiple files and awaits user action */\n showOpenMultipleFilesDialog(ops: OpenDialogOps): Promise<OpenMultipleFilesResponse>;\n\n /** Given a handle to a local file, allows to get file size */\n getLocalFileSize(file: LocalImportFileHandle): Promise<number>;\n\n /** Given a handle to a local file, allows to get its content */\n getLocalFileContent(file: LocalImportFileHandle, range?: TableRange): Promise<Uint8Array>;\n\n /**\n * Resolves browser's File object into platforma's import file handle.\n *\n * This method is useful among other things for implementation of UI\n * components, that handle file Drag&Drop.\n * */\n fileToImportHandle(file: FileLike): Promise<ImportFileHandle>;\n}\n\n/** Gets a file path from an import handle. */\nexport function getFilePathFromHandle(handle: ImportFileHandle): string {\n if (isImportFileHandleIndex(handle)) {\n const trimmed = handle.slice(indexPrefix.length);\n const data = JSON.parse(decodeURIComponent(trimmed));\n return data.path;\n } else if (isImportFileHandleUpload(handle)) {\n const trimmed = handle.slice(uploadPrefix.length);\n const data = JSON.parse(decodeURIComponent(trimmed));\n return data.localPath;\n }\n\n assertNever(handle);\n}\n\nfunction extractFileName(filePath: string) {\n return filePath.replace(/^.*[\\\\/]/, '');\n}\n\n/** Gets a file name from an import handle. */\nexport function getFileNameFromHandle(handle: ImportFileHandle): string {\n return extractFileName(getFilePathFromHandle(handle));\n}\n","import { number } from 'zod';\nimport { ValueType } from './spec';\n\nexport const PValueIntNA = -2147483648;\nexport const PValueLongNA = -9007199254740991n;\nexport const PValueFloatNA = NaN;\nexport const PValueDoubleNA = NaN;\nexport const PValueStringNA = null;\nexport const PValueBytesNA = null;\n\nexport type PValueInt = number;\nexport type PValueLong = number | bigint; // use bigint only if extra integer precision is needed\nexport type PValueFloat = number;\nexport type PValueDouble = number;\nexport type PValueString = string | null;\nexport type PValueBytes = Uint8Array | null;\n\nexport type NotNAPValueInt = number;\nexport type NotNAPValueLong = number | bigint; // use bigint only if extra integer precision is needed\nexport type NotNAPValueFloat = number;\nexport type NotNAPValueDouble = number;\nexport type NotNAPValueString = string;\n\nexport type NotNAPValue = number | bigint | string;\n\nexport type PValue =\n | PValueInt\n | PValueLong\n | PValueFloat\n | PValueDouble\n | PValueString\n | PValueBytes;\n\nexport function isValueNA(value: unknown, valueType: ValueType): boolean {\n switch (valueType) {\n case 'Int':\n return value === PValueIntNA;\n case 'Long':\n return value === Number(PValueLongNA) || value === PValueLongNA;\n case 'Float':\n return value === PValueFloatNA;\n case 'Double':\n return value === PValueDoubleNA;\n case 'String':\n return value === PValueStringNA;\n case 'Bytes':\n return value === PValueBytesNA;\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\nexport function ensureNotNAPValue(value: string): string;\nexport function ensureNotNAPValue(value: number): number;\nexport function ensureNotNAPValue(value: bigint): bigint;\nexport function ensureNotNAPValue(value: unknown): NotNAPValue;\nexport function ensureNotNAPValue(value: unknown): NotNAPValue {\n if (!isNotNAPValue(value)) throw new Error(`Expected not-NA PValue, got ${value}`);\n return value;\n}\n\nexport function isNotNAPValue(value: unknown, valueType: 'Int'): value is number;\nexport function isNotNAPValue(value: unknown, valueType: 'Long'): value is number | bigint;\nexport function isNotNAPValue(value: unknown, valueType: 'Float'): value is number;\nexport function isNotNAPValue(value: unknown, valueType: 'Double'): value is number;\nexport function isNotNAPValue(value: unknown, valueType: 'String'): value is string;\nexport function isNotNAPValue(value: unknown, valueType: ValueType): value is NotNAPValue;\nexport function isNotNAPValue(value: unknown): value is NotNAPValue;\nexport function isNotNAPValue(value: unknown, valueType?: ValueType): boolean {\n if (!valueType)\n return (\n typeof value === 'string' ||\n (typeof value === 'number' && isFinite(value)) ||\n typeof value === 'bigint'\n );\n if (isValueNA(value, valueType)) return false;\n switch (valueType) {\n case 'Int':\n return typeof value === 'number';\n case 'Long':\n return typeof value === 'number' || typeof value === 'bigint';\n case 'Float':\n return typeof value === 'number';\n case 'Double':\n return typeof value === 'number';\n case 'String':\n return typeof value === 'string';\n case 'Bytes':\n throw Error(`Bytes not yet supported`);\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\nexport function isPValue(value: unknown, valueType: 'Int'): value is PValueInt;\nexport function isPValue(value: unknown, valueType: 'Long'): value is PValueLong;\nexport function isPValue(value: unknown, valueType: 'Float'): value is PValueFloat;\nexport function isPValue(value: unknown, valueType: 'Double'): value is PValueDouble;\nexport function isPValue(value: unknown, valueType: 'String'): value is PValueString;\nexport function isPValue(value: unknown, valueType: ValueType): value is PValue;\nexport function isPValue(value: unknown): value is PValue;\nexport function isPValue(value: unknown, valueType?: ValueType): boolean {\n if (!valueType)\n return (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'bigint'\n );\n if (isValueNA(value, valueType)) return true;\n switch (valueType) {\n case 'Int':\n return typeof value === 'number';\n case 'Long':\n return typeof value === 'number' || typeof value === 'bigint';\n case 'Float':\n return typeof value === 'number';\n case 'Double':\n return typeof value === 'number';\n case 'String':\n return typeof value === 'string';\n case 'Bytes':\n throw Error(`Bytes not yet supported`);\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\nexport type PValueLongJsonSafe = { bigint: string };\nexport type PValueJsonSafe = number | string | null | PValueLongJsonSafe;\n\n/**\n * Converts PValue to value that can be safely serialized by standard JSON.stringify\n * method. Use {@link safeConvertToPValue} to \"deserialize\" the value back to runtime\n * PValue representation.\n */\nexport function toJsonSafePValue(value: PValue): PValueJsonSafe {\n if (value === null || typeof value === 'string' || typeof value === 'number') return value;\n if (typeof value === 'bigint') return { bigint: value.toString() };\n throw new Error(`Type ${typeof value} (value ${value}) not yet supported.`);\n}\n\n/**\n * Can be used to \"deserialize\" result of {@link toJsonSafePValue} or to\n * safely cast any unknown value to actual runtime PValue representation.\n */\nexport function safeConvertToPValue(value: unknown, checkType?: ValueType): PValue {\n if (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'bigint'\n ) {\n if (checkType && !isValueNA(value, checkType) && !isPValue(value, checkType))\n throw new Error(`Unexpected value type, got ${typeof value}, expected ${checkType}`);\n return value;\n }\n\n if (\n typeof value === 'object' &&\n value !== null &&\n 'bigint' in value &&\n typeof value.bigint === 'string'\n ) {\n if (checkType && checkType !== 'Long')\n throw new Error(`Unexpected value type, got serialized bigint, expected ${checkType}`);\n\n return BigInt(value.bigint);\n }\n\n throw new Error(`Unsupported type ${typeof value} (value ${value}).`);\n}\n\nexport function pValueToStringOrNumber(value: string): string;\nexport function pValueToStringOrNumber(value: number | bigint): number;\nexport function pValueToStringOrNumber(value: PValue | PValueJsonSafe): string | number;\nexport function pValueToStringOrNumber(value: PValue | PValueJsonSafe): string | number {\n value = pValueToStringOrNumberOrNull(value);\n if (value === null) throw new Error('Value is null');\n return value;\n}\n\nexport function pValueToStringOrNumberOrNull(value: string | null): string;\nexport function pValueToStringOrNumberOrNull(value: number | bigint | null): number;\nexport function pValueToStringOrNumberOrNull(\n value: PValue | PValueJsonSafe\n): string | number | null;\nexport function pValueToStringOrNumberOrNull(\n value: PValue | PValueJsonSafe\n): string | number | null {\n value = safeConvertToPValue(value);\n if (value === null) return null;\n if (typeof value === 'string') return value;\n if (typeof value === 'number') {\n if (!isFinite(value)) throw new Error(`Value is not finite (${value})`);\n return value;\n }\n if (typeof value === 'bigint') {\n // @TODO add range check\n return Number(value);\n }\n throw new Error(`Unexpected value type: ${typeof value}`);\n}\n\nexport type PVectorDataInt = Int32Array;\nexport type PVectorDataLong = BigInt64Array;\nexport type PVectorDataFloat = Float32Array;\nexport type PVectorDataDouble = Float64Array;\nexport type PVectorDataString = PValueString[];\nexport type PVectorDataBytes = PValueBytes[];\n\nexport type PVectorData =\n | PVectorDataInt\n | PVectorDataLong\n | PVectorDataFloat\n | PVectorDataDouble\n | PVectorDataString\n | PVectorDataBytes;\n\n/** Table column data in comparison to the data stored in a separate PColumn\n * may have some of the values \"absent\", i.e. as a result of missing record in\n * outer join operation. This information is encoded in {@link absent} field. */\nexport interface PTableVector {\n /** Stored data type */\n readonly type: ValueType;\n\n /** Values for present positions, absent positions have NA values */\n readonly data: PVectorData;\n\n /**\n * Encoded bit array marking some elements of this vector as absent,\n * call {@link isValueAbsent} to read the data.\n * */\n readonly absent: Uint8Array;\n}\n\n/** Used to read bit array with value absence information */\nexport function isValueAbsent(absent: Uint8Array, index: number): boolean {\n const chunkIndex = Math.floor(index / 8);\n const mask = 1 << (7 - (index % 8));\n return (absent[chunkIndex] & mask) > 0;\n}\n\nexport const PTableNull = { type: 'absent' };\nexport const PTableNA = null;\n\n/** Decoded PTable value */\nexport type PTableValue =\n | typeof PTableNull\n | typeof PTableNA\n | number | string;\n\n/** Read PTableValue from PTable column at specified row */\nexport function pTableValue(column: PTableVector, row: number): PTableValue {\n if (isValueAbsent(column.absent, row)) return PTableNull;\n\n const value = column.data[row];\n const valueType = column.type;\n if (isValueNA(value, valueType)) return PTableNA;\n\n switch (valueType) {\n case 'Int':\n return value as PVectorDataInt[number];\n case 'Long':\n return Number(value as PVectorDataLong[number]);\n case 'Float':\n return value as PVectorDataFloat[number];\n case 'Double':\n return value as PVectorDataDouble[number];\n case 'String':\n return value as PVectorDataString[number];\n case 'Bytes':\n throw Error(`Bytes not yet supported`);\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\n/** Used in requests to partially retrieve table's data */\nexport type TableRange = {\n /** Index of the first record to retrieve */\n readonly offset: number;\n\n /** Block length */\n readonly length: number;\n};\n\n/** Unified information about table shape */\nexport type PTableShape = {\n /** Number of unified table columns, including all axes and PColumn values */\n columns: number;\n\n /** Number of rows */\n rows: number;\n};\n","import { PObject, PObjectId, PObjectSpec } from '../../pool';\n\n/** PFrame columns and axes within them may store one of these types. */\nexport type ValueType = 'Int' | 'Long' | 'Float' | 'Double' | 'String' | 'Bytes';\n\n/**\n * Specification of an individual axis.\n *\n * Each axis is a part of a composite key that addresses data inside the PColumn.\n *\n * Each record inside a PColumn is addressed by a unique tuple of values set for\n * all the axes specified in the column spec.\n * */\nexport interface AxisSpec {\n /** Type of the axis value. Should not use non-key types like float or double. */\n readonly type: ValueType;\n\n /** Name of the axis */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Any additional information attached to the axis that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /**\n * Parent axes provide contextual grouping for the axis in question, establishing\n * a hierarchy where the current axis is dependent on one or more axes for its\n * full definition and meaning. For instance, in a data structure where each\n * \"container\" axis may contain multiple \"item\" axes, the `item` axis would\n * list the index of the `container` axis in this field to denote its dependency.\n *\n * This means that the identity or significance of the `item` axis is only\n * interpretable when combined with its parent `container` axis. An `item` axis\n * index by itself may be non-unique and only gains uniqueness within the context\n * of its parent `container`. Therefore, the `parentAxes` field is essential for\n * mapping these relationships and ensuring data coherence across nested or\n * multi-level data models.\n *\n * A list of zero-based indices of parent axes in the overall axes specification\n * from the column spec. Each index corresponds to the position of a parent axis\n * in the list that defines the structure of the data model.\n */\n readonly parentAxes?: number[];\n}\n\n/** Common type representing spec for all the axes in a column */\nexport type AxesSpec = AxisSpec[];\n\n/**\n * Full column specification including all axes specs and specs of the column\n * itself.\n *\n * A PColumn in its essence represents a mapping from a fixed size, explicitly\n * typed tuple to an explicitly typed value.\n *\n * (axis1Value1, axis2Value1, ...) -> columnValue\n *\n * Each element in tuple correspond to the axis having the same index in axesSpec.\n * */\nexport interface PColumnSpec extends PObjectSpec {\n /** Defines specific type of BObject, the most generic type of unit of\n * information in Platforma Project. */\n readonly kind: 'PColumn';\n\n /** Type of column values */\n readonly valueType: ValueType;\n\n /** Column name */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Any additional information attached to the column that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /** A list of zero-based indices of parent axes from the {@link axesSpec} array. */\n readonly parentAxes?: number[];\n\n /** Axes specifications */\n readonly axesSpec: AxesSpec;\n}\n\nexport interface PColumn<Data> extends PObject<Data> {\n /** PColumn spec, allowing it to be found among other PObjects */\n readonly spec: PColumnSpec;\n}\n\n/** Columns in a PFrame also have internal identifier, this object represents\n * combination of specs and such id */\nexport interface PColumnIdAndSpec {\n /** Internal column id within the PFrame */\n readonly columnId: PObjectId;\n\n /** Column spec */\n readonly spec: PColumnSpec;\n}\n\n/** Information returned by {@link PFrame.listColumns} method */\nexport interface PColumnInfo extends PColumnIdAndSpec {\n /** True if data was associated with this PColumn */\n readonly hasData: boolean;\n}\n\nexport interface AxisId {\n /** Type of the axis or column value. For an axis should not use non-key\n * types like float or double. */\n readonly type: ValueType;\n\n /** Name of the axis or column */\n readonly name: string;\n\n /** Adds auxiliary information to the axis or column name and type to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n}\n\n/** Array of axis ids */\nexport type AxesId = AxisId[];\n\n/** Extracts axis ids from axis spec */\nexport function getAxisId(spec: AxisSpec): AxisId {\n const { type, name, domain } = spec;\n return { type, name, ...(domain && { domain }) };\n}\n\n/** Extracts axes ids from axes spec array from column spec */\nexport function getAxesId(spec: AxesSpec): AxesId {\n return spec.map(getAxisId);\n}\n\n/** Returns true if all domains from query are found in target */\nfunction matchDomain(query?: Record<string, string>, target?: Record<string, string>) {\n if (query === undefined) return target === undefined;\n if (target === undefined) return true;\n for (const k in target) {\n if (query[k] !== target[k]) return false;\n }\n return true;\n}\n\n/** Returns whether \"match\" axis id is compatible with the \"query\" */\nexport function matchAxisId(query: AxisId, target: AxisId): boolean {\n return query.name === target.name && matchDomain(query.domain, target.domain);\n}\n","import { PTableColumnId, PTableColumnSpec } from './table_common';\nimport { PTableVector } from './data';\nimport { assertNever } from '../../util';\n\n/** Defines a terminal column node in the join request tree */\nexport interface ColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: 'column';\n\n /** Local column */\n readonly column: Col;\n}\n\n/**\n * Defines a join request tree node that will output only records present in\n * all child nodes ({@link entries}).\n * */\nexport interface InnerJoin<Col> {\n /** Node type discriminator */\n readonly type: 'inner';\n\n /** Child nodes to be inner joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present at\n * least in one of the child nodes ({@link entries}), values for those PColumns\n * that lacks corresponding combinations of axis values will be marked as absent,\n * see {@link PTableVector.absent}.\n * */\nexport interface FullJoin<Col> {\n /** Node type discriminator */\n readonly type: 'full';\n\n /** Child nodes to be fully outer joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present in\n * {@link primary} child node, and records from the {@link secondary} nodes will\n * be added to the output only if present, values for those PColumns from the\n * {@link secondary} list, that lacks corresponding combinations of axis values\n * will be marked as absent, see {@link PTableVector.absent}.\n *\n * This node can be thought as a chain of SQL LEFT JOIN operations starting from\n * the {@link primary} node and adding {@link secondary} nodes one by one.\n * */\nexport interface OuterJoin<Col> {\n /** Node type discriminator */\n readonly type: 'outer';\n\n /** Primes the join operation. Left part of LEFT JOIN. */\n readonly primary: JoinEntry<Col>;\n\n /** Driven nodes, giving their values only if primary node have corresponding\n * nodes. Right parts of LEFT JOIN chain. */\n readonly secondary: JoinEntry<Col>[];\n}\n\n/**\n * Base type of all join request tree nodes. Join request tree allows to combine\n * information from multiple PColumns into a PTable. Correlation between records\n * is performed by looking for records with the same values in common axis between\n * the PColumns. Common axis are those axis which have equal {@link AxisId} derived\n * from the columns axes spec.\n * */\nexport type JoinEntry<Col> =\n | ColumnJoinEntry<Col>\n | InnerJoin<Col>\n | FullJoin<Col>\n | OuterJoin<Col>;\n\n/** Container representing whole data stored in specific PTable column. */\nexport interface FullPTableColumnData {\n /** Unified spec */\n readonly spec: PTableColumnSpec;\n\n /** Data */\n readonly data: PTableVector;\n}\n\nexport interface SingleValueIsNAPredicate {\n /** Comparison operator */\n readonly operator: 'IsNA';\n}\n\nexport interface SingleValueEqualPredicate {\n /** Comparison operator */\n readonly operator: 'Equal';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueIEqualPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'IEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string;\n}\n\nexport interface SingleValueLessPredicate {\n /** Comparison operator */\n readonly operator: 'Less';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueLessOrEqualPredicate {\n /** Comparison operator */\n readonly operator: 'LessOrEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterPredicate {\n /** Comparison operator */\n readonly operator: 'Greater';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterOrEqualPredicate {\n /** Comparison operator */\n readonly operator: 'GreaterOrEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueStringContainsPredicate {\n /** Comparison operator */\n readonly operator: 'StringContains';\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueStringIContainsPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'StringIContains';\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueMatchesPredicate {\n /** Comparison operator */\n readonly operator: 'Matches';\n\n /** Regular expression, NA values are skipped */\n readonly regex: string;\n}\n\nexport interface SingleValueStringContainsFuzzyPredicate {\n /** Comparison operator */\n readonly operator: 'StringContainsFuzzy';\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueStringIContainsFuzzyPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'StringIContainsFuzzy';\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueNotPredicateV2 {\n /** Comparison operator */\n readonly operator: 'Not';\n\n /** Operand to negate */\n readonly operand: SingleValuePredicateV2;\n}\n\nexport interface SingleValueAndPredicateV2 {\n /** Comparison operator */\n readonly operator: 'And';\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\nexport interface SingleValueOrPredicateV2 {\n /** Comparison operator */\n readonly operator: 'Or';\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\n/** Filtering predicate for a single axis or column value */\nexport type SingleValuePredicateV2 =\n | SingleValueIsNAPredicate\n | SingleValueEqualPredicate\n | SingleValueLessPredicate\n | SingleValueLessOrEqualPredicate\n | SingleValueGreaterPredicate\n | SingleValueGreaterOrEqualPredicate\n | SingleValueStringContainsPredicate\n | SingleValueMatchesPredicate\n | SingleValueStringContainsFuzzyPredicate\n | SingleValueNotPredicateV2\n | SingleValueAndPredicateV2\n | SingleValueOrPredicateV2\n | SingleValueIEqualPredicate\n | SingleValueStringIContainsPredicate\n | SingleValueStringIContainsFuzzyPredicate;\n\n/**\n * Filter PTable records based on specific axis or column value. If this is an\n * axis value filter and the axis is part of a partitioning key in some of the\n * source PColumns, the filter will be pushed down to those columns, so only\n * specific partitions will be retrieved from the remote storage.\n * */\nexport interface PTableRecordSingleValueFilterV2 {\n /** Filter type discriminator */\n readonly type: 'bySingleColumnV2';\n\n /** Target axis selector to examine values from */\n readonly column: PTableColumnId;\n\n /** Value predicate */\n readonly predicate: SingleValuePredicateV2;\n}\n\n/** Generic PTable records filter */\nexport type PTableRecordFilter = PTableRecordSingleValueFilterV2;\n\n/** Sorting parameters for a PTable. */\nexport type PTableSorting = {\n /** Unified column identifier */\n readonly column: PTableColumnId;\n\n /** Sorting order */\n readonly ascending: boolean;\n\n /** Sorting in respect to NA and absent values */\n readonly naAndAbsentAreLeastValues: boolean;\n};\n\n/** Information required to instantiate a PTable. */\nexport interface PTableDef<Col> {\n /** Join tree to populate the PTable */\n readonly src: JoinEntry<Col>;\n\n /** Record filters */\n readonly filters: PTableRecordFilter[];\n\n /** Table sorting */\n readonly sorting: PTableSorting[];\n}\n\n/** Request to create and retrieve entirety of data of PTable. */\nexport type CalculateTableDataRequest<Col> = PTableDef<Col>;\n\n/** Response for {@link CalculateTableDataRequest} */\nexport type CalculateTableDataResponse = FullPTableColumnData[];\n\nexport function mapPTableDef<C1, C2>(\n def: PTableDef<C1>,\n cb: (c: C1) => C2\n): PTableDef<C2> {\n return { ...def, src: mapJoinEntry(def.src, cb) };\n}\n\nexport function mapJoinEntry<C1, C2>(\n entry: JoinEntry<C1>,\n cb: (c: C1) => C2\n): JoinEntry<C2> {\n switch (entry.type) {\n case 'column':\n return {\n type: 'column',\n column: cb(entry.column)\n };\n case 'inner':\n case 'full':\n return {\n type: entry.type,\n entries: entry.entries.map((col) => mapJoinEntry(col, cb))\n };\n case 'outer':\n return {\n type: 'outer',\n primary: mapJoinEntry(entry.primary, cb),\n secondary: entry.secondary.map((col) => mapJoinEntry(col, cb))\n };\n default:\n assertNever(entry);\n }\n}\n","/** Block section visualized as items in left panel block overview */\nexport type BlockSection = BlockSectionLink | BlockSectionDelimiter;\n\n/** Tells the system that specific section from the main UI of this block should\n * be opened */\nexport type BlockSectionLink = {\n /** Potentially there may be multiple section types, i.e. for \"+\" rows and for\n * sections directly opening html from the outputs. */\n readonly type: 'link';\n\n /** Internal block section identifier */\n readonly href: `/${string}`;\n\n /** Visible section title, can also be used in the window header. */\n readonly label: string;\n};\n\n/** Create a horisontal line between sections */\nexport type BlockSectionDelimiter = {\n readonly type: 'delimiter';\n};\n\n/**\n * Part of the block state, representing current navigation information\n * (i.e. currently selected section)\n * */\nexport type NavigationState<Href extends `/${string}` = `/${string}`> = {\n readonly href: Href;\n};\n\nexport const DefaultNavigationState: NavigationState = { href: '/' };\n","import { z } from 'zod';\n\nexport const PlRef = z\n .object({\n __isRef: z\n .literal(true)\n .describe('Crucial marker for the block dependency tree reconstruction'),\n blockId: z.string().describe('Upstream block id'),\n name: z.string().describe(\"Name of the output provided to the upstream block's output context\")\n })\n .describe(\n 'Universal reference type, allowing to set block connections. It is crucial that ' +\n '{@link __isRef} is present and equal to true, internal logic relies on this marker ' +\n 'to build block dependency trees.'\n )\n .strict()\n .readonly();\nexport type PlRef = z.infer<typeof PlRef>;\n/** @deprecated use {@link PlRef} */\nexport type Ref = PlRef;\n\n/** Standard way how to communicate possible connections given specific\n * requirements for incoming data. */\nexport type Option = {\n /** Fully rendered reference to be assigned for the intended field in block's\n * args */\n readonly ref: PlRef;\n\n /** Label to be present for the user in i.e. drop-down list */\n readonly label: string;\n};\n\n/** Compare two PlRefs and returns true if they are qual */\nexport function plRefsEqual(ref1: PlRef, ref2: PlRef) {\n return ref1.blockId === ref2.blockId && ref1.name === ref2.name;\n}\n","import { Branded } from '../branding';\nimport { PColumn, PColumnSpec } from '../drivers';\nimport { ResultPoolEntry } from './entry';\n\n/** Any object exported into the result pool by the block always have spec attached to it */\nexport interface PObjectSpec {\n /** PObject kind discriminator */\n readonly kind: string;\n\n /** Additional information attached to the object */\n readonly annotations?: Record<string, string>;\n}\n\n/** Stable PObject id */\nexport type PObjectId = Branded<string, 'PColumnId'>;\n\n/**\n * Full PObject representation.\n *\n * @template Data type of the object referencing or describing the \"data\" part of the PObject\n * */\nexport interface PObject<Data> {\n /** Fully rendered PObjects are assigned a stable identifier. */\n readonly id: PObjectId;\n\n /** PObject spec, allowing it to be found among other PObjects */\n readonly spec: PObjectSpec;\n\n /** A handle to data object */\n readonly data: Data;\n}\n\nexport function isPColumnSpec(spec: PObjectSpec): spec is PColumnSpec {\n return spec.kind === 'PColumn';\n}\n\nexport function isPColumn<T>(obj: PObject<T>): obj is PColumn<T> {\n return isPColumnSpec(obj.spec);\n}\n\nexport function isPColumnSpecResult(\n r: ResultPoolEntry<PObjectSpec>\n): r is ResultPoolEntry<PColumnSpec> {\n return isPColumnSpec(r.obj);\n}\n\nexport function isPColumnResult<T>(\n r: ResultPoolEntry<PObject<T>>\n): r is ResultPoolEntry<PColumn<T>> {\n return isPColumnSpec(r.obj.spec);\n}\n\nexport function ensurePColumn<T>(obj: PObject<T>): PColumn<T> {\n if (!isPColumn(obj)) throw new Error(`not a PColumn (kind = ${obj.spec.kind})`);\n return obj;\n}\n\nexport function mapPObjectData<D1, D2>(pObj: PColumn<D1>, cb: (d: D1) => D2): PColumn<D2>;\nexport function mapPObjectData<D1, D2>(\n pObj: PColumn<D1> | undefined,\n cb: (d: D1) => D2\n): PColumn<D2> | undefined;\nexport function mapPObjectData<D1, D2>(pObj: PObject<D1>, cb: (d: D1) => D2): PObject<D2>;\nexport function mapPObjectData<D1, D2>(\n pObj: PObject<D1> | undefined,\n cb: (d: D1) => D2\n): PObject<D2> | undefined;\nexport function mapPObjectData<D1, D2>(\n pObj: PObject<D1> | undefined,\n cb: (d: D1) => D2\n): PObject<D2> | undefined {\n return pObj === undefined\n ? undefined\n : {\n ...pObj,\n data: cb(pObj.data)\n };\n}\n","import { AxisId } from '../drivers';\nimport { PObjectSpec, isPColumnSpec } from './spec';\n\nexport type PSpecPredicate =\n | {\n type: 'and' | 'or';\n operands: PSpecPredicate[];\n }\n | {\n type: 'not';\n operand: PSpecPredicate;\n }\n | {\n type: 'name';\n name: string;\n }\n | {\n type: 'name_pattern';\n pattern: string;\n }\n | {\n type: 'annotation';\n annotation: string;\n value: string;\n }\n | {\n type: 'annotation_pattern';\n annotation: string;\n pattern: string;\n }\n | {\n type: 'has_axes';\n axes: Partial<AxisId>[];\n };\n\nfunction assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x);\n}\n\nexport function executePSpecPredicate(\n predicate: PSpecPredicate,\n spec: PObjectSpec\n): boolean {\n switch (predicate.type) {\n case 'and':\n for (const operator of predicate.operands)\n if (!executePSpecPredicate(operator, spec)) return false;\n return true;\n case 'or':\n for (const operator of predicate.operands)\n if (executePSpecPredicate(operator, spec)) return true;\n return false;\n case 'not':\n return !executePSpecPredicate(predicate.operand, spec);\n case 'name':\n return isPColumnSpec(spec) && spec.name === predicate.name;\n case 'name_pattern':\n return isPColumnSpec(spec) && Boolean(spec.name.match(predicate.pattern));\n case 'annotation':\n return (\n isPColumnSpec(spec) &&\n spec.annotations !== undefined &&\n spec.annotations[predicate.annotation] === predicate.value\n );\n case 'annotation_pattern':\n return (\n isPColumnSpec(spec) &&\n spec.annotations !== undefined &&\n spec.annotations[predicate.annotation] !== undefined &&\n Boolean(spec.annotations[predicate.annotation].match(predicate.pattern))\n );\n case 'has_axes':\n return (\n isPColumnSpec(spec) &&\n predicate.axes.every((matcher) =>\n spec.axesSpec.some(\n (axisSpec) =>\n (matcher.type === undefined || matcher.type === axisSpec.type) &&\n (matcher.name === undefined || matcher.name === axisSpec.name) &&\n (matcher.domain === undefined ||\n Object.keys(matcher.domain).length === 0 ||\n (axisSpec.domain !== undefined &&\n Object.entries(matcher.domain).every(\n ([domain, domainValue]) =>\n axisSpec.domain![domain] === domainValue\n )))\n )\n )\n );\n default:\n assertNever(predicate);\n }\n}\n","export type ValueOrError<V, E> =\n | {\n ok: true;\n value: V;\n }\n | {\n ok: false;\n error: E;\n };\n\nexport function mapValueInVOE<V1, V2, E>(\n voe: ValueOrError<V1, E>,\n cb: (value: V1) => V2\n): ValueOrError<V2, E> {\n return voe.ok ? { ok: true, value: cb(voe.value) } : voe;\n}\n"],"names":["isLiveLog","handle","assertNever","x","uploadPrefix","indexPrefix","isImportFileHandleUpload","isImportFileHandleIndex","getFilePathFromHandle","trimmed","extractFileName","filePath","getFileNameFromHandle","PValueIntNA","PValueLongNA","PValueFloatNA","PValueDoubleNA","PValueStringNA","PValueBytesNA","isValueNA","value","valueType","ensureNotNAPValue","isNotNAPValue","isPValue","toJsonSafePValue","safeConvertToPValue","checkType","pValueToStringOrNumber","pValueToStringOrNumberOrNull","isValueAbsent","absent","index","chunkIndex","mask","PTableNull","PTableNA","pTableValue","column","row","getAxisId","spec","type","name","domain","getAxesId","matchDomain","query","target","k","matchAxisId","mapPTableDef","def","cb","mapJoinEntry","entry","col","DefaultNavigationState","PlRef","z","plRefsEqual","ref1","ref2","isPColumnSpec","isPColumn","obj","isPColumnSpecResult","r","isPColumnResult","ensurePColumn","mapPObjectData","pObj","executePSpecPredicate","predicate","operator","matcher","axisSpec","domainValue","mapValueInVOE","voe"],"mappings":";AAaO,SAASA,EAAUC,GAA2D;AACnF,SAAOA,MAAW,UAAaA,EAAO,WAAW,iBAAiB;AACpE;ACfO,SAASC,EAAYC,GAAiB;AACrC,QAAA,IAAI,MAAM,wBAAwBA,CAAC;AAC3C;ACGA,MAAMC,IAAe,oBACfC,IAAc;AASb,SAASC,EACdL,GACkC;AAC3B,SAAAA,EAAO,WAAWG,CAAY;AACvC;AAEO,SAASG,EAAwBN,GAA2D;AAC1F,SAAAA,EAAO,WAAWI,CAAW;AACtC;AAuGO,SAASG,EAAsBP,GAAkC;AAClE,MAAAM,EAAwBN,CAAM,GAAG;AACnC,UAAMQ,IAAUR,EAAO,MAAMI,EAAY,MAAM;AAE/C,WADa,KAAK,MAAM,mBAAmBI,CAAO,CAAC,EACvC;AAAA,EAAA,WACHH,EAAyBL,CAAM,GAAG;AAC3C,UAAMQ,IAAUR,EAAO,MAAMG,EAAa,MAAM;AAEhD,WADa,KAAK,MAAM,mBAAmBK,CAAO,CAAC,EACvC;AAAA,EAAA;AAGdP,EAAAA,EAAYD,CAAM;AACpB;AAEA,SAASS,EAAgBC,GAAkB;AAClC,SAAAA,EAAS,QAAQ,YAAY,EAAE;AACxC;AAGO,SAASC,EAAsBX,GAAkC;AAC/D,SAAAS,EAAgBF,EAAsBP,CAAM,CAAC;AACtD;AChJO,MAAMY,IAAc,aACdC,IAAe,CAAC,mBAChBC,IAAgB,KAChBC,IAAiB,KACjBC,IAAiB,MACjBC,IAAgB;AAyBb,SAAAC,EAAUC,GAAgBC,GAA+B;AACvE,UAAQA,GAA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;AACI,aAAAV,EAActB,CAAI,KAAK,EAAQA,EAAK,KAAK,MAAMgC,EAAU,OAAO;AAAA,IACzE,KAAK;AAED,aAAAV,EAActB,CAAI,KAClBA,EAAK,gBAAgB,UACrBA,EAAK,YAAYgC,EAAU,UAAU,MAAMA,EAAU;AAAA,IAEzD,KAAK;AAED,aAAAV,EAActB,CAAI,KAClBA,EAAK,gBAAgB,UACrBA,EAAK,YAAYgC,EAAU,UAAU,MAAM,UAC3C,EAAQhC,EAAK,YAAYgC,EAAU,UAAU,EAAE,MAAMA,EAAU,OAAO;AAAA,IAE1E,KAAK;AACH,aACEV,EAActB,CAAI,KAClBgC,EAAU,KAAK;AAAA,QAAM,CAACE,MACpBlC,EAAK,SAAS;AAAA,UACZ,CAACmC,OACED,EAAQ,SAAS,UAAaA,EAAQ,SAASC,EAAS,UACxDD,EAAQ,SAAS,UAAaA,EAAQ,SAASC,EAAS,UACxDD,EAAQ,WAAW,UAClB,OAAO,KAAKA,EAAQ,MAAM,EAAE,WAAW,KACtCC,EAAS,WAAW,UACnB,OAAO,QAAQD,EAAQ,MAAM,EAAE;AAAA,YAC7B,CAAC,CAAC/B,GAAQiC,CAAW,MACnBD,EAAS,OAAQhC,CAAM,MAAMiC;AAAA,UACjC;AAAA,QAAA;AAAA,MAEV;AAAA,IAEJ;AACE,MAAA3E,EAAYuE,CAAS;AAAA,EAAA;AAE3B;AClFgB,SAAAK,EACdC,GACA1B,GACqB;AACd,SAAA0B,EAAI,KAAK,EAAE,IAAI,IAAM,OAAO1B,EAAG0B,EAAI,KAAK,EAAA,IAAMA;AACvD;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/drivers/log.ts","../src/util.ts","../src/drivers/ls.ts","../src/drivers/pframe/data.ts","../src/drivers/pframe/spec.ts","../src/drivers/pframe/table_calculate.ts","../src/navigation.ts","../src/ref.ts","../src/pool/spec.ts","../src/pool/query.ts","../src/value_or_error.ts"],"sourcesContent":["/** Handle of logs. This handle should be passed\n * to the driver for retrieving logs. */\nexport type AnyLogHandle = LiveLogHandle | ReadyLogHandle;\n\n/** Handle of the live logs of a program.\n * The resource that represents a log can be deleted,\n * in this case the handle should be refreshed. */\nexport type LiveLogHandle = `log+live://log/${string}`;\n\n/** Handle of the ready logs of a program. */\nexport type ReadyLogHandle = `log+ready://log/${string}`;\n\n/** Type guard to check if log is live, and corresponding porcess is not finished. */\nexport function isLiveLog(handle: AnyLogHandle | undefined): handle is LiveLogHandle {\n return handle !== undefined && handle.startsWith('log+live://log/');\n}\n\n/** Driver to retrieve logs given log handle */\nexport interface LogsDriver {\n lastLines(\n /** A handle that was issued previously. */\n handle: AnyLogHandle,\n\n /** Allows client to limit total data sent from server. */\n lineCount: number,\n\n /** Makes streamer to perform seek operation to given offset before sending the contents.\n * Client can just use the <new_offset> value of the last response from server to continue streaming after reconnection.\n * If undefined, then starts from the end. */\n offsetBytes?: number,\n\n /** Is substring for line search pattern.\n * This option makes controller to send to the client only lines, that\n * have given substring. */\n searchStr?: string\n ): Promise<StreamingApiResponse>;\n\n readText(\n /** A handle that was issued previously. */\n handle: AnyLogHandle,\n\n /** Allows client to limit total data sent from server. */\n lineCount: number,\n\n /** Makes streamer to perform seek operation to given offset before sending the contents.\n * Client can just use the <new_offset> value of the last response from server to continue streaming after reconnection.\n * If undefined of 0, then starts from the beginning. */\n offsetBytes?: number,\n\n /** Is substring for line search pattern.\n * This option makes controller to send to the client only lines, that\n * have given substring. */\n searchStr?: string\n ): Promise<StreamingApiResponse>;\n}\n\n/** Response of the driver.\n * The caller should give a handle to retrieve it.\n * It can be OK or outdated, in which case the handle\n * should be issued again. */\nexport type StreamingApiResponse = StreamingApiResponseOk | StreamingApiResponseHandleOutdated;\n\nexport type StreamingApiResponseOk = {\n /** The handle don't have to be updated,\n * the response is OK. */\n shouldUpdateHandle: false;\n\n /** Whether the log can still grow or it's in a final state. */\n live: boolean;\n\n /** Data of the response, in bytes. */\n data: Uint8Array;\n /** Current size of the file. It can grow if it's still live. */\n size: number;\n /** Offset in bytes from the beginning of a file. */\n newOffset: number;\n};\n\n/** The handle should be issued again, this one is done. */\nexport type StreamingApiResponseHandleOutdated = {\n shouldUpdateHandle: true;\n};\n","export function assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x);\n}\n","import { assertNever } from '../util';\nimport { Branded } from '../branding';\nimport { TableRange } from './pframe';\nimport { FileLike } from './interfaces';\n\nconst uploadPrefix = 'upload://upload/';\nconst indexPrefix = 'index://index/';\n\nexport type ImportFileHandleUpload = `upload://upload/${string}`;\nexport type ImportFileHandleIndex = `index://index/${string}`;\n\nexport type ImportFileHandle = ImportFileHandleUpload | ImportFileHandleIndex;\n\nexport type LocalImportFileHandle = Branded<ImportFileHandle, 'Local'>;\n\nexport function isImportFileHandleUpload(\n handle: ImportFileHandle\n): handle is ImportFileHandleUpload {\n return handle.startsWith(uploadPrefix);\n}\n\nexport function isImportFileHandleIndex(handle: ImportFileHandle): handle is ImportFileHandleIndex {\n return handle.startsWith(indexPrefix);\n}\n\n/** Results in upload */\nexport type StorageHandleLocal = `local://${string}`;\n\n/** Results in index */\nexport type StorageHandleRemote = `remote://${string}`;\n\nexport type StorageHandle = StorageHandleLocal | StorageHandleRemote;\n\nexport type StorageEntry = {\n name: string;\n handle: StorageHandle;\n initialFullPath: string;\n\n // TODO\n // pathStartsWithDisk\n};\n\nexport type ListFilesResult = {\n parent?: string;\n entries: LsEntry[];\n};\n\nexport type LsEntry =\n | {\n type: 'dir';\n name: string;\n fullPath: string;\n }\n | {\n type: 'file';\n name: string;\n fullPath: string;\n\n /** This handle should be set to args... */\n handle: ImportFileHandle;\n };\n\nexport type OpenDialogFilter = {\n /** Human-readable file type name */\n readonly name: string;\n /** File extensions */\n readonly extensions: string[];\n};\n\nexport type OpenDialogOps = {\n /** Open dialog window title */\n readonly title?: string;\n /** Custom label for the confirmation button, when left empty the default label will be used. */\n readonly buttonLabel?: string;\n /** Limits of file types user can select */\n readonly filters?: OpenDialogFilter[];\n};\n\nexport type OpenSingleFileResponse = {\n /** Contains local file handle, allowing file importing or content reading. If user canceled\n * the dialog, field will be undefined. */\n readonly file?: LocalImportFileHandle;\n};\n\nexport type OpenMultipleFilesResponse = {\n /** Contains local file handles, allowing file importing or content reading. If user canceled\n * the dialog, field will be undefined. */\n readonly files?: LocalImportFileHandle[];\n};\n\n/** Can be used to limit request for local file content to a certain bytes range */\nexport type FileRange = {\n /** From byte index (inclusive) */\n readonly from: number;\n /** To byte index (exclusive) */\n readonly to: number;\n};\n\nexport interface LsDriver {\n /** remote and local storages */\n getStorageList(): Promise<StorageEntry[]>;\n\n listFiles(storage: StorageHandle, fullPath: string): Promise<ListFilesResult>;\n\n /** Opens system file open dialog allowing to select single file and awaits user action */\n showOpenSingleFileDialog(ops: OpenDialogOps): Promise<OpenSingleFileResponse>;\n\n /** Opens system file open dialog allowing to multiple files and awaits user action */\n showOpenMultipleFilesDialog(ops: OpenDialogOps): Promise<OpenMultipleFilesResponse>;\n\n /** Given a handle to a local file, allows to get file size */\n getLocalFileSize(file: LocalImportFileHandle): Promise<number>;\n\n /** Given a handle to a local file, allows to get its content */\n getLocalFileContent(file: LocalImportFileHandle, range?: TableRange): Promise<Uint8Array>;\n\n /**\n * Resolves browser's File object into platforma's import file handle.\n *\n * This method is useful among other things for implementation of UI\n * components, that handle file Drag&Drop.\n * */\n fileToImportHandle(file: FileLike): Promise<ImportFileHandle>;\n}\n\n/** Gets a file path from an import handle. */\nexport function getFilePathFromHandle(handle: ImportFileHandle): string {\n if (isImportFileHandleIndex(handle)) {\n const trimmed = handle.slice(indexPrefix.length);\n const data = JSON.parse(decodeURIComponent(trimmed));\n return data.path;\n } else if (isImportFileHandleUpload(handle)) {\n const trimmed = handle.slice(uploadPrefix.length);\n const data = JSON.parse(decodeURIComponent(trimmed));\n return data.localPath;\n }\n\n assertNever(handle);\n}\n\nfunction extractFileName(filePath: string) {\n return filePath.replace(/^.*[\\\\/]/, '');\n}\n\n/** Gets a file name from an import handle. */\nexport function getFileNameFromHandle(handle: ImportFileHandle): string {\n return extractFileName(getFilePathFromHandle(handle));\n}\n","import { number } from 'zod';\nimport { ValueType } from './spec';\n\nexport const PValueIntNA = -2147483648;\nexport const PValueLongNA = -9007199254740991n;\nexport const PValueFloatNA = NaN;\nexport const PValueDoubleNA = NaN;\nexport const PValueStringNA = null;\nexport const PValueBytesNA = null;\n\nexport type PValueInt = number;\nexport type PValueLong = number | bigint; // use bigint only if extra integer precision is needed\nexport type PValueFloat = number;\nexport type PValueDouble = number;\nexport type PValueString = string | null;\nexport type PValueBytes = Uint8Array | null;\n\nexport type NotNAPValueInt = number;\nexport type NotNAPValueLong = number | bigint; // use bigint only if extra integer precision is needed\nexport type NotNAPValueFloat = number;\nexport type NotNAPValueDouble = number;\nexport type NotNAPValueString = string;\n\nexport type NotNAPValue = number | bigint | string;\n\nexport type PValue =\n | PValueInt\n | PValueLong\n | PValueFloat\n | PValueDouble\n | PValueString\n | PValueBytes;\n\nexport function isValueNA(value: unknown, valueType: ValueType): boolean {\n switch (valueType) {\n case 'Int':\n return value === PValueIntNA;\n case 'Long':\n return value === Number(PValueLongNA) || value === PValueLongNA;\n case 'Float':\n return value === PValueFloatNA;\n case 'Double':\n return value === PValueDoubleNA;\n case 'String':\n return value === PValueStringNA;\n case 'Bytes':\n return value === PValueBytesNA;\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\nexport function ensureNotNAPValue(value: string): string;\nexport function ensureNotNAPValue(value: number): number;\nexport function ensureNotNAPValue(value: bigint): bigint;\nexport function ensureNotNAPValue(value: unknown): NotNAPValue;\nexport function ensureNotNAPValue(value: unknown): NotNAPValue {\n if (!isNotNAPValue(value)) throw new Error(`Expected not-NA PValue, got ${value}`);\n return value;\n}\n\nexport function isNotNAPValue(value: unknown, valueType: 'Int'): value is number;\nexport function isNotNAPValue(value: unknown, valueType: 'Long'): value is number | bigint;\nexport function isNotNAPValue(value: unknown, valueType: 'Float'): value is number;\nexport function isNotNAPValue(value: unknown, valueType: 'Double'): value is number;\nexport function isNotNAPValue(value: unknown, valueType: 'String'): value is string;\nexport function isNotNAPValue(value: unknown, valueType: ValueType): value is NotNAPValue;\nexport function isNotNAPValue(value: unknown): value is NotNAPValue;\nexport function isNotNAPValue(value: unknown, valueType?: ValueType): boolean {\n if (!valueType)\n return (\n typeof value === 'string' ||\n (typeof value === 'number' && isFinite(value)) ||\n typeof value === 'bigint'\n );\n if (isValueNA(value, valueType)) return false;\n switch (valueType) {\n case 'Int':\n return typeof value === 'number';\n case 'Long':\n return typeof value === 'number' || typeof value === 'bigint';\n case 'Float':\n return typeof value === 'number';\n case 'Double':\n return typeof value === 'number';\n case 'String':\n return typeof value === 'string';\n case 'Bytes':\n throw Error(`Bytes not yet supported`);\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\nexport function isPValue(value: unknown, valueType: 'Int'): value is PValueInt;\nexport function isPValue(value: unknown, valueType: 'Long'): value is PValueLong;\nexport function isPValue(value: unknown, valueType: 'Float'): value is PValueFloat;\nexport function isPValue(value: unknown, valueType: 'Double'): value is PValueDouble;\nexport function isPValue(value: unknown, valueType: 'String'): value is PValueString;\nexport function isPValue(value: unknown, valueType: ValueType): value is PValue;\nexport function isPValue(value: unknown): value is PValue;\nexport function isPValue(value: unknown, valueType?: ValueType): boolean {\n if (!valueType)\n return (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'bigint'\n );\n if (isValueNA(value, valueType)) return true;\n switch (valueType) {\n case 'Int':\n return typeof value === 'number';\n case 'Long':\n return typeof value === 'number' || typeof value === 'bigint';\n case 'Float':\n return typeof value === 'number';\n case 'Double':\n return typeof value === 'number';\n case 'String':\n return typeof value === 'string';\n case 'Bytes':\n throw Error(`Bytes not yet supported`);\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\nexport type PValueLongJsonSafe = { bigint: string };\nexport type PValueJsonSafe = number | string | null | PValueLongJsonSafe;\n\n/**\n * Converts PValue to value that can be safely serialized by standard JSON.stringify\n * method. Use {@link safeConvertToPValue} to \"deserialize\" the value back to runtime\n * PValue representation.\n */\nexport function toJsonSafePValue(value: PValue): PValueJsonSafe {\n if (value === null || typeof value === 'string' || typeof value === 'number') return value;\n if (typeof value === 'bigint') return { bigint: value.toString() };\n throw new Error(`Type ${typeof value} (value ${value}) not yet supported.`);\n}\n\n/**\n * Can be used to \"deserialize\" result of {@link toJsonSafePValue} or to\n * safely cast any unknown value to actual runtime PValue representation.\n */\nexport function safeConvertToPValue(value: unknown, checkType?: ValueType): PValue {\n if (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'bigint'\n ) {\n if (checkType && !isValueNA(value, checkType) && !isPValue(value, checkType))\n throw new Error(`Unexpected value type, got ${typeof value}, expected ${checkType}`);\n return value;\n }\n\n if (\n typeof value === 'object' &&\n value !== null &&\n 'bigint' in value &&\n typeof value.bigint === 'string'\n ) {\n if (checkType && checkType !== 'Long')\n throw new Error(`Unexpected value type, got serialized bigint, expected ${checkType}`);\n\n return BigInt(value.bigint);\n }\n\n throw new Error(`Unsupported type ${typeof value} (value ${value}).`);\n}\n\nexport function pValueToStringOrNumber(value: string): string;\nexport function pValueToStringOrNumber(value: number | bigint): number;\nexport function pValueToStringOrNumber(value: PValue | PValueJsonSafe): string | number;\nexport function pValueToStringOrNumber(value: PValue | PValueJsonSafe): string | number {\n value = pValueToStringOrNumberOrNull(value);\n if (value === null) throw new Error('Value is null');\n return value;\n}\n\nexport function pValueToStringOrNumberOrNull(value: string | null): string;\nexport function pValueToStringOrNumberOrNull(value: number | bigint | null): number;\nexport function pValueToStringOrNumberOrNull(\n value: PValue | PValueJsonSafe\n): string | number | null;\nexport function pValueToStringOrNumberOrNull(\n value: PValue | PValueJsonSafe\n): string | number | null {\n value = safeConvertToPValue(value);\n if (value === null) return null;\n if (typeof value === 'string') return value;\n if (typeof value === 'number') {\n if (!isFinite(value)) throw new Error(`Value is not finite (${value})`);\n return value;\n }\n if (typeof value === 'bigint') {\n // @TODO add range check\n return Number(value);\n }\n throw new Error(`Unexpected value type: ${typeof value}`);\n}\n\nexport type PVectorDataInt = Int32Array;\nexport type PVectorDataLong = BigInt64Array;\nexport type PVectorDataFloat = Float32Array;\nexport type PVectorDataDouble = Float64Array;\nexport type PVectorDataString = PValueString[];\nexport type PVectorDataBytes = PValueBytes[];\n\nexport type PVectorData =\n | PVectorDataInt\n | PVectorDataLong\n | PVectorDataFloat\n | PVectorDataDouble\n | PVectorDataString\n | PVectorDataBytes;\n\n/** Table column data in comparison to the data stored in a separate PColumn\n * may have some of the values \"absent\", i.e. as a result of missing record in\n * outer join operation. This information is encoded in {@link absent} field. */\nexport interface PTableVector {\n /** Stored data type */\n readonly type: ValueType;\n\n /** Values for present positions, absent positions have NA values */\n readonly data: PVectorData;\n\n /**\n * Encoded bit array marking some elements of this vector as absent,\n * call {@link isValueAbsent} to read the data.\n * */\n readonly absent: Uint8Array;\n}\n\n/** Used to read bit array with value absence information */\nexport function isValueAbsent(absent: Uint8Array, index: number): boolean {\n const chunkIndex = Math.floor(index / 8);\n const mask = 1 << (7 - (index % 8));\n return (absent[chunkIndex] & mask) > 0;\n}\n\nexport type PColumnValue = null | number | string;\nexport type PColumnValuesEntry = {\n key: PColumnValue[];\n val: PColumnValue;\n};\nexport type PColumnValues = PColumnValuesEntry[];\n\nexport const PTableNull = { type: 'absent' };\nexport const PTableNA = null;\n\n/** Decoded PTable value */\nexport type PTableValue =\n | typeof PTableNull\n | typeof PTableNA\n | number | string;\n\n/** Read PTableValue from PTable column at specified row */\nexport function pTableValue(column: PTableVector, row: number): PTableValue {\n if (isValueAbsent(column.absent, row)) return PTableNull;\n\n const value = column.data[row];\n const valueType = column.type;\n if (isValueNA(value, valueType)) return PTableNA;\n\n switch (valueType) {\n case 'Int':\n return value as PVectorDataInt[number];\n case 'Long':\n return Number(value as PVectorDataLong[number]);\n case 'Float':\n return value as PVectorDataFloat[number];\n case 'Double':\n return value as PVectorDataDouble[number];\n case 'String':\n return value as PVectorDataString[number];\n case 'Bytes':\n throw Error(`Bytes not yet supported`);\n default:\n throw Error(`unsupported data type: ${valueType satisfies never}`);\n }\n}\n\n/** Used in requests to partially retrieve table's data */\nexport type TableRange = {\n /** Index of the first record to retrieve */\n readonly offset: number;\n\n /** Block length */\n readonly length: number;\n};\n\n/** Unified information about table shape */\nexport type PTableShape = {\n /** Number of unified table columns, including all axes and PColumn values */\n columns: number;\n\n /** Number of rows */\n rows: number;\n};\n","import { PObject, PObjectId, PObjectSpec } from '../../pool';\n\n/** PFrame columns and axes within them may store one of these types. */\nexport type ValueType = 'Int' | 'Long' | 'Float' | 'Double' | 'String' | 'Bytes';\n\n/**\n * Specification of an individual axis.\n *\n * Each axis is a part of a composite key that addresses data inside the PColumn.\n *\n * Each record inside a PColumn is addressed by a unique tuple of values set for\n * all the axes specified in the column spec.\n * */\nexport interface AxisSpec {\n /** Type of the axis value. Should not use non-key types like float or double. */\n readonly type: ValueType;\n\n /** Name of the axis */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Any additional information attached to the axis that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /**\n * Parent axes provide contextual grouping for the axis in question, establishing\n * a hierarchy where the current axis is dependent on one or more axes for its\n * full definition and meaning. For instance, in a data structure where each\n * \"container\" axis may contain multiple \"item\" axes, the `item` axis would\n * list the index of the `container` axis in this field to denote its dependency.\n *\n * This means that the identity or significance of the `item` axis is only\n * interpretable when combined with its parent `container` axis. An `item` axis\n * index by itself may be non-unique and only gains uniqueness within the context\n * of its parent `container`. Therefore, the `parentAxes` field is essential for\n * mapping these relationships and ensuring data coherence across nested or\n * multi-level data models.\n *\n * A list of zero-based indices of parent axes in the overall axes specification\n * from the column spec. Each index corresponds to the position of a parent axis\n * in the list that defines the structure of the data model.\n */\n readonly parentAxes?: number[];\n}\n\n/** Common type representing spec for all the axes in a column */\nexport type AxesSpec = AxisSpec[];\n\n/**\n * Full column specification including all axes specs and specs of the column\n * itself.\n *\n * A PColumn in its essence represents a mapping from a fixed size, explicitly\n * typed tuple to an explicitly typed value.\n *\n * (axis1Value1, axis2Value1, ...) -> columnValue\n *\n * Each element in tuple correspond to the axis having the same index in axesSpec.\n * */\nexport interface PColumnSpec extends PObjectSpec {\n /** Defines specific type of BObject, the most generic type of unit of\n * information in Platforma Project. */\n readonly kind: 'PColumn';\n\n /** Type of column values */\n readonly valueType: ValueType;\n\n /** Column name */\n readonly name: string;\n\n /** Adds auxiliary information to the axis name, type and parents to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n\n /** Any additional information attached to the column that does not affect its\n * identifier */\n readonly annotations?: Record<string, string>;\n\n /** A list of zero-based indices of parent axes from the {@link axesSpec} array. */\n readonly parentAxes?: number[];\n\n /** Axes specifications */\n readonly axesSpec: AxesSpec;\n}\n\nexport interface PColumn<Data> extends PObject<Data> {\n /** PColumn spec, allowing it to be found among other PObjects */\n readonly spec: PColumnSpec;\n}\n\n/** Columns in a PFrame also have internal identifier, this object represents\n * combination of specs and such id */\nexport interface PColumnIdAndSpec {\n /** Internal column id within the PFrame */\n readonly columnId: PObjectId;\n\n /** Column spec */\n readonly spec: PColumnSpec;\n}\n\n/** Information returned by {@link PFrame.listColumns} method */\nexport interface PColumnInfo extends PColumnIdAndSpec {\n /** True if data was associated with this PColumn */\n readonly hasData: boolean;\n}\n\nexport interface AxisId {\n /** Type of the axis or column value. For an axis should not use non-key\n * types like float or double. */\n readonly type: ValueType;\n\n /** Name of the axis or column */\n readonly name: string;\n\n /** Adds auxiliary information to the axis or column name and type to form a\n * unique identifier */\n readonly domain?: Record<string, string>;\n}\n\n/** Array of axis ids */\nexport type AxesId = AxisId[];\n\n/** Extracts axis ids from axis spec */\nexport function getAxisId(spec: AxisSpec): AxisId {\n const { type, name, domain } = spec;\n return { type, name, ...(domain && { domain }) };\n}\n\n/** Extracts axes ids from axes spec array from column spec */\nexport function getAxesId(spec: AxesSpec): AxesId {\n return spec.map(getAxisId);\n}\n\n/** Returns true if all domains from query are found in target */\nfunction matchDomain(query?: Record<string, string>, target?: Record<string, string>) {\n if (query === undefined) return target === undefined;\n if (target === undefined) return true;\n for (const k in target) {\n if (query[k] !== target[k]) return false;\n }\n return true;\n}\n\n/** Returns whether \"match\" axis id is compatible with the \"query\" */\nexport function matchAxisId(query: AxisId, target: AxisId): boolean {\n return query.name === target.name && matchDomain(query.domain, target.domain);\n}\n","import { PTableColumnId, PTableColumnSpec } from './table_common';\nimport { PTableVector } from './data';\nimport { assertNever } from '../../util';\n\n/** Defines a terminal column node in the join request tree */\nexport interface ColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: 'column';\n\n /** Local column */\n readonly column: Col;\n}\n\n/**\n * Defines a join request tree node that will output only records present in\n * all child nodes ({@link entries}).\n * */\nexport interface InnerJoin<Col> {\n /** Node type discriminator */\n readonly type: 'inner';\n\n /** Child nodes to be inner joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present at\n * least in one of the child nodes ({@link entries}), values for those PColumns\n * that lacks corresponding combinations of axis values will be marked as absent,\n * see {@link PTableVector.absent}.\n * */\nexport interface FullJoin<Col> {\n /** Node type discriminator */\n readonly type: 'full';\n\n /** Child nodes to be fully outer joined */\n readonly entries: JoinEntry<Col>[];\n}\n\n/**\n * Defines a join request tree node that will output all records present in\n * {@link primary} child node, and records from the {@link secondary} nodes will\n * be added to the output only if present, values for those PColumns from the\n * {@link secondary} list, that lacks corresponding combinations of axis values\n * will be marked as absent, see {@link PTableVector.absent}.\n *\n * This node can be thought as a chain of SQL LEFT JOIN operations starting from\n * the {@link primary} node and adding {@link secondary} nodes one by one.\n * */\nexport interface OuterJoin<Col> {\n /** Node type discriminator */\n readonly type: 'outer';\n\n /** Primes the join operation. Left part of LEFT JOIN. */\n readonly primary: JoinEntry<Col>;\n\n /** Driven nodes, giving their values only if primary node have corresponding\n * nodes. Right parts of LEFT JOIN chain. */\n readonly secondary: JoinEntry<Col>[];\n}\n\n/**\n * Base type of all join request tree nodes. Join request tree allows to combine\n * information from multiple PColumns into a PTable. Correlation between records\n * is performed by looking for records with the same values in common axis between\n * the PColumns. Common axis are those axis which have equal {@link AxisId} derived\n * from the columns axes spec.\n * */\nexport type JoinEntry<Col> =\n | ColumnJoinEntry<Col>\n | InnerJoin<Col>\n | FullJoin<Col>\n | OuterJoin<Col>;\n\n/** Container representing whole data stored in specific PTable column. */\nexport interface FullPTableColumnData {\n /** Unified spec */\n readonly spec: PTableColumnSpec;\n\n /** Data */\n readonly data: PTableVector;\n}\n\nexport interface SingleValueIsNAPredicate {\n /** Comparison operator */\n readonly operator: 'IsNA';\n}\n\nexport interface SingleValueEqualPredicate {\n /** Comparison operator */\n readonly operator: 'Equal';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueIEqualPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'IEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string;\n}\n\nexport interface SingleValueLessPredicate {\n /** Comparison operator */\n readonly operator: 'Less';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueLessOrEqualPredicate {\n /** Comparison operator */\n readonly operator: 'LessOrEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterPredicate {\n /** Comparison operator */\n readonly operator: 'Greater';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueGreaterOrEqualPredicate {\n /** Comparison operator */\n readonly operator: 'GreaterOrEqual';\n\n /** Reference value, NA values will not match */\n readonly reference: string | number;\n}\n\nexport interface SingleValueStringContainsPredicate {\n /** Comparison operator */\n readonly operator: 'StringContains';\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueStringIContainsPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'StringIContains';\n\n /** Reference substring, NA values are skipped */\n readonly substring: string;\n}\n\nexport interface SingleValueMatchesPredicate {\n /** Comparison operator */\n readonly operator: 'Matches';\n\n /** Regular expression, NA values are skipped */\n readonly regex: string;\n}\n\nexport interface SingleValueStringContainsFuzzyPredicate {\n /** Comparison operator */\n readonly operator: 'StringContainsFuzzy';\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueStringIContainsFuzzyPredicate {\n /** Comparison operator (case insensitive) */\n readonly operator: 'StringIContainsFuzzy';\n\n /** Reference value, NA values are skipped */\n readonly reference: string;\n\n /**\n * Integer specifying the upper bound of edit distance between\n * reference and actual value.\n * When {@link substitutionsOnly} is not defined or set to false\n * Levenshtein distance is used (substitutions and indels)\n * @see https://en.wikipedia.org/wiki/Levenshtein_distance\n * When {@link substitutionsOnly} is set to true\n * Hamming distance is used (substitutions only)\n * @see https://en.wikipedia.org/wiki/Hamming_distance\n */\n readonly maxEdits: number;\n\n /** Changes the type of edit distance in {@link maxEdits} */\n readonly substitutionsOnly?: boolean;\n\n /**\n * Some character in {@link reference} that will match any\n * single character in searched text.\n */\n readonly wildcard?: string;\n}\n\nexport interface SingleValueNotPredicateV2 {\n /** Comparison operator */\n readonly operator: 'Not';\n\n /** Operand to negate */\n readonly operand: SingleValuePredicateV2;\n}\n\nexport interface SingleValueAndPredicateV2 {\n /** Comparison operator */\n readonly operator: 'And';\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\nexport interface SingleValueOrPredicateV2 {\n /** Comparison operator */\n readonly operator: 'Or';\n\n /** Operands to combine */\n readonly operands: SingleValuePredicateV2[];\n}\n\n/** Filtering predicate for a single axis or column value */\nexport type SingleValuePredicateV2 =\n | SingleValueIsNAPredicate\n | SingleValueEqualPredicate\n | SingleValueLessPredicate\n | SingleValueLessOrEqualPredicate\n | SingleValueGreaterPredicate\n | SingleValueGreaterOrEqualPredicate\n | SingleValueStringContainsPredicate\n | SingleValueMatchesPredicate\n | SingleValueStringContainsFuzzyPredicate\n | SingleValueNotPredicateV2\n | SingleValueAndPredicateV2\n | SingleValueOrPredicateV2\n | SingleValueIEqualPredicate\n | SingleValueStringIContainsPredicate\n | SingleValueStringIContainsFuzzyPredicate;\n\n/**\n * Filter PTable records based on specific axis or column value. If this is an\n * axis value filter and the axis is part of a partitioning key in some of the\n * source PColumns, the filter will be pushed down to those columns, so only\n * specific partitions will be retrieved from the remote storage.\n * */\nexport interface PTableRecordSingleValueFilterV2 {\n /** Filter type discriminator */\n readonly type: 'bySingleColumnV2';\n\n /** Target axis selector to examine values from */\n readonly column: PTableColumnId;\n\n /** Value predicate */\n readonly predicate: SingleValuePredicateV2;\n}\n\n/** Generic PTable records filter */\nexport type PTableRecordFilter = PTableRecordSingleValueFilterV2;\n\n/** Sorting parameters for a PTable. */\nexport type PTableSorting = {\n /** Unified column identifier */\n readonly column: PTableColumnId;\n\n /** Sorting order */\n readonly ascending: boolean;\n\n /** Sorting in respect to NA and absent values */\n readonly naAndAbsentAreLeastValues: boolean;\n};\n\n/** Information required to instantiate a PTable. */\nexport interface PTableDef<Col> {\n /** Join tree to populate the PTable */\n readonly src: JoinEntry<Col>;\n\n /** Record filters */\n readonly filters: PTableRecordFilter[];\n\n /** Table sorting */\n readonly sorting: PTableSorting[];\n}\n\n/** Request to create and retrieve entirety of data of PTable. */\nexport type CalculateTableDataRequest<Col> = PTableDef<Col>;\n\n/** Response for {@link CalculateTableDataRequest} */\nexport type CalculateTableDataResponse = FullPTableColumnData[];\n\nexport function mapPTableDef<C1, C2>(\n def: PTableDef<C1>,\n cb: (c: C1) => C2\n): PTableDef<C2> {\n return { ...def, src: mapJoinEntry(def.src, cb) };\n}\n\nexport function mapJoinEntry<C1, C2>(\n entry: JoinEntry<C1>,\n cb: (c: C1) => C2\n): JoinEntry<C2> {\n switch (entry.type) {\n case 'column':\n return {\n type: 'column',\n column: cb(entry.column)\n };\n case 'inner':\n case 'full':\n return {\n type: entry.type,\n entries: entry.entries.map((col) => mapJoinEntry(col, cb))\n };\n case 'outer':\n return {\n type: 'outer',\n primary: mapJoinEntry(entry.primary, cb),\n secondary: entry.secondary.map((col) => mapJoinEntry(col, cb))\n };\n default:\n assertNever(entry);\n }\n}\n","/** Block section visualized as items in left panel block overview */\nexport type BlockSection = BlockSectionLink | BlockSectionDelimiter;\n\n/** Tells the system that specific section from the main UI of this block should\n * be opened */\nexport type BlockSectionLink = {\n /** Potentially there may be multiple section types, i.e. for \"+\" rows and for\n * sections directly opening html from the outputs. */\n readonly type: 'link';\n\n /** Internal block section identifier */\n readonly href: `/${string}`;\n\n /** Visible section title, can also be used in the window header. */\n readonly label: string;\n};\n\n/** Create a horisontal line between sections */\nexport type BlockSectionDelimiter = {\n readonly type: 'delimiter';\n};\n\n/**\n * Part of the block state, representing current navigation information\n * (i.e. currently selected section)\n * */\nexport type NavigationState<Href extends `/${string}` = `/${string}`> = {\n readonly href: Href;\n};\n\nexport const DefaultNavigationState: NavigationState = { href: '/' };\n","import { z } from 'zod';\n\nexport const PlRef = z\n .object({\n __isRef: z\n .literal(true)\n .describe('Crucial marker for the block dependency tree reconstruction'),\n blockId: z.string().describe('Upstream block id'),\n name: z.string().describe(\"Name of the output provided to the upstream block's output context\")\n })\n .describe(\n 'Universal reference type, allowing to set block connections. It is crucial that ' +\n '{@link __isRef} is present and equal to true, internal logic relies on this marker ' +\n 'to build block dependency trees.'\n )\n .strict()\n .readonly();\nexport type PlRef = z.infer<typeof PlRef>;\n/** @deprecated use {@link PlRef} */\nexport type Ref = PlRef;\n\n/** Standard way how to communicate possible connections given specific\n * requirements for incoming data. */\nexport type Option = {\n /** Fully rendered reference to be assigned for the intended field in block's\n * args */\n readonly ref: PlRef;\n\n /** Label to be present for the user in i.e. drop-down list */\n readonly label: string;\n};\n\n/** Compare two PlRefs and returns true if they are qual */\nexport function plRefsEqual(ref1: PlRef, ref2: PlRef) {\n return ref1.blockId === ref2.blockId && ref1.name === ref2.name;\n}\n","import { Branded } from '../branding';\nimport { JoinEntry, PColumn, PColumnSpec } from '../drivers';\nimport { assertNever } from '../util';\nimport { ResultPoolEntry } from './entry';\n\n/** Any object exported into the result pool by the block always have spec attached to it */\nexport interface PObjectSpec {\n /** PObject kind discriminator */\n readonly kind: string;\n\n /** Additional information attached to the object */\n readonly annotations?: Record<string, string>;\n}\n\n/** Stable PObject id */\nexport type PObjectId = Branded<string, 'PColumnId'>;\n\n/**\n * Full PObject representation.\n *\n * @template Data type of the object referencing or describing the \"data\" part of the PObject\n * */\nexport interface PObject<Data> {\n /** Fully rendered PObjects are assigned a stable identifier. */\n readonly id: PObjectId;\n\n /** PObject spec, allowing it to be found among other PObjects */\n readonly spec: PObjectSpec;\n\n /** A handle to data object */\n readonly data: Data;\n}\n\nexport function isPColumnSpec(spec: PObjectSpec): spec is PColumnSpec {\n return spec.kind === 'PColumn';\n}\n\nexport function isPColumn<T>(obj: PObject<T>): obj is PColumn<T> {\n return isPColumnSpec(obj.spec);\n}\n\nexport function isPColumnSpecResult(\n r: ResultPoolEntry<PObjectSpec>\n): r is ResultPoolEntry<PColumnSpec> {\n return isPColumnSpec(r.obj);\n}\n\nexport function isPColumnResult<T>(\n r: ResultPoolEntry<PObject<T>>\n): r is ResultPoolEntry<PColumn<T>> {\n return isPColumnSpec(r.obj.spec);\n}\n\nexport function ensurePColumn<T>(obj: PObject<T>): PColumn<T> {\n if (!isPColumn(obj)) throw new Error(`not a PColumn (kind = ${obj.spec.kind})`);\n return obj;\n}\n\nexport function mapPObjectData<D1, D2>(pObj: PColumn<D1>, cb: (d: D1) => D2): PColumn<D2>;\nexport function mapPObjectData<D1, D2>(\n pObj: PColumn<D1> | undefined,\n cb: (d: D1) => D2\n): PColumn<D2> | undefined;\nexport function mapPObjectData<D1, D2>(pObj: PObject<D1>, cb: (d: D1) => D2): PObject<D2>;\nexport function mapPObjectData<D1, D2>(\n pObj: PObject<D1> | undefined,\n cb: (d: D1) => D2\n): PObject<D2> | undefined;\nexport function mapPObjectData<D1, D2>(\n pObj: PObject<D1> | undefined,\n cb: (d: D1) => D2\n): PObject<D2> | undefined {\n return pObj === undefined\n ? undefined\n : {\n ...pObj,\n data: cb(pObj.data)\n };\n}\n\nexport function extractAllColumns<D>(entry: JoinEntry<PColumn<D>>): PColumn<D>[] {\n const columns = new Map<PObjectId, PColumn<D>>();\n const addAllColumns = (entry: JoinEntry<PColumn<D>>) => {\n switch (entry.type) {\n case 'column':\n columns.set(entry.column.id, entry.column);\n return;\n case 'full':\n case 'inner':\n for (const e of entry.entries) addAllColumns(e);\n return;\n case 'outer':\n addAllColumns(entry.primary);\n for (const e of entry.secondary) addAllColumns(e);\n return;\n default:\n assertNever(entry);\n }\n };\n addAllColumns(entry);\n return [...columns.values()];\n}\n","import { AxisId } from '../drivers';\nimport { PObjectSpec, isPColumnSpec } from './spec';\n\nexport type PSpecPredicate =\n | {\n type: 'and' | 'or';\n operands: PSpecPredicate[];\n }\n | {\n type: 'not';\n operand: PSpecPredicate;\n }\n | {\n type: 'name';\n name: string;\n }\n | {\n type: 'name_pattern';\n pattern: string;\n }\n | {\n type: 'annotation';\n annotation: string;\n value: string;\n }\n | {\n type: 'annotation_pattern';\n annotation: string;\n pattern: string;\n }\n | {\n type: 'has_axes';\n axes: Partial<AxisId>[];\n };\n\nfunction assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x);\n}\n\nexport function executePSpecPredicate(\n predicate: PSpecPredicate,\n spec: PObjectSpec\n): boolean {\n switch (predicate.type) {\n case 'and':\n for (const operator of predicate.operands)\n if (!executePSpecPredicate(operator, spec)) return false;\n return true;\n case 'or':\n for (const operator of predicate.operands)\n if (executePSpecPredicate(operator, spec)) return true;\n return false;\n case 'not':\n return !executePSpecPredicate(predicate.operand, spec);\n case 'name':\n return isPColumnSpec(spec) && spec.name === predicate.name;\n case 'name_pattern':\n return isPColumnSpec(spec) && Boolean(spec.name.match(predicate.pattern));\n case 'annotation':\n return (\n isPColumnSpec(spec) &&\n spec.annotations !== undefined &&\n spec.annotations[predicate.annotation] === predicate.value\n );\n case 'annotation_pattern':\n return (\n isPColumnSpec(spec) &&\n spec.annotations !== undefined &&\n spec.annotations[predicate.annotation] !== undefined &&\n Boolean(spec.annotations[predicate.annotation].match(predicate.pattern))\n );\n case 'has_axes':\n return (\n isPColumnSpec(spec) &&\n predicate.axes.every((matcher) =>\n spec.axesSpec.some(\n (axisSpec) =>\n (matcher.type === undefined || matcher.type === axisSpec.type) &&\n (matcher.name === undefined || matcher.name === axisSpec.name) &&\n (matcher.domain === undefined ||\n Object.keys(matcher.domain).length === 0 ||\n (axisSpec.domain !== undefined &&\n Object.entries(matcher.domain).every(\n ([domain, domainValue]) =>\n axisSpec.domain![domain] === domainValue\n )))\n )\n )\n );\n default:\n assertNever(predicate);\n }\n}\n","export type ValueOrError<V, E> =\n | {\n ok: true;\n value: V;\n }\n | {\n ok: false;\n error: E;\n };\n\nexport function mapValueInVOE<V1, V2, E>(\n voe: ValueOrError<V1, E>,\n cb: (value: V1) => V2\n): ValueOrError<V2, E> {\n return voe.ok ? { ok: true, value: cb(voe.value) } : voe;\n}\n"],"names":["isLiveLog","handle","assertNever","x","uploadPrefix","indexPrefix","isImportFileHandleUpload","isImportFileHandleIndex","getFilePathFromHandle","trimmed","extractFileName","filePath","getFileNameFromHandle","PValueIntNA","PValueLongNA","PValueFloatNA","PValueDoubleNA","PValueStringNA","PValueBytesNA","isValueNA","value","valueType","ensureNotNAPValue","isNotNAPValue","isPValue","toJsonSafePValue","safeConvertToPValue","checkType","pValueToStringOrNumber","pValueToStringOrNumberOrNull","isValueAbsent","absent","index","chunkIndex","mask","PTableNull","PTableNA","pTableValue","column","row","getAxisId","spec","type","name","domain","getAxesId","matchDomain","query","target","k","matchAxisId","mapPTableDef","def","cb","mapJoinEntry","entry","col","DefaultNavigationState","PlRef","z","plRefsEqual","ref1","ref2","isPColumnSpec","isPColumn","obj","isPColumnSpecResult","r","isPColumnResult","ensurePColumn","mapPObjectData","pObj","extractAllColumns","columns","addAllColumns","e","executePSpecPredicate","predicate","operator","matcher","axisSpec","domainValue","mapValueInVOE","voe"],"mappings":";AAaO,SAASA,EAAUC,GAA2D;AACnF,SAAOA,MAAW,UAAaA,EAAO,WAAW,iBAAiB;AACpE;ACfO,SAASC,EAAYC,GAAiB;AACrC,QAAA,IAAI,MAAM,wBAAwBA,CAAC;AAC3C;ACGA,MAAMC,IAAe,oBACfC,IAAc;AASb,SAASC,EACdL,GACkC;AAC3B,SAAAA,EAAO,WAAWG,CAAY;AACvC;AAEO,SAASG,EAAwBN,GAA2D;AAC1F,SAAAA,EAAO,WAAWI,CAAW;AACtC;AAuGO,SAASG,EAAsBP,GAAkC;AAClE,MAAAM,EAAwBN,CAAM,GAAG;AACnC,UAAMQ,IAAUR,EAAO,MAAMI,EAAY,MAAM;AAE/C,WADa,KAAK,MAAM,mBAAmBI,CAAO,CAAC,EACvC;AAAA,EAAA,WACHH,EAAyBL,CAAM,GAAG;AAC3C,UAAMQ,IAAUR,EAAO,MAAMG,EAAa,MAAM;AAEhD,WADa,KAAK,MAAM,mBAAmBK,CAAO,CAAC,EACvC;AAAA,EAAA;AAGdP,EAAAA,EAAYD,CAAM;AACpB;AAEA,SAASS,EAAgBC,GAAkB;AAClC,SAAAA,EAAS,QAAQ,YAAY,EAAE;AACxC;AAGO,SAASC,EAAsBX,GAAkC;AAC/D,SAAAS,EAAgBF,EAAsBP,CAAM,CAAC;AACtD;AChJO,MAAMY,IAAc,aACdC,IAAe,CAAC,mBAChB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AClB,OAAO,KAAKA,EAAQ,MAAM,EAAE,WAAW,KACtCC,EAAS,WAAW,UACnB,OAAO,QAAQD,EAAQ,MAAM,EAAE;AAAA,YAC7B,CAAC,CAACnC,GAAQqC,CAAW,MACnBD,EAAS,OAAQpC,CAAM,MAAMqC;AAAA,UACjC;AAAA,QAAA;AAAA,MAEV;AAAA,IAEJ;AACE,MAAA/E,EAAY2E,CAAS;AAAA,EAAA;AAE3B;AClFgB,SAAAK,EACdC,GACA9B,GACqB;AACd,SAAA8B,EAAI,KAAK,EAAE,IAAI,IAAM,OAAO9B,EAAG8B,EAAI,KAAK,EAAA,IAAMA;AACvD;"}
@@ -1,5 +1,5 @@
1
1
  import { Branded } from '../branding';
2
- import { PColumn, PColumnSpec } from '../drivers';
2
+ import { JoinEntry, PColumn, PColumnSpec } from '../drivers';
3
3
  import { ResultPoolEntry } from './entry';
4
4
  /** Any object exported into the result pool by the block always have spec attached to it */
5
5
  export interface PObjectSpec {
@@ -32,4 +32,5 @@ export declare function mapPObjectData<D1, D2>(pObj: PColumn<D1>, cb: (d: D1) =>
32
32
  export declare function mapPObjectData<D1, D2>(pObj: PColumn<D1> | undefined, cb: (d: D1) => D2): PColumn<D2> | undefined;
33
33
  export declare function mapPObjectData<D1, D2>(pObj: PObject<D1>, cb: (d: D1) => D2): PObject<D2>;
34
34
  export declare function mapPObjectData<D1, D2>(pObj: PObject<D1> | undefined, cb: (d: D1) => D2): PObject<D2> | undefined;
35
+ export declare function extractAllColumns<D>(entry: JoinEntry<PColumn<D>>): PColumn<D>[];
35
36
  //# sourceMappingURL=spec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../src/pool/spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAA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AAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;AAC1F,wBAAgB,cAAc,CAAC,EAAE,EAAE,EAAE,EACnC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,SAAS,EAC7B,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,GAChB,OAAO,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;AAa3B,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAqB/E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-model-common",
3
- "version": "1.9.0",
3
+ "version": "1.10.1",
4
4
  "description": "Platforma SDK Model",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -17,7 +17,7 @@
17
17
  "./src/**/*"
18
18
  ],
19
19
  "dependencies": {
20
- "zod": "^3.23.8"
20
+ "zod": "~3.23.8"
21
21
  },
22
22
  "devDependencies": {
23
23
  "typescript": "~5.5.4",
@@ -241,6 +241,13 @@ export function isValueAbsent(absent: Uint8Array, index: number): boolean {
241
241
  return (absent[chunkIndex] & mask) > 0;
242
242
  }
243
243
 
244
+ export type PColumnValue = null | number | string;
245
+ export type PColumnValuesEntry = {
246
+ key: PColumnValue[];
247
+ val: PColumnValue;
248
+ };
249
+ export type PColumnValues = PColumnValuesEntry[];
250
+
244
251
  export const PTableNull = { type: 'absent' };
245
252
  export const PTableNA = null;
246
253
 
package/src/pool/spec.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Branded } from '../branding';
2
- import { PColumn, PColumnSpec } from '../drivers';
2
+ import { JoinEntry, PColumn, PColumnSpec } from '../drivers';
3
+ import { assertNever } from '../util';
3
4
  import { ResultPoolEntry } from './entry';
4
5
 
5
6
  /** Any object exported into the result pool by the block always have spec attached to it */
@@ -76,3 +77,26 @@ export function mapPObjectData<D1, D2>(
76
77
  data: cb(pObj.data)
77
78
  };
78
79
  }
80
+
81
+ export function extractAllColumns<D>(entry: JoinEntry<PColumn<D>>): PColumn<D>[] {
82
+ const columns = new Map<PObjectId, PColumn<D>>();
83
+ const addAllColumns = (entry: JoinEntry<PColumn<D>>) => {
84
+ switch (entry.type) {
85
+ case 'column':
86
+ columns.set(entry.column.id, entry.column);
87
+ return;
88
+ case 'full':
89
+ case 'inner':
90
+ for (const e of entry.entries) addAllColumns(e);
91
+ return;
92
+ case 'outer':
93
+ addAllColumns(entry.primary);
94
+ for (const e of entry.secondary) addAllColumns(e);
95
+ return;
96
+ default:
97
+ assertNever(entry);
98
+ }
99
+ };
100
+ addAllColumns(entry);
101
+ return [...columns.values()];
102
+ }