@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.
- 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/Entity.d.ts +5 -1
- package/out/types/data/Entity.js +10 -3
- package/out/types/data/Entity.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 +5 -6
- package/out/types/data/genBlock/genCreateBlock.js.map +1 -1
- package/out/types/data/genBlock/genEnumSelectBlock.js +1 -1
- package/out/types/data/genBlock/genEnumSelectBlock.js.map +1 -1
- package/out/types/data/genBlock/genGetBlock.js +1 -1
- package/out/types/data/genBlock/genGetBlock.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/genQueryComponent.js +1 -1
- package/out/types/data/genBlock/genQueryComponent.js.map +1 -1
- package/out/types/data/genBlock/genSelectBlock.js +2 -1
- package/out/types/data/genBlock/genSelectBlock.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 +5 -6
- 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 +92 -36
- 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/Entity.ts +10 -4
- package/src/types/data/EntityProperty.ts +5 -0
- package/src/types/data/Interface.ts +3 -1
- package/src/types/data/genBlock/genCreateBlock.ts +5 -6
- package/src/types/data/genBlock/genEnumSelectBlock.ts +1 -1
- package/src/types/data/genBlock/genGetBlock.ts +1 -1
- package/src/types/data/genBlock/genListViewBlock.ts +1 -1
- package/src/types/data/genBlock/genQueryComponent.ts +1 -1
- package/src/types/data/genBlock/genSelectBlock.ts +2 -1
- package/src/types/data/genBlock/genTableBlock.ts +1 -1
- package/src/types/data/genBlock/genUpdateBlock.ts +5 -7
- package/src/types/logic/Logic.ts +35 -0
- package/src/types/logic/LogicItem.ts +305 -217
- package/src/types/logic/translator.js +64 -50
- 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.
|
|
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.
|
|
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[] = [
|
|
217
|
-
'
|
|
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[] = [
|
|
220
|
-
'
|
|
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) {
|
|
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 {
|
|
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(
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
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
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
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
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
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(
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
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(
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
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
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
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
|
|
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,
|
|
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
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
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
|
-
|
|
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(
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
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(
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
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
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
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(
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
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
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
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) {
|
|
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 {
|
|
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
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
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(
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
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
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
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(
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
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 &&
|
|
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() {
|
|
1192
|
+
toScript() {
|
|
1193
|
+
return '';
|
|
1194
|
+
}
|
|
1107
1195
|
|
|
1108
1196
|
getLogicItem(type: LOGIC_TYPE) {
|
|
1109
1197
|
let node: LogicItem = this;
|