@platforma-sdk/model 1.90.20 → 1.92.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 (79) hide show
  1. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs +2 -2
  2. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs.map +1 -1
  3. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.d.ts.map +1 -1
  4. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js +2 -2
  5. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js.map +1 -1
  6. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs +5 -4
  7. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs.map +1 -1
  8. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts +12 -0
  9. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts.map +1 -1
  10. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js +5 -4
  11. package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js.map +1 -1
  12. package/dist/components/PlDataTable/createPlDataTableSheet.cjs +7 -3
  13. package/dist/components/PlDataTable/createPlDataTableSheet.cjs.map +1 -1
  14. package/dist/components/PlDataTable/createPlDataTableSheet.d.ts +7 -2
  15. package/dist/components/PlDataTable/createPlDataTableSheet.d.ts.map +1 -1
  16. package/dist/components/PlDataTable/createPlDataTableSheet.js +7 -3
  17. package/dist/components/PlDataTable/createPlDataTableSheet.js.map +1 -1
  18. package/dist/components/PlDataTable/index.cjs +2 -0
  19. package/dist/components/PlDataTable/index.d.ts +2 -1
  20. package/dist/components/PlDataTable/index.js +2 -1
  21. package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
  22. package/dist/components/PlDataTable/state-migration.d.ts +2 -2
  23. package/dist/components/PlDataTable/state-migration.d.ts.map +1 -1
  24. package/dist/components/PlDataTable/state-migration.js.map +1 -1
  25. package/dist/components/PlDataTable/tableParams.cjs +61 -15
  26. package/dist/components/PlDataTable/tableParams.cjs.map +1 -1
  27. package/dist/components/PlDataTable/tableParams.d.ts +8 -0
  28. package/dist/components/PlDataTable/tableParams.d.ts.map +1 -0
  29. package/dist/components/PlDataTable/tableParams.js +60 -16
  30. package/dist/components/PlDataTable/tableParams.js.map +1 -1
  31. package/dist/components/PlDataTable/typesV8.d.ts +18 -0
  32. package/dist/components/PlDataTable/typesV8.d.ts.map +1 -1
  33. package/dist/components/PlDatasetSelector/build_dataset_options.cjs +43 -33
  34. package/dist/components/PlDatasetSelector/build_dataset_options.cjs.map +1 -1
  35. package/dist/components/PlDatasetSelector/build_dataset_options.d.ts +6 -2
  36. package/dist/components/PlDatasetSelector/build_dataset_options.d.ts.map +1 -1
  37. package/dist/components/PlDatasetSelector/build_dataset_options.js +46 -36
  38. package/dist/components/PlDatasetSelector/build_dataset_options.js.map +1 -1
  39. package/dist/components/PlDatasetSelector/dataset_selection.cjs.map +1 -1
  40. package/dist/components/PlDatasetSelector/dataset_selection.d.ts +13 -4
  41. package/dist/components/PlDatasetSelector/dataset_selection.d.ts.map +1 -1
  42. package/dist/components/PlDatasetSelector/dataset_selection.js.map +1 -1
  43. package/dist/components/PlDatasetSelector/enrichment_discovery.cjs +20 -26
  44. package/dist/components/PlDatasetSelector/enrichment_discovery.cjs.map +1 -1
  45. package/dist/components/PlDatasetSelector/enrichment_discovery.js +22 -28
  46. package/dist/components/PlDatasetSelector/enrichment_discovery.js.map +1 -1
  47. package/dist/components/PlDatasetSelector/filter_discovery.cjs +6 -14
  48. package/dist/components/PlDatasetSelector/filter_discovery.cjs.map +1 -1
  49. package/dist/components/PlDatasetSelector/filter_discovery.d.ts +5 -10
  50. package/dist/components/PlDatasetSelector/filter_discovery.d.ts.map +1 -1
  51. package/dist/components/PlDatasetSelector/filter_discovery.js +8 -13
  52. package/dist/components/PlDatasetSelector/filter_discovery.js.map +1 -1
  53. package/dist/components/PlDatasetSelector/index.cjs +0 -1
  54. package/dist/components/PlDatasetSelector/index.d.ts +3 -3
  55. package/dist/components/PlDatasetSelector/index.js +2 -2
  56. package/dist/components/index.cjs +2 -1
  57. package/dist/components/index.d.ts +4 -3
  58. package/dist/components/index.js +3 -2
  59. package/dist/index.cjs +2 -1
  60. package/dist/index.d.ts +4 -3
  61. package/dist/index.js +3 -2
  62. package/dist/package.cjs +1 -1
  63. package/dist/package.js +1 -1
  64. package/package.json +7 -7
  65. package/src/columns/__test_helpers__/collection_driver.ts +45 -5
  66. package/src/components/PlDataTable/createPlDataTable/createPlDataTableV2.ts +2 -1
  67. package/src/components/PlDataTable/createPlDataTable/createPlDataTableV3.ts +20 -2
  68. package/src/components/PlDataTable/createPlDataTableSheet.ts +6 -1
  69. package/src/components/PlDataTable/index.ts +1 -0
  70. package/src/components/PlDataTable/state-migration.ts +5 -5
  71. package/src/components/PlDataTable/tableParams.test.ts +71 -0
  72. package/src/components/PlDataTable/tableParams.ts +66 -9
  73. package/src/components/PlDataTable/typesV8.ts +27 -6
  74. package/src/components/PlDatasetSelector/build_dataset_options.test.ts +195 -0
  75. package/src/components/PlDatasetSelector/build_dataset_options.ts +86 -63
  76. package/src/components/PlDatasetSelector/dataset_selection.ts +14 -4
  77. package/src/components/PlDatasetSelector/enrichment_discovery.ts +26 -35
  78. package/src/components/PlDatasetSelector/filter_discovery.test.ts +16 -53
  79. package/src/components/PlDatasetSelector/filter_discovery.ts +10 -20
@@ -1,23 +1,20 @@
1
1
  import {
2
2
  Annotation,
3
- createEnrichmentRef,
4
- extractPObjectId,
3
+ isColumnDiscoveredId,
5
4
  isGlobalPObjectId,
5
+ parseColumnDiscoveredId,
6
6
  } from "@milaboratories/pl-model-common";
7
7
  import type {
8
8
  ColumnsCollectionDriverModel,
9
- EnrichmentStep,
10
- LabeledEnrichmentRef,
11
- LabeledEnrichmentRefs,
9
+ ColumnUniversalId,
12
10
  MultiColumnSelector,
13
11
  PColumnSpec,
14
12
  PObjectSpec,
15
13
  } from "@milaboratories/pl-model-common";
16
- import type { ColumnRecipe, ColumnsSource } from "../../columns";
14
+ import type { ColumnRecipe, ColumnsSource, ColumnsSourceShorthand } from "../../columns";
17
15
  import {
18
16
  hasSingleDataColumn,
19
17
  ColumnsCollection,
20
- collectLinkerIds,
21
18
  hitQualifications,
22
19
  collectLinkerColumns,
23
20
  queriesQualifications,
@@ -27,9 +24,10 @@ import {
27
24
  type DeriveLabelsOptions,
28
25
  type Entry,
29
26
  } from "../../labels/derive_distinct_labels";
27
+ import type { DatasetEnrichment } from "./dataset_selection";
30
28
 
31
29
  export interface FindEnrichmentColumnsOptions {
32
- sources: ReadonlyArray<ColumnsSource>;
30
+ sources: ReadonlyArray<ColumnsCollection | ColumnsSource | ColumnsSourceShorthand>;
33
31
  anchorSpec: PColumnSpec;
34
32
  maxHops?: number;
35
33
  include?: MultiColumnSelector | MultiColumnSelector[];
@@ -42,6 +40,9 @@ export interface FindEnrichmentColumnsOptions {
42
40
  * Linker-reached hits attached to the anchor primary. Drops zero-hop variants
43
41
  * (filters / the primary itself) and structural hits (subset, linker, label
44
42
  * columns). Narrow further with `include` selectors or a `predicate`.
43
+ *
44
+ * A hit is kept only when a workflow can find it by its id: the hit and every
45
+ * linker leading to it are block outputs.
45
46
  */
46
47
  export function findEnrichmentColumns(options: FindEnrichmentColumnsOptions): ColumnRecipe[] {
47
48
  const include =
@@ -68,48 +69,38 @@ export function findEnrichmentColumns(options: FindEnrichmentColumnsOptions): Co
68
69
  const predicate = options.predicate;
69
70
  return columns.filter((v) => {
70
71
  if (hasSingleDataColumn(v)) return false;
71
- if (predicate !== undefined && !predicate(v.getSpec())) return false;
72
- if (!isGlobalPObjectId(extractPObjectId(v.id))) return false;
73
- if (collectLinkerIds(v).some((id) => !isGlobalPObjectId(id))) return false;
74
- return true;
72
+ if (!reachesBlockOutputs(v.id)) return false;
73
+ return predicate === undefined || predicate(v.getSpec());
75
74
  });
76
75
  }
77
76
 
78
77
  /**
79
- * Pair each variant with a path-disambiguated label (so export headers stay
80
- * unique) and carry hit/linker `PObjectId`s through verbatim. Propagates
81
- * `qualifications.forHit`; `forQueries` is re-derived by the table builder.
78
+ * Pairs each column with a label that tells apart the same hit reached through
79
+ * different linkers, so export headers stay unique.
82
80
  */
83
- export function enrichmentVariantsToRefs(
81
+ export function labelEnrichments(
84
82
  variants: ColumnRecipe[],
85
83
  labelOptions?: DeriveLabelsOptions,
86
- ): LabeledEnrichmentRefs {
84
+ ): DatasetEnrichment[] {
87
85
  if (variants.length === 0) return [];
88
86
 
89
- const linkerIdsByVariant = variants.map((v) => collectLinkerIds(v));
90
- const hitQualsByVariant = variants.map((v) => [...hitQualifications(v)]);
91
-
92
- const entries: Entry[] = variants.map((variant, i) => ({
87
+ const entries: Entry[] = variants.map((variant) => ({
93
88
  spec: variant.getSpec(),
94
89
  linkerPath: collectLinkerColumns(variant).map((linker) => ({ spec: linker.getSpec() })),
95
90
  qualifications: {
96
- forHit: hitQualsByVariant[i],
91
+ forHit: [...hitQualifications(variant)],
97
92
  forQueries: queriesQualifications(variant),
98
93
  },
99
94
  }));
100
95
  const labels = deriveDistinctLabels(entries, labelOptions);
101
96
 
102
- return variants.map((variant, i): LabeledEnrichmentRef => {
103
- const path: undefined | EnrichmentStep[] =
104
- linkerIdsByVariant[i].length === 0
105
- ? undefined
106
- : linkerIdsByVariant[i].map((id) => ({ type: "linker", linker: id }));
107
- return {
108
- ref: createEnrichmentRef(extractPObjectId(variant.id), {
109
- path,
110
- qualifications: hitQualsByVariant[i],
111
- }),
112
- label: labels[i],
113
- };
114
- });
97
+ return variants.map((variant, i): DatasetEnrichment => ({ id: variant.id, label: labels[i] }));
98
+ }
99
+
100
+ // Internals
101
+
102
+ function reachesBlockOutputs(id: ColumnUniversalId): boolean {
103
+ if (!isColumnDiscoveredId(id)) return false;
104
+ const key = parseColumnDiscoveredId(id);
105
+ return [key.column, ...(key.path ?? []).map((step) => step.column)].every(isGlobalPObjectId);
115
106
  }
@@ -1,15 +1,14 @@
1
- import { Annotation, createGlobalPObjectId, createPlRef } from "@milaboratories/pl-model-common";
2
- import type {
3
- AxisSpec,
4
- PColumn,
5
- PColumnSpec,
6
- PlRef,
7
- PObjectId,
1
+ import {
2
+ Annotation,
3
+ createGlobalPObjectId,
4
+ createLocalPObjectId,
5
+ createPlRef,
8
6
  } from "@milaboratories/pl-model-common";
7
+ import type { AxisSpec, PColumn, PColumnSpec, PObjectId } from "@milaboratories/pl-model-common";
9
8
  import canonicalize from "canonicalize";
10
9
  import { afterEach, beforeEach, describe, expect, test } from "vitest";
11
10
  import type { PColumnDataUniversal } from "../../render/internal";
12
- import { buildRefMap, filterMatchesToOptions, findFilterColumns } from "./filter_discovery";
11
+ import { filterMatchesToOptions, findFilterColumns } from "./filter_discovery";
13
12
  import {
14
13
  createTestCollectionDriver,
15
14
  type TestCollectionDriverHandle,
@@ -108,33 +107,11 @@ describe("findFilterColumns", () => {
108
107
  });
109
108
  });
110
109
 
111
- describe("buildRefMap", () => {
112
- test("maps canonicalized PlRef to original ref", () => {
113
- const ref1 = createPlRef("b1", "out1");
114
- const ref2 = createPlRef("b2", "out2", true);
115
- const map = buildRefMap([{ ref: ref1 }, { ref: ref2 }]);
116
- expect(map.get(canonicalize(ref1)! as PObjectId)).toBe(ref1);
117
- expect(map.get(canonicalize(ref2)! as PObjectId)).toBe(ref2);
118
- expect(map.size).toBe(2);
119
- });
120
-
121
- test("returns empty map for empty entries", () => {
122
- expect(buildRefMap([]).size).toBe(0);
123
- });
124
- });
125
-
126
110
  describe("filterMatchesToOptions", () => {
127
111
  test("converts filter matches to Option[] with derived labels", () => {
128
112
  const filterRef1 = createPlRef("b1", "filter-top1000");
129
113
  const filterRef2 = createPlRef("b1", "filter-highconf");
130
114
 
131
- // Build ref map from entries (simulating result pool)
132
- const refMap = buildRefMap([
133
- { ref: anchorSnap.id as unknown as PlRef },
134
- { ref: filterRef1 },
135
- { ref: filterRef2 },
136
- ]);
137
-
138
115
  const filterSpec1 = spec("filter1", [axis("sample")], { [Annotation.IsSubset]: "true" });
139
116
  const filterSpec2 = spec("filter2", [axis("sample")], { [Annotation.IsSubset]: "true" });
140
117
 
@@ -149,14 +126,10 @@ describe("filterMatchesToOptions", () => {
149
126
  });
150
127
  expect(matches.length).toBe(2);
151
128
 
152
- const options = filterMatchesToOptions(matches, {
153
- refsByObjectId: refMap,
154
- datasetSpec: anchorSpec,
155
- });
129
+ const options = filterMatchesToOptions(matches, { datasetSpec: anchorSpec });
156
130
  expect(options).toHaveLength(2);
131
+ expect(options.map((o) => o.ref)).toEqual(expect.arrayContaining([filterRef1, filterRef2]));
157
132
  for (const opt of options) {
158
- expect(opt.ref).toBeDefined();
159
- expect(opt.label).toBeDefined();
160
133
  expect(typeof opt.label).toBe("string");
161
134
  }
162
135
  });
@@ -176,7 +149,6 @@ describe("filterMatchesToOptions", () => {
176
149
  });
177
150
 
178
151
  const filterRef = createPlRef("b1", "filter");
179
- const refMap = buildRefMap([{ ref: filterRef }]);
180
152
  const filterSpec = spec("filter", [axis("sample")], {
181
153
  [Annotation.IsSubset]: "true",
182
154
  [Annotation.Label]: "Selected Leads",
@@ -197,7 +169,7 @@ describe("filterMatchesToOptions", () => {
197
169
  });
198
170
  expect(matches).toHaveLength(1);
199
171
 
200
- const options = filterMatchesToOptions(matches, { refsByObjectId: refMap, datasetSpec });
172
+ const options = filterMatchesToOptions(matches, { datasetSpec });
201
173
  expect(options).toHaveLength(1);
202
174
  expect(options[0].label).toBe("Bulk / Top 10");
203
175
 
@@ -205,7 +177,6 @@ describe("filterMatchesToOptions", () => {
205
177
  // suppression — otherwise the algorithm short-circuits on the
206
178
  // inherited "Selected Leads" label.
207
179
  const withCustomNative = filterMatchesToOptions(matches, {
208
- refsByObjectId: refMap,
209
180
  datasetSpec,
210
181
  labelOptions: { formatters: { native: (l) => `<<${l}>>` } },
211
182
  });
@@ -213,7 +184,6 @@ describe("filterMatchesToOptions", () => {
213
184
 
214
185
  // Non-native label options (here `separator`) flow through.
215
186
  const withSeparator = filterMatchesToOptions(matches, {
216
- refsByObjectId: refMap,
217
187
  datasetSpec,
218
188
  labelOptions: { separator: " :: " },
219
189
  });
@@ -231,7 +201,6 @@ describe("filterMatchesToOptions", () => {
231
201
 
232
202
  const ref1 = createPlRef("b1", "f1");
233
203
  const ref2 = createPlRef("b2", "f2");
234
- const refMap = buildRefMap([{ ref: ref1 }, { ref: ref2 }]);
235
204
  const filterSpec1 = spec("filter1", [axis("sample")], {
236
205
  [Annotation.IsSubset]: "true",
237
206
  [Annotation.Label]: "Selected Leads",
@@ -262,22 +231,20 @@ describe("filterMatchesToOptions", () => {
262
231
  });
263
232
  expect(matches).toHaveLength(2);
264
233
 
265
- const options = filterMatchesToOptions(matches, { refsByObjectId: refMap, datasetSpec });
234
+ const options = filterMatchesToOptions(matches, { datasetSpec });
266
235
  expect(options.map((o) => o.label).sort()).toEqual(["Bulk / Top 10", "Bulk / Top 11"]);
267
236
  });
268
237
 
269
238
  test("returns empty array for empty matches", () => {
270
- expect(
271
- filterMatchesToOptions([], { refsByObjectId: new Map(), datasetSpec: anchorSpec }),
272
- ).toEqual([]);
239
+ expect(filterMatchesToOptions([], { datasetSpec: anchorSpec })).toEqual([]);
273
240
  });
274
241
 
275
- test("skips entries whose id is not in refsByObjectId", () => {
242
+ test("skips a column that is not a block output", () => {
276
243
  const knownRef = createPlRef("b1", "known");
277
244
  const knownSpec = spec("known", [axis("sample")], { [Annotation.IsSubset]: "true" });
278
245
  const orphanSpec = spec("orphan", [axis("sample")], { [Annotation.IsSubset]: "true" });
279
246
  const knownSnap = col(canonicalize(knownRef)! as PObjectId, knownSpec);
280
- const orphanSnap = col(gid("orphan"), orphanSpec);
247
+ const orphanSnap = col(createLocalPObjectId(["main"], "orphan"), orphanSpec);
281
248
  registerCols([knownSnap, orphanSnap, anchorSnap]);
282
249
 
283
250
  const matches = findFilterColumns({
@@ -286,12 +253,8 @@ describe("filterMatchesToOptions", () => {
286
253
  driver: driverHandle.driver,
287
254
  });
288
255
  expect(matches.length).toBe(2);
289
- const refMap = buildRefMap([{ ref: knownRef }]);
290
- const options = filterMatchesToOptions(matches, {
291
- refsByObjectId: refMap,
292
- datasetSpec: anchorSpec,
293
- });
256
+ const options = filterMatchesToOptions(matches, { datasetSpec: anchorSpec });
294
257
  expect(options).toHaveLength(1);
295
- expect(options[0].ref).toBe(knownRef);
258
+ expect(options[0].ref).toEqual(knownRef);
296
259
  });
297
260
  });
@@ -1,14 +1,12 @@
1
- import { Annotation, extractPObjectId } from "@milaboratories/pl-model-common";
1
+ import { Annotation, columnProducer, createPlRef } from "@milaboratories/pl-model-common";
2
2
  import type {
3
3
  ColumnsCollectionDriverModel,
4
4
  Option,
5
5
  PColumnSpec,
6
6
  PlRef,
7
- PObjectId,
8
7
  PObjectSpec,
9
8
  } from "@milaboratories/pl-model-common";
10
- import canonicalize from "canonicalize";
11
- import type { ColumnRecipe, ColumnsSource } from "../../columns";
9
+ import type { ColumnRecipe, ColumnsSource, ColumnsSourceShorthand } from "../../columns";
12
10
  import { ColumnsCollection, collectLinkerColumns } from "../../columns";
13
11
  import {
14
12
  deriveDistinctLabels,
@@ -17,7 +15,7 @@ import {
17
15
  } from "../../labels/derive_distinct_labels";
18
16
 
19
17
  export interface FindFilterColumnsOptions {
20
- sources: ReadonlyArray<ColumnsSource>;
18
+ sources: ReadonlyArray<ColumnsCollection | ColumnsSource | ColumnsSourceShorthand>;
21
19
  anchorSpec: PColumnSpec;
22
20
  /** Override the resolved `columnsCollection` service (primarily for tests). */
23
21
  driver?: ColumnsCollectionDriverModel;
@@ -43,8 +41,6 @@ export function findFilterColumns(options: FindFilterColumnsOptions): ColumnReci
43
41
  }
44
42
 
45
43
  export type FilterMatchOptions = {
46
- /** Maps result-pool column id back to its source PlRef (see {@link buildRefMap}). */
47
- refsByObjectId: ReadonlyMap<PObjectId, PlRef>;
48
44
  /** Spec of the dataset the filters are subsets of. */
49
45
  datasetSpec: PObjectSpec;
50
46
  /**
@@ -59,8 +55,8 @@ export type FilterMatchOptions = {
59
55
  /**
60
56
  * Derive labeled options from filter column variants, for use in DatasetOption.filters.
61
57
  *
62
- * Entries whose column id has no PlRef in `refsByObjectId` are silently
63
- * skipped — they cannot be exposed as user-selectable options.
58
+ * A filter is stored as a reference to a block output, so a column that is
59
+ * not one — a column of the current block — is silently skipped.
64
60
  */
65
61
  export function filterMatchesToOptions(
66
62
  variants: ColumnRecipe[],
@@ -68,17 +64,16 @@ export function filterMatchesToOptions(
68
64
  ): Option[] {
69
65
  if (variants.length === 0) return [];
70
66
 
71
- const { refsByObjectId, datasetSpec, labelOptions } = options;
67
+ const { datasetSpec, labelOptions } = options;
72
68
 
73
69
  // One Option per variant — `deriveDistinctLabels` disambiguates labels by
74
- // path. All variants of the same column share a terminal PObjectId, so the
75
- // ref lookup happens once per variant.
70
+ // path.
76
71
  const entries: (Entry & { ref: PlRef })[] = variants.flatMap((variant) => {
77
- const ref = refsByObjectId.get(extractPObjectId(variant.id));
78
- if (ref === undefined) return [];
72
+ const producer = columnProducer(variant.id);
73
+ if (producer === undefined) return [];
79
74
  return [
80
75
  {
81
- ref,
76
+ ref: createPlRef(producer.blockId, producer.name),
82
77
  spec: variant.getSpec(),
83
78
  linkerPath: collectLinkerColumns(variant).map((linker) => ({ spec: linker.getSpec() })),
84
79
  },
@@ -98,8 +93,3 @@ export function filterMatchesToOptions(
98
93
 
99
94
  return entries.map(({ ref }, i) => ({ ref, label: labels[i] }));
100
95
  }
101
-
102
- /** Build the `refsByObjectId` map from `ctx.resultPool.getSpecs().entries`. */
103
- export function buildRefMap(entries: readonly { readonly ref: PlRef }[]): Map<PObjectId, PlRef> {
104
- return new Map(entries.map((e) => [canonicalize(e.ref)! as PObjectId, e.ref]));
105
- }