@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
@@ -0,0 +1,391 @@
1
+ import App from './App__';
2
+ import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
3
+
4
+ //================================================================================
5
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
6
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
7
+ //================================================================================
8
+ import { EventPayload, Params } from '../common/EventEmitter';
9
+ import { concept, excludedInJSON, property } from '../decorators';
10
+
11
+ import * as utils from '../utils';
12
+ import { v4 as uuidv4 } from 'uuid';
13
+ import BaseNode from '../common/BaseNode';
14
+ import classMap from '../common/classMap';
15
+ import Entity from './Entity__';
16
+
17
+ /**
18
+ * 数据源
19
+ */
20
+ @concept('数据源')
21
+ export class DataSource extends BaseNode {
22
+ /**
23
+ * 产品概念
24
+ */
25
+ @property()
26
+ concept: 'DataSource' = 'DataSource';
27
+
28
+ /**
29
+ * 数据源名称
30
+ */
31
+ @property()
32
+ name: string = undefined;
33
+
34
+ /**
35
+ * 数据源描述
36
+ */
37
+ @property()
38
+ description: string = undefined;
39
+
40
+ /**
41
+ * 实体列表
42
+ */
43
+ @property('Entity')
44
+ entities: Array<Entity> = [];
45
+
46
+
47
+
48
+ /**
49
+ * @param source 需要合并的部分参数
50
+ */
51
+ constructor(source?: Partial<DataSource>) {
52
+ source = Object.assign({}, DataSource.getDefaultOptions(), source);
53
+ super(source);
54
+ super.subConstructor(source);
55
+ }
56
+
57
+ static from(source: any, parentNode?: any, parentKey?: string): DataSource {
58
+ return super.from(source, parentNode, parentKey) as DataSource;
59
+ }
60
+
61
+ /**
62
+ * 从父级删除该节点
63
+ * @internal
64
+ */
65
+ _delete() {
66
+ let params: Params = null;
67
+ if (this.parentNode) {
68
+ params = (this.parentNode as any)?.__removeDataSource?.(this);
69
+ }
70
+ return params;
71
+ }
72
+ /**
73
+ * 设置数据源描述
74
+ */
75
+ setDescription(description: string) {
76
+ const object = {
77
+ description,
78
+ };
79
+ this.update({
80
+ ...object,
81
+ });
82
+ }
83
+
84
+ getEntityExistingNames(excludedList: Array<Entity> = []) {
85
+ const excludedSet = new Set(excludedList);
86
+ return (this.entities || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
87
+ }
88
+ getEntityUniqueName(name = 'Entity1') {
89
+ return utils.unique(name, this.getEntityExistingNames(), undefined, true);
90
+ }
91
+
92
+ /**
93
+ * 插入实体
94
+ * @internal
95
+ * @param name 实体名称,如果不填会自动生成一个唯一名称
96
+ */
97
+ _insertEntityAt(name: string, index: number): Entity;
98
+
99
+ /**
100
+ * 插入实体
101
+ * @internal
102
+ * @param entityOptions 实体参数
103
+ */
104
+ _insertEntityAt(entityOptions: Partial<Entity>, index: number): Entity;
105
+
106
+ /**
107
+ * 插入实体
108
+ * @internal
109
+ * @param entity 已有的实体实例
110
+ */
111
+ _insertEntityAt(entity: Entity, index: number): Entity;
112
+
113
+ _insertEntityAt(options: string | Partial<Entity> | Entity, index: number) {
114
+ const entityOptions: any = {};
115
+ const relationOptions = { parentNode: this, parentKey: 'entities' };
116
+ let entity: Entity;
117
+ if (!options) {
118
+ entity = Entity.from({
119
+ ...entityOptions,
120
+ name: this.getEntityUniqueName(),
121
+ }, this, 'entities');
122
+ } else if (typeof options === 'string') {
123
+ entity = Entity.from({
124
+ ...entityOptions,
125
+ name: options,
126
+ }, this, 'entities');
127
+ } else if (options instanceof Entity) {
128
+ options.ensureDelete(); // 同一实例不支持多处存在
129
+ entity = options;
130
+ Object.assign(entity, relationOptions);
131
+ } else {
132
+ entity = Entity.from({
133
+ ...entityOptions,
134
+ ...options,
135
+ }, this, 'entities');
136
+ }
137
+ this.entities.splice(index, 0, entity);
138
+ return entity;
139
+ }
140
+
141
+ /**
142
+ * 插入实体
143
+ * @param name 实体名称,如果不填会自动生成一个唯一名称
144
+ */
145
+ insertEntityAt(name: string, index: number): Entity;
146
+
147
+ /**
148
+ * 插入实体
149
+ * @param entityOptions 实体参数
150
+ */
151
+ insertEntityAt(entityOptions: Partial<Entity>, index: number): Entity;
152
+
153
+ /**
154
+ * 插入实体
155
+ * @param entity 已有的实体实例
156
+ */
157
+ insertEntityAt(entity: Entity, index: number): Entity;
158
+
159
+ insertEntityAt(options: string | Partial<Entity> | Entity, index: number) {
160
+ const node = this._insertEntityAt(options as any, index);
161
+ node.create({
162
+ index,
163
+ parentNode: this,
164
+ parentKey: 'entities',
165
+ });
166
+ return node;
167
+ }
168
+
169
+ /**
170
+ * 添加实体
171
+ * @internal
172
+ * @param name 实体名称,如果不填会自动生成一个唯一名称
173
+ */
174
+ _addEntity(name?: string): Entity;
175
+
176
+ /**
177
+ * 添加实体
178
+ * @internal
179
+ * @param entityOptions 实体参数
180
+ */
181
+ _addEntity(entityOptions: Partial<Entity>): Entity;
182
+
183
+ /**
184
+ * 添加实体
185
+ * @internal
186
+ * @param entity 已有的实体实例
187
+ */
188
+ _addEntity(entity: Entity): Entity;
189
+
190
+ _addEntity(options?: string | Partial<Entity> | Entity) {
191
+ const index = 0;
192
+ return this._insertEntityAt(options as any, index);
193
+ }
194
+
195
+ /**
196
+ * 添加实体
197
+ * @internal
198
+ * @param name 实体名称,如果不填会自动生成一个唯一名称
199
+ */
200
+ addEntity(name?: string): Entity;
201
+
202
+ /**
203
+ * 添加实体
204
+ * @param entityOptions 实体参数
205
+ */
206
+ addEntity(entityOptions: Partial<Entity>): Entity;
207
+
208
+ /**
209
+ * 添加实体
210
+ * @param entity 已有的实体实例
211
+ */
212
+ addEntity(entity: Entity): Entity;
213
+
214
+ addEntity(options?: string | Partial<Entity> | Entity) {
215
+ const node = this._addEntity(options as any);
216
+ const index = this.entities.indexOf(node);
217
+ node.create({
218
+ index,
219
+ parentNode: this,
220
+ parentKey: 'entities',
221
+ });
222
+ return node;
223
+ }
224
+
225
+
226
+
227
+
228
+ /**
229
+ * 删除实体
230
+ * @param name 实体名称
231
+ */
232
+ removeEntity(name: string): void;
233
+
234
+ /**
235
+ * 删除实体
236
+ * @param entity 已有的实体实例
237
+ */
238
+ removeEntity(entity: Entity): void;
239
+
240
+ removeEntity(options: string | Entity) {
241
+ let entity: Entity;
242
+ if (typeof options === 'string') {
243
+ entity = this.entities.find((item) => item.name === options);
244
+ if (!entity) {
245
+ throw new Error('找不到实体 ' + options);
246
+ }
247
+ } else {
248
+ entity = options;
249
+ }
250
+ return entity.delete();
251
+ }
252
+
253
+ __removeEntity(entity: Entity) {
254
+ const parentKey = entity.parentKey;
255
+ const params: Params = {
256
+ parentNode: this,
257
+ parentKey,
258
+ index: -1,
259
+ object: null,
260
+ oldObject: entity,
261
+ };
262
+ if (parentKey) {
263
+ params.parentKey = parentKey;
264
+ if (Array.isArray((this as any)[parentKey])) {
265
+ const index = (this as any)[parentKey].indexOf(entity);
266
+ ~index && (this as any)[parentKey].splice(index, 1);
267
+ params.index = index;
268
+ } else if ((this as any)[parentKey] === entity) {
269
+ params.index = 0;
270
+ (this as any)[parentKey] = undefined;
271
+ }
272
+ }
273
+ return params;
274
+ }
275
+
276
+ //================================================================================
277
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
278
+ // 自动生成的代码已结束。下面可以手动编写。
279
+ //================================================================================
280
+ findEntityByName(name: string) {
281
+ return this.entities.find((entity) => entity.name === name);
282
+ }
283
+ /**
284
+ * 设置DataSource的名称
285
+ */
286
+ setName(name: string) {
287
+ const App = this.rootNode;
288
+ App.emit('collect:start', {
289
+ actionMsg: '修改数据源名称',
290
+ });
291
+ // 修改配置对应配置上的 datasource
292
+ const dataSourceGroup = (App as App).configuration?.getGroup('dataSource');
293
+ if (dataSourceGroup) {
294
+ const dataSourceConfig = dataSourceGroup.getProperty(this.name);
295
+ if (dataSourceConfig) {
296
+ dataSourceConfig.setName(name);
297
+ }
298
+ }
299
+
300
+ // 修改自己内部的名称
301
+ const object = {
302
+ name,
303
+ };
304
+ this.update({
305
+ ...object,
306
+ field: 'name',
307
+ });
308
+ // 结束修改 ,批量操作
309
+ App.emit('collect:end');
310
+ }
311
+ getNamespace() {
312
+ if (this.parentNode && (this.parentNode as App).getNamespace) {
313
+ const parentNamespace = (this.parentNode as App).getNamespace();
314
+ const parentName = this.parentNode.name;
315
+ const arr = [parentNamespace];
316
+ if (this.parentNode.concept !== 'App' && parentName) {
317
+ arr.push(parentName);
318
+ }
319
+ return `${arr.join('.')}.dataSources`;
320
+ } else
321
+ throw new Error('无法获取命名空间,请设置 parentNode!');
322
+ }
323
+ /**
324
+ * 生成宿主语言的文件路径
325
+ * @param name 一般不用传,用于 rename
326
+ */
327
+ getEmbeddedFilePath(name = this.name) {
328
+ return `/embedded/${this.rootNode?.name || this.parentNode.name}/datasources/${name}.ts`;
329
+ }
330
+ @withSourceMap()
331
+ toEmbeddedTS(state?: TranslatorState): string {
332
+ let code = `export namespace ${this.name} {\n`;
333
+ code += 'const name = ';
334
+ code += '"' + this.name + '";\n';
335
+ code += '}\n';
336
+ return code;
337
+ }
338
+ toEmbeddedTSFile() {
339
+ let code = `namespace ${this.getNamespace()} {\n`;
340
+
341
+ const state = createCompilerState(code, { tabSize: 1 });
342
+ try {
343
+ code += this.toEmbeddedTS(state);
344
+ } catch (err) {
345
+ code += '';
346
+ }
347
+ code += '}\n';
348
+
349
+ return {
350
+ code,
351
+ filePath: this.getEmbeddedFilePath(),
352
+ sourceMap: state.sourceMap,
353
+ };
354
+ }
355
+
356
+ // 获取datasource对应的数据源配置
357
+ get dataSourceConfig() {
358
+ let devProperty = null;
359
+ let onlineProperty = null;
360
+ let devValue = null;
361
+ let onlineValue = null;
362
+
363
+ const dataSourceGroup = (this.rootNode as App).configuration?.getGroup('dataSource');
364
+ if (dataSourceGroup) {
365
+ const property = dataSourceGroup.getProperty(this.name);
366
+ if (property.values) {
367
+ devProperty = property.values.find((item) => item.env === 'dev');
368
+ devValue = { ...devProperty, ...JSON.parse(devProperty.value || '{}') };
369
+ onlineProperty = property.values.find((item) => item.env === 'online');
370
+ onlineValue = { ...onlineProperty, ...JSON.parse(onlineProperty.value || '{}') };
371
+ }
372
+ }
373
+ return {
374
+ devProperty,
375
+ onlineProperty,
376
+ devValue,
377
+ onlineValue,
378
+ };
379
+ }
380
+ //================================================================================
381
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
382
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
383
+ //================================================================================
384
+ }
385
+
386
+ classMap['DataSource'] = DataSource;
387
+ export default DataSource;
388
+ //================================================================================
389
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
390
+ // 自动生成的代码已结束。下面可以手动编写。
391
+ //================================================================================
@@ -281,7 +281,14 @@ export class Destination extends LogicItem {
281
281
  url += ':destination="`';
282
282
  url += `/${viewArr.join('/')}`;
283
283
  if (Array.isArray(this.arguments) && this.arguments.length) {
284
- const args = this.arguments?.map((arg) => `${arg?.keyword}=` + `${arg?.toVue(options) === '' ? '' : '${' + arg?.toVue(options) + '}'}`);
284
+ const args = this.arguments.map((arg) => {
285
+ const value = arg?.toVue();
286
+ let argStr = '';
287
+ if (value) {
288
+ argStr += `${arg.keyword}=` + '${' + `${value}` + '}';
289
+ }
290
+ return argStr;
291
+ }).filter((arg) => !!arg);
285
292
  url += `?${args.join('&')}`;
286
293
  }
287
294
  url += '`"';
@@ -311,7 +318,14 @@ export class Destination extends LogicItem {
311
318
  url += 'this.$destination(`';
312
319
  url += `/${viewArr.join('/')}`;
313
320
  if (Array.isArray(this.arguments) && this.arguments.length) {
314
- const args = this.arguments.map((arg) => `${arg.keyword}=` + '${' + `${arg.toJS()}` + '}');
321
+ const args = this.arguments.map((arg) => {
322
+ const value = arg?.toJS();
323
+ let argStr = '';
324
+ if (value) {
325
+ argStr += `${arg.keyword}=` + '${' + `${value}` + '}';
326
+ }
327
+ return argStr;
328
+ }).filter((arg) => !!arg);
315
329
  url += `?${args.join('&')}`;
316
330
  }
317
331
  url += '`)';
@@ -390,7 +404,7 @@ export class Destination extends LogicItem {
390
404
  }
391
405
  @withSourceMap()
392
406
  toEmbeddedTSInProcess(state: TranslatorState, prependCode: string): string {
393
- // const tab = indent(state.tabSize);
407
+ // const tab = indent((state?.tabSize || 0));
394
408
  if (this.tsCalleeNamespace && this.tsName) {
395
409
  let code = `destination: function() {\n`;
396
410
  code += prependCode;
@@ -404,7 +418,7 @@ export class Destination extends LogicItem {
404
418
  }
405
419
  code += `});\n`;
406
420
  }
407
- code += indent(state.tabSize + 1) + `}\n`;
421
+ code += indent((state?.tabSize || 0) + 1) + `}\n`;
408
422
  return code;
409
423
  } else {
410
424
  return '__IDENTIFIER__';
@@ -417,7 +431,7 @@ export class Destination extends LogicItem {
417
431
 
418
432
  if (this.parentNode instanceof BindAttribute) {
419
433
  code = `${utils.firstLowerCase(this.concept)}: () => {\n`;
420
- code += indent(state.tabSize + 2);
434
+ code += indent((state?.tabSize || 0) + 2);
421
435
  if (this.tsCalleeNamespace && this.tsName) {
422
436
  code += `${this.tsCalleeNamespace}.${this.tsName}.$destination({`;
423
437
  if (Array.isArray(this.arguments)) {
@@ -427,7 +441,7 @@ export class Destination extends LogicItem {
427
441
  }
428
442
  code += `});\n`;
429
443
  }
430
- code += indent(state.tabSize + 1) + `},\n`;
444
+ code += indent((state?.tabSize || 0) + 1) + `},\n`;
431
445
  return code;
432
446
  } else {
433
447
  if (this.tsCalleeNamespace && this.tsName) {
@@ -447,7 +461,7 @@ export class Destination extends LogicItem {
447
461
  @withSourceMap()
448
462
  toEmbeddedTSNormalFunction(state?: TranslatorState): string {
449
463
  let code = `let ${utils.firstLowerCase(this.concept)} = function() {\n`;
450
- const tab = indent(state.tabSize + 2);
464
+ const tab = indent((state?.tabSize || 0) + 2);
451
465
  if (this.tsCalleeNamespace && this.tsName) {
452
466
  code += `${tab}${this.tsCalleeNamespace}.${this.tsName}.$destination(`;
453
467
  if (Array.isArray(this.arguments)) {
@@ -457,7 +471,7 @@ export class Destination extends LogicItem {
457
471
  }
458
472
  code += `${tab});\n`;
459
473
  }
460
- code += `${indent(state.tabSize + 1)}}\n`;
474
+ code += `${indent((state?.tabSize || 0) + 1)}}\n`;
461
475
  return code;
462
476
  }
463
477
  //================================================================================
@@ -70,9 +70,9 @@ export class End extends LogicItem {
70
70
  let code = '';
71
71
  const ret = this.logic.returns[0];
72
72
  if (ret) {
73
- code += indent(state.tabSize) + 'return ' + ret.name + ';';
73
+ code += indent((state?.tabSize || 0)) + 'return ' + ret.name + ';';
74
74
  } else {
75
- code += indent(state.tabSize) + 'return;';
75
+ code += indent((state?.tabSize || 0)) + 'return;';
76
76
  }
77
77
  return code;
78
78
  }
@@ -15,6 +15,7 @@ import classMap from '../common/classMap';
15
15
  import Entity from './Entity__';
16
16
  import Module from './Module__';
17
17
  import App from './App__';
18
+ import DataSource from './DataSource__';
18
19
 
19
20
  /**
20
21
  * 实体索引
@@ -75,6 +76,12 @@ export class EntityIndex extends BaseNode {
75
76
  get app() {
76
77
  return this.getAncestor('App') as App;
77
78
  }
79
+ /**
80
+ * 祖先 DataSource
81
+ */
82
+ get dataSource() {
83
+ return this.getAncestor('DataSource') as DataSource;
84
+ }
78
85
 
79
86
  /**
80
87
  * @param source 需要合并的部分参数
@@ -177,7 +184,8 @@ export class EntityIndex extends BaseNode {
177
184
  */
178
185
  moveUp() {
179
186
  const indexes = [...(this.parentNode as Entity).indexes];
180
- const oldIndex = indexes.indexOf(this);
187
+ const indexesNameList = indexes.map((item) => item.name);
188
+ const oldIndex = indexesNameList.indexOf(this.name);
181
189
  this.changeSort(indexes, oldIndex, 'up');
182
190
  this.parentNode.update({
183
191
  indexes,
@@ -188,7 +196,8 @@ export class EntityIndex extends BaseNode {
188
196
  */
189
197
  moveDown() {
190
198
  const indexes = [...(this.parentNode as Entity).indexes];
191
- const oldIndex = indexes.indexOf(this);
199
+ const indexesNameList = indexes.map((item) => item.name);
200
+ const oldIndex = indexesNameList.indexOf(this.name);
192
201
  this.changeSort(indexes, oldIndex, 'down');
193
202
  this.parentNode.update({
194
203
  indexes,
@@ -17,6 +17,7 @@ import TypeAnnotation from './TypeAnnotation__';
17
17
  import Entity from './Entity__';
18
18
  import Module from './Module__';
19
19
  import App from './App__';
20
+ import DataSource from './DataSource__';
20
21
 
21
22
  /**
22
23
  * 实体字段
@@ -154,6 +155,12 @@ export class EntityProperty extends BaseNode {
154
155
  get app() {
155
156
  return this.getAncestor('App') as App;
156
157
  }
158
+ /**
159
+ * 祖先 DataSource
160
+ */
161
+ get dataSource() {
162
+ return this.getAncestor('DataSource') as DataSource;
163
+ }
157
164
 
158
165
  /**
159
166
  * @param source 需要合并的部分参数
@@ -369,11 +376,9 @@ export class EntityProperty extends BaseNode {
369
376
  completionChildren = properties;
370
377
  }
371
378
  } else if (typeKind === 'generic') {
372
- if (typeNamespace === 'nasl.collection') {
373
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
374
- const properties = node.properties || [];
375
- completionChildren = properties;
376
- }
379
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
380
+ const properties = node.properties || [];
381
+ completionChildren = properties;
377
382
  } else {
378
383
  completionChildren = undefined;
379
384
  }
@@ -419,8 +424,8 @@ export class EntityProperty extends BaseNode {
419
424
  let code = '';
420
425
  if (this.relationNamespace && this.relationEntity && this.relationProperty) {
421
426
  code += `@nasl.annotation.EntityRelation(new ${this.relationNamespace}.${this.relationEntity}().${this.relationProperty})\n`;
422
- code += indent(state.tabSize + 2);
423
- // code += indent(state.tabSize + 1);
427
+ code += indent((state?.tabSize || 0) + 2);
428
+ // code += indent((state?.tabSize || 0) + 1);
424
429
  }
425
430
 
426
431
  code += this.name;
@@ -530,6 +535,17 @@ export class EntityProperty extends BaseNode {
530
535
  });
531
536
  }
532
537
 
538
+ /**
539
+ * 设置关联实体实体名称
540
+ */
541
+ setRelationNamespace(relationNamespace: string) {
542
+ const object = {
543
+ relationNamespace,
544
+ };
545
+ this.update({
546
+ ...object,
547
+ });
548
+ }
533
549
  /**
534
550
  * 设置关联实体实体名称
535
551
  */