@platforma-sdk/model 1.63.12 → 1.64.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/column_collection_builder.cjs +105 -92
- package/dist/columns/column_collection_builder.cjs.map +1 -1
- package/dist/columns/column_collection_builder.d.ts +13 -12
- package/dist/columns/column_collection_builder.d.ts.map +1 -1
- package/dist/columns/column_collection_builder.js +107 -94
- package/dist/columns/column_collection_builder.js.map +1 -1
- package/dist/columns/column_selector.cjs +8 -80
- package/dist/columns/column_selector.cjs.map +1 -1
- package/dist/columns/column_selector.d.ts +6 -14
- package/dist/columns/column_selector.d.ts.map +1 -1
- package/dist/columns/column_selector.js +6 -77
- package/dist/columns/column_selector.js.map +1 -1
- package/dist/columns/column_snapshot.cjs +3 -3
- package/dist/columns/column_snapshot.cjs.map +1 -1
- package/dist/columns/column_snapshot.d.ts +3 -3
- package/dist/columns/column_snapshot.d.ts.map +1 -1
- package/dist/columns/column_snapshot.js +3 -3
- package/dist/columns/column_snapshot.js.map +1 -1
- package/dist/columns/column_snapshot_provider.cjs +1 -1
- package/dist/columns/column_snapshot_provider.cjs.map +1 -1
- package/dist/columns/column_snapshot_provider.d.ts +8 -8
- package/dist/columns/column_snapshot_provider.d.ts.map +1 -1
- package/dist/columns/column_snapshot_provider.js +1 -1
- package/dist/columns/column_snapshot_provider.js.map +1 -1
- package/dist/columns/ctx_column_sources.cjs.map +1 -1
- package/dist/columns/ctx_column_sources.d.ts +2 -1
- package/dist/columns/ctx_column_sources.d.ts.map +1 -1
- package/dist/columns/ctx_column_sources.js.map +1 -1
- package/dist/columns/expand_by_partition.cjs +106 -0
- package/dist/columns/expand_by_partition.cjs.map +1 -0
- package/dist/columns/expand_by_partition.d.ts +33 -0
- package/dist/columns/expand_by_partition.d.ts.map +1 -0
- package/dist/columns/expand_by_partition.js +105 -0
- package/dist/columns/expand_by_partition.js.map +1 -0
- package/dist/columns/index.cjs +1 -0
- package/dist/columns/index.d.ts +4 -3
- package/dist/columns/index.js +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV2.cjs +26 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV2.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV2.js +25 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV2.js.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV3.cjs +68 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV3.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV3.js +67 -0
- package/dist/components/PlDataTable/createPlDataTable/createPTableDefV3.js.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs +20 -9
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.d.ts +4 -0
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js +21 -10
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV2.js.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs +257 -175
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts +37 -21
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js +260 -175
- package/dist/components/PlDataTable/createPlDataTable/createPlDataTableV3.js.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.cjs +64 -0
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.d.ts +17 -0
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.d.ts.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.js +63 -0
- package/dist/components/PlDataTable/createPlDataTable/discoverColumns.js.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/index.cjs +2 -1
- package/dist/components/PlDataTable/createPlDataTable/index.cjs.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/index.d.ts +2 -1
- package/dist/components/PlDataTable/createPlDataTable/index.d.ts.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/index.js +2 -1
- package/dist/components/PlDataTable/createPlDataTable/index.js.map +1 -1
- package/dist/components/PlDataTable/createPlDataTable/utils.cjs +109 -0
- package/dist/components/PlDataTable/createPlDataTable/utils.cjs.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/utils.d.ts +19 -0
- package/dist/components/PlDataTable/createPlDataTable/utils.d.ts.map +1 -0
- package/dist/components/PlDataTable/createPlDataTable/utils.js +102 -0
- package/dist/components/PlDataTable/createPlDataTable/utils.js.map +1 -0
- package/dist/components/PlDataTable/index.cjs +3 -1
- package/dist/components/PlDataTable/index.d.ts +4 -2
- package/dist/components/PlDataTable/index.js +3 -1
- package/dist/components/PlDataTable/labels.cjs +25 -11
- package/dist/components/PlDataTable/labels.cjs.map +1 -1
- package/dist/components/PlDataTable/labels.js +25 -11
- package/dist/components/PlDataTable/labels.js.map +1 -1
- package/dist/components/PlDataTable/state-migration.cjs +4 -1
- package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
- package/dist/components/PlDataTable/state-migration.d.ts.map +1 -1
- package/dist/components/PlDataTable/state-migration.js +4 -1
- package/dist/components/PlDataTable/state-migration.js.map +1 -1
- package/dist/components/PlDataTable/typesV5.d.ts +5 -4
- package/dist/components/PlDataTable/typesV5.d.ts.map +1 -1
- package/dist/components/index.cjs +3 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +3 -1
- package/dist/index.cjs +13 -9
- package/dist/index.d.ts +8 -6
- package/dist/index.js +6 -4
- package/dist/labels/derive_distinct_labels.cjs +39 -27
- package/dist/labels/derive_distinct_labels.cjs.map +1 -1
- package/dist/labels/derive_distinct_labels.d.ts +15 -15
- package/dist/labels/derive_distinct_labels.d.ts.map +1 -1
- package/dist/labels/derive_distinct_labels.js +39 -27
- package/dist/labels/derive_distinct_labels.js.map +1 -1
- package/dist/labels/index.cjs +0 -1
- package/dist/labels/index.d.ts +1 -2
- package/dist/labels/index.js +0 -1
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/render/api.cjs +10 -3
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +2 -2
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/api.js +10 -3
- package/dist/render/api.js.map +1 -1
- package/dist/render/util/column_collection.cjs +3 -3
- package/dist/render/util/column_collection.cjs.map +1 -1
- package/dist/render/util/column_collection.d.ts.map +1 -1
- package/dist/render/util/column_collection.js +3 -3
- package/dist/render/util/column_collection.js.map +1 -1
- package/dist/render/util/label.cjs +2 -2
- package/dist/render/util/label.cjs.map +1 -1
- package/dist/render/util/label.js +2 -2
- package/dist/render/util/label.js.map +1 -1
- package/dist/render/util/pcolumn_data.cjs.map +1 -1
- package/dist/render/util/pcolumn_data.d.ts +2 -2
- package/dist/render/util/pcolumn_data.d.ts.map +1 -1
- package/dist/render/util/pcolumn_data.js.map +1 -1
- package/package.json +6 -6
- package/src/columns/column_collection_builder.test.ts +40 -27
- package/src/columns/column_collection_builder.ts +176 -131
- package/src/columns/column_selector.test.ts +17 -399
- package/src/columns/column_selector.ts +14 -127
- package/src/columns/column_snapshot.ts +5 -5
- package/src/columns/column_snapshot_provider.ts +11 -10
- package/src/columns/ctx_column_sources.ts +2 -2
- package/src/columns/expand_by_partition.test.ts +4 -4
- package/src/columns/expand_by_partition.ts +4 -3
- package/src/columns/index.ts +1 -0
- package/src/components/PlDataTable/createPlDataTable/createPTableDefV2.ts +42 -0
- package/src/components/PlDataTable/createPlDataTable/createPTableDefV3.ts +89 -0
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV2.ts +39 -11
- package/src/components/PlDataTable/createPlDataTable/createPlDataTableV3.ts +502 -313
- package/src/components/PlDataTable/createPlDataTable/discoverColumns.ts +122 -0
- package/src/components/PlDataTable/createPlDataTable/index.ts +4 -2
- package/src/components/PlDataTable/createPlDataTable/utils.test.ts +257 -0
- package/src/components/PlDataTable/createPlDataTable/utils.ts +160 -0
- package/src/components/PlDataTable/index.ts +13 -2
- package/src/components/PlDataTable/labels.ts +29 -18
- package/src/components/PlDataTable/state-migration.ts +3 -1
- package/src/components/PlDataTable/typesV5.ts +4 -4
- package/src/labels/derive_distinct_labels.test.ts +143 -45
- package/src/labels/derive_distinct_labels.ts +102 -49
- package/src/labels/index.ts +0 -1
- package/src/render/api.ts +15 -5
- package/src/render/util/column_collection.ts +4 -3
- package/src/render/util/label.ts +2 -2
- package/src/render/util/pcolumn_data.ts +5 -3
- package/dist/labels/write_labels_to_specs.cjs +0 -14
- package/dist/labels/write_labels_to_specs.cjs.map +0 -1
- package/dist/labels/write_labels_to_specs.d.ts +0 -7
- package/dist/labels/write_labels_to_specs.d.ts.map +0 -1
- package/dist/labels/write_labels_to_specs.js +0 -13
- package/dist/labels/write_labels_to_specs.js.map +0 -1
- package/src/labels/write_labels_to_specs.ts +0 -12
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PObjectId } from "@milaboratories/pl-model-common";
|
|
1
2
|
import { PColumn } from "@milaboratories/pl-model-common";
|
|
2
3
|
import { TreeNodeAccessor } from "../render/accessor";
|
|
3
4
|
import type { PColumnDataUniversal } from "../render/internal";
|
|
@@ -13,7 +14,7 @@ import type { ColumnDataStatus, ColumnSnapshot } from "./column_snapshot";
|
|
|
13
14
|
*/
|
|
14
15
|
export interface ColumnSnapshotProvider {
|
|
15
16
|
/** Returns all currently known columns. */
|
|
16
|
-
getAllColumns(): ColumnSnapshot[];
|
|
17
|
+
getAllColumns(): ColumnSnapshot<PObjectId>[];
|
|
17
18
|
|
|
18
19
|
/** Whether the provider has finished enumerating all its columns.
|
|
19
20
|
* Calling this may mark the render context unstable — it touches
|
|
@@ -29,7 +30,7 @@ export interface ColumnSnapshotProvider {
|
|
|
29
30
|
*/
|
|
30
31
|
export type ColumnSource =
|
|
31
32
|
| ColumnSnapshotProvider
|
|
32
|
-
| ColumnSnapshot[]
|
|
33
|
+
| ColumnSnapshot<PObjectId>[]
|
|
33
34
|
| PColumn<PColumnDataUniversal | undefined>[];
|
|
34
35
|
|
|
35
36
|
// --- ArrayColumnProvider ---
|
|
@@ -39,7 +40,7 @@ export type ColumnSource =
|
|
|
39
40
|
* Always complete, data status always 'ready'.
|
|
40
41
|
*/
|
|
41
42
|
export class ArrayColumnProvider implements ColumnSnapshotProvider {
|
|
42
|
-
private readonly columns: ColumnSnapshot[];
|
|
43
|
+
private readonly columns: ColumnSnapshot<PObjectId>[];
|
|
43
44
|
|
|
44
45
|
constructor(columns: PColumn<PColumnDataUniversal | undefined>[]) {
|
|
45
46
|
this.columns = columns.map((col) => ({
|
|
@@ -50,7 +51,7 @@ export class ArrayColumnProvider implements ColumnSnapshotProvider {
|
|
|
50
51
|
}));
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
getAllColumns(): ColumnSnapshot[] {
|
|
54
|
+
getAllColumns(): ColumnSnapshot<PObjectId>[] {
|
|
54
55
|
return this.columns;
|
|
55
56
|
}
|
|
56
57
|
|
|
@@ -66,9 +67,9 @@ export class ArrayColumnProvider implements ColumnSnapshotProvider {
|
|
|
66
67
|
* Always complete. Data status taken from each snapshot.
|
|
67
68
|
*/
|
|
68
69
|
export class SnapshotColumnProvider implements ColumnSnapshotProvider {
|
|
69
|
-
constructor(private readonly snapshots: ColumnSnapshot[]) {}
|
|
70
|
+
constructor(private readonly snapshots: ColumnSnapshot<PObjectId>[]) {}
|
|
70
71
|
|
|
71
|
-
getAllColumns(): ColumnSnapshot[] {
|
|
72
|
+
getAllColumns(): ColumnSnapshot<PObjectId>[] {
|
|
72
73
|
return this.snapshots;
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -94,7 +95,7 @@ export class OutputColumnProvider implements ColumnSnapshotProvider {
|
|
|
94
95
|
private readonly opts?: OutputColumnProviderOpts,
|
|
95
96
|
) {}
|
|
96
97
|
|
|
97
|
-
getAllColumns(): ColumnSnapshot[] {
|
|
98
|
+
getAllColumns(): ColumnSnapshot<PObjectId>[] {
|
|
98
99
|
return this.getColumns();
|
|
99
100
|
}
|
|
100
101
|
|
|
@@ -102,7 +103,7 @@ export class OutputColumnProvider implements ColumnSnapshotProvider {
|
|
|
102
103
|
return this.accessor.getInputsLocked();
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
private getColumns(): ColumnSnapshot[] {
|
|
106
|
+
private getColumns(): ColumnSnapshot<PObjectId>[] {
|
|
106
107
|
const pColumns = this.accessor.getPColumns();
|
|
107
108
|
if (pColumns === undefined) return [];
|
|
108
109
|
|
|
@@ -155,7 +156,7 @@ function isPColumnArray(source: unknown): source is PColumn<PColumnDataUniversal
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
/** Checks if a value looks like a ColumnSnapshot array. */
|
|
158
|
-
function isColumnSnapshotArray(source: unknown): source is ColumnSnapshot[] {
|
|
159
|
+
function isColumnSnapshotArray(source: unknown): source is ColumnSnapshot<PObjectId>[] {
|
|
159
160
|
if (!Array.isArray(source)) return false;
|
|
160
161
|
if (source.length === 0) return true; // empty array — treat as snapshots
|
|
161
162
|
const first = source[0];
|
|
@@ -165,7 +166,7 @@ function isColumnSnapshotArray(source: unknown): source is ColumnSnapshot[] {
|
|
|
165
166
|
/**
|
|
166
167
|
* Normalize any ColumnSource into a ColumnSnapshotProvider.
|
|
167
168
|
* - ColumnSnapshotProvider → returned as-is
|
|
168
|
-
* - ColumnSnapshot[] → wrapped in SnapshotColumnProvider
|
|
169
|
+
* - ColumnSnapshot<PObjectId>[] → wrapped in SnapshotColumnProvider
|
|
169
170
|
* - PColumn[] → wrapped in ArrayColumnProvider
|
|
170
171
|
*/
|
|
171
172
|
export function toColumnSnapshotProvider(source: ColumnSource): ColumnSnapshotProvider {
|
|
@@ -51,7 +51,7 @@ export function collectCtxColumnSnapshotProviders<A, U, S>(
|
|
|
51
51
|
export class ResultPoolColumnSnapshotProvider implements ColumnSnapshotProvider {
|
|
52
52
|
constructor(private readonly pool: ResultPool) {}
|
|
53
53
|
|
|
54
|
-
getAllColumns(): ColumnSnapshot[] {
|
|
54
|
+
getAllColumns(): ColumnSnapshot<PObjectId>[] {
|
|
55
55
|
const pColumns = this.pool.selectColumns(() => true);
|
|
56
56
|
return pColumns.map((col) => toSnapshot(col.id, col.spec, col.data));
|
|
57
57
|
}
|
|
@@ -65,7 +65,7 @@ function toSnapshot(
|
|
|
65
65
|
id: PObjectId,
|
|
66
66
|
spec: PColumnSpec,
|
|
67
67
|
accessor: TreeNodeAccessor | undefined,
|
|
68
|
-
): ColumnSnapshot {
|
|
68
|
+
): ColumnSnapshot<PObjectId> {
|
|
69
69
|
if (accessor === undefined) {
|
|
70
70
|
return { id, spec, dataStatus: "absent" as ColumnDataStatus, data: undefined };
|
|
71
71
|
}
|
|
@@ -32,7 +32,7 @@ function createReadySnapshot(
|
|
|
32
32
|
columnSpec: PColumnSpec,
|
|
33
33
|
partitionKeyLength: number,
|
|
34
34
|
parts: { key: (string | number)[]; value: unknown }[],
|
|
35
|
-
): ColumnSnapshot {
|
|
35
|
+
): ColumnSnapshot<PObjectId> {
|
|
36
36
|
const dataEntries: JsonPartitionedDataInfoEntries<unknown> = {
|
|
37
37
|
type: "JsonPartitioned",
|
|
38
38
|
partitionKeyLength,
|
|
@@ -48,7 +48,7 @@ function createReadySnapshot(
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
function createComputingSnapshot(id: string, columnSpec: PColumnSpec): ColumnSnapshot {
|
|
51
|
+
function createComputingSnapshot(id: string, columnSpec: PColumnSpec): ColumnSnapshot<PObjectId> {
|
|
52
52
|
return {
|
|
53
53
|
id: id as PObjectId,
|
|
54
54
|
spec: columnSpec,
|
|
@@ -59,7 +59,7 @@ function createComputingSnapshot(id: string, columnSpec: PColumnSpec): ColumnSna
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function createAbsentSnapshot(id: string, columnSpec: PColumnSpec): ColumnSnapshot {
|
|
62
|
+
function createAbsentSnapshot(id: string, columnSpec: PColumnSpec): ColumnSnapshot<PObjectId> {
|
|
63
63
|
return {
|
|
64
64
|
id: id as PObjectId,
|
|
65
65
|
spec: columnSpec,
|
|
@@ -74,7 +74,7 @@ interface Trace {
|
|
|
74
74
|
importance: number;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
function extractTrace(snapshot: ColumnSnapshot): Trace[] {
|
|
77
|
+
function extractTrace(snapshot: ColumnSnapshot<PObjectId>): Trace[] {
|
|
78
78
|
const raw = snapshot.spec.annotations?.["pl7.app/trace"];
|
|
79
79
|
return raw ? (JSON.parse(raw) as Trace[]) : [];
|
|
80
80
|
}
|
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
AxisFilterValue,
|
|
4
4
|
AxisId,
|
|
5
5
|
PartitionedDataInfoEntries,
|
|
6
|
+
PObjectId,
|
|
6
7
|
} from "@milaboratories/pl-model-common";
|
|
7
8
|
import {
|
|
8
9
|
canonicalizeAxisId,
|
|
@@ -30,7 +31,7 @@ export interface ExpandByPartitionOpts {
|
|
|
30
31
|
|
|
31
32
|
export interface ExpandByPartitionResult {
|
|
32
33
|
/** Expanded snapshots (one per key combination per original snapshot). */
|
|
33
|
-
readonly items: ColumnSnapshot[];
|
|
34
|
+
readonly items: ColumnSnapshot<PObjectId>[];
|
|
34
35
|
/** False if any column's data was not ready for splitting. */
|
|
35
36
|
readonly complete: boolean;
|
|
36
37
|
}
|
|
@@ -49,7 +50,7 @@ export interface ExpandByPartitionResult {
|
|
|
49
50
|
* is not ready (status !== 'ready' or partition data unavailable).
|
|
50
51
|
*/
|
|
51
52
|
export function expandByPartition(
|
|
52
|
-
snapshots: ColumnSnapshot[],
|
|
53
|
+
snapshots: ColumnSnapshot<PObjectId>[],
|
|
53
54
|
splitAxes: SplitAxis[],
|
|
54
55
|
opts?: ExpandByPartitionOpts,
|
|
55
56
|
): ExpandByPartitionResult {
|
|
@@ -58,7 +59,7 @@ export function expandByPartition(
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
const splitAxisIdxs = splitAxes.map((a) => a.idx).sort((a, b) => a - b);
|
|
61
|
-
const result: ColumnSnapshot[] = [];
|
|
62
|
+
const result: ColumnSnapshot<PObjectId>[] = [];
|
|
62
63
|
|
|
63
64
|
for (const snapshot of snapshots) {
|
|
64
65
|
if (snapshot.dataStatus !== "ready" || snapshot.data === undefined) {
|
package/src/columns/index.ts
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PColumn,
|
|
3
|
+
PColumnIdAndSpec,
|
|
4
|
+
PTableSorting,
|
|
5
|
+
PTableDefV2,
|
|
6
|
+
DataInfo,
|
|
7
|
+
PColumnValues,
|
|
8
|
+
} from "@milaboratories/pl-model-common";
|
|
9
|
+
import { getColumnIdAndSpec } from "@milaboratories/pl-model-common";
|
|
10
|
+
import type { PColumnDataUniversal, TreeNodeAccessor } from "../../../render";
|
|
11
|
+
import { isFunction } from "es-toolkit";
|
|
12
|
+
import type { PlDataTableFilters } from "../typesV5";
|
|
13
|
+
import { createPTableDefV3 } from "./createPTableDefV3";
|
|
14
|
+
|
|
15
|
+
export function createPTableDefV2(params: {
|
|
16
|
+
columns: PColumn<PColumnDataUniversal>[];
|
|
17
|
+
labelColumns: PColumn<PColumnDataUniversal>[];
|
|
18
|
+
coreJoinType: "inner" | "full";
|
|
19
|
+
filters: null | PlDataTableFilters;
|
|
20
|
+
sorting: PTableSorting[];
|
|
21
|
+
coreColumnPredicate?: (spec: PColumnIdAndSpec) => boolean;
|
|
22
|
+
}): PTableDefV2<PColumn<TreeNodeAccessor | PColumnValues | DataInfo<TreeNodeAccessor>>> {
|
|
23
|
+
let coreColumns = params.columns;
|
|
24
|
+
const secondaryColumns: typeof params.columns = [];
|
|
25
|
+
|
|
26
|
+
if (isFunction(params.coreColumnPredicate)) {
|
|
27
|
+
coreColumns = [];
|
|
28
|
+
for (const c of params.columns)
|
|
29
|
+
if (params.coreColumnPredicate(getColumnIdAndSpec(c))) coreColumns.push(c);
|
|
30
|
+
else secondaryColumns.push(c);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
secondaryColumns.push(...params.labelColumns);
|
|
34
|
+
|
|
35
|
+
return createPTableDefV3({
|
|
36
|
+
primaryColumns: coreColumns,
|
|
37
|
+
secondaryGroups: secondaryColumns.map((c) => [c]),
|
|
38
|
+
primaryJoinType: params.coreJoinType,
|
|
39
|
+
filters: params.filters,
|
|
40
|
+
sorting: params.sorting,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PColumn,
|
|
3
|
+
PTableColumnId,
|
|
4
|
+
PTableSorting,
|
|
5
|
+
PTableDefV2,
|
|
6
|
+
SingleAxisSelector,
|
|
7
|
+
SpecQuery,
|
|
8
|
+
SpecQueryExpression,
|
|
9
|
+
SpecQueryJoinEntry,
|
|
10
|
+
} from "@milaboratories/pl-model-common";
|
|
11
|
+
import { isBooleanExpression } from "@milaboratories/pl-model-common";
|
|
12
|
+
import type { PColumnDataUniversal } from "../../../render";
|
|
13
|
+
import { isNil } from "es-toolkit";
|
|
14
|
+
import type { PlDataTableFilters } from "../typesV5";
|
|
15
|
+
import { distillFilterSpec, filterSpecToSpecQueryExpr } from "../../../filters";
|
|
16
|
+
import type { Nil } from "@milaboratories/helpers";
|
|
17
|
+
|
|
18
|
+
export function createPTableDefV3<Data = PColumnDataUniversal>(params: {
|
|
19
|
+
primaryJoinType: "inner" | "full";
|
|
20
|
+
primaryColumns: PColumn<Data>[];
|
|
21
|
+
secondaryGroups: PColumn<Data>[][];
|
|
22
|
+
filters?: Nil | PlDataTableFilters;
|
|
23
|
+
sorting?: Nil | PTableSorting[];
|
|
24
|
+
}): PTableDefV2<PColumn<Data>> {
|
|
25
|
+
// Build SpecQuery directly from columns
|
|
26
|
+
const coreJoinQuery: SpecQuery<PColumn<Data>> = {
|
|
27
|
+
type: params.primaryJoinType === "inner" ? "innerJoin" : "fullJoin",
|
|
28
|
+
entries: params.primaryColumns.map((c) => toJoinEntry({ type: "column", column: c })),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
let query: SpecQuery<PColumn<Data>> = {
|
|
32
|
+
type: "outerJoin",
|
|
33
|
+
primary: toJoinEntry(coreJoinQuery),
|
|
34
|
+
secondary: params.secondaryGroups.map((group) =>
|
|
35
|
+
toJoinEntry({
|
|
36
|
+
type: "innerJoin" as const,
|
|
37
|
+
entries: group.map((c) => toJoinEntry({ type: "column" as const, column: c })),
|
|
38
|
+
}),
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Apply filters
|
|
43
|
+
if (!isNil(params.filters)) {
|
|
44
|
+
const nonEmpty = distillFilterSpec(params.filters);
|
|
45
|
+
|
|
46
|
+
if (!isNil(nonEmpty)) {
|
|
47
|
+
const pridicate = filterSpecToSpecQueryExpr(nonEmpty);
|
|
48
|
+
if (!isBooleanExpression(pridicate)) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Filter conversion produced a non-boolean expression (got type "${pridicate.type}"), expected a boolean predicate for query filtering`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
query = {
|
|
54
|
+
type: "filter",
|
|
55
|
+
input: query,
|
|
56
|
+
predicate: pridicate,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Apply sorting
|
|
62
|
+
if (!isNil(params.sorting) && params.sorting.length > 0) {
|
|
63
|
+
query = {
|
|
64
|
+
type: "sort",
|
|
65
|
+
input: query,
|
|
66
|
+
sortBy: params.sorting.map((s) => ({
|
|
67
|
+
expression: columnIdToExpr(s.column),
|
|
68
|
+
ascending: s.ascending,
|
|
69
|
+
nullsFirst: !s.naAndAbsentAreLeastValues,
|
|
70
|
+
})),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return { query };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Convert a PTableColumnId to a SpecQueryExpression reference. */
|
|
78
|
+
function columnIdToExpr(col: PTableColumnId): SpecQueryExpression {
|
|
79
|
+
return col.type === "axis"
|
|
80
|
+
? { type: "axisRef", value: col.id as SingleAxisSelector }
|
|
81
|
+
: { type: "columnRef", value: col.id };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function toJoinEntry<C>(input: SpecQuery<C>): SpecQueryJoinEntry<C> {
|
|
85
|
+
return {
|
|
86
|
+
entry: input,
|
|
87
|
+
qualifications: [],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -15,18 +15,28 @@ import {
|
|
|
15
15
|
isLinkerColumn,
|
|
16
16
|
uniqueBy,
|
|
17
17
|
parseJson,
|
|
18
|
+
PColumnName,
|
|
18
19
|
} from "@milaboratories/pl-model-common";
|
|
19
|
-
import type {
|
|
20
|
-
|
|
20
|
+
import type {
|
|
21
|
+
AxisLabelProvider,
|
|
22
|
+
ColumnProvider,
|
|
23
|
+
PColumnDataUniversal,
|
|
24
|
+
RenderCtxBase,
|
|
25
|
+
} from "../../../render";
|
|
26
|
+
import { allPColumnsReady, deriveLabels, PColumnCollection } from "../../../render";
|
|
21
27
|
import { identity } from "es-toolkit";
|
|
22
28
|
import type { CreatePlDataTableOps, PlDataTableFilters, PlDataTableModel } from "../typesV5";
|
|
23
29
|
import { upgradePlDataTableStateV2 } from "../state-migration";
|
|
24
30
|
import type { PlDataTableStateV2 } from "../state-migration";
|
|
25
|
-
import {
|
|
31
|
+
import { getMatchingLabelColumns } from "../labels";
|
|
26
32
|
import { collectFilterSpecColumns } from "../../../filters/traverse";
|
|
27
33
|
import { isEmpty } from "es-toolkit/compat";
|
|
28
|
-
import {
|
|
34
|
+
import { createPTableDefV2 } from "./createPTableDefV2";
|
|
35
|
+
import { isColumnOptional } from "./utils";
|
|
29
36
|
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated This function is deprecated and will be removed in future. Please migrate to createPlDataTable with v3 options for improved column discovery and display configuration. See createPlDataTableOptionsV3 for details on the new options format and migration guidance.
|
|
39
|
+
*/
|
|
30
40
|
export type createPlDataTableOptionsV2 = {
|
|
31
41
|
columns: PColumn<PColumnDataUniversal>[];
|
|
32
42
|
tableState?: PlDataTableStateV2;
|
|
@@ -36,6 +46,7 @@ export type createPlDataTableOptionsV2 = {
|
|
|
36
46
|
/**
|
|
37
47
|
* Create p-table spec and handle given ui table state
|
|
38
48
|
*
|
|
49
|
+
* @deprecated This version of createPlDataTable is deprecated and will be removed in future. Please migrate to v3 by switching to the new options format and providing necessary information for column discovery and display configuration. See createPlDataTableOptionsV3 for details.
|
|
39
50
|
* @param ctx context
|
|
40
51
|
* @param columns column list
|
|
41
52
|
* @param tableState table ui state
|
|
@@ -50,11 +61,9 @@ export function createPlDataTableV2<A, U>(
|
|
|
50
61
|
if (columns.length === 0) return undefined;
|
|
51
62
|
|
|
52
63
|
const tableStateNormalized = upgradePlDataTableStateV2(tableState);
|
|
64
|
+
const allLabelColumns = getAllLabelColumns(ctx.resultPool) ?? [];
|
|
53
65
|
|
|
54
|
-
|
|
55
|
-
if (!allLabelColumns) return undefined;
|
|
56
|
-
|
|
57
|
-
let fullLabelColumns = getMatchingLabelColumns(columns.map(getColumnIdAndSpec), allLabelColumns);
|
|
66
|
+
let fullLabelColumns = getMatchingLabelColumns(columns, allLabelColumns);
|
|
58
67
|
fullLabelColumns = deriveLabels(fullLabelColumns, identity, { includeNativeLabel: true }).map(
|
|
59
68
|
(v) => {
|
|
60
69
|
return {
|
|
@@ -110,7 +119,7 @@ export function createPlDataTableV2<A, U>(
|
|
|
110
119
|
);
|
|
111
120
|
|
|
112
121
|
const coreJoinType = options?.coreJoinType ?? "full";
|
|
113
|
-
const fullDef =
|
|
122
|
+
const fullDef = createPTableDefV2({
|
|
114
123
|
columns,
|
|
115
124
|
labelColumns: fullLabelColumns,
|
|
116
125
|
coreJoinType,
|
|
@@ -129,7 +138,11 @@ export function createPlDataTableV2<A, U>(
|
|
|
129
138
|
if (coreJoinType === "inner") return [];
|
|
130
139
|
|
|
131
140
|
const hiddenColIds = tableStateNormalized.pTableParams.hiddenColIds;
|
|
132
|
-
if (hiddenColIds)
|
|
141
|
+
if (hiddenColIds !== null) {
|
|
142
|
+
return hiddenColIds
|
|
143
|
+
.filter((s): s is PTableColumnIdColumn => s.type === "column")
|
|
144
|
+
.map((s) => s.id);
|
|
145
|
+
}
|
|
133
146
|
|
|
134
147
|
return columns.filter((c) => isColumnOptional(c.spec)).map((c) => c.id);
|
|
135
148
|
})(),
|
|
@@ -172,7 +185,7 @@ export function createPlDataTableV2<A, U>(
|
|
|
172
185
|
// if at least one column is not yet computed, we can't show the table
|
|
173
186
|
if (!allPColumnsReady([...visibleColumns, ...visibleLabelColumns])) return undefined;
|
|
174
187
|
|
|
175
|
-
const visibleDef =
|
|
188
|
+
const visibleDef = createPTableDefV2({
|
|
176
189
|
columns: visibleColumns,
|
|
177
190
|
labelColumns: visibleLabelColumns,
|
|
178
191
|
coreJoinType,
|
|
@@ -191,3 +204,18 @@ export function createPlDataTableV2<A, U>(
|
|
|
191
204
|
visibleTableHandle: visibleHandle,
|
|
192
205
|
} satisfies PlDataTableModel;
|
|
193
206
|
}
|
|
207
|
+
|
|
208
|
+
function getAllLabelColumns(
|
|
209
|
+
resultPool: AxisLabelProvider & ColumnProvider,
|
|
210
|
+
): PColumn<PColumnDataUniversal>[] | undefined {
|
|
211
|
+
return new PColumnCollection()
|
|
212
|
+
.addAxisLabelProvider(resultPool)
|
|
213
|
+
.addColumnProvider(resultPool)
|
|
214
|
+
.getColumns(
|
|
215
|
+
{
|
|
216
|
+
name: PColumnName.Label,
|
|
217
|
+
axes: [{}], // exactly one axis
|
|
218
|
+
},
|
|
219
|
+
{ dontWaitAllData: true, overrideLabelAnnotation: false },
|
|
220
|
+
);
|
|
221
|
+
}
|