@gingkoo/pandora-metabase 1.0.107 → 1.0.109

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.
@@ -13,28 +13,20 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
13
13
  var RangePicker = _pandora.DatePicker.RangePicker,
14
14
  YearPicker = _pandora.DatePicker.YearPicker,
15
15
  MonthPicker = _pandora.DatePicker.MonthPicker;
16
- var DATE_FORMAT_OPTIONS = [{
17
- value: 'YYYY',
18
- label: 'YYYY'
19
- }, {
20
- value: 'YYYY-MM',
21
- label: 'YYYY-MM'
22
- }, {
16
+ var DATE_FORMAT_OPTIONS = [
17
+ // { value: 'YYYY', label: 'YYYY' },
18
+ // { value: 'YYYY-MM', label: 'YYYY-MM' },
19
+ {
23
20
  value: 'YYYY-MM-DD',
24
21
  label: 'YYYY-MM-DD'
25
22
  }, {
26
23
  value: 'YYYY-MM-DD HH:mm',
27
24
  label: 'YYYY-MM-DD HH:mm'
28
- }, {
29
- value: 'YYYY/MM',
30
- label: 'YYYY/MM'
31
- }, {
32
- value: 'YYYY/MM/DD',
33
- label: 'YYYY/MM/DD'
34
- }, {
35
- value: 'YYYY/MM/DD HH:mm',
36
- label: 'YYYY/MM/DD HH:mm'
37
- }];
25
+ }
26
+ // { value: 'YYYY/MM', label: 'YYYY/MM' },
27
+ // { value: 'YYYY/MM/DD', label: 'YYYY/MM/DD' },
28
+ // { value: 'YYYY/MM/DD HH:mm', label: 'YYYY/MM/DD HH:mm' },
29
+ ];
38
30
  var DEFAULT_FORMAT = 'YYYY-MM-DD HH:mm';
39
31
  var DateRangeFormatPicker = exports.DateRangeFormatPicker = function DateRangeFormatPicker(_ref) {
40
32
  var value = _ref.value,
@@ -4,23 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.DEFAULT_DATE_FORMAT = exports.DATE_FORMAT_OPTIONS = void 0;
7
- var DATE_FORMAT_OPTIONS = exports.DATE_FORMAT_OPTIONS = [{
8
- value: 'YYYY-MM',
9
- label: 'YYYY-MM'
10
- }, {
7
+ var DATE_FORMAT_OPTIONS = exports.DATE_FORMAT_OPTIONS = [
8
+ // { value: 'YYYY-MM', label: 'YYYY-MM' },
9
+ {
11
10
  value: 'YYYY-MM-DD',
12
11
  label: 'YYYY-MM-DD'
13
12
  }, {
14
13
  value: 'YYYY-MM-DD HH:mm',
15
14
  label: 'YYYY-MM-DD HH:mm'
16
- }, {
17
- value: 'YYYY/MM',
18
- label: 'YYYY/MM'
19
- }, {
20
- value: 'YYYY/MM/DD',
21
- label: 'YYYY/MM/DD'
22
- }, {
23
- value: 'YYYY/MM/DD HH:mm',
24
- label: 'YYYY/MM/DD HH:mm'
25
- }];
15
+ }
16
+ // { value: 'YYYY/MM', label: 'YYYY/MM' },
17
+ // { value: 'YYYY/MM/DD', label: 'YYYY/MM/DD' },
18
+ // { value: 'YYYY/MM/DD HH:mm', label: 'YYYY/MM/DD HH:mm' },
19
+ ];
26
20
  var DEFAULT_DATE_FORMAT = exports.DEFAULT_DATE_FORMAT = 'YYYY-MM-DD HH:mm';
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports["default"] = exports.SummarizeAlias = void 0;
8
+ var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createForOfIteratorHelper"));
8
9
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/typeof"));
9
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
10
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
@@ -834,49 +835,47 @@ var useStore = function useStore() {
834
835
  }
835
836
  return item;
836
837
  };
837
- // 检查粘贴位置上下级的 table1 是否与被粘贴项的 table1 有相同的 alias
838
- var checkTable1Conflict = function checkTable1Conflict(objList, index, groupIndex) {
839
- var _metaList$groupIndex, _objList$;
838
+ // 检查所有同级 joinData table1.id + table2.id 组合是否冲突
839
+ var checkTable1Conflict = function checkTable1Conflict(objList, _index, groupIndex) {
840
+ var _metaList$groupIndex;
840
841
  if (!objList || objList.length === 0) return {
841
842
  hasConflict: false
842
843
  };
843
844
  var groupList = ((_metaList$groupIndex = metaList[groupIndex]) === null || _metaList$groupIndex === void 0 ? void 0 : _metaList$groupIndex.list) || [];
844
- // 获取被粘贴项的 table1 alias
845
- var pastedTable1Alias = (_objList$ = objList[0]) === null || _objList$ === void 0 || (_objList$ = _objList$.table1) === null || _objList$ === void 0 ? void 0 : _objList$.alias;
846
- if (!pastedTable1Alias) return {
847
- hasConflict: false
845
+ // 获取所有同级 joinData 的 table1.id + table2.id 组合
846
+ var getJoinKey = function getJoinKey(table1, table2) {
847
+ return "".concat((table1 === null || table1 === void 0 ? void 0 : table1.id) || '', "_").concat((table2 === null || table2 === void 0 ? void 0 : table2.id) || '');
848
848
  };
849
- // 检查上下级的 table1 和 table2 alias
850
- var checkItem = function checkItem(item) {
851
- if (!item) return undefined;
852
- if (item.type === _enum.TypeEnum.joinData) {
853
- var _item$table, _item$table2;
854
- if (((_item$table = item.table1) === null || _item$table === void 0 ? void 0 : _item$table.alias) === pastedTable1Alias) return item.table1.alias;
855
- if (((_item$table2 = item.table2) === null || _item$table2 === void 0 ? void 0 : _item$table2.alias) === pastedTable1Alias) return item.table2.alias;
849
+ // 收集已存在的 joinData 组合
850
+ var existingJoinKeys = new Set();
851
+ groupList.forEach(function (item) {
852
+ if (item.type === _enum.TypeEnum.joinData && item.table1 && item.table2) {
853
+ existingJoinKeys.add(getJoinKey(item.table1, item.table2));
856
854
  }
857
- if (item.type === _enum.TypeEnum.data) {
858
- var _item$table3;
859
- if (((_item$table3 = item.table) === null || _item$table3 === void 0 ? void 0 : _item$table3.alias) === pastedTable1Alias) return item.table.alias;
855
+ });
856
+ // 检查每个被粘贴项的组合是否已存在
857
+ var _iterator = (0, _createForOfIteratorHelper2["default"])(objList),
858
+ _step;
859
+ try {
860
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
861
+ var pastedItem = _step.value;
862
+ if (pastedItem.type !== _enum.TypeEnum.joinData || !pastedItem.table1 || !pastedItem.table2) {
863
+ continue;
864
+ }
865
+ var pastedKey = getJoinKey(pastedItem.table1, pastedItem.table2);
866
+ if (existingJoinKeys.has(pastedKey)) {
867
+ var _pastedItem$table, _pastedItem$table2;
868
+ return {
869
+ hasConflict: true,
870
+ conflictingAlias: (_pastedItem$table = pastedItem.table2) === null || _pastedItem$table === void 0 ? void 0 : _pastedItem$table.alias,
871
+ conflictingId: (_pastedItem$table2 = pastedItem.table2) === null || _pastedItem$table2 === void 0 ? void 0 : _pastedItem$table2.id
872
+ };
873
+ }
860
874
  }
861
- return undefined;
862
- };
863
- // 检查上邻(index - 1 位置)
864
- var prevItem = groupList[index - 1];
865
- var prevConflict = checkItem(prevItem);
866
- if (prevConflict) {
867
- return {
868
- hasConflict: true,
869
- conflictingAlias: pastedTable1Alias
870
- };
871
- }
872
- // 检查下邻(index 位置,即被插入位置的原元素)
873
- var nextItem = groupList[index];
874
- var nextConflict = checkItem(nextItem);
875
- if (nextConflict) {
876
- return {
877
- hasConflict: true,
878
- conflictingAlias: pastedTable1Alias
879
- };
875
+ } catch (err) {
876
+ _iterator.e(err);
877
+ } finally {
878
+ _iterator.f();
880
879
  }
881
880
  return {
882
881
  hasConflict: false
package/lib/cjs/utils.js CHANGED
@@ -320,7 +320,7 @@ var _changeAlias = function changeAlias(items, val, type) {
320
320
  });
321
321
  };
322
322
  function isValidSQLAlias(str) {
323
- if (!str) return false;
323
+ if (!str) return true;
324
324
  var regex = /^[a-zA-Z][a-zA-Z0-9_]{0,29}$/;
325
325
  return regex.test(str);
326
326
  }
@@ -6,28 +6,20 @@ import dayjs from 'dayjs';
6
6
  var RangePicker = DatePicker.RangePicker,
7
7
  YearPicker = DatePicker.YearPicker,
8
8
  MonthPicker = DatePicker.MonthPicker;
9
- var DATE_FORMAT_OPTIONS = [{
10
- value: 'YYYY',
11
- label: 'YYYY'
12
- }, {
13
- value: 'YYYY-MM',
14
- label: 'YYYY-MM'
15
- }, {
9
+ var DATE_FORMAT_OPTIONS = [
10
+ // { value: 'YYYY', label: 'YYYY' },
11
+ // { value: 'YYYY-MM', label: 'YYYY-MM' },
12
+ {
16
13
  value: 'YYYY-MM-DD',
17
14
  label: 'YYYY-MM-DD'
18
15
  }, {
19
16
  value: 'YYYY-MM-DD HH:mm',
20
17
  label: 'YYYY-MM-DD HH:mm'
21
- }, {
22
- value: 'YYYY/MM',
23
- label: 'YYYY/MM'
24
- }, {
25
- value: 'YYYY/MM/DD',
26
- label: 'YYYY/MM/DD'
27
- }, {
28
- value: 'YYYY/MM/DD HH:mm',
29
- label: 'YYYY/MM/DD HH:mm'
30
- }];
18
+ }
19
+ // { value: 'YYYY/MM', label: 'YYYY/MM' },
20
+ // { value: 'YYYY/MM/DD', label: 'YYYY/MM/DD' },
21
+ // { value: 'YYYY/MM/DD HH:mm', label: 'YYYY/MM/DD HH:mm' },
22
+ ];
31
23
  var DEFAULT_FORMAT = 'YYYY-MM-DD HH:mm';
32
24
  export var DateRangeFormatPicker = function DateRangeFormatPicker(_ref) {
33
25
  var value = _ref.value,
@@ -1,20 +1,14 @@
1
- export var DATE_FORMAT_OPTIONS = [{
2
- value: 'YYYY-MM',
3
- label: 'YYYY-MM'
4
- }, {
1
+ export var DATE_FORMAT_OPTIONS = [
2
+ // { value: 'YYYY-MM', label: 'YYYY-MM' },
3
+ {
5
4
  value: 'YYYY-MM-DD',
6
5
  label: 'YYYY-MM-DD'
7
6
  }, {
8
7
  value: 'YYYY-MM-DD HH:mm',
9
8
  label: 'YYYY-MM-DD HH:mm'
10
- }, {
11
- value: 'YYYY/MM',
12
- label: 'YYYY/MM'
13
- }, {
14
- value: 'YYYY/MM/DD',
15
- label: 'YYYY/MM/DD'
16
- }, {
17
- value: 'YYYY/MM/DD HH:mm',
18
- label: 'YYYY/MM/DD HH:mm'
19
- }];
9
+ }
10
+ // { value: 'YYYY/MM', label: 'YYYY/MM' },
11
+ // { value: 'YYYY/MM/DD', label: 'YYYY/MM/DD' },
12
+ // { value: 'YYYY/MM/DD HH:mm', label: 'YYYY/MM/DD HH:mm' },
13
+ ];
20
14
  export var DEFAULT_DATE_FORMAT = 'YYYY-MM-DD HH:mm';
@@ -1,3 +1,4 @@
1
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
1
2
  import _typeof from "@babel/runtime/helpers/esm/typeof";
2
3
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
@@ -828,49 +829,47 @@ var useStore = function useStore() {
828
829
  }
829
830
  return item;
830
831
  };
831
- // 检查粘贴位置上下级的 table1 是否与被粘贴项的 table1 有相同的 alias
832
- var checkTable1Conflict = function checkTable1Conflict(objList, index, groupIndex) {
833
- var _metaList$groupIndex, _objList$;
832
+ // 检查所有同级 joinData table1.id + table2.id 组合是否冲突
833
+ var checkTable1Conflict = function checkTable1Conflict(objList, _index, groupIndex) {
834
+ var _metaList$groupIndex;
834
835
  if (!objList || objList.length === 0) return {
835
836
  hasConflict: false
836
837
  };
837
838
  var groupList = ((_metaList$groupIndex = metaList[groupIndex]) === null || _metaList$groupIndex === void 0 ? void 0 : _metaList$groupIndex.list) || [];
838
- // 获取被粘贴项的 table1 alias
839
- var pastedTable1Alias = (_objList$ = objList[0]) === null || _objList$ === void 0 || (_objList$ = _objList$.table1) === null || _objList$ === void 0 ? void 0 : _objList$.alias;
840
- if (!pastedTable1Alias) return {
841
- hasConflict: false
839
+ // 获取所有同级 joinData 的 table1.id + table2.id 组合
840
+ var getJoinKey = function getJoinKey(table1, table2) {
841
+ return "".concat((table1 === null || table1 === void 0 ? void 0 : table1.id) || '', "_").concat((table2 === null || table2 === void 0 ? void 0 : table2.id) || '');
842
842
  };
843
- // 检查上下级的 table1 和 table2 alias
844
- var checkItem = function checkItem(item) {
845
- if (!item) return undefined;
846
- if (item.type === TypeEnum.joinData) {
847
- var _item$table, _item$table2;
848
- if (((_item$table = item.table1) === null || _item$table === void 0 ? void 0 : _item$table.alias) === pastedTable1Alias) return item.table1.alias;
849
- if (((_item$table2 = item.table2) === null || _item$table2 === void 0 ? void 0 : _item$table2.alias) === pastedTable1Alias) return item.table2.alias;
843
+ // 收集已存在的 joinData 组合
844
+ var existingJoinKeys = new Set();
845
+ groupList.forEach(function (item) {
846
+ if (item.type === TypeEnum.joinData && item.table1 && item.table2) {
847
+ existingJoinKeys.add(getJoinKey(item.table1, item.table2));
850
848
  }
851
- if (item.type === TypeEnum.data) {
852
- var _item$table3;
853
- if (((_item$table3 = item.table) === null || _item$table3 === void 0 ? void 0 : _item$table3.alias) === pastedTable1Alias) return item.table.alias;
849
+ });
850
+ // 检查每个被粘贴项的组合是否已存在
851
+ var _iterator = _createForOfIteratorHelper(objList),
852
+ _step;
853
+ try {
854
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
855
+ var pastedItem = _step.value;
856
+ if (pastedItem.type !== TypeEnum.joinData || !pastedItem.table1 || !pastedItem.table2) {
857
+ continue;
858
+ }
859
+ var pastedKey = getJoinKey(pastedItem.table1, pastedItem.table2);
860
+ if (existingJoinKeys.has(pastedKey)) {
861
+ var _pastedItem$table, _pastedItem$table2;
862
+ return {
863
+ hasConflict: true,
864
+ conflictingAlias: (_pastedItem$table = pastedItem.table2) === null || _pastedItem$table === void 0 ? void 0 : _pastedItem$table.alias,
865
+ conflictingId: (_pastedItem$table2 = pastedItem.table2) === null || _pastedItem$table2 === void 0 ? void 0 : _pastedItem$table2.id
866
+ };
867
+ }
854
868
  }
855
- return undefined;
856
- };
857
- // 检查上邻(index - 1 位置)
858
- var prevItem = groupList[index - 1];
859
- var prevConflict = checkItem(prevItem);
860
- if (prevConflict) {
861
- return {
862
- hasConflict: true,
863
- conflictingAlias: pastedTable1Alias
864
- };
865
- }
866
- // 检查下邻(index 位置,即被插入位置的原元素)
867
- var nextItem = groupList[index];
868
- var nextConflict = checkItem(nextItem);
869
- if (nextConflict) {
870
- return {
871
- hasConflict: true,
872
- conflictingAlias: pastedTable1Alias
873
- };
869
+ } catch (err) {
870
+ _iterator.e(err);
871
+ } finally {
872
+ _iterator.f();
874
873
  }
875
874
  return {
876
875
  hasConflict: false
package/lib/es/utils.js CHANGED
@@ -307,7 +307,7 @@ var _changeAlias = function changeAlias(items, val, type) {
307
307
  });
308
308
  };
309
309
  export function isValidSQLAlias(str) {
310
- if (!str) return false;
310
+ if (!str) return true;
311
311
  var regex = /^[a-zA-Z][a-zA-Z0-9_]{0,29}$/;
312
312
  return regex.test(str);
313
313
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gingkoo/pandora-metabase",
3
- "version": "1.0.107",
3
+ "version": "1.0.109",
4
4
  "description": "",
5
5
  "main": "lib/es/index.js",
6
6
  "module": "lib/es/index.js",