@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.
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs +2 -2
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js +2 -2
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs +5 -4
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts +12 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js +5 -4
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js.map +1 -1
- package/dist/components/PlDataTable/createPlDataTableSheet.cjs +7 -3
- package/dist/components/PlDataTable/createPlDataTableSheet.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTableSheet.d.ts +7 -2
- package/dist/components/PlDataTable/createPlDataTableSheet.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTableSheet.js +7 -3
- package/dist/components/PlDataTable/createPlDataTableSheet.js.map +1 -1
- package/dist/components/PlDataTable/index.cjs +2 -0
- package/dist/components/PlDataTable/index.d.ts +2 -1
- package/dist/components/PlDataTable/index.js +2 -1
- package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
- package/dist/components/PlDataTable/state-migration.d.ts +2 -2
- package/dist/components/PlDataTable/state-migration.d.ts.map +1 -1
- package/dist/components/PlDataTable/state-migration.js.map +1 -1
- package/dist/components/PlDataTable/tableParams.cjs +61 -15
- package/dist/components/PlDataTable/tableParams.cjs.map +1 -1
- package/dist/components/PlDataTable/tableParams.d.ts +8 -0
- package/dist/components/PlDataTable/tableParams.d.ts.map +1 -0
- package/dist/components/PlDataTable/tableParams.js +60 -16
- package/dist/components/PlDataTable/tableParams.js.map +1 -1
- package/dist/components/PlDataTable/typesV8.d.ts +18 -0
- package/dist/components/PlDataTable/typesV8.d.ts.map +1 -1
- package/dist/components/PlDatasetSelector/build_dataset_options.cjs +43 -33
- package/dist/components/PlDatasetSelector/build_dataset_options.cjs.map +1 -1
- package/dist/components/PlDatasetSelector/build_dataset_options.d.ts +6 -2
- package/dist/components/PlDatasetSelector/build_dataset_options.d.ts.map +1 -1
- package/dist/components/PlDatasetSelector/build_dataset_options.js +46 -36
- package/dist/components/PlDatasetSelector/build_dataset_options.js.map +1 -1
- package/dist/components/PlDatasetSelector/dataset_selection.cjs.map +1 -1
- package/dist/components/PlDatasetSelector/dataset_selection.d.ts +13 -4
- package/dist/components/PlDatasetSelector/dataset_selection.d.ts.map +1 -1
- package/dist/components/PlDatasetSelector/dataset_selection.js.map +1 -1
- package/dist/components/PlDatasetSelector/enrichment_discovery.cjs +20 -26
- package/dist/components/PlDatasetSelector/enrichment_discovery.cjs.map +1 -1
- package/dist/components/PlDatasetSelector/enrichment_discovery.js +22 -28
- package/dist/components/PlDatasetSelector/enrichment_discovery.js.map +1 -1
- package/dist/components/PlDatasetSelector/filter_discovery.cjs +6 -14
- package/dist/components/PlDatasetSelector/filter_discovery.cjs.map +1 -1
- package/dist/components/PlDatasetSelector/filter_discovery.d.ts +5 -10
- package/dist/components/PlDatasetSelector/filter_discovery.d.ts.map +1 -1
- package/dist/components/PlDatasetSelector/filter_discovery.js +8 -13
- package/dist/components/PlDatasetSelector/filter_discovery.js.map +1 -1
- package/dist/components/PlDatasetSelector/index.cjs +0 -1
- package/dist/components/PlDatasetSelector/index.d.ts +3 -3
- package/dist/components/PlDatasetSelector/index.js +2 -2
- package/dist/components/index.cjs +2 -1
- package/dist/components/index.d.ts +4 -3
- package/dist/components/index.js +3 -2
- package/dist/index.cjs +2 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -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 +45 -5
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV2.ts +2 -1
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV3.ts +20 -2
- package/src/components/PlDataTable/createPlDataTableSheet.ts +6 -1
- package/src/components/PlDataTable/index.ts +1 -0
- package/src/components/PlDataTable/state-migration.ts +5 -5
- package/src/components/PlDataTable/tableParams.test.ts +71 -0
- package/src/components/PlDataTable/tableParams.ts +66 -9
- package/src/components/PlDataTable/typesV8.ts +27 -6
- package/src/components/PlDatasetSelector/build_dataset_options.test.ts +195 -0
- package/src/components/PlDatasetSelector/build_dataset_options.ts +86 -63
- package/src/components/PlDatasetSelector/dataset_selection.ts +14 -4
- package/src/components/PlDatasetSelector/enrichment_discovery.ts +26 -35
- package/src/components/PlDatasetSelector/filter_discovery.test.ts +16 -53
- package/src/components/PlDatasetSelector/filter_discovery.ts +10 -20
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { deriveDistinctLabels } from "../../labels/derive_distinct_labels.js";
|
|
2
|
+
import { ColumnsCollection } from "../../columns/columns_collection.js";
|
|
3
3
|
import "../../columns/index.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { filterMatchesToOptions, findFilterColumns } from "./filter_discovery.js";
|
|
5
|
+
import { findEnrichmentColumns, labelEnrichments } from "./enrichment_discovery.js";
|
|
6
|
+
import { columnProducer, createPlRef, multiColumnSelectorsToPredicate } from "@milaboratories/pl-model-common";
|
|
7
7
|
// src/components/PlDatasetSelector/build_dataset_options.ts
|
|
8
|
-
function toPredicate(opt) {
|
|
9
|
-
if (opt === void 0) return () => true;
|
|
10
|
-
return typeof opt === "function" ? opt : multiColumnSelectorsToPredicate(opt);
|
|
11
|
-
}
|
|
12
8
|
/**
|
|
13
9
|
* Usage:
|
|
14
10
|
* ```ts
|
|
@@ -16,43 +12,57 @@ function toPredicate(opt) {
|
|
|
16
12
|
* ```
|
|
17
13
|
*/
|
|
18
14
|
function buildDatasetOptions(ctx, opts) {
|
|
19
|
-
const
|
|
15
|
+
const pool = ColumnsCollection(["result_pool"], { ctx: ctx.ctx });
|
|
16
|
+
const datasets = findDatasets(pool, opts?.primary).flatMap((column) => {
|
|
17
|
+
const producer = columnProducer(column.id);
|
|
18
|
+
return producer === void 0 ? [] : [{
|
|
19
|
+
column,
|
|
20
|
+
producer
|
|
21
|
+
}];
|
|
22
|
+
});
|
|
23
|
+
if (datasets.length === 0) return [];
|
|
24
|
+
const labels = deriveDistinctLabels(datasets.map(({ column }) => column.getSpec()));
|
|
25
|
+
const requireEnrichments = opts?.requireEnrichments ?? true;
|
|
20
26
|
const filterPredicate = toPredicate(opts?.filter);
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return
|
|
28
|
-
const datasetSpec =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const withEnrichments = opts?.withEnrichments;
|
|
28
|
+
const enrichmentSearch = withEnrichments === void 0 ? void 0 : {
|
|
29
|
+
sources: [ColumnsCollection(["current_block", pool], { ctx: ctx.ctx })],
|
|
30
|
+
maxHops: opts?.enrichmentMaxHops,
|
|
31
|
+
...typeof withEnrichments === "function" ? { predicate: withEnrichments } : { include: withEnrichments }
|
|
32
|
+
};
|
|
33
|
+
return datasets.map(({ column, producer }, i) => {
|
|
34
|
+
const datasetSpec = column.getSpec();
|
|
35
|
+
const primary = {
|
|
36
|
+
ref: createPlRef(producer.blockId, producer.name, requireEnrichments),
|
|
37
|
+
label: labels[i]
|
|
38
|
+
};
|
|
39
|
+
const filters = filterMatchesToOptions(findFilterColumns({
|
|
40
|
+
sources: [pool],
|
|
32
41
|
anchorSpec: datasetSpec
|
|
33
|
-
}).filter((
|
|
34
|
-
const filters = filterMatches.length === 0 ? void 0 : filterMatchesToOptions(filterMatches, {
|
|
35
|
-
refsByObjectId: refMap,
|
|
42
|
+
}).filter((match) => filterPredicate(match.getSpec())), {
|
|
36
43
|
datasetSpec,
|
|
37
44
|
labelOptions: opts?.labelOptions
|
|
38
45
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
anchorSpec: datasetSpec,
|
|
44
|
-
maxHops: opts?.enrichmentMaxHops,
|
|
45
|
-
...typeof withEnrichments === "function" ? { predicate: withEnrichments } : { include: withEnrichments }
|
|
46
|
-
});
|
|
47
|
-
if (enrichmentVariants.length > 0) enrichments = enrichmentVariantsToRefs(enrichmentVariants, opts?.labelOptions);
|
|
48
|
-
}
|
|
46
|
+
const enrichments = enrichmentSearch === void 0 ? [] : labelEnrichments(findEnrichmentColumns({
|
|
47
|
+
...enrichmentSearch,
|
|
48
|
+
anchorSpec: datasetSpec
|
|
49
|
+
}), opts?.labelOptions);
|
|
49
50
|
return {
|
|
50
51
|
primary,
|
|
51
|
-
...filters
|
|
52
|
-
...enrichments
|
|
52
|
+
...filters.length > 0 ? { filters } : {},
|
|
53
|
+
...enrichments.length > 0 ? { enrichments } : {}
|
|
53
54
|
};
|
|
54
55
|
});
|
|
55
56
|
}
|
|
57
|
+
function toPredicate(opt) {
|
|
58
|
+
if (opt === void 0) return () => true;
|
|
59
|
+
return typeof opt === "function" ? opt : multiColumnSelectorsToPredicate(opt);
|
|
60
|
+
}
|
|
61
|
+
function findDatasets(pool, primary) {
|
|
62
|
+
if (primary === void 0) return pool.getColumns();
|
|
63
|
+
if (typeof primary === "function") return pool.getColumns().filter((column) => primary(column.getSpec()));
|
|
64
|
+
return pool.filter({ include: primary }).getColumns();
|
|
65
|
+
}
|
|
56
66
|
export { buildDatasetOptions };
|
|
57
67
|
|
|
58
68
|
//# sourceMappingURL=build_dataset_options.js.map
|
|
@@ -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 {
|
|
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 {\n columnProducer,\n createPlRef,\n multiColumnSelectorsToPredicate,\n} from \"@milaboratories/pl-model-common\";\nimport type { ColumnRecipe } from \"../../columns\";\nimport { ColumnsCollection } from \"../../columns\";\nimport {\n deriveDistinctLabels,\n type DeriveLabelsOptions,\n} from \"../../labels/derive_distinct_labels\";\nimport type { RenderCtxBase } from \"../../render\";\nimport type { DatasetOption } from \"./dataset_selection\";\nimport { filterMatchesToOptions, findFilterColumns } from \"./filter_discovery\";\nimport { findEnrichmentColumns, labelEnrichments } from \"./enrichment_discovery\";\n\nexport type BuildDatasetOptions = {\n /**\n * Which result pool columns qualify as datasets. Defaults to all. A selector\n * is matched by the host; a predicate reads the spec of every result pool\n * column, so prefer a selector when it can say the same.\n */\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 pool = ColumnsCollection([\"result_pool\"], { ctx: ctx.ctx });\n\n // A dataset is stored as a reference to a block output, so only a column\n // that is one can be offered.\n const datasets = findDatasets(pool, opts?.primary).flatMap((column) => {\n const producer = columnProducer(column.id);\n return producer === undefined ? [] : [{ column, producer }];\n });\n if (datasets.length === 0) return [];\n\n const labels = deriveDistinctLabels(datasets.map(({ column }) => column.getSpec()));\n const requireEnrichments = opts?.requireEnrichments ?? true;\n const filterPredicate = toPredicate(opts?.filter);\n\n const withEnrichments = opts?.withEnrichments;\n const enrichmentSearch =\n withEnrichments === undefined\n ? undefined\n : {\n // Enrichments are also looked for among this block's own columns.\n // Built once: every dataset searches the same set.\n sources: [ColumnsCollection([\"current_block\", pool], { ctx: ctx.ctx })],\n maxHops: opts?.enrichmentMaxHops,\n ...(typeof withEnrichments === \"function\"\n ? { predicate: withEnrichments }\n : { include: withEnrichments }),\n };\n\n return datasets.map(({ column, producer }, i): DatasetOption => {\n const datasetSpec = column.getSpec();\n const primary: Option = {\n ref: createPlRef(producer.blockId, producer.name, requireEnrichments),\n label: labels[i],\n };\n\n const filters = filterMatchesToOptions(\n findFilterColumns({ sources: [pool], anchorSpec: datasetSpec }).filter((match) =>\n filterPredicate(match.getSpec()),\n ),\n { datasetSpec, labelOptions: opts?.labelOptions },\n );\n\n const enrichments =\n enrichmentSearch === undefined\n ? []\n : labelEnrichments(\n findEnrichmentColumns({ ...enrichmentSearch, anchorSpec: datasetSpec }),\n opts?.labelOptions,\n );\n\n return {\n primary,\n ...(filters.length > 0 ? { filters } : {}),\n ...(enrichments.length > 0 ? { enrichments } : {}),\n };\n });\n}\n\n// Internals\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\nfunction findDatasets(\n pool: ColumnsCollection,\n primary: SpecPredicateOption | undefined,\n): ColumnRecipe[] {\n if (primary === undefined) return pool.getColumns();\n if (typeof primary === \"function\") {\n return pool.getColumns().filter((column) => primary(column.getSpec()));\n }\n return pool.filter({ include: primary }).getColumns();\n}\n"],"mappings":";;;;;;;;;;;;;AAyDA,SAAgB,oBACd,KACA,MAC6B;CAC7B,MAAM,OAAO,kBAAkB,CAAC,aAAa,GAAG,EAAE,KAAK,IAAI,IAAI,CAAC;CAIhE,MAAM,WAAW,aAAa,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,WAAW;EACrE,MAAM,WAAW,eAAe,OAAO,EAAE;EACzC,OAAO,aAAa,KAAA,IAAY,CAAC,IAAI,CAAC;GAAE;GAAQ;EAAS,CAAC;CAC5D,CAAC;CACD,IAAI,SAAS,WAAW,GAAG,OAAO,CAAC;CAEnC,MAAM,SAAS,qBAAqB,SAAS,KAAK,EAAE,aAAa,OAAO,QAAQ,CAAC,CAAC;CAClF,MAAM,qBAAqB,MAAM,sBAAsB;CACvD,MAAM,kBAAkB,YAAY,MAAM,MAAM;CAEhD,MAAM,kBAAkB,MAAM;CAC9B,MAAM,mBACJ,oBAAoB,KAAA,IAChB,KAAA,IACA;EAGE,SAAS,CAAC,kBAAkB,CAAC,iBAAiB,IAAI,GAAG,EAAE,KAAK,IAAI,IAAI,CAAC,CAAC;EACtE,SAAS,MAAM;EACf,GAAI,OAAO,oBAAoB,aAC3B,EAAE,WAAW,gBAAgB,IAC7B,EAAE,SAAS,gBAAgB;CACjC;CAEN,OAAO,SAAS,KAAK,EAAE,QAAQ,YAAY,MAAqB;EAC9D,MAAM,cAAc,OAAO,QAAQ;EACnC,MAAM,UAAkB;GACtB,KAAK,YAAY,SAAS,SAAS,SAAS,MAAM,kBAAkB;GACpE,OAAO,OAAO;EAChB;EAEA,MAAM,UAAU,uBACd,kBAAkB;GAAE,SAAS,CAAC,IAAI;GAAG,YAAY;EAAY,CAAC,CAAC,CAAC,QAAQ,UACtE,gBAAgB,MAAM,QAAQ,CAAC,CACjC,GACA;GAAE;GAAa,cAAc,MAAM;EAAa,CAClD;EAEA,MAAM,cACJ,qBAAqB,KAAA,IACjB,CAAC,IACD,iBACE,sBAAsB;GAAE,GAAG;GAAkB,YAAY;EAAY,CAAC,GACtE,MAAM,YACR;EAEN,OAAO;GACL;GACA,GAAI,QAAQ,SAAS,IAAI,EAAE,QAAQ,IAAI,CAAC;GACxC,GAAI,YAAY,SAAS,IAAI,EAAE,YAAY,IAAI,CAAC;EAClD;CACF,CAAC;AACH;AASA,SAAS,YAAY,KAAsE;CACzF,IAAI,QAAQ,KAAA,GAAW,aAAa;CACpC,OAAO,OAAO,QAAQ,aAAa,MAAM,gCAAgC,GAAG;AAC9E;AAEA,SAAS,aACP,MACA,SACgB;CAChB,IAAI,YAAY,KAAA,GAAW,OAAO,KAAK,WAAW;CAClD,IAAI,OAAO,YAAY,YACrB,OAAO,KAAK,WAAW,CAAC,CAAC,QAAQ,WAAW,QAAQ,OAAO,QAAQ,CAAC,CAAC;CAEvE,OAAO,KAAK,OAAO,EAAE,SAAS,QAAQ,CAAC,CAAC,CAAC,WAAW;AACtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataset_selection.cjs","names":[],"sources":["../../../src/components/PlDatasetSelector/dataset_selection.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"dataset_selection.cjs","names":[],"sources":["../../../src/components/PlDatasetSelector/dataset_selection.ts"],"sourcesContent":["import type { ColumnUniversalId, Option, PrimaryRef } from \"@milaboratories/pl-model-common\";\n\n/**\n * A column joined to a dataset without being picked by the user, with the header\n * it is exported under. The id names a block output reached from the dataset\n * through linker columns, so a workflow can find the column by the id alone.\n */\nexport type DatasetEnrichment = {\n readonly id: ColumnUniversalId;\n readonly label: string;\n};\n\n/** Dataset picker entry: user picks {@link primary}, gets {@link enrichments} attached. */\nexport type DatasetOption = {\n readonly primary: Option;\n readonly filters?: readonly Option[];\n readonly enrichments?: readonly DatasetEnrichment[];\n};\n\n/**\n * Picked dataset bundle emitted by `PlDatasetSelector`. Stored opaquely in\n * block data; block authors unbundle inside their args resolver.\n */\nexport type DatasetSelection = {\n readonly __isDatasetSelection: \"v1\";\n readonly primary: PrimaryRef;\n readonly enrichments?: readonly DatasetEnrichment[];\n};\n\nexport function isDatasetSelection(value: unknown): value is DatasetSelection {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as { __isDatasetSelection?: unknown }).__isDatasetSelection === \"v1\" &&\n \"primary\" in value\n );\n}\n\nexport function createDatasetSelection(\n primary: PrimaryRef,\n enrichments?: readonly DatasetEnrichment[],\n): DatasetSelection {\n if (enrichments !== undefined && enrichments.length > 0) {\n return { __isDatasetSelection: \"v1\", primary, enrichments };\n }\n return { __isDatasetSelection: \"v1\", primary };\n}\n"],"mappings":";AA6BA,SAAgB,mBAAmB,OAA2C;CAC5E,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA6C,yBAAyB,QACvE,aAAa;AAEjB;AAEA,SAAgB,uBACd,SACA,aACkB;CAClB,IAAI,gBAAgB,KAAA,KAAa,YAAY,SAAS,GACpD,OAAO;EAAE,sBAAsB;EAAM;EAAS;CAAY;CAE5D,OAAO;EAAE,sBAAsB;EAAM;CAAQ;AAC/C"}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ColumnUniversalId, Option, PrimaryRef } from "@milaboratories/pl-model-common";
|
|
2
|
+
/**
|
|
3
|
+
* A column joined to a dataset without being picked by the user, with the header
|
|
4
|
+
* it is exported under. The id names a block output reached from the dataset
|
|
5
|
+
* through linker columns, so a workflow can find the column by the id alone.
|
|
6
|
+
*/
|
|
7
|
+
export type DatasetEnrichment = {
|
|
8
|
+
readonly id: ColumnUniversalId;
|
|
9
|
+
readonly label: string;
|
|
10
|
+
};
|
|
2
11
|
/** Dataset picker entry: user picks {@link primary}, gets {@link enrichments} attached. */
|
|
3
12
|
export type DatasetOption = {
|
|
4
13
|
readonly primary: Option;
|
|
5
14
|
readonly filters?: readonly Option[];
|
|
6
|
-
readonly enrichments?:
|
|
15
|
+
readonly enrichments?: readonly DatasetEnrichment[];
|
|
7
16
|
};
|
|
8
17
|
/**
|
|
9
18
|
* Picked dataset bundle emitted by `PlDatasetSelector`. Stored opaquely in
|
|
@@ -12,8 +21,8 @@ export type DatasetOption = {
|
|
|
12
21
|
export type DatasetSelection = {
|
|
13
22
|
readonly __isDatasetSelection: "v1";
|
|
14
23
|
readonly primary: PrimaryRef;
|
|
15
|
-
readonly enrichments?:
|
|
24
|
+
readonly enrichments?: readonly DatasetEnrichment[];
|
|
16
25
|
};
|
|
17
26
|
export declare function isDatasetSelection(value: unknown): value is DatasetSelection;
|
|
18
|
-
export declare function createDatasetSelection(primary: PrimaryRef, enrichments?:
|
|
27
|
+
export declare function createDatasetSelection(primary: PrimaryRef, enrichments?: readonly DatasetEnrichment[]): DatasetSelection;
|
|
19
28
|
//# sourceMappingURL=dataset_selection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataset_selection.d.ts","names":[],"sources":["../../../src/components/PlDatasetSelector/dataset_selection.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dataset_selection.d.ts","names":[],"sources":["../../../src/components/PlDatasetSelector/dataset_selection.ts"],"mappings":";;;;;;YAOY;WACD,IAAI;WACJ;;;YAIC;WACD,SAAS;WACT,mBAAmB;WACnB,uBAAuB;;;;;;YAOtB;WACD;WACA,SAAS;WACT,uBAAuB;;wBAGlB,mBAAmB,iBAAiB,SAAS;wBAS7C,uBACd,SAAS,YACT,uBAAuB,sBACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataset_selection.js","names":[],"sources":["../../../src/components/PlDatasetSelector/dataset_selection.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"dataset_selection.js","names":[],"sources":["../../../src/components/PlDatasetSelector/dataset_selection.ts"],"sourcesContent":["import type { ColumnUniversalId, Option, PrimaryRef } from \"@milaboratories/pl-model-common\";\n\n/**\n * A column joined to a dataset without being picked by the user, with the header\n * it is exported under. The id names a block output reached from the dataset\n * through linker columns, so a workflow can find the column by the id alone.\n */\nexport type DatasetEnrichment = {\n readonly id: ColumnUniversalId;\n readonly label: string;\n};\n\n/** Dataset picker entry: user picks {@link primary}, gets {@link enrichments} attached. */\nexport type DatasetOption = {\n readonly primary: Option;\n readonly filters?: readonly Option[];\n readonly enrichments?: readonly DatasetEnrichment[];\n};\n\n/**\n * Picked dataset bundle emitted by `PlDatasetSelector`. Stored opaquely in\n * block data; block authors unbundle inside their args resolver.\n */\nexport type DatasetSelection = {\n readonly __isDatasetSelection: \"v1\";\n readonly primary: PrimaryRef;\n readonly enrichments?: readonly DatasetEnrichment[];\n};\n\nexport function isDatasetSelection(value: unknown): value is DatasetSelection {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as { __isDatasetSelection?: unknown }).__isDatasetSelection === \"v1\" &&\n \"primary\" in value\n );\n}\n\nexport function createDatasetSelection(\n primary: PrimaryRef,\n enrichments?: readonly DatasetEnrichment[],\n): DatasetSelection {\n if (enrichments !== undefined && enrichments.length > 0) {\n return { __isDatasetSelection: \"v1\", primary, enrichments };\n }\n return { __isDatasetSelection: \"v1\", primary };\n}\n"],"mappings":";AA6BA,SAAgB,mBAAmB,OAA2C;CAC5E,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA6C,yBAAyB,QACvE,aAAa;AAEjB;AAEA,SAAgB,uBACd,SACA,aACkB;CAClB,IAAI,gBAAgB,KAAA,KAAa,YAAY,SAAS,GACpD,OAAO;EAAE,sBAAsB;EAAM;EAAS;CAAY;CAE5D,OAAO;EAAE,sBAAsB;EAAM;CAAQ;AAC/C"}
|
|
@@ -8,6 +8,9 @@ let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common")
|
|
|
8
8
|
* Linker-reached hits attached to the anchor primary. Drops zero-hop variants
|
|
9
9
|
* (filters / the primary itself) and structural hits (subset, linker, label
|
|
10
10
|
* columns). Narrow further with `include` selectors or a `predicate`.
|
|
11
|
+
*
|
|
12
|
+
* A hit is kept only when a workflow can find it by its id: the hit and every
|
|
13
|
+
* linker leading to it are block outputs.
|
|
11
14
|
*/
|
|
12
15
|
function findEnrichmentColumns(options) {
|
|
13
16
|
const include = options.include === void 0 ? void 0 : Array.isArray(options.include) ? options.include : [options.include];
|
|
@@ -25,45 +28,36 @@ function findEnrichmentColumns(options) {
|
|
|
25
28
|
const predicate = options.predicate;
|
|
26
29
|
return columns.filter((v) => {
|
|
27
30
|
if (require_utils.hasSingleDataColumn(v)) return false;
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
if (require_utils.collectLinkerIds(v).some((id) => !(0, _milaboratories_pl_model_common.isGlobalPObjectId)(id))) return false;
|
|
31
|
-
return true;
|
|
31
|
+
if (!reachesBlockOutputs(v.id)) return false;
|
|
32
|
+
return predicate === void 0 || predicate(v.getSpec());
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* `qualifications.forHit`; `forQueries` is re-derived by the table builder.
|
|
36
|
+
* Pairs each column with a label that tells apart the same hit reached through
|
|
37
|
+
* different linkers, so export headers stay unique.
|
|
38
38
|
*/
|
|
39
|
-
function
|
|
39
|
+
function labelEnrichments(variants, labelOptions) {
|
|
40
40
|
if (variants.length === 0) return [];
|
|
41
|
-
const
|
|
42
|
-
const hitQualsByVariant = variants.map((v) => [...require_utils.hitQualifications(v)]);
|
|
43
|
-
const entries = variants.map((variant, i) => ({
|
|
41
|
+
const entries = variants.map((variant) => ({
|
|
44
42
|
spec: variant.getSpec(),
|
|
45
43
|
linkerPath: require_utils.collectLinkerColumns(variant).map((linker) => ({ spec: linker.getSpec() })),
|
|
46
44
|
qualifications: {
|
|
47
|
-
forHit:
|
|
45
|
+
forHit: [...require_utils.hitQualifications(variant)],
|
|
48
46
|
forQueries: require_utils.queriesQualifications(variant)
|
|
49
47
|
}
|
|
50
48
|
}));
|
|
51
49
|
const labels = require_derive_distinct_labels.deriveDistinctLabels(entries, labelOptions);
|
|
52
|
-
return variants.map((variant, i) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}),
|
|
62
|
-
label: labels[i]
|
|
63
|
-
};
|
|
64
|
-
});
|
|
50
|
+
return variants.map((variant, i) => ({
|
|
51
|
+
id: variant.id,
|
|
52
|
+
label: labels[i]
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
function reachesBlockOutputs(id) {
|
|
56
|
+
if (!(0, _milaboratories_pl_model_common.isColumnDiscoveredId)(id)) return false;
|
|
57
|
+
const key = (0, _milaboratories_pl_model_common.parseColumnDiscoveredId)(id);
|
|
58
|
+
return [key.column, ...(key.path ?? []).map((step) => step.column)].every(_milaboratories_pl_model_common.isGlobalPObjectId);
|
|
65
59
|
}
|
|
66
|
-
exports.enrichmentVariantsToRefs = enrichmentVariantsToRefs;
|
|
67
60
|
exports.findEnrichmentColumns = findEnrichmentColumns;
|
|
61
|
+
exports.labelEnrichments = labelEnrichments;
|
|
68
62
|
|
|
69
63
|
//# sourceMappingURL=enrichment_discovery.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enrichment_discovery.cjs","names":["ColumnsCollection","Annotation","hasSingleDataColumn","
|
|
1
|
+
{"version":3,"file":"enrichment_discovery.cjs","names":["ColumnsCollection","Annotation","hasSingleDataColumn","collectLinkerColumns","hitQualifications","queriesQualifications","deriveDistinctLabels","isColumnDiscoveredId","parseColumnDiscoveredId","isGlobalPObjectId"],"sources":["../../../src/components/PlDatasetSelector/enrichment_discovery.ts"],"sourcesContent":["import {\n Annotation,\n isColumnDiscoveredId,\n isGlobalPObjectId,\n parseColumnDiscoveredId,\n} from \"@milaboratories/pl-model-common\";\nimport type {\n ColumnsCollectionDriverModel,\n ColumnUniversalId,\n MultiColumnSelector,\n PColumnSpec,\n PObjectSpec,\n} from \"@milaboratories/pl-model-common\";\nimport type { ColumnRecipe, ColumnsSource, ColumnsSourceShorthand } from \"../../columns\";\nimport {\n hasSingleDataColumn,\n ColumnsCollection,\n hitQualifications,\n collectLinkerColumns,\n queriesQualifications,\n} from \"../../columns\";\nimport {\n deriveDistinctLabels,\n type DeriveLabelsOptions,\n type Entry,\n} from \"../../labels/derive_distinct_labels\";\nimport type { DatasetEnrichment } from \"./dataset_selection\";\n\nexport interface FindEnrichmentColumnsOptions {\n sources: ReadonlyArray<ColumnsCollection | ColumnsSource | ColumnsSourceShorthand>;\n anchorSpec: PColumnSpec;\n maxHops?: number;\n include?: MultiColumnSelector | MultiColumnSelector[];\n predicate?: (spec: PObjectSpec) => boolean;\n /** Override the resolved `columnsCollection` service (primarily for tests). */\n driver?: ColumnsCollectionDriverModel;\n}\n\n/**\n * Linker-reached hits attached to the anchor primary. Drops zero-hop variants\n * (filters / the primary itself) and structural hits (subset, linker, label\n * columns). Narrow further with `include` selectors or a `predicate`.\n *\n * A hit is kept only when a workflow can find it by its id: the hit and every\n * linker leading to it are block outputs.\n */\nexport function findEnrichmentColumns(options: FindEnrichmentColumnsOptions): ColumnRecipe[] {\n const include =\n options.include === undefined\n ? undefined\n : Array.isArray(options.include)\n ? options.include\n : [options.include];\n\n const columns = ColumnsCollection([...options.sources], { driver: options.driver })\n .discover({\n anchors: { main: options.anchorSpec },\n mode: \"enrichment\",\n maxHops: options.maxHops ?? 4,\n include,\n exclude: [\n { annotations: { [Annotation.IsSubset]: \"true\" } },\n { annotations: { [Annotation.IsLinkerColumn]: \"true\" } },\n { name: Annotation.Label },\n ],\n })\n .getColumns();\n\n const predicate = options.predicate;\n return columns.filter((v) => {\n if (hasSingleDataColumn(v)) return false;\n if (!reachesBlockOutputs(v.id)) return false;\n return predicate === undefined || predicate(v.getSpec());\n });\n}\n\n/**\n * Pairs each column with a label that tells apart the same hit reached through\n * different linkers, so export headers stay unique.\n */\nexport function labelEnrichments(\n variants: ColumnRecipe[],\n labelOptions?: DeriveLabelsOptions,\n): DatasetEnrichment[] {\n if (variants.length === 0) return [];\n\n const entries: Entry[] = variants.map((variant) => ({\n spec: variant.getSpec(),\n linkerPath: collectLinkerColumns(variant).map((linker) => ({ spec: linker.getSpec() })),\n qualifications: {\n forHit: [...hitQualifications(variant)],\n forQueries: queriesQualifications(variant),\n },\n }));\n const labels = deriveDistinctLabels(entries, labelOptions);\n\n return variants.map((variant, i): DatasetEnrichment => ({ id: variant.id, label: labels[i] }));\n}\n\n// Internals\n\nfunction reachesBlockOutputs(id: ColumnUniversalId): boolean {\n if (!isColumnDiscoveredId(id)) return false;\n const key = parseColumnDiscoveredId(id);\n return [key.column, ...(key.path ?? []).map((step) => step.column)].every(isGlobalPObjectId);\n}\n"],"mappings":";;;;;;;;;;;;;;AA8CA,SAAgB,sBAAsB,SAAuD;CAC3F,MAAM,UACJ,QAAQ,YAAY,KAAA,IAChB,KAAA,IACA,MAAM,QAAQ,QAAQ,OAAO,IAC3B,QAAQ,UACR,CAAC,QAAQ,OAAO;CAExB,MAAM,UAAUA,2BAAAA,kBAAkB,CAAC,GAAG,QAAQ,OAAO,GAAG,EAAE,QAAQ,QAAQ,OAAO,CAAC,CAAC,CAChF,SAAS;EACR,SAAS,EAAE,MAAM,QAAQ,WAAW;EACpC,MAAM;EACN,SAAS,QAAQ,WAAW;EAC5B;EACA,SAAS;GACP,EAAE,aAAa,GAAGC,gCAAAA,WAAW,WAAW,OAAO,EAAE;GACjD,EAAE,aAAa,GAAGA,gCAAAA,WAAW,iBAAiB,OAAO,EAAE;GACvD,EAAE,MAAMA,gCAAAA,WAAW,MAAM;EAC3B;CACF,CAAC,CAAC,CACD,WAAW;CAEd,MAAM,YAAY,QAAQ;CAC1B,OAAO,QAAQ,QAAQ,MAAM;EAC3B,IAAIC,cAAAA,oBAAoB,CAAC,GAAG,OAAO;EACnC,IAAI,CAAC,oBAAoB,EAAE,EAAE,GAAG,OAAO;EACvC,OAAO,cAAc,KAAA,KAAa,UAAU,EAAE,QAAQ,CAAC;CACzD,CAAC;AACH;;;;;AAMA,SAAgB,iBACd,UACA,cACqB;CACrB,IAAI,SAAS,WAAW,GAAG,OAAO,CAAC;CAEnC,MAAM,UAAmB,SAAS,KAAK,aAAa;EAClD,MAAM,QAAQ,QAAQ;EACtB,YAAYC,cAAAA,qBAAqB,OAAO,CAAC,CAAC,KAAK,YAAY,EAAE,MAAM,OAAO,QAAQ,EAAE,EAAE;EACtF,gBAAgB;GACd,QAAQ,CAAC,GAAGC,cAAAA,kBAAkB,OAAO,CAAC;GACtC,YAAYC,cAAAA,sBAAsB,OAAO;EAC3C;CACF,EAAE;CACF,MAAM,SAASC,+BAAAA,qBAAqB,SAAS,YAAY;CAEzD,OAAO,SAAS,KAAK,SAAS,OAA0B;EAAE,IAAI,QAAQ;EAAI,OAAO,OAAO;CAAG,EAAE;AAC/F;AAIA,SAAS,oBAAoB,IAAgC;CAC3D,IAAI,EAAA,GAACC,gCAAAA,qBAAAA,CAAqB,EAAE,GAAG,OAAO;CACtC,MAAM,OAAA,GAAMC,gCAAAA,wBAAAA,CAAwB,EAAE;CACtC,OAAO,CAAC,IAAI,QAAQ,IAAI,IAAI,QAAQ,CAAC,EAAA,CAAG,KAAK,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,MAAMC,gCAAAA,iBAAiB;AAC7F"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { deriveDistinctLabels } from "../../labels/derive_distinct_labels.js";
|
|
2
2
|
import { ColumnsCollection } from "../../columns/columns_collection.js";
|
|
3
|
-
import { collectLinkerColumns,
|
|
3
|
+
import { collectLinkerColumns, hasSingleDataColumn, hitQualifications, queriesQualifications } from "../../columns/utils.js";
|
|
4
4
|
import "../../columns/index.js";
|
|
5
|
-
import { Annotation,
|
|
5
|
+
import { Annotation, isColumnDiscoveredId, isGlobalPObjectId, parseColumnDiscoveredId } from "@milaboratories/pl-model-common";
|
|
6
6
|
// src/components/PlDatasetSelector/enrichment_discovery.ts
|
|
7
7
|
/**
|
|
8
8
|
* Linker-reached hits attached to the anchor primary. Drops zero-hop variants
|
|
9
9
|
* (filters / the primary itself) and structural hits (subset, linker, label
|
|
10
10
|
* columns). Narrow further with `include` selectors or a `predicate`.
|
|
11
|
+
*
|
|
12
|
+
* A hit is kept only when a workflow can find it by its id: the hit and every
|
|
13
|
+
* linker leading to it are block outputs.
|
|
11
14
|
*/
|
|
12
15
|
function findEnrichmentColumns(options) {
|
|
13
16
|
const include = options.include === void 0 ? void 0 : Array.isArray(options.include) ? options.include : [options.include];
|
|
@@ -25,44 +28,35 @@ function findEnrichmentColumns(options) {
|
|
|
25
28
|
const predicate = options.predicate;
|
|
26
29
|
return columns.filter((v) => {
|
|
27
30
|
if (hasSingleDataColumn(v)) return false;
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
if (collectLinkerIds(v).some((id) => !isGlobalPObjectId(id))) return false;
|
|
31
|
-
return true;
|
|
31
|
+
if (!reachesBlockOutputs(v.id)) return false;
|
|
32
|
+
return predicate === void 0 || predicate(v.getSpec());
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* `qualifications.forHit`; `forQueries` is re-derived by the table builder.
|
|
36
|
+
* Pairs each column with a label that tells apart the same hit reached through
|
|
37
|
+
* different linkers, so export headers stay unique.
|
|
38
38
|
*/
|
|
39
|
-
function
|
|
39
|
+
function labelEnrichments(variants, labelOptions) {
|
|
40
40
|
if (variants.length === 0) return [];
|
|
41
|
-
const
|
|
42
|
-
const hitQualsByVariant = variants.map((v) => [...hitQualifications(v)]);
|
|
43
|
-
const entries = variants.map((variant, i) => ({
|
|
41
|
+
const entries = variants.map((variant) => ({
|
|
44
42
|
spec: variant.getSpec(),
|
|
45
43
|
linkerPath: collectLinkerColumns(variant).map((linker) => ({ spec: linker.getSpec() })),
|
|
46
44
|
qualifications: {
|
|
47
|
-
forHit:
|
|
45
|
+
forHit: [...hitQualifications(variant)],
|
|
48
46
|
forQueries: queriesQualifications(variant)
|
|
49
47
|
}
|
|
50
48
|
}));
|
|
51
49
|
const labels = deriveDistinctLabels(entries, labelOptions);
|
|
52
|
-
return variants.map((variant, i) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}),
|
|
62
|
-
label: labels[i]
|
|
63
|
-
};
|
|
64
|
-
});
|
|
50
|
+
return variants.map((variant, i) => ({
|
|
51
|
+
id: variant.id,
|
|
52
|
+
label: labels[i]
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
function reachesBlockOutputs(id) {
|
|
56
|
+
if (!isColumnDiscoveredId(id)) return false;
|
|
57
|
+
const key = parseColumnDiscoveredId(id);
|
|
58
|
+
return [key.column, ...(key.path ?? []).map((step) => step.column)].every(isGlobalPObjectId);
|
|
65
59
|
}
|
|
66
|
-
export {
|
|
60
|
+
export { findEnrichmentColumns, labelEnrichments };
|
|
67
61
|
|
|
68
62
|
//# sourceMappingURL=enrichment_discovery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enrichment_discovery.js","names":[],"sources":["../../../src/components/PlDatasetSelector/enrichment_discovery.ts"],"sourcesContent":["import {\n Annotation,\n
|
|
1
|
+
{"version":3,"file":"enrichment_discovery.js","names":[],"sources":["../../../src/components/PlDatasetSelector/enrichment_discovery.ts"],"sourcesContent":["import {\n Annotation,\n isColumnDiscoveredId,\n isGlobalPObjectId,\n parseColumnDiscoveredId,\n} from \"@milaboratories/pl-model-common\";\nimport type {\n ColumnsCollectionDriverModel,\n ColumnUniversalId,\n MultiColumnSelector,\n PColumnSpec,\n PObjectSpec,\n} from \"@milaboratories/pl-model-common\";\nimport type { ColumnRecipe, ColumnsSource, ColumnsSourceShorthand } from \"../../columns\";\nimport {\n hasSingleDataColumn,\n ColumnsCollection,\n hitQualifications,\n collectLinkerColumns,\n queriesQualifications,\n} from \"../../columns\";\nimport {\n deriveDistinctLabels,\n type DeriveLabelsOptions,\n type Entry,\n} from \"../../labels/derive_distinct_labels\";\nimport type { DatasetEnrichment } from \"./dataset_selection\";\n\nexport interface FindEnrichmentColumnsOptions {\n sources: ReadonlyArray<ColumnsCollection | ColumnsSource | ColumnsSourceShorthand>;\n anchorSpec: PColumnSpec;\n maxHops?: number;\n include?: MultiColumnSelector | MultiColumnSelector[];\n predicate?: (spec: PObjectSpec) => boolean;\n /** Override the resolved `columnsCollection` service (primarily for tests). */\n driver?: ColumnsCollectionDriverModel;\n}\n\n/**\n * Linker-reached hits attached to the anchor primary. Drops zero-hop variants\n * (filters / the primary itself) and structural hits (subset, linker, label\n * columns). Narrow further with `include` selectors or a `predicate`.\n *\n * A hit is kept only when a workflow can find it by its id: the hit and every\n * linker leading to it are block outputs.\n */\nexport function findEnrichmentColumns(options: FindEnrichmentColumnsOptions): ColumnRecipe[] {\n const include =\n options.include === undefined\n ? undefined\n : Array.isArray(options.include)\n ? options.include\n : [options.include];\n\n const columns = ColumnsCollection([...options.sources], { driver: options.driver })\n .discover({\n anchors: { main: options.anchorSpec },\n mode: \"enrichment\",\n maxHops: options.maxHops ?? 4,\n include,\n exclude: [\n { annotations: { [Annotation.IsSubset]: \"true\" } },\n { annotations: { [Annotation.IsLinkerColumn]: \"true\" } },\n { name: Annotation.Label },\n ],\n })\n .getColumns();\n\n const predicate = options.predicate;\n return columns.filter((v) => {\n if (hasSingleDataColumn(v)) return false;\n if (!reachesBlockOutputs(v.id)) return false;\n return predicate === undefined || predicate(v.getSpec());\n });\n}\n\n/**\n * Pairs each column with a label that tells apart the same hit reached through\n * different linkers, so export headers stay unique.\n */\nexport function labelEnrichments(\n variants: ColumnRecipe[],\n labelOptions?: DeriveLabelsOptions,\n): DatasetEnrichment[] {\n if (variants.length === 0) return [];\n\n const entries: Entry[] = variants.map((variant) => ({\n spec: variant.getSpec(),\n linkerPath: collectLinkerColumns(variant).map((linker) => ({ spec: linker.getSpec() })),\n qualifications: {\n forHit: [...hitQualifications(variant)],\n forQueries: queriesQualifications(variant),\n },\n }));\n const labels = deriveDistinctLabels(entries, labelOptions);\n\n return variants.map((variant, i): DatasetEnrichment => ({ id: variant.id, label: labels[i] }));\n}\n\n// Internals\n\nfunction reachesBlockOutputs(id: ColumnUniversalId): boolean {\n if (!isColumnDiscoveredId(id)) return false;\n const key = parseColumnDiscoveredId(id);\n return [key.column, ...(key.path ?? []).map((step) => step.column)].every(isGlobalPObjectId);\n}\n"],"mappings":";;;;;;;;;;;;;;AA8CA,SAAgB,sBAAsB,SAAuD;CAC3F,MAAM,UACJ,QAAQ,YAAY,KAAA,IAChB,KAAA,IACA,MAAM,QAAQ,QAAQ,OAAO,IAC3B,QAAQ,UACR,CAAC,QAAQ,OAAO;CAExB,MAAM,UAAU,kBAAkB,CAAC,GAAG,QAAQ,OAAO,GAAG,EAAE,QAAQ,QAAQ,OAAO,CAAC,CAAC,CAChF,SAAS;EACR,SAAS,EAAE,MAAM,QAAQ,WAAW;EACpC,MAAM;EACN,SAAS,QAAQ,WAAW;EAC5B;EACA,SAAS;GACP,EAAE,aAAa,GAAG,WAAW,WAAW,OAAO,EAAE;GACjD,EAAE,aAAa,GAAG,WAAW,iBAAiB,OAAO,EAAE;GACvD,EAAE,MAAM,WAAW,MAAM;EAC3B;CACF,CAAC,CAAC,CACD,WAAW;CAEd,MAAM,YAAY,QAAQ;CAC1B,OAAO,QAAQ,QAAQ,MAAM;EAC3B,IAAI,oBAAoB,CAAC,GAAG,OAAO;EACnC,IAAI,CAAC,oBAAoB,EAAE,EAAE,GAAG,OAAO;EACvC,OAAO,cAAc,KAAA,KAAa,UAAU,EAAE,QAAQ,CAAC;CACzD,CAAC;AACH;;;;;AAMA,SAAgB,iBACd,UACA,cACqB;CACrB,IAAI,SAAS,WAAW,GAAG,OAAO,CAAC;CAEnC,MAAM,UAAmB,SAAS,KAAK,aAAa;EAClD,MAAM,QAAQ,QAAQ;EACtB,YAAY,qBAAqB,OAAO,CAAC,CAAC,KAAK,YAAY,EAAE,MAAM,OAAO,QAAQ,EAAE,EAAE;EACtF,gBAAgB;GACd,QAAQ,CAAC,GAAG,kBAAkB,OAAO,CAAC;GACtC,YAAY,sBAAsB,OAAO;EAC3C;CACF,EAAE;CACF,MAAM,SAAS,qBAAqB,SAAS,YAAY;CAEzD,OAAO,SAAS,KAAK,SAAS,OAA0B;EAAE,IAAI,QAAQ;EAAI,OAAO,OAAO;CAAG,EAAE;AAC/F;AAIA,SAAS,oBAAoB,IAAgC;CAC3D,IAAI,CAAC,qBAAqB,EAAE,GAAG,OAAO;CACtC,MAAM,MAAM,wBAAwB,EAAE;CACtC,OAAO,CAAC,IAAI,QAAQ,IAAI,IAAI,QAAQ,CAAC,EAAA,CAAG,KAAK,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,iBAAiB;AAC7F"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
1
|
const require_derive_distinct_labels = require("../../labels/derive_distinct_labels.cjs");
|
|
3
2
|
const require_columns_collection = require("../../columns/columns_collection.cjs");
|
|
4
3
|
const require_utils = require("../../columns/utils.cjs");
|
|
5
4
|
require("../../columns/index.cjs");
|
|
6
5
|
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
7
|
-
let canonicalize = require("canonicalize");
|
|
8
|
-
canonicalize = require_runtime.__toESM(canonicalize, 1);
|
|
9
6
|
// src/components/PlDatasetSelector/filter_discovery.ts
|
|
10
7
|
/**
|
|
11
8
|
* Matches columns annotated `pl7.app/isSubset: "true"` whose axes ⊆ anchor axes.
|
|
@@ -26,17 +23,17 @@ function findFilterColumns(options) {
|
|
|
26
23
|
/**
|
|
27
24
|
* Derive labeled options from filter column variants, for use in DatasetOption.filters.
|
|
28
25
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
26
|
+
* A filter is stored as a reference to a block output, so a column that is
|
|
27
|
+
* not one — a column of the current block — is silently skipped.
|
|
31
28
|
*/
|
|
32
29
|
function filterMatchesToOptions(variants, options) {
|
|
33
30
|
if (variants.length === 0) return [];
|
|
34
|
-
const {
|
|
31
|
+
const { datasetSpec, labelOptions } = options;
|
|
35
32
|
const entries = variants.flatMap((variant) => {
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
33
|
+
const producer = (0, _milaboratories_pl_model_common.columnProducer)(variant.id);
|
|
34
|
+
if (producer === void 0) return [];
|
|
38
35
|
return [{
|
|
39
|
-
ref,
|
|
36
|
+
ref: (0, _milaboratories_pl_model_common.createPlRef)(producer.blockId, producer.name),
|
|
40
37
|
spec: variant.getSpec(),
|
|
41
38
|
linkerPath: require_utils.collectLinkerColumns(variant).map((linker) => ({ spec: linker.getSpec() }))
|
|
42
39
|
}];
|
|
@@ -53,11 +50,6 @@ function filterMatchesToOptions(variants, options) {
|
|
|
53
50
|
label: labels[i]
|
|
54
51
|
}));
|
|
55
52
|
}
|
|
56
|
-
/** Build the `refsByObjectId` map from `ctx.resultPool.getSpecs().entries`. */
|
|
57
|
-
function buildRefMap(entries) {
|
|
58
|
-
return new Map(entries.map((e) => [(0, canonicalize.default)(e.ref), e.ref]));
|
|
59
|
-
}
|
|
60
|
-
exports.buildRefMap = buildRefMap;
|
|
61
53
|
exports.filterMatchesToOptions = filterMatchesToOptions;
|
|
62
54
|
exports.findFilterColumns = findFilterColumns;
|
|
63
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter_discovery.cjs","names":["ColumnsCollection","Annotation","
|
|
1
|
+
{"version":3,"file":"filter_discovery.cjs","names":["ColumnsCollection","Annotation","columnProducer","createPlRef","collectLinkerColumns","deriveDistinctLabels"],"sources":["../../../src/components/PlDatasetSelector/filter_discovery.ts"],"sourcesContent":["import { Annotation, columnProducer, createPlRef } from \"@milaboratories/pl-model-common\";\nimport type {\n ColumnsCollectionDriverModel,\n Option,\n PColumnSpec,\n PlRef,\n PObjectSpec,\n} from \"@milaboratories/pl-model-common\";\nimport type { ColumnRecipe, ColumnsSource, ColumnsSourceShorthand } from \"../../columns\";\nimport { ColumnsCollection, collectLinkerColumns } from \"../../columns\";\nimport {\n deriveDistinctLabels,\n type DeriveLabelsOptions,\n type Entry,\n} from \"../../labels/derive_distinct_labels\";\n\nexport interface FindFilterColumnsOptions {\n sources: ReadonlyArray<ColumnsCollection | ColumnsSource | ColumnsSourceShorthand>;\n anchorSpec: PColumnSpec;\n /** Override the resolved `columnsCollection` service (primarily for tests). */\n driver?: ColumnsCollectionDriverModel;\n}\n\n/**\n * Matches columns annotated `pl7.app/isSubset: \"true\"` whose axes ⊆ anchor axes.\n *\n * Filter-intent: only the dataset's own direct subset columns, no linker\n * traversal — so this uses `.filter()` (pins `maxHops: 0`), not `.discover()`\n * (which would default to 4 hops and surface subset columns from other,\n * linker-reachable datasets). `.filter()` still applies the default\n * `enrichment` matching mode (`allowFloatingHitAxes: false`), which enforces\n * the axes-subset constraint. See `matchingModeToConstraints()`.\n */\nexport function findFilterColumns(options: FindFilterColumnsOptions): ColumnRecipe[] {\n return ColumnsCollection([...options.sources], { driver: options.driver })\n .filter({\n anchors: { main: options.anchorSpec },\n include: { annotations: { [Annotation.IsSubset]: \"true\" } },\n })\n .getColumns();\n}\n\nexport type FilterMatchOptions = {\n /** Spec of the dataset the filters are subsets of. */\n datasetSpec: PObjectSpec;\n /**\n * Forwarded to `deriveDistinctLabels`. Any `formatters.native` caller\n * sets is silently overridden — the function relies on a no-op native\n * formatter to keep the algorithm from short-circuiting on filters'\n * inherited `pl7.app/label`.\n */\n labelOptions?: DeriveLabelsOptions;\n};\n\n/**\n * Derive labeled options from filter column variants, for use in DatasetOption.filters.\n *\n * A filter is stored as a reference to a block output, so a column that is\n * not one — a column of the current block — is silently skipped.\n */\nexport function filterMatchesToOptions(\n variants: ColumnRecipe[],\n options: FilterMatchOptions,\n): Option[] {\n if (variants.length === 0) return [];\n\n const { datasetSpec, labelOptions } = options;\n\n // One Option per variant — `deriveDistinctLabels` disambiguates labels by\n // path.\n const entries: (Entry & { ref: PlRef })[] = variants.flatMap((variant) => {\n const producer = columnProducer(variant.id);\n if (producer === undefined) return [];\n return [\n {\n ref: createPlRef(producer.blockId, producer.name),\n spec: variant.getSpec(),\n linkerPath: collectLinkerColumns(variant).map((linker) => ({ spec: linker.getSpec() })),\n },\n ];\n });\n\n // Appending the dataset forces a discriminating trace step into every\n // filter label (yielding e.g. \"Bulk / Top 10\"); the dataset's own label\n // is dropped because we only zip `entries`. Native label is force-\n // suppressed (the override sits after caller's spread) — filters\n // inherit the dataset's `pl7.app/label` and would otherwise satisfy\n // uniqueness before any trace step is consulted.\n const labels = deriveDistinctLabels([...entries, { spec: datasetSpec }], {\n ...labelOptions,\n formatters: { ...labelOptions?.formatters, native: () => undefined },\n });\n\n return entries.map(({ ref }, i) => ({ ref, label: labels[i] }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiCA,SAAgB,kBAAkB,SAAmD;CACnF,OAAOA,2BAAAA,kBAAkB,CAAC,GAAG,QAAQ,OAAO,GAAG,EAAE,QAAQ,QAAQ,OAAO,CAAC,CAAC,CACvE,OAAO;EACN,SAAS,EAAE,MAAM,QAAQ,WAAW;EACpC,SAAS,EAAE,aAAa,GAAGC,gCAAAA,WAAW,WAAW,OAAO,EAAE;CAC5D,CAAC,CAAC,CACD,WAAW;AAChB;;;;;;;AAoBA,SAAgB,uBACd,UACA,SACU;CACV,IAAI,SAAS,WAAW,GAAG,OAAO,CAAC;CAEnC,MAAM,EAAE,aAAa,iBAAiB;CAItC,MAAM,UAAsC,SAAS,SAAS,YAAY;EACxE,MAAM,YAAA,GAAWC,gCAAAA,eAAAA,CAAe,QAAQ,EAAE;EAC1C,IAAI,aAAa,KAAA,GAAW,OAAO,CAAC;EACpC,OAAO,CACL;GACE,MAAA,GAAKC,gCAAAA,YAAAA,CAAY,SAAS,SAAS,SAAS,IAAI;GAChD,MAAM,QAAQ,QAAQ;GACtB,YAAYC,cAAAA,qBAAqB,OAAO,CAAC,CAAC,KAAK,YAAY,EAAE,MAAM,OAAO,QAAQ,EAAE,EAAE;EACxF,CACF;CACF,CAAC;CAQD,MAAM,SAASC,+BAAAA,qBAAqB,CAAC,GAAG,SAAS,EAAE,MAAM,YAAY,CAAC,GAAG;EACvE,GAAG;EACH,YAAY;GAAE,GAAG,cAAc;GAAY,cAAc,KAAA;EAAU;CACrE,CAAC;CAED,OAAO,QAAQ,KAAK,EAAE,OAAO,OAAO;EAAE;EAAK,OAAO,OAAO;CAAG,EAAE;AAChE"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { DeriveLabelsOptions } from "../../labels/derive_distinct_labels.js";
|
|
2
2
|
import { ColumnRecipe } from "../../columns/column_recipes/index.js";
|
|
3
3
|
import { ColumnsSource } from "../../columns/column_providers/types.js";
|
|
4
|
+
import { ColumnsCollection, ColumnsSourceShorthand } from "../../columns/columns_collection.js";
|
|
4
5
|
import "../../columns/index.js";
|
|
5
|
-
import { ColumnsCollectionDriverModel, Option, PColumnSpec,
|
|
6
|
+
import { ColumnsCollectionDriverModel, Option, PColumnSpec, PObjectSpec } from "@milaboratories/pl-model-common";
|
|
6
7
|
export interface FindFilterColumnsOptions {
|
|
7
|
-
sources: ReadonlyArray<ColumnsSource>;
|
|
8
|
+
sources: ReadonlyArray<ColumnsCollection | ColumnsSource | ColumnsSourceShorthand>;
|
|
8
9
|
anchorSpec: PColumnSpec;
|
|
9
10
|
/** Override the resolved `columnsCollection` service (primarily for tests). */
|
|
10
11
|
driver?: ColumnsCollectionDriverModel;
|
|
@@ -21,8 +22,6 @@ export interface FindFilterColumnsOptions {
|
|
|
21
22
|
*/
|
|
22
23
|
export declare function findFilterColumns(options: FindFilterColumnsOptions): ColumnRecipe[];
|
|
23
24
|
export type FilterMatchOptions = {
|
|
24
|
-
/** Maps result-pool column id back to its source PlRef (see {@link buildRefMap}). */
|
|
25
|
-
refsByObjectId: ReadonlyMap<PObjectId, PlRef>;
|
|
26
25
|
/** Spec of the dataset the filters are subsets of. */
|
|
27
26
|
datasetSpec: PObjectSpec;
|
|
28
27
|
/**
|
|
@@ -36,12 +35,8 @@ export type FilterMatchOptions = {
|
|
|
36
35
|
/**
|
|
37
36
|
* Derive labeled options from filter column variants, for use in DatasetOption.filters.
|
|
38
37
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* A filter is stored as a reference to a block output, so a column that is
|
|
39
|
+
* not one — a column of the current block — is silently skipped.
|
|
41
40
|
*/
|
|
42
41
|
export declare function filterMatchesToOptions(variants: ColumnRecipe[], options: FilterMatchOptions): Option[];
|
|
43
|
-
/** Build the `refsByObjectId` map from `ctx.resultPool.getSpecs().entries`. */
|
|
44
|
-
export declare function buildRefMap(entries: readonly {
|
|
45
|
-
readonly ref: PlRef;
|
|
46
|
-
}[]): Map<PObjectId, PlRef>;
|
|
47
42
|
//# sourceMappingURL=filter_discovery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter_discovery.d.ts","names":[],"sources":["../../../src/components/PlDatasetSelector/filter_discovery.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"filter_discovery.d.ts","names":[],"sources":["../../../src/components/PlDatasetSelector/filter_discovery.ts"],"mappings":";;;;;;iBAgBiB;EACf,SAAS,cAAc,oBAAoB,gBAAgB;EAC3D,YAAY;;EAEZ,SAAS;;;;;;;;;;;;wBAaK,kBAAkB,SAAS,2BAA2B;YAS1D;;EAEV,aAAa;;;;;;;EAOb,eAAe;;;;;;;;wBASD,uBACd,UAAU,gBACV,SAAS,qBACR"}
|