@lcap/nasl 3.2.0-beta.4 → 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 (774) hide show
  1. package/out/automate/upgrader/2.20.js +1 -1
  2. package/out/automate/upgrader/2.20.js.map +1 -1
  3. package/out/bak/translator.js +11 -15
  4. package/out/bak/translator.js.map +1 -1
  5. package/out/breakpoint/generator/AfterStartNode.js +3 -1
  6. package/out/breakpoint/generator/AfterStartNode.js.map +1 -1
  7. package/out/breakpoint/generator/BeforeEndNode.js.map +1 -1
  8. package/out/breakpoint/generator/BreakpointNode.d.ts +1 -0
  9. package/out/breakpoint/generator/BreakpointNode.js +48 -15
  10. package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
  11. package/out/breakpoint/generator/CallbackNode.d.ts +4 -0
  12. package/out/breakpoint/generator/CallbackNode.js +22 -0
  13. package/out/breakpoint/generator/CallbackNode.js.map +1 -0
  14. package/out/breakpoint/generator/FragmentNode.d.ts +4 -0
  15. package/out/breakpoint/generator/FragmentNode.js +18 -0
  16. package/out/breakpoint/generator/FragmentNode.js.map +1 -0
  17. package/out/breakpoint/generator/index.js +25 -4
  18. package/out/breakpoint/generator/index.js.map +1 -1
  19. package/out/breakpoint/shared/constants.d.ts +3 -0
  20. package/out/breakpoint/shared/constants.js +6 -1
  21. package/out/breakpoint/shared/constants.js.map +1 -1
  22. package/out/breakpoint/shared/operations.js.map +1 -1
  23. package/out/breakpoint/shared/socket.d.ts +1 -1
  24. package/out/breakpoint/shared/socket.js +36 -7
  25. package/out/breakpoint/shared/socket.js.map +1 -1
  26. package/out/breakpoint/shared/utils.d.ts +2 -0
  27. package/out/breakpoint/shared/utils.js +15 -2
  28. package/out/breakpoint/shared/utils.js.map +1 -1
  29. package/out/breakpoint/store/core.d.ts +48 -2
  30. package/out/breakpoint/store/core.js +58 -32
  31. package/out/breakpoint/store/core.js.map +1 -1
  32. package/out/breakpoint/store/dock.js +1 -1
  33. package/out/breakpoint/store/dock.js.map +1 -1
  34. package/out/common/BaseNode.d.ts +1 -1
  35. package/out/common/BaseNode.js +105 -51
  36. package/out/common/BaseNode.js.map +1 -1
  37. package/out/common/Command.d.ts +13 -2
  38. package/out/common/Command.js +37 -9
  39. package/out/common/Command.js.map +1 -1
  40. package/out/common/EventEmitter.js.map +1 -1
  41. package/out/common/Messager.d.ts +3 -3
  42. package/out/common/Messager.js +6 -7
  43. package/out/common/Messager.js.map +1 -1
  44. package/out/common/asyncFuncMap.js.map +1 -1
  45. package/out/concepts/Abort__.js +6 -5
  46. package/out/concepts/Abort__.js.map +1 -1
  47. package/out/concepts/Anchor__.d.ts +4 -3
  48. package/out/concepts/Anchor__.js +24 -7
  49. package/out/concepts/Anchor__.js.map +1 -1
  50. package/out/concepts/AnonymousFunction__.d.ts +22 -21
  51. package/out/concepts/AnonymousFunction__.js +48 -22
  52. package/out/concepts/AnonymousFunction__.js.map +1 -1
  53. package/out/concepts/App__.d.ts +421 -247
  54. package/out/concepts/App__.js +286 -54
  55. package/out/concepts/App__.js.map +1 -1
  56. package/out/concepts/Argument__.d.ts +4 -3
  57. package/out/concepts/Argument__.js +42 -11
  58. package/out/concepts/Argument__.js.map +1 -1
  59. package/out/concepts/Assignee__.d.ts +45 -45
  60. package/out/concepts/Assignee__.js +15 -15
  61. package/out/concepts/Assignee__.js.map +1 -1
  62. package/out/concepts/AssignmentLine__.js +6 -5
  63. package/out/concepts/AssignmentLine__.js.map +1 -1
  64. package/out/concepts/Assignment__.d.ts +7 -6
  65. package/out/concepts/Assignment__.js +40 -22
  66. package/out/concepts/Assignment__.js.map +1 -1
  67. package/out/concepts/Attribute__.d.ts +3 -3
  68. package/out/concepts/Attribute__.js +8 -7
  69. package/out/concepts/Attribute__.js.map +1 -1
  70. package/out/concepts/AuthInterface__.js +4 -3
  71. package/out/concepts/AuthInterface__.js.map +1 -1
  72. package/out/concepts/AuthLogicForCallInterface__.d.ts +15 -15
  73. package/out/concepts/AuthLogicForCallInterface__.js +46 -27
  74. package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
  75. package/out/concepts/AuthLogic__.js +27 -13
  76. package/out/concepts/AuthLogic__.js.map +1 -1
  77. package/out/concepts/BackendVariable__.d.ts +5 -5
  78. package/out/concepts/BackendVariable__.js +23 -26
  79. package/out/concepts/BackendVariable__.js.map +1 -1
  80. package/out/concepts/Backend__.d.ts +18 -18
  81. package/out/concepts/Backend__.js +13 -13
  82. package/out/concepts/Backend__.js.map +1 -1
  83. package/out/concepts/BatchAssignment__.d.ts +34 -33
  84. package/out/concepts/BatchAssignment__.js +83 -43
  85. package/out/concepts/BatchAssignment__.js.map +1 -1
  86. package/out/concepts/BinaryExpression__.d.ts +7 -6
  87. package/out/concepts/BinaryExpression__.js +60 -24
  88. package/out/concepts/BinaryExpression__.js.map +1 -1
  89. package/out/concepts/BindAttribute__.d.ts +37 -37
  90. package/out/concepts/BindAttribute__.js +101 -48
  91. package/out/concepts/BindAttribute__.js.map +1 -1
  92. package/out/concepts/BindDirective__.d.ts +13 -13
  93. package/out/concepts/BindDirective__.js +23 -21
  94. package/out/concepts/BindDirective__.js.map +1 -1
  95. package/out/concepts/BindEvent__.d.ts +28 -28
  96. package/out/concepts/BindEvent__.js +99 -48
  97. package/out/concepts/BindEvent__.js.map +1 -1
  98. package/out/concepts/BindStyle__.d.ts +14 -15
  99. package/out/concepts/BindStyle__.js +16 -16
  100. package/out/concepts/BindStyle__.js.map +1 -1
  101. package/out/concepts/BooleanLiteral__.d.ts +1 -0
  102. package/out/concepts/BooleanLiteral__.js +12 -5
  103. package/out/concepts/BooleanLiteral__.js.map +1 -1
  104. package/out/concepts/CallAuthInterface__.d.ts +15 -15
  105. package/out/concepts/CallAuthInterface__.js +23 -22
  106. package/out/concepts/CallAuthInterface__.js.map +1 -1
  107. package/out/concepts/CallConnector__.d.ts +11 -9
  108. package/out/concepts/CallConnector__.js +79 -36
  109. package/out/concepts/CallConnector__.js.map +1 -1
  110. package/out/concepts/CallFunction__.d.ts +17 -16
  111. package/out/concepts/CallFunction__.js +95 -63
  112. package/out/concepts/CallFunction__.js.map +1 -1
  113. package/out/concepts/CallInterface__.d.ts +9 -8
  114. package/out/concepts/CallInterface__.js +71 -30
  115. package/out/concepts/CallInterface__.js.map +1 -1
  116. package/out/concepts/CallLogic__.d.ts +20 -19
  117. package/out/concepts/CallLogic__.js +155 -52
  118. package/out/concepts/CallLogic__.js.map +1 -1
  119. package/out/concepts/CallQueryComponent__.d.ts +51 -51
  120. package/out/concepts/CallQueryComponent__.js +66 -63
  121. package/out/concepts/CallQueryComponent__.js.map +1 -1
  122. package/out/concepts/Comment__.d.ts +1 -0
  123. package/out/concepts/Comment__.js +13 -6
  124. package/out/concepts/Comment__.js.map +1 -1
  125. package/out/concepts/CompletionProperty__.d.ts +3 -3
  126. package/out/concepts/CompletionProperty__.js +8 -7
  127. package/out/concepts/CompletionProperty__.js.map +1 -1
  128. package/out/concepts/ConfigGroup__.d.ts +15 -15
  129. package/out/concepts/ConfigGroup__.js +9 -9
  130. package/out/concepts/ConfigGroup__.js.map +1 -1
  131. package/out/concepts/ConfigPropertyValue__.js +4 -3
  132. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  133. package/out/concepts/ConfigProperty__.d.ts +15 -15
  134. package/out/concepts/ConfigProperty__.js +10 -10
  135. package/out/concepts/ConfigProperty__.js.map +1 -1
  136. package/out/concepts/Configuration__.d.ts +15 -15
  137. package/out/concepts/Configuration__.js +9 -9
  138. package/out/concepts/Configuration__.js.map +1 -1
  139. package/out/concepts/Connection__.d.ts +166 -0
  140. package/out/concepts/Connection__.js +332 -0
  141. package/out/concepts/Connection__.js.map +1 -0
  142. package/out/concepts/ConnectorTrigger__.js +4 -3
  143. package/out/concepts/ConnectorTrigger__.js.map +1 -1
  144. package/out/concepts/Connector__.d.ts +66 -66
  145. package/out/concepts/Connector__.js +16 -15
  146. package/out/concepts/Connector__.js.map +1 -1
  147. package/out/concepts/Constant__.d.ts +3 -3
  148. package/out/concepts/Constant__.js +8 -7
  149. package/out/concepts/Constant__.js.map +1 -1
  150. package/out/concepts/DataElement__.d.ts +3 -3
  151. package/out/concepts/DataElement__.js +6 -5
  152. package/out/concepts/DataElement__.js.map +1 -1
  153. package/out/concepts/DataSource__.d.ts +15 -15
  154. package/out/concepts/DataSource__.js +55 -39
  155. package/out/concepts/DataSource__.js.map +1 -1
  156. package/out/concepts/DatabaseTypeAnnotation__.js +4 -3
  157. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
  158. package/out/concepts/Destination__.d.ts +12 -11
  159. package/out/concepts/Destination__.js +93 -36
  160. package/out/concepts/Destination__.js.map +1 -1
  161. package/out/concepts/End__.js +15 -13
  162. package/out/concepts/End__.js.map +1 -1
  163. package/out/concepts/EntityIndex__.d.ts +1 -1
  164. package/out/concepts/EntityIndex__.js +6 -5
  165. package/out/concepts/EntityIndex__.js.map +1 -1
  166. package/out/concepts/EntityProperty__.d.ts +8 -7
  167. package/out/concepts/EntityProperty__.js +39 -24
  168. package/out/concepts/EntityProperty__.js.map +1 -1
  169. package/out/concepts/Entity__.d.ts +31 -30
  170. package/out/concepts/Entity__.js +40 -16
  171. package/out/concepts/Entity__.js.map +1 -1
  172. package/out/concepts/EnumItem__.d.ts +1 -0
  173. package/out/concepts/EnumItem__.js +12 -5
  174. package/out/concepts/EnumItem__.js.map +1 -1
  175. package/out/concepts/Enum__.d.ts +9 -8
  176. package/out/concepts/Enum__.js +24 -11
  177. package/out/concepts/Enum__.js.map +1 -1
  178. package/out/concepts/Event__.d.ts +15 -15
  179. package/out/concepts/Event__.js +6 -5
  180. package/out/concepts/Event__.js.map +1 -1
  181. package/out/concepts/ExternalDestination__.d.ts +6 -6
  182. package/out/concepts/ExternalDestination__.js +12 -11
  183. package/out/concepts/ExternalDestination__.js.map +1 -1
  184. package/out/concepts/ForEachStatement__.d.ts +25 -24
  185. package/out/concepts/ForEachStatement__.js +101 -36
  186. package/out/concepts/ForEachStatement__.js.map +1 -1
  187. package/out/concepts/FrontendLibrary__.d.ts +30 -30
  188. package/out/concepts/FrontendLibrary__.js +12 -13
  189. package/out/concepts/FrontendLibrary__.js.map +1 -1
  190. package/out/concepts/FrontendVariable__.js +4 -3
  191. package/out/concepts/FrontendVariable__.js.map +1 -1
  192. package/out/concepts/Frontend__.d.ts +64 -65
  193. package/out/concepts/Frontend__.js +23 -27
  194. package/out/concepts/Frontend__.js.map +1 -1
  195. package/out/concepts/Function__.d.ts +64 -63
  196. package/out/concepts/Function__.js +49 -21
  197. package/out/concepts/Function__.js.map +1 -1
  198. package/out/concepts/Identifier__.js +37 -31
  199. package/out/concepts/Identifier__.js.map +1 -1
  200. package/out/concepts/IfStatement__.d.ts +20 -19
  201. package/out/concepts/IfStatement__.js +64 -34
  202. package/out/concepts/IfStatement__.js.map +1 -1
  203. package/out/concepts/Integration__.d.ts +3 -3
  204. package/out/concepts/Integration__.js +8 -7
  205. package/out/concepts/Integration__.js.map +1 -1
  206. package/out/concepts/InterfaceParam__.d.ts +3 -3
  207. package/out/concepts/InterfaceParam__.js +7 -6
  208. package/out/concepts/InterfaceParam__.js.map +1 -1
  209. package/out/concepts/Interface__.d.ts +33 -33
  210. package/out/concepts/Interface__.js +19 -20
  211. package/out/concepts/Interface__.js.map +1 -1
  212. package/out/concepts/JSBlock__.d.ts +1 -0
  213. package/out/concepts/JSBlock__.js +12 -5
  214. package/out/concepts/JSBlock__.js.map +1 -1
  215. package/out/concepts/JavaLogic__.js +10 -9
  216. package/out/concepts/JavaLogic__.js.map +1 -1
  217. package/out/concepts/LogicItem__.d.ts +6 -0
  218. package/out/concepts/LogicItem__.js +14 -5
  219. package/out/concepts/LogicItem__.js.map +1 -1
  220. package/out/concepts/Logic__.d.ts +80 -79
  221. package/out/concepts/Logic__.js +204 -58
  222. package/out/concepts/Logic__.js.map +1 -1
  223. package/out/concepts/MatchCase__.d.ts +39 -38
  224. package/out/concepts/MatchCase__.js +122 -37
  225. package/out/concepts/MatchCase__.js.map +1 -1
  226. package/out/concepts/Match__.d.ts +13 -11
  227. package/out/concepts/Match__.js +128 -60
  228. package/out/concepts/Match__.js.map +1 -1
  229. package/out/concepts/MemberExpression__.d.ts +7 -6
  230. package/out/concepts/MemberExpression__.js +52 -22
  231. package/out/concepts/MemberExpression__.js.map +1 -1
  232. package/out/concepts/MicroApp__.js +4 -3
  233. package/out/concepts/MicroApp__.js.map +1 -1
  234. package/out/concepts/Module__.d.ts +239 -155
  235. package/out/concepts/Module__.js +139 -33
  236. package/out/concepts/Module__.js.map +1 -1
  237. package/out/concepts/MsgTriggerEvent__.d.ts +15 -15
  238. package/out/concepts/MsgTriggerEvent__.js +6 -5
  239. package/out/concepts/MsgTriggerEvent__.js.map +1 -1
  240. package/out/concepts/MsgTriggerLauncher__.d.ts +23 -15
  241. package/out/concepts/MsgTriggerLauncher__.js +24 -5
  242. package/out/concepts/MsgTriggerLauncher__.js.map +1 -1
  243. package/out/concepts/Namespace__.d.ts +180 -180
  244. package/out/concepts/Namespace__.js +33 -34
  245. package/out/concepts/Namespace__.js.map +1 -1
  246. package/out/concepts/NewComposite__.d.ts +49 -48
  247. package/out/concepts/NewComposite__.js +164 -49
  248. package/out/concepts/NewComposite__.js.map +1 -1
  249. package/out/concepts/NewList__.d.ts +19 -18
  250. package/out/concepts/NewList__.js +29 -12
  251. package/out/concepts/NewList__.js.map +1 -1
  252. package/out/concepts/NewMap__.d.ts +34 -33
  253. package/out/concepts/NewMap__.js +81 -72
  254. package/out/concepts/NewMap__.js.map +1 -1
  255. package/out/concepts/New__.js +6 -5
  256. package/out/concepts/New__.js.map +1 -1
  257. package/out/concepts/NullLiteral__.js +6 -5
  258. package/out/concepts/NullLiteral__.js.map +1 -1
  259. package/out/concepts/NumericLiteral__.d.ts +4 -3
  260. package/out/concepts/NumericLiteral__.js +15 -8
  261. package/out/concepts/NumericLiteral__.js.map +1 -1
  262. package/out/concepts/OqlQueryComponent__.d.ts +4 -3
  263. package/out/concepts/OqlQueryComponent__.js +25 -16
  264. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  265. package/out/concepts/OverriddenLogic__.d.ts +79 -79
  266. package/out/concepts/OverriddenLogic__.js +79 -58
  267. package/out/concepts/OverriddenLogic__.js.map +1 -1
  268. package/out/concepts/Param__.d.ts +6 -5
  269. package/out/concepts/Param__.js +66 -29
  270. package/out/concepts/Param__.js.map +1 -1
  271. package/out/concepts/Point__.js +4 -3
  272. package/out/concepts/Point__.js.map +1 -1
  273. package/out/concepts/ProcessComponent__.d.ts +30 -30
  274. package/out/concepts/ProcessComponent__.js +8 -7
  275. package/out/concepts/ProcessComponent__.js.map +1 -1
  276. package/out/concepts/ProcessElement__.d.ts +96 -96
  277. package/out/concepts/ProcessElement__.js +34 -34
  278. package/out/concepts/ProcessElement__.js.map +1 -1
  279. package/out/concepts/ProcessOutcome__.js +6 -5
  280. package/out/concepts/ProcessOutcome__.js.map +1 -1
  281. package/out/concepts/ProcessOutcomes__.js +6 -5
  282. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  283. package/out/concepts/Process__.d.ts +75 -75
  284. package/out/concepts/Process__.js +33 -30
  285. package/out/concepts/Process__.js.map +1 -1
  286. package/out/concepts/QueryAggregateExpression__.d.ts +3 -3
  287. package/out/concepts/QueryAggregateExpression__.js +8 -7
  288. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  289. package/out/concepts/QueryFieldExpression__.js +7 -6
  290. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  291. package/out/concepts/QueryFromExpression__.d.ts +8 -8
  292. package/out/concepts/QueryFromExpression__.js +8 -7
  293. package/out/concepts/QueryFromExpression__.js.map +1 -1
  294. package/out/concepts/QueryGroupByExpression__.d.ts +3 -3
  295. package/out/concepts/QueryGroupByExpression__.js +9 -10
  296. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  297. package/out/concepts/QueryJoinExpression__.d.ts +23 -23
  298. package/out/concepts/QueryJoinExpression__.js +11 -10
  299. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  300. package/out/concepts/QueryLimitExpression__.d.ts +6 -6
  301. package/out/concepts/QueryLimitExpression__.js +9 -8
  302. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  303. package/out/concepts/QueryOrderByExpression__.d.ts +6 -6
  304. package/out/concepts/QueryOrderByExpression__.js +9 -8
  305. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  306. package/out/concepts/QuerySelectExpression__.d.ts +30 -30
  307. package/out/concepts/QuerySelectExpression__.js +9 -8
  308. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  309. package/out/concepts/Rect__.js +4 -3
  310. package/out/concepts/Rect__.js.map +1 -1
  311. package/out/concepts/Return__.d.ts +4 -3
  312. package/out/concepts/Return__.js +37 -18
  313. package/out/concepts/Return__.js.map +1 -1
  314. package/out/concepts/Role__.js +9 -9
  315. package/out/concepts/Role__.js.map +1 -1
  316. package/out/concepts/SelectMembers__.d.ts +18 -18
  317. package/out/concepts/SelectMembers__.js +10 -9
  318. package/out/concepts/SelectMembers__.js.map +1 -1
  319. package/out/concepts/Slot__.d.ts +3 -3
  320. package/out/concepts/Slot__.js +6 -5
  321. package/out/concepts/Slot__.js.map +1 -1
  322. package/out/concepts/SqlQueryComponent__.d.ts +4 -3
  323. package/out/concepts/SqlQueryComponent__.js +21 -12
  324. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  325. package/out/concepts/Start__.js +6 -5
  326. package/out/concepts/Start__.js.map +1 -1
  327. package/out/concepts/StringInterpolation__.d.ts +16 -15
  328. package/out/concepts/StringInterpolation__.js +37 -14
  329. package/out/concepts/StringInterpolation__.js.map +1 -1
  330. package/out/concepts/StringLiteral__.d.ts +1 -0
  331. package/out/concepts/StringLiteral__.js +13 -8
  332. package/out/concepts/StringLiteral__.js.map +1 -1
  333. package/out/concepts/StructureProperty__.d.ts +4 -3
  334. package/out/concepts/StructureProperty__.js +22 -9
  335. package/out/concepts/StructureProperty__.js.map +1 -1
  336. package/out/concepts/Structure__.d.ts +31 -30
  337. package/out/concepts/Structure__.js +27 -15
  338. package/out/concepts/Structure__.js.map +1 -1
  339. package/out/concepts/SwitchCase__.d.ts +12 -11
  340. package/out/concepts/SwitchCase__.js +69 -31
  341. package/out/concepts/SwitchCase__.js.map +1 -1
  342. package/out/concepts/SwitchStatement__.d.ts +9 -8
  343. package/out/concepts/SwitchStatement__.js +27 -7
  344. package/out/concepts/SwitchStatement__.js.map +1 -1
  345. package/out/concepts/Theme__.js +4 -3
  346. package/out/concepts/Theme__.js.map +1 -1
  347. package/out/concepts/Transactional__.js +4 -3
  348. package/out/concepts/Transactional__.js.map +1 -1
  349. package/out/concepts/TriggerEvent__.d.ts +15 -15
  350. package/out/concepts/TriggerEvent__.js +6 -5
  351. package/out/concepts/TriggerEvent__.js.map +1 -1
  352. package/out/concepts/TriggerLauncher__.d.ts +15 -10
  353. package/out/concepts/TriggerLauncher__.js +54 -32
  354. package/out/concepts/TriggerLauncher__.js.map +1 -1
  355. package/out/concepts/TypeAnnotation__.d.ts +28 -27
  356. package/out/concepts/TypeAnnotation__.js +144 -124
  357. package/out/concepts/TypeAnnotation__.js.map +1 -1
  358. package/out/concepts/TypeParam__.d.ts +1 -0
  359. package/out/concepts/TypeParam__.js +12 -5
  360. package/out/concepts/TypeParam__.js.map +1 -1
  361. package/out/concepts/UnaryExpression__.d.ts +4 -3
  362. package/out/concepts/UnaryExpression__.js +31 -20
  363. package/out/concepts/UnaryExpression__.js.map +1 -1
  364. package/out/concepts/Unparsed__.d.ts +1 -0
  365. package/out/concepts/Unparsed__.js +12 -5
  366. package/out/concepts/Unparsed__.js.map +1 -1
  367. package/out/concepts/UseComponent__.js +4 -3
  368. package/out/concepts/UseComponent__.js.map +1 -1
  369. package/out/concepts/ValidationRule__.d.ts +14 -14
  370. package/out/concepts/ValidationRule__.js +19 -17
  371. package/out/concepts/ValidationRule__.js.map +1 -1
  372. package/out/concepts/Variable__.d.ts +4 -3
  373. package/out/concepts/Variable__.js +39 -23
  374. package/out/concepts/Variable__.js.map +1 -1
  375. package/out/concepts/ViewBlock__.js +4 -3
  376. package/out/concepts/ViewBlock__.js.map +1 -1
  377. package/out/concepts/ViewComponent__.d.ts +90 -90
  378. package/out/concepts/ViewComponent__.js +16 -15
  379. package/out/concepts/ViewComponent__.js.map +1 -1
  380. package/out/concepts/ViewElement__.d.ts +91 -86
  381. package/out/concepts/ViewElement__.js +218 -146
  382. package/out/concepts/ViewElement__.js.map +1 -1
  383. package/out/concepts/View__.d.ts +92 -92
  384. package/out/concepts/View__.js +135 -60
  385. package/out/concepts/View__.js.map +1 -1
  386. package/out/concepts/WhileStatement__.d.ts +12 -11
  387. package/out/concepts/WhileStatement__.js +46 -23
  388. package/out/concepts/WhileStatement__.js.map +1 -1
  389. package/out/concepts/index__.d.ts +2 -1
  390. package/out/concepts/index__.js +2 -1
  391. package/out/concepts/index__.js.map +1 -1
  392. package/out/concepts/types__.d.ts +2 -1
  393. package/out/decorators/index.d.ts +1 -1
  394. package/out/decorators/index.js +20 -7
  395. package/out/decorators/index.js.map +1 -1
  396. package/out/decorators/promise.d.ts +7 -0
  397. package/out/decorators/promise.js +28 -0
  398. package/out/decorators/promise.js.map +1 -0
  399. package/out/enums/KEYWORDS.js.map +1 -1
  400. package/out/enums/LEVEL_NAME_MAP.js.map +1 -1
  401. package/out/generator/compileComponent.js.map +1 -1
  402. package/out/generator/genBundleFiles.d.ts +4 -1
  403. package/out/generator/genBundleFiles.js +15 -11
  404. package/out/generator/genBundleFiles.js.map +1 -1
  405. package/out/generator/genHash.js.map +1 -1
  406. package/out/generator/genMetaData.js +12 -8
  407. package/out/generator/genMetaData.js.map +1 -1
  408. package/out/generator/genReleaseBody.js +33 -35
  409. package/out/generator/genReleaseBody.js.map +1 -1
  410. package/out/generator/microApp.js +2 -1
  411. package/out/generator/microApp.js.map +1 -1
  412. package/out/generator/permission.js +16 -14
  413. package/out/generator/permission.js.map +1 -1
  414. package/out/generator/styleReplacer.js +4 -7
  415. package/out/generator/styleReplacer.js.map +1 -1
  416. package/out/index.d.ts +0 -2
  417. package/out/index.js +0 -3
  418. package/out/index.js.map +1 -1
  419. package/out/manager/diagnostic.d.ts +1 -1
  420. package/out/manager/diagnostic.js.map +1 -1
  421. package/out/manager/stepRecorder.js +13 -9
  422. package/out/manager/stepRecorder.js.map +1 -1
  423. package/out/natural/RequirementAnalyzer.d.ts +22 -0
  424. package/out/natural/RequirementAnalyzer.js +196 -0
  425. package/out/natural/RequirementAnalyzer.js.map +1 -0
  426. package/out/natural/RequirementExecutor.d.ts +51 -0
  427. package/out/natural/RequirementExecutor.js +692 -0
  428. package/out/natural/RequirementExecutor.js.map +1 -0
  429. package/out/natural/componentData.d.ts +31 -0
  430. package/out/natural/componentData.js +85 -0
  431. package/out/natural/componentData.js.map +1 -0
  432. package/out/natural/genNaturalTS.d.ts +3 -0
  433. package/out/natural/genNaturalTS.js +76 -0
  434. package/out/natural/genNaturalTS.js.map +1 -0
  435. package/out/natural/index.d.ts +4 -0
  436. package/out/natural/index.js +21 -0
  437. package/out/natural/index.js.map +1 -0
  438. package/out/natural/knowledgeMap.d.ts +4 -0
  439. package/out/natural/knowledgeMap.js +40 -0
  440. package/out/natural/knowledgeMap.js.map +1 -0
  441. package/out/natural/naslStdlibMap.d.ts +2 -0
  442. package/out/natural/naslStdlibMap.js +26 -0
  443. package/out/natural/naslStdlibMap.js.map +1 -0
  444. package/out/natural/transformTSCode.d.ts +7 -0
  445. package/out/natural/transformTSCode.js +760 -0
  446. package/out/natural/transformTSCode.js.map +1 -0
  447. package/out/sentry/index.d.ts +2 -1
  448. package/out/sentry/index.js.map +1 -1
  449. package/out/server/createUiTs.js +28 -16
  450. package/out/server/createUiTs.js.map +1 -1
  451. package/out/server/entity2LogicNamespace.js +24 -22
  452. package/out/server/entity2LogicNamespace.js.map +1 -1
  453. package/out/server/event.js.map +1 -1
  454. package/out/server/extendBaseNode.js +55 -70
  455. package/out/server/extendBaseNode.js.map +1 -1
  456. package/out/server/formatTsUtils.js +46 -50
  457. package/out/server/formatTsUtils.js.map +1 -1
  458. package/out/server/getConnector.d.ts +3 -3
  459. package/out/server/getConnector.js +7 -8
  460. package/out/server/getConnector.js.map +1 -1
  461. package/out/server/getExtensionModules.js +2 -2
  462. package/out/server/getExtensionModules.js.map +1 -1
  463. package/out/server/getFunctions.js.map +1 -1
  464. package/out/server/getInterfaces.js.map +1 -1
  465. package/out/server/getLogging.js.map +1 -1
  466. package/out/server/getLogics.d.ts +1 -1
  467. package/out/server/getLogics.js +34 -16
  468. package/out/server/getLogics.js.map +1 -1
  469. package/out/server/getMemberIdentifier.js +13 -10
  470. package/out/server/getMemberIdentifier.js.map +1 -1
  471. package/out/server/getProcessComponents.js.map +1 -1
  472. package/out/server/getProcesses.js +21 -29
  473. package/out/server/getProcesses.js.map +1 -1
  474. package/out/server/getScope.js.map +1 -1
  475. package/out/server/getValidates.js.map +1 -1
  476. package/out/server/index.js +0 -1
  477. package/out/server/index.js.map +1 -1
  478. package/out/server/naslServer.d.ts +99 -94
  479. package/out/server/naslServer.js +485 -465
  480. package/out/server/naslServer.js.map +1 -1
  481. package/out/server/naslStdlibMap.js +4 -2
  482. package/out/server/naslStdlibMap.js.map +1 -1
  483. package/out/server/process2LogicNamespace.js.map +1 -1
  484. package/out/server/translator.d.ts +1 -1
  485. package/out/server/translator.js +52 -47
  486. package/out/server/translator.js.map +1 -1
  487. package/out/service/storage/init.d.ts +15 -1
  488. package/out/service/storage/init.js +65 -56
  489. package/out/service/storage/init.js.map +1 -1
  490. package/out/templator/genCallComponentLogic.js +1 -2
  491. package/out/templator/genCallComponentLogic.js.map +1 -1
  492. package/out/templator/genCreateBlock.js +13 -8
  493. package/out/templator/genCreateBlock.js.map +1 -1
  494. package/out/templator/genCurdEditMultipleKeyBlock.js +19 -10
  495. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  496. package/out/templator/genCurdMultipleKeyBlock.js +22 -26
  497. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  498. package/out/templator/genEditTableBlock.js +11 -12
  499. package/out/templator/genEditTableBlock.js.map +1 -1
  500. package/out/templator/genEnumSelectBlock.js +1 -1
  501. package/out/templator/genEnumSelectBlock.js.map +1 -1
  502. package/out/templator/genGetBlock.js +2 -2
  503. package/out/templator/genGetBlock.js.map +1 -1
  504. package/out/templator/genGridViewBlock.js +10 -14
  505. package/out/templator/genGridViewBlock.js.map +1 -1
  506. package/out/templator/genListViewBlock.js +4 -7
  507. package/out/templator/genListViewBlock.js.map +1 -1
  508. package/out/templator/genQueryComponent.js +22 -15
  509. package/out/templator/genQueryComponent.js.map +1 -1
  510. package/out/templator/genSelectBlock.js +12 -33
  511. package/out/templator/genSelectBlock.js.map +1 -1
  512. package/out/templator/genTableBlock.js +8 -10
  513. package/out/templator/genTableBlock.js.map +1 -1
  514. package/out/templator/genUpdateBlock.js +12 -7
  515. package/out/templator/genUpdateBlock.js.map +1 -1
  516. package/out/templator/index.d.ts +4 -2
  517. package/out/templator/index.js +2 -2
  518. package/out/templator/index.js.map +1 -1
  519. package/out/templator/utils.d.ts +2 -2
  520. package/out/templator/utils.js +21 -22
  521. package/out/templator/utils.js.map +1 -1
  522. package/out/translator/index.js +27 -28
  523. package/out/translator/index.js.map +1 -1
  524. package/out/utils/index.d.ts +2 -1
  525. package/out/utils/index.js +8 -14
  526. package/out/utils/index.js.map +1 -1
  527. package/out/utils/logger.js.map +1 -1
  528. package/out/utils/sortTsString.js +3 -1
  529. package/out/utils/sortTsString.js.map +1 -1
  530. package/out/utils/string.js +8 -11
  531. package/out/utils/string.js.map +1 -1
  532. package/out/utils/time-slicing.d.ts +41 -0
  533. package/out/utils/time-slicing.js +81 -0
  534. package/out/utils/time-slicing.js.map +1 -0
  535. package/out/utils/traverse.js +4 -6
  536. package/out/utils/traverse.js.map +1 -1
  537. package/package.json +11 -7
  538. package/sandbox/stdlib/nasl.auth.ts +49 -46
  539. package/sandbox/stdlib/nasl.http.ts +29 -31
  540. package/sandbox/stdlib/nasl.ui.definition.ts +13 -1
  541. package/sandbox-natural/stdlib/nasl.core.ts +36 -0
  542. package/sandbox-natural/stdlib/nasl.oql.ts +8 -0
  543. package/sandbox-natural/stdlib/nasl.ui.ts +56 -0
  544. package/sandbox-natural/stdlib/nasl.util.ts +26 -0
  545. package/sandbox-natural/tsconfig.json +12 -0
  546. package/src/automate/upgrader/2.20.js +1 -1
  547. package/src/bak/translator.js +92 -99
  548. package/src/breakpoint/generator/AfterStartNode.ts +19 -17
  549. package/src/breakpoint/generator/BeforeEndNode.ts +17 -17
  550. package/src/breakpoint/generator/BreakpointNode.ts +243 -195
  551. package/src/breakpoint/generator/CallbackNode.ts +20 -0
  552. package/src/breakpoint/generator/FragmentNode.ts +14 -0
  553. package/src/breakpoint/generator/index.ts +107 -80
  554. package/src/breakpoint/shared/constants.ts +59 -53
  555. package/src/breakpoint/shared/operations.ts +6 -6
  556. package/src/breakpoint/shared/socket.ts +277 -223
  557. package/src/breakpoint/shared/utils.ts +166 -146
  558. package/src/breakpoint/store/core.ts +326 -297
  559. package/src/breakpoint/store/dock.ts +103 -103
  560. package/src/breakpoint/types/index.d.ts +11 -11
  561. package/src/common/BaseNode.ts +1102 -1024
  562. package/src/common/Command.ts +46 -16
  563. package/src/common/ComponentAPI.ts +72 -72
  564. package/src/common/EventEmitter.ts +80 -76
  565. package/src/common/Messager.ts +223 -224
  566. package/src/common/asyncFuncMap.ts +12 -12
  567. package/src/concepts/Abort__.ts +53 -60
  568. package/src/concepts/Anchor__.ts +158 -149
  569. package/src/concepts/AnonymousFunction__.ts +584 -551
  570. package/src/concepts/App__.ts +4278 -3671
  571. package/src/concepts/Argument__.ts +234 -210
  572. package/src/concepts/Assignee__.ts +680 -656
  573. package/src/concepts/AssignmentLine__.ts +80 -84
  574. package/src/concepts/Assignment__.ts +275 -264
  575. package/src/concepts/Attribute__.ts +183 -184
  576. package/src/concepts/AuthInterface__.ts +61 -63
  577. package/src/concepts/AuthLogicForCallInterface__.ts +540 -511
  578. package/src/concepts/AuthLogic__.ts +210 -194
  579. package/src/concepts/BackendVariable__.ts +414 -415
  580. package/src/concepts/Backend__.ts +317 -303
  581. package/src/concepts/BatchAssignment__.ts +987 -939
  582. package/src/concepts/BinaryExpression__.ts +370 -341
  583. package/src/concepts/BindAttribute__.ts +1057 -1007
  584. package/src/concepts/BindDirective__.ts +540 -542
  585. package/src/concepts/BindEvent__.ts +992 -911
  586. package/src/concepts/BindStyle__.ts +442 -451
  587. package/src/concepts/BooleanLiteral__.ts +89 -90
  588. package/src/concepts/CallAuthInterface__.ts +458 -433
  589. package/src/concepts/CallConnector__.ts +209 -164
  590. package/src/concepts/CallFunction__.ts +600 -600
  591. package/src/concepts/CallInterface__.ts +752 -721
  592. package/src/concepts/CallLogic__.ts +1324 -1200
  593. package/src/concepts/CallQueryComponent__.ts +1580 -1501
  594. package/src/concepts/Comment__.ts +69 -68
  595. package/src/concepts/CompletionProperty__.ts +250 -255
  596. package/src/concepts/ConfigGroup__.ts +312 -296
  597. package/src/concepts/ConfigPropertyValue__.ts +92 -93
  598. package/src/concepts/ConfigProperty__.ts +374 -357
  599. package/src/concepts/Configuration__.ts +288 -276
  600. package/src/concepts/Connection__.ts +426 -0
  601. package/src/concepts/ConnectorTrigger__.ts +146 -142
  602. package/src/concepts/Connector__.ts +1090 -1048
  603. package/src/concepts/Constant__.ts +226 -219
  604. package/src/concepts/DataElement__.ts +108 -115
  605. package/src/concepts/DataSource__.ts +508 -472
  606. package/src/concepts/DatabaseTypeAnnotation__.ts +53 -59
  607. package/src/concepts/Destination__.ts +808 -746
  608. package/src/concepts/End__.ts +85 -89
  609. package/src/concepts/EntityIndex__.ts +206 -202
  610. package/src/concepts/EntityProperty__.ts +825 -791
  611. package/src/concepts/Entity__.ts +921 -864
  612. package/src/concepts/EnumItem__.ts +133 -125
  613. package/src/concepts/Enum__.ts +347 -337
  614. package/src/concepts/Event__.ts +305 -292
  615. package/src/concepts/ExternalDestination__.ts +269 -280
  616. package/src/concepts/ForEachStatement__.ts +583 -531
  617. package/src/concepts/FrontendLibrary__.ts +507 -485
  618. package/src/concepts/FrontendVariable__.ts +44 -49
  619. package/src/concepts/Frontend__.ts +1239 -1187
  620. package/src/concepts/Function__.ts +1110 -1045
  621. package/src/concepts/Identifier__.ts +276 -272
  622. package/src/concepts/IfStatement__.ts +467 -436
  623. package/src/concepts/Integration__.ts +136 -137
  624. package/src/concepts/InterfaceParam__.ts +239 -238
  625. package/src/concepts/Interface__.ts +969 -948
  626. package/src/concepts/JSBlock__.ts +83 -83
  627. package/src/concepts/JavaLogic__.ts +101 -106
  628. package/src/concepts/LogicItem__.ts +307 -237
  629. package/src/concepts/Logic__.ts +2301 -2088
  630. package/src/concepts/MatchCase__.ts +886 -779
  631. package/src/concepts/Match__.ts +728 -659
  632. package/src/concepts/MemberExpression__.ts +330 -311
  633. package/src/concepts/MicroApp__.ts +91 -97
  634. package/src/concepts/Module__.ts +2590 -2278
  635. package/src/concepts/MsgTriggerEvent__.ts +297 -281
  636. package/src/concepts/MsgTriggerLauncher__.ts +286 -256
  637. package/src/concepts/Namespace__.ts +2579 -2466
  638. package/src/concepts/NewComposite__.ts +1487 -1350
  639. package/src/concepts/NewList__.ts +464 -450
  640. package/src/concepts/NewMap__.ts +691 -674
  641. package/src/concepts/New__.ts +42 -49
  642. package/src/concepts/NullLiteral__.ts +66 -72
  643. package/src/concepts/NumericLiteral__.ts +169 -169
  644. package/src/concepts/OqlQueryComponent__.ts +282 -279
  645. package/src/concepts/OverriddenLogic__.ts +2142 -2097
  646. package/src/concepts/Param__.ts +500 -442
  647. package/src/concepts/Point__.ts +53 -59
  648. package/src/concepts/ProcessComponent__.ts +497 -475
  649. package/src/concepts/ProcessElement__.ts +1852 -1780
  650. package/src/concepts/ProcessOutcome__.ts +59 -64
  651. package/src/concepts/ProcessOutcomes__.ts +59 -64
  652. package/src/concepts/Process__.ts +1491 -1428
  653. package/src/concepts/QueryAggregateExpression__.ts +135 -142
  654. package/src/concepts/QueryFieldExpression__.ts +138 -142
  655. package/src/concepts/QueryFromExpression__.ts +246 -254
  656. package/src/concepts/QueryGroupByExpression__.ts +130 -136
  657. package/src/concepts/QueryJoinExpression__.ts +441 -438
  658. package/src/concepts/QueryLimitExpression__.ts +159 -166
  659. package/src/concepts/QueryOrderByExpression__.ts +173 -180
  660. package/src/concepts/QuerySelectExpression__.ts +464 -439
  661. package/src/concepts/Rect__.ts +73 -79
  662. package/src/concepts/Return__.ts +366 -345
  663. package/src/concepts/Role__.ts +146 -147
  664. package/src/concepts/SelectMembers__.ts +358 -350
  665. package/src/concepts/Slot__.ts +152 -153
  666. package/src/concepts/SqlQueryComponent__.ts +230 -228
  667. package/src/concepts/Start__.ts +45 -52
  668. package/src/concepts/StringInterpolation__.ts +323 -296
  669. package/src/concepts/StringLiteral__.ts +113 -115
  670. package/src/concepts/StructureProperty__.ts +306 -295
  671. package/src/concepts/Structure__.ts +615 -578
  672. package/src/concepts/SwitchCase__.ts +326 -290
  673. package/src/concepts/SwitchStatement__.ts +236 -229
  674. package/src/concepts/Theme__.ts +64 -68
  675. package/src/concepts/Transactional__.ts +159 -153
  676. package/src/concepts/TriggerEvent__.ts +285 -274
  677. package/src/concepts/TriggerLauncher__.ts +232 -196
  678. package/src/concepts/TypeAnnotation__.ts +1049 -1011
  679. package/src/concepts/TypeParam__.ts +48 -50
  680. package/src/concepts/UnaryExpression__.ts +163 -153
  681. package/src/concepts/Unparsed__.ts +81 -82
  682. package/src/concepts/UseComponent__.ts +53 -59
  683. package/src/concepts/ValidationRule__.ts +524 -544
  684. package/src/concepts/Variable__.ts +419 -397
  685. package/src/concepts/ViewBlock__.ts +58 -64
  686. package/src/concepts/ViewComponent__.ts +1323 -1261
  687. package/src/concepts/ViewElement__.ts +2538 -2350
  688. package/src/concepts/View__.ts +2447 -2268
  689. package/src/concepts/WhileStatement__.ts +293 -272
  690. package/src/concepts/index__.ts +2 -1
  691. package/src/concepts/types__.ts +123 -121
  692. package/src/decorators/index.ts +75 -77
  693. package/src/decorators/promise.ts +28 -0
  694. package/src/enums/KEYWORDS.ts +1228 -1228
  695. package/src/enums/LEVEL_NAME_MAP.ts +24 -24
  696. package/src/generator/compileComponent.ts +10 -10
  697. package/src/generator/genBundleFiles.ts +300 -291
  698. package/src/generator/genHash.ts +2 -2
  699. package/src/generator/genMetaData.ts +280 -261
  700. package/src/generator/genReleaseBody.ts +312 -291
  701. package/src/generator/icestark.ts +1 -1
  702. package/src/generator/microApp.ts +17 -20
  703. package/src/generator/permission.ts +227 -218
  704. package/src/generator/qiankun.ts +1 -1
  705. package/src/generator/styleReplacer.ts +28 -31
  706. package/src/index.ts +0 -3
  707. package/src/manager/diagnostic.ts +84 -82
  708. package/src/manager/stepRecorder.ts +106 -94
  709. package/src/natural/RequirementAnalyzer.ts +208 -0
  710. package/src/natural/RequirementExecutor.ts +685 -0
  711. package/src/natural/componentData.ts +81 -0
  712. package/src/natural/genNaturalTS.ts +77 -0
  713. package/src/natural/index.ts +4 -0
  714. package/src/natural/knowledgeMap.ts +39 -0
  715. package/src/natural/naslStdlibMap.ts +24 -0
  716. package/src/natural/transformTSCode.ts +692 -0
  717. package/src/sentry/index.ts +109 -104
  718. package/src/server/createUiTs.ts +190 -184
  719. package/src/server/entity2LogicNamespace.ts +379 -359
  720. package/src/server/event.js +145 -145
  721. package/src/server/extendBaseNode.ts +461 -456
  722. package/src/server/formatTsUtils.ts +712 -713
  723. package/src/server/getConnector.ts +33 -33
  724. package/src/server/getExtensionModules.ts +23 -22
  725. package/src/server/getFunctions.ts +6 -6
  726. package/src/server/getInterfaces.ts +38 -37
  727. package/src/server/getLogging.ts +1 -1
  728. package/src/server/getLogics.ts +390 -344
  729. package/src/server/getMemberIdentifier.ts +286 -281
  730. package/src/server/getProcessComponents.ts +2 -2
  731. package/src/server/getProcesses.ts +548 -534
  732. package/src/server/getScope.ts +51 -51
  733. package/src/server/getValidates.ts +3 -3
  734. package/src/server/index.ts +29 -30
  735. package/src/server/naslServer.ts +4302 -4225
  736. package/src/server/naslStdlibMap.ts +43 -41
  737. package/src/server/process2LogicNamespace.ts +97 -97
  738. package/src/server/translator.ts +740 -746
  739. package/src/service/storage/init.ts +761 -728
  740. package/src/templator/genCallComponentLogic.ts +14 -15
  741. package/src/templator/genCreateBlock.ts +257 -229
  742. package/src/templator/genCurdEditMultipleKeyBlock.ts +332 -316
  743. package/src/templator/genCurdMultipleKeyBlock.ts +501 -473
  744. package/src/templator/genEditTableBlock.ts +192 -182
  745. package/src/templator/genEnumSelectBlock.ts +13 -7
  746. package/src/templator/genGetBlock.ts +57 -55
  747. package/src/templator/genGridViewBlock.ts +191 -201
  748. package/src/templator/genListViewBlock.ts +59 -64
  749. package/src/templator/genQueryComponent.ts +337 -287
  750. package/src/templator/genSelectBlock.ts +276 -285
  751. package/src/templator/genTableBlock.ts +157 -160
  752. package/src/templator/genUpdateBlock.ts +269 -255
  753. package/src/templator/index.ts +4 -4
  754. package/src/templator/utils.ts +490 -464
  755. package/src/translator/index.ts +84 -84
  756. package/src/translator/lsp.ts +22 -22
  757. package/src/translator/tsp.ts +6 -6
  758. package/src/utils/index.ts +115 -117
  759. package/src/utils/logger.ts +3 -4
  760. package/src/utils/sortTsString.ts +34 -32
  761. package/src/utils/string.ts +47 -48
  762. package/src/utils/time-slicing.ts +109 -0
  763. package/src/utils/traverse.ts +114 -126
  764. package/test/concepts/match/__snapshots__/toEmbeddedTS.spec.ts.snap +66 -0
  765. package/test/concepts/match/__snapshots__/toJS.spec.ts.snap +40 -0
  766. package/test/concepts/match/constant.ts +5 -0
  767. package/test/concepts/match/fixtures/isExpression.json +259 -0
  768. package/test/concepts/match/fixtures/lastBodyIf.json +268 -0
  769. package/test/concepts/match/fixtures/noExpression.json +176 -0
  770. package/test/concepts/match/toEmbeddedTS.spec.ts +14 -0
  771. package/test/concepts/match/toJS.spec.ts +14 -0
  772. package/test/setup.ts +2 -1
  773. package/ts-worker/src/index.js +0 -2
  774. package/tsconfig.json +21 -21
@@ -1,3 +1,4 @@
1
+ import { v4 as uuidv4 } from 'uuid';
1
2
  import { FrontendLibrary } from './FrontendLibrary__';
2
3
  import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState, embeddedTSEmitter } from '../translator';
3
4
  import Namespace from './Namespace__';
@@ -15,15 +16,14 @@ import CallInterface from './CallInterface__';
15
16
  import CallLogic from './CallLogic__';
16
17
  import Logic from './Logic__';
17
18
 
18
- //================================================================================
19
+ //= ===============================================================================
19
20
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
20
21
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
21
- //================================================================================
22
+ //= ===============================================================================
22
23
  import { EventPayload, Params } from '../common/EventEmitter';
23
24
  import { concept, excludedInJSON, property } from '../decorators';
24
25
 
25
26
  import * as utils from '../utils';
26
- import { v4 as uuidv4 } from 'uuid';
27
27
  import BaseNode from '../common/BaseNode';
28
28
  import classMap from '../common/classMap';
29
29
  import Transactional from './Transactional__';
@@ -44,2122 +44,2167 @@ import Process from './Process__';
44
44
  */
45
45
  @concept('逻辑')
46
46
  export class OverriddenLogic extends BaseNode {
47
- /**
48
- * 产品概念
49
- */
50
- @property()
51
- concept: 'OverriddenLogic' = 'OverriddenLogic';
52
-
53
- /**
54
- * overriddenModule
55
- */
56
- @property()
57
- overriddenModule: string = undefined;
58
-
59
- /**
60
- * 逻辑名称
61
- */
62
- @property()
63
- name: string = undefined;
64
-
65
- /**
66
- * 逻辑描述
67
- */
68
- @property()
69
- description: string = undefined;
70
-
71
- /**
72
- * triggerType
73
- */
74
- @property()
75
- triggerType: string = undefined;
76
-
77
- /**
78
- * cron
79
- */
80
- @property()
81
- cron: string = undefined;
82
-
83
- /**
84
- * 事务
85
- */
86
- @property('Transactional')
87
- transactional: Transactional = undefined;
88
-
89
- /**
90
- * 编译器信息
91
- */
92
- @property()
93
- compilerInfoMap: { java?: { packageName: string, className: string } } = undefined;
94
-
95
- /**
96
- * 类型参数列表
97
- */
98
- @property('TypeParam')
99
- typeParams: Array<TypeParam> = null;
100
-
101
- /**
102
- * 输入参数列表
103
- */
104
- @property('Param')
105
- params: Array<Param> = [];
106
-
107
- /**
108
- * 输出参数列表
109
- */
110
- @property('Return')
111
- returns: Array<Return> = [];
112
-
113
- /**
114
- * 变量列表
115
- */
116
- @property('Variable')
117
- variables: Array<Variable> = [];
118
-
119
- /**
120
- * 逻辑项列表
121
- */
122
- @property('LogicItem')
123
- body: Array<LogicItem> = [];
124
-
125
- /**
126
- * 逻辑项列表
127
- */
128
- @property('LogicItem')
129
- playground: Array<LogicItem> = [];
130
-
131
- /**
132
- * 祖先 Module
133
- */
134
- get module() {
135
- return this.getAncestor('Module') as Module;
136
- }
137
- /**
138
- * 祖先 App
139
- */
140
- get app() {
141
- return this.getAncestor('App') as App;
142
- }
143
- /**
144
- * 祖先 View
145
- */
146
- get view() {
147
- return this.getAncestor('View') as View;
148
- }
149
- /**
150
- * 祖先 Frontend
151
- */
152
- get frontend() {
153
- return this.getAncestor('Frontend') as Frontend;
154
- }
155
- /**
156
- * 祖先 ProcessElement
157
- */
158
- get processElement() {
159
- return this.getAncestor('ProcessElement') as ProcessElement;
160
- }
161
- /**
162
- * 祖先 Process
163
- */
164
- get process() {
165
- return this.getAncestor('Process') as Process;
166
- }
167
-
168
- /**
169
- * @param source 需要合并的部分参数
170
- */
171
- constructor(source?: Partial<OverriddenLogic>) {
172
- source = Object.assign({}, OverriddenLogic.getDefaultOptions(), source);
173
- super(source);
174
- super.subConstructor(source);
175
- }
176
- getClassName() {
177
- return 'OverriddenLogic';
178
- }
179
-
180
- static from(source: any, parentNode?: any, parentKey?: string): OverriddenLogic {
181
- return super.from(source, parentNode, parentKey) as OverriddenLogic;
182
- }
183
-
184
- /**
185
- * 从父级删除该节点
186
- * @internal
187
- */
188
- _delete() {
189
- let params: Params = null;
190
- if (this.parentNode) {
191
- params = (this.parentNode as any)?.__removeOverriddenLogic?.(this);
192
- }
193
- return params;
194
- }
195
- /**
196
- * 设置overriddenModule
197
- */
198
- setOverriddenModule(overriddenModule: string) {
199
- const object = {
200
- overriddenModule,
201
- };
202
- this.update({
203
- ...object,
204
- });
205
- }
206
-
207
- /**
208
- * 设置逻辑名称
209
- */
210
- setName(name: string) {
211
- const object = {
212
- name,
213
- };
214
- this.update({
215
- ...object,
216
- field: 'name',
217
- });
218
- }
219
-
220
- /**
221
- * 设置逻辑描述
222
- */
223
- setDescription(description: string) {
224
- const object = {
225
- description,
226
- };
227
- this.update({
228
- ...object,
229
- });
230
- }
231
-
232
- /**
233
- * 设置triggerType
234
- */
235
- setTriggerType(triggerType: string) {
236
- const object = {
237
- triggerType,
238
- };
239
- this.update({
240
- ...object,
241
- });
242
- }
243
-
244
- /**
245
- * 设置cron
246
- */
247
- setCron(cron: string) {
248
- const object = {
249
- cron,
250
- };
251
- this.update({
252
- ...object,
253
- });
254
- }
255
-
256
- /**
257
- * 设置事务
258
- */
259
- setTransactional(transactional: Transactional) {
260
- transactional._delete();
261
- const relationOptions = { parentNode: this, parentKey: 'transactional' };
262
- Object.assign(transactional, relationOptions);
263
- const object = {
264
- transactional,
265
- };
266
- this.update({
267
- ...object,
268
- });
269
- }
270
-
271
- getTypeParamExistingNames(excludedList: Array<TypeParam> = []) {
272
- const excludedSet = new Set(excludedList);
273
- return ((this.typeParams as TypeParam[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
274
- }
275
- getTypeParamUniqueName(name = 'typeParam1') {
276
- return utils.unique(name, this.getTypeParamExistingNames(), undefined, false);
277
- }
278
-
279
- /**
280
- * 插入类型参数
281
- * @internal
282
- * @param name 类型参数名称,如果不填会自动生成一个唯一名称
283
- */
284
- _insertTypeParamAt(name: string, index: number): TypeParam;
285
-
286
- /**
287
- * 插入类型参数
288
- * @internal
289
- * @param typeParamOptions 类型参数参数
290
- */
291
- _insertTypeParamAt(typeParamOptions: Partial<TypeParam>, index: number): TypeParam;
292
-
293
- /**
294
- * 插入类型参数
295
- * @internal
296
- * @param typeParam 已有的类型参数实例
297
- */
298
- _insertTypeParamAt(typeParam: TypeParam, index: number): TypeParam;
299
-
300
- _insertTypeParamAt(options: string | Partial<TypeParam> | TypeParam, index: number) {
301
- const typeParamOptions: any = {};
302
- const relationOptions = { parentNode: this, parentKey: 'typeParams' };
303
- let typeParam: TypeParam;
304
- if (!options) {
305
- typeParam = TypeParam.from({
306
- ...typeParamOptions,
307
- name: this.getTypeParamUniqueName(),
308
- }, this, 'typeParams');
309
- } else if (typeof options === 'string') {
310
- typeParam = TypeParam.from({
311
- ...typeParamOptions,
312
- name: options,
313
- }, this, 'typeParams');
314
- } else if (options instanceof TypeParam) {
315
- options.ensureDelete(); // 同一实例不支持多处存在
316
- typeParam = options;
317
- Object.assign(typeParam, relationOptions);
318
- } else {
319
- typeParam = TypeParam.from({
320
- ...typeParamOptions,
321
- ...options,
322
- }, this, 'typeParams');
323
- }
324
- this.typeParams.splice(index, 0, typeParam);
325
- return typeParam;
326
- }
327
-
328
- /**
329
- * 插入类型参数
330
- * @param name 类型参数名称,如果不填会自动生成一个唯一名称
331
- */
332
- insertTypeParamAt(name: string, index: number): TypeParam;
333
-
334
- /**
335
- * 插入类型参数
336
- * @param typeParamOptions 类型参数参数
337
- */
338
- insertTypeParamAt(typeParamOptions: Partial<TypeParam>, index: number): TypeParam;
339
-
340
- /**
341
- * 插入类型参数
342
- * @param typeParam 已有的类型参数实例
343
- */
344
- insertTypeParamAt(typeParam: TypeParam, index: number): TypeParam;
345
-
346
- insertTypeParamAt(options: string | Partial<TypeParam> | TypeParam, index: number) {
347
- const node = this._insertTypeParamAt(options as any, index);
348
- node.create({
349
- index,
350
- parentNode: this,
351
- parentKey: 'typeParams',
352
- });
353
- return node;
354
- }
355
-
356
- /**
357
- * 添加类型参数
358
- * @internal
359
- * @param name 类型参数名称,如果不填会自动生成一个唯一名称
360
- */
361
- _addTypeParam(name?: string): TypeParam;
362
-
363
- /**
364
- * 添加类型参数
365
- * @internal
366
- * @param typeParamOptions 类型参数参数
367
- */
368
- _addTypeParam(typeParamOptions: Partial<TypeParam>): TypeParam;
369
-
370
- /**
371
- * 添加类型参数
372
- * @internal
373
- * @param typeParam 已有的类型参数实例
374
- */
375
- _addTypeParam(typeParam: TypeParam): TypeParam;
376
-
377
- _addTypeParam(options?: string | Partial<TypeParam> | TypeParam) {
378
- const index = this.typeParams.length;
379
- return this._insertTypeParamAt(options as any, index);
380
- }
381
-
382
- /**
383
- * 添加类型参数
384
- * @internal
385
- * @param name 类型参数名称,如果不填会自动生成一个唯一名称
386
- */
387
- addTypeParam(name?: string): TypeParam;
388
-
389
- /**
390
- * 添加类型参数
391
- * @param typeParamOptions 类型参数参数
392
- */
393
- addTypeParam(typeParamOptions: Partial<TypeParam>): TypeParam;
394
-
395
- /**
396
- * 添加类型参数
397
- * @param typeParam 已有的类型参数实例
398
- */
399
- addTypeParam(typeParam: TypeParam): TypeParam;
400
-
401
- addTypeParam(options?: string | Partial<TypeParam> | TypeParam) {
402
- const node = this._addTypeParam(options as any);
403
- const index = this.typeParams.indexOf(node);
404
- node.create({
405
- index,
406
- parentNode: this,
407
- parentKey: 'typeParams',
408
- });
409
- return node;
410
- }
411
-
412
-
413
- getParamUniqueName(name = 'param1') {
414
- return utils.unique(name, this.getVarExistingNames(), undefined, false);
415
- }
416
-
417
- /**
418
- * 插入输入参数
419
- * @internal
420
- * @param name 输入参数名称,如果不填会自动生成一个唯一名称
421
- */
422
- _insertParamAt(name: string, index: number): Param;
423
-
424
- /**
425
- * 插入输入参数
426
- * @internal
427
- * @param paramOptions 输入参数参数
428
- */
429
- _insertParamAt(paramOptions: Partial<Param>, index: number): Param;
430
-
431
- /**
432
- * 插入输入参数
433
- * @internal
434
- * @param param 已有的输入参数实例
435
- */
436
- _insertParamAt(param: Param, index: number): Param;
437
-
438
- _insertParamAt(options: string | Partial<Param> | Param, index: number) {
439
- const paramOptions: any = {};
440
- const relationOptions = { parentNode: this, parentKey: 'params' };
441
- let param: Param;
442
- if (!options) {
443
- param = Param.from({
444
- ...paramOptions,
445
- name: this.getParamUniqueName(),
446
- }, this, 'params');
447
- } else if (typeof options === 'string') {
448
- param = Param.from({
449
- ...paramOptions,
450
- name: options,
451
- }, this, 'params');
452
- } else if (options instanceof Param) {
453
- options.ensureDelete(); // 同一实例不支持多处存在
454
- param = options;
455
- Object.assign(param, relationOptions);
456
- } else {
457
- param = Param.from({
458
- ...paramOptions,
459
- ...options,
460
- }, this, 'params');
461
- }
462
- this.params.splice(index, 0, param);
463
- return param;
464
- }
465
-
466
- /**
467
- * 插入输入参数
468
- * @param name 输入参数名称,如果不填会自动生成一个唯一名称
469
- */
470
- insertParamAt(name: string, index: number): Param;
471
-
472
- /**
473
- * 插入输入参数
474
- * @param paramOptions 输入参数参数
475
- */
476
- insertParamAt(paramOptions: Partial<Param>, index: number): Param;
477
-
478
- /**
479
- * 插入输入参数
480
- * @param param 已有的输入参数实例
481
- */
482
- insertParamAt(param: Param, index: number): Param;
483
-
484
- insertParamAt(options: string | Partial<Param> | Param, index: number) {
485
- const node = this._insertParamAt(options as any, index);
486
- node.create({
487
- index,
488
- parentNode: this,
489
- parentKey: 'params',
490
- });
491
- return node;
492
- }
493
-
494
- /**
495
- * 添加输入参数
496
- * @internal
497
- * @param name 输入参数名称,如果不填会自动生成一个唯一名称
498
- */
499
- _addParam(name?: string): Param;
500
-
501
- /**
502
- * 添加输入参数
503
- * @internal
504
- * @param paramOptions 输入参数参数
505
- */
506
- _addParam(paramOptions: Partial<Param>): Param;
507
-
508
- /**
509
- * 添加输入参数
510
- * @internal
511
- * @param param 已有的输入参数实例
512
- */
513
- _addParam(param: Param): Param;
514
-
515
- _addParam(options?: string | Partial<Param> | Param) {
516
- const index = this.params.length;
517
- return this._insertParamAt(options as any, index);
518
- }
519
-
520
- /**
521
- * 添加输入参数
522
- * @internal
523
- * @param name 输入参数名称,如果不填会自动生成一个唯一名称
524
- */
525
- addParam(name?: string): Param;
526
-
527
- /**
528
- * 添加输入参数
529
- * @param paramOptions 输入参数参数
530
- */
531
- addParam(paramOptions: Partial<Param>): Param;
532
-
533
- /**
534
- * 添加输入参数
535
- * @param param 已有的输入参数实例
536
- */
537
- addParam(param: Param): Param;
538
-
539
- addParam(options?: string | Partial<Param> | Param) {
540
- const node = this._addParam(options as any);
541
- const index = this.params.indexOf(node);
542
- node.create({
543
- index,
544
- parentNode: this,
545
- parentKey: 'params',
546
- });
547
- return node;
548
- }
549
-
550
-
551
- getReturnUniqueName(name = 'result') {
552
- return utils.unique(name, this.getVarExistingNames(), undefined, false);
553
- }
554
-
555
- /**
556
- * 插入输出参数
557
- * @internal
558
- * @param name 输出参数名称,如果不填会自动生成一个唯一名称
559
- */
560
- _insertReturnAt(name: string, index: number): Return;
561
-
562
- /**
563
- * 插入输出参数
564
- * @internal
565
- * @param retOptions 输出参数参数
566
- */
567
- _insertReturnAt(retOptions: Partial<Return>, index: number): Return;
568
-
569
- /**
570
- * 插入输出参数
571
- * @internal
572
- * @param ret 已有的输出参数实例
573
- */
574
- _insertReturnAt(ret: Return, index: number): Return;
575
-
576
- _insertReturnAt(options: string | Partial<Return> | Return, index: number) {
577
- const retOptions: any = {};
578
- const relationOptions = { parentNode: this, parentKey: 'returns' };
579
- let ret: Return;
580
- if (!options) {
581
- ret = Return.from({
582
- ...retOptions,
583
- name: this.getReturnUniqueName(),
584
- }, this, 'returns');
585
- } else if (typeof options === 'string') {
586
- ret = Return.from({
587
- ...retOptions,
588
- name: options,
589
- }, this, 'returns');
590
- } else if (options instanceof Return) {
591
- options.ensureDelete(); // 同一实例不支持多处存在
592
- ret = options;
593
- Object.assign(ret, relationOptions);
594
- } else {
595
- ret = Return.from({
596
- ...retOptions,
597
- ...options,
598
- }, this, 'returns');
599
- }
600
- this.returns.splice(index, 0, ret);
601
- return ret;
602
- }
603
-
604
- /**
605
- * 插入输出参数
606
- * @param name 输出参数名称,如果不填会自动生成一个唯一名称
607
- */
608
- insertReturnAt(name: string, index: number): Return;
609
-
610
- /**
611
- * 插入输出参数
612
- * @param retOptions 输出参数参数
613
- */
614
- insertReturnAt(retOptions: Partial<Return>, index: number): Return;
615
-
616
- /**
617
- * 插入输出参数
618
- * @param ret 已有的输出参数实例
619
- */
620
- insertReturnAt(ret: Return, index: number): Return;
621
-
622
- insertReturnAt(options: string | Partial<Return> | Return, index: number) {
623
- const node = this._insertReturnAt(options as any, index);
624
- node.create({
625
- index,
626
- parentNode: this,
627
- parentKey: 'returns',
628
- });
629
- return node;
630
- }
631
-
632
- /**
633
- * 添加输出参数
634
- * @internal
635
- * @param name 输出参数名称,如果不填会自动生成一个唯一名称
636
- */
637
- _addReturn(name?: string): Return;
638
-
639
- /**
640
- * 添加输出参数
641
- * @internal
642
- * @param retOptions 输出参数参数
643
- */
644
- _addReturn(retOptions: Partial<Return>): Return;
645
-
646
- /**
647
- * 添加输出参数
648
- * @internal
649
- * @param ret 已有的输出参数实例
650
- */
651
- _addReturn(ret: Return): Return;
652
-
653
- _addReturn(options?: string | Partial<Return> | Return) {
654
- const index = this.returns.length;
655
- return this._insertReturnAt(options as any, index);
656
- }
657
-
658
- /**
659
- * 添加输出参数
660
- * @internal
661
- * @param name 输出参数名称,如果不填会自动生成一个唯一名称
662
- */
663
- addReturn(name?: string): Return;
664
-
665
- /**
666
- * 添加输出参数
667
- * @param retOptions 输出参数参数
668
- */
669
- addReturn(retOptions: Partial<Return>): Return;
670
-
671
- /**
672
- * 添加输出参数
673
- * @param ret 已有的输出参数实例
674
- */
675
- addReturn(ret: Return): Return;
676
-
677
- addReturn(options?: string | Partial<Return> | Return) {
678
- const node = this._addReturn(options as any);
679
- const index = this.returns.indexOf(node);
680
- node.create({
681
- index,
682
- parentNode: this,
683
- parentKey: 'returns',
684
- });
685
- return node;
686
- }
687
-
688
-
689
- getVariableUniqueName(name = 'variable1') {
690
- return utils.unique(name, this.getVarExistingNames(), undefined, false);
691
- }
692
-
693
- /**
694
- * 插入变量
695
- * @internal
696
- * @param name 变量名称,如果不填会自动生成一个唯一名称
697
- */
698
- _insertVariableAt(name: string, index: number): Variable;
699
-
700
- /**
701
- * 插入变量
702
- * @internal
703
- * @param variableOptions 变量参数
704
- */
705
- _insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
706
-
707
- /**
708
- * 插入变量
709
- * @internal
710
- * @param variable 已有的变量实例
711
- */
712
- _insertVariableAt(variable: Variable, index: number): Variable;
713
-
714
- _insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
715
- const variableOptions: any = {};
716
- const relationOptions = { parentNode: this, parentKey: 'variables' };
717
- let variable: Variable;
718
- if (!options) {
719
- variable = Variable.from({
720
- ...variableOptions,
721
- name: this.getVariableUniqueName(),
722
- }, this, 'variables');
723
- } else if (typeof options === 'string') {
724
- variable = Variable.from({
725
- ...variableOptions,
726
- name: options,
727
- }, this, 'variables');
728
- } else if (options instanceof Variable) {
729
- options.ensureDelete(); // 同一实例不支持多处存在
730
- variable = options;
731
- Object.assign(variable, relationOptions);
732
- } else {
733
- variable = Variable.from({
734
- ...variableOptions,
735
- ...options,
736
- }, this, 'variables');
737
- }
738
- this.variables.splice(index, 0, variable);
739
- return variable;
740
- }
741
-
742
- /**
743
- * 插入变量
744
- * @param name 变量名称,如果不填会自动生成一个唯一名称
745
- */
746
- insertVariableAt(name: string, index: number): Variable;
747
-
748
- /**
749
- * 插入变量
750
- * @param variableOptions 变量参数
751
- */
752
- insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
753
-
754
- /**
755
- * 插入变量
756
- * @param variable 已有的变量实例
757
- */
758
- insertVariableAt(variable: Variable, index: number): Variable;
759
-
760
- insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
761
- const node = this._insertVariableAt(options as any, index);
762
- node.create({
763
- index,
764
- parentNode: this,
765
- parentKey: 'variables',
766
- });
767
- return node;
768
- }
769
-
770
- /**
771
- * 添加变量
772
- * @internal
773
- * @param name 变量名称,如果不填会自动生成一个唯一名称
774
- */
775
- _addVariable(name?: string): Variable;
776
-
777
- /**
778
- * 添加变量
779
- * @internal
780
- * @param variableOptions 变量参数
781
- */
782
- _addVariable(variableOptions: Partial<Variable>): Variable;
783
-
784
- /**
785
- * 添加变量
786
- * @internal
787
- * @param variable 已有的变量实例
788
- */
789
- _addVariable(variable: Variable): Variable;
790
-
791
- _addVariable(options?: string | Partial<Variable> | Variable) {
792
- const index = this.variables.length;
793
- return this._insertVariableAt(options as any, index);
794
- }
795
-
796
- /**
797
- * 添加变量
798
- * @internal
799
- * @param name 变量名称,如果不填会自动生成一个唯一名称
800
- */
801
- addVariable(name?: string): Variable;
802
-
803
- /**
804
- * 添加变量
805
- * @param variableOptions 变量参数
806
- */
807
- addVariable(variableOptions: Partial<Variable>): Variable;
808
-
809
- /**
810
- * 添加变量
811
- * @param variable 已有的变量实例
812
- */
813
- addVariable(variable: Variable): Variable;
814
-
815
- addVariable(options?: string | Partial<Variable> | Variable) {
816
- const node = this._addVariable(options as any);
817
- const index = this.variables.indexOf(node);
818
- node.create({
819
- index,
820
- parentNode: this,
821
- parentKey: 'variables',
822
- });
823
- return node;
824
- }
825
-
826
-
827
-
828
-
829
-
830
-
831
- /**
832
- * 插入逻辑项
833
- * @internal
834
- * @param logicItemOptions 逻辑项参数
835
- */
836
- _insertItemInBodyAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
837
-
838
- /**
839
- * 插入逻辑项
840
- * @internal
841
- * @param logicItem 已有的逻辑项实例
842
- */
843
- _insertItemInBodyAt(logicItem: LogicItem, index: number): LogicItem;
844
-
845
- _insertItemInBodyAt(options: Partial<LogicItem> | LogicItem, index: number) {
846
- const logicItemOptions: any = {};
847
- const relationOptions = { parentNode: this, parentKey: 'body' };
848
- let logicItem: LogicItem;
849
- if (options instanceof LogicItem) {
850
- options.ensureDelete(); // 同一实例不支持多处存在
851
- logicItem = options;
852
- Object.assign(logicItem, relationOptions);
853
- } else {
854
- logicItem = LogicItem.from({
855
- ...logicItemOptions,
856
- ...options,
857
- }, this, 'body');
858
- }
859
- this.body.splice(index, 0, logicItem);
860
- return logicItem;
861
- }
862
-
863
-
864
-
865
- /**
866
- * 插入逻辑项
867
- * @param logicItemOptions 逻辑项参数
868
- */
869
- insertItemInBodyAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
870
-
871
- /**
872
- * 插入逻辑项
873
- * @param logicItem 已有的逻辑项实例
874
- */
875
- insertItemInBodyAt(logicItem: LogicItem, index: number): LogicItem;
876
-
877
- insertItemInBodyAt(options: Partial<LogicItem> | LogicItem, index: number) {
878
- const node = this._insertItemInBodyAt(options as any, index);
879
- node.create({
880
- index,
881
- parentNode: this,
882
- parentKey: 'body',
883
- });
884
- return node;
885
- }
886
-
887
-
888
-
889
- /**
890
- * 添加逻辑项
891
- * @internal
892
- * @param logicItemOptions 逻辑项参数
893
- */
894
- _addItemInBody(logicItemOptions: Partial<LogicItem>): LogicItem;
895
-
896
- /**
897
- * 添加逻辑项
898
- * @internal
899
- * @param logicItem 已有的逻辑项实例
900
- */
901
- _addItemInBody(logicItem: LogicItem): LogicItem;
902
-
903
- _addItemInBody(options?: Partial<LogicItem> | LogicItem) {
904
- const index = this.body.length;
905
- return this._insertItemInBodyAt(options as any, index);
906
- }
907
-
908
-
909
-
910
- /**
911
- * 添加逻辑项
912
- * @param logicItemOptions 逻辑项参数
913
- */
914
- addItemInBody(logicItemOptions: Partial<LogicItem>): LogicItem;
915
-
916
- /**
917
- * 添加逻辑项
918
- * @param logicItem 已有的逻辑项实例
919
- */
920
- addItemInBody(logicItem: LogicItem): LogicItem;
921
-
922
- addItemInBody(options?: Partial<LogicItem> | LogicItem) {
923
- const node = this._addItemInBody(options as any);
924
- const index = this.body.indexOf(node);
925
- node.create({
926
- index,
927
- parentNode: this,
928
- parentKey: 'body',
929
- });
930
- return node;
931
- }
932
-
933
-
934
-
935
- /**
936
- * 插入逻辑项
937
- * @internal
938
- * @param logicItemOptions 逻辑项参数
939
- */
940
- _insertItemInPlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
941
-
942
- /**
943
- * 插入逻辑项
944
- * @internal
945
- * @param logicItem 已有的逻辑项实例
946
- */
947
- _insertItemInPlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
948
-
949
- _insertItemInPlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
950
- const logicItemOptions: any = {};
951
- const relationOptions = { parentNode: this, parentKey: 'playground' };
952
- let logicItem: LogicItem;
953
- if (options instanceof LogicItem) {
954
- options.ensureDelete(); // 同一实例不支持多处存在
955
- logicItem = options;
956
- Object.assign(logicItem, relationOptions);
957
- } else {
958
- logicItem = LogicItem.from({
959
- ...logicItemOptions,
960
- ...options,
961
- }, this, 'playground');
962
- }
963
- this.playground.splice(index, 0, logicItem);
964
- return logicItem;
965
- }
966
-
967
-
968
-
969
- /**
970
- * 插入逻辑项
971
- * @param logicItemOptions 逻辑项参数
972
- */
973
- insertItemInPlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
974
-
975
- /**
976
- * 插入逻辑项
977
- * @param logicItem 已有的逻辑项实例
978
- */
979
- insertItemInPlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
980
-
981
- insertItemInPlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
982
- const node = this._insertItemInPlaygroundAt(options as any, index);
983
- node.create({
984
- index,
985
- parentNode: this,
986
- parentKey: 'playground',
987
- });
988
- return node;
989
- }
990
-
991
-
992
-
993
- /**
994
- * 添加逻辑项
995
- * @internal
996
- * @param logicItemOptions 逻辑项参数
997
- */
998
- _addItemInPlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
999
-
1000
- /**
1001
- * 添加逻辑项
1002
- * @internal
1003
- * @param logicItem 已有的逻辑项实例
1004
- */
1005
- _addItemInPlayground(logicItem: LogicItem): LogicItem;
1006
-
1007
- _addItemInPlayground(options?: Partial<LogicItem> | LogicItem) {
1008
- const index = this.playground.length;
1009
- return this._insertItemInPlaygroundAt(options as any, index);
1010
- }
1011
-
1012
-
1013
-
1014
- /**
1015
- * 添加逻辑项
1016
- * @param logicItemOptions 逻辑项参数
1017
- */
1018
- addItemInPlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
1019
-
1020
- /**
1021
- * 添加逻辑项
1022
- * @param logicItem 已有的逻辑项实例
1023
- */
1024
- addItemInPlayground(logicItem: LogicItem): LogicItem;
1025
-
1026
- addItemInPlayground(options?: Partial<LogicItem> | LogicItem) {
1027
- const node = this._addItemInPlayground(options as any);
1028
- const index = this.playground.indexOf(node);
1029
- node.create({
1030
- index,
1031
- parentNode: this,
1032
- parentKey: 'playground',
1033
- });
1034
- return node;
1035
- }
1036
-
1037
-
1038
-
1039
-
1040
- /**
1041
- * 删除事务
1042
- * @param name 事务名称
1043
- */
1044
- removeTransactional(name: string): void;
1045
-
1046
- /**
1047
- * 删除事务
1048
- * @param transactional 已有的事务实例
1049
- */
1050
- removeTransactional(transactional: Transactional): void;
1051
-
1052
- removeTransactional(options: string | Transactional) {
1053
- let transactional: Transactional;
1054
- if (typeof options === 'string') {
1055
- transactional = this.transactional;
1056
- if (!transactional) {
1057
- throw new Error('找不到事务 ' + options);
1058
- }
1059
- } else {
1060
- transactional = options;
1061
- }
1062
- return transactional.delete();
1063
- }
1064
-
1065
- __removeTransactional(transactional: Transactional) {
1066
- const parentKey = transactional.parentKey;
1067
- const params: Params = {
1068
- parentNode: this,
1069
- parentKey,
1070
- index: -1,
1071
- object: null,
1072
- oldObject: transactional,
1073
- };
1074
- if (parentKey) {
1075
- params.parentKey = parentKey;
1076
- if (Array.isArray((this as any)[parentKey])) {
1077
- const index = (this as any)[parentKey].indexOf(transactional);
1078
- ~index && (this as any)[parentKey].splice(index, 1);
1079
- params.index = index;
1080
- } else if ((this as any)[parentKey] === transactional) {
1081
- params.index = 0;
1082
- (this as any)[parentKey] = undefined;
1083
- }
1084
- }
1085
- return params;
1086
- }
1087
-
1088
-
1089
-
1090
- /**
1091
- * 删除类型参数
1092
- * @param name 类型参数名称
1093
- */
1094
- removeTypeParam(name: string): void;
1095
-
1096
- /**
1097
- * 删除类型参数
1098
- * @param typeParam 已有的类型参数实例
1099
- */
1100
- removeTypeParam(typeParam: TypeParam): void;
1101
-
1102
- removeTypeParam(options: string | TypeParam) {
1103
- let typeParam: TypeParam;
1104
- if (typeof options === 'string') {
1105
- typeParam = (this.typeParams as TypeParam[]).find((item) => item.name === options);
1106
- if (!typeParam) {
1107
- throw new Error('找不到类型参数 ' + options);
1108
- }
1109
- } else {
1110
- typeParam = options;
1111
- }
1112
- return typeParam.delete();
1113
- }
1114
-
1115
- __removeTypeParam(typeParam: TypeParam) {
1116
- const parentKey = typeParam.parentKey;
1117
- const params: Params = {
1118
- parentNode: this,
1119
- parentKey,
1120
- index: -1,
1121
- object: null,
1122
- oldObject: typeParam,
1123
- };
1124
- if (parentKey) {
1125
- params.parentKey = parentKey;
1126
- if (Array.isArray((this as any)[parentKey])) {
1127
- const index = (this as any)[parentKey].indexOf(typeParam);
1128
- ~index && (this as any)[parentKey].splice(index, 1);
1129
- params.index = index;
1130
- } else if ((this as any)[parentKey] === typeParam) {
1131
- params.index = 0;
1132
- (this as any)[parentKey] = undefined;
1133
- }
1134
- }
1135
- return params;
1136
- }
1137
-
1138
-
1139
-
1140
- /**
1141
- * 删除输入参数
1142
- * @param name 输入参数名称
1143
- */
1144
- removeParam(name: string): void;
1145
-
1146
- /**
1147
- * 删除输入参数
1148
- * @param param 已有的输入参数实例
1149
- */
1150
- removeParam(param: Param): void;
1151
-
1152
- removeParam(options: string | Param) {
1153
- let param: Param;
1154
- if (typeof options === 'string') {
1155
- param = (this.params as Param[]).find((item) => item.name === options);
1156
- if (!param) {
1157
- throw new Error('找不到输入参数 ' + options);
1158
- }
1159
- } else {
1160
- param = options;
1161
- }
1162
- return param.delete();
1163
- }
1164
-
1165
- __removeParam(param: Param) {
1166
- const parentKey = param.parentKey;
1167
- const params: Params = {
1168
- parentNode: this,
1169
- parentKey,
1170
- index: -1,
1171
- object: null,
1172
- oldObject: param,
1173
- };
1174
- if (parentKey) {
1175
- params.parentKey = parentKey;
1176
- if (Array.isArray((this as any)[parentKey])) {
1177
- const index = (this as any)[parentKey].indexOf(param);
1178
- ~index && (this as any)[parentKey].splice(index, 1);
1179
- params.index = index;
1180
- } else if ((this as any)[parentKey] === param) {
1181
- params.index = 0;
1182
- (this as any)[parentKey] = undefined;
1183
- }
1184
- }
1185
- return params;
1186
- }
1187
-
1188
-
1189
-
1190
- /**
1191
- * 删除输出参数
1192
- * @param name 输出参数名称
1193
- */
1194
- removeReturn(name: string): void;
1195
-
1196
- /**
1197
- * 删除输出参数
1198
- * @param ret 已有的输出参数实例
1199
- */
1200
- removeReturn(ret: Return): void;
1201
-
1202
- removeReturn(options: string | Return) {
1203
- let ret: Return;
1204
- if (typeof options === 'string') {
1205
- ret = (this.returns as Return[]).find((item) => item.name === options);
1206
- if (!ret) {
1207
- throw new Error('找不到输出参数 ' + options);
1208
- }
1209
- } else {
1210
- ret = options;
1211
- }
1212
- return ret.delete();
1213
- }
1214
-
1215
- __removeReturn(ret: Return) {
1216
- const parentKey = ret.parentKey;
1217
- const params: Params = {
1218
- parentNode: this,
1219
- parentKey,
1220
- index: -1,
1221
- object: null,
1222
- oldObject: ret,
1223
- };
1224
- if (parentKey) {
1225
- params.parentKey = parentKey;
1226
- if (Array.isArray((this as any)[parentKey])) {
1227
- const index = (this as any)[parentKey].indexOf(ret);
1228
- ~index && (this as any)[parentKey].splice(index, 1);
1229
- params.index = index;
1230
- } else if ((this as any)[parentKey] === ret) {
1231
- params.index = 0;
1232
- (this as any)[parentKey] = undefined;
1233
- }
1234
- }
1235
- return params;
1236
- }
1237
-
1238
-
1239
-
1240
- /**
1241
- * 删除变量
1242
- * @param name 变量名称
1243
- */
1244
- removeVariable(name: string): void;
1245
-
1246
- /**
1247
- * 删除变量
1248
- * @param variable 已有的变量实例
1249
- */
1250
- removeVariable(variable: Variable): void;
1251
-
1252
- removeVariable(options: string | Variable) {
1253
- let variable: Variable;
1254
- if (typeof options === 'string') {
1255
- variable = (this.variables as Variable[]).find((item) => item.name === options);
1256
- if (!variable) {
1257
- throw new Error('找不到变量 ' + options);
1258
- }
1259
- } else {
1260
- variable = options;
1261
- }
1262
- return variable.delete();
1263
- }
1264
-
1265
- __removeVariable(variable: Variable) {
1266
- const parentKey = variable.parentKey;
1267
- const params: Params = {
1268
- parentNode: this,
1269
- parentKey,
1270
- index: -1,
1271
- object: null,
1272
- oldObject: variable,
1273
- };
1274
- if (parentKey) {
1275
- params.parentKey = parentKey;
1276
- if (Array.isArray((this as any)[parentKey])) {
1277
- const index = (this as any)[parentKey].indexOf(variable);
1278
- ~index && (this as any)[parentKey].splice(index, 1);
1279
- params.index = index;
1280
- } else if ((this as any)[parentKey] === variable) {
1281
- params.index = 0;
1282
- (this as any)[parentKey] = undefined;
1283
- }
1284
- }
1285
- return params;
1286
- }
1287
-
1288
-
1289
-
1290
- /**
1291
- * 删除逻辑项
1292
- * @param logicItem 已有的逻辑项实例
1293
- */
1294
- removeItemInBody(logicItem: LogicItem): void;
1295
-
1296
- removeItemInBody(options: LogicItem) {
1297
- let logicItem: LogicItem = options;
1298
- return logicItem.delete();
1299
- }
1300
-
1301
-
1302
-
1303
- /**
1304
- * 删除逻辑项
1305
- * @param logicItem 已有的逻辑项实例
1306
- */
1307
- removeItemInPlayground(logicItem: LogicItem): void;
1308
-
1309
- removeItemInPlayground(options: LogicItem) {
1310
- let logicItem: LogicItem = options;
1311
- return logicItem.delete();
1312
- }
1313
-
1314
- __removeLogicItem(logicItem: LogicItem) {
1315
- const parentKey = logicItem.parentKey;
1316
- const params: Params = {
1317
- parentNode: this,
1318
- parentKey,
1319
- index: -1,
1320
- object: null,
1321
- oldObject: logicItem,
1322
- };
1323
- if (parentKey) {
1324
- params.parentKey = parentKey;
1325
- if (Array.isArray((this as any)[parentKey])) {
1326
- const index = (this as any)[parentKey].indexOf(logicItem);
1327
- ~index && (this as any)[parentKey].splice(index, 1);
1328
- params.index = index;
1329
- } else if ((this as any)[parentKey] === logicItem) {
1330
- params.index = 0;
1331
- (this as any)[parentKey] = undefined;
1332
- }
1333
- }
1334
- return params;
1335
- }
1336
-
1337
- //================================================================================
1338
- // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1339
- // 自动生成的代码已结束。下面可以手动编写。
1340
- //================================================================================
1341
- // 用于calllogic树中定位是那个logic,回显
1342
- get calleewholeKey() {
1343
- return this.getNamespace() + '.' + this.name;
1344
- }
1345
- // 设置定时任务
1346
- setCronAndTriggerType(cron: string, triggerType: string) {
1347
- const object = {
1348
- cron,
1349
- triggerType,
1350
- };
1351
- this.update({
1352
- ...object,
1353
- });
1354
- }
1355
-
1356
- /**
1357
- * 创建的时候 打开事务 通过开关设置数据库事务
1358
- */
1359
- openTransactional(flag: boolean) {
1360
- if (flag) {
1361
- const transactional = new Transactional({
1362
- enabled: flag,
1363
- });
1364
- transactional._delete();
1365
- const relationOptions = { parentNode: this, parentKey: 'transactional' };
1366
- Object.assign(transactional, relationOptions);
1367
- this.transactional = transactional;
1368
- }
1369
- }
1370
- findLogicItemByConcept(concept: string) {
1371
- let result: any;
1372
-
1373
- utils.traverse((current) => {
1374
- if ((current.node as any).concept === concept)
1375
- return (result = current.node);
1376
- }, { node: this }, {
1377
- mode: 'anyObject',
1378
- excludedKeySet: this.JSON_EXCLUDED_KEYS,
1379
- });
1380
-
1381
- return result as LogicItem;
1382
- }
1383
-
1384
- onChange($event?: EventPayload): void {
1385
- this.emit('change', $event);
1386
- }
1387
-
1388
- getVarExistingNames(excludedList: Array<Param | Return | Variable> = []) {
1389
- const excludedSet = new Set(excludedList);
1390
- const varList: any[] = [];
1391
- if (Array.isArray(this.params)) {
1392
- varList.push(...this.params);
47
+ /**
48
+ * 产品概念
49
+ */
50
+ @property()
51
+ concept: 'OverriddenLogic' = 'OverriddenLogic';
52
+
53
+ /**
54
+ * overriddenModule
55
+ */
56
+ @property()
57
+ overriddenModule: string = undefined;
58
+
59
+ /**
60
+ * 逻辑名称
61
+ */
62
+ @property()
63
+ name: string = undefined;
64
+
65
+ /**
66
+ * 逻辑描述
67
+ */
68
+ @property()
69
+ description: string = undefined;
70
+
71
+ /**
72
+ * triggerType
73
+ */
74
+ @property()
75
+ triggerType: string = undefined;
76
+
77
+ /**
78
+ * cron
79
+ */
80
+ @property()
81
+ cron: string = undefined;
82
+
83
+ /**
84
+ * 事务
85
+ */
86
+ @property('Transactional')
87
+ transactional: Transactional = undefined;
88
+
89
+ /**
90
+ * 编译器信息
91
+ */
92
+ @property()
93
+ compilerInfoMap: { java?: { packageName: string; className: string } } = undefined;
94
+
95
+ /**
96
+ * 类型参数列表
97
+ */
98
+ @property('TypeParam')
99
+ typeParams: Array<TypeParam> = null;
100
+
101
+ /**
102
+ * 输入参数列表
103
+ */
104
+ @property('Param')
105
+ params: Array<Param> = [];
106
+
107
+ /**
108
+ * 输出参数列表
109
+ */
110
+ @property('Return')
111
+ returns: Array<Return> = [];
112
+
113
+ /**
114
+ * 变量列表
115
+ */
116
+ @property('Variable')
117
+ variables: Array<Variable> = [];
118
+
119
+ /**
120
+ * 逻辑项列表
121
+ */
122
+ @property('LogicItem')
123
+ body: Array<LogicItem> = [];
124
+
125
+ /**
126
+ * 逻辑项列表
127
+ */
128
+ @property('LogicItem')
129
+ playground: Array<LogicItem> = [];
130
+
131
+ /**
132
+ * 祖先 Module
133
+ */
134
+ get module() {
135
+ return this.getAncestor('Module') as Module;
136
+ }
137
+
138
+ /**
139
+ * 祖先 App
140
+ */
141
+ get app() {
142
+ return this.getAncestor('App') as App;
143
+ }
144
+
145
+ /**
146
+ * 祖先 View
147
+ */
148
+ get view() {
149
+ return this.getAncestor('View') as View;
150
+ }
151
+
152
+ /**
153
+ * 祖先 Frontend
154
+ */
155
+ get frontend() {
156
+ return this.getAncestor('Frontend') as Frontend;
157
+ }
158
+
159
+ /**
160
+ * 祖先 ProcessElement
161
+ */
162
+ get processElement() {
163
+ return this.getAncestor('ProcessElement') as ProcessElement;
164
+ }
165
+
166
+ /**
167
+ * 祖先 Process
168
+ */
169
+ get process() {
170
+ return this.getAncestor('Process') as Process;
171
+ }
172
+
173
+ /**
174
+ * @param source 需要合并的部分参数
175
+ */
176
+ constructor(source?: Partial<OverriddenLogic>) {
177
+ // @ts-ignore
178
+ source = { ...OverriddenLogic.getDefaultOptions(), ...source };
179
+ super(source);
180
+ super.subConstructor(source);
181
+ }
182
+
183
+ getClassName() {
184
+ return 'OverriddenLogic';
185
+ }
186
+
187
+ static from(source: any, parentNode?: any, parentKey?: string): OverriddenLogic {
188
+ return super.from(source, parentNode, parentKey) as OverriddenLogic;
189
+ }
190
+
191
+ /**
192
+ * 从父级删除该节点
193
+ * @internal
194
+ */
195
+ _delete() {
196
+ let params: Params = null;
197
+ if (this.parentNode) {
198
+ params = (this.parentNode as any)?.__removeOverriddenLogic?.(this);
199
+ }
200
+ return params;
201
+ }
202
+
203
+ /**
204
+ * 设置overriddenModule
205
+ */
206
+ setOverriddenModule(overriddenModule: string) {
207
+ const object = {
208
+ overriddenModule,
209
+ };
210
+ this.update({
211
+ ...object,
212
+ });
213
+ }
214
+
215
+ /**
216
+ * 设置逻辑名称
217
+ */
218
+ setName(name: string) {
219
+ const object = {
220
+ name,
221
+ };
222
+ this.update({
223
+ ...object,
224
+ field: 'name',
225
+ });
226
+ }
227
+
228
+ /**
229
+ * 设置逻辑描述
230
+ */
231
+ setDescription(description: string) {
232
+ const object = {
233
+ description,
234
+ };
235
+ this.update({
236
+ ...object,
237
+ });
238
+ }
239
+
240
+ /**
241
+ * 设置triggerType
242
+ */
243
+ setTriggerType(triggerType: string) {
244
+ const object = {
245
+ triggerType,
246
+ };
247
+ this.update({
248
+ ...object,
249
+ });
250
+ }
251
+
252
+ /**
253
+ * 设置cron
254
+ */
255
+ setCron(cron: string) {
256
+ const object = {
257
+ cron,
258
+ };
259
+ this.update({
260
+ ...object,
261
+ });
262
+ }
263
+
264
+ /**
265
+ * 设置事务
266
+ */
267
+ setTransactional(transactional: Transactional) {
268
+ transactional._delete();
269
+ const relationOptions = { parentNode: this, parentKey: 'transactional' };
270
+ Object.assign(transactional, relationOptions);
271
+ const object = {
272
+ transactional,
273
+ };
274
+ this.update({
275
+ ...object,
276
+ });
277
+ }
278
+
279
+ getTypeParamExistingNames(excludedList: Array<TypeParam> = []) {
280
+ const excludedSet = new Set(excludedList);
281
+ return ((this.typeParams as TypeParam[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
282
+ }
283
+
284
+ getTypeParamUniqueName(name = 'typeParam1') {
285
+ return utils.unique(name, this.getTypeParamExistingNames(), undefined, false);
286
+ }
287
+
288
+ /**
289
+ * 插入类型参数
290
+ * @internal
291
+ * @param name 类型参数名称,如果不填会自动生成一个唯一名称
292
+ */
293
+ _insertTypeParamAt(name: string, index: number): TypeParam;
294
+
295
+ /**
296
+ * 插入类型参数
297
+ * @internal
298
+ * @param typeParamOptions 类型参数参数
299
+ */
300
+ _insertTypeParamAt(typeParamOptions: Partial<TypeParam>, index: number): TypeParam;
301
+
302
+ /**
303
+ * 插入类型参数
304
+ * @internal
305
+ * @param typeParam 已有的类型参数实例
306
+ */
307
+ _insertTypeParamAt(typeParam: TypeParam, index: number): TypeParam;
308
+
309
+ _insertTypeParamAt(options: string | Partial<TypeParam> | TypeParam, index: number) {
310
+ const typeParamOptions: any = {};
311
+ const relationOptions = { parentNode: this, parentKey: 'typeParams' };
312
+ let typeParam: TypeParam;
313
+ if (!options) {
314
+ typeParam = TypeParam.from(
315
+ {
316
+ ...typeParamOptions,
317
+ name: this.getTypeParamUniqueName(),
318
+ },
319
+ this,
320
+ 'typeParams'
321
+ );
322
+ } else if (typeof options === 'string') {
323
+ typeParam = TypeParam.from(
324
+ {
325
+ ...typeParamOptions,
326
+ name: options,
327
+ },
328
+ this,
329
+ 'typeParams'
330
+ );
331
+ } else if (options instanceof TypeParam) {
332
+ options.ensureDelete(); // 同一实例不支持多处存在
333
+ typeParam = options;
334
+ Object.assign(typeParam, relationOptions);
335
+ } else {
336
+ typeParam = TypeParam.from(
337
+ {
338
+ ...typeParamOptions,
339
+ ...options,
340
+ },
341
+ this,
342
+ 'typeParams'
343
+ );
344
+ }
345
+ this.typeParams.splice(index, 0, typeParam);
346
+ return typeParam;
347
+ }
348
+
349
+ /**
350
+ * 插入类型参数
351
+ * @param name 类型参数名称,如果不填会自动生成一个唯一名称
352
+ */
353
+ insertTypeParamAt(name: string, index: number): TypeParam;
354
+
355
+ /**
356
+ * 插入类型参数
357
+ * @param typeParamOptions 类型参数参数
358
+ */
359
+ insertTypeParamAt(typeParamOptions: Partial<TypeParam>, index: number): TypeParam;
360
+
361
+ /**
362
+ * 插入类型参数
363
+ * @param typeParam 已有的类型参数实例
364
+ */
365
+ insertTypeParamAt(typeParam: TypeParam, index: number): TypeParam;
366
+
367
+ insertTypeParamAt(options: string | Partial<TypeParam> | TypeParam, index: number) {
368
+ const node = this._insertTypeParamAt(options as any, index);
369
+ node.create({
370
+ index,
371
+ parentNode: this,
372
+ parentKey: 'typeParams',
373
+ });
374
+ return node;
375
+ }
376
+
377
+ /**
378
+ * 添加类型参数
379
+ * @internal
380
+ * @param name 类型参数名称,如果不填会自动生成一个唯一名称
381
+ */
382
+ _addTypeParam(name?: string): TypeParam;
383
+
384
+ /**
385
+ * 添加类型参数
386
+ * @internal
387
+ * @param typeParamOptions 类型参数参数
388
+ */
389
+ _addTypeParam(typeParamOptions: Partial<TypeParam>): TypeParam;
390
+
391
+ /**
392
+ * 添加类型参数
393
+ * @internal
394
+ * @param typeParam 已有的类型参数实例
395
+ */
396
+ _addTypeParam(typeParam: TypeParam): TypeParam;
397
+
398
+ _addTypeParam(options?: string | Partial<TypeParam> | TypeParam) {
399
+ const index = this.typeParams.length;
400
+ return this._insertTypeParamAt(options as any, index);
401
+ }
402
+
403
+ /**
404
+ * 添加类型参数
405
+ * @internal
406
+ * @param name 类型参数名称,如果不填会自动生成一个唯一名称
407
+ */
408
+ addTypeParam(name?: string): TypeParam;
409
+
410
+ /**
411
+ * 添加类型参数
412
+ * @param typeParamOptions 类型参数参数
413
+ */
414
+ addTypeParam(typeParamOptions: Partial<TypeParam>): TypeParam;
415
+
416
+ /**
417
+ * 添加类型参数
418
+ * @param typeParam 已有的类型参数实例
419
+ */
420
+ addTypeParam(typeParam: TypeParam): TypeParam;
421
+
422
+ addTypeParam(options?: string | Partial<TypeParam> | TypeParam) {
423
+ const node = this._addTypeParam(options as any);
424
+ const index = this.typeParams.indexOf(node);
425
+ node.create({
426
+ index,
427
+ parentNode: this,
428
+ parentKey: 'typeParams',
429
+ });
430
+ return node;
431
+ }
432
+
433
+ getParamUniqueName(name = 'param1') {
434
+ return utils.unique(name, this.getVarExistingNames(), undefined, false);
435
+ }
436
+
437
+ /**
438
+ * 插入输入参数
439
+ * @internal
440
+ * @param name 输入参数名称,如果不填会自动生成一个唯一名称
441
+ */
442
+ _insertParamAt(name: string, index: number): Param;
443
+
444
+ /**
445
+ * 插入输入参数
446
+ * @internal
447
+ * @param paramOptions 输入参数参数
448
+ */
449
+ _insertParamAt(paramOptions: Partial<Param>, index: number): Param;
450
+
451
+ /**
452
+ * 插入输入参数
453
+ * @internal
454
+ * @param param 已有的输入参数实例
455
+ */
456
+ _insertParamAt(param: Param, index: number): Param;
457
+
458
+ _insertParamAt(options: string | Partial<Param> | Param, index: number) {
459
+ const paramOptions: any = {};
460
+ const relationOptions = { parentNode: this, parentKey: 'params' };
461
+ let param: Param;
462
+ if (!options) {
463
+ param = Param.from(
464
+ {
465
+ ...paramOptions,
466
+ name: this.getParamUniqueName(),
467
+ },
468
+ this,
469
+ 'params'
470
+ );
471
+ } else if (typeof options === 'string') {
472
+ param = Param.from(
473
+ {
474
+ ...paramOptions,
475
+ name: options,
476
+ },
477
+ this,
478
+ 'params'
479
+ );
480
+ } else if (options instanceof Param) {
481
+ options.ensureDelete(); // 同一实例不支持多处存在
482
+ param = options;
483
+ Object.assign(param, relationOptions);
484
+ } else {
485
+ param = Param.from(
486
+ {
487
+ ...paramOptions,
488
+ ...options,
489
+ },
490
+ this,
491
+ 'params'
492
+ );
493
+ }
494
+ this.params.splice(index, 0, param);
495
+ return param;
496
+ }
497
+
498
+ /**
499
+ * 插入输入参数
500
+ * @param name 输入参数名称,如果不填会自动生成一个唯一名称
501
+ */
502
+ insertParamAt(name: string, index: number): Param;
503
+
504
+ /**
505
+ * 插入输入参数
506
+ * @param paramOptions 输入参数参数
507
+ */
508
+ insertParamAt(paramOptions: Partial<Param>, index: number): Param;
509
+
510
+ /**
511
+ * 插入输入参数
512
+ * @param param 已有的输入参数实例
513
+ */
514
+ insertParamAt(param: Param, index: number): Param;
515
+
516
+ insertParamAt(options: string | Partial<Param> | Param, index: number) {
517
+ const node = this._insertParamAt(options as any, index);
518
+ node.create({
519
+ index,
520
+ parentNode: this,
521
+ parentKey: 'params',
522
+ });
523
+ return node;
524
+ }
525
+
526
+ /**
527
+ * 添加输入参数
528
+ * @internal
529
+ * @param name 输入参数名称,如果不填会自动生成一个唯一名称
530
+ */
531
+ _addParam(name?: string): Param;
532
+
533
+ /**
534
+ * 添加输入参数
535
+ * @internal
536
+ * @param paramOptions 输入参数参数
537
+ */
538
+ _addParam(paramOptions: Partial<Param>): Param;
539
+
540
+ /**
541
+ * 添加输入参数
542
+ * @internal
543
+ * @param param 已有的输入参数实例
544
+ */
545
+ _addParam(param: Param): Param;
546
+
547
+ _addParam(options?: string | Partial<Param> | Param) {
548
+ const index = this.params.length;
549
+ return this._insertParamAt(options as any, index);
550
+ }
551
+
552
+ /**
553
+ * 添加输入参数
554
+ * @internal
555
+ * @param name 输入参数名称,如果不填会自动生成一个唯一名称
556
+ */
557
+ addParam(name?: string): Param;
558
+
559
+ /**
560
+ * 添加输入参数
561
+ * @param paramOptions 输入参数参数
562
+ */
563
+ addParam(paramOptions: Partial<Param>): Param;
564
+
565
+ /**
566
+ * 添加输入参数
567
+ * @param param 已有的输入参数实例
568
+ */
569
+ addParam(param: Param): Param;
570
+
571
+ addParam(options?: string | Partial<Param> | Param) {
572
+ const node = this._addParam(options as any);
573
+ const index = this.params.indexOf(node);
574
+ node.create({
575
+ index,
576
+ parentNode: this,
577
+ parentKey: 'params',
578
+ });
579
+ return node;
580
+ }
581
+
582
+ getReturnUniqueName(name = 'result') {
583
+ return utils.unique(name, this.getVarExistingNames(), undefined, false);
584
+ }
585
+
586
+ /**
587
+ * 插入输出参数
588
+ * @internal
589
+ * @param name 输出参数名称,如果不填会自动生成一个唯一名称
590
+ */
591
+ _insertReturnAt(name: string, index: number): Return;
592
+
593
+ /**
594
+ * 插入输出参数
595
+ * @internal
596
+ * @param retOptions 输出参数参数
597
+ */
598
+ _insertReturnAt(retOptions: Partial<Return>, index: number): Return;
599
+
600
+ /**
601
+ * 插入输出参数
602
+ * @internal
603
+ * @param ret 已有的输出参数实例
604
+ */
605
+ _insertReturnAt(ret: Return, index: number): Return;
606
+
607
+ _insertReturnAt(options: string | Partial<Return> | Return, index: number) {
608
+ const retOptions: any = {};
609
+ const relationOptions = { parentNode: this, parentKey: 'returns' };
610
+ let ret: Return;
611
+ if (!options) {
612
+ ret = Return.from(
613
+ {
614
+ ...retOptions,
615
+ name: this.getReturnUniqueName(),
616
+ },
617
+ this,
618
+ 'returns'
619
+ );
620
+ } else if (typeof options === 'string') {
621
+ ret = Return.from(
622
+ {
623
+ ...retOptions,
624
+ name: options,
625
+ },
626
+ this,
627
+ 'returns'
628
+ );
629
+ } else if (options instanceof Return) {
630
+ options.ensureDelete(); // 同一实例不支持多处存在
631
+ ret = options;
632
+ Object.assign(ret, relationOptions);
633
+ } else {
634
+ ret = Return.from(
635
+ {
636
+ ...retOptions,
637
+ ...options,
638
+ },
639
+ this,
640
+ 'returns'
641
+ );
642
+ }
643
+ this.returns.splice(index, 0, ret);
644
+ return ret;
645
+ }
646
+
647
+ /**
648
+ * 插入输出参数
649
+ * @param name 输出参数名称,如果不填会自动生成一个唯一名称
650
+ */
651
+ insertReturnAt(name: string, index: number): Return;
652
+
653
+ /**
654
+ * 插入输出参数
655
+ * @param retOptions 输出参数参数
656
+ */
657
+ insertReturnAt(retOptions: Partial<Return>, index: number): Return;
658
+
659
+ /**
660
+ * 插入输出参数
661
+ * @param ret 已有的输出参数实例
662
+ */
663
+ insertReturnAt(ret: Return, index: number): Return;
664
+
665
+ insertReturnAt(options: string | Partial<Return> | Return, index: number) {
666
+ const node = this._insertReturnAt(options as any, index);
667
+ node.create({
668
+ index,
669
+ parentNode: this,
670
+ parentKey: 'returns',
671
+ });
672
+ return node;
673
+ }
674
+
675
+ /**
676
+ * 添加输出参数
677
+ * @internal
678
+ * @param name 输出参数名称,如果不填会自动生成一个唯一名称
679
+ */
680
+ _addReturn(name?: string): Return;
681
+
682
+ /**
683
+ * 添加输出参数
684
+ * @internal
685
+ * @param retOptions 输出参数参数
686
+ */
687
+ _addReturn(retOptions: Partial<Return>): Return;
688
+
689
+ /**
690
+ * 添加输出参数
691
+ * @internal
692
+ * @param ret 已有的输出参数实例
693
+ */
694
+ _addReturn(ret: Return): Return;
695
+
696
+ _addReturn(options?: string | Partial<Return> | Return) {
697
+ const index = this.returns.length;
698
+ return this._insertReturnAt(options as any, index);
699
+ }
700
+
701
+ /**
702
+ * 添加输出参数
703
+ * @internal
704
+ * @param name 输出参数名称,如果不填会自动生成一个唯一名称
705
+ */
706
+ addReturn(name?: string): Return;
707
+
708
+ /**
709
+ * 添加输出参数
710
+ * @param retOptions 输出参数参数
711
+ */
712
+ addReturn(retOptions: Partial<Return>): Return;
713
+
714
+ /**
715
+ * 添加输出参数
716
+ * @param ret 已有的输出参数实例
717
+ */
718
+ addReturn(ret: Return): Return;
719
+
720
+ addReturn(options?: string | Partial<Return> | Return) {
721
+ const node = this._addReturn(options as any);
722
+ const index = this.returns.indexOf(node);
723
+ node.create({
724
+ index,
725
+ parentNode: this,
726
+ parentKey: 'returns',
727
+ });
728
+ return node;
729
+ }
730
+
731
+ getVariableUniqueName(name = 'variable1') {
732
+ return utils.unique(name, this.getVarExistingNames(), undefined, false);
733
+ }
734
+
735
+ /**
736
+ * 插入变量
737
+ * @internal
738
+ * @param name 变量名称,如果不填会自动生成一个唯一名称
739
+ */
740
+ _insertVariableAt(name: string, index: number): Variable;
741
+
742
+ /**
743
+ * 插入变量
744
+ * @internal
745
+ * @param variableOptions 变量参数
746
+ */
747
+ _insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
748
+
749
+ /**
750
+ * 插入变量
751
+ * @internal
752
+ * @param variable 已有的变量实例
753
+ */
754
+ _insertVariableAt(variable: Variable, index: number): Variable;
755
+
756
+ _insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
757
+ const variableOptions: any = {};
758
+ const relationOptions = { parentNode: this, parentKey: 'variables' };
759
+ let variable: Variable;
760
+ if (!options) {
761
+ variable = Variable.from(
762
+ {
763
+ ...variableOptions,
764
+ name: this.getVariableUniqueName(),
765
+ },
766
+ this,
767
+ 'variables'
768
+ );
769
+ } else if (typeof options === 'string') {
770
+ variable = Variable.from(
771
+ {
772
+ ...variableOptions,
773
+ name: options,
774
+ },
775
+ this,
776
+ 'variables'
777
+ );
778
+ } else if (options instanceof Variable) {
779
+ options.ensureDelete(); // 同一实例不支持多处存在
780
+ variable = options;
781
+ Object.assign(variable, relationOptions);
782
+ } else {
783
+ variable = Variable.from(
784
+ {
785
+ ...variableOptions,
786
+ ...options,
787
+ },
788
+ this,
789
+ 'variables'
790
+ );
791
+ }
792
+ this.variables.splice(index, 0, variable);
793
+ return variable;
794
+ }
795
+
796
+ /**
797
+ * 插入变量
798
+ * @param name 变量名称,如果不填会自动生成一个唯一名称
799
+ */
800
+ insertVariableAt(name: string, index: number): Variable;
801
+
802
+ /**
803
+ * 插入变量
804
+ * @param variableOptions 变量参数
805
+ */
806
+ insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
807
+
808
+ /**
809
+ * 插入变量
810
+ * @param variable 已有的变量实例
811
+ */
812
+ insertVariableAt(variable: Variable, index: number): Variable;
813
+
814
+ insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
815
+ const node = this._insertVariableAt(options as any, index);
816
+ node.create({
817
+ index,
818
+ parentNode: this,
819
+ parentKey: 'variables',
820
+ });
821
+ return node;
822
+ }
823
+
824
+ /**
825
+ * 添加变量
826
+ * @internal
827
+ * @param name 变量名称,如果不填会自动生成一个唯一名称
828
+ */
829
+ _addVariable(name?: string): Variable;
830
+
831
+ /**
832
+ * 添加变量
833
+ * @internal
834
+ * @param variableOptions 变量参数
835
+ */
836
+ _addVariable(variableOptions: Partial<Variable>): Variable;
837
+
838
+ /**
839
+ * 添加变量
840
+ * @internal
841
+ * @param variable 已有的变量实例
842
+ */
843
+ _addVariable(variable: Variable): Variable;
844
+
845
+ _addVariable(options?: string | Partial<Variable> | Variable) {
846
+ const index = this.variables.length;
847
+ return this._insertVariableAt(options as any, index);
848
+ }
849
+
850
+ /**
851
+ * 添加变量
852
+ * @internal
853
+ * @param name 变量名称,如果不填会自动生成一个唯一名称
854
+ */
855
+ addVariable(name?: string): Variable;
856
+
857
+ /**
858
+ * 添加变量
859
+ * @param variableOptions 变量参数
860
+ */
861
+ addVariable(variableOptions: Partial<Variable>): Variable;
862
+
863
+ /**
864
+ * 添加变量
865
+ * @param variable 已有的变量实例
866
+ */
867
+ addVariable(variable: Variable): Variable;
868
+
869
+ addVariable(options?: string | Partial<Variable> | Variable) {
870
+ const node = this._addVariable(options as any);
871
+ const index = this.variables.indexOf(node);
872
+ node.create({
873
+ index,
874
+ parentNode: this,
875
+ parentKey: 'variables',
876
+ });
877
+ return node;
878
+ }
879
+
880
+ /**
881
+ * 插入逻辑项
882
+ * @internal
883
+ * @param logicItemOptions 逻辑项参数
884
+ */
885
+ _insertItemInBodyAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
886
+
887
+ /**
888
+ * 插入逻辑项
889
+ * @internal
890
+ * @param logicItem 已有的逻辑项实例
891
+ */
892
+ _insertItemInBodyAt(logicItem: LogicItem, index: number): LogicItem;
893
+
894
+ _insertItemInBodyAt(options: Partial<LogicItem> | LogicItem, index: number) {
895
+ const logicItemOptions: any = {};
896
+ const relationOptions = { parentNode: this, parentKey: 'body' };
897
+ let logicItem: LogicItem;
898
+ if (options instanceof LogicItem) {
899
+ options.ensureDelete(); // 同一实例不支持多处存在
900
+ logicItem = options;
901
+ Object.assign(logicItem, relationOptions);
902
+ } else {
903
+ logicItem = LogicItem.from(
904
+ {
905
+ ...logicItemOptions,
906
+ ...options,
907
+ },
908
+ this,
909
+ 'body'
910
+ );
911
+ }
912
+ this.body.splice(index, 0, logicItem);
913
+ return logicItem;
914
+ }
915
+
916
+ /**
917
+ * 插入逻辑项
918
+ * @param logicItemOptions 逻辑项参数
919
+ */
920
+ insertItemInBodyAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
921
+
922
+ /**
923
+ * 插入逻辑项
924
+ * @param logicItem 已有的逻辑项实例
925
+ */
926
+ insertItemInBodyAt(logicItem: LogicItem, index: number): LogicItem;
927
+
928
+ insertItemInBodyAt(options: Partial<LogicItem> | LogicItem, index: number) {
929
+ const node = this._insertItemInBodyAt(options as any, index);
930
+ node.create({
931
+ index,
932
+ parentNode: this,
933
+ parentKey: 'body',
934
+ });
935
+ return node;
936
+ }
937
+
938
+ /**
939
+ * 添加逻辑项
940
+ * @internal
941
+ * @param logicItemOptions 逻辑项参数
942
+ */
943
+ _addItemInBody(logicItemOptions: Partial<LogicItem>): LogicItem;
944
+
945
+ /**
946
+ * 添加逻辑项
947
+ * @internal
948
+ * @param logicItem 已有的逻辑项实例
949
+ */
950
+ _addItemInBody(logicItem: LogicItem): LogicItem;
951
+
952
+ _addItemInBody(options?: Partial<LogicItem> | LogicItem) {
953
+ const index = this.body.length;
954
+ return this._insertItemInBodyAt(options as any, index);
955
+ }
956
+
957
+ /**
958
+ * 添加逻辑项
959
+ * @param logicItemOptions 逻辑项参数
960
+ */
961
+ addItemInBody(logicItemOptions: Partial<LogicItem>): LogicItem;
962
+
963
+ /**
964
+ * 添加逻辑项
965
+ * @param logicItem 已有的逻辑项实例
966
+ */
967
+ addItemInBody(logicItem: LogicItem): LogicItem;
968
+
969
+ addItemInBody(options?: Partial<LogicItem> | LogicItem) {
970
+ const node = this._addItemInBody(options as any);
971
+ const index = this.body.indexOf(node);
972
+ node.create({
973
+ index,
974
+ parentNode: this,
975
+ parentKey: 'body',
976
+ });
977
+ return node;
978
+ }
979
+
980
+ /**
981
+ * 插入逻辑项
982
+ * @internal
983
+ * @param logicItemOptions 逻辑项参数
984
+ */
985
+ _insertItemInPlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
986
+
987
+ /**
988
+ * 插入逻辑项
989
+ * @internal
990
+ * @param logicItem 已有的逻辑项实例
991
+ */
992
+ _insertItemInPlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
993
+
994
+ _insertItemInPlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
995
+ const logicItemOptions: any = {};
996
+ const relationOptions = { parentNode: this, parentKey: 'playground' };
997
+ let logicItem: LogicItem;
998
+ if (options instanceof LogicItem) {
999
+ options.ensureDelete(); // 同一实例不支持多处存在
1000
+ logicItem = options;
1001
+ Object.assign(logicItem, relationOptions);
1002
+ } else {
1003
+ logicItem = LogicItem.from(
1004
+ {
1005
+ ...logicItemOptions,
1006
+ ...options,
1007
+ },
1008
+ this,
1009
+ 'playground'
1010
+ );
1011
+ }
1012
+ this.playground.splice(index, 0, logicItem);
1013
+ return logicItem;
1014
+ }
1015
+
1016
+ /**
1017
+ * 插入逻辑项
1018
+ * @param logicItemOptions 逻辑项参数
1019
+ */
1020
+ insertItemInPlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
1021
+
1022
+ /**
1023
+ * 插入逻辑项
1024
+ * @param logicItem 已有的逻辑项实例
1025
+ */
1026
+ insertItemInPlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
1027
+
1028
+ insertItemInPlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
1029
+ const node = this._insertItemInPlaygroundAt(options as any, index);
1030
+ node.create({
1031
+ index,
1032
+ parentNode: this,
1033
+ parentKey: 'playground',
1034
+ });
1035
+ return node;
1036
+ }
1037
+
1038
+ /**
1039
+ * 添加逻辑项
1040
+ * @internal
1041
+ * @param logicItemOptions 逻辑项参数
1042
+ */
1043
+ _addItemInPlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
1044
+
1045
+ /**
1046
+ * 添加逻辑项
1047
+ * @internal
1048
+ * @param logicItem 已有的逻辑项实例
1049
+ */
1050
+ _addItemInPlayground(logicItem: LogicItem): LogicItem;
1051
+
1052
+ _addItemInPlayground(options?: Partial<LogicItem> | LogicItem) {
1053
+ const index = this.playground.length;
1054
+ return this._insertItemInPlaygroundAt(options as any, index);
1055
+ }
1056
+
1057
+ /**
1058
+ * 添加逻辑项
1059
+ * @param logicItemOptions 逻辑项参数
1060
+ */
1061
+ addItemInPlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
1062
+
1063
+ /**
1064
+ * 添加逻辑项
1065
+ * @param logicItem 已有的逻辑项实例
1066
+ */
1067
+ addItemInPlayground(logicItem: LogicItem): LogicItem;
1068
+
1069
+ addItemInPlayground(options?: Partial<LogicItem> | LogicItem) {
1070
+ const node = this._addItemInPlayground(options as any);
1071
+ const index = this.playground.indexOf(node);
1072
+ node.create({
1073
+ index,
1074
+ parentNode: this,
1075
+ parentKey: 'playground',
1076
+ });
1077
+ return node;
1078
+ }
1079
+
1080
+ /**
1081
+ * 删除事务
1082
+ * @param name 事务名称
1083
+ */
1084
+ removeTransactional(name: string): void;
1085
+
1086
+ /**
1087
+ * 删除事务
1088
+ * @param transactional 已有的事务实例
1089
+ */
1090
+ removeTransactional(transactional: Transactional): void;
1091
+
1092
+ removeTransactional(options: string | Transactional) {
1093
+ let transactional: Transactional;
1094
+ if (typeof options === 'string') {
1095
+ transactional = this.transactional;
1096
+ if (!transactional) {
1097
+ throw new Error(`找不到事务 ${options}`);
1098
+ }
1099
+ } else {
1100
+ transactional = options;
1101
+ }
1102
+ return transactional.delete();
1103
+ }
1104
+
1105
+ __removeTransactional(transactional: Transactional) {
1106
+ const { parentKey } = transactional;
1107
+ const params: Params = {
1108
+ parentNode: this,
1109
+ parentKey,
1110
+ index: -1,
1111
+ object: null,
1112
+ oldObject: transactional,
1113
+ };
1114
+ if (parentKey) {
1115
+ params.parentKey = parentKey;
1116
+ if (Array.isArray((this as any)[parentKey])) {
1117
+ const index = (this as any)[parentKey].indexOf(transactional);
1118
+ ~index && (this as any)[parentKey].splice(index, 1);
1119
+ params.index = index;
1120
+ } else if ((this as any)[parentKey] === transactional) {
1121
+ params.index = 0;
1122
+ (this as any)[parentKey] = undefined;
1123
+ }
1124
+ }
1125
+ return params;
1126
+ }
1127
+
1128
+ /**
1129
+ * 删除类型参数
1130
+ * @param name 类型参数名称
1131
+ */
1132
+ removeTypeParam(name: string): void;
1133
+
1134
+ /**
1135
+ * 删除类型参数
1136
+ * @param typeParam 已有的类型参数实例
1137
+ */
1138
+ removeTypeParam(typeParam: TypeParam): void;
1139
+
1140
+ removeTypeParam(options: string | TypeParam) {
1141
+ let typeParam: TypeParam;
1142
+ if (typeof options === 'string') {
1143
+ typeParam = (this.typeParams as TypeParam[]).find((item) => item.name === options);
1144
+ if (!typeParam) {
1145
+ throw new Error(`找不到类型参数 ${options}`);
1146
+ }
1147
+ } else {
1148
+ typeParam = options;
1149
+ }
1150
+ return typeParam.delete();
1151
+ }
1152
+
1153
+ __removeTypeParam(typeParam: TypeParam) {
1154
+ const { parentKey } = typeParam;
1155
+ const params: Params = {
1156
+ parentNode: this,
1157
+ parentKey,
1158
+ index: -1,
1159
+ object: null,
1160
+ oldObject: typeParam,
1161
+ };
1162
+ if (parentKey) {
1163
+ params.parentKey = parentKey;
1164
+ if (Array.isArray((this as any)[parentKey])) {
1165
+ const index = (this as any)[parentKey].indexOf(typeParam);
1166
+ ~index && (this as any)[parentKey].splice(index, 1);
1167
+ params.index = index;
1168
+ } else if ((this as any)[parentKey] === typeParam) {
1169
+ params.index = 0;
1170
+ (this as any)[parentKey] = undefined;
1171
+ }
1172
+ }
1173
+ return params;
1174
+ }
1175
+
1176
+ /**
1177
+ * 删除输入参数
1178
+ * @param name 输入参数名称
1179
+ */
1180
+ removeParam(name: string): void;
1181
+
1182
+ /**
1183
+ * 删除输入参数
1184
+ * @param param 已有的输入参数实例
1185
+ */
1186
+ removeParam(param: Param): void;
1187
+
1188
+ removeParam(options: string | Param) {
1189
+ let param: Param;
1190
+ if (typeof options === 'string') {
1191
+ param = (this.params as Param[]).find((item) => item.name === options);
1192
+ if (!param) {
1193
+ throw new Error(`找不到输入参数 ${options}`);
1194
+ }
1195
+ } else {
1196
+ param = options;
1197
+ }
1198
+ return param.delete();
1199
+ }
1200
+
1201
+ __removeParam(param: Param) {
1202
+ const { parentKey } = param;
1203
+ const params: Params = {
1204
+ parentNode: this,
1205
+ parentKey,
1206
+ index: -1,
1207
+ object: null,
1208
+ oldObject: param,
1209
+ };
1210
+ if (parentKey) {
1211
+ params.parentKey = parentKey;
1212
+ if (Array.isArray((this as any)[parentKey])) {
1213
+ const index = (this as any)[parentKey].indexOf(param);
1214
+ ~index && (this as any)[parentKey].splice(index, 1);
1215
+ params.index = index;
1216
+ } else if ((this as any)[parentKey] === param) {
1217
+ params.index = 0;
1218
+ (this as any)[parentKey] = undefined;
1219
+ }
1220
+ }
1221
+ return params;
1222
+ }
1223
+
1224
+ /**
1225
+ * 删除输出参数
1226
+ * @param name 输出参数名称
1227
+ */
1228
+ removeReturn(name: string): void;
1229
+
1230
+ /**
1231
+ * 删除输出参数
1232
+ * @param ret 已有的输出参数实例
1233
+ */
1234
+ removeReturn(ret: Return): void;
1235
+
1236
+ removeReturn(options: string | Return) {
1237
+ let ret: Return;
1238
+ if (typeof options === 'string') {
1239
+ ret = (this.returns as Return[]).find((item) => item.name === options);
1240
+ if (!ret) {
1241
+ throw new Error(`找不到输出参数 ${options}`);
1242
+ }
1243
+ } else {
1244
+ ret = options;
1245
+ }
1246
+ return ret.delete();
1247
+ }
1248
+
1249
+ __removeReturn(ret: Return) {
1250
+ const { parentKey } = ret;
1251
+ const params: Params = {
1252
+ parentNode: this,
1253
+ parentKey,
1254
+ index: -1,
1255
+ object: null,
1256
+ oldObject: ret,
1257
+ };
1258
+ if (parentKey) {
1259
+ params.parentKey = parentKey;
1260
+ if (Array.isArray((this as any)[parentKey])) {
1261
+ const index = (this as any)[parentKey].indexOf(ret);
1262
+ ~index && (this as any)[parentKey].splice(index, 1);
1263
+ params.index = index;
1264
+ } else if ((this as any)[parentKey] === ret) {
1265
+ params.index = 0;
1266
+ (this as any)[parentKey] = undefined;
1267
+ }
1268
+ }
1269
+ return params;
1270
+ }
1271
+
1272
+ /**
1273
+ * 删除变量
1274
+ * @param name 变量名称
1275
+ */
1276
+ removeVariable(name: string): void;
1277
+
1278
+ /**
1279
+ * 删除变量
1280
+ * @param variable 已有的变量实例
1281
+ */
1282
+ removeVariable(variable: Variable): void;
1283
+
1284
+ removeVariable(options: string | Variable) {
1285
+ let variable: Variable;
1286
+ if (typeof options === 'string') {
1287
+ variable = (this.variables as Variable[]).find((item) => item.name === options);
1288
+ if (!variable) {
1289
+ throw new Error(`找不到变量 ${options}`);
1290
+ }
1291
+ } else {
1292
+ variable = options;
1293
+ }
1294
+ return variable.delete();
1295
+ }
1296
+
1297
+ __removeVariable(variable: Variable) {
1298
+ const { parentKey } = variable;
1299
+ const params: Params = {
1300
+ parentNode: this,
1301
+ parentKey,
1302
+ index: -1,
1303
+ object: null,
1304
+ oldObject: variable,
1305
+ };
1306
+ if (parentKey) {
1307
+ params.parentKey = parentKey;
1308
+ if (Array.isArray((this as any)[parentKey])) {
1309
+ const index = (this as any)[parentKey].indexOf(variable);
1310
+ ~index && (this as any)[parentKey].splice(index, 1);
1311
+ params.index = index;
1312
+ } else if ((this as any)[parentKey] === variable) {
1313
+ params.index = 0;
1314
+ (this as any)[parentKey] = undefined;
1315
+ }
1316
+ }
1317
+ return params;
1318
+ }
1319
+
1320
+ /**
1321
+ * 删除逻辑项
1322
+ * @param logicItem 已有的逻辑项实例
1323
+ */
1324
+ removeItemInBody(logicItem: LogicItem): void;
1325
+
1326
+ removeItemInBody(options: LogicItem) {
1327
+ const logicItem: LogicItem = options;
1328
+ return logicItem.delete();
1329
+ }
1330
+
1331
+ /**
1332
+ * 删除逻辑项
1333
+ * @param logicItem 已有的逻辑项实例
1334
+ */
1335
+ removeItemInPlayground(logicItem: LogicItem): void;
1336
+
1337
+ removeItemInPlayground(options: LogicItem) {
1338
+ const logicItem: LogicItem = options;
1339
+ return logicItem.delete();
1340
+ }
1341
+
1342
+ __removeLogicItem(logicItem: LogicItem) {
1343
+ const { parentKey } = logicItem;
1344
+ const params: Params = {
1345
+ parentNode: this,
1346
+ parentKey,
1347
+ index: -1,
1348
+ object: null,
1349
+ oldObject: logicItem,
1350
+ };
1351
+ if (parentKey) {
1352
+ params.parentKey = parentKey;
1353
+ if (Array.isArray((this as any)[parentKey])) {
1354
+ const index = (this as any)[parentKey].indexOf(logicItem);
1355
+ ~index && (this as any)[parentKey].splice(index, 1);
1356
+ params.index = index;
1357
+ } else if ((this as any)[parentKey] === logicItem) {
1358
+ params.index = 0;
1359
+ (this as any)[parentKey] = undefined;
1360
+ }
1361
+ }
1362
+ return params;
1363
+ }
1364
+
1365
+ //= ===============================================================================
1366
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1367
+ // 自动生成的代码已结束。下面可以手动编写。
1368
+ //= ===============================================================================
1369
+ // 用于calllogic树中定位是那个logic,回显
1370
+ get calleewholeKey() {
1371
+ return `${this.getNamespace()}.${this.name}`;
1372
+ }
1373
+
1374
+ // 设置定时任务
1375
+ setCronAndTriggerType(cron: string, triggerType: string) {
1376
+ const object = {
1377
+ cron,
1378
+ triggerType,
1379
+ };
1380
+ this.update({
1381
+ ...object,
1382
+ });
1383
+ }
1384
+
1385
+ /**
1386
+ * 创建的时候 打开事务 通过开关设置数据库事务
1387
+ */
1388
+ openTransactional(flag: boolean) {
1389
+ if (flag) {
1390
+ const transactional = new Transactional({
1391
+ enabled: flag,
1392
+ });
1393
+ transactional._delete();
1394
+ const relationOptions = { parentNode: this, parentKey: 'transactional' };
1395
+ Object.assign(transactional, relationOptions);
1396
+ this.transactional = transactional;
1397
+ }
1398
+ }
1399
+
1400
+ findLogicItemByConcept(concept: string) {
1401
+ let result: any;
1402
+
1403
+ utils.traverse(
1404
+ (current) => {
1405
+ if ((current.node as any).concept === concept) return (result = current.node);
1406
+ },
1407
+ { node: this },
1408
+ {
1409
+ mode: 'anyObject',
1410
+ excludedKeySet: this.JSON_EXCLUDED_KEYS,
1411
+ }
1412
+ );
1413
+
1414
+ return result as LogicItem;
1415
+ }
1416
+
1417
+ onChange($event?: EventPayload): void {
1418
+ this.emit('change', $event);
1419
+ }
1420
+
1421
+ getVarExistingNames(excludedList: Array<Param | Return | Variable> = []) {
1422
+ const excludedSet = new Set(excludedList);
1423
+ const varList: any[] = [];
1424
+ if (Array.isArray(this.params)) {
1425
+ varList.push(...this.params);
1426
+ }
1427
+ if (Array.isArray(this.returns)) {
1428
+ varList.push(...this.returns);
1429
+ }
1430
+ if (Array.isArray(this.variables)) {
1431
+ varList.push(...this.variables);
1432
+ }
1433
+ if (this.view) {
1434
+ if (Array.isArray(this.view.params)) {
1435
+ varList.push(...this.view.params);
1436
+ }
1437
+ if (Array.isArray(this.view.variables)) {
1438
+ varList.push(...this.view.variables);
1439
+ }
1440
+ }
1441
+
1442
+ this.traverseChildren((el) => {
1443
+ if (el?.concept === 'ForEachStatement') {
1444
+ if ((el as ForEachStatement)?.item) {
1445
+ varList.push((el as ForEachStatement)?.item);
1393
1446
  }
1394
- if (Array.isArray(this.returns)) {
1395
- varList.push(...this.returns);
1447
+ if ((el as ForEachStatement)?.index) {
1448
+ varList.push((el as ForEachStatement)?.index);
1396
1449
  }
1397
- if (Array.isArray(this.variables)) {
1398
- varList.push(...this.variables);
1450
+ }
1451
+ });
1452
+ return varList.filter((item) => !excludedSet.has(item)).map((item) => item?.name);
1453
+ }
1454
+
1455
+ toJSContent(code: string, state?: TranslatorState): string {
1456
+ // params
1457
+ if (Array.isArray(this.params)) {
1458
+ this.params.forEach((param) => {
1459
+ code += `${indent((state?.tabSize || 0) + 1)}`;
1460
+ code += param.toJS(shiftState(state, code, { inline: true }));
1461
+ code += ';\n';
1462
+ });
1463
+ }
1464
+ // variables
1465
+ if (Array.isArray(this.variables)) {
1466
+ this.variables.forEach((variable) => {
1467
+ code += `${indent((state?.tabSize || 0) + 1)}let `;
1468
+ code += variable.toJS(shiftState(state, code, { inline: true }));
1469
+ code += ';\n';
1470
+ });
1471
+ }
1472
+
1473
+ // returns
1474
+ if (Array.isArray(this.returns)) {
1475
+ this.returns.forEach((ret) => {
1476
+ code += `${indent((state?.tabSize || 0) + 1)}let `;
1477
+ code += ret.toJS(shiftState(state, code, { inline: true }));
1478
+ code += ';\n';
1479
+ });
1480
+ }
1481
+ if (Array.isArray(this.body)) {
1482
+ this.body.forEach((item) => {
1483
+ code += item.toJS && item.toJS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1484
+ code += '\n';
1485
+ });
1486
+ }
1487
+
1488
+ return code;
1489
+ }
1490
+
1491
+ toJS(state?: TranslatorState, type?: string): string {
1492
+ let code = '';
1493
+ if (type === 'IIFE') {
1494
+ code += `await (async () => {\n`;
1495
+ code = this.toJSContent(code, state);
1496
+ code += `${indent(state?.tabSize || 0)}})();\n`;
1497
+ return code;
1498
+ }
1499
+ code += `async ${this.name} (`;
1500
+
1501
+ if (this.params?.length) {
1502
+ this.params.forEach((param, index) => {
1503
+ code += param.name;
1504
+ if (index !== this.params.length - 1) code += ', ';
1505
+ });
1506
+ }
1507
+ code += ') {\n';
1508
+
1509
+ code = this.toJSContent(code, state);
1510
+ code += `${indent(state?.tabSize || 0)}}\n`;
1511
+ return code;
1512
+ }
1513
+
1514
+ toProcessService() {
1515
+ return {
1516
+ config: {
1517
+ serviceType: 'micro',
1518
+ },
1519
+ url: {
1520
+ method: 'POST',
1521
+ path: this.getPath(),
1522
+ },
1523
+ };
1524
+ }
1525
+
1526
+ toService() {
1527
+ const { parentNode } = this;
1528
+ const { concept, name: entityName } = parentNode || {};
1529
+ const logicName = this.name;
1530
+ let serviceType = 'micro';
1531
+ let method = 'POST';
1532
+ // let path = `/api/${logicName}`;
1533
+ const map: Record<string, string> = {
1534
+ GetUser: 'LCAPAuth',
1535
+ Logout: 'LCAPAuth',
1536
+ CheckPermission: 'LCAPPermission',
1537
+ GetUserResources: 'LCAPPermission',
1538
+ UploadPermission: 'LCAPPermission',
1539
+ GetUserList: 'LCAPUserManage',
1540
+ GetRoleList: 'LCAPUserManage',
1541
+ };
1542
+ let path = `/api/${map[logicName]}/overridden/${logicName}`;
1543
+ if (concept === 'Module') {
1544
+ path = `/api/${entityName.replace('-', '_')}/${logicName}`;
1545
+ } else if (concept === 'Namespace') {
1546
+ serviceType = 'entity';
1547
+ let entityPath = entityName.replace(/[A-Z]/g, (char, index) => {
1548
+ const lowerChar = char.toLowerCase();
1549
+ return index === 0 ? lowerChar : `-${lowerChar}`;
1550
+ });
1551
+ const dataSource = parentNode.getAncestor('DataSource');
1552
+ // 默认数据源不动,其他数据源需要拼接数据源信息
1553
+ if (dataSource && dataSource.name !== 'defaultDS') {
1554
+ entityPath = `${dataSource.name}/${entityPath}`;
1555
+ }
1556
+ path = `/api/${entityPath}`;
1557
+ switch (this.name) {
1558
+ case 'get':
1559
+ method = 'GET';
1560
+ path = `/api/${entityPath}`;
1561
+ break;
1562
+ case 'create':
1563
+ method = 'POST';
1564
+ break;
1565
+ case 'update':
1566
+ method = 'PUT';
1567
+ break;
1568
+ case 'delete':
1569
+ method = 'DELETE';
1570
+ path = `/api/${entityPath}`;
1571
+ break;
1572
+ case 'createOrUpdate':
1573
+ method = 'POST';
1574
+ path = `/api/${entityPath}/createOrUpdate`;
1575
+ break;
1576
+ case 'updateBy':
1577
+ method = 'PUT';
1578
+ path = `/api/${entityPath}/by`;
1579
+ break;
1580
+ case 'deleteBy':
1581
+ method = 'DELETE';
1582
+ path = `/api/${entityPath}/by`;
1583
+ break;
1584
+ case 'batchCreate':
1585
+ method = 'POST';
1586
+ path = `/api/${entityPath}/batch`;
1587
+ break;
1588
+ case 'batchUpdate':
1589
+ method = 'PUT';
1590
+ path = `/api/${entityPath}/batch`;
1591
+ break;
1592
+ case 'batchDelete':
1593
+ method = 'DELETE';
1594
+ path = `/api/${entityPath}/batch`;
1595
+ break;
1596
+ case 'import':
1597
+ method = 'POST';
1598
+ path = `/api/${entityPath}/import`;
1599
+ break;
1600
+ default:
1601
+ break;
1602
+ }
1603
+ }
1604
+
1605
+ return {
1606
+ config: {
1607
+ serviceType,
1608
+ },
1609
+ url: {
1610
+ method,
1611
+ path,
1612
+ },
1613
+ };
1614
+ }
1615
+
1616
+ @withSourceMap()
1617
+ toEmbeddedTSInProcess(state?: TranslatorState, prependCode?: string, noName?: boolean, prefix?: boolean): string {
1618
+ let code = '';
1619
+ if (!prefix) code += `${noName ? '' : `${this.name}:`} function(`;
1620
+ else code += `function ${this.name}(`; // 加空格会导致无法查询到引用
1621
+ this.params.forEach((param, index) => {
1622
+ code += param.toEmbeddedTS(shiftState(state, code, { inline: true }));
1623
+ if (index !== this.params.length - 1) code += ', ';
1624
+ });
1625
+ code += `) {\n`;
1626
+ code += prependCode || '';
1627
+ code += '\n';
1628
+ this.variables.forEach((variable) => {
1629
+ code += `${indent((state?.tabSize || 0) + 1)}let `;
1630
+ code += variable.toEmbeddedTS(shiftState(state, code, { inline: true }));
1631
+ code += ';\n';
1632
+ });
1633
+
1634
+ this.returns.forEach((ret) => {
1635
+ code += `${indent((state?.tabSize || 0) + 1)}let `;
1636
+ code += ret.toEmbeddedTS(shiftState(state, code, { inline: true }));
1637
+ code += ';\n';
1638
+ });
1639
+
1640
+ if (!this.body.length && this.returns.length) {
1641
+ code += `${indent((state?.tabSize || 0) + 1)}return ${this.returns[0].name};\n`;
1642
+ } else {
1643
+ if ((this.parentNode as any).type === 'ExclusiveGateway') {
1644
+ if (this.body.length <= 1) {
1645
+ code += indent((state?.tabSize || 0) + 1);
1646
+ code += 'const __LogicEmpty: any = null;';
1399
1647
  }
1400
- if (this.view) {
1401
- if (Array.isArray(this.view.params)) {
1402
- varList.push(...this.view.params);
1648
+ } else if (this.body.length <= 2 && !(this.parentNode instanceof Namespace) && !(this.parentNode instanceof Process)) {
1649
+ code += indent((state?.tabSize || 0) + 1);
1650
+ code += `${indent(state?.tabSize || 0 + 4)}const __LogicEmpty: any = null;`;
1651
+ }
1652
+ this.body.forEach((item) => {
1653
+ code += item.toEmbeddedTS && item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1654
+ code += ';\n';
1655
+ });
1656
+ }
1657
+
1658
+ // 在body渲染完成之后把其余的节点放到下面
1659
+ this.playground.forEach((item) => {
1660
+ code += item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1661
+ code += '\n';
1662
+ });
1663
+
1664
+ code += `${indent(state?.tabSize || 0 + 4)}}`;
1665
+ code += '\n';
1666
+ return code;
1667
+ }
1668
+
1669
+ toEmbeddedTSNoExport(state?: TranslatorState): string {
1670
+ return this.toEmbeddedTS(state, 'noExport');
1671
+ }
1672
+
1673
+ @withSourceMap()
1674
+ toEmbeddedTS(state?: TranslatorState, prefix?: string): string {
1675
+ // 如果传了不要前缀那就为空, 要不用传进来的,要是都没有就默认导出
1676
+ let code = '';
1677
+ if (!prefix) {
1678
+ code += `export function ${this.name}`;
1679
+ } else if (prefix === 'noExport') {
1680
+ code += `function ${this.name}`;
1681
+ } else if (prefix === 'inObject') {
1682
+ code += `${this.name}`;
1683
+ }
1684
+ if (this.typeParams?.length) {
1685
+ code += '<';
1686
+ this.typeParams.forEach((typeParam, typeParamIndex) => {
1687
+ code += typeParam.toEmbeddedTS(shiftState(state, code, { inline: true }));
1688
+ if (typeParamIndex !== this.typeParams.length - 1) code += ', ';
1689
+ });
1690
+ code += '>';
1691
+ }
1692
+ // 有参数长度
1693
+ if (this.params.length) {
1694
+ code += '(';
1695
+ this.params.forEach((param, index) => {
1696
+ code += param.toEmbeddedTS(shiftState(state, code));
1697
+ if (index !== this.params.length - 1) code += ', ';
1698
+ });
1699
+ code += ')';
1700
+ } else {
1701
+ // 没有参数的
1702
+ code += '()';
1703
+ }
1704
+
1705
+ // 需要类型推导的局部变量/返回值需要调整申明顺序
1706
+ const advanceMap: Map<Return | Variable, Assignment | BatchAssignment> = new Map();
1707
+ const needGetSourceMapOqlList: Promise<any>[] = [];
1708
+ this.traverseChildren((el) => {
1709
+ if (el && (el instanceof BatchAssignment || (el instanceof Assignment && el.left?.name))) {
1710
+ if (el instanceof Assignment) {
1711
+ const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && el.left?.name === variable.name);
1712
+ if (advanceVar && !advanceMap.get(advanceVar)) {
1713
+ advanceMap.set(advanceVar, el);
1714
+ }
1715
+ const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && el.left?.name === ret.name);
1716
+ if (advanceRn && !advanceMap.get(advanceRn)) {
1717
+ advanceMap.set(advanceRn, el);
1718
+ }
1719
+ } else if (el instanceof BatchAssignment) {
1720
+ el.assignmentLines.forEach(({ leftIndex }) => {
1721
+ const leftCode =
1722
+ leftIndex.length === 1
1723
+ ? el.left.expression.toEmbeddedTS(shiftState(state, code, { inline: true }))
1724
+ : el.left.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true }));
1725
+ const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && leftCode === variable.name);
1726
+ if (advanceVar && !advanceMap.get(advanceVar)) {
1727
+ advanceMap.set(advanceVar, el);
1403
1728
  }
1404
- if (Array.isArray(this.view.variables)) {
1405
- varList.push(...this.view.variables);
1729
+ const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && leftCode === ret.name);
1730
+ if (advanceRn && !advanceMap.get(advanceRn)) {
1731
+ advanceMap.set(advanceRn, el);
1406
1732
  }
1733
+ });
1407
1734
  }
1408
-
1409
- this.traverseChildren((el) => {
1410
- if (el?.concept === 'ForEachStatement') {
1411
- if ((el as ForEachStatement)?.item) {
1412
- varList.push((el as ForEachStatement)?.item);
1413
- }
1414
- if ((el as ForEachStatement)?.index) {
1415
- varList.push((el as ForEachStatement)?.index);
1416
- }
1417
- }
1418
- });
1419
- return varList.filter((item) => !excludedSet.has(item)).map((item) => item?.name);
1420
- }
1421
-
1422
- toJSContent(code: string, state?: TranslatorState): string {
1423
- // params
1424
- if (Array.isArray(this.params)) {
1425
- this.params.forEach((param) => {
1426
- code += indent((state?.tabSize || 0) + 1) + '';
1427
- code += param.toJS(shiftState(state, code, { inline: true }));
1428
- code += ';\n';
1429
- });
1430
- }
1431
- // variables
1432
- if (Array.isArray(this.variables)) {
1433
- this.variables.forEach((variable) => {
1434
- code += indent((state?.tabSize || 0) + 1) + 'let ';
1435
- code += variable.toJS(shiftState(state, code, { inline: true }));
1436
- code += ';\n';
1437
- });
1438
- }
1439
-
1440
- // returns
1441
- if (Array.isArray(this.returns)) {
1442
- this.returns.forEach((ret) => {
1443
- code += indent((state?.tabSize || 0) + 1) + 'let ';
1444
- code += ret.toJS(shiftState(state, code, { inline: true }));
1445
- code += ';\n';
1446
- });
1447
- }
1448
- if (Array.isArray(this.body)) {
1449
- this.body.forEach((item) => {
1450
- code += item.toJS && item.toJS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1451
- code += '\n';
1452
- });
1453
- }
1454
-
1455
- return code;
1456
- }
1457
- toJS(state?: TranslatorState, type?: string): string {
1458
- let code = '';
1459
- if (type === 'IIFE') {
1460
- code += `await (async () => {\n`;
1461
- code = this.toJSContent(code, state);
1462
- code += indent(state?.tabSize || 0) + '})();\n';
1463
- return code;
1464
- }
1465
- code += `async ${this.name} (`;
1466
-
1467
- if (this.params?.length) {
1468
- this.params.forEach((param, index) => {
1469
- code += param.name;
1470
- if (index !== this.params.length - 1)
1471
- code += ', ';
1472
- });
1473
- }
1474
- code += ') {\n';
1475
-
1476
- code = this.toJSContent(code, state);
1477
- code += indent(state?.tabSize || 0) + '}\n';
1478
- return code;
1479
- }
1480
-
1481
- toProcessService() {
1482
- return {
1483
- config: {
1484
- serviceType: 'micro',
1485
- },
1486
- url: {
1487
- method: 'POST',
1488
- path: this.getPath(),
1489
- },
1490
- };
1491
- }
1492
-
1493
- toService() {
1494
- const parentNode = this.parentNode;
1495
- const { concept, name: entityName } = parentNode || {};
1496
- const logicName = this.name;
1497
- let serviceType = 'micro';
1498
- let method = 'POST';
1499
- // let path = `/api/${logicName}`;
1500
- const map: Record<string, string> = {
1501
- GetUser: 'LCAPAuth',
1502
- Logout: 'LCAPAuth',
1503
- CheckPermission: 'LCAPPermission',
1504
- GetUserResources: 'LCAPPermission',
1505
- UploadPermission: 'LCAPPermission',
1506
- GetUserList: 'LCAPUserManage',
1507
- GetRoleList: 'LCAPUserManage',
1508
- };
1509
- let path = `/api/${map[logicName]}/overridden/${logicName}`;
1510
- if (concept === 'Module') {
1511
- path = `/api/${entityName.replace('-', '_')}/${logicName}`;
1512
- } else if (concept === 'Namespace') {
1513
- serviceType = 'entity';
1514
- let entityPath = entityName.replace(/[A-Z]/g, (char, index) => {
1515
- const lowerChar = char.toLowerCase();
1516
- return index === 0 ? lowerChar : `-${lowerChar}`;
1517
- });
1518
- const dataSource = parentNode.getAncestor('DataSource');
1519
- // 默认数据源不动,其他数据源需要拼接数据源信息
1520
- if (dataSource && dataSource.name !== 'defaultDS') {
1521
- entityPath = dataSource.name + '/' + entityPath;
1522
- }
1523
- path = `/api/${entityPath}`;
1524
- switch (this.name) {
1525
- case 'get':
1526
- method = 'GET';
1527
- path = `/api/${entityPath}`;
1528
- break;
1529
- case 'create':
1530
- method = 'POST';
1531
- break;
1532
- case 'update':
1533
- method = 'PUT';
1534
- break;
1535
- case 'delete':
1536
- method = 'DELETE';
1537
- path = `/api/${entityPath}`;
1538
- break;
1539
- case 'createOrUpdate':
1540
- method = 'POST';
1541
- path = `/api/${entityPath}/createOrUpdate`;
1542
- break;
1543
- case 'updateBy':
1544
- method = 'PUT';
1545
- path = `/api/${entityPath}/by`;
1546
- break;
1547
- case 'deleteBy':
1548
- method = 'DELETE';
1549
- path = `/api/${entityPath}/by`;
1550
- break;
1551
- case 'batchCreate':
1552
- method = 'POST';
1553
- path = `/api/${entityPath}/batch`;
1554
- break;
1555
- case 'batchUpdate':
1556
- method = 'PUT';
1557
- path = `/api/${entityPath}/batch`;
1558
- break;
1559
- case 'batchDelete':
1560
- method = 'DELETE';
1561
- path = `/api/${entityPath}/batch`;
1562
- break;
1563
- case 'import':
1564
- method = 'POST';
1565
- path = `/api/${entityPath}/import`;
1566
- break;
1567
- default:
1568
- break;
1569
- }
1735
+ }
1736
+ // 如果有sql查询组件就需要把他们存起来
1737
+ if (el instanceof OqlQueryComponent) {
1738
+ if (!el.codeSourceMap) {
1739
+ needGetSourceMapOqlList.push(el.requestEmbeddedTS());
1570
1740
  }
1571
-
1572
- return {
1573
- config: {
1574
- serviceType,
1575
- },
1576
- url: {
1577
- method,
1578
- path,
1741
+ }
1742
+ });
1743
+
1744
+ if (needGetSourceMapOqlList.length) {
1745
+ Promise.all(needGetSourceMapOqlList).then(() => {
1746
+ // 触发一下更新重新生成代码
1747
+ (this.app as any)?.naslServer?.embeddedTSEmitter.emit('change', {
1748
+ value: [
1749
+ {
1750
+ originEvent: {
1751
+ action: 'update',
1752
+ target: this,
1753
+ },
1579
1754
  },
1580
- };
1581
- }
1582
-
1583
- @withSourceMap()
1584
- toEmbeddedTSInProcess(state?: TranslatorState, prependCode?: string, noName?: boolean, prefix?: boolean): string {
1585
- let code = '';
1586
- if (!prefix)
1587
- code += `${noName ? '' : `${this.name}:`} function(`;
1588
- else
1589
- code += `function ${this.name}(`; //加空格会导致无法查询到引用
1590
- this.params.forEach((param, index) => {
1591
- code += param.toEmbeddedTS(shiftState(state, code, { inline: true }));
1592
- if (index !== this.params.length - 1)
1593
- code += ', ';
1755
+ ],
1594
1756
  });
1595
- code += `) {\n`;
1596
- code += prependCode || '';
1597
- code += '\n';
1598
- this.variables.forEach((variable) => {
1599
- code += indent((state?.tabSize || 0) + 1) + 'let ';
1600
- code += variable.toEmbeddedTS(shiftState(state, code, { inline: true }));
1601
- code += ';\n';
1602
- });
1603
-
1604
- this.returns.forEach((ret) => {
1605
- code += indent((state?.tabSize || 0) + 1) + 'let ';
1606
- code += ret.toEmbeddedTS(shiftState(state, code, { inline: true }));
1607
- code += ';\n';
1608
- });
1609
-
1610
- if (!this.body.length && this.returns.length) {
1611
- code += indent((state?.tabSize || 0) + 1) + `return ${this.returns[0].name};\n`;
1612
- } else {
1613
- if ((this.parentNode as any).type === 'ExclusiveGateway') {
1614
- if (this.body.length <= 1) {
1615
- code += indent((state?.tabSize || 0) + 1);
1616
- code += 'const __LogicEmpty: any = null;';
1617
- }
1618
- } else if (this.body.length <= 2 && !(this.parentNode instanceof Namespace) && !(this.parentNode instanceof Process)) {
1619
- code += indent((state?.tabSize || 0) + 1);
1620
- code += indent(state?.tabSize || 0 + 4) + 'const __LogicEmpty: any = null;';
1621
- }
1622
- this.body.forEach((item) => {
1623
- code += item.toEmbeddedTS && item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1624
- code += ';\n';
1625
- });
1626
- }
1627
-
1628
- // 在body渲染完成之后把其余的节点放到下面
1629
- this.playground.forEach((item) => {
1630
- code += item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1631
- code += '\n';
1632
- });
1633
-
1634
- code += indent(state?.tabSize || 0 + 4) + '}';
1635
- code += '\n';
1636
- return code;
1757
+ });
1637
1758
  }
1638
-
1639
- toEmbeddedTSNoExport(state?: TranslatorState): string {
1640
- return this.toEmbeddedTS(state, 'noExport');
1759
+ // 兼容 return 没有类型情况
1760
+ if (this.returns.length && this.returns[0].typeAnnotation) {
1761
+ code += ': ';
1762
+ code += this.returns[0].typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true }));
1641
1763
  }
1764
+ code += '{\n';
1642
1765
 
1643
- @withSourceMap()
1644
- toEmbeddedTS(state?: TranslatorState, prefix?: string): string {
1645
- // 如果传了不要前缀那就为空, 要不用传进来的,要是都没有就默认导出
1646
- let code = '';
1647
- if (!prefix) {
1648
- code += `export function ${this.name}`;
1649
- } else if (prefix === 'noExport') {
1650
- code += `function ${this.name}`;
1651
- } else if (prefix === 'inObject') {
1652
- code += `${this.name}`;
1653
- }
1654
- if (this.typeParams?.length) {
1655
- code += '<';
1656
- this.typeParams.forEach((typeParam, typeParamIndex) => {
1657
- code += typeParam.toEmbeddedTS(shiftState(state, code, { inline: true }));
1658
- if (typeParamIndex !== this.typeParams.length - 1)
1659
- code += ', ';
1660
- });
1661
- code += '>';
1662
- }
1663
- // 有参数长度
1664
- if (this.params.length) {
1665
- code += '(';
1666
- this.params.forEach((param, index) => {
1667
- code += param.toEmbeddedTS(shiftState(state, code));
1668
- if (index !== this.params.length - 1)
1669
- code += ', ';
1670
- });
1671
- code += ')';
1672
- } else {
1673
- // 没有参数的
1674
- code += '()';
1675
- }
1676
-
1677
- // 需要类型推导的局部变量/返回值需要调整申明顺序
1678
- const advanceMap: Map<Return | Variable, Assignment | BatchAssignment> = new Map();
1679
- const needGetSourceMapOqlList: Promise<any>[] = [];
1680
- this.traverseChildren((el) => {
1681
- if (el && (el instanceof BatchAssignment || (el instanceof Assignment && el.left?.name))) {
1682
- if (el instanceof Assignment) {
1683
- const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && (el.left?.name === variable.name));
1684
- if (advanceVar && !advanceMap.get(advanceVar)) {
1685
- advanceMap.set(advanceVar, el);
1686
- }
1687
- const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && el.left?.name === ret.name);
1688
- if (advanceRn && !advanceMap.get(advanceRn)) {
1689
- advanceMap.set(advanceRn, el);
1690
- }
1691
- } else if (el instanceof BatchAssignment) {
1692
- el.assignmentLines.forEach(({ leftIndex }) => {
1693
- const leftCode
1694
- = leftIndex.length === 1 ? el.left.expression.toEmbeddedTS(shiftState(state, code, { inline: true })) : el.left.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true }));
1695
- const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && (leftCode === variable.name));
1696
- if (advanceVar && !advanceMap.get(advanceVar)) {
1697
- advanceMap.set(advanceVar, el);
1698
- }
1699
- const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && leftCode === ret.name);
1700
- if (advanceRn && !advanceMap.get(advanceRn)) {
1701
- advanceMap.set(advanceRn, el);
1702
- }
1703
- });
1704
- }
1705
- }
1706
- // 如果有sql查询组件就需要把他们存起来
1707
- if (el instanceof OqlQueryComponent) {
1708
- if (!el.codeSourceMap) {
1709
- needGetSourceMapOqlList.push(el.requestEmbeddedTS());
1710
- }
1711
- }
1712
- });
1713
-
1714
- if (needGetSourceMapOqlList.length) {
1715
- Promise.all(needGetSourceMapOqlList).then(() => {
1716
- // 触发一下更新重新生成代码
1717
- (this.app as any)?.naslServer?.embeddedTSEmitter.emit('change', {
1718
- value: [
1719
- {
1720
- originEvent: {
1721
- action: 'update',
1722
- target: this,
1723
- },
1724
- },
1725
- ],
1726
- });
1727
- });
1728
- }
1729
- // 兼容 return 没有类型情况
1730
- if (this.returns.length && this.returns[0].typeAnnotation) {
1731
- code += ': ';
1732
- code += this.returns[0].typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true }));
1733
- }
1734
- code += '{\n';
1735
-
1736
- // 用于虚拟节点的查找引用
1737
- this.virtualParams
1738
- && Array.isArray(this.virtualParams)
1739
- && this.virtualParams.forEach((param) => {
1740
- code += indent((state?.tabSize || 0) + 1);
1741
- code += param.toEmbeddedNameTS(shiftState(state, code, { inline: true }));
1742
- code += '\n';
1743
- });
1744
-
1745
- this.variables.forEach((variable) => {
1746
- if (!advanceMap.get(variable)) {
1747
- code += indent((state?.tabSize || 0) + 1) + 'let ';
1748
- code += variable.toEmbeddedTS(shiftState(state, code, { inline: true }));
1749
- code += ';\n';
1750
- }
1751
- });
1752
-
1753
- this.returns.forEach((ret) => {
1754
- if (!advanceMap.get(ret)) {
1755
- code += indent((state?.tabSize || 0) + 1) + 'let ';
1756
- code += ret.toEmbeddedTS(shiftState(state, code, { inline: true }));
1757
- code += ';\n';
1758
- }
1759
- });
1760
-
1761
- advanceMap.forEach((assignment, node) => {
1762
- code += indent((state?.tabSize || 0) + 1) + '// @ts-ignore\n';
1763
- code += indent((state?.tabSize || 0) + 1) + 'let ';
1764
- code += node.toEmbeddedTS(shiftState(state, code, { inline: true }));
1765
- if (assignment instanceof BatchAssignment) {
1766
- assignment.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1767
- const leftCode
1768
- = leftIndex.length === 1 ? assignment.left.expression.toEmbeddedTS(shiftState(state, code, { inline: true })) : assignment.left.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true }));
1769
- if (leftCode === node.name) {
1770
- const rightNode: any = rightIndex.length === 1 ? assignment.rights[rightIndex[0]]?.expression : assignment.rights[rightIndex[0]]?.members[rightIndex[1]];
1771
- // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1772
- if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
1773
- code += ': ';
1774
- code += rightNode.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) || 'null';
1775
- } else {
1776
- code += ' = ';
1777
- const rightCode = rightNode?.toEmbeddedTS(shiftState(state, code, { inline: true }));
1778
- code += this.getRightCode(rightCode, assignment, rightNode);
1779
- }
1780
- }
1781
- });
1782
- } else if (['NewList', 'NewMap'].includes(assignment.right?.concept) && !(assignment.right as any)?.typeAnnotation) {
1783
- const rightNode: any = assignment.right;
1784
- code += ' = ';
1785
- code += rightNode.getInitCode(shiftState(state, code, { inline: true }));
1786
- } else if (assignment.right?.concept === 'NewComposite' && (assignment.right as any)?.typeAnnotation?.typeKind === 'anonymousStructure') {
1787
- const rightNode: any = assignment.right;
1788
- code += ' = ';
1789
- code += rightNode.getInitCode(shiftState(state, code, { inline: true }));
1766
+ // 用于虚拟节点的查找引用
1767
+ this.virtualParams &&
1768
+ Array.isArray(this.virtualParams) &&
1769
+ this.virtualParams.forEach((param) => {
1770
+ code += indent((state?.tabSize || 0) + 1);
1771
+ code += param.toEmbeddedNameTS(shiftState(state, code, { inline: true }));
1772
+ code += '\n';
1773
+ });
1774
+
1775
+ this.variables.forEach((variable) => {
1776
+ if (!advanceMap.get(variable)) {
1777
+ code += `${indent((state?.tabSize || 0) + 1)}let `;
1778
+ code += variable.toEmbeddedTS(shiftState(state, code, { inline: true }));
1779
+ code += ';\n';
1780
+ }
1781
+ });
1782
+
1783
+ this.returns.forEach((ret) => {
1784
+ if (!advanceMap.get(ret)) {
1785
+ code += `${indent((state?.tabSize || 0) + 1)}let `;
1786
+ code += ret.toEmbeddedTS(shiftState(state, code, { inline: true }));
1787
+ code += ';\n';
1788
+ }
1789
+ });
1790
+
1791
+ advanceMap.forEach((assignment, node) => {
1792
+ code += `${indent((state?.tabSize || 0) + 1)}// @ts-ignore\n`;
1793
+ code += `${indent((state?.tabSize || 0) + 1)}let `;
1794
+ code += node.toEmbeddedTS(shiftState(state, code, { inline: true }));
1795
+ if (assignment instanceof BatchAssignment) {
1796
+ assignment.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1797
+ const leftCode =
1798
+ leftIndex.length === 1
1799
+ ? assignment.left.expression.toEmbeddedTS(shiftState(state, code, { inline: true }))
1800
+ : assignment.left.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true }));
1801
+ if (leftCode === node.name) {
1802
+ const rightNode: any =
1803
+ rightIndex.length === 1 ? assignment.rights[rightIndex[0]]?.expression : assignment.rights[rightIndex[0]]?.members[rightIndex[1]];
1804
+ // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1805
+ if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
1806
+ code += ': ';
1807
+ code += rightNode.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) || 'null';
1790
1808
  } else {
1791
- const rightNode: any = assignment.right;
1792
- // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1793
- if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
1794
- code += ': ';
1795
- code += rightNode.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) || 'null';
1796
- } else {
1797
- code += ' = ';
1798
- let rightCode = '';
1799
- // 因为右侧枚举要赋值就得new 一下;
1800
- if (rightNode && rightNode instanceof Identifier && rightNode.namespace && rightNode.namespace.endsWith('enums')) {
1801
- rightCode += 'new ';
1802
- }
1803
- rightCode += rightNode && rightNode.toEmbeddedTS ? rightNode.toEmbeddedTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
1804
- code += this.getRightCode(rightCode, assignment, rightNode);
1805
- }
1809
+ code += ' = ';
1810
+ const rightCode = rightNode?.toEmbeddedTS(shiftState(state, code, { inline: true }));
1811
+ code += this.getRightCode(rightCode, assignment, rightNode);
1806
1812
  }
1807
- code += ';\n';
1813
+ }
1808
1814
  });
1809
-
1810
- if (!this.body.length && this.returns.length) {
1811
- code += indent((state?.tabSize || 0) + 1) + `return ${this.returns[0].name};\n`;
1815
+ } else if (['NewList', 'NewMap'].includes(assignment.right?.concept) && !(assignment.right as any)?.typeAnnotation) {
1816
+ const rightNode: any = assignment.right;
1817
+ code += ' = ';
1818
+ code += rightNode.getInitCode(shiftState(state, code, { inline: true }));
1819
+ } else if (assignment.right?.concept === 'NewComposite' && (assignment.right as any)?.typeAnnotation?.typeKind === 'anonymousStructure') {
1820
+ const rightNode: any = assignment.right;
1821
+ code += ' = ';
1822
+ code += rightNode.getInitCode(shiftState(state, code, { inline: true }));
1823
+ } else {
1824
+ const rightNode: any = assignment.right;
1825
+ // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1826
+ if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
1827
+ code += ': ';
1828
+ code += rightNode.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) || 'null';
1812
1829
  } else {
1813
- // 如果长度小于2 并且不是虚拟节点就 报错,
1814
- if (this.body.length <= 2 && !(this.parentNode instanceof Namespace)) {
1815
- code += indent((state?.tabSize || 0) + 1);
1816
- code += 'const __LogicEmpty: any = null;';
1817
- }
1818
- this.body.forEach((item) => {
1819
- code += item.toEmbeddedTS && item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1820
- code += ';\n';
1821
- });
1822
- }
1823
-
1824
- // 在body渲染完成之后把其余的节点放到下面
1825
- this.playground.forEach((item) => {
1826
- code += item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1827
- code += ';\n';
1828
- });
1829
-
1830
- code += indent(state?.tabSize || 0) + '}';
1831
- if (prefix === 'inObject') {
1832
- code += `,`;
1833
- }
1834
- code += '\n';
1835
- return code;
1836
- }
1837
-
1838
- getRightCode(code: string, assignment: Assignment | BatchAssignment, rightNode: any): string {
1839
- code = code.replaceAll('\n', ' ');
1840
- if (assignment instanceof Assignment && !assignment.right)
1841
- return code;
1842
-
1843
- // 调用接口,参数替换成 null
1844
- if (rightNode instanceof CallInterface) {
1845
- const { _interface } = rightNode.getModuleInterface();
1846
- return _interface ? `${rightNode.tsCalleeKey}(${_interface.params.map(() => 'null').join(',')})` : null;
1847
- }
1848
-
1849
- // 调用服务端逻辑,参数替换成 null
1850
- if (rightNode instanceof CallLogic && rightNode.calleeNamespace === 'app.logics') {
1851
- const calleeName = rightNode?.calleeName;
1852
- const calleeLogic = this.app.logics.find((l) => l.name === calleeName);
1853
- return calleeLogic ? `app.logics.${calleeName}(${calleeLogic.params.map(() => 'null').join(',')})` : null;
1854
- }
1855
-
1856
- // ForEachStatement 内部变量需要替换处理,如 item、index
1857
- const forEachStatement = assignment.getAncestor('ForEachStatement') as ForEachStatement;
1858
- if (forEachStatement) {
1859
- code = this.handleForEachCode(code, forEachStatement);
1860
- }
1861
- // Match 需要针对分支缩小类型范围
1862
- const matchCase = assignment.getAncestor('MatchCase') as MatchCase;
1863
- if (matchCase) {
1864
- code = this.handleMatchCaseCode(code, matchCase);
1865
- }
1866
- return code;
1867
- }
1868
-
1869
- handleReplaceCode(code: string, variable: string, replaceCode: string) {
1870
- return code.replace(/\S+/g, ($1) => {
1871
- if ($1 === `${variable},`)
1872
- return `${replaceCode},`;
1873
- if ($1 === variable)
1874
- return replaceCode;
1875
-
1876
- let fnCode = $1;
1877
- if ($1.startsWith(`${variable}.`))
1878
- fnCode = $1.replaceAll(`${variable}.`, `${replaceCode}.`);
1879
- if ($1.startsWith(`${variable},`))
1880
- fnCode = $1.replaceAll(`${variable},`, `${replaceCode},`);
1881
- if ($1.includes(`(${variable},`))
1882
- fnCode = $1.replaceAll(`(${variable},`, `(${replaceCode},`);
1883
- if ($1.includes(`(${variable}.`))
1884
- fnCode = $1.replaceAll(`(${variable}.`, `(${replaceCode}.`);
1885
- if ($1.includes(`(${variable})`))
1886
- fnCode = $1.replaceAll(`(${variable})`, `(${replaceCode})`);
1887
- if ($1.includes(`,${variable},`))
1888
- fnCode = $1.replaceAll(`,${variable},`, `,${replaceCode},`);
1889
- if ($1.includes(`,${variable}.`))
1890
- fnCode = $1.replaceAll(`,${variable}.`, `,${replaceCode}.`);
1891
- if ($1.includes(`,${variable})`))
1892
- fnCode = $1.replaceAll(`,${variable})`, `,${replaceCode})`);
1893
- return fnCode;
1894
- });
1895
- }
1896
-
1897
- handleForEachCode(code: string, forEachStatement: ForEachStatement): string {
1898
- const { item, index, each } = forEachStatement;
1899
- if (code.includes(item.name)) {
1900
- const eachTSCode = each.toEmbeddedTS();
1901
- code = this.handleReplaceCode(code, item.name, eachTSCode === '__IDENTIFIER__' ? eachTSCode : `${eachTSCode}.__get(0)`);
1902
- }
1903
- if (code.includes(index.name))
1904
- code = this.handleReplaceCode(code, index.name, 'new nasl.core.Integer(0)');
1905
-
1906
- const parentForEachStatement = forEachStatement.getAncestor('ForEachStatement') as ForEachStatement;
1907
- if (parentForEachStatement) {
1908
- this.handleForEachCode(code, parentForEachStatement);
1909
- }
1910
- return code;
1911
- }
1912
-
1913
- handleMatchCaseCode(code: string, matchCase: MatchCase): string {
1914
- const match = matchCase.getAncestor('Match') as Match;
1915
- const expressionTsCode = match.expression.toEmbeddedTS();
1916
- if (code.includes(expressionTsCode)) {
1917
- let typeCode = '';
1918
- matchCase.patterns.forEach((pattern, index) => {
1919
- if (pattern instanceof TypeAnnotation) {
1920
- if (index === 0) {
1921
- typeCode += pattern.toEmbeddedTS();
1922
- } else {
1923
- typeCode += '|';
1924
- typeCode += pattern.toEmbeddedTS();
1925
- }
1926
- }
1927
- });
1928
- if (typeCode) {
1929
- code = this.handleReplaceCode(code, expressionTsCode, `(${expressionTsCode} as ${typeCode})`);
1930
- }
1931
- }
1932
- const parentMatchCase = match.getAncestor('MatchCase') as MatchCase;
1933
- if (parentMatchCase) {
1934
- code = this.handleMatchCaseCode(code, parentMatchCase);
1935
- }
1936
- return code;
1937
- }
1938
-
1939
- getNamespace(): string {
1940
- if (this.parentNode) {
1941
- const parentNamespace = (this.parentNode as any)?.getNamespace();
1942
- const parentName = this.parentNode.name;
1943
- const arr = [parentNamespace];
1944
- if (this.parentNode.concept !== 'App' && parentName) {
1945
- arr.push(parentName);
1946
- }
1947
- let namespace = arr.join('.');
1948
- if (
1949
- !['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace)
1950
- && !namespace.includes('.overriddenLogics')
1951
- ) {
1952
- namespace = `${namespace}.overriddenLogics`;
1953
- }
1954
- if (this.concept === 'OverriddenLogic') {
1955
- namespace = `extensions.${this.overriddenModule}.logics`;
1956
- }
1957
- return namespace;
1958
- } else
1959
- throw new Error('无法获取命名空间,请设置 parentNode!');
1960
- }
1961
-
1962
- getTsNamespace(): string {
1963
- if (this.parentNode) {
1964
- const parentNamespace = (this.parentNode as any)?.getTsNamespace();
1965
- const parentName = this.parentNode.tsName || this.parentNode.name;
1966
- const arr = [parentNamespace];
1967
- if (this.parentNode.concept !== 'App' && parentName) {
1968
- arr.push(parentName);
1969
- }
1970
- let namespace = arr.join('.');
1971
- if (
1972
- !['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace)
1973
- && !namespace.includes('.overriddenLogics')
1974
- ) {
1975
- namespace = `${namespace}.overriddenLogics`;
1976
- }
1977
- return namespace;
1978
- } else
1979
- throw new Error('无法获取命名空间,请设置 parentNode!');
1980
- }
1981
-
1982
- /**
1983
- * 生成宿主语言的文件路径
1984
- * @param name 一般不用传,用于 rename
1985
- */
1986
- getEmbeddedFilePath(name = this.name) {
1987
- let _path = this.module ? `/${this.module.parentKey}/${this.module.name}` : '';
1988
- if (this.parentNode instanceof FrontendLibrary) {
1989
- _path += `/frontends/${this.parentNode.type}`;
1990
- }
1991
- return `/embedded/${this.app.name}${_path}/overriddenLogics/${name}.ts`;
1992
- }
1993
-
1994
- toEmbeddedTSFile() {
1995
- let code = `namespace ${this.getTsNamespace()} {\n`;
1996
-
1997
- const state = createCompilerState(code, { tabSize: 1 });
1998
- try {
1999
- code += this.toEmbeddedTS(state);
2000
- } catch (err) {
2001
- console.log(err, '有问题翻译失败');
2002
- code += '';
2003
- console.log(err);
2004
- }
2005
- code += '}\n';
2006
- return {
2007
- code,
2008
- filePath: this.getEmbeddedFilePath(),
2009
- sourceMap: state.sourceMap,
2010
- };
2011
- }
2012
-
2013
- public static getDefaultOptions() {
2014
- return {
2015
- body: [
2016
- {
2017
- concept: 'Start',
2018
- label: '开始',
2019
- kind: 'Statement',
2020
- type: 'Start',
2021
- },
2022
- {
2023
- concept: 'End',
2024
- label: '结束',
2025
- kind: 'Statement',
2026
- type: 'End',
2027
- },
2028
- ],
2029
- };
2030
- }
2031
-
2032
- async saveStructureOfCallQueryComponents(root?: BaseNode | Logic) {
2033
- if (!root)
2034
- root = this;
2035
- const set = new Set();
2036
- utils.traverse(({ node }) => {
2037
- if (node instanceof CallQueryComponent) {
2038
- set.add(node);
2039
- }
2040
- }, { node: root }, {
2041
- mode: 'anyObject',
2042
- excludedKeySet: new Set(['parentNode', '__assignment__']),
2043
- });
2044
- for (const node of set) {
2045
- (<CallQueryComponent>node).saveStructure();
2046
- }
2047
- }
2048
-
2049
- // 通过开关设置数据库事务
2050
- setTransactionEnabled(flag: boolean) {
2051
- this.setTransactional(new Transactional({
2052
- enabled: flag,
2053
- }));
2054
- }
2055
- fake: boolean;
2056
-
2057
- getPath: () => string;
2058
-
2059
- delete() {
2060
- let actionMsg = '删除逻辑项';
2061
- if (this.name)
2062
- actionMsg += `“${this.name}”`;
2063
- this.app?.emit('collect:start', {
2064
- actionMsg,
2065
- });
2066
- super.delete();
2067
- this.traverseChildren((el) => {
2068
- if (el?.concept === 'CallQueryComponent')
2069
- (el as CallQueryComponent).removeStructure();
2070
- });
2071
- this.app?.emit('collect:end');
2072
- }
2073
-
2074
- // 是不是内部有错误
2075
- haveError: boolean = false;
2076
-
2077
- // 是否body为空
2078
- isSmpty: boolean = false;
2079
-
2080
- get pathName() {
2081
- if (this.view) {
2082
- return this.getEventLogicName('chinese');
2083
- }
2084
- const nameMap = {
2085
- OnProcessStart: '流程开始时',
2086
- OnTasksCreate: '任务创建时',
2087
- OnTasksOpen: '任务打开时',
2088
- OnTasksClose: '任务关闭时',
2089
- OnCreate: '用户任务创建时',
2090
- OnOpen: '用户任务打开时',
2091
- OnClose: '用户任务关闭时',
2092
- };
2093
- const pathName = [this.name];
2094
- let parentNode = this.parentNode;
2095
- while (parentNode && parentNode.concept !== 'Process') {
2096
- const name = (nameMap as any)[parentNode.name] || parentNode.name;
2097
- pathName.unshift(name);
2098
- parentNode = parentNode.parentNode;
2099
- }
2100
- return pathName.join('-');
2101
- }
2102
- // 获取bindEvent下的logic的名称
2103
- getEventLogicName(type?: string) {
2104
- if (this.parentNode instanceof BindEvent) {
2105
- if (type === 'chinese') {
2106
- const bindEvent = this.parentNode;
2107
- const bindChineseName = bindEvent.getPageViewEventChineseName();
2108
- return `${bindChineseName}-${this.name}`;
2109
- }
1830
+ code += ' = ';
1831
+ let rightCode = '';
1832
+ // 因为右侧枚举要赋值就得new 一下;
1833
+ if (rightNode && rightNode instanceof Identifier && rightNode.namespace && rightNode.namespace.endsWith('enums')) {
1834
+ rightCode += 'new ';
1835
+ }
1836
+ rightCode += rightNode && rightNode.toEmbeddedTS ? rightNode.toEmbeddedTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
1837
+ code += this.getRightCode(rightCode, assignment, rightNode);
2110
1838
  }
2111
- return this.name;
2112
- }
2113
-
2114
- // 虚拟输入参数列表
2115
- virtualParams: Array<Param> = [];
2116
-
2117
- get getLogicBelongTo() {
2118
- const [, belongTo] = this.calleewholeKey.split('.');
2119
- return belongTo;
2120
- }
2121
-
2122
- // 校验logic的返回值是不是有error类型
2123
- static checkLogicReturnTypeHasError(logic: Logic) {
2124
- let findHasError = false;
2125
- if (!logic) {
2126
- return findHasError;
1839
+ }
1840
+ code += ';\n';
1841
+ });
1842
+
1843
+ if (!this.body.length && this.returns.length) {
1844
+ code += `${indent((state?.tabSize || 0) + 1)}return ${this.returns[0].name};\n`;
1845
+ } else {
1846
+ // 如果长度小于2 并且不是虚拟节点就 报错,
1847
+ if (this.body.length <= 2 && !(this.parentNode instanceof Namespace)) {
1848
+ code += indent((state?.tabSize || 0) + 1);
1849
+ code += 'const __LogicEmpty: any = null;';
1850
+ }
1851
+ this.body.forEach((item) => {
1852
+ code += item.toEmbeddedTS && item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1853
+ code += ';\n';
1854
+ });
1855
+ }
1856
+
1857
+ // 在body渲染完成之后把其余的节点放到下面
1858
+ this.playground.forEach((item) => {
1859
+ code += item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1860
+ code += ';\n';
1861
+ });
1862
+
1863
+ code += `${indent(state?.tabSize || 0)}}`;
1864
+ if (prefix === 'inObject') {
1865
+ code += `,`;
1866
+ }
1867
+ code += '\n';
1868
+ return code;
1869
+ }
1870
+
1871
+ getRightCode(code: string, assignment: Assignment | BatchAssignment, rightNode: any): string {
1872
+ code = code.replaceAll('\n', ' ');
1873
+ if (assignment instanceof Assignment && !assignment.right) return code;
1874
+
1875
+ // 调用接口,参数替换成 null
1876
+ if (rightNode instanceof CallInterface) {
1877
+ const { _interface } = rightNode.getModuleInterface();
1878
+ return _interface ? `${rightNode.tsCalleeKey}(${_interface.params.map(() => 'null').join(',')})` : null;
1879
+ }
1880
+
1881
+ // 调用服务端逻辑,参数替换成 null
1882
+ if (rightNode instanceof CallLogic && rightNode.calleeNamespace === 'app.logics') {
1883
+ const calleeName = rightNode?.calleeName;
1884
+ const calleeLogic = this.app.logics.find((l) => l.name === calleeName);
1885
+ return calleeLogic ? `app.logics.${calleeName}(${calleeLogic.params.map(() => 'null').join(',')})` : null;
1886
+ }
1887
+
1888
+ // ForEachStatement 内部变量需要替换处理,如 item、index
1889
+ const forEachStatement = assignment.getAncestor('ForEachStatement') as ForEachStatement;
1890
+ if (forEachStatement) {
1891
+ code = this.handleForEachCode(code, forEachStatement);
1892
+ }
1893
+ // Match 需要针对分支缩小类型范围
1894
+ const matchCase = assignment.getAncestor('MatchCase') as MatchCase;
1895
+ if (matchCase) {
1896
+ code = this.handleMatchCaseCode(code, matchCase);
1897
+ }
1898
+ return code;
1899
+ }
1900
+
1901
+ handleReplaceCode(code: string, variable: string, replaceCode: string) {
1902
+ return code.replace(/\S+/g, ($1) => {
1903
+ if ($1 === `${variable},`) return `${replaceCode},`;
1904
+ if ($1 === variable) return replaceCode;
1905
+
1906
+ let fnCode = $1;
1907
+ if ($1.startsWith(`${variable}.`)) fnCode = $1.replaceAll(`${variable}.`, `${replaceCode}.`);
1908
+ if ($1.startsWith(`${variable},`)) fnCode = $1.replaceAll(`${variable},`, `${replaceCode},`);
1909
+ if ($1.includes(`(${variable},`)) fnCode = $1.replaceAll(`(${variable},`, `(${replaceCode},`);
1910
+ if ($1.includes(`(${variable}.`)) fnCode = $1.replaceAll(`(${variable}.`, `(${replaceCode}.`);
1911
+ if ($1.includes(`(${variable})`)) fnCode = $1.replaceAll(`(${variable})`, `(${replaceCode})`);
1912
+ if ($1.includes(`,${variable},`)) fnCode = $1.replaceAll(`,${variable},`, `,${replaceCode},`);
1913
+ if ($1.includes(`,${variable}.`)) fnCode = $1.replaceAll(`,${variable}.`, `,${replaceCode}.`);
1914
+ if ($1.includes(`,${variable})`)) fnCode = $1.replaceAll(`,${variable})`, `,${replaceCode})`);
1915
+ return fnCode;
1916
+ });
1917
+ }
1918
+
1919
+ handleForEachCode(code: string, forEachStatement: ForEachStatement): string {
1920
+ const { item, index, each } = forEachStatement;
1921
+ if (code.includes(item.name)) {
1922
+ const eachTSCode = each.toEmbeddedTS();
1923
+ code = this.handleReplaceCode(code, item.name, eachTSCode === '__IDENTIFIER__' ? eachTSCode : `${eachTSCode}.__get(0)`);
1924
+ }
1925
+ if (code.includes(index.name)) code = this.handleReplaceCode(code, index.name, 'new nasl.core.Integer(0)');
1926
+
1927
+ const parentForEachStatement = forEachStatement.getAncestor('ForEachStatement') as ForEachStatement;
1928
+ if (parentForEachStatement) {
1929
+ this.handleForEachCode(code, parentForEachStatement);
1930
+ }
1931
+ return code;
1932
+ }
1933
+
1934
+ handleMatchCaseCode(code: string, matchCase: MatchCase): string {
1935
+ const match = matchCase.getAncestor('Match') as Match;
1936
+ const expressionTsCode = match.expression.toEmbeddedTS();
1937
+ if (code.includes(expressionTsCode)) {
1938
+ let typeCode = '';
1939
+ matchCase.patterns.forEach((pattern, index) => {
1940
+ if (pattern instanceof TypeAnnotation) {
1941
+ if (index === 0) {
1942
+ typeCode += pattern.toEmbeddedTS();
1943
+ } else {
1944
+ typeCode += '|';
1945
+ typeCode += pattern.toEmbeddedTS();
1946
+ }
2127
1947
  }
2128
- if (logic.returns?.length && logic.returns[0]?.typeAnnotation) {
2129
- // 如果新导入的logic还有Error类型
2130
- const logicType = logic.returns[0].typeAnnotation;
2131
- if (logicType.typeNamespace === 'nasl.ui' && logicType.typeName === 'Error') {
2132
- findHasError = true;
2133
- } else if (logicType.typeNamespace === 'nasl.core' && logicType.typeKind === 'union') {
2134
- // 如果 logic 有 returns 而且,也有typeArguments的长度
2135
- findHasError = Boolean(logicType.typeArguments?.find((item) => (
2136
- item?.typeNamespace === 'nasl.ui' && item?.typeName === 'Error'
2137
- )));
2138
- }
1948
+ });
1949
+ if (typeCode) {
1950
+ code = this.handleReplaceCode(code, expressionTsCode, `(${expressionTsCode} as ${typeCode})`);
1951
+ }
1952
+ }
1953
+ const parentMatchCase = match.getAncestor('MatchCase') as MatchCase;
1954
+ if (parentMatchCase) {
1955
+ code = this.handleMatchCaseCode(code, parentMatchCase);
1956
+ }
1957
+ return code;
1958
+ }
1959
+
1960
+ getNamespace(): string {
1961
+ if (this.parentNode) {
1962
+ const parentNamespace = (this.parentNode as any)?.getNamespace();
1963
+ const parentName = this.parentNode.name;
1964
+ const arr = [parentNamespace];
1965
+ if (this.parentNode.concept !== 'App' && parentName) {
1966
+ arr.push(parentName);
1967
+ }
1968
+ let namespace = arr.join('.');
1969
+ if (
1970
+ ![
1971
+ 'nasl.ui',
1972
+ 'nasl.utils',
1973
+ 'nasl.util',
1974
+ 'nasl.browser',
1975
+ 'nasl.auth',
1976
+ 'nasl.configuration',
1977
+ 'nasl.process',
1978
+ 'nasl.logging',
1979
+ 'nasl.io',
1980
+ ].includes(namespace) &&
1981
+ !namespace.includes('.overriddenLogics')
1982
+ ) {
1983
+ namespace = `${namespace}.overriddenLogics`;
1984
+ }
1985
+ if (this.concept === 'OverriddenLogic') {
1986
+ namespace = `extensions.${this.overriddenModule}.logics`;
1987
+ }
1988
+ return namespace;
1989
+ }
1990
+ throw new Error('无法获取命名空间,请设置 parentNode!');
1991
+ }
1992
+
1993
+ getTsNamespace(): string {
1994
+ if (this.parentNode) {
1995
+ const parentNamespace = (this.parentNode as any)?.getTsNamespace();
1996
+ const parentName = this.parentNode.tsName || this.parentNode.name;
1997
+ const arr = [parentNamespace];
1998
+ if (this.parentNode.concept !== 'App' && parentName) {
1999
+ arr.push(parentName);
2000
+ }
2001
+ let namespace = arr.join('.');
2002
+ if (
2003
+ ![
2004
+ 'nasl.ui',
2005
+ 'nasl.utils',
2006
+ 'nasl.util',
2007
+ 'nasl.browser',
2008
+ 'nasl.auth',
2009
+ 'nasl.configuration',
2010
+ 'nasl.process',
2011
+ 'nasl.logging',
2012
+ 'nasl.io',
2013
+ ].includes(namespace) &&
2014
+ !namespace.includes('.overriddenLogics')
2015
+ ) {
2016
+ namespace = `${namespace}.overriddenLogics`;
2017
+ }
2018
+ return namespace;
2019
+ }
2020
+ throw new Error('无法获取命名空间,请设置 parentNode!');
2021
+ }
2022
+
2023
+ /**
2024
+ * 生成宿主语言的文件路径
2025
+ * @param name 一般不用传,用于 rename
2026
+ */
2027
+ getEmbeddedFilePath(name = this.name) {
2028
+ let _path = this.module ? `/${this.module.parentKey}/${this.module.name}` : '';
2029
+ if (this.parentNode instanceof FrontendLibrary) {
2030
+ _path += `/frontends/${this.parentNode.type}`;
2031
+ }
2032
+ return `/embedded/${this.app.name}${_path}/overriddenLogics/${name}.ts`;
2033
+ }
2034
+
2035
+ toEmbeddedTSFile() {
2036
+ let code = `namespace ${this.getTsNamespace()} {\n`;
2037
+
2038
+ const state = createCompilerState(code, { tabSize: 1 });
2039
+ try {
2040
+ code += this.toEmbeddedTS(state);
2041
+ } catch (err) {
2042
+ console.log(err, '有问题翻译失败');
2043
+ code += '';
2044
+ console.log(err);
2045
+ }
2046
+ code += '}\n';
2047
+ return {
2048
+ code,
2049
+ filePath: this.getEmbeddedFilePath(),
2050
+ sourceMap: state.sourceMap,
2051
+ };
2052
+ }
2053
+
2054
+ public static getDefaultOptions() {
2055
+ return {
2056
+ body: [
2057
+ {
2058
+ concept: 'Start',
2059
+ label: '开始',
2060
+ kind: 'Statement',
2061
+ type: 'Start',
2062
+ },
2063
+ {
2064
+ concept: 'End',
2065
+ label: '结束',
2066
+ kind: 'Statement',
2067
+ type: 'End',
2068
+ },
2069
+ ],
2070
+ };
2071
+ }
2072
+
2073
+ async saveStructureOfCallQueryComponents(root?: BaseNode | Logic) {
2074
+ if (!root) root = this;
2075
+ const set = new Set();
2076
+ utils.traverse(
2077
+ ({ node }) => {
2078
+ if (node instanceof CallQueryComponent) {
2079
+ set.add(node);
2139
2080
  }
2140
- return findHasError;
2141
- }
2142
- get getIsEmptyLogic() {
2143
- return this.body?.filter((node) => !['Start', 'End'].includes(node?.concept))?.length <= 0;
2144
- }
2145
- getOverriddenDepLogic() {
2146
- const dep = this.app.dependencies?.find((dep) => dep.name === this.overriddenModule);
2147
- if (dep) {
2148
- const depLogic = dep?.logics?.find((l) => l.name === this.name);
2149
- return depLogic || null;
2150
- } else {
2151
- return null;
2152
- }
2153
- }
2154
- //================================================================================
2155
- // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
2156
- // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
2157
- //================================================================================
2081
+ },
2082
+ { node: root },
2083
+ {
2084
+ mode: 'anyObject',
2085
+ excludedKeySet: new Set(['parentNode', '__assignment__']),
2086
+ }
2087
+ );
2088
+ for (const node of set) {
2089
+ (<CallQueryComponent>node).saveStructure();
2090
+ }
2091
+ }
2092
+
2093
+ // 通过开关设置数据库事务
2094
+ setTransactionEnabled(flag: boolean) {
2095
+ this.setTransactional(
2096
+ new Transactional({
2097
+ enabled: flag,
2098
+ })
2099
+ );
2100
+ }
2101
+
2102
+ fake: boolean;
2103
+
2104
+ getPath: () => string;
2105
+
2106
+ delete() {
2107
+ let actionMsg = '删除逻辑项';
2108
+ if (this.name) actionMsg += `“${this.name}”`;
2109
+ this.app?.emit('collect:start', {
2110
+ actionMsg,
2111
+ });
2112
+ super.delete();
2113
+ this.traverseChildren((el) => {
2114
+ if (el?.concept === 'CallQueryComponent') (el as CallQueryComponent).removeStructure();
2115
+ });
2116
+ this.app?.emit('collect:end');
2117
+ }
2118
+
2119
+ // 是不是内部有错误
2120
+ haveError: boolean = false;
2121
+
2122
+ // 是否body为空
2123
+ isSmpty: boolean = false;
2124
+
2125
+ get pathName() {
2126
+ if (this.view) {
2127
+ return this.getEventLogicName('chinese');
2128
+ }
2129
+ const nameMap = {
2130
+ OnProcessStart: '流程开始时',
2131
+ OnTasksCreate: '任务创建时',
2132
+ OnTasksOpen: '任务打开时',
2133
+ OnTasksClose: '任务关闭时',
2134
+ OnCreate: '用户任务创建时',
2135
+ OnOpen: '用户任务打开时',
2136
+ OnClose: '用户任务关闭时',
2137
+ };
2138
+ const pathName = [this.name];
2139
+ let { parentNode } = this;
2140
+ while (parentNode && parentNode.concept !== 'Process') {
2141
+ const name = (nameMap as any)[parentNode.name] || parentNode.name;
2142
+ pathName.unshift(name);
2143
+ parentNode = parentNode.parentNode;
2144
+ }
2145
+ return pathName.join('-');
2146
+ }
2147
+
2148
+ // 获取bindEvent下的logic的名称
2149
+ getEventLogicName(type?: string) {
2150
+ if (this.parentNode instanceof BindEvent) {
2151
+ if (type === 'chinese') {
2152
+ const bindEvent = this.parentNode;
2153
+ const bindChineseName = bindEvent.getPageViewEventChineseName();
2154
+ return `${bindChineseName}-${this.name}`;
2155
+ }
2156
+ }
2157
+ return this.name;
2158
+ }
2159
+
2160
+ // 虚拟输入参数列表
2161
+ virtualParams: Array<Param> = [];
2162
+
2163
+ get getLogicBelongTo() {
2164
+ const [, belongTo] = this.calleewholeKey.split('.');
2165
+ return belongTo;
2166
+ }
2167
+
2168
+ // 校验logic的返回值是不是有error类型
2169
+ static checkLogicReturnTypeHasError(logic: Logic) {
2170
+ let findHasError = false;
2171
+ if (!logic) {
2172
+ return findHasError;
2173
+ }
2174
+ if (logic.returns?.length && logic.returns[0]?.typeAnnotation) {
2175
+ // 如果新导入的logic还有Error类型
2176
+ const logicType = logic.returns[0].typeAnnotation;
2177
+ if (logicType.typeNamespace === 'nasl.ui' && logicType.typeName === 'Error') {
2178
+ findHasError = true;
2179
+ } else if (logicType.typeNamespace === 'nasl.core' && logicType.typeKind === 'union') {
2180
+ // 如果 logic 有 returns 而且,也有typeArguments的长度
2181
+ findHasError = Boolean(logicType.typeArguments?.find((item) => item?.typeNamespace === 'nasl.ui' && item?.typeName === 'Error'));
2182
+ }
2183
+ }
2184
+ return findHasError;
2185
+ }
2186
+
2187
+ get getIsEmptyLogic() {
2188
+ return this.body?.filter((node) => !['Start', 'End'].includes(node?.concept))?.length <= 0;
2189
+ }
2190
+
2191
+ getOverriddenDepLogic() {
2192
+ const dep = this.app.dependencies?.find((dep) => dep.name === this.overriddenModule);
2193
+ if (dep) {
2194
+ const depLogic = dep?.logics?.find((l) => l.name === this.name);
2195
+ return depLogic || null;
2196
+ }
2197
+ return null;
2198
+ }
2199
+ //= ===============================================================================
2200
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
2201
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
2202
+ //= ===============================================================================
2158
2203
  }
2159
2204
 
2160
2205
  classMap.OverriddenLogic = OverriddenLogic;
2161
2206
  export default OverriddenLogic;
2162
- //================================================================================
2207
+ //= ===============================================================================
2163
2208
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
2164
2209
  // 自动生成的代码已结束。下面可以手动编写。
2165
- //================================================================================
2210
+ //= ===============================================================================