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