@lcap/nasl 0.3.10 → 0.3.11
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/app/api.d.ts +1 -15
- package/out/service/app/api.js +7 -17
- package/out/service/app/api.js.map +1 -1
- package/out/service/create/errHandles.js +19 -2
- package/out/service/create/errHandles.js.map +1 -1
- package/out/service/create/index.js +5 -0
- package/out/service/create/index.js.map +1 -1
- package/out/service/logic/logic.d.ts +50 -14
- package/out/service/logic/logic.js +26 -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 +13 -0
- package/out/types/app/App.js +55 -1
- package/out/types/app/App.js.map +1 -1
- package/out/types/app/History.js +3 -2
- package/out/types/app/History.js.map +1 -1
- package/out/types/app/Service.d.ts +5 -2
- package/out/types/app/Service.js +42 -9
- 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/cacheData.js.map +1 -1
- package/out/types/common/Vertex.d.ts +25 -0
- package/out/types/common/Vertex.js +42 -1
- package/out/types/common/Vertex.js.map +1 -1
- package/out/types/data/Entity.d.ts +4 -0
- package/out/types/data/Entity.js +9 -0
- package/out/types/data/Entity.js.map +1 -1
- package/out/types/data/EntityProperty.d.ts +5 -0
- package/out/types/data/EntityProperty.js +16 -0
- package/out/types/data/EntityProperty.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/GlobalLogicNode.js +8 -1
- package/out/types/data/GlobalLogicNode.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/dataTypes.js +1 -1
- package/out/types/data/dataTypes.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/genCurdEditTableBlock.d.ts +3 -0
- package/out/types/data/genBlock/genCurdEditTableBlock.js +578 -0
- package/out/types/data/genBlock/genCurdEditTableBlock.js.map +1 -0
- package/out/types/data/genBlock/genEditTableBlock.d.ts +234 -0
- package/out/types/data/genBlock/genEditTableBlock.js +419 -0
- package/out/types/data/genBlock/genEditTableBlock.js.map +1 -0
- 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/genQueryComponent.d.ts +20 -0
- package/out/types/data/genBlock/genQueryComponent.js +57 -1
- package/out/types/data/genBlock/genQueryComponent.js.map +1 -1
- package/out/types/data/genBlock/genSelectBlock.js +2 -2
- package/out/types/data/genBlock/genTableBlock.js +23 -8
- 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/genBlock/index.d.ts +2 -0
- package/out/types/data/genBlock/index.js +2 -0
- package/out/types/data/genBlock/index.js.map +1 -1
- package/out/types/data/genBlock/utils.d.ts +7 -0
- package/out/types/data/genBlock/utils.js +38 -1
- package/out/types/data/genBlock/utils.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/Logic.d.ts +32 -0
- package/out/types/logic/Logic.js +151 -41
- package/out/types/logic/Logic.js.map +1 -1
- package/out/types/logic/LogicItem.d.ts +1 -0
- package/out/types/logic/LogicItem.js +49 -32
- package/out/types/logic/LogicItem.js.map +1 -1
- package/out/types/logic/Param.d.ts +1 -0
- package/out/types/logic/Param.js +43 -33
- package/out/types/logic/Param.js.map +1 -1
- package/out/types/logic/Return.js +17 -30
- package/out/types/logic/Return.js.map +1 -1
- package/out/types/logic/Variable.js +17 -25
- package/out/types/logic/Variable.js.map +1 -1
- package/out/types/logic/translator.js +39 -10
- 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 +24 -0
- package/out/types/page/Element.js +198 -134
- 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 +5 -0
- package/out/types/page/Page.js +66 -27
- package/out/types/page/Page.js.map +1 -1
- package/out/types/page/View.d.ts +19 -1
- package/out/types/page/View.js +150 -40
- 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 -24
- 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/out/types/process/ProcessParam.js +3 -1
- package/out/types/process/ProcessParam.js.map +1 -1
- package/out/types/utils/index.d.ts +1 -0
- package/out/types/utils/index.js +16 -7
- package/out/types/utils/index.js.map +1 -1
- package/package.json +1 -2
- package/src/service/app/api.js +8 -17
- package/src/service/create/errHandles.js +18 -2
- package/src/service/create/index.js +6 -0
- package/src/service/developPermission/api.js +37 -0
- package/src/service/developPermission/index.js +13 -0
- package/src/service/logic/logic.js +26 -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 +58 -2
- package/src/types/app/History.ts +3 -2
- package/src/types/app/Service.ts +48 -10
- package/src/types/cache.ts +50 -0
- package/src/types/cacheData.ts +7 -7
- package/src/types/common/Vertex.ts +32 -1
- package/src/types/data/Entity.ts +8 -0
- package/src/types/data/EntityProperty.ts +12 -0
- package/src/types/data/Enum.ts +5 -0
- package/src/types/data/GlobalLogicNode.ts +8 -1
- package/src/types/data/Interface.ts +4 -3
- package/src/types/data/dataTypes.ts +1 -1
- package/src/types/data/genBlock/genCreateBlock.ts +5 -5
- package/src/types/data/genBlock/genCurdBlock.ts +3 -3
- package/src/types/data/genBlock/genCurdEditTableBlock.ts +581 -0
- package/src/types/data/genBlock/genEditTableBlock.ts +470 -0
- 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/genQueryComponent.ts +56 -0
- package/src/types/data/genBlock/genSelectBlock.ts +2 -2
- package/src/types/data/genBlock/genTableBlock.ts +28 -13
- package/src/types/data/genBlock/genUpdateBlock.ts +5 -5
- package/src/types/data/genBlock/index.ts +2 -0
- package/src/types/data/genBlock/utils.ts +38 -0
- 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 +148 -39
- package/src/types/logic/LogicItem.ts +55 -38
- package/src/types/logic/Param.ts +43 -35
- package/src/types/logic/Return.ts +21 -34
- package/src/types/logic/Variable.ts +21 -27
- package/src/types/logic/translator.js +41 -14
- package/src/types/logic/translator_backup.js +5 -16
- package/src/types/nuims/Nuims.ts +11 -5
- package/src/types/page/Element.ts +212 -138
- package/src/types/page/Event.ts +0 -3
- package/src/types/page/Page.ts +80 -40
- package/src/types/page/View.ts +154 -39
- package/src/types/page/ViewParam.ts +22 -3
- package/src/types/page/ViewVariable.ts +16 -26
- package/src/types/page/dist/View.js +727 -0
- package/src/types/permission/Permission.ts +112 -0
- package/src/types/process/ProcessParam.ts +4 -1
- package/src/types/utils/index.ts +16 -7
- package/out/test/units/config.spec.d.ts +0 -1
- package/out/test/units/config.spec.js +0 -12
- package/out/test/units/config.spec.js.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createService } from '../create';
|
|
2
|
+
import api from './api';
|
|
3
|
+
|
|
4
|
+
// 兼容 node 运行环境
|
|
5
|
+
const global = typeof window !== 'undefined' ? window : this;
|
|
6
|
+
const service = createService(api, {
|
|
7
|
+
headers: {
|
|
8
|
+
// 单环境配置下默认使用生产环境
|
|
9
|
+
Env: !(global && global.appInfo && global.appInfo.multiEnvEnable) ? 'online' : 'dev',
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default service;
|
|
@@ -12,6 +12,11 @@ service.saveFile = async function (options) {
|
|
|
12
12
|
},
|
|
13
13
|
});
|
|
14
14
|
if (!result) {
|
|
15
|
+
// 新应用可能会并发调用多次 saveFile, 导致创建多次
|
|
16
|
+
options = { ...options,
|
|
17
|
+
config: {
|
|
18
|
+
noErrorTip: true,
|
|
19
|
+
} };
|
|
15
20
|
return service.createFile(options);
|
|
16
21
|
} else {
|
|
17
22
|
return service.updateFile(options);
|
|
@@ -20,4 +25,4 @@ service.saveFile = async function (options) {
|
|
|
20
25
|
|
|
21
26
|
export default service;
|
|
22
27
|
|
|
23
|
-
export const loadCacheService = createService(loadCacheApi);
|
|
28
|
+
export const loadCacheService = createService(loadCacheApi);
|
package/src/types/app/App.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { excludedInJSON, immutable } from '../decorators';
|
|
2
|
-
import { LEVEL_ENUM, Vertex, Service, WebService, MicroService, SERVICE_TYPE, utils, History, updateGenericTypeList } from '..';
|
|
2
|
+
import { LEVEL_ENUM, Vertex, Service, WebService, MicroService, SERVICE_TYPE, utils, History, updateGenericTypeList, vertexsMap, Entity, Structure, Enum, dataTypesMap, BaseVariable, variablesMap, updateDataTypeList } from '..';
|
|
3
3
|
import appService from '../../service/app';
|
|
4
4
|
|
|
5
5
|
interface AppLoadAllOptions {
|
|
@@ -119,6 +119,13 @@ export class App extends Vertex {
|
|
|
119
119
|
@immutable()
|
|
120
120
|
@excludedInJSON()
|
|
121
121
|
public readonly history: History = undefined;
|
|
122
|
+
/**
|
|
123
|
+
* 历史记录
|
|
124
|
+
* 用于处理撤销重做
|
|
125
|
+
*/
|
|
126
|
+
@immutable()
|
|
127
|
+
@excludedInJSON()
|
|
128
|
+
public readonly webConfig?: string = undefined;
|
|
122
129
|
/**
|
|
123
130
|
* @param source 需要合并的部分参数
|
|
124
131
|
*/
|
|
@@ -128,6 +135,19 @@ export class App extends Vertex {
|
|
|
128
135
|
|
|
129
136
|
this.history = new History({ app: this });
|
|
130
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* 加载是否内置官方模板创建应用
|
|
140
|
+
*/
|
|
141
|
+
loadWebConfig(appDetail: any) {
|
|
142
|
+
const { pages } = appDetail.services
|
|
143
|
+
.find((service: any) => service.type === 'app') || {};
|
|
144
|
+
let webConfig;
|
|
145
|
+
try {
|
|
146
|
+
const pagesConfig = JSON.parse(pages);
|
|
147
|
+
webConfig = pagesConfig.config;
|
|
148
|
+
} catch (error) {}
|
|
149
|
+
this.assign({ webConfig });
|
|
150
|
+
}
|
|
131
151
|
/**
|
|
132
152
|
* 加载详情并同步 envList 信息
|
|
133
153
|
* @requires this.id
|
|
@@ -155,6 +175,7 @@ export class App extends Vertex {
|
|
|
155
175
|
},
|
|
156
176
|
});
|
|
157
177
|
await this.loadEnvList(result);
|
|
178
|
+
this.loadWebConfig(result);
|
|
158
179
|
delete result.services;
|
|
159
180
|
this.assign(result);
|
|
160
181
|
return this;
|
|
@@ -244,8 +265,8 @@ export class App extends Vertex {
|
|
|
244
265
|
asyncLoadServicesDetail: false,
|
|
245
266
|
asyncLoadViewsDetail: false,
|
|
246
267
|
}) {
|
|
268
|
+
await this.load(); // 请求其它接口前,需要先查询到 app 上的 baseVersion
|
|
247
269
|
await Promise.all([
|
|
248
|
-
this.load(),
|
|
249
270
|
this.loadServices(),
|
|
250
271
|
updateGenericTypeList(),
|
|
251
272
|
]);
|
|
@@ -262,6 +283,41 @@ export class App extends Vertex {
|
|
|
262
283
|
from(source: any) {
|
|
263
284
|
return new App(source);
|
|
264
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* 清理内存,避免内存泄漏
|
|
288
|
+
*/
|
|
289
|
+
clear() {
|
|
290
|
+
function traverse(obj: any, callback: (obj: any) => void, ws = new WeakSet()) {
|
|
291
|
+
if (typeof obj !== 'object' || obj === null)
|
|
292
|
+
return;
|
|
293
|
+
if (ws.has(obj))
|
|
294
|
+
return;
|
|
295
|
+
|
|
296
|
+
ws.add(obj);
|
|
297
|
+
|
|
298
|
+
if (Array.isArray(obj))
|
|
299
|
+
obj.forEach((item) => {
|
|
300
|
+
traverse(item, callback, ws);
|
|
301
|
+
});
|
|
302
|
+
else {
|
|
303
|
+
callback(obj);
|
|
304
|
+
Object.values(obj).forEach((item) => {
|
|
305
|
+
traverse(item, callback, ws);
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
traverse(this, (obj: any) => {
|
|
311
|
+
vertexsMap.delete(obj?.id);
|
|
312
|
+
|
|
313
|
+
if (obj instanceof Entity || obj instanceof Structure || obj instanceof Enum)
|
|
314
|
+
delete dataTypesMap[obj.schemaRef];
|
|
315
|
+
|
|
316
|
+
if (obj instanceof BaseVariable)
|
|
317
|
+
variablesMap.delete(obj.id);
|
|
318
|
+
});
|
|
319
|
+
updateDataTypeList();
|
|
320
|
+
}
|
|
265
321
|
}
|
|
266
322
|
|
|
267
323
|
export default App;
|
package/src/types/app/History.ts
CHANGED
|
@@ -294,8 +294,9 @@ export class History {
|
|
|
294
294
|
appId: this.app.id,
|
|
295
295
|
},
|
|
296
296
|
});
|
|
297
|
-
|
|
298
|
-
this.
|
|
297
|
+
const { undoNumber, redoNumber } = result || {};
|
|
298
|
+
this.undoCount = undoNumber;
|
|
299
|
+
this.redoCount = redoNumber;
|
|
299
300
|
} catch (e) { }
|
|
300
301
|
}
|
|
301
302
|
async undo() {
|
package/src/types/app/Service.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { immutable, circular, action, excludedInJSON } from '../decorators';
|
|
2
|
-
import { Logic, config, LEVEL_ENUM, Vertex, App, Page, DataNode, GlobalLogicNode, Schema, Entity, EntityProperty, Structure, Enum, EnumItem, Interface, dataTypesMap, generator, vertexsMap, Process, EntityIndex } from '..';
|
|
2
|
+
import { Logic, config, LEVEL_ENUM, Vertex, App, Page, DataNode, GlobalLogicNode, Schema, Entity, EntityProperty, Structure, Enum, EnumItem, Interface, dataTypesMap, generator, vertexsMap, Process, EntityIndex, utils } from '..';
|
|
3
3
|
import appService from '../../service/app';
|
|
4
4
|
import pageService from '../../service/page';
|
|
5
5
|
import webFileService from '../../service/webFile';
|
|
@@ -166,6 +166,11 @@ export class Service extends Vertex {
|
|
|
166
166
|
* 加载服务所有的接口列表
|
|
167
167
|
*/
|
|
168
168
|
async loadInterfaces() {
|
|
169
|
+
// 接口列表中的旧接口可能已经已经不存在,需要从 vetexsMap 中清理掉
|
|
170
|
+
this.interfaces.forEach((it) => {
|
|
171
|
+
it.destroy();
|
|
172
|
+
});
|
|
173
|
+
|
|
169
174
|
const RESOLVER_NAMES = ['getAll', 'get', 'create', 'update', 'delete', 'count', 'import', 'export', 'batchDelete', 'batchCreate', 'batchUpdate'];
|
|
170
175
|
|
|
171
176
|
let interfaces: Array<Interface> = await interfaceService.loadList({
|
|
@@ -226,6 +231,7 @@ export class WebService extends Service {
|
|
|
226
231
|
template: { name: string, version: string },
|
|
227
232
|
ui: { name: string, version: string },
|
|
228
233
|
componentDependencies: { [name: string]: string },
|
|
234
|
+
templateConfig: { builtInTemplate: boolean },
|
|
229
235
|
themeVariables: { [name: string]: string },
|
|
230
236
|
} = undefined;
|
|
231
237
|
/**
|
|
@@ -379,10 +385,19 @@ ${Object.keys(themeVariables).map((key) => ` ${key}: ${themeVariables[key]};`
|
|
|
379
385
|
`;
|
|
380
386
|
}
|
|
381
387
|
|
|
382
|
-
async loadPages() {
|
|
388
|
+
async loadPages(enableCache = true) {
|
|
389
|
+
const isGONGHANG = utils.getGlobalEnv() === 'gonghang';
|
|
390
|
+
if (isGONGHANG) {
|
|
391
|
+
enableCache = false;
|
|
392
|
+
}
|
|
393
|
+
this.pages.forEach((page) => {
|
|
394
|
+
page.destroy();
|
|
395
|
+
});
|
|
396
|
+
|
|
383
397
|
const result: Array<Page> = await pageService.loadPages({
|
|
384
398
|
query: {
|
|
385
399
|
serviceId: this.id,
|
|
400
|
+
enableCache,
|
|
386
401
|
},
|
|
387
402
|
config: {
|
|
388
403
|
mock: config.mock,
|
|
@@ -750,14 +765,14 @@ export class MicroService extends Service {
|
|
|
750
765
|
microServiceId: this.id,
|
|
751
766
|
},
|
|
752
767
|
});
|
|
753
|
-
entities.forEach((item
|
|
768
|
+
entities.forEach((item) => {
|
|
754
769
|
const tempEntity = <Entity>vertexsMap.get(item.id);
|
|
755
770
|
if (tempEntity) {
|
|
756
771
|
tempEntity.assign({ lastVersionDef: item.lastVersionDef });
|
|
757
772
|
}
|
|
758
773
|
const lastVersionRef = item.lastVersionDef && item.lastVersionDef.properties || {};
|
|
759
774
|
const propertyList = tempEntity.propertyList as Array<EntityProperty>;
|
|
760
|
-
propertyList.forEach((property
|
|
775
|
+
propertyList.forEach((property) => {
|
|
761
776
|
property = <EntityProperty>vertexsMap.get(property.id);
|
|
762
777
|
if (property && lastVersionRef[property.name]) {
|
|
763
778
|
property.assign({ lastVersion: convert2RefType(lastVersionRef[property.name]) });
|
|
@@ -768,17 +783,39 @@ export class MicroService extends Service {
|
|
|
768
783
|
/**
|
|
769
784
|
* 加载服务所有的接口列表
|
|
770
785
|
*/
|
|
771
|
-
async loadInterfaces() {
|
|
786
|
+
async loadInterfaces(enableCache = true) {
|
|
787
|
+
const isGONGHANG = utils.getGlobalEnv() === 'gonghang';
|
|
788
|
+
if (isGONGHANG) {
|
|
789
|
+
enableCache = false;
|
|
790
|
+
}
|
|
791
|
+
const logicMap = new Map();
|
|
792
|
+
// 旧接口列表中,可能存在已经被删掉的接口,需要从 vertexsMap 中删除
|
|
793
|
+
this.interfaces.forEach((it) => {
|
|
794
|
+
logicMap.set(it.id, it.logic);
|
|
795
|
+
it.destroy();
|
|
796
|
+
});
|
|
797
|
+
|
|
772
798
|
let interfaces: Array<Interface> = await interfaceService.loadList({
|
|
773
799
|
query: {
|
|
774
800
|
serviceId: this.id,
|
|
801
|
+
enableCache,
|
|
775
802
|
},
|
|
776
803
|
headers: {
|
|
777
804
|
IdeVersion: 2.3,
|
|
778
805
|
},
|
|
779
806
|
});
|
|
780
807
|
|
|
781
|
-
interfaces = interfaces.map((item) =>
|
|
808
|
+
interfaces = interfaces.map((item) => {
|
|
809
|
+
if (logicMap.has(item.id)) {
|
|
810
|
+
item.logic = logicMap.get(item.id);
|
|
811
|
+
logicMap.delete(item.id);
|
|
812
|
+
}
|
|
813
|
+
return Interface.from(item, this);
|
|
814
|
+
});
|
|
815
|
+
// 清理掉已不存在的逻辑
|
|
816
|
+
for (const logic of logicMap.values()) {
|
|
817
|
+
logic.destroy();
|
|
818
|
+
}
|
|
782
819
|
|
|
783
820
|
interfaces.forEach((i) => {
|
|
784
821
|
if (i.serviceType === 'export') {
|
|
@@ -786,6 +823,7 @@ export class MicroService extends Service {
|
|
|
786
823
|
i.logic = logic;
|
|
787
824
|
}
|
|
788
825
|
});
|
|
826
|
+
|
|
789
827
|
this.assign({ interfaces });
|
|
790
828
|
this.mountResolverOnEntity();
|
|
791
829
|
this.mountResolverOnInterface();
|
|
@@ -890,16 +928,16 @@ export class MicroService extends Service {
|
|
|
890
928
|
}
|
|
891
929
|
|
|
892
930
|
private async _onVertexIdToNameChange(id: string, name: string) {
|
|
893
|
-
if (!config.webFileCache)
|
|
894
|
-
|
|
931
|
+
// if (!config.webFileCache)
|
|
932
|
+
// return;
|
|
895
933
|
|
|
896
934
|
if (id && name) {
|
|
897
935
|
if (!vertexIdToName) {
|
|
898
936
|
vertexIdToName = await generator.loadVertexIdToName(this.app);
|
|
899
937
|
vertexIdToName = vertexIdToName || {};
|
|
900
938
|
}
|
|
901
|
-
if (vertexIdToName[id] === name)
|
|
902
|
-
|
|
939
|
+
// if (vertexIdToName[id] === name)
|
|
940
|
+
// return;
|
|
903
941
|
}
|
|
904
942
|
// id 和 name 都没传时,跳过上一步的判断逻辑,直接更新
|
|
905
943
|
if ((id && name) || (!id && !name)) {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { config, View, Logic } from '.';
|
|
2
|
+
import { BusinessCode } from './enum';
|
|
3
|
+
|
|
4
|
+
export async function refreshInterfaces() {
|
|
5
|
+
await config.defaultApp?.firstMicroService?.loadInterfaces(false);
|
|
6
|
+
config.defaultApp?.firstMicroService?.emit('interfacesChange');
|
|
7
|
+
config.defaultApp?.emit('cache.refreshed');
|
|
8
|
+
config.defaultApp?.emit('cleanDesigners');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function refreshPages() {
|
|
12
|
+
await config.defaultApp?.firstWebService.loadPages(false);
|
|
13
|
+
await config.defaultApp?._loadViewsDetail();
|
|
14
|
+
config.defaultApp?.firstWebService.emit('pageTreeChange');
|
|
15
|
+
config.defaultApp?.emit('cache.refreshed');
|
|
16
|
+
config.defaultApp?.emit('cleanDesigners');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function refreshView(view: View) {
|
|
20
|
+
try {
|
|
21
|
+
await view.loadAll(false);
|
|
22
|
+
view.emit('change');
|
|
23
|
+
config.defaultApp?.emit('cache.refreshed');
|
|
24
|
+
config.defaultApp?.emit('cleanDesigners');
|
|
25
|
+
} catch(err: any) {
|
|
26
|
+
const code = err?.code;
|
|
27
|
+
if(code === BusinessCode.ElementNotExist) // 节点不存在
|
|
28
|
+
await refreshPages();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function refreshHtml(view: View) {
|
|
34
|
+
try {
|
|
35
|
+
await view.$html?.load();
|
|
36
|
+
view.emit('change');
|
|
37
|
+
config.defaultApp?.emit('cache.refreshed');
|
|
38
|
+
} catch(err: any) {
|
|
39
|
+
const code = err?.code;
|
|
40
|
+
if(code === BusinessCode.ElementNotExist) // 节点不存在
|
|
41
|
+
await refreshView(view);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function refreshLogic(logic: Logic) {
|
|
47
|
+
await logic.load(); // logic.load() 会根据后端返回的code, 调用 refreshView, refreshPages 或 refreshInterfaces
|
|
48
|
+
logic.emit('change');
|
|
49
|
+
config.defaultApp?.emit('cache.refreshed');
|
|
50
|
+
}
|
package/src/types/cacheData.ts
CHANGED
|
@@ -4,20 +4,20 @@ export const vertexsMap: Map<string, Vertex> = new Map();
|
|
|
4
4
|
export const entitiesMap: Map<string, Entity> = new Map();
|
|
5
5
|
|
|
6
6
|
export function genFinalCode(code: string, finalCode = true) {
|
|
7
|
-
if(!finalCode)
|
|
7
|
+
if (!finalCode)
|
|
8
8
|
return code;
|
|
9
9
|
|
|
10
|
-
if(typeof code !== 'string')
|
|
10
|
+
if (typeof code !== 'string')
|
|
11
11
|
return code;
|
|
12
12
|
// ID_ENUMVALUE_只需要返回ENUM的item的value值
|
|
13
|
-
if(code.includes('ID_ENUMVALUE_')){
|
|
13
|
+
if (code.includes('ID_ENUMVALUE_')) {
|
|
14
14
|
code = code.replace(/ID_([\w-]+).ID_ENUMVALUE_([\w-]+)/g, (m) => {
|
|
15
15
|
const id = m.split('.').pop().replace('ID_ENUMVALUE_', '');
|
|
16
16
|
const param = vertexsMap.get(id);
|
|
17
|
-
return
|
|
17
|
+
return param && `'${(param as any).value}'` || `'${id}'`;
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
if(code.includes('ID_ENUM_LIST_')){
|
|
20
|
+
if (code.includes('ID_ENUM_LIST_')) {
|
|
21
21
|
code = code.replace(/ID_ENUM_LIST_([\w-]+)/g, (m, id) => {
|
|
22
22
|
const param = vertexsMap.get(id);
|
|
23
23
|
return `$utils.EnumList('${param && param.name}')`;
|
|
@@ -27,7 +27,7 @@ export function genFinalCode(code: string, finalCode = true) {
|
|
|
27
27
|
return code.replace(/ID_([\w-]+)/g, (m, id) => {
|
|
28
28
|
const param = vertexsMap.get(id);
|
|
29
29
|
return (param as any)?.name
|
|
30
|
-
|| (param as any)?.asName
|
|
30
|
+
|| (param as any)?.asName
|
|
31
31
|
|| id;
|
|
32
32
|
});
|
|
33
|
-
}
|
|
33
|
+
}
|
|
@@ -93,6 +93,36 @@ export class Vertex extends EventEmitter {
|
|
|
93
93
|
*/
|
|
94
94
|
@excludedInJSON()
|
|
95
95
|
public expanded: boolean = false;
|
|
96
|
+
/**
|
|
97
|
+
* 节点是否显示
|
|
98
|
+
* 前端 UI 状态
|
|
99
|
+
*/
|
|
100
|
+
@excludedInJSON()
|
|
101
|
+
public hidden: boolean = false;
|
|
102
|
+
/**
|
|
103
|
+
* 页面树节点是否显示
|
|
104
|
+
* 前端 UI 状态
|
|
105
|
+
*/
|
|
106
|
+
@excludedInJSON()
|
|
107
|
+
public pageTreeNodeHidden: boolean = false;
|
|
108
|
+
/**
|
|
109
|
+
* 逻辑树节点是否显示
|
|
110
|
+
* 前端 UI 状态
|
|
111
|
+
*/
|
|
112
|
+
@excludedInJSON()
|
|
113
|
+
public logicTreeNodeHidden: boolean = false;
|
|
114
|
+
/**
|
|
115
|
+
* 数据树节点是否显示
|
|
116
|
+
* 前端 UI 状态
|
|
117
|
+
*/
|
|
118
|
+
@excludedInJSON()
|
|
119
|
+
public dataTreeNodeHidden: boolean = false;
|
|
120
|
+
/**
|
|
121
|
+
* 数据树节点是否展开
|
|
122
|
+
* 前端 UI 状态
|
|
123
|
+
*/
|
|
124
|
+
@excludedInJSON()
|
|
125
|
+
public logicTreeNodeExpanded: boolean = false;
|
|
96
126
|
/**
|
|
97
127
|
* 是否为叶子节点
|
|
98
128
|
* 前端 UI 状态
|
|
@@ -125,7 +155,8 @@ export class Vertex extends EventEmitter {
|
|
|
125
155
|
oldId && vertexsMap.delete(oldId);
|
|
126
156
|
this.id && vertexsMap.set(this.id, this);
|
|
127
157
|
|
|
128
|
-
this.
|
|
158
|
+
if(oldId || this.id)
|
|
159
|
+
this.emitVertexIdToNameChange();
|
|
129
160
|
|
|
130
161
|
this._mutable = false;
|
|
131
162
|
}
|
package/src/types/data/Entity.ts
CHANGED
|
@@ -27,6 +27,8 @@ export const systemProperty: { [name: string]: any, } = {
|
|
|
27
27
|
type: 'integer',
|
|
28
28
|
format: 'long',
|
|
29
29
|
editable: false,
|
|
30
|
+
required: true,
|
|
31
|
+
propertyGenRule: 'platform',
|
|
30
32
|
display: {
|
|
31
33
|
inTable: false,
|
|
32
34
|
inFilter: false,
|
|
@@ -171,6 +173,12 @@ export class Entity extends Vertex implements ObjectSchema {
|
|
|
171
173
|
@circular()
|
|
172
174
|
@immutable()
|
|
173
175
|
public readonly dataNode: DataNode = undefined;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 数据来源名称,平台生成 默认ide
|
|
179
|
+
*/
|
|
180
|
+
@immutable()
|
|
181
|
+
public readonly entityGenSource: string = undefined;
|
|
174
182
|
/**
|
|
175
183
|
* 周边存在的名称
|
|
176
184
|
*/
|
|
@@ -44,6 +44,11 @@ export class EntityProperty extends Vertex implements Schema {
|
|
|
44
44
|
*/
|
|
45
45
|
@immutable()
|
|
46
46
|
public readonly description: string = undefined;
|
|
47
|
+
/**
|
|
48
|
+
* 字段生成规则
|
|
49
|
+
*/
|
|
50
|
+
@immutable()
|
|
51
|
+
public readonly propertyGenRule: string = undefined;
|
|
47
52
|
/**
|
|
48
53
|
* type
|
|
49
54
|
*/
|
|
@@ -401,6 +406,13 @@ export class EntityProperty extends Vertex implements Schema {
|
|
|
401
406
|
actionDesc: `设置实体属性规则`,
|
|
402
407
|
});
|
|
403
408
|
}
|
|
409
|
+
@action('设置实体生成规则')
|
|
410
|
+
async setPropertyGenRule(propertyGenRule: string) {
|
|
411
|
+
this.assign({ propertyGenRule });
|
|
412
|
+
await this.update(undefined, {
|
|
413
|
+
actionDesc: `设置实体生成规则`,
|
|
414
|
+
});
|
|
415
|
+
}
|
|
404
416
|
/**
|
|
405
417
|
* 设置实体属性的默认值
|
|
406
418
|
*/
|
package/src/types/data/Enum.ts
CHANGED
|
@@ -66,7 +66,14 @@ export class GlobalLogicNode extends Vertex {
|
|
|
66
66
|
addCategoryInterface(iface: Interface) {
|
|
67
67
|
const category = iface.category;
|
|
68
68
|
const ciInstance = this.createOrGetCatogory(category);
|
|
69
|
-
ciInstance.categoryInterfaces.
|
|
69
|
+
const index = ciInstance.categoryInterfaces.findIndex((s) => s.name === iface.name);
|
|
70
|
+
if (index >= 0) {
|
|
71
|
+
const [oldiface] = ciInstance.categoryInterfaces.splice(index, 1, iface);
|
|
72
|
+
oldiface.destroy();
|
|
73
|
+
} else {
|
|
74
|
+
ciInstance.categoryInterfaces.unshift(iface);
|
|
75
|
+
}
|
|
76
|
+
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
addCategoryStructure(sturct: Structure) {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from '..';
|
|
6
6
|
import { interfaceService } from '../../service/data';
|
|
7
7
|
import { findUsageService } from '../../service/common';
|
|
8
|
+
import { catchFn } from '../logic/Logic';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* 接口类
|
|
@@ -199,9 +200,9 @@ export class Interface extends Vertex {
|
|
|
199
200
|
*/
|
|
200
201
|
@action('删除接口')
|
|
201
202
|
async delete(none?: void, actionOptions?: ActionOptions) {
|
|
202
|
-
config.defaultApp?.emit('saving');
|
|
203
|
+
if(this.id) config.defaultApp?.emit('saving');
|
|
203
204
|
|
|
204
|
-
if (this.logic)
|
|
205
|
+
if (this.logic && this.serviceType?.toLowerCase() !== 'export')
|
|
205
206
|
await this.logic.delete();
|
|
206
207
|
|
|
207
208
|
if (this.id) {
|
|
@@ -245,7 +246,7 @@ export class Interface extends Vertex {
|
|
|
245
246
|
operationDesc: actionOptions?.actionDesc || `修改接口"${this.name}"`,
|
|
246
247
|
},
|
|
247
248
|
body,
|
|
248
|
-
});
|
|
249
|
+
}).catch(catchFn(this.logic));
|
|
249
250
|
await then?.();
|
|
250
251
|
await config.defaultApp?.history.load();
|
|
251
252
|
config.defaultApp?.emit('saved');
|
|
@@ -47,7 +47,7 @@ export function properties2PropertyList(definition: any) {
|
|
|
47
47
|
|
|
48
48
|
export async function updateGenericTypeList() {
|
|
49
49
|
const datatypes = await getGenericList();
|
|
50
|
-
dataTypeList[2].children = datatypes.genericTypeList.concat(
|
|
50
|
+
dataTypeList[2].children = datatypes.genericTypeList.concat(systemTypeList);
|
|
51
51
|
Object.assign(dataTypesMap, datatypes.genericTypemap);
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -29,7 +29,7 @@ export function genCreateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
|
|
|
29
29
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
30
30
|
formItem += `
|
|
31
31
|
<u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroupMap.get(relationEntity.id).load}"
|
|
32
|
-
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" pageable remote-paging v-model="${nameGroup.model}.${property.name}">
|
|
32
|
+
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="${nameGroup.model}.${property.name}">
|
|
33
33
|
</u-select>
|
|
34
34
|
`;
|
|
35
35
|
} else
|
|
@@ -51,7 +51,7 @@ export function genCreateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
|
|
|
51
51
|
} else if (property.typeKey === '#/basicTypes/DateTime') {
|
|
52
52
|
formItem += `<u-date-time-picker clearable :date.sync="${nameGroup.model}.${property.name}" placeholder="请输入${label}"></u-date-time-picker>`;
|
|
53
53
|
} else if (dataTypesMap[property.typeKey].type === 'enum') {
|
|
54
|
-
formItem += genEnumSelectBlock(dataTypesMap[property.typeKey] as Enum, `${nameGroup.model}.${property.name}`, '', `请选择${label}
|
|
54
|
+
formItem += genEnumSelectBlock(dataTypesMap[property.typeKey] as Enum, `${nameGroup.model}.${property.name}`, '', `请选择${label}`, true);
|
|
55
55
|
} else {
|
|
56
56
|
formItem += `<u-input v-model="${nameGroup.model}.${property.name}" placeholder="请输入${label}"></u-input>`;
|
|
57
57
|
}
|
|
@@ -94,7 +94,7 @@ export function genH5CreateFormTemplate(entity: Entity, nameGroup: NameGroup, se
|
|
|
94
94
|
<template #input><van-cascader title="请选择${label}" placeholder="请选择${label}"
|
|
95
95
|
v-model="${nameGroup.model}.${property.name}" :data-source="${selectNameGroupMap.get(relationEntity.id).load}"
|
|
96
96
|
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}"
|
|
97
|
-
pageable remote-paging></van-cascader></template>
|
|
97
|
+
:pageable="true" :remote-paging="true"></van-cascader></template>
|
|
98
98
|
`;
|
|
99
99
|
} else
|
|
100
100
|
return '';
|
|
@@ -112,9 +112,9 @@ export function genH5CreateFormTemplate(entity: Entity, nameGroup: NameGroup, se
|
|
|
112
112
|
} else if (property.typeKey === '#/basicTypes/Date') {
|
|
113
113
|
formItem += `<template #input><van-calendar v-model="${nameGroup.model}.${property.name}" title="请输入${property.label || property.name}"></van-calendar></template>`;
|
|
114
114
|
} else if (property.typeKey === '#/basicTypes/Time') {
|
|
115
|
-
formItem += `<template #input><van-datetime-picker type="time" v-model="${nameGroup.model}.${property.name}" title="
|
|
115
|
+
formItem += `<template #input><van-datetime-picker type="time" v-model="${nameGroup.model}.${property.name}" title="请选择${property.label || property.name}" label-field=""></van-datetime-picker></template>`;
|
|
116
116
|
} else if (property.typeKey === '#/basicTypes/DateTime') {
|
|
117
|
-
formItem += `<template #input><van-datetime-picker type="datetime" v-model="${nameGroup.model}.${property.name}" title="
|
|
117
|
+
formItem += `<template #input><van-datetime-picker type="datetime" v-model="${nameGroup.model}.${property.name}" title="请选择${property.label || property.name}" label-field=""></van-datetime-picker></template>`;
|
|
118
118
|
} else if (dataTypesMap[property.typeKey].type === 'enum') {
|
|
119
119
|
formItem += '<template #input>' + genEnumSelectBlock(dataTypesMap[property.typeKey] as Enum, `${nameGroup.model}.${property.name}`, '', `请选择${property.label || property.name}`) + '</template>';
|
|
120
120
|
} else {
|
|
@@ -25,7 +25,7 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
25
25
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
26
26
|
formItem += `
|
|
27
27
|
<u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroupMap.get(relationEntity.id).load}"
|
|
28
|
-
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" pageable remote-paging v-model="filter.${property.name}">
|
|
28
|
+
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="filter.${property.name}">
|
|
29
29
|
</u-select>
|
|
30
30
|
`;
|
|
31
31
|
} else
|
|
@@ -111,7 +111,7 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
111
111
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
112
112
|
formItem += `
|
|
113
113
|
<u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroupMap.get(relationEntity.id).load}"
|
|
114
|
-
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" pageable remote-paging v-model="input.${property.name}">
|
|
114
|
+
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="input.${property.name}">
|
|
115
115
|
</u-select>
|
|
116
116
|
`;
|
|
117
117
|
} else
|
|
@@ -137,7 +137,7 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
137
137
|
} else if (property.typeKey === '#/basicTypes/DateTime') {
|
|
138
138
|
formItem += `<u-date-time-picker clearable :date.sync="input.${property.name}" placeholder="请输入${label}"></u-date-time-picker>`;
|
|
139
139
|
} else if (dataTypesMap[property.typeKey].type === 'enum') {
|
|
140
|
-
formItem += genEnumSelectBlock(dataTypesMap[property.typeKey] as Enum, `input.${property.name}`, '', `请选择${label}
|
|
140
|
+
formItem += genEnumSelectBlock(dataTypesMap[property.typeKey] as Enum, `input.${property.name}`, '', `请选择${label}`, true);
|
|
141
141
|
} else {
|
|
142
142
|
formItem += `<u-input v-model="input.${property.name}" placeholder="请输入${label}"></u-input>`;
|
|
143
143
|
}
|