@lcap/nasl 0.3.13 → 0.3.14

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.
Files changed (61) hide show
  1. package/out/service/logic/logic.d.ts +9 -0
  2. package/out/service/logic/logic.js +7 -0
  3. package/out/service/logic/logic.js.map +1 -1
  4. package/out/types/app/Service.js +9 -1
  5. package/out/types/app/Service.js.map +1 -1
  6. package/out/types/config.d.ts +1 -0
  7. package/out/types/config.js +1 -0
  8. package/out/types/config.js.map +1 -1
  9. package/out/types/data/Entity.d.ts +5 -1
  10. package/out/types/data/Entity.js +10 -3
  11. package/out/types/data/Entity.js.map +1 -1
  12. package/out/types/data/EntityProperty.d.ts +4 -0
  13. package/out/types/data/EntityProperty.js +7 -0
  14. package/out/types/data/EntityProperty.js.map +1 -1
  15. package/out/types/data/Interface.js +2 -1
  16. package/out/types/data/Interface.js.map +1 -1
  17. package/out/types/data/genBlock/genCreateBlock.js +5 -6
  18. package/out/types/data/genBlock/genCreateBlock.js.map +1 -1
  19. package/out/types/data/genBlock/genEnumSelectBlock.js +1 -1
  20. package/out/types/data/genBlock/genEnumSelectBlock.js.map +1 -1
  21. package/out/types/data/genBlock/genGetBlock.js +1 -1
  22. package/out/types/data/genBlock/genGetBlock.js.map +1 -1
  23. package/out/types/data/genBlock/genListViewBlock.js +1 -1
  24. package/out/types/data/genBlock/genListViewBlock.js.map +1 -1
  25. package/out/types/data/genBlock/genQueryComponent.js +1 -1
  26. package/out/types/data/genBlock/genQueryComponent.js.map +1 -1
  27. package/out/types/data/genBlock/genSelectBlock.js +2 -1
  28. package/out/types/data/genBlock/genSelectBlock.js.map +1 -1
  29. package/out/types/data/genBlock/genTableBlock.js +1 -1
  30. package/out/types/data/genBlock/genTableBlock.js.map +1 -1
  31. package/out/types/data/genBlock/genUpdateBlock.js +5 -6
  32. package/out/types/data/genBlock/genUpdateBlock.js.map +1 -1
  33. package/out/types/logic/Logic.d.ts +16 -0
  34. package/out/types/logic/Logic.js +39 -0
  35. package/out/types/logic/Logic.js.map +1 -1
  36. package/out/types/logic/LogicItem.d.ts +2 -2
  37. package/out/types/logic/LogicItem.js +92 -36
  38. package/out/types/logic/LogicItem.js.map +1 -1
  39. package/out/types/logic/translator.js +66 -50
  40. package/out/types/logic/translator.js.map +1 -1
  41. package/out/types/typeCheck.js +3 -0
  42. package/out/types/typeCheck.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/service/logic/logic.js +7 -0
  45. package/src/types/app/Service.ts +9 -1
  46. package/src/types/config.ts +1 -0
  47. package/src/types/data/Entity.ts +10 -4
  48. package/src/types/data/EntityProperty.ts +5 -0
  49. package/src/types/data/Interface.ts +3 -1
  50. package/src/types/data/genBlock/genCreateBlock.ts +5 -6
  51. package/src/types/data/genBlock/genEnumSelectBlock.ts +1 -1
  52. package/src/types/data/genBlock/genGetBlock.ts +1 -1
  53. package/src/types/data/genBlock/genListViewBlock.ts +1 -1
  54. package/src/types/data/genBlock/genQueryComponent.ts +1 -1
  55. package/src/types/data/genBlock/genSelectBlock.ts +2 -1
  56. package/src/types/data/genBlock/genTableBlock.ts +1 -1
  57. package/src/types/data/genBlock/genUpdateBlock.ts +5 -7
  58. package/src/types/logic/Logic.ts +35 -0
  59. package/src/types/logic/LogicItem.ts +305 -217
  60. package/src/types/logic/translator.js +64 -50
  61. package/src/types/typeCheck.ts +4 -0
@@ -7,6 +7,7 @@ import { getSchemaOfExpressionNode } from './tools';
7
7
  import Structure from '../data/Structure';
8
8
  import { refreshLogic } from '../cache';
9
9
  import { BusinessCode } from '../enum';
10
+ import { log } from 'console';
10
11
 
11
12
  export enum LOGIC_TYPE {
12
13
  // LogicNode
@@ -54,7 +55,7 @@ export enum LOGIC_TYPE {
54
55
  QuerySelectExpression = 'QuerySelectExpression',
55
56
  QueryFromExpression = 'QueryFromExpression',
56
57
  QueryJoinExpression = 'QueryJoinExpression',
57
- QueryAggregateExpression = 'QueryAggregateExpression',
58
+ QueryAggregateExpression = 'QueryAggregateExpression'
58
59
  }
59
60
 
60
61
  const atomicList = [
@@ -93,18 +94,16 @@ export function evaluate(node: LogicNode | ExpressionNode, finalCode = true): st
93
94
  left = `(${left})`;
94
95
 
95
96
  let right: string = evaluate(<LogicNode>node.right, finalCode);
96
- if (!atomicList.includes((node.right as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
97
+ if (!atomicList.includes((node.right as any)?.type) || (!finalCode && node.right?.type === LOGIC_TYPE.MemberExpression))
97
98
  right = `(${right})`;
98
-
99
99
  return `${left} ${node.operator} ${right}`;
100
100
  }
101
-
102
101
  if (node.type === 'LogicalExpression') {
103
102
  let left: string = evaluate(<LogicNode>node.left, finalCode);
104
103
  if (!atomicList.includes((node.left as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
105
104
  left = `(${left})`;
106
105
  let right: string = evaluate(<LogicNode>node.right, finalCode);
107
- if (!atomicList.includes((node.right as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
106
+ if (!atomicList.includes((node.right as any)?.type) || (!finalCode && node.right?.type === LOGIC_TYPE.MemberExpression))
108
107
  right = `(${right})`;
109
108
  return `${left} ${node.operator} ${right}`;
110
109
  }
@@ -155,7 +154,7 @@ export function evaluate(node: LogicNode | ExpressionNode, finalCode = true): st
155
154
 
156
155
  if (node.type === 'ObjectExpression') {
157
156
  const obj: {
158
- [prop: string]: any
157
+ [prop: string]: any;
159
158
  } = {};
160
159
  for (let { key, value } of (<ExpressionNode>node).properties) {
161
160
  let keyValue = evaluate(key, finalCode);
@@ -196,8 +195,7 @@ export function evaluate(node: LogicNode | ExpressionNode, finalCode = true): st
196
195
  if (!calleeCode)
197
196
  return;
198
197
  // 需要保持params顺序
199
- const params = ((node as any).builtInFuncParams || [])
200
- .map((param: any) => param.builtInFuncParamValue ? evaluate(param.builtInFuncParamValue, finalCode) : null);
198
+ const params = ((node as any).builtInFuncParams || []).map((param: any) => (param.builtInFuncParamValue ? evaluate(param.builtInFuncParamValue, finalCode) : null));
201
199
  let paramResult = params.join(',');
202
200
  if (paramResult === ',') {
203
201
  paramResult = '';
@@ -213,16 +211,56 @@ export function evaluate(node: LogicNode | ExpressionNode, finalCode = true): st
213
211
  }
214
212
  }
215
213
 
216
- export const logicItemKeyOfLogicItem: string[] = ['test', 'left', 'right', 'each', 'item', 'index', 'start', 'end', 'variables', 'taskId', 'processInstanceId', 'startedBy', 'errorMessage', 'callInterParamValue', 'builtInFuncParamValue', 'pageParamKey', 'pageParamKeyValue', 'argument',
217
- 'select', 'from', 'limit', 'orderElement', 'aggregateParam', 'order', 'pageElement', 'pageSizeElement', 'groupElement',
214
+ export const logicItemKeyOfLogicItem: string[] = [
215
+ 'test',
216
+ 'left',
217
+ 'right',
218
+ 'each',
219
+ 'item',
220
+ 'index',
221
+ 'start',
222
+ 'end',
223
+ 'variables',
224
+ 'taskId',
225
+ 'processInstanceId',
226
+ 'startedBy',
227
+ 'errorMessage',
228
+ 'callInterParamValue',
229
+ 'builtInFuncParamValue',
230
+ 'pageParamKey',
231
+ 'pageParamKeyValue',
232
+ 'argument',
233
+ 'select',
234
+ 'from',
235
+ 'limit',
236
+ 'orderElement',
237
+ 'aggregateParam',
238
+ 'order',
239
+ 'pageElement',
240
+ 'pageSizeElement',
241
+ 'groupElement',
218
242
  ];
219
- export const logicItemArrayKeyOfLogicItem: string[] = ['body', 'consequent', 'alternate', 'cases', 'params', 'arguments', 'builtInFuncParams',
220
- 'groupBy', 'orderBy', 'selectElementList', 'joinPartList', 'onExpressionList', 'where', 'having',
243
+ export const logicItemArrayKeyOfLogicItem: string[] = [
244
+ 'body',
245
+ 'consequent',
246
+ 'alternate',
247
+ 'cases',
248
+ 'params',
249
+ 'arguments',
250
+ 'builtInFuncParams',
251
+ 'groupBy',
252
+ 'orderBy',
253
+ 'selectElementList',
254
+ 'joinPartList',
255
+ 'onExpressionList',
256
+ 'where',
257
+ 'having',
221
258
  ];
222
259
 
223
260
  export function catchFn(logic: Logic) {
224
261
  return async (err: any) => {
225
- if (err.code !== BusinessCode.HasReferenced) // 节点被引用,不用刷新数据
262
+ if (err.code !== BusinessCode.HasReferenced)
263
+ // 节点被引用,不用刷新数据
226
264
  await refreshLogic(logic);
227
265
  else
228
266
  config.defaultApp?.emit('saved', err);
@@ -288,8 +326,8 @@ export class LogicItem extends Vertex {
288
326
  @immutable()
289
327
  public readonly _posIndex: number = undefined;
290
328
  /**
291
- * 标题
292
- */
329
+ * 标题
330
+ */
293
331
  @immutable()
294
332
  public readonly type: string = undefined;
295
333
  /**
@@ -336,10 +374,12 @@ export class LogicItem extends Vertex {
336
374
  if (!parent) {
337
375
  if (!this.logic)
338
376
  return;
339
- if (this.logic.playgroundId === parentId) { // In playgroundId
377
+ if (this.logic.playgroundId === parentId) {
378
+ // In playgroundId
340
379
  const index = _posIndex || this.logic.playground.length;
341
380
  this.logic.playground.splice(index, 0, this);
342
- } else { // In main body 这个后面让忠杰改成数组吧
381
+ } else {
382
+ // In main body 这个后面让忠杰改成数组吧
343
383
  const index = this.logic.body.findIndex((item) => item.id === parentId);
344
384
  ~index && this.logic.body.splice(index + 1, 0, this);
345
385
  this.logic.body.forEach((item, index) => {
@@ -366,24 +406,29 @@ export class LogicItem extends Vertex {
366
406
  * @param body
367
407
  */
368
408
  static preprocess(body: any) {
369
- traverse((current) => {
370
- delete current.node.editable;
371
- if (current.node.type !== 'ForEachStatement')
372
- delete current.node.index;
373
-
374
- // 处理 CallGraphQL
375
- if (current.node.type === 'CallGraphQL') {
376
- const body = current.node;
377
- delete body.paramsType;
378
- delete body.optionalParams;
379
- body.params && body.params.forEach((param: any, index: number) => {
380
- param._posIndex = index;
381
- });
382
- delete body.querySchemaMap;
383
- delete body.singularResolverName;
384
- body.querySchemaList = JSON.stringify(body.querySchemaList || []);
385
- }
386
- }, { node: body }, { mode: 'anyObject' });
409
+ traverse(
410
+ (current) => {
411
+ delete current.node.editable;
412
+ if (current.node.type !== 'ForEachStatement')
413
+ delete current.node.index;
414
+
415
+ // 处理 CallGraphQL
416
+ if (current.node.type === 'CallGraphQL') {
417
+ const body = current.node;
418
+ delete body.paramsType;
419
+ delete body.optionalParams;
420
+ body.params
421
+ && body.params.forEach((param: any, index: number) => {
422
+ param._posIndex = index;
423
+ });
424
+ delete body.querySchemaMap;
425
+ delete body.singularResolverName;
426
+ body.querySchemaList = JSON.stringify(body.querySchemaList || []);
427
+ }
428
+ },
429
+ { node: body },
430
+ { mode: 'anyObject' },
431
+ );
387
432
 
388
433
  // 处理 CallInterface
389
434
  if (body.type === 'CallInterface') {
@@ -404,23 +449,26 @@ export class LogicItem extends Vertex {
404
449
  * @param _posIndex
405
450
  * @param cache 在前端不处理节点
406
451
  */
407
- async create({
408
- parent,
409
- parentId,
410
- parentAttr,
411
- _posIndex,
412
- cache,
413
- offsetX,
414
- offsetY,
415
- }: {
416
- parent: LogicItem,
417
- parentId: string,
418
- parentAttr: string,
419
- _posIndex?: number,
420
- cache?: boolean,
421
- offsetX?: number,
422
- offsetY?: number,
423
- }, actionOptions?: ActionOptions) {
452
+ async create(
453
+ {
454
+ parent,
455
+ parentId,
456
+ parentAttr,
457
+ _posIndex,
458
+ cache,
459
+ offsetX,
460
+ offsetY,
461
+ }: {
462
+ parent: LogicItem;
463
+ parentId: string;
464
+ parentAttr: string;
465
+ _posIndex?: number;
466
+ cache?: boolean;
467
+ offsetX?: number;
468
+ offsetY?: number;
469
+ },
470
+ actionOptions?: ActionOptions,
471
+ ) {
424
472
  config.defaultApp?.emit('saving');
425
473
 
426
474
  const prevParent = this.parent;
@@ -446,17 +494,19 @@ export class LogicItem extends Vertex {
446
494
  utils.logger.debug(`在该逻辑节点的属性"${parentAttr}"上插入一个节点"`, body);
447
495
 
448
496
  body.logicId = this.logic && this.logic.id;
449
- result = await logicService.addItem({
450
- headers: {
451
- moduleType: this.logic && this.logic.moduleType,
452
- appId: config.defaultApp?.id,
453
- serviceId: this.logic?.interface?.serviceId,
454
- operationAction: 'LogicItem.create',
455
- operationDesc: actionOptions?.actionDesc || `添加逻辑项"${this.label || this.type}"`,
456
- operationIgnore: actionOptions?.actionIgnore,
457
- },
458
- body,
459
- }).catch(catchFn(this.logic));
497
+ result = await logicService
498
+ .addItem({
499
+ headers: {
500
+ moduleType: this.logic && this.logic.moduleType,
501
+ appId: config.defaultApp?.id,
502
+ serviceId: this.logic?.interface?.serviceId,
503
+ operationAction: 'LogicItem.create',
504
+ operationDesc: actionOptions?.actionDesc || `添加逻辑项"${this.label || this.type}"`,
505
+ operationIgnore: actionOptions?.actionIgnore,
506
+ },
507
+ body,
508
+ })
509
+ .catch(catchFn(this.logic));
460
510
  this.deepPick(result, ['id', 'parentId', 'parentAttr', 'joinPartRef', 'structureRef']);
461
511
  }
462
512
 
@@ -472,19 +522,26 @@ export class LogicItem extends Vertex {
472
522
 
473
523
  !cache && this.addIn(parent, parentId, parentAttr, _posIndex);
474
524
 
475
- utils.traverse(({ node }) => {
476
- if (node.type === LOGIC_TYPE.CallQueryComponent) {
477
- // 兼容 流程-流程节点 内部逻辑
478
- const service = this.logic.processComponent ? this.logic.processComponent.process?.service : this.logic.interface?.service;
479
- const structure = Structure.from({
480
- id: node.structureRef,
481
- }, service);
482
- structure.loadPro();
483
- }
484
- }, { node: this }, {
485
- mode: 'anyObject',
486
- excludedKeySet: this.JSON_EXCLUDED_KEYS,
487
- });
525
+ utils.traverse(
526
+ ({ node }) => {
527
+ if (node.type === LOGIC_TYPE.CallQueryComponent) {
528
+ // 兼容 流程-流程节点 内部逻辑
529
+ const service = this.logic.processComponent ? this.logic.processComponent.process?.service : this.logic.interface?.service;
530
+ const structure = Structure.from(
531
+ {
532
+ id: node.structureRef,
533
+ },
534
+ service,
535
+ );
536
+ structure.loadPro();
537
+ }
538
+ },
539
+ { node: this },
540
+ {
541
+ mode: 'anyObject',
542
+ excludedKeySet: this.JSON_EXCLUDED_KEYS,
543
+ },
544
+ );
488
545
 
489
546
  this.logic && this.logic.emit('change');
490
547
 
@@ -493,12 +550,14 @@ export class LogicItem extends Vertex {
493
550
  prevParent && prevParent.checkType();
494
551
  }
495
552
 
496
- await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
497
- operationAction: 'LogicItem.create',
498
- operationBeforeImage: null,
499
- operationAfterImage: JSON.parse(JSON.stringify(this)),
500
- operationDesc: `添加逻辑项"${this.label || this.type}"`,
501
- });
553
+ await config.defaultApp?.history.load(
554
+ actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
555
+ operationAction: 'LogicItem.create',
556
+ operationBeforeImage: null,
557
+ operationAfterImage: JSON.parse(JSON.stringify(this)),
558
+ operationDesc: `添加逻辑项"${this.label || this.type}"`,
559
+ },
560
+ );
502
561
  config.defaultApp?.emit('saved');
503
562
  }
504
563
  /**
@@ -510,23 +569,26 @@ export class LogicItem extends Vertex {
510
569
  * @param _posIndex
511
570
  * @param cache 在前端不处理节点
512
571
  */
513
- async move({
514
- parent,
515
- parentId,
516
- parentAttr,
517
- _posIndex,
518
- cache,
519
- offsetX,
520
- offsetY,
521
- }: {
522
- parent: LogicItem,
523
- parentId: string,
524
- parentAttr: string,
525
- _posIndex?: number,
526
- cache?: boolean,
527
- offsetX?: number,
528
- offsetY?: number,
529
- }, actionOptions?: ActionOptions) {
572
+ async move(
573
+ {
574
+ parent,
575
+ parentId,
576
+ parentAttr,
577
+ _posIndex,
578
+ cache,
579
+ offsetX,
580
+ offsetY,
581
+ }: {
582
+ parent: LogicItem;
583
+ parentId: string;
584
+ parentAttr: string;
585
+ _posIndex?: number;
586
+ cache?: boolean;
587
+ offsetX?: number;
588
+ offsetY?: number;
589
+ },
590
+ actionOptions?: ActionOptions,
591
+ ) {
530
592
  config.defaultApp?.emit('saving');
531
593
 
532
594
  const prevParent = this.parent;
@@ -549,31 +611,33 @@ export class LogicItem extends Vertex {
549
611
  if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
550
612
  utils.logger.debug(`在该逻辑节点的属性"${parentAttr}"上插入一个节点"`, body);
551
613
 
552
- await logicService.moveItem({
553
- headers: {
554
- moduleType: this.logic && this.logic.moduleType,
555
- appId: config.defaultApp?.id,
556
- operationAction: 'LogicItem.move',
557
- operationDesc: actionOptions?.actionDesc || `移动逻辑项"${this.label || this.type}"`,
558
- },
559
- body: {
560
- id: body.id,
561
- moveFromLogicItem: {
562
- parentId: this.parentId,
563
- parentAttr: this.parentAttr,
564
- _posIndex: this._posIndex,
565
- offsetX: this.offsetX,
566
- offsetY: this.offsetY,
614
+ await logicService
615
+ .moveItem({
616
+ headers: {
617
+ moduleType: this.logic && this.logic.moduleType,
618
+ appId: config.defaultApp?.id,
619
+ operationAction: 'LogicItem.move',
620
+ operationDesc: actionOptions?.actionDesc || `移动逻辑项"${this.label || this.type}"`,
567
621
  },
568
- moveToLogicItem: {
569
- parentId,
570
- parentAttr,
571
- _posIndex,
572
- offsetX,
573
- offsetY,
622
+ body: {
623
+ id: body.id,
624
+ moveFromLogicItem: {
625
+ parentId: this.parentId,
626
+ parentAttr: this.parentAttr,
627
+ _posIndex: this._posIndex,
628
+ offsetX: this.offsetX,
629
+ offsetY: this.offsetY,
630
+ },
631
+ moveToLogicItem: {
632
+ parentId,
633
+ parentAttr,
634
+ _posIndex,
635
+ offsetX,
636
+ offsetY,
637
+ },
574
638
  },
575
- },
576
- }).catch(catchFn(this.logic));
639
+ })
640
+ .catch(catchFn(this.logic));
577
641
  }
578
642
 
579
643
  if (!(this.parentId === parentId && this.parentId === this.logic.playgroundId && this.parentAttr === parentAttr)) {
@@ -599,12 +663,14 @@ export class LogicItem extends Vertex {
599
663
  this.checkType();
600
664
  prevParent && prevParent.checkType();
601
665
 
602
- await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
603
- operationAction: 'LogicItem.move',
604
- operationBeforeImage: null,
605
- operationAfterImage: null,
606
- operationDesc: `移动逻辑项"${this.label || this.type}"`,
607
- });
666
+ await config.defaultApp?.history.load(
667
+ actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
668
+ operationAction: 'LogicItem.move',
669
+ operationBeforeImage: null,
670
+ operationAfterImage: null,
671
+ operationDesc: `移动逻辑项"${this.label || this.type}"`,
672
+ },
673
+ );
608
674
  config.defaultApp?.emit('saved');
609
675
  }
610
676
  /**
@@ -616,15 +682,18 @@ export class LogicItem extends Vertex {
616
682
  * @param _posIndex
617
683
  * @param cache 在前端不处理节点
618
684
  */
619
- createOrMove(options: {
620
- parent: LogicItem,
621
- parentId: string,
622
- parentAttr: string,
623
- _posIndex?: number,
624
- cache?: boolean,
625
- offsetX?: number,
626
- offsetY?: number,
627
- }, actionOptions?: ActionOptions) {
685
+ createOrMove(
686
+ options: {
687
+ parent: LogicItem;
688
+ parentId: string;
689
+ parentAttr: string;
690
+ _posIndex?: number;
691
+ cache?: boolean;
692
+ offsetX?: number;
693
+ offsetY?: number;
694
+ },
695
+ actionOptions?: ActionOptions,
696
+ ) {
628
697
  if (this.id)
629
698
  return this.move(options, actionOptions);
630
699
  else
@@ -645,19 +714,21 @@ export class LogicItem extends Vertex {
645
714
  logicItems.forEach((logicItem) => {
646
715
  LogicItem.preprocess(logicItem);
647
716
  });
648
- const res = await logicService.paste({
649
- body: {
650
- type: 'logicItem',
651
- logicItems,
652
- targetId,
653
- targetType,
654
- },
655
- headers: {
656
- appId: config.defaultApp?.id,
657
- operationAction: 'LogicItem.paste',
658
- operationDesc: `粘贴逻辑项"${logicItems[0].label || logicItems[0].type}"`,
659
- },
660
- }).catch(catchFn(vertexsMap.get(targetId) as Logic));
717
+ const res = await logicService
718
+ .paste({
719
+ body: {
720
+ type: 'logicItem',
721
+ logicItems,
722
+ targetId,
723
+ targetType,
724
+ },
725
+ headers: {
726
+ appId: config.defaultApp?.id,
727
+ operationAction: 'LogicItem.paste',
728
+ operationDesc: `粘贴逻辑项"${logicItems[0].label || logicItems[0].type}"`,
729
+ },
730
+ })
731
+ .catch(catchFn(vertexsMap.get(targetId) as Logic));
661
732
 
662
733
  LogicItem.redoPaste(res);
663
734
  }
@@ -668,19 +739,26 @@ export class LogicItem extends Vertex {
668
739
  logic.playground.push(logicItem);
669
740
  logicItem.checkType();
670
741
 
671
- utils.traverse(({ node }) => {
672
- if (node.type === LOGIC_TYPE.CallQueryComponent) {
673
- // 兼容 流程-流程节点 内部逻辑
674
- const service = node.logic.processComponent ? node.logic.processComponent.process?.service : node.logic.interface?.service;
675
- const structure = Structure.from({
676
- id: node.structureRef,
677
- }, service);
678
- structure.loadPro();
679
- }
680
- }, { node: logicItem }, {
681
- mode: 'anyObject',
682
- excludedKeySet: logicItem.JSON_EXCLUDED_KEYS,
683
- });
742
+ utils.traverse(
743
+ ({ node }) => {
744
+ if (node.type === LOGIC_TYPE.CallQueryComponent) {
745
+ // 兼容 流程-流程节点 内部逻辑
746
+ const service = node.logic.processComponent ? node.logic.processComponent.process?.service : node.logic.interface?.service;
747
+ const structure = Structure.from(
748
+ {
749
+ id: node.structureRef,
750
+ },
751
+ service,
752
+ );
753
+ structure.loadPro();
754
+ }
755
+ },
756
+ { node: logicItem },
757
+ {
758
+ mode: 'anyObject',
759
+ excludedKeySet: logicItem.JSON_EXCLUDED_KEYS,
760
+ },
761
+ );
684
762
  });
685
763
 
686
764
  await config.defaultApp?.history.load();
@@ -716,20 +794,22 @@ export class LogicItem extends Vertex {
716
794
  });
717
795
 
718
796
  function removeId(logicItems: LogicItem[]) {
719
- return JSON.parse(JSON.stringify(logicItems, (key, value) => key === 'id' ? undefined : value));
797
+ return JSON.parse(JSON.stringify(logicItems, (key, value) => (key === 'id' ? undefined : value)));
720
798
  }
721
799
 
722
- return logicService.pretreatmentBeforePaste({
723
- body: {
724
- type: 'logicItem',
725
- logicItems,
726
- targetId,
727
- targetType,
728
- },
729
- }).then((res: any) => {
730
- res.logicItems = removeId(res.logicItems);
731
- return res;
732
- });
800
+ return logicService
801
+ .pretreatmentBeforePaste({
802
+ body: {
803
+ type: 'logicItem',
804
+ logicItems,
805
+ targetId,
806
+ targetType,
807
+ },
808
+ })
809
+ .then((res: any) => {
810
+ res.logicItems = removeId(res.logicItems);
811
+ return res;
812
+ });
733
813
  }
734
814
  /**
735
815
  * 纯前端创建
@@ -768,10 +848,12 @@ export class LogicItem extends Vertex {
768
848
  if (!this.parent) {
769
849
  if (!this.logic)
770
850
  return;
771
- if (this.logic.playgroundId === this.parentId) { // In playgroundId
851
+ if (this.logic.playgroundId === this.parentId) {
852
+ // In playgroundId
772
853
  const index = this.logic.playground.indexOf(this);
773
854
  ~index && this.logic.playground.splice(index, 1);
774
- } else { // In main body 这个后面让忠杰改成数组吧
855
+ } else {
856
+ // In main body 这个后面让忠杰改成数组吧
775
857
  const index = this.logic.body.indexOf(this);
776
858
  ~index && this.logic.body.splice(index, 1);
777
859
  this.logic.body.forEach((item, index) => {
@@ -805,16 +887,18 @@ export class LogicItem extends Vertex {
805
887
  delete body.index;
806
888
  ///
807
889
 
808
- await logicService.removeItem({
809
- headers: {
810
- moduleType: this.logic?.moduleType,
811
- appId: config.defaultApp?.id,
812
- serviceId: this.logic?.interface?.serviceId,
813
- operationAction: 'LogicItem.delete',
814
- operationDesc: `删除逻辑项"${this.label || this.type}"`,
815
- },
816
- body,
817
- }).catch(catchFn(this.logic));
890
+ await logicService
891
+ .removeItem({
892
+ headers: {
893
+ moduleType: this.logic?.moduleType,
894
+ appId: config.defaultApp?.id,
895
+ serviceId: this.logic?.interface?.serviceId,
896
+ operationAction: 'LogicItem.delete',
897
+ operationDesc: `删除逻辑项"${this.label || this.type}"`,
898
+ },
899
+ body,
900
+ })
901
+ .catch(catchFn(this.logic));
818
902
  }
819
903
  }
820
904
 
@@ -831,12 +915,14 @@ export class LogicItem extends Vertex {
831
915
  !cache && this.remove();
832
916
  this.destroy();
833
917
  this.logic && this.logic.emit('change');
834
- await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
835
- operationAction: 'LogicItem.delete',
836
- operationBeforeImage: JSON.parse(JSON.stringify(this)),
837
- operationAfterImage: null,
838
- operationDesc: `删除逻辑项"${this.label || this.type}"`,
839
- });
918
+ await config.defaultApp?.history.load(
919
+ actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
920
+ operationAction: 'LogicItem.delete',
921
+ operationBeforeImage: JSON.parse(JSON.stringify(this)),
922
+ operationAfterImage: null,
923
+ operationDesc: `删除逻辑项"${this.label || this.type}"`,
924
+ },
925
+ );
840
926
  config.defaultApp?.emit('saved');
841
927
  }
842
928
  /**
@@ -896,16 +982,18 @@ export class LogicItem extends Vertex {
896
982
 
897
983
  utils.logger.debug('修改逻辑项', body);
898
984
  if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
899
- const result = await logicService.updateItem({
900
- headers: {
901
- moduleType: this.logic.moduleType,
902
- appId: config.defaultApp?.id,
903
- operationAction: 'LogicItem.update',
904
- operationDesc: `修改逻辑项"${this.label || this.type}"`,
905
- operationIgnore: actionOptions?.actionIgnore,
906
- },
907
- body,
908
- }).catch(catchFn(this.logic));
985
+ const result = await logicService
986
+ .updateItem({
987
+ headers: {
988
+ moduleType: this.logic.moduleType,
989
+ appId: config.defaultApp?.id,
990
+ operationAction: 'LogicItem.update',
991
+ operationDesc: `修改逻辑项"${this.label || this.type}"`,
992
+ operationIgnore: actionOptions?.actionIgnore,
993
+ },
994
+ body,
995
+ })
996
+ .catch(catchFn(this.logic));
909
997
 
910
998
  // 合并params里的id
911
999
  if (body.params && body.params.length) {
@@ -943,12 +1031,14 @@ export class LogicItem extends Vertex {
943
1031
  this.logic && this.logic.emit('change');
944
1032
  this.checkType();
945
1033
 
946
- await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
947
- operationAction: 'LogicItem.update',
948
- operationBeforeImage: null,
949
- operationAfterImage: null,
950
- operationDesc: `修改逻辑项"${this.label || this.type}"`,
951
- });
1034
+ await config.defaultApp?.history.load(
1035
+ actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
1036
+ operationAction: 'LogicItem.update',
1037
+ operationBeforeImage: null,
1038
+ operationAfterImage: null,
1039
+ operationDesc: `修改逻辑项"${this.label || this.type}"`,
1040
+ },
1041
+ );
952
1042
  config.defaultApp?.emit('saved');
953
1043
  return this;
954
1044
  }
@@ -973,7 +1063,7 @@ export class LogicItem extends Vertex {
973
1063
  source.code = `ID_${source.id}`;
974
1064
 
975
1065
  let logicItem: LogicItem;
976
- if (!shouldCreateNewItem && (source instanceof LogicItem))
1066
+ if (!shouldCreateNewItem && source instanceof LogicItem)
977
1067
  logicItem = source;
978
1068
  else
979
1069
  logicItem = source.level === 'logicNode' ? new LogicNode(source) : new ExpressionNode(source);
@@ -1031,11 +1121,7 @@ export class LogicItem extends Vertex {
1031
1121
  let crt: LogicItem = this;
1032
1122
  const nodes = [];
1033
1123
  do {
1034
- if (
1035
- !['builtInFuncParams'].includes(crt.parentAttr)
1036
- && !(crt instanceof ExpressionNode && crt.parent instanceof LogicNode)
1037
- && (crt instanceof ExpressionNode || !crt.parent)
1038
- )
1124
+ if (!['builtInFuncParams'].includes(crt.parentAttr) && !(crt instanceof ExpressionNode && crt.parent instanceof LogicNode) && (crt instanceof ExpressionNode || !crt.parent))
1039
1125
  nodes.push(crt);
1040
1126
 
1041
1127
  // CallQueryComponent 内部的节点不用checkType
@@ -1051,7 +1137,7 @@ export class LogicItem extends Vertex {
1051
1137
  }
1052
1138
 
1053
1139
  private async _checkType(node: LogicItem) {
1054
- if (checkTypeClient.connect) {
1140
+ if (checkTypeClient.connect) {
1055
1141
  checkTypeClient.client.emit('checktype', {
1056
1142
  id: node.id,
1057
1143
  type: 'logicItem',
@@ -1103,7 +1189,9 @@ export class LogicItem extends Vertex {
1103
1189
  /**
1104
1190
  * 生成 JS 脚本
1105
1191
  */
1106
- toScript() { return ''; }
1192
+ toScript() {
1193
+ return '';
1194
+ }
1107
1195
 
1108
1196
  getLogicItem(type: LOGIC_TYPE) {
1109
1197
  let node: LogicItem = this;