@platforma-sdk/model 1.54.7 → 1.54.9
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/annotations/converter.cjs +2 -2
- package/dist/annotations/converter.cjs.map +1 -1
- package/dist/annotations/converter.js +2 -2
- package/dist/annotations/converter.js.map +1 -1
- package/dist/components/PlDataTable/index.d.ts +1 -1
- package/dist/components/PlDataTable/index.d.ts.map +1 -1
- package/dist/components/PlDataTable/state-migration.cjs +1 -1
- package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
- package/dist/components/PlDataTable/state-migration.js +2 -2
- package/dist/components/PlDataTable/state-migration.js.map +1 -1
- package/dist/components/PlDataTable/table.cjs +2 -3
- 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 +2 -3
- package/dist/components/PlDataTable/table.js.map +1 -1
- package/dist/components/PlDataTable/v5.d.ts +6 -5
- package/dist/components/PlDataTable/v5.d.ts.map +1 -1
- package/dist/filters/distill.cjs +22 -7
- package/dist/filters/distill.cjs.map +1 -1
- package/dist/filters/distill.d.ts +6 -5
- package/dist/filters/distill.d.ts.map +1 -1
- package/dist/filters/distill.js +22 -7
- package/dist/filters/distill.js.map +1 -1
- package/dist/filters/types.d.ts +1 -1
- package/dist/filters/types.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +4 -4
- package/src/annotations/converter.ts +2 -2
- package/src/components/PlDataTable/index.ts +2 -0
- package/src/components/PlDataTable/state-migration.ts +6 -6
- package/src/components/PlDataTable/table.ts +4 -5
- package/src/components/PlDataTable/v5.ts +5 -5
- package/src/filters/distill.test.ts +191 -0
- package/src/filters/distill.ts +26 -18
- package/src/filters/types.ts +0 -1
- package/dist/filters/converters/filterEmpty.cjs +0 -49
- package/dist/filters/converters/filterEmpty.cjs.map +0 -1
- package/dist/filters/converters/filterEmpty.d.ts +0 -4
- package/dist/filters/converters/filterEmpty.d.ts.map +0 -1
- package/dist/filters/converters/filterEmpty.js +0 -46
- package/dist/filters/converters/filterEmpty.js.map +0 -1
- package/src/filters/converters/filterEmpty.test.ts +0 -125
- package/src/filters/converters/filterEmpty.ts +0 -57
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
function filterPredicate(item) {
|
|
2
|
-
// No need to convert empty steps
|
|
3
|
-
if (item.type == null) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
if (item.type === "or") {
|
|
7
|
-
return item.filters.length > 0;
|
|
8
|
-
}
|
|
9
|
-
if (item.type === "and") {
|
|
10
|
-
return item.filters.length > 0;
|
|
11
|
-
}
|
|
12
|
-
if (item.type === "not") {
|
|
13
|
-
return filterPredicate(item.filter);
|
|
14
|
-
}
|
|
15
|
-
// Filter out any item that has undefined values in required fields
|
|
16
|
-
return !Object.values(item).some((v) => v === undefined);
|
|
17
|
-
}
|
|
18
|
-
function filterEmptyPieces(item) {
|
|
19
|
-
if (item.type === "or" || item.type === "and") {
|
|
20
|
-
const filtered = item.filters
|
|
21
|
-
.map(filterEmptyPieces)
|
|
22
|
-
.filter((f) => f !== null && filterPredicate(f));
|
|
23
|
-
return filtered.length === 0
|
|
24
|
-
? null
|
|
25
|
-
: {
|
|
26
|
-
...item,
|
|
27
|
-
filters: filtered,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
if (item.type === "not") {
|
|
31
|
-
const inner = filterEmptyPieces(item.filter);
|
|
32
|
-
return inner === null || !filterPredicate(inner)
|
|
33
|
-
? null
|
|
34
|
-
: {
|
|
35
|
-
...item,
|
|
36
|
-
filter: inner,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
if (!filterPredicate(item)) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
return item;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { filterEmptyPieces, filterPredicate };
|
|
46
|
-
//# sourceMappingURL=filterEmpty.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filterEmpty.js","sources":["../../../src/filters/converters/filterEmpty.ts"],"sourcesContent":["import { FilterSpec, FilterSpecLeaf } from \"@milaboratories/pl-model-common\";\n\nexport function filterPredicate(\n item: FilterSpec<FilterSpecLeaf<unknown>, unknown, unknown>,\n): boolean {\n // No need to convert empty steps\n if (item.type == null) {\n return false;\n }\n\n if (item.type === \"or\") {\n return item.filters.length > 0;\n }\n\n if (item.type === \"and\") {\n return item.filters.length > 0;\n }\n\n if (item.type === \"not\") {\n return filterPredicate(item.filter);\n }\n\n // Filter out any item that has undefined values in required fields\n return !Object.values(item).some((v) => v === undefined);\n}\n\nexport function filterEmptyPieces<T extends FilterSpec<FilterSpecLeaf<unknown>, unknown, unknown>>(\n item: T,\n): null | T {\n if (item.type === \"or\" || item.type === \"and\") {\n const filtered = item.filters\n .map(filterEmptyPieces)\n .filter((f): f is T => f !== null && filterPredicate(f));\n\n return filtered.length === 0\n ? null\n : {\n ...item,\n filters: filtered,\n };\n }\n if (item.type === \"not\") {\n const inner = filterEmptyPieces(item.filter);\n return inner === null || !filterPredicate(inner)\n ? null\n : {\n ...item,\n filter: inner,\n };\n }\n\n if (!filterPredicate(item)) {\n return null;\n }\n\n return item;\n}\n"],"names":[],"mappings":"AAEM,SAAU,eAAe,CAC7B,IAA2D,EAAA;;AAG3D,IAAA,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE;AACrB,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;AACtB,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;IAChC;AAEA,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE;AACvB,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;IAChC;AAEA,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE;AACvB,QAAA,OAAO,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;IACrC;;AAGA,IAAA,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC;AAC1D;AAEM,SAAU,iBAAiB,CAC/B,IAAO,EAAA;AAEP,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE;AAC7C,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC;aACnB,GAAG,CAAC,iBAAiB;AACrB,aAAA,MAAM,CAAC,CAAC,CAAC,KAAa,CAAC,KAAK,IAAI,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC;AAE1D,QAAA,OAAO,QAAQ,CAAC,MAAM,KAAK;AACzB,cAAE;AACF,cAAE;AACE,gBAAA,GAAG,IAAI;AACP,gBAAA,OAAO,EAAE,QAAQ;aAClB;IACP;AACA,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE;QACvB,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC;QAC5C,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,eAAe,CAAC,KAAK;AAC7C,cAAE;AACF,cAAE;AACE,gBAAA,GAAG,IAAI;AACP,gBAAA,MAAM,EAAE,KAAK;aACd;IACP;AAEA,IAAA,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;AAC1B,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,OAAO,IAAI;AACb;;;;"}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import type { FilterSpec, FilterSpecLeaf } from "@milaboratories/pl-model-common";
|
|
3
|
-
import { filterEmptyPieces, filterPredicate } from "./filterEmpty";
|
|
4
|
-
|
|
5
|
-
type F = FilterSpec<FilterSpecLeaf<string>>;
|
|
6
|
-
|
|
7
|
-
const leaf: F = { type: "equal", column: "c1", x: 1 };
|
|
8
|
-
const emptyLeaf: F = { type: undefined };
|
|
9
|
-
const incompleteLeaf: F = { type: "equal", column: "c1", x: undefined as unknown as number };
|
|
10
|
-
|
|
11
|
-
describe("filterPredicate", () => {
|
|
12
|
-
it("returns false for undefined type", () => {
|
|
13
|
-
expect(filterPredicate(emptyLeaf)).toBe(false);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("returns true for a valid leaf", () => {
|
|
17
|
-
expect(filterPredicate(leaf)).toBe(true);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("returns false for a leaf with undefined values", () => {
|
|
21
|
-
expect(filterPredicate(incompleteLeaf)).toBe(false);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("returns false for and with empty filters", () => {
|
|
25
|
-
expect(filterPredicate({ type: "and", filters: [] })).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("returns true for and with filters", () => {
|
|
29
|
-
expect(filterPredicate({ type: "and", filters: [leaf] })).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("returns false for or with empty filters", () => {
|
|
33
|
-
expect(filterPredicate({ type: "or", filters: [] })).toBe(false);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("returns false for not wrapping an empty filter", () => {
|
|
37
|
-
expect(filterPredicate({ type: "not", filter: emptyLeaf })).toBe(false);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("returns true for not wrapping a valid filter", () => {
|
|
41
|
-
expect(filterPredicate({ type: "not", filter: leaf })).toBe(true);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe("filterEmptyPieces", () => {
|
|
46
|
-
it("returns valid leaf as-is", () => {
|
|
47
|
-
expect(filterEmptyPieces(leaf)).toEqual(leaf);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("returns null for empty leaf", () => {
|
|
51
|
-
expect(filterEmptyPieces(emptyLeaf)).toBeNull();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("returns null for incomplete leaf", () => {
|
|
55
|
-
expect(filterEmptyPieces(incompleteLeaf)).toBeNull();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// --- and ---
|
|
59
|
-
|
|
60
|
-
it("filters out empty children from and", () => {
|
|
61
|
-
const filter: F = { type: "and", filters: [emptyLeaf, leaf, emptyLeaf] };
|
|
62
|
-
expect(filterEmptyPieces(filter)).toEqual({ type: "and", filters: [leaf] });
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("returns null when all and children are empty", () => {
|
|
66
|
-
const filter: F = { type: "and", filters: [emptyLeaf, emptyLeaf] };
|
|
67
|
-
expect(filterEmptyPieces(filter)).toBeNull();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("returns null for and with no children", () => {
|
|
71
|
-
const filter: F = { type: "and", filters: [] };
|
|
72
|
-
expect(filterEmptyPieces(filter)).toBeNull();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// --- or ---
|
|
76
|
-
|
|
77
|
-
it("filters out empty children from or", () => {
|
|
78
|
-
const leaf2: F = { type: "equal", column: "c2", x: 2 };
|
|
79
|
-
const filter: F = { type: "or", filters: [leaf, emptyLeaf, leaf2] };
|
|
80
|
-
expect(filterEmptyPieces(filter)).toEqual({ type: "or", filters: [leaf, leaf2] });
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("returns null when all or children are empty", () => {
|
|
84
|
-
const filter: F = { type: "or", filters: [emptyLeaf] };
|
|
85
|
-
expect(filterEmptyPieces(filter)).toBeNull();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// --- not ---
|
|
89
|
-
|
|
90
|
-
it("preserves not with valid inner filter", () => {
|
|
91
|
-
const filter: F = { type: "not", filter: leaf };
|
|
92
|
-
expect(filterEmptyPieces(filter)).toEqual({ type: "not", filter: leaf });
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("returns null for not wrapping an empty filter", () => {
|
|
96
|
-
const filter: F = { type: "not", filter: emptyLeaf };
|
|
97
|
-
expect(filterEmptyPieces(filter)).toBeNull();
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// --- nested collapse ---
|
|
101
|
-
|
|
102
|
-
it("returns null when nested and collapses", () => {
|
|
103
|
-
const filter: F = {
|
|
104
|
-
type: "not",
|
|
105
|
-
filter: { type: "and", filters: [emptyLeaf] },
|
|
106
|
-
};
|
|
107
|
-
expect(filterEmptyPieces(filter)).toBeNull();
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("returns null when parent and has only a collapsing child", () => {
|
|
111
|
-
const filter: F = {
|
|
112
|
-
type: "and",
|
|
113
|
-
filters: [{ type: "or", filters: [emptyLeaf] }],
|
|
114
|
-
};
|
|
115
|
-
expect(filterEmptyPieces(filter)).toBeNull();
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it("keeps valid siblings when one child collapses", () => {
|
|
119
|
-
const filter: F = {
|
|
120
|
-
type: "and",
|
|
121
|
-
filters: [{ type: "or", filters: [emptyLeaf] }, leaf],
|
|
122
|
-
};
|
|
123
|
-
expect(filterEmptyPieces(filter)).toEqual({ type: "and", filters: [leaf] });
|
|
124
|
-
});
|
|
125
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { FilterSpec, FilterSpecLeaf } from "@milaboratories/pl-model-common";
|
|
2
|
-
|
|
3
|
-
export function filterPredicate(
|
|
4
|
-
item: FilterSpec<FilterSpecLeaf<unknown>, unknown, unknown>,
|
|
5
|
-
): boolean {
|
|
6
|
-
// No need to convert empty steps
|
|
7
|
-
if (item.type == null) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (item.type === "or") {
|
|
12
|
-
return item.filters.length > 0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (item.type === "and") {
|
|
16
|
-
return item.filters.length > 0;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (item.type === "not") {
|
|
20
|
-
return filterPredicate(item.filter);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Filter out any item that has undefined values in required fields
|
|
24
|
-
return !Object.values(item).some((v) => v === undefined);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function filterEmptyPieces<T extends FilterSpec<FilterSpecLeaf<unknown>, unknown, unknown>>(
|
|
28
|
-
item: T,
|
|
29
|
-
): null | T {
|
|
30
|
-
if (item.type === "or" || item.type === "and") {
|
|
31
|
-
const filtered = item.filters
|
|
32
|
-
.map(filterEmptyPieces)
|
|
33
|
-
.filter((f): f is T => f !== null && filterPredicate(f));
|
|
34
|
-
|
|
35
|
-
return filtered.length === 0
|
|
36
|
-
? null
|
|
37
|
-
: {
|
|
38
|
-
...item,
|
|
39
|
-
filters: filtered,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if (item.type === "not") {
|
|
43
|
-
const inner = filterEmptyPieces(item.filter);
|
|
44
|
-
return inner === null || !filterPredicate(inner)
|
|
45
|
-
? null
|
|
46
|
-
: {
|
|
47
|
-
...item,
|
|
48
|
-
filter: inner,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (!filterPredicate(item)) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return item;
|
|
57
|
-
}
|