@lcap/nasl 0.3.10-beta → 0.3.10-beta.10

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 (126) 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 +12 -0
  5. package/out/service/create/errHandles.js.map +1 -1
  6. package/out/service/create/index.js +3 -0
  7. package/out/service/create/index.js.map +1 -1
  8. package/out/service/logic/logic.d.ts +26 -17
  9. package/out/service/logic/logic.js +6 -0
  10. package/out/service/logic/logic.js.map +1 -1
  11. package/out/types/app/App.d.ts +5 -4
  12. package/out/types/app/App.js +31 -25
  13. package/out/types/app/App.js.map +1 -1
  14. package/out/types/app/History.js +3 -2
  15. package/out/types/app/History.js.map +1 -1
  16. package/out/types/app/Service.d.ts +3 -0
  17. package/out/types/app/Service.js +10 -2
  18. package/out/types/app/Service.js.map +1 -1
  19. package/out/types/cacheData.js.map +1 -1
  20. package/out/types/data/Entity.d.ts +4 -0
  21. package/out/types/data/Entity.js +8 -0
  22. package/out/types/data/Entity.js.map +1 -1
  23. package/out/types/data/EntityProperty.d.ts +5 -0
  24. package/out/types/data/EntityProperty.js +16 -0
  25. package/out/types/data/EntityProperty.js.map +1 -1
  26. package/out/types/data/dataTypes.js +1 -1
  27. package/out/types/data/dataTypes.js.map +1 -1
  28. package/out/types/data/genBlock/genCurdEditTableBlock.d.ts +3 -0
  29. package/out/types/data/genBlock/genCurdEditTableBlock.js +578 -0
  30. package/out/types/data/genBlock/genCurdEditTableBlock.js.map +1 -0
  31. package/out/types/data/genBlock/genEditTableBlock.d.ts +234 -0
  32. package/out/types/data/genBlock/genEditTableBlock.js +419 -0
  33. package/out/types/data/genBlock/genEditTableBlock.js.map +1 -0
  34. package/out/types/data/genBlock/genQueryComponent.d.ts +20 -0
  35. package/out/types/data/genBlock/genQueryComponent.js +57 -1
  36. package/out/types/data/genBlock/genQueryComponent.js.map +1 -1
  37. package/out/types/data/genBlock/genTableBlock.js +9 -5
  38. package/out/types/data/genBlock/genTableBlock.js.map +1 -1
  39. package/out/types/data/genBlock/index.d.ts +2 -0
  40. package/out/types/data/genBlock/index.js +2 -0
  41. package/out/types/data/genBlock/index.js.map +1 -1
  42. package/out/types/data/genBlock/utils.d.ts +7 -0
  43. package/out/types/data/genBlock/utils.js +38 -1
  44. package/out/types/data/genBlock/utils.js.map +1 -1
  45. package/out/types/index.d.ts +2 -4
  46. package/out/types/index.js +3 -6
  47. package/out/types/index.js.map +1 -1
  48. package/out/types/logic/Logic.d.ts +4 -12
  49. package/out/types/logic/Logic.js +35 -24
  50. package/out/types/logic/Logic.js.map +1 -1
  51. package/out/types/logic/LogicItem.d.ts +1 -20
  52. package/out/types/logic/LogicItem.js +5 -191
  53. package/out/types/logic/LogicItem.js.map +1 -1
  54. package/out/types/logic/Param.js +5 -13
  55. package/out/types/logic/Param.js.map +1 -1
  56. package/out/types/logic/Return.js +3 -11
  57. package/out/types/logic/Return.js.map +1 -1
  58. package/out/types/logic/Variable.js +3 -6
  59. package/out/types/logic/Variable.js.map +1 -1
  60. package/out/types/logic/translator.js +39 -8
  61. package/out/types/logic/translator.js.map +1 -1
  62. package/out/types/page/Element.d.ts +21 -2
  63. package/out/types/page/Element.js +89 -7
  64. package/out/types/page/Element.js.map +1 -1
  65. package/out/types/page/Page.d.ts +4 -0
  66. package/out/types/page/Page.js +7 -0
  67. package/out/types/page/Page.js.map +1 -1
  68. package/out/types/page/View.d.ts +19 -16
  69. package/out/types/page/View.js +73 -15
  70. package/out/types/page/View.js.map +1 -1
  71. package/out/types/page/ViewVariable.js +0 -6
  72. package/out/types/page/ViewVariable.js.map +1 -1
  73. package/out/types/process/ProcessParam.js +3 -1
  74. package/out/types/process/ProcessParam.js.map +1 -1
  75. package/out/types/utils/index.d.ts +1 -0
  76. package/out/types/utils/index.js +16 -7
  77. package/out/types/utils/index.js.map +1 -1
  78. package/package.json +1 -2
  79. package/src/service/app/api.js +8 -17
  80. package/src/service/create/errHandles.js +12 -0
  81. package/src/service/create/index.js +4 -0
  82. package/src/service/logic/logic.js +6 -0
  83. package/src/types/app/App.ts +37 -28
  84. package/src/types/app/History.ts +3 -2
  85. package/src/types/app/Service.ts +14 -5
  86. package/src/types/cacheData.ts +7 -7
  87. package/src/types/data/Entity.ts +7 -0
  88. package/src/types/data/EntityProperty.ts +12 -0
  89. package/src/types/data/dataTypes.ts +1 -1
  90. package/src/types/data/genBlock/genCurdEditTableBlock.ts +581 -0
  91. package/src/types/data/genBlock/genEditTableBlock.ts +470 -0
  92. package/src/types/data/genBlock/genQueryComponent.ts +56 -0
  93. package/src/types/data/genBlock/genTableBlock.ts +14 -10
  94. package/src/types/data/genBlock/index.ts +2 -0
  95. package/src/types/data/genBlock/utils.ts +38 -0
  96. package/src/types/index.ts +2 -4
  97. package/src/types/logic/Logic.ts +45 -41
  98. package/src/types/logic/LogicItem.ts +12 -217
  99. package/src/types/logic/Param.ts +25 -35
  100. package/src/types/logic/Return.ts +18 -26
  101. package/src/types/logic/Variable.ts +18 -20
  102. package/src/types/logic/translator.js +125 -154
  103. package/src/types/page/Element.ts +160 -73
  104. package/src/types/page/Page.ts +7 -0
  105. package/src/types/page/View.ts +112 -61
  106. package/src/types/page/ViewVariable.ts +13 -19
  107. package/src/types/page/dist/View.js +727 -0
  108. package/src/types/process/ProcessParam.ts +4 -1
  109. package/src/types/utils/index.ts +16 -7
  110. package/tsconfig.json +1 -1
  111. package/out/service/debugger/debugger.d.ts +0 -3
  112. package/out/service/debugger/debugger.js +0 -95
  113. package/out/service/debugger/debugger.js.map +0 -1
  114. package/out/test/units/config.spec.d.ts +0 -1
  115. package/out/test/units/config.spec.js +0 -12
  116. package/out/test/units/config.spec.js.map +0 -1
  117. package/out/types/logic/BreakPoint.d.ts +0 -42
  118. package/out/types/logic/BreakPoint.js +0 -155
  119. package/out/types/logic/BreakPoint.js.map +0 -1
  120. package/out/types/logic/Debugger.d.ts +0 -156
  121. package/out/types/logic/Debugger.js +0 -912
  122. package/out/types/logic/Debugger.js.map +0 -1
  123. package/src/service/debugger/debugger.js +0 -90
  124. package/src/types/logic/BreakPoint.ts +0 -200
  125. package/src/types/logic/Debugger.ts +0 -1140
  126. package/src/types/logic/translator.d.ts +0 -16
@@ -19,6 +19,12 @@ export default {
19
19
  method: 'post',
20
20
  },
21
21
  },
22
+ callLogicUpdate: {
23
+ url: {
24
+ path: '/proxy/graph/api/v1/graph/logic/callLogicUpdate',
25
+ method: 'post',
26
+ },
27
+ },
22
28
  delete: {
23
29
  url: {
24
30
  path: '/proxy/graph/api/v1/graph/logic/delete',
@@ -1,8 +1,6 @@
1
- const { io } = require('socket.io-client');
2
1
  import { excludedInJSON, immutable } from '../decorators';
3
- import { LEVEL_ENUM, Vertex, Service, WebService, MicroService, SERVICE_TYPE, utils, History, updateGenericTypeList, BreakPoint, BreakpointMeta, Debugger } from '..';
2
+ import { LEVEL_ENUM, Vertex, Service, WebService, MicroService, SERVICE_TYPE, utils, History, updateGenericTypeList, vertexsMap, Entity, Structure, Enum, dataTypesMap, BaseVariable, variablesMap, updateDataTypeList } from '..';
4
3
  import appService from '../../service/app';
5
- import { createSocketClient, breakpointService } from '../../service/debugger/debugger';
6
4
 
7
5
  interface AppLoadAllOptions {
8
6
  asyncLoadServicesDetail?: boolean,
@@ -114,10 +112,6 @@ export class App extends Vertex {
114
112
  */
115
113
  @immutable()
116
114
  public readonly firstMicroService: MicroService = undefined;
117
-
118
- @immutable()
119
- @excludedInJSON()
120
- public debuggerClient: Debugger = null;
121
115
  /**
122
116
  * 历史记录
123
117
  * 用于处理撤销重做
@@ -133,8 +127,6 @@ export class App extends Vertex {
133
127
  source && this.assign(source);
134
128
 
135
129
  this.history = new History({ app: this });
136
- this.debuggerClient = new Debugger();
137
- this.debuggerClient.app = this;
138
130
  }
139
131
  /**
140
132
  * 加载详情并同步 envList 信息
@@ -167,24 +159,6 @@ export class App extends Vertex {
167
159
  this.assign(result);
168
160
  return this;
169
161
  }
170
-
171
- async loadBreakPoints() {
172
- const breakpointsMeta = await breakpointService.getAllBreakPoints({
173
- query: {
174
- appId: this.id,
175
- },
176
- });
177
- breakpointsMeta.forEach(async (bp: BreakpointMeta) => {
178
- const bpInstance = await BreakPoint.from(bp);
179
- if (bpInstance)
180
- this.debuggerClient.breakPoints.push(bpInstance);
181
- });
182
- }
183
-
184
- async bootDebugger() {
185
- await this.debuggerClient.boot();
186
- }
187
-
188
162
  /**
189
163
  * 加载 App 下的所有服务
190
164
  */
@@ -270,8 +244,8 @@ export class App extends Vertex {
270
244
  asyncLoadServicesDetail: false,
271
245
  asyncLoadViewsDetail: false,
272
246
  }) {
247
+ await this.load(); // 请求其它接口前,需要先查询到 app 上的 baseVersion
273
248
  await Promise.all([
274
- this.load(),
275
249
  this.loadServices(),
276
250
  updateGenericTypeList(),
277
251
  ]);
@@ -288,6 +262,41 @@ export class App extends Vertex {
288
262
  from(source: any) {
289
263
  return new App(source);
290
264
  }
265
+ /**
266
+ * 清理内存,避免内存泄漏
267
+ */
268
+ clear() {
269
+ function traverse(obj: any, callback: (obj: any) => void, ws = new WeakSet()) {
270
+ if (typeof obj !== 'object' || obj === null)
271
+ return;
272
+ if (ws.has(obj))
273
+ return;
274
+
275
+ ws.add(obj);
276
+
277
+ if (Array.isArray(obj))
278
+ obj.forEach((item) => {
279
+ traverse(item, callback, ws);
280
+ });
281
+ else {
282
+ callback(obj);
283
+ Object.values(obj).forEach((item) => {
284
+ traverse(item, callback, ws);
285
+ });
286
+ }
287
+ }
288
+
289
+ traverse(this, (obj: any) => {
290
+ vertexsMap.delete(obj?.id);
291
+
292
+ if (obj instanceof Entity || obj instanceof Structure || obj instanceof Enum)
293
+ delete dataTypesMap[obj.schemaRef];
294
+
295
+ if (obj instanceof BaseVariable)
296
+ variablesMap.delete(obj.id);
297
+ });
298
+ updateDataTypeList();
299
+ }
291
300
  }
292
301
 
293
302
  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';
@@ -231,6 +231,7 @@ export class WebService extends Service {
231
231
  template: { name: string, version: string },
232
232
  ui: { name: string, version: string },
233
233
  componentDependencies: { [name: string]: string },
234
+ templateConfig: { builtInTemplate: boolean },
234
235
  themeVariables: { [name: string]: string },
235
236
  } = undefined;
236
237
  /**
@@ -385,6 +386,10 @@ ${Object.keys(themeVariables).map((key) => ` ${key}: ${themeVariables[key]};`
385
386
  }
386
387
 
387
388
  async loadPages(enableCache = true) {
389
+ const isGONGHANG = utils.getGlobalEnv() === 'gonghang';
390
+ if (isGONGHANG) {
391
+ enableCache = false;
392
+ }
388
393
  this.pages.forEach((page) => {
389
394
  page.destroy();
390
395
  });
@@ -760,14 +765,14 @@ export class MicroService extends Service {
760
765
  microServiceId: this.id,
761
766
  },
762
767
  });
763
- entities.forEach((item, index) => {
768
+ entities.forEach((item) => {
764
769
  const tempEntity = <Entity>vertexsMap.get(item.id);
765
770
  if (tempEntity) {
766
771
  tempEntity.assign({ lastVersionDef: item.lastVersionDef });
767
772
  }
768
773
  const lastVersionRef = item.lastVersionDef && item.lastVersionDef.properties || {};
769
774
  const propertyList = tempEntity.propertyList as Array<EntityProperty>;
770
- propertyList.forEach((property, index) => {
775
+ propertyList.forEach((property) => {
771
776
  property = <EntityProperty>vertexsMap.get(property.id);
772
777
  if (property && lastVersionRef[property.name]) {
773
778
  property.assign({ lastVersion: convert2RefType(lastVersionRef[property.name]) });
@@ -779,6 +784,10 @@ export class MicroService extends Service {
779
784
  * 加载服务所有的接口列表
780
785
  */
781
786
  async loadInterfaces(enableCache = true) {
787
+ const isGONGHANG = utils.getGlobalEnv() === 'gonghang';
788
+ if (isGONGHANG) {
789
+ enableCache = false;
790
+ }
782
791
  const logicMap = new Map();
783
792
  // 旧接口列表中,可能存在已经被删掉的接口,需要从 vertexsMap 中删除
784
793
  this.interfaces.forEach((it) => {
@@ -797,14 +806,14 @@ export class MicroService extends Service {
797
806
  });
798
807
 
799
808
  interfaces = interfaces.map((item) => {
800
- if(logicMap.has(item.id)) {
809
+ if (logicMap.has(item.id)) {
801
810
  item.logic = logicMap.get(item.id);
802
811
  logicMap.delete(item.id);
803
812
  }
804
813
  return Interface.from(item, this);
805
814
  });
806
815
  // 清理掉已不存在的逻辑
807
- for(const logic of logicMap.values()) {
816
+ for (const logic of logicMap.values()) {
808
817
  logic.destroy();
809
818
  }
810
819
 
@@ -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
+ }
@@ -28,6 +28,7 @@ export const systemProperty: { [name: string]: any, } = {
28
28
  format: 'long',
29
29
  editable: false,
30
30
  required: true,
31
+ propertyGenRule: 'platform',
31
32
  display: {
32
33
  inTable: false,
33
34
  inFilter: false,
@@ -172,6 +173,12 @@ export class Entity extends Vertex implements ObjectSchema {
172
173
  @circular()
173
174
  @immutable()
174
175
  public readonly dataNode: DataNode = undefined;
176
+
177
+ /**
178
+ * 数据来源名称,平台生成 默认ide
179
+ */
180
+ @immutable()
181
+ public readonly entityGenSource: string = undefined;
175
182
  /**
176
183
  * 周边存在的名称
177
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
  */
@@ -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