@lingxiteam/ebe-utils 0.0.16 → 0.0.17

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/es/index.d.ts CHANGED
@@ -76,6 +76,7 @@ export declare const fetchData: ({ appId, services, platform, baseUrl, onProgres
76
76
  appInfo: Record<string, any>;
77
77
  pagePathEnglishMapping: any;
78
78
  incrementalConstruction: IncrementalConstruction | undefined;
79
+ pageTypeMap: any;
79
80
  };
80
81
  cleanedTree: any;
81
82
  }>;
package/es/index.js CHANGED
@@ -253,14 +253,14 @@ var getIsIncrementalConstruction = function getIsIncrementalConstruction(ic) {
253
253
  export var fetchData = /*#__PURE__*/function () {
254
254
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
255
255
  var _ref6, _attrSpecPage;
256
- var appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, incrementalConstruction, isIncrementalConstruction, attrSpecPage, appPageList, globalDataInfo, busiData, themeCss, frontendHookList, globalDataMap, appInfo, temCompAssetList, compAssetList, _globalDataInfo, dataSourceList, pageIdMapping, lastPageId, data, pages, _yield$services$qryBu, itemLists, _incrementalConstruct, busiPages, getTranslateName, chinese, translateNames, key, _translateNames, pagePathEnglishMapping, pagePathEnglishSet, getName, pagesChinese, pagesTranslateNames, _key, _pages$_key$pageConta, _pagePathEnglishMappi, _pagesTranslateNames, safeTranslateName, pageDSLS, getPlatform, options, cleanedTree;
256
+ var appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, incrementalConstruction, isIncrementalConstruction, attrSpecPage, incrementalConstructionPageList, globalDataInfo, busiData, themeCss, frontendHookList, pageTypeMap, globalDataMap, appInfo, appPageList, temCompAssetList, compAssetList, _globalDataInfo, dataSourceList, pageIdMapping, lastPageId, data, needFindDataPages, pages, _yield$services$qryBu, itemLists, _incrementalConstruct, busiPages, getTranslateName, chinese, translateNames, key, _translateNames, pagePathEnglishMapping, pagePathEnglishSet, getName, pagesChinese, pagesTranslateNames, findPageKeyByPageId, _key2, _appPageList$_key2$pa, _pagePathEnglishMappi, _pagesTranslateNames, safeTranslateName, pageKey, pageDSLS, getPlatform, options, cleanedTree;
257
257
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
258
258
  while (1) switch (_context3.prev = _context3.next) {
259
259
  case 0:
260
260
  appId = _ref4.appId, services = _ref4.services, platform = _ref4.platform, baseUrl = _ref4.baseUrl, onProgress = _ref4.onProgress, needTranslatePagePathToEnglish = _ref4.needTranslatePagePathToEnglish, incrementalConstruction = _ref4.incrementalConstruction;
261
261
  isIncrementalConstruction = getIsIncrementalConstruction(incrementalConstruction);
262
262
  attrSpecPage = {};
263
- appPageList = (_ref6 = (incrementalConstruction === null || incrementalConstruction === void 0 ? void 0 : incrementalConstruction.pageIds) || []) === null || _ref6 === void 0 ? void 0 : _ref6.map(function (i) {
263
+ incrementalConstructionPageList = (_ref6 = (incrementalConstruction === null || incrementalConstruction === void 0 ? void 0 : incrementalConstruction.pageIds) || []) === null || _ref6 === void 0 ? void 0 : _ref6.map(function (i) {
264
264
  return {
265
265
  pageId: i
266
266
  };
@@ -269,54 +269,64 @@ export var fetchData = /*#__PURE__*/function () {
269
269
  busiData = [];
270
270
  themeCss = '';
271
271
  frontendHookList = [];
272
+ pageTypeMap = {};
272
273
  globalDataMap = {};
273
- _context3.next = 11;
274
+ _context3.next = 12;
274
275
  return services.findApplication({
275
276
  appId: appId
276
277
  });
277
- case 11:
278
+ case 12:
278
279
  appInfo = _context3.sent;
279
280
  onProgress({
280
281
  log: '获取应用信息',
281
282
  progress: 1
282
283
  });
283
284
  if (!(!isIncrementalConstruction || incrementalConstruction !== null && incrementalConstruction !== void 0 && incrementalConstruction.frontendHookChange)) {
284
- _context3.next = 17;
285
+ _context3.next = 18;
285
286
  break;
286
287
  }
287
- _context3.next = 16;
288
+ _context3.next = 17;
288
289
  return services.queryFrontendHookList({
289
290
  appId: appId
290
291
  });
291
- case 16:
292
- frontendHookList = _context3.sent;
293
292
  case 17:
294
- if (isIncrementalConstruction) {
295
- _context3.next = 35;
296
- break;
297
- }
298
- _context3.next = 20;
299
- return services.qryAttrSpecPage({
300
- appId: appId,
301
- pageNum: 1,
302
- pageSize: 999999
303
- });
304
- case 20:
305
- attrSpecPage = _context3.sent;
293
+ frontendHookList = _context3.sent;
294
+ case 18:
306
295
  onProgress({
307
296
  log: '获取当前应用的全部页面',
308
297
  progress: 2
309
298
  });
310
299
  // 根据 appId 获取当前应用的全部页面
311
- _context3.next = 24;
300
+ _context3.next = 21;
312
301
  return services.qryPageInstListByAppId({
313
302
  appId: appId,
314
303
  terminalType: platform
315
304
  });
316
- case 24:
305
+ case 21:
317
306
  appPageList = _context3.sent;
318
- _context3.prev = 25;
319
- _context3.next = 28;
307
+ appPageList.forEach(function (o) {
308
+ if (o.pageContainerType === 'Drawer') {
309
+ var _o$pageContainerType, _pageTypeMap$_o$pageC;
310
+ (_pageTypeMap$_o$pageC = pageTypeMap[_o$pageContainerType = o.pageContainerType]) !== null && _pageTypeMap$_o$pageC !== void 0 ? _pageTypeMap$_o$pageC : pageTypeMap[_o$pageContainerType] = {};
311
+ pageTypeMap[o.pageContainerType][o.pageId] = true;
312
+ }
313
+ // pageTypeMap[o.pageContainerType] ??= {};
314
+ // pageTypeMap[o.pageContainerType][o.pageId] = true;
315
+ });
316
+ if (isIncrementalConstruction) {
317
+ _context3.next = 37;
318
+ break;
319
+ }
320
+ _context3.next = 26;
321
+ return services.qryAttrSpecPage({
322
+ appId: appId,
323
+ pageNum: 1,
324
+ pageSize: 999999
325
+ });
326
+ case 26:
327
+ attrSpecPage = _context3.sent;
328
+ _context3.prev = 27;
329
+ _context3.next = 30;
320
330
  return Promise.race([new Promise(function (resolve, reject) {
321
331
  services.getThemeCss({
322
332
  appId: appId,
@@ -329,26 +339,26 @@ export var fetchData = /*#__PURE__*/function () {
329
339
  resolve('');
330
340
  }, 5000);
331
341
  })]);
332
- case 28:
342
+ case 30:
333
343
  themeCss = _context3.sent;
334
344
  console.log('====获取主题成功');
335
- _context3.next = 35;
345
+ _context3.next = 37;
336
346
  break;
337
- case 32:
338
- _context3.prev = 32;
339
- _context3.t0 = _context3["catch"](25);
347
+ case 34:
348
+ _context3.prev = 34;
349
+ _context3.t0 = _context3["catch"](27);
340
350
  console.error('====获取主题失败', _context3.t0);
341
- case 35:
351
+ case 37:
342
352
  // 根据 appId 获取当前应用的使用的自定义组件
343
353
  onProgress({
344
354
  log: '获取当前应用的使用的自定义组件',
345
355
  progress: 3
346
356
  });
347
- _context3.next = 38;
357
+ _context3.next = 40;
348
358
  return services.qryPageCompAssetList({
349
359
  appId: appId
350
360
  });
351
- case 38:
361
+ case 40:
352
362
  temCompAssetList = _context3.sent;
353
363
  // 兼容下割接数据,数组前面的自定义组件是新的
354
364
  compAssetList = temCompAssetList.reduce(function (acc, current) {
@@ -361,7 +371,7 @@ export var fetchData = /*#__PURE__*/function () {
361
371
  return acc;
362
372
  }, []);
363
373
  if (!(!isIncrementalConstruction || incrementalConstruction !== null && incrementalConstruction !== void 0 && incrementalConstruction.globalStoreChange)) {
364
- _context3.next = 47;
374
+ _context3.next = 49;
365
375
  break;
366
376
  }
367
377
  // 根据appId 获取全局数据源
@@ -369,12 +379,12 @@ export var fetchData = /*#__PURE__*/function () {
369
379
  log: '获取全局数据源',
370
380
  progress: 4
371
381
  });
372
- _context3.next = 44;
382
+ _context3.next = 46;
373
383
  return services.queryFrontendDatasourcePage({
374
384
  appId: appId,
375
385
  pageSize: 10000
376
386
  });
377
- case 44:
387
+ case 46:
378
388
  globalDataInfo = _context3.sent;
379
389
  dataSourceList = ((_globalDataInfo = globalDataInfo) === null || _globalDataInfo === void 0 ? void 0 : _globalDataInfo.list) || [];
380
390
  dataSourceList.forEach(function (item) {
@@ -387,7 +397,7 @@ export var fetchData = /*#__PURE__*/function () {
387
397
  } catch (err) {}
388
398
  return null;
389
399
  });
390
- case 47:
400
+ case 49:
391
401
  pageIdMapping = {};
392
402
  lastPageId = ''; // 根据 pageId 获得 dsl
393
403
  data = [];
@@ -395,8 +405,9 @@ export var fetchData = /*#__PURE__*/function () {
395
405
  log: '获取所有页面dsl',
396
406
  progress: 5
397
407
  });
398
- _context3.next = 53;
399
- return Promise.all(appPageList.map(function (i) {
408
+ needFindDataPages = isIncrementalConstruction ? incrementalConstructionPageList : appPageList;
409
+ _context3.next = 56;
410
+ return Promise.all(needFindDataPages.map(function (i) {
400
411
  lastPageId = i.pageId;
401
412
  pageIdMapping[i.pagePath] = i.pageId;
402
413
  return services.findPageInstByVersionId({
@@ -404,11 +415,11 @@ export var fetchData = /*#__PURE__*/function () {
404
415
  pageId: i.pageId
405
416
  });
406
417
  }));
407
- case 53:
418
+ case 56:
408
419
  data = _context3.sent;
409
420
  pages = getPageDsls(data);
410
421
  if (isIncrementalConstruction) {
411
- _context3.next = 66;
422
+ _context3.next = 69;
412
423
  break;
413
424
  }
414
425
  onProgress({
@@ -417,7 +428,7 @@ export var fetchData = /*#__PURE__*/function () {
417
428
  });
418
429
 
419
430
  // 业务组件从被使用才生成改为全部生成
420
- _context3.next = 59;
431
+ _context3.next = 62;
421
432
  return services.qryBusiCompPage({
422
433
  appIds: [appId],
423
434
  appId: appId,
@@ -426,10 +437,10 @@ export var fetchData = /*#__PURE__*/function () {
426
437
  pageSize: 999999,
427
438
  terminalType: platform
428
439
  });
429
- case 59:
440
+ case 62:
430
441
  _yield$services$qryBu = _context3.sent;
431
442
  itemLists = _yield$services$qryBu.list;
432
- _context3.next = 63;
443
+ _context3.next = 66;
433
444
  return Promise.all(itemLists.map(function (i) {
434
445
  return services.findBusiCompById({
435
446
  busiCompId: i.busiCompId,
@@ -437,12 +448,12 @@ export var fetchData = /*#__PURE__*/function () {
437
448
  pageId: lastPageId
438
449
  });
439
450
  }));
440
- case 63:
451
+ case 66:
441
452
  busiData = _context3.sent;
442
- _context3.next = 69;
453
+ _context3.next = 72;
443
454
  break;
444
- case 66:
445
- _context3.next = 68;
455
+ case 69:
456
+ _context3.next = 71;
446
457
  return Promise.all(((_incrementalConstruct = incrementalConstruction === null || incrementalConstruction === void 0 ? void 0 : incrementalConstruction.busiCompIds) !== null && _incrementalConstruct !== void 0 ? _incrementalConstruct : []).map(function (i) {
447
458
  return services.findBusiCompById({
448
459
  busiCompId: i,
@@ -450,9 +461,9 @@ export var fetchData = /*#__PURE__*/function () {
450
461
  pageId: lastPageId
451
462
  });
452
463
  }));
453
- case 68:
464
+ case 71:
454
465
  busiData = _context3.sent;
455
- case 69:
466
+ case 72:
456
467
  // 过滤为空
457
468
  busiPages = busiData.filter(Boolean).map(function (i, index) {
458
469
  var _i$busiCompVersion;
@@ -525,14 +536,14 @@ export var fetchData = /*#__PURE__*/function () {
525
536
  });
526
537
  translateNames = {};
527
538
  if (!(chinese.length > 0)) {
528
- _context3.next = 77;
539
+ _context3.next = 80;
529
540
  break;
530
541
  }
531
- _context3.next = 76;
542
+ _context3.next = 79;
532
543
  return getTranslateName(appId, chinese, 'UPPER_CAMEL');
533
- case 76:
544
+ case 79:
534
545
  translateNames = _context3.sent;
535
- case 77:
546
+ case 80:
536
547
  // 翻译业务组件的名字
537
548
  for (key = 0; key < busiPages.length; key++) {
538
549
  onProgress({
@@ -544,7 +555,7 @@ export var fetchData = /*#__PURE__*/function () {
544
555
  }
545
556
  pagePathEnglishMapping = {};
546
557
  if (!needTranslatePagePathToEnglish) {
547
- _context3.next = 89;
558
+ _context3.next = 93;
548
559
  break;
549
560
  }
550
561
  pagePathEnglishSet = {};
@@ -561,36 +572,45 @@ export var fetchData = /*#__PURE__*/function () {
561
572
  }
562
573
  return getName("".concat(compName), type, index + 1);
563
574
  };
564
- pagesChinese = pages === null || pages === void 0 ? void 0 : pages.map(function (item) {
575
+ pagesChinese = appPageList === null || appPageList === void 0 ? void 0 : appPageList.map(function (item) {
565
576
  return getSafeTypeName(item.pageName);
566
577
  });
567
578
  pagesTranslateNames = {};
568
579
  if (!(pagesChinese.length > 0)) {
569
- _context3.next = 88;
580
+ _context3.next = 91;
570
581
  break;
571
582
  }
572
- _context3.next = 87;
583
+ _context3.next = 90;
573
584
  return getTranslateName(appId, pagesChinese, 'UPPER_CAMEL');
574
- case 87:
585
+ case 90:
575
586
  pagesTranslateNames = _context3.sent;
576
- case 88:
577
- // 翻译页面的名字
578
- for (_key = 0; _key < pages.length; _key++) {
587
+ case 91:
588
+ findPageKeyByPageId = function findPageKeyByPageId(id, arrs) {
589
+ for (var _key = 0; _key < arrs.length; _key++) {
590
+ var _arrs$_key;
591
+ if (((_arrs$_key = arrs[_key]) === null || _arrs$_key === void 0 ? void 0 : _arrs$_key.pageId) == id) {
592
+ return _key;
593
+ }
594
+ }
595
+ return 0;
596
+ }; // 翻译页面的名字
597
+ for (_key2 = 0; _key2 < appPageList.length; _key2++) {
579
598
  onProgress({
580
599
  log: '翻译页面路径',
581
- progress: 7 + _key / pages.length
600
+ progress: 7 + _key2 / appPageList.length
582
601
  });
583
602
  // 如果页面路径翻译失败,就不处理路径
584
603
  // index 保留不处理
585
- if (pages[_key].pagePath !== '/index') {
586
- (_pagePathEnglishMappi = pagePathEnglishMapping[_pages$_key$pageConta = pages[_key].pageContainerType]) !== null && _pagePathEnglishMappi !== void 0 ? _pagePathEnglishMappi : pagePathEnglishMapping[_pages$_key$pageConta] = {};
587
- safeTranslateName = getName(((_pagesTranslateNames = pagesTranslateNames) === null || _pagesTranslateNames === void 0 ? void 0 : _pagesTranslateNames[getSafeTypeName(pages[_key].pageName)]) || pages[_key].pageName, pages[_key].pageContainerType);
588
- pagePathEnglishMapping[pages[_key].pageContainerType][pages[_key].pagePath] = safeTranslateName;
589
- pages[_key]._pagePath = pages[_key].pagePath;
590
- pages[_key].pagePath = safeTranslateName;
604
+ if (appPageList[_key2].pagePath !== '/index') {
605
+ (_pagePathEnglishMappi = pagePathEnglishMapping[_appPageList$_key2$pa = appPageList[_key2].pageContainerType]) !== null && _pagePathEnglishMappi !== void 0 ? _pagePathEnglishMappi : pagePathEnglishMapping[_appPageList$_key2$pa] = {};
606
+ safeTranslateName = getName(((_pagesTranslateNames = pagesTranslateNames) === null || _pagesTranslateNames === void 0 ? void 0 : _pagesTranslateNames[getSafeTypeName(appPageList[_key2].pageName)]) || appPageList[_key2].pageName, appPageList[_key2].pageContainerType);
607
+ pagePathEnglishMapping[appPageList[_key2].pageContainerType][appPageList[_key2].pagePath] = safeTranslateName;
608
+ pageKey = findPageKeyByPageId(appPageList[_key2].pageId, pages);
609
+ pages[pageKey]._pagePath = pages[pageKey].pagePath;
610
+ pages[pageKey].pagePath = safeTranslateName;
591
611
  }
592
612
  }
593
- case 89:
613
+ case 93:
594
614
  // 合并页面,生成器那边支持页面类型和业务组件类型
595
615
  pageDSLS = [].concat(_toConsumableArray(pages), _toConsumableArray(busiPages));
596
616
  getPlatform = function getPlatform(platFormtype) {
@@ -620,7 +640,8 @@ export var fetchData = /*#__PURE__*/function () {
620
640
  appInfo: clearAppInfo(appInfo),
621
641
  // 英文路径的对应关系
622
642
  pagePathEnglishMapping: pagePathEnglishMapping,
623
- incrementalConstruction: incrementalConstruction
643
+ incrementalConstruction: incrementalConstruction,
644
+ pageTypeMap: pageTypeMap
624
645
  };
625
646
  onProgress({
626
647
  log: '清理无用数据',
@@ -632,11 +653,11 @@ export var fetchData = /*#__PURE__*/function () {
632
653
  options: options,
633
654
  cleanedTree: cleanedTree
634
655
  });
635
- case 96:
656
+ case 100:
636
657
  case "end":
637
658
  return _context3.stop();
638
659
  }
639
- }, _callee3, null, [[25, 32]]);
660
+ }, _callee3, null, [[27, 34]]);
640
661
  }));
641
662
  return function fetchData(_x) {
642
663
  return _ref5.apply(this, arguments);
@@ -177,5 +177,3 @@ namespace securityType {
177
177
  desKey: string;
178
178
  };
179
179
  }
180
-
181
- export default securityType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxiteam/ebe-utils",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -17,7 +17,7 @@
17
17
  "@babel/parser": "^7.12.12",
18
18
  "@babel/traverse": "^7.12.12",
19
19
  "@babel/types": "^7.12.12",
20
- "@lingxiteam/ebe": "0.0.16",
20
+ "@lingxiteam/ebe": "0.0.17",
21
21
  "cac": "^6.7.14",
22
22
  "fs-extra": "9.x"
23
23
  },