@platforma-sdk/ui-vue 1.40.6 → 1.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/.turbo/turbo-build.log +49 -22
  2. package/.turbo/turbo-type-check.log +1 -1
  3. package/CHANGELOG.md +12 -0
  4. package/dist/AgGridVue/useAgGridOptions.js +54 -53
  5. package/dist/AgGridVue/useAgGridOptions.js.map +1 -1
  6. package/dist/components/BlockLayout.vue.d.ts.map +1 -1
  7. package/dist/components/BlockLayout.vue.js +7 -50
  8. package/dist/components/BlockLayout.vue.js.map +1 -1
  9. package/dist/components/BlockLayout.vue2.js +53 -2
  10. package/dist/components/BlockLayout.vue2.js.map +1 -1
  11. package/dist/components/BlockLayout.vue3.js +9 -0
  12. package/dist/components/BlockLayout.vue3.js.map +1 -0
  13. package/dist/components/NotFound.vue.d.ts.map +1 -1
  14. package/dist/components/NotFound.vue.js +12 -14
  15. package/dist/components/NotFound.vue.js.map +1 -1
  16. package/dist/components/PlAgDataTable/PlAgRowCount.vue.js +7 -6
  17. package/dist/components/PlAgDataTable/PlAgRowCount.vue.js.map +1 -1
  18. package/dist/components/PlAgDataTable/sources/table-source-v2.js +12 -12
  19. package/dist/components/PlAgRowNumCheckbox/PlAgRowNumCheckbox.vue.js +10 -9
  20. package/dist/components/PlAgRowNumCheckbox/PlAgRowNumCheckbox.vue.js.map +1 -1
  21. package/dist/components/PlAgRowNumHeader.vue.js +3 -2
  22. package/dist/components/PlAgRowNumHeader.vue.js.map +1 -1
  23. package/dist/components/PlAnnotations/components/DynamicForm.vue2.js +10 -10
  24. package/dist/components/PlAnnotations/components/PlAnnotationCreateDialog.vue.d.ts +1 -1
  25. package/dist/components/PlAnnotations/components/PlAnnotationCreateDialog.vue.d.ts.map +1 -1
  26. package/dist/components/PlMultiSequenceAlignment/data.js +51 -51
  27. package/dist/composition/fileContent.js +16 -16
  28. package/dist/defineApp.d.ts +19 -6
  29. package/dist/defineApp.d.ts.map +1 -1
  30. package/dist/defineApp.js +50 -30
  31. package/dist/defineApp.js.map +1 -1
  32. package/dist/internal/UpdateSerializer.d.ts +26 -0
  33. package/dist/internal/UpdateSerializer.d.ts.map +1 -0
  34. package/dist/internal/UpdateSerializer.js +65 -0
  35. package/dist/internal/UpdateSerializer.js.map +1 -0
  36. package/dist/internal/createAppModel.d.ts +1 -1
  37. package/dist/internal/createAppModel.d.ts.map +1 -1
  38. package/dist/internal/createAppModel.js +43 -51
  39. package/dist/internal/createAppModel.js.map +1 -1
  40. package/dist/internal/{createApp.d.ts → createAppV1.d.ts} +4 -4
  41. package/dist/internal/createAppV1.d.ts.map +1 -0
  42. package/dist/internal/{createApp.js → createAppV1.js} +17 -18
  43. package/dist/internal/createAppV1.js.map +1 -0
  44. package/dist/internal/createAppV2.d.ts +56 -0
  45. package/dist/internal/createAppV2.d.ts.map +1 -0
  46. package/dist/internal/createAppV2.js +158 -0
  47. package/dist/internal/createAppV2.js.map +1 -0
  48. package/dist/internal/test-helpers/BlockMock.d.ts +28 -0
  49. package/dist/internal/test-helpers/BlockMock.d.ts.map +1 -0
  50. package/dist/internal/test-helpers/createMockApi.d.ts +4 -0
  51. package/dist/internal/test-helpers/createMockApi.d.ts.map +1 -0
  52. package/dist/internal/test-helpers/utils.d.ts +4 -0
  53. package/dist/internal/test-helpers/utils.d.ts.map +1 -0
  54. package/dist/{types.static-test.d.ts → internal/v1.static-test.d.ts} +3 -3
  55. package/dist/internal/v1.static-test.d.ts.map +1 -0
  56. package/dist/internal/v2.static-test.d.ts +7 -0
  57. package/dist/internal/v2.static-test.d.ts.map +1 -0
  58. package/dist/lib/model/common/dist/index.js +214 -199
  59. package/dist/lib/model/common/dist/index.js.map +1 -1
  60. package/dist/lib/ui/uikit/dist/components/PlAccordion/{ExpandTransition.vue.js → ExpandTransition.vue2.js} +1 -1
  61. package/dist/lib/ui/uikit/dist/components/PlAccordion/ExpandTransition.vue2.js.map +1 -0
  62. package/dist/lib/ui/uikit/dist/components/PlAccordion/PlAccordionSection.vue2.js +1 -1
  63. package/dist/lib/ui/uikit/dist/lib/model/common/dist/index.js +8 -8
  64. package/dist/lib/ui/uikit/dist/sdk/model/dist/index.js +64 -43
  65. package/dist/lib/ui/uikit/dist/sdk/model/dist/index.js.map +1 -1
  66. package/dist/lib/util/helpers/dist/index.js +67 -56
  67. package/dist/lib/util/helpers/dist/index.js.map +1 -1
  68. package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/index.js +29 -0
  69. package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/index.js.map +1 -0
  70. package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/core.js +208 -0
  71. package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/core.js.map +1 -0
  72. package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/duplex.js +95 -0
  73. package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/duplex.js.map +1 -0
  74. package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/helpers.js +112 -0
  75. package/dist/node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/helpers.js.map +1 -0
  76. package/dist/sdk/model/dist/index.js +151 -131
  77. package/dist/sdk/model/dist/index.js.map +1 -1
  78. package/dist/types.d.ts +2 -2
  79. package/dist/types.d.ts.map +1 -1
  80. package/package.json +8 -5
  81. package/src/components/BlockLayout.vue +9 -1
  82. package/src/components/NotFound.vue +1 -3
  83. package/src/defineApp.ts +134 -36
  84. package/src/internal/UpdateSerializer.ts +112 -0
  85. package/src/internal/createAppModel.ts +7 -20
  86. package/src/internal/{createApp.ts → createAppV1.ts} +10 -6
  87. package/src/internal/createAppV2.test.ts +158 -0
  88. package/src/internal/createAppV2.ts +309 -0
  89. package/src/internal/test-helpers/BlockMock.ts +144 -0
  90. package/src/internal/test-helpers/createMockApi.ts +92 -0
  91. package/src/internal/test-helpers/utils.ts +65 -0
  92. package/src/{types.static-test.ts → internal/v1.static-test.ts} +5 -9
  93. package/src/internal/v2.static-test.ts +98 -0
  94. package/src/types.ts +2 -2
  95. package/dist/internal/createApp.d.ts.map +0 -1
  96. package/dist/internal/createApp.js.map +0 -1
  97. package/dist/lib/ui/uikit/dist/components/PlAccordion/ExpandTransition.vue.js.map +0 -1
  98. package/dist/types.static-test.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../../../lib/model/common/src/drivers/blob.ts","../../../../../../../lib/model/common/src/util.ts","../../../../../../../lib/model/common/src/drivers/pframe/data_info.ts","../../../../../../../lib/model/common/src/drivers/pframe/data_types.ts","../../../../../../../lib/model/common/src/drivers/pframe/spec/spec.ts","../../../../../../../lib/model/common/src/drivers/pframe/table_calculate.ts","../../../../../../../lib/model/common/src/drivers/pframe/table_common.ts","../../../../../../../lib/model/common/src/drivers/pframe/spec/ids.ts","../../../../../../../lib/model/common/src/drivers/pframe/spec/anchored.ts","../../../../../../../lib/model/common/src/pool/spec.ts","../../../../../../../lib/model/common/src/drivers/pframe/spec/selectors.ts","../../../../../../../lib/model/common/src/drivers/pframe/spec/native_id.ts","../../../../../../../lib/model/common/src/ref.ts","../../../../../../../lib/model/common/src/value_or_error.ts","../../../../../../../lib/model/common/src/base32_encode.ts","../../../../../../../lib/model/common/src/plid.ts","../../../../../../../lib/model/common/src/json.ts","../../../../../../../lib/model/common/src/errors.ts"],"sourcesContent":["import type { Branded } from '../branding';\nimport { z } from 'zod';\n\n/** Handle of locally downloaded blob. This handle is issued only after the\n * blob's content is downloaded locally, and ready for quick access. */\nexport type LocalBlobHandle = Branded<string, 'LocalBlobHandle'>;\n\n/** Handle of remote blob. This handle is issued as soon as the data becomes\n * available on the remote server. */\nexport type RemoteBlobHandle = Branded<string, 'RemoteBlobHandle'>;\n\n/** Being configured inside the output structure provides information about\n * blob's content and means to retrieve it when needed. */\nexport interface BlobHandleAndSize<\n H extends LocalBlobHandle | RemoteBlobHandle = | LocalBlobHandle\n | RemoteBlobHandle,\n> {\n /** Handle to retrieve block content using {@link BlobDriver.getContent()} */\n readonly handle: H;\n\n /** Blob size in bytes. */\n readonly size: number;\n}\n\n/** Range in bytes, from should be less or equal than to. */\nexport const RangeBytes = z.object({\n /** Included left border. */\n from: z.number(),\n /** Excluded right border. */\n to: z.number(),\n});\n\nexport type RangeBytes = z.infer<typeof RangeBytes>;\n\nexport function newRangeBytesOpt(from?: number, to?: number): RangeBytes | undefined {\n if (from == undefined || to == undefined) {\n return undefined;\n }\n\n return { from, to };\n}\n\nexport function validateRangeBytes(range: RangeBytes, errMsg: string) {\n if (range.from < 0 || range.to < 0 || range.from >= range.to) {\n throw new Error(`${errMsg}: invalid bytes range: ${range}`);\n }\n}\n\n/** Being configured inside the output structure provides information about\n * locally downloaded blob and means to retrieve it's content when needed. This\n * structure is created only after the blob's content is downloaded locally, and\n * ready for quick access. */\nexport type LocalBlobHandleAndSize = BlobHandleAndSize<LocalBlobHandle>;\n\n/** Being configured inside the output structure provides information about\n * remote blob and means to retrieve it's content when needed. This structure\n * is created as soon as remote blob becomes available. */\nexport type RemoteBlobHandleAndSize = BlobHandleAndSize<RemoteBlobHandle>;\n\n/** Defines API of blob driver as it is seen from the block UI code. */\nexport interface BlobDriver {\n /** Given the blob handle returns its content. Depending on the handle type,\n * content will be served from locally downloaded file, or directly from\n * remote platforma storage. */\n getContent(handle: LocalBlobHandle | RemoteBlobHandle, range?: RangeBytes): Promise<Uint8Array>;\n}\n","export function assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error\n}\n","/**\n * Represents a JavaScript representation of a value in a PColumn. Can be null, a number, or a string.\n * These are the primitive types that can be stored directly in PColumns.\n *\n * Note: Actual columns can hold more value types, which are converted to these JavaScript types\n * once they enter the JavaScript runtime.\n */\nexport type PColumnValue = null | number | string;\n\n/**\n * Represents a key for a PColumn value.\n * Can be an array of strings or numbers.\n */\nexport type PColumnKey = (number | string)[];\n\n/**\n * Represents a single entry in a PColumn's data structure.\n * Contains a key and a value.\n */\nexport type PColumnDataEntry<T> = {\n /** Key for the value */\n key: PColumnKey;\n\n /** Value / blob at the given key */\n value: T;\n};\n\n/**\n * Represents column data stored as a simple JSON structure.\n * Used for small datasets that can be efficiently stored directly in memory.\n */\nexport type JsonDataInfo = {\n /** Identifier for this data format ('Json') */\n type: 'Json';\n\n /** Number of axes that make up the complete key (tuple length) */\n keyLength: number;\n\n /**\n * Key-value pairs where keys are stringified tuples of axis values\n * and values are the column values for those coordinates\n */\n data: Record<string, PColumnValue>;\n};\n\n/**\n * Represents column data partitioned across multiple JSON blobs.\n * Used for larger datasets that need to be split into manageable chunks.\n */\nexport type JsonPartitionedDataInfo<Blob> = {\n /** Identifier for this data format ('JsonPartitioned') */\n type: 'JsonPartitioned';\n\n /** Number of leading axes used for partitioning */\n partitionKeyLength: number;\n\n /** Map of stringified partition keys to blob references */\n parts: Record<string, Blob>;\n};\n\n/**\n * Represents a binary format chunk containing index and values as separate blobs.\n * Used for efficient storage and retrieval of column data in binary format.\n */\nexport type BinaryChunk<Blob> = {\n /** Binary blob containing structured index information */\n index: Blob;\n\n /** Binary blob containing the actual values */\n values: Blob;\n};\n\n/**\n * Represents column data partitioned across multiple binary chunks.\n * Optimized for efficient storage and retrieval of large datasets.\n */\nexport type BinaryPartitionedDataInfo<Blob> = {\n /** Identifier for this data format ('BinaryPartitioned') */\n type: 'BinaryPartitioned';\n\n /** Number of leading axes used for partitioning */\n partitionKeyLength: number;\n\n /** Map of stringified partition keys to binary chunks */\n parts: Record<string, BinaryChunk<Blob>>;\n};\n\n/**\n * Union type representing all possible data storage formats for PColumn data.\n * The specific format used depends on data size, access patterns, and performance requirements.\n *\n * @template Blob - Type parameter representing the storage reference type (could be ResourceInfo, PFrameBlobId, etc.)\n */\nexport type DataInfo<Blob> =\n | JsonDataInfo\n | JsonPartitionedDataInfo<Blob>\n | BinaryPartitionedDataInfo<Blob>;\n\n/**\n * Type guard function that checks if the given value is a valid DataInfo.\n *\n * @param value - The value to check\n * @returns True if the value is a valid DataInfo, false otherwise\n */\nexport function isDataInfo<Blob>(value: unknown): value is DataInfo<Blob> {\n if (!value || typeof value !== 'object') {\n return false;\n }\n\n const data = value as Record<string, unknown>;\n if (!('type' in data)) {\n return false;\n }\n\n switch (data.type) {\n case 'Json':\n return (\n typeof data.keyLength === 'number'\n && data.data !== undefined\n && typeof data.data === 'object'\n );\n case 'JsonPartitioned':\n return (\n typeof data.partitionKeyLength === 'number'\n && data.parts !== undefined\n && typeof data.parts === 'object'\n );\n case 'BinaryPartitioned':\n return (\n typeof data.partitionKeyLength === 'number'\n && data.parts !== undefined\n && typeof data.parts === 'object'\n );\n default:\n return false;\n }\n}\n\n/**\n * Maps blob references in a DataInfo object from one type to another using a mapping function.\n *\n * @template B1 - Source blob type\n * @template B2 - Target blob type\n * @param dataInfo - The source DataInfo object\n * @param mapFn - Function to transform blobs from type B1 to type B2\n * @returns A new DataInfo object with transformed blob references\n */\nexport function mapDataInfo<B1, B2>(\n dataInfo: DataInfo<B1>,\n mapFn: (blob: B1) => B2,\n): DataInfo<B2>;\nexport function mapDataInfo<B1, B2>(\n dataInfo: DataInfo<B1> | undefined,\n mapFn: (blob: B1) => B2,\n): DataInfo<B2> | undefined {\n if (dataInfo === undefined) {\n return undefined;\n }\n\n switch (dataInfo.type) {\n case 'Json':\n // Json type doesn't contain blobs, so return as is\n return dataInfo;\n case 'JsonPartitioned': {\n // Map each blob in parts\n const newParts: Record<string, B2> = {};\n for (const [key, blob] of Object.entries(dataInfo.parts)) {\n newParts[key] = mapFn(blob);\n }\n return {\n ...dataInfo,\n parts: newParts,\n };\n }\n case 'BinaryPartitioned': {\n // Map each index and values blob in parts\n const newParts: Record<string, BinaryChunk<B2>> = {};\n for (const [key, chunk] of Object.entries(dataInfo.parts)) {\n newParts[key] = {\n index: mapFn(chunk.index),\n values: mapFn(chunk.values),\n };\n }\n return {\n ...dataInfo,\n parts: newParts,\n };\n }\n }\n}\n\n/**\n * @param dataInfo - The source DataInfo object\n * @param cb - Callback, function that have access to every blob to visit them all\n * @returns Nothing\n */\nexport function visitDataInfo<B>(\n dataInfo: DataInfo<B>,\n cb: (blob: B) => void,\n): void {\n switch (dataInfo.type) {\n case 'Json':\n // Json type doesn't contain blobs, so return as is\n break;\n case 'JsonPartitioned': {\n // Visit each blob in parts\n for (const [_, blob] of Object.entries(dataInfo.parts)) {\n cb(blob);\n }\n break;\n }\n case 'BinaryPartitioned': {\n // Visit each index and values blob in parts\n for (const [_, chunk] of Object.entries(dataInfo.parts)) {\n cb(chunk.index);\n cb(chunk.values);\n }\n break;\n }\n }\n}\n\n//\n// Lightway representation for ExplicitJsonData\n//\n\n/**\n * Represents a single key-value entry in a column's explicit data structure.\n * Used when directly instantiating PColumns with explicit data.\n */\nexport type PColumnValuesEntry = {\n key: PColumnKey;\n val: PColumnValue;\n};\n\n/**\n * Array of key-value entries representing explicit column data.\n * Used for lightweight explicit instantiation of PColumns.\n */\nexport type PColumnValues = PColumnValuesEntry[];\n\n/**\n * Entry-based representation of JsonDataInfo\n */\nexport interface JsonDataInfoEntries {\n type: 'Json';\n keyLength: number;\n data: PColumnDataEntry<PColumnValue>[];\n}\n\n/**\n * Entry-based representation of JsonPartitionedDataInfo\n */\nexport interface JsonPartitionedDataInfoEntries<Blob> {\n type: 'JsonPartitioned';\n partitionKeyLength: number;\n parts: PColumnDataEntry<Blob>[];\n}\n\n/**\n * Entry-based representation of BinaryPartitionedDataInfo\n */\nexport interface BinaryPartitionedDataInfoEntries<Blob> {\n type: 'BinaryPartitioned';\n partitionKeyLength: number;\n parts: PColumnDataEntry<BinaryChunk<Blob>>[];\n}\n\n/**\n * Union type representing all possible entry-based partitioned data storage formats\n */\nexport type PartitionedDataInfoEntries<Blob> =\n | JsonPartitionedDataInfoEntries<Blob>\n | BinaryPartitionedDataInfoEntries<Blob>;\n\n/**\n * Union type representing all possible entry-based data storage formats\n */\nexport type DataInfoEntries<Blob> =\n | JsonDataInfoEntries\n | PartitionedDataInfoEntries<Blob>;\n\n/**\n * Type guard function that checks if the given value is a valid DataInfoEntries.\n *\n * @param value - The value to check\n * @returns True if the value is a valid DataInfoEntries, false otherwise\n */\nexport function isDataInfoEntries<Blob>(value: unknown): value is DataInfoEntries<Blob> {\n if (!value || typeof value !== 'object') {\n return false;\n }\n\n const data = value as Record<string, unknown>;\n if (!('type' in data)) {\n return false;\n }\n\n switch (data.type) {\n case 'Json':\n return (\n typeof data.keyLength === 'number'\n && Array.isArray(data.data)\n );\n case 'JsonPartitioned':\n return (\n typeof data.partitionKeyLength === 'number'\n && Array.isArray(data.parts)\n );\n case 'BinaryPartitioned':\n return (\n typeof data.partitionKeyLength === 'number'\n && Array.isArray(data.parts)\n );\n default:\n return false;\n }\n}\n\n/**\n * Type guard function that checks if the given value is a valid PartitionedDataInfoEntries.\n *\n * @template Blob - Type parameter representing the storage reference type\n * @param value - The value to check\n * @returns True if the value is a valid PartitionedDataInfoEntries, false otherwise\n */\nexport function isPartitionedDataInfoEntries<Blob>(value: unknown): value is PartitionedDataInfoEntries<Blob> {\n if (!isDataInfoEntries(value)) return false;\n return value.type === 'JsonPartitioned' || value.type === 'BinaryPartitioned';\n}\n\n/**\n * Converts DataInfo to DataInfoEntries\n *\n * @param dataInfo - The record-based DataInfo object\n * @returns The equivalent entry-based DataInfoEntries object\n */\nexport function dataInfoToEntries<Blob>(dataInfo: DataInfo<Blob>): DataInfoEntries<Blob> {\n switch (dataInfo.type) {\n case 'Json': {\n const entries: PColumnDataEntry<PColumnValue>[] = Object.entries(dataInfo.data).map(([keyStr, value]) => {\n const key = JSON.parse(keyStr) as PColumnKey;\n return { key, value };\n });\n\n return {\n type: 'Json',\n keyLength: dataInfo.keyLength,\n data: entries,\n };\n }\n case 'JsonPartitioned': {\n const parts: PColumnDataEntry<Blob>[] = Object.entries(dataInfo.parts).map(([keyStr, blob]) => {\n const key = JSON.parse(keyStr) as PColumnKey;\n return { key, value: blob };\n });\n\n return {\n type: 'JsonPartitioned',\n partitionKeyLength: dataInfo.partitionKeyLength,\n parts,\n };\n }\n case 'BinaryPartitioned': {\n const parts: PColumnDataEntry<BinaryChunk<Blob>>[] = Object.entries(dataInfo.parts).map(([keyStr, chunk]) => {\n const key = JSON.parse(keyStr) as PColumnKey;\n return { key, value: chunk };\n });\n\n return {\n type: 'BinaryPartitioned',\n partitionKeyLength: dataInfo.partitionKeyLength,\n parts,\n };\n }\n }\n}\n\n/**\n * Converts DataInfoEntries to DataInfo\n *\n * @param dataInfoEntries - The entry-based DataInfoEntries object\n * @returns The equivalent record-based DataInfo object\n */\nexport function entriesToDataInfo<Blob>(dataInfoEntries: DataInfoEntries<Blob>): DataInfo<Blob> {\n switch (dataInfoEntries.type) {\n case 'Json': {\n const data: Record<string, PColumnValue> = {};\n for (const entry of dataInfoEntries.data) {\n data[JSON.stringify(entry.key)] = entry.value;\n }\n\n return {\n type: 'Json',\n keyLength: dataInfoEntries.keyLength,\n data,\n };\n }\n case 'JsonPartitioned': {\n const parts: Record<string, Blob> = {};\n for (const entry of dataInfoEntries.parts) {\n parts[JSON.stringify(entry.key)] = entry.value;\n }\n\n return {\n type: 'JsonPartitioned',\n partitionKeyLength: dataInfoEntries.partitionKeyLength,\n parts,\n };\n }\n case 'BinaryPartitioned': {\n const parts: Record<string, BinaryChunk<Blob>> = {};\n for (const entry of dataInfoEntries.parts) {\n parts[JSON.stringify(entry.key)] = entry.value;\n }\n\n return {\n type: 'BinaryPartitioned',\n partitionKeyLength: dataInfoEntries.partitionKeyLength,\n parts,\n };\n }\n }\n}\n\n/**\n * Maps blob references in a DataInfoEntries object from one type to another using a mapping function.\n *\n * @template B1 - Source blob type\n * @template B2 - Target blob type\n * @param dataInfoEntries - The source DataInfoEntries object\n * @param mapFn - Function to transform blobs from type B1 to type B2\n * @returns A new DataInfoEntries object with transformed blob references\n */\nexport function mapDataInfoEntries<B1, B2>(\n dataInfoEntries: DataInfoEntries<B1>,\n mapFn: (blob: B1) => B2,\n): DataInfoEntries<B2>;\nexport function mapDataInfoEntries<B1, B2>(\n dataInfoEntries: DataInfoEntries<B1> | undefined,\n mapFn: (blob: B1) => B2,\n): DataInfoEntries<B2> | undefined {\n if (dataInfoEntries === undefined) {\n return undefined;\n }\n\n switch (dataInfoEntries.type) {\n case 'Json':\n // Json type doesn't contain blobs, so return as is\n return dataInfoEntries;\n case 'JsonPartitioned': {\n // Map each blob in parts\n const newParts = dataInfoEntries.parts.map((entry) => ({\n key: entry.key,\n value: mapFn(entry.value),\n }));\n\n return {\n ...dataInfoEntries,\n parts: newParts,\n };\n }\n case 'BinaryPartitioned': {\n // Map each index and values blob in parts\n const newParts = dataInfoEntries.parts.map((entry) => ({\n key: entry.key,\n value: {\n index: mapFn(entry.value.index),\n values: mapFn(entry.value.values),\n },\n }));\n\n return {\n ...dataInfoEntries,\n parts: newParts,\n };\n }\n }\n}\n","import type { ValueType } from './spec/spec';\n\nexport const PValueIntNA = -2147483648;\nexport const PValueLongNA = -9007199254740991n;\nexport const PValueFloatNA = NaN; // do not change, isNaN is used in other cases\nexport const PValueDoubleNA = NaN; // do not change, isNaN is used in other cases\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 // Doesn't differ from PValueInt, TODO: branded types for these PValue* types?\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 Number.isNaN(value);\n case 'Double':\n return Number.isNaN(value);\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 PTableAbsent = { type: 'absent' } as const;\nexport type PTableAbsent = typeof PTableAbsent;\nexport const PTableNA = null;\nexport type PTableNA = typeof PTableNA;\n\n/** Decoded PTable value */\nexport type PTableValue = PTableAbsent | PTableNA | number | string;\n\n/** Type guard for absent PValue */\nexport function isPTableAbsent(value: PTableValue): value is PTableAbsent {\n return typeof value === 'object' && value !== null && value.type === 'absent';\n}\n\nexport type AbsentAndNAFill = {\n na?: PTableValue;\n absent?: PTableValue;\n};\n\n/** Read PTableValue from PTable column at specified row */\nexport function pTableValue(\n column: PTableVector,\n row: number,\n fill: AbsentAndNAFill = {},\n): PTableValue {\n if (isValueAbsent(column.absent, row))\n return fill.absent === undefined ? PTableAbsent : fill.absent;\n\n const value = column.data[row];\n const valueType = column.type;\n if (isValueNA(value, valueType)) return fill.na === undefined ? PTableNA : fill.na;\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 type { PObject, PObjectId, PObjectSpec } from '../../../pool';\nimport canonicalize from 'canonicalize';\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 PUniversalColumnSpec 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: string;\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\n/**\n * Specification of a data column.\n *\n * Data column is a specialized type of PColumn that stores only simple values (strings and numbers)\n * addressed by multiple keys. This is in contrast to other PColumn variants that can store more complex\n * values like files or other abstract data types. Data columns are optimized for storing and processing\n * basic tabular data.\n */\nexport interface PDataColumnSpec extends PUniversalColumnSpec {\n /** Type of column values */\n readonly valueType: ValueType;\n}\n\n// @todo: change this to PUniversalColumnSpec\nexport type PColumnSpec = PDataColumnSpec;\n\n/** Unique PColumnSpec identifier */\nexport type PColumnSpecId = {\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 /** A list of zero-based indices of parent axes from the {@link axesSpec} array. */\n readonly parentAxes?: number[];\n\n /** Axes id */\n readonly axesId: AxesId;\n};\n\nexport function getPColumnSpecId(spec: PColumnSpec): PColumnSpecId {\n return {\n kind: spec.kind,\n valueType: spec.valueType,\n name: spec.name,\n domain: spec.domain,\n parentAxes: spec.parentAxes,\n axesId: getAxesId(spec.axesSpec),\n };\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/** Get column id and spec from a column */\nexport function getColumnIdAndSpec<Data>(column: PColumn<Data>): PColumnIdAndSpec {\n return {\n columnId: column.id,\n spec: column.spec,\n };\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 const result = { type, name };\n if (domain && Object.entries(domain).length > 0) {\n Object.assign(result, { domain });\n }\n return result;\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/**\n * Canonicalizes axis id\n * @deprecated Use {@link canonicalizeJson} instead to preserve type\n */\nexport function canonicalizeAxisId(id: AxisId): string {\n return canonicalize(getAxisId(id))!;\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 type { PTableColumnId, PTableColumnSpec } from './table_common';\nimport type { PTableVector } from './data_types';\nimport type { PObjectId } from '../../pool';\nimport { assertNever } from '../../util';\nimport type { PColumn } from './spec/spec';\nimport type { PColumnValues } from './data_info';\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 * Axis filter slicing target axis from column axes.\n * If the axis has parents or is a parent, slicing cannot be applied (an error will be thrown).\n * */\nexport interface ConstantAxisFilter {\n /** Filter type discriminator */\n readonly type: 'constant';\n\n /** Index of axis to slice (zero-based) */\n readonly axisIndex: number;\n\n /** Equality filter reference value, see {@link SingleValueEqualPredicate} */\n readonly constant: string | number;\n}\n\n/** Defines a terminal column node in the join request tree */\nexport interface SlicedColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: 'slicedColumn';\n\n /** Local column */\n readonly column: Col;\n\n /** New column id */\n readonly newId: PObjectId;\n\n /** Non-empty list of axis filters */\n readonly axisFilters: ConstantAxisFilter[];\n}\n\n/** Defines a terminal column node in the join request tree */\nexport interface InlineColumnJoinEntry {\n /** Node type discriminator */\n readonly type: 'inlineColumn';\n\n /** Column definition */\n readonly column: PColumn<PColumnValues>;\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 | SlicedColumnJoinEntry<Col>\n | InlineColumnJoinEntry\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 SingleValueInSetPredicate {\n /** Comparison operator */\n readonly operator: 'InSet';\n\n /** Reference values, NA values will not match */\n readonly references: (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 | SingleValueInSetPredicate\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 /** Partition filters */\n readonly partitionFilters: PTableRecordFilter[];\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> = {\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/** 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 'slicedColumn':\n return {\n type: 'slicedColumn',\n column: cb(entry.column),\n newId: entry.newId,\n axisFilters: entry.axisFilters,\n };\n case 'inlineColumn':\n return entry;\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","import type { PObjectId } from '../../pool';\nimport type { AxisId, AxisSpec, PColumnSpec } from './spec/spec';\n\nexport type PTableColumnSpecAxis = {\n type: 'axis';\n id: AxisId;\n spec: AxisSpec;\n};\n\nexport type PTableColumnSpecColumn = {\n type: 'column';\n id: PObjectId;\n spec: PColumnSpec;\n};\n\n/** Unified spec object for axes and columns */\nexport type PTableColumnSpec = PTableColumnSpecAxis | PTableColumnSpecColumn;\n\nexport type PTableColumnIdAxis = {\n type: 'axis';\n id: AxisId;\n};\n\nexport type PTableColumnIdColumn = {\n type: 'column';\n id: PObjectId;\n};\n\n/** Unified PTable column identifier */\nexport type PTableColumnId = PTableColumnIdAxis | PTableColumnIdColumn;\n\nexport function getPTableColumnId(spec: PTableColumnSpec): PTableColumnId {\n switch (spec.type) {\n case 'axis':\n return {\n type: 'axis',\n id: spec.id,\n };\n case 'column':\n return {\n type: 'column',\n id: spec.id,\n };\n }\n}\n","import type { Branded } from '../../../branding';\nimport type { AnchoredPColumnId } from './selectors';\nimport type { FilteredPColumnId } from './filtered_column';\nimport canonicalize from 'canonicalize';\nimport type { PObjectId } from '../../../pool';\n/**\n * Universal column identifier optionally anchored and optionally filtered.\n */\nexport type UniversalPColumnId = AnchoredPColumnId | FilteredPColumnId;\n\n/**\n * Canonically serialized {@link UniversalPColumnId}.\n */\nexport type SUniversalPColumnId = Branded<PObjectId, 'SUniversalPColumnId', '__pl_model_brand_2__'>;\n\n/**\n * Canonically serializes a {@link UniversalPColumnId} to a string.\n * @param id - The column identifier to serialize\n * @returns The canonically serialized string\n */\nexport function stringifyColumnId(id: UniversalPColumnId): SUniversalPColumnId {\n return canonicalize(id)! as SUniversalPColumnId;\n}\n\n/**\n * Parses a canonically serialized {@link UniversalPColumnId} from a string.\n * @param str - The string to parse\n * @returns The parsed column identifier\n */\nexport function parseColumnId(str: SUniversalPColumnId): UniversalPColumnId {\n return JSON.parse(str) as UniversalPColumnId;\n}\n","import canonicalize from 'canonicalize';\nimport type { PValue } from '../data_types';\nimport type { AxisFilter } from './filtered_column';\nimport type { SUniversalPColumnId, UniversalPColumnId } from './ids';\nimport { stringifyColumnId } from './ids';\nimport type { AAxisSelector, AnchorAxisRef, AnchorAxisRefByIdx, AnchoredPColumnId, AnchoredPColumnSelector, AxisSelector, PColumnSelector } from './selectors';\nimport type { AxisId, PColumnSpec } from './spec';\nimport { getAxisId, matchAxisId } from './spec';\n\n//\n// Helper functions\n//\n\nfunction axisKey(axis: AxisId): string {\n return canonicalize(getAxisId(axis))!;\n}\n\nfunction domainKey(key: string, value: string): string {\n return JSON.stringify([key, value]);\n}\n\n/**\n * Context for resolving and generating anchored references to columns and axes\n * Maintains maps of known domain values and axes that can be referenced by anchors\n */\nexport class AnchoredIdDeriver {\n private readonly domains = new Map<string, string>();\n private readonly axes = new Map<string, AnchorAxisRefByIdx>();\n /**\n * Domain packs are used to group domain keys that can be anchored to the same anchor\n * This is used to optimize the lookup of domain anchors\n */\n private readonly domainPacks: string[][] = [];\n /**\n * Maps domain packs to anchors\n */\n private readonly domainPackToAnchor = new Map<string, string>();\n\n /**\n * Creates a new anchor context from a set of anchor column specifications\n * @param anchors Record of anchor column specifications indexed by anchor ID\n */\n constructor(public readonly anchors: Record<string, PColumnSpec>) {\n const anchorEntries = Object.entries(anchors);\n anchorEntries.sort((a, b) => a[0].localeCompare(b[0]));\n for (const [anchorId, spec] of anchorEntries) {\n for (let axisIdx = 0; axisIdx < spec.axesSpec.length; axisIdx++) {\n const axis = spec.axesSpec[axisIdx];\n const key = axisKey(axis);\n this.axes.set(key, { anchor: anchorId, idx: axisIdx });\n }\n if (spec.domain !== undefined) {\n const domainEntries = Object.entries(spec.domain);\n domainEntries.sort((a, b) => a[0].localeCompare(b[0]));\n\n this.domainPackToAnchor.set(JSON.stringify(domainEntries), anchorId);\n this.domainPacks.push(domainEntries.map(([dKey]) => dKey));\n\n for (const [dKey, dValue] of domainEntries) {\n const key = domainKey(dKey, dValue);\n this.domains.set(key, anchorId);\n }\n }\n }\n }\n\n /**\n * Derives an anchored column identifier from a column specification\n * @param spec Column specification to anchor\n * @returns An anchored column identifier that can be used to identify columns similar to the input specification\n */\n derive(spec: PColumnSpec): AnchoredPColumnId;\n\n /**\n * Derives an anchored column identifier from a column specification\n * @param spec Column specification to anchor\n * @param axisFilters Axis filters to apply to the column\n * @returns An anchored and sliced column identifier that can be used to identify columns similar to the input specification\n */\n derive(spec: PColumnSpec, axisFilters?: AxisFilter[]): UniversalPColumnId;\n\n /**\n * Implementation of derive method\n */\n derive(spec: PColumnSpec, axisFilters?: AxisFilter[]): UniversalPColumnId {\n const result: AnchoredPColumnId = {\n name: spec.name,\n axes: [],\n };\n\n let skipDomains: Set<string> | undefined = undefined;\n if (spec.domain !== undefined) {\n outer:\n for (const domainPack of this.domainPacks) {\n const dAnchor: string[][] = [];\n for (const domainKey of domainPack) {\n const dValue = spec.domain[domainKey];\n if (dValue !== undefined)\n dAnchor.push([domainKey, dValue]);\n else\n break outer;\n }\n const domainAnchor = this.domainPackToAnchor.get(JSON.stringify(dAnchor));\n if (domainAnchor !== undefined) {\n result.domainAnchor = domainAnchor;\n skipDomains = new Set(domainPack);\n break;\n }\n }\n }\n\n for (const [dKey, dValue] of Object.entries(spec.domain ?? {})) {\n if (skipDomains !== undefined && skipDomains.has(dKey))\n continue;\n const key = domainKey(dKey, dValue);\n const anchorId = this.domains.get(key);\n result.domain ??= {};\n result.domain[dKey] = anchorId ? { anchor: anchorId } : dValue;\n }\n\n result.axes = spec.axesSpec.map((axis) => {\n const key = axisKey(axis);\n const anchorAxisRef = this.axes.get(key);\n if (anchorAxisRef === undefined) return getAxisId(axis);\n else return anchorAxisRef;\n });\n\n // If no axis filters are provided, return the anchored ID as is\n if (!axisFilters || axisFilters.length === 0) {\n return result;\n }\n\n // Process axis filters and create a sliced column ID\n const resolvedFilters: [number, PValue][] = [];\n\n for (const filter of axisFilters) {\n const [axisIdOrIndex, value] = filter;\n\n // If it's already a numeric index, validate it\n if (typeof axisIdOrIndex === 'number') {\n if (axisIdOrIndex < 0 || axisIdOrIndex >= spec.axesSpec.length) {\n throw new Error(`Axis index ${axisIdOrIndex} is out of bounds (0-${spec.axesSpec.length - 1})`);\n }\n resolvedFilters.push([axisIdOrIndex, value]);\n } else {\n // If it's a string (axis name), resolve it to an index\n const axisIndex = spec.axesSpec.findIndex((axis) => axis.name === axisIdOrIndex);\n if (axisIndex === -1) {\n throw new Error(`Axis with name \"${axisIdOrIndex}\" not found in the column specification`);\n }\n resolvedFilters.push([axisIndex, value]);\n }\n }\n\n // Sort filters by axis index to ensure consistency\n resolvedFilters.sort((a, b) => a[0] - b[0]);\n\n return {\n source: result,\n axisFilters: resolvedFilters,\n };\n }\n\n /**\n * Derives a canonicalized string representation of an anchored column identifier, can be used as a unique identifier for the column\n * @param spec Column specification to anchor\n * @param axisFilters Optional axis filters to apply to the column\n * @returns A canonicalized string representation of the anchored column identifier\n */\n deriveS(spec: PColumnSpec, axisFilters?: AxisFilter[]): SUniversalPColumnId {\n return stringifyColumnId(this.derive(spec, axisFilters));\n }\n}\n\n/**\n * Options for the resolveAnchors function\n */\nexport type ResolveAnchorsOptions = {\n /**\n * If true, missing domain keys in anchors will be ignored.\n * If false (default), an error will be thrown.\n */\n ignoreMissingDomains?: boolean;\n};\n\n/**\n * Resolves anchored references in a column matcher to create a non-anchored matcher.\n * Doing an opposite operation to {@link AnchorIdDeriver.derive()}.\n *\n * @param anchors - Record of anchor column specifications indexed by anchor id\n * @param matcher - An anchored column matcher (or id, which is subtype of it) containing references that need to be resolved\n * @param options - Options for resolving anchors\n * @returns A non-anchored column matcher with all references resolved to actual values\n */\nexport function resolveAnchors(anchors: Record<string, PColumnSpec>, matcher: AnchoredPColumnSelector, options?: ResolveAnchorsOptions): PColumnSelector {\n const result = { ...matcher };\n const ignoreMissingDomains = options?.ignoreMissingDomains ?? false;\n\n if (result.domainAnchor !== undefined) {\n const anchorSpec = anchors[result.domainAnchor];\n if (!anchorSpec)\n throw new Error(`Anchor \"${result.domainAnchor}\" not found`);\n\n const anchorDomains = anchorSpec.domain || {};\n result.domain = { ...anchorDomains, ...result.domain };\n delete result.domainAnchor;\n }\n\n if (result.domain) {\n const resolvedDomain: Record<string, string> = {};\n for (const [key, value] of Object.entries(result.domain)) {\n if (typeof value === 'string') {\n resolvedDomain[key] = value;\n } else {\n // It's an AnchorDomainRef\n const anchorSpec = anchors[value.anchor];\n if (!anchorSpec)\n throw new Error(`Anchor \"${value.anchor}\" not found for domain key \"${key}\"`);\n\n if (!anchorSpec.domain || anchorSpec.domain[key] === undefined) {\n if (!ignoreMissingDomains)\n throw new Error(`Domain key \"${key}\" not found in anchor \"${value.anchor}\"`);\n continue;\n }\n\n resolvedDomain[key] = anchorSpec.domain[key];\n }\n }\n result.domain = resolvedDomain;\n }\n\n if (result.axes)\n result.axes = result.axes.map((axis) => resolveAxisReference(anchors, axis));\n\n return result as PColumnSelector;\n}\n\n/**\n * Resolves an anchored axis reference to a concrete AxisId\n */\nfunction resolveAxisReference(anchors: Record<string, PColumnSpec>, axisRef: AAxisSelector): AxisSelector {\n if (!isAnchorAxisRef(axisRef))\n return axisRef;\n\n // It's an anchored reference\n const anchorId = axisRef.anchor;\n const anchorSpec = anchors[anchorId];\n if (!anchorSpec)\n throw new Error(`Anchor \"${anchorId}\" not found for axis reference`);\n\n if ('idx' in axisRef) {\n // AnchorAxisRefByIdx\n if (axisRef.idx < 0 || axisRef.idx >= anchorSpec.axesSpec.length)\n throw new Error(`Axis index ${axisRef.idx} out of bounds for anchor \"${anchorId}\"`);\n return anchorSpec.axesSpec[axisRef.idx];\n } else if ('name' in axisRef) {\n // AnchorAxisRefByName\n const matches = anchorSpec.axesSpec.filter((axis) => axis.name === axisRef.name);\n if (matches.length > 1)\n throw new Error(`Multiple axes with name \"${axisRef.name}\" found in anchor \"${anchorId}\"`);\n if (matches.length === 0)\n throw new Error(`Axis with name \"${axisRef.name}\" not found in anchor \"${anchorId}\"`);\n return matches[0];\n } else if ('id' in axisRef) {\n // AnchorAxisRefByMatcher\n const matches = anchorSpec.axesSpec.filter((axis) => matchAxisId(axisRef.id, getAxisId(axis)));\n if (matches.length > 1)\n throw new Error(`Multiple matching axes found for matcher in anchor \"${anchorId}\"`);\n if (matches.length === 0)\n throw new Error(`No matching axis found for matcher in anchor \"${anchorId}\"`);\n return matches[0];\n }\n\n throw new Error(`Unsupported axis reference type`);\n}\n\n/**\n * Type guard to check if a value is an anchored axis reference\n */\nfunction isAnchorAxisRef(value: AAxisSelector): value is AnchorAxisRef {\n return typeof value === 'object' && 'anchor' in value;\n}\n","import type { Branded } from '../branding';\nimport type { JoinEntry, PColumn, PColumnSpec } from '../drivers';\nimport { assertNever } from '../util';\nimport type { 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 /** Name is common part of PObject identity */\n readonly name: string;\n\n /** Domain is a set of key-value pairs that can be used to identify the object */\n readonly domain?: Record<string, 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 'slicedColumn':\n columns.set(entry.column.id, entry.column);\n return;\n case 'inlineColumn':\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 { isPColumnSpec, type PObjectSpec } from '../../../pool';\nimport type { AxisId, PColumnSpec, ValueType } from './spec';\nimport { getAxisId } from './spec';\n\n/**\n * Defines a pattern for matching axes within the PFrame data model.\n *\n * AxisSelector provides a flexible way to identify axes based on their\n * properties. All fields are optional, allowing for partial matching.\n * When multiple properties are specified, all must match for an axis\n * to be selected (logical AND).\n *\n * This interface is used in various selection and matching operations\n * throughout the PFrame system, such as column queries and axis lookups.\n */\nexport interface AxisSelector {\n /**\n * Optional value type to match against.\n * When specified, only axes with this exact type will match.\n * Can be a single type or an array of types to match against any of them.\n * Valid types include: 'Int', 'Long', 'Float', 'Double', 'String', 'Bytes'.\n */\n type?: ValueType | ValueType[];\n\n /**\n * Optional name to match against.\n * When specified, only axes with this exact name will match.\n */\n name?: string;\n\n /**\n * Optional domain key-value pairs to match against.\n * Domains provide additional context to uniquely identify an axis beyond its name and type.\n * When specified, an axis will match only if it contains all the key-value pairs defined here.\n * An axis with additional domain entries not present in this selector will still match.\n */\n domain?: Record<string, string>;\n}\n\n/**\n * Reference to an axis by its numerical index within the anchor column's axes array\n * Format: [anchorId, axisIndex]\n */\nexport type AnchorAxisRefByIdx = { anchor: string; idx: number };\n\n/**\n * Reference to an axis by its name within the anchor column\n * Format: [anchorId, axisName]\n */\nexport type AnchorAxisRefByName = { anchor: string; name: string };\n\n/**\n * Reference to an axis using an AxisId matcher within the anchor\n * Format: [anchorId, axisMatcher]\n */\nexport type AnchorAxisRefByMatcher = { anchor: string; id: AxisId };\n\n/**\n * Basic anchor axis reference that can be either by index or a direct AxisId\n */\nexport type AnchorAxisIdOrRefBasic = AnchorAxisRefByIdx | AxisId;\n\n/** Union of all possible ways to reference an axis in an anchored context */\nexport type AnchorAxisRef = AnchorAxisRefByIdx | AnchorAxisRefByName | AnchorAxisRefByMatcher;\n\n/** Reference to a domain value through an anchor */\nexport type AnchorDomainRef = { anchor: string };\n\n/**\n * Domain value that can be either a direct string value or a reference to a domain through an anchor\n * Used to establish domain context that can be resolved relative to other anchored columns\n */\nexport type ADomain = string | AnchorDomainRef;\n/**\n * Axis identifier that can be either a direct AxisId or a reference to an axis through an anchor\n * Allows referring to axes in a way that can be resolved in different contexts\n */\nexport type AAxisSelector = AxisSelector | AnchorAxisRef;\n\n/**\n * Match resolution strategy for PColumns\n * Specifies how to handle when multiple columns match the criteria\n * (default is \"expectSingle\")\n */\nexport type AnchoredColumnMatchStrategy = 'expectSingle' | 'expectMultiple' | 'takeFirst';\n\n/**\n * Matcher for PColumns in an anchored context\n * Supports partial matching on axes, allowing for flexible column discovery\n */\nexport interface AnchoredPColumnSelector {\n /** Optional name of the column to match; can't be used together with namePattern */\n name?: string;\n /** Optional regexp pattern for column name matching; can't be used together with name */\n namePattern?: string;\n /** Optional value type to match. If an array is provided, matches if the column's type is any of the specified types */\n type?: ValueType | ValueType[];\n /** If specified, the domain values must be anchored to this anchor */\n domainAnchor?: string;\n /** Optional domain values to match, can include anchored references, if domainAnchor is specified,\n * interpreted as additional domains to domain from the anchor */\n domain?: Record<string, ADomain>;\n /** Optional axes to match, can include anchored references */\n axes?: AAxisSelector[];\n /** When true, allows matching if only a subset of axes match */\n partialAxesMatch?: boolean;\n /** Optional annotations to match with exact values */\n annotations?: Record<string, string>;\n /** Optional annotation patterns to match with regex patterns */\n annotationPatterns?: Record<string, string>;\n /** Match resolution strategy, default is \"expectSingle\" */\n matchStrategy?: AnchoredColumnMatchStrategy;\n}\n\n/**\n * Matcher for PColumns in a non-anchored context\n */\nexport interface PColumnSelector extends AnchoredPColumnSelector {\n domainAnchor?: never;\n domain?: Record<string, string>;\n axes?: AxisSelector[];\n}\n\n/**\n * Strict identifier for PColumns in an anchored context\n * Unlike APColumnMatcher, this requires exact matches on domain and axes\n */\nexport interface AnchoredPColumnId extends AnchoredPColumnSelector {\n /** Name is required for exact column identification */\n name: string;\n /** No namePattern in ID */\n namePattern?: never;\n /** Type is not used in exact column identification */\n type?: never;\n /** Full axes specification using only basic references */\n axes: AnchorAxisIdOrRefBasic[];\n /** Partial axes matching is not allowed for exact identification */\n partialAxesMatch?: never;\n /** Annotations are not used in exact column identification */\n annotations?: never;\n /** Annotation patterns are not used in exact column identification */\n annotationPatterns?: never;\n /** \"Id\" implies single match strategy */\n matchStrategy?: never;\n}\n\n/**\n * Determines if an axis ID matches an axis selector.\n *\n * @param selector - The selector with criteria to match against\n * @param axis - The AxisId to check against the selector\n * @returns true if the AxisId matches all specified criteria in the selector, false otherwise\n */\nexport function matchAxis(selector: AxisSelector, axis: AxisId): boolean {\n // Match name if specified\n if (selector.name !== undefined && selector.name !== axis.name)\n return false;\n\n // Match type if specified\n if (selector.type !== undefined) {\n if (Array.isArray(selector.type)) {\n if (!selector.type.includes(axis.type))\n return false;\n } else if (selector.type !== axis.type) {\n return false;\n }\n }\n\n // Match domain if specified - using existing logic from matchAxisId\n if (selector.domain !== undefined) {\n const axisDomain = axis.domain || {};\n for (const [key, value] of Object.entries(selector.domain))\n if (axisDomain[key] !== value)\n return false;\n }\n\n return true;\n}\n\n/**\n * Determines if a given PColumnSpec matches a selector.\n *\n * @param pcolumn - The PColumnSpec to check against the selector\n * @param selector - The selector criteria to match against\n * @returns true if the PColumnSpec matches all criteria in the selector, false otherwise\n */\nexport function matchPColumn(pcolumn: PColumnSpec, selector: PColumnSelector): boolean {\n // Match name if specified\n if (selector.name !== undefined && pcolumn.name !== selector.name)\n return false;\n\n // Match name pattern if specified\n if (selector.namePattern !== undefined && !new RegExp(selector.namePattern).test(pcolumn.name))\n return false;\n\n // Match type if specified\n if (selector.type !== undefined) {\n if (Array.isArray(selector.type)) {\n if (!selector.type.includes(pcolumn.valueType))\n return false;\n } else if (selector.type !== pcolumn.valueType) {\n return false;\n }\n }\n\n // Match domain if specified\n if (selector.domain !== undefined) {\n const columnDomain = pcolumn.domain || {};\n for (const [key, value] of Object.entries(selector.domain))\n if (columnDomain[key] !== value)\n return false;\n }\n\n // Match axes if specified\n if (selector.axes !== undefined) {\n const pcolumnAxes = pcolumn.axesSpec.map(getAxisId);\n\n if (selector.partialAxesMatch) {\n // For partial matching, all selector axes must match at least one column axis\n for (const selectorAxis of selector.axes)\n if (!pcolumnAxes.some((columnAxis) => matchAxis(selectorAxis, columnAxis)))\n return false;\n } else {\n // For exact matching, column must have the same number of axes and all must match\n if (pcolumnAxes.length !== selector.axes.length)\n return false;\n\n // Each selector axis must match a corresponding column axis\n for (let i = 0; i < selector.axes.length; i++)\n if (!matchAxis(selector.axes[i], pcolumnAxes[i]))\n return false;\n }\n }\n\n // Match annotations if specified\n if (selector.annotations !== undefined) {\n const columnAnnotations = pcolumn.annotations || {};\n for (const [key, value] of Object.entries(selector.annotations))\n if (columnAnnotations[key] !== value)\n return false;\n }\n\n // Match annotation patterns if specified\n if (selector.annotationPatterns !== undefined) {\n const columnAnnotations = pcolumn.annotations || {};\n for (const [key, pattern] of Object.entries(selector.annotationPatterns)) {\n const value = columnAnnotations[key];\n if (value === undefined || !new RegExp(pattern).test(value))\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Convert a predicate or array of selectors to a single predicate function\n * @param predicateOrSelectors - Either a function that takes a PColumnSpec and returns a boolean,\n * or an array of PColumnSelectors, or a single PColumnSelector\n * @returns A function that takes a PColumnSpec and returns a boolean\n */\nexport function selectorsToPredicate(predicateOrSelectors: PColumnSelector | PColumnSelector[]): ((spec: PObjectSpec) => boolean) {\n if (Array.isArray(predicateOrSelectors))\n return (spec) => predicateOrSelectors.some((selector) => isPColumnSpec(spec) && matchPColumn(spec, selector));\n else\n return (spec) => isPColumnSpec(spec) && matchPColumn(spec, predicateOrSelectors);\n}\n","import type { Branded } from '../../../branding';\nimport { isPColumnSpec, type PObjectSpec } from '../../../pool';\nimport { getAxesId } from './spec';\nimport canonicalize from 'canonicalize';\nexport type NativePObjectId = Branded<string, 'NativePObjectId'>;\n\nexport function deriveNativeId(spec: PObjectSpec): NativePObjectId {\n const result: Record<string, unknown> = {\n kind: spec.kind,\n name: spec.name,\n };\n if (spec.domain !== undefined)\n result.domain = spec.domain;\n if (isPColumnSpec(spec))\n result.axesSpec = getAxesId(spec.axesSpec);\n return canonicalize(result) as NativePObjectId;\n}\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()\n .describe('Upstream block id'),\n name: z.string()\n .describe('Name of the output provided to the upstream block\\'s output context'),\n requireEnrichments: z.literal(true).optional()\n .describe('True if current block that stores this reference in its args, may need enrichments '\n + 'for the references value originating from the blocks in between current and referenced block'),\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 .readonly();\nexport type PlRef = z.infer<typeof PlRef>;\n/** @deprecated use {@link PlRef} */\nexport type Ref = PlRef;\n\n/**\n * Type guard to check if a value is a PlRef.\n *\n * @param value - The value to check.\n * @returns True if the value is a PlRef, false otherwise.\n */\nexport function isPlRef(value: unknown): value is PlRef {\n return (\n typeof value === 'object'\n && value !== null\n && '__isRef' in value\n && (value as { __isRef: unknown }).__isRef === true\n && 'blockId' in value\n && 'name' in value\n );\n}\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/**\n * Creates a PlRef with the given blockId and name.\n *\n * @param blockId - The blockId of the reference.\n * @param name - The name of the reference.\n * @param requireEnrichments - Whether the reference requires enrichments.\n */\nexport function createPlRef(blockId: string, name: string, requireEnrichments: boolean = false) {\n if (requireEnrichments)\n return {\n __isRef: true,\n blockId,\n name,\n requireEnrichments: true,\n };\n else\n return {\n __isRef: true,\n blockId,\n name,\n };\n}\n\n/**\n * Creates a new PlRef based on an existing one, explicitly setting (default) or removing the\n * requireEnrichments property.\n *\n * @param ref - The original PlRef object.\n * @param requireEnrichments - If true, the `requireEnrichments: true` property is added\n * to the returned PlRef. If false, the `requireEnrichments` property is removed. Defaults to true.\n * @returns A new PlRef object with the `requireEnrichments` property set or removed accordingly.\n */\nexport function withEnrichments(ref: PlRef, requireEnrichments: boolean = true): PlRef {\n if (requireEnrichments)\n return {\n ...ref,\n requireEnrichments: true,\n };\n else {\n const { requireEnrichments: _, ...rest } = ref;\n return rest;\n }\n}\n\n/** Compare two PlRefs and returns true if they are qual */\nexport function plRefsEqual(ref1: PlRef, ref2: PlRef, ignoreEnrichments: boolean = false) {\n return ref1.blockId === ref2.blockId && ref1.name === ref2.name && (ignoreEnrichments || ref1.requireEnrichments === ref2.requireEnrichments);\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","type Data = Int8Array | Uint8Array | Uint8ClampedArray | ArrayBuffer;\n\nfunction toDataView(data: Data) {\n if (data instanceof Int8Array || data instanceof Uint8Array || data instanceof Uint8ClampedArray)\n return new DataView(data.buffer, data.byteOffset, data.byteLength);\n\n if (data instanceof ArrayBuffer) return new DataView(data);\n\n throw new TypeError(\n 'Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray',\n );\n}\n\ninterface Options {\n /** If set, forcefully enable or disable padding. The default behavior is to follow the default of the selected variant. */\n padding?: boolean;\n}\n\nconst RFC4648 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\nconst RFC4648_HEX = '0123456789ABCDEFGHIJKLMNOPQRSTUV';\nconst CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';\n\nexport function base32Encode(\n data: Data,\n variant: 'RFC3548' | 'RFC4648' | 'RFC4648-HEX' | 'Crockford',\n options?: Options,\n) {\n options = options || {};\n let alphabet, defaultPadding;\n\n switch (variant) {\n case 'RFC3548':\n case 'RFC4648':\n alphabet = RFC4648;\n defaultPadding = true;\n break;\n case 'RFC4648-HEX':\n alphabet = RFC4648_HEX;\n defaultPadding = true;\n break;\n case 'Crockford':\n alphabet = CROCKFORD;\n defaultPadding = false;\n break;\n default:\n throw new Error('Unknown base32 variant: ' + String(variant));\n }\n\n const padding = options.padding !== undefined ? options.padding : defaultPadding;\n const view = toDataView(data);\n\n let bits = 0;\n let value = 0;\n let output = '';\n\n for (let i = 0; i < view.byteLength; i++) {\n value = (value << 8) | view.getUint8(i);\n bits += 8;\n\n while (bits >= 5) {\n output += alphabet[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) output += alphabet[(value << (5 - bits)) & 31];\n\n if (padding)\n while (output.length % 8 !== 0) {\n output += '=';\n }\n\n return output;\n}\n","import { z } from 'zod';\nimport { base32Encode } from './base32_encode';\n\n/** Number of raw bytes in the PlId. */\nexport const PlIdBytes = 15;\n/** Characters in string representation */\nexport const PlIdLength = 24; // = 15 bytes * 8 bits / 5 bits per char in base32\n\nexport const PlId = z\n .string()\n .length(PlIdLength)\n .regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/) // RFC4648\n .brand('PlId');\nexport type PlId = z.infer<typeof PlId>;\n\nexport function uniquePlId(): PlId {\n const data = new Uint8Array(PlIdBytes);\n crypto.getRandomValues(data);\n return PlId.parse(base32Encode(data, 'RFC4648'));\n}\n\nexport function plId(bytes: Uint8Array): PlId {\n if (bytes.length !== PlIdBytes) throw new Error(`Wrong number of bytes: ${bytes.length}`);\n return PlId.parse(base32Encode(bytes, 'RFC4648'));\n}\n\nexport async function digestPlId(data: string): Promise<PlId> {\n const encoder = new TextEncoder();\n const bytes = await crypto.subtle.digest('SHA-256', encoder.encode(data));\n return plId(new Uint8Array(bytes.slice(0, 15)));\n}\n","import canonicalize from 'canonicalize';\n\ntype JsonPrimitive = string | number | boolean | null | undefined;\n\ntype JsonValue = JsonPrimitive | JsonValue[] | {\n [key: string]: JsonValue;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\ntype NotAssignableToJson = bigint | symbol | Function;\n\nexport type JsonCompatible<T> = unknown extends T ? never : {\n [P in keyof T]:\n T[P] extends JsonValue ? T[P] :\n T[P] extends NotAssignableToJson ? never :\n JsonCompatible<T[P]>;\n};\n\nexport type StringifiedJson<T> = JsonCompatible<T> extends never ? never : string & {\n __json_stringified: T;\n};\n\nexport function stringifyJson<T>(value: JsonCompatible<T>): StringifiedJson<T> {\n return JSON.stringify(value)! as StringifiedJson<T>;\n}\n\nexport type CanonicalizedJson<T> = JsonCompatible<T> extends never ? never : string & {\n __json_canonicalized: T;\n};\n\nexport function canonicalizeJson<T>(value: JsonCompatible<T>): CanonicalizedJson<T> {\n return canonicalize(value)! as CanonicalizedJson<T>;\n}\n\nexport function parseJson<T>(value: StringifiedJson<T> | CanonicalizedJson<T>): T {\n return JSON.parse(value) as T;\n}\n","/**\n * Just for convenience, usually it is an Error with name 'AbortError'\n */\nexport class AbortError extends Error {\n name = 'AbortError';\n}\n\n/**\n * Throw this to show a message without stack trace in UI\n */\nexport class UiError extends Error {\n name = 'UiError';\n}\n\nexport function isAbortError(error: unknown): error is Error & { name: 'AbortError' } {\n return error instanceof Error && error.name === 'AbortError';\n}\n\nexport function hasAbortError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n\n return error.name === 'AbortError' || hasAbortError(error.cause);\n}\n\nexport function isAggregateError(error: unknown): error is AggregateError {\n return error instanceof Error && error.name === 'AggregateError';\n}\n\nexport class PFrameError extends Error {\n name = 'PFrameError';\n}\n\nexport function isPFrameError(error: unknown): error is PFrameError {\n return error instanceof Error && error.name === 'PFrameError';\n}\n\nexport class PFrameDriverError extends PFrameError {\n name = 'PFrameError.Driver';\n}\n\nexport function isPFrameDriverError(error: unknown): error is PFrameDriverError {\n return error instanceof Error && error.name === 'PFrameError.Driver';\n}\n\nfunction stringifyValue(value: unknown): string {\n if (typeof value === 'string') {\n return `String value was thrown: ${value}`;\n }\n\n if (value && typeof value === 'object') {\n try {\n return `Plain object was thrown: ${JSON.stringify(value)}`;\n } catch (jsonError) {\n const errorMessage = jsonError instanceof Error ? jsonError.message : String(jsonError);\n return `Non-serializable object was thrown (JSON.stringify failed: ${errorMessage}): ${String(value)}`;\n }\n }\n\n return String(`Non-Error value (${typeof value}) was thrown: ${value}`);\n}\n\nexport function ensureError(value: unknown): Error {\n if (value instanceof Error) {\n return value;\n }\n\n return new Error(stringifyValue(value));\n}\n\n// Error serialization for IPC/network transmission (Error objects can't be JSON serialized)\n\nexport type SerializedError = {\n name: string;\n message: string;\n stack: string | undefined;\n cause?: SerializedError;\n};\n\nexport function deserializeError(obj: SerializedError): Error {\n const cause = obj.cause ? deserializeError(obj.cause) : undefined;\n\n const error = new Error(obj.message, cause !== undefined ? { cause } : undefined);\n error.name = obj.name || 'Error';\n error.stack = obj.stack;\n\n return error;\n}\n\nexport function serializeError(e: unknown): SerializedError {\n const error = ensureError(e);\n const cause = error.cause ? serializeError(error.cause) : undefined;\n\n return {\n name: error.name,\n message: error.message,\n stack: error.stack,\n ...(error.cause !== undefined && { cause }),\n };\n}\n\nexport type ResultOrError<S, F = Error> = {\n value: S;\n error?: undefined;\n} | {\n error: F;\n};\n\nexport function unwrapResult<T>(result: ResultOrError<T>): T {\n if (result.error) {\n throw result.error;\n }\n return result.value;\n}\n\nexport function serializeResult<T>(result: ResultOrError<T>): ResultOrError<T, SerializedError> {\n if (result.error) {\n return { error: serializeError(result.error) };\n }\n return { value: result.value };\n}\n\nexport function deserializeResult<T>(result: ResultOrError<T, SerializedError>): ResultOrError<T> {\n if (result.error) {\n return { error: deserializeError(result.error) };\n }\n return { value: result.value };\n}\n\nexport function wrapCallback<T>(callback: () => T): ResultOrError<T> {\n try {\n const value = callback();\n return { value };\n } catch (error) {\n return { error: ensureError(error) };\n }\n}\n\nexport async function wrapAsyncCallback<T>(callback: () => Promise<T>): Promise<ResultOrError<T>> {\n try {\n const value = await callback();\n return { value };\n } catch (error) {\n return { error: ensureError(error) };\n }\n}\n\nexport function wrapAndSerialize<T>(callback: () => T): ResultOrError<T, SerializedError> {\n const result = wrapCallback(callback);\n return serializeResult(result);\n}\n\nexport async function wrapAndSerializeAsync<T>(callback: () => Promise<T>): Promise<ResultOrError<T, SerializedError>> {\n const result = await wrapAsyncCallback(callback);\n return serializeResult(result);\n}\n"],"names":["z","assertNever","x","isDataInfo","value","data","mapDataInfo","dataInfo","mapFn","newParts","key","blob","chunk","isDataInfoEntries","isPartitionedDataInfoEntries","dataInfoToEntries","entries","keyStr","parts","entriesToDataInfo","dataInfoEntries","entry","PValueIntNA","PValueLongNA","PValueStringNA","PValueBytesNA","isValueNA","valueType","isValueAbsent","absent","index","chunkIndex","mask","PTableAbsent","PTableNA","isPTableAbsent","pTableValue","column","row","fill","getAxisId","spec","type","name","domain","result","getAxesId","canonicalizeAxisId","id","canonicalize","matchDomain","query","target","k","matchAxisId","mapPTableDef","def","cb","mapJoinEntry","col","getPTableColumnId","stringifyColumnId","axisKey","axis","domainKey","AnchoredIdDeriver","anchors","__publicField","anchorEntries","a","b","anchorId","axisIdx","domainEntries","dKey","dValue","axisFilters","skipDomains","outer","domainPack","dAnchor","domainAnchor","anchorAxisRef","resolvedFilters","filter","axisIdOrIndex","axisIndex","resolveAnchors","matcher","options","ignoreMissingDomains","anchorSpec","anchorDomains","resolvedDomain","resolveAxisReference","axisRef","isAnchorAxisRef","matches","isPColumnSpec","isPColumn","obj","ensurePColumn","mapPObjectData","pObj","extractAllColumns","columns","addAllColumns","e","matchAxis","selector","axisDomain","matchPColumn","pcolumn","columnDomain","pcolumnAxes","selectorAxis","columnAxis","i","columnAnnotations","pattern","selectorsToPredicate","predicateOrSelectors","deriveNativeId","isPlRef","withEnrichments","ref","requireEnrichments","_","rest","mapValueInVOE","voe","toDataView","RFC4648","RFC4648_HEX","CROCKFORD","base32Encode","variant","alphabet","defaultPadding","padding","view","bits","output","PlIdBytes","PlIdLength","PlId","uniquePlId","canonicalizeJson","parseJson","stringifyValue","jsonError","ensureError"],"mappings":";;;AAyB0BA,EAAE,OAAO;AAAA;AAAA,EAEjC,MAAMA,EAAE,OAAO;AAAA;AAAA,EAEf,IAAIA,EAAE,OAAO;AACf,CAAC;AC9BM,SAASC,EAAYC,GAAiB;AACrC,QAAA,IAAI,MAAM,wBAAwBA,CAAC;AAC3C;ACsGO,SAASC,EAAiBC,GAAyC;AACpE,MAAA,CAACA,KAAS,OAAOA,KAAU;AACtB,WAAA;AAGT,QAAMC,IAAOD;AACT,MAAA,EAAE,UAAUC;AACP,WAAA;AAGT,UAAQA,EAAK,MAAM;AAAA,IACjB,KAAK;AAED,aAAA,OAAOA,EAAK,aAAc,YACvBA,EAAK,SAAS,UACd,OAAOA,EAAK,QAAS;AAAA,IAE5B,KAAK;AAED,aAAA,OAAOA,EAAK,sBAAuB,YAChCA,EAAK,UAAU,UACf,OAAOA,EAAK,SAAU;AAAA,IAE7B,KAAK;AAED,aAAA,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AAC,GAC9BwB,KAAA,GAEDA,KAAQ;AACbC,MAAAA,KAAUL,EAAUrI,MAAWyI,IAAO,IAAM,EAAE,GACtCA,KAAA;AAIRA,MAAAA,IAAO,MAAGC,KAAUL,EAAUrI,KAAU,IAAIyI,IAAS,EAAE,IAEvDF;AACKG,WAAAA,EAAO,SAAS,MAAM;AACjBA,MAAAA,KAAA;AAGPA,SAAAA;AACT;ACrEO,MAAMC,IAAY,IAEZC,IAAa,IAEbC,IAAOjJ,EACjB,OAAA,EACA,OAAOgJ,CAAU,EACjB,MAAM,oCAAoC,EAC1C,MAAM,MAAM;AAGR,SAASE,KAAmB;AAC3B7I,QAAAA,IAAO,IAAI,WAAW0I,CAAS;AAC9B,SAAA,OAAA,gBAAgB1I,CAAI,GACpB4I,EAAK,MAAMV,EAAalI,GAAM,SAAS,CAAC;AACjD;ACWO,SAAS8I,GAAoB/I,GAAgD;AAClF,SAAO6C,EAAa7C,CAAK;AAC3B;AAEO,SAASgJ,GAAahJ,GAAqD;AACzE,SAAA,KAAK,MAAMA,CAAK;AACzB;ACUA,SAASiJ,EAAejJ,GAAwB;AAC1C,MAAA,OAAOA,KAAU;AACnB,WAAO,4BAA4BA,CAAK;AAGtCA,MAAAA,KAAS,OAAOA,KAAU;AACxB,QAAA;AACF,aAAO,4BAA4B,KAAK,UAAUA,CAAK,CAAC;AAAA,IAAA,SACjDkJ,GAAW;AAEX,aAAA,8DADcA,aAAqB,QAAQA,EAAU,UAAU,OAAOA,CAAS,CACL,MAAM,OAAOlJ,CAAK,CAAC;AAAA,IAAA;AAIxG,SAAc,oBAAoB,OAAOA,CAAK,iBAAiBA,CAAK;AACtE;AAEO,SAASmJ,GAAYnJ,GAAuB;AACjD,SAAIA,aAAiB,QACZA,IAGF,IAAI,MAAMiJ,EAAejJ,CAAK,CAAC;AACxC;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../../../lib/model/common/src/drivers/blob.ts","../../../../../../../lib/model/common/src/util.ts","../../../../../../../lib/model/common/src/drivers/pframe/data_info.ts","../../../../../../../lib/model/common/src/drivers/pframe/data_types.ts","../../../../../../../lib/model/common/src/drivers/pframe/spec/spec.ts","../../../../../../../lib/model/common/src/drivers/pframe/table_calculate.ts","../../../../../../../lib/model/common/src/drivers/pframe/table_common.ts","../../../../../../../lib/model/common/src/drivers/pframe/spec/ids.ts","../../../../../../../lib/model/common/src/drivers/pframe/spec/anchored.ts","../../../../../../../lib/model/common/src/pool/spec.ts","../../../../../../../lib/model/common/src/drivers/pframe/spec/selectors.ts","../../../../../../../lib/model/common/src/drivers/pframe/spec/native_id.ts","../../../../../../../lib/model/common/src/ref.ts","../../../../../../../lib/model/common/src/value_or_error.ts","../../../../../../../lib/model/common/src/base32_encode.ts","../../../../../../../lib/model/common/src/plid.ts","../../../../../../../lib/model/common/src/json.ts","../../../../../../../lib/model/common/src/errors.ts"],"sourcesContent":["import type { Branded } from '../branding';\nimport { z } from 'zod';\n\n/** Handle of locally downloaded blob. This handle is issued only after the\n * blob's content is downloaded locally, and ready for quick access. */\nexport type LocalBlobHandle = Branded<string, 'LocalBlobHandle'>;\n\n/** Handle of remote blob. This handle is issued as soon as the data becomes\n * available on the remote server. */\nexport type RemoteBlobHandle = Branded<string, 'RemoteBlobHandle'>;\n\n/** Being configured inside the output structure provides information about\n * blob's content and means to retrieve it when needed. */\nexport interface BlobHandleAndSize<\n H extends LocalBlobHandle | RemoteBlobHandle = | LocalBlobHandle\n | RemoteBlobHandle,\n> {\n /** Handle to retrieve block content using {@link BlobDriver.getContent()} */\n readonly handle: H;\n\n /** Blob size in bytes. */\n readonly size: number;\n}\n\n/** Range in bytes, from should be less or equal than to. */\nexport const RangeBytes = z.object({\n /** Included left border. */\n from: z.number(),\n /** Excluded right border. */\n to: z.number(),\n});\n\nexport type RangeBytes = z.infer<typeof RangeBytes>;\n\nexport function newRangeBytesOpt(from?: number, to?: number): RangeBytes | undefined {\n if (from == undefined || to == undefined) {\n return undefined;\n }\n\n return { from, to };\n}\n\nexport function validateRangeBytes(range: RangeBytes, errMsg: string) {\n if (range.from < 0 || range.to < 0 || range.from >= range.to) {\n throw new Error(`${errMsg}: invalid bytes range: ${range}`);\n }\n}\n\n/** Being configured inside the output structure provides information about\n * locally downloaded blob and means to retrieve it's content when needed. This\n * structure is created only after the blob's content is downloaded locally, and\n * ready for quick access. */\nexport type LocalBlobHandleAndSize = BlobHandleAndSize<LocalBlobHandle>;\n\n/** Being configured inside the output structure provides information about\n * remote blob and means to retrieve it's content when needed. This structure\n * is created as soon as remote blob becomes available. */\nexport type RemoteBlobHandleAndSize = BlobHandleAndSize<RemoteBlobHandle>;\n\n/** Defines API of blob driver as it is seen from the block UI code. */\nexport interface BlobDriver {\n /** Given the blob handle returns its content. Depending on the handle type,\n * content will be served from locally downloaded file, or directly from\n * remote platforma storage. */\n getContent(handle: LocalBlobHandle | RemoteBlobHandle, range?: RangeBytes): Promise<Uint8Array>;\n}\n","export function assertNever(x: never): never {\n throw new Error('Unexpected object: ' + x); // This is ok, because this is a possible runtime error\n}\n","/**\n * Represents a JavaScript representation of a value in a PColumn. Can be null, a number, or a string.\n * These are the primitive types that can be stored directly in PColumns.\n *\n * Note: Actual columns can hold more value types, which are converted to these JavaScript types\n * once they enter the JavaScript runtime.\n */\nexport type PColumnValue = null | number | string;\n\n/**\n * Represents a key for a PColumn value.\n * Can be an array of strings or numbers.\n */\nexport type PColumnKey = (number | string)[];\n\n/**\n * Represents a single entry in a PColumn's data structure.\n * Contains a key and a value.\n */\nexport type PColumnDataEntry<T> = {\n /** Key for the value */\n key: PColumnKey;\n\n /** Value / blob at the given key */\n value: T;\n};\n\n/**\n * Represents column data stored as a simple JSON structure.\n * Used for small datasets that can be efficiently stored directly in memory.\n */\nexport type JsonDataInfo = {\n /** Identifier for this data format ('Json') */\n type: 'Json';\n\n /** Number of axes that make up the complete key (tuple length) */\n keyLength: number;\n\n /**\n * Key-value pairs where keys are stringified tuples of axis values\n * and values are the column values for those coordinates\n */\n data: Record<string, PColumnValue>;\n};\n\n/**\n * Represents column data partitioned across multiple JSON blobs.\n * Used for larger datasets that need to be split into manageable chunks.\n */\nexport type JsonPartitionedDataInfo<Blob> = {\n /** Identifier for this data format ('JsonPartitioned') */\n type: 'JsonPartitioned';\n\n /** Number of leading axes used for partitioning */\n partitionKeyLength: number;\n\n /** Map of stringified partition keys to blob references */\n parts: Record<string, Blob>;\n};\n\n/**\n * Represents a binary format chunk containing index and values as separate blobs.\n * Used for efficient storage and retrieval of column data in binary format.\n */\nexport type BinaryChunk<Blob> = {\n /** Binary blob containing structured index information */\n index: Blob;\n\n /** Binary blob containing the actual values */\n values: Blob;\n};\n\n/**\n * Represents column data partitioned across multiple binary chunks.\n * Optimized for efficient storage and retrieval of large datasets.\n */\nexport type BinaryPartitionedDataInfo<Blob> = {\n /** Identifier for this data format ('BinaryPartitioned') */\n type: 'BinaryPartitioned';\n\n /** Number of leading axes used for partitioning */\n partitionKeyLength: number;\n\n /** Map of stringified partition keys to binary chunks */\n parts: Record<string, BinaryChunk<Blob>>;\n};\n\n/**\n * Union type representing all possible data storage formats for PColumn data.\n * The specific format used depends on data size, access patterns, and performance requirements.\n *\n * @template Blob - Type parameter representing the storage reference type (could be ResourceInfo, PFrameBlobId, etc.)\n */\nexport type DataInfo<Blob> =\n | JsonDataInfo\n | JsonPartitionedDataInfo<Blob>\n | BinaryPartitionedDataInfo<Blob>;\n\n/**\n * Type guard function that checks if the given value is a valid DataInfo.\n *\n * @param value - The value to check\n * @returns True if the value is a valid DataInfo, false otherwise\n */\nexport function isDataInfo<Blob>(value: unknown): value is DataInfo<Blob> {\n if (!value || typeof value !== 'object') {\n return false;\n }\n\n const data = value as Record<string, unknown>;\n if (!('type' in data)) {\n return false;\n }\n\n switch (data.type) {\n case 'Json':\n return (\n typeof data.keyLength === 'number'\n && data.data !== undefined\n && typeof data.data === 'object'\n );\n case 'JsonPartitioned':\n return (\n typeof data.partitionKeyLength === 'number'\n && data.parts !== undefined\n && typeof data.parts === 'object'\n );\n case 'BinaryPartitioned':\n return (\n typeof data.partitionKeyLength === 'number'\n && data.parts !== undefined\n && typeof data.parts === 'object'\n );\n default:\n return false;\n }\n}\n\n/**\n * Maps blob references in a DataInfo object from one type to another using a mapping function.\n *\n * @template B1 - Source blob type\n * @template B2 - Target blob type\n * @param dataInfo - The source DataInfo object\n * @param mapFn - Function to transform blobs from type B1 to type B2\n * @returns A new DataInfo object with transformed blob references\n */\nexport function mapDataInfo<B1, B2>(\n dataInfo: DataInfo<B1>,\n mapFn: (blob: B1) => B2,\n): DataInfo<B2>;\nexport function mapDataInfo<B1, B2>(\n dataInfo: DataInfo<B1> | undefined,\n mapFn: (blob: B1) => B2,\n): DataInfo<B2> | undefined {\n if (dataInfo === undefined) {\n return undefined;\n }\n\n switch (dataInfo.type) {\n case 'Json':\n // Json type doesn't contain blobs, so return as is\n return dataInfo;\n case 'JsonPartitioned': {\n // Map each blob in parts\n const newParts: Record<string, B2> = {};\n for (const [key, blob] of Object.entries(dataInfo.parts)) {\n newParts[key] = mapFn(blob);\n }\n return {\n ...dataInfo,\n parts: newParts,\n };\n }\n case 'BinaryPartitioned': {\n // Map each index and values blob in parts\n const newParts: Record<string, BinaryChunk<B2>> = {};\n for (const [key, chunk] of Object.entries(dataInfo.parts)) {\n newParts[key] = {\n index: mapFn(chunk.index),\n values: mapFn(chunk.values),\n };\n }\n return {\n ...dataInfo,\n parts: newParts,\n };\n }\n }\n}\n\n/**\n * @param dataInfo - The source DataInfo object\n * @param cb - Callback, function that have access to every blob to visit them all\n * @returns Nothing\n */\nexport function visitDataInfo<B>(\n dataInfo: DataInfo<B>,\n cb: (blob: B) => void,\n): void {\n switch (dataInfo.type) {\n case 'Json':\n // Json type doesn't contain blobs, so return as is\n break;\n case 'JsonPartitioned': {\n // Visit each blob in parts\n for (const [_, blob] of Object.entries(dataInfo.parts)) {\n cb(blob);\n }\n break;\n }\n case 'BinaryPartitioned': {\n // Visit each index and values blob in parts\n for (const [_, chunk] of Object.entries(dataInfo.parts)) {\n cb(chunk.index);\n cb(chunk.values);\n }\n break;\n }\n }\n}\n\n//\n// Lightway representation for ExplicitJsonData\n//\n\n/**\n * Represents a single key-value entry in a column's explicit data structure.\n * Used when directly instantiating PColumns with explicit data.\n */\nexport type PColumnValuesEntry = {\n key: PColumnKey;\n val: PColumnValue;\n};\n\n/**\n * Array of key-value entries representing explicit column data.\n * Used for lightweight explicit instantiation of PColumns.\n */\nexport type PColumnValues = PColumnValuesEntry[];\n\n/**\n * Entry-based representation of JsonDataInfo\n */\nexport interface JsonDataInfoEntries {\n type: 'Json';\n keyLength: number;\n data: PColumnDataEntry<PColumnValue>[];\n}\n\n/**\n * Entry-based representation of JsonPartitionedDataInfo\n */\nexport interface JsonPartitionedDataInfoEntries<Blob> {\n type: 'JsonPartitioned';\n partitionKeyLength: number;\n parts: PColumnDataEntry<Blob>[];\n}\n\n/**\n * Entry-based representation of BinaryPartitionedDataInfo\n */\nexport interface BinaryPartitionedDataInfoEntries<Blob> {\n type: 'BinaryPartitioned';\n partitionKeyLength: number;\n parts: PColumnDataEntry<BinaryChunk<Blob>>[];\n}\n\n/**\n * Union type representing all possible entry-based partitioned data storage formats\n */\nexport type PartitionedDataInfoEntries<Blob> =\n | JsonPartitionedDataInfoEntries<Blob>\n | BinaryPartitionedDataInfoEntries<Blob>;\n\n/**\n * Union type representing all possible entry-based data storage formats\n */\nexport type DataInfoEntries<Blob> =\n | JsonDataInfoEntries\n | PartitionedDataInfoEntries<Blob>;\n\n/**\n * Type guard function that checks if the given value is a valid DataInfoEntries.\n *\n * @param value - The value to check\n * @returns True if the value is a valid DataInfoEntries, false otherwise\n */\nexport function isDataInfoEntries<Blob>(value: unknown): value is DataInfoEntries<Blob> {\n if (!value || typeof value !== 'object') {\n return false;\n }\n\n const data = value as Record<string, unknown>;\n if (!('type' in data)) {\n return false;\n }\n\n switch (data.type) {\n case 'Json':\n return (\n typeof data.keyLength === 'number'\n && Array.isArray(data.data)\n );\n case 'JsonPartitioned':\n return (\n typeof data.partitionKeyLength === 'number'\n && Array.isArray(data.parts)\n );\n case 'BinaryPartitioned':\n return (\n typeof data.partitionKeyLength === 'number'\n && Array.isArray(data.parts)\n );\n default:\n return false;\n }\n}\n\n/**\n * Type guard function that checks if the given value is a valid PartitionedDataInfoEntries.\n *\n * @template Blob - Type parameter representing the storage reference type\n * @param value - The value to check\n * @returns True if the value is a valid PartitionedDataInfoEntries, false otherwise\n */\nexport function isPartitionedDataInfoEntries<Blob>(value: unknown): value is PartitionedDataInfoEntries<Blob> {\n if (!isDataInfoEntries(value)) return false;\n return value.type === 'JsonPartitioned' || value.type === 'BinaryPartitioned';\n}\n\n/**\n * Converts DataInfo to DataInfoEntries\n *\n * @param dataInfo - The record-based DataInfo object\n * @returns The equivalent entry-based DataInfoEntries object\n */\nexport function dataInfoToEntries<Blob>(dataInfo: DataInfo<Blob>): DataInfoEntries<Blob> {\n switch (dataInfo.type) {\n case 'Json': {\n const entries: PColumnDataEntry<PColumnValue>[] = Object.entries(dataInfo.data).map(([keyStr, value]) => {\n const key = JSON.parse(keyStr) as PColumnKey;\n return { key, value };\n });\n\n return {\n type: 'Json',\n keyLength: dataInfo.keyLength,\n data: entries,\n };\n }\n case 'JsonPartitioned': {\n const parts: PColumnDataEntry<Blob>[] = Object.entries(dataInfo.parts).map(([keyStr, blob]) => {\n const key = JSON.parse(keyStr) as PColumnKey;\n return { key, value: blob };\n });\n\n return {\n type: 'JsonPartitioned',\n partitionKeyLength: dataInfo.partitionKeyLength,\n parts,\n };\n }\n case 'BinaryPartitioned': {\n const parts: PColumnDataEntry<BinaryChunk<Blob>>[] = Object.entries(dataInfo.parts).map(([keyStr, chunk]) => {\n const key = JSON.parse(keyStr) as PColumnKey;\n return { key, value: chunk };\n });\n\n return {\n type: 'BinaryPartitioned',\n partitionKeyLength: dataInfo.partitionKeyLength,\n parts,\n };\n }\n }\n}\n\n/**\n * Converts DataInfoEntries to DataInfo\n *\n * @param dataInfoEntries - The entry-based DataInfoEntries object\n * @returns The equivalent record-based DataInfo object\n */\nexport function entriesToDataInfo<Blob>(dataInfoEntries: DataInfoEntries<Blob>): DataInfo<Blob> {\n switch (dataInfoEntries.type) {\n case 'Json': {\n const data: Record<string, PColumnValue> = {};\n for (const entry of dataInfoEntries.data) {\n data[JSON.stringify(entry.key)] = entry.value;\n }\n\n return {\n type: 'Json',\n keyLength: dataInfoEntries.keyLength,\n data,\n };\n }\n case 'JsonPartitioned': {\n const parts: Record<string, Blob> = {};\n for (const entry of dataInfoEntries.parts) {\n parts[JSON.stringify(entry.key)] = entry.value;\n }\n\n return {\n type: 'JsonPartitioned',\n partitionKeyLength: dataInfoEntries.partitionKeyLength,\n parts,\n };\n }\n case 'BinaryPartitioned': {\n const parts: Record<string, BinaryChunk<Blob>> = {};\n for (const entry of dataInfoEntries.parts) {\n parts[JSON.stringify(entry.key)] = entry.value;\n }\n\n return {\n type: 'BinaryPartitioned',\n partitionKeyLength: dataInfoEntries.partitionKeyLength,\n parts,\n };\n }\n }\n}\n\n/**\n * Maps blob references in a DataInfoEntries object from one type to another using a mapping function.\n *\n * @template B1 - Source blob type\n * @template B2 - Target blob type\n * @param dataInfoEntries - The source DataInfoEntries object\n * @param mapFn - Function to transform blobs from type B1 to type B2\n * @returns A new DataInfoEntries object with transformed blob references\n */\nexport function mapDataInfoEntries<B1, B2>(\n dataInfoEntries: DataInfoEntries<B1>,\n mapFn: (blob: B1) => B2,\n): DataInfoEntries<B2>;\nexport function mapDataInfoEntries<B1, B2>(\n dataInfoEntries: DataInfoEntries<B1> | undefined,\n mapFn: (blob: B1) => B2,\n): DataInfoEntries<B2> | undefined {\n if (dataInfoEntries === undefined) {\n return undefined;\n }\n\n switch (dataInfoEntries.type) {\n case 'Json':\n // Json type doesn't contain blobs, so return as is\n return dataInfoEntries;\n case 'JsonPartitioned': {\n // Map each blob in parts\n const newParts = dataInfoEntries.parts.map((entry) => ({\n key: entry.key,\n value: mapFn(entry.value),\n }));\n\n return {\n ...dataInfoEntries,\n parts: newParts,\n };\n }\n case 'BinaryPartitioned': {\n // Map each index and values blob in parts\n const newParts = dataInfoEntries.parts.map((entry) => ({\n key: entry.key,\n value: {\n index: mapFn(entry.value.index),\n values: mapFn(entry.value.values),\n },\n }));\n\n return {\n ...dataInfoEntries,\n parts: newParts,\n };\n }\n }\n}\n","import type { ValueType } from './spec/spec';\n\nexport const PValueIntNA = -2147483648;\nexport const PValueLongNA = -9007199254740991n;\nexport const PValueFloatNA = NaN; // do not change, isNaN is used in other cases\nexport const PValueDoubleNA = NaN; // do not change, isNaN is used in other cases\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 // Doesn't differ from PValueInt, TODO: branded types for these PValue* types?\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 Number.isNaN(value);\n case 'Double':\n return Number.isNaN(value);\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 PTableAbsent = { type: 'absent' } as const;\nexport type PTableAbsent = typeof PTableAbsent;\nexport const PTableNA = null;\nexport type PTableNA = typeof PTableNA;\n\n/** Decoded PTable value */\nexport type PTableValue = PTableAbsent | PTableNA | number | string;\n\n/** Type guard for absent PValue */\nexport function isPTableAbsent(value: PTableValue): value is PTableAbsent {\n return typeof value === 'object' && value !== null && value.type === 'absent';\n}\n\nexport type AbsentAndNAFill = {\n na?: PTableValue;\n absent?: PTableValue;\n};\n\n/** Read PTableValue from PTable column at specified row */\nexport function pTableValue(\n column: PTableVector,\n row: number,\n fill: AbsentAndNAFill = {},\n): PTableValue {\n if (isValueAbsent(column.absent, row))\n return fill.absent === undefined ? PTableAbsent : fill.absent;\n\n const value = column.data[row];\n const valueType = column.type;\n if (isValueNA(value, valueType)) return fill.na === undefined ? PTableNA : fill.na;\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 type { PObject, PObjectId, PObjectSpec } from '../../../pool';\nimport canonicalize from 'canonicalize';\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 PUniversalColumnSpec 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: string;\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\n/**\n * Specification of a data column.\n *\n * Data column is a specialized type of PColumn that stores only simple values (strings and numbers)\n * addressed by multiple keys. This is in contrast to other PColumn variants that can store more complex\n * values like files or other abstract data types. Data columns are optimized for storing and processing\n * basic tabular data.\n */\nexport interface PDataColumnSpec extends PUniversalColumnSpec {\n /** Type of column values */\n readonly valueType: ValueType;\n}\n\n// @todo: change this to PUniversalColumnSpec\nexport type PColumnSpec = PDataColumnSpec;\n\n/** Unique PColumnSpec identifier */\nexport type PColumnSpecId = {\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 /** A list of zero-based indices of parent axes from the {@link axesSpec} array. */\n readonly parentAxes?: number[];\n\n /** Axes id */\n readonly axesId: AxesId;\n};\n\nexport function getPColumnSpecId(spec: PColumnSpec): PColumnSpecId {\n return {\n kind: spec.kind,\n valueType: spec.valueType,\n name: spec.name,\n domain: spec.domain,\n parentAxes: spec.parentAxes,\n axesId: getAxesId(spec.axesSpec),\n };\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/** Get column id and spec from a column */\nexport function getColumnIdAndSpec<Data>(column: PColumn<Data>): PColumnIdAndSpec {\n return {\n columnId: column.id,\n spec: column.spec,\n };\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 const result = { type, name };\n if (domain && Object.entries(domain).length > 0) {\n Object.assign(result, { domain });\n }\n return result;\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/**\n * Canonicalizes axis id\n * @deprecated Use {@link canonicalizeJson} instead to preserve type\n */\nexport function canonicalizeAxisId(id: AxisId): string {\n return canonicalize(getAxisId(id))!;\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 type { PTableColumnId, PTableColumnSpec } from './table_common';\nimport type { PTableVector } from './data_types';\nimport type { PObjectId } from '../../pool';\nimport { assertNever } from '../../util';\nimport type { PColumn } from './spec/spec';\nimport type { PColumnValues } from './data_info';\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 * Axis filter slicing target axis from column axes.\n * If the axis has parents or is a parent, slicing cannot be applied (an error will be thrown).\n * */\nexport interface ConstantAxisFilter {\n /** Filter type discriminator */\n readonly type: 'constant';\n\n /** Index of axis to slice (zero-based) */\n readonly axisIndex: number;\n\n /** Equality filter reference value, see {@link SingleValueEqualPredicate} */\n readonly constant: string | number;\n}\n\n/** Defines a terminal column node in the join request tree */\nexport interface SlicedColumnJoinEntry<Col> {\n /** Node type discriminator */\n readonly type: 'slicedColumn';\n\n /** Local column */\n readonly column: Col;\n\n /** New column id */\n readonly newId: PObjectId;\n\n /** Non-empty list of axis filters */\n readonly axisFilters: ConstantAxisFilter[];\n}\n\n/** Defines a terminal column node in the join request tree */\nexport interface InlineColumnJoinEntry {\n /** Node type discriminator */\n readonly type: 'inlineColumn';\n\n /** Column definition */\n readonly column: PColumn<PColumnValues>;\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 | SlicedColumnJoinEntry<Col>\n | InlineColumnJoinEntry\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 SingleValueInSetPredicate {\n /** Comparison operator */\n readonly operator: 'InSet';\n\n /** Reference values, NA values will not match */\n readonly references: (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 | SingleValueInSetPredicate\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 /** Partition filters */\n readonly partitionFilters: PTableRecordFilter[];\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> = {\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/** 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 'slicedColumn':\n return {\n type: 'slicedColumn',\n column: cb(entry.column),\n newId: entry.newId,\n axisFilters: entry.axisFilters,\n };\n case 'inlineColumn':\n return entry;\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","import type { PObjectId } from '../../pool';\nimport type { AxisId, AxisSpec, PColumnSpec } from './spec/spec';\n\nexport type PTableColumnSpecAxis = {\n type: 'axis';\n id: AxisId;\n spec: AxisSpec;\n};\n\nexport type PTableColumnSpecColumn = {\n type: 'column';\n id: PObjectId;\n spec: PColumnSpec;\n};\n\n/** Unified spec object for axes and columns */\nexport type PTableColumnSpec = PTableColumnSpecAxis | PTableColumnSpecColumn;\n\nexport type PTableColumnIdAxis = {\n type: 'axis';\n id: AxisId;\n};\n\nexport type PTableColumnIdColumn = {\n type: 'column';\n id: PObjectId;\n};\n\n/** Unified PTable column identifier */\nexport type PTableColumnId = PTableColumnIdAxis | PTableColumnIdColumn;\n\nexport function getPTableColumnId(spec: PTableColumnSpec): PTableColumnId {\n switch (spec.type) {\n case 'axis':\n return {\n type: 'axis',\n id: spec.id,\n };\n case 'column':\n return {\n type: 'column',\n id: spec.id,\n };\n }\n}\n","import type { Branded } from '../../../branding';\nimport type { AnchoredPColumnId } from './selectors';\nimport type { FilteredPColumnId } from './filtered_column';\nimport canonicalize from 'canonicalize';\nimport type { PObjectId } from '../../../pool';\n/**\n * Universal column identifier optionally anchored and optionally filtered.\n */\nexport type UniversalPColumnId = AnchoredPColumnId | FilteredPColumnId;\n\n/**\n * Canonically serialized {@link UniversalPColumnId}.\n */\nexport type SUniversalPColumnId = Branded<PObjectId, 'SUniversalPColumnId', '__pl_model_brand_2__'>;\n\n/**\n * Canonically serializes a {@link UniversalPColumnId} to a string.\n * @param id - The column identifier to serialize\n * @returns The canonically serialized string\n */\nexport function stringifyColumnId(id: UniversalPColumnId): SUniversalPColumnId {\n return canonicalize(id)! as SUniversalPColumnId;\n}\n\n/**\n * Parses a canonically serialized {@link UniversalPColumnId} from a string.\n * @param str - The string to parse\n * @returns The parsed column identifier\n */\nexport function parseColumnId(str: SUniversalPColumnId): UniversalPColumnId {\n return JSON.parse(str) as UniversalPColumnId;\n}\n","import canonicalize from 'canonicalize';\nimport type { PValue } from '../data_types';\nimport type { AxisFilter } from './filtered_column';\nimport type { SUniversalPColumnId, UniversalPColumnId } from './ids';\nimport { stringifyColumnId } from './ids';\nimport type { AAxisSelector, AnchorAxisRef, AnchorAxisRefByIdx, AnchoredPColumnId, AnchoredPColumnSelector, AxisSelector, PColumnSelector } from './selectors';\nimport type { AxisId, PColumnSpec } from './spec';\nimport { getAxisId, matchAxisId } from './spec';\n\n//\n// Helper functions\n//\n\nfunction axisKey(axis: AxisId): string {\n return canonicalize(getAxisId(axis))!;\n}\n\nfunction domainKey(key: string, value: string): string {\n return JSON.stringify([key, value]);\n}\n\n/**\n * Context for resolving and generating anchored references to columns and axes\n * Maintains maps of known domain values and axes that can be referenced by anchors\n */\nexport class AnchoredIdDeriver {\n private readonly domains = new Map<string, string>();\n private readonly axes = new Map<string, AnchorAxisRefByIdx>();\n /**\n * Domain packs are used to group domain keys that can be anchored to the same anchor\n * This is used to optimize the lookup of domain anchors\n */\n private readonly domainPacks: string[][] = [];\n /**\n * Maps domain packs to anchors\n */\n private readonly domainPackToAnchor = new Map<string, string>();\n\n /**\n * Creates a new anchor context from a set of anchor column specifications\n * @param anchors Record of anchor column specifications indexed by anchor ID\n */\n constructor(public readonly anchors: Record<string, PColumnSpec>) {\n const anchorEntries = Object.entries(anchors);\n anchorEntries.sort((a, b) => a[0].localeCompare(b[0]));\n for (const [anchorId, spec] of anchorEntries) {\n for (let axisIdx = 0; axisIdx < spec.axesSpec.length; axisIdx++) {\n const axis = spec.axesSpec[axisIdx];\n const key = axisKey(axis);\n this.axes.set(key, { anchor: anchorId, idx: axisIdx });\n }\n if (spec.domain !== undefined) {\n const domainEntries = Object.entries(spec.domain);\n domainEntries.sort((a, b) => a[0].localeCompare(b[0]));\n\n this.domainPackToAnchor.set(JSON.stringify(domainEntries), anchorId);\n this.domainPacks.push(domainEntries.map(([dKey]) => dKey));\n\n for (const [dKey, dValue] of domainEntries) {\n const key = domainKey(dKey, dValue);\n this.domains.set(key, anchorId);\n }\n }\n }\n }\n\n /**\n * Derives an anchored column identifier from a column specification\n * @param spec Column specification to anchor\n * @returns An anchored column identifier that can be used to identify columns similar to the input specification\n */\n derive(spec: PColumnSpec): AnchoredPColumnId;\n\n /**\n * Derives an anchored column identifier from a column specification\n * @param spec Column specification to anchor\n * @param axisFilters Axis filters to apply to the column\n * @returns An anchored and sliced column identifier that can be used to identify columns similar to the input specification\n */\n derive(spec: PColumnSpec, axisFilters?: AxisFilter[]): UniversalPColumnId;\n\n /**\n * Implementation of derive method\n */\n derive(spec: PColumnSpec, axisFilters?: AxisFilter[]): UniversalPColumnId {\n const result: AnchoredPColumnId = {\n name: spec.name,\n axes: [],\n };\n\n let skipDomains: Set<string> | undefined = undefined;\n if (spec.domain !== undefined) {\n outer:\n for (const domainPack of this.domainPacks) {\n const dAnchor: string[][] = [];\n for (const domainKey of domainPack) {\n const dValue = spec.domain[domainKey];\n if (dValue !== undefined)\n dAnchor.push([domainKey, dValue]);\n else\n break outer;\n }\n const domainAnchor = this.domainPackToAnchor.get(JSON.stringify(dAnchor));\n if (domainAnchor !== undefined) {\n result.domainAnchor = domainAnchor;\n skipDomains = new Set(domainPack);\n break;\n }\n }\n }\n\n for (const [dKey, dValue] of Object.entries(spec.domain ?? {})) {\n if (skipDomains !== undefined && skipDomains.has(dKey))\n continue;\n const key = domainKey(dKey, dValue);\n const anchorId = this.domains.get(key);\n result.domain ??= {};\n result.domain[dKey] = anchorId ? { anchor: anchorId } : dValue;\n }\n\n result.axes = spec.axesSpec.map((axis) => {\n const key = axisKey(axis);\n const anchorAxisRef = this.axes.get(key);\n if (anchorAxisRef === undefined) return getAxisId(axis);\n else return anchorAxisRef;\n });\n\n // If no axis filters are provided, return the anchored ID as is\n if (!axisFilters || axisFilters.length === 0) {\n return result;\n }\n\n // Process axis filters and create a sliced column ID\n const resolvedFilters: [number, PValue][] = [];\n\n for (const filter of axisFilters) {\n const [axisIdOrIndex, value] = filter;\n\n // If it's already a numeric index, validate it\n if (typeof axisIdOrIndex === 'number') {\n if (axisIdOrIndex < 0 || axisIdOrIndex >= spec.axesSpec.length) {\n throw new Error(`Axis index ${axisIdOrIndex} is out of bounds (0-${spec.axesSpec.length - 1})`);\n }\n resolvedFilters.push([axisIdOrIndex, value]);\n } else {\n // If it's a string (axis name), resolve it to an index\n const axisIndex = spec.axesSpec.findIndex((axis) => axis.name === axisIdOrIndex);\n if (axisIndex === -1) {\n throw new Error(`Axis with name \"${axisIdOrIndex}\" not found in the column specification`);\n }\n resolvedFilters.push([axisIndex, value]);\n }\n }\n\n // Sort filters by axis index to ensure consistency\n resolvedFilters.sort((a, b) => a[0] - b[0]);\n\n return {\n source: result,\n axisFilters: resolvedFilters,\n };\n }\n\n /**\n * Derives a canonicalized string representation of an anchored column identifier, can be used as a unique identifier for the column\n * @param spec Column specification to anchor\n * @param axisFilters Optional axis filters to apply to the column\n * @returns A canonicalized string representation of the anchored column identifier\n */\n deriveS(spec: PColumnSpec, axisFilters?: AxisFilter[]): SUniversalPColumnId {\n return stringifyColumnId(this.derive(spec, axisFilters));\n }\n}\n\n/**\n * Options for the resolveAnchors function\n */\nexport type ResolveAnchorsOptions = {\n /**\n * If true, missing domain keys in anchors will be ignored.\n * If false (default), an error will be thrown.\n */\n ignoreMissingDomains?: boolean;\n};\n\n/**\n * Resolves anchored references in a column matcher to create a non-anchored matcher.\n * Doing an opposite operation to {@link AnchorIdDeriver.derive()}.\n *\n * @param anchors - Record of anchor column specifications indexed by anchor id\n * @param matcher - An anchored column matcher (or id, which is subtype of it) containing references that need to be resolved\n * @param options - Options for resolving anchors\n * @returns A non-anchored column matcher with all references resolved to actual values\n */\nexport function resolveAnchors(anchors: Record<string, PColumnSpec>, matcher: AnchoredPColumnSelector, options?: ResolveAnchorsOptions): PColumnSelector {\n const result = { ...matcher };\n const ignoreMissingDomains = options?.ignoreMissingDomains ?? false;\n\n if (result.domainAnchor !== undefined) {\n const anchorSpec = anchors[result.domainAnchor];\n if (!anchorSpec)\n throw new Error(`Anchor \"${result.domainAnchor}\" not found`);\n\n const anchorDomains = anchorSpec.domain || {};\n result.domain = { ...anchorDomains, ...result.domain };\n delete result.domainAnchor;\n }\n\n if (result.domain) {\n const resolvedDomain: Record<string, string> = {};\n for (const [key, value] of Object.entries(result.domain)) {\n if (typeof value === 'string') {\n resolvedDomain[key] = value;\n } else {\n // It's an AnchorDomainRef\n const anchorSpec = anchors[value.anchor];\n if (!anchorSpec)\n throw new Error(`Anchor \"${value.anchor}\" not found for domain key \"${key}\"`);\n\n if (!anchorSpec.domain || anchorSpec.domain[key] === undefined) {\n if (!ignoreMissingDomains)\n throw new Error(`Domain key \"${key}\" not found in anchor \"${value.anchor}\"`);\n continue;\n }\n\n resolvedDomain[key] = anchorSpec.domain[key];\n }\n }\n result.domain = resolvedDomain;\n }\n\n if (result.axes)\n result.axes = result.axes.map((axis) => resolveAxisReference(anchors, axis));\n\n return result as PColumnSelector;\n}\n\n/**\n * Resolves an anchored axis reference to a concrete AxisId\n */\nfunction resolveAxisReference(anchors: Record<string, PColumnSpec>, axisRef: AAxisSelector): AxisSelector {\n if (!isAnchorAxisRef(axisRef))\n return axisRef;\n\n // It's an anchored reference\n const anchorId = axisRef.anchor;\n const anchorSpec = anchors[anchorId];\n if (!anchorSpec)\n throw new Error(`Anchor \"${anchorId}\" not found for axis reference`);\n\n if ('idx' in axisRef) {\n // AnchorAxisRefByIdx\n if (axisRef.idx < 0 || axisRef.idx >= anchorSpec.axesSpec.length)\n throw new Error(`Axis index ${axisRef.idx} out of bounds for anchor \"${anchorId}\"`);\n return anchorSpec.axesSpec[axisRef.idx];\n } else if ('name' in axisRef) {\n // AnchorAxisRefByName\n const matches = anchorSpec.axesSpec.filter((axis) => axis.name === axisRef.name);\n if (matches.length > 1)\n throw new Error(`Multiple axes with name \"${axisRef.name}\" found in anchor \"${anchorId}\"`);\n if (matches.length === 0)\n throw new Error(`Axis with name \"${axisRef.name}\" not found in anchor \"${anchorId}\"`);\n return matches[0];\n } else if ('id' in axisRef) {\n // AnchorAxisRefByMatcher\n const matches = anchorSpec.axesSpec.filter((axis) => matchAxisId(axisRef.id, getAxisId(axis)));\n if (matches.length > 1)\n throw new Error(`Multiple matching axes found for matcher in anchor \"${anchorId}\"`);\n if (matches.length === 0)\n throw new Error(`No matching axis found for matcher in anchor \"${anchorId}\"`);\n return matches[0];\n }\n\n throw new Error(`Unsupported axis reference type`);\n}\n\n/**\n * Type guard to check if a value is an anchored axis reference\n */\nfunction isAnchorAxisRef(value: AAxisSelector): value is AnchorAxisRef {\n return typeof value === 'object' && 'anchor' in value;\n}\n","import type { Branded } from '../branding';\nimport type { JoinEntry, PColumn, PColumnSpec } from '../drivers';\nimport { assertNever } from '../util';\nimport type { 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 /** Name is common part of PObject identity */\n readonly name: string;\n\n /** Domain is a set of key-value pairs that can be used to identify the object */\n readonly domain?: Record<string, 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 'slicedColumn':\n columns.set(entry.column.id, entry.column);\n return;\n case 'inlineColumn':\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 { isPColumnSpec, type PObjectSpec } from '../../../pool';\nimport type { AxisId, PColumnSpec, ValueType } from './spec';\nimport { getAxisId } from './spec';\n\n/**\n * Defines a pattern for matching axes within the PFrame data model.\n *\n * AxisSelector provides a flexible way to identify axes based on their\n * properties. All fields are optional, allowing for partial matching.\n * When multiple properties are specified, all must match for an axis\n * to be selected (logical AND).\n *\n * This interface is used in various selection and matching operations\n * throughout the PFrame system, such as column queries and axis lookups.\n */\nexport interface AxisSelector {\n /**\n * Optional value type to match against.\n * When specified, only axes with this exact type will match.\n * Can be a single type or an array of types to match against any of them.\n * Valid types include: 'Int', 'Long', 'Float', 'Double', 'String', 'Bytes'.\n */\n type?: ValueType | ValueType[];\n\n /**\n * Optional name to match against.\n * When specified, only axes with this exact name will match.\n */\n name?: string;\n\n /**\n * Optional domain key-value pairs to match against.\n * Domains provide additional context to uniquely identify an axis beyond its name and type.\n * When specified, an axis will match only if it contains all the key-value pairs defined here.\n * An axis with additional domain entries not present in this selector will still match.\n */\n domain?: Record<string, string>;\n}\n\n/**\n * Reference to an axis by its numerical index within the anchor column's axes array\n * Format: [anchorId, axisIndex]\n */\nexport type AnchorAxisRefByIdx = { anchor: string; idx: number };\n\n/**\n * Reference to an axis by its name within the anchor column\n * Format: [anchorId, axisName]\n */\nexport type AnchorAxisRefByName = { anchor: string; name: string };\n\n/**\n * Reference to an axis using an AxisId matcher within the anchor\n * Format: [anchorId, axisMatcher]\n */\nexport type AnchorAxisRefByMatcher = { anchor: string; id: AxisId };\n\n/**\n * Basic anchor axis reference that can be either by index or a direct AxisId\n */\nexport type AnchorAxisIdOrRefBasic = AnchorAxisRefByIdx | AxisId;\n\n/** Union of all possible ways to reference an axis in an anchored context */\nexport type AnchorAxisRef = AnchorAxisRefByIdx | AnchorAxisRefByName | AnchorAxisRefByMatcher;\n\n/** Reference to a domain value through an anchor */\nexport type AnchorDomainRef = { anchor: string };\n\n/**\n * Domain value that can be either a direct string value or a reference to a domain through an anchor\n * Used to establish domain context that can be resolved relative to other anchored columns\n */\nexport type ADomain = string | AnchorDomainRef;\n/**\n * Axis identifier that can be either a direct AxisId or a reference to an axis through an anchor\n * Allows referring to axes in a way that can be resolved in different contexts\n */\nexport type AAxisSelector = AxisSelector | AnchorAxisRef;\n\n/**\n * Match resolution strategy for PColumns\n * Specifies how to handle when multiple columns match the criteria\n * (default is \"expectSingle\")\n */\nexport type AnchoredColumnMatchStrategy = 'expectSingle' | 'expectMultiple' | 'takeFirst';\n\n/**\n * Matcher for PColumns in an anchored context\n * Supports partial matching on axes, allowing for flexible column discovery\n */\nexport interface AnchoredPColumnSelector {\n /** Optional name of the column to match; can't be used together with namePattern */\n name?: string;\n /** Optional regexp pattern for column name matching; can't be used together with name */\n namePattern?: string;\n /** Optional value type to match. If an array is provided, matches if the column's type is any of the specified types */\n type?: ValueType | ValueType[];\n /** If specified, the domain values must be anchored to this anchor */\n domainAnchor?: string;\n /** Optional domain values to match, can include anchored references, if domainAnchor is specified,\n * interpreted as additional domains to domain from the anchor */\n domain?: Record<string, ADomain>;\n /** Optional axes to match, can include anchored references */\n axes?: AAxisSelector[];\n /** When true, allows matching if only a subset of axes match */\n partialAxesMatch?: boolean;\n /** Optional annotations to match with exact values */\n annotations?: Record<string, string>;\n /** Optional annotation patterns to match with regex patterns */\n annotationPatterns?: Record<string, string>;\n /** Match resolution strategy, default is \"expectSingle\" */\n matchStrategy?: AnchoredColumnMatchStrategy;\n}\n\n/**\n * Matcher for PColumns in a non-anchored context\n */\nexport interface PColumnSelector extends AnchoredPColumnSelector {\n domainAnchor?: never;\n domain?: Record<string, string>;\n axes?: AxisSelector[];\n}\n\n/**\n * Strict identifier for PColumns in an anchored context\n * Unlike APColumnMatcher, this requires exact matches on domain and axes\n */\nexport interface AnchoredPColumnId extends AnchoredPColumnSelector {\n /** Name is required for exact column identification */\n name: string;\n /** No namePattern in ID */\n namePattern?: never;\n /** Type is not used in exact column identification */\n type?: never;\n /** Full axes specification using only basic references */\n axes: AnchorAxisIdOrRefBasic[];\n /** Partial axes matching is not allowed for exact identification */\n partialAxesMatch?: never;\n /** Annotations are not used in exact column identification */\n annotations?: never;\n /** Annotation patterns are not used in exact column identification */\n annotationPatterns?: never;\n /** \"Id\" implies single match strategy */\n matchStrategy?: never;\n}\n\n/**\n * Determines if an axis ID matches an axis selector.\n *\n * @param selector - The selector with criteria to match against\n * @param axis - The AxisId to check against the selector\n * @returns true if the AxisId matches all specified criteria in the selector, false otherwise\n */\nexport function matchAxis(selector: AxisSelector, axis: AxisId): boolean {\n // Match name if specified\n if (selector.name !== undefined && selector.name !== axis.name)\n return false;\n\n // Match type if specified\n if (selector.type !== undefined) {\n if (Array.isArray(selector.type)) {\n if (!selector.type.includes(axis.type))\n return false;\n } else if (selector.type !== axis.type) {\n return false;\n }\n }\n\n // Match domain if specified - using existing logic from matchAxisId\n if (selector.domain !== undefined) {\n const axisDomain = axis.domain || {};\n for (const [key, value] of Object.entries(selector.domain))\n if (axisDomain[key] !== value)\n return false;\n }\n\n return true;\n}\n\n/**\n * Determines if a given PColumnSpec matches a selector.\n *\n * @param pcolumn - The PColumnSpec to check against the selector\n * @param selector - The selector criteria to match against\n * @returns true if the PColumnSpec matches all criteria in the selector, false otherwise\n */\nexport function matchPColumn(pcolumn: PColumnSpec, selector: PColumnSelector): boolean {\n // Match name if specified\n if (selector.name !== undefined && pcolumn.name !== selector.name)\n return false;\n\n // Match name pattern if specified\n if (selector.namePattern !== undefined && !new RegExp(selector.namePattern).test(pcolumn.name))\n return false;\n\n // Match type if specified\n if (selector.type !== undefined) {\n if (Array.isArray(selector.type)) {\n if (!selector.type.includes(pcolumn.valueType))\n return false;\n } else if (selector.type !== pcolumn.valueType) {\n return false;\n }\n }\n\n // Match domain if specified\n if (selector.domain !== undefined) {\n const columnDomain = pcolumn.domain || {};\n for (const [key, value] of Object.entries(selector.domain))\n if (columnDomain[key] !== value)\n return false;\n }\n\n // Match axes if specified\n if (selector.axes !== undefined) {\n const pcolumnAxes = pcolumn.axesSpec.map(getAxisId);\n\n if (selector.partialAxesMatch) {\n // For partial matching, all selector axes must match at least one column axis\n for (const selectorAxis of selector.axes)\n if (!pcolumnAxes.some((columnAxis) => matchAxis(selectorAxis, columnAxis)))\n return false;\n } else {\n // For exact matching, column must have the same number of axes and all must match\n if (pcolumnAxes.length !== selector.axes.length)\n return false;\n\n // Each selector axis must match a corresponding column axis\n for (let i = 0; i < selector.axes.length; i++)\n if (!matchAxis(selector.axes[i], pcolumnAxes[i]))\n return false;\n }\n }\n\n // Match annotations if specified\n if (selector.annotations !== undefined) {\n const columnAnnotations = pcolumn.annotations || {};\n for (const [key, value] of Object.entries(selector.annotations))\n if (columnAnnotations[key] !== value)\n return false;\n }\n\n // Match annotation patterns if specified\n if (selector.annotationPatterns !== undefined) {\n const columnAnnotations = pcolumn.annotations || {};\n for (const [key, pattern] of Object.entries(selector.annotationPatterns)) {\n const value = columnAnnotations[key];\n if (value === undefined || !new RegExp(pattern).test(value))\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Convert a predicate or array of selectors to a single predicate function\n * @param predicateOrSelectors - Either a function that takes a PColumnSpec and returns a boolean,\n * or an array of PColumnSelectors, or a single PColumnSelector\n * @returns A function that takes a PColumnSpec and returns a boolean\n */\nexport function selectorsToPredicate(predicateOrSelectors: PColumnSelector | PColumnSelector[]): ((spec: PObjectSpec) => boolean) {\n if (Array.isArray(predicateOrSelectors))\n return (spec) => predicateOrSelectors.some((selector) => isPColumnSpec(spec) && matchPColumn(spec, selector));\n else\n return (spec) => isPColumnSpec(spec) && matchPColumn(spec, predicateOrSelectors);\n}\n","import type { Branded } from '../../../branding';\nimport { isPColumnSpec, type PObjectSpec } from '../../../pool';\nimport { getAxesId } from './spec';\nimport canonicalize from 'canonicalize';\nexport type NativePObjectId = Branded<string, 'NativePObjectId'>;\n\nexport function deriveNativeId(spec: PObjectSpec): NativePObjectId {\n const result: Record<string, unknown> = {\n kind: spec.kind,\n name: spec.name,\n };\n if (spec.domain !== undefined)\n result.domain = spec.domain;\n if (isPColumnSpec(spec))\n result.axesSpec = getAxesId(spec.axesSpec);\n return canonicalize(result) as NativePObjectId;\n}\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()\n .describe('Upstream block id'),\n name: z.string()\n .describe('Name of the output provided to the upstream block\\'s output context'),\n requireEnrichments: z.literal(true).optional()\n .describe('True if current block that stores this reference in its args, may need enrichments '\n + 'for the references value originating from the blocks in between current and referenced block'),\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 .readonly();\nexport type PlRef = z.infer<typeof PlRef>;\n/** @deprecated use {@link PlRef} */\nexport type Ref = PlRef;\n\n/**\n * Type guard to check if a value is a PlRef.\n *\n * @param value - The value to check.\n * @returns True if the value is a PlRef, false otherwise.\n */\nexport function isPlRef(value: unknown): value is PlRef {\n return (\n typeof value === 'object'\n && value !== null\n && '__isRef' in value\n && (value as { __isRef: unknown }).__isRef === true\n && 'blockId' in value\n && 'name' in value\n );\n}\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/**\n * Creates a PlRef with the given blockId and name.\n *\n * @param blockId - The blockId of the reference.\n * @param name - The name of the reference.\n * @param requireEnrichments - Whether the reference requires enrichments.\n */\nexport function createPlRef(blockId: string, name: string, requireEnrichments: boolean = false) {\n if (requireEnrichments)\n return {\n __isRef: true,\n blockId,\n name,\n requireEnrichments: true,\n };\n else\n return {\n __isRef: true,\n blockId,\n name,\n };\n}\n\n/**\n * Creates a new PlRef based on an existing one, explicitly setting (default) or removing the\n * requireEnrichments property.\n *\n * @param ref - The original PlRef object.\n * @param requireEnrichments - If true, the `requireEnrichments: true` property is added\n * to the returned PlRef. If false, the `requireEnrichments` property is removed. Defaults to true.\n * @returns A new PlRef object with the `requireEnrichments` property set or removed accordingly.\n */\nexport function withEnrichments(ref: PlRef, requireEnrichments: boolean = true): PlRef {\n if (requireEnrichments)\n return {\n ...ref,\n requireEnrichments: true,\n };\n else {\n const { requireEnrichments: _, ...rest } = ref;\n return rest;\n }\n}\n\n/** Compare two PlRefs and returns true if they are qual */\nexport function plRefsEqual(ref1: PlRef, ref2: PlRef, ignoreEnrichments: boolean = false) {\n return ref1.blockId === ref2.blockId && ref1.name === ref2.name && (ignoreEnrichments || ref1.requireEnrichments === ref2.requireEnrichments);\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","type Data = Int8Array | Uint8Array | Uint8ClampedArray | ArrayBuffer;\n\nfunction toDataView(data: Data) {\n if (data instanceof Int8Array || data instanceof Uint8Array || data instanceof Uint8ClampedArray)\n return new DataView(data.buffer, data.byteOffset, data.byteLength);\n\n if (data instanceof ArrayBuffer) return new DataView(data);\n\n throw new TypeError(\n 'Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray',\n );\n}\n\ninterface Options {\n /** If set, forcefully enable or disable padding. The default behavior is to follow the default of the selected variant. */\n padding?: boolean;\n}\n\nconst RFC4648 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\nconst RFC4648_HEX = '0123456789ABCDEFGHIJKLMNOPQRSTUV';\nconst CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';\n\nexport function base32Encode(\n data: Data,\n variant: 'RFC3548' | 'RFC4648' | 'RFC4648-HEX' | 'Crockford',\n options?: Options,\n) {\n options = options || {};\n let alphabet, defaultPadding;\n\n switch (variant) {\n case 'RFC3548':\n case 'RFC4648':\n alphabet = RFC4648;\n defaultPadding = true;\n break;\n case 'RFC4648-HEX':\n alphabet = RFC4648_HEX;\n defaultPadding = true;\n break;\n case 'Crockford':\n alphabet = CROCKFORD;\n defaultPadding = false;\n break;\n default:\n throw new Error('Unknown base32 variant: ' + String(variant));\n }\n\n const padding = options.padding !== undefined ? options.padding : defaultPadding;\n const view = toDataView(data);\n\n let bits = 0;\n let value = 0;\n let output = '';\n\n for (let i = 0; i < view.byteLength; i++) {\n value = (value << 8) | view.getUint8(i);\n bits += 8;\n\n while (bits >= 5) {\n output += alphabet[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) output += alphabet[(value << (5 - bits)) & 31];\n\n if (padding)\n while (output.length % 8 !== 0) {\n output += '=';\n }\n\n return output;\n}\n","import { z } from 'zod';\nimport { base32Encode } from './base32_encode';\n\n/** Number of raw bytes in the PlId. */\nexport const PlIdBytes = 15;\n/** Characters in string representation */\nexport const PlIdLength = 24; // = 15 bytes * 8 bits / 5 bits per char in base32\n\nexport const PlId = z\n .string()\n .length(PlIdLength)\n .regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/) // RFC4648\n .brand('PlId');\nexport type PlId = z.infer<typeof PlId>;\n\nexport function uniquePlId(): PlId {\n const data = new Uint8Array(PlIdBytes);\n crypto.getRandomValues(data);\n return PlId.parse(base32Encode(data, 'RFC4648'));\n}\n\nexport function plId(bytes: Uint8Array): PlId {\n if (bytes.length !== PlIdBytes) throw new Error(`Wrong number of bytes: ${bytes.length}`);\n return PlId.parse(base32Encode(bytes, 'RFC4648'));\n}\n\nexport async function digestPlId(data: string): Promise<PlId> {\n const encoder = new TextEncoder();\n const bytes = await crypto.subtle.digest('SHA-256', encoder.encode(data));\n return plId(new Uint8Array(bytes.slice(0, 15)));\n}\n","import canonicalize from 'canonicalize';\n\ntype JsonPrimitive = string | number | boolean | null | undefined;\n\ntype JsonValue = JsonPrimitive | JsonValue[] | {\n [key: string]: JsonValue;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\ntype NotAssignableToJson = bigint | symbol | Function;\n\nexport type JsonCompatible<T> = unknown extends T ? never : {\n [P in keyof T]:\n T[P] extends JsonValue ? T[P] :\n T[P] extends NotAssignableToJson ? never :\n JsonCompatible<T[P]>;\n};\n\nexport type StringifiedJson<T> = JsonCompatible<T> extends never ? never : string & {\n __json_stringified: T;\n};\n\nexport function stringifyJson<T>(value: JsonCompatible<T>): StringifiedJson<T> {\n return JSON.stringify(value)! as StringifiedJson<T>;\n}\n\nexport type CanonicalizedJson<T> = JsonCompatible<T> extends never ? never : string & {\n __json_canonicalized: T;\n};\n\nexport function canonicalizeJson<T>(value: JsonCompatible<T>): CanonicalizedJson<T> {\n return canonicalize(value)! as CanonicalizedJson<T>;\n}\n\nexport function parseJson<T>(value: StringifiedJson<T> | CanonicalizedJson<T>): T {\n return JSON.parse(value) as T;\n}\n","/**\n * Just for convenience, usually it is an Error with name 'AbortError'\n */\nexport class AbortError extends Error {\n name = 'AbortError';\n}\n\n/**\n * Throw this to show a message without stack trace in UI\n */\nexport class UiError extends Error {\n name = 'UiError';\n}\n\nexport function isAbortError(error: unknown): error is Error & { name: 'AbortError' } {\n return error instanceof Error && error.name === 'AbortError';\n}\n\nexport function hasAbortError(error: unknown): boolean {\n if (!(error instanceof Error)) {\n return false;\n }\n\n return error.name === 'AbortError' || hasAbortError(error.cause);\n}\n\nexport function isAggregateError(error: unknown): error is AggregateError {\n return error instanceof Error && error.name === 'AggregateError';\n}\n\nexport class PFrameError extends Error {\n name = 'PFrameError';\n}\n\nexport function isPFrameError(error: unknown): error is PFrameError {\n return error instanceof Error && error.name === 'PFrameError';\n}\n\nexport class PFrameDriverError extends PFrameError {\n name = 'PFrameError.Driver';\n}\n\nexport function isPFrameDriverError(error: unknown): error is PFrameDriverError {\n return error instanceof Error && error.name === 'PFrameError.Driver';\n}\n\nfunction stringifyValue(value: unknown): string {\n if (typeof value === 'string') {\n return `String value was thrown: ${value}`;\n }\n\n if (value && typeof value === 'object') {\n try {\n return `Plain object was thrown: ${JSON.stringify(value)}`;\n } catch (jsonError) {\n const errorMessage = jsonError instanceof Error ? jsonError.message : String(jsonError);\n return `Non-serializable object was thrown (JSON.stringify failed: ${errorMessage}): ${String(value)}`;\n }\n }\n\n return String(`Non-Error value (${typeof value}) was thrown: ${value}`);\n}\n\nexport function ensureError(value: unknown): Error {\n if (value instanceof Error) {\n return value;\n }\n\n return new Error(stringifyValue(value));\n}\n\n// Error serialization for IPC/network transmission (Error objects can't be JSON serialized)\n\nexport type SerializedError = {\n name: string;\n message: string;\n stack: string | undefined;\n cause?: SerializedError;\n};\n\nexport function deserializeError(obj: SerializedError): Error {\n const cause = obj.cause ? deserializeError(obj.cause) : undefined;\n\n const error = new Error(obj.message, cause !== undefined ? { cause } : undefined);\n error.name = obj.name || 'Error';\n error.stack = obj.stack;\n\n return error;\n}\n\nexport function serializeError(e: unknown): SerializedError {\n const error = ensureError(e);\n const cause = error.cause ? serializeError(error.cause) : undefined;\n\n return {\n name: error.name,\n message: error.message,\n stack: error.stack,\n ...(error.cause !== undefined && { cause }),\n };\n}\n\nexport type ResultOrError<S, F = Error> = {\n value: S;\n error?: undefined;\n} | {\n error: F;\n};\n\nexport function unwrapResult<T>(result: ResultOrError<T, Error | SerializedError>): T {\n if (result.error) {\n throw result.error instanceof Error ? result.error : deserializeError(result.error);\n }\n return result.value;\n}\n\nexport function serializeResult<T>(result: ResultOrError<T>): ResultOrError<T, SerializedError> {\n if (result.error) {\n return { error: serializeError(result.error) };\n }\n return { value: result.value };\n}\n\nexport function deserializeResult<T>(result: ResultOrError<T, SerializedError>): ResultOrError<T> {\n if (result.error) {\n return { error: deserializeError(result.error) };\n }\n return { value: result.value };\n}\n\nexport function wrapCallback<T>(callback: () => T): ResultOrError<T> {\n try {\n const value = callback();\n return { value };\n } catch (error) {\n return { error: ensureError(error) };\n }\n}\n\nexport async function wrapAsyncCallback<T>(callback: () => Promise<T>): Promise<ResultOrError<T>> {\n try {\n const value = await callback();\n return { value };\n } catch (error) {\n return { error: ensureError(error) };\n }\n}\n\nexport function wrapAndSerialize<T>(callback: () => T): ResultOrError<T, SerializedError> {\n const result = wrapCallback(callback);\n return serializeResult(result);\n}\n\nexport async function wrapAndSerializeAsync<T>(callback: () => Promise<T>): Promise<ResultOrError<T, SerializedError>> {\n const result = await wrapAsyncCallback(callback);\n return serializeResult(result);\n}\n"],"names":["z","assertNever","x","isDataInfo","value","data","mapDataInfo","dataInfo","mapFn","newParts","key","blob","chunk","isDataInfoEntries","isPartitionedDataInfoEntries","dataInfoToEntries","entries","keyStr","parts","entriesToDataInfo","dataInfoEntries","entry","PValueIntNA","PValueLongNA","PValueStringNA","PValueBytesNA","isValueNA","valueType","isValueAbsent","absent","index","chunkIndex","mask","PTableAbsent","PTableNA","isPTableAbsent","pTableValue","column","row","fill","getAxisId","spec","type","name","domain","result","getAxesId","canonicalizeAxisId","id","canonicalize","matchDomain","query","target","k","matchAxisId","mapPTableDef","def","cb","mapJoinEntry","col","getPTableColumnId","stringifyColumnId","axisKey","axis","domainKey","AnchoredIdDeriver","anchors","__publicField","anchorEntries","a","b","anchorId","axisIdx","domainEntries","dKey","dValue","axisFilters","skipDomains","outer","domainPack","dAnchor","domainAnchor","anchorAxisRef","resolvedFilters","filter","axisIdOrIndex","axisIndex","resolveAnchors","matcher","options","ignoreMissingDomains","anchorSpec","anchorDomains","resolvedDomain","resolveAxisReference","axisRef","isAnchorAxisRef","matches","isPColumnSpec","isPColumn","obj","ensurePColumn","mapPObjectData","pObj","extractAllColumns","columns","addAllColumns","e","matchAxis","selector","axisDomain","matchPColumn","pcolumn","columnDomain","pcolumnAxes","selectorAxis","columnAxis","i","columnAnnotations","pattern","selectorsToPredicate","predicateOrSelectors","deriveNativeId","isPlRef","withEnrichments","ref","requireEnrichments","_","rest","mapValueInVOE","voe","toDataView","RFC4648","RFC4648_HEX","CROCKFORD","base32Encode","variant","alphabet","defaultPadding","padding","view","bits","output","PlIdBytes","PlIdLength","PlId","uniquePlId","canonicalizeJson","parseJson","hasAbortError","error","stringifyValue","jsonError","ensureError","deserializeError","cause","unwrapResult"],"mappings":";;;AAyB0BA,EAAE,OAAO;AAAA;AAAA,EAEjC,MAAMA,EAAE,OAAO;AAAA;AAAA,EAEf,IAAIA,EAAE,OAAO;AACf,CAAC;AC9BM,SAASC,EAAYC,GAAiB;AACrC,QAAA,IAAI,MAAM,wBAAwBA,CAAC;AAC3C;ACsGO,SAASC,EAAiBC,GAAyC;AACpE,MAAA,CAACA,KAAS,OAAOA,KAAU;AACtB,WAAA;AAGT,QAAMC,IAAOD;AACT,MAAA,EAAE,UAAUC;AACP,WAAA;AAGT,UAAQA,EAAK,MAAM;AAAA,IACjB,KAAK;AAED,aAAA,OAAOA,EAAK,aAAc,YACvBA,EAAK,SAAS,UACd,OAAOA,EAAK,QAAS;AAAA,IAE5B,KAAK;AAED,aAAA,OAAOA,EAAK,sBAAuB,YAChCA,EAAK,UAAU,UACf,OAAOA,EAAK,SAAU;AAAA,IAE7B,KAAK;AAED,aAAA,OAAOA,EAAK,sBAAuB,YAChCA,EAAK,UAAU,UACf,OAAOA,EAAK,SAAU;AAAA,IAE7B;AACS,aAAA;AAAA,EAAA;AAEb;AAegB,SAAAC,GACdC,GACAC,GAC0B;AAC1B,MAAID,MAAa;AAIjB,YAAQA,EAAS,MAAM;AAAA,MACrB,KAAK;AAEIA,eAAAA;AAAAA,MACT,KAAK,mBAAmB;AAEtB,cAAME,IAA+B,CAAC;AAC3B,mBAAA,CAACC,GAAKC,CAAI,KAAK,OAAO,QAAQJ,EAAS,KAAK;AAC5CE,UAAAA,EAAAC,CAAG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;AAChB;"}
@@ -24,4 +24,4 @@ const f = /* @__PURE__ */ n({
24
24
  export {
25
25
  f as default
26
26
  };
27
- //# sourceMappingURL=ExpandTransition.vue.js.map
27
+ //# sourceMappingURL=ExpandTransition.vue2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpandTransition.vue2.js","sources":["../../../../../../../../../lib/ui/uikit/src/components/PlAccordion/ExpandTransition.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nconst onStart = (el: Element) => {\n el.classList.add('expand-collapse-fix');\n (el as HTMLElement).style.setProperty('--component-height', el.scrollHeight + 'px');\n};\n\nconst onAfter = (el: Element) => {\n (el as HTMLElement).style.removeProperty('--component-height');\n el.classList.remove('expand-collapse-fix');\n};\n</script>\n\n<template>\n <Transition name=\"expand-collapse\" @enter=\"onStart\" @leave=\"onStart\" @after-enter=\"onAfter\" @after-leave=\"onAfter\">\n <slot/>\n </Transition>\n</template>\n\n<style>\n.expand-collapse-fix {\n overflow: hidden;\n}\n\n.expand-collapse-enter-active,\n.expand-collapse-leave-active {\n transition:\n height 0.2s ease-in-out,\n opacity 0.2s ease-in-out;\n height: var(--component-height);\n}\n\n.expand-collapse-enter-from,\n.expand-collapse-leave-to {\n opacity: 0.5;\n height: 0;\n}\n</style>\n"],"names":["onStart","el","onAfter"],"mappings":";;;;AACMA,UAAAA,IAAU,CAACC,MAAgB;AAC5BA,QAAA,UAAU,IAAI,qBAAqB,GACrCA,EAAmB,MAAM,YAAY,sBAAsBA,EAAG,eAAe,IAAI;AAAA,IAAA,GAG9EC,IAAU,CAACD,MAAgB;AAC9BA,QAAmB,MAAM,eAAe,oBAAoB,GAC1DA,EAAA,UAAU,OAAO,qBAAqB;AAAA,IAC3C;;;;;;;;;;;;;;;"}
@@ -2,7 +2,7 @@ import { defineComponent as x, mergeModels as g, inject as d, toRef as u, useMod
2
2
  import { uniqueId as w } from "../../lib/util/helpers/dist/index.js";
3
3
  import B from "../PlIcon16/PlIcon16.vue.js";
4
4
  import N from "../PlSectionSeparator/PlSectionSeparator.vue.js";
5
- import _ from "./ExpandTransition.vue.js";
5
+ import _ from "./ExpandTransition.vue2.js";
6
6
  (function() {
7
7
  try {
8
8
  if (typeof document < "u") {