@lcap/nasl 1.0.2 → 2.12.0

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 (299) hide show
  1. package/out/automate/engine/index.d.ts +1 -0
  2. package/out/automate/engine/index.js +34 -12
  3. package/out/automate/engine/index.js.map +1 -1
  4. package/out/automate/engine/operators.d.ts +10 -2
  5. package/out/automate/engine/operators.js +105 -7
  6. package/out/automate/engine/operators.js.map +1 -1
  7. package/out/automate/engine/uniqueName.d.ts +8 -2
  8. package/out/automate/engine/uniqueName.js +72 -4
  9. package/out/automate/engine/uniqueName.js.map +1 -1
  10. package/out/automate/engine/utils.d.ts +1 -0
  11. package/out/automate/engine/utils.js +92 -67
  12. package/out/automate/engine/utils.js.map +1 -1
  13. package/out/automate/template/process.d.ts +9 -0
  14. package/out/automate/template/process.js +10976 -0
  15. package/out/automate/template/process.js.map +1 -0
  16. package/out/bak/translator.js +1 -0
  17. package/out/bak/translator.js.map +1 -1
  18. package/out/common/BaseNode.d.ts +5 -0
  19. package/out/common/BaseNode.js +24 -3
  20. package/out/common/BaseNode.js.map +1 -1
  21. package/out/concepts/App__.d.ts +51 -49
  22. package/out/concepts/App__.js +86 -53
  23. package/out/concepts/App__.js.map +1 -1
  24. package/out/concepts/BindAttribute__.js +2 -2
  25. package/out/concepts/BindAttribute__.js.map +1 -1
  26. package/out/concepts/BindDirective__.js +10 -3
  27. package/out/concepts/BindDirective__.js.map +1 -1
  28. package/out/concepts/BindEvent__.js +15 -6
  29. package/out/concepts/BindEvent__.js.map +1 -1
  30. package/out/concepts/BooleanLiteral__.d.ts +4 -0
  31. package/out/concepts/BooleanLiteral__.js +11 -0
  32. package/out/concepts/BooleanLiteral__.js.map +1 -1
  33. package/out/concepts/CallFunction__.js +8 -2
  34. package/out/concepts/CallFunction__.js.map +1 -1
  35. package/out/concepts/CallLogic__.js +48 -30
  36. package/out/concepts/CallLogic__.js.map +1 -1
  37. package/out/concepts/CallQueryComponent__.d.ts +8 -7
  38. package/out/concepts/CallQueryComponent__.js +86 -76
  39. package/out/concepts/CallQueryComponent__.js.map +1 -1
  40. package/out/concepts/Comment__.js +1 -1
  41. package/out/concepts/Comment__.js.map +1 -1
  42. package/out/concepts/ConfigGroup__.d.ts +1 -0
  43. package/out/concepts/ConfigGroup__.js +7 -0
  44. package/out/concepts/ConfigGroup__.js.map +1 -1
  45. package/out/concepts/ConfigProperty__.d.ts +1 -0
  46. package/out/concepts/ConfigProperty__.js +3 -0
  47. package/out/concepts/ConfigProperty__.js.map +1 -1
  48. package/out/concepts/Configuration__.d.ts +1 -0
  49. package/out/concepts/Configuration__.js +3 -0
  50. package/out/concepts/Configuration__.js.map +1 -1
  51. package/out/concepts/DataSource__.d.ts +143 -0
  52. package/out/concepts/DataSource__.js +318 -0
  53. package/out/concepts/DataSource__.js.map +1 -0
  54. package/out/concepts/Destination__.js +8 -8
  55. package/out/concepts/Destination__.js.map +1 -1
  56. package/out/concepts/End__.js +2 -2
  57. package/out/concepts/End__.js.map +1 -1
  58. package/out/concepts/EntityIndex__.d.ts +5 -0
  59. package/out/concepts/EntityIndex__.js +6 -0
  60. package/out/concepts/EntityIndex__.js.map +1 -1
  61. package/out/concepts/EntityProperty__.d.ts +9 -0
  62. package/out/concepts/EntityProperty__.js +19 -2
  63. package/out/concepts/EntityProperty__.js.map +1 -1
  64. package/out/concepts/Entity__.d.ts +5 -0
  65. package/out/concepts/Entity__.js +20 -10
  66. package/out/concepts/Entity__.js.map +1 -1
  67. package/out/concepts/Enum__.js +12 -6
  68. package/out/concepts/Enum__.js.map +1 -1
  69. package/out/concepts/ForEachStatement__.js +2 -2
  70. package/out/concepts/ForEachStatement__.js.map +1 -1
  71. package/out/concepts/Function__.d.ts +18 -0
  72. package/out/concepts/Function__.js +96 -1
  73. package/out/concepts/Function__.js.map +1 -1
  74. package/out/concepts/Identifier__.js +6 -15
  75. package/out/concepts/Identifier__.js.map +1 -1
  76. package/out/concepts/IfStatement__.js +8 -8
  77. package/out/concepts/IfStatement__.js.map +1 -1
  78. package/out/concepts/Interface__.js +19 -12
  79. package/out/concepts/Interface__.js.map +1 -1
  80. package/out/concepts/JSBlock__.js +3 -5
  81. package/out/concepts/JSBlock__.js.map +1 -1
  82. package/out/concepts/Logic__.js +44 -44
  83. package/out/concepts/Logic__.js.map +1 -1
  84. package/out/concepts/Module__.d.ts +116 -194
  85. package/out/concepts/Module__.js +31 -114
  86. package/out/concepts/Module__.js.map +1 -1
  87. package/out/concepts/Namespace__.d.ts +0 -86
  88. package/out/concepts/Namespace__.js +1 -108
  89. package/out/concepts/Namespace__.js.map +1 -1
  90. package/out/concepts/Param__.d.ts +2 -1
  91. package/out/concepts/Param__.js +1 -1
  92. package/out/concepts/Param__.js.map +1 -1
  93. package/out/concepts/ProcessElement__.js +30 -10
  94. package/out/concepts/ProcessElement__.js.map +1 -1
  95. package/out/concepts/Process__.d.ts +1 -1
  96. package/out/concepts/Process__.js +17 -10
  97. package/out/concepts/Process__.js.map +1 -1
  98. package/out/concepts/QueryFieldExpression__.js +8 -1
  99. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  100. package/out/concepts/QueryFromExpression__.d.ts +4 -0
  101. package/out/concepts/QueryFromExpression__.js +13 -2
  102. package/out/concepts/QueryFromExpression__.js.map +1 -1
  103. package/out/concepts/QueryJoinExpression__.d.ts +4 -0
  104. package/out/concepts/QueryJoinExpression__.js +14 -3
  105. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  106. package/out/concepts/Return__.js +1 -1
  107. package/out/concepts/Return__.js.map +1 -1
  108. package/out/concepts/Role__.js +10 -3
  109. package/out/concepts/Role__.js.map +1 -1
  110. package/out/concepts/SqlQueryComponent__.d.ts +14 -0
  111. package/out/concepts/SqlQueryComponent__.js +48 -5
  112. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  113. package/out/concepts/StringLiteral__.d.ts +1 -1
  114. package/out/concepts/StringLiteral__.js +1 -1
  115. package/out/concepts/StructureProperty__.js +6 -5
  116. package/out/concepts/StructureProperty__.js.map +1 -1
  117. package/out/concepts/Structure__.js +19 -12
  118. package/out/concepts/Structure__.js.map +1 -1
  119. package/out/concepts/SwitchCase__.d.ts +1 -1
  120. package/out/concepts/SwitchCase__.js +23 -25
  121. package/out/concepts/SwitchCase__.js.map +1 -1
  122. package/out/concepts/SwitchStatement__.js +1 -6
  123. package/out/concepts/SwitchStatement__.js.map +1 -1
  124. package/out/concepts/TypeAnnotation__.d.ts +8 -0
  125. package/out/concepts/TypeAnnotation__.js +44 -2
  126. package/out/concepts/TypeAnnotation__.js.map +1 -1
  127. package/out/concepts/Variable__.js +1 -1
  128. package/out/concepts/Variable__.js.map +1 -1
  129. package/out/concepts/ViewElement__.js +25 -20
  130. package/out/concepts/ViewElement__.js.map +1 -1
  131. package/out/concepts/View__.d.ts +0 -2
  132. package/out/concepts/View__.js +27 -32
  133. package/out/concepts/View__.js.map +1 -1
  134. package/out/concepts/WhileStatement__.js +4 -4
  135. package/out/concepts/WhileStatement__.js.map +1 -1
  136. package/out/concepts/basics/stdlib/nasl.auth.js +20 -0
  137. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
  138. package/out/concepts/basics/stdlib/nasl.process.d.ts +4 -0
  139. package/out/concepts/basics/stdlib/nasl.process.js +410 -0
  140. package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
  141. package/out/concepts/basics/stdlib/nasl.ui.js +1 -11
  142. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  143. package/out/concepts/basics/stdlib/nasl.util.js +280 -2
  144. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  145. package/out/concepts/basics/types/index.d.ts +1 -0
  146. package/out/concepts/basics/types/index.js +4 -1
  147. package/out/concepts/basics/types/index.js.map +1 -1
  148. package/out/concepts/index__.d.ts +1 -0
  149. package/out/concepts/index__.js +1 -0
  150. package/out/concepts/index__.js.map +1 -1
  151. package/out/generator/genBundleFiles.d.ts +3 -1
  152. package/out/generator/genBundleFiles.js +23 -5
  153. package/out/generator/genBundleFiles.js.map +1 -1
  154. package/out/generator/genMetaData.d.ts +1 -0
  155. package/out/generator/genMetaData.js +20 -12
  156. package/out/generator/genMetaData.js.map +1 -1
  157. package/out/index.d.ts +1 -1
  158. package/out/index.js +2 -1
  159. package/out/index.js.map +1 -1
  160. package/out/server/createUiTs.js +1 -0
  161. package/out/server/createUiTs.js.map +1 -1
  162. package/out/server/getLogics.js +27 -1
  163. package/out/server/getLogics.js.map +1 -1
  164. package/out/server/getMemberIdentifier.js +5 -0
  165. package/out/server/getMemberIdentifier.js.map +1 -1
  166. package/out/server/getProcesses.d.ts +4 -0
  167. package/out/server/getProcesses.js +69 -1
  168. package/out/server/getProcesses.js.map +1 -1
  169. package/out/server/naslServer.d.ts +1 -0
  170. package/out/server/naslServer.js +223 -26
  171. package/out/server/naslServer.js.map +1 -1
  172. package/out/server/process2LogicNamespace.js +10 -1
  173. package/out/server/process2LogicNamespace.js.map +1 -1
  174. package/out/server/translator.js +37 -1
  175. package/out/server/translator.js.map +1 -1
  176. package/out/service/creator/errHandles.js +5 -0
  177. package/out/service/creator/errHandles.js.map +1 -1
  178. package/out/service/storage/init.d.ts +1 -0
  179. package/out/service/storage/init.js +95 -84
  180. package/out/service/storage/init.js.map +1 -1
  181. package/out/templator/genCreateBlock.js +34 -24
  182. package/out/templator/genCreateBlock.js.map +1 -1
  183. package/out/templator/genCurdEditMultipleKeyBlock.js +28 -18
  184. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  185. package/out/templator/genCurdMultipleKeyBlock.js +45 -29
  186. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  187. package/out/templator/genEditTableBlock.js +15 -13
  188. package/out/templator/genEditTableBlock.js.map +1 -1
  189. package/out/templator/genEnumSelectBlock.js +1 -1
  190. package/out/templator/genEnumSelectBlock.js.map +1 -1
  191. package/out/templator/genGridViewBlock.js +29 -24
  192. package/out/templator/genGridViewBlock.js.map +1 -1
  193. package/out/templator/genListViewBlock.js +7 -5
  194. package/out/templator/genListViewBlock.js.map +1 -1
  195. package/out/templator/genQueryComponent.js +25 -26
  196. package/out/templator/genQueryComponent.js.map +1 -1
  197. package/out/templator/genSelectBlock.js +8 -7
  198. package/out/templator/genSelectBlock.js.map +1 -1
  199. package/out/templator/genTableBlock.js +31 -21
  200. package/out/templator/genTableBlock.js.map +1 -1
  201. package/out/templator/genUpdateBlock.js +34 -24
  202. package/out/templator/genUpdateBlock.js.map +1 -1
  203. package/out/templator/utils.d.ts +2 -2
  204. package/out/templator/utils.js.map +1 -1
  205. package/out/test/integration/connect-file.js +6 -6
  206. package/out/test/integration/connect-file.js.map +1 -1
  207. package/out/translator/index.js +1 -1
  208. package/out/translator/index.js.map +1 -1
  209. package/out/utils/index.d.ts +5 -0
  210. package/out/utils/index.js +50 -1
  211. package/out/utils/index.js.map +1 -1
  212. package/package.json +1 -1
  213. package/src/automate/engine/index.js +33 -8
  214. package/src/automate/engine/operators.js +114 -17
  215. package/src/automate/engine/uniqueName.js +77 -9
  216. package/src/automate/engine/utils.js +95 -68
  217. package/src/automate/template/process.js +10999 -0
  218. package/src/bak/translator.js +1 -0
  219. package/src/common/BaseNode.ts +21 -4
  220. package/src/concepts/App__.ts +128 -94
  221. package/src/concepts/BindAttribute__.ts +2 -2
  222. package/src/concepts/BindDirective__.ts +9 -7
  223. package/src/concepts/BindEvent__.ts +14 -6
  224. package/src/concepts/BooleanLiteral__.ts +12 -0
  225. package/src/concepts/CallFunction__.ts +6 -2
  226. package/src/concepts/CallLogic__.ts +47 -32
  227. package/src/concepts/CallQueryComponent__.ts +92 -81
  228. package/src/concepts/Comment__.ts +1 -1
  229. package/src/concepts/ConfigGroup__.ts +3 -1
  230. package/src/concepts/ConfigProperty__.ts +4 -0
  231. package/src/concepts/Configuration__.ts +3 -0
  232. package/src/concepts/DataSource__.ts +391 -0
  233. package/src/concepts/Destination__.ts +24 -8
  234. package/src/concepts/End__.ts +2 -2
  235. package/src/concepts/EntityIndex__.ts +7 -0
  236. package/src/concepts/EntityProperty__.ts +20 -2
  237. package/src/concepts/Entity__.ts +23 -11
  238. package/src/concepts/Enum__.ts +25 -6
  239. package/src/concepts/ForEachStatement__.ts +2 -2
  240. package/src/concepts/Function__.ts +95 -1
  241. package/src/concepts/Identifier__.ts +15 -15
  242. package/src/concepts/IfStatement__.ts +9 -9
  243. package/src/concepts/Interface__.ts +20 -12
  244. package/src/concepts/JSBlock__.ts +3 -12
  245. package/src/concepts/Logic__.ts +45 -79
  246. package/src/concepts/Module__.ts +141 -342
  247. package/src/concepts/Namespace__.ts +1 -204
  248. package/src/concepts/Param__.ts +3 -2
  249. package/src/concepts/ProcessElement__.ts +33 -12
  250. package/src/concepts/Process__.ts +18 -12
  251. package/src/concepts/QueryFieldExpression__.ts +9 -1
  252. package/src/concepts/QueryFromExpression__.ts +13 -2
  253. package/src/concepts/QueryJoinExpression__.ts +14 -3
  254. package/src/concepts/Return__.ts +1 -1
  255. package/src/concepts/Role__.ts +10 -4
  256. package/src/concepts/SqlQueryComponent__.ts +47 -11
  257. package/src/concepts/StringLiteral__.ts +1 -1
  258. package/src/concepts/StructureProperty__.ts +6 -9
  259. package/src/concepts/Structure__.ts +19 -11
  260. package/src/concepts/SwitchCase__.ts +23 -27
  261. package/src/concepts/SwitchStatement__.ts +1 -5
  262. package/src/concepts/TypeAnnotation__.ts +43 -2
  263. package/src/concepts/Variable__.ts +1 -1
  264. package/src/concepts/ViewElement__.ts +26 -39
  265. package/src/concepts/View__.ts +29 -34
  266. package/src/concepts/WhileStatement__.ts +4 -4
  267. package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
  268. package/src/concepts/basics/stdlib/nasl.process.ts +406 -0
  269. package/src/concepts/basics/stdlib/nasl.ui.ts +1 -11
  270. package/src/concepts/basics/stdlib/nasl.util.ts +281 -2
  271. package/src/concepts/basics/types/index.ts +1 -0
  272. package/src/concepts/index__.ts +1 -0
  273. package/src/generator/genBundleFiles.ts +28 -7
  274. package/src/generator/genMetaData.ts +22 -13
  275. package/src/index.ts +1 -1
  276. package/src/server/createUiTs.ts +1 -0
  277. package/src/server/getLogics.ts +29 -4
  278. package/src/server/getMemberIdentifier.ts +4 -0
  279. package/src/server/getProcesses.ts +68 -0
  280. package/src/server/naslServer.ts +227 -30
  281. package/src/server/process2LogicNamespace.ts +29 -19
  282. package/src/server/translator.ts +39 -1
  283. package/src/service/creator/errHandles.js +6 -0
  284. package/src/service/storage/init.ts +97 -86
  285. package/src/templator/genCreateBlock.ts +35 -26
  286. package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -21
  287. package/src/templator/genCurdMultipleKeyBlock.ts +46 -31
  288. package/src/templator/genEditTableBlock.ts +17 -14
  289. package/src/templator/genEnumSelectBlock.ts +1 -1
  290. package/src/templator/genGridViewBlock.ts +30 -25
  291. package/src/templator/genListViewBlock.ts +10 -7
  292. package/src/templator/genQueryComponent.ts +28 -27
  293. package/src/templator/genSelectBlock.ts +9 -8
  294. package/src/templator/genTableBlock.ts +32 -23
  295. package/src/templator/genUpdateBlock.ts +35 -25
  296. package/src/templator/utils.ts +2 -2
  297. package/src/test/integration/connect-file.ts +6 -6
  298. package/src/translator/index.ts +1 -1
  299. package/src/utils/index.ts +51 -0
@@ -171,10 +171,6 @@ export class StructureProperty extends BaseNode {
171
171
  });
172
172
  }
173
173
 
174
-
175
-
176
-
177
-
178
174
  /**
179
175
  * 删除类型标注
180
176
  * @param name 类型标注名称
@@ -251,7 +247,7 @@ export class StructureProperty extends BaseNode {
251
247
  const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
252
248
  let completionChildren;
253
249
  if (typeKind === 'reference') {
254
- if (typeNamespace === 'nasl.ui') {
250
+ if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process') {
255
251
  const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
256
252
  const properties = node.properties || [];
257
253
  completionChildren = properties;
@@ -284,9 +280,10 @@ export class StructureProperty extends BaseNode {
284
280
  code += ': ';
285
281
  code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
286
282
  }
287
- if (this.defaultValue) {
288
- code += ` = ${this.defaultValue}`;
289
- } // else
283
+ // StructureProperty 暂不支持默认值
284
+ // if (this.defaultValue) {
285
+ // code += ` = ${this.defaultValue}`;
286
+ // }
290
287
  return code;
291
288
  }
292
289
 
@@ -345,7 +342,7 @@ export class StructureProperty extends BaseNode {
345
342
  //================================================================================
346
343
  }
347
344
 
348
- classMap['StructureProperty'] = StructureProperty;
345
+ classMap.StructureProperty = StructureProperty;
349
346
  export default StructureProperty;
350
347
  //================================================================================
351
348
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -531,34 +531,42 @@ export class Structure extends BaseNode {
531
531
  @withSourceMap()
532
532
  toEmbeddedTS(state?: TranslatorState): string {
533
533
  let code = `export class ${this.tsName} {\n`;
534
- code += indent(state.tabSize + 1);
534
+ code += indent((state?.tabSize || 0) + 1);
535
535
  code += `__name: '${this.getTsNamespace()}.${this.tsName}';\n`;
536
536
  this.properties.forEach((property) => {
537
- code += indent(state.tabSize + 1);
537
+ code += indent((state?.tabSize || 0) + 1);
538
538
  code += property.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
539
539
  code += ';\n';
540
540
  });
541
- code += indent(state.tabSize) + '}\n';
541
+ code += indent((state?.tabSize || 0)) + '}\n';
542
542
 
543
543
  return code;
544
544
  }
545
545
 
546
546
  getNamespace() {
547
547
  if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
548
- return `${(this.parentNode as Namespace).getNamespace()}.structures`;
548
+ const parentNamespace = (this.parentNode as Namespace).getNamespace();
549
+ const parentName = this.parentNode.name;
550
+ const arr = [parentNamespace];
551
+ if (this.parentNode.concept !== 'App' && parentName) {
552
+ arr.push(parentName);
553
+ }
554
+ return `${arr.join('.')}.structures`;
549
555
  } else
550
556
  throw new Error('无法获取命名空间,请设置 parentNode!');
551
557
  }
552
558
 
553
559
  getTsNamespace() {
554
- if (this.parentNode.concept === 'App') {
555
- return `${(this.parentNode as Namespace).getNamespace()}.structures`;
556
- } else {
557
- if (this.parentNode && (this.parentNode as Namespace).getTsNamespace) {
558
- return `${(this.parentNode as Namespace).getTsNamespace()}.structures`;
559
- } else {
560
- throw new Error('无法获取命名空间,请设置 parentNode!');
560
+ if (this.parentNode && (this.parentNode as Namespace).getTsNamespace) {
561
+ const parentNamespace = (this.parentNode as Namespace).getTsNamespace();
562
+ const parentName = this.parentNode.tsName || this.parentNode.name;
563
+ const arr = [parentNamespace];
564
+ if (this.parentNode.concept !== 'App' && parentName) {
565
+ arr.push(parentName);
561
566
  }
567
+ return `${arr.join('.')}.structures`;
568
+ } else {
569
+ throw new Error('无法获取命名空间,请设置 parentNode!');
562
570
  }
563
571
  }
564
572
 
@@ -241,37 +241,33 @@ export class SwitchCase extends LogicItem {
241
241
  // 自动生成的代码已结束。下面可以手动编写。
242
242
  //================================================================================
243
243
 
244
- toJS(state?: TranslatorState, isLast?: boolean): string {
244
+ toJS(state?: TranslatorState, index?: number, length?: number): string {
245
245
  let code = '';
246
- if (!isLast) {
246
+ if (index === 0) {
247
247
  code = 'if (';
248
248
  code += this.test ? this.test.toJS(shiftState(state, code, {
249
249
  tabSize: 0,
250
250
  })) : '';
251
-
252
251
  code += ') {\n';
253
-
254
- if (Array.isArray(this.consequent)) {
255
- this.consequent.forEach((logicItem) => {
256
- code
257
- += logicItem.toJS(shiftState(state, code, {
258
- tabSize: 0,
259
- })) + '\n';
260
- });
261
- }
262
- code += '}\n';
252
+ } else if (index !== length - 1) {
253
+ code = 'else if (';
254
+ code += this.test ? this.test.toJS(shiftState(state, code, {
255
+ tabSize: 0,
256
+ })) : '';
257
+ code += ') {\n';
263
258
  } else {
264
259
  code += 'else {\n';
265
- if (Array.isArray(this.consequent)) {
266
- this.consequent.forEach((logicItem) => {
267
- code
268
- += logicItem.toJS(shiftState(state, code, {
269
- tabSize: 0,
270
- })) + '\n';
271
- });
272
- }
273
- code += '}\n';
274
260
  }
261
+ if (Array.isArray(this.consequent)) {
262
+ this.consequent.forEach((logicItem) => {
263
+ code
264
+ += logicItem.toJS(shiftState(state, code, {
265
+ tabSize: 0,
266
+ })) + '\n';
267
+ });
268
+ }
269
+ code += '}\n';
270
+
275
271
  return code;
276
272
  }
277
273
 
@@ -281,7 +277,7 @@ export class SwitchCase extends LogicItem {
281
277
  if (!isLast) {
282
278
  code += 'if (nasl.core.ensureBoolean(';
283
279
  code += this.test ? this.test.toEmbeddedTS(shiftState(state, code, {
284
- tabSize: state.tabSize + 1,
280
+ tabSize: (state?.tabSize || 0) + 1,
285
281
  })) : '__IDENTIFIER__';
286
282
 
287
283
  code += ')) {\n';
@@ -290,22 +286,22 @@ export class SwitchCase extends LogicItem {
290
286
  this.consequent.forEach((logicItem) => {
291
287
  code
292
288
  += logicItem.toEmbeddedTS(shiftState(state, code, {
293
- tabSize: state.tabSize + 1,
289
+ tabSize: (state?.tabSize || 0) + 1,
294
290
  })) + '\n';
295
291
  });
296
292
  }
297
- code += indent(state.tabSize) + '}\n';
293
+ code += indent((state?.tabSize || 0)) + '}\n';
298
294
  } else {
299
295
  code += 'else {\n';
300
296
  if (Array.isArray(this.consequent)) {
301
297
  this.consequent.forEach((logicItem) => {
302
298
  code
303
299
  += logicItem.toEmbeddedTS(shiftState(state, code, {
304
- tabSize: state.tabSize + 1,
300
+ tabSize: (state?.tabSize || 0) + 1,
305
301
  })) + '\n';
306
302
  });
307
303
  }
308
- code += indent(state.tabSize) + '}\n';
304
+ code += indent((state?.tabSize || 0)) + '}\n';
309
305
  }
310
306
 
311
307
  return code;
@@ -213,11 +213,7 @@ export class SwitchStatement extends LogicItem {
213
213
  let code = '';
214
214
  this.cases.forEach((item, index) => {
215
215
  // 如果是最后一项
216
- if (index === this.cases.length - 1) {
217
- code += item.toJS(state, true);
218
- } else {
219
- code += item.toJS(state);
220
- }
216
+ code += item.toJS(state, index, this.cases.length);
221
217
  });
222
218
  return code;
223
219
  }
@@ -258,6 +258,35 @@ export class TypeAnnotation extends BaseNode {
258
258
  }
259
259
  }
260
260
 
261
+ /**
262
+ * 用于展示的 type 标题
263
+ */
264
+ get headTitle(): string {
265
+ if (this.typeKind === 'primitive') {
266
+ return `${this.typeName} ${PRIMITIVE_TITLE[this.typeName]}`;
267
+ } else if (this.typeKind === 'reference') {
268
+ const typeNamespace = this?.typeNamespace;
269
+ let typeTitle = this.typeName;
270
+ if (typeNamespace && this.rootNode) {
271
+ const entity = (this.rootNode as any).findNodeByCompleteName([typeNamespace, this?.typeName].join('.'));
272
+ if (entity?.concept === 'Entity') {
273
+ const dataSourceName = entity.dataSource?.name;
274
+ if (dataSourceName) {
275
+ typeTitle += `(${dataSourceName})`;
276
+ }
277
+ }
278
+ }
279
+ return typeTitle;
280
+ } else if (this.typeKind === 'generic') {
281
+ if (this.typeArguments && this.typeArguments.length)
282
+ return `${this.typeName}<${(this.typeArguments || []).map((arg) => arg.headTitle || 'T')}>`;
283
+ else
284
+ return this.typeName;
285
+ } else {
286
+ return this.typeName;
287
+ }
288
+ }
289
+
261
290
  /**
262
291
  * 用于展示的 type 标题
263
292
  */
@@ -265,11 +294,11 @@ export class TypeAnnotation extends BaseNode {
265
294
  if (this.typeKind === 'primitive') {
266
295
  return `${this.typeName} ${PRIMITIVE_TITLE[this.typeName]}`;
267
296
  } else if (this.typeKind === 'reference') {
268
- return `${this.typeName}`;
297
+ return this.typeName;
269
298
  } else if (this.typeKind === 'generic') {
270
299
  let str = `${this.typeName}`;
271
300
  const loop = (typeArguments: Array<TypeAnnotation>) => {
272
- str += '<' + (typeArguments[0].typeName || 'T');
301
+ str += '<' + (typeArguments[0].typeTitle || 'T');
273
302
  if (typeArguments[0].typeKind === 'generic') {
274
303
  if (this.typeArguments && this.typeArguments.length) {
275
304
  loop(typeArguments[0].typeArguments);
@@ -329,6 +358,18 @@ export class TypeAnnotation extends BaseNode {
329
358
  });
330
359
  }
331
360
 
361
+ /**
362
+ * 设置类型字段名称
363
+ */
364
+ setTypeNamespace(typeNamespace: string) {
365
+ const object = {
366
+ typeNamespace,
367
+ };
368
+ this.update({
369
+ ...object,
370
+ });
371
+ }
372
+
332
373
  get tsCalleeNamespace() {
333
374
  if (this.typeNamespace) {
334
375
  let tsCalleeNamespace = this.typeNamespace;
@@ -329,7 +329,7 @@ export class Variable extends BaseNode {
329
329
  const { typeName, typeKind, typeNamespace } = newTypeAnnotation || this.typeAnnotation;
330
330
  let completionChildren;
331
331
  if (typeKind === 'reference') {
332
- if (typeNamespace === 'nasl.ui') {
332
+ if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process') {
333
333
  const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
334
334
  const properties = node.properties || [];
335
335
  completionChildren = properties;
@@ -262,8 +262,6 @@ export class ViewElement extends BaseNode {
262
262
  super.subConstructor(source);
263
263
  }
264
264
 
265
-
266
-
267
265
  /**
268
266
  * 从父级删除该节点
269
267
  * @internal
@@ -300,7 +298,7 @@ export class ViewElement extends BaseNode {
300
298
  });
301
299
  }
302
300
 
303
- getBindAttributeExistingNames(excludedList: Array<BindAttribute> = []) {
301
+ getBindAttributeExistingNames(excludedList: Array<BindAttribute> = []) {
304
302
  const excludedSet = new Set(excludedList);
305
303
  return (this.bindAttrs || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
306
304
  }
@@ -441,7 +439,6 @@ export class ViewElement extends BaseNode {
441
439
  return node;
442
440
  }
443
441
 
444
-
445
442
  getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
446
443
  const excludedSet = new Set(excludedList);
447
444
  return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
@@ -583,7 +580,6 @@ export class ViewElement extends BaseNode {
583
580
  return node;
584
581
  }
585
582
 
586
-
587
583
  getBindDirectiveExistingNames(excludedList: Array<BindDirective> = []) {
588
584
  const excludedSet = new Set(excludedList);
589
585
  return (this.bindDirectives || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
@@ -725,11 +721,6 @@ export class ViewElement extends BaseNode {
725
721
  return node;
726
722
  }
727
723
 
728
-
729
-
730
-
731
-
732
-
733
724
  /**
734
725
  * 插入页面元素
735
726
  * @internal
@@ -863,9 +854,6 @@ export class ViewElement extends BaseNode {
863
854
  return node;
864
855
  }
865
856
 
866
-
867
-
868
-
869
857
  /**
870
858
  * 删除元素绑定属性
871
859
  * @param name 元素绑定属性名称
@@ -914,8 +902,6 @@ export class ViewElement extends BaseNode {
914
902
  return params;
915
903
  }
916
904
 
917
-
918
-
919
905
  /**
920
906
  * 删除元素绑定事件
921
907
  * @param name 元素绑定事件名称
@@ -964,8 +950,6 @@ export class ViewElement extends BaseNode {
964
950
  return params;
965
951
  }
966
952
 
967
-
968
-
969
953
  /**
970
954
  * 删除元素指令
971
955
  * @param name 元素指令名称
@@ -1014,8 +998,6 @@ export class ViewElement extends BaseNode {
1014
998
  return params;
1015
999
  }
1016
1000
 
1017
-
1018
-
1019
1001
  /**
1020
1002
  * 删除页面元素
1021
1003
  * @param name 页面元素名称
@@ -1120,7 +1102,7 @@ export class ViewElement extends BaseNode {
1120
1102
 
1121
1103
  haveScope(node: ViewElement): boolean {
1122
1104
  // uGallery 没有子集不需要scope
1123
- const dataSourcePcList = ['uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect', 'devopsDragTable'];
1105
+ const dataSourcePcList = ['uTableView', 'uListView', 'uGridView', 'uCalendarView', 'uListComponents', 'uSelect', 'devopsDragTable', 'uTreeViewNew', 'uTreeSelectNew'];
1124
1106
  const dataSourceH5List = ['vanRadioGroup', 'vanCheckboxGroup', 'vanListView', 'vanGridView', 'vanForComponents', 'lcapEchartsLine', 'lcapEchartsBar', 'lcapEchartsPie'];
1125
1107
  const dataSourceList = [...dataSourcePcList, ...dataSourceH5List];
1126
1108
  return dataSourceList.includes(node.toHump(node.tag));
@@ -1132,7 +1114,7 @@ export class ViewElement extends BaseNode {
1132
1114
  let code = '';
1133
1115
  // formItem的单独处理
1134
1116
  if (this.tag === 'u-form-item') {
1135
- code = indent(state.tabSize) + `${this.name}: nasl.ui.${this.toHump(this.tag)}`;
1117
+ code = indent((state?.tabSize || 0)) + `${this.name}: nasl.ui.${this.toHump(this.tag)}`;
1136
1118
  if (Array.isArray(this.children) && this.children.length) {
1137
1119
  const tag = this.children[0].tag;
1138
1120
  if (tag === 'u-input') {
@@ -1185,9 +1167,9 @@ export class ViewElement extends BaseNode {
1185
1167
  }
1186
1168
  }
1187
1169
  }
1188
- code += indent(state.tabSize) + `${this.name}: nasl.ui.${this.toHump(this.tag)}<${genericType}>;\n`;
1170
+ code += indent((state?.tabSize || 0)) + `${this.name}: nasl.ui.${this.toHump(this.tag)}<${genericType}>;\n`;
1189
1171
  } else {
1190
- code = indent(state.tabSize) + `${this.name}: nasl.ui.${this.toHump(this.tag)}<any>;\n`;
1172
+ code = indent((state?.tabSize || 0)) + `${this.name}: nasl.ui.${this.toHump(this.tag)}<any>;\n`;
1191
1173
  }
1192
1174
  if (Array.isArray(this.children)) {
1193
1175
  this.children.forEach((element) => {
@@ -1217,14 +1199,14 @@ export class ViewElement extends BaseNode {
1217
1199
  }
1218
1200
  // 角色
1219
1201
  if (Array.isArray(this.bindRoles) && this.bindRoles.length) {
1220
- code += indent(state.tabSize + 2);
1202
+ code += indent((state?.tabSize || 0) + 2);
1221
1203
  code += 'roles = [\n';
1222
1204
  this.bindRoles.forEach((role) => {
1223
- code += indent(state.tabSize + 3);
1205
+ code += indent((state?.tabSize || 0) + 3);
1224
1206
  code += `${this.app.getNamespace()}.roles.${chineseTsName(role)}.${chineseTsName(role)},`;
1225
1207
  code += '\n';
1226
1208
  });
1227
- code += indent(state.tabSize + 2);
1209
+ code += indent((state?.tabSize || 0) + 2);
1228
1210
  code += '],\n';
1229
1211
  }
1230
1212
  // 绑定属性
@@ -1233,7 +1215,7 @@ export class ViewElement extends BaseNode {
1233
1215
  // 跳转页面
1234
1216
  if (attr.destination) {
1235
1217
  code += attr.destination.toEmbeddedTS(shiftState(state, code, {
1236
- tabSize: state.tabSize,
1218
+ tabSize: (state?.tabSize || 0),
1237
1219
  }));
1238
1220
  }
1239
1221
  });
@@ -1244,7 +1226,7 @@ export class ViewElement extends BaseNode {
1244
1226
  if (Array.isArray(this.bindEvents)) {
1245
1227
  this.bindEvents.forEach((event) => {
1246
1228
  code += event.toEmbeddedTS(shiftState(state, code, {
1247
- tabSize: state.tabSize + 2,
1229
+ tabSize: (state?.tabSize || 0) + 2,
1248
1230
  }));
1249
1231
  code += '\n';
1250
1232
  });
@@ -1252,7 +1234,7 @@ export class ViewElement extends BaseNode {
1252
1234
 
1253
1235
  // 子元素
1254
1236
  if (Array.isArray(this.children)) {
1255
- code += indent(state.tabSize + 1);
1237
+ code += indent((state?.tabSize || 0) + 1);
1256
1238
 
1257
1239
  if (Array.isArray(this.bindAttrs)) {
1258
1240
  code += `bindAttr: () => [\n`;
@@ -1260,7 +1242,7 @@ export class ViewElement extends BaseNode {
1260
1242
  if (attr.expression) {
1261
1243
  code
1262
1244
  += attr.expression.toEmbeddedTS(shiftState(state, code, {
1263
- tabSize: state.tabSize + 2,
1245
+ tabSize: (state?.tabSize || 0) + 2,
1264
1246
  })) + ',\n';
1265
1247
  }
1266
1248
  if (Array.isArray(attr.rules) && attr.rules.length) {
@@ -1273,11 +1255,11 @@ export class ViewElement extends BaseNode {
1273
1255
  if (directive.expression) {
1274
1256
  code
1275
1257
  += directive.expression.toEmbeddedTS(shiftState(state, code, {
1276
- tabSize: state.tabSize + 2,
1258
+ tabSize: (state?.tabSize || 0) + 2,
1277
1259
  })) + ',\n';
1278
1260
  }
1279
1261
  });
1280
- code += indent(state.tabSize + 2) + '],\n';
1262
+ code += indent((state?.tabSize || 0) + 2) + '],\n';
1281
1263
  }
1282
1264
 
1283
1265
  let levelIndex = parentLevel || 0;
@@ -1290,15 +1272,15 @@ export class ViewElement extends BaseNode {
1290
1272
 
1291
1273
  this.children.forEach((element) => {
1292
1274
  code += element.toEmbeddedTS(shiftState(state, code, {
1293
- tabSize: state.tabSize + 2,
1275
+ tabSize: (state?.tabSize || 0) + 2,
1294
1276
  }), levelIndex);
1295
1277
  code += '\n';
1296
1278
  });
1297
- code += indent(state.tabSize + 1);
1279
+ code += indent((state?.tabSize || 0) + 1);
1298
1280
  code += ']\n';
1299
1281
  }
1300
1282
 
1301
- code += indent(state.tabSize) + '}),\n';
1283
+ code += indent((state?.tabSize || 0)) + '}),\n';
1302
1284
 
1303
1285
  return code;
1304
1286
  }
@@ -1550,7 +1532,7 @@ export class ViewElement extends BaseNode {
1550
1532
  tag: tagName,
1551
1533
  name: view.getViewElementUniqueName(`${baseName}1`),
1552
1534
  });
1553
- const value = astNode.text.match(/{{(.*?)}}/)[1].trim();
1535
+ const value = astNode.text?.match(/{{(.*?)}}/)[1].trim();
1554
1536
  const expression = <any> this._parseExpression(value);
1555
1537
  element.addBindAttribute(new BindAttribute({
1556
1538
  type: 'dynamic',
@@ -1568,7 +1550,7 @@ export class ViewElement extends BaseNode {
1568
1550
  element.addBindAttribute(new BindAttribute({
1569
1551
  name: 'text',
1570
1552
  type: 'string',
1571
- value: astNode.text,
1553
+ value: astNode.text?.trim(),
1572
1554
  }));
1573
1555
  }
1574
1556
  return element;
@@ -1615,6 +1597,11 @@ export class ViewElement extends BaseNode {
1615
1597
  const apiOfAttr = api && api.attrs && api.attrs.find((_attr) => _attr.name === attr.name);
1616
1598
  if (apiOfAttr && apiOfAttr['designer-value'] !== undefined) {
1617
1599
  let designerValue = apiOfAttr['designer-value'];
1600
+ //对流程模板拖拽进行特判
1601
+ element.bindAttrs.forEach((property) => {
1602
+ if (property.name === 'repeat' && property.value === '1')
1603
+ designerValue = '[{}, {}]';
1604
+ });
1618
1605
  if (typeof designerValue === 'string') {
1619
1606
  designerValue = designerValue.replace(/"/g, "'");
1620
1607
  }
@@ -1673,7 +1660,7 @@ export class ViewElement extends BaseNode {
1673
1660
  if (hasAuto)
1674
1661
  addEmpty = false;
1675
1662
  }
1676
- if (['u-select', 'u-dropdown', 'u-panel'].includes(el.tag)) {
1663
+ if (['u-select', 'u-dropdown', 'u-panel', 'u-toc', 'u-toc-item', 'u-tree-view-new', 'u-tree-view-node-new', 'u-tree-select', 'u-tree-select-new', 'u-anchor'].includes(el.tag)) {
1677
1664
  addEmpty = false;
1678
1665
  }
1679
1666
  const background = (emptySlot && emptySlot['empty-background']) || (hasSupport ? 'add-sub' : '');
@@ -1801,7 +1788,7 @@ export class ViewElement extends BaseNode {
1801
1788
  //================================================================================
1802
1789
  }
1803
1790
 
1804
- classMap['ViewElement'] = ViewElement;
1791
+ classMap.ViewElement = ViewElement;
1805
1792
  export default ViewElement;
1806
1793
  //================================================================================
1807
1794
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑