@gingkoo/pandora-metabase 1.0.158-alpha.13 → 1.0.158-alpha.15

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 (33) hide show
  1. package/lib/cjs/components/dialog/formula-list/index.js +1 -0
  2. package/lib/cjs/components/dialog/formula-list/utils.d.ts +5 -1
  3. package/lib/cjs/components/dialog/formula-list/utils.js +130 -119
  4. package/lib/cjs/components/metabase/index.js +54 -55
  5. package/lib/cjs/components/modules/join-data.js +2 -0
  6. package/lib/cjs/components/modules/table-data.js +2 -0
  7. package/lib/cjs/components/sql-syntax-confirm.d.ts +1 -1
  8. package/lib/cjs/components/sql-syntax-confirm.js +12 -6
  9. package/lib/cjs/hooks/use-state.js +50 -17
  10. package/lib/cjs/index.js +1 -3
  11. package/lib/cjs/locale/en.js +2 -0
  12. package/lib/cjs/locale/zh.js +2 -0
  13. package/lib/cjs/utils/transformSql.d.ts +2 -0
  14. package/lib/cjs/utils/transformSql.js +75 -30
  15. package/lib/es/components/dialog/formula-list/index.js +1 -0
  16. package/lib/es/components/dialog/formula-list/utils.d.ts +5 -1
  17. package/lib/es/components/dialog/formula-list/utils.js +130 -119
  18. package/lib/es/components/metabase/index.js +54 -55
  19. package/lib/es/components/modules/join-data.js +2 -0
  20. package/lib/es/components/modules/table-data.js +2 -0
  21. package/lib/es/components/sql-syntax-confirm.d.ts +1 -1
  22. package/lib/es/components/sql-syntax-confirm.js +12 -6
  23. package/lib/es/hooks/use-state.js +50 -17
  24. package/lib/es/index.js +1 -3
  25. package/lib/es/locale/en.js +2 -0
  26. package/lib/es/locale/zh.js +2 -0
  27. package/lib/es/utils/transformSql.d.ts +2 -0
  28. package/lib/es/utils/transformSql.js +75 -30
  29. package/package.json +2 -1
  30. package/lib/cjs/components/dialog/diff-viewer/index copy.d.ts +0 -10
  31. package/lib/cjs/components/dialog/diff-viewer/index copy.js +0 -139
  32. package/lib/es/components/dialog/diff-viewer/index copy.d.ts +0 -10
  33. package/lib/es/components/dialog/diff-viewer/index copy.js +0 -132
@@ -2778,6 +2778,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
2778
2778
  notExistsColumns: exitData,
2779
2779
  fieldEnableAlias: false,
2780
2780
  toolbar: _toolbar,
2781
+ subToolbar: subToolbar,
2781
2782
  btnText: (0, _locale.__)('SqlQueryBuilder.confirm'),
2782
2783
  value: (0, _cloneDeep["default"])(_value),
2783
2784
  onOk: function onOk(newList) {
@@ -24,7 +24,7 @@ export declare const customTypes: ({
24
24
  })[];
25
25
  export declare const getTemplateItem: (type: AtomsTypeEnum, item?: any) => AtomsItem;
26
26
  export declare const isOk: (rhsVal: AtomsItem[], allowEmptyInputString?: boolean) => boolean;
27
- export declare function validateExpressionIntegrity(list: AtomsItem[]): {
27
+ type ExpressionIntegrityResult = {
28
28
  isError: boolean;
29
29
  error?: string;
30
30
  code?: 'parentheses' | 'case' | 'window' | 'duplicate-logical-operator' | 'and-or';
@@ -32,5 +32,9 @@ export declare function validateExpressionIntegrity(list: AtomsItem[]): {
32
32
  isCase?: boolean;
33
33
  isOver?: boolean;
34
34
  };
35
+ type ValidateExpressionOptions = {
36
+ skipListLevelChecks?: boolean;
37
+ };
38
+ export declare function validateExpressionIntegrity(list: AtomsItem[], options?: ValidateExpressionOptions): ExpressionIntegrityResult;
35
39
  export declare const getConstantLabel: (list: any[], val: string, defaultVal?: string) => any;
36
40
  export {};
@@ -652,6 +652,123 @@ function validateAndOrStructure(item) {
652
652
  }
653
653
  return true;
654
654
  }
655
+ var createLogicalOperatorAtom = function createLogicalOperatorAtom(operator) {
656
+ return {
657
+ type: _types.AtomsTypeEnum.OPERATOR,
658
+ val: operator
659
+ };
660
+ };
661
+ function flattenAndOrSequence(item) {
662
+ if (Array.isArray(item.items) && item.items.length > 0) {
663
+ return item.items.reduce(function (acc, logicItem, index) {
664
+ if (index > 0 && logicItem !== null && logicItem !== void 0 && logicItem.operator) {
665
+ acc.push(createLogicalOperatorAtom(logicItem.operator));
666
+ }
667
+ acc.push.apply(acc, (0, _toConsumableArray2["default"])((logicItem === null || logicItem === void 0 ? void 0 : logicItem.atoms) || []));
668
+ return acc;
669
+ }, []);
670
+ }
671
+ var legacyItem = item;
672
+ var hasBinarySides = Array.isArray(legacyItem.leftAtoms) || Array.isArray(legacyItem.rightAtoms);
673
+ if (hasBinarySides) {
674
+ var flattened = (0, _toConsumableArray2["default"])(legacyItem.leftAtoms || []);
675
+ if (legacyItem.operator) {
676
+ flattened.push(createLogicalOperatorAtom(legacyItem.operator));
677
+ }
678
+ flattened.push.apply(flattened, (0, _toConsumableArray2["default"])(legacyItem.rightAtoms || []));
679
+ return flattened;
680
+ }
681
+ return legacyItem.atoms || [];
682
+ }
683
+ function validateListLevelIntegrity(list) {
684
+ var cleanList = list.filter(function (item) {
685
+ return !(item.type === _types.AtomsTypeEnum.UNKNOWN && item.val === '');
686
+ });
687
+ if (!validateParentheses(cleanList)) {
688
+ return {
689
+ isError: true,
690
+ error: '括号不匹配',
691
+ code: 'parentheses',
692
+ isBracket: true
693
+ };
694
+ }
695
+ if (!validateCaseStructure(cleanList)) {
696
+ return {
697
+ isError: true,
698
+ error: 'CASE 语句不完整(缺少 END 或 WHEN/THEN)',
699
+ code: 'case',
700
+ isCase: true
701
+ };
702
+ }
703
+ if (!validateCaseKeywordScope(cleanList)) {
704
+ return {
705
+ isError: true,
706
+ error: 'WHEN、THEN、ELSE、END 只能出现在 CASE 结构中',
707
+ code: 'case',
708
+ isCase: true
709
+ };
710
+ }
711
+ if (!validateWindowFunction(cleanList)) {
712
+ return {
713
+ isError: true,
714
+ error: '窗口函数结构不完整(缺少 OVER 或括号)',
715
+ code: 'window',
716
+ isOver: true
717
+ };
718
+ }
719
+ if (!validateDuplicateLogicalOperator(cleanList)) {
720
+ return {
721
+ isError: true,
722
+ error: '逻辑操作符重复(例如 AND AND 或 OR OR)',
723
+ code: 'duplicate-logical-operator'
724
+ };
725
+ }
726
+ return {
727
+ isError: false
728
+ };
729
+ }
730
+ function validateAndOrItem(item) {
731
+ if (!validateAndOrStructure(item)) {
732
+ return {
733
+ isError: true,
734
+ error: 'AND / OR 结构不完整',
735
+ code: 'and-or'
736
+ };
737
+ }
738
+ var nestedOptions = {
739
+ skipListLevelChecks: true
740
+ };
741
+ if (Array.isArray(item.items) && item.items.length > 0) {
742
+ for (var index = 0; index < item.items.length; index++) {
743
+ var logicItem = item.items[index];
744
+ if (index > 0 && !isLogicalOperator(logicItem === null || logicItem === void 0 ? void 0 : logicItem.operator)) {
745
+ return {
746
+ isError: true,
747
+ error: 'AND / OR 结构缺少操作符',
748
+ code: 'and-or'
749
+ };
750
+ }
751
+ var nestedError = validateExpressionIntegrity((logicItem === null || logicItem === void 0 ? void 0 : logicItem.atoms) || [], nestedOptions);
752
+ if (nestedError.isError) return nestedError;
753
+ }
754
+ } else {
755
+ var legacyItem = item;
756
+ if (!legacyItem.operator) {
757
+ return {
758
+ isError: true,
759
+ error: 'AND / OR 结构缺少操作符',
760
+ code: 'and-or'
761
+ };
762
+ }
763
+ var nestedLists = Array.isArray(legacyItem.leftAtoms) || Array.isArray(legacyItem.rightAtoms) ? [legacyItem.leftAtoms || [], legacyItem.rightAtoms || []] : [legacyItem.atoms || []];
764
+ for (var _i = 0, _nestedLists = nestedLists; _i < _nestedLists.length; _i++) {
765
+ var nestedList = _nestedLists[_i];
766
+ var _nestedError = validateExpressionIntegrity(nestedList, nestedOptions);
767
+ if (_nestedError.isError) return _nestedError;
768
+ }
769
+ }
770
+ return validateListLevelIntegrity(flattenAndOrSequence(item));
771
+ }
655
772
  function validateNoTrailingOperator(list) {
656
773
  for (var i = list.length - 1; i >= 0; i--) {
657
774
  var item = list[i];
@@ -667,6 +784,7 @@ function validateNoTrailingOperator(list) {
667
784
  return true;
668
785
  }
669
786
  function validateExpressionIntegrity(list) {
787
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
670
788
  if (!Array.isArray(list)) {
671
789
  return {
672
790
  isError: false
@@ -692,77 +810,9 @@ function validateExpressionIntegrity(list) {
692
810
  if (rhsError.isError) return rhsError;
693
811
  }
694
812
  if (item.type === _types.AtomsTypeEnum.AND_OR) {
695
- if (Array.isArray(item.items) && item.items.length > 0) {
696
- var _iterator5 = (0, _createForOfIteratorHelper2["default"])(item.items),
697
- _step5;
698
- try {
699
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
700
- var logicItem = _step5.value;
701
- var _nestedError = validateExpressionIntegrity((logicItem === null || logicItem === void 0 ? void 0 : logicItem.atoms) || []);
702
- if (_nestedError.isError) return _nestedError;
703
- }
704
- } catch (err) {
705
- _iterator5.e(err);
706
- } finally {
707
- _iterator5.f();
708
- }
709
- } else {
710
- var _legacyItem = item;
711
- var nestedLists = Array.isArray(_legacyItem.leftAtoms) || Array.isArray(_legacyItem.rightAtoms) ? [_legacyItem.leftAtoms || [], _legacyItem.rightAtoms || []] : [_legacyItem.atoms || []];
712
- for (var _i = 0, _nestedLists = nestedLists; _i < _nestedLists.length; _i++) {
713
- var nestedList = _nestedLists[_i];
714
- var _nestedError2 = validateExpressionIntegrity(nestedList);
715
- if (_nestedError2.isError) return _nestedError2;
716
- }
717
- }
718
- if (!validateAndOrStructure(item)) {
719
- return {
720
- isError: true,
721
- error: 'AND / OR 结构不完整',
722
- code: 'and-or'
723
- };
724
- }
725
- if (Array.isArray(item.items) && item.items.length > 0) {
726
- for (var index = 0; index < item.items.length; index++) {
727
- var _logicItem = item.items[index];
728
- if (index > 0 && !isLogicalOperator(_logicItem.operator)) {
729
- return {
730
- isError: true,
731
- error: 'AND / OR 结构缺少操作符',
732
- code: 'and-or'
733
- };
734
- }
735
- var _nestedError3 = validateExpressionIntegrity(_logicItem.atoms || []);
736
- if (_nestedError3.isError) {
737
- return _nestedError3;
738
- }
739
- }
740
- continue;
741
- }
742
- var legacyItem = item;
743
- if (!legacyItem.operator) {
744
- return {
745
- isError: true,
746
- error: 'AND / OR 结构缺少操作符',
747
- code: 'and-or'
748
- };
749
- }
750
- var hasBinarySides = Array.isArray(legacyItem.leftAtoms) || Array.isArray(legacyItem.rightAtoms);
751
- if (hasBinarySides) {
752
- var leftError = validateExpressionIntegrity(legacyItem.leftAtoms || []);
753
- if (leftError.isError) {
754
- return leftError;
755
- }
756
- var rightError = validateExpressionIntegrity(legacyItem.rightAtoms || []);
757
- if (rightError.isError) {
758
- return rightError;
759
- }
760
- continue;
761
- }
762
- var nestedError = validateExpressionIntegrity(legacyItem.atoms || []);
763
- if (nestedError.isError) {
764
- return nestedError;
765
- }
813
+ var andOrError = validateAndOrItem(item);
814
+ if (andOrError.isError) return andOrError;
815
+ continue;
766
816
  }
767
817
  if (item.type === _types.AtomsTypeEnum.CASE_WHEN) {
768
818
  var whenClauses = item.whenClauses || [];
@@ -778,11 +828,11 @@ function validateExpressionIntegrity(list) {
778
828
  if (caseAtomsError.isError) {
779
829
  return caseAtomsError;
780
830
  }
781
- var _iterator6 = (0, _createForOfIteratorHelper2["default"])(whenClauses),
782
- _step6;
831
+ var _iterator5 = (0, _createForOfIteratorHelper2["default"])(whenClauses),
832
+ _step5;
783
833
  try {
784
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
785
- var branch = _step6.value;
834
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
835
+ var branch = _step5.value;
786
836
  var whenError = validateExpressionIntegrity(branch.whenAtoms || []);
787
837
  if (whenError.isError) {
788
838
  return whenError;
@@ -793,9 +843,9 @@ function validateExpressionIntegrity(list) {
793
843
  }
794
844
  }
795
845
  } catch (err) {
796
- _iterator6.e(err);
846
+ _iterator5.e(err);
797
847
  } finally {
798
- _iterator6.f();
848
+ _iterator5.f();
799
849
  }
800
850
  var elseError = validateExpressionIntegrity(item.elseAtoms || []);
801
851
  if (elseError.isError) {
@@ -808,51 +858,12 @@ function validateExpressionIntegrity(list) {
808
858
  } finally {
809
859
  _iterator4.f();
810
860
  }
811
- var cleanList = list.filter(function (item) {
812
- return !(item.type === _types.AtomsTypeEnum.UNKNOWN && item.val === '');
813
- });
814
- if (!validateParentheses(cleanList)) {
815
- return {
816
- isError: true,
817
- error: '括号不匹配',
818
- code: 'parentheses',
819
- isBracket: true
820
- };
821
- }
822
- if (!validateCaseStructure(cleanList)) {
823
- return {
824
- isError: true,
825
- error: 'CASE 语句不完整(缺少 END 或 WHEN/THEN)',
826
- code: 'case',
827
- isCase: true
828
- };
829
- }
830
- if (!validateCaseKeywordScope(cleanList)) {
831
- return {
832
- isError: true,
833
- error: 'WHEN、THEN、ELSE、END 只能出现在 CASE 结构中',
834
- code: 'case',
835
- isCase: true
836
- };
837
- }
838
- if (!validateWindowFunction(cleanList)) {
861
+ if (options.skipListLevelChecks) {
839
862
  return {
840
- isError: true,
841
- error: '窗口函数结构不完整(缺少 OVER 或括号)',
842
- code: 'window',
843
- isOver: true
844
- };
845
- }
846
- if (!validateDuplicateLogicalOperator(cleanList)) {
847
- return {
848
- isError: true,
849
- error: '逻辑操作符重复(例如 AND AND 或 OR OR)',
850
- code: 'duplicate-logical-operator'
863
+ isError: false
851
864
  };
852
865
  }
853
- return {
854
- isError: false
855
- };
866
+ return validateListLevelIntegrity(list);
856
867
  }
857
868
  var getConstantLabel = exports.getConstantLabel = function getConstantLabel(list, val, defaultVal) {
858
869
  var _list$filter;
@@ -126,64 +126,63 @@ var Metabase = function Metabase(props) {
126
126
  return;
127
127
  }
128
128
  }
129
- var doms = store.popupContainer.current.querySelectorAll('.isError');
130
- var isSqlError = store.popupContainer.current.querySelectorAll('.isSqlError');
131
- var checkDomIssues = function checkDomIssues() {
132
- if (doms.length) {
133
- _pandora.Modal.confirm({
134
- title: (0, _locale.__)('metabase.prompt'),
135
- content: (0, _locale.__)('metabase.validationFailed'),
136
- onOk: function () {
137
- var _onOk = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee() {
138
- return _regenerator["default"].wrap(function (_context) {
139
- while (1) switch (_context.prev = _context.next) {
140
- case 0:
141
- _context.next = 1;
142
- return onSave();
143
- case 1:
144
- case "end":
145
- return _context.stop();
146
- }
147
- }, _callee);
148
- }));
149
- function onOk() {
150
- return _onOk.apply(this, arguments);
151
- }
152
- return onOk;
153
- }()
154
- });
155
- return;
156
- }
157
- onSave();
158
- };
159
- var checkFormulaIssues = function checkFormulaIssues() {
160
- if (isSqlError.length) {
161
- _pandora.Modal.confirm({
162
- title: (0, _locale.__)('metabase.prompt'),
163
- content: (0, _locale.__)('metabase.validationFormulaSave'),
164
- onOk: checkDomIssues
165
- });
166
- return;
167
- }
168
- checkDomIssues();
169
- };
170
- if (sqlValidationEnabled) {
171
- var sqlMetaList = (0, _utils.normalizeLegacySummarizeForSave)((0, _utils.splitByUnion)(store.metaList));
172
- var sqlValidation = (0, _transformSql.validateMetabaseConfig)(sqlMetaList, sqlDialect, {
173
- queryKind: sqlValidationQueryKind
129
+ var container = store.popupContainer.current;
130
+ var doms = container ? container.querySelectorAll('.isError') : [];
131
+ var isSqlError = container ? container.querySelectorAll('.isSqlError') : [];
132
+ var extraMessages = [];
133
+ if (isSqlError.length) extraMessages.push((0, _locale.__)('metabase.sqlErrorFormula'));
134
+ if (doms.length) extraMessages.push((0, _locale.__)('metabase.sqlErrorUi'));
135
+ var sqlIssues = sqlValidationEnabled ? (0, _transformSql.validateMetabaseConfig)((0, _utils.normalizeLegacySummarizeForSave)((0, _utils.splitByUnion)(store.metaList)), sqlDialect, {
136
+ queryKind: sqlValidationQueryKind
137
+ }).issues : [];
138
+ var confirmSave = function () {
139
+ var _ref = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee() {
140
+ return _regenerator["default"].wrap(function (_context) {
141
+ while (1) switch (_context.prev = _context.next) {
142
+ case 0:
143
+ _context.next = 1;
144
+ return onSave();
145
+ case 1:
146
+ case "end":
147
+ return _context.stop();
148
+ }
149
+ }, _callee);
150
+ }));
151
+ return function confirmSave() {
152
+ return _ref.apply(this, arguments);
153
+ };
154
+ }();
155
+ if (sqlIssues.length) {
156
+ var hasConfigIssue = sqlIssues.some(function (issue) {
157
+ return issue.severity === 'error';
174
158
  });
175
- if (sqlValidation.issues.length) {
176
- var hasConfigIssue = sqlValidation.issues.some(function (issue) {
177
- return issue.severity === 'error';
178
- });
179
- (0, _sqlSyntaxConfirm.confirmSyntaxIssues)(sqlValidation.issues, checkFormulaIssues, hasConfigIssue ? 'metabase.validationConfigSave' : 'metabase.validationSqlSave');
180
- return;
181
- }
159
+ (0, _sqlSyntaxConfirm.confirmSyntaxIssues)(sqlIssues, confirmSave, hasConfigIssue ? 'metabase.validationConfigSave' : 'metabase.validationSqlSave', extraMessages);
160
+ return;
161
+ }
162
+ if (extraMessages.length > 1) {
163
+ (0, _sqlSyntaxConfirm.confirmSyntaxIssues)([], confirmSave, 'metabase.validationConfigSave', extraMessages);
164
+ return;
165
+ }
166
+ if (isSqlError.length) {
167
+ _pandora.Modal.confirm({
168
+ title: (0, _locale.__)('metabase.prompt'),
169
+ content: (0, _locale.__)('metabase.validationFormulaSave'),
170
+ onOk: confirmSave
171
+ });
172
+ return;
173
+ }
174
+ if (doms.length) {
175
+ _pandora.Modal.confirm({
176
+ title: (0, _locale.__)('metabase.prompt'),
177
+ content: (0, _locale.__)('metabase.validationFailed'),
178
+ onOk: confirmSave
179
+ });
180
+ return;
182
181
  }
183
- checkFormulaIssues();
182
+ confirmSave();
184
183
  };
185
184
  var onSave = function () {
186
- var _ref = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2() {
185
+ var _ref2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2() {
187
186
  var intercept, _metaList;
188
187
  return _regenerator["default"].wrap(function (_context2) {
189
188
  while (1) switch (_context2.prev = _context2.next) {
@@ -224,7 +223,7 @@ var Metabase = function Metabase(props) {
224
223
  }, _callee2);
225
224
  }));
226
225
  return function onSave() {
227
- return _ref.apply(this, arguments);
226
+ return _ref2.apply(this, arguments);
228
227
  };
229
228
  }();
230
229
  (0, _react.useEffect)(function () {
@@ -1038,6 +1038,8 @@ var JoinData = function JoinData(props) {
1038
1038
  isExit: isExit,
1039
1039
  isSubquery: true,
1040
1040
  toolbar: _toolbar,
1041
+ subToolbar: subToolbar,
1042
+ sqlValidationQueryKind: 'query',
1041
1043
  btnText: (0, _locale.__)('SqlQueryBuilder.confirm'),
1042
1044
  value: (0, _cloneDeep["default"])(val),
1043
1045
  onOk: function onOk(newList) {
@@ -226,6 +226,8 @@ var TableData = function TableData(props) {
226
226
  isExit: isExit,
227
227
  isSubquery: true,
228
228
  toolbar: _toolbar,
229
+ subToolbar: subToolbar,
230
+ sqlValidationQueryKind: 'query',
229
231
  btnText: (0, _locale.__)('SqlQueryBuilder.confirm'),
230
232
  value: (0, _cloneDeep["default"])(val),
231
233
  onOk: function onOk(newList) {
@@ -1,5 +1,5 @@
1
1
  import { SqlValidationIssue } from '../utils/transformSql';
2
- export declare const confirmSyntaxIssues: (issues: SqlValidationIssue[] | undefined, onOk: () => void | Promise<void>, descriptionKey?: string) => void | Promise<void>;
2
+ export declare const confirmSyntaxIssues: (issues: SqlValidationIssue[] | undefined, onOk: () => void | Promise<void>, descriptionKey?: string, extraMessages?: string[]) => void | Promise<void>;
3
3
  export declare const toSyntaxIssues: (result?: {
4
4
  isError?: boolean;
5
5
  issues?: SqlValidationIssue[];
@@ -32,15 +32,16 @@ var getIssuePath = function getIssuePath(issue) {
32
32
  }).join(' > ');
33
33
  };
34
34
  var renderIssues = function renderIssues(issues, descriptionKey) {
35
+ var extraMessages = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
35
36
  return (0, _jsxRuntime.jsxs)("div", {
36
37
  children: [(0, _jsxRuntime.jsx)("div", {
37
38
  children: (0, _locale.__)(descriptionKey)
38
- }), (0, _jsxRuntime.jsx)("ul", {
39
+ }), issues.length || extraMessages.length ? (0, _jsxRuntime.jsxs)("ul", {
39
40
  style: {
40
41
  margin: '8px 0 0',
41
42
  paddingLeft: 20
42
43
  },
43
- children: issues.map(function (issue) {
44
+ children: [issues.map(function (issue) {
44
45
  var issuePath = getIssuePath(issue);
45
46
  var key = "".concat(issue.code, "-").concat((issue.path || []).map(function (item) {
46
47
  var _item$metaKey, _item$index;
@@ -49,20 +50,25 @@ var renderIssues = function renderIssues(issues, descriptionKey) {
49
50
  return (0, _jsxRuntime.jsxs)("li", {
50
51
  children: [issuePath ? "".concat(issuePath, "\uFF1A") : '', getIssueMessage(issue.code)]
51
52
  }, key);
52
- })
53
- })]
53
+ }), extraMessages.map(function (message, index) {
54
+ return (0, _jsxRuntime.jsx)("li", {
55
+ children: message
56
+ }, "extra-".concat(index));
57
+ })]
58
+ }) : null]
54
59
  });
55
60
  };
56
61
  var confirmSyntaxIssues = exports.confirmSyntaxIssues = function confirmSyntaxIssues() {
57
62
  var issues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
58
63
  var onOk = arguments.length > 1 ? arguments[1] : undefined;
59
64
  var descriptionKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'metabase.validationSqlSave';
60
- if (!issues.length) {
65
+ var extraMessages = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
66
+ if (!issues.length && !extraMessages.length) {
61
67
  return onOk();
62
68
  }
63
69
  _pandora.Modal.confirm({
64
70
  title: (0, _locale.__)('metabase.prompt'),
65
- content: renderIssues(issues, descriptionKey),
71
+ content: renderIssues(issues, descriptionKey, extraMessages),
66
72
  onOk: onOk
67
73
  });
68
74
  };
@@ -506,15 +506,21 @@ var useStore = function useStore() {
506
506
  }
507
507
  return _context7.abrupt("return", tables);
508
508
  case 1:
509
- _context7.next = 2;
509
+ if (!(typeof fetchDatasetFn.current !== 'function')) {
510
+ _context7.next = 2;
511
+ break;
512
+ }
513
+ return _context7.abrupt("return", []);
514
+ case 2:
515
+ _context7.next = 3;
510
516
  return fetchDatasetFn.current(datasourceId, {
511
517
  isExit: isExit
512
518
  });
513
- case 2:
519
+ case 3:
514
520
  _tables = _context7.sent;
515
521
  setDataset(datasourceId, _tables);
516
522
  return _context7.abrupt("return", _tables);
517
- case 3:
523
+ case 4:
518
524
  case "end":
519
525
  return _context7.stop();
520
526
  }
@@ -550,19 +556,26 @@ var useStore = function useStore() {
550
556
  _isExit = _args8.length > 5 && _args8[5] !== undefined ? _args8[5] : isExit;
551
557
  _table$alias = table.alias, alias = _table$alias === void 0 ? '' : _table$alias, datasourceName = table.datasourceName, did = table.datasourceId, column = table.column, extra = (0, _objectWithoutProperties2["default"])(table, _excluded);
552
558
  tableName = table.name;
553
- columns = getColumns(tableName);
559
+ columns = getColumns(tableName, datasourceId, _isExit);
554
560
  if (columns.length) {
555
- _context8.next = 2;
561
+ _context8.next = 3;
556
562
  break;
557
563
  }
558
- _context8.next = 1;
564
+ if (!(typeof fetchColumnsFn.current !== 'function')) {
565
+ _context8.next = 1;
566
+ break;
567
+ }
568
+ typeof callback === 'function' && callback(oldColumns);
569
+ return _context8.abrupt("return", oldColumns);
570
+ case 1:
571
+ _context8.next = 2;
559
572
  return fetchColumnsFn.current(extra, datasourceId, {
560
573
  isExit: _isExit
561
574
  });
562
- case 1:
563
- columns = _context8.sent;
564
- setColumns(tableName, columns);
565
575
  case 2:
576
+ columns = _context8.sent;
577
+ setColumns(tableName, columns, datasourceId, _isExit);
578
+ case 3:
566
579
  _columns = (_columns2 = columns) === null || _columns2 === void 0 ? void 0 : _columns2.map(function (v) {
567
580
  var _ref9, _obj$fieldAlias;
568
581
  var obj = oldColumns.find(function (oldColumn) {
@@ -576,7 +589,7 @@ var useStore = function useStore() {
576
589
  });
577
590
  });
578
591
  typeof callback === 'function' && callback(_columns);
579
- case 3:
592
+ case 4:
580
593
  case "end":
581
594
  return _context8.stop();
582
595
  }
@@ -597,7 +610,8 @@ var useStore = function useStore() {
597
610
  oldData,
598
611
  newData,
599
612
  isChange,
600
- _args9 = arguments;
613
+ _args9 = arguments,
614
+ _t;
601
615
  return _regenerator["default"].wrap(function (_context9) {
602
616
  while (1) switch (_context9.prev = _context9.next) {
603
617
  case 0:
@@ -628,25 +642,35 @@ var useStore = function useStore() {
628
642
  case 2:
629
643
  oldData = (0, _utils.splitByUnion)(prevMeta);
630
644
  newData = (0, _utils.splitByUnion)(newMeta);
645
+ if (!(typeof fetchChangeFn.current === 'function')) {
646
+ _context9.next = 4;
647
+ break;
648
+ }
631
649
  _context9.next = 3;
632
650
  return fetchChangeFn.current(oldData, changeObj, {
633
651
  isExit: isExit
634
652
  }, newData);
635
653
  case 3:
636
- isChange = _context9.sent;
654
+ _t = _context9.sent;
655
+ _context9.next = 5;
656
+ break;
657
+ case 4:
658
+ _t = true;
659
+ case 5:
660
+ isChange = _t;
637
661
  if (!(isChange === false)) {
638
- _context9.next = 4;
662
+ _context9.next = 6;
639
663
  break;
640
664
  }
641
665
  if (requestId === metaRequestRef.current && metaRevisionRef.current === prevRevision) {
642
666
  _setMeta(prevMeta);
643
667
  }
644
668
  return _context9.abrupt("return");
645
- case 4:
669
+ case 6:
646
670
  if (requestId === metaRequestRef.current && metaRevisionRef.current === prevRevision) {
647
671
  _setMeta(newMeta);
648
672
  }
649
- case 5:
673
+ case 7:
650
674
  case "end":
651
675
  return _context9.stop();
652
676
  }
@@ -978,18 +1002,27 @@ var useStore = function useStore() {
978
1002
  });
979
1003
  setMeta(_metaList, groupIndex);
980
1004
  };
1005
+ var getColumnsCacheKey = function getColumnsCacheKey(tableId) {
1006
+ var datasourceId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1007
+ var exitMode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1008
+ return "".concat(datasourceId || '', "::").concat(tableId || '', "::").concat(exitMode ? 'exit' : 'main');
1009
+ };
981
1010
  var setColumns = function setColumns(tableId, columns) {
1011
+ var datasourceId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
1012
+ var exitMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
982
1013
  var _columns = columns === null || columns === void 0 ? void 0 : columns.map(function (v) {
983
1014
  return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, v), {}, {
984
1015
  fieldUuid: v.fieldUuid || (0, _helper.uuidv4)('field')
985
1016
  });
986
1017
  });
987
1018
  var map = (0, _objectSpread2["default"])({}, _cacheColumnsMap);
988
- map[tableId] = _columns;
1019
+ map[getColumnsCacheKey(tableId, datasourceId, exitMode)] = _columns;
989
1020
  set_cacheColumnsMap(map);
990
1021
  };
991
1022
  var getColumns = function getColumns(tableId) {
992
- return _cacheColumnsMap[tableId] || [];
1023
+ var datasourceId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1024
+ var exitMode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1025
+ return _cacheColumnsMap[getColumnsCacheKey(tableId, datasourceId, exitMode)] || [];
993
1026
  };
994
1027
  var setDataset = function setDataset(datasourceId, tables) {
995
1028
  var map = (0, _objectSpread2["default"])({}, _cacheSource2TableMap);