@gingkoo/pandora-metabase 1.0.93 → 1.0.95

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.
@@ -185,10 +185,14 @@ var useStore = function useStore() {
185
185
  _useState66 = _slicedToArray(_useState65, 2),
186
186
  isMetabaseCopy = _useState66[0],
187
187
  setIsMetabaseCopy = _useState66[1]; // 是否开启勾选组复制
188
- var _useState67 = useState(storage._metabaseCopyModule || []),
188
+ var _useState67 = useState([]),
189
189
  _useState68 = _slicedToArray(_useState67, 2),
190
- metabaseCopyModule = _useState68[0],
191
- setMetabaseCopyModule = _useState68[1]; // 复制的内容
190
+ existsError = _useState68[0],
191
+ setExistsError = _useState68[1]; // exists 的错误字段
192
+ var _useState69 = useState(storage._metabaseCopyModule || []),
193
+ _useState70 = _slicedToArray(_useState69, 2),
194
+ metabaseCopyModule = _useState70[0],
195
+ setMetabaseCopyModule = _useState70[1]; // 复制的内容
192
196
  var setFormulaTemplates = function setFormulaTemplates(data) {
193
197
  var newData = data === null || data === void 0 ? void 0 : data.map(function (v) {
194
198
  var children = v.children.map(function (vv) {
@@ -214,40 +218,69 @@ var useStore = function useStore() {
214
218
  var fetchColumnsFn = useRef();
215
219
  var fetchChangeFn = useRef();
216
220
  var fetchDiffFn = useRef();
221
+ var fetchExistsError = useRef();
217
222
  var setFetchChangeFn = function setFetchChangeFn(fn) {
218
223
  fetchChangeFn.current = fn;
219
224
  };
220
225
  var setFetchDiffFn = function setFetchDiffFn(fn) {
221
226
  fetchDiffFn.current = fn;
222
227
  };
228
+ var setExistsErrorFn = /*#__PURE__*/function () {
229
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(fn, value) {
230
+ var data;
231
+ return _regeneratorRuntime.wrap(function (_context) {
232
+ while (1) switch (_context.prev = _context.next) {
233
+ case 0:
234
+ if (!(!value || value.length < 1)) {
235
+ _context.next = 1;
236
+ break;
237
+ }
238
+ setExistsError([]);
239
+ return _context.abrupt("return");
240
+ case 1:
241
+ _context.next = 2;
242
+ return fn(value);
243
+ case 2:
244
+ data = _context.sent;
245
+ setExistsError(data || []);
246
+ case 3:
247
+ case "end":
248
+ return _context.stop();
249
+ }
250
+ }, _callee);
251
+ }));
252
+ return function setExistsErrorFn(_x, _x2) {
253
+ return _ref.apply(this, arguments);
254
+ };
255
+ }();
223
256
  // 获取所有数据表
224
257
  var getModuleDiffCode = /*#__PURE__*/function () {
225
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
258
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
226
259
  var oldCode,
227
260
  newCode,
228
261
  data,
229
- _args = arguments;
230
- return _regeneratorRuntime.wrap(function (_context) {
231
- while (1) switch (_context.prev = _context.next) {
262
+ _args2 = arguments;
263
+ return _regeneratorRuntime.wrap(function (_context2) {
264
+ while (1) switch (_context2.prev = _context2.next) {
232
265
  case 0:
233
- oldCode = _args.length > 0 && _args[0] !== undefined ? _args[0] : [];
234
- newCode = _args.length > 1 ? _args[1] : undefined;
235
- _context.next = 1;
266
+ oldCode = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : [];
267
+ newCode = _args2.length > 1 ? _args2[1] : undefined;
268
+ _context2.next = 1;
236
269
  return fetchDiffFn.current({
237
270
  oldCode: oldCode,
238
271
  newCode: newCode
239
272
  });
240
273
  case 1:
241
- data = _context.sent;
242
- return _context.abrupt("return", data);
274
+ data = _context2.sent;
275
+ return _context2.abrupt("return", data);
243
276
  case 2:
244
277
  case "end":
245
- return _context.stop();
278
+ return _context2.stop();
246
279
  }
247
- }, _callee);
280
+ }, _callee2);
248
281
  }));
249
282
  return function getModuleDiffCode() {
250
- return _ref.apply(this, arguments);
283
+ return _ref2.apply(this, arguments);
251
284
  };
252
285
  }();
253
286
  var setFetchColumnsFn = function setFetchColumnsFn(fn) {
@@ -288,46 +321,46 @@ var useStore = function useStore() {
288
321
  }, [sourceList, isExit, tableFlat]);
289
322
  // 获取所有数据表
290
323
  var getSourceTable = /*#__PURE__*/function () {
291
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(source) {
324
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(source) {
292
325
  var results;
293
- return _regeneratorRuntime.wrap(function (_context3) {
294
- while (1) switch (_context3.prev = _context3.next) {
326
+ return _regeneratorRuntime.wrap(function (_context4) {
327
+ while (1) switch (_context4.prev = _context4.next) {
295
328
  case 0:
296
- _context3.next = 1;
329
+ _context4.next = 1;
297
330
  return Promise.all(source.map(/*#__PURE__*/function () {
298
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(v) {
331
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(v) {
299
332
  var tables;
300
- return _regeneratorRuntime.wrap(function (_context2) {
301
- while (1) switch (_context2.prev = _context2.next) {
333
+ return _regeneratorRuntime.wrap(function (_context3) {
334
+ while (1) switch (_context3.prev = _context3.next) {
302
335
  case 0:
303
- _context2.next = 1;
336
+ _context3.next = 1;
304
337
  return fetchDataset(v.datasourceId);
305
338
  case 1:
306
- tables = _context2.sent;
307
- return _context2.abrupt("return", _objectSpread(_objectSpread({}, v), {}, {
339
+ tables = _context3.sent;
340
+ return _context3.abrupt("return", _objectSpread(_objectSpread({}, v), {}, {
308
341
  children: tables
309
342
  }));
310
343
  case 2:
311
344
  case "end":
312
- return _context2.stop();
345
+ return _context3.stop();
313
346
  }
314
- }, _callee2);
347
+ }, _callee3);
315
348
  }));
316
- return function (_x2) {
317
- return _ref3.apply(this, arguments);
349
+ return function (_x4) {
350
+ return _ref4.apply(this, arguments);
318
351
  };
319
352
  }()));
320
353
  case 1:
321
- results = _context3.sent;
354
+ results = _context4.sent;
322
355
  setSourceTable(results || []);
323
356
  case 2:
324
357
  case "end":
325
- return _context3.stop();
358
+ return _context4.stop();
326
359
  }
327
- }, _callee3);
360
+ }, _callee4);
328
361
  }));
329
- return function getSourceTable(_x) {
330
- return _ref2.apply(this, arguments);
362
+ return function getSourceTable(_x3) {
363
+ return _ref3.apply(this, arguments);
331
364
  };
332
365
  }();
333
366
  // const showMainColumn = useMemo(() => {
@@ -346,41 +379,41 @@ var useStore = function useStore() {
346
379
  return !!~toolbar.indexOf(name);
347
380
  };
348
381
  var fetchDataset = /*#__PURE__*/function () {
349
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(datasourceId) {
382
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(datasourceId) {
350
383
  var tables, _tables;
351
- return _regeneratorRuntime.wrap(function (_context4) {
352
- while (1) switch (_context4.prev = _context4.next) {
384
+ return _regeneratorRuntime.wrap(function (_context5) {
385
+ while (1) switch (_context5.prev = _context5.next) {
353
386
  case 0:
354
387
  tables = getDataset(datasourceId);
355
388
  if (!tables.length) {
356
- _context4.next = 1;
389
+ _context5.next = 1;
357
390
  break;
358
391
  }
359
- return _context4.abrupt("return", tables);
392
+ return _context5.abrupt("return", tables);
360
393
  case 1:
361
- _context4.next = 2;
394
+ _context5.next = 2;
362
395
  return fetchDatasetFn.current(datasourceId, {
363
396
  isExit: isExit
364
397
  });
365
398
  case 2:
366
- _tables = _context4.sent;
399
+ _tables = _context5.sent;
367
400
  setDataset(datasourceId, _tables);
368
- return _context4.abrupt("return", _tables);
401
+ return _context5.abrupt("return", _tables);
369
402
  case 3:
370
403
  case "end":
371
- return _context4.stop();
404
+ return _context5.stop();
372
405
  }
373
- }, _callee4);
406
+ }, _callee5);
374
407
  }));
375
- return function fetchDataset(_x3) {
376
- return _ref4.apply(this, arguments);
408
+ return function fetchDataset(_x5) {
409
+ return _ref5.apply(this, arguments);
377
410
  };
378
411
  }();
379
412
  // 根据数据源id查询集合列表
380
413
  // fetchDataset():
381
414
  // 查询表字段
382
415
  var fetchColumns = /*#__PURE__*/function () {
383
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(table, datasourceId) {
416
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(table, datasourceId) {
384
417
  var _columns2;
385
418
  var oldColumns,
386
419
  callback,
@@ -398,15 +431,15 @@ var useStore = function useStore() {
398
431
  tableName,
399
432
  columns,
400
433
  _columns,
401
- _args5 = arguments;
402
- return _regeneratorRuntime.wrap(function (_context5) {
403
- while (1) switch (_context5.prev = _context5.next) {
434
+ _args6 = arguments;
435
+ return _regeneratorRuntime.wrap(function (_context6) {
436
+ while (1) switch (_context6.prev = _context6.next) {
404
437
  case 0:
405
- oldColumns = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : [];
406
- callback = _args5.length > 3 ? _args5[3] : undefined;
407
- isSelect = _args5.length > 4 && _args5[4] !== undefined ? _args5[4] : isSelectFields;
408
- _isSubquery = _args5.length > 5 && _args5[5] !== undefined ? _args5[5] : isSubquery;
409
- _isExit = _args5.length > 6 && _args5[6] !== undefined ? _args5[6] : isExit;
438
+ oldColumns = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : [];
439
+ callback = _args6.length > 3 ? _args6[3] : undefined;
440
+ isSelect = _args6.length > 4 && _args6[4] !== undefined ? _args6[4] : isSelectFields;
441
+ _isSubquery = _args6.length > 5 && _args6[5] !== undefined ? _args6[5] : isSubquery;
442
+ _isExit = _args6.length > 6 && _args6[6] !== undefined ? _args6[6] : isExit;
410
443
  // 获取之前选中的数据
411
444
  oldObj = {};
412
445
  selectId = oldColumns.filter(function (v) {
@@ -425,15 +458,15 @@ var useStore = function useStore() {
425
458
  tableName = table.name;
426
459
  columns = getColumns(tableName);
427
460
  if (columns.length) {
428
- _context5.next = 2;
461
+ _context6.next = 2;
429
462
  break;
430
463
  }
431
- _context5.next = 1;
464
+ _context6.next = 1;
432
465
  return fetchColumnsFn.current(extra, datasourceId, {
433
466
  isExit: _isExit
434
467
  });
435
468
  case 1:
436
- columns = _context5.sent;
469
+ columns = _context6.sent;
437
470
  setColumns(tableName, columns);
438
471
  case 2:
439
472
  _columns = (_columns2 = columns) === null || _columns2 === void 0 ? void 0 : _columns2.map(function (v) {
@@ -448,26 +481,26 @@ var useStore = function useStore() {
448
481
  typeof callback === 'function' && callback(_columns);
449
482
  case 3:
450
483
  case "end":
451
- return _context5.stop();
484
+ return _context6.stop();
452
485
  }
453
- }, _callee5);
486
+ }, _callee6);
454
487
  }));
455
- return function fetchColumns(_x4, _x5) {
456
- return _ref5.apply(this, arguments);
488
+ return function fetchColumns(_x6, _x7) {
489
+ return _ref6.apply(this, arguments);
457
490
  };
458
491
  }();
459
492
  var setMeta = /*#__PURE__*/function () {
460
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(curData, groupInd) {
493
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(curData, groupInd) {
461
494
  var changeObj,
462
495
  _metaList,
463
496
  newMeta,
464
497
  isChange,
465
- _args6 = arguments;
466
- return _regeneratorRuntime.wrap(function (_context6) {
467
- while (1) switch (_context6.prev = _context6.next) {
498
+ _args7 = arguments;
499
+ return _regeneratorRuntime.wrap(function (_context7) {
500
+ while (1) switch (_context7.prev = _context7.next) {
468
501
  case 0:
469
- changeObj = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
470
- _metaList = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : metaList;
502
+ changeObj = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : {};
503
+ _metaList = _args7.length > 3 && _args7[3] !== undefined ? _args7[3] : metaList;
471
504
  newMeta = cloneDeep(_metaList);
472
505
  if (newMeta[groupInd]) {
473
506
  newMeta[groupInd].list = curData;
@@ -475,29 +508,29 @@ var useStore = function useStore() {
475
508
  }
476
509
  // 过滤掉初始化
477
510
  if (!(changeObj === 'init')) {
478
- _context6.next = 1;
511
+ _context7.next = 1;
479
512
  break;
480
513
  }
481
- return _context6.abrupt("return");
514
+ return _context7.abrupt("return");
482
515
  case 1:
483
- _context6.next = 2;
516
+ _context7.next = 2;
484
517
  return fetchChangeFn.current(splitByUnion(_metaList), changeObj, {
485
518
  isExit: isExit
486
519
  });
487
520
  case 2:
488
- isChange = _context6.sent;
521
+ isChange = _context7.sent;
489
522
  // 是否还原
490
523
  if (isChange === false) {
491
524
  _setMeta(_metaList);
492
525
  }
493
526
  case 3:
494
527
  case "end":
495
- return _context6.stop();
528
+ return _context7.stop();
496
529
  }
497
- }, _callee6);
530
+ }, _callee7);
498
531
  }));
499
- return function setMeta(_x6, _x7) {
500
- return _ref6.apply(this, arguments);
532
+ return function setMeta(_x8, _x9) {
533
+ return _ref7.apply(this, arguments);
501
534
  };
502
535
  }();
503
536
  // 回显
@@ -872,7 +905,9 @@ var useStore = function useStore() {
872
905
  isMetabaseCopy: isMetabaseCopy,
873
906
  setIsMetabaseCopy: setIsMetabaseCopy,
874
907
  operatorList: operatorList,
875
- setOperatorList: setOperatorList
908
+ setOperatorList: setOperatorList,
909
+ setExistsErrorFn: setExistsErrorFn,
910
+ existsError: existsError
876
911
  };
877
912
  };
878
913
  export default useStore;
package/lib/es/index.d.ts CHANGED
@@ -3,12 +3,6 @@ import './locale/en';
3
3
  import './locale/zh';
4
4
  import type { MetabaseProps, SqlVisionBuilderRef, DatasourceType } from './types';
5
5
  import type { MetaListType, ToolbarType } from './store/types';
6
- /**
7
- * 规则
8
- * 1、主表一换 下面全部删除
9
- * 2、关联如果动了表或者删除了 下面的关联都删除
10
- * 3、关联如果动了表或者删除了 下面对应排序用到的对应的字段也删除 todo. 未完成 因为有可能关联里面选一样的表 还不知道怎么搞
11
- */
12
6
  declare const SqlVisionBuilder: React.ForwardRefExoticComponent<MetabaseProps & React.RefAttributes<SqlVisionBuilderRef>>;
13
7
  export default SqlVisionBuilder;
14
8
  export { MetabaseProps, DatasourceType, MetaListType, ToolbarType, SqlVisionBuilderRef };
package/lib/es/index.js CHANGED
@@ -17,6 +17,7 @@ import cloneDeep from 'lodash/cloneDeep';
17
17
  * 2、关联如果动了表或者删除了 下面的关联都删除
18
18
  * 3、关联如果动了表或者删除了 下面对应排序用到的对应的字段也删除 todo. 未完成 因为有可能关联里面选一样的表 还不知道怎么搞
19
19
  */
20
+ var EMPTY_ARRAY = [];
20
21
  var SqlVisionBuilder = React.forwardRef(function (props, ref) {
21
22
  var _props$loading = props.loading,
22
23
  loading = _props$loading === void 0 ? false : _props$loading,
@@ -26,6 +27,7 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
26
27
  getColumns = props.getColumns,
27
28
  onChange = props.onChange,
28
29
  getModuleDiffCode = props.getModuleDiffCode,
30
+ getExistsError = props.getExistsError,
29
31
  _props$tableNameTpl = props.tableNameTpl,
30
32
  tableNameTpl = _props$tableNameTpl === void 0 ? '${name}' : _props$tableNameTpl,
31
33
  _props$fieldNameTpl = props.fieldNameTpl,
@@ -33,11 +35,11 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
33
35
  _props$toolbar = props.toolbar,
34
36
  toolbar = _props$toolbar === void 0 ? ['filter', 'summarize', 'joinData', 'customColumn', 'sort', 'rowLimit'] : _props$toolbar,
35
37
  _props$value = props.value,
36
- value = _props$value === void 0 ? [] : _props$value,
38
+ value = _props$value === void 0 ? EMPTY_ARRAY : _props$value,
37
39
  _props$sourceList = props.sourceList,
38
- sourceList = _props$sourceList === void 0 ? [] : _props$sourceList,
40
+ sourceList = _props$sourceList === void 0 ? EMPTY_ARRAY : _props$sourceList,
39
41
  _props$exitSourceList = props.exitSourceList,
40
- exitSourceList = _props$exitSourceList === void 0 ? [] : _props$exitSourceList,
42
+ exitSourceList = _props$exitSourceList === void 0 ? EMPTY_ARRAY : _props$exitSourceList,
41
43
  _props$showSubquery = props.showSubquery,
42
44
  showSubquery = _props$showSubquery === void 0 ? true : _props$showSubquery,
43
45
  _props$subShowSubquer = props.subShowSubquery,
@@ -70,7 +72,7 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
70
72
  _props$moduleCopy = props.moduleCopy,
71
73
  moduleCopy = _props$moduleCopy === void 0 ? false : _props$moduleCopy,
72
74
  _props$operatorList = props.operatorList,
73
- operatorList = _props$operatorList === void 0 ? [] : _props$operatorList;
75
+ operatorList = _props$operatorList === void 0 ? EMPTY_ARRAY : _props$operatorList;
74
76
  var store = useData();
75
77
  useEffect(function () {
76
78
  getTables && store.setFetchDatasetFn(getTables);
@@ -86,6 +88,7 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
86
88
  var source_value = patchData(value);
87
89
  store.setPreData(cloneDeep(_value), isSubquery, isExit);
88
90
  store.setSourceData(source_value);
91
+ getExistsError && store.setExistsErrorFn(getExistsError, value);
89
92
  }, [value]);
90
93
  useEffect(function () {
91
94
  store.setSourceList(isExit && exitSourceList && Array.from(exitSourceList).length > 0 ? exitSourceList || sourceList : sourceList);
@@ -112,7 +115,7 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
112
115
  store.setModuleDiff(moduleDiff);
113
116
  store.setIsSubquery(isSubquery);
114
117
  store.setModuleCopy(moduleCopy);
115
- store.setOperatorList(operatorList);
118
+ store.setOperatorList(operatorList || []);
116
119
  }, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType, isExit, tableEnableAlias, fieldEnableAlias, groupByEnableAlias, isSelectFields, tableFlat, copyType, metabaseCopy, moduleDiff, isSubquery, moduleCopy, operatorList]);
117
120
  React.useImperativeHandle(ref, function () {
118
121
  return {
package/lib/es/types.d.ts CHANGED
@@ -59,6 +59,7 @@ export interface MetabaseProps {
59
59
  oldCode: string;
60
60
  newCode: string;
61
61
  }>;
62
+ getExistsError?: (params: MetaListType[]) => Promise<any[]>;
62
63
  operatorList?: any[];
63
64
  }
64
65
  export interface OptionItem {
package/lib/es/utils.d.ts CHANGED
@@ -30,6 +30,14 @@ export declare const patchData: (metas: MetaListType[]) => MetaListType[];
30
30
  export declare function reassembleByUnion(target?: any[]): any[];
31
31
  export declare const buildSqlQuery: (data: MetaListType[] | undefined, type: string) => string;
32
32
  export declare const isError: (item: AtomsItem | AtomsItem[], data: DataType[]) => boolean;
33
+ /**
34
+ * 在嵌套结构 root 中查找是否存在一个对象,使得 target 是该对象的子集
35
+ * @param root 可能包含任意层数组/对象的根数据
36
+ * @param target 目标对象(可能只包含部分字段)
37
+ * @returns 是否存在
38
+ */
39
+ export declare function containsSubset(root: unknown, target: Record<string, unknown>): boolean;
40
+ export declare const isExistsError: (meta: any[], errorList: any[]) => boolean;
33
41
  export declare const changeCopyField: (items: AtomsItem[], data: any[]) => AtomsItem[];
34
42
  export declare const changeExistsCopyField: (list: MetaListType[], data: any[]) => MetaListType[];
35
43
  export declare const metaIsCheck: (data: any[], item: any) => boolean;
package/lib/es/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
1
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
3
  import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
3
4
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
@@ -767,15 +768,102 @@ var _isError = function isError(item, data) {
767
768
  }
768
769
  return false; // 其他类型默认无错误
769
770
  };
770
- // 设置新字段信息
771
+ /**
772
+ * 深度判断 sub 是否是 obj 的子集(递归比较所有可枚举自有属性)
773
+ * @param sub 可能包含部分属性的对象
774
+ * @param obj 待比较的对象
775
+ * @param visited 用于处理循环引用的 WeakSet
776
+ */
771
777
  export { _isError as isError };
778
+ function isSubset(sub, obj) {
779
+ var visited = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new WeakSet();
780
+ // 基本类型或引用相同
781
+ if (sub === obj) return true;
782
+ // 如果任一不是对象/数组,或者为 null,则不相等(sub 为基本类型时,上面已经比较过,这里只处理对象不等的情况)
783
+ if (_typeof(sub) !== 'object' || sub === null || _typeof(obj) !== 'object' || obj === null) {
784
+ return false;
785
+ }
786
+ // 避免循环引用
787
+ if (visited.has(sub) || visited.has(obj)) return false;
788
+ visited.add(sub);
789
+ visited.add(obj);
790
+ // 处理数组
791
+ if (Array.isArray(sub)) {
792
+ if (!Array.isArray(obj) || sub.length !== obj.length) return false;
793
+ for (var i = 0; i < sub.length; i++) {
794
+ if (!isSubset(sub[i], obj[i], visited)) return false;
795
+ }
796
+ return true;
797
+ }
798
+ // 普通对象:遍历 sub 的每个键
799
+ for (var key in sub) {
800
+ if (Object.prototype.hasOwnProperty.call(sub, key)) {
801
+ // obj 必须包含该键
802
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) return false;
803
+ // 递归比较值
804
+ if (!isSubset(sub[key], obj[key], visited)) return false;
805
+ }
806
+ }
807
+ return true;
808
+ }
809
+ /**
810
+ * 在嵌套结构 root 中查找是否存在一个对象,使得 target 是该对象的子集
811
+ * @param root 可能包含任意层数组/对象的根数据
812
+ * @param target 目标对象(可能只包含部分字段)
813
+ * @returns 是否存在
814
+ */
815
+ export function containsSubset(root, target) {
816
+ var visited = new WeakSet();
817
+ function search(current) {
818
+ if (current && _typeof(current) === 'object') {
819
+ // 避免循环引用
820
+ if (visited.has(current)) return false;
821
+ visited.add(current);
822
+ // 如果是普通对象(非数组),先检查是否包含 target 子集
823
+ if (!Array.isArray(current) && isSubset(target, current)) {
824
+ return true;
825
+ }
826
+ // 继续深入遍历子元素
827
+ if (Array.isArray(current)) {
828
+ var _iterator2 = _createForOfIteratorHelper(current),
829
+ _step2;
830
+ try {
831
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
832
+ var item = _step2.value;
833
+ if (search(item)) return true;
834
+ }
835
+ } catch (err) {
836
+ _iterator2.e(err);
837
+ } finally {
838
+ _iterator2.f();
839
+ }
840
+ } else {
841
+ for (var key in current) {
842
+ if (Object.prototype.hasOwnProperty.call(current, key)) {
843
+ if (search(current[key])) return true;
844
+ }
845
+ }
846
+ }
847
+ }
848
+ return false;
849
+ }
850
+ return search(root);
851
+ }
852
+ // 判断当前meta中是否含有errorList
853
+ export var isExistsError = function isExistsError(meta, errorList) {
854
+ var _meta = cloneDeep(meta);
855
+ return errorList.some(function (error) {
856
+ return containsSubset(_meta, error);
857
+ });
858
+ };
859
+ // 设置新字段信息
772
860
  function setNewField(field, data) {
773
861
  console.log('🚀 ~ setNewField ~ field:', field);
774
- var _iterator2 = _createForOfIteratorHelper(data),
775
- _step2;
862
+ var _iterator3 = _createForOfIteratorHelper(data),
863
+ _step3;
776
864
  try {
777
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
778
- var table = _step2.value;
865
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
866
+ var table = _step3.value;
779
867
  // 第一步:判断表名是否一致
780
868
  if (table.name !== field.tableName) {
781
869
  continue;
@@ -803,9 +891,9 @@ function setNewField(field, data) {
803
891
  break;
804
892
  }
805
893
  } catch (err) {
806
- _iterator2.e(err);
894
+ _iterator3.e(err);
807
895
  } finally {
808
- _iterator2.f();
896
+ _iterator3.f();
809
897
  }
810
898
  console.log('🚀 ~ setNewField ~ field:', field);
811
899
  return field;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gingkoo/pandora-metabase",
3
- "version": "1.0.93",
3
+ "version": "1.0.95",
4
4
  "description": "",
5
5
  "main": "lib/es/index.js",
6
6
  "module": "lib/es/index.js",