@gingkoo/pandora-metabase 1.0.156 → 1.0.157-alpha.10
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 +61 -5
- package/lib/cjs/components/dialog/expression/index.js +132 -54
- package/lib/cjs/components/dialog/expression/index.less +43 -0
- package/lib/cjs/components/dialog/formula/index.js +3 -1
- package/lib/cjs/components/dialog/formula/utils.d.ts +1 -0
- package/lib/cjs/components/dialog/formula/utils.js +20 -2
- package/lib/cjs/components/dialog/formula-list/index.d.ts +2 -0
- package/lib/cjs/components/dialog/formula-list/index.js +1119 -151
- package/lib/cjs/components/dialog/formula-list/index.less +362 -46
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +13 -1
- package/lib/cjs/components/dialog/formula-list/utils.js +100 -1
- package/lib/cjs/components/dialog/select-column-multiple/index.d.ts +2 -1
- package/lib/cjs/components/dialog/select-column-multiple/index.js +4 -2
- package/lib/cjs/components/dialog/select-join/index.js +11 -0
- package/lib/cjs/components/dialog/select-summarize/index.d.ts +4 -0
- package/lib/cjs/components/dialog/select-summarize/index.js +136 -15
- package/lib/cjs/components/dialog/select-summarize/index.less +34 -1
- package/lib/cjs/components/dialog/select-table/index.d.ts +4 -1
- package/lib/cjs/components/dialog/select-table/index.js +51 -7
- package/lib/cjs/components/dialog/select-table/index.less +20 -0
- package/lib/cjs/components/icons.d.ts +1 -0
- package/lib/cjs/components/icons.js +54 -29
- package/lib/cjs/components/metabase/index.js +8 -0
- package/lib/cjs/components/metabase/index.less +17 -14
- package/lib/cjs/components/modules/components/item-name.js +16 -2
- package/lib/cjs/components/modules/components/meta-icon.js +6 -4
- package/lib/cjs/components/modules/join-data.js +5 -0
- package/lib/cjs/components/modules/summarize/group-by.js +12 -1
- package/lib/cjs/components/modules/summarize/select-index.js +12 -1
- package/lib/cjs/hooks/use-state.js +1 -13
- package/lib/cjs/index.d.ts +3 -2
- package/lib/cjs/index.js +7 -0
- package/lib/cjs/locale/en.js +31 -0
- package/lib/cjs/locale/index.js +10 -6
- package/lib/cjs/locale/zh.js +31 -0
- package/lib/cjs/store/enum.d.ts +2 -1
- package/lib/cjs/store/enum.js +1 -0
- package/lib/cjs/store/helper.js +25 -2
- package/lib/cjs/store/types.d.ts +7 -1
- package/lib/cjs/types.d.ts +41 -1
- package/lib/cjs/utils/helper.js +20 -0
- package/lib/cjs/utils/transformSql.js +59 -2
- package/lib/cjs/utils.js +25 -4
- package/lib/es/components/dialog/custom-editor/index.js +62 -6
- package/lib/es/components/dialog/expression/index.js +133 -55
- package/lib/es/components/dialog/expression/index.less +43 -0
- package/lib/es/components/dialog/formula/index.js +4 -2
- package/lib/es/components/dialog/formula/utils.d.ts +1 -0
- package/lib/es/components/dialog/formula/utils.js +18 -1
- package/lib/es/components/dialog/formula-list/index.d.ts +2 -0
- package/lib/es/components/dialog/formula-list/index.js +1121 -153
- package/lib/es/components/dialog/formula-list/index.less +362 -46
- package/lib/es/components/dialog/formula-list/utils.d.ts +13 -1
- package/lib/es/components/dialog/formula-list/utils.js +99 -0
- package/lib/es/components/dialog/select-column-multiple/index.d.ts +2 -1
- package/lib/es/components/dialog/select-column-multiple/index.js +4 -2
- package/lib/es/components/dialog/select-join/index.js +12 -1
- package/lib/es/components/dialog/select-summarize/index.d.ts +4 -0
- package/lib/es/components/dialog/select-summarize/index.js +140 -19
- package/lib/es/components/dialog/select-summarize/index.less +34 -1
- package/lib/es/components/dialog/select-table/index.d.ts +4 -1
- package/lib/es/components/dialog/select-table/index.js +51 -7
- package/lib/es/components/dialog/select-table/index.less +20 -0
- package/lib/es/components/icons.d.ts +1 -0
- package/lib/es/components/icons.js +53 -28
- package/lib/es/components/metabase/index.js +8 -0
- package/lib/es/components/metabase/index.less +17 -14
- package/lib/es/components/modules/components/item-name.js +16 -2
- package/lib/es/components/modules/components/meta-icon.js +6 -4
- package/lib/es/components/modules/join-data.js +6 -1
- package/lib/es/components/modules/summarize/group-by.js +12 -1
- package/lib/es/components/modules/summarize/select-index.js +12 -1
- package/lib/es/hooks/use-state.js +1 -13
- package/lib/es/index.d.ts +3 -2
- package/lib/es/index.js +3 -1
- package/lib/es/locale/en.js +31 -0
- package/lib/es/locale/index.js +10 -6
- package/lib/es/locale/zh.js +31 -0
- package/lib/es/store/enum.d.ts +2 -1
- package/lib/es/store/enum.js +1 -0
- package/lib/es/store/helper.js +25 -2
- package/lib/es/store/types.d.ts +7 -1
- package/lib/es/types.d.ts +41 -1
- package/lib/es/utils/helper.js +20 -0
- package/lib/es/utils/transformSql.js +59 -2
- package/lib/es/utils.js +25 -4
- package/package.json +1 -1
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
@import './helper.less';
|
|
2
2
|
|
|
3
|
+
// Tooltip 动画期间组件库会临时关闭 pointer-events,导致点击穿透到下层按钮。
|
|
4
|
+
.pd-Trigger.pd-Tooltip {
|
|
5
|
+
pointer-events: auto !important;
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
.visual-box {
|
|
4
9
|
position: relative;
|
|
5
10
|
width: 100%;
|
|
@@ -167,10 +172,7 @@
|
|
|
167
172
|
cursor: pointer;
|
|
168
173
|
pointer-events: none;
|
|
169
174
|
transform: translateY(-50%) scale(0.86);
|
|
170
|
-
transition:
|
|
171
|
-
opacity 160ms ease,
|
|
172
|
-
border-color 160ms ease,
|
|
173
|
-
background-color 160ms ease,
|
|
175
|
+
transition: opacity 160ms ease, border-color 160ms ease, background-color 160ms ease,
|
|
174
176
|
transform 160ms ease;
|
|
175
177
|
|
|
176
178
|
&::before {
|
|
@@ -184,9 +186,7 @@
|
|
|
184
186
|
background: transparent;
|
|
185
187
|
box-shadow: none;
|
|
186
188
|
transform: translateY(-50%);
|
|
187
|
-
transition:
|
|
188
|
-
border-color 160ms ease,
|
|
189
|
-
background-color 160ms ease;
|
|
189
|
+
transition: border-color 160ms ease, background-color 160ms ease;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
img {
|
|
@@ -289,9 +289,7 @@
|
|
|
289
289
|
border-radius: 5px;
|
|
290
290
|
color: white;
|
|
291
291
|
background-color: rgb(80, 158, 227);
|
|
292
|
-
transition:
|
|
293
|
-
background 300ms linear 0s,
|
|
294
|
-
border 300ms linear 0s;
|
|
292
|
+
transition: background 300ms linear 0s, border 300ms linear 0s;
|
|
295
293
|
box-sizing: border-box;
|
|
296
294
|
margin: 0;
|
|
297
295
|
padding: 4px 7px;
|
|
@@ -550,7 +548,7 @@
|
|
|
550
548
|
svg {
|
|
551
549
|
flex-shrink: 0;
|
|
552
550
|
}
|
|
553
|
-
|
|
551
|
+
.Sqb-button-label {
|
|
554
552
|
margin-top: 0.5rem;
|
|
555
553
|
}
|
|
556
554
|
}
|
|
@@ -582,15 +580,20 @@
|
|
|
582
580
|
&.small {
|
|
583
581
|
margin-right: 8px;
|
|
584
582
|
margin-top: 0;
|
|
585
|
-
padding: 0.5rem;
|
|
583
|
+
padding: 0.5rem 0.75rem;
|
|
586
584
|
& > div {
|
|
587
585
|
min-width: 0;
|
|
586
|
+
flex-direction: row;
|
|
587
|
+
gap: 4px;
|
|
588
588
|
svg {
|
|
589
589
|
width: 14px;
|
|
590
590
|
height: 14px;
|
|
591
591
|
}
|
|
592
|
-
|
|
593
|
-
|
|
592
|
+
.Sqb-button-label {
|
|
593
|
+
margin-top: 0;
|
|
594
|
+
font-size: 12px;
|
|
595
|
+
line-height: 14px;
|
|
596
|
+
white-space: nowrap;
|
|
594
597
|
}
|
|
595
598
|
}
|
|
596
599
|
}
|
|
@@ -11,7 +11,15 @@ var ItemName = function ItemName(props) {
|
|
|
11
11
|
var showError = isError && !store.snapshotMode;
|
|
12
12
|
return _jsx(Badge, {
|
|
13
13
|
count: showError ? _jsx(Tooltip, {
|
|
14
|
-
title:
|
|
14
|
+
title: _jsx("span", {
|
|
15
|
+
onMouseDown: function onMouseDown(e) {
|
|
16
|
+
return e.stopPropagation();
|
|
17
|
+
},
|
|
18
|
+
onClick: function onClick(e) {
|
|
19
|
+
return e.stopPropagation();
|
|
20
|
+
},
|
|
21
|
+
children: message || __('metabase.verify')
|
|
22
|
+
}),
|
|
15
23
|
children: _jsx(Button, {
|
|
16
24
|
className: 'isError',
|
|
17
25
|
style: {
|
|
@@ -22,7 +30,13 @@ var ItemName = function ItemName(props) {
|
|
|
22
30
|
danger: true,
|
|
23
31
|
size: 'small',
|
|
24
32
|
icon: _jsx(ExclamationCircleFill, {}),
|
|
25
|
-
iconOnly: true
|
|
33
|
+
iconOnly: true,
|
|
34
|
+
onMouseDown: function onMouseDown(e) {
|
|
35
|
+
return e.stopPropagation();
|
|
36
|
+
},
|
|
37
|
+
onClick: function onClick(e) {
|
|
38
|
+
return e.stopPropagation();
|
|
39
|
+
}
|
|
26
40
|
})
|
|
27
41
|
}) : '',
|
|
28
42
|
children: children
|
|
@@ -68,9 +68,10 @@ var metaIcon = function metaIcon(size, handleClick) {
|
|
|
68
68
|
return handleClick(type);
|
|
69
69
|
},
|
|
70
70
|
children: _jsxs("div", {
|
|
71
|
-
children: [info.icon,
|
|
71
|
+
children: [info.icon, _jsx("span", {
|
|
72
|
+
className: 'Sqb-button-label',
|
|
72
73
|
children: info.name
|
|
73
|
-
})
|
|
74
|
+
})]
|
|
74
75
|
})
|
|
75
76
|
})
|
|
76
77
|
});
|
|
@@ -344,9 +345,10 @@ var NextDom = function NextDom(props) {
|
|
|
344
345
|
handleClick(v);
|
|
345
346
|
},
|
|
346
347
|
children: _jsxs("div", {
|
|
347
|
-
children: [info.icon,
|
|
348
|
+
children: [info.icon, _jsx("span", {
|
|
349
|
+
className: 'Sqb-button-label',
|
|
348
350
|
children: info.name
|
|
349
|
-
})
|
|
351
|
+
})]
|
|
350
352
|
})
|
|
351
353
|
})
|
|
352
354
|
}, "".concat(String(v), "-").concat(idx));
|
|
@@ -28,7 +28,7 @@ import NextDom from './components/meta-icon';
|
|
|
28
28
|
import Header from './components/header';
|
|
29
29
|
import ItemWrapper from './components/item-wrapper';
|
|
30
30
|
import SelectList from '../dialog/select-list';
|
|
31
|
-
import { LeftJoinIcon, InnerJoinIcon } from '../icons';
|
|
31
|
+
import { LeftJoinIcon, InnerJoinIcon, FullJoinIcon } from '../icons';
|
|
32
32
|
import { SelectTable, SelectJoin, SelectColumnMultiple, SelectColumn, Expression, SelectPermissionTable, FormulaList, getTemplateItem } from '../dialog';
|
|
33
33
|
import { useStore } from '../../hooks/use-provider';
|
|
34
34
|
var PrevResult = 'Previous results';
|
|
@@ -1372,6 +1372,11 @@ var JoinData = function JoinData(props) {
|
|
|
1372
1372
|
marginRight: '0.5rem',
|
|
1373
1373
|
cursor: 'pointer'
|
|
1374
1374
|
}
|
|
1375
|
+
}) : meta.joinType === JoinEnum.full ? _jsx(FullJoinIcon, {
|
|
1376
|
+
style: {
|
|
1377
|
+
marginRight: '0.5rem',
|
|
1378
|
+
cursor: 'pointer'
|
|
1379
|
+
}
|
|
1375
1380
|
}) : _jsx(InnerJoinIcon, {
|
|
1376
1381
|
style: {
|
|
1377
1382
|
marginRight: '0.5rem',
|
|
@@ -528,7 +528,18 @@ var GroupBy = function GroupBy(props) {
|
|
|
528
528
|
children: [v.quotes && _jsx(_Fragment, {
|
|
529
529
|
children: store.groupByEnableAlias && !store.snapshotMode && _jsx(_Fragment, {
|
|
530
530
|
children: _jsx(Tooltip, {
|
|
531
|
-
|
|
531
|
+
triggerProps: {
|
|
532
|
+
duration: 0
|
|
533
|
+
},
|
|
534
|
+
title: _jsx("span", {
|
|
535
|
+
onMouseDown: function onMouseDown(e) {
|
|
536
|
+
return e.stopPropagation();
|
|
537
|
+
},
|
|
538
|
+
onClick: function onClick(e) {
|
|
539
|
+
return e.stopPropagation();
|
|
540
|
+
},
|
|
541
|
+
children: __(existsError ? 'SqlQueryBuilder.existsErrorAliasAction' : aliasError ? 'SqlQueryBuilder.aliasForRulesAction' : 'SqlQueryBuilder.alias')
|
|
542
|
+
}),
|
|
532
543
|
children: _jsx(Button, {
|
|
533
544
|
danger: existsError || aliasError,
|
|
534
545
|
className: cx(':Sqb-TableName-as :Sqb-TableName green-name', {
|
|
@@ -426,7 +426,18 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
426
426
|
children: [v.quotes && _jsx(_Fragment, {
|
|
427
427
|
children: store.groupByEnableAlias && !store.snapshotMode && _jsx(_Fragment, {
|
|
428
428
|
children: _jsx(Tooltip, {
|
|
429
|
-
|
|
429
|
+
triggerProps: {
|
|
430
|
+
duration: 0
|
|
431
|
+
},
|
|
432
|
+
title: _jsx("span", {
|
|
433
|
+
onMouseDown: function onMouseDown(e) {
|
|
434
|
+
return e.stopPropagation();
|
|
435
|
+
},
|
|
436
|
+
onClick: function onClick(e) {
|
|
437
|
+
return e.stopPropagation();
|
|
438
|
+
},
|
|
439
|
+
children: __(existsError ? 'SqlQueryBuilder.existsErrorAliasAction' : aliasError ? 'SqlQueryBuilder.aliasForRulesAction' : 'SqlQueryBuilder.alias')
|
|
440
|
+
}),
|
|
430
441
|
children: _jsx(Button, {
|
|
431
442
|
danger: existsError || aliasError,
|
|
432
443
|
className: cx(':Sqb-TableName-as :Sqb-TableName green-name', {
|
|
@@ -519,8 +519,6 @@ var useStore = function useStore() {
|
|
|
519
519
|
isSelect,
|
|
520
520
|
_isSubquery,
|
|
521
521
|
_isExit,
|
|
522
|
-
oldObj,
|
|
523
|
-
selectId,
|
|
524
522
|
_table$alias,
|
|
525
523
|
alias,
|
|
526
524
|
datasourceName,
|
|
@@ -539,17 +537,7 @@ var useStore = function useStore() {
|
|
|
539
537
|
isSelect = _args8.length > 4 && _args8[4] !== undefined ? _args8[4] : isSelectFields;
|
|
540
538
|
_isSubquery = _args8.length > 5 && _args8[5] !== undefined ? _args8[5] : isSubquery;
|
|
541
539
|
_isExit = _args8.length > 6 && _args8[6] !== undefined ? _args8[6] : isExit;
|
|
542
|
-
oldObj = {};
|
|
543
|
-
selectId = oldColumns.filter(function (v) {
|
|
544
|
-
oldObj[v.id] = v;
|
|
545
|
-
return v.select;
|
|
546
|
-
}).map(function (v) {
|
|
547
|
-
return v.id;
|
|
548
|
-
}).filter(function (v) {
|
|
549
|
-
return v;
|
|
550
|
-
});
|
|
551
540
|
if (_isSubquery && oldColumns.length < 1) {
|
|
552
|
-
selectId = [];
|
|
553
541
|
isSelect = false;
|
|
554
542
|
}
|
|
555
543
|
_table$alias = table.alias, alias = _table$alias === void 0 ? '' : _table$alias, datasourceName = table.datasourceName, did = table.datasourceId, column = table.column, extra = _objectWithoutProperties(table, _excluded);
|
|
@@ -572,7 +560,7 @@ var useStore = function useStore() {
|
|
|
572
560
|
var obj = oldColumns.find(function (oldColumn) {
|
|
573
561
|
return isSameColumnByIdFirst(oldColumn, v);
|
|
574
562
|
});
|
|
575
|
-
var select =
|
|
563
|
+
var select = Boolean(obj === null || obj === void 0 ? void 0 : obj.select);
|
|
576
564
|
return _objectSpread(_objectSpread(_objectSpread({}, obj), v), {}, {
|
|
577
565
|
select: isSelect || select,
|
|
578
566
|
fieldAlias: (_ref9 = (_obj$fieldAlias = obj === null || obj === void 0 ? void 0 : obj.fieldAlias) !== null && _obj$fieldAlias !== void 0 ? _obj$fieldAlias : v.fieldAlias) !== null && _ref9 !== void 0 ? _ref9 : '',
|
package/lib/es/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './locale/en';
|
|
3
3
|
import './locale/zh';
|
|
4
|
-
import type { MetabaseProps, SqlVisionBuilderRef, DatasourceType, MetabaseRightClickMenuItem, MetabaseRightClickMenuClickParams } from './types';
|
|
4
|
+
import type { MetabaseProps, SqlVisionBuilderRef, DatasourceType, MetabaseRightClickMenuItem, MetabaseRightClickMenuClickParams, FormulaSqlParseParams, FormulaSqlParseResult, FormulaSqlChatMessage, FormulaSqlTableScopeItem, FormulaSqlStreamHandlers, FormulaSqlStreamParseParams } from './types';
|
|
5
5
|
import type { MetaListType, ToolbarType } from './store/types';
|
|
6
|
+
import { AtomsTypeEnum } from './store/types';
|
|
6
7
|
declare const SqlVisionBuilder: React.ForwardRefExoticComponent<MetabaseProps & React.RefAttributes<SqlVisionBuilderRef>>;
|
|
7
8
|
export default SqlVisionBuilder;
|
|
8
|
-
export { MetabaseProps, DatasourceType, MetaListType, ToolbarType, SqlVisionBuilderRef, MetabaseRightClickMenuItem, MetabaseRightClickMenuClickParams, };
|
|
9
|
+
export { MetabaseProps, DatasourceType, MetaListType, ToolbarType, SqlVisionBuilderRef, MetabaseRightClickMenuItem, MetabaseRightClickMenuClickParams, FormulaSqlParseParams, FormulaSqlParseResult, FormulaSqlChatMessage, FormulaSqlTableScopeItem, FormulaSqlStreamHandlers, FormulaSqlStreamParseParams, AtomsTypeEnum, };
|
package/lib/es/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import './locale/zh';
|
|
|
8
8
|
import { __ } from './locale';
|
|
9
9
|
import Loading from './common/Loading';
|
|
10
10
|
import Metabase from './components/metabase';
|
|
11
|
+
import { AtomsTypeEnum } from './store/types';
|
|
11
12
|
import { reassembleByUnion, patchData, splitByUnion, normalizeLegacySummarizeForSave, normalizeAndOrStructure } from './utils';
|
|
12
13
|
import cloneDeep from 'lodash/cloneDeep';
|
|
13
14
|
var EMPTY_ARRAY = [];
|
|
@@ -161,4 +162,5 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
161
162
|
children: _jsx(Metabase, _objectSpread({}, props))
|
|
162
163
|
});
|
|
163
164
|
});
|
|
164
|
-
export default SqlVisionBuilder;
|
|
165
|
+
export default SqlVisionBuilder;
|
|
166
|
+
export { AtomsTypeEnum };
|
package/lib/es/locale/en.js
CHANGED
|
@@ -35,6 +35,34 @@ export default register('en', {
|
|
|
35
35
|
'SqlQueryBuilder.pickConstant': 'Select constant...',
|
|
36
36
|
'customColumn.input': 'Input',
|
|
37
37
|
'customColumn.numberInput': 'Number input',
|
|
38
|
+
'customColumn.addSql': 'Add SQL',
|
|
39
|
+
'customColumn.parseSql': 'Parse with AI',
|
|
40
|
+
'customColumn.sqlChatTitle': 'AI SQL Assistant',
|
|
41
|
+
'customColumn.sqlChatDesc': 'Generate expression configuration in chat, then apply it here.',
|
|
42
|
+
'customColumn.sqlChatEmpty': 'Paste SQL or continue with more context. AI will convert it into expression configuration.',
|
|
43
|
+
'customColumn.sqlChatPlaceholder': 'Paste SQL, or continue refining the previous result...',
|
|
44
|
+
'customColumn.sqlChatThinking': 'Parsing SQL...',
|
|
45
|
+
'customColumn.sqlChatGeneratingConfig': 'Generating configuration...',
|
|
46
|
+
'customColumn.sqlChatSuccess': 'Expression configuration is ready to apply.',
|
|
47
|
+
'customColumn.sqlChatSuccessApplied': 'Expression configuration has been applied.',
|
|
48
|
+
'customColumn.sqlChatCanceled': 'Canceled by user',
|
|
49
|
+
'customColumn.sqlChatApply': 'Apply',
|
|
50
|
+
'customColumn.sqlChatPreview': 'Preview',
|
|
51
|
+
'customColumn.sqlChatPaste': 'Paste SQL',
|
|
52
|
+
'customColumn.sqlChatSend': 'Send',
|
|
53
|
+
'customColumn.sqlChatStop': 'Stop',
|
|
54
|
+
'customColumn.sqlChatMe': 'Me',
|
|
55
|
+
'customColumn.sqlChatClipboardEmpty': 'Clipboard does not contain SQL content',
|
|
56
|
+
'customColumn.sqlChatPasteFailed': 'Unable to read clipboard. Paste directly into the input box.',
|
|
57
|
+
'customColumn.sqlChatMissingParser': 'SQL parser is not configured for this component',
|
|
58
|
+
'customColumn.sqlChatTableScope': 'Table scope',
|
|
59
|
+
'customColumn.sqlChatAddTable': 'Add table',
|
|
60
|
+
'customColumn.sqlChatPickDatasource': 'Select datasource',
|
|
61
|
+
'customColumn.sqlChatLoadingTables': 'Loading tables...',
|
|
62
|
+
'customColumn.sqlChatNoTables': 'No tables available',
|
|
63
|
+
'customColumn.sqlChatScopeFallback': 'When no table is selected, the current expression context is used.',
|
|
64
|
+
'customColumn.sqlParseInvalid': 'AI returned an invalid custom column configuration',
|
|
65
|
+
'customColumn.sqlParseFailed': 'Failed to parse SQL. Please try again',
|
|
38
66
|
'customColumn.formula': 'Formula',
|
|
39
67
|
'customColumn.selectFormula': 'Select formula...',
|
|
40
68
|
'SqlQueryBuilder.switchSubQuery': 'Open subquery',
|
|
@@ -144,6 +172,8 @@ export default register('en', {
|
|
|
144
172
|
'summarize.theSmallestYes': 'the smallest, yes',
|
|
145
173
|
'summarize.maximumCalue': 'maximum value',
|
|
146
174
|
'summarize.biggestYes': 'biggest, yes',
|
|
175
|
+
'summarize.stringAgg': 'Aggregate string concatenation',
|
|
176
|
+
'summarize.stringAggExpression': 'STRING_AGG',
|
|
147
177
|
'summarize.totalNumberOfRowsOfData': 'total number of rows of data',
|
|
148
178
|
'summarize.theSumOfAllValuesInAField': 'the sum of all values in a field',
|
|
149
179
|
'summarize.theAverageOfAllValuesInAfield': 'the average of all values in a field',
|
|
@@ -153,6 +183,7 @@ export default register('en', {
|
|
|
153
183
|
'summarize.theStandardDeviationOfAllValuesInAfield': 'the standard deviation of all values in a field',
|
|
154
184
|
'summarize.theMinimumValueOfAfield': 'the minimum value of a field',
|
|
155
185
|
'summarize.TheMaximumValueOfAfield': 'the maximum value of a field',
|
|
186
|
+
'summarize.stringAggDescription': 'Concatenate strings across rows within each group, with a custom delimiter.',
|
|
156
187
|
'rowLimit.pleaseEnter': 'please enter',
|
|
157
188
|
'result.TheSQLStatementForThisQuery': 'The SQL statement for this query',
|
|
158
189
|
'result.closePanel': 'close panel',
|
package/lib/es/locale/index.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { getCookie } from '../utils/cookies';
|
|
2
2
|
var locales = {};
|
|
3
|
-
var
|
|
3
|
+
var normalizeLocale = function normalizeLocale(locale) {
|
|
4
|
+
var normalized = (locale || 'zh').toLowerCase().replace('_', '-');
|
|
5
|
+
if (normalized.startsWith('en')) return 'en';
|
|
6
|
+
return 'zh';
|
|
7
|
+
};
|
|
8
|
+
var activeLocale = normalizeLocale(getCookie('LOCALE'));
|
|
4
9
|
export var isEn = activeLocale === 'en';
|
|
5
10
|
export var register = function register(name, data) {
|
|
6
11
|
if (name in locales) {} else {
|
|
@@ -8,9 +13,8 @@ export var register = function register(name, data) {
|
|
|
8
13
|
}
|
|
9
14
|
};
|
|
10
15
|
export var __ = function __(name) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
+
var _locales$activeLocale, _locales$zh, _locales$en;
|
|
17
|
+
var message = ((_locales$activeLocale = locales[activeLocale]) === null || _locales$activeLocale === void 0 ? void 0 : _locales$activeLocale[name]) || ((_locales$zh = locales.zh) === null || _locales$zh === void 0 ? void 0 : _locales$zh[name]) || ((_locales$en = locales.en) === null || _locales$en === void 0 ? void 0 : _locales$en[name]);
|
|
18
|
+
if (!message) {}
|
|
19
|
+
return message || name;
|
|
16
20
|
};
|
package/lib/es/locale/zh.js
CHANGED
|
@@ -80,6 +80,34 @@ export default register('zh', {
|
|
|
80
80
|
'customColumn.selectFormula': '选择公式...',
|
|
81
81
|
'customColumn.input': '输入框',
|
|
82
82
|
'customColumn.numberInput': '数字输入框',
|
|
83
|
+
'customColumn.addSql': '添加 SQL',
|
|
84
|
+
'customColumn.parseSql': 'AI 解析',
|
|
85
|
+
'customColumn.sqlChatTitle': 'AI SQL 助手',
|
|
86
|
+
'customColumn.sqlChatDesc': '对话生成表达式配置,采纳后写入当前公式区域。',
|
|
87
|
+
'customColumn.sqlChatEmpty': '粘贴 SQL 或继续补充说明,AI 会转换成当前表达式配置。',
|
|
88
|
+
'customColumn.sqlChatPlaceholder': '粘贴 SQL,或继续补充上一轮解析说明...',
|
|
89
|
+
'customColumn.sqlChatThinking': '正在解析 SQL...',
|
|
90
|
+
'customColumn.sqlChatGeneratingConfig': '正在生成配置...',
|
|
91
|
+
'customColumn.sqlChatSuccess': '已生成表达式配置,可采纳到当前区域。',
|
|
92
|
+
'customColumn.sqlChatSuccessApplied': '已生成并写入当前表达式配置。',
|
|
93
|
+
'customColumn.sqlChatCanceled': '用户已取消',
|
|
94
|
+
'customColumn.sqlChatApply': '应用',
|
|
95
|
+
'customColumn.sqlChatPreview': '预览',
|
|
96
|
+
'customColumn.sqlChatPaste': '粘贴 SQL',
|
|
97
|
+
'customColumn.sqlChatSend': '发送',
|
|
98
|
+
'customColumn.sqlChatStop': '停止',
|
|
99
|
+
'customColumn.sqlChatMe': '我',
|
|
100
|
+
'customColumn.sqlChatClipboardEmpty': '剪贴板没有可用的 SQL 内容',
|
|
101
|
+
'customColumn.sqlChatPasteFailed': '无法读取剪贴板,请直接在输入框粘贴',
|
|
102
|
+
'customColumn.sqlChatMissingParser': '当前组件未配置 SQL 解析方法',
|
|
103
|
+
'customColumn.sqlChatTableScope': '表范围',
|
|
104
|
+
'customColumn.sqlChatAddTable': '添加表',
|
|
105
|
+
'customColumn.sqlChatPickDatasource': '选择数据源',
|
|
106
|
+
'customColumn.sqlChatLoadingTables': '正在加载表...',
|
|
107
|
+
'customColumn.sqlChatNoTables': '暂无可选表',
|
|
108
|
+
'customColumn.sqlChatScopeFallback': '未选择表时,将使用当前表达式已有上下文。',
|
|
109
|
+
'customColumn.sqlParseInvalid': 'AI 返回的自定义列结构无效',
|
|
110
|
+
'customColumn.sqlParseFailed': 'SQL 解析失败,请重试',
|
|
83
111
|
'filter.addFilter': '添加过滤器',
|
|
84
112
|
'filter.confirm': '确认',
|
|
85
113
|
'filter.pleaseEnter': '请输入',
|
|
@@ -144,6 +172,8 @@ export default register('zh', {
|
|
|
144
172
|
'summarize.theSmallestYes': '最小 的',
|
|
145
173
|
'summarize.maximumCalue': '最大值',
|
|
146
174
|
'summarize.biggestYes': '最大 的',
|
|
175
|
+
'summarize.stringAgg': '聚合字符串拼接',
|
|
176
|
+
'summarize.stringAggExpression': 'STRING_AGG',
|
|
147
177
|
'summarize.totalNumberOfRowsOfData': '总的数据行数',
|
|
148
178
|
'summarize.theSumOfAllValuesInAField': '一个字段所有数值的总和',
|
|
149
179
|
'summarize.theAverageOfAllValuesInAfield': '一个字段所有数值的平均值',
|
|
@@ -153,6 +183,7 @@ export default register('zh', {
|
|
|
153
183
|
'summarize.theStandardDeviationOfAllValuesInAfield': '一个字段所有数值的标准差',
|
|
154
184
|
'summarize.theMinimumValueOfAfield': '一个字段的最小值',
|
|
155
185
|
'summarize.TheMaximumValueOfAfield': '一个字段的最大值',
|
|
186
|
+
'summarize.stringAggDescription': '按分组跨行拼接字符串,支持自定义分隔符。',
|
|
156
187
|
'rowLimit.pleaseEnter': '请输入',
|
|
157
188
|
'result.TheSQLStatementForThisQuery': '这个查询的SQL语句',
|
|
158
189
|
'result.closePanel': '关闭面板',
|
package/lib/es/store/enum.d.ts
CHANGED
package/lib/es/store/enum.js
CHANGED
package/lib/es/store/helper.js
CHANGED
|
@@ -2,6 +2,7 @@ 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';
|
|
5
6
|
import { TypeEnum, SQL_COLUMN_TYPE } from './enum';
|
|
6
7
|
import { handleBaseType2Sql } from '../utils/transformSql';
|
|
7
8
|
export var SummarizeAlias = 'source';
|
|
@@ -54,6 +55,25 @@ export var summarizeToSql = function summarizeToSql(arr, record) {
|
|
|
54
55
|
sql = "max(".concat(field, ")");
|
|
55
56
|
as = 'max';
|
|
56
57
|
break;
|
|
58
|
+
case '聚合字符串拼接':
|
|
59
|
+
if (typeof record.delimiter === 'string') {
|
|
60
|
+
var _record$atoms2, _record$atoms3, _record$orderBy;
|
|
61
|
+
var delimiterIndex = (_record$atoms2 = record.atoms) === null || _record$atoms2 === void 0 ? void 0 : _record$atoms2.findIndex(function (atom) {
|
|
62
|
+
return atom.type === AtomsTypeEnum.OPERATOR && atom.val === ',';
|
|
63
|
+
});
|
|
64
|
+
var expressionAtoms = typeof delimiterIndex === 'number' && delimiterIndex >= 0 ? (_record$atoms3 = record.atoms) === null || _record$atoms3 === void 0 ? void 0 : _record$atoms3.slice(0, delimiterIndex) : record.atoms;
|
|
65
|
+
var expression = expressionAtoms !== null && expressionAtoms !== void 0 && expressionAtoms.length ? handleBaseType2Sql(expressionAtoms).sql.trim() : field;
|
|
66
|
+
var orderExpression = (_record$orderBy = record.orderBy) !== null && _record$orderBy !== void 0 && _record$orderBy.length ? handleBaseType2Sql(record.orderBy).sql.trim() : '';
|
|
67
|
+
var orderSql = orderExpression ? " order by ".concat(orderExpression, " ").concat(record.orderDirection || 'ASC') : '';
|
|
68
|
+
sql = "string_agg(".concat(record.distinct ? 'distinct ' : '').concat(expression, ", '").concat(record.delimiter.replace(/'/g, "''"), "'").concat(orderSql, ")");
|
|
69
|
+
} else {
|
|
70
|
+
var _record$atoms4;
|
|
71
|
+
sql = "string_agg(".concat(field).concat((_record$atoms4 = record.atoms) !== null && _record$atoms4 !== void 0 && _record$atoms4.some(function (atom) {
|
|
72
|
+
return atom.type === AtomsTypeEnum.OPERATOR && atom.val === ',';
|
|
73
|
+
}) ? '' : ", ','", ")");
|
|
74
|
+
}
|
|
75
|
+
as = 'string_agg';
|
|
76
|
+
break;
|
|
57
77
|
}
|
|
58
78
|
var count = 0;
|
|
59
79
|
prevList.forEach(function (v) {
|
|
@@ -75,6 +95,9 @@ export var summarizeToSql = function summarizeToSql(arr, record) {
|
|
|
75
95
|
if (condition === '最大值' && v.condition === '最大值') {
|
|
76
96
|
count++;
|
|
77
97
|
}
|
|
98
|
+
if (condition === '聚合字符串拼接' && v.condition === '聚合字符串拼接') {
|
|
99
|
+
count++;
|
|
100
|
+
}
|
|
78
101
|
});
|
|
79
102
|
as = as + (count ? '_' + (count + 1) : '');
|
|
80
103
|
return {
|
|
@@ -83,9 +106,9 @@ export var summarizeToSql = function summarizeToSql(arr, record) {
|
|
|
83
106
|
};
|
|
84
107
|
};
|
|
85
108
|
export var summarizeByToSql = function summarizeByToSql(record) {
|
|
86
|
-
var _record$
|
|
109
|
+
var _record$atoms5;
|
|
87
110
|
var sql = "".concat(record.alias, ".").concat(record.realName || record.name);
|
|
88
|
-
if ((_record$
|
|
111
|
+
if ((_record$atoms5 = record.atoms) !== null && _record$atoms5 !== void 0 && _record$atoms5.length) {
|
|
89
112
|
sql = handleBaseType2Sql(record.atoms).sql.trim() || sql;
|
|
90
113
|
}
|
|
91
114
|
return sql;
|
package/lib/es/store/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DatasourceType } from '../types';
|
|
2
|
-
import { TypeEnum, SpecialType, JoinEnum, SQL_COLUMN_TYPE, SortEnum } from './enum';
|
|
2
|
+
import { TypeEnum, SpecialType, JoinEnum, SQL_COLUMN_TYPE, SortEnum, UnionEnum } from './enum';
|
|
3
3
|
export declare enum FormulaTypeEnum {
|
|
4
4
|
CUSTOM = "custom",
|
|
5
5
|
FILTER = "filter",
|
|
@@ -210,6 +210,7 @@ export interface MetaData_ColumnsType {
|
|
|
210
210
|
}
|
|
211
211
|
export interface MetaData {
|
|
212
212
|
metaKey: number;
|
|
213
|
+
patchVersion?: string;
|
|
213
214
|
readonly?: boolean;
|
|
214
215
|
hidden?: boolean;
|
|
215
216
|
type: TypeEnum.data;
|
|
@@ -293,6 +294,10 @@ export interface MetaSummarize_Group {
|
|
|
293
294
|
datasourceId: string;
|
|
294
295
|
datasourceName: string;
|
|
295
296
|
atoms?: AtomsItem[];
|
|
297
|
+
delimiter?: string;
|
|
298
|
+
distinct?: boolean;
|
|
299
|
+
orderBy?: AtomsItem[];
|
|
300
|
+
orderDirection?: SortEnum;
|
|
296
301
|
summarizeType: MetaSummarize_Enum;
|
|
297
302
|
[params: string]: any;
|
|
298
303
|
}
|
|
@@ -347,6 +352,7 @@ export interface MetaPermissionTable {
|
|
|
347
352
|
export interface MetaUnion {
|
|
348
353
|
metaKey: number;
|
|
349
354
|
type: TypeEnum.union;
|
|
355
|
+
union: UnionEnum;
|
|
350
356
|
subquery: MetaListType[];
|
|
351
357
|
}
|
|
352
358
|
export interface LooseObject {
|
package/lib/es/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MetaListType, ToolbarType, FormulaTemplatesItem, ChangeType, FormulaTypeEnum, AtomsItem } from './store/types';
|
|
2
2
|
import { UnionEnum } from './store/enum';
|
|
3
|
-
import { DataType } from './components/dialog/select-
|
|
3
|
+
import { DataType } from './components/dialog/select-column-multiple';
|
|
4
4
|
export interface MetaListProps {
|
|
5
5
|
name: string;
|
|
6
6
|
type: 'group' | 'union';
|
|
@@ -26,6 +26,44 @@ export interface FormulaDiffCodeParams {
|
|
|
26
26
|
oldCode: AtomsItem[];
|
|
27
27
|
newCode: AtomsItem[];
|
|
28
28
|
}
|
|
29
|
+
export interface FormulaSqlParseParams {
|
|
30
|
+
sql: string;
|
|
31
|
+
availableTables: DataType[];
|
|
32
|
+
tableScope?: FormulaSqlTableScopeItem[];
|
|
33
|
+
metasContext?: MetaListType[];
|
|
34
|
+
constantList?: OptionItem[];
|
|
35
|
+
formulaTemplates?: FormulaTemplatesItem[];
|
|
36
|
+
operatorList?: any[];
|
|
37
|
+
otherTypes?: any[];
|
|
38
|
+
allowFormulaTableLookup?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface FormulaSqlParseResult {
|
|
41
|
+
content?: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
formulaList: AtomsItem[];
|
|
44
|
+
}
|
|
45
|
+
export interface FormulaSqlChatMessage {
|
|
46
|
+
role: 'user' | 'assistant';
|
|
47
|
+
content: string;
|
|
48
|
+
}
|
|
49
|
+
export interface FormulaSqlTableScopeItem {
|
|
50
|
+
datasourceId: string;
|
|
51
|
+
datasourceName?: string;
|
|
52
|
+
tableId: string;
|
|
53
|
+
tableName?: string;
|
|
54
|
+
tableNameZh?: string;
|
|
55
|
+
tableAlias?: string;
|
|
56
|
+
tableUuid?: string;
|
|
57
|
+
fixed?: boolean;
|
|
58
|
+
scopeKey?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface FormulaSqlStreamHandlers {
|
|
61
|
+
signal: AbortSignal;
|
|
62
|
+
onDelta: (delta: string) => void;
|
|
63
|
+
}
|
|
64
|
+
export interface FormulaSqlStreamParseParams extends FormulaSqlParseParams {
|
|
65
|
+
messages: FormulaSqlChatMessage[];
|
|
66
|
+
}
|
|
29
67
|
export interface MetabaseRightClickMenuItem {
|
|
30
68
|
label: React.ReactNode;
|
|
31
69
|
value: React.Key;
|
|
@@ -97,6 +135,8 @@ export interface MetabaseProps {
|
|
|
97
135
|
}>;
|
|
98
136
|
getFormulaSqlCode?: (value: AtomsItem[]) => Promise<FormulaSqlCodeResult> | FormulaSqlCodeResult;
|
|
99
137
|
getFormulaDiffCode?: (params: FormulaDiffCodeParams) => Promise<FormulaDiffCodeResult> | FormulaDiffCodeResult;
|
|
138
|
+
parseFormulaSql?: (params: FormulaSqlParseParams) => Promise<FormulaSqlParseResult> | FormulaSqlParseResult;
|
|
139
|
+
parseFormulaSqlStream?: (params: FormulaSqlStreamParseParams, handlers: FormulaSqlStreamHandlers) => Promise<FormulaSqlParseResult | undefined> | FormulaSqlParseResult | undefined;
|
|
100
140
|
getExistsError?: (params: MetaListType[]) => Promise<any[]>;
|
|
101
141
|
operatorList?: any[];
|
|
102
142
|
otherTypes?: any[];
|
package/lib/es/utils/helper.js
CHANGED
|
@@ -21,6 +21,15 @@ var getColumnIdNameParts = function getColumnIdNameParts() {
|
|
|
21
21
|
name: normalizeId(column.fieldName || column.name)
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
+
var getSummarizeOutputName = function getSummarizeOutputName() {
|
|
25
|
+
var column = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
26
|
+
return normalizeId(column.name || column.fieldName || column.fieldAlias);
|
|
27
|
+
};
|
|
28
|
+
var areSummarizeOutputColumns = function areSummarizeOutputColumns() {
|
|
29
|
+
var left = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
30
|
+
var right = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
31
|
+
return Boolean(left.summarizeType && right.summarizeType);
|
|
32
|
+
};
|
|
24
33
|
export var isSameTableByIdName = function isSameTableByIdName() {
|
|
25
34
|
var left = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
26
35
|
var right = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -100,6 +109,10 @@ export var isSameTableByIdFirst = function isSameTableByIdFirst() {
|
|
|
100
109
|
export var getColumnIdFirstKey = function getColumnIdFirstKey() {
|
|
101
110
|
var column = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
102
111
|
var tableKey = getTableIdFirstKey(column);
|
|
112
|
+
var summarizeOutputName = column.summarizeType ? getSummarizeOutputName(column) : '';
|
|
113
|
+
if (summarizeOutputName) {
|
|
114
|
+
return "".concat(tableKey, "|summarizeType:").concat(column.summarizeType, "|output:").concat(summarizeOutputName);
|
|
115
|
+
}
|
|
103
116
|
var fieldId = normalizeId(column.fieldId || column.id);
|
|
104
117
|
if (fieldId) return "".concat(tableKey, "|fieldId:").concat(fieldId);
|
|
105
118
|
var fieldUuid = normalizeId(column.fieldUuid);
|
|
@@ -126,6 +139,13 @@ export var isSameColumnByIdFirst = function isSameColumnByIdFirst() {
|
|
|
126
139
|
if (hasBoth(leftTableUuid, rightTableUuid) && leftTableUuid !== rightTableUuid) {
|
|
127
140
|
return false;
|
|
128
141
|
}
|
|
142
|
+
if (areSummarizeOutputColumns(left, right)) {
|
|
143
|
+
var leftOutputName = getSummarizeOutputName(left);
|
|
144
|
+
var rightOutputName = getSummarizeOutputName(right);
|
|
145
|
+
if (hasBoth(leftOutputName, rightOutputName)) {
|
|
146
|
+
return left.summarizeType === right.summarizeType && leftOutputName === rightOutputName;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
129
149
|
var leftFieldId = normalizeId(left.fieldId || left.id);
|
|
130
150
|
var rightFieldId = normalizeId(right.fieldId || right.id);
|
|
131
151
|
if (hasBoth(leftFieldId, rightFieldId)) {
|