@lcap/nasl 1.0.1 → 1.0.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 (173) hide show
  1. package/out/automate/engine/utils.js +16 -0
  2. package/out/automate/engine/utils.js.map +1 -1
  3. package/out/common/BaseNode.d.ts +1 -1
  4. package/out/common/BaseNode.js +13 -3
  5. package/out/common/BaseNode.js.map +1 -1
  6. package/out/concepts/App__.d.ts +1 -0
  7. package/out/concepts/App__.js +4 -1
  8. package/out/concepts/App__.js.map +1 -1
  9. package/out/concepts/Assignee__.d.ts +11 -0
  10. package/out/concepts/Assignee__.js +34 -0
  11. package/out/concepts/Assignee__.js.map +1 -1
  12. package/out/concepts/CallFunction__.js +1 -2
  13. package/out/concepts/CallFunction__.js.map +1 -1
  14. package/out/concepts/CallQueryComponent__.d.ts +31 -2
  15. package/out/concepts/CallQueryComponent__.js +286 -51
  16. package/out/concepts/CallQueryComponent__.js.map +1 -1
  17. package/out/concepts/Constant__.js +6 -6
  18. package/out/concepts/Constant__.js.map +1 -1
  19. package/out/concepts/Destination__.js +18 -4
  20. package/out/concepts/Destination__.js.map +1 -1
  21. package/out/concepts/EntityIndex__.js +4 -2
  22. package/out/concepts/EntityIndex__.js.map +1 -1
  23. package/out/concepts/EntityProperty__.js +3 -5
  24. package/out/concepts/EntityProperty__.js.map +1 -1
  25. package/out/concepts/Entity__.d.ts +1 -0
  26. package/out/concepts/Entity__.js +7 -1
  27. package/out/concepts/Entity__.js.map +1 -1
  28. package/out/concepts/Enum__.d.ts +1 -0
  29. package/out/concepts/Enum__.js +6 -2
  30. package/out/concepts/Enum__.js.map +1 -1
  31. package/out/concepts/Identifier__.js +1 -1
  32. package/out/concepts/Identifier__.js.map +1 -1
  33. package/out/concepts/InterfaceParam__.js +9 -4
  34. package/out/concepts/InterfaceParam__.js.map +1 -1
  35. package/out/concepts/Param__.d.ts +1 -1
  36. package/out/concepts/Param__.js +14 -7
  37. package/out/concepts/Param__.js.map +1 -1
  38. package/out/concepts/ProcessElement__.js +8 -2
  39. package/out/concepts/ProcessElement__.js.map +1 -1
  40. package/out/concepts/QueryAggregateExpression__.js +1 -1
  41. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  42. package/out/concepts/QueryFieldExpression__.d.ts +1 -0
  43. package/out/concepts/QueryFieldExpression__.js +3 -0
  44. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  45. package/out/concepts/QueryGroupByExpression__.d.ts +3 -0
  46. package/out/concepts/QueryGroupByExpression__.js +20 -0
  47. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  48. package/out/concepts/Return__.d.ts +1 -1
  49. package/out/concepts/Return__.js +15 -10
  50. package/out/concepts/Return__.js.map +1 -1
  51. package/out/concepts/StringLiteral__.js +1 -8
  52. package/out/concepts/StringLiteral__.js.map +1 -1
  53. package/out/concepts/StructureProperty__.js +5 -5
  54. package/out/concepts/StructureProperty__.js.map +1 -1
  55. package/out/concepts/TypeAnnotation__.js +12 -4
  56. package/out/concepts/TypeAnnotation__.js.map +1 -1
  57. package/out/concepts/Variable__.d.ts +1 -1
  58. package/out/concepts/Variable__.js +15 -10
  59. package/out/concepts/Variable__.js.map +1 -1
  60. package/out/concepts/ViewElement__.js +1 -1
  61. package/out/concepts/ViewElement__.js.map +1 -1
  62. package/out/concepts/View__.d.ts +1 -1
  63. package/out/concepts/View__.js +15 -4
  64. package/out/concepts/View__.js.map +1 -1
  65. package/out/concepts/basics/stdlib/nasl.configuration.js +1 -1
  66. package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
  67. package/out/concepts/basics/stdlib/nasl.interface.d.ts +2 -0
  68. package/out/concepts/basics/stdlib/nasl.interface.js +4 -4
  69. package/out/concepts/basics/stdlib/nasl.interface.js.map +1 -1
  70. package/out/concepts/basics/stdlib/nasl.util.js +21 -37
  71. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  72. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +1 -1
  73. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js.map +1 -1
  74. package/out/concepts/basics/types/index.d.ts +1 -0
  75. package/out/concepts/basics/types/index.js +3 -1
  76. package/out/concepts/basics/types/index.js.map +1 -1
  77. package/out/enums/KEYWORDS.js +0 -7
  78. package/out/enums/KEYWORDS.js.map +1 -1
  79. package/out/manager/diagnostic.d.ts +1 -1
  80. package/out/{test/integration/connect-file copy.d.ts → server/extendBaseNode.d.ts} +0 -0
  81. package/out/server/extendBaseNode.js +323 -0
  82. package/out/server/extendBaseNode.js.map +1 -0
  83. package/out/server/getLogics.js +22 -1
  84. package/out/server/getLogics.js.map +1 -1
  85. package/out/server/getMemberIdentifier.js +47 -2
  86. package/out/server/getMemberIdentifier.js.map +1 -1
  87. package/out/server/getProcesses.d.ts +4 -2
  88. package/out/server/getProcesses.js +160 -20
  89. package/out/server/getProcesses.js.map +1 -1
  90. package/out/server/getScope.d.ts +1 -0
  91. package/out/server/getScope.js +4 -0
  92. package/out/server/getScope.js.map +1 -1
  93. package/out/server/index.d.ts +1 -0
  94. package/out/server/index.js +1 -0
  95. package/out/server/index.js.map +1 -1
  96. package/out/server/naslServer.d.ts +7 -5
  97. package/out/server/naslServer.js +96 -362
  98. package/out/server/naslServer.js.map +1 -1
  99. package/out/server/translator.d.ts +1 -1
  100. package/out/server/translator.js +3 -1
  101. package/out/server/translator.js.map +1 -1
  102. package/out/service/storage/init.js +18 -10
  103. package/out/service/storage/init.js.map +1 -1
  104. package/out/templator/genGetBlock.js +1 -1
  105. package/out/templator/genGetBlock.js.map +1 -1
  106. package/out/templator/genQueryComponent.js +7 -4
  107. package/out/templator/genQueryComponent.js.map +1 -1
  108. package/out/templator/genSelectBlock.js +5 -15
  109. package/out/templator/genSelectBlock.js.map +1 -1
  110. package/out/templator/genUpdateBlock.js +1 -1
  111. package/out/templator/genUpdateBlock.js.map +1 -1
  112. package/out/templator/utils.d.ts +3 -1
  113. package/out/templator/utils.js +2 -1
  114. package/out/templator/utils.js.map +1 -1
  115. package/package.json +1 -2
  116. package/src/automate/engine/utils.js +16 -2
  117. package/src/common/BaseNode.ts +14 -3
  118. package/src/concepts/App__.ts +6 -39
  119. package/src/concepts/Assignee__.ts +30 -0
  120. package/src/concepts/CallFunction__.ts +1 -2
  121. package/src/concepts/CallQueryComponent__.ts +294 -54
  122. package/src/concepts/Constant__.ts +6 -6
  123. package/src/concepts/Destination__.ts +18 -20
  124. package/src/concepts/EntityIndex__.ts +4 -2
  125. package/src/concepts/EntityProperty__.ts +3 -5
  126. package/src/concepts/Entity__.ts +15 -3
  127. package/src/concepts/Enum__.ts +7 -15
  128. package/src/concepts/Identifier__.ts +1 -10
  129. package/src/concepts/InterfaceParam__.ts +9 -4
  130. package/src/concepts/Param__.ts +14 -7
  131. package/src/concepts/ProcessElement__.ts +9 -3
  132. package/src/concepts/QueryAggregateExpression__.ts +1 -1
  133. package/src/concepts/QueryFieldExpression__.ts +4 -0
  134. package/src/concepts/QueryGroupByExpression__.ts +23 -0
  135. package/src/concepts/Return__.ts +15 -10
  136. package/src/concepts/StringLiteral__.ts +1 -8
  137. package/src/concepts/StructureProperty__.ts +5 -5
  138. package/src/concepts/TypeAnnotation__.ts +12 -4
  139. package/src/concepts/Variable__.ts +15 -10
  140. package/src/concepts/ViewElement__.ts +2 -2
  141. package/src/concepts/View__.ts +16 -4
  142. package/src/concepts/basics/stdlib/nasl.configuration.ts +1 -1
  143. package/src/concepts/basics/stdlib/nasl.interface.ts +1 -1
  144. package/src/concepts/basics/stdlib/nasl.util.ts +21 -37
  145. package/src/concepts/basics/stdlib/reference2TypeAnnotationList.ts +1 -1
  146. package/src/concepts/basics/types/index.ts +1 -0
  147. package/src/enums/KEYWORDS.ts +0 -7
  148. package/src/manager/diagnostic.ts +1 -1
  149. package/src/server/extendBaseNode.ts +318 -0
  150. package/src/server/getLogics.ts +22 -1
  151. package/src/server/getMemberIdentifier.ts +49 -2
  152. package/src/server/getProcesses.ts +170 -21
  153. package/src/server/getScope.ts +5 -0
  154. package/src/server/index.ts +1 -0
  155. package/src/server/naslServer.ts +100 -355
  156. package/src/server/translator.ts +3 -1
  157. package/src/service/storage/init.ts +18 -11
  158. package/src/templator/genGetBlock.ts +1 -1
  159. package/src/templator/genQueryComponent.ts +7 -4
  160. package/src/templator/genSelectBlock.ts +5 -15
  161. package/src/templator/genUpdateBlock.ts +1 -1
  162. package/src/templator/utils.ts +3 -0
  163. package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +0 -3
  164. package/out/concepts/basics/stdlib/nasl.browser copy.js +0 -70
  165. package/out/concepts/basics/stdlib/nasl.browser copy.js.map +0 -1
  166. package/out/terms/LEVEL_NAME_MAP.d.ts +0 -26
  167. package/out/terms/LEVEL_NAME_MAP.js +0 -30
  168. package/out/terms/LEVEL_NAME_MAP.js.map +0 -1
  169. package/out/test/integration/connect-file copy.js +0 -50
  170. package/out/test/integration/connect-file copy.js.map +0 -1
  171. package/out/test/integration/node-nasl-server.d.ts +0 -1
  172. package/out/test/integration/node-nasl-server.js +0 -41
  173. package/out/test/integration/node-nasl-server.js.map +0 -1
@@ -125,10 +125,6 @@ export class Enum extends BaseNode {
125
125
  });
126
126
  }
127
127
 
128
-
129
-
130
-
131
-
132
128
  /**
133
129
  * 插入枚举项
134
130
  * @internal
@@ -161,8 +157,6 @@ export class Enum extends BaseNode {
161
157
  return enumItem;
162
158
  }
163
159
 
164
-
165
-
166
160
  /**
167
161
  * 插入枚举项
168
162
  * @param enumItemOptions 枚举项参数
@@ -185,8 +179,6 @@ export class Enum extends BaseNode {
185
179
  return node;
186
180
  }
187
181
 
188
-
189
-
190
182
  /**
191
183
  * 添加枚举项
192
184
  * @internal
@@ -206,8 +198,6 @@ export class Enum extends BaseNode {
206
198
  return this._insertEnumItemAt(options as any, index);
207
199
  }
208
200
 
209
-
210
-
211
201
  /**
212
202
  * 添加枚举项
213
203
  * @param enumItemOptions 枚举项参数
@@ -231,9 +221,6 @@ export class Enum extends BaseNode {
231
221
  return node;
232
222
  }
233
223
 
234
-
235
-
236
-
237
224
  /**
238
225
  * 删除枚举项
239
226
  * @param enumItem 已有的枚举项实例
@@ -241,7 +228,7 @@ export class Enum extends BaseNode {
241
228
  removeEnumItem(enumItem: EnumItem): void;
242
229
 
243
230
  removeEnumItem(options: EnumItem) {
244
- let enumItem: EnumItem = options;
231
+ const enumItem: EnumItem = options;
245
232
  return enumItem.delete();
246
233
  }
247
234
 
@@ -286,6 +273,11 @@ export class Enum extends BaseNode {
286
273
  @property()
287
274
  isLeaf: boolean = true;
288
275
 
276
+ getEnumItemExistingNames(excludedList: Array<EnumItem> = []) {
277
+ const excludedSet = new Set(excludedList);
278
+ return (this.enumItems || []).filter((item) => !excludedSet.has(item)).map((item) => item.value);
279
+ }
280
+
289
281
  @withSourceMap()
290
282
  toEmbeddedTS(state?: TranslatorState): string {
291
283
  let code = `export class ${this.name} extends nasl.core.Enums {\n`;
@@ -351,7 +343,7 @@ export class Enum extends BaseNode {
351
343
  //================================================================================
352
344
  }
353
345
 
354
- classMap['Enum'] = Enum;
346
+ classMap.Enum = Enum;
355
347
  export default Enum;
356
348
  //================================================================================
357
349
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -38,8 +38,6 @@ export class Identifier extends LogicItem {
38
38
  @property()
39
39
  name: string = undefined;
40
40
 
41
-
42
-
43
41
  /**
44
42
  * @param source 需要合并的部分参数
45
43
  */
@@ -53,13 +51,6 @@ export class Identifier extends LogicItem {
53
51
  return super.from(source, parentNode, parentKey) as Identifier;
54
52
  }
55
53
 
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
54
  //================================================================================
64
55
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
65
56
  // 自动生成的代码已结束。下面可以手动编写。
@@ -224,7 +215,7 @@ export class Identifier extends LogicItem {
224
215
  //================================================================================
225
216
  }
226
217
 
227
- classMap['Identifier'] = Identifier;
218
+ classMap.Identifier = Identifier;
228
219
  export default Identifier;
229
220
  //================================================================================
230
221
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -309,11 +309,16 @@ export class InterfaceParam extends BaseNode {
309
309
  completionChildren = properties;
310
310
  }
311
311
  } else if (typeKind === 'generic') {
312
- if (typeNamespace === 'nasl.collection') {
313
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
314
- const properties = node.properties || [];
315
- completionChildren = properties;
312
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
313
+ const properties = node.properties || [];
314
+ for (let i = 0; i < properties.length; i++) {
315
+ const item = properties[i];
316
+ if (item?.typeAnnotation?.typeKind === 'typeParam') {
317
+ properties[i].typeAnnotation = this?.typeAnnotation?.typeArguments[0];
318
+ properties[i].parentNode = this;
319
+ }
316
320
  }
321
+ completionChildren = properties;
317
322
  } else {
318
323
  completionChildren = undefined;
319
324
  }
@@ -305,7 +305,7 @@ export class Param extends BaseNode {
305
305
  typeAnnotation,
306
306
  };
307
307
  try {
308
- this.completionChildren = this.getSelectRef();
308
+ this.completionChildren = this.getSelectRef(typeAnnotation);
309
309
  } catch (err) {
310
310
  this.completionChildren = [];
311
311
  console.log(err);
@@ -350,9 +350,9 @@ export class Param extends BaseNode {
350
350
  get isTreeLeaf() {
351
351
  return !this.hasChildren;
352
352
  }
353
- getSelectRef() {
353
+ getSelectRef(newTypeAnnotation: TypeAnnotation) {
354
354
  try {
355
- const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
355
+ const { typeName, typeKind, typeNamespace } = newTypeAnnotation || this.typeAnnotation;
356
356
  let completionChildren;
357
357
  if (typeKind === 'reference') {
358
358
  if (typeNamespace === 'nasl.ui') {
@@ -367,11 +367,18 @@ export class Param extends BaseNode {
367
367
  completionChildren = properties;
368
368
  }
369
369
  } else if (typeKind === 'generic') {
370
- if (typeNamespace === 'nasl.collection') {
371
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
372
- const properties = node.properties || [];
373
- completionChildren = properties;
370
+ // if (typeNamespace === 'nasl.collection' || typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.interface') {
371
+ // }
372
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
373
+ const properties = node.properties || [];
374
+ for (let i = 0; i < properties.length; i++) {
375
+ const item = properties[i];
376
+ if (item?.typeAnnotation?.typeKind === 'typeParam') {
377
+ properties[i].typeAnnotation = this?.typeAnnotation?.typeArguments[0];
378
+ properties[i].parentNode = this;
379
+ }
374
380
  }
381
+ completionChildren = properties;
375
382
  } else {
376
383
  completionChildren = undefined;
377
384
  }
@@ -1348,7 +1348,8 @@ export class ProcessElement extends BaseNode {
1348
1348
  });
1349
1349
 
1350
1350
  if (this.type === 'UserTask'
1351
- || this.type === 'ExclusiveGateway') {
1351
+ || this.type === 'ExclusiveGateway'
1352
+ || this.type === 'AutoTask') {
1352
1353
  const prevTasks = getPreviousTask(this);
1353
1354
  let prevCode = `${tab3}const ${this.process.name} = {\n`;
1354
1355
  const processName = this.process.name;
@@ -1374,6 +1375,11 @@ export class ProcessElement extends BaseNode {
1374
1375
  if (attr.name === 'destination') {
1375
1376
  code += `${attr.destination.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: state.tabSize + 3 }), prevCode)},\n`;
1376
1377
  }
1378
+ if (attr.name === 'assignee') {
1379
+ code += `assignee: function(): string[] {\n`
1380
+ code += `${attr.assignee.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: state.tabSize + 3 }), prevCode)}\n`;
1381
+ code += `},\n`;
1382
+ }
1377
1383
  });
1378
1384
  const logic = genUserTaskLogic(this);
1379
1385
  // sourceMap 映射
@@ -1384,8 +1390,8 @@ export class ProcessElement extends BaseNode {
1384
1390
  code += `${tab1}}`;
1385
1391
  }
1386
1392
 
1387
- if (this.type === 'ExclusiveGateway') {
1388
- prevCode += `\n${tab5}${this.name}: elements.${this.name},\n`;
1393
+ if(this.type === 'ExclusiveGateway' || this.type === 'AutoTask') {
1394
+ prevCode += `\n${tab5}${this.name}: elements.${this.name},\n`
1389
1395
  prevCode += `${tab3}}\n`;
1390
1396
  code += `${tab1}logic: ${this.logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: state.tabSize + 3 }), prevCode, true)},`;
1391
1397
  }
@@ -138,7 +138,7 @@ export class QueryAggregateExpression extends LogicItem {
138
138
  // code += `[__EMPTY_AGGREGATE_NAME__, '']`;
139
139
 
140
140
  // return code;
141
- return `__${this.asName || '__EMPTY_AGGREGATE_ALIAS__'}`;
141
+ return `__${this.asName || 'EMPTY_AGGREGATE_ALIAS__'}`;
142
142
  }
143
143
 
144
144
  setName(asName: string) {
@@ -103,6 +103,10 @@ export class QueryFieldExpression extends LogicItem {
103
103
  };
104
104
  }
105
105
 
106
+ setName(asName: string) {
107
+ this.update({ asName });
108
+ }
109
+
106
110
  getValue() {
107
111
  const { entityAsName, propertyName } = this;
108
112
  return `${entityAsName}.${propertyName}`;
@@ -1,3 +1,7 @@
1
+ import { withSourceMap } from '../translator';
2
+ import type CallQueryComponent from './CallQueryComponent__';
3
+ import type QueryFieldExpression from './QueryFieldExpression__';
4
+
1
5
  //================================================================================
2
6
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
3
7
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -125,6 +129,25 @@ export class QueryGroupByExpression extends LogicItem {
125
129
  };
126
130
  }
127
131
 
132
+ setEntityAsName(name: string) {
133
+ (this.groupElement as QueryFieldExpression).setEntityAsName(name);
134
+ }
135
+
136
+ setPropertyName(name: string) {
137
+ (this.groupElement as QueryFieldExpression).setPropertyName(name);
138
+ }
139
+
140
+ @withSourceMap()
141
+ toEmbeddedTS(): string {
142
+ // 判断老应用
143
+ if ((this.parentNode as CallQueryComponent).isAutoInfer()) {
144
+ // 2.11版本后 分组使用别名
145
+ return `__${(this.groupElement as QueryFieldExpression).asName || 'EMPTY_GROUP_BY_ALIAS__'}`;
146
+ } else {
147
+ return (this.groupElement as QueryFieldExpression).toEmbeddedTS();
148
+ }
149
+ }
150
+
128
151
  //================================================================================
129
152
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
130
153
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -252,9 +252,9 @@ export class Return extends BaseNode {
252
252
  code += ': undefined as ';
253
253
  code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
254
254
  }
255
- if (this.defaultValue) {
256
- code += `: ${this.defaultValue}`;
257
- }
255
+ // if (this.defaultValue) {
256
+ // code += `: ${this.defaultValue}`;
257
+ // }
258
258
  return code;
259
259
  }
260
260
 
@@ -284,7 +284,7 @@ export class Return extends BaseNode {
284
284
  }
285
285
  // 处理下拉属性
286
286
  try {
287
- this.completionChildren = this.getSelectRef();
287
+ this.completionChildren = this.getSelectRef(typeAnnotation);
288
288
  } catch (err) {
289
289
  this.completionChildren = [];
290
290
  console.log(err);
@@ -327,9 +327,9 @@ export class Return extends BaseNode {
327
327
  get isTreeLeaf() {
328
328
  return !this.hasChildren;
329
329
  }
330
- getSelectRef() {
330
+ getSelectRef(newTypeAnnotation: TypeAnnotation) {
331
331
  try {
332
- const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
332
+ const { typeName, typeKind, typeNamespace } = newTypeAnnotation || this.typeAnnotation;
333
333
  let completionChildren;
334
334
  if (typeKind === 'reference') {
335
335
  if (typeNamespace === 'nasl.ui') {
@@ -344,11 +344,16 @@ export class Return extends BaseNode {
344
344
  completionChildren = properties;
345
345
  }
346
346
  } else if (typeKind === 'generic') {
347
- if (typeNamespace === 'nasl.collection') {
348
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
349
- const properties = node.properties || [];
350
- completionChildren = properties;
347
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
348
+ const properties = node.properties || [];
349
+ for (let i = 0; i < properties.length; i++) {
350
+ const item = properties[i];
351
+ if (item?.typeAnnotation?.typeKind === 'typeParam') {
352
+ properties[i].typeAnnotation = this?.typeAnnotation?.typeArguments[0];
353
+ properties[i].parentNode = this;
354
+ }
351
355
  }
356
+ completionChildren = properties;
352
357
  } else {
353
358
  completionChildren = undefined;
354
359
  }
@@ -94,14 +94,7 @@ export class StringLiteral extends LogicItem {
94
94
  toEmbeddedTS(state?: TranslatorState, isRequired?: boolean): string {
95
95
  let code = '';
96
96
  if (typeof this.value === 'string') {
97
- if (!this.value.includes("'"))
98
- code += `'${this.value}'`;
99
- else if (!this.value.includes('"'))
100
- code += `"${this.value}"`;
101
- else if (!this.value.includes('`'))
102
- code += `\`${this.value}\``;
103
- else
104
- code += `'${this.value.replace(/'/g, "\\'")}'`;
97
+ code += `'StringLiteral'`;
105
98
  } else {
106
99
  code += isRequired ? '__IDENTIFIER__' : `''`;
107
100
  }
@@ -263,11 +263,11 @@ export class StructureProperty extends BaseNode {
263
263
  completionChildren = properties;
264
264
  }
265
265
  } else if (typeKind === 'generic') {
266
- if (typeNamespace === 'nasl.collection') {
267
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
268
- const properties = node.properties || [];
269
- completionChildren = properties;
270
- }
266
+ // if (typeNamespace === 'nasl.collection' || typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.interface') {
267
+ // }
268
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
269
+ const properties = node.properties || [];
270
+ completionChildren = properties;
271
271
  } else {
272
272
  completionChildren = undefined;
273
273
  }
@@ -267,10 +267,18 @@ export class TypeAnnotation extends BaseNode {
267
267
  } else if (this.typeKind === 'reference') {
268
268
  return `${this.typeName}`;
269
269
  } else if (this.typeKind === 'generic') {
270
- if (this.typeArguments && this.typeArguments.length)
271
- return `${this.typeName}<${(this.typeArguments || []).map((arg) => arg.typeName || 'T')}>`;
272
- else
273
- return this.typeName;
270
+ let str = `${this.typeName}`;
271
+ const loop = (typeArguments: Array<TypeAnnotation>) => {
272
+ str += '<' + (typeArguments[0].typeName || 'T');
273
+ if (typeArguments[0].typeKind === 'generic') {
274
+ if (this.typeArguments && this.typeArguments.length) {
275
+ loop(typeArguments[0].typeArguments);
276
+ }
277
+ }
278
+ str += '>';
279
+ };
280
+ loop(this.typeArguments);
281
+ return str;
274
282
  } else {
275
283
  return this.typeName;
276
284
  }
@@ -253,9 +253,9 @@ export class Variable extends BaseNode {
253
253
  code += ': undefined as ';
254
254
  code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
255
255
  }
256
- if (this.defaultValue) {
257
- code += `: ${this.defaultValue}`;
258
- }
256
+ // if (this.defaultValue) {
257
+ // code += `: ${this.defaultValue}`;
258
+ // }
259
259
  return code;
260
260
  }
261
261
 
@@ -281,7 +281,7 @@ export class Variable extends BaseNode {
281
281
  }
282
282
  // 处理下拉属性
283
283
  try {
284
- this.completionChildren = this.getSelectRef();
284
+ this.completionChildren = this.getSelectRef(typeAnnotation);
285
285
  } catch (err) {
286
286
  this.completionChildren = [];
287
287
  console.log(err);
@@ -324,9 +324,9 @@ export class Variable extends BaseNode {
324
324
  get isTreeLeaf() {
325
325
  return !this.hasChildren;
326
326
  }
327
- getSelectRef() {
327
+ getSelectRef(newTypeAnnotation: TypeAnnotation) {
328
328
  try {
329
- const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
329
+ const { typeName, typeKind, typeNamespace } = newTypeAnnotation || this.typeAnnotation;
330
330
  let completionChildren;
331
331
  if (typeKind === 'reference') {
332
332
  if (typeNamespace === 'nasl.ui') {
@@ -341,11 +341,16 @@ export class Variable extends BaseNode {
341
341
  completionChildren = properties;
342
342
  }
343
343
  } else if (typeKind === 'generic') {
344
- if (typeNamespace === 'nasl.collection') {
345
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
346
- const properties = node.properties || [];
347
- completionChildren = properties;
344
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
345
+ const properties = node.properties || [];
346
+ for (let i = 0; i < properties.length; i++) {
347
+ const item = properties[i];
348
+ if (item?.typeAnnotation?.typeKind === 'typeParam') {
349
+ properties[i].typeAnnotation = this?.typeAnnotation?.typeArguments[0];
350
+ properties[i].parentNode = this;
351
+ }
348
352
  }
353
+ completionChildren = properties;
349
354
  } else {
350
355
  completionChildren = undefined;
351
356
  }
@@ -864,7 +864,7 @@ export class ViewElement extends BaseNode {
864
864
  }
865
865
 
866
866
 
867
-
867
+
868
868
 
869
869
  /**
870
870
  * 删除元素绑定属性
@@ -1120,7 +1120,7 @@ export class ViewElement extends BaseNode {
1120
1120
 
1121
1121
  haveScope(node: ViewElement): boolean {
1122
1122
  // uGallery 没有子集不需要scope
1123
- const dataSourcePcList = ['uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect'];
1123
+ const dataSourcePcList = ['uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect', 'devopsDragTable'];
1124
1124
  const dataSourceH5List = ['vanRadioGroup', 'vanCheckboxGroup', 'vanListView', 'vanGridView', 'vanForComponents', 'lcapEchartsLine', 'lcapEchartsBar', 'lcapEchartsPie'];
1125
1125
  const dataSourceList = [...dataSourcePcList, ...dataSourceH5List];
1126
1126
  return dataSourceList.includes(node.toHump(node.tag));
@@ -654,10 +654,6 @@ export class View extends BaseNode {
654
654
  }
655
655
 
656
656
 
657
- getLogicExistingNames(excludedList: Array<Logic> = []) {
658
- const excludedSet = new Set(excludedList);
659
- return (this.logics || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
660
- }
661
657
  getLogicUniqueName(name = 'logic1') {
662
658
  return utils.unique(name, this.getLogicExistingNames(), undefined, false);
663
659
  }
@@ -1545,6 +1541,21 @@ export class View extends BaseNode {
1545
1541
  this.emit('change', $event);
1546
1542
  }
1547
1543
 
1544
+ getLogicExistingNames(excludedList: Array<Logic> = []) {
1545
+ const excludedSet = new Set(excludedList);
1546
+ const varList: any[] = [];
1547
+ if (Array.isArray(this.params)) {
1548
+ varList.push(...this.params);
1549
+ }
1550
+ if (Array.isArray(this.variables)) {
1551
+ varList.push(...this.variables);
1552
+ }
1553
+ if (Array.isArray(this.logics)) {
1554
+ varList.push(...this.logics);
1555
+ }
1556
+ return varList.filter((item) => !excludedSet.has(item)).map((item) => item.name);
1557
+ }
1558
+
1548
1559
  getVarExistingNames(excludedList: Array<Param | Variable> = []) {
1549
1560
  const excludedSet = new Set(excludedList);
1550
1561
  const varList: any[] = [];
@@ -1556,6 +1567,7 @@ export class View extends BaseNode {
1556
1567
  }
1557
1568
  if (Array.isArray(this.logics)) {
1558
1569
  this.logics.forEach((logic) => {
1570
+ varList.push(logic);
1559
1571
  if (Array.isArray(logic.params)) {
1560
1572
  varList.push(...logic.params);
1561
1573
  }
@@ -8,7 +8,7 @@ export default new Namespace({
8
8
  name: 'configuration',
9
9
  logics: [
10
10
  new Logic({
11
- name: 'getConfig',
11
+ name: 'getCustomConfig',
12
12
  params: [
13
13
  new Param({
14
14
  name: 'name',
@@ -10,7 +10,7 @@ import { primitiveTypeList } from '../types/coreTypeList';
10
10
  import { reference2TypeAnnotationList } from './reference2TypeAnnotationList';
11
11
  import TypeParam from '../../TypeParam__';
12
12
 
13
- const interfaceStructures = [
13
+ export const interfaceStructures = [
14
14
  new Structure({
15
15
  name: 'ApiReturnOf',
16
16
  typeParams: [
@@ -718,51 +718,35 @@ export default new Namespace({
718
718
  ],
719
719
  }),
720
720
  new Function({
721
- name: 'GetProperties',
722
- description: '获取应用配置参数',
721
+ name: 'CreatePageOf',
722
+ description: '将List<T>集合转换为分页集合PageOf<T>',
723
723
  params: [
724
724
  new Param({
725
- name: 'name',
726
- typeAnnotation: TypeAnnotation.createPrimitive('String'),
727
- useComponent: { type: 's-config-select' },
725
+ name: 'list',
726
+ typeAnnotation: TypeAnnotation.createGeneric('List', {
727
+ typeArguments: [TypeAnnotation.createTypeParam('T')],
728
+ }),
729
+ }),
730
+ new Param({
731
+ name: 'page',
732
+ typeAnnotation: TypeAnnotation.createPrimitive('Integer'),
733
+ }),
734
+ new Param({
735
+ name: 'size',
736
+ typeAnnotation: TypeAnnotation.createPrimitive('Integer'),
737
+ }),
738
+ new Param({
739
+ name: 'total',
740
+ typeAnnotation: TypeAnnotation.createPrimitive('Integer'),
728
741
  }),
729
742
  ],
730
743
  returns: [
731
744
  new Return({
732
- typeAnnotation: TypeAnnotation.createPrimitive('String'),
745
+ typeAnnotation: TypeAnnotation.createPrimitive('PageOf', {
746
+ typeArguments: [TypeAnnotation.createTypeParam('T')],
747
+ }),
733
748
  }),
734
749
  ],
735
750
  }),
736
- // new Function({
737
- // name: 'CreatePageOf',
738
- // description: '将List<T>集合转换为分页集合PageOf<T>',
739
- // params: [
740
- // new Param({
741
- // name: 'list',
742
- // typeAnnotation: TypeAnnotation.createGeneric('List', {
743
- // typeArguments: [TypeAnnotation.createTypeParam('T')],
744
- // }),
745
- // }),
746
- // new Param({
747
- // name: 'page',
748
- // typeAnnotation: TypeAnnotation.createPrimitive('Integer'),
749
- // }),
750
- // new Param({
751
- // name: 'size',
752
- // typeAnnotation: TypeAnnotation.createPrimitive('Integer'),
753
- // }),
754
- // new Param({
755
- // name: 'total',
756
- // typeAnnotation: TypeAnnotation.createPrimitive('Integer'),
757
- // }),
758
- // ],
759
- // returns: [
760
- // new Return({
761
- // typeAnnotation: TypeAnnotation.createPrimitive('PageOf', {
762
- // typeArguments: [TypeAnnotation.createTypeParam('T')],
763
- // }),
764
- // }),
765
- // ],
766
- // }),
767
751
  ],
768
752
  });
@@ -9,7 +9,7 @@ import Enum from '../../Enum__';
9
9
  import TypeAnnotation from '../../TypeAnnotation__';
10
10
  import { primitiveTypeList } from '../types/coreTypeList';
11
11
 
12
- export function reference2TypeAnnotationList(list: Array<Entity | Structure | Enum>, namespace: string) {
12
+ export function reference2TypeAnnotationList(list: Array<Entity | Structure | Enum> = [], namespace: string) {
13
13
  return list.map((item) => {
14
14
  if (item instanceof Structure && item.typeParams?.length > 0) {
15
15
  return TypeAnnotation.createReference(item.name, {
@@ -18,3 +18,4 @@ primitiveTypeList.forEach((typeAnnotation) => {
18
18
  export { collectionStructures, collectionTypeList } from '../stdlib/nasl.collection';
19
19
  export { uiStructures, uiTypeList } from '../stdlib/nasl.ui';
20
20
  export { interfaceTypeList } from '../stdlib/nasl.interface';
21
+ export { interfaceStructures } from '../stdlib/nasl.interface';
@@ -789,7 +789,6 @@ export const ENTITY_KEYWORDS = [
789
789
  'PROTECTED',
790
790
  'PUBLIC',
791
791
  'PURGE',
792
- 'Page',
793
792
  'Pageable',
794
793
  'PaginationUtil',
795
794
  'PutMapping',
@@ -912,14 +911,12 @@ export const ENTITY_KEYWORDS = [
912
911
  'SHUTDOWN',
913
912
  'SIGNAL',
914
913
  'SIMILAR',
915
- 'SIZE',
916
914
  'SKIP',
917
915
  'SKIP_UNUSABLE_INDEXES',
918
916
  'SLOW',
919
917
  'SMALLINT',
920
918
  'SNAPSHOT',
921
919
  'SOME',
922
- 'SORT',
923
920
  'SPATIAL',
924
921
  'SPECIFIC',
925
922
  'SPECIFICATION',
@@ -1197,8 +1194,4 @@ export const ENTITY_PROPERTY_KEYWORDS = [
1197
1194
  'PUBLIC',
1198
1195
  'STATIC',
1199
1196
  'YIELD',
1200
- 'SIZE',
1201
- 'SORT',
1202
- 'CODE',
1203
- 'PAGE',
1204
1197
  ];
@@ -10,7 +10,7 @@ import * as tsProtocol from 'typescript/lib/protocol';
10
10
  export interface Diagnostic {
11
11
  id?: string;
12
12
  severity: string;
13
- originalDiagnostic: tsProtocol.DiagnosticWithFileName;
13
+ originalDiagnostic?: tsProtocol.DiagnosticWithFileName;
14
14
  message?: string;
15
15
  code?: number;
16
16
  node?: BaseNode;