@lcap/nasl 3.3.0-beta.0 → 3.4.0-alpha.2

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 (423) hide show
  1. package/out/common/BaseNode.js +2 -1
  2. package/out/common/BaseNode.js.map +1 -1
  3. package/out/concepts/Abort__.js +2 -1
  4. package/out/concepts/Abort__.js.map +1 -1
  5. package/out/concepts/Anchor__.d.ts +1 -0
  6. package/out/concepts/Anchor__.js +16 -0
  7. package/out/concepts/Anchor__.js.map +1 -1
  8. package/out/concepts/AnonymousFunction__.d.ts +1 -0
  9. package/out/concepts/AnonymousFunction__.js +28 -2
  10. package/out/concepts/AnonymousFunction__.js.map +1 -1
  11. package/out/concepts/App__.js +2 -1
  12. package/out/concepts/App__.js.map +1 -1
  13. package/out/concepts/Argument__.d.ts +1 -0
  14. package/out/concepts/Argument__.js +21 -0
  15. package/out/concepts/Argument__.js.map +1 -1
  16. package/out/concepts/Assignee__.js.map +1 -1
  17. package/out/concepts/AssignmentLine__.js +1 -1
  18. package/out/concepts/AssignmentLine__.js.map +1 -1
  19. package/out/concepts/Assignment__.d.ts +1 -0
  20. package/out/concepts/Assignment__.js +15 -1
  21. package/out/concepts/Assignment__.js.map +1 -1
  22. package/out/concepts/BackendVariable__.js +1 -1
  23. package/out/concepts/BackendVariable__.js.map +1 -1
  24. package/out/concepts/Backend__.js +1 -1
  25. package/out/concepts/Backend__.js.map +1 -1
  26. package/out/concepts/BatchAssignment__.d.ts +1 -0
  27. package/out/concepts/BatchAssignment__.js +18 -1
  28. package/out/concepts/BatchAssignment__.js.map +1 -1
  29. package/out/concepts/BinaryExpression__.d.ts +1 -0
  30. package/out/concepts/BinaryExpression__.js +53 -16
  31. package/out/concepts/BinaryExpression__.js.map +1 -1
  32. package/out/concepts/BindAttribute__.d.ts +1 -0
  33. package/out/concepts/BindAttribute__.js +67 -3
  34. package/out/concepts/BindAttribute__.js.map +1 -1
  35. package/out/concepts/BindDirective__.js +1 -1
  36. package/out/concepts/BindDirective__.js.map +1 -1
  37. package/out/concepts/BindEvent__.d.ts +1 -0
  38. package/out/concepts/BindEvent__.js +57 -0
  39. package/out/concepts/BindEvent__.js.map +1 -1
  40. package/out/concepts/BindStyle__.js +1 -1
  41. package/out/concepts/BindStyle__.js.map +1 -1
  42. package/out/concepts/BooleanLiteral__.d.ts +1 -0
  43. package/out/concepts/BooleanLiteral__.js +7 -1
  44. package/out/concepts/BooleanLiteral__.js.map +1 -1
  45. package/out/concepts/CallAuthInterface__.js +1 -1
  46. package/out/concepts/CallAuthInterface__.js.map +1 -1
  47. package/out/concepts/CallConnector__.js +1 -1
  48. package/out/concepts/CallConnector__.js.map +1 -1
  49. package/out/concepts/CallFunction__.d.ts +1 -0
  50. package/out/concepts/CallFunction__.js +45 -1
  51. package/out/concepts/CallFunction__.js.map +1 -1
  52. package/out/concepts/CallInterface__.d.ts +1 -0
  53. package/out/concepts/CallInterface__.js +44 -8
  54. package/out/concepts/CallInterface__.js.map +1 -1
  55. package/out/concepts/CallLogic__.d.ts +1 -0
  56. package/out/concepts/CallLogic__.js +101 -1
  57. package/out/concepts/CallLogic__.js.map +1 -1
  58. package/out/concepts/CallQueryComponent__.js +1 -1
  59. package/out/concepts/CallQueryComponent__.js.map +1 -1
  60. package/out/concepts/Comment__.d.ts +1 -0
  61. package/out/concepts/Comment__.js +7 -1
  62. package/out/concepts/Comment__.js.map +1 -1
  63. package/out/concepts/ConfigProperty__.js +1 -1
  64. package/out/concepts/ConfigProperty__.js.map +1 -1
  65. package/out/concepts/Constant__.js +1 -1
  66. package/out/concepts/Constant__.js.map +1 -1
  67. package/out/concepts/DataSource__.js +2 -2
  68. package/out/concepts/DataSource__.js.map +1 -1
  69. package/out/concepts/Destination__.d.ts +1 -0
  70. package/out/concepts/Destination__.js +52 -1
  71. package/out/concepts/Destination__.js.map +1 -1
  72. package/out/concepts/End__.js +1 -1
  73. package/out/concepts/End__.js.map +1 -1
  74. package/out/concepts/EntityIndex__.js +1 -1
  75. package/out/concepts/EntityIndex__.js.map +1 -1
  76. package/out/concepts/EntityProperty__.d.ts +1 -0
  77. package/out/concepts/EntityProperty__.js +17 -1
  78. package/out/concepts/EntityProperty__.js.map +1 -1
  79. package/out/concepts/Entity__.d.ts +1 -0
  80. package/out/concepts/Entity__.js +25 -1
  81. package/out/concepts/Entity__.js.map +1 -1
  82. package/out/concepts/EnumItem__.d.ts +1 -0
  83. package/out/concepts/EnumItem__.js +7 -1
  84. package/out/concepts/EnumItem__.js.map +1 -1
  85. package/out/concepts/Enum__.d.ts +1 -0
  86. package/out/concepts/Enum__.js +14 -1
  87. package/out/concepts/Enum__.js.map +1 -1
  88. package/out/concepts/ForEachStatement__.d.ts +1 -0
  89. package/out/concepts/ForEachStatement__.js +44 -1
  90. package/out/concepts/ForEachStatement__.js.map +1 -1
  91. package/out/concepts/Frontend__.js +1 -1
  92. package/out/concepts/Frontend__.js.map +1 -1
  93. package/out/concepts/Function__.d.ts +1 -0
  94. package/out/concepts/Function__.js +29 -1
  95. package/out/concepts/Function__.js.map +1 -1
  96. package/out/concepts/Identifier__.js +1 -1
  97. package/out/concepts/Identifier__.js.map +1 -1
  98. package/out/concepts/IfStatement__.d.ts +1 -0
  99. package/out/concepts/IfStatement__.js +30 -1
  100. package/out/concepts/IfStatement__.js.map +1 -1
  101. package/out/concepts/Interface__.d.ts +3 -1
  102. package/out/concepts/Interface__.js +19 -3
  103. package/out/concepts/Interface__.js.map +1 -1
  104. package/out/concepts/JSBlock__.d.ts +1 -0
  105. package/out/concepts/JSBlock__.js +7 -1
  106. package/out/concepts/JSBlock__.js.map +1 -1
  107. package/out/concepts/JavaLogic__.js +1 -1
  108. package/out/concepts/JavaLogic__.js.map +1 -1
  109. package/out/concepts/LogicItem__.d.ts +6 -0
  110. package/out/concepts/LogicItem__.js +10 -1
  111. package/out/concepts/LogicItem__.js.map +1 -1
  112. package/out/concepts/Logic__.d.ts +1 -0
  113. package/out/concepts/Logic__.js +133 -1
  114. package/out/concepts/Logic__.js.map +1 -1
  115. package/out/concepts/MatchCase__.d.ts +1 -0
  116. package/out/concepts/MatchCase__.js +88 -0
  117. package/out/concepts/MatchCase__.js.map +1 -1
  118. package/out/concepts/Match__.d.ts +1 -0
  119. package/out/concepts/Match__.js +44 -1
  120. package/out/concepts/Match__.js.map +1 -1
  121. package/out/concepts/MemberExpression__.d.ts +1 -0
  122. package/out/concepts/MemberExpression__.js +19 -1
  123. package/out/concepts/MemberExpression__.js.map +1 -1
  124. package/out/concepts/NewComposite__.d.ts +1 -0
  125. package/out/concepts/NewComposite__.js +91 -1
  126. package/out/concepts/NewComposite__.js.map +1 -1
  127. package/out/concepts/NewList__.d.ts +1 -0
  128. package/out/concepts/NewList__.js +17 -1
  129. package/out/concepts/NewList__.js.map +1 -1
  130. package/out/concepts/NewMap__.d.ts +1 -0
  131. package/out/concepts/NewMap__.js +11 -1
  132. package/out/concepts/NewMap__.js.map +1 -1
  133. package/out/concepts/New__.js +1 -1
  134. package/out/concepts/New__.js.map +1 -1
  135. package/out/concepts/NullLiteral__.js +1 -1
  136. package/out/concepts/NullLiteral__.js.map +1 -1
  137. package/out/concepts/NumericLiteral__.d.ts +1 -0
  138. package/out/concepts/NumericLiteral__.js +7 -1
  139. package/out/concepts/NumericLiteral__.js.map +1 -1
  140. package/out/concepts/OqlQueryComponent__.d.ts +1 -0
  141. package/out/concepts/OqlQueryComponent__.js +8 -1
  142. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  143. package/out/concepts/Param__.d.ts +1 -0
  144. package/out/concepts/Param__.js +41 -0
  145. package/out/concepts/Param__.js.map +1 -1
  146. package/out/concepts/ProcessElement__.js +1 -1
  147. package/out/concepts/ProcessElement__.js.map +1 -1
  148. package/out/concepts/ProcessOutcome__.js +1 -1
  149. package/out/concepts/ProcessOutcome__.js.map +1 -1
  150. package/out/concepts/ProcessOutcomes__.js +1 -1
  151. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  152. package/out/concepts/QueryAggregateExpression__.js +1 -1
  153. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  154. package/out/concepts/QueryFieldExpression__.js +1 -1
  155. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  156. package/out/concepts/QueryFromExpression__.js +1 -1
  157. package/out/concepts/QueryFromExpression__.js.map +1 -1
  158. package/out/concepts/QueryJoinExpression__.js +1 -1
  159. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  160. package/out/concepts/QueryLimitExpression__.js +1 -1
  161. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  162. package/out/concepts/QueryOrderByExpression__.js +1 -1
  163. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  164. package/out/concepts/Return__.d.ts +1 -0
  165. package/out/concepts/Return__.js +20 -1
  166. package/out/concepts/Return__.js.map +1 -1
  167. package/out/concepts/Role__.js +1 -1
  168. package/out/concepts/Role__.js.map +1 -1
  169. package/out/concepts/SelectMembers__.js +1 -1
  170. package/out/concepts/SelectMembers__.js.map +1 -1
  171. package/out/concepts/SqlQueryComponent__.d.ts +1 -0
  172. package/out/concepts/SqlQueryComponent__.js +8 -1
  173. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  174. package/out/concepts/Start__.js +1 -1
  175. package/out/concepts/Start__.js.map +1 -1
  176. package/out/concepts/StringInterpolation__.d.ts +1 -0
  177. package/out/concepts/StringInterpolation__.js +19 -1
  178. package/out/concepts/StringInterpolation__.js.map +1 -1
  179. package/out/concepts/StringLiteral__.d.ts +1 -0
  180. package/out/concepts/StringLiteral__.js +6 -0
  181. package/out/concepts/StringLiteral__.js.map +1 -1
  182. package/out/concepts/StructureProperty__.d.ts +5 -0
  183. package/out/concepts/StructureProperty__.js +19 -2
  184. package/out/concepts/StructureProperty__.js.map +1 -1
  185. package/out/concepts/Structure__.d.ts +5 -0
  186. package/out/concepts/Structure__.js +22 -2
  187. package/out/concepts/Structure__.js.map +1 -1
  188. package/out/concepts/SwitchCase__.d.ts +1 -0
  189. package/out/concepts/SwitchCase__.js +34 -0
  190. package/out/concepts/SwitchCase__.js.map +1 -1
  191. package/out/concepts/SwitchStatement__.d.ts +1 -0
  192. package/out/concepts/SwitchStatement__.js +19 -1
  193. package/out/concepts/SwitchStatement__.js.map +1 -1
  194. package/out/concepts/TriggerLauncher__.js +1 -1
  195. package/out/concepts/TriggerLauncher__.js.map +1 -1
  196. package/out/concepts/TypeAnnotation__.d.ts +1 -0
  197. package/out/concepts/TypeAnnotation__.js +47 -1
  198. package/out/concepts/TypeAnnotation__.js.map +1 -1
  199. package/out/concepts/TypeParam__.d.ts +1 -0
  200. package/out/concepts/TypeParam__.js +6 -0
  201. package/out/concepts/TypeParam__.js.map +1 -1
  202. package/out/concepts/UnaryExpression__.d.ts +1 -0
  203. package/out/concepts/UnaryExpression__.js +19 -1
  204. package/out/concepts/UnaryExpression__.js.map +1 -1
  205. package/out/concepts/Unparsed__.d.ts +1 -0
  206. package/out/concepts/Unparsed__.js +6 -0
  207. package/out/concepts/Unparsed__.js.map +1 -1
  208. package/out/concepts/ValidationRule__.js.map +1 -1
  209. package/out/concepts/Variable__.d.ts +1 -0
  210. package/out/concepts/Variable__.js +20 -1
  211. package/out/concepts/Variable__.js.map +1 -1
  212. package/out/concepts/ViewElement__.d.ts +2 -0
  213. package/out/concepts/ViewElement__.js +67 -0
  214. package/out/concepts/ViewElement__.js.map +1 -1
  215. package/out/concepts/View__.d.ts +1 -0
  216. package/out/concepts/View__.js +94 -2
  217. package/out/concepts/View__.js.map +1 -1
  218. package/out/concepts/WhileStatement__.d.ts +1 -0
  219. package/out/concepts/WhileStatement__.js +21 -1
  220. package/out/concepts/WhileStatement__.js.map +1 -1
  221. package/out/index.d.ts +1 -0
  222. package/out/index.js +1 -0
  223. package/out/index.js.map +1 -1
  224. package/out/natural/componentData.d.ts +31 -0
  225. package/out/natural/componentData.js +85 -0
  226. package/out/natural/componentData.js.map +1 -0
  227. package/out/natural/genNaturalTS.d.ts +3 -0
  228. package/out/natural/genNaturalTS.js +91 -0
  229. package/out/natural/genNaturalTS.js.map +1 -0
  230. package/out/natural/index.d.ts +2 -0
  231. package/out/natural/index.js +19 -0
  232. package/out/natural/index.js.map +1 -0
  233. package/out/natural/naslStdlibMap.d.ts +2 -0
  234. package/out/natural/naslStdlibMap.js +26 -0
  235. package/out/natural/naslStdlibMap.js.map +1 -0
  236. package/out/natural/transformTSCode.d.ts +7 -0
  237. package/out/natural/transformTSCode.js +878 -0
  238. package/out/natural/transformTSCode.js.map +1 -0
  239. package/out/server/naslServer.d.ts +3 -3
  240. package/out/server/naslServer.js +93 -108
  241. package/out/server/naslServer.js.map +1 -1
  242. package/out/service/storage/init.js +16 -0
  243. package/out/service/storage/init.js.map +1 -1
  244. package/out/utils/env.d.ts +2 -0
  245. package/out/utils/env.js +6 -0
  246. package/out/utils/env.js.map +1 -0
  247. package/out/utils/index.d.ts +1 -0
  248. package/out/utils/index.js +1 -0
  249. package/out/utils/index.js.map +1 -1
  250. package/out/utils/time-slicing.js +2 -1
  251. package/out/utils/time-slicing.js.map +1 -1
  252. package/package.json +11 -5
  253. package/sandbox-natural/stdlib/nasl.core.ts +36 -0
  254. package/sandbox-natural/stdlib/nasl.oql.ts +8 -0
  255. package/sandbox-natural/stdlib/nasl.ui.ts +63 -0
  256. package/sandbox-natural/stdlib/nasl.util.ts +119 -0
  257. package/sandbox-natural/tsconfig.json +12 -0
  258. package/src/common/BaseNode.ts +3 -1
  259. package/src/concepts/Abort__.ts +2 -2
  260. package/src/concepts/Anchor__.ts +16 -2
  261. package/src/concepts/AnonymousFunction__.ts +29 -4
  262. package/src/concepts/App__.ts +2 -1
  263. package/src/concepts/Argument__.ts +19 -1
  264. package/src/concepts/Assignee__.ts +1 -1
  265. package/src/concepts/AssignmentLine__.ts +2 -2
  266. package/src/concepts/Assignment__.ts +26 -11
  267. package/src/concepts/BackendVariable__.ts +2 -2
  268. package/src/concepts/Backend__.ts +1 -1
  269. package/src/concepts/BatchAssignment__.ts +20 -3
  270. package/src/concepts/BinaryExpression__.ts +54 -18
  271. package/src/concepts/BindAttribute__.ts +63 -4
  272. package/src/concepts/BindDirective__.ts +2 -2
  273. package/src/concepts/BindEvent__.ts +58 -0
  274. package/src/concepts/BindStyle__.ts +2 -2
  275. package/src/concepts/BooleanLiteral__.ts +7 -2
  276. package/src/concepts/CallAuthInterface__.ts +2 -2
  277. package/src/concepts/CallConnector__.ts +2 -2
  278. package/src/concepts/CallFunction__.ts +42 -2
  279. package/src/concepts/CallInterface__.ts +48 -10
  280. package/src/concepts/CallLogic__.ts +123 -3
  281. package/src/concepts/CallQueryComponent__.ts +2 -2
  282. package/src/concepts/Comment__.ts +9 -3
  283. package/src/concepts/ConfigProperty__.ts +1 -1
  284. package/src/concepts/Constant__.ts +2 -2
  285. package/src/concepts/DataSource__.ts +2 -2
  286. package/src/concepts/Destination__.ts +58 -2
  287. package/src/concepts/End__.ts +2 -2
  288. package/src/concepts/EntityIndex__.ts +2 -2
  289. package/src/concepts/EntityProperty__.ts +18 -2
  290. package/src/concepts/Entity__.ts +27 -1
  291. package/src/concepts/EnumItem__.ts +7 -2
  292. package/src/concepts/Enum__.ts +14 -1
  293. package/src/concepts/ForEachStatement__.ts +48 -4
  294. package/src/concepts/Frontend__.ts +1 -1
  295. package/src/concepts/Function__.ts +30 -2
  296. package/src/concepts/Identifier__.ts +2 -2
  297. package/src/concepts/IfStatement__.ts +39 -3
  298. package/src/concepts/Interface__.ts +20 -3
  299. package/src/concepts/JSBlock__.ts +7 -2
  300. package/src/concepts/JavaLogic__.ts +2 -2
  301. package/src/concepts/LogicItem__.ts +11 -2
  302. package/src/concepts/Logic__.ts +137 -1
  303. package/src/concepts/MatchCase__.ts +90 -2
  304. package/src/concepts/Match__.ts +47 -3
  305. package/src/concepts/MemberExpression__.ts +19 -2
  306. package/src/concepts/NewComposite__.ts +85 -2
  307. package/src/concepts/NewList__.ts +17 -2
  308. package/src/concepts/NewMap__.ts +11 -2
  309. package/src/concepts/New__.ts +2 -2
  310. package/src/concepts/NullLiteral__.ts +2 -2
  311. package/src/concepts/NumericLiteral__.ts +7 -2
  312. package/src/concepts/OqlQueryComponent__.ts +8 -2
  313. package/src/concepts/Param__.ts +40 -1
  314. package/src/concepts/ProcessElement__.ts +2 -2
  315. package/src/concepts/ProcessOutcome__.ts +2 -2
  316. package/src/concepts/ProcessOutcomes__.ts +2 -2
  317. package/src/concepts/QueryAggregateExpression__.ts +2 -2
  318. package/src/concepts/QueryFieldExpression__.ts +2 -2
  319. package/src/concepts/QueryFromExpression__.ts +2 -2
  320. package/src/concepts/QueryJoinExpression__.ts +2 -2
  321. package/src/concepts/QueryLimitExpression__.ts +2 -2
  322. package/src/concepts/QueryOrderByExpression__.ts +2 -2
  323. package/src/concepts/Return__.ts +20 -2
  324. package/src/concepts/Role__.ts +1 -1
  325. package/src/concepts/SelectMembers__.ts +2 -2
  326. package/src/concepts/SqlQueryComponent__.ts +8 -2
  327. package/src/concepts/Start__.ts +2 -2
  328. package/src/concepts/StringInterpolation__.ts +20 -3
  329. package/src/concepts/StringLiteral__.ts +6 -1
  330. package/src/concepts/StructureProperty__.ts +20 -3
  331. package/src/concepts/Structure__.ts +22 -2
  332. package/src/concepts/SwitchCase__.ts +35 -2
  333. package/src/concepts/SwitchStatement__.ts +20 -3
  334. package/src/concepts/TriggerLauncher__.ts +1 -1
  335. package/src/concepts/TypeAnnotation__.ts +47 -2
  336. package/src/concepts/TypeParam__.ts +8 -2
  337. package/src/concepts/UnaryExpression__.ts +22 -3
  338. package/src/concepts/Unparsed__.ts +5 -1
  339. package/src/concepts/ValidationRule__.ts +2 -2
  340. package/src/concepts/Variable__.ts +20 -2
  341. package/src/concepts/ViewElement__.ts +70 -2
  342. package/src/concepts/View__.ts +106 -8
  343. package/src/concepts/WhileStatement__.ts +25 -3
  344. package/src/index.ts +1 -0
  345. package/src/natural/componentData.ts +81 -0
  346. package/src/natural/genNaturalTS.ts +91 -0
  347. package/src/natural/index.ts +2 -0
  348. package/src/natural/naslStdlibMap.ts +24 -0
  349. package/src/natural/transformTSCode.ts +834 -0
  350. package/src/server/naslServer.ts +90 -87
  351. package/src/service/storage/init.ts +17 -0
  352. package/src/utils/env.ts +2 -0
  353. package/src/utils/index.ts +1 -0
  354. package/src/utils/time-slicing.ts +3 -1
  355. package/test/concepts/anonymous-function/__snapshots__/toEmbeddedTS.spec.ts.snap +8 -0
  356. package/test/concepts/anonymous-function/__snapshots__/toJS.spec.ts.snap +3 -0
  357. package/test/concepts/anonymous-function/__snapshots__/toVue.spec.ts.snap +6 -0
  358. package/test/concepts/anonymous-function/constant.ts +5 -0
  359. package/test/concepts/anonymous-function/fixtures/simple.json +85 -0
  360. package/test/concepts/anonymous-function/toEmbeddedTS.spec.ts +14 -0
  361. package/test/concepts/anonymous-function/toJS.spec.ts +14 -0
  362. package/test/concepts/anonymous-function/toVue.spec.ts +14 -0
  363. package/test/concepts/assignment/__snapshots__/toEmbeddedTS.spec.ts.snap +21 -0
  364. package/test/concepts/assignment/__snapshots__/toJS.spec.ts.snap +9 -0
  365. package/test/concepts/assignment/__snapshots__/toVue.spec.ts.snap +21 -0
  366. package/test/concepts/assignment/constant.ts +5 -0
  367. package/test/concepts/assignment/fixtures/both-space.json +4 -0
  368. package/test/concepts/assignment/fixtures/left-space.json +14 -0
  369. package/test/concepts/assignment/fixtures/right-space.json +8 -0
  370. package/test/concepts/assignment/fixtures/simple.json +12 -0
  371. package/test/concepts/assignment/toEmbeddedTS.spec.ts +14 -0
  372. package/test/concepts/assignment/toJS.spec.ts +14 -0
  373. package/test/concepts/assignment/toVue.spec.ts +14 -0
  374. package/test/concepts/batch-assignment/__snapshots__/toEmbeddedTS.spec.ts.snap +28 -0
  375. package/test/concepts/batch-assignment/__snapshots__/toJS.spec.ts.snap +13 -0
  376. package/test/concepts/batch-assignment/__snapshots__/toVue.spec.ts.snap +14 -0
  377. package/test/concepts/batch-assignment/constant.ts +5 -0
  378. package/test/concepts/batch-assignment/fixtures/muli-var-muli-value.json +144 -0
  379. package/test/concepts/batch-assignment/fixtures/simple-var-simple-value.json +36 -0
  380. package/test/concepts/batch-assignment/toEmbeddedTS.spec.ts +14 -0
  381. package/test/concepts/batch-assignment/toJS.spec.ts +14 -0
  382. package/test/concepts/batch-assignment/toVue.spec.ts +14 -0
  383. package/test/concepts/binary-expression/__snapshots__/toEmbeddedTS.spec.ts.snap +25 -0
  384. package/test/concepts/binary-expression/__snapshots__/toJS.spec.ts.snap +16 -0
  385. package/test/concepts/binary-expression/__snapshots__/toVue.spec.ts.snap +19 -0
  386. package/test/concepts/binary-expression/constant.ts +5 -0
  387. package/test/concepts/binary-expression/fixtures/constant-nested.json +36 -0
  388. package/test/concepts/binary-expression/fixtures/constant-simple.json +12 -0
  389. package/test/concepts/binary-expression/fixtures/variable-nested.json +69 -0
  390. package/test/concepts/binary-expression/toEmbeddedTS.spec.ts +14 -0
  391. package/test/concepts/binary-expression/toJS.spec.ts +14 -0
  392. package/test/concepts/binary-expression/toVue.spec.ts +14 -0
  393. package/test/concepts/boolean-literal/toEmbeddedTS.spec.ts +2 -2
  394. package/test/concepts/boolean-literal/toJS.spec.ts +2 -2
  395. package/test/concepts/boolean-literal/toVue.spec.ts +2 -2
  396. package/test/concepts/data-source/__snapshots__/toEmbeddedTS.spec.ts.snap +8 -0
  397. package/test/concepts/data-source/__snapshots__/toEmbeddedTSFile.spec.ts.snap +12 -0
  398. package/test/concepts/data-source/constant.ts +5 -0
  399. package/test/concepts/data-source/fixtures/normal.json +289 -0
  400. package/test/concepts/data-source/toEmbeddedTS.spec.ts +14 -0
  401. package/test/concepts/data-source/toEmbeddedTSFile.spec.ts +15 -0
  402. package/test/concepts/entity/__snapshots__/toEmbeddedTS.spec.ts.snap +74 -0
  403. package/test/concepts/entity/__snapshots__/toEmbeddedTSFile.spec.ts.snap +3 -0
  404. package/test/concepts/entity/constant.ts +5 -0
  405. package/test/concepts/entity/fixtures/normal.json +469 -0
  406. package/test/concepts/entity/toEmbeddedTS.spec.ts +14 -0
  407. package/test/concepts/entity/toEmbeddedTSFile.spec.ts +14 -0
  408. package/test/concepts/identifier/toEmbeddedTS.spec.ts +2 -2
  409. package/test/concepts/identifier/toJS.spec.ts +2 -2
  410. package/test/concepts/identifier/toVue.spec.ts +2 -2
  411. package/test/concepts/member-expression/toEmbeddedTS.spec.ts +2 -2
  412. package/test/concepts/member-expression/toJS.spec.ts +2 -2
  413. package/test/concepts/member-expression/toVue.spec.ts +2 -2
  414. package/test/concepts/null-literal/toEmbeddedTS.spec.ts +2 -2
  415. package/test/concepts/null-literal/toJS.spec.ts +2 -2
  416. package/test/concepts/null-literal/toVue.spec.ts +2 -2
  417. package/test/concepts/numeric-literal/toEmbeddedTS.spec.ts +2 -2
  418. package/test/concepts/numeric-literal/toJS.spec.ts +2 -2
  419. package/test/concepts/numeric-literal/toVue.spec.ts +2 -2
  420. package/test/concepts/string-literal/toEmbeddedTS.spec.ts +2 -2
  421. package/test/concepts/string-literal/toJS.spec.ts +2 -2
  422. package/test/concepts/string-literal/toVue.spec.ts +2 -2
  423. package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +66 -62
@@ -1,5 +1,5 @@
1
1
  import Namespace from './Namespace__';
2
- import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
2
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
3
3
  import { ElementToVueOptions } from './ViewElement__';
4
4
  import ForEachStatement from './ForEachStatement__';
5
5
  import NewList from './NewList__';
@@ -492,7 +492,7 @@ export class AnonymousFunction extends LogicItem {
492
492
  }
493
493
 
494
494
  @withSourceMap()
495
- toEmbeddedTS(state?: TranslatorState): string {
495
+ toEmbeddedTS(state = createCompilerState()): string {
496
496
  let updateNoPropertyCode = '';
497
497
  const grandParent = this.parentNode?.parentNode;
498
498
  if (
@@ -504,7 +504,6 @@ export class AnonymousFunction extends LogicItem {
504
504
  const entity = logicNode?.upperNode?.upperNode as Entity;
505
505
  if (entity) {
506
506
  const primaryKeys = entity.properties.filter((item) => item.primaryKey);
507
-
508
507
  const propertyArg = grandParent.arguments.find((item) => item.keyword === 'properties');
509
508
  const expression = propertyArg?.expression as unknown as AnonymousFunction;
510
509
  const newList = expression?.body as NewList;
@@ -531,8 +530,34 @@ export class AnonymousFunction extends LogicItem {
531
530
 
532
531
  if (this.body) {
533
532
  code +=
534
- this.body.toEmbeddedTS && this.body.toEmbeddedTS(shiftState(state, code, { tabSize: state.tabSize + 1 }));
533
+ this.body.toEmbeddedTS && this.body.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize ?? 0) + 1 }));
534
+ }
535
+ code += ';';
536
+ code += `${indent(state?.tabSize ?? 0)}}`;
537
+ } else {
538
+ code += '__IDENTIFIER__';
539
+ }
540
+
541
+ return code;
542
+ }
543
+
544
+ @withSourceMap()
545
+ toNaturalTS(state = createCompilerState()): string {
546
+ let code = '';
547
+ if (this.body) {
548
+ code += `(`;
549
+ this.params.forEach((param, index) => {
550
+ code += param.toNaturalTS(shiftState(state, code, { inline: true }));
551
+ if (index !== this.params.length - 1)
552
+ code += ', ';
553
+ });
554
+ code += `)`;
555
+ code += ` => (`;
556
+
557
+ if (this.body) {
558
+ code += this.body.toNaturalTS && this.body.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1, inline: true }));
535
559
  }
560
+ code += ')';
536
561
  code += ';';
537
562
  code += `${indent(state.tabSize)}}`;
538
563
  } else {
@@ -3850,7 +3850,8 @@ export class App extends BaseNode {
3850
3850
  const start = nameArr.shift();
3851
3851
  const mod = 0;
3852
3852
  const modulesMap: any = {
3853
- extensions: node.dependencies,
3853
+ // v3.3 版本引入自定义连接器,在配置自定义连接器时需要同步支持内部数据结构使用,所以这里做扩展
3854
+ extensions: [...node.dependencies, ...(node?.integration?.connectors || [])],
3854
3855
  apis: node.interfaceDependencies,
3855
3856
  components: node.componentDependencies,
3856
3857
  };
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
2
2
  import { ElementToVueOptions } from './ViewElement__';
3
3
  import StringLiteral from './StringLiteral__';
4
4
  import TypeAnnotation from './TypeAnnotation__';
@@ -253,6 +253,24 @@ export class Argument extends LogicItem {
253
253
  return code;
254
254
  }
255
255
 
256
+ @withSourceMap()
257
+ toNaturalTS(state = createCompilerState(), isRequired: boolean = true, isHaveKeyWord?: boolean): string {
258
+ let code = this.spread ? '...' : '';
259
+ if (isHaveKeyWord) {
260
+ code += `${this.tsKeyword}:`;
261
+ }
262
+ if (this.expression) {
263
+ if ((this.expression as StringLiteral).name === 'ListDistinctByTargetDefaultExpression') {
264
+ code += (this.expression as NewList).toEmbeddedIgnoreTS(shiftState(state, code));
265
+ } else {
266
+ code += (this.expression as StringLiteral).toNaturalTS(shiftState(state, code), isRequired);
267
+ }
268
+ } else {
269
+ code += isRequired ? '__IDENTIFIER__' : 'undefined';
270
+ }
271
+ return code;
272
+ }
273
+
256
274
  // 参数的类型
257
275
  paramTypeAnnotation?: TypeAnnotation = undefined;
258
276
 
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
2
2
  import { ProcessElement, Process } from '..';
3
3
  import Namespace from './Namespace__';
4
4
  //================================================================================
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
2
2
  //================================================================================
3
3
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
4
4
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -91,7 +91,7 @@ export class AssignmentLine extends BaseNode {
91
91
  // 自动生成的代码已结束。下面可以手动编写。
92
92
  //================================================================================
93
93
  @withSourceMap()
94
- toEmbeddedTS(state?: TranslatorState): string {
94
+ toEmbeddedTS(state = createCompilerState()): string {
95
95
  const code = '';
96
96
  return code;
97
97
  }
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
2
2
  import Identifier from './Identifier__';
3
3
  import { ElementToVueOptions } from './ViewElement__';
4
4
  import BatchAssignment from './BatchAssignment__';
@@ -226,15 +226,15 @@ export class Assignment extends LogicItem {
226
226
  });
227
227
  const batchObject = this.right
228
228
  ? {
229
- left: leftSelect,
230
- rights: [rightSelect],
231
- assignmentLines: [assignmentLine],
232
- }
229
+ left: leftSelect,
230
+ rights: [rightSelect],
231
+ assignmentLines: [assignmentLine],
232
+ }
233
233
  : {
234
- left: leftSelect,
235
- rights: [],
236
- assignmentLines: [],
237
- };
234
+ left: leftSelect,
235
+ rights: [],
236
+ assignmentLines: [],
237
+ };
238
238
  const batchAssignment = new BatchAssignment({
239
239
  ...batchObject,
240
240
  offsetX: this.offsetX,
@@ -296,7 +296,7 @@ export class Assignment extends LogicItem {
296
296
  }
297
297
 
298
298
  @withSourceMap()
299
- toEmbeddedTS(state?: TranslatorState): string {
299
+ toEmbeddedTS(state = createCompilerState()): string {
300
300
  let code = 'nasl.core.assign(';
301
301
 
302
302
  code += this.left ? this.left.toEmbeddedTS(shiftState(state, code, { inline: true })) : '__LEFT__';
@@ -318,7 +318,22 @@ export class Assignment extends LogicItem {
318
318
  return code;
319
319
  }
320
320
 
321
- //================================================================================
321
+ @withSourceMap()
322
+ toNaturalTS(state = createCompilerState()): string {
323
+ let code = '';
324
+
325
+ code += this.left ? this.left.toNaturalTS(shiftState(state, code, { inline: true })) : '__LEFT__';
326
+ code += ' = ';
327
+ // 因为右侧枚举要赋值就得new 一下;
328
+ if (this.right && this.right instanceof Identifier && this.right.namespace && this.right.namespace.endsWith('enums')) {
329
+ code += 'new ';
330
+ }
331
+ code += (this.right && this.right.toNaturalTS) ? this.right.toNaturalTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
332
+
333
+ return code;
334
+ }
335
+
336
+ //= ===============================================================================
322
337
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
323
338
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
324
339
  //================================================================================
@@ -1,5 +1,5 @@
1
1
  import { dataTypesMap } from './basics/types';
2
- import { TranslatorState, shiftState, withSourceMap, createCompilerState, indent } from '../translator';
2
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
3
3
  import { ElementToVueOptions } from './ViewElement__';
4
4
  import EntityProperty from './EntityProperty__';
5
5
  import StructureProperty from './StructureProperty__';
@@ -289,7 +289,7 @@ export class BackendVariable extends BaseNode {
289
289
  }
290
290
 
291
291
  @withSourceMap()
292
- toEmbeddedTS(state?: TranslatorState): string {
292
+ toEmbeddedTS(state = createCompilerState()): string {
293
293
  let code = this.name;
294
294
  if (this.typeAnnotation) {
295
295
  code += ': ';
@@ -316,7 +316,7 @@ export class Backend extends BaseNode {
316
316
  }
317
317
 
318
318
  @withSourceMap()
319
- toEmbeddedTS(state?: TranslatorState): string {
319
+ toEmbeddedTS(state = createCompilerState()): string {
320
320
  let code = `export namespace ${this.name} {\n`;
321
321
  code += 'const name = ';
322
322
  code += `"${this.name}";\n`;
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
2
2
  import { ElementToVueOptions } from './ViewElement__';
3
3
  import MemberExpression from './MemberExpression__';
4
4
  import Assignment from './Assignment__';
@@ -999,7 +999,7 @@ export class BatchAssignment extends LogicItem {
999
999
  }
1000
1000
 
1001
1001
  @withSourceMap()
1002
- toEmbeddedTS(state?: TranslatorState): string {
1002
+ toEmbeddedTS(state = createCompilerState()): string {
1003
1003
  let code = '// 以下是批量赋值的翻译代码\n';
1004
1004
  // 提供sourcemap,获取类型标注和上下文可选变量
1005
1005
  code += this.left.expression
@@ -1042,7 +1042,24 @@ export class BatchAssignment extends LogicItem {
1042
1042
  code += '// 批量赋值的翻译代码结束---------\n';
1043
1043
  return code;
1044
1044
  }
1045
- //================================================================================
1045
+
1046
+ @withSourceMap()
1047
+ toNaturalTS(state = createCompilerState()): string {
1048
+ let code = '';
1049
+ // 根据连线状态,拆分成多个单赋值
1050
+ this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1051
+ const leftValue = leftIndex.length === 1 ? this.left.expression.toNaturalTS(shiftState(state, code, { inline: true })) : this.left.members[leftIndex[1]]?.toNaturalTS(shiftState(state, code, { inline: true }));
1052
+ code += `${leftValue}`;
1053
+ code += ' = ';
1054
+ const rightValue = rightIndex.length === 1 ? this.rights[rightIndex[0]]?.expression?.toNaturalTS(shiftState(state, code, { inline: true })) : this.rights[rightIndex[0]]?.members[rightIndex[1]]?.toNaturalTS(shiftState(state, code, { inline: true }));
1055
+ code += `${rightValue}`;
1056
+ code += ';';
1057
+ code += '\n';
1058
+ });
1059
+ return code;
1060
+ }
1061
+
1062
+ //= ===============================================================================
1046
1063
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
1047
1064
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
1048
1065
  //================================================================================
@@ -1,6 +1,22 @@
1
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
2
2
  import { ElementToVueOptions } from './ViewElement__';
3
3
 
4
+ const operatorMap = {
5
+ '&&': 'and',
6
+ '||': 'or',
7
+ '+': 'add',
8
+ '-': 'minus',
9
+ '*': 'multiply',
10
+ '/': 'divide',
11
+ '%': 'remainder',
12
+ '==': 'equal',
13
+ '!=': 'notEqual',
14
+ '>': 'greaterThan',
15
+ '<': 'lessThan',
16
+ '>=': 'greaterThanOrEqual',
17
+ '<=': 'lessThanOrEqual',
18
+ };
19
+
4
20
  //================================================================================
5
21
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
6
22
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -357,7 +373,7 @@ export class BinaryExpression extends LogicItem {
357
373
  }
358
374
 
359
375
  @withSourceMap()
360
- toEmbeddedTS(state?: TranslatorState): string {
376
+ toEmbeddedTS(state = createCompilerState()): string {
361
377
  if (['startwith', 'endwith', 'like', 'in'].includes(this.operator)) {
362
378
  const fnName = this.operator.toUpperCase();
363
379
  let code = '';
@@ -371,21 +387,6 @@ export class BinaryExpression extends LogicItem {
371
387
  return code;
372
388
  }
373
389
  if (['&&', '||', '+', '-', '*', '/', '%', '==', '!=', '>', '<', '>=', '<='].includes(this.operator)) {
374
- const operatorMap = {
375
- '&&': 'and',
376
- '||': 'or',
377
- '+': 'add',
378
- '-': 'minus',
379
- '*': 'multiply',
380
- '/': 'divide',
381
- '%': 'remainder',
382
- '==': 'equal',
383
- '!=': 'notEqual',
384
- '>': 'greaterThan',
385
- '<': 'lessThan',
386
- '>=': 'greaterThanOrEqual',
387
- '<=': 'lessThanOrEqual',
388
- };
389
390
  let code = '';
390
391
  code += `nasl.core.${operatorMap[this.operator as keyof typeof operatorMap]}(`;
391
392
  code += this.left?.toEmbeddedTS ? this.left.toEmbeddedTS(shiftState(state, code, { inline: true })) : '__LEFT__';
@@ -404,7 +405,42 @@ export class BinaryExpression extends LogicItem {
404
405
  return code;
405
406
  }
406
407
 
407
- //================================================================================
408
+ @withSourceMap()
409
+ toNaturalTS(state = createCompilerState()): string {
410
+ if (['startwith', 'endwith', 'like', 'in'].includes(this.operator)) {
411
+ const fnName = this.operator.toUpperCase();
412
+ let code = '';
413
+ code += `nasl.langUtil.${fnName}(`;
414
+ code += this.left ? this.left.toNaturalTS(shiftState(state, code, { inline: true })) : '__LEFT__';
415
+ code += ', ';
416
+ code += this.right ? this.right.toNaturalTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
417
+ code += ')';
418
+ return code;
419
+ }
420
+ if (['&&', '||', '+', '-', '*', '/', '%', '==', '!=', '>', '<', '>=', '<='].includes(this.operator)) {
421
+ let code = '';
422
+ if (this.left && this.left.concept === 'BinaryExpression') {
423
+ code += this.left ? `(${this.left.toNaturalTS(shiftState(state, code, { inline: true }))})` : '__LEFT__';
424
+ } else {
425
+ code += this.left ? this.left.toNaturalTS(shiftState(state, code, { inline: true })) : '__LEFT__';
426
+ }
427
+ code += `${this.operator}`;
428
+ if (this.right && this.right.concept === 'BinaryExpression') {
429
+ code += this.right ? `(${this.right.toNaturalTS(shiftState(state, code, { inline: true }))})` : '__RIGHT__';
430
+ } else {
431
+ code += this.right ? this.right.toNaturalTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
432
+ }
433
+ return code;
434
+ }
435
+
436
+ let code = '';
437
+ code += this.left ? this.left.toNaturalTS(shiftState(state, code, { inline: true })) : '__LEFT__';
438
+ code += ` ${this.operator} `;
439
+ code += this.right ? this.right.toNaturalTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
440
+ return code;
441
+ }
442
+
443
+ //= ===============================================================================
408
444
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
409
445
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
410
446
  //================================================================================
@@ -1,4 +1,4 @@
1
- import { TranslatorState, indent, shiftState, withSourceMap } from '../translator';
1
+ import { TranslatorState, indent, shiftState, withSourceMap, createCompilerState } from '../translator';
2
2
  import { ElementToVueOptions } from './ViewElement__';
3
3
  import Namespace from './Namespace__';
4
4
  import MemberExpression from './MemberExpression__';
@@ -977,7 +977,11 @@ export class BindAttribute extends BaseNode {
977
977
  code = value;
978
978
  if (options?.finalCode !== false) {
979
979
  code = value.replace(/['"`\\]/g, (m) => {
980
- const escape = '\\';
980
+ let escape = '\\\\';
981
+ escape = '\\\\';
982
+ /// #if process.env.BUILD_TARGET === 'node'
983
+ escape = '\\';
984
+ /// #endif
981
985
  if (m === '\\') {
982
986
  return `${escape}${escape}`;
983
987
  }
@@ -1003,7 +1007,11 @@ export class BindAttribute extends BaseNode {
1003
1007
  value = `$utils['ToString'](${value}, '${expTypeAnnotation?.sortedTypeKey}')`;
1004
1008
  }
1005
1009
  if (this.type === 'string' && name !== 'rules') {
1006
- str += `${name}="${value}"`;
1010
+ if (options?.finalCode !== false) {
1011
+ str += `:${name}="\`${value}\`"`;
1012
+ } else {
1013
+ str += `${name}="${value}"`;
1014
+ }
1007
1015
  } else if (this.sync) {
1008
1016
  str += `:${name}.sync="${value}"`;
1009
1017
  } else if (name === 'destination') {
@@ -1023,7 +1031,7 @@ export class BindAttribute extends BaseNode {
1023
1031
  }
1024
1032
 
1025
1033
  @withSourceMap()
1026
- toEmbeddedTS(state?: TranslatorState): string {
1034
+ toEmbeddedTS(state = createCompilerState()): string {
1027
1035
  const { name, type, value, rules, expression, playground } = this;
1028
1036
 
1029
1037
  let code = '';
@@ -1156,6 +1164,57 @@ export class BindAttribute extends BaseNode {
1156
1164
  return undefined
1157
1165
  }
1158
1166
  }
1167
+ @withSourceMap()
1168
+ toNaturalTS(state = createCompilerState()): string {
1169
+ const { name, type, value, rules, expression, playground } = this;
1170
+ let code = '() => {';
1171
+
1172
+ if (['destination', 'externalDestination'].includes(name) && type === 'dynamic') {
1173
+ code += (this as any)[name].toNaturalTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1174
+ code += ';\n';
1175
+ } else if (name === 'rules') {
1176
+ rules?.forEach((item) => {
1177
+ code += item.toNaturalTS(shiftState(state, code));
1178
+ code += ';\n';
1179
+ });
1180
+ } else if (expression) {
1181
+ code += expression.toNaturalTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1182
+ code += ';\n';
1183
+ } else if (name === 'url' && value) {
1184
+ /**
1185
+ * ls定制化处理
1186
+ * url字符串处理成实体的引用,方便改名或者删除的时候查找引用
1187
+ * 因为这里只有字符串信息,所以在这里拼接成一个有引用的内容
1188
+ */
1189
+ const names = /api\/(.+?)\/import/g.exec(value);
1190
+ if (names) {
1191
+ const dataSourceNameAndEntityName = names[1];
1192
+ let dataSourceName = '';
1193
+ let entityName = '';
1194
+ if (dataSourceNameAndEntityName.includes('/')) {
1195
+ const arr: string[] = dataSourceNameAndEntityName.split('/');
1196
+ dataSourceName = arr[0];
1197
+ entityName = arr[1];
1198
+ } else {
1199
+ entityName = dataSourceNameAndEntityName;
1200
+ }
1201
+ // 连接符转驼峰
1202
+ entityName = entityName.replace(/\-(\w)/g, (all, letter) => letter.toUpperCase());
1203
+ entityName = entityName[0].toUpperCase() + entityName.substr(1);
1204
+ code += `app.dataSources.${dataSourceName || 'defaultDS'}.entities.${entityName}`;
1205
+ code += ';\n';
1206
+ }
1207
+ }
1208
+ if (type === 'dynamic') {
1209
+ playground?.forEach((item) => {
1210
+ code += item.toNaturalTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
1211
+ code += ';\n';
1212
+ });
1213
+ }
1214
+
1215
+ code += '}';
1216
+ return code;
1217
+ }
1159
1218
 
1160
1219
  setUrlValue(newValue: string) {
1161
1220
  const object = {
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
2
2
  import { ElementToVueOptions } from './ViewElement__';
3
3
  import MemberExpression from './MemberExpression__';
4
4
  //================================================================================
@@ -583,7 +583,7 @@ export class BindDirective extends BaseNode {
583
583
  }
584
584
 
585
585
  @withSourceMap()
586
- toEmbeddedTS(state?: TranslatorState): string {
586
+ toEmbeddedTS(state = createCompilerState()): string {
587
587
  let code = '()=>{';
588
588
  if (this.expression) {
589
589
  code += this.expression.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
@@ -669,6 +669,64 @@ export class BindEvent extends BaseNode {
669
669
  return code;
670
670
  }
671
671
 
672
+ @withSourceMap()
673
+ toNaturalTS(state = createCompilerState(), isPageCycle?: Boolean): string {
674
+ // 如果有绑定的事件名
675
+ let code = ``;
676
+ if (isPageCycle) {
677
+ this.logics.forEach((logic, index) => {
678
+ const logicName = `viewLogic_${logic.name}${index}`;
679
+ // logic.name = logic.view.name + logic.name + index;
680
+ code += logic.toNaturalTS(shiftState(state, code, {
681
+ tabSize: state.tabSize,
682
+ }), 'noExport', logicName);
683
+
684
+ // logic.name = logicName;
685
+ // code += indent(state.tabSize);
686
+ // code += `${logicName}();\n`;
687
+ });
688
+ return code;
689
+ }
690
+ // code = `${this.toHump(this.name) || '__IDENTIFIER__'}: (event: `;
691
+
692
+ // event的类型
693
+ // code += this.getEventTypeString();
694
+
695
+ // code += ') => [\n';
696
+ this.logics.forEach((logic) => {
697
+ // 一些默认的逻辑不翻译 排除掉
698
+ if (logic.name.startsWith('__')) {
699
+ return;
700
+ }
701
+ if (logic.view) {
702
+ const logicName = logic.name;
703
+ logic.name = `on_${(logic.parentNode as BindEvent).element.name}_${logic.name}`;
704
+ // logic.name = '__' + logic.view.name + (logic.parentNode as BindEvent).element.name + logic.name;
705
+ logic.name = logic.name.replace(/-/g, '');
706
+ try {
707
+ code += logic.toNaturalTS(shiftState(state, code, {
708
+ tabSize: state.tabSize,
709
+ }), 'noExport');
710
+ } finally {
711
+ // 翻译logic可能出错
712
+ logic.name = logicName;
713
+ }
714
+ } else {
715
+ code += logic.toNaturalTS(shiftState(state, code, {
716
+ tabSize: state.tabSize,
717
+ }), 'noExport');
718
+ }
719
+
720
+ code += indent(state.tabSize);
721
+ // code += ',\n';
722
+ });
723
+ // if (this.view)
724
+ // code += '],\n';
725
+ // else
726
+ // code += ']\n';
727
+ return code;
728
+ }
729
+
672
730
  getEventTypeString() {
673
731
  let code = '';
674
732
  if (!Object.keys(elementsEventsMap).length) return;
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
2
2
  import { ElementToVueOptions } from './ViewElement__';
3
3
  import MemberExpression from './MemberExpression__';
4
4
  //================================================================================
@@ -482,7 +482,7 @@ export class BindStyle extends BaseNode {
482
482
  }
483
483
 
484
484
  @withSourceMap()
485
- toEmbeddedTS(state?: TranslatorState): string {
485
+ toEmbeddedTS(state = createCompilerState()): string {
486
486
  let code = '()=>{';
487
487
  if (this.expression) {
488
488
  code += this.expression.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
@@ -1,4 +1,4 @@
1
- import { TranslatorState, withSourceMap } from '../translator';
1
+ import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
2
2
  import { ElementToVueOptions } from './ViewElement__';
3
3
  //================================================================================
4
4
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -69,10 +69,15 @@ export class BooleanLiteral extends LogicItem {
69
69
  }
70
70
 
71
71
  @withSourceMap()
72
- toEmbeddedTS(state?: TranslatorState) {
72
+ toEmbeddedTS(state = createCompilerState()) {
73
73
  return `new nasl.core.Boolean(${this.value})`;
74
74
  }
75
75
 
76
+ @withSourceMap()
77
+ toNaturalTS(): string {
78
+ return this.value;
79
+ }
80
+
76
81
  /**
77
82
  * 设置布尔值内容
78
83
  */
@@ -1,5 +1,5 @@
1
1
  import Param from './Param__';
2
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
2
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
3
3
  import { getNodeByNodeCallee } from '../automate/engine/utils.js';
4
4
  import AuthLogicForCallInterface from './AuthLogicForCallInterface__';
5
5
  import LogicItem from './LogicItem__';
@@ -328,7 +328,7 @@ export class CallAuthInterface extends CallInterface {
328
328
  }
329
329
 
330
330
  @withSourceMap()
331
- toEmbeddedTS(state?: TranslatorState): string {
331
+ toEmbeddedTS(state = createCompilerState()): string {
332
332
  let code = this.tsAuthLogicKey;
333
333
  // 目前没有任何其他范型,故这里先支持默认俩范型
334
334
  // FIXME
@@ -5,7 +5,7 @@ import Argument from './Argument__';
5
5
  import Identifier from './Identifier__';
6
6
  import TypeAnnotation from './TypeAnnotation__';
7
7
  import Connection from './Connection__';
8
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
8
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
9
9
  import Namespace from './Namespace__';
10
10
 
11
11
  //================================================================================
@@ -201,7 +201,7 @@ export class CallConnector extends CallLogic {
201
201
  }
202
202
 
203
203
  @withSourceMap()
204
- toEmbeddedTS(state?: TranslatorState): string {
204
+ toEmbeddedTS(state = createCompilerState()): string {
205
205
  let code = '';
206
206
  if (this.handleError) {
207
207
  code += 'nasl.util.autoHandleError(';