@lcap/nasl 3.2.0-beta.3 → 3.3.0-alpha

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 (842) hide show
  1. package/out/automate/engine/utils.js +4 -0
  2. package/out/automate/engine/utils.js.map +1 -1
  3. package/out/automate/upgrader/2.20.js +1 -1
  4. package/out/automate/upgrader/2.20.js.map +1 -1
  5. package/out/bak/translator.js +11 -15
  6. package/out/bak/translator.js.map +1 -1
  7. package/out/breakpoint/generator/AfterStartNode.js +3 -1
  8. package/out/breakpoint/generator/AfterStartNode.js.map +1 -1
  9. package/out/breakpoint/generator/BeforeEndNode.js.map +1 -1
  10. package/out/breakpoint/generator/BreakpointNode.d.ts +1 -0
  11. package/out/breakpoint/generator/BreakpointNode.js +48 -15
  12. package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
  13. package/out/breakpoint/generator/CallbackNode.d.ts +4 -0
  14. package/out/breakpoint/generator/CallbackNode.js +22 -0
  15. package/out/breakpoint/generator/CallbackNode.js.map +1 -0
  16. package/out/breakpoint/generator/FragmentNode.d.ts +4 -0
  17. package/out/breakpoint/generator/FragmentNode.js +18 -0
  18. package/out/breakpoint/generator/FragmentNode.js.map +1 -0
  19. package/out/breakpoint/generator/index.js +25 -4
  20. package/out/breakpoint/generator/index.js.map +1 -1
  21. package/out/breakpoint/shared/constants.d.ts +3 -0
  22. package/out/breakpoint/shared/constants.js +6 -1
  23. package/out/breakpoint/shared/constants.js.map +1 -1
  24. package/out/breakpoint/shared/operations.js.map +1 -1
  25. package/out/breakpoint/shared/socket.d.ts +1 -1
  26. package/out/breakpoint/shared/socket.js +36 -7
  27. package/out/breakpoint/shared/socket.js.map +1 -1
  28. package/out/breakpoint/shared/utils.d.ts +2 -0
  29. package/out/breakpoint/shared/utils.js +15 -2
  30. package/out/breakpoint/shared/utils.js.map +1 -1
  31. package/out/breakpoint/store/core.d.ts +48 -2
  32. package/out/breakpoint/store/core.js +58 -32
  33. package/out/breakpoint/store/core.js.map +1 -1
  34. package/out/breakpoint/store/dock.js +1 -1
  35. package/out/breakpoint/store/dock.js.map +1 -1
  36. package/out/common/BaseNode.d.ts +2 -2
  37. package/out/common/BaseNode.js +110 -53
  38. package/out/common/BaseNode.js.map +1 -1
  39. package/out/common/Command.d.ts +13 -2
  40. package/out/common/Command.js +37 -9
  41. package/out/common/Command.js.map +1 -1
  42. package/out/common/EventEmitter.js.map +1 -1
  43. package/out/common/Messager.d.ts +3 -3
  44. package/out/common/Messager.js +6 -7
  45. package/out/common/Messager.js.map +1 -1
  46. package/out/common/asyncFuncMap.js.map +1 -1
  47. package/out/concepts/Abort__.js +6 -5
  48. package/out/concepts/Abort__.js.map +1 -1
  49. package/out/concepts/Anchor__.d.ts +4 -3
  50. package/out/concepts/Anchor__.js +24 -7
  51. package/out/concepts/Anchor__.js.map +1 -1
  52. package/out/concepts/AnonymousFunction__.d.ts +22 -21
  53. package/out/concepts/AnonymousFunction__.js +48 -22
  54. package/out/concepts/AnonymousFunction__.js.map +1 -1
  55. package/out/concepts/App__.d.ts +421 -247
  56. package/out/concepts/App__.js +288 -54
  57. package/out/concepts/App__.js.map +1 -1
  58. package/out/concepts/Argument__.d.ts +4 -3
  59. package/out/concepts/Argument__.js +42 -11
  60. package/out/concepts/Argument__.js.map +1 -1
  61. package/out/concepts/Assignee__.d.ts +45 -45
  62. package/out/concepts/Assignee__.js +15 -15
  63. package/out/concepts/Assignee__.js.map +1 -1
  64. package/out/concepts/AssignmentLine__.js +6 -5
  65. package/out/concepts/AssignmentLine__.js.map +1 -1
  66. package/out/concepts/Assignment__.d.ts +7 -6
  67. package/out/concepts/Assignment__.js +41 -23
  68. package/out/concepts/Assignment__.js.map +1 -1
  69. package/out/concepts/Attribute__.d.ts +3 -3
  70. package/out/concepts/Attribute__.js +8 -7
  71. package/out/concepts/Attribute__.js.map +1 -1
  72. package/out/concepts/AuthInterface__.js +4 -3
  73. package/out/concepts/AuthInterface__.js.map +1 -1
  74. package/out/concepts/AuthLogicForCallInterface__.d.ts +15 -15
  75. package/out/concepts/AuthLogicForCallInterface__.js +46 -27
  76. package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
  77. package/out/concepts/AuthLogic__.js +27 -13
  78. package/out/concepts/AuthLogic__.js.map +1 -1
  79. package/out/concepts/BackendVariable__.d.ts +5 -5
  80. package/out/concepts/BackendVariable__.js +23 -26
  81. package/out/concepts/BackendVariable__.js.map +1 -1
  82. package/out/concepts/Backend__.d.ts +18 -18
  83. package/out/concepts/Backend__.js +13 -13
  84. package/out/concepts/Backend__.js.map +1 -1
  85. package/out/concepts/BatchAssignment__.d.ts +34 -33
  86. package/out/concepts/BatchAssignment__.js +83 -43
  87. package/out/concepts/BatchAssignment__.js.map +1 -1
  88. package/out/concepts/BinaryExpression__.d.ts +7 -6
  89. package/out/concepts/BinaryExpression__.js +60 -24
  90. package/out/concepts/BinaryExpression__.js.map +1 -1
  91. package/out/concepts/BindAttribute__.d.ts +37 -37
  92. package/out/concepts/BindAttribute__.js +102 -58
  93. package/out/concepts/BindAttribute__.js.map +1 -1
  94. package/out/concepts/BindDirective__.d.ts +13 -13
  95. package/out/concepts/BindDirective__.js +23 -21
  96. package/out/concepts/BindDirective__.js.map +1 -1
  97. package/out/concepts/BindEvent__.d.ts +28 -28
  98. package/out/concepts/BindEvent__.js +150 -57
  99. package/out/concepts/BindEvent__.js.map +1 -1
  100. package/out/concepts/BindStyle__.d.ts +14 -15
  101. package/out/concepts/BindStyle__.js +16 -16
  102. package/out/concepts/BindStyle__.js.map +1 -1
  103. package/out/concepts/BooleanLiteral__.d.ts +1 -0
  104. package/out/concepts/BooleanLiteral__.js +12 -5
  105. package/out/concepts/BooleanLiteral__.js.map +1 -1
  106. package/out/concepts/CallAuthInterface__.d.ts +15 -15
  107. package/out/concepts/CallAuthInterface__.js +23 -22
  108. package/out/concepts/CallAuthInterface__.js.map +1 -1
  109. package/out/concepts/CallConnector__.d.ts +11 -9
  110. package/out/concepts/CallConnector__.js +79 -36
  111. package/out/concepts/CallConnector__.js.map +1 -1
  112. package/out/concepts/CallFunction__.d.ts +17 -16
  113. package/out/concepts/CallFunction__.js +95 -63
  114. package/out/concepts/CallFunction__.js.map +1 -1
  115. package/out/concepts/CallInterface__.d.ts +9 -8
  116. package/out/concepts/CallInterface__.js +109 -80
  117. package/out/concepts/CallInterface__.js.map +1 -1
  118. package/out/concepts/CallLogic__.d.ts +24 -20
  119. package/out/concepts/CallLogic__.js +209 -162
  120. package/out/concepts/CallLogic__.js.map +1 -1
  121. package/out/concepts/CallQueryComponent__.d.ts +51 -51
  122. package/out/concepts/CallQueryComponent__.js +66 -63
  123. package/out/concepts/CallQueryComponent__.js.map +1 -1
  124. package/out/concepts/Comment__.d.ts +1 -0
  125. package/out/concepts/Comment__.js +13 -6
  126. package/out/concepts/Comment__.js.map +1 -1
  127. package/out/concepts/CompletionProperty__.d.ts +3 -3
  128. package/out/concepts/CompletionProperty__.js +16 -8
  129. package/out/concepts/CompletionProperty__.js.map +1 -1
  130. package/out/concepts/ConfigGroup__.d.ts +15 -15
  131. package/out/concepts/ConfigGroup__.js +9 -9
  132. package/out/concepts/ConfigGroup__.js.map +1 -1
  133. package/out/concepts/ConfigPropertyValue__.js +4 -3
  134. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  135. package/out/concepts/ConfigProperty__.d.ts +15 -15
  136. package/out/concepts/ConfigProperty__.js +10 -10
  137. package/out/concepts/ConfigProperty__.js.map +1 -1
  138. package/out/concepts/Configuration__.d.ts +15 -15
  139. package/out/concepts/Configuration__.js +9 -9
  140. package/out/concepts/Configuration__.js.map +1 -1
  141. package/out/concepts/Connection__.d.ts +166 -0
  142. package/out/concepts/Connection__.js +332 -0
  143. package/out/concepts/Connection__.js.map +1 -0
  144. package/out/concepts/ConnectorTrigger__.js +4 -3
  145. package/out/concepts/ConnectorTrigger__.js.map +1 -1
  146. package/out/concepts/Connector__.d.ts +66 -66
  147. package/out/concepts/Connector__.js +16 -15
  148. package/out/concepts/Connector__.js.map +1 -1
  149. package/out/concepts/Constant__.d.ts +3 -3
  150. package/out/concepts/Constant__.js +8 -7
  151. package/out/concepts/Constant__.js.map +1 -1
  152. package/out/concepts/DataElement__.d.ts +3 -3
  153. package/out/concepts/DataElement__.js +6 -5
  154. package/out/concepts/DataElement__.js.map +1 -1
  155. package/out/concepts/DataSource__.d.ts +15 -15
  156. package/out/concepts/DataSource__.js +55 -39
  157. package/out/concepts/DataSource__.js.map +1 -1
  158. package/out/concepts/DatabaseTypeAnnotation__.js +4 -3
  159. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
  160. package/out/concepts/Destination__.d.ts +12 -11
  161. package/out/concepts/Destination__.js +93 -36
  162. package/out/concepts/Destination__.js.map +1 -1
  163. package/out/concepts/End__.js +15 -13
  164. package/out/concepts/End__.js.map +1 -1
  165. package/out/concepts/EntityIndex__.d.ts +1 -1
  166. package/out/concepts/EntityIndex__.js +6 -5
  167. package/out/concepts/EntityIndex__.js.map +1 -1
  168. package/out/concepts/EntityProperty__.d.ts +8 -7
  169. package/out/concepts/EntityProperty__.js +39 -24
  170. package/out/concepts/EntityProperty__.js.map +1 -1
  171. package/out/concepts/Entity__.d.ts +31 -30
  172. package/out/concepts/Entity__.js +40 -16
  173. package/out/concepts/Entity__.js.map +1 -1
  174. package/out/concepts/EnumItem__.d.ts +1 -0
  175. package/out/concepts/EnumItem__.js +12 -5
  176. package/out/concepts/EnumItem__.js.map +1 -1
  177. package/out/concepts/Enum__.d.ts +9 -8
  178. package/out/concepts/Enum__.js +24 -11
  179. package/out/concepts/Enum__.js.map +1 -1
  180. package/out/concepts/Event__.d.ts +15 -15
  181. package/out/concepts/Event__.js +6 -5
  182. package/out/concepts/Event__.js.map +1 -1
  183. package/out/concepts/ExternalDestination__.d.ts +6 -6
  184. package/out/concepts/ExternalDestination__.js +12 -11
  185. package/out/concepts/ExternalDestination__.js.map +1 -1
  186. package/out/concepts/ForEachStatement__.d.ts +25 -24
  187. package/out/concepts/ForEachStatement__.js +101 -36
  188. package/out/concepts/ForEachStatement__.js.map +1 -1
  189. package/out/concepts/FrontendLibrary__.d.ts +30 -30
  190. package/out/concepts/FrontendLibrary__.js +12 -13
  191. package/out/concepts/FrontendLibrary__.js.map +1 -1
  192. package/out/concepts/FrontendVariable__.js +4 -3
  193. package/out/concepts/FrontendVariable__.js.map +1 -1
  194. package/out/concepts/Frontend__.d.ts +64 -65
  195. package/out/concepts/Frontend__.js +23 -27
  196. package/out/concepts/Frontend__.js.map +1 -1
  197. package/out/concepts/Function__.d.ts +64 -63
  198. package/out/concepts/Function__.js +49 -21
  199. package/out/concepts/Function__.js.map +1 -1
  200. package/out/concepts/Identifier__.js +37 -31
  201. package/out/concepts/Identifier__.js.map +1 -1
  202. package/out/concepts/IfStatement__.d.ts +20 -19
  203. package/out/concepts/IfStatement__.js +64 -34
  204. package/out/concepts/IfStatement__.js.map +1 -1
  205. package/out/concepts/Integration__.d.ts +3 -3
  206. package/out/concepts/Integration__.js +8 -7
  207. package/out/concepts/Integration__.js.map +1 -1
  208. package/out/concepts/InterfaceParam__.d.ts +3 -3
  209. package/out/concepts/InterfaceParam__.js +7 -6
  210. package/out/concepts/InterfaceParam__.js.map +1 -1
  211. package/out/concepts/Interface__.d.ts +33 -33
  212. package/out/concepts/Interface__.js +19 -20
  213. package/out/concepts/Interface__.js.map +1 -1
  214. package/out/concepts/JSBlock__.d.ts +1 -0
  215. package/out/concepts/JSBlock__.js +12 -5
  216. package/out/concepts/JSBlock__.js.map +1 -1
  217. package/out/concepts/JavaLogic__.js +10 -9
  218. package/out/concepts/JavaLogic__.js.map +1 -1
  219. package/out/concepts/LogicItem__.d.ts +6 -0
  220. package/out/concepts/LogicItem__.js +14 -5
  221. package/out/concepts/LogicItem__.js.map +1 -1
  222. package/out/concepts/Logic__.d.ts +80 -79
  223. package/out/concepts/Logic__.js +204 -58
  224. package/out/concepts/Logic__.js.map +1 -1
  225. package/out/concepts/MatchCase__.d.ts +39 -38
  226. package/out/concepts/MatchCase__.js +122 -37
  227. package/out/concepts/MatchCase__.js.map +1 -1
  228. package/out/concepts/Match__.d.ts +13 -11
  229. package/out/concepts/Match__.js +128 -60
  230. package/out/concepts/Match__.js.map +1 -1
  231. package/out/concepts/MemberExpression__.d.ts +7 -6
  232. package/out/concepts/MemberExpression__.js +52 -22
  233. package/out/concepts/MemberExpression__.js.map +1 -1
  234. package/out/concepts/MicroApp__.js +4 -3
  235. package/out/concepts/MicroApp__.js.map +1 -1
  236. package/out/concepts/Module__.d.ts +242 -154
  237. package/out/concepts/Module__.js +139 -33
  238. package/out/concepts/Module__.js.map +1 -1
  239. package/out/concepts/MsgTriggerEvent__.d.ts +15 -15
  240. package/out/concepts/MsgTriggerEvent__.js +6 -5
  241. package/out/concepts/MsgTriggerEvent__.js.map +1 -1
  242. package/out/concepts/MsgTriggerLauncher__.d.ts +23 -15
  243. package/out/concepts/MsgTriggerLauncher__.js +24 -5
  244. package/out/concepts/MsgTriggerLauncher__.js.map +1 -1
  245. package/out/concepts/Namespace__.d.ts +180 -180
  246. package/out/concepts/Namespace__.js +33 -34
  247. package/out/concepts/Namespace__.js.map +1 -1
  248. package/out/concepts/NewComposite__.d.ts +49 -48
  249. package/out/concepts/NewComposite__.js +164 -49
  250. package/out/concepts/NewComposite__.js.map +1 -1
  251. package/out/concepts/NewList__.d.ts +19 -18
  252. package/out/concepts/NewList__.js +29 -12
  253. package/out/concepts/NewList__.js.map +1 -1
  254. package/out/concepts/NewMap__.d.ts +34 -33
  255. package/out/concepts/NewMap__.js +81 -72
  256. package/out/concepts/NewMap__.js.map +1 -1
  257. package/out/concepts/New__.js +6 -5
  258. package/out/concepts/New__.js.map +1 -1
  259. package/out/concepts/NullLiteral__.js +6 -5
  260. package/out/concepts/NullLiteral__.js.map +1 -1
  261. package/out/concepts/NumericLiteral__.d.ts +4 -3
  262. package/out/concepts/NumericLiteral__.js +15 -8
  263. package/out/concepts/NumericLiteral__.js.map +1 -1
  264. package/out/concepts/OqlQueryComponent__.d.ts +4 -3
  265. package/out/concepts/OqlQueryComponent__.js +25 -16
  266. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  267. package/out/concepts/OverriddenLogic__.d.ts +79 -79
  268. package/out/concepts/OverriddenLogic__.js +79 -58
  269. package/out/concepts/OverriddenLogic__.js.map +1 -1
  270. package/out/concepts/Param__.d.ts +6 -5
  271. package/out/concepts/Param__.js +66 -29
  272. package/out/concepts/Param__.js.map +1 -1
  273. package/out/concepts/Point__.js +4 -3
  274. package/out/concepts/Point__.js.map +1 -1
  275. package/out/concepts/ProcessComponent__.d.ts +30 -30
  276. package/out/concepts/ProcessComponent__.js +8 -7
  277. package/out/concepts/ProcessComponent__.js.map +1 -1
  278. package/out/concepts/ProcessElement__.d.ts +96 -96
  279. package/out/concepts/ProcessElement__.js +34 -34
  280. package/out/concepts/ProcessElement__.js.map +1 -1
  281. package/out/concepts/ProcessOutcome__.js +6 -5
  282. package/out/concepts/ProcessOutcome__.js.map +1 -1
  283. package/out/concepts/ProcessOutcomes__.js +6 -5
  284. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  285. package/out/concepts/Process__.d.ts +75 -75
  286. package/out/concepts/Process__.js +33 -30
  287. package/out/concepts/Process__.js.map +1 -1
  288. package/out/concepts/QueryAggregateExpression__.d.ts +3 -3
  289. package/out/concepts/QueryAggregateExpression__.js +8 -7
  290. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  291. package/out/concepts/QueryFieldExpression__.js +7 -6
  292. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  293. package/out/concepts/QueryFromExpression__.d.ts +8 -8
  294. package/out/concepts/QueryFromExpression__.js +8 -7
  295. package/out/concepts/QueryFromExpression__.js.map +1 -1
  296. package/out/concepts/QueryGroupByExpression__.d.ts +3 -3
  297. package/out/concepts/QueryGroupByExpression__.js +9 -10
  298. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  299. package/out/concepts/QueryJoinExpression__.d.ts +23 -23
  300. package/out/concepts/QueryJoinExpression__.js +11 -10
  301. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  302. package/out/concepts/QueryLimitExpression__.d.ts +6 -6
  303. package/out/concepts/QueryLimitExpression__.js +9 -8
  304. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  305. package/out/concepts/QueryOrderByExpression__.d.ts +6 -6
  306. package/out/concepts/QueryOrderByExpression__.js +9 -8
  307. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  308. package/out/concepts/QuerySelectExpression__.d.ts +30 -30
  309. package/out/concepts/QuerySelectExpression__.js +9 -8
  310. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  311. package/out/concepts/Rect__.js +4 -3
  312. package/out/concepts/Rect__.js.map +1 -1
  313. package/out/concepts/Return__.d.ts +4 -3
  314. package/out/concepts/Return__.js +37 -18
  315. package/out/concepts/Return__.js.map +1 -1
  316. package/out/concepts/Role__.js +9 -9
  317. package/out/concepts/Role__.js.map +1 -1
  318. package/out/concepts/SelectMembers__.d.ts +18 -18
  319. package/out/concepts/SelectMembers__.js +10 -9
  320. package/out/concepts/SelectMembers__.js.map +1 -1
  321. package/out/concepts/Slot__.d.ts +3 -3
  322. package/out/concepts/Slot__.js +6 -5
  323. package/out/concepts/Slot__.js.map +1 -1
  324. package/out/concepts/SqlQueryComponent__.d.ts +4 -3
  325. package/out/concepts/SqlQueryComponent__.js +21 -12
  326. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  327. package/out/concepts/Start__.js +6 -5
  328. package/out/concepts/Start__.js.map +1 -1
  329. package/out/concepts/StringInterpolation__.d.ts +16 -15
  330. package/out/concepts/StringInterpolation__.js +37 -14
  331. package/out/concepts/StringInterpolation__.js.map +1 -1
  332. package/out/concepts/StringLiteral__.d.ts +1 -0
  333. package/out/concepts/StringLiteral__.js +13 -8
  334. package/out/concepts/StringLiteral__.js.map +1 -1
  335. package/out/concepts/StructureProperty__.d.ts +4 -3
  336. package/out/concepts/StructureProperty__.js +22 -9
  337. package/out/concepts/StructureProperty__.js.map +1 -1
  338. package/out/concepts/Structure__.d.ts +31 -30
  339. package/out/concepts/Structure__.js +27 -15
  340. package/out/concepts/Structure__.js.map +1 -1
  341. package/out/concepts/SwitchCase__.d.ts +12 -11
  342. package/out/concepts/SwitchCase__.js +69 -31
  343. package/out/concepts/SwitchCase__.js.map +1 -1
  344. package/out/concepts/SwitchStatement__.d.ts +9 -8
  345. package/out/concepts/SwitchStatement__.js +27 -7
  346. package/out/concepts/SwitchStatement__.js.map +1 -1
  347. package/out/concepts/Theme__.js +4 -3
  348. package/out/concepts/Theme__.js.map +1 -1
  349. package/out/concepts/Transactional__.js +4 -3
  350. package/out/concepts/Transactional__.js.map +1 -1
  351. package/out/concepts/TriggerEvent__.d.ts +15 -15
  352. package/out/concepts/TriggerEvent__.js +6 -5
  353. package/out/concepts/TriggerEvent__.js.map +1 -1
  354. package/out/concepts/TriggerLauncher__.d.ts +15 -10
  355. package/out/concepts/TriggerLauncher__.js +54 -32
  356. package/out/concepts/TriggerLauncher__.js.map +1 -1
  357. package/out/concepts/TypeAnnotation__.d.ts +28 -27
  358. package/out/concepts/TypeAnnotation__.js +144 -124
  359. package/out/concepts/TypeAnnotation__.js.map +1 -1
  360. package/out/concepts/TypeParam__.d.ts +1 -0
  361. package/out/concepts/TypeParam__.js +12 -5
  362. package/out/concepts/TypeParam__.js.map +1 -1
  363. package/out/concepts/UnaryExpression__.d.ts +4 -3
  364. package/out/concepts/UnaryExpression__.js +31 -20
  365. package/out/concepts/UnaryExpression__.js.map +1 -1
  366. package/out/concepts/Unparsed__.d.ts +1 -0
  367. package/out/concepts/Unparsed__.js +12 -5
  368. package/out/concepts/Unparsed__.js.map +1 -1
  369. package/out/concepts/UseComponent__.js +4 -3
  370. package/out/concepts/UseComponent__.js.map +1 -1
  371. package/out/concepts/ValidationRule__.d.ts +14 -14
  372. package/out/concepts/ValidationRule__.js +19 -17
  373. package/out/concepts/ValidationRule__.js.map +1 -1
  374. package/out/concepts/Variable__.d.ts +4 -3
  375. package/out/concepts/Variable__.js +39 -23
  376. package/out/concepts/Variable__.js.map +1 -1
  377. package/out/concepts/ViewBlock__.js +4 -3
  378. package/out/concepts/ViewBlock__.js.map +1 -1
  379. package/out/concepts/ViewComponent__.d.ts +90 -90
  380. package/out/concepts/ViewComponent__.js +16 -15
  381. package/out/concepts/ViewComponent__.js.map +1 -1
  382. package/out/concepts/ViewElement__.d.ts +92 -86
  383. package/out/concepts/ViewElement__.js +258 -200
  384. package/out/concepts/ViewElement__.js.map +1 -1
  385. package/out/concepts/View__.d.ts +92 -92
  386. package/out/concepts/View__.js +173 -63
  387. package/out/concepts/View__.js.map +1 -1
  388. package/out/concepts/WhileStatement__.d.ts +12 -11
  389. package/out/concepts/WhileStatement__.js +46 -23
  390. package/out/concepts/WhileStatement__.js.map +1 -1
  391. package/out/concepts/basics/stdlib/index.js +17 -1
  392. package/out/concepts/basics/stdlib/index.js.map +1 -1
  393. package/out/concepts/basics/stdlib/nasl.browser.js +36 -0
  394. package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
  395. package/out/concepts/basics/stdlib/nasl.event.d.ts +3 -0
  396. package/out/concepts/basics/stdlib/nasl.event.js +23 -0
  397. package/out/concepts/basics/stdlib/nasl.event.js.map +1 -0
  398. package/out/concepts/basics/stdlib/nasl.ui.js +45 -0
  399. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  400. package/out/concepts/basics/stdlib/nasl.util.js +6 -22
  401. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  402. package/out/concepts/index__.d.ts +2 -1
  403. package/out/concepts/index__.js +2 -1
  404. package/out/concepts/index__.js.map +1 -1
  405. package/out/concepts/types__.d.ts +2 -1
  406. package/out/decorators/index.d.ts +1 -1
  407. package/out/decorators/index.js +20 -7
  408. package/out/decorators/index.js.map +1 -1
  409. package/out/decorators/promise.d.ts +7 -0
  410. package/out/decorators/promise.js +28 -0
  411. package/out/decorators/promise.js.map +1 -0
  412. package/out/enums/KEYWORDS.js.map +1 -1
  413. package/out/enums/LEVEL_NAME_MAP.js.map +1 -1
  414. package/out/generator/compileComponent.js.map +1 -1
  415. package/out/generator/genBundleFiles.d.ts +4 -1
  416. package/out/generator/genBundleFiles.js +15 -11
  417. package/out/generator/genBundleFiles.js.map +1 -1
  418. package/out/generator/genHash.js.map +1 -1
  419. package/out/generator/genMetaData.js +12 -8
  420. package/out/generator/genMetaData.js.map +1 -1
  421. package/out/generator/genReleaseBody.js +33 -35
  422. package/out/generator/genReleaseBody.js.map +1 -1
  423. package/out/generator/microApp.js +2 -1
  424. package/out/generator/microApp.js.map +1 -1
  425. package/out/generator/permission.js +31 -30
  426. package/out/generator/permission.js.map +1 -1
  427. package/out/generator/styleReplacer.js +4 -7
  428. package/out/generator/styleReplacer.js.map +1 -1
  429. package/out/index.d.ts +0 -2
  430. package/out/index.js +0 -3
  431. package/out/index.js.map +1 -1
  432. package/out/manager/diagnostic.d.ts +1 -1
  433. package/out/manager/diagnostic.js.map +1 -1
  434. package/out/manager/stepRecorder.js +13 -9
  435. package/out/manager/stepRecorder.js.map +1 -1
  436. package/out/natural/RequirementAnalyzer.d.ts +22 -0
  437. package/out/natural/RequirementAnalyzer.js +196 -0
  438. package/out/natural/RequirementAnalyzer.js.map +1 -0
  439. package/out/natural/RequirementExecutor.d.ts +51 -0
  440. package/out/natural/RequirementExecutor.js +692 -0
  441. package/out/natural/RequirementExecutor.js.map +1 -0
  442. package/out/natural/componentData.d.ts +31 -0
  443. package/out/natural/componentData.js +85 -0
  444. package/out/natural/componentData.js.map +1 -0
  445. package/out/natural/genNaturalTS.d.ts +3 -0
  446. package/out/natural/genNaturalTS.js +76 -0
  447. package/out/natural/genNaturalTS.js.map +1 -0
  448. package/out/natural/index.d.ts +4 -0
  449. package/out/natural/index.js +21 -0
  450. package/out/natural/index.js.map +1 -0
  451. package/out/natural/knowledgeMap.d.ts +4 -0
  452. package/out/natural/knowledgeMap.js +40 -0
  453. package/out/natural/knowledgeMap.js.map +1 -0
  454. package/out/natural/naslStdlibMap.d.ts +2 -0
  455. package/out/natural/naslStdlibMap.js +26 -0
  456. package/out/natural/naslStdlibMap.js.map +1 -0
  457. package/out/natural/transformTSCode.d.ts +7 -0
  458. package/out/natural/transformTSCode.js +760 -0
  459. package/out/natural/transformTSCode.js.map +1 -0
  460. package/out/sentry/index.d.ts +2 -1
  461. package/out/sentry/index.js.map +1 -1
  462. package/out/server/createUiTs.js +28 -16
  463. package/out/server/createUiTs.js.map +1 -1
  464. package/out/server/entity2LogicNamespace.js +24 -22
  465. package/out/server/entity2LogicNamespace.js.map +1 -1
  466. package/out/server/event.d.ts +12 -0
  467. package/out/server/event.js +52 -28
  468. package/out/server/event.js.map +1 -1
  469. package/out/server/extendBaseNode.js +55 -70
  470. package/out/server/extendBaseNode.js.map +1 -1
  471. package/out/server/formatTsUtils.js +46 -50
  472. package/out/server/formatTsUtils.js.map +1 -1
  473. package/out/server/getConnector.d.ts +3 -3
  474. package/out/server/getConnector.js +7 -8
  475. package/out/server/getConnector.js.map +1 -1
  476. package/out/server/getExtensionModules.js +2 -2
  477. package/out/server/getExtensionModules.js.map +1 -1
  478. package/out/server/getFunctions.js.map +1 -1
  479. package/out/server/getInterfaces.js.map +1 -1
  480. package/out/server/getLogging.js.map +1 -1
  481. package/out/server/getLogics.d.ts +1 -1
  482. package/out/server/getLogics.js +55 -8
  483. package/out/server/getLogics.js.map +1 -1
  484. package/out/server/getMemberIdentifier.js +13 -10
  485. package/out/server/getMemberIdentifier.js.map +1 -1
  486. package/out/server/getProcessComponents.js.map +1 -1
  487. package/out/server/getProcesses.js +21 -29
  488. package/out/server/getProcesses.js.map +1 -1
  489. package/out/server/getScope.js.map +1 -1
  490. package/out/server/getValidates.js.map +1 -1
  491. package/out/server/index.js +0 -1
  492. package/out/server/index.js.map +1 -1
  493. package/out/server/naslServer.d.ts +99 -94
  494. package/out/server/naslServer.js +490 -469
  495. package/out/server/naslServer.js.map +1 -1
  496. package/out/server/naslStdlibMap.js +6 -2
  497. package/out/server/naslStdlibMap.js.map +1 -1
  498. package/out/server/process2LogicNamespace.js.map +1 -1
  499. package/out/server/translator.d.ts +1 -1
  500. package/out/server/translator.js +52 -47
  501. package/out/server/translator.js.map +1 -1
  502. package/out/service/storage/init.d.ts +15 -1
  503. package/out/service/storage/init.js +65 -56
  504. package/out/service/storage/init.js.map +1 -1
  505. package/out/templator/genCallComponentLogic.js +1 -2
  506. package/out/templator/genCallComponentLogic.js.map +1 -1
  507. package/out/templator/genCreateBlock.js +14 -9
  508. package/out/templator/genCreateBlock.js.map +1 -1
  509. package/out/templator/genCurdEditMultipleKeyBlock.js +23 -14
  510. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  511. package/out/templator/genCurdMultipleKeyBlock.js +26 -30
  512. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  513. package/out/templator/genEditTableBlock.d.ts +1 -1
  514. package/out/templator/genEditTableBlock.js +14 -19
  515. package/out/templator/genEditTableBlock.js.map +1 -1
  516. package/out/templator/genEnumSelectBlock.js +1 -1
  517. package/out/templator/genEnumSelectBlock.js.map +1 -1
  518. package/out/templator/genGetBlock.js +2 -2
  519. package/out/templator/genGetBlock.js.map +1 -1
  520. package/out/templator/genGridViewBlock.d.ts +2 -2
  521. package/out/templator/genGridViewBlock.js +18 -28
  522. package/out/templator/genGridViewBlock.js.map +1 -1
  523. package/out/templator/genListViewBlock.d.ts +2 -2
  524. package/out/templator/genListViewBlock.js +9 -16
  525. package/out/templator/genListViewBlock.js.map +1 -1
  526. package/out/templator/genQueryComponent.js +22 -15
  527. package/out/templator/genQueryComponent.js.map +1 -1
  528. package/out/templator/genSelectBlock.d.ts +2 -2
  529. package/out/templator/genSelectBlock.js +21 -48
  530. package/out/templator/genSelectBlock.js.map +1 -1
  531. package/out/templator/genTableBlock.d.ts +1 -1
  532. package/out/templator/genTableBlock.js +11 -17
  533. package/out/templator/genTableBlock.js.map +1 -1
  534. package/out/templator/genUpdateBlock.js +13 -8
  535. package/out/templator/genUpdateBlock.js.map +1 -1
  536. package/out/templator/index.d.ts +4 -2
  537. package/out/templator/index.js +2 -2
  538. package/out/templator/index.js.map +1 -1
  539. package/out/templator/utils.d.ts +9 -2
  540. package/out/templator/utils.js +22 -22
  541. package/out/templator/utils.js.map +1 -1
  542. package/out/translator/index.js +27 -28
  543. package/out/translator/index.js.map +1 -1
  544. package/out/utils/index.d.ts +2 -1
  545. package/out/utils/index.js +8 -14
  546. package/out/utils/index.js.map +1 -1
  547. package/out/utils/logger.js.map +1 -1
  548. package/out/utils/sortTsString.js +3 -1
  549. package/out/utils/sortTsString.js.map +1 -1
  550. package/out/utils/string.js +8 -11
  551. package/out/utils/string.js.map +1 -1
  552. package/out/utils/time-slicing.d.ts +41 -0
  553. package/out/utils/time-slicing.js +81 -0
  554. package/out/utils/time-slicing.js.map +1 -0
  555. package/out/utils/traverse.js +4 -6
  556. package/out/utils/traverse.js.map +1 -1
  557. package/package.json +22 -20
  558. package/sandbox/stdlib/nasl.auth.ts +49 -46
  559. package/sandbox/stdlib/nasl.browser.ts +1 -0
  560. package/sandbox/stdlib/nasl.event.ts +4 -0
  561. package/sandbox/stdlib/nasl.http.ts +29 -31
  562. package/sandbox/stdlib/nasl.ui.definition.ts +13 -1
  563. package/sandbox/stdlib/nasl.ui.ts +11 -0
  564. package/sandbox-natural/stdlib/nasl.core.ts +36 -0
  565. package/sandbox-natural/stdlib/nasl.oql.ts +8 -0
  566. package/sandbox-natural/stdlib/nasl.ui.ts +56 -0
  567. package/sandbox-natural/stdlib/nasl.util.ts +26 -0
  568. package/sandbox-natural/tsconfig.json +12 -0
  569. package/src/automate/engine/utils.js +3 -0
  570. package/src/automate/upgrader/2.20.js +1 -1
  571. package/src/bak/translator.js +92 -99
  572. package/src/breakpoint/generator/AfterStartNode.ts +19 -17
  573. package/src/breakpoint/generator/BeforeEndNode.ts +17 -17
  574. package/src/breakpoint/generator/BreakpointNode.ts +243 -195
  575. package/src/breakpoint/generator/CallbackNode.ts +20 -0
  576. package/src/breakpoint/generator/FragmentNode.ts +14 -0
  577. package/src/breakpoint/generator/index.ts +107 -80
  578. package/src/breakpoint/shared/constants.ts +59 -53
  579. package/src/breakpoint/shared/operations.ts +6 -6
  580. package/src/breakpoint/shared/socket.ts +277 -223
  581. package/src/breakpoint/shared/utils.ts +166 -146
  582. package/src/breakpoint/store/core.ts +326 -297
  583. package/src/breakpoint/store/dock.ts +103 -103
  584. package/src/breakpoint/types/index.d.ts +11 -11
  585. package/src/common/BaseNode.ts +1103 -1020
  586. package/src/common/Command.ts +46 -16
  587. package/src/common/ComponentAPI.ts +72 -72
  588. package/src/common/EventEmitter.ts +80 -76
  589. package/src/common/Messager.ts +223 -224
  590. package/src/common/asyncFuncMap.ts +12 -12
  591. package/src/concepts/Abort__.ts +53 -60
  592. package/src/concepts/Anchor__.ts +158 -149
  593. package/src/concepts/AnonymousFunction__.ts +584 -551
  594. package/src/concepts/App__.ts +4278 -3669
  595. package/src/concepts/Argument__.ts +234 -210
  596. package/src/concepts/Assignee__.ts +680 -656
  597. package/src/concepts/AssignmentLine__.ts +80 -84
  598. package/src/concepts/Assignment__.ts +276 -264
  599. package/src/concepts/Attribute__.ts +183 -184
  600. package/src/concepts/AuthInterface__.ts +61 -63
  601. package/src/concepts/AuthLogicForCallInterface__.ts +540 -511
  602. package/src/concepts/AuthLogic__.ts +210 -194
  603. package/src/concepts/BackendVariable__.ts +414 -415
  604. package/src/concepts/Backend__.ts +317 -303
  605. package/src/concepts/BatchAssignment__.ts +987 -939
  606. package/src/concepts/BinaryExpression__.ts +370 -341
  607. package/src/concepts/BindAttribute__.ts +1056 -1011
  608. package/src/concepts/BindDirective__.ts +540 -542
  609. package/src/concepts/BindEvent__.ts +992 -866
  610. package/src/concepts/BindStyle__.ts +442 -451
  611. package/src/concepts/BooleanLiteral__.ts +89 -90
  612. package/src/concepts/CallAuthInterface__.ts +458 -433
  613. package/src/concepts/CallConnector__.ts +209 -164
  614. package/src/concepts/CallFunction__.ts +600 -600
  615. package/src/concepts/CallInterface__.ts +752 -725
  616. package/src/concepts/CallLogic__.ts +1328 -1236
  617. package/src/concepts/CallQueryComponent__.ts +1580 -1501
  618. package/src/concepts/Comment__.ts +69 -68
  619. package/src/concepts/CompletionProperty__.ts +250 -250
  620. package/src/concepts/ConfigGroup__.ts +312 -296
  621. package/src/concepts/ConfigPropertyValue__.ts +81 -82
  622. package/src/concepts/ConfigProperty__.ts +374 -357
  623. package/src/concepts/Configuration__.ts +288 -276
  624. package/src/concepts/Connection__.ts +426 -0
  625. package/src/concepts/ConnectorTrigger__.ts +146 -142
  626. package/src/concepts/Connector__.ts +1090 -1048
  627. package/src/concepts/Constant__.ts +226 -219
  628. package/src/concepts/DataElement__.ts +108 -115
  629. package/src/concepts/DataSource__.ts +508 -472
  630. package/src/concepts/DatabaseTypeAnnotation__.ts +53 -59
  631. package/src/concepts/Destination__.ts +808 -746
  632. package/src/concepts/End__.ts +85 -89
  633. package/src/concepts/EntityIndex__.ts +206 -202
  634. package/src/concepts/EntityProperty__.ts +825 -791
  635. package/src/concepts/Entity__.ts +921 -864
  636. package/src/concepts/EnumItem__.ts +133 -125
  637. package/src/concepts/Enum__.ts +347 -337
  638. package/src/concepts/Event__.ts +305 -292
  639. package/src/concepts/ExternalDestination__.ts +269 -280
  640. package/src/concepts/ForEachStatement__.ts +583 -531
  641. package/src/concepts/FrontendLibrary__.ts +507 -485
  642. package/src/concepts/FrontendVariable__.ts +44 -49
  643. package/src/concepts/Frontend__.ts +1239 -1187
  644. package/src/concepts/Function__.ts +1110 -1045
  645. package/src/concepts/Identifier__.ts +276 -272
  646. package/src/concepts/IfStatement__.ts +467 -436
  647. package/src/concepts/Integration__.ts +136 -137
  648. package/src/concepts/InterfaceParam__.ts +239 -238
  649. package/src/concepts/Interface__.ts +969 -948
  650. package/src/concepts/JSBlock__.ts +83 -83
  651. package/src/concepts/JavaLogic__.ts +101 -106
  652. package/src/concepts/LogicItem__.ts +307 -237
  653. package/src/concepts/Logic__.ts +2301 -2088
  654. package/src/concepts/MatchCase__.ts +886 -779
  655. package/src/concepts/Match__.ts +728 -659
  656. package/src/concepts/MemberExpression__.ts +330 -311
  657. package/src/concepts/MicroApp__.ts +91 -97
  658. package/src/concepts/Module__.ts +2590 -2275
  659. package/src/concepts/MsgTriggerEvent__.ts +297 -281
  660. package/src/concepts/MsgTriggerLauncher__.ts +286 -256
  661. package/src/concepts/Namespace__.ts +2579 -2466
  662. package/src/concepts/NewComposite__.ts +1487 -1350
  663. package/src/concepts/NewList__.ts +464 -450
  664. package/src/concepts/NewMap__.ts +691 -674
  665. package/src/concepts/New__.ts +42 -49
  666. package/src/concepts/NullLiteral__.ts +66 -72
  667. package/src/concepts/NumericLiteral__.ts +169 -169
  668. package/src/concepts/OqlQueryComponent__.ts +282 -279
  669. package/src/concepts/OverriddenLogic__.ts +2142 -2097
  670. package/src/concepts/Param__.ts +500 -442
  671. package/src/concepts/Point__.ts +53 -59
  672. package/src/concepts/ProcessComponent__.ts +497 -475
  673. package/src/concepts/ProcessElement__.ts +1852 -1780
  674. package/src/concepts/ProcessOutcome__.ts +59 -64
  675. package/src/concepts/ProcessOutcomes__.ts +59 -64
  676. package/src/concepts/Process__.ts +1491 -1428
  677. package/src/concepts/QueryAggregateExpression__.ts +135 -142
  678. package/src/concepts/QueryFieldExpression__.ts +138 -142
  679. package/src/concepts/QueryFromExpression__.ts +246 -254
  680. package/src/concepts/QueryGroupByExpression__.ts +130 -136
  681. package/src/concepts/QueryJoinExpression__.ts +441 -438
  682. package/src/concepts/QueryLimitExpression__.ts +159 -166
  683. package/src/concepts/QueryOrderByExpression__.ts +173 -180
  684. package/src/concepts/QuerySelectExpression__.ts +464 -439
  685. package/src/concepts/Rect__.ts +73 -79
  686. package/src/concepts/Return__.ts +366 -345
  687. package/src/concepts/Role__.ts +146 -147
  688. package/src/concepts/SelectMembers__.ts +358 -350
  689. package/src/concepts/Slot__.ts +152 -153
  690. package/src/concepts/SqlQueryComponent__.ts +230 -228
  691. package/src/concepts/Start__.ts +45 -52
  692. package/src/concepts/StringInterpolation__.ts +323 -296
  693. package/src/concepts/StringLiteral__.ts +113 -115
  694. package/src/concepts/StructureProperty__.ts +306 -295
  695. package/src/concepts/Structure__.ts +615 -578
  696. package/src/concepts/SwitchCase__.ts +326 -290
  697. package/src/concepts/SwitchStatement__.ts +236 -229
  698. package/src/concepts/Theme__.ts +64 -68
  699. package/src/concepts/Transactional__.ts +159 -153
  700. package/src/concepts/TriggerEvent__.ts +285 -274
  701. package/src/concepts/TriggerLauncher__.ts +232 -196
  702. package/src/concepts/TypeAnnotation__.ts +1049 -1011
  703. package/src/concepts/TypeParam__.ts +48 -50
  704. package/src/concepts/UnaryExpression__.ts +163 -153
  705. package/src/concepts/Unparsed__.ts +81 -82
  706. package/src/concepts/UseComponent__.ts +53 -59
  707. package/src/concepts/ValidationRule__.ts +524 -544
  708. package/src/concepts/Variable__.ts +419 -397
  709. package/src/concepts/ViewBlock__.ts +58 -64
  710. package/src/concepts/ViewComponent__.ts +1323 -1261
  711. package/src/concepts/ViewElement__.ts +2537 -2351
  712. package/src/concepts/View__.ts +2461 -2245
  713. package/src/concepts/WhileStatement__.ts +293 -272
  714. package/src/concepts/basics/stdlib/index.ts +17 -1
  715. package/src/concepts/basics/stdlib/nasl.browser.ts +36 -0
  716. package/src/concepts/basics/stdlib/nasl.event.ts +18 -0
  717. package/src/concepts/basics/stdlib/nasl.ui.ts +45 -0
  718. package/src/concepts/basics/stdlib/nasl.util.ts +6 -22
  719. package/src/concepts/index__.ts +2 -1
  720. package/src/concepts/types__.ts +123 -121
  721. package/src/decorators/index.ts +75 -77
  722. package/src/decorators/promise.ts +28 -0
  723. package/src/enums/KEYWORDS.ts +1228 -1228
  724. package/src/enums/LEVEL_NAME_MAP.ts +24 -24
  725. package/src/generator/compileComponent.ts +10 -10
  726. package/src/generator/genBundleFiles.ts +300 -291
  727. package/src/generator/genHash.ts +2 -2
  728. package/src/generator/genMetaData.ts +280 -261
  729. package/src/generator/genReleaseBody.ts +312 -291
  730. package/src/generator/icestark.ts +1 -1
  731. package/src/generator/microApp.ts +17 -20
  732. package/src/generator/permission.ts +241 -232
  733. package/src/generator/qiankun.ts +1 -1
  734. package/src/generator/styleReplacer.ts +28 -31
  735. package/src/index.ts +0 -3
  736. package/src/manager/diagnostic.ts +84 -82
  737. package/src/manager/stepRecorder.ts +106 -94
  738. package/src/natural/RequirementAnalyzer.ts +208 -0
  739. package/src/natural/RequirementExecutor.ts +685 -0
  740. package/src/natural/componentData.ts +81 -0
  741. package/src/natural/genNaturalTS.ts +77 -0
  742. package/src/natural/index.ts +4 -0
  743. package/src/natural/knowledgeMap.ts +39 -0
  744. package/src/natural/naslStdlibMap.ts +24 -0
  745. package/src/natural/transformTSCode.ts +692 -0
  746. package/src/sentry/index.ts +109 -104
  747. package/src/server/createUiTs.ts +190 -184
  748. package/src/server/entity2LogicNamespace.ts +379 -359
  749. package/src/server/event.js +145 -121
  750. package/src/server/extendBaseNode.ts +461 -456
  751. package/src/server/formatTsUtils.ts +712 -713
  752. package/src/server/getConnector.ts +33 -33
  753. package/src/server/getExtensionModules.ts +23 -22
  754. package/src/server/getFunctions.ts +6 -6
  755. package/src/server/getInterfaces.ts +38 -37
  756. package/src/server/getLogging.ts +1 -1
  757. package/src/server/getLogics.ts +391 -312
  758. package/src/server/getMemberIdentifier.ts +286 -281
  759. package/src/server/getProcessComponents.ts +2 -2
  760. package/src/server/getProcesses.ts +548 -534
  761. package/src/server/getScope.ts +51 -51
  762. package/src/server/getValidates.ts +3 -3
  763. package/src/server/index.ts +29 -30
  764. package/src/server/naslServer.ts +4303 -4222
  765. package/src/server/naslStdlibMap.ts +43 -39
  766. package/src/server/process2LogicNamespace.ts +97 -97
  767. package/src/server/translator.ts +740 -746
  768. package/src/service/storage/init.ts +761 -728
  769. package/src/templator/genCallComponentLogic.ts +14 -15
  770. package/src/templator/genCreateBlock.ts +257 -229
  771. package/src/templator/genCurdEditMultipleKeyBlock.ts +333 -317
  772. package/src/templator/genCurdMultipleKeyBlock.ts +503 -475
  773. package/src/templator/genEditTableBlock.ts +194 -187
  774. package/src/templator/genEnumSelectBlock.ts +13 -7
  775. package/src/templator/genGetBlock.ts +57 -55
  776. package/src/templator/genGridViewBlock.ts +195 -211
  777. package/src/templator/genListViewBlock.ts +62 -72
  778. package/src/templator/genQueryComponent.ts +337 -287
  779. package/src/templator/genSelectBlock.ts +283 -297
  780. package/src/templator/genTableBlock.ts +160 -166
  781. package/src/templator/genUpdateBlock.ts +269 -255
  782. package/src/templator/index.ts +4 -4
  783. package/src/templator/utils.ts +491 -463
  784. package/src/translator/index.ts +84 -84
  785. package/src/translator/lsp.ts +22 -22
  786. package/src/translator/tsp.ts +6 -6
  787. package/src/utils/index.ts +115 -117
  788. package/src/utils/logger.ts +3 -4
  789. package/src/utils/sortTsString.ts +34 -32
  790. package/src/utils/string.ts +47 -48
  791. package/src/utils/time-slicing.ts +109 -0
  792. package/src/utils/traverse.ts +114 -126
  793. package/test/concepts/call-interface/__snapshots__/toEmbeddedTS.spec.ts.snap +71 -0
  794. package/test/concepts/call-interface/__snapshots__/toJS.spec.ts.snap +140 -0
  795. package/test/concepts/call-interface/constant.ts +5 -0
  796. package/test/concepts/call-interface/fixtures/only-interface.json +158 -0
  797. package/test/concepts/call-interface/fixtures/with-body-complex-argument.json +455 -0
  798. package/test/concepts/call-interface/fixtures/with-body-no-argument.json +187 -0
  799. package/test/concepts/call-interface/fixtures/with-body-simple-argument.json +225 -0
  800. package/test/concepts/call-interface/fixtures/with-headers-no-argument.json +213 -0
  801. package/test/concepts/call-interface/fixtures/with-headers.json +192 -0
  802. package/test/concepts/call-interface/fixtures/with-query-no-argument.json +213 -0
  803. package/test/concepts/call-interface/fixtures/with-query.json +192 -0
  804. package/test/concepts/call-interface/toEmbeddedTS.spec.ts +14 -0
  805. package/test/concepts/call-interface/toJS.spec.ts +14 -0
  806. package/test/concepts/call-logic/__snapshots__/toEmbeddedTS.spec.ts.snap +74 -0
  807. package/test/concepts/call-logic/__snapshots__/toJS.spec.ts.snap +141 -0
  808. package/test/concepts/call-logic/constant.ts +5 -0
  809. package/test/concepts/call-logic/fixtures/entries-get-with-arguments.json +223 -0
  810. package/test/concepts/call-logic/fixtures/entries-update-with-arguments.json +359 -0
  811. package/test/concepts/call-logic/fixtures/global-logic-argument-no-expression.json +209 -0
  812. package/test/concepts/call-logic/fixtures/global-logic-argument-some-expression.json +311 -0
  813. package/test/concepts/call-logic/fixtures/only-call-logic.json +10 -0
  814. package/test/concepts/call-logic/fixtures/view-buildin-logic-with-argument.json +128 -0
  815. package/test/concepts/call-logic/fixtures/view-component-logic-no-argument.json +126 -0
  816. package/test/concepts/call-logic/fixtures/view-component-with-validation.json +244 -0
  817. package/test/concepts/call-logic/toEmbeddedTS.spec.ts +14 -0
  818. package/test/concepts/call-logic/toJS.spec.ts +14 -0
  819. package/test/concepts/match/__snapshots__/toEmbeddedTS.spec.ts.snap +66 -0
  820. package/test/concepts/match/__snapshots__/toJS.spec.ts.snap +40 -0
  821. package/test/concepts/match/constant.ts +5 -0
  822. package/test/concepts/match/fixtures/isExpression.json +259 -0
  823. package/test/concepts/match/fixtures/lastBodyIf.json +268 -0
  824. package/test/concepts/match/fixtures/noExpression.json +176 -0
  825. package/test/concepts/match/toEmbeddedTS.spec.ts +14 -0
  826. package/test/concepts/match/toJS.spec.ts +14 -0
  827. package/test/concepts/utils.ts +76 -3
  828. package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +3 -3
  829. package/test/concepts/validation-rule/__snapshots__/toJS.spec.ts.snap +16 -0
  830. package/test/concepts/validation-rule/constant.ts +5 -0
  831. package/test/concepts/validation-rule/toEmbeddedTS.spec.ts +10 -17
  832. package/test/concepts/validation-rule/toJS.spec.ts +14 -0
  833. package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +68 -0
  834. package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +44 -0
  835. package/test/concepts/view-element/constant.ts +5 -0
  836. package/test/concepts/view-element/fixtures/default-not-found.json +322 -0
  837. package/test/concepts/view-element/toEmbeddedTS.spec.ts +14 -0
  838. package/test/concepts/view-element/toVue.spec.ts +14 -0
  839. package/test/setup.ts +7 -0
  840. package/ts-worker/src/index.js +0 -2
  841. package/tsconfig.json +21 -21
  842. package/bin/naslc +0 -3
@@ -1,3 +1,4 @@
1
+ import { v4 as uuidv4 } from 'uuid';
1
2
  import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
2
3
  import QueryJoinExpression from './QueryJoinExpression__';
3
4
  import Entity from './Entity__';
@@ -7,15 +8,14 @@ import CompletionProperty from './CompletionProperty__';
7
8
  import QueryFieldExpression from './QueryFieldExpression__';
8
9
  import Identifier from './Identifier__';
9
10
  import MemberExpression from './MemberExpression__';
10
- //================================================================================
11
+ //= ===============================================================================
11
12
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
12
13
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
13
- //================================================================================
14
+ //= ===============================================================================
14
15
  import { EventPayload, Params } from '../common/EventEmitter';
15
16
  import { concept, excludedInJSON, property } from '../decorators';
16
17
 
17
18
  import * as utils from '../utils';
18
- import { v4 as uuidv4 } from 'uuid';
19
19
  import BaseNode from '../common/BaseNode';
20
20
  import classMap from '../common/classMap';
21
21
  import TypeAnnotation from './TypeAnnotation__';
@@ -31,1564 +31,1643 @@ import QueryLimitExpression from './QueryLimitExpression__';
31
31
  */
32
32
  @concept('数据查询')
33
33
  export class CallQueryComponent extends LogicItem {
34
- /**
35
- * 产品概念
36
- */
37
- @property()
38
- concept: 'CallQueryComponent' = 'CallQueryComponent';
39
-
40
- /**
41
- * 类型
42
- */
43
- @property('TypeAnnotation')
44
- typeAnnotation: TypeAnnotation = undefined;
45
-
46
- /**
47
- * select
48
- */
49
- @property('QuerySelectExpression')
50
- select: QuerySelectExpression = undefined;
51
-
52
- /**
53
- * from
54
- */
55
- @property('QueryFromExpression')
56
- from: QueryFromExpression = undefined;
57
-
58
- /**
59
- * where
60
- */
61
- @property('LogicItem')
62
- where: LogicItem = undefined;
63
-
64
- /**
65
- * where 草稿态
66
- */
67
- @property('LogicItem')
68
- wherePlayground: Array<LogicItem> = [];
69
-
70
- /**
71
- * groupBy
72
- */
73
- @property('QueryGroupByExpression')
74
- groupBy: Array<QueryGroupByExpression> = [];
75
-
76
- /**
77
- * having
78
- */
79
- @property('LogicItem')
80
- having: LogicItem = undefined;
81
-
82
- /**
83
- * having 草稿态
84
- */
85
- @property('LogicItem')
86
- havingPlayground: Array<LogicItem> = [];
87
-
88
- /**
89
- * orderBy
90
- */
91
- @property('QueryOrderByExpression')
92
- orderBy: Array<QueryOrderByExpression> = [];
93
-
94
- /**
95
- * limit
96
- */
97
- @property('QueryLimitExpression')
98
- limit: QueryLimitExpression = undefined;
99
-
100
- /**
101
- * 查询组件的局部版本
102
- */
103
- @property()
104
- ideVersion: string = undefined;
105
-
106
- /**
107
- * @param source 需要合并的部分参数
108
- */
109
- constructor(source?: Partial<CallQueryComponent>) {
110
- source = Object.assign({}, CallQueryComponent.getDefaultOptions(), source);
111
- super(source);
112
- super.subConstructor(source);
113
- }
114
- getClassName() {
115
- return 'CallQueryComponent';
116
- }
117
-
118
- static from(source: any, parentNode?: any, parentKey?: string): CallQueryComponent {
119
- return super.from(source, parentNode, parentKey) as CallQueryComponent;
120
- }
121
-
122
- /**
123
- * 设置select
124
- */
125
- setSelect(select: QuerySelectExpression) {
126
- select._delete();
127
- const relationOptions = { parentNode: this, parentKey: 'select' };
128
- Object.assign(select, relationOptions);
129
- const object = {
130
- select,
131
- };
132
- this.update({
133
- ...object,
134
- });
135
- }
136
-
137
- /**
138
- * 设置from
139
- */
140
- setFrom(from: QueryFromExpression) {
141
- from._delete();
142
- const relationOptions = { parentNode: this, parentKey: 'from' };
143
- Object.assign(from, relationOptions);
144
- const object = {
145
- from,
146
- };
147
- this.update({
148
- ...object,
149
- });
150
- }
151
-
152
- /**
153
- * 设置where
154
- */
155
- setWhere(where: LogicItem) {
156
- where._delete();
157
- const relationOptions = { parentNode: this, parentKey: 'where' };
158
- Object.assign(where, relationOptions);
159
- const object = {
160
- where,
161
- };
162
- this.update({
163
- ...object,
164
- });
165
- }
166
-
167
- /**
168
- * 设置groupBy
169
- */
170
- setGroupBy(groupBy: Array<QueryGroupByExpression>) {
171
- const object = {
172
- groupBy,
173
- };
174
- this.update({
175
- ...object,
176
- });
177
- }
178
-
179
- /**
180
- * 设置having
181
- */
182
- setHaving(having: LogicItem) {
183
- having._delete();
184
- const relationOptions = { parentNode: this, parentKey: 'having' };
185
- Object.assign(having, relationOptions);
186
- const object = {
187
- having,
188
- };
189
- this.update({
190
- ...object,
191
- });
192
- }
193
-
194
- /**
195
- * 设置orderBy
196
- */
197
- setOrderBy(orderBy: Array<QueryOrderByExpression>) {
198
- const object = {
199
- orderBy,
200
- };
201
- this.update({
202
- ...object,
203
- });
34
+ /**
35
+ * 产品概念
36
+ */
37
+ @property()
38
+ concept: 'CallQueryComponent' = 'CallQueryComponent';
39
+
40
+ /**
41
+ * 类型
42
+ */
43
+ @property('TypeAnnotation')
44
+ typeAnnotation: TypeAnnotation = undefined;
45
+
46
+ /**
47
+ * select
48
+ */
49
+ @property('QuerySelectExpression')
50
+ select: QuerySelectExpression = undefined;
51
+
52
+ /**
53
+ * from
54
+ */
55
+ @property('QueryFromExpression')
56
+ from: QueryFromExpression = undefined;
57
+
58
+ /**
59
+ * where
60
+ */
61
+ @property('LogicItem')
62
+ where: LogicItem = undefined;
63
+
64
+ /**
65
+ * where 草稿态
66
+ */
67
+ @property('LogicItem')
68
+ wherePlayground: Array<LogicItem> = [];
69
+
70
+ /**
71
+ * groupBy
72
+ */
73
+ @property('QueryGroupByExpression')
74
+ groupBy: Array<QueryGroupByExpression> = [];
75
+
76
+ /**
77
+ * having
78
+ */
79
+ @property('LogicItem')
80
+ having: LogicItem = undefined;
81
+
82
+ /**
83
+ * having 草稿态
84
+ */
85
+ @property('LogicItem')
86
+ havingPlayground: Array<LogicItem> = [];
87
+
88
+ /**
89
+ * orderBy
90
+ */
91
+ @property('QueryOrderByExpression')
92
+ orderBy: Array<QueryOrderByExpression> = [];
93
+
94
+ /**
95
+ * limit
96
+ */
97
+ @property('QueryLimitExpression')
98
+ limit: QueryLimitExpression = undefined;
99
+
100
+ /**
101
+ * 查询组件的局部版本
102
+ */
103
+ @property()
104
+ ideVersion: string = undefined;
105
+
106
+ /**
107
+ * @param source 需要合并的部分参数
108
+ */
109
+ constructor(source?: Partial<CallQueryComponent>) {
110
+ // @ts-ignore
111
+ source = { ...CallQueryComponent.getDefaultOptions(), ...source };
112
+ super(source);
113
+ super.subConstructor(source);
114
+ }
115
+
116
+ getClassName() {
117
+ return 'CallQueryComponent';
118
+ }
119
+
120
+ static from(source: any, parentNode?: any, parentKey?: string): CallQueryComponent {
121
+ return super.from(source, parentNode, parentKey) as CallQueryComponent;
122
+ }
123
+
124
+ /**
125
+ * 设置select
126
+ */
127
+ setSelect(select: QuerySelectExpression) {
128
+ select._delete();
129
+ const relationOptions = { parentNode: this, parentKey: 'select' };
130
+ Object.assign(select, relationOptions);
131
+ const object = {
132
+ select,
133
+ };
134
+ this.update({
135
+ ...object,
136
+ });
137
+ }
138
+
139
+ /**
140
+ * 设置from
141
+ */
142
+ setFrom(from: QueryFromExpression) {
143
+ from._delete();
144
+ const relationOptions = { parentNode: this, parentKey: 'from' };
145
+ Object.assign(from, relationOptions);
146
+ const object = {
147
+ from,
148
+ };
149
+ this.update({
150
+ ...object,
151
+ });
152
+ }
153
+
154
+ /**
155
+ * 设置where
156
+ */
157
+ setWhere(where: LogicItem) {
158
+ where._delete();
159
+ const relationOptions = { parentNode: this, parentKey: 'where' };
160
+ Object.assign(where, relationOptions);
161
+ const object = {
162
+ where,
163
+ };
164
+ this.update({
165
+ ...object,
166
+ });
167
+ }
168
+
169
+ /**
170
+ * 设置groupBy
171
+ */
172
+ setGroupBy(groupBy: Array<QueryGroupByExpression>) {
173
+ const object = {
174
+ groupBy,
175
+ };
176
+ this.update({
177
+ ...object,
178
+ });
179
+ }
180
+
181
+ /**
182
+ * 设置having
183
+ */
184
+ setHaving(having: LogicItem) {
185
+ having._delete();
186
+ const relationOptions = { parentNode: this, parentKey: 'having' };
187
+ Object.assign(having, relationOptions);
188
+ const object = {
189
+ having,
190
+ };
191
+ this.update({
192
+ ...object,
193
+ });
194
+ }
195
+
196
+ /**
197
+ * 设置orderBy
198
+ */
199
+ setOrderBy(orderBy: Array<QueryOrderByExpression>) {
200
+ const object = {
201
+ orderBy,
202
+ };
203
+ this.update({
204
+ ...object,
205
+ });
206
+ }
207
+
208
+ /**
209
+ * 设置limit
210
+ */
211
+ setLimit(limit: QueryLimitExpression) {
212
+ limit._delete();
213
+ const relationOptions = { parentNode: this, parentKey: 'limit' };
214
+ Object.assign(limit, relationOptions);
215
+ const object = {
216
+ limit,
217
+ };
218
+ this.update({
219
+ ...object,
220
+ });
221
+ }
222
+
223
+ /**
224
+ * 插入逻辑项
225
+ * @internal
226
+ * @param logicItemOptions 逻辑项参数
227
+ */
228
+ _insertItemInWherePlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
229
+
230
+ /**
231
+ * 插入逻辑项
232
+ * @internal
233
+ * @param logicItem 已有的逻辑项实例
234
+ */
235
+ _insertItemInWherePlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
236
+
237
+ _insertItemInWherePlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
238
+ const logicItemOptions: any = {};
239
+ const relationOptions = { parentNode: this, parentKey: 'wherePlayground' };
240
+ let logicItem: LogicItem;
241
+ if (options instanceof LogicItem) {
242
+ options.ensureDelete(); // 同一实例不支持多处存在
243
+ logicItem = options;
244
+ Object.assign(logicItem, relationOptions);
245
+ } else {
246
+ logicItem = LogicItem.from(
247
+ {
248
+ ...logicItemOptions,
249
+ ...options,
250
+ },
251
+ this,
252
+ 'wherePlayground'
253
+ );
204
254
  }
205
-
206
- /**
207
- * 设置limit
208
- */
209
- setLimit(limit: QueryLimitExpression) {
210
- limit._delete();
211
- const relationOptions = { parentNode: this, parentKey: 'limit' };
212
- Object.assign(limit, relationOptions);
213
- const object = {
214
- limit,
215
- };
216
- this.update({
217
- ...object,
218
- });
255
+ this.wherePlayground.splice(index, 0, logicItem);
256
+ return logicItem;
257
+ }
258
+
259
+ /**
260
+ * 插入逻辑项
261
+ * @param logicItemOptions 逻辑项参数
262
+ */
263
+ insertItemInWherePlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
264
+
265
+ /**
266
+ * 插入逻辑项
267
+ * @param logicItem 已有的逻辑项实例
268
+ */
269
+ insertItemInWherePlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
270
+
271
+ insertItemInWherePlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
272
+ const node = this._insertItemInWherePlaygroundAt(options as any, index);
273
+ node.create({
274
+ index,
275
+ parentNode: this,
276
+ parentKey: 'wherePlayground',
277
+ });
278
+ return node;
279
+ }
280
+
281
+ /**
282
+ * 添加逻辑项
283
+ * @internal
284
+ * @param logicItemOptions 逻辑项参数
285
+ */
286
+ _addItemInWherePlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
287
+
288
+ /**
289
+ * 添加逻辑项
290
+ * @internal
291
+ * @param logicItem 已有的逻辑项实例
292
+ */
293
+ _addItemInWherePlayground(logicItem: LogicItem): LogicItem;
294
+
295
+ _addItemInWherePlayground(options?: Partial<LogicItem> | LogicItem) {
296
+ const index = this.wherePlayground.length;
297
+ return this._insertItemInWherePlaygroundAt(options as any, index);
298
+ }
299
+
300
+ /**
301
+ * 添加逻辑项
302
+ * @param logicItemOptions 逻辑项参数
303
+ */
304
+ addItemInWherePlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
305
+
306
+ /**
307
+ * 添加逻辑项
308
+ * @param logicItem 已有的逻辑项实例
309
+ */
310
+ addItemInWherePlayground(logicItem: LogicItem): LogicItem;
311
+
312
+ addItemInWherePlayground(options?: Partial<LogicItem> | LogicItem) {
313
+ const node = this._addItemInWherePlayground(options as any);
314
+ const index = this.wherePlayground.indexOf(node);
315
+ node.create({
316
+ index,
317
+ parentNode: this,
318
+ parentKey: 'wherePlayground',
319
+ });
320
+ return node;
321
+ }
322
+
323
+ /**
324
+ * 插入查询分组
325
+ * @internal
326
+ * @param queryGroupByExpressionOptions 查询分组参数
327
+ */
328
+ _insertQueryGroupByExpressionInGroupByAt(queryGroupByExpressionOptions: Partial<QueryGroupByExpression>, index: number): QueryGroupByExpression;
329
+
330
+ /**
331
+ * 插入查询分组
332
+ * @internal
333
+ * @param queryGroupByExpression 已有的查询分组实例
334
+ */
335
+ _insertQueryGroupByExpressionInGroupByAt(queryGroupByExpression: QueryGroupByExpression, index: number): QueryGroupByExpression;
336
+
337
+ _insertQueryGroupByExpressionInGroupByAt(options: Partial<QueryGroupByExpression> | QueryGroupByExpression, index: number) {
338
+ const queryGroupByExpressionOptions: any = {};
339
+ const relationOptions = { parentNode: this, parentKey: 'groupBy' };
340
+ let queryGroupByExpression: QueryGroupByExpression;
341
+ if (options instanceof QueryGroupByExpression) {
342
+ options.ensureDelete(); // 同一实例不支持多处存在
343
+ queryGroupByExpression = options;
344
+ Object.assign(queryGroupByExpression, relationOptions);
345
+ } else {
346
+ queryGroupByExpression = QueryGroupByExpression.from(
347
+ {
348
+ ...queryGroupByExpressionOptions,
349
+ ...options,
350
+ },
351
+ this,
352
+ 'groupBy'
353
+ );
219
354
  }
220
-
221
- /**
222
- * 插入逻辑项
223
- * @internal
224
- * @param logicItemOptions 逻辑项参数
225
- */
226
- _insertItemInWherePlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
227
-
228
- /**
229
- * 插入逻辑项
230
- * @internal
231
- * @param logicItem 已有的逻辑项实例
232
- */
233
- _insertItemInWherePlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
234
-
235
- _insertItemInWherePlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
236
- const logicItemOptions: any = {};
237
- const relationOptions = { parentNode: this, parentKey: 'wherePlayground' };
238
- let logicItem: LogicItem;
239
- if (options instanceof LogicItem) {
240
- options.ensureDelete(); // 同一实例不支持多处存在
241
- logicItem = options;
242
- Object.assign(logicItem, relationOptions);
243
- } else {
244
- logicItem = LogicItem.from({
245
- ...logicItemOptions,
246
- ...options,
247
- }, this, 'wherePlayground');
248
- }
249
- this.wherePlayground.splice(index, 0, logicItem);
250
- return logicItem;
355
+ this.groupBy.splice(index, 0, queryGroupByExpression);
356
+ return queryGroupByExpression;
357
+ }
358
+
359
+ /**
360
+ * 插入查询分组
361
+ * @param queryGroupByExpressionOptions 查询分组参数
362
+ */
363
+ insertQueryGroupByExpressionInGroupByAt(queryGroupByExpressionOptions: Partial<QueryGroupByExpression>, index: number): QueryGroupByExpression;
364
+
365
+ /**
366
+ * 插入查询分组
367
+ * @param queryGroupByExpression 已有的查询分组实例
368
+ */
369
+ insertQueryGroupByExpressionInGroupByAt(queryGroupByExpression: QueryGroupByExpression, index: number): QueryGroupByExpression;
370
+
371
+ insertQueryGroupByExpressionInGroupByAt(options: Partial<QueryGroupByExpression> | QueryGroupByExpression, index: number) {
372
+ const node = this._insertQueryGroupByExpressionInGroupByAt(options as any, index);
373
+ node.create({
374
+ index,
375
+ parentNode: this,
376
+ parentKey: 'groupBy',
377
+ });
378
+ return node;
379
+ }
380
+
381
+ /**
382
+ * 添加查询分组
383
+ * @internal
384
+ * @param queryGroupByExpressionOptions 查询分组参数
385
+ */
386
+ _addQueryGroupByExpressionInGroupBy(queryGroupByExpressionOptions: Partial<QueryGroupByExpression>): QueryGroupByExpression;
387
+
388
+ /**
389
+ * 添加查询分组
390
+ * @internal
391
+ * @param queryGroupByExpression 已有的查询分组实例
392
+ */
393
+ _addQueryGroupByExpressionInGroupBy(queryGroupByExpression: QueryGroupByExpression): QueryGroupByExpression;
394
+
395
+ _addQueryGroupByExpressionInGroupBy(options?: Partial<QueryGroupByExpression> | QueryGroupByExpression) {
396
+ const index = this.groupBy.length;
397
+ return this._insertQueryGroupByExpressionInGroupByAt(options as any, index);
398
+ }
399
+
400
+ /**
401
+ * 添加查询分组
402
+ * @param queryGroupByExpressionOptions 查询分组参数
403
+ */
404
+ addQueryGroupByExpressionInGroupBy(queryGroupByExpressionOptions: Partial<QueryGroupByExpression>): QueryGroupByExpression;
405
+
406
+ /**
407
+ * 添加查询分组
408
+ * @param queryGroupByExpression 已有的查询分组实例
409
+ */
410
+ addQueryGroupByExpressionInGroupBy(queryGroupByExpression: QueryGroupByExpression): QueryGroupByExpression;
411
+
412
+ addQueryGroupByExpressionInGroupBy(options?: Partial<QueryGroupByExpression> | QueryGroupByExpression) {
413
+ const node = this._addQueryGroupByExpressionInGroupBy(options as any);
414
+ const index = this.groupBy.indexOf(node);
415
+ node.create({
416
+ index,
417
+ parentNode: this,
418
+ parentKey: 'groupBy',
419
+ });
420
+ return node;
421
+ }
422
+
423
+ /**
424
+ * 插入逻辑项
425
+ * @internal
426
+ * @param logicItemOptions 逻辑项参数
427
+ */
428
+ _insertItemInHavingPlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
429
+
430
+ /**
431
+ * 插入逻辑项
432
+ * @internal
433
+ * @param logicItem 已有的逻辑项实例
434
+ */
435
+ _insertItemInHavingPlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
436
+
437
+ _insertItemInHavingPlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
438
+ const logicItemOptions: any = {};
439
+ const relationOptions = { parentNode: this, parentKey: 'havingPlayground' };
440
+ let logicItem: LogicItem;
441
+ if (options instanceof LogicItem) {
442
+ options.ensureDelete(); // 同一实例不支持多处存在
443
+ logicItem = options;
444
+ Object.assign(logicItem, relationOptions);
445
+ } else {
446
+ logicItem = LogicItem.from(
447
+ {
448
+ ...logicItemOptions,
449
+ ...options,
450
+ },
451
+ this,
452
+ 'havingPlayground'
453
+ );
251
454
  }
252
-
253
- /**
254
- * 插入逻辑项
255
- * @param logicItemOptions 逻辑项参数
256
- */
257
- insertItemInWherePlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
258
-
259
- /**
260
- * 插入逻辑项
261
- * @param logicItem 已有的逻辑项实例
262
- */
263
- insertItemInWherePlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
264
-
265
- insertItemInWherePlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
266
- const node = this._insertItemInWherePlaygroundAt(options as any, index);
267
- node.create({
268
- index,
269
- parentNode: this,
270
- parentKey: 'wherePlayground',
271
- });
272
- return node;
455
+ this.havingPlayground.splice(index, 0, logicItem);
456
+ return logicItem;
457
+ }
458
+
459
+ /**
460
+ * 插入逻辑项
461
+ * @param logicItemOptions 逻辑项参数
462
+ */
463
+ insertItemInHavingPlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
464
+
465
+ /**
466
+ * 插入逻辑项
467
+ * @param logicItem 已有的逻辑项实例
468
+ */
469
+ insertItemInHavingPlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
470
+
471
+ insertItemInHavingPlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
472
+ const node = this._insertItemInHavingPlaygroundAt(options as any, index);
473
+ node.create({
474
+ index,
475
+ parentNode: this,
476
+ parentKey: 'havingPlayground',
477
+ });
478
+ return node;
479
+ }
480
+
481
+ /**
482
+ * 添加逻辑项
483
+ * @internal
484
+ * @param logicItemOptions 逻辑项参数
485
+ */
486
+ _addItemInHavingPlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
487
+
488
+ /**
489
+ * 添加逻辑项
490
+ * @internal
491
+ * @param logicItem 已有的逻辑项实例
492
+ */
493
+ _addItemInHavingPlayground(logicItem: LogicItem): LogicItem;
494
+
495
+ _addItemInHavingPlayground(options?: Partial<LogicItem> | LogicItem) {
496
+ const index = this.havingPlayground.length;
497
+ return this._insertItemInHavingPlaygroundAt(options as any, index);
498
+ }
499
+
500
+ /**
501
+ * 添加逻辑项
502
+ * @param logicItemOptions 逻辑项参数
503
+ */
504
+ addItemInHavingPlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
505
+
506
+ /**
507
+ * 添加逻辑项
508
+ * @param logicItem 已有的逻辑项实例
509
+ */
510
+ addItemInHavingPlayground(logicItem: LogicItem): LogicItem;
511
+
512
+ addItemInHavingPlayground(options?: Partial<LogicItem> | LogicItem) {
513
+ const node = this._addItemInHavingPlayground(options as any);
514
+ const index = this.havingPlayground.indexOf(node);
515
+ node.create({
516
+ index,
517
+ parentNode: this,
518
+ parentKey: 'havingPlayground',
519
+ });
520
+ return node;
521
+ }
522
+
523
+ /**
524
+ * 插入查询排序子句
525
+ * @internal
526
+ * @param queryOrderByExpressionOptions 查询排序子句参数
527
+ */
528
+ _insertQueryOrderByExpressionInOrderByAt(queryOrderByExpressionOptions: Partial<QueryOrderByExpression>, index: number): QueryOrderByExpression;
529
+
530
+ /**
531
+ * 插入查询排序子句
532
+ * @internal
533
+ * @param queryOrderByExpression 已有的查询排序子句实例
534
+ */
535
+ _insertQueryOrderByExpressionInOrderByAt(queryOrderByExpression: QueryOrderByExpression, index: number): QueryOrderByExpression;
536
+
537
+ _insertQueryOrderByExpressionInOrderByAt(options: Partial<QueryOrderByExpression> | QueryOrderByExpression, index: number) {
538
+ const queryOrderByExpressionOptions: any = {};
539
+ const relationOptions = { parentNode: this, parentKey: 'orderBy' };
540
+ let queryOrderByExpression: QueryOrderByExpression;
541
+ if (options instanceof QueryOrderByExpression) {
542
+ options.ensureDelete(); // 同一实例不支持多处存在
543
+ queryOrderByExpression = options;
544
+ Object.assign(queryOrderByExpression, relationOptions);
545
+ } else {
546
+ queryOrderByExpression = QueryOrderByExpression.from(
547
+ {
548
+ ...queryOrderByExpressionOptions,
549
+ ...options,
550
+ },
551
+ this,
552
+ 'orderBy'
553
+ );
273
554
  }
274
-
275
- /**
276
- * 添加逻辑项
277
- * @internal
278
- * @param logicItemOptions 逻辑项参数
279
- */
280
- _addItemInWherePlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
281
-
282
- /**
283
- * 添加逻辑项
284
- * @internal
285
- * @param logicItem 已有的逻辑项实例
286
- */
287
- _addItemInWherePlayground(logicItem: LogicItem): LogicItem;
288
-
289
- _addItemInWherePlayground(options?: Partial<LogicItem> | LogicItem) {
290
- const index = this.wherePlayground.length;
291
- return this._insertItemInWherePlaygroundAt(options as any, index);
555
+ this.orderBy.splice(index, 0, queryOrderByExpression);
556
+ return queryOrderByExpression;
557
+ }
558
+
559
+ /**
560
+ * 插入查询排序子句
561
+ * @param queryOrderByExpressionOptions 查询排序子句参数
562
+ */
563
+ insertQueryOrderByExpressionInOrderByAt(queryOrderByExpressionOptions: Partial<QueryOrderByExpression>, index: number): QueryOrderByExpression;
564
+
565
+ /**
566
+ * 插入查询排序子句
567
+ * @param queryOrderByExpression 已有的查询排序子句实例
568
+ */
569
+ insertQueryOrderByExpressionInOrderByAt(queryOrderByExpression: QueryOrderByExpression, index: number): QueryOrderByExpression;
570
+
571
+ insertQueryOrderByExpressionInOrderByAt(options: Partial<QueryOrderByExpression> | QueryOrderByExpression, index: number) {
572
+ const node = this._insertQueryOrderByExpressionInOrderByAt(options as any, index);
573
+ node.create({
574
+ index,
575
+ parentNode: this,
576
+ parentKey: 'orderBy',
577
+ });
578
+ return node;
579
+ }
580
+
581
+ /**
582
+ * 添加查询排序子句
583
+ * @internal
584
+ * @param queryOrderByExpressionOptions 查询排序子句参数
585
+ */
586
+ _addQueryOrderByExpressionInOrderBy(queryOrderByExpressionOptions: Partial<QueryOrderByExpression>): QueryOrderByExpression;
587
+
588
+ /**
589
+ * 添加查询排序子句
590
+ * @internal
591
+ * @param queryOrderByExpression 已有的查询排序子句实例
592
+ */
593
+ _addQueryOrderByExpressionInOrderBy(queryOrderByExpression: QueryOrderByExpression): QueryOrderByExpression;
594
+
595
+ _addQueryOrderByExpressionInOrderBy(options?: Partial<QueryOrderByExpression> | QueryOrderByExpression) {
596
+ const index = this.orderBy.length;
597
+ return this._insertQueryOrderByExpressionInOrderByAt(options as any, index);
598
+ }
599
+
600
+ /**
601
+ * 添加查询排序子句
602
+ * @param queryOrderByExpressionOptions 查询排序子句参数
603
+ */
604
+ addQueryOrderByExpressionInOrderBy(queryOrderByExpressionOptions: Partial<QueryOrderByExpression>): QueryOrderByExpression;
605
+
606
+ /**
607
+ * 添加查询排序子句
608
+ * @param queryOrderByExpression 已有的查询排序子句实例
609
+ */
610
+ addQueryOrderByExpressionInOrderBy(queryOrderByExpression: QueryOrderByExpression): QueryOrderByExpression;
611
+
612
+ addQueryOrderByExpressionInOrderBy(options?: Partial<QueryOrderByExpression> | QueryOrderByExpression) {
613
+ const node = this._addQueryOrderByExpressionInOrderBy(options as any);
614
+ const index = this.orderBy.indexOf(node);
615
+ node.create({
616
+ index,
617
+ parentNode: this,
618
+ parentKey: 'orderBy',
619
+ });
620
+ return node;
621
+ }
622
+
623
+ /**
624
+ * 删除类型标注
625
+ * @param name 类型标注名称
626
+ */
627
+ removeTypeAnnotation(name: string): void;
628
+
629
+ /**
630
+ * 删除类型标注
631
+ * @param typeAnnotation 已有的类型标注实例
632
+ */
633
+ removeTypeAnnotation(typeAnnotation: TypeAnnotation): void;
634
+
635
+ removeTypeAnnotation(options: string | TypeAnnotation) {
636
+ let typeAnnotation: TypeAnnotation;
637
+ if (typeof options === 'string') {
638
+ typeAnnotation = this.typeAnnotation;
639
+ if (!typeAnnotation) {
640
+ throw new Error(`找不到类型标注 ${options}`);
641
+ }
642
+ } else {
643
+ typeAnnotation = options;
292
644
  }
293
-
294
- /**
295
- * 添加逻辑项
296
- * @param logicItemOptions 逻辑项参数
297
- */
298
- addItemInWherePlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
299
-
300
- /**
301
- * 添加逻辑项
302
- * @param logicItem 已有的逻辑项实例
303
- */
304
- addItemInWherePlayground(logicItem: LogicItem): LogicItem;
305
-
306
- addItemInWherePlayground(options?: Partial<LogicItem> | LogicItem) {
307
- const node = this._addItemInWherePlayground(options as any);
308
- const index = this.wherePlayground.indexOf(node);
309
- node.create({
310
- index,
311
- parentNode: this,
312
- parentKey: 'wherePlayground',
313
- });
314
- return node;
645
+ return typeAnnotation.delete();
646
+ }
647
+
648
+ __removeTypeAnnotation(typeAnnotation: TypeAnnotation) {
649
+ const { parentKey } = typeAnnotation;
650
+ const params: Params = {
651
+ parentNode: this,
652
+ parentKey,
653
+ index: -1,
654
+ object: null,
655
+ oldObject: typeAnnotation,
656
+ };
657
+ if (parentKey) {
658
+ params.parentKey = parentKey;
659
+ if (Array.isArray((this as any)[parentKey])) {
660
+ const index = (this as any)[parentKey].indexOf(typeAnnotation);
661
+ ~index && (this as any)[parentKey].splice(index, 1);
662
+ params.index = index;
663
+ } else if ((this as any)[parentKey] === typeAnnotation) {
664
+ params.index = 0;
665
+ (this as any)[parentKey] = undefined;
666
+ }
315
667
  }
316
-
317
- /**
318
- * 插入查询分组
319
- * @internal
320
- * @param queryGroupByExpressionOptions 查询分组参数
321
- */
322
- _insertQueryGroupByExpressionInGroupByAt(queryGroupByExpressionOptions: Partial<QueryGroupByExpression>, index: number): QueryGroupByExpression;
323
-
324
- /**
325
- * 插入查询分组
326
- * @internal
327
- * @param queryGroupByExpression 已有的查询分组实例
328
- */
329
- _insertQueryGroupByExpressionInGroupByAt(queryGroupByExpression: QueryGroupByExpression, index: number): QueryGroupByExpression;
330
-
331
- _insertQueryGroupByExpressionInGroupByAt(options: Partial<QueryGroupByExpression> | QueryGroupByExpression, index: number) {
332
- const queryGroupByExpressionOptions: any = {};
333
- const relationOptions = { parentNode: this, parentKey: 'groupBy' };
334
- let queryGroupByExpression: QueryGroupByExpression;
335
- if (options instanceof QueryGroupByExpression) {
336
- options.ensureDelete(); // 同一实例不支持多处存在
337
- queryGroupByExpression = options;
338
- Object.assign(queryGroupByExpression, relationOptions);
339
- } else {
340
- queryGroupByExpression = QueryGroupByExpression.from({
341
- ...queryGroupByExpressionOptions,
342
- ...options,
343
- }, this, 'groupBy');
344
- }
345
- this.groupBy.splice(index, 0, queryGroupByExpression);
346
- return queryGroupByExpression;
668
+ return params;
669
+ }
670
+
671
+ /**
672
+ * 删除查询选择子句
673
+ * @param name 查询选择子句名称
674
+ */
675
+ removeSelect(name: string): void;
676
+
677
+ /**
678
+ * 删除查询选择子句
679
+ * @param select 已有的查询选择子句实例
680
+ */
681
+ removeSelect(select: QuerySelectExpression): void;
682
+
683
+ removeSelect(options: string | QuerySelectExpression) {
684
+ let select: QuerySelectExpression;
685
+ if (typeof options === 'string') {
686
+ select = this.select;
687
+ if (!select) {
688
+ throw new Error(`找不到查询选择子句 ${options}`);
689
+ }
690
+ } else {
691
+ select = options;
347
692
  }
348
-
349
- /**
350
- * 插入查询分组
351
- * @param queryGroupByExpressionOptions 查询分组参数
352
- */
353
- insertQueryGroupByExpressionInGroupByAt(queryGroupByExpressionOptions: Partial<QueryGroupByExpression>, index: number): QueryGroupByExpression;
354
-
355
- /**
356
- * 插入查询分组
357
- * @param queryGroupByExpression 已有的查询分组实例
358
- */
359
- insertQueryGroupByExpressionInGroupByAt(queryGroupByExpression: QueryGroupByExpression, index: number): QueryGroupByExpression;
360
-
361
- insertQueryGroupByExpressionInGroupByAt(options: Partial<QueryGroupByExpression> | QueryGroupByExpression, index: number) {
362
- const node = this._insertQueryGroupByExpressionInGroupByAt(options as any, index);
363
- node.create({
364
- index,
365
- parentNode: this,
366
- parentKey: 'groupBy',
367
- });
368
- return node;
693
+ return select.delete();
694
+ }
695
+
696
+ /**
697
+ * 删除查询 From 子句
698
+ * @param name 查询 From 子句名称
699
+ */
700
+ removeFrom(name: string): void;
701
+
702
+ /**
703
+ * 删除查询 From 子句
704
+ * @param from 已有的查询 From 子句实例
705
+ */
706
+ removeFrom(from: QueryFromExpression): void;
707
+
708
+ removeFrom(options: string | QueryFromExpression) {
709
+ let from: QueryFromExpression;
710
+ if (typeof options === 'string') {
711
+ from = this.from;
712
+ if (!from) {
713
+ throw new Error(`找不到查询 From 子句 ${options}`);
714
+ }
715
+ } else {
716
+ from = options;
369
717
  }
370
-
371
- /**
372
- * 添加查询分组
373
- * @internal
374
- * @param queryGroupByExpressionOptions 查询分组参数
375
- */
376
- _addQueryGroupByExpressionInGroupBy(queryGroupByExpressionOptions: Partial<QueryGroupByExpression>): QueryGroupByExpression;
377
-
378
- /**
379
- * 添加查询分组
380
- * @internal
381
- * @param queryGroupByExpression 已有的查询分组实例
382
- */
383
- _addQueryGroupByExpressionInGroupBy(queryGroupByExpression: QueryGroupByExpression): QueryGroupByExpression;
384
-
385
- _addQueryGroupByExpressionInGroupBy(options?: Partial<QueryGroupByExpression> | QueryGroupByExpression) {
386
- const index = this.groupBy.length;
387
- return this._insertQueryGroupByExpressionInGroupByAt(options as any, index);
718
+ return from.delete();
719
+ }
720
+
721
+ /**
722
+ * 删除逻辑项
723
+ * @param name 逻辑项名称
724
+ */
725
+ removeWhere(name: string): void;
726
+
727
+ /**
728
+ * 删除逻辑项
729
+ * @param where 已有的逻辑项实例
730
+ */
731
+ removeWhere(where: LogicItem): void;
732
+
733
+ removeWhere(options: string | LogicItem) {
734
+ let where: LogicItem;
735
+ if (typeof options === 'string') {
736
+ where = this.where;
737
+ if (!where) {
738
+ throw new Error(`找不到逻辑项 ${options}`);
739
+ }
740
+ } else {
741
+ where = options;
388
742
  }
389
-
390
- /**
391
- * 添加查询分组
392
- * @param queryGroupByExpressionOptions 查询分组参数
393
- */
394
- addQueryGroupByExpressionInGroupBy(queryGroupByExpressionOptions: Partial<QueryGroupByExpression>): QueryGroupByExpression;
395
-
396
- /**
397
- * 添加查询分组
398
- * @param queryGroupByExpression 已有的查询分组实例
399
- */
400
- addQueryGroupByExpressionInGroupBy(queryGroupByExpression: QueryGroupByExpression): QueryGroupByExpression;
401
-
402
- addQueryGroupByExpressionInGroupBy(options?: Partial<QueryGroupByExpression> | QueryGroupByExpression) {
403
- const node = this._addQueryGroupByExpressionInGroupBy(options as any);
404
- const index = this.groupBy.indexOf(node);
405
- node.create({
406
- index,
407
- parentNode: this,
408
- parentKey: 'groupBy',
409
- });
410
- return node;
743
+ return where.delete();
744
+ }
745
+
746
+ /**
747
+ * 删除逻辑项
748
+ * @param logicItem 已有的逻辑项实例
749
+ */
750
+ removeItemInWherePlayground(logicItem: LogicItem): void;
751
+
752
+ removeItemInWherePlayground(options: LogicItem) {
753
+ const logicItem: LogicItem = options;
754
+ return logicItem.delete();
755
+ }
756
+
757
+ /**
758
+ * 删除查询分组
759
+ * @param queryGroupByExpression 已有的查询分组实例
760
+ */
761
+ removeQueryGroupByExpressionInGroupBy(queryGroupByExpression: QueryGroupByExpression): void;
762
+
763
+ removeQueryGroupByExpressionInGroupBy(options: QueryGroupByExpression) {
764
+ const queryGroupByExpression: QueryGroupByExpression = options;
765
+ return queryGroupByExpression.delete();
766
+ }
767
+
768
+ /**
769
+ * 删除逻辑项
770
+ * @param name 逻辑项名称
771
+ */
772
+ removeHaving(name: string): void;
773
+
774
+ /**
775
+ * 删除逻辑项
776
+ * @param having 已有的逻辑项实例
777
+ */
778
+ removeHaving(having: LogicItem): void;
779
+
780
+ removeHaving(options: string | LogicItem) {
781
+ let having: LogicItem;
782
+ if (typeof options === 'string') {
783
+ having = this.having;
784
+ if (!having) {
785
+ throw new Error(`找不到逻辑项 ${options}`);
786
+ }
787
+ } else {
788
+ having = options;
411
789
  }
412
-
413
- /**
414
- * 插入逻辑项
415
- * @internal
416
- * @param logicItemOptions 逻辑项参数
417
- */
418
- _insertItemInHavingPlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
419
-
420
- /**
421
- * 插入逻辑项
422
- * @internal
423
- * @param logicItem 已有的逻辑项实例
424
- */
425
- _insertItemInHavingPlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
426
-
427
- _insertItemInHavingPlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
428
- const logicItemOptions: any = {};
429
- const relationOptions = { parentNode: this, parentKey: 'havingPlayground' };
430
- let logicItem: LogicItem;
431
- if (options instanceof LogicItem) {
432
- options.ensureDelete(); // 同一实例不支持多处存在
433
- logicItem = options;
434
- Object.assign(logicItem, relationOptions);
435
- } else {
436
- logicItem = LogicItem.from({
437
- ...logicItemOptions,
438
- ...options,
439
- }, this, 'havingPlayground');
440
- }
441
- this.havingPlayground.splice(index, 0, logicItem);
442
- return logicItem;
790
+ return having.delete();
791
+ }
792
+
793
+ /**
794
+ * 删除逻辑项
795
+ * @param logicItem 已有的逻辑项实例
796
+ */
797
+ removeItemInHavingPlayground(logicItem: LogicItem): void;
798
+
799
+ removeItemInHavingPlayground(options: LogicItem) {
800
+ const logicItem: LogicItem = options;
801
+ return logicItem.delete();
802
+ }
803
+
804
+ /**
805
+ * 删除查询排序子句
806
+ * @param queryOrderByExpression 已有的查询排序子句实例
807
+ */
808
+ removeQueryOrderByExpressionInOrderBy(queryOrderByExpression: QueryOrderByExpression): void;
809
+
810
+ removeQueryOrderByExpressionInOrderBy(options: QueryOrderByExpression) {
811
+ const queryOrderByExpression: QueryOrderByExpression = options;
812
+ return queryOrderByExpression.delete();
813
+ }
814
+
815
+ /**
816
+ * 删除查询分页子句
817
+ * @param name 查询分页子句名称
818
+ */
819
+ removeLimit(name: string): void;
820
+
821
+ /**
822
+ * 删除查询分页子句
823
+ * @param limit 已有的查询分页子句实例
824
+ */
825
+ removeLimit(limit: QueryLimitExpression): void;
826
+
827
+ removeLimit(options: string | QueryLimitExpression) {
828
+ let limit: QueryLimitExpression;
829
+ if (typeof options === 'string') {
830
+ limit = this.limit;
831
+ if (!limit) {
832
+ throw new Error(`找不到查询分页子句 ${options}`);
833
+ }
834
+ } else {
835
+ limit = options;
443
836
  }
444
-
445
- /**
446
- * 插入逻辑项
447
- * @param logicItemOptions 逻辑项参数
448
- */
449
- insertItemInHavingPlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
450
-
451
- /**
452
- * 插入逻辑项
453
- * @param logicItem 已有的逻辑项实例
454
- */
455
- insertItemInHavingPlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
456
-
457
- insertItemInHavingPlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
458
- const node = this._insertItemInHavingPlaygroundAt(options as any, index);
459
- node.create({
460
- index,
461
- parentNode: this,
462
- parentKey: 'havingPlayground',
463
- });
464
- return node;
837
+ return limit.delete();
838
+ }
839
+
840
+ __removeLogicItem(logicItem: LogicItem) {
841
+ const { parentKey } = logicItem;
842
+ const params: Params = {
843
+ parentNode: this,
844
+ parentKey,
845
+ index: -1,
846
+ object: null,
847
+ oldObject: logicItem,
848
+ };
849
+ if (parentKey) {
850
+ params.parentKey = parentKey;
851
+ if (Array.isArray((this as any)[parentKey])) {
852
+ const index = (this as any)[parentKey].indexOf(logicItem);
853
+ ~index && (this as any)[parentKey].splice(index, 1);
854
+ params.index = index;
855
+ } else if ((this as any)[parentKey] === logicItem) {
856
+ params.index = 0;
857
+ (this as any)[parentKey] = undefined;
858
+ }
465
859
  }
466
-
467
- /**
468
- * 添加逻辑项
469
- * @internal
470
- * @param logicItemOptions 逻辑项参数
471
- */
472
- _addItemInHavingPlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
473
-
474
- /**
475
- * 添加逻辑项
476
- * @internal
477
- * @param logicItem 已有的逻辑项实例
478
- */
479
- _addItemInHavingPlayground(logicItem: LogicItem): LogicItem;
480
-
481
- _addItemInHavingPlayground(options?: Partial<LogicItem> | LogicItem) {
482
- const index = this.havingPlayground.length;
483
- return this._insertItemInHavingPlaygroundAt(options as any, index);
860
+ return params;
861
+ }
862
+
863
+ //= ===============================================================================
864
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
865
+ // 自动生成的代码已结束。下面可以手动编写。
866
+ //= ===============================================================================
867
+
868
+ /**
869
+ * 获取添加时的默认选项
870
+ * @returns
871
+ */
872
+ public static getDefaultOptions(): any {
873
+ return {
874
+ kind: 'Statement',
875
+ concept: 'CallQueryComponent',
876
+ label: '数据查询',
877
+ select: {
878
+ concept: 'QuerySelectExpression',
879
+ label: '查询组件Select子句',
880
+ distinct: false,
881
+ star: true,
882
+ selectElements: [],
883
+ },
884
+ from: null,
885
+ where: null,
886
+ groupBy: [],
887
+ having: null,
888
+ orderBy: [],
889
+ limit: {
890
+ concept: 'QueryLimitExpression',
891
+ label: '查询组件Limit子句',
892
+ pageElement: {
893
+ concept: 'NumericLiteral',
894
+ value: 1,
895
+ },
896
+ pageSizeElement: {
897
+ concept: 'NumericLiteral',
898
+ value: 1000,
899
+ },
900
+ },
901
+ };
902
+ }
903
+
904
+ toEmbeddedTSOfSubPart<T extends { toEmbeddedTS: (state?: TranslatorState) => string }>(
905
+ key: string,
906
+ list: Array<T>,
907
+ options: {
908
+ code: string;
909
+ state: TranslatorState;
910
+ multipleErrorType?: '__WHERE_MULTIPLE_CONDITION__' | '__HAVING_MULTIPLE_CONDITION__';
484
911
  }
485
-
486
- /**
487
- * 添加逻辑项
488
- * @param logicItemOptions 逻辑项参数
489
- */
490
- addItemInHavingPlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
491
-
492
- /**
493
- * 添加逻辑项
494
- * @param logicItem 已有的逻辑项实例
495
- */
496
- addItemInHavingPlayground(logicItem: LogicItem): LogicItem;
497
-
498
- addItemInHavingPlayground(options?: Partial<LogicItem> | LogicItem) {
499
- const node = this._addItemInHavingPlayground(options as any);
500
- const index = this.havingPlayground.indexOf(node);
501
- node.create({
502
- index,
503
- parentNode: this,
504
- parentKey: 'havingPlayground',
505
- });
506
- return node;
912
+ ) {
913
+ let { code, state, multipleErrorType } = options;
914
+ if (list.length === 0) return code;
915
+
916
+ code += `${indent((state?.tabSize || 0) + 1)}.${key}(() => `;
917
+ list.forEach((item, index) => {
918
+ if (index > 0) code += `,\n${indent((state?.tabSize || 0) + 2)}() => `;
919
+ code += item?.toEmbeddedTS?.(shiftState(state, code, { tabSize: 0 }));
920
+ });
921
+ if (list.length > 1) {
922
+ if (multipleErrorType) code += `,\n${indent((state?.tabSize || 0) + 2)}() => ${multipleErrorType}`;
923
+ code += `\n${indent((state?.tabSize || 0) + 1)}`;
507
924
  }
508
-
509
- /**
510
- * 插入查询排序子句
511
- * @internal
512
- * @param queryOrderByExpressionOptions 查询排序子句参数
513
- */
514
- _insertQueryOrderByExpressionInOrderByAt(queryOrderByExpressionOptions: Partial<QueryOrderByExpression>, index: number): QueryOrderByExpression;
515
-
516
- /**
517
- * 插入查询排序子句
518
- * @internal
519
- * @param queryOrderByExpression 已有的查询排序子句实例
520
- */
521
- _insertQueryOrderByExpressionInOrderByAt(queryOrderByExpression: QueryOrderByExpression, index: number): QueryOrderByExpression;
522
-
523
- _insertQueryOrderByExpressionInOrderByAt(options: Partial<QueryOrderByExpression> | QueryOrderByExpression, index: number) {
524
- const queryOrderByExpressionOptions: any = {};
525
- const relationOptions = { parentNode: this, parentKey: 'orderBy' };
526
- let queryOrderByExpression: QueryOrderByExpression;
527
- if (options instanceof QueryOrderByExpression) {
528
- options.ensureDelete(); // 同一实例不支持多处存在
529
- queryOrderByExpression = options;
530
- Object.assign(queryOrderByExpression, relationOptions);
531
- } else {
532
- queryOrderByExpression = QueryOrderByExpression.from({
533
- ...queryOrderByExpressionOptions,
534
- ...options,
535
- }, this, 'orderBy');
536
- }
537
- this.orderBy.splice(index, 0, queryOrderByExpression);
538
- return queryOrderByExpression;
539
- }
540
-
541
- /**
542
- * 插入查询排序子句
543
- * @param queryOrderByExpressionOptions 查询排序子句参数
544
- */
545
- insertQueryOrderByExpressionInOrderByAt(queryOrderByExpressionOptions: Partial<QueryOrderByExpression>, index: number): QueryOrderByExpression;
546
-
547
- /**
548
- * 插入查询排序子句
549
- * @param queryOrderByExpression 已有的查询排序子句实例
550
- */
551
- insertQueryOrderByExpressionInOrderByAt(queryOrderByExpression: QueryOrderByExpression, index: number): QueryOrderByExpression;
552
-
553
- insertQueryOrderByExpressionInOrderByAt(options: Partial<QueryOrderByExpression> | QueryOrderByExpression, index: number) {
554
- const node = this._insertQueryOrderByExpressionInOrderByAt(options as any, index);
555
- node.create({
556
- index,
557
- parentNode: this,
558
- parentKey: 'orderBy',
559
- });
560
- return node;
561
- }
562
-
563
- /**
564
- * 添加查询排序子句
565
- * @internal
566
- * @param queryOrderByExpressionOptions 查询排序子句参数
567
- */
568
- _addQueryOrderByExpressionInOrderBy(queryOrderByExpressionOptions: Partial<QueryOrderByExpression>): QueryOrderByExpression;
569
-
570
- /**
571
- * 添加查询排序子句
572
- * @internal
573
- * @param queryOrderByExpression 已有的查询排序子句实例
574
- */
575
- _addQueryOrderByExpressionInOrderBy(queryOrderByExpression: QueryOrderByExpression): QueryOrderByExpression;
576
-
577
- _addQueryOrderByExpressionInOrderBy(options?: Partial<QueryOrderByExpression> | QueryOrderByExpression) {
578
- const index = this.orderBy.length;
579
- return this._insertQueryOrderByExpressionInOrderByAt(options as any, index);
580
- }
581
-
582
- /**
583
- * 添加查询排序子句
584
- * @param queryOrderByExpressionOptions 查询排序子句参数
585
- */
586
- addQueryOrderByExpressionInOrderBy(queryOrderByExpressionOptions: Partial<QueryOrderByExpression>): QueryOrderByExpression;
587
-
588
- /**
589
- * 添加查询排序子句
590
- * @param queryOrderByExpression 已有的查询排序子句实例
591
- */
592
- addQueryOrderByExpressionInOrderBy(queryOrderByExpression: QueryOrderByExpression): QueryOrderByExpression;
593
-
594
- addQueryOrderByExpressionInOrderBy(options?: Partial<QueryOrderByExpression> | QueryOrderByExpression) {
595
- const node = this._addQueryOrderByExpressionInOrderBy(options as any);
596
- const index = this.orderBy.indexOf(node);
597
- node.create({
598
- index,
599
- parentNode: this,
600
- parentKey: 'orderBy',
601
- });
602
- return node;
603
- }
604
-
605
- /**
606
- * 删除类型标注
607
- * @param name 类型标注名称
608
- */
609
- removeTypeAnnotation(name: string): void;
610
-
611
- /**
612
- * 删除类型标注
613
- * @param typeAnnotation 已有的类型标注实例
614
- */
615
- removeTypeAnnotation(typeAnnotation: TypeAnnotation): void;
616
-
617
- removeTypeAnnotation(options: string | TypeAnnotation) {
618
- let typeAnnotation: TypeAnnotation;
619
- if (typeof options === 'string') {
620
- typeAnnotation = this.typeAnnotation;
621
- if (!typeAnnotation) {
622
- throw new Error('找不到类型标注 ' + options);
623
- }
624
- } else {
625
- typeAnnotation = options;
626
- }
627
- return typeAnnotation.delete();
628
- }
629
-
630
- __removeTypeAnnotation(typeAnnotation: TypeAnnotation) {
631
- const parentKey = typeAnnotation.parentKey;
632
- const params: Params = {
633
- parentNode: this,
634
- parentKey,
635
- index: -1,
636
- object: null,
637
- oldObject: typeAnnotation,
638
- };
639
- if (parentKey) {
640
- params.parentKey = parentKey;
641
- if (Array.isArray((this as any)[parentKey])) {
642
- const index = (this as any)[parentKey].indexOf(typeAnnotation);
643
- ~index && (this as any)[parentKey].splice(index, 1);
644
- params.index = index;
645
- } else if ((this as any)[parentKey] === typeAnnotation) {
646
- params.index = 0;
647
- (this as any)[parentKey] = undefined;
648
- }
649
- }
650
- return params;
651
- }
652
-
653
- /**
654
- * 删除查询选择子句
655
- * @param name 查询选择子句名称
656
- */
657
- removeSelect(name: string): void;
658
-
659
- /**
660
- * 删除查询选择子句
661
- * @param select 已有的查询选择子句实例
662
- */
663
- removeSelect(select: QuerySelectExpression): void;
664
-
665
- removeSelect(options: string | QuerySelectExpression) {
666
- let select: QuerySelectExpression;
667
- if (typeof options === 'string') {
668
- select = this.select;
669
- if (!select) {
670
- throw new Error('找不到查询选择子句 ' + options);
671
- }
672
- } else {
673
- select = options;
674
- }
675
- return select.delete();
676
- }
677
-
678
- /**
679
- * 删除查询 From 子句
680
- * @param name 查询 From 子句名称
681
- */
682
- removeFrom(name: string): void;
683
-
684
- /**
685
- * 删除查询 From 子句
686
- * @param from 已有的查询 From 子句实例
687
- */
688
- removeFrom(from: QueryFromExpression): void;
689
-
690
- removeFrom(options: string | QueryFromExpression) {
691
- let from: QueryFromExpression;
692
- if (typeof options === 'string') {
693
- from = this.from;
694
- if (!from) {
695
- throw new Error('找不到查询 From 子句 ' + options);
696
- }
697
- } else {
698
- from = options;
699
- }
700
- return from.delete();
925
+ code += ')\n';
926
+
927
+ return code;
928
+ }
929
+
930
+ toJS() {
931
+ return '';
932
+ // const { entityName } = this.from;
933
+ // return `await this.$services["_custom"]["load${entityName}"]({
934
+ // config: {
935
+ // download: false,
936
+ // },
937
+ // path: {},
938
+ // query: {},
939
+ // headers: {},
940
+ // body: {
941
+ // },
942
+ // })`;
943
+ }
944
+
945
+ // 2.11版本,自动推断返回类型
946
+ isAutoInfer() {
947
+ return this.ideVersion === '2.11' || this.ideVersion === '2.22';
948
+ }
949
+
950
+ // 2.22版本,实体支持列筛选 2.11版本不支持列筛选,需要运维select.selectElements
951
+ get entityPropertySelectable() {
952
+ return this.ideVersion === '2.22';
953
+ }
954
+
955
+ @withSourceMap()
956
+ toEmbeddedTS(state?: TranslatorState): string {
957
+ if (!this.typeAnnotation)
958
+ return `(function () {
959
+ return;
960
+ })()`;
961
+ let code = `(function(): `;
962
+ if (this.isAutoInfer()) {
963
+ code += `${this.typeAnnotation.toEmbeddedTS(shiftState(state, code))} {\n`;
964
+ } else {
965
+ code += `{ list: nasl.collection.List<`;
966
+ code += `${this.typeAnnotation.toEmbeddedTS(shiftState(state, code))}>, total: nasl.core.Long } {\n`;
701
967
  }
702
-
703
- /**
704
- * 删除逻辑项
705
- * @param name 逻辑项名称
706
- */
707
- removeWhere(name: string): void;
708
-
709
- /**
710
- * 删除逻辑项
711
- * @param where 已有的逻辑项实例
712
- */
713
- removeWhere(where: LogicItem): void;
714
-
715
- removeWhere(options: string | LogicItem) {
716
- let where: LogicItem;
717
- if (typeof options === 'string') {
718
- where = this.where;
719
- if (!where) {
720
- throw new Error('找不到逻辑项 ' + options);
721
- }
722
- } else {
723
- where = options;
724
- }
725
- return where.delete();
968
+ // 2.11版本后 分组使用别名
969
+ if (this.isAutoInfer()) {
970
+ // 分组别名(列别名)
971
+ this.groupBy.forEach((item, index, array) => {
972
+ code += indent(state.tabSize + 1);
973
+ const groupElement = item.groupElement as QueryFieldExpression;
974
+ if (groupElement.asName) code += `const __${groupElement.asName} = `;
975
+ if (groupElement.propertyName) {
976
+ code += groupElement.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
977
+ code += ';\n';
978
+ } else code += `__EMPTY_GROUP_BY_NAME__;\n`;
979
+
980
+ if (index === array.length - 1) code += '\n';
981
+ });
726
982
  }
727
-
728
- /**
729
- * 删除逻辑项
730
- * @param logicItem 已有的逻辑项实例
731
- */
732
- removeItemInWherePlayground(logicItem: LogicItem): void;
733
-
734
- removeItemInWherePlayground(options: LogicItem) {
735
- const logicItem: LogicItem = options;
736
- return logicItem.delete();
983
+ // 聚合属性别名
984
+ this.select.selectAggregateElements.forEach((item, index, array) => {
985
+ code += indent((state?.tabSize || 0) + 1);
986
+ const { asName, aggregateName, aggregateParam } = item;
987
+ if (asName) code += `const __${asName} = `;
988
+ if (aggregateName) {
989
+ code += `nasl.langUtil.${aggregateName}(`;
990
+ code += aggregateParam.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
991
+ code += ');\n';
992
+ } else code += `__EMPTY_AGGREGATE_NAME__;\n`;
993
+
994
+ if (index === array.length - 1) code += '\n';
995
+ });
996
+
997
+ if (this.from) code += this.from.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
998
+ else code += `${indent((state?.tabSize || 0) + 1)}nasl.langUtil.FROM()\n`;
999
+
1000
+ // where 子句
1001
+ code = this.toEmbeddedTSOfSubPart('WHERE', this.where ? [this.where] : [], {
1002
+ code,
1003
+ state,
1004
+ multipleErrorType: '__WHERE_MULTIPLE_CONDITION__',
1005
+ });
1006
+
1007
+ if (this.select.selectAggregateElements.length) {
1008
+ // 聚合属性
1009
+ code = this.toEmbeddedTSOfSubPart('SELECT', this.select.selectAggregateElements, {
1010
+ code,
1011
+ state,
1012
+ });
1013
+ } else {
1014
+ // select实体字段
1015
+ code = this.toEmbeddedTSOfSubPart('SELECT', this.select.selectFieldElements, {
1016
+ code,
1017
+ state,
1018
+ });
737
1019
  }
738
1020
 
739
- /**
740
- * 删除查询分组
741
- * @param queryGroupByExpression 已有的查询分组实例
742
- */
743
- removeQueryGroupByExpressionInGroupBy(queryGroupByExpression: QueryGroupByExpression): void;
744
-
745
- removeQueryGroupByExpressionInGroupBy(options: QueryGroupByExpression) {
746
- const queryGroupByExpression: QueryGroupByExpression = options;
747
- return queryGroupByExpression.delete();
1021
+ // 分组属性(Group by)
1022
+ code = this.toEmbeddedTSOfSubPart('GROUP_BY', this.groupBy, {
1023
+ code,
1024
+ state,
1025
+ });
1026
+
1027
+ // 聚合属性过滤(Having)
1028
+ code = this.toEmbeddedTSOfSubPart('HAVING', this.having ? [this.having] : [], {
1029
+ code,
1030
+ state,
1031
+ multipleErrorType: '__HAVING_MULTIPLE_CONDITION__',
1032
+ });
1033
+
1034
+ // 排序规则
1035
+ code = this.toEmbeddedTSOfSubPart('ORDER_BY', this.orderBy, {
1036
+ code,
1037
+ state,
1038
+ });
1039
+
1040
+ // 分页参数
1041
+ code = this.toEmbeddedTSOfSubPart('LIMIT', this.limit ? [this.limit] : [], {
1042
+ code,
1043
+ state,
1044
+ });
1045
+
1046
+ code += '\n';
1047
+ code += `${indent((state?.tabSize || 0) + 1)}return;\n`;
1048
+ code += `${indent(state?.tabSize || 0)}})()`;
1049
+ if (
1050
+ this.parentNode.concept !== 'Argument' &&
1051
+ this.parentKey !== 'test' &&
1052
+ this.parentKey !== 'patterns' &&
1053
+ this.parentNode.concept !== 'Assignment' &&
1054
+ this.parentNode.concept !== 'ForEachStatement' &&
1055
+ this.parentNode.concept !== 'SelectMembers' &&
1056
+ this.parentNode.concept !== 'UnaryExpression' &&
1057
+ this.parentNode.concept !== 'BinaryExpression' &&
1058
+ this.parentNode.concept !== 'StringInterpolation' &&
1059
+ this.parentNode.concept !== 'MemberExpression' &&
1060
+ ['NewMap', 'NewList'].includes(this.parentNode.concept) &&
1061
+ this.parentKey !== 'returnExpression'
1062
+ ) {
1063
+ code += ';';
748
1064
  }
749
-
750
- /**
751
- * 删除逻辑项
752
- * @param name 逻辑项名称
753
- */
754
- removeHaving(name: string): void;
755
-
756
- /**
757
- * 删除逻辑项
758
- * @param having 已有的逻辑项实例
759
- */
760
- removeHaving(having: LogicItem): void;
761
-
762
- removeHaving(options: string | LogicItem) {
763
- let having: LogicItem;
764
- if (typeof options === 'string') {
765
- having = this.having;
766
- if (!having) {
767
- throw new Error('找不到逻辑项 ' + options);
768
- }
769
- } else {
770
- having = options;
771
- }
772
- return having.delete();
1065
+ code += '\n';
1066
+ return code;
1067
+ }
1068
+
1069
+ genPropertiesFrom(node: QueryFromExpression | QueryJoinExpression, properties: StructureProperty[] = []) {
1070
+ if (!node) return [];
1071
+
1072
+ const { entityName } = node;
1073
+ const { entityNamespace } = node;
1074
+ // 生成整个实体类型 { entity1: Entity1 } 在2.11属于默认情况;在2.22勾选实体节点(isDotStar=true)时
1075
+ if (!this.entityPropertySelectable || this.select.selectFieldElements.some((item) => item.entityAsName === entityName && item.isDotStar)) {
1076
+ properties.push(
1077
+ StructureProperty.from({
1078
+ name: utils.firstLowerCase(entityName),
1079
+ typeAnnotation: TypeAnnotation.from({
1080
+ concept: 'TypeAnnotation',
1081
+ typeKind: 'reference',
1082
+ typeName: entityName,
1083
+ typeNamespace: entityNamespace,
1084
+ }),
1085
+ })
1086
+ );
1087
+ } else if (this.select.selectFieldElements.some((item) => item.entityAsName === entityName && item.propertyName)) {
1088
+ // 2.22 选择字段时,生成选择字段的匿名数据结构 { entity1: { prop1, prop2 } }
1089
+ const entity: Entity = this.app.findNodeByCompleteName(`${entityNamespace}.${entityName}`);
1090
+ entity &&
1091
+ properties.push(
1092
+ StructureProperty.from({
1093
+ name: utils.firstLowerCase(entityName),
1094
+ typeAnnotation: TypeAnnotation.from({
1095
+ concept: 'TypeAnnotation',
1096
+ typeKind: 'anonymousStructure',
1097
+ properties: this.select.selectFieldElements
1098
+ .filter((sel) => sel.entityAsName === entityName && sel.propertyName)
1099
+ .map((item) => {
1100
+ const property = entity.properties.find((prop) => prop.name === item.propertyName);
1101
+ return (
1102
+ property &&
1103
+ StructureProperty.from({
1104
+ name: item.propertyName,
1105
+ typeAnnotation: TypeAnnotation.from(property.typeAnnotation),
1106
+ })
1107
+ );
1108
+ })
1109
+ .filter(Boolean),
1110
+ }),
1111
+ })
1112
+ );
1113
+ } else {
1114
+ /* 实体或属性都不选择时,不生成数据结构 */
773
1115
  }
774
1116
 
775
- /**
776
- * 删除逻辑项
777
- * @param logicItem 已有的逻辑项实例
778
- */
779
- removeItemInHavingPlayground(logicItem: LogicItem): void;
780
-
781
- removeItemInHavingPlayground(options: LogicItem) {
782
- const logicItem: LogicItem = options;
783
- return logicItem.delete();
1117
+ for (const sub of node.joinParts) {
1118
+ this.genPropertiesFrom(sub, properties);
784
1119
  }
785
1120
 
786
- /**
787
- * 删除查询排序子句
788
- * @param queryOrderByExpression 已有的查询排序子句实例
789
- */
790
- removeQueryOrderByExpressionInOrderBy(queryOrderByExpression: QueryOrderByExpression): void;
791
-
792
- removeQueryOrderByExpressionInOrderBy(options: QueryOrderByExpression) {
793
- const queryOrderByExpression: QueryOrderByExpression = options;
794
- return queryOrderByExpression.delete();
1121
+ return properties;
1122
+ }
1123
+
1124
+ genPropertyListOfFrom(node: QueryFromExpression | QueryJoinExpression, entities: any[] = []) {
1125
+ if (!node) return [];
1126
+
1127
+ const { entityName } = node;
1128
+ const { entityNamespace } = node;
1129
+ entities.push({
1130
+ concept: 'StructureProperty',
1131
+ name: utils.firstLowerCase(entityName),
1132
+ typeAnnotation: {
1133
+ concept: 'TypeAnnotation',
1134
+ typeKind: 'reference',
1135
+ typeName: entityName,
1136
+ typeNamespace: entityNamespace,
1137
+ },
1138
+ });
1139
+
1140
+ for (const sub of node.joinParts) {
1141
+ this.genPropertyListOfFrom(sub, entities);
795
1142
  }
796
1143
 
797
- /**
798
- * 删除查询分页子句
799
- * @param name 查询分页子句名称
800
- */
801
- removeLimit(name: string): void;
802
-
803
- /**
804
- * 删除查询分页子句
805
- * @param limit 已有的查询分页子句实例
806
- */
807
- removeLimit(limit: QueryLimitExpression): void;
808
-
809
- removeLimit(options: string | QueryLimitExpression) {
810
- let limit: QueryLimitExpression;
811
- if (typeof options === 'string') {
812
- limit = this.limit;
813
- if (!limit) {
814
- throw new Error('找不到查询分页子句 ' + options);
815
- }
1144
+ return entities;
1145
+ }
1146
+
1147
+ genPropertyListOfAggregate(node: CallQueryComponent, entities: Entity[]) {
1148
+ return node.select.selectAggregateElements
1149
+ .filter((item) => item.aggregateName && item.asName)
1150
+ .map((item) => {
1151
+ let typeName;
1152
+ if (['COUNT', 'COUNTD'].includes(item.aggregateName)) {
1153
+ typeName = 'Long';
1154
+ } else if (['AVG'].includes(item.aggregateName)) {
1155
+ const { entityAsName, propertyName } = item.aggregateParam;
1156
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
1157
+ const property = entity?.properties.find((item: any) => item.name === propertyName);
1158
+ const propertyTypeName = property?.typeAnnotation?.typeName;
1159
+ if (propertyTypeName === 'Decimal') {
1160
+ typeName = 'Decimal';
1161
+ } else {
1162
+ typeName = 'Decimal';
1163
+ }
816
1164
  } else {
817
- limit = options;
1165
+ const { entityAsName, propertyName } = item.aggregateParam;
1166
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
1167
+ const property = entity?.properties.find((item) => item.name === propertyName);
1168
+ typeName = property?.typeAnnotation?.typeName;
818
1169
  }
819
- return limit.delete();
820
- }
821
-
822
- __removeLogicItem(logicItem: LogicItem) {
823
- const parentKey = logicItem.parentKey;
824
- const params: Params = {
825
- parentNode: this,
826
- parentKey,
827
- index: -1,
828
- object: null,
829
- oldObject: logicItem,
1170
+ return {
1171
+ concept: 'StructureProperty',
1172
+ name: item.asName,
1173
+ typeAnnotation: {
1174
+ concept: 'TypeAnnotation',
1175
+ typeKind: 'primitive',
1176
+ typeNamespace: 'nasl.core',
1177
+ typeName,
1178
+ },
830
1179
  };
831
- if (parentKey) {
832
- params.parentKey = parentKey;
833
- if (Array.isArray((this as any)[parentKey])) {
834
- const index = (this as any)[parentKey].indexOf(logicItem);
835
- ~index && (this as any)[parentKey].splice(index, 1);
836
- params.index = index;
837
- } else if ((this as any)[parentKey] === logicItem) {
838
- params.index = 0;
839
- (this as any)[parentKey] = undefined;
840
- }
841
- }
842
- return params;
843
- }
844
-
845
- //================================================================================
846
- // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
847
- // 自动生成的代码已结束。下面可以手动编写。
848
- //================================================================================
1180
+ });
1181
+ }
1182
+
1183
+ genPropertyListOfGroupBy(node: CallQueryComponent, entities: Entity[]) {
1184
+ return node.groupBy
1185
+ .filter(
1186
+ (item) => item.groupElement && (item.groupElement as QueryFieldExpression).propertyName && (item.groupElement as QueryFieldExpression).asName
1187
+ )
1188
+ .map((item) => {
1189
+ const { entityAsName, propertyName, asName } = item.groupElement as QueryFieldExpression;
1190
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
1191
+ const property = entity?.properties.find((item) => item.name === propertyName);
1192
+ const propertyTypeAnnotation = property?.typeAnnotation;
849
1193
 
850
- /**
851
- * 获取添加时的默认选项
852
- * @returns
853
- */
854
- public static getDefaultOptions(): any {
855
1194
  return {
856
- kind: 'Statement',
857
- concept: 'CallQueryComponent',
858
- label: '数据查询',
859
- select: {
860
- concept: 'QuerySelectExpression',
861
- label: '查询组件Select子句',
862
- distinct: false,
863
- star: true,
864
- selectElements: [],
865
- },
866
- from: null,
867
- where: null,
868
- groupBy: [],
869
- having: null,
870
- orderBy: [],
871
- limit: {
872
- concept: 'QueryLimitExpression',
873
- label: '查询组件Limit子句',
874
- pageElement: {
875
- concept: 'NumericLiteral',
876
- value: 1,
877
- },
878
- pageSizeElement: {
879
- concept: 'NumericLiteral',
880
- value: 1000,
881
- },
882
- },
1195
+ concept: 'StructureProperty',
1196
+ name: asName,
1197
+ typeAnnotation: {
1198
+ concept: propertyTypeAnnotation.concept,
1199
+ typeKind: propertyTypeAnnotation.typeKind,
1200
+ typeName: propertyTypeAnnotation.typeName,
1201
+ typeNamespace: propertyTypeAnnotation.typeNamespace,
1202
+ },
883
1203
  };
1204
+ });
1205
+ }
1206
+
1207
+ genStructure(structureName?: string, properties: any[] = []) {
1208
+ const logic = this.logic || this.AuthLogic || this.AuthLogicForCallInterface;
1209
+ return Structure.from({
1210
+ concept: 'Structure',
1211
+ name: structureName || this.typeAnnotation?.typeName || `${utils.firstUpperCase(logic.name)}Structure`,
1212
+ origin: 'CallQueryComponent',
1213
+ properties,
1214
+ });
1215
+ }
1216
+
1217
+ saveStructure() {
1218
+ // 没有数据源时不初始化数据结构
1219
+ if (!this.entityInfos.length) {
1220
+ return;
884
1221
  }
885
-
886
- toEmbeddedTSOfSubPart<T extends { toEmbeddedTS: (state?: TranslatorState) => string }>(
887
- key: string,
888
- list: Array<T>,
889
- options: {
890
- code: string;
891
- state: TranslatorState;
892
- multipleErrorType?: '__WHERE_MULTIPLE_CONDITION__' | '__HAVING_MULTIPLE_CONDITION__';
893
- }) {
894
- let { code, state, multipleErrorType } = options;
895
- if (list.length === 0)
896
- return code;
897
-
898
- code += indent((state?.tabSize || 0) + 1) + `.${key}(() => `;
899
- list.forEach((item, index) => {
900
- if (index > 0)
901
- code += `,\n${indent((state?.tabSize || 0) + 2)}() => `;
902
- code += item?.toEmbeddedTS?.(shiftState(state, code, { tabSize: 0 }));
903
- });
904
- if (list.length > 1) {
905
- if (multipleErrorType)
906
- code += `,\n${indent((state?.tabSize || 0) + 2)}() => ${multipleErrorType}`;
907
- code += `\n${indent((state?.tabSize || 0) + 1)}`;
908
- }
909
- code += ')\n';
910
-
911
- return code;
912
- }
913
-
914
- toJS() {
915
- return '';
916
- // const { entityName } = this.from;
917
- // return `await this.$services["_custom"]["load${entityName}"]({
918
- // config: {
919
- // download: false,
920
- // },
921
- // path: {},
922
- // query: {},
923
- // headers: {},
924
- // body: {
925
- // },
926
- // })`;
1222
+ const entityNamespace = this.from?.entityNamespace;
1223
+ const entities = this.app.findNodeByCompleteName(entityNamespace);
1224
+ if (!this.isAutoInfer()) {
1225
+ // 存量应用走之前的逻辑
1226
+ return this.saveStructureNoInfer(entities);
927
1227
  }
928
1228
 
929
- // 2.11版本,自动推断返回类型
930
- isAutoInfer() {
931
- return this.ideVersion === '2.11' || this.ideVersion === '2.22';
932
- }
933
- // 2.22版本,实体支持列筛选 2.11版本不支持列筛选,需要运维select.selectElements
934
- get entityPropertySelectable() {
935
- return this.ideVersion === '2.22';
936
- }
937
-
938
- @withSourceMap()
939
- toEmbeddedTS(state?: TranslatorState): string {
940
- if (!this.typeAnnotation)
941
- return `(function () {
942
- return;
943
- })()`;
944
- let code = `(function(): `;
945
- if (this.isAutoInfer()) {
946
- code += `${this.typeAnnotation.toEmbeddedTS(shiftState(state, code))} {\n`;
947
- } else {
948
- code += `{ list: nasl.collection.List<`;
949
- code += `${this.typeAnnotation.toEmbeddedTS(shiftState(state, code))}>, total: nasl.core.Long } {\n`;
950
- }
951
- // 2.11版本后 分组使用别名
952
- if (this.isAutoInfer()) {
953
- // 分组别名(列别名)
954
- this.groupBy.forEach((item, index, array) => {
955
- code += indent(state.tabSize + 1);
956
- const groupElement = item.groupElement as QueryFieldExpression;
957
- if (groupElement.asName)
958
- code += `const __${groupElement.asName} = `;
959
- if (groupElement.propertyName) {
960
- code += groupElement.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
961
- code += ';\n';
962
- } else
963
- code += `__EMPTY_GROUP_BY_NAME__;\n`;
964
-
965
- if (index === array.length - 1)
966
- code += '\n';
967
- });
968
- }
969
- // 聚合属性别名
970
- this.select.selectAggregateElements.forEach((item, index, array) => {
971
- code += indent((state?.tabSize || 0) + 1);
972
- const { asName, aggregateName, aggregateParam } = item;
973
- if (asName)
974
- code += `const __${asName} = `;
975
- if (aggregateName) {
976
- code += `nasl.langUtil.${aggregateName}(`;
977
- code += aggregateParam.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
978
- code += ');\n';
979
- } else
980
- code += `__EMPTY_AGGREGATE_NAME__;\n`;
981
-
982
- if (index === array.length - 1)
983
- code += '\n';
984
- });
985
-
986
- if (this.from)
987
- code += this.from.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
988
- else
989
- code += `${indent((state?.tabSize || 0) + 1)}nasl.langUtil.FROM()\n`;
990
-
991
- // where 子句
992
- code = this.toEmbeddedTSOfSubPart('WHERE', this.where ? [this.where] : [], {
993
- code,
994
- state,
995
- multipleErrorType: '__WHERE_MULTIPLE_CONDITION__',
996
- });
997
-
998
- if (this.select.selectAggregateElements.length) {
999
- // 聚合属性
1000
- code = this.toEmbeddedTSOfSubPart('SELECT', this.select.selectAggregateElements, {
1001
- code,
1002
- state,
1003
- });
1004
- } else {
1005
- // select实体字段
1006
- code = this.toEmbeddedTSOfSubPart('SELECT', this.select.selectFieldElements, {
1007
- code,
1008
- state,
1009
- });
1010
- }
1011
-
1012
- // 分组属性(Group by)
1013
- code = this.toEmbeddedTSOfSubPart('GROUP_BY', this.groupBy, {
1014
- code,
1015
- state,
1016
- });
1017
-
1018
- // 聚合属性过滤(Having)
1019
- code = this.toEmbeddedTSOfSubPart('HAVING', this.having ? [this.having] : [], {
1020
- code,
1021
- state,
1022
- multipleErrorType: '__HAVING_MULTIPLE_CONDITION__',
1023
- });
1024
-
1025
- // 排序规则
1026
- code = this.toEmbeddedTSOfSubPart('ORDER_BY', this.orderBy, {
1027
- code,
1028
- state,
1029
- });
1030
-
1031
- // 分页参数
1032
- code = this.toEmbeddedTSOfSubPart('LIMIT', this.limit ? [this.limit] : [], {
1033
- code,
1034
- state,
1035
- });
1036
-
1037
- code += '\n';
1038
- code += indent((state?.tabSize || 0) + 1) + 'return;\n';
1039
- code += indent((state?.tabSize || 0)) + '})()';
1040
- if (this.parentNode.concept !== 'Argument'
1041
- && this.parentKey !== 'test'
1042
- && this.parentKey !== 'patterns'
1043
- && this.parentNode.concept !== 'Assignment'
1044
- && this.parentNode.concept !== 'ForEachStatement'
1045
- && this.parentNode.concept !== 'SelectMembers'
1046
- && this.parentNode.concept !== 'UnaryExpression'
1047
- && this.parentNode.concept !== 'BinaryExpression'
1048
- && this.parentNode.concept !== 'StringInterpolation'
1049
- && this.parentNode.concept !== 'MemberExpression'
1050
- && ['NewMap', 'NewList'].includes(this.parentNode.concept)
1051
- && this.parentKey !== 'returnExpression') {
1052
- code += ';';
1229
+ const { groupBy } = this;
1230
+ const selectElements = this.select.selectAggregateElements;
1231
+ let structureName;
1232
+ let typeAnnotation;
1233
+
1234
+ // remove structure
1235
+ if (this.typeAnnotation) {
1236
+ const { typeNamespace, typeName, typeArguments } = this.typeAnnotation;
1237
+ if (typeNamespace === 'app.structures') {
1238
+ structureName = typeName;
1239
+ this.removeStructure(structureName);
1240
+ } else if (typeNamespace === 'nasl.collection' && typeName === 'PageOf') {
1241
+ // PageOf<Structures>
1242
+ if (typeArguments[0].typeNamespace === 'app.structures') {
1243
+ structureName = typeArguments[0].typeName;
1244
+ this.removeStructure(structureName);
1053
1245
  }
1054
- code += '\n';
1055
- return code;
1246
+ }
1056
1247
  }
1057
1248
 
1058
- genPropertiesFrom(node: QueryFromExpression | QueryJoinExpression, properties: StructureProperty[] = []) {
1059
- if (!node)
1060
- return [];
1061
-
1062
- const entityName = node.entityName;
1063
- const entityNamespace = node.entityNamespace;
1064
- // 生成整个实体类型 { entity1: Entity1 } 在2.11属于默认情况;在2.22勾选实体节点(isDotStar=true)时
1065
- if (!this.entityPropertySelectable || this.select.selectFieldElements.some((item) => item.entityAsName === entityName && item.isDotStar)) {
1066
- properties.push(StructureProperty.from({
1067
- name: utils.firstLowerCase(entityName),
1068
- typeAnnotation: TypeAnnotation.from({
1249
+ const logic = this.logic || this.AuthLogic || this.AuthLogicForCallInterface || this.OverriddenLogic;
1250
+ structureName = structureName || utils.unique(`${utils.firstUpperCase(logic?.name)}Structure`, this.app.getStructureExistingNames());
1251
+ const groupByLength = groupBy.filter(
1252
+ (item) => (item.groupElement as QueryFieldExpression)?.propertyName && (item.groupElement as QueryFieldExpression).asName
1253
+ ).length;
1254
+ const aggregateLength = selectElements.filter((item) => item.aggregateName && item.asName).length;
1255
+
1256
+ // 1. 有分组
1257
+ if (groupByLength) {
1258
+ if (!aggregateLength && groupByLength === 1) {
1259
+ // 1.1 单分组无聚合:`{ list: List<列的类型>, total: Long }`
1260
+ const { entityAsName, propertyName } = groupBy[0].groupElement as QueryFieldExpression;
1261
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
1262
+ const property = entity?.properties.find((item: any) => item.name === propertyName);
1263
+ const propertyTypeAnnotation = property.typeAnnotation;
1264
+
1265
+ typeAnnotation = TypeAnnotation.from(
1266
+ {
1267
+ concept: 'TypeAnnotation',
1268
+ typeKind: 'anonymousStructure',
1269
+ properties: [
1270
+ StructureProperty.from({
1271
+ name: 'list',
1272
+ typeAnnotation: TypeAnnotation.from(
1273
+ {
1069
1274
  concept: 'TypeAnnotation',
1070
- typeKind: 'reference',
1071
- typeName: entityName,
1072
- typeNamespace: entityNamespace,
1073
- }),
1074
- }));
1075
- } else if (this.select.selectFieldElements.some((item) => item.entityAsName === entityName && item.propertyName)) {
1076
- // 2.22 选择字段时,生成选择字段的匿名数据结构 { entity1: { prop1, prop2 } }
1077
- const entity: Entity = this.app.findNodeByCompleteName(entityNamespace + '.' + entityName);
1078
- entity && properties.push(StructureProperty.from({
1079
- name: utils.firstLowerCase(entityName),
1080
- typeAnnotation: TypeAnnotation.from({
1081
- concept: 'TypeAnnotation',
1082
- typeKind: 'anonymousStructure',
1083
- properties: this.select.selectFieldElements
1084
- .filter((sel) => sel.entityAsName === entityName && sel.propertyName)
1085
- .map((item) => {
1086
- const property = entity.properties.find((prop) => prop.name === item.propertyName);
1087
- return property && StructureProperty.from({
1088
- name: item.propertyName,
1089
- typeAnnotation: TypeAnnotation.from(property.typeAnnotation),
1090
- });
1091
- }).filter(Boolean),
1092
- }),
1093
- }));
1094
- } else { /* 实体或属性都不选择时,不生成数据结构 */ }
1095
-
1096
- for (const sub of node.joinParts) {
1097
- this.genPropertiesFrom(sub, properties);
1098
- }
1099
-
1100
- return properties;
1101
- }
1102
-
1103
- genPropertyListOfFrom(node: QueryFromExpression | QueryJoinExpression, entities: any[] = []) {
1104
- if (!node)
1105
- return [];
1106
-
1107
- const entityName = node.entityName;
1108
- const entityNamespace = node.entityNamespace;
1109
- entities.push({
1110
- concept: 'StructureProperty',
1111
- name: utils.firstLowerCase(entityName),
1112
- typeAnnotation: {
1113
- concept: 'TypeAnnotation',
1114
- typeKind: 'reference',
1115
- typeName: entityName,
1116
- typeNamespace: entityNamespace,
1117
- },
1118
- });
1119
-
1120
- for (const sub of node.joinParts) {
1121
- this.genPropertyListOfFrom(sub, entities);
1122
- }
1123
-
1124
- return entities;
1125
- }
1126
-
1127
- genPropertyListOfAggregate(node: CallQueryComponent, entities: Entity[]) {
1128
- return node.select.selectAggregateElements
1129
- .filter((item) => item.aggregateName && item.asName)
1130
- .map((item) => {
1131
- let typeName;
1132
- if (['COUNT', 'COUNTD'].includes(item.aggregateName)) {
1133
- typeName = 'Long';
1134
- } else if (['AVG'].includes(item.aggregateName)) {
1135
- const { entityAsName, propertyName } = item.aggregateParam;
1136
- const entity = entities.find((item: Entity) => item.name === entityAsName);
1137
- const property = entity?.properties.find((item: any) => item.name === propertyName);
1138
- const propertyTypeName = property?.typeAnnotation?.typeName;
1139
- if (propertyTypeName === 'Decimal') {
1140
- typeName = 'Decimal';
1141
- } else {
1142
- typeName = 'Decimal';
1143
- }
1144
- } else {
1145
- const { entityAsName, propertyName } = item.aggregateParam;
1146
- const entity = entities.find((item: Entity) => item.name === entityAsName);
1147
- const property = entity?.properties.find((item) => item.name === propertyName);
1148
- typeName = property?.typeAnnotation?.typeName;
1149
- }
1150
- return {
1151
- concept: 'StructureProperty',
1152
- name: item.asName,
1153
- typeAnnotation: {
1154
- concept: 'TypeAnnotation',
1155
- typeKind: 'primitive',
1156
- typeNamespace: 'nasl.core',
1157
- typeName,
1158
- },
1159
- };
1160
- });
1161
- }
1162
-
1163
- genPropertyListOfGroupBy(node: CallQueryComponent, entities: Entity[]) {
1164
- return node.groupBy
1165
- .filter((item) => item.groupElement && (item.groupElement as QueryFieldExpression).propertyName && (item.groupElement as QueryFieldExpression).asName)
1166
- .map((item) => {
1167
- const { entityAsName, propertyName, asName } = item.groupElement as QueryFieldExpression;
1168
- const entity = entities.find((item: Entity) => item.name === entityAsName);
1169
- const property = entity?.properties.find((item) => item.name === propertyName);
1170
- const propertyTypeAnnotation = property?.typeAnnotation;
1171
-
1172
- return {
1173
- concept: 'StructureProperty',
1174
- name: asName,
1175
- typeAnnotation: {
1275
+ typeKind: 'generic',
1276
+ typeName: 'List',
1277
+ typeNamespace: 'nasl.collection',
1278
+ typeArguments: [
1279
+ TypeAnnotation.from({
1176
1280
  concept: propertyTypeAnnotation.concept,
1177
1281
  typeKind: propertyTypeAnnotation.typeKind,
1178
1282
  typeName: propertyTypeAnnotation.typeName,
1179
1283
  typeNamespace: propertyTypeAnnotation.typeNamespace,
1180
- },
1181
- };
1182
- });
1183
- }
1184
-
1185
- genStructure(structureName?: string, properties: any[] = []) {
1186
- const logic = this.logic || this.AuthLogic || this.AuthLogicForCallInterface;
1187
- return Structure.from({
1188
- concept: 'Structure',
1189
- name: structureName || this.typeAnnotation?.typeName || `${utils.firstUpperCase(logic.name)}Structure`,
1190
- origin: 'CallQueryComponent',
1191
- properties,
1192
- });
1193
- }
1194
-
1195
- saveStructure() {
1196
- // 没有数据源时不初始化数据结构
1197
- if (!this.entityInfos.length) {
1198
- return;
1199
- }
1200
- const entityNamespace = this.from?.entityNamespace;
1201
- const entities = this.app.findNodeByCompleteName(entityNamespace);
1202
- if (!this.isAutoInfer()) {
1203
- // 存量应用走之前的逻辑
1204
- return this.saveStructureNoInfer(entities);
1205
- }
1206
-
1207
- const groupBy = this.groupBy;
1208
- const selectElements = this.select.selectAggregateElements;
1209
- let structureName;
1210
- let typeAnnotation;
1211
-
1212
- // remove structure
1213
- if (this.typeAnnotation) {
1214
- const { typeNamespace, typeName, typeArguments } = this.typeAnnotation;
1215
- if (typeNamespace === 'app.structures') {
1216
- structureName = typeName;
1217
- this.removeStructure(structureName);
1218
- } else if (typeNamespace === 'nasl.collection' && typeName === 'PageOf') {
1219
- // PageOf<Structures>
1220
- if (typeArguments[0].typeNamespace === 'app.structures') {
1221
- structureName = typeArguments[0].typeName;
1222
- this.removeStructure(structureName);
1223
- }
1224
- }
1225
- }
1226
-
1227
- const logic = this.logic || this.AuthLogic || this.AuthLogicForCallInterface || this.OverriddenLogic;
1228
- structureName = structureName || utils.unique(`${utils.firstUpperCase(logic?.name)}Structure`, this.app.getStructureExistingNames());
1229
- const groupByLength = groupBy.filter((item) => (item.groupElement as QueryFieldExpression)?.propertyName && (item.groupElement as QueryFieldExpression).asName).length;
1230
- const aggregateLength = selectElements.filter((item) => item.aggregateName && item.asName).length;
1231
-
1232
- // 1. 有分组
1233
- if (groupByLength) {
1234
- if (!aggregateLength && groupByLength === 1) {
1235
- // 1.1 单分组无聚合:`{ list: List<列的类型>, total: Long }`
1236
- const { entityAsName, propertyName } = groupBy[0].groupElement as QueryFieldExpression;
1237
- const entity = entities.find((item: Entity) => item.name === entityAsName);
1238
- const property = entity?.properties.find((item: any) => item.name === propertyName);
1239
- const propertyTypeAnnotation = property.typeAnnotation;
1240
-
1241
- typeAnnotation = TypeAnnotation.from({
1242
- concept: 'TypeAnnotation',
1243
- typeKind: 'anonymousStructure',
1244
- properties: [
1245
- StructureProperty.from({
1246
- name: 'list',
1247
- typeAnnotation: TypeAnnotation.from({
1248
- concept: 'TypeAnnotation',
1249
- typeKind: 'generic',
1250
- typeName: 'List',
1251
- typeNamespace: 'nasl.collection',
1252
- typeArguments: [TypeAnnotation.from({
1253
- concept: propertyTypeAnnotation.concept,
1254
- typeKind: propertyTypeAnnotation.typeKind,
1255
- typeName: propertyTypeAnnotation.typeName,
1256
- typeNamespace: propertyTypeAnnotation.typeNamespace,
1257
- })],
1258
- }, this.typeAnnotation, 'typeAnnotation'),
1259
- }),
1260
- StructureProperty.from({
1261
- name: 'total',
1262
- typeAnnotation: TypeAnnotation.from({
1263
- concept: 'TypeAnnotation',
1264
- typeKind: 'primitive',
1265
- typeNamespace: 'nasl.core',
1266
- typeName: 'Long',
1267
- }, this.typeAnnotation, 'typeAnnotation'),
1268
- }),
1284
+ }),
1269
1285
  ],
1270
- }, this, 'typeAnnotation');
1271
- } else {
1272
- // 1.2 多分组:`{ list: List<anonymousStructure>, total: Long }`
1273
- typeAnnotation = TypeAnnotation.from({
1286
+ },
1287
+ this.typeAnnotation,
1288
+ 'typeAnnotation'
1289
+ ),
1290
+ }),
1291
+ StructureProperty.from({
1292
+ name: 'total',
1293
+ typeAnnotation: TypeAnnotation.from(
1294
+ {
1274
1295
  concept: 'TypeAnnotation',
1275
- typeKind: 'anonymousStructure',
1276
- properties: [
1277
- StructureProperty.from({
1278
- name: 'list',
1279
- typeAnnotation: TypeAnnotation.from({
1280
- concept: 'TypeAnnotation',
1281
- typeKind: 'generic',
1282
- typeName: 'List',
1283
- typeNamespace: 'nasl.collection',
1284
- typeArguments: [
1285
- TypeAnnotation.from({
1286
- concept: 'TypeAnnotation',
1287
- typeKind: 'anonymousStructure',
1288
- properties: [
1289
- ...this.genPropertyListOfGroupBy(this, entities),
1290
- ...this.genPropertyListOfAggregate(this, entities),
1291
- ],
1292
- }),
1293
- ],
1294
- }, this.typeAnnotation, 'typeAnnotation'),
1295
- }),
1296
- StructureProperty.from({
1297
- name: 'total',
1298
- typeAnnotation: TypeAnnotation.from({
1299
- concept: 'TypeAnnotation',
1300
- typeKind: 'primitive',
1301
- typeNamespace: 'nasl.core',
1302
- typeName: 'Long',
1303
- }, this.typeAnnotation, 'typeAnnotation'),
1304
- }),
1305
- ],
1306
- }, this, 'typeAnnotation');
1307
- }
1308
- } else { // 2. 无分组
1309
- if (aggregateLength) {
1310
- if (aggregateLength === 1) {
1311
- // 2.1 单聚合:`基本类型`
1312
- let typeName;
1313
- if (['COUNT', 'COUNTD'].includes(selectElements[0].aggregateName)) {
1314
- // 2.1.1. `COUNT`、`COUNTD` 返回 `Long`
1315
- typeName = 'Long';
1316
- } else if (['AVG'].includes(selectElements[0].aggregateName)) {
1317
- const { entityAsName, propertyName } = selectElements[0].aggregateParam;
1318
- const entity = entities.find((item: Entity) => item.name === entityAsName);
1319
- const property = entity?.properties.find((item: any) => item.name === propertyName);
1320
- const propertyTypeName = property?.typeAnnotation?.typeName;
1321
- if (propertyTypeName === 'Decimal') {
1322
- typeName = 'Decimal';
1323
- } else {
1324
- typeName = 'Double';
1325
- }
1326
- } else {
1327
- // 2.1.3. 其他返回列类型,包含:`Long`、`Long`、`Double`
1328
- const { entityAsName, propertyName } = selectElements[0].aggregateParam;
1329
- const entity = entities.find((item: Entity) => item.name === entityAsName);
1330
- const property = entity?.properties.find((item: any) => item.name === propertyName);
1331
- typeName = property?.typeAnnotation?.typeName;
1332
- }
1333
- typeAnnotation = TypeAnnotation.from({
1334
- concept: 'TypeAnnotation',
1335
- typeKind: 'primitive',
1336
- typeName,
1337
- typeNamespace: 'nasl.core',
1338
- }, this, 'typeAnnotation');
1339
- } else {
1340
- // 2.2 多聚合:`{ Structure }`
1341
- typeAnnotation = TypeAnnotation.from({
1296
+ typeKind: 'primitive',
1297
+ typeNamespace: 'nasl.core',
1298
+ typeName: 'Long',
1299
+ },
1300
+ this.typeAnnotation,
1301
+ 'typeAnnotation'
1302
+ ),
1303
+ }),
1304
+ ],
1305
+ },
1306
+ this,
1307
+ 'typeAnnotation'
1308
+ );
1309
+ } else {
1310
+ // 1.2 多分组:`{ list: List<anonymousStructure>, total: Long }`
1311
+ typeAnnotation = TypeAnnotation.from(
1312
+ {
1313
+ concept: 'TypeAnnotation',
1314
+ typeKind: 'anonymousStructure',
1315
+ properties: [
1316
+ StructureProperty.from({
1317
+ name: 'list',
1318
+ typeAnnotation: TypeAnnotation.from(
1319
+ {
1320
+ concept: 'TypeAnnotation',
1321
+ typeKind: 'generic',
1322
+ typeName: 'List',
1323
+ typeNamespace: 'nasl.collection',
1324
+ typeArguments: [
1325
+ TypeAnnotation.from({
1342
1326
  concept: 'TypeAnnotation',
1343
1327
  typeKind: 'anonymousStructure',
1344
- properties: [...this.genPropertyListOfAggregate(this, entities)],
1345
- }, this, 'typeAnnotation');
1346
- }
1347
- } else {
1348
- // 2.3 无分组&&无聚合 (默认情况):`{ list: List<Structure>, total: Long }`
1349
- typeAnnotation = TypeAnnotation.from({
1350
- concept: 'TypeAnnotation',
1351
- typeKind: 'anonymousStructure',
1352
- properties: [
1353
- StructureProperty.from({
1354
- name: 'list',
1355
- typeAnnotation: TypeAnnotation.from({
1356
- concept: 'TypeAnnotation',
1357
- typeKind: 'generic',
1358
- typeName: 'List',
1359
- typeNamespace: 'nasl.collection',
1360
- typeArguments: [
1361
- TypeAnnotation.from({
1362
- concept: 'TypeAnnotation',
1363
- typeKind: 'anonymousStructure',
1364
- properties: this.genPropertiesFrom(this.from),
1365
- }),
1366
- ],
1367
- }, this.typeAnnotation, 'typeAnnotation'),
1368
- }),
1369
- StructureProperty.from({
1370
- name: 'total',
1371
- typeAnnotation: TypeAnnotation.from({
1372
- concept: 'TypeAnnotation',
1373
- typeKind: 'primitive',
1374
- typeNamespace: 'nasl.core',
1375
- typeName: 'Long',
1376
- }, this.typeAnnotation, 'typeAnnotation'),
1377
- }),
1328
+ properties: [...this.genPropertyListOfGroupBy(this, entities), ...this.genPropertyListOfAggregate(this, entities)],
1329
+ }),
1378
1330
  ],
1379
- }, this, 'typeAnnotation');
1380
- }
1381
- }
1382
-
1383
- this.update({ typeAnnotation });
1384
- }
1385
-
1386
- saveStructureNoInfer(entities: any[] = []) {
1387
- const source = this.genStructure(null, [
1388
- ...this.genPropertyListOfFrom(this.from),
1389
- ...this.genPropertyListOfAggregate(this, entities),
1390
- ]);
1391
- if (this.typeAnnotation) {
1392
- // 老版本没有 ListTotal 结构,支持匿名数据结构
1393
- if (this.typeAnnotation.typeKind === 'anonymousStructure') {
1394
- const typeAnnotation = TypeAnnotation.from({
1331
+ },
1332
+ this.typeAnnotation,
1333
+ 'typeAnnotation'
1334
+ ),
1335
+ }),
1336
+ StructureProperty.from({
1337
+ name: 'total',
1338
+ typeAnnotation: TypeAnnotation.from(
1339
+ {
1395
1340
  concept: 'TypeAnnotation',
1396
- typeKind: 'anonymousStructure',
1397
- properties: source.properties,
1398
- }, this, 'typeAnnotation');
1399
- this.update({ typeAnnotation });
1341
+ typeKind: 'primitive',
1342
+ typeNamespace: 'nasl.core',
1343
+ typeName: 'Long',
1344
+ },
1345
+ this.typeAnnotation,
1346
+ 'typeAnnotation'
1347
+ ),
1348
+ }),
1349
+ ],
1350
+ },
1351
+ this,
1352
+ 'typeAnnotation'
1353
+ );
1354
+ }
1355
+ } else {
1356
+ // 2. 无分组
1357
+ if (aggregateLength) {
1358
+ if (aggregateLength === 1) {
1359
+ // 2.1 单聚合:`基本类型`
1360
+ let typeName;
1361
+ if (['COUNT', 'COUNTD'].includes(selectElements[0].aggregateName)) {
1362
+ // 2.1.1. `COUNT`、`COUNTD` 返回 `Long`
1363
+ typeName = 'Long';
1364
+ } else if (['AVG'].includes(selectElements[0].aggregateName)) {
1365
+ const { entityAsName, propertyName } = selectElements[0].aggregateParam;
1366
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
1367
+ const property = entity?.properties.find((item: any) => item.name === propertyName);
1368
+ const propertyTypeName = property?.typeAnnotation?.typeName;
1369
+ if (propertyTypeName === 'Decimal') {
1370
+ typeName = 'Decimal';
1400
1371
  } else {
1401
- const structure = this.app.structures.find((item) => item.name === this.typeAnnotation.typeName);
1402
- if (structure) {
1403
- const properties = source.properties.map((property) => StructureProperty.from(property, structure, 'properties'));
1404
- structure.update({
1405
- properties,
1406
- });
1407
- } else
1408
- this.app.addStructure(source);
1372
+ typeName = 'Double';
1409
1373
  }
1374
+ } else {
1375
+ // 2.1.3. 其他返回列类型,包含:`Long`、`Long`、`Double`
1376
+ const { entityAsName, propertyName } = selectElements[0].aggregateParam;
1377
+ const entity = entities.find((item: Entity) => item.name === entityAsName);
1378
+ const property = entity?.properties.find((item: any) => item.name === propertyName);
1379
+ typeName = property?.typeAnnotation?.typeName;
1380
+ }
1381
+ typeAnnotation = TypeAnnotation.from(
1382
+ {
1383
+ concept: 'TypeAnnotation',
1384
+ typeKind: 'primitive',
1385
+ typeName,
1386
+ typeNamespace: 'nasl.core',
1387
+ },
1388
+ this,
1389
+ 'typeAnnotation'
1390
+ );
1410
1391
  } else {
1411
- source.name = utils.unique(source.name, this.app.getStructureExistingNames());
1412
- this.app.addStructure(source);
1413
- const typeAnnotation = TypeAnnotation.from({
1414
- concept: 'TypeAnnotation',
1415
- typeKind: 'reference',
1416
- typeName: source.name,
1417
- typeNamespace: `app.structures`,
1418
- }, this, 'typeAnnotation');
1419
- this.update({
1420
- typeAnnotation,
1421
- });
1392
+ // 2.2 多聚合:`{ Structure }`
1393
+ typeAnnotation = TypeAnnotation.from(
1394
+ {
1395
+ concept: 'TypeAnnotation',
1396
+ typeKind: 'anonymousStructure',
1397
+ properties: [...this.genPropertyListOfAggregate(this, entities)],
1398
+ },
1399
+ this,
1400
+ 'typeAnnotation'
1401
+ );
1422
1402
  }
1403
+ } else {
1404
+ // 2.3 无分组&&无聚合 (默认情况):`{ list: List<Structure>, total: Long }`
1405
+ typeAnnotation = TypeAnnotation.from(
1406
+ {
1407
+ concept: 'TypeAnnotation',
1408
+ typeKind: 'anonymousStructure',
1409
+ properties: [
1410
+ StructureProperty.from({
1411
+ name: 'list',
1412
+ typeAnnotation: TypeAnnotation.from(
1413
+ {
1414
+ concept: 'TypeAnnotation',
1415
+ typeKind: 'generic',
1416
+ typeName: 'List',
1417
+ typeNamespace: 'nasl.collection',
1418
+ typeArguments: [
1419
+ TypeAnnotation.from({
1420
+ concept: 'TypeAnnotation',
1421
+ typeKind: 'anonymousStructure',
1422
+ properties: this.genPropertiesFrom(this.from),
1423
+ }),
1424
+ ],
1425
+ },
1426
+ this.typeAnnotation,
1427
+ 'typeAnnotation'
1428
+ ),
1429
+ }),
1430
+ StructureProperty.from({
1431
+ name: 'total',
1432
+ typeAnnotation: TypeAnnotation.from(
1433
+ {
1434
+ concept: 'TypeAnnotation',
1435
+ typeKind: 'primitive',
1436
+ typeNamespace: 'nasl.core',
1437
+ typeName: 'Long',
1438
+ },
1439
+ this.typeAnnotation,
1440
+ 'typeAnnotation'
1441
+ ),
1442
+ }),
1443
+ ],
1444
+ },
1445
+ this,
1446
+ 'typeAnnotation'
1447
+ );
1448
+ }
1423
1449
  }
1424
1450
 
1425
- removeStructure(structureName?: string) {
1426
- try {
1427
- if (this.typeAnnotation) {
1428
- const { typeNamespace, typeName, typeArguments } = this.typeAnnotation;
1429
- if (typeNamespace === 'app.structures') {
1430
- // Structures
1431
- structureName = typeName;
1432
- this.app.removeStructure(structureName);
1433
- } else if (typeNamespace === 'nasl.collection' && typeName === 'PageOf') {
1434
- // PageOf<Structures>
1435
- if (typeArguments[0].typeNamespace === 'app.structures') {
1436
- structureName = typeArguments[0].typeName;
1437
- this.app.removeStructure(structureName);
1438
- }
1439
- }
1440
- }
1441
- } catch { }
1442
- }
1443
-
1444
- getEntityInfos(node: QueryFromExpression | QueryJoinExpression, set = new Set()) {
1445
- if (node?.entityName)
1446
- set.add({
1447
- namespace: node.entityNamespace,
1448
- name: node.entityName,
1449
- });
1450
-
1451
- node?.joinParts?.forEach((child) => {
1452
- this.getEntityInfos(child, set);
1453
- });
1454
- return Array.from(set);
1455
- }
1456
-
1457
- get entityInfos() {
1458
- return this.getEntityInfos(this.from);
1451
+ this.update({ typeAnnotation });
1452
+ }
1453
+
1454
+ saveStructureNoInfer(entities: any[] = []) {
1455
+ const source = this.genStructure(null, [...this.genPropertyListOfFrom(this.from), ...this.genPropertyListOfAggregate(this, entities)]);
1456
+ if (this.typeAnnotation) {
1457
+ // 老版本没有 ListTotal 结构,支持匿名数据结构
1458
+ if (this.typeAnnotation.typeKind === 'anonymousStructure') {
1459
+ const typeAnnotation = TypeAnnotation.from(
1460
+ {
1461
+ concept: 'TypeAnnotation',
1462
+ typeKind: 'anonymousStructure',
1463
+ properties: source.properties,
1464
+ },
1465
+ this,
1466
+ 'typeAnnotation'
1467
+ );
1468
+ this.update({ typeAnnotation });
1469
+ } else {
1470
+ const structure = this.app.structures.find((item) => item.name === this.typeAnnotation.typeName);
1471
+ if (structure) {
1472
+ const properties = source.properties.map((property) => StructureProperty.from(property, structure, 'properties'));
1473
+ structure.update({
1474
+ properties,
1475
+ });
1476
+ } else this.app.addStructure(source);
1477
+ }
1478
+ } else {
1479
+ source.name = utils.unique(source.name, this.app.getStructureExistingNames());
1480
+ this.app.addStructure(source);
1481
+ const typeAnnotation = TypeAnnotation.from(
1482
+ {
1483
+ concept: 'TypeAnnotation',
1484
+ typeKind: 'reference',
1485
+ typeName: source.name,
1486
+ typeNamespace: `app.structures`,
1487
+ },
1488
+ this,
1489
+ 'typeAnnotation'
1490
+ );
1491
+ this.update({
1492
+ typeAnnotation,
1493
+ });
1459
1494
  }
1460
-
1461
- getCompletionPropertyOfEntities() {
1462
- const firstEntityInfo: any = this.entityInfos[0];
1463
- if (firstEntityInfo) {
1464
- const namespace = firstEntityInfo.namespace;
1465
- const entities: Entity[] = this.app.findNodeByCompleteName(namespace);
1466
- if (Array.isArray(entities)) {
1467
- const children = this.entityInfos
1468
- .map(({ name }) => entities.find((item) => item.name === name))
1469
- .filter((item) => item)
1470
- .map((entity) => ({
1471
- concept: 'Entity',
1472
- name: entity.name,
1473
- children: entity.properties.map((property) => {
1474
- const expression = LogicItem.from({
1475
- concept: 'QueryFieldExpression',
1476
- name: property.name,
1477
- value: `${entity.name}.${property.name}`,
1478
- entityAsName: entity.name,
1479
- propertyName: property.name,
1480
- });
1481
- expression.parentNode = this;
1482
- const completionProperty = new CompletionProperty({
1483
- concept: 'CompletionProperty',
1484
- name: property.name,
1485
- value: `${entity.name}.${property.name}`,
1486
- expression,
1487
- });
1488
- completionProperty.icon = 'property';
1489
- // 标记实体属性是否是符合类型
1490
- Object.assign(completionProperty, { isComplexType: property.typeAnnotation.isComplexType() });
1491
- return completionProperty;
1492
- }),
1493
- }));
1494
- if (children.length) {
1495
- return {
1496
- name: '实体',
1497
- icon: 'category',
1498
- children,
1499
- };
1500
- }
1501
- }
1495
+ }
1496
+
1497
+ removeStructure(structureName?: string) {
1498
+ try {
1499
+ if (this.typeAnnotation) {
1500
+ const { typeNamespace, typeName, typeArguments } = this.typeAnnotation;
1501
+ if (typeNamespace === 'app.structures') {
1502
+ // Structures
1503
+ structureName = typeName;
1504
+ this.app.removeStructure(structureName);
1505
+ } else if (typeNamespace === 'nasl.collection' && typeName === 'PageOf') {
1506
+ // PageOf<Structures>
1507
+ if (typeArguments[0].typeNamespace === 'app.structures') {
1508
+ structureName = typeArguments[0].typeName;
1509
+ this.app.removeStructure(structureName);
1510
+ }
1502
1511
  }
1512
+ }
1513
+ } catch {}
1514
+ }
1515
+
1516
+ getEntityInfos(node: QueryFromExpression | QueryJoinExpression, set = new Set()) {
1517
+ if (node?.entityName)
1518
+ set.add({
1519
+ namespace: node.entityNamespace,
1520
+ name: node.entityName,
1521
+ });
1522
+
1523
+ node?.joinParts?.forEach((child) => {
1524
+ this.getEntityInfos(child, set);
1525
+ });
1526
+ return Array.from(set);
1527
+ }
1528
+
1529
+ get entityInfos() {
1530
+ return this.getEntityInfos(this.from);
1531
+ }
1532
+
1533
+ getCompletionPropertyOfEntities() {
1534
+ const firstEntityInfo: any = this.entityInfos[0];
1535
+ if (firstEntityInfo) {
1536
+ const { namespace } = firstEntityInfo;
1537
+ const entities: Entity[] = this.app.findNodeByCompleteName(namespace);
1538
+ if (Array.isArray(entities)) {
1539
+ const children = this.entityInfos
1540
+ .map(({ name }) => entities.find((item) => item.name === name))
1541
+ .filter((item) => item)
1542
+ .map((entity) => ({
1543
+ concept: 'Entity',
1544
+ name: entity.name,
1545
+ children: entity.properties.map((property) => {
1546
+ const expression = LogicItem.from({
1547
+ concept: 'QueryFieldExpression',
1548
+ name: property.name,
1549
+ value: `${entity.name}.${property.name}`,
1550
+ entityAsName: entity.name,
1551
+ propertyName: property.name,
1552
+ });
1553
+ expression.parentNode = this;
1554
+ const completionProperty = new CompletionProperty({
1555
+ concept: 'CompletionProperty',
1556
+ name: property.name,
1557
+ value: `${entity.name}.${property.name}`,
1558
+ expression,
1559
+ });
1560
+ completionProperty.icon = 'property';
1561
+ // 标记实体属性是否是符合类型
1562
+ Object.assign(completionProperty, { isComplexType: property.typeAnnotation.isComplexType() });
1563
+ return completionProperty;
1564
+ }),
1565
+ }));
1566
+ if (children.length) {
1567
+ return {
1568
+ name: '实体',
1569
+ icon: 'category',
1570
+ children,
1571
+ };
1572
+ }
1573
+ }
1503
1574
  }
1504
-
1505
- getCompletionPropertyOfAggregateAsNames() {
1506
- const children = this.select?.selectElements
1507
- ?.filter((item) => item.concept === 'QueryAggregateExpression' && item.asName)
1508
- .map((item) =>
1509
- new CompletionProperty({
1510
- concept: 'CompletionProperty',
1511
- name: item.asName,
1512
- value: `inner.${item.asName}`,
1513
- expression: LogicItem.from({
1514
- concept: 'Identifier',
1515
- name: item.asName,
1516
- namespace: 'inner',
1517
- }),
1518
- }));
1519
- if (!children || children.length === 0)
1520
- return;
1521
-
1522
- children.forEach((item) => {
1523
- item.icon = 'variable';
1524
- });
1525
- return { name: '聚合属性别名', icon: 'category', children, expanded: true };
1526
- }
1527
-
1528
- getCompletionPropertyOfGroupByAsNames() {
1529
- const children = this.groupBy
1530
- ?.filter((item) => item.concept === 'QueryGroupByExpression' && (item.groupElement as QueryFieldExpression)?.asName)
1531
- .map((item) =>
1532
- new CompletionProperty({
1533
- concept: 'CompletionProperty',
1534
- name: (item.groupElement as QueryFieldExpression).asName,
1535
- value: `inner.${(item.groupElement as QueryFieldExpression).asName}`,
1536
- expression: LogicItem.from({
1537
- concept: 'Identifier',
1538
- name: (item.groupElement as QueryFieldExpression).asName,
1539
- namespace: 'inner',
1540
- }),
1541
- }));
1542
- if (!children || children.length === 0)
1543
- return;
1544
-
1545
- children.forEach((item) => {
1546
- item.icon = 'variable';
1547
- });
1548
- return { name: '分组属性别名', icon: 'category', children, expanded: true };
1549
- }
1550
-
1551
- /**
1552
- * 获取当前内部使用到的变量
1553
- */
1554
- getContentVariable() {
1555
- const contentVariables: Array<Identifier | MemberExpression> = [];
1556
- utils.traverse(({ node }) => {
1557
- if ((node as any)?.parentNode?.concept !== 'MemberExpression') {
1558
- if ((node as any)?.concept === 'MemberExpression') {
1559
- contentVariables.push(node as any);
1560
- } else if ((node as any)?.concept === 'Identifier') {
1561
- // 因为要是父级是MemberExpression 就放入了父级,子级就不需要了
1562
- contentVariables.push(node as any);
1563
- }
1564
- }
1565
- }, { node: this }, {
1566
- mode: 'anyObject',
1567
- excludedKeySet: new Set(['parentNode', '_events', 'globalDataMap', 'havingPlayground', 'wherePlayground']),
1568
- });
1569
- return contentVariables;
1570
- }
1571
- // 临时升级脚本
1572
- // 将所有from的实体,在selectElements中初始化一个isDotStar=true的QueryFieldExpression
1573
- initFieldSelectElement(node: CallQueryComponent = this) {
1574
- const loop = (from: QueryFromExpression | QueryJoinExpression) => {
1575
- node.select.addQueryFieldExpressionInSelectElements({
1576
- entityAsName: from.entityName,
1577
- isDotStar: true,
1578
- });
1579
- from.joinParts?.forEach(loop);
1580
- };
1581
- loop(node.from);
1582
- }
1583
- //================================================================================
1584
- // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
1585
- // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
1586
- //================================================================================
1575
+ }
1576
+
1577
+ getCompletionPropertyOfAggregateAsNames() {
1578
+ const children = this.select?.selectElements
1579
+ ?.filter((item) => item.concept === 'QueryAggregateExpression' && item.asName)
1580
+ .map(
1581
+ (item) =>
1582
+ new CompletionProperty({
1583
+ concept: 'CompletionProperty',
1584
+ name: item.asName,
1585
+ value: `inner.${item.asName}`,
1586
+ expression: LogicItem.from({
1587
+ concept: 'Identifier',
1588
+ name: item.asName,
1589
+ namespace: 'inner',
1590
+ }),
1591
+ })
1592
+ );
1593
+ if (!children || children.length === 0) return;
1594
+
1595
+ children.forEach((item) => {
1596
+ item.icon = 'variable';
1597
+ });
1598
+ return { name: '聚合属性别名', icon: 'category', children, expanded: true };
1599
+ }
1600
+
1601
+ getCompletionPropertyOfGroupByAsNames() {
1602
+ const children = this.groupBy
1603
+ ?.filter((item) => item.concept === 'QueryGroupByExpression' && (item.groupElement as QueryFieldExpression)?.asName)
1604
+ .map(
1605
+ (item) =>
1606
+ new CompletionProperty({
1607
+ concept: 'CompletionProperty',
1608
+ name: (item.groupElement as QueryFieldExpression).asName,
1609
+ value: `inner.${(item.groupElement as QueryFieldExpression).asName}`,
1610
+ expression: LogicItem.from({
1611
+ concept: 'Identifier',
1612
+ name: (item.groupElement as QueryFieldExpression).asName,
1613
+ namespace: 'inner',
1614
+ }),
1615
+ })
1616
+ );
1617
+ if (!children || children.length === 0) return;
1618
+
1619
+ children.forEach((item) => {
1620
+ item.icon = 'variable';
1621
+ });
1622
+ return { name: '分组属性别名', icon: 'category', children, expanded: true };
1623
+ }
1624
+
1625
+ /**
1626
+ * 获取当前内部使用到的变量
1627
+ */
1628
+ getContentVariable() {
1629
+ const contentVariables: Array<Identifier | MemberExpression> = [];
1630
+ utils.traverse(
1631
+ ({ node }) => {
1632
+ if ((node as any)?.parentNode?.concept !== 'MemberExpression') {
1633
+ if ((node as any)?.concept === 'MemberExpression') {
1634
+ contentVariables.push(node as any);
1635
+ } else if ((node as any)?.concept === 'Identifier') {
1636
+ // 因为要是父级是MemberExpression, 就放入了父级,子级就不需要了
1637
+ contentVariables.push(node as any);
1638
+ }
1639
+ }
1640
+ },
1641
+ { node: this },
1642
+ {
1643
+ mode: 'anyObject',
1644
+ excludedKeySet: new Set(['parentNode', '_events', 'globalDataMap', 'havingPlayground', 'wherePlayground']),
1645
+ }
1646
+ );
1647
+ return contentVariables;
1648
+ }
1649
+
1650
+ // 临时升级脚本
1651
+ // 将所有from的实体,在selectElements中初始化一个isDotStar=true的QueryFieldExpression
1652
+ initFieldSelectElement(node: CallQueryComponent = this) {
1653
+ const loop = (from: QueryFromExpression | QueryJoinExpression) => {
1654
+ node.select.addQueryFieldExpressionInSelectElements({
1655
+ entityAsName: from.entityName,
1656
+ isDotStar: true,
1657
+ });
1658
+ from.joinParts?.forEach(loop);
1659
+ };
1660
+ loop(node.from);
1661
+ }
1662
+ //= ===============================================================================
1663
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
1664
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
1665
+ //= ===============================================================================
1587
1666
  }
1588
1667
 
1589
1668
  classMap.CallQueryComponent = CallQueryComponent;
1590
1669
  export default CallQueryComponent;
1591
- //================================================================================
1670
+ //= ===============================================================================
1592
1671
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1593
1672
  // 自动生成的代码已结束。下面可以手动编写。
1594
- //================================================================================
1673
+ //= ===============================================================================