@gingkoo/pandora-metabase 1.0.157-alpha.7 → 1.0.157-alpha.8

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.
Files changed (29) hide show
  1. package/lib/cjs/components/dialog/custom-editor/index.js +4 -3
  2. package/lib/cjs/components/dialog/formula-list/index.d.ts +2 -1
  3. package/lib/cjs/components/dialog/formula-list/index.js +984 -212
  4. package/lib/cjs/components/dialog/formula-list/index.less +322 -58
  5. package/lib/cjs/components/dialog/select-table/index.d.ts +4 -1
  6. package/lib/cjs/components/dialog/select-table/index.js +51 -7
  7. package/lib/cjs/components/dialog/select-table/index.less +20 -0
  8. package/lib/cjs/components/metabase/index.less +12 -14
  9. package/lib/cjs/components/modules/components/meta-icon.js +6 -4
  10. package/lib/cjs/index.d.ts +2 -2
  11. package/lib/cjs/locale/en.js +24 -0
  12. package/lib/cjs/locale/index.js +10 -6
  13. package/lib/cjs/locale/zh.js +24 -0
  14. package/lib/cjs/types.d.ts +31 -0
  15. package/lib/es/components/dialog/custom-editor/index.js +4 -3
  16. package/lib/es/components/dialog/formula-list/index.d.ts +2 -1
  17. package/lib/es/components/dialog/formula-list/index.js +986 -214
  18. package/lib/es/components/dialog/formula-list/index.less +322 -58
  19. package/lib/es/components/dialog/select-table/index.d.ts +4 -1
  20. package/lib/es/components/dialog/select-table/index.js +51 -7
  21. package/lib/es/components/dialog/select-table/index.less +20 -0
  22. package/lib/es/components/metabase/index.less +12 -14
  23. package/lib/es/components/modules/components/meta-icon.js +6 -4
  24. package/lib/es/index.d.ts +2 -2
  25. package/lib/es/locale/en.js +24 -0
  26. package/lib/es/locale/index.js +10 -6
  27. package/lib/es/locale/zh.js +24 -0
  28. package/lib/es/types.d.ts +31 -0
  29. package/package.json +1 -1
@@ -77,9 +77,10 @@ var metaIcon = function metaIcon(size, handleClick) {
77
77
  return handleClick(type);
78
78
  },
79
79
  children: (0, _jsxRuntime.jsxs)("div", {
80
- children: [info.icon, size === IconSIzeEnum.LARGE ? (0, _jsxRuntime.jsx)("div", {
80
+ children: [info.icon, (0, _jsxRuntime.jsx)("span", {
81
+ className: 'Sqb-button-label',
81
82
  children: info.name
82
- }) : '']
83
+ })]
83
84
  })
84
85
  })
85
86
  });
@@ -353,9 +354,10 @@ var NextDom = function NextDom(props) {
353
354
  handleClick(v);
354
355
  },
355
356
  children: (0, _jsxRuntime.jsxs)("div", {
356
- children: [info.icon, size === IconSIzeEnum.LARGE ? (0, _jsxRuntime.jsx)("div", {
357
+ children: [info.icon, (0, _jsxRuntime.jsx)("span", {
358
+ className: 'Sqb-button-label',
357
359
  children: info.name
358
- }) : '']
360
+ })]
359
361
  })
360
362
  })
361
363
  }, "".concat(String(v), "-").concat(idx));
@@ -1,9 +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, FormulaSqlParseParams, FormulaSqlParseResult } 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
6
  import { AtomsTypeEnum } from './store/types';
7
7
  declare const SqlVisionBuilder: React.ForwardRefExoticComponent<MetabaseProps & React.RefAttributes<SqlVisionBuilderRef>>;
8
8
  export default SqlVisionBuilder;
9
- export { MetabaseProps, DatasourceType, MetaListType, ToolbarType, SqlVisionBuilderRef, MetabaseRightClickMenuItem, MetabaseRightClickMenuClickParams, FormulaSqlParseParams, FormulaSqlParseResult, AtomsTypeEnum, };
9
+ export { MetabaseProps, DatasourceType, MetaListType, ToolbarType, SqlVisionBuilderRef, MetabaseRightClickMenuItem, MetabaseRightClickMenuClickParams, FormulaSqlParseParams, FormulaSqlParseResult, FormulaSqlChatMessage, FormulaSqlTableScopeItem, FormulaSqlStreamHandlers, FormulaSqlStreamParseParams, AtomsTypeEnum, };
@@ -43,6 +43,30 @@ var _default = exports["default"] = (0, _index.register)('en', {
43
43
  'customColumn.numberInput': 'Number input',
44
44
  'customColumn.addSql': 'Add SQL',
45
45
  'customColumn.parseSql': 'Parse with AI',
46
+ 'customColumn.sqlChatTitle': 'AI SQL Assistant',
47
+ 'customColumn.sqlChatDesc': 'Generate expression configuration in chat, then apply it here.',
48
+ 'customColumn.sqlChatEmpty': 'Paste SQL or continue with more context. AI will convert it into expression configuration.',
49
+ 'customColumn.sqlChatPlaceholder': 'Paste SQL, or continue refining the previous result...',
50
+ 'customColumn.sqlChatThinking': 'Parsing SQL...',
51
+ 'customColumn.sqlChatGeneratingConfig': 'Generating configuration...',
52
+ 'customColumn.sqlChatSuccess': 'Expression configuration is ready to apply.',
53
+ 'customColumn.sqlChatSuccessApplied': 'Expression configuration has been applied.',
54
+ 'customColumn.sqlChatCanceled': 'Canceled by user',
55
+ 'customColumn.sqlChatApply': 'Apply',
56
+ 'customColumn.sqlChatPreview': 'Preview',
57
+ 'customColumn.sqlChatPaste': 'Paste SQL',
58
+ 'customColumn.sqlChatSend': 'Send',
59
+ 'customColumn.sqlChatStop': 'Stop',
60
+ 'customColumn.sqlChatMe': 'Me',
61
+ 'customColumn.sqlChatClipboardEmpty': 'Clipboard does not contain SQL content',
62
+ 'customColumn.sqlChatPasteFailed': 'Unable to read clipboard. Paste directly into the input box.',
63
+ 'customColumn.sqlChatMissingParser': 'SQL parser is not configured for this component',
64
+ 'customColumn.sqlChatTableScope': 'Table scope',
65
+ 'customColumn.sqlChatAddTable': 'Add table',
66
+ 'customColumn.sqlChatPickDatasource': 'Select datasource',
67
+ 'customColumn.sqlChatLoadingTables': 'Loading tables...',
68
+ 'customColumn.sqlChatNoTables': 'No tables available',
69
+ 'customColumn.sqlChatScopeFallback': 'When no table is selected, the current expression context is used.',
46
70
  'customColumn.sqlParseInvalid': 'AI returned an invalid custom column configuration',
47
71
  'customColumn.sqlParseFailed': 'Failed to parse SQL. Please try again',
48
72
  'customColumn.formula': 'Formula',
@@ -6,7 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.register = exports.isEn = exports.__ = void 0;
7
7
  var _cookies = require("../utils/cookies");
8
8
  var locales = {};
9
- var activeLocale = (0, _cookies.getCookie)('LOCALE') || 'zh';
9
+ var normalizeLocale = function normalizeLocale(locale) {
10
+ var normalized = (locale || 'zh').toLowerCase().replace('_', '-');
11
+ if (normalized.startsWith('en')) return 'en';
12
+ return 'zh';
13
+ };
14
+ var activeLocale = normalizeLocale((0, _cookies.getCookie)('LOCALE'));
10
15
  var isEn = exports.isEn = activeLocale === 'en';
11
16
  var register = exports.register = function register(name, data) {
12
17
  if (name in locales) {} else {
@@ -14,9 +19,8 @@ var register = exports.register = function register(name, data) {
14
19
  }
15
20
  };
16
21
  var __ = exports.__ = function __(name) {
17
- if (activeLocale in locales) {
18
- return locales[activeLocale][name] || '';
19
- } else {
20
- return '';
21
- }
22
+ var _locales$activeLocale, _locales$zh, _locales$en;
23
+ 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]);
24
+ if (!message) {}
25
+ return message || name;
22
26
  };
@@ -88,6 +88,30 @@ var _default = exports["default"] = (0, _index.register)('zh', {
88
88
  'customColumn.numberInput': '数字输入框',
89
89
  'customColumn.addSql': '添加 SQL',
90
90
  'customColumn.parseSql': 'AI 解析',
91
+ 'customColumn.sqlChatTitle': 'AI SQL 助手',
92
+ 'customColumn.sqlChatDesc': '对话生成表达式配置,采纳后写入当前公式区域。',
93
+ 'customColumn.sqlChatEmpty': '粘贴 SQL 或继续补充说明,AI 会转换成当前表达式配置。',
94
+ 'customColumn.sqlChatPlaceholder': '粘贴 SQL,或继续补充上一轮解析说明...',
95
+ 'customColumn.sqlChatThinking': '正在解析 SQL...',
96
+ 'customColumn.sqlChatGeneratingConfig': '正在生成配置...',
97
+ 'customColumn.sqlChatSuccess': '已生成表达式配置,可采纳到当前区域。',
98
+ 'customColumn.sqlChatSuccessApplied': '已生成并写入当前表达式配置。',
99
+ 'customColumn.sqlChatCanceled': '用户已取消',
100
+ 'customColumn.sqlChatApply': '应用',
101
+ 'customColumn.sqlChatPreview': '预览',
102
+ 'customColumn.sqlChatPaste': '粘贴 SQL',
103
+ 'customColumn.sqlChatSend': '发送',
104
+ 'customColumn.sqlChatStop': '停止',
105
+ 'customColumn.sqlChatMe': '我',
106
+ 'customColumn.sqlChatClipboardEmpty': '剪贴板没有可用的 SQL 内容',
107
+ 'customColumn.sqlChatPasteFailed': '无法读取剪贴板,请直接在输入框粘贴',
108
+ 'customColumn.sqlChatMissingParser': '当前组件未配置 SQL 解析方法',
109
+ 'customColumn.sqlChatTableScope': '表范围',
110
+ 'customColumn.sqlChatAddTable': '添加表',
111
+ 'customColumn.sqlChatPickDatasource': '选择数据源',
112
+ 'customColumn.sqlChatLoadingTables': '正在加载表...',
113
+ 'customColumn.sqlChatNoTables': '暂无可选表',
114
+ 'customColumn.sqlChatScopeFallback': '未选择表时,将使用当前表达式已有上下文。',
91
115
  'customColumn.sqlParseInvalid': 'AI 返回的自定义列结构无效',
92
116
  'customColumn.sqlParseFailed': 'SQL 解析失败,请重试',
93
117
  'filter.addFilter': '添加过滤器',
@@ -29,11 +29,41 @@ export interface FormulaDiffCodeParams {
29
29
  export interface FormulaSqlParseParams {
30
30
  sql: string;
31
31
  availableTables: DataType[];
32
+ tableScope?: FormulaSqlTableScopeItem[];
33
+ metasContext?: MetaListType[];
34
+ constantList?: OptionItem[];
35
+ formulaTemplates?: FormulaTemplatesItem[];
36
+ operatorList?: any[];
37
+ otherTypes?: any[];
38
+ allowFormulaTableLookup?: boolean;
32
39
  }
33
40
  export interface FormulaSqlParseResult {
41
+ content?: string;
34
42
  name?: string;
35
43
  formulaList: AtomsItem[];
36
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
+ }
37
67
  export interface MetabaseRightClickMenuItem {
38
68
  label: React.ReactNode;
39
69
  value: React.Key;
@@ -106,6 +136,7 @@ export interface MetabaseProps {
106
136
  getFormulaSqlCode?: (value: AtomsItem[]) => Promise<FormulaSqlCodeResult> | FormulaSqlCodeResult;
107
137
  getFormulaDiffCode?: (params: FormulaDiffCodeParams) => Promise<FormulaDiffCodeResult> | FormulaDiffCodeResult;
108
138
  parseFormulaSql?: (params: FormulaSqlParseParams) => Promise<FormulaSqlParseResult> | FormulaSqlParseResult;
139
+ parseFormulaSqlStream?: (params: FormulaSqlStreamParseParams, handlers: FormulaSqlStreamHandlers) => Promise<FormulaSqlParseResult | undefined> | FormulaSqlParseResult | undefined;
109
140
  getExistsError?: (params: MetaListType[]) => Promise<any[]>;
110
141
  operatorList?: any[];
111
142
  otherTypes?: any[];
@@ -59,7 +59,7 @@ var CaseEditor = function CaseEditor(props) {
59
59
  };
60
60
  var parseFormulaSql = (_store$preProps = store.preProps) === null || _store$preProps === void 0 ? void 0 : _store$preProps.parseFormulaSql;
61
61
  var handleParseSql = function () {
62
- var _ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(sql) {
62
+ var _ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(sql, availableTables, tableScope) {
63
63
  var normalizedSql, result, _t;
64
64
  return _regeneratorRuntime.wrap(function (_context) {
65
65
  while (1) switch (_context.prev = _context.next) {
@@ -75,7 +75,8 @@ var CaseEditor = function CaseEditor(props) {
75
75
  _context.next = 2;
76
76
  return parseFormulaSql({
77
77
  sql: normalizedSql,
78
- availableTables: data
78
+ availableTables: availableTables !== null && availableTables !== void 0 && availableTables.length ? availableTables : data,
79
+ tableScope: tableScope
79
80
  });
80
81
  case 2:
81
82
  result = _context.sent;
@@ -103,7 +104,7 @@ var CaseEditor = function CaseEditor(props) {
103
104
  }
104
105
  }, _callee, null, [[1, 4]]);
105
106
  }));
106
- return function handleParseSql(_x) {
107
+ return function handleParseSql(_x, _x2, _x3) {
107
108
  return _ref.apply(this, arguments);
108
109
  };
109
110
  }();
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import './index.less';
3
3
  import { AtomsItem } from '../../../store/types';
4
+ import type { FormulaSqlTableScopeItem } from '../../../types';
4
5
  interface PropsType {
5
6
  customTypes?: any[];
6
7
  otherTypes?: any[];
@@ -17,7 +18,7 @@ interface PropsType {
17
18
  enableCopy?: boolean;
18
19
  enableZoom?: boolean;
19
20
  parentPopupChannel?: 'primary' | 'secondary';
20
- onAddSql?: (sql: string) => Promise<void | (() => void)> | void | (() => void);
21
+ onAddSql?: (sql: string, availableTables?: any[], tableScope?: FormulaSqlTableScopeItem[]) => Promise<void | (() => void)> | void | (() => void);
21
22
  }
22
23
  declare const FormulaList: React.ForwardRefExoticComponent<PropsType & React.RefAttributes<unknown>>;
23
24
  export default FormulaList;