@lcap/nasl 1.0.1 → 2.12.0-beta.1

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 (364) hide show
  1. package/out/automate/engine/index.d.ts +1 -0
  2. package/out/automate/engine/index.js +34 -12
  3. package/out/automate/engine/index.js.map +1 -1
  4. package/out/automate/engine/operators.d.ts +10 -2
  5. package/out/automate/engine/operators.js +105 -7
  6. package/out/automate/engine/operators.js.map +1 -1
  7. package/out/automate/engine/uniqueName.d.ts +8 -2
  8. package/out/automate/engine/uniqueName.js +72 -4
  9. package/out/automate/engine/uniqueName.js.map +1 -1
  10. package/out/automate/engine/utils.d.ts +1 -0
  11. package/out/automate/engine/utils.js +108 -67
  12. package/out/automate/engine/utils.js.map +1 -1
  13. package/out/automate/template/process.d.ts +9 -0
  14. package/out/automate/template/process.js +10976 -0
  15. package/out/automate/template/process.js.map +1 -0
  16. package/out/bak/translator.js +1 -0
  17. package/out/bak/translator.js.map +1 -1
  18. package/out/common/BaseNode.d.ts +6 -1
  19. package/out/common/BaseNode.js +37 -6
  20. package/out/common/BaseNode.js.map +1 -1
  21. package/out/concepts/App__.d.ts +52 -49
  22. package/out/concepts/App__.js +89 -53
  23. package/out/concepts/App__.js.map +1 -1
  24. package/out/concepts/Assignee__.d.ts +11 -0
  25. package/out/concepts/Assignee__.js +34 -0
  26. package/out/concepts/Assignee__.js.map +1 -1
  27. package/out/concepts/BindAttribute__.js +2 -2
  28. package/out/concepts/BindAttribute__.js.map +1 -1
  29. package/out/concepts/BindDirective__.js +10 -3
  30. package/out/concepts/BindDirective__.js.map +1 -1
  31. package/out/concepts/BindEvent__.js +15 -6
  32. package/out/concepts/BindEvent__.js.map +1 -1
  33. package/out/concepts/BooleanLiteral__.d.ts +4 -0
  34. package/out/concepts/BooleanLiteral__.js +11 -0
  35. package/out/concepts/BooleanLiteral__.js.map +1 -1
  36. package/out/concepts/CallFunction__.js +9 -4
  37. package/out/concepts/CallFunction__.js.map +1 -1
  38. package/out/concepts/CallLogic__.js +48 -30
  39. package/out/concepts/CallLogic__.js.map +1 -1
  40. package/out/concepts/CallQueryComponent__.d.ts +34 -4
  41. package/out/concepts/CallQueryComponent__.js +340 -95
  42. package/out/concepts/CallQueryComponent__.js.map +1 -1
  43. package/out/concepts/Comment__.js +1 -1
  44. package/out/concepts/Comment__.js.map +1 -1
  45. package/out/concepts/ConfigGroup__.d.ts +1 -0
  46. package/out/concepts/ConfigGroup__.js +7 -0
  47. package/out/concepts/ConfigGroup__.js.map +1 -1
  48. package/out/concepts/ConfigProperty__.d.ts +1 -0
  49. package/out/concepts/ConfigProperty__.js +3 -0
  50. package/out/concepts/ConfigProperty__.js.map +1 -1
  51. package/out/concepts/Configuration__.d.ts +1 -0
  52. package/out/concepts/Configuration__.js +3 -0
  53. package/out/concepts/Configuration__.js.map +1 -1
  54. package/out/concepts/Constant__.js +6 -6
  55. package/out/concepts/Constant__.js.map +1 -1
  56. package/out/concepts/DataSource__.d.ts +143 -0
  57. package/out/concepts/DataSource__.js +318 -0
  58. package/out/concepts/DataSource__.js.map +1 -0
  59. package/out/concepts/Destination__.js +22 -8
  60. package/out/concepts/Destination__.js.map +1 -1
  61. package/out/concepts/End__.js +2 -2
  62. package/out/concepts/End__.js.map +1 -1
  63. package/out/concepts/EntityIndex__.d.ts +5 -0
  64. package/out/concepts/EntityIndex__.js +10 -2
  65. package/out/concepts/EntityIndex__.js.map +1 -1
  66. package/out/concepts/EntityProperty__.d.ts +9 -0
  67. package/out/concepts/EntityProperty__.js +22 -7
  68. package/out/concepts/EntityProperty__.js.map +1 -1
  69. package/out/concepts/Entity__.d.ts +6 -0
  70. package/out/concepts/Entity__.js +27 -11
  71. package/out/concepts/Entity__.js.map +1 -1
  72. package/out/concepts/Enum__.d.ts +1 -0
  73. package/out/concepts/Enum__.js +14 -4
  74. package/out/concepts/Enum__.js.map +1 -1
  75. package/out/concepts/ForEachStatement__.js +2 -2
  76. package/out/concepts/ForEachStatement__.js.map +1 -1
  77. package/out/concepts/Function__.d.ts +18 -0
  78. package/out/concepts/Function__.js +96 -1
  79. package/out/concepts/Function__.js.map +1 -1
  80. package/out/concepts/Identifier__.js +5 -14
  81. package/out/concepts/Identifier__.js.map +1 -1
  82. package/out/concepts/IfStatement__.js +8 -8
  83. package/out/concepts/IfStatement__.js.map +1 -1
  84. package/out/concepts/InterfaceParam__.js +9 -4
  85. package/out/concepts/InterfaceParam__.js.map +1 -1
  86. package/out/concepts/Interface__.js +19 -12
  87. package/out/concepts/Interface__.js.map +1 -1
  88. package/out/concepts/JSBlock__.js +3 -5
  89. package/out/concepts/JSBlock__.js.map +1 -1
  90. package/out/concepts/Logic__.js +44 -44
  91. package/out/concepts/Logic__.js.map +1 -1
  92. package/out/concepts/Module__.d.ts +116 -194
  93. package/out/concepts/Module__.js +31 -114
  94. package/out/concepts/Module__.js.map +1 -1
  95. package/out/concepts/Namespace__.d.ts +0 -86
  96. package/out/concepts/Namespace__.js +1 -108
  97. package/out/concepts/Namespace__.js.map +1 -1
  98. package/out/concepts/Param__.d.ts +3 -2
  99. package/out/concepts/Param__.js +15 -8
  100. package/out/concepts/Param__.js.map +1 -1
  101. package/out/concepts/ProcessElement__.js +38 -12
  102. package/out/concepts/ProcessElement__.js.map +1 -1
  103. package/out/concepts/Process__.d.ts +1 -1
  104. package/out/concepts/Process__.js +17 -10
  105. package/out/concepts/Process__.js.map +1 -1
  106. package/out/concepts/QueryAggregateExpression__.js +1 -1
  107. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  108. package/out/concepts/QueryFieldExpression__.d.ts +1 -0
  109. package/out/concepts/QueryFieldExpression__.js +11 -1
  110. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  111. package/out/concepts/QueryFromExpression__.d.ts +4 -0
  112. package/out/concepts/QueryFromExpression__.js +13 -2
  113. package/out/concepts/QueryFromExpression__.js.map +1 -1
  114. package/out/concepts/QueryGroupByExpression__.d.ts +3 -0
  115. package/out/concepts/QueryGroupByExpression__.js +20 -0
  116. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  117. package/out/concepts/QueryJoinExpression__.d.ts +4 -0
  118. package/out/concepts/QueryJoinExpression__.js +14 -3
  119. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  120. package/out/concepts/Return__.d.ts +1 -1
  121. package/out/concepts/Return__.js +16 -11
  122. package/out/concepts/Return__.js.map +1 -1
  123. package/out/concepts/Role__.js +10 -3
  124. package/out/concepts/Role__.js.map +1 -1
  125. package/out/concepts/SqlQueryComponent__.d.ts +14 -0
  126. package/out/concepts/SqlQueryComponent__.js +48 -5
  127. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  128. package/out/concepts/StringLiteral__.d.ts +1 -1
  129. package/out/concepts/StringLiteral__.js +2 -9
  130. package/out/concepts/StringLiteral__.js.map +1 -1
  131. package/out/concepts/StructureProperty__.js +11 -10
  132. package/out/concepts/StructureProperty__.js.map +1 -1
  133. package/out/concepts/Structure__.js +19 -12
  134. package/out/concepts/Structure__.js.map +1 -1
  135. package/out/concepts/SwitchCase__.d.ts +1 -1
  136. package/out/concepts/SwitchCase__.js +23 -25
  137. package/out/concepts/SwitchCase__.js.map +1 -1
  138. package/out/concepts/SwitchStatement__.js +1 -6
  139. package/out/concepts/SwitchStatement__.js.map +1 -1
  140. package/out/concepts/TypeAnnotation__.d.ts +8 -0
  141. package/out/concepts/TypeAnnotation__.js +53 -3
  142. package/out/concepts/TypeAnnotation__.js.map +1 -1
  143. package/out/concepts/Variable__.d.ts +1 -1
  144. package/out/concepts/Variable__.js +16 -11
  145. package/out/concepts/Variable__.js.map +1 -1
  146. package/out/concepts/ViewElement__.js +25 -20
  147. package/out/concepts/ViewElement__.js.map +1 -1
  148. package/out/concepts/View__.d.ts +1 -3
  149. package/out/concepts/View__.js +42 -36
  150. package/out/concepts/View__.js.map +1 -1
  151. package/out/concepts/WhileStatement__.js +4 -4
  152. package/out/concepts/WhileStatement__.js.map +1 -1
  153. package/out/concepts/basics/stdlib/nasl.auth.js +20 -0
  154. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
  155. package/out/concepts/basics/stdlib/nasl.configuration.js +1 -1
  156. package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
  157. package/out/concepts/basics/stdlib/nasl.interface.d.ts +2 -0
  158. package/out/concepts/basics/stdlib/nasl.interface.js +4 -4
  159. package/out/concepts/basics/stdlib/nasl.interface.js.map +1 -1
  160. package/out/concepts/basics/stdlib/nasl.process.d.ts +4 -0
  161. package/out/concepts/basics/stdlib/nasl.process.js +410 -0
  162. package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
  163. package/out/concepts/basics/stdlib/nasl.ui.js +1 -11
  164. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  165. package/out/concepts/basics/stdlib/nasl.util.js +270 -8
  166. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  167. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +1 -1
  168. package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js.map +1 -1
  169. package/out/concepts/basics/types/index.d.ts +2 -0
  170. package/out/concepts/basics/types/index.js +6 -1
  171. package/out/concepts/basics/types/index.js.map +1 -1
  172. package/out/concepts/index__.d.ts +1 -0
  173. package/out/concepts/index__.js +1 -0
  174. package/out/concepts/index__.js.map +1 -1
  175. package/out/enums/KEYWORDS.js +0 -7
  176. package/out/enums/KEYWORDS.js.map +1 -1
  177. package/out/generator/genBundleFiles.d.ts +3 -1
  178. package/out/generator/genBundleFiles.js +23 -5
  179. package/out/generator/genBundleFiles.js.map +1 -1
  180. package/out/generator/genMetaData.d.ts +1 -0
  181. package/out/generator/genMetaData.js +20 -12
  182. package/out/generator/genMetaData.js.map +1 -1
  183. package/out/index.d.ts +1 -1
  184. package/out/index.js +2 -1
  185. package/out/index.js.map +1 -1
  186. package/out/manager/diagnostic.d.ts +1 -1
  187. package/out/server/createUiTs.js +1 -0
  188. package/out/server/createUiTs.js.map +1 -1
  189. package/out/{test/integration/connect-file copy.d.ts → server/extendBaseNode.d.ts} +0 -0
  190. package/out/server/extendBaseNode.js +323 -0
  191. package/out/server/extendBaseNode.js.map +1 -0
  192. package/out/server/getLogics.js +49 -2
  193. package/out/server/getLogics.js.map +1 -1
  194. package/out/server/getMemberIdentifier.js +52 -2
  195. package/out/server/getMemberIdentifier.js.map +1 -1
  196. package/out/server/getProcesses.d.ts +8 -2
  197. package/out/server/getProcesses.js +228 -20
  198. package/out/server/getProcesses.js.map +1 -1
  199. package/out/server/getScope.d.ts +1 -0
  200. package/out/server/getScope.js +4 -0
  201. package/out/server/getScope.js.map +1 -1
  202. package/out/server/index.d.ts +1 -0
  203. package/out/server/index.js +1 -0
  204. package/out/server/index.js.map +1 -1
  205. package/out/server/naslServer.d.ts +8 -5
  206. package/out/server/naslServer.js +314 -383
  207. package/out/server/naslServer.js.map +1 -1
  208. package/out/server/process2LogicNamespace.js +10 -1
  209. package/out/server/process2LogicNamespace.js.map +1 -1
  210. package/out/server/translator.d.ts +1 -1
  211. package/out/server/translator.js +40 -2
  212. package/out/server/translator.js.map +1 -1
  213. package/out/service/creator/errHandles.js +5 -0
  214. package/out/service/creator/errHandles.js.map +1 -1
  215. package/out/service/storage/init.d.ts +1 -0
  216. package/out/service/storage/init.js +113 -94
  217. package/out/service/storage/init.js.map +1 -1
  218. package/out/templator/genCreateBlock.js +34 -24
  219. package/out/templator/genCreateBlock.js.map +1 -1
  220. package/out/templator/genCurdEditMultipleKeyBlock.js +28 -18
  221. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  222. package/out/templator/genCurdMultipleKeyBlock.js +45 -29
  223. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  224. package/out/templator/genEditTableBlock.js +15 -13
  225. package/out/templator/genEditTableBlock.js.map +1 -1
  226. package/out/templator/genEnumSelectBlock.js +1 -1
  227. package/out/templator/genEnumSelectBlock.js.map +1 -1
  228. package/out/templator/genGetBlock.js +1 -1
  229. package/out/templator/genGetBlock.js.map +1 -1
  230. package/out/templator/genGridViewBlock.js +29 -24
  231. package/out/templator/genGridViewBlock.js.map +1 -1
  232. package/out/templator/genListViewBlock.js +7 -5
  233. package/out/templator/genListViewBlock.js.map +1 -1
  234. package/out/templator/genQueryComponent.js +31 -29
  235. package/out/templator/genQueryComponent.js.map +1 -1
  236. package/out/templator/genSelectBlock.js +13 -22
  237. package/out/templator/genSelectBlock.js.map +1 -1
  238. package/out/templator/genTableBlock.js +31 -21
  239. package/out/templator/genTableBlock.js.map +1 -1
  240. package/out/templator/genUpdateBlock.js +35 -25
  241. package/out/templator/genUpdateBlock.js.map +1 -1
  242. package/out/templator/utils.d.ts +5 -3
  243. package/out/templator/utils.js +2 -1
  244. package/out/templator/utils.js.map +1 -1
  245. package/out/test/integration/connect-file.js +6 -6
  246. package/out/test/integration/connect-file.js.map +1 -1
  247. package/out/translator/index.js +1 -1
  248. package/out/translator/index.js.map +1 -1
  249. package/out/utils/index.d.ts +5 -0
  250. package/out/utils/index.js +50 -1
  251. package/out/utils/index.js.map +1 -1
  252. package/package.json +1 -2
  253. package/src/automate/engine/index.js +33 -8
  254. package/src/automate/engine/operators.js +114 -17
  255. package/src/automate/engine/uniqueName.js +77 -9
  256. package/src/automate/engine/utils.js +110 -69
  257. package/src/automate/template/process.js +10999 -0
  258. package/src/bak/translator.js +1 -0
  259. package/src/common/BaseNode.ts +35 -7
  260. package/src/concepts/App__.ts +132 -131
  261. package/src/concepts/Assignee__.ts +30 -0
  262. package/src/concepts/BindAttribute__.ts +2 -2
  263. package/src/concepts/BindDirective__.ts +9 -7
  264. package/src/concepts/BindEvent__.ts +14 -6
  265. package/src/concepts/BooleanLiteral__.ts +12 -0
  266. package/src/concepts/CallFunction__.ts +7 -4
  267. package/src/concepts/CallLogic__.ts +47 -32
  268. package/src/concepts/CallQueryComponent__.ts +352 -101
  269. package/src/concepts/Comment__.ts +1 -1
  270. package/src/concepts/ConfigGroup__.ts +3 -1
  271. package/src/concepts/ConfigProperty__.ts +4 -0
  272. package/src/concepts/Configuration__.ts +3 -0
  273. package/src/concepts/Constant__.ts +6 -6
  274. package/src/concepts/DataSource__.ts +391 -0
  275. package/src/concepts/Destination__.ts +22 -8
  276. package/src/concepts/End__.ts +2 -2
  277. package/src/concepts/EntityIndex__.ts +11 -2
  278. package/src/concepts/EntityProperty__.ts +23 -7
  279. package/src/concepts/Entity__.ts +38 -14
  280. package/src/concepts/Enum__.ts +15 -4
  281. package/src/concepts/ForEachStatement__.ts +2 -2
  282. package/src/concepts/Function__.ts +95 -1
  283. package/src/concepts/Identifier__.ts +5 -14
  284. package/src/concepts/IfStatement__.ts +9 -9
  285. package/src/concepts/InterfaceParam__.ts +9 -4
  286. package/src/concepts/Interface__.ts +20 -12
  287. package/src/concepts/JSBlock__.ts +3 -12
  288. package/src/concepts/Logic__.ts +45 -79
  289. package/src/concepts/Module__.ts +141 -342
  290. package/src/concepts/Namespace__.ts +1 -204
  291. package/src/concepts/Param__.ts +17 -9
  292. package/src/concepts/ProcessElement__.ts +42 -15
  293. package/src/concepts/Process__.ts +18 -12
  294. package/src/concepts/QueryAggregateExpression__.ts +1 -1
  295. package/src/concepts/QueryFieldExpression__.ts +13 -1
  296. package/src/concepts/QueryFromExpression__.ts +13 -2
  297. package/src/concepts/QueryGroupByExpression__.ts +23 -0
  298. package/src/concepts/QueryJoinExpression__.ts +14 -3
  299. package/src/concepts/Return__.ts +16 -11
  300. package/src/concepts/Role__.ts +10 -4
  301. package/src/concepts/SqlQueryComponent__.ts +47 -11
  302. package/src/concepts/StringLiteral__.ts +2 -9
  303. package/src/concepts/StructureProperty__.ts +11 -14
  304. package/src/concepts/Structure__.ts +19 -11
  305. package/src/concepts/SwitchCase__.ts +23 -27
  306. package/src/concepts/SwitchStatement__.ts +1 -5
  307. package/src/concepts/TypeAnnotation__.ts +52 -3
  308. package/src/concepts/Variable__.ts +16 -11
  309. package/src/concepts/ViewElement__.ts +26 -39
  310. package/src/concepts/View__.ts +45 -38
  311. package/src/concepts/WhileStatement__.ts +4 -4
  312. package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
  313. package/src/concepts/basics/stdlib/nasl.configuration.ts +1 -1
  314. package/src/concepts/basics/stdlib/nasl.interface.ts +1 -1
  315. package/src/concepts/basics/stdlib/nasl.process.ts +406 -0
  316. package/src/concepts/basics/stdlib/nasl.ui.ts +1 -11
  317. package/src/concepts/basics/stdlib/nasl.util.ts +271 -8
  318. package/src/concepts/basics/stdlib/reference2TypeAnnotationList.ts +1 -1
  319. package/src/concepts/basics/types/index.ts +2 -0
  320. package/src/concepts/index__.ts +1 -0
  321. package/src/enums/KEYWORDS.ts +0 -7
  322. package/src/generator/genBundleFiles.ts +28 -7
  323. package/src/generator/genMetaData.ts +22 -13
  324. package/src/index.ts +1 -1
  325. package/src/manager/diagnostic.ts +1 -1
  326. package/src/server/createUiTs.ts +1 -0
  327. package/src/server/extendBaseNode.ts +318 -0
  328. package/src/server/getLogics.ts +51 -5
  329. package/src/server/getMemberIdentifier.ts +53 -2
  330. package/src/server/getProcesses.ts +238 -21
  331. package/src/server/getScope.ts +5 -0
  332. package/src/server/index.ts +1 -0
  333. package/src/server/naslServer.ts +322 -380
  334. package/src/server/process2LogicNamespace.ts +29 -19
  335. package/src/server/translator.ts +42 -2
  336. package/src/service/creator/errHandles.js +6 -0
  337. package/src/service/storage/init.ts +115 -97
  338. package/src/templator/genCreateBlock.ts +35 -26
  339. package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -21
  340. package/src/templator/genCurdMultipleKeyBlock.ts +46 -31
  341. package/src/templator/genEditTableBlock.ts +17 -14
  342. package/src/templator/genEnumSelectBlock.ts +1 -1
  343. package/src/templator/genGetBlock.ts +1 -1
  344. package/src/templator/genGridViewBlock.ts +30 -25
  345. package/src/templator/genListViewBlock.ts +10 -7
  346. package/src/templator/genQueryComponent.ts +34 -30
  347. package/src/templator/genSelectBlock.ts +14 -23
  348. package/src/templator/genTableBlock.ts +32 -23
  349. package/src/templator/genUpdateBlock.ts +36 -26
  350. package/src/templator/utils.ts +5 -2
  351. package/src/test/integration/connect-file.ts +6 -6
  352. package/src/translator/index.ts +1 -1
  353. package/src/utils/index.ts +51 -0
  354. package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +0 -3
  355. package/out/concepts/basics/stdlib/nasl.browser copy.js +0 -70
  356. package/out/concepts/basics/stdlib/nasl.browser copy.js.map +0 -1
  357. package/out/terms/LEVEL_NAME_MAP.d.ts +0 -26
  358. package/out/terms/LEVEL_NAME_MAP.js +0 -30
  359. package/out/terms/LEVEL_NAME_MAP.js.map +0 -1
  360. package/out/test/integration/connect-file copy.js +0 -50
  361. package/out/test/integration/connect-file copy.js.map +0 -1
  362. package/out/test/integration/node-nasl-server.d.ts +0 -1
  363. package/out/test/integration/node-nasl-server.js +0 -41
  364. package/out/test/integration/node-nasl-server.js.map +0 -1
@@ -104,7 +104,7 @@ export class Role extends BaseNode {
104
104
  toEmbeddedTS(state?: TranslatorState): string {
105
105
  let code = `export enum ${this.tsName} {\n`;
106
106
  code += ` ${this.tsName}='${this.tsName}'\n`;
107
- code += indent(state.tabSize) + '}\n';
107
+ code += indent((state?.tabSize || 0)) + '}\n';
108
108
 
109
109
  return code;
110
110
  }
@@ -117,9 +117,15 @@ export class Role extends BaseNode {
117
117
  }
118
118
 
119
119
  getNamespace() {
120
- if (this.parentNode && (this.parentNode as Namespace).getNamespace)
121
- return `${(this.parentNode as Namespace).getNamespace()}.roles`;
122
- else
120
+ if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
121
+ const parentNamespace = (this.parentNode as Namespace).getNamespace();
122
+ const parentName = this.parentNode.name;
123
+ const arr = [parentNamespace];
124
+ if (this.parentNode.concept !== 'App' && parentName) {
125
+ arr.push(parentName);
126
+ }
127
+ return `${arr.join('.')}.roles`;
128
+ } else
123
129
  throw new Error('无法获取命名空间,请设置 parentNode!');
124
130
  }
125
131
 
@@ -42,7 +42,11 @@ export class SqlQueryComponent extends LogicItem {
42
42
  @property('TypeAnnotation')
43
43
  typeAnnotation: TypeAnnotation = undefined;
44
44
 
45
-
45
+ /**
46
+ * 局部版本
47
+ */
48
+ @property()
49
+ ideVersion: string = undefined;
46
50
 
47
51
  /**
48
52
  * @param source 需要合并的部分参数
@@ -57,7 +61,6 @@ export class SqlQueryComponent extends LogicItem {
57
61
  return super.from(source, parentNode, parentKey) as SqlQueryComponent;
58
62
  }
59
63
 
60
-
61
64
  /**
62
65
  * 设置SQL 查询
63
66
  */
@@ -70,10 +73,6 @@ export class SqlQueryComponent extends LogicItem {
70
73
  });
71
74
  }
72
75
 
73
-
74
-
75
-
76
-
77
76
  /**
78
77
  * 删除类型标注
79
78
  * @param name 类型标注名称
@@ -126,22 +125,59 @@ export class SqlQueryComponent extends LogicItem {
126
125
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
127
126
  // 自动生成的代码已结束。下面可以手动编写。
128
127
  //================================================================================
128
+
129
+ @property()
130
+ dataSource: string = undefined;
131
+
132
+ /**
133
+ * 设置SQL 查询
134
+ */
135
+ setDataSource(dataSource: string) {
136
+ const object = {
137
+ dataSource,
138
+ };
139
+ this.update({
140
+ ...object,
141
+ });
142
+ }
143
+
129
144
  @withSourceMap()
130
145
  toEmbeddedTS(state?: TranslatorState): string {
131
- let code = `(function(): nasl.collection.List<`
132
- code +=`${this.typeAnnotation ? this.typeAnnotation.toEmbeddedTS(shiftState(state, code)): '__IDENTIFIER__'}> {\n`;
146
+ let code;
147
+ if (this.ideVersion === '2.11') {
148
+ code = `(function(): `;
149
+ code += `${this.typeAnnotation ? this.typeAnnotation.toEmbeddedTS(shiftState(state, code)) : '__IDENTIFIER__'} {\n`;
150
+ } else {
151
+ code = `(function(): nasl.collection.List<`;
152
+ code += `${this.typeAnnotation ? this.typeAnnotation.toEmbeddedTS(shiftState(state, code)) : '__IDENTIFIER__'}> {\n`;
153
+ }
154
+ // app.dataSources.defaultDS;
155
+ if (this.dataSource) {
156
+ code += indent((state?.tabSize || 0) + 1);
157
+ code += `const dataSource = app.dataSources.${this.dataSource};`;
158
+ }
133
159
  code += '\n';
134
- code += indent(state.tabSize + 1) + 'return;\n';
135
- code += indent(state.tabSize) + '})();\n';
160
+ code += indent((state?.tabSize || 0) + 1) + 'return;\n';
161
+ code += indent((state?.tabSize || 0)) + '})();\n';
136
162
  return code;
137
163
  }
164
+
165
+ /**
166
+ * 获取添加时的默认选项
167
+ * @returns
168
+ */
169
+ public static getDefaultOptions(): any {
170
+ return {
171
+ dataSource: 'defaultDS',
172
+ };
173
+ }
138
174
  //================================================================================
139
175
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
140
176
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
141
177
  //================================================================================
142
178
  }
143
179
 
144
- classMap['SqlQueryComponent'] = SqlQueryComponent;
180
+ classMap.SqlQueryComponent = SqlQueryComponent;
145
181
  export default SqlQueryComponent;
146
182
  //================================================================================
147
183
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -94,14 +94,7 @@ export class StringLiteral extends LogicItem {
94
94
  toEmbeddedTS(state?: TranslatorState, isRequired?: boolean): string {
95
95
  let code = '';
96
96
  if (typeof this.value === 'string') {
97
- if (!this.value.includes("'"))
98
- code += `'${this.value}'`;
99
- else if (!this.value.includes('"'))
100
- code += `"${this.value}"`;
101
- else if (!this.value.includes('`'))
102
- code += `\`${this.value}\``;
103
- else
104
- code += `'${this.value.replace(/'/g, "\\'")}'`;
97
+ code += `'StringLiteral'`;
105
98
  } else {
106
99
  code += isRequired ? '__IDENTIFIER__' : `''`;
107
100
  }
@@ -109,7 +102,7 @@ export class StringLiteral extends LogicItem {
109
102
  }
110
103
 
111
104
  /**
112
- * 设置数组内容
105
+ * 设置字符串内容
113
106
  */
114
107
  setValue(value: string) {
115
108
  const object = {
@@ -171,10 +171,6 @@ export class StructureProperty extends BaseNode {
171
171
  });
172
172
  }
173
173
 
174
-
175
-
176
-
177
-
178
174
  /**
179
175
  * 删除类型标注
180
176
  * @param name 类型标注名称
@@ -251,7 +247,7 @@ export class StructureProperty extends BaseNode {
251
247
  const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
252
248
  let completionChildren;
253
249
  if (typeKind === 'reference') {
254
- if (typeNamespace === 'nasl.ui') {
250
+ if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process') {
255
251
  const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
256
252
  const properties = node.properties || [];
257
253
  completionChildren = properties;
@@ -263,11 +259,11 @@ export class StructureProperty extends BaseNode {
263
259
  completionChildren = properties;
264
260
  }
265
261
  } else if (typeKind === 'generic') {
266
- if (typeNamespace === 'nasl.collection') {
267
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
268
- const properties = node.properties || [];
269
- completionChildren = properties;
270
- }
262
+ // if (typeNamespace === 'nasl.collection' || typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.interface') {
263
+ // }
264
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
265
+ const properties = node.properties || [];
266
+ completionChildren = properties;
271
267
  } else {
272
268
  completionChildren = undefined;
273
269
  }
@@ -284,9 +280,10 @@ export class StructureProperty extends BaseNode {
284
280
  code += ': ';
285
281
  code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
286
282
  }
287
- if (this.defaultValue) {
288
- code += ` = ${this.defaultValue}`;
289
- } // else
283
+ // StructureProperty 暂不支持默认值
284
+ // if (this.defaultValue) {
285
+ // code += ` = ${this.defaultValue}`;
286
+ // }
290
287
  return code;
291
288
  }
292
289
 
@@ -345,7 +342,7 @@ export class StructureProperty extends BaseNode {
345
342
  //================================================================================
346
343
  }
347
344
 
348
- classMap['StructureProperty'] = StructureProperty;
345
+ classMap.StructureProperty = StructureProperty;
349
346
  export default StructureProperty;
350
347
  //================================================================================
351
348
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -531,34 +531,42 @@ export class Structure extends BaseNode {
531
531
  @withSourceMap()
532
532
  toEmbeddedTS(state?: TranslatorState): string {
533
533
  let code = `export class ${this.tsName} {\n`;
534
- code += indent(state.tabSize + 1);
534
+ code += indent((state?.tabSize || 0) + 1);
535
535
  code += `__name: '${this.getTsNamespace()}.${this.tsName}';\n`;
536
536
  this.properties.forEach((property) => {
537
- code += indent(state.tabSize + 1);
537
+ code += indent((state?.tabSize || 0) + 1);
538
538
  code += property.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
539
539
  code += ';\n';
540
540
  });
541
- code += indent(state.tabSize) + '}\n';
541
+ code += indent((state?.tabSize || 0)) + '}\n';
542
542
 
543
543
  return code;
544
544
  }
545
545
 
546
546
  getNamespace() {
547
547
  if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
548
- return `${(this.parentNode as Namespace).getNamespace()}.structures`;
548
+ const parentNamespace = (this.parentNode as Namespace).getNamespace();
549
+ const parentName = this.parentNode.name;
550
+ const arr = [parentNamespace];
551
+ if (this.parentNode.concept !== 'App' && parentName) {
552
+ arr.push(parentName);
553
+ }
554
+ return `${arr.join('.')}.structures`;
549
555
  } else
550
556
  throw new Error('无法获取命名空间,请设置 parentNode!');
551
557
  }
552
558
 
553
559
  getTsNamespace() {
554
- if (this.parentNode.concept === 'App') {
555
- return `${(this.parentNode as Namespace).getNamespace()}.structures`;
556
- } else {
557
- if (this.parentNode && (this.parentNode as Namespace).getTsNamespace) {
558
- return `${(this.parentNode as Namespace).getTsNamespace()}.structures`;
559
- } else {
560
- throw new Error('无法获取命名空间,请设置 parentNode!');
560
+ if (this.parentNode && (this.parentNode as Namespace).getTsNamespace) {
561
+ const parentNamespace = (this.parentNode as Namespace).getTsNamespace();
562
+ const parentName = this.parentNode.tsName || this.parentNode.name;
563
+ const arr = [parentNamespace];
564
+ if (this.parentNode.concept !== 'App' && parentName) {
565
+ arr.push(parentName);
561
566
  }
567
+ return `${arr.join('.')}.structures`;
568
+ } else {
569
+ throw new Error('无法获取命名空间,请设置 parentNode!');
562
570
  }
563
571
  }
564
572
 
@@ -241,37 +241,33 @@ export class SwitchCase extends LogicItem {
241
241
  // 自动生成的代码已结束。下面可以手动编写。
242
242
  //================================================================================
243
243
 
244
- toJS(state?: TranslatorState, isLast?: boolean): string {
244
+ toJS(state?: TranslatorState, index?: number, length?: number): string {
245
245
  let code = '';
246
- if (!isLast) {
246
+ if (index === 0) {
247
247
  code = 'if (';
248
248
  code += this.test ? this.test.toJS(shiftState(state, code, {
249
249
  tabSize: 0,
250
250
  })) : '';
251
-
252
251
  code += ') {\n';
253
-
254
- if (Array.isArray(this.consequent)) {
255
- this.consequent.forEach((logicItem) => {
256
- code
257
- += logicItem.toJS(shiftState(state, code, {
258
- tabSize: 0,
259
- })) + '\n';
260
- });
261
- }
262
- code += '}\n';
252
+ } else if (index !== length - 1) {
253
+ code = 'else if (';
254
+ code += this.test ? this.test.toJS(shiftState(state, code, {
255
+ tabSize: 0,
256
+ })) : '';
257
+ code += ') {\n';
263
258
  } else {
264
259
  code += 'else {\n';
265
- if (Array.isArray(this.consequent)) {
266
- this.consequent.forEach((logicItem) => {
267
- code
268
- += logicItem.toJS(shiftState(state, code, {
269
- tabSize: 0,
270
- })) + '\n';
271
- });
272
- }
273
- code += '}\n';
274
260
  }
261
+ if (Array.isArray(this.consequent)) {
262
+ this.consequent.forEach((logicItem) => {
263
+ code
264
+ += logicItem.toJS(shiftState(state, code, {
265
+ tabSize: 0,
266
+ })) + '\n';
267
+ });
268
+ }
269
+ code += '}\n';
270
+
275
271
  return code;
276
272
  }
277
273
 
@@ -281,7 +277,7 @@ export class SwitchCase extends LogicItem {
281
277
  if (!isLast) {
282
278
  code += 'if (nasl.core.ensureBoolean(';
283
279
  code += this.test ? this.test.toEmbeddedTS(shiftState(state, code, {
284
- tabSize: state.tabSize + 1,
280
+ tabSize: (state?.tabSize || 0) + 1,
285
281
  })) : '__IDENTIFIER__';
286
282
 
287
283
  code += ')) {\n';
@@ -290,22 +286,22 @@ export class SwitchCase extends LogicItem {
290
286
  this.consequent.forEach((logicItem) => {
291
287
  code
292
288
  += logicItem.toEmbeddedTS(shiftState(state, code, {
293
- tabSize: state.tabSize + 1,
289
+ tabSize: (state?.tabSize || 0) + 1,
294
290
  })) + '\n';
295
291
  });
296
292
  }
297
- code += indent(state.tabSize) + '}\n';
293
+ code += indent((state?.tabSize || 0)) + '}\n';
298
294
  } else {
299
295
  code += 'else {\n';
300
296
  if (Array.isArray(this.consequent)) {
301
297
  this.consequent.forEach((logicItem) => {
302
298
  code
303
299
  += logicItem.toEmbeddedTS(shiftState(state, code, {
304
- tabSize: state.tabSize + 1,
300
+ tabSize: (state?.tabSize || 0) + 1,
305
301
  })) + '\n';
306
302
  });
307
303
  }
308
- code += indent(state.tabSize) + '}\n';
304
+ code += indent((state?.tabSize || 0)) + '}\n';
309
305
  }
310
306
 
311
307
  return code;
@@ -213,11 +213,7 @@ export class SwitchStatement extends LogicItem {
213
213
  let code = '';
214
214
  this.cases.forEach((item, index) => {
215
215
  // 如果是最后一项
216
- if (index === this.cases.length - 1) {
217
- code += item.toJS(state, true);
218
- } else {
219
- code += item.toJS(state);
220
- }
216
+ code += item.toJS(state, index, this.cases.length);
221
217
  });
222
218
  return code;
223
219
  }
@@ -261,14 +261,25 @@ export class TypeAnnotation extends BaseNode {
261
261
  /**
262
262
  * 用于展示的 type 标题
263
263
  */
264
- get typeTitle(): string {
264
+ get headTitle(): string {
265
265
  if (this.typeKind === 'primitive') {
266
266
  return `${this.typeName} ${PRIMITIVE_TITLE[this.typeName]}`;
267
267
  } else if (this.typeKind === 'reference') {
268
- return `${this.typeName}`;
268
+ const typeNamespace = this?.typeNamespace;
269
+ let typeTitle = this.typeName;
270
+ if (typeNamespace && this.rootNode) {
271
+ const entity = (this.rootNode as any).findNodeByCompleteName([typeNamespace, this?.typeName].join('.'));
272
+ if (entity?.concept === 'Entity') {
273
+ const dataSourceName = entity.dataSource?.name;
274
+ if (dataSourceName) {
275
+ typeTitle += `(${dataSourceName})`;
276
+ }
277
+ }
278
+ }
279
+ return typeTitle;
269
280
  } else if (this.typeKind === 'generic') {
270
281
  if (this.typeArguments && this.typeArguments.length)
271
- return `${this.typeName}<${(this.typeArguments || []).map((arg) => arg.typeName || 'T')}>`;
282
+ return `${this.typeName}<${(this.typeArguments || []).map((arg) => arg.headTitle || 'T')}>`;
272
283
  else
273
284
  return this.typeName;
274
285
  } else {
@@ -276,6 +287,32 @@ export class TypeAnnotation extends BaseNode {
276
287
  }
277
288
  }
278
289
 
290
+ /**
291
+ * 用于展示的 type 标题
292
+ */
293
+ get typeTitle(): string {
294
+ if (this.typeKind === 'primitive') {
295
+ return `${this.typeName} ${PRIMITIVE_TITLE[this.typeName]}`;
296
+ } else if (this.typeKind === 'reference') {
297
+ return this.typeName;
298
+ } else if (this.typeKind === 'generic') {
299
+ let str = `${this.typeName}`;
300
+ const loop = (typeArguments: Array<TypeAnnotation>) => {
301
+ str += '<' + (typeArguments[0].typeTitle || 'T');
302
+ if (typeArguments[0].typeKind === 'generic') {
303
+ if (this.typeArguments && this.typeArguments.length) {
304
+ loop(typeArguments[0].typeArguments);
305
+ }
306
+ }
307
+ str += '>';
308
+ };
309
+ loop(this.typeArguments);
310
+ return str;
311
+ } else {
312
+ return this.typeName;
313
+ }
314
+ }
315
+
279
316
  static createPrimitive(typeName: string, source?: Partial<TypeAnnotation>) {
280
317
  if ((PRIMITIVE_TYPE as any)[typeName]) {
281
318
  return this.from(Object.assign({
@@ -321,6 +358,18 @@ export class TypeAnnotation extends BaseNode {
321
358
  });
322
359
  }
323
360
 
361
+ /**
362
+ * 设置类型字段名称
363
+ */
364
+ setTypeNamespace(typeNamespace: string) {
365
+ const object = {
366
+ typeNamespace,
367
+ };
368
+ this.update({
369
+ ...object,
370
+ });
371
+ }
372
+
324
373
  get tsCalleeNamespace() {
325
374
  if (this.typeNamespace) {
326
375
  let tsCalleeNamespace = this.typeNamespace;
@@ -253,9 +253,9 @@ export class Variable extends BaseNode {
253
253
  code += ': undefined as ';
254
254
  code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
255
255
  }
256
- if (this.defaultValue) {
257
- code += `: ${this.defaultValue}`;
258
- }
256
+ // if (this.defaultValue) {
257
+ // code += `: ${this.defaultValue}`;
258
+ // }
259
259
  return code;
260
260
  }
261
261
 
@@ -281,7 +281,7 @@ export class Variable extends BaseNode {
281
281
  }
282
282
  // 处理下拉属性
283
283
  try {
284
- this.completionChildren = this.getSelectRef();
284
+ this.completionChildren = this.getSelectRef(typeAnnotation);
285
285
  } catch (err) {
286
286
  this.completionChildren = [];
287
287
  console.log(err);
@@ -324,12 +324,12 @@ export class Variable extends BaseNode {
324
324
  get isTreeLeaf() {
325
325
  return !this.hasChildren;
326
326
  }
327
- getSelectRef() {
327
+ getSelectRef(newTypeAnnotation: TypeAnnotation) {
328
328
  try {
329
- const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
329
+ const { typeName, typeKind, typeNamespace } = newTypeAnnotation || this.typeAnnotation;
330
330
  let completionChildren;
331
331
  if (typeKind === 'reference') {
332
- if (typeNamespace === 'nasl.ui') {
332
+ if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process') {
333
333
  const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
334
334
  const properties = node.properties || [];
335
335
  completionChildren = properties;
@@ -341,11 +341,16 @@ export class Variable extends BaseNode {
341
341
  completionChildren = properties;
342
342
  }
343
343
  } else if (typeKind === 'generic') {
344
- if (typeNamespace === 'nasl.collection') {
345
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
346
- const properties = node.properties || [];
347
- completionChildren = properties;
344
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
345
+ const properties = node.properties || [];
346
+ for (let i = 0; i < properties.length; i++) {
347
+ const item = properties[i];
348
+ if (item?.typeAnnotation?.typeKind === 'typeParam') {
349
+ properties[i].typeAnnotation = this?.typeAnnotation?.typeArguments[0];
350
+ properties[i].parentNode = this;
351
+ }
348
352
  }
353
+ completionChildren = properties;
349
354
  } else {
350
355
  completionChildren = undefined;
351
356
  }