@gingkoo/pandora-metabase 1.0.118 → 1.0.120
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/common/Portal/index.js +0 -2
- package/lib/cjs/common/SplitView/index.d.ts +0 -4
- package/lib/cjs/common/SplitView/index.js +0 -10
- package/lib/cjs/components/dialog/custom-column/config.js +4 -48
- package/lib/cjs/components/dialog/custom-column/expression-editor.js +3 -14
- package/lib/cjs/components/dialog/custom-column/expressions/suggest.d.ts +2 -34
- package/lib/cjs/components/dialog/custom-column/expressions/suggest.js +2 -43
- package/lib/cjs/components/dialog/custom-column/expressions/tokenizer.js +8 -65
- package/lib/cjs/components/dialog/custom-column/index.js +2 -4
- package/lib/cjs/components/dialog/custom-column/tokenized-expression.js +2 -3
- package/lib/cjs/components/dialog/custom-column/tokenizedI-input.js +1 -1
- package/lib/cjs/components/dialog/custom-editor/index.js +2 -7
- package/lib/cjs/components/dialog/diff-viewer/index copy.js +1 -16
- package/lib/cjs/components/dialog/expression/date-format-picker.js +2 -20
- package/lib/cjs/components/dialog/expression/date-format.js +2 -8
- package/lib/cjs/components/dialog/expression/index.d.ts +0 -3
- package/lib/cjs/components/dialog/expression/index.js +2 -83
- package/lib/cjs/components/dialog/formula/index.js +6 -31
- package/lib/cjs/components/dialog/formula/utils.js +2 -10
- package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.d.ts +19 -0
- package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.js +109 -0
- package/lib/cjs/components/dialog/formula-list/LogicGroup.d.ts +9 -0
- package/lib/cjs/components/dialog/formula-list/LogicGroup.js +43 -0
- package/lib/cjs/components/dialog/formula-list/index.d.ts +3 -0
- package/lib/cjs/components/dialog/formula-list/index.js +970 -504
- package/lib/cjs/components/dialog/formula-list/index.less +724 -0
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +0 -7
- package/lib/cjs/components/dialog/formula-list/utils.js +117 -113
- package/lib/cjs/components/dialog/select-column/index.d.ts +0 -6
- package/lib/cjs/components/dialog/select-column/index.js +4 -15
- package/lib/cjs/components/dialog/select-column-multiple/index.d.ts +0 -8
- package/lib/cjs/components/dialog/select-column-multiple/index.js +6 -45
- package/lib/cjs/components/dialog/select-join/index.d.ts +0 -5
- package/lib/cjs/components/dialog/select-join/index.js +0 -6
- package/lib/cjs/components/dialog/select-join-column/index.d.ts +0 -8
- package/lib/cjs/components/dialog/select-join-column/index.js +7 -21
- package/lib/cjs/components/dialog/select-join-column-multiple/index.d.ts +0 -8
- package/lib/cjs/components/dialog/select-join-column-multiple/index.js +5 -35
- package/lib/cjs/components/dialog/select-permission-table/index.d.ts +0 -5
- package/lib/cjs/components/dialog/select-permission-table/index.js +0 -6
- package/lib/cjs/components/dialog/select-summarize/index.d.ts +7 -4
- package/lib/cjs/components/dialog/select-summarize/index.js +105 -18
- package/lib/cjs/components/dialog/select-summarize/index.less +23 -0
- package/lib/cjs/components/dialog/select-table/index.d.ts +0 -6
- package/lib/cjs/components/dialog/select-table/index.js +1 -9
- package/lib/cjs/components/metabase/index.js +72 -86
- package/lib/cjs/components/metabase/index.less +7 -7
- package/lib/cjs/components/modules/components/Wrapper.js +1 -1
- package/lib/cjs/components/modules/components/header.js +2 -2
- package/lib/cjs/components/modules/components/meta-icon.d.ts +0 -3
- package/lib/cjs/components/modules/components/meta-icon.js +2 -47
- package/lib/cjs/components/modules/custom-column.js +3 -29
- package/lib/cjs/components/modules/enum/filter-enum.js +9 -88
- package/lib/cjs/components/modules/filter.js +2 -20
- package/lib/cjs/components/modules/index.d.ts +4 -2
- package/lib/cjs/components/modules/index.js +24 -1
- package/lib/cjs/components/modules/join-data.js +13 -291
- package/lib/cjs/components/modules/row-limit.js +0 -1
- package/lib/cjs/components/modules/sort.js +1 -61
- package/lib/cjs/components/modules/summarize/group-by.d.ts +0 -5
- package/lib/cjs/components/modules/summarize/group-by.js +251 -89
- package/lib/cjs/components/modules/summarize/select-index.js +116 -59
- package/lib/cjs/components/modules/table-data.js +11 -64
- package/lib/cjs/components/popup.js +26 -32
- package/lib/cjs/hooks/patch.d.ts +1 -0
- package/lib/cjs/hooks/patch.js +104 -6
- package/lib/cjs/hooks/patch2.js +3 -165
- package/lib/cjs/hooks/use-provider.js +0 -3
- package/lib/cjs/hooks/use-state.js +55 -135
- package/lib/cjs/index.js +0 -15
- package/lib/cjs/locale/en.js +5 -0
- package/lib/cjs/locale/index.js +1 -4
- package/lib/cjs/locale/zh.js +5 -0
- package/lib/cjs/sql-formula.js +0 -1
- package/lib/cjs/store/enum.d.ts +6 -6
- package/lib/cjs/store/enum.js +0 -13
- package/lib/cjs/store/helper.d.ts +2 -1
- package/lib/cjs/store/helper.js +15 -225
- package/lib/cjs/store/types.d.ts +45 -67
- package/lib/cjs/store/types.js +3 -49
- package/lib/cjs/types.d.ts +1 -0
- package/lib/cjs/utils/cookies.js +0 -3
- package/lib/cjs/utils/event.js +1 -1
- package/lib/cjs/utils/helper-dom.d.ts +1 -0
- package/lib/cjs/utils/helper-dom.js +17 -10
- package/lib/cjs/utils/helper.js +1 -24
- package/lib/cjs/utils/keydown.js +4 -7
- package/lib/cjs/utils/platform.d.ts +0 -9
- package/lib/cjs/utils/platform.js +0 -10
- package/lib/cjs/utils/selection.js +0 -6
- package/lib/cjs/utils/storage.d.ts +0 -9
- package/lib/cjs/utils/storage.js +1 -11
- package/lib/cjs/utils/transformSql.d.ts +5 -0
- package/lib/cjs/utils/transformSql.js +40 -101
- package/lib/cjs/utils.d.ts +1 -6
- package/lib/cjs/utils.js +126 -255
- package/lib/es/common/Portal/index.js +0 -2
- package/lib/es/common/SplitView/index.d.ts +0 -4
- package/lib/es/common/SplitView/index.js +0 -10
- package/lib/es/components/dialog/custom-column/config.js +4 -48
- package/lib/es/components/dialog/custom-column/expression-editor.js +3 -14
- package/lib/es/components/dialog/custom-column/expressions/suggest.d.ts +2 -34
- package/lib/es/components/dialog/custom-column/expressions/suggest.js +2 -43
- package/lib/es/components/dialog/custom-column/expressions/tokenizer.js +8 -65
- package/lib/es/components/dialog/custom-column/index.js +2 -4
- package/lib/es/components/dialog/custom-column/tokenized-expression.js +1 -3
- package/lib/es/components/dialog/custom-column/tokenizedI-input.js +1 -1
- package/lib/es/components/dialog/custom-editor/index.js +1 -7
- package/lib/es/components/dialog/diff-viewer/index copy.js +1 -15
- package/lib/es/components/dialog/expression/date-format-picker.js +2 -20
- package/lib/es/components/dialog/expression/date-format.js +2 -8
- package/lib/es/components/dialog/expression/index.d.ts +0 -3
- package/lib/es/components/dialog/expression/index.js +2 -82
- package/lib/es/components/dialog/formula/index.js +5 -31
- package/lib/es/components/dialog/formula/utils.js +2 -10
- package/lib/es/components/dialog/formula-list/CaseWhenGroup.d.ts +19 -0
- package/lib/es/components/dialog/formula-list/CaseWhenGroup.js +102 -0
- package/lib/es/components/dialog/formula-list/LogicGroup.d.ts +9 -0
- package/lib/es/components/dialog/formula-list/LogicGroup.js +36 -0
- package/lib/es/components/dialog/formula-list/index.d.ts +3 -0
- package/lib/es/components/dialog/formula-list/index.js +969 -504
- package/lib/es/components/dialog/formula-list/index.less +724 -0
- package/lib/es/components/dialog/formula-list/utils.d.ts +0 -7
- package/lib/es/components/dialog/formula-list/utils.js +117 -113
- package/lib/es/components/dialog/index.js +3 -3
- package/lib/es/components/dialog/select-column/index.d.ts +0 -6
- package/lib/es/components/dialog/select-column/index.js +4 -14
- package/lib/es/components/dialog/select-column-multiple/index.d.ts +0 -8
- package/lib/es/components/dialog/select-column-multiple/index.js +7 -47
- package/lib/es/components/dialog/select-join/index.d.ts +0 -5
- package/lib/es/components/dialog/select-join/index.js +0 -5
- package/lib/es/components/dialog/select-join-column/index.d.ts +0 -8
- package/lib/es/components/dialog/select-join-column/index.js +7 -20
- package/lib/es/components/dialog/select-join-column-multiple/index.d.ts +0 -8
- package/lib/es/components/dialog/select-join-column-multiple/index.js +5 -34
- package/lib/es/components/dialog/select-permission-table/index.d.ts +0 -5
- package/lib/es/components/dialog/select-permission-table/index.js +0 -5
- package/lib/es/components/dialog/select-summarize/index.d.ts +7 -4
- package/lib/es/components/dialog/select-summarize/index.js +106 -18
- package/lib/es/components/dialog/select-summarize/index.less +23 -0
- package/lib/es/components/dialog/select-table/index.d.ts +0 -6
- package/lib/es/components/dialog/select-table/index.js +1 -8
- package/lib/es/components/metabase/index.js +72 -87
- package/lib/es/components/metabase/index.less +7 -7
- package/lib/es/components/modules/components/Wrapper.js +1 -1
- package/lib/es/components/modules/components/header.js +2 -2
- package/lib/es/components/modules/components/meta-icon.d.ts +0 -3
- package/lib/es/components/modules/components/meta-icon.js +2 -46
- package/lib/es/components/modules/custom-column.js +3 -29
- package/lib/es/components/modules/enum/filter-enum.js +9 -88
- package/lib/es/components/modules/filter.js +2 -19
- package/lib/es/components/modules/index.d.ts +4 -2
- package/lib/es/components/modules/index.js +24 -1
- package/lib/es/components/modules/join-data.js +13 -291
- package/lib/es/components/modules/row-limit.js +0 -1
- package/lib/es/components/modules/sort.js +1 -61
- package/lib/es/components/modules/summarize/group-by.d.ts +0 -5
- package/lib/es/components/modules/summarize/group-by.js +253 -91
- package/lib/es/components/modules/summarize/select-index.js +116 -59
- package/lib/es/components/modules/table-data.js +11 -64
- package/lib/es/components/popup.js +27 -33
- package/lib/es/hooks/patch.d.ts +1 -0
- package/lib/es/hooks/patch.js +103 -5
- package/lib/es/hooks/patch2.js +2 -164
- package/lib/es/hooks/use-provider.js +0 -3
- package/lib/es/hooks/use-state.js +55 -135
- package/lib/es/index.js +0 -14
- package/lib/es/locale/en.js +5 -0
- package/lib/es/locale/index.js +1 -4
- package/lib/es/locale/zh.js +5 -0
- package/lib/es/sql-formula.js +0 -1
- package/lib/es/store/enum.d.ts +6 -6
- package/lib/es/store/enum.js +0 -13
- package/lib/es/store/helper.d.ts +2 -1
- package/lib/es/store/helper.js +13 -224
- package/lib/es/store/types.d.ts +45 -67
- package/lib/es/store/types.js +3 -49
- package/lib/es/types.d.ts +1 -0
- package/lib/es/types.js +1 -18
- package/lib/es/utils/cookies.js +0 -3
- package/lib/es/utils/event.js +1 -1
- package/lib/es/utils/helper-dom.d.ts +1 -0
- package/lib/es/utils/helper-dom.js +16 -9
- package/lib/es/utils/helper.js +1 -24
- package/lib/es/utils/keydown.js +4 -7
- package/lib/es/utils/platform.d.ts +0 -9
- package/lib/es/utils/platform.js +0 -10
- package/lib/es/utils/selection.js +0 -6
- package/lib/es/utils/storage.d.ts +0 -9
- package/lib/es/utils/storage.js +1 -10
- package/lib/es/utils/transformSql.d.ts +5 -0
- package/lib/es/utils/transformSql.js +40 -100
- package/lib/es/utils.d.ts +1 -6
- package/lib/es/utils.js +127 -255
- package/package.json +1 -1
|
@@ -22,7 +22,8 @@ var _Portal = _interopRequireDefault(require("../common/Portal"));
|
|
|
22
22
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
23
23
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, (0, _isNativeReflectConstruct2["default"])() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
24
24
|
var outSpacing = 10;
|
|
25
|
-
var
|
|
25
|
+
var popupOrderSeed = 1;
|
|
26
|
+
var TriggerInternal = function (_React$Component) {
|
|
26
27
|
function TriggerInternal(props) {
|
|
27
28
|
var _this;
|
|
28
29
|
(0, _classCallCheck2["default"])(this, TriggerInternal);
|
|
@@ -34,11 +35,21 @@ var TriggerInternal = /*#__PURE__*/function (_React$Component) {
|
|
|
34
35
|
(0, _defineProperty2["default"])(_this, "scrollHeightCheckTimer", null);
|
|
35
36
|
(0, _defineProperty2["default"])(_this, "lastScrollHeight", 0);
|
|
36
37
|
(0, _defineProperty2["default"])(_this, "handleClickOutside", function (e) {
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
var _this$props$node, _this$props$node$cont, _this$popupContainer;
|
|
39
|
+
var target = e.target;
|
|
40
|
+
if (!target) {
|
|
41
|
+
_this.closePopup();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if ((_this$props$node = _this.props.node) !== null && _this$props$node !== void 0 && (_this$props$node$cont = _this$props$node.contains) !== null && _this$props$node$cont !== void 0 && _this$props$node$cont.call(_this$props$node, target)) return;
|
|
45
|
+
if ((_this$popupContainer = _this.popupContainer) !== null && _this$popupContainer !== void 0 && _this$popupContainer.contains(target)) return;
|
|
46
|
+
var clickedPopupContainer = target instanceof Element ? target.closest('[data-sqb-popup-container="true"]') : null;
|
|
47
|
+
if (clickedPopupContainer && _this.popupContainer) {
|
|
48
|
+
var currentOrder = Number(_this.popupContainer.getAttribute('data-sqb-popup-order') || 0);
|
|
49
|
+
var clickedOrder = Number(clickedPopupContainer.getAttribute('data-sqb-popup-order') || 0);
|
|
50
|
+
if (clickedOrder > currentOrder) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
42
53
|
}
|
|
43
54
|
_this.closePopup();
|
|
44
55
|
});
|
|
@@ -47,7 +58,7 @@ var TriggerInternal = /*#__PURE__*/function (_React$Component) {
|
|
|
47
58
|
_this.createPopupContainer();
|
|
48
59
|
_this.resetId = _event.winResetEvent.addEvent(_this.didUpdate, _this, 300);
|
|
49
60
|
window.addEventListener('scroll', _this.didUpdate, true);
|
|
50
|
-
document.
|
|
61
|
+
document.addEventListener('mousedown', _this.handleClickOutside, true);
|
|
51
62
|
_this.initContentResizeObserver();
|
|
52
63
|
_this.startScrollHeightCheck();
|
|
53
64
|
setTimeout(function () {
|
|
@@ -70,7 +81,7 @@ var TriggerInternal = /*#__PURE__*/function (_React$Component) {
|
|
|
70
81
|
(0, _defineProperty2["default"])(_this, "cleanup", function () {
|
|
71
82
|
_event.winResetEvent.removeEvent(_this.resetId);
|
|
72
83
|
window.removeEventListener('scroll', _this.didUpdate, true);
|
|
73
|
-
document.
|
|
84
|
+
document.removeEventListener('mousedown', _this.handleClickOutside, true);
|
|
74
85
|
if (_this.resizeObserver) {
|
|
75
86
|
_this.resizeObserver.disconnect();
|
|
76
87
|
_this.resizeObserver = null;
|
|
@@ -105,7 +116,6 @@ var TriggerInternal = /*#__PURE__*/function (_React$Component) {
|
|
|
105
116
|
_this.didUpdate();
|
|
106
117
|
});
|
|
107
118
|
_this.contentResizeObserver.observe(targetNode);
|
|
108
|
-
// 额外监听图片加载
|
|
109
119
|
var images = targetNode.querySelectorAll('img');
|
|
110
120
|
images.forEach(function (img) {
|
|
111
121
|
if (!img.complete) {
|
|
@@ -137,7 +147,12 @@ var TriggerInternal = /*#__PURE__*/function (_React$Component) {
|
|
|
137
147
|
var _this$props$zIndex;
|
|
138
148
|
if (_this.popupContainer) return;
|
|
139
149
|
var container = document.createElement('span');
|
|
140
|
-
container.
|
|
150
|
+
container.setAttribute('data-sqb-popup-container', 'true');
|
|
151
|
+
container.setAttribute('data-sqb-popup-order', String(popupOrderSeed++));
|
|
152
|
+
var baseZIndex = Number((_this$props$zIndex = _this.props.zIndex) !== null && _this$props$zIndex !== void 0 ? _this$props$zIndex : 999);
|
|
153
|
+
var normalizedBaseZIndex = Number.isNaN(baseZIndex) ? 999 : baseZIndex;
|
|
154
|
+
var containerZIndex = Math.max(normalizedBaseZIndex, (0, _helperDom.getTopLayerZIndex)() + 1);
|
|
155
|
+
container.style.cssText = "\n position: absolute;\n top: 0;\n left: 0;\n pointer-events: none;\n z-index: ".concat(containerZIndex, ";\n opacity: 0;\n transition: opacity 0.2s ease;\n will-change: transform;\n ");
|
|
141
156
|
document.body.appendChild(container);
|
|
142
157
|
_this.popupContainer = container;
|
|
143
158
|
});
|
|
@@ -179,17 +194,12 @@ var TriggerInternal = /*#__PURE__*/function (_React$Component) {
|
|
|
179
194
|
innerSpacing = _this$props$innerSpac === void 0 ? 10 : _this$props$innerSpac,
|
|
180
195
|
_this$props$outSpacin = _this$props.outSpacing,
|
|
181
196
|
outSpacing = _this$props$outSpacin === void 0 ? 5 : _this$props$outSpacin;
|
|
182
|
-
// 假设 outSpacing 也是 props 或者常量,这里保持与你原代码一致,若未定义请确保其存在
|
|
183
|
-
// const outSpacing = this.props.outSpacing || 0;
|
|
184
197
|
var rect = node.getBoundingClientRect();
|
|
185
|
-
// --- 垂直方向逻辑 (保持原样) ---
|
|
186
198
|
var triggerTop = rect.top + window.scrollY;
|
|
187
|
-
var triggerLeft = rect.left + window.scrollX;
|
|
199
|
+
var triggerLeft = rect.left + window.scrollX;
|
|
188
200
|
var triggerHeight = rect.height;
|
|
189
201
|
var popupContent = _this.ref.current;
|
|
190
202
|
var realHeight = popupContent.scrollHeight;
|
|
191
|
-
// 获取弹窗的实际宽度,用于水平碰撞检测
|
|
192
|
-
// 注意:此时 popupContent 可能还没有被渲染到最终位置,但 scrollWidth 通常能反映内容宽度
|
|
193
203
|
var realWidth = popupContent.scrollWidth;
|
|
194
204
|
var _getWindowSize = (0, _helperDom.getWindowSize)(),
|
|
195
205
|
viewportHeight = _getWindowSize.height,
|
|
@@ -205,31 +215,15 @@ var TriggerInternal = /*#__PURE__*/function (_React$Component) {
|
|
|
205
215
|
maxHeight = Math.min(realHeight, spaceAbove - innerSpacing - outSpacing);
|
|
206
216
|
topPosition = triggerTop - innerSpacing - maxHeight;
|
|
207
217
|
}
|
|
208
|
-
// --- 水平方向逻辑 (新增) ---
|
|
209
218
|
var leftPosition = triggerLeft;
|
|
210
|
-
// 1. 检查是否超出右侧边界
|
|
211
219
|
if (leftPosition + realWidth > viewportWidth) {
|
|
212
|
-
// 如果超出,尝试向左移动,使弹窗右边缘对齐屏幕右边缘
|
|
213
220
|
leftPosition = viewportWidth - realWidth;
|
|
214
221
|
}
|
|
215
|
-
// 2. 检查是否超出左侧边界 (兜底策略)
|
|
216
|
-
// 如果弹窗太宽,或者触发点太靠左导致上面的计算结果小于0
|
|
217
222
|
if (leftPosition < 0) {
|
|
218
223
|
leftPosition = 0;
|
|
219
|
-
// 可选:如果弹窗比屏幕还宽,你可能希望限制它的最大宽度为屏幕宽度
|
|
220
|
-
// 此时需要重新计算 realWidth 或者直接限制样式
|
|
221
|
-
// 这里我们通过 CSS 的 maxWidth 来配合,或者在这里强制限制 width
|
|
222
|
-
// 如果必须通过 JS 控制宽度:
|
|
223
|
-
// popupContent.style.width = `${viewportWidth}px`;
|
|
224
|
-
// leftPosition = 0;
|
|
225
224
|
}
|
|
226
|
-
// --- 应用样式 ---
|
|
227
|
-
// 使用 transform 进行定位
|
|
228
225
|
_this.popupContainer.style.transform = "translate(".concat(leftPosition, "px, ").concat(topPosition, "px)");
|
|
229
|
-
// 设置最大高度
|
|
230
226
|
popupContent.style.maxHeight = "".concat(maxHeight, "px");
|
|
231
|
-
// 【重要】为了防止第2步中弹窗过宽超出屏幕,建议同时限制 popupContent 的最大宽度
|
|
232
|
-
// 这样即使 leftPosition=0,内容也不会撑破屏幕
|
|
233
227
|
popupContent.style.maxWidth = "".concat(viewportWidth - outSpacing * 2, "px");
|
|
234
228
|
});
|
|
235
229
|
_this.state = {
|
package/lib/cjs/hooks/patch.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import { MetaListType } from '../store/types';
|
|
|
2
2
|
export declare const joinDataPatch: (newMeta: any, constantList: any, formulaTemplates: any) => any;
|
|
3
3
|
export declare const filterPatch: (newMeta: any, constantList: any, formulaTemplates: any) => any;
|
|
4
4
|
export declare const customColumnPatch: (newMeta: any, constantList: any, formulaTemplates: any) => any;
|
|
5
|
+
export declare const summarizePatch: (newMeta: any, constantList: any, formulaTemplates: any) => any;
|
|
5
6
|
export declare const patchMetas: (items: MetaListType[], constantList: any[], formulaTemplates: any[]) => MetaListType[];
|
package/lib/cjs/hooks/patch.js
CHANGED
|
@@ -4,9 +4,33 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.patchMetas = exports.joinDataPatch = exports.filterPatch = exports.customColumnPatch = void 0;
|
|
7
|
+
exports.summarizePatch = exports.patchMetas = exports.joinDataPatch = exports.filterPatch = exports.customColumnPatch = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
9
9
|
var _enum = require("../store/enum");
|
|
10
|
+
var SQL_ALIAS_MAX_LENGTH = 30;
|
|
11
|
+
var normalizeSqlAlias = function normalizeSqlAlias() {
|
|
12
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
13
|
+
var index = arguments.length > 1 ? arguments[1] : undefined;
|
|
14
|
+
var fallbackAlias = "group_by_".concat(index + 1);
|
|
15
|
+
var alias = value.replace(/[^a-zA-Z0-9_]/g, '_').replace(/_+/g, '_').replace(/^_+|_+$/g, '');
|
|
16
|
+
if (!/^[a-zA-Z]/.test(alias)) {
|
|
17
|
+
alias = "a_".concat(alias.replace(/^[^a-zA-Z]+/, ''));
|
|
18
|
+
}
|
|
19
|
+
if (!/^[a-zA-Z]/.test(alias)) {
|
|
20
|
+
alias = fallbackAlias;
|
|
21
|
+
}
|
|
22
|
+
if (alias.length > SQL_ALIAS_MAX_LENGTH) {
|
|
23
|
+
var uniqueSuffix = "_".concat(index + 1);
|
|
24
|
+
var maxBaseLength = Math.max(1, SQL_ALIAS_MAX_LENGTH - uniqueSuffix.length);
|
|
25
|
+
alias = "".concat(alias.slice(0, maxBaseLength)).concat(uniqueSuffix);
|
|
26
|
+
}
|
|
27
|
+
return alias.slice(0, SQL_ALIAS_MAX_LENGTH);
|
|
28
|
+
};
|
|
29
|
+
var isValidSqlAlias = function isValidSqlAlias() {
|
|
30
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
31
|
+
if (!value) return true;
|
|
32
|
+
return /^[a-zA-Z][a-zA-Z0-9_]{0,29}$/.test(value);
|
|
33
|
+
};
|
|
10
34
|
var setConstantId = function setConstantId(item, constantList) {
|
|
11
35
|
constantList === null || constantList === void 0 || constantList.map(function (v) {
|
|
12
36
|
if (v.label === item.val) {
|
|
@@ -22,7 +46,6 @@ var setFormulaId = function setFormulaId(item, formulaTemplates) {
|
|
|
22
46
|
}
|
|
23
47
|
return item;
|
|
24
48
|
};
|
|
25
|
-
// 关联
|
|
26
49
|
var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta, constantList, formulaTemplates) {
|
|
27
50
|
var _newMeta$expressions;
|
|
28
51
|
newMeta.expressions = (_newMeta$expressions = newMeta.expressions) === null || _newMeta$expressions === void 0 ? void 0 : _newMeta$expressions.map(function (v, i) {
|
|
@@ -43,7 +66,6 @@ var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta, cons
|
|
|
43
66
|
});
|
|
44
67
|
return newMeta;
|
|
45
68
|
};
|
|
46
|
-
// 过滤器
|
|
47
69
|
var filterPatch = exports.filterPatch = function filterPatch(newMeta, constantList, formulaTemplates) {
|
|
48
70
|
var _newMeta$filter;
|
|
49
71
|
var _filter = (_newMeta$filter = newMeta.filter) === null || _newMeta$filter === void 0 ? void 0 : _newMeta$filter.map(function (v) {
|
|
@@ -79,7 +101,6 @@ var filterPatch = exports.filterPatch = function filterPatch(newMeta, constantLi
|
|
|
79
101
|
return arg;
|
|
80
102
|
});
|
|
81
103
|
return _v;
|
|
82
|
-
// return setFormulaId(v, formulaTemplates);
|
|
83
104
|
}
|
|
84
105
|
if (v.type === 'exists' || v.type === 'notExists') {
|
|
85
106
|
v.notExists = _patchMetas(v.notExists, constantList, formulaTemplates);
|
|
@@ -89,7 +110,6 @@ var filterPatch = exports.filterPatch = function filterPatch(newMeta, constantLi
|
|
|
89
110
|
newMeta.filter = _filter;
|
|
90
111
|
return newMeta;
|
|
91
112
|
};
|
|
92
|
-
// 自定义
|
|
93
113
|
var customColumnPatch = exports.customColumnPatch = function customColumnPatch(newMeta, constantList, formulaTemplates) {
|
|
94
114
|
var _newMeta$customColumn;
|
|
95
115
|
newMeta.customColumn = (newMeta === null || newMeta === void 0 || (_newMeta$customColumn = newMeta.customColumn) === null || _newMeta$customColumn === void 0 ? void 0 : _newMeta$customColumn.map(function (v) {
|
|
@@ -126,7 +146,82 @@ var customColumnPatch = exports.customColumnPatch = function customColumnPatch(n
|
|
|
126
146
|
})) || newMeta.customColumn;
|
|
127
147
|
return newMeta;
|
|
128
148
|
};
|
|
129
|
-
|
|
149
|
+
var summarizePatch = exports.summarizePatch = function summarizePatch(newMeta, constantList, formulaTemplates) {
|
|
150
|
+
var _newMeta$group, _newMeta$by;
|
|
151
|
+
newMeta.group = ((_newMeta$group = newMeta.group) === null || _newMeta$group === void 0 ? void 0 : _newMeta$group.map(function (item, index) {
|
|
152
|
+
var _item$atoms;
|
|
153
|
+
var atoms = (_item$atoms = item.atoms) === null || _item$atoms === void 0 ? void 0 : _item$atoms.map(function (formula) {
|
|
154
|
+
if (formula.type === 'expression') {
|
|
155
|
+
var _formula$lhs2, _formula$rhs2;
|
|
156
|
+
formula.lhs = (_formula$lhs2 = formula.lhs) === null || _formula$lhs2 === void 0 ? void 0 : _formula$lhs2.map(function (vv) {
|
|
157
|
+
if (vv.type === 'constant' && !vv.id) {
|
|
158
|
+
return setConstantId(vv, constantList);
|
|
159
|
+
}
|
|
160
|
+
return vv;
|
|
161
|
+
});
|
|
162
|
+
formula.rhs = (_formula$rhs2 = formula.rhs) === null || _formula$rhs2 === void 0 ? void 0 : _formula$rhs2.map(function (vv) {
|
|
163
|
+
if (vv.type === 'constant' && !vv.id) {
|
|
164
|
+
return setConstantId(vv, constantList);
|
|
165
|
+
}
|
|
166
|
+
return vv;
|
|
167
|
+
});
|
|
168
|
+
} else if (formula.type === 'constant' && !formula.id) {
|
|
169
|
+
return setConstantId(formula, constantList);
|
|
170
|
+
} else if (formula.type === 'FORMULA' && !formula.id) {
|
|
171
|
+
return setFormulaId(formula, formulaTemplates);
|
|
172
|
+
} else if (formula.type === 'exists' || formula.type === 'notExists') {
|
|
173
|
+
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, formula), {}, {
|
|
174
|
+
notExists: _patchMetas(formula.notExists, constantList, formulaTemplates)
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return formula;
|
|
178
|
+
});
|
|
179
|
+
var nextItem = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, item), {}, {
|
|
180
|
+
atoms: atoms
|
|
181
|
+
});
|
|
182
|
+
if (!isValidSqlAlias(nextItem.fieldAlias)) {
|
|
183
|
+
nextItem.fieldAlias = normalizeSqlAlias(nextItem.fieldAlias || nextItem.name || "group_".concat(index + 1), index);
|
|
184
|
+
}
|
|
185
|
+
return nextItem;
|
|
186
|
+
})) || newMeta.group;
|
|
187
|
+
newMeta.by = ((_newMeta$by = newMeta.by) === null || _newMeta$by === void 0 ? void 0 : _newMeta$by.map(function (item, index) {
|
|
188
|
+
var _item$atoms2;
|
|
189
|
+
var atoms = (_item$atoms2 = item.atoms) === null || _item$atoms2 === void 0 ? void 0 : _item$atoms2.map(function (formula) {
|
|
190
|
+
if (formula.type === 'expression') {
|
|
191
|
+
var _formula$lhs3, _formula$rhs3;
|
|
192
|
+
formula.lhs = (_formula$lhs3 = formula.lhs) === null || _formula$lhs3 === void 0 ? void 0 : _formula$lhs3.map(function (vv) {
|
|
193
|
+
if (vv.type === 'constant' && !vv.id) {
|
|
194
|
+
return setConstantId(vv, constantList);
|
|
195
|
+
}
|
|
196
|
+
return vv;
|
|
197
|
+
});
|
|
198
|
+
formula.rhs = (_formula$rhs3 = formula.rhs) === null || _formula$rhs3 === void 0 ? void 0 : _formula$rhs3.map(function (vv) {
|
|
199
|
+
if (vv.type === 'constant' && !vv.id) {
|
|
200
|
+
return setConstantId(vv, constantList);
|
|
201
|
+
}
|
|
202
|
+
return vv;
|
|
203
|
+
});
|
|
204
|
+
} else if (formula.type === 'constant' && !formula.id) {
|
|
205
|
+
return setConstantId(formula, constantList);
|
|
206
|
+
} else if (formula.type === 'FORMULA' && !formula.id) {
|
|
207
|
+
return setFormulaId(formula, formulaTemplates);
|
|
208
|
+
} else if (formula.type === 'exists' || formula.type === 'notExists') {
|
|
209
|
+
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, formula), {}, {
|
|
210
|
+
notExists: _patchMetas(formula.notExists, constantList, formulaTemplates)
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
return formula;
|
|
214
|
+
});
|
|
215
|
+
var nextItem = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, item), {}, {
|
|
216
|
+
atoms: atoms
|
|
217
|
+
});
|
|
218
|
+
if (!isValidSqlAlias(nextItem.fieldAlias)) {
|
|
219
|
+
nextItem.fieldAlias = normalizeSqlAlias(nextItem.fieldAlias || nextItem.name || "group_by_".concat(index + 1), index);
|
|
220
|
+
}
|
|
221
|
+
return nextItem;
|
|
222
|
+
})) || newMeta.by;
|
|
223
|
+
return newMeta;
|
|
224
|
+
};
|
|
130
225
|
var _patchMetas = exports.patchMetas = function patchMetas(items, constantList, formulaTemplates) {
|
|
131
226
|
return (items === null || items === void 0 ? void 0 : items.map(function (v) {
|
|
132
227
|
if (v.type === _enum.TypeEnum.joinData) {
|
|
@@ -138,6 +233,9 @@ var _patchMetas = exports.patchMetas = function patchMetas(items, constantList,
|
|
|
138
233
|
if (v.type === _enum.TypeEnum.customColumn) {
|
|
139
234
|
v = customColumnPatch(v, constantList, formulaTemplates);
|
|
140
235
|
}
|
|
236
|
+
if (v.type === _enum.TypeEnum.summarize) {
|
|
237
|
+
v = summarizePatch(v, constantList, formulaTemplates);
|
|
238
|
+
}
|
|
141
239
|
if (v.type === _enum.TypeEnum.union) {
|
|
142
240
|
v.subquery = _patchMetas(v.subquery || [], constantList, formulaTemplates);
|
|
143
241
|
}
|
package/lib/cjs/hooks/patch2.js
CHANGED
|
@@ -11,54 +11,19 @@ var _utils = require("../utils");
|
|
|
11
11
|
var _types = require("../store/types");
|
|
12
12
|
var _enum = require("../store/enum");
|
|
13
13
|
var dataPatch = exports.dataPatch = function dataPatch(newMeta) {
|
|
14
|
-
// let item = newMeta.expressions?.[0] || {};
|
|
15
|
-
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
16
|
-
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
17
|
-
// return newMeta;
|
|
18
|
-
// }
|
|
19
|
-
// }
|
|
20
14
|
newMeta.subquery = _patchMetas(newMeta.subquery);
|
|
21
15
|
return newMeta;
|
|
22
16
|
};
|
|
23
17
|
var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
24
18
|
var _fields, _fields2, _fields3, _fields4, _newMeta$expressions;
|
|
25
|
-
// let item = newMeta.expressions?.[0] || {};
|
|
26
|
-
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
27
|
-
// if (
|
|
28
|
-
// (item.type === AtomsTypeEnum.EXPRESSION || item.type === AtomsTypeEnum.JOIN_DEFAULT) &&
|
|
29
|
-
// item.lhs
|
|
30
|
-
// ) {
|
|
31
|
-
// return newMeta;
|
|
32
|
-
// }
|
|
33
|
-
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
34
|
-
// return newMeta;
|
|
35
|
-
// }
|
|
36
|
-
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
37
|
-
// return newMeta;
|
|
38
|
-
// }
|
|
39
|
-
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
40
|
-
// return newMeta;
|
|
41
|
-
// }
|
|
42
|
-
// }
|
|
43
|
-
// if (
|
|
44
|
-
// newMeta.expressions?.[0]?.type &&
|
|
45
|
-
// Object.values(AtomsTypeEnum).includes(newMeta.expressions[0].type)
|
|
46
|
-
// ) {
|
|
47
|
-
// return newMeta;
|
|
48
|
-
// }
|
|
49
19
|
var fields1 = newMeta.table1.fields || [];
|
|
50
20
|
var fields2 = newMeta.table2.fields || [];
|
|
51
|
-
// 处理老字段
|
|
52
21
|
var field1 = {
|
|
53
22
|
fieldAlias: newMeta.table1.fieldAlias || newMeta.table1.column || newMeta.table1.name,
|
|
54
23
|
fieldUuid: newMeta.table1.fieldUuid || (0, _helper.uuidv4)('field'),
|
|
55
24
|
fieldId: newMeta.table1.fieldId,
|
|
56
25
|
fieldNameZh: newMeta.table1.name_zh,
|
|
57
26
|
fieldName: newMeta.table1.fieldName || newMeta.table1.name
|
|
58
|
-
// quotes: newMeta.table1.quotes || newMeta.table1.column,
|
|
59
|
-
// tableUuid: newMeta.table1.tableUuid,
|
|
60
|
-
// tableId: newMeta.table1.datasourceId,
|
|
61
|
-
// tableAlias: newMeta.table1.alias,
|
|
62
27
|
};
|
|
63
28
|
var field2 = {
|
|
64
29
|
fieldAlias: newMeta.table2.fieldAlias || newMeta.table2.column || newMeta.table2.name,
|
|
@@ -67,53 +32,20 @@ var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
67
32
|
fieldNameZh: newMeta.table2.name_zh,
|
|
68
33
|
fieldName: newMeta.table2.fieldName || newMeta.table2.name
|
|
69
34
|
};
|
|
70
|
-
// 处理多选
|
|
71
35
|
if (field1.fieldAlias && ((_fields = fields1) === null || _fields === void 0 ? void 0 : _fields.length) < 1) {
|
|
72
36
|
fields1 = [(0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, field1), {}, {
|
|
73
|
-
// quotes: field1.quotes,
|
|
74
37
|
fieldUuid: field1.fieldUuid,
|
|
75
38
|
fieldAlias: field1.fieldAlias,
|
|
76
39
|
fieldId: field1.fieldId
|
|
77
|
-
// fieldNameZh: newMeta.table1.name_zh,
|
|
78
|
-
// fieldName: newMeta.table1.fieldName || newMeta.table1.name,
|
|
79
|
-
// tableAlias: newMeta.table1.alias,
|
|
80
|
-
// tableId: newMeta.table1.id,
|
|
81
|
-
// tableName: newMeta.table1.name,
|
|
82
|
-
// tableNameZh: newMeta.table1.name_zh,
|
|
83
|
-
// tableUuid: newMeta.table1.tableUuid,
|
|
84
|
-
// datasourceName: newMeta.table1.datasourceName, // 数据源名
|
|
85
|
-
// datasourceId: newMeta.table1.datasourceId, // 数据源id
|
|
86
40
|
})];
|
|
87
41
|
}
|
|
88
42
|
if (field2.fieldAlias && ((_fields2 = fields2) === null || _fields2 === void 0 ? void 0 : _fields2.length) < 1) {
|
|
89
43
|
fields2 = [(0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, field2), {}, {
|
|
90
|
-
// quotes: field2.quotes,
|
|
91
44
|
fieldUuid: field2.fieldUuid,
|
|
92
45
|
fieldAlias: field2.fieldAlias,
|
|
93
46
|
fieldId: field2.fieldId
|
|
94
|
-
// fieldNameZh: newMeta.table2.name_zh,
|
|
95
|
-
// fieldName: newMeta.table2.fieldName || newMeta.table2.name,
|
|
96
|
-
// tableAlias: newMeta.table2.alias,
|
|
97
|
-
// tableId: newMeta.table2.id,
|
|
98
|
-
// tableName: newMeta.table2.name,
|
|
99
|
-
// tableNameZh: newMeta.table2.name_zh,
|
|
100
|
-
// tableUuid: newMeta.table2.tableUuid,
|
|
101
|
-
// datasourceName: newMeta.table2.datasourceName, // 数据源名
|
|
102
|
-
// datasourceId: newMeta.table2.datasourceId, // 数据源id
|
|
103
47
|
})];
|
|
104
48
|
}
|
|
105
|
-
// newMeta.table1 = {
|
|
106
|
-
// ...newMeta.table1,
|
|
107
|
-
// ...field1,
|
|
108
|
-
// tableUuid: newMeta.table1.tableUuid || uuidv4('table'),
|
|
109
|
-
// fields: fields1,
|
|
110
|
-
// };
|
|
111
|
-
// newMeta.table2 = {
|
|
112
|
-
// ...newMeta.table2,
|
|
113
|
-
// ...field2,
|
|
114
|
-
// tableUuid: newMeta.table2.tableUuid || uuidv4('table'),
|
|
115
|
-
// fields: fields2,
|
|
116
|
-
// };
|
|
117
49
|
var beforeExpressions = [];
|
|
118
50
|
if (((_fields3 = fields1) === null || _fields3 === void 0 ? void 0 : _fields3.length) > 0 || ((_fields4 = fields2) === null || _fields4 === void 0 ? void 0 : _fields4.length) > 0) {
|
|
119
51
|
beforeExpressions = [{
|
|
@@ -126,17 +58,13 @@ var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
126
58
|
right_string: '',
|
|
127
59
|
right_fields: fields2 || [],
|
|
128
60
|
right_type: 'field',
|
|
129
|
-
type: 'default'
|
|
61
|
+
type: 'default'
|
|
130
62
|
}];
|
|
131
63
|
}
|
|
132
64
|
var expressions = ((_newMeta$expressions = newMeta.expressions) === null || _newMeta$expressions === void 0 ? void 0 : _newMeta$expressions.map(function (v) {
|
|
133
65
|
var _left_fields, _right_fields;
|
|
134
66
|
var left_fields = v.left_fields || [];
|
|
135
67
|
var right_fields = v.right_fields || [];
|
|
136
|
-
// if (v.type !== 'default') {
|
|
137
|
-
// return v;
|
|
138
|
-
// }
|
|
139
|
-
// 先处理老数据的字段
|
|
140
68
|
var left_field = {
|
|
141
69
|
left_fieldAlias: v.left_fieldAlias || v.left_column,
|
|
142
70
|
left_fieldUuid: v.left_fieldUuid || (0, _helper.uuidv4)('field'),
|
|
@@ -147,15 +75,11 @@ var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
147
75
|
right_fieldUuid: v.right_fieldUuid || (0, _helper.uuidv4)('field'),
|
|
148
76
|
right_quotes: v.right_quotes || v.right_column
|
|
149
77
|
};
|
|
150
|
-
// 再处理多选
|
|
151
78
|
if (left_field.left_fieldAlias && ((_left_fields = left_fields) === null || _left_fields === void 0 ? void 0 : _left_fields.length) < 1) {
|
|
152
79
|
left_fields = [{
|
|
153
80
|
fieldAlias: left_field.left_fieldAlias,
|
|
154
81
|
fieldUuid: left_field.left_fieldUuid,
|
|
155
82
|
quotes: left_field.left_quotes
|
|
156
|
-
// tableUuid: newMeta.table1.tableUuid,
|
|
157
|
-
// tableId: newMeta.table1.datasourceId,
|
|
158
|
-
// tableAlias: newMeta.table1.alias,
|
|
159
83
|
}];
|
|
160
84
|
}
|
|
161
85
|
if (right_field.right_fieldAlias && ((_right_fields = right_fields) === null || _right_fields === void 0 ? void 0 : _right_fields.length) < 1) {
|
|
@@ -163,9 +87,6 @@ var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
163
87
|
fieldAlias: right_field.right_fieldAlias,
|
|
164
88
|
fieldUuid: right_field.right_fieldUuid,
|
|
165
89
|
quotes: right_field.right_quotes
|
|
166
|
-
// tableUuid: newMeta.table2.tableUuid,
|
|
167
|
-
// tableId: newMeta.table2.datasourceId,
|
|
168
|
-
// tableAlias: newMeta.table2.alias,
|
|
169
90
|
}];
|
|
170
91
|
}
|
|
171
92
|
return {
|
|
@@ -178,7 +99,7 @@ var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
178
99
|
right_string: v.right_string || '',
|
|
179
100
|
right_fields: right_fields,
|
|
180
101
|
right_type: v.right_type || '',
|
|
181
|
-
type: v.type || 'default'
|
|
102
|
+
type: v.type || 'default'
|
|
182
103
|
};
|
|
183
104
|
})) || [];
|
|
184
105
|
var _expressions = beforeExpressions.concat(expressions);
|
|
@@ -208,9 +129,7 @@ var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
208
129
|
tableNameZh: newMeta.table1.name_zh,
|
|
209
130
|
tableUuid: newMeta.table1.tableUuid,
|
|
210
131
|
datasourceName: newMeta.table1.datasourceName,
|
|
211
|
-
// 数据源名
|
|
212
132
|
datasourceId: newMeta.table1.datasourceId,
|
|
213
|
-
// 数据源id
|
|
214
133
|
type: _types.AtomsTypeEnum.FIELD
|
|
215
134
|
}, vv);
|
|
216
135
|
});
|
|
@@ -237,9 +156,7 @@ var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
237
156
|
tableNameZh: newMeta.table2.name_zh,
|
|
238
157
|
tableUuid: newMeta.table2.tableUuid,
|
|
239
158
|
datasourceName: newMeta.table2.datasourceName,
|
|
240
|
-
// 数据源名
|
|
241
159
|
datasourceId: newMeta.table2.datasourceId,
|
|
242
|
-
// 数据源id
|
|
243
160
|
type: _types.AtomsTypeEnum.FIELD
|
|
244
161
|
}, vv);
|
|
245
162
|
});
|
|
@@ -247,9 +164,7 @@ var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
247
164
|
var item = {
|
|
248
165
|
lhs: lhs,
|
|
249
166
|
rhs: rhs,
|
|
250
|
-
// database_type: '',
|
|
251
167
|
condition: '',
|
|
252
|
-
// quotes: '',
|
|
253
168
|
type: _types.AtomsTypeEnum.JOIN_DEFAULT
|
|
254
169
|
};
|
|
255
170
|
newExpressions.push(item);
|
|
@@ -261,9 +176,7 @@ var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
261
176
|
}
|
|
262
177
|
return item;
|
|
263
178
|
});
|
|
264
|
-
// 清除table1中不用字段
|
|
265
179
|
delete newMeta.table1.fields;
|
|
266
|
-
// 清除table2中不用字段
|
|
267
180
|
delete newMeta.table2.fields;
|
|
268
181
|
newMeta.subquery = _patchMetas(newMeta.subquery);
|
|
269
182
|
newMeta.expressions = newExpressions;
|
|
@@ -271,23 +184,7 @@ var joinDataPatch = exports.joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
271
184
|
};
|
|
272
185
|
var filterPatch = exports.filterPatch = function filterPatch(newMeta) {
|
|
273
186
|
var _newMeta$filter;
|
|
274
|
-
// let item = newMeta.filter?.[0] || {};
|
|
275
|
-
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
276
|
-
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
277
|
-
// return newMeta;
|
|
278
|
-
// }
|
|
279
|
-
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
280
|
-
// return newMeta;
|
|
281
|
-
// }
|
|
282
|
-
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
283
|
-
// return newMeta;
|
|
284
|
-
// }
|
|
285
|
-
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
286
|
-
// return newMeta;
|
|
287
|
-
// }
|
|
288
|
-
// }
|
|
289
187
|
var _filter = (_newMeta$filter = newMeta.filter) === null || _newMeta$filter === void 0 ? void 0 : _newMeta$filter.map(function (v) {
|
|
290
|
-
// 表达式
|
|
291
188
|
var tem;
|
|
292
189
|
if (typeof v === 'string') {
|
|
293
190
|
return {
|
|
@@ -379,21 +276,6 @@ var filterPatch = exports.filterPatch = function filterPatch(newMeta) {
|
|
|
379
276
|
};
|
|
380
277
|
var customColumnPatch = exports.customColumnPatch = function customColumnPatch(newMeta) {
|
|
381
278
|
var _newMeta$customColumn;
|
|
382
|
-
// let item = newMeta.customColumn?.[0]?.formulaList?.[0] || {};
|
|
383
|
-
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
384
|
-
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
385
|
-
// return newMeta;
|
|
386
|
-
// }
|
|
387
|
-
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
388
|
-
// return newMeta;
|
|
389
|
-
// }
|
|
390
|
-
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
391
|
-
// return newMeta;
|
|
392
|
-
// }
|
|
393
|
-
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
394
|
-
// return newMeta;
|
|
395
|
-
// }
|
|
396
|
-
// }
|
|
397
279
|
newMeta.customColumn = (newMeta === null || newMeta === void 0 || (_newMeta$customColumn = newMeta.customColumn) === null || _newMeta$customColumn === void 0 ? void 0 : _newMeta$customColumn.map(function (v) {
|
|
398
280
|
var _formulaList = v.formulaList.map(function (formula) {
|
|
399
281
|
var tem = formula;
|
|
@@ -413,7 +295,6 @@ var customColumnPatch = exports.customColumnPatch = function customColumnPatch(n
|
|
|
413
295
|
tableUuid: formula.expression.table2.tableUuid,
|
|
414
296
|
datasourceName: formula.expression.table2.datasourceName,
|
|
415
297
|
datasourceId: formula.expression.table2.datasourceId,
|
|
416
|
-
// quotes: formula.expression.table2.quotes,
|
|
417
298
|
type: _types.AtomsTypeEnum.FIELD
|
|
418
299
|
}];
|
|
419
300
|
} else if (formula.expression.valType === 'constant') {
|
|
@@ -451,7 +332,6 @@ var customColumnPatch = exports.customColumnPatch = function customColumnPatch(n
|
|
|
451
332
|
tableUuid: formula.expression.tableUuid,
|
|
452
333
|
datasourceName: formula.expression.datasourceName,
|
|
453
334
|
datasourceId: formula.expression.datasourceId,
|
|
454
|
-
// quotes: formula.expression.name,
|
|
455
335
|
type: _types.AtomsTypeEnum.FIELD
|
|
456
336
|
}],
|
|
457
337
|
rhs: rhs,
|
|
@@ -475,7 +355,6 @@ var customColumnPatch = exports.customColumnPatch = function customColumnPatch(n
|
|
|
475
355
|
tableUuid: formula.expression.tableUuid,
|
|
476
356
|
datasourceName: formula.expression.datasourceName,
|
|
477
357
|
datasourceId: formula.expression.datasourceId,
|
|
478
|
-
// quotes: formula.expression.quotes,
|
|
479
358
|
type: _types.AtomsTypeEnum.FIELD
|
|
480
359
|
};
|
|
481
360
|
} else if (formula.type === 'operator') {
|
|
@@ -494,7 +373,6 @@ var customColumnPatch = exports.customColumnPatch = function customColumnPatch(n
|
|
|
494
373
|
type: _types.AtomsTypeEnum.INPUT_STRING
|
|
495
374
|
};
|
|
496
375
|
} else if (formula.type === 'notExists') {
|
|
497
|
-
//应该是多余
|
|
498
376
|
return {
|
|
499
377
|
notExists: v.expression.notExists,
|
|
500
378
|
quotes: v.expression.quotes,
|
|
@@ -512,21 +390,6 @@ var customColumnPatch = exports.customColumnPatch = function customColumnPatch(n
|
|
|
512
390
|
};
|
|
513
391
|
var sortPatch = exports.sortPatch = function sortPatch(newMeta) {
|
|
514
392
|
var _newMeta$sort;
|
|
515
|
-
// let item = newMeta.sort?.[0].expression?.[0] || {};
|
|
516
|
-
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
517
|
-
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
518
|
-
// return newMeta;
|
|
519
|
-
// }
|
|
520
|
-
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
521
|
-
// return newMeta;
|
|
522
|
-
// }
|
|
523
|
-
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
524
|
-
// return newMeta;
|
|
525
|
-
// }
|
|
526
|
-
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
527
|
-
// return newMeta;
|
|
528
|
-
// }
|
|
529
|
-
// }
|
|
530
393
|
var _sort = (_newMeta$sort = newMeta.sort) === null || _newMeta$sort === void 0 ? void 0 : _newMeta$sort.map(function (v) {
|
|
531
394
|
return {
|
|
532
395
|
expression: [{
|
|
@@ -572,29 +435,4 @@ var _patchMetas = exports.patchMetas = function patchMetas(items) {
|
|
|
572
435
|
}
|
|
573
436
|
return v;
|
|
574
437
|
})) || [];
|
|
575
|
-
};
|
|
576
|
-
// export const patchMetas1 = (items: MetaListType[]) => {
|
|
577
|
-
// return (
|
|
578
|
-
// items?.map((v: MetaListType): MetaListType => {
|
|
579
|
-
// // if (v.type === TypeEnum.data) {
|
|
580
|
-
// // v = dataPatch(v);
|
|
581
|
-
// // }
|
|
582
|
-
// // if (v.type === TypeEnum.joinData) {
|
|
583
|
-
// // v = joinDataPatch(v);
|
|
584
|
-
// // }
|
|
585
|
-
// // if (v.type === TypeEnum.filter) {
|
|
586
|
-
// // v = filterPatch(v);
|
|
587
|
-
// // }
|
|
588
|
-
// // if (v.type === TypeEnum.sort) {
|
|
589
|
-
// // v = sortPatch(v);
|
|
590
|
-
// // }
|
|
591
|
-
// // if (v.type === TypeEnum.customColumn) {
|
|
592
|
-
// // v = customColumnPatch(v);
|
|
593
|
-
// // }
|
|
594
|
-
// if (v.type === TypeEnum.union) {
|
|
595
|
-
// v.subquery = patchMetas(v.subquery || []);
|
|
596
|
-
// }
|
|
597
|
-
// return v;
|
|
598
|
-
// }) || []
|
|
599
|
-
// );
|
|
600
|
-
// };
|
|
438
|
+
};
|
|
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useStore = exports.Provider = void 0;
|
|
7
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
// 创建 Context
|
|
10
9
|
var Context = (0, _react.createContext)({});
|
|
11
|
-
// 创建 Provider 组件
|
|
12
10
|
var Provider = exports.Provider = function Provider(_ref) {
|
|
13
11
|
var value = _ref.value,
|
|
14
12
|
children = _ref.children;
|
|
@@ -17,7 +15,6 @@ var Provider = exports.Provider = function Provider(_ref) {
|
|
|
17
15
|
children: children
|
|
18
16
|
});
|
|
19
17
|
};
|
|
20
|
-
// 自定义 Hook 来使用 Context
|
|
21
18
|
var useStore = exports.useStore = function useStore() {
|
|
22
19
|
return (0, _react.useContext)(Context);
|
|
23
20
|
};
|