@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
@@ -1,4 +1,4 @@
1
- import { CallLogic, EntityProperty, BindEvent, App, Namespace, Entity, BaseNode, Logic, Param, TypeAnnotation, Function, Return } from '..';
1
+ import { CallLogic, EntityProperty, BindEvent, App, Namespace, Entity, BaseNode, Logic, Param, TypeAnnotation, Function, Return, AnonymousFunction, NewList } from '..';
2
2
 
3
3
  export function entity2LogicNamespace(entity: Entity) {
4
4
  const properties = entity.properties;
@@ -86,6 +86,26 @@ export function entity2LogicNamespace(entity: Entity) {
86
86
  }),
87
87
  required: true,
88
88
  }),
89
+ new Param({
90
+ name: 'properties',
91
+ defaultExpression: new AnonymousFunction({
92
+ description: '',
93
+ params: [
94
+ new Param({
95
+ name: 'item',
96
+ typeAnnotation: new TypeAnnotation({
97
+ typeKind: 'reference',
98
+ typeNamespace: entity.getNamespace(),
99
+ typeName: entity.name,
100
+ }),
101
+ }),
102
+ ],
103
+ body: new NewList({
104
+ concept: 'NewList',
105
+ }),
106
+ }),
107
+ required: false,
108
+ }),
89
109
  ],
90
110
  returns: [
91
111
  new Return({
@@ -135,15 +155,6 @@ export function entity2LogicNamespace(entity: Entity) {
135
155
  name: 'updateBy',
136
156
  description: '根据条件,将body除id外所有属性更新到数据记录',
137
157
  params: [
138
- new Param({
139
- name: 'body',
140
- typeAnnotation: new TypeAnnotation({
141
- typeKind: 'reference',
142
- typeNamespace: entity.getNamespace(),
143
- typeName: entity.name,
144
- }),
145
- required: true,
146
- }),
147
158
  new Param({
148
159
  name: 'filter',
149
160
  defaultExpression: new Function({
@@ -167,6 +178,35 @@ export function entity2LogicNamespace(entity: Entity) {
167
178
  }),
168
179
  required: true,
169
180
  }),
181
+ new Param({
182
+ name: 'body',
183
+ typeAnnotation: new TypeAnnotation({
184
+ typeKind: 'reference',
185
+ typeNamespace: entity.getNamespace(),
186
+ typeName: entity.name,
187
+ }),
188
+ required: true,
189
+ }),
190
+ new Param({
191
+ name: 'properties',
192
+ defaultExpression: new AnonymousFunction({
193
+ description: '',
194
+ params: [
195
+ new Param({
196
+ name: 'item',
197
+ typeAnnotation: new TypeAnnotation({
198
+ typeKind: 'reference',
199
+ typeNamespace: entity.getNamespace(),
200
+ typeName: entity.name,
201
+ }),
202
+ }),
203
+ ],
204
+ body: new NewList({
205
+ concept: 'NewList',
206
+ }),
207
+ }),
208
+ required: false,
209
+ }),
170
210
  ],
171
211
  returns: [
172
212
  new Return({
@@ -257,6 +297,26 @@ export function entity2LogicNamespace(entity: Entity) {
257
297
  }),
258
298
  required: true,
259
299
  }),
300
+ new Param({
301
+ name: 'properties',
302
+ defaultExpression: new AnonymousFunction({
303
+ description: '',
304
+ params: [
305
+ new Param({
306
+ name: 'item',
307
+ typeAnnotation: new TypeAnnotation({
308
+ typeKind: 'reference',
309
+ typeNamespace: entity.getNamespace(),
310
+ typeName: entity.name,
311
+ }),
312
+ }),
313
+ ],
314
+ body: new NewList({
315
+ concept: 'NewList',
316
+ }),
317
+ }),
318
+ required: false,
319
+ }),
260
320
  ],
261
321
  returns: [
262
322
  new Return({
@@ -230,7 +230,11 @@ BaseNode.prototype.prepareDelete = async function prepareDelete() {
230
230
  return null;
231
231
  const minRange: MinRange = naslServer._findMinRange(record, fileNode as FileNode);
232
232
  if (minRange) {
233
- if (minRange.node instanceof CallLogic || minRange.node instanceof Destination) {
233
+ /**
234
+ * 调用方是 调用逻辑或者跳转页面, 去删除对应位置的内容
235
+ * 如果是跳转页面,因为流程下的特殊翻译,需要过滤下 非页面下的参数修改,查找到页面跳转
236
+ */
237
+ if (minRange.node instanceof CallLogic || (node.parentNode instanceof View && minRange.node instanceof Destination)) {
234
238
  minRange.node.deleteCalleeArg(Index);
235
239
  }
236
240
  }
@@ -339,14 +343,14 @@ BaseNode.prototype.addParamsPrepare = async function addParamsPrepare(needAdd =
339
343
  /**
340
344
  * 在原型上增加方法来调用
341
345
  */
342
- BaseNode.prototype.getCurrentTypeAnnotation = async function getCurrentTypeAnnotation() {
346
+ BaseNode.prototype.getCurrentTypeAnnotation = async function getCurrentTypeAnnotation(outTime? :number) {
343
347
  try {
344
348
  /**
345
349
  * 查找这个节点是不是有依赖
346
350
  */
347
351
  const app = this.getAncestor('App');
348
352
  const naslServer = (app as any).naslServer as NaslServer;
349
- return naslServer.getCurrentTypeAnnotation(this);
353
+ return naslServer.getCurrentTypeAnnotation(this, outTime || 2000);
350
354
  } catch (err) {
351
355
  console.log(err);
352
356
  }
@@ -513,6 +513,8 @@ export function formatVariableData(data: unknown | variableItem[], node: BaseNod
513
513
  item.expression = memberExpression;
514
514
  item.variableParent = parent;
515
515
  item.typeKey = typeKey;
516
+ // 标记实体属性是否是符合类型
517
+ item.isComplexType = item.typeAnnotation?.isComplexType();
516
518
  }
517
519
  // 如果有类型而且类型不是没有子集的类型,就把他当前的类型拿到
518
520
  if (typeKey && !isNoChildType(typeKey)) {
@@ -532,6 +534,10 @@ export function formatVariableData(data: unknown | variableItem[], node: BaseNod
532
534
  // 如果是从实体或者数据结构取的属性,就需要重置一下类型
533
535
  item.concept = 'CompletionProperty';
534
536
  const completionProperty = new CompletionProperty(item);
537
+ // 标记实体属性是否是符合类型
538
+ if (typeof item.isComplexType === 'boolean') {
539
+ Object.assign(completionProperty, { isComplexType: item.isComplexType });
540
+ }
535
541
  if (!parent) {
536
542
  // 变量 param return 在这里添加图标
537
543
  completionProperty.icon = getNodeiconFromLogic(completionProperty, node);
@@ -1,3 +1,4 @@
1
+ import { Identifier } from './../concepts/Identifier__';
1
2
  import { CallLogic, BindEvent, App, Namespace, Entity, BaseNode, Logic, Param, TypeAnnotation, Return, Process, ViewElement, stdlibNamespace, EnumItem } from '..';
2
3
  import { process2LogicNamespace } from './process2LogicNamespace';
3
4
  import { moduleToLogicNamesapce } from './getExtensionModules';
@@ -56,7 +57,7 @@ function iterator(tree: FakeNode | FakeProcessNode, searchContent: string, fakeN
56
57
  function toHump(name: string): string {
57
58
  return name.replace(/\-(\w)/g, (all, letter) => letter.toUpperCase());
58
59
  }
59
- export async function getLogics(node: CallLogic | BindEvent, needAllLogic: boolean = true) {
60
+ export async function getLogics(node: CallLogic | BindEvent| Identifier, needAllLogic: boolean = true) {
60
61
  const app = node.rootNode as App;
61
62
  if (node.concept === 'CallLogic' || node.concept === 'BindEvent') {
62
63
  const result = [];
@@ -264,6 +265,17 @@ export async function getLogics(node: CallLogic | BindEvent, needAllLogic: boole
264
265
  result.push(systemTree);
265
266
  }
266
267
  return result;
268
+ } else if (node.concept === 'Identifier') {
269
+ const extensions = app.dependencies.map(moduleToLogicNamesapce).filter((item) => item.logics && item.logics.length);
270
+ const tree = new Namespace({
271
+ name: 'category`',
272
+ path: `${app.getNamespace()}.logics`,
273
+ title: '全局逻辑',
274
+ logics: app.logics,
275
+ children: [...extensions],
276
+ });
277
+
278
+ return [tree];
267
279
  }
268
280
  }
269
281
 
@@ -191,7 +191,7 @@ export async function getMemberIdentifier(node: BaseNode) {
191
191
 
192
192
  // 这个可能需要自己算一下
193
193
  const result = [
194
- { name: '字面量', children: literals, expanded: true, icon: 'category' },
194
+ { name: '常量', children: literals, expanded: true, icon: 'category' },
195
195
  { name: '枚举', children: newEnums, expanded: false, icon: 'category' },
196
196
  { name: '变量', children: completionData, expanded: true, icon: 'category' },
197
197
  { name: '公共变量', children: globalVariable, expanded: false, icon: 'category' },
@@ -202,7 +202,34 @@ export class NaslServer {
202
202
  // 收集到一个行为集合
203
203
  const eventValue = $event.value;
204
204
  eventValue.forEach(async (item: EventPayload) => {
205
- this.changeStackList.push(item.originEvent);
205
+ /**
206
+ * 多个行为进行合并
207
+ * 合并规则是
208
+ * 1.[a,b,c,c] 在cc的时候,在已有一个c,又来一个c的时候,如果他们不都是file级别的节点
209
+ * 就可以前面的内容去掉,只保留最后一个
210
+ * 2.[a,b,c,b,c] 在bc已存在,又来了bc 这就都要保留,因为可能顺序有相关性,不能去掉
211
+ * 理论上只处理同时几个操作 合并,
212
+ * 3.有field的也直接保留
213
+ */
214
+ try {
215
+ const changeEvent = item.originEvent;
216
+ const changeNode = changeEvent.target;
217
+ const { fileNode } = this.getCurrentSource(changeNode);
218
+ if (changeNode !== fileNode || !changeEvent.field) {
219
+ const findIndex = this.changeStackList.findIndex((changeStackItem: EventPayload) => {
220
+ const target = changeStackItem.target;
221
+ const { fileNode: targetFileNode } = this.getCurrentSource(target);
222
+ return targetFileNode === fileNode;
223
+ });
224
+ if (findIndex === this.changeStackList.length - 1) {
225
+ this.changeStackList.pop();
226
+ }
227
+ }
228
+ this.changeStackList.push(item.originEvent);
229
+ } catch (err) {
230
+ console.log(err);
231
+ this.changeStackList.push(item.originEvent);
232
+ }
206
233
  });
207
234
 
208
235
  // 如果有长度开始执行状态机
@@ -615,7 +642,8 @@ export class NaslServer {
615
642
  return '';
616
643
  }
617
644
  async getDataSchemaStructureOrTypeAnnotation(node: ViewElement) {
618
- if (!(node instanceof ViewElement)) return;
645
+ if (!(node instanceof ViewElement))
646
+ return;
619
647
 
620
648
  const { currentSource, fileNode } = this.getCurrentSource(node);
621
649
  const quickInfo = await this._getTypeQuickinfo({
@@ -626,16 +654,18 @@ export class NaslServer {
626
654
  if (quickInfo.responseRequired) {
627
655
  const displayString = quickInfo?.response?.displayString || '';
628
656
  const flag = displayString.includes('<') && displayString.includes('>');
629
- if(!flag) return;
657
+ if (!flag)
658
+ return;
630
659
 
631
660
  const types = /\<([^()]+)\>/g.exec(displayString);
632
- let typeStr = types && types[1];
661
+ const typeStr = types && types[1];
633
662
  const app = node.app;
634
663
  if (typeStr.includes('__name: "AStructure_')) {
635
664
  const properties: StructureProperty[] = [];
636
665
  typeStr
637
666
  .replace(/([^:\s]+):\s+([^;]+);/g, ($1, name, typeKey) => {
638
- if(name === '__name') return;
667
+ if (name === '__name')
668
+ return;
639
669
 
640
670
  typeKey = `app.${typeKey}`;
641
671
  const keys = typeKey.split('.');
@@ -647,12 +677,12 @@ export class NaslServer {
647
677
  typeKind: 'reference',
648
678
  typeName,
649
679
  typeNamespace,
650
- })
651
- }))
680
+ }),
681
+ }));
652
682
  return '';
653
683
  });
654
684
  return TypeAnnotation.createTypeAnonymousStructure(properties);
655
- } else if(typeStr.startsWith('structures'))
685
+ } else if (typeStr.startsWith('structures'))
656
686
  return app.findNodeByCompleteName(`app.${typeStr}`);
657
687
  }
658
688
  }
@@ -814,7 +844,8 @@ export class NaslServer {
814
844
  // record.suggestionDiagnostics = record.suggestionDiagnostics.filter((item) => !item.text.includes(`implicitly has an 'any' type, but a better type may be inferred from usage.`));
815
845
  // }
816
846
  record.suggestionDiagnostics = record.suggestionDiagnostics
817
- .filter((item) => [`'__LogicEmpty' is declared but its value is never read.`, `'__destinationEmpty__' is declared but its value is never read.`].includes(item.text))
847
+ .filter((item) => [`'__LogicEmpty' is declared but its value is never read.`, `'__destinationEmpty__' is declared but its value is never read.`
848
+ , `'__UpdateNoProperty__' is declared but its value is never read.`].includes(item.text))
818
849
  .map((diag) => this._resolveDiagnostic(diag as unknown as tsProtocol.DiagnosticWithFileName, node as FileNode, record))
819
850
  .filter((diag) => !!diag);
820
851
 
@@ -847,7 +878,7 @@ export class NaslServer {
847
878
  }
848
879
  if (removed)
849
880
  return diagnostics;
850
- fileNode?.sourceMap.forEach(async (value, node) => {
881
+ fileNode?.sourceMap.forEach((value, node) => {
851
882
  if (node instanceof Match) {
852
883
  const { cases, expression } = node || {};
853
884
  const typeAnnotationMap: any = {};
@@ -857,7 +888,7 @@ export class NaslServer {
857
888
  count: 0,
858
889
  };
859
890
  if (Array.isArray(cases)) {
860
- cases.forEach(async (caseItem, index) => {
891
+ cases.forEach((caseItem, index) => {
861
892
  let isDisabled = false;
862
893
  // 是最后一项
863
894
  if (index === cases.length - 1) {
@@ -997,7 +1028,7 @@ export class NaslServer {
997
1028
  if (removed)
998
1029
  return diagnostics;
999
1030
 
1000
- fileNode?.sourceMap.forEach(async (value, node) => {
1031
+ fileNode?.sourceMap.forEach((value, node) => {
1001
1032
  if (node instanceof ViewElement && node.view === fileNode) {
1002
1033
  if (node.tag) {
1003
1034
  node.bindAttrs.forEach((bindAttr) => {
@@ -1111,6 +1142,40 @@ export class NaslServer {
1111
1142
  },
1112
1143
  };
1113
1144
  diagnostics.push(diagnostic);
1145
+ } else if (propertyValue.value) {
1146
+ const dataSource: any = fileNode;
1147
+ // 数据源有连接错误
1148
+ let envText;
1149
+ if (propertyValue.env === 'dev') {
1150
+ if (dataSource.__devConnectError) {
1151
+ envText = '开发';
1152
+ } else if (dataSource.__devConnectError === false) {
1153
+ return;
1154
+ }
1155
+ } else if (propertyValue.env === 'online') {
1156
+ if (dataSource.__onlineConnectError) {
1157
+ envText = '生产';
1158
+ } else if (dataSource.__onlineConnectError === false) {
1159
+ return;
1160
+ }
1161
+ }
1162
+ // 手动插入报错
1163
+ if (envText) {
1164
+ const diagnostic = {
1165
+ node: fileNode,
1166
+ severity: 'error',
1167
+ message: `数据源配置:数据源 ${property.name} ${envText}环境数据源连接不通,请先检查${envText}环境数据源配置`,
1168
+ // 保留原来的内容方便查询一些问题
1169
+ originalDiagnostic: {
1170
+ fileName: '',
1171
+ start: <any>null,
1172
+ end: <any>null,
1173
+ category: 'error',
1174
+ text: `DataSource connection error`,
1175
+ },
1176
+ };
1177
+ return diagnostics.push(diagnostic);
1178
+ }
1114
1179
  }
1115
1180
  });
1116
1181
  }
@@ -1121,17 +1186,18 @@ export class NaslServer {
1121
1186
  if (fileNode.parentNode instanceof App && !fileNode.parentNode.logics.includes(fileNode))
1122
1187
  return diagnostics;
1123
1188
 
1124
- fileNode?.sourceMap.forEach(async (value, node) => {
1189
+ fileNode?.sourceMap.forEach((value, node) => {
1190
+ //OQL支持返回复合类型数据了
1125
1191
  // SqlQueryComponent内部返回值类型,如果是嵌套的就需要报错
1126
- if ((node instanceof OqlQueryComponent || node instanceof SqlQueryComponent) && (node as SqlQueryComponent).getTypeBanError()) {
1127
- const diagnostic = {
1128
- node,
1129
- severity: 'error',
1130
- message: 'SQL查询:返回类型内部,不支持复杂类型。',
1131
- };
1132
- node.tsErrorDetail = diagnostic;
1133
- diagnostics.push(diagnostic);
1134
- }
1192
+ // if ((node instanceof OqlQueryComponent || node instanceof SqlQueryComponent) && (node as SqlQueryComponent).getTypeBanError()) {
1193
+ // const diagnostic = {
1194
+ // node,
1195
+ // severity: 'error',
1196
+ // message: 'SQL查询:返回类型内部,不支持复杂类型。',
1197
+ // };
1198
+ // node.tsErrorDetail = diagnostic;
1199
+ // diagnostics.push(diagnostic);
1200
+ // }
1135
1201
  if (node instanceof Return || node instanceof Variable) {
1136
1202
  if (!node.typeAnnotation && !node.__TypeAnnotation) {
1137
1203
  const nodeTypeName = node.concept === 'Return' ? '输出参数' : '局部变量';
@@ -1167,6 +1233,11 @@ export class NaslServer {
1167
1233
  this.checkNodeError(node, diagnostics);
1168
1234
  });
1169
1235
  }
1236
+ if (fileNode instanceof Process) {
1237
+ fileNode?.sourceMap.forEach((value, node) => {
1238
+ this.checkNodeError(node, diagnostics);
1239
+ });
1240
+ }
1170
1241
  return diagnostics;
1171
1242
  }
1172
1243
 
@@ -1226,6 +1297,16 @@ export class NaslServer {
1226
1297
  }
1227
1298
  });
1228
1299
  }
1300
+ if (node instanceof MatchCase && (node.getAncestor('Match') as Match)?.isExpression && node.body.length === 0 && !node.isDisabled) {
1301
+ const diagnostic = {
1302
+ node,
1303
+ severity: 'error',
1304
+ message: '匹配分支:表达式不能为空',
1305
+ titleTip: '表达式不能为空',
1306
+ };
1307
+ node.tsErrorDetail = diagnostic;
1308
+ diagnostics.push(diagnostic);
1309
+ }
1229
1310
  // 如果节点是match的patterns 里的
1230
1311
  if (node?.parentKey === 'patterns' && node.parentNode instanceof MatchCase) {
1231
1312
  const matchNode = node.getAncestor('Match');
@@ -1244,9 +1325,30 @@ export class NaslServer {
1244
1325
  node.tsErrorDetail = diagnostic;
1245
1326
  diagnostics.push(diagnostic);
1246
1327
  }
1328
+ // 如果TypeAnnotation 还存在,但是本身已经不是union类型,就是已经从union换别的类型了就都要报错
1329
+ } else if (node instanceof TypeAnnotation && matchExpressionType?.typeKind !== 'union') {
1330
+ const diagnostic = {
1331
+ node,
1332
+ severity: 'error',
1333
+ message: '匹配:选择类型不存在',
1334
+ titleTip: '该类型已被删除',
1335
+ };
1336
+ node.tsErrorDetail = diagnostic;
1337
+ diagnostics.push(diagnostic);
1338
+ // 如果可枚举变量的 ,变量 还存在,但是本身已经是union类型,就是已经从别的类型 换了union就都要报错
1339
+ } else if (!(node instanceof TypeAnnotation) && matchExpressionType?.typeKind === 'union') {
1340
+ const diagnostic = {
1341
+ node,
1342
+ severity: 'error',
1343
+ message: '匹配:选择值不存在',
1344
+ titleTip: '该值无法匹配,请重新选择类型',
1345
+ };
1346
+ node.tsErrorDetail = diagnostic;
1347
+ diagnostics.push(diagnostic);
1247
1348
  }
1248
1349
  if (node.tsErrorDetail) {
1249
- if (matchExpressionType?.typeNamespace?.includes('enums')) {
1350
+ // 如果父级是枚举,而且子集选的是变量,就提示枚举值已被删除
1351
+ if (matchExpressionType?.typeNamespace?.includes('enums') && (node instanceof MemberExpression)) {
1250
1352
  node.tsErrorDetail.titleTip = '该枚举值已被删除';
1251
1353
  } else if (!node.tsErrorDetail.titleTip) {
1252
1354
  node.tsErrorDetail.titleTip = '该值已被删除';
@@ -1263,6 +1365,25 @@ export class NaslServer {
1263
1365
  node.tsErrorDetail = diagnostic;
1264
1366
  diagnostics.push(diagnostic);
1265
1367
  }
1368
+ /**
1369
+ * 如果节点是内置函数
1370
+ * 穷举在线上的情况,不在线上就void报错, calllogic 和 callinterface 因为原来有报错,所以就忽略掉
1371
+ * && 他在父级中,不在body
1372
+ * && 也不再 if的线上
1373
+ * && 也不再 switch的线上consequent
1374
+ * && 也不再草稿区域
1375
+ * && 不在 parentNode.parentNode(只用处理两层的,超过两层上就需要报错,只用直接是参数位第一层的需要) 是 callfunction 和 callInfterfase中,因为这两本身有强制类型,内置函数或者一些带T的声明那种,
1376
+ * && 而且也没有类型,就说明在槽位里,就需要报错
1377
+ */
1378
+ if (node instanceof CallFunction && node.parentKey !== 'body' && node.parentKey !== 'alternate' && node.parentKey !== 'playground' && node.parentKey !== 'consequent' && node.parentNode?.parentNode?.concept !== 'CallLogic' && node.parentNode?.parentNode?.concept !== 'CallInterface' && !node.__TypeAnnotation) {
1379
+ const diagnostic = {
1380
+ node,
1381
+ severity: 'error',
1382
+ message: `类型不匹配,传入类型:void`,
1383
+ };
1384
+ node.tsErrorDetail = diagnostic;
1385
+ diagnostics.push(diagnostic);
1386
+ }
1266
1387
  }
1267
1388
 
1268
1389
  /* 接口导入查找 */
@@ -2289,7 +2410,7 @@ export class NaslServer {
2289
2410
  * @returns 不需要去查就可以返回类型的节点
2290
2411
  */
2291
2412
  getCurrentNodeKnownTypeAnnotation(node: BaseNode) {
2292
- if (node.concept === 'StringLiteral' || node.concept === 'BooleanLiteral' || node.concept === 'NullLiteral') {
2413
+ if (node.concept === 'StringLiteral' || node.concept === 'StringInterpolation' || node.concept === 'BooleanLiteral' || node.concept === 'NullLiteral') {
2293
2414
  let type = 'String';
2294
2415
  switch (node.concept) {
2295
2416
  case 'NullLiteral':
@@ -2306,7 +2427,7 @@ export class NaslServer {
2306
2427
  return TypeAnnotation.createPrimitive('Boolean');
2307
2428
  }
2308
2429
  // Convert和new都是自身携带类型的,就不进行修改
2309
- if (node instanceof CallFunction && node.calleeNamespace === 'nasl.util' && (node.calleeName === 'Convert' || node.calleeName === 'New')) {
2430
+ if (node instanceof CallFunction && node.calleeNamespace === 'nasl.util' && (['Convert', 'New', 'FromString'].includes(node.calleeName))) {
2310
2431
  if (node.typeArguments.length) {
2311
2432
  return node.typeArguments[0];
2312
2433
  }
@@ -2396,6 +2517,9 @@ export class NaslServer {
2396
2517
  'Return',
2397
2518
  'Variable',
2398
2519
  'Match',
2520
+ 'NewComposite',
2521
+ 'NewList',
2522
+ 'NewMap',
2399
2523
  ].includes(node.concept))
2400
2524
  return;
2401
2525
  // 要去ls那边获取的
@@ -2442,12 +2566,18 @@ export class NaslServer {
2442
2566
  let newCode = item.code.substring(0, indexOf);
2443
2567
  newCode = newCode.substring(newCode.lastIndexOf('\n'), indexOf);
2444
2568
  fileDetail.offset = newCode.length + 'return '.length;
2569
+ } else if (['NewComposite', 'NewList', 'NewMap'].includes(node.concept)) {
2570
+ fileDetail.line = item.range.end.line;
2571
+ const indexOf = item.code.indexOf('return __newComposite');
2572
+ let newCode = item.code.substring(0, indexOf);
2573
+ newCode = newCode.substring(newCode.lastIndexOf('\n'), indexOf);
2574
+ fileDetail.offset = newCode.length + 'return '.length;
2445
2575
  }
2446
2576
  args.push(fileDetail);
2447
2577
  });
2448
- console.time('请求')
2578
+ console.time('请求');
2449
2579
  const resultMap: any = (await this.getNaslNodeTypeFull(args)).response;
2450
- console.timeEnd('请求')
2580
+ console.timeEnd('请求');
2451
2581
 
2452
2582
  // console.log(resultMap);
2453
2583
 
@@ -2499,6 +2629,9 @@ export class NaslServer {
2499
2629
  } else if (value.typeAnnotation) {
2500
2630
  node.__TypeAnnotation = (Object.freeze(value.typeAnnotation) as TypeAnnotation);
2501
2631
  }
2632
+ } else {
2633
+ // 清空原来已经赋值上去的类型,可能原来有现在没有了
2634
+ node.__TypeAnnotation = null;
2502
2635
  }
2503
2636
  } catch (err) {
2504
2637
  if (globalThis.window) {
@@ -2773,7 +2906,7 @@ export class NaslServer {
2773
2906
  };
2774
2907
  }
2775
2908
 
2776
- async getCurrentTypeAnnotation(node: BaseNode) {
2909
+ async getCurrentTypeAnnotation(node: BaseNode, outTime: number = 600) {
2777
2910
  if (node.__TypeAnnotation) {
2778
2911
  return node.__TypeAnnotation;
2779
2912
  }
@@ -2787,7 +2920,7 @@ export class NaslServer {
2787
2920
  } else {
2788
2921
  resolve(null);
2789
2922
  }
2790
- }, 600);
2923
+ }, outTime);
2791
2924
  const mySetInterval = setInterval(() => {
2792
2925
  if (node.__isCorrectTypeAnnotation) {
2793
2926
  resolve(node.__TypeAnnotation);
@@ -89,6 +89,10 @@ export function processToTreeFragment(process: Process) {
89
89
  k.getNamespace = function () {
90
90
  return path;
91
91
  };
92
+ const api = `/api/${process.name}/${e.name}/${k.name}`;
93
+ k.getPath = function () {
94
+ return api;
95
+ };
92
96
  });
93
97
 
94
98
  fragment.elements.push({
@@ -107,6 +111,10 @@ export function processToTreeFragment(process: Process) {
107
111
  launchLogic.getNamespace = function () {
108
112
  return path;
109
113
  };
114
+ const api = `/api/${process.name}/${launchLogic.name}`;
115
+ launchLogic.getPath = function () {
116
+ return api;
117
+ };
110
118
 
111
119
  fragment.logics.push(launchLogic);
112
120
  launchLogic.parentKey = 'readonly';