@platforma-sdk/model 1.85.2 → 1.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/columns/index.cjs +8 -0
- package/dist/columns/index.d.ts +3 -2
- package/dist/columns/index.js +3 -2
- package/dist/columns/peer_links.cjs +43 -0
- package/dist/columns/peer_links.cjs.map +1 -0
- package/dist/columns/peer_links.d.ts +18 -0
- package/dist/columns/peer_links.d.ts.map +1 -0
- package/dist/columns/peer_links.js +39 -0
- package/dist/columns/peer_links.js.map +1 -0
- package/dist/columns/utils.cjs +29 -5
- package/dist/columns/utils.cjs.map +1 -1
- package/dist/columns/utils.d.ts +11 -0
- package/dist/columns/utils.d.ts.map +1 -1
- package/dist/columns/utils.js +28 -6
- package/dist/columns/utils.js.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs +20 -3
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js +20 -3
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/utils.cjs +2 -1
- package/dist/components/PlDataTable/createPlDataTable/utils.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/utils.js +2 -1
- package/dist/components/PlDataTable/createPlDataTable/utils.js.map +1 -1
- package/dist/components/PlDataTable/typesV8.d.ts +2 -0
- package/dist/components/PlDataTable/typesV8.d.ts.map +1 -1
- package/dist/index.cjs +8 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/labels/derive_distinct_labels.cjs +6 -3
- package/dist/labels/derive_distinct_labels.cjs.map +1 -1
- package/dist/labels/derive_distinct_labels.d.ts +3 -0
- package/dist/labels/derive_distinct_labels.d.ts.map +1 -1
- package/dist/labels/derive_distinct_labels.js +6 -3
- package/dist/labels/derive_distinct_labels.js.map +1 -1
- package/dist/labels/linked_column_postfix.cjs +4 -1
- package/dist/labels/linked_column_postfix.cjs.map +1 -1
- package/dist/labels/linked_column_postfix.d.ts.map +1 -1
- package/dist/labels/linked_column_postfix.js +4 -1
- package/dist/labels/linked_column_postfix.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/package.json +15 -10
- package/src/columns/index.ts +1 -0
- package/src/columns/peer_links.test.ts +58 -0
- package/src/columns/peer_links.ts +57 -0
- package/src/columns/utils.ts +42 -2
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV3.ts +28 -3
- package/src/components/PlDataTable/createPlDataTable/utils.ts +3 -0
- package/src/components/PlDataTable/typesV8.ts +2 -0
- package/src/labels/derive_distinct_labels.ts +8 -1
- package/src/labels/linked_column_postfix.test.ts +8 -0
- package/src/labels/linked_column_postfix.ts +13 -7
package/dist/columns/index.cjs
CHANGED
|
@@ -7,6 +7,7 @@ const require_data_column = require("./data_column.cjs");
|
|
|
7
7
|
const require_providers = require("./column_providers/providers.cjs");
|
|
8
8
|
const require_index$1 = require("./column_providers/index.cjs");
|
|
9
9
|
const require_columns_collection = require("./columns_collection.cjs");
|
|
10
|
+
const require_peer_links = require("./peer_links.cjs");
|
|
10
11
|
const require_utils = require("./utils.cjs");
|
|
11
12
|
const require_derive_axis_values_labels = require("./derive_axis_values_labels.cjs");
|
|
12
13
|
const require_split_by_axes = require("./split_by_axes.cjs");
|
|
@@ -27,11 +28,17 @@ exports.DataColumnImpl = require_data_column.DataColumnImpl;
|
|
|
27
28
|
exports.ResultPoolColumnsProvider = require_providers.ResultPoolColumnsProvider;
|
|
28
29
|
exports.ResultPoolColumnsProviderImpl = require_providers.ResultPoolColumnsProviderImpl;
|
|
29
30
|
exports._ctxProvidersCache = require_index$1._ctxProvidersCache;
|
|
31
|
+
exports.collectDatasetAxes = require_peer_links.collectDatasetAxes;
|
|
30
32
|
exports.collectLinkerColumns = require_utils.collectLinkerColumns;
|
|
31
33
|
exports.collectLinkerIds = require_utils.collectLinkerIds;
|
|
34
|
+
exports.createPeerLinkFinder = require_utils.createPeerLinkFinder;
|
|
32
35
|
exports.deriveAxisValuesLabels = require_derive_axis_values_labels.deriveAxisValuesLabels;
|
|
33
36
|
exports.deriveColumnOptions = require_utils.deriveColumnOptions;
|
|
37
|
+
exports.deriveRecipeOptions = require_utils.deriveRecipeOptions;
|
|
38
|
+
exports.describePeerLinks = require_peer_links.describePeerLinks;
|
|
39
|
+
exports.findPeerLinks = require_peer_links.findPeerLinks;
|
|
34
40
|
exports.getCtxProviders = require_index$1.getCtxProviders;
|
|
41
|
+
exports.getResultPoolDatasetAxes = require_peer_links.getResultPoolDatasetAxes;
|
|
35
42
|
exports.hasColumnData = require_utils.hasColumnData;
|
|
36
43
|
exports.hasReachableData = require_utils.hasReachableData;
|
|
37
44
|
exports.hasSingleDataColumn = require_utils.hasSingleDataColumn;
|
|
@@ -41,6 +48,7 @@ exports.isColumnProvider = require_index$1.isColumnProvider;
|
|
|
41
48
|
exports.isColumnsCollection = require_columns_collection.isColumnsCollection;
|
|
42
49
|
exports.isDataColumn = require_data_column.isDataColumn;
|
|
43
50
|
exports.isLeafColumn = require_utils.isLeafColumn;
|
|
51
|
+
exports.peerLinkedLast = require_peer_links.peerLinkedLast;
|
|
44
52
|
exports.queriesQualifications = require_utils.queriesQualifications;
|
|
45
53
|
exports.splitByAxes = require_split_by_axes.splitByAxes;
|
|
46
54
|
exports.toColumnProvider = require_index$1.toColumnProvider;
|
package/dist/columns/index.d.ts
CHANGED
|
@@ -11,5 +11,6 @@ import { _ctxProvidersCache, getCtxProviders, isColumnProvider, toColumnProvider
|
|
|
11
11
|
import { SplitAxis, SplitByAxesOpts, splitByAxes } from "./split_by_axes.js";
|
|
12
12
|
import { ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsSourceShorthand, isColumnsCollection } from "./columns_collection.js";
|
|
13
13
|
import { deriveAxisValuesLabels } from "./derive_axis_values_labels.js";
|
|
14
|
-
import { ColumnOption, collectLinkerColumns, collectLinkerIds, deriveColumnOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications } from "./utils.js";
|
|
15
|
-
|
|
14
|
+
import { ColumnOption, collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveColumnOptions, deriveRecipeOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications } from "./utils.js";
|
|
15
|
+
import { DatasetAxes, collectDatasetAxes, describePeerLinks, findPeerLinks, getResultPoolDatasetAxes, peerLinkedLast } from "./peer_links.js";
|
|
16
|
+
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column, ColumnAbsentError, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, ColumnOverriddenRecipe, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsProvider, ColumnsSource, ColumnsSourceShorthand, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DatasetAxes, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, type SpecQuery, SplitAxis, SplitByAxesOpts, _ctxProvidersCache, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveAxisValuesLabels, deriveColumnOptions, deriveRecipeOptions, describePeerLinks, findPeerLinks, getCtxProviders, getResultPoolDatasetAxes, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isColumn, isColumnProvider, isColumnsCollection, isDataColumn, isLeafColumn, peerLinkedLast, queriesQualifications, splitByAxes, toColumnProvider };
|
package/dist/columns/index.js
CHANGED
|
@@ -7,7 +7,8 @@ import { ColumnAbsentError, DataColumn, DataColumnImpl, isDataColumn } from "./d
|
|
|
7
7
|
import { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, ColumnsProvider, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl } from "./column_providers/providers.js";
|
|
8
8
|
import { _ctxProvidersCache, getCtxProviders, isColumnProvider, toColumnProvider } from "./column_providers/index.js";
|
|
9
9
|
import { ColumnsCollection, ColumnsCollectionImpl, isColumnsCollection } from "./columns_collection.js";
|
|
10
|
-
import {
|
|
10
|
+
import { collectDatasetAxes, describePeerLinks, findPeerLinks, getResultPoolDatasetAxes, peerLinkedLast } from "./peer_links.js";
|
|
11
|
+
import { collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveColumnOptions, deriveRecipeOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications } from "./utils.js";
|
|
11
12
|
import { deriveAxisValuesLabels } from "./derive_axis_values_labels.js";
|
|
12
13
|
import { splitByAxes } from "./split_by_axes.js";
|
|
13
|
-
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column, ColumnAbsentError, ColumnDiscoveredRecipe, ColumnFilteredRecipe, ColumnOverriddenRecipe, ColumnRecipe, ColumnsCollection, ColumnsCollectionImpl, ColumnsProvider, DataColumn, DataColumnImpl, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, _ctxProvidersCache, collectLinkerColumns, collectLinkerIds, deriveAxisValuesLabels, deriveColumnOptions, getCtxProviders, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isColumn, isColumnProvider, isColumnsCollection, isDataColumn, isLeafColumn, queriesQualifications, splitByAxes, toColumnProvider };
|
|
14
|
+
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, Column, ColumnAbsentError, ColumnDiscoveredRecipe, ColumnFilteredRecipe, ColumnOverriddenRecipe, ColumnRecipe, ColumnsCollection, ColumnsCollectionImpl, ColumnsProvider, DataColumn, DataColumnImpl, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, _ctxProvidersCache, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveAxisValuesLabels, deriveColumnOptions, deriveRecipeOptions, describePeerLinks, findPeerLinks, getCtxProviders, getResultPoolDatasetAxes, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isColumn, isColumnProvider, isColumnsCollection, isDataColumn, isLeafColumn, peerLinkedLast, queriesQualifications, splitByAxes, toColumnProvider };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const require_providers = require("./column_providers/providers.cjs");
|
|
2
|
+
require("./column_providers/index.cjs");
|
|
3
|
+
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
4
|
+
let es_toolkit = require("es-toolkit");
|
|
5
|
+
//#region src/columns/peer_links.ts
|
|
6
|
+
/** Main axes of the datasets: the second axis of every column marked `pl7.app/isAnchor`. */
|
|
7
|
+
function collectDatasetAxes(specs) {
|
|
8
|
+
return new Set(specs.flatMap((spec) => {
|
|
9
|
+
const main = spec.axesSpec[1];
|
|
10
|
+
return (0, _milaboratories_pl_model_common.readAnnotation)(spec, _milaboratories_pl_model_common.Annotation.IsAnchor) === "true" && main !== void 0 ? [(0, _milaboratories_pl_model_common.canonicalizeAxisId)(main)] : [];
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
/** {@link collectDatasetAxes} over the result pool. */
|
|
14
|
+
function getResultPoolDatasetAxes() {
|
|
15
|
+
return collectDatasetAxes(require_providers.ResultPoolColumnsProvider().getColumns().map((c) => c.getSpec()));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Labels of the peer links on a linker path. A peer link joins two datasets' main axes, e.g. one
|
|
19
|
+
* clonotype to another, so the columns behind it describe a different clonotype than the row.
|
|
20
|
+
*/
|
|
21
|
+
function findPeerLinks(linkers, datasetAxes) {
|
|
22
|
+
return (0, es_toolkit.uniq)(linkers.flatMap((l) => {
|
|
23
|
+
const peer = l.axesSpec.every((a) => datasetAxes.has((0, _milaboratories_pl_model_common.canonicalizeAxisId)(a)));
|
|
24
|
+
const label = (0, _milaboratories_pl_model_common.readAnnotation)(l, _milaboratories_pl_model_common.Annotation.LinkLabel) ?? (0, _milaboratories_pl_model_common.readAnnotation)(l, _milaboratories_pl_model_common.Annotation.Label);
|
|
25
|
+
return peer && label ? [label] : [];
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
/** Hover text for the link icon. */
|
|
29
|
+
function describePeerLinks(links) {
|
|
30
|
+
return `Reached via ${links.join(", then ")}`;
|
|
31
|
+
}
|
|
32
|
+
/** Moves peer-linked items after the others, keeping the order within each group. */
|
|
33
|
+
function peerLinkedLast(items, isPeerLinked) {
|
|
34
|
+
return [...items.filter((i) => !isPeerLinked(i)), ...items.filter(isPeerLinked)];
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.collectDatasetAxes = collectDatasetAxes;
|
|
38
|
+
exports.describePeerLinks = describePeerLinks;
|
|
39
|
+
exports.findPeerLinks = findPeerLinks;
|
|
40
|
+
exports.getResultPoolDatasetAxes = getResultPoolDatasetAxes;
|
|
41
|
+
exports.peerLinkedLast = peerLinkedLast;
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=peer_links.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peer_links.cjs","names":["Annotation","ResultPoolColumnsProvider"],"sources":["../../src/columns/peer_links.ts"],"sourcesContent":["import {\n Annotation,\n canonicalizeAxisId,\n readAnnotation,\n type AxisId,\n type CanonicalizedJson,\n type PColumnSpec,\n} from \"@milaboratories/pl-model-common\";\nimport { uniq } from \"es-toolkit\";\nimport { ResultPoolColumnsProvider } from \"./column_providers\";\n\nexport type DatasetAxes = Set<CanonicalizedJson<AxisId>>;\n\n/** Main axes of the datasets: the second axis of every column marked `pl7.app/isAnchor`. */\nexport function collectDatasetAxes(specs: PColumnSpec[]): DatasetAxes {\n return new Set(\n specs.flatMap((spec) => {\n const main = spec.axesSpec[1];\n return readAnnotation(spec, Annotation.IsAnchor) === \"true\" && main !== undefined\n ? [canonicalizeAxisId(main)]\n : [];\n }),\n );\n}\n\n/** {@link collectDatasetAxes} over the result pool. */\nexport function getResultPoolDatasetAxes(): DatasetAxes {\n return collectDatasetAxes(\n ResultPoolColumnsProvider()\n .getColumns()\n .map((c) => c.getSpec()),\n );\n}\n\n/**\n * Labels of the peer links on a linker path. A peer link joins two datasets' main axes, e.g. one\n * clonotype to another, so the columns behind it describe a different clonotype than the row.\n */\nexport function findPeerLinks(linkers: PColumnSpec[], datasetAxes: DatasetAxes): string[] {\n return uniq(\n linkers.flatMap((l) => {\n const peer = l.axesSpec.every((a) => datasetAxes.has(canonicalizeAxisId(a)));\n const label = readAnnotation(l, Annotation.LinkLabel) ?? readAnnotation(l, Annotation.Label);\n return peer && label ? [label] : [];\n }),\n );\n}\n\n/** Hover text for the link icon. */\nexport function describePeerLinks(links: string[]): string {\n return `Reached via ${links.join(\", then \")}`;\n}\n\n/** Moves peer-linked items after the others, keeping the order within each group. */\nexport function peerLinkedLast<T>(items: T[], isPeerLinked: (item: T) => boolean): T[] {\n return [...items.filter((i) => !isPeerLinked(i)), ...items.filter(isPeerLinked)];\n}\n"],"mappings":";;;;;;AAcA,SAAgB,mBAAmB,OAAmC;CACpE,OAAO,IAAI,IACT,MAAM,SAAS,SAAS;EACtB,MAAM,OAAO,KAAK,SAAS;EAC3B,QAAA,GAAA,gCAAA,eAAA,CAAsB,MAAMA,gCAAAA,WAAW,QAAQ,MAAM,UAAU,SAAS,KAAA,IACpE,EAAA,GAAA,gCAAA,mBAAA,CAAoB,IAAI,CAAC,IACzB,CAAC;CACP,CAAC,CACH;AACF;;AAGA,SAAgB,2BAAwC;CACtD,OAAO,mBACLC,kBAAAA,0BAA0B,CAAC,CACxB,WAAW,CAAC,CACZ,KAAK,MAAM,EAAE,QAAQ,CAAC,CAC3B;AACF;;;;;AAMA,SAAgB,cAAc,SAAwB,aAAoC;CACxF,QAAA,GAAA,WAAA,KAAA,CACE,QAAQ,SAAS,MAAM;EACrB,MAAM,OAAO,EAAE,SAAS,OAAO,MAAM,YAAY,KAAA,GAAA,gCAAA,mBAAA,CAAuB,CAAC,CAAC,CAAC;EAC3E,MAAM,SAAA,GAAA,gCAAA,eAAA,CAAuB,GAAGD,gCAAAA,WAAW,SAAS,MAAA,GAAA,gCAAA,eAAA,CAAoB,GAAGA,gCAAAA,WAAW,KAAK;EAC3F,OAAO,QAAQ,QAAQ,CAAC,KAAK,IAAI,CAAC;CACpC,CAAC,CACH;AACF;;AAGA,SAAgB,kBAAkB,OAAyB;CACzD,OAAO,eAAe,MAAM,KAAK,SAAS;AAC5C;;AAGA,SAAgB,eAAkB,OAAY,cAAyC;CACrF,OAAO,CAAC,GAAG,MAAM,QAAQ,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,GAAG,MAAM,OAAO,YAAY,CAAC;AACjF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AxisId, CanonicalizedJson, PColumnSpec } from "@milaboratories/pl-model-common";
|
|
2
|
+
//#region src/columns/peer_links.d.ts
|
|
3
|
+
export type DatasetAxes = Set<CanonicalizedJson<AxisId>>;
|
|
4
|
+
/** Main axes of the datasets: the second axis of every column marked `pl7.app/isAnchor`. */
|
|
5
|
+
export declare function collectDatasetAxes(specs: PColumnSpec[]): DatasetAxes;
|
|
6
|
+
/** {@link collectDatasetAxes} over the result pool. */
|
|
7
|
+
export declare function getResultPoolDatasetAxes(): DatasetAxes;
|
|
8
|
+
/**
|
|
9
|
+
* Labels of the peer links on a linker path. A peer link joins two datasets' main axes, e.g. one
|
|
10
|
+
* clonotype to another, so the columns behind it describe a different clonotype than the row.
|
|
11
|
+
*/
|
|
12
|
+
export declare function findPeerLinks(linkers: PColumnSpec[], datasetAxes: DatasetAxes): string[];
|
|
13
|
+
/** Hover text for the link icon. */
|
|
14
|
+
export declare function describePeerLinks(links: string[]): string;
|
|
15
|
+
/** Moves peer-linked items after the others, keeping the order within each group. */
|
|
16
|
+
export declare function peerLinkedLast<T>(items: T[], isPeerLinked: (item: T) => boolean): T[];
|
|
17
|
+
//#endregion
|
|
18
|
+
//# sourceMappingURL=peer_links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peer_links.d.ts","names":[],"sources":["../../src/columns/peer_links.ts"],"mappings":";;YAWY,cAAc,IAAI,kBAAkB;;wBAGhC,mBAAmB,OAAO,gBAAgB;;wBAY1C,4BAA4B;;;;;wBAY5B,cAAc,SAAS,eAAe,aAAa;;wBAWnD,kBAAkB;;wBAKlB,eAAe,GAAG,OAAO,KAAK,eAAe,MAAM,gBAAgB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ResultPoolColumnsProvider } from "./column_providers/providers.js";
|
|
2
|
+
import "./column_providers/index.js";
|
|
3
|
+
import { Annotation, canonicalizeAxisId, readAnnotation } from "@milaboratories/pl-model-common";
|
|
4
|
+
import { uniq } from "es-toolkit";
|
|
5
|
+
//#region src/columns/peer_links.ts
|
|
6
|
+
/** Main axes of the datasets: the second axis of every column marked `pl7.app/isAnchor`. */
|
|
7
|
+
function collectDatasetAxes(specs) {
|
|
8
|
+
return new Set(specs.flatMap((spec) => {
|
|
9
|
+
const main = spec.axesSpec[1];
|
|
10
|
+
return readAnnotation(spec, Annotation.IsAnchor) === "true" && main !== void 0 ? [canonicalizeAxisId(main)] : [];
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
/** {@link collectDatasetAxes} over the result pool. */
|
|
14
|
+
function getResultPoolDatasetAxes() {
|
|
15
|
+
return collectDatasetAxes(ResultPoolColumnsProvider().getColumns().map((c) => c.getSpec()));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Labels of the peer links on a linker path. A peer link joins two datasets' main axes, e.g. one
|
|
19
|
+
* clonotype to another, so the columns behind it describe a different clonotype than the row.
|
|
20
|
+
*/
|
|
21
|
+
function findPeerLinks(linkers, datasetAxes) {
|
|
22
|
+
return uniq(linkers.flatMap((l) => {
|
|
23
|
+
const peer = l.axesSpec.every((a) => datasetAxes.has(canonicalizeAxisId(a)));
|
|
24
|
+
const label = readAnnotation(l, Annotation.LinkLabel) ?? readAnnotation(l, Annotation.Label);
|
|
25
|
+
return peer && label ? [label] : [];
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
/** Hover text for the link icon. */
|
|
29
|
+
function describePeerLinks(links) {
|
|
30
|
+
return `Reached via ${links.join(", then ")}`;
|
|
31
|
+
}
|
|
32
|
+
/** Moves peer-linked items after the others, keeping the order within each group. */
|
|
33
|
+
function peerLinkedLast(items, isPeerLinked) {
|
|
34
|
+
return [...items.filter((i) => !isPeerLinked(i)), ...items.filter(isPeerLinked)];
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { collectDatasetAxes, describePeerLinks, findPeerLinks, getResultPoolDatasetAxes, peerLinkedLast };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=peer_links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peer_links.js","names":[],"sources":["../../src/columns/peer_links.ts"],"sourcesContent":["import {\n Annotation,\n canonicalizeAxisId,\n readAnnotation,\n type AxisId,\n type CanonicalizedJson,\n type PColumnSpec,\n} from \"@milaboratories/pl-model-common\";\nimport { uniq } from \"es-toolkit\";\nimport { ResultPoolColumnsProvider } from \"./column_providers\";\n\nexport type DatasetAxes = Set<CanonicalizedJson<AxisId>>;\n\n/** Main axes of the datasets: the second axis of every column marked `pl7.app/isAnchor`. */\nexport function collectDatasetAxes(specs: PColumnSpec[]): DatasetAxes {\n return new Set(\n specs.flatMap((spec) => {\n const main = spec.axesSpec[1];\n return readAnnotation(spec, Annotation.IsAnchor) === \"true\" && main !== undefined\n ? [canonicalizeAxisId(main)]\n : [];\n }),\n );\n}\n\n/** {@link collectDatasetAxes} over the result pool. */\nexport function getResultPoolDatasetAxes(): DatasetAxes {\n return collectDatasetAxes(\n ResultPoolColumnsProvider()\n .getColumns()\n .map((c) => c.getSpec()),\n );\n}\n\n/**\n * Labels of the peer links on a linker path. A peer link joins two datasets' main axes, e.g. one\n * clonotype to another, so the columns behind it describe a different clonotype than the row.\n */\nexport function findPeerLinks(linkers: PColumnSpec[], datasetAxes: DatasetAxes): string[] {\n return uniq(\n linkers.flatMap((l) => {\n const peer = l.axesSpec.every((a) => datasetAxes.has(canonicalizeAxisId(a)));\n const label = readAnnotation(l, Annotation.LinkLabel) ?? readAnnotation(l, Annotation.Label);\n return peer && label ? [label] : [];\n }),\n );\n}\n\n/** Hover text for the link icon. */\nexport function describePeerLinks(links: string[]): string {\n return `Reached via ${links.join(\", then \")}`;\n}\n\n/** Moves peer-linked items after the others, keeping the order within each group. */\nexport function peerLinkedLast<T>(items: T[], isPeerLinked: (item: T) => boolean): T[] {\n return [...items.filter((i) => !isPeerLinked(i)), ...items.filter(isPeerLinked)];\n}\n"],"mappings":";;;;;;AAcA,SAAgB,mBAAmB,OAAmC;CACpE,OAAO,IAAI,IACT,MAAM,SAAS,SAAS;EACtB,MAAM,OAAO,KAAK,SAAS;EAC3B,OAAO,eAAe,MAAM,WAAW,QAAQ,MAAM,UAAU,SAAS,KAAA,IACpE,CAAC,mBAAmB,IAAI,CAAC,IACzB,CAAC;CACP,CAAC,CACH;AACF;;AAGA,SAAgB,2BAAwC;CACtD,OAAO,mBACL,0BAA0B,CAAC,CACxB,WAAW,CAAC,CACZ,KAAK,MAAM,EAAE,QAAQ,CAAC,CAC3B;AACF;;;;;AAMA,SAAgB,cAAc,SAAwB,aAAoC;CACxF,OAAO,KACL,QAAQ,SAAS,MAAM;EACrB,MAAM,OAAO,EAAE,SAAS,OAAO,MAAM,YAAY,IAAI,mBAAmB,CAAC,CAAC,CAAC;EAC3E,MAAM,QAAQ,eAAe,GAAG,WAAW,SAAS,KAAK,eAAe,GAAG,WAAW,KAAK;EAC3F,OAAO,QAAQ,QAAQ,CAAC,KAAK,IAAI,CAAC;CACpC,CAAC,CACH;AACF;;AAGA,SAAgB,kBAAkB,OAAyB;CACzD,OAAO,eAAe,MAAM,KAAK,SAAS;AAC5C;;AAGA,SAAgB,eAAkB,OAAY,cAAyC;CACrF,OAAO,CAAC,GAAG,MAAM,QAAQ,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,GAAG,MAAM,OAAO,YAAY,CAAC;AACjF"}
|
package/dist/columns/utils.cjs
CHANGED
|
@@ -6,6 +6,7 @@ const require_column_filtered_recipe = require("./column_recipes/column_filtered
|
|
|
6
6
|
const require_column_overrided_recipe = require("./column_recipes/column_overrided_recipe.cjs");
|
|
7
7
|
const require_data_column = require("./data_column.cjs");
|
|
8
8
|
const require_columns_collection = require("./columns_collection.cjs");
|
|
9
|
+
const require_peer_links = require("./peer_links.cjs");
|
|
9
10
|
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
10
11
|
let _milaboratories_helpers = require("@milaboratories/helpers");
|
|
11
12
|
//#region src/columns/utils.ts
|
|
@@ -39,6 +40,11 @@ function collectLinkerIds(recipe) {
|
|
|
39
40
|
function collectLinkerColumns(recipe, opts = {}) {
|
|
40
41
|
return collectLinkerIds(recipe).map((id) => require_data_column.DataColumnImpl.fromId(id, opts) ?? (0, _milaboratories_helpers.throwError)(`materializeLinkers: linker ${id} not resolvable`));
|
|
41
42
|
}
|
|
43
|
+
/** Peer link labels for a column, checked against the result pool's datasets. */
|
|
44
|
+
function createPeerLinkFinder() {
|
|
45
|
+
const datasetAxes = require_peer_links.getResultPoolDatasetAxes();
|
|
46
|
+
return (recipe) => require_peer_links.findPeerLinks(collectLinkerColumns(recipe).map((l) => l.getSpec()), datasetAxes);
|
|
47
|
+
}
|
|
42
48
|
/**
|
|
43
49
|
* Hit-side axis qualifications for the recipe — the ones that should land on
|
|
44
50
|
* the outer-join entry wrapping this column at the consumer boundary.
|
|
@@ -172,17 +178,35 @@ function hasReachableData(recipe) {
|
|
|
172
178
|
* to be wrapped on the fly.
|
|
173
179
|
*/
|
|
174
180
|
function deriveColumnOptions(source, labelOptions = {}) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
label: labels[i]
|
|
181
|
+
return deriveRecipeOptions((require_columns_collection.isColumnsCollection(source) ? source : require_columns_collection.ColumnsCollection(source)).getColumns(), labelOptions).map(({ id, label, linkHint }) => ({
|
|
182
|
+
id,
|
|
183
|
+
label,
|
|
184
|
+
linkHint
|
|
180
185
|
}));
|
|
181
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* {@link ColumnOption}s for `recipes`, each with its recipe. Peer-linked columns go last, the rest
|
|
189
|
+
* keep their order.
|
|
190
|
+
*/
|
|
191
|
+
function deriveRecipeOptions(recipes, labelOptions = {}) {
|
|
192
|
+
const labels = require_derive_distinct_labels.deriveDistinctLabels(recipes.map((r) => r.getSpec()), labelOptions);
|
|
193
|
+
const findPeerLinks = createPeerLinkFinder();
|
|
194
|
+
return require_peer_links.peerLinkedLast(recipes.map((recipe, i) => {
|
|
195
|
+
const links = findPeerLinks(recipe);
|
|
196
|
+
return {
|
|
197
|
+
id: recipe.id,
|
|
198
|
+
label: labels[i],
|
|
199
|
+
linkHint: links.length > 0 ? require_peer_links.describePeerLinks(links) : void 0,
|
|
200
|
+
recipe
|
|
201
|
+
};
|
|
202
|
+
}), (o) => o.linkHint !== void 0);
|
|
203
|
+
}
|
|
182
204
|
//#endregion
|
|
183
205
|
exports.collectLinkerColumns = collectLinkerColumns;
|
|
184
206
|
exports.collectLinkerIds = collectLinkerIds;
|
|
207
|
+
exports.createPeerLinkFinder = createPeerLinkFinder;
|
|
185
208
|
exports.deriveColumnOptions = deriveColumnOptions;
|
|
209
|
+
exports.deriveRecipeOptions = deriveRecipeOptions;
|
|
186
210
|
exports.hasColumnData = hasColumnData;
|
|
187
211
|
exports.hasReachableData = hasReachableData;
|
|
188
212
|
exports.hasSingleDataColumn = hasSingleDataColumn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":["DataColumnImpl","TreeNodeAccessor","ColumnDiscoveredRecipe","ColumnOverriddenRecipe","ColumnFilteredRecipe","DataColumnOverriddenRecipe","isColumnsCollection","ColumnsCollection","deriveDistinctLabels"],"sources":["../../src/columns/utils.ts"],"sourcesContent":["import {\n collectSpecQueryColumns,\n extractPObjectId,\n isDataInfo,\n visitDataInfo,\n type AxisQualification,\n type ColumnUniversalId,\n type PObjectId,\n} from \"@milaboratories/pl-model-common\";\nimport { throwError } from \"@milaboratories/helpers\";\nimport type { GlobalCfgRenderCtx } from \"../render/internal\";\nimport { TreeNodeAccessor } from \"../render\";\nimport { deriveDistinctLabels, type DeriveLabelsOptions } from \"../labels/derive_distinct_labels\";\nimport { DataColumnRecipe, DataColumnImpl, type ColumnData } from \"./data_column\";\nimport { ColumnDiscoveredRecipe } from \"./column_recipes/column_discovered_recipe\";\nimport { ColumnFilteredRecipe } from \"./column_recipes/column_filtered_recipe\";\nimport {\n ColumnOverriddenRecipe,\n DataColumnOverriddenRecipe,\n} from \"./column_recipes/column_overrided_recipe\";\nimport type { ColumnRecipe } from \"./column_recipes/types\";\nimport { ColumnsCollection, isColumnsCollection } from \"./columns_collection\";\nimport type { ColumnsSource } from \"./column_providers/types\";\n\n/**\n * PObjectIds of every non-hit column referenced by `recipe.getQuery()`,\n * deduped in traversal order. The hit column is\n * `extractPObjectId(recipe.id)`; anything else in the query is a linker or\n * other engine-consumed column.\n *\n * Pure query walk — no registry access. Use {@link collectLinkerColumns} for\n * the resolved {@link DataColumnRecipe} variant.\n */\nexport function collectLinkerIds(recipe: ColumnRecipe): PObjectId[] {\n const hit = extractPObjectId(recipe.id);\n const seen = new Set<PObjectId>();\n const out: PObjectId[] = [];\n for (const id of collectSpecQueryColumns(recipe.getQuery())) {\n // Leaf ids in SpecQuery may be rich (e.g. ColumnDiscoveredId) — drop to\n // bare PObjectId before comparing/registering so we hand the ambient\n // ColumnRegistry physical ids it can resolve.\n const bare = extractPObjectId(id);\n if (bare === hit) continue;\n if (seen.has(bare)) continue;\n seen.add(bare);\n out.push(bare);\n }\n return out;\n}\n\n/**\n * {@link collectLinkerIds} resolved against the ambient context as\n * {@link DataColumnRecipe} leaves. Throws if any id fails to resolve —\n * matches the contract of the legacy `resolveLinkers` it replaces.\n */\nexport function collectLinkerColumns(\n recipe: ColumnRecipe,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): DataColumnRecipe<PObjectId>[] {\n return collectLinkerIds(recipe).map(\n (id) =>\n DataColumnImpl.fromId(id, opts) ??\n throwError(`materializeLinkers: linker ${id} not resolvable`),\n );\n}\n\n/**\n * Hit-side axis qualifications for the recipe — the ones that should land on\n * the outer-join entry wrapping this column at the consumer boundary.\n *\n * Descends {@link ColumnOverriddenRecipe} / {@link ColumnFilteredRecipe} via\n * `getInner()` until it finds a {@link ColumnDiscoveredRecipe}; otherwise\n * returns `[]`. Pure recipe walk — no query-tree introspection.\n */\nexport function hitQualifications(recipe: ColumnRecipe): readonly AxisQualification[] {\n const discovered = findDiscovered(recipe);\n return discovered?.getColumnQualifications() ?? [];\n}\n\n/**\n * Per-primary-column axis qualifications for the recipe — applied to the\n * outer primary anchors on this recipe's group side. Keyed by the external\n * primary column id (NOT by columns inside this recipe's own query).\n *\n * Same walk strategy as {@link hitQualifications}.\n */\nexport function queriesQualifications(\n recipe: ColumnRecipe,\n): Readonly<Record<PObjectId, AxisQualification[]>> {\n const discovered = findDiscovered(recipe);\n return discovered?.getQueriesQualifications() ?? {};\n}\n\n/**\n * Whether the recipe's underlying data resources actually carry bytes —\n * strictly stronger than `getDataStatus() === \"present\"`, which only tells\n * that the `.data` field is wired onto the accessor.\n *\n * Walks every physical leaf the recipe depends on via\n * {@link ColumnRecipe.getReferencedIds} (resolves each id back to a\n * {@link DataColumnRecipe} through the ambient ctx) and ANDs `hasData()` across\n * all of them. Inline {@link PColumnValues} payloads count as present.\n *\n * Returns `false` if any leaf cannot be re-resolved in `opts.ctx` (treat as\n * \"not yet ready\") rather than throwing — this is a UI-facing predicate, not\n * a contract assertion.\n */\nexport function hasColumnData(\n recipe: ColumnRecipe,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): boolean {\n for (const id of recipe.getReferencedIds()) {\n const leaf = DataColumnImpl.fromId(id, opts);\n if (leaf === undefined) return false;\n if (leaf.getDataStatus() !== \"present\") return false;\n if (!isLeafDataPresent(leaf.getData())) return false;\n }\n return true;\n}\n\nfunction isLeafDataPresent(data: ColumnData): boolean {\n if (data === undefined) return false;\n if (Array.isArray(data)) return true;\n if (data instanceof TreeNodeAccessor) return data.hasData();\n if (isDataInfo(data)) {\n let ok = true;\n visitDataInfo(data, (blob) => {\n ok &&= blob.hasData();\n });\n return ok;\n }\n return false;\n}\n\n/**\n * Walk wrapper layers (Overridden, Filtered) until a {@link\n * ColumnDiscoveredRecipe} is found. Returns `undefined` if the recipe chain\n * has no Discovered layer (bare leaves and Overridden-over-leaf cases).\n *\n * Invariant from the wrapper classes themselves: there is at most one\n * Discovered layer in any recipe chain — Discovered is constructed only via\n * its own factory and is never re-wrapped by Discovered.\n */\nfunction findDiscovered(recipe: ColumnRecipe): undefined | ColumnDiscoveredRecipe {\n let current: ColumnRecipe = recipe;\n while (true) {\n if (current instanceof ColumnDiscoveredRecipe) return current;\n if (current instanceof ColumnOverriddenRecipe || current instanceof ColumnFilteredRecipe) {\n current = current.getInner();\n continue;\n }\n return undefined;\n }\n}\n\n/**\n * Whether the recipe reads exactly one data column — its own — rather than\n * reaching through others.\n *\n * True for a bare leaf and for projections over one (spec overrides, axis\n * slicing): those add layers but no new columns. False when the recipe gets at\n * its data through further columns, which happens when discovery reached it via\n * a linker chain.\n *\n * **Why callers care.** A recipe over a single data column is co-indexed by its\n * own axes, so its spec is the whole truth about them. One that needs other\n * columns only lines up after they are joined in, and therefore drags axes into\n * the join that its own spec never mentions — which is why it cannot serve as a\n * primary column, and why `createPlDataTableV3` splits on this.\n *\n * The count comes from {@link ColumnRecipe.getReferencedIds}, which resolves\n * through the whole wrapper chain, so no class walk is involved and foreign\n * `ColumnRecipe` implementations are handled too.\n */\nexport function hasSingleDataColumn(recipe: ColumnRecipe): boolean {\n return recipe.getReferencedIds().length === 1;\n}\n\n/**\n * @deprecated Renamed to {@link hasSingleDataColumn} — \"leaf\" read as \"you can\n * get data out of it\", which is a different question (see\n * {@link hasReachableData}). Same semantics.\n */\nexport const isLeafColumn = hasSingleDataColumn;\n\n/**\n * Whether the column's data can be read here and now, consistent with its\n * spec — narrows to {@link DataColumnRecipe}, which exposes `getData()`.\n *\n * True for a bare leaf and for a spec-override over a bare leaf. False for an\n * axis-filtered recipe (its spec has dropped axes the underlying data still\n * carries, so the two no longer line up) and for anything reached through\n * other columns (nothing to read until the engine joins them). In both of\n * those cases the data exists only engine-side: pass `recipe.id` to\n * `createPFrame` / `createPTable` instead of trying to read it.\n *\n * The distinction is settled when the recipe is built, not here — recipes that\n * carry data are instances of a class that declares `getData`. So a `true`\n * result narrows to a value that really has the method, and there is no\n * throwing path behind the guard.\n */\nexport function hasReachableData(recipe: ColumnRecipe): recipe is DataColumnRecipe {\n return recipe instanceof DataColumnImpl || recipe instanceof DataColumnOverriddenRecipe;\n}\n\n/** Drop-down option built over a {@link ColumnsCollection} — universal-id valued. */\nexport type ColumnOption = {\n readonly id: ColumnUniversalId;\n readonly label: string;\n};\n\n/**\n * Enumerates every column already in `source` and renders distinct labels\n * from each recipe's spec. Filtering is the caller's job — pass a\n * {@link ColumnsCollection} that was already narrowed via `.filter(...)` /\n * `.discover(...)`, or hand over a raw {@link ColumnsSource} (provider,\n * accessor, column array, or `\"result_pool\"` / `\"current_block\"` shorthand)\n * to be wrapped on the fly.\n */\nexport function deriveColumnOptions(\n source: ColumnsCollection | ColumnsSource[],\n labelOptions: DeriveLabelsOptions = {},\n): ColumnOption[] {\n const collection = isColumnsCollection(source) ? source : ColumnsCollection(source);\n const recipes = collection.getColumns();\n const labels = deriveDistinctLabels(\n recipes.map((r) => r.getSpec()),\n labelOptions,\n );\n return recipes.map((r, i) => ({ id: r.id, label: labels[i] }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCA,SAAgB,iBAAiB,QAAmC;CAClE,MAAM,OAAA,GAAA,gCAAA,iBAAA,CAAuB,OAAO,EAAE;CACtC,MAAM,uBAAO,IAAI,IAAe;CAChC,MAAM,MAAmB,CAAC;CAC1B,KAAK,MAAM,OAAA,GAAA,gCAAA,wBAAA,CAA8B,OAAO,SAAS,CAAC,GAAG;EAI3D,MAAM,QAAA,GAAA,gCAAA,iBAAA,CAAwB,EAAE;EAChC,IAAI,SAAS,KAAK;EAClB,IAAI,KAAK,IAAI,IAAI,GAAG;EACpB,KAAK,IAAI,IAAI;EACb,IAAI,KAAK,IAAI;CACf;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,qBACd,QACA,OAAqC,CAAC,GACP;CAC/B,OAAO,iBAAiB,MAAM,CAAC,CAAC,KAC7B,OACCA,oBAAAA,eAAe,OAAO,IAAI,IAAI,MAAA,GAAA,wBAAA,WAAA,CACnB,8BAA8B,GAAG,gBAAgB,CAChE;AACF;;;;;;;;;AAUA,SAAgB,kBAAkB,QAAoD;CAEpF,OADmB,eAAe,MAClB,CAAC,EAAE,wBAAwB,KAAK,CAAC;AACnD;;;;;;;;AASA,SAAgB,sBACd,QACkD;CAElD,OADmB,eAAe,MAClB,CAAC,EAAE,yBAAyB,KAAK,CAAC;AACpD;;;;;;;;;;;;;;;AAgBA,SAAgB,cACd,QACA,OAAqC,CAAC,GAC7B;CACT,KAAK,MAAM,MAAM,OAAO,iBAAiB,GAAG;EAC1C,MAAM,OAAOA,oBAAAA,eAAe,OAAO,IAAI,IAAI;EAC3C,IAAI,SAAS,KAAA,GAAW,OAAO;EAC/B,IAAI,KAAK,cAAc,MAAM,WAAW,OAAO;EAC/C,IAAI,CAAC,kBAAkB,KAAK,QAAQ,CAAC,GAAG,OAAO;CACjD;CACA,OAAO;AACT;AAEA,SAAS,kBAAkB,MAA2B;CACpD,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO;CAChC,IAAI,gBAAgBC,iBAAAA,kBAAkB,OAAO,KAAK,QAAQ;CAC1D,KAAA,GAAA,gCAAA,WAAA,CAAe,IAAI,GAAG;EACpB,IAAI,KAAK;EACT,CAAA,GAAA,gCAAA,cAAA,CAAc,OAAO,SAAS;GAC5B,OAAO,KAAK,QAAQ;EACtB,CAAC;EACD,OAAO;CACT;CACA,OAAO;AACT;;;;;;;;;;AAWA,SAAS,eAAe,QAA0D;CAChF,IAAI,UAAwB;CAC5B,OAAO,MAAM;EACX,IAAI,mBAAmBC,iCAAAA,wBAAwB,OAAO;EACtD,IAAI,mBAAmBC,gCAAAA,0BAA0B,mBAAmBC,+BAAAA,sBAAsB;GACxF,UAAU,QAAQ,SAAS;GAC3B;EACF;EACA;CACF;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,oBAAoB,QAA+B;CACjE,OAAO,OAAO,iBAAiB,CAAC,CAAC,WAAW;AAC9C;;;;;;AAOA,MAAa,eAAe;;;;;;;;;;;;;;;;;AAkB5B,SAAgB,iBAAiB,QAAkD;CACjF,OAAO,kBAAkBJ,oBAAAA,kBAAkB,kBAAkBK,gCAAAA;AAC/D;;;;;;;;;AAgBA,SAAgB,oBACd,QACA,eAAoC,CAAC,GACrB;CAEhB,MAAM,WADaC,2BAAAA,oBAAoB,MAAM,IAAI,SAASC,2BAAAA,kBAAkB,MAAM,EAAA,CACvD,WAAW;CACtC,MAAM,SAASC,+BAAAA,qBACb,QAAQ,KAAK,MAAM,EAAE,QAAQ,CAAC,GAC9B,YACF;CACA,OAAO,QAAQ,KAAK,GAAG,OAAO;EAAE,IAAI,EAAE;EAAI,OAAO,OAAO;CAAG,EAAE;AAC/D"}
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":["DataColumnImpl","getResultPoolDatasetAxes","findPeerLinks","TreeNodeAccessor","ColumnDiscoveredRecipe","ColumnOverriddenRecipe","ColumnFilteredRecipe","DataColumnOverriddenRecipe","isColumnsCollection","ColumnsCollection","deriveDistinctLabels","peerLinkedLast","describePeerLinks"],"sources":["../../src/columns/utils.ts"],"sourcesContent":["import {\n collectSpecQueryColumns,\n extractPObjectId,\n isDataInfo,\n visitDataInfo,\n type AxisQualification,\n type ColumnUniversalId,\n type PObjectId,\n} from \"@milaboratories/pl-model-common\";\nimport { throwError } from \"@milaboratories/helpers\";\nimport type { GlobalCfgRenderCtx } from \"../render/internal\";\nimport { TreeNodeAccessor } from \"../render\";\nimport { deriveDistinctLabels, type DeriveLabelsOptions } from \"../labels/derive_distinct_labels\";\nimport { DataColumnRecipe, DataColumnImpl, type ColumnData } from \"./data_column\";\nimport { ColumnDiscoveredRecipe } from \"./column_recipes/column_discovered_recipe\";\nimport { ColumnFilteredRecipe } from \"./column_recipes/column_filtered_recipe\";\nimport {\n ColumnOverriddenRecipe,\n DataColumnOverriddenRecipe,\n} from \"./column_recipes/column_overrided_recipe\";\nimport type { ColumnRecipe } from \"./column_recipes/types\";\nimport { ColumnsCollection, isColumnsCollection } from \"./columns_collection\";\nimport type { ColumnsSource } from \"./column_providers/types\";\nimport {\n describePeerLinks,\n findPeerLinks,\n getResultPoolDatasetAxes,\n peerLinkedLast,\n} from \"./peer_links\";\n\n/**\n * PObjectIds of every non-hit column referenced by `recipe.getQuery()`,\n * deduped in traversal order. The hit column is\n * `extractPObjectId(recipe.id)`; anything else in the query is a linker or\n * other engine-consumed column.\n *\n * Pure query walk — no registry access. Use {@link collectLinkerColumns} for\n * the resolved {@link DataColumnRecipe} variant.\n */\nexport function collectLinkerIds(recipe: ColumnRecipe): PObjectId[] {\n const hit = extractPObjectId(recipe.id);\n const seen = new Set<PObjectId>();\n const out: PObjectId[] = [];\n for (const id of collectSpecQueryColumns(recipe.getQuery())) {\n // Leaf ids in SpecQuery may be rich (e.g. ColumnDiscoveredId) — drop to\n // bare PObjectId before comparing/registering so we hand the ambient\n // ColumnRegistry physical ids it can resolve.\n const bare = extractPObjectId(id);\n if (bare === hit) continue;\n if (seen.has(bare)) continue;\n seen.add(bare);\n out.push(bare);\n }\n return out;\n}\n\n/**\n * {@link collectLinkerIds} resolved against the ambient context as\n * {@link DataColumnRecipe} leaves. Throws if any id fails to resolve —\n * matches the contract of the legacy `resolveLinkers` it replaces.\n */\nexport function collectLinkerColumns(\n recipe: ColumnRecipe,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): DataColumnRecipe<PObjectId>[] {\n return collectLinkerIds(recipe).map(\n (id) =>\n DataColumnImpl.fromId(id, opts) ??\n throwError(`materializeLinkers: linker ${id} not resolvable`),\n );\n}\n\n/** Peer link labels for a column, checked against the result pool's datasets. */\nexport function createPeerLinkFinder(): (recipe: ColumnRecipe) => string[] {\n const datasetAxes = getResultPoolDatasetAxes();\n return (recipe) =>\n findPeerLinks(\n collectLinkerColumns(recipe).map((l) => l.getSpec()),\n datasetAxes,\n );\n}\n\n/**\n * Hit-side axis qualifications for the recipe — the ones that should land on\n * the outer-join entry wrapping this column at the consumer boundary.\n *\n * Descends {@link ColumnOverriddenRecipe} / {@link ColumnFilteredRecipe} via\n * `getInner()` until it finds a {@link ColumnDiscoveredRecipe}; otherwise\n * returns `[]`. Pure recipe walk — no query-tree introspection.\n */\nexport function hitQualifications(recipe: ColumnRecipe): readonly AxisQualification[] {\n const discovered = findDiscovered(recipe);\n return discovered?.getColumnQualifications() ?? [];\n}\n\n/**\n * Per-primary-column axis qualifications for the recipe — applied to the\n * outer primary anchors on this recipe's group side. Keyed by the external\n * primary column id (NOT by columns inside this recipe's own query).\n *\n * Same walk strategy as {@link hitQualifications}.\n */\nexport function queriesQualifications(\n recipe: ColumnRecipe,\n): Readonly<Record<PObjectId, AxisQualification[]>> {\n const discovered = findDiscovered(recipe);\n return discovered?.getQueriesQualifications() ?? {};\n}\n\n/**\n * Whether the recipe's underlying data resources actually carry bytes —\n * strictly stronger than `getDataStatus() === \"present\"`, which only tells\n * that the `.data` field is wired onto the accessor.\n *\n * Walks every physical leaf the recipe depends on via\n * {@link ColumnRecipe.getReferencedIds} (resolves each id back to a\n * {@link DataColumnRecipe} through the ambient ctx) and ANDs `hasData()` across\n * all of them. Inline {@link PColumnValues} payloads count as present.\n *\n * Returns `false` if any leaf cannot be re-resolved in `opts.ctx` (treat as\n * \"not yet ready\") rather than throwing — this is a UI-facing predicate, not\n * a contract assertion.\n */\nexport function hasColumnData(\n recipe: ColumnRecipe,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): boolean {\n for (const id of recipe.getReferencedIds()) {\n const leaf = DataColumnImpl.fromId(id, opts);\n if (leaf === undefined) return false;\n if (leaf.getDataStatus() !== \"present\") return false;\n if (!isLeafDataPresent(leaf.getData())) return false;\n }\n return true;\n}\n\nfunction isLeafDataPresent(data: ColumnData): boolean {\n if (data === undefined) return false;\n if (Array.isArray(data)) return true;\n if (data instanceof TreeNodeAccessor) return data.hasData();\n if (isDataInfo(data)) {\n let ok = true;\n visitDataInfo(data, (blob) => {\n ok &&= blob.hasData();\n });\n return ok;\n }\n return false;\n}\n\n/**\n * Walk wrapper layers (Overridden, Filtered) until a {@link\n * ColumnDiscoveredRecipe} is found. Returns `undefined` if the recipe chain\n * has no Discovered layer (bare leaves and Overridden-over-leaf cases).\n *\n * Invariant from the wrapper classes themselves: there is at most one\n * Discovered layer in any recipe chain — Discovered is constructed only via\n * its own factory and is never re-wrapped by Discovered.\n */\nfunction findDiscovered(recipe: ColumnRecipe): undefined | ColumnDiscoveredRecipe {\n let current: ColumnRecipe = recipe;\n while (true) {\n if (current instanceof ColumnDiscoveredRecipe) return current;\n if (current instanceof ColumnOverriddenRecipe || current instanceof ColumnFilteredRecipe) {\n current = current.getInner();\n continue;\n }\n return undefined;\n }\n}\n\n/**\n * Whether the recipe reads exactly one data column — its own — rather than\n * reaching through others.\n *\n * True for a bare leaf and for projections over one (spec overrides, axis\n * slicing): those add layers but no new columns. False when the recipe gets at\n * its data through further columns, which happens when discovery reached it via\n * a linker chain.\n *\n * **Why callers care.** A recipe over a single data column is co-indexed by its\n * own axes, so its spec is the whole truth about them. One that needs other\n * columns only lines up after they are joined in, and therefore drags axes into\n * the join that its own spec never mentions — which is why it cannot serve as a\n * primary column, and why `createPlDataTableV3` splits on this.\n *\n * The count comes from {@link ColumnRecipe.getReferencedIds}, which resolves\n * through the whole wrapper chain, so no class walk is involved and foreign\n * `ColumnRecipe` implementations are handled too.\n */\nexport function hasSingleDataColumn(recipe: ColumnRecipe): boolean {\n return recipe.getReferencedIds().length === 1;\n}\n\n/**\n * @deprecated Renamed to {@link hasSingleDataColumn} — \"leaf\" read as \"you can\n * get data out of it\", which is a different question (see\n * {@link hasReachableData}). Same semantics.\n */\nexport const isLeafColumn = hasSingleDataColumn;\n\n/**\n * Whether the column's data can be read here and now, consistent with its\n * spec — narrows to {@link DataColumnRecipe}, which exposes `getData()`.\n *\n * True for a bare leaf and for a spec-override over a bare leaf. False for an\n * axis-filtered recipe (its spec has dropped axes the underlying data still\n * carries, so the two no longer line up) and for anything reached through\n * other columns (nothing to read until the engine joins them). In both of\n * those cases the data exists only engine-side: pass `recipe.id` to\n * `createPFrame` / `createPTable` instead of trying to read it.\n *\n * The distinction is settled when the recipe is built, not here — recipes that\n * carry data are instances of a class that declares `getData`. So a `true`\n * result narrows to a value that really has the method, and there is no\n * throwing path behind the guard.\n */\nexport function hasReachableData(recipe: ColumnRecipe): recipe is DataColumnRecipe {\n return recipe instanceof DataColumnImpl || recipe instanceof DataColumnOverriddenRecipe;\n}\n\n/** Drop-down option built over a {@link ColumnsCollection} — universal-id valued. */\nexport type ColumnOption = {\n readonly id: ColumnUniversalId;\n readonly label: string;\n /** Set for columns reached through a peer link; the dropdown shows it beside a link icon. */\n readonly linkHint?: string;\n};\n\n/**\n * Enumerates every column already in `source` and renders distinct labels\n * from each recipe's spec. Filtering is the caller's job — pass a\n * {@link ColumnsCollection} that was already narrowed via `.filter(...)` /\n * `.discover(...)`, or hand over a raw {@link ColumnsSource} (provider,\n * accessor, column array, or `\"result_pool\"` / `\"current_block\"` shorthand)\n * to be wrapped on the fly.\n */\nexport function deriveColumnOptions(\n source: ColumnsCollection | ColumnsSource[],\n labelOptions: DeriveLabelsOptions = {},\n): ColumnOption[] {\n const collection = isColumnsCollection(source) ? source : ColumnsCollection(source);\n return deriveRecipeOptions(collection.getColumns(), labelOptions).map(\n ({ id, label, linkHint }) => ({ id, label, linkHint }),\n );\n}\n\n/**\n * {@link ColumnOption}s for `recipes`, each with its recipe. Peer-linked columns go last, the rest\n * keep their order.\n */\nexport function deriveRecipeOptions<R extends ColumnRecipe>(\n recipes: R[],\n labelOptions: DeriveLabelsOptions = {},\n): (ColumnOption & { readonly recipe: R })[] {\n const labels = deriveDistinctLabels(\n recipes.map((r) => r.getSpec()),\n labelOptions,\n );\n const findPeerLinks = createPeerLinkFinder();\n const options = recipes.map((recipe, i) => {\n const links = findPeerLinks(recipe);\n return {\n id: recipe.id,\n label: labels[i],\n linkHint: links.length > 0 ? describePeerLinks(links) : undefined,\n recipe,\n };\n });\n return peerLinkedLast(options, (o) => o.linkHint !== undefined);\n}\n"],"mappings":"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"}
|
package/dist/columns/utils.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export declare function collectLinkerIds(recipe: ColumnRecipe): PObjectId[];
|
|
|
24
24
|
export declare function collectLinkerColumns(recipe: ColumnRecipe, opts?: {
|
|
25
25
|
ctx?: GlobalCfgRenderCtx;
|
|
26
26
|
}): DataColumnRecipe<PObjectId>[];
|
|
27
|
+
/** Peer link labels for a column, checked against the result pool's datasets. */
|
|
28
|
+
export declare function createPeerLinkFinder(): (recipe: ColumnRecipe) => string[];
|
|
27
29
|
/**
|
|
28
30
|
* Hit-side axis qualifications for the recipe — the ones that should land on
|
|
29
31
|
* the outer-join entry wrapping this column at the consumer boundary.
|
|
@@ -105,6 +107,8 @@ export declare function hasReachableData(recipe: ColumnRecipe): recipe is DataCo
|
|
|
105
107
|
export type ColumnOption = {
|
|
106
108
|
readonly id: ColumnUniversalId;
|
|
107
109
|
readonly label: string;
|
|
110
|
+
/** Set for columns reached through a peer link; the dropdown shows it beside a link icon. */
|
|
111
|
+
readonly linkHint?: string;
|
|
108
112
|
};
|
|
109
113
|
/**
|
|
110
114
|
* Enumerates every column already in `source` and renders distinct labels
|
|
@@ -115,5 +119,12 @@ export type ColumnOption = {
|
|
|
115
119
|
* to be wrapped on the fly.
|
|
116
120
|
*/
|
|
117
121
|
export declare function deriveColumnOptions(source: ColumnsCollection | ColumnsSource[], labelOptions?: DeriveLabelsOptions): ColumnOption[];
|
|
122
|
+
/**
|
|
123
|
+
* {@link ColumnOption}s for `recipes`, each with its recipe. Peer-linked columns go last, the rest
|
|
124
|
+
* keep their order.
|
|
125
|
+
*/
|
|
126
|
+
export declare function deriveRecipeOptions<R extends ColumnRecipe>(recipes: R[], labelOptions?: DeriveLabelsOptions): (ColumnOption & {
|
|
127
|
+
readonly recipe: R;
|
|
128
|
+
})[];
|
|
118
129
|
//#endregion
|
|
119
130
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/columns/utils.ts"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/columns/utils.ts"],"mappings":";;;;;;;;;;;;;;;;;wBAuCgB,iBAAiB,QAAQ,eAAe;;;;;;wBAsBxC,qBACd,QAAQ,cACR;EAAQ,MAAM;IACb,iBAAiB;;wBASJ,yBAAyB,QAAQ;;;;;;;;;wBAiBjC,kBAAkB,QAAQ,wBAAwB;;;;;;;;wBAYlD,sBACd,QAAQ,eACP,SAAS,OAAO,WAAW;;;;;;;;;;;;;;;wBAmBd,cACd,QAAQ,cACR;EAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;wBAiEA,oBAAoB,QAAQ;;;;;;qBAS/B,qBAAY;;;;;;;;;;;;;;;;;wBAkBT,iBAAiB,QAAQ,eAAe,UAAU;;YAKtD;WACD,IAAI;WACJ;;WAEA;;;;;;;;;;wBAWK,oBACd,QAAQ,oBAAoB,iBAC5B,eAAc,sBACb;;;;;wBAWa,oBAAoB,UAAU,cAC5C,SAAS,KACT,eAAc,uBACZ;WAA0B,QAAQ"}
|
package/dist/columns/utils.js
CHANGED
|
@@ -6,6 +6,7 @@ import { ColumnFilteredRecipe } from "./column_recipes/column_filtered_recipe.js
|
|
|
6
6
|
import { ColumnOverriddenRecipe, DataColumnOverriddenRecipe } from "./column_recipes/column_overrided_recipe.js";
|
|
7
7
|
import { DataColumnImpl } from "./data_column.js";
|
|
8
8
|
import { ColumnsCollection, isColumnsCollection } from "./columns_collection.js";
|
|
9
|
+
import { describePeerLinks, findPeerLinks, getResultPoolDatasetAxes, peerLinkedLast } from "./peer_links.js";
|
|
9
10
|
import { collectSpecQueryColumns, extractPObjectId, isDataInfo, visitDataInfo } from "@milaboratories/pl-model-common";
|
|
10
11
|
import { throwError } from "@milaboratories/helpers";
|
|
11
12
|
//#region src/columns/utils.ts
|
|
@@ -39,6 +40,11 @@ function collectLinkerIds(recipe) {
|
|
|
39
40
|
function collectLinkerColumns(recipe, opts = {}) {
|
|
40
41
|
return collectLinkerIds(recipe).map((id) => DataColumnImpl.fromId(id, opts) ?? throwError(`materializeLinkers: linker ${id} not resolvable`));
|
|
41
42
|
}
|
|
43
|
+
/** Peer link labels for a column, checked against the result pool's datasets. */
|
|
44
|
+
function createPeerLinkFinder() {
|
|
45
|
+
const datasetAxes = getResultPoolDatasetAxes();
|
|
46
|
+
return (recipe) => findPeerLinks(collectLinkerColumns(recipe).map((l) => l.getSpec()), datasetAxes);
|
|
47
|
+
}
|
|
42
48
|
/**
|
|
43
49
|
* Hit-side axis qualifications for the recipe — the ones that should land on
|
|
44
50
|
* the outer-join entry wrapping this column at the consumer boundary.
|
|
@@ -172,14 +178,30 @@ function hasReachableData(recipe) {
|
|
|
172
178
|
* to be wrapped on the fly.
|
|
173
179
|
*/
|
|
174
180
|
function deriveColumnOptions(source, labelOptions = {}) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
label: labels[i]
|
|
181
|
+
return deriveRecipeOptions((isColumnsCollection(source) ? source : ColumnsCollection(source)).getColumns(), labelOptions).map(({ id, label, linkHint }) => ({
|
|
182
|
+
id,
|
|
183
|
+
label,
|
|
184
|
+
linkHint
|
|
180
185
|
}));
|
|
181
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* {@link ColumnOption}s for `recipes`, each with its recipe. Peer-linked columns go last, the rest
|
|
189
|
+
* keep their order.
|
|
190
|
+
*/
|
|
191
|
+
function deriveRecipeOptions(recipes, labelOptions = {}) {
|
|
192
|
+
const labels = deriveDistinctLabels(recipes.map((r) => r.getSpec()), labelOptions);
|
|
193
|
+
const findPeerLinks = createPeerLinkFinder();
|
|
194
|
+
return peerLinkedLast(recipes.map((recipe, i) => {
|
|
195
|
+
const links = findPeerLinks(recipe);
|
|
196
|
+
return {
|
|
197
|
+
id: recipe.id,
|
|
198
|
+
label: labels[i],
|
|
199
|
+
linkHint: links.length > 0 ? describePeerLinks(links) : void 0,
|
|
200
|
+
recipe
|
|
201
|
+
};
|
|
202
|
+
}), (o) => o.linkHint !== void 0);
|
|
203
|
+
}
|
|
182
204
|
//#endregion
|
|
183
|
-
export { collectLinkerColumns, collectLinkerIds, deriveColumnOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications };
|
|
205
|
+
export { collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveColumnOptions, deriveRecipeOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications };
|
|
184
206
|
|
|
185
207
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../src/columns/utils.ts"],"sourcesContent":["import {\n collectSpecQueryColumns,\n extractPObjectId,\n isDataInfo,\n visitDataInfo,\n type AxisQualification,\n type ColumnUniversalId,\n type PObjectId,\n} from \"@milaboratories/pl-model-common\";\nimport { throwError } from \"@milaboratories/helpers\";\nimport type { GlobalCfgRenderCtx } from \"../render/internal\";\nimport { TreeNodeAccessor } from \"../render\";\nimport { deriveDistinctLabels, type DeriveLabelsOptions } from \"../labels/derive_distinct_labels\";\nimport { DataColumnRecipe, DataColumnImpl, type ColumnData } from \"./data_column\";\nimport { ColumnDiscoveredRecipe } from \"./column_recipes/column_discovered_recipe\";\nimport { ColumnFilteredRecipe } from \"./column_recipes/column_filtered_recipe\";\nimport {\n ColumnOverriddenRecipe,\n DataColumnOverriddenRecipe,\n} from \"./column_recipes/column_overrided_recipe\";\nimport type { ColumnRecipe } from \"./column_recipes/types\";\nimport { ColumnsCollection, isColumnsCollection } from \"./columns_collection\";\nimport type { ColumnsSource } from \"./column_providers/types\";\n\n/**\n * PObjectIds of every non-hit column referenced by `recipe.getQuery()`,\n * deduped in traversal order. The hit column is\n * `extractPObjectId(recipe.id)`; anything else in the query is a linker or\n * other engine-consumed column.\n *\n * Pure query walk — no registry access. Use {@link collectLinkerColumns} for\n * the resolved {@link DataColumnRecipe} variant.\n */\nexport function collectLinkerIds(recipe: ColumnRecipe): PObjectId[] {\n const hit = extractPObjectId(recipe.id);\n const seen = new Set<PObjectId>();\n const out: PObjectId[] = [];\n for (const id of collectSpecQueryColumns(recipe.getQuery())) {\n // Leaf ids in SpecQuery may be rich (e.g. ColumnDiscoveredId) — drop to\n // bare PObjectId before comparing/registering so we hand the ambient\n // ColumnRegistry physical ids it can resolve.\n const bare = extractPObjectId(id);\n if (bare === hit) continue;\n if (seen.has(bare)) continue;\n seen.add(bare);\n out.push(bare);\n }\n return out;\n}\n\n/**\n * {@link collectLinkerIds} resolved against the ambient context as\n * {@link DataColumnRecipe} leaves. Throws if any id fails to resolve —\n * matches the contract of the legacy `resolveLinkers` it replaces.\n */\nexport function collectLinkerColumns(\n recipe: ColumnRecipe,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): DataColumnRecipe<PObjectId>[] {\n return collectLinkerIds(recipe).map(\n (id) =>\n DataColumnImpl.fromId(id, opts) ??\n throwError(`materializeLinkers: linker ${id} not resolvable`),\n );\n}\n\n/**\n * Hit-side axis qualifications for the recipe — the ones that should land on\n * the outer-join entry wrapping this column at the consumer boundary.\n *\n * Descends {@link ColumnOverriddenRecipe} / {@link ColumnFilteredRecipe} via\n * `getInner()` until it finds a {@link ColumnDiscoveredRecipe}; otherwise\n * returns `[]`. Pure recipe walk — no query-tree introspection.\n */\nexport function hitQualifications(recipe: ColumnRecipe): readonly AxisQualification[] {\n const discovered = findDiscovered(recipe);\n return discovered?.getColumnQualifications() ?? [];\n}\n\n/**\n * Per-primary-column axis qualifications for the recipe — applied to the\n * outer primary anchors on this recipe's group side. Keyed by the external\n * primary column id (NOT by columns inside this recipe's own query).\n *\n * Same walk strategy as {@link hitQualifications}.\n */\nexport function queriesQualifications(\n recipe: ColumnRecipe,\n): Readonly<Record<PObjectId, AxisQualification[]>> {\n const discovered = findDiscovered(recipe);\n return discovered?.getQueriesQualifications() ?? {};\n}\n\n/**\n * Whether the recipe's underlying data resources actually carry bytes —\n * strictly stronger than `getDataStatus() === \"present\"`, which only tells\n * that the `.data` field is wired onto the accessor.\n *\n * Walks every physical leaf the recipe depends on via\n * {@link ColumnRecipe.getReferencedIds} (resolves each id back to a\n * {@link DataColumnRecipe} through the ambient ctx) and ANDs `hasData()` across\n * all of them. Inline {@link PColumnValues} payloads count as present.\n *\n * Returns `false` if any leaf cannot be re-resolved in `opts.ctx` (treat as\n * \"not yet ready\") rather than throwing — this is a UI-facing predicate, not\n * a contract assertion.\n */\nexport function hasColumnData(\n recipe: ColumnRecipe,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): boolean {\n for (const id of recipe.getReferencedIds()) {\n const leaf = DataColumnImpl.fromId(id, opts);\n if (leaf === undefined) return false;\n if (leaf.getDataStatus() !== \"present\") return false;\n if (!isLeafDataPresent(leaf.getData())) return false;\n }\n return true;\n}\n\nfunction isLeafDataPresent(data: ColumnData): boolean {\n if (data === undefined) return false;\n if (Array.isArray(data)) return true;\n if (data instanceof TreeNodeAccessor) return data.hasData();\n if (isDataInfo(data)) {\n let ok = true;\n visitDataInfo(data, (blob) => {\n ok &&= blob.hasData();\n });\n return ok;\n }\n return false;\n}\n\n/**\n * Walk wrapper layers (Overridden, Filtered) until a {@link\n * ColumnDiscoveredRecipe} is found. Returns `undefined` if the recipe chain\n * has no Discovered layer (bare leaves and Overridden-over-leaf cases).\n *\n * Invariant from the wrapper classes themselves: there is at most one\n * Discovered layer in any recipe chain — Discovered is constructed only via\n * its own factory and is never re-wrapped by Discovered.\n */\nfunction findDiscovered(recipe: ColumnRecipe): undefined | ColumnDiscoveredRecipe {\n let current: ColumnRecipe = recipe;\n while (true) {\n if (current instanceof ColumnDiscoveredRecipe) return current;\n if (current instanceof ColumnOverriddenRecipe || current instanceof ColumnFilteredRecipe) {\n current = current.getInner();\n continue;\n }\n return undefined;\n }\n}\n\n/**\n * Whether the recipe reads exactly one data column — its own — rather than\n * reaching through others.\n *\n * True for a bare leaf and for projections over one (spec overrides, axis\n * slicing): those add layers but no new columns. False when the recipe gets at\n * its data through further columns, which happens when discovery reached it via\n * a linker chain.\n *\n * **Why callers care.** A recipe over a single data column is co-indexed by its\n * own axes, so its spec is the whole truth about them. One that needs other\n * columns only lines up after they are joined in, and therefore drags axes into\n * the join that its own spec never mentions — which is why it cannot serve as a\n * primary column, and why `createPlDataTableV3` splits on this.\n *\n * The count comes from {@link ColumnRecipe.getReferencedIds}, which resolves\n * through the whole wrapper chain, so no class walk is involved and foreign\n * `ColumnRecipe` implementations are handled too.\n */\nexport function hasSingleDataColumn(recipe: ColumnRecipe): boolean {\n return recipe.getReferencedIds().length === 1;\n}\n\n/**\n * @deprecated Renamed to {@link hasSingleDataColumn} — \"leaf\" read as \"you can\n * get data out of it\", which is a different question (see\n * {@link hasReachableData}). Same semantics.\n */\nexport const isLeafColumn = hasSingleDataColumn;\n\n/**\n * Whether the column's data can be read here and now, consistent with its\n * spec — narrows to {@link DataColumnRecipe}, which exposes `getData()`.\n *\n * True for a bare leaf and for a spec-override over a bare leaf. False for an\n * axis-filtered recipe (its spec has dropped axes the underlying data still\n * carries, so the two no longer line up) and for anything reached through\n * other columns (nothing to read until the engine joins them). In both of\n * those cases the data exists only engine-side: pass `recipe.id` to\n * `createPFrame` / `createPTable` instead of trying to read it.\n *\n * The distinction is settled when the recipe is built, not here — recipes that\n * carry data are instances of a class that declares `getData`. So a `true`\n * result narrows to a value that really has the method, and there is no\n * throwing path behind the guard.\n */\nexport function hasReachableData(recipe: ColumnRecipe): recipe is DataColumnRecipe {\n return recipe instanceof DataColumnImpl || recipe instanceof DataColumnOverriddenRecipe;\n}\n\n/** Drop-down option built over a {@link ColumnsCollection} — universal-id valued. */\nexport type ColumnOption = {\n readonly id: ColumnUniversalId;\n readonly label: string;\n};\n\n/**\n * Enumerates every column already in `source` and renders distinct labels\n * from each recipe's spec. Filtering is the caller's job — pass a\n * {@link ColumnsCollection} that was already narrowed via `.filter(...)` /\n * `.discover(...)`, or hand over a raw {@link ColumnsSource} (provider,\n * accessor, column array, or `\"result_pool\"` / `\"current_block\"` shorthand)\n * to be wrapped on the fly.\n */\nexport function deriveColumnOptions(\n source: ColumnsCollection | ColumnsSource[],\n labelOptions: DeriveLabelsOptions = {},\n): ColumnOption[] {\n const collection = isColumnsCollection(source) ? source : ColumnsCollection(source);\n const recipes = collection.getColumns();\n const labels = deriveDistinctLabels(\n recipes.map((r) => r.getSpec()),\n labelOptions,\n );\n return recipes.map((r, i) => ({ id: r.id, label: labels[i] }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCA,SAAgB,iBAAiB,QAAmC;CAClE,MAAM,MAAM,iBAAiB,OAAO,EAAE;CACtC,MAAM,uBAAO,IAAI,IAAe;CAChC,MAAM,MAAmB,CAAC;CAC1B,KAAK,MAAM,MAAM,wBAAwB,OAAO,SAAS,CAAC,GAAG;EAI3D,MAAM,OAAO,iBAAiB,EAAE;EAChC,IAAI,SAAS,KAAK;EAClB,IAAI,KAAK,IAAI,IAAI,GAAG;EACpB,KAAK,IAAI,IAAI;EACb,IAAI,KAAK,IAAI;CACf;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,qBACd,QACA,OAAqC,CAAC,GACP;CAC/B,OAAO,iBAAiB,MAAM,CAAC,CAAC,KAC7B,OACC,eAAe,OAAO,IAAI,IAAI,KAC9B,WAAW,8BAA8B,GAAG,gBAAgB,CAChE;AACF;;;;;;;;;AAUA,SAAgB,kBAAkB,QAAoD;CAEpF,OADmB,eAAe,MAClB,CAAC,EAAE,wBAAwB,KAAK,CAAC;AACnD;;;;;;;;AASA,SAAgB,sBACd,QACkD;CAElD,OADmB,eAAe,MAClB,CAAC,EAAE,yBAAyB,KAAK,CAAC;AACpD;;;;;;;;;;;;;;;AAgBA,SAAgB,cACd,QACA,OAAqC,CAAC,GAC7B;CACT,KAAK,MAAM,MAAM,OAAO,iBAAiB,GAAG;EAC1C,MAAM,OAAO,eAAe,OAAO,IAAI,IAAI;EAC3C,IAAI,SAAS,KAAA,GAAW,OAAO;EAC/B,IAAI,KAAK,cAAc,MAAM,WAAW,OAAO;EAC/C,IAAI,CAAC,kBAAkB,KAAK,QAAQ,CAAC,GAAG,OAAO;CACjD;CACA,OAAO;AACT;AAEA,SAAS,kBAAkB,MAA2B;CACpD,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO;CAChC,IAAI,gBAAgB,kBAAkB,OAAO,KAAK,QAAQ;CAC1D,IAAI,WAAW,IAAI,GAAG;EACpB,IAAI,KAAK;EACT,cAAc,OAAO,SAAS;GAC5B,OAAO,KAAK,QAAQ;EACtB,CAAC;EACD,OAAO;CACT;CACA,OAAO;AACT;;;;;;;;;;AAWA,SAAS,eAAe,QAA0D;CAChF,IAAI,UAAwB;CAC5B,OAAO,MAAM;EACX,IAAI,mBAAmB,wBAAwB,OAAO;EACtD,IAAI,mBAAmB,0BAA0B,mBAAmB,sBAAsB;GACxF,UAAU,QAAQ,SAAS;GAC3B;EACF;EACA;CACF;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,oBAAoB,QAA+B;CACjE,OAAO,OAAO,iBAAiB,CAAC,CAAC,WAAW;AAC9C;;;;;;AAOA,MAAa,eAAe;;;;;;;;;;;;;;;;;AAkB5B,SAAgB,iBAAiB,QAAkD;CACjF,OAAO,kBAAkB,kBAAkB,kBAAkB;AAC/D;;;;;;;;;AAgBA,SAAgB,oBACd,QACA,eAAoC,CAAC,GACrB;CAEhB,MAAM,WADa,oBAAoB,MAAM,IAAI,SAAS,kBAAkB,MAAM,EAAA,CACvD,WAAW;CACtC,MAAM,SAAS,qBACb,QAAQ,KAAK,MAAM,EAAE,QAAQ,CAAC,GAC9B,YACF;CACA,OAAO,QAAQ,KAAK,GAAG,OAAO;EAAE,IAAI,EAAE;EAAI,OAAO,OAAO;CAAG,EAAE;AAC/D"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/columns/utils.ts"],"sourcesContent":["import {\n collectSpecQueryColumns,\n extractPObjectId,\n isDataInfo,\n visitDataInfo,\n type AxisQualification,\n type ColumnUniversalId,\n type PObjectId,\n} from \"@milaboratories/pl-model-common\";\nimport { throwError } from \"@milaboratories/helpers\";\nimport type { GlobalCfgRenderCtx } from \"../render/internal\";\nimport { TreeNodeAccessor } from \"../render\";\nimport { deriveDistinctLabels, type DeriveLabelsOptions } from \"../labels/derive_distinct_labels\";\nimport { DataColumnRecipe, DataColumnImpl, type ColumnData } from \"./data_column\";\nimport { ColumnDiscoveredRecipe } from \"./column_recipes/column_discovered_recipe\";\nimport { ColumnFilteredRecipe } from \"./column_recipes/column_filtered_recipe\";\nimport {\n ColumnOverriddenRecipe,\n DataColumnOverriddenRecipe,\n} from \"./column_recipes/column_overrided_recipe\";\nimport type { ColumnRecipe } from \"./column_recipes/types\";\nimport { ColumnsCollection, isColumnsCollection } from \"./columns_collection\";\nimport type { ColumnsSource } from \"./column_providers/types\";\nimport {\n describePeerLinks,\n findPeerLinks,\n getResultPoolDatasetAxes,\n peerLinkedLast,\n} from \"./peer_links\";\n\n/**\n * PObjectIds of every non-hit column referenced by `recipe.getQuery()`,\n * deduped in traversal order. The hit column is\n * `extractPObjectId(recipe.id)`; anything else in the query is a linker or\n * other engine-consumed column.\n *\n * Pure query walk — no registry access. Use {@link collectLinkerColumns} for\n * the resolved {@link DataColumnRecipe} variant.\n */\nexport function collectLinkerIds(recipe: ColumnRecipe): PObjectId[] {\n const hit = extractPObjectId(recipe.id);\n const seen = new Set<PObjectId>();\n const out: PObjectId[] = [];\n for (const id of collectSpecQueryColumns(recipe.getQuery())) {\n // Leaf ids in SpecQuery may be rich (e.g. ColumnDiscoveredId) — drop to\n // bare PObjectId before comparing/registering so we hand the ambient\n // ColumnRegistry physical ids it can resolve.\n const bare = extractPObjectId(id);\n if (bare === hit) continue;\n if (seen.has(bare)) continue;\n seen.add(bare);\n out.push(bare);\n }\n return out;\n}\n\n/**\n * {@link collectLinkerIds} resolved against the ambient context as\n * {@link DataColumnRecipe} leaves. Throws if any id fails to resolve —\n * matches the contract of the legacy `resolveLinkers` it replaces.\n */\nexport function collectLinkerColumns(\n recipe: ColumnRecipe,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): DataColumnRecipe<PObjectId>[] {\n return collectLinkerIds(recipe).map(\n (id) =>\n DataColumnImpl.fromId(id, opts) ??\n throwError(`materializeLinkers: linker ${id} not resolvable`),\n );\n}\n\n/** Peer link labels for a column, checked against the result pool's datasets. */\nexport function createPeerLinkFinder(): (recipe: ColumnRecipe) => string[] {\n const datasetAxes = getResultPoolDatasetAxes();\n return (recipe) =>\n findPeerLinks(\n collectLinkerColumns(recipe).map((l) => l.getSpec()),\n datasetAxes,\n );\n}\n\n/**\n * Hit-side axis qualifications for the recipe — the ones that should land on\n * the outer-join entry wrapping this column at the consumer boundary.\n *\n * Descends {@link ColumnOverriddenRecipe} / {@link ColumnFilteredRecipe} via\n * `getInner()` until it finds a {@link ColumnDiscoveredRecipe}; otherwise\n * returns `[]`. Pure recipe walk — no query-tree introspection.\n */\nexport function hitQualifications(recipe: ColumnRecipe): readonly AxisQualification[] {\n const discovered = findDiscovered(recipe);\n return discovered?.getColumnQualifications() ?? [];\n}\n\n/**\n * Per-primary-column axis qualifications for the recipe — applied to the\n * outer primary anchors on this recipe's group side. Keyed by the external\n * primary column id (NOT by columns inside this recipe's own query).\n *\n * Same walk strategy as {@link hitQualifications}.\n */\nexport function queriesQualifications(\n recipe: ColumnRecipe,\n): Readonly<Record<PObjectId, AxisQualification[]>> {\n const discovered = findDiscovered(recipe);\n return discovered?.getQueriesQualifications() ?? {};\n}\n\n/**\n * Whether the recipe's underlying data resources actually carry bytes —\n * strictly stronger than `getDataStatus() === \"present\"`, which only tells\n * that the `.data` field is wired onto the accessor.\n *\n * Walks every physical leaf the recipe depends on via\n * {@link ColumnRecipe.getReferencedIds} (resolves each id back to a\n * {@link DataColumnRecipe} through the ambient ctx) and ANDs `hasData()` across\n * all of them. Inline {@link PColumnValues} payloads count as present.\n *\n * Returns `false` if any leaf cannot be re-resolved in `opts.ctx` (treat as\n * \"not yet ready\") rather than throwing — this is a UI-facing predicate, not\n * a contract assertion.\n */\nexport function hasColumnData(\n recipe: ColumnRecipe,\n opts: { ctx?: GlobalCfgRenderCtx } = {},\n): boolean {\n for (const id of recipe.getReferencedIds()) {\n const leaf = DataColumnImpl.fromId(id, opts);\n if (leaf === undefined) return false;\n if (leaf.getDataStatus() !== \"present\") return false;\n if (!isLeafDataPresent(leaf.getData())) return false;\n }\n return true;\n}\n\nfunction isLeafDataPresent(data: ColumnData): boolean {\n if (data === undefined) return false;\n if (Array.isArray(data)) return true;\n if (data instanceof TreeNodeAccessor) return data.hasData();\n if (isDataInfo(data)) {\n let ok = true;\n visitDataInfo(data, (blob) => {\n ok &&= blob.hasData();\n });\n return ok;\n }\n return false;\n}\n\n/**\n * Walk wrapper layers (Overridden, Filtered) until a {@link\n * ColumnDiscoveredRecipe} is found. Returns `undefined` if the recipe chain\n * has no Discovered layer (bare leaves and Overridden-over-leaf cases).\n *\n * Invariant from the wrapper classes themselves: there is at most one\n * Discovered layer in any recipe chain — Discovered is constructed only via\n * its own factory and is never re-wrapped by Discovered.\n */\nfunction findDiscovered(recipe: ColumnRecipe): undefined | ColumnDiscoveredRecipe {\n let current: ColumnRecipe = recipe;\n while (true) {\n if (current instanceof ColumnDiscoveredRecipe) return current;\n if (current instanceof ColumnOverriddenRecipe || current instanceof ColumnFilteredRecipe) {\n current = current.getInner();\n continue;\n }\n return undefined;\n }\n}\n\n/**\n * Whether the recipe reads exactly one data column — its own — rather than\n * reaching through others.\n *\n * True for a bare leaf and for projections over one (spec overrides, axis\n * slicing): those add layers but no new columns. False when the recipe gets at\n * its data through further columns, which happens when discovery reached it via\n * a linker chain.\n *\n * **Why callers care.** A recipe over a single data column is co-indexed by its\n * own axes, so its spec is the whole truth about them. One that needs other\n * columns only lines up after they are joined in, and therefore drags axes into\n * the join that its own spec never mentions — which is why it cannot serve as a\n * primary column, and why `createPlDataTableV3` splits on this.\n *\n * The count comes from {@link ColumnRecipe.getReferencedIds}, which resolves\n * through the whole wrapper chain, so no class walk is involved and foreign\n * `ColumnRecipe` implementations are handled too.\n */\nexport function hasSingleDataColumn(recipe: ColumnRecipe): boolean {\n return recipe.getReferencedIds().length === 1;\n}\n\n/**\n * @deprecated Renamed to {@link hasSingleDataColumn} — \"leaf\" read as \"you can\n * get data out of it\", which is a different question (see\n * {@link hasReachableData}). Same semantics.\n */\nexport const isLeafColumn = hasSingleDataColumn;\n\n/**\n * Whether the column's data can be read here and now, consistent with its\n * spec — narrows to {@link DataColumnRecipe}, which exposes `getData()`.\n *\n * True for a bare leaf and for a spec-override over a bare leaf. False for an\n * axis-filtered recipe (its spec has dropped axes the underlying data still\n * carries, so the two no longer line up) and for anything reached through\n * other columns (nothing to read until the engine joins them). In both of\n * those cases the data exists only engine-side: pass `recipe.id` to\n * `createPFrame` / `createPTable` instead of trying to read it.\n *\n * The distinction is settled when the recipe is built, not here — recipes that\n * carry data are instances of a class that declares `getData`. So a `true`\n * result narrows to a value that really has the method, and there is no\n * throwing path behind the guard.\n */\nexport function hasReachableData(recipe: ColumnRecipe): recipe is DataColumnRecipe {\n return recipe instanceof DataColumnImpl || recipe instanceof DataColumnOverriddenRecipe;\n}\n\n/** Drop-down option built over a {@link ColumnsCollection} — universal-id valued. */\nexport type ColumnOption = {\n readonly id: ColumnUniversalId;\n readonly label: string;\n /** Set for columns reached through a peer link; the dropdown shows it beside a link icon. */\n readonly linkHint?: string;\n};\n\n/**\n * Enumerates every column already in `source` and renders distinct labels\n * from each recipe's spec. Filtering is the caller's job — pass a\n * {@link ColumnsCollection} that was already narrowed via `.filter(...)` /\n * `.discover(...)`, or hand over a raw {@link ColumnsSource} (provider,\n * accessor, column array, or `\"result_pool\"` / `\"current_block\"` shorthand)\n * to be wrapped on the fly.\n */\nexport function deriveColumnOptions(\n source: ColumnsCollection | ColumnsSource[],\n labelOptions: DeriveLabelsOptions = {},\n): ColumnOption[] {\n const collection = isColumnsCollection(source) ? source : ColumnsCollection(source);\n return deriveRecipeOptions(collection.getColumns(), labelOptions).map(\n ({ id, label, linkHint }) => ({ id, label, linkHint }),\n );\n}\n\n/**\n * {@link ColumnOption}s for `recipes`, each with its recipe. Peer-linked columns go last, the rest\n * keep their order.\n */\nexport function deriveRecipeOptions<R extends ColumnRecipe>(\n recipes: R[],\n labelOptions: DeriveLabelsOptions = {},\n): (ColumnOption & { readonly recipe: R })[] {\n const labels = deriveDistinctLabels(\n recipes.map((r) => r.getSpec()),\n labelOptions,\n );\n const findPeerLinks = createPeerLinkFinder();\n const options = recipes.map((recipe, i) => {\n const links = findPeerLinks(recipe);\n return {\n id: recipe.id,\n label: labels[i],\n linkHint: links.length > 0 ? describePeerLinks(links) : undefined,\n recipe,\n };\n });\n return peerLinkedLast(options, (o) => o.linkHint !== undefined);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,iBAAiB,QAAmC;CAClE,MAAM,MAAM,iBAAiB,OAAO,EAAE;CACtC,MAAM,uBAAO,IAAI,IAAe;CAChC,MAAM,MAAmB,CAAC;CAC1B,KAAK,MAAM,MAAM,wBAAwB,OAAO,SAAS,CAAC,GAAG;EAI3D,MAAM,OAAO,iBAAiB,EAAE;EAChC,IAAI,SAAS,KAAK;EAClB,IAAI,KAAK,IAAI,IAAI,GAAG;EACpB,KAAK,IAAI,IAAI;EACb,IAAI,KAAK,IAAI;CACf;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,qBACd,QACA,OAAqC,CAAC,GACP;CAC/B,OAAO,iBAAiB,MAAM,CAAC,CAAC,KAC7B,OACC,eAAe,OAAO,IAAI,IAAI,KAC9B,WAAW,8BAA8B,GAAG,gBAAgB,CAChE;AACF;;AAGA,SAAgB,uBAA2D;CACzE,MAAM,cAAc,yBAAyB;CAC7C,QAAQ,WACN,cACE,qBAAqB,MAAM,CAAC,CAAC,KAAK,MAAM,EAAE,QAAQ,CAAC,GACnD,WACF;AACJ;;;;;;;;;AAUA,SAAgB,kBAAkB,QAAoD;CAEpF,OADmB,eAAe,MAClB,CAAC,EAAE,wBAAwB,KAAK,CAAC;AACnD;;;;;;;;AASA,SAAgB,sBACd,QACkD;CAElD,OADmB,eAAe,MAClB,CAAC,EAAE,yBAAyB,KAAK,CAAC;AACpD;;;;;;;;;;;;;;;AAgBA,SAAgB,cACd,QACA,OAAqC,CAAC,GAC7B;CACT,KAAK,MAAM,MAAM,OAAO,iBAAiB,GAAG;EAC1C,MAAM,OAAO,eAAe,OAAO,IAAI,IAAI;EAC3C,IAAI,SAAS,KAAA,GAAW,OAAO;EAC/B,IAAI,KAAK,cAAc,MAAM,WAAW,OAAO;EAC/C,IAAI,CAAC,kBAAkB,KAAK,QAAQ,CAAC,GAAG,OAAO;CACjD;CACA,OAAO;AACT;AAEA,SAAS,kBAAkB,MAA2B;CACpD,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO;CAChC,IAAI,gBAAgB,kBAAkB,OAAO,KAAK,QAAQ;CAC1D,IAAI,WAAW,IAAI,GAAG;EACpB,IAAI,KAAK;EACT,cAAc,OAAO,SAAS;GAC5B,OAAO,KAAK,QAAQ;EACtB,CAAC;EACD,OAAO;CACT;CACA,OAAO;AACT;;;;;;;;;;AAWA,SAAS,eAAe,QAA0D;CAChF,IAAI,UAAwB;CAC5B,OAAO,MAAM;EACX,IAAI,mBAAmB,wBAAwB,OAAO;EACtD,IAAI,mBAAmB,0BAA0B,mBAAmB,sBAAsB;GACxF,UAAU,QAAQ,SAAS;GAC3B;EACF;EACA;CACF;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,oBAAoB,QAA+B;CACjE,OAAO,OAAO,iBAAiB,CAAC,CAAC,WAAW;AAC9C;;;;;;AAOA,MAAa,eAAe;;;;;;;;;;;;;;;;;AAkB5B,SAAgB,iBAAiB,QAAkD;CACjF,OAAO,kBAAkB,kBAAkB,kBAAkB;AAC/D;;;;;;;;;AAkBA,SAAgB,oBACd,QACA,eAAoC,CAAC,GACrB;CAEhB,OAAO,qBADY,oBAAoB,MAAM,IAAI,SAAS,kBAAkB,MAAM,EAAA,CAC5C,WAAW,GAAG,YAAY,CAAC,CAAC,KAC/D,EAAE,IAAI,OAAO,gBAAgB;EAAE;EAAI;EAAO;CAAS,EACtD;AACF;;;;;AAMA,SAAgB,oBACd,SACA,eAAoC,CAAC,GACM;CAC3C,MAAM,SAAS,qBACb,QAAQ,KAAK,MAAM,EAAE,QAAQ,CAAC,GAC9B,YACF;CACA,MAAM,gBAAgB,qBAAqB;CAU3C,OAAO,eATS,QAAQ,KAAK,QAAQ,MAAM;EACzC,MAAM,QAAQ,cAAc,MAAM;EAClC,OAAO;GACL,IAAI,OAAO;GACX,OAAO,OAAO;GACd,UAAU,MAAM,SAAS,IAAI,kBAAkB,KAAK,IAAI,KAAA;GACxD;EACF;CACF,CAC4B,IAAI,MAAM,EAAE,aAAa,KAAA,CAAS;AAChE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_peer_links = require("../../../columns/peer_links.cjs");
|
|
1
2
|
const require_utils = require("../../../columns/utils.cjs");
|
|
2
3
|
require("../../../columns/index.cjs");
|
|
3
4
|
const require_traverse = require("../../../filters/traverse.cjs");
|
|
@@ -18,8 +19,13 @@ function createPlDataTableV3(ctx, options) {
|
|
|
18
19
|
const { primary, secondary } = resolved;
|
|
19
20
|
if (primary.length === 0) return void 0;
|
|
20
21
|
const { direct, linked } = splitByTopology(secondary);
|
|
22
|
+
const labelable = [...primary, ...secondary].map(toLabelableColumn);
|
|
23
|
+
const linkHints = collectLinkHints(labelable);
|
|
21
24
|
const derivedLabels = require_utils$1.deriveAllLabels({
|
|
22
|
-
columns:
|
|
25
|
+
columns: labelable.filter((c) => !require_utils$1.isColumnHidden(c.spec)).map((c) => ({
|
|
26
|
+
...c,
|
|
27
|
+
marker: linkHints.get(c.id)
|
|
28
|
+
})),
|
|
23
29
|
deriveLabelsOptions: {
|
|
24
30
|
includeNativeLabel: true,
|
|
25
31
|
...options.labelsOptions
|
|
@@ -92,6 +98,7 @@ function createPlDataTableV3(ctx, options) {
|
|
|
92
98
|
],
|
|
93
99
|
primaryColumns: primary,
|
|
94
100
|
derivedLabels,
|
|
101
|
+
linkHints,
|
|
95
102
|
visibilityByColId,
|
|
96
103
|
orderByColId
|
|
97
104
|
});
|
|
@@ -133,6 +140,15 @@ function splitByTopology(columns) {
|
|
|
133
140
|
function collectLinkerSnapshots(linked) {
|
|
134
141
|
return (0, _milaboratories_pl_model_common.uniqueBy)(linked.flatMap((c) => require_utils.collectLinkerColumns(c)), (c) => c.id);
|
|
135
142
|
}
|
|
143
|
+
/** Link icon hover text per column, for columns reached through at least one peer link. */
|
|
144
|
+
function collectLinkHints(columns) {
|
|
145
|
+
if (!columns.some((c) => c.linkerPath?.length)) return /* @__PURE__ */ new Map();
|
|
146
|
+
const datasetAxes = require_peer_links.getResultPoolDatasetAxes();
|
|
147
|
+
return new Map(columns.flatMap((c) => {
|
|
148
|
+
const links = require_peer_links.findPeerLinks(c.linkerPath?.map((step) => step.linker.spec) ?? [], datasetAxes);
|
|
149
|
+
return links.length > 0 ? [[c.id, require_peer_links.describePeerLinks(links)]] : [];
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
136
152
|
function toLabelableColumn(col) {
|
|
137
153
|
return {
|
|
138
154
|
id: col.id,
|
|
@@ -153,7 +169,7 @@ function toLabelableColumn(col) {
|
|
|
153
169
|
* The UI overlays this onto the engine-emitted specs at render time.
|
|
154
170
|
*/
|
|
155
171
|
function buildColumnsMeta(params) {
|
|
156
|
-
const { fullColumns, visibleColumns, primaryColumns, derivedLabels } = params;
|
|
172
|
+
const { fullColumns, visibleColumns, primaryColumns, derivedLabels, linkHints } = params;
|
|
157
173
|
const { visibilityByColId, orderByColId } = params;
|
|
158
174
|
const visibleStatus = require_utils$1.buildDataStatusMap(visibleColumns);
|
|
159
175
|
const columns = fullColumns.reduce((acc, c) => {
|
|
@@ -162,7 +178,8 @@ function buildColumnsMeta(params) {
|
|
|
162
178
|
label: derivedLabels[c.id],
|
|
163
179
|
visibility: require_utils$1.getEffectiveVisibility(rc, visibilityByColId),
|
|
164
180
|
order: require_utils$1.getOrderPriority(rc, orderByColId),
|
|
165
|
-
status: visibleStatus[c.id]
|
|
181
|
+
status: visibleStatus[c.id],
|
|
182
|
+
linkHint: linkHints.get(c.id)
|
|
166
183
|
};
|
|
167
184
|
return acc;
|
|
168
185
|
}, {});
|