@lcap/nasl 2.20.0-beta.2 → 2.20.0-beta.4

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 (323) hide show
  1. package/out/automate/engine/index.d.ts +1 -1
  2. package/out/automate/engine/index.js +2 -3
  3. package/out/automate/engine/index.js.map +1 -1
  4. package/out/automate/engine/uniqueName.d.ts +1 -1
  5. package/out/automate/engine/uniqueName.js +2 -2
  6. package/out/automate/engine/uniqueName.js.map +1 -1
  7. package/out/automate/engine/utils.js +4 -1
  8. package/out/automate/engine/utils.js.map +1 -1
  9. package/out/automate/template/myProcess.d.ts +1 -1
  10. package/out/automate/template/myProcess.js +2 -2
  11. package/out/automate/template/myProcess.js.map +1 -1
  12. package/out/bak/translator.js +14 -22
  13. package/out/bak/translator.js.map +1 -1
  14. package/out/common/BaseNode.js +4 -1
  15. package/out/common/BaseNode.js.map +1 -1
  16. package/out/common/Command.d.ts +1 -0
  17. package/out/common/Command.js +5 -1
  18. package/out/common/Command.js.map +1 -1
  19. package/out/concepts/App__.d.ts +4 -0
  20. package/out/concepts/App__.js +30 -6
  21. package/out/concepts/App__.js.map +1 -1
  22. package/out/concepts/Assignee__.js +4 -3
  23. package/out/concepts/Assignee__.js.map +1 -1
  24. package/out/concepts/BatchAssignment__.js +3 -3
  25. package/out/concepts/BatchAssignment__.js.map +1 -1
  26. package/out/concepts/BindAttribute__.d.ts +7 -0
  27. package/out/concepts/BindAttribute__.js +270 -39
  28. package/out/concepts/BindAttribute__.js.map +1 -1
  29. package/out/concepts/BindDirective__.d.ts +7 -0
  30. package/out/concepts/BindDirective__.js +215 -17
  31. package/out/concepts/BindDirective__.js.map +1 -1
  32. package/out/concepts/BindStyle__.d.ts +7 -0
  33. package/out/concepts/BindStyle__.js +194 -4
  34. package/out/concepts/BindStyle__.js.map +1 -1
  35. package/out/concepts/CallFunction__.js +22 -8
  36. package/out/concepts/CallFunction__.js.map +1 -1
  37. package/out/concepts/CallInterface__.js +3 -2
  38. package/out/concepts/CallInterface__.js.map +1 -1
  39. package/out/concepts/CallLogic__.d.ts +3 -0
  40. package/out/concepts/CallLogic__.js +78 -89
  41. package/out/concepts/CallLogic__.js.map +1 -1
  42. package/out/concepts/CallQueryComponent__.js +20 -3
  43. package/out/concepts/CallQueryComponent__.js.map +1 -1
  44. package/out/concepts/ConfigGroup__.d.ts +1 -0
  45. package/out/concepts/ConfigGroup__.js +13 -0
  46. package/out/concepts/ConfigGroup__.js.map +1 -1
  47. package/out/concepts/ConfigProperty__.d.ts +19 -0
  48. package/out/concepts/ConfigProperty__.js +61 -0
  49. package/out/concepts/ConfigProperty__.js.map +1 -1
  50. package/out/concepts/Configuration__.d.ts +1 -0
  51. package/out/concepts/Configuration__.js +13 -0
  52. package/out/concepts/Configuration__.js.map +1 -1
  53. package/out/concepts/DataSource__.js.map +1 -1
  54. package/out/concepts/Destination__.d.ts +1 -0
  55. package/out/concepts/Destination__.js +61 -7
  56. package/out/concepts/Destination__.js.map +1 -1
  57. package/out/concepts/EntityProperty__.js +9 -1
  58. package/out/concepts/EntityProperty__.js.map +1 -1
  59. package/out/concepts/EnumItem__.d.ts +5 -5
  60. package/out/concepts/EnumItem__.js +6 -6
  61. package/out/concepts/Enum__.d.ts +20 -19
  62. package/out/concepts/Enum__.js +28 -1
  63. package/out/concepts/Enum__.js.map +1 -1
  64. package/out/concepts/ExternalDestination__.d.ts +1 -0
  65. package/out/concepts/ExternalDestination__.js +21 -3
  66. package/out/concepts/ExternalDestination__.js.map +1 -1
  67. package/out/concepts/ForEachStatement__.js +2 -0
  68. package/out/concepts/ForEachStatement__.js.map +1 -1
  69. package/out/concepts/Frontend__.d.ts +2 -1
  70. package/out/concepts/Frontend__.js.map +1 -1
  71. package/out/concepts/Identifier__.js +16 -5
  72. package/out/concepts/Identifier__.js.map +1 -1
  73. package/out/concepts/InterfaceParam__.js +9 -1
  74. package/out/concepts/InterfaceParam__.js.map +1 -1
  75. package/out/concepts/JSBlock__.js +5 -1
  76. package/out/concepts/JSBlock__.js.map +1 -1
  77. package/out/concepts/Logic__.d.ts +79 -79
  78. package/out/concepts/Logic__.js +16 -3
  79. package/out/concepts/Logic__.js.map +1 -1
  80. package/out/concepts/Match__.d.ts +0 -3
  81. package/out/concepts/Match__.js +11 -66
  82. package/out/concepts/Match__.js.map +1 -1
  83. package/out/concepts/MemberExpression__.js +9 -0
  84. package/out/concepts/MemberExpression__.js.map +1 -1
  85. package/out/concepts/Module__.d.ts +16 -0
  86. package/out/concepts/Module__.js +43 -0
  87. package/out/concepts/Module__.js.map +1 -1
  88. package/out/concepts/NewComposite__.d.ts +2 -4
  89. package/out/concepts/NewComposite__.js +91 -126
  90. package/out/concepts/NewComposite__.js.map +1 -1
  91. package/out/concepts/NewList__.d.ts +1 -0
  92. package/out/concepts/NewList__.js +22 -2
  93. package/out/concepts/NewList__.js.map +1 -1
  94. package/out/concepts/NewMap__.d.ts +1 -0
  95. package/out/concepts/NewMap__.js +43 -11
  96. package/out/concepts/NewMap__.js.map +1 -1
  97. package/out/concepts/OqlQueryComponent__.js +40 -12
  98. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  99. package/out/concepts/Param__.js +10 -2
  100. package/out/concepts/Param__.js.map +1 -1
  101. package/out/concepts/ProcessElement__.js +2 -1
  102. package/out/concepts/ProcessElement__.js.map +1 -1
  103. package/out/concepts/ProcessOutcome__.js +1 -1
  104. package/out/concepts/ProcessOutcome__.js.map +1 -1
  105. package/out/concepts/ProcessOutcomes__.js +1 -1
  106. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  107. package/out/concepts/Process__.js +1 -0
  108. package/out/concepts/Process__.js.map +1 -1
  109. package/out/concepts/Return__.js +10 -2
  110. package/out/concepts/Return__.js.map +1 -1
  111. package/out/concepts/StringInterpolation__.js +14 -2
  112. package/out/concepts/StringInterpolation__.js.map +1 -1
  113. package/out/concepts/StringLiteral__.js +6 -6
  114. package/out/concepts/StringLiteral__.js.map +1 -1
  115. package/out/concepts/StructureProperty__.js +9 -1
  116. package/out/concepts/StructureProperty__.js.map +1 -1
  117. package/out/concepts/TypeAnnotation__.d.ts +6 -3
  118. package/out/concepts/TypeAnnotation__.js +67 -13
  119. package/out/concepts/TypeAnnotation__.js.map +1 -1
  120. package/out/concepts/ValidationRule__.d.ts +1 -0
  121. package/out/concepts/ValidationRule__.js +53 -0
  122. package/out/concepts/ValidationRule__.js.map +1 -1
  123. package/out/concepts/Variable__.js +9 -1
  124. package/out/concepts/Variable__.js.map +1 -1
  125. package/out/concepts/ViewElement__.js +17 -1
  126. package/out/concepts/ViewElement__.js.map +1 -1
  127. package/out/concepts/View__.d.ts +1 -3
  128. package/out/concepts/View__.js +22 -11
  129. package/out/concepts/View__.js.map +1 -1
  130. package/out/concepts/basics/stdlib/nasl.collection.js +6 -1
  131. package/out/concepts/basics/stdlib/nasl.collection.js.map +1 -1
  132. package/out/concepts/basics/stdlib/nasl.configuration.js +3 -0
  133. package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
  134. package/out/concepts/basics/stdlib/nasl.core.d.ts +2 -0
  135. package/out/concepts/basics/stdlib/nasl.core.js +34 -0
  136. package/out/concepts/basics/stdlib/nasl.core.js.map +1 -1
  137. package/out/concepts/basics/stdlib/nasl.util.js +4 -2
  138. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  139. package/out/concepts/basics/types/index.d.ts +1 -0
  140. package/out/concepts/basics/types/index.js +3 -1
  141. package/out/concepts/basics/types/index.js.map +1 -1
  142. package/out/concepts/index__.d.ts +0 -1
  143. package/out/concepts/index__.js +0 -1
  144. package/out/concepts/index__.js.map +1 -1
  145. package/out/enums/KEYWORDS.js +8 -0
  146. package/out/enums/KEYWORDS.js.map +1 -1
  147. package/out/generator/genBundleFiles.js +24 -5
  148. package/out/generator/genBundleFiles.js.map +1 -1
  149. package/out/generator/genReleaseBody.d.ts +2 -3
  150. package/out/generator/genReleaseBody.js +97 -23
  151. package/out/generator/genReleaseBody.js.map +1 -1
  152. package/out/generator/permission.d.ts +2 -10
  153. package/out/generator/permission.js +27 -14
  154. package/out/generator/permission.js.map +1 -1
  155. package/out/server/entity2LogicNamespace.js +2 -20
  156. package/out/server/entity2LogicNamespace.js.map +1 -1
  157. package/out/server/extendBaseNode.js +16 -5
  158. package/out/server/extendBaseNode.js.map +1 -1
  159. package/out/server/formatTsUtils.d.ts +2 -1
  160. package/out/server/formatTsUtils.js +40 -10
  161. package/out/server/formatTsUtils.js.map +1 -1
  162. package/out/server/getLogics.d.ts +2 -2
  163. package/out/server/getLogics.js +3 -3
  164. package/out/server/getLogics.js.map +1 -1
  165. package/out/server/getMemberIdentifier.d.ts +1 -0
  166. package/out/server/getMemberIdentifier.js +27 -1
  167. package/out/server/getMemberIdentifier.js.map +1 -1
  168. package/out/server/index.js +1 -0
  169. package/out/server/index.js.map +1 -1
  170. package/out/server/naslServer.d.ts +7 -1
  171. package/out/server/naslServer.js +519 -46
  172. package/out/server/naslServer.js.map +1 -1
  173. package/out/server/translator.js +109 -33
  174. package/out/server/translator.js.map +1 -1
  175. package/out/service/storage/init.js +21 -1
  176. package/out/service/storage/init.js.map +1 -1
  177. package/out/templator/genCreateBlock.js +1 -3
  178. package/out/templator/genCreateBlock.js.map +1 -1
  179. package/out/templator/genCurdEditMultipleKeyBlock.js +1 -3
  180. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  181. package/out/templator/genCurdMultipleKeyBlock.js +2 -4
  182. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  183. package/out/templator/genGetBlock.js +1 -1
  184. package/out/templator/genGetBlock.js.map +1 -1
  185. package/out/templator/genGridViewBlock.js +2 -2
  186. package/out/templator/genGridViewBlock.js.map +1 -1
  187. package/out/templator/genListViewBlock.js +7 -1
  188. package/out/templator/genListViewBlock.js.map +1 -1
  189. package/out/templator/genSelectBlock.js +1 -1
  190. package/out/templator/genSelectBlock.js.map +1 -1
  191. package/out/templator/genTableBlock.js +2 -2
  192. package/out/templator/genTableBlock.js.map +1 -1
  193. package/out/templator/genUpdateBlock.js +2 -3
  194. package/out/templator/genUpdateBlock.js.map +1 -1
  195. package/out/utils/traverse.js +8 -2
  196. package/out/utils/traverse.js.map +1 -1
  197. package/package.json +2 -2
  198. package/sandbox/stdlib/dist/nasl.logging.js +0 -0
  199. package/sandbox/stdlib/dist/nasl.util.js +0 -0
  200. package/sandbox/stdlib/nasl.collection.ts +1 -0
  201. package/sandbox/stdlib/nasl.core.ts +34 -0
  202. package/sandbox/stdlib/nasl.oql.ts +71 -15
  203. package/sandbox/stdlib/nasl.util.ts +9 -3
  204. package/src/automate/engine/dist/index.dev.js +517 -0
  205. package/src/automate/engine/index.js +2 -3
  206. package/src/automate/engine/uniqueName.js +2 -2
  207. package/src/automate/engine/utils.js +4 -2
  208. package/src/automate/template/myProcess.js +2 -2
  209. package/src/bak/translator.js +16 -25
  210. package/src/common/BaseNode.ts +3 -1
  211. package/src/common/Command.ts +4 -0
  212. package/src/common/dist/BaseNode.js +1101 -0
  213. package/src/concepts/App__.ts +36 -7
  214. package/src/concepts/Assignee__.ts +4 -3
  215. package/src/concepts/BatchAssignment__.ts +3 -3
  216. package/src/concepts/BindAttribute__.ts +299 -38
  217. package/src/concepts/BindDirective__.ts +204 -31
  218. package/src/concepts/BindStyle__.ts +187 -24
  219. package/src/concepts/CallFunction__.ts +55 -10
  220. package/src/concepts/CallInterface__.ts +3 -2
  221. package/src/concepts/CallLogic__.ts +110 -90
  222. package/src/concepts/CallQueryComponent__.ts +18 -3
  223. package/src/concepts/ConfigGroup__.ts +17 -4
  224. package/src/concepts/ConfigProperty__.ts +70 -4
  225. package/src/concepts/Configuration__.ts +14 -5
  226. package/src/concepts/DataSource__.ts +4 -1
  227. package/src/concepts/Destination__.ts +61 -7
  228. package/src/concepts/EntityProperty__.ts +7 -1
  229. package/src/concepts/EnumItem__.ts +6 -6
  230. package/src/concepts/Enum__.ts +22 -19
  231. package/src/concepts/ExternalDestination__.ts +28 -8
  232. package/src/concepts/ForEachStatement__.ts +2 -0
  233. package/src/concepts/Frontend__.ts +2 -1
  234. package/src/concepts/Identifier__.ts +16 -5
  235. package/src/concepts/InterfaceParam__.ts +7 -1
  236. package/src/concepts/JSBlock__.ts +3 -2
  237. package/src/concepts/Logic__.ts +95 -83
  238. package/src/concepts/Match__.ts +31 -67
  239. package/src/concepts/MemberExpression__.ts +6 -0
  240. package/src/concepts/Module__.ts +57 -0
  241. package/src/concepts/NewComposite__.ts +95 -140
  242. package/src/concepts/NewList__.ts +23 -2
  243. package/src/concepts/NewMap__.ts +48 -24
  244. package/src/concepts/OqlQueryComponent__.ts +40 -20
  245. package/src/concepts/Param__.ts +178 -176
  246. package/src/concepts/ProcessElement__.ts +2 -1
  247. package/src/concepts/ProcessOutcome__.ts +1 -1
  248. package/src/concepts/ProcessOutcomes__.ts +1 -1
  249. package/src/concepts/Process__.ts +1 -0
  250. package/src/concepts/Return__.ts +8 -2
  251. package/src/concepts/StringInterpolation__.ts +19 -7
  252. package/src/concepts/StringLiteral__.ts +7 -6
  253. package/src/concepts/StructureProperty__.ts +7 -1
  254. package/src/concepts/TypeAnnotation__.ts +101 -14
  255. package/src/concepts/ValidationRule__.ts +58 -9
  256. package/src/concepts/Variable__.ts +11 -1
  257. package/src/concepts/ViewElement__.ts +39 -2
  258. package/src/concepts/View__.ts +26 -14
  259. package/src/concepts/basics/stdlib/dist/nasl.util.js +1602 -0
  260. package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
  261. package/src/concepts/basics/stdlib/nasl.collection.ts +6 -1
  262. package/src/concepts/basics/stdlib/nasl.configuration.ts +3 -0
  263. package/src/concepts/basics/stdlib/nasl.core.ts +33 -2
  264. package/src/concepts/basics/stdlib/nasl.util.ts +4 -2
  265. package/src/concepts/basics/types/index.ts +1 -0
  266. package/src/concepts/dist/BindAttribute__.js +795 -0
  267. package/src/concepts/dist/BindEvent__.js +732 -0
  268. package/src/concepts/dist/CallFunction__.js +527 -0
  269. package/src/concepts/dist/CallLogic__.js +932 -0
  270. package/src/concepts/dist/Destination__.js +708 -0
  271. package/src/concepts/dist/ExternalDestination__.js +298 -0
  272. package/src/concepts/dist/Identifier__.js +311 -0
  273. package/src/concepts/dist/StringInterpolation__.js +231 -0
  274. package/src/concepts/dist/TypeAnnotation__.js +834 -0
  275. package/src/concepts/dist/ViewElement__.js +1692 -0
  276. package/src/concepts/dist/View__.js +1601 -0
  277. package/src/concepts/index__.ts +0 -1
  278. package/src/enums/KEYWORDS.ts +8 -0
  279. package/src/generator/dist/genBundleFiles.js +261 -0
  280. package/src/generator/dist/genMetaData.js +245 -0
  281. package/src/generator/dist/permission.js +405 -0
  282. package/src/generator/genBundleFiles.ts +24 -5
  283. package/src/generator/genReleaseBody.ts +75 -30
  284. package/src/generator/permission.ts +31 -15
  285. package/src/server/entity2LogicNamespace.ts +2 -20
  286. package/src/server/extendBaseNode.ts +15 -5
  287. package/src/server/formatTsUtils.ts +41 -10
  288. package/src/server/getLogics.ts +4 -4
  289. package/src/server/getMemberIdentifier.ts +27 -1
  290. package/src/server/index.ts +2 -0
  291. package/src/server/naslServer.ts +520 -48
  292. package/src/server/translator.ts +96 -34
  293. package/src/service/storage/dist/init.js +579 -0
  294. package/src/service/storage/init.ts +22 -2
  295. package/src/templator/dist/genEditTableBlock.js +204 -0
  296. package/src/templator/dist/genGridViewBlock.js +265 -0
  297. package/src/templator/dist/genListViewBlock.js +84 -0
  298. package/src/templator/dist/genTableBlock.js +209 -0
  299. package/src/templator/dist/utils.js +527 -0
  300. package/src/templator/genCreateBlock.ts +1 -3
  301. package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -3
  302. package/src/templator/genCurdMultipleKeyBlock.ts +2 -4
  303. package/src/templator/genGetBlock.ts +1 -1
  304. package/src/templator/genGridViewBlock.ts +3 -4
  305. package/src/templator/genListViewBlock.ts +9 -3
  306. package/src/templator/genSelectBlock.ts +1 -1
  307. package/src/templator/genTableBlock.ts +3 -3
  308. package/src/templator/genUpdateBlock.ts +2 -3
  309. package/src/utils/traverse.ts +10 -2
  310. package/ts-worker/lib/tsserver.js +10 -2
  311. package/ts-worker/package.json +1 -0
  312. package/ts-worker/webpack.config.js +11 -2
  313. package/out/concepts/ConstructArgument__.d.ts +0 -40
  314. package/out/concepts/ConstructArgument__.js +0 -108
  315. package/out/concepts/ConstructArgument__.js.map +0 -1
  316. package/out/concepts/Construct__.d.ts +0 -189
  317. package/out/concepts/Construct__.js +0 -340
  318. package/out/concepts/Construct__.js.map +0 -1
  319. package/out/templator/sql-parser/index.d.ts +0 -1
  320. package/out/templator/sql-parser/index.js +0 -228
  321. package/out/templator/sql-parser/index.js.map +0 -1
  322. package/out/templator/sql-parser/parser.js +0 -26664
  323. package/out/templator/sql-parser/parser.js.map +0 -1
@@ -54,8 +54,6 @@ export class OqlQueryComponent extends LogicItem {
54
54
  @property()
55
55
  dataSource: string = undefined;
56
56
 
57
-
58
-
59
57
  /**
60
58
  * @param source 需要合并的部分参数
61
59
  */
@@ -69,7 +67,6 @@ export class OqlQueryComponent extends LogicItem {
69
67
  return super.from(source, parentNode, parentKey) as OqlQueryComponent;
70
68
  }
71
69
 
72
-
73
70
  /**
74
71
  * 设置SQL 查询
75
72
  */
@@ -82,10 +79,6 @@ export class OqlQueryComponent extends LogicItem {
82
79
  });
83
80
  }
84
81
 
85
-
86
-
87
-
88
-
89
82
  /**
90
83
  * 删除类型标注
91
84
  * @param name 类型标注名称
@@ -272,24 +265,44 @@ export class OqlQueryComponent extends LogicItem {
272
265
  @withSourceMap()
273
266
  toEmbeddedTS(state?: TranslatorState): string {
274
267
  let code: string;
275
- code = `(function(): `;
276
- code += `${this.typeAnnotation ? this.typeAnnotation.toEmbeddedTS(shiftState(state, code)) : '__NO_SELECT_TYPE__'} {\n`;
277
- // app.dataSources.defaultDS;
268
+ const typeAnnotation = this.typeAnnotation;
269
+ if (typeAnnotation) {
270
+ code = `(function(): ${typeAnnotation.toEmbeddedTS()} {\n`;
271
+ } else {
272
+ code = `(function __oqlQueryFn${String(this.id).slice(0, 8)} () {\n`;
273
+ }
274
+
275
+ const indent1 = indent((state?.tabSize || 0) + 1);
276
+ // this.dataSource: 'app.dataSources.defaultDS';
278
277
  if (this.dataSource) {
279
- code += indent((state?.tabSize || 0) + 1);
278
+ code += indent1;
280
279
  code += `const dataSource = ${this.dataSource || 'app.dataSources.defaultDS'};\n`;
281
280
  }
281
+ const hasSyntaxErrors = !!this.codeSourceMap?.oqlSyntaxError?.syntaxErrors?.length;
282
282
  // 生成内部的ts内容
283
- if (this.codeSourceMap) {
284
- code += this.codeSourceMap.typescript || '';
285
- if (!this.code) {
286
- // SQL 为空
287
- code += '__OQL_EMPTY_ERROR__;';
288
- } else if (this.codeSourceMap.lexicalErrorCode === 1001) {
283
+ if (!this.code) {
284
+ // SQL 为空
285
+ code += `${indent1}__OQL_EMPTY_ERROR__;\n`;
286
+ } else if (hasSyntaxErrors) {
287
+ const syntaxErrors = this.codeSourceMap?.oqlSyntaxError?.syntaxErrors || [];
288
+ const warningList = syntaxErrors.filter((err: any) => err.errorMsg.includes('别名不符合规范'));
289
+ if (warningList.length === syntaxErrors.length) {
290
+ // SQL 别名警告
291
+ code += `${indent1}__OQL_ALIAS_WARNING__;\n`;
292
+ } else {
293
+ if (warningList.length > 0) {
294
+ // SQL 别名警告
295
+ code += `${indent1}__OQL_ALIAS_WARNING__;\n`;
296
+ }
289
297
  // SQL 语法错误
290
- code += '__OQL_GRAMMAR_ERROR__;';
298
+ code += `${indent1}__OQL_GRAMMAR_ERROR__;\n`;
291
299
  }
292
300
  }
301
+ // insert typescript code
302
+ const typescript = this.codeSourceMap?.typescript;
303
+ if (typescript) {
304
+ code += `${indent1}const __oqlQueryResult = ${typescript};`;
305
+ }
293
306
 
294
307
  // 临时方案拼接字符串
295
308
  this.getTextVariables();
@@ -300,7 +313,12 @@ export class OqlQueryComponent extends LogicItem {
300
313
  code += ';\n';
301
314
  });
302
315
  code += '\n';
303
- code += indent((state?.tabSize || 0) + 1) + 'return;\n';
316
+
317
+ if (typescript && !typeAnnotation) {
318
+ code += `${indent1}return __oqlQueryResult;\n`;
319
+ } else {
320
+ code += `${indent1}return;\n`;
321
+ }
304
322
  code += indent((state?.tabSize || 0)) + '})()';
305
323
  return code;
306
324
  }
@@ -314,6 +332,8 @@ export class OqlQueryComponent extends LogicItem {
314
332
  oqlIdentifier: 'myoqlIdentifier',
315
333
  dataSourceName: this.dataSource,
316
334
  oql: this.code,
335
+ ideVersion: this.app.ideVersion,
336
+ dataSourceNasl: this.app.findNodeByCompleteName(this.dataSource).toJSON(),
317
337
  typeScriptStartLine: 1,
318
338
  typeScriptStartLineColumn: 1,
319
339
  },
@@ -335,7 +355,7 @@ export class OqlQueryComponent extends LogicItem {
335
355
  };
336
356
  }
337
357
 
338
- _TsVariables: Array<Identifier | MemberExpression>= [];
358
+ _TsVariables: Array<Identifier | MemberExpression> = [];
339
359
 
340
360
  // 节点的sourcemap
341
361
  codeSourceMap: any = undefined;
@@ -9,13 +9,13 @@ import Function from './Function__';
9
9
  import AnonymousFunction from './AnonymousFunction__';
10
10
 
11
11
  function tryJSONParse(str: string) {
12
- let result;
12
+ let result;
13
13
 
14
- try {
15
- result = JSON.parse(str);
16
- } catch (e) { }
14
+ try {
15
+ result = JSON.parse(str);
16
+ } catch (e) { }
17
17
 
18
- return result;
18
+ return result;
19
19
  }
20
20
 
21
21
  //================================================================================
@@ -195,10 +195,6 @@ export class Param extends BaseNode {
195
195
  });
196
196
  }
197
197
 
198
-
199
-
200
-
201
-
202
198
  /**
203
199
  * 删除类型标注
204
200
  * @param name 类型标注名称
@@ -271,97 +267,97 @@ export class Param extends BaseNode {
271
267
  completionChildren: Array<EntityProperty | StructureProperty> = undefined;
272
268
 
273
269
  toJS(state?: TranslatorState): string {
274
- if (this.view) {
275
- const typeAnnotation = this.typeAnnotation || this.__TypeAnnotation;
276
- const needGenInitFromSchema = typeAnnotation && (
277
- !['primitive', 'union'].includes(typeAnnotation.typeKind)
270
+ if (this.view) {
271
+ const typeAnnotation = this.typeAnnotation || this.__TypeAnnotation;
272
+ const needGenInitFromSchema = typeAnnotation && (
273
+ !['primitive', 'union'].includes(typeAnnotation.typeKind)
278
274
  || typeAnnotation.typeName === 'DateTime'
279
- );
280
- let code = `${this.name} = `;
281
- if (needGenInitFromSchema) {
282
- code += `this.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}',`;
283
- }
284
- const defaultValue = this.defaultValue;
285
- const defaultValueType = Object.prototype.toString.call(defaultValue);
286
- const { typeKind, typeNamespace, typeName } = typeAnnotation || {};
287
- // 设置成null,才能同步给后端清除该值,但是null对checkbox组件是一种特殊状态
288
- let parsedValue = defaultValue ?? undefined;
289
- if (
290
- defaultValueType === '[object String]'
275
+ );
276
+ let code = `${this.name} = `;
277
+ if (needGenInitFromSchema) {
278
+ code += `this.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}',`;
279
+ }
280
+ const defaultValue = this.defaultValue;
281
+ const defaultValueType = Object.prototype.toString.call(defaultValue);
282
+ const { typeKind, typeNamespace, typeName } = typeAnnotation || {};
283
+ // 设置成null,才能同步给后端清除该值,但是null对checkbox组件是一种特殊状态
284
+ let parsedValue = defaultValue ?? undefined;
285
+ if (
286
+ defaultValueType === '[object String]'
291
287
  && (
292
- !(typeKind === 'primitive' && typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName))
288
+ !(typeKind === 'primitive' && typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName))
293
289
  && !(this.isEnum())
294
290
  && !['union'].includes(typeKind)
295
291
  )
296
- ) {
297
- // 一些特殊情况,特殊处理成undefined
298
- // 1.defaultValue在nasl节点上错误得赋值给了空制符串
299
- if ([''].includes(defaultValue)) {
300
- parsedValue = undefined;
301
- } else {
302
- parsedValue = tryJSONParse(defaultValue) ?? defaultValue;
303
- }
304
- }
305
- code += `${this.name} || (this.$route.query.hasOwnProperty('${this.name}') ? this.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}', this.$route.query.${this.name}) : ${JSON.stringify(this.defaultValue)})`;
292
+ ) {
293
+ // 一些特殊情况,特殊处理成undefined
294
+ // 1.defaultValue在nasl节点上错误得赋值给了空制符串
295
+ if ([''].includes(defaultValue)) {
296
+ parsedValue = undefined;
297
+ } else {
298
+ parsedValue = tryJSONParse(defaultValue) ?? defaultValue;
299
+ }
300
+ }
301
+ code += `${this.name} || (this.$route.query.hasOwnProperty('${this.name}') ? this.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}', this.$route.query.${this.name}) : ${JSON.stringify(this.defaultValue)})`;
306
302
 
307
- if (needGenInitFromSchema) {
308
- code += `)`;
303
+ if (needGenInitFromSchema) {
304
+ code += `)`;
305
+ }
306
+ return code;
307
+ } else {
308
+ return '';
309
309
  }
310
- return code;
311
- } else {
312
- return '';
313
- }
314
310
  }
315
311
 
316
312
  isEnum() {
317
- return this.typeAnnotation?.typeNamespace?.endsWith('.enums');
313
+ return this.typeAnnotation?.typeNamespace?.endsWith('.enums');
318
314
  }
319
315
 
320
316
  @withSourceMap()
321
317
  toEmbeddedTS(state?: TranslatorState, dontType?: boolean): string {
322
- let code = this.name;
323
- // 回调函数类的参数
324
- if (this?.typeAnnotation?.typeKind === 'function') {
325
- code += ':{(';
326
- const paramTypes = this.typeAnnotation?.typeArguments || [];
327
- paramTypes.forEach((type, index) => {
328
- code += `type${index + 1}:` + type.toEmbeddedTS(shiftState(state, code));
329
- if (index !== paramTypes.length - 1) {
330
- code += ',';
331
- } else {
332
- code += ')';
333
- }
334
- });
335
- code += ':';
336
- const returnTypes = (this.typeAnnotation?.returnType || []);
337
- returnTypes.forEach((type) => {
338
- code += type.toEmbeddedTS(shiftState(state, code));
339
- });
340
- code += '}';
341
- return code;
342
- }
318
+ let code = this.name;
319
+ // 回调函数类的参数
320
+ if (this?.typeAnnotation?.typeKind === 'function') {
321
+ code += ':{(';
322
+ const paramTypes = this.typeAnnotation?.typeArguments || [];
323
+ paramTypes.forEach((type, index) => {
324
+ code += `type${index + 1}:` + type.toEmbeddedTS(shiftState(state, code));
325
+ if (index !== paramTypes.length - 1) {
326
+ code += ',';
327
+ } else {
328
+ code += ')';
329
+ }
330
+ });
331
+ code += ':';
332
+ const returnTypes = (this.typeAnnotation?.returnType || []);
333
+ returnTypes.forEach((type) => {
334
+ code += type.toEmbeddedTS(shiftState(state, code));
335
+ });
336
+ code += '}';
337
+ return code;
338
+ }
343
339
 
344
- if (this.defaultExpression instanceof Function || this.defaultExpression instanceof AnonymousFunction) {
345
- code += this.required ? ': ' : '?: ';
346
- code += this.defaultExpression.toEmbeddedTSDefinition(shiftState(state, code));
347
- } else if (!dontType && this.typeAnnotation) {
348
- code += ': ';
349
- code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
350
- // toTS暂时只需要翻译引用数据类型的,因为值都是字符串
351
- // 就不在这里赋值了,这里单纯就为了快速查找
352
- // 并且屏蔽了一些异常的错误
353
- if (this.typeAnnotation?.typeKind !== 'primitive' && this.defaultValue) {
354
- if (this.isEnum()) {
355
- code += `= ${this.typeAnnotation.typeKey}['${this.defaultValue}']`;
356
- }
340
+ if (this.defaultExpression instanceof Function || this.defaultExpression instanceof AnonymousFunction) {
341
+ code += this.required ? ': ' : '?: ';
342
+ code += this.defaultExpression.toEmbeddedTSDefinition(shiftState(state, code));
343
+ } else if (!dontType && this.typeAnnotation) {
344
+ code += ': ';
345
+ code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
346
+ // toTS暂时只需要翻译引用数据类型的,因为值都是字符串
347
+ // 就不在这里赋值了,这里单纯就为了快速查找
348
+ // 并且屏蔽了一些异常的错误
349
+ if (this.typeAnnotation?.typeKind !== 'primitive' && this.defaultValue) {
350
+ if (this.isEnum()) {
351
+ code += `= ${this.typeAnnotation.typeKey}['${this.defaultValue}']`;
352
+ }
353
+ }
357
354
  }
358
- }
359
- return code;
355
+ return code;
360
356
  }
361
357
 
362
358
  @withSourceMap()
363
359
  toEmbeddedNameTS(state?: TranslatorState): string {
364
- return `${this.name}`;
360
+ return `${this.name}`;
365
361
  }
366
362
  /**
367
363
  * 设置数据类型
@@ -374,47 +370,47 @@ export class Param extends BaseNode {
374
370
  */
375
371
  async setDataType(typeKey: string): Promise<void>;
376
372
  async setDataType(typeAnnotation: TypeAnnotation | string) {
377
- if (typeof typeAnnotation === 'string') {
378
- typeAnnotation = dataTypesMap[typeAnnotation];
379
- if (!typeAnnotation)
380
- // eslint-disable-next-line prefer-rest-params
381
- throw new Error('找不到类型:' + arguments[0]);
382
- } else {
383
- typeAnnotation._delete?.();
384
- const relationOptions = { parentId: this.id, parentConcept: this.concept, parentNode: this };
385
- Object.assign(typeAnnotation, relationOptions);
386
- }
387
- const object: any = {
388
- typeAnnotation,
389
- };
373
+ if (typeof typeAnnotation === 'string') {
374
+ typeAnnotation = dataTypesMap[typeAnnotation];
375
+ if (!typeAnnotation)
376
+ // eslint-disable-next-line prefer-rest-params
377
+ throw new Error('找不到类型:' + arguments[0]);
378
+ } else {
379
+ typeAnnotation._delete?.();
380
+ const relationOptions = { parentId: this.id, parentConcept: this.concept, parentNode: this };
381
+ Object.assign(typeAnnotation, relationOptions);
382
+ }
383
+ const object: any = {
384
+ typeAnnotation,
385
+ };
390
386
 
391
- // 切换类型的时候如果有默认值就清除掉
392
- if (this.defaultValue) {
393
- object.defaultValue = '';
394
- }
395
- try {
396
- this.completionChildren = this.getSelectRef(typeAnnotation);
397
- } catch (err) {
398
- this.completionChildren = [];
399
- console.log(err);
400
- }
401
- // 处理下拉属性
402
- return this.update({
403
- ...object,
404
- });
387
+ // 切换类型的时候如果有默认值就清除掉
388
+ if (this.defaultValue) {
389
+ object.defaultValue = '';
390
+ }
391
+ try {
392
+ this.completionChildren = this.getSelectRef(typeAnnotation);
393
+ } catch (err) {
394
+ this.completionChildren = [];
395
+ console.log(err);
396
+ }
397
+ // 处理下拉属性
398
+ return this.update({
399
+ ...object,
400
+ });
405
401
  }
406
402
 
407
403
  public static getDefaultOptions() {
408
- return {
409
- required: true,
410
- defaultValue: '',
411
- typeAnnotation: {
412
- concept: 'TypeAnnotation',
413
- typeKind: 'primitive',
414
- typeNamespace: 'nasl.core',
415
- typeName: 'String',
416
- },
417
- };
404
+ return {
405
+ required: true,
406
+ defaultValue: '',
407
+ typeAnnotation: {
408
+ concept: 'TypeAnnotation',
409
+ typeKind: 'primitive',
410
+ typeNamespace: 'nasl.core',
411
+ typeName: 'String',
412
+ },
413
+ };
418
414
  }
419
415
 
420
416
  _readonly: boolean = false;
@@ -422,86 +418,92 @@ export class Param extends BaseNode {
422
418
  * 是否可编辑
423
419
  * */
424
420
  get readonly() {
425
- return !!this.module || this._readonly;
421
+ return !!this.module || this._readonly;
426
422
  }
427
423
 
428
424
  set readonly(val) {
429
- this._readonly = val;
425
+ this._readonly = val;
430
426
  }
431
427
  get hasChildren() {
432
- const { typeKind, typeNamespace } = this.typeAnnotation;
433
- if (typeKind === 'reference' || typeKind === 'generic') {
434
- if (typeNamespace.endsWith('.enums'))
435
- return null;
436
- return [{}];
437
- }
438
- return null;
428
+ const { typeKind, typeNamespace, typeName } = this.typeAnnotation;
429
+ if (typeKind === 'reference' || typeKind === 'generic') {
430
+ if (typeNamespace.endsWith('.enums'))
431
+ return null;
432
+ return [{}];
433
+ } else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
434
+ return [{}];
435
+ }
436
+ return null;
439
437
  }
440
438
  get isTreeLeaf() {
441
- return !this.hasChildren;
439
+ return !this.hasChildren;
442
440
  }
443
441
  getSelectRef(newTypeAnnotation: TypeAnnotation) {
444
- try {
445
- const { typeName, typeKind, typeNamespace } = newTypeAnnotation || this.typeAnnotation;
446
- let completionChildren;
447
- if (typeKind === 'reference') {
448
- if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process' || typeNamespace === 'nasl.auth') {
449
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
450
- const properties = (node as Structure)?.properties || [];
451
- completionChildren = properties;
452
- } else if (typeNamespace.endsWith('.enums')) {
453
- completionChildren = [];
454
- } else {
455
- const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
456
- const properties = node?.properties || [];
457
- completionChildren = properties;
458
- }
459
- } else if (typeKind === 'generic') {
460
- // if (typeNamespace === 'nasl.collection' || typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.interface') {
461
- // }
462
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
463
- const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
464
- for (let i = 0; i < properties.length; i++) {
465
- const item = properties[i];
466
- if (item?.typeAnnotation?.typeKind === 'typeParam') {
467
- const newItem = StructureProperty.from(item.toJSON());
468
- newItem.typeAnnotation = this?.typeAnnotation?.typeArguments[0];
469
- newItem.parentNode = this;
470
- properties[i] = newItem;
442
+ try {
443
+ const { typeName, typeKind, typeNamespace, sortedTypeKey } = newTypeAnnotation || this.typeAnnotation;
444
+ let completionChildren;
445
+ if (typeKind === 'reference') {
446
+ if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process' || typeNamespace === 'nasl.auth') {
447
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
448
+ const properties = (node as Structure)?.properties || [];
449
+ completionChildren = properties;
450
+ } else if (typeNamespace.endsWith('.enums')) {
451
+ completionChildren = [];
452
+ } else {
453
+ const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
454
+ const properties = node?.properties || [];
455
+ completionChildren = properties;
456
+ }
457
+ } else if (typeKind === 'generic') {
458
+ // if (typeNamespace === 'nasl.collection' || typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.interface') {
459
+ // }
460
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
461
+ const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
462
+ for (let i = 0; i < properties.length; i++) {
463
+ const item = properties[i];
464
+ if (item?.typeAnnotation?.typeKind === 'typeParam') {
465
+ const newItem = StructureProperty.from(item.toJSON());
466
+ newItem.typeAnnotation = this?.typeAnnotation?.typeArguments[0];
467
+ newItem.parentNode = this;
468
+ properties[i] = newItem;
469
+ }
470
+ }
471
+ completionChildren = properties;
472
+ } else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
473
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
474
+ const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
475
+ completionChildren = properties;
476
+ } else {
477
+ completionChildren = [];
471
478
  }
472
- }
473
- completionChildren = properties;
474
- } else {
475
- completionChildren = [];
479
+ return completionChildren;
480
+ } catch (err) {
481
+ console.log(err);
476
482
  }
477
- return completionChildren;
478
- } catch (err) {
479
- console.log(err);
480
- }
481
483
  }
482
484
 
483
485
  setnNewTypeAnnotation(oldTypeAnnotation: TypeAnnotation) {
484
- const json = oldTypeAnnotation.toJSON();
485
- const typeAnnotation = TypeAnnotation.from(json);
486
- this.typeAnnotation = typeAnnotation;
486
+ const json = oldTypeAnnotation.toJSON();
487
+ const typeAnnotation = TypeAnnotation.from(json);
488
+ this.typeAnnotation = typeAnnotation;
487
489
  }
488
490
  get isFunction() {
489
- return this.typeAnnotation.typeKind === 'function';
491
+ return this.typeAnnotation.typeKind === 'function';
490
492
  }
491
493
 
492
494
  get getFunctionSign() {
493
- if (this.isFunction) {
494
- const paramTypes = this.typeAnnotation.typeArguments || [];
495
- const returnTypes = this.typeAnnotation.returnType || [];
496
- const paramTypeNames = paramTypes.map((item) => item.sign);
497
- const returnTypeNames = returnTypes.map((item) => item.sign);
498
- return `(${paramTypeNames.toString()}) → ${returnTypeNames.toString()}`;
499
- } else {
500
- return '';
501
- }
495
+ if (this.isFunction) {
496
+ const paramTypes = this.typeAnnotation.typeArguments || [];
497
+ const returnTypes = this.typeAnnotation.returnType || [];
498
+ const paramTypeNames = paramTypes.map((item) => item.sign);
499
+ const returnTypeNames = returnTypes.map((item) => item.sign);
500
+ return `(${paramTypeNames.toString()}) → ${returnTypeNames.toString()}`;
501
+ } else {
502
+ return '';
503
+ }
502
504
  }
503
505
 
504
- //================================================================================
506
+ //================================================================================
505
507
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
506
508
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
507
509
  //================================================================================
@@ -1598,7 +1598,8 @@ export class ProcessElement extends BaseNode {
1598
1598
  || this.type === 'AutoTask'
1599
1599
  || this.type === 'InclusiveGateway') {
1600
1600
  const prevTasks = getPreviousTask(this);
1601
- let prevCode = `${tab4}const ${this.process.name} = {\n`;
1601
+ let prevCode = `${tab4}__ProcessIdentification__;\n`;
1602
+ prevCode += `${tab4}const ${this.process.name} = {\n`;
1602
1603
  const processName = this.process.name;
1603
1604
  this.process.params.forEach((p) => {
1604
1605
  prevCode += `${tab5}${p.name}: app.processes.${processName}.${p.name},\n`;
@@ -28,7 +28,7 @@ export class ProcessOutcome extends LogicItem {
28
28
  * 判断结果标题
29
29
  */
30
30
  @property()
31
- label: string = '判断结果';
31
+ label: string = '流向';
32
32
 
33
33
  /**
34
34
  * 关联连接器
@@ -27,7 +27,7 @@ export class ProcessOutcomes extends LogicItem {
27
27
  * 判断结果数组标题
28
28
  */
29
29
  @property()
30
- label: string = '判断结果';
30
+ label: string = '流向';
31
31
 
32
32
  /**
33
33
  * 关联连接器
@@ -1227,6 +1227,7 @@ export class Process extends BaseNode {
1227
1227
  const tab3 = indent((state?.tabSize || 0) + 3);
1228
1228
  // code += `${tab1}namespace variables{\n`;
1229
1229
 
1230
+ code += `${tab1}let __ProcessIdentification__: string;\n`;
1230
1231
  code += `${tab1}export namespace logics {\n`;
1231
1232
  const logic = genLaunchProcess(this);
1232
1233
  // sourceMap 映射
@@ -372,11 +372,13 @@ export class Return extends BaseNode {
372
372
  get hasChildren() {
373
373
  if (!this.typeAnnotation)
374
374
  return null;
375
- const { typeKind, typeNamespace } = this.typeAnnotation;
375
+ const { typeKind, typeNamespace, typeName } = this.typeAnnotation;
376
376
  if (typeKind === 'reference' || typeKind === 'generic') {
377
377
  if (typeNamespace.endsWith('.enums'))
378
378
  return null;
379
379
  return [{}];
380
+ } else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
381
+ return [{}];
380
382
  }
381
383
  return null;
382
384
  }
@@ -385,7 +387,7 @@ export class Return extends BaseNode {
385
387
  }
386
388
  getSelectRef(newTypeAnnotation: TypeAnnotation) {
387
389
  try {
388
- const { typeName, typeKind, typeNamespace } = newTypeAnnotation || this.typeAnnotation;
390
+ const { typeName, typeKind, typeNamespace, sortedTypeKey } = newTypeAnnotation || this.typeAnnotation;
389
391
  let completionChildren;
390
392
  if (typeKind === 'reference') {
391
393
  if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process' || typeNamespace === 'nasl.auth') {
@@ -412,6 +414,10 @@ export class Return extends BaseNode {
412
414
  }
413
415
  }
414
416
  completionChildren = properties;
417
+ } else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
418
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
419
+ const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
420
+ completionChildren = properties;
415
421
  } else {
416
422
  completionChildren = [];
417
423
  }