@lcap/nasl 2.20.1-beta.1 → 2.20.1-beta.3

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 (264) hide show
  1. package/docs/classes/EntityProperty.html +1 -1
  2. package/out/automate/engine/operators.d.ts +10 -1
  3. package/out/automate/engine/operators.js +14 -5
  4. package/out/automate/engine/operators.js.map +1 -1
  5. package/out/automate/engine/viewCache.d.ts +1 -0
  6. package/out/automate/template/myProcess.d.ts +1 -0
  7. package/out/automate/template/myProcess.js +9021 -9021
  8. package/out/automate/template/myProcess.js.map +1 -1
  9. package/out/bak/translator.js +3 -3
  10. package/out/bak/translator.js.map +1 -1
  11. package/out/common/BaseNode.js.map +1 -1
  12. package/out/common/Command.d.ts +1 -1
  13. package/out/common/EventEmitter.d.ts +1 -1
  14. package/out/concepts/Abort__.d.ts +25 -0
  15. package/out/concepts/Abort__.js +80 -0
  16. package/out/concepts/Abort__.js.map +1 -0
  17. package/out/concepts/Anchor__.js.map +1 -1
  18. package/out/concepts/AnonymousFunction__.js.map +1 -1
  19. package/out/concepts/App__.js.map +1 -1
  20. package/out/concepts/Argument__.js.map +1 -1
  21. package/out/concepts/Assignee__.js.map +1 -1
  22. package/out/concepts/AssignmentLine__.js.map +1 -1
  23. package/out/concepts/Assignment__.js.map +1 -1
  24. package/out/concepts/Attribute__.js.map +1 -1
  25. package/out/concepts/BatchAssignment__.js.map +1 -1
  26. package/out/concepts/BinaryExpression__.js.map +1 -1
  27. package/out/concepts/BindAttribute__.js +7 -6
  28. package/out/concepts/BindAttribute__.js.map +1 -1
  29. package/out/concepts/BindDirective__.js +7 -6
  30. package/out/concepts/BindDirective__.js.map +1 -1
  31. package/out/concepts/BindEvent__.js.map +1 -1
  32. package/out/concepts/BindStyle__.js +10 -10
  33. package/out/concepts/BindStyle__.js.map +1 -1
  34. package/out/concepts/BooleanLiteral__.js.map +1 -1
  35. package/out/concepts/CallFunction__.js.map +1 -1
  36. package/out/concepts/CallInterface__.d.ts +1 -0
  37. package/out/concepts/CallInterface__.js +32 -2
  38. package/out/concepts/CallInterface__.js.map +1 -1
  39. package/out/concepts/CallLogic__.js +3 -3
  40. package/out/concepts/CallLogic__.js.map +1 -1
  41. package/out/concepts/CallQueryComponent__.js.map +1 -1
  42. package/out/concepts/Comment__.js.map +1 -1
  43. package/out/concepts/CompletionProperty__.js.map +1 -1
  44. package/out/concepts/ConfigGroup__.js.map +1 -1
  45. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  46. package/out/concepts/ConfigProperty__.js.map +1 -1
  47. package/out/concepts/Configuration__.js.map +1 -1
  48. package/out/concepts/Constant__.js.map +1 -1
  49. package/out/concepts/DataElement__.js.map +1 -1
  50. package/out/concepts/DataSource__.js +11 -3
  51. package/out/concepts/DataSource__.js.map +1 -1
  52. package/out/concepts/DatabaseTypeAnnotation__.d.ts +31 -0
  53. package/out/concepts/DatabaseTypeAnnotation__.js +78 -0
  54. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -0
  55. package/out/concepts/Destination__.js +7 -7
  56. package/out/concepts/Destination__.js.map +1 -1
  57. package/out/concepts/End__.js.map +1 -1
  58. package/out/concepts/EntityIndex__.d.ts +1 -1
  59. package/out/concepts/EntityIndex__.js.map +1 -1
  60. package/out/concepts/EntityProperty__.d.ts +1 -1
  61. package/out/concepts/EntityProperty__.js.map +1 -1
  62. package/out/concepts/Entity__.js.map +1 -1
  63. package/out/concepts/EnumItem__.js.map +1 -1
  64. package/out/concepts/Enum__.js.map +1 -1
  65. package/out/concepts/Event__.js.map +1 -1
  66. package/out/concepts/ExternalDestination__.js.map +1 -1
  67. package/out/concepts/ForEachStatement__.js.map +1 -1
  68. package/out/concepts/FrontendLibrary__.js.map +1 -1
  69. package/out/concepts/Frontend__.js.map +1 -1
  70. package/out/concepts/Function__.js.map +1 -1
  71. package/out/concepts/Identifier__.js.map +1 -1
  72. package/out/concepts/IfStatement__.js.map +1 -1
  73. package/out/concepts/Integration__.d.ts +53 -0
  74. package/out/concepts/Integration__.js +143 -0
  75. package/out/concepts/Integration__.js.map +1 -0
  76. package/out/concepts/InterfaceParam__.js.map +1 -1
  77. package/out/concepts/Interface__.d.ts +9 -0
  78. package/out/concepts/Interface__.js +54 -0
  79. package/out/concepts/Interface__.js.map +1 -1
  80. package/out/concepts/JSBlock__.js.map +1 -1
  81. package/out/concepts/JavaLogic__.d.ts +42 -0
  82. package/out/concepts/JavaLogic__.js +122 -0
  83. package/out/concepts/JavaLogic__.js.map +1 -0
  84. package/out/concepts/LogicItem__.js.map +1 -1
  85. package/out/concepts/Logic__.js +2 -2
  86. package/out/concepts/Logic__.js.map +1 -1
  87. package/out/concepts/MatchCase__.js.map +1 -1
  88. package/out/concepts/Match__.d.ts +3 -0
  89. package/out/concepts/Match__.js +73 -2
  90. package/out/concepts/Match__.js.map +1 -1
  91. package/out/concepts/MemberExpression__.js.map +1 -1
  92. package/out/concepts/MicroApp__.d.ts +51 -0
  93. package/out/concepts/MicroApp__.js +113 -0
  94. package/out/concepts/MicroApp__.js.map +1 -0
  95. package/out/concepts/Module__.d.ts +1 -1
  96. package/out/concepts/Module__.js.map +1 -1
  97. package/out/concepts/Namespace__.js.map +1 -1
  98. package/out/concepts/NewComposite__.d.ts +1 -0
  99. package/out/concepts/NewComposite__.js +20 -2
  100. package/out/concepts/NewComposite__.js.map +1 -1
  101. package/out/concepts/NewList__.js.map +1 -1
  102. package/out/concepts/NewMap__.js.map +1 -1
  103. package/out/concepts/New__.js.map +1 -1
  104. package/out/concepts/NullLiteral__.js.map +1 -1
  105. package/out/concepts/NumericLiteral__.js.map +1 -1
  106. package/out/concepts/OqlQueryComponent__.js +2 -0
  107. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  108. package/out/concepts/Param__.js +1 -1
  109. package/out/concepts/Param__.js.map +1 -1
  110. package/out/concepts/Point__.js.map +1 -1
  111. package/out/concepts/ProcessComponent__.js.map +1 -1
  112. package/out/concepts/ProcessElement__.js.map +1 -1
  113. package/out/concepts/ProcessOutcome__.js.map +1 -1
  114. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  115. package/out/concepts/Process__.js.map +1 -1
  116. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  117. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  118. package/out/concepts/QueryFromExpression__.js.map +1 -1
  119. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  120. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  121. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  122. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  123. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  124. package/out/concepts/Rect__.js.map +1 -1
  125. package/out/concepts/Return__.js.map +1 -1
  126. package/out/concepts/Role__.js.map +1 -1
  127. package/out/concepts/SelectMembers__.js.map +1 -1
  128. package/out/concepts/Slot__.js.map +1 -1
  129. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  130. package/out/concepts/Start__.js.map +1 -1
  131. package/out/concepts/StringInterpolation__.js.map +1 -1
  132. package/out/concepts/StringLiteral__.js.map +1 -1
  133. package/out/concepts/StructureProperty__.js.map +1 -1
  134. package/out/concepts/Structure__.js.map +1 -1
  135. package/out/concepts/SwitchCase__.js.map +1 -1
  136. package/out/concepts/SwitchStatement__.js.map +1 -1
  137. package/out/concepts/Theme__.js.map +1 -1
  138. package/out/concepts/Transactional__.js.map +1 -1
  139. package/out/concepts/TypeAnnotation__.js.map +1 -1
  140. package/out/concepts/TypeParam__.js.map +1 -1
  141. package/out/concepts/UnaryExpression__.js.map +1 -1
  142. package/out/concepts/Unparsed__.js.map +1 -1
  143. package/out/concepts/UseComponent__.js.map +1 -1
  144. package/out/concepts/ValidationRule__.js.map +1 -1
  145. package/out/concepts/Variable__.js.map +1 -1
  146. package/out/concepts/ViewBlock__.js.map +1 -1
  147. package/out/concepts/ViewComponent__.js.map +1 -1
  148. package/out/concepts/ViewElement__.d.ts +1 -0
  149. package/out/concepts/ViewElement__.js +7 -0
  150. package/out/concepts/ViewElement__.js.map +1 -1
  151. package/out/concepts/View__.js +8 -3
  152. package/out/concepts/View__.js.map +1 -1
  153. package/out/concepts/WhileStatement__.js.map +1 -1
  154. package/out/config.d.ts +1 -1
  155. package/out/decorators/index.d.ts +2 -2
  156. package/out/generator/genReleaseBody.d.ts +1 -0
  157. package/out/generator/genReleaseBody.js +1 -0
  158. package/out/generator/genReleaseBody.js.map +1 -1
  159. package/out/generator/icestark.d.ts +2 -0
  160. package/out/generator/icestark.js +48 -0
  161. package/out/generator/icestark.js.map +1 -0
  162. package/out/generator/microApp.d.ts +2 -0
  163. package/out/generator/microApp.js +35 -0
  164. package/out/generator/microApp.js.map +1 -0
  165. package/out/generator/permission.d.ts +2 -1
  166. package/out/generator/permission.js +17 -8
  167. package/out/generator/permission.js.map +1 -1
  168. package/out/generator/qiankun.d.ts +2 -0
  169. package/out/generator/qiankun.js +52 -0
  170. package/out/generator/qiankun.js.map +1 -0
  171. package/out/index.d.ts +1 -1
  172. package/out/index.js +2 -1
  173. package/out/index.js.map +1 -1
  174. package/out/manager/stepRecorder.d.ts +20 -0
  175. package/out/manager/stepRecorder.js +110 -0
  176. package/out/manager/stepRecorder.js.map +1 -0
  177. package/out/sentry/index.d.ts +29 -0
  178. package/out/sentry/index.js +111 -0
  179. package/out/sentry/index.js.map +1 -0
  180. package/out/server/getMemberIdentifier.js +3 -2
  181. package/out/server/getMemberIdentifier.js.map +1 -1
  182. package/out/server/getProcesses.d.ts +3 -3
  183. package/out/server/getScope.d.ts +1 -1
  184. package/out/server/naslServer.d.ts +1 -1
  185. package/out/server/naslServer.js +22 -5
  186. package/out/server/naslServer.js.map +1 -1
  187. package/out/service/creator/add.configs.js +2 -0
  188. package/out/service/creator/add.configs.js.map +1 -1
  189. package/out/service/creator/errHandles.js +5 -0
  190. package/out/service/creator/errHandles.js.map +1 -1
  191. package/out/service/creator/index.js +2 -0
  192. package/out/service/creator/index.js.map +1 -1
  193. package/out/service/storage/api.d.ts +18 -0
  194. package/out/service/storage/api.js +12 -0
  195. package/out/service/storage/api.js.map +1 -1
  196. package/out/service/storage/init.d.ts +41 -1
  197. package/out/service/storage/init.js +172 -42
  198. package/out/service/storage/init.js.map +1 -1
  199. package/out/service/storage/service.d.ts +9 -1
  200. package/out/service/storage/service.js +27 -1
  201. package/out/service/storage/service.js.map +1 -1
  202. package/out/templator/genCreateBlock.js +1 -1
  203. package/out/templator/genCreateBlock.js.map +1 -1
  204. package/out/templator/genCurdEditMultipleKeyBlock.js +4 -4
  205. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  206. package/out/templator/genCurdMultipleKeyBlock.js +4 -5
  207. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  208. package/out/templator/genEditTableBlock.js +2 -2
  209. package/out/templator/genEditTableBlock.js.map +1 -1
  210. package/out/templator/genSelectBlock.js +1 -1
  211. package/out/templator/genTableBlock.js +2 -2
  212. package/out/templator/genTableBlock.js.map +1 -1
  213. package/out/templator/genUpdateBlock.js +1 -1
  214. package/out/templator/genUpdateBlock.js.map +1 -1
  215. package/out/translator/index.d.ts +1 -1
  216. package/out/translator/index.js +4 -1
  217. package/out/translator/index.js.map +1 -1
  218. package/out/translator/lsp.d.ts +3 -3
  219. package/out/utils/index.d.ts +4 -4
  220. package/package.json +2 -2
  221. package/sandbox/stdlib/nasl.oql.ts +4 -0
  222. package/src/automate/engine/operators.js +13 -5
  223. package/src/automate/template/myProcess.js +11451 -11452
  224. package/src/automate/upgrader/2.20.js +1 -0
  225. package/src/bak/translator.js +3 -3
  226. package/src/concepts/BindAttribute__.ts +7 -5
  227. package/src/concepts/BindDirective__.ts +7 -5
  228. package/src/concepts/BindStyle__.ts +7 -6
  229. package/src/concepts/CallInterface__.ts +34 -20
  230. package/src/concepts/CallLogic__.ts +3 -3
  231. package/src/concepts/ConfigGroup__.ts +2 -2
  232. package/src/concepts/DataSource__.ts +11 -7
  233. package/src/concepts/Destination__.ts +7 -7
  234. package/src/concepts/Interface__.ts +59 -7
  235. package/src/concepts/Logic__.ts +2 -2
  236. package/src/concepts/Match__.ts +77 -2
  237. package/src/concepts/NewComposite__.ts +20 -2
  238. package/src/concepts/OqlQueryComponent__.ts +2 -0
  239. package/src/concepts/Param__.ts +1 -1
  240. package/src/concepts/ViewElement__.ts +9 -1
  241. package/src/concepts/View__.ts +11 -8
  242. package/src/generator/genReleaseBody.ts +2 -1
  243. package/src/generator/permission.ts +17 -7
  244. package/src/index.ts +1 -1
  245. package/src/server/getMemberIdentifier.ts +5 -2
  246. package/src/server/naslServer.ts +17 -5
  247. package/src/service/creator/add.configs.js +3 -0
  248. package/src/service/creator/errHandles.js +6 -0
  249. package/src/service/creator/index.js +3 -0
  250. package/src/service/storage/api.js +12 -0
  251. package/src/service/storage/init.ts +204 -41
  252. package/src/service/storage/service.ts +29 -1
  253. package/src/templator/genCreateBlock.ts +1 -1
  254. package/src/templator/genCurdEditMultipleKeyBlock.ts +4 -4
  255. package/src/templator/genCurdMultipleKeyBlock.ts +4 -5
  256. package/src/templator/genEditTableBlock.ts +2 -2
  257. package/src/templator/genSelectBlock.ts +1 -1
  258. package/src/templator/genTableBlock.ts +2 -2
  259. package/src/templator/genUpdateBlock.ts +1 -1
  260. package/src/translator/index.ts +3 -1
  261. package/out/automate/engine/2.14-components.d.ts +0 -1115
  262. package/out/automate/engine/2.14-components.js +0 -1087
  263. package/out/automate/engine/2.14-components.js.map +0 -1
  264. package/yarn-error.log +0 -2087
@@ -21,6 +21,7 @@ const excludedKeySet = new Set([
21
21
  export function replace(script) {
22
22
  script = script.replace('execTemplate = function(app,', 'execTemplate = function(app, frontend, ');
23
23
  script = script.replace('_uniqueName.initAppUniqueNames(app);', '_uniqueName.initAppUniqueNames(app, frontend);');
24
+ script = script.replace('_addModule(app', '_addModule(app, frontend');
24
25
  return script;
25
26
  }
26
27
 
@@ -76,9 +76,9 @@ export default function (definition) {
76
76
 
77
77
  let viewExpressionMethods;
78
78
  if (hasViewExpressions) {
79
- viewExpressions.forEach((viewExpression) => {
80
- viewVariablesData.push(`${safeCodeAsKey(viewExpression.expressionNameInView)}: undefined`);
81
- });
79
+ //viewExpressions.forEach((viewExpression) => {
80
+ // viewVariablesData.push(`${safeCodeAsKey(viewExpression.expressionNameInView)}: undefined`);
81
+ //});
82
82
  viewExpressionMethods = (viewExpressions).map((viewExpression) =>
83
83
  viewExpression.getInViewMethod({
84
84
  tabSize: 1,
@@ -815,12 +815,13 @@ export class BindAttribute extends BaseNode {
815
815
  let memberExpressionNode = node?.parentNode;
816
816
  while (memberExpressionNode?.concept === 'MemberExpression') {
817
817
  expressionNode = memberExpressionNode;
818
+ // 为了处理MemberExpression里面存在CallLogic、CallFunction等的情况
818
819
  const { concept: objConcept } = memberExpressionNode.object || {};
819
820
  if (!['MemberExpression', 'Identifier'].includes(objConcept)) {
820
821
  memberExpressionNode = null;
821
822
  expressionNode = null;
822
823
  } else {
823
- memberExpressionNode = memberExpressionNode.object;
824
+ memberExpressionNode = memberExpressionNode.parentNode;
824
825
  }
825
826
  }
826
827
  if (expressionNode) {
@@ -926,10 +927,11 @@ export class BindAttribute extends BaseNode {
926
927
  let value = this.value;
927
928
  if (this.type === 'dynamic' || (this.name === 'rules' && this.rules)) {
928
929
  // 需要用标识符替换
929
- if (options?.finalCode !== false && this.needReplaceWithIdentifier) {
930
- const argsList = this.getArgsList();
931
- value = `${this.expressionBuilderName}(${argsList.join(', ')})`;
932
- } else if (this.name === 'rules' && this.rules) {
930
+ //if (options?.finalCode !== false && this.needReplaceWithIdentifier) {
931
+ // const argsList = this.getArgsList();
932
+ // value = `${this.expressionBuilderName}(${argsList.join(', ')})`;
933
+ //} else
934
+ if (this.name === 'rules' && this.rules) {
933
935
  const ruleStrs = this.rules.map((rule) => rule.toVue(options));
934
936
  value = `[${ruleStrs.join(' , ')}]`;
935
937
  } else if (['destination', 'externalDestination'].includes(this.name)) {
@@ -416,12 +416,13 @@ export class BindDirective extends BaseNode {
416
416
  let memberExpressionNode = node?.parentNode;
417
417
  while (memberExpressionNode?.concept === 'MemberExpression') {
418
418
  expressionNode = memberExpressionNode;
419
+ // 为了处理MemberExpression里面存在CallLogic、CallFunction等的情况
419
420
  const { concept: objConcept } = memberExpressionNode.object || {};
420
421
  if (!['MemberExpression', 'Identifier'].includes(objConcept)) {
421
422
  memberExpressionNode = null;
422
423
  expressionNode = null;
423
424
  } else {
424
- memberExpressionNode = memberExpressionNode.object;
425
+ memberExpressionNode = memberExpressionNode.parentNode;
425
426
  }
426
427
  }
427
428
  if (expressionNode) {
@@ -518,10 +519,11 @@ export class BindDirective extends BaseNode {
518
519
  // eslint-disable-next-line no-nested-ternary
519
520
  let value = (this.type ?? 'string') !== 'string' ? this.value : this.value ? `'${this.value}'` : '';
520
521
  // 需要用标识符替换
521
- if (options.finalCode !== false && this.needReplaceWithIdentifier) {
522
- const argsList = this.getArgsList();
523
- value = `${this.expressionBuilderName}(${argsList.join(', ')})`;
524
- } else if (this.expression) {
522
+ //if (options.finalCode !== false && this.needReplaceWithIdentifier) {
523
+ // const argsList = this.getArgsList();
524
+ // value = `${this.expressionBuilderName}(${argsList.join(', ')})`;
525
+ //} else
526
+ if (this.expression) {
525
527
  value = this.expression.toVue(options);
526
528
  if (this.expression.concept === 'StringLiteral') {
527
529
  value = `${value}`;
@@ -372,12 +372,13 @@ export class BindStyle extends BaseNode {
372
372
  let memberExpressionNode = node?.parentNode;
373
373
  while (memberExpressionNode?.concept === 'MemberExpression') {
374
374
  expressionNode = memberExpressionNode;
375
+ // 为了处理MemberExpression里面存在CallLogic、CallFunction等的情况
375
376
  const { concept: objConcept } = memberExpressionNode.object || {};
376
377
  if (!['MemberExpression', 'Identifier'].includes(objConcept)) {
377
378
  memberExpressionNode = null;
378
379
  expressionNode = null;
379
380
  } else {
380
- memberExpressionNode = memberExpressionNode.object;
381
+ memberExpressionNode = memberExpressionNode.parentNode;
381
382
  }
382
383
  }
383
384
  if (expressionNode) {
@@ -472,14 +473,14 @@ export class BindStyle extends BaseNode {
472
473
  toVue(options?: ElementToVueOptions) {
473
474
  let value: string;
474
475
  // 需要用标识符替换
475
- if (options?.finalCode !== false && this.needReplaceWithIdentifier) {
476
- const argsList = this.getArgsList();
477
- value = `${this.expressionBuilderName} (${argsList.join(', ')})`;
478
- } else {
476
+ //if (options?.finalCode !== false && this.needReplaceWithIdentifier) {
477
+ // const argsList = this.getArgsList();
478
+ // value = `${this.expressionBuilderName} (${argsList.join(', ')})`;
479
+ //} else {
479
480
  value = this.expression?.toVue(options);
480
481
  if (this.name?.endsWith('background-image') && value)
481
482
  value = `\`url(\${${value}})\``;
482
- }
483
+ //}
483
484
  return value && `'${this.name}': ${value}`;
484
485
  }
485
486
 
@@ -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
 
@@ -227,6 +209,38 @@ export class CallInterface extends LogicItem {
227
209
  // 自动生成的代码已结束。下面可以手动编写。
228
210
  //================================================================================
229
211
 
212
+ async deleteCallNode() {
213
+ // 计算之前选择的接口的引用次数
214
+ if (this.calleeKey !== '__IDENTIFIER__') {
215
+ const oldItf = this.getCallNode();
216
+ if (oldItf) {
217
+ let refCount = 0;
218
+ let isSelfRef = false;
219
+ // 选择无变化时
220
+
221
+ const refs = await oldItf.findUsage();
222
+ refs.forEach((val: any) => {
223
+ const loopFindNode = (item: any) => {
224
+ if (item.children) {
225
+ item.children.forEach((child: any) => loopFindNode(child));
226
+ } else {
227
+ refCount++;
228
+ if (item.node === this) {
229
+ isSelfRef = true;
230
+ }
231
+ }
232
+ };
233
+ loopFindNode(val);
234
+ });
235
+
236
+ // 仅被自己引用则删除
237
+ if (isSelfRef && refCount === 1) {
238
+ oldItf.delete();
239
+ }
240
+ }
241
+ }
242
+ }
243
+
230
244
  get tsCalleeNamespace() {
231
245
  if (this.calleeNamespace) {
232
246
  let tsCalleeNamespace = this.calleeNamespace;
@@ -550,7 +564,7 @@ export class CallInterface extends LogicItem {
550
564
  const node = this.getCallNode();
551
565
  let logicParam: InterfaceParam[] = [];
552
566
  const Arguments: Argument[] = [];
553
- if (node) {
567
+ if (node?.params) {
554
568
  logicParam = node.params;
555
569
  }
556
570
  if (this.arguments?.length) {
@@ -534,7 +534,7 @@ export class CallLogic extends LogicItem {
534
534
  if (typeof argIndex === 'number') {
535
535
  if (!this.arguments[argIndex]?.expression) {
536
536
  // 如果本身没有值就直接删除
537
- return this.arguments[argIndex].delete();
537
+ return this.arguments[argIndex]?.delete();
538
538
  }
539
539
  if (argIndex !== this.arguments.length - 1) {
540
540
  this.arguments[argIndex]?.moveNode({
@@ -567,7 +567,7 @@ export class CallLogic extends LogicItem {
567
567
 
568
568
  const node = this.getCallNode();
569
569
  let logicParam: Param[] = [];
570
- if (node) {
570
+ if (node?.params) {
571
571
  logicParam = node.params;
572
572
  }
573
573
  if (this.arguments?.length) {
@@ -1041,7 +1041,7 @@ export class CallLogic extends LogicItem {
1041
1041
  const node = this.getCallNode();
1042
1042
  let logicParam: Param[] = [];
1043
1043
  const Arguments: Argument[] = [];
1044
- if (node) {
1044
+ if (node?.params) {
1045
1045
  logicParam = node.params;
1046
1046
  }
1047
1047
  if (this.arguments?.length) {
@@ -1,3 +1,5 @@
1
+ import Namespace from './Namespace__';
2
+
1
3
  //================================================================================
2
4
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
3
5
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -11,8 +13,6 @@ import BaseNode from '../common/BaseNode';
11
13
  import classMap from '../common/classMap';
12
14
  import ConfigProperty from './ConfigProperty__';
13
15
  import App from './App__';
14
- import Namespace from './Namespace__';
15
- import Configuration from './Configuration__';
16
16
 
17
17
  /**
18
18
  * 配置组
@@ -94,7 +94,7 @@ export class DataSource extends BaseNode {
94
94
  });
95
95
  }
96
96
 
97
- getEntityExistingNames(excludedList: Array<Entity> = []) {
97
+ getEntityExistingNames(excludedList: Array<Entity> = []) {
98
98
  const excludedSet = new Set(excludedList);
99
99
  return ((this.entities as Entity[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
100
100
  }
@@ -235,9 +235,6 @@ export class DataSource extends BaseNode {
235
235
  return node;
236
236
  }
237
237
 
238
-
239
-
240
-
241
238
  /**
242
239
  * 删除实体
243
240
  * @param name 实体名称
@@ -422,13 +419,20 @@ export class DataSource extends BaseNode {
422
419
  if (!prop.value) {
423
420
  return;
424
421
  }
425
- const dataSource = configProperty.name;
422
+ let isRecycled = false;
423
+ try {
424
+ const value = JSON.parse(prop.value);
425
+ // 被回收的数据库不需要 Ping
426
+ if (value.dataBaseMode === 'Platform_Generation' && value.status === 1) {
427
+ isRecycled = true;
428
+ }
429
+ } catch (e) {}
426
430
  const env = prop.env;
427
- return datasourceService.pingDatabase({
431
+ return isRecycled ? Promise.resolve() : datasourceService.pingDatabase({
428
432
  body: {
429
433
  category: 'sql',
430
434
  appId: this.app.id,
431
- dataSource,
435
+ dataSource: configProperty.name,
432
436
  env,
433
437
  },
434
438
  }).then(() => {
@@ -353,7 +353,7 @@ export class Destination extends LogicItem {
353
353
  if (Array.isArray(completeArguments) && completeArguments.length) {
354
354
  const node = this.viewNode;
355
355
  let logicParam: Param[] = [];
356
- if (node) {
356
+ if (node?.params) {
357
357
  logicParam = node.params;
358
358
  }
359
359
  const logicParamLen = logicParam.length;
@@ -407,7 +407,7 @@ export class Destination extends LogicItem {
407
407
  if (completeArguments.length) {
408
408
  const node = this.viewNode;
409
409
  let logicParam: Param[] = [];
410
- if (node) {
410
+ if (node?.params) {
411
411
  logicParam = node.params;
412
412
  }
413
413
  const logicParamLength = logicParam.length;
@@ -447,7 +447,7 @@ export class Destination extends LogicItem {
447
447
  if (completeArguments.length) {
448
448
  const node = this.viewNode;
449
449
  let logicParam: Param[] = [];
450
- if (node) {
450
+ if (node?.params) {
451
451
  logicParam = node.params;
452
452
  }
453
453
  const logicParamLength = logicParam.length;
@@ -488,7 +488,7 @@ export class Destination extends LogicItem {
488
488
  if (completeArguments.length) {
489
489
  const node = this.viewNode;
490
490
  let logicParam: Param[] = [];
491
- if (node) {
491
+ if (node?.params) {
492
492
  logicParam = node.params;
493
493
  }
494
494
  const logicParamLength = logicParam.length;
@@ -599,7 +599,7 @@ export class Destination extends LogicItem {
599
599
  */
600
600
  if (typeof argIndex === 'number') {
601
601
  if (!this.arguments[argIndex]?.expression) {
602
- return this.arguments[argIndex].delete();
602
+ return this.arguments[argIndex]?.delete();
603
603
  }
604
604
  if (argIndex !== this.arguments.length - 1) {
605
605
  // 如果本身没有值就直接删除
@@ -668,7 +668,7 @@ export class Destination extends LogicItem {
668
668
 
669
669
  const node = this.viewNode;
670
670
  let logicParam: Param[] = [];
671
- if (node) {
671
+ if (node?.params) {
672
672
  logicParam = node.params;
673
673
  }
674
674
  const logicParamLength = logicParam.length;
@@ -759,7 +759,7 @@ export class Destination extends LogicItem {
759
759
  const node = this.viewNode;
760
760
  let logicParam: Param[] = [];
761
761
  const Arguments: Argument[] = [];
762
- if (node) {
762
+ if (node?.params) {
763
763
  logicParam = node.params;
764
764
  }
765
765
  if (this.arguments?.length) {
@@ -2,6 +2,7 @@ import { TranslatorState, shiftState, withSourceMap, createCompilerState } from
2
2
  import Namespace from './Namespace__';
3
3
  import TypeAnnotation from './TypeAnnotation__';
4
4
  import Structure from './Structure__';
5
+ import Param from './Param__';
5
6
  //================================================================================
6
7
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
7
8
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -133,7 +134,7 @@ export class Interface extends BaseNode {
133
134
  });
134
135
  }
135
136
 
136
- getInterfaceParamUniqueName(name = 'interfaceParam1') {
137
+ getInterfaceParamUniqueName(name = 'interfaceParam1') {
137
138
  return utils.unique(name, this.getVarExistingNames(), undefined, false);
138
139
  }
139
140
 
@@ -270,7 +271,6 @@ export class Interface extends BaseNode {
270
271
  return node;
271
272
  }
272
273
 
273
-
274
274
  getReturnUniqueName(name = 'result') {
275
275
  return utils.unique(name, this.getVarExistingNames(), undefined, false);
276
276
  }
@@ -408,9 +408,6 @@ export class Interface extends BaseNode {
408
408
  return node;
409
409
  }
410
410
 
411
-
412
-
413
-
414
411
  /**
415
412
  * 删除接口参数
416
413
  * @param name 接口参数名称
@@ -459,8 +456,6 @@ export class Interface extends BaseNode {
459
456
  return params;
460
457
  }
461
458
 
462
-
463
-
464
459
  /**
465
460
  * 删除输出参数
466
461
  * @param name 输出参数名称
@@ -514,6 +509,18 @@ export class Interface extends BaseNode {
514
509
  // 自动生成的代码已结束。下面可以手动编写。
515
510
  //================================================================================
516
511
 
512
+ /**
513
+ * 协议
514
+ */
515
+ // @property()
516
+ // protocol: string = undefined;
517
+
518
+ /**
519
+ * 协议参数列表
520
+ */
521
+ // @property('Param')
522
+ // protocolParams: Array<Param> = [];
523
+
517
524
  /**
518
525
  * 是否可编辑
519
526
  * */
@@ -545,6 +552,21 @@ export class Interface extends BaseNode {
545
552
  });
546
553
  }
547
554
 
555
+ // 更新所有调用接口
556
+ async updateAllRefCallInterface() {
557
+ const refs = await this.findUsage();
558
+ refs.forEach((val: any) => {
559
+ const loopFindNode = (item: any) => {
560
+ if (item.children) {
561
+ item.children.forEach((i: any) => loopFindNode(i));
562
+ } else {
563
+ item.node.setCallee(this);
564
+ }
565
+ };
566
+ loopFindNode(val);
567
+ });
568
+ }
569
+
548
570
  /* 删除空数据模块 */
549
571
  deleteLogincAndModule() {
550
572
  this.rootNode.emit('collect:start', {
@@ -823,6 +845,36 @@ export class Interface extends BaseNode {
823
845
  return [...this.params, ...this.returns].filter((item) => !excludedSet.has(item)).map((item) => item.name);
824
846
  }
825
847
 
848
+ // 递归找出 response/request 的 Body/Returns 引用的数据结构
849
+ getRefStructures(structures: Structure[] = []): Set<Structure> {
850
+ const structuresSet: Set<Structure> = new Set();
851
+ const loopSaveStructure = (typeAnnotation: TypeAnnotation) => {
852
+ if (!typeAnnotation)
853
+ return;
854
+ if (typeAnnotation.typeKind === 'reference') {
855
+ const targetStructure = structures.find((s) => s.name === typeAnnotation.typeName);
856
+ if (targetStructure && !structuresSet.has(targetStructure)) {
857
+ structuresSet.add(targetStructure);
858
+ targetStructure?.properties.forEach((prop) => {
859
+ loopSaveStructure(prop.typeAnnotation);
860
+ });
861
+ }
862
+ } else if (typeAnnotation.typeKind === 'generic') {
863
+ typeAnnotation.typeArguments.forEach(loopSaveStructure);
864
+ }
865
+ };
866
+
867
+ const { params = [], returns = [] } = this;
868
+ [...params, ...returns].forEach((p) => {
869
+ if ('in' in p && p.in === 'cookie') {
870
+ p.in = 'header';
871
+ return;
872
+ }
873
+ loopSaveStructure(p?.typeAnnotation);
874
+ });
875
+ return structuresSet;
876
+ }
877
+
826
878
  //================================================================================
827
879
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
828
880
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -1712,11 +1712,11 @@ export class Logic extends BaseNode {
1712
1712
  }
1713
1713
  }
1714
1714
  });
1715
- } else if (['NewList', 'NewMap'].includes(assignment.right.concept) && !(assignment.right as any).typeAnnotation) {
1715
+ } else if (['NewList', 'NewMap'].includes(assignment.right?.concept) && !(assignment.right as any)?.typeAnnotation) {
1716
1716
  const rightNode: any = assignment.right;
1717
1717
  code += ' = ';
1718
1718
  code += rightNode.getInitCode(shiftState(state, code, { inline: true }));
1719
- } else if (assignment.right.concept === 'NewComposite' && (assignment.right as any).typeAnnotation?.typeKind === 'anonymousStructure') {
1719
+ } else if (assignment.right?.concept === 'NewComposite' && (assignment.right as any)?.typeAnnotation?.typeKind === 'anonymousStructure') {
1720
1720
  const rightNode: any = assignment.right;
1721
1721
  code += ' = ';
1722
1722
  code += rightNode.getInitCode(shiftState(state, code, { inline: true }));
@@ -438,10 +438,69 @@ export class Match extends LogicItem {
438
438
  this.emit('change', $event);
439
439
  }
440
440
 
441
+
442
+ // 获取在页面中的名字
443
+ get expressionNameInView() {
444
+ const nameList: string[] = [];
445
+ let node: BaseNode = this;
446
+ while (node) {
447
+ if (node === this) {
448
+ nameList.unshift('viewMatchExpression');
449
+ } else {
450
+ nameList.unshift(node.name);
451
+ }
452
+ if (node.concept === 'ViewElement') {
453
+ node = null;
454
+ } else {
455
+ nameList.unshift(node.parentKey);
456
+ node = node.parentNode;
457
+ }
458
+ }
459
+ return nameList.join('_').replace(/-/g, '_');
460
+ }
461
+
462
+ getViewMatchExpressionBuilder() {
463
+ return `gen${this.expressionNameInView}`;
464
+ }
465
+
466
+ getInViewMethod(state?: TranslatorState) {
467
+ const viewElement = this?.getAncestor('ViewElement');
468
+ const argsList = [];
469
+ let parent = viewElement?.parentNode;
470
+ let index = 0;
471
+ while (parent && parent.concept !== 'View') {
472
+ if ((parent as ViewElement).slotScope) {
473
+ argsList.unshift(index === 0 ? 'current' : 'current' + index);
474
+ index++;
475
+ }
476
+ parent = parent.parentNode;
477
+ }
478
+
479
+ let code = '';
480
+ code += `${this.getViewMatchExpressionBuilder()} (${argsList.join(', ')}) {\n`;
481
+ code += `return ${this.toJS()}`;
482
+ code += `;\n`;
483
+ code += '}';
484
+ return code;
485
+ }
486
+
441
487
  toVue(state?: TranslatorState): string {
442
488
  if (state?.finalCode === false) {
443
489
  return this.toUI();
444
490
  } else {
491
+ const viewElement = this?.getAncestor('ViewElement');
492
+ const argsList = [];
493
+ let parent = viewElement?.parentNode;
494
+ let index = 0;
495
+ while (parent && parent.concept !== 'View') {
496
+ if ((parent as ViewElement).slotScope) {
497
+ argsList.unshift(index === 0 ? 'current' : 'current' + index);
498
+ index++;
499
+ }
500
+ parent = parent.parentNode;
501
+ }
502
+ return `${this.getViewMatchExpressionBuilder()}(${argsList.join(', ')})`;
503
+
445
504
  // let code = 'await (async () => {\n';
446
505
  // if (this.expression && Array.isArray(this.cases)) {
447
506
  // this.cases.forEach((item, index) => {
@@ -469,13 +528,29 @@ export class Match extends LogicItem {
469
528
  }
470
529
 
471
530
  toJS(state?: TranslatorState): string {
472
- let code = 'await (async () => {\n';
531
+ //let code = 'await (async () => {\n';
532
+ //if (this.expression && Array.isArray(this.cases)) {
533
+ // this.cases.forEach((item, index) => {
534
+ // code += item?.toJS?.(this.expression, index, this.cases.length);
535
+ // });
536
+ //}
537
+ //code += `})()`;
538
+ //return code;
539
+
540
+ let code = '';
541
+ // 祖先逻辑
542
+ const ancestorLogic = this.getAncestor('Logic');
543
+ if (ancestorLogic) {
544
+ code += 'await (async () => {\n';
545
+ } else {
546
+ code += '(() => {\n';
547
+ }
473
548
  if (this.expression && Array.isArray(this.cases)) {
474
549
  this.cases.forEach((item, index) => {
475
550
  code += item?.toJS?.(this.expression, index, this.cases.length);
476
551
  });
477
552
  }
478
- code += `})()`;
553
+ code += '})()';
479
554
  return code;
480
555
  }
481
556