@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
@@ -15,6 +15,7 @@ import classMap from '../common/classMap';
15
15
  import EntityProperty from './EntityProperty__';
16
16
  import EntityIndex from './EntityIndex__';
17
17
  import Module from './Module__';
18
+ import DataSource from './DataSource__';
18
19
  import App from './App__';
19
20
 
20
21
  /**
@@ -82,6 +83,12 @@ export class Entity extends BaseNode {
82
83
  get app() {
83
84
  return this.getAncestor('App') as App;
84
85
  }
86
+ /**
87
+ * 祖先 DataSource
88
+ */
89
+ get dataSource() {
90
+ return this.getAncestor('DataSource') as DataSource;
91
+ }
85
92
 
86
93
  /**
87
94
  * @param source 需要合并的部分参数
@@ -107,7 +114,6 @@ export class Entity extends BaseNode {
107
114
  }
108
115
  return params;
109
116
  }
110
-
111
117
  /**
112
118
  * 设置实体描述
113
119
  */
@@ -120,7 +126,7 @@ export class Entity extends BaseNode {
120
126
  });
121
127
  }
122
128
 
123
- getPropertyExistingNames(excludedList: Array<EntityProperty> = []) {
129
+ getPropertyExistingNames(excludedList: Array<EntityProperty> = []) {
124
130
  const excludedSet = new Set(excludedList);
125
131
  return (this.properties || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
126
132
  }
@@ -261,6 +267,7 @@ export class Entity extends BaseNode {
261
267
  return node;
262
268
  }
263
269
 
270
+
264
271
  getEntityIndexExistingNames(excludedList: Array<EntityIndex> = []) {
265
272
  const excludedSet = new Set(excludedList);
266
273
  return (this.indexes || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
@@ -402,6 +409,9 @@ export class Entity extends BaseNode {
402
409
  return node;
403
410
  }
404
411
 
412
+
413
+
414
+
405
415
  /**
406
416
  * 删除实体字段
407
417
  * @param name 实体字段名称
@@ -450,6 +460,8 @@ export class Entity extends BaseNode {
450
460
  return params;
451
461
  }
452
462
 
463
+
464
+
453
465
  /**
454
466
  * 删除实体索引
455
467
  * @param name 实体索引名称
@@ -503,6 +515,13 @@ export class Entity extends BaseNode {
503
515
  // 自动生成的代码已结束。下面可以手动编写。
504
516
  //================================================================================
505
517
 
518
+ getPropertyExistingNameList(excludedList: Array<EntityProperty> = []) {
519
+ const excludedSet = Array.from(new Set(excludedList));
520
+ const namelist = excludedSet.map((item) => item.name);
521
+ console.log(namelist);
522
+
523
+ return (this.properties || []).filter((item) => !namelist.includes(item.name)).map((item) => item.name);
524
+ }
506
525
  /**
507
526
  * 设置实体表名并修改表名
508
527
  */
@@ -632,40 +651,45 @@ export class Entity extends BaseNode {
632
651
  @withSourceMap()
633
652
  toEmbeddedTS(state?: TranslatorState): string {
634
653
  let code = `export class ${this.name} {\n`;
635
- code += indent(state.tabSize + 1);
654
+ code += indent((state?.tabSize || 0) + 1);
636
655
  code += `__name: '${this.getNamespace()}.${this.name}';\n`;
637
656
  this.properties.forEach((property) => {
638
- code += indent(state.tabSize + 1);
657
+ code += indent((state?.tabSize || 0) + 1);
639
658
  code += property.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
640
659
  code += ';\n';
641
660
  });
642
661
  if (this.indexes && this.indexes.length) {
643
- code += indent(state.tabSize + 1);
662
+ code += indent((state?.tabSize || 0) + 1);
644
663
  code += `__IndexList() {\n`;
645
664
  code += ` return [`;
646
665
  this.indexes.forEach((entityIndex) => {
647
- code += indent(state.tabSize + 1);
666
+ code += indent((state?.tabSize || 0) + 1);
648
667
  code += '\n ';
649
668
  code += entityIndex.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
650
669
  });
651
- code += indent(state.tabSize) + `\n ];\n }\n`;
670
+ code += indent((state?.tabSize || 0)) + `\n ];\n }\n`;
652
671
  }
653
672
 
654
673
  const ns = this.ns;
674
+
675
+ /**
676
+ * 8个函数的总行数
677
+ * 如果修改这里,可能会影响到dataSource的重命名, 在naslserver中,可能要一起修改
678
+ */
655
679
  code += `\nstatic logics = {\n`;
656
680
  ns.logics.forEach((logic) => {
657
- code += indent(state.tabSize + 1);
681
+ code += indent((state?.tabSize || 0) + 1);
658
682
  code += logic.toEmbeddedTS(shiftState(state, code), 'inObject');
659
683
  });
660
684
  code += '}\n';
661
- code += indent(state.tabSize) + '}\n';
685
+ code += indent((state?.tabSize || 0)) + '}\n';
662
686
 
663
687
  return code;
664
688
  }
665
689
 
666
690
  getNamespace() {
667
- if (this.parentNode && (this.parentNode as Namespace).getNamespace)
668
- return `${(this.parentNode as Namespace).getNamespace()}.entities`;
691
+ if (this.parentNode && (this.parentNode as DataSource).getNamespace)
692
+ return `${(this.parentNode as DataSource).getNamespace()}.${this.parentNode.name}.entities`;
669
693
  else
670
694
  throw new Error('无法获取命名空间,请设置 parentNode!');
671
695
  }
@@ -675,12 +699,12 @@ export class Entity extends BaseNode {
675
699
  * @param name 一般不用传,用于 rename
676
700
  */
677
701
  getEmbeddedFilePath(name = this.name) {
678
- return `/embedded/${this.app.name}/entities/${name}.ts`;
702
+ return `/embedded/${this.app.name}/datasources/${this.parentNode.name}/entities/${name}.ts`;
679
703
  }
680
704
 
681
705
  get ns() {
682
706
  const ns: Namespace = entity2LogicNamespace(this);
683
- ns.path = this.getNamespace() + '.' + ns.name;
707
+ ns.path = this.getNamespace();
684
708
  return ns;
685
709
  }
686
710
  // @excludedInJSON()
@@ -716,7 +740,7 @@ export class Entity extends BaseNode {
716
740
  //================================================================================
717
741
  }
718
742
 
719
- classMap.Entity = Entity;
743
+ classMap['Entity'] = Entity;
720
744
  export default Entity;
721
745
  //================================================================================
722
746
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -286,13 +286,18 @@ export class Enum extends BaseNode {
286
286
  @property()
287
287
  isLeaf: boolean = true;
288
288
 
289
+ getEnumItemExistingNames(excludedList: Array<EnumItem> = []) {
290
+ const excludedSet = new Set(excludedList);
291
+ return (this.enumItems || []).filter((item) => !excludedSet.has(item)).map((item) => item.value);
292
+ }
293
+
289
294
  @withSourceMap()
290
295
  toEmbeddedTS(state?: TranslatorState): string {
291
296
  let code = `export class ${this.name} extends nasl.core.Enums {\n`;
292
297
  // 增加一个单独的标签
293
- code += indent(state.tabSize + 1) + `__name: '${this.getNamespace()}.${this.name}';\n`;
298
+ code += indent((state?.tabSize || 0) + 1) + `__name: '${this.getNamespace()}.${this.name}';\n`;
294
299
  this.enumItems.forEach((property) => {
295
- code += indent(state.tabSize + 1);
300
+ code += indent((state?.tabSize || 0) + 1);
296
301
  code += property.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
297
302
  code += ';\n';
298
303
  });
@@ -306,14 +311,20 @@ export class Enum extends BaseNode {
306
311
  return str;
307
312
  }
308
313
  `;
309
- code += indent(state.tabSize) + '}\n';
314
+ code += indent((state?.tabSize || 0)) + '}\n';
310
315
 
311
316
  return code;
312
317
  }
313
318
 
314
319
  getNamespace() {
315
320
  if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
316
- return `${(this.parentNode as Namespace).getNamespace()}.enums`;
321
+ const parentNamespace = (this.parentNode as Namespace).getNamespace();
322
+ const parentName = this.parentNode.name;
323
+ const arr = [parentNamespace];
324
+ if (this.parentNode.concept !== 'App' && parentName) {
325
+ arr.push(parentName);
326
+ }
327
+ return `${arr.join('.')}.enums`;
317
328
  } else
318
329
  throw new Error('无法获取命名空间,请设置 parentNode!');
319
330
  }
@@ -548,11 +548,11 @@ export class ForEachStatement extends LogicItem {
548
548
  this.body.forEach((logicItem) => {
549
549
  code
550
550
  += logicItem.toEmbeddedTS(shiftState(state, code, {
551
- tabSize: state.tabSize + 1,
551
+ tabSize: (state?.tabSize || 0) + 1,
552
552
  })) + '\n';
553
553
  });
554
554
  }
555
- code += indent(state.tabSize) + '})\n';
555
+ code += indent((state?.tabSize || 0)) + '})\n';
556
556
 
557
557
  return code;
558
558
  }
@@ -1,4 +1,7 @@
1
1
  import Namespace from './Namespace__';
2
+ import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
3
+ import LogicItem from './LogicItem__';
4
+
2
5
  //================================================================================
3
6
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
4
7
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -886,7 +889,72 @@ export class Function extends BaseNode {
886
889
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
887
890
  // 自动生成的代码已结束。下面可以手动编写。
888
891
  //================================================================================
892
+ /**
893
+ * returnExpression 输出的Lambda 表达式
894
+ */
895
+ @property('LogicItem')
896
+ returnExpression: LogicItem = undefined;
889
897
 
898
+ /**
899
+ * 设置returnExpression 输出的Lambda 表达式
900
+ */
901
+ setReturnExpression(expression: LogicItem) {
902
+ expression._delete();
903
+ const relationOptions = { parentNode: this, parentKey: 'returnExpression' };
904
+ Object.assign(expression, relationOptions);
905
+ const object = {
906
+ returnExpression: expression,
907
+ };
908
+ this.update({
909
+ ...object,
910
+ });
911
+ }
912
+
913
+ toJS(state?: TranslatorState): String {
914
+ let code = '';
915
+ code += '(';
916
+ this.params.forEach((param, index) => {
917
+ code += param.toJS(shiftState(state, code));
918
+ if (index !== this.params.length - 1) {
919
+ code += ',';
920
+ }
921
+ });
922
+ code += ')';
923
+ code += ' => (';
924
+ if (this.returnExpression) {
925
+ code += this.returnExpression.toJS(shiftState(state, code));
926
+ }
927
+ code += ')';
928
+ return code;
929
+ }
930
+
931
+ /**
932
+ * 刪除LogicItem
933
+ * @param logicItem
934
+ * @returns
935
+ */
936
+ __removeLogicItem(logicItem: LogicItem) {
937
+ const parentKey = logicItem.parentKey;
938
+ const params: Params = {
939
+ parentNode: this,
940
+ parentKey,
941
+ index: -1,
942
+ object: null,
943
+ oldObject: logicItem,
944
+ };
945
+ if (parentKey) {
946
+ params.parentKey = parentKey;
947
+ if (Array.isArray((this as any)[parentKey])) {
948
+ const index = (this as any)[parentKey].indexOf(logicItem);
949
+ ~index && (this as any)[parentKey].splice(index, 1);
950
+ params.index = index;
951
+ } else if ((this as any)[parentKey] === logicItem) {
952
+ params.index = 0;
953
+ (this as any)[parentKey] = undefined;
954
+ }
955
+ }
956
+ return params;
957
+ }
890
958
  getVarExistingNames(excludedList: Array<Param | Return | Variable> = []) {
891
959
  const excludedSet = new Set(excludedList);
892
960
  return [...this.params, ...this.returns, ...this.variables].filter((item) => !excludedSet.has(item)).map((item) => item.name);
@@ -895,13 +963,39 @@ export class Function extends BaseNode {
895
963
  if (this.parentNode) {
896
964
  let parentNodeNamespace = '';
897
965
  if ((this.parentNode as Namespace).getNamespace) {
898
- parentNodeNamespace = (this.parentNode as Namespace).getNamespace();
966
+ parentNodeNamespace = [(this.parentNode as Namespace).getNamespace(), this.parentNode.name].join('.');
899
967
  }
900
968
  return `${parentNodeNamespace}`;
901
969
  } else
902
970
  throw new Error('无法获取命名空间,请设置 parentNode!');
903
971
  }
972
+ @withSourceMap()
973
+ toEmbeddedTS(state?: TranslatorState): string {
974
+ let code = '';
975
+ if (this.returnExpression) {
976
+ code += `(`;
977
+ this.params.forEach((param, index) => {
978
+ code += param.toEmbeddedTS(shiftState(state, code, { inline: true }));
979
+ if (index !== this.params.length - 1)
980
+ code += ', ';
981
+ });
982
+ code += `)`;
983
+ if (this.returns.length) {
984
+ code += ': ';
985
+ code += this.returns[0].typeAnnotation.toEmbeddedTS(shiftState(state, code, { inline: true }));
986
+ }
987
+ code += ` => (`;
904
988
 
989
+ if (this.returnExpression) {
990
+ code += this.returnExpression.toEmbeddedTS && this.returnExpression.toEmbeddedTS(shiftState(state, code, { tabSize: state.tabSize + 1 }));
991
+ }
992
+ code += indent(state.tabSize) + ')';
993
+ } else {
994
+ code += '__IDENTIFIER__';
995
+ }
996
+
997
+ return code;
998
+ }
905
999
  get calleeKey() {
906
1000
  const calleeNamespace = this.getNamespace();
907
1001
  const calleeName = this.name;
@@ -1,6 +1,7 @@
1
1
  import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
2
2
  import { BindAttribute, CallFunction, CallLogic, Argument, MemberExpression, TypeAnnotation } from '..';
3
3
  import { ElementToVueOptions } from './ViewElement__';
4
+ import { findConceptKeyWordByNamespace } from '../utils';
4
5
 
5
6
  //================================================================================
6
7
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -77,25 +78,14 @@ export class Identifier extends LogicItem {
77
78
  };
78
79
 
79
80
  isEnum() {
80
- const namespace = this.namespace;
81
- if (namespace) {
82
- const namespaceArr = namespace.split('.');
83
- const start = namespaceArr.shift();
84
- if (start === 'app' || start === 'extensions') {
85
- const mod = start === 'app' ? 0 : 1;
86
- const keywordViews = namespaceArr.filter((namespaceItem, index) => index % 2 === mod);
87
- const last = keywordViews.pop();
88
- return last === 'enums';
89
- }
90
- }
91
- return false;
81
+ return findConceptKeyWordByNamespace(this.namespace) === 'enums';
92
82
  }
93
83
 
94
84
  toVue(options?: ElementToVueOptions): string {
95
85
  let name = this.name;
96
86
  const namespace = this.namespace;
97
87
  if (namespace) {
98
- if ((this.namespace.endsWith('nasl.browser') || this.namespace.endsWith('nasl.auth') || this.namespace.endsWith('nasl.configuration'))) {
88
+ if ((this.namespace.endsWith('nasl.browser') || this.namespace.endsWith('nasl.auth') || this.namespace.endsWith('nasl.configuration') || this.namespace.endsWith('nasl.process'))) {
99
89
  name = `$global.${this.name}`;
100
90
  } else if (this.isEnum()) {
101
91
  name = `$utils.EnumList("${this.name}")`;
@@ -136,7 +126,7 @@ export class Identifier extends LogicItem {
136
126
  let name = this.name;
137
127
  const namespace = this.namespace;
138
128
  if (namespace) {
139
- if (namespace.endsWith('nasl.browser') || namespace.endsWith('nasl.auth') || namespace.endsWith('nasl.configuration')) {
129
+ if (namespace.endsWith('nasl.browser') || namespace.endsWith('nasl.auth') || namespace.endsWith('nasl.configuration') || this.namespace.endsWith('nasl.process')) {
140
130
  name = `$global.${this.name}`;
141
131
  } else if (this.isEnum()) {
142
132
  name = `$utils.EnumList("${this.name}")`;
@@ -147,6 +137,7 @@ export class Identifier extends LogicItem {
147
137
  || namespace?.endsWith('nasl.browser')
148
138
  || namespace?.endsWith('nasl.auth')
149
139
  || namespace?.endsWith('nasl.configuration')
140
+ || namespace?.endsWith('nasl.process')
150
141
  || this.isEnum())
151
142
  && !isMemberExpressionProperty ? `this.${name}` : name;
152
143
  }
@@ -367,13 +367,13 @@ export class IfStatement extends LogicItem {
367
367
  public static getDefaultOptions() {
368
368
  return {
369
369
  label: '条件分支',
370
- }
370
+ };
371
371
  }
372
372
  toJS(state?: TranslatorState) {
373
373
  let code = '';
374
374
  code += 'if (';
375
375
  code += this.test ? this.test.toJS(shiftState(state, code, {
376
- tabSize: state.tabSize + 1,
376
+ tabSize: (state?.tabSize || 0) + 1,
377
377
  })) : '';
378
378
 
379
379
  code += ') {\n';
@@ -382,17 +382,17 @@ export class IfStatement extends LogicItem {
382
382
  this.consequent.forEach((logicItem) => {
383
383
  code
384
384
  += logicItem.toJS(shiftState(state, code, {
385
- tabSize: state.tabSize + 1,
385
+ tabSize: (state?.tabSize || 0) + 1,
386
386
  })) + '\n';
387
387
  });
388
388
  }
389
389
  code += '}';
390
390
  if (Array.isArray(this.alternate)) {
391
- code += indent(state.tabSize) + ' else {\n';
391
+ code += indent((state?.tabSize || 0)) + ' else {\n';
392
392
  this.alternate.forEach((logicItem) => {
393
393
  code
394
394
  += logicItem.toJS(shiftState(state, code, {
395
- tabSize: state.tabSize + 1,
395
+ tabSize: (state?.tabSize || 0) + 1,
396
396
  })) + '\n';
397
397
  });
398
398
  code += '}\n';
@@ -414,21 +414,21 @@ export class IfStatement extends LogicItem {
414
414
  this.consequent.forEach((logicItem) => {
415
415
  code
416
416
  += logicItem.toEmbeddedTS(shiftState(state, code, {
417
- tabSize: state.tabSize + 1,
417
+ tabSize: (state?.tabSize || 0) + 1,
418
418
  })) + '\n';
419
419
  });
420
420
  }
421
421
 
422
- code += indent(state.tabSize) + '}';
422
+ code += indent((state?.tabSize || 0)) + '}';
423
423
  if (Array.isArray(this.alternate)) {
424
424
  code += ' else {\n';
425
425
  this.alternate.forEach((logicItem) => {
426
426
  code
427
427
  += logicItem.toEmbeddedTS(shiftState(state, code, {
428
- tabSize: state.tabSize + 1,
428
+ tabSize: (state?.tabSize || 0) + 1,
429
429
  })) + '\n';
430
430
  });
431
- code += indent(state.tabSize) + '}\n';
431
+ code += indent((state?.tabSize || 0)) + '}\n';
432
432
  }
433
433
  return code;
434
434
  }
@@ -309,11 +309,16 @@ export class InterfaceParam extends BaseNode {
309
309
  completionChildren = properties;
310
310
  }
311
311
  } else if (typeKind === 'generic') {
312
- if (typeNamespace === 'nasl.collection') {
313
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
314
- const properties = node.properties || [];
315
- completionChildren = properties;
312
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
313
+ const properties = node.properties || [];
314
+ for (let i = 0; i < properties.length; i++) {
315
+ const item = properties[i];
316
+ if (item?.typeAnnotation?.typeKind === 'typeParam') {
317
+ properties[i].typeAnnotation = this?.typeAnnotation?.typeArguments[0];
318
+ properties[i].parentNode = this;
319
+ }
316
320
  }
321
+ completionChildren = properties;
317
322
  } else {
318
323
  completionChildren = undefined;
319
324
  }
@@ -581,7 +581,7 @@ export class Interface extends BaseNode {
581
581
  }
582
582
 
583
583
  get calleeKey(): string {
584
- return `${this.getTsNamespace()}.${this.name} `;
584
+ return `${this.getTsNamespace()}.${this.name}`;
585
585
  }
586
586
 
587
587
  get calleewholeKey() {
@@ -726,21 +726,29 @@ export class Interface extends BaseNode {
726
726
  }
727
727
 
728
728
  getNamespace() {
729
- if (this.parentNode && (this.parentNode as Namespace).getNamespace)
730
- return `${(this.parentNode as Namespace).getNamespace()}.interfaces`;
731
- else
729
+ if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
730
+ const parentNamespace = (this.parentNode as Namespace).getNamespace();
731
+ const parentName = this.parentNode.name;
732
+ const arr = [parentNamespace];
733
+ if (this.parentNode.concept !== 'App' && parentName) {
734
+ arr.push(parentName);
735
+ }
736
+ return `${arr.join('.')}.interfaces`;
737
+ } else
732
738
  throw new Error('无法获取命名空间,请设置 parentNode!');
733
739
  }
740
+
734
741
  getTsNamespace() {
735
- if (this.parentNode.concept === 'App') {
736
- return `${(this.parentNode as Namespace).getNamespace()}.interfaces`;
737
- } else {
738
- if (this.parentNode && (this.parentNode as Namespace).getTsNamespace) {
739
- return `${(this.parentNode as Namespace).getTsNamespace()}.interfaces`;
740
- } else {
741
- throw new Error('无法获取命名空间,请设置 parentNode!');
742
+ if (this.parentNode && (this.parentNode as Namespace).getTsNamespace) {
743
+ const parentNamespace = (this.parentNode as Namespace).getTsNamespace();
744
+ const parentName = this.parentNode.tsName || this.parentNode.name;
745
+ const arr = [parentNamespace];
746
+ if (this.parentNode.concept !== 'App' && parentName) {
747
+ arr.push(parentName);
742
748
  }
743
- }
749
+ return `${arr.join('.')}.interfaces`;
750
+ } else
751
+ throw new Error('无法获取命名空间,请设置 parentNode!');
744
752
  }
745
753
 
746
754
  getVarExistingNames(excludedList: Array<InterfaceParam | Return> = []) {
@@ -35,8 +35,6 @@ export class JSBlock extends LogicItem {
35
35
  @property()
36
36
  code: string = undefined;
37
37
 
38
-
39
-
40
38
  /**
41
39
  * @param source 需要合并的部分参数
42
40
  */
@@ -50,7 +48,6 @@ export class JSBlock extends LogicItem {
50
48
  return super.from(source, parentNode, parentKey) as JSBlock;
51
49
  }
52
50
 
53
-
54
51
  /**
55
52
  * 设置代码内容
56
53
  */
@@ -63,10 +60,6 @@ export class JSBlock extends LogicItem {
63
60
  });
64
61
  }
65
62
 
66
-
67
-
68
-
69
-
70
63
  //================================================================================
71
64
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
72
65
  // 自动生成的代码已结束。下面可以手动编写。
@@ -76,11 +69,9 @@ export class JSBlock extends LogicItem {
76
69
  /**
77
70
  * 生成 JS 脚本
78
71
  */
79
- return `const jsBlock_number = async () => {
72
+ return `await (async () => {
80
73
  ${this.code}
81
- }
82
-
83
- await jsBlock_number();`;
74
+ })();`;
84
75
  }
85
76
 
86
77
  toEmbeddedTS(state?: TranslatorState): string {
@@ -93,7 +84,7 @@ export class JSBlock extends LogicItem {
93
84
  //================================================================================
94
85
  }
95
86
 
96
- classMap['JSBlock'] = JSBlock;
87
+ classMap.JSBlock = JSBlock;
97
88
  export default JSBlock;
98
89
  //================================================================================
99
90
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑