@platforma-sdk/model 1.86.3 → 1.87.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/columns/column_providers/providers.cjs +2 -2
- 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 +2 -2
- 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/data_column.cjs +21 -50
- package/dist/columns/data_column.cjs.map +1 -1
- package/dist/columns/data_column.d.ts +10 -22
- package/dist/columns/data_column.d.ts.map +1 -1
- package/dist/columns/data_column.js +23 -51
- package/dist/columns/data_column.js.map +1 -1
- package/dist/columns/index.cjs +0 -1
- package/dist/columns/index.d.ts +2 -2
- package/dist/columns/index.js +2 -2
- package/dist/components/PlDatasetSelector/build_dataset_options.cjs +1 -1
- package/dist/components/PlDatasetSelector/build_dataset_options.cjs.map +1 -1
- package/dist/components/PlDatasetSelector/build_dataset_options.js +2 -2
- package/dist/components/PlDatasetSelector/build_dataset_options.js.map +1 -1
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/package.json +7 -7
- package/src/columns/__test_helpers__/collection_driver.ts +10 -8
- package/src/columns/__test_helpers__/stub_registry.ts +6 -8
- package/src/columns/column_providers/providers.test.ts +45 -0
- package/src/columns/column_providers/providers.ts +7 -6
- package/src/columns/column_recipes/column_recipes.test.ts +11 -15
- package/src/columns/column_recipes/index.ts +2 -3
- package/src/columns/columns_collection.test.ts +39 -0
- package/src/columns/data_column.test.ts +20 -11
- package/src/columns/data_column.ts +24 -49
- package/src/components/PlDatasetSelector/build_dataset_options.ts +7 -4
- package/src/labels/derive_distinct_labels.test.ts +1 -1
|
@@ -1,29 +1,10 @@
|
|
|
1
1
|
import { ColumnOverriddenRecipe } from "./column_recipes/column_overrided_recipe.js";
|
|
2
2
|
import { getCtxProviders } from "./column_providers/index.js";
|
|
3
|
-
import { ColumnRegistry, createGlobalPObjectId, isPColumn, isPlRef } from "@milaboratories/pl-model-common";
|
|
3
|
+
import { ColumnRegistry, createGlobalPObjectId, isPColumn, isPColumnSpec, isPlRef } from "@milaboratories/pl-model-common";
|
|
4
4
|
import { isNil } from "es-toolkit";
|
|
5
5
|
import { LRUCache } from "lru-cache";
|
|
6
6
|
// src/columns/data_column.ts
|
|
7
7
|
/**
|
|
8
|
-
* Thrown by leaf-recipe factories when the requested column is provably
|
|
9
|
-
* absent in the active render ctx — i.e. every relevant accessor reports
|
|
10
|
-
* `inputsLocked` and the column did not appear. Distinct from the
|
|
11
|
-
* `undefined` return that the factories still use for the "resolving" case
|
|
12
|
-
* (the column may still appear later).
|
|
13
|
-
*
|
|
14
|
-
* Catch at the boundary (resolver / filter+sort wiring / data-table assembly)
|
|
15
|
-
* when partial absence should be surfaced to the user rather than silently
|
|
16
|
-
* producing an empty result.
|
|
17
|
-
*/
|
|
18
|
-
var ColumnAbsentError = class extends Error {
|
|
19
|
-
id;
|
|
20
|
-
constructor(id) {
|
|
21
|
-
super(`Column is absent in the active render ctx and will not appear: ${id}`);
|
|
22
|
-
this.id = id;
|
|
23
|
-
this.name = "ColumnAbsentError";
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
8
|
* The leaf-recipe building block: a {@link DataColumnRecipe} whose `id` is a bare
|
|
28
9
|
* {@link PObjectId} and whose readers are bound to a single tree-accessor
|
|
29
10
|
* leaf. Layered encodings (Overridden / Discovered / Filtered) are reified
|
|
@@ -75,29 +56,15 @@ var DataColumnImpl = class DataColumnImpl {
|
|
|
75
56
|
}
|
|
76
57
|
/**
|
|
77
58
|
* Resolve via the ambient {@link ColumnRegistry}. Spec is resolved eagerly:
|
|
78
|
-
* returns `undefined`
|
|
79
|
-
*
|
|
80
|
-
*
|
|
59
|
+
* returns `undefined` unless the id names a column whose spec is readable in
|
|
60
|
+
* this ctx — while it is resolving, when it is absent, and when the id names
|
|
61
|
+
* an export that is not a column (a `kind: "File"` object, for example).
|
|
81
62
|
* Data and dataStatus stay lazy.
|
|
82
63
|
*/
|
|
83
64
|
static fromId(id, { ctx } = {}) {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (registry.isFinal()) throw new ColumnAbsentError(id);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const spec = readSpecAccessor(leaf);
|
|
91
|
-
if (isNil(spec)) {
|
|
92
|
-
if (leaf.accessor.getInputsLocked()) throw new ColumnAbsentError(id);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (!spec.hasData()) return void 0;
|
|
96
|
-
return new DataColumnImpl(id, {
|
|
97
|
-
getSpec: () => spec.getDataAsJson(),
|
|
98
|
-
getData: () => readDataAccessor(leaf),
|
|
99
|
-
getDataStatus: () => readDataStatus(leaf)
|
|
100
|
-
});
|
|
65
|
+
const leaf = new ColumnRegistry(getCtxProviders({ ctx })).resolve(id);
|
|
66
|
+
if (isNil(leaf)) return void 0;
|
|
67
|
+
return DataColumnImpl.fromAccessor(leaf);
|
|
101
68
|
}
|
|
102
69
|
/** {@link PlRef} wrapper over {@link fromId}. */
|
|
103
70
|
static fromPlRef(ref) {
|
|
@@ -105,18 +72,15 @@ var DataColumnImpl = class DataColumnImpl {
|
|
|
105
72
|
}
|
|
106
73
|
/**
|
|
107
74
|
* Bind directly to an accessor-backed {@link LeafEntry} — no registry.
|
|
108
|
-
*
|
|
109
|
-
*
|
|
75
|
+
* Returns `undefined` unless the leaf's spec is readable and is a column
|
|
76
|
+
* spec: while the spec is resolving, when it is absent, and for an export
|
|
77
|
+
* that is not a column.
|
|
110
78
|
*/
|
|
111
79
|
static fromAccessor(entry) {
|
|
112
|
-
const spec =
|
|
113
|
-
if (
|
|
114
|
-
if (entry.accessor.getInputsLocked()) throw new ColumnAbsentError(entry.id);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if (!spec.hasData()) return void 0;
|
|
80
|
+
const spec = readSpec(entry);
|
|
81
|
+
if (spec === void 0 || !isPColumnSpec(spec)) return void 0;
|
|
118
82
|
return new DataColumnImpl(entry.id, {
|
|
119
|
-
getSpec: () => spec
|
|
83
|
+
getSpec: () => spec,
|
|
120
84
|
getData: () => readDataAccessor(entry),
|
|
121
85
|
getDataStatus: () => readDataStatus(entry)
|
|
122
86
|
});
|
|
@@ -138,7 +102,9 @@ var DataColumnImpl = class DataColumnImpl {
|
|
|
138
102
|
* Distinguishes `present` / `resolving` / `absent` for a {@link PObjectId}
|
|
139
103
|
* in the active render ctx. Falls back to the registry's `isFinal()`
|
|
140
104
|
* when the id has no entry — only then we can say `absent` instead of
|
|
141
|
-
* `resolving`.
|
|
105
|
+
* `resolving`. The status tells only whether the spec is readable: for an
|
|
106
|
+
* export that is not a column it is `present`, and the factories return
|
|
107
|
+
* `undefined`.
|
|
142
108
|
*/
|
|
143
109
|
static getStatusById(id, { ctx } = {}) {
|
|
144
110
|
const registry = new ColumnRegistry(getCtxProviders({ ctx }));
|
|
@@ -207,6 +173,12 @@ const readSpecAccessor = memoizeByEntry(({ accessor, name }) => accessor.travers
|
|
|
207
173
|
assertFieldType: "Input",
|
|
208
174
|
ignoreError: true
|
|
209
175
|
}));
|
|
176
|
+
/** The leaf's spec, or `undefined` until the spec resource has data. */
|
|
177
|
+
const readSpec = memoizeByEntry((entry) => {
|
|
178
|
+
const spec = readSpecAccessor(entry);
|
|
179
|
+
if (isNil(spec) || !spec.hasData()) return void 0;
|
|
180
|
+
return spec.getDataAsJson();
|
|
181
|
+
});
|
|
210
182
|
/**
|
|
211
183
|
* Per-entry counterpart to {@link readDataStatus}: tells whether the leaf's
|
|
212
184
|
* **spec** can be read in this ctx, and — for the negative cases —
|
|
@@ -242,6 +214,6 @@ function memoizeByEntry(fn) {
|
|
|
242
214
|
return hit.value;
|
|
243
215
|
};
|
|
244
216
|
}
|
|
245
|
-
export {
|
|
217
|
+
export { DataColumn, DataColumnImpl, isDataColumn };
|
|
246
218
|
|
|
247
219
|
//# sourceMappingURL=data_column.js.map
|
|
@@ -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 isPlRef,\n PlRef,\n PObjectId,\n type ColumnUniversalId,\n type LeafEntry,\n type PColumn,\n type PColumnSpec,\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 — the column will not exist in this ctx.\n * 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 const spec = readSpecAccessor(leaf);\n if (isNil(spec)) {\n if (leaf.accessor.getInputsLocked()) throw new ColumnAbsentError(id);\n return undefined;\n }\n if (!spec.hasData()) return undefined;\n return new DataColumnImpl(id, {\n getSpec: () => spec.getDataAsJson<PColumnSpec>(),\n getData: () => readDataAccessor(leaf),\n getDataStatus: () => readDataStatus(leaf),\n });\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`. Returns `undefined` while still resolving.\n */\n static fromAccessor(entry: LeafEntry<TreeNodeAccessor>): undefined | DataColumnRecipe<PObjectId> {\n const spec = readSpecAccessor(entry);\n if (isNil(spec)) {\n if (entry.accessor.getInputsLocked()) throw new ColumnAbsentError(entry.id);\n return undefined;\n }\n if (!spec.hasData()) return undefined;\n return new DataColumnImpl(entry.id, {\n getSpec: () => spec.getDataAsJson<PColumnSpec>(),\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`.\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/**\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":";;;;;;;;;;;;;;;;;AAgEA,IAAa,oBAAb,cAAuC,MAAM;CACf;CAA5B,YAAY,IAAuC;EACjD,MAAM,kEAAkE,IAAI;EADlD,KAAA,KAAA;EAE1B,KAAK,OAAO;CACd;AACF;;;;;;;;;;AAWA,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;;;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{\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;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require_providers.AccessorColumnsProvider;
|
|
|
15
15
|
exports.AccessorColumnsProviderImpl = require_providers.AccessorColumnsProviderImpl;
|
|
16
16
|
exports.ArrayColumnsProvider = require_providers.ArrayColumnsProvider;
|
|
17
17
|
exports.Column = require_column.Column;
|
|
18
|
-
exports.ColumnAbsentError = require_data_column.ColumnAbsentError;
|
|
19
18
|
exports.ColumnDiscoveredRecipe = require_column_discovered_recipe.ColumnDiscoveredRecipe;
|
|
20
19
|
exports.ColumnFilteredRecipe = require_column_filtered_recipe.ColumnFilteredRecipe;
|
|
21
20
|
exports.ColumnOverriddenRecipe = require_column_overrided_recipe.ColumnOverriddenRecipe;
|
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,4 @@ 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
|
-
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column,
|
|
16
|
+
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, ColumnOverriddenRecipe, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsProvider, ColumnsSource, ColumnsSourceShorthand, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DatasetAxes, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, type SpecQuery, SplitAxis, SplitByAxesOpts, _ctxProvidersCache, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveAxisValuesLabels, deriveColumnOptions, 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,4 @@ 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
|
-
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column,
|
|
14
|
+
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column, ColumnDiscoveredRecipe, ColumnFilteredRecipe, ColumnOverriddenRecipe, ColumnRecipe, ColumnsCollection, ColumnsCollectionImpl, ColumnsProvider, DataColumn, DataColumnImpl, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, _ctxProvidersCache, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveAxisValuesLabels, deriveColumnOptions, deriveRecipeOptions, describePeerLinks, findPeerLinks, getCtxProviders, getResultPoolDatasetAxes, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isColumn, isColumnProvider, isColumnsCollection, isDataColumn, isLeafColumn, peerLinkedLast, queriesQualifications, splitByAxes, toColumnProvider };
|
|
@@ -18,7 +18,7 @@ function toPredicate(opt) {
|
|
|
18
18
|
function buildDatasetOptions(ctx, opts) {
|
|
19
19
|
const primaryPredicate = toPredicate(opts?.primary);
|
|
20
20
|
const filterPredicate = toPredicate(opts?.filter);
|
|
21
|
-
const options = ctx.resultPool.getOptions(primaryPredicate, { refsWithEnrichments: opts?.requireEnrichments ?? true });
|
|
21
|
+
const options = ctx.resultPool.getOptions((spec) => (0, _milaboratories_pl_model_common.isPColumnSpec)(spec) && primaryPredicate(spec), { refsWithEnrichments: opts?.requireEnrichments ?? true });
|
|
22
22
|
if (options.length === 0) return [];
|
|
23
23
|
const refMap = require_filter_discovery.buildRefMap(ctx.resultPool.getSpecs().entries);
|
|
24
24
|
const withEnrichments = opts?.withEnrichments ?? false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_dataset_options.cjs","names":["multiColumnSelectorsToPredicate","buildRefMap","ColumnsProvider","getCtxProviders","findFilterColumns","filterMatchesToOptions","findEnrichmentColumns","enrichmentVariantsToRefs"],"sources":["../../../src/components/PlDatasetSelector/build_dataset_options.ts"],"sourcesContent":["import type { MultiColumnSelector, Option, PObjectSpec } from \"@milaboratories/pl-model-common\";\nimport { multiColumnSelectorsToPredicate } from \"@milaboratories/pl-model-common\";\nimport type { DeriveLabelsOptions } from \"../../labels/derive_distinct_labels\";\nimport type { RenderCtxBase } from \"../../render\";\nimport type { DatasetOption } from \"./dataset_selection\";\nimport { buildRefMap, filterMatchesToOptions, findFilterColumns } from \"./filter_discovery\";\nimport { enrichmentVariantsToRefs, findEnrichmentColumns } from \"./enrichment_discovery\";\nimport { ColumnsProvider, getCtxProviders } from \"../../columns\";\n\ntype SpecPredicateOption =\n | MultiColumnSelector\n | MultiColumnSelector[]\n | ((spec: PObjectSpec) => boolean);\n\nfunction toPredicate(opt: SpecPredicateOption | undefined): (spec: PObjectSpec) => boolean {\n if (opt === undefined) return () => true;\n return typeof opt === \"function\" ? opt : multiColumnSelectorsToPredicate(opt);\n}\n\nexport type BuildDatasetOptions = {\n /** Which result pool columns qualify as datasets. Defaults to all. */\n primary?: SpecPredicateOption;\n /**\n * Restricts which result pool columns are considered as filters. Intersected\n * with the built-in `pl7.app/isSubset: \"true\"` constraint. Defaults to\n * accept-all.\n */\n filter?: SpecPredicateOption;\n /**\n * Formatting options forwarded to label derivation for both filter and\n * enrichment rows. `formatters.native` on the filter path is overridden\n * — see `FilterMatchOptions.labelOptions`.\n */\n labelOptions?: DeriveLabelsOptions;\n /**\n * Enables enrichment discovery and filters hits attached to\n * `DatasetOption.enrichments`. Use `() => true` to accept all; omit to disable.\n */\n withEnrichments?: SpecPredicateOption;\n /** Maximum linker hops considered. Only used when `withEnrichments` is set. */\n enrichmentMaxHops?: number;\n /**\n * Whether the dataset refs in the returned options carry `requireEnrichments: true`.\n * A block that stores such a ref depends on every block that enriches the dataset.\n * Set `false` for a block that only needs the dataset and its filters. Defaults to `true`.\n */\n requireEnrichments?: boolean;\n};\n\n/**\n * Usage:\n * ```ts\n * .output(\"datasetOptions\", (ctx) => buildDatasetOptions(ctx))\n * ```\n */\nexport function buildDatasetOptions(\n ctx: RenderCtxBase,\n opts?: BuildDatasetOptions,\n): DatasetOption[] | undefined {\n const primaryPredicate = toPredicate(opts?.primary);\n const filterPredicate = toPredicate(opts?.filter);\n\n const options = ctx.resultPool.getOptions(primaryPredicate
|
|
1
|
+
{"version":3,"file":"build_dataset_options.cjs","names":["multiColumnSelectorsToPredicate","isPColumnSpec","buildRefMap","ColumnsProvider","getCtxProviders","findFilterColumns","filterMatchesToOptions","findEnrichmentColumns","enrichmentVariantsToRefs"],"sources":["../../../src/components/PlDatasetSelector/build_dataset_options.ts"],"sourcesContent":["import type { MultiColumnSelector, Option, PObjectSpec } from \"@milaboratories/pl-model-common\";\nimport { isPColumnSpec, multiColumnSelectorsToPredicate } from \"@milaboratories/pl-model-common\";\nimport type { DeriveLabelsOptions } from \"../../labels/derive_distinct_labels\";\nimport type { RenderCtxBase } from \"../../render\";\nimport type { DatasetOption } from \"./dataset_selection\";\nimport { buildRefMap, filterMatchesToOptions, findFilterColumns } from \"./filter_discovery\";\nimport { enrichmentVariantsToRefs, findEnrichmentColumns } from \"./enrichment_discovery\";\nimport { ColumnsProvider, getCtxProviders } from \"../../columns\";\n\ntype SpecPredicateOption =\n | MultiColumnSelector\n | MultiColumnSelector[]\n | ((spec: PObjectSpec) => boolean);\n\nfunction toPredicate(opt: SpecPredicateOption | undefined): (spec: PObjectSpec) => boolean {\n if (opt === undefined) return () => true;\n return typeof opt === \"function\" ? opt : multiColumnSelectorsToPredicate(opt);\n}\n\nexport type BuildDatasetOptions = {\n /** Which result pool columns qualify as datasets. Defaults to all. */\n primary?: SpecPredicateOption;\n /**\n * Restricts which result pool columns are considered as filters. Intersected\n * with the built-in `pl7.app/isSubset: \"true\"` constraint. Defaults to\n * accept-all.\n */\n filter?: SpecPredicateOption;\n /**\n * Formatting options forwarded to label derivation for both filter and\n * enrichment rows. `formatters.native` on the filter path is overridden\n * — see `FilterMatchOptions.labelOptions`.\n */\n labelOptions?: DeriveLabelsOptions;\n /**\n * Enables enrichment discovery and filters hits attached to\n * `DatasetOption.enrichments`. Use `() => true` to accept all; omit to disable.\n */\n withEnrichments?: SpecPredicateOption;\n /** Maximum linker hops considered. Only used when `withEnrichments` is set. */\n enrichmentMaxHops?: number;\n /**\n * Whether the dataset refs in the returned options carry `requireEnrichments: true`.\n * A block that stores such a ref depends on every block that enriches the dataset.\n * Set `false` for a block that only needs the dataset and its filters. Defaults to `true`.\n */\n requireEnrichments?: boolean;\n};\n\n/**\n * Usage:\n * ```ts\n * .output(\"datasetOptions\", (ctx) => buildDatasetOptions(ctx))\n * ```\n */\nexport function buildDatasetOptions(\n ctx: RenderCtxBase,\n opts?: BuildDatasetOptions,\n): DatasetOption[] | undefined {\n const primaryPredicate = toPredicate(opts?.primary);\n const filterPredicate = toPredicate(opts?.filter);\n\n const options = ctx.resultPool.getOptions(\n (spec) => isPColumnSpec(spec) && primaryPredicate(spec),\n {\n refsWithEnrichments: opts?.requireEnrichments ?? true,\n },\n );\n if (options.length === 0) return [];\n\n const refMap = buildRefMap(ctx.resultPool.getSpecs().entries);\n\n const withEnrichments = opts?.withEnrichments ?? false;\n const filterSource = ColumnsProvider(ctx.ctx.getUpstreamBlockCtx());\n // Hoist providers once: getCtxProviders walks the full output tree, so\n // calling it per dataset option would be O(N × tree).\n const enrichmentSources = withEnrichments ? getCtxProviders(ctx) : undefined;\n\n return options.map((primary: Option): DatasetOption => {\n const datasetSpec = ctx.resultPool.getPColumnSpecByRef(primary.ref);\n if (!datasetSpec) return { primary };\n\n const filterMatches = findFilterColumns({\n sources: [filterSource],\n anchorSpec: datasetSpec,\n }).filter((m) => filterPredicate(m.getSpec()!));\n\n const filters =\n filterMatches.length === 0\n ? undefined\n : filterMatchesToOptions(filterMatches, {\n refsByObjectId: refMap,\n datasetSpec,\n labelOptions: opts?.labelOptions,\n });\n\n let enrichments;\n if (enrichmentSources && withEnrichments) {\n const enrichmentVariants = findEnrichmentColumns({\n sources: enrichmentSources,\n anchorSpec: datasetSpec,\n maxHops: opts?.enrichmentMaxHops,\n ...(typeof withEnrichments === \"function\"\n ? { predicate: withEnrichments }\n : { include: withEnrichments }),\n });\n if (enrichmentVariants.length > 0) {\n enrichments = enrichmentVariantsToRefs(enrichmentVariants, opts?.labelOptions);\n }\n }\n\n return {\n primary,\n ...(filters !== undefined && filters.length > 0 ? { filters } : {}),\n ...(enrichments !== undefined && enrichments.length > 0 ? { enrichments } : {}),\n };\n });\n}\n"],"mappings":";;;;;;;AAcA,SAAS,YAAY,KAAsE;CACzF,IAAI,QAAQ,KAAA,GAAW,aAAa;CACpC,OAAO,OAAO,QAAQ,aAAa,OAAA,GAAMA,gCAAAA,gCAAAA,CAAgC,GAAG;AAC9E;;;;;;;AAsCA,SAAgB,oBACd,KACA,MAC6B;CAC7B,MAAM,mBAAmB,YAAY,MAAM,OAAO;CAClD,MAAM,kBAAkB,YAAY,MAAM,MAAM;CAEhD,MAAM,UAAU,IAAI,WAAW,YAC5B,UAAA,GAASC,gCAAAA,cAAAA,CAAc,IAAI,KAAK,iBAAiB,IAAI,GACtD,EACE,qBAAqB,MAAM,sBAAsB,KACnD,CACF;CACA,IAAI,QAAQ,WAAW,GAAG,OAAO,CAAC;CAElC,MAAM,SAASC,yBAAAA,YAAY,IAAI,WAAW,SAAS,CAAC,CAAC,OAAO;CAE5D,MAAM,kBAAkB,MAAM,mBAAmB;CACjD,MAAM,eAAeC,kBAAAA,gBAAgB,IAAI,IAAI,oBAAoB,CAAC;CAGlE,MAAM,oBAAoB,kBAAkBC,cAAAA,gBAAgB,GAAG,IAAI,KAAA;CAEnE,OAAO,QAAQ,KAAK,YAAmC;EACrD,MAAM,cAAc,IAAI,WAAW,oBAAoB,QAAQ,GAAG;EAClE,IAAI,CAAC,aAAa,OAAO,EAAE,QAAQ;EAEnC,MAAM,gBAAgBC,yBAAAA,kBAAkB;GACtC,SAAS,CAAC,YAAY;GACtB,YAAY;EACd,CAAC,CAAC,CAAC,QAAQ,MAAM,gBAAgB,EAAE,QAAQ,CAAE,CAAC;EAE9C,MAAM,UACJ,cAAc,WAAW,IACrB,KAAA,IACAC,yBAAAA,uBAAuB,eAAe;GACpC,gBAAgB;GAChB;GACA,cAAc,MAAM;EACtB,CAAC;EAEP,IAAI;EACJ,IAAI,qBAAqB,iBAAiB;GACxC,MAAM,qBAAqBC,6BAAAA,sBAAsB;IAC/C,SAAS;IACT,YAAY;IACZ,SAAS,MAAM;IACf,GAAI,OAAO,oBAAoB,aAC3B,EAAE,WAAW,gBAAgB,IAC7B,EAAE,SAAS,gBAAgB;GACjC,CAAC;GACD,IAAI,mBAAmB,SAAS,GAC9B,cAAcC,6BAAAA,yBAAyB,oBAAoB,MAAM,YAAY;EAEjF;EAEA,OAAO;GACL;GACA,GAAI,YAAY,KAAA,KAAa,QAAQ,SAAS,IAAI,EAAE,QAAQ,IAAI,CAAC;GACjE,GAAI,gBAAgB,KAAA,KAAa,YAAY,SAAS,IAAI,EAAE,YAAY,IAAI,CAAC;EAC/E;CACF,CAAC;AACH"}
|
|
@@ -3,7 +3,7 @@ import { getCtxProviders } from "../../columns/column_providers/index.js";
|
|
|
3
3
|
import "../../columns/index.js";
|
|
4
4
|
import { buildRefMap, filterMatchesToOptions, findFilterColumns } from "./filter_discovery.js";
|
|
5
5
|
import { enrichmentVariantsToRefs, findEnrichmentColumns } from "./enrichment_discovery.js";
|
|
6
|
-
import { multiColumnSelectorsToPredicate } from "@milaboratories/pl-model-common";
|
|
6
|
+
import { isPColumnSpec, multiColumnSelectorsToPredicate } from "@milaboratories/pl-model-common";
|
|
7
7
|
// src/components/PlDatasetSelector/build_dataset_options.ts
|
|
8
8
|
function toPredicate(opt) {
|
|
9
9
|
if (opt === void 0) return () => true;
|
|
@@ -18,7 +18,7 @@ function toPredicate(opt) {
|
|
|
18
18
|
function buildDatasetOptions(ctx, opts) {
|
|
19
19
|
const primaryPredicate = toPredicate(opts?.primary);
|
|
20
20
|
const filterPredicate = toPredicate(opts?.filter);
|
|
21
|
-
const options = ctx.resultPool.getOptions(primaryPredicate, { refsWithEnrichments: opts?.requireEnrichments ?? true });
|
|
21
|
+
const options = ctx.resultPool.getOptions((spec) => isPColumnSpec(spec) && primaryPredicate(spec), { refsWithEnrichments: opts?.requireEnrichments ?? true });
|
|
22
22
|
if (options.length === 0) return [];
|
|
23
23
|
const refMap = buildRefMap(ctx.resultPool.getSpecs().entries);
|
|
24
24
|
const withEnrichments = opts?.withEnrichments ?? false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_dataset_options.js","names":[],"sources":["../../../src/components/PlDatasetSelector/build_dataset_options.ts"],"sourcesContent":["import type { MultiColumnSelector, Option, PObjectSpec } from \"@milaboratories/pl-model-common\";\nimport { multiColumnSelectorsToPredicate } from \"@milaboratories/pl-model-common\";\nimport type { DeriveLabelsOptions } from \"../../labels/derive_distinct_labels\";\nimport type { RenderCtxBase } from \"../../render\";\nimport type { DatasetOption } from \"./dataset_selection\";\nimport { buildRefMap, filterMatchesToOptions, findFilterColumns } from \"./filter_discovery\";\nimport { enrichmentVariantsToRefs, findEnrichmentColumns } from \"./enrichment_discovery\";\nimport { ColumnsProvider, getCtxProviders } from \"../../columns\";\n\ntype SpecPredicateOption =\n | MultiColumnSelector\n | MultiColumnSelector[]\n | ((spec: PObjectSpec) => boolean);\n\nfunction toPredicate(opt: SpecPredicateOption | undefined): (spec: PObjectSpec) => boolean {\n if (opt === undefined) return () => true;\n return typeof opt === \"function\" ? opt : multiColumnSelectorsToPredicate(opt);\n}\n\nexport type BuildDatasetOptions = {\n /** Which result pool columns qualify as datasets. Defaults to all. */\n primary?: SpecPredicateOption;\n /**\n * Restricts which result pool columns are considered as filters. Intersected\n * with the built-in `pl7.app/isSubset: \"true\"` constraint. Defaults to\n * accept-all.\n */\n filter?: SpecPredicateOption;\n /**\n * Formatting options forwarded to label derivation for both filter and\n * enrichment rows. `formatters.native` on the filter path is overridden\n * — see `FilterMatchOptions.labelOptions`.\n */\n labelOptions?: DeriveLabelsOptions;\n /**\n * Enables enrichment discovery and filters hits attached to\n * `DatasetOption.enrichments`. Use `() => true` to accept all; omit to disable.\n */\n withEnrichments?: SpecPredicateOption;\n /** Maximum linker hops considered. Only used when `withEnrichments` is set. */\n enrichmentMaxHops?: number;\n /**\n * Whether the dataset refs in the returned options carry `requireEnrichments: true`.\n * A block that stores such a ref depends on every block that enriches the dataset.\n * Set `false` for a block that only needs the dataset and its filters. Defaults to `true`.\n */\n requireEnrichments?: boolean;\n};\n\n/**\n * Usage:\n * ```ts\n * .output(\"datasetOptions\", (ctx) => buildDatasetOptions(ctx))\n * ```\n */\nexport function buildDatasetOptions(\n ctx: RenderCtxBase,\n opts?: BuildDatasetOptions,\n): DatasetOption[] | undefined {\n const primaryPredicate = toPredicate(opts?.primary);\n const filterPredicate = toPredicate(opts?.filter);\n\n const options = ctx.resultPool.getOptions(primaryPredicate
|
|
1
|
+
{"version":3,"file":"build_dataset_options.js","names":[],"sources":["../../../src/components/PlDatasetSelector/build_dataset_options.ts"],"sourcesContent":["import type { MultiColumnSelector, Option, PObjectSpec } from \"@milaboratories/pl-model-common\";\nimport { isPColumnSpec, multiColumnSelectorsToPredicate } from \"@milaboratories/pl-model-common\";\nimport type { DeriveLabelsOptions } from \"../../labels/derive_distinct_labels\";\nimport type { RenderCtxBase } from \"../../render\";\nimport type { DatasetOption } from \"./dataset_selection\";\nimport { buildRefMap, filterMatchesToOptions, findFilterColumns } from \"./filter_discovery\";\nimport { enrichmentVariantsToRefs, findEnrichmentColumns } from \"./enrichment_discovery\";\nimport { ColumnsProvider, getCtxProviders } from \"../../columns\";\n\ntype SpecPredicateOption =\n | MultiColumnSelector\n | MultiColumnSelector[]\n | ((spec: PObjectSpec) => boolean);\n\nfunction toPredicate(opt: SpecPredicateOption | undefined): (spec: PObjectSpec) => boolean {\n if (opt === undefined) return () => true;\n return typeof opt === \"function\" ? opt : multiColumnSelectorsToPredicate(opt);\n}\n\nexport type BuildDatasetOptions = {\n /** Which result pool columns qualify as datasets. Defaults to all. */\n primary?: SpecPredicateOption;\n /**\n * Restricts which result pool columns are considered as filters. Intersected\n * with the built-in `pl7.app/isSubset: \"true\"` constraint. Defaults to\n * accept-all.\n */\n filter?: SpecPredicateOption;\n /**\n * Formatting options forwarded to label derivation for both filter and\n * enrichment rows. `formatters.native` on the filter path is overridden\n * — see `FilterMatchOptions.labelOptions`.\n */\n labelOptions?: DeriveLabelsOptions;\n /**\n * Enables enrichment discovery and filters hits attached to\n * `DatasetOption.enrichments`. Use `() => true` to accept all; omit to disable.\n */\n withEnrichments?: SpecPredicateOption;\n /** Maximum linker hops considered. Only used when `withEnrichments` is set. */\n enrichmentMaxHops?: number;\n /**\n * Whether the dataset refs in the returned options carry `requireEnrichments: true`.\n * A block that stores such a ref depends on every block that enriches the dataset.\n * Set `false` for a block that only needs the dataset and its filters. Defaults to `true`.\n */\n requireEnrichments?: boolean;\n};\n\n/**\n * Usage:\n * ```ts\n * .output(\"datasetOptions\", (ctx) => buildDatasetOptions(ctx))\n * ```\n */\nexport function buildDatasetOptions(\n ctx: RenderCtxBase,\n opts?: BuildDatasetOptions,\n): DatasetOption[] | undefined {\n const primaryPredicate = toPredicate(opts?.primary);\n const filterPredicate = toPredicate(opts?.filter);\n\n const options = ctx.resultPool.getOptions(\n (spec) => isPColumnSpec(spec) && primaryPredicate(spec),\n {\n refsWithEnrichments: opts?.requireEnrichments ?? true,\n },\n );\n if (options.length === 0) return [];\n\n const refMap = buildRefMap(ctx.resultPool.getSpecs().entries);\n\n const withEnrichments = opts?.withEnrichments ?? false;\n const filterSource = ColumnsProvider(ctx.ctx.getUpstreamBlockCtx());\n // Hoist providers once: getCtxProviders walks the full output tree, so\n // calling it per dataset option would be O(N × tree).\n const enrichmentSources = withEnrichments ? getCtxProviders(ctx) : undefined;\n\n return options.map((primary: Option): DatasetOption => {\n const datasetSpec = ctx.resultPool.getPColumnSpecByRef(primary.ref);\n if (!datasetSpec) return { primary };\n\n const filterMatches = findFilterColumns({\n sources: [filterSource],\n anchorSpec: datasetSpec,\n }).filter((m) => filterPredicate(m.getSpec()!));\n\n const filters =\n filterMatches.length === 0\n ? undefined\n : filterMatchesToOptions(filterMatches, {\n refsByObjectId: refMap,\n datasetSpec,\n labelOptions: opts?.labelOptions,\n });\n\n let enrichments;\n if (enrichmentSources && withEnrichments) {\n const enrichmentVariants = findEnrichmentColumns({\n sources: enrichmentSources,\n anchorSpec: datasetSpec,\n maxHops: opts?.enrichmentMaxHops,\n ...(typeof withEnrichments === \"function\"\n ? { predicate: withEnrichments }\n : { include: withEnrichments }),\n });\n if (enrichmentVariants.length > 0) {\n enrichments = enrichmentVariantsToRefs(enrichmentVariants, opts?.labelOptions);\n }\n }\n\n return {\n primary,\n ...(filters !== undefined && filters.length > 0 ? { filters } : {}),\n ...(enrichments !== undefined && enrichments.length > 0 ? { enrichments } : {}),\n };\n });\n}\n"],"mappings":";;;;;;;AAcA,SAAS,YAAY,KAAsE;CACzF,IAAI,QAAQ,KAAA,GAAW,aAAa;CACpC,OAAO,OAAO,QAAQ,aAAa,MAAM,gCAAgC,GAAG;AAC9E;;;;;;;AAsCA,SAAgB,oBACd,KACA,MAC6B;CAC7B,MAAM,mBAAmB,YAAY,MAAM,OAAO;CAClD,MAAM,kBAAkB,YAAY,MAAM,MAAM;CAEhD,MAAM,UAAU,IAAI,WAAW,YAC5B,SAAS,cAAc,IAAI,KAAK,iBAAiB,IAAI,GACtD,EACE,qBAAqB,MAAM,sB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age_facade.BlockStorageFacadeCallbacks;
|
|
78
78
|
exports.BlockStorageFacadeHandles = require_block_storage_facade.BlockStorageFacadeHandles;
|
|
79
79
|
exports.Column = require_column.Column;
|
|
80
|
-
exports.ColumnAbsentError = require_data_column.ColumnAbsentError;
|
|
81
80
|
exports.ColumnDiscoveredRecipe = require_column_discovered_recipe.ColumnDiscoveredRecipe;
|
|
82
81
|
exports.ColumnFilteredRecipe = require_column_filtered_recipe.ColumnFilteredRecipe;
|
|
83
82
|
exports.ColumnOverriddenRecipe = require_column_overrided_recipe.ColumnOverriddenRecipe;
|
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";
|
|
@@ -86,4 +86,4 @@ import "./services/index.js";
|
|
|
86
86
|
import { getEnvironmentValue } from "./env_value.js";
|
|
87
87
|
export * from "@milaboratories/pl-model-common";
|
|
88
88
|
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,
|
|
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, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, type ColumnOrderRule, ColumnOverriddenRecipe, ColumnProvider, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, 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, 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, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, type createPlDataTableOptionsV3, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, 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, 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";
|
|
@@ -68,4 +68,4 @@ import { getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, g
|
|
|
68
68
|
import { getEnvironmentValue } from "./env_value.js";
|
|
69
69
|
export * from "@milaboratories/pl-model-common";
|
|
70
70
|
export * from "@milaboratories/pl-error-like";
|
|
71
|
-
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockModelV3, BlockRenderCtx, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, Column,
|
|
71
|
+
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, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, 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, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
|
package/dist/package.cjs
CHANGED
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/model",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.87.0",
|
|
4
4
|
"description": "Platforma.bio SDK / Block Model",
|
|
5
5
|
"files": [
|
|
6
6
|
"./dist/**/*",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@milaboratories/helpers": "1.14.6",
|
|
29
29
|
"@milaboratories/pl-error-like": "1.12.10",
|
|
30
|
-
"@milaboratories/pl-model-common": "1.54.
|
|
31
|
-
"@milaboratories/pl-model-middle-layer": "1.34.
|
|
32
|
-
"@milaboratories/ptabler-expression-js": "1.2.
|
|
30
|
+
"@milaboratories/pl-model-common": "1.54.2",
|
|
31
|
+
"@milaboratories/pl-model-middle-layer": "1.34.6",
|
|
32
|
+
"@milaboratories/ptabler-expression-js": "1.2.46",
|
|
33
33
|
"canonicalize": "~2.1.0",
|
|
34
34
|
"es-toolkit": "^1.39.10",
|
|
35
35
|
"fast-json-patch": "^3.1.1",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@milaboratories/build-configs": "2.0.2",
|
|
42
|
-
"@milaboratories/columns-collection-driver": "0.2.
|
|
43
|
-
"@milaboratories/pf-driver": "1.9.
|
|
44
|
-
"@milaboratories/pf-spec-driver": "1.5.
|
|
42
|
+
"@milaboratories/columns-collection-driver": "0.2.12",
|
|
43
|
+
"@milaboratories/pf-driver": "1.9.12",
|
|
44
|
+
"@milaboratories/pf-spec-driver": "1.5.12",
|
|
45
45
|
"@milaboratories/ts-builder": "1.7.3",
|
|
46
46
|
"@milaboratories/ts-configs": "1.4.0",
|
|
47
47
|
"@platforma-sdk/block-kind": "1.1.0",
|
|
@@ -18,11 +18,11 @@ import type {
|
|
|
18
18
|
ColumnsCollectionDriverHost,
|
|
19
19
|
ColumnsCollectionDriverModel,
|
|
20
20
|
LeafEntry,
|
|
21
|
-
PColumnSpec,
|
|
22
21
|
PObjectId,
|
|
22
|
+
PObjectSpec,
|
|
23
23
|
ServiceName,
|
|
24
24
|
} from "@milaboratories/pl-model-common";
|
|
25
|
-
import { extractPObjectId, Services } from "@milaboratories/pl-model-common";
|
|
25
|
+
import { extractPObjectId, isPColumnSpec, Services } from "@milaboratories/pl-model-common";
|
|
26
26
|
import { ColumnsCollectionDriverImpl } from "@milaboratories/columns-collection-driver";
|
|
27
27
|
import { SpecDriver } from "@milaboratories/pf-spec-driver";
|
|
28
28
|
import type { GlobalCfgRenderCtx } from "../../render/internal";
|
|
@@ -34,7 +34,7 @@ import { DataColumn, type DataColumnRecipe } from "../data_column";
|
|
|
34
34
|
export interface TestCollectionDriverHandle {
|
|
35
35
|
readonly driver: ColumnsCollectionDriverModel;
|
|
36
36
|
/** Register `(id → spec)` pairs the driver will see via `resolveSpec`. */
|
|
37
|
-
register(columns: ReadonlyArray<{ readonly id: PObjectId; readonly spec:
|
|
37
|
+
register(columns: ReadonlyArray<{ readonly id: PObjectId; readonly spec: PObjectSpec }>): void;
|
|
38
38
|
/**
|
|
39
39
|
* Install a minimal `globalThis.cfgRenderCtx` so `getService("columnsCollection")`
|
|
40
40
|
* resolves to this driver and registered columns are reachable via
|
|
@@ -72,7 +72,7 @@ const PFRAME_SPEC_METHODS: ReadonlyArray<string> = [
|
|
|
72
72
|
];
|
|
73
73
|
|
|
74
74
|
export function createTestCollectionDriver(): TestCollectionDriverHandle {
|
|
75
|
-
const specMap = new Map<PObjectId,
|
|
75
|
+
const specMap = new Map<PObjectId, PObjectSpec>();
|
|
76
76
|
const specDriver = new SpecDriver();
|
|
77
77
|
const impl = new ColumnsCollectionDriverImpl();
|
|
78
78
|
|
|
@@ -87,7 +87,7 @@ export function createTestCollectionDriver(): TestCollectionDriverHandle {
|
|
|
87
87
|
|
|
88
88
|
const driver: ColumnsCollectionDriverModel = {
|
|
89
89
|
create: (sources) => impl.create(sources, bindings).key,
|
|
90
|
-
isEmpty: (h) => impl.isEmpty(h),
|
|
90
|
+
isEmpty: (h) => impl.isEmpty(h, bindings),
|
|
91
91
|
isFinal: (h) => impl.isFinal(h),
|
|
92
92
|
getColumns: (h) => impl.getColumns(h, bindings),
|
|
93
93
|
addSource: (h, srcs) => impl.addSource(h, srcs, bindings).key,
|
|
@@ -157,7 +157,7 @@ export function createTestCollectionDriver(): TestCollectionDriverHandle {
|
|
|
157
157
|
* - `getInputsLocked()` → `true` (no pending resolution).
|
|
158
158
|
*/
|
|
159
159
|
function buildStubProvider(
|
|
160
|
-
specMap: ReadonlyMap<PObjectId,
|
|
160
|
+
specMap: ReadonlyMap<PObjectId, PObjectSpec>,
|
|
161
161
|
): ColumnEntriesProvider<TreeNodeAccessor> & ColumnsProvider {
|
|
162
162
|
const entries = new Map<PObjectId, LeafEntry<TreeNodeAccessor>>();
|
|
163
163
|
for (const [id, spec] of specMap) {
|
|
@@ -165,7 +165,9 @@ function buildStubProvider(
|
|
|
165
165
|
}
|
|
166
166
|
const columns: DataColumnRecipe<PObjectId>[] = [];
|
|
167
167
|
for (const [id, spec] of specMap) {
|
|
168
|
-
|
|
168
|
+
if (isPColumnSpec(spec)) {
|
|
169
|
+
columns.push(DataColumn.fromColumn({ id, spec, data: undefined as never }));
|
|
170
|
+
}
|
|
169
171
|
}
|
|
170
172
|
return {
|
|
171
173
|
getPObjectEntries: () => entries,
|
|
@@ -174,7 +176,7 @@ function buildStubProvider(
|
|
|
174
176
|
};
|
|
175
177
|
}
|
|
176
178
|
|
|
177
|
-
function stubAccessorFor(id: PObjectId, spec:
|
|
179
|
+
function stubAccessorFor(id: PObjectId, spec: PObjectSpec): TreeNodeAccessor {
|
|
178
180
|
const specField = `${id}.spec`;
|
|
179
181
|
const specHolder = {
|
|
180
182
|
getDataAsJson: <T>() => spec as unknown as T,
|
|
@@ -23,7 +23,9 @@ import type {
|
|
|
23
23
|
LeafEntry,
|
|
24
24
|
PColumnSpec,
|
|
25
25
|
PObjectId,
|
|
26
|
+
PObjectSpec,
|
|
26
27
|
} from "@milaboratories/pl-model-common";
|
|
28
|
+
import { isPColumnSpec } from "@milaboratories/pl-model-common";
|
|
27
29
|
import type { GlobalCfgRenderCtx } from "../../render/internal";
|
|
28
30
|
import type { TreeNodeAccessor } from "../../render/accessor";
|
|
29
31
|
import { _ctxProvidersCache } from "../column_providers";
|
|
@@ -33,7 +35,7 @@ import { DataColumn, type DataColumnRecipe } from "../data_column";
|
|
|
33
35
|
/** Fine-grained per-leaf stub config. Defaults match the shorthand form. */
|
|
34
36
|
export type StubLeafConfig = {
|
|
35
37
|
/** Spec returned by `${id}.spec` traverse. Omit to simulate a missing field. */
|
|
36
|
-
spec?:
|
|
38
|
+
spec?: PObjectSpec;
|
|
37
39
|
/** Drives `leaf.accessor.getInputsLocked()`. Default `true`. */
|
|
38
40
|
accessorLocked?: boolean;
|
|
39
41
|
/** Drives `spec.hasData()` (ignored when `spec` is omitted). Default `true`. */
|
|
@@ -63,7 +65,7 @@ function buildStubProvider(
|
|
|
63
65
|
(acc, [id, raw]) => {
|
|
64
66
|
const cfg = normalizeLeafInput(raw);
|
|
65
67
|
acc.entries.set(id, { accessor: stubAccessorFor(id, cfg), name: id, id });
|
|
66
|
-
if (cfg.spec !== undefined && cfg.specHasData) {
|
|
68
|
+
if (cfg.spec !== undefined && cfg.specHasData && isPColumnSpec(cfg.spec)) {
|
|
67
69
|
acc.columns.push(DataColumn.fromColumn({ id, spec: cfg.spec, data: undefined as never }));
|
|
68
70
|
}
|
|
69
71
|
return acc;
|
|
@@ -81,13 +83,13 @@ function buildStubProvider(
|
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
type NormalizedLeafConfig = {
|
|
84
|
-
spec?:
|
|
86
|
+
spec?: PObjectSpec;
|
|
85
87
|
accessorLocked: boolean;
|
|
86
88
|
specHasData: boolean;
|
|
87
89
|
};
|
|
88
90
|
|
|
89
91
|
function normalizeLeafInput(raw: StubLeafInput): NormalizedLeafConfig {
|
|
90
|
-
if (
|
|
92
|
+
if ("kind" in raw) {
|
|
91
93
|
return { spec: raw, accessorLocked: true, specHasData: true };
|
|
92
94
|
}
|
|
93
95
|
return {
|
|
@@ -97,10 +99,6 @@ function normalizeLeafInput(raw: StubLeafInput): NormalizedLeafConfig {
|
|
|
97
99
|
};
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
function isPColumnSpec(v: StubLeafInput): v is PColumnSpec {
|
|
101
|
-
return typeof v === "object" && v !== null && "kind" in v;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
102
|
let stubAccessorSeq = 0;
|
|
105
103
|
|
|
106
104
|
function stubAccessorFor(id: PObjectId, cfg: NormalizedLeafConfig): TreeNodeAccessor {
|