@platforma-sdk/model 1.58.3 → 1.58.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/_virtual/_rolldown/runtime.cjs +43 -0
- package/dist/_virtual/_rolldown/runtime.js +18 -0
- package/dist/annotations/converter.cjs +15 -20
- package/dist/annotations/converter.cjs.map +1 -1
- package/dist/annotations/converter.d.ts +6 -2
- package/dist/annotations/converter.js +14 -18
- package/dist/annotations/converter.js.map +1 -1
- package/dist/annotations/index.cjs +1 -0
- package/dist/annotations/index.d.ts +2 -3
- package/dist/annotations/index.js +1 -0
- package/dist/annotations/types.d.ts +21 -16
- package/dist/bconfig/index.cjs +2 -0
- package/dist/bconfig/index.d.ts +5 -6
- package/dist/bconfig/index.js +2 -0
- package/dist/bconfig/lambdas.d.ts +52 -52
- package/dist/bconfig/normalization.cjs +13 -18
- package/dist/bconfig/normalization.cjs.map +1 -1
- package/dist/bconfig/normalization.d.ts +10 -6
- package/dist/bconfig/normalization.js +12 -16
- package/dist/bconfig/normalization.js.map +1 -1
- package/dist/bconfig/types.cjs +4 -3
- package/dist/bconfig/types.cjs.map +1 -1
- package/dist/bconfig/types.d.ts +10 -5
- package/dist/bconfig/types.js +4 -2
- package/dist/bconfig/types.js.map +1 -1
- package/dist/bconfig/util.d.ts +7 -4
- package/dist/bconfig/v3.d.ts +10 -6
- package/dist/block_api_v1.d.ts +62 -58
- package/dist/block_api_v2.d.ts +51 -47
- package/dist/block_api_v3.d.ts +33 -29
- package/dist/block_migrations.cjs +481 -413
- package/dist/block_migrations.cjs.map +1 -1
- package/dist/block_migrations.d.ts +258 -204
- package/dist/block_migrations.js +482 -408
- package/dist/block_migrations.js.map +1 -1
- package/dist/block_model.cjs +312 -343
- package/dist/block_model.cjs.map +1 -1
- package/dist/block_model.d.ts +143 -147
- package/dist/block_model.js +312 -341
- package/dist/block_model.js.map +1 -1
- package/dist/block_model_legacy.cjs +231 -255
- package/dist/block_model_legacy.cjs.map +1 -1
- package/dist/block_model_legacy.d.ts +108 -106
- package/dist/block_model_legacy.js +231 -253
- package/dist/block_model_legacy.js.map +1 -1
- package/dist/block_state_patch.d.ts +10 -10
- package/dist/block_state_util.cjs +15 -19
- package/dist/block_state_util.cjs.map +1 -1
- package/dist/block_state_util.d.ts +14 -13
- package/dist/block_state_util.js +15 -18
- package/dist/block_state_util.js.map +1 -1
- package/dist/block_storage.cjs +233 -238
- package/dist/block_storage.cjs.map +1 -1
- package/dist/block_storage.d.ts +62 -78
- package/dist/block_storage.js +234 -237
- package/dist/block_storage.js.map +1 -1
- package/dist/block_storage_callbacks.cjs +156 -195
- package/dist/block_storage_callbacks.cjs.map +1 -1
- package/dist/block_storage_callbacks.js +156 -192
- package/dist/block_storage_callbacks.js.map +1 -1
- package/dist/block_storage_facade.cjs +29 -85
- package/dist/block_storage_facade.cjs.map +1 -1
- package/dist/block_storage_facade.d.ts +83 -126
- package/dist/block_storage_facade.js +29 -83
- package/dist/block_storage_facade.js.map +1 -1
- package/dist/components/PFrameForGraphs.cjs +26 -24
- package/dist/components/PFrameForGraphs.cjs.map +1 -1
- package/dist/components/PFrameForGraphs.d.ts +12 -7
- package/dist/components/PFrameForGraphs.js +25 -22
- package/dist/components/PFrameForGraphs.js.map +1 -1
- package/dist/components/PlAnnotations/filter.d.ts +62 -79
- package/dist/components/PlAnnotations/filters_ui.cjs +135 -171
- package/dist/components/PlAnnotations/filters_ui.cjs.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.d.ts +48 -46
- package/dist/components/PlAnnotations/filters_ui.js +135 -170
- package/dist/components/PlAnnotations/filters_ui.js.map +1 -1
- package/dist/components/PlAnnotations/index.d.ts +2 -3
- package/dist/components/PlDataTable/index.cjs +2 -0
- package/dist/components/PlDataTable/index.d.ts +3 -5
- package/dist/components/PlDataTable/index.js +2 -0
- package/dist/components/PlDataTable/labels.cjs +59 -81
- package/dist/components/PlDataTable/labels.cjs.map +1 -1
- package/dist/components/PlDataTable/labels.js +58 -79
- package/dist/components/PlDataTable/labels.js.map +1 -1
- package/dist/components/PlDataTable/state-migration.cjs +186 -144
- package/dist/components/PlDataTable/state-migration.cjs.map +1 -1
- package/dist/components/PlDataTable/state-migration.d.ts +85 -82
- package/dist/components/PlDataTable/state-migration.js +185 -142
- package/dist/components/PlDataTable/state-migration.js.map +1 -1
- package/dist/components/PlDataTable/table.cjs +172 -194
- package/dist/components/PlDataTable/table.cjs.map +1 -1
- package/dist/components/PlDataTable/table.d.ts +16 -12
- package/dist/components/PlDataTable/table.js +171 -192
- package/dist/components/PlDataTable/table.js.map +1 -1
- package/dist/components/PlDataTable/v4.d.ts +84 -119
- package/dist/components/PlDataTable/v5.d.ts +80 -103
- package/dist/components/PlMultiSequenceAlignment.cjs +27 -29
- package/dist/components/PlMultiSequenceAlignment.cjs.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.d.ts +36 -27
- package/dist/components/PlMultiSequenceAlignment.js +26 -27
- package/dist/components/PlMultiSequenceAlignment.js.map +1 -1
- package/dist/components/PlSelectionModel.cjs +7 -6
- package/dist/components/PlSelectionModel.cjs.map +1 -1
- package/dist/components/PlSelectionModel.d.ts +10 -8
- package/dist/components/PlSelectionModel.js +7 -5
- package/dist/components/PlSelectionModel.js.map +1 -1
- package/dist/components/index.cjs +8 -0
- package/dist/components/index.d.ts +11 -6
- package/dist/components/index.js +8 -0
- package/dist/config/actions.cjs +138 -171
- package/dist/config/actions.cjs.map +1 -1
- package/dist/config/actions.d.ts +47 -47
- package/dist/config/actions.js +146 -178
- package/dist/config/actions.js.map +1 -1
- package/dist/config/actions_kinds.d.ts +114 -121
- package/dist/config/index.cjs +1 -0
- package/dist/config/index.d.ts +6 -7
- package/dist/config/index.js +1 -0
- package/dist/config/model.d.ts +131 -127
- package/dist/config/model_meta.d.ts +4 -1
- package/dist/config/type_engine.d.ts +22 -21
- package/dist/config/type_util.d.ts +12 -10
- package/dist/env_value.cjs +5 -6
- package/dist/env_value.cjs.map +1 -1
- package/dist/env_value.d.ts +4 -1
- package/dist/env_value.js +5 -5
- package/dist/env_value.js.map +1 -1
- package/dist/filters/converters/filterToQuery.cjs +273 -239
- package/dist/filters/converters/filterToQuery.cjs.map +1 -1
- package/dist/filters/converters/filterToQuery.d.ts +6 -2
- package/dist/filters/converters/filterToQuery.js +272 -237
- package/dist/filters/converters/filterToQuery.js.map +1 -1
- package/dist/filters/converters/filterUiToExpressionImpl.cjs +56 -85
- package/dist/filters/converters/filterUiToExpressionImpl.cjs.map +1 -1
- package/dist/filters/converters/filterUiToExpressionImpl.d.ts +8 -4
- package/dist/filters/converters/filterUiToExpressionImpl.js +55 -83
- package/dist/filters/converters/filterUiToExpressionImpl.js.map +1 -1
- package/dist/filters/converters/index.cjs +2 -0
- package/dist/filters/converters/index.d.ts +2 -3
- package/dist/filters/converters/index.js +2 -0
- package/dist/filters/distill.cjs +59 -50
- package/dist/filters/distill.cjs.map +1 -1
- package/dist/filters/distill.d.ts +6 -3
- package/dist/filters/distill.js +58 -48
- package/dist/filters/distill.js.map +1 -1
- package/dist/filters/index.cjs +4 -0
- package/dist/filters/index.d.ts +5 -4
- package/dist/filters/index.js +4 -0
- package/dist/filters/traverse.cjs +31 -40
- package/dist/filters/traverse.cjs.map +1 -1
- package/dist/filters/traverse.js +31 -39
- package/dist/filters/traverse.js.map +1 -1
- package/dist/filters/types.d.ts +10 -7
- package/dist/index.cjs +193 -187
- package/dist/index.d.ts +61 -28
- package/dist/index.js +49 -41
- package/dist/internal.cjs +48 -62
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.js +49 -60
- package/dist/internal.js.map +1 -1
- package/dist/package.cjs +12 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.js +6 -0
- package/dist/package.js.map +1 -0
- package/dist/pframe.cjs +32 -37
- package/dist/pframe.cjs.map +1 -1
- package/dist/pframe.d.ts +14 -10
- package/dist/pframe.js +32 -35
- package/dist/pframe.js.map +1 -1
- package/dist/pframe_utils/axes.cjs +81 -114
- package/dist/pframe_utils/axes.cjs.map +1 -1
- package/dist/pframe_utils/axes.d.ts +10 -13
- package/dist/pframe_utils/axes.js +80 -112
- package/dist/pframe_utils/axes.js.map +1 -1
- package/dist/pframe_utils/columns.cjs +61 -81
- package/dist/pframe_utils/columns.cjs.map +1 -1
- package/dist/pframe_utils/columns.d.ts +15 -6
- package/dist/pframe_utils/columns.js +60 -79
- package/dist/pframe_utils/columns.js.map +1 -1
- package/dist/pframe_utils/index.cjs +232 -253
- package/dist/pframe_utils/index.cjs.map +1 -1
- package/dist/pframe_utils/index.d.ts +39 -35
- package/dist/pframe_utils/index.js +231 -251
- package/dist/pframe_utils/index.js.map +1 -1
- package/dist/platforma.d.ts +48 -46
- package/dist/plugin_handle.cjs +6 -14
- package/dist/plugin_handle.cjs.map +1 -1
- package/dist/plugin_handle.d.ts +20 -25
- package/dist/plugin_handle.js +6 -13
- package/dist/plugin_handle.js.map +1 -1
- package/dist/plugin_model.cjs +364 -163
- package/dist/plugin_model.cjs.map +1 -1
- package/dist/plugin_model.d.ts +280 -129
- package/dist/plugin_model.js +362 -163
- package/dist/plugin_model.js.map +1 -1
- package/dist/raw_globals.cjs +10 -22
- package/dist/raw_globals.cjs.map +1 -1
- package/dist/raw_globals.d.ts +8 -5
- package/dist/raw_globals.js +10 -20
- package/dist/raw_globals.js.map +1 -1
- package/dist/ref_util.cjs +14 -13
- package/dist/ref_util.cjs.map +1 -1
- package/dist/ref_util.d.ts +18 -12
- package/dist/ref_util.js +14 -11
- package/dist/ref_util.js.map +1 -1
- package/dist/render/accessor.cjs +213 -226
- package/dist/render/accessor.cjs.map +1 -1
- package/dist/render/accessor.d.ts +115 -120
- package/dist/render/accessor.js +212 -224
- package/dist/render/accessor.js.map +1 -1
- package/dist/render/api.cjs +478 -580
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +207 -209
- package/dist/render/api.js +476 -578
- package/dist/render/api.js.map +1 -1
- package/dist/render/future.cjs +28 -32
- package/dist/render/future.cjs.map +1 -1
- package/dist/render/future.d.ts +15 -11
- package/dist/render/future.js +28 -30
- package/dist/render/future.js.map +1 -1
- package/dist/render/index.cjs +8 -0
- package/dist/render/index.d.ts +10 -8
- package/dist/render/index.js +8 -0
- package/dist/render/internal.cjs +33 -29
- package/dist/render/internal.cjs.map +1 -1
- package/dist/render/internal.d.ts +78 -72
- package/dist/render/internal.js +29 -26
- package/dist/render/internal.js.map +1 -1
- package/dist/render/traversal_ops.d.ts +42 -43
- package/dist/render/util/axis_filtering.cjs +63 -86
- package/dist/render/util/axis_filtering.cjs.map +1 -1
- package/dist/render/util/axis_filtering.d.ts +10 -7
- package/dist/render/util/axis_filtering.js +63 -85
- package/dist/render/util/axis_filtering.js.map +1 -1
- package/dist/render/util/column_collection.cjs +266 -321
- package/dist/render/util/column_collection.cjs.map +1 -1
- package/dist/render/util/column_collection.d.ts +47 -47
- package/dist/render/util/column_collection.js +264 -319
- package/dist/render/util/column_collection.js.map +1 -1
- package/dist/render/util/index.cjs +4 -0
- package/dist/render/util/index.d.ts +4 -5
- package/dist/render/util/index.js +4 -0
- package/dist/render/util/label.cjs +129 -163
- package/dist/render/util/label.cjs.map +1 -1
- package/dist/render/util/label.d.ts +45 -46
- package/dist/render/util/label.js +128 -161
- package/dist/render/util/label.js.map +1 -1
- package/dist/render/util/pcolumn_data.cjs +315 -375
- package/dist/render/util/pcolumn_data.cjs.map +1 -1
- package/dist/render/util/pcolumn_data.d.ts +33 -32
- package/dist/render/util/pcolumn_data.js +314 -373
- package/dist/render/util/pcolumn_data.js.map +1 -1
- package/dist/render/util/pframe_upgraders.cjs +37 -42
- package/dist/render/util/pframe_upgraders.cjs.map +1 -1
- package/dist/render/util/pframe_upgraders.js +37 -41
- package/dist/render/util/pframe_upgraders.js.map +1 -1
- package/dist/render/util/split_selectors.d.ts +13 -9
- package/dist/version.cjs +6 -8
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.ts +7 -4
- package/dist/version.js +5 -5
- package/dist/version.js.map +1 -1
- package/package.json +9 -3
- package/src/block_migrations.test.ts +184 -14
- package/src/block_migrations.ts +185 -30
- package/src/block_model.ts +111 -66
- package/src/block_storage.test.ts +147 -3
- package/src/block_storage.ts +43 -8
- package/src/block_storage_callbacks.ts +9 -4
- package/src/env_value.ts +0 -2
- package/src/filters/distill.ts +17 -6
- package/src/index.ts +12 -11
- package/src/internal.ts +0 -1
- package/src/platforma.ts +4 -4
- package/src/plugin_handle.ts +1 -1
- package/src/plugin_model.test.ts +217 -21
- package/src/plugin_model.ts +450 -55
- package/src/raw_globals.ts +0 -1
- package/dist/annotations/converter.d.ts.map +0 -1
- package/dist/annotations/index.d.ts.map +0 -1
- package/dist/annotations/types.d.ts.map +0 -1
- package/dist/bconfig/index.d.ts.map +0 -1
- package/dist/bconfig/lambdas.d.ts.map +0 -1
- package/dist/bconfig/normalization.d.ts.map +0 -1
- package/dist/bconfig/types.d.ts.map +0 -1
- package/dist/bconfig/util.d.ts.map +0 -1
- package/dist/bconfig/v3.d.ts.map +0 -1
- package/dist/block_api_v1.d.ts.map +0 -1
- package/dist/block_api_v2.d.ts.map +0 -1
- package/dist/block_api_v3.d.ts.map +0 -1
- package/dist/block_migrations.d.ts.map +0 -1
- package/dist/block_model.d.ts.map +0 -1
- package/dist/block_model_legacy.d.ts.map +0 -1
- package/dist/block_state_patch.d.ts.map +0 -1
- package/dist/block_state_util.d.ts.map +0 -1
- package/dist/block_storage.d.ts.map +0 -1
- package/dist/block_storage_callbacks.d.ts +0 -115
- package/dist/block_storage_callbacks.d.ts.map +0 -1
- package/dist/block_storage_facade.d.ts.map +0 -1
- package/dist/components/PFrameForGraphs.d.ts.map +0 -1
- package/dist/components/PlAnnotations/filter.d.ts.map +0 -1
- package/dist/components/PlAnnotations/filters_ui.d.ts.map +0 -1
- package/dist/components/PlAnnotations/index.d.ts.map +0 -1
- package/dist/components/PlAnnotations/types.d.ts +0 -3
- package/dist/components/PlAnnotations/types.d.ts.map +0 -1
- package/dist/components/PlDataTable/index.d.ts.map +0 -1
- package/dist/components/PlDataTable/labels.d.ts +0 -7
- package/dist/components/PlDataTable/labels.d.ts.map +0 -1
- package/dist/components/PlDataTable/state-migration.d.ts.map +0 -1
- package/dist/components/PlDataTable/table.d.ts.map +0 -1
- package/dist/components/PlDataTable/v4.d.ts.map +0 -1
- package/dist/components/PlDataTable/v5.d.ts.map +0 -1
- package/dist/components/PlMultiSequenceAlignment.d.ts.map +0 -1
- package/dist/components/PlSelectionModel.d.ts.map +0 -1
- package/dist/components/index.d.ts.map +0 -1
- package/dist/config/actions.d.ts.map +0 -1
- package/dist/config/actions_kinds.d.ts.map +0 -1
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/model.d.ts.map +0 -1
- package/dist/config/model_meta.d.ts.map +0 -1
- package/dist/config/type_engine.d.ts.map +0 -1
- package/dist/config/type_util.d.ts.map +0 -1
- package/dist/env_value.d.ts.map +0 -1
- package/dist/filters/converters/filterToQuery.d.ts.map +0 -1
- package/dist/filters/converters/filterUiToExpressionImpl.d.ts.map +0 -1
- package/dist/filters/converters/index.d.ts.map +0 -1
- package/dist/filters/distill.d.ts.map +0 -1
- package/dist/filters/index.d.ts.map +0 -1
- package/dist/filters/traverse.d.ts +0 -27
- package/dist/filters/traverse.d.ts.map +0 -1
- package/dist/filters/types.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal.d.ts +0 -36
- package/dist/internal.d.ts.map +0 -1
- package/dist/package.json.cjs +0 -6
- package/dist/package.json.cjs.map +0 -1
- package/dist/package.json.js +0 -4
- package/dist/package.json.js.map +0 -1
- package/dist/pframe.d.ts.map +0 -1
- package/dist/pframe_utils/axes.d.ts.map +0 -1
- package/dist/pframe_utils/columns.d.ts.map +0 -1
- package/dist/pframe_utils/index.d.ts.map +0 -1
- package/dist/pframe_utils/querySpec.d.ts +0 -2
- package/dist/pframe_utils/querySpec.d.ts.map +0 -1
- package/dist/platforma.d.ts.map +0 -1
- package/dist/plugin_handle.d.ts.map +0 -1
- package/dist/plugin_model.d.ts.map +0 -1
- package/dist/raw_globals.d.ts.map +0 -1
- package/dist/ref_util.d.ts.map +0 -1
- package/dist/render/accessor.d.ts.map +0 -1
- package/dist/render/api.d.ts.map +0 -1
- package/dist/render/future.d.ts.map +0 -1
- package/dist/render/index.d.ts.map +0 -1
- package/dist/render/internal.d.ts.map +0 -1
- package/dist/render/traversal_ops.d.ts.map +0 -1
- package/dist/render/util/axis_filtering.d.ts.map +0 -1
- package/dist/render/util/column_collection.d.ts.map +0 -1
- package/dist/render/util/index.d.ts.map +0 -1
- package/dist/render/util/label.d.ts.map +0 -1
- package/dist/render/util/pcolumn_data.d.ts.map +0 -1
- package/dist/render/util/pframe_upgraders.d.ts +0 -3
- package/dist/render/util/pframe_upgraders.d.ts.map +0 -1
- package/dist/render/util/split_selectors.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
|
@@ -1,95 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var traverse = require('../traverse.cjs');
|
|
1
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_traverse = require('../traverse.cjs');
|
|
3
|
+
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
4
|
+
let _milaboratories_ptabler_expression_js = require("@milaboratories/ptabler-expression-js");
|
|
6
5
|
|
|
6
|
+
//#region src/filters/converters/filterUiToExpressionImpl.ts
|
|
7
7
|
function convertFilterUiToExpressionImpl(value) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return ptablerExpressionJs.or(...expressions);
|
|
21
|
-
},
|
|
22
|
-
not: (result) => result.not(),
|
|
23
|
-
});
|
|
8
|
+
return require_traverse.traverseFilterSpec(value, {
|
|
9
|
+
leaf: leafToExpressionImpl,
|
|
10
|
+
and: (expressions) => {
|
|
11
|
+
if (expressions.length === 0) throw new Error("AND filter requires at least one operand");
|
|
12
|
+
return (0, _milaboratories_ptabler_expression_js.and)(...expressions);
|
|
13
|
+
},
|
|
14
|
+
or: (expressions) => {
|
|
15
|
+
if (expressions.length === 0) throw new Error("OR filter requires at least one operand");
|
|
16
|
+
return (0, _milaboratories_ptabler_expression_js.or)(...expressions);
|
|
17
|
+
},
|
|
18
|
+
not: (result) => result.not()
|
|
19
|
+
});
|
|
24
20
|
}
|
|
25
21
|
function leafToExpressionImpl(value) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return ptablerExpressionJs.col(value.column).lt(ptablerExpressionJs.col(value.rhs));
|
|
63
|
-
case "greaterThanColumnOrEqual":
|
|
64
|
-
if (value.minDiff !== undefined && value.minDiff !== 0) {
|
|
65
|
-
return ptablerExpressionJs.col(value.column).plus(ptablerExpressionJs.lit(value.minDiff)).ge(ptablerExpressionJs.col(value.rhs));
|
|
66
|
-
}
|
|
67
|
-
return ptablerExpressionJs.col(value.column).ge(ptablerExpressionJs.col(value.rhs));
|
|
68
|
-
case "lessThanColumnOrEqual":
|
|
69
|
-
if (value.minDiff !== undefined && value.minDiff !== 0) {
|
|
70
|
-
return ptablerExpressionJs.col(value.column).plus(ptablerExpressionJs.lit(value.minDiff)).le(ptablerExpressionJs.col(value.rhs));
|
|
71
|
-
}
|
|
72
|
-
return ptablerExpressionJs.col(value.column).le(ptablerExpressionJs.col(value.rhs));
|
|
73
|
-
case "topN":
|
|
74
|
-
return ptablerExpressionJs.rank(ptablerExpressionJs.col(value.column), true).over([]).le(ptablerExpressionJs.lit(value.n));
|
|
75
|
-
case "bottomN":
|
|
76
|
-
return ptablerExpressionJs.rank(ptablerExpressionJs.col(value.column), false).over([]).le(ptablerExpressionJs.lit(value.n));
|
|
77
|
-
case "patternMatchesRegularExpression":
|
|
78
|
-
case "patternFuzzyContainSubsequence":
|
|
79
|
-
case "inSet":
|
|
80
|
-
case "notInSet":
|
|
81
|
-
case "ifNa":
|
|
82
|
-
throw new Error("Not implemented filter type: " + value.type);
|
|
83
|
-
case undefined:
|
|
84
|
-
throw new Error("Filter type is undefined, this should not happen");
|
|
85
|
-
default:
|
|
86
|
-
plModelCommon.assertNever(value);
|
|
87
|
-
}
|
|
22
|
+
switch (value.type) {
|
|
23
|
+
case "isNA": return (0, _milaboratories_ptabler_expression_js.col)(value.column).isNull();
|
|
24
|
+
case "isNotNA": return (0, _milaboratories_ptabler_expression_js.col)(value.column).isNotNull();
|
|
25
|
+
case "patternEquals": return (0, _milaboratories_ptabler_expression_js.col)(value.column).eq((0, _milaboratories_ptabler_expression_js.lit)(value.value));
|
|
26
|
+
case "patternNotEquals": return (0, _milaboratories_ptabler_expression_js.col)(value.column).neq((0, _milaboratories_ptabler_expression_js.lit)(value.value));
|
|
27
|
+
case "patternContainSubsequence": return (0, _milaboratories_ptabler_expression_js.col)(value.column).strContains(value.value, false, true);
|
|
28
|
+
case "patternNotContainSubsequence": return (0, _milaboratories_ptabler_expression_js.col)(value.column).strContains(value.value, false, true).not();
|
|
29
|
+
case "equal": return (0, _milaboratories_ptabler_expression_js.col)(value.column).eq((0, _milaboratories_ptabler_expression_js.lit)(value.x));
|
|
30
|
+
case "notEqual": return (0, _milaboratories_ptabler_expression_js.col)(value.column).neq((0, _milaboratories_ptabler_expression_js.lit)(value.x));
|
|
31
|
+
case "lessThan": return (0, _milaboratories_ptabler_expression_js.col)(value.column).lt((0, _milaboratories_ptabler_expression_js.lit)(value.x));
|
|
32
|
+
case "greaterThan": return (0, _milaboratories_ptabler_expression_js.col)(value.column).gt((0, _milaboratories_ptabler_expression_js.lit)(value.x));
|
|
33
|
+
case "lessThanOrEqual": return (0, _milaboratories_ptabler_expression_js.col)(value.column).le((0, _milaboratories_ptabler_expression_js.lit)(value.x));
|
|
34
|
+
case "greaterThanOrEqual": return (0, _milaboratories_ptabler_expression_js.col)(value.column).ge((0, _milaboratories_ptabler_expression_js.lit)(value.x));
|
|
35
|
+
case "equalToColumn": return (0, _milaboratories_ptabler_expression_js.col)(value.column).eq((0, _milaboratories_ptabler_expression_js.col)(value.rhs));
|
|
36
|
+
case "greaterThanColumn":
|
|
37
|
+
if (value.minDiff !== void 0 && value.minDiff !== 0) return (0, _milaboratories_ptabler_expression_js.col)(value.column).plus((0, _milaboratories_ptabler_expression_js.lit)(value.minDiff)).gt((0, _milaboratories_ptabler_expression_js.col)(value.rhs));
|
|
38
|
+
return (0, _milaboratories_ptabler_expression_js.col)(value.column).gt((0, _milaboratories_ptabler_expression_js.col)(value.rhs));
|
|
39
|
+
case "lessThanColumn":
|
|
40
|
+
if (value.minDiff !== void 0 && value.minDiff !== 0) return (0, _milaboratories_ptabler_expression_js.col)(value.column).plus((0, _milaboratories_ptabler_expression_js.lit)(value.minDiff)).lt((0, _milaboratories_ptabler_expression_js.col)(value.rhs));
|
|
41
|
+
return (0, _milaboratories_ptabler_expression_js.col)(value.column).lt((0, _milaboratories_ptabler_expression_js.col)(value.rhs));
|
|
42
|
+
case "greaterThanColumnOrEqual":
|
|
43
|
+
if (value.minDiff !== void 0 && value.minDiff !== 0) return (0, _milaboratories_ptabler_expression_js.col)(value.column).plus((0, _milaboratories_ptabler_expression_js.lit)(value.minDiff)).ge((0, _milaboratories_ptabler_expression_js.col)(value.rhs));
|
|
44
|
+
return (0, _milaboratories_ptabler_expression_js.col)(value.column).ge((0, _milaboratories_ptabler_expression_js.col)(value.rhs));
|
|
45
|
+
case "lessThanColumnOrEqual":
|
|
46
|
+
if (value.minDiff !== void 0 && value.minDiff !== 0) return (0, _milaboratories_ptabler_expression_js.col)(value.column).plus((0, _milaboratories_ptabler_expression_js.lit)(value.minDiff)).le((0, _milaboratories_ptabler_expression_js.col)(value.rhs));
|
|
47
|
+
return (0, _milaboratories_ptabler_expression_js.col)(value.column).le((0, _milaboratories_ptabler_expression_js.col)(value.rhs));
|
|
48
|
+
case "topN": return (0, _milaboratories_ptabler_expression_js.rank)((0, _milaboratories_ptabler_expression_js.col)(value.column), true).over([]).le((0, _milaboratories_ptabler_expression_js.lit)(value.n));
|
|
49
|
+
case "bottomN": return (0, _milaboratories_ptabler_expression_js.rank)((0, _milaboratories_ptabler_expression_js.col)(value.column), false).over([]).le((0, _milaboratories_ptabler_expression_js.lit)(value.n));
|
|
50
|
+
case "patternMatchesRegularExpression":
|
|
51
|
+
case "patternFuzzyContainSubsequence":
|
|
52
|
+
case "inSet":
|
|
53
|
+
case "notInSet":
|
|
54
|
+
case "ifNa": throw new Error("Not implemented filter type: " + value.type);
|
|
55
|
+
case void 0: throw new Error("Filter type is undefined, this should not happen");
|
|
56
|
+
default: (0, _milaboratories_pl_model_common.assertNever)(value);
|
|
57
|
+
}
|
|
88
58
|
}
|
|
89
59
|
function convertFilterUiToExpressions(value) {
|
|
90
|
-
|
|
60
|
+
return convertFilterUiToExpressionImpl(value).toJSON();
|
|
91
61
|
}
|
|
92
62
|
|
|
63
|
+
//#endregion
|
|
93
64
|
exports.convertFilterUiToExpressionImpl = convertFilterUiToExpressionImpl;
|
|
94
65
|
exports.convertFilterUiToExpressions = convertFilterUiToExpressions;
|
|
95
|
-
//# sourceMappingURL=filterUiToExpressionImpl.cjs.map
|
|
66
|
+
//# sourceMappingURL=filterUiToExpressionImpl.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterUiToExpressionImpl.cjs","sources":["../../../src/filters/converters/filterUiToExpressionImpl.ts"],"sourcesContent":["import { assertNever } from \"@milaboratories/pl-model-common\";\nimport type { FilterSpecLeaf } from \"@milaboratories/pl-model-common\";\nimport {\n and,\n col,\n lit,\n or,\n rank,\n type Expression,\n type ExpressionImpl,\n} from \"@milaboratories/ptabler-expression-js\";\nimport type { FilterSpec } from \"../types\";\nimport { traverseFilterSpec } from \"../traverse\";\n\nexport function convertFilterUiToExpressionImpl(value: FilterSpec): ExpressionImpl {\n return traverseFilterSpec(value, {\n leaf: leafToExpressionImpl,\n and: (expressions) => {\n if (expressions.length === 0) {\n throw new Error(\"AND filter requires at least one operand\");\n }\n return and(...expressions);\n },\n or: (expressions) => {\n if (expressions.length === 0) {\n throw new Error(\"OR filter requires at least one operand\");\n }\n return or(...expressions);\n },\n not: (result) => result.not(),\n });\n}\n\nfunction leafToExpressionImpl(value: FilterSpecLeaf): ExpressionImpl {\n switch (value.type) {\n case \"isNA\":\n return col(value.column).isNull();\n case \"isNotNA\":\n return col(value.column).isNotNull();\n case \"patternEquals\":\n return col(value.column).eq(lit(value.value));\n case \"patternNotEquals\":\n return col(value.column).neq(lit(value.value));\n case \"patternContainSubsequence\":\n return col(value.column).strContains(value.value, false, true);\n case \"patternNotContainSubsequence\":\n return col(value.column).strContains(value.value, false, true).not();\n case \"equal\":\n return col(value.column).eq(lit(value.x));\n case \"notEqual\":\n return col(value.column).neq(lit(value.x));\n case \"lessThan\":\n return col(value.column).lt(lit(value.x));\n case \"greaterThan\":\n return col(value.column).gt(lit(value.x));\n case \"lessThanOrEqual\":\n return col(value.column).le(lit(value.x));\n case \"greaterThanOrEqual\":\n return col(value.column).ge(lit(value.x));\n case \"equalToColumn\":\n return col(value.column).eq(col(value.rhs));\n case \"greaterThanColumn\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).gt(col(value.rhs));\n }\n return col(value.column).gt(col(value.rhs));\n case \"lessThanColumn\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).lt(col(value.rhs));\n }\n return col(value.column).lt(col(value.rhs));\n case \"greaterThanColumnOrEqual\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).ge(col(value.rhs));\n }\n return col(value.column).ge(col(value.rhs));\n case \"lessThanColumnOrEqual\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).le(col(value.rhs));\n }\n return col(value.column).le(col(value.rhs));\n case \"topN\":\n return rank(col(value.column), true).over([]).le(lit(value.n));\n case \"bottomN\":\n return rank(col(value.column), false).over([]).le(lit(value.n));\n case \"patternMatchesRegularExpression\":\n case \"patternFuzzyContainSubsequence\":\n case \"inSet\":\n case \"notInSet\":\n case \"ifNa\":\n throw new Error(\"Not implemented filter type: \" + value.type);\n case undefined:\n throw new Error(\"Filter type is undefined, this should not happen\");\n default:\n assertNever(value);\n }\n}\n\nexport function convertFilterUiToExpressions(value: FilterSpec): Expression {\n return convertFilterUiToExpressionImpl(value).toJSON();\n}\n"],"
|
|
1
|
+
{"version":3,"file":"filterUiToExpressionImpl.cjs","names":["traverseFilterSpec"],"sources":["../../../src/filters/converters/filterUiToExpressionImpl.ts"],"sourcesContent":["import { assertNever } from \"@milaboratories/pl-model-common\";\nimport type { FilterSpecLeaf } from \"@milaboratories/pl-model-common\";\nimport {\n and,\n col,\n lit,\n or,\n rank,\n type Expression,\n type ExpressionImpl,\n} from \"@milaboratories/ptabler-expression-js\";\nimport type { FilterSpec } from \"../types\";\nimport { traverseFilterSpec } from \"../traverse\";\n\nexport function convertFilterUiToExpressionImpl(value: FilterSpec): ExpressionImpl {\n return traverseFilterSpec(value, {\n leaf: leafToExpressionImpl,\n and: (expressions) => {\n if (expressions.length === 0) {\n throw new Error(\"AND filter requires at least one operand\");\n }\n return and(...expressions);\n },\n or: (expressions) => {\n if (expressions.length === 0) {\n throw new Error(\"OR filter requires at least one operand\");\n }\n return or(...expressions);\n },\n not: (result) => result.not(),\n });\n}\n\nfunction leafToExpressionImpl(value: FilterSpecLeaf): ExpressionImpl {\n switch (value.type) {\n case \"isNA\":\n return col(value.column).isNull();\n case \"isNotNA\":\n return col(value.column).isNotNull();\n case \"patternEquals\":\n return col(value.column).eq(lit(value.value));\n case \"patternNotEquals\":\n return col(value.column).neq(lit(value.value));\n case \"patternContainSubsequence\":\n return col(value.column).strContains(value.value, false, true);\n case \"patternNotContainSubsequence\":\n return col(value.column).strContains(value.value, false, true).not();\n case \"equal\":\n return col(value.column).eq(lit(value.x));\n case \"notEqual\":\n return col(value.column).neq(lit(value.x));\n case \"lessThan\":\n return col(value.column).lt(lit(value.x));\n case \"greaterThan\":\n return col(value.column).gt(lit(value.x));\n case \"lessThanOrEqual\":\n return col(value.column).le(lit(value.x));\n case \"greaterThanOrEqual\":\n return col(value.column).ge(lit(value.x));\n case \"equalToColumn\":\n return col(value.column).eq(col(value.rhs));\n case \"greaterThanColumn\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).gt(col(value.rhs));\n }\n return col(value.column).gt(col(value.rhs));\n case \"lessThanColumn\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).lt(col(value.rhs));\n }\n return col(value.column).lt(col(value.rhs));\n case \"greaterThanColumnOrEqual\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).ge(col(value.rhs));\n }\n return col(value.column).ge(col(value.rhs));\n case \"lessThanColumnOrEqual\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).le(col(value.rhs));\n }\n return col(value.column).le(col(value.rhs));\n case \"topN\":\n return rank(col(value.column), true).over([]).le(lit(value.n));\n case \"bottomN\":\n return rank(col(value.column), false).over([]).le(lit(value.n));\n case \"patternMatchesRegularExpression\":\n case \"patternFuzzyContainSubsequence\":\n case \"inSet\":\n case \"notInSet\":\n case \"ifNa\":\n throw new Error(\"Not implemented filter type: \" + value.type);\n case undefined:\n throw new Error(\"Filter type is undefined, this should not happen\");\n default:\n assertNever(value);\n }\n}\n\nexport function convertFilterUiToExpressions(value: FilterSpec): Expression {\n return convertFilterUiToExpressionImpl(value).toJSON();\n}\n"],"mappings":"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"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { FilterSpec } from "../types.js";
|
|
2
|
+
import { Expression, ExpressionImpl } from "@milaboratories/ptabler-expression-js";
|
|
3
|
+
|
|
4
|
+
//#region src/filters/converters/filterUiToExpressionImpl.d.ts
|
|
5
|
+
declare function convertFilterUiToExpressionImpl(value: FilterSpec): ExpressionImpl;
|
|
6
|
+
declare function convertFilterUiToExpressions(value: FilterSpec): Expression;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { convertFilterUiToExpressionImpl, convertFilterUiToExpressions };
|
|
5
9
|
//# sourceMappingURL=filterUiToExpressionImpl.d.ts.map
|
|
@@ -1,92 +1,64 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { traverseFilterSpec } from "../traverse.js";
|
|
2
|
+
import { assertNever } from "@milaboratories/pl-model-common";
|
|
3
|
+
import { and, col, lit, or, rank } from "@milaboratories/ptabler-expression-js";
|
|
4
4
|
|
|
5
|
+
//#region src/filters/converters/filterUiToExpressionImpl.ts
|
|
5
6
|
function convertFilterUiToExpressionImpl(value) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return or(...expressions);
|
|
19
|
-
},
|
|
20
|
-
not: (result) => result.not(),
|
|
21
|
-
});
|
|
7
|
+
return traverseFilterSpec(value, {
|
|
8
|
+
leaf: leafToExpressionImpl,
|
|
9
|
+
and: (expressions) => {
|
|
10
|
+
if (expressions.length === 0) throw new Error("AND filter requires at least one operand");
|
|
11
|
+
return and(...expressions);
|
|
12
|
+
},
|
|
13
|
+
or: (expressions) => {
|
|
14
|
+
if (expressions.length === 0) throw new Error("OR filter requires at least one operand");
|
|
15
|
+
return or(...expressions);
|
|
16
|
+
},
|
|
17
|
+
not: (result) => result.not()
|
|
18
|
+
});
|
|
22
19
|
}
|
|
23
20
|
function leafToExpressionImpl(value) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return col(value.column).lt(col(value.rhs));
|
|
61
|
-
case "greaterThanColumnOrEqual":
|
|
62
|
-
if (value.minDiff !== undefined && value.minDiff !== 0) {
|
|
63
|
-
return col(value.column).plus(lit(value.minDiff)).ge(col(value.rhs));
|
|
64
|
-
}
|
|
65
|
-
return col(value.column).ge(col(value.rhs));
|
|
66
|
-
case "lessThanColumnOrEqual":
|
|
67
|
-
if (value.minDiff !== undefined && value.minDiff !== 0) {
|
|
68
|
-
return col(value.column).plus(lit(value.minDiff)).le(col(value.rhs));
|
|
69
|
-
}
|
|
70
|
-
return col(value.column).le(col(value.rhs));
|
|
71
|
-
case "topN":
|
|
72
|
-
return rank(col(value.column), true).over([]).le(lit(value.n));
|
|
73
|
-
case "bottomN":
|
|
74
|
-
return rank(col(value.column), false).over([]).le(lit(value.n));
|
|
75
|
-
case "patternMatchesRegularExpression":
|
|
76
|
-
case "patternFuzzyContainSubsequence":
|
|
77
|
-
case "inSet":
|
|
78
|
-
case "notInSet":
|
|
79
|
-
case "ifNa":
|
|
80
|
-
throw new Error("Not implemented filter type: " + value.type);
|
|
81
|
-
case undefined:
|
|
82
|
-
throw new Error("Filter type is undefined, this should not happen");
|
|
83
|
-
default:
|
|
84
|
-
assertNever(value);
|
|
85
|
-
}
|
|
21
|
+
switch (value.type) {
|
|
22
|
+
case "isNA": return col(value.column).isNull();
|
|
23
|
+
case "isNotNA": return col(value.column).isNotNull();
|
|
24
|
+
case "patternEquals": return col(value.column).eq(lit(value.value));
|
|
25
|
+
case "patternNotEquals": return col(value.column).neq(lit(value.value));
|
|
26
|
+
case "patternContainSubsequence": return col(value.column).strContains(value.value, false, true);
|
|
27
|
+
case "patternNotContainSubsequence": return col(value.column).strContains(value.value, false, true).not();
|
|
28
|
+
case "equal": return col(value.column).eq(lit(value.x));
|
|
29
|
+
case "notEqual": return col(value.column).neq(lit(value.x));
|
|
30
|
+
case "lessThan": return col(value.column).lt(lit(value.x));
|
|
31
|
+
case "greaterThan": return col(value.column).gt(lit(value.x));
|
|
32
|
+
case "lessThanOrEqual": return col(value.column).le(lit(value.x));
|
|
33
|
+
case "greaterThanOrEqual": return col(value.column).ge(lit(value.x));
|
|
34
|
+
case "equalToColumn": return col(value.column).eq(col(value.rhs));
|
|
35
|
+
case "greaterThanColumn":
|
|
36
|
+
if (value.minDiff !== void 0 && value.minDiff !== 0) return col(value.column).plus(lit(value.minDiff)).gt(col(value.rhs));
|
|
37
|
+
return col(value.column).gt(col(value.rhs));
|
|
38
|
+
case "lessThanColumn":
|
|
39
|
+
if (value.minDiff !== void 0 && value.minDiff !== 0) return col(value.column).plus(lit(value.minDiff)).lt(col(value.rhs));
|
|
40
|
+
return col(value.column).lt(col(value.rhs));
|
|
41
|
+
case "greaterThanColumnOrEqual":
|
|
42
|
+
if (value.minDiff !== void 0 && value.minDiff !== 0) return col(value.column).plus(lit(value.minDiff)).ge(col(value.rhs));
|
|
43
|
+
return col(value.column).ge(col(value.rhs));
|
|
44
|
+
case "lessThanColumnOrEqual":
|
|
45
|
+
if (value.minDiff !== void 0 && value.minDiff !== 0) return col(value.column).plus(lit(value.minDiff)).le(col(value.rhs));
|
|
46
|
+
return col(value.column).le(col(value.rhs));
|
|
47
|
+
case "topN": return rank(col(value.column), true).over([]).le(lit(value.n));
|
|
48
|
+
case "bottomN": return rank(col(value.column), false).over([]).le(lit(value.n));
|
|
49
|
+
case "patternMatchesRegularExpression":
|
|
50
|
+
case "patternFuzzyContainSubsequence":
|
|
51
|
+
case "inSet":
|
|
52
|
+
case "notInSet":
|
|
53
|
+
case "ifNa": throw new Error("Not implemented filter type: " + value.type);
|
|
54
|
+
case void 0: throw new Error("Filter type is undefined, this should not happen");
|
|
55
|
+
default: assertNever(value);
|
|
56
|
+
}
|
|
86
57
|
}
|
|
87
58
|
function convertFilterUiToExpressions(value) {
|
|
88
|
-
|
|
59
|
+
return convertFilterUiToExpressionImpl(value).toJSON();
|
|
89
60
|
}
|
|
90
61
|
|
|
62
|
+
//#endregion
|
|
91
63
|
export { convertFilterUiToExpressionImpl, convertFilterUiToExpressions };
|
|
92
|
-
//# sourceMappingURL=filterUiToExpressionImpl.js.map
|
|
64
|
+
//# sourceMappingURL=filterUiToExpressionImpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterUiToExpressionImpl.js","sources":["../../../src/filters/converters/filterUiToExpressionImpl.ts"],"sourcesContent":["import { assertNever } from \"@milaboratories/pl-model-common\";\nimport type { FilterSpecLeaf } from \"@milaboratories/pl-model-common\";\nimport {\n and,\n col,\n lit,\n or,\n rank,\n type Expression,\n type ExpressionImpl,\n} from \"@milaboratories/ptabler-expression-js\";\nimport type { FilterSpec } from \"../types\";\nimport { traverseFilterSpec } from \"../traverse\";\n\nexport function convertFilterUiToExpressionImpl(value: FilterSpec): ExpressionImpl {\n return traverseFilterSpec(value, {\n leaf: leafToExpressionImpl,\n and: (expressions) => {\n if (expressions.length === 0) {\n throw new Error(\"AND filter requires at least one operand\");\n }\n return and(...expressions);\n },\n or: (expressions) => {\n if (expressions.length === 0) {\n throw new Error(\"OR filter requires at least one operand\");\n }\n return or(...expressions);\n },\n not: (result) => result.not(),\n });\n}\n\nfunction leafToExpressionImpl(value: FilterSpecLeaf): ExpressionImpl {\n switch (value.type) {\n case \"isNA\":\n return col(value.column).isNull();\n case \"isNotNA\":\n return col(value.column).isNotNull();\n case \"patternEquals\":\n return col(value.column).eq(lit(value.value));\n case \"patternNotEquals\":\n return col(value.column).neq(lit(value.value));\n case \"patternContainSubsequence\":\n return col(value.column).strContains(value.value, false, true);\n case \"patternNotContainSubsequence\":\n return col(value.column).strContains(value.value, false, true).not();\n case \"equal\":\n return col(value.column).eq(lit(value.x));\n case \"notEqual\":\n return col(value.column).neq(lit(value.x));\n case \"lessThan\":\n return col(value.column).lt(lit(value.x));\n case \"greaterThan\":\n return col(value.column).gt(lit(value.x));\n case \"lessThanOrEqual\":\n return col(value.column).le(lit(value.x));\n case \"greaterThanOrEqual\":\n return col(value.column).ge(lit(value.x));\n case \"equalToColumn\":\n return col(value.column).eq(col(value.rhs));\n case \"greaterThanColumn\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).gt(col(value.rhs));\n }\n return col(value.column).gt(col(value.rhs));\n case \"lessThanColumn\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).lt(col(value.rhs));\n }\n return col(value.column).lt(col(value.rhs));\n case \"greaterThanColumnOrEqual\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).ge(col(value.rhs));\n }\n return col(value.column).ge(col(value.rhs));\n case \"lessThanColumnOrEqual\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).le(col(value.rhs));\n }\n return col(value.column).le(col(value.rhs));\n case \"topN\":\n return rank(col(value.column), true).over([]).le(lit(value.n));\n case \"bottomN\":\n return rank(col(value.column), false).over([]).le(lit(value.n));\n case \"patternMatchesRegularExpression\":\n case \"patternFuzzyContainSubsequence\":\n case \"inSet\":\n case \"notInSet\":\n case \"ifNa\":\n throw new Error(\"Not implemented filter type: \" + value.type);\n case undefined:\n throw new Error(\"Filter type is undefined, this should not happen\");\n default:\n assertNever(value);\n }\n}\n\nexport function convertFilterUiToExpressions(value: FilterSpec): Expression {\n return convertFilterUiToExpressionImpl(value).toJSON();\n}\n"],"
|
|
1
|
+
{"version":3,"file":"filterUiToExpressionImpl.js","names":[],"sources":["../../../src/filters/converters/filterUiToExpressionImpl.ts"],"sourcesContent":["import { assertNever } from \"@milaboratories/pl-model-common\";\nimport type { FilterSpecLeaf } from \"@milaboratories/pl-model-common\";\nimport {\n and,\n col,\n lit,\n or,\n rank,\n type Expression,\n type ExpressionImpl,\n} from \"@milaboratories/ptabler-expression-js\";\nimport type { FilterSpec } from \"../types\";\nimport { traverseFilterSpec } from \"../traverse\";\n\nexport function convertFilterUiToExpressionImpl(value: FilterSpec): ExpressionImpl {\n return traverseFilterSpec(value, {\n leaf: leafToExpressionImpl,\n and: (expressions) => {\n if (expressions.length === 0) {\n throw new Error(\"AND filter requires at least one operand\");\n }\n return and(...expressions);\n },\n or: (expressions) => {\n if (expressions.length === 0) {\n throw new Error(\"OR filter requires at least one operand\");\n }\n return or(...expressions);\n },\n not: (result) => result.not(),\n });\n}\n\nfunction leafToExpressionImpl(value: FilterSpecLeaf): ExpressionImpl {\n switch (value.type) {\n case \"isNA\":\n return col(value.column).isNull();\n case \"isNotNA\":\n return col(value.column).isNotNull();\n case \"patternEquals\":\n return col(value.column).eq(lit(value.value));\n case \"patternNotEquals\":\n return col(value.column).neq(lit(value.value));\n case \"patternContainSubsequence\":\n return col(value.column).strContains(value.value, false, true);\n case \"patternNotContainSubsequence\":\n return col(value.column).strContains(value.value, false, true).not();\n case \"equal\":\n return col(value.column).eq(lit(value.x));\n case \"notEqual\":\n return col(value.column).neq(lit(value.x));\n case \"lessThan\":\n return col(value.column).lt(lit(value.x));\n case \"greaterThan\":\n return col(value.column).gt(lit(value.x));\n case \"lessThanOrEqual\":\n return col(value.column).le(lit(value.x));\n case \"greaterThanOrEqual\":\n return col(value.column).ge(lit(value.x));\n case \"equalToColumn\":\n return col(value.column).eq(col(value.rhs));\n case \"greaterThanColumn\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).gt(col(value.rhs));\n }\n return col(value.column).gt(col(value.rhs));\n case \"lessThanColumn\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).lt(col(value.rhs));\n }\n return col(value.column).lt(col(value.rhs));\n case \"greaterThanColumnOrEqual\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).ge(col(value.rhs));\n }\n return col(value.column).ge(col(value.rhs));\n case \"lessThanColumnOrEqual\":\n if (value.minDiff !== undefined && value.minDiff !== 0) {\n return col(value.column).plus(lit(value.minDiff)).le(col(value.rhs));\n }\n return col(value.column).le(col(value.rhs));\n case \"topN\":\n return rank(col(value.column), true).over([]).le(lit(value.n));\n case \"bottomN\":\n return rank(col(value.column), false).over([]).le(lit(value.n));\n case \"patternMatchesRegularExpression\":\n case \"patternFuzzyContainSubsequence\":\n case \"inSet\":\n case \"notInSet\":\n case \"ifNa\":\n throw new Error(\"Not implemented filter type: \" + value.type);\n case undefined:\n throw new Error(\"Filter type is undefined, this should not happen\");\n default:\n assertNever(value);\n }\n}\n\nexport function convertFilterUiToExpressions(value: FilterSpec): Expression {\n return convertFilterUiToExpressionImpl(value).toJSON();\n}\n"],"mappings":"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"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { filterSpecToSpecQueryExpr } from "./filterToQuery.js";
|
|
2
|
+
import { convertFilterUiToExpressionImpl, convertFilterUiToExpressions } from "./filterUiToExpressionImpl.js";
|
package/dist/filters/distill.cjs
CHANGED
|
@@ -1,61 +1,70 @@
|
|
|
1
|
-
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_traverse = require('./traverse.cjs');
|
|
3
|
+
let es_toolkit_compat = require("es-toolkit/compat");
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"substitutionsOnly",
|
|
18
|
-
];
|
|
19
|
-
const KNOWN_LEAF_KEYS = new Set(KNOWN_LEAF_KEYS_TUPLE);
|
|
5
|
+
//#region src/filters/distill.ts
|
|
6
|
+
const KNOWN_LEAF_KEYS = new Set([
|
|
7
|
+
"n",
|
|
8
|
+
"x",
|
|
9
|
+
"rhs",
|
|
10
|
+
"type",
|
|
11
|
+
"value",
|
|
12
|
+
"column",
|
|
13
|
+
"minDiff",
|
|
14
|
+
"maxEdits",
|
|
15
|
+
"wildcard",
|
|
16
|
+
"replacement",
|
|
17
|
+
"substitutionsOnly"
|
|
18
|
+
]);
|
|
20
19
|
/** Returns true if the leaf is filled — type is defined and no required fields are undefined. */
|
|
21
20
|
function isFilledLeaf(node) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
if (node.type == null) return false;
|
|
22
|
+
return !Object.values(node).some((value) => {
|
|
23
|
+
switch (typeof value) {
|
|
24
|
+
case "number":
|
|
25
|
+
case "boolean": return false;
|
|
26
|
+
case "string": return value.trim() === "";
|
|
27
|
+
default: return (0, es_toolkit_compat.isEmpty)(value);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
25
30
|
}
|
|
26
31
|
function distillLeaf(node) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
result[key] = value;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
32
|
+
const result = {};
|
|
33
|
+
for (const [key, value] of Object.entries(node)) if (KNOWN_LEAF_KEYS.has(key)) result[key] = value;
|
|
34
|
+
return result;
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
* Strips non-FilterSpec metadata (whitelist approach) and removes
|
|
38
|
+
* unfilled leaves (type is undefined or any required field is undefined).
|
|
39
|
+
*/
|
|
39
40
|
function distillFilterSpec(filter) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
41
|
+
if (filter == null) return null;
|
|
42
|
+
return require_traverse.traverseFilterSpec(filter, {
|
|
43
|
+
leaf: (leaf) => {
|
|
44
|
+
const distilled = distillLeaf(leaf);
|
|
45
|
+
return isFilledLeaf(distilled) ? distilled : null;
|
|
46
|
+
},
|
|
47
|
+
and: (results) => {
|
|
48
|
+
const filtered = results.filter((f) => f !== null);
|
|
49
|
+
return filtered.length === 0 ? null : {
|
|
50
|
+
type: "and",
|
|
51
|
+
filters: filtered
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
or: (results) => {
|
|
55
|
+
const filtered = results.filter((f) => f !== null);
|
|
56
|
+
return filtered.length === 0 ? null : {
|
|
57
|
+
type: "or",
|
|
58
|
+
filters: filtered
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
not: (result) => result === null ? null : {
|
|
62
|
+
type: "not",
|
|
63
|
+
filter: result
|
|
64
|
+
}
|
|
65
|
+
});
|
|
58
66
|
}
|
|
59
67
|
|
|
68
|
+
//#endregion
|
|
60
69
|
exports.distillFilterSpec = distillFilterSpec;
|
|
61
|
-
//# sourceMappingURL=distill.cjs.map
|
|
70
|
+
//# sourceMappingURL=distill.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distill.cjs","sources":["../../src/filters/distill.ts"],"sourcesContent":["import { DistributiveKeys, UnionToTuples } from \"@milaboratories/helpers\";\nimport {\n RootFilterSpec,\n type FilterSpec,\n type FilterSpecLeaf,\n} from \"@milaboratories/pl-model-common\";\nimport { traverseFilterSpec } from \"./traverse\";\nimport { InferFilterSpecLeaf } from \"@milaboratories/pl-model-common\";\n\n/** All possible field names that can appear in any FilterSpecLeaf variant. */\ntype FilterSpecLeafKey = DistributiveKeys<FilterSpecLeaf<string>>;\n\n/** Compile-time check: every key in the tuple is a valid leaf key (via satisfies). */\nconst KNOWN_LEAF_KEYS_TUPLE: UnionToTuples<FilterSpecLeafKey> = [\n \"n\",\n \"x\",\n \"rhs\",\n \"type\",\n \"value\",\n \"column\",\n \"minDiff\",\n \"maxEdits\",\n \"wildcard\",\n \"replacement\",\n \"substitutionsOnly\",\n];\nconst KNOWN_LEAF_KEYS: Set<FilterSpecLeafKey> = new Set(KNOWN_LEAF_KEYS_TUPLE);\n\n/** Returns true if the leaf is filled — type is defined and no required fields are undefined. */\nfunction isFilledLeaf(node:
|
|
1
|
+
{"version":3,"file":"distill.cjs","names":["traverseFilterSpec"],"sources":["../../src/filters/distill.ts"],"sourcesContent":["import { DistributiveKeys, UnionToTuples } from \"@milaboratories/helpers\";\nimport {\n RootFilterSpec,\n type FilterSpec,\n type FilterSpecLeaf,\n} from \"@milaboratories/pl-model-common\";\nimport { traverseFilterSpec } from \"./traverse\";\nimport { InferFilterSpecLeaf } from \"@milaboratories/pl-model-common\";\nimport { isEmpty } from \"es-toolkit/compat\";\n\n/** All possible field names that can appear in any FilterSpecLeaf variant. */\ntype FilterSpecLeafKey = DistributiveKeys<FilterSpecLeaf<string>>;\n\n/** Compile-time check: every key in the tuple is a valid leaf key (via satisfies). */\nconst KNOWN_LEAF_KEYS_TUPLE: UnionToTuples<FilterSpecLeafKey> = [\n \"n\",\n \"x\",\n \"rhs\",\n \"type\",\n \"value\",\n \"column\",\n \"minDiff\",\n \"maxEdits\",\n \"wildcard\",\n \"replacement\",\n \"substitutionsOnly\",\n];\nconst KNOWN_LEAF_KEYS: Set<FilterSpecLeafKey> = new Set(KNOWN_LEAF_KEYS_TUPLE);\n\n/** Returns true if the leaf is filled — type is defined and no required fields are undefined. */\nfunction isFilledLeaf<T>(node: FilterSpecLeaf<T>): boolean {\n if (node.type == null) return false;\n return !Object.values(node).some((value) => {\n switch (typeof value) {\n case \"number\":\n case \"boolean\":\n return false;\n case \"string\":\n return value.trim() === \"\";\n default: // undefined, null, empty objects/arrays\n return isEmpty(value);\n }\n });\n}\n\nfunction distillLeaf<T>(node: FilterSpecLeaf<T>): FilterSpecLeaf<T> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(node)) {\n if (KNOWN_LEAF_KEYS.has(key as FilterSpecLeafKey)) {\n result[key] = value;\n }\n }\n return result as FilterSpecLeaf<T>;\n}\n\n/**\n * Strips non-FilterSpec metadata (whitelist approach) and removes\n * unfilled leaves (type is undefined or any required field is undefined).\n */\nexport function distillFilterSpec<\n FS extends FilterSpec<FilterSpecLeaf<unknown>, unknown, unknown>,\n R extends FS extends RootFilterSpec<FilterSpecLeaf<unknown>, unknown, unknown>\n ? RootFilterSpec<InferFilterSpecLeaf<FS>>\n : FilterSpec<InferFilterSpecLeaf<FS>>,\n>(filter: null | undefined | FS): null | R {\n if (filter == null) return null;\n return traverseFilterSpec<FS, null | R>(filter, {\n leaf: (leaf) => {\n const distilled = distillLeaf(leaf);\n return isFilledLeaf(distilled) ? (distilled as R) : null;\n },\n and: (results) => {\n const filtered = results.filter((f): f is NonNullable<typeof f> => f !== null);\n return filtered.length === 0 ? null : ({ type: \"and\", filters: filtered } as R);\n },\n or: (results) => {\n const filtered = results.filter((f): f is NonNullable<typeof f> => f !== null);\n return filtered.length === 0 ? null : ({ type: \"or\", filters: filtered } as R);\n },\n not: (result) => (result === null ? null : ({ type: \"not\", filter: result } as R)),\n });\n}\n"],"mappings":";;;;;AA2BA,MAAM,kBAA0C,IAAI,IAbY;CAC9D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAC6E;;AAG9E,SAAS,aAAgB,MAAkC;AACzD,KAAI,KAAK,QAAQ,KAAM,QAAO;AAC9B,QAAO,CAAC,OAAO,OAAO,KAAK,CAAC,MAAM,UAAU;AAC1C,UAAQ,OAAO,OAAf;GACE,KAAK;GACL,KAAK,UACH,QAAO;GACT,KAAK,SACH,QAAO,MAAM,MAAM,KAAK;GAC1B,QACE,uCAAe,MAAM;;GAEzB;;AAGJ,SAAS,YAAe,MAA4C;CAClE,MAAM,SAAkC,EAAE;AAC1C,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,CAC7C,KAAI,gBAAgB,IAAI,IAAyB,CAC/C,QAAO,OAAO;AAGlB,QAAO;;;;;;AAOT,SAAgB,kBAKd,QAAyC;AACzC,KAAI,UAAU,KAAM,QAAO;AAC3B,QAAOA,oCAAiC,QAAQ;EAC9C,OAAO,SAAS;GACd,MAAM,YAAY,YAAY,KAAK;AACnC,UAAO,aAAa,UAAU,GAAI,YAAkB;;EAEtD,MAAM,YAAY;GAChB,MAAM,WAAW,QAAQ,QAAQ,MAAkC,MAAM,KAAK;AAC9E,UAAO,SAAS,WAAW,IAAI,OAAQ;IAAE,MAAM;IAAO,SAAS;IAAU;;EAE3E,KAAK,YAAY;GACf,MAAM,WAAW,QAAQ,QAAQ,MAAkC,MAAM,KAAK;AAC9E,UAAO,SAAS,WAAW,IAAI,OAAQ;IAAE,MAAM;IAAM,SAAS;IAAU;;EAE1E,MAAM,WAAY,WAAW,OAAO,OAAQ;GAAE,MAAM;GAAO,QAAQ;GAAQ;EAC5E,CAAC"}
|