@platforma-sdk/model 1.44.13 → 1.45.0
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 +29 -0
- package/dist/annotations/converter.cjs.map +1 -0
- package/dist/annotations/converter.d.ts +3 -0
- package/dist/annotations/converter.d.ts.map +1 -0
- package/dist/annotations/converter.js +27 -0
- package/dist/annotations/converter.js.map +1 -0
- package/dist/annotations/index.d.ts +3 -0
- package/dist/annotations/index.d.ts.map +1 -0
- package/dist/annotations/types.d.ts +22 -0
- package/dist/annotations/types.d.ts.map +1 -0
- package/dist/components/PlAnnotations/filter.d.ts.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.cjs +1 -372
- package/dist/components/PlAnnotations/filters_ui.cjs.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.d.ts +11 -756
- package/dist/components/PlAnnotations/filters_ui.d.ts.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.js +2 -370
- package/dist/components/PlAnnotations/filters_ui.js.map +1 -1
- package/dist/components/PlAnnotations/index.d.ts.map +1 -1
- package/dist/components/PlAnnotations/types.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/filters/converter.cjs +101 -0
- package/dist/filters/converter.cjs.map +1 -0
- package/dist/filters/converter.d.ts +5 -0
- package/dist/filters/converter.d.ts.map +1 -0
- package/dist/filters/converter.js +98 -0
- package/dist/filters/converter.js.map +1 -0
- package/dist/filters/index.d.ts +3 -0
- package/dist/filters/index.d.ts.map +1 -0
- package/dist/filters/types.d.ts +102 -0
- package/dist/filters/types.d.ts.map +1 -0
- package/dist/index.cjs +10 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/render/util/column_collection.cjs +2 -2
- package/dist/render/util/column_collection.cjs.map +1 -1
- package/dist/render/util/column_collection.d.ts +2 -2
- package/dist/render/util/column_collection.d.ts.map +1 -1
- package/dist/render/util/column_collection.js +2 -2
- package/dist/render/util/column_collection.js.map +1 -1
- package/dist/render/util/pcolumn_data.cjs +4 -0
- package/dist/render/util/pcolumn_data.cjs.map +1 -1
- package/dist/render/util/pcolumn_data.d.ts.map +1 -1
- package/dist/render/util/pcolumn_data.js +4 -0
- package/dist/render/util/pcolumn_data.js.map +1 -1
- package/package.json +7 -6
- package/src/annotations/converter.test.ts +74 -0
- package/src/annotations/converter.ts +28 -0
- package/src/annotations/index.ts +2 -0
- package/src/annotations/types.ts +23 -0
- package/src/components/PlAnnotations/filter.ts +1 -0
- package/src/components/PlAnnotations/filters_ui.test.ts +1 -0
- package/src/components/PlAnnotations/filters_ui.ts +56 -439
- package/src/components/PlAnnotations/index.ts +1 -0
- package/src/components/PlAnnotations/types.ts +1 -0
- package/src/components/index.ts +1 -1
- package/src/filters/converter.test.ts +336 -0
- package/src/filters/converter.ts +119 -0
- package/src/filters/index.ts +2 -0
- package/src/filters/types.ts +47 -0
- package/src/index.ts +2 -0
- package/src/render/util/column_collection.ts +19 -19
- package/src/render/util/pcolumn_data.ts +4 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { SUniversalPColumnId } from '@milaboratories/pl-model-common';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { convertFilterSpecsToExpressionSpecs } from './converter';
|
|
4
|
+
import { FilterSpecUi } from './types';
|
|
5
|
+
|
|
6
|
+
describe('convertFilterSpecsToExpressionSpecs', () => {
|
|
7
|
+
test('should compile an empty annotation script', () => {
|
|
8
|
+
const script = convertFilterSpecsToExpressionSpecs([]);
|
|
9
|
+
expect(script).toEqual([]);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('should compile an annotation script with steps', () => {
|
|
13
|
+
const filters: FilterSpecUi[] = [
|
|
14
|
+
{
|
|
15
|
+
label: 'Step 1',
|
|
16
|
+
filter: {
|
|
17
|
+
type: 'and',
|
|
18
|
+
filters: [
|
|
19
|
+
{ type: 'isNA', column: 'colA' as unknown as SUniversalPColumnId },
|
|
20
|
+
{ type: 'patternEquals', column: 'colB' as unknown as SUniversalPColumnId, value: 'abc' },
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
const expected = [
|
|
26
|
+
{
|
|
27
|
+
"name": "Step 1",
|
|
28
|
+
"type": "alias",
|
|
29
|
+
"value": {
|
|
30
|
+
"conditions": [
|
|
31
|
+
{
|
|
32
|
+
"then": {
|
|
33
|
+
"type": "const",
|
|
34
|
+
"value": true,
|
|
35
|
+
},
|
|
36
|
+
"when": {
|
|
37
|
+
"operands": [
|
|
38
|
+
{
|
|
39
|
+
"type": "is_na",
|
|
40
|
+
"value": {
|
|
41
|
+
"name": "colA",
|
|
42
|
+
"type": "col",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"lhs": {
|
|
47
|
+
"name": "colB",
|
|
48
|
+
"type": "col",
|
|
49
|
+
},
|
|
50
|
+
"rhs": {
|
|
51
|
+
"type": "const",
|
|
52
|
+
"value": "abc",
|
|
53
|
+
},
|
|
54
|
+
"type": "eq",
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
"type": "and",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
"otherwise": {
|
|
62
|
+
"type": "const",
|
|
63
|
+
"value": false,
|
|
64
|
+
},
|
|
65
|
+
"type": "when_then_otherwise",
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
const script = convertFilterSpecsToExpressionSpecs(filters);
|
|
70
|
+
expect(script).toEqual(expected);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { when } from '@milaboratories/ptabler-expression-js';
|
|
2
|
+
import { convertFilterUiToExpressionImpl } from '../filters/converter';
|
|
3
|
+
import type { ExpressionSpec, FilterSpecUi } from './types';
|
|
4
|
+
|
|
5
|
+
export function convertFilterSpecsToExpressionSpecs(annotationsUI: FilterSpecUi[]): ExpressionSpec[] {
|
|
6
|
+
return annotationsUI
|
|
7
|
+
.filter((annotation) => {
|
|
8
|
+
// No need to convert empty steps
|
|
9
|
+
if (annotation.filter.type == null) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (annotation.filter.type === 'or') {
|
|
14
|
+
return annotation.filter.filters.length > 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (annotation.filter.type === 'and') {
|
|
18
|
+
return annotation.filter.filters.length > 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return false;
|
|
22
|
+
})
|
|
23
|
+
.map((step): ExpressionSpec => ({
|
|
24
|
+
type: 'alias',
|
|
25
|
+
name: step.label.trim(),
|
|
26
|
+
value: when(convertFilterUiToExpressionImpl(step.filter)).then(true).otherwise(false).toJSON(),
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Expression } from '@milaboratories/ptabler-expression-js';
|
|
2
|
+
import type { FilterSpec } from '../filters';
|
|
3
|
+
|
|
4
|
+
export type AnnotationSpec<T extends ExpressionSpec = ExpressionSpec> = {
|
|
5
|
+
title: string;
|
|
6
|
+
steps: T[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type ExpressionSpec<T extends Expression = Expression> = {
|
|
10
|
+
type: 'alias';
|
|
11
|
+
name: string;
|
|
12
|
+
value: T;
|
|
13
|
+
}; // | OtherExpressionSpecTypesInFuture;
|
|
14
|
+
|
|
15
|
+
export type AnnotationSpecUi<T extends FilterSpecUi = FilterSpecUi> = {
|
|
16
|
+
title: string;
|
|
17
|
+
steps: T[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type FilterSpecUi<T extends FilterSpec = Extract<FilterSpec, { type: 'and' | 'or' }>> = {
|
|
21
|
+
label: string;
|
|
22
|
+
filter: T;
|
|
23
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @DEPRECATED - use sdk/model/src/filters + sdk/model/src/annotations
|
|
1
2
|
import type { SUniversalPColumnId } from '@milaboratories/pl-model-common';
|
|
2
3
|
import { describe, expect, it, test } from 'vitest';
|
|
3
4
|
import type { AnnotationFilter, AnnotationScript, IsNA, NotFilter, NumericalComparisonFilter, PatternFilter, ValueRank } from './filter';
|
|
@@ -1,64 +1,59 @@
|
|
|
1
|
+
// @DEPRECATED - use sdk/model/src/filters + sdk/model/src/annotations
|
|
1
2
|
import type { SUniversalPColumnId } from '@milaboratories/pl-model-common';
|
|
3
|
+
import type { FilterSpecUi } from '../../annotations';
|
|
4
|
+
import type { FilterSpec } from '../../filters';
|
|
2
5
|
import type { AnnotationFilter, AnnotationMode, AnnotationScript, IsNA, NotFilter, NumericalComparisonFilter, PatternFilter, PatternPredicate, ValueRank } from './filter';
|
|
3
|
-
import type { SimplifiedPColumnSpec } from './types';
|
|
4
6
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
| { type: 'isNotNA'; column: SUniversalPColumnId }
|
|
26
|
-
| { type: 'patternEquals'; column: SUniversalPColumnId; value: string }
|
|
27
|
-
| { type: 'patternNotEquals'; column: SUniversalPColumnId; value: string }
|
|
28
|
-
| { type: 'patternContainSubsequence'; column: SUniversalPColumnId; value: string }
|
|
29
|
-
| { type: 'patternNotContainSubsequence'; column: SUniversalPColumnId; value: string }
|
|
30
|
-
| { type: 'topN'; column: SUniversalPColumnId; n: number }
|
|
31
|
-
| { type: 'bottomN'; column: SUniversalPColumnId; n: number }
|
|
32
|
-
| { type: 'lessThan'; column: SUniversalPColumnId; x: number }
|
|
33
|
-
| { type: 'greaterThan'; column: SUniversalPColumnId; x: number }
|
|
34
|
-
| { type: 'lessThanOrEqual'; column: SUniversalPColumnId; x: number }
|
|
35
|
-
| { type: 'greaterThanOrEqual'; column: SUniversalPColumnId; x: number }
|
|
36
|
-
| { type: 'lessThanColumn'; column: SUniversalPColumnId; rhs: SUniversalPColumnId; minDiff?: number }
|
|
37
|
-
| { type: 'lessThanColumnOrEqual'; column: SUniversalPColumnId; rhs: SUniversalPColumnId; minDiff?: number });
|
|
7
|
+
export type FilterUi = FilterSpec<Extract<
|
|
8
|
+
FilterSpec,
|
|
9
|
+
// supported filters
|
|
10
|
+
{ type:
|
|
11
|
+
| 'lessThan'
|
|
12
|
+
| 'greaterThan'
|
|
13
|
+
| 'lessThanOrEqual'
|
|
14
|
+
| 'greaterThanOrEqual'
|
|
15
|
+
| 'lessThanColumn'
|
|
16
|
+
| 'lessThanColumnOrEqual'
|
|
17
|
+
| 'patternContainSubsequence'
|
|
18
|
+
| 'patternNotContainSubsequence'
|
|
19
|
+
| 'patternEquals'
|
|
20
|
+
| 'patternNotEquals'
|
|
21
|
+
| 'topN'
|
|
22
|
+
| 'bottomN'
|
|
23
|
+
| 'isNA'
|
|
24
|
+
| 'isNotNA';
|
|
25
|
+
}
|
|
26
|
+
>, { id?: number; name?: string; isExpanded?: boolean }>;
|
|
38
27
|
|
|
39
28
|
export type FilterUiType = Exclude<FilterUi, { type: undefined }>['type'];
|
|
40
29
|
|
|
41
30
|
export type FilterUiOfType<T extends FilterUiType> = Extract<FilterUi, { type: T }>;
|
|
42
31
|
|
|
32
|
+
// DEPRECATED - use lib/ui/uikit/src/composition/filters
|
|
33
|
+
export function unreachable(x: never): never {
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
35
|
+
throw new Error('Unexpected object: ' + x);
|
|
36
|
+
}
|
|
37
|
+
|
|
43
38
|
export type TypeToLiteral<T> =
|
|
44
|
-
[T] extends [FilterUiType] ? 'FilterUiType' :
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
39
|
+
[T] extends [FilterUiType] ? 'FilterUiType' :
|
|
40
|
+
[T] extends [SUniversalPColumnId] ? 'SUniversalPColumnId' :
|
|
41
|
+
[T] extends [PatternPredicate] ? 'PatternPredicate' :
|
|
42
|
+
[T] extends [AnnotationFilter[]] ? 'AnnotationFilter[]' :
|
|
43
|
+
[T] extends [AnnotationFilter] ? 'AnnotationFilter' :
|
|
44
|
+
[T] extends [number] ? 'number' :
|
|
45
|
+
[T] extends [number | undefined] ? 'number?' :
|
|
46
|
+
[T] extends [string] ? 'string' :
|
|
47
|
+
[T] extends [string | undefined] ? 'string?' :
|
|
48
|
+
[T] extends [boolean] ? 'boolean' :
|
|
49
|
+
[T] extends [boolean | undefined] ? 'boolean?' :
|
|
50
|
+
[T] extends [unknown[]] ? 'unknown[]' :
|
|
51
|
+
// this is special
|
|
52
|
+
T extends number ? 'number' :
|
|
53
|
+
T extends string ? 'string' :
|
|
54
|
+
T extends boolean ? 'boolean' :
|
|
55
|
+
T extends Record<string, unknown> ? 'form' :
|
|
56
|
+
'unknown';
|
|
62
57
|
|
|
63
58
|
// @TODO: "parse" option
|
|
64
59
|
export type TypeField<V> = {
|
|
@@ -67,7 +62,7 @@ export type TypeField<V> = {
|
|
|
67
62
|
defaultValue: () => V | undefined;
|
|
68
63
|
};
|
|
69
64
|
|
|
70
|
-
export type TypeFieldRecord<T> = { [K in keyof T]: TypeField<T[K]>; };
|
|
65
|
+
export type TypeFieldRecord<T extends FilterUi> = { [K in keyof T]: TypeField<T[K]>; };
|
|
71
66
|
|
|
72
67
|
export type TypeForm<T> = {
|
|
73
68
|
[P in keyof T]: T[P] extends Record<string, unknown> ? {
|
|
@@ -94,377 +89,16 @@ export type FormField =
|
|
|
94
89
|
|
|
95
90
|
export type AnyForm = Record<string, FormField>;
|
|
96
91
|
|
|
97
|
-
type
|
|
98
|
-
|
|
99
|
-
label: string;
|
|
100
|
-
form: TypeForm<FilterUiOfType<T>>; // TODO: simplify this to `TypeField<T>`
|
|
101
|
-
supportedFor: (spec1: SimplifiedPColumnSpec, spec2: SimplifiedPColumnSpec | undefined) => boolean;
|
|
102
|
-
}
|
|
92
|
+
export type AnnotationStepUi = FilterSpecUi<FilterUi> & {
|
|
93
|
+
id?: number;
|
|
103
94
|
};
|
|
104
95
|
|
|
105
|
-
export
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
fieldType: 'SUniversalPColumnId',
|
|
112
|
-
defaultValue: () => undefined,
|
|
113
|
-
},
|
|
114
|
-
type: {
|
|
115
|
-
label: 'Predicate',
|
|
116
|
-
fieldType: 'FilterUiType',
|
|
117
|
-
defaultValue: () => 'lessThan',
|
|
118
|
-
},
|
|
119
|
-
x: {
|
|
120
|
-
label: 'X',
|
|
121
|
-
fieldType: 'number',
|
|
122
|
-
defaultValue: () => 0,
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
supportedFor: isNumericValueType,
|
|
126
|
-
},
|
|
127
|
-
greaterThan: {
|
|
128
|
-
label: 'Col > X (Greater Than)',
|
|
129
|
-
form: {
|
|
130
|
-
column: {
|
|
131
|
-
label: 'Column',
|
|
132
|
-
fieldType: 'SUniversalPColumnId',
|
|
133
|
-
defaultValue: () => undefined,
|
|
134
|
-
},
|
|
135
|
-
type: {
|
|
136
|
-
label: 'Predicate',
|
|
137
|
-
fieldType: 'FilterUiType',
|
|
138
|
-
defaultValue: () => 'greaterThan',
|
|
139
|
-
},
|
|
140
|
-
x: {
|
|
141
|
-
label: 'X',
|
|
142
|
-
fieldType: 'number',
|
|
143
|
-
defaultValue: () => 0,
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
supportedFor: isNumericValueType,
|
|
147
|
-
},
|
|
148
|
-
lessThanOrEqual: {
|
|
149
|
-
label: 'Col ≤ X (Less Than or Equal)',
|
|
150
|
-
form: {
|
|
151
|
-
column: {
|
|
152
|
-
label: 'Column',
|
|
153
|
-
fieldType: 'SUniversalPColumnId',
|
|
154
|
-
defaultValue: () => undefined,
|
|
155
|
-
},
|
|
156
|
-
type: {
|
|
157
|
-
label: 'Predicate',
|
|
158
|
-
fieldType: 'FilterUiType',
|
|
159
|
-
defaultValue: () => 'lessThanOrEqual',
|
|
160
|
-
},
|
|
161
|
-
x: {
|
|
162
|
-
label: 'X',
|
|
163
|
-
fieldType: 'number',
|
|
164
|
-
defaultValue: () => 0,
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
supportedFor: isNumericValueType,
|
|
168
|
-
},
|
|
169
|
-
greaterThanOrEqual: {
|
|
170
|
-
label: 'Col ≥ X (Greater Than or Equal)',
|
|
171
|
-
form: {
|
|
172
|
-
column: {
|
|
173
|
-
label: 'Column',
|
|
174
|
-
fieldType: 'SUniversalPColumnId',
|
|
175
|
-
defaultValue: () => undefined,
|
|
176
|
-
},
|
|
177
|
-
type: {
|
|
178
|
-
label: 'Predicate',
|
|
179
|
-
fieldType: 'FilterUiType',
|
|
180
|
-
defaultValue: () => 'greaterThanOrEqual',
|
|
181
|
-
},
|
|
182
|
-
x: {
|
|
183
|
-
label: 'X',
|
|
184
|
-
fieldType: 'number',
|
|
185
|
-
defaultValue: () => 0,
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
supportedFor: isNumericValueType,
|
|
189
|
-
},
|
|
190
|
-
lessThanColumn: {
|
|
191
|
-
label: 'Col₁ < Col₂ (Compare Columns)',
|
|
192
|
-
form: {
|
|
193
|
-
column: {
|
|
194
|
-
label: 'Col₁',
|
|
195
|
-
fieldType: 'SUniversalPColumnId',
|
|
196
|
-
defaultValue: () => undefined,
|
|
197
|
-
},
|
|
198
|
-
type: {
|
|
199
|
-
label: 'Predicate',
|
|
200
|
-
fieldType: 'FilterUiType',
|
|
201
|
-
defaultValue: () => 'lessThanColumn',
|
|
202
|
-
},
|
|
203
|
-
rhs: {
|
|
204
|
-
label: 'Col₂',
|
|
205
|
-
fieldType: 'SUniversalPColumnId',
|
|
206
|
-
defaultValue: () => undefined,
|
|
207
|
-
},
|
|
208
|
-
minDiff: {
|
|
209
|
-
label: 'Margin (positive)',
|
|
210
|
-
fieldType: 'number?',
|
|
211
|
-
defaultValue: () => undefined,
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
supportedFor: (spec1: SimplifiedPColumnSpec, spec2?: SimplifiedPColumnSpec): boolean => {
|
|
215
|
-
return isNumericValueType(spec1) && (spec2 === undefined || isNumericValueType(spec2));
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
lessThanColumnOrEqual: {
|
|
219
|
-
label: 'Col₁ ≤ Col₂ (Compare Columns)',
|
|
220
|
-
form: {
|
|
221
|
-
column: {
|
|
222
|
-
label: 'Col₁',
|
|
223
|
-
fieldType: 'SUniversalPColumnId',
|
|
224
|
-
defaultValue: () => undefined,
|
|
225
|
-
},
|
|
226
|
-
type: {
|
|
227
|
-
label: 'Predicate',
|
|
228
|
-
fieldType: 'FilterUiType',
|
|
229
|
-
defaultValue: () => 'lessThanColumnOrEqual',
|
|
230
|
-
},
|
|
231
|
-
rhs: {
|
|
232
|
-
label: 'Col₂',
|
|
233
|
-
fieldType: 'SUniversalPColumnId',
|
|
234
|
-
defaultValue: () => undefined,
|
|
235
|
-
},
|
|
236
|
-
minDiff: {
|
|
237
|
-
label: 'Margin (positive)',
|
|
238
|
-
fieldType: 'number?',
|
|
239
|
-
defaultValue: () => undefined,
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
supportedFor: (spec1: SimplifiedPColumnSpec, spec2?: SimplifiedPColumnSpec): boolean => {
|
|
243
|
-
return isNumericValueType(spec1) && (spec2 === undefined || isNumericValueType(spec2));
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
topN: {
|
|
247
|
-
label: 'Top N',
|
|
248
|
-
form: {
|
|
249
|
-
column: {
|
|
250
|
-
label: 'Rank By Column',
|
|
251
|
-
fieldType: 'SUniversalPColumnId',
|
|
252
|
-
defaultValue: () => undefined,
|
|
253
|
-
},
|
|
254
|
-
type: {
|
|
255
|
-
label: 'Predicate',
|
|
256
|
-
fieldType: 'FilterUiType',
|
|
257
|
-
defaultValue: () => 'topN',
|
|
258
|
-
},
|
|
259
|
-
n: {
|
|
260
|
-
label: 'N',
|
|
261
|
-
fieldType: 'number',
|
|
262
|
-
defaultValue: () => 10,
|
|
263
|
-
},
|
|
264
|
-
},
|
|
265
|
-
supportedFor: isNumericValueType,
|
|
266
|
-
},
|
|
267
|
-
bottomN: {
|
|
268
|
-
label: 'Bottom N',
|
|
269
|
-
form: {
|
|
270
|
-
column: {
|
|
271
|
-
label: 'Rank By Column',
|
|
272
|
-
fieldType: 'SUniversalPColumnId',
|
|
273
|
-
defaultValue: () => undefined,
|
|
274
|
-
},
|
|
275
|
-
type: {
|
|
276
|
-
label: 'Predicate',
|
|
277
|
-
fieldType: 'FilterUiType',
|
|
278
|
-
defaultValue: () => 'bottomN',
|
|
279
|
-
},
|
|
280
|
-
n: {
|
|
281
|
-
label: 'N',
|
|
282
|
-
fieldType: 'number',
|
|
283
|
-
defaultValue: () => 10,
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
supportedFor: isNumericValueType,
|
|
287
|
-
},
|
|
288
|
-
patternContainSubsequence: {
|
|
289
|
-
label: 'Col ~ Seq (Contain Subsequence)',
|
|
290
|
-
form: {
|
|
291
|
-
column: {
|
|
292
|
-
label: 'Column',
|
|
293
|
-
fieldType: 'SUniversalPColumnId',
|
|
294
|
-
defaultValue: () => undefined,
|
|
295
|
-
},
|
|
296
|
-
type: {
|
|
297
|
-
label: 'Predicate',
|
|
298
|
-
fieldType: 'FilterUiType',
|
|
299
|
-
defaultValue: () => 'patternContainSubsequence',
|
|
300
|
-
},
|
|
301
|
-
value: {
|
|
302
|
-
label: 'Seq',
|
|
303
|
-
fieldType: 'string',
|
|
304
|
-
defaultValue: () => '',
|
|
305
|
-
},
|
|
306
|
-
},
|
|
307
|
-
supportedFor: isStringValueType,
|
|
308
|
-
},
|
|
309
|
-
patternNotContainSubsequence: {
|
|
310
|
-
label: 'Col ≁ Seq (Not Contain Subsequence)',
|
|
311
|
-
form: {
|
|
312
|
-
column: {
|
|
313
|
-
label: 'Column',
|
|
314
|
-
fieldType: 'SUniversalPColumnId',
|
|
315
|
-
defaultValue: () => undefined,
|
|
316
|
-
},
|
|
317
|
-
type: {
|
|
318
|
-
label: 'Predicate',
|
|
319
|
-
fieldType: 'FilterUiType',
|
|
320
|
-
defaultValue: () => 'patternNotContainSubsequence',
|
|
321
|
-
},
|
|
322
|
-
value: {
|
|
323
|
-
label: 'Seq',
|
|
324
|
-
fieldType: 'string',
|
|
325
|
-
defaultValue: () => '',
|
|
326
|
-
},
|
|
327
|
-
},
|
|
328
|
-
supportedFor: isStringValueType,
|
|
329
|
-
},
|
|
330
|
-
patternEquals: {
|
|
331
|
-
label: 'Col = Seq (Equals)',
|
|
332
|
-
form: {
|
|
333
|
-
column: {
|
|
334
|
-
label: 'Column',
|
|
335
|
-
fieldType: 'SUniversalPColumnId',
|
|
336
|
-
defaultValue: () => undefined,
|
|
337
|
-
},
|
|
338
|
-
type: {
|
|
339
|
-
label: 'Predicate',
|
|
340
|
-
fieldType: 'FilterUiType',
|
|
341
|
-
defaultValue: () => 'patternEquals',
|
|
342
|
-
},
|
|
343
|
-
value: {
|
|
344
|
-
label: 'Seq',
|
|
345
|
-
fieldType: 'string',
|
|
346
|
-
defaultValue: () => '',
|
|
347
|
-
},
|
|
348
|
-
},
|
|
349
|
-
supportedFor: isStringValueType,
|
|
350
|
-
},
|
|
351
|
-
patternNotEquals: {
|
|
352
|
-
label: 'Col ≠ Seq (Not Equal)',
|
|
353
|
-
form: {
|
|
354
|
-
column: {
|
|
355
|
-
label: 'Column',
|
|
356
|
-
fieldType: 'SUniversalPColumnId',
|
|
357
|
-
defaultValue: () => undefined,
|
|
358
|
-
},
|
|
359
|
-
type: {
|
|
360
|
-
label: 'Predicate',
|
|
361
|
-
fieldType: 'FilterUiType',
|
|
362
|
-
defaultValue: () => 'patternNotEquals',
|
|
363
|
-
},
|
|
364
|
-
value: {
|
|
365
|
-
label: 'Seq',
|
|
366
|
-
fieldType: 'string',
|
|
367
|
-
defaultValue: () => '',
|
|
368
|
-
},
|
|
369
|
-
},
|
|
370
|
-
supportedFor: isStringValueType,
|
|
371
|
-
},
|
|
372
|
-
isNA: {
|
|
373
|
-
label: 'Is NA',
|
|
374
|
-
form: {
|
|
375
|
-
column: {
|
|
376
|
-
label: 'Column',
|
|
377
|
-
fieldType: 'SUniversalPColumnId',
|
|
378
|
-
defaultValue: () => undefined,
|
|
379
|
-
},
|
|
380
|
-
type: {
|
|
381
|
-
label: 'Predicate',
|
|
382
|
-
fieldType: 'FilterUiType',
|
|
383
|
-
defaultValue: () => 'isNA',
|
|
384
|
-
},
|
|
385
|
-
},
|
|
386
|
-
supportedFor: () => true,
|
|
387
|
-
},
|
|
388
|
-
isNotNA: {
|
|
389
|
-
label: 'Is Not NA',
|
|
390
|
-
form: {
|
|
391
|
-
column: {
|
|
392
|
-
label: 'Column',
|
|
393
|
-
fieldType: 'SUniversalPColumnId',
|
|
394
|
-
defaultValue: () => undefined,
|
|
395
|
-
},
|
|
396
|
-
type: {
|
|
397
|
-
label: 'Predicate',
|
|
398
|
-
fieldType: 'FilterUiType',
|
|
399
|
-
defaultValue: () => 'isNotNA',
|
|
400
|
-
},
|
|
401
|
-
},
|
|
402
|
-
supportedFor: () => true,
|
|
403
|
-
},
|
|
404
|
-
or: {
|
|
405
|
-
label: 'Or',
|
|
406
|
-
form: {
|
|
407
|
-
type: {
|
|
408
|
-
fieldType: 'FilterUiType',
|
|
409
|
-
label: 'Predicate',
|
|
410
|
-
defaultValue: () => 'or',
|
|
411
|
-
},
|
|
412
|
-
filters: {
|
|
413
|
-
fieldType: 'unknown[]',
|
|
414
|
-
label: 'Filters',
|
|
415
|
-
defaultValue: () => [],
|
|
416
|
-
},
|
|
417
|
-
},
|
|
418
|
-
supportedFor: () => false,
|
|
419
|
-
},
|
|
420
|
-
and: {
|
|
421
|
-
label: 'And',
|
|
422
|
-
form: {
|
|
423
|
-
type: {
|
|
424
|
-
fieldType: 'FilterUiType',
|
|
425
|
-
label: 'Predicate',
|
|
426
|
-
defaultValue: () => 'and',
|
|
427
|
-
},
|
|
428
|
-
filters: {
|
|
429
|
-
fieldType: 'unknown[]',
|
|
430
|
-
label: 'Filters',
|
|
431
|
-
defaultValue: () => [],
|
|
432
|
-
},
|
|
433
|
-
},
|
|
434
|
-
supportedFor: () => false,
|
|
435
|
-
},
|
|
436
|
-
not: {
|
|
437
|
-
label: 'Not',
|
|
438
|
-
form: {
|
|
439
|
-
type: {
|
|
440
|
-
fieldType: 'FilterUiType',
|
|
441
|
-
label: 'Predicate',
|
|
442
|
-
defaultValue: () => 'not',
|
|
443
|
-
},
|
|
444
|
-
filter: {
|
|
445
|
-
fieldType: 'form',
|
|
446
|
-
label: 'Filter',
|
|
447
|
-
defaultValue: () => undefined as unknown as FilterUi, // TODO:
|
|
448
|
-
},
|
|
449
|
-
},
|
|
450
|
-
supportedFor: () => false,
|
|
451
|
-
},
|
|
452
|
-
} satisfies CreateFilterUiMetadataMap<FilterUiType>;
|
|
453
|
-
|
|
454
|
-
export function getFilterUiTypeOptions(columnSpec?: SimplifiedPColumnSpec) {
|
|
455
|
-
if (!columnSpec) {
|
|
456
|
-
return [];
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
return Object.entries(filterUiMetadata).filter(([_, metadata]) => metadata.supportedFor(columnSpec)).map(([type, metadata]) => ({
|
|
460
|
-
label: metadata.label,
|
|
461
|
-
value: type,
|
|
462
|
-
}));
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
export function getFilterUiMetadata(type: FilterUiType) {
|
|
466
|
-
return filterUiMetadata[type];
|
|
467
|
-
}
|
|
96
|
+
export type AnnotationScriptUi = {
|
|
97
|
+
isCreated?: boolean;
|
|
98
|
+
title: string;
|
|
99
|
+
mode: AnnotationMode;
|
|
100
|
+
steps: AnnotationStepUi[];
|
|
101
|
+
};
|
|
468
102
|
|
|
469
103
|
export function compileFilter(ui: FilterUi): AnnotationFilter {
|
|
470
104
|
if (ui.type === 'or') {
|
|
@@ -626,10 +260,6 @@ export function compileFilter(ui: FilterUi): AnnotationFilter {
|
|
|
626
260
|
};
|
|
627
261
|
}
|
|
628
262
|
|
|
629
|
-
if (ui.type === undefined) {
|
|
630
|
-
throw new Error('Filter type is undefined, this should not happen');
|
|
631
|
-
}
|
|
632
|
-
|
|
633
263
|
unreachable(ui);
|
|
634
264
|
}
|
|
635
265
|
|
|
@@ -637,19 +267,6 @@ export function compileFilters(uiFilters: FilterUi[]): AnnotationFilter[] {
|
|
|
637
267
|
return uiFilters.filter((f) => f.type !== undefined).map(compileFilter);
|
|
638
268
|
}
|
|
639
269
|
|
|
640
|
-
export type AnnotationStepUi = {
|
|
641
|
-
id?: number;
|
|
642
|
-
label: string;
|
|
643
|
-
filter: Extract<FilterUi, { type: 'and' | 'or' }>;
|
|
644
|
-
};
|
|
645
|
-
|
|
646
|
-
export type AnnotationScriptUi = {
|
|
647
|
-
isCreated?: boolean;
|
|
648
|
-
title: string;
|
|
649
|
-
mode: AnnotationMode;
|
|
650
|
-
steps: AnnotationStepUi[];
|
|
651
|
-
};
|
|
652
|
-
|
|
653
270
|
export function compileAnnotationScript(uiScript: AnnotationScriptUi): AnnotationScript {
|
|
654
271
|
return {
|
|
655
272
|
title: uiScript.title,
|