@gingkoo/pandora-metabase 1.0.117 → 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 +966 -509
- 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 -112
- 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 +14 -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 +965 -509
- 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 -112
- 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 +14 -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: ({
|
|
@@ -10,18 +10,9 @@ var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime
|
|
|
10
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
11
11
|
var _locale = require("../../../locale");
|
|
12
12
|
var _types = require("../../../store/types");
|
|
13
|
-
// import { FUNCTION_TEMPLATES } from '../function/utils';
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param type 当前选择的类型
|
|
17
|
-
* @param list 当前数组
|
|
18
|
-
* @param index 需要讲模版插入的位置
|
|
19
|
-
* @returns
|
|
20
|
-
*/
|
|
21
13
|
var insertTemplateAt = exports.insertTemplateAt = function insertTemplateAt(oldType, type, list, index) {
|
|
22
14
|
var temList = [];
|
|
23
15
|
var needChange = ['RANK()', 'DENSE_RANK()', 'ROW_NUMBER()', 'when', 'case', 'then'].includes(oldType);
|
|
24
|
-
// 只改变类型不需要插入模版
|
|
25
16
|
if (needChange) {
|
|
26
17
|
return list;
|
|
27
18
|
}
|
|
@@ -73,58 +64,34 @@ var insertTemplateAt = exports.insertTemplateAt = function insertTemplateAt(oldT
|
|
|
73
64
|
type: _types.AtomsTypeEnum.OPERATOR
|
|
74
65
|
}, {
|
|
75
66
|
fieldName: '',
|
|
76
|
-
// 字段名
|
|
77
67
|
fieldNameZh: '',
|
|
78
|
-
// 字段中文名
|
|
79
68
|
fieldAlias: '',
|
|
80
|
-
// 别名
|
|
81
69
|
fieldUuid: '',
|
|
82
|
-
// uuid
|
|
83
70
|
fieldId: '',
|
|
84
|
-
// 字段id
|
|
85
|
-
// quotes?: string; // 字段展示的 不知道有没有用
|
|
86
71
|
tableName: '',
|
|
87
|
-
// 表名
|
|
88
72
|
tableNameZh: '',
|
|
89
73
|
tableId: '',
|
|
90
|
-
// 表名
|
|
91
74
|
tableAlias: '',
|
|
92
|
-
// 别名
|
|
93
75
|
tableUuid: '',
|
|
94
|
-
// 表唯一标识
|
|
95
76
|
datasourceName: '',
|
|
96
|
-
// 数据源名
|
|
97
77
|
datasourceId: '',
|
|
98
|
-
// 数据源id
|
|
99
78
|
type: _types.AtomsTypeEnum.FIELD
|
|
100
79
|
}, {
|
|
101
80
|
val: 'ORDER BY',
|
|
102
81
|
type: _types.AtomsTypeEnum.OPERATOR
|
|
103
82
|
}, {
|
|
104
83
|
fieldName: '',
|
|
105
|
-
// 字段名
|
|
106
84
|
fieldNameZh: '',
|
|
107
|
-
// 字段中文名
|
|
108
85
|
fieldAlias: '',
|
|
109
|
-
// 别名
|
|
110
86
|
fieldUuid: '',
|
|
111
|
-
// uuid
|
|
112
87
|
fieldId: '',
|
|
113
|
-
// 字段id
|
|
114
|
-
// quotes?: string; // 字段展示的 不知道有没有用
|
|
115
88
|
tableName: '',
|
|
116
|
-
// 表名
|
|
117
89
|
tableNameZh: '',
|
|
118
90
|
tableId: '',
|
|
119
|
-
// 表名
|
|
120
91
|
tableAlias: '',
|
|
121
|
-
// 别名
|
|
122
92
|
tableUuid: '',
|
|
123
|
-
// 表唯一标识
|
|
124
93
|
datasourceName: '',
|
|
125
|
-
// 数据源名
|
|
126
94
|
datasourceId: '',
|
|
127
|
-
// 数据源id
|
|
128
95
|
type: _types.AtomsTypeEnum.FIELD
|
|
129
96
|
}, {
|
|
130
97
|
val: ')',
|
|
@@ -135,46 +102,30 @@ var insertTemplateAt = exports.insertTemplateAt = function insertTemplateAt(oldT
|
|
|
135
102
|
return list;
|
|
136
103
|
};
|
|
137
104
|
var operatorList = exports.operatorList = ['and', 'or', '(', ')', ',', '+', '-', '*', '/', '!', '!=', '<=', '>=', '<', '>', '=', 'case', 'when', 'then', 'else', 'end', 'NULL', 'DESC', 'ASC', 'OVER', 'PARTITION BY', 'ORDER BY', 'RANK()', 'DENSE_RANK()', 'ROW_NUMBER()'];
|
|
138
|
-
var customTypes = exports.customTypes = [
|
|
139
|
-
// 字段
|
|
140
|
-
{
|
|
105
|
+
var customTypes = exports.customTypes = [{
|
|
141
106
|
value: _types.AtomsTypeEnum.FIELD,
|
|
142
107
|
label: (0, _locale.__)('customColumn.field')
|
|
143
|
-
},
|
|
144
|
-
// 表达式
|
|
145
|
-
{
|
|
108
|
+
}, {
|
|
146
109
|
value: _types.AtomsTypeEnum.EXPRESSION,
|
|
147
110
|
label: (0, _locale.__)('customColumn.expression')
|
|
148
|
-
},
|
|
149
|
-
// 输入框
|
|
150
|
-
{
|
|
111
|
+
}, {
|
|
151
112
|
value: _types.AtomsTypeEnum.INPUT_STRING,
|
|
152
113
|
label: (0, _locale.__)('customColumn.input')
|
|
153
|
-
},
|
|
154
|
-
// 数字输入框
|
|
155
|
-
{
|
|
114
|
+
}, {
|
|
156
115
|
value: _types.AtomsTypeEnum.INPUT_NUMBER,
|
|
157
116
|
label: (0, _locale.__)('customColumn.numberInput')
|
|
158
|
-
},
|
|
159
|
-
// 数字输入框
|
|
160
|
-
{
|
|
117
|
+
}, {
|
|
161
118
|
value: _types.AtomsTypeEnum.CONSTANT,
|
|
162
119
|
label: (0, _locale.__)('customColumn.constant')
|
|
163
|
-
},
|
|
164
|
-
// 连接符
|
|
165
|
-
{
|
|
120
|
+
}, {
|
|
166
121
|
value: _types.AtomsTypeEnum.OPERATOR,
|
|
167
122
|
label: (0, _locale.__)('customColumn.operator'),
|
|
168
123
|
children: operatorList
|
|
169
|
-
},
|
|
170
|
-
// 函数
|
|
171
|
-
{
|
|
124
|
+
}, {
|
|
172
125
|
value: _types.AtomsTypeEnum.FORMULA,
|
|
173
126
|
label: (0, _locale.__)('customColumn.formula'),
|
|
174
127
|
children: operatorList
|
|
175
|
-
},
|
|
176
|
-
// EXISTS
|
|
177
|
-
{
|
|
128
|
+
}, {
|
|
178
129
|
value: _types.AtomsTypeEnum.NOT_EXISTS,
|
|
179
130
|
label: 'NOT_EXISTS'
|
|
180
131
|
}, {
|
|
@@ -186,38 +137,23 @@ var customTypes = exports.customTypes = [
|
|
|
186
137
|
}];
|
|
187
138
|
var getTemplateItem = exports.getTemplateItem = function getTemplateItem(type, item) {
|
|
188
139
|
var temItem;
|
|
189
|
-
// 字段
|
|
190
140
|
if (type === _types.AtomsTypeEnum.FIELD) {
|
|
191
141
|
temItem = {
|
|
192
142
|
fieldName: '',
|
|
193
|
-
// 字段名
|
|
194
143
|
fieldNameZh: '',
|
|
195
|
-
// 字段中文名
|
|
196
144
|
fieldAlias: '',
|
|
197
|
-
// 别名
|
|
198
145
|
fieldUuid: '',
|
|
199
|
-
// uuid
|
|
200
146
|
fieldId: '',
|
|
201
|
-
// 字段id
|
|
202
|
-
// quotes?: string; // 字段展示的 不知道有没有用
|
|
203
147
|
tableName: '',
|
|
204
|
-
// 表名
|
|
205
148
|
tableNameZh: '',
|
|
206
149
|
tableId: '',
|
|
207
|
-
// 表名
|
|
208
150
|
tableAlias: '',
|
|
209
|
-
// 别名
|
|
210
151
|
tableUuid: '',
|
|
211
|
-
// 表唯一标识
|
|
212
152
|
datasourceName: '',
|
|
213
|
-
// 数据源名
|
|
214
153
|
datasourceId: '',
|
|
215
|
-
// 数据源id
|
|
216
154
|
type: _types.AtomsTypeEnum.FIELD
|
|
217
155
|
};
|
|
218
|
-
}
|
|
219
|
-
// 表达式
|
|
220
|
-
else if (type === _types.AtomsTypeEnum.EXPRESSION || type === _types.AtomsTypeEnum.JOIN_DEFAULT) {
|
|
156
|
+
} else if (type === _types.AtomsTypeEnum.EXPRESSION || type === _types.AtomsTypeEnum.JOIN_DEFAULT) {
|
|
221
157
|
return {
|
|
222
158
|
lhs: [],
|
|
223
159
|
rhs: [],
|
|
@@ -228,21 +164,17 @@ var getTemplateItem = exports.getTemplateItem = function getTemplateItem(type, i
|
|
|
228
164
|
} else if (type === _types.AtomsTypeEnum.EXISTS || type === _types.AtomsTypeEnum.NOT_EXISTS) {
|
|
229
165
|
return {
|
|
230
166
|
quotes: '',
|
|
231
|
-
// 展示用户看的 组装的文字
|
|
232
167
|
notExists: [],
|
|
233
168
|
type: type
|
|
234
169
|
};
|
|
235
170
|
} else if (type === _types.AtomsTypeEnum.SUB_QUERY) {
|
|
236
171
|
return {
|
|
237
172
|
quotes: '',
|
|
238
|
-
// 展示用户看的 组装的文字
|
|
239
173
|
subQuery: [],
|
|
240
174
|
type: type
|
|
241
175
|
};
|
|
242
176
|
} else if (type === _types.AtomsTypeEnum.UNKNOWN) {
|
|
243
177
|
return {
|
|
244
|
-
// quotes: '', // 展示用户看的 组装的文字
|
|
245
|
-
// notExists: [],
|
|
246
178
|
val: (item === null || item === void 0 ? void 0 : item["default"]) || '',
|
|
247
179
|
type: type
|
|
248
180
|
};
|
|
@@ -259,12 +191,37 @@ var getTemplateItem = exports.getTemplateItem = function getTemplateItem(type, i
|
|
|
259
191
|
} else if (type === _types.AtomsTypeEnum.FORMULA) {
|
|
260
192
|
temItem = {
|
|
261
193
|
args: [],
|
|
262
|
-
// params: FUNCTION_TEMPLATES?.[type]?.params || [],
|
|
263
|
-
// arity: FUNCTION_TEMPLATES?.[type]?.arity || {},
|
|
264
194
|
name: '',
|
|
265
195
|
quotes: '',
|
|
266
196
|
type: type
|
|
267
197
|
};
|
|
198
|
+
} else if (type === _types.AtomsTypeEnum.CASE_WHEN) {
|
|
199
|
+
return {
|
|
200
|
+
caseValue: [],
|
|
201
|
+
branches: [{
|
|
202
|
+
when: [{
|
|
203
|
+
val: '',
|
|
204
|
+
type: _types.AtomsTypeEnum.UNKNOWN
|
|
205
|
+
}],
|
|
206
|
+
then: [{
|
|
207
|
+
val: '',
|
|
208
|
+
type: _types.AtomsTypeEnum.UNKNOWN
|
|
209
|
+
}]
|
|
210
|
+
}],
|
|
211
|
+
elseValue: [],
|
|
212
|
+
quotes: '',
|
|
213
|
+
type: type
|
|
214
|
+
};
|
|
215
|
+
} else if (type === _types.AtomsTypeEnum.AND_OR) {
|
|
216
|
+
return {
|
|
217
|
+
operator: 'and',
|
|
218
|
+
list: [{
|
|
219
|
+
val: '',
|
|
220
|
+
type: _types.AtomsTypeEnum.UNKNOWN
|
|
221
|
+
}],
|
|
222
|
+
quotes: '',
|
|
223
|
+
type: type
|
|
224
|
+
};
|
|
268
225
|
} else if (type === _types.AtomsTypeEnum.COLLECTION) {
|
|
269
226
|
return {
|
|
270
227
|
list: [],
|
|
@@ -281,7 +238,6 @@ var getTemplateItem = exports.getTemplateItem = function getTemplateItem(type, i
|
|
|
281
238
|
type: type
|
|
282
239
|
};
|
|
283
240
|
} else {
|
|
284
|
-
// 其他
|
|
285
241
|
temItem = {
|
|
286
242
|
val: '',
|
|
287
243
|
type: type
|
|
@@ -294,30 +250,35 @@ var _isOk = exports.isOk = function isOk(rhsVal) {
|
|
|
294
250
|
if (v.type === _types.AtomsTypeEnum.UNKNOWN) {
|
|
295
251
|
return false;
|
|
296
252
|
} else if (v.type === _types.AtomsTypeEnum.JOIN_DEFAULT) {
|
|
297
|
-
|
|
298
|
-
return true; // 或者根据业务逻辑决定是否算“有效”
|
|
253
|
+
return true;
|
|
299
254
|
} else if (v.type === _types.AtomsTypeEnum.FIELD) {
|
|
300
|
-
return Boolean(v.fieldName);
|
|
255
|
+
return Boolean(v.fieldName);
|
|
301
256
|
} else if (v.type === _types.AtomsTypeEnum.EXPRESSION || v.type === _types.AtomsTypeEnum.EXISTS || v.type === _types.AtomsTypeEnum.NOT_EXISTS || v.type === _types.AtomsTypeEnum.SUB_QUERY) {
|
|
302
|
-
return Boolean(v.quotes);
|
|
257
|
+
return Boolean(v.quotes);
|
|
303
258
|
} else if (v.type === _types.AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
304
259
|
return Array.isArray(v.val) && v.val.every(function (vv) {
|
|
305
260
|
return Boolean(vv);
|
|
306
261
|
});
|
|
307
262
|
} else if (v.type === _types.AtomsTypeEnum.COLLECTION) {
|
|
308
263
|
return _isOk(v.list || []);
|
|
264
|
+
} else if (v.type === _types.AtomsTypeEnum.CASE_WHEN) {
|
|
265
|
+
return (v.branches || []).length > 0 && (v.branches || []).every(function (branch) {
|
|
266
|
+
return _isOk(branch.when || []) && _isOk(branch.then || []);
|
|
267
|
+
}) && _isOk(v.caseValue || []) && _isOk(v.elseValue || []);
|
|
268
|
+
} else if (v.type === _types.AtomsTypeEnum.AND_OR) {
|
|
269
|
+
return Boolean(v.operator) && _isOk(v.list || []);
|
|
309
270
|
} else if (v.type === _types.AtomsTypeEnum.FORMULA) {
|
|
310
271
|
if (!v.quotes) {
|
|
311
272
|
return false;
|
|
312
273
|
}
|
|
313
274
|
return _isOk(v.args || []);
|
|
275
|
+
} else if (v.type === _types.AtomsTypeEnum.SELECT) {
|
|
276
|
+
return Array.isArray(v.val) ? v.val.length > 0 : Boolean(v.val);
|
|
314
277
|
} else {
|
|
315
|
-
return Boolean(v.val) || v.val === 0
|
|
278
|
+
return 'val' in v ? Boolean(v.val) || v.val === 0 : false;
|
|
316
279
|
}
|
|
317
280
|
});
|
|
318
281
|
};
|
|
319
|
-
// 校验表达式完整性
|
|
320
|
-
// 括号不匹配
|
|
321
282
|
function validateParentheses(list) {
|
|
322
283
|
var depth = 0;
|
|
323
284
|
var _iterator = (0, _createForOfIteratorHelper2["default"])(list),
|
|
@@ -339,14 +300,13 @@ function validateParentheses(list) {
|
|
|
339
300
|
}
|
|
340
301
|
return depth === 0;
|
|
341
302
|
}
|
|
342
|
-
// CASE 语句不完整(缺少 END 或 WHEN/THEN)
|
|
343
303
|
function validateCaseStructure(list) {
|
|
344
304
|
for (var i = 0; i < list.length; i++) {
|
|
345
305
|
var item = list[i];
|
|
346
306
|
if (item.type === _types.AtomsTypeEnum.OPERATOR && item.val === 'case') {
|
|
347
307
|
var depth = 1;
|
|
348
308
|
var hasValidWhenThen = false;
|
|
349
|
-
var lastWasWhen = false;
|
|
309
|
+
var lastWasWhen = false;
|
|
350
310
|
for (var j = i + 1; j < list.length; j++) {
|
|
351
311
|
var token = list[j];
|
|
352
312
|
if (token.type !== _types.AtomsTypeEnum.OPERATOR) continue;
|
|
@@ -356,13 +316,11 @@ function validateCaseStructure(list) {
|
|
|
356
316
|
} else if (val === 'end') {
|
|
357
317
|
depth--;
|
|
358
318
|
if (depth === 0) {
|
|
359
|
-
// 当前 case 块结束
|
|
360
319
|
if (!hasValidWhenThen) {
|
|
361
|
-
return false;
|
|
320
|
+
return false;
|
|
362
321
|
}
|
|
363
|
-
break;
|
|
322
|
+
break;
|
|
364
323
|
}
|
|
365
|
-
// 如果 depth < 0,说明 end 多余,但这里我们只关心当前 case,可忽略或报错
|
|
366
324
|
} else if (val === 'when') {
|
|
367
325
|
if (depth === 1) {
|
|
368
326
|
lastWasWhen = true;
|
|
@@ -370,28 +328,24 @@ function validateCaseStructure(list) {
|
|
|
370
328
|
} else if (val === 'then') {
|
|
371
329
|
if (depth === 1) {
|
|
372
330
|
if (!lastWasWhen) {
|
|
373
|
-
return false;
|
|
331
|
+
return false;
|
|
374
332
|
}
|
|
375
333
|
hasValidWhenThen = true;
|
|
376
|
-
lastWasWhen = false;
|
|
334
|
+
lastWasWhen = false;
|
|
377
335
|
}
|
|
378
336
|
}
|
|
379
|
-
// 注意:其他操作符(如 else)可在此扩展
|
|
380
337
|
}
|
|
381
|
-
// 如果循环结束还没找到匹配的 end(即 depth > 0)
|
|
382
338
|
if (depth > 0) {
|
|
383
|
-
return false;
|
|
339
|
+
return false;
|
|
384
340
|
}
|
|
385
341
|
}
|
|
386
342
|
}
|
|
387
343
|
return true;
|
|
388
344
|
}
|
|
389
|
-
// 窗口函数结构不完整(缺少 OVER 或括号)
|
|
390
345
|
function validateWindowFunction(list) {
|
|
391
346
|
for (var i = 0; i < list.length; i++) {
|
|
392
347
|
var item = list[i];
|
|
393
348
|
if (item.type === _types.AtomsTypeEnum.OPERATOR && ['RANK()', 'DENSE_RANK()', 'ROW_NUMBER()'].includes(item.val)) {
|
|
394
|
-
// 找后面的 OVER (
|
|
395
349
|
var foundOver = false;
|
|
396
350
|
var parenDepth = 0;
|
|
397
351
|
for (var j = i + 1; j < list.length; j++) {
|
|
@@ -401,41 +355,95 @@ function validateWindowFunction(list) {
|
|
|
401
355
|
foundOver = true;
|
|
402
356
|
} else if (foundOver && next.val === '(') {
|
|
403
357
|
parenDepth = 1;
|
|
404
|
-
// 继续找匹配的 )
|
|
405
358
|
for (var k = j + 1; k < list.length; k++) {
|
|
406
359
|
if (list[k].type !== _types.AtomsTypeEnum.OPERATOR) continue;
|
|
407
360
|
if (list[k].val === '(') parenDepth++;else if (list[k].val === ')') {
|
|
408
361
|
parenDepth--;
|
|
409
|
-
if (parenDepth === 0) return true;
|
|
362
|
+
if (parenDepth === 0) return true;
|
|
410
363
|
}
|
|
411
364
|
}
|
|
412
|
-
return false;
|
|
365
|
+
return false;
|
|
413
366
|
}
|
|
414
367
|
}
|
|
415
|
-
return false;
|
|
368
|
+
return false;
|
|
416
369
|
}
|
|
417
370
|
}
|
|
418
371
|
return true;
|
|
419
372
|
}
|
|
420
|
-
// 表达式末尾不能是操作符(如 +, AND, WHEN 等)
|
|
421
373
|
function validateNoTrailingOperator(list) {
|
|
422
|
-
// 从后往前找第一个非空 OPERATOR
|
|
423
374
|
for (var i = list.length - 1; i >= 0; i--) {
|
|
424
375
|
var item = list[i];
|
|
425
376
|
if (item.type === _types.AtomsTypeEnum.UNKNOWN && item.val === '') continue;
|
|
426
377
|
if (item.type === _types.AtomsTypeEnum.OPERATOR) {
|
|
427
378
|
var val = item.val;
|
|
428
|
-
// 二元操作符、逗号、(、when、then 等不能结尾
|
|
429
379
|
if (['+', '-', '*', '/', '=', '!=', '<', '>', 'and', 'or', ',', '(', 'when', 'then'].includes(val)) {
|
|
430
380
|
return false;
|
|
431
381
|
}
|
|
432
382
|
}
|
|
433
|
-
break;
|
|
383
|
+
break;
|
|
434
384
|
}
|
|
435
385
|
return true;
|
|
436
386
|
}
|
|
437
387
|
function validateExpressionIntegrity(list) {
|
|
438
|
-
|
|
388
|
+
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(list),
|
|
389
|
+
_step2;
|
|
390
|
+
try {
|
|
391
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
392
|
+
var item = _step2.value;
|
|
393
|
+
if (item.type === _types.AtomsTypeEnum.AND_OR) {
|
|
394
|
+
if (!item.operator) {
|
|
395
|
+
return {
|
|
396
|
+
isError: true,
|
|
397
|
+
error: 'AND / OR 结构缺少操作符'
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
var nestedError = validateExpressionIntegrity(item.list || []);
|
|
401
|
+
if (nestedError.isError) {
|
|
402
|
+
return nestedError;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (item.type === _types.AtomsTypeEnum.CASE_WHEN) {
|
|
406
|
+
if ((item.branches || []).length < 1) {
|
|
407
|
+
return {
|
|
408
|
+
isError: true,
|
|
409
|
+
error: 'CASE WHEN 至少需要一个 when / then 分支',
|
|
410
|
+
isCase: true
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
var caseValueError = validateExpressionIntegrity(item.caseValue || []);
|
|
414
|
+
if (caseValueError.isError) {
|
|
415
|
+
return caseValueError;
|
|
416
|
+
}
|
|
417
|
+
var _iterator3 = (0, _createForOfIteratorHelper2["default"])(item.branches || []),
|
|
418
|
+
_step3;
|
|
419
|
+
try {
|
|
420
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
421
|
+
var branch = _step3.value;
|
|
422
|
+
var whenError = validateExpressionIntegrity(branch.when || []);
|
|
423
|
+
if (whenError.isError) {
|
|
424
|
+
return whenError;
|
|
425
|
+
}
|
|
426
|
+
var thenError = validateExpressionIntegrity(branch.then || []);
|
|
427
|
+
if (thenError.isError) {
|
|
428
|
+
return thenError;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
} catch (err) {
|
|
432
|
+
_iterator3.e(err);
|
|
433
|
+
} finally {
|
|
434
|
+
_iterator3.f();
|
|
435
|
+
}
|
|
436
|
+
var elseError = validateExpressionIntegrity(item.elseValue || []);
|
|
437
|
+
if (elseError.isError) {
|
|
438
|
+
return elseError;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
} catch (err) {
|
|
443
|
+
_iterator2.e(err);
|
|
444
|
+
} finally {
|
|
445
|
+
_iterator2.f();
|
|
446
|
+
}
|
|
439
447
|
var cleanList = list.filter(function (item) {
|
|
440
448
|
return !(item.type === _types.AtomsTypeEnum.UNKNOWN && item.val === '');
|
|
441
449
|
});
|
|
@@ -460,9 +468,6 @@ function validateExpressionIntegrity(list) {
|
|
|
460
468
|
isOver: true
|
|
461
469
|
};
|
|
462
470
|
}
|
|
463
|
-
// if (!validateNoTrailingOperator(cleanList)) {
|
|
464
|
-
// return { isError: true, error: '表达式末尾不能是操作符(如 +, AND, WHEN 等)' };
|
|
465
|
-
// }
|
|
466
471
|
return {
|
|
467
472
|
isError: false
|
|
468
473
|
};
|
|
@@ -21,14 +21,6 @@ var _icons = require("../../icons");
|
|
|
21
21
|
var _useProvider = require("../../../hooks/use-provider");
|
|
22
22
|
var _helper = require("../../../utils/helper");
|
|
23
23
|
var _utils = require("../../../utils");
|
|
24
|
-
/**
|
|
25
|
-
* 选择保留哪些表字段
|
|
26
|
-
* 谁在用?
|
|
27
|
-
* 1、数据模块
|
|
28
|
-
* 2、关联模块
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
// 选择表中参数
|
|
32
24
|
var SelectColumn = function SelectColumn(_ref) {
|
|
33
25
|
var _ref$data = _ref.data,
|
|
34
26
|
data = _ref$data === void 0 ? [] : _ref$data,
|
|
@@ -84,12 +76,12 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
84
76
|
}
|
|
85
77
|
}, [isAllSelect]);
|
|
86
78
|
function onSelect(columns, newMetaList) {
|
|
87
|
-
var originalData = (0, _cloneDeep["default"])(originList);
|
|
79
|
+
var originalData = (0, _cloneDeep["default"])(originList);
|
|
88
80
|
var mergedColumns = originalData.map(function (item) {
|
|
89
81
|
var match = columns.find(function (col) {
|
|
90
82
|
return col.fieldUuid === item.fieldUuid;
|
|
91
83
|
});
|
|
92
|
-
return match ? (0, _cloneDeep["default"])(match) : item;
|
|
84
|
+
return match ? (0, _cloneDeep["default"])(match) : item;
|
|
93
85
|
});
|
|
94
86
|
setColumns(columns);
|
|
95
87
|
setOriginList(mergedColumns);
|
|
@@ -99,7 +91,6 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
99
91
|
var fieldAlias = val || '';
|
|
100
92
|
_pandora.Modal.confirm({
|
|
101
93
|
title: (0, _locale.__)('SqlQueryBuilder.alias'),
|
|
102
|
-
// 设置别名
|
|
103
94
|
content: (0, _jsxRuntime.jsx)(_pandora.Input, {
|
|
104
95
|
defaultValue: fieldAlias,
|
|
105
96
|
onChange: function onChange(val) {
|
|
@@ -107,7 +98,7 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
107
98
|
}
|
|
108
99
|
}),
|
|
109
100
|
onOk: function () {
|
|
110
|
-
var _onOk = (0, _asyncToGenerator2["default"])(
|
|
101
|
+
var _onOk = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee() {
|
|
111
102
|
var newColumns, newMetaList;
|
|
112
103
|
return _regenerator["default"].wrap(function (_context) {
|
|
113
104
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -156,9 +147,7 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
156
147
|
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
157
148
|
className: 'Sqb-SelectColumn--header pt-2',
|
|
158
149
|
children: [(0, _jsxRuntime.jsx)("div", {
|
|
159
|
-
className: (0, _classnames["default"])("SelectColumn-border mb-2 pb-2 px-2 flex items-center", {
|
|
160
|
-
// 'events-none': isAllSelect
|
|
161
|
-
}),
|
|
150
|
+
className: (0, _classnames["default"])("SelectColumn-border mb-2 pb-2 px-2 flex items-center", {}),
|
|
162
151
|
onClick: function onClick() {
|
|
163
152
|
var newColumns = columns.map(function (v) {
|
|
164
153
|
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, 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';
|