@platforma-sdk/model 1.54.10 → 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 +11 -2
- 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 +12 -3
- package/dist/components/PlDataTable/table.js.map +1 -1
- package/dist/components/PlDataTable/v5.d.ts +7 -4
- package/dist/components/PlDataTable/v5.d.ts.map +1 -1
- package/dist/filters/converters/filterToQuery.cjs +3 -4
- 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 +3 -4
- package/dist/filters/converters/filterToQuery.js.map +1 -1
- 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.map +1 -1
- package/dist/filters/traverse.cjs +7 -3
- package/dist/filters/traverse.cjs.map +1 -1
- package/dist/filters/traverse.d.ts +14 -12
- package/dist/filters/traverse.d.ts.map +1 -1
- package/dist/filters/traverse.js +7 -3
- package/dist/filters/traverse.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +6 -6
- package/src/components/PlDataTable/state-migration.ts +4 -4
- package/src/components/PlDataTable/table.ts +16 -3
- package/src/components/PlDataTable/v5.ts +9 -5
- package/src/filters/converters/filterToQuery.ts +8 -7
- package/src/filters/distill.ts +19 -11
- package/src/filters/traverse.ts +44 -24
package/src/filters/traverse.ts
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
import type {
|
|
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
|
+
};
|
|
2
22
|
|
|
3
23
|
/**
|
|
4
24
|
* Recursively traverses a FilterSpec tree bottom-up, applying visitor callbacks.
|
|
@@ -11,50 +31,50 @@ import type { FilterSpecLeaf, FilterSpecNode } from "@milaboratories/pl-model-co
|
|
|
11
31
|
* 2. Apply the corresponding visitor callback with already-traversed children
|
|
12
32
|
* 3. For leaf nodes, call `leaf` directly
|
|
13
33
|
*/
|
|
14
|
-
export function traverseFilterSpec<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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>,
|
|
26
47
|
): R {
|
|
27
48
|
switch (filter.type) {
|
|
28
49
|
case "and":
|
|
29
50
|
return visitor.and(
|
|
30
51
|
filter.filters
|
|
31
52
|
.filter((f) => f.type !== undefined)
|
|
32
|
-
.map((f) =>
|
|
53
|
+
.map((f) => traverseFilterSpecImpl(f, visitor)),
|
|
33
54
|
);
|
|
34
55
|
case "or":
|
|
35
56
|
return visitor.or(
|
|
36
57
|
filter.filters
|
|
37
58
|
.filter((f) => f.type !== undefined)
|
|
38
|
-
.map((f) =>
|
|
59
|
+
.map((f) => traverseFilterSpecImpl(f, visitor)),
|
|
39
60
|
);
|
|
40
61
|
case "not":
|
|
41
|
-
return visitor.not(
|
|
62
|
+
return visitor.not(traverseFilterSpecImpl(filter.filter, visitor));
|
|
42
63
|
default:
|
|
43
|
-
return visitor.leaf(filter
|
|
64
|
+
return visitor.leaf(filter);
|
|
44
65
|
}
|
|
45
66
|
}
|
|
46
67
|
|
|
47
68
|
/** Collects all column references (`column` and `rhs` fields) from filter leaves. */
|
|
48
69
|
export function collectFilterSpecColumns<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
>(filter: FilterSpecNode<Leaf, CommonNode, CommonLeaf>): string[] {
|
|
70
|
+
F extends FilterSpec<FilterSpecLeaf<unknown>, unknown, unknown>,
|
|
71
|
+
R extends InferFilterSpecLeafColumn<F> = InferFilterSpecLeafColumn<F>,
|
|
72
|
+
>(filter: F): R[] {
|
|
53
73
|
return traverseFilterSpec(filter, {
|
|
54
74
|
leaf: (leaf) => {
|
|
55
|
-
const cols:
|
|
56
|
-
if ("column" in leaf && leaf.column !== undefined) cols.push(leaf.column as
|
|
57
|
-
if ("rhs" in leaf && leaf.rhs !== undefined) cols.push(leaf.rhs as
|
|
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);
|
|
58
78
|
return cols;
|
|
59
79
|
},
|
|
60
80
|
and: (results) => results.flat(),
|