@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.
Files changed (41) hide show
  1. package/dist/columns/column_providers/providers.cjs +2 -2
  2. package/dist/columns/column_providers/providers.cjs.map +1 -1
  3. package/dist/columns/column_providers/providers.d.ts.map +1 -1
  4. package/dist/columns/column_providers/providers.js +2 -2
  5. package/dist/columns/column_providers/providers.js.map +1 -1
  6. package/dist/columns/column_recipes/index.cjs +2 -2
  7. package/dist/columns/column_recipes/index.cjs.map +1 -1
  8. package/dist/columns/column_recipes/index.d.ts +2 -3
  9. package/dist/columns/column_recipes/index.d.ts.map +1 -1
  10. package/dist/columns/column_recipes/index.js +2 -2
  11. package/dist/columns/column_recipes/index.js.map +1 -1
  12. package/dist/columns/data_column.cjs +21 -50
  13. package/dist/columns/data_column.cjs.map +1 -1
  14. package/dist/columns/data_column.d.ts +10 -22
  15. package/dist/columns/data_column.d.ts.map +1 -1
  16. package/dist/columns/data_column.js +23 -51
  17. package/dist/columns/data_column.js.map +1 -1
  18. package/dist/columns/index.cjs +0 -1
  19. package/dist/columns/index.d.ts +2 -2
  20. package/dist/columns/index.js +2 -2
  21. package/dist/components/PlDatasetSelector/build_dataset_options.cjs +1 -1
  22. package/dist/components/PlDatasetSelector/build_dataset_options.cjs.map +1 -1
  23. package/dist/components/PlDatasetSelector/build_dataset_options.js +2 -2
  24. package/dist/components/PlDatasetSelector/build_dataset_options.js.map +1 -1
  25. package/dist/index.cjs +0 -1
  26. package/dist/index.d.ts +2 -2
  27. package/dist/index.js +2 -2
  28. package/dist/package.cjs +1 -1
  29. package/dist/package.js +1 -1
  30. package/package.json +7 -7
  31. package/src/columns/__test_helpers__/collection_driver.ts +10 -8
  32. package/src/columns/__test_helpers__/stub_registry.ts +6 -8
  33. package/src/columns/column_providers/providers.test.ts +45 -0
  34. package/src/columns/column_providers/providers.ts +7 -6
  35. package/src/columns/column_recipes/column_recipes.test.ts +11 -15
  36. package/src/columns/column_recipes/index.ts +2 -3
  37. package/src/columns/columns_collection.test.ts +39 -0
  38. package/src/columns/data_column.test.ts +20 -11
  39. package/src/columns/data_column.ts +24 -49
  40. package/src/components/PlDatasetSelector/build_dataset_options.ts +7 -4
  41. package/src/labels/derive_distinct_labels.test.ts +1 -1
@@ -0,0 +1,45 @@
1
+ import type { PObjectSpec } from "@milaboratories/pl-model-common";
2
+ import { ResourceTypeName } from "@milaboratories/pl-model-common";
3
+ import { afterEach, expect, test } from "vitest";
4
+ import type { AccessorHandle } from "../../render/internal";
5
+ import { TreeNodeAccessor } from "../../render/accessor";
6
+ import { AccessorColumnsProviderImpl } from "./providers";
7
+
8
+ const rootHandle = "pframe" as AccessorHandle;
9
+
10
+ function installPFrameCtx(specs: Record<string, PObjectSpec>): void {
11
+ const fieldOf = (step: string | { field: string }) =>
12
+ typeof step === "string" ? step : step.field;
13
+ const specOf = (handle: AccessorHandle) => specs[handle.slice(`${rootHandle}/`.length)];
14
+ (globalThis as { cfgRenderCtx?: unknown }).cfgRenderCtx = {
15
+ resolveWithCommon: (
16
+ handle: AccessorHandle,
17
+ _options: unknown,
18
+ step: string | { field: string },
19
+ ) => {
20
+ const name = fieldOf(step).slice(0, -".spec".length);
21
+ if (handle !== rootHandle || specs[name] === undefined) {
22
+ return undefined;
23
+ }
24
+ return `${rootHandle}/${name}` as AccessorHandle;
25
+ },
26
+ getResourceType: () => ({ name: ResourceTypeName.PFrame, version: "1" }),
27
+ getInputsLocked: () => true,
28
+ listInputFields: () => Object.keys(specs).map((name) => `${name}.spec`),
29
+ hasData: () => true,
30
+ getDataAsString: (handle: AccessorHandle) => JSON.stringify(specOf(handle)),
31
+ };
32
+ }
33
+
34
+ afterEach(() => {
35
+ delete (globalThis as { cfgRenderCtx?: unknown }).cfgRenderCtx;
36
+ });
37
+
38
+ test("getColumns skips an export that is not a column", () => {
39
+ installPFrameCtx({
40
+ clones: { kind: "PColumn", name: "clones", valueType: "Int", axesSpec: [] },
41
+ library: { kind: "File", name: "library" },
42
+ });
43
+ const provider = new AccessorColumnsProviderImpl(new TreeNodeAccessor(rootHandle, ["main"]));
44
+ expect(provider.getColumns().map((column) => column.getSpec().name)).toEqual(["clones"]);
45
+ });
@@ -129,9 +129,9 @@ export class AccessorColumnsProviderImpl
129
129
 
130
130
  getColumns(): DataColumnRecipe<PObjectId>[] {
131
131
  if (this.cachedColumns !== undefined) return this.cachedColumns;
132
- return (this.cachedColumns = Array.from(this.entries.values())
133
- .map((e) => DataColumn.fromAccessor(e))
134
- .filter((v): v is DataColumnRecipe<PObjectId> => !isNil(v)));
132
+ return (this.cachedColumns = Array.from(this.entries.values(), DataColumn.fromAccessor).filter(
133
+ (column) => column !== undefined,
134
+ ));
135
135
  }
136
136
  }
137
137
 
@@ -173,9 +173,10 @@ export class ResultPoolColumnsProviderImpl
173
173
 
174
174
  getColumns(): DataColumnRecipe<PObjectId>[] {
175
175
  if (this.cachedColumns !== undefined) return this.cachedColumns;
176
- return (this.cachedColumns = Array.from(this.getPObjectEntries().values())
177
- .map((e) => DataColumn.fromAccessor(e))
178
- .filter((v): v is DataColumnRecipe<PObjectId> => !isNil(v)));
176
+ return (this.cachedColumns = Array.from(
177
+ this.getPObjectEntries().values(),
178
+ DataColumn.fromAccessor,
179
+ ).filter((column) => column !== undefined));
179
180
  }
180
181
  }
181
182
 
@@ -24,7 +24,6 @@ import { ColumnDiscoveredRecipe } from "./column_discovered_recipe";
24
24
  import { ColumnOverriddenRecipe } from "./column_overrided_recipe";
25
25
  import { ColumnFilteredRecipe } from "./column_filtered_recipe";
26
26
  import { ColumnRecipe } from "./index";
27
- import { ColumnAbsentError } from "../data_column";
28
27
  import type { ColumnFieldStatus } from "./types";
29
28
  import { installStubRegistry } from "../__test_helpers__/stub_registry";
30
29
  import { throwError } from "@milaboratories/helpers";
@@ -403,11 +402,9 @@ describe("ColumnDiscoveredRecipe", () => {
403
402
  ).toThrow(/Unsupported ColumnRecipe id variant/);
404
403
  });
405
404
 
406
- test("fromKey propagates ColumnAbsentError from a referenced absent column", () => {
407
- // Default ctx mock has no providers → empty registry → leaf id is provably
408
- // absent. The leaf-level throw inside `Column(uniId, opts)` propagates
409
- // unchanged through `fromKey`.
410
- expect(() => ColumnDiscoveredRecipe.fromKey(trivialKey)).toThrow(ColumnAbsentError);
405
+ test("fromKey returns undefined when a referenced column is absent", () => {
406
+ // Default ctx mock has no providers → empty registry → leaf id is absent.
407
+ expect(ColumnDiscoveredRecipe.fromKey(trivialKey)).toBeUndefined();
411
408
  });
412
409
 
413
410
  test("id is the canonical stringify(ColumnDiscoveredKey)", () => {
@@ -611,10 +608,9 @@ describe("ColumnRecipe.getStatus (top-level dispatcher)", () => {
611
608
  });
612
609
  });
613
610
 
614
- describe("ColumnRecipe(id) throw propagation on absent leaves", () => {
615
- test("filtered id over an absent source throws ColumnAbsentError", () => {
616
- // Empty registry with isFinal=true → leaf is provably absent → throw
617
- // propagates through the Filtered dispatch branch.
611
+ describe("ColumnRecipe(id) over absent leaves", () => {
612
+ test("filtered id over an absent source returns undefined", () => {
613
+ // Empty registry with isFinal=true → leaf is absent.
618
614
  const ctx = makeCtx();
619
615
  (globalThis as { cfgRenderCtx?: unknown }).cfgRenderCtx = ctx;
620
616
  installStubRegistry(ctx, {}, { isFinal: true });
@@ -622,10 +618,10 @@ describe("ColumnRecipe(id) throw propagation on absent leaves", () => {
622
618
  source: baseLeaf,
623
619
  axisFilters: [],
624
620
  });
625
- expect(() => ColumnRecipe(id)).toThrow(ColumnAbsentError);
621
+ expect(ColumnRecipe(id)).toBeUndefined();
626
622
  });
627
623
 
628
- test("overrided id over an absent source throws ColumnAbsentError", () => {
624
+ test("overrided id over an absent source returns undefined", () => {
629
625
  const ctx = makeCtx();
630
626
  (globalThis as { cfgRenderCtx?: unknown }).cfgRenderCtx = ctx;
631
627
  installStubRegistry(ctx, {}, { isFinal: true });
@@ -633,15 +629,15 @@ describe("ColumnRecipe(id) throw propagation on absent leaves", () => {
633
629
  source: baseLeaf,
634
630
  specOverrides: overrides({}),
635
631
  });
636
- expect(() => ColumnRecipe(id)).toThrow(ColumnAbsentError);
632
+ expect(ColumnRecipe(id)).toBeUndefined();
637
633
  });
638
634
 
639
- test("discovered id over an absent hit throws ColumnAbsentError", () => {
635
+ test("discovered id over an absent hit returns undefined", () => {
640
636
  const ctx = makeCtx();
641
637
  (globalThis as { cfgRenderCtx?: unknown }).cfgRenderCtx = ctx;
642
638
  installStubRegistry(ctx, {}, { isFinal: true });
643
639
  const id = stringifyColumnDiscoveredId({ column: baseLeaf });
644
- expect(() => ColumnRecipe(id)).toThrow(ColumnAbsentError);
640
+ expect(ColumnRecipe(id)).toBeUndefined();
645
641
  });
646
642
  });
647
643
 
@@ -19,7 +19,6 @@ import type {
19
19
  } from "./types";
20
20
 
21
21
  export type { ColumnFieldStatus, ColumnRecipeId, ColumnResolutionStatus, SpecQuery } from "./types";
22
- export { ColumnAbsentError } from "../data_column";
23
22
  export { ColumnDiscoveredRecipe } from "./column_discovered_recipe";
24
23
  export { ColumnFilteredRecipe } from "./column_filtered_recipe";
25
24
  export { ColumnOverriddenRecipe } from "./column_overrided_recipe";
@@ -90,8 +89,8 @@ function ColumnRecipeBuild(
90
89
  * Resolution status counterpart to {@link ColumnRecipeBuild}. Dispatches on
91
90
  * the parsed id shape to the matching `getStatusBy*` static — never
92
91
  * constructs the recipe. Use this at boundaries (resolver, filter/sort
93
- * targets) to throw early on `absent` instead of silently producing an empty
94
- * recipe via {@link ColumnRecipeBuild}.
92
+ * targets) to tell an `absent` column from a `resolving` one: the recipe
93
+ * factory returns `undefined` for both.
95
94
  */
96
95
  function ColumnRecipeGetStatus(
97
96
  id: ColumnUniversalId,
@@ -79,6 +79,23 @@ describe("ColumnsCollection.isEmpty", () => {
79
79
  const c = { id: gid("c1"), spec: spec("col1") };
80
80
  expect(makeCollection([c]).isEmpty()).toBe(false);
81
81
  });
82
+
83
+ test("driver: true when the only export is not a column", () => {
84
+ const file = { id: gid("library"), spec: { kind: "File", name: "library" } };
85
+ handle.register([file]);
86
+ const collection = handle.driver.create([{ kind: "ids", ids: [file.id], isFinal: true }]);
87
+ expect(handle.driver.isEmpty(collection)).toBe(true);
88
+ });
89
+
90
+ test("driver: lists an id only once its spec is readable", () => {
91
+ const late = { id: gid("late"), spec: spec("late") };
92
+ const collection = handle.driver.create([{ kind: "ids", ids: [late.id], isFinal: true }]);
93
+ expect(handle.driver.getColumns(collection)).toEqual([]);
94
+ expect(handle.driver.isEmpty(collection)).toBe(true);
95
+ handle.register([late]);
96
+ expect(handle.driver.getColumns(collection)).toEqual([late.id]);
97
+ expect(handle.driver.isEmpty(collection)).toBe(false);
98
+ });
82
99
  });
83
100
 
84
101
  describe("ColumnsCollection.isFinal", () => {
@@ -114,6 +131,28 @@ describe("ColumnsCollection.getColumnIds", () => {
114
131
  });
115
132
  });
116
133
 
134
+ describe("ColumnsCollection driver getColumns", () => {
135
+ test("drops ids whose spec is not a column", () => {
136
+ const column = { id: gid("c1"), spec: spec("col1") };
137
+ const file = { id: gid("library"), spec: { kind: "File", name: "library" } };
138
+ handle.register([column, file]);
139
+ const collection = handle.driver.create([
140
+ { kind: "ids", ids: [column.id, file.id], isFinal: true },
141
+ ]);
142
+ expect(handle.driver.getColumns(collection)).toEqual([column.id]);
143
+ });
144
+
145
+ test("filter over a collection with a file export returns only columns", () => {
146
+ const column = { id: gid("c1"), spec: spec("col1") };
147
+ const file = { id: gid("library"), spec: { kind: "File", name: "library" } };
148
+ handle.register([column, file]);
149
+ const collection = handle.driver.create([
150
+ { kind: "ids", ids: [column.id, file.id], isFinal: true },
151
+ ]);
152
+ expect(handle.driver.getColumns(handle.driver.filter(collection, {}))).toEqual([column.id]);
153
+ });
154
+ });
155
+
117
156
  describe("ColumnsCollection.addSource", () => {
118
157
  test("returns new instance, original unchanged", () => {
119
158
  const c1 = { id: gid("c1"), spec: spec("col1") };
@@ -5,8 +5,9 @@ import {
5
5
  SpecOverrides,
6
6
  type PColumnSpec,
7
7
  type PObjectId,
8
+ type PObjectSpec,
8
9
  } from "@milaboratories/pl-model-common";
9
- import { ColumnAbsentError, DataColumnImpl } from "./data_column";
10
+ import { DataColumnImpl } from "./data_column";
10
11
  import { _ctxProvidersCache } from "./column_providers";
11
12
  import { installStubRegistry } from "./__test_helpers__/stub_registry";
12
13
 
@@ -33,6 +34,8 @@ const baseLeaf = createLocalPObjectId(["main", "out"], "col-1");
33
34
 
34
35
  const stubSpec = { kind: "PColumn", name: "stub" } as unknown as PColumnSpec;
35
36
 
37
+ const fileSpec: PObjectSpec = { kind: "File", name: "library" };
38
+
36
39
  function lazyOf(id: PObjectId, spec: PColumnSpec = stubSpec) {
37
40
  return DataColumnImpl.fromColumn({ id, spec, data: undefined });
38
41
  }
@@ -83,10 +86,9 @@ describe("DataColumnImpl.spec — applySpecOverrides", () => {
83
86
  expect(c.getSpec()).toBe(stubSpec);
84
87
  });
85
88
 
86
- test("fromId throws ColumnAbsentError when ctx has no handles", () => {
87
- // Empty registry — `isFinal()` returns true vacuously, so the leaf is
88
- // provably absent (no provider will ever supply it).
89
- expect(() => DataColumnImpl.fromId(baseLeaf)).toThrow(ColumnAbsentError);
89
+ test("fromId returns undefined when ctx has no handles", () => {
90
+ // Empty registry — `isFinal()` returns true vacuously, so the leaf is absent.
91
+ expect(DataColumnImpl.fromId(baseLeaf)).toBeUndefined();
90
92
  });
91
93
 
92
94
  test("appends axes at indices past base.axesSpec.length", () => {
@@ -127,7 +129,7 @@ describe("DataColumnImpl.spec — applySpecOverrides", () => {
127
129
  });
128
130
  });
129
131
 
130
- // --- resolution status / absent throw --------------------------------------
132
+ // --- resolution status / absent column --------------------------------------
131
133
 
132
134
  describe("DataColumnImpl resolution: fromId / fromAccessor / getStatus", () => {
133
135
  test("fromId returns undefined when registry is unfinalized and id not found", () => {
@@ -136,10 +138,10 @@ describe("DataColumnImpl resolution: fromId / fromAccessor / getStatus", () => {
136
138
  expect(DataColumnImpl.fromId(baseLeaf)).toBeUndefined();
137
139
  });
138
140
 
139
- test("fromId throws ColumnAbsentError when leaf has no spec field on locked accessor", () => {
140
- // Leaf entry present, no spec field, accessor locked → absent forever.
141
+ test("fromId returns undefined when leaf has no spec field on locked accessor", () => {
142
+ // Leaf entry present, no spec field, accessor locked → absent.
141
143
  installStubRegistry(mockCtx, { [baseLeaf]: { accessorLocked: true } });
142
- expect(() => DataColumnImpl.fromId(baseLeaf)).toThrow(ColumnAbsentError);
144
+ expect(DataColumnImpl.fromId(baseLeaf)).toBeUndefined();
143
145
  });
144
146
 
145
147
  test("fromId returns undefined when leaf has no spec field on unlocked accessor", () => {
@@ -154,10 +156,10 @@ describe("DataColumnImpl resolution: fromId / fromAccessor / getStatus", () => {
154
156
  expect(DataColumnImpl.fromId(baseLeaf)).toBeUndefined();
155
157
  });
156
158
 
157
- test("fromAccessor throws ColumnAbsentError when accessor is locked without spec", () => {
159
+ test("fromAccessor returns undefined when accessor is locked without spec", () => {
158
160
  installStubRegistry(mockCtx, { [baseLeaf]: { accessorLocked: true } });
159
161
  const entry = pluckLeafEntry(baseLeaf);
160
- expect(() => DataColumnImpl.fromAccessor(entry)).toThrow(ColumnAbsentError);
162
+ expect(DataColumnImpl.fromAccessor(entry)).toBeUndefined();
161
163
  });
162
164
 
163
165
  test("fromAccessor returns undefined when accessor is unlocked without spec", () => {
@@ -166,6 +168,13 @@ describe("DataColumnImpl resolution: fromId / fromAccessor / getStatus", () => {
166
168
  expect(DataColumnImpl.fromAccessor(entry)).toBeUndefined();
167
169
  });
168
170
 
171
+ test("an export that is not a column: fromId and fromAccessor return undefined, status tracks only resolution", () => {
172
+ installStubRegistry(mockCtx, { [baseLeaf]: { spec: fileSpec } });
173
+ expect(DataColumnImpl.fromId(baseLeaf)).toBeUndefined();
174
+ expect(DataColumnImpl.fromAccessor(pluckLeafEntry(baseLeaf))).toBeUndefined();
175
+ expect(DataColumnImpl.getStatusById(baseLeaf)).toBe("present");
176
+ });
177
+
169
178
  test("getStatusById returns 'absent' / 'resolving' / 'present' across configurations", () => {
170
179
  // present — spec with data on a locked, populated leaf.
171
180
  installStubRegistry(mockCtx, { [baseLeaf]: stubSpec });
@@ -2,13 +2,14 @@ import {
2
2
  ColumnRegistry,
3
3
  createGlobalPObjectId,
4
4
  isPColumn,
5
+ isPColumnSpec,
5
6
  isPlRef,
6
7
  PlRef,
7
8
  PObjectId,
8
- type ColumnUniversalId,
9
9
  type LeafEntry,
10
10
  type PColumn,
11
11
  type PColumnSpec,
12
+ type PObjectSpec,
12
13
  type SpecOverrides,
13
14
  type SpecQuery,
14
15
  } from "@milaboratories/pl-model-common";
@@ -51,24 +52,6 @@ export interface DataColumnRecipe<
51
52
  getData(): ColumnData;
52
53
  }
53
54
 
54
- /**
55
- * Thrown by leaf-recipe factories when the requested column is provably
56
- * absent in the active render ctx — i.e. every relevant accessor reports
57
- * `inputsLocked` and the column did not appear. Distinct from the
58
- * `undefined` return that the factories still use for the "resolving" case
59
- * (the column may still appear later).
60
- *
61
- * Catch at the boundary (resolver / filter+sort wiring / data-table assembly)
62
- * when partial absence should be surfaced to the user rather than silently
63
- * producing an empty result.
64
- */
65
- export class ColumnAbsentError extends Error {
66
- constructor(public readonly id: ColumnUniversalId) {
67
- super(`Column is absent in the active render ctx and will not appear: ${id}`);
68
- this.name = "ColumnAbsentError";
69
- }
70
- }
71
-
72
55
  /**
73
56
  * The leaf-recipe building block: a {@link DataColumnRecipe} whose `id` is a bare
74
57
  * {@link PObjectId} and whose readers are bound to a single tree-accessor
@@ -132,32 +115,18 @@ export class DataColumnImpl implements DataColumnRecipe<PObjectId> {
132
115
 
133
116
  /**
134
117
  * Resolve via the ambient {@link ColumnRegistry}. Spec is resolved eagerly:
135
- * returns `undefined` if the leaf isn't reachable yet (resolving). Throws
136
- * {@link ColumnAbsentError} when every relevant accessor is `inputsLocked`
137
- * and the column did not appear — the column will not exist in this ctx.
118
+ * returns `undefined` unless the id names a column whose spec is readable in
119
+ * this ctx — while it is resolving, when it is absent, and when the id names
120
+ * an export that is not a column (a `kind: "File"` object, for example).
138
121
  * Data and dataStatus stay lazy.
139
122
  */
140
123
  static fromId(
141
124
  id: PObjectId,
142
125
  { ctx }: { ctx?: GlobalCfgRenderCtx } = {},
143
126
  ): undefined | DataColumnRecipe<PObjectId> {
144
- const registry = new ColumnRegistry(getCtxProviders({ ctx }));
145
- const leaf = registry.resolve(id);
146
- if (isNil(leaf)) {
147
- if (registry.isFinal()) throw new ColumnAbsentError(id);
148
- return undefined;
149
- }
150
- const spec = readSpecAccessor(leaf);
151
- if (isNil(spec)) {
152
- if (leaf.accessor.getInputsLocked()) throw new ColumnAbsentError(id);
153
- return undefined;
154
- }
155
- if (!spec.hasData()) return undefined;
156
- return new DataColumnImpl(id, {
157
- getSpec: () => spec.getDataAsJson<PColumnSpec>(),
158
- getData: () => readDataAccessor(leaf),
159
- getDataStatus: () => readDataStatus(leaf),
160
- });
127
+ const leaf = new ColumnRegistry(getCtxProviders({ ctx })).resolve(id);
128
+ if (isNil(leaf)) return undefined;
129
+ return DataColumnImpl.fromAccessor(leaf);
161
130
  }
162
131
 
163
132
  /** {@link PlRef} wrapper over {@link fromId}. */
@@ -167,18 +136,15 @@ export class DataColumnImpl implements DataColumnRecipe<PObjectId> {
167
136
 
168
137
  /**
169
138
  * Bind directly to an accessor-backed {@link LeafEntry} — no registry.
170
- * Throws {@link ColumnAbsentError} if the leaf has no spec field and its
171
- * accessor is `inputsLocked`. Returns `undefined` while still resolving.
139
+ * Returns `undefined` unless the leaf's spec is readable and is a column
140
+ * spec: while the spec is resolving, when it is absent, and for an export
141
+ * that is not a column.
172
142
  */
173
143
  static fromAccessor(entry: LeafEntry<TreeNodeAccessor>): undefined | DataColumnRecipe<PObjectId> {
174
- const spec = readSpecAccessor(entry);
175
- if (isNil(spec)) {
176
- if (entry.accessor.getInputsLocked()) throw new ColumnAbsentError(entry.id);
177
- return undefined;
178
- }
179
- if (!spec.hasData()) return undefined;
144
+ const spec = readSpec(entry);
145
+ if (spec === undefined || !isPColumnSpec(spec)) return undefined;
180
146
  return new DataColumnImpl(entry.id, {
181
- getSpec: () => spec.getDataAsJson<PColumnSpec>(),
147
+ getSpec: () => spec,
182
148
  getData: () => readDataAccessor(entry),
183
149
  getDataStatus: () => readDataStatus(entry),
184
150
  });
@@ -208,7 +174,9 @@ export class DataColumnImpl implements DataColumnRecipe<PObjectId> {
208
174
  * Distinguishes `present` / `resolving` / `absent` for a {@link PObjectId}
209
175
  * in the active render ctx. Falls back to the registry's `isFinal()`
210
176
  * when the id has no entry — only then we can say `absent` instead of
211
- * `resolving`.
177
+ * `resolving`. The status tells only whether the spec is readable: for an
178
+ * export that is not a column it is `present`, and the factories return
179
+ * `undefined`.
212
180
  */
213
181
  static getStatusById(
214
182
  id: PObjectId,
@@ -306,6 +274,13 @@ const readSpecAccessor = memoizeByEntry(
306
274
  accessor.traverse({ field: `${name}.spec`, assertFieldType: "Input", ignoreError: true }),
307
275
  );
308
276
 
277
+ /** The leaf's spec, or `undefined` until the spec resource has data. */
278
+ const readSpec = memoizeByEntry((entry: LeafEntry<TreeNodeAccessor>): undefined | PObjectSpec => {
279
+ const spec = readSpecAccessor(entry);
280
+ if (isNil(spec) || !spec.hasData()) return undefined;
281
+ return spec.getDataAsJson<PObjectSpec>();
282
+ });
283
+
309
284
  /**
310
285
  * Per-entry counterpart to {@link readDataStatus}: tells whether the leaf's
311
286
  * **spec** can be read in this ctx, and — for the negative cases —
@@ -1,5 +1,5 @@
1
1
  import type { MultiColumnSelector, Option, PObjectSpec } from "@milaboratories/pl-model-common";
2
- import { multiColumnSelectorsToPredicate } from "@milaboratories/pl-model-common";
2
+ import { isPColumnSpec, multiColumnSelectorsToPredicate } from "@milaboratories/pl-model-common";
3
3
  import type { DeriveLabelsOptions } from "../../labels/derive_distinct_labels";
4
4
  import type { RenderCtxBase } from "../../render";
5
5
  import type { DatasetOption } from "./dataset_selection";
@@ -60,9 +60,12 @@ export function buildDatasetOptions(
60
60
  const primaryPredicate = toPredicate(opts?.primary);
61
61
  const filterPredicate = toPredicate(opts?.filter);
62
62
 
63
- const options = ctx.resultPool.getOptions(primaryPredicate, {
64
- refsWithEnrichments: opts?.requireEnrichments ?? true,
65
- });
63
+ const options = ctx.resultPool.getOptions(
64
+ (spec) => isPColumnSpec(spec) && primaryPredicate(spec),
65
+ {
66
+ refsWithEnrichments: opts?.requireEnrichments ?? true,
67
+ },
68
+ );
66
69
  if (options.length === 0) return [];
67
70
 
68
71
  const refMap = buildRefMap(ctx.resultPool.getSpecs().entries);
@@ -234,7 +234,7 @@ test("cluster-id preset: colliding columns are distinguished by a token they hav
234
234
  {
235
235
  type: "milaboratories.samples-and-data/dataset",
236
236
  importance: 100,
237
- label: "MB135 + Podocytes",
237
+ label: "Sample A + Cells",
238
238
  },
239
239
  {
240
240
  type: "milaboratories.mixcr-amplicon-alignment",