@lcap/nasl 0.3.9 → 0.3.10-beta.oom3
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/create/errHandles.js +7 -2
- package/out/service/create/errHandles.js.map +1 -1
- package/out/service/debugger/debugger.d.ts +3 -0
- package/out/service/debugger/debugger.js +95 -0
- package/out/service/debugger/debugger.js.map +1 -0
- package/out/service/logic/logic.d.ts +27 -0
- package/out/service/logic/logic.js +20 -0
- package/out/service/logic/logic.js.map +1 -1
- package/out/service/page/element.d.ts +9 -0
- package/out/service/page/element.js +6 -0
- package/out/service/page/element.js.map +1 -1
- package/out/service/permission/api.d.ts +57 -0
- package/out/service/permission/api.js +41 -0
- package/out/service/permission/api.js.map +1 -0
- package/out/service/permission/index.d.ts +2 -0
- package/out/service/permission/index.js +17 -0
- package/out/service/permission/index.js.map +1 -0
- package/out/service/webFile/index.js +5 -0
- package/out/service/webFile/index.js.map +1 -1
- package/out/types/app/App.d.ts +4 -0
- package/out/types/app/App.js +29 -0
- package/out/types/app/App.js.map +1 -1
- package/out/types/app/Service.d.ts +2 -2
- package/out/types/app/Service.js +28 -3
- package/out/types/app/Service.js.map +1 -1
- package/out/types/cache.d.ts +6 -0
- package/out/types/cache.js +54 -0
- package/out/types/cache.js.map +1 -0
- package/out/types/common/Vertex.d.ts +25 -0
- package/out/types/common/Vertex.js +40 -0
- package/out/types/common/Vertex.js.map +1 -1
- package/out/types/data/Entity.js +1 -0
- package/out/types/data/Entity.js.map +1 -1
- package/out/types/data/Enum.d.ts +5 -0
- package/out/types/data/Enum.js +5 -0
- package/out/types/data/Enum.js.map +1 -1
- package/out/types/data/Interface.js +5 -3
- package/out/types/data/Interface.js.map +1 -1
- package/out/types/data/genBlock/genCreateBlock.js +5 -5
- package/out/types/data/genBlock/genCreateBlock.js.map +1 -1
- package/out/types/data/genBlock/genCurdBlock.js +3 -3
- package/out/types/data/genBlock/genCurdBlock.js.map +1 -1
- package/out/types/data/genBlock/genEnumSelectBlock.d.ts +1 -1
- package/out/types/data/genBlock/genEnumSelectBlock.js +2 -2
- package/out/types/data/genBlock/genEnumSelectBlock.js.map +1 -1
- package/out/types/data/genBlock/genGridViewBlock.js +12 -1
- package/out/types/data/genBlock/genGridViewBlock.js.map +1 -1
- package/out/types/data/genBlock/genListViewBlock.js +2 -2
- package/out/types/data/genBlock/genSelectBlock.js +2 -2
- package/out/types/data/genBlock/genTableBlock.js +14 -3
- package/out/types/data/genBlock/genTableBlock.js.map +1 -1
- package/out/types/data/genBlock/genUpdateBlock.js +5 -5
- package/out/types/data/genBlock/genUpdateBlock.js.map +1 -1
- package/out/types/data/systemTypes.js +47 -0
- package/out/types/data/systemTypes.js.map +1 -1
- package/out/types/enum.d.ts +6 -0
- package/out/types/enum.js +11 -0
- package/out/types/enum.js.map +1 -0
- package/out/types/generator/hotReload.d.ts +2 -0
- package/out/types/generator/hotReload.js +12 -1
- package/out/types/generator/hotReload.js.map +1 -1
- package/out/types/index.d.ts +5 -1
- package/out/types/index.js +8 -2
- package/out/types/index.js.map +1 -1
- package/out/types/logic/BreakPoint.d.ts +42 -0
- package/out/types/logic/BreakPoint.js +155 -0
- package/out/types/logic/BreakPoint.js.map +1 -0
- package/out/types/logic/Debugger.d.ts +156 -0
- package/out/types/logic/Debugger.js +912 -0
- package/out/types/logic/Debugger.js.map +1 -0
- package/out/types/logic/Logic.d.ts +28 -0
- package/out/types/logic/Logic.js +116 -31
- package/out/types/logic/Logic.js.map +1 -1
- package/out/types/logic/LogicItem.d.ts +1 -0
- package/out/types/logic/LogicItem.js +43 -24
- package/out/types/logic/LogicItem.js.map +1 -1
- package/out/types/logic/Param.d.ts +1 -0
- package/out/types/logic/Param.js +38 -20
- package/out/types/logic/Param.js.map +1 -1
- package/out/types/logic/Return.js +14 -19
- package/out/types/logic/Return.js.map +1 -1
- package/out/types/logic/Variable.js +14 -19
- package/out/types/logic/Variable.js.map +1 -1
- package/out/types/logic/translator.js +0 -2
- package/out/types/logic/translator.js.map +1 -1
- package/out/types/nuims/Nuims.d.ts +1 -1
- package/out/types/nuims/Nuims.js +11 -4
- package/out/types/nuims/Nuims.js.map +1 -1
- package/out/types/page/Element.d.ts +5 -0
- package/out/types/page/Element.js +115 -132
- package/out/types/page/Element.js.map +1 -1
- package/out/types/page/Event.js.map +1 -1
- package/out/types/page/Page.d.ts +1 -0
- package/out/types/page/Page.js +59 -27
- package/out/types/page/Page.js.map +1 -1
- package/out/types/page/View.d.ts +1 -1
- package/out/types/page/View.js +38 -33
- package/out/types/page/View.js.map +1 -1
- package/out/types/page/ViewParam.d.ts +1 -0
- package/out/types/page/ViewParam.js +23 -4
- package/out/types/page/ViewParam.js.map +1 -1
- package/out/types/page/ViewVariable.js +13 -18
- package/out/types/page/ViewVariable.js.map +1 -1
- package/out/types/permission/Permission.d.ts +41 -0
- package/out/types/permission/Permission.js +122 -0
- package/out/types/permission/Permission.js.map +1 -0
- package/package.json +1 -2
- package/src/service/create/errHandles.js +6 -2
- package/src/service/developPermission/api.js +37 -0
- package/src/service/developPermission/index.js +13 -0
- package/src/service/logic/logic.js +20 -0
- package/src/service/page/element.js +6 -0
- package/src/service/permission/api.js +38 -0
- package/src/service/permission/index.js +13 -0
- package/src/service/webFile/index.js +6 -1
- package/src/types/app/App.ts +32 -1
- package/src/types/app/Service.ts +32 -3
- package/src/types/cache.ts +50 -0
- package/src/types/common/Vertex.ts +30 -0
- package/src/types/data/Entity.ts +1 -0
- package/src/types/data/Enum.ts +5 -0
- package/src/types/data/Interface.ts +4 -3
- package/src/types/data/genBlock/genCreateBlock.ts +5 -5
- package/src/types/data/genBlock/genCurdBlock.ts +3 -3
- package/src/types/data/genBlock/genEnumSelectBlock.ts +2 -2
- package/src/types/data/genBlock/genGridViewBlock.ts +12 -1
- package/src/types/data/genBlock/genListViewBlock.ts +2 -2
- package/src/types/data/genBlock/genSelectBlock.ts +2 -2
- package/src/types/data/genBlock/genTableBlock.ts +14 -3
- package/src/types/data/genBlock/genUpdateBlock.ts +5 -5
- package/src/types/data/systemTypes.ts +47 -0
- package/src/types/enum.ts +6 -0
- package/src/types/generator/hotReload.ts +10 -0
- package/src/types/index.ts +5 -1
- package/src/types/logic/Logic.ts +109 -28
- package/src/types/logic/LogicItem.ts +48 -28
- package/src/types/logic/Param.ts +26 -8
- package/src/types/logic/Return.ts +4 -9
- package/src/types/logic/Variable.ts +4 -8
- package/src/types/logic/translator.js +0 -4
- package/src/types/logic/translator_backup.js +5 -16
- package/src/types/nuims/Nuims.ts +11 -5
- package/src/types/page/Element.ts +64 -77
- package/src/types/page/Event.ts +0 -3
- package/src/types/page/Page.ts +73 -40
- package/src/types/page/View.ts +18 -12
- package/src/types/page/ViewParam.ts +22 -3
- package/src/types/page/ViewVariable.ts +4 -8
- package/src/types/permission/Permission.ts +112 -0
|
@@ -23,6 +23,7 @@ export const systemTypeList = [
|
|
|
23
23
|
{ kind: 'systemType', text: 'UploadEvent', value: '#/systemTypes/UploadEvent' },
|
|
24
24
|
{ kind: 'systemType', text: 'UploadErrorEvent', value: '#/systemTypes/UploadErrorEvent' },
|
|
25
25
|
{ kind: 'systemType', text: 'SortEvent', value: '#/systemTypes/SortEvent' },
|
|
26
|
+
{ kind: 'systemType', text: 'PoiInfo', value: '#/systemTypes/PoiInfo' },
|
|
26
27
|
];
|
|
27
28
|
|
|
28
29
|
export const systemTypeMap: { [name: string]: ObjectSchema } = {
|
|
@@ -1512,4 +1513,50 @@ export const systemTypeMap: { [name: string]: ObjectSchema } = {
|
|
|
1512
1513
|
},
|
|
1513
1514
|
],
|
|
1514
1515
|
},
|
|
1516
|
+
'#/systemTypes/PoiInfo': {
|
|
1517
|
+
name: 'PoiInfo',
|
|
1518
|
+
type: 'object',
|
|
1519
|
+
propertyList: [
|
|
1520
|
+
{
|
|
1521
|
+
typeKey: '#/basicTypes/String',
|
|
1522
|
+
type: 'string',
|
|
1523
|
+
format: '',
|
|
1524
|
+
name: 'source',
|
|
1525
|
+
description: '信息来源',
|
|
1526
|
+
isLeaf: true,
|
|
1527
|
+
},
|
|
1528
|
+
{
|
|
1529
|
+
typeKey: '#/basicTypes/String',
|
|
1530
|
+
type: 'string',
|
|
1531
|
+
format: '',
|
|
1532
|
+
name: 'id',
|
|
1533
|
+
description: 'POI点的id',
|
|
1534
|
+
isLeaf: true,
|
|
1535
|
+
},
|
|
1536
|
+
{
|
|
1537
|
+
typeKey: '#/basicTypes/String',
|
|
1538
|
+
type: 'string',
|
|
1539
|
+
format: '',
|
|
1540
|
+
name: 'name',
|
|
1541
|
+
description: '名称',
|
|
1542
|
+
isLeaf: true,
|
|
1543
|
+
},
|
|
1544
|
+
{
|
|
1545
|
+
typeKey: '#/basicTypes/String',
|
|
1546
|
+
type: 'string',
|
|
1547
|
+
format: '',
|
|
1548
|
+
name: 'location',
|
|
1549
|
+
description: '经纬度',
|
|
1550
|
+
isLeaf: true,
|
|
1551
|
+
},
|
|
1552
|
+
{
|
|
1553
|
+
typeKey: '#/basicTypes/String',
|
|
1554
|
+
type: 'string',
|
|
1555
|
+
format: '',
|
|
1556
|
+
name: 'address',
|
|
1557
|
+
description: '地址',
|
|
1558
|
+
isLeaf: true,
|
|
1559
|
+
},
|
|
1560
|
+
],
|
|
1561
|
+
},
|
|
1515
1562
|
};
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import webFileService from '../../service/webFile';
|
|
2
2
|
|
|
3
|
+
let saveLastModifiedEnabled = true;
|
|
4
|
+
export function enableSaveLastModified() {
|
|
5
|
+
saveLastModifiedEnabled = true;
|
|
6
|
+
}
|
|
7
|
+
export function disableSaveLastModified() {
|
|
8
|
+
saveLastModifiedEnabled = false;
|
|
9
|
+
}
|
|
10
|
+
|
|
3
11
|
/**
|
|
4
12
|
* 生成上次修改的缓存
|
|
5
13
|
* @param serviceId
|
|
6
14
|
* @param path
|
|
7
15
|
*/
|
|
8
16
|
export function saveLastModified(serviceId: string, path?: string) {
|
|
17
|
+
if(!saveLastModifiedEnabled) return;
|
|
18
|
+
|
|
9
19
|
return webFileService.saveFile({
|
|
10
20
|
body: {
|
|
11
21
|
serviceId,
|
package/src/types/index.ts
CHANGED
|
@@ -22,7 +22,7 @@ export { Interface } from './data/Interface';
|
|
|
22
22
|
export { Category } from './data/GlobalLogicNode';
|
|
23
23
|
export { Logic } from './logic/Logic';
|
|
24
24
|
export { LogicItem, LogicNode, ExpressionNode, evaluate } from './logic/LogicItem';
|
|
25
|
-
export { BaseVariable, updateVariablesChildrenSchema, updateAllVariablesChildrenSchema } from './logic/BaseVariable';
|
|
25
|
+
export { BaseVariable, updateVariablesChildrenSchema, updateAllVariablesChildrenSchema, variablesMap } from './logic/BaseVariable';
|
|
26
26
|
export { Param } from './logic/Param';
|
|
27
27
|
export { Variable } from './logic/Variable';
|
|
28
28
|
export { Return } from './logic/Return';
|
|
@@ -57,6 +57,7 @@ export { default as login } from './login';
|
|
|
57
57
|
export * as utils from './utils';
|
|
58
58
|
export * as genBlock from './data/genBlock';
|
|
59
59
|
export * as generator from './generator';
|
|
60
|
+
export { Permission } from './permission/Permission';
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
63
|
* 层级枚举
|
|
@@ -75,6 +76,7 @@ export enum LEVEL_ENUM {
|
|
|
75
76
|
|
|
76
77
|
logic = 'logic',
|
|
77
78
|
param = 'param',
|
|
79
|
+
timer = 'timer',
|
|
78
80
|
variable = 'variable',
|
|
79
81
|
return = 'return',
|
|
80
82
|
interface = 'interface',
|
|
@@ -104,6 +106,7 @@ export enum LEVEL_ENUM {
|
|
|
104
106
|
processComponent = 'processComponent',
|
|
105
107
|
processParam = 'processParam',
|
|
106
108
|
processReturn = 'processReturn',
|
|
109
|
+
processTimer = 'processTimer',
|
|
107
110
|
processProperty = 'processProperty',
|
|
108
111
|
processComponentReturn = 'processComponentReturn',
|
|
109
112
|
processComponentVariable = 'processComponentVariable',
|
|
@@ -121,6 +124,7 @@ export const LEVEL_NAME_MAP = {
|
|
|
121
124
|
|
|
122
125
|
logic: '逻辑',
|
|
123
126
|
param: '输入参数',
|
|
127
|
+
timer: '定时任务',
|
|
124
128
|
variable: '局部变量',
|
|
125
129
|
return: '输出参数',
|
|
126
130
|
interface: '接口',
|
package/src/types/logic/Logic.ts
CHANGED
|
@@ -5,6 +5,30 @@ import View from '../page/View';
|
|
|
5
5
|
import { ExpressionNode, LogicItem, LogicNode } from './LogicItem';
|
|
6
6
|
import { convert2SchemaType } from '../data/dataTypeUtils';
|
|
7
7
|
import { isPlainObject, throttle } from 'lodash';
|
|
8
|
+
import { refreshInterfaces, refreshView, refreshPages } from '../cache';
|
|
9
|
+
import { BusinessCode } from '../enum';
|
|
10
|
+
|
|
11
|
+
export function catchFn(logic: Logic) {
|
|
12
|
+
return async (err: any) => {
|
|
13
|
+
const code = err?.code;
|
|
14
|
+
if([BusinessCode.ElementExist, BusinessCode.ElementNotExist].includes(code)) {
|
|
15
|
+
if(logic.interface) {
|
|
16
|
+
await refreshInterfaces();
|
|
17
|
+
} else if(logic.view) {
|
|
18
|
+
await refreshView(logic.view);
|
|
19
|
+
}
|
|
20
|
+
} else if(code === BusinessCode.ParentElementNotExist) { // 父节点不存在。视图添加逻辑,发现视图不存在
|
|
21
|
+
if(logic.view) {
|
|
22
|
+
await refreshPages();
|
|
23
|
+
}
|
|
24
|
+
} else
|
|
25
|
+
config.defaultApp?.emit('saved', err);
|
|
26
|
+
|
|
27
|
+
config.defaultApp?.history.load();
|
|
28
|
+
|
|
29
|
+
throw err;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
8
32
|
|
|
9
33
|
/**
|
|
10
34
|
* 逻辑类
|
|
@@ -123,6 +147,19 @@ export class Logic extends Vertex {
|
|
|
123
147
|
/**
|
|
124
148
|
* @param source 需要合并的部分参数
|
|
125
149
|
*/
|
|
150
|
+
/**
|
|
151
|
+
* 逻辑配置的cron表达式
|
|
152
|
+
*/
|
|
153
|
+
@immutable()
|
|
154
|
+
public cron: string = undefined;
|
|
155
|
+
/**
|
|
156
|
+
* 定时类型,当前只能是cronTrigger
|
|
157
|
+
*/
|
|
158
|
+
@immutable()
|
|
159
|
+
public triggerType: string = undefined;
|
|
160
|
+
/**
|
|
161
|
+
* 定时任务
|
|
162
|
+
*/
|
|
126
163
|
constructor(source?: Partial<Logic>) {
|
|
127
164
|
super();
|
|
128
165
|
source && this.assign(source);
|
|
@@ -152,7 +189,7 @@ export class Logic extends Vertex {
|
|
|
152
189
|
operationDesc: actionOptions?.actionDesc || `添加逻辑"${this.name}"`,
|
|
153
190
|
},
|
|
154
191
|
body,
|
|
155
|
-
});
|
|
192
|
+
}).catch(catchFn(this));
|
|
156
193
|
this.deepPick(result, ['id']);
|
|
157
194
|
this.pick(result, ['playgroundId']);
|
|
158
195
|
this.assign({ body: result.body.map((logicNode) => LogicNode.from(logicNode, this, null)) });
|
|
@@ -180,9 +217,8 @@ export class Logic extends Vertex {
|
|
|
180
217
|
*/
|
|
181
218
|
@action('删除逻辑')
|
|
182
219
|
async delete(none?: void, actionOptions?: ActionOptions) {
|
|
183
|
-
config.defaultApp?.emit('saving');
|
|
184
|
-
|
|
185
220
|
if (this.id) {
|
|
221
|
+
config.defaultApp?.emit('saving');
|
|
186
222
|
const body = this.toPlainJSON();
|
|
187
223
|
if (this.view) {
|
|
188
224
|
body.moduleId = this.view.id;
|
|
@@ -191,19 +227,15 @@ export class Logic extends Vertex {
|
|
|
191
227
|
body.moduleId = this.interface.service.id;
|
|
192
228
|
body.moduleType = 'microService';
|
|
193
229
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
} catch (err) {
|
|
204
|
-
await config.defaultApp?.history.load();
|
|
205
|
-
throw err;
|
|
206
|
-
}
|
|
230
|
+
|
|
231
|
+
await logicService.delete({
|
|
232
|
+
headers: {
|
|
233
|
+
appId: config.defaultApp?.id,
|
|
234
|
+
operationAction: actionOptions?.actionName || 'Logic.delete',
|
|
235
|
+
operationDesc: actionOptions?.actionDesc || `删除逻辑"${this.name}"`,
|
|
236
|
+
},
|
|
237
|
+
body,
|
|
238
|
+
}).catch(catchFn(this));
|
|
207
239
|
|
|
208
240
|
if (this.view) {
|
|
209
241
|
const { logics } = this.view.$def;
|
|
@@ -249,7 +281,7 @@ export class Logic extends Vertex {
|
|
|
249
281
|
operationDesc: actionOptions?.actionDesc || `修改逻辑"${this.name}"`,
|
|
250
282
|
},
|
|
251
283
|
body,
|
|
252
|
-
});
|
|
284
|
+
}).catch(catchFn(this));
|
|
253
285
|
|
|
254
286
|
await then?.();
|
|
255
287
|
await config.defaultApp?.history.load();
|
|
@@ -305,17 +337,16 @@ export class Logic extends Vertex {
|
|
|
305
337
|
return this.contentPromise;
|
|
306
338
|
|
|
307
339
|
return this.contentPromise = (async () => {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
} catch (err) {}
|
|
340
|
+
const result = await logicService.loadDetail({
|
|
341
|
+
query: {
|
|
342
|
+
moduleId: this.moduleId,
|
|
343
|
+
moduleType: this.moduleType,
|
|
344
|
+
id: this.id,
|
|
345
|
+
},
|
|
346
|
+
config: { noErrorTip: true },
|
|
347
|
+
}).catch(catchFn(this));
|
|
348
|
+
const newLogic = Logic.from(result, this.interface || this.view || this.processComponent, this);
|
|
349
|
+
this.assign(newLogic);
|
|
319
350
|
return this;
|
|
320
351
|
})().finally(() => this.contentPromise = undefined);
|
|
321
352
|
}
|
|
@@ -437,6 +468,56 @@ export class Logic extends Vertex {
|
|
|
437
468
|
|
|
438
469
|
return logic;
|
|
439
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* 更新定时任务
|
|
473
|
+
*/
|
|
474
|
+
@action('更新定时任务')
|
|
475
|
+
async updateTimer(cron: string) {
|
|
476
|
+
this.assign({ cron });
|
|
477
|
+
this.triggerType = 'cronTrigger';
|
|
478
|
+
await this.update(undefined, {
|
|
479
|
+
actionDesc: `设置定时任务"为"${cron}"`,
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
if (this.view) {
|
|
483
|
+
this.view.page.service.emit('pageTreeChange');
|
|
484
|
+
this.emit('change');
|
|
485
|
+
}
|
|
486
|
+
return this;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* 验证表达式正确与否
|
|
490
|
+
*/
|
|
491
|
+
async validateTimer() {
|
|
492
|
+
const body = this.toPlainJSON();
|
|
493
|
+
const result = await logicService.validateTimer({
|
|
494
|
+
body,
|
|
495
|
+
config: {
|
|
496
|
+
noErrorTip: true,
|
|
497
|
+
},
|
|
498
|
+
});
|
|
499
|
+
return result;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* 输出最近十次运行结果
|
|
503
|
+
*/
|
|
504
|
+
async testTimer() {
|
|
505
|
+
const body = this.toPlainJSON();
|
|
506
|
+
const result = await logicService.testTimer({
|
|
507
|
+
body,
|
|
508
|
+
});
|
|
509
|
+
return result;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* 更新接口缓存
|
|
513
|
+
*/
|
|
514
|
+
async updateCronCache() {
|
|
515
|
+
const body = this.toPlainJSON();
|
|
516
|
+
const result = await logicService.updateCronCache({
|
|
517
|
+
body,
|
|
518
|
+
});
|
|
519
|
+
return result;
|
|
520
|
+
}
|
|
440
521
|
}
|
|
441
522
|
|
|
442
523
|
export default Logic;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { immutable, excludedInJSON,
|
|
2
|
-
import { config,
|
|
1
|
+
import { immutable, excludedInJSON, action } from '../decorators';
|
|
2
|
+
import { config, typeCheck, utils, Vertex, LEVEL_ENUM, Logic, Schema, ActionOptions, ACTION_MODE } from '..';
|
|
3
3
|
import { logicService } from '../../service/logic';
|
|
4
|
-
import { assert } from 'console';
|
|
5
4
|
import { traverse } from '../utils';
|
|
6
5
|
import { vertexsMap } from '../cacheData';
|
|
7
6
|
import { getSchemaOfExpressionNode } from './tools';
|
|
8
7
|
import Structure from '../data/Structure';
|
|
8
|
+
import { refreshLogic } from '../cache';
|
|
9
|
+
import { BusinessCode } from '../enum';
|
|
9
10
|
|
|
10
11
|
export enum LOGIC_TYPE {
|
|
11
12
|
// LogicNode
|
|
@@ -56,6 +57,18 @@ export enum LOGIC_TYPE {
|
|
|
56
57
|
QueryAggregateExpression = 'QueryAggregateExpression',
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
const atomicList = [
|
|
61
|
+
LOGIC_TYPE.Identifier,
|
|
62
|
+
LOGIC_TYPE.NumericLiteral,
|
|
63
|
+
LOGIC_TYPE.BooleanLiteral,
|
|
64
|
+
LOGIC_TYPE.StringLiteral,
|
|
65
|
+
LOGIC_TYPE.NullLiteral,
|
|
66
|
+
LOGIC_TYPE.UnaryExpression,
|
|
67
|
+
LOGIC_TYPE.MemberExpression,
|
|
68
|
+
LOGIC_TYPE.Unparsed,
|
|
69
|
+
LOGIC_TYPE.BuiltInFunction,
|
|
70
|
+
];
|
|
71
|
+
|
|
59
72
|
export function evaluate(node: LogicNode | ExpressionNode, finalCode = true): string {
|
|
60
73
|
if (!node)
|
|
61
74
|
return '';
|
|
@@ -76,11 +89,11 @@ export function evaluate(node: LogicNode | ExpressionNode, finalCode = true): st
|
|
|
76
89
|
|
|
77
90
|
if (node.type === 'BinaryExpression') {
|
|
78
91
|
let left: string = evaluate(<LogicNode>node.left, finalCode);
|
|
79
|
-
if (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression)
|
|
92
|
+
if (!atomicList.includes((node.left as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
|
|
80
93
|
left = `(${left})`;
|
|
81
94
|
|
|
82
95
|
let right: string = evaluate(<LogicNode>node.right, finalCode);
|
|
83
|
-
if (!finalCode && node.
|
|
96
|
+
if (!atomicList.includes((node.right as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
|
|
84
97
|
right = `(${right})`;
|
|
85
98
|
|
|
86
99
|
return `${left} ${node.operator} ${right}`;
|
|
@@ -88,13 +101,11 @@ export function evaluate(node: LogicNode | ExpressionNode, finalCode = true): st
|
|
|
88
101
|
|
|
89
102
|
if (node.type === 'LogicalExpression') {
|
|
90
103
|
let left: string = evaluate(<LogicNode>node.left, finalCode);
|
|
91
|
-
if (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression)
|
|
104
|
+
if (!atomicList.includes((node.left as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
|
|
92
105
|
left = `(${left})`;
|
|
93
|
-
|
|
94
106
|
let right: string = evaluate(<LogicNode>node.right, finalCode);
|
|
95
|
-
if (!finalCode && node.
|
|
107
|
+
if (!atomicList.includes((node.right as any)?.type) || (!finalCode && node.left?.type === LOGIC_TYPE.MemberExpression))
|
|
96
108
|
right = `(${right})`;
|
|
97
|
-
|
|
98
109
|
return `${left} ${node.operator} ${right}`;
|
|
99
110
|
}
|
|
100
111
|
|
|
@@ -209,6 +220,18 @@ export const logicItemArrayKeyOfLogicItem: string[] = ['body', 'consequent', 'al
|
|
|
209
220
|
'groupBy', 'orderBy', 'selectElementList', 'joinPartList', 'onExpressionList', 'where', 'having',
|
|
210
221
|
];
|
|
211
222
|
|
|
223
|
+
export function catchFn(logic: Logic) {
|
|
224
|
+
return async (err: any) => {
|
|
225
|
+
if (err.code !== BusinessCode.HasReferenced) // 节点被引用,不用刷新数据
|
|
226
|
+
await refreshLogic(logic);
|
|
227
|
+
else
|
|
228
|
+
config.defaultApp?.emit('saved', err);
|
|
229
|
+
|
|
230
|
+
config.defaultApp?.history.load();
|
|
231
|
+
throw err;
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
212
235
|
/**
|
|
213
236
|
* 逻辑项类
|
|
214
237
|
*/
|
|
@@ -432,7 +455,7 @@ export class LogicItem extends Vertex {
|
|
|
432
455
|
operationIgnore: actionOptions?.actionIgnore,
|
|
433
456
|
},
|
|
434
457
|
body,
|
|
435
|
-
});
|
|
458
|
+
}).catch(catchFn(this.logic));
|
|
436
459
|
this.deepPick(result, ['id', 'parentId', 'parentAttr', 'joinPartRef', 'structureRef']);
|
|
437
460
|
}
|
|
438
461
|
|
|
@@ -548,7 +571,7 @@ export class LogicItem extends Vertex {
|
|
|
548
571
|
offsetY,
|
|
549
572
|
},
|
|
550
573
|
},
|
|
551
|
-
});
|
|
574
|
+
}).catch(catchFn(this.logic));
|
|
552
575
|
}
|
|
553
576
|
|
|
554
577
|
if (!(this.parentId === parentId && this.parentId === this.logic.playgroundId && this.parentAttr === parentAttr)) {
|
|
@@ -612,6 +635,8 @@ export class LogicItem extends Vertex {
|
|
|
612
635
|
* @param targetId
|
|
613
636
|
*/
|
|
614
637
|
static async paste(logicItems: LogicItem[] | LogicItem, targetType: 'logic' | 'html' | 'processComponent', targetId: string) {
|
|
638
|
+
config.defaultApp?.emit('saving');
|
|
639
|
+
|
|
615
640
|
if (!Array.isArray(logicItems))
|
|
616
641
|
logicItems = [logicItems];
|
|
617
642
|
|
|
@@ -630,7 +655,7 @@ export class LogicItem extends Vertex {
|
|
|
630
655
|
operationAction: 'LogicItem.paste',
|
|
631
656
|
operationDesc: `粘贴逻辑项"${logicItems[0].label || logicItems[0].type}"`,
|
|
632
657
|
},
|
|
633
|
-
});
|
|
658
|
+
}).catch(catchFn(vertexsMap.get(targetId) as Logic));
|
|
634
659
|
|
|
635
660
|
LogicItem.redoPaste(res);
|
|
636
661
|
}
|
|
@@ -778,21 +803,16 @@ export class LogicItem extends Vertex {
|
|
|
778
803
|
delete body.index;
|
|
779
804
|
///
|
|
780
805
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
});
|
|
792
|
-
} catch (err) {
|
|
793
|
-
await config.defaultApp?.history.load();
|
|
794
|
-
throw err;
|
|
795
|
-
}
|
|
806
|
+
await logicService.removeItem({
|
|
807
|
+
headers: {
|
|
808
|
+
appId: config.defaultApp?.id,
|
|
809
|
+
serviceId: this.logic?.interface?.serviceId,
|
|
810
|
+
operationAction: 'LogicItem.delete',
|
|
811
|
+
operationDesc: `删除逻辑项"${this.label || this.type}"`,
|
|
812
|
+
|
|
813
|
+
},
|
|
814
|
+
body,
|
|
815
|
+
}).catch(catchFn(this.logic));
|
|
796
816
|
}
|
|
797
817
|
}
|
|
798
818
|
|
|
@@ -883,7 +903,7 @@ export class LogicItem extends Vertex {
|
|
|
883
903
|
operationIgnore: actionOptions?.actionIgnore,
|
|
884
904
|
},
|
|
885
905
|
body,
|
|
886
|
-
});
|
|
906
|
+
}).catch(catchFn(this.logic));
|
|
887
907
|
// this.deepPick(result, ['id', 'parentId', 'parentAttr']);
|
|
888
908
|
|
|
889
909
|
// 合并params里的id
|
package/src/types/logic/Param.ts
CHANGED
|
@@ -4,6 +4,29 @@ import { paramService } from '../../service/logic';
|
|
|
4
4
|
import { convert2RefType, convert2SchemaType } from '../data/dataTypeUtils';
|
|
5
5
|
import { getBasicTypeDefaultValue } from '../data/basicTypes';
|
|
6
6
|
import { schemaService } from '../../service/common';
|
|
7
|
+
import { refreshLogic, refreshInterfaces, refreshView } from '../cache';
|
|
8
|
+
import { BusinessCode } from '../enum';
|
|
9
|
+
|
|
10
|
+
export function catchFn(logic: Logic) {
|
|
11
|
+
return async (err: any) => {
|
|
12
|
+
const code = err?.code;
|
|
13
|
+
// 节点已存在; 节点不存在
|
|
14
|
+
if([BusinessCode.ElementExist, BusinessCode.ElementNotExist].includes(code)) {
|
|
15
|
+
await refreshLogic(logic);
|
|
16
|
+
} else if(code === BusinessCode.ParentElementNotExist) { // 父节点不存在,即逻辑不存在
|
|
17
|
+
if(logic.interface) {
|
|
18
|
+
await refreshInterfaces();
|
|
19
|
+
} else if(logic.view) {
|
|
20
|
+
await refreshView(logic.view);
|
|
21
|
+
}
|
|
22
|
+
} else
|
|
23
|
+
config.defaultApp?.emit('saved', err);
|
|
24
|
+
|
|
25
|
+
config.defaultApp?.history.load();
|
|
26
|
+
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
7
30
|
|
|
8
31
|
/**
|
|
9
32
|
* 逻辑输入参数
|
|
@@ -60,7 +83,7 @@ export class Param extends BaseVariable {
|
|
|
60
83
|
operationDesc: actionOptions?.actionDesc || `添加逻辑"${this.logic.name}"输入参数"${this.name}"`,
|
|
61
84
|
},
|
|
62
85
|
body,
|
|
63
|
-
});
|
|
86
|
+
}).catch(catchFn(this.logic));
|
|
64
87
|
// convert2RefType(result.schema);
|
|
65
88
|
this.deepPick(result, ['id']);
|
|
66
89
|
this.assign({ code: this.genCode() });
|
|
@@ -85,7 +108,6 @@ export class Param extends BaseVariable {
|
|
|
85
108
|
config.defaultApp?.emit('saving');
|
|
86
109
|
|
|
87
110
|
if (this.id) {
|
|
88
|
-
try {
|
|
89
111
|
await paramService.delete({
|
|
90
112
|
headers: {
|
|
91
113
|
appId: config.defaultApp?.id,
|
|
@@ -96,11 +118,7 @@ export class Param extends BaseVariable {
|
|
|
96
118
|
loValId: this.id,
|
|
97
119
|
logicId: this.logic.id,
|
|
98
120
|
},
|
|
99
|
-
});
|
|
100
|
-
} catch(err) {
|
|
101
|
-
await config.defaultApp?.history.load();
|
|
102
|
-
throw err;
|
|
103
|
-
}
|
|
121
|
+
}).catch(catchFn(this.logic));
|
|
104
122
|
}
|
|
105
123
|
|
|
106
124
|
const index = this.logic.params.indexOf(this);
|
|
@@ -133,7 +151,7 @@ export class Param extends BaseVariable {
|
|
|
133
151
|
operationDesc: actionOptions?.actionDesc || `修改逻辑输入参数"${this.name}"`,
|
|
134
152
|
},
|
|
135
153
|
body,
|
|
136
|
-
});
|
|
154
|
+
}).catch(catchFn(this.logic));
|
|
137
155
|
this.schema.id = result.schema.id;
|
|
138
156
|
// convert2RefType(result.schema);
|
|
139
157
|
// this.plainAssign(result);
|
|
@@ -4,7 +4,7 @@ import { paramService } from '../../service/logic';
|
|
|
4
4
|
import { convert2RefType, convert2SchemaType } from '../data/dataTypeUtils';
|
|
5
5
|
import { getBasicTypeDefaultValue } from '../data/basicTypes';
|
|
6
6
|
import { schemaService } from '../../service/common';
|
|
7
|
-
|
|
7
|
+
import { catchFn } from './Param';
|
|
8
8
|
/**
|
|
9
9
|
* 逻辑输出参数
|
|
10
10
|
*/
|
|
@@ -50,7 +50,7 @@ export class Return extends BaseVariable {
|
|
|
50
50
|
operationDesc: actionOptions?.actionDesc || `添加逻辑"${this.logic.name}"输出参数"${this.name}"`,
|
|
51
51
|
},
|
|
52
52
|
body,
|
|
53
|
-
});
|
|
53
|
+
}).catch(catchFn(this.logic));
|
|
54
54
|
// convert2RefType(result.schema);
|
|
55
55
|
this.deepPick(result, ['id']);
|
|
56
56
|
this.assign({ code: this.genCode() });
|
|
@@ -75,7 +75,6 @@ export class Return extends BaseVariable {
|
|
|
75
75
|
config.defaultApp?.emit('saving');
|
|
76
76
|
|
|
77
77
|
if (this.id) {
|
|
78
|
-
try {
|
|
79
78
|
await paramService.delete({
|
|
80
79
|
headers: {
|
|
81
80
|
appId: config.defaultApp?.id,
|
|
@@ -86,11 +85,7 @@ export class Return extends BaseVariable {
|
|
|
86
85
|
loValId: this.id,
|
|
87
86
|
logicId: this.logic.id,
|
|
88
87
|
},
|
|
89
|
-
});
|
|
90
|
-
} catch(err) {
|
|
91
|
-
await config.defaultApp?.history.load();
|
|
92
|
-
throw err;
|
|
93
|
-
}
|
|
88
|
+
}).catch(catchFn(this.logic));
|
|
94
89
|
}
|
|
95
90
|
|
|
96
91
|
const index = this.logic.returns.indexOf(this);
|
|
@@ -123,7 +118,7 @@ export class Return extends BaseVariable {
|
|
|
123
118
|
operationDesc: actionOptions?.actionDesc || `修改逻辑输出参数"${this.name}"`,
|
|
124
119
|
},
|
|
125
120
|
body,
|
|
126
|
-
});
|
|
121
|
+
}).catch(catchFn(this.logic));
|
|
127
122
|
this.schema.id = result.schema.id;
|
|
128
123
|
// convert2RefType(result.schema);
|
|
129
124
|
// this.plainAssign(result);
|
|
@@ -4,6 +4,7 @@ import { paramService } from '../../service/logic';
|
|
|
4
4
|
import { convert2RefType, convert2SchemaType } from '../data/dataTypeUtils';
|
|
5
5
|
import { getBasicTypeDefaultValue } from '../data/basicTypes';
|
|
6
6
|
import { schemaService } from '../../service/common';
|
|
7
|
+
import { catchFn } from './Param';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* 逻辑局部变量
|
|
@@ -49,7 +50,7 @@ export class Variable extends BaseVariable {
|
|
|
49
50
|
operationDesc: actionOptions?.actionDesc || `添加逻辑"${this.logic.name}"局部变量"${this.name}"`,
|
|
50
51
|
},
|
|
51
52
|
body,
|
|
52
|
-
});
|
|
53
|
+
}).catch(catchFn(this.logic));
|
|
53
54
|
// convert2RefType(result.schema);
|
|
54
55
|
this.deepPick(result, ['id']);
|
|
55
56
|
this.assign({ code: this.genCode() });
|
|
@@ -73,7 +74,6 @@ export class Variable extends BaseVariable {
|
|
|
73
74
|
config.defaultApp?.emit('saving');
|
|
74
75
|
|
|
75
76
|
if (this.id) {
|
|
76
|
-
try {
|
|
77
77
|
await paramService.delete({
|
|
78
78
|
headers: {
|
|
79
79
|
appId: config.defaultApp?.id,
|
|
@@ -84,11 +84,7 @@ export class Variable extends BaseVariable {
|
|
|
84
84
|
loValId: this.id,
|
|
85
85
|
logicId: this.logic.id,
|
|
86
86
|
},
|
|
87
|
-
});
|
|
88
|
-
} catch(err) {
|
|
89
|
-
await config.defaultApp?.history.load();
|
|
90
|
-
throw err;
|
|
91
|
-
}
|
|
87
|
+
}).catch(catchFn(this.logic));
|
|
92
88
|
}
|
|
93
89
|
|
|
94
90
|
const index = this.logic.variables.indexOf(this);
|
|
@@ -120,7 +116,7 @@ export class Variable extends BaseVariable {
|
|
|
120
116
|
operationDesc: actionOptions?.actionDesc || `修改逻辑局部变量"${this.name}"`,
|
|
121
117
|
},
|
|
122
118
|
body,
|
|
123
|
-
});
|
|
119
|
+
}).catch(catchFn(this.logic));
|
|
124
120
|
this.schema.id = result.schema.id;
|
|
125
121
|
// convert2RefType(result.schema);
|
|
126
122
|
// this.plainAssign(result);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import generate from '@babel/generator';
|
|
2
1
|
import { Vertex } from '..';
|
|
3
2
|
|
|
4
3
|
function switchCase2If(cases) {
|
|
@@ -597,9 +596,6 @@ export default function (source) {
|
|
|
597
596
|
script += `${generateNode(node, index)}${newLine()}`;
|
|
598
597
|
});
|
|
599
598
|
|
|
600
|
-
// console.info("JSON generate:", JSON.stringify(logic.body));
|
|
601
|
-
// console.log(generate({ type: 'Program', body: logic.body }).code);
|
|
602
|
-
|
|
603
599
|
return `methods['${logic.name}'] = async function (${logic.params.map((param) => param.name).join(', ')}) {
|
|
604
600
|
${logic.params.length ? logic.params.map((param) => `${param.name} = ${param.name} !== undefined ? ${param.name} : this.$genInitFromSchema(${JSON.stringify(param.schema)}, ${JSON.stringify(param.defaultValue)});`).join('\n') + '' : ''}
|
|
605
601
|
${logic.variables.length ? logic.variables.map((variable) => `let ${variable.name} = this.$genInitFromSchema(${JSON.stringify(variable.schema)}, ${JSON.stringify(variable.defaultValue)});`).join('\n') + '' : ''}
|