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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (842) hide show
  1. package/out/automate/engine/utils.js +4 -0
  2. package/out/automate/engine/utils.js.map +1 -1
  3. package/out/automate/upgrader/2.20.js +1 -1
  4. package/out/automate/upgrader/2.20.js.map +1 -1
  5. package/out/bak/translator.js +11 -15
  6. package/out/bak/translator.js.map +1 -1
  7. package/out/breakpoint/generator/AfterStartNode.js +3 -1
  8. package/out/breakpoint/generator/AfterStartNode.js.map +1 -1
  9. package/out/breakpoint/generator/BeforeEndNode.js.map +1 -1
  10. package/out/breakpoint/generator/BreakpointNode.d.ts +1 -0
  11. package/out/breakpoint/generator/BreakpointNode.js +48 -15
  12. package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
  13. package/out/breakpoint/generator/CallbackNode.d.ts +4 -0
  14. package/out/breakpoint/generator/CallbackNode.js +22 -0
  15. package/out/breakpoint/generator/CallbackNode.js.map +1 -0
  16. package/out/breakpoint/generator/FragmentNode.d.ts +4 -0
  17. package/out/breakpoint/generator/FragmentNode.js +18 -0
  18. package/out/breakpoint/generator/FragmentNode.js.map +1 -0
  19. package/out/breakpoint/generator/index.js +25 -4
  20. package/out/breakpoint/generator/index.js.map +1 -1
  21. package/out/breakpoint/shared/constants.d.ts +3 -0
  22. package/out/breakpoint/shared/constants.js +6 -1
  23. package/out/breakpoint/shared/constants.js.map +1 -1
  24. package/out/breakpoint/shared/operations.js.map +1 -1
  25. package/out/breakpoint/shared/socket.d.ts +1 -1
  26. package/out/breakpoint/shared/socket.js +36 -7
  27. package/out/breakpoint/shared/socket.js.map +1 -1
  28. package/out/breakpoint/shared/utils.d.ts +2 -0
  29. package/out/breakpoint/shared/utils.js +15 -2
  30. package/out/breakpoint/shared/utils.js.map +1 -1
  31. package/out/breakpoint/store/core.d.ts +48 -2
  32. package/out/breakpoint/store/core.js +58 -32
  33. package/out/breakpoint/store/core.js.map +1 -1
  34. package/out/breakpoint/store/dock.js +1 -1
  35. package/out/breakpoint/store/dock.js.map +1 -1
  36. package/out/common/BaseNode.d.ts +2 -2
  37. package/out/common/BaseNode.js +110 -53
  38. package/out/common/BaseNode.js.map +1 -1
  39. package/out/common/Command.d.ts +13 -2
  40. package/out/common/Command.js +37 -9
  41. package/out/common/Command.js.map +1 -1
  42. package/out/common/EventEmitter.js.map +1 -1
  43. package/out/common/Messager.d.ts +3 -3
  44. package/out/common/Messager.js +6 -7
  45. package/out/common/Messager.js.map +1 -1
  46. package/out/common/asyncFuncMap.js.map +1 -1
  47. package/out/concepts/Abort__.js +6 -5
  48. package/out/concepts/Abort__.js.map +1 -1
  49. package/out/concepts/Anchor__.d.ts +4 -3
  50. package/out/concepts/Anchor__.js +24 -7
  51. package/out/concepts/Anchor__.js.map +1 -1
  52. package/out/concepts/AnonymousFunction__.d.ts +22 -21
  53. package/out/concepts/AnonymousFunction__.js +48 -22
  54. package/out/concepts/AnonymousFunction__.js.map +1 -1
  55. package/out/concepts/App__.d.ts +421 -247
  56. package/out/concepts/App__.js +288 -54
  57. package/out/concepts/App__.js.map +1 -1
  58. package/out/concepts/Argument__.d.ts +4 -3
  59. package/out/concepts/Argument__.js +42 -11
  60. package/out/concepts/Argument__.js.map +1 -1
  61. package/out/concepts/Assignee__.d.ts +45 -45
  62. package/out/concepts/Assignee__.js +15 -15
  63. package/out/concepts/Assignee__.js.map +1 -1
  64. package/out/concepts/AssignmentLine__.js +6 -5
  65. package/out/concepts/AssignmentLine__.js.map +1 -1
  66. package/out/concepts/Assignment__.d.ts +7 -6
  67. package/out/concepts/Assignment__.js +41 -23
  68. package/out/concepts/Assignment__.js.map +1 -1
  69. package/out/concepts/Attribute__.d.ts +3 -3
  70. package/out/concepts/Attribute__.js +8 -7
  71. package/out/concepts/Attribute__.js.map +1 -1
  72. package/out/concepts/AuthInterface__.js +4 -3
  73. package/out/concepts/AuthInterface__.js.map +1 -1
  74. package/out/concepts/AuthLogicForCallInterface__.d.ts +15 -15
  75. package/out/concepts/AuthLogicForCallInterface__.js +46 -27
  76. package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
  77. package/out/concepts/AuthLogic__.js +27 -13
  78. package/out/concepts/AuthLogic__.js.map +1 -1
  79. package/out/concepts/BackendVariable__.d.ts +5 -5
  80. package/out/concepts/BackendVariable__.js +23 -26
  81. package/out/concepts/BackendVariable__.js.map +1 -1
  82. package/out/concepts/Backend__.d.ts +18 -18
  83. package/out/concepts/Backend__.js +13 -13
  84. package/out/concepts/Backend__.js.map +1 -1
  85. package/out/concepts/BatchAssignment__.d.ts +34 -33
  86. package/out/concepts/BatchAssignment__.js +83 -43
  87. package/out/concepts/BatchAssignment__.js.map +1 -1
  88. package/out/concepts/BinaryExpression__.d.ts +7 -6
  89. package/out/concepts/BinaryExpression__.js +60 -24
  90. package/out/concepts/BinaryExpression__.js.map +1 -1
  91. package/out/concepts/BindAttribute__.d.ts +37 -37
  92. package/out/concepts/BindAttribute__.js +102 -58
  93. package/out/concepts/BindAttribute__.js.map +1 -1
  94. package/out/concepts/BindDirective__.d.ts +13 -13
  95. package/out/concepts/BindDirective__.js +23 -21
  96. package/out/concepts/BindDirective__.js.map +1 -1
  97. package/out/concepts/BindEvent__.d.ts +28 -28
  98. package/out/concepts/BindEvent__.js +150 -57
  99. package/out/concepts/BindEvent__.js.map +1 -1
  100. package/out/concepts/BindStyle__.d.ts +14 -15
  101. package/out/concepts/BindStyle__.js +16 -16
  102. package/out/concepts/BindStyle__.js.map +1 -1
  103. package/out/concepts/BooleanLiteral__.d.ts +1 -0
  104. package/out/concepts/BooleanLiteral__.js +12 -5
  105. package/out/concepts/BooleanLiteral__.js.map +1 -1
  106. package/out/concepts/CallAuthInterface__.d.ts +15 -15
  107. package/out/concepts/CallAuthInterface__.js +23 -22
  108. package/out/concepts/CallAuthInterface__.js.map +1 -1
  109. package/out/concepts/CallConnector__.d.ts +11 -9
  110. package/out/concepts/CallConnector__.js +79 -36
  111. package/out/concepts/CallConnector__.js.map +1 -1
  112. package/out/concepts/CallFunction__.d.ts +17 -16
  113. package/out/concepts/CallFunction__.js +95 -63
  114. package/out/concepts/CallFunction__.js.map +1 -1
  115. package/out/concepts/CallInterface__.d.ts +9 -8
  116. package/out/concepts/CallInterface__.js +109 -80
  117. package/out/concepts/CallInterface__.js.map +1 -1
  118. package/out/concepts/CallLogic__.d.ts +24 -20
  119. package/out/concepts/CallLogic__.js +209 -162
  120. package/out/concepts/CallLogic__.js.map +1 -1
  121. package/out/concepts/CallQueryComponent__.d.ts +51 -51
  122. package/out/concepts/CallQueryComponent__.js +66 -63
  123. package/out/concepts/CallQueryComponent__.js.map +1 -1
  124. package/out/concepts/Comment__.d.ts +1 -0
  125. package/out/concepts/Comment__.js +13 -6
  126. package/out/concepts/Comment__.js.map +1 -1
  127. package/out/concepts/CompletionProperty__.d.ts +3 -3
  128. package/out/concepts/CompletionProperty__.js +16 -8
  129. package/out/concepts/CompletionProperty__.js.map +1 -1
  130. package/out/concepts/ConfigGroup__.d.ts +15 -15
  131. package/out/concepts/ConfigGroup__.js +9 -9
  132. package/out/concepts/ConfigGroup__.js.map +1 -1
  133. package/out/concepts/ConfigPropertyValue__.js +4 -3
  134. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  135. package/out/concepts/ConfigProperty__.d.ts +15 -15
  136. package/out/concepts/ConfigProperty__.js +10 -10
  137. package/out/concepts/ConfigProperty__.js.map +1 -1
  138. package/out/concepts/Configuration__.d.ts +15 -15
  139. package/out/concepts/Configuration__.js +9 -9
  140. package/out/concepts/Configuration__.js.map +1 -1
  141. package/out/concepts/Connection__.d.ts +166 -0
  142. package/out/concepts/Connection__.js +332 -0
  143. package/out/concepts/Connection__.js.map +1 -0
  144. package/out/concepts/ConnectorTrigger__.js +4 -3
  145. package/out/concepts/ConnectorTrigger__.js.map +1 -1
  146. package/out/concepts/Connector__.d.ts +66 -66
  147. package/out/concepts/Connector__.js +16 -15
  148. package/out/concepts/Connector__.js.map +1 -1
  149. package/out/concepts/Constant__.d.ts +3 -3
  150. package/out/concepts/Constant__.js +8 -7
  151. package/out/concepts/Constant__.js.map +1 -1
  152. package/out/concepts/DataElement__.d.ts +3 -3
  153. package/out/concepts/DataElement__.js +6 -5
  154. package/out/concepts/DataElement__.js.map +1 -1
  155. package/out/concepts/DataSource__.d.ts +15 -15
  156. package/out/concepts/DataSource__.js +55 -39
  157. package/out/concepts/DataSource__.js.map +1 -1
  158. package/out/concepts/DatabaseTypeAnnotation__.js +4 -3
  159. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
  160. package/out/concepts/Destination__.d.ts +12 -11
  161. package/out/concepts/Destination__.js +93 -36
  162. package/out/concepts/Destination__.js.map +1 -1
  163. package/out/concepts/End__.js +15 -13
  164. package/out/concepts/End__.js.map +1 -1
  165. package/out/concepts/EntityIndex__.d.ts +1 -1
  166. package/out/concepts/EntityIndex__.js +6 -5
  167. package/out/concepts/EntityIndex__.js.map +1 -1
  168. package/out/concepts/EntityProperty__.d.ts +8 -7
  169. package/out/concepts/EntityProperty__.js +39 -24
  170. package/out/concepts/EntityProperty__.js.map +1 -1
  171. package/out/concepts/Entity__.d.ts +31 -30
  172. package/out/concepts/Entity__.js +40 -16
  173. package/out/concepts/Entity__.js.map +1 -1
  174. package/out/concepts/EnumItem__.d.ts +1 -0
  175. package/out/concepts/EnumItem__.js +12 -5
  176. package/out/concepts/EnumItem__.js.map +1 -1
  177. package/out/concepts/Enum__.d.ts +9 -8
  178. package/out/concepts/Enum__.js +24 -11
  179. package/out/concepts/Enum__.js.map +1 -1
  180. package/out/concepts/Event__.d.ts +15 -15
  181. package/out/concepts/Event__.js +6 -5
  182. package/out/concepts/Event__.js.map +1 -1
  183. package/out/concepts/ExternalDestination__.d.ts +6 -6
  184. package/out/concepts/ExternalDestination__.js +12 -11
  185. package/out/concepts/ExternalDestination__.js.map +1 -1
  186. package/out/concepts/ForEachStatement__.d.ts +25 -24
  187. package/out/concepts/ForEachStatement__.js +101 -36
  188. package/out/concepts/ForEachStatement__.js.map +1 -1
  189. package/out/concepts/FrontendLibrary__.d.ts +30 -30
  190. package/out/concepts/FrontendLibrary__.js +12 -13
  191. package/out/concepts/FrontendLibrary__.js.map +1 -1
  192. package/out/concepts/FrontendVariable__.js +4 -3
  193. package/out/concepts/FrontendVariable__.js.map +1 -1
  194. package/out/concepts/Frontend__.d.ts +64 -65
  195. package/out/concepts/Frontend__.js +23 -27
  196. package/out/concepts/Frontend__.js.map +1 -1
  197. package/out/concepts/Function__.d.ts +64 -63
  198. package/out/concepts/Function__.js +49 -21
  199. package/out/concepts/Function__.js.map +1 -1
  200. package/out/concepts/Identifier__.js +37 -31
  201. package/out/concepts/Identifier__.js.map +1 -1
  202. package/out/concepts/IfStatement__.d.ts +20 -19
  203. package/out/concepts/IfStatement__.js +64 -34
  204. package/out/concepts/IfStatement__.js.map +1 -1
  205. package/out/concepts/Integration__.d.ts +3 -3
  206. package/out/concepts/Integration__.js +8 -7
  207. package/out/concepts/Integration__.js.map +1 -1
  208. package/out/concepts/InterfaceParam__.d.ts +3 -3
  209. package/out/concepts/InterfaceParam__.js +7 -6
  210. package/out/concepts/InterfaceParam__.js.map +1 -1
  211. package/out/concepts/Interface__.d.ts +33 -33
  212. package/out/concepts/Interface__.js +19 -20
  213. package/out/concepts/Interface__.js.map +1 -1
  214. package/out/concepts/JSBlock__.d.ts +1 -0
  215. package/out/concepts/JSBlock__.js +12 -5
  216. package/out/concepts/JSBlock__.js.map +1 -1
  217. package/out/concepts/JavaLogic__.js +10 -9
  218. package/out/concepts/JavaLogic__.js.map +1 -1
  219. package/out/concepts/LogicItem__.d.ts +6 -0
  220. package/out/concepts/LogicItem__.js +14 -5
  221. package/out/concepts/LogicItem__.js.map +1 -1
  222. package/out/concepts/Logic__.d.ts +80 -79
  223. package/out/concepts/Logic__.js +204 -58
  224. package/out/concepts/Logic__.js.map +1 -1
  225. package/out/concepts/MatchCase__.d.ts +39 -38
  226. package/out/concepts/MatchCase__.js +122 -37
  227. package/out/concepts/MatchCase__.js.map +1 -1
  228. package/out/concepts/Match__.d.ts +13 -11
  229. package/out/concepts/Match__.js +128 -60
  230. package/out/concepts/Match__.js.map +1 -1
  231. package/out/concepts/MemberExpression__.d.ts +7 -6
  232. package/out/concepts/MemberExpression__.js +52 -22
  233. package/out/concepts/MemberExpression__.js.map +1 -1
  234. package/out/concepts/MicroApp__.js +4 -3
  235. package/out/concepts/MicroApp__.js.map +1 -1
  236. package/out/concepts/Module__.d.ts +242 -154
  237. package/out/concepts/Module__.js +139 -33
  238. package/out/concepts/Module__.js.map +1 -1
  239. package/out/concepts/MsgTriggerEvent__.d.ts +15 -15
  240. package/out/concepts/MsgTriggerEvent__.js +6 -5
  241. package/out/concepts/MsgTriggerEvent__.js.map +1 -1
  242. package/out/concepts/MsgTriggerLauncher__.d.ts +23 -15
  243. package/out/concepts/MsgTriggerLauncher__.js +24 -5
  244. package/out/concepts/MsgTriggerLauncher__.js.map +1 -1
  245. package/out/concepts/Namespace__.d.ts +180 -180
  246. package/out/concepts/Namespace__.js +33 -34
  247. package/out/concepts/Namespace__.js.map +1 -1
  248. package/out/concepts/NewComposite__.d.ts +49 -48
  249. package/out/concepts/NewComposite__.js +164 -49
  250. package/out/concepts/NewComposite__.js.map +1 -1
  251. package/out/concepts/NewList__.d.ts +19 -18
  252. package/out/concepts/NewList__.js +29 -12
  253. package/out/concepts/NewList__.js.map +1 -1
  254. package/out/concepts/NewMap__.d.ts +34 -33
  255. package/out/concepts/NewMap__.js +81 -72
  256. package/out/concepts/NewMap__.js.map +1 -1
  257. package/out/concepts/New__.js +6 -5
  258. package/out/concepts/New__.js.map +1 -1
  259. package/out/concepts/NullLiteral__.js +6 -5
  260. package/out/concepts/NullLiteral__.js.map +1 -1
  261. package/out/concepts/NumericLiteral__.d.ts +4 -3
  262. package/out/concepts/NumericLiteral__.js +15 -8
  263. package/out/concepts/NumericLiteral__.js.map +1 -1
  264. package/out/concepts/OqlQueryComponent__.d.ts +4 -3
  265. package/out/concepts/OqlQueryComponent__.js +25 -16
  266. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  267. package/out/concepts/OverriddenLogic__.d.ts +79 -79
  268. package/out/concepts/OverriddenLogic__.js +79 -58
  269. package/out/concepts/OverriddenLogic__.js.map +1 -1
  270. package/out/concepts/Param__.d.ts +6 -5
  271. package/out/concepts/Param__.js +66 -29
  272. package/out/concepts/Param__.js.map +1 -1
  273. package/out/concepts/Point__.js +4 -3
  274. package/out/concepts/Point__.js.map +1 -1
  275. package/out/concepts/ProcessComponent__.d.ts +30 -30
  276. package/out/concepts/ProcessComponent__.js +8 -7
  277. package/out/concepts/ProcessComponent__.js.map +1 -1
  278. package/out/concepts/ProcessElement__.d.ts +96 -96
  279. package/out/concepts/ProcessElement__.js +34 -34
  280. package/out/concepts/ProcessElement__.js.map +1 -1
  281. package/out/concepts/ProcessOutcome__.js +6 -5
  282. package/out/concepts/ProcessOutcome__.js.map +1 -1
  283. package/out/concepts/ProcessOutcomes__.js +6 -5
  284. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  285. package/out/concepts/Process__.d.ts +75 -75
  286. package/out/concepts/Process__.js +33 -30
  287. package/out/concepts/Process__.js.map +1 -1
  288. package/out/concepts/QueryAggregateExpression__.d.ts +3 -3
  289. package/out/concepts/QueryAggregateExpression__.js +8 -7
  290. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  291. package/out/concepts/QueryFieldExpression__.js +7 -6
  292. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  293. package/out/concepts/QueryFromExpression__.d.ts +8 -8
  294. package/out/concepts/QueryFromExpression__.js +8 -7
  295. package/out/concepts/QueryFromExpression__.js.map +1 -1
  296. package/out/concepts/QueryGroupByExpression__.d.ts +3 -3
  297. package/out/concepts/QueryGroupByExpression__.js +9 -10
  298. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  299. package/out/concepts/QueryJoinExpression__.d.ts +23 -23
  300. package/out/concepts/QueryJoinExpression__.js +11 -10
  301. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  302. package/out/concepts/QueryLimitExpression__.d.ts +6 -6
  303. package/out/concepts/QueryLimitExpression__.js +9 -8
  304. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  305. package/out/concepts/QueryOrderByExpression__.d.ts +6 -6
  306. package/out/concepts/QueryOrderByExpression__.js +9 -8
  307. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  308. package/out/concepts/QuerySelectExpression__.d.ts +30 -30
  309. package/out/concepts/QuerySelectExpression__.js +9 -8
  310. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  311. package/out/concepts/Rect__.js +4 -3
  312. package/out/concepts/Rect__.js.map +1 -1
  313. package/out/concepts/Return__.d.ts +4 -3
  314. package/out/concepts/Return__.js +37 -18
  315. package/out/concepts/Return__.js.map +1 -1
  316. package/out/concepts/Role__.js +9 -9
  317. package/out/concepts/Role__.js.map +1 -1
  318. package/out/concepts/SelectMembers__.d.ts +18 -18
  319. package/out/concepts/SelectMembers__.js +10 -9
  320. package/out/concepts/SelectMembers__.js.map +1 -1
  321. package/out/concepts/Slot__.d.ts +3 -3
  322. package/out/concepts/Slot__.js +6 -5
  323. package/out/concepts/Slot__.js.map +1 -1
  324. package/out/concepts/SqlQueryComponent__.d.ts +4 -3
  325. package/out/concepts/SqlQueryComponent__.js +21 -12
  326. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  327. package/out/concepts/Start__.js +6 -5
  328. package/out/concepts/Start__.js.map +1 -1
  329. package/out/concepts/StringInterpolation__.d.ts +16 -15
  330. package/out/concepts/StringInterpolation__.js +37 -14
  331. package/out/concepts/StringInterpolation__.js.map +1 -1
  332. package/out/concepts/StringLiteral__.d.ts +1 -0
  333. package/out/concepts/StringLiteral__.js +13 -8
  334. package/out/concepts/StringLiteral__.js.map +1 -1
  335. package/out/concepts/StructureProperty__.d.ts +4 -3
  336. package/out/concepts/StructureProperty__.js +22 -9
  337. package/out/concepts/StructureProperty__.js.map +1 -1
  338. package/out/concepts/Structure__.d.ts +31 -30
  339. package/out/concepts/Structure__.js +27 -15
  340. package/out/concepts/Structure__.js.map +1 -1
  341. package/out/concepts/SwitchCase__.d.ts +12 -11
  342. package/out/concepts/SwitchCase__.js +69 -31
  343. package/out/concepts/SwitchCase__.js.map +1 -1
  344. package/out/concepts/SwitchStatement__.d.ts +9 -8
  345. package/out/concepts/SwitchStatement__.js +27 -7
  346. package/out/concepts/SwitchStatement__.js.map +1 -1
  347. package/out/concepts/Theme__.js +4 -3
  348. package/out/concepts/Theme__.js.map +1 -1
  349. package/out/concepts/Transactional__.js +4 -3
  350. package/out/concepts/Transactional__.js.map +1 -1
  351. package/out/concepts/TriggerEvent__.d.ts +15 -15
  352. package/out/concepts/TriggerEvent__.js +6 -5
  353. package/out/concepts/TriggerEvent__.js.map +1 -1
  354. package/out/concepts/TriggerLauncher__.d.ts +15 -10
  355. package/out/concepts/TriggerLauncher__.js +54 -32
  356. package/out/concepts/TriggerLauncher__.js.map +1 -1
  357. package/out/concepts/TypeAnnotation__.d.ts +28 -27
  358. package/out/concepts/TypeAnnotation__.js +144 -124
  359. package/out/concepts/TypeAnnotation__.js.map +1 -1
  360. package/out/concepts/TypeParam__.d.ts +1 -0
  361. package/out/concepts/TypeParam__.js +12 -5
  362. package/out/concepts/TypeParam__.js.map +1 -1
  363. package/out/concepts/UnaryExpression__.d.ts +4 -3
  364. package/out/concepts/UnaryExpression__.js +31 -20
  365. package/out/concepts/UnaryExpression__.js.map +1 -1
  366. package/out/concepts/Unparsed__.d.ts +1 -0
  367. package/out/concepts/Unparsed__.js +12 -5
  368. package/out/concepts/Unparsed__.js.map +1 -1
  369. package/out/concepts/UseComponent__.js +4 -3
  370. package/out/concepts/UseComponent__.js.map +1 -1
  371. package/out/concepts/ValidationRule__.d.ts +14 -14
  372. package/out/concepts/ValidationRule__.js +19 -17
  373. package/out/concepts/ValidationRule__.js.map +1 -1
  374. package/out/concepts/Variable__.d.ts +4 -3
  375. package/out/concepts/Variable__.js +39 -23
  376. package/out/concepts/Variable__.js.map +1 -1
  377. package/out/concepts/ViewBlock__.js +4 -3
  378. package/out/concepts/ViewBlock__.js.map +1 -1
  379. package/out/concepts/ViewComponent__.d.ts +90 -90
  380. package/out/concepts/ViewComponent__.js +16 -15
  381. package/out/concepts/ViewComponent__.js.map +1 -1
  382. package/out/concepts/ViewElement__.d.ts +92 -86
  383. package/out/concepts/ViewElement__.js +258 -200
  384. package/out/concepts/ViewElement__.js.map +1 -1
  385. package/out/concepts/View__.d.ts +92 -92
  386. package/out/concepts/View__.js +173 -63
  387. package/out/concepts/View__.js.map +1 -1
  388. package/out/concepts/WhileStatement__.d.ts +12 -11
  389. package/out/concepts/WhileStatement__.js +46 -23
  390. package/out/concepts/WhileStatement__.js.map +1 -1
  391. package/out/concepts/basics/stdlib/index.js +17 -1
  392. package/out/concepts/basics/stdlib/index.js.map +1 -1
  393. package/out/concepts/basics/stdlib/nasl.browser.js +36 -0
  394. package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
  395. package/out/concepts/basics/stdlib/nasl.event.d.ts +3 -0
  396. package/out/concepts/basics/stdlib/nasl.event.js +23 -0
  397. package/out/concepts/basics/stdlib/nasl.event.js.map +1 -0
  398. package/out/concepts/basics/stdlib/nasl.ui.js +45 -0
  399. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  400. package/out/concepts/basics/stdlib/nasl.util.js +6 -22
  401. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  402. package/out/concepts/index__.d.ts +2 -1
  403. package/out/concepts/index__.js +2 -1
  404. package/out/concepts/index__.js.map +1 -1
  405. package/out/concepts/types__.d.ts +2 -1
  406. package/out/decorators/index.d.ts +1 -1
  407. package/out/decorators/index.js +20 -7
  408. package/out/decorators/index.js.map +1 -1
  409. package/out/decorators/promise.d.ts +7 -0
  410. package/out/decorators/promise.js +28 -0
  411. package/out/decorators/promise.js.map +1 -0
  412. package/out/enums/KEYWORDS.js.map +1 -1
  413. package/out/enums/LEVEL_NAME_MAP.js.map +1 -1
  414. package/out/generator/compileComponent.js.map +1 -1
  415. package/out/generator/genBundleFiles.d.ts +4 -1
  416. package/out/generator/genBundleFiles.js +15 -11
  417. package/out/generator/genBundleFiles.js.map +1 -1
  418. package/out/generator/genHash.js.map +1 -1
  419. package/out/generator/genMetaData.js +12 -8
  420. package/out/generator/genMetaData.js.map +1 -1
  421. package/out/generator/genReleaseBody.js +33 -35
  422. package/out/generator/genReleaseBody.js.map +1 -1
  423. package/out/generator/microApp.js +2 -1
  424. package/out/generator/microApp.js.map +1 -1
  425. package/out/generator/permission.js +31 -30
  426. package/out/generator/permission.js.map +1 -1
  427. package/out/generator/styleReplacer.js +4 -7
  428. package/out/generator/styleReplacer.js.map +1 -1
  429. package/out/index.d.ts +0 -2
  430. package/out/index.js +0 -3
  431. package/out/index.js.map +1 -1
  432. package/out/manager/diagnostic.d.ts +1 -1
  433. package/out/manager/diagnostic.js.map +1 -1
  434. package/out/manager/stepRecorder.js +13 -9
  435. package/out/manager/stepRecorder.js.map +1 -1
  436. package/out/natural/RequirementAnalyzer.d.ts +22 -0
  437. package/out/natural/RequirementAnalyzer.js +196 -0
  438. package/out/natural/RequirementAnalyzer.js.map +1 -0
  439. package/out/natural/RequirementExecutor.d.ts +51 -0
  440. package/out/natural/RequirementExecutor.js +692 -0
  441. package/out/natural/RequirementExecutor.js.map +1 -0
  442. package/out/natural/componentData.d.ts +31 -0
  443. package/out/natural/componentData.js +85 -0
  444. package/out/natural/componentData.js.map +1 -0
  445. package/out/natural/genNaturalTS.d.ts +3 -0
  446. package/out/natural/genNaturalTS.js +76 -0
  447. package/out/natural/genNaturalTS.js.map +1 -0
  448. package/out/natural/index.d.ts +4 -0
  449. package/out/natural/index.js +21 -0
  450. package/out/natural/index.js.map +1 -0
  451. package/out/natural/knowledgeMap.d.ts +4 -0
  452. package/out/natural/knowledgeMap.js +40 -0
  453. package/out/natural/knowledgeMap.js.map +1 -0
  454. package/out/natural/naslStdlibMap.d.ts +2 -0
  455. package/out/natural/naslStdlibMap.js +26 -0
  456. package/out/natural/naslStdlibMap.js.map +1 -0
  457. package/out/natural/transformTSCode.d.ts +7 -0
  458. package/out/natural/transformTSCode.js +760 -0
  459. package/out/natural/transformTSCode.js.map +1 -0
  460. package/out/sentry/index.d.ts +2 -1
  461. package/out/sentry/index.js.map +1 -1
  462. package/out/server/createUiTs.js +28 -16
  463. package/out/server/createUiTs.js.map +1 -1
  464. package/out/server/entity2LogicNamespace.js +24 -22
  465. package/out/server/entity2LogicNamespace.js.map +1 -1
  466. package/out/server/event.d.ts +12 -0
  467. package/out/server/event.js +52 -28
  468. package/out/server/event.js.map +1 -1
  469. package/out/server/extendBaseNode.js +55 -70
  470. package/out/server/extendBaseNode.js.map +1 -1
  471. package/out/server/formatTsUtils.js +46 -50
  472. package/out/server/formatTsUtils.js.map +1 -1
  473. package/out/server/getConnector.d.ts +3 -3
  474. package/out/server/getConnector.js +7 -8
  475. package/out/server/getConnector.js.map +1 -1
  476. package/out/server/getExtensionModules.js +2 -2
  477. package/out/server/getExtensionModules.js.map +1 -1
  478. package/out/server/getFunctions.js.map +1 -1
  479. package/out/server/getInterfaces.js.map +1 -1
  480. package/out/server/getLogging.js.map +1 -1
  481. package/out/server/getLogics.d.ts +1 -1
  482. package/out/server/getLogics.js +55 -8
  483. package/out/server/getLogics.js.map +1 -1
  484. package/out/server/getMemberIdentifier.js +13 -10
  485. package/out/server/getMemberIdentifier.js.map +1 -1
  486. package/out/server/getProcessComponents.js.map +1 -1
  487. package/out/server/getProcesses.js +21 -29
  488. package/out/server/getProcesses.js.map +1 -1
  489. package/out/server/getScope.js.map +1 -1
  490. package/out/server/getValidates.js.map +1 -1
  491. package/out/server/index.js +0 -1
  492. package/out/server/index.js.map +1 -1
  493. package/out/server/naslServer.d.ts +99 -94
  494. package/out/server/naslServer.js +490 -469
  495. package/out/server/naslServer.js.map +1 -1
  496. package/out/server/naslStdlibMap.js +6 -2
  497. package/out/server/naslStdlibMap.js.map +1 -1
  498. package/out/server/process2LogicNamespace.js.map +1 -1
  499. package/out/server/translator.d.ts +1 -1
  500. package/out/server/translator.js +52 -47
  501. package/out/server/translator.js.map +1 -1
  502. package/out/service/storage/init.d.ts +15 -1
  503. package/out/service/storage/init.js +65 -56
  504. package/out/service/storage/init.js.map +1 -1
  505. package/out/templator/genCallComponentLogic.js +1 -2
  506. package/out/templator/genCallComponentLogic.js.map +1 -1
  507. package/out/templator/genCreateBlock.js +14 -9
  508. package/out/templator/genCreateBlock.js.map +1 -1
  509. package/out/templator/genCurdEditMultipleKeyBlock.js +23 -14
  510. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  511. package/out/templator/genCurdMultipleKeyBlock.js +26 -30
  512. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  513. package/out/templator/genEditTableBlock.d.ts +1 -1
  514. package/out/templator/genEditTableBlock.js +14 -19
  515. package/out/templator/genEditTableBlock.js.map +1 -1
  516. package/out/templator/genEnumSelectBlock.js +1 -1
  517. package/out/templator/genEnumSelectBlock.js.map +1 -1
  518. package/out/templator/genGetBlock.js +2 -2
  519. package/out/templator/genGetBlock.js.map +1 -1
  520. package/out/templator/genGridViewBlock.d.ts +2 -2
  521. package/out/templator/genGridViewBlock.js +18 -28
  522. package/out/templator/genGridViewBlock.js.map +1 -1
  523. package/out/templator/genListViewBlock.d.ts +2 -2
  524. package/out/templator/genListViewBlock.js +9 -16
  525. package/out/templator/genListViewBlock.js.map +1 -1
  526. package/out/templator/genQueryComponent.js +22 -15
  527. package/out/templator/genQueryComponent.js.map +1 -1
  528. package/out/templator/genSelectBlock.d.ts +2 -2
  529. package/out/templator/genSelectBlock.js +21 -48
  530. package/out/templator/genSelectBlock.js.map +1 -1
  531. package/out/templator/genTableBlock.d.ts +1 -1
  532. package/out/templator/genTableBlock.js +11 -17
  533. package/out/templator/genTableBlock.js.map +1 -1
  534. package/out/templator/genUpdateBlock.js +13 -8
  535. package/out/templator/genUpdateBlock.js.map +1 -1
  536. package/out/templator/index.d.ts +4 -2
  537. package/out/templator/index.js +2 -2
  538. package/out/templator/index.js.map +1 -1
  539. package/out/templator/utils.d.ts +9 -2
  540. package/out/templator/utils.js +22 -22
  541. package/out/templator/utils.js.map +1 -1
  542. package/out/translator/index.js +27 -28
  543. package/out/translator/index.js.map +1 -1
  544. package/out/utils/index.d.ts +2 -1
  545. package/out/utils/index.js +8 -14
  546. package/out/utils/index.js.map +1 -1
  547. package/out/utils/logger.js.map +1 -1
  548. package/out/utils/sortTsString.js +3 -1
  549. package/out/utils/sortTsString.js.map +1 -1
  550. package/out/utils/string.js +8 -11
  551. package/out/utils/string.js.map +1 -1
  552. package/out/utils/time-slicing.d.ts +41 -0
  553. package/out/utils/time-slicing.js +81 -0
  554. package/out/utils/time-slicing.js.map +1 -0
  555. package/out/utils/traverse.js +4 -6
  556. package/out/utils/traverse.js.map +1 -1
  557. package/package.json +22 -20
  558. package/sandbox/stdlib/nasl.auth.ts +49 -46
  559. package/sandbox/stdlib/nasl.browser.ts +1 -0
  560. package/sandbox/stdlib/nasl.event.ts +4 -0
  561. package/sandbox/stdlib/nasl.http.ts +29 -31
  562. package/sandbox/stdlib/nasl.ui.definition.ts +13 -1
  563. package/sandbox/stdlib/nasl.ui.ts +11 -0
  564. package/sandbox-natural/stdlib/nasl.core.ts +36 -0
  565. package/sandbox-natural/stdlib/nasl.oql.ts +8 -0
  566. package/sandbox-natural/stdlib/nasl.ui.ts +56 -0
  567. package/sandbox-natural/stdlib/nasl.util.ts +26 -0
  568. package/sandbox-natural/tsconfig.json +12 -0
  569. package/src/automate/engine/utils.js +3 -0
  570. package/src/automate/upgrader/2.20.js +1 -1
  571. package/src/bak/translator.js +92 -99
  572. package/src/breakpoint/generator/AfterStartNode.ts +19 -17
  573. package/src/breakpoint/generator/BeforeEndNode.ts +17 -17
  574. package/src/breakpoint/generator/BreakpointNode.ts +243 -195
  575. package/src/breakpoint/generator/CallbackNode.ts +20 -0
  576. package/src/breakpoint/generator/FragmentNode.ts +14 -0
  577. package/src/breakpoint/generator/index.ts +107 -80
  578. package/src/breakpoint/shared/constants.ts +59 -53
  579. package/src/breakpoint/shared/operations.ts +6 -6
  580. package/src/breakpoint/shared/socket.ts +277 -223
  581. package/src/breakpoint/shared/utils.ts +166 -146
  582. package/src/breakpoint/store/core.ts +326 -297
  583. package/src/breakpoint/store/dock.ts +103 -103
  584. package/src/breakpoint/types/index.d.ts +11 -11
  585. package/src/common/BaseNode.ts +1103 -1020
  586. package/src/common/Command.ts +46 -16
  587. package/src/common/ComponentAPI.ts +72 -72
  588. package/src/common/EventEmitter.ts +80 -76
  589. package/src/common/Messager.ts +223 -224
  590. package/src/common/asyncFuncMap.ts +12 -12
  591. package/src/concepts/Abort__.ts +53 -60
  592. package/src/concepts/Anchor__.ts +158 -149
  593. package/src/concepts/AnonymousFunction__.ts +584 -551
  594. package/src/concepts/App__.ts +4278 -3669
  595. package/src/concepts/Argument__.ts +234 -210
  596. package/src/concepts/Assignee__.ts +680 -656
  597. package/src/concepts/AssignmentLine__.ts +80 -84
  598. package/src/concepts/Assignment__.ts +276 -264
  599. package/src/concepts/Attribute__.ts +183 -184
  600. package/src/concepts/AuthInterface__.ts +61 -63
  601. package/src/concepts/AuthLogicForCallInterface__.ts +540 -511
  602. package/src/concepts/AuthLogic__.ts +210 -194
  603. package/src/concepts/BackendVariable__.ts +414 -415
  604. package/src/concepts/Backend__.ts +317 -303
  605. package/src/concepts/BatchAssignment__.ts +987 -939
  606. package/src/concepts/BinaryExpression__.ts +370 -341
  607. package/src/concepts/BindAttribute__.ts +1056 -1011
  608. package/src/concepts/BindDirective__.ts +540 -542
  609. package/src/concepts/BindEvent__.ts +992 -866
  610. package/src/concepts/BindStyle__.ts +442 -451
  611. package/src/concepts/BooleanLiteral__.ts +89 -90
  612. package/src/concepts/CallAuthInterface__.ts +458 -433
  613. package/src/concepts/CallConnector__.ts +209 -164
  614. package/src/concepts/CallFunction__.ts +600 -600
  615. package/src/concepts/CallInterface__.ts +752 -725
  616. package/src/concepts/CallLogic__.ts +1328 -1236
  617. package/src/concepts/CallQueryComponent__.ts +1580 -1501
  618. package/src/concepts/Comment__.ts +69 -68
  619. package/src/concepts/CompletionProperty__.ts +250 -250
  620. package/src/concepts/ConfigGroup__.ts +312 -296
  621. package/src/concepts/ConfigPropertyValue__.ts +81 -82
  622. package/src/concepts/ConfigProperty__.ts +374 -357
  623. package/src/concepts/Configuration__.ts +288 -276
  624. package/src/concepts/Connection__.ts +426 -0
  625. package/src/concepts/ConnectorTrigger__.ts +146 -142
  626. package/src/concepts/Connector__.ts +1090 -1048
  627. package/src/concepts/Constant__.ts +226 -219
  628. package/src/concepts/DataElement__.ts +108 -115
  629. package/src/concepts/DataSource__.ts +508 -472
  630. package/src/concepts/DatabaseTypeAnnotation__.ts +53 -59
  631. package/src/concepts/Destination__.ts +808 -746
  632. package/src/concepts/End__.ts +85 -89
  633. package/src/concepts/EntityIndex__.ts +206 -202
  634. package/src/concepts/EntityProperty__.ts +825 -791
  635. package/src/concepts/Entity__.ts +921 -864
  636. package/src/concepts/EnumItem__.ts +133 -125
  637. package/src/concepts/Enum__.ts +347 -337
  638. package/src/concepts/Event__.ts +305 -292
  639. package/src/concepts/ExternalDestination__.ts +269 -280
  640. package/src/concepts/ForEachStatement__.ts +583 -531
  641. package/src/concepts/FrontendLibrary__.ts +507 -485
  642. package/src/concepts/FrontendVariable__.ts +44 -49
  643. package/src/concepts/Frontend__.ts +1239 -1187
  644. package/src/concepts/Function__.ts +1110 -1045
  645. package/src/concepts/Identifier__.ts +276 -272
  646. package/src/concepts/IfStatement__.ts +467 -436
  647. package/src/concepts/Integration__.ts +136 -137
  648. package/src/concepts/InterfaceParam__.ts +239 -238
  649. package/src/concepts/Interface__.ts +969 -948
  650. package/src/concepts/JSBlock__.ts +83 -83
  651. package/src/concepts/JavaLogic__.ts +101 -106
  652. package/src/concepts/LogicItem__.ts +307 -237
  653. package/src/concepts/Logic__.ts +2301 -2088
  654. package/src/concepts/MatchCase__.ts +886 -779
  655. package/src/concepts/Match__.ts +728 -659
  656. package/src/concepts/MemberExpression__.ts +330 -311
  657. package/src/concepts/MicroApp__.ts +91 -97
  658. package/src/concepts/Module__.ts +2590 -2275
  659. package/src/concepts/MsgTriggerEvent__.ts +297 -281
  660. package/src/concepts/MsgTriggerLauncher__.ts +286 -256
  661. package/src/concepts/Namespace__.ts +2579 -2466
  662. package/src/concepts/NewComposite__.ts +1487 -1350
  663. package/src/concepts/NewList__.ts +464 -450
  664. package/src/concepts/NewMap__.ts +691 -674
  665. package/src/concepts/New__.ts +42 -49
  666. package/src/concepts/NullLiteral__.ts +66 -72
  667. package/src/concepts/NumericLiteral__.ts +169 -169
  668. package/src/concepts/OqlQueryComponent__.ts +282 -279
  669. package/src/concepts/OverriddenLogic__.ts +2142 -2097
  670. package/src/concepts/Param__.ts +500 -442
  671. package/src/concepts/Point__.ts +53 -59
  672. package/src/concepts/ProcessComponent__.ts +497 -475
  673. package/src/concepts/ProcessElement__.ts +1852 -1780
  674. package/src/concepts/ProcessOutcome__.ts +59 -64
  675. package/src/concepts/ProcessOutcomes__.ts +59 -64
  676. package/src/concepts/Process__.ts +1491 -1428
  677. package/src/concepts/QueryAggregateExpression__.ts +135 -142
  678. package/src/concepts/QueryFieldExpression__.ts +138 -142
  679. package/src/concepts/QueryFromExpression__.ts +246 -254
  680. package/src/concepts/QueryGroupByExpression__.ts +130 -136
  681. package/src/concepts/QueryJoinExpression__.ts +441 -438
  682. package/src/concepts/QueryLimitExpression__.ts +159 -166
  683. package/src/concepts/QueryOrderByExpression__.ts +173 -180
  684. package/src/concepts/QuerySelectExpression__.ts +464 -439
  685. package/src/concepts/Rect__.ts +73 -79
  686. package/src/concepts/Return__.ts +366 -345
  687. package/src/concepts/Role__.ts +146 -147
  688. package/src/concepts/SelectMembers__.ts +358 -350
  689. package/src/concepts/Slot__.ts +152 -153
  690. package/src/concepts/SqlQueryComponent__.ts +230 -228
  691. package/src/concepts/Start__.ts +45 -52
  692. package/src/concepts/StringInterpolation__.ts +323 -296
  693. package/src/concepts/StringLiteral__.ts +113 -115
  694. package/src/concepts/StructureProperty__.ts +306 -295
  695. package/src/concepts/Structure__.ts +615 -578
  696. package/src/concepts/SwitchCase__.ts +326 -290
  697. package/src/concepts/SwitchStatement__.ts +236 -229
  698. package/src/concepts/Theme__.ts +64 -68
  699. package/src/concepts/Transactional__.ts +159 -153
  700. package/src/concepts/TriggerEvent__.ts +285 -274
  701. package/src/concepts/TriggerLauncher__.ts +232 -196
  702. package/src/concepts/TypeAnnotation__.ts +1049 -1011
  703. package/src/concepts/TypeParam__.ts +48 -50
  704. package/src/concepts/UnaryExpression__.ts +163 -153
  705. package/src/concepts/Unparsed__.ts +81 -82
  706. package/src/concepts/UseComponent__.ts +53 -59
  707. package/src/concepts/ValidationRule__.ts +524 -544
  708. package/src/concepts/Variable__.ts +419 -397
  709. package/src/concepts/ViewBlock__.ts +58 -64
  710. package/src/concepts/ViewComponent__.ts +1323 -1261
  711. package/src/concepts/ViewElement__.ts +2537 -2351
  712. package/src/concepts/View__.ts +2461 -2245
  713. package/src/concepts/WhileStatement__.ts +293 -272
  714. package/src/concepts/basics/stdlib/index.ts +17 -1
  715. package/src/concepts/basics/stdlib/nasl.browser.ts +36 -0
  716. package/src/concepts/basics/stdlib/nasl.event.ts +18 -0
  717. package/src/concepts/basics/stdlib/nasl.ui.ts +45 -0
  718. package/src/concepts/basics/stdlib/nasl.util.ts +6 -22
  719. package/src/concepts/index__.ts +2 -1
  720. package/src/concepts/types__.ts +123 -121
  721. package/src/decorators/index.ts +75 -77
  722. package/src/decorators/promise.ts +28 -0
  723. package/src/enums/KEYWORDS.ts +1228 -1228
  724. package/src/enums/LEVEL_NAME_MAP.ts +24 -24
  725. package/src/generator/compileComponent.ts +10 -10
  726. package/src/generator/genBundleFiles.ts +300 -291
  727. package/src/generator/genHash.ts +2 -2
  728. package/src/generator/genMetaData.ts +280 -261
  729. package/src/generator/genReleaseBody.ts +312 -291
  730. package/src/generator/icestark.ts +1 -1
  731. package/src/generator/microApp.ts +17 -20
  732. package/src/generator/permission.ts +241 -232
  733. package/src/generator/qiankun.ts +1 -1
  734. package/src/generator/styleReplacer.ts +28 -31
  735. package/src/index.ts +0 -3
  736. package/src/manager/diagnostic.ts +84 -82
  737. package/src/manager/stepRecorder.ts +106 -94
  738. package/src/natural/RequirementAnalyzer.ts +208 -0
  739. package/src/natural/RequirementExecutor.ts +685 -0
  740. package/src/natural/componentData.ts +81 -0
  741. package/src/natural/genNaturalTS.ts +77 -0
  742. package/src/natural/index.ts +4 -0
  743. package/src/natural/knowledgeMap.ts +39 -0
  744. package/src/natural/naslStdlibMap.ts +24 -0
  745. package/src/natural/transformTSCode.ts +692 -0
  746. package/src/sentry/index.ts +109 -104
  747. package/src/server/createUiTs.ts +190 -184
  748. package/src/server/entity2LogicNamespace.ts +379 -359
  749. package/src/server/event.js +145 -121
  750. package/src/server/extendBaseNode.ts +461 -456
  751. package/src/server/formatTsUtils.ts +712 -713
  752. package/src/server/getConnector.ts +33 -33
  753. package/src/server/getExtensionModules.ts +23 -22
  754. package/src/server/getFunctions.ts +6 -6
  755. package/src/server/getInterfaces.ts +38 -37
  756. package/src/server/getLogging.ts +1 -1
  757. package/src/server/getLogics.ts +391 -312
  758. package/src/server/getMemberIdentifier.ts +286 -281
  759. package/src/server/getProcessComponents.ts +2 -2
  760. package/src/server/getProcesses.ts +548 -534
  761. package/src/server/getScope.ts +51 -51
  762. package/src/server/getValidates.ts +3 -3
  763. package/src/server/index.ts +29 -30
  764. package/src/server/naslServer.ts +4303 -4222
  765. package/src/server/naslStdlibMap.ts +43 -39
  766. package/src/server/process2LogicNamespace.ts +97 -97
  767. package/src/server/translator.ts +740 -746
  768. package/src/service/storage/init.ts +761 -728
  769. package/src/templator/genCallComponentLogic.ts +14 -15
  770. package/src/templator/genCreateBlock.ts +257 -229
  771. package/src/templator/genCurdEditMultipleKeyBlock.ts +333 -317
  772. package/src/templator/genCurdMultipleKeyBlock.ts +503 -475
  773. package/src/templator/genEditTableBlock.ts +194 -187
  774. package/src/templator/genEnumSelectBlock.ts +13 -7
  775. package/src/templator/genGetBlock.ts +57 -55
  776. package/src/templator/genGridViewBlock.ts +195 -211
  777. package/src/templator/genListViewBlock.ts +62 -72
  778. package/src/templator/genQueryComponent.ts +337 -287
  779. package/src/templator/genSelectBlock.ts +283 -297
  780. package/src/templator/genTableBlock.ts +160 -166
  781. package/src/templator/genUpdateBlock.ts +269 -255
  782. package/src/templator/index.ts +4 -4
  783. package/src/templator/utils.ts +491 -463
  784. package/src/translator/index.ts +84 -84
  785. package/src/translator/lsp.ts +22 -22
  786. package/src/translator/tsp.ts +6 -6
  787. package/src/utils/index.ts +115 -117
  788. package/src/utils/logger.ts +3 -4
  789. package/src/utils/sortTsString.ts +34 -32
  790. package/src/utils/string.ts +47 -48
  791. package/src/utils/time-slicing.ts +109 -0
  792. package/src/utils/traverse.ts +114 -126
  793. package/test/concepts/call-interface/__snapshots__/toEmbeddedTS.spec.ts.snap +71 -0
  794. package/test/concepts/call-interface/__snapshots__/toJS.spec.ts.snap +140 -0
  795. package/test/concepts/call-interface/constant.ts +5 -0
  796. package/test/concepts/call-interface/fixtures/only-interface.json +158 -0
  797. package/test/concepts/call-interface/fixtures/with-body-complex-argument.json +455 -0
  798. package/test/concepts/call-interface/fixtures/with-body-no-argument.json +187 -0
  799. package/test/concepts/call-interface/fixtures/with-body-simple-argument.json +225 -0
  800. package/test/concepts/call-interface/fixtures/with-headers-no-argument.json +213 -0
  801. package/test/concepts/call-interface/fixtures/with-headers.json +192 -0
  802. package/test/concepts/call-interface/fixtures/with-query-no-argument.json +213 -0
  803. package/test/concepts/call-interface/fixtures/with-query.json +192 -0
  804. package/test/concepts/call-interface/toEmbeddedTS.spec.ts +14 -0
  805. package/test/concepts/call-interface/toJS.spec.ts +14 -0
  806. package/test/concepts/call-logic/__snapshots__/toEmbeddedTS.spec.ts.snap +74 -0
  807. package/test/concepts/call-logic/__snapshots__/toJS.spec.ts.snap +141 -0
  808. package/test/concepts/call-logic/constant.ts +5 -0
  809. package/test/concepts/call-logic/fixtures/entries-get-with-arguments.json +223 -0
  810. package/test/concepts/call-logic/fixtures/entries-update-with-arguments.json +359 -0
  811. package/test/concepts/call-logic/fixtures/global-logic-argument-no-expression.json +209 -0
  812. package/test/concepts/call-logic/fixtures/global-logic-argument-some-expression.json +311 -0
  813. package/test/concepts/call-logic/fixtures/only-call-logic.json +10 -0
  814. package/test/concepts/call-logic/fixtures/view-buildin-logic-with-argument.json +128 -0
  815. package/test/concepts/call-logic/fixtures/view-component-logic-no-argument.json +126 -0
  816. package/test/concepts/call-logic/fixtures/view-component-with-validation.json +244 -0
  817. package/test/concepts/call-logic/toEmbeddedTS.spec.ts +14 -0
  818. package/test/concepts/call-logic/toJS.spec.ts +14 -0
  819. package/test/concepts/match/__snapshots__/toEmbeddedTS.spec.ts.snap +66 -0
  820. package/test/concepts/match/__snapshots__/toJS.spec.ts.snap +40 -0
  821. package/test/concepts/match/constant.ts +5 -0
  822. package/test/concepts/match/fixtures/isExpression.json +259 -0
  823. package/test/concepts/match/fixtures/lastBodyIf.json +268 -0
  824. package/test/concepts/match/fixtures/noExpression.json +176 -0
  825. package/test/concepts/match/toEmbeddedTS.spec.ts +14 -0
  826. package/test/concepts/match/toJS.spec.ts +14 -0
  827. package/test/concepts/utils.ts +76 -3
  828. package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +3 -3
  829. package/test/concepts/validation-rule/__snapshots__/toJS.spec.ts.snap +16 -0
  830. package/test/concepts/validation-rule/constant.ts +5 -0
  831. package/test/concepts/validation-rule/toEmbeddedTS.spec.ts +10 -17
  832. package/test/concepts/validation-rule/toJS.spec.ts +14 -0
  833. package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +68 -0
  834. package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +44 -0
  835. package/test/concepts/view-element/constant.ts +5 -0
  836. package/test/concepts/view-element/fixtures/default-not-found.json +322 -0
  837. package/test/concepts/view-element/toEmbeddedTS.spec.ts +14 -0
  838. package/test/concepts/view-element/toVue.spec.ts +14 -0
  839. package/test/setup.ts +7 -0
  840. package/ts-worker/src/index.js +0 -2
  841. package/tsconfig.json +21 -21
  842. package/bin/naslc +0 -3
@@ -1,16 +1,23 @@
1
+ import { v4 as uuidv4 } from 'uuid';
1
2
  import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
2
- import { genUserTaskLogic, getPreviousTask, syncMemberExpression, getFlowAfterElements, isFromStartNode, getFlowBeforeElements } from '../server/getProcesses';
3
+ import {
4
+ genUserTaskLogic,
5
+ getPreviousTask,
6
+ syncMemberExpression,
7
+ getFlowAfterElements,
8
+ isFromStartNode,
9
+ getFlowBeforeElements,
10
+ } from '../server/getProcesses';
3
11
  import Namespace from './Namespace__';
4
12
  import View from './View__';
5
- //================================================================================
13
+ //= ===============================================================================
6
14
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
7
15
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
8
- //================================================================================
16
+ //= ===============================================================================
9
17
  import { EventPayload, Params } from '../common/EventEmitter';
10
18
  import { concept, excludedInJSON, property } from '../decorators';
11
19
 
12
20
  import * as utils from '../utils';
13
- import { v4 as uuidv4 } from 'uuid';
14
21
  import BaseNode from '../common/BaseNode';
15
22
  import classMap from '../common/classMap';
16
23
  import BindEvent from './BindEvent__';
@@ -30,1804 +37,1869 @@ import App from './App__';
30
37
  */
31
38
  @concept('流程元素')
32
39
  export class ProcessElement extends BaseNode {
33
- /**
34
- * 产品概念
35
- */
36
- @property()
37
- concept: 'ProcessElement' = 'ProcessElement';
38
-
39
- /**
40
- * 流程元素名称
41
- */
42
- @property()
43
- name: string = undefined;
44
-
45
- /**
46
- * 流程元素标题
47
- */
48
- @property()
49
- title: string = undefined;
50
-
51
- /**
52
- * 流程元素描述
53
- */
54
- @property()
55
- description: string = undefined;
56
-
57
- /**
58
- * 元素绑定事件列表
59
- */
60
- @property('BindEvent')
61
- bindEvents: Array<BindEvent> = [];
62
-
63
- /**
64
- * type
65
- */
66
- @property()
67
- type: string = undefined;
68
-
69
- /**
70
- * sourceRef
71
- */
72
- @property()
73
- sourceRef: string = undefined;
74
-
75
- /**
76
- * targetRef
77
- */
78
- @property()
79
- targetRef: string = undefined;
80
-
81
- /**
82
- * 矩形信息
83
- */
84
- @property('Rect')
85
- bounds: Rect = undefined;
86
-
87
- /**
88
- * 点信息列表
89
- */
90
- @property('Point')
91
- waypoints: Array<Point> = [];
92
-
93
- /**
94
- * flowValue
95
- */
96
- @property()
97
- flowValue: string = undefined;
98
-
99
- /**
100
- * 逻辑
101
- */
102
- @property('Logic')
103
- logic: Logic = undefined;
104
-
105
- /**
106
- * 变量列表
107
- */
108
- @property('Variable')
109
- variables: Array<Variable> = [];
110
-
111
- /**
112
- * 输出参数列表
113
- */
114
- @property('Return')
115
- returns: Array<Return> = [];
116
-
117
- /**
118
- * 常量列表
119
- */
120
- @property('Constant')
121
- constants: Array<Constant> = [];
122
-
123
- /**
124
- * 元素绑定属性列表
125
- */
126
- @property('BindAttribute')
127
- bindAttrs: Array<BindAttribute> = [];
128
-
129
- /**
130
- * 祖先 Process
131
- */
132
- get process() {
133
- return this.getAncestor('Process') as Process;
134
- }
135
- /**
136
- * 祖先 Module
137
- */
138
- get module() {
139
- return this.getAncestor('Module') as Module;
140
- }
141
- /**
142
- * 祖先 App
143
- */
144
- get app() {
145
- return this.getAncestor('App') as App;
146
- }
147
-
148
- /**
149
- * @param source 需要合并的部分参数
150
- */
151
- constructor(source?: Partial<ProcessElement>) {
152
- source = Object.assign({}, ProcessElement.getDefaultOptions(), source);
153
- super(source);
154
- super.subConstructor(source);
155
- }
156
- getClassName() {
157
- return 'ProcessElement';
158
- }
159
-
160
- static from(source: any, parentNode?: any, parentKey?: string): ProcessElement {
161
- return super.from(source, parentNode, parentKey) as ProcessElement;
162
- }
163
-
164
- /**
165
- * 从父级删除该节点
166
- * @internal
167
- */
168
- _delete() {
169
- let params: Params = null;
170
- if (this.parentNode) {
171
- params = (this.parentNode as any)?.__removeProcessElement?.(this);
172
- }
173
- return params;
174
- }
175
- /**
176
- * 设置流程元素名称
177
- */
178
- setName(name: string) {
179
- const object = {
180
- name,
181
- };
182
- this.update({
183
- ...object,
184
- field: 'name',
185
- });
186
- }
187
-
188
- /**
189
- * 设置流程元素标题
190
- */
191
- setTitle(title: string) {
192
- const object = {
193
- title,
194
- };
195
- this.update({
196
- ...object,
197
- });
198
- }
199
-
200
- /**
201
- * 设置流程元素描述
202
- */
203
- setDescription(description: string) {
204
- const object = {
205
- description,
206
- };
207
- this.update({
208
- ...object,
209
- });
210
- }
211
-
212
- /**
213
- * 设置sourceRef
214
- */
215
- setSourceRef(sourceRef: string) {
216
- const object = {
217
- sourceRef,
218
- };
219
- this.update({
220
- ...object,
221
- });
222
- }
223
-
224
- /**
225
- * 设置targetRef
226
- */
227
- setTargetRef(targetRef: string) {
228
- const object = {
229
- targetRef,
230
- };
231
- this.update({
232
- ...object,
233
- });
234
- }
235
-
236
- /**
237
- * 设置矩形信息
238
- */
239
- setBounds(bounds: Rect) {
240
- bounds._delete();
241
- const relationOptions = { parentNode: this, parentKey: 'bounds' };
242
- Object.assign(bounds, relationOptions);
243
- const object = {
244
- bounds,
245
- };
246
- this.update({
247
- ...object,
248
- });
249
- }
250
-
251
- /**
252
- * 设置flowValue
253
- */
254
- setFlowValue(flowValue: string) {
255
- const object = {
256
- flowValue,
257
- };
258
- this.update({
259
- ...object,
260
- });
261
- }
262
-
263
- getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
264
- const excludedSet = new Set(excludedList);
265
- return ((this.bindEvents as BindEvent[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
266
- }
267
- getBindEventUniqueName(name = 'bindEvent1') {
268
- return utils.unique(name, this.getBindEventExistingNames(), undefined, false);
269
- }
270
-
271
- /**
272
- * 插入元素绑定事件
273
- * @internal
274
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
275
- */
276
- _insertBindEventAt(name: string, index: number): BindEvent;
277
-
278
- /**
279
- * 插入元素绑定事件
280
- * @internal
281
- * @param bindEventOptions 元素绑定事件参数
282
- */
283
- _insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
284
-
285
- /**
286
- * 插入元素绑定事件
287
- * @internal
288
- * @param bindEvent 已有的元素绑定事件实例
289
- */
290
- _insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
291
-
292
- _insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
293
- const bindEventOptions: any = {};
294
- const relationOptions = { parentNode: this, parentKey: 'bindEvents' };
295
- let bindEvent: BindEvent;
296
- if (!options) {
297
- bindEvent = BindEvent.from({
298
- ...bindEventOptions,
299
- name: this.getBindEventUniqueName(),
300
- }, this, 'bindEvents');
301
- } else if (typeof options === 'string') {
302
- bindEvent = BindEvent.from({
303
- ...bindEventOptions,
304
- name: options,
305
- }, this, 'bindEvents');
306
- } else if (options instanceof BindEvent) {
307
- options.ensureDelete(); // 同一实例不支持多处存在
308
- bindEvent = options;
309
- Object.assign(bindEvent, relationOptions);
310
- } else {
311
- bindEvent = BindEvent.from({
312
- ...bindEventOptions,
313
- ...options,
314
- }, this, 'bindEvents');
315
- }
316
- this.bindEvents.splice(index, 0, bindEvent);
317
- return bindEvent;
318
- }
319
-
320
- /**
321
- * 插入元素绑定事件
322
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
323
- */
324
- insertBindEventAt(name: string, index: number): BindEvent;
325
-
326
- /**
327
- * 插入元素绑定事件
328
- * @param bindEventOptions 元素绑定事件参数
329
- */
330
- insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
331
-
332
- /**
333
- * 插入元素绑定事件
334
- * @param bindEvent 已有的元素绑定事件实例
335
- */
336
- insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
337
-
338
- insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
339
- const node = this._insertBindEventAt(options as any, index);
340
- node.create({
341
- index,
342
- parentNode: this,
343
- parentKey: 'bindEvents',
344
- });
345
- return node;
346
- }
347
-
348
- /**
349
- * 添加元素绑定事件
350
- * @internal
351
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
352
- */
353
- _addBindEvent(name?: string): BindEvent;
354
-
355
- /**
356
- * 添加元素绑定事件
357
- * @internal
358
- * @param bindEventOptions 元素绑定事件参数
359
- */
360
- _addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
361
-
362
- /**
363
- * 添加元素绑定事件
364
- * @internal
365
- * @param bindEvent 已有的元素绑定事件实例
366
- */
367
- _addBindEvent(bindEvent: BindEvent): BindEvent;
368
-
369
- _addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
370
- const index = this.bindEvents.length;
371
- return this._insertBindEventAt(options as any, index);
372
- }
373
-
374
- /**
375
- * 添加元素绑定事件
376
- * @internal
377
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
378
- */
379
- addBindEvent(name?: string): BindEvent;
380
-
381
- /**
382
- * 添加元素绑定事件
383
- * @param bindEventOptions 元素绑定事件参数
384
- */
385
- addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
386
-
387
- /**
388
- * 添加元素绑定事件
389
- * @param bindEvent 已有的元素绑定事件实例
390
- */
391
- addBindEvent(bindEvent: BindEvent): BindEvent;
392
-
393
- addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
394
- const node = this._addBindEvent(options as any);
395
- const index = this.bindEvents.indexOf(node);
396
- node.create({
397
- index,
398
- parentNode: this,
399
- parentKey: 'bindEvents',
400
- });
401
- return node;
402
- }
403
-
404
-
405
- getPointExistingNames(excludedList: Array<Point> = []) {
406
- const excludedSet = new Set(excludedList);
407
- return ((this.waypoints as Point[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
408
- }
409
- getPointUniqueName(name = 'point1') {
410
- return utils.unique(name, this.getPointExistingNames(), undefined, false);
411
- }
412
-
413
- /**
414
- * 插入点信息
415
- * @internal
416
- * @param name 点信息名称,如果不填会自动生成一个唯一名称
417
- */
418
- _insertPointAt(name: string, index: number): Point;
419
-
420
- /**
421
- * 插入点信息
422
- * @internal
423
- * @param pointOptions 点信息参数
424
- */
425
- _insertPointAt(pointOptions: Partial<Point>, index: number): Point;
426
-
427
- /**
428
- * 插入点信息
429
- * @internal
430
- * @param point 已有的点信息实例
431
- */
432
- _insertPointAt(point: Point, index: number): Point;
433
-
434
- _insertPointAt(options: string | Partial<Point> | Point, index: number) {
435
- const pointOptions: any = {};
436
- const relationOptions = { parentNode: this, parentKey: 'waypoints' };
437
- let point: Point;
438
- if (!options) {
439
- point = Point.from({
440
- ...pointOptions,
441
- name: this.getPointUniqueName(),
442
- }, this, 'waypoints');
443
- } else if (typeof options === 'string') {
444
- point = Point.from({
445
- ...pointOptions,
446
- name: options,
447
- }, this, 'waypoints');
448
- } else if (options instanceof Point) {
449
- options.ensureDelete(); // 同一实例不支持多处存在
450
- point = options;
451
- Object.assign(point, relationOptions);
452
- } else {
453
- point = Point.from({
454
- ...pointOptions,
455
- ...options,
456
- }, this, 'waypoints');
457
- }
458
- this.waypoints.splice(index, 0, point);
459
- return point;
460
- }
461
-
462
- /**
463
- * 插入点信息
464
- * @param name 点信息名称,如果不填会自动生成一个唯一名称
465
- */
466
- insertPointAt(name: string, index: number): Point;
467
-
468
- /**
469
- * 插入点信息
470
- * @param pointOptions 点信息参数
471
- */
472
- insertPointAt(pointOptions: Partial<Point>, index: number): Point;
473
-
474
- /**
475
- * 插入点信息
476
- * @param point 已有的点信息实例
477
- */
478
- insertPointAt(point: Point, index: number): Point;
479
-
480
- insertPointAt(options: string | Partial<Point> | Point, index: number) {
481
- const node = this._insertPointAt(options as any, index);
482
- node.create({
483
- index,
484
- parentNode: this,
485
- parentKey: 'waypoints',
486
- });
487
- return node;
488
- }
489
-
490
- /**
491
- * 添加点信息
492
- * @internal
493
- * @param name 点信息名称,如果不填会自动生成一个唯一名称
494
- */
495
- _addPoint(name?: string): Point;
496
-
497
- /**
498
- * 添加点信息
499
- * @internal
500
- * @param pointOptions 点信息参数
501
- */
502
- _addPoint(pointOptions: Partial<Point>): Point;
503
-
504
- /**
505
- * 添加点信息
506
- * @internal
507
- * @param point 已有的点信息实例
508
- */
509
- _addPoint(point: Point): Point;
510
-
511
- _addPoint(options?: string | Partial<Point> | Point) {
512
- const index = this.waypoints.length;
513
- return this._insertPointAt(options as any, index);
514
- }
515
-
516
- /**
517
- * 添加点信息
518
- * @internal
519
- * @param name 点信息名称,如果不填会自动生成一个唯一名称
520
- */
521
- addPoint(name?: string): Point;
522
-
523
- /**
524
- * 添加点信息
525
- * @param pointOptions 点信息参数
526
- */
527
- addPoint(pointOptions: Partial<Point>): Point;
528
-
529
- /**
530
- * 添加点信息
531
- * @param point 已有的点信息实例
532
- */
533
- addPoint(point: Point): Point;
534
-
535
- addPoint(options?: string | Partial<Point> | Point) {
536
- const node = this._addPoint(options as any);
537
- const index = this.waypoints.indexOf(node);
538
- node.create({
539
- index,
540
- parentNode: this,
541
- parentKey: 'waypoints',
542
- });
543
- return node;
544
- }
545
-
546
-
547
- getVariableExistingNames(excludedList: Array<Variable> = []) {
548
- const excludedSet = new Set(excludedList);
549
- return ((this.variables as Variable[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
550
- }
551
- getVariableUniqueName(name = 'variable1') {
552
- return utils.unique(name, this.getVariableExistingNames(), undefined, false);
553
- }
554
-
555
- /**
556
- * 插入变量
557
- * @internal
558
- * @param name 变量名称,如果不填会自动生成一个唯一名称
559
- */
560
- _insertVariableAt(name: string, index: number): Variable;
561
-
562
- /**
563
- * 插入变量
564
- * @internal
565
- * @param variableOptions 变量参数
566
- */
567
- _insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
568
-
569
- /**
570
- * 插入变量
571
- * @internal
572
- * @param variable 已有的变量实例
573
- */
574
- _insertVariableAt(variable: Variable, index: number): Variable;
575
-
576
- _insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
577
- const variableOptions: any = {};
578
- const relationOptions = { parentNode: this, parentKey: 'variables' };
579
- let variable: Variable;
580
- if (!options) {
581
- variable = Variable.from({
582
- ...variableOptions,
583
- name: this.getVariableUniqueName(),
584
- }, this, 'variables');
585
- } else if (typeof options === 'string') {
586
- variable = Variable.from({
587
- ...variableOptions,
588
- name: options,
589
- }, this, 'variables');
590
- } else if (options instanceof Variable) {
591
- options.ensureDelete(); // 同一实例不支持多处存在
592
- variable = options;
593
- Object.assign(variable, relationOptions);
594
- } else {
595
- variable = Variable.from({
596
- ...variableOptions,
597
- ...options,
598
- }, this, 'variables');
599
- }
600
- this.variables.splice(index, 0, variable);
601
- return variable;
602
- }
603
-
604
- /**
605
- * 插入变量
606
- * @param name 变量名称,如果不填会自动生成一个唯一名称
607
- */
608
- insertVariableAt(name: string, index: number): Variable;
609
-
610
- /**
611
- * 插入变量
612
- * @param variableOptions 变量参数
613
- */
614
- insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
615
-
616
- /**
617
- * 插入变量
618
- * @param variable 已有的变量实例
619
- */
620
- insertVariableAt(variable: Variable, index: number): Variable;
621
-
622
- insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
623
- const node = this._insertVariableAt(options as any, index);
624
- node.create({
625
- index,
626
- parentNode: this,
627
- parentKey: 'variables',
628
- });
629
- return node;
630
- }
631
-
632
- /**
633
- * 添加变量
634
- * @internal
635
- * @param name 变量名称,如果不填会自动生成一个唯一名称
636
- */
637
- _addVariable(name?: string): Variable;
638
-
639
- /**
640
- * 添加变量
641
- * @internal
642
- * @param variableOptions 变量参数
643
- */
644
- _addVariable(variableOptions: Partial<Variable>): Variable;
645
-
646
- /**
647
- * 添加变量
648
- * @internal
649
- * @param variable 已有的变量实例
650
- */
651
- _addVariable(variable: Variable): Variable;
652
-
653
- _addVariable(options?: string | Partial<Variable> | Variable) {
654
- const index = this.variables.length;
655
- return this._insertVariableAt(options as any, index);
656
- }
657
-
658
- /**
659
- * 添加变量
660
- * @internal
661
- * @param name 变量名称,如果不填会自动生成一个唯一名称
662
- */
663
- addVariable(name?: string): Variable;
664
-
665
- /**
666
- * 添加变量
667
- * @param variableOptions 变量参数
668
- */
669
- addVariable(variableOptions: Partial<Variable>): Variable;
670
-
671
- /**
672
- * 添加变量
673
- * @param variable 已有的变量实例
674
- */
675
- addVariable(variable: Variable): Variable;
676
-
677
- addVariable(options?: string | Partial<Variable> | Variable) {
678
- const node = this._addVariable(options as any);
679
- const index = this.variables.indexOf(node);
680
- node.create({
681
- index,
682
- parentNode: this,
683
- parentKey: 'variables',
684
- });
685
- return node;
686
- }
687
-
688
-
689
- getReturnExistingNames(excludedList: Array<Return> = []) {
690
- const excludedSet = new Set(excludedList);
691
- return ((this.returns as Return[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
692
- }
693
- getReturnUniqueName(name = 'ret1') {
694
- return utils.unique(name, this.getReturnExistingNames(), undefined, false);
695
- }
696
-
697
- /**
698
- * 插入输出参数
699
- * @internal
700
- * @param name 输出参数名称,如果不填会自动生成一个唯一名称
701
- */
702
- _insertReturnAt(name: string, index: number): Return;
703
-
704
- /**
705
- * 插入输出参数
706
- * @internal
707
- * @param retOptions 输出参数参数
708
- */
709
- _insertReturnAt(retOptions: Partial<Return>, index: number): Return;
710
-
711
- /**
712
- * 插入输出参数
713
- * @internal
714
- * @param ret 已有的输出参数实例
715
- */
716
- _insertReturnAt(ret: Return, index: number): Return;
717
-
718
- _insertReturnAt(options: string | Partial<Return> | Return, index: number) {
719
- const retOptions: any = {};
720
- const relationOptions = { parentNode: this, parentKey: 'returns' };
721
- let ret: Return;
722
- if (!options) {
723
- ret = Return.from({
724
- ...retOptions,
725
- name: this.getReturnUniqueName(),
726
- }, this, 'returns');
727
- } else if (typeof options === 'string') {
728
- ret = Return.from({
729
- ...retOptions,
730
- name: options,
731
- }, this, 'returns');
732
- } else if (options instanceof Return) {
733
- options.ensureDelete(); // 同一实例不支持多处存在
734
- ret = options;
735
- Object.assign(ret, relationOptions);
736
- } else {
737
- ret = Return.from({
738
- ...retOptions,
739
- ...options,
740
- }, this, 'returns');
741
- }
742
- this.returns.splice(index, 0, ret);
743
- return ret;
744
- }
745
-
746
- /**
747
- * 插入输出参数
748
- * @param name 输出参数名称,如果不填会自动生成一个唯一名称
749
- */
750
- insertReturnAt(name: string, index: number): Return;
751
-
752
- /**
753
- * 插入输出参数
754
- * @param retOptions 输出参数参数
755
- */
756
- insertReturnAt(retOptions: Partial<Return>, index: number): Return;
757
-
758
- /**
759
- * 插入输出参数
760
- * @param ret 已有的输出参数实例
761
- */
762
- insertReturnAt(ret: Return, index: number): Return;
763
-
764
- insertReturnAt(options: string | Partial<Return> | Return, index: number) {
765
- const node = this._insertReturnAt(options as any, index);
766
- node.create({
767
- index,
768
- parentNode: this,
769
- parentKey: 'returns',
770
- });
771
- return node;
772
- }
40
+ /**
41
+ * 产品概念
42
+ */
43
+ @property()
44
+ concept: 'ProcessElement' = 'ProcessElement';
45
+
46
+ /**
47
+ * 流程元素名称
48
+ */
49
+ @property()
50
+ name: string = undefined;
51
+
52
+ /**
53
+ * 流程元素标题
54
+ */
55
+ @property()
56
+ title: string = undefined;
57
+
58
+ /**
59
+ * 流程元素描述
60
+ */
61
+ @property()
62
+ description: string = undefined;
63
+
64
+ /**
65
+ * 元素绑定事件列表
66
+ */
67
+ @property('BindEvent')
68
+ bindEvents: Array<BindEvent> = [];
69
+
70
+ /**
71
+ * type
72
+ */
73
+ @property()
74
+ type: string = undefined;
75
+
76
+ /**
77
+ * sourceRef
78
+ */
79
+ @property()
80
+ sourceRef: string = undefined;
81
+
82
+ /**
83
+ * targetRef
84
+ */
85
+ @property()
86
+ targetRef: string = undefined;
87
+
88
+ /**
89
+ * 矩形信息
90
+ */
91
+ @property('Rect')
92
+ bounds: Rect = undefined;
93
+
94
+ /**
95
+ * 点信息列表
96
+ */
97
+ @property('Point')
98
+ waypoints: Array<Point> = [];
99
+
100
+ /**
101
+ * flowValue
102
+ */
103
+ @property()
104
+ flowValue: string = undefined;
105
+
106
+ /**
107
+ * 逻辑
108
+ */
109
+ @property('Logic')
110
+ logic: Logic = undefined;
111
+
112
+ /**
113
+ * 变量列表
114
+ */
115
+ @property('Variable')
116
+ variables: Array<Variable> = [];
117
+
118
+ /**
119
+ * 输出参数列表
120
+ */
121
+ @property('Return')
122
+ returns: Array<Return> = [];
123
+
124
+ /**
125
+ * 常量列表
126
+ */
127
+ @property('Constant')
128
+ constants: Array<Constant> = [];
129
+
130
+ /**
131
+ * 元素绑定属性列表
132
+ */
133
+ @property('BindAttribute')
134
+ bindAttrs: Array<BindAttribute> = [];
135
+
136
+ /**
137
+ * 祖先 Process
138
+ */
139
+ get process() {
140
+ return this.getAncestor('Process') as Process;
141
+ }
142
+
143
+ /**
144
+ * 祖先 Module
145
+ */
146
+ get module() {
147
+ return this.getAncestor('Module') as Module;
148
+ }
149
+
150
+ /**
151
+ * 祖先 App
152
+ */
153
+ get app() {
154
+ return this.getAncestor('App') as App;
155
+ }
156
+
157
+ /**
158
+ * @param source 需要合并的部分参数
159
+ */
160
+ constructor(source?: Partial<ProcessElement>) {
161
+ // @ts-ignore
162
+ source = { ...ProcessElement.getDefaultOptions(), ...source };
163
+ super(source);
164
+ super.subConstructor(source);
165
+ }
166
+
167
+ getClassName() {
168
+ return 'ProcessElement';
169
+ }
170
+
171
+ static from(source: any, parentNode?: any, parentKey?: string): ProcessElement {
172
+ return super.from(source, parentNode, parentKey) as ProcessElement;
173
+ }
174
+
175
+ /**
176
+ * 从父级删除该节点
177
+ * @internal
178
+ */
179
+ _delete() {
180
+ let params: Params = null;
181
+ if (this.parentNode) {
182
+ params = (this.parentNode as any)?.__removeProcessElement?.(this);
183
+ }
184
+ return params;
185
+ }
186
+
187
+ /**
188
+ * 设置流程元素名称
189
+ */
190
+ setName(name: string) {
191
+ const object = {
192
+ name,
193
+ };
194
+ this.update({
195
+ ...object,
196
+ field: 'name',
197
+ });
198
+ }
773
199
 
774
- /**
775
- * 添加输出参数
776
- * @internal
777
- * @param name 输出参数名称,如果不填会自动生成一个唯一名称
778
- */
779
- _addReturn(name?: string): Return;
780
-
781
- /**
782
- * 添加输出参数
783
- * @internal
784
- * @param retOptions 输出参数参数
785
- */
786
- _addReturn(retOptions: Partial<Return>): Return;
787
-
788
- /**
789
- * 添加输出参数
790
- * @internal
791
- * @param ret 已有的输出参数实例
792
- */
793
- _addReturn(ret: Return): Return;
794
-
795
- _addReturn(options?: string | Partial<Return> | Return) {
796
- const index = this.returns.length;
797
- return this._insertReturnAt(options as any, index);
798
- }
200
+ /**
201
+ * 设置流程元素标题
202
+ */
203
+ setTitle(title: string) {
204
+ const object = {
205
+ title,
206
+ };
207
+ this.update({
208
+ ...object,
209
+ });
210
+ }
799
211
 
800
- /**
801
- * 添加输出参数
802
- * @internal
803
- * @param name 输出参数名称,如果不填会自动生成一个唯一名称
804
- */
805
- addReturn(name?: string): Return;
806
-
807
- /**
808
- * 添加输出参数
809
- * @param retOptions 输出参数参数
810
- */
811
- addReturn(retOptions: Partial<Return>): Return;
812
-
813
- /**
814
- * 添加输出参数
815
- * @param ret 已有的输出参数实例
816
- */
817
- addReturn(ret: Return): Return;
818
-
819
- addReturn(options?: string | Partial<Return> | Return) {
820
- const node = this._addReturn(options as any);
821
- const index = this.returns.indexOf(node);
822
- node.create({
823
- index,
824
- parentNode: this,
825
- parentKey: 'returns',
826
- });
827
- return node;
828
- }
212
+ /**
213
+ * 设置流程元素描述
214
+ */
215
+ setDescription(description: string) {
216
+ const object = {
217
+ description,
218
+ };
219
+ this.update({
220
+ ...object,
221
+ });
222
+ }
829
223
 
224
+ /**
225
+ * 设置sourceRef
226
+ */
227
+ setSourceRef(sourceRef: string) {
228
+ const object = {
229
+ sourceRef,
230
+ };
231
+ this.update({
232
+ ...object,
233
+ });
234
+ }
830
235
 
831
- getConstantExistingNames(excludedList: Array<Constant> = []) {
832
- const excludedSet = new Set(excludedList);
833
- return ((this.constants as Constant[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
834
- }
835
- getConstantUniqueName(name = 'constant1') {
836
- return utils.unique(name, this.getConstantExistingNames(), undefined, false);
837
- }
236
+ /**
237
+ * 设置targetRef
238
+ */
239
+ setTargetRef(targetRef: string) {
240
+ const object = {
241
+ targetRef,
242
+ };
243
+ this.update({
244
+ ...object,
245
+ });
246
+ }
247
+
248
+ /**
249
+ * 设置矩形信息
250
+ */
251
+ setBounds(bounds: Rect) {
252
+ bounds._delete();
253
+ const relationOptions = { parentNode: this, parentKey: 'bounds' };
254
+ Object.assign(bounds, relationOptions);
255
+ const object = {
256
+ bounds,
257
+ };
258
+ this.update({
259
+ ...object,
260
+ });
261
+ }
838
262
 
839
- /**
840
- * 插入常量
841
- * @internal
842
- * @param name 常量名称,如果不填会自动生成一个唯一名称
843
- */
844
- _insertConstantAt(name: string, index: number): Constant;
845
-
846
- /**
847
- * 插入常量
848
- * @internal
849
- * @param constantOptions 常量参数
850
- */
851
- _insertConstantAt(constantOptions: Partial<Constant>, index: number): Constant;
852
-
853
- /**
854
- * 插入常量
855
- * @internal
856
- * @param constant 已有的常量实例
857
- */
858
- _insertConstantAt(constant: Constant, index: number): Constant;
859
-
860
- _insertConstantAt(options: string | Partial<Constant> | Constant, index: number) {
861
- const constantOptions: any = {};
862
- const relationOptions = { parentNode: this, parentKey: 'constants' };
863
- let constant: Constant;
864
- if (!options) {
865
- constant = Constant.from({
866
- ...constantOptions,
867
- name: this.getConstantUniqueName(),
868
- }, this, 'constants');
869
- } else if (typeof options === 'string') {
870
- constant = Constant.from({
871
- ...constantOptions,
872
- name: options,
873
- }, this, 'constants');
874
- } else if (options instanceof Constant) {
875
- options.ensureDelete(); // 同一实例不支持多处存在
876
- constant = options;
877
- Object.assign(constant, relationOptions);
878
- } else {
879
- constant = Constant.from({
880
- ...constantOptions,
881
- ...options,
882
- }, this, 'constants');
263
+ /**
264
+ * 设置flowValue
265
+ */
266
+ setFlowValue(flowValue: string) {
267
+ const object = {
268
+ flowValue,
269
+ };
270
+ this.update({
271
+ ...object,
272
+ });
273
+ }
274
+
275
+ getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
276
+ const excludedSet = new Set(excludedList);
277
+ return ((this.bindEvents as BindEvent[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
278
+ }
279
+
280
+ getBindEventUniqueName(name = 'bindEvent1') {
281
+ return utils.unique(name, this.getBindEventExistingNames(), undefined, false);
282
+ }
283
+
284
+ /**
285
+ * 插入元素绑定事件
286
+ * @internal
287
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
288
+ */
289
+ _insertBindEventAt(name: string, index: number): BindEvent;
290
+
291
+ /**
292
+ * 插入元素绑定事件
293
+ * @internal
294
+ * @param bindEventOptions 元素绑定事件参数
295
+ */
296
+ _insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
297
+
298
+ /**
299
+ * 插入元素绑定事件
300
+ * @internal
301
+ * @param bindEvent 已有的元素绑定事件实例
302
+ */
303
+ _insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
304
+
305
+ _insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
306
+ const bindEventOptions: any = {};
307
+ const relationOptions = { parentNode: this, parentKey: 'bindEvents' };
308
+ let bindEvent: BindEvent;
309
+ if (!options) {
310
+ bindEvent = BindEvent.from(
311
+ {
312
+ ...bindEventOptions,
313
+ name: this.getBindEventUniqueName(),
314
+ },
315
+ this,
316
+ 'bindEvents'
317
+ );
318
+ } else if (typeof options === 'string') {
319
+ bindEvent = BindEvent.from(
320
+ {
321
+ ...bindEventOptions,
322
+ name: options,
323
+ },
324
+ this,
325
+ 'bindEvents'
326
+ );
327
+ } else if (options instanceof BindEvent) {
328
+ options.ensureDelete(); // 同一实例不支持多处存在
329
+ bindEvent = options;
330
+ Object.assign(bindEvent, relationOptions);
331
+ } else {
332
+ bindEvent = BindEvent.from(
333
+ {
334
+ ...bindEventOptions,
335
+ ...options,
336
+ },
337
+ this,
338
+ 'bindEvents'
339
+ );
340
+ }
341
+ this.bindEvents.splice(index, 0, bindEvent);
342
+ return bindEvent;
343
+ }
344
+
345
+ /**
346
+ * 插入元素绑定事件
347
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
348
+ */
349
+ insertBindEventAt(name: string, index: number): BindEvent;
350
+
351
+ /**
352
+ * 插入元素绑定事件
353
+ * @param bindEventOptions 元素绑定事件参数
354
+ */
355
+ insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
356
+
357
+ /**
358
+ * 插入元素绑定事件
359
+ * @param bindEvent 已有的元素绑定事件实例
360
+ */
361
+ insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
362
+
363
+ insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
364
+ const node = this._insertBindEventAt(options as any, index);
365
+ node.create({
366
+ index,
367
+ parentNode: this,
368
+ parentKey: 'bindEvents',
369
+ });
370
+ return node;
371
+ }
372
+
373
+ /**
374
+ * 添加元素绑定事件
375
+ * @internal
376
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
377
+ */
378
+ _addBindEvent(name?: string): BindEvent;
379
+
380
+ /**
381
+ * 添加元素绑定事件
382
+ * @internal
383
+ * @param bindEventOptions 元素绑定事件参数
384
+ */
385
+ _addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
386
+
387
+ /**
388
+ * 添加元素绑定事件
389
+ * @internal
390
+ * @param bindEvent 已有的元素绑定事件实例
391
+ */
392
+ _addBindEvent(bindEvent: BindEvent): BindEvent;
393
+
394
+ _addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
395
+ const index = this.bindEvents.length;
396
+ return this._insertBindEventAt(options as any, index);
397
+ }
398
+
399
+ /**
400
+ * 添加元素绑定事件
401
+ * @internal
402
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
403
+ */
404
+ addBindEvent(name?: string): BindEvent;
405
+
406
+ /**
407
+ * 添加元素绑定事件
408
+ * @param bindEventOptions 元素绑定事件参数
409
+ */
410
+ addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
411
+
412
+ /**
413
+ * 添加元素绑定事件
414
+ * @param bindEvent 已有的元素绑定事件实例
415
+ */
416
+ addBindEvent(bindEvent: BindEvent): BindEvent;
417
+
418
+ addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
419
+ const node = this._addBindEvent(options as any);
420
+ const index = this.bindEvents.indexOf(node);
421
+ node.create({
422
+ index,
423
+ parentNode: this,
424
+ parentKey: 'bindEvents',
425
+ });
426
+ return node;
427
+ }
428
+
429
+ getPointExistingNames(excludedList: Array<Point> = []) {
430
+ const excludedSet = new Set(excludedList);
431
+ return ((this.waypoints as Point[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
432
+ }
433
+
434
+ getPointUniqueName(name = 'point1') {
435
+ return utils.unique(name, this.getPointExistingNames(), undefined, false);
436
+ }
437
+
438
+ /**
439
+ * 插入点信息
440
+ * @internal
441
+ * @param name 点信息名称,如果不填会自动生成一个唯一名称
442
+ */
443
+ _insertPointAt(name: string, index: number): Point;
444
+
445
+ /**
446
+ * 插入点信息
447
+ * @internal
448
+ * @param pointOptions 点信息参数
449
+ */
450
+ _insertPointAt(pointOptions: Partial<Point>, index: number): Point;
451
+
452
+ /**
453
+ * 插入点信息
454
+ * @internal
455
+ * @param point 已有的点信息实例
456
+ */
457
+ _insertPointAt(point: Point, index: number): Point;
458
+
459
+ _insertPointAt(options: string | Partial<Point> | Point, index: number) {
460
+ const pointOptions: any = {};
461
+ const relationOptions = { parentNode: this, parentKey: 'waypoints' };
462
+ let point: Point;
463
+ if (!options) {
464
+ point = Point.from(
465
+ {
466
+ ...pointOptions,
467
+ name: this.getPointUniqueName(),
468
+ },
469
+ this,
470
+ 'waypoints'
471
+ );
472
+ } else if (typeof options === 'string') {
473
+ point = Point.from(
474
+ {
475
+ ...pointOptions,
476
+ name: options,
477
+ },
478
+ this,
479
+ 'waypoints'
480
+ );
481
+ } else if (options instanceof Point) {
482
+ options.ensureDelete(); // 同一实例不支持多处存在
483
+ point = options;
484
+ Object.assign(point, relationOptions);
485
+ } else {
486
+ point = Point.from(
487
+ {
488
+ ...pointOptions,
489
+ ...options,
490
+ },
491
+ this,
492
+ 'waypoints'
493
+ );
494
+ }
495
+ this.waypoints.splice(index, 0, point);
496
+ return point;
497
+ }
498
+
499
+ /**
500
+ * 插入点信息
501
+ * @param name 点信息名称,如果不填会自动生成一个唯一名称
502
+ */
503
+ insertPointAt(name: string, index: number): Point;
504
+
505
+ /**
506
+ * 插入点信息
507
+ * @param pointOptions 点信息参数
508
+ */
509
+ insertPointAt(pointOptions: Partial<Point>, index: number): Point;
510
+
511
+ /**
512
+ * 插入点信息
513
+ * @param point 已有的点信息实例
514
+ */
515
+ insertPointAt(point: Point, index: number): Point;
516
+
517
+ insertPointAt(options: string | Partial<Point> | Point, index: number) {
518
+ const node = this._insertPointAt(options as any, index);
519
+ node.create({
520
+ index,
521
+ parentNode: this,
522
+ parentKey: 'waypoints',
523
+ });
524
+ return node;
525
+ }
526
+
527
+ /**
528
+ * 添加点信息
529
+ * @internal
530
+ * @param name 点信息名称,如果不填会自动生成一个唯一名称
531
+ */
532
+ _addPoint(name?: string): Point;
533
+
534
+ /**
535
+ * 添加点信息
536
+ * @internal
537
+ * @param pointOptions 点信息参数
538
+ */
539
+ _addPoint(pointOptions: Partial<Point>): Point;
540
+
541
+ /**
542
+ * 添加点信息
543
+ * @internal
544
+ * @param point 已有的点信息实例
545
+ */
546
+ _addPoint(point: Point): Point;
547
+
548
+ _addPoint(options?: string | Partial<Point> | Point) {
549
+ const index = this.waypoints.length;
550
+ return this._insertPointAt(options as any, index);
551
+ }
552
+
553
+ /**
554
+ * 添加点信息
555
+ * @internal
556
+ * @param name 点信息名称,如果不填会自动生成一个唯一名称
557
+ */
558
+ addPoint(name?: string): Point;
559
+
560
+ /**
561
+ * 添加点信息
562
+ * @param pointOptions 点信息参数
563
+ */
564
+ addPoint(pointOptions: Partial<Point>): Point;
565
+
566
+ /**
567
+ * 添加点信息
568
+ * @param point 已有的点信息实例
569
+ */
570
+ addPoint(point: Point): Point;
571
+
572
+ addPoint(options?: string | Partial<Point> | Point) {
573
+ const node = this._addPoint(options as any);
574
+ const index = this.waypoints.indexOf(node);
575
+ node.create({
576
+ index,
577
+ parentNode: this,
578
+ parentKey: 'waypoints',
579
+ });
580
+ return node;
581
+ }
582
+
583
+ getVariableExistingNames(excludedList: Array<Variable> = []) {
584
+ const excludedSet = new Set(excludedList);
585
+ return ((this.variables as Variable[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
586
+ }
587
+
588
+ getVariableUniqueName(name = 'variable1') {
589
+ return utils.unique(name, this.getVariableExistingNames(), undefined, false);
590
+ }
591
+
592
+ /**
593
+ * 插入变量
594
+ * @internal
595
+ * @param name 变量名称,如果不填会自动生成一个唯一名称
596
+ */
597
+ _insertVariableAt(name: string, index: number): Variable;
598
+
599
+ /**
600
+ * 插入变量
601
+ * @internal
602
+ * @param variableOptions 变量参数
603
+ */
604
+ _insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
605
+
606
+ /**
607
+ * 插入变量
608
+ * @internal
609
+ * @param variable 已有的变量实例
610
+ */
611
+ _insertVariableAt(variable: Variable, index: number): Variable;
612
+
613
+ _insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
614
+ const variableOptions: any = {};
615
+ const relationOptions = { parentNode: this, parentKey: 'variables' };
616
+ let variable: Variable;
617
+ if (!options) {
618
+ variable = Variable.from(
619
+ {
620
+ ...variableOptions,
621
+ name: this.getVariableUniqueName(),
622
+ },
623
+ this,
624
+ 'variables'
625
+ );
626
+ } else if (typeof options === 'string') {
627
+ variable = Variable.from(
628
+ {
629
+ ...variableOptions,
630
+ name: options,
631
+ },
632
+ this,
633
+ 'variables'
634
+ );
635
+ } else if (options instanceof Variable) {
636
+ options.ensureDelete(); // 同一实例不支持多处存在
637
+ variable = options;
638
+ Object.assign(variable, relationOptions);
639
+ } else {
640
+ variable = Variable.from(
641
+ {
642
+ ...variableOptions,
643
+ ...options,
644
+ },
645
+ this,
646
+ 'variables'
647
+ );
648
+ }
649
+ this.variables.splice(index, 0, variable);
650
+ return variable;
651
+ }
652
+
653
+ /**
654
+ * 插入变量
655
+ * @param name 变量名称,如果不填会自动生成一个唯一名称
656
+ */
657
+ insertVariableAt(name: string, index: number): Variable;
658
+
659
+ /**
660
+ * 插入变量
661
+ * @param variableOptions 变量参数
662
+ */
663
+ insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
664
+
665
+ /**
666
+ * 插入变量
667
+ * @param variable 已有的变量实例
668
+ */
669
+ insertVariableAt(variable: Variable, index: number): Variable;
670
+
671
+ insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
672
+ const node = this._insertVariableAt(options as any, index);
673
+ node.create({
674
+ index,
675
+ parentNode: this,
676
+ parentKey: 'variables',
677
+ });
678
+ return node;
679
+ }
680
+
681
+ /**
682
+ * 添加变量
683
+ * @internal
684
+ * @param name 变量名称,如果不填会自动生成一个唯一名称
685
+ */
686
+ _addVariable(name?: string): Variable;
687
+
688
+ /**
689
+ * 添加变量
690
+ * @internal
691
+ * @param variableOptions 变量参数
692
+ */
693
+ _addVariable(variableOptions: Partial<Variable>): Variable;
694
+
695
+ /**
696
+ * 添加变量
697
+ * @internal
698
+ * @param variable 已有的变量实例
699
+ */
700
+ _addVariable(variable: Variable): Variable;
701
+
702
+ _addVariable(options?: string | Partial<Variable> | Variable) {
703
+ const index = this.variables.length;
704
+ return this._insertVariableAt(options as any, index);
705
+ }
706
+
707
+ /**
708
+ * 添加变量
709
+ * @internal
710
+ * @param name 变量名称,如果不填会自动生成一个唯一名称
711
+ */
712
+ addVariable(name?: string): Variable;
713
+
714
+ /**
715
+ * 添加变量
716
+ * @param variableOptions 变量参数
717
+ */
718
+ addVariable(variableOptions: Partial<Variable>): Variable;
719
+
720
+ /**
721
+ * 添加变量
722
+ * @param variable 已有的变量实例
723
+ */
724
+ addVariable(variable: Variable): Variable;
725
+
726
+ addVariable(options?: string | Partial<Variable> | Variable) {
727
+ const node = this._addVariable(options as any);
728
+ const index = this.variables.indexOf(node);
729
+ node.create({
730
+ index,
731
+ parentNode: this,
732
+ parentKey: 'variables',
733
+ });
734
+ return node;
735
+ }
736
+
737
+ getReturnExistingNames(excludedList: Array<Return> = []) {
738
+ const excludedSet = new Set(excludedList);
739
+ return ((this.returns as Return[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
740
+ }
741
+
742
+ getReturnUniqueName(name = 'ret1') {
743
+ return utils.unique(name, this.getReturnExistingNames(), undefined, false);
744
+ }
745
+
746
+ /**
747
+ * 插入输出参数
748
+ * @internal
749
+ * @param name 输出参数名称,如果不填会自动生成一个唯一名称
750
+ */
751
+ _insertReturnAt(name: string, index: number): Return;
752
+
753
+ /**
754
+ * 插入输出参数
755
+ * @internal
756
+ * @param retOptions 输出参数参数
757
+ */
758
+ _insertReturnAt(retOptions: Partial<Return>, index: number): Return;
759
+
760
+ /**
761
+ * 插入输出参数
762
+ * @internal
763
+ * @param ret 已有的输出参数实例
764
+ */
765
+ _insertReturnAt(ret: Return, index: number): Return;
766
+
767
+ _insertReturnAt(options: string | Partial<Return> | Return, index: number) {
768
+ const retOptions: any = {};
769
+ const relationOptions = { parentNode: this, parentKey: 'returns' };
770
+ let ret: Return;
771
+ if (!options) {
772
+ ret = Return.from(
773
+ {
774
+ ...retOptions,
775
+ name: this.getReturnUniqueName(),
776
+ },
777
+ this,
778
+ 'returns'
779
+ );
780
+ } else if (typeof options === 'string') {
781
+ ret = Return.from(
782
+ {
783
+ ...retOptions,
784
+ name: options,
785
+ },
786
+ this,
787
+ 'returns'
788
+ );
789
+ } else if (options instanceof Return) {
790
+ options.ensureDelete(); // 同一实例不支持多处存在
791
+ ret = options;
792
+ Object.assign(ret, relationOptions);
793
+ } else {
794
+ ret = Return.from(
795
+ {
796
+ ...retOptions,
797
+ ...options,
798
+ },
799
+ this,
800
+ 'returns'
801
+ );
802
+ }
803
+ this.returns.splice(index, 0, ret);
804
+ return ret;
805
+ }
806
+
807
+ /**
808
+ * 插入输出参数
809
+ * @param name 输出参数名称,如果不填会自动生成一个唯一名称
810
+ */
811
+ insertReturnAt(name: string, index: number): Return;
812
+
813
+ /**
814
+ * 插入输出参数
815
+ * @param retOptions 输出参数参数
816
+ */
817
+ insertReturnAt(retOptions: Partial<Return>, index: number): Return;
818
+
819
+ /**
820
+ * 插入输出参数
821
+ * @param ret 已有的输出参数实例
822
+ */
823
+ insertReturnAt(ret: Return, index: number): Return;
824
+
825
+ insertReturnAt(options: string | Partial<Return> | Return, index: number) {
826
+ const node = this._insertReturnAt(options as any, index);
827
+ node.create({
828
+ index,
829
+ parentNode: this,
830
+ parentKey: 'returns',
831
+ });
832
+ return node;
833
+ }
834
+
835
+ /**
836
+ * 添加输出参数
837
+ * @internal
838
+ * @param name 输出参数名称,如果不填会自动生成一个唯一名称
839
+ */
840
+ _addReturn(name?: string): Return;
841
+
842
+ /**
843
+ * 添加输出参数
844
+ * @internal
845
+ * @param retOptions 输出参数参数
846
+ */
847
+ _addReturn(retOptions: Partial<Return>): Return;
848
+
849
+ /**
850
+ * 添加输出参数
851
+ * @internal
852
+ * @param ret 已有的输出参数实例
853
+ */
854
+ _addReturn(ret: Return): Return;
855
+
856
+ _addReturn(options?: string | Partial<Return> | Return) {
857
+ const index = this.returns.length;
858
+ return this._insertReturnAt(options as any, index);
859
+ }
860
+
861
+ /**
862
+ * 添加输出参数
863
+ * @internal
864
+ * @param name 输出参数名称,如果不填会自动生成一个唯一名称
865
+ */
866
+ addReturn(name?: string): Return;
867
+
868
+ /**
869
+ * 添加输出参数
870
+ * @param retOptions 输出参数参数
871
+ */
872
+ addReturn(retOptions: Partial<Return>): Return;
873
+
874
+ /**
875
+ * 添加输出参数
876
+ * @param ret 已有的输出参数实例
877
+ */
878
+ addReturn(ret: Return): Return;
879
+
880
+ addReturn(options?: string | Partial<Return> | Return) {
881
+ const node = this._addReturn(options as any);
882
+ const index = this.returns.indexOf(node);
883
+ node.create({
884
+ index,
885
+ parentNode: this,
886
+ parentKey: 'returns',
887
+ });
888
+ return node;
889
+ }
890
+
891
+ getConstantExistingNames(excludedList: Array<Constant> = []) {
892
+ const excludedSet = new Set(excludedList);
893
+ return ((this.constants as Constant[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
894
+ }
895
+
896
+ getConstantUniqueName(name = 'constant1') {
897
+ return utils.unique(name, this.getConstantExistingNames(), undefined, false);
898
+ }
899
+
900
+ /**
901
+ * 插入常量
902
+ * @internal
903
+ * @param name 常量名称,如果不填会自动生成一个唯一名称
904
+ */
905
+ _insertConstantAt(name: string, index: number): Constant;
906
+
907
+ /**
908
+ * 插入常量
909
+ * @internal
910
+ * @param constantOptions 常量参数
911
+ */
912
+ _insertConstantAt(constantOptions: Partial<Constant>, index: number): Constant;
913
+
914
+ /**
915
+ * 插入常量
916
+ * @internal
917
+ * @param constant 已有的常量实例
918
+ */
919
+ _insertConstantAt(constant: Constant, index: number): Constant;
920
+
921
+ _insertConstantAt(options: string | Partial<Constant> | Constant, index: number) {
922
+ const constantOptions: any = {};
923
+ const relationOptions = { parentNode: this, parentKey: 'constants' };
924
+ let constant: Constant;
925
+ if (!options) {
926
+ constant = Constant.from(
927
+ {
928
+ ...constantOptions,
929
+ name: this.getConstantUniqueName(),
930
+ },
931
+ this,
932
+ 'constants'
933
+ );
934
+ } else if (typeof options === 'string') {
935
+ constant = Constant.from(
936
+ {
937
+ ...constantOptions,
938
+ name: options,
939
+ },
940
+ this,
941
+ 'constants'
942
+ );
943
+ } else if (options instanceof Constant) {
944
+ options.ensureDelete(); // 同一实例不支持多处存在
945
+ constant = options;
946
+ Object.assign(constant, relationOptions);
947
+ } else {
948
+ constant = Constant.from(
949
+ {
950
+ ...constantOptions,
951
+ ...options,
952
+ },
953
+ this,
954
+ 'constants'
955
+ );
956
+ }
957
+ this.constants.splice(index, 0, constant);
958
+ return constant;
959
+ }
960
+
961
+ /**
962
+ * 插入常量
963
+ * @param name 常量名称,如果不填会自动生成一个唯一名称
964
+ */
965
+ insertConstantAt(name: string, index: number): Constant;
966
+
967
+ /**
968
+ * 插入常量
969
+ * @param constantOptions 常量参数
970
+ */
971
+ insertConstantAt(constantOptions: Partial<Constant>, index: number): Constant;
972
+
973
+ /**
974
+ * 插入常量
975
+ * @param constant 已有的常量实例
976
+ */
977
+ insertConstantAt(constant: Constant, index: number): Constant;
978
+
979
+ insertConstantAt(options: string | Partial<Constant> | Constant, index: number) {
980
+ const node = this._insertConstantAt(options as any, index);
981
+ node.create({
982
+ index,
983
+ parentNode: this,
984
+ parentKey: 'constants',
985
+ });
986
+ return node;
987
+ }
988
+
989
+ /**
990
+ * 添加常量
991
+ * @internal
992
+ * @param name 常量名称,如果不填会自动生成一个唯一名称
993
+ */
994
+ _addConstant(name?: string): Constant;
995
+
996
+ /**
997
+ * 添加常量
998
+ * @internal
999
+ * @param constantOptions 常量参数
1000
+ */
1001
+ _addConstant(constantOptions: Partial<Constant>): Constant;
1002
+
1003
+ /**
1004
+ * 添加常量
1005
+ * @internal
1006
+ * @param constant 已有的常量实例
1007
+ */
1008
+ _addConstant(constant: Constant): Constant;
1009
+
1010
+ _addConstant(options?: string | Partial<Constant> | Constant) {
1011
+ const index = this.constants.length;
1012
+ return this._insertConstantAt(options as any, index);
1013
+ }
1014
+
1015
+ /**
1016
+ * 添加常量
1017
+ * @internal
1018
+ * @param name 常量名称,如果不填会自动生成一个唯一名称
1019
+ */
1020
+ addConstant(name?: string): Constant;
1021
+
1022
+ /**
1023
+ * 添加常量
1024
+ * @param constantOptions 常量参数
1025
+ */
1026
+ addConstant(constantOptions: Partial<Constant>): Constant;
1027
+
1028
+ /**
1029
+ * 添加常量
1030
+ * @param constant 已有的常量实例
1031
+ */
1032
+ addConstant(constant: Constant): Constant;
1033
+
1034
+ addConstant(options?: string | Partial<Constant> | Constant) {
1035
+ const node = this._addConstant(options as any);
1036
+ const index = this.constants.indexOf(node);
1037
+ node.create({
1038
+ index,
1039
+ parentNode: this,
1040
+ parentKey: 'constants',
1041
+ });
1042
+ return node;
1043
+ }
1044
+
1045
+ getBindAttributeExistingNames(excludedList: Array<BindAttribute> = []) {
1046
+ const excludedSet = new Set(excludedList);
1047
+ return ((this.bindAttrs as BindAttribute[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
1048
+ }
1049
+
1050
+ getBindAttributeUniqueName(name = 'bindAttribute1') {
1051
+ return utils.unique(name, this.getBindAttributeExistingNames(), undefined, false);
1052
+ }
1053
+
1054
+ /**
1055
+ * 插入元素绑定属性
1056
+ * @internal
1057
+ * @param name 元素绑定属性名称,如果不填会自动生成一个唯一名称
1058
+ */
1059
+ _insertBindAttributeAt(name: string, index: number): BindAttribute;
1060
+
1061
+ /**
1062
+ * 插入元素绑定属性
1063
+ * @internal
1064
+ * @param bindAttributeOptions 元素绑定属性参数
1065
+ */
1066
+ _insertBindAttributeAt(bindAttributeOptions: Partial<BindAttribute>, index: number): BindAttribute;
1067
+
1068
+ /**
1069
+ * 插入元素绑定属性
1070
+ * @internal
1071
+ * @param bindAttribute 已有的元素绑定属性实例
1072
+ */
1073
+ _insertBindAttributeAt(bindAttribute: BindAttribute, index: number): BindAttribute;
1074
+
1075
+ _insertBindAttributeAt(options: string | Partial<BindAttribute> | BindAttribute, index: number) {
1076
+ const bindAttributeOptions: any = {};
1077
+ const relationOptions = { parentNode: this, parentKey: 'bindAttrs' };
1078
+ let bindAttribute: BindAttribute;
1079
+ if (!options) {
1080
+ bindAttribute = BindAttribute.from(
1081
+ {
1082
+ ...bindAttributeOptions,
1083
+ name: this.getBindAttributeUniqueName(),
1084
+ },
1085
+ this,
1086
+ 'bindAttrs'
1087
+ );
1088
+ } else if (typeof options === 'string') {
1089
+ bindAttribute = BindAttribute.from(
1090
+ {
1091
+ ...bindAttributeOptions,
1092
+ name: options,
1093
+ },
1094
+ this,
1095
+ 'bindAttrs'
1096
+ );
1097
+ } else if (options instanceof BindAttribute) {
1098
+ options.ensureDelete(); // 同一实例不支持多处存在
1099
+ bindAttribute = options;
1100
+ Object.assign(bindAttribute, relationOptions);
1101
+ } else {
1102
+ bindAttribute = BindAttribute.from(
1103
+ {
1104
+ ...bindAttributeOptions,
1105
+ ...options,
1106
+ },
1107
+ this,
1108
+ 'bindAttrs'
1109
+ );
1110
+ }
1111
+ this.bindAttrs.splice(index, 0, bindAttribute);
1112
+ return bindAttribute;
1113
+ }
1114
+
1115
+ /**
1116
+ * 插入元素绑定属性
1117
+ * @param name 元素绑定属性名称,如果不填会自动生成一个唯一名称
1118
+ */
1119
+ insertBindAttributeAt(name: string, index: number): BindAttribute;
1120
+
1121
+ /**
1122
+ * 插入元素绑定属性
1123
+ * @param bindAttributeOptions 元素绑定属性参数
1124
+ */
1125
+ insertBindAttributeAt(bindAttributeOptions: Partial<BindAttribute>, index: number): BindAttribute;
1126
+
1127
+ /**
1128
+ * 插入元素绑定属性
1129
+ * @param bindAttribute 已有的元素绑定属性实例
1130
+ */
1131
+ insertBindAttributeAt(bindAttribute: BindAttribute, index: number): BindAttribute;
1132
+
1133
+ insertBindAttributeAt(options: string | Partial<BindAttribute> | BindAttribute, index: number) {
1134
+ const node = this._insertBindAttributeAt(options as any, index);
1135
+ node.create({
1136
+ index,
1137
+ parentNode: this,
1138
+ parentKey: 'bindAttrs',
1139
+ });
1140
+ return node;
1141
+ }
1142
+
1143
+ /**
1144
+ * 添加元素绑定属性
1145
+ * @internal
1146
+ * @param name 元素绑定属性名称,如果不填会自动生成一个唯一名称
1147
+ */
1148
+ _addBindAttribute(name?: string): BindAttribute;
1149
+
1150
+ /**
1151
+ * 添加元素绑定属性
1152
+ * @internal
1153
+ * @param bindAttributeOptions 元素绑定属性参数
1154
+ */
1155
+ _addBindAttribute(bindAttributeOptions: Partial<BindAttribute>): BindAttribute;
1156
+
1157
+ /**
1158
+ * 添加元素绑定属性
1159
+ * @internal
1160
+ * @param bindAttribute 已有的元素绑定属性实例
1161
+ */
1162
+ _addBindAttribute(bindAttribute: BindAttribute): BindAttribute;
1163
+
1164
+ _addBindAttribute(options?: string | Partial<BindAttribute> | BindAttribute) {
1165
+ const index = this.bindAttrs.length;
1166
+ return this._insertBindAttributeAt(options as any, index);
1167
+ }
1168
+
1169
+ /**
1170
+ * 添加元素绑定属性
1171
+ * @internal
1172
+ * @param name 元素绑定属性名称,如果不填会自动生成一个唯一名称
1173
+ */
1174
+ addBindAttribute(name?: string): BindAttribute;
1175
+
1176
+ /**
1177
+ * 添加元素绑定属性
1178
+ * @param bindAttributeOptions 元素绑定属性参数
1179
+ */
1180
+ addBindAttribute(bindAttributeOptions: Partial<BindAttribute>): BindAttribute;
1181
+
1182
+ /**
1183
+ * 添加元素绑定属性
1184
+ * @param bindAttribute 已有的元素绑定属性实例
1185
+ */
1186
+ addBindAttribute(bindAttribute: BindAttribute): BindAttribute;
1187
+
1188
+ addBindAttribute(options?: string | Partial<BindAttribute> | BindAttribute) {
1189
+ const node = this._addBindAttribute(options as any);
1190
+ const index = this.bindAttrs.indexOf(node);
1191
+ node.create({
1192
+ index,
1193
+ parentNode: this,
1194
+ parentKey: 'bindAttrs',
1195
+ });
1196
+ return node;
1197
+ }
1198
+
1199
+ /**
1200
+ * 删除元素绑定事件
1201
+ * @param name 元素绑定事件名称
1202
+ */
1203
+ removeBindEvent(name: string): void;
1204
+
1205
+ /**
1206
+ * 删除元素绑定事件
1207
+ * @param bindEvent 已有的元素绑定事件实例
1208
+ */
1209
+ removeBindEvent(bindEvent: BindEvent): void;
1210
+
1211
+ removeBindEvent(options: string | BindEvent) {
1212
+ let bindEvent: BindEvent;
1213
+ if (typeof options === 'string') {
1214
+ bindEvent = (this.bindEvents as BindEvent[]).find((item) => item.name === options);
1215
+ if (!bindEvent) {
1216
+ throw new Error(`找不到元素绑定事件 ${options}`);
1217
+ }
1218
+ } else {
1219
+ bindEvent = options;
1220
+ }
1221
+ return bindEvent.delete();
1222
+ }
1223
+
1224
+ __removeBindEvent(bindEvent: BindEvent) {
1225
+ const { parentKey } = bindEvent;
1226
+ const params: Params = {
1227
+ parentNode: this,
1228
+ parentKey,
1229
+ index: -1,
1230
+ object: null,
1231
+ oldObject: bindEvent,
1232
+ };
1233
+ if (parentKey) {
1234
+ params.parentKey = parentKey;
1235
+ if (Array.isArray((this as any)[parentKey])) {
1236
+ const index = (this as any)[parentKey].indexOf(bindEvent);
1237
+ ~index && (this as any)[parentKey].splice(index, 1);
1238
+ params.index = index;
1239
+ } else if ((this as any)[parentKey] === bindEvent) {
1240
+ params.index = 0;
1241
+ (this as any)[parentKey] = undefined;
1242
+ }
1243
+ }
1244
+ return params;
1245
+ }
1246
+
1247
+ /**
1248
+ * 删除矩形信息
1249
+ * @param name 矩形信息名称
1250
+ */
1251
+ removeBounds(name: string): void;
1252
+
1253
+ /**
1254
+ * 删除矩形信息
1255
+ * @param bounds 已有的矩形信息实例
1256
+ */
1257
+ removeBounds(bounds: Rect): void;
1258
+
1259
+ removeBounds(options: string | Rect) {
1260
+ let bounds: Rect;
1261
+ if (typeof options === 'string') {
1262
+ bounds = this.bounds;
1263
+ if (!bounds) {
1264
+ throw new Error(`找不到矩形信息 ${options}`);
1265
+ }
1266
+ } else {
1267
+ bounds = options;
1268
+ }
1269
+ return bounds.delete();
1270
+ }
1271
+
1272
+ __removeRect(rect: Rect) {
1273
+ const { parentKey } = rect;
1274
+ const params: Params = {
1275
+ parentNode: this,
1276
+ parentKey,
1277
+ index: -1,
1278
+ object: null,
1279
+ oldObject: rect,
1280
+ };
1281
+ if (parentKey) {
1282
+ params.parentKey = parentKey;
1283
+ if (Array.isArray((this as any)[parentKey])) {
1284
+ const index = (this as any)[parentKey].indexOf(rect);
1285
+ ~index && (this as any)[parentKey].splice(index, 1);
1286
+ params.index = index;
1287
+ } else if ((this as any)[parentKey] === rect) {
1288
+ params.index = 0;
1289
+ (this as any)[parentKey] = undefined;
1290
+ }
1291
+ }
1292
+ return params;
1293
+ }
1294
+
1295
+ /**
1296
+ * 删除点信息
1297
+ * @param name 点信息名称
1298
+ */
1299
+ removePoint(name: string): void;
1300
+
1301
+ /**
1302
+ * 删除点信息
1303
+ * @param point 已有的点信息实例
1304
+ */
1305
+ removePoint(point: Point): void;
1306
+
1307
+ removePoint(options: string | Point) {
1308
+ let point: Point;
1309
+ if (typeof options === 'string') {
1310
+ point = (this.waypoints as Point[]).find((item) => item.name === options);
1311
+ if (!point) {
1312
+ throw new Error(`找不到点信息 ${options}`);
1313
+ }
1314
+ } else {
1315
+ point = options;
1316
+ }
1317
+ return point.delete();
1318
+ }
1319
+
1320
+ __removePoint(point: Point) {
1321
+ const { parentKey } = point;
1322
+ const params: Params = {
1323
+ parentNode: this,
1324
+ parentKey,
1325
+ index: -1,
1326
+ object: null,
1327
+ oldObject: point,
1328
+ };
1329
+ if (parentKey) {
1330
+ params.parentKey = parentKey;
1331
+ if (Array.isArray((this as any)[parentKey])) {
1332
+ const index = (this as any)[parentKey].indexOf(point);
1333
+ ~index && (this as any)[parentKey].splice(index, 1);
1334
+ params.index = index;
1335
+ } else if ((this as any)[parentKey] === point) {
1336
+ params.index = 0;
1337
+ (this as any)[parentKey] = undefined;
1338
+ }
1339
+ }
1340
+ return params;
1341
+ }
1342
+
1343
+ /**
1344
+ * 删除逻辑
1345
+ * @param name 逻辑名称
1346
+ */
1347
+ removeLogic(name: string): void;
1348
+
1349
+ /**
1350
+ * 删除逻辑
1351
+ * @param logic 已有的逻辑实例
1352
+ */
1353
+ removeLogic(logic: Logic): void;
1354
+
1355
+ removeLogic(options: string | Logic) {
1356
+ let logic: Logic;
1357
+ if (typeof options === 'string') {
1358
+ logic = this.logic;
1359
+ if (!logic) {
1360
+ throw new Error(`找不到逻辑 ${options}`);
1361
+ }
1362
+ } else {
1363
+ logic = options;
1364
+ }
1365
+ return logic.delete();
1366
+ }
1367
+
1368
+ __removeLogic(logic: Logic) {
1369
+ const { parentKey } = logic;
1370
+ const params: Params = {
1371
+ parentNode: this,
1372
+ parentKey,
1373
+ index: -1,
1374
+ object: null,
1375
+ oldObject: logic,
1376
+ };
1377
+ if (parentKey) {
1378
+ params.parentKey = parentKey;
1379
+ if (Array.isArray((this as any)[parentKey])) {
1380
+ const index = (this as any)[parentKey].indexOf(logic);
1381
+ ~index && (this as any)[parentKey].splice(index, 1);
1382
+ params.index = index;
1383
+ } else if ((this as any)[parentKey] === logic) {
1384
+ params.index = 0;
1385
+ (this as any)[parentKey] = undefined;
1386
+ }
1387
+ }
1388
+ return params;
1389
+ }
1390
+
1391
+ /**
1392
+ * 删除变量
1393
+ * @param name 变量名称
1394
+ */
1395
+ removeVariable(name: string): void;
1396
+
1397
+ /**
1398
+ * 删除变量
1399
+ * @param variable 已有的变量实例
1400
+ */
1401
+ removeVariable(variable: Variable): void;
1402
+
1403
+ removeVariable(options: string | Variable) {
1404
+ let variable: Variable;
1405
+ if (typeof options === 'string') {
1406
+ variable = (this.variables as Variable[]).find((item) => item.name === options);
1407
+ if (!variable) {
1408
+ throw new Error(`找不到变量 ${options}`);
1409
+ }
1410
+ } else {
1411
+ variable = options;
1412
+ }
1413
+ return variable.delete();
1414
+ }
1415
+
1416
+ __removeVariable(variable: Variable) {
1417
+ const { parentKey } = variable;
1418
+ const params: Params = {
1419
+ parentNode: this,
1420
+ parentKey,
1421
+ index: -1,
1422
+ object: null,
1423
+ oldObject: variable,
1424
+ };
1425
+ if (parentKey) {
1426
+ params.parentKey = parentKey;
1427
+ if (Array.isArray((this as any)[parentKey])) {
1428
+ const index = (this as any)[parentKey].indexOf(variable);
1429
+ ~index && (this as any)[parentKey].splice(index, 1);
1430
+ params.index = index;
1431
+ } else if ((this as any)[parentKey] === variable) {
1432
+ params.index = 0;
1433
+ (this as any)[parentKey] = undefined;
1434
+ }
1435
+ }
1436
+ return params;
1437
+ }
1438
+
1439
+ /**
1440
+ * 删除输出参数
1441
+ * @param name 输出参数名称
1442
+ */
1443
+ removeReturn(name: string): void;
1444
+
1445
+ /**
1446
+ * 删除输出参数
1447
+ * @param ret 已有的输出参数实例
1448
+ */
1449
+ removeReturn(ret: Return): void;
1450
+
1451
+ removeReturn(options: string | Return) {
1452
+ let ret: Return;
1453
+ if (typeof options === 'string') {
1454
+ ret = (this.returns as Return[]).find((item) => item.name === options);
1455
+ if (!ret) {
1456
+ throw new Error(`找不到输出参数 ${options}`);
1457
+ }
1458
+ } else {
1459
+ ret = options;
1460
+ }
1461
+ return ret.delete();
1462
+ }
1463
+
1464
+ __removeReturn(ret: Return) {
1465
+ const { parentKey } = ret;
1466
+ const params: Params = {
1467
+ parentNode: this,
1468
+ parentKey,
1469
+ index: -1,
1470
+ object: null,
1471
+ oldObject: ret,
1472
+ };
1473
+ if (parentKey) {
1474
+ params.parentKey = parentKey;
1475
+ if (Array.isArray((this as any)[parentKey])) {
1476
+ const index = (this as any)[parentKey].indexOf(ret);
1477
+ ~index && (this as any)[parentKey].splice(index, 1);
1478
+ params.index = index;
1479
+ } else if ((this as any)[parentKey] === ret) {
1480
+ params.index = 0;
1481
+ (this as any)[parentKey] = undefined;
1482
+ }
1483
+ }
1484
+ return params;
1485
+ }
1486
+
1487
+ /**
1488
+ * 删除常量
1489
+ * @param name 常量名称
1490
+ */
1491
+ removeConstant(name: string): void;
1492
+
1493
+ /**
1494
+ * 删除常量
1495
+ * @param constant 已有的常量实例
1496
+ */
1497
+ removeConstant(constant: Constant): void;
1498
+
1499
+ removeConstant(options: string | Constant) {
1500
+ let constant: Constant;
1501
+ if (typeof options === 'string') {
1502
+ constant = (this.constants as Constant[]).find((item) => item.name === options);
1503
+ if (!constant) {
1504
+ throw new Error(`找不到常量 ${options}`);
1505
+ }
1506
+ } else {
1507
+ constant = options;
1508
+ }
1509
+ return constant.delete();
1510
+ }
1511
+
1512
+ __removeConstant(constant: Constant) {
1513
+ const { parentKey } = constant;
1514
+ const params: Params = {
1515
+ parentNode: this,
1516
+ parentKey,
1517
+ index: -1,
1518
+ object: null,
1519
+ oldObject: constant,
1520
+ };
1521
+ if (parentKey) {
1522
+ params.parentKey = parentKey;
1523
+ if (Array.isArray((this as any)[parentKey])) {
1524
+ const index = (this as any)[parentKey].indexOf(constant);
1525
+ ~index && (this as any)[parentKey].splice(index, 1);
1526
+ params.index = index;
1527
+ } else if ((this as any)[parentKey] === constant) {
1528
+ params.index = 0;
1529
+ (this as any)[parentKey] = undefined;
1530
+ }
1531
+ }
1532
+ return params;
1533
+ }
1534
+
1535
+ /**
1536
+ * 删除元素绑定属性
1537
+ * @param name 元素绑定属性名称
1538
+ */
1539
+ removeBindAttribute(name: string): void;
1540
+
1541
+ /**
1542
+ * 删除元素绑定属性
1543
+ * @param bindAttribute 已有的元素绑定属性实例
1544
+ */
1545
+ removeBindAttribute(bindAttribute: BindAttribute): void;
1546
+
1547
+ removeBindAttribute(options: string | BindAttribute) {
1548
+ let bindAttribute: BindAttribute;
1549
+ if (typeof options === 'string') {
1550
+ bindAttribute = (this.bindAttrs as BindAttribute[]).find((item) => item.name === options);
1551
+ if (!bindAttribute) {
1552
+ throw new Error(`找不到元素绑定属性 ${options}`);
1553
+ }
1554
+ } else {
1555
+ bindAttribute = options;
1556
+ }
1557
+ return bindAttribute.delete();
1558
+ }
1559
+
1560
+ __removeBindAttribute(bindAttribute: BindAttribute) {
1561
+ const { parentKey } = bindAttribute;
1562
+ const params: Params = {
1563
+ parentNode: this,
1564
+ parentKey,
1565
+ index: -1,
1566
+ object: null,
1567
+ oldObject: bindAttribute,
1568
+ };
1569
+ if (parentKey) {
1570
+ params.parentKey = parentKey;
1571
+ if (Array.isArray((this as any)[parentKey])) {
1572
+ const index = (this as any)[parentKey].indexOf(bindAttribute);
1573
+ ~index && (this as any)[parentKey].splice(index, 1);
1574
+ params.index = index;
1575
+ } else if ((this as any)[parentKey] === bindAttribute) {
1576
+ params.index = 0;
1577
+ (this as any)[parentKey] = undefined;
1578
+ }
1579
+ }
1580
+ return params;
1581
+ }
1582
+
1583
+ //= ===============================================================================
1584
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1585
+ // 自动生成的代码已结束。下面可以手动编写。
1586
+ //= ===============================================================================
1587
+ getVarExistingNames(excludedList: Array<Variable | Return | Constant> = []) {
1588
+ const excludedSet = new Set(excludedList);
1589
+ return [...this.variables, ...this.returns, ...this.constants].filter((item) => !excludedSet.has(item)).map((item) => item.name);
1590
+ }
1591
+
1592
+ get isUserTask() {
1593
+ return this.type === 'UserTask' || this.type === 'ApprovalTask' || this.type === 'InitiateTask';
1594
+ }
1595
+
1596
+ get logics() {
1597
+ return [...genUserTaskLogic(this)];
1598
+ // const ns = entity2LogicNamespace(this);
1599
+ // ns.path = this.getNamespace() + '.' + ns.name;
1600
+ // return ns;
1601
+ }
1602
+
1603
+ get assigneeLogics() {
1604
+ let logics: Array<Logic> = [];
1605
+ this.bindAttrs.forEach((bindAttr) => {
1606
+ if (bindAttr.assignee) {
1607
+ logics = bindAttr.assignee.logicUsers;
1608
+ }
1609
+ });
1610
+ return logics;
1611
+ }
1612
+
1613
+ getNamespace(ns: string) {
1614
+ if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
1615
+ const parentNamespace = (this.parentNode as Namespace).getNamespace();
1616
+ const parentName = this.parentNode.name;
1617
+ const arr = [parentNamespace];
1618
+ if (this.parentNode.concept !== 'App' && parentName) {
1619
+ arr.push(parentName);
1620
+ }
1621
+ return `${arr.join('.')}.${ns || 'bindEvent'}`;
1622
+ }
1623
+ throw new Error('无法获取命名空间,请设置 parentNode!');
1624
+ }
1625
+
1626
+ async cancelBindDelete(processDelete: boolean) {
1627
+ if (!processDelete) this.delete();
1628
+ await Promise.all(
1629
+ this.bindAttrs.map(async ({ destination }) => {
1630
+ if (destination && destination.viewNode) {
1631
+ const view = destination.viewNode;
1632
+ const name = this.uniqueTaskId(view);
1633
+ const node = view.params.find((param: any) => param.name === name);
1634
+ if (!node) return;
1635
+ const UsageMap = await node.findUsage();
1636
+ const usageNodes = UsageMap.get(this.process);
1637
+ // console.log(UsageMap, usageNodes)
1638
+ if (!UsageMap.size || (UsageMap.size === 1 && usageNodes && (!usageNodes.children || usageNodes.children.length === 1)))
1639
+ view.removeParam(name);
883
1640
  }
884
- this.constants.splice(index, 0, constant);
885
- return constant;
886
- }
887
-
888
- /**
889
- * 插入常量
890
- * @param name 常量名称,如果不填会自动生成一个唯一名称
891
- */
892
- insertConstantAt(name: string, index: number): Constant;
893
-
894
- /**
895
- * 插入常量
896
- * @param constantOptions 常量参数
897
- */
898
- insertConstantAt(constantOptions: Partial<Constant>, index: number): Constant;
899
-
900
- /**
901
- * 插入常量
902
- * @param constant 已有的常量实例
903
- */
904
- insertConstantAt(constant: Constant, index: number): Constant;
905
-
906
- insertConstantAt(options: string | Partial<Constant> | Constant, index: number) {
907
- const node = this._insertConstantAt(options as any, index);
908
- node.create({
909
- index,
910
- parentNode: this,
911
- parentKey: 'constants',
1641
+ })
1642
+ );
1643
+ }
1644
+
1645
+ // 获取当前页面类型为String的taskId参数
1646
+ uniqueTaskId(view: View) {
1647
+ let count = 0;
1648
+ let uniqueName = 'taskId0';
1649
+ let param = view.params.find((param) => param.name === 'taskId');
1650
+ if (!param || param.typeAnnotation.typeName === 'String') return 'taskId';
1651
+ do {
1652
+ count++;
1653
+ uniqueName = uniqueName.substring(0, uniqueName.length - 1) + count;
1654
+ param = view.params.find((param) => param.name === uniqueName);
1655
+ if (!param) {
1656
+ return uniqueName;
1657
+ }
1658
+ } while (param.typeAnnotation.typeName !== 'String');
1659
+ return uniqueName;
1660
+ }
1661
+
1662
+ @withSourceMap()
1663
+ toEmbeddedTS(state?: TranslatorState): string {
1664
+ // this.syncLogic();
1665
+ const tab0 = indent(state?.tabSize || 0);
1666
+ const tab1 = indent((state?.tabSize || 0) + 1);
1667
+ const tab3 = indent((state?.tabSize || 0) + 2);
1668
+ const tab4 = indent((state?.tabSize || 0) + 3);
1669
+ const tab5 = indent((state?.tabSize || 0) + 4);
1670
+ const tab6 = indent((state?.tabSize || 0) + 5);
1671
+ const constantsArr: any = [];
1672
+ const returnsArr: any = [];
1673
+ let code = `${this.name}: {\n`;
1674
+ this.variables.forEach((property) => {
1675
+ code += `${tab1}`;
1676
+ code += `${property.toEmbeddedTSInProcess(shiftState(state, code, { inline: true }))},\n`;
1677
+ });
1678
+ this.returns.forEach((property, index) => {
1679
+ code += `${tab1}`;
1680
+ returnsArr.push(property.toEmbeddedTSInProcess(shiftState(state, code, { inline: true })));
1681
+ code += `${returnsArr[index]},\n`;
1682
+ });
1683
+ this.constants.forEach((property, index) => {
1684
+ code += `${tab1}`;
1685
+ constantsArr.push(property.toEmbeddedTSInProcess(shiftState(state, code, { inline: true })));
1686
+ code += `${constantsArr[index]},\n`;
1687
+ });
1688
+ const afterLinks = getFlowAfterElements(this);
1689
+ const beforeLinks = getFlowBeforeElements(this);
1690
+ if (this.isUserTask || this.type === 'ExclusiveGateway' || this.type === 'AutoTask' || this.type === 'InclusiveGateway') {
1691
+ const prevTasks = getPreviousTask(this);
1692
+ let prevCode = `${tab4}__ProcessIdentification__;\n`;
1693
+ prevCode += `${tab4}const ${this.process.name} = {\n`;
1694
+ const processName = this.process.name;
1695
+ this.process.params.forEach((p) => {
1696
+ prevCode += `${tab5}${p.name}: app.processes.${processName}.${p.name},\n`;
1697
+ });
1698
+ this.process.returns.forEach((p) => {
1699
+ prevCode += `${tab5}${p.name}: app.processes.${processName}.${p.name},\n`;
1700
+ });
1701
+ this.process.constants.forEach((p) => {
1702
+ prevCode += `${tab5}${p.name}: app.processes.${processName}.${p.name},\n`;
1703
+ });
1704
+ // prevCode += `${tab4}elements: {\n`
1705
+ prevCode += prevTasks.map((t) => `${tab5}${t.name}: elements.${t.name},\n`).join(``);
1706
+
1707
+ // prevCode += `${tab4}}\n`
1708
+
1709
+ if (this.isUserTask) {
1710
+ // 任务完成时可以拿到输出参数,prevCodeClose包含输出参数
1711
+ let prevCodeClose = `${prevCode}\n${tab5}${this.name}: { \n`;
1712
+ this.constants.forEach((c, index) => {
1713
+ prevCodeClose += tab6;
1714
+ prevCodeClose += constantsArr[index];
1715
+ prevCodeClose += ',';
912
1716
  });
913
- return node;
914
- }
915
-
916
- /**
917
- * 添加常量
918
- * @internal
919
- * @param name 常量名称,如果不填会自动生成一个唯一名称
920
- */
921
- _addConstant(name?: string): Constant;
922
-
923
- /**
924
- * 添加常量
925
- * @internal
926
- * @param constantOptions 常量参数
927
- */
928
- _addConstant(constantOptions: Partial<Constant>): Constant;
929
-
930
- /**
931
- * 添加常量
932
- * @internal
933
- * @param constant 已有的常量实例
934
- */
935
- _addConstant(constant: Constant): Constant;
936
-
937
- _addConstant(options?: string | Partial<Constant> | Constant) {
938
- const index = this.constants.length;
939
- return this._insertConstantAt(options as any, index);
940
- }
941
-
942
- /**
943
- * 添加常量
944
- * @internal
945
- * @param name 常量名称,如果不填会自动生成一个唯一名称
946
- */
947
- addConstant(name?: string): Constant;
948
-
949
- /**
950
- * 添加常量
951
- * @param constantOptions 常量参数
952
- */
953
- addConstant(constantOptions: Partial<Constant>): Constant;
954
-
955
- /**
956
- * 添加常量
957
- * @param constant 已有的常量实例
958
- */
959
- addConstant(constant: Constant): Constant;
960
-
961
- addConstant(options?: string | Partial<Constant> | Constant) {
962
- const node = this._addConstant(options as any);
963
- const index = this.constants.indexOf(node);
964
- node.create({
965
- index,
966
- parentNode: this,
967
- parentKey: 'constants',
1717
+ this.returns.forEach((c, index) => {
1718
+ prevCodeClose += `\n${tab6}`;
1719
+ prevCodeClose += returnsArr[index];
1720
+ prevCodeClose += ',';
968
1721
  });
969
- return node;
970
- }
971
-
972
-
973
- getBindAttributeExistingNames(excludedList: Array<BindAttribute> = []) {
974
- const excludedSet = new Set(excludedList);
975
- return ((this.bindAttrs as BindAttribute[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
976
- }
977
- getBindAttributeUniqueName(name = 'bindAttribute1') {
978
- return utils.unique(name, this.getBindAttributeExistingNames(), undefined, false);
979
- }
980
-
981
- /**
982
- * 插入元素绑定属性
983
- * @internal
984
- * @param name 元素绑定属性名称,如果不填会自动生成一个唯一名称
985
- */
986
- _insertBindAttributeAt(name: string, index: number): BindAttribute;
987
-
988
- /**
989
- * 插入元素绑定属性
990
- * @internal
991
- * @param bindAttributeOptions 元素绑定属性参数
992
- */
993
- _insertBindAttributeAt(bindAttributeOptions: Partial<BindAttribute>, index: number): BindAttribute;
994
-
995
- /**
996
- * 插入元素绑定属性
997
- * @internal
998
- * @param bindAttribute 已有的元素绑定属性实例
999
- */
1000
- _insertBindAttributeAt(bindAttribute: BindAttribute, index: number): BindAttribute;
1001
-
1002
- _insertBindAttributeAt(options: string | Partial<BindAttribute> | BindAttribute, index: number) {
1003
- const bindAttributeOptions: any = {};
1004
- const relationOptions = { parentNode: this, parentKey: 'bindAttrs' };
1005
- let bindAttribute: BindAttribute;
1006
- if (!options) {
1007
- bindAttribute = BindAttribute.from({
1008
- ...bindAttributeOptions,
1009
- name: this.getBindAttributeUniqueName(),
1010
- }, this, 'bindAttrs');
1011
- } else if (typeof options === 'string') {
1012
- bindAttribute = BindAttribute.from({
1013
- ...bindAttributeOptions,
1014
- name: options,
1015
- }, this, 'bindAttrs');
1016
- } else if (options instanceof BindAttribute) {
1017
- options.ensureDelete(); // 同一实例不支持多处存在
1018
- bindAttribute = options;
1019
- Object.assign(bindAttribute, relationOptions);
1020
- } else {
1021
- bindAttribute = BindAttribute.from({
1022
- ...bindAttributeOptions,
1023
- ...options,
1024
- }, this, 'bindAttrs');
1025
- }
1026
- this.bindAttrs.splice(index, 0, bindAttribute);
1027
- return bindAttribute;
1028
- }
1029
-
1030
- /**
1031
- * 插入元素绑定属性
1032
- * @param name 元素绑定属性名称,如果不填会自动生成一个唯一名称
1033
- */
1034
- insertBindAttributeAt(name: string, index: number): BindAttribute;
1035
-
1036
- /**
1037
- * 插入元素绑定属性
1038
- * @param bindAttributeOptions 元素绑定属性参数
1039
- */
1040
- insertBindAttributeAt(bindAttributeOptions: Partial<BindAttribute>, index: number): BindAttribute;
1041
-
1042
- /**
1043
- * 插入元素绑定属性
1044
- * @param bindAttribute 已有的元素绑定属性实例
1045
- */
1046
- insertBindAttributeAt(bindAttribute: BindAttribute, index: number): BindAttribute;
1047
-
1048
- insertBindAttributeAt(options: string | Partial<BindAttribute> | BindAttribute, index: number) {
1049
- const node = this._insertBindAttributeAt(options as any, index);
1050
- node.create({
1051
- index,
1052
- parentNode: this,
1053
- parentKey: 'bindAttrs',
1722
+ prevCodeClose += ` \n${tab5}}\n`;
1723
+ prevCodeClose += `${tab4}}\n`;
1724
+
1725
+ prevCode += `\n${tab5}${this.name}: { \n`;
1726
+ this.constants.forEach((c, index) => {
1727
+ prevCode += `${tab6}`;
1728
+ prevCode += constantsArr[index];
1729
+ prevCode += ',';
1054
1730
  });
1055
- return node;
1056
- }
1057
-
1058
- /**
1059
- * 添加元素绑定属性
1060
- * @internal
1061
- * @param name 元素绑定属性名称,如果不填会自动生成一个唯一名称
1062
- */
1063
- _addBindAttribute(name?: string): BindAttribute;
1064
-
1065
- /**
1066
- * 添加元素绑定属性
1067
- * @internal
1068
- * @param bindAttributeOptions 元素绑定属性参数
1069
- */
1070
- _addBindAttribute(bindAttributeOptions: Partial<BindAttribute>): BindAttribute;
1071
-
1072
- /**
1073
- * 添加元素绑定属性
1074
- * @internal
1075
- * @param bindAttribute 已有的元素绑定属性实例
1076
- */
1077
- _addBindAttribute(bindAttribute: BindAttribute): BindAttribute;
1078
-
1079
- _addBindAttribute(options?: string | Partial<BindAttribute> | BindAttribute) {
1080
- const index = this.bindAttrs.length;
1081
- return this._insertBindAttributeAt(options as any, index);
1082
- }
1083
-
1084
- /**
1085
- * 添加元素绑定属性
1086
- * @internal
1087
- * @param name 元素绑定属性名称,如果不填会自动生成一个唯一名称
1088
- */
1089
- addBindAttribute(name?: string): BindAttribute;
1090
-
1091
- /**
1092
- * 添加元素绑定属性
1093
- * @param bindAttributeOptions 元素绑定属性参数
1094
- */
1095
- addBindAttribute(bindAttributeOptions: Partial<BindAttribute>): BindAttribute;
1096
-
1097
- /**
1098
- * 添加元素绑定属性
1099
- * @param bindAttribute 已有的元素绑定属性实例
1100
- */
1101
- addBindAttribute(bindAttribute: BindAttribute): BindAttribute;
1102
-
1103
- addBindAttribute(options?: string | Partial<BindAttribute> | BindAttribute) {
1104
- const node = this._addBindAttribute(options as any);
1105
- const index = this.bindAttrs.indexOf(node);
1106
- node.create({
1107
- index,
1108
- parentNode: this,
1109
- parentKey: 'bindAttrs',
1110
- });
1111
- return node;
1112
- }
1113
-
1114
-
1115
-
1116
-
1117
- /**
1118
- * 删除元素绑定事件
1119
- * @param name 元素绑定事件名称
1120
- */
1121
- removeBindEvent(name: string): void;
1122
-
1123
- /**
1124
- * 删除元素绑定事件
1125
- * @param bindEvent 已有的元素绑定事件实例
1126
- */
1127
- removeBindEvent(bindEvent: BindEvent): void;
1128
-
1129
- removeBindEvent(options: string | BindEvent) {
1130
- let bindEvent: BindEvent;
1131
- if (typeof options === 'string') {
1132
- bindEvent = (this.bindEvents as BindEvent[]).find((item) => item.name === options);
1133
- if (!bindEvent) {
1134
- throw new Error('找不到元素绑定事件 ' + options);
1135
- }
1136
- } else {
1137
- bindEvent = options;
1138
- }
1139
- return bindEvent.delete();
1140
- }
1141
-
1142
- __removeBindEvent(bindEvent: BindEvent) {
1143
- const parentKey = bindEvent.parentKey;
1144
- const params: Params = {
1145
- parentNode: this,
1146
- parentKey,
1147
- index: -1,
1148
- object: null,
1149
- oldObject: bindEvent,
1150
- };
1151
- if (parentKey) {
1152
- params.parentKey = parentKey;
1153
- if (Array.isArray((this as any)[parentKey])) {
1154
- const index = (this as any)[parentKey].indexOf(bindEvent);
1155
- ~index && (this as any)[parentKey].splice(index, 1);
1156
- params.index = index;
1157
- } else if ((this as any)[parentKey] === bindEvent) {
1158
- params.index = 0;
1159
- (this as any)[parentKey] = undefined;
1160
- }
1161
- }
1162
- return params;
1163
- }
1164
-
1165
-
1166
-
1167
- /**
1168
- * 删除矩形信息
1169
- * @param name 矩形信息名称
1170
- */
1171
- removeBounds(name: string): void;
1172
-
1173
- /**
1174
- * 删除矩形信息
1175
- * @param bounds 已有的矩形信息实例
1176
- */
1177
- removeBounds(bounds: Rect): void;
1178
-
1179
- removeBounds(options: string | Rect) {
1180
- let bounds: Rect;
1181
- if (typeof options === 'string') {
1182
- bounds = this.bounds;
1183
- if (!bounds) {
1184
- throw new Error('找不到矩形信息 ' + options);
1185
- }
1186
- } else {
1187
- bounds = options;
1188
- }
1189
- return bounds.delete();
1190
- }
1191
-
1192
- __removeRect(rect: Rect) {
1193
- const parentKey = rect.parentKey;
1194
- const params: Params = {
1195
- parentNode: this,
1196
- parentKey,
1197
- index: -1,
1198
- object: null,
1199
- oldObject: rect,
1200
- };
1201
- if (parentKey) {
1202
- params.parentKey = parentKey;
1203
- if (Array.isArray((this as any)[parentKey])) {
1204
- const index = (this as any)[parentKey].indexOf(rect);
1205
- ~index && (this as any)[parentKey].splice(index, 1);
1206
- params.index = index;
1207
- } else if ((this as any)[parentKey] === rect) {
1208
- params.index = 0;
1209
- (this as any)[parentKey] = undefined;
1210
- }
1211
- }
1212
- return params;
1213
- }
1214
-
1215
-
1216
-
1217
- /**
1218
- * 删除点信息
1219
- * @param name 点信息名称
1220
- */
1221
- removePoint(name: string): void;
1222
-
1223
- /**
1224
- * 删除点信息
1225
- * @param point 已有的点信息实例
1226
- */
1227
- removePoint(point: Point): void;
1228
-
1229
- removePoint(options: string | Point) {
1230
- let point: Point;
1231
- if (typeof options === 'string') {
1232
- point = (this.waypoints as Point[]).find((item) => item.name === options);
1233
- if (!point) {
1234
- throw new Error('找不到点信息 ' + options);
1235
- }
1236
- } else {
1237
- point = options;
1238
- }
1239
- return point.delete();
1240
- }
1241
-
1242
- __removePoint(point: Point) {
1243
- const parentKey = point.parentKey;
1244
- const params: Params = {
1245
- parentNode: this,
1246
- parentKey,
1247
- index: -1,
1248
- object: null,
1249
- oldObject: point,
1250
- };
1251
- if (parentKey) {
1252
- params.parentKey = parentKey;
1253
- if (Array.isArray((this as any)[parentKey])) {
1254
- const index = (this as any)[parentKey].indexOf(point);
1255
- ~index && (this as any)[parentKey].splice(index, 1);
1256
- params.index = index;
1257
- } else if ((this as any)[parentKey] === point) {
1258
- params.index = 0;
1259
- (this as any)[parentKey] = undefined;
1260
- }
1261
- }
1262
- return params;
1263
- }
1264
-
1265
-
1266
-
1267
- /**
1268
- * 删除逻辑
1269
- * @param name 逻辑名称
1270
- */
1271
- removeLogic(name: string): void;
1272
-
1273
- /**
1274
- * 删除逻辑
1275
- * @param logic 已有的逻辑实例
1276
- */
1277
- removeLogic(logic: Logic): void;
1278
-
1279
- removeLogic(options: string | Logic) {
1280
- let logic: Logic;
1281
- if (typeof options === 'string') {
1282
- logic = this.logic;
1283
- if (!logic) {
1284
- throw new Error('找不到逻辑 ' + options);
1285
- }
1286
- } else {
1287
- logic = options;
1288
- }
1289
- return logic.delete();
1290
- }
1291
-
1292
- __removeLogic(logic: Logic) {
1293
- const parentKey = logic.parentKey;
1294
- const params: Params = {
1295
- parentNode: this,
1296
- parentKey,
1297
- index: -1,
1298
- object: null,
1299
- oldObject: logic,
1300
- };
1301
- if (parentKey) {
1302
- params.parentKey = parentKey;
1303
- if (Array.isArray((this as any)[parentKey])) {
1304
- const index = (this as any)[parentKey].indexOf(logic);
1305
- ~index && (this as any)[parentKey].splice(index, 1);
1306
- params.index = index;
1307
- } else if ((this as any)[parentKey] === logic) {
1308
- params.index = 0;
1309
- (this as any)[parentKey] = undefined;
1310
- }
1311
- }
1312
- return params;
1313
- }
1314
-
1315
-
1316
-
1317
- /**
1318
- * 删除变量
1319
- * @param name 变量名称
1320
- */
1321
- removeVariable(name: string): void;
1322
-
1323
- /**
1324
- * 删除变量
1325
- * @param variable 已有的变量实例
1326
- */
1327
- removeVariable(variable: Variable): void;
1328
-
1329
- removeVariable(options: string | Variable) {
1330
- let variable: Variable;
1331
- if (typeof options === 'string') {
1332
- variable = (this.variables as Variable[]).find((item) => item.name === options);
1333
- if (!variable) {
1334
- throw new Error('找不到变量 ' + options);
1335
- }
1336
- } else {
1337
- variable = options;
1338
- }
1339
- return variable.delete();
1340
- }
1341
-
1342
- __removeVariable(variable: Variable) {
1343
- const parentKey = variable.parentKey;
1344
- const params: Params = {
1345
- parentNode: this,
1346
- parentKey,
1347
- index: -1,
1348
- object: null,
1349
- oldObject: variable,
1350
- };
1351
- if (parentKey) {
1352
- params.parentKey = parentKey;
1353
- if (Array.isArray((this as any)[parentKey])) {
1354
- const index = (this as any)[parentKey].indexOf(variable);
1355
- ~index && (this as any)[parentKey].splice(index, 1);
1356
- params.index = index;
1357
- } else if ((this as any)[parentKey] === variable) {
1358
- params.index = 0;
1359
- (this as any)[parentKey] = undefined;
1360
- }
1361
- }
1362
- return params;
1363
- }
1364
-
1365
-
1366
-
1367
- /**
1368
- * 删除输出参数
1369
- * @param name 输出参数名称
1370
- */
1371
- removeReturn(name: string): void;
1372
-
1373
- /**
1374
- * 删除输出参数
1375
- * @param ret 已有的输出参数实例
1376
- */
1377
- removeReturn(ret: Return): void;
1378
-
1379
- removeReturn(options: string | Return) {
1380
- let ret: Return;
1381
- if (typeof options === 'string') {
1382
- ret = (this.returns as Return[]).find((item) => item.name === options);
1383
- if (!ret) {
1384
- throw new Error('找不到输出参数 ' + options);
1385
- }
1386
- } else {
1387
- ret = options;
1388
- }
1389
- return ret.delete();
1390
- }
1391
-
1392
- __removeReturn(ret: Return) {
1393
- const parentKey = ret.parentKey;
1394
- const params: Params = {
1395
- parentNode: this,
1396
- parentKey,
1397
- index: -1,
1398
- object: null,
1399
- oldObject: ret,
1400
- };
1401
- if (parentKey) {
1402
- params.parentKey = parentKey;
1403
- if (Array.isArray((this as any)[parentKey])) {
1404
- const index = (this as any)[parentKey].indexOf(ret);
1405
- ~index && (this as any)[parentKey].splice(index, 1);
1406
- params.index = index;
1407
- } else if ((this as any)[parentKey] === ret) {
1408
- params.index = 0;
1409
- (this as any)[parentKey] = undefined;
1410
- }
1411
- }
1412
- return params;
1413
- }
1414
-
1415
-
1416
-
1417
- /**
1418
- * 删除常量
1419
- * @param name 常量名称
1420
- */
1421
- removeConstant(name: string): void;
1422
-
1423
- /**
1424
- * 删除常量
1425
- * @param constant 已有的常量实例
1426
- */
1427
- removeConstant(constant: Constant): void;
1428
-
1429
- removeConstant(options: string | Constant) {
1430
- let constant: Constant;
1431
- if (typeof options === 'string') {
1432
- constant = (this.constants as Constant[]).find((item) => item.name === options);
1433
- if (!constant) {
1434
- throw new Error('找不到常量 ' + options);
1435
- }
1436
- } else {
1437
- constant = options;
1438
- }
1439
- return constant.delete();
1440
- }
1441
-
1442
- __removeConstant(constant: Constant) {
1443
- const parentKey = constant.parentKey;
1444
- const params: Params = {
1445
- parentNode: this,
1446
- parentKey,
1447
- index: -1,
1448
- object: null,
1449
- oldObject: constant,
1450
- };
1451
- if (parentKey) {
1452
- params.parentKey = parentKey;
1453
- if (Array.isArray((this as any)[parentKey])) {
1454
- const index = (this as any)[parentKey].indexOf(constant);
1455
- ~index && (this as any)[parentKey].splice(index, 1);
1456
- params.index = index;
1457
- } else if ((this as any)[parentKey] === constant) {
1458
- params.index = 0;
1459
- (this as any)[parentKey] = undefined;
1460
- }
1731
+ prevCode += ` \n${tab5}}\n`;
1732
+ prevCode += `${tab4}}\n`;
1733
+ if (Array.isArray(this.bindEvents)) {
1734
+ this.bindEvents.forEach((bindEvent) => {
1735
+ // 任务完成时可以拿到输出参数
1736
+ const currentPrevCode = bindEvent.name === 'OnClose' ? prevCodeClose : prevCode;
1737
+ code += `${tab1}${bindEvent.name}: () => [\n`;
1738
+ bindEvent.logics.forEach((logic) => {
1739
+ code += `${logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: 0 }), currentPrevCode, true, true)}${tab3},\n`;
1740
+ });
1741
+ code += `${tab1}],\n`;
1742
+ });
1461
1743
  }
1462
- return params;
1463
- }
1464
-
1465
-
1466
-
1467
- /**
1468
- * 删除元素绑定属性
1469
- * @param name 元素绑定属性名称
1470
- */
1471
- removeBindAttribute(name: string): void;
1472
-
1473
- /**
1474
- * 删除元素绑定属性
1475
- * @param bindAttribute 已有的元素绑定属性实例
1476
- */
1477
- removeBindAttribute(bindAttribute: BindAttribute): void;
1478
-
1479
- removeBindAttribute(options: string | BindAttribute) {
1480
- let bindAttribute: BindAttribute;
1481
- if (typeof options === 'string') {
1482
- bindAttribute = (this.bindAttrs as BindAttribute[]).find((item) => item.name === options);
1483
- if (!bindAttribute) {
1484
- throw new Error('找不到元素绑定属性 ' + options);
1485
- }
1744
+ code += `${tab1}logics: {\n`;
1745
+ let destinationAttrs = this.bindAttrs.filter((attr) => attr.name === 'destination' || attr.name.startsWith('destination-'));
1746
+ const destinationAllEmpty = destinationAttrs.length && destinationAttrs.every((attr) => !attr.destination.viewNamespace);
1747
+ if (destinationAllEmpty) {
1748
+ code += `${destinationAttrs[0].destination.toEmbeddedTSInProcess(
1749
+ shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }),
1750
+ prevCode
1751
+ )},\n`;
1486
1752
  } else {
1487
- bindAttribute = options;
1753
+ destinationAttrs = destinationAttrs.filter((attr) => attr.destination.viewNamespace);
1754
+ destinationAttrs.forEach((attr) => {
1755
+ code += `${attr.destination.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }), prevCode)},\n`;
1756
+ });
1488
1757
  }
1489
- return bindAttribute.delete();
1490
- }
1491
-
1492
- __removeBindAttribute(bindAttribute: BindAttribute) {
1493
- const parentKey = bindAttribute.parentKey;
1494
- const params: Params = {
1495
- parentNode: this,
1496
- parentKey,
1497
- index: -1,
1498
- object: null,
1499
- oldObject: bindAttribute,
1500
- };
1501
- if (parentKey) {
1502
- params.parentKey = parentKey;
1503
- if (Array.isArray((this as any)[parentKey])) {
1504
- const index = (this as any)[parentKey].indexOf(bindAttribute);
1505
- ~index && (this as any)[parentKey].splice(index, 1);
1506
- params.index = index;
1507
- } else if ((this as any)[parentKey] === bindAttribute) {
1508
- params.index = 0;
1509
- (this as any)[parentKey] = undefined;
1510
- }
1511
- }
1512
- return params;
1513
- }
1514
-
1515
- //================================================================================
1516
- // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1517
- // 自动生成的代码已结束。下面可以手动编写。
1518
- //================================================================================
1519
- getVarExistingNames(excludedList: Array<Variable | Return | Constant> = []) {
1520
- const excludedSet = new Set(excludedList);
1521
- return [...this.variables, ...this.returns, ...this.constants].filter((item) => !excludedSet.has(item)).map((item) => item.name);
1522
- }
1523
-
1524
- get isUserTask() {
1525
- return this.type === 'UserTask' || this.type === 'ApprovalTask' || this.type === 'InitiateTask';
1526
- }
1527
-
1528
- get logics() {
1529
- return [...genUserTaskLogic(this)];
1530
- // const ns = entity2LogicNamespace(this);
1531
- // ns.path = this.getNamespace() + '.' + ns.name;
1532
- // return ns;
1533
- }
1534
-
1535
- get assigneeLogics() {
1536
- let logics: Array<Logic> = [];
1537
- this.bindAttrs.forEach((bindAttr) => {
1538
- if (bindAttr.assignee) {
1539
- logics = bindAttr.assignee.logicUsers;
1540
- }
1758
+ this.bindAttrs.forEach((attr) => {
1759
+ if (attr.name === 'assignee') {
1760
+ code += `${tab3}assignee: function(): string[] {\n`;
1761
+ code += `${attr.assignee.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: state.tabSize + 3 }), prevCode)}\n`;
1762
+ code += `${tab3}},\n`;
1763
+ }
1541
1764
  });
1542
- return logics;
1543
- }
1765
+ const logics = genUserTaskLogic(this);
1766
+ // sourceMap 映射
1544
1767
 
1545
- getNamespace(ns: string) {
1546
- if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
1547
- const parentNamespace = (this.parentNode as Namespace).getNamespace();
1548
- const parentName = this.parentNode.name;
1549
- const arr = [parentNamespace];
1550
- if (this.parentNode.concept !== 'App' && parentName) {
1551
- arr.push(parentName);
1552
- }
1553
- return `${arr.join('.')}.${ns || 'bindEvent'}`;
1554
- } else
1555
- throw new Error('无法获取命名空间,请设置 parentNode!');
1556
- }
1557
- async cancelBindDelete(processDelete: boolean) {
1558
- if (!processDelete)
1559
- this.delete();
1560
- await Promise.all(this.bindAttrs.map(async ({ destination }) => {
1561
- if (destination && destination.viewNode) {
1562
- const view = destination.viewNode;
1563
- const name = this.uniqueTaskId(view);
1564
- const node = view.params.find((param: any) => param.name === name);
1565
- if (!node)
1566
- return;
1567
- const UsageMap = await node.findUsage();
1568
- const usageNodes = UsageMap.get(this.process);
1569
- // console.log(UsageMap, usageNodes)
1570
- if (!UsageMap.size || (UsageMap.size === 1 && usageNodes && (!usageNodes.children || usageNodes.children.length === 1)))
1571
- view.removeParam(name);
1572
- }
1573
- }));
1574
- }
1575
- //获取当前页面类型为String的taskId参数
1576
- uniqueTaskId(view: View) {
1577
- let count = 0;
1578
- let uniqueName = 'taskId0';
1579
- let param = view.params.find((param) => param.name === 'taskId');
1580
- if (!param || param.typeAnnotation.typeName === 'String')
1581
- return 'taskId';
1582
- do {
1583
- count++;
1584
- uniqueName = uniqueName.substring(0, uniqueName.length - 1) + count;
1585
- param = view.params.find((param) => param.name === uniqueName);
1586
- if (!param) {
1587
- return uniqueName;
1588
- }
1589
- } while (param.typeAnnotation.typeName !== 'String');
1590
- return uniqueName;
1591
- }
1768
+ logics.forEach((logic) => {
1769
+ logic.parentNode = this.process;
1592
1770
 
1593
- @withSourceMap()
1594
- toEmbeddedTS(state?: TranslatorState): string {
1595
- // this.syncLogic();
1596
- const tab0 = indent((state?.tabSize || 0));
1597
- const tab1 = indent((state?.tabSize || 0) + 1);
1598
- const tab3 = indent((state?.tabSize || 0) + 2);
1599
- const tab4 = indent((state?.tabSize || 0) + 3);
1600
- const tab5 = indent((state?.tabSize || 0) + 4);
1601
- const tab6 = indent((state?.tabSize || 0) + 5);
1602
- const constantsArr: any = [];
1603
- const returnsArr: any = [];
1604
- let code = `${this.name}: {\n`;
1605
- this.variables.forEach((property) => {
1606
- code += `${tab1}`;
1607
- code += `${property.toEmbeddedTSInProcess(shiftState(state, code, { inline: true }))},\n`;
1608
- });
1609
- this.returns.forEach((property, index) => {
1610
- code += `${tab1}`;
1611
- returnsArr.push(property.toEmbeddedTSInProcess(shiftState(state, code, { inline: true })));
1612
- code += `${returnsArr[index]},\n`;
1613
- });
1614
- this.constants.forEach((property, index) => {
1615
- code += `${tab1}`;
1616
- constantsArr.push(property.toEmbeddedTSInProcess(shiftState(state, code, { inline: true })));
1617
- code += `${constantsArr[index]},\n`;
1771
+ code += logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }));
1772
+ code += ',\n';
1618
1773
  });
1619
- const afterLinks = getFlowAfterElements(this);
1620
- const beforeLinks = getFlowBeforeElements(this);
1621
- if (this.isUserTask
1622
- || this.type === 'ExclusiveGateway'
1623
- || this.type === 'AutoTask'
1624
- || this.type === 'InclusiveGateway') {
1625
- const prevTasks = getPreviousTask(this);
1626
- let prevCode = `${tab4}__ProcessIdentification__;\n`;
1627
- prevCode += `${tab4}const ${this.process.name} = {\n`;
1628
- const processName = this.process.name;
1629
- this.process.params.forEach((p) => {
1630
- prevCode += `${tab5}${p.name}: app.processes.${processName}.${p.name},\n`;
1631
- });
1632
- this.process.returns.forEach((p) => {
1633
- prevCode += `${tab5}${p.name}: app.processes.${processName}.${p.name},\n`;
1634
- });
1635
- this.process.constants.forEach((p) => {
1636
- prevCode += `${tab5}${p.name}: app.processes.${processName}.${p.name},\n`;
1637
- });
1638
- // prevCode += `${tab4}elements: {\n`
1639
- prevCode += prevTasks.map((t) => `${tab5}${t.name}: elements.${t.name},\n`).join(``);
1640
-
1641
- // prevCode += `${tab4}}\n`
1642
-
1643
- if (this.isUserTask) {
1644
- //任务完成时可以拿到输出参数,prevCodeClose包含输出参数
1645
- let prevCodeClose = prevCode + `\n${tab5}${this.name}: { \n`;
1646
- this.constants.forEach((c, index) => {
1647
- prevCodeClose += tab6;
1648
- prevCodeClose += constantsArr[index];
1649
- prevCodeClose += ',';
1650
- });
1651
- this.returns.forEach((c, index) => {
1652
- prevCodeClose += `\n${tab6}`;
1653
- prevCodeClose += returnsArr[index];
1654
- prevCodeClose += ',';
1655
- });
1656
- prevCodeClose += ` \n${tab5}}\n`;
1657
- prevCodeClose += `${tab4}}\n`;
1658
-
1659
- prevCode += `\n${tab5}${this.name}: { \n`;
1660
- this.constants.forEach((c, index) => {
1661
- prevCode += `${tab6}`;
1662
- prevCode += constantsArr[index];
1663
- prevCode += ',';
1664
- });
1665
- prevCode += ` \n${tab5}}\n`;
1666
- prevCode += `${tab4}}\n`;
1667
- if (Array.isArray(this.bindEvents)) {
1668
- this.bindEvents.forEach((bindEvent) => {
1669
- //任务完成时可以拿到输出参数
1670
- const currentPrevCode = bindEvent.name === 'OnClose' ? prevCodeClose : prevCode;
1671
- code += `${tab1}${bindEvent.name}: () => [\n`;
1672
- bindEvent.logics.forEach((logic) => {
1673
- code += `${logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: 0 }), currentPrevCode, true, true)}${tab3},\n`;
1674
- });
1675
- code += `${tab1}],\n`;
1676
- });
1677
- }
1678
- code += `${tab1}logics: {\n`;
1679
- let destinationAttrs = this.bindAttrs.filter((attr) => attr.name === 'destination' || attr.name.startsWith('destination-'));
1680
- const destinationAllEmpty = destinationAttrs.length && destinationAttrs.every((attr) => !attr.destination.viewNamespace);
1681
- if (destinationAllEmpty) {
1682
- code += `${destinationAttrs[0].destination.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }), prevCode)},\n`;
1683
- } else {
1684
- destinationAttrs = destinationAttrs.filter((attr) => attr.destination.viewNamespace);
1685
- destinationAttrs.forEach((attr) => {
1686
- code += `${attr.destination.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }), prevCode)},\n`;
1687
- });
1688
- }
1689
- this.bindAttrs.forEach((attr) => {
1690
- if (attr.name === 'assignee') {
1691
- code += `${tab3}assignee: function(): string[] {\n`;
1692
- code += `${attr.assignee.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: state.tabSize + 3 }), prevCode)}\n`;
1693
- code += `${tab3}},\n`;
1694
- }
1695
- });
1696
- const logics = genUserTaskLogic(this);
1697
- // sourceMap 映射
1698
-
1699
- logics.forEach((logic) => {
1700
- logic.parentNode = this.process;
1701
-
1702
- code += logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }));
1703
- code += ',\n';
1704
- });
1705
- code += `${tab1}},\n`;
1706
- }
1707
-
1708
- if (['ExclusiveGateway', 'AutoTask', 'InclusiveGateway'].includes(this.type)) {
1709
- prevCode += `\n${tab5}${this.name}: elements.${this.name},\n`;
1710
- prevCode += `${tab3}}\n`;
1711
- code += `${tab1}logic: `;
1712
- code += `${this.logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }), prevCode, true)},\n`;
1713
- }
1714
- }
1715
- if (this.isUserTask || this.type === 'AutoTask' || this.type === 'StartNoneEvent') {
1716
- code += '_constraints: function() {\n';
1717
- code += `${tab1}nasl.process.oneOutcomeFlow(${afterLinks.map((l) => `'${l.name}'`).join(',')})\n`;
1718
- code += '},\n';
1719
- }
1720
- if (['ExclusiveGateway', 'ParallelGateway', 'InclusiveGateway'].includes(this.type)) {
1721
- code += '_constraints: function() {\n';
1722
- code += `${tab1}nasl.process.atLeastOneOutcomeFlow(${afterLinks.map((l) => `'${l.name}'`).join(',')})\n`;
1723
- code += `${tab1}nasl.process.atLeastOneOutcomeFlow(${beforeLinks.map((l) => `'${l.name}'`).join(',')})\n`;
1724
- if (afterLinks.length > 0 && beforeLinks.length > 0) {
1725
- code += `${tab1}nasl.process.atLeastThreeOutcomeFlow(${beforeLinks.concat(afterLinks).map((l) => `'${l.name}'`).join(',')})\n`;
1726
- }
1727
- code += '},\n';
1728
- }
1729
-
1730
- if (!isFromStartNode(this)) {
1731
- code += '__outOfProcess__,';
1732
- }
1733
-
1734
- code += `${tab0}\n},`;
1735
- // let code = '';
1736
- // this.variables.forEach((property) => {
1737
- // code += `${tab0}export let `;
1738
- // code += property.toEmbeddedTS(shiftState(state, code, { inline: true }));
1739
- // code += ';\n';
1740
- // });
1741
-
1742
- // this.returns.forEach((property) => {
1743
- // code += `${tab0}export let `;
1744
- // code += property.toEmbeddedTS(shiftState(state, code, { inline: true }));
1745
- // code += ';\n';
1746
- // });
1747
- // this.constants.forEach((property) => {
1748
- // code += `${tab0}export let `;
1749
- // code += property.toEmbeddedTS(shiftState(state, code, { inline: true }));
1750
- // code += ';\n';
1751
- // });
1752
- return code;
1753
- }
1754
-
1755
- // syncLogic() {
1756
- // if (this.type === 'UserTask') {
1757
- // if (!this.logic) {
1758
- // this.logic = new Logic({
1759
- // name: `complete`,
1760
- // });
1761
- // }
1762
- // this.logic.params = [...this.constants.map(constantToParam), ...this.returns.map(returnToParam)];
1763
- // }
1764
- // }
1765
-
1766
- /**
1767
- * 设置流程元素名称
1768
- */
1769
- // setNameWithFlowChange(name: string) {
1770
- // this.app.emit('collect:start', {
1771
- // actionMsg: '设置流程元素名称',
1772
- // });
1773
- // const oldName = this.name;
1774
- // this.setName(name);
1775
- // const process = this.process;
1776
- // process.elements.forEach((el) => {
1777
- // if (el.sourceRef === oldName) {
1778
- // el.setSourceRef(name);
1779
- // }
1780
- // if (el.targetRef === oldName) {
1781
- // el.setTargetRef(name);
1782
- // }
1783
- // });
1784
- // this.app.emit('collect:end');
1785
- // }
1786
- //================================================================================
1787
- // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
1788
- // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
1789
- //================================================================================
1774
+ code += `${tab1}},\n`;
1775
+ }
1776
+
1777
+ if (['ExclusiveGateway', 'AutoTask', 'InclusiveGateway'].includes(this.type)) {
1778
+ prevCode += `\n${tab5}${this.name}: elements.${this.name},\n`;
1779
+ prevCode += `${tab3}}\n`;
1780
+ code += `${tab1}logic: `;
1781
+ code += `${this.logic.toEmbeddedTSInProcess(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 3 }), prevCode, true)},\n`;
1782
+ }
1783
+ }
1784
+ if (this.isUserTask || this.type === 'AutoTask' || this.type === 'StartNoneEvent') {
1785
+ code += '_constraints: function() {\n';
1786
+ code += `${tab1}nasl.process.oneOutcomeFlow(${afterLinks.map((l) => `'${l.name}'`).join(',')})\n`;
1787
+ code += '},\n';
1788
+ }
1789
+ if (['ExclusiveGateway', 'ParallelGateway', 'InclusiveGateway'].includes(this.type)) {
1790
+ code += '_constraints: function() {\n';
1791
+ code += `${tab1}nasl.process.atLeastOneOutcomeFlow(${afterLinks.map((l) => `'${l.name}'`).join(',')})\n`;
1792
+ code += `${tab1}nasl.process.atLeastOneOutcomeFlow(${beforeLinks.map((l) => `'${l.name}'`).join(',')})\n`;
1793
+ if (afterLinks.length > 0 && beforeLinks.length > 0) {
1794
+ code += `${tab1}nasl.process.atLeastThreeOutcomeFlow(${beforeLinks
1795
+ .concat(afterLinks)
1796
+ .map((l) => `'${l.name}'`)
1797
+ .join(',')})\n`;
1798
+ }
1799
+ code += '},\n';
1800
+ }
1801
+
1802
+ if (!isFromStartNode(this)) {
1803
+ code += '__outOfProcess__,';
1804
+ }
1805
+
1806
+ code += `${tab0}\n},`;
1807
+ // let code = '';
1808
+ // this.variables.forEach((property) => {
1809
+ // code += `${tab0}export let `;
1810
+ // code += property.toEmbeddedTS(shiftState(state, code, { inline: true }));
1811
+ // code += ';\n';
1812
+ // });
1813
+
1814
+ // this.returns.forEach((property) => {
1815
+ // code += `${tab0}export let `;
1816
+ // code += property.toEmbeddedTS(shiftState(state, code, { inline: true }));
1817
+ // code += ';\n';
1818
+ // });
1819
+ // this.constants.forEach((property) => {
1820
+ // code += `${tab0}export let `;
1821
+ // code += property.toEmbeddedTS(shiftState(state, code, { inline: true }));
1822
+ // code += ';\n';
1823
+ // });
1824
+ return code;
1825
+ }
1826
+
1827
+ // syncLogic() {
1828
+ // if (this.type === 'UserTask') {
1829
+ // if (!this.logic) {
1830
+ // this.logic = new Logic({
1831
+ // name: `complete`,
1832
+ // });
1833
+ // }
1834
+ // this.logic.params = [...this.constants.map(constantToParam), ...this.returns.map(returnToParam)];
1835
+ // }
1836
+ // }
1837
+
1838
+ /**
1839
+ * 设置流程元素名称
1840
+ */
1841
+ // setNameWithFlowChange(name: string) {
1842
+ // this.app.emit('collect:start', {
1843
+ // actionMsg: '设置流程元素名称',
1844
+ // });
1845
+ // const oldName = this.name;
1846
+ // this.setName(name);
1847
+ // const process = this.process;
1848
+ // process.elements.forEach((el) => {
1849
+ // if (el.sourceRef === oldName) {
1850
+ // el.setSourceRef(name);
1851
+ // }
1852
+ // if (el.targetRef === oldName) {
1853
+ // el.setTargetRef(name);
1854
+ // }
1855
+ // });
1856
+ // this.app.emit('collect:end');
1857
+ // }
1858
+ //= ===============================================================================
1859
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
1860
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
1861
+ //= ===============================================================================
1790
1862
  }
1791
1863
 
1792
1864
  classMap.ProcessElement = ProcessElement;
1793
1865
  export default ProcessElement;
1794
- //================================================================================
1866
+ //= ===============================================================================
1795
1867
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1796
1868
  // 自动生成的代码已结束。下面可以手动编写。
1797
- //================================================================================
1869
+ //= ===============================================================================
1798
1870
  ProcessElement.prototype.setName = function (name: string) {
1799
- const App = this.rootNode;
1800
- const oldName = this.name;
1801
- const processName = this.parentNode.name;
1802
-
1803
- App.emit('collect:start', {
1804
- actionMsg: '设置名称',
1805
- });
1806
- const object = {
1871
+ const App = this.rootNode;
1872
+ const oldName = this.name;
1873
+ const processName = this.parentNode.name;
1874
+
1875
+ App.emit('collect:start', {
1876
+ actionMsg: '设置名称',
1877
+ });
1878
+ const object = {
1879
+ name,
1880
+ };
1881
+ this.update({
1882
+ ...object,
1883
+ field: 'name',
1884
+ });
1885
+ syncMemberExpression(this, (node) => {
1886
+ if (node.object.name === processName && node.property.name === oldName) {
1887
+ node.property.update({
1807
1888
  name,
1808
- };
1809
- this.update({
1810
- ...object,
1811
- field: 'name',
1812
- });
1813
- syncMemberExpression(this, (node) => {
1814
- if (node.object.name === processName && node.property.name === oldName) {
1815
- node.property.update({
1816
- name,
1817
- });
1818
- }
1819
- });
1820
- const process = this.process;
1821
- process.elements.forEach((el) => {
1822
- if (el.sourceRef === oldName) {
1823
- el.setSourceRef(name);
1824
- }
1825
- if (el.targetRef === oldName) {
1826
- el.setTargetRef(name);
1827
- }
1828
- });
1829
- if (this.logic) {
1830
- this.logic.setName(name);
1831
- }
1832
- App.emit('collect:end');
1889
+ });
1890
+ }
1891
+ });
1892
+ const { process } = this;
1893
+ process.elements.forEach((el) => {
1894
+ if (el.sourceRef === oldName) {
1895
+ el.setSourceRef(name);
1896
+ }
1897
+ if (el.targetRef === oldName) {
1898
+ el.setTargetRef(name);
1899
+ }
1900
+ });
1901
+ if (this.logic) {
1902
+ this.logic.setName(name);
1903
+ }
1904
+ App.emit('collect:end');
1833
1905
  };