@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,1949 +1,1970 @@
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 Logic_1;
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Logic = 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 Logic = class Logic extends BaseNode_1.default {
63
- static { Logic_1 = this; }
64
- /** 类名 */
65
- static ConceptName = 'Logic';
66
- /**
67
- * 产品概念
68
- */
69
- concept;
70
- /**
71
- * 逻辑名称
72
- */
73
- // @ts-ignore
74
- name;
75
- /**
76
- * 逻辑标题
77
- */
78
- // @ts-ignore
79
- title;
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
- overridable;
100
- /**
101
- * 事务
102
- */
103
- // @ts-ignore
104
- transactional;
105
- /**
106
- * 类型参数列表
107
- */
108
- typeParams = null;
109
- /**
110
- * 输入参数列表
111
- */
112
- params = [];
113
- /**
114
- * 输出参数列表
115
- */
116
- returns = [];
117
- /**
118
- * 变量列表
119
- */
120
- variables = [];
121
- /**
122
- * 逻辑项列表
123
- */
124
- body = [];
125
- /**
126
- * 逻辑项列表
127
- */
128
- playground = [];
129
- /**
130
- * 祖先 Module
131
- */
132
- get module() {
133
- return this.getAncestor('Module');
134
- }
135
- /**
136
- * 祖先 App
137
- */
138
- get app() {
139
- return this.getAncestor('App');
140
- }
141
- /**
142
- * 祖先 Connector
143
- */
144
- get connector() {
145
- return this.getAncestor('Connector');
146
- }
147
- /**
148
- * 祖先 View
149
- */
150
- get view() {
151
- return this.getAncestor('View');
152
- }
153
- /**
154
- * 祖先 Frontend
155
- */
156
- get frontend() {
157
- return this.getAncestor('Frontend');
158
- }
159
- /**
160
- * 祖先 ProcessElement
161
- */
162
- get processElement() {
163
- return this.getAncestor('ProcessElement');
164
- }
165
- /**
166
- * 祖先 Process
167
- */
168
- get process() {
169
- return this.getAncestor('Process');
170
- }
171
- /**
172
- * @param source 需要合并的部分参数
173
- */
174
- constructor(source) {
175
- source = Object.assign({}, Logic_1.getDefaultOptions(), source);
176
- super(source);
177
- super.subConstructor(source);
178
- }
179
- static from(source, parentNode, parentKey) {
180
- return super.from(source, parentNode, parentKey);
181
- }
182
- /**
183
- * 从父级删除该节点
184
- * @internal
185
- */
186
- _delete() {
187
- let params = null;
188
- if (this.parentNode) {
189
- params = this.parentNode?.__removeLogic?.(this);
190
- }
191
- return params;
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
- setTitle(title) {
209
- const object = {
210
- title,
211
- };
212
- this.update({
213
- ...object,
214
- });
215
- }
216
- /**
217
- * 设置逻辑描述
218
- */
219
- setDescription(description) {
220
- const object = {
221
- description,
222
- };
223
- this.update({
224
- ...object,
225
- });
226
- }
227
- /**
228
- * 设置触发方式
229
- */
230
- setTriggerType(triggerType) {
231
- const object = {
232
- triggerType,
233
- };
234
- this.update({
235
- ...object,
236
- });
237
- }
238
- /**
239
- * 设置定时任务表达式
240
- */
241
- setCron(cron) {
242
- const object = {
243
- cron,
244
- };
245
- this.update({
246
- ...object,
247
- });
248
- }
249
- /**
250
- * 设置是否可覆写
251
- */
252
- setOverridable(overridable) {
253
- const object = {
254
- overridable,
255
- };
256
- this.update({
257
- ...object,
258
- });
259
- }
260
- /**
261
- * 设置事务
262
- */
263
- setTransactional(transactional) {
264
- transactional._delete();
265
- const relationOptions = { parentNode: this, parentKey: 'transactional' };
266
- Object.assign(transactional, relationOptions);
267
- const object = {
268
- transactional,
269
- };
270
- this.update({
271
- ...object,
272
- });
273
- }
274
- getTypeParamExistingNames(excludedList = []) {
275
- const excludedSet = new Set(excludedList);
276
- return (this.typeParams || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
277
- }
278
- getTypeParamUniqueName(name = 'typeParam1') {
279
- return utils.unique(name, this.getTypeParamExistingNames(), undefined, false);
280
- }
281
- _insertTypeParamAt(options, index) {
282
- const typeParamOptions = {};
283
- const relationOptions = { parentNode: this, parentKey: 'typeParams' };
284
- let typeParam;
285
- if (!options) {
286
- typeParam = TypeParam__1.default.from({
287
- ...typeParamOptions,
288
- name: this.getTypeParamUniqueName(),
289
- }, this, 'typeParams');
290
- }
291
- else if (typeof options === 'string') {
292
- typeParam = TypeParam__1.default.from({
293
- ...typeParamOptions,
294
- name: options,
295
- }, this, 'typeParams');
296
- }
297
- else if (options instanceof TypeParam__1.default) {
298
- options.ensureDelete(); // 同一实例不支持多处存在
299
- typeParam = options;
300
- Object.assign(typeParam, relationOptions);
301
- }
302
- else {
303
- typeParam = TypeParam__1.default.from({
304
- ...typeParamOptions,
305
- ...options,
306
- }, this, 'typeParams');
307
- }
308
- this.typeParams.splice(index, 0, typeParam);
309
- return typeParam;
310
- }
311
- insertTypeParamAt(options, index) {
312
- const node = this._insertTypeParamAt(options, index);
313
- node.create({
314
- index,
315
- parentNode: this,
316
- parentKey: 'typeParams',
317
- });
318
- return node;
319
- }
320
- _addTypeParam(options) {
321
- const index = this.typeParams.length;
322
- return this._insertTypeParamAt(options, index);
323
- }
324
- addTypeParam(options) {
325
- const node = this._addTypeParam(options);
326
- const index = this.typeParams.indexOf(node);
327
- node.create({
328
- index,
329
- parentNode: this,
330
- parentKey: 'typeParams',
331
- });
332
- return node;
333
- }
334
- getParamUniqueName(name = 'param1') {
335
- return utils.unique(name, this.getVarExistingNames(), undefined, false);
336
- }
337
- _insertParamAt(options, index) {
338
- const paramOptions = {};
339
- const relationOptions = { parentNode: this, parentKey: 'params' };
340
- let param;
341
- if (!options) {
342
- param = Param__1.default.from({
343
- ...paramOptions,
344
- name: this.getParamUniqueName(),
345
- }, this, 'params');
346
- }
347
- else if (typeof options === 'string') {
348
- param = Param__1.default.from({
349
- ...paramOptions,
350
- name: options,
351
- }, this, 'params');
352
- }
353
- else if (options instanceof Param__1.default) {
354
- options.ensureDelete(); // 同一实例不支持多处存在
355
- param = options;
356
- Object.assign(param, relationOptions);
357
- }
358
- else {
359
- param = Param__1.default.from({
360
- ...paramOptions,
361
- ...options,
362
- }, this, 'params');
363
- }
364
- this.params.splice(index, 0, param);
365
- return param;
366
- }
367
- insertParamAt(options, index) {
368
- const node = this._insertParamAt(options, index);
369
- node.create({
370
- index,
371
- parentNode: this,
372
- parentKey: 'params',
373
- });
374
- return node;
375
- }
376
- _addParam(options) {
377
- const index = this.params.length;
378
- return this._insertParamAt(options, index);
379
- }
380
- addParam(options) {
381
- const node = this._addParam(options);
382
- const index = this.params.indexOf(node);
383
- node.create({
384
- index,
385
- parentNode: this,
386
- parentKey: 'params',
387
- });
388
- return node;
389
- }
390
- getReturnUniqueName(name = 'result') {
391
- return utils.unique(name, this.getVarExistingNames(), undefined, false);
392
- }
393
- _insertReturnAt(options, index) {
394
- const retOptions = {};
395
- const relationOptions = { parentNode: this, parentKey: 'returns' };
396
- let ret;
397
- if (!options) {
398
- ret = Return__1.default.from({
399
- ...retOptions,
400
- name: this.getReturnUniqueName(),
401
- }, this, 'returns');
402
- }
403
- else if (typeof options === 'string') {
404
- ret = Return__1.default.from({
405
- ...retOptions,
406
- name: options,
407
- }, this, 'returns');
408
- }
409
- else if (options instanceof Return__1.default) {
410
- options.ensureDelete(); // 同一实例不支持多处存在
411
- ret = options;
412
- Object.assign(ret, relationOptions);
413
- }
414
- else {
415
- ret = Return__1.default.from({
416
- ...retOptions,
417
- ...options,
418
- }, this, 'returns');
419
- }
420
- this.returns.splice(index, 0, ret);
421
- return ret;
422
- }
423
- insertReturnAt(options, index) {
424
- const node = this._insertReturnAt(options, index);
425
- node.create({
426
- index,
427
- parentNode: this,
428
- parentKey: 'returns',
429
- });
430
- return node;
431
- }
432
- _addReturn(options) {
433
- const index = this.returns.length;
434
- return this._insertReturnAt(options, index);
435
- }
436
- addReturn(options) {
437
- const node = this._addReturn(options);
438
- const index = this.returns.indexOf(node);
439
- node.create({
440
- index,
441
- parentNode: this,
442
- parentKey: 'returns',
443
- });
444
- return node;
445
- }
446
- getVariableUniqueName(name = 'variable1') {
447
- return utils.unique(name, this.getVarExistingNames(), undefined, false);
448
- }
449
- _insertVariableAt(options, index) {
450
- const variableOptions = {};
451
- const relationOptions = { parentNode: this, parentKey: 'variables' };
452
- let variable;
453
- if (!options) {
454
- variable = Variable__1.default.from({
455
- ...variableOptions,
456
- name: this.getVariableUniqueName(),
457
- }, this, 'variables');
458
- }
459
- else if (typeof options === 'string') {
460
- variable = Variable__1.default.from({
461
- ...variableOptions,
462
- name: options,
463
- }, this, 'variables');
464
- }
465
- else if (options instanceof Variable__1.default) {
466
- options.ensureDelete(); // 同一实例不支持多处存在
467
- variable = options;
468
- Object.assign(variable, relationOptions);
469
- }
470
- else {
471
- variable = Variable__1.default.from({
472
- ...variableOptions,
473
- ...options,
474
- }, this, 'variables');
475
- }
476
- this.variables.splice(index, 0, variable);
477
- return variable;
478
- }
479
- insertVariableAt(options, index) {
480
- const node = this._insertVariableAt(options, index);
481
- node.create({
482
- index,
483
- parentNode: this,
484
- parentKey: 'variables',
485
- });
486
- return node;
487
- }
488
- _addVariable(options) {
489
- const index = this.variables.length;
490
- return this._insertVariableAt(options, index);
491
- }
492
- addVariable(options) {
493
- const node = this._addVariable(options);
494
- const index = this.variables.indexOf(node);
495
- node.create({
496
- index,
497
- parentNode: this,
498
- parentKey: 'variables',
499
- });
500
- return node;
501
- }
502
- _insertItemInBodyAt(options, index) {
503
- const logicItemOptions = {};
504
- const relationOptions = { parentNode: this, parentKey: 'body' };
505
- let logicItem;
506
- if (options instanceof LogicItem__1.default) {
507
- options.ensureDelete(); // 同一实例不支持多处存在
508
- logicItem = options;
509
- Object.assign(logicItem, relationOptions);
510
- }
511
- else {
512
- logicItem = LogicItem__1.default.from({
513
- ...logicItemOptions,
514
- ...options,
515
- }, this, 'body');
516
- }
517
- this.body.splice(index, 0, logicItem);
518
- return logicItem;
519
- }
520
- insertItemInBodyAt(options, index) {
521
- const node = this._insertItemInBodyAt(options, index);
522
- node.create({
523
- index,
524
- parentNode: this,
525
- parentKey: 'body',
526
- });
527
- return node;
528
- }
529
- _addItemInBody(options) {
530
- const index = this.body.length;
531
- return this._insertItemInBodyAt(options, index);
532
- }
533
- addItemInBody(options) {
534
- const node = this._addItemInBody(options);
535
- const index = this.body.indexOf(node);
536
- node.create({
537
- index,
538
- parentNode: this,
539
- parentKey: 'body',
540
- });
541
- return node;
542
- }
543
- _insertItemInPlaygroundAt(options, index) {
544
- const logicItemOptions = {};
545
- const relationOptions = { parentNode: this, parentKey: 'playground' };
546
- let logicItem;
547
- if (options instanceof LogicItem__1.default) {
548
- options.ensureDelete(); // 同一实例不支持多处存在
549
- logicItem = options;
550
- Object.assign(logicItem, relationOptions);
551
- }
552
- else {
553
- logicItem = LogicItem__1.default.from({
554
- ...logicItemOptions,
555
- ...options,
556
- }, this, 'playground');
557
- }
558
- this.playground.splice(index, 0, logicItem);
559
- return logicItem;
560
- }
561
- insertItemInPlaygroundAt(options, index) {
562
- const node = this._insertItemInPlaygroundAt(options, index);
563
- node.create({
564
- index,
565
- parentNode: this,
566
- parentKey: 'playground',
567
- });
568
- return node;
569
- }
570
- _addItemInPlayground(options) {
571
- const index = this.playground.length;
572
- return this._insertItemInPlaygroundAt(options, index);
573
- }
574
- addItemInPlayground(options) {
575
- const node = this._addItemInPlayground(options);
576
- const index = this.playground.indexOf(node);
577
- node.create({
578
- index,
579
- parentNode: this,
580
- parentKey: 'playground',
581
- });
582
- return node;
583
- }
584
- removeTransactional(options) {
585
- let transactional;
586
- if (typeof options === 'string') {
587
- transactional = this.transactional;
588
- if (!transactional) {
589
- throw new Error('找不到事务 ' + options);
590
- }
591
- }
592
- else {
593
- transactional = options;
594
- }
595
- return transactional.delete();
596
- }
597
- __removeTransactional(transactional) {
598
- const parentKey = transactional.parentKey;
599
- const params = {
600
- parentNode: this,
601
- parentKey,
602
- index: -1,
603
- object: null,
604
- oldObject: transactional,
605
- };
606
- if (parentKey) {
607
- params.parentKey = parentKey;
608
- // @ts-ignore
609
- const t = this.__v_raw || this;
610
- // @ts-ignore
611
- const n = transactional.__v_raw || transactional;
612
- if (Array.isArray(t[parentKey])) {
613
- const index = t[parentKey].indexOf(n);
614
- ~index && this[parentKey].splice(index, 1);
615
- params.index = index;
616
- }
617
- else if (t[parentKey] === n) {
618
- params.index = 0;
619
- this[parentKey] = undefined;
620
- }
621
- }
622
- return params;
623
- }
624
- removeTypeParam(options) {
625
- let typeParam;
626
- if (typeof options === 'string') {
627
- typeParam = this.typeParams.find((item) => item.name === options);
628
- if (!typeParam) {
629
- throw new Error('找不到类型参数 ' + options);
630
- }
631
- }
632
- else {
633
- typeParam = options;
634
- }
635
- return typeParam.delete();
636
- }
637
- __removeTypeParam(typeParam) {
638
- const parentKey = typeParam.parentKey;
639
- const params = {
640
- parentNode: this,
641
- parentKey,
642
- index: -1,
643
- object: null,
644
- oldObject: typeParam,
645
- };
646
- if (parentKey) {
647
- params.parentKey = parentKey;
648
- // @ts-ignore
649
- const t = this.__v_raw || this;
650
- // @ts-ignore
651
- const n = typeParam.__v_raw || typeParam;
652
- if (Array.isArray(t[parentKey])) {
653
- const index = t[parentKey].indexOf(n);
654
- ~index && this[parentKey].splice(index, 1);
655
- params.index = index;
656
- }
657
- else if (t[parentKey] === n) {
658
- params.index = 0;
659
- this[parentKey] = undefined;
660
- }
661
- }
662
- return params;
663
- }
664
- removeParam(options) {
665
- let param;
666
- if (typeof options === 'string') {
667
- param = this.params.find((item) => item.name === options);
668
- if (!param) {
669
- throw new Error('找不到输入参数 ' + options);
670
- }
671
- }
672
- else {
673
- param = options;
674
- }
675
- return param.delete();
676
- }
677
- __removeParam(param) {
678
- const parentKey = param.parentKey;
679
- const params = {
680
- parentNode: this,
681
- parentKey,
682
- index: -1,
683
- object: null,
684
- oldObject: param,
685
- };
686
- if (parentKey) {
687
- params.parentKey = parentKey;
688
- // @ts-ignore
689
- const t = this.__v_raw || this;
690
- // @ts-ignore
691
- const n = param.__v_raw || param;
692
- if (Array.isArray(t[parentKey])) {
693
- const index = t[parentKey].indexOf(n);
694
- ~index && this[parentKey].splice(index, 1);
695
- params.index = index;
696
- }
697
- else if (t[parentKey] === n) {
698
- params.index = 0;
699
- this[parentKey] = undefined;
700
- }
701
- }
702
- return params;
703
- }
704
- removeReturn(options) {
705
- let ret;
706
- if (typeof options === 'string') {
707
- ret = this.returns.find((item) => item.name === options);
708
- if (!ret) {
709
- throw new Error('找不到输出参数 ' + options);
710
- }
711
- }
712
- else {
713
- ret = options;
714
- }
715
- return ret.delete();
716
- }
717
- __removeReturn(ret) {
718
- const parentKey = ret.parentKey;
719
- const params = {
720
- parentNode: this,
721
- parentKey,
722
- index: -1,
723
- object: null,
724
- oldObject: ret,
725
- };
726
- if (parentKey) {
727
- params.parentKey = parentKey;
728
- // @ts-ignore
729
- const t = this.__v_raw || this;
730
- // @ts-ignore
731
- const n = ret.__v_raw || ret;
732
- if (Array.isArray(t[parentKey])) {
733
- const index = t[parentKey].indexOf(n);
734
- ~index && this[parentKey].splice(index, 1);
735
- params.index = index;
736
- }
737
- else if (t[parentKey] === n) {
738
- params.index = 0;
739
- this[parentKey] = undefined;
740
- }
741
- }
742
- return params;
743
- }
744
- removeVariable(options) {
745
- let variable;
746
- if (typeof options === 'string') {
747
- variable = this.variables.find((item) => item.name === options);
748
- if (!variable) {
749
- throw new Error('找不到变量 ' + options);
750
- }
751
- }
752
- else {
753
- variable = options;
754
- }
755
- return variable.delete();
756
- }
757
- __removeVariable(variable) {
758
- const parentKey = variable.parentKey;
759
- const params = {
760
- parentNode: this,
761
- parentKey,
762
- index: -1,
763
- object: null,
764
- oldObject: variable,
765
- };
766
- if (parentKey) {
767
- params.parentKey = parentKey;
768
- // @ts-ignore
769
- const t = this.__v_raw || this;
770
- // @ts-ignore
771
- const n = variable.__v_raw || variable;
772
- if (Array.isArray(t[parentKey])) {
773
- const index = t[parentKey].indexOf(n);
774
- ~index && this[parentKey].splice(index, 1);
775
- params.index = index;
776
- }
777
- else if (t[parentKey] === n) {
778
- params.index = 0;
779
- this[parentKey] = undefined;
780
- }
781
- }
782
- return params;
783
- }
784
- removeItemInBody(options) {
785
- let logicItem = options;
786
- return logicItem.delete();
787
- }
788
- removeItemInPlayground(options) {
789
- let logicItem = options;
790
- return logicItem.delete();
791
- }
792
- __removeLogicItem(logicItem) {
793
- const parentKey = logicItem.parentKey;
794
- const params = {
795
- parentNode: this,
796
- parentKey,
797
- index: -1,
798
- object: null,
799
- oldObject: logicItem,
800
- };
801
- if (parentKey) {
802
- params.parentKey = parentKey;
803
- // @ts-ignore
804
- const t = this.__v_raw || this;
805
- // @ts-ignore
806
- const n = logicItem.__v_raw || logicItem;
807
- if (Array.isArray(t[parentKey])) {
808
- const index = t[parentKey].indexOf(n);
809
- ~index && this[parentKey].splice(index, 1);
810
- params.index = index;
811
- }
812
- else if (t[parentKey] === n) {
813
- params.index = 0;
814
- this[parentKey] = undefined;
815
- }
816
- }
817
- return params;
818
- }
819
- //================================================================================
820
- // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
821
- // 自动生成的代码已结束。下面可以手动编写。
822
- //================================================================================
823
- // 用于calllogic树中定位是那个logic,回显
824
- get calleewholeKey() {
825
- return `${this.getNamespace()}.${this.name}`;
826
- }
827
- // 设置定时任务
828
- setCronAndTriggerType(cron, triggerType) {
829
- const object = {
830
- cron,
831
- triggerType,
832
- };
833
- this.update({
834
- ...object,
835
- });
836
- }
837
- /**
838
- * 创建的时候 打开事务 通过开关设置数据库事务
839
- */
840
- openTransactional(flag) {
841
- if (flag) {
842
- const transactional = new Transactional__1.default({
843
- enabled: flag,
844
- });
845
- transactional._delete();
846
- const relationOptions = { parentNode: this, parentKey: 'transactional' };
847
- Object.assign(transactional, relationOptions);
848
- this.transactional = transactional;
849
- }
850
- }
851
- findLogicItemByConcept(concept) {
852
- let result;
853
- utils.traverse((current) => {
854
- if (current.node.concept === concept)
855
- return (result = current.node);
856
- }, { node: this }, {
857
- mode: 'anyObject',
858
- excludedKeySet: this.JSON_EXCLUDED_KEYS,
859
- });
860
- return result;
861
- }
862
- onChange($event) {
863
- this.emit('change', $event);
864
- }
865
- getVarExistingNames(excludedList = []) {
866
- const excludedSet = new Set(excludedList);
867
- const varList = [];
868
- if (Array.isArray(this.params)) {
869
- varList.push(...this.params);
870
- }
871
- if (Array.isArray(this.returns)) {
872
- varList.push(...this.returns);
873
- }
874
- if (Array.isArray(this.variables)) {
875
- varList.push(...this.variables);
876
- }
877
- if (this.view) {
878
- // 页面下,变量名不可以跟逻辑名相同,会有js 翻译问题
879
- varList.push(this);
880
- if (Array.isArray(this.view.params)) {
881
- varList.push(...this.view.params);
882
- }
883
- if (Array.isArray(this.view.variables)) {
884
- varList.push(...this.view.variables);
885
- }
886
- }
887
- this.traverseChildren((el) => {
888
- if (el?.concept === 'ForEachStatement') {
889
- if (el?.item) {
890
- varList.push(el?.item);
891
- }
892
- if (el?.index) {
893
- varList.push(el?.index);
894
- }
895
- }
896
- });
897
- return varList.filter((item) => !excludedSet.has(item)).map((item) => item?.name);
898
- }
899
- toJSContent(code, state) {
900
- // params
901
- if (Array.isArray(this.params)) {
902
- this.params.forEach((param) => {
903
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}`;
904
- code += param.toJS((0, translator_1.shiftState)(state, code, { inline: true }));
905
- code += ';\n';
906
- });
907
- }
908
- // variables
909
- if (Array.isArray(this.variables)) {
910
- this.variables.forEach((variable) => {
911
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
912
- code += variable.toJS((0, translator_1.shiftState)(state, code, { inline: true }));
913
- code += ';\n';
914
- });
915
- }
916
- // returns
917
- if (Array.isArray(this.returns)) {
918
- this.returns.forEach((ret) => {
919
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
920
- code += ret.toJS((0, translator_1.shiftState)(state, code, { inline: true }));
921
- code += ';\n';
922
- });
923
- }
924
- if (Array.isArray(this.body)) {
925
- this.body.forEach((item) => {
926
- code += item.toJS && item.toJS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
927
- code += '\n';
928
- });
929
- }
930
- return code;
931
- }
932
- toJS(state, type) {
933
- let code = '';
934
- if (type === 'IIFE') {
935
- code += `await (async () => {\n`;
936
- code = this.toJSContent(code, state);
937
- code += `${(0, translator_1.indent)(state?.tabSize || 0)}})();\n`;
938
- return code;
939
- }
940
- code += `async ${this.name} (`;
941
- if (this.params?.length) {
942
- this.params.forEach((param, index) => {
943
- code += param.name;
944
- if (index !== this.params.length - 1)
945
- code += ', ';
946
- });
947
- }
948
- code += ') {\n';
949
- code = this.toJSContent(code, state);
950
- code += `${(0, translator_1.indent)(state?.tabSize || 0)}}\n`;
951
- return code;
952
- }
953
- toProcessService() {
954
- return {
955
- config: {
956
- serviceType: 'micro',
957
- },
958
- url: {
959
- method: 'POST',
960
- path: this.getPath(),
961
- },
962
- };
963
- }
964
- toService() {
965
- const { parentNode } = this;
966
- const { concept, name: entityName } = parentNode || {};
967
- const logicName = this.name;
968
- let serviceType = 'micro';
969
- let method = 'POST';
970
- let path = `/api/lcplogics/${logicName}`;
971
- if (concept === 'Module') {
972
- path = `/api/${entityName.replace('-', '_')}/${logicName}`;
973
- }
974
- else if (concept === 'Namespace') {
975
- serviceType = 'entity';
976
- let entityPath = entityName.replace(/[A-Z]/g, (char, index) => {
977
- const lowerChar = char.toLowerCase();
978
- return index === 0 ? lowerChar : `-${lowerChar}`;
979
- });
980
- const dataSource = parentNode.getAncestor('DataSource');
981
- // 默认数据源不动,其他数据源需要拼接数据源信息
982
- if (dataSource && dataSource.name !== 'defaultDS') {
983
- entityPath = `${dataSource.name}/${entityPath}`;
984
- }
985
- path = `/api/${entityPath}`;
986
- switch (this.name) {
987
- case 'get':
988
- method = 'GET';
989
- path = `/api/${entityPath}`;
990
- break;
991
- case 'create':
992
- method = 'POST';
993
- break;
994
- case 'update':
995
- method = 'PUT';
996
- break;
997
- case 'delete':
998
- method = 'DELETE';
999
- path = `/api/${entityPath}`;
1000
- break;
1001
- case 'createOrUpdate':
1002
- method = 'POST';
1003
- path = `/api/${entityPath}/createOrUpdate`;
1004
- break;
1005
- case 'updateBy':
1006
- method = 'PUT';
1007
- path = `/api/${entityPath}/by`;
1008
- break;
1009
- case 'deleteBy':
1010
- method = 'DELETE';
1011
- path = `/api/${entityPath}/by`;
1012
- break;
1013
- case 'batchCreate':
1014
- method = 'POST';
1015
- path = `/api/${entityPath}/batch`;
1016
- break;
1017
- case 'batchUpdate':
1018
- method = 'PUT';
1019
- path = `/api/${entityPath}/batch`;
1020
- break;
1021
- case 'batchDelete':
1022
- method = 'DELETE';
1023
- path = `/api/${entityPath}/batch`;
1024
- break;
1025
- case 'import':
1026
- method = 'POST';
1027
- path = `/api/${entityPath}/import`;
1028
- break;
1029
- default:
1030
- break;
1031
- }
1032
- }
1033
- return {
1034
- config: {
1035
- serviceType,
1036
- },
1037
- url: {
1038
- method,
1039
- path,
1040
- },
1041
- };
1042
- }
1043
- toEmbeddedTSInProcess(state, prependCode, noName, prefix) {
1044
- let code = '';
1045
- if (!prefix)
1046
- code += `${noName ? '' : `${this.name}:`} function(`;
1047
- else
1048
- code += `function ${this.name}(`; // 加空格会导致无法查询到引用
1049
- this.params.forEach((param, index) => {
1050
- code += param.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }), null, true);
1051
- if (index !== this.params.length - 1)
1052
- code += ', ';
1053
- });
1054
- code += `) {\n`;
1055
- code += prependCode || '';
1056
- code += '\n';
1057
- this.variables.forEach((variable) => {
1058
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1059
- code += variable.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1060
- code += ';\n';
1061
- });
1062
- this.returns.forEach((ret) => {
1063
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1064
- code += ret.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1065
- code += ';\n';
1066
- });
1067
- if (!this.body.length && this.returns.length) {
1068
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}return ${this.returns[0].name};\n`;
1069
- }
1070
- else {
1071
- if (this.parentNode.type === 'ExclusiveGateway') {
1072
- if (this.body.length <= 1) {
1073
- code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1074
- code += 'const __LogicEmpty: any = null;';
1075
- }
1076
- }
1077
- else if (this.body.length <= 2 &&
1078
- !(this.parentNode instanceof Namespace__1.default) &&
1079
- !(this.parentNode instanceof Process__1.default)) {
1080
- code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1081
- code += `${(0, translator_1.indent)(state?.tabSize || 0 + 4)}const __LogicEmpty: any = null;`;
1082
- }
1083
- this.body.forEach((item) => {
1084
- code += item.toEmbeddedTS && item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1085
- code += ';\n';
1086
- });
1087
- }
1088
- // 在body渲染完成之后把其余的节点放到下面
1089
- this.playground.forEach((item) => {
1090
- code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1091
- code += '\n';
1092
- });
1093
- code += `${(0, translator_1.indent)(state?.tabSize || 0 + 4)}}`;
1094
- code += '\n';
1095
- return code;
1096
- }
1097
- toEmbeddedTSNoExport(state) {
1098
- return this.toEmbeddedTS(state, 'noExport');
1099
- }
1100
- toEmbeddedTS(state, prefix, hideDefaultValue) {
1101
- // 如果传了不要前缀那就为空, 要不用传进来的,要是都没有就默认导出
1102
- let code = '';
1103
- // 用来储存默认值翻译结构是__IDENTIFIER__或者__IDENTIFIER__()的节点
1104
- const IDENTIFIERMAP = new Set();
1105
- if (!prefix) {
1106
- code += `export function ${this.name}`;
1107
- }
1108
- else if (prefix === 'noExport') {
1109
- code += `function ${this.name}`;
1110
- }
1111
- else if (prefix === 'inObject') {
1112
- code += `${this.name}`;
1113
- }
1114
- if (this.typeParams?.length) {
1115
- code += '<';
1116
- this.typeParams.forEach((typeParam, typeParamIndex) => {
1117
- code += typeParam.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1118
- if (typeParamIndex !== this.typeParams.length - 1)
1119
- code += ', ';
1120
- });
1121
- code += '>';
1122
- }
1123
- // 有参数长度
1124
- if (this.params.length) {
1125
- code += '(';
1126
- this.params.forEach((param, index) => {
1127
- code += param.toEmbeddedTS((0, translator_1.shiftState)(state, code));
1128
- if (index !== this.params.length - 1)
1129
- code += ', ';
1130
- });
1131
- code += ')';
1132
- }
1133
- else {
1134
- // 没有参数的
1135
- code += '()';
1136
- }
1137
- // 需要类型推导的局部变量/返回值需要调整申明顺序
1138
- const advanceMap = new Map();
1139
- const needGetSourceMapOqlList = [];
1140
- this.traverseChildren((el) => {
1141
- if (el && (el instanceof BatchAssignment__1.default || (el instanceof Assignment__1.default && el.left?.name))) {
1142
- if (el instanceof Assignment__1.default) {
1143
- const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && el.left?.name === variable.name);
1144
- if (advanceVar && !advanceMap.get(advanceVar)) {
1145
- advanceMap.set(advanceVar, el);
1146
- }
1147
- const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && el.left?.name === ret.name);
1148
- if (advanceRn && !advanceMap.get(advanceRn)) {
1149
- advanceMap.set(advanceRn, el);
1150
- }
1151
- }
1152
- else if (el instanceof BatchAssignment__1.default) {
1153
- el.assignmentLines.forEach(({ leftIndex }) => {
1154
- const leftCode = leftIndex.length === 1
1155
- ? el.left.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }))
1156
- : el.left.members[leftIndex[1]]?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1157
- const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && leftCode === variable.name);
1158
- if (advanceVar && !advanceMap.get(advanceVar)) {
1159
- advanceMap.set(advanceVar, el);
1160
- }
1161
- const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && leftCode === ret.name);
1162
- if (advanceRn && !advanceMap.get(advanceRn)) {
1163
- advanceMap.set(advanceRn, el);
1164
- }
1165
- });
1166
- }
1167
- }
1168
- // 如果有sql查询组件就需要把他们存起来
1169
- if (el instanceof OqlQueryComponent__1.default) {
1170
- if (!el.codeSourceMap) {
1171
- needGetSourceMapOqlList.push(el.requestEmbeddedTS());
1172
- }
1173
- }
1174
- });
1175
- if (needGetSourceMapOqlList.length) {
1176
- Promise.all(needGetSourceMapOqlList).then(() => {
1177
- // 触发一下更新重新生成代码
1178
- this.app?.naslServer?.embeddedTSEmitter.emit('change', {
1179
- value: [
1180
- {
1181
- originEvent: {
1182
- action: 'update',
1183
- target: this,
1184
- },
1185
- },
1186
- ],
1187
- });
1188
- });
1189
- }
1190
- // 兼容 return 没有类型情况
1191
- if (this.returns.length && this.returns[0].typeAnnotation) {
1192
- code += ': ';
1193
- code += this.returns[0].typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1194
- }
1195
- code += '{\n';
1196
- // 用于虚拟节点的查找引用
1197
- this.virtualParams &&
1198
- Array.isArray(this.virtualParams) &&
1199
- this.virtualParams.forEach((param) => {
1200
- code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1201
- code += param.toEmbeddedNameTS((0, translator_1.shiftState)(state, code, { inline: true }));
1202
- code += '\n';
1203
- });
1204
- this.variables.forEach((variable) => {
1205
- const ts = variable.defaultValue?.expression?.toEmbeddedTS();
1206
- if (['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
1207
- IDENTIFIERMAP.add(variable);
1208
- }
1209
- if (!advanceMap.get(variable)) {
1210
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1211
- code += variable.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1212
- code += ';\n';
1213
- }
1214
- });
1215
- this.returns.forEach((ret) => {
1216
- const ts = ret.defaultValue?.expression?.toEmbeddedTS();
1217
- if (['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
1218
- IDENTIFIERMAP.add(ret);
1219
- }
1220
- if (!advanceMap.get(ret)) {
1221
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1222
- code += ret.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1223
- code += ';\n';
1224
- }
1225
- });
1226
- advanceMap.forEach((assignment, node) => {
1227
- // 有默认值的用默认值来推导类型, 但是如果是__IDENTIFIER__或者__IDENTIFIER__(),就不需要默认值来推导了
1228
- if (node.defaultValue?.expression && !IDENTIFIERMAP.has(node)) {
1229
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1230
- code += node.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1231
- return;
1232
- }
1233
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}// @ts-ignore\n`;
1234
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1235
- code += node.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1236
- if (assignment instanceof BatchAssignment__1.default) {
1237
- assignment.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1238
- const leftCode = leftIndex.length === 1
1239
- ? assignment.left.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }))
1240
- : assignment.left.members[leftIndex[1]]?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1241
- if (leftCode === node.name) {
1242
- const rightNode = rightIndex.length === 1
1243
- ? assignment.rights[rightIndex[0]]?.expression
1244
- : assignment.rights[rightIndex[0]]?.members[rightIndex[1]];
1245
- // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1246
- if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent__1.default && !rightNode.isAutoInfer())) {
1247
- if (rightNode.concept === 'NewComposite' && rightNode.typeAnnotation?.typeKind === 'anonymousStructure') {
1248
- code += '= ';
1249
- code += rightNode.getInitCode((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
1250
- }
1251
- else if (rightNode.concept === 'NewComposite' && rightNode.typeAnnotation?.typeKind === 'generic') {
1252
- code += '= ';
1253
- code += rightNode.getNewCompositeCode((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
1254
- }
1255
- else {
1256
- code += ': ';
1257
- code += rightNode.typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
1258
- }
1259
- }
1260
- else {
1261
- code += ' = ';
1262
- const rightCode = rightNode?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1263
- code += this.getRightCode(rightCode, assignment, rightNode);
1264
- }
1265
- }
1266
- });
1267
- }
1268
- else if (['NewList', 'NewMap'].includes(assignment.right?.concept) &&
1269
- !assignment.right?.typeAnnotation) {
1270
- const rightNode = assignment.right;
1271
- code += ' = ';
1272
- code += rightNode.getInitCode((0, translator_1.shiftState)(state, code, { inline: true }));
1273
- }
1274
- else if (assignment.right?.concept === 'NewComposite' &&
1275
- assignment.right?.typeAnnotation?.typeKind === 'anonymousStructure') {
1276
- const rightNode = assignment.right;
1277
- code += ' = ';
1278
- code += rightNode.getInitCode((0, translator_1.shiftState)(state, code, { inline: true }));
1279
- }
1280
- else if (assignment.right?.concept === 'NewComposite' &&
1281
- assignment.right?.typeAnnotation?.typeKind === 'generic') {
1282
- const rightNode = assignment.right;
1283
- code += ' = ';
1284
- code += rightNode.getNewCompositeCode((0, translator_1.shiftState)(state, code, { inline: true }));
1285
- }
1286
- else {
1287
- const rightNode = assignment.right;
1288
- // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1289
- if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent__1.default && !rightNode.isAutoInfer())) {
1290
- code += ': ';
1291
- code += rightNode.typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
1292
- }
1293
- else {
1294
- code += ' = ';
1295
- let rightCode = '';
1296
- // 因为右侧枚举要赋值就得new 一下;
1297
- if (rightNode &&
1298
- rightNode instanceof Identifier__1.default &&
1299
- rightNode.namespace &&
1300
- rightNode.namespace.endsWith('enums')) {
1301
- rightCode += 'new ';
1302
- }
1303
- rightCode +=
1304
- rightNode && rightNode.toEmbeddedTS
1305
- ? rightNode.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }))
1306
- : '__RIGHT__';
1307
- code += this.getRightCode(rightCode, assignment, rightNode);
1308
- }
1309
- }
1310
- code += ';\n';
1311
- });
1312
- // 参数的默认值是__IDENTIFIER__或者__IDENTIFIER__()时不赋默认值,但是需要ts翻译出来进行报错校验
1313
- if (!hideDefaultValue) {
1314
- IDENTIFIERMAP.forEach((node) => {
1315
- code += node.defaultValue.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1316
- code += '; ';
1317
- });
1318
- code += '\n';
1319
- }
1320
- if (!this.body.length && this.returns.length) {
1321
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}return ${this.returns[0].name};\n`;
1322
- }
1323
- else {
1324
- // 如果长度小于2 并且不是虚拟节点就 加 报错,
1325
- if (this.body.length <= 2 && !(this.parentNode instanceof Namespace__1.default)) {
1326
- if (this.body.length && this.body[0].concept === 'JavaLogic') {
1327
- code += '';
1328
- }
1329
- else {
1330
- code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1331
- code += 'const __LogicEmpty: any = null;';
1332
- }
1333
- }
1334
- this.body.forEach((item) => {
1335
- code += item.toEmbeddedTS && item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1336
- code += ';\n';
1337
- });
1338
- }
1339
- // 在body渲染完成之后把其余的节点放到下面
1340
- this.playground.forEach((item) => {
1341
- code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1342
- code += ';\n';
1343
- });
1344
- if (!hideDefaultValue) {
1345
- if (this.variables.length) {
1346
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}/* -----以下是variable的默认值草稿------ */\n`;
1347
- }
1348
- this.variables.forEach((variable) => {
1349
- if (variable.defaultValue) {
1350
- variable.defaultValue.playground?.forEach((item) => {
1351
- code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1352
- code += ';\n';
1353
- });
1354
- }
1355
- });
1356
- if (this.returns.length) {
1357
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}/* -----以下是returns的默认值草稿------ */\n`;
1358
- }
1359
- this.returns.forEach((return_) => {
1360
- if (return_.defaultValue) {
1361
- return_.defaultValue.playground?.forEach((item) => {
1362
- code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1363
- code += ';\n';
1364
- });
1365
- }
1366
- });
1367
- if (this.params.length) {
1368
- code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}/* -----以下是params的默认值草稿------ */\n`;
1369
- }
1370
- this.params.forEach((param) => {
1371
- if (param.defaultValue) {
1372
- param.defaultValue.playground?.forEach((item) => {
1373
- code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1374
- code += ';\n';
1375
- });
1376
- }
1377
- });
1378
- }
1379
- code += `${(0, translator_1.indent)(state?.tabSize || 0)}}`;
1380
- if (prefix === 'inObject') {
1381
- code += `,`;
1382
- }
1383
- code += '\n';
1384
- return code;
1385
- }
1386
- toNaturalTS(state = (0, translator_1.createCompilerState)(), prefix, logicName, currentNode) {
1387
- // 如果传了不要前缀那就为空, 要不用传进来的,要是都没有就默认导出
1388
- let code = '';
1389
- if (currentNode === this) {
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 Logic_1;
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Logic = 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 constants_1 = require("./basics/constants");
50
+ const decorators_1 = require("../decorators");
51
+ const utils = __importStar(require("../utils"));
52
+ const BaseNode_1 = __importDefault(require("../common/BaseNode"));
53
+ const Transactional__1 = __importDefault(require("./Transactional__"));
54
+ const TypeParam__1 = __importDefault(require("./TypeParam__"));
55
+ const Param__1 = __importDefault(require("./Param__"));
56
+ const Return__1 = __importDefault(require("./Return__"));
57
+ const Variable__1 = __importDefault(require("./Variable__"));
58
+ const LogicItem__1 = __importDefault(require("./LogicItem__"));
59
+ const Process__1 = __importDefault(require("./Process__"));
60
+ /**
61
+ * 逻辑
62
+ */
63
+ let Logic = Logic_1 =
64
+ // @ts-ignore
65
+ class Logic extends BaseNode_1.default {
66
+ /** 类名 */
67
+ static ConceptName = 'Logic';
68
+ /** 继承链 */
69
+ static inheritanceChain = ['BaseNode'];
70
+ /**
71
+ * 产品概念
72
+ */
73
+ concept;
74
+ /**
75
+ * 逻辑名称
76
+ */
77
+ // @ts-ignore
78
+ name;
79
+ /**
80
+ * 逻辑标题
81
+ */
82
+ // @ts-ignore
83
+ title;
84
+ /**
85
+ * 逻辑描述
86
+ */
87
+ // @ts-ignore
88
+ description;
89
+ /**
90
+ * 触发方式
91
+ */
92
+ // @ts-ignore
93
+ triggerType;
94
+ /**
95
+ * 定时任务表达式
96
+ */
97
+ // @ts-ignore
98
+ cron;
99
+ /**
100
+ * 是否可覆写
101
+ */
102
+ // @ts-ignore
103
+ overridable;
104
+ /**
105
+ * 事务
106
+ */
107
+ // @ts-ignore
108
+ transactional;
109
+ /**
110
+ * 类型参数列表
111
+ */
112
+ typeParams = null;
113
+ /**
114
+ * 输入参数列表
115
+ */
116
+ params = [];
117
+ /**
118
+ * 输出参数列表
119
+ */
120
+ returns = [];
121
+ /**
122
+ * 变量列表
123
+ */
124
+ variables = [];
125
+ /**
126
+ * 逻辑项列表
127
+ */
128
+ body = [];
129
+ /**
130
+ * 逻辑项列表
131
+ */
132
+ playground = [];
133
+ /**
134
+ * 祖先 Module
135
+ */
136
+ get module() {
137
+ return this.getAncestor('Module');
138
+ }
139
+ /**
140
+ * 祖先 App
141
+ */
142
+ get app() {
143
+ return this.getAncestor('App');
144
+ }
145
+ /**
146
+ * 祖先 Connector
147
+ */
148
+ get connector() {
149
+ return this.getAncestor('Connector');
150
+ }
151
+ /**
152
+ * 祖先 View
153
+ */
154
+ get view() {
155
+ return this.getAncestor('View');
156
+ }
157
+ /**
158
+ * 祖先 Frontend
159
+ */
160
+ get frontend() {
161
+ return this.getAncestor('Frontend');
162
+ }
163
+ /**
164
+ * 祖先 ProcessElement
165
+ */
166
+ get processElement() {
167
+ return this.getAncestor('ProcessElement');
168
+ }
169
+ /**
170
+ * 祖先 Process
171
+ */
172
+ get process() {
173
+ return this.getAncestor('Process');
174
+ }
175
+ /**
176
+ * @param source 需要合并的部分参数
177
+ */
178
+ constructor(source) {
179
+ source = Object.assign({}, Logic_1.getDefaultOptions(), source);
180
+ super(source);
181
+ super.subConstructor(source);
182
+ }
183
+ static from(source, parentNode, parentKey) {
184
+ return super.from(source, parentNode, parentKey);
185
+ }
186
+ /**
187
+ * 从父级删除该节点
188
+ * @internal
189
+ */
190
+ _delete() {
191
+ let params = null;
192
+ if (this.parentNode) {
193
+ params = this.parentNode?.__removeLogic?.(this);
194
+ }
195
+ return params;
196
+ }
197
+ /**
198
+ * 设置逻辑名称
199
+ */
200
+ setName(name) {
201
+ const object = {
202
+ name,
203
+ };
204
+ this.update({
205
+ ...object,
206
+ field: 'name',
207
+ });
208
+ }
209
+ /**
210
+ * 设置逻辑标题
211
+ */
212
+ setTitle(title) {
213
+ const object = {
214
+ title,
215
+ };
216
+ this.update({
217
+ ...object,
218
+ });
219
+ }
220
+ /**
221
+ * 设置逻辑描述
222
+ */
223
+ setDescription(description) {
224
+ const object = {
225
+ description,
226
+ };
227
+ this.update({
228
+ ...object,
229
+ });
230
+ }
231
+ /**
232
+ * 设置触发方式
233
+ */
234
+ setTriggerType(triggerType) {
235
+ const object = {
236
+ triggerType,
237
+ };
238
+ this.update({
239
+ ...object,
240
+ });
241
+ }
242
+ /**
243
+ * 设置定时任务表达式
244
+ */
245
+ setCron(cron) {
246
+ const object = {
247
+ cron,
248
+ };
249
+ this.update({
250
+ ...object,
251
+ });
252
+ }
253
+ /**
254
+ * 设置是否可覆写
255
+ */
256
+ setOverridable(overridable) {
257
+ const object = {
258
+ overridable,
259
+ };
260
+ this.update({
261
+ ...object,
262
+ });
263
+ }
264
+ /**
265
+ * 设置事务
266
+ */
267
+ setTransactional(transactional) {
268
+ transactional._delete();
269
+ const relationOptions = { parentNode: this, parentKey: 'transactional' };
270
+ Object.assign(transactional, relationOptions);
271
+ const object = {
272
+ transactional,
273
+ };
274
+ this.update({
275
+ ...object,
276
+ });
277
+ }
278
+ getTypeParamExistingNames(excludedList = []) {
279
+ const excludedSet = new Set(excludedList);
280
+ return (this.typeParams || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
281
+ }
282
+ getTypeParamUniqueName(name = 'typeParam1') {
283
+ return utils.unique(name, this.getTypeParamExistingNames(), undefined, false);
284
+ }
285
+ _insertTypeParamAt(options, index) {
286
+ const typeParamOptions = {};
287
+ const relationOptions = { parentNode: this, parentKey: 'typeParams' };
288
+ let typeParam;
289
+ if (!options) {
290
+ typeParam = TypeParam__1.default.from({
291
+ ...typeParamOptions,
292
+ name: this.getTypeParamUniqueName(),
293
+ }, this, 'typeParams');
294
+ }
295
+ else if (typeof options === 'string') {
296
+ typeParam = TypeParam__1.default.from({
297
+ ...typeParamOptions,
298
+ name: options,
299
+ }, this, 'typeParams');
300
+ }
301
+ else if (options instanceof TypeParam__1.default) {
302
+ options.ensureDelete(); // 同一实例不支持多处存在
303
+ typeParam = options;
304
+ Object.assign(typeParam, relationOptions);
305
+ }
306
+ else {
307
+ typeParam = TypeParam__1.default.from({
308
+ ...typeParamOptions,
309
+ ...options,
310
+ }, this, 'typeParams');
311
+ }
312
+ this.typeParams.splice(index, 0, typeParam);
313
+ return typeParam;
314
+ }
315
+ insertTypeParamAt(options, index) {
316
+ const node = this._insertTypeParamAt(options, index);
317
+ node.create({
318
+ index,
319
+ parentNode: this,
320
+ parentKey: 'typeParams',
321
+ });
322
+ return node;
323
+ }
324
+ _addTypeParam(options) {
325
+ const index = this.typeParams.length;
326
+ return this._insertTypeParamAt(options, index);
327
+ }
328
+ addTypeParam(options) {
329
+ const node = this._addTypeParam(options);
330
+ const index = this.typeParams.indexOf(node);
331
+ node.create({
332
+ index,
333
+ parentNode: this,
334
+ parentKey: 'typeParams',
335
+ });
336
+ return node;
337
+ }
338
+ getParamUniqueName(name = 'param1') {
339
+ return utils.unique(name, this.getVarExistingNames(), undefined, false);
340
+ }
341
+ _insertParamAt(options, index) {
342
+ const paramOptions = {};
343
+ const relationOptions = { parentNode: this, parentKey: 'params' };
344
+ let param;
345
+ if (!options) {
346
+ param = Param__1.default.from({
347
+ ...paramOptions,
348
+ name: this.getParamUniqueName(),
349
+ }, this, 'params');
350
+ }
351
+ else if (typeof options === 'string') {
352
+ param = Param__1.default.from({
353
+ ...paramOptions,
354
+ name: options,
355
+ }, this, 'params');
356
+ }
357
+ else if (options instanceof Param__1.default) {
358
+ options.ensureDelete(); // 同一实例不支持多处存在
359
+ param = options;
360
+ Object.assign(param, relationOptions);
361
+ }
362
+ else {
363
+ param = Param__1.default.from({
364
+ ...paramOptions,
365
+ ...options,
366
+ }, this, 'params');
367
+ }
368
+ this.params.splice(index, 0, param);
369
+ return param;
370
+ }
371
+ insertParamAt(options, index) {
372
+ const node = this._insertParamAt(options, index);
373
+ node.create({
374
+ index,
375
+ parentNode: this,
376
+ parentKey: 'params',
377
+ });
378
+ return node;
379
+ }
380
+ _addParam(options) {
381
+ const index = this.params.length;
382
+ return this._insertParamAt(options, index);
383
+ }
384
+ addParam(options) {
385
+ const node = this._addParam(options);
386
+ const index = this.params.indexOf(node);
387
+ node.create({
388
+ index,
389
+ parentNode: this,
390
+ parentKey: 'params',
391
+ });
392
+ return node;
393
+ }
394
+ getReturnUniqueName(name = 'result') {
395
+ return utils.unique(name, this.getVarExistingNames(), undefined, false);
396
+ }
397
+ _insertReturnAt(options, index) {
398
+ const retOptions = {};
399
+ const relationOptions = { parentNode: this, parentKey: 'returns' };
400
+ let ret;
401
+ if (!options) {
402
+ ret = Return__1.default.from({
403
+ ...retOptions,
404
+ name: this.getReturnUniqueName(),
405
+ }, this, 'returns');
406
+ }
407
+ else if (typeof options === 'string') {
408
+ ret = Return__1.default.from({
409
+ ...retOptions,
410
+ name: options,
411
+ }, this, 'returns');
412
+ }
413
+ else if (options instanceof Return__1.default) {
414
+ options.ensureDelete(); // 同一实例不支持多处存在
415
+ ret = options;
416
+ Object.assign(ret, relationOptions);
417
+ }
418
+ else {
419
+ ret = Return__1.default.from({
420
+ ...retOptions,
421
+ ...options,
422
+ }, this, 'returns');
423
+ }
424
+ this.returns.splice(index, 0, ret);
425
+ return ret;
426
+ }
427
+ insertReturnAt(options, index) {
428
+ const node = this._insertReturnAt(options, index);
429
+ node.create({
430
+ index,
431
+ parentNode: this,
432
+ parentKey: 'returns',
433
+ });
434
+ return node;
435
+ }
436
+ _addReturn(options) {
437
+ const index = this.returns.length;
438
+ return this._insertReturnAt(options, index);
439
+ }
440
+ addReturn(options) {
441
+ const node = this._addReturn(options);
442
+ const index = this.returns.indexOf(node);
443
+ node.create({
444
+ index,
445
+ parentNode: this,
446
+ parentKey: 'returns',
447
+ });
448
+ return node;
449
+ }
450
+ getVariableUniqueName(name = 'variable1') {
451
+ return utils.unique(name, this.getVarExistingNames(), undefined, false);
452
+ }
453
+ _insertVariableAt(options, index) {
454
+ const variableOptions = {};
455
+ const relationOptions = { parentNode: this, parentKey: 'variables' };
456
+ let variable;
457
+ if (!options) {
458
+ variable = Variable__1.default.from({
459
+ ...variableOptions,
460
+ name: this.getVariableUniqueName(),
461
+ }, this, 'variables');
462
+ }
463
+ else if (typeof options === 'string') {
464
+ variable = Variable__1.default.from({
465
+ ...variableOptions,
466
+ name: options,
467
+ }, this, 'variables');
468
+ }
469
+ else if (options instanceof Variable__1.default) {
470
+ options.ensureDelete(); // 同一实例不支持多处存在
471
+ variable = options;
472
+ Object.assign(variable, relationOptions);
473
+ }
474
+ else {
475
+ variable = Variable__1.default.from({
476
+ ...variableOptions,
477
+ ...options,
478
+ }, this, 'variables');
479
+ }
480
+ this.variables.splice(index, 0, variable);
481
+ return variable;
482
+ }
483
+ insertVariableAt(options, index) {
484
+ const node = this._insertVariableAt(options, index);
485
+ node.create({
486
+ index,
487
+ parentNode: this,
488
+ parentKey: 'variables',
489
+ });
490
+ return node;
491
+ }
492
+ _addVariable(options) {
493
+ const index = this.variables.length;
494
+ return this._insertVariableAt(options, index);
495
+ }
496
+ addVariable(options) {
497
+ const node = this._addVariable(options);
498
+ const index = this.variables.indexOf(node);
499
+ node.create({
500
+ index,
501
+ parentNode: this,
502
+ parentKey: 'variables',
503
+ });
504
+ return node;
505
+ }
506
+ _insertItemInBodyAt(options, index) {
507
+ const logicItemOptions = {};
508
+ const relationOptions = { parentNode: this, parentKey: 'body' };
509
+ let logicItem;
510
+ if (options instanceof LogicItem__1.default) {
511
+ options.ensureDelete(); // 同一实例不支持多处存在
512
+ logicItem = options;
513
+ Object.assign(logicItem, relationOptions);
514
+ }
515
+ else {
516
+ logicItem = LogicItem__1.default.from({
517
+ ...logicItemOptions,
518
+ ...options,
519
+ }, this, 'body');
520
+ }
521
+ this.body.splice(index, 0, logicItem);
522
+ return logicItem;
523
+ }
524
+ insertItemInBodyAt(options, index) {
525
+ const node = this._insertItemInBodyAt(options, index);
526
+ node.create({
527
+ index,
528
+ parentNode: this,
529
+ parentKey: 'body',
530
+ });
531
+ return node;
532
+ }
533
+ _addItemInBody(options) {
534
+ const index = this.body.length;
535
+ return this._insertItemInBodyAt(options, index);
536
+ }
537
+ addItemInBody(options) {
538
+ const node = this._addItemInBody(options);
539
+ const index = this.body.indexOf(node);
540
+ node.create({
541
+ index,
542
+ parentNode: this,
543
+ parentKey: 'body',
544
+ });
545
+ return node;
546
+ }
547
+ _insertItemInPlaygroundAt(options, index) {
548
+ const logicItemOptions = {};
549
+ const relationOptions = { parentNode: this, parentKey: 'playground' };
550
+ let logicItem;
551
+ if (options instanceof LogicItem__1.default) {
552
+ options.ensureDelete(); // 同一实例不支持多处存在
553
+ logicItem = options;
554
+ Object.assign(logicItem, relationOptions);
555
+ }
556
+ else {
557
+ logicItem = LogicItem__1.default.from({
558
+ ...logicItemOptions,
559
+ ...options,
560
+ }, this, 'playground');
561
+ }
562
+ this.playground.splice(index, 0, logicItem);
563
+ return logicItem;
564
+ }
565
+ insertItemInPlaygroundAt(options, index) {
566
+ const node = this._insertItemInPlaygroundAt(options, index);
567
+ node.create({
568
+ index,
569
+ parentNode: this,
570
+ parentKey: 'playground',
571
+ });
572
+ return node;
573
+ }
574
+ _addItemInPlayground(options) {
575
+ const index = this.playground.length;
576
+ return this._insertItemInPlaygroundAt(options, index);
577
+ }
578
+ addItemInPlayground(options) {
579
+ const node = this._addItemInPlayground(options);
580
+ const index = this.playground.indexOf(node);
581
+ node.create({
582
+ index,
583
+ parentNode: this,
584
+ parentKey: 'playground',
585
+ });
586
+ return node;
587
+ }
588
+ removeTransactional(options) {
589
+ let transactional;
590
+ if (typeof options === 'string') {
591
+ transactional = this.transactional;
592
+ if (!transactional) {
593
+ throw new Error('找不到事务 ' + options);
594
+ }
595
+ }
596
+ else {
597
+ transactional = options;
598
+ }
599
+ return transactional.delete();
600
+ }
601
+ __removeTransactional(transactional) {
602
+ const parentKey = transactional.parentKey;
603
+ const params = {
604
+ parentNode: this,
605
+ parentKey,
606
+ index: -1,
607
+ object: null,
608
+ oldObject: transactional,
609
+ };
610
+ if (parentKey) {
611
+ params.parentKey = parentKey;
612
+ // @ts-ignore
613
+ const t = this.__v_raw || this;
614
+ // @ts-ignore
615
+ const n = transactional.__v_raw || transactional;
616
+ if (Array.isArray(t[parentKey])) {
617
+ // @ts-ignore
618
+ const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
619
+ ~index && this[parentKey].splice(index, 1);
620
+ params.index = index;
621
+ }
622
+ else if (t[parentKey] === n) {
623
+ params.index = 0;
624
+ this[parentKey] = undefined;
625
+ }
626
+ }
627
+ return params;
628
+ }
629
+ removeTypeParam(options) {
630
+ let typeParam;
631
+ if (typeof options === 'string') {
632
+ typeParam = this.typeParams.find((item) => item.name === options);
633
+ if (!typeParam) {
634
+ throw new Error('找不到类型参数 ' + options);
635
+ }
636
+ }
637
+ else {
638
+ typeParam = options;
639
+ }
640
+ return typeParam.delete();
641
+ }
642
+ __removeTypeParam(typeParam) {
643
+ const parentKey = typeParam.parentKey;
644
+ const params = {
645
+ parentNode: this,
646
+ parentKey,
647
+ index: -1,
648
+ object: null,
649
+ oldObject: typeParam,
650
+ };
651
+ if (parentKey) {
652
+ params.parentKey = parentKey;
653
+ // @ts-ignore
654
+ const t = this.__v_raw || this;
655
+ // @ts-ignore
656
+ const n = typeParam.__v_raw || typeParam;
657
+ if (Array.isArray(t[parentKey])) {
658
+ // @ts-ignore
659
+ const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
660
+ ~index && this[parentKey].splice(index, 1);
661
+ params.index = index;
662
+ }
663
+ else if (t[parentKey] === n) {
664
+ params.index = 0;
665
+ this[parentKey] = undefined;
666
+ }
667
+ }
668
+ return params;
669
+ }
670
+ removeParam(options) {
671
+ let param;
672
+ if (typeof options === 'string') {
673
+ param = this.params.find((item) => item.name === options);
674
+ if (!param) {
675
+ throw new Error('找不到输入参数 ' + options);
676
+ }
677
+ }
678
+ else {
679
+ param = options;
680
+ }
681
+ return param.delete();
682
+ }
683
+ __removeParam(param) {
684
+ const parentKey = param.parentKey;
685
+ const params = {
686
+ parentNode: this,
687
+ parentKey,
688
+ index: -1,
689
+ object: null,
690
+ oldObject: param,
691
+ };
692
+ if (parentKey) {
693
+ params.parentKey = parentKey;
694
+ // @ts-ignore
695
+ const t = this.__v_raw || this;
696
+ // @ts-ignore
697
+ const n = param.__v_raw || param;
698
+ if (Array.isArray(t[parentKey])) {
699
+ // @ts-ignore
700
+ const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
701
+ ~index && this[parentKey].splice(index, 1);
702
+ params.index = index;
703
+ }
704
+ else if (t[parentKey] === n) {
705
+ params.index = 0;
706
+ this[parentKey] = undefined;
707
+ }
708
+ }
709
+ return params;
710
+ }
711
+ removeReturn(options) {
712
+ let ret;
713
+ if (typeof options === 'string') {
714
+ ret = this.returns.find((item) => item.name === options);
715
+ if (!ret) {
716
+ throw new Error('找不到输出参数 ' + options);
717
+ }
718
+ }
719
+ else {
720
+ ret = options;
721
+ }
722
+ return ret.delete();
723
+ }
724
+ __removeReturn(ret) {
725
+ const parentKey = ret.parentKey;
726
+ const params = {
727
+ parentNode: this,
728
+ parentKey,
729
+ index: -1,
730
+ object: null,
731
+ oldObject: ret,
732
+ };
733
+ if (parentKey) {
734
+ params.parentKey = parentKey;
735
+ // @ts-ignore
736
+ const t = this.__v_raw || this;
737
+ // @ts-ignore
738
+ const n = ret.__v_raw || ret;
739
+ if (Array.isArray(t[parentKey])) {
740
+ // @ts-ignore
741
+ const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
742
+ ~index && this[parentKey].splice(index, 1);
743
+ params.index = index;
744
+ }
745
+ else if (t[parentKey] === n) {
746
+ params.index = 0;
747
+ this[parentKey] = undefined;
748
+ }
749
+ }
750
+ return params;
751
+ }
752
+ removeVariable(options) {
753
+ let variable;
754
+ if (typeof options === 'string') {
755
+ variable = this.variables.find((item) => item.name === options);
756
+ if (!variable) {
757
+ throw new Error('找不到变量 ' + options);
758
+ }
759
+ }
760
+ else {
761
+ variable = options;
762
+ }
763
+ return variable.delete();
764
+ }
765
+ __removeVariable(variable) {
766
+ const parentKey = variable.parentKey;
767
+ const params = {
768
+ parentNode: this,
769
+ parentKey,
770
+ index: -1,
771
+ object: null,
772
+ oldObject: variable,
773
+ };
774
+ if (parentKey) {
775
+ params.parentKey = parentKey;
776
+ // @ts-ignore
777
+ const t = this.__v_raw || this;
778
+ // @ts-ignore
779
+ const n = variable.__v_raw || variable;
780
+ if (Array.isArray(t[parentKey])) {
781
+ // @ts-ignore
782
+ const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
783
+ ~index && this[parentKey].splice(index, 1);
784
+ params.index = index;
785
+ }
786
+ else if (t[parentKey] === n) {
787
+ params.index = 0;
788
+ this[parentKey] = undefined;
789
+ }
790
+ }
791
+ return params;
792
+ }
793
+ removeItemInBody(options) {
794
+ let logicItem = options;
795
+ return logicItem.delete();
796
+ }
797
+ removeItemInPlayground(options) {
798
+ let logicItem = options;
799
+ return logicItem.delete();
800
+ }
801
+ __removeLogicItem(logicItem) {
802
+ const parentKey = logicItem.parentKey;
803
+ const params = {
804
+ parentNode: this,
805
+ parentKey,
806
+ index: -1,
807
+ object: null,
808
+ oldObject: logicItem,
809
+ };
810
+ if (parentKey) {
811
+ params.parentKey = parentKey;
812
+ // @ts-ignore
813
+ const t = this.__v_raw || this;
814
+ // @ts-ignore
815
+ const n = logicItem.__v_raw || logicItem;
816
+ if (Array.isArray(t[parentKey])) {
817
+ // @ts-ignore
818
+ const index = t[parentKey].findIndex((el) => (el.__v_raw || el) === n);
819
+ ~index && this[parentKey].splice(index, 1);
820
+ params.index = index;
821
+ }
822
+ else if (t[parentKey] === n) {
823
+ params.index = 0;
824
+ this[parentKey] = undefined;
825
+ }
826
+ }
827
+ return params;
828
+ }
829
+ //================================================================================
830
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
831
+ // 自动生成的代码已结束。下面可以手动编写。
832
+ //================================================================================
833
+ // 用于calllogic树中定位是那个logic,回显
834
+ get calleewholeKey() {
835
+ return `${this.getNamespace()}.${this.name}`;
836
+ }
837
+ // 设置定时任务
838
+ setCronAndTriggerType(cron, triggerType) {
839
+ const object = {
840
+ cron,
841
+ triggerType,
842
+ };
843
+ this.update({
844
+ ...object,
845
+ });
846
+ }
847
+ /**
848
+ * 创建的时候 打开事务 通过开关设置数据库事务
849
+ */
850
+ openTransactional(flag) {
851
+ if (flag) {
852
+ const transactional = new Transactional__1.default({
853
+ enabled: flag,
854
+ });
855
+ transactional._delete();
856
+ const relationOptions = { parentNode: this, parentKey: 'transactional' };
857
+ Object.assign(transactional, relationOptions);
858
+ this.transactional = transactional;
859
+ }
860
+ }
861
+ findLogicItemByConcept(concept) {
862
+ let result;
863
+ utils.traverse((current) => {
864
+ if (current.node.concept === concept)
865
+ return (result = current.node);
866
+ }, { node: this }, {
867
+ mode: 'anyObject',
868
+ excludedKeySet: this.JSON_EXCLUDED_KEYS,
869
+ });
870
+ return result;
871
+ }
872
+ onChange($event) {
873
+ this.emit('change', $event);
874
+ }
875
+ getVarExistingNames(excludedList = []) {
876
+ const excludedSet = new Set(excludedList);
877
+ const varList = [];
878
+ if (Array.isArray(this.params)) {
879
+ varList.push(...this.params);
880
+ }
881
+ if (Array.isArray(this.returns)) {
882
+ varList.push(...this.returns);
883
+ }
884
+ if (Array.isArray(this.variables)) {
885
+ varList.push(...this.variables);
886
+ }
887
+ if (this.view) {
888
+ // 页面下,变量名不可以跟逻辑名相同,会有js 翻译问题
889
+ varList.push(this);
890
+ if (Array.isArray(this.view.params)) {
891
+ varList.push(...this.view.params);
892
+ }
893
+ if (Array.isArray(this.view.variables)) {
894
+ varList.push(...this.view.variables);
895
+ }
896
+ }
897
+ this.traverseChildren((el) => {
898
+ if (el?.concept === 'ForEachStatement') {
899
+ if (el?.item) {
900
+ varList.push(el?.item);
901
+ }
902
+ if (el?.index) {
903
+ varList.push(el?.index);
904
+ }
905
+ }
906
+ });
907
+ return varList.filter((item) => !excludedSet.has(item)).map((item) => item?.name);
908
+ }
909
+ toJSContent(code, state) {
910
+ // params
911
+ if (Array.isArray(this.params)) {
912
+ this.params.forEach((param) => {
913
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}`;
914
+ code += param.toJS((0, translator_1.shiftState)(state, code, { inline: true }));
915
+ code += ';\n';
916
+ });
917
+ }
918
+ // variables
919
+ if (Array.isArray(this.variables)) {
920
+ this.variables.forEach((variable) => {
921
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
922
+ code += variable.toJS((0, translator_1.shiftState)(state, code, { inline: true }));
923
+ code += ';\n';
924
+ });
925
+ }
926
+ // returns
927
+ if (Array.isArray(this.returns)) {
928
+ this.returns.forEach((ret) => {
929
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
930
+ code += ret.toJS((0, translator_1.shiftState)(state, code, { inline: true }));
931
+ code += ';\n';
932
+ });
933
+ }
934
+ if (Array.isArray(this.body)) {
935
+ this.body.forEach((item) => {
936
+ code += item.toJS && item.toJS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
937
+ code += '\n';
938
+ });
939
+ }
940
+ return code;
941
+ }
942
+ toJS(state, type) {
943
+ let code = '';
944
+ if (type === 'IIFE') {
945
+ code += `await (async () => {\n`;
946
+ code = this.toJSContent(code, state);
947
+ code += `${(0, translator_1.indent)(state?.tabSize || 0)}})();\n`;
948
+ return code;
949
+ }
950
+ code += `async ${this.name} (`;
951
+ if (this.params?.length) {
952
+ this.params.forEach((param, index) => {
953
+ code += param.name;
954
+ if (index !== this.params.length - 1)
955
+ code += ', ';
956
+ });
957
+ }
958
+ code += ') {\n';
959
+ code = this.toJSContent(code, state);
960
+ code += `${(0, translator_1.indent)(state?.tabSize || 0)}}\n`;
961
+ return code;
962
+ }
963
+ toProcessService() {
964
+ return {
965
+ config: {
966
+ serviceType: 'micro',
967
+ },
968
+ url: {
969
+ method: 'POST',
970
+ path: this.getPath(),
971
+ },
972
+ };
973
+ }
974
+ toService() {
975
+ const { parentNode } = this;
976
+ const { concept, name: entityName } = parentNode || {};
977
+ const logicName = this.name;
978
+ let serviceType = 'micro';
979
+ let method = 'POST';
980
+ let path = `/api/lcplogics/${logicName}`;
981
+ if (concept === 'Module') {
982
+ path = `/api/${entityName.replace('-', '_')}/${logicName}`;
983
+ }
984
+ else if (concept === 'Namespace') {
985
+ serviceType = 'entity';
986
+ let entityPath = entityName.replace(/[A-Z]/g, (char, index) => {
987
+ const lowerChar = char.toLowerCase();
988
+ return index === 0 ? lowerChar : `-${lowerChar}`;
989
+ });
990
+ const dataSource = parentNode.getAncestor('DataSource');
991
+ // 默认数据源不动,其他数据源需要拼接数据源信息
992
+ if (dataSource && dataSource.name !== 'defaultDS') {
993
+ entityPath = `${dataSource.name}/${entityPath}`;
994
+ }
995
+ path = `/api/${entityPath}`;
996
+ switch (this.name) {
997
+ case 'get':
998
+ method = 'GET';
999
+ path = `/api/${entityPath}`;
1000
+ break;
1001
+ case 'create':
1002
+ method = 'POST';
1003
+ break;
1004
+ case 'update':
1005
+ method = 'PUT';
1006
+ break;
1007
+ case 'delete':
1008
+ method = 'DELETE';
1009
+ path = `/api/${entityPath}`;
1010
+ break;
1011
+ case 'createOrUpdate':
1012
+ method = 'POST';
1013
+ path = `/api/${entityPath}/createOrUpdate`;
1014
+ break;
1015
+ case 'updateBy':
1016
+ method = 'PUT';
1017
+ path = `/api/${entityPath}/by`;
1018
+ break;
1019
+ case 'deleteBy':
1020
+ method = 'DELETE';
1021
+ path = `/api/${entityPath}/by`;
1022
+ break;
1023
+ case 'batchCreate':
1024
+ method = 'POST';
1025
+ path = `/api/${entityPath}/batch`;
1026
+ break;
1027
+ case 'batchUpdate':
1028
+ method = 'PUT';
1029
+ path = `/api/${entityPath}/batch`;
1030
+ break;
1031
+ case 'batchDelete':
1032
+ method = 'DELETE';
1033
+ path = `/api/${entityPath}/batch`;
1034
+ break;
1035
+ case 'import':
1036
+ method = 'POST';
1037
+ path = `/api/${entityPath}/import`;
1038
+ break;
1039
+ default:
1040
+ break;
1041
+ }
1042
+ }
1043
+ return {
1044
+ config: {
1045
+ serviceType,
1046
+ },
1047
+ url: {
1048
+ method,
1049
+ path,
1050
+ },
1051
+ };
1052
+ }
1053
+ toEmbeddedTSInProcess(state, prependCode, noName, prefix) {
1054
+ let code = '';
1055
+ if (!prefix)
1056
+ code += `${noName ? '' : `${this.name}:`} function(`;
1057
+ else
1058
+ code += `function ${this.name}(`; // 加空格会导致无法查询到引用
1059
+ this.params.forEach((param, index) => {
1060
+ code += param.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }), null, true);
1061
+ if (index !== this.params.length - 1)
1062
+ code += ', ';
1063
+ });
1064
+ code += `) {\n`;
1065
+ code += prependCode || '';
1066
+ code += '\n';
1067
+ this.variables.forEach((variable) => {
1068
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1069
+ code += variable.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1070
+ code += ';\n';
1071
+ });
1072
+ this.returns.forEach((ret) => {
1073
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1074
+ code += ret.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1075
+ code += ';\n';
1076
+ });
1077
+ if (!this.body.length && this.returns.length) {
1078
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}return ${this.returns[0].name};\n`;
1079
+ }
1080
+ else {
1081
+ if (this.parentNode.type === 'ExclusiveGateway') {
1082
+ if (this.body.length <= 1) {
1083
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1084
+ code += 'const __LogicEmpty: any = null;';
1085
+ }
1086
+ }
1087
+ else if (this.body.length <= 2 &&
1088
+ !(this.parentNode instanceof Namespace__1.default) &&
1089
+ !(this.parentNode instanceof Process__1.default)) {
1090
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1091
+ code += `${(0, translator_1.indent)(state?.tabSize || 0 + 4)}const __LogicEmpty: any = null;`;
1092
+ }
1093
+ this.body.forEach((item) => {
1094
+ code += item.toEmbeddedTS && item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1095
+ code += ';\n';
1096
+ });
1097
+ }
1098
+ // 在body渲染完成之后把其余的节点放到下面
1099
+ this.playground.forEach((item) => {
1100
+ code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1101
+ code += '\n';
1102
+ });
1103
+ code += `${(0, translator_1.indent)(state?.tabSize || 0 + 4)}}`;
1104
+ code += '\n';
1105
+ return code;
1106
+ }
1107
+ toEmbeddedTSNoExport(state) {
1108
+ return this.toEmbeddedTS(state, 'noExport');
1109
+ }
1110
+ get tsName() {
1111
+ // 来自集成中心,且是连接内部的逻辑,则认为是编辑态的,需要加上后缀
1112
+ if (this.connector && this.integration) {
1113
+ return `${this.name}${constants_1.CUSTOM_CONNECTOR_EDITABLE_SUFFIX}`;
1114
+ }
1115
+ // 由于Logic name 已经是符合函数预期的,因此不再需要做格式化
1116
+ return this.name;
1117
+ }
1118
+ toEmbeddedTS(state, prefix, hideDefaultValue) {
1119
+ // 如果传了不要前缀那就为空, 要不用传进来的,要是都没有就默认导出
1120
+ let code = '';
1121
+ // 用来储存默认值翻译结构是__IDENTIFIER__或者__IDENTIFIER__()的节点
1122
+ const IDENTIFIERMAP = new Set();
1123
+ if (!prefix) {
1124
+ code += `export function ${this.tsName}`;
1125
+ }
1126
+ else if (prefix === 'noExport') {
1127
+ code += `function ${this.tsName}`;
1128
+ }
1129
+ else if (prefix === 'inObject') {
1130
+ code += `${this.tsName}`;
1131
+ }
1132
+ if (this.typeParams?.length) {
1133
+ code += '<';
1134
+ this.typeParams.forEach((typeParam, typeParamIndex) => {
1135
+ code += typeParam.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1136
+ if (typeParamIndex !== this.typeParams.length - 1)
1137
+ code += ', ';
1138
+ });
1139
+ code += '>';
1140
+ }
1141
+ // 有参数长度
1142
+ if (this.params.length) {
1143
+ code += '(';
1144
+ this.params.forEach((param, index) => {
1145
+ code += param.toEmbeddedTS((0, translator_1.shiftState)(state, code));
1146
+ if (index !== this.params.length - 1)
1147
+ code += ', ';
1148
+ });
1149
+ code += ')';
1150
+ }
1151
+ else {
1152
+ // 没有参数的
1153
+ code += '()';
1154
+ }
1155
+ // 需要类型推导的局部变量/返回值需要调整申明顺序
1156
+ const advanceMap = new Map();
1157
+ const needGetSourceMapOqlList = [];
1158
+ this.traverseChildren((el) => {
1159
+ if (el && (el instanceof BatchAssignment__1.default || (el instanceof Assignment__1.default && el.left?.name))) {
1160
+ if (el instanceof Assignment__1.default) {
1161
+ const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && el.left?.name === variable.name);
1162
+ if (advanceVar && !advanceMap.get(advanceVar)) {
1163
+ advanceMap.set(advanceVar, el);
1164
+ }
1165
+ const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && el.left?.name === ret.name);
1166
+ if (advanceRn && !advanceMap.get(advanceRn)) {
1167
+ advanceMap.set(advanceRn, el);
1168
+ }
1169
+ }
1170
+ else if (el instanceof BatchAssignment__1.default) {
1171
+ el.assignmentLines.forEach(({ leftIndex }) => {
1172
+ const leftCode = leftIndex.length === 1
1173
+ ? el.left.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }))
1174
+ : el.left.members[leftIndex[1]]?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1175
+ const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && leftCode === variable.name);
1176
+ if (advanceVar && !advanceMap.get(advanceVar)) {
1177
+ advanceMap.set(advanceVar, el);
1178
+ }
1179
+ const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && leftCode === ret.name);
1180
+ if (advanceRn && !advanceMap.get(advanceRn)) {
1181
+ advanceMap.set(advanceRn, el);
1182
+ }
1183
+ });
1184
+ }
1185
+ }
1186
+ // 如果有sql查询组件就需要把他们存起来
1187
+ if (el instanceof OqlQueryComponent__1.default) {
1188
+ if (!el.codeSourceMap) {
1189
+ needGetSourceMapOqlList.push(el.requestEmbeddedTS());
1190
+ }
1191
+ }
1192
+ });
1193
+ if (needGetSourceMapOqlList.length) {
1194
+ Promise.all(needGetSourceMapOqlList).then(() => {
1195
+ // 触发一下更新重新生成代码
1196
+ this.app?.naslServer?.embeddedTSEmitter.emit('change', {
1197
+ value: [
1198
+ {
1199
+ originEvent: {
1200
+ action: 'update',
1201
+ target: this,
1202
+ },
1203
+ },
1204
+ ],
1205
+ });
1206
+ });
1207
+ }
1208
+ // 兼容 return 没有类型情况
1209
+ if (this.returns.length && this.returns[0].typeAnnotation) {
1210
+ code += ': ';
1211
+ code += this.returns[0].typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1212
+ }
1213
+ code += '{\n';
1214
+ // 用于虚拟节点的查找引用
1215
+ this.virtualParams &&
1216
+ Array.isArray(this.virtualParams) &&
1217
+ this.virtualParams.forEach((param) => {
1218
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1219
+ code += param.toEmbeddedNameTS((0, translator_1.shiftState)(state, code, { inline: true }));
1220
+ code += '\n';
1221
+ });
1222
+ this.variables.forEach((variable) => {
1223
+ const ts = variable.defaultValue?.toEmbeddedTS();
1224
+ if (['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
1225
+ IDENTIFIERMAP.add(variable);
1226
+ }
1227
+ if (!advanceMap.get(variable)) {
1228
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1229
+ code += variable.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1230
+ code += ';\n';
1231
+ }
1232
+ });
1233
+ this.returns.forEach((ret) => {
1234
+ const ts = ret.defaultValue?.toEmbeddedTS();
1235
+ if (['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
1236
+ IDENTIFIERMAP.add(ret);
1237
+ }
1238
+ if (!advanceMap.get(ret)) {
1239
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1240
+ code += ret.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1241
+ code += ';\n';
1242
+ }
1243
+ });
1244
+ advanceMap.forEach((assignment, node) => {
1245
+ // 有默认值的用默认值来推导类型, 但是如果是__IDENTIFIER__或者__IDENTIFIER__(),就不需要默认值来推导了
1246
+ if (node.defaultValue?.expression && !IDENTIFIERMAP.has(node)) {
1247
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1248
+ code += node.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1249
+ return;
1250
+ }
1251
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}// @ts-ignore\n`;
1252
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}let `;
1253
+ code += node.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1254
+ if (assignment instanceof BatchAssignment__1.default) {
1255
+ assignment.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1256
+ const leftCode = leftIndex.length === 1
1257
+ ? assignment.left.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }))
1258
+ : assignment.left.members[leftIndex[1]]?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1259
+ if (leftCode === node.name) {
1260
+ const rightNode = rightIndex.length === 1
1261
+ ? assignment.rights[rightIndex[0]]?.expression
1262
+ : assignment.rights[rightIndex[0]]?.members[rightIndex[1]];
1263
+ // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1264
+ if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent__1.default && !rightNode.isAutoInfer())) {
1265
+ if (rightNode.concept === 'NewComposite' && rightNode.typeAnnotation?.typeKind === 'anonymousStructure') {
1266
+ code += '= ';
1267
+ code += rightNode.getInitCode((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
1268
+ }
1269
+ else if (rightNode.concept === 'NewComposite' && rightNode.typeAnnotation?.typeKind === 'generic') {
1270
+ code += '= ';
1271
+ code += rightNode.getNewCompositeCode((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
1272
+ }
1273
+ else {
1274
+ code += ': ';
1275
+ code += rightNode.typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
1276
+ }
1277
+ }
1278
+ else {
1279
+ code += ' = ';
1280
+ const rightCode = rightNode?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1281
+ code += this.getRightCode(rightCode, assignment, rightNode);
1282
+ }
1283
+ }
1284
+ });
1285
+ }
1286
+ else if (['NewList', 'NewMap'].includes(assignment.right?.concept) &&
1287
+ !assignment.right?.typeAnnotation) {
1288
+ const rightNode = assignment.right;
1289
+ code += ' = ';
1290
+ code += rightNode.getInitCode((0, translator_1.shiftState)(state, code, { inline: true }));
1291
+ }
1292
+ else if (assignment.right?.concept === 'NewComposite' &&
1293
+ assignment.right?.typeAnnotation?.typeKind === 'anonymousStructure') {
1294
+ const rightNode = assignment.right;
1295
+ code += ' = ';
1296
+ code += rightNode.getInitCode((0, translator_1.shiftState)(state, code, { inline: true }));
1297
+ }
1298
+ else if (assignment.right?.concept === 'NewComposite' &&
1299
+ assignment.right?.typeAnnotation?.typeKind === 'generic') {
1300
+ const rightNode = assignment.right;
1301
+ code += ' = ';
1302
+ code += rightNode.getNewCompositeCode((0, translator_1.shiftState)(state, code, { inline: true }));
1303
+ }
1304
+ else {
1305
+ const rightNode = assignment.right;
1306
+ // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1307
+ if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent__1.default && !rightNode.isAutoInfer())) {
1308
+ code += ': ';
1309
+ code += rightNode.typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
1310
+ }
1311
+ else {
1312
+ code += ' = ';
1313
+ let rightCode = '';
1314
+ // 因为右侧枚举要赋值就得new 一下;
1315
+ if (rightNode &&
1316
+ rightNode instanceof Identifier__1.default &&
1317
+ rightNode.namespace &&
1318
+ rightNode.namespace.endsWith('enums')) {
1319
+ rightCode += 'new ';
1320
+ }
1321
+ rightCode +=
1322
+ rightNode && rightNode.toEmbeddedTS
1323
+ ? rightNode.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }))
1324
+ : '__RIGHT__';
1325
+ code += this.getRightCode(rightCode, assignment, rightNode);
1326
+ }
1327
+ }
1328
+ code += ';\n';
1329
+ });
1330
+ // 参数的默认值是__IDENTIFIER__或者__IDENTIFIER__()时不赋默认值,但是需要ts翻译出来进行报错校验
1331
+ if (!hideDefaultValue) {
1332
+ IDENTIFIERMAP.forEach((node) => {
1333
+ code += node.defaultValue.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
1334
+ code += '; ';
1335
+ });
1336
+ code += '\n';
1337
+ }
1338
+ if (!this.body.length && this.returns.length) {
1339
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}return ${this.returns[0].name};\n`;
1340
+ }
1341
+ else {
1342
+ // 如果长度小于2 并且不是虚拟节点就 加 报错,
1343
+ if (this.body.length <= 2 && !(this.parentNode instanceof Namespace__1.default)) {
1344
+ if (this.body.length && this.body[0].concept === 'JavaLogic') {
1345
+ code += '';
1346
+ }
1347
+ else {
1348
+ code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
1349
+ code += 'const __LogicEmpty: any = null;';
1350
+ }
1351
+ }
1352
+ this.body.forEach((item) => {
1353
+ code += item.toEmbeddedTS && item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1354
+ code += ';\n';
1355
+ });
1356
+ }
1357
+ // 在body渲染完成之后把其余的节点放到下面
1358
+ this.playground.forEach((item) => {
1359
+ code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1360
+ code += ';\n';
1361
+ });
1362
+ if (!hideDefaultValue) {
1363
+ if (this.variables.length) {
1364
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}/* -----以下是variable的默认值草稿------ */\n`;
1365
+ }
1366
+ this.variables.forEach((variable) => {
1367
+ if (variable.defaultValue) {
1368
+ variable.defaultValue.playground?.forEach((item) => {
1369
+ code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1370
+ code += ';\n';
1371
+ });
1372
+ }
1373
+ });
1374
+ if (this.returns.length) {
1375
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}/* -----以下是returns的默认值草稿------ */\n`;
1376
+ }
1377
+ this.returns.forEach((return_) => {
1378
+ if (return_.defaultValue) {
1379
+ return_.defaultValue.playground?.forEach((item) => {
1380
+ code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1381
+ code += ';\n';
1382
+ });
1383
+ }
1384
+ });
1385
+ if (this.params.length) {
1386
+ code += `${(0, translator_1.indent)((state?.tabSize || 0) + 1)}/* -----以下是params的默认值草稿------ */\n`;
1387
+ }
1388
+ this.params.forEach((param) => {
1389
+ if (param.defaultValue) {
1390
+ param.defaultValue.playground?.forEach((item) => {
1391
+ code += item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1392
+ code += ';\n';
1393
+ });
1394
+ }
1395
+ });
1396
+ }
1397
+ code += `${(0, translator_1.indent)(state?.tabSize || 0)}}`;
1398
+ if (prefix === 'inObject') {
1399
+ code += `,`;
1400
+ }
1401
+ code += '\n';
1402
+ return code;
1403
+ }
1404
+ toNaturalTS(state = (0, translator_1.createCompilerState)(), prefix, logicName, currentNode) {
1405
+ // 如果传了不要前缀那就为空, 要不用传进来的,要是都没有就默认导出
1406
+ let code = '';
1407
+ if (currentNode === this) {
1390
1408
  code += `\n${(0, translator_1.indent)(state.tabSize)}/**
1391
1409
  ${(0, translator_1.indent)(state.tabSize)} * 当前逻辑
1392
- ${(0, translator_1.indent)(state.tabSize)} */\n`;
1393
- }
1394
- if (!logicName) {
1395
- const { name, parentNode } = this;
1396
- if (parentNode?.concept === 'View') {
1397
- logicName = `viewLogic_${name}`;
1398
- }
1399
- else if (parentNode?.concept === 'BindEvent') {
1400
- logicName = `on_${parentNode?.parentNode?.name}_${name}`;
1401
- }
1402
- else {
1403
- logicName = this.name;
1404
- }
1405
- }
1406
- if (!prefix) {
1407
- code += `${(0, translator_1.indent)(state.tabSize)}export ${currentNode !== this ? 'declare function' : 'function'} ${logicName}`;
1408
- }
1409
- else if (prefix === 'noExport') {
1410
- code += `${(0, translator_1.indent)(state.tabSize)}${currentNode !== this ? 'declare function' : 'function'} ${logicName}`;
1411
- }
1412
- else if (prefix === 'inObject') {
1413
- code += `${logicName}`;
1414
- }
1415
- if (this.typeParams?.length) {
1416
- code += '<';
1417
- this.typeParams.forEach((typeParam, typeParamIndex) => {
1418
- code += typeParam.toNaturalTS((0, translator_1.shiftState)(state, code, { inline: true }));
1419
- if (typeParamIndex !== this.typeParams.length - 1)
1420
- code += ', ';
1421
- });
1422
- code += '>';
1423
- }
1424
- // 有参数长度
1425
- code += '(';
1426
- this.params.forEach((param, index) => {
1427
- code += param.toNaturalTS((0, translator_1.shiftState)(state, code, { inline: true }));
1428
- if (index !== this.params.length - 1)
1429
- code += ', ';
1430
- });
1431
- code += ')';
1432
- // 需要类型推导的局部变量/返回值需要调整申明顺序
1433
- const advanceMap = new Map();
1434
- this.traverseChildren((el) => {
1435
- if (el && (el instanceof BatchAssignment__1.default || (el instanceof Assignment__1.default && el.left?.name))) {
1436
- const jsCode = el.toJS();
1437
- const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && jsCode.includes(`${variable.name} = `));
1438
- if (advanceVar && !advanceMap.get(advanceVar)) {
1439
- advanceMap.set(advanceVar, el);
1440
- }
1441
- const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && jsCode.includes(`${ret.name} = `));
1442
- if (advanceRn && !advanceMap.get(advanceRn)) {
1443
- advanceMap.set(advanceRn, el);
1444
- }
1445
- }
1446
- });
1447
- // 兼容 return 没有类型情况
1448
- if (this.returns.length && this.returns[0].typeAnnotation) {
1449
- code += ': ';
1450
- code += this.returns[0].typeAnnotation?.toNaturalTS((0, translator_1.shiftState)(state, code, { inline: true }));
1451
- }
1452
- if (currentNode !== this) {
1453
- code += ';';
1454
- }
1455
- else {
1456
- code += ' {\n';
1457
- this.variables.forEach((variable) => {
1458
- code += `${(0, translator_1.indent)(state.tabSize + 1)}let `;
1459
- code += variable.toNaturalTS((0, translator_1.shiftState)(state, code, { inline: true }));
1460
- code += ';\n';
1461
- });
1462
- this.returns.forEach((ret) => {
1463
- code += `${(0, translator_1.indent)(state.tabSize + 1)}let `;
1464
- code += ret.toNaturalTS((0, translator_1.shiftState)(state, code, { inline: true }));
1465
- code += ';\n';
1466
- });
1467
- code += `${(0, translator_1.indent)(state.tabSize + 1)}// 当前位置\n`;
1468
- if (!this.body.length && this.returns.length) {
1469
- code += `${(0, translator_1.indent)(state.tabSize + 1)}return ${this.returns[0].name};\n`;
1470
- }
1471
- else {
1472
- this.body.forEach((item) => {
1473
- let partialCode = '';
1474
- if (item.toNaturalTS) {
1475
- partialCode = item.toNaturalTS((0, translator_1.shiftState)(state, code, { tabSize: state.tabSize + 1 }));
1476
- }
1477
- else if (item.toEmbeddedTS) {
1478
- partialCode = item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: state.tabSize + 1 }));
1479
- }
1480
- if (partialCode.trim()) {
1481
- code += partialCode;
1482
- code += '\n';
1483
- }
1484
- });
1485
- }
1486
- code += `${(0, translator_1.indent)(state.tabSize)}}`;
1487
- }
1488
- if (prefix === 'inObject') {
1489
- code += `,`;
1490
- }
1491
- code += '\n';
1492
- return code;
1493
- }
1494
- getRightCode(code, assignment, rightNode) {
1495
- code = code.replaceAll('\n', ' ');
1496
- if (assignment instanceof Assignment__1.default && !assignment.right)
1497
- return code;
1498
- // 调用接口,参数替换成 null
1499
- if (rightNode instanceof CallInterface__1.default) {
1500
- const { _interface } = rightNode.getModuleInterface();
1501
- return _interface ? `${rightNode.tsCalleeKey}(${_interface.params.map(() => 'null').join(',')})` : null;
1502
- }
1503
- // 调用服务端逻辑,参数替换成 null
1504
- if (rightNode instanceof CallLogic__1.default && rightNode.calleeNamespace === 'app.logics') {
1505
- const calleeName = rightNode?.calleeName;
1506
- const calleeLogic = this.app.logics.find((l) => l.name === calleeName);
1507
- return calleeLogic ? `app.logics.${calleeName}(${calleeLogic.params.map(() => 'null').join(',')})` : null;
1508
- }
1509
- // ForEachStatement 内部变量需要替换处理,如 item、index
1510
- const forEachStatement = assignment.getAncestor('ForEachStatement');
1511
- if (forEachStatement) {
1512
- code = this.handleForEachCode(code, forEachStatement);
1513
- }
1514
- // Match 需要针对分支缩小类型范围
1515
- const matchCase = assignment.getAncestor('MatchCase');
1516
- if (matchCase) {
1517
- code = this.handleMatchCaseCode(code, matchCase);
1518
- }
1519
- return code;
1520
- }
1521
- handleReplaceCode(code, variable, replaceCode) {
1522
- return code.replace(/\S+/g, ($1) => {
1523
- if ($1 === `${variable},`)
1524
- return `${replaceCode},`;
1525
- if ($1 === variable)
1526
- return replaceCode;
1527
- let fnCode = $1;
1528
- if ($1.startsWith(`${variable}.`))
1529
- fnCode = $1.replaceAll(`${variable}.`, `${replaceCode}.`);
1530
- if ($1.startsWith(`${variable},`))
1531
- fnCode = $1.replaceAll(`${variable},`, `${replaceCode},`);
1532
- if ($1.includes(`(${variable},`))
1533
- fnCode = $1.replaceAll(`(${variable},`, `(${replaceCode},`);
1534
- if ($1.includes(`(${variable}.`))
1535
- fnCode = $1.replaceAll(`(${variable}.`, `(${replaceCode}.`);
1536
- if ($1.includes(`(${variable})`))
1537
- fnCode = $1.replaceAll(`(${variable})`, `(${replaceCode})`);
1538
- if ($1.includes(`,${variable},`))
1539
- fnCode = $1.replaceAll(`,${variable},`, `,${replaceCode},`);
1540
- if ($1.includes(`,${variable}.`))
1541
- fnCode = $1.replaceAll(`,${variable}.`, `,${replaceCode}.`);
1542
- if ($1.includes(`,${variable})`))
1543
- fnCode = $1.replaceAll(`,${variable})`, `,${replaceCode})`);
1544
- return fnCode;
1545
- });
1546
- }
1547
- handleForEachCode(code, forEachStatement) {
1548
- const { item, index, each } = forEachStatement;
1549
- if (code.includes(item.name)) {
1550
- const eachTSCode = each ? each.toEmbeddedTS() : '__IDENTIFIER__';
1551
- code = this.handleReplaceCode(code, item.name, eachTSCode === '__IDENTIFIER__' ? eachTSCode : `${eachTSCode}.__get(0)`);
1552
- }
1553
- if (code.includes(index.name))
1554
- code = this.handleReplaceCode(code, index.name, 'new nasl.core.Long(0)');
1555
- const parentForEachStatement = forEachStatement.getAncestor('ForEachStatement');
1556
- if (parentForEachStatement) {
1557
- this.handleForEachCode(code, parentForEachStatement);
1558
- }
1559
- return code;
1560
- }
1561
- handleMatchCaseCode(code, matchCase) {
1562
- const match = matchCase.getAncestor('Match');
1563
- const expressionTsCode = match.expression.toEmbeddedTS();
1564
- if (code.includes(expressionTsCode)) {
1565
- let typeCode = '';
1566
- matchCase.patterns.forEach((pattern, index) => {
1567
- if (pattern instanceof TypeAnnotation__1.default) {
1568
- if (index === 0) {
1569
- typeCode += pattern.toEmbeddedTS();
1570
- }
1571
- else {
1572
- typeCode += '|';
1573
- typeCode += pattern.toEmbeddedTS();
1574
- }
1575
- }
1576
- });
1577
- if (typeCode) {
1578
- code = this.handleReplaceCode(code, expressionTsCode, `(${expressionTsCode} as ${typeCode})`);
1579
- }
1580
- }
1581
- const parentMatchCase = match.getAncestor('MatchCase');
1582
- if (parentMatchCase) {
1583
- code = this.handleMatchCaseCode(code, parentMatchCase);
1584
- }
1585
- return code;
1586
- }
1587
- getNamespace() {
1588
- if (this.parentNode) {
1589
- const parentNamespace = this.parentNode?.getNamespace();
1590
- // 针对Connector, 其对应的引入入口只有连接器。且唯一标识由
1591
- // calleeName、calleeNamespace 两个字段组合确认,
1592
- // 故这里只返回 Connector 对应的nameSpace 且 俩字段组合默认会含带logic 字段
1593
- // 因此最后 CallConnector 的 calleewholeKey 为 : `${calleeNamespace}.logics.${calleeName}`
1594
- if (this.parentNode.concept === 'Connector') {
1595
- return parentNamespace;
1596
- }
1597
- const parentName = this.parentNode.name;
1598
- // 自定义连接器,增加了分组概念,故需要额外扩展一层namespace
1599
- const connector = this.getAncestor('Connector');
1600
- if (connector && connector.connectorKind === 'app') {
1601
- return `${parentNamespace}.${parentName}`;
1602
- }
1603
- const arr = [parentNamespace];
1604
- if (this.parentNode.concept !== 'App' && parentName) {
1605
- arr.push(parentName);
1606
- }
1607
- let namespace = arr.join('.');
1608
- if (![
1609
- 'nasl.ui',
1610
- 'nasl.utils',
1611
- 'nasl.util',
1612
- 'nasl.browser',
1613
- 'nasl.auth',
1614
- 'nasl.configuration',
1615
- 'nasl.process',
1616
- 'nasl.logging',
1617
- 'nasl.io',
1618
- 'nasl.event',
1619
- ].includes(namespace) &&
1620
- !namespace.includes('.logics')) {
1621
- namespace = `${namespace}.logics`;
1622
- }
1623
- return namespace;
1624
- }
1625
- throw new Error('无法获取命名空间,请设置 parentNode!');
1626
- }
1627
- getTsNamespace() {
1628
- if (this.parentNode) {
1629
- const parentNamespace = this.parentNode?.getTsNamespace();
1630
- // 对于parent类型为Namespace的情况,getTsNamespace 已经返回了具体的 name,
1631
- // 为什么下文还要重新获取???
1632
- const parentName = this.parentNode.tsName || this.parentNode.name;
1633
- const arr = [parentNamespace];
1634
- if (this.parentNode.concept !== 'App' && parentName) {
1635
- arr.push(parentName);
1636
- }
1637
- let namespace = arr.join('.');
1638
- if (![
1639
- 'nasl.ui',
1640
- 'nasl.utils',
1641
- 'nasl.util',
1642
- 'nasl.browser',
1643
- 'nasl.auth',
1644
- 'nasl.configuration',
1645
- 'nasl.process',
1646
- 'nasl.logging',
1647
- 'nasl.io',
1648
- ].includes(namespace) &&
1649
- !namespace.includes('.logics')) {
1650
- namespace = `${namespace}.logics`;
1651
- }
1652
- return namespace;
1653
- }
1654
- throw new Error('无法获取命名空间,请设置 parentNode!');
1655
- }
1656
- /**
1657
- * 生成宿主语言的文件路径
1658
- * @param name 一般不用传,用于 rename
1659
- */
1660
- getEmbeddedFilePath(name = this.name) {
1661
- let _path = '';
1662
- if (this.module) {
1663
- _path = `/${this.module.parentKey}/${this.module.name}`;
1664
- }
1665
- else if (this.connector) {
1666
- // 自定义连接器有分组的概念因此,需要做文件夹处理
1667
- if (this.connector.connectorKind === 'app') {
1668
- _path = `/${this.connector.parentKey}/${this.connector.name}/${this.parentNode.name}`;
1669
- }
1670
- else {
1671
- _path = `/${this.connector.parentKey}/${this.connector.name}`;
1672
- }
1673
- }
1674
- if (this.parentNode instanceof FrontendLibrary__1.FrontendLibrary) {
1675
- _path += `/frontends/${this.parentNode.type}`;
1676
- }
1677
- else if (this.parentNode.concept === 'BindEvent' && this.parentNode?.parentNode.concept === 'Frontend') {
1678
- _path += `/frontends/${this.parentNode.parentNode.name}/bindEvents/${name}.ts`;
1679
- }
1680
- return `/embedded/${this.app.name}${_path}/logics/${name}.ts`;
1681
- }
1682
- toEmbeddedTSFile() {
1683
- let code = `namespace ${this.getTsNamespace()} {\n`;
1684
- const state = (0, translator_1.createCompilerState)(code, { tabSize: 1 });
1685
- try {
1686
- code += this.toEmbeddedTS(state);
1687
- }
1688
- catch (err) {
1689
- console.log(err, `有问题翻译失败:${this.getTsNamespace()}.${this.name}`);
1690
- code += '';
1691
- console.log(err);
1692
- }
1693
- code += '}\n';
1694
- return {
1695
- code,
1696
- filePath: this.getEmbeddedFilePath(),
1697
- sourceMap: state.sourceMap,
1698
- };
1699
- }
1700
- static getDefaultOptions() {
1701
- return {
1702
- body: [
1703
- {
1704
- concept: 'Start',
1705
- label: '开始',
1706
- kind: 'Statement',
1707
- type: 'Start',
1708
- },
1709
- {
1710
- concept: 'End',
1711
- label: '结束',
1712
- kind: 'Statement',
1713
- type: 'End',
1714
- },
1715
- ],
1716
- };
1717
- }
1718
- async saveStructureOfCallQueryComponents(root) {
1719
- if (!root)
1720
- root = this;
1721
- const set = new Set();
1722
- utils.traverse(({ node }) => {
1723
- if (node instanceof CallQueryComponent__1.default) {
1724
- set.add(node);
1725
- }
1726
- }, { node: root }, {
1727
- mode: 'anyObject',
1728
- excludedKeySet: new Set(['parentNode', '__assignment__']),
1729
- });
1730
- for (const node of set) {
1731
- node.saveStructure();
1732
- }
1733
- }
1734
- // 通过开关设置数据库事务
1735
- setTransactionEnabled(flag) {
1736
- this.setTransactional(new Transactional__1.default({
1737
- enabled: flag,
1738
- }));
1739
- }
1740
- fake;
1741
- getPath;
1742
- delete() {
1743
- let actionMsg = '删除逻辑项';
1744
- if (this.name)
1745
- actionMsg += `“${this.name}”`;
1746
- this.app?.emit('logicDeleted', { actionMsg: this.nodePath });
1747
- this.app?.emit('collect:start', {
1748
- actionMsg,
1749
- });
1750
- super.delete();
1751
- this.traverseChildren(async (el) => {
1752
- if (el?.concept === 'CallQueryComponent')
1753
- el.removeStructure();
1754
- // 仅仅针对 自定义连接器下的 Loigc,其他需要界定边界
1755
- const connector = el?.getAncestor?.('Connector');
1756
- if (['CallAuthInterface', 'CallInterface'].includes(el?.concept) && connector) {
1757
- const { calleeName } = el;
1758
- const targetInterface = connector.interfaces.find((i) => i.name === calleeName);
1759
- if (targetInterface) {
1760
- const refs = await this.app?.naslServer?._isHaveRef(targetInterface);
1761
- // 如果只有两个引用,则必然为自身以及当前logic引用,需要删除此接口
1762
- if (refs?.length <= 2) {
1763
- targetInterface.deleteInterface();
1764
- }
1765
- }
1766
- }
1767
- });
1768
- this.app?.emit('collect:end');
1769
- }
1770
- // 是不是内部有错误
1771
- haveError = false;
1772
- // 是否body为空
1773
- isSmpty = false;
1774
- get exportInterface() {
1775
- return this.rootNode?.interfaces?.find((item) => item.originLogicName === this.name);
1776
- }
1777
- get pathName() {
1778
- if (this.view) {
1779
- return this.getEventLogicName('chinese');
1780
- }
1781
- let { parentNode } = this;
1782
- if (parentNode.concept === 'BindEvent' && parentNode.parentNode.concept === 'Frontend') {
1783
- const frontEndEventNameMap = {
1784
- rendered: '应用进入后',
1785
- preRequest: '调用服务端逻辑前',
1786
- postRequest: '调用服务端逻辑后',
1787
- beforeRouter: '页面切换前',
1788
- afterRouter: '页面切换后',
1789
- };
1790
- const pathName = [this.name];
1791
- while (parentNode && parentNode.concept !== 'Frontend') {
1792
- const name = frontEndEventNameMap[parentNode.name] || parentNode.name;
1793
- pathName.unshift(name);
1794
- parentNode = parentNode.parentNode;
1795
- }
1796
- return pathName.join('-');
1797
- }
1798
- const nameMap = {
1799
- OnProcessStart: '流程开始时',
1800
- OnTasksCreate: '任务创建时',
1801
- OnTasksOpen: '任务打开时',
1802
- OnTasksClose: '任务关闭时',
1803
- OnCreate: '用户任务创建时',
1804
- OnOpen: '用户任务打开时',
1805
- OnClose: '用户任务关闭时',
1806
- };
1807
- const pathName = [this.name];
1808
- parentNode = this.parentNode;
1809
- while (parentNode && parentNode.concept !== 'Process') {
1810
- const name = nameMap[parentNode.name] || parentNode.name;
1811
- pathName.unshift(name);
1812
- parentNode = parentNode.parentNode;
1813
- }
1814
- return pathName.join('-');
1815
- }
1816
- // 获取bindEvent下的logic的名称
1817
- getEventLogicName(type) {
1818
- if (this.parentNode instanceof BindEvent__1.default) {
1819
- if (type === 'chinese') {
1820
- const bindEvent = this.parentNode;
1821
- const bindChineseName = bindEvent.getPageViewEventChineseName();
1822
- return `${bindChineseName} -${this.name} `;
1823
- }
1824
- }
1825
- return this.name;
1826
- }
1827
- // 虚拟输入参数列表
1828
- virtualParams = [];
1829
- get getLogicBelongTo() {
1830
- const [, belongTo] = this.calleewholeKey.split('.');
1831
- return belongTo;
1832
- }
1833
- // 校验logic的返回值是不是有error类型
1834
- static checkLogicReturnTypeHasError(logic) {
1835
- let findHasError = false;
1836
- if (!logic) {
1837
- return findHasError;
1838
- }
1839
- if (logic.returns?.length && logic.returns[0]?.typeAnnotation) {
1840
- // 如果新导入的logic还有Error类型
1841
- const logicType = logic.returns[0].typeAnnotation;
1842
- if (logicType.typeNamespace === 'nasl.ui' && logicType.typeName === 'Error') {
1843
- findHasError = true;
1844
- }
1845
- else if (logicType.typeNamespace === 'nasl.core' && logicType.typeKind === 'union') {
1846
- // 如果 logic returns 而且,也有typeArguments的长度
1847
- findHasError = Boolean(logicType.typeArguments?.find((item) => item?.typeNamespace === 'nasl.ui' && item?.typeName === 'Error'));
1848
- }
1849
- }
1850
- return findHasError;
1851
- }
1852
- };
1853
- exports.Logic = Logic;
1854
- __decorate([
1855
- (0, decorators_1.property)('concept')
1856
- // @ts-ignore
1857
- ], Logic.prototype, "concept", void 0);
1858
- __decorate([
1859
- (0, decorators_1.property)()
1860
- // @ts-ignore
1861
- ], Logic.prototype, "name", void 0);
1862
- __decorate([
1863
- (0, decorators_1.property)()
1864
- // @ts-ignore
1865
- ], Logic.prototype, "title", void 0);
1866
- __decorate([
1867
- (0, decorators_1.property)()
1868
- // @ts-ignore
1869
- ], Logic.prototype, "description", void 0);
1870
- __decorate([
1871
- (0, decorators_1.property)()
1872
- // @ts-ignore
1873
- ], Logic.prototype, "triggerType", void 0);
1874
- __decorate([
1875
- (0, decorators_1.property)()
1876
- // @ts-ignore
1877
- ], Logic.prototype, "cron", void 0);
1878
- __decorate([
1879
- (0, decorators_1.property)()
1880
- // @ts-ignore
1881
- ], Logic.prototype, "overridable", void 0);
1882
- __decorate([
1883
- (0, decorators_1.property)({
1884
- objectRef: 'Transactional',
1885
- })
1886
- // @ts-ignore
1887
- ], Logic.prototype, "transactional", void 0);
1888
- __decorate([
1889
- (0, decorators_1.property)({
1890
- objectRef: 'TypeParam',
1891
- isArray: true,
1892
- defaultValue: null,
1893
- })
1894
- ], Logic.prototype, "typeParams", void 0);
1895
- __decorate([
1896
- (0, decorators_1.property)({
1897
- objectRef: 'Param',
1898
- isArray: true,
1899
- defaultValue: [],
1900
- })
1901
- ], Logic.prototype, "params", void 0);
1902
- __decorate([
1903
- (0, decorators_1.property)({
1904
- objectRef: 'Return',
1905
- isArray: true,
1906
- defaultValue: [],
1907
- })
1908
- ], Logic.prototype, "returns", void 0);
1909
- __decorate([
1910
- (0, decorators_1.property)({
1911
- objectRef: 'Variable',
1912
- isArray: true,
1913
- defaultValue: [],
1914
- })
1915
- ], Logic.prototype, "variables", void 0);
1916
- __decorate([
1917
- (0, decorators_1.property)({
1918
- objectRef: 'LogicItem',
1919
- isArray: true,
1920
- defaultValue: [],
1921
- })
1922
- ], Logic.prototype, "body", void 0);
1923
- __decorate([
1924
- (0, decorators_1.property)({
1925
- objectRef: 'LogicItem',
1926
- isArray: true,
1927
- defaultValue: [],
1928
- })
1929
- ], Logic.prototype, "playground", void 0);
1930
- __decorate([
1931
- (0, translator_1.withSourceMap)()
1932
- ], Logic.prototype, "toEmbeddedTSInProcess", null);
1933
- __decorate([
1934
- (0, translator_1.withSourceMap)()
1935
- ], Logic.prototype, "toEmbeddedTS", null);
1936
- __decorate([
1937
- (0, translator_1.withSourceMap)()
1938
- ], Logic.prototype, "toNaturalTS", null);
1939
- exports.Logic = Logic = Logic_1 = __decorate([
1940
- decorators_1.className,
1941
- (0, decorators_1.concept)('逻辑')
1942
- // @ts-ignore
1943
- ], Logic);
1944
- exports.default = Logic;
1945
- //================================================================================
1946
- // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1947
- // 自动生成的代码已结束。下面可以手动编写。
1948
- //================================================================================
1410
+ ${(0, translator_1.indent)(state.tabSize)} */\n`;
1411
+ }
1412
+ if (!logicName) {
1413
+ const { name, parentNode } = this;
1414
+ if (parentNode?.concept === 'View') {
1415
+ logicName = `viewLogic_${name}`;
1416
+ }
1417
+ else if (parentNode?.concept === 'BindEvent') {
1418
+ logicName = `on_${parentNode?.parentNode?.name}_${name}`;
1419
+ }
1420
+ else {
1421
+ logicName = this.name;
1422
+ }
1423
+ }
1424
+ if (!prefix) {
1425
+ code += `${(0, translator_1.indent)(state.tabSize)}export ${currentNode !== this ? 'declare function' : 'function'} ${logicName}`;
1426
+ }
1427
+ else if (prefix === 'noExport') {
1428
+ code += `${(0, translator_1.indent)(state.tabSize)}${currentNode !== this ? 'declare function' : 'function'} ${logicName}`;
1429
+ }
1430
+ else if (prefix === 'inObject') {
1431
+ code += `${logicName}`;
1432
+ }
1433
+ if (this.typeParams?.length) {
1434
+ code += '<';
1435
+ this.typeParams.forEach((typeParam, typeParamIndex) => {
1436
+ code += typeParam.toNaturalTS((0, translator_1.shiftState)(state, code, { inline: true }));
1437
+ if (typeParamIndex !== this.typeParams.length - 1)
1438
+ code += ', ';
1439
+ });
1440
+ code += '>';
1441
+ }
1442
+ // 有参数长度
1443
+ code += '(';
1444
+ this.params.forEach((param, index) => {
1445
+ code += param.toNaturalTS((0, translator_1.shiftState)(state, code, { inline: true }));
1446
+ if (index !== this.params.length - 1)
1447
+ code += ', ';
1448
+ });
1449
+ code += ')';
1450
+ // 需要类型推导的局部变量/返回值需要调整申明顺序
1451
+ const advanceMap = new Map();
1452
+ this.traverseChildren((el) => {
1453
+ if (el && (el instanceof BatchAssignment__1.default || (el instanceof Assignment__1.default && el.left?.name))) {
1454
+ const jsCode = el.toJS();
1455
+ const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && jsCode.includes(`${variable.name} = `));
1456
+ if (advanceVar && !advanceMap.get(advanceVar)) {
1457
+ advanceMap.set(advanceVar, el);
1458
+ }
1459
+ const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && jsCode.includes(`${ret.name} = `));
1460
+ if (advanceRn && !advanceMap.get(advanceRn)) {
1461
+ advanceMap.set(advanceRn, el);
1462
+ }
1463
+ }
1464
+ });
1465
+ // 兼容 return 没有类型情况
1466
+ if (this.returns.length && this.returns[0].typeAnnotation) {
1467
+ code += ': ';
1468
+ code += this.returns[0].typeAnnotation?.toNaturalTS((0, translator_1.shiftState)(state, code, { inline: true }));
1469
+ }
1470
+ if (currentNode !== this) {
1471
+ code += ';';
1472
+ }
1473
+ else {
1474
+ code += ' {\n';
1475
+ this.variables.forEach((variable) => {
1476
+ code += `${(0, translator_1.indent)(state.tabSize + 1)}let `;
1477
+ code += variable.toNaturalTS((0, translator_1.shiftState)(state, code, { inline: true }));
1478
+ code += ';\n';
1479
+ });
1480
+ this.returns.forEach((ret) => {
1481
+ code += `${(0, translator_1.indent)(state.tabSize + 1)}let `;
1482
+ code += ret.toNaturalTS((0, translator_1.shiftState)(state, code, { inline: true }));
1483
+ code += ';\n';
1484
+ });
1485
+ if (!this.body.length && this.returns.length) {
1486
+ if (!state.focusedNodePath || `${this.nodePath}.body[0]` === state.focusedNodePath)
1487
+ code += `${(0, translator_1.indent)(state.tabSize + 1)}// 当前位置\n`;
1488
+ code += `${(0, translator_1.indent)(state.tabSize + 1)}return ${this.returns[0].name};\n`;
1489
+ }
1490
+ else {
1491
+ this.body.forEach((item) => {
1492
+ let partialCode = '';
1493
+ if (!state.focusedNodePath && item.concept === 'End')
1494
+ code += `${(0, translator_1.indent)(state.tabSize + 1)}// 当前位置\n`;
1495
+ if (item.toNaturalTS) {
1496
+ partialCode = item.toNaturalTS((0, translator_1.shiftState)(state, code, { tabSize: state.tabSize + 1 }));
1497
+ }
1498
+ else if (item.toEmbeddedTS) {
1499
+ partialCode = item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: state.tabSize + 1 }));
1500
+ }
1501
+ if (partialCode.trim()) {
1502
+ code += partialCode;
1503
+ code += '\n';
1504
+ }
1505
+ });
1506
+ }
1507
+ code += `${(0, translator_1.indent)(state.tabSize)}}`;
1508
+ }
1509
+ if (prefix === 'inObject') {
1510
+ code += `,`;
1511
+ }
1512
+ code += '\n';
1513
+ return code;
1514
+ }
1515
+ getRightCode(code, assignment, rightNode) {
1516
+ code = code.replaceAll('\n', ' ');
1517
+ if (assignment instanceof Assignment__1.default && !assignment.right)
1518
+ return code;
1519
+ // 调用接口,参数替换成 null
1520
+ if (rightNode instanceof CallInterface__1.default) {
1521
+ const { _interface } = rightNode.getModuleInterface();
1522
+ return _interface ? `${rightNode.tsCalleeKey}(${_interface.params.map(() => 'null').join(',')})` : null;
1523
+ }
1524
+ // 调用服务端逻辑,参数替换成 null
1525
+ if (rightNode instanceof CallLogic__1.default && rightNode.calleeNamespace === 'app.logics') {
1526
+ const calleeName = rightNode?.calleeName;
1527
+ const calleeLogic = this.app.logics.find((l) => l.name === calleeName);
1528
+ return calleeLogic ? `app.logics.${calleeName}(${calleeLogic.params.map(() => 'null').join(',')})` : null;
1529
+ }
1530
+ // ForEachStatement 内部变量需要替换处理,如 item、index
1531
+ const forEachStatement = assignment.getAncestor('ForEachStatement');
1532
+ if (forEachStatement) {
1533
+ code = this.handleForEachCode(code, forEachStatement);
1534
+ }
1535
+ // Match 需要针对分支缩小类型范围
1536
+ const matchCase = assignment.getAncestor('MatchCase');
1537
+ if (matchCase) {
1538
+ code = this.handleMatchCaseCode(code, matchCase);
1539
+ }
1540
+ return code;
1541
+ }
1542
+ handleReplaceCode(code, variable, replaceCode) {
1543
+ return code.replace(/\S+/g, ($1) => {
1544
+ if ($1 === `${variable},`)
1545
+ return `${replaceCode},`;
1546
+ if ($1 === variable)
1547
+ return replaceCode;
1548
+ let fnCode = $1;
1549
+ if ($1.startsWith(`${variable}.`))
1550
+ fnCode = $1.replaceAll(`${variable}.`, `${replaceCode}.`);
1551
+ if ($1.startsWith(`${variable},`))
1552
+ fnCode = $1.replaceAll(`${variable},`, `${replaceCode},`);
1553
+ if ($1.includes(`(${variable},`))
1554
+ fnCode = $1.replaceAll(`(${variable},`, `(${replaceCode},`);
1555
+ if ($1.includes(`(${variable}.`))
1556
+ fnCode = $1.replaceAll(`(${variable}.`, `(${replaceCode}.`);
1557
+ if ($1.includes(`(${variable})`))
1558
+ fnCode = $1.replaceAll(`(${variable})`, `(${replaceCode})`);
1559
+ if ($1.includes(`,${variable},`))
1560
+ fnCode = $1.replaceAll(`,${variable},`, `,${replaceCode},`);
1561
+ if ($1.includes(`,${variable}.`))
1562
+ fnCode = $1.replaceAll(`,${variable}.`, `,${replaceCode}.`);
1563
+ if ($1.includes(`,${variable})`))
1564
+ fnCode = $1.replaceAll(`,${variable})`, `,${replaceCode})`);
1565
+ if ($1.includes(`...[${variable}.`))
1566
+ fnCode = $1.replaceAll(`...[${variable}.`, `...[${replaceCode}.`);
1567
+ return fnCode;
1568
+ });
1569
+ }
1570
+ handleForEachCode(code, forEachStatement) {
1571
+ const { item, index, each } = forEachStatement;
1572
+ if (code.includes(item.name)) {
1573
+ const eachTSCode = each ? each.toEmbeddedTS() : '__IDENTIFIER__';
1574
+ code = this.handleReplaceCode(code, item.name, eachTSCode === '__IDENTIFIER__' ? eachTSCode : `${eachTSCode}.__get(0)`);
1575
+ }
1576
+ if (code.includes(index.name))
1577
+ code = this.handleReplaceCode(code, index.name, 'new nasl.core.Long(0)');
1578
+ const parentForEachStatement = forEachStatement.getAncestor('ForEachStatement');
1579
+ if (parentForEachStatement) {
1580
+ this.handleForEachCode(code, parentForEachStatement);
1581
+ }
1582
+ return code;
1583
+ }
1584
+ handleMatchCaseCode(code, matchCase) {
1585
+ const match = matchCase.getAncestor('Match');
1586
+ const expressionTsCode = match.expression.toEmbeddedTS();
1587
+ if (code.includes(expressionTsCode)) {
1588
+ let typeCode = '';
1589
+ matchCase.patterns.forEach((pattern, index) => {
1590
+ if (pattern instanceof TypeAnnotation__1.default) {
1591
+ if (index === 0) {
1592
+ typeCode += pattern.toEmbeddedTS();
1593
+ }
1594
+ else {
1595
+ typeCode += '|';
1596
+ typeCode += pattern.toEmbeddedTS();
1597
+ }
1598
+ }
1599
+ });
1600
+ if (typeCode) {
1601
+ code = this.handleReplaceCode(code, expressionTsCode, `(${expressionTsCode} as ${typeCode})`);
1602
+ }
1603
+ }
1604
+ const parentMatchCase = match.getAncestor('MatchCase');
1605
+ if (parentMatchCase) {
1606
+ code = this.handleMatchCaseCode(code, parentMatchCase);
1607
+ }
1608
+ return code;
1609
+ }
1610
+ getNamespace() {
1611
+ if (this.parentNode) {
1612
+ const parentNamespace = this.parentNode?.getNamespace();
1613
+ // 针对Connector, 其对应的引入入口只有连接器。且唯一标识由
1614
+ // calleeName、calleeNamespace 两个字段组合确认,
1615
+ // 故这里只返回 Connector 对应的nameSpace 且 俩字段组合默认会含带logic 字段
1616
+ // 因此最后 CallConnector 的 calleewholeKey 为 : `${calleeNamespace}.logics.${calleeName}`
1617
+ if (this.parentNode.concept === 'Connector') {
1618
+ return parentNamespace;
1619
+ }
1620
+ const parentName = this.parentNode.name;
1621
+ // 自定义连接器,增加了分组概念,故需要额外扩展一层namespace
1622
+ const connector = this.getAncestor('Connector');
1623
+ if (connector && connector.connectorKind === 'app') {
1624
+ return `${parentNamespace}.${parentName}`;
1625
+ }
1626
+ const arr = [parentNamespace];
1627
+ if (this.parentNode.concept !== 'App' && parentName) {
1628
+ arr.push(parentName);
1629
+ }
1630
+ let namespace = arr.join('.');
1631
+ if (![
1632
+ 'nasl.ui',
1633
+ 'nasl.utils',
1634
+ 'nasl.util',
1635
+ 'nasl.browser',
1636
+ 'nasl.auth',
1637
+ 'nasl.configuration',
1638
+ 'nasl.process',
1639
+ 'nasl.logging',
1640
+ 'nasl.io',
1641
+ 'nasl.event',
1642
+ ].includes(namespace) &&
1643
+ !namespace.includes('.logics')) {
1644
+ namespace = `${namespace}.logics`;
1645
+ }
1646
+ return namespace;
1647
+ }
1648
+ throw new Error('无法获取命名空间,请设置 parentNode!');
1649
+ }
1650
+ getTsNamespace() {
1651
+ if (this.parentNode) {
1652
+ const parentNamespace = this.parentNode?.getTsNamespace();
1653
+ // 对于parent类型为Namespace的情况,getTsNamespace 已经返回了具体的 name,
1654
+ // 为什么下文还要重新获取???
1655
+ const parentName = this.parentNode.tsName || this.parentNode.name;
1656
+ const arr = [parentNamespace];
1657
+ if (this.parentNode.concept !== 'App' && parentName) {
1658
+ arr.push(parentName);
1659
+ }
1660
+ let namespace = arr.join('.');
1661
+ if (![
1662
+ 'nasl.ui',
1663
+ 'nasl.utils',
1664
+ 'nasl.util',
1665
+ 'nasl.browser',
1666
+ 'nasl.auth',
1667
+ 'nasl.configuration',
1668
+ 'nasl.process',
1669
+ 'nasl.logging',
1670
+ 'nasl.io',
1671
+ ].includes(namespace) &&
1672
+ !namespace.includes('.logics')) {
1673
+ namespace = `${namespace}.logics`;
1674
+ }
1675
+ return namespace;
1676
+ }
1677
+ throw new Error('无法获取命名空间,请设置 parentNode!');
1678
+ }
1679
+ /**
1680
+ * 生成宿主语言的文件路径
1681
+ * @param name 一般不用传,用于 rename
1682
+ */
1683
+ getEmbeddedFilePath(name = this.name) {
1684
+ let _path = '';
1685
+ if (this.module) {
1686
+ _path = `/${this.module.parentKey}/${this.module.name}`;
1687
+ }
1688
+ else if (this.connector) {
1689
+ // 自定义连接器 编辑态文件对应parentKey 为 connectors,
1690
+ // 稳定态文件对应parentKey 为 dependencies
1691
+ // 自定义连接器有分组的概念因此,需要做文件夹处理
1692
+ if (this.connector.connectorKind === 'app') {
1693
+ _path = `/${this.connector.parentKey}/${this.connector.name}/${this.parentNode.name}`;
1694
+ }
1695
+ else {
1696
+ _path = `/${this.connector.parentKey}/${this.connector.name}`;
1697
+ }
1698
+ }
1699
+ if (this.parentNode instanceof FrontendLibrary__1.FrontendLibrary) {
1700
+ _path += `/frontends/${this.parentNode.type}`;
1701
+ }
1702
+ else if (this.parentNode.concept === 'BindEvent' && this.parentNode?.parentNode.concept === 'Frontend') {
1703
+ _path += `/frontends/${this.parentNode.parentNode.name}/bindEvents/${name}.ts`;
1704
+ }
1705
+ return `/embedded/${this.app.name}${_path}/logics/${name}.ts`;
1706
+ }
1707
+ toEmbeddedTSFile() {
1708
+ let code = `namespace ${this.getTsNamespace()} {\n`;
1709
+ const state = (0, translator_1.createCompilerState)(code, { tabSize: 1 });
1710
+ try {
1711
+ code += this.toEmbeddedTS(state);
1712
+ }
1713
+ catch (err) {
1714
+ console.log(err, `有问题翻译失败:${this.getTsNamespace()}.${this.name}`);
1715
+ code += '';
1716
+ console.log(err);
1717
+ }
1718
+ code += '}\n';
1719
+ return {
1720
+ code,
1721
+ filePath: this.getEmbeddedFilePath(),
1722
+ sourceMap: state.sourceMap,
1723
+ };
1724
+ }
1725
+ static getDefaultOptions() {
1726
+ return {
1727
+ body: [
1728
+ {
1729
+ concept: 'Start',
1730
+ label: '开始',
1731
+ kind: 'Statement',
1732
+ type: 'Start',
1733
+ },
1734
+ {
1735
+ concept: 'End',
1736
+ label: '结束',
1737
+ kind: 'Statement',
1738
+ type: 'End',
1739
+ },
1740
+ ],
1741
+ };
1742
+ }
1743
+ async saveStructureOfCallQueryComponents(root) {
1744
+ if (!root)
1745
+ root = this;
1746
+ const set = new Set();
1747
+ utils.traverse(({ node }) => {
1748
+ if (node instanceof CallQueryComponent__1.default) {
1749
+ set.add(node);
1750
+ }
1751
+ }, { node: root }, {
1752
+ mode: 'anyObject',
1753
+ excludedKeySet: new Set(['parentNode', '__assignment__']),
1754
+ });
1755
+ for (const node of set) {
1756
+ node.saveStructure();
1757
+ }
1758
+ }
1759
+ // 通过开关设置数据库事务
1760
+ setTransactionEnabled(flag) {
1761
+ this.setTransactional(new Transactional__1.default({
1762
+ enabled: flag,
1763
+ }));
1764
+ }
1765
+ fake;
1766
+ getPath;
1767
+ delete() {
1768
+ let actionMsg = '删除逻辑项';
1769
+ if (this.name)
1770
+ actionMsg += `“${this.name}”`;
1771
+ this.app?.emit('logicDeleted', { actionMsg: this.nodePath });
1772
+ this.app?.emit('collect:start', {
1773
+ actionMsg,
1774
+ });
1775
+ super.delete();
1776
+ this.traverseChildren(async (el) => {
1777
+ if (el?.concept === 'CallQueryComponent')
1778
+ el.removeStructure();
1779
+ // 仅仅针对 自定义连接器下的 Loigc,其他需要界定边界
1780
+ const connector = el?.getAncestor?.('Connector');
1781
+ if (['CallAuthInterface', 'CallInterface'].includes(el?.concept) && connector) {
1782
+ const { calleeName } = el;
1783
+ const targetInterface = connector.interfaces.find((i) => i.name === calleeName);
1784
+ if (targetInterface) {
1785
+ const refs = await this.app?.naslServer?._isHaveRef(targetInterface);
1786
+ // 如果只有两个引用,则必然为自身以及当前logic引用,需要删除此接口
1787
+ if (refs?.length <= 2) {
1788
+ targetInterface.deleteInterface();
1789
+ }
1790
+ }
1791
+ }
1792
+ });
1793
+ this.app?.emit('collect:end');
1794
+ }
1795
+ // 是不是内部有错误
1796
+ haveError = false;
1797
+ // 是否body为空
1798
+ isSmpty = false;
1799
+ get exportInterface() {
1800
+ return this.rootNode?.interfaces?.find((item) => item.originLogicName === this.name);
1801
+ }
1802
+ get pathName() {
1803
+ if (this.view) {
1804
+ return this.getEventLogicName('chinese');
1805
+ }
1806
+ let { parentNode } = this;
1807
+ if (parentNode.concept === 'BindEvent' && parentNode.parentNode.concept === 'Frontend') {
1808
+ const frontEndEventNameMap = {
1809
+ rendered: '应用进入后',
1810
+ preRequest: '调用服务端逻辑前',
1811
+ postRequest: '调用服务端逻辑后',
1812
+ beforeRouter: '页面切换前',
1813
+ afterRouter: '页面切换后',
1814
+ };
1815
+ const pathName = [this.name];
1816
+ while (parentNode && parentNode.concept !== 'Frontend') {
1817
+ const name = frontEndEventNameMap[parentNode.name] || parentNode.name;
1818
+ pathName.unshift(name);
1819
+ parentNode = parentNode.parentNode;
1820
+ }
1821
+ return pathName.join('-');
1822
+ }
1823
+ const nameMap = {
1824
+ OnProcessStart: '流程开始时',
1825
+ OnTasksCreate: '任务创建时',
1826
+ OnTasksOpen: '任务打开时',
1827
+ OnTasksClose: '任务关闭时',
1828
+ OnCreate: '用户任务创建时',
1829
+ OnOpen: '用户任务打开时',
1830
+ OnClose: '用户任务关闭时',
1831
+ };
1832
+ const pathName = [this.name];
1833
+ parentNode = this.parentNode;
1834
+ while (parentNode && parentNode.concept !== 'Process') {
1835
+ const name = nameMap[parentNode.name] || parentNode.name;
1836
+ pathName.unshift(name);
1837
+ parentNode = parentNode.parentNode;
1838
+ }
1839
+ return pathName.join('-');
1840
+ }
1841
+ // 获取bindEvent下的logic的名称
1842
+ getEventLogicName(type) {
1843
+ if (this.parentNode instanceof BindEvent__1.default) {
1844
+ if (type === 'chinese') {
1845
+ const bindEvent = this.parentNode;
1846
+ const bindChineseName = bindEvent.getPageViewEventChineseName();
1847
+ return `${bindChineseName} -${this.name} `;
1848
+ }
1849
+ }
1850
+ return this.name;
1851
+ }
1852
+ // 虚拟输入参数列表
1853
+ virtualParams = [];
1854
+ get getLogicBelongTo() {
1855
+ const [, belongTo] = this.calleewholeKey.split('.');
1856
+ return belongTo;
1857
+ }
1858
+ // 校验logic的返回值是不是有error类型
1859
+ static checkLogicReturnTypeHasError(logic) {
1860
+ let findHasError = false;
1861
+ if (!logic) {
1862
+ return findHasError;
1863
+ }
1864
+ if (logic.returns?.length && logic.returns[0]?.typeAnnotation) {
1865
+ // 如果新导入的logic还有Error类型
1866
+ const logicType = logic.returns[0].typeAnnotation;
1867
+ if (logicType.typeNamespace === 'nasl.ui' && logicType.typeName === 'Error') {
1868
+ findHasError = true;
1869
+ }
1870
+ else if (logicType.typeNamespace === 'nasl.core' && logicType.typeKind === 'union') {
1871
+ // 如果 logic 有 returns 而且,也有typeArguments的长度
1872
+ findHasError = Boolean(logicType.typeArguments?.find((item) => item?.typeNamespace === 'nasl.ui' && item?.typeName === 'Error'));
1873
+ }
1874
+ }
1875
+ return findHasError;
1876
+ }
1877
+ // 是否来自于 集成中心
1878
+ get integration() {
1879
+ return this.getAncestor('Integration');
1880
+ }
1881
+ };
1882
+ __decorate([
1883
+ (0, decorators_1.property)('concept')
1884
+ ], Logic.prototype, "concept", void 0);
1885
+ __decorate([
1886
+ (0, decorators_1.property)()
1887
+ ], Logic.prototype, "name", void 0);
1888
+ __decorate([
1889
+ (0, decorators_1.property)()
1890
+ ], Logic.prototype, "title", void 0);
1891
+ __decorate([
1892
+ (0, decorators_1.property)()
1893
+ ], Logic.prototype, "description", void 0);
1894
+ __decorate([
1895
+ (0, decorators_1.property)()
1896
+ ], Logic.prototype, "triggerType", void 0);
1897
+ __decorate([
1898
+ (0, decorators_1.property)()
1899
+ ], Logic.prototype, "cron", void 0);
1900
+ __decorate([
1901
+ (0, decorators_1.property)()
1902
+ ], Logic.prototype, "overridable", void 0);
1903
+ __decorate([
1904
+ (0, decorators_1.property)({
1905
+ objectRef: 'Transactional',
1906
+ })
1907
+ ], Logic.prototype, "transactional", void 0);
1908
+ __decorate([
1909
+ (0, decorators_1.property)({
1910
+ objectRef: 'TypeParam',
1911
+ isArray: true,
1912
+ defaultValue: null,
1913
+ })
1914
+ ], Logic.prototype, "typeParams", void 0);
1915
+ __decorate([
1916
+ (0, decorators_1.property)({
1917
+ objectRef: 'Param',
1918
+ isArray: true,
1919
+ defaultValue: [],
1920
+ })
1921
+ ], Logic.prototype, "params", void 0);
1922
+ __decorate([
1923
+ (0, decorators_1.property)({
1924
+ objectRef: 'Return',
1925
+ isArray: true,
1926
+ defaultValue: [],
1927
+ })
1928
+ ], Logic.prototype, "returns", void 0);
1929
+ __decorate([
1930
+ (0, decorators_1.property)({
1931
+ objectRef: 'Variable',
1932
+ isArray: true,
1933
+ defaultValue: [],
1934
+ })
1935
+ ], Logic.prototype, "variables", void 0);
1936
+ __decorate([
1937
+ (0, decorators_1.property)({
1938
+ objectRef: 'LogicItem',
1939
+ isArray: true,
1940
+ defaultValue: [],
1941
+ })
1942
+ ], Logic.prototype, "body", void 0);
1943
+ __decorate([
1944
+ (0, decorators_1.property)({
1945
+ objectRef: 'LogicItem',
1946
+ isArray: true,
1947
+ defaultValue: [],
1948
+ })
1949
+ ], Logic.prototype, "playground", void 0);
1950
+ __decorate([
1951
+ (0, translator_1.withSourceMap)()
1952
+ ], Logic.prototype, "toEmbeddedTSInProcess", null);
1953
+ __decorate([
1954
+ (0, translator_1.withSourceMap)()
1955
+ ], Logic.prototype, "toEmbeddedTS", null);
1956
+ __decorate([
1957
+ (0, translator_1.withSourceMap)()
1958
+ ], Logic.prototype, "toNaturalTS", null);
1959
+ Logic = Logic_1 = __decorate([
1960
+ decorators_1.className,
1961
+ (0, decorators_1.concept)('逻辑')
1962
+ // @ts-ignore
1963
+ ], Logic);
1964
+ exports.Logic = Logic;
1965
+ exports.default = Logic;
1966
+ //================================================================================
1967
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1968
+ // 自动生成的代码已结束。下面可以手动编写。
1969
+ //================================================================================
1949
1970
  //# sourceMappingURL=Logic__.js.map