@platforma-sdk/model 1.88.16 → 1.90.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/columns_collection.cjs +18 -0
- package/dist/columns/columns_collection.cjs.map +1 -1
- package/dist/columns/columns_collection.d.ts +21 -1
- package/dist/columns/columns_collection.d.ts.map +1 -1
- package/dist/columns/columns_collection.js +18 -0
- package/dist/columns/columns_collection.js.map +1 -1
- package/dist/columns/index.d.ts +2 -2
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs +20 -5
- 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 +21 -6
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs +28 -23
- 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 +29 -23
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js.map +1 -1
- package/dist/components/PlDataTable/state-migration.cjs +25 -1
- package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
- package/dist/components/PlDataTable/state-migration.d.ts +31 -6
- package/dist/components/PlDataTable/state-migration.d.ts.map +1 -1
- package/dist/components/PlDataTable/state-migration.js +25 -1
- package/dist/components/PlDataTable/state-migration.js.map +1 -1
- package/dist/components/PlDataTable/tableParams.cjs +156 -0
- package/dist/components/PlDataTable/tableParams.cjs.map +1 -0
- package/dist/components/PlDataTable/tableParams.js +152 -0
- package/dist/components/PlDataTable/tableParams.js.map +1 -0
- package/dist/components/PlDataTable/typesV8.d.ts +12 -9
- package/dist/components/PlDataTable/typesV8.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/package.json +7 -7
- package/src/columns/__test_helpers__/collection_driver.ts +3 -0
- package/src/columns/columns_collection.test.ts +47 -0
- package/src/columns/columns_collection.ts +33 -0
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV2.ts +35 -6
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV3.ts +38 -23
- package/src/components/PlDataTable/state-migration.test.ts +26 -26
- package/src/components/PlDataTable/state-migration.ts +75 -11
- package/src/components/PlDataTable/tableParams.test.ts +291 -0
- package/src/components/PlDataTable/tableParams.ts +243 -0
- package/src/components/PlDataTable/typesV8.ts +18 -17
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV3.test.ts +0 -61
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const require_distill = require("../../filters/distill.cjs");
|
|
2
|
+
require("../../filters/index.cjs");
|
|
3
|
+
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
4
|
+
let es_toolkit = require("es-toolkit");
|
|
5
|
+
// src/components/PlDataTable/tableParams.ts
|
|
6
|
+
/** Read the user's settings for the source the stored state points at. */
|
|
7
|
+
function readPlDataTableUserParams(state) {
|
|
8
|
+
const sourceId = state.pTableParams.sourceId;
|
|
9
|
+
const entry = findEntry(state, sourceId);
|
|
10
|
+
if ((0, es_toolkit.isNil)(entry)) return {
|
|
11
|
+
sourceId,
|
|
12
|
+
sheetsState: [],
|
|
13
|
+
userFilters: null,
|
|
14
|
+
defaultFilters: null,
|
|
15
|
+
searchString: null,
|
|
16
|
+
sorting: null,
|
|
17
|
+
hiddenColIds: null
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
sourceId,
|
|
21
|
+
sheetsState: entry.sheetsState,
|
|
22
|
+
userFilters: (0, es_toolkit.isNil)(entry.filtersState) ? null : require_distill.distillFilterSpec(stripSuppressedFilters(entry.filtersState)),
|
|
23
|
+
defaultFilters: (0, es_toolkit.isNil)(entry.defaultFiltersState) ? null : require_distill.distillFilterSpec(stripSuppressedFilters(entry.defaultFiltersState)) ?? emptyGroup(),
|
|
24
|
+
searchString: entry.searchString?.trim() || null,
|
|
25
|
+
sorting: entry.sorting,
|
|
26
|
+
hiddenColIds: entry.hiddenColIds
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** One filter per sheet, selecting the value picked on it. */
|
|
30
|
+
function createSheetFilters(sheetsState) {
|
|
31
|
+
return sheetsState.map((sheet) => {
|
|
32
|
+
const column = {
|
|
33
|
+
type: "axis",
|
|
34
|
+
id: sheet.axisId
|
|
35
|
+
};
|
|
36
|
+
return typeof sheet.value === "number" ? {
|
|
37
|
+
type: "equal",
|
|
38
|
+
column,
|
|
39
|
+
x: sheet.value
|
|
40
|
+
} : {
|
|
41
|
+
type: "patternEquals",
|
|
42
|
+
column,
|
|
43
|
+
value: sheet.value
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The columns the fast search looks into: the visible ones, and the visible axes
|
|
49
|
+
* except those a sheet fixes to a single value, where every row would match, and
|
|
50
|
+
* those the table shows through their label column, whose raw values are never
|
|
51
|
+
* on screen. Hidden are columns the block's rules hide, linker columns, and the
|
|
52
|
+
* columns in the user's hidden list, or, while the user has not touched it, the
|
|
53
|
+
* optional ones.
|
|
54
|
+
*/
|
|
55
|
+
function collectSearchColumns(params) {
|
|
56
|
+
const { columns, isAxisHidden, sheetAxes, hiddenColIds } = params;
|
|
57
|
+
const sheetAxisKeys = new Set(sheetAxes.map(axisKey));
|
|
58
|
+
const labeledAxes = columns.filter((c) => (0, _milaboratories_pl_model_common.isLabelColumn)(c.spec)).flatMap((c) => c.spec.axesSpec.map(_milaboratories_pl_model_common.getAxisId));
|
|
59
|
+
const shownAxes = uniqueAxes(columns.flatMap((c) => c.spec.axesSpec)).filter((axis) => {
|
|
60
|
+
const id = (0, _milaboratories_pl_model_common.getAxisId)(axis);
|
|
61
|
+
return !sheetAxisKeys.has(axisKey(id)) && !isAxisHidden(axis) && !labeledAxes.some((labeled) => (0, _milaboratories_pl_model_common.matchAxisId)(labeled, id));
|
|
62
|
+
});
|
|
63
|
+
const shownColumns = columns.filter((c) => c.visibility !== "hidden" && !(0, _milaboratories_pl_model_common.isLinkerColumn)(c.spec));
|
|
64
|
+
const hidden = new Set((hiddenColIds ?? shownColumns.filter((c) => c.visibility === "optional").map((c) => ({
|
|
65
|
+
type: "column",
|
|
66
|
+
id: c.id
|
|
67
|
+
}))).map((id) => (0, _milaboratories_pl_model_common.canonicalizeJson)(id)));
|
|
68
|
+
return [...shownAxes.map((axis) => ({
|
|
69
|
+
id: {
|
|
70
|
+
type: "axis",
|
|
71
|
+
id: (0, _milaboratories_pl_model_common.getAxisId)(axis)
|
|
72
|
+
},
|
|
73
|
+
valueType: axis.type
|
|
74
|
+
})), ...shownColumns.map((c) => ({
|
|
75
|
+
id: {
|
|
76
|
+
type: "column",
|
|
77
|
+
id: c.id
|
|
78
|
+
},
|
|
79
|
+
valueType: c.spec.valueType
|
|
80
|
+
}))].filter((c) => !hidden.has((0, _milaboratories_pl_model_common.canonicalizeJson)(c.id)));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The fast search as a filter: a row matches when any searched column holds the
|
|
84
|
+
* text exactly, or, for a number, holds that number.
|
|
85
|
+
*/
|
|
86
|
+
function createSearchFilter(searchString, columns) {
|
|
87
|
+
if ((0, es_toolkit.isNil)(searchString)) return null;
|
|
88
|
+
const number = Number(searchString);
|
|
89
|
+
const isNumber = searchString.length > 0 && Number.isFinite(number);
|
|
90
|
+
const parts = columns.flatMap((c) => {
|
|
91
|
+
if (c.valueType === _milaboratories_pl_model_common.ValueType.String) return [{
|
|
92
|
+
type: "patternEquals",
|
|
93
|
+
column: c.id,
|
|
94
|
+
value: searchString
|
|
95
|
+
}];
|
|
96
|
+
if (isNumericValueType(c.valueType) && isNumber) return [{
|
|
97
|
+
type: "equal",
|
|
98
|
+
column: c.id,
|
|
99
|
+
x: number
|
|
100
|
+
}];
|
|
101
|
+
return [];
|
|
102
|
+
});
|
|
103
|
+
return parts.length === 0 ? null : {
|
|
104
|
+
type: "or",
|
|
105
|
+
filters: parts
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** AND of the given filter trees, `null` when none is left. */
|
|
109
|
+
function joinFilters(filters) {
|
|
110
|
+
const operands = filters.flatMap((f) => {
|
|
111
|
+
if ((0, es_toolkit.isNil)(f)) return [];
|
|
112
|
+
return f.type === "and" ? f.filters : [f];
|
|
113
|
+
});
|
|
114
|
+
return operands.length === 0 ? null : {
|
|
115
|
+
type: "and",
|
|
116
|
+
filters: operands
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function findEntry(state, sourceId) {
|
|
120
|
+
if ((0, es_toolkit.isNil)(sourceId)) return void 0;
|
|
121
|
+
return state.stateCache.find((entry) => entry.sourceId === sourceId);
|
|
122
|
+
}
|
|
123
|
+
function stripSuppressedFilters(node) {
|
|
124
|
+
return {
|
|
125
|
+
...node,
|
|
126
|
+
filters: node.filters.filter((child) => !("isSuppressed" in child && child.isSuppressed === true)).map((child) => (child.type === "and" || child.type === "or") && "filters" in child ? stripSuppressedFilters(child) : child)
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function emptyGroup() {
|
|
130
|
+
return {
|
|
131
|
+
type: "and",
|
|
132
|
+
filters: []
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function isNumericValueType(valueType) {
|
|
136
|
+
return valueType === _milaboratories_pl_model_common.ValueType.Int || valueType === _milaboratories_pl_model_common.ValueType.Long || valueType === _milaboratories_pl_model_common.ValueType.Float || valueType === _milaboratories_pl_model_common.ValueType.Double;
|
|
137
|
+
}
|
|
138
|
+
function axisKey(axisId) {
|
|
139
|
+
return (0, _milaboratories_pl_model_common.canonicalizeJson)(axisId);
|
|
140
|
+
}
|
|
141
|
+
function uniqueAxes(axes) {
|
|
142
|
+
const seen = /* @__PURE__ */ new Set();
|
|
143
|
+
return axes.filter((axis) => {
|
|
144
|
+
const key = axisKey((0, _milaboratories_pl_model_common.getAxisId)(axis));
|
|
145
|
+
if (seen.has(key)) return false;
|
|
146
|
+
seen.add(key);
|
|
147
|
+
return true;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
exports.collectSearchColumns = collectSearchColumns;
|
|
151
|
+
exports.createSearchFilter = createSearchFilter;
|
|
152
|
+
exports.createSheetFilters = createSheetFilters;
|
|
153
|
+
exports.joinFilters = joinFilters;
|
|
154
|
+
exports.readPlDataTableUserParams = readPlDataTableUserParams;
|
|
155
|
+
|
|
156
|
+
//# sourceMappingURL=tableParams.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableParams.cjs","names":["isNil","distillFilterSpec","isLabelColumn","getAxisId","matchAxisId","isLinkerColumn","canonicalizeJson","ValueType"],"sources":["../../../src/components/PlDataTable/tableParams.ts"],"sourcesContent":["import type {\n AxisId,\n AxisSpec,\n CanonicalizedJson,\n ColumnUniversalId,\n FilterSpecNode,\n PColumnSpec,\n PTableColumnId,\n PTableSorting,\n} from \"@milaboratories/pl-model-common\";\nimport {\n canonicalizeJson,\n getAxisId,\n isLabelColumn,\n isLinkerColumn,\n matchAxisId,\n ValueType,\n} from \"@milaboratories/pl-model-common\";\nimport { isNil } from \"es-toolkit\";\nimport { distillFilterSpec } from \"../../filters\";\nimport type {\n PlDataTableFilters,\n PlDataTableFiltersWithMeta,\n PlDataTableFilterSpecLeaf,\n PlDataTableSheetState,\n PlDataTableStateV2CacheEntry,\n PlDataTableStateV2Normalized,\n} from \"./typesV8\";\n\n/** What the user set up for the table of the source the UI shows. */\nexport type PlDataTableUserParams = {\n /** Source the UI shows; `null` until the UI has shown one. */\n sourceId: null | string;\n /** The value picked on each sheet. */\n sheetsState: PlDataTableSheetState[];\n /** The user's own filters without the suppressed ones; `null` when there are none. */\n userFilters: null | PlDataTableFilters;\n /**\n * The user's edit of the default filters: `null` while untouched, so the block's\n * defaults apply, and an empty group once every default is suppressed.\n */\n defaultFilters: null | PlDataTableFilters;\n /** Fast-search text, trimmed; `null` when empty. */\n searchString: null | string;\n /** `null` while untouched, so the block's default sorting applies; `[]` once cleared. */\n sorting: null | PTableSorting[];\n /** Columns the user hid; `null` while untouched, so optional columns stay hidden. */\n hiddenColIds: null | PTableColumnId[];\n};\n\n/** A column the fast search looks into. */\nexport type PlDataTableSearchColumn = {\n id: PTableColumnId;\n valueType: ValueType;\n};\n\n/** A column of the table as the fast search sees it. */\nexport type PlDataTableSearchCandidate = {\n id: ColumnUniversalId;\n spec: PColumnSpec;\n visibility: \"default\" | \"optional\" | \"hidden\";\n};\n\n/** Read the user's settings for the source the stored state points at. */\nexport function readPlDataTableUserParams(\n state: PlDataTableStateV2Normalized,\n): PlDataTableUserParams {\n const sourceId = state.pTableParams.sourceId;\n const entry = findEntry(state, sourceId);\n if (isNil(entry)) {\n return {\n sourceId,\n sheetsState: [],\n userFilters: null,\n defaultFilters: null,\n searchString: null,\n sorting: null,\n hiddenColIds: null,\n };\n }\n\n return {\n sourceId,\n sheetsState: entry.sheetsState,\n userFilters: isNil(entry.filtersState)\n ? null\n : distillFilterSpec(stripSuppressedFilters(entry.filtersState)),\n defaultFilters: isNil(entry.defaultFiltersState)\n ? null\n : (distillFilterSpec(stripSuppressedFilters(entry.defaultFiltersState)) ?? emptyGroup()),\n searchString: entry.searchString?.trim() || null,\n sorting: entry.sorting,\n hiddenColIds: entry.hiddenColIds,\n };\n}\n\n/** One filter per sheet, selecting the value picked on it. */\nexport function createSheetFilters(sheetsState: PlDataTableSheetState[]): PlDataTableFilterNode[] {\n return sheetsState.map((sheet) => {\n const column: PTableColumnId = { type: \"axis\", id: sheet.axisId };\n return typeof sheet.value === \"number\"\n ? { type: \"equal\", column, x: sheet.value }\n : { type: \"patternEquals\", column, value: sheet.value };\n });\n}\n\n/**\n * The columns the fast search looks into: the visible ones, and the visible axes\n * except those a sheet fixes to a single value, where every row would match, and\n * those the table shows through their label column, whose raw values are never\n * on screen. Hidden are columns the block's rules hide, linker columns, and the\n * columns in the user's hidden list, or, while the user has not touched it, the\n * optional ones.\n */\nexport function collectSearchColumns(params: {\n columns: PlDataTableSearchCandidate[];\n isAxisHidden: (axis: AxisSpec) => boolean;\n sheetAxes: AxisId[];\n hiddenColIds: null | PTableColumnId[];\n}): PlDataTableSearchColumn[] {\n const { columns, isAxisHidden, sheetAxes, hiddenColIds } = params;\n const sheetAxisKeys = new Set(sheetAxes.map(axisKey));\n const labeledAxes = columns\n .filter((c) => isLabelColumn(c.spec))\n .flatMap((c) => c.spec.axesSpec.map(getAxisId));\n const shownAxes = uniqueAxes(columns.flatMap((c) => c.spec.axesSpec)).filter((axis) => {\n const id = getAxisId(axis);\n return (\n !sheetAxisKeys.has(axisKey(id)) &&\n !isAxisHidden(axis) &&\n !labeledAxes.some((labeled) => matchAxisId(labeled, id))\n );\n });\n const shownColumns = columns.filter((c) => c.visibility !== \"hidden\" && !isLinkerColumn(c.spec));\n\n const hidden = new Set(\n (\n hiddenColIds ??\n shownColumns\n .filter((c) => c.visibility === \"optional\")\n .map((c): PTableColumnId => ({ type: \"column\", id: c.id }))\n ).map((id) => canonicalizeJson<PTableColumnId>(id)),\n );\n\n return [\n ...shownAxes.map((axis): PlDataTableSearchColumn => ({\n id: { type: \"axis\", id: getAxisId(axis) },\n valueType: axis.type,\n })),\n ...shownColumns.map((c): PlDataTableSearchColumn => ({\n id: { type: \"column\", id: c.id },\n valueType: c.spec.valueType,\n })),\n ].filter((c) => !hidden.has(canonicalizeJson<PTableColumnId>(c.id)));\n}\n\n/**\n * The fast search as a filter: a row matches when any searched column holds the\n * text exactly, or, for a number, holds that number.\n */\nexport function createSearchFilter(\n searchString: null | string,\n columns: PlDataTableSearchColumn[],\n): null | PlDataTableFilters {\n if (isNil(searchString)) return null;\n const number = Number(searchString);\n const isNumber = searchString.length > 0 && Number.isFinite(number);\n\n const parts = columns.flatMap((c): PlDataTableFilterNode[] => {\n if (c.valueType === ValueType.String) {\n return [{ type: \"patternEquals\", column: c.id, value: searchString }];\n }\n if (isNumericValueType(c.valueType) && isNumber) {\n return [{ type: \"equal\", column: c.id, x: number }];\n }\n return [];\n });\n\n return parts.length === 0 ? null : { type: \"or\", filters: parts };\n}\n\n/** AND of the given filter trees, `null` when none is left. */\nexport function joinFilters(\n filters: (null | undefined | PlDataTableFilterNode)[],\n): null | PlDataTableFilters {\n const operands = filters.flatMap((f): PlDataTableFilterNode[] => {\n if (isNil(f)) return [];\n return f.type === \"and\" ? f.filters : [f];\n });\n return operands.length === 0 ? null : { type: \"and\", filters: operands };\n}\n\nexport type PlDataTableFilterNode = FilterSpecNode<PlDataTableFilterSpecLeaf>;\n\n// Internals\n\nfunction findEntry(\n state: PlDataTableStateV2Normalized,\n sourceId: null | string,\n): undefined | PlDataTableStateV2CacheEntry {\n if (isNil(sourceId)) return undefined;\n return state.stateCache.find((entry) => entry.sourceId === sourceId);\n}\n\nfunction stripSuppressedFilters(node: PlDataTableFiltersWithMeta): PlDataTableFiltersWithMeta {\n return {\n ...node,\n filters: node.filters\n .filter((child) => !(\"isSuppressed\" in child && child.isSuppressed === true))\n .map((child) =>\n (child.type === \"and\" || child.type === \"or\") && \"filters\" in child\n ? stripSuppressedFilters(child)\n : child,\n ),\n };\n}\n\nfunction emptyGroup(): PlDataTableFilters {\n return { type: \"and\", filters: [] };\n}\n\nfunction isNumericValueType(valueType: ValueType): boolean {\n return (\n valueType === ValueType.Int ||\n valueType === ValueType.Long ||\n valueType === ValueType.Float ||\n valueType === ValueType.Double\n );\n}\n\nfunction axisKey(axisId: AxisId): CanonicalizedJson<AxisId> {\n return canonicalizeJson<AxisId>(axisId);\n}\n\nfunction uniqueAxes(axes: AxisSpec[]): AxisSpec[] {\n const seen = new Set<CanonicalizedJson<AxisId>>();\n return axes.filter((axis) => {\n const key = axisKey(getAxisId(axis));\n if (seen.has(key)) return false;\n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BAAAA,CAAyB,MAAM;AACxC;AAEA,SAAS,WAAW,MAA8B;CAChD,MAAM,uBAAO,IAAI,IAA+B;CAChD,OAAO,KAAK,QAAQ,SAAS;EAC3B,MAAM,MAAM,SAAA,GAAQH,gCAAAA,UAAAA,CAAU,IAAI,CAAC;EACnC,IAAI,KAAK,IAAI,GAAG,GAAG,OAAO;EAC1B,KAAK,IAAI,GAAG;EACZ,OAAO;CACT,CAAC;AACH"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { distillFilterSpec } from "../../filters/distill.js";
|
|
2
|
+
import "../../filters/index.js";
|
|
3
|
+
import { ValueType, canonicalizeJson, getAxisId, isLabelColumn, isLinkerColumn, matchAxisId } from "@milaboratories/pl-model-common";
|
|
4
|
+
import { isNil } from "es-toolkit";
|
|
5
|
+
// src/components/PlDataTable/tableParams.ts
|
|
6
|
+
/** Read the user's settings for the source the stored state points at. */
|
|
7
|
+
function readPlDataTableUserParams(state) {
|
|
8
|
+
const sourceId = state.pTableParams.sourceId;
|
|
9
|
+
const entry = findEntry(state, sourceId);
|
|
10
|
+
if (isNil(entry)) return {
|
|
11
|
+
sourceId,
|
|
12
|
+
sheetsState: [],
|
|
13
|
+
userFilters: null,
|
|
14
|
+
defaultFilters: null,
|
|
15
|
+
searchString: null,
|
|
16
|
+
sorting: null,
|
|
17
|
+
hiddenColIds: null
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
sourceId,
|
|
21
|
+
sheetsState: entry.sheetsState,
|
|
22
|
+
userFilters: isNil(entry.filtersState) ? null : distillFilterSpec(stripSuppressedFilters(entry.filtersState)),
|
|
23
|
+
defaultFilters: isNil(entry.defaultFiltersState) ? null : distillFilterSpec(stripSuppressedFilters(entry.defaultFiltersState)) ?? emptyGroup(),
|
|
24
|
+
searchString: entry.searchString?.trim() || null,
|
|
25
|
+
sorting: entry.sorting,
|
|
26
|
+
hiddenColIds: entry.hiddenColIds
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** One filter per sheet, selecting the value picked on it. */
|
|
30
|
+
function createSheetFilters(sheetsState) {
|
|
31
|
+
return sheetsState.map((sheet) => {
|
|
32
|
+
const column = {
|
|
33
|
+
type: "axis",
|
|
34
|
+
id: sheet.axisId
|
|
35
|
+
};
|
|
36
|
+
return typeof sheet.value === "number" ? {
|
|
37
|
+
type: "equal",
|
|
38
|
+
column,
|
|
39
|
+
x: sheet.value
|
|
40
|
+
} : {
|
|
41
|
+
type: "patternEquals",
|
|
42
|
+
column,
|
|
43
|
+
value: sheet.value
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The columns the fast search looks into: the visible ones, and the visible axes
|
|
49
|
+
* except those a sheet fixes to a single value, where every row would match, and
|
|
50
|
+
* those the table shows through their label column, whose raw values are never
|
|
51
|
+
* on screen. Hidden are columns the block's rules hide, linker columns, and the
|
|
52
|
+
* columns in the user's hidden list, or, while the user has not touched it, the
|
|
53
|
+
* optional ones.
|
|
54
|
+
*/
|
|
55
|
+
function collectSearchColumns(params) {
|
|
56
|
+
const { columns, isAxisHidden, sheetAxes, hiddenColIds } = params;
|
|
57
|
+
const sheetAxisKeys = new Set(sheetAxes.map(axisKey));
|
|
58
|
+
const labeledAxes = columns.filter((c) => isLabelColumn(c.spec)).flatMap((c) => c.spec.axesSpec.map(getAxisId));
|
|
59
|
+
const shownAxes = uniqueAxes(columns.flatMap((c) => c.spec.axesSpec)).filter((axis) => {
|
|
60
|
+
const id = getAxisId(axis);
|
|
61
|
+
return !sheetAxisKeys.has(axisKey(id)) && !isAxisHidden(axis) && !labeledAxes.some((labeled) => matchAxisId(labeled, id));
|
|
62
|
+
});
|
|
63
|
+
const shownColumns = columns.filter((c) => c.visibility !== "hidden" && !isLinkerColumn(c.spec));
|
|
64
|
+
const hidden = new Set((hiddenColIds ?? shownColumns.filter((c) => c.visibility === "optional").map((c) => ({
|
|
65
|
+
type: "column",
|
|
66
|
+
id: c.id
|
|
67
|
+
}))).map((id) => canonicalizeJson(id)));
|
|
68
|
+
return [...shownAxes.map((axis) => ({
|
|
69
|
+
id: {
|
|
70
|
+
type: "axis",
|
|
71
|
+
id: getAxisId(axis)
|
|
72
|
+
},
|
|
73
|
+
valueType: axis.type
|
|
74
|
+
})), ...shownColumns.map((c) => ({
|
|
75
|
+
id: {
|
|
76
|
+
type: "column",
|
|
77
|
+
id: c.id
|
|
78
|
+
},
|
|
79
|
+
valueType: c.spec.valueType
|
|
80
|
+
}))].filter((c) => !hidden.has(canonicalizeJson(c.id)));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The fast search as a filter: a row matches when any searched column holds the
|
|
84
|
+
* text exactly, or, for a number, holds that number.
|
|
85
|
+
*/
|
|
86
|
+
function createSearchFilter(searchString, columns) {
|
|
87
|
+
if (isNil(searchString)) return null;
|
|
88
|
+
const number = Number(searchString);
|
|
89
|
+
const isNumber = searchString.length > 0 && Number.isFinite(number);
|
|
90
|
+
const parts = columns.flatMap((c) => {
|
|
91
|
+
if (c.valueType === ValueType.String) return [{
|
|
92
|
+
type: "patternEquals",
|
|
93
|
+
column: c.id,
|
|
94
|
+
value: searchString
|
|
95
|
+
}];
|
|
96
|
+
if (isNumericValueType(c.valueType) && isNumber) return [{
|
|
97
|
+
type: "equal",
|
|
98
|
+
column: c.id,
|
|
99
|
+
x: number
|
|
100
|
+
}];
|
|
101
|
+
return [];
|
|
102
|
+
});
|
|
103
|
+
return parts.length === 0 ? null : {
|
|
104
|
+
type: "or",
|
|
105
|
+
filters: parts
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** AND of the given filter trees, `null` when none is left. */
|
|
109
|
+
function joinFilters(filters) {
|
|
110
|
+
const operands = filters.flatMap((f) => {
|
|
111
|
+
if (isNil(f)) return [];
|
|
112
|
+
return f.type === "and" ? f.filters : [f];
|
|
113
|
+
});
|
|
114
|
+
return operands.length === 0 ? null : {
|
|
115
|
+
type: "and",
|
|
116
|
+
filters: operands
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function findEntry(state, sourceId) {
|
|
120
|
+
if (isNil(sourceId)) return void 0;
|
|
121
|
+
return state.stateCache.find((entry) => entry.sourceId === sourceId);
|
|
122
|
+
}
|
|
123
|
+
function stripSuppressedFilters(node) {
|
|
124
|
+
return {
|
|
125
|
+
...node,
|
|
126
|
+
filters: node.filters.filter((child) => !("isSuppressed" in child && child.isSuppressed === true)).map((child) => (child.type === "and" || child.type === "or") && "filters" in child ? stripSuppressedFilters(child) : child)
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function emptyGroup() {
|
|
130
|
+
return {
|
|
131
|
+
type: "and",
|
|
132
|
+
filters: []
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function isNumericValueType(valueType) {
|
|
136
|
+
return valueType === ValueType.Int || valueType === ValueType.Long || valueType === ValueType.Float || valueType === ValueType.Double;
|
|
137
|
+
}
|
|
138
|
+
function axisKey(axisId) {
|
|
139
|
+
return canonicalizeJson(axisId);
|
|
140
|
+
}
|
|
141
|
+
function uniqueAxes(axes) {
|
|
142
|
+
const seen = /* @__PURE__ */ new Set();
|
|
143
|
+
return axes.filter((axis) => {
|
|
144
|
+
const key = axisKey(getAxisId(axis));
|
|
145
|
+
if (seen.has(key)) return false;
|
|
146
|
+
seen.add(key);
|
|
147
|
+
return true;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
export { collectSearchColumns, createSearchFilter, createSheetFilters, joinFilters, readPlDataTableUserParams };
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=tableParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableParams.js","names":[],"sources":["../../../src/components/PlDataTable/tableParams.ts"],"sourcesContent":["import type {\n AxisId,\n AxisSpec,\n CanonicalizedJson,\n ColumnUniversalId,\n FilterSpecNode,\n PColumnSpec,\n PTableColumnId,\n PTableSorting,\n} from \"@milaboratories/pl-model-common\";\nimport {\n canonicalizeJson,\n getAxisId,\n isLabelColumn,\n isLinkerColumn,\n matchAxisId,\n ValueType,\n} from \"@milaboratories/pl-model-common\";\nimport { isNil } from \"es-toolkit\";\nimport { distillFilterSpec } from \"../../filters\";\nimport type {\n PlDataTableFilters,\n PlDataTableFiltersWithMeta,\n PlDataTableFilterSpecLeaf,\n PlDataTableSheetState,\n PlDataTableStateV2CacheEntry,\n PlDataTableStateV2Normalized,\n} from \"./typesV8\";\n\n/** What the user set up for the table of the source the UI shows. */\nexport type PlDataTableUserParams = {\n /** Source the UI shows; `null` until the UI has shown one. */\n sourceId: null | string;\n /** The value picked on each sheet. */\n sheetsState: PlDataTableSheetState[];\n /** The user's own filters without the suppressed ones; `null` when there are none. */\n userFilters: null | PlDataTableFilters;\n /**\n * The user's edit of the default filters: `null` while untouched, so the block's\n * defaults apply, and an empty group once every default is suppressed.\n */\n defaultFilters: null | PlDataTableFilters;\n /** Fast-search text, trimmed; `null` when empty. */\n searchString: null | string;\n /** `null` while untouched, so the block's default sorting applies; `[]` once cleared. */\n sorting: null | PTableSorting[];\n /** Columns the user hid; `null` while untouched, so optional columns stay hidden. */\n hiddenColIds: null | PTableColumnId[];\n};\n\n/** A column the fast search looks into. */\nexport type PlDataTableSearchColumn = {\n id: PTableColumnId;\n valueType: ValueType;\n};\n\n/** A column of the table as the fast search sees it. */\nexport type PlDataTableSearchCandidate = {\n id: ColumnUniversalId;\n spec: PColumnSpec;\n visibility: \"default\" | \"optional\" | \"hidden\";\n};\n\n/** Read the user's settings for the source the stored state points at. */\nexport function readPlDataTableUserParams(\n state: PlDataTableStateV2Normalized,\n): PlDataTableUserParams {\n const sourceId = state.pTableParams.sourceId;\n const entry = findEntry(state, sourceId);\n if (isNil(entry)) {\n return {\n sourceId,\n sheetsState: [],\n userFilters: null,\n defaultFilters: null,\n searchString: null,\n sorting: null,\n hiddenColIds: null,\n };\n }\n\n return {\n sourceId,\n sheetsState: entry.sheetsState,\n userFilters: isNil(entry.filtersState)\n ? null\n : distillFilterSpec(stripSuppressedFilters(entry.filtersState)),\n defaultFilters: isNil(entry.defaultFiltersState)\n ? null\n : (distillFilterSpec(stripSuppressedFilters(entry.defaultFiltersState)) ?? emptyGroup()),\n searchString: entry.searchString?.trim() || null,\n sorting: entry.sorting,\n hiddenColIds: entry.hiddenColIds,\n };\n}\n\n/** One filter per sheet, selecting the value picked on it. */\nexport function createSheetFilters(sheetsState: PlDataTableSheetState[]): PlDataTableFilterNode[] {\n return sheetsState.map((sheet) => {\n const column: PTableColumnId = { type: \"axis\", id: sheet.axisId };\n return typeof sheet.value === \"number\"\n ? { type: \"equal\", column, x: sheet.value }\n : { type: \"patternEquals\", column, value: sheet.value };\n });\n}\n\n/**\n * The columns the fast search looks into: the visible ones, and the visible axes\n * except those a sheet fixes to a single value, where every row would match, and\n * those the table shows through their label column, whose raw values are never\n * on screen. Hidden are columns the block's rules hide, linker columns, and the\n * columns in the user's hidden list, or, while the user has not touched it, the\n * optional ones.\n */\nexport function collectSearchColumns(params: {\n columns: PlDataTableSearchCandidate[];\n isAxisHidden: (axis: AxisSpec) => boolean;\n sheetAxes: AxisId[];\n hiddenColIds: null | PTableColumnId[];\n}): PlDataTableSearchColumn[] {\n const { columns, isAxisHidden, sheetAxes, hiddenColIds } = params;\n const sheetAxisKeys = new Set(sheetAxes.map(axisKey));\n const labeledAxes = columns\n .filter((c) => isLabelColumn(c.spec))\n .flatMap((c) => c.spec.axesSpec.map(getAxisId));\n const shownAxes = uniqueAxes(columns.flatMap((c) => c.spec.axesSpec)).filter((axis) => {\n const id = getAxisId(axis);\n return (\n !sheetAxisKeys.has(axisKey(id)) &&\n !isAxisHidden(axis) &&\n !labeledAxes.some((labeled) => matchAxisId(labeled, id))\n );\n });\n const shownColumns = columns.filter((c) => c.visibility !== \"hidden\" && !isLinkerColumn(c.spec));\n\n const hidden = new Set(\n (\n hiddenColIds ??\n shownColumns\n .filter((c) => c.visibility === \"optional\")\n .map((c): PTableColumnId => ({ type: \"column\", id: c.id }))\n ).map((id) => canonicalizeJson<PTableColumnId>(id)),\n );\n\n return [\n ...shownAxes.map((axis): PlDataTableSearchColumn => ({\n id: { type: \"axis\", id: getAxisId(axis) },\n valueType: axis.type,\n })),\n ...shownColumns.map((c): PlDataTableSearchColumn => ({\n id: { type: \"column\", id: c.id },\n valueType: c.spec.valueType,\n })),\n ].filter((c) => !hidden.has(canonicalizeJson<PTableColumnId>(c.id)));\n}\n\n/**\n * The fast search as a filter: a row matches when any searched column holds the\n * text exactly, or, for a number, holds that number.\n */\nexport function createSearchFilter(\n searchString: null | string,\n columns: PlDataTableSearchColumn[],\n): null | PlDataTableFilters {\n if (isNil(searchString)) return null;\n const number = Number(searchString);\n const isNumber = searchString.length > 0 && Number.isFinite(number);\n\n const parts = columns.flatMap((c): PlDataTableFilterNode[] => {\n if (c.valueType === ValueType.String) {\n return [{ type: \"patternEquals\", column: c.id, value: searchString }];\n }\n if (isNumericValueType(c.valueType) && isNumber) {\n return [{ type: \"equal\", column: c.id, x: number }];\n }\n return [];\n });\n\n return parts.length === 0 ? null : { type: \"or\", filters: parts };\n}\n\n/** AND of the given filter trees, `null` when none is left. */\nexport function joinFilters(\n filters: (null | undefined | PlDataTableFilterNode)[],\n): null | PlDataTableFilters {\n const operands = filters.flatMap((f): PlDataTableFilterNode[] => {\n if (isNil(f)) return [];\n return f.type === \"and\" ? f.filters : [f];\n });\n return operands.length === 0 ? null : { type: \"and\", filters: operands };\n}\n\nexport type PlDataTableFilterNode = FilterSpecNode<PlDataTableFilterSpecLeaf>;\n\n// Internals\n\nfunction findEntry(\n state: PlDataTableStateV2Normalized,\n sourceId: null | string,\n): undefined | PlDataTableStateV2CacheEntry {\n if (isNil(sourceId)) return undefined;\n return state.stateCache.find((entry) => entry.sourceId === sourceId);\n}\n\nfunction stripSuppressedFilters(node: PlDataTableFiltersWithMeta): PlDataTableFiltersWithMeta {\n return {\n ...node,\n filters: node.filters\n .filter((child) => !(\"isSuppressed\" in child && child.isSuppressed === true))\n .map((child) =>\n (child.type === \"and\" || child.type === \"or\") && \"filters\" in child\n ? stripSuppressedFilters(child)\n : child,\n ),\n };\n}\n\nfunction emptyGroup(): PlDataTableFilters {\n return { type: \"and\", filters: [] };\n}\n\nfunction isNumericValueType(valueType: ValueType): boolean {\n return (\n valueType === ValueType.Int ||\n valueType === ValueType.Long ||\n valueType === ValueType.Float ||\n valueType === ValueType.Double\n );\n}\n\nfunction axisKey(axisId: AxisId): CanonicalizedJson<AxisId> {\n return canonicalizeJson<AxisId>(axisId);\n}\n\nfunction uniqueAxes(axes: AxisSpec[]): AxisSpec[] {\n const seen = new Set<CanonicalizedJson<AxisId>>();\n return axes.filter((axis) => {\n const key = axisKey(getAxisId(axis));\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\n"],"mappings":";;;;;;AAgEA,SAAgB,0BACd,OACuB;CACvB,MAAM,WAAW,MAAM,aAAa;CACpC,MAAM,QAAQ,UAAU,OAAO,QAAQ;CACvC,IAAI,MAAM,KAAK,GACb,OAAO;EACL;EACA,aAAa,CAAC;EACd,aAAa;EACb,gBAAgB;EAChB,cAAc;EACd,SAAS;EACT,cAAc;CAChB;CAGF,OAAO;EACL;EACA,aAAa,MAAM;EACnB,aAAa,MAAM,MAAM,YAAY,IACjC,OACA,kBAAkB,uBAAuB,MAAM,YAAY,CAAC;EAChE,gBAAgB,MAAM,MAAM,mBAAmB,IAC3C,OACC,kBAAkB,uBAAuB,MAAM,mBAAmB,CAAC,KAAK,WAAW;EACxF,cAAc,MAAM,cAAc,KAAK,KAAK;EAC5C,SAAS,MAAM;EACf,cAAc,MAAM;CACtB;AACF;;AAGA,SAAgB,mBAAmB,aAA+D;CAChG,OAAO,YAAY,KAAK,UAAU;EAChC,MAAM,SAAyB;GAAE,MAAM;GAAQ,IAAI,MAAM;EAAO;EAChE,OAAO,OAAO,MAAM,UAAU,WAC1B;GAAE,MAAM;GAAS;GAAQ,GAAG,MAAM;EAAM,IACxC;GAAE,MAAM;GAAiB;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QACxB,cAAc,UAAU,SACxB,cAAc,UAAU;AAE5B;AAEA,SAAS,QAAQ,QAA2C;CAC1D,OAAO,iBAAyB,MAAM;AACxC;AAEA,SAAS,WAAW,MAA8B;CAChD,MAAM,uBAAO,IAAI,IAA+B;CAChD,OAAO,KAAK,QAAQ,SAAS;EAC3B,MAAM,MAAM,QAAQ,UAAU,IAAI,CAAC;EACnC,IAAI,KAAK,IAAI,GAAG,GAAG,OAAO;EAC1B,KAAK,IAAI,GAAG;EACZ,OAAO;CACT,CAAC;AACH"}
|
|
@@ -52,8 +52,12 @@ export type PlDataTableFiltersWithMeta = RootFilterSpec<PlDataTableFilterSpecLea
|
|
|
52
52
|
export type PlDataTableStateV2CacheEntry = {
|
|
53
53
|
/** DataSource identifier for state management */
|
|
54
54
|
sourceId: string;
|
|
55
|
-
/**
|
|
55
|
+
/** The grid's own state, kept to restore the grid; opaque to everything but the grid */
|
|
56
56
|
gridState: PlDataTableGridStateCore;
|
|
57
|
+
/** Sorting the user set; `null` while untouched, so the block's default applies, `[]` once cleared */
|
|
58
|
+
sorting: null | PTableSorting[];
|
|
59
|
+
/** Columns the user hid; `null` while untouched, so optional columns stay hidden */
|
|
60
|
+
hiddenColIds: null | PTableColumnId[];
|
|
57
61
|
/** Sheets state */
|
|
58
62
|
sheetsState: PlDataTableSheetState[];
|
|
59
63
|
/** User filters state (tree-based, compatible with PlAdvancedFilter) */
|
|
@@ -63,25 +67,24 @@ export type PlDataTableStateV2CacheEntry = {
|
|
|
63
67
|
/** Fast search string */
|
|
64
68
|
searchString?: string;
|
|
65
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Which source the UI shows. The model builds the table from that source's cache
|
|
72
|
+
* entry; the remaining fields stay `null`, so a block version built against an
|
|
73
|
+
* earlier SDK reads the state as untouched.
|
|
74
|
+
*/
|
|
66
75
|
export type PTableParamsV2 = {
|
|
67
|
-
sourceId: null;
|
|
76
|
+
sourceId: null | string;
|
|
68
77
|
hiddenColIds: null;
|
|
69
78
|
sorting: null;
|
|
70
79
|
filters: null;
|
|
71
80
|
defaultFilters: null;
|
|
72
|
-
} | {
|
|
73
|
-
sourceId: string;
|
|
74
|
-
hiddenColIds: null | PTableColumnId[];
|
|
75
|
-
sorting: null | PTableSorting[];
|
|
76
|
-
filters: null | PlDataTableFilters;
|
|
77
|
-
defaultFilters: null | PlDataTableFilters;
|
|
78
81
|
};
|
|
79
82
|
export type PlDataTableStateV2Normalized = {
|
|
80
83
|
/** Version for upgrades. v9 has the v8 shape; it marks column ids rewritten to the current form. */
|
|
81
84
|
version: 9;
|
|
82
85
|
/** Internal states, LRU cache for 5 sourceId-s */
|
|
83
86
|
stateCache: PlDataTableStateV2CacheEntry[];
|
|
84
|
-
/**
|
|
87
|
+
/** Which source the UI shows */
|
|
85
88
|
pTableParams: PTableParamsV2;
|
|
86
89
|
};
|
|
87
90
|
/** PlAgDataTable model */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesV8.d.ts","names":["FilterSpecLeaf"],"sources":["../../../src/components/PlDataTable/typesV8.ts"],"mappings":";;;;YAiBY,sBAAsB,kBAAkB;YAExC;;EAEV;;IAEE,eAAe;;;EAGjB;;IAEE;;MAEE,OAAO;;MAEP;;;;EAIJ;;IAEE,cAAc;;;YAIN;;EAEV,MAAM;;EAEN,SAAS;;EAET;;YAGU;;EAEV,QAAQ;;EAER;;;YAIU;EACV;EACA;EACA;EACA;;YAEU,4BAA4BA,iBAAe;YAC3C,qBAAqB,eAAe;YACpC,6BAA6B,eACvC,2BACA;YAGU;;EAEV;;EAEA,WAAW;;EAEX,aAAa;;EAEb,qBAAqB;;EAErB,4BAA4B;;EAE5B
|
|
1
|
+
{"version":3,"file":"typesV8.d.ts","names":["FilterSpecLeaf"],"sources":["../../../src/components/PlDataTable/typesV8.ts"],"mappings":";;;;YAiBY,sBAAsB,kBAAkB;YAExC;;EAEV;;IAEE,eAAe;;;EAGjB;;IAEE;;MAEE,OAAO;;MAEP;;;;EAIJ;;IAEE,cAAc;;;YAIN;;EAEV,MAAM;;EAEN,SAAS;;EAET;;YAGU;;EAEV,QAAQ;;EAER;;;YAIU;EACV;EACA;EACA;EACA;;YAEU,4BAA4BA,iBAAe;YAC3C,qBAAqB,eAAe;YACpC,6BAA6B,eACvC,2BACA;YAGU;;EAEV;;EAEA,WAAW;;EAEX,gBAAgB;;EAEhB,qBAAqB;;EAErB,aAAa;;EAEb,qBAAqB;;EAErB,4BAA4B;;EAE5B;;;;;;;YAQU;EACV;EACA;EACA;EACA;EACA;;YAGU;;EAEV;;EAEA,YAAY;;EAEZ,cAAc;;;YAIJ;;EAEV;;EAEA,kBAAkB;;EAElB,mBAAmB;;EAEnB,qBAAqB;;EAErB,iBAAiB,MAAM;;;;;;;;;EASvB,cAAc;;;YAIJ;;EAEV;;EAEA;;EAEA;;EAEA,SAAS;;EAET;;;YAIU;;EAEV;;;YAIU;;EAEV,SAAS,OAAO,mBAAmB;;EAEnC,MAAM,OAAO,kBAAkB,SAAS;;YAG9B;;EAEV,UAAU;;EAGV,UAAU;;;;;;EAOV,uBAAuB,MAAM;;;;;;;;;;;;EAa7B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ import { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvi
|
|
|
56
56
|
import { ColumnsSource } from "./columns/column_providers/types.js";
|
|
57
57
|
import { _ctxProvidersCache, getCtxProviders, isColumnProvider, toColumnProvider } from "./columns/column_providers/index.js";
|
|
58
58
|
import { SplitAxis, SplitByAxesOpts, splitByAxes } from "./columns/split_by_axes.js";
|
|
59
|
-
import { ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsSourceShorthand, isColumnsCollection } from "./columns/columns_collection.js";
|
|
59
|
+
import { ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, ColumnsSourceShorthand, DiscoveredRoot, isColumnsCollection } from "./columns/columns_collection.js";
|
|
60
60
|
import { deriveAxisValuesLabels } from "./columns/derive_axis_values_labels.js";
|
|
61
61
|
import { ColumnOption, collectLinkerColumns, collectLinkerIds, createPeerLinkFinder, deriveColumnOptions, deriveRecipeOptions, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, isLeafColumn, queriesQualifications } from "./columns/utils.js";
|
|
62
62
|
import { DatasetAxes, collectDatasetAxes, describePeerLinks, findPeerLinks, getResultPoolDatasetAxes, peerLinkedLast } from "./columns/peer_links.js";
|
|
@@ -88,4 +88,4 @@ import "./services/index.js";
|
|
|
88
88
|
import { getEnvironmentValue } from "./env_value.js";
|
|
89
89
|
export * from "@milaboratories/pl-model-common";
|
|
90
90
|
export * from "@milaboratories/pl-error-like";
|
|
91
|
-
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, type AccessorHandle, AndFilter, AnnotationFilter, AnnotationMode, AnnotationScript, AnnotationScript2, AnnotationScriptUi, AnnotationSpec, AnnotationSpecUi, AnnotationStep, AnnotationStepUi, AnyForm, ArrayColumnsProvider, type AxesVault, AxisLabelProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockApiV1, BlockApiV2, BlockConfig, BlockConfigV3, BlockConfigV4, BlockDefaultModelServices, BlockDefaultUiServices, BlockModelInfo, BlockModelV3, BlockRenderCtx, BlockServiceFlags, BlockStatePatch, type BlockStorage, BlockStorageFacade, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, type BlockStorageSchemaVersion, BuildDatasetOptions, CancelSubscription, Cfg, CfgAnd, CfgBlobContent, CfgBlobContentAsJson, CfgBlobContentAsString, CfgDownloadedBlobContent, CfgExtractArchiveAndGetURL, CfgFlatten, CfgGetFromCtx, CfgGetJsonField, CfgGetResourceField, CfgImmediate, CfgImportProgress, CfgIsEmpty, CfgIsolate, CfgLastLogs, CfgLogHandle, CfgMakeArray, CfgMakeObject, CfgMapArrayValues, CfgMapRecordValues, CfgMapResourceFields, CfgNot, CfgOnDemandBlobContent, CfgOr, CfgProgressLog, CfgProgressLogWithInfo, CfgResourceValueAsJson, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, type ColumnOrderRule, ColumnOverriddenRecipe, ColumnProvider, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, type ColumnVisibilityRule, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, type ColumnsDisplayOptions, ColumnsProvider, type ColumnsSelectorConfig, ColumnsSource, ColumnsSourceShorthand, CommonFieldTraverseOps, CommonTraversalOps, ConfigRenderLambda, ConfigRenderLambdaFlags, CurrentSdkInfo, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DataModel, DataModelBuilder, DatasetAxes, DatasetOption, DatasetSelection, DeriveHref, DeriveLabelsFormatters, DeriveLabelsOptions, Entry, ExpressionSpec, ExtractFunctionHandleReturn, type ExtractFutureRefType, FieldTraversalStep, FieldType, FilterMatchOptions, type FilterSpec, type FilterSpecLeaf, type FilterSpecNode, type FilterSpecOfType, type FilterSpecType, FilterSpecUi, FilterUi, FilterUiOfType, FilterUiType, FindFilterColumnsOptions, FormField, FutureRef, GetFieldStep, InferArgsType, InferBlockState, InferBlockStatePatch, InferDataType, InferFactoryData, InferFactoryModelServices, InferFactoryOutputs, InferFactoryParams, InferFactoryUiServices, InferHrefType, InferOutputsFromLambdas, InferOutputsType, InferPluginData, InferPluginHandle, InferPluginNames, InferPluginUiEntries, InferRenderFunctionReturn, InferUiState, IsNA, internal_d_exports as JsRenderInternal, type DeriveLabelsOptions as LabelDerivationOps, LinkerStep, Log10, MainAccessorName, type MigrateBlockStorageConfig, type MigrationFailure, type MigrationResult, type MigrationSuccess, type ModelServices, type MutateStoragePayload, NotFilter, NumericalComparisonFilter, OptionalPlResourceEntry, OrFilter, OutputError, PColumnCollection, type PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, PColumnKeyList, PColumnPredicate, PColumnResourceMapData, PColumnResourceMapEntry, PColumnUniversal, PColumnWithLabel, PFrameImpl, PTableKey, type PTableParamsV2, type ParamsInput, Patch, PatternFilter, PatternPredicate, PatternPredicateContainSubsequence, PatternPredicateEquals, type PlDataTableAxisMeta, type PlDataTableColumnMeta, type PlDataTableColumnsMeta, type PlDataTableFilterMeta, type PlDataTableFilterSpecLeaf, type PlDataTableFilters, type PlDataTableFiltersWithMeta, type PlDataTableGridStateCore, type PlDataTableModel, type PlDataTableSheet, type PlDataTableSheetState, type PlDataTableStateV2, type PlDataTableStateV2CacheEntry, type PlDataTableStateV2Normalized, PlMultiSequenceAlignmentColorSchemeOption, PlMultiSequenceAlignmentModel, PlMultiSequenceAlignmentSettings, PlMultiSequenceAlignmentWidget, PlResourceEntry, PlSelectionModel, type PlTableColumnIdJson, Platforma, PlatformaApiVersion, PlatformaExtended, PlatformaFactory, PlatformaSDKVersion, PlatformaV1, PlatformaV2, PlatformaV3, type PluginConfig, type PluginData, PluginDataModel, PluginDataModelBuilder, type PluginDataModelVersions, type PluginFactory, PluginFactoryLike, PluginHandle, PluginInstance, PluginModel, type PluginName, type PluginOutputs, type PluginParams, type PluginPublicOutputs, type PluginRecord, type PluginRegistry, PluginRenderCtx, PresentColumnValueOptionsModel, type PublicOutputFieldDef, QueryColumnId, QueryColumnIdAxis, QueryColumnIdColumn, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtx, RenderCtxBase, RenderFunction, ResolveModelServices, ResolveUiServices, ResourceTraversalOps, ResourceType, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, SdkInfo, ServiceProxy, SimplifiedPColumnSpec, SimplifiedUniversalPColumnEntry, SortedCumulativeSum, type Entry as SpecExtractorResult, type SpecQuery, SplitAxis, SplitByAxesOpts, StagingAccessorName, StdCtx, StdCtxArgsOnly, TooltipEntry, type Trace, type TraceEntry, TransformedColumn, TreeNodeAccessor, TypeField, TypeFieldRecord, TypeForm, TypeToLiteral, TypedConfig, TypedConfigOrConfigLambda, TypedConfigOrString, type UiServices, Unionize, UniversalColumnOption, UnwrapFutureRef, ValueRank, type VersionedData, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildRefMap, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, type createPlDataTableOptionsV3, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
|
|
91
|
+
export { AccessorColumnsProvider, AccessorColumnsProviderImpl, type AccessorHandle, AndFilter, AnnotationFilter, AnnotationMode, AnnotationScript, AnnotationScript2, AnnotationScriptUi, AnnotationSpec, AnnotationSpecUi, AnnotationStep, AnnotationStepUi, AnyForm, ArrayColumnsProvider, type AxesVault, AxisLabelProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockApiV1, BlockApiV2, BlockConfig, BlockConfigV3, BlockConfigV4, BlockDefaultModelServices, BlockDefaultUiServices, BlockModelInfo, BlockModelV3, BlockRenderCtx, BlockServiceFlags, BlockStatePatch, type BlockStorage, BlockStorageFacade, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, type BlockStorageSchemaVersion, BuildDatasetOptions, CancelSubscription, Cfg, CfgAnd, CfgBlobContent, CfgBlobContentAsJson, CfgBlobContentAsString, CfgDownloadedBlobContent, CfgExtractArchiveAndGetURL, CfgFlatten, CfgGetFromCtx, CfgGetJsonField, CfgGetResourceField, CfgImmediate, CfgImportProgress, CfgIsEmpty, CfgIsolate, CfgLastLogs, CfgLogHandle, CfgMakeArray, CfgMakeObject, CfgMapArrayValues, CfgMapRecordValues, CfgMapResourceFields, CfgNot, CfgOnDemandBlobContent, CfgOr, CfgProgressLog, CfgProgressLogWithInfo, CfgResourceValueAsJson, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, type ColumnOrderRule, ColumnOverriddenRecipe, ColumnProvider, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, type ColumnVisibilityRule, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, type ColumnsDisplayOptions, ColumnsProvider, type ColumnsSelectorConfig, ColumnsSource, ColumnsSourceShorthand, CommonFieldTraverseOps, CommonTraversalOps, ConfigRenderLambda, ConfigRenderLambdaFlags, CurrentSdkInfo, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DataModel, DataModelBuilder, DatasetAxes, DatasetOption, DatasetSelection, DeriveHref, DeriveLabelsFormatters, DeriveLabelsOptions, DiscoveredRoot, Entry, ExpressionSpec, ExtractFunctionHandleReturn, type ExtractFutureRefType, FieldTraversalStep, FieldType, FilterMatchOptions, type FilterSpec, type FilterSpecLeaf, type FilterSpecNode, type FilterSpecOfType, type FilterSpecType, FilterSpecUi, FilterUi, FilterUiOfType, FilterUiType, FindFilterColumnsOptions, FormField, FutureRef, GetFieldStep, InferArgsType, InferBlockState, InferBlockStatePatch, InferDataType, InferFactoryData, InferFactoryModelServices, InferFactoryOutputs, InferFactoryParams, InferFactoryUiServices, InferHrefType, InferOutputsFromLambdas, InferOutputsType, InferPluginData, InferPluginHandle, InferPluginNames, InferPluginUiEntries, InferRenderFunctionReturn, InferUiState, IsNA, internal_d_exports as JsRenderInternal, type DeriveLabelsOptions as LabelDerivationOps, LinkerStep, Log10, MainAccessorName, type MigrateBlockStorageConfig, type MigrationFailure, type MigrationResult, type MigrationSuccess, type ModelServices, type MutateStoragePayload, NotFilter, NumericalComparisonFilter, OptionalPlResourceEntry, OrFilter, OutputError, PColumnCollection, type PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, PColumnKeyList, PColumnPredicate, PColumnResourceMapData, PColumnResourceMapEntry, PColumnUniversal, PColumnWithLabel, PFrameImpl, PTableKey, type PTableParamsV2, type ParamsInput, Patch, PatternFilter, PatternPredicate, PatternPredicateContainSubsequence, PatternPredicateEquals, type PlDataTableAxisMeta, type PlDataTableColumnMeta, type PlDataTableColumnsMeta, type PlDataTableFilterMeta, type PlDataTableFilterSpecLeaf, type PlDataTableFilters, type PlDataTableFiltersWithMeta, type PlDataTableGridStateCore, type PlDataTableModel, type PlDataTableSheet, type PlDataTableSheetState, type PlDataTableStateV2, type PlDataTableStateV2CacheEntry, type PlDataTableStateV2Normalized, PlMultiSequenceAlignmentColorSchemeOption, PlMultiSequenceAlignmentModel, PlMultiSequenceAlignmentSettings, PlMultiSequenceAlignmentWidget, PlResourceEntry, PlSelectionModel, type PlTableColumnIdJson, Platforma, PlatformaApiVersion, PlatformaExtended, PlatformaFactory, PlatformaSDKVersion, PlatformaV1, PlatformaV2, PlatformaV3, type PluginConfig, type PluginData, PluginDataModel, PluginDataModelBuilder, type PluginDataModelVersions, type PluginFactory, PluginFactoryLike, PluginHandle, PluginInstance, PluginModel, type PluginName, type PluginOutputs, type PluginParams, type PluginPublicOutputs, type PluginRecord, type PluginRegistry, PluginRenderCtx, PresentColumnValueOptionsModel, type PublicOutputFieldDef, QueryColumnId, QueryColumnIdAxis, QueryColumnIdColumn, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtx, RenderCtxBase, RenderFunction, ResolveModelServices, ResolveUiServices, ResourceTraversalOps, ResourceType, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, SdkInfo, ServiceProxy, SimplifiedPColumnSpec, SimplifiedUniversalPColumnEntry, SortedCumulativeSum, type Entry as SpecExtractorResult, type SpecQuery, SplitAxis, SplitByAxesOpts, StagingAccessorName, StdCtx, StdCtxArgsOnly, TooltipEntry, type Trace, type TraceEntry, TransformedColumn, TreeNodeAccessor, TypeField, TypeFieldRecord, TypeForm, TypeToLiteral, TypedConfig, TypedConfigOrConfigLambda, TypedConfigOrString, type UiServices, Unionize, UniversalColumnOption, UnwrapFutureRef, ValueRank, type VersionedData, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildRefMap, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, type createPlDataTableOptionsV3, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
|
package/dist/package.cjs
CHANGED
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/model",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.90.0",
|
|
4
4
|
"description": "Platforma.bio SDK / Block Model",
|
|
5
5
|
"files": [
|
|
6
6
|
"./dist/**/*",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@milaboratories/helpers": "1.14.7",
|
|
29
29
|
"@milaboratories/pl-error-like": "1.12.11",
|
|
30
|
-
"@milaboratories/pl-model-common": "1.
|
|
31
|
-
"@milaboratories/pl-model-middle-layer": "1.
|
|
32
|
-
"@milaboratories/ptabler-expression-js": "1.2.
|
|
30
|
+
"@milaboratories/pl-model-common": "1.56.0",
|
|
31
|
+
"@milaboratories/pl-model-middle-layer": "1.40.0",
|
|
32
|
+
"@milaboratories/ptabler-expression-js": "1.2.50",
|
|
33
33
|
"canonicalize": "~2.1.0",
|
|
34
34
|
"es-toolkit": "^1.39.10",
|
|
35
35
|
"fast-json-patch": "^3.1.1",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@milaboratories/build-configs": "2.0.3",
|
|
42
|
-
"@milaboratories/columns-collection-driver": "0.
|
|
43
|
-
"@milaboratories/pf-driver": "1.9.
|
|
44
|
-
"@milaboratories/pf-spec-driver": "1.
|
|
42
|
+
"@milaboratories/columns-collection-driver": "0.3.0",
|
|
43
|
+
"@milaboratories/pf-driver": "1.9.18",
|
|
44
|
+
"@milaboratories/pf-spec-driver": "1.6.0",
|
|
45
45
|
"@milaboratories/ts-builder": "1.8.0",
|
|
46
46
|
"@milaboratories/ts-configs": "1.4.1",
|
|
47
47
|
"@platforma-sdk/block-kind": "1.1.1",
|
|
@@ -56,12 +56,14 @@ const COLUMNS_COLLECTION_METHODS: ReadonlyArray<string> = [
|
|
|
56
56
|
"addSource",
|
|
57
57
|
"discover",
|
|
58
58
|
"filter",
|
|
59
|
+
"discoverRoots",
|
|
59
60
|
];
|
|
60
61
|
|
|
61
62
|
const PFRAME_SPEC_METHODS: ReadonlyArray<string> = [
|
|
62
63
|
"createSpecFrame",
|
|
63
64
|
"listColumns",
|
|
64
65
|
"discoverColumns",
|
|
66
|
+
"discoverRoots",
|
|
65
67
|
"deleteColumn",
|
|
66
68
|
"evaluateQuery",
|
|
67
69
|
"buildQuery",
|
|
@@ -93,6 +95,7 @@ export function createTestCollectionDriver(): TestCollectionDriverHandle {
|
|
|
93
95
|
addSource: (h, srcs) => impl.addSource(h, srcs, bindings).key,
|
|
94
96
|
discover: (h, o) => impl.discover(h, o, bindings).key,
|
|
95
97
|
filter: (h, o) => impl.filter(h, o, bindings).key,
|
|
98
|
+
discoverRoots: (h, o) => impl.discoverRoots(h, o, bindings),
|
|
96
99
|
};
|
|
97
100
|
|
|
98
101
|
let installedCtx: GlobalCfgRenderCtx | undefined;
|
|
@@ -201,3 +201,50 @@ describe("ColumnsCollection.filter", () => {
|
|
|
201
201
|
expect(ids).toEqual([c1.id, c2.id]);
|
|
202
202
|
});
|
|
203
203
|
});
|
|
204
|
+
|
|
205
|
+
describe("ColumnsCollection.discoverRoots", () => {
|
|
206
|
+
const cellAxis: AxisSpec = { name: "cell", type: "Int" };
|
|
207
|
+
const sampleAxis: AxisSpec = { name: "sample", type: "Long" };
|
|
208
|
+
const linkerSpec: PColumnSpec = {
|
|
209
|
+
...spec("cellToSample", [cellAxis, sampleAxis]),
|
|
210
|
+
annotations: { "pl7.app/isLinkerColumn": "true" },
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const cellData = { id: gid("cellData"), spec: spec("cellData", [cellAxis]) };
|
|
214
|
+
const linker = { id: gid("cellToSample"), spec: linkerSpec };
|
|
215
|
+
const sampleData = { id: gid("sampleData"), spec: spec("sampleData", [sampleAxis]) };
|
|
216
|
+
|
|
217
|
+
beforeEach(() => handle.installAmbientCtx());
|
|
218
|
+
afterEach(() => handle.uninstallAmbientCtx());
|
|
219
|
+
|
|
220
|
+
test("finds the column the given one hangs off, with the linker path", () => {
|
|
221
|
+
const found = makeCollection([cellData, linker, sampleData]).discoverRoots({
|
|
222
|
+
leaves: [cellData.id],
|
|
223
|
+
maxHops: 1,
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
expect(found.map((r) => r.root.id)).toEqual([sampleData.id]);
|
|
227
|
+
expect(found[0]?.path.map((c) => c.id)).toEqual([linker.id]);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test("the leaf is what discover anchored on the root returns", () => {
|
|
231
|
+
const collection = makeCollection([cellData, linker, sampleData]);
|
|
232
|
+
const [found] = collection.discoverRoots({ leaves: [cellData.id], maxHops: 1 });
|
|
233
|
+
|
|
234
|
+
const discovered = collection
|
|
235
|
+
.discover({ anchors: { r: sampleData.id }, maxHops: 1 })
|
|
236
|
+
.getColumnIds();
|
|
237
|
+
|
|
238
|
+
expect(found).toBeDefined();
|
|
239
|
+
expect(discovered).toContain(found?.leaf.id);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
test("a column at the top of the hierarchy has no roots", () => {
|
|
243
|
+
const found = makeCollection([cellData, linker, sampleData]).discoverRoots({
|
|
244
|
+
leaves: [sampleData.id],
|
|
245
|
+
maxHops: 1,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
expect(found).toEqual([]);
|
|
249
|
+
});
|
|
250
|
+
});
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
ColumnsCollectionDriverModel,
|
|
5
5
|
ColumnsDiscoverOptions,
|
|
6
6
|
ColumnsFilterOptions,
|
|
7
|
+
DiscoverRootsOptions,
|
|
7
8
|
SerializedColumnsSource,
|
|
8
9
|
} from "@milaboratories/pl-model-common";
|
|
9
10
|
import type { GlobalCfgRenderCtx } from "../render/internal";
|
|
@@ -58,6 +59,21 @@ export function isColumnsCollection(value: unknown): value is ColumnsCollection
|
|
|
58
59
|
return value instanceof ColumnsCollectionImpl;
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
/**
|
|
63
|
+
* A root found by {@link ColumnsCollectionImpl.discoverRoots}: `leaf` is the
|
|
64
|
+
* requested column exactly as `discover({ anchors: { r: root } })` would
|
|
65
|
+
* return it — carrying the linker `path` and qualifications — so the table is
|
|
66
|
+
* built from `root` as the anchor plus `leaf`.
|
|
67
|
+
*/
|
|
68
|
+
export interface DiscoveredRoot {
|
|
69
|
+
/** The column the leaf hangs off. */
|
|
70
|
+
readonly root: ColumnRecipe;
|
|
71
|
+
/** The requested column, discovered from the root. */
|
|
72
|
+
readonly leaf: ColumnRecipe;
|
|
73
|
+
/** Linker columns from the root to the leaf; empty when they join directly. */
|
|
74
|
+
readonly path: ColumnRecipe[];
|
|
75
|
+
}
|
|
76
|
+
|
|
61
77
|
/**
|
|
62
78
|
* Sandbox proxy over the host-side `ColumnsCollection` driver. The driver
|
|
63
79
|
* owns all column-set state; this object only carries an opaque
|
|
@@ -110,6 +126,23 @@ export class ColumnsCollectionImpl {
|
|
|
110
126
|
filter(options: ColumnsFilterOptions): ColumnsCollection {
|
|
111
127
|
return new ColumnsCollectionImpl(this.driver.filter(this.handle, options), this.driver);
|
|
112
128
|
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Finds the roots the given columns hang off: the columns that, used as
|
|
132
|
+
* `anchors` of {@link discover}, would reach them. One entry per root, leaf
|
|
133
|
+
* and linker path; entries whose columns are not yet resolvable are skipped.
|
|
134
|
+
*/
|
|
135
|
+
discoverRoots(options: DiscoverRootsOptions): DiscoveredRoot[] {
|
|
136
|
+
return this.driver.discoverRoots(this.handle, options).flatMap((ids) => {
|
|
137
|
+
const root = ColumnRecipe(ids.root);
|
|
138
|
+
const leaf = ColumnRecipe(ids.leaf);
|
|
139
|
+
const path = ids.path
|
|
140
|
+
.map((id) => ColumnRecipe(id))
|
|
141
|
+
.filter((c): c is ColumnRecipe => !isNil(c));
|
|
142
|
+
if (isNil(root) || isNil(leaf) || path.length !== ids.path.length) return [];
|
|
143
|
+
return [{ root, leaf, path }];
|
|
144
|
+
});
|
|
145
|
+
}
|
|
113
146
|
}
|
|
114
147
|
|
|
115
148
|
/** Public type alias — value of the same name is the factory function above. */
|