@lcap/nasl 1.0.0-alpha.13 → 1.0.0-alpha.16

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 (324) hide show
  1. package/out/automate/engine/index.d.ts +1 -1
  2. package/out/automate/engine/index.js +73 -25
  3. package/out/automate/engine/index.js.map +1 -1
  4. package/out/automate/engine/utils.js +7 -6
  5. package/out/automate/engine/utils.js.map +1 -1
  6. package/out/common/BaseNode.d.ts +5 -4
  7. package/out/common/BaseNode.js +48 -41
  8. package/out/common/BaseNode.js.map +1 -1
  9. package/out/concepts/App__.d.ts +18 -1
  10. package/out/concepts/App__.js +64 -24
  11. package/out/concepts/App__.js.map +1 -1
  12. package/out/concepts/Argument__.js +2 -2
  13. package/out/concepts/Argument__.js.map +1 -1
  14. package/out/concepts/Assignee__.d.ts +190 -0
  15. package/out/concepts/Assignee__.js +264 -0
  16. package/out/concepts/Assignee__.js.map +1 -0
  17. package/out/concepts/BinaryExpression__.js +6 -6
  18. package/out/concepts/BinaryExpression__.js.map +1 -1
  19. package/out/concepts/BindAttribute__.d.ts +19 -0
  20. package/out/concepts/BindAttribute__.js +36 -2
  21. package/out/concepts/BindAttribute__.js.map +1 -1
  22. package/out/concepts/BindDirective__.js +21 -1
  23. package/out/concepts/BindDirective__.js.map +1 -1
  24. package/out/concepts/BindEvent__.d.ts +1 -0
  25. package/out/concepts/BindEvent__.js +38 -14
  26. package/out/concepts/BindEvent__.js.map +1 -1
  27. package/out/concepts/CallFunction__.js +20 -7
  28. package/out/concepts/CallFunction__.js.map +1 -1
  29. package/out/concepts/CallInterface__.d.ts +11 -8
  30. package/out/concepts/CallInterface__.js +160 -23
  31. package/out/concepts/CallInterface__.js.map +1 -1
  32. package/out/concepts/CallLogic__.d.ts +1 -0
  33. package/out/concepts/CallLogic__.js +17 -7
  34. package/out/concepts/CallLogic__.js.map +1 -1
  35. package/out/concepts/CallQueryComponent__.d.ts +5 -1
  36. package/out/concepts/CallQueryComponent__.js +15 -11
  37. package/out/concepts/CallQueryComponent__.js.map +1 -1
  38. package/out/concepts/Comment__.js +6 -2
  39. package/out/concepts/Comment__.js.map +1 -1
  40. package/out/concepts/ConfigGroup__.js +1 -1
  41. package/out/concepts/ConfigGroup__.js.map +1 -1
  42. package/out/concepts/ConfigProperty__.js +1 -1
  43. package/out/concepts/ConfigProperty__.js.map +1 -1
  44. package/out/concepts/Configuration__.js +1 -1
  45. package/out/concepts/Configuration__.js.map +1 -1
  46. package/out/concepts/Destination__.d.ts +11 -0
  47. package/out/concepts/Destination__.js +59 -19
  48. package/out/concepts/Destination__.js.map +1 -1
  49. package/out/concepts/End__.js +10 -2
  50. package/out/concepts/End__.js.map +1 -1
  51. package/out/concepts/EntityProperty__.d.ts +7 -0
  52. package/out/concepts/EntityProperty__.js +60 -3
  53. package/out/concepts/EntityProperty__.js.map +1 -1
  54. package/out/concepts/Entity__.d.ts +4 -1
  55. package/out/concepts/Entity__.js +29 -12
  56. package/out/concepts/Entity__.js.map +1 -1
  57. package/out/concepts/Enum__.d.ts +4 -0
  58. package/out/concepts/Enum__.js +9 -6
  59. package/out/concepts/Enum__.js.map +1 -1
  60. package/out/concepts/Event__.js +1 -1
  61. package/out/concepts/Event__.js.map +1 -1
  62. package/out/concepts/ForEachStatement__.js +8 -12
  63. package/out/concepts/ForEachStatement__.js.map +1 -1
  64. package/out/concepts/Function__.js +5 -5
  65. package/out/concepts/Function__.js.map +1 -1
  66. package/out/concepts/Identifier__.js +26 -24
  67. package/out/concepts/Identifier__.js.map +1 -1
  68. package/out/concepts/IfStatement__.js +2 -2
  69. package/out/concepts/IfStatement__.js.map +1 -1
  70. package/out/concepts/InterfaceParam__.d.ts +2 -0
  71. package/out/concepts/InterfaceParam__.js +41 -21
  72. package/out/concepts/InterfaceParam__.js.map +1 -1
  73. package/out/concepts/Interface__.d.ts +3 -0
  74. package/out/concepts/Interface__.js +105 -9
  75. package/out/concepts/Interface__.js.map +1 -1
  76. package/out/concepts/LogicItem__.d.ts +2 -1
  77. package/out/concepts/LogicItem__.js +14 -0
  78. package/out/concepts/LogicItem__.js.map +1 -1
  79. package/out/concepts/Logic__.d.ts +3 -0
  80. package/out/concepts/Logic__.js +57 -16
  81. package/out/concepts/Logic__.js.map +1 -1
  82. package/out/concepts/MemberExpression__.js +13 -6
  83. package/out/concepts/MemberExpression__.js.map +1 -1
  84. package/out/concepts/Module__.d.ts +6 -0
  85. package/out/concepts/Module__.js +18 -8
  86. package/out/concepts/Module__.js.map +1 -1
  87. package/out/concepts/Namespace__.d.ts +4 -0
  88. package/out/concepts/Namespace__.js +23 -12
  89. package/out/concepts/Namespace__.js.map +1 -1
  90. package/out/concepts/Param__.d.ts +2 -1
  91. package/out/concepts/Param__.js +35 -22
  92. package/out/concepts/Param__.js.map +1 -1
  93. package/out/concepts/ProcessComponent__.js +2 -2
  94. package/out/concepts/ProcessComponent__.js.map +1 -1
  95. package/out/concepts/ProcessElement__.js +20 -18
  96. package/out/concepts/ProcessElement__.js.map +1 -1
  97. package/out/concepts/ProcessOutcome__.js +1 -1
  98. package/out/concepts/ProcessOutcome__.js.map +1 -1
  99. package/out/concepts/Process__.d.ts +6 -1
  100. package/out/concepts/Process__.js +18 -14
  101. package/out/concepts/Process__.js.map +1 -1
  102. package/out/concepts/QueryAggregateExpression__.js +1 -1
  103. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  104. package/out/concepts/QueryFromExpression__.js +1 -1
  105. package/out/concepts/QueryFromExpression__.js.map +1 -1
  106. package/out/concepts/QueryJoinExpression__.js +2 -2
  107. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  108. package/out/concepts/QuerySelectExpression__.js +1 -1
  109. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  110. package/out/concepts/Return__.d.ts +1 -0
  111. package/out/concepts/Return__.js +38 -25
  112. package/out/concepts/Return__.js.map +1 -1
  113. package/out/concepts/SqlQueryComponent__.js +1 -1
  114. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  115. package/out/concepts/StringLiteral__.d.ts +1 -1
  116. package/out/concepts/StringLiteral__.js +2 -2
  117. package/out/concepts/StringLiteral__.js.map +1 -1
  118. package/out/concepts/StructureProperty__.d.ts +5 -4
  119. package/out/concepts/StructureProperty__.js +54 -31
  120. package/out/concepts/StructureProperty__.js.map +1 -1
  121. package/out/concepts/Structure__.d.ts +1 -0
  122. package/out/concepts/Structure__.js +18 -5
  123. package/out/concepts/Structure__.js.map +1 -1
  124. package/out/concepts/SwitchCase__.js +3 -3
  125. package/out/concepts/SwitchCase__.js.map +1 -1
  126. package/out/concepts/SwitchStatement__.js +1 -1
  127. package/out/concepts/SwitchStatement__.js.map +1 -1
  128. package/out/concepts/TypeAnnotation__.d.ts +3 -5
  129. package/out/concepts/TypeAnnotation__.js +36 -14
  130. package/out/concepts/TypeAnnotation__.js.map +1 -1
  131. package/out/concepts/UnaryExpression__.js +4 -2
  132. package/out/concepts/UnaryExpression__.js.map +1 -1
  133. package/out/concepts/ValidationRule__.d.ts +1 -0
  134. package/out/concepts/ValidationRule__.js +27 -1
  135. package/out/concepts/ValidationRule__.js.map +1 -1
  136. package/out/concepts/Variable__.d.ts +1 -0
  137. package/out/concepts/Variable__.js +38 -25
  138. package/out/concepts/Variable__.js.map +1 -1
  139. package/out/concepts/ViewComponent__.js +5 -5
  140. package/out/concepts/ViewComponent__.js.map +1 -1
  141. package/out/concepts/ViewElement__.d.ts +7 -1
  142. package/out/concepts/ViewElement__.js +154 -117
  143. package/out/concepts/ViewElement__.js.map +1 -1
  144. package/out/concepts/View__.d.ts +4 -0
  145. package/out/concepts/View__.js +38 -25
  146. package/out/concepts/View__.js.map +1 -1
  147. package/out/concepts/WhileStatement__.js +1 -1
  148. package/out/concepts/WhileStatement__.js.map +1 -1
  149. package/out/concepts/basics/stdlib/index.js +3 -1
  150. package/out/concepts/basics/stdlib/index.js.map +1 -1
  151. package/out/concepts/basics/stdlib/nasl.auth.d.ts +3 -0
  152. package/out/concepts/basics/stdlib/nasl.auth.js +30 -0
  153. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -0
  154. package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +3 -0
  155. package/out/concepts/basics/stdlib/nasl.browser copy.js +70 -0
  156. package/out/concepts/basics/stdlib/nasl.browser copy.js.map +1 -0
  157. package/out/concepts/basics/stdlib/nasl.browser.js +6 -35
  158. package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
  159. package/out/concepts/basics/stdlib/nasl.configuration.d.ts +3 -0
  160. package/out/concepts/basics/stdlib/nasl.configuration.js +25 -0
  161. package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -0
  162. package/out/concepts/basics/stdlib/nasl.util.js +49 -41
  163. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  164. package/out/concepts/basics/stdlib/nasl.validation.js +26 -20
  165. package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -1
  166. package/out/concepts/basics/types/coreTypeList.js +11 -11
  167. package/out/concepts/basics/types/coreTypeList.js.map +1 -1
  168. package/out/concepts/index__.d.ts +1 -0
  169. package/out/concepts/index__.js +1 -0
  170. package/out/concepts/index__.js.map +1 -1
  171. package/out/enums/KEYWORDS.js +1 -1
  172. package/out/enums/KEYWORDS.js.map +1 -1
  173. package/out/generator/genBundleFiles.d.ts +1 -0
  174. package/out/generator/genBundleFiles.js +122 -93
  175. package/out/generator/genBundleFiles.js.map +1 -1
  176. package/out/manager/diagnostic.d.ts +1 -1
  177. package/out/server/createUiTs.d.ts +1 -0
  178. package/out/server/createUiTs.js +19 -2
  179. package/out/server/createUiTs.js.map +1 -1
  180. package/out/server/entity2LogicNamespace.js +24 -9
  181. package/out/server/entity2LogicNamespace.js.map +1 -1
  182. package/out/server/getExtensionModules.js +2 -0
  183. package/out/server/getExtensionModules.js.map +1 -1
  184. package/out/server/getLogics.js +40 -56
  185. package/out/server/getLogics.js.map +1 -1
  186. package/out/server/getMemberIdentifier.d.ts +4 -0
  187. package/out/server/getMemberIdentifier.js +90 -48
  188. package/out/server/getMemberIdentifier.js.map +1 -1
  189. package/out/server/getProcesses.d.ts +2 -2
  190. package/out/server/getProcesses.js +34 -11
  191. package/out/server/getProcesses.js.map +1 -1
  192. package/out/server/index.js +4 -0
  193. package/out/server/index.js.map +1 -1
  194. package/out/server/naslServer.d.ts +11 -30
  195. package/out/server/naslServer.js +410 -199
  196. package/out/server/naslServer.js.map +1 -1
  197. package/out/server/process2LogicNamespace.d.ts +10 -0
  198. package/out/server/process2LogicNamespace.js +16 -0
  199. package/out/server/process2LogicNamespace.js.map +1 -1
  200. package/out/server/translator.d.ts +22 -3
  201. package/out/server/translator.js +336 -130
  202. package/out/server/translator.js.map +1 -1
  203. package/out/service/storage/init.js +29 -15
  204. package/out/service/storage/init.js.map +1 -1
  205. package/out/templator/genCreateBlock.js +5 -5
  206. package/out/templator/genCreateBlock.js.map +1 -1
  207. package/out/templator/genCurdEditMultipleKeyBlock.js +9 -13
  208. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  209. package/out/templator/genCurdMultipleKeyBlock.js +7 -7
  210. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  211. package/out/templator/genEditTableBlock.js +2 -2
  212. package/out/templator/genEditTableBlock.js.map +1 -1
  213. package/out/templator/genGetBlock.js +4 -2
  214. package/out/templator/genGetBlock.js.map +1 -1
  215. package/out/templator/genGridViewBlock.d.ts +1 -1
  216. package/out/templator/genGridViewBlock.js +3 -3
  217. package/out/templator/genGridViewBlock.js.map +1 -1
  218. package/out/templator/genQueryComponent.d.ts +2 -0
  219. package/out/templator/genQueryComponent.js +1 -0
  220. package/out/templator/genQueryComponent.js.map +1 -1
  221. package/out/templator/genTableBlock.d.ts +1 -1
  222. package/out/templator/genTableBlock.js +3 -3
  223. package/out/templator/genTableBlock.js.map +1 -1
  224. package/out/templator/genUpdateBlock.js +7 -7
  225. package/out/templator/genUpdateBlock.js.map +1 -1
  226. package/out/templator/utils.d.ts +3 -1
  227. package/out/templator/utils.js +2 -1
  228. package/out/templator/utils.js.map +1 -1
  229. package/out/utils/index.d.ts +6 -0
  230. package/out/utils/index.js +20 -1
  231. package/out/utils/index.js.map +1 -1
  232. package/package.json +2 -1
  233. package/src/automate/engine/index.js +73 -25
  234. package/src/automate/engine/utils.js +7 -6
  235. package/src/common/BaseNode.ts +51 -42
  236. package/src/concepts/App__.ts +104 -26
  237. package/src/concepts/Argument__.ts +3 -2
  238. package/src/concepts/Assignee__.ts +437 -0
  239. package/src/concepts/BinaryExpression__.ts +7 -6
  240. package/src/concepts/BindAttribute__.ts +51 -2
  241. package/src/concepts/BindDirective__.ts +20 -1
  242. package/src/concepts/BindEvent__.ts +39 -16
  243. package/src/concepts/CallFunction__.ts +21 -8
  244. package/src/concepts/CallInterface__.ts +161 -42
  245. package/src/concepts/CallLogic__.ts +21 -9
  246. package/src/concepts/CallQueryComponent__.ts +15 -13
  247. package/src/concepts/Comment__.ts +6 -2
  248. package/src/concepts/ConfigGroup__.ts +1 -1
  249. package/src/concepts/ConfigProperty__.ts +1 -1
  250. package/src/concepts/Configuration__.ts +1 -1
  251. package/src/concepts/Destination__.ts +57 -19
  252. package/src/concepts/End__.ts +9 -11
  253. package/src/concepts/EntityProperty__.ts +56 -3
  254. package/src/concepts/Entity__.ts +33 -20
  255. package/src/concepts/Enum__.ts +8 -7
  256. package/src/concepts/Event__.ts +1 -1
  257. package/src/concepts/ForEachStatement__.ts +8 -13
  258. package/src/concepts/Function__.ts +5 -5
  259. package/src/concepts/Identifier__.ts +31 -26
  260. package/src/concepts/IfStatement__.ts +2 -2
  261. package/src/concepts/InterfaceParam__.ts +39 -20
  262. package/src/concepts/Interface__.ts +103 -9
  263. package/src/concepts/LogicItem__.ts +16 -1
  264. package/src/concepts/Logic__.ts +60 -18
  265. package/src/concepts/MemberExpression__.ts +18 -6
  266. package/src/concepts/Module__.ts +19 -8
  267. package/src/concepts/Namespace__.ts +24 -12
  268. package/src/concepts/Param__.ts +34 -23
  269. package/src/concepts/ProcessComponent__.ts +2 -2
  270. package/src/concepts/ProcessElement__.ts +51 -50
  271. package/src/concepts/ProcessOutcome__.ts +1 -1
  272. package/src/concepts/Process__.ts +32 -28
  273. package/src/concepts/QueryAggregateExpression__.ts +1 -1
  274. package/src/concepts/QueryFromExpression__.ts +1 -1
  275. package/src/concepts/QueryJoinExpression__.ts +2 -2
  276. package/src/concepts/QuerySelectExpression__.ts +1 -1
  277. package/src/concepts/Return__.ts +35 -25
  278. package/src/concepts/SqlQueryComponent__.ts +1 -1
  279. package/src/concepts/StringLiteral__.ts +2 -2
  280. package/src/concepts/StructureProperty__.ts +49 -29
  281. package/src/concepts/Structure__.ts +17 -5
  282. package/src/concepts/SwitchCase__.ts +3 -3
  283. package/src/concepts/SwitchStatement__.ts +1 -1
  284. package/src/concepts/TypeAnnotation__.ts +34 -12
  285. package/src/concepts/UnaryExpression__.ts +4 -2
  286. package/src/concepts/ValidationRule__.ts +24 -1
  287. package/src/concepts/Variable__.ts +35 -24
  288. package/src/concepts/ViewComponent__.ts +5 -5
  289. package/src/concepts/ViewElement__.ts +168 -113
  290. package/src/concepts/View__.ts +44 -25
  291. package/src/concepts/WhileStatement__.ts +1 -1
  292. package/src/concepts/basics/stdlib/index.ts +3 -1
  293. package/src/concepts/basics/stdlib/nasl.auth.ts +26 -0
  294. package/src/concepts/basics/stdlib/nasl.browser.ts +7 -41
  295. package/src/concepts/basics/stdlib/nasl.configuration.ts +21 -0
  296. package/src/concepts/basics/stdlib/nasl.util.ts +49 -41
  297. package/src/concepts/basics/stdlib/nasl.validation.ts +17 -11
  298. package/src/concepts/basics/types/coreTypeList.ts +11 -11
  299. package/src/concepts/index__.ts +1 -0
  300. package/src/enums/KEYWORDS.ts +1 -1
  301. package/src/generator/genBundleFiles.ts +131 -112
  302. package/src/manager/diagnostic.ts +1 -1
  303. package/src/server/createUiTs.ts +22 -4
  304. package/src/server/entity2LogicNamespace.ts +25 -9
  305. package/src/server/getExtensionModules.ts +2 -0
  306. package/src/server/getLogics.ts +42 -58
  307. package/src/server/getMemberIdentifier.ts +88 -46
  308. package/src/server/getProcesses.ts +32 -9
  309. package/src/server/index.ts +12 -1
  310. package/src/server/naslServer.ts +422 -215
  311. package/src/server/process2LogicNamespace.ts +17 -1
  312. package/src/server/translator.ts +392 -134
  313. package/src/service/storage/init.ts +27 -16
  314. package/src/templator/genCreateBlock.ts +5 -5
  315. package/src/templator/genCurdEditMultipleKeyBlock.ts +25 -26
  316. package/src/templator/genCurdMultipleKeyBlock.ts +7 -7
  317. package/src/templator/genEditTableBlock.ts +2 -2
  318. package/src/templator/genGetBlock.ts +5 -7
  319. package/src/templator/genGridViewBlock.ts +4 -7
  320. package/src/templator/genQueryComponent.ts +1 -0
  321. package/src/templator/genTableBlock.ts +4 -7
  322. package/src/templator/genUpdateBlock.ts +7 -8
  323. package/src/templator/utils.ts +2 -1
  324. package/src/utils/index.ts +19 -0
@@ -7,7 +7,6 @@ import Structure from './Structure__';
7
7
  import StructureProperty from './StructureProperty__';
8
8
  import { getNodeByNodeCallee, getNaslNodeByNodeCallee } from '../automate/engine/utils';
9
9
 
10
-
11
10
  //================================================================================
12
11
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
13
12
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -240,9 +239,9 @@ export class Return extends BaseNode {
240
239
  code += ': ';
241
240
  code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
242
241
  }
243
- if (this.defaultValue) {
244
- code += ` = ${this.defaultValue}`;
245
- }
242
+ // if (this.defaultValue) {
243
+ // code += ` = ${this.defaultValue}`;
244
+ // }
246
245
  return code;
247
246
  }
248
247
 
@@ -279,7 +278,7 @@ export class Return extends BaseNode {
279
278
  if (!typeAnnotation)
280
279
  throw new Error('找不到类型:' + typeAnnotation);
281
280
  } else {
282
- typeAnnotation._delete();
281
+ typeAnnotation._delete?.();
283
282
  const relationOptions = { parentId: this.id, parentConcept: this.concept, parentNode: this };
284
283
  Object.assign(typeAnnotation, relationOptions);
285
284
  }
@@ -317,35 +316,46 @@ export class Return extends BaseNode {
317
316
  return !!this.module;
318
317
  }
319
318
  get hasChildren() {
320
- const { typeKind } = this.typeAnnotation;
319
+ const { typeKind, typeNamespace } = this.typeAnnotation;
321
320
  if (typeKind === 'reference' || typeKind === 'generic') {
321
+ if (typeNamespace.endsWith('.enums'))
322
+ return null;
322
323
  return [{}];
323
324
  }
324
325
  return null;
325
326
  }
327
+ get isTreeLeaf() {
328
+ return !this.hasChildren;
329
+ }
326
330
  getSelectRef() {
327
- const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
328
- let completionChildren;
329
- if (typeKind === 'reference') {
330
- if (typeNamespace === 'nasl.ui') {
331
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
332
- const properties = node.properties || [];
333
- completionChildren = properties;
331
+ try {
332
+ const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
333
+ let completionChildren;
334
+ if (typeKind === 'reference') {
335
+ if (typeNamespace === 'nasl.ui') {
336
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
337
+ const properties = node.properties || [];
338
+ completionChildren = properties;
339
+ } else if (typeNamespace.endsWith('.enums')) {
340
+ completionChildren = undefined;
341
+ } else {
342
+ const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
343
+ const properties = node.properties || [];
344
+ completionChildren = properties;
345
+ }
346
+ } else if (typeKind === 'generic') {
347
+ if (typeNamespace === 'nasl.collection') {
348
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
349
+ const properties = node.properties || [];
350
+ completionChildren = properties;
351
+ }
334
352
  } else {
335
- const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
336
- const properties = node.properties || [];
337
- completionChildren = properties;
353
+ completionChildren = undefined;
338
354
  }
339
- } else if (typeKind === 'generic') {
340
- if (typeNamespace === 'nasl.collection') {
341
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
342
- const properties = node.properties || [];
343
- completionChildren = properties;
344
- }
345
- } else {
346
- completionChildren = undefined;
355
+ return completionChildren;
356
+ } catch (err) {
357
+ console.log(err);
347
358
  }
348
- return completionChildren;
349
359
  }
350
360
  //================================================================================
351
361
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -129,7 +129,7 @@ export class SqlQueryComponent extends LogicItem {
129
129
  @withSourceMap()
130
130
  toEmbeddedTS(state?: TranslatorState): string {
131
131
  let code = `(function(): nasl.collection.List<`
132
- code +=`${this.typeAnnotation ? this.typeAnnotation.toEmbeddedTS(shiftState(state, code)): 'unknown'}> {\n`;
132
+ code +=`${this.typeAnnotation ? this.typeAnnotation.toEmbeddedTS(shiftState(state, code)): '__IDENTIFIER__'}> {\n`;
133
133
  code += '\n';
134
134
  code += indent(state.tabSize + 1) + 'return;\n';
135
135
  code += indent(state.tabSize) + '})();\n';
@@ -101,7 +101,7 @@ export class StringLiteral extends LogicItem {
101
101
  }
102
102
 
103
103
  @withSourceMap()
104
- toEmbeddedTS(state?: TranslatorState): string {
104
+ toEmbeddedTS(state?: TranslatorState, isRequired?: boolean): string {
105
105
  let code = '';
106
106
  if (this.value) {
107
107
  if (!this.value.includes("'"))
@@ -113,7 +113,7 @@ export class StringLiteral extends LogicItem {
113
113
  else
114
114
  code += `'${this.value.replace(/'/g, "\\'")}'`;
115
115
  } else {
116
- code += `''`;
116
+ code += isRequired ? '__IDENTIFIER__' : `''`;
117
117
  }
118
118
  return code;
119
119
  }
@@ -227,10 +227,55 @@ export class StructureProperty extends BaseNode {
227
227
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
228
228
  // 自动生成的代码已结束。下面可以手动编写。
229
229
  //================================================================================
230
+
231
+ get hasChildren() {
232
+ const { typeKind, typeNamespace } = this.typeAnnotation;
233
+ if (typeKind === 'reference' || typeKind === 'generic') {
234
+ if (typeNamespace.endsWith('.enums'))
235
+ return null;
236
+ return [{}];
237
+ }
238
+ return null;
239
+ }
240
+ get isTreeLeaf() {
241
+ return !this.hasChildren;
242
+ }
230
243
  /**
231
- * 自动补全的字段列表
244
+ * 是否展开
232
245
  */
233
- completionChildren: Array<EntityProperty | StructureProperty> = undefined;
246
+ @property()
247
+ isLeaf: boolean = true;
248
+
249
+ getSelectRef() {
250
+ try {
251
+ const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
252
+ let completionChildren;
253
+ if (typeKind === 'reference') {
254
+ if (typeNamespace === 'nasl.ui') {
255
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
256
+ const properties = node.properties || [];
257
+ completionChildren = properties;
258
+ } else if (typeNamespace.endsWith('.enums')) {
259
+ completionChildren = undefined;
260
+ } else {
261
+ const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
262
+ const properties = node.properties || [];
263
+ completionChildren = properties;
264
+ }
265
+ } else if (typeKind === 'generic') {
266
+ if (typeNamespace === 'nasl.collection') {
267
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
268
+ const properties = node.properties || [];
269
+ completionChildren = properties;
270
+ }
271
+ } else {
272
+ completionChildren = undefined;
273
+ }
274
+ return completionChildren;
275
+ } catch (err) {
276
+ console.log(err);
277
+ }
278
+ }
234
279
 
235
280
  @withSourceMap()
236
281
  toEmbeddedTS(state?: TranslatorState): string {
@@ -262,7 +307,7 @@ export class StructureProperty extends BaseNode {
262
307
  // eslint-disable-next-line prefer-rest-params
263
308
  throw new Error('找不到类型:' + arguments[0]);
264
309
  } else {
265
- typeAnnotation._delete();
310
+ typeAnnotation._delete?.();
266
311
  const relationOptions = { parentId: this.id, parentConcept: this.concept, parentNode: this };
267
312
  Object.assign(typeAnnotation, relationOptions);
268
313
  }
@@ -291,32 +336,7 @@ export class StructureProperty extends BaseNode {
291
336
  * 是否可编辑
292
337
  * */
293
338
  get readonly() {
294
- return !!this.module;
295
- }
296
-
297
- getSelectRef() {
298
- const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
299
- let completionChildren;
300
- if (typeKind === 'reference') {
301
- if (typeNamespace === 'nasl.ui') {
302
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
303
- const properties = node.properties || [];
304
- completionChildren = properties;
305
- } else {
306
- const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
307
- const properties = node.properties || [];
308
- completionChildren = properties;
309
- }
310
- } else if (typeKind === 'generic') {
311
- if (typeNamespace === 'nasl.collection') {
312
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
313
- const properties = node.properties || [];
314
- completionChildren = properties;
315
- }
316
- } else {
317
- completionChildren = undefined;
318
- }
319
- return completionChildren;
339
+ return !!this.module || (this.parentNode as Structure).origin === 'CallQueryComponent';
320
340
  }
321
341
 
322
342
  //================================================================================
@@ -169,7 +169,7 @@ export class Structure extends BaseNode {
169
169
  name: options,
170
170
  }, this, 'typeParams');
171
171
  } else if (options instanceof TypeParam) {
172
- options.delete(); // 同一实例不支持多处存在
172
+ options.ensureDelete(); // 同一实例不支持多处存在
173
173
  typeParam = options;
174
174
  Object.assign(typeParam, relationOptions);
175
175
  } else {
@@ -311,7 +311,7 @@ export class Structure extends BaseNode {
311
311
  name: options,
312
312
  }, this, 'properties');
313
313
  } else if (options instanceof StructureProperty) {
314
- options.delete(); // 同一实例不支持多处存在
314
+ options.ensureDelete(); // 同一实例不支持多处存在
315
315
  property = options;
316
316
  Object.assign(property, relationOptions);
317
317
  } else {
@@ -518,7 +518,7 @@ export class Structure extends BaseNode {
518
518
  * 是否可编辑
519
519
  * */
520
520
  get readonly() {
521
- return !!this.module;
521
+ return !!this.module || this.origin === 'CallQueryComponent';
522
522
  }
523
523
  /* 删除空数据模块 */
524
524
  deleteLogincAndModule() {
@@ -532,7 +532,7 @@ export class Structure extends BaseNode {
532
532
  toEmbeddedTS(state?: TranslatorState): string {
533
533
  let code = `export class ${this.tsName} {\n`;
534
534
  code += indent(state.tabSize + 1);
535
- code += `__name: '${this.getNamespace()}.${this.tsName}';\n`;
535
+ code += `__name: '${this.getTsNamespace()}.${this.tsName}';\n`;
536
536
  this.properties.forEach((property) => {
537
537
  code += indent(state.tabSize + 1);
538
538
  code += property.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
@@ -550,6 +550,18 @@ export class Structure extends BaseNode {
550
550
  throw new Error('无法获取命名空间,请设置 parentNode!');
551
551
  }
552
552
 
553
+ getTsNamespace() {
554
+ if (this.parentNode.concept === 'App') {
555
+ return `${(this.parentNode as Namespace).getNamespace()}.structures`;
556
+ } else {
557
+ if (this.parentNode && (this.parentNode as Namespace).getTsNamespace) {
558
+ return `${(this.parentNode as Namespace).getTsNamespace()}.structures`;
559
+ } else {
560
+ throw new Error('无法获取命名空间,请设置 parentNode!');
561
+ }
562
+ }
563
+ }
564
+
553
565
  /**
554
566
  * 生成宿主语言的文件路径
555
567
  * @param name 一般不用传,用于 rename
@@ -560,7 +572,7 @@ export class Structure extends BaseNode {
560
572
  }
561
573
 
562
574
  toEmbeddedTSFile() {
563
- let code = `namespace ${this.getNamespace()} {\n`;
575
+ let code = `namespace ${this.getTsNamespace()} {\n`;
564
576
 
565
577
  const state = createCompilerState(code, { tabSize: 1 });
566
578
  try {
@@ -89,7 +89,7 @@ export class SwitchCase extends LogicItem {
89
89
  const relationOptions = { parentNode: this, parentKey: 'consequent' };
90
90
  let logicItem: LogicItem;
91
91
  if (options instanceof LogicItem) {
92
- options.delete(); // 同一实例不支持多处存在
92
+ options.ensureDelete(); // 同一实例不支持多处存在
93
93
  logicItem = options;
94
94
  Object.assign(logicItem, relationOptions);
95
95
  } else {
@@ -249,7 +249,7 @@ export class SwitchCase extends LogicItem {
249
249
  tabSize: 0,
250
250
  })) : '';
251
251
 
252
- code += ')) {\n';
252
+ code += ') {\n';
253
253
 
254
254
  if (Array.isArray(this.consequent)) {
255
255
  this.consequent.forEach((logicItem) => {
@@ -277,7 +277,7 @@ export class SwitchCase extends LogicItem {
277
277
 
278
278
  @withSourceMap()
279
279
  toEmbeddedTS(state?: TranslatorState, isLast?: boolean): string {
280
- let code = '';
280
+ let code = '\n';
281
281
  if (!isLast) {
282
282
  code += 'if (nasl.core.ensureBoolean(';
283
283
  code += this.test ? this.test.toEmbeddedTS(shiftState(state, code, {
@@ -72,7 +72,7 @@ export class SwitchStatement extends LogicItem {
72
72
  const relationOptions = { parentNode: this, parentKey: 'cases' };
73
73
  let switchCase: SwitchCase;
74
74
  if (options instanceof SwitchCase) {
75
- options.delete(); // 同一实例不支持多处存在
75
+ options.ensureDelete(); // 同一实例不支持多处存在
76
76
  switchCase = options;
77
77
  Object.assign(switchCase, relationOptions);
78
78
  } else {
@@ -14,6 +14,20 @@ export enum PRIMITIVE_TYPE {
14
14
  Email = 'Email'
15
15
  }
16
16
 
17
+ export const PRIMITIVE_TITLE: Record<string, string> = {
18
+ Boolean: '布尔值',
19
+ Integer: '整数',
20
+ Long: '长整数',
21
+ Double: '小数',
22
+ String: '字符串',
23
+ Text: '长文本',
24
+ Binary: '二进制流',
25
+ Date: '日期',
26
+ Time: '时间',
27
+ DateTime: '日期时间',
28
+ Email: '电子邮箱',
29
+ };
30
+
17
31
  //================================================================================
18
32
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
19
33
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -62,13 +76,6 @@ export class TypeAnnotation extends BaseNode {
62
76
  @property('TypeAnnotation')
63
77
  typeArguments?: Array<TypeAnnotation> = null;
64
78
 
65
- /**
66
- * 显示文本
67
- */
68
- @excludedInJSON()
69
- @property()
70
- text?: string = undefined;
71
-
72
79
  /**
73
80
  * 是否是推断出来的
74
81
  */
@@ -116,7 +123,7 @@ export class TypeAnnotation extends BaseNode {
116
123
  const relationOptions = { parentNode: this, parentKey: 'typeArguments' };
117
124
  let typeAnnotation: TypeAnnotation;
118
125
  if (options instanceof TypeAnnotation) {
119
- options.delete(); // 同一实例不支持多处存在
126
+ options.ensureDelete(); // 同一实例不支持多处存在
120
127
  typeAnnotation = options;
121
128
  Object.assign(typeAnnotation, relationOptions);
122
129
  } else {
@@ -252,13 +259,18 @@ export class TypeAnnotation extends BaseNode {
252
259
  }
253
260
 
254
261
  /**
255
- * 临时展示 type 标题
262
+ * 用于展示的 type 标题
256
263
  */
257
264
  get typeTitle(): string {
258
- if (this.typeKind === 'primitive' || this.typeKind === 'reference') {
265
+ if (this.typeKind === 'primitive') {
266
+ return `${this.typeName} ${PRIMITIVE_TITLE[this.typeName]}`;
267
+ } else if (this.typeKind === 'reference') {
259
268
  return `${this.typeName}`;
260
269
  } else if (this.typeKind === 'generic') {
261
- return `${this.typeName}<${(this.typeArguments || []).map((arg) => arg.typeTitle)}>`;
270
+ if (this.typeArguments && this.typeArguments.length)
271
+ return `${this.typeName}<${(this.typeArguments || []).map((arg) => arg.typeName || 'T')}>`;
272
+ else
273
+ return this.typeName;
262
274
  } else {
263
275
  return this.typeName;
264
276
  }
@@ -319,6 +331,10 @@ export class TypeAnnotation extends BaseNode {
319
331
  return '';
320
332
  }
321
333
 
334
+ toJS(state?: TranslatorState): string {
335
+ return JSON.stringify(this);
336
+ }
337
+
322
338
  @withSourceMap()
323
339
  toEmbeddedTS(state?: TranslatorState): string {
324
340
  if (this.typeKind === 'primitive' || this.typeKind === 'reference') {
@@ -330,7 +346,13 @@ export class TypeAnnotation extends BaseNode {
330
346
  let code = `${this.tsCalleeNamespace}.${this.typeName}<`;
331
347
  return (code += `${(this.typeArguments || []).map((arg) => arg.toEmbeddedTS(shiftState(state, code, { inline: true })))}>`);
332
348
  } else {
333
- return this.typeName;
349
+ if (this.tsCalleeNamespace && this.typeName) {
350
+ return `${this.tsCalleeNamespace}.${this.typeName}`;
351
+ } else if (this.typeName) {
352
+ return this.typeName;
353
+ } else {
354
+ return '__IDENTIFIER__';
355
+ }
334
356
  }
335
357
  }
336
358
 
@@ -137,7 +137,7 @@ export class UnaryExpression extends LogicItem {
137
137
  if (this.operator === 'isNull') {
138
138
  return this.argument.toUI(state);
139
139
  } else {
140
- return '!' + this.argument.toUI(state);
140
+ return '!(' + this.argument.toUI(state) + ')';
141
141
  }
142
142
  }
143
143
 
@@ -162,7 +162,9 @@ export class UnaryExpression extends LogicItem {
162
162
 
163
163
  let code = '';
164
164
  if (this.argument) {
165
- code += `${this.operator}(${this.argument.toEmbeddedTS(shiftState(state, code))})`;
165
+ code += `${this.operator}(`;
166
+ code += `${this.argument.toEmbeddedTS(shiftState(state, code))}`;
167
+ code += `)`;
166
168
  } else {
167
169
  code += `${this.operator}(__IDENTIFIER__)`;
168
170
  }
@@ -92,7 +92,7 @@ export class ValidationRule extends LogicItem {
92
92
  const relationOptions = { parentNode: this, parentKey: 'arguments' };
93
93
  let argument: Argument;
94
94
  if (options instanceof Argument) {
95
- options.delete(); // 同一实例不支持多处存在
95
+ options.ensureDelete(); // 同一实例不支持多处存在
96
96
  argument = options;
97
97
  Object.assign(argument, relationOptions);
98
98
  } else {
@@ -258,6 +258,29 @@ export class ValidationRule extends LogicItem {
258
258
  return code;
259
259
  }
260
260
 
261
+ @withSourceMap()
262
+ toEmbeddedTS(state?: TranslatorState): string {
263
+ let code = '';
264
+ if (this.calleeName) {
265
+ if (this.arguments.length) {
266
+ code += this.calleeKey;
267
+ code += '(';
268
+ this.arguments.forEach((arg, index) => {
269
+ code += arg.toEmbeddedTS(shiftState(state, code), false, false);
270
+ if (index !== this.arguments.length - 1)
271
+ code += ', ';
272
+ });
273
+ code += ')';
274
+ } else {
275
+ // 没有入参数的不需要校验
276
+ return 'null';
277
+ }
278
+ } else {
279
+ code += '__IDENTIFIER__';
280
+ }
281
+ return code;
282
+ }
283
+
261
284
  get calleeKey(): string {
262
285
  return `${this.calleeNamespace}.${this.calleeName}`;
263
286
  }
@@ -240,9 +240,9 @@ export class Variable extends BaseNode {
240
240
  code += ': ';
241
241
  code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
242
242
  }
243
- if (this.defaultValue) {
244
- code += ` = ${this.defaultValue}`;
245
- }
243
+ // if (this.defaultValue) {
244
+ // code += ` = ${this.defaultValue}`;
245
+ // }
246
246
  return code;
247
247
  }
248
248
 
@@ -275,7 +275,7 @@ export class Variable extends BaseNode {
275
275
  if (!typeAnnotation)
276
276
  throw new Error('找不到类型:' + arguments[0]);
277
277
  } else {
278
- typeAnnotation._delete();
278
+ typeAnnotation._delete?.();
279
279
  const relationOptions = { parentId: this.id, parentConcept: this.concept, parentNode: this };
280
280
  Object.assign(typeAnnotation, relationOptions);
281
281
  }
@@ -313,35 +313,46 @@ export class Variable extends BaseNode {
313
313
  return !!this.module;
314
314
  }
315
315
  get hasChildren() {
316
- const { typeKind } = this.typeAnnotation;
316
+ const { typeKind, typeNamespace } = this.typeAnnotation;
317
317
  if (typeKind === 'reference' || typeKind === 'generic') {
318
+ if (typeNamespace.endsWith('.enums'))
319
+ return null;
318
320
  return [{}];
319
321
  }
320
322
  return null;
321
323
  }
324
+ get isTreeLeaf() {
325
+ return !this.hasChildren;
326
+ }
322
327
  getSelectRef() {
323
- const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
324
- let completionChildren;
325
- if (typeKind === 'reference') {
326
- if (typeNamespace === 'nasl.ui') {
327
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
328
- const properties = node.properties || [];
329
- completionChildren = properties;
328
+ try {
329
+ const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
330
+ let completionChildren;
331
+ if (typeKind === 'reference') {
332
+ if (typeNamespace === 'nasl.ui') {
333
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
334
+ const properties = node.properties || [];
335
+ completionChildren = properties;
336
+ } else if (typeNamespace.endsWith('.enums')) {
337
+ completionChildren = undefined;
338
+ } else {
339
+ const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
340
+ const properties = node.properties || [];
341
+ completionChildren = properties;
342
+ }
343
+ } else if (typeKind === 'generic') {
344
+ if (typeNamespace === 'nasl.collection') {
345
+ const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
346
+ const properties = node.properties || [];
347
+ completionChildren = properties;
348
+ }
330
349
  } else {
331
- const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
332
- const properties = node.properties || [];
333
- completionChildren = properties;
350
+ completionChildren = undefined;
334
351
  }
335
- } else if (typeKind === 'generic') {
336
- if (typeNamespace === 'nasl.collection') {
337
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
338
- const properties = node.properties || [];
339
- completionChildren = properties;
340
- }
341
- } else {
342
- completionChildren = undefined;
352
+ return completionChildren;
353
+ } catch (err) {
354
+ console.log(err);
343
355
  }
344
- return completionChildren;
345
356
  }
346
357
  //================================================================================
347
358
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -164,7 +164,7 @@ export class ViewComponent extends BaseNode {
164
164
  name: options,
165
165
  }, this, 'attrs');
166
166
  } else if (options instanceof Attribute) {
167
- options.delete(); // 同一实例不支持多处存在
167
+ options.ensureDelete(); // 同一实例不支持多处存在
168
168
  attribute = options;
169
169
  Object.assign(attribute, relationOptions);
170
170
  } else {
@@ -306,7 +306,7 @@ export class ViewComponent extends BaseNode {
306
306
  name: options,
307
307
  }, this, 'events');
308
308
  } else if (options instanceof Event) {
309
- options.delete(); // 同一实例不支持多处存在
309
+ options.ensureDelete(); // 同一实例不支持多处存在
310
310
  event = options;
311
311
  Object.assign(event, relationOptions);
312
312
  } else {
@@ -448,7 +448,7 @@ export class ViewComponent extends BaseNode {
448
448
  name: options,
449
449
  }, this, 'slots');
450
450
  } else if (options instanceof Slot) {
451
- options.delete(); // 同一实例不支持多处存在
451
+ options.ensureDelete(); // 同一实例不支持多处存在
452
452
  slot = options;
453
453
  Object.assign(slot, relationOptions);
454
454
  } else {
@@ -590,7 +590,7 @@ export class ViewComponent extends BaseNode {
590
590
  name: options,
591
591
  }, this, 'methods');
592
592
  } else if (options instanceof Logic) {
593
- options.delete(); // 同一实例不支持多处存在
593
+ options.ensureDelete(); // 同一实例不支持多处存在
594
594
  logic = options;
595
595
  Object.assign(logic, relationOptions);
596
596
  } else {
@@ -732,7 +732,7 @@ export class ViewComponent extends BaseNode {
732
732
  name: options,
733
733
  }, this, 'children');
734
734
  } else if (options instanceof ViewComponent) {
735
- options.delete(); // 同一实例不支持多处存在
735
+ options.ensureDelete(); // 同一实例不支持多处存在
736
736
  viewComponent = options;
737
737
  Object.assign(viewComponent, relationOptions);
738
738
  } else {