@lcap/nasl 1.0.0 → 2.12.0-beta

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 (422) hide show
  1. package/out/automate/engine/index.js +39 -127
  2. package/out/automate/engine/index.js.map +1 -1
  3. package/out/automate/engine/operators.d.ts +13 -0
  4. package/out/automate/engine/operators.js +63 -0
  5. package/out/automate/engine/operators.js.map +1 -0
  6. package/out/automate/engine/uniqueName.d.ts +6 -0
  7. package/out/automate/engine/uniqueName.js +39 -0
  8. package/out/automate/engine/uniqueName.js.map +1 -0
  9. package/out/automate/engine/utils.d.ts +1 -0
  10. package/out/automate/engine/utils.js +105 -67
  11. package/out/automate/engine/utils.js.map +1 -1
  12. package/out/common/BaseNode.d.ts +1 -1
  13. package/out/common/BaseNode.js +13 -3
  14. package/out/common/BaseNode.js.map +1 -1
  15. package/out/concepts/App__.d.ts +52 -49
  16. package/out/concepts/App__.js +95 -60
  17. package/out/concepts/App__.js.map +1 -1
  18. package/out/concepts/Argument__.js +1 -1
  19. package/out/concepts/Argument__.js.map +1 -1
  20. package/out/concepts/Assignee__.d.ts +11 -0
  21. package/out/concepts/Assignee__.js +36 -2
  22. package/out/concepts/Assignee__.js.map +1 -1
  23. package/out/concepts/Assignment__.js +1 -1
  24. package/out/concepts/Assignment__.js.map +1 -1
  25. package/out/concepts/Attribute__.js +1 -1
  26. package/out/concepts/Attribute__.js.map +1 -1
  27. package/out/concepts/BinaryExpression__.js +1 -1
  28. package/out/concepts/BinaryExpression__.js.map +1 -1
  29. package/out/concepts/BindAttribute__.js +4 -4
  30. package/out/concepts/BindAttribute__.js.map +1 -1
  31. package/out/concepts/BindDirective__.js +2 -2
  32. package/out/concepts/BindDirective__.js.map +1 -1
  33. package/out/concepts/BindEvent__.js +11 -6
  34. package/out/concepts/BindEvent__.js.map +1 -1
  35. package/out/concepts/BooleanLiteral__.js +1 -1
  36. package/out/concepts/BooleanLiteral__.js.map +1 -1
  37. package/out/concepts/CallFunction__.js +25 -5
  38. package/out/concepts/CallFunction__.js.map +1 -1
  39. package/out/concepts/CallInterface__.js +1 -1
  40. package/out/concepts/CallInterface__.js.map +1 -1
  41. package/out/concepts/CallLogic__.js +24 -22
  42. package/out/concepts/CallLogic__.js.map +1 -1
  43. package/out/concepts/CallQueryComponent__.d.ts +35 -5
  44. package/out/concepts/CallQueryComponent__.js +344 -99
  45. package/out/concepts/CallQueryComponent__.js.map +1 -1
  46. package/out/concepts/Comment__.js +2 -2
  47. package/out/concepts/Comment__.js.map +1 -1
  48. package/out/concepts/CompletionProperty__.js +1 -1
  49. package/out/concepts/CompletionProperty__.js.map +1 -1
  50. package/out/concepts/ConfigGroup__.d.ts +1 -0
  51. package/out/concepts/ConfigGroup__.js +9 -2
  52. package/out/concepts/ConfigGroup__.js.map +1 -1
  53. package/out/concepts/ConfigPropertyValue__.js +1 -1
  54. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  55. package/out/concepts/ConfigProperty__.d.ts +1 -0
  56. package/out/concepts/ConfigProperty__.js +5 -2
  57. package/out/concepts/ConfigProperty__.js.map +1 -1
  58. package/out/concepts/Configuration__.d.ts +1 -0
  59. package/out/concepts/Configuration__.js +5 -2
  60. package/out/concepts/Configuration__.js.map +1 -1
  61. package/out/concepts/Constant__.js +7 -7
  62. package/out/concepts/Constant__.js.map +1 -1
  63. package/out/concepts/DataElement__.js +1 -1
  64. package/out/concepts/DataElement__.js.map +1 -1
  65. package/out/concepts/DataSource__.d.ts +143 -0
  66. package/out/concepts/DataSource__.js +316 -0
  67. package/out/concepts/DataSource__.js.map +1 -0
  68. package/out/concepts/Destination__.js +26 -9
  69. package/out/concepts/Destination__.js.map +1 -1
  70. package/out/concepts/End__.js +3 -3
  71. package/out/concepts/End__.js.map +1 -1
  72. package/out/concepts/EntityIndex__.d.ts +5 -0
  73. package/out/concepts/EntityIndex__.js +11 -3
  74. package/out/concepts/EntityIndex__.js.map +1 -1
  75. package/out/concepts/EntityProperty__.d.ts +9 -0
  76. package/out/concepts/EntityProperty__.js +23 -8
  77. package/out/concepts/EntityProperty__.js.map +1 -1
  78. package/out/concepts/Entity__.d.ts +6 -3
  79. package/out/concepts/Entity__.js +28 -24
  80. package/out/concepts/Entity__.js.map +1 -1
  81. package/out/concepts/EnumItem__.js +1 -1
  82. package/out/concepts/EnumItem__.js.map +1 -1
  83. package/out/concepts/Enum__.d.ts +1 -0
  84. package/out/concepts/Enum__.js +15 -5
  85. package/out/concepts/Enum__.js.map +1 -1
  86. package/out/concepts/Event__.js +2 -2
  87. package/out/concepts/Event__.js.map +1 -1
  88. package/out/concepts/ForEachStatement__.d.ts +1 -1
  89. package/out/concepts/ForEachStatement__.js +5 -5
  90. package/out/concepts/ForEachStatement__.js.map +1 -1
  91. package/out/concepts/Function__.d.ts +18 -0
  92. package/out/concepts/Function__.js +100 -5
  93. package/out/concepts/Function__.js.map +1 -1
  94. package/out/concepts/Identifier__.js +2 -12
  95. package/out/concepts/Identifier__.js.map +1 -1
  96. package/out/concepts/IfStatement__.js +9 -9
  97. package/out/concepts/IfStatement__.js.map +1 -1
  98. package/out/concepts/InterfaceParam__.js +10 -5
  99. package/out/concepts/InterfaceParam__.js.map +1 -1
  100. package/out/concepts/Interface__.js +21 -14
  101. package/out/concepts/Interface__.js.map +1 -1
  102. package/out/concepts/JSBlock__.js +1 -1
  103. package/out/concepts/JSBlock__.js.map +1 -1
  104. package/out/concepts/LogicItem__.js +1 -1
  105. package/out/concepts/LogicItem__.js.map +1 -1
  106. package/out/concepts/Logic__.d.ts +4 -0
  107. package/out/concepts/Logic__.js +59 -46
  108. package/out/concepts/Logic__.js.map +1 -1
  109. package/out/concepts/MemberExpression__.js +1 -2
  110. package/out/concepts/MemberExpression__.js.map +1 -1
  111. package/out/concepts/Module__.d.ts +1 -85
  112. package/out/concepts/Module__.js +13 -114
  113. package/out/concepts/Module__.js.map +1 -1
  114. package/out/concepts/Namespace__.d.ts +0 -86
  115. package/out/concepts/Namespace__.js +12 -119
  116. package/out/concepts/Namespace__.js.map +1 -1
  117. package/out/concepts/NullLiteral__.js +1 -1
  118. package/out/concepts/NullLiteral__.js.map +1 -1
  119. package/out/concepts/NumericLiteral__.js +1 -1
  120. package/out/concepts/NumericLiteral__.js.map +1 -1
  121. package/out/concepts/Param__.d.ts +3 -2
  122. package/out/concepts/Param__.js +15 -8
  123. package/out/concepts/Param__.js.map +1 -1
  124. package/out/concepts/Point__.js +1 -1
  125. package/out/concepts/Point__.js.map +1 -1
  126. package/out/concepts/ProcessComponent__.js +3 -3
  127. package/out/concepts/ProcessComponent__.js.map +1 -1
  128. package/out/concepts/ProcessElement__.js +39 -18
  129. package/out/concepts/ProcessElement__.js.map +1 -1
  130. package/out/concepts/ProcessOutcome__.js +1 -1
  131. package/out/concepts/ProcessOutcome__.js.map +1 -1
  132. package/out/concepts/Process__.js +21 -14
  133. package/out/concepts/Process__.js.map +1 -1
  134. package/out/concepts/QueryAggregateExpression__.js +2 -2
  135. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  136. package/out/concepts/QueryFieldExpression__.d.ts +1 -0
  137. package/out/concepts/QueryFieldExpression__.js +12 -2
  138. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  139. package/out/concepts/QueryFromExpression__.d.ts +4 -0
  140. package/out/concepts/QueryFromExpression__.js +14 -3
  141. package/out/concepts/QueryFromExpression__.js.map +1 -1
  142. package/out/concepts/QueryGroupByExpression__.d.ts +3 -0
  143. package/out/concepts/QueryGroupByExpression__.js +21 -1
  144. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  145. package/out/concepts/QueryJoinExpression__.d.ts +4 -0
  146. package/out/concepts/QueryJoinExpression__.js +16 -5
  147. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  148. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  149. package/out/concepts/QueryOrderByExpression__.js +1 -1
  150. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  151. package/out/concepts/QuerySelectExpression__.js +2 -2
  152. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  153. package/out/concepts/Rect__.js +1 -1
  154. package/out/concepts/Rect__.js.map +1 -1
  155. package/out/concepts/Return__.d.ts +1 -1
  156. package/out/concepts/Return__.js +16 -11
  157. package/out/concepts/Return__.js.map +1 -1
  158. package/out/concepts/Role__.js +11 -4
  159. package/out/concepts/Role__.js.map +1 -1
  160. package/out/concepts/Slot__.js +1 -1
  161. package/out/concepts/Slot__.js.map +1 -1
  162. package/out/concepts/SqlQueryComponent__.d.ts +10 -0
  163. package/out/concepts/SqlQueryComponent__.js +32 -5
  164. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  165. package/out/concepts/Start__.js +1 -1
  166. package/out/concepts/Start__.js.map +1 -1
  167. package/out/concepts/StringLiteral__.js +2 -9
  168. package/out/concepts/StringLiteral__.js.map +1 -1
  169. package/out/concepts/StructureProperty__.js +6 -6
  170. package/out/concepts/StructureProperty__.js.map +1 -1
  171. package/out/concepts/Structure__.js +22 -15
  172. package/out/concepts/Structure__.js.map +1 -1
  173. package/out/concepts/SwitchCase__.js +6 -6
  174. package/out/concepts/SwitchCase__.js.map +1 -1
  175. package/out/concepts/SwitchStatement__.js +1 -1
  176. package/out/concepts/SwitchStatement__.js.map +1 -1
  177. package/out/concepts/Theme__.js +1 -1
  178. package/out/concepts/Theme__.js.map +1 -1
  179. package/out/concepts/Transactional__.js +1 -1
  180. package/out/concepts/Transactional__.js.map +1 -1
  181. package/out/concepts/TypeAnnotation__.d.ts +8 -0
  182. package/out/concepts/TypeAnnotation__.js +56 -6
  183. package/out/concepts/TypeAnnotation__.js.map +1 -1
  184. package/out/concepts/TypeParam__.js +1 -1
  185. package/out/concepts/TypeParam__.js.map +1 -1
  186. package/out/concepts/UnaryExpression__.js +1 -1
  187. package/out/concepts/UnaryExpression__.js.map +1 -1
  188. package/out/concepts/Unparsed__.js +1 -1
  189. package/out/concepts/Unparsed__.js.map +1 -1
  190. package/out/concepts/UseComponent__.js +1 -1
  191. package/out/concepts/UseComponent__.js.map +1 -1
  192. package/out/concepts/ValidationRule__.js +1 -1
  193. package/out/concepts/ValidationRule__.js.map +1 -1
  194. package/out/concepts/Variable__.d.ts +1 -1
  195. package/out/concepts/Variable__.js +16 -11
  196. package/out/concepts/Variable__.js.map +1 -1
  197. package/out/concepts/ViewComponent__.js +6 -6
  198. package/out/concepts/ViewComponent__.js.map +1 -1
  199. package/out/concepts/ViewElement__.js +21 -21
  200. package/out/concepts/ViewElement__.js.map +1 -1
  201. package/out/concepts/View__.d.ts +3 -1
  202. package/out/concepts/View__.js +53 -32
  203. package/out/concepts/View__.js.map +1 -1
  204. package/out/concepts/WhileStatement__.js +5 -5
  205. package/out/concepts/WhileStatement__.js.map +1 -1
  206. package/out/concepts/basics/stdlib/nasl.configuration.js +1 -1
  207. package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
  208. package/out/concepts/basics/stdlib/nasl.interface.d.ts +2 -0
  209. package/out/concepts/basics/stdlib/nasl.interface.js +4 -4
  210. package/out/concepts/basics/stdlib/nasl.interface.js.map +1 -1
  211. package/out/concepts/basics/stdlib/nasl.util.js +268 -6
  212. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  213. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +1 -1
  214. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js.map +1 -1
  215. package/out/concepts/basics/types/index.d.ts +1 -0
  216. package/out/concepts/basics/types/index.js +3 -1
  217. package/out/concepts/basics/types/index.js.map +1 -1
  218. package/out/concepts/index__.d.ts +1 -0
  219. package/out/concepts/index__.js +1 -0
  220. package/out/concepts/index__.js.map +1 -1
  221. package/out/enums/KEYWORDS.js +0 -9
  222. package/out/enums/KEYWORDS.js.map +1 -1
  223. package/out/generator/genBundleFiles.js +8 -3
  224. package/out/generator/genBundleFiles.js.map +1 -1
  225. package/out/generator/genMetaData.js +13 -12
  226. package/out/generator/genMetaData.js.map +1 -1
  227. package/out/manager/diagnostic.d.ts +1 -1
  228. package/out/server/createUiTs.js +1 -0
  229. package/out/server/createUiTs.js.map +1 -1
  230. package/out/server/extendBaseNode.d.ts +1 -0
  231. package/out/server/extendBaseNode.js +323 -0
  232. package/out/server/extendBaseNode.js.map +1 -0
  233. package/out/server/getLogics.js +31 -2
  234. package/out/server/getLogics.js.map +1 -1
  235. package/out/server/getMemberIdentifier.js +47 -2
  236. package/out/server/getMemberIdentifier.js.map +1 -1
  237. package/out/server/getProcesses.d.ts +7 -2
  238. package/out/server/getProcesses.js +220 -20
  239. package/out/server/getProcesses.js.map +1 -1
  240. package/out/server/getScope.d.ts +3 -1
  241. package/out/server/getScope.js +30 -14
  242. package/out/server/getScope.js.map +1 -1
  243. package/out/server/index.d.ts +1 -0
  244. package/out/server/index.js +1 -0
  245. package/out/server/index.js.map +1 -1
  246. package/out/server/naslServer.d.ts +7 -5
  247. package/out/server/naslServer.js +249 -372
  248. package/out/server/naslServer.js.map +1 -1
  249. package/out/server/process2LogicNamespace.js +10 -1
  250. package/out/server/process2LogicNamespace.js.map +1 -1
  251. package/out/server/translator.d.ts +1 -1
  252. package/out/server/translator.js +22 -2
  253. package/out/server/translator.js.map +1 -1
  254. package/out/service/storage/init.js +32 -11
  255. package/out/service/storage/init.js.map +1 -1
  256. package/out/templator/genCreateBlock.js +15 -11
  257. package/out/templator/genCreateBlock.js.map +1 -1
  258. package/out/templator/genCurdEditMultipleKeyBlock.js +15 -12
  259. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  260. package/out/templator/genCurdMultipleKeyBlock.js +25 -21
  261. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  262. package/out/templator/genEditTableBlock.js +12 -12
  263. package/out/templator/genEditTableBlock.js.map +1 -1
  264. package/out/templator/genGetBlock.js +1 -1
  265. package/out/templator/genGetBlock.js.map +1 -1
  266. package/out/templator/genGridViewBlock.js +21 -20
  267. package/out/templator/genGridViewBlock.js.map +1 -1
  268. package/out/templator/genListViewBlock.js +6 -3
  269. package/out/templator/genListViewBlock.js.map +1 -1
  270. package/out/templator/genQueryComponent.js +11 -8
  271. package/out/templator/genQueryComponent.js.map +1 -1
  272. package/out/templator/genSelectBlock.js +13 -22
  273. package/out/templator/genSelectBlock.js.map +1 -1
  274. package/out/templator/genTableBlock.js +17 -15
  275. package/out/templator/genTableBlock.js.map +1 -1
  276. package/out/templator/genUpdateBlock.js +16 -12
  277. package/out/templator/genUpdateBlock.js.map +1 -1
  278. package/out/templator/utils.d.ts +5 -3
  279. package/out/templator/utils.js +2 -1
  280. package/out/templator/utils.js.map +1 -1
  281. package/out/test/integration/connect-file.js +6 -6
  282. package/out/test/integration/connect-file.js.map +1 -1
  283. package/out/translator/index.js +1 -1
  284. package/out/translator/index.js.map +1 -1
  285. package/out/utils/index.d.ts +4 -0
  286. package/out/utils/index.js +38 -2
  287. package/out/utils/index.js.map +1 -1
  288. package/out/utils/string.d.ts +1 -1
  289. package/out/utils/string.js +38 -9
  290. package/out/utils/string.js.map +1 -1
  291. package/package.json +1 -2
  292. package/src/automate/engine/index.js +38 -128
  293. package/src/automate/engine/operators.js +63 -0
  294. package/src/automate/engine/uniqueName.js +36 -0
  295. package/src/automate/engine/utils.js +108 -69
  296. package/src/common/BaseNode.ts +14 -3
  297. package/src/concepts/App__.ts +138 -101
  298. package/src/concepts/Argument__.ts +1 -1
  299. package/src/concepts/Assignee__.ts +32 -2
  300. package/src/concepts/Assignment__.ts +1 -1
  301. package/src/concepts/Attribute__.ts +1 -1
  302. package/src/concepts/BinaryExpression__.ts +1 -1
  303. package/src/concepts/BindAttribute__.ts +4 -4
  304. package/src/concepts/BindDirective__.ts +2 -2
  305. package/src/concepts/BindEvent__.ts +10 -6
  306. package/src/concepts/BooleanLiteral__.ts +1 -1
  307. package/src/concepts/CallFunction__.ts +36 -18
  308. package/src/concepts/CallInterface__.ts +1 -1
  309. package/src/concepts/CallLogic__.ts +55 -24
  310. package/src/concepts/CallQueryComponent__.ts +357 -134
  311. package/src/concepts/Comment__.ts +2 -2
  312. package/src/concepts/CompletionProperty__.ts +1 -1
  313. package/src/concepts/ConfigGroup__.ts +5 -3
  314. package/src/concepts/ConfigPropertyValue__.ts +1 -1
  315. package/src/concepts/ConfigProperty__.ts +6 -2
  316. package/src/concepts/Configuration__.ts +5 -2
  317. package/src/concepts/Constant__.ts +7 -7
  318. package/src/concepts/DataElement__.ts +1 -1
  319. package/src/concepts/DataSource__.ts +389 -0
  320. package/src/concepts/Destination__.ts +28 -10
  321. package/src/concepts/End__.ts +3 -3
  322. package/src/concepts/EntityIndex__.ts +12 -3
  323. package/src/concepts/EntityProperty__.ts +24 -8
  324. package/src/concepts/Entity__.ts +39 -27
  325. package/src/concepts/EnumItem__.ts +1 -1
  326. package/src/concepts/Enum__.ts +16 -5
  327. package/src/concepts/Event__.ts +2 -2
  328. package/src/concepts/ForEachStatement__.ts +5 -5
  329. package/src/concepts/Function__.ts +101 -7
  330. package/src/concepts/Identifier__.ts +2 -12
  331. package/src/concepts/IfStatement__.ts +10 -10
  332. package/src/concepts/InterfaceParam__.ts +10 -5
  333. package/src/concepts/Interface__.ts +22 -14
  334. package/src/concepts/JSBlock__.ts +1 -1
  335. package/src/concepts/LogicItem__.ts +1 -1
  336. package/src/concepts/Logic__.ts +60 -43
  337. package/src/concepts/MemberExpression__.ts +1 -2
  338. package/src/concepts/Module__.ts +16 -211
  339. package/src/concepts/Namespace__.ts +12 -215
  340. package/src/concepts/NullLiteral__.ts +1 -1
  341. package/src/concepts/NumericLiteral__.ts +1 -1
  342. package/src/concepts/Param__.ts +17 -9
  343. package/src/concepts/Point__.ts +1 -1
  344. package/src/concepts/ProcessComponent__.ts +3 -3
  345. package/src/concepts/ProcessElement__.ts +43 -21
  346. package/src/concepts/ProcessOutcome__.ts +1 -1
  347. package/src/concepts/Process__.ts +21 -15
  348. package/src/concepts/QueryAggregateExpression__.ts +2 -2
  349. package/src/concepts/QueryFieldExpression__.ts +14 -2
  350. package/src/concepts/QueryFromExpression__.ts +14 -3
  351. package/src/concepts/QueryGroupByExpression__.ts +24 -1
  352. package/src/concepts/QueryJoinExpression__.ts +16 -5
  353. package/src/concepts/QueryLimitExpression__.ts +9 -0
  354. package/src/concepts/QueryOrderByExpression__.ts +1 -1
  355. package/src/concepts/QuerySelectExpression__.ts +2 -2
  356. package/src/concepts/Rect__.ts +1 -1
  357. package/src/concepts/Return__.ts +16 -11
  358. package/src/concepts/Role__.ts +11 -5
  359. package/src/concepts/Slot__.ts +1 -1
  360. package/src/concepts/SqlQueryComponent__.ts +30 -11
  361. package/src/concepts/Start__.ts +1 -1
  362. package/src/concepts/StringLiteral__.ts +2 -9
  363. package/src/concepts/StructureProperty__.ts +6 -6
  364. package/src/concepts/Structure__.ts +22 -14
  365. package/src/concepts/SwitchCase__.ts +6 -6
  366. package/src/concepts/SwitchStatement__.ts +1 -1
  367. package/src/concepts/Theme__.ts +1 -1
  368. package/src/concepts/Transactional__.ts +1 -1
  369. package/src/concepts/TypeAnnotation__.ts +55 -25
  370. package/src/concepts/TypeParam__.ts +1 -1
  371. package/src/concepts/UnaryExpression__.ts +1 -1
  372. package/src/concepts/Unparsed__.ts +1 -1
  373. package/src/concepts/UseComponent__.ts +1 -1
  374. package/src/concepts/ValidationRule__.ts +1 -1
  375. package/src/concepts/Variable__.ts +16 -11
  376. package/src/concepts/ViewComponent__.ts +6 -6
  377. package/src/concepts/ViewElement__.ts +21 -21
  378. package/src/concepts/View__.ts +54 -32
  379. package/src/concepts/WhileStatement__.ts +5 -5
  380. package/src/concepts/basics/stdlib/nasl.configuration.ts +1 -1
  381. package/src/concepts/basics/stdlib/nasl.interface.ts +1 -1
  382. package/src/concepts/basics/stdlib/nasl.util.ts +269 -6
  383. package/src/concepts/basics/stdlib/reference2TypeAnnotationList.ts +1 -1
  384. package/src/concepts/basics/types/index.ts +1 -0
  385. package/src/concepts/index__.ts +1 -0
  386. package/src/enums/KEYWORDS.ts +0 -9
  387. package/src/generator/genBundleFiles.ts +8 -3
  388. package/src/generator/genMetaData.ts +13 -13
  389. package/src/manager/diagnostic.ts +1 -1
  390. package/src/server/createUiTs.ts +1 -0
  391. package/src/server/extendBaseNode.ts +318 -0
  392. package/src/server/getLogics.ts +33 -4
  393. package/src/server/getMemberIdentifier.ts +49 -2
  394. package/src/server/getProcesses.ts +231 -21
  395. package/src/server/getScope.ts +41 -24
  396. package/src/server/index.ts +1 -0
  397. package/src/server/naslServer.ts +248 -366
  398. package/src/server/process2LogicNamespace.ts +29 -19
  399. package/src/server/translator.ts +25 -2
  400. package/src/service/storage/init.ts +32 -12
  401. package/src/templator/genCreateBlock.ts +16 -13
  402. package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -13
  403. package/src/templator/genCurdMultipleKeyBlock.ts +26 -22
  404. package/src/templator/genEditTableBlock.ts +14 -13
  405. package/src/templator/genGetBlock.ts +1 -1
  406. package/src/templator/genGridViewBlock.ts +22 -21
  407. package/src/templator/genListViewBlock.ts +9 -5
  408. package/src/templator/genQueryComponent.ts +12 -9
  409. package/src/templator/genSelectBlock.ts +14 -23
  410. package/src/templator/genTableBlock.ts +18 -16
  411. package/src/templator/genUpdateBlock.ts +17 -13
  412. package/src/templator/utils.ts +5 -2
  413. package/src/test/integration/connect-file.ts +6 -6
  414. package/src/translator/index.ts +1 -1
  415. package/src/utils/index.ts +38 -1
  416. package/src/utils/string.ts +39 -9
  417. package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +0 -3
  418. package/out/concepts/basics/stdlib/nasl.browser copy.js +0 -70
  419. package/out/concepts/basics/stdlib/nasl.browser copy.js.map +0 -1
  420. package/out/terms/LEVEL_NAME_MAP.d.ts +0 -26
  421. package/out/terms/LEVEL_NAME_MAP.js +0 -30
  422. package/out/terms/LEVEL_NAME_MAP.js.map +0 -1
@@ -4,6 +4,7 @@ import Entity from './Entity__';
4
4
  import Structure from './Structure__';
5
5
  import StructureProperty from './StructureProperty__';
6
6
  import CompletionProperty from './CompletionProperty__';
7
+ import QueryFieldExpression from './QueryFieldExpression__';
7
8
  //================================================================================
8
9
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
9
10
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -83,13 +84,11 @@ export class CallQueryComponent extends LogicItem {
83
84
  limit: QueryLimitExpression = undefined;
84
85
 
85
86
  /**
86
- * 查询组件的局部版本
87
+ * 局部版本
87
88
  */
88
89
  @property()
89
90
  ideVersion: string = undefined;
90
91
 
91
-
92
-
93
92
  /**
94
93
  * @param source 需要合并的部分参数
95
94
  */
@@ -103,7 +102,6 @@ export class CallQueryComponent extends LogicItem {
103
102
  return super.from(source, parentNode, parentKey) as CallQueryComponent;
104
103
  }
105
104
 
106
-
107
105
  /**
108
106
  * 设置select
109
107
  */
@@ -203,12 +201,12 @@ export class CallQueryComponent extends LogicItem {
203
201
  });
204
202
  }
205
203
 
206
- getQueryGroupByExpressionExistingNames(excludedList: Array<QueryGroupByExpression> = []) {
204
+ getQueryGroupByExpressionExistingNames(excludedList: Array<QueryGroupByExpression> = []) {
207
205
  const excludedSet = new Set(excludedList);
208
206
  return (this.groupBy || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
209
207
  }
210
208
  getQueryGroupByExpressionUniqueName(name = 'queryGroupByExpression1') {
211
- return utils.unique(name, this.getQueryGroupByExpressionExistingNames());
209
+ return utils.unique(name, this.getQueryGroupByExpressionExistingNames(), undefined, false);
212
210
  }
213
211
 
214
212
  /**
@@ -344,8 +342,6 @@ export class CallQueryComponent extends LogicItem {
344
342
  return node;
345
343
  }
346
344
 
347
-
348
-
349
345
  /**
350
346
  * 插入查询排序子句
351
347
  * @internal
@@ -378,8 +374,6 @@ export class CallQueryComponent extends LogicItem {
378
374
  return queryOrderByExpression;
379
375
  }
380
376
 
381
-
382
-
383
377
  /**
384
378
  * 插入查询排序子句
385
379
  * @param queryOrderByExpressionOptions 查询排序子句参数
@@ -402,8 +396,6 @@ export class CallQueryComponent extends LogicItem {
402
396
  return node;
403
397
  }
404
398
 
405
-
406
-
407
399
  /**
408
400
  * 添加查询排序子句
409
401
  * @internal
@@ -423,8 +415,6 @@ export class CallQueryComponent extends LogicItem {
423
415
  return this._insertQueryOrderByExpressionInOrderByAt(options as any, index);
424
416
  }
425
417
 
426
-
427
-
428
418
  /**
429
419
  * 添加查询排序子句
430
420
  * @param queryOrderByExpressionOptions 查询排序子句参数
@@ -448,9 +438,6 @@ export class CallQueryComponent extends LogicItem {
448
438
  return node;
449
439
  }
450
440
 
451
-
452
-
453
-
454
441
  /**
455
442
  * 删除类型标注
456
443
  * @param name 类型标注名称
@@ -499,8 +486,6 @@ export class CallQueryComponent extends LogicItem {
499
486
  return params;
500
487
  }
501
488
 
502
-
503
-
504
489
  /**
505
490
  * 删除查询选择子句
506
491
  * @param name 查询选择子句名称
@@ -526,8 +511,6 @@ export class CallQueryComponent extends LogicItem {
526
511
  return select.delete();
527
512
  }
528
513
 
529
-
530
-
531
514
  /**
532
515
  * 删除查询 From 子句
533
516
  * @param name 查询 From 子句名称
@@ -553,8 +536,6 @@ export class CallQueryComponent extends LogicItem {
553
536
  return from.delete();
554
537
  }
555
538
 
556
-
557
-
558
539
  /**
559
540
  * 删除逻辑项
560
541
  * @param name 逻辑项名称
@@ -580,8 +561,6 @@ export class CallQueryComponent extends LogicItem {
580
561
  return where.delete();
581
562
  }
582
563
 
583
-
584
-
585
564
  /**
586
565
  * 删除查询分组
587
566
  * @param name 查询分组名称
@@ -607,8 +586,6 @@ export class CallQueryComponent extends LogicItem {
607
586
  return queryGroupByExpression.delete();
608
587
  }
609
588
 
610
-
611
-
612
589
  /**
613
590
  * 删除逻辑项
614
591
  * @param name 逻辑项名称
@@ -634,8 +611,6 @@ export class CallQueryComponent extends LogicItem {
634
611
  return having.delete();
635
612
  }
636
613
 
637
-
638
-
639
614
  /**
640
615
  * 删除查询排序子句
641
616
  * @param queryOrderByExpression 已有的查询排序子句实例
@@ -643,12 +618,10 @@ export class CallQueryComponent extends LogicItem {
643
618
  removeQueryOrderByExpressionInOrderBy(queryOrderByExpression: QueryOrderByExpression): void;
644
619
 
645
620
  removeQueryOrderByExpressionInOrderBy(options: QueryOrderByExpression) {
646
- let queryOrderByExpression: QueryOrderByExpression = options;
621
+ const queryOrderByExpression: QueryOrderByExpression = options;
647
622
  return queryOrderByExpression.delete();
648
623
  }
649
624
 
650
-
651
-
652
625
  /**
653
626
  * 删除查询分页子句
654
627
  * @param name 查询分页子句名称
@@ -750,16 +723,16 @@ export class CallQueryComponent extends LogicItem {
750
723
  if (list.length === 0)
751
724
  return code;
752
725
 
753
- code += indent(state.tabSize + 1) + `.${key}(() => `;
726
+ code += indent((state?.tabSize || 0) + 1) + `.${key}(() => `;
754
727
  list.forEach((item, index) => {
755
728
  if (index > 0)
756
- code += `,\n${indent(state.tabSize + 2)}() => `;
729
+ code += `,\n${indent((state?.tabSize || 0) + 2)}() => `;
757
730
  code += item?.toEmbeddedTS?.(shiftState(state, code, { tabSize: 0 }));
758
731
  });
759
732
  if (list.length > 1) {
760
733
  if (multipleErrorType)
761
- code += `,\n${indent(state.tabSize + 2)}() => ${multipleErrorType}`;
762
- code += `\n${indent(state.tabSize + 1)}`;
734
+ code += `,\n${indent((state?.tabSize || 0) + 2)}() => ${multipleErrorType}`;
735
+ code += `\n${indent((state?.tabSize || 0) + 1)}`;
763
736
  }
764
737
  code += ')\n';
765
738
 
@@ -781,13 +754,44 @@ export class CallQueryComponent extends LogicItem {
781
754
  // })`;
782
755
  }
783
756
 
757
+ isAutoInfer() {
758
+ return this.ideVersion === '2.11';
759
+ }
760
+
784
761
  @withSourceMap()
785
762
  toEmbeddedTS(state?: TranslatorState): string {
786
- let code = `(function(): nasl.collection.PageOf<`;
787
- code += `${this.typeAnnotation.toEmbeddedTS(shiftState(state, code))}> {\n`;
763
+ if (!this.typeAnnotation)
764
+ return `(function () {
765
+ return;
766
+ })()`;
767
+ let code = `(function(): `;
768
+ if (this.isAutoInfer()) {
769
+ code += `${this.typeAnnotation.toEmbeddedTS(shiftState(state, code))} {\n`;
770
+ } else {
771
+ code += `nasl.collection.PageOf<`;
772
+ code += `${this.typeAnnotation.toEmbeddedTS(shiftState(state, code))}> {\n`;
773
+ }
774
+ // 2.11版本后 分组使用别名
775
+ if (this.isAutoInfer()) {
776
+ // 分组别名(列别名)
777
+ this.groupBy.forEach((item, index, array) => {
778
+ code += indent(state.tabSize + 1);
779
+ const groupElement = item.groupElement as QueryFieldExpression;
780
+ if (groupElement.asName)
781
+ code += `const __${groupElement.asName} = `;
782
+ if (groupElement.propertyName) {
783
+ code += groupElement.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
784
+ code += ';\n';
785
+ } else
786
+ code += `__EMPTY_GROUP_BY_NAME__;\n`;
787
+
788
+ if (index === array.length - 1)
789
+ code += '\n';
790
+ });
791
+ }
788
792
  // 聚合属性别名
789
793
  this.select.selectElements.forEach((item, index, array) => {
790
- code += indent(state.tabSize + 1);
794
+ code += indent((state?.tabSize || 0) + 1);
791
795
  const { asName, aggregateName, aggregateParam } = item;
792
796
  if (asName)
793
797
  code += `const __${asName} = `;
@@ -803,9 +807,9 @@ export class CallQueryComponent extends LogicItem {
803
807
  });
804
808
 
805
809
  if (this.from)
806
- code += this.from.toEmbeddedTS(shiftState(state, code, { tabSize: state.tabSize + 1 }));
810
+ code += this.from.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
807
811
  else
808
- code += `${indent(state.tabSize + 1)}nasl.langUtil.FROM()\n`;
812
+ code += `${indent((state?.tabSize || 0) + 1)}nasl.langUtil.FROM()\n`;
809
813
 
810
814
  // where 子句
811
815
  code = this.toEmbeddedTSOfSubPart('WHERE', this.where ? [this.where] : [], {
@@ -821,7 +825,7 @@ export class CallQueryComponent extends LogicItem {
821
825
  });
822
826
 
823
827
  // 分组属性(Group by)
824
- code = this.toEmbeddedTSOfSubPart('GROUP_BY', this.groupBy.map((item) => item.groupElement), {
828
+ code = this.toEmbeddedTSOfSubPart('GROUP_BY', this.groupBy, {
825
829
  code,
826
830
  state,
827
831
  });
@@ -846,75 +850,250 @@ export class CallQueryComponent extends LogicItem {
846
850
  });
847
851
 
848
852
  code += '\n';
849
- code += indent(state.tabSize + 1) + 'return;\n';
850
- code += indent(state.tabSize) + '})();\n';
853
+ code += indent((state?.tabSize || 0) + 1) + 'return;\n';
854
+ code += indent((state?.tabSize || 0)) + '})();\n';
851
855
  return code;
852
856
  }
853
857
 
854
- genStructure() {
855
- const { app } = this;
856
- function genPropertyListOfFrom(node: QueryFromExpression | QueryJoinExpression, entities: any[] = []) {
857
- if (!node)
858
- return [];
859
-
860
- const entityName = node.entityName;
861
- entities.push({
862
- concept: 'StructureProperty',
863
- name: utils.firstLowerCase(entityName),
864
- typeAnnotation: {
865
- concept: 'TypeAnnotation',
866
- typeKind: 'reference',
867
- typeName: entityName,
868
- typeNamespace: `${app.getNamespace()}.entities`,
869
- },
870
- });
858
+ genPropertyListOfFrom(node: QueryFromExpression | QueryJoinExpression, entities: any[] = []) {
859
+ if (!node)
860
+ return [];
871
861
 
872
- for (const sub of node.joinParts) {
873
- genPropertyListOfFrom(sub, entities);
874
- }
862
+ const entityName = node.entityName;
863
+ const entityNamespace = node.entityNamespace;
864
+ entities.push({
865
+ concept: 'StructureProperty',
866
+ name: utils.firstLowerCase(entityName),
867
+ typeAnnotation: {
868
+ concept: 'TypeAnnotation',
869
+ typeKind: 'reference',
870
+ typeName: entityName,
871
+ typeNamespace: entityNamespace,
872
+ },
873
+ });
875
874
 
876
- return entities;
875
+ for (const sub of node.joinParts) {
876
+ this.genPropertyListOfFrom(sub, entities);
877
877
  }
878
878
 
879
- function genPropertyListOfAggregate(node: CallQueryComponent) {
880
- return node.select.selectElements
881
- .filter((item) => item.aggregateName && item.asName)
882
- .map((item) => {
883
- let typeName;
884
- if (['COUNT', 'COUNTD'].includes(item.aggregateName))
885
- typeName = 'Integer';
886
- else {
887
- const { entityAsName, propertyName } = item.aggregateParam;
888
- const entity = app.entities.find((item: Entity) => item.name === entityAsName);
889
- const property = entity?.properties.find((item) => item.name === propertyName);
890
- typeName = property?.typeAnnotation.typeName;
891
- }
892
- return {
893
- concept: 'StructureProperty',
894
- name: item.asName,
895
- typeAnnotation: {
896
- concept: 'TypeAnnotation',
897
- typeKind: 'primitive',
898
- typeNamespace: 'nasl.core',
899
- typeName,
900
- },
901
- };
902
- });
903
- }
879
+ return entities;
880
+ }
881
+
882
+ genPropertyListOfAggregate(node: CallQueryComponent, entities: Entity[]) {
883
+ return node.select.selectElements
884
+ .filter((item) => item.aggregateName && item.asName)
885
+ .map((item) => {
886
+ let typeName;
887
+ if (['COUNT', 'COUNTD'].includes(item.aggregateName)) {
888
+ typeName = 'Integer';
889
+ } else if (['AVG'].includes(item.aggregateName)) {
890
+ typeName = 'Double';
891
+ } else {
892
+ const { entityAsName, propertyName } = item.aggregateParam;
893
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
894
+ const property = entity?.properties.find((item) => item.name === propertyName);
895
+ typeName = property?.typeAnnotation?.typeName;
896
+ }
897
+ return {
898
+ concept: 'StructureProperty',
899
+ name: item.asName,
900
+ typeAnnotation: {
901
+ concept: 'TypeAnnotation',
902
+ typeKind: 'primitive',
903
+ typeNamespace: 'nasl.core',
904
+ typeName,
905
+ },
906
+ };
907
+ });
908
+ }
904
909
 
905
- const structureName = this.typeAnnotation?.typeName || `${utils.firstUpperCase(this.logic.name)}Structure`;
910
+ genPropertyListOfGroupBy(node: CallQueryComponent, entities: Entity[]) {
911
+ return node.groupBy
912
+ .filter((item) => item.groupElement && (item.groupElement as QueryFieldExpression).propertyName && (item.groupElement as QueryFieldExpression).asName)
913
+ .map((item) => {
914
+ const { entityAsName, propertyName, asName } = item.groupElement as QueryFieldExpression;
915
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
916
+ const property = entity?.properties.find((item) => item.name === propertyName);
917
+ const propertyTypeAnnotation = property.typeAnnotation;
918
+
919
+ return {
920
+ concept: 'StructureProperty',
921
+ name: asName,
922
+ typeAnnotation: {
923
+ concept: propertyTypeAnnotation.concept,
924
+ typeKind: propertyTypeAnnotation.typeKind,
925
+ typeName: propertyTypeAnnotation.typeName,
926
+ typeNamespace: propertyTypeAnnotation.typeNamespace,
927
+ },
928
+ };
929
+ });
930
+ }
906
931
 
932
+ genStructure(structureName?: string, properties: any[] = []) {
907
933
  return Structure.from({
908
934
  concept: 'Structure',
909
- name: structureName,
935
+ name: structureName || this.typeAnnotation?.typeName || `${utils.firstUpperCase(this.logic.name)}Structure`,
910
936
  origin: 'CallQueryComponent',
911
- properties: [...genPropertyListOfFrom(this.from), ...genPropertyListOfAggregate(this)],
937
+ properties,
912
938
  });
913
939
  }
914
940
 
915
941
  saveStructure() {
916
- const source = this.genStructure();
917
- // console.log(source);
942
+ // 没有数据源时不初始化数据结构
943
+ if (!this.entityInfos.length) {
944
+ return;
945
+ }
946
+ const entityNamespace = this.from?.entityNamespace;
947
+ const entities = this.app.findNodeByCompleteName(entityNamespace);
948
+ if (!this.isAutoInfer()) {
949
+ // 存量应用走之前的逻辑
950
+ return this.saveStructureNoInfer(entities);
951
+ }
952
+
953
+ const groupBy = this.groupBy;
954
+ const selectElements = this.select.selectElements;
955
+ let structureName;
956
+ let typeAnnotation;
957
+
958
+ // Structures
959
+ if (this.typeAnnotation) {
960
+ const { typeNamespace, typeName, typeArguments } = this.typeAnnotation;
961
+ if (typeNamespace === 'app.structures') {
962
+ structureName = typeName;
963
+ this.removeStructure(structureName);
964
+ } else if (typeNamespace === 'nasl.collection' && typeName === 'PageOf') {
965
+ // PageOf<Structures>
966
+ if (typeArguments[0].typeNamespace === 'app.structures') {
967
+ structureName = typeArguments[0].typeName;
968
+ this.removeStructure(structureName);
969
+ }
970
+ }
971
+ }
972
+
973
+ structureName = structureName || utils.unique(`${utils.firstUpperCase(this.logic.name)}Structure`, this.app.getStructureExistingNames());
974
+ const groupByLength = groupBy.filter((item) => (item.groupElement as QueryFieldExpression)?.propertyName && (item.groupElement as QueryFieldExpression).asName).length;
975
+ const aggregateLength = selectElements.filter((item) => item.aggregateName && item.asName).length;
976
+
977
+
978
+
979
+ // 1. 有分组
980
+ if (groupByLength) {
981
+ if (!aggregateLength && groupByLength === 1) {
982
+ // 1.1 单分组无聚合:`PageOf<列的类型>`
983
+ const { entityAsName, propertyName } = groupBy[0].groupElement as QueryFieldExpression;
984
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
985
+ const property = entity?.properties.find((item: any) => item.name === propertyName);
986
+ const propertyTypeAnnotation = property.typeAnnotation;
987
+
988
+ typeAnnotation = TypeAnnotation.from({
989
+ text: `PageOf<${propertyTypeAnnotation.typeName}>`,
990
+ concept: 'TypeAnnotation',
991
+ typeKind: 'generic',
992
+ typeName: 'PageOf',
993
+ typeNamespace: `nasl.collection`,
994
+ typeArguments: [TypeAnnotation.from({
995
+ concept: propertyTypeAnnotation.concept,
996
+ typeKind: propertyTypeAnnotation.typeKind,
997
+ typeName: propertyTypeAnnotation.typeName,
998
+ typeNamespace: propertyTypeAnnotation.typeNamespace,
999
+ }, this.typeAnnotation, 'typeAnnotation')],
1000
+ }, this, 'typeAnnotation');
1001
+ } else {
1002
+ // 1.2 多分组:`PageOf<Structure>`
1003
+ const structure = this.genStructure(structureName, [
1004
+ ...this.genPropertyListOfGroupBy(this, entities),
1005
+ ...this.genPropertyListOfAggregate(this, entities),
1006
+ ]);
1007
+ this.app.addStructure(structure);
1008
+
1009
+ typeAnnotation = TypeAnnotation.from({
1010
+ text: `PageOf<${structureName}>`,
1011
+ concept: 'TypeAnnotation',
1012
+ typeKind: 'generic',
1013
+ typeName: 'PageOf',
1014
+ typeNamespace: `nasl.collection`,
1015
+ typeArguments: [
1016
+ TypeAnnotation.from({
1017
+ concept: 'TypeAnnotation',
1018
+ typeKind: 'reference',
1019
+ typeName: structureName,
1020
+ typeNamespace: 'app.structures',
1021
+ }, this.typeAnnotation, 'typeAnnotation'),
1022
+ ],
1023
+ }, this, 'typeAnnotation');
1024
+ }
1025
+ } else { // 2. 无分组
1026
+ if (aggregateLength) {
1027
+ if (aggregateLength === 1) {
1028
+ // 2.1 单聚合:`基本类型`
1029
+ let typeName;
1030
+ if (['COUNT', 'COUNTD'].includes(selectElements[0].aggregateName)) {
1031
+ // 2.1.1. `COUNT`、`COUNTD` 返回 `Integer`
1032
+ typeName = 'Integer';
1033
+ } else if (['AVG'].includes(selectElements[0].aggregateName)) {
1034
+ // 2.1.2. `AVG` 返回 `Double`
1035
+ typeName = 'Double';
1036
+ } else {
1037
+ // 2.1.3. 其他返回列类型,包含:`Integer`、`Long`、`Double`
1038
+ const { entityAsName, propertyName } = selectElements[0].aggregateParam;
1039
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
1040
+ const property = entity?.properties.find((item: any) => item.name === propertyName);
1041
+ typeName = property?.typeAnnotation?.typeName;
1042
+ }
1043
+ typeAnnotation = TypeAnnotation.from({
1044
+ concept: 'TypeAnnotation',
1045
+ typeKind: 'primitive',
1046
+ typeName,
1047
+ typeNamespace: 'nasl.core',
1048
+ }, this, 'typeAnnotation');
1049
+ } else {
1050
+ // 2.2. 多聚合:`Structure`(自动创建 `Structure`)
1051
+ const structure = this.genStructure(structureName, [
1052
+ ...this.genPropertyListOfAggregate(this, entities),
1053
+ ]);
1054
+ this.app.addStructure(structure);
1055
+
1056
+ typeAnnotation = TypeAnnotation.from({
1057
+ concept: 'TypeAnnotation',
1058
+ typeKind: 'reference',
1059
+ typeName: structureName,
1060
+ typeNamespace: `app.structures`,
1061
+ }, this, 'typeAnnotation');
1062
+ }
1063
+ } else {
1064
+ // 2.3. 无聚合(默认情况):`PageOf<Structure>`(自动创建 `Structure`)
1065
+ const structure = this.genStructure(structureName, [
1066
+ ...this.genPropertyListOfFrom(this.from),
1067
+ ...this.genPropertyListOfAggregate(this, entities),
1068
+ ]);
1069
+ this.app.addStructure(structure);
1070
+
1071
+ typeAnnotation = TypeAnnotation.from({
1072
+ text: structureName,
1073
+ concept: 'TypeAnnotation',
1074
+ typeKind: 'generic',
1075
+ typeName: 'PageOf',
1076
+ typeNamespace: `nasl.collection`,
1077
+ typeArguments: [
1078
+ TypeAnnotation.from({
1079
+ concept: 'TypeAnnotation',
1080
+ typeKind: 'reference',
1081
+ typeName: structureName,
1082
+ typeNamespace: 'app.structures',
1083
+ }, this.typeAnnotation, 'typeAnnotation'),
1084
+ ],
1085
+ }, this, 'typeAnnotation');
1086
+ }
1087
+ }
1088
+
1089
+ this.update({ typeAnnotation });
1090
+ }
1091
+
1092
+ saveStructureNoInfer(entities: any[] = []) {
1093
+ const source = this.genStructure(null, [
1094
+ ...this.genPropertyListOfFrom(this.from),
1095
+ ...this.genPropertyListOfAggregate(this, entities),
1096
+ ]);
918
1097
  if (this.typeAnnotation) {
919
1098
  const structure = this.app.structures.find((item) => item.name === this.typeAnnotation.typeName);
920
1099
  if (structure) {
@@ -939,59 +1118,80 @@ export class CallQueryComponent extends LogicItem {
939
1118
  }
940
1119
  }
941
1120
 
942
- removeStructure() {
1121
+ removeStructure(structureName?: string) {
943
1122
  try {
944
- this.app.removeStructure(this.typeAnnotation?.typeName);
1123
+ if (this.typeAnnotation) {
1124
+ const { typeNamespace, typeName, typeArguments } = this.typeAnnotation;
1125
+ if (typeNamespace === 'app.structures') {
1126
+ // Structures
1127
+ structureName = typeName;
1128
+ this.app.removeStructure(structureName);
1129
+ } else if (typeNamespace === 'nasl.collection' && typeName === 'PageOf') {
1130
+ // PageOf<Structures>
1131
+ if (typeArguments[0].typeNamespace === 'app.structures') {
1132
+ structureName = typeArguments[0].typeName;
1133
+ this.app.removeStructure(structureName);
1134
+ }
1135
+ }
1136
+ }
945
1137
  } catch {}
946
1138
  }
947
1139
 
948
- getEntityNames(node: QueryFromExpression | QueryJoinExpression, set = new Set()) {
1140
+ getEntityInfos(node: QueryFromExpression | QueryJoinExpression, set = new Set()) {
949
1141
  if (node?.entityName)
950
- set.add(node.entityName);
1142
+ set.add({
1143
+ namespace: node.entityNamespace,
1144
+ name: node.entityName,
1145
+ });
951
1146
 
952
1147
  node?.joinParts?.forEach((child) => {
953
- this.getEntityNames(child, set);
1148
+ this.getEntityInfos(child, set);
954
1149
  });
955
1150
  return Array.from(set);
956
1151
  }
957
1152
 
958
- get entityNames() {
959
- return this.getEntityNames(this.from);
1153
+ get entityInfos() {
1154
+ return this.getEntityInfos(this.from);
960
1155
  }
961
1156
 
962
1157
  getCompletionPropertyOfEntities() {
963
- const entities = this.app.entities;
964
- const children = this.entityNames
965
- .map((name) => entities.find((item) => item.name === name))
966
- .filter((item) => item)
967
- .map((entity) => ({
968
- concept: 'Entity',
969
- name: entity.name,
970
- children: entity.properties.map((property) => {
971
- const completionProperty = new CompletionProperty({
972
- concept: 'CompletionProperty',
973
- name: property.name,
974
- value: `${entity.name}.${property.name}`,
975
- expression: LogicItem.from({
976
- concept: 'QueryFieldExpression',
977
- name: property.name,
978
- value: `${entity.name}.${property.name}`,
979
- entityAsName: entity.name,
980
- propertyName: property.name,
1158
+ const firstEntityInfo: any = this.entityInfos[0];
1159
+ if (firstEntityInfo) {
1160
+ const namespace = firstEntityInfo.namespace;
1161
+ const entities: Entity[] = this.app.findNodeByCompleteName(namespace);
1162
+ if (Array.isArray(entities)) {
1163
+ const children = this.entityInfos
1164
+ .map(({ name }) => entities.find((item) => item.name === name))
1165
+ .filter((item) => item)
1166
+ .map((entity) => ({
1167
+ concept: 'Entity',
1168
+ name: entity.name,
1169
+ children: entity.properties.map((property) => {
1170
+ const completionProperty = new CompletionProperty({
1171
+ concept: 'CompletionProperty',
1172
+ name: property.name,
1173
+ value: `${entity.name}.${property.name}`,
1174
+ expression: LogicItem.from({
1175
+ concept: 'QueryFieldExpression',
1176
+ name: property.name,
1177
+ value: `${entity.name}.${property.name}`,
1178
+ entityAsName: entity.name,
1179
+ propertyName: property.name,
1180
+ }),
1181
+ });
1182
+ completionProperty.icon = 'property';
1183
+ return completionProperty;
981
1184
  }),
982
- });
983
- completionProperty.icon = 'property';
984
- return completionProperty;
985
- }),
986
- }));
987
- if (children.length === 0)
988
- return;
989
-
990
- return {
991
- name: '实体',
992
- icon: 'category',
993
- children,
994
- };
1185
+ }));
1186
+ if (children.length) {
1187
+ return {
1188
+ name: '实体',
1189
+ icon: 'category',
1190
+ children,
1191
+ };
1192
+ }
1193
+ }
1194
+ }
995
1195
  }
996
1196
 
997
1197
  getCompletionPropertyOfAggregateAsNames() {
@@ -1017,13 +1217,36 @@ export class CallQueryComponent extends LogicItem {
1017
1217
  return { name: '聚合属性别名', icon: 'category', children, expanded: true };
1018
1218
  }
1019
1219
 
1220
+ getCompletionPropertyOfGroupByAsNames() {
1221
+ const children = this.groupBy
1222
+ ?.filter((item) => item.concept === 'QueryGroupByExpression' && (item.groupElement as QueryFieldExpression)?.asName)
1223
+ .map((item) =>
1224
+ new CompletionProperty({
1225
+ concept: 'CompletionProperty',
1226
+ name: (item.groupElement as QueryFieldExpression).asName,
1227
+ value: `inner.${(item.groupElement as QueryFieldExpression).asName}`,
1228
+ expression: LogicItem.from({
1229
+ concept: 'Identifier',
1230
+ name: (item.groupElement as QueryFieldExpression).asName,
1231
+ namespace: 'inner',
1232
+ }),
1233
+ }));
1234
+ if (!children || children.length === 0)
1235
+ return;
1236
+
1237
+ children.forEach((item) => {
1238
+ item.icon = 'variable';
1239
+ });
1240
+ return { name: '分组属性别名', icon: 'category', children, expanded: true };
1241
+ }
1242
+
1020
1243
  //================================================================================
1021
1244
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
1022
1245
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
1023
1246
  //================================================================================
1024
1247
  }
1025
1248
 
1026
- classMap['CallQueryComponent'] = CallQueryComponent;
1249
+ classMap.CallQueryComponent = CallQueryComponent;
1027
1250
  export default CallQueryComponent;
1028
1251
  //================================================================================
1029
1252
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑