@gingkoo/pandora-metabase 1.0.118 → 1.0.119
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/lib/cjs/common/Portal/index.js +0 -2
- package/lib/cjs/common/SplitView/index.d.ts +0 -4
- package/lib/cjs/common/SplitView/index.js +0 -10
- package/lib/cjs/components/dialog/custom-column/config.js +4 -48
- package/lib/cjs/components/dialog/custom-column/expression-editor.js +3 -14
- package/lib/cjs/components/dialog/custom-column/expressions/suggest.d.ts +2 -34
- package/lib/cjs/components/dialog/custom-column/expressions/suggest.js +2 -43
- package/lib/cjs/components/dialog/custom-column/expressions/tokenizer.js +8 -65
- package/lib/cjs/components/dialog/custom-column/index.js +2 -4
- package/lib/cjs/components/dialog/custom-column/tokenized-expression.js +2 -3
- package/lib/cjs/components/dialog/custom-column/tokenizedI-input.js +1 -1
- package/lib/cjs/components/dialog/custom-editor/index.js +2 -7
- package/lib/cjs/components/dialog/diff-viewer/index copy.js +1 -16
- package/lib/cjs/components/dialog/expression/date-format-picker.js +2 -20
- package/lib/cjs/components/dialog/expression/date-format.js +2 -8
- package/lib/cjs/components/dialog/expression/index.d.ts +0 -3
- package/lib/cjs/components/dialog/expression/index.js +2 -83
- package/lib/cjs/components/dialog/formula/index.js +1 -30
- package/lib/cjs/components/dialog/formula/utils.js +2 -10
- package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.d.ts +19 -0
- package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.js +109 -0
- package/lib/cjs/components/dialog/formula-list/LogicGroup.d.ts +9 -0
- package/lib/cjs/components/dialog/formula-list/LogicGroup.js +43 -0
- package/lib/cjs/components/dialog/formula-list/index.d.ts +3 -0
- package/lib/cjs/components/dialog/formula-list/index.js +967 -503
- package/lib/cjs/components/dialog/formula-list/index.less +724 -0
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +0 -7
- package/lib/cjs/components/dialog/formula-list/utils.js +117 -113
- package/lib/cjs/components/dialog/select-column/index.d.ts +0 -6
- package/lib/cjs/components/dialog/select-column/index.js +4 -15
- package/lib/cjs/components/dialog/select-column-multiple/index.d.ts +0 -8
- package/lib/cjs/components/dialog/select-column-multiple/index.js +6 -45
- package/lib/cjs/components/dialog/select-join/index.d.ts +0 -5
- package/lib/cjs/components/dialog/select-join/index.js +0 -6
- package/lib/cjs/components/dialog/select-join-column/index.d.ts +0 -8
- package/lib/cjs/components/dialog/select-join-column/index.js +7 -21
- package/lib/cjs/components/dialog/select-join-column-multiple/index.d.ts +0 -8
- package/lib/cjs/components/dialog/select-join-column-multiple/index.js +5 -35
- package/lib/cjs/components/dialog/select-permission-table/index.d.ts +0 -5
- package/lib/cjs/components/dialog/select-permission-table/index.js +0 -6
- package/lib/cjs/components/dialog/select-summarize/index.d.ts +3 -3
- package/lib/cjs/components/dialog/select-summarize/index.js +105 -18
- package/lib/cjs/components/dialog/select-summarize/index.less +23 -0
- package/lib/cjs/components/dialog/select-table/index.d.ts +0 -6
- package/lib/cjs/components/dialog/select-table/index.js +1 -9
- package/lib/cjs/components/metabase/index.js +72 -86
- package/lib/cjs/components/metabase/index.less +7 -7
- package/lib/cjs/components/modules/components/Wrapper.js +1 -1
- package/lib/cjs/components/modules/components/header.js +2 -2
- package/lib/cjs/components/modules/components/meta-icon.d.ts +0 -3
- package/lib/cjs/components/modules/components/meta-icon.js +2 -47
- package/lib/cjs/components/modules/custom-column.js +3 -29
- package/lib/cjs/components/modules/enum/filter-enum.js +9 -88
- package/lib/cjs/components/modules/filter.js +2 -20
- package/lib/cjs/components/modules/index.d.ts +4 -2
- package/lib/cjs/components/modules/index.js +24 -1
- package/lib/cjs/components/modules/join-data.js +13 -291
- package/lib/cjs/components/modules/row-limit.js +0 -1
- package/lib/cjs/components/modules/sort.js +1 -61
- package/lib/cjs/components/modules/summarize/group-by.d.ts +0 -5
- package/lib/cjs/components/modules/summarize/group-by.js +231 -76
- package/lib/cjs/components/modules/summarize/select-index.js +96 -46
- package/lib/cjs/components/modules/table-data.js +11 -64
- package/lib/cjs/components/popup.js +26 -32
- package/lib/cjs/hooks/patch.d.ts +1 -0
- package/lib/cjs/hooks/patch.js +104 -6
- package/lib/cjs/hooks/patch2.js +3 -165
- package/lib/cjs/hooks/use-provider.js +0 -3
- package/lib/cjs/hooks/use-state.js +55 -135
- package/lib/cjs/index.js +0 -15
- package/lib/cjs/locale/en.js +5 -0
- package/lib/cjs/locale/index.js +1 -4
- package/lib/cjs/locale/zh.js +5 -0
- package/lib/cjs/sql-formula.js +0 -1
- package/lib/cjs/store/enum.d.ts +6 -6
- package/lib/cjs/store/enum.js +0 -13
- package/lib/cjs/store/helper.d.ts +2 -1
- package/lib/cjs/store/helper.js +15 -225
- package/lib/cjs/store/types.d.ts +45 -67
- package/lib/cjs/store/types.js +3 -49
- package/lib/cjs/types.d.ts +1 -0
- package/lib/cjs/utils/cookies.js +0 -3
- package/lib/cjs/utils/event.js +1 -1
- package/lib/cjs/utils/helper-dom.d.ts +1 -0
- package/lib/cjs/utils/helper-dom.js +17 -10
- package/lib/cjs/utils/helper.js +1 -24
- package/lib/cjs/utils/keydown.js +4 -7
- package/lib/cjs/utils/platform.d.ts +0 -9
- package/lib/cjs/utils/platform.js +0 -10
- package/lib/cjs/utils/selection.js +0 -6
- package/lib/cjs/utils/storage.d.ts +0 -9
- package/lib/cjs/utils/storage.js +1 -11
- package/lib/cjs/utils/transformSql.d.ts +5 -0
- package/lib/cjs/utils/transformSql.js +42 -113
- package/lib/cjs/utils.d.ts +1 -6
- package/lib/cjs/utils.js +115 -255
- package/lib/es/common/Portal/index.js +0 -2
- package/lib/es/common/SplitView/index.d.ts +0 -4
- package/lib/es/common/SplitView/index.js +0 -10
- package/lib/es/components/dialog/custom-column/config.js +4 -48
- package/lib/es/components/dialog/custom-column/expression-editor.js +3 -14
- package/lib/es/components/dialog/custom-column/expressions/suggest.d.ts +2 -34
- package/lib/es/components/dialog/custom-column/expressions/suggest.js +2 -43
- package/lib/es/components/dialog/custom-column/expressions/tokenizer.js +8 -65
- package/lib/es/components/dialog/custom-column/index.js +2 -4
- package/lib/es/components/dialog/custom-column/tokenized-expression.js +1 -3
- package/lib/es/components/dialog/custom-column/tokenizedI-input.js +1 -1
- package/lib/es/components/dialog/custom-editor/index.js +1 -7
- package/lib/es/components/dialog/diff-viewer/index copy.js +1 -15
- package/lib/es/components/dialog/expression/date-format-picker.js +2 -20
- package/lib/es/components/dialog/expression/date-format.js +2 -8
- package/lib/es/components/dialog/expression/index.d.ts +0 -3
- package/lib/es/components/dialog/expression/index.js +2 -82
- package/lib/es/components/dialog/formula/index.js +0 -30
- package/lib/es/components/dialog/formula/utils.js +2 -10
- package/lib/es/components/dialog/formula-list/CaseWhenGroup.d.ts +19 -0
- package/lib/es/components/dialog/formula-list/CaseWhenGroup.js +102 -0
- package/lib/es/components/dialog/formula-list/LogicGroup.d.ts +9 -0
- package/lib/es/components/dialog/formula-list/LogicGroup.js +36 -0
- package/lib/es/components/dialog/formula-list/index.d.ts +3 -0
- package/lib/es/components/dialog/formula-list/index.js +966 -503
- package/lib/es/components/dialog/formula-list/index.less +724 -0
- package/lib/es/components/dialog/formula-list/utils.d.ts +0 -7
- package/lib/es/components/dialog/formula-list/utils.js +117 -113
- package/lib/es/components/dialog/index.js +3 -3
- package/lib/es/components/dialog/select-column/index.d.ts +0 -6
- package/lib/es/components/dialog/select-column/index.js +4 -14
- package/lib/es/components/dialog/select-column-multiple/index.d.ts +0 -8
- package/lib/es/components/dialog/select-column-multiple/index.js +7 -47
- package/lib/es/components/dialog/select-join/index.d.ts +0 -5
- package/lib/es/components/dialog/select-join/index.js +0 -5
- package/lib/es/components/dialog/select-join-column/index.d.ts +0 -8
- package/lib/es/components/dialog/select-join-column/index.js +7 -20
- package/lib/es/components/dialog/select-join-column-multiple/index.d.ts +0 -8
- package/lib/es/components/dialog/select-join-column-multiple/index.js +5 -34
- package/lib/es/components/dialog/select-permission-table/index.d.ts +0 -5
- package/lib/es/components/dialog/select-permission-table/index.js +0 -5
- package/lib/es/components/dialog/select-summarize/index.d.ts +3 -3
- package/lib/es/components/dialog/select-summarize/index.js +106 -18
- package/lib/es/components/dialog/select-summarize/index.less +23 -0
- package/lib/es/components/dialog/select-table/index.d.ts +0 -6
- package/lib/es/components/dialog/select-table/index.js +1 -8
- package/lib/es/components/metabase/index.js +72 -87
- package/lib/es/components/metabase/index.less +7 -7
- package/lib/es/components/modules/components/Wrapper.js +1 -1
- package/lib/es/components/modules/components/header.js +2 -2
- package/lib/es/components/modules/components/meta-icon.d.ts +0 -3
- package/lib/es/components/modules/components/meta-icon.js +2 -46
- package/lib/es/components/modules/custom-column.js +3 -29
- package/lib/es/components/modules/enum/filter-enum.js +9 -88
- package/lib/es/components/modules/filter.js +2 -19
- package/lib/es/components/modules/index.d.ts +4 -2
- package/lib/es/components/modules/index.js +24 -1
- package/lib/es/components/modules/join-data.js +13 -291
- package/lib/es/components/modules/row-limit.js +0 -1
- package/lib/es/components/modules/sort.js +1 -61
- package/lib/es/components/modules/summarize/group-by.d.ts +0 -5
- package/lib/es/components/modules/summarize/group-by.js +233 -78
- package/lib/es/components/modules/summarize/select-index.js +96 -46
- package/lib/es/components/modules/table-data.js +11 -64
- package/lib/es/components/popup.js +27 -33
- package/lib/es/hooks/patch.d.ts +1 -0
- package/lib/es/hooks/patch.js +103 -5
- package/lib/es/hooks/patch2.js +2 -164
- package/lib/es/hooks/use-provider.js +0 -3
- package/lib/es/hooks/use-state.js +55 -135
- package/lib/es/index.js +0 -14
- package/lib/es/locale/en.js +5 -0
- package/lib/es/locale/index.js +1 -4
- package/lib/es/locale/zh.js +5 -0
- package/lib/es/sql-formula.js +0 -1
- package/lib/es/store/enum.d.ts +6 -6
- package/lib/es/store/enum.js +0 -13
- package/lib/es/store/helper.d.ts +2 -1
- package/lib/es/store/helper.js +13 -224
- package/lib/es/store/types.d.ts +45 -67
- package/lib/es/store/types.js +3 -49
- package/lib/es/types.d.ts +1 -0
- package/lib/es/types.js +1 -18
- package/lib/es/utils/cookies.js +0 -3
- package/lib/es/utils/event.js +1 -1
- package/lib/es/utils/helper-dom.d.ts +1 -0
- package/lib/es/utils/helper-dom.js +16 -9
- package/lib/es/utils/helper.js +1 -24
- package/lib/es/utils/keydown.js +4 -7
- package/lib/es/utils/platform.d.ts +0 -9
- package/lib/es/utils/platform.js +0 -10
- package/lib/es/utils/selection.js +0 -6
- package/lib/es/utils/storage.d.ts +0 -9
- package/lib/es/utils/storage.js +1 -10
- package/lib/es/utils/transformSql.d.ts +5 -0
- package/lib/es/utils/transformSql.js +42 -112
- package/lib/es/utils.d.ts +1 -6
- package/lib/es/utils.js +116 -255
- package/package.json +1 -1
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { AtomsTypeEnum, AtomsItem } from '../../../store/types';
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param type 当前选择的类型
|
|
5
|
-
* @param list 当前数组
|
|
6
|
-
* @param index 需要讲模版插入的位置
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
2
|
export declare const insertTemplateAt: (oldType: string, type: string, list: any[], index: number) => any[];
|
|
10
3
|
export declare const operatorList: string[];
|
|
11
4
|
export declare const customTypes: ({
|
|
@@ -2,18 +2,9 @@ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIt
|
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
3
|
import { __ } from '../../../locale';
|
|
4
4
|
import { AtomsTypeEnum } from '../../../store/types';
|
|
5
|
-
// import { FUNCTION_TEMPLATES } from '../function/utils';
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param type 当前选择的类型
|
|
9
|
-
* @param list 当前数组
|
|
10
|
-
* @param index 需要讲模版插入的位置
|
|
11
|
-
* @returns
|
|
12
|
-
*/
|
|
13
5
|
export var insertTemplateAt = function insertTemplateAt(oldType, type, list, index) {
|
|
14
6
|
var temList = [];
|
|
15
7
|
var needChange = ['RANK()', 'DENSE_RANK()', 'ROW_NUMBER()', 'when', 'case', 'then'].includes(oldType);
|
|
16
|
-
// 只改变类型不需要插入模版
|
|
17
8
|
if (needChange) {
|
|
18
9
|
return list;
|
|
19
10
|
}
|
|
@@ -65,58 +56,34 @@ export var insertTemplateAt = function insertTemplateAt(oldType, type, list, ind
|
|
|
65
56
|
type: AtomsTypeEnum.OPERATOR
|
|
66
57
|
}, {
|
|
67
58
|
fieldName: '',
|
|
68
|
-
// 字段名
|
|
69
59
|
fieldNameZh: '',
|
|
70
|
-
// 字段中文名
|
|
71
60
|
fieldAlias: '',
|
|
72
|
-
// 别名
|
|
73
61
|
fieldUuid: '',
|
|
74
|
-
// uuid
|
|
75
62
|
fieldId: '',
|
|
76
|
-
// 字段id
|
|
77
|
-
// quotes?: string; // 字段展示的 不知道有没有用
|
|
78
63
|
tableName: '',
|
|
79
|
-
// 表名
|
|
80
64
|
tableNameZh: '',
|
|
81
65
|
tableId: '',
|
|
82
|
-
// 表名
|
|
83
66
|
tableAlias: '',
|
|
84
|
-
// 别名
|
|
85
67
|
tableUuid: '',
|
|
86
|
-
// 表唯一标识
|
|
87
68
|
datasourceName: '',
|
|
88
|
-
// 数据源名
|
|
89
69
|
datasourceId: '',
|
|
90
|
-
// 数据源id
|
|
91
70
|
type: AtomsTypeEnum.FIELD
|
|
92
71
|
}, {
|
|
93
72
|
val: 'ORDER BY',
|
|
94
73
|
type: AtomsTypeEnum.OPERATOR
|
|
95
74
|
}, {
|
|
96
75
|
fieldName: '',
|
|
97
|
-
// 字段名
|
|
98
76
|
fieldNameZh: '',
|
|
99
|
-
// 字段中文名
|
|
100
77
|
fieldAlias: '',
|
|
101
|
-
// 别名
|
|
102
78
|
fieldUuid: '',
|
|
103
|
-
// uuid
|
|
104
79
|
fieldId: '',
|
|
105
|
-
// 字段id
|
|
106
|
-
// quotes?: string; // 字段展示的 不知道有没有用
|
|
107
80
|
tableName: '',
|
|
108
|
-
// 表名
|
|
109
81
|
tableNameZh: '',
|
|
110
82
|
tableId: '',
|
|
111
|
-
// 表名
|
|
112
83
|
tableAlias: '',
|
|
113
|
-
// 别名
|
|
114
84
|
tableUuid: '',
|
|
115
|
-
// 表唯一标识
|
|
116
85
|
datasourceName: '',
|
|
117
|
-
// 数据源名
|
|
118
86
|
datasourceId: '',
|
|
119
|
-
// 数据源id
|
|
120
87
|
type: AtomsTypeEnum.FIELD
|
|
121
88
|
}, {
|
|
122
89
|
val: ')',
|
|
@@ -127,46 +94,30 @@ export var insertTemplateAt = function insertTemplateAt(oldType, type, list, ind
|
|
|
127
94
|
return list;
|
|
128
95
|
};
|
|
129
96
|
export var operatorList = ['and', 'or', '(', ')', ',', '+', '-', '*', '/', '!', '!=', '<=', '>=', '<', '>', '=', 'case', 'when', 'then', 'else', 'end', 'NULL', 'DESC', 'ASC', 'OVER', 'PARTITION BY', 'ORDER BY', 'RANK()', 'DENSE_RANK()', 'ROW_NUMBER()'];
|
|
130
|
-
export var customTypes = [
|
|
131
|
-
// 字段
|
|
132
|
-
{
|
|
97
|
+
export var customTypes = [{
|
|
133
98
|
value: AtomsTypeEnum.FIELD,
|
|
134
99
|
label: __('customColumn.field')
|
|
135
|
-
},
|
|
136
|
-
// 表达式
|
|
137
|
-
{
|
|
100
|
+
}, {
|
|
138
101
|
value: AtomsTypeEnum.EXPRESSION,
|
|
139
102
|
label: __('customColumn.expression')
|
|
140
|
-
},
|
|
141
|
-
// 输入框
|
|
142
|
-
{
|
|
103
|
+
}, {
|
|
143
104
|
value: AtomsTypeEnum.INPUT_STRING,
|
|
144
105
|
label: __('customColumn.input')
|
|
145
|
-
},
|
|
146
|
-
// 数字输入框
|
|
147
|
-
{
|
|
106
|
+
}, {
|
|
148
107
|
value: AtomsTypeEnum.INPUT_NUMBER,
|
|
149
108
|
label: __('customColumn.numberInput')
|
|
150
|
-
},
|
|
151
|
-
// 数字输入框
|
|
152
|
-
{
|
|
109
|
+
}, {
|
|
153
110
|
value: AtomsTypeEnum.CONSTANT,
|
|
154
111
|
label: __('customColumn.constant')
|
|
155
|
-
},
|
|
156
|
-
// 连接符
|
|
157
|
-
{
|
|
112
|
+
}, {
|
|
158
113
|
value: AtomsTypeEnum.OPERATOR,
|
|
159
114
|
label: __('customColumn.operator'),
|
|
160
115
|
children: operatorList
|
|
161
|
-
},
|
|
162
|
-
// 函数
|
|
163
|
-
{
|
|
116
|
+
}, {
|
|
164
117
|
value: AtomsTypeEnum.FORMULA,
|
|
165
118
|
label: __('customColumn.formula'),
|
|
166
119
|
children: operatorList
|
|
167
|
-
},
|
|
168
|
-
// EXISTS
|
|
169
|
-
{
|
|
120
|
+
}, {
|
|
170
121
|
value: AtomsTypeEnum.NOT_EXISTS,
|
|
171
122
|
label: 'NOT_EXISTS'
|
|
172
123
|
}, {
|
|
@@ -178,38 +129,23 @@ export var customTypes = [
|
|
|
178
129
|
}];
|
|
179
130
|
export var getTemplateItem = function getTemplateItem(type, item) {
|
|
180
131
|
var temItem;
|
|
181
|
-
// 字段
|
|
182
132
|
if (type === AtomsTypeEnum.FIELD) {
|
|
183
133
|
temItem = {
|
|
184
134
|
fieldName: '',
|
|
185
|
-
// 字段名
|
|
186
135
|
fieldNameZh: '',
|
|
187
|
-
// 字段中文名
|
|
188
136
|
fieldAlias: '',
|
|
189
|
-
// 别名
|
|
190
137
|
fieldUuid: '',
|
|
191
|
-
// uuid
|
|
192
138
|
fieldId: '',
|
|
193
|
-
// 字段id
|
|
194
|
-
// quotes?: string; // 字段展示的 不知道有没有用
|
|
195
139
|
tableName: '',
|
|
196
|
-
// 表名
|
|
197
140
|
tableNameZh: '',
|
|
198
141
|
tableId: '',
|
|
199
|
-
// 表名
|
|
200
142
|
tableAlias: '',
|
|
201
|
-
// 别名
|
|
202
143
|
tableUuid: '',
|
|
203
|
-
// 表唯一标识
|
|
204
144
|
datasourceName: '',
|
|
205
|
-
// 数据源名
|
|
206
145
|
datasourceId: '',
|
|
207
|
-
// 数据源id
|
|
208
146
|
type: AtomsTypeEnum.FIELD
|
|
209
147
|
};
|
|
210
|
-
}
|
|
211
|
-
// 表达式
|
|
212
|
-
else if (type === AtomsTypeEnum.EXPRESSION || type === AtomsTypeEnum.JOIN_DEFAULT) {
|
|
148
|
+
} else if (type === AtomsTypeEnum.EXPRESSION || type === AtomsTypeEnum.JOIN_DEFAULT) {
|
|
213
149
|
return {
|
|
214
150
|
lhs: [],
|
|
215
151
|
rhs: [],
|
|
@@ -220,21 +156,17 @@ export var getTemplateItem = function getTemplateItem(type, item) {
|
|
|
220
156
|
} else if (type === AtomsTypeEnum.EXISTS || type === AtomsTypeEnum.NOT_EXISTS) {
|
|
221
157
|
return {
|
|
222
158
|
quotes: '',
|
|
223
|
-
// 展示用户看的 组装的文字
|
|
224
159
|
notExists: [],
|
|
225
160
|
type: type
|
|
226
161
|
};
|
|
227
162
|
} else if (type === AtomsTypeEnum.SUB_QUERY) {
|
|
228
163
|
return {
|
|
229
164
|
quotes: '',
|
|
230
|
-
// 展示用户看的 组装的文字
|
|
231
165
|
subQuery: [],
|
|
232
166
|
type: type
|
|
233
167
|
};
|
|
234
168
|
} else if (type === AtomsTypeEnum.UNKNOWN) {
|
|
235
169
|
return {
|
|
236
|
-
// quotes: '', // 展示用户看的 组装的文字
|
|
237
|
-
// notExists: [],
|
|
238
170
|
val: (item === null || item === void 0 ? void 0 : item["default"]) || '',
|
|
239
171
|
type: type
|
|
240
172
|
};
|
|
@@ -251,12 +183,37 @@ export var getTemplateItem = function getTemplateItem(type, item) {
|
|
|
251
183
|
} else if (type === AtomsTypeEnum.FORMULA) {
|
|
252
184
|
temItem = {
|
|
253
185
|
args: [],
|
|
254
|
-
// params: FUNCTION_TEMPLATES?.[type]?.params || [],
|
|
255
|
-
// arity: FUNCTION_TEMPLATES?.[type]?.arity || {},
|
|
256
186
|
name: '',
|
|
257
187
|
quotes: '',
|
|
258
188
|
type: type
|
|
259
189
|
};
|
|
190
|
+
} else if (type === AtomsTypeEnum.CASE_WHEN) {
|
|
191
|
+
return {
|
|
192
|
+
caseValue: [],
|
|
193
|
+
branches: [{
|
|
194
|
+
when: [{
|
|
195
|
+
val: '',
|
|
196
|
+
type: AtomsTypeEnum.UNKNOWN
|
|
197
|
+
}],
|
|
198
|
+
then: [{
|
|
199
|
+
val: '',
|
|
200
|
+
type: AtomsTypeEnum.UNKNOWN
|
|
201
|
+
}]
|
|
202
|
+
}],
|
|
203
|
+
elseValue: [],
|
|
204
|
+
quotes: '',
|
|
205
|
+
type: type
|
|
206
|
+
};
|
|
207
|
+
} else if (type === AtomsTypeEnum.AND_OR) {
|
|
208
|
+
return {
|
|
209
|
+
operator: 'and',
|
|
210
|
+
list: [{
|
|
211
|
+
val: '',
|
|
212
|
+
type: AtomsTypeEnum.UNKNOWN
|
|
213
|
+
}],
|
|
214
|
+
quotes: '',
|
|
215
|
+
type: type
|
|
216
|
+
};
|
|
260
217
|
} else if (type === AtomsTypeEnum.COLLECTION) {
|
|
261
218
|
return {
|
|
262
219
|
list: [],
|
|
@@ -273,7 +230,6 @@ export var getTemplateItem = function getTemplateItem(type, item) {
|
|
|
273
230
|
type: type
|
|
274
231
|
};
|
|
275
232
|
} else {
|
|
276
|
-
// 其他
|
|
277
233
|
temItem = {
|
|
278
234
|
val: '',
|
|
279
235
|
type: type
|
|
@@ -286,33 +242,37 @@ var _isOk = function isOk(rhsVal) {
|
|
|
286
242
|
if (v.type === AtomsTypeEnum.UNKNOWN) {
|
|
287
243
|
return false;
|
|
288
244
|
} else if (v.type === AtomsTypeEnum.JOIN_DEFAULT) {
|
|
289
|
-
|
|
290
|
-
return true; // 或者根据业务逻辑决定是否算“有效”
|
|
245
|
+
return true;
|
|
291
246
|
} else if (v.type === AtomsTypeEnum.FIELD) {
|
|
292
|
-
return Boolean(v.fieldName);
|
|
247
|
+
return Boolean(v.fieldName);
|
|
293
248
|
} else if (v.type === AtomsTypeEnum.EXPRESSION || v.type === AtomsTypeEnum.EXISTS || v.type === AtomsTypeEnum.NOT_EXISTS || v.type === AtomsTypeEnum.SUB_QUERY) {
|
|
294
|
-
return Boolean(v.quotes);
|
|
249
|
+
return Boolean(v.quotes);
|
|
295
250
|
} else if (v.type === AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
296
251
|
return Array.isArray(v.val) && v.val.every(function (vv) {
|
|
297
252
|
return Boolean(vv);
|
|
298
253
|
});
|
|
299
254
|
} else if (v.type === AtomsTypeEnum.COLLECTION) {
|
|
300
255
|
return _isOk(v.list || []);
|
|
256
|
+
} else if (v.type === AtomsTypeEnum.CASE_WHEN) {
|
|
257
|
+
return (v.branches || []).length > 0 && (v.branches || []).every(function (branch) {
|
|
258
|
+
return _isOk(branch.when || []) && _isOk(branch.then || []);
|
|
259
|
+
}) && _isOk(v.caseValue || []) && _isOk(v.elseValue || []);
|
|
260
|
+
} else if (v.type === AtomsTypeEnum.AND_OR) {
|
|
261
|
+
return Boolean(v.operator) && _isOk(v.list || []);
|
|
301
262
|
} else if (v.type === AtomsTypeEnum.FORMULA) {
|
|
302
263
|
if (!v.quotes) {
|
|
303
264
|
return false;
|
|
304
265
|
}
|
|
305
266
|
return _isOk(v.args || []);
|
|
267
|
+
} else if (v.type === AtomsTypeEnum.SELECT) {
|
|
268
|
+
return Array.isArray(v.val) ? v.val.length > 0 : Boolean(v.val);
|
|
306
269
|
} else {
|
|
307
|
-
return Boolean(v.val) || v.val === 0
|
|
270
|
+
return 'val' in v ? Boolean(v.val) || v.val === 0 : false;
|
|
308
271
|
}
|
|
309
272
|
});
|
|
310
273
|
};
|
|
311
|
-
// 校验表达式完整性
|
|
312
|
-
// 括号不匹配
|
|
313
274
|
export { _isOk as isOk };
|
|
314
275
|
function validateParentheses(list) {
|
|
315
|
-
console.log('🚀 ~ validateParentheses ~ list:', list);
|
|
316
276
|
var depth = 0;
|
|
317
277
|
var _iterator = _createForOfIteratorHelper(list),
|
|
318
278
|
_step;
|
|
@@ -333,14 +293,13 @@ function validateParentheses(list) {
|
|
|
333
293
|
}
|
|
334
294
|
return depth === 0;
|
|
335
295
|
}
|
|
336
|
-
// CASE 语句不完整(缺少 END 或 WHEN/THEN)
|
|
337
296
|
function validateCaseStructure(list) {
|
|
338
297
|
for (var i = 0; i < list.length; i++) {
|
|
339
298
|
var item = list[i];
|
|
340
299
|
if (item.type === AtomsTypeEnum.OPERATOR && item.val === 'case') {
|
|
341
300
|
var depth = 1;
|
|
342
301
|
var hasValidWhenThen = false;
|
|
343
|
-
var lastWasWhen = false;
|
|
302
|
+
var lastWasWhen = false;
|
|
344
303
|
for (var j = i + 1; j < list.length; j++) {
|
|
345
304
|
var token = list[j];
|
|
346
305
|
if (token.type !== AtomsTypeEnum.OPERATOR) continue;
|
|
@@ -350,13 +309,11 @@ function validateCaseStructure(list) {
|
|
|
350
309
|
} else if (val === 'end') {
|
|
351
310
|
depth--;
|
|
352
311
|
if (depth === 0) {
|
|
353
|
-
// 当前 case 块结束
|
|
354
312
|
if (!hasValidWhenThen) {
|
|
355
|
-
return false;
|
|
313
|
+
return false;
|
|
356
314
|
}
|
|
357
|
-
break;
|
|
315
|
+
break;
|
|
358
316
|
}
|
|
359
|
-
// 如果 depth < 0,说明 end 多余,但这里我们只关心当前 case,可忽略或报错
|
|
360
317
|
} else if (val === 'when') {
|
|
361
318
|
if (depth === 1) {
|
|
362
319
|
lastWasWhen = true;
|
|
@@ -364,28 +321,24 @@ function validateCaseStructure(list) {
|
|
|
364
321
|
} else if (val === 'then') {
|
|
365
322
|
if (depth === 1) {
|
|
366
323
|
if (!lastWasWhen) {
|
|
367
|
-
return false;
|
|
324
|
+
return false;
|
|
368
325
|
}
|
|
369
326
|
hasValidWhenThen = true;
|
|
370
|
-
lastWasWhen = false;
|
|
327
|
+
lastWasWhen = false;
|
|
371
328
|
}
|
|
372
329
|
}
|
|
373
|
-
// 注意:其他操作符(如 else)可在此扩展
|
|
374
330
|
}
|
|
375
|
-
// 如果循环结束还没找到匹配的 end(即 depth > 0)
|
|
376
331
|
if (depth > 0) {
|
|
377
|
-
return false;
|
|
332
|
+
return false;
|
|
378
333
|
}
|
|
379
334
|
}
|
|
380
335
|
}
|
|
381
336
|
return true;
|
|
382
337
|
}
|
|
383
|
-
// 窗口函数结构不完整(缺少 OVER 或括号)
|
|
384
338
|
function validateWindowFunction(list) {
|
|
385
339
|
for (var i = 0; i < list.length; i++) {
|
|
386
340
|
var item = list[i];
|
|
387
341
|
if (item.type === AtomsTypeEnum.OPERATOR && ['RANK()', 'DENSE_RANK()', 'ROW_NUMBER()'].includes(item.val)) {
|
|
388
|
-
// 找后面的 OVER (
|
|
389
342
|
var foundOver = false;
|
|
390
343
|
var parenDepth = 0;
|
|
391
344
|
for (var j = i + 1; j < list.length; j++) {
|
|
@@ -395,41 +348,95 @@ function validateWindowFunction(list) {
|
|
|
395
348
|
foundOver = true;
|
|
396
349
|
} else if (foundOver && next.val === '(') {
|
|
397
350
|
parenDepth = 1;
|
|
398
|
-
// 继续找匹配的 )
|
|
399
351
|
for (var k = j + 1; k < list.length; k++) {
|
|
400
352
|
if (list[k].type !== AtomsTypeEnum.OPERATOR) continue;
|
|
401
353
|
if (list[k].val === '(') parenDepth++;else if (list[k].val === ')') {
|
|
402
354
|
parenDepth--;
|
|
403
|
-
if (parenDepth === 0) return true;
|
|
355
|
+
if (parenDepth === 0) return true;
|
|
404
356
|
}
|
|
405
357
|
}
|
|
406
|
-
return false;
|
|
358
|
+
return false;
|
|
407
359
|
}
|
|
408
360
|
}
|
|
409
|
-
return false;
|
|
361
|
+
return false;
|
|
410
362
|
}
|
|
411
363
|
}
|
|
412
364
|
return true;
|
|
413
365
|
}
|
|
414
|
-
// 表达式末尾不能是操作符(如 +, AND, WHEN 等)
|
|
415
366
|
function validateNoTrailingOperator(list) {
|
|
416
|
-
// 从后往前找第一个非空 OPERATOR
|
|
417
367
|
for (var i = list.length - 1; i >= 0; i--) {
|
|
418
368
|
var item = list[i];
|
|
419
369
|
if (item.type === AtomsTypeEnum.UNKNOWN && item.val === '') continue;
|
|
420
370
|
if (item.type === AtomsTypeEnum.OPERATOR) {
|
|
421
371
|
var val = item.val;
|
|
422
|
-
// 二元操作符、逗号、(、when、then 等不能结尾
|
|
423
372
|
if (['+', '-', '*', '/', '=', '!=', '<', '>', 'and', 'or', ',', '(', 'when', 'then'].includes(val)) {
|
|
424
373
|
return false;
|
|
425
374
|
}
|
|
426
375
|
}
|
|
427
|
-
break;
|
|
376
|
+
break;
|
|
428
377
|
}
|
|
429
378
|
return true;
|
|
430
379
|
}
|
|
431
380
|
export function validateExpressionIntegrity(list) {
|
|
432
|
-
|
|
381
|
+
var _iterator2 = _createForOfIteratorHelper(list),
|
|
382
|
+
_step2;
|
|
383
|
+
try {
|
|
384
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
385
|
+
var item = _step2.value;
|
|
386
|
+
if (item.type === AtomsTypeEnum.AND_OR) {
|
|
387
|
+
if (!item.operator) {
|
|
388
|
+
return {
|
|
389
|
+
isError: true,
|
|
390
|
+
error: 'AND / OR 结构缺少操作符'
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
var nestedError = validateExpressionIntegrity(item.list || []);
|
|
394
|
+
if (nestedError.isError) {
|
|
395
|
+
return nestedError;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (item.type === AtomsTypeEnum.CASE_WHEN) {
|
|
399
|
+
if ((item.branches || []).length < 1) {
|
|
400
|
+
return {
|
|
401
|
+
isError: true,
|
|
402
|
+
error: 'CASE WHEN 至少需要一个 when / then 分支',
|
|
403
|
+
isCase: true
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
var caseValueError = validateExpressionIntegrity(item.caseValue || []);
|
|
407
|
+
if (caseValueError.isError) {
|
|
408
|
+
return caseValueError;
|
|
409
|
+
}
|
|
410
|
+
var _iterator3 = _createForOfIteratorHelper(item.branches || []),
|
|
411
|
+
_step3;
|
|
412
|
+
try {
|
|
413
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
414
|
+
var branch = _step3.value;
|
|
415
|
+
var whenError = validateExpressionIntegrity(branch.when || []);
|
|
416
|
+
if (whenError.isError) {
|
|
417
|
+
return whenError;
|
|
418
|
+
}
|
|
419
|
+
var thenError = validateExpressionIntegrity(branch.then || []);
|
|
420
|
+
if (thenError.isError) {
|
|
421
|
+
return thenError;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
} catch (err) {
|
|
425
|
+
_iterator3.e(err);
|
|
426
|
+
} finally {
|
|
427
|
+
_iterator3.f();
|
|
428
|
+
}
|
|
429
|
+
var elseError = validateExpressionIntegrity(item.elseValue || []);
|
|
430
|
+
if (elseError.isError) {
|
|
431
|
+
return elseError;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
} catch (err) {
|
|
436
|
+
_iterator2.e(err);
|
|
437
|
+
} finally {
|
|
438
|
+
_iterator2.f();
|
|
439
|
+
}
|
|
433
440
|
var cleanList = list.filter(function (item) {
|
|
434
441
|
return !(item.type === AtomsTypeEnum.UNKNOWN && item.val === '');
|
|
435
442
|
});
|
|
@@ -454,9 +461,6 @@ export function validateExpressionIntegrity(list) {
|
|
|
454
461
|
isOver: true
|
|
455
462
|
};
|
|
456
463
|
}
|
|
457
|
-
// if (!validateNoTrailingOperator(cleanList)) {
|
|
458
|
-
// return { isError: true, error: '表达式末尾不能是操作符(如 +, AND, WHEN 等)' };
|
|
459
|
-
// }
|
|
460
464
|
return {
|
|
461
465
|
isError: false
|
|
462
466
|
};
|
|
@@ -6,6 +6,6 @@ export { default as SelectSummarize } from './select-summarize/index';
|
|
|
6
6
|
export { default as SelectJoin } from './select-join/index';
|
|
7
7
|
export { default as SelectTable } from './select-table/index';
|
|
8
8
|
export { default as SelectPermissionTable } from './select-permission-table/index';
|
|
9
|
-
export { default as FormulaList } from './formula-list/index';
|
|
10
|
-
export { default as Expression } from './expression/index';
|
|
11
|
-
export { getTemplateItem } from './formula-list/utils';
|
|
9
|
+
export { default as FormulaList } from './formula-list/index';
|
|
10
|
+
export { default as Expression } from './expression/index';
|
|
11
|
+
export { getTemplateItem } from './formula-list/utils';
|
|
@@ -3,12 +3,6 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
5
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
-
/**
|
|
7
|
-
* 选择保留哪些表字段
|
|
8
|
-
* 谁在用?
|
|
9
|
-
* 1、数据模块
|
|
10
|
-
* 2、关联模块
|
|
11
|
-
*/
|
|
12
6
|
import './index.less';
|
|
13
7
|
import { useEffect, useMemo, useState } from 'react';
|
|
14
8
|
import cloneDeep from 'lodash/cloneDeep';
|
|
@@ -21,7 +15,6 @@ import { useStore } from '../../../hooks/use-provider';
|
|
|
21
15
|
import { uuidv4 } from '../../../utils/helper';
|
|
22
16
|
import { changeFieldAlias, isValidSQLAlias } from '../../../utils';
|
|
23
17
|
import { SearchIcon } from '../../icons';
|
|
24
|
-
// 选择表中参数
|
|
25
18
|
var SelectColumn = function SelectColumn(_ref) {
|
|
26
19
|
var _ref$data = _ref.data,
|
|
27
20
|
data = _ref$data === void 0 ? [] : _ref$data,
|
|
@@ -77,12 +70,12 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
77
70
|
}
|
|
78
71
|
}, [isAllSelect]);
|
|
79
72
|
function onSelect(columns, newMetaList) {
|
|
80
|
-
var originalData = cloneDeep(originList);
|
|
73
|
+
var originalData = cloneDeep(originList);
|
|
81
74
|
var mergedColumns = originalData.map(function (item) {
|
|
82
75
|
var match = columns.find(function (col) {
|
|
83
76
|
return col.fieldUuid === item.fieldUuid;
|
|
84
77
|
});
|
|
85
|
-
return match ? cloneDeep(match) : item;
|
|
78
|
+
return match ? cloneDeep(match) : item;
|
|
86
79
|
});
|
|
87
80
|
setColumns(columns);
|
|
88
81
|
setOriginList(mergedColumns);
|
|
@@ -92,7 +85,6 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
92
85
|
var fieldAlias = val || '';
|
|
93
86
|
Modal.confirm({
|
|
94
87
|
title: __('SqlQueryBuilder.alias'),
|
|
95
|
-
// 设置别名
|
|
96
88
|
content: _jsx(Input, {
|
|
97
89
|
defaultValue: fieldAlias,
|
|
98
90
|
onChange: function onChange(val) {
|
|
@@ -100,7 +92,7 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
100
92
|
}
|
|
101
93
|
}),
|
|
102
94
|
onOk: function () {
|
|
103
|
-
var _onOk = _asyncToGenerator(
|
|
95
|
+
var _onOk = _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
|
|
104
96
|
var newColumns, newMetaList;
|
|
105
97
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
106
98
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -149,9 +141,7 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
149
141
|
children: [_jsxs("div", {
|
|
150
142
|
className: 'Sqb-SelectColumn--header pt-2',
|
|
151
143
|
children: [_jsx("div", {
|
|
152
|
-
className: cx("SelectColumn-border mb-2 pb-2 px-2 flex items-center", {
|
|
153
|
-
// 'events-none': isAllSelect
|
|
154
|
-
}),
|
|
144
|
+
className: cx("SelectColumn-border mb-2 pb-2 px-2 flex items-center", {}),
|
|
155
145
|
onClick: function onClick() {
|
|
156
146
|
var newColumns = columns.map(function (v) {
|
|
157
147
|
return _objectSpread(_objectSpread({}, v), {}, {
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 选择表字段当条件
|
|
3
|
-
* 谁在用?
|
|
4
|
-
* 1、关联模块
|
|
5
|
-
* 2、过滤器模块
|
|
6
|
-
* 3、聚合模块
|
|
7
|
-
* 4、排序模块
|
|
8
|
-
*/
|
|
9
1
|
import './index.less';
|
|
10
2
|
import { ColumnsPopupThemeEnum, SQL_COLUMN_TYPE } from '../../../store/enum';
|
|
11
3
|
import { MetaData_ColumnsType, MetaJoin_TalbeType, AtomsField } from '../../../store/types';
|