@platforma-sdk/model 1.53.11 → 1.53.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/annotations/converter.cjs +11 -11
- package/dist/annotations/converter.cjs.map +1 -1
- package/dist/annotations/converter.d.ts +1 -1
- package/dist/annotations/converter.d.ts.map +1 -1
- package/dist/annotations/converter.js +11 -11
- package/dist/annotations/converter.js.map +1 -1
- package/dist/annotations/index.d.ts +2 -2
- package/dist/annotations/types.d.ts +4 -4
- package/dist/bconfig/index.d.ts +5 -5
- package/dist/bconfig/lambdas.d.ts +7 -7
- package/dist/bconfig/lambdas.d.ts.map +1 -1
- package/dist/bconfig/normalization.cjs.map +1 -1
- package/dist/bconfig/normalization.d.ts +3 -3
- package/dist/bconfig/normalization.js.map +1 -1
- package/dist/bconfig/types.cjs.map +1 -1
- package/dist/bconfig/types.d.ts +2 -2
- package/dist/bconfig/types.d.ts.map +1 -1
- package/dist/bconfig/types.js.map +1 -1
- package/dist/bconfig/util.d.ts +4 -4
- package/dist/bconfig/v3.d.ts +3 -3
- package/dist/block_api_v1.d.ts +2 -2
- package/dist/block_api_v1.d.ts.map +1 -1
- package/dist/block_api_v2.d.ts +2 -2
- package/dist/block_api_v2.d.ts.map +1 -1
- package/dist/block_api_v3.d.ts +3 -3
- package/dist/block_migrations.cjs +10 -10
- package/dist/block_migrations.cjs.map +1 -1
- package/dist/block_migrations.d.ts.map +1 -1
- package/dist/block_migrations.js +10 -10
- package/dist/block_migrations.js.map +1 -1
- package/dist/block_model.cjs +11 -11
- package/dist/block_model.cjs.map +1 -1
- package/dist/block_model.d.ts +8 -8
- package/dist/block_model.d.ts.map +1 -1
- package/dist/block_model.js +11 -11
- package/dist/block_model.js.map +1 -1
- package/dist/block_state_patch.d.ts +2 -2
- package/dist/block_state_util.cjs +1 -1
- package/dist/block_state_util.cjs.map +1 -1
- package/dist/block_state_util.d.ts +3 -3
- package/dist/block_state_util.js +1 -1
- package/dist/block_state_util.js.map +1 -1
- package/dist/block_storage.cjs +10 -10
- package/dist/block_storage.cjs.map +1 -1
- package/dist/block_storage.d.ts +2 -2
- package/dist/block_storage.d.ts.map +1 -1
- package/dist/block_storage.js +10 -10
- package/dist/block_storage.js.map +1 -1
- package/dist/block_storage_vm.cjs +22 -22
- package/dist/block_storage_vm.cjs.map +1 -1
- package/dist/block_storage_vm.d.ts +1 -1
- package/dist/block_storage_vm.d.ts.map +1 -1
- package/dist/block_storage_vm.js +22 -22
- package/dist/block_storage_vm.js.map +1 -1
- package/dist/builder.cjs +32 -23
- package/dist/builder.cjs.map +1 -1
- package/dist/builder.d.ts +7 -7
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +32 -23
- package/dist/builder.js.map +1 -1
- package/dist/components/PFrameForGraphs.cjs +7 -6
- package/dist/components/PFrameForGraphs.cjs.map +1 -1
- package/dist/components/PFrameForGraphs.d.ts +4 -4
- package/dist/components/PFrameForGraphs.d.ts.map +1 -1
- package/dist/components/PFrameForGraphs.js +7 -6
- package/dist/components/PFrameForGraphs.js.map +1 -1
- package/dist/components/PlAnnotations/filter.d.ts +14 -14
- package/dist/components/PlAnnotations/filter.d.ts.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.cjs +46 -46
- package/dist/components/PlAnnotations/filters_ui.cjs.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.d.ts +10 -34
- package/dist/components/PlAnnotations/filters_ui.d.ts.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.js +46 -46
- package/dist/components/PlAnnotations/filters_ui.js.map +1 -1
- package/dist/components/PlAnnotations/index.d.ts +2 -2
- package/dist/components/PlAnnotations/types.d.ts +2 -2
- package/dist/components/PlDataTable.cjs +19 -20
- package/dist/components/PlDataTable.cjs.map +1 -1
- package/dist/components/PlDataTable.d.ts +27 -27
- package/dist/components/PlDataTable.d.ts.map +1 -1
- package/dist/components/PlDataTable.js +19 -20
- package/dist/components/PlDataTable.js.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.cjs +2 -2
- package/dist/components/PlMultiSequenceAlignment.cjs.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.d.ts +6 -6
- package/dist/components/PlMultiSequenceAlignment.d.ts.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.js +2 -2
- package/dist/components/PlMultiSequenceAlignment.js.map +1 -1
- package/dist/components/PlSelectionModel.cjs.map +1 -1
- package/dist/components/PlSelectionModel.d.ts +1 -1
- package/dist/components/PlSelectionModel.js.map +1 -1
- package/dist/components/index.d.ts +5 -5
- package/dist/config/actions.cjs +39 -39
- package/dist/config/actions.cjs.map +1 -1
- package/dist/config/actions.d.ts +9 -9
- package/dist/config/actions.d.ts.map +1 -1
- package/dist/config/actions.js +39 -39
- package/dist/config/actions.js.map +1 -1
- package/dist/config/actions_kinds.d.ts +30 -30
- package/dist/config/actions_kinds.d.ts.map +1 -1
- package/dist/config/index.d.ts +6 -6
- package/dist/config/model.d.ts +28 -28
- package/dist/config/model_meta.d.ts +1 -1
- package/dist/config/type_engine.d.ts +3 -3
- package/dist/config/type_util.d.ts +2 -2
- package/dist/env_value.cjs +1 -1
- package/dist/env_value.cjs.map +1 -1
- package/dist/env_value.js +1 -1
- package/dist/env_value.js.map +1 -1
- package/dist/filters/converter.cjs +36 -32
- package/dist/filters/converter.cjs.map +1 -1
- package/dist/filters/converter.d.ts +2 -2
- package/dist/filters/converter.d.ts.map +1 -1
- package/dist/filters/converter.js +36 -32
- package/dist/filters/converter.js.map +1 -1
- package/dist/filters/index.d.ts +2 -2
- package/dist/filters/types.d.ts +33 -33
- package/dist/filters/types.d.ts.map +1 -1
- package/dist/index.d.ts +24 -24
- package/dist/internal.cjs +7 -7
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.ts +4 -4
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +7 -7
- package/dist/internal.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/pframe.cjs +1 -1
- package/dist/pframe.cjs.map +1 -1
- package/dist/pframe.d.ts +1 -1
- package/dist/pframe.js +1 -1
- package/dist/pframe.js.map +1 -1
- package/dist/pframe_utils/columns.cjs +23 -15
- package/dist/pframe_utils/columns.cjs.map +1 -1
- package/dist/pframe_utils/columns.d.ts +3 -3
- package/dist/pframe_utils/columns.d.ts.map +1 -1
- package/dist/pframe_utils/columns.js +23 -15
- package/dist/pframe_utils/columns.js.map +1 -1
- package/dist/pframe_utils/index.cjs +25 -25
- package/dist/pframe_utils/index.cjs.map +1 -1
- package/dist/pframe_utils/index.d.ts +3 -3
- package/dist/pframe_utils/index.d.ts.map +1 -1
- package/dist/pframe_utils/index.js +25 -25
- package/dist/pframe_utils/index.js.map +1 -1
- package/dist/platforma.d.ts +7 -7
- package/dist/platforma.d.ts.map +1 -1
- package/dist/raw_globals.cjs +4 -1
- package/dist/raw_globals.cjs.map +1 -1
- package/dist/raw_globals.d.ts +2 -2
- package/dist/raw_globals.d.ts.map +1 -1
- package/dist/raw_globals.js +4 -1
- package/dist/raw_globals.js.map +1 -1
- package/dist/ref_util.cjs +4 -4
- package/dist/ref_util.cjs.map +1 -1
- package/dist/ref_util.d.ts +1 -1
- package/dist/ref_util.js +4 -4
- package/dist/ref_util.js.map +1 -1
- package/dist/render/accessor.cjs +24 -24
- package/dist/render/accessor.cjs.map +1 -1
- package/dist/render/accessor.d.ts +10 -10
- package/dist/render/accessor.d.ts.map +1 -1
- package/dist/render/accessor.js +24 -24
- package/dist/render/accessor.js.map +1 -1
- package/dist/render/api.cjs +23 -23
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +11 -11
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/api.js +23 -23
- package/dist/render/api.js.map +1 -1
- package/dist/render/future.cjs.map +1 -1
- package/dist/render/future.d.ts +1 -1
- package/dist/render/future.js.map +1 -1
- package/dist/render/index.d.ts +6 -6
- package/dist/render/internal.cjs +4 -4
- package/dist/render/internal.cjs.map +1 -1
- package/dist/render/internal.d.ts +7 -7
- package/dist/render/internal.d.ts.map +1 -1
- package/dist/render/internal.js +4 -4
- package/dist/render/internal.js.map +1 -1
- package/dist/render/traversal_ops.d.ts +1 -1
- package/dist/render/util/axis_filtering.cjs +48 -44
- package/dist/render/util/axis_filtering.cjs.map +1 -1
- package/dist/render/util/axis_filtering.d.ts +2 -2
- package/dist/render/util/axis_filtering.js +48 -44
- package/dist/render/util/axis_filtering.js.map +1 -1
- package/dist/render/util/column_collection.cjs +42 -35
- package/dist/render/util/column_collection.cjs.map +1 -1
- package/dist/render/util/column_collection.d.ts +4 -4
- package/dist/render/util/column_collection.d.ts.map +1 -1
- package/dist/render/util/column_collection.js +42 -35
- package/dist/render/util/column_collection.js.map +1 -1
- package/dist/render/util/index.d.ts +4 -4
- package/dist/render/util/label.cjs +15 -21
- package/dist/render/util/label.cjs.map +1 -1
- package/dist/render/util/label.d.ts +2 -2
- package/dist/render/util/label.d.ts.map +1 -1
- package/dist/render/util/label.js +15 -21
- package/dist/render/util/label.js.map +1 -1
- package/dist/render/util/pcolumn_data.cjs +56 -54
- package/dist/render/util/pcolumn_data.cjs.map +1 -1
- package/dist/render/util/pcolumn_data.d.ts +5 -5
- package/dist/render/util/pcolumn_data.d.ts.map +1 -1
- package/dist/render/util/pcolumn_data.js +56 -54
- package/dist/render/util/pcolumn_data.js.map +1 -1
- package/dist/render/util/pframe_upgraders.cjs +6 -6
- package/dist/render/util/pframe_upgraders.cjs.map +1 -1
- package/dist/render/util/pframe_upgraders.d.ts +1 -1
- package/dist/render/util/pframe_upgraders.d.ts.map +1 -1
- package/dist/render/util/pframe_upgraders.js +6 -6
- package/dist/render/util/pframe_upgraders.js.map +1 -1
- package/dist/render/util/split_selectors.d.ts +1 -1
- package/dist/render/util/split_selectors.d.ts.map +1 -1
- package/dist/sdk_info.cjs.map +1 -1
- package/dist/sdk_info.js.map +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +24 -22
- package/src/annotations/converter.test.ts +98 -101
- package/src/annotations/converter.ts +21 -17
- package/src/annotations/index.ts +2 -2
- package/src/annotations/types.ts +4 -4
- package/src/bconfig/index.ts +5 -5
- package/src/bconfig/lambdas.ts +10 -12
- package/src/bconfig/normalization.ts +5 -5
- package/src/bconfig/types.ts +3 -5
- package/src/bconfig/util.ts +3 -3
- package/src/bconfig/v3.ts +3 -3
- package/src/block_api_v1.ts +7 -3
- package/src/block_api_v2.ts +7 -3
- package/src/block_api_v3.ts +3 -3
- package/src/block_migrations.test.ts +66 -67
- package/src/block_migrations.ts +16 -16
- package/src/block_model.ts +76 -140
- package/src/block_state_patch.ts +2 -2
- package/src/block_state_util.ts +4 -4
- package/src/block_storage.test.ts +106 -99
- package/src/block_storage.ts +22 -25
- package/src/block_storage_vm.ts +41 -35
- package/src/builder.ts +107 -95
- package/src/components/PFrameForGraphs.test.ts +261 -255
- package/src/components/PFrameForGraphs.ts +35 -22
- package/src/components/PlAnnotations/filter.ts +21 -15
- package/src/components/PlAnnotations/filters_ui.test.ts +230 -73
- package/src/components/PlAnnotations/filters_ui.ts +138 -105
- package/src/components/PlAnnotations/index.ts +2 -2
- package/src/components/PlAnnotations/types.ts +2 -2
- package/src/components/PlDataTable.ts +177 -164
- package/src/components/PlMultiSequenceAlignment.ts +11 -18
- package/src/components/PlSelectionModel.ts +1 -1
- package/src/components/index.ts +5 -5
- package/src/config/actions.ts +64 -59
- package/src/config/actions_kinds.ts +38 -34
- package/src/config/index.ts +6 -6
- package/src/config/model.ts +28 -28
- package/src/config/model_meta.ts +1 -1
- package/src/config/type_engine.ts +3 -3
- package/src/config/type_util.ts +2 -2
- package/src/env_value.ts +2 -2
- package/src/filters/converter.test.ts +185 -144
- package/src/filters/converter.ts +47 -35
- package/src/filters/index.ts +2 -2
- package/src/filters/types.ts +44 -39
- package/src/global.d.ts +1 -1
- package/src/index.ts +24 -24
- package/src/internal.ts +27 -17
- package/src/pframe.ts +3 -3
- package/src/pframe_utils/columns.ts +81 -31
- package/src/pframe_utils/index.ts +65 -43
- package/src/platforma.ts +44 -21
- package/src/raw_globals.ts +13 -7
- package/src/ref_util.ts +6 -6
- package/src/render/accessor.ts +43 -44
- package/src/render/api.ts +102 -78
- package/src/render/future.ts +2 -2
- package/src/render/index.ts +6 -6
- package/src/render/internal.ts +11 -12
- package/src/render/traversal_ops.ts +1 -1
- package/src/render/util/axis_filtering.ts +67 -52
- package/src/render/util/column_collection.ts +171 -91
- package/src/render/util/index.ts +4 -4
- package/src/render/util/label.test.ts +139 -139
- package/src/render/util/label.ts +42 -33
- package/src/render/util/pcolumn_data.ts +111 -75
- package/src/render/util/pframe_upgraders.ts +24 -13
- package/src/render/util/split_selectors.ts +6 -1
- package/src/sdk_info.ts +1 -1
- package/src/typing.test.ts +56 -56
- package/src/version.ts +1 -1
|
@@ -1,336 +1,377 @@
|
|
|
1
|
-
import type { SUniversalPColumnId } from
|
|
2
|
-
import { describe, expect, it } from
|
|
3
|
-
import { convertFilterUiToExpressions } from
|
|
4
|
-
import { FilterSpec } from
|
|
1
|
+
import type { SUniversalPColumnId } from "@milaboratories/pl-model-common";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { convertFilterUiToExpressions } from "./converter";
|
|
4
|
+
import { FilterSpec } from "./types";
|
|
5
5
|
|
|
6
|
-
describe(
|
|
6
|
+
describe("convertFilterUiToExpressions", () => {
|
|
7
7
|
it('should compile "or" filter to ptabler expression', () => {
|
|
8
8
|
const uiFilter: FilterSpec = {
|
|
9
|
-
type:
|
|
9
|
+
type: "or",
|
|
10
10
|
filters: [
|
|
11
|
-
{ type:
|
|
12
|
-
{ type:
|
|
11
|
+
{ type: "isNA", column: "colA" as unknown as SUniversalPColumnId },
|
|
12
|
+
{ type: "patternEquals", column: "colB" as unknown as SUniversalPColumnId, value: "test" },
|
|
13
13
|
],
|
|
14
14
|
};
|
|
15
15
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
16
|
-
expect(result.type).toBe(
|
|
16
|
+
expect(result.type).toBe("or");
|
|
17
17
|
expect((result as any).operands).toHaveLength(2);
|
|
18
|
-
expect((result as any).operands[0].type).toBe(
|
|
19
|
-
expect((result as any).operands[1].type).toBe(
|
|
18
|
+
expect((result as any).operands[0].type).toBe("is_na");
|
|
19
|
+
expect((result as any).operands[1].type).toBe("eq");
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it('should compile "and" filter to ptabler expression', () => {
|
|
23
23
|
const uiFilter: FilterSpec = {
|
|
24
|
-
type:
|
|
24
|
+
type: "and",
|
|
25
25
|
filters: [
|
|
26
|
-
{ type:
|
|
27
|
-
{ type:
|
|
26
|
+
{ type: "isNA", column: "colA" as unknown as SUniversalPColumnId },
|
|
27
|
+
{ type: "greaterThan", column: "colNum" as unknown as SUniversalPColumnId, x: 10 },
|
|
28
28
|
],
|
|
29
29
|
};
|
|
30
30
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
31
|
-
expect(result.type).toBe(
|
|
31
|
+
expect(result.type).toBe("and");
|
|
32
32
|
expect((result as any).operands).toHaveLength(2);
|
|
33
|
-
expect((result as any).operands[0].type).toBe(
|
|
34
|
-
expect((result as any).operands[1].type).toBe(
|
|
33
|
+
expect((result as any).operands[0].type).toBe("is_na");
|
|
34
|
+
expect((result as any).operands[1].type).toBe("gt");
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
it('should compile "not" filter to ptabler expression', () => {
|
|
38
38
|
const uiFilter: FilterSpec = {
|
|
39
|
-
type:
|
|
40
|
-
filter: { type:
|
|
39
|
+
type: "not",
|
|
40
|
+
filter: { type: "isNA", column: "colA" as unknown as SUniversalPColumnId },
|
|
41
41
|
};
|
|
42
42
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
43
|
-
expect(result.type).toBe(
|
|
44
|
-
expect((result as any).value.type).toBe(
|
|
45
|
-
expect((result as any).value.value.type).toBe(
|
|
46
|
-
expect((result as any).value.value.name).toBe(
|
|
43
|
+
expect(result.type).toBe("not");
|
|
44
|
+
expect((result as any).value.type).toBe("is_na");
|
|
45
|
+
expect((result as any).value.value.type).toBe("col");
|
|
46
|
+
expect((result as any).value.value.name).toBe("colA");
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
it('should compile "isNA" filter to ptabler expression', () => {
|
|
50
|
-
const uiFilter: FilterSpec = { type:
|
|
50
|
+
const uiFilter: FilterSpec = { type: "isNA", column: "colA" as unknown as SUniversalPColumnId };
|
|
51
51
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
52
52
|
expect(result as any).toEqual({
|
|
53
|
-
type:
|
|
54
|
-
value: { type:
|
|
53
|
+
type: "is_na",
|
|
54
|
+
value: { type: "col", name: "colA" },
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
it('should compile "isNotNA" filter to ptabler expression', () => {
|
|
59
|
-
const uiFilter: FilterSpec = {
|
|
59
|
+
const uiFilter: FilterSpec = {
|
|
60
|
+
type: "isNotNA",
|
|
61
|
+
column: "colA" as unknown as SUniversalPColumnId,
|
|
62
|
+
};
|
|
60
63
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
61
64
|
expect(result as any).toEqual({
|
|
62
|
-
type:
|
|
63
|
-
value: { type:
|
|
65
|
+
type: "is_not_na",
|
|
66
|
+
value: { type: "col", name: "colA" },
|
|
64
67
|
});
|
|
65
68
|
});
|
|
66
69
|
|
|
67
70
|
it('should compile "patternEquals" filter to ptabler expression', () => {
|
|
68
|
-
const uiFilter: FilterSpec = {
|
|
71
|
+
const uiFilter: FilterSpec = {
|
|
72
|
+
type: "patternEquals",
|
|
73
|
+
column: "colB" as unknown as SUniversalPColumnId,
|
|
74
|
+
value: "abc",
|
|
75
|
+
};
|
|
69
76
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
70
77
|
expect(result as any).toEqual({
|
|
71
|
-
type:
|
|
72
|
-
lhs: { type:
|
|
73
|
-
rhs: { type:
|
|
78
|
+
type: "eq",
|
|
79
|
+
lhs: { type: "col", name: "colB" },
|
|
80
|
+
rhs: { type: "const", value: "abc" },
|
|
74
81
|
});
|
|
75
82
|
});
|
|
76
83
|
|
|
77
84
|
it('should compile "patternNotEquals" filter to ptabler expression', () => {
|
|
78
|
-
const uiFilter: FilterSpec = {
|
|
85
|
+
const uiFilter: FilterSpec = {
|
|
86
|
+
type: "patternNotEquals",
|
|
87
|
+
column: "colB" as unknown as SUniversalPColumnId,
|
|
88
|
+
value: "abc",
|
|
89
|
+
};
|
|
79
90
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
80
91
|
expect(result as any).toEqual({
|
|
81
|
-
type:
|
|
82
|
-
lhs: { type:
|
|
83
|
-
rhs: { type:
|
|
92
|
+
type: "neq",
|
|
93
|
+
lhs: { type: "col", name: "colB" },
|
|
94
|
+
rhs: { type: "const", value: "abc" },
|
|
84
95
|
});
|
|
85
96
|
});
|
|
86
97
|
|
|
87
98
|
it('should compile "patternContainSubsequence" filter to ptabler expression', () => {
|
|
88
|
-
const uiFilter: FilterSpec = {
|
|
99
|
+
const uiFilter: FilterSpec = {
|
|
100
|
+
type: "patternContainSubsequence",
|
|
101
|
+
column: "colC" as unknown as SUniversalPColumnId,
|
|
102
|
+
value: "sub",
|
|
103
|
+
};
|
|
89
104
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
90
|
-
expect(result.type).toBe(
|
|
91
|
-
expect((result as any).value).toEqual({ type:
|
|
92
|
-
expect((result as any).pattern).toEqual({ type:
|
|
105
|
+
expect(result.type).toBe("str_contains");
|
|
106
|
+
expect((result as any).value).toEqual({ type: "col", name: "colC" });
|
|
107
|
+
expect((result as any).pattern).toEqual({ type: "const", value: "sub" });
|
|
93
108
|
});
|
|
94
109
|
|
|
95
110
|
it('should compile "patternNotContainSubsequence" filter to ptabler expression', () => {
|
|
96
|
-
const uiFilter: FilterSpec = {
|
|
111
|
+
const uiFilter: FilterSpec = {
|
|
112
|
+
type: "patternNotContainSubsequence",
|
|
113
|
+
column: "colC" as unknown as SUniversalPColumnId,
|
|
114
|
+
value: "sub",
|
|
115
|
+
};
|
|
97
116
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
98
|
-
expect(result.type).toBe(
|
|
99
|
-
expect((result as any).value.type).toBe(
|
|
100
|
-
expect((result as any).value.value).toEqual({ type:
|
|
101
|
-
expect((result as any).value.pattern).toEqual({ type:
|
|
117
|
+
expect(result.type).toBe("not");
|
|
118
|
+
expect((result as any).value.type).toBe("str_contains");
|
|
119
|
+
expect((result as any).value.value).toEqual({ type: "col", name: "colC" });
|
|
120
|
+
expect((result as any).value.pattern).toEqual({ type: "const", value: "sub" });
|
|
102
121
|
});
|
|
103
122
|
|
|
104
|
-
it(
|
|
123
|
+
it("should compile numerical comparison filters to ptabler expressions", () => {
|
|
105
124
|
const testCases = [
|
|
106
|
-
{ type:
|
|
107
|
-
{ type:
|
|
108
|
-
{ type:
|
|
109
|
-
{ type:
|
|
110
|
-
{ type:
|
|
125
|
+
{ type: "equal" as const, expected: "eq" },
|
|
126
|
+
{ type: "lessThan" as const, expected: "lt" },
|
|
127
|
+
{ type: "greaterThan" as const, expected: "gt" },
|
|
128
|
+
{ type: "lessThanOrEqual" as const, expected: "le" },
|
|
129
|
+
{ type: "greaterThanOrEqual" as const, expected: "ge" },
|
|
111
130
|
];
|
|
112
131
|
|
|
113
132
|
testCases.forEach(({ type, expected }) => {
|
|
114
|
-
const uiFilter: FilterSpec = {
|
|
133
|
+
const uiFilter: FilterSpec = {
|
|
134
|
+
type,
|
|
135
|
+
column: "colNum" as unknown as SUniversalPColumnId,
|
|
136
|
+
x: 10,
|
|
137
|
+
};
|
|
115
138
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
116
139
|
expect(result as any).toEqual({
|
|
117
140
|
type: expected,
|
|
118
|
-
lhs: { type:
|
|
119
|
-
rhs: { type:
|
|
141
|
+
lhs: { type: "col", name: "colNum" },
|
|
142
|
+
rhs: { type: "const", value: 10 },
|
|
120
143
|
});
|
|
121
144
|
});
|
|
122
145
|
});
|
|
123
146
|
|
|
124
147
|
it('should compile "lessThanColumn" filter to ptabler expression', () => {
|
|
125
148
|
const uiFilter: FilterSpec = {
|
|
126
|
-
type:
|
|
127
|
-
column:
|
|
128
|
-
rhs:
|
|
149
|
+
type: "lessThanColumn",
|
|
150
|
+
column: "colNum1" as unknown as SUniversalPColumnId,
|
|
151
|
+
rhs: "colNum2" as unknown as SUniversalPColumnId,
|
|
129
152
|
};
|
|
130
153
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
131
154
|
expect(result as any).toEqual({
|
|
132
|
-
type:
|
|
133
|
-
lhs: { type:
|
|
134
|
-
rhs: { type:
|
|
155
|
+
type: "lt",
|
|
156
|
+
lhs: { type: "col", name: "colNum1" },
|
|
157
|
+
rhs: { type: "col", name: "colNum2" },
|
|
135
158
|
});
|
|
136
159
|
});
|
|
137
160
|
|
|
138
161
|
it('should compile "lessThanColumn" filter with minDiff to ptabler expression', () => {
|
|
139
162
|
const uiFilter: FilterSpec = {
|
|
140
|
-
type:
|
|
141
|
-
column:
|
|
142
|
-
rhs:
|
|
163
|
+
type: "lessThanColumn",
|
|
164
|
+
column: "colNum1" as unknown as SUniversalPColumnId,
|
|
165
|
+
rhs: "colNum2" as unknown as SUniversalPColumnId,
|
|
143
166
|
minDiff: 5,
|
|
144
167
|
};
|
|
145
168
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
146
169
|
expect(result as any).toEqual({
|
|
147
|
-
type:
|
|
170
|
+
type: "lt",
|
|
148
171
|
lhs: {
|
|
149
|
-
type:
|
|
150
|
-
lhs: { type:
|
|
151
|
-
rhs: { type:
|
|
172
|
+
type: "plus",
|
|
173
|
+
lhs: { type: "col", name: "colNum1" },
|
|
174
|
+
rhs: { type: "const", value: 5 },
|
|
152
175
|
},
|
|
153
|
-
rhs: { type:
|
|
176
|
+
rhs: { type: "col", name: "colNum2" },
|
|
154
177
|
});
|
|
155
178
|
});
|
|
156
179
|
|
|
157
180
|
it('should compile "greaterThanColumn" filter to ptabler expression', () => {
|
|
158
181
|
const uiFilter: FilterSpec = {
|
|
159
|
-
type:
|
|
160
|
-
column:
|
|
161
|
-
rhs:
|
|
182
|
+
type: "greaterThanColumn",
|
|
183
|
+
column: "colNum1" as unknown as SUniversalPColumnId,
|
|
184
|
+
rhs: "colNum2" as unknown as SUniversalPColumnId,
|
|
162
185
|
};
|
|
163
186
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
164
187
|
expect(result as any).toEqual({
|
|
165
|
-
type:
|
|
166
|
-
lhs: { type:
|
|
167
|
-
rhs: { type:
|
|
188
|
+
type: "gt",
|
|
189
|
+
lhs: { type: "col", name: "colNum1" },
|
|
190
|
+
rhs: { type: "col", name: "colNum2" },
|
|
168
191
|
});
|
|
169
192
|
});
|
|
170
193
|
|
|
171
194
|
it('should compile "greaterThanColumn" filter with minDiff to ptabler expression', () => {
|
|
172
195
|
const uiFilter: FilterSpec = {
|
|
173
|
-
type:
|
|
174
|
-
column:
|
|
175
|
-
rhs:
|
|
196
|
+
type: "greaterThanColumn",
|
|
197
|
+
column: "colNum1" as unknown as SUniversalPColumnId,
|
|
198
|
+
rhs: "colNum2" as unknown as SUniversalPColumnId,
|
|
176
199
|
minDiff: 7,
|
|
177
200
|
};
|
|
178
201
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
179
202
|
expect(result as any).toEqual({
|
|
180
|
-
type:
|
|
203
|
+
type: "gt",
|
|
181
204
|
lhs: {
|
|
182
|
-
type:
|
|
183
|
-
lhs: { type:
|
|
184
|
-
rhs: { type:
|
|
205
|
+
type: "plus",
|
|
206
|
+
lhs: { type: "col", name: "colNum1" },
|
|
207
|
+
rhs: { type: "const", value: 7 },
|
|
185
208
|
},
|
|
186
|
-
rhs: { type:
|
|
209
|
+
rhs: { type: "col", name: "colNum2" },
|
|
187
210
|
});
|
|
188
211
|
});
|
|
189
212
|
|
|
190
213
|
it('should compile "equalToColumn" filter to ptabler expression', () => {
|
|
191
214
|
const uiFilter: FilterSpec = {
|
|
192
|
-
type:
|
|
193
|
-
column:
|
|
194
|
-
rhs:
|
|
215
|
+
type: "equalToColumn",
|
|
216
|
+
column: "colNum1" as unknown as SUniversalPColumnId,
|
|
217
|
+
rhs: "colNum2" as unknown as SUniversalPColumnId,
|
|
195
218
|
};
|
|
196
219
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
197
220
|
expect(result as any).toEqual({
|
|
198
|
-
type:
|
|
199
|
-
lhs: { type:
|
|
200
|
-
rhs: { type:
|
|
221
|
+
type: "eq",
|
|
222
|
+
lhs: { type: "col", name: "colNum1" },
|
|
223
|
+
rhs: { type: "col", name: "colNum2" },
|
|
201
224
|
});
|
|
202
225
|
});
|
|
203
226
|
|
|
204
227
|
it('should compile "greaterThanColumnOrEqual" filter to ptabler expression', () => {
|
|
205
228
|
const uiFilter: FilterSpec = {
|
|
206
|
-
type:
|
|
207
|
-
column:
|
|
208
|
-
rhs:
|
|
229
|
+
type: "greaterThanColumnOrEqual",
|
|
230
|
+
column: "colNum1" as unknown as SUniversalPColumnId,
|
|
231
|
+
rhs: "colNum2" as unknown as SUniversalPColumnId,
|
|
209
232
|
};
|
|
210
233
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
211
234
|
expect(result as any).toEqual({
|
|
212
|
-
type:
|
|
213
|
-
lhs: { type:
|
|
214
|
-
rhs: { type:
|
|
235
|
+
type: "ge",
|
|
236
|
+
lhs: { type: "col", name: "colNum1" },
|
|
237
|
+
rhs: { type: "col", name: "colNum2" },
|
|
215
238
|
});
|
|
216
239
|
});
|
|
217
240
|
|
|
218
241
|
it('should compile "greaterThanColumnOrEqual" filter with minDiff to ptabler expression', () => {
|
|
219
242
|
const uiFilter: FilterSpec = {
|
|
220
|
-
type:
|
|
221
|
-
column:
|
|
222
|
-
rhs:
|
|
243
|
+
type: "greaterThanColumnOrEqual",
|
|
244
|
+
column: "colNum1" as unknown as SUniversalPColumnId,
|
|
245
|
+
rhs: "colNum2" as unknown as SUniversalPColumnId,
|
|
223
246
|
minDiff: 2,
|
|
224
247
|
};
|
|
225
248
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
226
249
|
expect(result as any).toEqual({
|
|
227
|
-
type:
|
|
250
|
+
type: "ge",
|
|
228
251
|
lhs: {
|
|
229
|
-
type:
|
|
230
|
-
lhs: { type:
|
|
231
|
-
rhs: { type:
|
|
252
|
+
type: "plus",
|
|
253
|
+
lhs: { type: "col", name: "colNum1" },
|
|
254
|
+
rhs: { type: "const", value: 2 },
|
|
232
255
|
},
|
|
233
|
-
rhs: { type:
|
|
256
|
+
rhs: { type: "col", name: "colNum2" },
|
|
234
257
|
});
|
|
235
258
|
});
|
|
236
259
|
|
|
237
260
|
it('should compile "lessThanColumnOrEqual" filter to ptabler expression', () => {
|
|
238
261
|
const uiFilter: FilterSpec = {
|
|
239
|
-
type:
|
|
240
|
-
column:
|
|
241
|
-
rhs:
|
|
262
|
+
type: "lessThanColumnOrEqual",
|
|
263
|
+
column: "colNum1" as unknown as SUniversalPColumnId,
|
|
264
|
+
rhs: "colNum2" as unknown as SUniversalPColumnId,
|
|
242
265
|
};
|
|
243
266
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
244
267
|
expect(result as any).toEqual({
|
|
245
|
-
type:
|
|
246
|
-
lhs: { type:
|
|
247
|
-
rhs: { type:
|
|
268
|
+
type: "le",
|
|
269
|
+
lhs: { type: "col", name: "colNum1" },
|
|
270
|
+
rhs: { type: "col", name: "colNum2" },
|
|
248
271
|
});
|
|
249
272
|
});
|
|
250
273
|
|
|
251
274
|
it('should compile "lessThanColumnOrEqual" filter with minDiff to ptabler expression', () => {
|
|
252
275
|
const uiFilter: FilterSpec = {
|
|
253
|
-
type:
|
|
254
|
-
column:
|
|
255
|
-
rhs:
|
|
276
|
+
type: "lessThanColumnOrEqual",
|
|
277
|
+
column: "colNum1" as unknown as SUniversalPColumnId,
|
|
278
|
+
rhs: "colNum2" as unknown as SUniversalPColumnId,
|
|
256
279
|
minDiff: 3,
|
|
257
280
|
};
|
|
258
281
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
259
282
|
expect(result as any).toEqual({
|
|
260
|
-
type:
|
|
283
|
+
type: "le",
|
|
261
284
|
lhs: {
|
|
262
|
-
type:
|
|
263
|
-
lhs: { type:
|
|
264
|
-
rhs: { type:
|
|
285
|
+
type: "plus",
|
|
286
|
+
lhs: { type: "col", name: "colNum1" },
|
|
287
|
+
rhs: { type: "const", value: 3 },
|
|
265
288
|
},
|
|
266
|
-
rhs: { type:
|
|
289
|
+
rhs: { type: "col", name: "colNum2" },
|
|
267
290
|
});
|
|
268
291
|
});
|
|
269
292
|
|
|
270
293
|
it('should compile "topN" filter to ptabler expression', () => {
|
|
271
|
-
const uiFilter: FilterSpec = {
|
|
294
|
+
const uiFilter: FilterSpec = {
|
|
295
|
+
type: "topN",
|
|
296
|
+
column: "colNum" as unknown as SUniversalPColumnId,
|
|
297
|
+
n: 5,
|
|
298
|
+
};
|
|
272
299
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
273
300
|
expect(result as any).toEqual({
|
|
274
|
-
type:
|
|
301
|
+
type: "le",
|
|
275
302
|
lhs: {
|
|
276
|
-
type:
|
|
277
|
-
orderBy: [{ type:
|
|
303
|
+
type: "rank",
|
|
304
|
+
orderBy: [{ type: "col", name: "colNum" }],
|
|
278
305
|
partitionBy: [],
|
|
279
306
|
descending: true,
|
|
280
307
|
},
|
|
281
|
-
rhs: { type:
|
|
308
|
+
rhs: { type: "const", value: 5 },
|
|
282
309
|
});
|
|
283
310
|
});
|
|
284
311
|
|
|
285
312
|
it('should compile "bottomN" filter to ptabler expression', () => {
|
|
286
|
-
const uiFilter: FilterSpec = {
|
|
313
|
+
const uiFilter: FilterSpec = {
|
|
314
|
+
type: "bottomN",
|
|
315
|
+
column: "colNum" as unknown as SUniversalPColumnId,
|
|
316
|
+
n: 3,
|
|
317
|
+
};
|
|
287
318
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
288
319
|
expect(result as any).toEqual({
|
|
289
|
-
type:
|
|
320
|
+
type: "le",
|
|
290
321
|
lhs: {
|
|
291
|
-
type:
|
|
292
|
-
orderBy: [{ type:
|
|
322
|
+
type: "rank",
|
|
323
|
+
orderBy: [{ type: "col", name: "colNum" }],
|
|
293
324
|
partitionBy: [],
|
|
294
325
|
descending: undefined, // ptabler-js sets descending to undefined when false
|
|
295
326
|
},
|
|
296
|
-
rhs: { type:
|
|
327
|
+
rhs: { type: "const", value: 3 },
|
|
297
328
|
});
|
|
298
329
|
});
|
|
299
330
|
|
|
300
|
-
it(
|
|
331
|
+
it("should compile nested filters to ptabler expressions", () => {
|
|
301
332
|
const uiFilter: FilterSpec = {
|
|
302
|
-
type:
|
|
333
|
+
type: "and",
|
|
303
334
|
filters: [
|
|
304
335
|
{
|
|
305
|
-
type:
|
|
336
|
+
type: "or",
|
|
306
337
|
filters: [
|
|
307
|
-
{ type:
|
|
308
|
-
{
|
|
338
|
+
{ type: "isNA", column: "colA" as unknown as SUniversalPColumnId },
|
|
339
|
+
{
|
|
340
|
+
type: "patternEquals",
|
|
341
|
+
column: "colB" as unknown as SUniversalPColumnId,
|
|
342
|
+
value: "test",
|
|
343
|
+
},
|
|
309
344
|
],
|
|
310
345
|
},
|
|
311
|
-
{ type:
|
|
346
|
+
{ type: "greaterThan", column: "colNum" as unknown as SUniversalPColumnId, x: 10 },
|
|
312
347
|
],
|
|
313
348
|
};
|
|
314
349
|
const result = convertFilterUiToExpressions(uiFilter);
|
|
315
|
-
expect(result.type).toBe(
|
|
350
|
+
expect(result.type).toBe("and");
|
|
316
351
|
expect((result as any).operands).toHaveLength(2);
|
|
317
|
-
expect((result as any).operands[0].type).toBe(
|
|
352
|
+
expect((result as any).operands[0].type).toBe("or");
|
|
318
353
|
expect((result as any).operands[0].operands).toHaveLength(2);
|
|
319
|
-
expect((result as any).operands[1].type).toBe(
|
|
354
|
+
expect((result as any).operands[1].type).toBe("gt");
|
|
320
355
|
});
|
|
321
356
|
|
|
322
|
-
it(
|
|
323
|
-
const uiFilter: FilterSpec = { type:
|
|
324
|
-
expect(() => convertFilterUiToExpressions(uiFilter)).toThrow(
|
|
357
|
+
it("should throw error for OR filter with no operands", () => {
|
|
358
|
+
const uiFilter: FilterSpec = { type: "or", filters: [] };
|
|
359
|
+
expect(() => convertFilterUiToExpressions(uiFilter)).toThrow(
|
|
360
|
+
"OR filter requires at least one operand",
|
|
361
|
+
);
|
|
325
362
|
});
|
|
326
363
|
|
|
327
|
-
it(
|
|
328
|
-
const uiFilter: FilterSpec = { type:
|
|
329
|
-
expect(() => convertFilterUiToExpressions(uiFilter)).toThrow(
|
|
364
|
+
it("should throw error for AND filter with no operands", () => {
|
|
365
|
+
const uiFilter: FilterSpec = { type: "and", filters: [] };
|
|
366
|
+
expect(() => convertFilterUiToExpressions(uiFilter)).toThrow(
|
|
367
|
+
"AND filter requires at least one operand",
|
|
368
|
+
);
|
|
330
369
|
});
|
|
331
370
|
|
|
332
|
-
it(
|
|
371
|
+
it("should throw error for undefined filter type", () => {
|
|
333
372
|
const uiFilter: FilterSpec = { type: undefined };
|
|
334
|
-
expect(() => convertFilterUiToExpressions(uiFilter)).toThrow(
|
|
373
|
+
expect(() => convertFilterUiToExpressions(uiFilter)).toThrow(
|
|
374
|
+
"Filter type is undefined, this should not happen",
|
|
375
|
+
);
|
|
335
376
|
});
|
|
336
377
|
});
|