@platforma-sdk/model 1.86.5 → 1.88.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/block_api_v3.d.ts +9 -0
- package/dist/block_api_v3.d.ts.map +1 -1
- package/dist/block_model.cjs +89 -9
- package/dist/block_model.cjs.map +1 -1
- package/dist/block_model.d.ts +81 -19
- package/dist/block_model.d.ts.map +1 -1
- package/dist/block_model.js +89 -9
- package/dist/block_model.js.map +1 -1
- package/dist/block_storage_callbacks.cjs +128 -25
- package/dist/block_storage_callbacks.cjs.map +1 -1
- package/dist/block_storage_callbacks.js +129 -26
- package/dist/block_storage_callbacks.js.map +1 -1
- package/dist/block_storage_facade.cjs.map +1 -1
- package/dist/block_storage_facade.d.ts +37 -4
- package/dist/block_storage_facade.d.ts.map +1 -1
- package/dist/block_storage_facade.js.map +1 -1
- package/dist/columns/column_providers/providers.cjs +2 -10
- package/dist/columns/column_providers/providers.cjs.map +1 -1
- package/dist/columns/column_providers/providers.d.ts.map +1 -1
- package/dist/columns/column_providers/providers.js +3 -11
- package/dist/columns/column_providers/providers.js.map +1 -1
- package/dist/columns/column_recipes/index.cjs +2 -2
- package/dist/columns/column_recipes/index.cjs.map +1 -1
- package/dist/columns/column_recipes/index.d.ts +2 -3
- package/dist/columns/column_recipes/index.d.ts.map +1 -1
- package/dist/columns/column_recipes/index.js +2 -2
- package/dist/columns/column_recipes/index.js.map +1 -1
- package/dist/columns/column_values.cjs +126 -0
- package/dist/columns/column_values.cjs.map +1 -0
- package/dist/columns/column_values.d.ts +65 -0
- package/dist/columns/column_values.d.ts.map +1 -0
- package/dist/columns/column_values.js +124 -0
- package/dist/columns/column_values.js.map +1 -0
- package/dist/columns/data_column.cjs +12 -42
- package/dist/columns/data_column.cjs.map +1 -1
- package/dist/columns/data_column.d.ts +10 -26
- package/dist/columns/data_column.d.ts.map +1 -1
- package/dist/columns/data_column.js +13 -42
- package/dist/columns/data_column.js.map +1 -1
- package/dist/columns/index.cjs +4 -1
- package/dist/columns/index.d.ts +3 -2
- package/dist/columns/index.js +3 -2
- package/dist/index.cjs +6 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/pframe_utils/column_value_options.cjs +85 -0
- package/dist/pframe_utils/column_value_options.cjs.map +1 -0
- package/dist/pframe_utils/column_value_options.d.ts +14 -0
- package/dist/pframe_utils/column_value_options.d.ts.map +1 -0
- package/dist/pframe_utils/column_value_options.js +85 -0
- package/dist/pframe_utils/column_value_options.js.map +1 -0
- package/dist/pframe_utils/index.cjs +2 -0
- package/dist/pframe_utils/index.cjs.map +1 -1
- package/dist/pframe_utils/index.d.ts +2 -1
- package/dist/pframe_utils/index.d.ts.map +1 -1
- package/dist/pframe_utils/index.js +2 -1
- package/dist/pframe_utils/index.js.map +1 -1
- package/package.json +7 -7
- package/src/args_issues.test.ts +532 -0
- package/src/block_api_v3.ts +10 -0
- package/src/block_model.ts +146 -32
- package/src/block_storage_callbacks.ts +174 -43
- package/src/block_storage_facade.ts +36 -6
- package/src/columns/column_providers/providers.ts +3 -15
- package/src/columns/column_recipes/column_recipes.test.ts +11 -15
- package/src/columns/column_recipes/index.ts +2 -3
- package/src/columns/column_values.test.ts +183 -0
- package/src/columns/column_values.ts +194 -0
- package/src/columns/data_column.test.ts +13 -14
- package/src/columns/data_column.ts +12 -41
- package/src/columns/index.ts +1 -0
- package/src/pframe_utils/column_value_options.test.ts +126 -0
- package/src/pframe_utils/column_value_options.ts +111 -0
- package/src/pframe_utils/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data_column.js","names":[],"sources":["../../src/columns/data_column.ts"],"sourcesContent":["import {\n ColumnRegistry,\n createGlobalPObjectId,\n isPColumn,\n isPColumnSpec,\n isPlRef,\n PlRef,\n PObjectId,\n type ColumnUniversalId,\n type LeafEntry,\n type PColumn,\n type PColumnSpec,\n type PObjectSpec,\n type SpecOverrides,\n type SpecQuery,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx, PColumnDataUniversal } from \"../render/internal\";\nimport { getCtxProviders } from \"./column_providers\";\nimport { isNil } from \"es-toolkit\";\nimport { LRUCache } from \"lru-cache\";\nimport { TreeNodeAccessor } from \"../render\";\nimport type {\n ColumnFieldStatus,\n ColumnRecipe,\n ColumnRecipeId,\n ColumnResolutionStatus,\n} from \"./column_recipes/types\";\nimport { ColumnOverriddenRecipe } from \"./column_recipes/column_overrided_recipe\";\n\nexport type DataColumnId = PObjectId;\nexport type ColumnData = undefined | PColumnDataUniversal;\nexport type { ColumnFieldStatus, ColumnResolutionStatus } from \"./column_recipes/types\";\n\n/**\n * A {@link ColumnRecipe} that can be read directly in the sandbox: its\n * {@link getData} is guaranteed to be consistent with {@link getSpec}.\n *\n * This is a *capability*, not a class. Only two recipe shapes carry it — a\n * bare leaf and a spec-override over a bare leaf — because those are the only\n * ones whose data still matches their spec. An axis-filtered recipe drops axes\n * from its spec while the underlying data keeps them, and a discovered recipe\n * only materialises after a join; neither can be read here, so neither\n * implements this interface.\n *\n * Narrow to it with `hasReachableData(recipe)` rather than testing for a concrete\n * class — which recipe classes exist is an implementation detail behind\n * `recipe.id`.\n */\nexport interface DataColumnRecipe<\n ID extends ColumnRecipeId = ColumnRecipeId,\n> extends ColumnRecipe<ID> {\n /** Column data, consistent with {@link ColumnRecipe.getSpec}. */\n getData(): ColumnData;\n}\n\n/**\n * Thrown by leaf-recipe factories when the requested column is provably\n * absent in the active render ctx — i.e. every relevant accessor reports\n * `inputsLocked` and the column did not appear. Distinct from the\n * `undefined` return that the factories still use for the \"resolving\" case\n * (the column may still appear later).\n *\n * Catch at the boundary (resolver / filter+sort wiring / data-table assembly)\n * when partial absence should be surfaced to the user rather than silently\n * producing an empty result.\n */\nexport class ColumnAbsentError extends Error {\n constructor(public readonly id: ColumnUniversalId) {\n super(`Column is absent in the active render ctx and will not appear: ${id}`);\n this.name = \"ColumnAbsentError\";\n }\n}\n\n/**\n * The leaf-recipe building block: a {@link DataColumnRecipe} whose `id` is a bare\n * {@link PObjectId} and whose readers are bound to a single tree-accessor\n * leaf. Layered encodings (Overridden / Discovered / Filtered) are reified\n * through their dedicated recipe classes and reference leaf columns by id.\n *\n * Internal — consumers hold the {@link DataColumnRecipe} interface and construct\n * through the {@link DataColumnRecipe} dispatcher.\n */\nexport class DataColumnImpl implements DataColumnRecipe<PObjectId> {\n private specCache?: { readonly value: PColumnSpec };\n private dataCache?: { readonly value: ColumnData };\n private dataStatusCache?: { readonly value: ColumnFieldStatus };\n\n private constructor(\n public readonly id: PObjectId,\n private readonly options: {\n getSpec: () => PColumnSpec;\n getData: () => ColumnData;\n getDataStatus: () => ColumnFieldStatus;\n },\n ) {}\n\n /** A leaf-recipe references exactly one column — its own id. */\n getReferencedIds(): PObjectId[] {\n return [this.id];\n }\n\n getSpec(): PColumnSpec {\n if (this.specCache === undefined) {\n this.specCache = { value: this.options.getSpec() };\n }\n return this.specCache.value;\n }\n\n /** Leaf-shaped — points straight at `this.id`. */\n getQuery(): SpecQuery {\n return { type: \"column\", column: this.id } as SpecQuery;\n }\n\n getData(): ColumnData {\n if (this.dataCache === undefined) this.dataCache = { value: this.options.getData() };\n return this.dataCache.value;\n }\n\n getDataStatus(): ColumnFieldStatus {\n if (this.dataStatusCache === undefined) {\n this.dataStatusCache = { value: this.options.getDataStatus() };\n }\n return this.dataStatusCache.value;\n }\n\n /**\n * Overlay overrides → produces a {@link ColumnOverriddenRecipe} wrapping\n * this leaf. The leaf itself stays bare (id remains a plain PObjectId);\n * layering lives entirely in the recipe wrappers.\n */\n withSpecs(overrides: SpecOverrides): ColumnRecipe {\n return ColumnOverriddenRecipe.wrap(this, overrides);\n }\n\n /**\n * Resolve via the ambient {@link ColumnRegistry}. Spec is resolved eagerly:\n * returns `undefined` if the leaf isn't reachable yet (resolving). Throws\n * {@link ColumnAbsentError} when every relevant accessor is `inputsLocked`\n * and the column did not appear, or when the id names an export that is not\n * a column (a `kind: \"File\"` object, for example) — the column will not\n * exist in this ctx. Data and dataStatus stay lazy.\n */\n static fromId(\n id: PObjectId,\n { ctx }: { ctx?: GlobalCfgRenderCtx } = {},\n ): undefined | DataColumnRecipe<PObjectId> {\n const registry = new ColumnRegistry(getCtxProviders({ ctx }));\n const leaf = registry.resolve(id);\n if (isNil(leaf)) {\n if (registry.isFinal()) throw new ColumnAbsentError(id);\n return undefined;\n }\n return DataColumnImpl.fromAccessor(leaf);\n }\n\n /** {@link PlRef} wrapper over {@link fromId}. */\n static fromPlRef(ref: PlRef): undefined | DataColumnRecipe<PObjectId> {\n return DataColumnImpl.fromId(createGlobalPObjectId(ref.blockId, ref.name));\n }\n\n /**\n * Bind directly to an accessor-backed {@link LeafEntry} — no registry.\n * Throws {@link ColumnAbsentError} if the leaf has no spec field and its\n * accessor is `inputsLocked`, or if it names an export that is not a column.\n * Returns `undefined` while still resolving.\n */\n static fromAccessor(entry: LeafEntry<TreeNodeAccessor>): undefined | DataColumnRecipe<PObjectId> {\n if (isNil(readSpecAccessor(entry))) {\n if (entry.accessor.getInputsLocked()) throw new ColumnAbsentError(entry.id);\n return undefined;\n }\n const spec = readSpec(entry);\n if (spec === undefined) return undefined;\n if (!isPColumnSpec(spec)) throw new ColumnAbsentError(entry.id);\n return new DataColumnImpl(entry.id, {\n getSpec: () => spec,\n getData: () => readDataAccessor(entry),\n getDataStatus: () => readDataStatus(entry),\n });\n }\n\n /**\n * Wrap a materialised {@link PColumn}. If the input is already a\n * {@link DataColumnRecipe} leaf it is returned as-is.\n */\n static fromColumn(\n column: PColumn<ColumnData> | DataColumnRecipe<PObjectId>,\n ): DataColumnRecipe<PObjectId> {\n if (column instanceof DataColumnImpl) return column;\n // `DataColumnRecipe` is an interface, so `instanceof` above does not remove it\n // from the union. The only implementation carrying a bare `PObjectId` is\n // `DataColumnImpl` (wrappers expose `ColumnUniversalId`), so anything\n // reaching here is a materialised `PColumn`.\n const pColumn = column as PColumn<ColumnData>;\n return new DataColumnImpl(pColumn.id, {\n getSpec: () => pColumn.spec,\n getData: () => pColumn.data,\n getDataStatus: () => \"present\",\n });\n }\n\n /**\n * Distinguishes `present` / `resolving` / `absent` for a {@link PObjectId}\n * in the active render ctx. Falls back to the registry's `isFinal()`\n * when the id has no entry — only then we can say `absent` instead of\n * `resolving`. The status tells only whether the spec is readable: for an\n * export that is not a column it is `present`, and the factories throw\n * {@link ColumnAbsentError}.\n */\n static getStatusById(\n id: PObjectId,\n { ctx }: { ctx?: GlobalCfgRenderCtx } = {},\n ): ColumnResolutionStatus {\n const registry = new ColumnRegistry(getCtxProviders({ ctx }));\n const leaf = registry.resolve(id);\n if (isNil(leaf)) return registry.isFinal() ? \"absent\" : \"resolving\";\n return getLeafEntryStatus(leaf);\n }\n\n /** {@link PlRef} wrapper over {@link getStatusById}. */\n static getStatusByPlRef(\n ref: PlRef,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n ): ColumnResolutionStatus {\n return DataColumnImpl.getStatusById(createGlobalPObjectId(ref.blockId, ref.name), opts);\n }\n\n /** No registry — reads straight off the entry's accessor. */\n static getStatusByAccessor(entry: LeafEntry<TreeNodeAccessor>): ColumnResolutionStatus {\n return getLeafEntryStatus(entry);\n }\n}\n\n/** Anything the {@link DataColumnRecipe} dispatcher can build a leaf from. */\nexport type DataColumnSource =\n | PObjectId\n | PlRef\n | LeafEntry<TreeNodeAccessor>\n | PColumn<ColumnData>\n | DataColumnRecipe<PObjectId>;\n\n/**\n * Unified dispatcher — picks the right `DataColumnImpl.fromX` by source\n * shape. For ambiguous inputs callers can still use the explicit factories\n * (also attached as properties: `DataColumn.fromId`, `.fromPlRef`,\n * `.fromAccessor`, `.fromColumn`).\n */\nfunction DataColumnDispatch(\n source: DataColumnSource,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): undefined | DataColumnRecipe<PObjectId> {\n if (typeof source === \"string\") return DataColumnImpl.fromId(source, opts);\n if (source instanceof DataColumnImpl) return source;\n // `DataColumnRecipe` is an interface — `instanceof` above cannot remove it from\n // the union, and only `DataColumnImpl` implements it with a bare id.\n const rest = source as LeafEntry<TreeNodeAccessor> | PlRef | PColumn<ColumnData>;\n if (\"accessor\" in rest) return DataColumnImpl.fromAccessor(rest);\n if (isPlRef(rest)) return DataColumnImpl.fromPlRef(rest);\n if (isPColumn(rest)) return DataColumnImpl.fromColumn(rest);\n throw new Error(\"DataColumn: unknown source shape\");\n}\n\n/**\n * Polymorphic counterpart to {@link DataColumnDispatch}: returns the\n * {@link ColumnResolutionStatus} for any factory input without constructing\n * the recipe. For already-materialised sources ({@link PColumn} value,\n * existing {@link DataColumnRecipe}) status is `present` by construction.\n */\nfunction DataColumnGetStatus(\n source: DataColumnSource,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): ColumnResolutionStatus {\n if (typeof source === \"string\") return DataColumnImpl.getStatusById(source, opts);\n if (source instanceof DataColumnImpl) return \"present\";\n const rest = source as LeafEntry<TreeNodeAccessor> | PlRef | PColumn<ColumnData>;\n if (\"accessor\" in rest) return DataColumnImpl.getStatusByAccessor(rest);\n if (isPlRef(rest)) return DataColumnImpl.getStatusByPlRef(rest, opts);\n if (isPColumn(rest)) return \"present\";\n throw new Error(\"DataColumn.getStatus: unknown source shape\");\n}\n\nexport const DataColumn = Object.assign(DataColumnDispatch, {\n fromId: DataColumnImpl.fromId,\n fromPlRef: DataColumnImpl.fromPlRef,\n fromAccessor: DataColumnImpl.fromAccessor,\n fromColumn: DataColumnImpl.fromColumn,\n getStatus: DataColumnGetStatus,\n getStatusById: DataColumnImpl.getStatusById,\n getStatusByPlRef: DataColumnImpl.getStatusByPlRef,\n getStatusByAccessor: DataColumnImpl.getStatusByAccessor,\n});\n\n/**\n * Type-guard narrowing to a bare leaf — a {@link DataColumnRecipe} whose `id` is a\n * plain {@link PObjectId}.\n */\nexport function isDataColumn(value: unknown): value is DataColumnRecipe<PObjectId> {\n return value instanceof DataColumnImpl;\n}\n\nconst readSpecAccessor = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): undefined | TreeNodeAccessor =>\n accessor.traverse({ field: `${name}.spec`, assertFieldType: \"Input\", ignoreError: true }),\n);\n\n/** The leaf's spec, or `undefined` until the spec resource has data. */\nconst readSpec = memoizeByEntry((entry: LeafEntry<TreeNodeAccessor>): undefined | PObjectSpec => {\n const spec = readSpecAccessor(entry);\n if (isNil(spec) || !spec.hasData()) return undefined;\n return spec.getDataAsJson<PObjectSpec>();\n});\n\n/**\n * Per-entry counterpart to {@link readDataStatus}: tells whether the leaf's\n * **spec** can be read in this ctx, and — for the negative cases —\n * distinguishes `resolving` from `absent` via `getInputsLocked()`.\n *\n * - spec field not yet on the entry's accessor + inputs locked → `absent`\n * - spec field not yet on the entry's accessor + still resolving → `resolving`\n * - spec resource present but bytes not yet written → `resolving`\n * (transient — the spec resource is connected, just unfilled)\n * - spec resource present and `hasData()` → `present`\n */\nfunction getLeafEntryStatus(entry: LeafEntry<TreeNodeAccessor>): ColumnResolutionStatus {\n const spec = readSpecAccessor(entry);\n if (isNil(spec)) return entry.accessor.getInputsLocked() ? \"absent\" : \"resolving\";\n if (!spec.hasData()) return \"resolving\";\n return \"present\";\n}\n\nconst readDataAccessor = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): undefined | TreeNodeAccessor =>\n accessor.traverse({ field: `${name}.data`, assertFieldType: \"Input\", ignoreError: true }),\n);\n\nconst readDataStatus = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): ColumnFieldStatus => {\n if (accessor.listInputFields().includes(`${name}.data`)) return \"present\";\n return accessor.getInputsLocked() ? \"absent\" : \"resolving\";\n },\n);\n\nfunction memoizeByEntry<R>(\n fn: (entry: LeafEntry<TreeNodeAccessor>) => R,\n): (entry: LeafEntry<TreeNodeAccessor>) => R {\n const cache = new LRUCache<string, { value: R }>({ max: 1000 });\n return (entry) => {\n const key = `${entry.accessor.handle}:${entry.name}`;\n let hit =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B,OAA4D;CACtF,MAAM,OAAO,iBAAiB,KAAK;CACnC,IAAI,MAAM,IAAI,GAAG,OAAO,MAAM,SAAS,gBAAgB,IAAI,WAAW;CACtE,IAAI,CAAC,KAAK,QAAQ,GAAG,OAAO;CAC5B,OAAO;AACT;AAEA,MAAM,mBAAmB,gBACtB,EAAE,UAAU,WACX,SAAS,SAAS;CAAE,OAAO,GAAG,KAAK;CAAQ,iBAAiB;CAAS,aAAa;AAAK,CAAC,CAC5F;AAEA,MAAM,iBAAiB,gBACpB,EAAE,UAAU,WAA2D;CACtE,IAAI,SAAS,gBAAgB,CAAC,CAAC,SAAS,GAAG,KAAK,MAAM,GAAG,OAAO;CAChE,OAAO,SAAS,gBAAgB,IAAI,WAAW;AACjD,CACF;AAEA,SAAS,eACP,IAC2C;CAC3C,MAAM,QAAQ,IAAI,SAA+B,EAAE,KAAK,IAAK,CAAC;CAC9D,QAAQ,UAAU;EAChB,MAAM,MAAM,GAAG,MAAM,SAAS,OAAO,GAAG,MAAM;EAC9C,IAAI,MAAM,MAAM,IAAI,GAAG;EACvB,IAAI,CAAC,KAAK,MAAM,IAAI,KAAM,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,CAAE;EACrD,OAAO,IAAI;CACb;AACF"}
|
|
1
|
+
{"version":3,"file":"data_column.js","names":[],"sources":["../../src/columns/data_column.ts"],"sourcesContent":["import {\n ColumnRegistry,\n createGlobalPObjectId,\n isPColumn,\n isPColumnSpec,\n isPlRef,\n PlRef,\n PObjectId,\n type LeafEntry,\n type PColumn,\n type PColumnSpec,\n type PObjectSpec,\n type SpecOverrides,\n type SpecQuery,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx, PColumnDataUniversal } from \"../render/internal\";\nimport { getCtxProviders } from \"./column_providers\";\nimport { isNil } from \"es-toolkit\";\nimport { LRUCache } from \"lru-cache\";\nimport { TreeNodeAccessor } from \"../render\";\nimport type {\n ColumnFieldStatus,\n ColumnRecipe,\n ColumnRecipeId,\n ColumnResolutionStatus,\n} from \"./column_recipes/types\";\nimport { ColumnOverriddenRecipe } from \"./column_recipes/column_overrided_recipe\";\n\nexport type DataColumnId = PObjectId;\nexport type ColumnData = undefined | PColumnDataUniversal;\nexport type { ColumnFieldStatus, ColumnResolutionStatus } from \"./column_recipes/types\";\n\n/**\n * A {@link ColumnRecipe} that can be read directly in the sandbox: its\n * {@link getData} is guaranteed to be consistent with {@link getSpec}.\n *\n * This is a *capability*, not a class. Only two recipe shapes carry it — a\n * bare leaf and a spec-override over a bare leaf — because those are the only\n * ones whose data still matches their spec. An axis-filtered recipe drops axes\n * from its spec while the underlying data keeps them, and a discovered recipe\n * only materialises after a join; neither can be read here, so neither\n * implements this interface.\n *\n * Narrow to it with `hasReachableData(recipe)` rather than testing for a concrete\n * class — which recipe classes exist is an implementation detail behind\n * `recipe.id`.\n */\nexport interface DataColumnRecipe<\n ID extends ColumnRecipeId = ColumnRecipeId,\n> extends ColumnRecipe<ID> {\n /** Column data, consistent with {@link ColumnRecipe.getSpec}. */\n getData(): ColumnData;\n}\n\n/**\n * The leaf-recipe building block: a {@link DataColumnRecipe} whose `id` is a bare\n * {@link PObjectId} and whose readers are bound to a single tree-accessor\n * leaf. Layered encodings (Overridden / Discovered / Filtered) are reified\n * through their dedicated recipe classes and reference leaf columns by id.\n *\n * Internal — consumers hold the {@link DataColumnRecipe} interface and construct\n * through the {@link DataColumnRecipe} dispatcher.\n */\nexport class DataColumnImpl implements DataColumnRecipe<PObjectId> {\n private specCache?: { readonly value: PColumnSpec };\n private dataCache?: { readonly value: ColumnData };\n private dataStatusCache?: { readonly value: ColumnFieldStatus };\n\n private constructor(\n public readonly id: PObjectId,\n private readonly options: {\n getSpec: () => PColumnSpec;\n getData: () => ColumnData;\n getDataStatus: () => ColumnFieldStatus;\n },\n ) {}\n\n /** A leaf-recipe references exactly one column — its own id. */\n getReferencedIds(): PObjectId[] {\n return [this.id];\n }\n\n getSpec(): PColumnSpec {\n if (this.specCache === undefined) {\n this.specCache = { value: this.options.getSpec() };\n }\n return this.specCache.value;\n }\n\n /** Leaf-shaped — points straight at `this.id`. */\n getQuery(): SpecQuery {\n return { type: \"column\", column: this.id } as SpecQuery;\n }\n\n getData(): ColumnData {\n if (this.dataCache === undefined) this.dataCache = { value: this.options.getData() };\n return this.dataCache.value;\n }\n\n getDataStatus(): ColumnFieldStatus {\n if (this.dataStatusCache === undefined) {\n this.dataStatusCache = { value: this.options.getDataStatus() };\n }\n return this.dataStatusCache.value;\n }\n\n /**\n * Overlay overrides → produces a {@link ColumnOverriddenRecipe} wrapping\n * this leaf. The leaf itself stays bare (id remains a plain PObjectId);\n * layering lives entirely in the recipe wrappers.\n */\n withSpecs(overrides: SpecOverrides): ColumnRecipe {\n return ColumnOverriddenRecipe.wrap(this, overrides);\n }\n\n /**\n * Resolve via the ambient {@link ColumnRegistry}. Spec is resolved eagerly:\n * returns `undefined` unless the id names a column whose spec is readable in\n * this ctx — while it is resolving, when it is absent, and when the id names\n * an export that is not a column (a `kind: \"File\"` object, for example).\n * Data and dataStatus stay lazy.\n */\n static fromId(\n id: PObjectId,\n { ctx }: { ctx?: GlobalCfgRenderCtx } = {},\n ): undefined | DataColumnRecipe<PObjectId> {\n const leaf = new ColumnRegistry(getCtxProviders({ ctx })).resolve(id);\n if (isNil(leaf)) return undefined;\n return DataColumnImpl.fromAccessor(leaf);\n }\n\n /** {@link PlRef} wrapper over {@link fromId}. */\n static fromPlRef(ref: PlRef): undefined | DataColumnRecipe<PObjectId> {\n return DataColumnImpl.fromId(createGlobalPObjectId(ref.blockId, ref.name));\n }\n\n /**\n * Bind directly to an accessor-backed {@link LeafEntry} — no registry.\n * Returns `undefined` unless the leaf's spec is readable and is a column\n * spec: while the spec is resolving, when it is absent, and for an export\n * that is not a column.\n */\n static fromAccessor(entry: LeafEntry<TreeNodeAccessor>): undefined | DataColumnRecipe<PObjectId> {\n const spec = readSpec(entry);\n if (spec === undefined || !isPColumnSpec(spec)) return undefined;\n return new DataColumnImpl(entry.id, {\n getSpec: () => spec,\n getData: () => readDataAccessor(entry),\n getDataStatus: () => readDataStatus(entry),\n });\n }\n\n /**\n * Wrap a materialised {@link PColumn}. If the input is already a\n * {@link DataColumnRecipe} leaf it is returned as-is.\n */\n static fromColumn(\n column: PColumn<ColumnData> | DataColumnRecipe<PObjectId>,\n ): DataColumnRecipe<PObjectId> {\n if (column instanceof DataColumnImpl) return column;\n // `DataColumnRecipe` is an interface, so `instanceof` above does not remove it\n // from the union. The only implementation carrying a bare `PObjectId` is\n // `DataColumnImpl` (wrappers expose `ColumnUniversalId`), so anything\n // reaching here is a materialised `PColumn`.\n const pColumn = column as PColumn<ColumnData>;\n return new DataColumnImpl(pColumn.id, {\n getSpec: () => pColumn.spec,\n getData: () => pColumn.data,\n getDataStatus: () => \"present\",\n });\n }\n\n /**\n * Distinguishes `present` / `resolving` / `absent` for a {@link PObjectId}\n * in the active render ctx. Falls back to the registry's `isFinal()`\n * when the id has no entry — only then we can say `absent` instead of\n * `resolving`. The status tells only whether the spec is readable: for an\n * export that is not a column it is `present`, and the factories return\n * `undefined`.\n */\n static getStatusById(\n id: PObjectId,\n { ctx }: { ctx?: GlobalCfgRenderCtx } = {},\n ): ColumnResolutionStatus {\n const registry = new ColumnRegistry(getCtxProviders({ ctx }));\n const leaf = registry.resolve(id);\n if (isNil(leaf)) return registry.isFinal() ? \"absent\" : \"resolving\";\n return getLeafEntryStatus(leaf);\n }\n\n /** {@link PlRef} wrapper over {@link getStatusById}. */\n static getStatusByPlRef(\n ref: PlRef,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n ): ColumnResolutionStatus {\n return DataColumnImpl.getStatusById(createGlobalPObjectId(ref.blockId, ref.name), opts);\n }\n\n /** No registry — reads straight off the entry's accessor. */\n static getStatusByAccessor(entry: LeafEntry<TreeNodeAccessor>): ColumnResolutionStatus {\n return getLeafEntryStatus(entry);\n }\n}\n\n/** Anything the {@link DataColumnRecipe} dispatcher can build a leaf from. */\nexport type DataColumnSource =\n | PObjectId\n | PlRef\n | LeafEntry<TreeNodeAccessor>\n | PColumn<ColumnData>\n | DataColumnRecipe<PObjectId>;\n\n/**\n * Unified dispatcher — picks the right `DataColumnImpl.fromX` by source\n * shape. For ambiguous inputs callers can still use the explicit factories\n * (also attached as properties: `DataColumn.fromId`, `.fromPlRef`,\n * `.fromAccessor`, `.fromColumn`).\n */\nfunction DataColumnDispatch(\n source: DataColumnSource,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): undefined | DataColumnRecipe<PObjectId> {\n if (typeof source === \"string\") return DataColumnImpl.fromId(source, opts);\n if (source instanceof DataColumnImpl) return source;\n // `DataColumnRecipe` is an interface — `instanceof` above cannot remove it from\n // the union, and only `DataColumnImpl` implements it with a bare id.\n const rest = source as LeafEntry<TreeNodeAccessor> | PlRef | PColumn<ColumnData>;\n if (\"accessor\" in rest) return DataColumnImpl.fromAccessor(rest);\n if (isPlRef(rest)) return DataColumnImpl.fromPlRef(rest);\n if (isPColumn(rest)) return DataColumnImpl.fromColumn(rest);\n throw new Error(\"DataColumn: unknown source shape\");\n}\n\n/**\n * Polymorphic counterpart to {@link DataColumnDispatch}: returns the\n * {@link ColumnResolutionStatus} for any factory input without constructing\n * the recipe. For already-materialised sources ({@link PColumn} value,\n * existing {@link DataColumnRecipe}) status is `present` by construction.\n */\nfunction DataColumnGetStatus(\n source: DataColumnSource,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): ColumnResolutionStatus {\n if (typeof source === \"string\") return DataColumnImpl.getStatusById(source, opts);\n if (source instanceof DataColumnImpl) return \"present\";\n const rest = source as LeafEntry<TreeNodeAccessor> | PlRef | PColumn<ColumnData>;\n if (\"accessor\" in rest) return DataColumnImpl.getStatusByAccessor(rest);\n if (isPlRef(rest)) return DataColumnImpl.getStatusByPlRef(rest, opts);\n if (isPColumn(rest)) return \"present\";\n throw new Error(\"DataColumn.getStatus: unknown source shape\");\n}\n\nexport const DataColumn = Object.assign(DataColumnDispatch, {\n fromId: DataColumnImpl.fromId,\n fromPlRef: DataColumnImpl.fromPlRef,\n fromAccessor: DataColumnImpl.fromAccessor,\n fromColumn: DataColumnImpl.fromColumn,\n getStatus: DataColumnGetStatus,\n getStatusById: DataColumnImpl.getStatusById,\n getStatusByPlRef: DataColumnImpl.getStatusByPlRef,\n getStatusByAccessor: DataColumnImpl.getStatusByAccessor,\n});\n\n/**\n * Type-guard narrowing to a bare leaf — a {@link DataColumnRecipe} whose `id` is a\n * plain {@link PObjectId}.\n */\nexport function isDataColumn(value: unknown): value is DataColumnRecipe<PObjectId> {\n return value instanceof DataColumnImpl;\n}\n\nconst readSpecAccessor = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): undefined | TreeNodeAccessor =>\n accessor.traverse({ field: `${name}.spec`, assertFieldType: \"Input\", ignoreError: true }),\n);\n\n/** The leaf's spec, or `undefined` until the spec resource has data. */\nconst readSpec = memoizeByEntry((entry: LeafEntry<TreeNodeAccessor>): undefined | PObjectSpec => {\n const spec = readSpecAccessor(entry);\n if (isNil(spec) || !spec.hasData()) return undefined;\n return spec.getDataAsJson<PObjectSpec>();\n});\n\n/**\n * Per-entry counterpart to {@link readDataStatus}: tells whether the leaf's\n * **spec** can be read in this ctx, and — for the negative cases —\n * distinguishes `resolving` from `absent` via `getInputsLocked()`.\n *\n * - spec field not yet on the entry's accessor + inputs locked → `absent`\n * - spec field not yet on the entry's accessor + still resolving → `resolving`\n * - spec resource present but bytes not yet written → `resolving`\n * (transient — the spec resource is connected, just unfilled)\n * - spec resource present and `hasData()` → `present`\n */\nfunction getLeafEntryStatus(entry: LeafEntry<TreeNodeAccessor>): ColumnResolutionStatus {\n const spec = readSpecAccessor(entry);\n if (isNil(spec)) return entry.accessor.getInputsLocked() ? \"absent\" : \"resolving\";\n if (!spec.hasData()) return \"resolving\";\n return \"present\";\n}\n\nconst readDataAccessor = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): undefined | TreeNodeAccessor =>\n accessor.traverse({ field: `${name}.data`, assertFieldType: \"Input\", ignoreError: true }),\n);\n\nconst readDataStatus = memoizeByEntry(\n ({ accessor, name }: LeafEntry<TreeNodeAccessor>): ColumnFieldStatus => {\n if (accessor.listInputFields().includes(`${name}.data`)) return \"present\";\n return accessor.getInputsLocked() ? \"absent\" : \"resolving\";\n },\n);\n\nfunction memoizeByEntry<R>(\n fn: (entry: LeafEntry<TreeNodeAccessor>) => R,\n): (entry: LeafEntry<TreeNodeAccessor>) => R {\n const cache = new LRUCache<string, { value: R }>({ max: 1000 });\n return (entry) => {\n const key = `${entry.accessor.handle}:${entry.name}`;\n let hit = cache.get(key);\n if (!hit) cache.set(key, (hit = { value: fn(entry) }));\n return hit.value;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AA+DA,IAAa,iBAAb,MAAa,eAAsD;CAM/C;CACC;CANnB;CACA;CACA;CAEA,YACE,IACA,SAKA;EANgB,KAAA,KAAA;EACC,KAAA,UAAA;CAKhB;;CAGH,mBAAgC;EAC9B,OAAO,CAAC,KAAK,EAAE;CACjB;CAEA,UAAuB;EACrB,IAAI,KAAK,cAAc,KAAA,GACrB,KAAK,YAAY,EAAE,OAAO,KAAK,QAAQ,QAAQ,EAAE;EAEnD,OAAO,KAAK,UAAU;CACxB;;CAGA,WAAsB;EACpB,OAAO;GAAE,MAAM;GAAU,QAAQ,KAAK;EAAG;CAC3C;CAEA,UAAsB;EACpB,IAAI,KAAK,cAAc,KAAA,GAAW,KAAK,YAAY,EAAE,OAAO,KAAK,QAAQ,QAAQ,EAAE;EACnF,OAAO,KAAK,UAAU;CACxB;CAEA,gBAAmC;EACjC,IAAI,KAAK,oBAAoB,KAAA,GAC3B,KAAK,kBAAkB,EAAE,OAAO,KAAK,QAAQ,cAAc,EAAE;EAE/D,OAAO,KAAK,gBAAgB;CAC9B;;;;;;CAOA,UAAU,WAAwC;EAChD,OAAO,uBAAuB,KAAK,MAAM,SAAS;CACpD;;;;;;;;CASA,OAAO,OACL,IACA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mBAAmB,OAA4D;CACtF,MAAM,OAAO,iBAAiB,KAAK;CACnC,IAAI,MAAM,IAAI,GAAG,OAAO,MAAM,SAAS,gBAAgB,IAAI,WAAW;CACtE,IAAI,CAAC,KAAK,QAAQ,GAAG,OAAO;CAC5B,OAAO;AACT;AAEA,MAAM,mBAAmB,gBACtB,EAAE,UAAU,WACX,SAAS,SAAS;CAAE,OAAO,GAAG,KAAK;CAAQ,iBAAiB;CAAS,aAAa;AAAK,CAAC,CAC5F;AAEA,MAAM,iBAAiB,gBACpB,EAAE,UAAU,WAA2D;CACtE,IAAI,SAAS,gBAAgB,CAAC,CAAC,SAAS,GAAG,KAAK,MAAM,GAAG,OAAO;CAChE,OAAO,SAAS,gBAAgB,IAAI,WAAW;AACjD,CACF;AAEA,SAAS,eACP,IAC2C;CAC3C,MAAM,QAAQ,IAAI,SAA+B,EAAE,KAAK,IAAK,CAAC;CAC9D,QAAQ,UAAU;EAChB,MAAM,MAAM,GAAG,MAAM,SAAS,OAAO,GAAG,MAAM;EAC9C,IAAI,MAAM,MAAM,IAAI,GAAG;EACvB,IAAI,CAAC,KAAK,MAAM,IAAI,KAAM,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,CAAE;EACrD,OAAO,IAAI;CACb;AACF"}
|
package/dist/columns/index.cjs
CHANGED
|
@@ -11,11 +11,11 @@ const require_peer_links = require("./peer_links.cjs");
|
|
|
11
11
|
const require_utils = require("./utils.cjs");
|
|
12
12
|
const require_derive_axis_values_labels = require("./derive_axis_values_labels.cjs");
|
|
13
13
|
const require_split_by_axes = require("./split_by_axes.cjs");
|
|
14
|
+
const require_column_values = require("./column_values.cjs");
|
|
14
15
|
exports.AccessorColumnsProvider = require_providers.AccessorColumnsProvider;
|
|
15
16
|
exports.AccessorColumnsProviderImpl = require_providers.AccessorColumnsProviderImpl;
|
|
16
17
|
exports.ArrayColumnsProvider = require_providers.ArrayColumnsProvider;
|
|
17
18
|
exports.Column = require_column.Column;
|
|
18
|
-
exports.ColumnAbsentError = require_data_column.ColumnAbsentError;
|
|
19
19
|
exports.ColumnDiscoveredRecipe = require_column_discovered_recipe.ColumnDiscoveredRecipe;
|
|
20
20
|
exports.ColumnFilteredRecipe = require_column_filtered_recipe.ColumnFilteredRecipe;
|
|
21
21
|
exports.ColumnOverriddenRecipe = require_column_overrided_recipe.ColumnOverriddenRecipe;
|
|
@@ -31,9 +31,12 @@ exports._ctxProvidersCache = require_index$1._ctxProvidersCache;
|
|
|
31
31
|
exports.collectDatasetAxes = require_peer_links.collectDatasetAxes;
|
|
32
32
|
exports.collectLinkerColumns = require_utils.collectLinkerColumns;
|
|
33
33
|
exports.collectLinkerIds = require_utils.collectLinkerIds;
|
|
34
|
+
exports.createColumnValueOptions = require_column_values.createColumnValueOptions;
|
|
34
35
|
exports.createPeerLinkFinder = require_utils.createPeerLinkFinder;
|
|
35
36
|
exports.deriveAxisValuesLabels = require_derive_axis_values_labels.deriveAxisValuesLabels;
|
|
36
37
|
exports.deriveColumnOptions = require_utils.deriveColumnOptions;
|
|
38
|
+
exports.deriveColumnValueOptions = require_column_values.deriveColumnValueOptions;
|
|
39
|
+
exports.deriveLabelledColumnValueOptions = require_column_values.deriveLabelledColumnValueOptions;
|
|
37
40
|
exports.deriveRecipeOptions = require_utils.deriveRecipeOptions;
|
|
38
41
|
exports.describePeerLinks = require_peer_links.describePeerLinks;
|
|
39
42
|
exports.findPeerLinks = require_peer_links.findPeerLinks;
|
package/dist/columns/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColumnFieldStatus, ColumnRecipeId, ColumnResolutionStatus, SpecQuery } from "./column_recipes/types.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ColumnData, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, isDataColumn } from "./data_column.js";
|
|
3
3
|
import { ColumnDiscoveredRecipe } from "./column_recipes/column_discovered_recipe.js";
|
|
4
4
|
import { ColumnFilteredRecipe } from "./column_recipes/column_filtered_recipe.js";
|
|
5
5
|
import { Column, ColumnSource, isColumn } from "./column.js";
|
|
@@ -13,4 +13,5 @@ import { ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, Column
|
|
|
13
13
|
import { deriveAxisValuesLabels } from "./derive_axis_values_labels.js";
|
|
14
14
|
import { ColumnOption, collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveColumnOptions, deriveRecipeOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications } from "./utils.js";
|
|
15
15
|
import { DatasetAxes, collectDatasetAxes, describePeerLinks, findPeerLinks, getResultPoolDatasetAxes, peerLinkedLast } from "./peer_links.js";
|
|
16
|
-
|
|
16
|
+
import { ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, createColumnValueOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions } from "./column_values.js";
|
|
17
|
+
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, ColumnOverriddenRecipe, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsProvider, ColumnsSource, ColumnsSourceShorthand, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DatasetAxes, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, type SpecQuery, SplitAxis, SplitByAxesOpts, _ctxProvidersCache, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, createColumnValueOptions, createPeerLinkFinder, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions, deriveRecipeOptions, describePeerLinks, findPeerLinks, getCtxProviders, getResultPoolDatasetAxes, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isColumn, isColumnProvider, isColumnsCollection, isDataColumn, isLeafColumn, peerLinkedLast, queriesQualifications, splitByAxes, toColumnProvider };
|
package/dist/columns/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { ColumnDiscoveredRecipe } from "./column_recipes/column_discovered_recip
|
|
|
3
3
|
import { ColumnFilteredRecipe } from "./column_recipes/column_filtered_recipe.js";
|
|
4
4
|
import { ColumnRecipe } from "./column_recipes/index.js";
|
|
5
5
|
import { ColumnOverriddenRecipe } from "./column_recipes/column_overrided_recipe.js";
|
|
6
|
-
import {
|
|
6
|
+
import { DataColumn, DataColumnImpl, isDataColumn } from "./data_column.js";
|
|
7
7
|
import { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, ColumnsProvider, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl } from "./column_providers/providers.js";
|
|
8
8
|
import { _ctxProvidersCache, getCtxProviders, isColumnProvider, toColumnProvider } from "./column_providers/index.js";
|
|
9
9
|
import { ColumnsCollection, ColumnsCollectionImpl, isColumnsCollection } from "./columns_collection.js";
|
|
@@ -11,4 +11,5 @@ import { collectDatasetAxes, describePeerLinks, findPeerLinks, getResultPoolData
|
|
|
11
11
|
import { collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveColumnOptions, deriveRecipeOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications } from "./utils.js";
|
|
12
12
|
import { deriveAxisValuesLabels } from "./derive_axis_values_labels.js";
|
|
13
13
|
import { splitByAxes } from "./split_by_axes.js";
|
|
14
|
-
|
|
14
|
+
import { createColumnValueOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions } from "./column_values.js";
|
|
15
|
+
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column, ColumnDiscoveredRecipe, ColumnFilteredRecipe, ColumnOverriddenRecipe, ColumnRecipe, ColumnsCollection, ColumnsCollectionImpl, ColumnsProvider, DataColumn, DataColumnImpl, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, _ctxProvidersCache, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, createColumnValueOptions, createPeerLinkFinder, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions, deriveRecipeOptions, describePeerLinks, findPeerLinks, getCtxProviders, getResultPoolDatasetAxes, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isColumn, isColumnProvider, isColumnsCollection, isDataColumn, isLeafColumn, peerLinkedLast, queriesQualifications, splitByAxes, toColumnProvider };
|
package/dist/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ const require_peer_links = require("./columns/peer_links.cjs");
|
|
|
38
38
|
const require_utils = require("./columns/utils.cjs");
|
|
39
39
|
const require_derive_axis_values_labels = require("./columns/derive_axis_values_labels.cjs");
|
|
40
40
|
const require_split_by_axes = require("./columns/split_by_axes.cjs");
|
|
41
|
+
const require_column_values = require("./columns/column_values.cjs");
|
|
41
42
|
require("./columns/index.cjs");
|
|
42
43
|
const require_columns = require("./pframe_utils/columns.cjs");
|
|
43
44
|
const require_PFrameForGraphs = require("./components/PFrameForGraphs.cjs");
|
|
@@ -65,6 +66,7 @@ require("./labels/index.cjs");
|
|
|
65
66
|
const require_raw_globals = require("./raw_globals.cjs");
|
|
66
67
|
const require_converter = require("./annotations/converter.cjs");
|
|
67
68
|
require("./annotations/index.cjs");
|
|
69
|
+
const require_column_value_options = require("./pframe_utils/column_value_options.cjs");
|
|
68
70
|
const require_index$11 = require("./pframe_utils/index.cjs");
|
|
69
71
|
const require_env_value = require("./env_value.cjs");
|
|
70
72
|
exports.AccessorColumnsProvider = require_providers.AccessorColumnsProvider;
|
|
@@ -77,7 +79,6 @@ exports.BlockRenderCtx = require_api.BlockRenderCtx;
|
|
|
77
79
|
exports.BlockStorageFacadeCallbacks = require_block_storage_facade.BlockStorageFacadeCallbacks;
|
|
78
80
|
exports.BlockStorageFacadeHandles = require_block_storage_facade.BlockStorageFacadeHandles;
|
|
79
81
|
exports.Column = require_column.Column;
|
|
80
|
-
exports.ColumnAbsentError = require_data_column.ColumnAbsentError;
|
|
81
82
|
exports.ColumnDiscoveredRecipe = require_column_discovered_recipe.ColumnDiscoveredRecipe;
|
|
82
83
|
exports.ColumnFilteredRecipe = require_column_filtered_recipe.ColumnFilteredRecipe;
|
|
83
84
|
exports.ColumnOverriddenRecipe = require_column_overrided_recipe.ColumnOverriddenRecipe;
|
|
@@ -138,6 +139,7 @@ exports.convertFilterUiToExpressionImpl = require_filterUiToExpressionImpl.conve
|
|
|
138
139
|
exports.convertFilterUiToExpressions = require_filterUiToExpressionImpl.convertFilterUiToExpressions;
|
|
139
140
|
exports.convertOrParsePColumnData = require_pcolumn_data.convertOrParsePColumnData;
|
|
140
141
|
exports.createBlockStorage = require_block_storage.createBlockStorage;
|
|
142
|
+
exports.createColumnValueOptions = require_column_values.createColumnValueOptions;
|
|
141
143
|
exports.createDatasetSelection = require_dataset_selection.createDatasetSelection;
|
|
142
144
|
exports.createDefaultPTableParams = require_state_migration.createDefaultPTableParams;
|
|
143
145
|
exports.createPFrameForGraphs = require_PFrameForGraphs.createPFrameForGraphs;
|
|
@@ -152,9 +154,11 @@ exports.createRowSelectionColumn = require_PlMultiSequenceAlignment.createRowSel
|
|
|
152
154
|
exports.createServiceProxy = require_service_bridge.createServiceProxy;
|
|
153
155
|
exports.deriveAxisValuesLabels = require_derive_axis_values_labels.deriveAxisValuesLabels;
|
|
154
156
|
exports.deriveColumnOptions = require_utils.deriveColumnOptions;
|
|
157
|
+
exports.deriveColumnValueOptions = require_column_values.deriveColumnValueOptions;
|
|
155
158
|
exports.deriveDataFromStorage = require_block_storage.deriveDataFromStorage;
|
|
156
159
|
exports.deriveDistinctLabels = require_derive_distinct_labels.deriveDistinctLabels;
|
|
157
160
|
exports.deriveDistinctTooltips = require_derive_distinct_tooltips.deriveDistinctTooltips;
|
|
161
|
+
exports.deriveLabelledColumnValueOptions = require_column_values.deriveLabelledColumnValueOptions;
|
|
158
162
|
exports.deriveLabels = require_label.deriveLabels;
|
|
159
163
|
exports.deriveRecipeOptions = require_utils.deriveRecipeOptions;
|
|
160
164
|
exports.describePeerLinks = require_peer_links.describePeerLinks;
|
|
@@ -221,6 +225,7 @@ exports.peerLinkedLast = require_peer_links.peerLinkedLast;
|
|
|
221
225
|
exports.pluginOutputKey = require_plugin_handle.pluginOutputKey;
|
|
222
226
|
exports.pluginOutputPrefix = require_plugin_handle.pluginOutputPrefix;
|
|
223
227
|
exports.queriesQualifications = require_utils.queriesQualifications;
|
|
228
|
+
exports.readColumnValueOptions = require_column_value_options.readColumnValueOptions;
|
|
224
229
|
exports.readOutput = require_block_state_util.readOutput;
|
|
225
230
|
exports.registerFacadeCallbacks = require_block_storage_facade.registerFacadeCallbacks;
|
|
226
231
|
exports.splitByAxes = require_split_by_axes.splitByAxes;
|
package/dist/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ import "./annotations/index.js";
|
|
|
46
46
|
import { AnnotationScriptUi, AnnotationStepUi, AnyForm, FilterUi, FilterUiOfType, FilterUiType, FormField, TypeField, TypeFieldRecord, TypeForm, TypeToLiteral, compileAnnotationScript, compileFilter, compileFilters, unreachable } from "./components/PlAnnotations/filters_ui.js";
|
|
47
47
|
import { DatasetOption, DatasetSelection, createDatasetSelection, isDatasetSelection } from "./components/PlDatasetSelector/dataset_selection.js";
|
|
48
48
|
import { ColumnFieldStatus, ColumnRecipeId, ColumnResolutionStatus, SpecQuery } from "./columns/column_recipes/types.js";
|
|
49
|
-
import {
|
|
49
|
+
import { ColumnData, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, isDataColumn } from "./columns/data_column.js";
|
|
50
50
|
import { ColumnDiscoveredRecipe } from "./columns/column_recipes/column_discovered_recipe.js";
|
|
51
51
|
import { ColumnFilteredRecipe } from "./columns/column_recipes/column_filtered_recipe.js";
|
|
52
52
|
import { Column, ColumnSource, isColumn } from "./columns/column.js";
|
|
@@ -60,6 +60,7 @@ import { ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, Column
|
|
|
60
60
|
import { deriveAxisValuesLabels } from "./columns/derive_axis_values_labels.js";
|
|
61
61
|
import { ColumnOption, collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveColumnOptions, deriveRecipeOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications } from "./columns/utils.js";
|
|
62
62
|
import { DatasetAxes, collectDatasetAxes, describePeerLinks, findPeerLinks, getResultPoolDatasetAxes, peerLinkedLast } from "./columns/peer_links.js";
|
|
63
|
+
import { ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, createColumnValueOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions } from "./columns/column_values.js";
|
|
63
64
|
import "./columns/index.js";
|
|
64
65
|
import { FilterMatchOptions, FindFilterColumnsOptions, buildRefMap, filterMatchesToOptions, findFilterColumns } from "./components/PlDatasetSelector/filter_discovery.js";
|
|
65
66
|
import { BuildDatasetOptions, buildDatasetOptions } from "./components/PlDatasetSelector/build_dataset_options.js";
|
|
@@ -79,6 +80,7 @@ import { TooltipEntry, deriveDistinctTooltips } from "./labels/derive_distinct_t
|
|
|
79
80
|
import "./labels/index.js";
|
|
80
81
|
import { getPlatformaApiVersion, getRawPlatformaInstance } from "./raw_globals.js";
|
|
81
82
|
import { getAllRelatedColumns, getRelatedColumns } from "./pframe_utils/columns.js";
|
|
83
|
+
import { PresentColumnValueOptionsModel, readColumnValueOptions } from "./pframe_utils/column_value_options.js";
|
|
82
84
|
import { getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getRequestColumnsFromSelectedSources, getSingleColumnData, getUniqueAxisValuesWithLabels, getUniqueSourceValuesWithLabels } from "./pframe_utils/index.js";
|
|
83
85
|
import { ServiceProxy, buildServices, createServiceProxy } from "./services/service_bridge.js";
|
|
84
86
|
import { getService } from "./services/get_services.js";
|
|
@@ -86,4 +88,4 @@ import "./services/index.js";
|
|
|
86
88
|
import { getEnvironmentValue } from "./env_value.js";
|
|
87
89
|
export * from "@milaboratories/pl-model-common";
|
|
88
90
|
export * from "@milaboratories/pl-error-like";
|
|
89
|
-
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, type AccessorHandle, AndFilter, AnnotationFilter, AnnotationMode, AnnotationScript, AnnotationScript2, AnnotationScriptUi, AnnotationSpec, AnnotationSpecUi, AnnotationStep, AnnotationStepUi, AnyForm, ArrayColumnsProvider, type AxesVault, AxisLabelProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockApiV1, BlockApiV2, BlockConfig, BlockConfigV3, BlockConfigV4, BlockDefaultModelServices, BlockDefaultUiServices, BlockModelInfo, BlockModelV3, BlockRenderCtx, BlockServiceFlags, BlockStatePatch, type BlockStorage, BlockStorageFacade, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, type BlockStorageSchemaVersion, BuildDatasetOptions, CancelSubscription, Cfg, CfgAnd, CfgBlobContent, CfgBlobContentAsJson, CfgBlobContentAsString, CfgDownloadedBlobContent, CfgExtractArchiveAndGetURL, CfgFlatten, CfgGetFromCtx, CfgGetJsonField, CfgGetResourceField, CfgImmediate, CfgImportProgress, CfgIsEmpty, CfgIsolate, CfgLastLogs, CfgLogHandle, CfgMakeArray, CfgMakeObject, CfgMapArrayValues, CfgMapRecordValues, CfgMapResourceFields, CfgNot, CfgOnDemandBlobContent, CfgOr, CfgProgressLog, CfgProgressLogWithInfo, CfgResourceValueAsJson, Column,
|
|
91
|
+
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, type AccessorHandle, AndFilter, AnnotationFilter, AnnotationMode, AnnotationScript, AnnotationScript2, AnnotationScriptUi, AnnotationSpec, AnnotationSpecUi, AnnotationStep, AnnotationStepUi, AnyForm, ArrayColumnsProvider, type AxesVault, AxisLabelProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockApiV1, BlockApiV2, BlockConfig, BlockConfigV3, BlockConfigV4, BlockDefaultModelServices, BlockDefaultUiServices, BlockModelInfo, BlockModelV3, BlockRenderCtx, BlockServiceFlags, BlockStatePatch, type BlockStorage, BlockStorageFacade, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, type BlockStorageSchemaVersion, BuildDatasetOptions, CancelSubscription, Cfg, CfgAnd, CfgBlobContent, CfgBlobContentAsJson, CfgBlobContentAsString, CfgDownloadedBlobContent, CfgExtractArchiveAndGetURL, CfgFlatten, CfgGetFromCtx, CfgGetJsonField, CfgGetResourceField, CfgImmediate, CfgImportProgress, CfgIsEmpty, CfgIsolate, CfgLastLogs, CfgLogHandle, CfgMakeArray, CfgMakeObject, CfgMapArrayValues, CfgMapRecordValues, CfgMapResourceFields, CfgNot, CfgOnDemandBlobContent, CfgOr, CfgProgressLog, CfgProgressLogWithInfo, CfgResourceValueAsJson, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, type ColumnOrderRule, ColumnOverriddenRecipe, ColumnProvider, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, type ColumnVisibilityRule, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, type ColumnsDisplayOptions, ColumnsProvider, type ColumnsSelectorConfig, ColumnsSource, ColumnsSourceShorthand, CommonFieldTraverseOps, CommonTraversalOps, ConfigRenderLambda, ConfigRenderLambdaFlags, CurrentSdkInfo, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DataModel, DataModelBuilder, DatasetAxes, DatasetOption, DatasetSelection, DeriveHref, DeriveLabelsFormatters, DeriveLabelsOptions, Entry, ExpressionSpec, ExtractFunctionHandleReturn, type ExtractFutureRefType, FieldTraversalStep, FieldType, FilterMatchOptions, type FilterSpec, type FilterSpecLeaf, type FilterSpecNode, type FilterSpecOfType, type FilterSpecType, FilterSpecUi, FilterUi, FilterUiOfType, FilterUiType, FindFilterColumnsOptions, FormField, FutureRef, GetFieldStep, InferArgsType, InferBlockState, InferBlockStatePatch, InferDataType, InferFactoryData, InferFactoryModelServices, InferFactoryOutputs, InferFactoryParams, InferFactoryUiServices, InferHrefType, InferOutputsFromLambdas, InferOutputsType, InferPluginData, InferPluginHandle, InferPluginNames, InferPluginUiEntries, InferRenderFunctionReturn, InferUiState, IsNA, internal_d_exports as JsRenderInternal, type DeriveLabelsOptions as LabelDerivationOps, LinkerStep, Log10, MainAccessorName, type MigrateBlockStorageConfig, type MigrationFailure, type MigrationResult, type MigrationSuccess, type ModelServices, type MutateStoragePayload, NotFilter, NumericalComparisonFilter, OptionalPlResourceEntry, OrFilter, OutputError, PColumnCollection, type PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, PColumnKeyList, PColumnPredicate, PColumnResourceMapData, PColumnResourceMapEntry, PColumnUniversal, PColumnWithLabel, PFrameImpl, PTableKey, type PTableParamsV2, type ParamsInput, Patch, PatternFilter, PatternPredicate, PatternPredicateContainSubsequence, PatternPredicateEquals, type PlDataTableAxisMeta, type PlDataTableColumnMeta, type PlDataTableColumnsMeta, type PlDataTableFilterMeta, type PlDataTableFilterSpecLeaf, type PlDataTableFilters, type PlDataTableFiltersWithMeta, type PlDataTableGridStateCore, type PlDataTableModel, type PlDataTableSheet, type PlDataTableSheetState, type PlDataTableStateV2, type PlDataTableStateV2CacheEntry, type PlDataTableStateV2Normalized, PlMultiSequenceAlignmentColorSchemeOption, PlMultiSequenceAlignmentModel, PlMultiSequenceAlignmentSettings, PlMultiSequenceAlignmentWidget, PlResourceEntry, PlSelectionModel, type PlTableColumnIdJson, Platforma, PlatformaApiVersion, PlatformaExtended, PlatformaFactory, PlatformaSDKVersion, PlatformaV1, PlatformaV2, PlatformaV3, type PluginConfig, type PluginData, PluginDataModel, PluginDataModelBuilder, type PluginDataModelVersions, type PluginFactory, PluginFactoryLike, PluginHandle, PluginInstance, PluginModel, type PluginName, type PluginOutputs, type PluginParams, type PluginPublicOutputs, type PluginRecord, type PluginRegistry, PluginRenderCtx, PresentColumnValueOptionsModel, type PublicOutputFieldDef, QueryColumnId, QueryColumnIdAxis, QueryColumnIdColumn, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtx, RenderCtxBase, RenderFunction, ResolveModelServices, ResolveUiServices, ResourceTraversalOps, ResourceType, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, SdkInfo, ServiceProxy, SimplifiedPColumnSpec, SimplifiedUniversalPColumnEntry, SortedCumulativeSum, type Entry as SpecExtractorResult, type SpecQuery, SplitAxis, SplitByAxesOpts, StagingAccessorName, StdCtx, StdCtxArgsOnly, TooltipEntry, type Trace, type TraceEntry, TransformedColumn, TreeNodeAccessor, TypeField, TypeFieldRecord, TypeForm, TypeToLiteral, TypedConfig, TypedConfigOrConfigLambda, TypedConfigOrString, type UiServices, Unionize, UniversalColumnOption, UnwrapFutureRef, ValueRank, type VersionedData, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildRefMap, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, type createPlDataTableOptionsV3, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ import { ColumnDiscoveredRecipe } from "./columns/column_recipes/column_discover
|
|
|
29
29
|
import { ColumnFilteredRecipe } from "./columns/column_recipes/column_filtered_recipe.js";
|
|
30
30
|
import { ColumnRecipe } from "./columns/column_recipes/index.js";
|
|
31
31
|
import { ColumnOverriddenRecipe } from "./columns/column_recipes/column_overrided_recipe.js";
|
|
32
|
-
import {
|
|
32
|
+
import { DataColumn, DataColumnImpl, isDataColumn } from "./columns/data_column.js";
|
|
33
33
|
import { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, ColumnsProvider, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl } from "./columns/column_providers/providers.js";
|
|
34
34
|
import { _ctxProvidersCache, getCtxProviders, isColumnProvider, toColumnProvider } from "./columns/column_providers/index.js";
|
|
35
35
|
import { ColumnsCollection, ColumnsCollectionImpl, isColumnsCollection } from "./columns/columns_collection.js";
|
|
@@ -37,6 +37,7 @@ import { collectDatasetAxes, describePeerLinks, findPeerLinks, getResultPoolData
|
|
|
37
37
|
import { collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveColumnOptions, deriveRecipeOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications } from "./columns/utils.js";
|
|
38
38
|
import { deriveAxisValuesLabels } from "./columns/derive_axis_values_labels.js";
|
|
39
39
|
import { splitByAxes } from "./columns/split_by_axes.js";
|
|
40
|
+
import { createColumnValueOptions, deriveColumnValueOptions, deriveLabelledColumnValueOptions } from "./columns/column_values.js";
|
|
40
41
|
import "./columns/index.js";
|
|
41
42
|
import { getAllRelatedColumns, getRelatedColumns } from "./pframe_utils/columns.js";
|
|
42
43
|
import { createPFrameForGraphs, isHiddenFromGraphColumn, isHiddenFromUIColumn } from "./components/PFrameForGraphs.js";
|
|
@@ -64,8 +65,9 @@ import "./labels/index.js";
|
|
|
64
65
|
import { getPlatformaApiVersion, getRawPlatformaInstance } from "./raw_globals.js";
|
|
65
66
|
import { convertFilterSpecsToExpressionSpecs } from "./annotations/converter.js";
|
|
66
67
|
import "./annotations/index.js";
|
|
68
|
+
import { readColumnValueOptions } from "./pframe_utils/column_value_options.js";
|
|
67
69
|
import { getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getRequestColumnsFromSelectedSources, getSingleColumnData, getUniqueAxisValuesWithLabels, getUniqueSourceValuesWithLabels } from "./pframe_utils/index.js";
|
|
68
70
|
import { getEnvironmentValue } from "./env_value.js";
|
|
69
71
|
export * from "@milaboratories/pl-model-common";
|
|
70
72
|
export * from "@milaboratories/pl-error-like";
|
|
71
|
-
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockModelV3, BlockRenderCtx, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, Column,
|
|
73
|
+
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockModelV3, BlockRenderCtx, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, Column, ColumnDiscoveredRecipe, ColumnFilteredRecipe, ColumnOverriddenRecipe, ColumnRecipe, ColumnsCollection, ColumnsCollectionImpl, ColumnsProvider, CurrentSdkInfo, DataColumn, DataColumnImpl, DataModel, DataModelBuilder, FutureRef, internal_exports as JsRenderInternal, MainAccessorName, OutputError, PColumnCollection, PFrameImpl, PlatformaSDKVersion, PluginDataModel, PluginDataModelBuilder, PluginInstance, PluginModel, PluginRenderCtx, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtxBase, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, StagingAccessorName, TreeNodeAccessor, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildRefMap, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
|
package/dist/package.cjs
CHANGED
package/dist/package.js
CHANGED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const require_column_values = require("../columns/column_values.cjs");
|
|
2
|
+
require("../columns/index.cjs");
|
|
3
|
+
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
4
|
+
// src/pframe_utils/column_value_options.ts
|
|
5
|
+
/**
|
|
6
|
+
* The options of a value picker, read in the UI through the frame of `model` (see
|
|
7
|
+
* `deriveColumnValueOptions` and `deriveLabelledColumnValueOptions`). Missing values are not
|
|
8
|
+
* offered; a value with a missing label labels itself. Rejects when the value column has more
|
|
9
|
+
* distinct values than a picker can offer, or, with a label column, more rows than it reads.
|
|
10
|
+
*/
|
|
11
|
+
async function readColumnValueOptions(model) {
|
|
12
|
+
const { value, label } = model.frameColumns;
|
|
13
|
+
if (label === null) return require_column_values.deriveColumnValueOptions(model.valueColumn, await readDistinctValues(model.frame, value));
|
|
14
|
+
return require_column_values.deriveLabelledColumnValueOptions(model.valueColumn, await readLabelledValues(model.frame, {
|
|
15
|
+
value,
|
|
16
|
+
label
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
/** More distinct values than any picker can usefully list. */
|
|
20
|
+
const VALUES_LIMIT = 1e5;
|
|
21
|
+
async function readDistinctValues(frame, column) {
|
|
22
|
+
const response = await frameDriver().getUniqueValues(frame, {
|
|
23
|
+
columnId: column,
|
|
24
|
+
filters: [],
|
|
25
|
+
limit: VALUES_LIMIT
|
|
26
|
+
});
|
|
27
|
+
if (response.overflow) throw new Error(`The column has more than ${VALUES_LIMIT} distinct values`);
|
|
28
|
+
const values = [];
|
|
29
|
+
for (let row = 0; row < response.values.data.length; row++) {
|
|
30
|
+
const value = (0, _milaboratories_pl_model_common.pTableValue)(response.values, row, { na: null });
|
|
31
|
+
if (value !== null) values.push(String(value));
|
|
32
|
+
}
|
|
33
|
+
return values;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Every row of the value column with the label the label column holds at the same keys, or an
|
|
37
|
+
* empty label where it holds none. Rows without a value are left out.
|
|
38
|
+
*/
|
|
39
|
+
async function readLabelledValues(frame, columns) {
|
|
40
|
+
const request = {
|
|
41
|
+
src: {
|
|
42
|
+
type: "outer",
|
|
43
|
+
primary: {
|
|
44
|
+
type: "column",
|
|
45
|
+
column: columns.value
|
|
46
|
+
},
|
|
47
|
+
secondary: [{
|
|
48
|
+
type: "column",
|
|
49
|
+
column: columns.label
|
|
50
|
+
}]
|
|
51
|
+
},
|
|
52
|
+
filters: [],
|
|
53
|
+
sorting: []
|
|
54
|
+
};
|
|
55
|
+
const response = await frameDriver().calculateTableData(frame, request, {
|
|
56
|
+
offset: 0,
|
|
57
|
+
length: 100001
|
|
58
|
+
});
|
|
59
|
+
const values = columnData(response, columns.value);
|
|
60
|
+
const labels = columnData(response, columns.label);
|
|
61
|
+
if (values.data.length > VALUES_LIMIT) throw new Error(`The column has more than ${VALUES_LIMIT} rows`);
|
|
62
|
+
const rows = [];
|
|
63
|
+
for (let row = 0; row < values.data.length; row++) {
|
|
64
|
+
const value = (0, _milaboratories_pl_model_common.pTableValue)(values, row, { na: null });
|
|
65
|
+
if (value === null) continue;
|
|
66
|
+
const label = (0, _milaboratories_pl_model_common.pTableValue)(labels, row, { na: null });
|
|
67
|
+
rows.push({
|
|
68
|
+
value: String(value),
|
|
69
|
+
label: label === null ? "" : String(label)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return rows;
|
|
73
|
+
}
|
|
74
|
+
function columnData(response, column) {
|
|
75
|
+
const entry = response.find((item) => item.spec.type === "column" && item.spec.id === column);
|
|
76
|
+
if (entry === void 0) throw new Error(`The frame did not return column ${column}`);
|
|
77
|
+
return entry.data;
|
|
78
|
+
}
|
|
79
|
+
function frameDriver() {
|
|
80
|
+
if (typeof platforma === "undefined" || platforma.pFrameDriver === void 0) throw new Error("The frame driver is not available");
|
|
81
|
+
return platforma.pFrameDriver;
|
|
82
|
+
}
|
|
83
|
+
exports.readColumnValueOptions = readColumnValueOptions;
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=column_value_options.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column_value_options.cjs","names":["deriveColumnValueOptions","deriveLabelledColumnValueOptions","pTableValue"],"sources":["../../src/pframe_utils/column_value_options.ts"],"sourcesContent":["import {\n pTableValue,\n type CalculateTableDataRequest,\n type FullPTableColumnData,\n type PFrameHandle,\n type PObjectId,\n} from \"@milaboratories/pl-model-common\";\nimport type { ColumnValueOption, ColumnValueOptionsModel } from \"../columns\";\nimport { deriveColumnValueOptions, deriveLabelledColumnValueOptions } from \"../columns\";\n\n/** A model whose value column is there to read. */\nexport type PresentColumnValueOptionsModel = Extract<ColumnValueOptionsModel, { type: \"present\" }>;\n\n/**\n * The options of a value picker, read in the UI through the frame of `model` (see\n * `deriveColumnValueOptions` and `deriveLabelledColumnValueOptions`). Missing values are not\n * offered; a value with a missing label labels itself. Rejects when the value column has more\n * distinct values than a picker can offer, or, with a label column, more rows than it reads.\n */\nexport async function readColumnValueOptions(\n model: PresentColumnValueOptionsModel,\n): Promise<ColumnValueOption[]> {\n const { value, label } = model.frameColumns;\n if (label === null) {\n return deriveColumnValueOptions(\n model.valueColumn,\n await readDistinctValues(model.frame, value),\n );\n }\n return deriveLabelledColumnValueOptions(\n model.valueColumn,\n await readLabelledValues(model.frame, { value, label }),\n );\n}\n\n// Internals\n\n/** More distinct values than any picker can usefully list. */\nconst VALUES_LIMIT = 100_000;\n\nasync function readDistinctValues(frame: PFrameHandle, column: PObjectId): Promise<string[]> {\n const response = await frameDriver().getUniqueValues(frame, {\n columnId: column,\n filters: [],\n limit: VALUES_LIMIT,\n });\n if (response.overflow) {\n throw new Error(`The column has more than ${VALUES_LIMIT} distinct values`);\n }\n\n const values: string[] = [];\n for (let row = 0; row < response.values.data.length; row++) {\n const value = pTableValue(response.values, row, { na: null });\n if (value !== null) values.push(String(value));\n }\n return values;\n}\n\n/**\n * Every row of the value column with the label the label column holds at the same keys, or an\n * empty label where it holds none. Rows without a value are left out.\n */\nasync function readLabelledValues(\n frame: PFrameHandle,\n columns: { readonly value: PObjectId; readonly label: PObjectId },\n): Promise<{ value: string; label: string }[]> {\n const request: CalculateTableDataRequest<PObjectId> = {\n src: {\n type: \"outer\",\n primary: { type: \"column\", column: columns.value },\n secondary: [{ type: \"column\", column: columns.label }],\n },\n filters: [],\n sorting: [],\n };\n // One row past the limit tells a column that has more rows than a picker reads.\n const response = await frameDriver().calculateTableData(frame, request, {\n offset: 0,\n length: VALUES_LIMIT + 1,\n });\n const values = columnData(response, columns.value);\n const labels = columnData(response, columns.label);\n if (values.data.length > VALUES_LIMIT) {\n throw new Error(`The column has more than ${VALUES_LIMIT} rows`);\n }\n\n const rows: { value: string; label: string }[] = [];\n for (let row = 0; row < values.data.length; row++) {\n const value = pTableValue(values, row, { na: null });\n if (value === null) continue;\n const label = pTableValue(labels, row, { na: null });\n rows.push({ value: String(value), label: label === null ? \"\" : String(label) });\n }\n return rows;\n}\n\nfunction columnData(\n response: readonly FullPTableColumnData[],\n column: PObjectId,\n): FullPTableColumnData[\"data\"] {\n const entry = response.find((item) => item.spec.type === \"column\" && item.spec.id === column);\n if (entry === undefined) throw new Error(`The frame did not return column ${column}`);\n return entry.data;\n}\n\nfunction frameDriver() {\n if (typeof platforma === \"undefined\" || platforma.pFrameDriver === undefined) {\n throw new Error(\"The frame driver is not available\");\n }\n return platforma.pFrameDriver;\n}\n"],"mappings":";;;;;;;;;;AAmBA,eAAsB,uBACpB,OAC8B;CAC9B,MAAM,EAAE,OAAO,UAAU,MAAM;CAC/B,IAAI,UAAU,MACZ,OAAOA,sBAAAA,yBACL,MAAM,aACN,MAAM,mBAAmB,MAAM,OAAO,KAAK,CAC7C;CAEF,OAAOC,sBAAAA,iCACL,MAAM,aACN,MAAM,mBAAmB,MAAM,OAAO;EAAE;EAAO;CAAM,CAAC,CACxD;AACF;;AAKA,MAAM,eAAe;AAErB,eAAe,mBAAmB,OAAqB,QAAsC;CAC3F,MAAM,WAAW,MAAM,YAAY,CAAC,CAAC,gBAAgB,OAAO;EAC1D,UAAU;EACV,SAAS,CAAC;EACV,OAAO;CACT,CAAC;CACD,IAAI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QAC8B;CAC9B,MAAM,QAAQ,SAAS,MAAM,SAAS,KAAK,KAAK,SAAS,YAAY,KAAK,KAAK,OAAO,MAAM;CAC5F,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,mCAAmC,QAAQ;CACpF,OAAO,MAAM;AACf;AAEA,SAAS,cAAc;CACrB,IAAI,OAAO,cAAc,eAAe,UAAU,iBAAiB,KAAA,GACjE,MAAM,IAAI,MAAM,mCAAmC;CAErD,OAAO,UAAU;AACnB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ColumnValueOption, ColumnValueOptionsModel } from "../columns/column_values.js";
|
|
2
|
+
import "../columns/index.js";
|
|
3
|
+
/** A model whose value column is there to read. */
|
|
4
|
+
export type PresentColumnValueOptionsModel = Extract<ColumnValueOptionsModel, {
|
|
5
|
+
type: "present";
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* The options of a value picker, read in the UI through the frame of `model` (see
|
|
9
|
+
* `deriveColumnValueOptions` and `deriveLabelledColumnValueOptions`). Missing values are not
|
|
10
|
+
* offered; a value with a missing label labels itself. Rejects when the value column has more
|
|
11
|
+
* distinct values than a picker can offer, or, with a label column, more rows than it reads.
|
|
12
|
+
*/
|
|
13
|
+
export declare function readColumnValueOptions(model: PresentColumnValueOptionsModel): Promise<ColumnValueOption[]>;
|
|
14
|
+
//# sourceMappingURL=column_value_options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column_value_options.d.ts","names":[],"sources":["../../src/pframe_utils/column_value_options.ts"],"mappings":";;;YAWY,iCAAiC,QAAQ;EAA2B;;;;;;;;wBAQ1D,uBACpB,OAAO,iCACN,QAAQ"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { deriveColumnValueOptions, deriveLabelledColumnValueOptions } from "../columns/column_values.js";
|
|
2
|
+
import "../columns/index.js";
|
|
3
|
+
import { pTableValue } from "@milaboratories/pl-model-common";
|
|
4
|
+
// src/pframe_utils/column_value_options.ts
|
|
5
|
+
/**
|
|
6
|
+
* The options of a value picker, read in the UI through the frame of `model` (see
|
|
7
|
+
* `deriveColumnValueOptions` and `deriveLabelledColumnValueOptions`). Missing values are not
|
|
8
|
+
* offered; a value with a missing label labels itself. Rejects when the value column has more
|
|
9
|
+
* distinct values than a picker can offer, or, with a label column, more rows than it reads.
|
|
10
|
+
*/
|
|
11
|
+
async function readColumnValueOptions(model) {
|
|
12
|
+
const { value, label } = model.frameColumns;
|
|
13
|
+
if (label === null) return deriveColumnValueOptions(model.valueColumn, await readDistinctValues(model.frame, value));
|
|
14
|
+
return deriveLabelledColumnValueOptions(model.valueColumn, await readLabelledValues(model.frame, {
|
|
15
|
+
value,
|
|
16
|
+
label
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
/** More distinct values than any picker can usefully list. */
|
|
20
|
+
const VALUES_LIMIT = 1e5;
|
|
21
|
+
async function readDistinctValues(frame, column) {
|
|
22
|
+
const response = await frameDriver().getUniqueValues(frame, {
|
|
23
|
+
columnId: column,
|
|
24
|
+
filters: [],
|
|
25
|
+
limit: VALUES_LIMIT
|
|
26
|
+
});
|
|
27
|
+
if (response.overflow) throw new Error(`The column has more than ${VALUES_LIMIT} distinct values`);
|
|
28
|
+
const values = [];
|
|
29
|
+
for (let row = 0; row < response.values.data.length; row++) {
|
|
30
|
+
const value = pTableValue(response.values, row, { na: null });
|
|
31
|
+
if (value !== null) values.push(String(value));
|
|
32
|
+
}
|
|
33
|
+
return values;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Every row of the value column with the label the label column holds at the same keys, or an
|
|
37
|
+
* empty label where it holds none. Rows without a value are left out.
|
|
38
|
+
*/
|
|
39
|
+
async function readLabelledValues(frame, columns) {
|
|
40
|
+
const request = {
|
|
41
|
+
src: {
|
|
42
|
+
type: "outer",
|
|
43
|
+
primary: {
|
|
44
|
+
type: "column",
|
|
45
|
+
column: columns.value
|
|
46
|
+
},
|
|
47
|
+
secondary: [{
|
|
48
|
+
type: "column",
|
|
49
|
+
column: columns.label
|
|
50
|
+
}]
|
|
51
|
+
},
|
|
52
|
+
filters: [],
|
|
53
|
+
sorting: []
|
|
54
|
+
};
|
|
55
|
+
const response = await frameDriver().calculateTableData(frame, request, {
|
|
56
|
+
offset: 0,
|
|
57
|
+
length: 100001
|
|
58
|
+
});
|
|
59
|
+
const values = columnData(response, columns.value);
|
|
60
|
+
const labels = columnData(response, columns.label);
|
|
61
|
+
if (values.data.length > VALUES_LIMIT) throw new Error(`The column has more than ${VALUES_LIMIT} rows`);
|
|
62
|
+
const rows = [];
|
|
63
|
+
for (let row = 0; row < values.data.length; row++) {
|
|
64
|
+
const value = pTableValue(values, row, { na: null });
|
|
65
|
+
if (value === null) continue;
|
|
66
|
+
const label = pTableValue(labels, row, { na: null });
|
|
67
|
+
rows.push({
|
|
68
|
+
value: String(value),
|
|
69
|
+
label: label === null ? "" : String(label)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return rows;
|
|
73
|
+
}
|
|
74
|
+
function columnData(response, column) {
|
|
75
|
+
const entry = response.find((item) => item.spec.type === "column" && item.spec.id === column);
|
|
76
|
+
if (entry === void 0) throw new Error(`The frame did not return column ${column}`);
|
|
77
|
+
return entry.data;
|
|
78
|
+
}
|
|
79
|
+
function frameDriver() {
|
|
80
|
+
if (typeof platforma === "undefined" || platforma.pFrameDriver === void 0) throw new Error("The frame driver is not available");
|
|
81
|
+
return platforma.pFrameDriver;
|
|
82
|
+
}
|
|
83
|
+
export { readColumnValueOptions };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=column_value_options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column_value_options.js","names":[],"sources":["../../src/pframe_utils/column_value_options.ts"],"sourcesContent":["import {\n pTableValue,\n type CalculateTableDataRequest,\n type FullPTableColumnData,\n type PFrameHandle,\n type PObjectId,\n} from \"@milaboratories/pl-model-common\";\nimport type { ColumnValueOption, ColumnValueOptionsModel } from \"../columns\";\nimport { deriveColumnValueOptions, deriveLabelledColumnValueOptions } from \"../columns\";\n\n/** A model whose value column is there to read. */\nexport type PresentColumnValueOptionsModel = Extract<ColumnValueOptionsModel, { type: \"present\" }>;\n\n/**\n * The options of a value picker, read in the UI through the frame of `model` (see\n * `deriveColumnValueOptions` and `deriveLabelledColumnValueOptions`). Missing values are not\n * offered; a value with a missing label labels itself. Rejects when the value column has more\n * distinct values than a picker can offer, or, with a label column, more rows than it reads.\n */\nexport async function readColumnValueOptions(\n model: PresentColumnValueOptionsModel,\n): Promise<ColumnValueOption[]> {\n const { value, label } = model.frameColumns;\n if (label === null) {\n return deriveColumnValueOptions(\n model.valueColumn,\n await readDistinctValues(model.frame, value),\n );\n }\n return deriveLabelledColumnValueOptions(\n model.valueColumn,\n await readLabelledValues(model.frame, { value, label }),\n );\n}\n\n// Internals\n\n/** More distinct values than any picker can usefully list. */\nconst VALUES_LIMIT = 100_000;\n\nasync function readDistinctValues(frame: PFrameHandle, column: PObjectId): Promise<string[]> {\n const response = await frameDriver().getUniqueValues(frame, {\n columnId: column,\n filters: [],\n limit: VALUES_LIMIT,\n });\n if (response.overflow) {\n throw new Error(`The column has more than ${VALUES_LIMIT} distinct values`);\n }\n\n const values: string[] = [];\n for (let row = 0; row < response.values.data.length; row++) {\n const value = pTableValue(response.values, row, { na: null });\n if (value !== null) values.push(String(value));\n }\n return values;\n}\n\n/**\n * Every row of the value column with the label the label column holds at the same keys, or an\n * empty label where it holds none. Rows without a value are left out.\n */\nasync function readLabelledValues(\n frame: PFrameHandle,\n columns: { readonly value: PObjectId; readonly label: PObjectId },\n): Promise<{ value: string; label: string }[]> {\n const request: CalculateTableDataRequest<PObjectId> = {\n src: {\n type: \"outer\",\n primary: { type: \"column\", column: columns.value },\n secondary: [{ type: \"column\", column: columns.label }],\n },\n filters: [],\n sorting: [],\n };\n // One row past the limit tells a column that has more rows than a picker reads.\n const response = await frameDriver().calculateTableData(frame, request, {\n offset: 0,\n length: VALUES_LIMIT + 1,\n });\n const values = columnData(response, columns.value);\n const labels = columnData(response, columns.label);\n if (values.data.length > VALUES_LIMIT) {\n throw new Error(`The column has more than ${VALUES_LIMIT} rows`);\n }\n\n const rows: { value: string; label: string }[] = [];\n for (let row = 0; row < values.data.length; row++) {\n const value = pTableValue(values, row, { na: null });\n if (value === null) continue;\n const label = pTableValue(labels, row, { na: null });\n rows.push({ value: String(value), label: label === null ? \"\" : String(label) });\n }\n return rows;\n}\n\nfunction columnData(\n response: readonly FullPTableColumnData[],\n column: PObjectId,\n): FullPTableColumnData[\"data\"] {\n const entry = response.find((item) => item.spec.type === \"column\" && item.spec.id === column);\n if (entry === undefined) throw new Error(`The frame did not return column ${column}`);\n return entry.data;\n}\n\nfunction frameDriver() {\n if (typeof platforma === \"undefined\" || platforma.pFrameDriver === undefined) {\n throw new Error(\"The frame driver is not available\");\n }\n return platforma.pFrameDriver;\n}\n"],"mappings":";;;;;;;;;;AAmBA,eAAsB,uBACpB,OAC8B;CAC9B,MAAM,EAAE,OAAO,UAAU,MAAM;CAC/B,IAAI,UAAU,MACZ,OAAO,yBACL,MAAM,aACN,MAAM,mBAAmB,MAAM,OAAO,KAAK,CAC7C;CAEF,OAAO,iCACL,MAAM,aACN,MAAM,mBAAmB,MAAM,OAAO;EAAE;EAAO;CAAM,CAAC,CACxD;AACF;;AAKA,MAAM,eAAe;AAErB,eAAe,mBAAmB,OAAqB,QAAsC;CAC3F,MAAM,WAAW,MAAM,YAAY,CAAC,CAAC,gBAAgB,OAAO;EAC1D,UAAU;EACV,SAAS,CAAC;EACV,OAAO;CACT,CAAC;CACD,IAAI,SAAS,UACX,MAAM,IAAI,MAAM,4BAA4B,aAAa,iBAAiB;CAG5E,MAAM,SAAmB,CAAC;CAC1B,KAAK,IAAI,MAAM,GAAG,MAAM,SAAS,OAAO,KAAK,QAAQ,OAAO;EAC1D,MAAM,QAAQ,YAAY,SAAS,QAAQ,KAAK,EAAE,IAAI,KAAK,CA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mC;CAErD,OAAO,UAAU;AACnB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_columns = require("./columns.cjs");
|
|
2
|
+
const require_column_value_options = require("./column_value_options.cjs");
|
|
2
3
|
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
3
4
|
let es_toolkit = require("es-toolkit");
|
|
4
5
|
// src/pframe_utils/index.ts
|
|
@@ -285,5 +286,6 @@ exports.getRequestColumnsFromSelectedSources = getRequestColumnsFromSelectedSour
|
|
|
285
286
|
exports.getSingleColumnData = getSingleColumnData;
|
|
286
287
|
exports.getUniqueAxisValuesWithLabels = getUniqueAxisValuesWithLabels;
|
|
287
288
|
exports.getUniqueSourceValuesWithLabels = getUniqueSourceValuesWithLabels;
|
|
289
|
+
exports.readColumnValueOptions = require_column_value_options.readColumnValueOptions;
|
|
288
290
|
|
|
289
291
|
//# sourceMappingURL=index.cjs.map
|