@lcap/nasl 3.4.0-beta.3 → 3.4.0-beta.4

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 (880) hide show
  1. package/out/automate/engine/index.d.ts +4 -4
  2. package/out/automate/engine/index.js +363 -363
  3. package/out/automate/engine/operators.d.ts +26 -16
  4. package/out/automate/engine/operators.js +363 -363
  5. package/out/automate/engine/uniqueName.d.ts +12 -12
  6. package/out/automate/engine/uniqueName.js +111 -111
  7. package/out/automate/engine/utils.d.ts +25 -25
  8. package/out/automate/engine/utils.js +443 -443
  9. package/out/automate/engine/viewCache.d.ts +19 -18
  10. package/out/automate/engine/viewCache.js +44 -44
  11. package/out/automate/template/myProcess.d.ts +10 -9
  12. package/out/automate/template/myProcess.js +11501 -11500
  13. package/out/automate/template/myProcess.js.map +1 -1
  14. package/out/automate/upgrader/2.12.d.ts +7 -7
  15. package/out/automate/upgrader/2.12.js +62 -62
  16. package/out/automate/upgrader/2.14-components.d.ts +1115 -1115
  17. package/out/automate/upgrader/2.14-components.js +1086 -1086
  18. package/out/automate/upgrader/2.14.d.ts +10 -10
  19. package/out/automate/upgrader/2.14.js +235 -235
  20. package/out/automate/upgrader/2.14.old.d.ts +1 -1
  21. package/out/automate/upgrader/2.14.old.js +124 -124
  22. package/out/automate/upgrader/2.16.d.ts +10 -10
  23. package/out/automate/upgrader/2.16.js +74 -74
  24. package/out/automate/upgrader/2.17.d.ts +21 -21
  25. package/out/automate/upgrader/2.17.js +556 -556
  26. package/out/automate/upgrader/2.18.d.ts +10 -10
  27. package/out/automate/upgrader/2.18.js +106 -106
  28. package/out/automate/upgrader/2.20.d.ts +17 -17
  29. package/out/automate/upgrader/2.20.js +67 -67
  30. package/out/bak/translator.d.ts +1 -1
  31. package/out/bak/translator.js +143 -143
  32. package/out/breakpoint/generator/AfterStartNode.d.ts +7 -7
  33. package/out/breakpoint/generator/AfterStartNode.js +29 -29
  34. package/out/breakpoint/generator/BeforeEndNode.d.ts +7 -7
  35. package/out/breakpoint/generator/BeforeEndNode.js +27 -27
  36. package/out/breakpoint/generator/BreakpointNode.d.ts +15 -15
  37. package/out/breakpoint/generator/BreakpointNode.js +283 -283
  38. package/out/breakpoint/generator/CallbackNode.d.ts +4 -4
  39. package/out/breakpoint/generator/CallbackNode.js +21 -21
  40. package/out/breakpoint/generator/FragmentNode.d.ts +4 -4
  41. package/out/breakpoint/generator/FragmentNode.js +17 -17
  42. package/out/breakpoint/generator/index.d.ts +4 -4
  43. package/out/breakpoint/generator/index.js +118 -118
  44. package/out/breakpoint/index.d.ts +3 -3
  45. package/out/breakpoint/index.js +19 -19
  46. package/out/breakpoint/shared/constants.d.ts +37 -37
  47. package/out/breakpoint/shared/constants.js +105 -105
  48. package/out/breakpoint/shared/index.d.ts +3 -3
  49. package/out/breakpoint/shared/index.js +32 -32
  50. package/out/breakpoint/shared/operations.d.ts +10 -10
  51. package/out/breakpoint/shared/operations.js +24 -24
  52. package/out/breakpoint/shared/socket.d.ts +48 -48
  53. package/out/breakpoint/shared/socket.js +256 -256
  54. package/out/breakpoint/shared/utils.d.ts +27 -27
  55. package/out/breakpoint/shared/utils.js +228 -228
  56. package/out/breakpoint/store/core.d.ts +80 -80
  57. package/out/breakpoint/store/core.js +415 -415
  58. package/out/breakpoint/store/dock.d.ts +1 -1
  59. package/out/breakpoint/store/dock.js +159 -159
  60. package/out/breakpoint/store/index.d.ts +2 -2
  61. package/out/breakpoint/store/index.js +18 -18
  62. package/out/common/BaseNode.d.ts +347 -334
  63. package/out/common/BaseNode.js +1376 -1325
  64. package/out/common/BaseNode.js.map +1 -1
  65. package/out/common/Command.d.ts +21 -21
  66. package/out/common/Command.js +78 -78
  67. package/out/common/ComponentAPI.d.ts +110 -110
  68. package/out/common/ComponentAPI.js +2 -2
  69. package/out/common/EventEmitter.d.ts +60 -60
  70. package/out/common/EventEmitter.js +68 -68
  71. package/out/common/EventEmitter.js.map +1 -1
  72. package/out/common/Messager.d.ts +91 -91
  73. package/out/common/Messager.js +206 -206
  74. package/out/common/asyncFuncMap.d.ts +2 -2
  75. package/out/common/asyncFuncMap.js +15 -15
  76. package/out/common/index.d.ts +3 -3
  77. package/out/common/index.js +19 -19
  78. package/out/concepts/Abort__.d.ts +28 -26
  79. package/out/concepts/Abort__.js +83 -81
  80. package/out/concepts/Abort__.js.map +1 -1
  81. package/out/concepts/AbstractInterface__.d.ts +22 -0
  82. package/out/concepts/AbstractInterface__.js +60 -0
  83. package/out/concepts/AbstractInterface__.js.map +1 -0
  84. package/out/concepts/Anchor__.d.ts +48 -46
  85. package/out/concepts/Anchor__.js +208 -206
  86. package/out/concepts/Anchor__.js.map +1 -1
  87. package/out/concepts/AnonymousFunction__.d.ts +175 -173
  88. package/out/concepts/AnonymousFunction__.js +548 -546
  89. package/out/concepts/AnonymousFunction__.js.map +1 -1
  90. package/out/concepts/App__.d.ts +1770 -1687
  91. package/out/concepts/App__.js +2777 -2670
  92. package/out/concepts/App__.js.map +1 -1
  93. package/out/concepts/Argument__.d.ts +70 -68
  94. package/out/concepts/Argument__.js +285 -285
  95. package/out/concepts/Argument__.js.map +1 -1
  96. package/out/concepts/Assignee__.d.ts +291 -289
  97. package/out/concepts/Assignee__.js +455 -452
  98. package/out/concepts/Assignee__.js.map +1 -1
  99. package/out/concepts/AssignmentLine__.d.ts +44 -42
  100. package/out/concepts/AssignmentLine__.js +120 -118
  101. package/out/concepts/AssignmentLine__.js.map +1 -1
  102. package/out/concepts/Assignment__.d.ts +77 -75
  103. package/out/concepts/Assignment__.js +328 -327
  104. package/out/concepts/Assignment__.js.map +1 -1
  105. package/out/concepts/Attribute__.d.ts +112 -110
  106. package/out/concepts/Attribute__.js +259 -265
  107. package/out/concepts/Attribute__.js.map +1 -1
  108. package/out/concepts/AuthInterface__.d.ts +38 -36
  109. package/out/concepts/AuthInterface__.js +86 -85
  110. package/out/concepts/AuthInterface__.js.map +1 -1
  111. package/out/concepts/AuthLogicForCallInterface__.d.ts +141 -139
  112. package/out/concepts/AuthLogicForCallInterface__.js +535 -532
  113. package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
  114. package/out/concepts/AuthLogic__.d.ts +69 -67
  115. package/out/concepts/AuthLogic__.js +222 -221
  116. package/out/concepts/AuthLogic__.js.map +1 -1
  117. package/out/concepts/BackendVariable__.d.ts +148 -146
  118. package/out/concepts/BackendVariable__.js +482 -481
  119. package/out/concepts/BackendVariable__.js.map +1 -1
  120. package/out/concepts/Backend__.d.ts +137 -135
  121. package/out/concepts/Backend__.js +287 -285
  122. package/out/concepts/Backend__.js.map +1 -1
  123. package/out/concepts/BatchAssignment__.d.ts +255 -253
  124. package/out/concepts/BatchAssignment__.js +883 -880
  125. package/out/concepts/BatchAssignment__.js.map +1 -1
  126. package/out/concepts/BinaryExpression__.d.ts +74 -72
  127. package/out/concepts/BinaryExpression__.js +398 -398
  128. package/out/concepts/BinaryExpression__.js.map +1 -1
  129. package/out/concepts/BindAttribute__.d.ts +330 -328
  130. package/out/concepts/BindAttribute__.js +1064 -1071
  131. package/out/concepts/BindAttribute__.js.map +1 -1
  132. package/out/concepts/BindDirective__.d.ts +169 -167
  133. package/out/concepts/BindDirective__.js +558 -562
  134. package/out/concepts/BindDirective__.js.map +1 -1
  135. package/out/concepts/BindEvent__.d.ts +255 -253
  136. package/out/concepts/BindEvent__.js +943 -942
  137. package/out/concepts/BindEvent__.js.map +1 -1
  138. package/out/concepts/BindStyle__.d.ts +142 -140
  139. package/out/concepts/BindStyle__.js +424 -423
  140. package/out/concepts/BindStyle__.js.map +1 -1
  141. package/out/concepts/BooleanLiteral__.d.ts +38 -36
  142. package/out/concepts/BooleanLiteral__.js +109 -108
  143. package/out/concepts/BooleanLiteral__.js.map +1 -1
  144. package/out/concepts/CallAuthInterface__.d.ts +128 -126
  145. package/out/concepts/CallAuthInterface__.js +421 -414
  146. package/out/concepts/CallAuthInterface__.js.map +1 -1
  147. package/out/concepts/CallConnector__.d.ts +49 -47
  148. package/out/concepts/CallConnector__.js +267 -266
  149. package/out/concepts/CallConnector__.js.map +1 -1
  150. package/out/concepts/CallFunction__.d.ts +161 -159
  151. package/out/concepts/CallFunction__.js +589 -568
  152. package/out/concepts/CallFunction__.js.map +1 -1
  153. package/out/concepts/CallInterface__.d.ts +132 -130
  154. package/out/concepts/CallInterface__.js +808 -802
  155. package/out/concepts/CallInterface__.js.map +1 -1
  156. package/out/concepts/CallLogic__.d.ts +233 -231
  157. package/out/concepts/CallLogic__.js +1317 -1319
  158. package/out/concepts/CallLogic__.js.map +1 -1
  159. package/out/concepts/CallQueryComponent__.d.ts +435 -433
  160. package/out/concepts/CallQueryComponent__.js +1313 -1325
  161. package/out/concepts/CallQueryComponent__.js.map +1 -1
  162. package/out/concepts/Comment__.d.ts +35 -33
  163. package/out/concepts/Comment__.js +101 -100
  164. package/out/concepts/Comment__.js.map +1 -1
  165. package/out/concepts/CompletionProperty__.d.ts +107 -105
  166. package/out/concepts/CompletionProperty__.js +279 -283
  167. package/out/concepts/CompletionProperty__.js.map +1 -1
  168. package/out/concepts/ConfigGroup__.d.ts +127 -125
  169. package/out/concepts/ConfigGroup__.js +266 -264
  170. package/out/concepts/ConfigGroup__.js.map +1 -1
  171. package/out/concepts/ConfigPropertyValue__.d.ts +47 -45
  172. package/out/concepts/ConfigPropertyValue__.js +110 -110
  173. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  174. package/out/concepts/ConfigProperty__.d.ts +156 -154
  175. package/out/concepts/ConfigProperty__.js +334 -334
  176. package/out/concepts/ConfigProperty__.js.map +1 -1
  177. package/out/concepts/Configuration__.d.ts +126 -124
  178. package/out/concepts/Configuration__.js +239 -236
  179. package/out/concepts/Configuration__.js.map +1 -1
  180. package/out/concepts/Connection__.d.ts +168 -166
  181. package/out/concepts/Connection__.js +347 -347
  182. package/out/concepts/Connection__.js.map +1 -1
  183. package/out/concepts/ConnectorTrigger__.d.ts +81 -79
  184. package/out/concepts/ConnectorTrigger__.js +160 -161
  185. package/out/concepts/ConnectorTrigger__.js.map +1 -1
  186. package/out/concepts/Connector__.d.ts +929 -570
  187. package/out/concepts/Connector__.js +1346 -907
  188. package/out/concepts/Connector__.js.map +1 -1
  189. package/out/concepts/Constant__.d.ts +121 -119
  190. package/out/concepts/Constant__.js +313 -313
  191. package/out/concepts/Constant__.js.map +1 -1
  192. package/out/concepts/DataSource__.d.ts +171 -169
  193. package/out/concepts/DataSource__.js +477 -477
  194. package/out/concepts/DataSource__.js.map +1 -1
  195. package/out/concepts/DatabaseTypeAnnotation__.d.ts +34 -32
  196. package/out/concepts/DatabaseTypeAnnotation__.js +82 -82
  197. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
  198. package/out/concepts/DefaultValue__.d.ts +98 -98
  199. package/out/concepts/DefaultValue__.js +210 -209
  200. package/out/concepts/DefaultValue__.js.map +1 -1
  201. package/out/concepts/Destination__.d.ts +160 -158
  202. package/out/concepts/Destination__.js +804 -804
  203. package/out/concepts/Destination__.js.map +1 -1
  204. package/out/concepts/End__.d.ts +27 -25
  205. package/out/concepts/End__.js +117 -115
  206. package/out/concepts/End__.js.map +1 -1
  207. package/out/concepts/EntityIndex__.d.ts +98 -96
  208. package/out/concepts/EntityIndex__.js +227 -229
  209. package/out/concepts/EntityIndex__.js.map +1 -1
  210. package/out/concepts/EntityProperty__.d.ts +289 -287
  211. package/out/concepts/EntityProperty__.js +883 -888
  212. package/out/concepts/EntityProperty__.js.map +1 -1
  213. package/out/concepts/Entity__.d.ts +342 -340
  214. package/out/concepts/Entity__.js +779 -769
  215. package/out/concepts/Entity__.js.map +1 -1
  216. package/out/concepts/EnumItem__.d.ts +67 -65
  217. package/out/concepts/EnumItem__.js +155 -155
  218. package/out/concepts/EnumItem__.js.map +1 -1
  219. package/out/concepts/Enum__.d.ts +141 -139
  220. package/out/concepts/Enum__.js +341 -341
  221. package/out/concepts/Enum__.js.map +1 -1
  222. package/out/concepts/Event__.d.ts +146 -144
  223. package/out/concepts/Event__.js +261 -263
  224. package/out/concepts/Event__.js.map +1 -1
  225. package/out/concepts/ExternalDestination__.d.ts +78 -76
  226. package/out/concepts/ExternalDestination__.js +292 -291
  227. package/out/concepts/ExternalDestination__.js.map +1 -1
  228. package/out/concepts/ForEachStatement__.d.ts +173 -190
  229. package/out/concepts/ForEachStatement__.js +533 -534
  230. package/out/concepts/ForEachStatement__.js.map +1 -1
  231. package/out/concepts/FrontendLibrary__.d.ts +216 -214
  232. package/out/concepts/FrontendLibrary__.js +374 -372
  233. package/out/concepts/FrontendLibrary__.js.map +1 -1
  234. package/out/concepts/FrontendVariable__.d.ts +24 -22
  235. package/out/concepts/FrontendVariable__.js +66 -63
  236. package/out/concepts/FrontendVariable__.js.map +1 -1
  237. package/out/concepts/Frontend__.d.ts +511 -509
  238. package/out/concepts/Frontend__.js +1043 -1003
  239. package/out/concepts/Frontend__.js.map +1 -1
  240. package/out/concepts/Function__.d.ts +420 -418
  241. package/out/concepts/Function__.js +805 -801
  242. package/out/concepts/Function__.js.map +1 -1
  243. package/out/concepts/I18nInfo__.d.ts +44 -44
  244. package/out/concepts/I18nInfo__.js +110 -110
  245. package/out/concepts/I18nInfo__.js.map +1 -1
  246. package/out/concepts/Identifier__.d.ts +54 -52
  247. package/out/concepts/Identifier__.js +309 -305
  248. package/out/concepts/Identifier__.js.map +1 -1
  249. package/out/concepts/IfStatement__.d.ts +161 -159
  250. package/out/concepts/IfStatement__.js +353 -352
  251. package/out/concepts/IfStatement__.js.map +1 -1
  252. package/out/concepts/Integration__.d.ts +146 -144
  253. package/out/concepts/Integration__.js +301 -298
  254. package/out/concepts/Integration__.js.map +1 -1
  255. package/out/concepts/InterfaceFromExample__.d.ts +88 -0
  256. package/out/concepts/InterfaceFromExample__.js +172 -0
  257. package/out/concepts/InterfaceFromExample__.js.map +1 -0
  258. package/out/concepts/InterfaceParam__.d.ts +151 -144
  259. package/out/concepts/InterfaceParam__.js +354 -346
  260. package/out/concepts/InterfaceParam__.js.map +1 -1
  261. package/out/concepts/Interface__.d.ts +334 -331
  262. package/out/concepts/Interface__.js +923 -910
  263. package/out/concepts/Interface__.js.map +1 -1
  264. package/out/concepts/JSBlock__.d.ts +37 -35
  265. package/out/concepts/JSBlock__.js +113 -112
  266. package/out/concepts/JSBlock__.js.map +1 -1
  267. package/out/concepts/JavaLogic__.d.ts +45 -43
  268. package/out/concepts/JavaLogic__.js +127 -128
  269. package/out/concepts/JavaLogic__.js.map +1 -1
  270. package/out/concepts/LogicItem__.d.ts +154 -152
  271. package/out/concepts/LogicItem__.js +289 -291
  272. package/out/concepts/LogicItem__.js.map +1 -1
  273. package/out/concepts/Logic__.d.ts +648 -644
  274. package/out/concepts/Logic__.js +1967 -1946
  275. package/out/concepts/Logic__.js.map +1 -1
  276. package/out/concepts/MatchCase__.d.ts +261 -259
  277. package/out/concepts/MatchCase__.js +703 -693
  278. package/out/concepts/MatchCase__.js.map +1 -1
  279. package/out/concepts/Match__.d.ts +127 -125
  280. package/out/concepts/Match__.js +697 -695
  281. package/out/concepts/Match__.js.map +1 -1
  282. package/out/concepts/MemberExpression__.d.ts +77 -75
  283. package/out/concepts/MemberExpression__.js +496 -495
  284. package/out/concepts/MemberExpression__.js.map +1 -1
  285. package/out/concepts/MicroApp__.d.ts +54 -52
  286. package/out/concepts/MicroApp__.js +122 -127
  287. package/out/concepts/MicroApp__.js.map +1 -1
  288. package/out/concepts/Module__.d.ts +985 -1236
  289. package/out/concepts/Module__.js +1450 -1756
  290. package/out/concepts/Module__.js.map +1 -1
  291. package/out/concepts/MsgTriggerEvent__.d.ts +140 -138
  292. package/out/concepts/MsgTriggerEvent__.js +239 -236
  293. package/out/concepts/MsgTriggerEvent__.js.map +1 -1
  294. package/out/concepts/MsgTriggerLauncher__.d.ts +129 -127
  295. package/out/concepts/MsgTriggerLauncher__.js +234 -232
  296. package/out/concepts/MsgTriggerLauncher__.js.map +1 -1
  297. package/out/concepts/Namespace__.d.ts +1086 -1070
  298. package/out/concepts/Namespace__.js +1546 -1491
  299. package/out/concepts/Namespace__.js.map +1 -1
  300. package/out/concepts/NewComposite__.d.ts +351 -349
  301. package/out/concepts/NewComposite__.js +1261 -1311
  302. package/out/concepts/NewComposite__.js.map +1 -1
  303. package/out/concepts/NewList__.d.ts +138 -136
  304. package/out/concepts/NewList__.js +455 -449
  305. package/out/concepts/NewList__.js.map +1 -1
  306. package/out/concepts/NewMap__.d.ts +229 -227
  307. package/out/concepts/NewMap__.js +600 -589
  308. package/out/concepts/NewMap__.js.map +1 -1
  309. package/out/concepts/New__.d.ts +23 -21
  310. package/out/concepts/New__.js +71 -69
  311. package/out/concepts/New__.js.map +1 -1
  312. package/out/concepts/NullLiteral__.d.ts +29 -27
  313. package/out/concepts/NullLiteral__.js +84 -82
  314. package/out/concepts/NullLiteral__.js.map +1 -1
  315. package/out/concepts/NumericLiteral__.d.ts +59 -57
  316. package/out/concepts/NumericLiteral__.js +190 -189
  317. package/out/concepts/NumericLiteral__.js.map +1 -1
  318. package/out/concepts/OqlQueryComponent__.d.ts +76 -74
  319. package/out/concepts/OqlQueryComponent__.js +368 -365
  320. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  321. package/out/concepts/OverriddenLogic__.d.ts +637 -635
  322. package/out/concepts/OverriddenLogic__.js +1693 -1691
  323. package/out/concepts/OverriddenLogic__.js.map +1 -1
  324. package/out/concepts/Param__.d.ts +182 -180
  325. package/out/concepts/Param__.js +512 -512
  326. package/out/concepts/Param__.js.map +1 -1
  327. package/out/concepts/Point__.d.ts +34 -32
  328. package/out/concepts/Point__.js +82 -82
  329. package/out/concepts/Point__.js.map +1 -1
  330. package/out/concepts/ProcessComponent__.d.ts +222 -220
  331. package/out/concepts/ProcessComponent__.js +360 -360
  332. package/out/concepts/ProcessComponent__.js.map +1 -1
  333. package/out/concepts/ProcessElement__.d.ts +649 -647
  334. package/out/concepts/ProcessElement__.js +1335 -1334
  335. package/out/concepts/ProcessElement__.js.map +1 -1
  336. package/out/concepts/ProcessOutcome__.d.ts +33 -32
  337. package/out/concepts/ProcessOutcome__.js +108 -92
  338. package/out/concepts/ProcessOutcome__.js.map +1 -1
  339. package/out/concepts/ProcessOutcomes__.d.ts +33 -32
  340. package/out/concepts/ProcessOutcomes__.js +110 -93
  341. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  342. package/out/concepts/Process__.d.ts +616 -614
  343. package/out/concepts/Process__.js +1139 -1135
  344. package/out/concepts/Process__.js.map +1 -1
  345. package/out/concepts/QueryAggregateExpression__.d.ts +54 -52
  346. package/out/concepts/QueryAggregateExpression__.js +159 -159
  347. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  348. package/out/concepts/QueryFieldExpression__.d.ts +56 -54
  349. package/out/concepts/QueryFieldExpression__.js +163 -164
  350. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  351. package/out/concepts/QueryFromExpression__.d.ts +101 -99
  352. package/out/concepts/QueryFromExpression__.js +220 -220
  353. package/out/concepts/QueryFromExpression__.js.map +1 -1
  354. package/out/concepts/QueryGroupByExpression__.d.ts +49 -47
  355. package/out/concepts/QueryGroupByExpression__.js +150 -148
  356. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  357. package/out/concepts/QueryJoinExpression__.d.ts +188 -186
  358. package/out/concepts/QueryJoinExpression__.js +347 -348
  359. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  360. package/out/concepts/QueryLimitExpression__.d.ts +60 -58
  361. package/out/concepts/QueryLimitExpression__.js +172 -171
  362. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  363. package/out/concepts/QueryOrderByExpression__.d.ts +71 -69
  364. package/out/concepts/QueryOrderByExpression__.js +185 -184
  365. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  366. package/out/concepts/QuerySelectExpression__.d.ts +206 -204
  367. package/out/concepts/QuerySelectExpression__.js +311 -308
  368. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  369. package/out/concepts/Rect__.d.ts +42 -40
  370. package/out/concepts/Rect__.js +98 -100
  371. package/out/concepts/Rect__.js.map +1 -1
  372. package/out/concepts/Return__.d.ts +147 -145
  373. package/out/concepts/Return__.js +410 -409
  374. package/out/concepts/Return__.js.map +1 -1
  375. package/out/concepts/Role__.d.ts +65 -63
  376. package/out/concepts/Role__.js +172 -173
  377. package/out/concepts/Role__.js.map +1 -1
  378. package/out/concepts/SelectMembers__.d.ts +145 -143
  379. package/out/concepts/SelectMembers__.js +307 -305
  380. package/out/concepts/SelectMembers__.js.map +1 -1
  381. package/out/concepts/Slot__.d.ts +77 -75
  382. package/out/concepts/Slot__.js +175 -178
  383. package/out/concepts/Slot__.js.map +1 -1
  384. package/out/concepts/SqlQueryComponent__.d.ts +74 -72
  385. package/out/concepts/SqlQueryComponent__.js +291 -292
  386. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  387. package/out/concepts/Start__.d.ts +27 -25
  388. package/out/concepts/Start__.js +76 -74
  389. package/out/concepts/Start__.js.map +1 -1
  390. package/out/concepts/StringInterpolation__.d.ts +118 -116
  391. package/out/concepts/StringInterpolation__.js +275 -272
  392. package/out/concepts/StringInterpolation__.js.map +1 -1
  393. package/out/concepts/StringLiteral__.d.ts +45 -43
  394. package/out/concepts/StringLiteral__.js +165 -157
  395. package/out/concepts/StringLiteral__.js.map +1 -1
  396. package/out/concepts/StructureProperty__.d.ts +150 -148
  397. package/out/concepts/StructureProperty__.js +373 -372
  398. package/out/concepts/StructureProperty__.js.map +1 -1
  399. package/out/concepts/Structure__.d.ts +252 -248
  400. package/out/concepts/Structure__.js +521 -506
  401. package/out/concepts/Structure__.js.map +1 -1
  402. package/out/concepts/SwitchCase__.d.ts +97 -95
  403. package/out/concepts/SwitchCase__.js +287 -281
  404. package/out/concepts/SwitchCase__.js.map +1 -1
  405. package/out/concepts/SwitchStatement__.d.ts +87 -85
  406. package/out/concepts/SwitchStatement__.js +212 -209
  407. package/out/concepts/SwitchStatement__.js.map +1 -1
  408. package/out/concepts/Theme__.d.ts +40 -38
  409. package/out/concepts/Theme__.js +91 -89
  410. package/out/concepts/Theme__.js.map +1 -1
  411. package/out/concepts/Transactional__.d.ts +90 -88
  412. package/out/concepts/Transactional__.js +171 -172
  413. package/out/concepts/Transactional__.js.map +1 -1
  414. package/out/concepts/TriggerEvent__.d.ts +123 -121
  415. package/out/concepts/TriggerEvent__.js +236 -234
  416. package/out/concepts/TriggerEvent__.js.map +1 -1
  417. package/out/concepts/TriggerLauncher__.d.ts +84 -82
  418. package/out/concepts/TriggerLauncher__.js +223 -225
  419. package/out/concepts/TriggerLauncher__.js.map +1 -1
  420. package/out/concepts/TypeAnnotation__.d.ts +304 -299
  421. package/out/concepts/TypeAnnotation__.js +1054 -1025
  422. package/out/concepts/TypeAnnotation__.js.map +1 -1
  423. package/out/concepts/TypeParam__.d.ts +28 -26
  424. package/out/concepts/TypeParam__.js +82 -81
  425. package/out/concepts/TypeParam__.js.map +1 -1
  426. package/out/concepts/UnaryExpression__.d.ts +52 -50
  427. package/out/concepts/UnaryExpression__.js +200 -199
  428. package/out/concepts/UnaryExpression__.js.map +1 -1
  429. package/out/concepts/Unparsed__.d.ts +36 -33
  430. package/out/concepts/Unparsed__.js +103 -102
  431. package/out/concepts/Unparsed__.js.map +1 -1
  432. package/out/concepts/UseComponent__.d.ts +34 -32
  433. package/out/concepts/UseComponent__.js +82 -82
  434. package/out/concepts/UseComponent__.js.map +1 -1
  435. package/out/concepts/ValidationRule__.d.ts +152 -150
  436. package/out/concepts/ValidationRule__.js +531 -525
  437. package/out/concepts/ValidationRule__.js.map +1 -1
  438. package/out/concepts/Variable__.d.ts +167 -165
  439. package/out/concepts/Variable__.js +479 -478
  440. package/out/concepts/Variable__.js.map +1 -1
  441. package/out/concepts/ViewBlock__.d.ts +38 -36
  442. package/out/concepts/ViewBlock__.js +90 -91
  443. package/out/concepts/ViewBlock__.js.map +1 -1
  444. package/out/concepts/ViewComponent__.d.ts +568 -566
  445. package/out/concepts/ViewComponent__.js +819 -816
  446. package/out/concepts/ViewComponent__.js.map +1 -1
  447. package/out/concepts/ViewElement__.d.ts +628 -626
  448. package/out/concepts/ViewElement__.js +2315 -2316
  449. package/out/concepts/ViewElement__.js.map +1 -1
  450. package/out/concepts/View__.d.ts +725 -723
  451. package/out/concepts/View__.js +2219 -2217
  452. package/out/concepts/View__.js.map +1 -1
  453. package/out/concepts/WhileStatement__.d.ts +100 -98
  454. package/out/concepts/WhileStatement__.js +251 -247
  455. package/out/concepts/WhileStatement__.js.map +1 -1
  456. package/out/concepts/basics/constants.d.ts +1 -0
  457. package/out/concepts/basics/constants.js +6 -0
  458. package/out/concepts/basics/constants.js.map +1 -0
  459. package/out/concepts/basics/stdlib/index.d.ts +4 -4
  460. package/out/concepts/basics/stdlib/index.js +44 -44
  461. package/out/concepts/basics/stdlib/nasl.auth.d.ts +7 -7
  462. package/out/concepts/basics/stdlib/nasl.auth.js +163 -163
  463. package/out/concepts/basics/stdlib/nasl.browser.d.ts +3 -3
  464. package/out/concepts/basics/stdlib/nasl.browser.js +148 -148
  465. package/out/concepts/basics/stdlib/nasl.collection.d.ts +7 -7
  466. package/out/concepts/basics/stdlib/nasl.collection.js +51 -51
  467. package/out/concepts/basics/stdlib/nasl.configuration.d.ts +3 -3
  468. package/out/concepts/basics/stdlib/nasl.configuration.js +55 -55
  469. package/out/concepts/basics/stdlib/nasl.core.d.ts +5 -5
  470. package/out/concepts/basics/stdlib/nasl.core.js +48 -48
  471. package/out/concepts/basics/stdlib/nasl.event.d.ts +3 -3
  472. package/out/concepts/basics/stdlib/nasl.event.js +24 -24
  473. package/out/concepts/basics/stdlib/nasl.http.d.ts +7 -7
  474. package/out/concepts/basics/stdlib/nasl.http.js +168 -168
  475. package/out/concepts/basics/stdlib/nasl.interface.d.ts +7 -7
  476. package/out/concepts/basics/stdlib/nasl.interface.js +42 -42
  477. package/out/concepts/basics/stdlib/nasl.io.d.ts +3 -3
  478. package/out/concepts/basics/stdlib/nasl.io.js +51 -51
  479. package/out/concepts/basics/stdlib/nasl.logging.d.ts +3 -3
  480. package/out/concepts/basics/stdlib/nasl.logging.js +55 -55
  481. package/out/concepts/basics/stdlib/nasl.process.d.ts +7 -7
  482. package/out/concepts/basics/stdlib/nasl.process.js +637 -637
  483. package/out/concepts/basics/stdlib/nasl.ui.d.ts +7 -7
  484. package/out/concepts/basics/stdlib/nasl.ui.js +1062 -1062
  485. package/out/concepts/basics/stdlib/nasl.util.d.ts +5 -5
  486. package/out/concepts/basics/stdlib/nasl.util.js +2291 -2291
  487. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  488. package/out/concepts/basics/stdlib/nasl.validation.d.ts +3 -3
  489. package/out/concepts/basics/stdlib/nasl.validation.js +564 -564
  490. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.d.ts +5 -5
  491. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +25 -25
  492. package/out/concepts/basics/stdlib/timeZone.d.ts +5 -5
  493. package/out/concepts/basics/stdlib/timeZone.js +195 -195
  494. package/out/concepts/basics/types/coreTypeList.d.ts +2 -2
  495. package/out/concepts/basics/types/coreTypeList.js +14 -14
  496. package/out/concepts/basics/types/index.d.ts +16 -16
  497. package/out/concepts/basics/types/index.js +34 -34
  498. package/out/concepts/index.d.ts +6 -6
  499. package/out/concepts/index.js +24 -24
  500. package/out/concepts/index__.d.ts +126 -124
  501. package/out/concepts/index__.js +142 -140
  502. package/out/concepts/index__.js.map +1 -1
  503. package/out/concepts/types__.d.ts +128 -126
  504. package/out/concepts/types__.js +2 -2
  505. package/out/config.d.ts +43 -43
  506. package/out/config.js +71 -71
  507. package/out/decorators/index.d.ts +69 -57
  508. package/out/decorators/index.js +216 -172
  509. package/out/decorators/index.js.map +1 -1
  510. package/out/decorators/promise.d.ts +7 -7
  511. package/out/decorators/promise.js +27 -27
  512. package/out/enums/KEYWORDS.d.ts +6 -6
  513. package/out/enums/KEYWORDS.js +1245 -1243
  514. package/out/enums/KEYWORDS.js.map +1 -1
  515. package/out/enums/LEVEL_NAME_MAP.d.ts +26 -26
  516. package/out/enums/LEVEL_NAME_MAP.js +29 -29
  517. package/out/eventBus.d.ts +3 -3
  518. package/out/eventBus.js +6 -6
  519. package/out/generator/compileComponent.d.ts +11 -11
  520. package/out/generator/compileComponent.js +11 -11
  521. package/out/generator/genBundleFiles.d.ts +34 -34
  522. package/out/generator/genBundleFiles.js +356 -356
  523. package/out/generator/genBundleFiles.js.map +1 -1
  524. package/out/generator/genHash.d.ts +7 -7
  525. package/out/generator/genHash.js +38 -38
  526. package/out/generator/genMetaData.d.ts +31 -31
  527. package/out/generator/genMetaData.js +305 -301
  528. package/out/generator/genMetaData.js.map +1 -1
  529. package/out/generator/genReleaseBody.d.ts +72 -72
  530. package/out/generator/genReleaseBody.js +323 -321
  531. package/out/generator/genReleaseBody.js.map +1 -1
  532. package/out/generator/icestark.d.ts +2 -2
  533. package/out/generator/icestark.js +7 -5
  534. package/out/generator/icestark.js.map +1 -1
  535. package/out/generator/index.d.ts +7 -7
  536. package/out/generator/index.js +23 -23
  537. package/out/generator/microApp.d.ts +2 -2
  538. package/out/generator/microApp.js +35 -35
  539. package/out/generator/permission.d.ts +10 -10
  540. package/out/generator/permission.js +269 -269
  541. package/out/generator/qiankun.d.ts +2 -2
  542. package/out/generator/qiankun.js +6 -4
  543. package/out/generator/qiankun.js.map +1 -1
  544. package/out/generator/styleReplacer.d.ts +3 -3
  545. package/out/generator/styleReplacer.js +67 -67
  546. package/out/index.d.ts +13 -13
  547. package/out/index.js +66 -66
  548. package/out/manager/diagnostic.d.ts +35 -35
  549. package/out/manager/diagnostic.js +62 -62
  550. package/out/manager/stepRecorder.d.ts +20 -20
  551. package/out/manager/stepRecorder.js +108 -108
  552. package/out/natural/componentData.d.ts +31 -31
  553. package/out/natural/componentData.js +84 -84
  554. package/out/natural/genNaturalTS.d.ts +3 -3
  555. package/out/natural/genNaturalTS.js +89 -90
  556. package/out/natural/genNaturalTS.js.map +1 -1
  557. package/out/natural/index.d.ts +2 -2
  558. package/out/natural/index.js +18 -18
  559. package/out/natural/naslStdlibMap.d.ts +2 -2
  560. package/out/natural/naslStdlibMap.js +25 -25
  561. package/out/natural/transformTSCode.d.ts +7 -7
  562. package/out/natural/transformTSCode.js +919 -877
  563. package/out/natural/transformTSCode.js.map +1 -1
  564. package/out/sentry/index.d.ts +34 -34
  565. package/out/sentry/index.js +148 -147
  566. package/out/sentry/index.js.map +1 -1
  567. package/out/server/createUiTs.d.ts +16 -16
  568. package/out/server/createUiTs.js +242 -242
  569. package/out/server/entity2LogicNamespace.d.ts +10 -10
  570. package/out/server/entity2LogicNamespace.js +381 -381
  571. package/out/server/event.d.ts +30 -30
  572. package/out/server/event.js +150 -150
  573. package/out/server/extendBaseNode.d.ts +1 -1
  574. package/out/server/extendBaseNode.js +574 -543
  575. package/out/server/extendBaseNode.js.map +1 -1
  576. package/out/server/formatTsUtils.d.ts +37 -37
  577. package/out/server/formatTsUtils.js +851 -851
  578. package/out/server/getConnector.d.ts +14 -14
  579. package/out/server/getConnector.js +77 -77
  580. package/out/server/getExtensionModules.d.ts +3 -3
  581. package/out/server/getExtensionModules.js +33 -33
  582. package/out/server/getFunctions.d.ts +3 -3
  583. package/out/server/getFunctions.js +19 -19
  584. package/out/server/getInterfaces.d.ts +2 -2
  585. package/out/server/getInterfaces.js +47 -47
  586. package/out/server/getLogging.d.ts +1 -1
  587. package/out/server/getLogging.js +8 -8
  588. package/out/server/getLogics.d.ts +4 -4
  589. package/out/server/getLogics.js +380 -380
  590. package/out/server/getMemberIdentifier.d.ts +17 -17
  591. package/out/server/getMemberIdentifier.js +508 -508
  592. package/out/server/getProcessComponents.d.ts +2 -2
  593. package/out/server/getProcessComponents.js +12 -12
  594. package/out/server/getProcesses.d.ts +33 -33
  595. package/out/server/getProcesses.js +596 -596
  596. package/out/server/getScope.d.ts +13 -13
  597. package/out/server/getScope.js +60 -60
  598. package/out/server/getValidates.d.ts +3 -3
  599. package/out/server/getValidates.js +13 -13
  600. package/out/server/index.d.ts +5 -5
  601. package/out/server/index.js +41 -41
  602. package/out/server/naslServer.d.ts +375 -371
  603. package/out/server/naslServer.js +4706 -4585
  604. package/out/server/naslServer.js.map +1 -1
  605. package/out/server/naslStdlibMap.d.ts +2 -2
  606. package/out/server/naslStdlibMap.js +53 -53
  607. package/out/server/process2LogicNamespace.d.ts +26 -26
  608. package/out/server/process2LogicNamespace.js +108 -108
  609. package/out/server/translator.d.ts +26 -26
  610. package/out/server/translator.js +819 -805
  611. package/out/server/translator.js.map +1 -1
  612. package/out/service/creator/add.configs.d.ts +1 -1
  613. package/out/service/creator/add.configs.js +102 -102
  614. package/out/service/creator/errHandles.d.ts +18 -18
  615. package/out/service/creator/errHandles.js +67 -67
  616. package/out/service/creator/index.d.ts +1 -1
  617. package/out/service/creator/index.js +86 -86
  618. package/out/service/datasource/api.d.ts +12 -12
  619. package/out/service/datasource/api.js +13 -13
  620. package/out/service/datasource/index.d.ts +2 -2
  621. package/out/service/datasource/index.js +9 -9
  622. package/out/service/defaultErrorMessage.json +98 -98
  623. package/out/service/logic/api.d.ts +9 -9
  624. package/out/service/logic/api.js +10 -10
  625. package/out/service/logic/checktypeSocket.d.ts +5 -5
  626. package/out/service/logic/checktypeSocket.js +54 -54
  627. package/out/service/logic/index.d.ts +2 -2
  628. package/out/service/logic/index.js +9 -9
  629. package/out/service/storage/api.d.ts +54 -54
  630. package/out/service/storage/api.js +41 -41
  631. package/out/service/storage/index.d.ts +2 -2
  632. package/out/service/storage/index.js +9 -9
  633. package/out/service/storage/init.d.ts +102 -102
  634. package/out/service/storage/init.js +1161 -1161
  635. package/out/service/storage/jsoner.d.ts +36 -36
  636. package/out/service/storage/jsoner.js +128 -130
  637. package/out/service/storage/jsoner.js.map +1 -1
  638. package/out/service/storage/map.d.ts +4 -4
  639. package/out/service/storage/map.js +53 -53
  640. package/out/service/storage/service.d.ts +25 -25
  641. package/out/service/storage/service.js +79 -79
  642. package/out/service/storage/storagePoint.d.ts +17 -17
  643. package/out/service/storage/storagePoint.js +75 -75
  644. package/out/service/video/BaseService.d.ts +7 -7
  645. package/out/service/video/BaseService.js +60 -60
  646. package/out/service/video/MainCallbackService.d.ts +12 -12
  647. package/out/service/video/MainCallbackService.js +182 -182
  648. package/out/service/video/VideoTranscribe.d.ts +15 -15
  649. package/out/service/video/VideoTranscribe.js +95 -95
  650. package/out/service/video/publishService.d.ts +1 -1
  651. package/out/service/video/publishService.js +57 -57
  652. package/out/templator/genCallComponentLogic.d.ts +17 -17
  653. package/out/templator/genCallComponentLogic.js +28 -28
  654. package/out/templator/genCreateBlock.d.ts +10 -10
  655. package/out/templator/genCreateBlock.js +297 -297
  656. package/out/templator/genCurdEditMultipleKeyBlock.d.ts +8 -8
  657. package/out/templator/genCurdEditMultipleKeyBlock.js +398 -398
  658. package/out/templator/genCurdMultipleKeyBlock.d.ts +34 -34
  659. package/out/templator/genCurdMultipleKeyBlock.js +541 -541
  660. package/out/templator/genEditTableBlock.d.ts +51 -51
  661. package/out/templator/genEditTableBlock.js +255 -255
  662. package/out/templator/genEnumSelectBlock.d.ts +10 -10
  663. package/out/templator/genEnumSelectBlock.js +21 -21
  664. package/out/templator/genGetBlock.d.ts +6 -6
  665. package/out/templator/genGetBlock.js +96 -96
  666. package/out/templator/genGridViewBlock.d.ts +55 -55
  667. package/out/templator/genGridViewBlock.js +286 -286
  668. package/out/templator/genListViewBlock.d.ts +19 -19
  669. package/out/templator/genListViewBlock.js +108 -108
  670. package/out/templator/genQueryComponent.d.ts +34 -34
  671. package/out/templator/genQueryComponent.js +348 -348
  672. package/out/templator/genSelectBlock.d.ts +45 -45
  673. package/out/templator/genSelectBlock.js +340 -340
  674. package/out/templator/genTableBlock.d.ts +53 -53
  675. package/out/templator/genTableBlock.js +226 -226
  676. package/out/templator/genUpdateBlock.d.ts +6 -6
  677. package/out/templator/genUpdateBlock.js +322 -322
  678. package/out/templator/index.d.ts +19 -19
  679. package/out/templator/index.js +37 -37
  680. package/out/templator/utils.d.ts +683 -683
  681. package/out/templator/utils.js +458 -458
  682. package/out/translator/constant.d.ts +6 -6
  683. package/out/translator/constant.js +9 -9
  684. package/out/translator/index.d.ts +3 -3
  685. package/out/translator/index.js +19 -19
  686. package/out/translator/types.d.ts +33 -32
  687. package/out/translator/types.js +2 -2
  688. package/out/translator/utils.d.ts +17 -17
  689. package/out/translator/utils.js +110 -97
  690. package/out/translator/utils.js.map +1 -1
  691. package/out/utils/cookie.d.ts +9 -9
  692. package/out/utils/cookie.js +61 -61
  693. package/out/utils/env.d.ts +2 -2
  694. package/out/utils/env.js +5 -5
  695. package/out/utils/i18nInfo.d.ts +5 -5
  696. package/out/utils/i18nInfo.js +60 -60
  697. package/out/utils/index.d.ts +44 -44
  698. package/out/utils/index.js +200 -200
  699. package/out/utils/logger.d.ts +7 -7
  700. package/out/utils/logger.js +22 -22
  701. package/out/utils/sortTsString.d.ts +1 -1
  702. package/out/utils/sortTsString.js +43 -37
  703. package/out/utils/sortTsString.js.map +1 -1
  704. package/out/utils/string.d.ts +51 -51
  705. package/out/utils/string.js +106 -106
  706. package/out/utils/time-slicing.d.ts +41 -41
  707. package/out/utils/time-slicing.js +81 -81
  708. package/out/utils/traverse.d.ts +36 -36
  709. package/out/utils/traverse.js +142 -142
  710. package/out/utils/types.d.ts +1 -1
  711. package/out/utils/types.js +2 -2
  712. package/out/utils/window.d.ts +7 -7
  713. package/out/utils/window.js +13 -13
  714. package/package.json +8 -8
  715. package/sandbox/stdlib/nasl.oql.ts +6 -1
  716. package/sandbox-natural/stdlib/nasl.core.ts +6 -3
  717. package/sandbox-natural/stdlib/nasl.oql.ts +6 -0
  718. package/sandbox-natural/stdlib/nasl.util.ts +2 -1
  719. package/src/automate/template/myProcess.js +3 -2
  720. package/src/common/BaseNode.ts +108 -51
  721. package/src/concepts/Abort__.ts +4 -1
  722. package/src/concepts/AbstractInterface__.ts +64 -0
  723. package/src/concepts/Anchor__.ts +6 -2
  724. package/src/concepts/AnonymousFunction__.ts +11 -5
  725. package/src/concepts/App__.ts +1648 -1378
  726. package/src/concepts/Argument__.ts +7 -3
  727. package/src/concepts/Assignee__.ts +10 -5
  728. package/src/concepts/AssignmentLine__.ts +3 -0
  729. package/src/concepts/Assignment__.ts +8 -4
  730. package/src/concepts/Attribute__.ts +7 -2
  731. package/src/concepts/AuthInterface__.ts +3 -0
  732. package/src/concepts/AuthLogicForCallInterface__.ts +8 -4
  733. package/src/concepts/AuthLogic__.ts +3 -0
  734. package/src/concepts/BackendVariable__.ts +11 -4
  735. package/src/concepts/Backend__.ts +5 -1
  736. package/src/concepts/BatchAssignment__.ts +13 -8
  737. package/src/concepts/BinaryExpression__.ts +10 -6
  738. package/src/concepts/BindAttribute__.ts +6 -2
  739. package/src/concepts/BindDirective__.ts +11 -4
  740. package/src/concepts/BindEvent__.ts +8 -3
  741. package/src/concepts/BindStyle__.ts +5 -1
  742. package/src/concepts/BooleanLiteral__.ts +4 -1
  743. package/src/concepts/CallAuthInterface__.ts +11 -3
  744. package/src/concepts/CallConnector__.ts +3 -0
  745. package/src/concepts/CallFunction__.ts +41 -15
  746. package/src/concepts/CallInterface__.ts +33 -21
  747. package/src/concepts/CallLogic__.ts +41 -35
  748. package/src/concepts/CallQueryComponent__.ts +11 -14
  749. package/src/concepts/Comment__.ts +3 -0
  750. package/src/concepts/CompletionProperty__.ts +5 -1
  751. package/src/concepts/ConfigGroup__.ts +5 -1
  752. package/src/concepts/ConfigPropertyValue__.ts +3 -0
  753. package/src/concepts/ConfigProperty__.ts +5 -1
  754. package/src/concepts/Configuration__.ts +5 -1
  755. package/src/concepts/Connection__.ts +5 -1
  756. package/src/concepts/ConnectorTrigger__.ts +3 -0
  757. package/src/concepts/Connector__.ts +910 -25
  758. package/src/concepts/Constant__.ts +9 -4
  759. package/src/concepts/DataSource__.ts +5 -1
  760. package/src/concepts/DatabaseTypeAnnotation__.ts +3 -0
  761. package/src/concepts/DefaultValue__.ts +4 -3
  762. package/src/concepts/Destination__.ts +8 -4
  763. package/src/concepts/End__.ts +3 -0
  764. package/src/concepts/EntityIndex__.ts +3 -0
  765. package/src/concepts/EntityProperty__.ts +14 -4
  766. package/src/concepts/Entity__.ts +17 -2
  767. package/src/concepts/EnumItem__.ts +3 -0
  768. package/src/concepts/Enum__.ts +5 -1
  769. package/src/concepts/Event__.ts +5 -1
  770. package/src/concepts/ExternalDestination__.ts +7 -3
  771. package/src/concepts/ForEachStatement__.ts +21 -16
  772. package/src/concepts/FrontendLibrary__.ts +7 -2
  773. package/src/concepts/FrontendVariable__.ts +3 -0
  774. package/src/concepts/Frontend__.ts +59 -14
  775. package/src/concepts/Function__.ts +15 -7
  776. package/src/concepts/I18nInfo__.ts +1 -0
  777. package/src/concepts/Identifier__.ts +9 -2
  778. package/src/concepts/IfStatement__.ts +25 -22
  779. package/src/concepts/Integration__.ts +8 -4
  780. package/src/concepts/InterfaceFromExample__.ts +194 -0
  781. package/src/concepts/InterfaceParam__.ts +20 -4
  782. package/src/concepts/Interface__.ts +51 -25
  783. package/src/concepts/JSBlock__.ts +3 -0
  784. package/src/concepts/JavaLogic__.ts +3 -0
  785. package/src/concepts/LogicItem__.ts +3 -0
  786. package/src/concepts/Logic__.ts +48 -19
  787. package/src/concepts/MatchCase__.ts +16 -5
  788. package/src/concepts/Match__.ts +8 -4
  789. package/src/concepts/MemberExpression__.ts +8 -4
  790. package/src/concepts/MicroApp__.ts +3 -0
  791. package/src/concepts/Module__.ts +286 -893
  792. package/src/concepts/MsgTriggerEvent__.ts +5 -1
  793. package/src/concepts/MsgTriggerLauncher__.ts +6 -2
  794. package/src/concepts/Namespace__.ts +246 -173
  795. package/src/concepts/NewComposite__.ts +54 -103
  796. package/src/concepts/NewList__.ts +27 -18
  797. package/src/concepts/NewMap__.ts +29 -15
  798. package/src/concepts/New__.ts +3 -0
  799. package/src/concepts/NullLiteral__.ts +4 -1
  800. package/src/concepts/NumericLiteral__.ts +6 -2
  801. package/src/concepts/OqlQueryComponent__.ts +8 -1
  802. package/src/concepts/OverriddenLogic__.ts +18 -7
  803. package/src/concepts/Param__.ts +8 -2
  804. package/src/concepts/Point__.ts +3 -0
  805. package/src/concepts/ProcessComponent__.ts +7 -2
  806. package/src/concepts/ProcessElement__.ts +19 -8
  807. package/src/concepts/ProcessOutcome__.ts +20 -2
  808. package/src/concepts/ProcessOutcomes__.ts +20 -2
  809. package/src/concepts/Process__.ts +15 -7
  810. package/src/concepts/QueryAggregateExpression__.ts +5 -1
  811. package/src/concepts/QueryFieldExpression__.ts +3 -0
  812. package/src/concepts/QueryFromExpression__.ts +5 -1
  813. package/src/concepts/QueryGroupByExpression__.ts +5 -1
  814. package/src/concepts/QueryJoinExpression__.ts +5 -1
  815. package/src/concepts/QueryLimitExpression__.ts +5 -1
  816. package/src/concepts/QueryOrderByExpression__.ts +5 -1
  817. package/src/concepts/QuerySelectExpression__.ts +5 -1
  818. package/src/concepts/Rect__.ts +3 -0
  819. package/src/concepts/Return__.ts +9 -3
  820. package/src/concepts/Role__.ts +3 -0
  821. package/src/concepts/SelectMembers__.ts +5 -1
  822. package/src/concepts/Slot__.ts +5 -1
  823. package/src/concepts/SqlQueryComponent__.ts +5 -1
  824. package/src/concepts/Start__.ts +3 -0
  825. package/src/concepts/StringInterpolation__.ts +7 -3
  826. package/src/concepts/StringLiteral__.ts +12 -3
  827. package/src/concepts/StructureProperty__.ts +12 -4
  828. package/src/concepts/Structure__.ts +25 -3
  829. package/src/concepts/SwitchCase__.ts +9 -1
  830. package/src/concepts/SwitchStatement__.ts +7 -3
  831. package/src/concepts/Theme__.ts +3 -0
  832. package/src/concepts/Transactional__.ts +3 -0
  833. package/src/concepts/TriggerEvent__.ts +5 -1
  834. package/src/concepts/TriggerLauncher__.ts +3 -0
  835. package/src/concepts/TypeAnnotation__.ts +62 -23
  836. package/src/concepts/TypeParam__.ts +3 -0
  837. package/src/concepts/UnaryExpression__.ts +8 -4
  838. package/src/concepts/Unparsed__.ts +5 -2
  839. package/src/concepts/UseComponent__.ts +3 -0
  840. package/src/concepts/ValidationRule__.ts +21 -7
  841. package/src/concepts/Variable__.ts +10 -4
  842. package/src/concepts/ViewBlock__.ts +3 -0
  843. package/src/concepts/ViewComponent__.ts +15 -6
  844. package/src/concepts/ViewElement__.ts +13 -5
  845. package/src/concepts/View__.ts +27 -11
  846. package/src/concepts/WhileStatement__.ts +7 -1
  847. package/src/concepts/basics/constants.ts +2 -0
  848. package/src/concepts/basics/stdlib/nasl.util.ts +3 -3
  849. package/src/concepts/index__.ts +2 -0
  850. package/src/concepts/types__.ts +4 -0
  851. package/src/decorators/index.ts +55 -0
  852. package/src/enums/KEYWORDS.ts +2 -0
  853. package/src/generator/genBundleFiles.ts +7 -7
  854. package/src/generator/genMetaData.ts +7 -2
  855. package/src/generator/genReleaseBody.ts +8 -4
  856. package/src/generator/icestark.ts +4 -2
  857. package/src/generator/qiankun.ts +3 -1
  858. package/src/natural/genNaturalTS.ts +5 -6
  859. package/src/natural/transformTSCode.ts +53 -13
  860. package/src/sentry/index.ts +3 -1
  861. package/src/server/extendBaseNode.ts +30 -2
  862. package/src/server/naslServer.ts +142 -22
  863. package/src/server/translator.ts +13 -1
  864. package/src/service/storage/jsoner.ts +2 -2
  865. package/src/translator/types.ts +1 -0
  866. package/src/translator/utils.ts +15 -0
  867. package/src/utils/sortTsString.ts +9 -4
  868. package/test/concepts/call-function/__snapshots__/toEmbeddedTS.spec.ts.snap +26 -0
  869. package/test/concepts/call-function/__snapshots__/toJS.spec.ts.snap +26 -0
  870. package/test/concepts/call-function/constant.ts +5 -0
  871. package/test/concepts/call-function/fixtures/from-string.json +100 -0
  872. package/test/concepts/call-function/fixtures/to-string-global-tz.json +99 -0
  873. package/test/concepts/call-function/fixtures/to-string-no-tz.json +89 -0
  874. package/test/concepts/call-function/fixtures/to-string-user-tz.json +101 -0
  875. package/test/concepts/call-function/fixtures/to-string-utc-tz.json +101 -0
  876. package/test/concepts/call-function/toEmbeddedTS.spec.ts +14 -0
  877. package/test/concepts/call-function/toJS.spec.ts +14 -0
  878. package/test/concepts/call-interface/__snapshots__/toEmbeddedTS.spec.ts.snap +6 -3
  879. package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +3 -3
  880. package/test/concepts/call-logic/__snapshots__/toEmbeddedTS.spec.ts.snap +3 -3
@@ -1,1692 +1,1694 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
- var __importDefault = (this && this.__importDefault) || function (mod) {
32
- return (mod && mod.__esModule) ? mod : { "default": mod };
33
- };
34
- var OverriddenLogic_1;
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.OverriddenLogic = void 0;
37
- const FrontendLibrary__1 = require("./FrontendLibrary__");
38
- const translator_1 = require("../translator");
39
- const Namespace__1 = __importDefault(require("./Namespace__"));
40
- const CallQueryComponent__1 = __importDefault(require("./CallQueryComponent__"));
41
- const Assignment__1 = __importDefault(require("./Assignment__"));
42
- const Identifier__1 = __importDefault(require("./Identifier__"));
43
- const BindEvent__1 = __importDefault(require("./BindEvent__"));
44
- const BatchAssignment__1 = __importDefault(require("./BatchAssignment__"));
45
- const OqlQueryComponent__1 = __importDefault(require("./OqlQueryComponent__"));
46
- const TypeAnnotation__1 = __importDefault(require("./TypeAnnotation__"));
47
- const CallInterface__1 = __importDefault(require("./CallInterface__"));
48
- const CallLogic__1 = __importDefault(require("./CallLogic__"));
49
- const decorators_1 = require("../decorators");
50
- const utils = __importStar(require("../utils"));
51
- const BaseNode_1 = __importDefault(require("../common/BaseNode"));
52
- const Transactional__1 = __importDefault(require("./Transactional__"));
53
- const TypeParam__1 = __importDefault(require("./TypeParam__"));
54
- const Param__1 = __importDefault(require("./Param__"));
55
- const Return__1 = __importDefault(require("./Return__"));
56
- const Variable__1 = __importDefault(require("./Variable__"));
57
- const LogicItem__1 = __importDefault(require("./LogicItem__"));
58
- const Process__1 = __importDefault(require("./Process__"));
59
- /**
60
- * 覆写逻辑
61
- */
62
- let OverriddenLogic = class OverriddenLogic extends BaseNode_1.default {
63
- static { OverriddenLogic_1 = this; }
64
- /** 类名 */
65
- static ConceptName = 'OverriddenLogic';
66
- /**
67
- * 产品概念
68
- */
69
- concept;
70
- /**
71
- * 覆写的模块
72
- */
73
- // @ts-ignore
74
- overriddenModule;
75
- /**
76
- * 覆写逻辑名称
77
- */
78
- // @ts-ignore
79
- name;
80
- /**
81
- * 覆写逻辑描述
82
- */
83
- // @ts-ignore
84
- description;
85
- /**
86
- * 触发方式
87
- */
88
- // @ts-ignore
89
- triggerType;
90
- /**
91
- * 定时任务表达式
92
- */
93
- // @ts-ignore
94
- cron;
95
- /**
96
- * 事务
97
- */
98
- // @ts-ignore
99
- transactional;
100
- /**
101
- * 类型参数列表
102
- */
103
- typeParams = null;
104
- /**
105
- * 输入参数列表
106
- */
107
- params = [];
108
- /**
109
- * 输出参数列表
110
- */
111
- returns = [];
112
- /**
113
- * 变量列表
114
- */
115
- variables = [];
116
- /**
117
- * 逻辑项列表
118
- */
119
- body = [];
120
- /**
121
- * 逻辑项列表
122
- */
123
- playground = [];
124
- /**
125
- * 祖先 Module
126
- */
127
- get module() {
128
- return this.getAncestor('Module');
129
- }
130
- /**
131
- * 祖先 App
132
- */
133
- get app() {
134
- return this.getAncestor('App');
135
- }
136
- /**
137
- * 祖先 View
138
- */
139
- get view() {
140
- return this.getAncestor('View');
141
- }
142
- /**
143
- * 祖先 Frontend
144
- */
145
- get frontend() {
146
- return this.getAncestor('Frontend');
147
- }
148
- /**
149
- * 祖先 ProcessElement
150
- */
151
- get processElement() {
152
- return this.getAncestor('ProcessElement');
153
- }
154
- /**
155
- * 祖先 Process
156
- */
157
- get process() {
158
- return this.getAncestor('Process');
159
- }
160
- /**
161
- * @param source 需要合并的部分参数
162
- */
163
- constructor(source) {
164
- source = Object.assign({}, OverriddenLogic_1.getDefaultOptions(), source);
165
- super(source);
166
- super.subConstructor(source);
167
- }
168
- static from(source, parentNode, parentKey) {
169
- return super.from(source, parentNode, parentKey);
170
- }
171
- /**
172
- * 从父级删除该节点
173
- * @internal
174
- */
175
- _delete() {
176
- let params = null;
177
- if (this.parentNode) {
178
- params = this.parentNode?.__removeOverriddenLogic?.(this);
179
- }
180
- return params;
181
- }
182
- /**
183
- * 设置覆写的模块
184
- */
185
- setOverriddenModule(overriddenModule) {
186
- const object = {
187
- overriddenModule,
188
- };
189
- this.update({
190
- ...object,
191
- });
192
- }
193
- /**
194
- * 设置覆写逻辑名称
195
- */
196
- setName(name) {
197
- const object = {
198
- name,
199
- };
200
- this.update({
201
- ...object,
202
- field: 'name',
203
- });
204
- }
205
- /**
206
- * 设置覆写逻辑描述
207
- */
208
- setDescription(description) {
209
- const object = {
210
- description,
211
- };
212
- this.update({
213
- ...object,
214
- });
215
- }
216
- /**
217
- * 设置触发方式
218
- */
219
- setTriggerType(triggerType) {
220
- const object = {
221
- triggerType,
222
- };
223
- this.update({
224
- ...object,
225
- });
226
- }
227
- /**
228
- * 设置定时任务表达式
229
- */
230
- setCron(cron) {
231
- const object = {
232
- cron,
233
- };
234
- this.update({
235
- ...object,
236
- });
237
- }
238
- /**
239
- * 设置事务
240
- */
241
- setTransactional(transactional) {
242
- transactional._delete();
243
- const relationOptions = { parentNode: this, parentKey: 'transactional' };
244
- Object.assign(transactional, relationOptions);
245
- const object = {
246
- transactional,
247
- };
248
- this.update({
249
- ...object,
250
- });
251
- }
252
- getTypeParamExistingNames(excludedList = []) {
253
- const excludedSet = new Set(excludedList);
254
- return (this.typeParams || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
255
- }
256
- getTypeParamUniqueName(name = 'typeParam1') {
257
- return utils.unique(name, this.getTypeParamExistingNames(), undefined, false);
258
- }
259
- _insertTypeParamAt(options, index) {
260
- const typeParamOptions = {};
261
- const relationOptions = { parentNode: this, parentKey: 'typeParams' };
262
- let typeParam;
263
- if (!options) {
264
- typeParam = TypeParam__1.default.from({
265
- ...typeParamOptions,
266
- name: this.getTypeParamUniqueName(),
267
- }, this, 'typeParams');
268
- }
269
- else if (typeof options === 'string') {
270
- typeParam = TypeParam__1.default.from({
271
- ...typeParamOptions,
272
- name: options,
273
- }, this, 'typeParams');
274
- }
275
- else if (options instanceof TypeParam__1.default) {
276
- options.ensureDelete(); // 同一实例不支持多处存在
277
- typeParam = options;
278
- Object.assign(typeParam, relationOptions);
279
- }
280
- else {
281
- typeParam = TypeParam__1.default.from({
282
- ...typeParamOptions,
283
- ...options,
284
- }, this, 'typeParams');
285
- }
286
- this.typeParams.splice(index, 0, typeParam);
287
- return typeParam;
288
- }
289
- insertTypeParamAt(options, index) {
290
- const node = this._insertTypeParamAt(options, index);
291
- node.create({
292
- index,
293
- parentNode: this,
294
- parentKey: 'typeParams',
295
- });
296
- return node;
297
- }
298
- _addTypeParam(options) {
299
- const index = this.typeParams.length;
300
- return this._insertTypeParamAt(options, index);
301
- }
302
- addTypeParam(options) {
303
- const node = this._addTypeParam(options);
304
- const index = this.typeParams.indexOf(node);
305
- node.create({
306
- index,
307
- parentNode: this,
308
- parentKey: 'typeParams',
309
- });
310
- return node;
311
- }
312
- getParamUniqueName(name = 'param1') {
313
- return utils.unique(name, this.getVarExistingNames(), undefined, false);
314
- }
315
- _insertParamAt(options, index) {
316
- const paramOptions = {};
317
- const relationOptions = { parentNode: this, parentKey: 'params' };
318
- let param;
319
- if (!options) {
320
- param = Param__1.default.from({
321
- ...paramOptions,
322
- name: this.getParamUniqueName(),
323
- }, this, 'params');
324
- }
325
- else if (typeof options === 'string') {
326
- param = Param__1.default.from({
327
- ...paramOptions,
328
- name: options,
329
- }, this, 'params');
330
- }
331
- else if (options instanceof Param__1.default) {
332
- options.ensureDelete(); // 同一实例不支持多处存在
333
- param = options;
334
- Object.assign(param, relationOptions);
335
- }
336
- else {
337
- param = Param__1.default.from({
338
- ...paramOptions,
339
- ...options,
340
- }, this, 'params');
341
- }
342
- this.params.splice(index, 0, param);
343
- return param;
344
- }
345
- insertParamAt(options, index) {
346
- const node = this._insertParamAt(options, index);
347
- node.create({
348
- index,
349
- parentNode: this,
350
- parentKey: 'params',
351
- });
352
- return node;
353
- }
354
- _addParam(options) {
355
- const index = this.params.length;
356
- return this._insertParamAt(options, index);
357
- }
358
- addParam(options) {
359
- const node = this._addParam(options);
360
- const index = this.params.indexOf(node);
361
- node.create({
362
- index,
363
- parentNode: this,
364
- parentKey: 'params',
365
- });
366
- return node;
367
- }
368
- getReturnUniqueName(name = 'result') {
369
- return utils.unique(name, this.getVarExistingNames(), undefined, false);
370
- }
371
- _insertReturnAt(options, index) {
372
- const retOptions = {};
373
- const relationOptions = { parentNode: this, parentKey: 'returns' };
374
- let ret;
375
- if (!options) {
376
- ret = Return__1.default.from({
377
- ...retOptions,
378
- name: this.getReturnUniqueName(),
379
- }, this, 'returns');
380
- }
381
- else if (typeof options === 'string') {
382
- ret = Return__1.default.from({
383
- ...retOptions,
384
- name: options,
385
- }, this, 'returns');
386
- }
387
- else if (options instanceof Return__1.default) {
388
- options.ensureDelete(); // 同一实例不支持多处存在
389
- ret = options;
390
- Object.assign(ret, relationOptions);
391
- }
392
- else {
393
- ret = Return__1.default.from({
394
- ...retOptions,
395
- ...options,
396
- }, this, 'returns');
397
- }
398
- this.returns.splice(index, 0, ret);
399
- return ret;
400
- }
401
- insertReturnAt(options, index) {
402
- const node = this._insertReturnAt(options, index);
403
- node.create({
404
- index,
405
- parentNode: this,
406
- parentKey: 'returns',
407
- });
408
- return node;
409
- }
410
- _addReturn(options) {
411
- const index = this.returns.length;
412
- return this._insertReturnAt(options, index);
413
- }
414
- addReturn(options) {
415
- const node = this._addReturn(options);
416
- const index = this.returns.indexOf(node);
417
- node.create({
418
- index,
419
- parentNode: this,
420
- parentKey: 'returns',
421
- });
422
- return node;
423
- }
424
- getVariableUniqueName(name = 'variable1') {
425
- return utils.unique(name, this.getVarExistingNames(), undefined, false);
426
- }
427
- _insertVariableAt(options, index) {
428
- const variableOptions = {};
429
- const relationOptions = { parentNode: this, parentKey: 'variables' };
430
- let variable;
431
- if (!options) {
432
- variable = Variable__1.default.from({
433
- ...variableOptions,
434
- name: this.getVariableUniqueName(),
435
- }, this, 'variables');
436
- }
437
- else if (typeof options === 'string') {
438
- variable = Variable__1.default.from({
439
- ...variableOptions,
440
- name: options,
441
- }, this, 'variables');
442
- }
443
- else if (options instanceof Variable__1.default) {
444
- options.ensureDelete(); // 同一实例不支持多处存在
445
- variable = options;
446
- Object.assign(variable, relationOptions);
447
- }
448
- else {
449
- variable = Variable__1.default.from({
450
- ...variableOptions,
451
- ...options,
452
- }, this, 'variables');
453
- }
454
- this.variables.splice(index, 0, variable);
455
- return variable;
456
- }
457
- insertVariableAt(options, index) {
458
- const node = this._insertVariableAt(options, index);
459
- node.create({
460
- index,
461
- parentNode: this,
462
- parentKey: 'variables',
463
- });
464
- return node;
465
- }
466
- _addVariable(options) {
467
- const index = this.variables.length;
468
- return this._insertVariableAt(options, index);
469
- }
470
- addVariable(options) {
471
- const node = this._addVariable(options);
472
- const index = this.variables.indexOf(node);
473
- node.create({
474
- index,
475
- parentNode: this,
476
- parentKey: 'variables',
477
- });
478
- return node;
479
- }
480
- _insertItemInBodyAt(options, index) {
481
- const logicItemOptions = {};
482
- const relationOptions = { parentNode: this, parentKey: 'body' };
483
- let logicItem;
484
- if (options instanceof LogicItem__1.default) {
485
- options.ensureDelete(); // 同一实例不支持多处存在
486
- logicItem = options;
487
- Object.assign(logicItem, relationOptions);
488
- }
489
- else {
490
- logicItem = LogicItem__1.default.from({
491
- ...logicItemOptions,
492
- ...options,
493
- }, this, 'body');
494
- }
495
- this.body.splice(index, 0, logicItem);
496
- return logicItem;
497
- }
498
- insertItemInBodyAt(options, index) {
499
- const node = this._insertItemInBodyAt(options, index);
500
- node.create({
501
- index,
502
- parentNode: this,
503
- parentKey: 'body',
504
- });
505
- return node;
506
- }
507
- _addItemInBody(options) {
508
- const index = this.body.length;
509
- return this._insertItemInBodyAt(options, index);
510
- }
511
- addItemInBody(options) {
512
- const node = this._addItemInBody(options);
513
- const index = this.body.indexOf(node);
514
- node.create({
515
- index,
516
- parentNode: this,
517
- parentKey: 'body',
518
- });
519
- return node;
520
- }
521
- _insertItemInPlaygroundAt(options, index) {
522
- const logicItemOptions = {};
523
- const relationOptions = { parentNode: this, parentKey: 'playground' };
524
- let logicItem;
525
- if (options instanceof LogicItem__1.default) {
526
- options.ensureDelete(); // 同一实例不支持多处存在
527
- logicItem = options;
528
- Object.assign(logicItem, relationOptions);
529
- }
530
- else {
531
- logicItem = LogicItem__1.default.from({
532
- ...logicItemOptions,
533
- ...options,
534
- }, this, 'playground');
535
- }
536
- this.playground.splice(index, 0, logicItem);
537
- return logicItem;
538
- }
539
- insertItemInPlaygroundAt(options, index) {
540
- const node = this._insertItemInPlaygroundAt(options, index);
541
- node.create({
542
- index,
543
- parentNode: this,
544
- parentKey: 'playground',
545
- });
546
- return node;
547
- }
548
- _addItemInPlayground(options) {
549
- const index = this.playground.length;
550
- return this._insertItemInPlaygroundAt(options, index);
551
- }
552
- addItemInPlayground(options) {
553
- const node = this._addItemInPlayground(options);
554
- const index = this.playground.indexOf(node);
555
- node.create({
556
- index,
557
- parentNode: this,
558
- parentKey: 'playground',
559
- });
560
- return node;
561
- }
562
- removeTransactional(options) {
563
- let transactional;
564
- if (typeof options === 'string') {
565
- transactional = this.transactional;
566
- if (!transactional) {
567
- throw new Error('找不到事务 ' + options);
568
- }
569
- }
570
- else {
571
- transactional = options;
572
- }
573
- return transactional.delete();
574
- }
575
- __removeTransactional(transactional) {
576
- const parentKey = transactional.parentKey;
577
- const params = {
578
- parentNode: this,
579
- parentKey,
580
- index: -1,
581
- object: null,
582
- oldObject: transactional,
583
- };
584
- if (parentKey) {
585
- params.parentKey = parentKey;
586
- // @ts-ignore
587
- const t = this.__v_raw || this;
588
- // @ts-ignore
589
- const n = transactional.__v_raw || transactional;
590
- if (Array.isArray(t[parentKey])) {
591
- const index = t[parentKey].indexOf(n);
592
- ~index && this[parentKey].splice(index, 1);
593
- params.index = index;
594
- }
595
- else if (t[parentKey] === n) {
596
- params.index = 0;
597
- this[parentKey] = undefined;
598
- }
599
- }
600
- return params;
601
- }
602
- removeTypeParam(options) {
603
- let typeParam;
604
- if (typeof options === 'string') {
605
- typeParam = this.typeParams.find((item) => item.name === options);
606
- if (!typeParam) {
607
- throw new Error('找不到类型参数 ' + options);
608
- }
609
- }
610
- else {
611
- typeParam = options;
612
- }
613
- return typeParam.delete();
614
- }
615
- __removeTypeParam(typeParam) {
616
- const parentKey = typeParam.parentKey;
617
- const params = {
618
- parentNode: this,
619
- parentKey,
620
- index: -1,
621
- object: null,
622
- oldObject: typeParam,
623
- };
624
- if (parentKey) {
625
- params.parentKey = parentKey;
626
- // @ts-ignore
627
- const t = this.__v_raw || this;
628
- // @ts-ignore
629
- const n = typeParam.__v_raw || typeParam;
630
- if (Array.isArray(t[parentKey])) {
631
- const index = t[parentKey].indexOf(n);
632
- ~index && this[parentKey].splice(index, 1);
633
- params.index = index;
634
- }
635
- else if (t[parentKey] === n) {
636
- params.index = 0;
637
- this[parentKey] = undefined;
638
- }
639
- }
640
- return params;
641
- }
642
- removeParam(options) {
643
- let param;
644
- if (typeof options === 'string') {
645
- param = this.params.find((item) => item.name === options);
646
- if (!param) {
647
- throw new Error('找不到输入参数 ' + options);
648
- }
649
- }
650
- else {
651
- param = options;
652
- }
653
- return param.delete();
654
- }
655
- __removeParam(param) {
656
- const parentKey = param.parentKey;
657
- const params = {
658
- parentNode: this,
659
- parentKey,
660
- index: -1,
661
- object: null,
662
- oldObject: param,
663
- };
664
- if (parentKey) {
665
- params.parentKey = parentKey;
666
- // @ts-ignore
667
- const t = this.__v_raw || this;
668
- // @ts-ignore
669
- const n = param.__v_raw || param;
670
- if (Array.isArray(t[parentKey])) {
671
- const index = t[parentKey].indexOf(n);
672
- ~index && this[parentKey].splice(index, 1);
673
- params.index = index;
674
- }
675
- else if (t[parentKey] === n) {
676
- params.index = 0;
677
- this[parentKey] = undefined;
678
- }
679
- }
680
- return params;
681
- }
682
- removeReturn(options) {
683
- let ret;
684
- if (typeof options === 'string') {
685
- ret = this.returns.find((item) => item.name === options);
686
- if (!ret) {
687
- throw new Error('找不到输出参数 ' + options);
688
- }
689
- }
690
- else {
691
- ret = options;
692
- }
693
- return ret.delete();
694
- }
695
- __removeReturn(ret) {
696
- const parentKey = ret.parentKey;
697
- const params = {
698
- parentNode: this,
699
- parentKey,
700
- index: -1,
701
- object: null,
702
- oldObject: ret,
703
- };
704
- if (parentKey) {
705
- params.parentKey = parentKey;
706
- // @ts-ignore
707
- const t = this.__v_raw || this;
708
- // @ts-ignore
709
- const n = ret.__v_raw || ret;
710
- if (Array.isArray(t[parentKey])) {
711
- const index = t[parentKey].indexOf(n);
712
- ~index && this[parentKey].splice(index, 1);
713
- params.index = index;
714
- }
715
- else if (t[parentKey] === n) {
716
- params.index = 0;
717
- this[parentKey] = undefined;
718
- }
719
- }
720
- return params;
721
- }
722
- removeVariable(options) {
723
- let variable;
724
- if (typeof options === 'string') {
725
- variable = this.variables.find((item) => item.name === options);
726
- if (!variable) {
727
- throw new Error('找不到变量 ' + options);
728
- }
729
- }
730
- else {
731
- variable = options;
732
- }
733
- return variable.delete();
734
- }
735
- __removeVariable(variable) {
736
- const parentKey = variable.parentKey;
737
- const params = {
738
- parentNode: this,
739
- parentKey,
740
- index: -1,
741
- object: null,
742
- oldObject: variable,
743
- };
744
- if (parentKey) {
745
- params.parentKey = parentKey;
746
- // @ts-ignore
747
- const t = this.__v_raw || this;
748
- // @ts-ignore
749
- const n = variable.__v_raw || variable;
750
- if (Array.isArray(t[parentKey])) {
751
- const index = t[parentKey].indexOf(n);
752
- ~index && this[parentKey].splice(index, 1);
753
- params.index = index;
754
- }
755
- else if (t[parentKey] === n) {
756
- params.index = 0;
757
- this[parentKey] = undefined;
758
- }
759
- }
760
- return params;
761
- }
762
- removeItemInBody(options) {
763
- let logicItem = options;
764
- return logicItem.delete();
765
- }
766
- removeItemInPlayground(options) {
767
- let logicItem = options;
768
- return logicItem.delete();
769
- }
770
- __removeLogicItem(logicItem) {
771
- const parentKey = logicItem.parentKey;
772
- const params = {
773
- parentNode: this,
774
- parentKey,
775
- index: -1,
776
- object: null,
777
- oldObject: logicItem,
778
- };
779
- if (parentKey) {
780
- params.parentKey = parentKey;
781
- // @ts-ignore
782
- const t = this.__v_raw || this;
783
- // @ts-ignore
784
- const n = logicItem.__v_raw || logicItem;
785
- if (Array.isArray(t[parentKey])) {
786
- const index = t[parentKey].indexOf(n);
787
- ~index && this[parentKey].splice(index, 1);
788
- params.index = index;
789
- }
790
- else if (t[parentKey] === n) {
791
- params.index = 0;
792
- this[parentKey] = undefined;
793
- }
794
- }
795
- return params;
796
- }
797
- //================================================================================
798
- // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
799
- // 自动生成的代码已结束。下面可以手动编写。
800
- //================================================================================
801
- // 用于calllogic树中定位是那个logic,回显
802
- get calleewholeKey() {
803
- return `${this.getNamespace()}.${this.name}`;
804
- }
805
- // 设置定时任务
806
- setCronAndTriggerType(cron, triggerType) {
807
- const object = {
808
- cron,
809
- triggerType,
810
- };
811
- this.update({
812
- ...object,
813
- });
814
- }
815
- /**
816
- * 创建的时候 打开事务 通过开关设置数据库事务
817
- */
818
- openTransactional(flag) {
819
- if (flag) {
820
- const transactional = new Transactional__1.default({
821
- enabled: flag,
822
- });
823
- transactional._delete();
824
- const relationOptions = { parentNode: this, parentKey: 'transactional' };
825
- Object.assign(transactional, relationOptions);
826
- this.transactional = transactional;
827
- }
828
- }
829
- findLogicItemByConcept(concept) {
830
- let result;
831
- utils.traverse((current) => {
832
- if (current.node.concept === concept)
833
- return (result = current.node);
834
- }, { node: this }, {
835
- mode: 'anyObject',
836
- excludedKeySet: this.JSON_EXCLUDED_KEYS,
837
- });
838
- return result;
839
- }
840
- onChange($event) {
841
- this.emit('change', $event);
842
- }
843
- getVarExistingNames(excludedList = []) {
844
- const excludedSet = new Set(excludedList);
845
- const varList = [];
846
- if (Array.isArray(this.params)) {
847
- varList.push(...this.params);
848
- }
849
- if (Array.isArray(this.returns)) {
850
- varList.push(...this.returns);
851
- }
852
- if (Array.isArray(this.variables)) {
853
- varList.push(...this.variables);
854
- }
855
- if (this.view) {
856
- if (Array.isArray(this.view.params)) {
857
- varList.push(...this.view.params);
858
- }
859
- if (Array.isArray(this.view.variables)) {
860
- varList.push(...this.view.variables);
861
- }
862
- }
863
- this.traverseChildren((el) => {
864
- if (el?.concept === 'ForEachStatement') {
865
- if (el?.item) {
866
- varList.push(el?.item);
867
- }
868
- if (el?.index) {
869
- varList.push(el?.index);
870
- }
871
- }
872
- });
873
- return varList.filter((item) => !excludedSet.has(item)).map((item) => item?.name);
874
- }
875
- toJSContent(code, state) {
876
- // params
877
- if (Array.isArray(this.params)) {
878
- this.params.forEach((param) => {
879
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}`;
880
- code += param.toJS((0, translator_1.shiftState)(state, code, { inline: true }));
881
- code += ';\n';
882
- });
883
- }
884
- // variables
885
- if (Array.isArray(this.variables)) {
886
- this.variables.forEach((variable) => {
887
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
888
- code += variable.toJS((0, translator_1.shiftState)(state, code, { inline: true }));
889
- code += ';\n';
890
- });
891
- }
892
- // returns
893
- if (Array.isArray(this.returns)) {
894
- this.returns.forEach((ret) => {
895
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
896
- code += ret.toJS((0, translator_1.shiftState)(state, code, { inline: true }));
897
- code += ';\n';
898
- });
899
- }
900
- if (Array.isArray(this.body)) {
901
- this.body.forEach((item) => {
902
- code += item.toJS && item.toJS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
903
- code += '\n';
904
- });
905
- }
906
- return code;
907
- }
908
- toJS(state, type) {
909
- let code = '';
910
- if (type === 'IIFE') {
911
- code += `await (async () => {\n`;
912
- code = this.toJSContent(code, state);
913
- code += `${(0, translator_1.indent)(state?.tabSize || 0)}})();\n`;
914
- return code;
915
- }
916
- code += `async ${this.name} (`;
917
- if (this.params?.length) {
918
- this.params.forEach((param, index) => {
919
- code += param.name;
920
- if (index !== this.params.length - 1)
921
- code += ', ';
922
- });
923
- }
924
- code += ') {\n';
925
- code = this.toJSContent(code, state);
926
- code += `${(0, translator_1.indent)(state?.tabSize || 0)}}\n`;
927
- return code;
928
- }
929
- toProcessService() {
930
- return {
931
- config: {
932
- serviceType: 'micro',
933
- },
934
- url: {
935
- method: 'POST',
936
- path: this.getPath(),
937
- },
938
- };
939
- }
940
- toService() {
941
- const { parentNode } = this;
942
- const { concept, name: entityName } = parentNode || {};
943
- const logicName = this.name;
944
- let serviceType = 'micro';
945
- let method = 'POST';
946
- // let path = `/api/${logicName}`;
947
- const map = {
948
- GetUser: 'LCAPAuth',
949
- Logout: 'LCAPAuth',
950
- CheckPermission: 'LCAPPermission',
951
- GetUserResources: 'LCAPPermission',
952
- UploadPermission: 'LCAPPermission',
953
- GetUserList: 'LCAPUserManage',
954
- GetRoleList: 'LCAPUserManage',
955
- };
956
- let path = `/api/${map[logicName]}/overridden/${logicName}`;
957
- if (concept === 'Module') {
958
- path = `/api/${entityName.replace('-', '_')}/${logicName}`;
959
- }
960
- else if (concept === 'Namespace') {
961
- serviceType = 'entity';
962
- let entityPath = entityName.replace(/[A-Z]/g, (char, index) => {
963
- const lowerChar = char.toLowerCase();
964
- return index === 0 ? lowerChar : `-${lowerChar}`;
965
- });
966
- const dataSource = parentNode.getAncestor('DataSource');
967
- // 默认数据源不动,其他数据源需要拼接数据源信息
968
- if (dataSource && dataSource.name !== 'defaultDS') {
969
- entityPath = `${dataSource.name}/${entityPath}`;
970
- }
971
- path = `/api/${entityPath}`;
972
- switch (this.name) {
973
- case 'get':
974
- method = 'GET';
975
- path = `/api/${entityPath}`;
976
- break;
977
- case 'create':
978
- method = 'POST';
979
- break;
980
- case 'update':
981
- method = 'PUT';
982
- break;
983
- case 'delete':
984
- method = 'DELETE';
985
- path = `/api/${entityPath}`;
986
- break;
987
- case 'createOrUpdate':
988
- method = 'POST';
989
- path = `/api/${entityPath}/createOrUpdate`;
990
- break;
991
- case 'updateBy':
992
- method = 'PUT';
993
- path = `/api/${entityPath}/by`;
994
- break;
995
- case 'deleteBy':
996
- method = 'DELETE';
997
- path = `/api/${entityPath}/by`;
998
- break;
999
- case 'batchCreate':
1000
- method = 'POST';
1001
- path = `/api/${entityPath}/batch`;
1002
- break;
1003
- case 'batchUpdate':
1004
- method = 'PUT';
1005
- path = `/api/${entityPath}/batch`;
1006
- break;
1007
- case 'batchDelete':
1008
- method = 'DELETE';
1009
- path = `/api/${entityPath}/batch`;
1010
- break;
1011
- case 'import':
1012
- method = 'POST';
1013
- path = `/api/${entityPath}/import`;
1014
- break;
1015
- default:
1016
- break;
1017
- }
1018
- }
1019
- return {
1020
- config: {
1021
- serviceType,
1022
- },
1023
- url: {
1024
- method,
1025
- path,
1026
- },
1027
- };
1028
- }
1029
- toEmbeddedTSInProcess(state, prependCode, noName, prefix) {
1030
- let code = '';
1031
- if (!prefix)
1032
- code += `${noName ? '' : `${this.name}:`} function(`;
1033
- else
1034
- code += `function ${this.name}(`; // 加空格会导致无法查询到引用
1035
- this.params.forEach((param, index) => {
1036
- code += param.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1037
- if (index !== this.params.length - 1)
1038
- code += ', ';
1039
- });
1040
- code += `) {\n`;
1041
- code += prependCode || '';
1042
- code += '\n';
1043
- this.variables.forEach((variable) => {
1044
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1045
- code += variable.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1046
- code += ';\n';
1047
- });
1048
- this.returns.forEach((ret) => {
1049
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1050
- code += ret.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1051
- code += ';\n';
1052
- });
1053
- if (!this.body.length && this.returns.length) {
1054
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}return ${this.returns[0].name};\n`;
1055
- }
1056
- else {
1057
- if (this.parentNode.type === 'ExclusiveGateway') {
1058
- if (this.body.length <= 1) {
1059
- code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1060
- code += 'const __LogicEmpty: any = null;';
1061
- }
1062
- }
1063
- else if (this.body.length <= 2 &&
1064
- !(this.parentNode instanceof Namespace__1.default) &&
1065
- !(this.parentNode instanceof Process__1.default)) {
1066
- code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1067
- code += `${(0, translator_1.indent)(state?.tabSize || 0 + 4)}const __LogicEmpty: any = null;`;
1068
- }
1069
- this.body.forEach((item) => {
1070
- code += item.toEmbeddedTS && item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1071
- code += ';\n';
1072
- });
1073
- }
1074
- // 在body渲染完成之后把其余的节点放到下面
1075
- this.playground.forEach((item) => {
1076
- code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1077
- code += '\n';
1078
- });
1079
- code += `${(0, translator_1.indent)(state?.tabSize || 0 + 4)}}`;
1080
- code += '\n';
1081
- return code;
1082
- }
1083
- toEmbeddedTSNoExport(state) {
1084
- return this.toEmbeddedTS(state, 'noExport');
1085
- }
1086
- toEmbeddedTS(state, prefix) {
1087
- // 如果传了不要前缀那就为空, 要不用传进来的,要是都没有就默认导出
1088
- let code = '';
1089
- if (!prefix) {
1090
- code += `export function ${this.name}`;
1091
- }
1092
- else if (prefix === 'noExport') {
1093
- code += `function ${this.name}`;
1094
- }
1095
- else if (prefix === 'inObject') {
1096
- code += `${this.name}`;
1097
- }
1098
- if (this.typeParams?.length) {
1099
- code += '<';
1100
- this.typeParams.forEach((typeParam, typeParamIndex) => {
1101
- code += typeParam.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1102
- if (typeParamIndex !== this.typeParams.length - 1)
1103
- code += ', ';
1104
- });
1105
- code += '>';
1106
- }
1107
- // 有参数长度
1108
- if (this.params.length) {
1109
- code += '(';
1110
- this.params.forEach((param, index) => {
1111
- code += param.toEmbeddedTS((0, translator_1.shiftState)(state, code));
1112
- if (index !== this.params.length - 1)
1113
- code += ', ';
1114
- });
1115
- code += ')';
1116
- }
1117
- else {
1118
- // 没有参数的
1119
- code += '()';
1120
- }
1121
- // 需要类型推导的局部变量/返回值需要调整申明顺序
1122
- const advanceMap = new Map();
1123
- const needGetSourceMapOqlList = [];
1124
- this.traverseChildren((el) => {
1125
- if (el && (el instanceof BatchAssignment__1.default || (el instanceof Assignment__1.default && el.left?.name))) {
1126
- if (el instanceof Assignment__1.default) {
1127
- const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && el.left?.name === variable.name);
1128
- if (advanceVar && !advanceMap.get(advanceVar)) {
1129
- advanceMap.set(advanceVar, el);
1130
- }
1131
- const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && el.left?.name === ret.name);
1132
- if (advanceRn && !advanceMap.get(advanceRn)) {
1133
- advanceMap.set(advanceRn, el);
1134
- }
1135
- }
1136
- else if (el instanceof BatchAssignment__1.default) {
1137
- el.assignmentLines.forEach(({ leftIndex }) => {
1138
- const leftCode = leftIndex.length === 1
1139
- ? el.left.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }))
1140
- : el.left.members[leftIndex[1]]?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1141
- const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && leftCode === variable.name);
1142
- if (advanceVar && !advanceMap.get(advanceVar)) {
1143
- advanceMap.set(advanceVar, el);
1144
- }
1145
- const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && leftCode === ret.name);
1146
- if (advanceRn && !advanceMap.get(advanceRn)) {
1147
- advanceMap.set(advanceRn, el);
1148
- }
1149
- });
1150
- }
1151
- }
1152
- // 如果有sql查询组件就需要把他们存起来
1153
- if (el instanceof OqlQueryComponent__1.default) {
1154
- if (!el.codeSourceMap) {
1155
- needGetSourceMapOqlList.push(el.requestEmbeddedTS());
1156
- }
1157
- }
1158
- });
1159
- if (needGetSourceMapOqlList.length) {
1160
- Promise.all(needGetSourceMapOqlList).then(() => {
1161
- // 触发一下更新重新生成代码
1162
- this.app?.naslServer?.embeddedTSEmitter.emit('change', {
1163
- value: [
1164
- {
1165
- originEvent: {
1166
- action: 'update',
1167
- target: this,
1168
- },
1169
- },
1170
- ],
1171
- });
1172
- });
1173
- }
1174
- // 兼容 return 没有类型情况
1175
- if (this.returns.length && this.returns[0].typeAnnotation) {
1176
- code += ': ';
1177
- code += this.returns[0].typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1178
- }
1179
- code += '{\n';
1180
- // 用于虚拟节点的查找引用
1181
- this.virtualParams &&
1182
- Array.isArray(this.virtualParams) &&
1183
- this.virtualParams.forEach((param) => {
1184
- code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1185
- code += param.toEmbeddedNameTS((0, translator_1.shiftState)(state, code, { inline: true }));
1186
- code += '\n';
1187
- });
1188
- this.variables.forEach((variable) => {
1189
- if (!advanceMap.get(variable)) {
1190
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1191
- code += variable.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1192
- code += ';\n';
1193
- }
1194
- });
1195
- this.returns.forEach((ret) => {
1196
- if (!advanceMap.get(ret)) {
1197
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1198
- code += ret.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1199
- code += ';\n';
1200
- }
1201
- });
1202
- advanceMap.forEach((assignment, node) => {
1203
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}// @ts-ignore\n`;
1204
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1205
- code += node.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1206
- if (assignment instanceof BatchAssignment__1.default) {
1207
- assignment.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1208
- const leftCode = leftIndex.length === 1
1209
- ? assignment.left.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }))
1210
- : assignment.left.members[leftIndex[1]]?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1211
- if (leftCode === node.name) {
1212
- const rightNode = rightIndex.length === 1
1213
- ? assignment.rights[rightIndex[0]]?.expression
1214
- : assignment.rights[rightIndex[0]]?.members[rightIndex[1]];
1215
- // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1216
- if (rightNode?.typeAnnotation &&
1217
- !(rightNode instanceof CallQueryComponent__1.default && rightNode.ideVersion !== '2.11')) {
1218
- code += ': ';
1219
- code += rightNode.typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
1220
- }
1221
- else {
1222
- code += ' = ';
1223
- const rightCode = rightNode?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1224
- code += this.getRightCode(rightCode, assignment, rightNode);
1225
- }
1226
- }
1227
- });
1228
- }
1229
- else if (['NewList', 'NewMap'].includes(assignment.right?.concept) &&
1230
- !assignment.right?.typeAnnotation) {
1231
- const rightNode = assignment.right;
1232
- code += ' = ';
1233
- code += rightNode.getInitCode((0, translator_1.shiftState)(state, code, { inline: true }));
1234
- }
1235
- else if (assignment.right?.concept === 'NewComposite' &&
1236
- assignment.right?.typeAnnotation?.typeKind === 'anonymousStructure') {
1237
- const rightNode = assignment.right;
1238
- code += ' = ';
1239
- code += rightNode.getInitCode((0, translator_1.shiftState)(state, code, { inline: true }));
1240
- }
1241
- else {
1242
- const rightNode = assignment.right;
1243
- // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1244
- if (rightNode?.typeAnnotation &&
1245
- !(rightNode instanceof CallQueryComponent__1.default && rightNode.ideVersion !== '2.11')) {
1246
- code += ': ';
1247
- code += rightNode.typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
1248
- }
1249
- else {
1250
- code += ' = ';
1251
- let rightCode = '';
1252
- // 因为右侧枚举要赋值就得new 一下;
1253
- if (rightNode &&
1254
- rightNode instanceof Identifier__1.default &&
1255
- rightNode.namespace &&
1256
- rightNode.namespace.endsWith('enums')) {
1257
- rightCode += 'new ';
1258
- }
1259
- rightCode +=
1260
- rightNode && rightNode.toEmbeddedTS
1261
- ? rightNode.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }))
1262
- : '__RIGHT__';
1263
- code += this.getRightCode(rightCode, assignment, rightNode);
1264
- }
1265
- }
1266
- code += ';\n';
1267
- });
1268
- if (!this.body.length && this.returns.length) {
1269
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}return ${this.returns[0].name};\n`;
1270
- }
1271
- else {
1272
- // 如果长度小于2 并且不是虚拟节点就 报错,
1273
- if (this.body.length <= 2 && !(this.parentNode instanceof Namespace__1.default)) {
1274
- code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1275
- code += 'const __LogicEmpty: any = null;';
1276
- }
1277
- this.body.forEach((item) => {
1278
- code += item.toEmbeddedTS && item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1279
- code += ';\n';
1280
- });
1281
- }
1282
- // body渲染完成之后把其余的节点放到下面
1283
- this.playground.forEach((item) => {
1284
- code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1285
- code += ';\n';
1286
- });
1287
- code += `${(0, translator_1.indent)(state?.tabSize || 0)}}`;
1288
- if (prefix === 'inObject') {
1289
- code += `,`;
1290
- }
1291
- code += '\n';
1292
- return code;
1293
- }
1294
- getRightCode(code, assignment, rightNode) {
1295
- code = code.replaceAll('\n', ' ');
1296
- if (assignment instanceof Assignment__1.default && !assignment.right)
1297
- return code;
1298
- // 调用接口,参数替换成 null
1299
- if (rightNode instanceof CallInterface__1.default) {
1300
- const { _interface } = rightNode.getModuleInterface();
1301
- return _interface ? `${rightNode.tsCalleeKey}(${_interface.params.map(() => 'null').join(',')})` : null;
1302
- }
1303
- // 调用服务端逻辑,参数替换成 null
1304
- if (rightNode instanceof CallLogic__1.default && rightNode.calleeNamespace === 'app.logics') {
1305
- const calleeName = rightNode?.calleeName;
1306
- const calleeLogic = this.app.logics.find((l) => l.name === calleeName);
1307
- return calleeLogic ? `app.logics.${calleeName}(${calleeLogic.params.map(() => 'null').join(',')})` : null;
1308
- }
1309
- // ForEachStatement 内部变量需要替换处理,如 item、index
1310
- const forEachStatement = assignment.getAncestor('ForEachStatement');
1311
- if (forEachStatement) {
1312
- code = this.handleForEachCode(code, forEachStatement);
1313
- }
1314
- // Match 需要针对分支缩小类型范围
1315
- const matchCase = assignment.getAncestor('MatchCase');
1316
- if (matchCase) {
1317
- code = this.handleMatchCaseCode(code, matchCase);
1318
- }
1319
- return code;
1320
- }
1321
- handleReplaceCode(code, variable, replaceCode) {
1322
- return code.replace(/\S+/g, ($1) => {
1323
- if ($1 === `${variable},`)
1324
- return `${replaceCode},`;
1325
- if ($1 === variable)
1326
- return replaceCode;
1327
- let fnCode = $1;
1328
- if ($1.startsWith(`${variable}.`))
1329
- fnCode = $1.replaceAll(`${variable}.`, `${replaceCode}.`);
1330
- if ($1.startsWith(`${variable},`))
1331
- fnCode = $1.replaceAll(`${variable},`, `${replaceCode},`);
1332
- if ($1.includes(`(${variable},`))
1333
- fnCode = $1.replaceAll(`(${variable},`, `(${replaceCode},`);
1334
- if ($1.includes(`(${variable}.`))
1335
- fnCode = $1.replaceAll(`(${variable}.`, `(${replaceCode}.`);
1336
- if ($1.includes(`(${variable})`))
1337
- fnCode = $1.replaceAll(`(${variable})`, `(${replaceCode})`);
1338
- if ($1.includes(`,${variable},`))
1339
- fnCode = $1.replaceAll(`,${variable},`, `,${replaceCode},`);
1340
- if ($1.includes(`,${variable}.`))
1341
- fnCode = $1.replaceAll(`,${variable}.`, `,${replaceCode}.`);
1342
- if ($1.includes(`,${variable})`))
1343
- fnCode = $1.replaceAll(`,${variable})`, `,${replaceCode})`);
1344
- return fnCode;
1345
- });
1346
- }
1347
- handleForEachCode(code, forEachStatement) {
1348
- const { item, index, each } = forEachStatement;
1349
- if (code.includes(item.name)) {
1350
- const eachTSCode = each ? each.toEmbeddedTS() : '__IDENTIFIER__';
1351
- code = this.handleReplaceCode(code, item.name, eachTSCode === '__IDENTIFIER__' ? eachTSCode : `${eachTSCode}.__get(0)`);
1352
- }
1353
- if (code.includes(index.name))
1354
- code = this.handleReplaceCode(code, index.name, 'new nasl.core.Integer(0)');
1355
- const parentForEachStatement = forEachStatement.getAncestor('ForEachStatement');
1356
- if (parentForEachStatement) {
1357
- this.handleForEachCode(code, parentForEachStatement);
1358
- }
1359
- return code;
1360
- }
1361
- handleMatchCaseCode(code, matchCase) {
1362
- const match = matchCase.getAncestor('Match');
1363
- const expressionTsCode = match.expression.toEmbeddedTS();
1364
- if (code.includes(expressionTsCode)) {
1365
- let typeCode = '';
1366
- matchCase.patterns.forEach((pattern, index) => {
1367
- if (pattern instanceof TypeAnnotation__1.default) {
1368
- if (index === 0) {
1369
- typeCode += pattern.toEmbeddedTS();
1370
- }
1371
- else {
1372
- typeCode += '|';
1373
- typeCode += pattern.toEmbeddedTS();
1374
- }
1375
- }
1376
- });
1377
- if (typeCode) {
1378
- code = this.handleReplaceCode(code, expressionTsCode, `(${expressionTsCode} as ${typeCode})`);
1379
- }
1380
- }
1381
- const parentMatchCase = match.getAncestor('MatchCase');
1382
- if (parentMatchCase) {
1383
- code = this.handleMatchCaseCode(code, parentMatchCase);
1384
- }
1385
- return code;
1386
- }
1387
- getNamespace() {
1388
- if (this.parentNode) {
1389
- const parentNamespace = this.parentNode?.getNamespace();
1390
- const parentName = this.parentNode.name;
1391
- const arr = [parentNamespace];
1392
- if (this.parentNode.concept !== 'App' && parentName) {
1393
- arr.push(parentName);
1394
- }
1395
- let namespace = arr.join('.');
1396
- if (![
1397
- 'nasl.ui',
1398
- 'nasl.utils',
1399
- 'nasl.util',
1400
- 'nasl.browser',
1401
- 'nasl.auth',
1402
- 'nasl.configuration',
1403
- 'nasl.process',
1404
- 'nasl.logging',
1405
- 'nasl.io',
1406
- ].includes(namespace) &&
1407
- !namespace.includes('.overriddenLogics')) {
1408
- namespace = `${namespace}.overriddenLogics`;
1409
- }
1410
- if (this.concept === 'OverriddenLogic') {
1411
- namespace = `extensions.${this.overriddenModule}.logics`;
1412
- }
1413
- return namespace;
1414
- }
1415
- throw new Error('无法获取命名空间,请设置 parentNode!');
1416
- }
1417
- getTsNamespace() {
1418
- if (this.parentNode) {
1419
- const parentNamespace = this.parentNode?.getTsNamespace();
1420
- const parentName = this.parentNode.tsName || this.parentNode.name;
1421
- const arr = [parentNamespace];
1422
- if (this.parentNode.concept !== 'App' && parentName) {
1423
- arr.push(parentName);
1424
- }
1425
- let namespace = arr.join('.');
1426
- if (![
1427
- 'nasl.ui',
1428
- 'nasl.utils',
1429
- 'nasl.util',
1430
- 'nasl.browser',
1431
- 'nasl.auth',
1432
- 'nasl.configuration',
1433
- 'nasl.process',
1434
- 'nasl.logging',
1435
- 'nasl.io',
1436
- ].includes(namespace) &&
1437
- !namespace.includes('.overriddenLogics')) {
1438
- namespace = `${namespace}.overriddenLogics`;
1439
- }
1440
- return namespace;
1441
- }
1442
- throw new Error('无法获取命名空间,请设置 parentNode!');
1443
- }
1444
- /**
1445
- * 生成宿主语言的文件路径
1446
- * @param name 一般不用传,用于 rename
1447
- */
1448
- getEmbeddedFilePath(name = this.name) {
1449
- let _path = this.module ? `/${this.module.parentKey}/${this.module.name}` : '';
1450
- if (this.parentNode instanceof FrontendLibrary__1.FrontendLibrary) {
1451
- _path += `/frontends/${this.parentNode.type}`;
1452
- }
1453
- return `/embedded/${this.app.name}${_path}/overriddenLogics/${name}.ts`;
1454
- }
1455
- toEmbeddedTSFile() {
1456
- let code = `namespace ${this.getTsNamespace()} {\n`;
1457
- const state = (0, translator_1.createCompilerState)(code, { tabSize: 1 });
1458
- try {
1459
- code += this.toEmbeddedTS(state);
1460
- }
1461
- catch (err) {
1462
- console.log(err, '有问题翻译失败');
1463
- code += '';
1464
- console.log(err);
1465
- }
1466
- code += '}\n';
1467
- return {
1468
- code,
1469
- filePath: this.getEmbeddedFilePath(),
1470
- sourceMap: state.sourceMap,
1471
- };
1472
- }
1473
- static getDefaultOptions() {
1474
- return {
1475
- body: [
1476
- {
1477
- concept: 'Start',
1478
- label: '开始',
1479
- kind: 'Statement',
1480
- type: 'Start',
1481
- },
1482
- {
1483
- concept: 'End',
1484
- label: '结束',
1485
- kind: 'Statement',
1486
- type: 'End',
1487
- },
1488
- ],
1489
- };
1490
- }
1491
- async saveStructureOfCallQueryComponents(root) {
1492
- if (!root)
1493
- root = this;
1494
- const set = new Set();
1495
- utils.traverse(({ node }) => {
1496
- if (node instanceof CallQueryComponent__1.default) {
1497
- set.add(node);
1498
- }
1499
- }, { node: root }, {
1500
- mode: 'anyObject',
1501
- excludedKeySet: new Set(['parentNode', '__assignment__']),
1502
- });
1503
- for (const node of set) {
1504
- node.saveStructure();
1505
- }
1506
- }
1507
- // 通过开关设置数据库事务
1508
- setTransactionEnabled(flag) {
1509
- this.setTransactional(new Transactional__1.default({
1510
- enabled: flag,
1511
- }));
1512
- }
1513
- fake;
1514
- getPath;
1515
- delete() {
1516
- let actionMsg = '删除逻辑项';
1517
- if (this.name)
1518
- actionMsg += `“${this.name}”`;
1519
- this.app?.emit('collect:start', {
1520
- actionMsg,
1521
- });
1522
- super.delete();
1523
- this.traverseChildren((el) => {
1524
- if (el?.concept === 'CallQueryComponent')
1525
- el.removeStructure();
1526
- });
1527
- this.app?.emit('collect:end');
1528
- }
1529
- // 是不是内部有错误
1530
- haveError = false;
1531
- // 是否body为空
1532
- isSmpty = false;
1533
- get pathName() {
1534
- if (this.view) {
1535
- return this.getEventLogicName('chinese');
1536
- }
1537
- const nameMap = {
1538
- OnProcessStart: '流程开始时',
1539
- OnTasksCreate: '任务创建时',
1540
- OnTasksOpen: '任务打开时',
1541
- OnTasksClose: '任务关闭时',
1542
- OnCreate: '用户任务创建时',
1543
- OnOpen: '用户任务打开时',
1544
- OnClose: '用户任务关闭时',
1545
- };
1546
- const pathName = [this.name];
1547
- let { parentNode } = this;
1548
- while (parentNode && parentNode.concept !== 'Process') {
1549
- const name = nameMap[parentNode.name] || parentNode.name;
1550
- pathName.unshift(name);
1551
- parentNode = parentNode.parentNode;
1552
- }
1553
- return pathName.join('-');
1554
- }
1555
- // 获取bindEvent下的logic的名称
1556
- getEventLogicName(type) {
1557
- if (this.parentNode instanceof BindEvent__1.default) {
1558
- if (type === 'chinese') {
1559
- const bindEvent = this.parentNode;
1560
- const bindChineseName = bindEvent.getPageViewEventChineseName();
1561
- return `${bindChineseName}-${this.name}`;
1562
- }
1563
- }
1564
- return this.name;
1565
- }
1566
- // 虚拟输入参数列表
1567
- virtualParams = [];
1568
- get getLogicBelongTo() {
1569
- const [, belongTo] = this.calleewholeKey.split('.');
1570
- return belongTo;
1571
- }
1572
- // 校验logic的返回值是不是有error类型
1573
- static checkLogicReturnTypeHasError(logic) {
1574
- let findHasError = false;
1575
- if (!logic) {
1576
- return findHasError;
1577
- }
1578
- if (logic.returns?.length && logic.returns[0]?.typeAnnotation) {
1579
- // 如果新导入的logic还有Error类型
1580
- const logicType = logic.returns[0].typeAnnotation;
1581
- if (logicType.typeNamespace === 'nasl.ui' && logicType.typeName === 'Error') {
1582
- findHasError = true;
1583
- }
1584
- else if (logicType.typeNamespace === 'nasl.core' && logicType.typeKind === 'union') {
1585
- // 如果 logic 有 returns 而且,也有typeArguments的长度
1586
- findHasError = Boolean(logicType.typeArguments?.find((item) => item?.typeNamespace === 'nasl.ui' && item?.typeName === 'Error'));
1587
- }
1588
- }
1589
- return findHasError;
1590
- }
1591
- get getIsEmptyLogic() {
1592
- return this.body?.filter((node) => !['Start', 'End'].includes(node?.concept))?.length <= 0;
1593
- }
1594
- getOverriddenDepLogic() {
1595
- const dep = this.app.dependencies?.find((dep) => dep.name === this.overriddenModule);
1596
- if (dep) {
1597
- const depLogic = dep?.logics?.find((l) => l.name === this.name);
1598
- return depLogic || null;
1599
- }
1600
- return null;
1601
- }
1602
- };
1603
- exports.OverriddenLogic = OverriddenLogic;
1604
- __decorate([
1605
- (0, decorators_1.property)('concept')
1606
- // @ts-ignore
1607
- ], OverriddenLogic.prototype, "concept", void 0);
1608
- __decorate([
1609
- (0, decorators_1.property)()
1610
- // @ts-ignore
1611
- ], OverriddenLogic.prototype, "overriddenModule", void 0);
1612
- __decorate([
1613
- (0, decorators_1.property)()
1614
- // @ts-ignore
1615
- ], OverriddenLogic.prototype, "name", void 0);
1616
- __decorate([
1617
- (0, decorators_1.property)()
1618
- // @ts-ignore
1619
- ], OverriddenLogic.prototype, "description", void 0);
1620
- __decorate([
1621
- (0, decorators_1.property)()
1622
- // @ts-ignore
1623
- ], OverriddenLogic.prototype, "triggerType", void 0);
1624
- __decorate([
1625
- (0, decorators_1.property)()
1626
- // @ts-ignore
1627
- ], OverriddenLogic.prototype, "cron", void 0);
1628
- __decorate([
1629
- (0, decorators_1.property)({
1630
- objectRef: 'Transactional',
1631
- })
1632
- // @ts-ignore
1633
- ], OverriddenLogic.prototype, "transactional", void 0);
1634
- __decorate([
1635
- (0, decorators_1.property)({
1636
- objectRef: 'TypeParam',
1637
- isArray: true,
1638
- defaultValue: null,
1639
- })
1640
- ], OverriddenLogic.prototype, "typeParams", void 0);
1641
- __decorate([
1642
- (0, decorators_1.property)({
1643
- objectRef: 'Param',
1644
- isArray: true,
1645
- defaultValue: [],
1646
- })
1647
- ], OverriddenLogic.prototype, "params", void 0);
1648
- __decorate([
1649
- (0, decorators_1.property)({
1650
- objectRef: 'Return',
1651
- isArray: true,
1652
- defaultValue: [],
1653
- })
1654
- ], OverriddenLogic.prototype, "returns", void 0);
1655
- __decorate([
1656
- (0, decorators_1.property)({
1657
- objectRef: 'Variable',
1658
- isArray: true,
1659
- defaultValue: [],
1660
- })
1661
- ], OverriddenLogic.prototype, "variables", void 0);
1662
- __decorate([
1663
- (0, decorators_1.property)({
1664
- objectRef: 'LogicItem',
1665
- isArray: true,
1666
- defaultValue: [],
1667
- })
1668
- ], OverriddenLogic.prototype, "body", void 0);
1669
- __decorate([
1670
- (0, decorators_1.property)({
1671
- objectRef: 'LogicItem',
1672
- isArray: true,
1673
- defaultValue: [],
1674
- })
1675
- ], OverriddenLogic.prototype, "playground", void 0);
1676
- __decorate([
1677
- (0, translator_1.withSourceMap)()
1678
- ], OverriddenLogic.prototype, "toEmbeddedTSInProcess", null);
1679
- __decorate([
1680
- (0, translator_1.withSourceMap)()
1681
- ], OverriddenLogic.prototype, "toEmbeddedTS", null);
1682
- exports.OverriddenLogic = OverriddenLogic = OverriddenLogic_1 = __decorate([
1683
- decorators_1.className,
1684
- (0, decorators_1.concept)('覆写逻辑')
1685
- // @ts-ignore
1686
- ], OverriddenLogic);
1687
- exports.default = OverriddenLogic;
1688
- //================================================================================
1689
- // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1690
- // 自动生成的代码已结束。下面可以手动编写。
1691
- //================================================================================
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ var __importDefault = (this && this.__importDefault) || function (mod) {
32
+ return (mod && mod.__esModule) ? mod : { "default": mod };
33
+ };
34
+ var OverriddenLogic_1;
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.OverriddenLogic = void 0;
37
+ const FrontendLibrary__1 = require("./FrontendLibrary__");
38
+ const translator_1 = require("../translator");
39
+ const Namespace__1 = __importDefault(require("./Namespace__"));
40
+ const CallQueryComponent__1 = __importDefault(require("./CallQueryComponent__"));
41
+ const Assignment__1 = __importDefault(require("./Assignment__"));
42
+ const Identifier__1 = __importDefault(require("./Identifier__"));
43
+ const BindEvent__1 = __importDefault(require("./BindEvent__"));
44
+ const BatchAssignment__1 = __importDefault(require("./BatchAssignment__"));
45
+ const OqlQueryComponent__1 = __importDefault(require("./OqlQueryComponent__"));
46
+ const TypeAnnotation__1 = __importDefault(require("./TypeAnnotation__"));
47
+ const CallInterface__1 = __importDefault(require("./CallInterface__"));
48
+ const CallLogic__1 = __importDefault(require("./CallLogic__"));
49
+ const decorators_1 = require("../decorators");
50
+ const utils = __importStar(require("../utils"));
51
+ const BaseNode_1 = __importDefault(require("../common/BaseNode"));
52
+ const Transactional__1 = __importDefault(require("./Transactional__"));
53
+ const TypeParam__1 = __importDefault(require("./TypeParam__"));
54
+ const Param__1 = __importDefault(require("./Param__"));
55
+ const Return__1 = __importDefault(require("./Return__"));
56
+ const Variable__1 = __importDefault(require("./Variable__"));
57
+ const LogicItem__1 = __importDefault(require("./LogicItem__"));
58
+ const Process__1 = __importDefault(require("./Process__"));
59
+ /**
60
+ * 覆写逻辑
61
+ */
62
+ let OverriddenLogic = OverriddenLogic_1 =
63
+ // @ts-ignore
64
+ class OverriddenLogic extends BaseNode_1.default {
65
+ /** 类名 */
66
+ static ConceptName = 'OverriddenLogic';
67
+ /** 继承链 */
68
+ static inheritanceChain = ['BaseNode'];
69
+ /**
70
+ * 产品概念
71
+ */
72
+ concept;
73
+ /**
74
+ * 覆写的模块
75
+ */
76
+ // @ts-ignore
77
+ overriddenModule;
78
+ /**
79
+ * 覆写逻辑名称
80
+ */
81
+ // @ts-ignore
82
+ name;
83
+ /**
84
+ * 覆写逻辑描述
85
+ */
86
+ // @ts-ignore
87
+ description;
88
+ /**
89
+ * 触发方式
90
+ */
91
+ // @ts-ignore
92
+ triggerType;
93
+ /**
94
+ * 定时任务表达式
95
+ */
96
+ // @ts-ignore
97
+ cron;
98
+ /**
99
+ * 事务
100
+ */
101
+ // @ts-ignore
102
+ transactional;
103
+ /**
104
+ * 类型参数列表
105
+ */
106
+ typeParams = null;
107
+ /**
108
+ * 输入参数列表
109
+ */
110
+ params = [];
111
+ /**
112
+ * 输出参数列表
113
+ */
114
+ returns = [];
115
+ /**
116
+ * 变量列表
117
+ */
118
+ variables = [];
119
+ /**
120
+ * 逻辑项列表
121
+ */
122
+ body = [];
123
+ /**
124
+ * 逻辑项列表
125
+ */
126
+ playground = [];
127
+ /**
128
+ * 祖先 Module
129
+ */
130
+ get module() {
131
+ return this.getAncestor('Module');
132
+ }
133
+ /**
134
+ * 祖先 App
135
+ */
136
+ get app() {
137
+ return this.getAncestor('App');
138
+ }
139
+ /**
140
+ * 祖先 View
141
+ */
142
+ get view() {
143
+ return this.getAncestor('View');
144
+ }
145
+ /**
146
+ * 祖先 Frontend
147
+ */
148
+ get frontend() {
149
+ return this.getAncestor('Frontend');
150
+ }
151
+ /**
152
+ * 祖先 ProcessElement
153
+ */
154
+ get processElement() {
155
+ return this.getAncestor('ProcessElement');
156
+ }
157
+ /**
158
+ * 祖先 Process
159
+ */
160
+ get process() {
161
+ return this.getAncestor('Process');
162
+ }
163
+ /**
164
+ * @param source 需要合并的部分参数
165
+ */
166
+ constructor(source) {
167
+ source = Object.assign({}, OverriddenLogic_1.getDefaultOptions(), source);
168
+ super(source);
169
+ super.subConstructor(source);
170
+ }
171
+ static from(source, parentNode, parentKey) {
172
+ return super.from(source, parentNode, parentKey);
173
+ }
174
+ /**
175
+ * 从父级删除该节点
176
+ * @internal
177
+ */
178
+ _delete() {
179
+ let params = null;
180
+ if (this.parentNode) {
181
+ params = this.parentNode?.__removeOverriddenLogic?.(this);
182
+ }
183
+ return params;
184
+ }
185
+ /**
186
+ * 设置覆写的模块
187
+ */
188
+ setOverriddenModule(overriddenModule) {
189
+ const object = {
190
+ overriddenModule,
191
+ };
192
+ this.update({
193
+ ...object,
194
+ });
195
+ }
196
+ /**
197
+ * 设置覆写逻辑名称
198
+ */
199
+ setName(name) {
200
+ const object = {
201
+ name,
202
+ };
203
+ this.update({
204
+ ...object,
205
+ field: 'name',
206
+ });
207
+ }
208
+ /**
209
+ * 设置覆写逻辑描述
210
+ */
211
+ setDescription(description) {
212
+ const object = {
213
+ description,
214
+ };
215
+ this.update({
216
+ ...object,
217
+ });
218
+ }
219
+ /**
220
+ * 设置触发方式
221
+ */
222
+ setTriggerType(triggerType) {
223
+ const object = {
224
+ triggerType,
225
+ };
226
+ this.update({
227
+ ...object,
228
+ });
229
+ }
230
+ /**
231
+ * 设置定时任务表达式
232
+ */
233
+ setCron(cron) {
234
+ const object = {
235
+ cron,
236
+ };
237
+ this.update({
238
+ ...object,
239
+ });
240
+ }
241
+ /**
242
+ * 设置事务
243
+ */
244
+ setTransactional(transactional) {
245
+ transactional._delete();
246
+ const relationOptions = { parentNode: this, parentKey: 'transactional' };
247
+ Object.assign(transactional, relationOptions);
248
+ const object = {
249
+ transactional,
250
+ };
251
+ this.update({
252
+ ...object,
253
+ });
254
+ }
255
+ getTypeParamExistingNames(excludedList = []) {
256
+ const excludedSet = new Set(excludedList);
257
+ return (this.typeParams || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
258
+ }
259
+ getTypeParamUniqueName(name = 'typeParam1') {
260
+ return utils.unique(name, this.getTypeParamExistingNames(), undefined, false);
261
+ }
262
+ _insertTypeParamAt(options, index) {
263
+ const typeParamOptions = {};
264
+ const relationOptions = { parentNode: this, parentKey: 'typeParams' };
265
+ let typeParam;
266
+ if (!options) {
267
+ typeParam = TypeParam__1.default.from({
268
+ ...typeParamOptions,
269
+ name: this.getTypeParamUniqueName(),
270
+ }, this, 'typeParams');
271
+ }
272
+ else if (typeof options === 'string') {
273
+ typeParam = TypeParam__1.default.from({
274
+ ...typeParamOptions,
275
+ name: options,
276
+ }, this, 'typeParams');
277
+ }
278
+ else if (options instanceof TypeParam__1.default) {
279
+ options.ensureDelete(); // 同一实例不支持多处存在
280
+ typeParam = options;
281
+ Object.assign(typeParam, relationOptions);
282
+ }
283
+ else {
284
+ typeParam = TypeParam__1.default.from({
285
+ ...typeParamOptions,
286
+ ...options,
287
+ }, this, 'typeParams');
288
+ }
289
+ this.typeParams.splice(index, 0, typeParam);
290
+ return typeParam;
291
+ }
292
+ insertTypeParamAt(options, index) {
293
+ const node = this._insertTypeParamAt(options, index);
294
+ node.create({
295
+ index,
296
+ parentNode: this,
297
+ parentKey: 'typeParams',
298
+ });
299
+ return node;
300
+ }
301
+ _addTypeParam(options) {
302
+ const index = this.typeParams.length;
303
+ return this._insertTypeParamAt(options, index);
304
+ }
305
+ addTypeParam(options) {
306
+ const node = this._addTypeParam(options);
307
+ const index = this.typeParams.indexOf(node);
308
+ node.create({
309
+ index,
310
+ parentNode: this,
311
+ parentKey: 'typeParams',
312
+ });
313
+ return node;
314
+ }
315
+ getParamUniqueName(name = 'param1') {
316
+ return utils.unique(name, this.getVarExistingNames(), undefined, false);
317
+ }
318
+ _insertParamAt(options, index) {
319
+ const paramOptions = {};
320
+ const relationOptions = { parentNode: this, parentKey: 'params' };
321
+ let param;
322
+ if (!options) {
323
+ param = Param__1.default.from({
324
+ ...paramOptions,
325
+ name: this.getParamUniqueName(),
326
+ }, this, 'params');
327
+ }
328
+ else if (typeof options === 'string') {
329
+ param = Param__1.default.from({
330
+ ...paramOptions,
331
+ name: options,
332
+ }, this, 'params');
333
+ }
334
+ else if (options instanceof Param__1.default) {
335
+ options.ensureDelete(); // 同一实例不支持多处存在
336
+ param = options;
337
+ Object.assign(param, relationOptions);
338
+ }
339
+ else {
340
+ param = Param__1.default.from({
341
+ ...paramOptions,
342
+ ...options,
343
+ }, this, 'params');
344
+ }
345
+ this.params.splice(index, 0, param);
346
+ return param;
347
+ }
348
+ insertParamAt(options, index) {
349
+ const node = this._insertParamAt(options, index);
350
+ node.create({
351
+ index,
352
+ parentNode: this,
353
+ parentKey: 'params',
354
+ });
355
+ return node;
356
+ }
357
+ _addParam(options) {
358
+ const index = this.params.length;
359
+ return this._insertParamAt(options, index);
360
+ }
361
+ addParam(options) {
362
+ const node = this._addParam(options);
363
+ const index = this.params.indexOf(node);
364
+ node.create({
365
+ index,
366
+ parentNode: this,
367
+ parentKey: 'params',
368
+ });
369
+ return node;
370
+ }
371
+ getReturnUniqueName(name = 'result') {
372
+ return utils.unique(name, this.getVarExistingNames(), undefined, false);
373
+ }
374
+ _insertReturnAt(options, index) {
375
+ const retOptions = {};
376
+ const relationOptions = { parentNode: this, parentKey: 'returns' };
377
+ let ret;
378
+ if (!options) {
379
+ ret = Return__1.default.from({
380
+ ...retOptions,
381
+ name: this.getReturnUniqueName(),
382
+ }, this, 'returns');
383
+ }
384
+ else if (typeof options === 'string') {
385
+ ret = Return__1.default.from({
386
+ ...retOptions,
387
+ name: options,
388
+ }, this, 'returns');
389
+ }
390
+ else if (options instanceof Return__1.default) {
391
+ options.ensureDelete(); // 同一实例不支持多处存在
392
+ ret = options;
393
+ Object.assign(ret, relationOptions);
394
+ }
395
+ else {
396
+ ret = Return__1.default.from({
397
+ ...retOptions,
398
+ ...options,
399
+ }, this, 'returns');
400
+ }
401
+ this.returns.splice(index, 0, ret);
402
+ return ret;
403
+ }
404
+ insertReturnAt(options, index) {
405
+ const node = this._insertReturnAt(options, index);
406
+ node.create({
407
+ index,
408
+ parentNode: this,
409
+ parentKey: 'returns',
410
+ });
411
+ return node;
412
+ }
413
+ _addReturn(options) {
414
+ const index = this.returns.length;
415
+ return this._insertReturnAt(options, index);
416
+ }
417
+ addReturn(options) {
418
+ const node = this._addReturn(options);
419
+ const index = this.returns.indexOf(node);
420
+ node.create({
421
+ index,
422
+ parentNode: this,
423
+ parentKey: 'returns',
424
+ });
425
+ return node;
426
+ }
427
+ getVariableUniqueName(name = 'variable1') {
428
+ return utils.unique(name, this.getVarExistingNames(), undefined, false);
429
+ }
430
+ _insertVariableAt(options, index) {
431
+ const variableOptions = {};
432
+ const relationOptions = { parentNode: this, parentKey: 'variables' };
433
+ let variable;
434
+ if (!options) {
435
+ variable = Variable__1.default.from({
436
+ ...variableOptions,
437
+ name: this.getVariableUniqueName(),
438
+ }, this, 'variables');
439
+ }
440
+ else if (typeof options === 'string') {
441
+ variable = Variable__1.default.from({
442
+ ...variableOptions,
443
+ name: options,
444
+ }, this, 'variables');
445
+ }
446
+ else if (options instanceof Variable__1.default) {
447
+ options.ensureDelete(); // 同一实例不支持多处存在
448
+ variable = options;
449
+ Object.assign(variable, relationOptions);
450
+ }
451
+ else {
452
+ variable = Variable__1.default.from({
453
+ ...variableOptions,
454
+ ...options,
455
+ }, this, 'variables');
456
+ }
457
+ this.variables.splice(index, 0, variable);
458
+ return variable;
459
+ }
460
+ insertVariableAt(options, index) {
461
+ const node = this._insertVariableAt(options, index);
462
+ node.create({
463
+ index,
464
+ parentNode: this,
465
+ parentKey: 'variables',
466
+ });
467
+ return node;
468
+ }
469
+ _addVariable(options) {
470
+ const index = this.variables.length;
471
+ return this._insertVariableAt(options, index);
472
+ }
473
+ addVariable(options) {
474
+ const node = this._addVariable(options);
475
+ const index = this.variables.indexOf(node);
476
+ node.create({
477
+ index,
478
+ parentNode: this,
479
+ parentKey: 'variables',
480
+ });
481
+ return node;
482
+ }
483
+ _insertItemInBodyAt(options, index) {
484
+ const logicItemOptions = {};
485
+ const relationOptions = { parentNode: this, parentKey: 'body' };
486
+ let logicItem;
487
+ if (options instanceof LogicItem__1.default) {
488
+ options.ensureDelete(); // 同一实例不支持多处存在
489
+ logicItem = options;
490
+ Object.assign(logicItem, relationOptions);
491
+ }
492
+ else {
493
+ logicItem = LogicItem__1.default.from({
494
+ ...logicItemOptions,
495
+ ...options,
496
+ }, this, 'body');
497
+ }
498
+ this.body.splice(index, 0, logicItem);
499
+ return logicItem;
500
+ }
501
+ insertItemInBodyAt(options, index) {
502
+ const node = this._insertItemInBodyAt(options, index);
503
+ node.create({
504
+ index,
505
+ parentNode: this,
506
+ parentKey: 'body',
507
+ });
508
+ return node;
509
+ }
510
+ _addItemInBody(options) {
511
+ const index = this.body.length;
512
+ return this._insertItemInBodyAt(options, index);
513
+ }
514
+ addItemInBody(options) {
515
+ const node = this._addItemInBody(options);
516
+ const index = this.body.indexOf(node);
517
+ node.create({
518
+ index,
519
+ parentNode: this,
520
+ parentKey: 'body',
521
+ });
522
+ return node;
523
+ }
524
+ _insertItemInPlaygroundAt(options, index) {
525
+ const logicItemOptions = {};
526
+ const relationOptions = { parentNode: this, parentKey: 'playground' };
527
+ let logicItem;
528
+ if (options instanceof LogicItem__1.default) {
529
+ options.ensureDelete(); // 同一实例不支持多处存在
530
+ logicItem = options;
531
+ Object.assign(logicItem, relationOptions);
532
+ }
533
+ else {
534
+ logicItem = LogicItem__1.default.from({
535
+ ...logicItemOptions,
536
+ ...options,
537
+ }, this, 'playground');
538
+ }
539
+ this.playground.splice(index, 0, logicItem);
540
+ return logicItem;
541
+ }
542
+ insertItemInPlaygroundAt(options, index) {
543
+ const node = this._insertItemInPlaygroundAt(options, index);
544
+ node.create({
545
+ index,
546
+ parentNode: this,
547
+ parentKey: 'playground',
548
+ });
549
+ return node;
550
+ }
551
+ _addItemInPlayground(options) {
552
+ const index = this.playground.length;
553
+ return this._insertItemInPlaygroundAt(options, index);
554
+ }
555
+ addItemInPlayground(options) {
556
+ const node = this._addItemInPlayground(options);
557
+ const index = this.playground.indexOf(node);
558
+ node.create({
559
+ index,
560
+ parentNode: this,
561
+ parentKey: 'playground',
562
+ });
563
+ return node;
564
+ }
565
+ removeTransactional(options) {
566
+ let transactional;
567
+ if (typeof options === 'string') {
568
+ transactional = this.transactional;
569
+ if (!transactional) {
570
+ throw new Error('找不到事务 ' + options);
571
+ }
572
+ }
573
+ else {
574
+ transactional = options;
575
+ }
576
+ return transactional.delete();
577
+ }
578
+ __removeTransactional(transactional) {
579
+ const parentKey = transactional.parentKey;
580
+ const params = {
581
+ parentNode: this,
582
+ parentKey,
583
+ index: -1,
584
+ object: null,
585
+ oldObject: transactional,
586
+ };
587
+ if (parentKey) {
588
+ params.parentKey = parentKey;
589
+ // @ts-ignore
590
+ const t = this.__v_raw || this;
591
+ // @ts-ignore
592
+ const n = transactional.__v_raw || transactional;
593
+ if (Array.isArray(t[parentKey])) {
594
+ // @ts-ignore
595
+ const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
596
+ ~index && this[parentKey].splice(index, 1);
597
+ params.index = index;
598
+ }
599
+ else if (t[parentKey] === n) {
600
+ params.index = 0;
601
+ this[parentKey] = undefined;
602
+ }
603
+ }
604
+ return params;
605
+ }
606
+ removeTypeParam(options) {
607
+ let typeParam;
608
+ if (typeof options === 'string') {
609
+ typeParam = this.typeParams.find((item) => item.name === options);
610
+ if (!typeParam) {
611
+ throw new Error('找不到类型参数 ' + options);
612
+ }
613
+ }
614
+ else {
615
+ typeParam = options;
616
+ }
617
+ return typeParam.delete();
618
+ }
619
+ __removeTypeParam(typeParam) {
620
+ const parentKey = typeParam.parentKey;
621
+ const params = {
622
+ parentNode: this,
623
+ parentKey,
624
+ index: -1,
625
+ object: null,
626
+ oldObject: typeParam,
627
+ };
628
+ if (parentKey) {
629
+ params.parentKey = parentKey;
630
+ // @ts-ignore
631
+ const t = this.__v_raw || this;
632
+ // @ts-ignore
633
+ const n = typeParam.__v_raw || typeParam;
634
+ if (Array.isArray(t[parentKey])) {
635
+ // @ts-ignore
636
+ const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
637
+ ~index && this[parentKey].splice(index, 1);
638
+ params.index = index;
639
+ }
640
+ else if (t[parentKey] === n) {
641
+ params.index = 0;
642
+ this[parentKey] = undefined;
643
+ }
644
+ }
645
+ return params;
646
+ }
647
+ removeParam(options) {
648
+ let param;
649
+ if (typeof options === 'string') {
650
+ param = this.params.find((item) => item.name === options);
651
+ if (!param) {
652
+ throw new Error('找不到输入参数 ' + options);
653
+ }
654
+ }
655
+ else {
656
+ param = options;
657
+ }
658
+ return param.delete();
659
+ }
660
+ __removeParam(param) {
661
+ const parentKey = param.parentKey;
662
+ const params = {
663
+ parentNode: this,
664
+ parentKey,
665
+ index: -1,
666
+ object: null,
667
+ oldObject: param,
668
+ };
669
+ if (parentKey) {
670
+ params.parentKey = parentKey;
671
+ // @ts-ignore
672
+ const t = this.__v_raw || this;
673
+ // @ts-ignore
674
+ const n = param.__v_raw || param;
675
+ if (Array.isArray(t[parentKey])) {
676
+ // @ts-ignore
677
+ const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
678
+ ~index && this[parentKey].splice(index, 1);
679
+ params.index = index;
680
+ }
681
+ else if (t[parentKey] === n) {
682
+ params.index = 0;
683
+ this[parentKey] = undefined;
684
+ }
685
+ }
686
+ return params;
687
+ }
688
+ removeReturn(options) {
689
+ let ret;
690
+ if (typeof options === 'string') {
691
+ ret = this.returns.find((item) => item.name === options);
692
+ if (!ret) {
693
+ throw new Error('找不到输出参数 ' + options);
694
+ }
695
+ }
696
+ else {
697
+ ret = options;
698
+ }
699
+ return ret.delete();
700
+ }
701
+ __removeReturn(ret) {
702
+ const parentKey = ret.parentKey;
703
+ const params = {
704
+ parentNode: this,
705
+ parentKey,
706
+ index: -1,
707
+ object: null,
708
+ oldObject: ret,
709
+ };
710
+ if (parentKey) {
711
+ params.parentKey = parentKey;
712
+ // @ts-ignore
713
+ const t = this.__v_raw || this;
714
+ // @ts-ignore
715
+ const n = ret.__v_raw || ret;
716
+ if (Array.isArray(t[parentKey])) {
717
+ // @ts-ignore
718
+ const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
719
+ ~index && this[parentKey].splice(index, 1);
720
+ params.index = index;
721
+ }
722
+ else if (t[parentKey] === n) {
723
+ params.index = 0;
724
+ this[parentKey] = undefined;
725
+ }
726
+ }
727
+ return params;
728
+ }
729
+ removeVariable(options) {
730
+ let variable;
731
+ if (typeof options === 'string') {
732
+ variable = this.variables.find((item) => item.name === options);
733
+ if (!variable) {
734
+ throw new Error('找不到变量 ' + options);
735
+ }
736
+ }
737
+ else {
738
+ variable = options;
739
+ }
740
+ return variable.delete();
741
+ }
742
+ __removeVariable(variable) {
743
+ const parentKey = variable.parentKey;
744
+ const params = {
745
+ parentNode: this,
746
+ parentKey,
747
+ index: -1,
748
+ object: null,
749
+ oldObject: variable,
750
+ };
751
+ if (parentKey) {
752
+ params.parentKey = parentKey;
753
+ // @ts-ignore
754
+ const t = this.__v_raw || this;
755
+ // @ts-ignore
756
+ const n = variable.__v_raw || variable;
757
+ if (Array.isArray(t[parentKey])) {
758
+ // @ts-ignore
759
+ const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
760
+ ~index && this[parentKey].splice(index, 1);
761
+ params.index = index;
762
+ }
763
+ else if (t[parentKey] === n) {
764
+ params.index = 0;
765
+ this[parentKey] = undefined;
766
+ }
767
+ }
768
+ return params;
769
+ }
770
+ removeItemInBody(options) {
771
+ let logicItem = options;
772
+ return logicItem.delete();
773
+ }
774
+ removeItemInPlayground(options) {
775
+ let logicItem = options;
776
+ return logicItem.delete();
777
+ }
778
+ __removeLogicItem(logicItem) {
779
+ const parentKey = logicItem.parentKey;
780
+ const params = {
781
+ parentNode: this,
782
+ parentKey,
783
+ index: -1,
784
+ object: null,
785
+ oldObject: logicItem,
786
+ };
787
+ if (parentKey) {
788
+ params.parentKey = parentKey;
789
+ // @ts-ignore
790
+ const t = this.__v_raw || this;
791
+ // @ts-ignore
792
+ const n = logicItem.__v_raw || logicItem;
793
+ if (Array.isArray(t[parentKey])) {
794
+ // @ts-ignore
795
+ const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
796
+ ~index && this[parentKey].splice(index, 1);
797
+ params.index = index;
798
+ }
799
+ else if (t[parentKey] === n) {
800
+ params.index = 0;
801
+ this[parentKey] = undefined;
802
+ }
803
+ }
804
+ return params;
805
+ }
806
+ //================================================================================
807
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
808
+ // 自动生成的代码已结束。下面可以手动编写。
809
+ //================================================================================
810
+ // 用于calllogic树中定位是那个logic,回显
811
+ get calleewholeKey() {
812
+ return `${this.getNamespace()}.${this.name}`;
813
+ }
814
+ // 设置定时任务
815
+ setCronAndTriggerType(cron, triggerType) {
816
+ const object = {
817
+ cron,
818
+ triggerType,
819
+ };
820
+ this.update({
821
+ ...object,
822
+ });
823
+ }
824
+ /**
825
+ * 创建的时候 打开事务 通过开关设置数据库事务
826
+ */
827
+ openTransactional(flag) {
828
+ if (flag) {
829
+ const transactional = new Transactional__1.default({
830
+ enabled: flag,
831
+ });
832
+ transactional._delete();
833
+ const relationOptions = { parentNode: this, parentKey: 'transactional' };
834
+ Object.assign(transactional, relationOptions);
835
+ this.transactional = transactional;
836
+ }
837
+ }
838
+ findLogicItemByConcept(concept) {
839
+ let result;
840
+ utils.traverse((current) => {
841
+ if (current.node.concept === concept)
842
+ return (result = current.node);
843
+ }, { node: this }, {
844
+ mode: 'anyObject',
845
+ excludedKeySet: this.JSON_EXCLUDED_KEYS,
846
+ });
847
+ return result;
848
+ }
849
+ onChange($event) {
850
+ this.emit('change', $event);
851
+ }
852
+ getVarExistingNames(excludedList = []) {
853
+ const excludedSet = new Set(excludedList);
854
+ const varList = [];
855
+ if (Array.isArray(this.params)) {
856
+ varList.push(...this.params);
857
+ }
858
+ if (Array.isArray(this.returns)) {
859
+ varList.push(...this.returns);
860
+ }
861
+ if (Array.isArray(this.variables)) {
862
+ varList.push(...this.variables);
863
+ }
864
+ if (this.view) {
865
+ if (Array.isArray(this.view.params)) {
866
+ varList.push(...this.view.params);
867
+ }
868
+ if (Array.isArray(this.view.variables)) {
869
+ varList.push(...this.view.variables);
870
+ }
871
+ }
872
+ this.traverseChildren((el) => {
873
+ if (el?.concept === 'ForEachStatement') {
874
+ if (el?.item) {
875
+ varList.push(el?.item);
876
+ }
877
+ if (el?.index) {
878
+ varList.push(el?.index);
879
+ }
880
+ }
881
+ });
882
+ return varList.filter((item) => !excludedSet.has(item)).map((item) => item?.name);
883
+ }
884
+ toJSContent(code, state) {
885
+ // params
886
+ if (Array.isArray(this.params)) {
887
+ this.params.forEach((param) => {
888
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}`;
889
+ code += param.toJS((0, translator_1.shiftState)(state, code, { inline: true }));
890
+ code += ';\n';
891
+ });
892
+ }
893
+ // variables
894
+ if (Array.isArray(this.variables)) {
895
+ this.variables.forEach((variable) => {
896
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
897
+ code += variable.toJS((0, translator_1.shiftState)(state, code, { inline: true }));
898
+ code += ';\n';
899
+ });
900
+ }
901
+ // returns
902
+ if (Array.isArray(this.returns)) {
903
+ this.returns.forEach((ret) => {
904
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
905
+ code += ret.toJS((0, translator_1.shiftState)(state, code, { inline: true }));
906
+ code += ';\n';
907
+ });
908
+ }
909
+ if (Array.isArray(this.body)) {
910
+ this.body.forEach((item) => {
911
+ code += item.toJS && item.toJS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
912
+ code += '\n';
913
+ });
914
+ }
915
+ return code;
916
+ }
917
+ toJS(state, type) {
918
+ let code = '';
919
+ if (type === 'IIFE') {
920
+ code += `await (async () => {\n`;
921
+ code = this.toJSContent(code, state);
922
+ code += `${(0, translator_1.indent)(state?.tabSize || 0)}})();\n`;
923
+ return code;
924
+ }
925
+ code += `async ${this.name} (`;
926
+ if (this.params?.length) {
927
+ this.params.forEach((param, index) => {
928
+ code += param.name;
929
+ if (index !== this.params.length - 1)
930
+ code += ', ';
931
+ });
932
+ }
933
+ code += ') {\n';
934
+ code = this.toJSContent(code, state);
935
+ code += `${(0, translator_1.indent)(state?.tabSize || 0)}}\n`;
936
+ return code;
937
+ }
938
+ toProcessService() {
939
+ return {
940
+ config: {
941
+ serviceType: 'micro',
942
+ },
943
+ url: {
944
+ method: 'POST',
945
+ path: this.getPath(),
946
+ },
947
+ };
948
+ }
949
+ toService() {
950
+ const { parentNode } = this;
951
+ const { concept, name: entityName } = parentNode || {};
952
+ const logicName = this.name;
953
+ let serviceType = 'micro';
954
+ let method = 'POST';
955
+ // let path = `/api/${logicName}`;
956
+ const map = {
957
+ GetUser: 'LCAPAuth',
958
+ Logout: 'LCAPAuth',
959
+ CheckPermission: 'LCAPPermission',
960
+ GetUserResources: 'LCAPPermission',
961
+ UploadPermission: 'LCAPPermission',
962
+ GetUserList: 'LCAPUserManage',
963
+ GetRoleList: 'LCAPUserManage',
964
+ };
965
+ let path = `/api/${map[logicName]}/overridden/${logicName}`;
966
+ if (concept === 'Module') {
967
+ path = `/api/${entityName.replace('-', '_')}/${logicName}`;
968
+ }
969
+ else if (concept === 'Namespace') {
970
+ serviceType = 'entity';
971
+ let entityPath = entityName.replace(/[A-Z]/g, (char, index) => {
972
+ const lowerChar = char.toLowerCase();
973
+ return index === 0 ? lowerChar : `-${lowerChar}`;
974
+ });
975
+ const dataSource = parentNode.getAncestor('DataSource');
976
+ // 默认数据源不动,其他数据源需要拼接数据源信息
977
+ if (dataSource && dataSource.name !== 'defaultDS') {
978
+ entityPath = `${dataSource.name}/${entityPath}`;
979
+ }
980
+ path = `/api/${entityPath}`;
981
+ switch (this.name) {
982
+ case 'get':
983
+ method = 'GET';
984
+ path = `/api/${entityPath}`;
985
+ break;
986
+ case 'create':
987
+ method = 'POST';
988
+ break;
989
+ case 'update':
990
+ method = 'PUT';
991
+ break;
992
+ case 'delete':
993
+ method = 'DELETE';
994
+ path = `/api/${entityPath}`;
995
+ break;
996
+ case 'createOrUpdate':
997
+ method = 'POST';
998
+ path = `/api/${entityPath}/createOrUpdate`;
999
+ break;
1000
+ case 'updateBy':
1001
+ method = 'PUT';
1002
+ path = `/api/${entityPath}/by`;
1003
+ break;
1004
+ case 'deleteBy':
1005
+ method = 'DELETE';
1006
+ path = `/api/${entityPath}/by`;
1007
+ break;
1008
+ case 'batchCreate':
1009
+ method = 'POST';
1010
+ path = `/api/${entityPath}/batch`;
1011
+ break;
1012
+ case 'batchUpdate':
1013
+ method = 'PUT';
1014
+ path = `/api/${entityPath}/batch`;
1015
+ break;
1016
+ case 'batchDelete':
1017
+ method = 'DELETE';
1018
+ path = `/api/${entityPath}/batch`;
1019
+ break;
1020
+ case 'import':
1021
+ method = 'POST';
1022
+ path = `/api/${entityPath}/import`;
1023
+ break;
1024
+ default:
1025
+ break;
1026
+ }
1027
+ }
1028
+ return {
1029
+ config: {
1030
+ serviceType,
1031
+ },
1032
+ url: {
1033
+ method,
1034
+ path,
1035
+ },
1036
+ };
1037
+ }
1038
+ toEmbeddedTSInProcess(state, prependCode, noName, prefix) {
1039
+ let code = '';
1040
+ if (!prefix)
1041
+ code += `${noName ? '' : `${this.name}:`} function(`;
1042
+ else
1043
+ code += `function ${this.name}(`; // 加空格会导致无法查询到引用
1044
+ this.params.forEach((param, index) => {
1045
+ code += param.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1046
+ if (index !== this.params.length - 1)
1047
+ code += ', ';
1048
+ });
1049
+ code += `) {\n`;
1050
+ code += prependCode || '';
1051
+ code += '\n';
1052
+ this.variables.forEach((variable) => {
1053
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1054
+ code += variable.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1055
+ code += ';\n';
1056
+ });
1057
+ this.returns.forEach((ret) => {
1058
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1059
+ code += ret.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1060
+ code += ';\n';
1061
+ });
1062
+ if (!this.body.length && this.returns.length) {
1063
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}return ${this.returns[0].name};\n`;
1064
+ }
1065
+ else {
1066
+ if (this.parentNode.type === 'ExclusiveGateway') {
1067
+ if (this.body.length <= 1) {
1068
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1069
+ code += 'const __LogicEmpty: any = null;';
1070
+ }
1071
+ }
1072
+ else if (this.body.length <= 2 &&
1073
+ !(this.parentNode instanceof Namespace__1.default) &&
1074
+ !(this.parentNode instanceof Process__1.default)) {
1075
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1076
+ code += `${(0, translator_1.indent)(state?.tabSize || 0 + 4)}const __LogicEmpty: any = null;`;
1077
+ }
1078
+ this.body.forEach((item) => {
1079
+ code += item.toEmbeddedTS && item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1080
+ code += ';\n';
1081
+ });
1082
+ }
1083
+ // 在body渲染完成之后把其余的节点放到下面
1084
+ this.playground.forEach((item) => {
1085
+ code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1086
+ code += '\n';
1087
+ });
1088
+ code += `${(0, translator_1.indent)(state?.tabSize || 0 + 4)}}`;
1089
+ code += '\n';
1090
+ return code;
1091
+ }
1092
+ toEmbeddedTSNoExport(state) {
1093
+ return this.toEmbeddedTS(state, 'noExport');
1094
+ }
1095
+ toEmbeddedTS(state, prefix) {
1096
+ // 如果传了不要前缀那就为空, 要不用传进来的,要是都没有就默认导出
1097
+ let code = '';
1098
+ if (!prefix) {
1099
+ code += `export function ${this.name}`;
1100
+ }
1101
+ else if (prefix === 'noExport') {
1102
+ code += `function ${this.name}`;
1103
+ }
1104
+ else if (prefix === 'inObject') {
1105
+ code += `${this.name}`;
1106
+ }
1107
+ if (this.typeParams?.length) {
1108
+ code += '<';
1109
+ this.typeParams.forEach((typeParam, typeParamIndex) => {
1110
+ code += typeParam.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1111
+ if (typeParamIndex !== this.typeParams.length - 1)
1112
+ code += ', ';
1113
+ });
1114
+ code += '>';
1115
+ }
1116
+ // 有参数长度
1117
+ if (this.params.length) {
1118
+ code += '(';
1119
+ this.params.forEach((param, index) => {
1120
+ code += param.toEmbeddedTS((0, translator_1.shiftState)(state, code));
1121
+ if (index !== this.params.length - 1)
1122
+ code += ', ';
1123
+ });
1124
+ code += ')';
1125
+ }
1126
+ else {
1127
+ // 没有参数的
1128
+ code += '()';
1129
+ }
1130
+ // 需要类型推导的局部变量/返回值需要调整申明顺序
1131
+ const advanceMap = new Map();
1132
+ const needGetSourceMapOqlList = [];
1133
+ this.traverseChildren((el) => {
1134
+ if (el && (el instanceof BatchAssignment__1.default || (el instanceof Assignment__1.default && el.left?.name))) {
1135
+ if (el instanceof Assignment__1.default) {
1136
+ const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && el.left?.name === variable.name);
1137
+ if (advanceVar && !advanceMap.get(advanceVar)) {
1138
+ advanceMap.set(advanceVar, el);
1139
+ }
1140
+ const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && el.left?.name === ret.name);
1141
+ if (advanceRn && !advanceMap.get(advanceRn)) {
1142
+ advanceMap.set(advanceRn, el);
1143
+ }
1144
+ }
1145
+ else if (el instanceof BatchAssignment__1.default) {
1146
+ el.assignmentLines.forEach(({ leftIndex }) => {
1147
+ const leftCode = leftIndex.length === 1
1148
+ ? el.left.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }))
1149
+ : el.left.members[leftIndex[1]]?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1150
+ const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && leftCode === variable.name);
1151
+ if (advanceVar && !advanceMap.get(advanceVar)) {
1152
+ advanceMap.set(advanceVar, el);
1153
+ }
1154
+ const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && leftCode === ret.name);
1155
+ if (advanceRn && !advanceMap.get(advanceRn)) {
1156
+ advanceMap.set(advanceRn, el);
1157
+ }
1158
+ });
1159
+ }
1160
+ }
1161
+ // 如果有sql查询组件就需要把他们存起来
1162
+ if (el instanceof OqlQueryComponent__1.default) {
1163
+ if (!el.codeSourceMap) {
1164
+ needGetSourceMapOqlList.push(el.requestEmbeddedTS());
1165
+ }
1166
+ }
1167
+ });
1168
+ if (needGetSourceMapOqlList.length) {
1169
+ Promise.all(needGetSourceMapOqlList).then(() => {
1170
+ // 触发一下更新重新生成代码
1171
+ this.app?.naslServer?.embeddedTSEmitter.emit('change', {
1172
+ value: [
1173
+ {
1174
+ originEvent: {
1175
+ action: 'update',
1176
+ target: this,
1177
+ },
1178
+ },
1179
+ ],
1180
+ });
1181
+ });
1182
+ }
1183
+ // 兼容 return 没有类型情况
1184
+ if (this.returns.length && this.returns[0].typeAnnotation) {
1185
+ code += ': ';
1186
+ code += this.returns[0].typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1187
+ }
1188
+ code += '{\n';
1189
+ // 用于虚拟节点的查找引用
1190
+ this.virtualParams &&
1191
+ Array.isArray(this.virtualParams) &&
1192
+ this.virtualParams.forEach((param) => {
1193
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1194
+ code += param.toEmbeddedNameTS((0, translator_1.shiftState)(state, code, { inline: true }));
1195
+ code += '\n';
1196
+ });
1197
+ this.variables.forEach((variable) => {
1198
+ if (!advanceMap.get(variable)) {
1199
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1200
+ code += variable.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1201
+ code += ';\n';
1202
+ }
1203
+ });
1204
+ this.returns.forEach((ret) => {
1205
+ if (!advanceMap.get(ret)) {
1206
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1207
+ code += ret.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1208
+ code += ';\n';
1209
+ }
1210
+ });
1211
+ advanceMap.forEach((assignment, node) => {
1212
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}// @ts-ignore\n`;
1213
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1214
+ code += node.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1215
+ if (assignment instanceof BatchAssignment__1.default) {
1216
+ assignment.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1217
+ const leftCode = leftIndex.length === 1
1218
+ ? assignment.left.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }))
1219
+ : assignment.left.members[leftIndex[1]]?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1220
+ if (leftCode === node.name) {
1221
+ const rightNode = rightIndex.length === 1
1222
+ ? assignment.rights[rightIndex[0]]?.expression
1223
+ : assignment.rights[rightIndex[0]]?.members[rightIndex[1]];
1224
+ // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1225
+ if (rightNode?.typeAnnotation &&
1226
+ !(rightNode instanceof CallQueryComponent__1.default && rightNode.ideVersion !== '2.11')) {
1227
+ code += ': ';
1228
+ code += rightNode.typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
1229
+ }
1230
+ else {
1231
+ code += ' = ';
1232
+ const rightCode = rightNode?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1233
+ code += this.getRightCode(rightCode, assignment, rightNode);
1234
+ }
1235
+ }
1236
+ });
1237
+ }
1238
+ else if (['NewList', 'NewMap'].includes(assignment.right?.concept) &&
1239
+ !assignment.right?.typeAnnotation) {
1240
+ const rightNode = assignment.right;
1241
+ code += ' = ';
1242
+ code += rightNode.getInitCode((0, translator_1.shiftState)(state, code, { inline: true }));
1243
+ }
1244
+ else if (assignment.right?.concept === 'NewComposite' &&
1245
+ assignment.right?.typeAnnotation?.typeKind === 'anonymousStructure') {
1246
+ const rightNode = assignment.right;
1247
+ code += ' = ';
1248
+ code += rightNode.getInitCode((0, translator_1.shiftState)(state, code, { inline: true }));
1249
+ }
1250
+ else {
1251
+ const rightNode = assignment.right;
1252
+ // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1253
+ if (rightNode?.typeAnnotation &&
1254
+ !(rightNode instanceof CallQueryComponent__1.default && rightNode.ideVersion !== '2.11')) {
1255
+ code += ': ';
1256
+ code += rightNode.typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
1257
+ }
1258
+ else {
1259
+ code += ' = ';
1260
+ let rightCode = '';
1261
+ // 因为右侧枚举要赋值就得new 一下;
1262
+ if (rightNode &&
1263
+ rightNode instanceof Identifier__1.default &&
1264
+ rightNode.namespace &&
1265
+ rightNode.namespace.endsWith('enums')) {
1266
+ rightCode += 'new ';
1267
+ }
1268
+ rightCode +=
1269
+ rightNode && rightNode.toEmbeddedTS
1270
+ ? rightNode.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }))
1271
+ : '__RIGHT__';
1272
+ code += this.getRightCode(rightCode, assignment, rightNode);
1273
+ }
1274
+ }
1275
+ code += ';\n';
1276
+ });
1277
+ if (!this.body.length && this.returns.length) {
1278
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}return ${this.returns[0].name};\n`;
1279
+ }
1280
+ else {
1281
+ // 如果长度小于2 并且不是虚拟节点就 加 报错,
1282
+ if (this.body.length <= 2 && !(this.parentNode instanceof Namespace__1.default)) {
1283
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1284
+ code += 'const __LogicEmpty: any = null;';
1285
+ }
1286
+ this.body.forEach((item) => {
1287
+ code += item.toEmbeddedTS && item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1288
+ code += ';\n';
1289
+ });
1290
+ }
1291
+ // 在body渲染完成之后把其余的节点放到下面
1292
+ this.playground.forEach((item) => {
1293
+ code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1294
+ code += ';\n';
1295
+ });
1296
+ code += `${(0, translator_1.indent)(state?.tabSize || 0)}}`;
1297
+ if (prefix === 'inObject') {
1298
+ code += `,`;
1299
+ }
1300
+ code += '\n';
1301
+ return code;
1302
+ }
1303
+ getRightCode(code, assignment, rightNode) {
1304
+ code = code.replaceAll('\n', ' ');
1305
+ if (assignment instanceof Assignment__1.default && !assignment.right)
1306
+ return code;
1307
+ // 调用接口,参数替换成 null
1308
+ if (rightNode instanceof CallInterface__1.default) {
1309
+ const { _interface } = rightNode.getModuleInterface();
1310
+ return _interface ? `${rightNode.tsCalleeKey}(${_interface.params.map(() => 'null').join(',')})` : null;
1311
+ }
1312
+ // 调用服务端逻辑,参数替换成 null
1313
+ if (rightNode instanceof CallLogic__1.default && rightNode.calleeNamespace === 'app.logics') {
1314
+ const calleeName = rightNode?.calleeName;
1315
+ const calleeLogic = this.app.logics.find((l) => l.name === calleeName);
1316
+ return calleeLogic ? `app.logics.${calleeName}(${calleeLogic.params.map(() => 'null').join(',')})` : null;
1317
+ }
1318
+ // ForEachStatement 内部变量需要替换处理,如 item、index
1319
+ const forEachStatement = assignment.getAncestor('ForEachStatement');
1320
+ if (forEachStatement) {
1321
+ code = this.handleForEachCode(code, forEachStatement);
1322
+ }
1323
+ // Match 需要针对分支缩小类型范围
1324
+ const matchCase = assignment.getAncestor('MatchCase');
1325
+ if (matchCase) {
1326
+ code = this.handleMatchCaseCode(code, matchCase);
1327
+ }
1328
+ return code;
1329
+ }
1330
+ handleReplaceCode(code, variable, replaceCode) {
1331
+ return code.replace(/\S+/g, ($1) => {
1332
+ if ($1 === `${variable},`)
1333
+ return `${replaceCode},`;
1334
+ if ($1 === variable)
1335
+ return replaceCode;
1336
+ let fnCode = $1;
1337
+ if ($1.startsWith(`${variable}.`))
1338
+ fnCode = $1.replaceAll(`${variable}.`, `${replaceCode}.`);
1339
+ if ($1.startsWith(`${variable},`))
1340
+ fnCode = $1.replaceAll(`${variable},`, `${replaceCode},`);
1341
+ if ($1.includes(`(${variable},`))
1342
+ fnCode = $1.replaceAll(`(${variable},`, `(${replaceCode},`);
1343
+ if ($1.includes(`(${variable}.`))
1344
+ fnCode = $1.replaceAll(`(${variable}.`, `(${replaceCode}.`);
1345
+ if ($1.includes(`(${variable})`))
1346
+ fnCode = $1.replaceAll(`(${variable})`, `(${replaceCode})`);
1347
+ if ($1.includes(`,${variable},`))
1348
+ fnCode = $1.replaceAll(`,${variable},`, `,${replaceCode},`);
1349
+ if ($1.includes(`,${variable}.`))
1350
+ fnCode = $1.replaceAll(`,${variable}.`, `,${replaceCode}.`);
1351
+ if ($1.includes(`,${variable})`))
1352
+ fnCode = $1.replaceAll(`,${variable})`, `,${replaceCode})`);
1353
+ return fnCode;
1354
+ });
1355
+ }
1356
+ handleForEachCode(code, forEachStatement) {
1357
+ const { item, index, each } = forEachStatement;
1358
+ if (code.includes(item.name)) {
1359
+ const eachTSCode = each ? each.toEmbeddedTS() : '__IDENTIFIER__';
1360
+ code = this.handleReplaceCode(code, item.name, eachTSCode === '__IDENTIFIER__' ? eachTSCode : `${eachTSCode}.__get(0)`);
1361
+ }
1362
+ if (code.includes(index.name))
1363
+ code = this.handleReplaceCode(code, index.name, 'new nasl.core.Integer(0)');
1364
+ const parentForEachStatement = forEachStatement.getAncestor('ForEachStatement');
1365
+ if (parentForEachStatement) {
1366
+ this.handleForEachCode(code, parentForEachStatement);
1367
+ }
1368
+ return code;
1369
+ }
1370
+ handleMatchCaseCode(code, matchCase) {
1371
+ const match = matchCase.getAncestor('Match');
1372
+ const expressionTsCode = match.expression.toEmbeddedTS();
1373
+ if (code.includes(expressionTsCode)) {
1374
+ let typeCode = '';
1375
+ matchCase.patterns.forEach((pattern, index) => {
1376
+ if (pattern instanceof TypeAnnotation__1.default) {
1377
+ if (index === 0) {
1378
+ typeCode += pattern.toEmbeddedTS();
1379
+ }
1380
+ else {
1381
+ typeCode += '|';
1382
+ typeCode += pattern.toEmbeddedTS();
1383
+ }
1384
+ }
1385
+ });
1386
+ if (typeCode) {
1387
+ code = this.handleReplaceCode(code, expressionTsCode, `(${expressionTsCode} as ${typeCode})`);
1388
+ }
1389
+ }
1390
+ const parentMatchCase = match.getAncestor('MatchCase');
1391
+ if (parentMatchCase) {
1392
+ code = this.handleMatchCaseCode(code, parentMatchCase);
1393
+ }
1394
+ return code;
1395
+ }
1396
+ getNamespace() {
1397
+ if (this.parentNode) {
1398
+ const parentNamespace = this.parentNode?.getNamespace();
1399
+ const parentName = this.parentNode.name;
1400
+ const arr = [parentNamespace];
1401
+ if (this.parentNode.concept !== 'App' && parentName) {
1402
+ arr.push(parentName);
1403
+ }
1404
+ let namespace = arr.join('.');
1405
+ if (![
1406
+ 'nasl.ui',
1407
+ 'nasl.utils',
1408
+ 'nasl.util',
1409
+ 'nasl.browser',
1410
+ 'nasl.auth',
1411
+ 'nasl.configuration',
1412
+ 'nasl.process',
1413
+ 'nasl.logging',
1414
+ 'nasl.io',
1415
+ ].includes(namespace) &&
1416
+ !namespace.includes('.overriddenLogics')) {
1417
+ namespace = `${namespace}.overriddenLogics`;
1418
+ }
1419
+ if (this.concept === 'OverriddenLogic') {
1420
+ namespace = `extensions.${this.overriddenModule}.logics`;
1421
+ }
1422
+ return namespace;
1423
+ }
1424
+ throw new Error('无法获取命名空间,请设置 parentNode!');
1425
+ }
1426
+ getTsNamespace() {
1427
+ if (this.parentNode) {
1428
+ const parentNamespace = this.parentNode?.getTsNamespace();
1429
+ const parentName = this.parentNode.tsName || this.parentNode.name;
1430
+ const arr = [parentNamespace];
1431
+ if (this.parentNode.concept !== 'App' && parentName) {
1432
+ arr.push(parentName);
1433
+ }
1434
+ let namespace = arr.join('.');
1435
+ if (![
1436
+ 'nasl.ui',
1437
+ 'nasl.utils',
1438
+ 'nasl.util',
1439
+ 'nasl.browser',
1440
+ 'nasl.auth',
1441
+ 'nasl.configuration',
1442
+ 'nasl.process',
1443
+ 'nasl.logging',
1444
+ 'nasl.io',
1445
+ ].includes(namespace) &&
1446
+ !namespace.includes('.overriddenLogics')) {
1447
+ namespace = `${namespace}.overriddenLogics`;
1448
+ }
1449
+ return namespace;
1450
+ }
1451
+ throw new Error('无法获取命名空间,请设置 parentNode!');
1452
+ }
1453
+ /**
1454
+ * 生成宿主语言的文件路径
1455
+ * @param name 一般不用传,用于 rename
1456
+ */
1457
+ getEmbeddedFilePath(name = this.name) {
1458
+ let _path = this.module ? `/${this.module.parentKey}/${this.module.name}` : '';
1459
+ if (this.parentNode instanceof FrontendLibrary__1.FrontendLibrary) {
1460
+ _path += `/frontends/${this.parentNode.type}`;
1461
+ }
1462
+ return `/embedded/${this.app.name}${_path}/overriddenLogics/${name}.ts`;
1463
+ }
1464
+ toEmbeddedTSFile() {
1465
+ let code = `namespace ${this.getTsNamespace()} {\n`;
1466
+ const state = (0, translator_1.createCompilerState)(code, { tabSize: 1 });
1467
+ try {
1468
+ code += this.toEmbeddedTS(state);
1469
+ }
1470
+ catch (err) {
1471
+ console.log(err, '有问题翻译失败');
1472
+ code += '';
1473
+ console.log(err);
1474
+ }
1475
+ code += '}\n';
1476
+ return {
1477
+ code,
1478
+ filePath: this.getEmbeddedFilePath(),
1479
+ sourceMap: state.sourceMap,
1480
+ };
1481
+ }
1482
+ static getDefaultOptions() {
1483
+ return {
1484
+ body: [
1485
+ {
1486
+ concept: 'Start',
1487
+ label: '开始',
1488
+ kind: 'Statement',
1489
+ type: 'Start',
1490
+ },
1491
+ {
1492
+ concept: 'End',
1493
+ label: '结束',
1494
+ kind: 'Statement',
1495
+ type: 'End',
1496
+ },
1497
+ ],
1498
+ };
1499
+ }
1500
+ async saveStructureOfCallQueryComponents(root) {
1501
+ if (!root)
1502
+ root = this;
1503
+ const set = new Set();
1504
+ utils.traverse(({ node }) => {
1505
+ if (node instanceof CallQueryComponent__1.default) {
1506
+ set.add(node);
1507
+ }
1508
+ }, { node: root }, {
1509
+ mode: 'anyObject',
1510
+ excludedKeySet: new Set(['parentNode', '__assignment__']),
1511
+ });
1512
+ for (const node of set) {
1513
+ node.saveStructure();
1514
+ }
1515
+ }
1516
+ // 通过开关设置数据库事务
1517
+ setTransactionEnabled(flag) {
1518
+ this.setTransactional(new Transactional__1.default({
1519
+ enabled: flag,
1520
+ }));
1521
+ }
1522
+ fake;
1523
+ getPath;
1524
+ delete() {
1525
+ let actionMsg = '删除逻辑项';
1526
+ if (this.name)
1527
+ actionMsg += `“${this.name}”`;
1528
+ this.app?.emit('collect:start', {
1529
+ actionMsg,
1530
+ });
1531
+ super.delete();
1532
+ this.traverseChildren((el) => {
1533
+ if (el?.concept === 'CallQueryComponent')
1534
+ el.removeStructure();
1535
+ });
1536
+ this.app?.emit('collect:end');
1537
+ }
1538
+ // 是不是内部有错误
1539
+ haveError = false;
1540
+ // 是否body为空
1541
+ isSmpty = false;
1542
+ get pathName() {
1543
+ if (this.view) {
1544
+ return this.getEventLogicName('chinese');
1545
+ }
1546
+ const nameMap = {
1547
+ OnProcessStart: '流程开始时',
1548
+ OnTasksCreate: '任务创建时',
1549
+ OnTasksOpen: '任务打开时',
1550
+ OnTasksClose: '任务关闭时',
1551
+ OnCreate: '用户任务创建时',
1552
+ OnOpen: '用户任务打开时',
1553
+ OnClose: '用户任务关闭时',
1554
+ };
1555
+ const pathName = [this.name];
1556
+ let { parentNode } = this;
1557
+ while (parentNode && parentNode.concept !== 'Process') {
1558
+ const name = nameMap[parentNode.name] || parentNode.name;
1559
+ pathName.unshift(name);
1560
+ parentNode = parentNode.parentNode;
1561
+ }
1562
+ return pathName.join('-');
1563
+ }
1564
+ // 获取bindEvent下的logic的名称
1565
+ getEventLogicName(type) {
1566
+ if (this.parentNode instanceof BindEvent__1.default) {
1567
+ if (type === 'chinese') {
1568
+ const bindEvent = this.parentNode;
1569
+ const bindChineseName = bindEvent.getPageViewEventChineseName();
1570
+ return `${bindChineseName}-${this.name}`;
1571
+ }
1572
+ }
1573
+ return this.name;
1574
+ }
1575
+ // 虚拟输入参数列表
1576
+ virtualParams = [];
1577
+ get getLogicBelongTo() {
1578
+ const [, belongTo] = this.calleewholeKey.split('.');
1579
+ return belongTo;
1580
+ }
1581
+ // 校验logic的返回值是不是有error类型
1582
+ static checkLogicReturnTypeHasError(logic) {
1583
+ let findHasError = false;
1584
+ if (!logic) {
1585
+ return findHasError;
1586
+ }
1587
+ if (logic.returns?.length && logic.returns[0]?.typeAnnotation) {
1588
+ // 如果新导入的logic还有Error类型
1589
+ const logicType = logic.returns[0].typeAnnotation;
1590
+ if (logicType.typeNamespace === 'nasl.ui' && logicType.typeName === 'Error') {
1591
+ findHasError = true;
1592
+ }
1593
+ else if (logicType.typeNamespace === 'nasl.core' && logicType.typeKind === 'union') {
1594
+ // 如果 logic 有 returns 而且,也有typeArguments的长度
1595
+ findHasError = Boolean(logicType.typeArguments?.find((item) => item?.typeNamespace === 'nasl.ui' && item?.typeName === 'Error'));
1596
+ }
1597
+ }
1598
+ return findHasError;
1599
+ }
1600
+ get getIsEmptyLogic() {
1601
+ return this.body?.filter((node) => !['Start', 'End'].includes(node?.concept))?.length <= 0;
1602
+ }
1603
+ getOverriddenDepLogic() {
1604
+ const dep = this.app.dependencies?.find((dep) => dep.name === this.overriddenModule);
1605
+ if (dep) {
1606
+ const depLogic = dep?.logics?.find((l) => l.name === this.name);
1607
+ return depLogic || null;
1608
+ }
1609
+ return null;
1610
+ }
1611
+ };
1612
+ __decorate([
1613
+ (0, decorators_1.property)('concept')
1614
+ ], OverriddenLogic.prototype, "concept", void 0);
1615
+ __decorate([
1616
+ (0, decorators_1.property)()
1617
+ ], OverriddenLogic.prototype, "overriddenModule", void 0);
1618
+ __decorate([
1619
+ (0, decorators_1.property)()
1620
+ ], OverriddenLogic.prototype, "name", void 0);
1621
+ __decorate([
1622
+ (0, decorators_1.property)()
1623
+ ], OverriddenLogic.prototype, "description", void 0);
1624
+ __decorate([
1625
+ (0, decorators_1.property)()
1626
+ ], OverriddenLogic.prototype, "triggerType", void 0);
1627
+ __decorate([
1628
+ (0, decorators_1.property)()
1629
+ ], OverriddenLogic.prototype, "cron", void 0);
1630
+ __decorate([
1631
+ (0, decorators_1.property)({
1632
+ objectRef: 'Transactional',
1633
+ })
1634
+ ], OverriddenLogic.prototype, "transactional", void 0);
1635
+ __decorate([
1636
+ (0, decorators_1.property)({
1637
+ objectRef: 'TypeParam',
1638
+ isArray: true,
1639
+ defaultValue: null,
1640
+ })
1641
+ ], OverriddenLogic.prototype, "typeParams", void 0);
1642
+ __decorate([
1643
+ (0, decorators_1.property)({
1644
+ objectRef: 'Param',
1645
+ isArray: true,
1646
+ defaultValue: [],
1647
+ })
1648
+ ], OverriddenLogic.prototype, "params", void 0);
1649
+ __decorate([
1650
+ (0, decorators_1.property)({
1651
+ objectRef: 'Return',
1652
+ isArray: true,
1653
+ defaultValue: [],
1654
+ })
1655
+ ], OverriddenLogic.prototype, "returns", void 0);
1656
+ __decorate([
1657
+ (0, decorators_1.property)({
1658
+ objectRef: 'Variable',
1659
+ isArray: true,
1660
+ defaultValue: [],
1661
+ })
1662
+ ], OverriddenLogic.prototype, "variables", void 0);
1663
+ __decorate([
1664
+ (0, decorators_1.property)({
1665
+ objectRef: 'LogicItem',
1666
+ isArray: true,
1667
+ defaultValue: [],
1668
+ })
1669
+ ], OverriddenLogic.prototype, "body", void 0);
1670
+ __decorate([
1671
+ (0, decorators_1.property)({
1672
+ objectRef: 'LogicItem',
1673
+ isArray: true,
1674
+ defaultValue: [],
1675
+ })
1676
+ ], OverriddenLogic.prototype, "playground", void 0);
1677
+ __decorate([
1678
+ (0, translator_1.withSourceMap)()
1679
+ ], OverriddenLogic.prototype, "toEmbeddedTSInProcess", null);
1680
+ __decorate([
1681
+ (0, translator_1.withSourceMap)()
1682
+ ], OverriddenLogic.prototype, "toEmbeddedTS", null);
1683
+ OverriddenLogic = OverriddenLogic_1 = __decorate([
1684
+ decorators_1.className,
1685
+ (0, decorators_1.concept)('覆写逻辑')
1686
+ // @ts-ignore
1687
+ ], OverriddenLogic);
1688
+ exports.OverriddenLogic = OverriddenLogic;
1689
+ exports.default = OverriddenLogic;
1690
+ //================================================================================
1691
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1692
+ // 自动生成的代码已结束。下面可以手动编写。
1693
+ //================================================================================
1692
1694
  //# sourceMappingURL=OverriddenLogic__.js.map