@gingkoo/pandora-metabase 1.0.141 → 1.0.143
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/formula-list/LogicGroup.d.ts +8 -5
- package/lib/cjs/components/dialog/formula-list/LogicGroup.js +64 -18
- package/lib/cjs/components/dialog/formula-list/index.js +374 -153
- package/lib/cjs/components/dialog/formula-list/index.less +18 -5
- package/lib/cjs/components/dialog/formula-list/utils.js +45 -17
- package/lib/cjs/components/dialog/select-column/index.js +5 -2
- package/lib/cjs/components/dialog/select-summarize/index.js +7 -0
- package/lib/cjs/components/modules/summarize/group-by.js +10 -1
- package/lib/cjs/components/modules/summarize/select-index.js +3 -1
- package/lib/cjs/hooks/use-state.js +167 -75
- package/lib/cjs/index.js +17 -3
- package/lib/cjs/store/types.d.ts +4 -4
- package/lib/cjs/types.d.ts +20 -1
- package/lib/cjs/utils/transformSql.js +51 -38
- package/lib/cjs/utils.d.ts +1 -0
- package/lib/cjs/utils.js +327 -57
- package/lib/es/components/dialog/formula-list/LogicGroup.d.ts +8 -5
- package/lib/es/components/dialog/formula-list/LogicGroup.js +65 -19
- package/lib/es/components/dialog/formula-list/index.js +373 -152
- package/lib/es/components/dialog/formula-list/index.less +18 -5
- package/lib/es/components/dialog/formula-list/utils.js +45 -17
- package/lib/es/components/dialog/select-column/index.js +5 -2
- package/lib/es/components/dialog/select-summarize/index.js +7 -0
- package/lib/es/components/modules/summarize/group-by.js +10 -1
- package/lib/es/components/modules/summarize/select-index.js +3 -1
- package/lib/es/hooks/use-state.js +167 -75
- package/lib/es/index.js +18 -4
- package/lib/es/store/types.d.ts +4 -4
- package/lib/es/types.d.ts +20 -1
- package/lib/es/utils/transformSql.js +52 -39
- package/lib/es/utils.d.ts +1 -0
- package/lib/es/utils.js +326 -56
- package/package.json +1 -1
package/lib/es/utils.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
1
2
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
4
4
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
6
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
7
|
-
var _excluded = ["
|
|
7
|
+
var _excluded = ["operator", "leftAtoms", "rightAtoms", "atoms"],
|
|
8
|
+
_excluded2 = ["operator", "leftAtoms", "rightAtoms", "atoms"],
|
|
9
|
+
_excluded3 = ["operator", "leftAtoms", "rightAtoms", "atoms", "items"],
|
|
10
|
+
_excluded4 = ["list"];
|
|
8
11
|
import { __, isEn } from './locale';
|
|
9
12
|
import { TypeEnum, SQL_COLUMN_TYPE } from './store/enum';
|
|
10
13
|
import { MetaSummarize_Enum, AtomsTypeEnum } from './store/types';
|
|
@@ -312,14 +315,13 @@ var _syncSubQueryFieldItems = function syncSubQueryFieldItems() {
|
|
|
312
315
|
elseAtoms: _syncSubQueryFieldItems(item.elseAtoms || [], table, columns, oldColumns)
|
|
313
316
|
});
|
|
314
317
|
} else if (item.type === AtomsTypeEnum.AND_OR) {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
});
|
|
318
|
+
nextItem = syncAndOrBinaryFields(_objectSpread(_objectSpread({}, item), {}, {
|
|
319
|
+
items: normalizeAndOrItems(item).map(function (logicItem) {
|
|
320
|
+
return _objectSpread(_objectSpread({}, logicItem), {}, {
|
|
321
|
+
atoms: _syncSubQueryFieldItems(logicItem.atoms || [], table, columns, oldColumns)
|
|
322
|
+
});
|
|
323
|
+
})
|
|
324
|
+
}));
|
|
323
325
|
} else {
|
|
324
326
|
nextItem = item;
|
|
325
327
|
}
|
|
@@ -619,15 +621,250 @@ var buildFormulaQuotes = function buildFormulaQuotes(item) {
|
|
|
619
621
|
var argsText = (item.args || []).map(_getAtomDisplayText).join(' , ');
|
|
620
622
|
return normalizeAtomQuotes("".concat(item.name || '', " ( ").concat(argsText, " )"));
|
|
621
623
|
};
|
|
624
|
+
var normalizeAndOrItems = function normalizeAndOrItems(item) {
|
|
625
|
+
if (Array.isArray(item.items) && item.items.length > 0) {
|
|
626
|
+
return item.items.map(function (logicItem, index) {
|
|
627
|
+
var operator = logicItem.operator,
|
|
628
|
+
leftAtoms = logicItem.leftAtoms,
|
|
629
|
+
rightAtoms = logicItem.rightAtoms,
|
|
630
|
+
atoms = logicItem.atoms,
|
|
631
|
+
nextLogicItem = _objectWithoutProperties(logicItem, _excluded);
|
|
632
|
+
return _objectSpread(_objectSpread(_objectSpread({}, nextLogicItem), index > 0 ? {
|
|
633
|
+
operator: operator || item.operator || 'and'
|
|
634
|
+
} : {}), {}, {
|
|
635
|
+
atoms: Array.isArray(atoms) && atoms.length > 0 ? atoms : []
|
|
636
|
+
});
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
if (Array.isArray(item.leftAtoms) || Array.isArray(item.rightAtoms)) {
|
|
640
|
+
return [{
|
|
641
|
+
atoms: Array.isArray(item.leftAtoms) ? item.leftAtoms : []
|
|
642
|
+
}, {
|
|
643
|
+
operator: item.operator || 'and',
|
|
644
|
+
atoms: Array.isArray(item.rightAtoms) ? item.rightAtoms : []
|
|
645
|
+
}];
|
|
646
|
+
}
|
|
647
|
+
return [{
|
|
648
|
+
atoms: Array.isArray(item.atoms) ? item.atoms : []
|
|
649
|
+
}];
|
|
650
|
+
};
|
|
622
651
|
var buildAndOrQuotes = function buildAndOrQuotes(item) {
|
|
623
|
-
var
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
652
|
+
var itemsText = normalizeAndOrItems(item).map(function (logicItem, index) {
|
|
653
|
+
var atomsText = (logicItem.atoms || []).map(_getAtomDisplayText).join(' ');
|
|
654
|
+
return index === 0 ? atomsText : "".concat(logicItem.operator || 'and', " ").concat(atomsText);
|
|
655
|
+
}).join(' ');
|
|
656
|
+
return normalizeAtomQuotes("( ".concat(itemsText, " )"));
|
|
657
|
+
};
|
|
658
|
+
var syncAndOrBinaryFields = function syncAndOrBinaryFields(item) {
|
|
659
|
+
var operator = item.operator,
|
|
660
|
+
leftAtoms = item.leftAtoms,
|
|
661
|
+
rightAtoms = item.rightAtoms,
|
|
662
|
+
atoms = item.atoms,
|
|
663
|
+
nextItem = _objectWithoutProperties(item, _excluded2);
|
|
664
|
+
return _objectSpread(_objectSpread({}, nextItem), {}, {
|
|
665
|
+
items: normalizeAndOrItems(item)
|
|
666
|
+
});
|
|
667
|
+
};
|
|
668
|
+
var _normalizeAndOrStructureInner = function normalizeAndOrStructureInner(data, cache) {
|
|
669
|
+
if (!data || _typeof(data) !== 'object') return data;
|
|
670
|
+
if (cache.has(data)) return cache.get(data);
|
|
671
|
+
if (Array.isArray(data)) {
|
|
672
|
+
var nextList = [];
|
|
673
|
+
cache.set(data, nextList);
|
|
674
|
+
data.forEach(function (item) {
|
|
675
|
+
nextList.push(_normalizeAndOrStructureInner(item, cache));
|
|
676
|
+
});
|
|
677
|
+
return nextList;
|
|
678
|
+
}
|
|
679
|
+
var item = data;
|
|
680
|
+
if (item.type === AtomsTypeEnum.AND_OR) {
|
|
681
|
+
var operator = item.operator,
|
|
682
|
+
leftAtoms = item.leftAtoms,
|
|
683
|
+
rightAtoms = item.rightAtoms,
|
|
684
|
+
atoms = item.atoms,
|
|
685
|
+
items = item.items,
|
|
686
|
+
nextItem = _objectWithoutProperties(item, _excluded3);
|
|
687
|
+
var normalizedItem = _objectSpread(_objectSpread({}, nextItem), {}, {
|
|
688
|
+
items: []
|
|
689
|
+
});
|
|
690
|
+
cache.set(item, normalizedItem);
|
|
691
|
+
normalizedItem.items = normalizeAndOrItems(item).map(function (logicItem) {
|
|
692
|
+
return _objectSpread(_objectSpread({}, logicItem.operator ? {
|
|
693
|
+
operator: logicItem.operator
|
|
694
|
+
} : {}), {}, {
|
|
695
|
+
atoms: _normalizeAndOrStructureInner(logicItem.atoms || [], cache)
|
|
696
|
+
});
|
|
697
|
+
});
|
|
698
|
+
normalizedItem.quotes = buildAndOrQuotes(normalizedItem);
|
|
699
|
+
return normalizedItem;
|
|
700
|
+
}
|
|
701
|
+
if (item.type === AtomsTypeEnum.JOIN_DEFAULT || item.type === AtomsTypeEnum.EXPRESSION) {
|
|
702
|
+
var _nextItem = _objectSpread({}, item);
|
|
703
|
+
cache.set(item, _nextItem);
|
|
704
|
+
if (Array.isArray(item.lhs)) {
|
|
705
|
+
_nextItem.lhs = _normalizeAndOrStructureInner(item.lhs, cache);
|
|
706
|
+
}
|
|
707
|
+
if (Array.isArray(item.rhs)) {
|
|
708
|
+
_nextItem.rhs = _normalizeAndOrStructureInner(item.rhs, cache);
|
|
709
|
+
}
|
|
710
|
+
return _nextItem;
|
|
711
|
+
}
|
|
712
|
+
if (item.type === AtomsTypeEnum.FORMULA) {
|
|
713
|
+
var _nextItem2 = _objectSpread({}, item);
|
|
714
|
+
cache.set(item, _nextItem2);
|
|
715
|
+
if (Array.isArray(item.args)) {
|
|
716
|
+
_nextItem2.args = _normalizeAndOrStructureInner(item.args, cache);
|
|
717
|
+
}
|
|
718
|
+
return _nextItem2;
|
|
719
|
+
}
|
|
720
|
+
if (item.type === AtomsTypeEnum.COLLECTION) {
|
|
721
|
+
var _nextItem3 = _objectSpread({}, item);
|
|
722
|
+
cache.set(item, _nextItem3);
|
|
723
|
+
if (Array.isArray(item.list)) {
|
|
724
|
+
_nextItem3.list = _normalizeAndOrStructureInner(item.list, cache);
|
|
725
|
+
}
|
|
726
|
+
return _nextItem3;
|
|
727
|
+
}
|
|
728
|
+
if (item.type === AtomsTypeEnum.CASE_WHEN) {
|
|
729
|
+
var _nextItem4 = _objectSpread({}, item);
|
|
730
|
+
cache.set(item, _nextItem4);
|
|
731
|
+
if (Array.isArray(item.caseAtoms)) {
|
|
732
|
+
_nextItem4.caseAtoms = _normalizeAndOrStructureInner(item.caseAtoms, cache);
|
|
733
|
+
}
|
|
734
|
+
if (Array.isArray(item.whenClauses)) {
|
|
735
|
+
_nextItem4.whenClauses = item.whenClauses.map(function (clause) {
|
|
736
|
+
if (!clause || _typeof(clause) !== 'object') return clause;
|
|
737
|
+
if (cache.has(clause)) return cache.get(clause);
|
|
738
|
+
var nextClause = _objectSpread({}, clause);
|
|
739
|
+
cache.set(clause, nextClause);
|
|
740
|
+
if (Array.isArray(clause.whenAtoms)) {
|
|
741
|
+
nextClause.whenAtoms = _normalizeAndOrStructureInner(clause.whenAtoms, cache);
|
|
742
|
+
}
|
|
743
|
+
if (Array.isArray(clause.thenAtoms)) {
|
|
744
|
+
nextClause.thenAtoms = _normalizeAndOrStructureInner(clause.thenAtoms, cache);
|
|
745
|
+
}
|
|
746
|
+
return nextClause;
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
if (Array.isArray(item.elseAtoms)) {
|
|
750
|
+
_nextItem4.elseAtoms = _normalizeAndOrStructureInner(item.elseAtoms, cache);
|
|
751
|
+
}
|
|
752
|
+
return _nextItem4;
|
|
753
|
+
}
|
|
754
|
+
if (item.type === AtomsTypeEnum.EXISTS || item.type === AtomsTypeEnum.NOT_EXISTS || item.type === AtomsTypeEnum.SUB_QUERY) {
|
|
755
|
+
var _nextItem5 = _objectSpread({}, item);
|
|
756
|
+
cache.set(item, _nextItem5);
|
|
757
|
+
if (Array.isArray(item.notExists)) {
|
|
758
|
+
_nextItem5.notExists = _normalizeAndOrStructureInner(item.notExists, cache);
|
|
759
|
+
}
|
|
760
|
+
if (Array.isArray(item.subQuery)) {
|
|
761
|
+
_nextItem5.subQuery = _normalizeAndOrStructureInner(item.subQuery, cache);
|
|
762
|
+
}
|
|
763
|
+
return _nextItem5;
|
|
764
|
+
}
|
|
765
|
+
if (item.type === TypeEnum.data) {
|
|
766
|
+
var _nextItem6 = _objectSpread({}, item);
|
|
767
|
+
cache.set(item, _nextItem6);
|
|
768
|
+
if (Array.isArray(item.subquery)) {
|
|
769
|
+
_nextItem6.subquery = _normalizeAndOrStructureInner(item.subquery, cache);
|
|
770
|
+
}
|
|
771
|
+
return _nextItem6;
|
|
772
|
+
}
|
|
773
|
+
if (item.type === TypeEnum.joinData) {
|
|
774
|
+
var _nextItem7 = _objectSpread({}, item);
|
|
775
|
+
cache.set(item, _nextItem7);
|
|
776
|
+
if (Array.isArray(item.expressions)) {
|
|
777
|
+
_nextItem7.expressions = _normalizeAndOrStructureInner(item.expressions, cache);
|
|
778
|
+
}
|
|
779
|
+
if (Array.isArray(item.subquery)) {
|
|
780
|
+
_nextItem7.subquery = _normalizeAndOrStructureInner(item.subquery, cache);
|
|
781
|
+
}
|
|
782
|
+
return _nextItem7;
|
|
783
|
+
}
|
|
784
|
+
if (item.type === TypeEnum.customColumn) {
|
|
785
|
+
var _nextItem8 = _objectSpread({}, item);
|
|
786
|
+
cache.set(item, _nextItem8);
|
|
787
|
+
if (Array.isArray(item.customColumn)) {
|
|
788
|
+
_nextItem8.customColumn = item.customColumn.map(function (column) {
|
|
789
|
+
if (!column || _typeof(column) !== 'object') return column;
|
|
790
|
+
if (cache.has(column)) return cache.get(column);
|
|
791
|
+
var nextColumn = _objectSpread({}, column);
|
|
792
|
+
cache.set(column, nextColumn);
|
|
793
|
+
if (Array.isArray(column.formulaList)) {
|
|
794
|
+
nextColumn.formulaList = _normalizeAndOrStructureInner(column.formulaList, cache);
|
|
795
|
+
}
|
|
796
|
+
return nextColumn;
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
return _nextItem8;
|
|
800
|
+
}
|
|
801
|
+
if (item.type === TypeEnum.filter) {
|
|
802
|
+
var _nextItem9 = _objectSpread({}, item);
|
|
803
|
+
cache.set(item, _nextItem9);
|
|
804
|
+
if (Array.isArray(item.filter)) {
|
|
805
|
+
_nextItem9.filter = _normalizeAndOrStructureInner(item.filter, cache);
|
|
806
|
+
}
|
|
807
|
+
return _nextItem9;
|
|
808
|
+
}
|
|
809
|
+
if (item.type === TypeEnum.summarize) {
|
|
810
|
+
var _nextItem0 = _objectSpread({}, item);
|
|
811
|
+
cache.set(item, _nextItem0);
|
|
812
|
+
if (Array.isArray(item.group)) {
|
|
813
|
+
_nextItem0.group = item.group.map(function (record) {
|
|
814
|
+
if (!record || _typeof(record) !== 'object') return record;
|
|
815
|
+
if (cache.has(record)) return cache.get(record);
|
|
816
|
+
var nextRecord = _objectSpread({}, record);
|
|
817
|
+
cache.set(record, nextRecord);
|
|
818
|
+
if (Array.isArray(record.atoms)) {
|
|
819
|
+
nextRecord.atoms = _normalizeAndOrStructureInner(record.atoms, cache);
|
|
820
|
+
}
|
|
821
|
+
return nextRecord;
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
if (Array.isArray(item.by)) {
|
|
825
|
+
_nextItem0.by = item.by.map(function (record) {
|
|
826
|
+
if (!record || _typeof(record) !== 'object') return record;
|
|
827
|
+
if (cache.has(record)) return cache.get(record);
|
|
828
|
+
var nextRecord = _objectSpread({}, record);
|
|
829
|
+
cache.set(record, nextRecord);
|
|
830
|
+
if (Array.isArray(record.atoms)) {
|
|
831
|
+
nextRecord.atoms = _normalizeAndOrStructureInner(record.atoms, cache);
|
|
832
|
+
}
|
|
833
|
+
return nextRecord;
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
return _nextItem0;
|
|
837
|
+
}
|
|
838
|
+
if (item.type === TypeEnum.sort) {
|
|
839
|
+
var _nextItem1 = _objectSpread({}, item);
|
|
840
|
+
cache.set(item, _nextItem1);
|
|
841
|
+
if (Array.isArray(item.sort)) {
|
|
842
|
+
_nextItem1.sort = item.sort.map(function (record) {
|
|
843
|
+
if (!record || _typeof(record) !== 'object') return record;
|
|
844
|
+
if (cache.has(record)) return cache.get(record);
|
|
845
|
+
var nextRecord = _objectSpread({}, record);
|
|
846
|
+
cache.set(record, nextRecord);
|
|
847
|
+
if (Array.isArray(record.expression)) {
|
|
848
|
+
nextRecord.expression = _normalizeAndOrStructureInner(record.expression, cache);
|
|
849
|
+
}
|
|
850
|
+
return nextRecord;
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
return _nextItem1;
|
|
854
|
+
}
|
|
855
|
+
if (item.type === TypeEnum.union) {
|
|
856
|
+
var _nextItem10 = _objectSpread({}, item);
|
|
857
|
+
cache.set(item, _nextItem10);
|
|
858
|
+
if (Array.isArray(item.subquery)) {
|
|
859
|
+
_nextItem10.subquery = _normalizeAndOrStructureInner(item.subquery, cache);
|
|
860
|
+
}
|
|
861
|
+
return _nextItem10;
|
|
862
|
+
}
|
|
863
|
+
cache.set(item, item);
|
|
864
|
+
return item;
|
|
865
|
+
};
|
|
866
|
+
export var normalizeAndOrStructure = function normalizeAndOrStructure(data) {
|
|
867
|
+
return _normalizeAndOrStructureInner(data, new WeakMap());
|
|
631
868
|
};
|
|
632
869
|
var buildCaseWhenQuotes = function buildCaseWhenQuotes(item) {
|
|
633
870
|
var caseAtomsText = (item.caseAtoms || []).map(_getAtomDisplayText).join(' ');
|
|
@@ -734,23 +971,23 @@ var syncAtomQuotes = function syncAtomQuotes(item) {
|
|
|
734
971
|
});
|
|
735
972
|
}
|
|
736
973
|
if (item.type === AtomsTypeEnum.FORMULA) {
|
|
737
|
-
var
|
|
974
|
+
var _nextItem11 = _objectSpread(_objectSpread({}, item), {}, {
|
|
738
975
|
args: syncAtomQuotesList(item.args || [])
|
|
739
976
|
});
|
|
740
|
-
return _objectSpread(_objectSpread({},
|
|
741
|
-
quotes: buildFormulaQuotes(
|
|
977
|
+
return _objectSpread(_objectSpread({}, _nextItem11), {}, {
|
|
978
|
+
quotes: buildFormulaQuotes(_nextItem11)
|
|
742
979
|
});
|
|
743
980
|
}
|
|
744
981
|
if (item.type === AtomsTypeEnum.COLLECTION) {
|
|
745
|
-
var
|
|
982
|
+
var _nextItem12 = _objectSpread(_objectSpread({}, item), {}, {
|
|
746
983
|
list: syncAtomQuotesList(item.list || [])
|
|
747
984
|
});
|
|
748
|
-
return _objectSpread(_objectSpread({},
|
|
749
|
-
quotes: (
|
|
985
|
+
return _objectSpread(_objectSpread({}, _nextItem12), {}, {
|
|
986
|
+
quotes: (_nextItem12.list || []).map(_getAtomDisplayText).join(' ')
|
|
750
987
|
});
|
|
751
988
|
}
|
|
752
989
|
if (item.type === AtomsTypeEnum.CASE_WHEN) {
|
|
753
|
-
var
|
|
990
|
+
var _nextItem13 = _objectSpread(_objectSpread({}, item), {}, {
|
|
754
991
|
caseAtoms: syncAtomQuotesList(item.caseAtoms || []),
|
|
755
992
|
whenClauses: (item.whenClauses || []).map(function (clause) {
|
|
756
993
|
return _objectSpread(_objectSpread({}, clause), {}, {
|
|
@@ -760,21 +997,20 @@ var syncAtomQuotes = function syncAtomQuotes(item) {
|
|
|
760
997
|
}),
|
|
761
998
|
elseAtoms: syncAtomQuotesList(item.elseAtoms || [])
|
|
762
999
|
});
|
|
763
|
-
return _objectSpread(_objectSpread({},
|
|
764
|
-
quotes: buildCaseWhenQuotes(
|
|
1000
|
+
return _objectSpread(_objectSpread({}, _nextItem13), {}, {
|
|
1001
|
+
quotes: buildCaseWhenQuotes(_nextItem13)
|
|
765
1002
|
});
|
|
766
1003
|
}
|
|
767
1004
|
if (item.type === AtomsTypeEnum.AND_OR) {
|
|
768
|
-
var
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
})
|
|
776
|
-
|
|
777
|
-
quotes: buildAndOrQuotes(_nextItem4)
|
|
1005
|
+
var _nextItem14 = syncAndOrBinaryFields(_objectSpread(_objectSpread({}, item), {}, {
|
|
1006
|
+
items: normalizeAndOrItems(item).map(function (logicItem) {
|
|
1007
|
+
return _objectSpread(_objectSpread({}, logicItem), {}, {
|
|
1008
|
+
atoms: syncAtomQuotesList(logicItem.atoms || [])
|
|
1009
|
+
});
|
|
1010
|
+
})
|
|
1011
|
+
}));
|
|
1012
|
+
return _objectSpread(_objectSpread({}, _nextItem14), {}, {
|
|
1013
|
+
quotes: buildAndOrQuotes(_nextItem14)
|
|
778
1014
|
});
|
|
779
1015
|
}
|
|
780
1016
|
return item;
|
|
@@ -821,6 +1057,34 @@ var isAliasTargetSummarizeRecord = function isAliasTargetSummarizeRecord(record,
|
|
|
821
1057
|
type: AtomsTypeEnum.FIELD
|
|
822
1058
|
}, target);
|
|
823
1059
|
};
|
|
1060
|
+
var isAliasTargetColumn = function isAliasTargetColumn(column, target, table) {
|
|
1061
|
+
return isAliasTargetField({
|
|
1062
|
+
fieldName: column.name || '',
|
|
1063
|
+
fieldNameZh: column.name_zh || '',
|
|
1064
|
+
fieldAlias: column.fieldAlias || '',
|
|
1065
|
+
fieldUuid: column.fieldUuid || '',
|
|
1066
|
+
fieldId: column.fieldId || column.id || '',
|
|
1067
|
+
tableName: (table === null || table === void 0 ? void 0 : table.name) || column.tableName || '',
|
|
1068
|
+
tableNameZh: (table === null || table === void 0 ? void 0 : table.name_zh) || column.tableNameZh || '',
|
|
1069
|
+
tableId: (table === null || table === void 0 ? void 0 : table.id) || column.tableId || '',
|
|
1070
|
+
tableAlias: (table === null || table === void 0 ? void 0 : table.alias) || column.tableAlias || '',
|
|
1071
|
+
tableUuid: (table === null || table === void 0 ? void 0 : table.tableUuid) || column.tableUuid || '',
|
|
1072
|
+
datasourceName: (table === null || table === void 0 ? void 0 : table.datasourceName) || column.datasourceName || '',
|
|
1073
|
+
datasourceId: (table === null || table === void 0 ? void 0 : table.datasourceId) || column.datasourceId || '',
|
|
1074
|
+
type: AtomsTypeEnum.FIELD
|
|
1075
|
+
}, target);
|
|
1076
|
+
};
|
|
1077
|
+
var changeColumnAlias = function changeColumnAlias() {
|
|
1078
|
+
var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1079
|
+
var target = arguments.length > 1 ? arguments[1] : undefined;
|
|
1080
|
+
var table = arguments.length > 2 ? arguments[2] : undefined;
|
|
1081
|
+
return columns.map(function (column) {
|
|
1082
|
+
return isAliasTargetColumn(column, target, table) ? _objectSpread(_objectSpread({}, column), {}, {
|
|
1083
|
+
fieldAlias: target.alias,
|
|
1084
|
+
fieldUuid: column.fieldUuid || target.uuid || ''
|
|
1085
|
+
}) : column;
|
|
1086
|
+
});
|
|
1087
|
+
};
|
|
824
1088
|
var _changeAlias = function changeAlias(items, val, type) {
|
|
825
1089
|
return items.map(function (v) {
|
|
826
1090
|
var nextItem;
|
|
@@ -893,14 +1157,13 @@ var _changeAlias = function changeAlias(items, val, type) {
|
|
|
893
1157
|
elseAtoms: _changeAlias(v.elseAtoms || [], val, type)
|
|
894
1158
|
});
|
|
895
1159
|
} else if (v.type === AtomsTypeEnum.AND_OR) {
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
});
|
|
1160
|
+
nextItem = syncAndOrBinaryFields(_objectSpread(_objectSpread({}, v), {}, {
|
|
1161
|
+
items: normalizeAndOrItems(v).map(function (logicItem) {
|
|
1162
|
+
return _objectSpread(_objectSpread({}, logicItem), {}, {
|
|
1163
|
+
atoms: _changeAlias(logicItem.atoms || [], val, type)
|
|
1164
|
+
});
|
|
1165
|
+
})
|
|
1166
|
+
}));
|
|
904
1167
|
} else {
|
|
905
1168
|
nextItem = v;
|
|
906
1169
|
}
|
|
@@ -1030,8 +1293,15 @@ export var changeFieldAlias = function changeFieldAlias(list, curObj) {
|
|
|
1030
1293
|
};
|
|
1031
1294
|
var newList = cloneDeep(list);
|
|
1032
1295
|
return (newList === null || newList === void 0 ? void 0 : newList.map(function (v) {
|
|
1033
|
-
if (v.type === TypeEnum.data) {
|
|
1296
|
+
if (v.type === TypeEnum.data) {
|
|
1297
|
+
if (v.columns && v.columns.length > 0) {
|
|
1298
|
+
v.columns = changeColumnAlias(v.columns, aliasTarget, v.table);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1034
1301
|
if (v.type === TypeEnum.joinData) {
|
|
1302
|
+
if (v.columns && v.columns.length > 0) {
|
|
1303
|
+
v.columns = changeColumnAlias(v.columns, aliasTarget, v.table2);
|
|
1304
|
+
}
|
|
1035
1305
|
if (v.expressions && v.expressions.length > 0) {
|
|
1036
1306
|
v.expressions = _changeAlias(v.expressions, aliasTarget, AliasType.field);
|
|
1037
1307
|
}
|
|
@@ -1105,7 +1375,7 @@ export function splitByUnion(data) {
|
|
|
1105
1375
|
i++;
|
|
1106
1376
|
} else if (item.type === 'union') {
|
|
1107
1377
|
var list = item.list,
|
|
1108
|
-
otehr = _objectWithoutProperties(item,
|
|
1378
|
+
otehr = _objectWithoutProperties(item, _excluded4);
|
|
1109
1379
|
var nextItem = original[i + 1];
|
|
1110
1380
|
if (nextItem && nextItem.type === 'group') {
|
|
1111
1381
|
result.push(_objectSpread(_objectSpread({}, otehr), {}, {
|
|
@@ -1176,7 +1446,7 @@ var normalizeSummarizeByForSave = function normalizeSummarizeByForSave(record) {
|
|
|
1176
1446
|
};
|
|
1177
1447
|
var _normalizeLegacySummarizeForSave = function normalizeLegacySummarizeForSave() {
|
|
1178
1448
|
var metas = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1179
|
-
|
|
1449
|
+
var normalizedMetas = metas.map(function (meta) {
|
|
1180
1450
|
if (meta.type === TypeEnum.summarize) {
|
|
1181
1451
|
return _objectSpread(_objectSpread({}, meta), {}, {
|
|
1182
1452
|
group: meta.group.map(function (item) {
|
|
@@ -1194,6 +1464,7 @@ var _normalizeLegacySummarizeForSave = function normalizeLegacySummarizeForSave(
|
|
|
1194
1464
|
}
|
|
1195
1465
|
return meta;
|
|
1196
1466
|
});
|
|
1467
|
+
return normalizeAndOrStructure(normalizedMetas);
|
|
1197
1468
|
};
|
|
1198
1469
|
export { _normalizeLegacySummarizeForSave as normalizeLegacySummarizeForSave };
|
|
1199
1470
|
export var getObjTem = function getObjTem(arr) {
|
|
@@ -1497,14 +1768,13 @@ var _changeCopyField = function changeCopyField(items, data) {
|
|
|
1497
1768
|
v.args = _changeCopyField(v.args, data);
|
|
1498
1769
|
return v;
|
|
1499
1770
|
} else if (v.type === AtomsTypeEnum.AND_OR) {
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
});
|
|
1771
|
+
return syncAndOrBinaryFields(_objectSpread(_objectSpread({}, v), {}, {
|
|
1772
|
+
items: normalizeAndOrItems(v).map(function (logicItem) {
|
|
1773
|
+
return _objectSpread(_objectSpread({}, logicItem), {}, {
|
|
1774
|
+
atoms: _changeCopyField(logicItem.atoms || [], data)
|
|
1775
|
+
});
|
|
1776
|
+
})
|
|
1777
|
+
}));
|
|
1508
1778
|
} else if (v.type === AtomsTypeEnum.COLLECTION) {
|
|
1509
1779
|
v.list = _changeCopyField(v.list, data);
|
|
1510
1780
|
return v;
|