@gingkoo/pandora-metabase 1.0.23 → 1.0.24
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/components/dialog/custom-editor/index.js +2 -2
- package/lib/cjs/components/dialog/expression/index.js +1 -1
- package/lib/cjs/components/dialog/formula/index.d.ts +10 -0
- package/lib/cjs/components/dialog/formula/index.js +242 -0
- package/lib/cjs/components/dialog/formula/index.less +81 -0
- package/lib/cjs/components/dialog/formula/utils.d.ts +7 -0
- package/lib/cjs/components/dialog/formula/utils.js +45 -0
- package/lib/cjs/components/dialog/formula-list/index.d.ts +2 -2
- package/lib/cjs/components/dialog/formula-list/index.js +87 -29
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +14 -1
- package/lib/cjs/components/dialog/formula-list/utils.js +159 -2
- package/lib/cjs/components/metabase/index.less +1 -0
- package/lib/cjs/components/modules/enum/filter-enum.d.ts +7 -2
- package/lib/cjs/components/modules/enum/filter-enum.js +8 -2
- package/lib/cjs/components/modules/join-data.js +27 -2
- package/lib/cjs/hooks/patch.js +77 -75
- package/lib/cjs/hooks/use-state.js +33 -27
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/locale/en.js +4 -2
- package/lib/cjs/locale/zh.js +4 -2
- package/lib/cjs/store/helper.d.ts +1 -2
- package/lib/cjs/store/helper.js +1 -76
- package/lib/cjs/store/types.d.ts +36 -2
- package/lib/cjs/store/types.js +3 -0
- package/lib/cjs/types.d.ts +2 -1
- package/lib/cjs/utils.js +2 -1
- package/lib/es/components/dialog/custom-editor/index.js +2 -2
- package/lib/es/components/dialog/expression/index.js +1 -1
- package/lib/es/components/dialog/formula/index.d.ts +10 -0
- package/lib/es/components/dialog/formula/index.js +236 -0
- package/lib/es/components/dialog/formula/index.less +81 -0
- package/lib/es/components/dialog/formula/utils.d.ts +7 -0
- package/lib/es/components/dialog/formula/utils.js +37 -0
- package/lib/es/components/dialog/formula-list/index.d.ts +2 -2
- package/lib/es/components/dialog/formula-list/index.js +84 -26
- package/lib/es/components/dialog/formula-list/utils.d.ts +14 -1
- package/lib/es/components/dialog/formula-list/utils.js +160 -2
- package/lib/es/components/metabase/index.less +1 -0
- package/lib/es/components/modules/enum/filter-enum.d.ts +7 -2
- package/lib/es/components/modules/enum/filter-enum.js +8 -2
- package/lib/es/components/modules/join-data.js +27 -2
- package/lib/es/hooks/patch.js +77 -75
- package/lib/es/hooks/use-state.js +33 -27
- package/lib/es/index.js +3 -1
- package/lib/es/locale/en.js +4 -2
- package/lib/es/locale/zh.js +4 -2
- package/lib/es/store/helper.d.ts +1 -2
- package/lib/es/store/helper.js +0 -75
- package/lib/es/store/types.d.ts +36 -2
- package/lib/es/store/types.js +3 -0
- package/lib/es/types.d.ts +2 -1
- package/lib/es/types.js +18 -1
- package/lib/es/utils.js +2 -1
- package/package.json +1 -1
- package/lib/cjs/components/dialog/formula-list/enum.d.ts +0 -39
- package/lib/cjs/components/dialog/formula-list/enum.js +0 -123
- package/lib/es/components/dialog/formula-list/enum.d.ts +0 -39
- package/lib/es/components/dialog/formula-list/enum.js +0 -117
package/lib/es/hooks/patch.js
CHANGED
|
@@ -4,33 +4,35 @@ import { buildSqlQuery } from '../utils';
|
|
|
4
4
|
import { AtomsTypeEnum } from '../store/types';
|
|
5
5
|
import { TypeEnum } from '../store/enum';
|
|
6
6
|
export var dataPatch = function dataPatch(newMeta) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (item
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
7
|
+
// let item = newMeta.expressions?.[0] || {};
|
|
8
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
9
|
+
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
10
|
+
// return newMeta;
|
|
11
|
+
// }
|
|
12
|
+
// }
|
|
14
13
|
newMeta.subquery = _patchMetas(newMeta.subquery);
|
|
15
14
|
return newMeta;
|
|
16
15
|
};
|
|
17
16
|
export var joinDataPatch = function joinDataPatch(newMeta) {
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
if (item
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
var _fields, _fields2, _fields3, _fields4, _newMeta$expressions;
|
|
18
|
+
// let item = newMeta.expressions?.[0] || {};
|
|
19
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
20
|
+
// if (
|
|
21
|
+
// (item.type === AtomsTypeEnum.EXPRESSION || item.type === AtomsTypeEnum.JOIN_DEFAULT) &&
|
|
22
|
+
// item.lhs
|
|
23
|
+
// ) {
|
|
24
|
+
// return newMeta;
|
|
25
|
+
// }
|
|
26
|
+
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
27
|
+
// return newMeta;
|
|
28
|
+
// }
|
|
29
|
+
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
30
|
+
// return newMeta;
|
|
31
|
+
// }
|
|
32
|
+
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
33
|
+
// return newMeta;
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
34
36
|
// if (
|
|
35
37
|
// newMeta.expressions?.[0]?.type &&
|
|
36
38
|
// Object.values(AtomsTypeEnum).includes(newMeta.expressions[0].type)
|
|
@@ -120,7 +122,7 @@ export var joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
120
122
|
type: 'default' // 默认是字段模式
|
|
121
123
|
}];
|
|
122
124
|
}
|
|
123
|
-
var expressions = ((_newMeta$
|
|
125
|
+
var expressions = ((_newMeta$expressions = newMeta.expressions) === null || _newMeta$expressions === void 0 ? void 0 : _newMeta$expressions.map(function (v) {
|
|
124
126
|
var _left_fields, _right_fields;
|
|
125
127
|
var left_fields = v.left_fields || [];
|
|
126
128
|
var right_fields = v.right_fields || [];
|
|
@@ -261,23 +263,23 @@ export var joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
261
263
|
return newMeta;
|
|
262
264
|
};
|
|
263
265
|
export var filterPatch = function filterPatch(newMeta) {
|
|
264
|
-
var _newMeta$filter
|
|
265
|
-
|
|
266
|
-
if (item
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
var _filter = (_newMeta$
|
|
266
|
+
var _newMeta$filter;
|
|
267
|
+
// let item = newMeta.filter?.[0] || {};
|
|
268
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
269
|
+
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
270
|
+
// return newMeta;
|
|
271
|
+
// }
|
|
272
|
+
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
273
|
+
// return newMeta;
|
|
274
|
+
// }
|
|
275
|
+
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
276
|
+
// return newMeta;
|
|
277
|
+
// }
|
|
278
|
+
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
279
|
+
// return newMeta;
|
|
280
|
+
// }
|
|
281
|
+
// }
|
|
282
|
+
var _filter = (_newMeta$filter = newMeta.filter) === null || _newMeta$filter === void 0 ? void 0 : _newMeta$filter.map(function (v) {
|
|
281
283
|
// 表达式
|
|
282
284
|
var tem;
|
|
283
285
|
if (typeof v === 'string') {
|
|
@@ -369,23 +371,23 @@ export var filterPatch = function filterPatch(newMeta) {
|
|
|
369
371
|
return newMeta;
|
|
370
372
|
};
|
|
371
373
|
export var customColumnPatch = function customColumnPatch(newMeta) {
|
|
372
|
-
var _newMeta$customColumn
|
|
373
|
-
|
|
374
|
-
if (item
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
newMeta.customColumn = (newMeta === null || newMeta === void 0 || (_newMeta$
|
|
374
|
+
var _newMeta$customColumn;
|
|
375
|
+
// let item = newMeta.customColumn?.[0]?.formulaList?.[0] || {};
|
|
376
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
377
|
+
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
378
|
+
// return newMeta;
|
|
379
|
+
// }
|
|
380
|
+
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
381
|
+
// return newMeta;
|
|
382
|
+
// }
|
|
383
|
+
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
384
|
+
// return newMeta;
|
|
385
|
+
// }
|
|
386
|
+
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
387
|
+
// return newMeta;
|
|
388
|
+
// }
|
|
389
|
+
// }
|
|
390
|
+
newMeta.customColumn = (newMeta === null || newMeta === void 0 || (_newMeta$customColumn = newMeta.customColumn) === null || _newMeta$customColumn === void 0 ? void 0 : _newMeta$customColumn.map(function (v) {
|
|
389
391
|
var _formulaList = v.formulaList.map(function (formula) {
|
|
390
392
|
var tem = formula;
|
|
391
393
|
if (formula.type === 'expression') {
|
|
@@ -502,23 +504,23 @@ export var customColumnPatch = function customColumnPatch(newMeta) {
|
|
|
502
504
|
return newMeta;
|
|
503
505
|
};
|
|
504
506
|
export var sortPatch = function sortPatch(newMeta) {
|
|
505
|
-
var _newMeta$sort
|
|
506
|
-
|
|
507
|
-
if (item
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
}
|
|
521
|
-
var _sort = (_newMeta$
|
|
507
|
+
var _newMeta$sort;
|
|
508
|
+
// let item = newMeta.sort?.[0].expression?.[0] || {};
|
|
509
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
510
|
+
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
511
|
+
// return newMeta;
|
|
512
|
+
// }
|
|
513
|
+
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
514
|
+
// return newMeta;
|
|
515
|
+
// }
|
|
516
|
+
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
517
|
+
// return newMeta;
|
|
518
|
+
// }
|
|
519
|
+
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
520
|
+
// return newMeta;
|
|
521
|
+
// }
|
|
522
|
+
// }
|
|
523
|
+
var _sort = (_newMeta$sort = newMeta.sort) === null || _newMeta$sort === void 0 ? void 0 : _newMeta$sort.map(function (v) {
|
|
522
524
|
return {
|
|
523
525
|
expression: [{
|
|
524
526
|
fieldName: v.name,
|
|
@@ -70,50 +70,54 @@ var useStore = function useStore() {
|
|
|
70
70
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
71
71
|
constantList = _useState14[0],
|
|
72
72
|
setConstantList = _useState14[1]; //常量列表
|
|
73
|
-
var _useState15 = useState(
|
|
73
|
+
var _useState15 = useState([]),
|
|
74
74
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
formulaTemplates = _useState16[0],
|
|
76
|
+
setFormulaTemplates = _useState16[1]; //公式配置数组
|
|
77
77
|
var _useState17 = useState(false),
|
|
78
78
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var _useState19 = useState(
|
|
79
|
+
ignoreGroupByType = _useState18[0],
|
|
80
|
+
setIgnoreGroupByType = _useState18[1]; // 忽略groupBy类型
|
|
81
|
+
var _useState19 = useState(false),
|
|
82
82
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
filterCustomType = _useState20[0],
|
|
84
|
+
setfilterCustomType = _useState20[1]; // 过滤器自定义类型
|
|
85
85
|
var _useState21 = useState({}),
|
|
86
86
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var _useState23 = useState(
|
|
87
|
+
_cacheSource2TableMap = _useState22[0],
|
|
88
|
+
set_cacheSource2TableMap = _useState22[1]; //数据源id 对应数据集列表
|
|
89
|
+
var _useState23 = useState({}),
|
|
90
90
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
var _useState25 = useState(
|
|
91
|
+
_cacheColumnsMap = _useState24[0],
|
|
92
|
+
set_cacheColumnsMap = _useState24[1]; //数据源id 对应数据集列表
|
|
93
|
+
var _useState25 = useState(defaultMeta),
|
|
94
|
+
_useState26 = _slicedToArray(_useState25, 2),
|
|
95
|
+
metaList = _useState26[0],
|
|
96
|
+
_setMeta = _useState26[1]; //数据源id 对应数据集列表
|
|
97
|
+
var _useState27 = useState({
|
|
94
98
|
visible: false,
|
|
95
99
|
node: null,
|
|
96
100
|
content: null
|
|
97
101
|
}),
|
|
98
|
-
|
|
99
|
-
popupData =
|
|
100
|
-
setPopup =
|
|
101
|
-
var
|
|
102
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
103
|
+
popupData = _useState28[0],
|
|
104
|
+
setPopup = _useState28[1]; //弹窗
|
|
105
|
+
var _useState29 = useState({
|
|
102
106
|
visible: false,
|
|
103
107
|
node: null,
|
|
104
108
|
content: null
|
|
105
109
|
}),
|
|
106
|
-
_useState28 = _slicedToArray(_useState27, 2),
|
|
107
|
-
popupData2 = _useState28[0],
|
|
108
|
-
setPopup2 = _useState28[1]; //弹窗
|
|
109
|
-
var _useState29 = useState(true),
|
|
110
110
|
_useState30 = _slicedToArray(_useState29, 2),
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
popupData2 = _useState30[0],
|
|
112
|
+
setPopup2 = _useState30[1]; //弹窗
|
|
113
113
|
var _useState31 = useState(true),
|
|
114
114
|
_useState32 = _slicedToArray(_useState31, 2),
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
popupClosable = _useState32[0],
|
|
116
|
+
setClosable = _useState32[1]; //是否可关闭 如果弹框里面再弹框 则不可关闭
|
|
117
|
+
var _useState33 = useState(true),
|
|
118
|
+
_useState34 = _slicedToArray(_useState33, 2),
|
|
119
|
+
popupClosable2 = _useState34[0],
|
|
120
|
+
setClosable2 = _useState34[1]; //是否可关闭 如果弹框里面再弹框 则不可关闭
|
|
117
121
|
// 外层ref
|
|
118
122
|
var popupContainer = useRef();
|
|
119
123
|
// const [fetchDatasetFn, setFetchDatasetFn] = useState<(id: string) => Promise<any>>(
|
|
@@ -585,7 +589,9 @@ var useStore = function useStore() {
|
|
|
585
589
|
ignoreGroupByType: ignoreGroupByType,
|
|
586
590
|
setIgnoreGroupByType: setIgnoreGroupByType,
|
|
587
591
|
filterCustomType: filterCustomType,
|
|
588
|
-
setfilterCustomType: setfilterCustomType
|
|
592
|
+
setfilterCustomType: setfilterCustomType,
|
|
593
|
+
formulaTemplates: formulaTemplates,
|
|
594
|
+
setFormulaTemplates: setFormulaTemplates
|
|
589
595
|
};
|
|
590
596
|
};
|
|
591
597
|
export default useStore;
|
package/lib/es/index.js
CHANGED
|
@@ -38,6 +38,7 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
38
38
|
_props$subShowSubquer = props.subShowSubquery,
|
|
39
39
|
subShowSubquery = _props$subShowSubquer === void 0 ? false : _props$subShowSubquer,
|
|
40
40
|
constantList = props.constantList,
|
|
41
|
+
formulaTemplates = props.formulaTemplates,
|
|
41
42
|
_props$ignoreGroupByT = props.ignoreGroupByType,
|
|
42
43
|
ignoreGroupByType = _props$ignoreGroupByT === void 0 ? false : _props$ignoreGroupByT,
|
|
43
44
|
_props$filterCustomTy = props.filterCustomType,
|
|
@@ -65,9 +66,10 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
65
66
|
store.setShowSubquery(showSubquery);
|
|
66
67
|
store._setShowSubquery(subShowSubquery);
|
|
67
68
|
store.setConstantList(constantList || []);
|
|
69
|
+
store.setFormulaTemplates(formulaTemplates || []);
|
|
68
70
|
store.setIgnoreGroupByType(ignoreGroupByType);
|
|
69
71
|
store.setfilterCustomType(filterCustomType);
|
|
70
|
-
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, ignoreGroupByType, filterCustomType]);
|
|
72
|
+
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType]);
|
|
71
73
|
React.useImperativeHandle(ref, function () {
|
|
72
74
|
return {
|
|
73
75
|
// setDatasource: (list) => {
|
package/lib/es/locale/en.js
CHANGED
|
@@ -33,8 +33,10 @@ export default register('en', {
|
|
|
33
33
|
'SqlQueryBuilder.customExpression': 'customExpression',
|
|
34
34
|
'SqlQueryBuilder.pickTable': 'Select data table...',
|
|
35
35
|
'SqlQueryBuilder.pickConstant': 'Select constant...',
|
|
36
|
-
'
|
|
37
|
-
'
|
|
36
|
+
'customColumn.input': 'Input',
|
|
37
|
+
'customColumn.numberInput': 'Number input',
|
|
38
|
+
'customColumn.formula': 'Formula',
|
|
39
|
+
'customColumn.selectFormula': 'Select formula...',
|
|
38
40
|
'SqlQueryBuilder.switchSubQuery': 'Open subquery',
|
|
39
41
|
'SqlQueryBuilder.setSubQuery': 'Set Subquery...',
|
|
40
42
|
'SqlQueryBuilder.subquery': 'Subquery',
|
package/lib/es/locale/zh.js
CHANGED
|
@@ -33,8 +33,6 @@ export default register('zh', {
|
|
|
33
33
|
'SqlQueryBuilder.customExpression': '自定义表达方式',
|
|
34
34
|
'SqlQueryBuilder.pickTable': '选择数据表...',
|
|
35
35
|
'SqlQueryBuilder.pickConstant': '选择常量...',
|
|
36
|
-
'SqlQueryBuilder.input': '输入框',
|
|
37
|
-
'SqlQueryBuilder.numberInput': '数字输入框',
|
|
38
36
|
'SqlQueryBuilder.switchSubQuery': '切换子查询',
|
|
39
37
|
'SqlQueryBuilder.setSubQuery': '设置子查询...',
|
|
40
38
|
'SqlQueryBuilder.subquery': '子查询',
|
|
@@ -65,6 +63,10 @@ export default register('zh', {
|
|
|
65
63
|
'customColumn.selectExpression': '选择表达式',
|
|
66
64
|
'customColumn.selectOtherSyntax': '选择其他语法',
|
|
67
65
|
'customColumn.selectCustomInput': '选择自定义输入框',
|
|
66
|
+
'customColumn.formula': '公式',
|
|
67
|
+
'customColumn.selectFormula': '选择公式...',
|
|
68
|
+
'customColumn.input': '输入框',
|
|
69
|
+
'customColumn.numberInput': '数字输入框',
|
|
68
70
|
'filter.addFilter': '添加过滤器',
|
|
69
71
|
'filter.confirm': '确认',
|
|
70
72
|
'filter.pleaseEnter': '请输入',
|
package/lib/es/store/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MetaListType, MetaSummarize_Group
|
|
1
|
+
import { MetaListType, MetaSummarize_Group } from './types';
|
|
2
2
|
export declare const SummarizeAlias = "source";
|
|
3
3
|
export declare const summarizeToSql: (arr: MetaSummarize_Group[], record: MetaSummarize_Group) => {
|
|
4
4
|
sql: string;
|
|
@@ -6,4 +6,3 @@ export declare const summarizeToSql: (arr: MetaSummarize_Group[], record: MetaSu
|
|
|
6
6
|
};
|
|
7
7
|
export declare const compressionStructure: (data: MetaListType[]) => string;
|
|
8
8
|
export declare const restoreStructure: (data: string) => MetaListType[];
|
|
9
|
-
export declare const getTemItem: (type: AtomsTypeEnum) => AtomsItem;
|
package/lib/es/store/helper.js
CHANGED
|
@@ -2,7 +2,6 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["children"],
|
|
4
4
|
_excluded2 = ["metaKey"];
|
|
5
|
-
import { AtomsTypeEnum } from './types';
|
|
6
5
|
// import { SummarizeAlias } from './index';
|
|
7
6
|
import { TypeEnum, SQL_COLUMN_TYPE } from './enum';
|
|
8
7
|
export var SummarizeAlias = 'source';
|
|
@@ -416,78 +415,4 @@ export var restoreStructure = function restoreStructure(data) {
|
|
|
416
415
|
} catch (e) {
|
|
417
416
|
return [];
|
|
418
417
|
}
|
|
419
|
-
};
|
|
420
|
-
export var getTemItem = function getTemItem(type) {
|
|
421
|
-
var temItem;
|
|
422
|
-
// 字段
|
|
423
|
-
if (type === AtomsTypeEnum.FIELD) {
|
|
424
|
-
temItem = {
|
|
425
|
-
fieldName: '',
|
|
426
|
-
// 字段名
|
|
427
|
-
fieldNameZh: '',
|
|
428
|
-
// 字段中文名
|
|
429
|
-
fieldAlias: '',
|
|
430
|
-
// 别名
|
|
431
|
-
fieldUuid: '',
|
|
432
|
-
// uuid
|
|
433
|
-
fieldId: '',
|
|
434
|
-
// 字段id
|
|
435
|
-
// quotes?: string; // 字段展示的 不知道有没有用
|
|
436
|
-
tableName: '',
|
|
437
|
-
// 表名
|
|
438
|
-
tableNameZh: '',
|
|
439
|
-
tableId: '',
|
|
440
|
-
// 表名
|
|
441
|
-
tableAlias: '',
|
|
442
|
-
// 别名
|
|
443
|
-
tableUuid: '',
|
|
444
|
-
// 表唯一标识
|
|
445
|
-
datasourceName: '',
|
|
446
|
-
// 数据源名
|
|
447
|
-
datasourceId: '',
|
|
448
|
-
// 数据源id
|
|
449
|
-
type: AtomsTypeEnum.FIELD
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
// 表达式
|
|
453
|
-
else if (type === AtomsTypeEnum.EXPRESSION || type === AtomsTypeEnum.JOIN_DEFAULT) {
|
|
454
|
-
return {
|
|
455
|
-
lhs: [],
|
|
456
|
-
rhs: [],
|
|
457
|
-
condition: '',
|
|
458
|
-
quotes: '',
|
|
459
|
-
type: type
|
|
460
|
-
};
|
|
461
|
-
} else if (type === AtomsTypeEnum.EXISTS || type === AtomsTypeEnum.NOT_EXISTS) {
|
|
462
|
-
return {
|
|
463
|
-
quotes: '',
|
|
464
|
-
// 展示用户看的 组装的文字
|
|
465
|
-
notExists: [],
|
|
466
|
-
type: type
|
|
467
|
-
};
|
|
468
|
-
} else if (type === AtomsTypeEnum.UNKNOWN) {
|
|
469
|
-
return {
|
|
470
|
-
// quotes: '', // 展示用户看的 组装的文字
|
|
471
|
-
// notExists: [],
|
|
472
|
-
val: '',
|
|
473
|
-
type: type
|
|
474
|
-
};
|
|
475
|
-
} else if (type === AtomsTypeEnum.INPUT_NUMBER) {
|
|
476
|
-
return {
|
|
477
|
-
val: 0,
|
|
478
|
-
type: type
|
|
479
|
-
};
|
|
480
|
-
} else if (type === AtomsTypeEnum.INPUT_NUMBER_LIST || type === AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
481
|
-
temItem = {
|
|
482
|
-
val: [],
|
|
483
|
-
type: type
|
|
484
|
-
};
|
|
485
|
-
} else {
|
|
486
|
-
// 其他
|
|
487
|
-
temItem = {
|
|
488
|
-
val: '',
|
|
489
|
-
type: type
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
return temItem;
|
|
493
418
|
};
|
package/lib/es/store/types.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ export declare enum AtomsTypeEnum {
|
|
|
12
12
|
INPUT_NUMBER = "inputNumber",// 数字输入框
|
|
13
13
|
CONSTANT = "constant",// 常量
|
|
14
14
|
OPERATOR = "operator",// 运算符
|
|
15
|
-
UNKNOWN = "unknown"
|
|
15
|
+
UNKNOWN = "unknown",//未选具体类型
|
|
16
|
+
FORMULA = "FORMULA",
|
|
17
|
+
COLLECTION = "collection"
|
|
16
18
|
}
|
|
17
19
|
export interface AtomsNotExists {
|
|
18
20
|
quotes: string;
|
|
@@ -24,6 +26,21 @@ export interface AtomsExists {
|
|
|
24
26
|
notExists?: MetaListType[];
|
|
25
27
|
type: AtomsTypeEnum.EXISTS;
|
|
26
28
|
}
|
|
29
|
+
export type Arity = {
|
|
30
|
+
exact: number;
|
|
31
|
+
} | {
|
|
32
|
+
min: number;
|
|
33
|
+
} | {
|
|
34
|
+
min: number;
|
|
35
|
+
max: number;
|
|
36
|
+
};
|
|
37
|
+
export interface AtomsFormula {
|
|
38
|
+
args: AtomsItem[];
|
|
39
|
+
arity?: Arity;
|
|
40
|
+
quotes: string;
|
|
41
|
+
name: string;
|
|
42
|
+
type: AtomsTypeEnum.FORMULA;
|
|
43
|
+
}
|
|
27
44
|
export interface AtomsExpression {
|
|
28
45
|
lhs: AtomsItem[];
|
|
29
46
|
rhs: AtomsItem[];
|
|
@@ -82,7 +99,12 @@ export interface AtomsUnknown {
|
|
|
82
99
|
val: string;
|
|
83
100
|
type: AtomsTypeEnum.UNKNOWN;
|
|
84
101
|
}
|
|
85
|
-
export
|
|
102
|
+
export interface AtomsCollection {
|
|
103
|
+
list: AtomsItem[];
|
|
104
|
+
quotes: string;
|
|
105
|
+
type: AtomsTypeEnum.COLLECTION;
|
|
106
|
+
}
|
|
107
|
+
export type AtomsItem = AtomsNotExists | AtomsExists | AtomsJoinDefault | AtomsExpression | AtomsFormula | AtomsField | AtomsInputString | AtomsInputStringList | AtomsInputNumberList | AtomsInputNumber | AtomsOprator | AtomsConstant | AtomsUnknown | AtomsCollection;
|
|
86
108
|
export type ToolbarType = TypeEnum | 'filter' | 'summarize' | 'joinData' | 'permissionTable' | 'customColumn' | 'sort' | 'rowLimit' | 'union';
|
|
87
109
|
export type MetaListType = MetaData | MetaJoin | MetaCustom | MetaFilter | MetaSummarize | MetaSort | MetaLimit | MetaPermissionTable | MetaUnion;
|
|
88
110
|
export type initColumnsType = MetaData_ColumnsType;
|
|
@@ -293,10 +315,22 @@ export interface ParamsType {
|
|
|
293
315
|
code: string;
|
|
294
316
|
}
|
|
295
317
|
export interface PopupData {
|
|
318
|
+
container?: any;
|
|
296
319
|
visible: boolean;
|
|
297
320
|
node?: any;
|
|
298
321
|
content?: any;
|
|
299
322
|
}
|
|
323
|
+
export interface FormulaTemplatesItem {
|
|
324
|
+
name: string;
|
|
325
|
+
args: {
|
|
326
|
+
type: AtomsTypeEnum;
|
|
327
|
+
check?: string | null;
|
|
328
|
+
}[];
|
|
329
|
+
arity?: Arity;
|
|
330
|
+
output?: string;
|
|
331
|
+
description?: string;
|
|
332
|
+
example?: string;
|
|
333
|
+
}
|
|
300
334
|
export {};
|
|
301
335
|
/**
|
|
302
336
|
let a = {
|
package/lib/es/store/types.js
CHANGED
|
@@ -6,6 +6,7 @@ export var AtomsTypeEnum;
|
|
|
6
6
|
AtomsTypeEnum["NOT_EXISTS"] = "notExists";
|
|
7
7
|
AtomsTypeEnum["FIELD"] = "field";
|
|
8
8
|
AtomsTypeEnum["EXPRESSION"] = "expression";
|
|
9
|
+
// FUNCTION = 'function', // 函数
|
|
9
10
|
AtomsTypeEnum["INPUT_STRING"] = "inputString";
|
|
10
11
|
AtomsTypeEnum["INPUT_STRING_LIST"] = "inputStringList";
|
|
11
12
|
AtomsTypeEnum["INPUT_NUMBER_LIST"] = "inputNumberList";
|
|
@@ -13,6 +14,8 @@ export var AtomsTypeEnum;
|
|
|
13
14
|
AtomsTypeEnum["CONSTANT"] = "constant";
|
|
14
15
|
AtomsTypeEnum["OPERATOR"] = "operator";
|
|
15
16
|
AtomsTypeEnum["UNKNOWN"] = "unknown";
|
|
17
|
+
AtomsTypeEnum["FORMULA"] = "FORMULA";
|
|
18
|
+
AtomsTypeEnum["COLLECTION"] = "collection";
|
|
16
19
|
})(AtomsTypeEnum || (AtomsTypeEnum = {}));
|
|
17
20
|
// ----------- 第五个模块 聚合模块 ------------
|
|
18
21
|
export var MetaSummarize_Enum;
|
package/lib/es/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MetaListType, ToolbarType } from './store/types';
|
|
1
|
+
import type { MetaListType, ToolbarType, FormulaTemplatesItem } from './store/types';
|
|
2
2
|
import { UnionEnum } from './store/enum';
|
|
3
3
|
import { DataType } from './components/dialog/select-join-column';
|
|
4
4
|
export interface MetaListProps {
|
|
@@ -32,6 +32,7 @@ export interface MetabaseProps {
|
|
|
32
32
|
ignoreGroupByType?: boolean;
|
|
33
33
|
filterCustomType?: boolean;
|
|
34
34
|
notExistsColumns?: DataType[];
|
|
35
|
+
formulaTemplates?: FormulaTemplatesItem[];
|
|
35
36
|
}
|
|
36
37
|
export interface OptionItem {
|
|
37
38
|
value?: string;
|
package/lib/es/types.js
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
|
+
// {
|
|
3
|
+
// name: 'LENGTH', // 函数名
|
|
4
|
+
// args: [
|
|
5
|
+
// {
|
|
6
|
+
// type: 'field', // 参数类型
|
|
7
|
+
// check: 'string', // null 啥都可以, string 字符串, number 数字, (默认不传是 null)
|
|
8
|
+
// },
|
|
9
|
+
// {
|
|
10
|
+
// type: 'constant', // 参数类型
|
|
11
|
+
// check: null, // null 啥都可以, string 字符串, number 数字, (默认不传是 null)
|
|
12
|
+
// },
|
|
13
|
+
// ],
|
|
14
|
+
// arity: { max: 4 },
|
|
15
|
+
// output: 'number', // string | number| null (默认是 null)
|
|
16
|
+
// description: '返回字符串的长度',
|
|
17
|
+
// example: 'LENGTH("hello")',
|
|
18
|
+
// },
|
package/lib/es/utils.js
CHANGED
|
@@ -439,6 +439,7 @@ export function splitByUnion(data) {
|
|
|
439
439
|
return result;
|
|
440
440
|
}
|
|
441
441
|
export var patchData = function patchData(metas) {
|
|
442
|
+
return metas;
|
|
442
443
|
var mainTable = metas[0] || {};
|
|
443
444
|
var version = (mainTable === null || mainTable === void 0 ? void 0 : mainTable.patchVersion) || '';
|
|
444
445
|
if (version != '1.0.0') {
|
|
@@ -584,7 +585,7 @@ export var buildSqlQuery = function buildSqlQuery() {
|
|
|
584
585
|
var filterStrings = item.filter.map(function (f) {
|
|
585
586
|
if (f.type === AtomsTypeEnum.FIELD) {
|
|
586
587
|
return f.fieldName;
|
|
587
|
-
} else if (f.type === AtomsTypeEnum.EXPRESSION || f.type === AtomsTypeEnum.EXISTS || f.type === AtomsTypeEnum.NOT_EXISTS) {
|
|
588
|
+
} else if (f.type === AtomsTypeEnum.EXPRESSION || f.type === AtomsTypeEnum.EXISTS || f.type === AtomsTypeEnum.NOT_EXISTS || f.type === AtomsTypeEnum.FORMULA || f.type === AtomsTypeEnum.COLLECTION) {
|
|
588
589
|
return f.quotes;
|
|
589
590
|
} else if (f.type === AtomsTypeEnum.JOIN_DEFAULT) {
|
|
590
591
|
return '';
|
package/package.json
CHANGED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { AtomsTypeEnum } from '../../../store/types';
|
|
2
|
-
export declare enum FunctionEnum {
|
|
3
|
-
LOWER = "lower",
|
|
4
|
-
UPPER = "upper",
|
|
5
|
-
SUBSTRING = "substring",
|
|
6
|
-
REGEX_MATCH_FIRST = "regex-match-first",
|
|
7
|
-
'CONCAT' = "concat",
|
|
8
|
-
'REPLACE' = "replace",
|
|
9
|
-
'TRIM' = "trim",
|
|
10
|
-
'RTRIM' = "RTRIM",
|
|
11
|
-
'LTRIM' = "rtrim",
|
|
12
|
-
'LENGTH' = "length",
|
|
13
|
-
'ABS' = "abs",
|
|
14
|
-
'FLOOR' = "floor",
|
|
15
|
-
'CEIL' = "ceil",
|
|
16
|
-
'ROUND' = "round",
|
|
17
|
-
'SQRT' = "sqrt",
|
|
18
|
-
'POWER' = "power",
|
|
19
|
-
'LOG' = "log",
|
|
20
|
-
'EXP' = "exp",
|
|
21
|
-
'CONTAINS' = "contains",
|
|
22
|
-
'ENDS_WITH' = "ends-with",
|
|
23
|
-
'STARTS_WITH' = "starts-with",
|
|
24
|
-
'BETWEEN' = "between",
|
|
25
|
-
'TIME_INTERVAL' = "time-interval",
|
|
26
|
-
'IS_NULL' = "is-null",
|
|
27
|
-
'IS_EMPTY' = "is-empty",
|
|
28
|
-
'COALESCE' = "coalesce"
|
|
29
|
-
}
|
|
30
|
-
export declare const operatorList: string[];
|
|
31
|
-
export declare const customTypes: ({
|
|
32
|
-
value: AtomsTypeEnum;
|
|
33
|
-
label: any;
|
|
34
|
-
children?: undefined;
|
|
35
|
-
} | {
|
|
36
|
-
value: AtomsTypeEnum;
|
|
37
|
-
label: any;
|
|
38
|
-
children: string[];
|
|
39
|
-
})[];
|