@lcap/nasl 3.3.0-beta.0 → 3.3.0-beta.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 (368) 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 +27 -1
  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 +38 -1
  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 +3 -1
  53. package/out/concepts/CallInterface__.js +112 -17
  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 +1 -1
  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 +132 -20
  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/Module__.d.ts +1 -0
  125. package/out/concepts/Module__.js +16 -0
  126. package/out/concepts/Module__.js.map +1 -1
  127. package/out/concepts/NewComposite__.d.ts +1 -0
  128. package/out/concepts/NewComposite__.js +91 -1
  129. package/out/concepts/NewComposite__.js.map +1 -1
  130. package/out/concepts/NewList__.d.ts +1 -0
  131. package/out/concepts/NewList__.js +17 -1
  132. package/out/concepts/NewList__.js.map +1 -1
  133. package/out/concepts/NewMap__.d.ts +1 -0
  134. package/out/concepts/NewMap__.js +11 -1
  135. package/out/concepts/NewMap__.js.map +1 -1
  136. package/out/concepts/New__.js +1 -1
  137. package/out/concepts/New__.js.map +1 -1
  138. package/out/concepts/NullLiteral__.js +1 -1
  139. package/out/concepts/NullLiteral__.js.map +1 -1
  140. package/out/concepts/NumericLiteral__.d.ts +1 -0
  141. package/out/concepts/NumericLiteral__.js +7 -1
  142. package/out/concepts/NumericLiteral__.js.map +1 -1
  143. package/out/concepts/OqlQueryComponent__.d.ts +1 -0
  144. package/out/concepts/OqlQueryComponent__.js +8 -1
  145. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  146. package/out/concepts/OverriddenLogic__.js +1 -1
  147. package/out/concepts/OverriddenLogic__.js.map +1 -1
  148. package/out/concepts/Param__.d.ts +1 -0
  149. package/out/concepts/Param__.js +41 -0
  150. package/out/concepts/Param__.js.map +1 -1
  151. package/out/concepts/ProcessElement__.js +1 -1
  152. package/out/concepts/ProcessElement__.js.map +1 -1
  153. package/out/concepts/ProcessOutcome__.js +1 -1
  154. package/out/concepts/ProcessOutcome__.js.map +1 -1
  155. package/out/concepts/ProcessOutcomes__.js +1 -1
  156. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  157. package/out/concepts/QueryAggregateExpression__.js +1 -1
  158. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  159. package/out/concepts/QueryFieldExpression__.js +1 -1
  160. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  161. package/out/concepts/QueryFromExpression__.js +1 -1
  162. package/out/concepts/QueryFromExpression__.js.map +1 -1
  163. package/out/concepts/QueryJoinExpression__.js +1 -1
  164. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  165. package/out/concepts/QueryLimitExpression__.js +1 -1
  166. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  167. package/out/concepts/QueryOrderByExpression__.js +1 -1
  168. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  169. package/out/concepts/Return__.d.ts +1 -0
  170. package/out/concepts/Return__.js +20 -1
  171. package/out/concepts/Return__.js.map +1 -1
  172. package/out/concepts/Role__.js +1 -1
  173. package/out/concepts/Role__.js.map +1 -1
  174. package/out/concepts/SelectMembers__.js +1 -1
  175. package/out/concepts/SelectMembers__.js.map +1 -1
  176. package/out/concepts/SqlQueryComponent__.d.ts +1 -0
  177. package/out/concepts/SqlQueryComponent__.js +8 -1
  178. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  179. package/out/concepts/Start__.js +1 -1
  180. package/out/concepts/Start__.js.map +1 -1
  181. package/out/concepts/StringInterpolation__.d.ts +1 -0
  182. package/out/concepts/StringInterpolation__.js +19 -1
  183. package/out/concepts/StringInterpolation__.js.map +1 -1
  184. package/out/concepts/StringLiteral__.d.ts +1 -0
  185. package/out/concepts/StringLiteral__.js +6 -0
  186. package/out/concepts/StringLiteral__.js.map +1 -1
  187. package/out/concepts/StructureProperty__.d.ts +5 -0
  188. package/out/concepts/StructureProperty__.js +19 -2
  189. package/out/concepts/StructureProperty__.js.map +1 -1
  190. package/out/concepts/Structure__.d.ts +5 -0
  191. package/out/concepts/Structure__.js +22 -2
  192. package/out/concepts/Structure__.js.map +1 -1
  193. package/out/concepts/SwitchCase__.d.ts +1 -0
  194. package/out/concepts/SwitchCase__.js +34 -0
  195. package/out/concepts/SwitchCase__.js.map +1 -1
  196. package/out/concepts/SwitchStatement__.d.ts +1 -0
  197. package/out/concepts/SwitchStatement__.js +19 -1
  198. package/out/concepts/SwitchStatement__.js.map +1 -1
  199. package/out/concepts/TriggerLauncher__.js +1 -1
  200. package/out/concepts/TriggerLauncher__.js.map +1 -1
  201. package/out/concepts/TypeAnnotation__.d.ts +1 -0
  202. package/out/concepts/TypeAnnotation__.js +47 -1
  203. package/out/concepts/TypeAnnotation__.js.map +1 -1
  204. package/out/concepts/TypeParam__.d.ts +1 -0
  205. package/out/concepts/TypeParam__.js +6 -0
  206. package/out/concepts/TypeParam__.js.map +1 -1
  207. package/out/concepts/UnaryExpression__.d.ts +1 -0
  208. package/out/concepts/UnaryExpression__.js +19 -1
  209. package/out/concepts/UnaryExpression__.js.map +1 -1
  210. package/out/concepts/Unparsed__.d.ts +1 -0
  211. package/out/concepts/Unparsed__.js +6 -0
  212. package/out/concepts/Unparsed__.js.map +1 -1
  213. package/out/concepts/ValidationRule__.js.map +1 -1
  214. package/out/concepts/Variable__.d.ts +1 -0
  215. package/out/concepts/Variable__.js +20 -1
  216. package/out/concepts/Variable__.js.map +1 -1
  217. package/out/concepts/ViewElement__.d.ts +2 -0
  218. package/out/concepts/ViewElement__.js +74 -2
  219. package/out/concepts/ViewElement__.js.map +1 -1
  220. package/out/concepts/View__.d.ts +2 -0
  221. package/out/concepts/View__.js +106 -2
  222. package/out/concepts/View__.js.map +1 -1
  223. package/out/concepts/WhileStatement__.d.ts +1 -0
  224. package/out/concepts/WhileStatement__.js +21 -1
  225. package/out/concepts/WhileStatement__.js.map +1 -1
  226. package/out/generator/permission.js +3 -1
  227. package/out/generator/permission.js.map +1 -1
  228. package/out/index.d.ts +1 -0
  229. package/out/index.js +1 -0
  230. package/out/index.js.map +1 -1
  231. package/out/natural/componentData.d.ts +31 -0
  232. package/out/natural/componentData.js +85 -0
  233. package/out/natural/componentData.js.map +1 -0
  234. package/out/natural/genNaturalTS.d.ts +3 -0
  235. package/out/natural/genNaturalTS.js +90 -0
  236. package/out/natural/genNaturalTS.js.map +1 -0
  237. package/out/natural/index.d.ts +2 -0
  238. package/out/natural/index.js +19 -0
  239. package/out/natural/index.js.map +1 -0
  240. package/out/natural/naslStdlibMap.d.ts +2 -0
  241. package/out/natural/naslStdlibMap.js +26 -0
  242. package/out/natural/naslStdlibMap.js.map +1 -0
  243. package/out/natural/transformTSCode.d.ts +7 -0
  244. package/out/natural/transformTSCode.js +883 -0
  245. package/out/natural/transformTSCode.js.map +1 -0
  246. package/out/server/naslServer.d.ts +4 -4
  247. package/out/server/naslServer.js +98 -111
  248. package/out/server/naslServer.js.map +1 -1
  249. package/out/service/storage/init.js +16 -0
  250. package/out/service/storage/init.js.map +1 -1
  251. package/out/translator/utils.js +24 -28
  252. package/out/translator/utils.js.map +1 -1
  253. package/out/utils/env.d.ts +2 -0
  254. package/out/utils/env.js +6 -0
  255. package/out/utils/env.js.map +1 -0
  256. package/out/utils/index.d.ts +1 -0
  257. package/out/utils/index.js +1 -0
  258. package/out/utils/index.js.map +1 -1
  259. package/out/utils/time-slicing.js +2 -1
  260. package/out/utils/time-slicing.js.map +1 -1
  261. package/package.json +11 -5
  262. package/sandbox-natural/stdlib/nasl.core.ts +36 -0
  263. package/sandbox-natural/stdlib/nasl.oql.ts +8 -0
  264. package/sandbox-natural/stdlib/nasl.ui.ts +63 -0
  265. package/sandbox-natural/stdlib/nasl.util.ts +119 -0
  266. package/sandbox-natural/tsconfig.json +12 -0
  267. package/src/common/BaseNode.ts +3 -1
  268. package/src/concepts/Abort__.ts +2 -2
  269. package/src/concepts/Anchor__.ts +16 -2
  270. package/src/concepts/AnonymousFunction__.ts +28 -2
  271. package/src/concepts/App__.ts +2 -1
  272. package/src/concepts/Argument__.ts +19 -1
  273. package/src/concepts/Assignee__.ts +1 -1
  274. package/src/concepts/AssignmentLine__.ts +2 -2
  275. package/src/concepts/Assignment__.ts +26 -11
  276. package/src/concepts/BackendVariable__.ts +2 -2
  277. package/src/concepts/Backend__.ts +1 -1
  278. package/src/concepts/BatchAssignment__.ts +20 -3
  279. package/src/concepts/BinaryExpression__.ts +38 -3
  280. package/src/concepts/BindAttribute__.ts +63 -4
  281. package/src/concepts/BindDirective__.ts +2 -2
  282. package/src/concepts/BindEvent__.ts +58 -0
  283. package/src/concepts/BindStyle__.ts +2 -2
  284. package/src/concepts/BooleanLiteral__.ts +7 -2
  285. package/src/concepts/CallAuthInterface__.ts +2 -2
  286. package/src/concepts/CallConnector__.ts +2 -2
  287. package/src/concepts/CallFunction__.ts +42 -2
  288. package/src/concepts/CallInterface__.ts +113 -20
  289. package/src/concepts/CallLogic__.ts +123 -3
  290. package/src/concepts/CallQueryComponent__.ts +2 -2
  291. package/src/concepts/Comment__.ts +9 -3
  292. package/src/concepts/ConfigProperty__.ts +1 -1
  293. package/src/concepts/Constant__.ts +2 -2
  294. package/src/concepts/DataSource__.ts +1 -1
  295. package/src/concepts/Destination__.ts +58 -2
  296. package/src/concepts/End__.ts +2 -2
  297. package/src/concepts/EntityIndex__.ts +2 -2
  298. package/src/concepts/EntityProperty__.ts +18 -2
  299. package/src/concepts/Entity__.ts +27 -1
  300. package/src/concepts/EnumItem__.ts +7 -2
  301. package/src/concepts/Enum__.ts +14 -1
  302. package/src/concepts/ForEachStatement__.ts +48 -4
  303. package/src/concepts/Frontend__.ts +1 -1
  304. package/src/concepts/Function__.ts +30 -2
  305. package/src/concepts/Identifier__.ts +2 -2
  306. package/src/concepts/IfStatement__.ts +39 -3
  307. package/src/concepts/Interface__.ts +20 -3
  308. package/src/concepts/JSBlock__.ts +7 -2
  309. package/src/concepts/JavaLogic__.ts +2 -2
  310. package/src/concepts/LogicItem__.ts +11 -2
  311. package/src/concepts/Logic__.ts +149 -26
  312. package/src/concepts/MatchCase__.ts +90 -2
  313. package/src/concepts/Match__.ts +47 -3
  314. package/src/concepts/MemberExpression__.ts +19 -2
  315. package/src/concepts/Module__.ts +16 -0
  316. package/src/concepts/NewComposite__.ts +85 -2
  317. package/src/concepts/NewList__.ts +17 -2
  318. package/src/concepts/NewMap__.ts +11 -2
  319. package/src/concepts/New__.ts +2 -2
  320. package/src/concepts/NullLiteral__.ts +2 -2
  321. package/src/concepts/NumericLiteral__.ts +7 -2
  322. package/src/concepts/OqlQueryComponent__.ts +8 -2
  323. package/src/concepts/OverriddenLogic__.ts +1 -1
  324. package/src/concepts/Param__.ts +40 -1
  325. package/src/concepts/ProcessElement__.ts +2 -2
  326. package/src/concepts/ProcessOutcome__.ts +2 -2
  327. package/src/concepts/ProcessOutcomes__.ts +2 -2
  328. package/src/concepts/QueryAggregateExpression__.ts +2 -2
  329. package/src/concepts/QueryFieldExpression__.ts +2 -2
  330. package/src/concepts/QueryFromExpression__.ts +2 -2
  331. package/src/concepts/QueryJoinExpression__.ts +2 -2
  332. package/src/concepts/QueryLimitExpression__.ts +2 -2
  333. package/src/concepts/QueryOrderByExpression__.ts +2 -2
  334. package/src/concepts/Return__.ts +20 -2
  335. package/src/concepts/Role__.ts +1 -1
  336. package/src/concepts/SelectMembers__.ts +2 -2
  337. package/src/concepts/SqlQueryComponent__.ts +8 -2
  338. package/src/concepts/Start__.ts +2 -2
  339. package/src/concepts/StringInterpolation__.ts +20 -3
  340. package/src/concepts/StringLiteral__.ts +6 -1
  341. package/src/concepts/StructureProperty__.ts +20 -3
  342. package/src/concepts/Structure__.ts +22 -2
  343. package/src/concepts/SwitchCase__.ts +35 -2
  344. package/src/concepts/SwitchStatement__.ts +20 -3
  345. package/src/concepts/TriggerLauncher__.ts +1 -1
  346. package/src/concepts/TypeAnnotation__.ts +47 -2
  347. package/src/concepts/TypeParam__.ts +8 -2
  348. package/src/concepts/UnaryExpression__.ts +22 -3
  349. package/src/concepts/Unparsed__.ts +5 -1
  350. package/src/concepts/ValidationRule__.ts +2 -2
  351. package/src/concepts/Variable__.ts +20 -2
  352. package/src/concepts/ViewElement__.ts +77 -4
  353. package/src/concepts/View__.ts +122 -8
  354. package/src/concepts/WhileStatement__.ts +25 -3
  355. package/src/generator/permission.ts +3 -1
  356. package/src/index.ts +1 -0
  357. package/src/natural/componentData.ts +81 -0
  358. package/src/natural/genNaturalTS.ts +90 -0
  359. package/src/natural/index.ts +2 -0
  360. package/src/natural/naslStdlibMap.ts +24 -0
  361. package/src/natural/transformTSCode.ts +840 -0
  362. package/src/server/naslServer.ts +95 -90
  363. package/src/service/storage/init.ts +17 -0
  364. package/src/translator/utils.ts +7 -9
  365. package/src/utils/env.ts +2 -0
  366. package/src/utils/index.ts +1 -0
  367. package/src/utils/time-slicing.ts +3 -1
  368. package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +66 -62
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
2
2
  import { ElementToVueOptions } from './ViewElement__';
3
3
  import MemberExpression from './MemberExpression__';
4
4
  import StructureProperty from './StructureProperty__';
@@ -1196,7 +1196,7 @@ export class NewComposite extends LogicItem {
1196
1196
  }
1197
1197
 
1198
1198
  @withSourceMap()
1199
- toEmbeddedTS(state?: TranslatorState): string {
1199
+ toEmbeddedTS(state = createCompilerState()): string {
1200
1200
  const indent0 = indent(state?.tabSize || 0);
1201
1201
  const indent1 = indent((state?.tabSize || 0) + 1);
1202
1202
  const indent2 = indent((state?.tabSize || 0) + 2);
@@ -1365,6 +1365,89 @@ export class NewComposite extends LogicItem {
1365
1365
  return code;
1366
1366
  }
1367
1367
 
1368
+ @withSourceMap()
1369
+ toNaturalTS(state = createCompilerState()): string {
1370
+ const indent0 = indent((state?.tabSize || 0));
1371
+ const indent1 = indent((state?.tabSize || 0) + 1);
1372
+ const indent2 = indent((state?.tabSize || 0) + 2);
1373
+ let code = '';
1374
+ if (!this.typeAnnotation) {
1375
+ code += '__IDENTIFIER__';
1376
+ } else if (this.typeAnnotation.typeKind !== 'anonymousStructure') {
1377
+ const rightMap = new Map();
1378
+ // 提供sourcemap,获取类型标注和上下文可选变量
1379
+ this.rights.forEach((right) => {
1380
+ code += indent1;
1381
+ rightMap.set(right.expression, right.expression.toNaturalTS(shiftState(state, code, { inline: true })));
1382
+ code += rightMap.get(right.expression);
1383
+ code += ';\n';
1384
+ if (right.members?.length) {
1385
+ code += indent2;
1386
+ }
1387
+ right.members.forEach((member) => {
1388
+ rightMap.set(member, member.toNaturalTS(shiftState(state, code, { inline: true })));
1389
+ code += rightMap.get(member);
1390
+ code += '; ';
1391
+ });
1392
+ code += right.members.length ? '\n' : '';
1393
+ });
1394
+ // 方便ts报错检查
1395
+ // 是否是左边的顶层连线
1396
+ const leftTopIndex = this.assignmentLines.findIndex(({ leftIndex }) => leftIndex[1] === undefined);
1397
+ if (leftTopIndex !== -1) {
1398
+ // const rightIndex = this.assignmentLines[leftTopIndex].rightIndex;
1399
+ // const rightExpression = rightIndex[1] !== undefined ? this.rights[rightIndex[0]].members[rightIndex[1]] : this.rights[rightIndex[0]].expression;
1400
+ // code += `__obj = ${rightExpression.toNaturalTS(shiftState(state, code, { inline: true }))};`;
1401
+ // code += '\n';
1402
+ } else {
1403
+ code += `${indent0}new ${this.typeAnnotation.typeName}({\n`;
1404
+ this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1405
+ const leftSecondIndex = leftIndex[1];
1406
+ const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
1407
+ const leftItem = this.properties[leftSecondIndex];
1408
+ const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
1409
+ const rightTs = rightMap.get(rightItem);
1410
+ code += `${indent1}${leftItem.toNaturalTS(shiftState(state, code, { inline: true }))}: ${['__IDENTIFIER__', '__IDENTIFIER__()'].includes(rightTs) ? 'null' : rightMap.get(rightItem)},\n`;
1411
+ });
1412
+ code += `${indent0}})`;
1413
+ }
1414
+ } else {
1415
+ const nameMap = new Map();
1416
+ const rightMap = new Map();
1417
+ this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1418
+ const leftSecondIndex = leftIndex[1];
1419
+ const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
1420
+ const leftItem = this.properties[leftSecondIndex];
1421
+ const rightItem = rightSecond !== undefined ? this.rights[rightFirst].members[rightSecond] : this.rights[rightFirst].expression;
1422
+ nameMap.set(leftItem.name, rightItem);
1423
+ rightMap.set(rightItem, null);
1424
+ });
1425
+ code += `${indent0}{\n`;
1426
+ this.properties.forEach((property, index) => {
1427
+ const temp = `temp${index}`;
1428
+ const propertyType = this.typeAnnotation.properties[index]?.typeAnnotation;
1429
+ const { name } = property;
1430
+ const rightItem = nameMap.get(name);
1431
+ const ts = rightMap.get(rightItem);
1432
+ if (ts !== undefined) {
1433
+ if (['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts)) {
1434
+ code += `${indent1}${temp}: null,\n`;
1435
+ } else {
1436
+ code += `${indent1}${temp}: ${ts},\n`;
1437
+ }
1438
+ } else if (propertyType) {
1439
+ code += `${indent1}${property.name}: ${propertyType.toNaturalTS(shiftState(state, code, { inline: true }))},\n`;
1440
+ } else {
1441
+ code += `${indent1}`;
1442
+ code += property.toNaturalTS(shiftState(state, code, { inline: true }));
1443
+ code += ',\n';
1444
+ }
1445
+ });
1446
+ code += `${indent0}}`;
1447
+ }
1448
+ return code;
1449
+ }
1450
+
1368
1451
  getInitCode(state?: TranslatorState): string {
1369
1452
  const indent1 = indent((state?.tabSize || 0) + 1);
1370
1453
  const indent2 = indent((state?.tabSize || 0) + 2);
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
2
2
  import ForEachStatement from './ForEachStatement__';
3
3
  import Logic from './Logic__';
4
4
  //================================================================================
@@ -377,7 +377,7 @@ export class NewList extends LogicItem {
377
377
  }
378
378
 
379
379
  @withSourceMap()
380
- toEmbeddedTS(state?: TranslatorState): string {
380
+ toEmbeddedTS(state = createCompilerState()): string {
381
381
  const indent0 = indent(state?.tabSize || 0);
382
382
  const indent1 = indent((state?.tabSize || 0) + 1);
383
383
  const indent2 = indent((state?.tabSize || 0) + 2);
@@ -445,6 +445,21 @@ export class NewList extends LogicItem {
445
445
  return code;
446
446
  }
447
447
 
448
+ @withSourceMap()
449
+ toNaturalTS(state = createCompilerState()): string {
450
+ const indent0 = indent((state?.tabSize || 0));
451
+ let code = '';
452
+ if (this.typeAnnotation) {
453
+ code += `new ${this.typeAnnotation.typeName}(\n`;
454
+ this.items.forEach((item) => {
455
+ code += item.toNaturalTS(shiftState(state, code, { inline: true }));
456
+ code += ',\n';
457
+ });
458
+ code += `${indent0})\n`;
459
+ }
460
+ return code;
461
+ }
462
+
448
463
  getInitCode(state?: TranslatorState): string {
449
464
  const indent1 = indent((state?.tabSize || 0) + 1);
450
465
  const indent2 = indent((state?.tabSize || 0) + 2);
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
2
2
  import { ElementToVueOptions } from './ViewElement__';
3
3
  import ForEachStatement from './ForEachStatement__';
4
4
  import Logic from './Logic__';
@@ -585,7 +585,7 @@ export class NewMap extends LogicItem {
585
585
  }
586
586
 
587
587
  @withSourceMap()
588
- toEmbeddedTS(state?: TranslatorState): string {
588
+ toEmbeddedTS(state = createCompilerState()): string {
589
589
  const indent0 = indent(state?.tabSize || 0);
590
590
  const indent1 = indent((state?.tabSize || 0) + 1);
591
591
  const indent2 = indent((state?.tabSize || 0) + 2);
@@ -678,6 +678,15 @@ export class NewMap extends LogicItem {
678
678
  return code;
679
679
  }
680
680
 
681
+ @withSourceMap()
682
+ toNaturalTS(state = createCompilerState()): string {
683
+ let code = '';
684
+ if (this.typeAnnotation) {
685
+ code += `new ${this.typeAnnotation.sortedTypeKey}()`;
686
+ }
687
+ return code;
688
+ }
689
+
681
690
  getInitCode(state?: TranslatorState): string {
682
691
  let code = '';
683
692
  if (this.keys.some((key) => key) || this.values.some((value) => value)) {
@@ -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
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -50,7 +50,7 @@ export class New extends LogicItem {
50
50
  }
51
51
 
52
52
  @withSourceMap()
53
- toEmbeddedTS(state?: TranslatorState): string {
53
+ toEmbeddedTS(state = createCompilerState()): string {
54
54
  const code = '__IDENTIFIER__';
55
55
  return code;
56
56
  }
@@ -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
  //================================================================================
@@ -63,7 +63,7 @@ export class NullLiteral extends LogicItem {
63
63
  }
64
64
 
65
65
  @withSourceMap()
66
- toEmbeddedTS(state?: TranslatorState) {
66
+ toEmbeddedTS(state = createCompilerState()) {
67
67
  return 'null';
68
68
  }
69
69
 
@@ -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
  //================================================================================
@@ -130,12 +130,17 @@ export class NumericLiteral extends LogicItem {
130
130
  }
131
131
 
132
132
  @withSourceMap()
133
- toEmbeddedTS(state?: TranslatorState): string {
133
+ toEmbeddedTS(state = createCompilerState()): string {
134
134
  const type = `${this.typeAnnotation.typeNamespace}.${this.typeAnnotation.typeName}`;
135
135
  const code = this.value ? `new ${type}(${this.value})` : '__IDENTIFIER__';
136
136
  return code;
137
137
  }
138
138
 
139
+ @withSourceMap()
140
+ toNaturalTS(): string {
141
+ return this.value;
142
+ }
143
+
139
144
  changeType(value: string | number) {
140
145
  const newValue = value.toString();
141
146
  let typeName = 'Long';
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
2
2
  import { getNodeByNodeCallee, getNaslNodeByNodeCallee } from '../automate/engine/utils';
3
3
  import StructureProperty from './StructureProperty__';
4
4
  import Structure from './Structure__';
@@ -235,7 +235,7 @@ export class OqlQueryComponent extends LogicItem {
235
235
  }
236
236
 
237
237
  @withSourceMap()
238
- toEmbeddedTS(state?: TranslatorState): string {
238
+ toEmbeddedTS(state = createCompilerState()): string {
239
239
  let code: string;
240
240
  const { typeAnnotation } = this;
241
241
  if (typeAnnotation) {
@@ -295,6 +295,12 @@ export class OqlQueryComponent extends LogicItem {
295
295
  return code;
296
296
  }
297
297
 
298
+ @withSourceMap()
299
+ toNaturalTS(state = createCompilerState()): string {
300
+ const code: string = `nasl.oql.query(\`${this.code}\`)`;
301
+ return code;
302
+ }
303
+
298
304
  // 从服务端获取 SQL -> TS 的翻译和 sourceMap
299
305
  async requestEmbeddedTS(): Promise<any> {
300
306
  if (this.code) {
@@ -1948,7 +1948,7 @@ export class OverriddenLogic extends BaseNode {
1948
1948
  handleForEachCode(code: string, forEachStatement: ForEachStatement): string {
1949
1949
  const { item, index, each } = forEachStatement;
1950
1950
  if (code.includes(item.name)) {
1951
- const eachTSCode = each.toEmbeddedTS();
1951
+ const eachTSCode = each ? each.toEmbeddedTS() : '__IDENTIFIER__'
1952
1952
  code = this.handleReplaceCode(
1953
1953
  code,
1954
1954
  item.name,
@@ -1,5 +1,5 @@
1
1
  import { dataTypesMap } from './basics/types';
2
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
2
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
3
3
  import LogicItem from './LogicItem__';
4
4
  import EntityProperty from './EntityProperty__';
5
5
  import Structure from './Structure__';
@@ -386,6 +386,45 @@ export class Param extends BaseNode {
386
386
  return code;
387
387
  }
388
388
 
389
+ @withSourceMap()
390
+ toNaturalTS(state = createCompilerState(), dontType?: boolean): string {
391
+ let code = this.name;
392
+ // 回调函数类的参数
393
+ if (this?.typeAnnotation?.typeKind === 'function') {
394
+ code += ':{(';
395
+ const paramTypes = this.typeAnnotation?.typeArguments || [];
396
+ paramTypes.forEach((type, index) => {
397
+ code += `type${index + 1}:${type.toNaturalTS(shiftState(state, code))}`;
398
+ if (index !== paramTypes.length - 1) {
399
+ code += ',';
400
+ } else {
401
+ code += ')';
402
+ }
403
+ });
404
+ code += ':';
405
+ const returnTypes = this.typeAnnotation?.returnType || [];
406
+ returnTypes.forEach((type) => {
407
+ code += type.toNaturalTS(shiftState(state, code));
408
+ });
409
+ code += '}';
410
+ return code;
411
+ }
412
+
413
+ if (this.defaultExpression instanceof Function || this.defaultExpression instanceof AnonymousFunction) {
414
+ code += this.required ? ': ' : '?: ';
415
+ code += this.defaultExpression.toEmbeddedTSDefinition(shiftState(state, code));
416
+ } else if (!dontType && this.typeAnnotation) {
417
+ code += ': ';
418
+ code += this.typeAnnotation.toNaturalTS(shiftState(state, code));
419
+ if (this.typeAnnotation?.typeKind !== 'primitive' && this.defaultValue) {
420
+ if (this.isEnum()) {
421
+ code += `= ${this.typeAnnotation.typeKey}['${this.defaultValue}']`;
422
+ }
423
+ }
424
+ }
425
+ return code;
426
+ }
427
+
389
428
  @withSourceMap()
390
429
  toEmbeddedNameTS(state?: TranslatorState): string {
391
430
  return `${this.name}`;
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
2
2
  import {
3
3
  genUserTaskLogic,
4
4
  getPreviousTask,
@@ -1666,7 +1666,7 @@ export class ProcessElement extends BaseNode {
1666
1666
  }
1667
1667
 
1668
1668
  @withSourceMap()
1669
- toEmbeddedTS(state?: TranslatorState): string {
1669
+ toEmbeddedTS(state = createCompilerState()): string {
1670
1670
  // this.syncLogic();
1671
1671
  const tab0 = indent(state?.tabSize || 0);
1672
1672
  const tab1 = indent((state?.tabSize || 0) + 1);
@@ -1,4 +1,4 @@
1
- import { TranslatorState, withSourceMap } from '../translator';
1
+ import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
2
2
 
3
3
  //================================================================================
4
4
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -71,7 +71,7 @@ export class ProcessOutcome extends LogicItem {
71
71
  // 自动生成的代码已结束。下面可以手动编写。
72
72
  //================================================================================
73
73
  @withSourceMap()
74
- toEmbeddedTS(state?: TranslatorState): string {
74
+ toEmbeddedTS(state = createCompilerState()): string {
75
75
  const code = `return () => ${this.flowRef ? `"${this.flowRef}"` : '__IDENTIFIER__'}`;
76
76
  return code;
77
77
  }
@@ -1,4 +1,4 @@
1
- import { TranslatorState, withSourceMap } from '../translator';
1
+ import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
2
2
  //================================================================================
3
3
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
4
4
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -69,7 +69,7 @@ export class ProcessOutcomes extends LogicItem {
69
69
  // 自动生成的代码已结束。下面可以手动编写。
70
70
  //================================================================================
71
71
  @withSourceMap()
72
- toEmbeddedTS(state?: TranslatorState): string {
72
+ toEmbeddedTS(state = createCompilerState()): string {
73
73
  const code = `return () => ${this.flowRefs?.length > 0 ? `"${this.flowRefs}"` : '__IDENTIFIER__'}`;
74
74
  return code;
75
75
  }
@@ -1,4 +1,4 @@
1
- import { TranslatorState, withSourceMap } from '../translator';
1
+ import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
2
2
  //================================================================================
3
3
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
4
4
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -124,7 +124,7 @@ export class QueryAggregateExpression extends LogicItem {
124
124
  }
125
125
 
126
126
  @withSourceMap()
127
- toEmbeddedTS(state?: TranslatorState): string {
127
+ toEmbeddedTS(state = createCompilerState()): string {
128
128
  // const { aggregateName, aggregateParam, asName } = this;
129
129
  // let code = '';
130
130
  // if (aggregateName && aggregateParam) {
@@ -1,4 +1,4 @@
1
- import { TranslatorState, withSourceMap } from '../translator';
1
+ import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
2
2
  import CallQueryComponent from './CallQueryComponent__';
3
3
  //================================================================================
4
4
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -134,7 +134,7 @@ export class QueryFieldExpression extends LogicItem {
134
134
  }
135
135
 
136
136
  @withSourceMap()
137
- toEmbeddedTS(state?: TranslatorState): string {
137
+ toEmbeddedTS(state = createCompilerState()): string {
138
138
  const { entityAsName, propertyName, isDotStar } = this;
139
139
  const callQueryComponent = this.getAncestor('CallQueryComponent') as CallQueryComponent;
140
140
  if (callQueryComponent) {
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
2
2
  import type CallQueryComponent from './CallQueryComponent__';
3
3
  //================================================================================
4
4
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -249,7 +249,7 @@ export class QueryFromExpression extends LogicItem {
249
249
  }
250
250
 
251
251
  @withSourceMap()
252
- toEmbeddedTS(state?: TranslatorState): string {
252
+ toEmbeddedTS(state = createCompilerState()): string {
253
253
  let code = '';
254
254
  code += `nasl.langUtil.FROM(new nasl.langUtil.Collection<[${this.entityKey}]>()`;
255
255
  if (this.joinParts.length) {
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
2
2
  import CallQueryComponent from './CallQueryComponent__';
3
3
  //================================================================================
4
4
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -461,7 +461,7 @@ export class QueryJoinExpression extends LogicItem {
461
461
  }
462
462
 
463
463
  @withSourceMap()
464
- toEmbeddedTS(state?: TranslatorState): string {
464
+ toEmbeddedTS(state = createCompilerState()): string {
465
465
  let code = '';
466
466
  code += `.${this.joinType}_JOIN(new nasl.langUtil.Collection<[${this.entityKey}]>())\n`;
467
467
  if (this.onExpressions.length > 0) {
@@ -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
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -163,7 +163,7 @@ export class QueryLimitExpression extends LogicItem {
163
163
  //================================================================================
164
164
 
165
165
  @withSourceMap()
166
- toEmbeddedTS(state?: TranslatorState): string {
166
+ toEmbeddedTS(state = createCompilerState()): string {
167
167
  const { pageElement, pageSizeElement } = this;
168
168
  let code = '[';
169
169
  code += `${pageElement.toEmbeddedTS(shiftState(state, code))}, `;
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
2
2
  //================================================================================
3
3
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
4
4
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -177,7 +177,7 @@ export class QueryOrderByExpression extends LogicItem {
177
177
  }
178
178
 
179
179
  @withSourceMap()
180
- toEmbeddedTS(state?: TranslatorState): string {
180
+ toEmbeddedTS(state = createCompilerState()): string {
181
181
  const { orderElement, order } = this;
182
182
  let code = '[';
183
183
  code += `${orderElement.toEmbeddedTS(shiftState(state, code))}, `;
@@ -1,5 +1,5 @@
1
1
  import { dataTypesMap } from './basics/types';
2
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
2
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
3
3
  import EntityProperty from './EntityProperty__';
4
4
  import StructureProperty from './StructureProperty__';
5
5
 
@@ -288,7 +288,7 @@ export class Return extends BaseNode {
288
288
  }
289
289
 
290
290
  @withSourceMap()
291
- toEmbeddedTS(state?: TranslatorState): string {
291
+ toEmbeddedTS(state = createCompilerState()): string {
292
292
  let code = this.name || '__return';
293
293
  if (this.typeAnnotation) {
294
294
  code += ': ';
@@ -308,6 +308,24 @@ export class Return extends BaseNode {
308
308
  return code;
309
309
  }
310
310
 
311
+ @withSourceMap()
312
+ toNaturalTS(state = createCompilerState()): string {
313
+ let code = this.name || '__return';
314
+ if (this.typeAnnotation) {
315
+ code += ': ';
316
+ code += this.typeAnnotation.toNaturalTS(shiftState(state, code));
317
+ // toTS暂时只需要翻译引用数据类型的,因为值都是字符串
318
+ // 就不在这里赋值了,这里单纯就为了快速查找
319
+ // 并且屏蔽了一些异常的错误
320
+ if (this.typeAnnotation?.typeKind !== 'primitive' && this.defaultValue) {
321
+ if (this.isEnum()) {
322
+ code += `= ${this.typeAnnotation.typeKey}['${this.defaultValue}']`;
323
+ }
324
+ }
325
+ }
326
+ return code;
327
+ }
328
+
311
329
  isEnum() {
312
330
  return this.typeAnnotation?.typeNamespace?.endsWith('.enums');
313
331
  }
@@ -104,7 +104,7 @@ export class Role extends BaseNode {
104
104
  // 自动生成的代码已结束。下面可以手动编写。
105
105
  //================================================================================
106
106
  @withSourceMap()
107
- toEmbeddedTS(state?: TranslatorState): string {
107
+ toEmbeddedTS(state = createCompilerState()): string {
108
108
  let code = `export enum ${this.tsName} {\n`;
109
109
  code += ` ${this.tsName}='${this.tsName}'\n`;
110
110
  code += `${indent(state?.tabSize || 0)}}\n`;
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
2
2
  import BatchAssignment from './BatchAssignment__';
3
3
  import AssignmentLine from './AssignmentLine__';
4
4
  //================================================================================
@@ -370,7 +370,7 @@ export class SelectMembers extends BaseNode {
370
370
  }
371
371
 
372
372
  @withSourceMap()
373
- toEmbeddedTS(state?: TranslatorState): string {
373
+ toEmbeddedTS(state = createCompilerState()): string {
374
374
  const code = '';
375
375
  return code;
376
376
  }
@@ -1,4 +1,4 @@
1
- import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
2
2
  import { getNodeByNodeCallee, getNaslNodeByNodeCallee } from '../automate/engine/utils';
3
3
  import StructureProperty from './StructureProperty__';
4
4
  import Structure from './Structure__';
@@ -236,7 +236,7 @@ export class SqlQueryComponent extends LogicItem {
236
236
  }
237
237
 
238
238
  @withSourceMap()
239
- toEmbeddedTS(state?: TranslatorState): string {
239
+ toEmbeddedTS(state = createCompilerState()): string {
240
240
  let code: string;
241
241
  if (this.ideVersion === '2.11') {
242
242
  code = `(function(): `;
@@ -268,6 +268,12 @@ export class SqlQueryComponent extends LogicItem {
268
268
  return code;
269
269
  }
270
270
 
271
+ @withSourceMap()
272
+ toNaturalTS(state = createCompilerState()): string {
273
+ const code: string = `nasl.oql.query(\`${this.code}\`)`;
274
+ return code;
275
+ }
276
+
271
277
  /**
272
278
  * 获取添加时的默认选项
273
279
  * @returns
@@ -1,4 +1,4 @@
1
- import { TranslatorState, withSourceMap } from '../translator';
1
+ import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
2
2
  //================================================================================
3
3
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
4
4
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -56,7 +56,7 @@ export class Start extends LogicItem {
56
56
  }
57
57
 
58
58
  @withSourceMap()
59
- toEmbeddedTS(state?: TranslatorState): string {
59
+ toEmbeddedTS(state = createCompilerState()): string {
60
60
  return '';
61
61
  }
62
62
 
@@ -1,5 +1,6 @@
1
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
1
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
2
2
  import { ElementToVueOptions } from './ViewElement__';
3
+ import { StringLiteral } from './StringLiteral__';
3
4
  //================================================================================
4
5
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
5
6
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -306,7 +307,7 @@ export class StringInterpolation extends LogicItem {
306
307
  }
307
308
 
308
309
  @withSourceMap()
309
- toEmbeddedTS(state?: TranslatorState): string {
310
+ toEmbeddedTS(state = createCompilerState()): string {
310
311
  let code = 'nasl.util.stringInterpolation(';
311
312
  this.expressions.forEach((exp, idx) => {
312
313
  code += exp.toEmbeddedTS(shiftState(state, code));
@@ -318,7 +319,23 @@ export class StringInterpolation extends LogicItem {
318
319
  return code;
319
320
  }
320
321
 
321
- //================================================================================
322
+ @withSourceMap()
323
+ toNaturalTS(state = createCompilerState()): string {
324
+ let code = '`';
325
+ this.expressions.forEach((exp) => {
326
+ if (exp.concept === 'StringLiteral') {
327
+ code += (exp as StringLiteral).value;
328
+ } else {
329
+ code += '${';
330
+ code += exp.toNaturalTS(shiftState(state, code));
331
+ code += '}';
332
+ }
333
+ });
334
+ code += '`\n';
335
+ return code;
336
+ }
337
+
338
+ //= ===============================================================================
322
339
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
323
340
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
324
341
  //================================================================================
@@ -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 自动生成,请不手动修改!
@@ -103,6 +103,11 @@ export class StringLiteral extends LogicItem {
103
103
  return code;
104
104
  }
105
105
 
106
+ @withSourceMap()
107
+ toNaturalTS(state = createCompilerState(), isRequired?: boolean): string {
108
+ return `'${this.value}'`;
109
+ }
110
+
106
111
  /**
107
112
  * 设置字符串内容
108
113
  */