@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.
Files changed (194) hide show
  1. package/out/service/app/api.d.ts +1 -15
  2. package/out/service/app/api.js +7 -17
  3. package/out/service/app/api.js.map +1 -1
  4. package/out/service/create/errHandles.js +19 -2
  5. package/out/service/create/errHandles.js.map +1 -1
  6. package/out/service/create/index.js +5 -0
  7. package/out/service/create/index.js.map +1 -1
  8. package/out/service/logic/logic.d.ts +50 -14
  9. package/out/service/logic/logic.js +26 -0
  10. package/out/service/logic/logic.js.map +1 -1
  11. package/out/service/page/element.d.ts +9 -0
  12. package/out/service/page/element.js +6 -0
  13. package/out/service/page/element.js.map +1 -1
  14. package/out/service/permission/api.d.ts +57 -0
  15. package/out/service/permission/api.js +41 -0
  16. package/out/service/permission/api.js.map +1 -0
  17. package/out/service/permission/index.d.ts +2 -0
  18. package/out/service/permission/index.js +17 -0
  19. package/out/service/permission/index.js.map +1 -0
  20. package/out/service/webFile/index.js +5 -0
  21. package/out/service/webFile/index.js.map +1 -1
  22. package/out/types/app/App.d.ts +13 -0
  23. package/out/types/app/App.js +55 -1
  24. package/out/types/app/App.js.map +1 -1
  25. package/out/types/app/History.js +3 -2
  26. package/out/types/app/History.js.map +1 -1
  27. package/out/types/app/Service.d.ts +5 -2
  28. package/out/types/app/Service.js +42 -9
  29. package/out/types/app/Service.js.map +1 -1
  30. package/out/types/cache.d.ts +6 -0
  31. package/out/types/cache.js +54 -0
  32. package/out/types/cache.js.map +1 -0
  33. package/out/types/cacheData.js.map +1 -1
  34. package/out/types/common/Vertex.d.ts +25 -0
  35. package/out/types/common/Vertex.js +42 -1
  36. package/out/types/common/Vertex.js.map +1 -1
  37. package/out/types/data/Entity.d.ts +4 -0
  38. package/out/types/data/Entity.js +9 -0
  39. package/out/types/data/Entity.js.map +1 -1
  40. package/out/types/data/EntityProperty.d.ts +5 -0
  41. package/out/types/data/EntityProperty.js +16 -0
  42. package/out/types/data/EntityProperty.js.map +1 -1
  43. package/out/types/data/Enum.d.ts +5 -0
  44. package/out/types/data/Enum.js +5 -0
  45. package/out/types/data/Enum.js.map +1 -1
  46. package/out/types/data/GlobalLogicNode.js +8 -1
  47. package/out/types/data/GlobalLogicNode.js.map +1 -1
  48. package/out/types/data/Interface.js +5 -3
  49. package/out/types/data/Interface.js.map +1 -1
  50. package/out/types/data/dataTypes.js +1 -1
  51. package/out/types/data/dataTypes.js.map +1 -1
  52. package/out/types/data/genBlock/genCreateBlock.js +5 -5
  53. package/out/types/data/genBlock/genCreateBlock.js.map +1 -1
  54. package/out/types/data/genBlock/genCurdBlock.js +3 -3
  55. package/out/types/data/genBlock/genCurdBlock.js.map +1 -1
  56. package/out/types/data/genBlock/genCurdEditTableBlock.d.ts +3 -0
  57. package/out/types/data/genBlock/genCurdEditTableBlock.js +578 -0
  58. package/out/types/data/genBlock/genCurdEditTableBlock.js.map +1 -0
  59. package/out/types/data/genBlock/genEditTableBlock.d.ts +234 -0
  60. package/out/types/data/genBlock/genEditTableBlock.js +419 -0
  61. package/out/types/data/genBlock/genEditTableBlock.js.map +1 -0
  62. package/out/types/data/genBlock/genEnumSelectBlock.d.ts +1 -1
  63. package/out/types/data/genBlock/genEnumSelectBlock.js +2 -2
  64. package/out/types/data/genBlock/genEnumSelectBlock.js.map +1 -1
  65. package/out/types/data/genBlock/genGridViewBlock.js +12 -1
  66. package/out/types/data/genBlock/genGridViewBlock.js.map +1 -1
  67. package/out/types/data/genBlock/genListViewBlock.js +2 -2
  68. package/out/types/data/genBlock/genQueryComponent.d.ts +20 -0
  69. package/out/types/data/genBlock/genQueryComponent.js +57 -1
  70. package/out/types/data/genBlock/genQueryComponent.js.map +1 -1
  71. package/out/types/data/genBlock/genSelectBlock.js +2 -2
  72. package/out/types/data/genBlock/genTableBlock.js +23 -8
  73. package/out/types/data/genBlock/genTableBlock.js.map +1 -1
  74. package/out/types/data/genBlock/genUpdateBlock.js +5 -5
  75. package/out/types/data/genBlock/genUpdateBlock.js.map +1 -1
  76. package/out/types/data/genBlock/index.d.ts +2 -0
  77. package/out/types/data/genBlock/index.js +2 -0
  78. package/out/types/data/genBlock/index.js.map +1 -1
  79. package/out/types/data/genBlock/utils.d.ts +7 -0
  80. package/out/types/data/genBlock/utils.js +38 -1
  81. package/out/types/data/genBlock/utils.js.map +1 -1
  82. package/out/types/data/systemTypes.js +47 -0
  83. package/out/types/data/systemTypes.js.map +1 -1
  84. package/out/types/enum.d.ts +6 -0
  85. package/out/types/enum.js +11 -0
  86. package/out/types/enum.js.map +1 -0
  87. package/out/types/generator/hotReload.d.ts +2 -0
  88. package/out/types/generator/hotReload.js +12 -1
  89. package/out/types/generator/hotReload.js.map +1 -1
  90. package/out/types/index.d.ts +5 -1
  91. package/out/types/index.js +8 -2
  92. package/out/types/index.js.map +1 -1
  93. package/out/types/logic/Logic.d.ts +32 -0
  94. package/out/types/logic/Logic.js +151 -41
  95. package/out/types/logic/Logic.js.map +1 -1
  96. package/out/types/logic/LogicItem.d.ts +1 -0
  97. package/out/types/logic/LogicItem.js +49 -32
  98. package/out/types/logic/LogicItem.js.map +1 -1
  99. package/out/types/logic/Param.d.ts +1 -0
  100. package/out/types/logic/Param.js +43 -33
  101. package/out/types/logic/Param.js.map +1 -1
  102. package/out/types/logic/Return.js +17 -30
  103. package/out/types/logic/Return.js.map +1 -1
  104. package/out/types/logic/Variable.js +17 -25
  105. package/out/types/logic/Variable.js.map +1 -1
  106. package/out/types/logic/translator.js +39 -10
  107. package/out/types/logic/translator.js.map +1 -1
  108. package/out/types/nuims/Nuims.d.ts +1 -1
  109. package/out/types/nuims/Nuims.js +11 -4
  110. package/out/types/nuims/Nuims.js.map +1 -1
  111. package/out/types/page/Element.d.ts +24 -0
  112. package/out/types/page/Element.js +198 -134
  113. package/out/types/page/Element.js.map +1 -1
  114. package/out/types/page/Event.js.map +1 -1
  115. package/out/types/page/Page.d.ts +5 -0
  116. package/out/types/page/Page.js +66 -27
  117. package/out/types/page/Page.js.map +1 -1
  118. package/out/types/page/View.d.ts +19 -1
  119. package/out/types/page/View.js +150 -40
  120. package/out/types/page/View.js.map +1 -1
  121. package/out/types/page/ViewParam.d.ts +1 -0
  122. package/out/types/page/ViewParam.js +23 -4
  123. package/out/types/page/ViewParam.js.map +1 -1
  124. package/out/types/page/ViewVariable.js +13 -24
  125. package/out/types/page/ViewVariable.js.map +1 -1
  126. package/out/types/permission/Permission.d.ts +41 -0
  127. package/out/types/permission/Permission.js +122 -0
  128. package/out/types/permission/Permission.js.map +1 -0
  129. package/out/types/process/ProcessParam.js +3 -1
  130. package/out/types/process/ProcessParam.js.map +1 -1
  131. package/out/types/utils/index.d.ts +1 -0
  132. package/out/types/utils/index.js +16 -7
  133. package/out/types/utils/index.js.map +1 -1
  134. package/package.json +1 -2
  135. package/src/service/app/api.js +8 -17
  136. package/src/service/create/errHandles.js +18 -2
  137. package/src/service/create/index.js +6 -0
  138. package/src/service/developPermission/api.js +37 -0
  139. package/src/service/developPermission/index.js +13 -0
  140. package/src/service/logic/logic.js +26 -0
  141. package/src/service/page/element.js +6 -0
  142. package/src/service/permission/api.js +38 -0
  143. package/src/service/permission/index.js +13 -0
  144. package/src/service/webFile/index.js +6 -1
  145. package/src/types/app/App.ts +58 -2
  146. package/src/types/app/History.ts +3 -2
  147. package/src/types/app/Service.ts +48 -10
  148. package/src/types/cache.ts +50 -0
  149. package/src/types/cacheData.ts +7 -7
  150. package/src/types/common/Vertex.ts +32 -1
  151. package/src/types/data/Entity.ts +8 -0
  152. package/src/types/data/EntityProperty.ts +12 -0
  153. package/src/types/data/Enum.ts +5 -0
  154. package/src/types/data/GlobalLogicNode.ts +8 -1
  155. package/src/types/data/Interface.ts +4 -3
  156. package/src/types/data/dataTypes.ts +1 -1
  157. package/src/types/data/genBlock/genCreateBlock.ts +5 -5
  158. package/src/types/data/genBlock/genCurdBlock.ts +3 -3
  159. package/src/types/data/genBlock/genCurdEditTableBlock.ts +581 -0
  160. package/src/types/data/genBlock/genEditTableBlock.ts +470 -0
  161. package/src/types/data/genBlock/genEnumSelectBlock.ts +2 -2
  162. package/src/types/data/genBlock/genGridViewBlock.ts +12 -1
  163. package/src/types/data/genBlock/genListViewBlock.ts +2 -2
  164. package/src/types/data/genBlock/genQueryComponent.ts +56 -0
  165. package/src/types/data/genBlock/genSelectBlock.ts +2 -2
  166. package/src/types/data/genBlock/genTableBlock.ts +28 -13
  167. package/src/types/data/genBlock/genUpdateBlock.ts +5 -5
  168. package/src/types/data/genBlock/index.ts +2 -0
  169. package/src/types/data/genBlock/utils.ts +38 -0
  170. package/src/types/data/systemTypes.ts +47 -0
  171. package/src/types/enum.ts +6 -0
  172. package/src/types/generator/hotReload.ts +10 -0
  173. package/src/types/index.ts +5 -1
  174. package/src/types/logic/Logic.ts +148 -39
  175. package/src/types/logic/LogicItem.ts +55 -38
  176. package/src/types/logic/Param.ts +43 -35
  177. package/src/types/logic/Return.ts +21 -34
  178. package/src/types/logic/Variable.ts +21 -27
  179. package/src/types/logic/translator.js +41 -14
  180. package/src/types/logic/translator_backup.js +5 -16
  181. package/src/types/nuims/Nuims.ts +11 -5
  182. package/src/types/page/Element.ts +212 -138
  183. package/src/types/page/Event.ts +0 -3
  184. package/src/types/page/Page.ts +80 -40
  185. package/src/types/page/View.ts +154 -39
  186. package/src/types/page/ViewParam.ts +22 -3
  187. package/src/types/page/ViewVariable.ts +16 -26
  188. package/src/types/page/dist/View.js +727 -0
  189. package/src/types/permission/Permission.ts +112 -0
  190. package/src/types/process/ProcessParam.ts +4 -1
  191. package/src/types/utils/index.ts +16 -7
  192. package/out/test/units/config.spec.d.ts +0 -1
  193. package/out/test/units/config.spec.js +0 -12
  194. 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);
@@ -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;
@@ -294,8 +294,9 @@ export class History {
294
294
  appId: this.app.id,
295
295
  },
296
296
  });
297
- this.undoCount = result.undoNumber;
298
- this.redoCount = result.redoNumber;
297
+ const { undoNumber, redoNumber } = result || {};
298
+ this.undoCount = undoNumber;
299
+ this.redoCount = redoNumber;
299
300
  } catch (e) { }
300
301
  }
301
302
  async undo() {
@@ -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, index) => {
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, index) => {
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) => Interface.from(item, this));
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
- return;
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
- return;
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
+ }
@@ -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 param && `'${(param as any).value}'` || `'${id}'`;
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.emitVertexIdToNameChange();
158
+ if(oldId || this.id)
159
+ this.emitVertexIdToNameChange();
129
160
 
130
161
  this._mutable = false;
131
162
  }
@@ -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
  */
@@ -66,6 +66,11 @@ export class Enum extends Vertex {
66
66
  */
67
67
  @immutable()
68
68
  public readonly service: Service = undefined;
69
+ /**
70
+ * 节点是否为叶子节点
71
+ * 前端 UI 状态
72
+ */
73
+ public isLeaf = true;
69
74
  /**
70
75
  * 父节点
71
76
  */
@@ -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.unshift(iface);
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(dataTypeList[2].children);
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="请输入${property.label || property.name}"></van-datetime-picker></template>`;
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="请输入${property.label || property.name}"></van-datetime-picker></template>`;
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
  }