@platforma-sdk/model 1.54.9 → 1.54.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
- package/dist/components/PlDataTable/state-migration.js.map +1 -1
- package/dist/components/PlDataTable/table.cjs +27 -9
- package/dist/components/PlDataTable/table.cjs.map +1 -1
- package/dist/components/PlDataTable/table.d.ts.map +1 -1
- package/dist/components/PlDataTable/table.js +28 -10
- package/dist/components/PlDataTable/table.js.map +1 -1
- package/dist/components/PlDataTable/v5.d.ts +8 -5
- package/dist/components/PlDataTable/v5.d.ts.map +1 -1
- package/dist/filters/converters/filterToQuery.cjs +21 -15
- package/dist/filters/converters/filterToQuery.cjs.map +1 -1
- package/dist/filters/converters/filterToQuery.d.ts +1 -1
- package/dist/filters/converters/filterToQuery.d.ts.map +1 -1
- package/dist/filters/converters/filterToQuery.js +21 -15
- package/dist/filters/converters/filterToQuery.js.map +1 -1
- package/dist/filters/converters/filterUiToExpressionImpl.cjs +80 -100
- package/dist/filters/converters/filterUiToExpressionImpl.cjs.map +1 -1
- package/dist/filters/converters/filterUiToExpressionImpl.d.ts.map +1 -1
- package/dist/filters/converters/filterUiToExpressionImpl.js +81 -101
- package/dist/filters/converters/filterUiToExpressionImpl.js.map +1 -1
- package/dist/filters/distill.cjs +18 -18
- package/dist/filters/distill.cjs.map +1 -1
- package/dist/filters/distill.d.ts +3 -2
- package/dist/filters/distill.d.ts.map +1 -1
- package/dist/filters/distill.js +18 -18
- package/dist/filters/distill.js.map +1 -1
- package/dist/filters/traverse.cjs +53 -0
- package/dist/filters/traverse.cjs.map +1 -0
- package/dist/filters/traverse.d.ts +27 -0
- package/dist/filters/traverse.d.ts.map +1 -0
- package/dist/filters/traverse.js +50 -0
- package/dist/filters/traverse.js.map +1 -0
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/pframe_utils/querySpec.d.ts +1 -1
- package/dist/pframe_utils/querySpec.d.ts.map +1 -1
- package/dist/render/api.cjs +1 -1
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/api.js +2 -2
- package/dist/render/api.js.map +1 -1
- package/package.json +6 -6
- package/src/components/PlDataTable/state-migration.ts +4 -4
- package/src/components/PlDataTable/table.ts +43 -12
- package/src/components/PlDataTable/v5.ts +10 -7
- package/src/filters/converters/filterToQuery.ts +25 -17
- package/src/filters/converters/filterUiToExpressionImpl.ts +81 -125
- package/src/filters/distill.ts +28 -24
- package/src/filters/traverse.test.ts +134 -0
- package/src/filters/traverse.ts +84 -0
- package/src/pframe_utils/querySpec.ts +1 -1
- package/src/render/api.ts +2 -2
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FilterSpec,
|
|
3
|
+
FilterSpecLeaf,
|
|
4
|
+
FilterSpecNode,
|
|
5
|
+
InferFilterSpecLeafColumn,
|
|
6
|
+
} from "@milaboratories/pl-model-common";
|
|
7
|
+
import type {
|
|
8
|
+
InferFilterSpecCommonLeaf,
|
|
9
|
+
InferFilterSpecLeaf,
|
|
10
|
+
} from "@milaboratories/pl-model-common";
|
|
11
|
+
|
|
12
|
+
export type FilterSpecVisitor<LeafArg, R> = {
|
|
13
|
+
/** Handle a leaf filter node. */
|
|
14
|
+
leaf: (leaf: LeafArg) => R;
|
|
15
|
+
/** Handle an AND node after children have been traversed. */
|
|
16
|
+
and: (results: R[]) => R;
|
|
17
|
+
/** Handle an OR node after children have been traversed. */
|
|
18
|
+
or: (results: R[]) => R;
|
|
19
|
+
/** Handle a NOT node after the inner filter has been traversed. */
|
|
20
|
+
not: (result: R) => R;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Recursively traverses a FilterSpec tree bottom-up, applying visitor callbacks.
|
|
25
|
+
*
|
|
26
|
+
* Entries with `{ type: undefined }` inside `and`/`or` arrays are skipped
|
|
27
|
+
* (these represent unfilled filter slots in the UI).
|
|
28
|
+
*
|
|
29
|
+
* Traversal order:
|
|
30
|
+
* 1. Recurse into child filters (`and`/`or`/`not`)
|
|
31
|
+
* 2. Apply the corresponding visitor callback with already-traversed children
|
|
32
|
+
* 3. For leaf nodes, call `leaf` directly
|
|
33
|
+
*/
|
|
34
|
+
export function traverseFilterSpec<
|
|
35
|
+
F extends FilterSpec<FilterSpecLeaf<unknown>, unknown, unknown>,
|
|
36
|
+
R,
|
|
37
|
+
>(
|
|
38
|
+
filter: F,
|
|
39
|
+
visitor: FilterSpecVisitor<InferFilterSpecCommonLeaf<F> & InferFilterSpecLeaf<F>, R>,
|
|
40
|
+
): R {
|
|
41
|
+
return traverseFilterSpecImpl(filter, visitor as FilterSpecVisitor<unknown, R>);
|
|
42
|
+
}
|
|
43
|
+
/** Internal implementation with simple generics for clean recursion. */
|
|
44
|
+
function traverseFilterSpecImpl<R>(
|
|
45
|
+
filter: FilterSpecNode<FilterSpecLeaf<unknown>, unknown, unknown>,
|
|
46
|
+
visitor: FilterSpecVisitor<unknown, R>,
|
|
47
|
+
): R {
|
|
48
|
+
switch (filter.type) {
|
|
49
|
+
case "and":
|
|
50
|
+
return visitor.and(
|
|
51
|
+
filter.filters
|
|
52
|
+
.filter((f) => f.type !== undefined)
|
|
53
|
+
.map((f) => traverseFilterSpecImpl(f, visitor)),
|
|
54
|
+
);
|
|
55
|
+
case "or":
|
|
56
|
+
return visitor.or(
|
|
57
|
+
filter.filters
|
|
58
|
+
.filter((f) => f.type !== undefined)
|
|
59
|
+
.map((f) => traverseFilterSpecImpl(f, visitor)),
|
|
60
|
+
);
|
|
61
|
+
case "not":
|
|
62
|
+
return visitor.not(traverseFilterSpecImpl(filter.filter, visitor));
|
|
63
|
+
default:
|
|
64
|
+
return visitor.leaf(filter);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Collects all column references (`column` and `rhs` fields) from filter leaves. */
|
|
69
|
+
export function collectFilterSpecColumns<
|
|
70
|
+
F extends FilterSpec<FilterSpecLeaf<unknown>, unknown, unknown>,
|
|
71
|
+
R extends InferFilterSpecLeafColumn<F> = InferFilterSpecLeafColumn<F>,
|
|
72
|
+
>(filter: F): R[] {
|
|
73
|
+
return traverseFilterSpec(filter, {
|
|
74
|
+
leaf: (leaf) => {
|
|
75
|
+
const cols: R[] = [];
|
|
76
|
+
if ("column" in leaf && leaf.column !== undefined) cols.push(leaf.column as R);
|
|
77
|
+
if ("rhs" in leaf && leaf.rhs !== undefined) cols.push(leaf.rhs as R);
|
|
78
|
+
return cols;
|
|
79
|
+
},
|
|
80
|
+
and: (results) => results.flat(),
|
|
81
|
+
or: (results) => results.flat(),
|
|
82
|
+
not: (result) => result,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { collectSpecQueryColumns, isBooleanExpression } from "@milaboratories/pl-model-common";
|
package/src/render/api.ts
CHANGED
|
@@ -28,6 +28,7 @@ import type {
|
|
|
28
28
|
} from "@milaboratories/pl-model-common";
|
|
29
29
|
import {
|
|
30
30
|
AnchoredIdDeriver,
|
|
31
|
+
collectSpecQueryColumns,
|
|
31
32
|
ensurePColumn,
|
|
32
33
|
extractAllColumns,
|
|
33
34
|
isDataInfo,
|
|
@@ -62,7 +63,6 @@ import type { APColumnSelectorWithSplit } from "./util/split_selectors";
|
|
|
62
63
|
import { patchInSetFilters } from "./util/pframe_upgraders";
|
|
63
64
|
import { allPColumnsReady } from "./util/pcolumn_data";
|
|
64
65
|
import type { PColumnDataUniversal } from "./internal";
|
|
65
|
-
import { collectQueryColumns } from "@milaboratories/pl-model-common";
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Helper function to match domain objects
|
|
@@ -682,7 +682,7 @@ export abstract class RenderCtxBase<Args, Data> {
|
|
|
682
682
|
}
|
|
683
683
|
|
|
684
684
|
public createPTableV2(def: PTableDefV2<PColumn<PColumnDataUniversal>>): PTableHandle | undefined {
|
|
685
|
-
const columns =
|
|
685
|
+
const columns = collectSpecQueryColumns(def.query);
|
|
686
686
|
this.verifyInlineAndExplicitColumnsSupport(columns);
|
|
687
687
|
if (!allPColumnsReady(columns)) return undefined;
|
|
688
688
|
return this.ctx.createPTableV2(mapPTableDefV2(def, (po) => transformPColumnData(po)));
|