@lcap/nasl 3.3.0-alpha.1 → 3.3.0-alpha.3

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 (380) hide show
  1. package/out/automate/upgrader/2.20.js.map +1 -1
  2. package/out/bak/translator.js +52 -1
  3. package/out/bak/translator.js.map +1 -1
  4. package/out/breakpoint/shared/utils.js +0 -2
  5. package/out/breakpoint/shared/utils.js.map +1 -1
  6. package/out/common/Command.d.ts +1 -0
  7. package/out/common/Command.js +9 -1
  8. package/out/common/Command.js.map +1 -1
  9. package/out/concepts/Abort__.js +2 -1
  10. package/out/concepts/Abort__.js.map +1 -1
  11. package/out/concepts/Anchor__.js +1 -1
  12. package/out/concepts/Anchor__.js.map +1 -1
  13. package/out/concepts/AnonymousFunction__.js +2 -2
  14. package/out/concepts/AnonymousFunction__.js.map +1 -1
  15. package/out/concepts/Argument__.js +1 -1
  16. package/out/concepts/Argument__.js.map +1 -1
  17. package/out/concepts/Assignee__.js.map +1 -1
  18. package/out/concepts/AssignmentLine__.js +1 -1
  19. package/out/concepts/AssignmentLine__.js.map +1 -1
  20. package/out/concepts/Assignment__.js +2 -2
  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__.js +2 -2
  27. package/out/concepts/BatchAssignment__.js.map +1 -1
  28. package/out/concepts/BinaryExpression__.js +2 -2
  29. package/out/concepts/BinaryExpression__.js.map +1 -1
  30. package/out/concepts/BindAttribute__.d.ts +2 -0
  31. package/out/concepts/BindAttribute__.js +79 -4
  32. package/out/concepts/BindAttribute__.js.map +1 -1
  33. package/out/concepts/BindDirective__.js +1 -1
  34. package/out/concepts/BindDirective__.js.map +1 -1
  35. package/out/concepts/BindEvent__.d.ts +2 -1
  36. package/out/concepts/BindEvent__.js +44 -37
  37. package/out/concepts/BindEvent__.js.map +1 -1
  38. package/out/concepts/BindStyle__.js +1 -1
  39. package/out/concepts/BindStyle__.js.map +1 -1
  40. package/out/concepts/BooleanLiteral__.js +1 -1
  41. package/out/concepts/BooleanLiteral__.js.map +1 -1
  42. package/out/concepts/CallAuthInterface__.js +1 -1
  43. package/out/concepts/CallAuthInterface__.js.map +1 -1
  44. package/out/concepts/CallConnector__.js +1 -1
  45. package/out/concepts/CallConnector__.js.map +1 -1
  46. package/out/concepts/CallFunction__.js +2 -2
  47. package/out/concepts/CallFunction__.js.map +1 -1
  48. package/out/concepts/CallInterface__.js +2 -2
  49. package/out/concepts/CallInterface__.js.map +1 -1
  50. package/out/concepts/CallLogic__.js +69 -12
  51. package/out/concepts/CallLogic__.js.map +1 -1
  52. package/out/concepts/CallQueryComponent__.d.ts +1 -1
  53. package/out/concepts/CallQueryComponent__.js +1 -1
  54. package/out/concepts/CallQueryComponent__.js.map +1 -1
  55. package/out/concepts/Comment__.js +1 -1
  56. package/out/concepts/Comment__.js.map +1 -1
  57. package/out/concepts/ConfigProperty__.js +1 -1
  58. package/out/concepts/ConfigProperty__.js.map +1 -1
  59. package/out/concepts/Connection__.js +9 -10
  60. package/out/concepts/Connection__.js.map +1 -1
  61. package/out/concepts/Constant__.js +1 -1
  62. package/out/concepts/Constant__.js.map +1 -1
  63. package/out/concepts/DataSource__.js +1 -1
  64. package/out/concepts/DataSource__.js.map +1 -1
  65. package/out/concepts/Destination__.js +2 -2
  66. package/out/concepts/Destination__.js.map +1 -1
  67. package/out/concepts/End__.js +1 -1
  68. package/out/concepts/End__.js.map +1 -1
  69. package/out/concepts/EntityIndex__.js +1 -1
  70. package/out/concepts/EntityIndex__.js.map +1 -1
  71. package/out/concepts/EntityProperty__.js +2 -2
  72. package/out/concepts/EntityProperty__.js.map +1 -1
  73. package/out/concepts/Entity__.js +2 -2
  74. package/out/concepts/Entity__.js.map +1 -1
  75. package/out/concepts/EnumItem__.js +2 -2
  76. package/out/concepts/EnumItem__.js.map +1 -1
  77. package/out/concepts/Enum__.js +2 -2
  78. package/out/concepts/Enum__.js.map +1 -1
  79. package/out/concepts/ForEachStatement__.js +27 -37
  80. package/out/concepts/ForEachStatement__.js.map +1 -1
  81. package/out/concepts/Frontend__.js +1 -1
  82. package/out/concepts/Frontend__.js.map +1 -1
  83. package/out/concepts/Function__.js +2 -2
  84. package/out/concepts/Function__.js.map +1 -1
  85. package/out/concepts/Identifier__.js +1 -1
  86. package/out/concepts/Identifier__.js.map +1 -1
  87. package/out/concepts/IfStatement__.js +2 -2
  88. package/out/concepts/IfStatement__.js.map +1 -1
  89. package/out/concepts/Interface__.js +1 -1
  90. package/out/concepts/Interface__.js.map +1 -1
  91. package/out/concepts/JSBlock__.js +1 -1
  92. package/out/concepts/JSBlock__.js.map +1 -1
  93. package/out/concepts/JavaLogic__.js +1 -1
  94. package/out/concepts/JavaLogic__.js.map +1 -1
  95. package/out/concepts/LogicItem__.js +3 -2
  96. package/out/concepts/LogicItem__.js.map +1 -1
  97. package/out/concepts/Logic__.js +2 -1
  98. package/out/concepts/Logic__.js.map +1 -1
  99. package/out/concepts/MatchCase__.js +1 -1
  100. package/out/concepts/MatchCase__.js.map +1 -1
  101. package/out/concepts/Match__.js +2 -2
  102. package/out/concepts/Match__.js.map +1 -1
  103. package/out/concepts/MemberExpression__.d.ts +1 -0
  104. package/out/concepts/MemberExpression__.js +117 -2
  105. package/out/concepts/MemberExpression__.js.map +1 -1
  106. package/out/concepts/Module__.d.ts +1 -1
  107. package/out/concepts/Module__.js +34 -35
  108. package/out/concepts/Module__.js.map +1 -1
  109. package/out/concepts/NewComposite__.js +2 -2
  110. package/out/concepts/NewComposite__.js.map +1 -1
  111. package/out/concepts/NewList__.js +2 -2
  112. package/out/concepts/NewList__.js.map +1 -1
  113. package/out/concepts/NewMap__.js +2 -2
  114. package/out/concepts/NewMap__.js.map +1 -1
  115. package/out/concepts/New__.js +1 -1
  116. package/out/concepts/New__.js.map +1 -1
  117. package/out/concepts/NullLiteral__.js +1 -1
  118. package/out/concepts/NullLiteral__.js.map +1 -1
  119. package/out/concepts/NumericLiteral__.js +1 -1
  120. package/out/concepts/NumericLiteral__.js.map +1 -1
  121. package/out/concepts/OqlQueryComponent__.js +2 -2
  122. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  123. package/out/concepts/Param__.js +1 -1
  124. package/out/concepts/Param__.js.map +1 -1
  125. package/out/concepts/ProcessElement__.js +1 -1
  126. package/out/concepts/ProcessElement__.js.map +1 -1
  127. package/out/concepts/ProcessOutcome__.js +1 -1
  128. package/out/concepts/ProcessOutcome__.js.map +1 -1
  129. package/out/concepts/ProcessOutcomes__.js +1 -1
  130. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  131. package/out/concepts/Process__.js +1 -1
  132. package/out/concepts/Process__.js.map +1 -1
  133. package/out/concepts/QueryAggregateExpression__.js +1 -1
  134. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  135. package/out/concepts/QueryFieldExpression__.js +1 -1
  136. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  137. package/out/concepts/QueryFromExpression__.js +1 -1
  138. package/out/concepts/QueryFromExpression__.js.map +1 -1
  139. package/out/concepts/QueryJoinExpression__.js +1 -1
  140. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  141. package/out/concepts/QueryLimitExpression__.js +1 -1
  142. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  143. package/out/concepts/QueryOrderByExpression__.js +1 -1
  144. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  145. package/out/concepts/Return__.js +2 -2
  146. package/out/concepts/Return__.js.map +1 -1
  147. package/out/concepts/Role__.js +1 -1
  148. package/out/concepts/Role__.js.map +1 -1
  149. package/out/concepts/SelectMembers__.js +1 -1
  150. package/out/concepts/SelectMembers__.js.map +1 -1
  151. package/out/concepts/SqlQueryComponent__.js +2 -2
  152. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  153. package/out/concepts/Start__.js +1 -1
  154. package/out/concepts/Start__.js.map +1 -1
  155. package/out/concepts/StringInterpolation__.js +2 -2
  156. package/out/concepts/StringInterpolation__.js.map +1 -1
  157. package/out/concepts/StringLiteral__.js +1 -1
  158. package/out/concepts/StringLiteral__.js.map +1 -1
  159. package/out/concepts/StructureProperty__.js +2 -2
  160. package/out/concepts/StructureProperty__.js.map +1 -1
  161. package/out/concepts/Structure__.js +2 -2
  162. package/out/concepts/Structure__.js.map +1 -1
  163. package/out/concepts/SwitchCase__.js +1 -1
  164. package/out/concepts/SwitchCase__.js.map +1 -1
  165. package/out/concepts/SwitchStatement__.js +2 -2
  166. package/out/concepts/SwitchStatement__.js.map +1 -1
  167. package/out/concepts/TriggerLauncher__.js +1 -1
  168. package/out/concepts/TriggerLauncher__.js.map +1 -1
  169. package/out/concepts/TypeAnnotation__.d.ts +4 -3
  170. package/out/concepts/TypeAnnotation__.js +116 -75
  171. package/out/concepts/TypeAnnotation__.js.map +1 -1
  172. package/out/concepts/TypeParam__.js +1 -1
  173. package/out/concepts/TypeParam__.js.map +1 -1
  174. package/out/concepts/UnaryExpression__.js +2 -2
  175. package/out/concepts/UnaryExpression__.js.map +1 -1
  176. package/out/concepts/ValidationRule__.d.ts +14 -14
  177. package/out/concepts/ValidationRule__.js +28 -24
  178. package/out/concepts/ValidationRule__.js.map +1 -1
  179. package/out/concepts/Variable__.js +2 -2
  180. package/out/concepts/Variable__.js.map +1 -1
  181. package/out/concepts/ViewElement__.d.ts +88 -87
  182. package/out/concepts/ViewElement__.js +268 -204
  183. package/out/concepts/ViewElement__.js.map +1 -1
  184. package/out/concepts/View__.d.ts +6 -0
  185. package/out/concepts/View__.js +254 -11
  186. package/out/concepts/View__.js.map +1 -1
  187. package/out/concepts/WhileStatement__.js +2 -2
  188. package/out/concepts/WhileStatement__.js.map +1 -1
  189. package/out/concepts/basics/stdlib/nasl.browser.js +1 -0
  190. package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
  191. package/out/concepts/basics/stdlib/nasl.event.js +2 -0
  192. package/out/concepts/basics/stdlib/nasl.event.js.map +1 -1
  193. package/out/generator/genBundleFiles.js +90 -1
  194. package/out/generator/genBundleFiles.js.map +1 -1
  195. package/out/generator/genReleaseBody.js +1 -1
  196. package/out/generator/genReleaseBody.js.map +1 -1
  197. package/out/generator/permission.js +3 -3
  198. package/out/generator/permission.js.map +1 -1
  199. package/out/index.d.ts +1 -0
  200. package/out/index.js +1 -0
  201. package/out/index.js.map +1 -1
  202. package/out/natural/genNaturalTS.js +7 -3
  203. package/out/natural/genNaturalTS.js.map +1 -1
  204. package/out/natural/knowledgeMap.js +12 -12
  205. package/out/natural/knowledgeMap.js.map +1 -1
  206. package/out/natural/transformTSCode.d.ts +1 -1
  207. package/out/natural/transformTSCode.js +115 -141
  208. package/out/natural/transformTSCode.js.map +1 -1
  209. package/out/server/extendBaseNode.js +69 -44
  210. package/out/server/extendBaseNode.js.map +1 -1
  211. package/out/server/formatTsUtils.js +72 -63
  212. package/out/server/formatTsUtils.js.map +1 -1
  213. package/out/server/getLogics.js +20 -23
  214. package/out/server/getLogics.js.map +1 -1
  215. package/out/server/getMemberIdentifier.d.ts +1 -0
  216. package/out/server/getMemberIdentifier.js +149 -1
  217. package/out/server/getMemberIdentifier.js.map +1 -1
  218. package/out/server/naslServer.d.ts +3 -3
  219. package/out/server/naslServer.js +182 -132
  220. package/out/server/naslServer.js.map +1 -1
  221. package/out/server/translator.js +43 -33
  222. package/out/server/translator.js.map +1 -1
  223. package/out/service/defaultErrorMessage.json +6 -6
  224. package/out/service/storage/init.js +16 -0
  225. package/out/service/storage/init.js.map +1 -1
  226. package/out/templator/genCreateBlock.js +5 -3
  227. package/out/templator/genCreateBlock.js.map +1 -1
  228. package/out/templator/genCurdEditMultipleKeyBlock.js +12 -8
  229. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  230. package/out/templator/genCurdMultipleKeyBlock.js +8 -7
  231. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  232. package/out/templator/genEditTableBlock.d.ts +1 -1
  233. package/out/templator/genEditTableBlock.js +12 -6
  234. package/out/templator/genEditTableBlock.js.map +1 -1
  235. package/out/templator/genEnumSelectBlock.js +2 -2
  236. package/out/templator/genEnumSelectBlock.js.map +1 -1
  237. package/out/templator/genGetBlock.js +1 -1
  238. package/out/templator/genGetBlock.js.map +1 -1
  239. package/out/templator/genGridViewBlock.d.ts +2 -2
  240. package/out/templator/genGridViewBlock.js +20 -7
  241. package/out/templator/genGridViewBlock.js.map +1 -1
  242. package/out/templator/genListViewBlock.d.ts +2 -2
  243. package/out/templator/genListViewBlock.js +13 -5
  244. package/out/templator/genListViewBlock.js.map +1 -1
  245. package/out/templator/genSelectBlock.d.ts +2 -2
  246. package/out/templator/genSelectBlock.js +8 -6
  247. package/out/templator/genSelectBlock.js.map +1 -1
  248. package/out/templator/genTableBlock.d.ts +1 -1
  249. package/out/templator/genTableBlock.js +10 -5
  250. package/out/templator/genTableBlock.js.map +1 -1
  251. package/out/templator/genUpdateBlock.js +5 -3
  252. package/out/templator/genUpdateBlock.js.map +1 -1
  253. package/package.json +3 -1
  254. package/sandbox/stdlib/nasl.auth.ts +40 -44
  255. package/sandbox/stdlib/nasl.core.ts +8 -1
  256. package/sandbox/stdlib/nasl.http.ts +22 -22
  257. package/sandbox-natural/stdlib/nasl.util.ts +74 -15
  258. package/src/automate/upgrader/2.20.js +17 -13
  259. package/src/bak/translator.js +50 -1
  260. package/src/breakpoint/shared/utils.ts +0 -2
  261. package/src/common/Command.ts +8 -0
  262. package/src/concepts/Abort__.ts +2 -2
  263. package/src/concepts/Anchor__.ts +2 -2
  264. package/src/concepts/AnonymousFunction__.ts +3 -3
  265. package/src/concepts/Argument__.ts +2 -2
  266. package/src/concepts/Assignee__.ts +1 -1
  267. package/src/concepts/AssignmentLine__.ts +2 -2
  268. package/src/concepts/Assignment__.ts +3 -3
  269. package/src/concepts/BackendVariable__.ts +2 -2
  270. package/src/concepts/Backend__.ts +1 -1
  271. package/src/concepts/BatchAssignment__.ts +3 -3
  272. package/src/concepts/BinaryExpression__.ts +3 -3
  273. package/src/concepts/BindAttribute__.ts +69 -4
  274. package/src/concepts/BindDirective__.ts +2 -2
  275. package/src/concepts/BindEvent__.ts +44 -64
  276. package/src/concepts/BindStyle__.ts +2 -2
  277. package/src/concepts/BooleanLiteral__.ts +2 -2
  278. package/src/concepts/CallAuthInterface__.ts +2 -2
  279. package/src/concepts/CallConnector__.ts +2 -2
  280. package/src/concepts/CallFunction__.ts +3 -3
  281. package/src/concepts/CallInterface__.ts +3 -3
  282. package/src/concepts/CallLogic__.ts +69 -13
  283. package/src/concepts/CallQueryComponent__.ts +2 -2
  284. package/src/concepts/Comment__.ts +2 -2
  285. package/src/concepts/ConfigProperty__.ts +2 -2
  286. package/src/concepts/Connection__.ts +15 -21
  287. package/src/concepts/Constant__.ts +2 -2
  288. package/src/concepts/DataSource__.ts +1 -1
  289. package/src/concepts/Destination__.ts +3 -3
  290. package/src/concepts/End__.ts +2 -2
  291. package/src/concepts/EntityIndex__.ts +2 -2
  292. package/src/concepts/EntityProperty__.ts +3 -3
  293. package/src/concepts/Entity__.ts +2 -2
  294. package/src/concepts/EnumItem__.ts +3 -3
  295. package/src/concepts/Enum__.ts +2 -2
  296. package/src/concepts/ForEachStatement__.ts +35 -46
  297. package/src/concepts/Frontend__.ts +1 -1
  298. package/src/concepts/Function__.ts +3 -3
  299. package/src/concepts/Identifier__.ts +2 -2
  300. package/src/concepts/IfStatement__.ts +3 -3
  301. package/src/concepts/Interface__.ts +1 -1
  302. package/src/concepts/JSBlock__.ts +2 -2
  303. package/src/concepts/JavaLogic__.ts +2 -2
  304. package/src/concepts/LogicItem__.ts +3 -3
  305. package/src/concepts/Logic__.ts +2 -1
  306. package/src/concepts/MatchCase__.ts +2 -2
  307. package/src/concepts/Match__.ts +3 -3
  308. package/src/concepts/MemberExpression__.ts +112 -4
  309. package/src/concepts/Module__.ts +41 -58
  310. package/src/concepts/NewComposite__.ts +3 -3
  311. package/src/concepts/NewList__.ts +3 -3
  312. package/src/concepts/NewMap__.ts +3 -3
  313. package/src/concepts/New__.ts +2 -2
  314. package/src/concepts/NullLiteral__.ts +2 -2
  315. package/src/concepts/NumericLiteral__.ts +2 -2
  316. package/src/concepts/OqlQueryComponent__.ts +3 -3
  317. package/src/concepts/Param__.ts +2 -2
  318. package/src/concepts/ProcessElement__.ts +2 -2
  319. package/src/concepts/ProcessOutcome__.ts +2 -2
  320. package/src/concepts/ProcessOutcomes__.ts +2 -2
  321. package/src/concepts/Process__.ts +1 -1
  322. package/src/concepts/QueryAggregateExpression__.ts +2 -2
  323. package/src/concepts/QueryFieldExpression__.ts +2 -2
  324. package/src/concepts/QueryFromExpression__.ts +2 -2
  325. package/src/concepts/QueryJoinExpression__.ts +2 -2
  326. package/src/concepts/QueryLimitExpression__.ts +2 -2
  327. package/src/concepts/QueryOrderByExpression__.ts +2 -2
  328. package/src/concepts/Return__.ts +3 -3
  329. package/src/concepts/Role__.ts +1 -1
  330. package/src/concepts/SelectMembers__.ts +2 -2
  331. package/src/concepts/SqlQueryComponent__.ts +3 -3
  332. package/src/concepts/Start__.ts +2 -2
  333. package/src/concepts/StringInterpolation__.ts +3 -3
  334. package/src/concepts/StringLiteral__.ts +2 -2
  335. package/src/concepts/StructureProperty__.ts +3 -3
  336. package/src/concepts/Structure__.ts +2 -2
  337. package/src/concepts/SwitchCase__.ts +2 -2
  338. package/src/concepts/SwitchStatement__.ts +3 -3
  339. package/src/concepts/TriggerLauncher__.ts +1 -1
  340. package/src/concepts/TypeAnnotation__.ts +145 -125
  341. package/src/concepts/TypeParam__.ts +2 -2
  342. package/src/concepts/UnaryExpression__.ts +3 -3
  343. package/src/concepts/ValidationRule__.ts +554 -524
  344. package/src/concepts/Variable__.ts +3 -3
  345. package/src/concepts/ViewElement__.ts +2445 -2498
  346. package/src/concepts/View__.ts +258 -10
  347. package/src/concepts/WhileStatement__.ts +3 -3
  348. package/src/concepts/basics/stdlib/nasl.browser.ts +1 -0
  349. package/src/concepts/basics/stdlib/nasl.event.ts +2 -0
  350. package/src/generator/genBundleFiles.ts +91 -1
  351. package/src/generator/genReleaseBody.ts +1 -1
  352. package/src/generator/permission.ts +3 -3
  353. package/src/index.ts +1 -0
  354. package/src/natural/genNaturalTS.ts +8 -4
  355. package/src/natural/knowledgeMap.ts +12 -12
  356. package/src/natural/transformTSCode.ts +139 -151
  357. package/src/server/extendBaseNode.ts +71 -45
  358. package/src/server/formatTsUtils.ts +64 -64
  359. package/src/server/getLogics.ts +23 -30
  360. package/src/server/getMemberIdentifier.ts +143 -0
  361. package/src/server/naslServer.ts +174 -148
  362. package/src/server/translator.ts +40 -39
  363. package/src/service/defaultErrorMessage.json +6 -6
  364. package/src/service/storage/init.ts +17 -0
  365. package/src/templator/genCreateBlock.ts +5 -3
  366. package/src/templator/genCurdEditMultipleKeyBlock.ts +12 -8
  367. package/src/templator/genCurdMultipleKeyBlock.ts +8 -7
  368. package/src/templator/genEditTableBlock.ts +12 -7
  369. package/src/templator/genEnumSelectBlock.ts +2 -2
  370. package/src/templator/genGetBlock.ts +6 -6
  371. package/src/templator/genGridViewBlock.ts +22 -9
  372. package/src/templator/genListViewBlock.ts +14 -5
  373. package/src/templator/genSelectBlock.ts +8 -6
  374. package/src/templator/genTableBlock.ts +10 -9
  375. package/src/templator/genUpdateBlock.ts +5 -3
  376. package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +11 -0
  377. package/test/concepts/validation-rule/__snapshots__/toJS.spec.ts.snap +10 -0
  378. package/test/concepts/validation-rule/fixtures/argument-without-keyword.json +34 -0
  379. package/test/concepts/validation-rule/fixtures/empty-rule.json +9 -0
  380. package/test/concepts/validation-rule/validation-rule.spec.ts +15 -0
@@ -1,22 +1,9 @@
1
- import { v4 as uuidv4 } from 'uuid';
2
1
  import App from './App__';
3
2
  import Structure from './Structure__';
4
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
3
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
5
4
  import { genHash } from '../generator';
6
5
  import { firstUpperCase } from '../utils/string';
7
6
 
8
- //= ===============================================================================
9
- // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
10
- // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
11
- //= ===============================================================================
12
- import { EventPayload, Params } from '../common/EventEmitter';
13
- import { concept, excludedInJSON, property } from '../decorators';
14
-
15
- import * as utils from '../utils';
16
- import BaseNode from '../common/BaseNode';
17
- import classMap from '../common/classMap';
18
- import StructureProperty from './StructureProperty__';
19
-
20
7
  export enum PRIMITIVE_TYPE {
21
8
  Boolean = 'Boolean',
22
9
  Integer = 'Integer',
@@ -95,6 +82,19 @@ export function isUnion(typeAnnotation: TypeAnnotation): boolean {
95
82
  return typeAnnotation && typeAnnotation.typeKind === 'union' && typeAnnotation.typeNamespace === 'nasl.core' && typeAnnotation.typeName === 'Union';
96
83
  }
97
84
 
85
+ //================================================================================
86
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
87
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
88
+ //================================================================================
89
+ import { EventPayload, Params } from '../common/EventEmitter';
90
+ import { concept, excludedInJSON, property } from '../decorators';
91
+
92
+ import * as utils from '../utils';
93
+ import { v4 as uuidv4 } from 'uuid';
94
+ import BaseNode from '../common/BaseNode';
95
+ import classMap from '../common/classMap';
96
+ import StructureProperty from './StructureProperty__';
97
+
98
98
  /**
99
99
  * 类型标注
100
100
  */
@@ -158,12 +158,10 @@ export class TypeAnnotation extends BaseNode {
158
158
  * @param source 需要合并的部分参数
159
159
  */
160
160
  constructor(source?: Partial<TypeAnnotation>) {
161
- // @ts-ignore
162
- source = { ...TypeAnnotation.getDefaultOptions(), ...source };
161
+ source = Object.assign({}, TypeAnnotation.getDefaultOptions(), source);
163
162
  super(source);
164
163
  super.subConstructor(source);
165
164
  }
166
-
167
165
  getClassName() {
168
166
  return 'TypeAnnotation';
169
167
  }
@@ -183,7 +181,6 @@ export class TypeAnnotation extends BaseNode {
183
181
  }
184
182
  return params;
185
183
  }
186
-
187
184
  /**
188
185
  * 设置规则对象
189
186
  */
@@ -519,7 +516,7 @@ export class TypeAnnotation extends BaseNode {
519
516
  }
520
517
 
521
518
  __removeTypeAnnotation(typeAnnotation: TypeAnnotation) {
522
- const { parentKey } = typeAnnotation;
519
+ const parentKey = typeAnnotation.parentKey;
523
520
  const params: Params = {
524
521
  parentNode: this,
525
522
  parentKey,
@@ -553,7 +550,7 @@ export class TypeAnnotation extends BaseNode {
553
550
  }
554
551
 
555
552
  __removeStructureProperty(structureProperty: StructureProperty) {
556
- const { parentKey } = structureProperty;
553
+ const parentKey = structureProperty.parentKey;
557
554
  const params: Params = {
558
555
  parentNode: this,
559
556
  parentKey,
@@ -575,10 +572,13 @@ export class TypeAnnotation extends BaseNode {
575
572
  return params;
576
573
  }
577
574
 
578
- //= ===============================================================================
575
+ //================================================================================
579
576
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
580
577
  // 自动生成的代码已结束。下面可以手动编写。
581
- //= ===============================================================================
578
+ //================================================================================
579
+
580
+ // 兼容 long 需要显示为 long 的情况,默认 undefined
581
+ longNotInteger: boolean = undefined;
582
582
 
583
583
  toUI(state?: TranslatorState): string {
584
584
  return this.headTitle;
@@ -607,17 +607,15 @@ export class TypeAnnotation extends BaseNode {
607
607
  get typeKey(): string {
608
608
  if (this.typeKind === 'primitive' || this.typeKind === 'reference') {
609
609
  return `${this.typeNamespace}.${this.typeName}`;
610
- }
611
- if (this.typeKind === 'generic') {
610
+ } else if (this.typeKind === 'generic') {
612
611
  return `${this.typeNamespace}.${this.typeName}<${(this.typeArguments || []).map((arg) => arg.typeKey)}>`;
613
- }
614
- if (this.typeKind === 'anonymousStructure') {
612
+ } else if (this.typeKind === 'anonymousStructure') {
615
613
  return `{ ${this.properties.map(({ name, typeAnnotation }) => `${name}: ${typeAnnotation ? typeAnnotation.typeKey : '未知'}`).join(', ')} }`;
616
- }
617
- if (this.typeKind === 'union') {
614
+ } else if (this.typeKind === 'union') {
618
615
  return `${this.typeArguments.map((arg) => arg.typeKey).join(' | ')}`;
616
+ } else {
617
+ return this.typeName;
619
618
  }
620
- return this.typeName;
621
619
  }
622
620
 
623
621
  // 排过序的类型标识
@@ -628,8 +626,7 @@ export class TypeAnnotation extends BaseNode {
628
626
  .sort(({ name: name1 }, { name: name2 }) => (name1 > name2 ? 1 : -1))
629
627
  .map(({ name, typeAnnotation }) => `${name}: ${typeAnnotation ? typeAnnotation.sortedTypeKey : '未知'}`)
630
628
  .join(', ')}}`;
631
- }
632
- if (this.typeKind === 'union') {
629
+ } else if (this.typeKind === 'union') {
633
630
  // 按返回的每个具体项排序
634
631
  return `${this.typeArguments
635
632
  .map((arg) => arg.sortedTypeKey)
@@ -662,12 +659,12 @@ export class TypeAnnotation extends BaseNode {
662
659
  */
663
660
  get headTitle(): string {
664
661
  if (this.typeKind === 'primitive') {
665
- if (this.typeName === 'Long') {
662
+ // longNotInteger: 兼容 long 需要显示为 long 的情况,默认 undefined
663
+ if (this.typeName === 'Long' && !this.longNotInteger) {
666
664
  return `Integer ${PRIMITIVE_TITLE[this.typeName] || ''}`;
667
665
  }
668
666
  return `${this.typeName} ${PRIMITIVE_TITLE[this.typeName] || ''}`;
669
- }
670
- if (this.typeKind === 'reference') {
667
+ } else if (this.typeKind === 'reference') {
671
668
  const typeNamespace = this?.typeNamespace;
672
669
  let typeTitle = this.typeName;
673
670
  if (typeNamespace && this.rootNode) {
@@ -680,19 +677,17 @@ export class TypeAnnotation extends BaseNode {
680
677
  }
681
678
  }
682
679
  return typeTitle;
683
- }
684
- if (this.typeKind === 'generic') {
680
+ } else if (this.typeKind === 'generic') {
685
681
  if (this.typeArguments && this.typeArguments.length)
686
682
  return `${this.typeName}<${(this.typeArguments || []).map((arg) => arg.headTitle || arg.name || 'T').join(', ')}>`;
687
- return this.typeName;
688
- }
689
- if (this.typeKind === 'anonymousStructure') {
683
+ else return this.typeName;
684
+ } else if (this.typeKind === 'anonymousStructure') {
690
685
  return `{ ${this.properties?.map(({ name, typeAnnotation }) => `${name}: ${typeAnnotation.headTitle}`).join(', ')} }`;
691
- }
692
- if (this.typeKind === 'union') {
686
+ } else if (this.typeKind === 'union') {
693
687
  return `${this.typeArguments.map((arg) => arg.typeTitle || arg.name).join(' 或 ')}`;
688
+ } else {
689
+ return this.typeName;
694
690
  }
695
- return this.typeName;
696
691
  }
697
692
 
698
693
  /**
@@ -704,20 +699,17 @@ export class TypeAnnotation extends BaseNode {
704
699
  return `Integer ${PRIMITIVE_TITLE[this.typeName] || ''}`;
705
700
  }
706
701
  return `${this.typeName} ${PRIMITIVE_TITLE[this.typeName] || ''}`;
707
- }
708
- if (this.typeKind === 'reference') {
702
+ } else if (this.typeKind === 'reference') {
709
703
  return this.typeName;
710
- }
711
- if (this.typeKind === 'generic') {
704
+ } else if (this.typeKind === 'generic') {
712
705
  return `${this.typeName}<${!this.typeArguments.length ? 'T' : this.typeArguments.map((arg) => arg.typeTitle || arg.name || 'T').join(', ')}>`;
713
- }
714
- if (this.typeKind === 'anonymousStructure') {
706
+ } else if (this.typeKind === 'anonymousStructure') {
715
707
  return `{ ${this.properties?.map(({ name, typeAnnotation }) => `${name}: ${typeAnnotation ? typeAnnotation.typeTitle : '未知'}`).join(', ')} }`;
716
- }
717
- if (this.typeKind === 'union') {
708
+ } else if (this.typeKind === 'union') {
718
709
  return `${this.typeArguments.map((arg) => arg.typeTitle || arg.name).join(' 或 ')}`;
710
+ } else {
711
+ return this.typeName;
719
712
  }
720
- return this.typeName;
721
713
  }
722
714
 
723
715
  /**
@@ -729,23 +721,21 @@ export class TypeAnnotation extends BaseNode {
729
721
  return 'Integer';
730
722
  }
731
723
  return this.typeName;
732
- }
733
- if (this.typeKind === 'reference') {
724
+ } else if (this.typeKind === 'reference') {
734
725
  return this.typeName;
735
- }
736
- if (this.typeKind === 'generic') {
737
- return `${this.typeName}<${!this.typeArguments.length ? 'T' : this.typeArguments.map((arg) => arg.typeInlineTitle || arg.name || 'T').join(', ')
738
- }>`;
739
- }
740
- if (this.typeKind === 'anonymousStructure') {
726
+ } else if (this.typeKind === 'generic') {
727
+ return `${this.typeName}<${
728
+ !this.typeArguments.length ? 'T' : this.typeArguments.map((arg) => arg.typeInlineTitle || arg.name || 'T').join(', ')
729
+ }>`;
730
+ } else if (this.typeKind === 'anonymousStructure') {
741
731
  return `{ ${this.properties
742
732
  ?.map(({ name, typeAnnotation }) => `${name}: ${typeAnnotation ? typeAnnotation.typeInlineTitle : '未知'}`)
743
733
  .join(', ')} }`;
744
- }
745
- if (this.typeKind === 'union') {
734
+ } else if (this.typeKind === 'union') {
746
735
  return `${this.typeArguments.map((arg) => arg.typeInlineTitle || arg.name).join(' 或 ')}`;
736
+ } else {
737
+ return this.typeName;
747
738
  }
748
- return this.typeName;
749
739
  }
750
740
 
751
741
  /**
@@ -754,22 +744,19 @@ export class TypeAnnotation extends BaseNode {
754
744
  get typeChineseTitle(): string {
755
745
  if (this.typeKind === 'primitive') {
756
746
  return `${PRIMITIVE_TITLE[this.typeName] || ''}`;
757
- }
758
- if (this.typeKind === 'reference') {
747
+ } else if (this.typeKind === 'reference') {
759
748
  return this.typeName;
760
- }
761
- if (this.typeKind === 'generic') {
749
+ } else if (this.typeKind === 'generic') {
762
750
  return `${this.typeName}<${this.typeArguments.map((arg) => arg.typeChineseTitle || arg.name || 'T').join(', ')}>`;
763
- }
764
- if (this.typeKind === 'anonymousStructure') {
751
+ } else if (this.typeKind === 'anonymousStructure') {
765
752
  return `{ ${this.properties
766
753
  ?.map(({ name, typeAnnotation }) => `${name}: ${typeAnnotation ? typeAnnotation.typeChineseTitle : '未知'}`)
767
754
  .join(', ')} }`;
768
- }
769
- if (this.typeKind === 'union') {
755
+ } else if (this.typeKind === 'union') {
770
756
  return `${this.typeArguments.map((arg) => arg.typeChineseTitle || arg.name).join(' 或 ')}`;
757
+ } else {
758
+ return this.typeName;
771
759
  }
772
- return this.typeName;
773
760
  }
774
761
 
775
762
  get typeTitleList() {
@@ -810,26 +797,68 @@ export class TypeAnnotation extends BaseNode {
810
797
 
811
798
  static createPrimitive(typeName: string, source?: Partial<TypeAnnotation>) {
812
799
  if ((PRIMITIVE_TYPE as any)[typeName]) {
813
- return this.from({ typeKind: typeName === 'Union' ? 'union' : 'primitive', typeName, typeNamespace: 'nasl.core', ...source });
800
+ return this.from(
801
+ Object.assign(
802
+ {
803
+ typeKind: typeName === 'Union' ? 'union' : 'primitive',
804
+ typeName,
805
+ typeNamespace: 'nasl.core',
806
+ },
807
+ source
808
+ )
809
+ );
814
810
  }
815
811
  }
816
812
 
817
813
  static createReference(typeName: string, source?: Partial<TypeAnnotation>) {
818
- return this.from({ typeKind: 'reference', typeName, typeNamespace: 'nasl.core', ...source });
814
+ return this.from(
815
+ Object.assign(
816
+ {
817
+ typeKind: 'reference',
818
+ typeName,
819
+ typeNamespace: 'nasl.core',
820
+ },
821
+ source
822
+ )
823
+ );
819
824
  }
820
825
 
821
826
  static createGeneric(typeName: string, source?: Partial<TypeAnnotation>) {
822
- return this.from({ typeKind: 'generic', typeName, typeNamespace: 'nasl.collection', ...source });
827
+ return this.from(
828
+ Object.assign(
829
+ {
830
+ typeKind: 'generic',
831
+ typeName,
832
+ typeNamespace: 'nasl.collection',
833
+ },
834
+ source
835
+ )
836
+ );
823
837
  }
824
838
 
825
839
  static createTypeParam(typeName: string, source?: Partial<TypeAnnotation>) {
826
- return this.from({ typeKind: 'typeParam', typeName, ...source });
840
+ return this.from(
841
+ Object.assign(
842
+ {
843
+ typeKind: 'typeParam',
844
+ typeName,
845
+ },
846
+ source
847
+ )
848
+ );
827
849
  }
828
850
 
829
851
  static createTypeAnonymousStructure(properties: Array<StructureProperty>, source?: Partial<TypeAnnotation>) {
830
- return this.from({ typeKind: 'anonymousStructure', properties, ...source });
852
+ return this.from(
853
+ Object.assign(
854
+ {
855
+ typeKind: 'anonymousStructure',
856
+ properties,
857
+ },
858
+ source
859
+ )
860
+ );
831
861
  }
832
-
833
862
  /**
834
863
  * 设置类型属性名称
835
864
  */
@@ -873,14 +902,13 @@ export class TypeAnnotation extends BaseNode {
873
902
  }
874
903
 
875
904
  @withSourceMap()
876
- toEmbeddedTS(state?: TranslatorState): string {
905
+ toEmbeddedTS(state = createCompilerState()): string {
877
906
  if (this.typeKind === 'primitive' || this.typeKind === 'reference') {
878
907
  if (this.typeKind === 'reference' && this.typeNamespace && this.typeNamespace.endsWith('enums')) {
879
908
  return `${this.tsCalleeNamespace}.${this.typeName}`;
880
909
  }
881
910
  return `${this.tsCalleeNamespace}.${this.typeName}`;
882
- }
883
- if (this.typeKind === 'generic') {
911
+ } else if (this.typeKind === 'generic') {
884
912
  let code = `${this.tsCalleeNamespace}.${this.typeName}<`;
885
913
  (this.typeArguments || []).forEach((arg, index) => {
886
914
  code += arg.toEmbeddedTS(shiftState(state, code, { inline: true }));
@@ -888,16 +916,14 @@ export class TypeAnnotation extends BaseNode {
888
916
  });
889
917
  code += '>';
890
918
  return code;
891
- }
892
- if (this.typeKind === 'union') {
919
+ } else if (this.typeKind === 'union') {
893
920
  let code = '';
894
921
  (this.typeArguments || []).forEach((arg, index) => {
895
922
  code += arg.toEmbeddedTS(shiftState(state, code, { inline: true }));
896
923
  if (index !== this.typeArguments.length - 1) code += ' | ';
897
924
  });
898
925
  return code;
899
- }
900
- if (this.typeKind === 'anonymousStructure') {
926
+ } else if (this.typeKind === 'anonymousStructure') {
901
927
  let code = `{ `;
902
928
  (this.properties || []).forEach((property, i) => {
903
929
  code += `${property.name}: `;
@@ -910,18 +936,19 @@ export class TypeAnnotation extends BaseNode {
910
936
  code += `__name: "AStructure_${this.hash}" `;
911
937
  code += ' }';
912
938
  return code;
939
+ } else {
940
+ if (this.tsCalleeNamespace && this.typeName) {
941
+ return `${this.tsCalleeNamespace}.${this.typeName}`;
942
+ } else if (this.typeName) {
943
+ return this.typeName;
944
+ } else {
945
+ return '__IDENTIFIER__';
946
+ }
913
947
  }
914
- if (this.tsCalleeNamespace && this.typeName) {
915
- return `${this.tsCalleeNamespace}.${this.typeName}`;
916
- }
917
- if (this.typeName) {
918
- return this.typeName;
919
- }
920
- return '__IDENTIFIER__';
921
948
  }
922
949
 
923
950
  @withSourceMap()
924
- toNaturalTS(state?: TranslatorState): string {
951
+ toNaturalTS(state = createCompilerState()): string {
925
952
  if (this.typeKind === 'primitive' || this.typeKind === 'reference') {
926
953
  if (this.typeKind === 'reference' && this.typeNamespace && this.typeNamespace.endsWith('enums')) {
927
954
  return this.tsCalleeNamespace.startsWith('nasl.ui') ? `${this.tsCalleeNamespace}.${this.typeName}` : `${this.typeName}`;
@@ -971,8 +998,7 @@ export class TypeAnnotation extends BaseNode {
971
998
  get anonymousStructureTypeDesc(): string {
972
999
  if (this.typeKind === 'generic') {
973
1000
  return `${this.typeName}<${this.typeArguments.map((arg) => arg.anonymousStructureTypeDesc || arg.name || 'T').join(', ')}>`;
974
- }
975
- if (this.typeKind === 'anonymousStructure') {
1001
+ } else if (this.typeKind === 'anonymousStructure') {
976
1002
  return `{ ${[...this.properties]
977
1003
  .sort(({ name: aName }, { name: bName }) => {
978
1004
  if (aName > bName) return 1;
@@ -980,8 +1006,9 @@ export class TypeAnnotation extends BaseNode {
980
1006
  })
981
1007
  .map(({ name, typeAnnotation }) => `${name}: ${typeAnnotation ? typeAnnotation.anonymousStructureTypeDesc : '未知'}`)
982
1008
  .join(', ')} }`;
1009
+ } else {
1010
+ return this.typeName;
983
1011
  }
984
- return this.typeName;
985
1012
  }
986
1013
 
987
1014
  /**
@@ -996,12 +1023,14 @@ export class TypeAnnotation extends BaseNode {
996
1023
  if (this.typeKind === 'primitive') {
997
1024
  if (this.typeName === 'String') {
998
1025
  code = ` new nasl.core.String("${value}") `;
999
- } else if (['Text'].includes(this.typeName)) {
1000
- code = ` new ${this.typeNamespace}.${this.typeName}("${value}")`;
1001
- } else if (['Boolean'].includes(this.typeName)) {
1002
- code = value;
1003
1026
  } else {
1004
- code = ` new ${this.typeNamespace}.${this.typeName}(${value})`;
1027
+ if (['Text'].includes(this.typeName)) {
1028
+ code = ` new ${this.typeNamespace}.${this.typeName}("${value}")`;
1029
+ } else if (['Boolean'].includes(this.typeName)) {
1030
+ code = value;
1031
+ } else {
1032
+ code = ` new ${this.typeNamespace}.${this.typeName}(${value})`;
1033
+ }
1005
1034
  }
1006
1035
  } else {
1007
1036
  code = ` ${this.typeNamespace}.${this.typeName}['${value}']`;
@@ -1024,20 +1053,15 @@ export class TypeAnnotation extends BaseNode {
1024
1053
  const BooleanReg = /(false|true|\u662f|\u5426)/i;
1025
1054
  if (EmailReg.test(code)) {
1026
1055
  return this.createPrimitive('String');
1027
- }
1028
- if (TimeReg.test(code)) {
1056
+ } else if (TimeReg.test(code)) {
1029
1057
  return this.createPrimitive('Time');
1030
- }
1031
- if (BooleanReg.test(code)) {
1058
+ } else if (BooleanReg.test(code)) {
1032
1059
  return this.createPrimitive('Boolean');
1033
- }
1034
- if (DateReg.test(code)) {
1060
+ } else if (DateReg.test(code)) {
1035
1061
  return this.createPrimitive('Date');
1036
- }
1037
- if (DateTimeReg.test(code)) {
1062
+ } else if (DateTimeReg.test(code)) {
1038
1063
  return this.createPrimitive('DateTime');
1039
- }
1040
- if (!isNaN(Number(code))) {
1064
+ } else if (!isNaN(Number(code))) {
1041
1065
  if (code.indexOf('.') !== -1) {
1042
1066
  return this.createPrimitive('Decimal');
1043
1067
  // return this.createPrimitive('Decimal');
@@ -1046,15 +1070,14 @@ export class TypeAnnotation extends BaseNode {
1046
1070
  return this.createPrimitive('Long');
1047
1071
  }
1048
1072
  return this.createPrimitive('Long');
1049
- }
1050
- if (code.length > 255) {
1073
+ } else if (code.length > 255) {
1051
1074
  return this.createPrimitive('String');
1052
1075
  }
1053
1076
  return this.createPrimitive('String');
1077
+ } else {
1078
+ return this.createPrimitive('Long');
1054
1079
  }
1055
- return this.createPrimitive('Long');
1056
1080
  }
1057
-
1058
1081
  // 增加插入泛型子类型
1059
1082
  typeArgumentsPush(typeItem: TypeAnnotation) {
1060
1083
  if (typeItem instanceof TypeAnnotation) {
@@ -1072,12 +1095,11 @@ export class TypeAnnotation extends BaseNode {
1072
1095
  const namespaceType = this.typeNamespace?.split('.').pop();
1073
1096
  return ['Map', 'List'].includes(this.typeName) || (this.typeKind === 'reference' && ['entities', 'structures'].includes(namespaceType));
1074
1097
  }
1075
-
1076
1098
  /* 类型签名 */
1077
1099
  get sign() {
1078
1100
  let str: string = '';
1079
1101
  if (['Map', 'List'].includes(this.typeName)) {
1080
- str += `${this.typeName}<`;
1102
+ str += this.typeName + '<';
1081
1103
  (this.typeArguments || []).forEach((item, index) => {
1082
1104
  str += item.sign;
1083
1105
  if (index + 1 !== this.typeArguments.length) {
@@ -1114,8 +1136,7 @@ export class TypeAnnotation extends BaseNode {
1114
1136
  if (item && item.concept === 'TypeAnnotation') {
1115
1137
  if (item.typeKind === 'anonymousStructure') {
1116
1138
  return item.properties.some((prop) => traverseChild(prop.typeAnnotation, cb));
1117
- }
1118
- if (item.typeArguments && ['generic', 'union'].includes(item.typeKind)) {
1139
+ } else if (item.typeArguments && ['generic', 'union'].includes(item.typeKind)) {
1119
1140
  return item.typeArguments.some((arg) => traverseChild(arg, cb));
1120
1141
  }
1121
1142
  }
@@ -1123,14 +1144,13 @@ export class TypeAnnotation extends BaseNode {
1123
1144
  let result = false;
1124
1145
  traverseChild(this, (node: TypeAnnotation) => {
1125
1146
  if (node.typeNamespace?.endsWith('.structures')) {
1126
- const structure = this.rootNode.findNodeByCompleteName(`${node.typeNamespace}.${node.typeName}`);
1147
+ const structure = this.rootNode.findNodeByCompleteName(node.typeNamespace + '.' + node.typeName);
1127
1148
  const res = !structure.properties.some((prop: StructureProperty) => prop.typeAnnotation.hasSystemType());
1128
1149
  if (res === false) {
1129
1150
  result = true;
1130
1151
  }
1131
1152
  return res;
1132
- }
1133
- if (disableTypeNamespaces.includes(node.typeNamespace)) {
1153
+ } else if (disableTypeNamespaces.includes(node.typeNamespace)) {
1134
1154
  result = true;
1135
1155
  return false;
1136
1156
  }
@@ -1138,15 +1158,15 @@ export class TypeAnnotation extends BaseNode {
1138
1158
  return result;
1139
1159
  }
1140
1160
 
1141
- //= ===============================================================================
1161
+ //================================================================================
1142
1162
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
1143
1163
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
1144
- //= ===============================================================================
1164
+ //================================================================================
1145
1165
  }
1146
1166
 
1147
1167
  classMap.TypeAnnotation = TypeAnnotation;
1148
1168
  export default TypeAnnotation;
1149
- //= ===============================================================================
1169
+ //================================================================================
1150
1170
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1151
1171
  // 自动生成的代码已结束。下面可以手动编写。
1152
- //= ===============================================================================
1172
+ //================================================================================
@@ -1,5 +1,5 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
- import { TranslatorState, withSourceMap } from '../translator';
2
+ import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
3
3
 
4
4
  //= ===============================================================================
5
5
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -61,7 +61,7 @@ export class TypeParam extends BaseNode {
61
61
  }
62
62
 
63
63
  @withSourceMap()
64
- toNaturalTS(state?: TranslatorState, prefix?: string): string {
64
+ toNaturalTS(state = createCompilerState(), prefix?: string): string {
65
65
  return this.name;
66
66
  }
67
67
 
@@ -1,5 +1,5 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
- import { TranslatorState, shiftState, withSourceMap } from '../translator';
2
+ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from '../translator';
3
3
  import { ElementToVueOptions } from './ViewElement__';
4
4
 
5
5
  //= ===============================================================================
@@ -153,7 +153,7 @@ export class UnaryExpression extends LogicItem {
153
153
  }
154
154
 
155
155
  @withSourceMap()
156
- toEmbeddedTS(state?: TranslatorState): string {
156
+ toEmbeddedTS(state = createCompilerState()): string {
157
157
  if (this.operator === 'isNull') {
158
158
  const fnName = this.operator.toUpperCase();
159
159
  let code = '';
@@ -173,7 +173,7 @@ export class UnaryExpression extends LogicItem {
173
173
  }
174
174
 
175
175
  @withSourceMap()
176
- toNaturalTS(state?: TranslatorState): string {
176
+ toNaturalTS(state = createCompilerState()): string {
177
177
  if (this.operator === 'isNull') {
178
178
  let code = '((';
179
179
  code += this.argument?.toNaturalTS ? this.argument.toNaturalTS(shiftState(state, '', { inline: true })) : '__IDENTIFIER__';