@lcap/nasl 2.18.0 → 2.20.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 (287) hide show
  1. package/out/automate/engine/index.d.ts +1 -1
  2. package/out/automate/engine/index.js +4 -4
  3. package/out/automate/engine/index.js.map +1 -1
  4. package/out/automate/engine/uniqueName.d.ts +1 -1
  5. package/out/automate/engine/uniqueName.js +3 -3
  6. package/out/automate/engine/uniqueName.js.map +1 -1
  7. package/out/automate/template/myProcess.js +1 -1
  8. package/out/automate/template/myProcess.js.map +1 -1
  9. package/out/bak/translator.js +2 -1
  10. package/out/bak/translator.js.map +1 -1
  11. package/out/common/BaseNode.js +1 -0
  12. package/out/common/BaseNode.js.map +1 -1
  13. package/out/concepts/AnonymousFunction__.d.ts +1 -0
  14. package/out/concepts/AnonymousFunction__.js +40 -2
  15. package/out/concepts/AnonymousFunction__.js.map +1 -1
  16. package/out/concepts/App__.d.ts +79 -261
  17. package/out/concepts/App__.js +241 -367
  18. package/out/concepts/App__.js.map +1 -1
  19. package/out/concepts/BatchAssignment__.d.ts +2 -0
  20. package/out/concepts/BatchAssignment__.js +108 -47
  21. package/out/concepts/BatchAssignment__.js.map +1 -1
  22. package/out/concepts/BindAttribute__.d.ts +5 -0
  23. package/out/concepts/BindAttribute__.js +15 -2
  24. package/out/concepts/BindAttribute__.js.map +1 -1
  25. package/out/concepts/BindDirective__.d.ts +5 -0
  26. package/out/concepts/BindDirective__.js +6 -0
  27. package/out/concepts/BindDirective__.js.map +1 -1
  28. package/out/concepts/BindEvent__.d.ts +5 -0
  29. package/out/concepts/BindEvent__.js +6 -0
  30. package/out/concepts/BindEvent__.js.map +1 -1
  31. package/out/concepts/BindStyle__.d.ts +5 -0
  32. package/out/concepts/BindStyle__.js +6 -0
  33. package/out/concepts/BindStyle__.js.map +1 -1
  34. package/out/concepts/CallFunction__.js +33 -14
  35. package/out/concepts/CallFunction__.js.map +1 -1
  36. package/out/concepts/CallInterface__.js +2 -1
  37. package/out/concepts/CallInterface__.js.map +1 -1
  38. package/out/concepts/CallLogic__.d.ts +2 -1
  39. package/out/concepts/CallLogic__.js +112 -27
  40. package/out/concepts/CallLogic__.js.map +1 -1
  41. package/out/concepts/CallQueryComponent__.js +4 -1
  42. package/out/concepts/CallQueryComponent__.js.map +1 -1
  43. package/out/concepts/Constant__.d.ts +5 -0
  44. package/out/concepts/Constant__.js +6 -0
  45. package/out/concepts/Constant__.js.map +1 -1
  46. package/out/concepts/DataSource__.d.ts +2 -0
  47. package/out/concepts/DataSource__.js +55 -1
  48. package/out/concepts/DataSource__.js.map +1 -1
  49. package/out/concepts/Destination__.d.ts +2 -1
  50. package/out/concepts/Destination__.js +98 -25
  51. package/out/concepts/Destination__.js.map +1 -1
  52. package/out/concepts/Frontend__.d.ts +370 -0
  53. package/out/concepts/Frontend__.js +669 -0
  54. package/out/concepts/Frontend__.js.map +1 -0
  55. package/out/concepts/Identifier__.d.ts +1 -0
  56. package/out/concepts/Identifier__.js +18 -7
  57. package/out/concepts/Identifier__.js.map +1 -1
  58. package/out/concepts/LogicItem__.d.ts +6 -1
  59. package/out/concepts/LogicItem__.js +6 -0
  60. package/out/concepts/LogicItem__.js.map +1 -1
  61. package/out/concepts/Logic__.d.ts +85 -79
  62. package/out/concepts/Logic__.js +41 -23
  63. package/out/concepts/Logic__.js.map +1 -1
  64. package/out/concepts/Match__.js +14 -9
  65. package/out/concepts/Match__.js.map +1 -1
  66. package/out/concepts/NewComposite__.d.ts +345 -0
  67. package/out/concepts/NewComposite__.js +1068 -0
  68. package/out/concepts/NewComposite__.js.map +1 -0
  69. package/out/concepts/NewList__.d.ts +130 -0
  70. package/out/concepts/NewList__.js +349 -0
  71. package/out/concepts/NewList__.js.map +1 -0
  72. package/out/concepts/NewMap__.d.ts +221 -0
  73. package/out/concepts/NewMap__.js +480 -0
  74. package/out/concepts/NewMap__.js.map +1 -0
  75. package/out/concepts/New__.d.ts +19 -0
  76. package/out/concepts/New__.js +66 -0
  77. package/out/concepts/New__.js.map +1 -0
  78. package/out/concepts/Param__.d.ts +7 -0
  79. package/out/concepts/Param__.js +46 -3
  80. package/out/concepts/Param__.js.map +1 -1
  81. package/out/concepts/ProcessElement__.js +42 -13
  82. package/out/concepts/ProcessElement__.js.map +1 -1
  83. package/out/concepts/ProcessOutcomes__.d.ts +30 -0
  84. package/out/concepts/ProcessOutcomes__.js +87 -0
  85. package/out/concepts/ProcessOutcomes__.js.map +1 -0
  86. package/out/concepts/Process__.d.ts +4 -20
  87. package/out/concepts/Process__.js +0 -7
  88. package/out/concepts/Process__.js.map +1 -1
  89. package/out/concepts/Return__.d.ts +5 -0
  90. package/out/concepts/Return__.js +8 -1
  91. package/out/concepts/Return__.js.map +1 -1
  92. package/out/concepts/SelectMembers__.js +3 -3
  93. package/out/concepts/SelectMembers__.js.map +1 -1
  94. package/out/concepts/Transactional__.d.ts +5 -0
  95. package/out/concepts/Transactional__.js +6 -0
  96. package/out/concepts/Transactional__.js.map +1 -1
  97. package/out/concepts/TypeAnnotation__.d.ts +3 -0
  98. package/out/concepts/TypeAnnotation__.js +50 -11
  99. package/out/concepts/TypeAnnotation__.js.map +1 -1
  100. package/out/concepts/ValidationRule__.js +1 -1
  101. package/out/concepts/ValidationRule__.js.map +1 -1
  102. package/out/concepts/Variable__.d.ts +5 -0
  103. package/out/concepts/Variable__.js +9 -2
  104. package/out/concepts/Variable__.js.map +1 -1
  105. package/out/concepts/ViewElement__.d.ts +5 -0
  106. package/out/concepts/ViewElement__.js +21 -3
  107. package/out/concepts/ViewElement__.js.map +1 -1
  108. package/out/concepts/View__.d.ts +6 -0
  109. package/out/concepts/View__.js +23 -3
  110. package/out/concepts/View__.js.map +1 -1
  111. package/out/concepts/basics/stdlib/nasl.auth.js +1 -1
  112. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
  113. package/out/concepts/basics/stdlib/nasl.logging.js +5 -0
  114. package/out/concepts/basics/stdlib/nasl.logging.js.map +1 -1
  115. package/out/concepts/basics/stdlib/nasl.ui.js +2 -0
  116. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  117. package/out/concepts/basics/stdlib/nasl.util.js +151 -19
  118. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  119. package/out/concepts/index__.d.ts +7 -0
  120. package/out/concepts/index__.js +7 -0
  121. package/out/concepts/index__.js.map +1 -1
  122. package/out/enums/KEYWORDS.d.ts +1 -0
  123. package/out/enums/KEYWORDS.js +9 -1
  124. package/out/enums/KEYWORDS.js.map +1 -1
  125. package/out/generator/genBundleFiles.d.ts +6 -3
  126. package/out/generator/genBundleFiles.js +54 -192
  127. package/out/generator/genBundleFiles.js.map +1 -1
  128. package/out/generator/genMetaData.d.ts +2 -11
  129. package/out/generator/genMetaData.js +185 -51
  130. package/out/generator/genMetaData.js.map +1 -1
  131. package/out/generator/genReleaseBody.d.ts +18 -2
  132. package/out/generator/genReleaseBody.js +80 -40
  133. package/out/generator/genReleaseBody.js.map +1 -1
  134. package/out/generator/index.d.ts +1 -0
  135. package/out/generator/index.js +1 -0
  136. package/out/generator/index.js.map +1 -1
  137. package/out/generator/permission.d.ts +17 -0
  138. package/out/generator/permission.js +221 -0
  139. package/out/generator/permission.js.map +1 -0
  140. package/out/index.d.ts +1 -1
  141. package/out/index.js +3 -1
  142. package/out/index.js.map +1 -1
  143. package/out/server/entity2LogicNamespace.js +89 -9
  144. package/out/server/entity2LogicNamespace.js.map +1 -1
  145. package/out/server/extendBaseNode.js +33 -20
  146. package/out/server/extendBaseNode.js.map +1 -1
  147. package/out/server/formatTsUtils.d.ts +1 -2
  148. package/out/server/formatTsUtils.js +36 -47
  149. package/out/server/formatTsUtils.js.map +1 -1
  150. package/out/server/getLogics.d.ts +2 -1
  151. package/out/server/getLogics.js +13 -2
  152. package/out/server/getLogics.js.map +1 -1
  153. package/out/server/getMemberIdentifier.js +4 -4
  154. package/out/server/getMemberIdentifier.js.map +1 -1
  155. package/out/server/getProcesses.js +1 -1
  156. package/out/server/getProcesses.js.map +1 -1
  157. package/out/server/naslServer.d.ts +3 -1
  158. package/out/server/naslServer.js +254 -65
  159. package/out/server/naslServer.js.map +1 -1
  160. package/out/server/process2LogicNamespace.js +8 -0
  161. package/out/server/process2LogicNamespace.js.map +1 -1
  162. package/out/server/translator.js +50 -5
  163. package/out/server/translator.js.map +1 -1
  164. package/out/service/creator/add.configs.js +4 -0
  165. package/out/service/creator/add.configs.js.map +1 -1
  166. package/out/service/datasource/api.d.ts +12 -0
  167. package/out/service/datasource/api.js +14 -0
  168. package/out/service/datasource/api.js.map +1 -0
  169. package/out/service/datasource/index.d.ts +2 -0
  170. package/out/service/datasource/index.js +10 -0
  171. package/out/service/datasource/index.js.map +1 -0
  172. package/out/service/storage/init.js +15 -4
  173. package/out/service/storage/init.js.map +1 -1
  174. package/out/templator/genEditTableBlock.js +4 -5
  175. package/out/templator/genEditTableBlock.js.map +1 -1
  176. package/out/templator/genGetBlock.js +4 -3
  177. package/out/templator/genGetBlock.js.map +1 -1
  178. package/out/templator/genGridViewBlock.js +16 -14
  179. package/out/templator/genGridViewBlock.js.map +1 -1
  180. package/out/templator/genListViewBlock.js +5 -5
  181. package/out/templator/genListViewBlock.js.map +1 -1
  182. package/out/templator/genTableBlock.js +6 -10
  183. package/out/templator/genTableBlock.js.map +1 -1
  184. package/package.json +2 -2
  185. package/sandbox/stdlib/nasl.auth.ts +1 -1
  186. package/sandbox/stdlib/nasl.core.ts +1 -0
  187. package/sandbox/stdlib/nasl.logging.ts +4 -4
  188. package/sandbox/stdlib/nasl.util.ts +9 -5
  189. package/src/automate/engine/index.js +4 -4
  190. package/src/automate/engine/uniqueName.js +3 -3
  191. package/src/automate/template/myProcess.js +1 -1
  192. package/src/automate/upgrader/2.20.js +41 -0
  193. package/src/bak/translator.js +4 -1
  194. package/src/common/BaseNode.ts +1 -0
  195. package/src/concepts/AnonymousFunction__.ts +48 -2
  196. package/src/concepts/App__.ts +298 -650
  197. package/src/concepts/BatchAssignment__.ts +111 -51
  198. package/src/concepts/BindAttribute__.ts +18 -25
  199. package/src/concepts/BindDirective__.ts +7 -0
  200. package/src/concepts/BindEvent__.ts +7 -0
  201. package/src/concepts/BindStyle__.ts +7 -0
  202. package/src/concepts/CallFunction__.ts +34 -45
  203. package/src/concepts/CallInterface__.ts +2 -1
  204. package/src/concepts/CallLogic__.ts +87 -55
  205. package/src/concepts/CallQueryComponent__.ts +4 -1
  206. package/src/concepts/Constant__.ts +7 -0
  207. package/src/concepts/DataSource__.ts +57 -5
  208. package/src/concepts/Destination__.ts +100 -43
  209. package/src/concepts/Frontend__.ts +945 -0
  210. package/src/concepts/Identifier__.ts +18 -16
  211. package/src/concepts/LogicItem__.ts +8 -1
  212. package/src/concepts/Logic__.ts +134 -149
  213. package/src/concepts/Match__.ts +13 -29
  214. package/src/concepts/NewComposite__.ts +1357 -0
  215. package/src/concepts/NewList__.ts +440 -0
  216. package/src/concepts/NewMap__.ts +666 -0
  217. package/src/concepts/New__.ts +73 -0
  218. package/src/concepts/Param__.ts +245 -199
  219. package/src/concepts/ProcessElement__.ts +43 -36
  220. package/src/concepts/ProcessOutcomes__.ts +90 -0
  221. package/src/concepts/Process__.ts +1 -23
  222. package/src/concepts/Return__.ts +11 -1
  223. package/src/concepts/SelectMembers__.ts +3 -3
  224. package/src/concepts/Transactional__.ts +7 -0
  225. package/src/concepts/TypeAnnotation__.ts +54 -49
  226. package/src/concepts/ValidationRule__.ts +19 -1
  227. package/src/concepts/Variable__.ts +12 -6
  228. package/src/concepts/ViewElement__.ts +28 -26
  229. package/src/concepts/View__.ts +26 -26
  230. package/src/concepts/basics/stdlib/nasl.auth.ts +1 -1
  231. package/src/concepts/basics/stdlib/nasl.logging.ts +5 -0
  232. package/src/concepts/basics/stdlib/nasl.ui.ts +2 -0
  233. package/src/concepts/basics/stdlib/nasl.util.ts +153 -19
  234. package/src/concepts/index__.ts +7 -0
  235. package/src/enums/KEYWORDS.ts +9 -0
  236. package/src/generator/genBundleFiles.ts +74 -245
  237. package/src/generator/genMetaData.ts +178 -78
  238. package/src/generator/genReleaseBody.ts +87 -44
  239. package/src/generator/index.ts +1 -0
  240. package/src/generator/permission.ts +261 -0
  241. package/src/index.ts +1 -1
  242. package/src/server/entity2LogicNamespace.ts +90 -10
  243. package/src/server/extendBaseNode.ts +33 -22
  244. package/src/server/formatTsUtils.ts +36 -46
  245. package/src/server/getLogics.ts +15 -3
  246. package/src/server/getMemberIdentifier.ts +5 -5
  247. package/src/server/getProcesses.ts +1 -1
  248. package/src/server/naslServer.ts +260 -77
  249. package/src/server/process2LogicNamespace.ts +8 -0
  250. package/src/server/translator.ts +51 -5
  251. package/src/service/creator/add.configs.js +4 -0
  252. package/src/service/datasource/api.js +11 -0
  253. package/src/service/datasource/index.js +6 -0
  254. package/src/service/storage/init.ts +15 -4
  255. package/src/service/video/VideoTranscribe.js +1 -0
  256. package/src/templator/genEditTableBlock.ts +8 -16
  257. package/src/templator/genGetBlock.ts +18 -19
  258. package/src/templator/genGridViewBlock.ts +18 -18
  259. package/src/templator/genListViewBlock.ts +8 -11
  260. package/src/templator/genTableBlock.ts +6 -10
  261. package/ts-worker/lib/tsserver.js +8 -1
  262. package/out/automate/engine/2.14-components.d.ts +0 -1115
  263. package/out/automate/engine/2.14-components.js +0 -1087
  264. package/out/automate/engine/2.14-components.js.map +0 -1
  265. package/out/concepts/MatchExpression__.d.ts +0 -97
  266. package/out/concepts/MatchExpression__.js +0 -281
  267. package/out/concepts/MatchExpression__.js.map +0 -1
  268. package/src/automate/engine/dist/index.dev.js +0 -517
  269. package/src/common/dist/BaseNode.js +0 -1101
  270. package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +0 -24
  271. package/src/concepts/dist/Anchor__.js +0 -179
  272. package/src/concepts/dist/Assignment__.js +0 -301
  273. package/src/concepts/dist/CallFunction__.js +0 -473
  274. package/src/concepts/dist/CallInterface__.js +0 -533
  275. package/src/concepts/dist/CallLogic__.js +0 -864
  276. package/src/concepts/dist/ForEachStatement__.js +0 -426
  277. package/src/concepts/dist/MatchCase__.js +0 -587
  278. package/src/concepts/dist/MemberExpression__.js +0 -348
  279. package/src/concepts/dist/Param__.js +0 -537
  280. package/src/concepts/dist/Return__.js +0 -493
  281. package/src/generator/dist/genBundleFiles.js +0 -414
  282. package/src/server/dist/formatTsUtils.js +0 -683
  283. package/src/server/dist/naslServer.js +0 -3396
  284. package/src/service/storage/dist/init.js +0 -541
  285. package/ts-worker/dist/webpack.config.dev.js +0 -104
  286. package/ts-worker/lib/dist/tsserver.dev.js +0 -22953
  287. package/ts-worker/sources/lib/dist/tsserver.dev.js +0 -22912
@@ -34,6 +34,7 @@ import Module from './Module__';
34
34
  import View from './View__';
35
35
  import ProcessElement from './ProcessElement__';
36
36
  import App from './App__';
37
+ import Frontend from './Frontend__';
37
38
  import Process from './Process__';
38
39
 
39
40
  /**
@@ -81,7 +82,7 @@ export class Logic extends BaseNode {
81
82
  * 编译器信息
82
83
  */
83
84
  @property()
84
- compilerInfoMap: { java?: { packageName: string, className: string } } = undefined;
85
+ compilerInfoMap: { java?: { packageName: string; className: string } } = undefined;
85
86
 
86
87
  /**
87
88
  * 类型参数列表
@@ -137,6 +138,12 @@ export class Logic extends BaseNode {
137
138
  get view() {
138
139
  return this.getAncestor('View') as View;
139
140
  }
141
+ /**
142
+ * 祖先 Frontend
143
+ */
144
+ get frontend() {
145
+ return this.getAncestor('Frontend') as Frontend;
146
+ }
140
147
  /**
141
148
  * 祖先 ProcessElement
142
149
  */
@@ -238,7 +245,7 @@ export class Logic extends BaseNode {
238
245
  });
239
246
  }
240
247
 
241
- getTypeParamExistingNames(excludedList: Array<TypeParam> = []) {
248
+ getTypeParamExistingNames(excludedList: Array<TypeParam> = []) {
242
249
  const excludedSet = new Set(excludedList);
243
250
  return ((this.typeParams as TypeParam[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
244
251
  }
@@ -247,24 +254,24 @@ export class Logic extends BaseNode {
247
254
  }
248
255
 
249
256
  /**
250
- * 插入类型参数
251
- * @internal
252
- * @param name 类型参数名称,如果不填会自动生成一个唯一名称
253
- */
257
+ * 插入类型参数
258
+ * @internal
259
+ * @param name 类型参数名称,如果不填会自动生成一个唯一名称
260
+ */
254
261
  _insertTypeParamAt(name: string, index: number): TypeParam;
255
262
 
256
263
  /**
257
- * 插入类型参数
258
- * @internal
259
- * @param typeParamOptions 类型参数参数
260
- */
264
+ * 插入类型参数
265
+ * @internal
266
+ * @param typeParamOptions 类型参数参数
267
+ */
261
268
  _insertTypeParamAt(typeParamOptions: Partial<TypeParam>, index: number): TypeParam;
262
269
 
263
270
  /**
264
- * 插入类型参数
265
- * @internal
266
- * @param typeParam 已有的类型参数实例
267
- */
271
+ * 插入类型参数
272
+ * @internal
273
+ * @param typeParam 已有的类型参数实例
274
+ */
268
275
  _insertTypeParamAt(typeParam: TypeParam, index: number): TypeParam;
269
276
 
270
277
  _insertTypeParamAt(options: string | Partial<TypeParam> | TypeParam, index: number) {
@@ -379,30 +386,29 @@ export class Logic extends BaseNode {
379
386
  return node;
380
387
  }
381
388
 
382
-
383
389
  getParamUniqueName(name = 'param1') {
384
390
  return utils.unique(name, this.getVarExistingNames(), undefined, false);
385
391
  }
386
392
 
387
393
  /**
388
- * 插入输入参数
389
- * @internal
390
- * @param name 输入参数名称,如果不填会自动生成一个唯一名称
391
- */
394
+ * 插入输入参数
395
+ * @internal
396
+ * @param name 输入参数名称,如果不填会自动生成一个唯一名称
397
+ */
392
398
  _insertParamAt(name: string, index: number): Param;
393
399
 
394
400
  /**
395
- * 插入输入参数
396
- * @internal
397
- * @param paramOptions 输入参数参数
398
- */
401
+ * 插入输入参数
402
+ * @internal
403
+ * @param paramOptions 输入参数参数
404
+ */
399
405
  _insertParamAt(paramOptions: Partial<Param>, index: number): Param;
400
406
 
401
407
  /**
402
- * 插入输入参数
403
- * @internal
404
- * @param param 已有的输入参数实例
405
- */
408
+ * 插入输入参数
409
+ * @internal
410
+ * @param param 已有的输入参数实例
411
+ */
406
412
  _insertParamAt(param: Param, index: number): Param;
407
413
 
408
414
  _insertParamAt(options: string | Partial<Param> | Param, index: number) {
@@ -517,30 +523,29 @@ export class Logic extends BaseNode {
517
523
  return node;
518
524
  }
519
525
 
520
-
521
526
  getReturnUniqueName(name = 'result') {
522
527
  return utils.unique(name, this.getVarExistingNames(), undefined, false);
523
528
  }
524
529
 
525
530
  /**
526
- * 插入输出参数
527
- * @internal
528
- * @param name 输出参数名称,如果不填会自动生成一个唯一名称
529
- */
531
+ * 插入输出参数
532
+ * @internal
533
+ * @param name 输出参数名称,如果不填会自动生成一个唯一名称
534
+ */
530
535
  _insertReturnAt(name: string, index: number): Return;
531
536
 
532
537
  /**
533
- * 插入输出参数
534
- * @internal
535
- * @param retOptions 输出参数参数
536
- */
538
+ * 插入输出参数
539
+ * @internal
540
+ * @param retOptions 输出参数参数
541
+ */
537
542
  _insertReturnAt(retOptions: Partial<Return>, index: number): Return;
538
543
 
539
544
  /**
540
- * 插入输出参数
541
- * @internal
542
- * @param ret 已有的输出参数实例
543
- */
545
+ * 插入输出参数
546
+ * @internal
547
+ * @param ret 已有的输出参数实例
548
+ */
544
549
  _insertReturnAt(ret: Return, index: number): Return;
545
550
 
546
551
  _insertReturnAt(options: string | Partial<Return> | Return, index: number) {
@@ -655,30 +660,29 @@ export class Logic extends BaseNode {
655
660
  return node;
656
661
  }
657
662
 
658
-
659
663
  getVariableUniqueName(name = 'variable1') {
660
664
  return utils.unique(name, this.getVarExistingNames(), undefined, false);
661
665
  }
662
666
 
663
667
  /**
664
- * 插入变量
665
- * @internal
666
- * @param name 变量名称,如果不填会自动生成一个唯一名称
667
- */
668
+ * 插入变量
669
+ * @internal
670
+ * @param name 变量名称,如果不填会自动生成一个唯一名称
671
+ */
668
672
  _insertVariableAt(name: string, index: number): Variable;
669
673
 
670
674
  /**
671
- * 插入变量
672
- * @internal
673
- * @param variableOptions 变量参数
674
- */
675
+ * 插入变量
676
+ * @internal
677
+ * @param variableOptions 变量参数
678
+ */
675
679
  _insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
676
680
 
677
681
  /**
678
- * 插入变量
679
- * @internal
680
- * @param variable 已有的变量实例
681
- */
682
+ * 插入变量
683
+ * @internal
684
+ * @param variable 已有的变量实例
685
+ */
682
686
  _insertVariableAt(variable: Variable, index: number): Variable;
683
687
 
684
688
  _insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
@@ -793,23 +797,18 @@ export class Logic extends BaseNode {
793
797
  return node;
794
798
  }
795
799
 
796
-
797
-
798
-
799
-
800
-
801
800
  /**
802
- * 插入逻辑项
803
- * @internal
804
- * @param logicItemOptions 逻辑项参数
805
- */
801
+ * 插入逻辑项
802
+ * @internal
803
+ * @param logicItemOptions 逻辑项参数
804
+ */
806
805
  _insertItemInBodyAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
807
806
 
808
807
  /**
809
- * 插入逻辑项
810
- * @internal
811
- * @param logicItem 已有的逻辑项实例
812
- */
808
+ * 插入逻辑项
809
+ * @internal
810
+ * @param logicItem 已有的逻辑项实例
811
+ */
813
812
  _insertItemInBodyAt(logicItem: LogicItem, index: number): LogicItem;
814
813
 
815
814
  _insertItemInBodyAt(options: Partial<LogicItem> | LogicItem, index: number) {
@@ -830,8 +829,6 @@ export class Logic extends BaseNode {
830
829
  return logicItem;
831
830
  }
832
831
 
833
-
834
-
835
832
  /**
836
833
  * 插入逻辑项
837
834
  * @param logicItemOptions 逻辑项参数
@@ -854,8 +851,6 @@ export class Logic extends BaseNode {
854
851
  return node;
855
852
  }
856
853
 
857
-
858
-
859
854
  /**
860
855
  * 添加逻辑项
861
856
  * @internal
@@ -875,8 +870,6 @@ export class Logic extends BaseNode {
875
870
  return this._insertItemInBodyAt(options as any, index);
876
871
  }
877
872
 
878
-
879
-
880
873
  /**
881
874
  * 添加逻辑项
882
875
  * @param logicItemOptions 逻辑项参数
@@ -900,20 +893,18 @@ export class Logic extends BaseNode {
900
893
  return node;
901
894
  }
902
895
 
903
-
904
-
905
896
  /**
906
- * 插入逻辑项
907
- * @internal
908
- * @param logicItemOptions 逻辑项参数
909
- */
897
+ * 插入逻辑项
898
+ * @internal
899
+ * @param logicItemOptions 逻辑项参数
900
+ */
910
901
  _insertItemInPlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
911
902
 
912
903
  /**
913
- * 插入逻辑项
914
- * @internal
915
- * @param logicItem 已有的逻辑项实例
916
- */
904
+ * 插入逻辑项
905
+ * @internal
906
+ * @param logicItem 已有的逻辑项实例
907
+ */
917
908
  _insertItemInPlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
918
909
 
919
910
  _insertItemInPlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
@@ -934,8 +925,6 @@ export class Logic extends BaseNode {
934
925
  return logicItem;
935
926
  }
936
927
 
937
-
938
-
939
928
  /**
940
929
  * 插入逻辑项
941
930
  * @param logicItemOptions 逻辑项参数
@@ -958,8 +947,6 @@ export class Logic extends BaseNode {
958
947
  return node;
959
948
  }
960
949
 
961
-
962
-
963
950
  /**
964
951
  * 添加逻辑项
965
952
  * @internal
@@ -979,8 +966,6 @@ export class Logic extends BaseNode {
979
966
  return this._insertItemInPlaygroundAt(options as any, index);
980
967
  }
981
968
 
982
-
983
-
984
969
  /**
985
970
  * 添加逻辑项
986
971
  * @param logicItemOptions 逻辑项参数
@@ -1004,13 +989,10 @@ export class Logic extends BaseNode {
1004
989
  return node;
1005
990
  }
1006
991
 
1007
-
1008
-
1009
-
1010
992
  /**
1011
- * 删除事务
1012
- * @param name 事务名称
1013
- */
993
+ * 删除事务
994
+ * @param name 事务名称
995
+ */
1014
996
  removeTransactional(name: string): void;
1015
997
 
1016
998
  /**
@@ -1055,12 +1037,10 @@ export class Logic extends BaseNode {
1055
1037
  return params;
1056
1038
  }
1057
1039
 
1058
-
1059
-
1060
1040
  /**
1061
- * 删除类型参数
1062
- * @param name 类型参数名称
1063
- */
1041
+ * 删除类型参数
1042
+ * @param name 类型参数名称
1043
+ */
1064
1044
  removeTypeParam(name: string): void;
1065
1045
 
1066
1046
  /**
@@ -1105,12 +1085,10 @@ export class Logic extends BaseNode {
1105
1085
  return params;
1106
1086
  }
1107
1087
 
1108
-
1109
-
1110
1088
  /**
1111
- * 删除输入参数
1112
- * @param name 输入参数名称
1113
- */
1089
+ * 删除输入参数
1090
+ * @param name 输入参数名称
1091
+ */
1114
1092
  removeParam(name: string): void;
1115
1093
 
1116
1094
  /**
@@ -1155,12 +1133,10 @@ export class Logic extends BaseNode {
1155
1133
  return params;
1156
1134
  }
1157
1135
 
1158
-
1159
-
1160
1136
  /**
1161
- * 删除输出参数
1162
- * @param name 输出参数名称
1163
- */
1137
+ * 删除输出参数
1138
+ * @param name 输出参数名称
1139
+ */
1164
1140
  removeReturn(name: string): void;
1165
1141
 
1166
1142
  /**
@@ -1205,12 +1181,10 @@ export class Logic extends BaseNode {
1205
1181
  return params;
1206
1182
  }
1207
1183
 
1208
-
1209
-
1210
1184
  /**
1211
- * 删除变量
1212
- * @param name 变量名称
1213
- */
1185
+ * 删除变量
1186
+ * @param name 变量名称
1187
+ */
1214
1188
  removeVariable(name: string): void;
1215
1189
 
1216
1190
  /**
@@ -1255,8 +1229,6 @@ export class Logic extends BaseNode {
1255
1229
  return params;
1256
1230
  }
1257
1231
 
1258
-
1259
-
1260
1232
  /**
1261
1233
  * 删除逻辑项
1262
1234
  * @param logicItem 已有的逻辑项实例
@@ -1264,12 +1236,10 @@ export class Logic extends BaseNode {
1264
1236
  removeItemInBody(logicItem: LogicItem): void;
1265
1237
 
1266
1238
  removeItemInBody(options: LogicItem) {
1267
- let logicItem: LogicItem = options;
1239
+ const logicItem: LogicItem = options;
1268
1240
  return logicItem.delete();
1269
1241
  }
1270
1242
 
1271
-
1272
-
1273
1243
  /**
1274
1244
  * 删除逻辑项
1275
1245
  * @param logicItem 已有的逻辑项实例
@@ -1277,7 +1247,7 @@ export class Logic extends BaseNode {
1277
1247
  removeItemInPlayground(logicItem: LogicItem): void;
1278
1248
 
1279
1249
  removeItemInPlayground(options: LogicItem) {
1280
- let logicItem: LogicItem = options;
1250
+ const logicItem: LogicItem = options;
1281
1251
  return logicItem.delete();
1282
1252
  }
1283
1253
 
@@ -1625,15 +1595,10 @@ export class Logic extends BaseNode {
1625
1595
  code += '(';
1626
1596
  this.params.forEach((param, index) => {
1627
1597
  code += param.toEmbeddedTS(shiftState(state, code));
1628
- code += ',';
1629
- });
1630
- code += '\n, __defaultValues?: { \n';
1631
- this.params.forEach((param, index) => {
1632
- code += `${param.name}: "${param.defaultValue || ''}"`;
1633
1598
  if (index !== this.params.length - 1)
1634
- code += ',\n';
1599
+ code += ', ';
1635
1600
  });
1636
- code += '})';
1601
+ code += ')';
1637
1602
  } else {
1638
1603
  // 没有参数的
1639
1604
  code += '()';
@@ -1645,13 +1610,11 @@ export class Logic extends BaseNode {
1645
1610
  this.traverseChildren((el) => {
1646
1611
  if (el && (el instanceof BatchAssignment || (el instanceof Assignment && el.left?.name))) {
1647
1612
  const jsCode = el.toJS();
1648
- const advanceVar = this.variables?.find((variable) =>
1649
- !variable.typeAnnotation && jsCode.includes(`${variable.name} = `));
1613
+ const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && jsCode.includes(`${variable.name} = `));
1650
1614
  if (advanceVar && !advanceMap.get(advanceVar)) {
1651
1615
  advanceMap.set(advanceVar, el);
1652
1616
  }
1653
- const advanceRn = this.returns?.find((ret) =>
1654
- !ret.typeAnnotation && jsCode.includes(`${ret.name} = `));
1617
+ const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && jsCode.includes(`${ret.name} = `));
1655
1618
  if (advanceRn && !advanceMap.get(advanceRn)) {
1656
1619
  advanceMap.set(advanceRn, el);
1657
1620
  }
@@ -1668,12 +1631,14 @@ export class Logic extends BaseNode {
1668
1631
  Promise.all(needGetSourceMapOqlList).then(() => {
1669
1632
  // 触发一下更新重新生成代码
1670
1633
  (this.app as any)?.naslServer?.embeddedTSEmitter.emit('change', {
1671
- value: [{
1672
- originEvent: {
1673
- action: 'update',
1674
- target: this,
1634
+ value: [
1635
+ {
1636
+ originEvent: {
1637
+ action: 'update',
1638
+ target: this,
1639
+ },
1675
1640
  },
1676
- }],
1641
+ ],
1677
1642
  });
1678
1643
  });
1679
1644
  }
@@ -1685,11 +1650,13 @@ export class Logic extends BaseNode {
1685
1650
  code += '{\n';
1686
1651
 
1687
1652
  // 用于虚拟节点的查找引用
1688
- this.virtualParams && Array.isArray(this.virtualParams) && this.virtualParams.forEach((param) => {
1689
- code += indent((state?.tabSize || 0) + 1);
1690
- code += param.toEmbeddedNameTS(shiftState(state, code, { inline: true }));
1691
- code += '\n';
1692
- });
1653
+ this.virtualParams
1654
+ && Array.isArray(this.virtualParams)
1655
+ && this.virtualParams.forEach((param) => {
1656
+ code += indent((state?.tabSize || 0) + 1);
1657
+ code += param.toEmbeddedNameTS(shiftState(state, code, { inline: true }));
1658
+ code += '\n';
1659
+ });
1693
1660
 
1694
1661
  this.variables.forEach((variable) => {
1695
1662
  if (!advanceMap.get(variable)) {
@@ -1713,12 +1680,12 @@ export class Logic extends BaseNode {
1713
1680
  code += node.toEmbeddedTS(shiftState(state, code, { inline: true }));
1714
1681
  if (assignment instanceof BatchAssignment) {
1715
1682
  assignment.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1716
- const leftCode = leftIndex.length === 1 ? assignment.left.expression.toEmbeddedTS(shiftState(state, code, { inline: true })) : assignment.left.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true }));
1683
+ const leftCode
1684
+ = leftIndex.length === 1 ? assignment.left.expression.toEmbeddedTS(shiftState(state, code, { inline: true })) : assignment.left.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true }));
1717
1685
  if (leftCode === node.name) {
1718
1686
  const rightNode: any = rightIndex.length === 1 ? assignment.rights[rightIndex[0]]?.expression : assignment.rights[rightIndex[0]]?.members[rightIndex[1]];
1719
1687
  // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1720
- if (rightNode?.typeAnnotation
1721
- && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
1688
+ if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
1722
1689
  code += ': ';
1723
1690
  code += rightNode.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) || 'null';
1724
1691
  } else {
@@ -1728,11 +1695,14 @@ export class Logic extends BaseNode {
1728
1695
  }
1729
1696
  }
1730
1697
  });
1698
+ } else if (['NewList', 'NewMap'].includes(assignment.right.concept) && !(assignment.right as any).typeAnnotation) {
1699
+ const rightNode: any = assignment.right;
1700
+ code += ' = ';
1701
+ code += rightNode.getInitCode(shiftState(state, code, { inline: true }));
1731
1702
  } else {
1732
1703
  const rightNode: any = assignment.right;
1733
1704
  // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1734
- if (rightNode?.typeAnnotation
1735
- && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
1705
+ if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
1736
1706
  code += ': ';
1737
1707
  code += rightNode.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) || 'null';
1738
1708
  } else {
@@ -1742,7 +1712,7 @@ export class Logic extends BaseNode {
1742
1712
  if (rightNode && rightNode instanceof Identifier && rightNode.namespace && rightNode.namespace.endsWith('enums')) {
1743
1713
  rightCode += 'new ';
1744
1714
  }
1745
- rightCode += (rightNode && rightNode.toEmbeddedTS) ? rightNode.toEmbeddedTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
1715
+ rightCode += rightNode && rightNode.toEmbeddedTS ? rightNode.toEmbeddedTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
1746
1716
  code += this.getRightCode(rightCode, assignment, rightNode);
1747
1717
  }
1748
1718
  }
@@ -1815,6 +1785,10 @@ export class Logic extends BaseNode {
1815
1785
  return replaceCode;
1816
1786
 
1817
1787
  let fnCode = $1;
1788
+ if ($1.startsWith(`${variable}.`))
1789
+ fnCode = $1.replaceAll(`${variable}.`, `${replaceCode}.`);
1790
+ if ($1.startsWith(`${variable},`))
1791
+ fnCode = $1.replaceAll(`${variable},`, `${replaceCode},`);
1818
1792
  if ($1.includes(`(${variable},`))
1819
1793
  fnCode = $1.replaceAll(`(${variable},`, `(${replaceCode},`);
1820
1794
  if ($1.includes(`(${variable}.`))
@@ -1882,7 +1856,10 @@ export class Logic extends BaseNode {
1882
1856
  arr.push(parentName);
1883
1857
  }
1884
1858
  let namespace = arr.join('.');
1885
- if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace) && !namespace.includes('.logics')) {
1859
+ if (
1860
+ !['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace)
1861
+ && !namespace.includes('.logics')
1862
+ ) {
1886
1863
  namespace = `${namespace}.logics`;
1887
1864
  }
1888
1865
  return namespace;
@@ -1899,7 +1876,10 @@ export class Logic extends BaseNode {
1899
1876
  arr.push(parentName);
1900
1877
  }
1901
1878
  let namespace = arr.join('.');
1902
- if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace) && !namespace.includes('.logics')) {
1879
+ if (
1880
+ !['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace)
1881
+ && !namespace.includes('.logics')
1882
+ ) {
1903
1883
  namespace = `${namespace}.logics`;
1904
1884
  }
1905
1885
  return namespace;
@@ -2039,6 +2019,11 @@ export class Logic extends BaseNode {
2039
2019
  // 虚拟输入参数列表
2040
2020
  virtualParams: Array<Param> = [];
2041
2021
 
2022
+ get getLogicBelongTo() {
2023
+ const [, belongTo] = this.calleewholeKey.split('.');
2024
+ return belongTo;
2025
+ }
2026
+
2042
2027
  //================================================================================
2043
2028
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
2044
2029
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓