@lcap/nasl 1.0.2 → 2.12.0-beta

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 (355) hide show
  1. package/out/automate/engine/index.js +11 -0
  2. package/out/automate/engine/index.js.map +1 -1
  3. package/out/automate/engine/uniqueName.js +1 -1
  4. package/out/automate/engine/uniqueName.js.map +1 -1
  5. package/out/automate/engine/utils.d.ts +1 -0
  6. package/out/automate/engine/utils.js +89 -67
  7. package/out/automate/engine/utils.js.map +1 -1
  8. package/out/concepts/App__.d.ts +51 -49
  9. package/out/concepts/App__.js +86 -54
  10. package/out/concepts/App__.js.map +1 -1
  11. package/out/concepts/Argument__.js +1 -1
  12. package/out/concepts/Argument__.js.map +1 -1
  13. package/out/concepts/Assignee__.js +1 -1
  14. package/out/concepts/Assignee__.js.map +1 -1
  15. package/out/concepts/Assignment__.js +1 -1
  16. package/out/concepts/Assignment__.js.map +1 -1
  17. package/out/concepts/Attribute__.js +1 -1
  18. package/out/concepts/Attribute__.js.map +1 -1
  19. package/out/concepts/BinaryExpression__.js +1 -1
  20. package/out/concepts/BinaryExpression__.js.map +1 -1
  21. package/out/concepts/BindAttribute__.js +3 -3
  22. package/out/concepts/BindAttribute__.js.map +1 -1
  23. package/out/concepts/BindDirective__.js +1 -1
  24. package/out/concepts/BindDirective__.js.map +1 -1
  25. package/out/concepts/BindEvent__.js +11 -6
  26. package/out/concepts/BindEvent__.js.map +1 -1
  27. package/out/concepts/BooleanLiteral__.js +1 -1
  28. package/out/concepts/BooleanLiteral__.js.map +1 -1
  29. package/out/concepts/CallFunction__.js +8 -3
  30. package/out/concepts/CallFunction__.js.map +1 -1
  31. package/out/concepts/CallInterface__.js +1 -1
  32. package/out/concepts/CallInterface__.js.map +1 -1
  33. package/out/concepts/CallLogic__.js +23 -21
  34. package/out/concepts/CallLogic__.js.map +1 -1
  35. package/out/concepts/CallQueryComponent__.d.ts +9 -8
  36. package/out/concepts/CallQueryComponent__.js +89 -79
  37. package/out/concepts/CallQueryComponent__.js.map +1 -1
  38. package/out/concepts/Comment__.js +2 -2
  39. package/out/concepts/Comment__.js.map +1 -1
  40. package/out/concepts/CompletionProperty__.js +1 -1
  41. package/out/concepts/CompletionProperty__.js.map +1 -1
  42. package/out/concepts/ConfigGroup__.d.ts +1 -0
  43. package/out/concepts/ConfigGroup__.js +8 -1
  44. package/out/concepts/ConfigGroup__.js.map +1 -1
  45. package/out/concepts/ConfigPropertyValue__.js +1 -1
  46. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  47. package/out/concepts/ConfigProperty__.d.ts +1 -0
  48. package/out/concepts/ConfigProperty__.js +4 -1
  49. package/out/concepts/ConfigProperty__.js.map +1 -1
  50. package/out/concepts/Configuration__.d.ts +1 -0
  51. package/out/concepts/Configuration__.js +4 -1
  52. package/out/concepts/Configuration__.js.map +1 -1
  53. package/out/concepts/Constant__.js +1 -1
  54. package/out/concepts/Constant__.js.map +1 -1
  55. package/out/concepts/DataElement__.js +1 -1
  56. package/out/concepts/DataElement__.js.map +1 -1
  57. package/out/concepts/DataSource__.d.ts +143 -0
  58. package/out/concepts/DataSource__.js +316 -0
  59. package/out/concepts/DataSource__.js.map +1 -0
  60. package/out/concepts/Destination__.js +8 -8
  61. package/out/concepts/Destination__.js.map +1 -1
  62. package/out/concepts/End__.js +3 -3
  63. package/out/concepts/End__.js.map +1 -1
  64. package/out/concepts/EntityIndex__.d.ts +5 -0
  65. package/out/concepts/EntityIndex__.js +7 -1
  66. package/out/concepts/EntityIndex__.js.map +1 -1
  67. package/out/concepts/EntityProperty__.d.ts +9 -0
  68. package/out/concepts/EntityProperty__.js +20 -3
  69. package/out/concepts/EntityProperty__.js.map +1 -1
  70. package/out/concepts/Entity__.d.ts +5 -0
  71. package/out/concepts/Entity__.js +21 -11
  72. package/out/concepts/Entity__.js.map +1 -1
  73. package/out/concepts/EnumItem__.js +1 -1
  74. package/out/concepts/EnumItem__.js.map +1 -1
  75. package/out/concepts/Enum__.js +11 -5
  76. package/out/concepts/Enum__.js.map +1 -1
  77. package/out/concepts/Event__.js +1 -1
  78. package/out/concepts/Event__.js.map +1 -1
  79. package/out/concepts/ForEachStatement__.js +3 -3
  80. package/out/concepts/ForEachStatement__.js.map +1 -1
  81. package/out/concepts/Function__.d.ts +18 -0
  82. package/out/concepts/Function__.js +96 -1
  83. package/out/concepts/Function__.js.map +1 -1
  84. package/out/concepts/Identifier__.js +3 -13
  85. package/out/concepts/Identifier__.js.map +1 -1
  86. package/out/concepts/IfStatement__.js +9 -9
  87. package/out/concepts/IfStatement__.js.map +1 -1
  88. package/out/concepts/InterfaceParam__.js +1 -1
  89. package/out/concepts/InterfaceParam__.js.map +1 -1
  90. package/out/concepts/Interface__.js +19 -12
  91. package/out/concepts/Interface__.js.map +1 -1
  92. package/out/concepts/JSBlock__.js +1 -1
  93. package/out/concepts/JSBlock__.js.map +1 -1
  94. package/out/concepts/LogicItem__.js +1 -1
  95. package/out/concepts/LogicItem__.js.map +1 -1
  96. package/out/concepts/Logic__.js +41 -42
  97. package/out/concepts/Logic__.js.map +1 -1
  98. package/out/concepts/MemberExpression__.js +1 -1
  99. package/out/concepts/MemberExpression__.js.map +1 -1
  100. package/out/concepts/Module__.d.ts +1 -85
  101. package/out/concepts/Module__.js +6 -107
  102. package/out/concepts/Module__.js.map +1 -1
  103. package/out/concepts/Namespace__.d.ts +0 -86
  104. package/out/concepts/Namespace__.js +1 -108
  105. package/out/concepts/Namespace__.js.map +1 -1
  106. package/out/concepts/NullLiteral__.js +1 -1
  107. package/out/concepts/NullLiteral__.js.map +1 -1
  108. package/out/concepts/NumericLiteral__.js +1 -1
  109. package/out/concepts/NumericLiteral__.js.map +1 -1
  110. package/out/concepts/Param__.d.ts +2 -1
  111. package/out/concepts/Param__.js +1 -1
  112. package/out/concepts/Param__.js.map +1 -1
  113. package/out/concepts/Point__.js +1 -1
  114. package/out/concepts/Point__.js.map +1 -1
  115. package/out/concepts/ProcessComponent__.js +1 -1
  116. package/out/concepts/ProcessComponent__.js.map +1 -1
  117. package/out/concepts/ProcessElement__.js +26 -11
  118. package/out/concepts/ProcessElement__.js.map +1 -1
  119. package/out/concepts/ProcessOutcome__.js +1 -1
  120. package/out/concepts/ProcessOutcome__.js.map +1 -1
  121. package/out/concepts/Process__.js +17 -10
  122. package/out/concepts/Process__.js.map +1 -1
  123. package/out/concepts/QueryAggregateExpression__.js +1 -1
  124. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  125. package/out/concepts/QueryFieldExpression__.js +9 -2
  126. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  127. package/out/concepts/QueryFromExpression__.d.ts +4 -0
  128. package/out/concepts/QueryFromExpression__.js +14 -3
  129. package/out/concepts/QueryFromExpression__.js.map +1 -1
  130. package/out/concepts/QueryGroupByExpression__.js +1 -1
  131. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  132. package/out/concepts/QueryJoinExpression__.d.ts +4 -0
  133. package/out/concepts/QueryJoinExpression__.js +15 -4
  134. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  135. package/out/concepts/QueryLimitExpression__.js +1 -1
  136. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  137. package/out/concepts/QueryOrderByExpression__.js +1 -1
  138. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  139. package/out/concepts/QuerySelectExpression__.js +1 -1
  140. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  141. package/out/concepts/Rect__.js +1 -1
  142. package/out/concepts/Rect__.js.map +1 -1
  143. package/out/concepts/Return__.js +1 -1
  144. package/out/concepts/Return__.js.map +1 -1
  145. package/out/concepts/Role__.js +11 -4
  146. package/out/concepts/Role__.js.map +1 -1
  147. package/out/concepts/Slot__.js +1 -1
  148. package/out/concepts/Slot__.js.map +1 -1
  149. package/out/concepts/SqlQueryComponent__.d.ts +10 -0
  150. package/out/concepts/SqlQueryComponent__.js +32 -5
  151. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  152. package/out/concepts/Start__.js +1 -1
  153. package/out/concepts/Start__.js.map +1 -1
  154. package/out/concepts/StringLiteral__.js +1 -1
  155. package/out/concepts/StringLiteral__.js.map +1 -1
  156. package/out/concepts/StructureProperty__.js +1 -1
  157. package/out/concepts/StructureProperty__.js.map +1 -1
  158. package/out/concepts/Structure__.js +20 -13
  159. package/out/concepts/Structure__.js.map +1 -1
  160. package/out/concepts/SwitchCase__.js +6 -6
  161. package/out/concepts/SwitchCase__.js.map +1 -1
  162. package/out/concepts/SwitchStatement__.js +1 -1
  163. package/out/concepts/SwitchStatement__.js.map +1 -1
  164. package/out/concepts/Theme__.js +1 -1
  165. package/out/concepts/Theme__.js.map +1 -1
  166. package/out/concepts/Transactional__.js +1 -1
  167. package/out/concepts/Transactional__.js.map +1 -1
  168. package/out/concepts/TypeAnnotation__.d.ts +8 -0
  169. package/out/concepts/TypeAnnotation__.js +46 -4
  170. package/out/concepts/TypeAnnotation__.js.map +1 -1
  171. package/out/concepts/TypeParam__.js +1 -1
  172. package/out/concepts/TypeParam__.js.map +1 -1
  173. package/out/concepts/UnaryExpression__.js +1 -1
  174. package/out/concepts/UnaryExpression__.js.map +1 -1
  175. package/out/concepts/Unparsed__.js +1 -1
  176. package/out/concepts/Unparsed__.js.map +1 -1
  177. package/out/concepts/UseComponent__.js +1 -1
  178. package/out/concepts/UseComponent__.js.map +1 -1
  179. package/out/concepts/ValidationRule__.js +1 -1
  180. package/out/concepts/ValidationRule__.js.map +1 -1
  181. package/out/concepts/Variable__.js +1 -1
  182. package/out/concepts/Variable__.js.map +1 -1
  183. package/out/concepts/ViewComponent__.js +1 -1
  184. package/out/concepts/ViewComponent__.js.map +1 -1
  185. package/out/concepts/ViewElement__.js +18 -18
  186. package/out/concepts/ViewElement__.js.map +1 -1
  187. package/out/concepts/View__.js +25 -23
  188. package/out/concepts/View__.js.map +1 -1
  189. package/out/concepts/WhileStatement__.js +5 -5
  190. package/out/concepts/WhileStatement__.js.map +1 -1
  191. package/out/concepts/basics/stdlib/nasl.util.js +278 -0
  192. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  193. package/out/concepts/index__.d.ts +1 -0
  194. package/out/concepts/index__.js +1 -0
  195. package/out/concepts/index__.js.map +1 -1
  196. package/out/generator/genBundleFiles.js +8 -3
  197. package/out/generator/genBundleFiles.js.map +1 -1
  198. package/out/generator/genMetaData.js +13 -12
  199. package/out/generator/genMetaData.js.map +1 -1
  200. package/out/server/createUiTs.js +1 -0
  201. package/out/server/createUiTs.js.map +1 -1
  202. package/out/server/getLogics.js +9 -1
  203. package/out/server/getLogics.js.map +1 -1
  204. package/out/server/getProcesses.d.ts +3 -0
  205. package/out/server/getProcesses.js +61 -1
  206. package/out/server/getProcesses.js.map +1 -1
  207. package/out/server/naslServer.js +128 -6
  208. package/out/server/naslServer.js.map +1 -1
  209. package/out/server/process2LogicNamespace.js +10 -1
  210. package/out/server/process2LogicNamespace.js.map +1 -1
  211. package/out/server/translator.js +19 -1
  212. package/out/server/translator.js.map +1 -1
  213. package/out/service/storage/init.js +2 -2
  214. package/out/service/storage/init.js.map +1 -1
  215. package/out/templator/genCreateBlock.js +15 -11
  216. package/out/templator/genCreateBlock.js.map +1 -1
  217. package/out/templator/genCurdEditMultipleKeyBlock.js +15 -12
  218. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  219. package/out/templator/genCurdMultipleKeyBlock.js +25 -21
  220. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  221. package/out/templator/genEditTableBlock.js +12 -12
  222. package/out/templator/genEditTableBlock.js.map +1 -1
  223. package/out/templator/genGridViewBlock.js +21 -20
  224. package/out/templator/genGridViewBlock.js.map +1 -1
  225. package/out/templator/genListViewBlock.js +6 -3
  226. package/out/templator/genListViewBlock.js.map +1 -1
  227. package/out/templator/genQueryComponent.js +5 -5
  228. package/out/templator/genQueryComponent.js.map +1 -1
  229. package/out/templator/genSelectBlock.js +8 -7
  230. package/out/templator/genSelectBlock.js.map +1 -1
  231. package/out/templator/genTableBlock.js +17 -15
  232. package/out/templator/genTableBlock.js.map +1 -1
  233. package/out/templator/genUpdateBlock.js +15 -11
  234. package/out/templator/genUpdateBlock.js.map +1 -1
  235. package/out/templator/utils.d.ts +2 -2
  236. package/out/templator/utils.js.map +1 -1
  237. package/out/test/integration/connect-file.js +6 -6
  238. package/out/test/integration/connect-file.js.map +1 -1
  239. package/out/translator/index.js +1 -1
  240. package/out/translator/index.js.map +1 -1
  241. package/out/utils/index.d.ts +4 -0
  242. package/out/utils/index.js +32 -1
  243. package/out/utils/index.js.map +1 -1
  244. package/package.json +1 -1
  245. package/src/automate/engine/index.js +12 -1
  246. package/src/automate/engine/uniqueName.js +1 -1
  247. package/src/automate/engine/utils.js +92 -67
  248. package/src/concepts/App__.ts +165 -95
  249. package/src/concepts/Argument__.ts +1 -1
  250. package/src/concepts/Assignee__.ts +1 -1
  251. package/src/concepts/Assignment__.ts +1 -1
  252. package/src/concepts/Attribute__.ts +1 -1
  253. package/src/concepts/BinaryExpression__.ts +1 -1
  254. package/src/concepts/BindAttribute__.ts +3 -3
  255. package/src/concepts/BindDirective__.ts +1 -1
  256. package/src/concepts/BindEvent__.ts +10 -6
  257. package/src/concepts/BooleanLiteral__.ts +1 -1
  258. package/src/concepts/CallFunction__.ts +19 -16
  259. package/src/concepts/CallInterface__.ts +1 -1
  260. package/src/concepts/CallLogic__.ts +23 -23
  261. package/src/concepts/CallQueryComponent__.ts +96 -113
  262. package/src/concepts/Comment__.ts +2 -2
  263. package/src/concepts/CompletionProperty__.ts +1 -1
  264. package/src/concepts/ConfigGroup__.ts +4 -2
  265. package/src/concepts/ConfigPropertyValue__.ts +1 -1
  266. package/src/concepts/ConfigProperty__.ts +5 -1
  267. package/src/concepts/Configuration__.ts +4 -1
  268. package/src/concepts/Constant__.ts +1 -1
  269. package/src/concepts/DataElement__.ts +1 -1
  270. package/src/concepts/DataSource__.ts +389 -0
  271. package/src/concepts/Destination__.ts +24 -8
  272. package/src/concepts/End__.ts +3 -3
  273. package/src/concepts/EntityIndex__.ts +8 -1
  274. package/src/concepts/EntityProperty__.ts +21 -3
  275. package/src/concepts/Entity__.ts +24 -12
  276. package/src/concepts/EnumItem__.ts +1 -1
  277. package/src/concepts/Enum__.ts +24 -5
  278. package/src/concepts/Event__.ts +1 -1
  279. package/src/concepts/ForEachStatement__.ts +3 -3
  280. package/src/concepts/Function__.ts +97 -3
  281. package/src/concepts/Identifier__.ts +12 -13
  282. package/src/concepts/IfStatement__.ts +10 -10
  283. package/src/concepts/InterfaceParam__.ts +1 -1
  284. package/src/concepts/Interface__.ts +20 -12
  285. package/src/concepts/JSBlock__.ts +1 -1
  286. package/src/concepts/LogicItem__.ts +1 -1
  287. package/src/concepts/Logic__.ts +41 -39
  288. package/src/concepts/MemberExpression__.ts +1 -1
  289. package/src/concepts/Module__.ts +9 -204
  290. package/src/concepts/Namespace__.ts +1 -204
  291. package/src/concepts/NullLiteral__.ts +1 -1
  292. package/src/concepts/NumericLiteral__.ts +1 -1
  293. package/src/concepts/Param__.ts +3 -2
  294. package/src/concepts/Point__.ts +1 -1
  295. package/src/concepts/ProcessComponent__.ts +1 -1
  296. package/src/concepts/ProcessElement__.ts +29 -13
  297. package/src/concepts/ProcessOutcome__.ts +1 -1
  298. package/src/concepts/Process__.ts +17 -11
  299. package/src/concepts/QueryAggregateExpression__.ts +1 -1
  300. package/src/concepts/QueryFieldExpression__.ts +10 -2
  301. package/src/concepts/QueryFromExpression__.ts +14 -3
  302. package/src/concepts/QueryGroupByExpression__.ts +1 -1
  303. package/src/concepts/QueryJoinExpression__.ts +15 -4
  304. package/src/concepts/QueryLimitExpression__.ts +1 -1
  305. package/src/concepts/QueryOrderByExpression__.ts +1 -1
  306. package/src/concepts/QuerySelectExpression__.ts +1 -1
  307. package/src/concepts/Rect__.ts +1 -1
  308. package/src/concepts/Return__.ts +1 -1
  309. package/src/concepts/Role__.ts +11 -5
  310. package/src/concepts/Slot__.ts +1 -1
  311. package/src/concepts/SqlQueryComponent__.ts +30 -11
  312. package/src/concepts/Start__.ts +1 -1
  313. package/src/concepts/StringLiteral__.ts +1 -1
  314. package/src/concepts/StructureProperty__.ts +1 -1
  315. package/src/concepts/Structure__.ts +20 -12
  316. package/src/concepts/SwitchCase__.ts +6 -6
  317. package/src/concepts/SwitchStatement__.ts +1 -1
  318. package/src/concepts/Theme__.ts +1 -1
  319. package/src/concepts/Transactional__.ts +1 -1
  320. package/src/concepts/TypeAnnotation__.ts +45 -23
  321. package/src/concepts/TypeParam__.ts +1 -1
  322. package/src/concepts/UnaryExpression__.ts +1 -1
  323. package/src/concepts/Unparsed__.ts +1 -1
  324. package/src/concepts/UseComponent__.ts +1 -1
  325. package/src/concepts/ValidationRule__.ts +1 -1
  326. package/src/concepts/Variable__.ts +1 -1
  327. package/src/concepts/ViewComponent__.ts +1 -1
  328. package/src/concepts/ViewElement__.ts +19 -19
  329. package/src/concepts/View__.ts +25 -23
  330. package/src/concepts/WhileStatement__.ts +5 -5
  331. package/src/concepts/basics/stdlib/nasl.util.ts +279 -0
  332. package/src/concepts/index__.ts +1 -0
  333. package/src/generator/genBundleFiles.ts +8 -3
  334. package/src/generator/genMetaData.ts +13 -13
  335. package/src/server/createUiTs.ts +1 -0
  336. package/src/server/getLogics.ts +11 -3
  337. package/src/server/getProcesses.ts +61 -0
  338. package/src/server/naslServer.ts +124 -6
  339. package/src/server/process2LogicNamespace.ts +29 -19
  340. package/src/server/translator.ts +22 -1
  341. package/src/service/storage/init.ts +2 -2
  342. package/src/templator/genCreateBlock.ts +16 -13
  343. package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -13
  344. package/src/templator/genCurdMultipleKeyBlock.ts +26 -22
  345. package/src/templator/genEditTableBlock.ts +14 -13
  346. package/src/templator/genGridViewBlock.ts +22 -21
  347. package/src/templator/genListViewBlock.ts +9 -5
  348. package/src/templator/genQueryComponent.ts +6 -6
  349. package/src/templator/genSelectBlock.ts +9 -8
  350. package/src/templator/genTableBlock.ts +18 -16
  351. package/src/templator/genUpdateBlock.ts +16 -12
  352. package/src/templator/utils.ts +2 -2
  353. package/src/test/integration/connect-file.ts +6 -6
  354. package/src/translator/index.ts +1 -1
  355. package/src/utils/index.ts +32 -0
@@ -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 需要合并的部分参数
@@ -644,40 +651,45 @@ export class Entity extends BaseNode {
644
651
  @withSourceMap()
645
652
  toEmbeddedTS(state?: TranslatorState): string {
646
653
  let code = `export class ${this.name} {\n`;
647
- code += indent(state.tabSize + 1);
654
+ code += indent((state?.tabSize || 0) + 1);
648
655
  code += `__name: '${this.getNamespace()}.${this.name}';\n`;
649
656
  this.properties.forEach((property) => {
650
- code += indent(state.tabSize + 1);
657
+ code += indent((state?.tabSize || 0) + 1);
651
658
  code += property.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
652
659
  code += ';\n';
653
660
  });
654
661
  if (this.indexes && this.indexes.length) {
655
- code += indent(state.tabSize + 1);
662
+ code += indent((state?.tabSize || 0) + 1);
656
663
  code += `__IndexList() {\n`;
657
664
  code += ` return [`;
658
665
  this.indexes.forEach((entityIndex) => {
659
- code += indent(state.tabSize + 1);
666
+ code += indent((state?.tabSize || 0) + 1);
660
667
  code += '\n ';
661
668
  code += entityIndex.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
662
669
  });
663
- code += indent(state.tabSize) + `\n ];\n }\n`;
670
+ code += indent((state?.tabSize || 0)) + `\n ];\n }\n`;
664
671
  }
665
672
 
666
673
  const ns = this.ns;
674
+
675
+ /**
676
+ * 8个函数的总行数
677
+ * 如果修改这里,可能会影响到dataSource的重命名, 在naslserver中,可能要一起修改
678
+ */
667
679
  code += `\nstatic logics = {\n`;
668
680
  ns.logics.forEach((logic) => {
669
- code += indent(state.tabSize + 1);
681
+ code += indent((state?.tabSize || 0) + 1);
670
682
  code += logic.toEmbeddedTS(shiftState(state, code), 'inObject');
671
683
  });
672
684
  code += '}\n';
673
- code += indent(state.tabSize) + '}\n';
685
+ code += indent((state?.tabSize || 0)) + '}\n';
674
686
 
675
687
  return code;
676
688
  }
677
689
 
678
690
  getNamespace() {
679
- if (this.parentNode && (this.parentNode as Namespace).getNamespace)
680
- 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`;
681
693
  else
682
694
  throw new Error('无法获取命名空间,请设置 parentNode!');
683
695
  }
@@ -687,12 +699,12 @@ export class Entity extends BaseNode {
687
699
  * @param name 一般不用传,用于 rename
688
700
  */
689
701
  getEmbeddedFilePath(name = this.name) {
690
- return `/embedded/${this.app.name}/entities/${name}.ts`;
702
+ return `/embedded/${this.app.name}/datasources/${this.parentNode.name}/entities/${name}.ts`;
691
703
  }
692
704
 
693
705
  get ns() {
694
706
  const ns: Namespace = entity2LogicNamespace(this);
695
- ns.path = this.getNamespace() + '.' + ns.name;
707
+ ns.path = this.getNamespace();
696
708
  return ns;
697
709
  }
698
710
  // @excludedInJSON()
@@ -728,7 +740,7 @@ export class Entity extends BaseNode {
728
740
  //================================================================================
729
741
  }
730
742
 
731
- classMap['Entity'] = Entity;
743
+ classMap.Entity = Entity;
732
744
  export default Entity;
733
745
  //================================================================================
734
746
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -132,7 +132,7 @@ export class EnumItem extends BaseNode {
132
132
  //================================================================================
133
133
  }
134
134
 
135
- classMap['EnumItem'] = EnumItem;
135
+ classMap.EnumItem = EnumItem;
136
136
  export default EnumItem;
137
137
  //================================================================================
138
138
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -125,6 +125,10 @@ export class Enum extends BaseNode {
125
125
  });
126
126
  }
127
127
 
128
+
129
+
130
+
131
+
128
132
  /**
129
133
  * 插入枚举项
130
134
  * @internal
@@ -157,6 +161,8 @@ export class Enum extends BaseNode {
157
161
  return enumItem;
158
162
  }
159
163
 
164
+
165
+
160
166
  /**
161
167
  * 插入枚举项
162
168
  * @param enumItemOptions 枚举项参数
@@ -179,6 +185,8 @@ export class Enum extends BaseNode {
179
185
  return node;
180
186
  }
181
187
 
188
+
189
+
182
190
  /**
183
191
  * 添加枚举项
184
192
  * @internal
@@ -198,6 +206,8 @@ export class Enum extends BaseNode {
198
206
  return this._insertEnumItemAt(options as any, index);
199
207
  }
200
208
 
209
+
210
+
201
211
  /**
202
212
  * 添加枚举项
203
213
  * @param enumItemOptions 枚举项参数
@@ -221,6 +231,9 @@ export class Enum extends BaseNode {
221
231
  return node;
222
232
  }
223
233
 
234
+
235
+
236
+
224
237
  /**
225
238
  * 删除枚举项
226
239
  * @param enumItem 已有的枚举项实例
@@ -228,7 +241,7 @@ export class Enum extends BaseNode {
228
241
  removeEnumItem(enumItem: EnumItem): void;
229
242
 
230
243
  removeEnumItem(options: EnumItem) {
231
- const enumItem: EnumItem = options;
244
+ let enumItem: EnumItem = options;
232
245
  return enumItem.delete();
233
246
  }
234
247
 
@@ -282,9 +295,9 @@ export class Enum extends BaseNode {
282
295
  toEmbeddedTS(state?: TranslatorState): string {
283
296
  let code = `export class ${this.name} extends nasl.core.Enums {\n`;
284
297
  // 增加一个单独的标签
285
- code += indent(state.tabSize + 1) + `__name: '${this.getNamespace()}.${this.name}';\n`;
298
+ code += indent((state?.tabSize || 0) + 1) + `__name: '${this.getNamespace()}.${this.name}';\n`;
286
299
  this.enumItems.forEach((property) => {
287
- code += indent(state.tabSize + 1);
300
+ code += indent((state?.tabSize || 0) + 1);
288
301
  code += property.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
289
302
  code += ';\n';
290
303
  });
@@ -298,14 +311,20 @@ export class Enum extends BaseNode {
298
311
  return str;
299
312
  }
300
313
  `;
301
- code += indent(state.tabSize) + '}\n';
314
+ code += indent((state?.tabSize || 0)) + '}\n';
302
315
 
303
316
  return code;
304
317
  }
305
318
 
306
319
  getNamespace() {
307
320
  if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
308
- 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`;
309
328
  } else
310
329
  throw new Error('无法获取命名空间,请设置 parentNode!');
311
330
  }
@@ -309,7 +309,7 @@ export class Event extends BaseNode {
309
309
  //================================================================================
310
310
  }
311
311
 
312
- classMap['Event'] = Event;
312
+ classMap.Event = Event;
313
313
  export default Event;
314
314
  //================================================================================
315
315
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -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
  }
@@ -562,7 +562,7 @@ export class ForEachStatement extends LogicItem {
562
562
  //================================================================================
563
563
  }
564
564
 
565
- classMap['ForEachStatement'] = ForEachStatement;
565
+ classMap.ForEachStatement = ForEachStatement;
566
566
  export default ForEachStatement;
567
567
  //================================================================================
568
568
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -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
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -682,7 +685,7 @@ export class Function extends BaseNode {
682
685
  }
683
686
 
684
687
 
685
-
688
+
686
689
 
687
690
  /**
688
691
  * 删除类型参数
@@ -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);
@@ -901,7 +969,33 @@ export class Function extends BaseNode {
901
969
  } else
902
970
  throw new Error('无法获取命名空间,请设置 parentNode!');
903
971
  }
904
-
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 += ` => (`;
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;
@@ -914,7 +1008,7 @@ export class Function extends BaseNode {
914
1008
  //================================================================================
915
1009
  }
916
1010
 
917
- classMap['Function'] = Function;
1011
+ classMap.Function = Function;
918
1012
  export default Function;
919
1013
  //================================================================================
920
1014
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -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 自动生成,请不手动修改!
@@ -38,6 +39,8 @@ export class Identifier extends LogicItem {
38
39
  @property()
39
40
  name: string = undefined;
40
41
 
42
+
43
+
41
44
  /**
42
45
  * @param source 需要合并的部分参数
43
46
  */
@@ -51,6 +54,13 @@ export class Identifier extends LogicItem {
51
54
  return super.from(source, parentNode, parentKey) as Identifier;
52
55
  }
53
56
 
57
+
58
+
59
+
60
+
61
+
62
+
63
+
54
64
  //================================================================================
55
65
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
56
66
  // 自动生成的代码已结束。下面可以手动编写。
@@ -68,18 +78,7 @@ export class Identifier extends LogicItem {
68
78
  };
69
79
 
70
80
  isEnum() {
71
- const namespace = this.namespace;
72
- if (namespace) {
73
- const namespaceArr = namespace.split('.');
74
- const start = namespaceArr.shift();
75
- if (start === 'app' || start === 'extensions') {
76
- const mod = start === 'app' ? 0 : 1;
77
- const keywordViews = namespaceArr.filter((namespaceItem, index) => index % 2 === mod);
78
- const last = keywordViews.pop();
79
- return last === 'enums';
80
- }
81
- }
82
- return false;
81
+ return findConceptKeyWordByNamespace(this.namespace) === 'enums';
83
82
  }
84
83
 
85
84
  toVue(options?: ElementToVueOptions): string {
@@ -215,7 +214,7 @@ export class Identifier extends LogicItem {
215
214
  //================================================================================
216
215
  }
217
216
 
218
- classMap.Identifier = Identifier;
217
+ classMap['Identifier'] = Identifier;
219
218
  export default Identifier;
220
219
  //================================================================================
221
220
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -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
  }
@@ -438,7 +438,7 @@ export class IfStatement extends LogicItem {
438
438
  //================================================================================
439
439
  }
440
440
 
441
- classMap['IfStatement'] = IfStatement;
441
+ classMap.IfStatement = IfStatement;
442
442
  export default IfStatement;
443
443
  //================================================================================
444
444
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -333,7 +333,7 @@ export class InterfaceParam extends BaseNode {
333
333
  //================================================================================
334
334
  }
335
335
 
336
- classMap['InterfaceParam'] = InterfaceParam;
336
+ classMap.InterfaceParam = InterfaceParam;
337
337
  export default InterfaceParam;
338
338
  //================================================================================
339
339
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -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> = []) {
@@ -754,7 +762,7 @@ export class Interface extends BaseNode {
754
762
  //================================================================================
755
763
  }
756
764
 
757
- classMap['Interface'] = Interface;
765
+ classMap.Interface = Interface;
758
766
  export default Interface;
759
767
  //================================================================================
760
768
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -93,7 +93,7 @@ export class JSBlock extends LogicItem {
93
93
  //================================================================================
94
94
  }
95
95
 
96
- classMap['JSBlock'] = JSBlock;
96
+ classMap.JSBlock = JSBlock;
97
97
  export default JSBlock;
98
98
  //================================================================================
99
99
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -245,7 +245,7 @@ export class LogicItem extends BaseNode {
245
245
  //================================================================================
246
246
  }
247
247
 
248
- classMap['LogicItem'] = LogicItem;
248
+ classMap.LogicItem = LogicItem;
249
249
  export default LogicItem;
250
250
  //================================================================================
251
251
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑