@lcap/nasl 2.18.0-beta.7 → 2.19.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 (265) hide show
  1. package/out/automate/template/myProcess.js +1 -1
  2. package/out/automate/template/myProcess.js.map +1 -1
  3. package/out/bak/translator.js +2 -1
  4. package/out/bak/translator.js.map +1 -1
  5. package/out/common/Command.d.ts +1 -0
  6. package/out/common/Command.js +5 -1
  7. package/out/common/Command.js.map +1 -1
  8. package/out/concepts/AnonymousFunction__.d.ts +1 -0
  9. package/out/concepts/AnonymousFunction__.js +40 -2
  10. package/out/concepts/AnonymousFunction__.js.map +1 -1
  11. package/out/concepts/App__.d.ts +10 -0
  12. package/out/concepts/App__.js +132 -0
  13. package/out/concepts/App__.js.map +1 -1
  14. package/out/concepts/Assignee__.js +4 -3
  15. package/out/concepts/Assignee__.js.map +1 -1
  16. package/out/concepts/BatchAssignment__.d.ts +2 -0
  17. package/out/concepts/BatchAssignment__.js +45 -1
  18. package/out/concepts/BatchAssignment__.js.map +1 -1
  19. package/out/concepts/BindAttribute__.js +8 -1
  20. package/out/concepts/BindAttribute__.js.map +1 -1
  21. package/out/concepts/CallFunction__.js +51 -18
  22. package/out/concepts/CallFunction__.js.map +1 -1
  23. package/out/concepts/CallInterface__.js +6 -4
  24. package/out/concepts/CallInterface__.js.map +1 -1
  25. package/out/concepts/CallLogic__.js +87 -15
  26. package/out/concepts/CallLogic__.js.map +1 -1
  27. package/out/concepts/CallQueryComponent__.js +4 -1
  28. package/out/concepts/CallQueryComponent__.js.map +1 -1
  29. package/out/concepts/DataSource__.d.ts +2 -0
  30. package/out/concepts/DataSource__.js +55 -1
  31. package/out/concepts/DataSource__.js.map +1 -1
  32. package/out/concepts/ForEachStatement__.js +2 -0
  33. package/out/concepts/ForEachStatement__.js.map +1 -1
  34. package/out/concepts/Identifier__.d.ts +1 -0
  35. package/out/concepts/Identifier__.js +18 -7
  36. package/out/concepts/Identifier__.js.map +1 -1
  37. package/out/concepts/LogicItem__.d.ts +1 -1
  38. package/out/concepts/LogicItem__.js.map +1 -1
  39. package/out/concepts/Logic__.d.ts +1 -0
  40. package/out/concepts/Logic__.js +27 -14
  41. package/out/concepts/Logic__.js.map +1 -1
  42. package/out/concepts/Match__.js +13 -8
  43. package/out/concepts/Match__.js.map +1 -1
  44. package/out/concepts/NewComposite__.d.ts +345 -0
  45. package/out/concepts/NewComposite__.js +1067 -0
  46. package/out/concepts/NewComposite__.js.map +1 -0
  47. package/out/concepts/NewList__.d.ts +130 -0
  48. package/out/concepts/NewList__.js +353 -0
  49. package/out/concepts/NewList__.js.map +1 -0
  50. package/out/concepts/NewMap__.d.ts +221 -0
  51. package/out/concepts/NewMap__.js +492 -0
  52. package/out/concepts/NewMap__.js.map +1 -0
  53. package/out/concepts/New__.d.ts +19 -0
  54. package/out/concepts/New__.js +66 -0
  55. package/out/concepts/New__.js.map +1 -0
  56. package/out/concepts/Param__.d.ts +2 -0
  57. package/out/concepts/Param__.js +40 -3
  58. package/out/concepts/Param__.js.map +1 -1
  59. package/out/concepts/ProcessElement__.js +31 -10
  60. package/out/concepts/ProcessElement__.js.map +1 -1
  61. package/out/concepts/ProcessOutcome__.js +1 -1
  62. package/out/concepts/ProcessOutcome__.js.map +1 -1
  63. package/out/concepts/ProcessOutcomes__.d.ts +30 -0
  64. package/out/concepts/{ConstructArgument__.js → ProcessOutcomes__.js} +27 -48
  65. package/out/concepts/ProcessOutcomes__.js.map +1 -0
  66. package/out/concepts/Return__.js +2 -1
  67. package/out/concepts/Return__.js.map +1 -1
  68. package/out/concepts/SelectMembers__.js +3 -3
  69. package/out/concepts/SelectMembers__.js.map +1 -1
  70. package/out/concepts/StringInterpolation__.js +12 -2
  71. package/out/concepts/StringInterpolation__.js.map +1 -1
  72. package/out/concepts/TypeAnnotation__.d.ts +4 -0
  73. package/out/concepts/TypeAnnotation__.js +66 -12
  74. package/out/concepts/TypeAnnotation__.js.map +1 -1
  75. package/out/concepts/ValidationRule__.js +1 -1
  76. package/out/concepts/ValidationRule__.js.map +1 -1
  77. package/out/concepts/Variable__.js +2 -1
  78. package/out/concepts/Variable__.js.map +1 -1
  79. package/out/concepts/ViewElement__.js +12 -0
  80. package/out/concepts/ViewElement__.js.map +1 -1
  81. package/out/concepts/View__.d.ts +1 -0
  82. package/out/concepts/View__.js +9 -0
  83. package/out/concepts/View__.js.map +1 -1
  84. package/out/concepts/basics/stdlib/nasl.auth.js +1 -1
  85. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
  86. package/out/concepts/basics/stdlib/nasl.logging.js +5 -0
  87. package/out/concepts/basics/stdlib/nasl.logging.js.map +1 -1
  88. package/out/concepts/basics/stdlib/nasl.ui.js +2 -0
  89. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  90. package/out/concepts/basics/stdlib/nasl.util.js +151 -19
  91. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  92. package/out/concepts/index__.d.ts +5 -0
  93. package/out/concepts/index__.js +5 -0
  94. package/out/concepts/index__.js.map +1 -1
  95. package/out/enums/KEYWORDS.js +1 -0
  96. package/out/enums/KEYWORDS.js.map +1 -1
  97. package/out/generator/genMetaData.js +1 -6
  98. package/out/generator/genMetaData.js.map +1 -1
  99. package/out/generator/genReleaseBody.d.ts +2 -0
  100. package/out/generator/genReleaseBody.js +18 -1
  101. package/out/generator/genReleaseBody.js.map +1 -1
  102. package/out/generator/index.d.ts +1 -0
  103. package/out/generator/index.js +1 -0
  104. package/out/generator/index.js.map +1 -1
  105. package/out/generator/permission.d.ts +9 -0
  106. package/out/generator/permission.js +235 -0
  107. package/out/generator/permission.js.map +1 -0
  108. package/out/index.d.ts +1 -1
  109. package/out/index.js +2 -1
  110. package/out/index.js.map +1 -1
  111. package/out/server/entity2LogicNamespace.js +69 -9
  112. package/out/server/entity2LogicNamespace.js.map +1 -1
  113. package/out/server/extendBaseNode.js +7 -3
  114. package/out/server/extendBaseNode.js.map +1 -1
  115. package/out/server/formatTsUtils.js +6 -0
  116. package/out/server/formatTsUtils.js.map +1 -1
  117. package/out/server/getLogics.d.ts +2 -1
  118. package/out/server/getLogics.js +11 -0
  119. package/out/server/getLogics.js.map +1 -1
  120. package/out/server/getMemberIdentifier.js +1 -1
  121. package/out/server/getMemberIdentifier.js.map +1 -1
  122. package/out/server/naslServer.d.ts +1 -1
  123. package/out/server/naslServer.js +161 -22
  124. package/out/server/naslServer.js.map +1 -1
  125. package/out/server/process2LogicNamespace.js +8 -0
  126. package/out/server/process2LogicNamespace.js.map +1 -1
  127. package/out/server/translator.js +53 -8
  128. package/out/server/translator.js.map +1 -1
  129. package/out/service/creator/add.configs.js +4 -0
  130. package/out/service/creator/add.configs.js.map +1 -1
  131. package/out/service/datasource/api.d.ts +12 -0
  132. package/out/service/datasource/api.js +14 -0
  133. package/out/service/datasource/api.js.map +1 -0
  134. package/out/service/datasource/index.d.ts +2 -0
  135. package/out/service/datasource/index.js +10 -0
  136. package/out/service/datasource/index.js.map +1 -0
  137. package/out/service/storage/init.js +8 -1
  138. package/out/service/storage/init.js.map +1 -1
  139. package/out/templator/genEditTableBlock.js +4 -5
  140. package/out/templator/genEditTableBlock.js.map +1 -1
  141. package/out/templator/genGetBlock.js +4 -3
  142. package/out/templator/genGetBlock.js.map +1 -1
  143. package/out/templator/genGridViewBlock.js +16 -14
  144. package/out/templator/genGridViewBlock.js.map +1 -1
  145. package/out/templator/genListViewBlock.js +5 -5
  146. package/out/templator/genListViewBlock.js.map +1 -1
  147. package/out/templator/genTableBlock.js +6 -10
  148. package/out/templator/genTableBlock.js.map +1 -1
  149. package/package.json +1 -1
  150. package/sandbox/stdlib/dist/nasl.util.js +0 -0
  151. package/sandbox/stdlib/nasl.auth.ts +1 -1
  152. package/sandbox/stdlib/nasl.core.ts +4 -0
  153. package/sandbox/stdlib/nasl.logging.ts +4 -4
  154. package/sandbox/stdlib/nasl.util.ts +13 -4
  155. package/src/automate/template/myProcess.js +1 -1
  156. package/src/bak/translator.js +4 -1
  157. package/src/common/Command.ts +4 -0
  158. package/src/concepts/AnonymousFunction__.ts +48 -2
  159. package/src/concepts/App__.ts +140 -41
  160. package/src/concepts/Assignee__.ts +4 -3
  161. package/src/concepts/BatchAssignment__.ts +45 -1
  162. package/src/concepts/BindAttribute__.ts +9 -2
  163. package/src/concepts/CallFunction__.ts +65 -31
  164. package/src/concepts/CallInterface__.ts +6 -22
  165. package/src/concepts/CallLogic__.ts +62 -13
  166. package/src/concepts/CallQueryComponent__.ts +4 -1
  167. package/src/concepts/DataSource__.ts +56 -1
  168. package/src/concepts/ForEachStatement__.ts +2 -0
  169. package/src/concepts/Identifier__.ts +18 -7
  170. package/src/concepts/LogicItem__.ts +1 -1
  171. package/src/concepts/Logic__.ts +48 -32
  172. package/src/concepts/Match__.ts +12 -8
  173. package/src/concepts/NewComposite__.ts +1356 -0
  174. package/src/concepts/NewList__.ts +444 -0
  175. package/src/concepts/NewMap__.ts +678 -0
  176. package/src/concepts/New__.ts +73 -0
  177. package/src/concepts/Param__.ts +238 -199
  178. package/src/concepts/ProcessElement__.ts +32 -10
  179. package/src/concepts/ProcessOutcome__.ts +1 -1
  180. package/src/concepts/ProcessOutcomes__.ts +90 -0
  181. package/src/concepts/Return__.ts +4 -1
  182. package/src/concepts/SelectMembers__.ts +3 -3
  183. package/src/concepts/StringInterpolation__.ts +21 -11
  184. package/src/concepts/TypeAnnotation__.ts +71 -50
  185. package/src/concepts/ValidationRule__.ts +19 -1
  186. package/src/concepts/Variable__.ts +4 -1
  187. package/src/concepts/ViewElement__.ts +38 -1
  188. package/src/concepts/View__.ts +12 -2
  189. package/src/concepts/basics/stdlib/dist/nasl.util.js +133 -34
  190. package/src/concepts/basics/stdlib/nasl.auth.ts +1 -1
  191. package/src/concepts/basics/stdlib/nasl.logging.ts +5 -0
  192. package/src/concepts/basics/stdlib/nasl.ui.ts +2 -0
  193. package/src/concepts/basics/stdlib/nasl.util.ts +153 -19
  194. package/src/concepts/dist/BindAttribute__.js +760 -0
  195. package/src/concepts/dist/BindEvent__.js +732 -0
  196. package/src/concepts/dist/CallFunction__.js +21 -7
  197. package/src/concepts/dist/CallLogic__.js +50 -10
  198. package/src/concepts/dist/Identifier__.js +311 -0
  199. package/src/concepts/dist/StringInterpolation__.js +231 -0
  200. package/src/concepts/dist/TypeAnnotation__.js +834 -0
  201. package/src/concepts/dist/ViewElement__.js +12 -0
  202. package/src/concepts/dist/View__.js +1601 -0
  203. package/src/concepts/index__.ts +5 -0
  204. package/src/enums/KEYWORDS.ts +1 -0
  205. package/src/generator/dist/genMetaData.js +1 -5
  206. package/src/generator/dist/permission.js +392 -0
  207. package/src/generator/genMetaData.ts +1 -6
  208. package/src/generator/genReleaseBody.ts +21 -3
  209. package/src/generator/index.ts +1 -0
  210. package/src/generator/permission.ts +271 -0
  211. package/src/index.ts +1 -1
  212. package/src/server/dist/naslServer.js +385 -269
  213. package/src/server/entity2LogicNamespace.ts +70 -10
  214. package/src/server/extendBaseNode.ts +7 -3
  215. package/src/server/formatTsUtils.ts +6 -0
  216. package/src/server/getLogics.ts +13 -1
  217. package/src/server/getMemberIdentifier.ts +1 -1
  218. package/src/server/naslServer.ts +162 -29
  219. package/src/server/process2LogicNamespace.ts +8 -0
  220. package/src/server/translator.ts +52 -9
  221. package/src/service/creator/add.configs.js +4 -0
  222. package/src/service/dataSource/api.js +11 -0
  223. package/src/service/dataSource/index.js +6 -0
  224. package/src/service/storage/dist/init.js +8 -1
  225. package/src/service/storage/init.ts +9 -2
  226. package/src/service/video/VideoTranscribe.js +1 -0
  227. package/src/templator/dist/genEditTableBlock.js +204 -0
  228. package/src/templator/dist/genGridViewBlock.js +265 -0
  229. package/src/templator/dist/genListViewBlock.js +84 -0
  230. package/src/templator/dist/genTableBlock.js +209 -0
  231. package/src/templator/dist/utils.js +527 -0
  232. package/src/templator/genEditTableBlock.ts +8 -16
  233. package/src/templator/genGetBlock.ts +18 -19
  234. package/src/templator/genGridViewBlock.ts +18 -18
  235. package/src/templator/genListViewBlock.ts +8 -11
  236. package/src/templator/genTableBlock.ts +6 -10
  237. package/ts-worker/dist/webpack.config.dev.js +1 -3
  238. package/ts-worker/lib/tsserver.js +8 -1
  239. package/out/automate/engine/2.14-components.d.ts +0 -1115
  240. package/out/automate/engine/2.14-components.js +0 -1087
  241. package/out/automate/engine/2.14-components.js.map +0 -1
  242. package/out/concepts/ConstructArgument__.d.ts +0 -40
  243. package/out/concepts/ConstructArgument__.js.map +0 -1
  244. package/out/concepts/Construct__.d.ts +0 -189
  245. package/out/concepts/Construct__.js +0 -340
  246. package/out/concepts/Construct__.js.map +0 -1
  247. package/out/concepts/MatchExpression__.d.ts +0 -97
  248. package/out/concepts/MatchExpression__.js +0 -281
  249. package/out/concepts/MatchExpression__.js.map +0 -1
  250. package/out/templator/sql-parser/index.d.ts +0 -1
  251. package/out/templator/sql-parser/index.js +0 -228
  252. package/out/templator/sql-parser/index.js.map +0 -1
  253. package/out/templator/sql-parser/parser.js +0 -26664
  254. package/out/templator/sql-parser/parser.js.map +0 -1
  255. package/src/concepts/dist/Anchor__.js +0 -179
  256. package/src/concepts/dist/Assignment__.js +0 -301
  257. package/src/concepts/dist/CallInterface__.js +0 -533
  258. package/src/concepts/dist/ForEachStatement__.js +0 -426
  259. package/src/concepts/dist/MatchCase__.js +0 -587
  260. package/src/concepts/dist/Match__.js +0 -631
  261. package/src/concepts/dist/MemberExpression__.js +0 -348
  262. package/src/concepts/dist/Param__.js +0 -538
  263. package/src/concepts/dist/Return__.js +0 -494
  264. package/src/concepts/dist/Variable__.js +0 -537
  265. package/src/server/dist/formatTsUtils.js +0 -683
@@ -731,7 +731,7 @@ export class BatchAssignment extends LogicItem {
731
731
  }
732
732
 
733
733
  deleteAssignmentLine(assignmentLine: AssignmentLine) {
734
- const newLine = this.assignmentLines.filter((line) => line === assignmentLine);
734
+ const newLine = this.assignmentLines.filter((line) => line !== assignmentLine);
735
735
  this.update({
736
736
  assignmentLines: newLine,
737
737
  });
@@ -769,6 +769,50 @@ export class BatchAssignment extends LogicItem {
769
769
  }
770
770
  }
771
771
 
772
+ changeMembers(oldNode:any, members: MemberExpression[], keepMembers: any, expression: LogicItem) {
773
+ this.app.emit('collect:start', {
774
+ actionMsg: '批量赋值修改变量',
775
+ });
776
+ const selectMember = oldNode.parentNode;
777
+ const autoConnectionIndex = this.rights.findIndex((right) => right === selectMember);
778
+ const newSelectMember = Object.assign({}, selectMember, { expression, members });
779
+ let newLines: any = [];
780
+ // 修改连线
781
+ if (selectMember.parentKey === 'left') {
782
+ members.forEach((item: any, index: any) => {
783
+ if (keepMembers.has(item.completeName)) {
784
+ const lines = this.findlines(item, selectMember);
785
+ lines.forEach((line) => {
786
+ const newLine = Object.assign({}, line, { leftIndex: [line.leftIndex[0], index] });
787
+ newLines.push(newLine);
788
+ });
789
+ }
790
+ });
791
+ this.update({
792
+ assignmentLines: newLines,
793
+ left: newSelectMember,
794
+ });
795
+ } else {
796
+ const splitIndex = this.rights.findIndex((right) => selectMember === right);
797
+ newLines = this.assignmentLines.filter(({ rightIndex }) => rightIndex[0] !== splitIndex);
798
+ members.forEach((item, index) => {
799
+ if (keepMembers.has(item.completeName)) {
800
+ const lines = this.findlines(item, selectMember);
801
+ lines.forEach((line) => {
802
+ const newLine = Object.assign({}, line, { rightIndex: [line.rightIndex[0], index] });
803
+ newLines.push(newLine);
804
+ });
805
+ }
806
+ });
807
+ this.update({
808
+ assignmentLines: newLines,
809
+ rights: [...this.rights.slice(0, splitIndex), newSelectMember, ...this.rights.slice(splitIndex + 1, this.rights.length)],
810
+ });
811
+ }
812
+ this.autoConnection && this.batchAutoConnection(autoConnectionIndex);
813
+ this.app.emit('collect:end');
814
+ }
815
+
772
816
  findMember(arrIndex: Array<number>, place: string) {
773
817
  const [firstIndex, secondIndex] = [arrIndex[0], arrIndex[1]];
774
818
  if (place === 'left') {
@@ -723,13 +723,20 @@ export class BindAttribute extends BaseNode {
723
723
  str += 'download="true" ';
724
724
  name = 'href';
725
725
  }
726
+ // 文本默认要经过toString转换
727
+ if (options.finalCode !== false && name === 'text' && !this.sync && this.type === 'dynamic') {
728
+ const expTypeAnnotation = (this.expression as any)?.typeAnnotation || this.expression?.__TypeAnnotation;
729
+ value = `$utils['ToString'](${value}, '${expTypeAnnotation?.sortedTypeKey}')`;
730
+ }
726
731
  if (this.type === 'string') {
727
732
  str += `${name}="${value}"`;
728
733
  } else {
729
734
  str += `:${name}${this.sync ? '.sync' : ''}="${value}"`;
730
735
  }
731
- } else if(this.type === 'string' && this.value === '')
732
- str = `${name}="${this.value}"`;
736
+ } else if (this.type === 'string' && this.value === '')
737
+ if (!['destination', 'externalDestination'].includes(this.name)) {
738
+ str = `${name}="${this.value}"`;
739
+ }
733
740
 
734
741
  return str;
735
742
  }
@@ -66,7 +66,7 @@ export class CallFunction extends LogicItem {
66
66
  @property('Argument')
67
67
  arguments: Array<Argument> = [];
68
68
 
69
-
69
+
70
70
 
71
71
  /**
72
72
  * @param source 需要合并的部分参数
@@ -81,12 +81,12 @@ export class CallFunction extends LogicItem {
81
81
  return super.from(source, parentNode, parentKey) as CallFunction;
82
82
  }
83
83
 
84
-
85
-
86
84
 
87
-
88
85
 
89
-
86
+
87
+
88
+
89
+
90
90
 
91
91
  /**
92
92
  * 插入类型标注
@@ -120,7 +120,7 @@ export class CallFunction extends LogicItem {
120
120
  return typeAnnotation;
121
121
  }
122
122
 
123
-
123
+
124
124
 
125
125
  /**
126
126
  * 插入类型标注
@@ -144,7 +144,7 @@ export class CallFunction extends LogicItem {
144
144
  return node;
145
145
  }
146
146
 
147
-
147
+
148
148
 
149
149
  /**
150
150
  * 添加类型标注
@@ -165,7 +165,7 @@ export class CallFunction extends LogicItem {
165
165
  return this._insertTypeAnnotationAt(options as any, index);
166
166
  }
167
167
 
168
-
168
+
169
169
 
170
170
  /**
171
171
  * 添加类型标注
@@ -193,7 +193,7 @@ export class CallFunction extends LogicItem {
193
193
 
194
194
 
195
195
 
196
-
196
+
197
197
 
198
198
  /**
199
199
  * 插入实际参数
@@ -227,7 +227,7 @@ export class CallFunction extends LogicItem {
227
227
  return argument;
228
228
  }
229
229
 
230
-
230
+
231
231
 
232
232
  /**
233
233
  * 插入实际参数
@@ -251,7 +251,7 @@ export class CallFunction extends LogicItem {
251
251
  return node;
252
252
  }
253
253
 
254
-
254
+
255
255
 
256
256
  /**
257
257
  * 添加实际参数
@@ -272,7 +272,7 @@ export class CallFunction extends LogicItem {
272
272
  return this._insertArgumentAt(options as any, index);
273
273
  }
274
274
 
275
-
275
+
276
276
 
277
277
  /**
278
278
  * 添加实际参数
@@ -298,7 +298,7 @@ export class CallFunction extends LogicItem {
298
298
  }
299
299
 
300
300
 
301
-
301
+
302
302
 
303
303
  /**
304
304
  * 删除类型标注
@@ -380,11 +380,19 @@ export class CallFunction extends LogicItem {
380
380
  } else {
381
381
  let code = `$utils['${this.calleeName}']`;
382
382
  code += '(';
383
- this.arguments?.forEach((arg, index) => {
384
- code += arg?.toVue(options);
385
- if (index !== this.arguments?.length - 1)
386
- code += ', ';
387
- });
383
+ if (Array.isArray(this.arguments) && this.arguments.length) {
384
+ const needToString = ['Concat'].includes(this.calleeName);
385
+ this.arguments?.forEach((arg: any, index) => {
386
+ let argStr = arg?.toVue(options);
387
+ if (needToString) {
388
+ const argTypeAnnotation = arg.typeAnnotation || arg.__TypeAnnotation;
389
+ argStr = `$utils['ToString'](${argStr}, '${argTypeAnnotation?.sortedTypeKey}')`;
390
+ }
391
+ code += argStr;
392
+ if (index !== this.arguments?.length - 1)
393
+ code += ', ';
394
+ });
395
+ }
388
396
  if (this.typeArguments && this.typeArguments.length) {
389
397
  if (this.arguments?.length)
390
398
  code += ', ';
@@ -423,23 +431,49 @@ export class CallFunction extends LogicItem {
423
431
  toJS(state?: TranslatorState): string {
424
432
  let code = `this.$utils['${this.calleeName}']`;
425
433
  code += '(';
426
- this.arguments?.forEach((arg, index) => {
427
- code += arg?.toJS(shiftState(state, code));
428
- if (index !== this.arguments?.length - 1)
429
- code += ', ';
430
- });
431
- if (this.typeArguments && this.typeArguments.length) {
432
- if (this.arguments?.length)
433
- code += ', ';
434
- this.typeArguments?.forEach((arg, index) => {
435
- code += arg?.toJS(shiftState(state, code));
436
- if (index !== this.typeArguments?.length - 1)
434
+ if (Array.isArray(this.arguments) && this.arguments.length) {
435
+ const needToString = ['Concat'].includes(this.calleeName);
436
+ this.arguments.forEach((arg: any, index) => {
437
+ let argStr = arg?.toJS(shiftState(state, code));
438
+ if (needToString) {
439
+ const argTypeAnnotation = arg.typeAnnotation || arg.__TypeAnnotation;
440
+ argStr = `this.$utils['ToString'](${argStr}, '${argTypeAnnotation?.sortedTypeKey}')`;
441
+ }
442
+ code += argStr;
443
+ if (index !== this.arguments?.length - 1)
437
444
  code += ', ';
438
445
  });
439
446
  }
447
+ const isStringConvert = ['ToString', 'FromString'].includes(this.calleeName);
448
+ let argTypeAnnotation;
449
+ if (isStringConvert) {
450
+ if (this.calleeName === 'ToString') {
451
+ const arg = this.arguments[0];
452
+ argTypeAnnotation = (arg as any).typeAnnotation || arg.__TypeAnnotation;
453
+ } else if (this.calleeName === 'FromString') {
454
+ argTypeAnnotation = this.typeArguments?.[0];
455
+ }
456
+ }
457
+ if (argTypeAnnotation) {
458
+ code += `, '${argTypeAnnotation?.sortedTypeKey}'`;
459
+ } else {
460
+ if (Array.isArray(this.typeArguments) && this.typeArguments.length) {
461
+ if (this.arguments?.length)
462
+ code += ', ';
463
+ this.typeArguments?.forEach((arg, index) => {
464
+ code += arg?.toJS(shiftState(state, code));
465
+ if (index !== this.typeArguments?.length - 1)
466
+ code += ', ';
467
+ });
468
+ }
469
+ }
470
+
440
471
  code += ')';
441
472
  const typeAnnotation = (this as any).typeAnnotation || this.__TypeAnnotation;
442
- const needGenInitFromSchema = typeAnnotation && !['primitive', 'union'].includes(typeAnnotation.typeKind);
473
+ const needGenInitFromSchema = typeAnnotation && (
474
+ !['primitive', 'union'].includes(typeAnnotation.typeKind)
475
+ || typeAnnotation.typeName === 'DateTime'
476
+ );
443
477
  if (needGenInitFromSchema) {
444
478
  code = `this.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}', ${code})`;
445
479
  }
@@ -550,7 +584,7 @@ export class CallFunction extends LogicItem {
550
584
  toEmbeddedTS(state?: TranslatorState): string {
551
585
  let code = '';
552
586
  const calleeKey = this.calleeKey;
553
- if (calleeKey === 'nasl.util.Convert') {
587
+ if (['nasl.util.Convert', 'nasl.util.FromString'].includes(calleeKey)) {
554
588
  // nasl.util.Convert(variable1)<nasl.core.String>();
555
589
  // 单独处理
556
590
 
@@ -61,8 +61,6 @@ export class CallInterface extends LogicItem {
61
61
  @property('Argument')
62
62
  arguments: Array<Argument> = [];
63
63
 
64
-
65
-
66
64
  /**
67
65
  * @param source 需要合并的部分参数
68
66
  */
@@ -76,13 +74,6 @@ export class CallInterface extends LogicItem {
76
74
  return super.from(source, parentNode, parentKey) as CallInterface;
77
75
  }
78
76
 
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
77
  /**
87
78
  * 插入实际参数
88
79
  * @internal
@@ -115,8 +106,6 @@ export class CallInterface extends LogicItem {
115
106
  return argument;
116
107
  }
117
108
 
118
-
119
-
120
109
  /**
121
110
  * 插入实际参数
122
111
  * @param argumentOptions 实际参数参数
@@ -139,8 +128,6 @@ export class CallInterface extends LogicItem {
139
128
  return node;
140
129
  }
141
130
 
142
-
143
-
144
131
  /**
145
132
  * 添加实际参数
146
133
  * @internal
@@ -160,8 +147,6 @@ export class CallInterface extends LogicItem {
160
147
  return this._insertArgumentAt(options as any, index);
161
148
  }
162
149
 
163
-
164
-
165
150
  /**
166
151
  * 添加实际参数
167
152
  * @param argumentOptions 实际参数参数
@@ -185,9 +170,6 @@ export class CallInterface extends LogicItem {
185
170
  return node;
186
171
  }
187
172
 
188
-
189
-
190
-
191
173
  /**
192
174
  * 删除实际参数
193
175
  * @param argument 已有的实际参数实例
@@ -195,7 +177,7 @@ export class CallInterface extends LogicItem {
195
177
  removeArgument(argument: Argument): void;
196
178
 
197
179
  removeArgument(options: Argument) {
198
- let argument: Argument = options;
180
+ const argument: Argument = options;
199
181
  return argument.delete();
200
182
  }
201
183
 
@@ -368,7 +350,8 @@ export class CallInterface extends LogicItem {
368
350
  && this.parentNode.concept !== 'SelectMembers'
369
351
  && this.parentNode.concept !== 'BinaryExpression'
370
352
  && this.parentNode.concept !== 'MemberExpression'
371
- && this.parentNode.concept !== 'StringInterpolation') {
353
+ && this.parentNode.concept !== 'StringInterpolation'
354
+ && !['NewMap', 'NewList'].includes(this.parentNode.concept)) {
372
355
  code += ';';
373
356
  }
374
357
  code += '\n';
@@ -553,8 +536,9 @@ export class CallInterface extends LogicItem {
553
536
  logicParam = node.params;
554
537
  }
555
538
  if (this.arguments?.length) {
556
- this.arguments.forEach((arg, index) => {
557
- const param = logicParam[index];
539
+ this.arguments.forEach((arg) => {
540
+ const idx = logicParam.findIndex((params) => arg.keyword === params.name);
541
+ const param = logicParam[idx];
558
542
 
559
543
  arg.paramRequired = param?.required;
560
544
  arg.paramTypeAnnotation = undefined;
@@ -5,6 +5,8 @@ import View from './View__';
5
5
  import { ElementToVueOptions } from './ViewElement__';
6
6
  import { getNodeByNodeCallee, getNaslNodeByNodeCallee } from '../automate/engine/utils';
7
7
  import { findConceptKeyWordIndexFromNamespace } from '../utils';
8
+ import * as JSON5 from 'json5';
9
+ import Identifier from './Identifier__';
8
10
 
9
11
  //================================================================================
10
12
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -448,10 +450,14 @@ export class CallLogic extends LogicItem {
448
450
  }
449
451
  this.calleeName = logic.name;
450
452
  this.arguments = [];
451
- logic.params.forEach((param) => {
452
- this._addArgument({
453
+ logic.params.forEach((param: any) => {
454
+ const argument = this._addArgument({
453
455
  keyword: param.name,
454
456
  });
457
+ if (param.defaultExpression) {
458
+ const exp: any = BaseNode.from({ ...param.defaultExpression.toJSON() });
459
+ argument.setExpression(exp);
460
+ }
455
461
  });
456
462
  if (logic.typeParams) {
457
463
  this.typeArguments = [];
@@ -471,7 +477,7 @@ export class CallLogic extends LogicItem {
471
477
  const relationOptions = { parentNode: this, parentKey: 'arguments' };
472
478
  const argument = Argument.from({
473
479
  keyword: param.name,
474
- expression: param.defaultExpression,
480
+ expression: param.isFunction ? new Identifier() : param.defaultExpression,
475
481
  }, this);
476
482
  Object.assign(argument, relationOptions);
477
483
  return argument;
@@ -692,7 +698,6 @@ var __parseType = __parseType || ((root, prop) => {
692
698
 
693
699
  // 全局逻辑
694
700
  if (!isViewLogic) {
695
- const namespaceArr = calleeNamespace?.split('.');
696
701
  const logic = getNodeByNodeCallee(this.app, this.calleewholeKey, (key: string, tempPoint: any) => {
697
702
  // 处理 NASL 中未定义的假的节点
698
703
  if (key === tempPoint.name) {
@@ -754,12 +759,31 @@ var __parseType = __parseType || ((root, prop) => {
754
759
  code += `},\n`;
755
760
  break;
756
761
  }
762
+ case 'update':
763
+ case 'createOrUpdate':
764
+ case 'batchUpdate': {
765
+ code += `body: {\n`;
766
+ const argsStr = logicArgs
767
+ .filter((arg: any) => arg.expression)
768
+ .map((arg: any) => {
769
+ const name = arg.keyword === 'body' ?
770
+ (this.calleeName === 'batchUpdate' ? 'entities' : 'entity') :
771
+ arg.keyword;
772
+ return `${name}: ${arg.expression.toJS(shiftState(state, code))}`;
773
+ })
774
+ .join(',\n');
775
+ code += argsStr;
776
+ code += `},\n`;
777
+ logicArgs = [];
778
+ breakBody = true;
779
+ break;
780
+ }
757
781
  case 'updateBy': {
758
782
  code += `body: {`;
759
783
  const argsStr = logicArgs
760
784
  .filter((arg: any) => arg.expression)
761
785
  .map((arg: any) => {
762
- const name = arg.expression.returnExpression ? arg.expression.name : 'entity';
786
+ const name = arg.keyword === 'body' ? 'entity' : arg.keyword;
763
787
  // filter回调函数
764
788
  if (arg.expression.returnExpression) {
765
789
  const argsStr = JSON.stringify(handleMember(arg.expression.returnExpression));
@@ -816,6 +840,9 @@ var __parseType = __parseType || ((root, prop) => {
816
840
  .map((obj: any) => `\n${obj?.keyword}: ${obj?.arg?.toJS(shiftState(state, code))}`)
817
841
  .join(', ');
818
842
  code += argsStr;
843
+ if (Array.isArray(this.typeArguments) && this.typeArguments.length) {
844
+ code += `,\n__typeArguments: ${JSON5.stringify(this.typeArguments)}`;
845
+ }
819
846
  }
820
847
  code += '\n}';
821
848
  }
@@ -854,12 +881,27 @@ var __parseType = __parseType || ((root, prop) => {
854
881
  code += '})';
855
882
  } else {
856
883
  code += '(';
857
- completeArguments
858
- .forEach((arg, index) => {
884
+ const needToString = ['showMessage', 'consoleLog'].includes(this.calleeName);
885
+ if (needToString) {
886
+ code += `this.$utils['ToString'](`;
887
+ }
888
+ if (Array.isArray(completeArguments) && completeArguments.length) {
889
+ completeArguments.forEach((arg, index) => {
859
890
  code += arg?.toJS(shiftState(state, code));
860
891
  if (index !== completeArguments?.length - 1)
861
892
  code += ', ';
862
893
  });
894
+ if (needToString) {
895
+ const arg = this.arguments[0];
896
+ const argTypeAnnotation = (arg as any).typeAnnotation || arg.__TypeAnnotation;
897
+ if (argTypeAnnotation) {
898
+ code += `, '${argTypeAnnotation?.sortedTypeKey}'`;
899
+ }
900
+ }
901
+ }
902
+ if (needToString) {
903
+ code += `)`;
904
+ }
863
905
  code += ')';
864
906
  }
865
907
  }
@@ -914,7 +956,10 @@ var __parseType = __parseType || ((root, prop) => {
914
956
  };
915
957
  }
916
958
  const typeAnnotation = (this as any).typeAnnotation || this.__TypeAnnotation;
917
- const needGenInitFromSchema = typeAnnotation && !['primitive', 'union'].includes(typeAnnotation.typeKind);
959
+ const needGenInitFromSchema = typeAnnotation && (
960
+ !['primitive', 'union'].includes(typeAnnotation.typeKind)
961
+ || typeAnnotation.typeName === 'DateTime'
962
+ );
918
963
  if (needGenInitFromSchema) {
919
964
  code = `this.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}', ${code})`;
920
965
  }
@@ -934,13 +979,14 @@ var __parseType = __parseType || ((root, prop) => {
934
979
  code += `<`;
935
980
  code += `${typeAnnotation.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }))}>`;
936
981
  }
937
-
982
+ // 参数必填
983
+ const paramRequired = ['showMessage', 'consoleLog'].includes(this.calleeName);
938
984
  const tsCalleeNamespace = this.tsCalleeNamespace;
939
985
  if ((tsCalleeNamespace.startsWith('elements') && tsCalleeNamespace.endsWith('logics')) || tsCalleeNamespace.startsWith('nasl.')) {
940
986
  code += '(';
941
987
  this.arguments.forEach((arg, index) => {
942
988
  // 页面逻辑先都非必填
943
- code += arg.toEmbeddedTS(shiftState(state, code), false);
989
+ code += arg.toEmbeddedTS(shiftState(state, code), paramRequired);
944
990
  if (index !== this.arguments.length - 1)
945
991
  code += ', ';
946
992
  });
@@ -953,7 +999,8 @@ var __parseType = __parseType || ((root, prop) => {
953
999
  && this.parentNode.concept !== 'SelectMembers'
954
1000
  && this.parentNode.concept !== 'BinaryExpression'
955
1001
  && this.parentNode.concept !== 'StringInterpolation'
956
- && this.parentNode.concept !== 'MemberExpression') {
1002
+ && this.parentNode.concept !== 'MemberExpression'
1003
+ && !['NewMap', 'NewList'].includes(this.parentNode.concept)) {
957
1004
  code += ';';
958
1005
  }
959
1006
  } else {
@@ -975,7 +1022,8 @@ var __parseType = __parseType || ((root, prop) => {
975
1022
  && this.parentNode.concept !== 'SelectMembers'
976
1023
  && this.parentNode.concept !== 'BinaryExpression'
977
1024
  && this.parentNode.concept !== 'StringInterpolation'
978
- && this.parentNode.concept !== 'MemberExpression') {
1025
+ && this.parentNode.concept !== 'MemberExpression'
1026
+ && !['NewMap', 'NewList'].includes(this.parentNode.concept)) {
979
1027
  code += ';';
980
1028
  }
981
1029
  } else {
@@ -988,7 +1036,8 @@ var __parseType = __parseType || ((root, prop) => {
988
1036
  && this.parentNode.concept !== 'SelectMembers'
989
1037
  && this.parentNode.concept !== 'BinaryExpression'
990
1038
  && this.parentNode.concept !== 'StringInterpolation'
991
- && this.parentNode.concept !== 'MemberExpression') {
1039
+ && this.parentNode.concept !== 'MemberExpression'
1040
+ && !['NewMap', 'NewList'].includes(this.parentNode.concept)) {
992
1041
  code += ';';
993
1042
  }
994
1043
  }
@@ -1087,7 +1087,8 @@ export class CallQueryComponent extends LogicItem {
1087
1087
  && this.parentNode.concept !== 'SelectMembers'
1088
1088
  && this.parentNode.concept !== 'BinaryExpression'
1089
1089
  && this.parentNode.concept !== 'StringInterpolation'
1090
- && this.parentNode.concept !== 'MemberExpression') {
1090
+ && this.parentNode.concept !== 'MemberExpression'
1091
+ && ['NewMap', 'NewList'].includes(this.parentNode.concept)) {
1091
1092
  code += ';';
1092
1093
  }
1093
1094
  code += '\n';
@@ -1486,6 +1487,8 @@ export class CallQueryComponent extends LogicItem {
1486
1487
  expression,
1487
1488
  });
1488
1489
  completionProperty.icon = 'property';
1490
+ // 标记实体属性是否是符合类型
1491
+ Object.assign(completionProperty, { isComplexType: property.typeAnnotation.isComplexType() });
1489
1492
  return completionProperty;
1490
1493
  }),
1491
1494
  }));
@@ -1,4 +1,5 @@
1
1
  import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
2
+ import datasourceService from '../service/datasource';
2
3
 
3
4
  //================================================================================
4
5
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -402,7 +403,7 @@ export class DataSource extends BaseNode {
402
403
  code += this.toEmbeddedTS(state);
403
404
  } catch (err) {
404
405
  code += '';
405
- console.log(err);
406
+ console.error(err);
406
407
  }
407
408
  code += '}\n';
408
409
 
@@ -413,6 +414,60 @@ export class DataSource extends BaseNode {
413
414
  };
414
415
  }
415
416
 
417
+ // 测试数据源连通性
418
+ async pingDatabase(recordEnvConnectError: Function) {
419
+ const configProperty = this.app.configuration.getGroup('dataSource').getProperty(this.name);
420
+ configProperty && configProperty.values.forEach((prop) => {
421
+ // 未配置数据源时,不进行连接测试
422
+ if (!prop.value) {
423
+ return;
424
+ }
425
+ const dataSource = configProperty.name;
426
+ const env = prop.env;
427
+ return datasourceService.pingDatabase({
428
+ body: {
429
+ category: 'sql',
430
+ appId: this.app.id,
431
+ dataSource,
432
+ env,
433
+ },
434
+ }).then(() => {
435
+ Object.assign(this, { [`__${env}ConnectError`]: false });
436
+ }).catch(() => {
437
+ Object.assign(this, { [`__${env}ConnectError`]: true });
438
+ }).then(() => {
439
+ recordEnvConnectError(env);
440
+ });
441
+ });
442
+ }
443
+ recordEnvConnectError(records: any[], env: string) {
444
+ const target = records?.find((item: any) => item.id === this.id);
445
+ // 诊断还未生成,在诊断时生成问题
446
+ if (!target) {
447
+ return;
448
+ }
449
+ // 诊断已生成,手动插入问题
450
+ const errorKey = `__${env}ConnectError`;
451
+ const errorText = `DataSource ${env} env connect error`;
452
+ target.semanticDiagnostics = target.semanticDiagnostics.filter((item: any) => item.code !== errorText);
453
+ if ((this as any)[errorKey]) {
454
+ const envText = env === 'online' ? '生产' : '开发';
455
+ target.semanticDiagnostics.push({
456
+ text: errorText,
457
+ node: this,
458
+ severity: 'error',
459
+ message: `数据源配置:数据源 ${this.name} ${envText}环境数据源连接不通,请先检查${envText}环境数据源配置`,
460
+ originalDiagnostic: {
461
+ fileName: '',
462
+ start: null,
463
+ end: null,
464
+ category: 'error',
465
+ text: `DataSource connection error`,
466
+ },
467
+ });
468
+ }
469
+ }
470
+
416
471
  // 获取datasource对应的数据源配置
417
472
  get dataSourceConfig() {
418
473
  let devProperty = null;
@@ -531,6 +531,8 @@ export class ForEachStatement extends LogicItem {
531
531
  code += this.each ? this.each.toEmbeddedTS(shiftState(state, code, {
532
532
  tabSize: 0,
533
533
  })) : '__IDENTIFIER__';
534
+ if (['NewList', 'NewMap'].includes(this.each.concept))
535
+ code += '\n';
534
536
  code += '.__slice(';
535
537
  code += this.start ? this.start.toEmbeddedTS(shiftState(state, code)) : '__IDENTIFIER__';
536
538
  code += ', ';