@lcap/nasl 2.13.0-beta.1 → 2.13.0-beta.2

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 (112) hide show
  1. package/out/bak/translator.js +1 -6
  2. package/out/bak/translator.js.map +1 -1
  3. package/out/common/BaseNode.js +1 -1
  4. package/out/common/BaseNode.js.map +1 -1
  5. package/out/concepts/BindAttribute__.d.ts +65 -12
  6. package/out/concepts/BindAttribute__.js +72 -7
  7. package/out/concepts/BindAttribute__.js.map +1 -1
  8. package/out/concepts/BindDirective__.d.ts +55 -0
  9. package/out/concepts/BindDirective__.js +69 -0
  10. package/out/concepts/BindDirective__.js.map +1 -1
  11. package/out/concepts/BindEvent__.d.ts +2 -94
  12. package/out/concepts/BindEvent__.js +55 -347
  13. package/out/concepts/BindEvent__.js.map +1 -1
  14. package/out/concepts/CallQueryComponent__.d.ts +102 -26
  15. package/out/concepts/CallQueryComponent__.js +104 -28
  16. package/out/concepts/CallQueryComponent__.js.map +1 -1
  17. package/out/concepts/CompletionProperty__.d.ts +1 -0
  18. package/out/concepts/CompletionProperty__.js +1 -0
  19. package/out/concepts/CompletionProperty__.js.map +1 -1
  20. package/out/concepts/Destination__.d.ts +1 -0
  21. package/out/concepts/Destination__.js +5 -1
  22. package/out/concepts/Destination__.js.map +1 -1
  23. package/out/concepts/Function__.d.ts +1 -2
  24. package/out/concepts/Function__.js +28 -0
  25. package/out/concepts/Function__.js.map +1 -1
  26. package/out/concepts/Logic__.d.ts +1 -7
  27. package/out/concepts/Logic__.js +10 -76
  28. package/out/concepts/Logic__.js.map +1 -1
  29. package/out/concepts/Param__.d.ts +0 -1
  30. package/out/concepts/Param__.js +0 -6
  31. package/out/concepts/Param__.js.map +1 -1
  32. package/out/concepts/ProcessElement__.d.ts +0 -86
  33. package/out/concepts/ProcessElement__.js +0 -130
  34. package/out/concepts/ProcessElement__.js.map +1 -1
  35. package/out/concepts/Process__.d.ts +0 -93
  36. package/out/concepts/Process__.js +0 -141
  37. package/out/concepts/Process__.js.map +1 -1
  38. package/out/concepts/ViewElement__.d.ts +8 -0
  39. package/out/concepts/ViewElement__.js +35 -47
  40. package/out/concepts/ViewElement__.js.map +1 -1
  41. package/out/concepts/View__.d.ts +8 -9
  42. package/out/concepts/View__.js +26 -72
  43. package/out/concepts/View__.js.map +1 -1
  44. package/out/concepts/basics/stdlib/nasl.ui.js +0 -4
  45. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  46. package/out/index.d.ts +1 -1
  47. package/out/index.js +3 -1
  48. package/out/index.js.map +1 -1
  49. package/out/server/createUiTs.d.ts +0 -9
  50. package/out/server/createUiTs.js +1 -28
  51. package/out/server/createUiTs.js.map +1 -1
  52. package/out/server/getMemberIdentifier.d.ts +1 -16
  53. package/out/server/getMemberIdentifier.js +29 -94
  54. package/out/server/getMemberIdentifier.js.map +1 -1
  55. package/out/server/getProcesses.d.ts +3 -3
  56. package/out/server/getProcesses.js +27 -28
  57. package/out/server/getProcesses.js.map +1 -1
  58. package/out/server/index.js +0 -3
  59. package/out/server/index.js.map +1 -1
  60. package/out/server/naslServer.js +7 -19
  61. package/out/server/naslServer.js.map +1 -1
  62. package/out/server/translator.js +5 -13
  63. package/out/server/translator.js.map +1 -1
  64. package/out/service/storage/init.d.ts +8 -0
  65. package/out/service/storage/init.js +5 -7
  66. package/out/service/storage/init.js.map +1 -1
  67. package/out/service/storage/service.d.ts +11 -2
  68. package/out/service/storage/service.js +26 -1
  69. package/out/service/storage/service.js.map +1 -1
  70. package/out/templator/genCurdEditMultipleKeyBlock.js +2 -4
  71. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  72. package/out/templator/genCurdMultipleKeyBlock.d.ts +0 -11
  73. package/out/templator/genCurdMultipleKeyBlock.js +19 -29
  74. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  75. package/out/templator/genEditTableBlock.js +30 -2
  76. package/out/templator/genEditTableBlock.js.map +1 -1
  77. package/out/templator/genGridViewBlock.js +15 -1
  78. package/out/templator/genGridViewBlock.js.map +1 -1
  79. package/out/templator/genTableBlock.js +15 -1
  80. package/out/templator/genTableBlock.js.map +1 -1
  81. package/package.json +1 -1
  82. package/src/bak/translator.js +1 -8
  83. package/src/common/BaseNode.ts +1 -1
  84. package/src/concepts/BindAttribute__.ts +153 -19
  85. package/src/concepts/BindDirective__.ts +139 -0
  86. package/src/concepts/BindEvent__.ts +57 -422
  87. package/src/concepts/CallQueryComponent__.ts +253 -56
  88. package/src/concepts/CompletionProperty__.ts +1 -0
  89. package/src/concepts/Destination__.ts +6 -1
  90. package/src/concepts/Function__.ts +1 -15
  91. package/src/concepts/Logic__.ts +11 -77
  92. package/src/concepts/Param__.ts +0 -6
  93. package/src/concepts/ProcessElement__.ts +1 -227
  94. package/src/concepts/Process__.ts +1 -237
  95. package/src/concepts/ViewElement__.ts +36 -48
  96. package/src/concepts/View__.ts +27 -72
  97. package/src/concepts/basics/stdlib/nasl.ui.ts +0 -4
  98. package/src/index.ts +1 -1
  99. package/src/server/createUiTs.ts +2 -26
  100. package/src/server/getMemberIdentifier.ts +28 -88
  101. package/src/server/getProcesses.ts +30 -31
  102. package/src/server/index.ts +0 -4
  103. package/src/server/naslServer.ts +7 -20
  104. package/src/server/translator.ts +6 -13
  105. package/src/service/storage/init.ts +5 -6
  106. package/src/service/storage/service.ts +28 -1
  107. package/src/templator/genCurdEditMultipleKeyBlock.ts +2 -5
  108. package/src/templator/genCurdMultipleKeyBlock.ts +16 -27
  109. package/src/templator/genEditTableBlock.ts +27 -0
  110. package/src/templator/genGridViewBlock.ts +13 -0
  111. package/src/templator/genTableBlock.ts +13 -0
  112. package/src/server/events.yaml +0 -89
@@ -70,6 +70,12 @@ export class View extends BaseNode {
70
70
  @property()
71
71
  auth: boolean = undefined;
72
72
 
73
+ /**
74
+ * 权限资源描述
75
+ */
76
+ @property()
77
+ authDescription: string = undefined;
78
+
73
79
  /**
74
80
  * 是否是默认跳转的页面
75
81
  */
@@ -222,6 +228,18 @@ export class View extends BaseNode {
222
228
  });
223
229
  }
224
230
 
231
+ /**
232
+ * 设置权限资源描述
233
+ */
234
+ setAuthDescription(authDescription: string) {
235
+ const object = {
236
+ authDescription,
237
+ };
238
+ this.update({
239
+ ...object,
240
+ });
241
+ }
242
+
225
243
  /**
226
244
  * 设置是否是默认跳转的页面
227
245
  */
@@ -1453,7 +1471,6 @@ export class View extends BaseNode {
1453
1471
  if (template) {
1454
1472
  const node = ViewElement.fromHTML(template, {
1455
1473
  view: this,
1456
- definition,
1457
1474
  });
1458
1475
  if (!parentNode) {
1459
1476
  return;
@@ -1512,38 +1529,20 @@ export class View extends BaseNode {
1512
1529
  // 页面逻辑
1513
1530
  if (Array.isArray(definition.viewLogics)) {
1514
1531
  definition.viewLogics.forEach((logicOption: any) => {
1515
- // 页面逻辑只有load函数的走之前的逻辑其余不用创建
1516
- if (logicOption.name.startsWith('load')) {
1517
- const logic = Logic.from({
1518
- ...logicOption,
1519
- }, this, 'logics');
1520
- this.addLogic(logic);
1521
- }
1532
+ const logic = Logic.from({
1533
+ ...logicOption,
1534
+ }, this, 'logics');
1535
+ this.addLogic(logic);
1522
1536
  });
1523
1537
  }
1538
+
1524
1539
  // 页面事件
1525
1540
  if (Array.isArray(definition.viewBindEvents)) {
1526
1541
  definition.viewBindEvents.forEach((eventOption: any) => {
1527
- const newLogic = definition.viewLogics.find((logic: Logic) => {
1528
- return eventOption.calleeName === logic.name;
1529
- });
1530
- const bindEvent = this.bindEvents.find((currentEventItem) => {
1531
- return currentEventItem.name === eventOption.name;
1532
- });
1533
-
1534
- // 如果没有event对象就先新增一个,如果已经有了就在内部添加logic
1535
- if (!bindEvent) {
1536
- const event = BindEvent.from({
1537
- ...eventOption,
1538
- calleeName: '',
1539
- logics: [newLogic],
1540
- }, this, 'events');
1541
- this.addBindEvent(event);
1542
- } else {
1543
- const index = bindEvent.logics.length;
1544
- newLogic.name = newLogic.name + index;
1545
- bindEvent.addLogic(newLogic);
1546
- }
1542
+ const event = BindEvent.from({
1543
+ ...eventOption,
1544
+ }, this, 'events');
1545
+ this.addBindEvent(event);
1547
1546
  });
1548
1547
  }
1549
1548
  }
@@ -1611,7 +1610,6 @@ export class View extends BaseNode {
1611
1610
  crumb: this.crumb,
1612
1611
  first: this.children.find((child) => child.isIndex)?.name,
1613
1612
  auth: this.auth ? 'loginAuth' : undefined,
1614
- viewBindEvents: this.getViewBindEvents(),
1615
1613
  };
1616
1614
  return `${componentOptions}
1617
1615
  ${translator(definition)}
@@ -1846,49 +1844,6 @@ export class View extends BaseNode {
1846
1844
  get authPath() {
1847
1845
  return this.path;
1848
1846
  }
1849
- /**
1850
- * 获取当前页面下所有elements上bindEvents下的logic
1851
- */
1852
- get elementLogicRoot() {
1853
- const logics: Array<Logic> = [];
1854
- // 页面上的绑定的事件
1855
- this.bindEvents.forEach((bindEvent) => {
1856
- bindEvent.logics.forEach((logic) => {
1857
- // logic.virtualParams = bindEvent.getContextRenderLogicParams(logic);
1858
- logics.push(logic);
1859
- });
1860
- });
1861
- this.elements.forEach((item) => {
1862
- utils.traverse((current) => {
1863
- current.node.bindEvents.forEach((bindEvent) => {
1864
- bindEvent.logics.forEach((logic) => {
1865
- // logic.virtualParams = bindEvent.getContextRenderLogicParams(logic);
1866
- logics.push(logic);
1867
- });
1868
- });
1869
- }, { node: item });
1870
- });
1871
- return [{
1872
- concept: 'elementLogicRoot',
1873
- expanded: false,
1874
- children: logics,
1875
- }];
1876
- }
1877
- getViewBindEvents() {
1878
- const bindEvents: Array<BindEvent> = [];
1879
- // 页面上的绑定的事件
1880
- this.bindEvents.forEach((bindEvent) => {
1881
- bindEvents.push(bindEvent);
1882
- });
1883
- this.elements.forEach((item) => {
1884
- utils.traverse((current) => {
1885
- current.node.bindEvents.forEach((bindEvent) => {
1886
- bindEvents.push(bindEvent);
1887
- });
1888
- }, { node: item });
1889
- });
1890
- return bindEvents;
1891
- }
1892
1847
 
1893
1848
  /**
1894
1849
  * @param path 子路径
@@ -38,10 +38,6 @@ export const uiStructures = [
38
38
  }),
39
39
  ],
40
40
  }),
41
- new Structure({
42
- name: 'BaseEvent',
43
- properties: [],
44
- }),
45
41
  new Structure({
46
42
  name: 'DataSourceParams',
47
43
  properties: [
package/src/index.ts CHANGED
@@ -8,5 +8,5 @@ export * as genBlock from './templator';
8
8
  export * as utils from './utils';
9
9
  export * from './config';
10
10
  export * from './eventBus';
11
- export { loadApp, loadAppSync, handleApp } from './service/storage/init';
11
+ export { loadApp, loadAppSync, handleApp, batchAction, batchQuery } from './service/storage/init';
12
12
  import './automate/engine';
@@ -1,6 +1,5 @@
1
1
  import { Logic, TypeAnnotation, Param, LogicItem, NumericLiteral, BooleanLiteral, StringLiteral, Identifier, MemberExpression } from '..';
2
- // @ts-ignore
3
- import trigger from './events.yaml';
2
+
4
3
  const naslStdlibMap: any = {
5
4
  'nasl.core.ts': require('!!raw-loader!../../../file-storage/data/stdlib/nasl.core.ts').default,
6
5
  'nasl.collection.ts': require('!!raw-loader!../../../file-storage/data/stdlib/nasl.collection.ts').default,
@@ -15,26 +14,6 @@ const naslStdlibMap: any = {
15
14
  'nasl.validation.ts': require('!!raw-loader!../../../file-storage/data/stdlib/nasl.validation.ts').default,
16
15
  'nasl.process.ts': require('!!raw-loader!../../../file-storage/data/stdlib/nasl.process.ts').default,
17
16
  };
18
- export let elementsEventsMap: { [componentTagEventName: string]: any} = {};
19
-
20
- export function getAllComponentEventMap(allComponent: any) {
21
- const eventsMap: { [componentTagEventName: string]: any} = {};
22
- for (const i in allComponent) {
23
- const item = allComponent[i];
24
- if (item.events && Array.isArray(item.events)) {
25
- item.events.forEach((eventItem: any) => {
26
- const name = `${item.name}-${eventItem.name}`;
27
- eventsMap[name] = eventItem;
28
- });
29
- }
30
- }
31
- trigger.forEach((item: any) => {
32
- eventsMap[item.name] = item;
33
- });
34
-
35
- elementsEventsMap = eventsMap;
36
- return eventsMap;
37
- }
38
17
 
39
18
  export default function formatUiTs(allComponent: any) {
40
19
  const indent = (tabSize: number) => ' '.repeat(tabSize * 2);
@@ -102,7 +81,6 @@ export default function formatUiTs(allComponent: any) {
102
81
  return logic;
103
82
  };
104
83
  const elementsLogic: { [componentName: string]: Array<Logic> } = {};
105
-
106
84
  let value = `namespace nasl.ui {
107
85
  export class VueComponent {
108
86
  }
@@ -128,7 +106,7 @@ export default function formatUiTs(allComponent: any) {
128
106
  options?: {
129
107
  [propname: string]: any,
130
108
  bindAttr?: () => Array<any>,
131
- slotDefault?: (scope: nasl.ui.ScopeOf<T>) => Array<any>,
109
+ slotDefault?: ()=> Array<any>,
132
110
  }){super()}
133
111
  }
134
112
  export type GetItemTypeFromDataSource<T> = T extends nasl.collection.PageOf<infer U> | nasl.collection.List<infer U> | ((...args: any) => nasl.collection.PageOf<infer U> | nasl.collection.List<infer U>) ? U : never;
@@ -212,11 +190,9 @@ export default function formatUiTs(allComponent: any) {
212
190
  value += '}\n';
213
191
  // console.log(value);
214
192
  // console.log(elementsLogic);
215
- // const elementsEventsMap = getAllComponentEventMap(allComponent);
216
193
  return {
217
194
  code: value,
218
195
  elementsLogic,
219
196
  naslStdlibMap,
220
- elementsEventsMap,
221
197
  };
222
198
  }
@@ -1,6 +1,5 @@
1
- import { BaseNode, CompletionProperty, App, Identifier, MemberExpression, Enum, NullLiteral, BooleanLiteral, Param, BindAttribute, LogicItem, TypeAnnotation, StructureProperty, Entity, Structure, EntityProperty } from '..';
1
+ import { BaseNode, CompletionProperty, App, Identifier, MemberExpression, Enum, NullLiteral, BooleanLiteral, Param, BindAttribute, LogicItem, TypeAnnotation } from '..';
2
2
  import naslServer from './naslServer';
3
- import { getNaslNodeByNodeCallee } from '../automate/engine/utils';
4
3
 
5
4
  interface variableItem {
6
5
  text: string;
@@ -38,7 +37,7 @@ function formatTs2TypeString(displayParts: Array<{ text: string; kind: string }>
38
37
  * @param type app
39
38
  * @returns typeAnnotation
40
39
  */
41
- export function getCompletionDetailType(type: string): TypeAnnotation {
40
+ function getCompletionDetailType(type: string): TypeAnnotation {
42
41
  let typeAnnotation;
43
42
  try {
44
43
  if (type.includes('<') && type.includes('>')) {
@@ -116,8 +115,6 @@ export function getPlatformType(tsType: string): string {
116
115
  const namespacePrefix = ['app', 'extensions', 'apis', 'components', 'nasl'];
117
116
  if (tsType === 'String') {
118
117
  return 'nasl.core.String';
119
- } else if (tsType === 'Boolean') {
120
- return 'nasl.core.Boolean';
121
118
  }
122
119
 
123
120
  const strTypes = tsType.split('.');
@@ -168,97 +165,29 @@ function sortFirstVariableData(result: CompletionProperty[], node: BaseNode) {
168
165
  newResult.push(...result);
169
166
  return newResult;
170
167
  }
171
- export function isNoChildType(type: String) {
172
- return type?.startsWith('nasl.core') || type?.startsWith('app.enums');
173
- }
174
- function findNode(typeKey: string, node: BaseNode) {
175
- let newType: Structure | Entity;
176
- if (typeKey.startsWith('nasl.') && typeKey.includes('<')) {
177
- const findGenericsIndex = typeKey.indexOf('<');
178
- typeKey = typeKey.substring(0, findGenericsIndex);
179
- const typeIndex = typeKey.lastIndexOf('.');
180
- newType = getNaslNodeByNodeCallee(typeKey.substring(0, typeIndex), typeKey.substring(typeIndex + 1, typeKey.length));
181
- } else if (typeKey.startsWith('nasl.')) {
182
- const typeIndex = typeKey.lastIndexOf('.');
183
- newType = getNaslNodeByNodeCallee(typeKey.substring(0, typeIndex), typeKey.substring(typeIndex + 1, typeKey.length));
184
- } else {
185
- newType = (node as Identifier)?.app?.findNodeByCompleteName(typeKey);
186
- }
187
- return newType;
188
- }
189
-
190
- /**
191
- * 获取下一级的节点进行递归
192
- * @param typeKey 当前节点的类型,主要为了取出内部的 T中的实际类型
193
- * @param item 当前节点的内容
194
- * @param parent 父级节点的内容
195
- * @param node 获取变量框的位置
196
- */
197
- export function nextFindTypeChild(typeKey: string, item: any, parent: any, node: BaseNode) {
198
- // 有一个当前树分支的全部节点的node map,用作防止数据无限递归,只保留3层
199
- const nodeMap = parent ? parent.nodeMap : new Map();
200
- item.nodeMap = nodeMap;
201
- const newType = findNode(typeKey, node);
202
- if (newType?.properties && newType.properties.length) {
203
- // 处理泛型的内容要取到值
204
- const StructureJson = newType.toJSON();
205
- const newStructure = new Structure(StructureJson);
206
- newStructure.properties.forEach((item: StructureProperty | EntityProperty) => {
207
- const itemType = item?.typeAnnotation?.typeKey;
208
- if (itemType === 'T' && /\<([^()]+)\>/g.exec(typeKey)) {
209
- const newTypes = /\<([^()]+)\>/g.exec(typeKey);
210
- // 找到当前原来的类型
211
- const contentType = getPlatformType(newTypes[1]);
212
- const typeNamespace = contentType.substring(0, contentType.lastIndexOf('.'));
213
- const typeName = contentType.substring(contentType.lastIndexOf('.') + 1, contentType.length);
214
- item.typeAnnotation = new TypeAnnotation({
215
- typeKind: 'reference',
216
- typeNamespace,
217
- typeName,
218
- });
219
- }
220
- });
221
- const index = nodeMap.get(newType) || 0;
222
- if (index) {
223
- nodeMap.set(newType, index + 1);
224
- } else {
225
- nodeMap.set(newType, 1);
226
- }
227
- // 最多保留3层
228
- if (index < 3) {
229
- item.children = formatVariableData(newStructure.properties, node, item);
230
- }
231
- }
232
- }
233
168
  // 格式化变量数据
234
169
  export function formatVariableData(data: unknown | variableItem[], node: BaseNode, parent?: any) {
235
170
  if (Array.isArray(data)) {
236
171
  let result = data.map((item) => {
237
- item.children = [];
172
+ // value需要拼接生成
173
+ item.value = parent ? `${parent.value}.${item.text}` : item.text;
174
+ item.name = item.text;
238
175
  // 当前结构的typeAnnotation
239
176
  let typeAnnotation;
240
- // 当前的类型如 app.entitys.entity1 nasl.core.String
241
- let typeKey: string;
177
+ let type;
242
178
 
243
179
  if (item.completionDetail) {
244
- // 当前节点的完整类型,主要是在有T的内容使用 nasl.list<Enum1> 内部匹配内容给里面子集的T赋值类型
245
- const currentType: string = formatTs2TypeString(item.completionDetail.displayParts as Array<{ text: string; kind: string }>);
246
- typeAnnotation = getCompletionDetailType(currentType);
247
- typeKey = getPlatformType(currentType);
248
- } else if (item instanceof StructureProperty) {
249
- typeKey = item?.typeAnnotation?.typeKey;
180
+ let type = formatTs2TypeString(item.completionDetail.displayParts as Array<{ text: string; kind: string }>);
181
+ typeAnnotation = getCompletionDetailType(type);
182
+ type = getPlatformType(type);
250
183
  }
251
184
  // 如果没有父节点就是Identifier
252
185
  if (!parent) {
253
- // value需要拼接生成
254
- item.value = parent ? `${parent.value}.${item.text}` : item.text;
255
- item.name = item.text;
256
186
  const identifier = new Identifier({ name: item.name });
257
187
  // 携带上当前的类型
258
188
  identifier.typeAnnotation = typeAnnotation;
259
189
  item.expression = identifier;
260
190
  } else {
261
- item.value = `${parent.value}.${item.name}`;
262
191
  const memberExpression = new MemberExpression({
263
192
  object: parent.expression,
264
193
  property: new Identifier({ name: item.name }),
@@ -267,18 +196,19 @@ export function formatVariableData(data: unknown | variableItem[], node: BaseNod
267
196
  memberExpression.typeAnnotation = typeAnnotation;
268
197
  item.expression = memberExpression;
269
198
  }
270
- // 如果有类型而且类型不是没有子集的类型,就把他当前的类型拿到
271
- if (typeKey && !isNoChildType(typeKey)) {
272
- nextFindTypeChild(typeKey, item, parent, node);
199
+ if (item.children) {
200
+ item.children = formatVariableData(item.children, node, item);
273
201
  }
274
- const completionProperty = new CompletionProperty(item);
275
202
  if (!parent) {
203
+ const completionProperty = new CompletionProperty(item);
276
204
  // 变量 param return 在这里添加图标
277
205
  completionProperty.icon = getNodeiconFromLogic(completionProperty, node);
206
+ return completionProperty;
278
207
  } else {
208
+ const completionProperty = new CompletionProperty(item);
279
209
  completionProperty.icon = 'refProperty';
210
+ return completionProperty;
280
211
  }
281
- return completionProperty;
282
212
  });
283
213
 
284
214
  /**
@@ -533,9 +463,19 @@ export function getEnumsIdentifier(node: BaseNode): CompletionProperty[] {
533
463
  // 获取变量
534
464
  export async function getVariableIdentifier(node: BaseNode): Promise<CompletionProperty[]> {
535
465
  let completionData: CompletionProperty[] = [new CompletionProperty({})];
536
- // 只获取第一层内容
537
- const nextCompletion = await naslServer.getFieldKeySelectCompletion(node, '');
538
- completionData = formatVariableData(nextCompletion, node);
466
+ if (node instanceof Identifier || node instanceof MemberExpression) {
467
+ const value = (node as Identifier | MemberExpression).getValue();
468
+ if (value) {
469
+ const completion = (await naslServer.getValueSelectCompletion(node, value)) as variableItem[];
470
+ completionData = formatVariableData(completion, node);
471
+ } else {
472
+ const nextCompletion = await naslServer.getFieldKeySelectCompletion(node, '');
473
+ completionData = formatVariableData(nextCompletion, node);
474
+ }
475
+ } else {
476
+ const nextCompletion = await naslServer.getFieldKeySelectCompletion(node, '');
477
+ completionData = formatVariableData(nextCompletion, node);
478
+ }
539
479
  return completionData;
540
480
  }
541
481
 
@@ -1,7 +1,6 @@
1
1
  import Constant from '@nasl/concepts/Constant__';
2
2
  import { CompletionProperty, Process, ProcessElement, Namespace, Logic, TypeAnnotation, Return, Variable, StructureProperty, Param, Identifier, MemberExpression, LogicItem, App, BaseNode, Structure, Entity, EntityProperty } from '..';
3
3
  import { getNodeByNodeCallee } from '../automate/engine/utils';
4
- import { isNoChildType, nextFindTypeChild } from './getMemberIdentifier';
5
4
  function alphaUpper(name: string) {
6
5
  if (!name) {
7
6
  return '';
@@ -251,26 +250,26 @@ export function genCompletionProperty(prefix: string[] = []):(v: Variable | Para
251
250
  if (t.length) {
252
251
  prevalue = `${t.join('.')}.`;
253
252
  }
254
- const noChildType = isNoChildType(v.typeAnnotation.typeKey);
255
- const item = {
253
+ const hasChild = ['reference', 'generic'].includes(v.typeAnnotation.typeKind);
254
+ const cp = new CompletionProperty({
256
255
  expression: m || p,
256
+ noFurther: !hasChild,
257
257
  name: v.name,
258
258
  value: prevalue + v.name,
259
- };
260
259
 
261
- if (!noChildType) {
262
- nextFindTypeChild(v.typeAnnotation.typeKey, item, null, v);
263
- }
264
-
265
- const cp = new CompletionProperty(item);
266
- console.log(cp.value, v);
260
+ });
261
+ console.log(cp.value);
267
262
  cp.icon = v.concept;
263
+
264
+ if (hasChild) {
265
+ cp.children = [new CompletionProperty()];
266
+ }
268
267
  return cp;
269
268
  };
270
269
  }
271
270
 
272
- export function getPreviousTask(node: ProcessElement, nodePorcess?: Process) {
273
- const process = node.process || nodePorcess;
271
+ export function getPreviousTask(node: ProcessElement) {
272
+ const process = node.process;
274
273
  const elems = process.elements;
275
274
  const elements: ProcessElement[] = [];
276
275
  const visitedMap = new WeakMap();
@@ -296,20 +295,19 @@ export function getPreviousTask(node: ProcessElement, nodePorcess?: Process) {
296
295
  return elements;
297
296
  }
298
297
 
299
- export function getProcessVariableSuggestions(node: LogicItem, abandonConstant: boolean = false): CompletionProperty {
300
- // if (!node.processElement) {
301
- // return;
302
- // }
303
- //流程下的callback没有processElement
304
- const tempPorcessEle = new ProcessElement({});
305
- const processElem = node.processElement || tempPorcessEle;
298
+ export function getProcessVariableSuggestions(node: Logic, abandonConstant: boolean = false): CompletionProperty {
299
+ if (!node.processElement) {
300
+ return;
301
+ }
302
+ const processElem = node.processElement;
306
303
  const process = node.process;
307
304
 
308
- const elements: ProcessElement[] = getPreviousTask(processElem, process);
305
+ const elements: ProcessElement[] = getPreviousTask(processElem);
309
306
  const prevtasks = elements.map((us) => {
310
307
  const cp = new CompletionProperty({
311
308
  name: us.name,
312
309
  value: us.name,
310
+ noFurther: true,
313
311
  children: [
314
312
  ...us.returns.map(genCompletionProperty([process.name, us.name])),
315
313
  ...(abandonConstant ? [] : us.constants.map(genCompletionProperty([process.name, us.name]))),
@@ -323,6 +321,7 @@ export function getProcessVariableSuggestions(node: LogicItem, abandonConstant:
323
321
  const processVariables = new CompletionProperty({
324
322
  name: process.name,
325
323
  value: process.name,
324
+ noFurther: true,
326
325
  children: [
327
326
  ...process.params.map(genCompletionProperty([process.name])),
328
327
  ...process.returns.map(genCompletionProperty([process.name])),
@@ -336,6 +335,7 @@ export function getProcessVariableSuggestions(node: LogicItem, abandonConstant:
336
335
  name: processElem.name,
337
336
  value: processElem.name,
338
337
  icon: processElem.type,
338
+ noFurther: true,
339
339
  children: processElem.variables.map(genCompletionProperty([process.name, processElem.name])),
340
340
  });
341
341
  scopeVariable.isProcess = true;
@@ -344,33 +344,27 @@ export function getProcessVariableSuggestions(node: LogicItem, abandonConstant:
344
344
  }
345
345
 
346
346
  if (processElem.type === 'UserTask') {
347
- // 任务完成时可以拿到该任务的输出参数
348
- let returns: CompletionProperty[] = [];
349
- if (node.logic && node.logic.parentNode.name === 'OnClose') {
350
- returns = processElem.returns.map(genCompletionProperty([process.name, processElem.name]));
351
- }
352
347
  const scopeVariable = new CompletionProperty({
353
348
  name: processElem.name,
354
349
  value: processElem.name,
355
350
  icon: processElem.type,
356
- children: [
357
- ...returns,
358
- ...processElem.constants.map(genCompletionProperty([process.name, processElem.name])),
359
- ],
351
+ noFurther: true,
352
+ children: processElem.constants.map(genCompletionProperty([process.name, processElem.name])),
360
353
  });
361
354
  scopeVariable.isProcess = true;
362
355
  scopeVariable.icon = processElem.type;
363
356
  processVariables.children.push(scopeVariable);
364
357
  }
365
- if (processElem.type === 'AutoTask') {
358
+ if(processElem.type === 'AutoTask') {
366
359
  const scopeVariable = new CompletionProperty({
367
360
  name: processElem.name,
368
361
  value: processElem.name,
369
362
  icon: processElem.type,
363
+ noFurther: true,
370
364
  children: [
371
365
  ...processElem.variables.map(genCompletionProperty([process.name, processElem.name])),
372
366
  ...processElem.returns.map(genCompletionProperty([process.name, processElem.name])),
373
- ],
367
+ ]
374
368
  });
375
369
  scopeVariable.isProcess = true;
376
370
  scopeVariable.icon = processElem.type;
@@ -463,6 +457,7 @@ export function getProcessVariableSuggestionsAll(node: ProcessElement) {
463
457
  const cp = new CompletionProperty({
464
458
  name: us.name,
465
459
  value: us.name,
460
+ noFurther: true,
466
461
  children: [
467
462
  ...us.returns.map(node => deduceTypeAnnotation(app, node, node.typeAnnotation, [process.name, us.name], [])),
468
463
  ...us.constants.map(node => deduceTypeAnnotation(app, node, node.typeAnnotation, [process.name, us.name], [])),
@@ -477,6 +472,7 @@ export function getProcessVariableSuggestionsAll(node: ProcessElement) {
477
472
  const processVariables = new CompletionProperty({
478
473
  name: process.name,
479
474
  value: process.name,
475
+ noFurther: true,
480
476
  children: [
481
477
  ...process.params.map(node => deduceTypeAnnotation(app, node, node.typeAnnotation, [process.name], [])),
482
478
  ...process.returns.map(node => deduceTypeAnnotation(app, node, node.typeAnnotation, [process.name], [])),
@@ -491,6 +487,7 @@ export function getProcessVariableSuggestionsAll(node: ProcessElement) {
491
487
  name: processElem.name,
492
488
  value: processElem.name,
493
489
  icon: processElem.type,
490
+ noFurther: true,
494
491
  children: processElem.variables.map(node => deduceTypeAnnotation(app, node, node.typeAnnotation, [process.name, processElem.name], [])),
495
492
  });
496
493
  scopeVariable.expanded = true;
@@ -504,6 +501,7 @@ export function getProcessVariableSuggestionsAll(node: ProcessElement) {
504
501
  name: processElem.name,
505
502
  value: processElem.name,
506
503
  icon: processElem.type,
504
+ noFurther: true,
507
505
  children: processElem.constants.map(node => deduceTypeAnnotation(app, node, node.typeAnnotation, [process.name, processElem.name], [])),
508
506
  });
509
507
  scopeVariable.expanded = true;
@@ -516,6 +514,7 @@ export function getProcessVariableSuggestionsAll(node: ProcessElement) {
516
514
  name: processElem.name,
517
515
  value: processElem.name,
518
516
  icon: processElem.type,
517
+ noFurther: true,
519
518
  children: [
520
519
  ...processElem.variables.map(node => deduceTypeAnnotation(app, node, node.typeAnnotation, [process.name, processElem.name], [])),
521
520
  ...processElem.returns.map(node => deduceTypeAnnotation(app, node, node.typeAnnotation, [process.name, processElem.name], [])),
@@ -10,11 +10,9 @@ import {
10
10
  getGlobalVariableIdentifier,
11
11
  getLiteralsIdentifier,
12
12
  getSelectNextCompletionData,
13
- getCompletionDetailType,
14
13
  } from './getMemberIdentifier';
15
14
  import naslServer from './naslServer';
16
15
  import './extendBaseNode';
17
- import { getAllComponentEventMap } from './createUiTs';
18
16
 
19
17
  const server: any = {
20
18
  ...naslServer,
@@ -33,7 +31,5 @@ const server: any = {
33
31
  getEnumsIdentifier,
34
32
  getGlobalVariableIdentifier,
35
33
  getLiteralsIdentifier,
36
- getAllComponentEventMap,
37
- getCompletionDetailType,
38
34
  };
39
35
  export default server;
@@ -519,20 +519,7 @@ const naslServer = {
519
519
  // 先获取原来的节点先清除一下之前有异常的节点,下面重新赋值
520
520
  const oldRecord = diagnosticManager.getRecord(record.id);
521
521
  oldRecord?.semanticDiagnostics.forEach((item) => {
522
- if (item.node) {
523
- item.node.tsErrorDetail = undefined;
524
- // 如果logic中有报错就把标识置为true
525
- if ((item.node as any).logic) {
526
- (item.node as any).logic.haveError = false;
527
- }
528
- }
529
- });
530
-
531
- // 清空一些状态
532
- oldRecord?.suggestionDiagnostics.forEach((item) => {
533
- if (item.node && item.node instanceof Logic) {
534
- item.node.isSmpty = false;
535
- }
522
+ item.node ? (item.node.tsErrorDetail = undefined) : '';
536
523
  });
537
524
  // 语义诊断
538
525
  if (isChangeInterface) {
@@ -556,10 +543,11 @@ const naslServer = {
556
543
  // // logic在for循环中,不展示any提示
557
544
  // record.suggestionDiagnostics = record.suggestionDiagnostics.filter((item) => !item.text.includes(`implicitly has an 'any' type, but a better type may be inferred from usage.`));
558
545
  // }
559
- record.suggestionDiagnostics = record.suggestionDiagnostics
560
- .filter((item) => { return [`'$LogicEmpty' is declared but its value is never read.`].includes(item.text); })
561
- .map((diag) => this._resolveDiagnostic(diag as unknown as tsProtocol.DiagnosticWithFileName, node as FileNode))
562
- .filter((diag) => !!diag);
546
+ // record.suggestionDiagnostics = record.suggestionDiagnostics
547
+ // .map((diag) => this._resolveDiagnostic(diag as unknown as tsProtocol.DiagnosticWithFileName, node.sourceMap))
548
+ // .filter((diag) => !!diag);
549
+ record.suggestionDiagnostics = [];
550
+ // 语法诊断暂时不需要
563
551
  });
564
552
 
565
553
  return records;
@@ -1298,9 +1286,8 @@ const naslServer = {
1298
1286
  App.emit('collect:start', {
1299
1287
  actionMsg: '增加逻辑参数',
1300
1288
  });
1301
- const index = node.getIndexOfParent();
1302
1289
  node.create({
1303
- index,
1290
+ index: 0,
1304
1291
  parentNode: parantNode,
1305
1292
  parentKey: node.parentKey,
1306
1293
  });