@lcap/nasl 2.21.0-beta.2 → 2.21.0-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 (188) hide show
  1. package/out/automate/engine/operators.d.ts +2 -2
  2. package/out/automate/engine/operators.js +14 -5
  3. package/out/automate/engine/operators.js.map +1 -1
  4. package/out/common/BaseNode.d.ts +6 -0
  5. package/out/common/BaseNode.js +45 -8
  6. package/out/common/BaseNode.js.map +1 -1
  7. package/out/concepts/Abort__.d.ts +1 -1
  8. package/out/concepts/Abort__.js +3 -3
  9. package/out/concepts/Abort__.js.map +1 -1
  10. package/out/concepts/App__.d.ts +0 -2
  11. package/out/concepts/App__.js +0 -42
  12. package/out/concepts/App__.js.map +1 -1
  13. package/out/concepts/BindAttribute__.js +18 -0
  14. package/out/concepts/BindAttribute__.js.map +1 -1
  15. package/out/concepts/BindEvent__.js +21 -22
  16. package/out/concepts/BindEvent__.js.map +1 -1
  17. package/out/concepts/CallFunction__.js.map +1 -1
  18. package/out/concepts/CallQueryComponent__.js +16 -16
  19. package/out/concepts/CallQueryComponent__.js.map +1 -1
  20. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  21. package/out/concepts/DataSource__.d.ts +0 -1
  22. package/out/concepts/DataSource__.js +0 -3
  23. package/out/concepts/DataSource__.js.map +1 -1
  24. package/out/concepts/EntityProperty__.d.ts +0 -23
  25. package/out/concepts/EntityProperty__.js +0 -121
  26. package/out/concepts/EntityProperty__.js.map +1 -1
  27. package/out/concepts/InterfaceParam__.d.ts +0 -3
  28. package/out/concepts/InterfaceParam__.js +0 -64
  29. package/out/concepts/InterfaceParam__.js.map +1 -1
  30. package/out/concepts/Interface__.d.ts +0 -3
  31. package/out/concepts/Interface__.js +4 -8
  32. package/out/concepts/Interface__.js.map +1 -1
  33. package/out/concepts/Logic__.d.ts +1 -1
  34. package/out/concepts/Logic__.js +22 -42
  35. package/out/concepts/Logic__.js.map +1 -1
  36. package/out/concepts/MatchCase__.js +1 -1
  37. package/out/concepts/MatchCase__.js.map +1 -1
  38. package/out/concepts/MemberExpression__.js +1 -1
  39. package/out/concepts/MemberExpression__.js.map +1 -1
  40. package/out/concepts/Module__.d.ts +0 -12
  41. package/out/concepts/Module__.js +0 -7
  42. package/out/concepts/Module__.js.map +1 -1
  43. package/out/concepts/NewMap__.js +5 -1
  44. package/out/concepts/NewMap__.js.map +1 -1
  45. package/out/concepts/NumericLiteral__.js +9 -3
  46. package/out/concepts/NumericLiteral__.js.map +1 -1
  47. package/out/concepts/OqlQueryComponent__.d.ts +0 -1
  48. package/out/concepts/OqlQueryComponent__.js +0 -46
  49. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  50. package/out/concepts/Param__.d.ts +0 -3
  51. package/out/concepts/Param__.js +1 -67
  52. package/out/concepts/Param__.js.map +1 -1
  53. package/out/concepts/Rect__.js.map +1 -1
  54. package/out/concepts/Return__.d.ts +0 -3
  55. package/out/concepts/Return__.js +1 -67
  56. package/out/concepts/Return__.js.map +1 -1
  57. package/out/concepts/SqlQueryComponent__.d.ts +0 -1
  58. package/out/concepts/SqlQueryComponent__.js +0 -46
  59. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  60. package/out/concepts/StructureProperty__.d.ts +0 -3
  61. package/out/concepts/StructureProperty__.js +0 -65
  62. package/out/concepts/StructureProperty__.js.map +1 -1
  63. package/out/concepts/TypeAnnotation__.d.ts +1 -3
  64. package/out/concepts/TypeAnnotation__.js +12 -31
  65. package/out/concepts/TypeAnnotation__.js.map +1 -1
  66. package/out/concepts/Variable__.d.ts +0 -3
  67. package/out/concepts/Variable__.js +1 -67
  68. package/out/concepts/Variable__.js.map +1 -1
  69. package/out/concepts/ViewComponent__.d.ts +7 -0
  70. package/out/concepts/ViewComponent__.js +7 -0
  71. package/out/concepts/ViewComponent__.js.map +1 -1
  72. package/out/concepts/ViewElement__.js +1 -1
  73. package/out/concepts/ViewElement__.js.map +1 -1
  74. package/out/concepts/basics/stdlib/nasl.collection.js +2 -2
  75. package/out/concepts/basics/stdlib/nasl.collection.js.map +1 -1
  76. package/out/concepts/basics/stdlib/nasl.core.js +3 -3
  77. package/out/concepts/basics/stdlib/nasl.core.js.map +1 -1
  78. package/out/concepts/basics/stdlib/nasl.interface.js +1 -1
  79. package/out/concepts/basics/stdlib/nasl.interface.js.map +1 -1
  80. package/out/concepts/basics/stdlib/nasl.process.js +6 -6
  81. package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
  82. package/out/concepts/basics/stdlib/nasl.ui.js +43 -43
  83. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  84. package/out/concepts/basics/stdlib/nasl.util.js +19 -46
  85. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  86. package/out/concepts/basics/stdlib/nasl.validation.js +13 -13
  87. package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -1
  88. package/out/concepts/basics/types/coreTypeList.js +5 -1
  89. package/out/concepts/basics/types/coreTypeList.js.map +1 -1
  90. package/out/concepts/index__.d.ts +0 -1
  91. package/out/concepts/index__.js +0 -1
  92. package/out/concepts/index__.js.map +1 -1
  93. package/out/generator/genReleaseBody.js +0 -3
  94. package/out/generator/genReleaseBody.js.map +1 -1
  95. package/out/sentry/index.d.ts +28 -0
  96. package/out/sentry/index.js +104 -0
  97. package/out/sentry/index.js.map +1 -0
  98. package/out/server/entity2LogicNamespace.js +1 -1
  99. package/out/server/entity2LogicNamespace.js.map +1 -1
  100. package/out/server/extendBaseNode.js +65 -0
  101. package/out/server/extendBaseNode.js.map +1 -1
  102. package/out/server/formatTsUtils.js +5 -5
  103. package/out/server/formatTsUtils.js.map +1 -1
  104. package/out/server/getLogics.js +9 -7
  105. package/out/server/getLogics.js.map +1 -1
  106. package/out/server/naslServer.d.ts +2 -2
  107. package/out/server/naslServer.js +120 -51
  108. package/out/server/naslServer.js.map +1 -1
  109. package/out/server/translator.js +3 -2
  110. package/out/server/translator.js.map +1 -1
  111. package/out/service/creator/errHandles.js +5 -0
  112. package/out/service/creator/errHandles.js.map +1 -1
  113. package/out/service/storage/init.js +6 -8
  114. package/out/service/storage/init.js.map +1 -1
  115. package/out/templator/genQueryComponent.js +2 -2
  116. package/out/templator/genQueryComponent.js.map +1 -1
  117. package/out/templator/genSelectBlock.js +9 -1
  118. package/out/templator/genSelectBlock.js.map +1 -1
  119. package/out/templator/utils.d.ts +32 -0
  120. package/out/templator/utils.js +7 -7
  121. package/out/templator/utils.js.map +1 -1
  122. package/package.json +2 -2
  123. package/sandbox/stdlib/nasl.auth.ts +3 -1
  124. package/sandbox/stdlib/nasl.browser.ts +1 -1
  125. package/sandbox/stdlib/nasl.collection.ts +9 -9
  126. package/sandbox/stdlib/nasl.core.ts +100 -38
  127. package/sandbox/stdlib/nasl.interface.ts +1 -1
  128. package/sandbox/stdlib/nasl.langUtil.ts +4 -4
  129. package/sandbox/stdlib/nasl.oql.ts +156 -156
  130. package/sandbox/stdlib/nasl.process.ts +6 -6
  131. package/sandbox/stdlib/nasl.ui.ts +42 -42
  132. package/sandbox/stdlib/nasl.util.ts +45 -44
  133. package/sandbox/stdlib/nasl.validation.ts +8 -8
  134. package/src/automate/engine/operators.js +13 -5
  135. package/src/automate/upgrader/2.20.js +1 -0
  136. package/src/common/BaseNode.ts +32 -1
  137. package/src/concepts/Abort__.ts +4 -3
  138. package/src/concepts/App__.ts +2 -38
  139. package/src/concepts/BindAttribute__.ts +17 -1
  140. package/src/concepts/BindEvent__.ts +21 -21
  141. package/src/concepts/CallFunction__.ts +0 -1
  142. package/src/concepts/CallQueryComponent__.ts +16 -74
  143. package/src/concepts/ConfigPropertyValue__.ts +0 -4
  144. package/src/concepts/DataSource__.ts +0 -4
  145. package/src/concepts/EntityProperty__.ts +0 -129
  146. package/src/concepts/InterfaceParam__.ts +0 -55
  147. package/src/concepts/Interface__.ts +4 -4
  148. package/src/concepts/Logic__.ts +31 -47
  149. package/src/concepts/MatchCase__.ts +1 -1
  150. package/src/concepts/MemberExpression__.ts +1 -1
  151. package/src/concepts/Module__.ts +0 -6
  152. package/src/concepts/NewMap__.ts +5 -1
  153. package/src/concepts/NumericLiteral__.ts +9 -4
  154. package/src/concepts/OqlQueryComponent__.ts +0 -40
  155. package/src/concepts/Param__.ts +3 -59
  156. package/src/concepts/Rect__.ts +0 -8
  157. package/src/concepts/Return__.ts +1 -58
  158. package/src/concepts/SqlQueryComponent__.ts +0 -40
  159. package/src/concepts/StructureProperty__.ts +0 -57
  160. package/src/concepts/TypeAnnotation__.ts +12 -72
  161. package/src/concepts/Variable__.ts +1 -58
  162. package/src/concepts/ViewComponent__.ts +6 -0
  163. package/src/concepts/ViewElement__.ts +7 -7
  164. package/src/concepts/basics/stdlib/nasl.collection.ts +2 -2
  165. package/src/concepts/basics/stdlib/nasl.core.ts +3 -3
  166. package/src/concepts/basics/stdlib/nasl.interface.ts +1 -1
  167. package/src/concepts/basics/stdlib/nasl.process.ts +6 -6
  168. package/src/concepts/basics/stdlib/nasl.ui.ts +43 -43
  169. package/src/concepts/basics/stdlib/nasl.util.ts +19 -46
  170. package/src/concepts/basics/stdlib/nasl.validation.ts +13 -13
  171. package/src/concepts/basics/types/coreTypeList.ts +5 -1
  172. package/src/concepts/index__.ts +0 -1
  173. package/src/generator/genReleaseBody.ts +0 -2
  174. package/src/sentry/index.ts +134 -0
  175. package/src/server/entity2LogicNamespace.ts +1 -1
  176. package/src/server/extendBaseNode.ts +61 -1
  177. package/src/server/formatTsUtils.ts +5 -5
  178. package/src/server/getLogics.ts +8 -7
  179. package/src/server/naslServer.ts +120 -53
  180. package/src/server/translator.ts +3 -2
  181. package/src/service/creator/errHandles.js +6 -0
  182. package/src/service/storage/init.ts +6 -8
  183. package/src/templator/genQueryComponent.ts +5 -5
  184. package/src/templator/genSelectBlock.ts +9 -1
  185. package/src/templator/utils.ts +7 -7
  186. package/ts-worker/lib/Messager.js +0 -3
  187. package/ts-worker/src/index.js +0 -1
  188. package/src/concepts/DatabaseTypeAnnotation__.ts +0 -88
@@ -1688,12 +1688,14 @@ export class Logic extends BaseNode {
1688
1688
  Promise.all(needGetSourceMapOqlList).then(() => {
1689
1689
  // 触发一下更新重新生成代码
1690
1690
  (this.app as any)?.naslServer?.embeddedTSEmitter.emit('change', {
1691
- value: [{
1692
- originEvent: {
1693
- action: 'update',
1694
- target: this,
1691
+ value: [
1692
+ {
1693
+ originEvent: {
1694
+ action: 'update',
1695
+ target: this,
1696
+ },
1695
1697
  },
1696
- }],
1698
+ ],
1697
1699
  });
1698
1700
  });
1699
1701
  }
@@ -1705,11 +1707,13 @@ export class Logic extends BaseNode {
1705
1707
  code += '{\n';
1706
1708
 
1707
1709
  // 用于虚拟节点的查找引用
1708
- this.virtualParams && Array.isArray(this.virtualParams) && this.virtualParams.forEach((param) => {
1709
- code += indent((state?.tabSize || 0) + 1);
1710
- code += param.toEmbeddedNameTS(shiftState(state, code, { inline: true }));
1711
- code += '\n';
1712
- });
1710
+ this.virtualParams
1711
+ && Array.isArray(this.virtualParams)
1712
+ && this.virtualParams.forEach((param) => {
1713
+ code += indent((state?.tabSize || 0) + 1);
1714
+ code += param.toEmbeddedNameTS(shiftState(state, code, { inline: true }));
1715
+ code += '\n';
1716
+ });
1713
1717
 
1714
1718
  this.variables.forEach((variable) => {
1715
1719
  if (!advanceMap.get(variable)) {
@@ -1733,12 +1737,12 @@ export class Logic extends BaseNode {
1733
1737
  code += node.toEmbeddedTS(shiftState(state, code, { inline: true }));
1734
1738
  if (assignment instanceof BatchAssignment) {
1735
1739
  assignment.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1736
- const leftCode = leftIndex.length === 1 ? assignment.left.expression.toEmbeddedTS(shiftState(state, code, { inline: true })) : assignment.left.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true }));
1740
+ const leftCode
1741
+ = leftIndex.length === 1 ? assignment.left.expression.toEmbeddedTS(shiftState(state, code, { inline: true })) : assignment.left.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true }));
1737
1742
  if (leftCode === node.name) {
1738
1743
  const rightNode: any = rightIndex.length === 1 ? assignment.rights[rightIndex[0]]?.expression : assignment.rights[rightIndex[0]]?.members[rightIndex[1]];
1739
1744
  // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1740
- if (rightNode?.typeAnnotation
1741
- && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
1745
+ if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
1742
1746
  code += ': ';
1743
1747
  code += rightNode.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) || 'null';
1744
1748
  } else {
@@ -1759,8 +1763,7 @@ export class Logic extends BaseNode {
1759
1763
  } else {
1760
1764
  const rightNode: any = assignment.right;
1761
1765
  // 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
1762
- if (rightNode?.typeAnnotation
1763
- && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
1766
+ if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
1764
1767
  code += ': ';
1765
1768
  code += rightNode.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) || 'null';
1766
1769
  } else {
@@ -1770,7 +1773,7 @@ export class Logic extends BaseNode {
1770
1773
  if (rightNode && rightNode instanceof Identifier && rightNode.namespace && rightNode.namespace.endsWith('enums')) {
1771
1774
  rightCode += 'new ';
1772
1775
  }
1773
- rightCode += (rightNode && rightNode.toEmbeddedTS) ? rightNode.toEmbeddedTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
1776
+ rightCode += rightNode && rightNode.toEmbeddedTS ? rightNode.toEmbeddedTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
1774
1777
  code += this.getRightCode(rightCode, assignment, rightNode);
1775
1778
  }
1776
1779
  }
@@ -1871,7 +1874,7 @@ export class Logic extends BaseNode {
1871
1874
  code = this.handleReplaceCode(code, item.name, eachTSCode === '__IDENTIFIER__' ? eachTSCode : `${eachTSCode}.__get(0)`);
1872
1875
  }
1873
1876
  if (code.includes(index.name))
1874
- code = this.handleReplaceCode(code, index.name, 'new nasl.core.Long(0)');
1877
+ code = this.handleReplaceCode(code, index.name, 'new nasl.core.Integer(0)');
1875
1878
 
1876
1879
  const parentForEachStatement = forEachStatement.getAncestor('ForEachStatement') as ForEachStatement;
1877
1880
  if (parentForEachStatement) {
@@ -1915,7 +1918,10 @@ export class Logic extends BaseNode {
1915
1918
  arr.push(parentName);
1916
1919
  }
1917
1920
  let namespace = arr.join('.');
1918
- if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace) && !namespace.includes('.logics')) {
1921
+ if (
1922
+ !['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace)
1923
+ && !namespace.includes('.logics')
1924
+ ) {
1919
1925
  namespace = `${namespace}.logics`;
1920
1926
  }
1921
1927
  return namespace;
@@ -1932,7 +1938,10 @@ export class Logic extends BaseNode {
1932
1938
  arr.push(parentName);
1933
1939
  }
1934
1940
  let namespace = arr.join('.');
1935
- if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace) && !namespace.includes('.logics')) {
1941
+ if (
1942
+ !['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace)
1943
+ && !namespace.includes('.logics')
1944
+ ) {
1936
1945
  namespace = `${namespace}.logics`;
1937
1946
  }
1938
1947
  return namespace;
@@ -2075,34 +2084,9 @@ export class Logic extends BaseNode {
2075
2084
  // 虚拟输入参数列表
2076
2085
  virtualParams: Array<Param> = [];
2077
2086
 
2078
- /* 零时用 需要删除*/
2079
- addParamsFunction() {
2080
- this.addParam({
2081
- name: 'param5',
2082
- typeAnnotation: TypeAnnotation.from({
2083
- typeKind: 'function',
2084
- typeName: 'String',
2085
- typeNamespace: 'nasl.core',
2086
- returnType: [TypeAnnotation.from({
2087
- typeKind: 'primitive',
2088
- typeName: 'Boolean',
2089
- typeNamespace: 'nasl.core',
2090
- })],
2091
- typeArguments: [
2092
- TypeAnnotation.from({
2093
- typeKind: 'primitive',
2094
- typeName: 'String',
2095
- typeNamespace: 'nasl.core',
2096
- }),
2097
- TypeAnnotation.from({
2098
- typeKind: 'primitive',
2099
- typeName: 'Boolean',
2100
- typeNamespace: 'nasl.core',
2101
- }),
2102
- ],
2103
- }),
2104
-
2105
- });
2087
+ get getLogicBelongTo() {
2088
+ const [, belongTo] = this.calleewholeKey.split('.');
2089
+ return belongTo;
2106
2090
  }
2107
2091
 
2108
2092
  // 校验logic的返回值是不是有error类型
@@ -716,7 +716,7 @@ export class MatchCase extends LogicItem {
716
716
  }
717
717
  if (Array.isArray(this.body)) {
718
718
  this.body.forEach((logicItem, bodyIndex) => {
719
- if (this.parentNode.isExpression && bodyIndex === this.body.length - 1) {
719
+ if (this.parentNode.isExpression && bodyIndex === this.body.length - 1 && logicItem.concept !== 'Abort') {
720
720
  code += `return `;
721
721
  }
722
722
  code += logicItem.toJS() + '\n';
@@ -251,7 +251,7 @@ export class MemberExpression extends LogicItem {
251
251
  }
252
252
 
253
253
  isEnum() {
254
- return (this.object as Identifier)?.isEnum();
254
+ return (this.object as Identifier)?.isEnum?.();
255
255
  }
256
256
  // 方便快速取值,遍历获取value
257
257
  getValue() {
@@ -81,12 +81,6 @@ export class Module extends BaseNode {
81
81
  @property()
82
82
  externalDependencyMap: { maven?: Array<{ groupId: string, artifactId: string, version: string }> } = undefined;
83
83
 
84
- /**
85
- * 外部语言依赖
86
- */
87
- @property()
88
- compilerInfoMap: { java?: Array<{ packageName: string,className:string,naslName: string, type: string,javaTypes:any }> } = undefined;
89
-
90
84
  /**
91
85
  * 数据源列表
92
86
  */
@@ -633,8 +633,12 @@ export class NewMap extends LogicItem {
633
633
  code += key.toEmbeddedTS(shiftState(state, code, { inline: true }));
634
634
  code += ');\n';
635
635
  });
636
+ if (keyIndex !== -1) {
637
+ code += `nasl.util.ValidMapKey(`;
638
+ code += `${this.keys[keyIndex].toEmbeddedTS(shiftState(state, code, { inline: true }))});\n`;
639
+ }
636
640
  code += `return nasl.util.NewMap(`;
637
- code += `${keyIndex === -1 ? 'null' : this.keys[keyIndex].toEmbeddedTS(shiftState(state, code, { inline: true }))}, ...[`;
641
+ code += `${keyIndex === -1 ? 'null' : keyTs}, ...[`;
638
642
  valueTsArr.forEach((ts: any, index: number) => {
639
643
  code += ['__IDENTIFIER__', '__IDENTIFIER__()'].includes(ts) ? null : ts;
640
644
  if (index + 1 < this.values.length)
@@ -131,7 +131,7 @@ export class NumericLiteral extends LogicItem {
131
131
  return code;
132
132
  }
133
133
  toBrief(): string {
134
- return `${this.value}`;
134
+ return `${this.value}`
135
135
  }
136
136
 
137
137
  @withSourceMap()
@@ -143,9 +143,14 @@ export class NumericLiteral extends LogicItem {
143
143
 
144
144
  changeType(value: string | number) {
145
145
  const newValue = value.toString();
146
- let typeName = 'Long';
146
+ let typeName = 'Integer';
147
+ if (newValue.length > 8) {
148
+ typeName = 'Long';
149
+ } else {
150
+ typeName = 'Integer';
151
+ }
147
152
  if (newValue.includes('.')) {
148
- typeName = 'Decimal';
153
+ typeName = 'Double';
149
154
  }
150
155
  return typeName;
151
156
  }
@@ -178,7 +183,7 @@ export class NumericLiteral extends LogicItem {
178
183
  value: '0',
179
184
  typeAnnotation: new TypeAnnotation({
180
185
  typeNamespace: 'nasl.core',
181
- typeName: 'Long',
186
+ typeName: 'Integer',
182
187
  typeKind: 'primitive',
183
188
  }),
184
189
  };
@@ -232,46 +232,6 @@ export class OqlQueryComponent extends LogicItem {
232
232
  return sqlTypeBan;
233
233
  }
234
234
 
235
- getSelectRef(newTypeAnnotation: TypeAnnotation) {
236
- try {
237
- const { typeName, typeKind, typeNamespace } = newTypeAnnotation || this.typeAnnotation;
238
- let completionChildren;
239
- if (typeKind === 'reference') {
240
- if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process') {
241
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
242
- const properties = (node as Structure)?.properties || [];
243
- completionChildren = properties;
244
- } else if (typeNamespace.endsWith('.enums')) {
245
- completionChildren = [];
246
- } else {
247
- const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
248
- const properties = node?.properties || [];
249
- completionChildren = properties;
250
- }
251
- } else if (typeKind === 'generic') {
252
- // if (typeNamespace === 'nasl.collection' || typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.interface') {
253
- // }
254
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
255
- const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
256
- for (let i = 0; i < properties.length; i++) {
257
- const item = properties[i];
258
- if (item?.typeAnnotation?.typeKind === 'typeParam') {
259
- const newItem = StructureProperty.from(item.toJSON());
260
- newItem.typeAnnotation = this?.typeAnnotation?.typeArguments[0];
261
- newItem.parentNode = this;
262
- properties[i] = newItem;
263
- }
264
- }
265
- completionChildren = properties;
266
- } else {
267
- completionChildren = [];
268
- }
269
- return completionChildren;
270
- } catch (err) {
271
- console.log(err);
272
- }
273
- }
274
-
275
235
  @withSourceMap()
276
236
  toEmbeddedTS(state?: TranslatorState): string {
277
237
  let code: string;
@@ -4,7 +4,6 @@ import LogicItem from './LogicItem__';
4
4
  import EntityProperty from './EntityProperty__';
5
5
  import Structure from './Structure__';
6
6
  import StructureProperty from './StructureProperty__';
7
- import { getNodeByNodeCallee, getNaslNodeByNodeCallee } from '../automate/engine/utils';
8
7
  import Function from './Function__';
9
8
  import AnonymousFunction from './AnonymousFunction__';
10
9
 
@@ -396,7 +395,7 @@ export class Param extends BaseNode {
396
395
  object.defaultValue = '';
397
396
  }
398
397
  try {
399
- this.completionChildren = this.getSelectRef(typeAnnotation);
398
+ this.completionChildren = this.getSelectRef(typeAnnotation, true);
400
399
  } catch (err) {
401
400
  this.completionChildren = [];
402
401
  console.log(err);
@@ -431,63 +430,8 @@ export class Param extends BaseNode {
431
430
  set readonly(val) {
432
431
  this._readonly = val;
433
432
  }
434
- get hasChildren() {
435
- const { typeKind, typeNamespace, typeName } = this.typeAnnotation;
436
- if (typeKind === 'reference' || typeKind === 'generic') {
437
- if (typeNamespace.endsWith('.enums'))
438
- return null;
439
- return [{}];
440
- } else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
441
- return [{}];
442
- }
443
- return null;
444
- }
445
- get isTreeLeaf() {
446
- return !this.hasChildren;
447
- }
448
- getSelectRef(newTypeAnnotation: TypeAnnotation) {
449
- try {
450
- const { typeName, typeKind, typeNamespace, sortedTypeKey } = newTypeAnnotation || this.typeAnnotation;
451
- let completionChildren;
452
- if (typeKind === 'reference') {
453
- if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process' || typeNamespace === 'nasl.auth') {
454
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
455
- const properties = (node as Structure)?.properties || [];
456
- completionChildren = properties;
457
- } else if (typeNamespace.endsWith('.enums')) {
458
- completionChildren = [];
459
- } else {
460
- const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
461
- const properties = node?.properties || [];
462
- completionChildren = properties;
463
- }
464
- } else if (typeKind === 'generic') {
465
- // if (typeNamespace === 'nasl.collection' || typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.interface') {
466
- // }
467
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
468
- const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
469
- for (let i = 0; i < properties.length; i++) {
470
- const item = properties[i];
471
- if (item?.typeAnnotation?.typeKind === 'typeParam') {
472
- const newItem = StructureProperty.from(item.toJSON());
473
- newItem.typeAnnotation = this?.typeAnnotation?.typeArguments[0];
474
- newItem.parentNode = this;
475
- properties[i] = newItem;
476
- }
477
- }
478
- completionChildren = properties;
479
- } else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
480
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
481
- const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
482
- completionChildren = properties;
483
- } else {
484
- completionChildren = [];
485
- }
486
- return completionChildren;
487
- } catch (err) {
488
- console.log(err);
489
- }
490
- }
433
+
434
+
491
435
 
492
436
  setnNewTypeAnnotation(oldTypeAnnotation: TypeAnnotation) {
493
437
  const json = oldTypeAnnotation.toJSON();
@@ -10,7 +10,6 @@ import { v4 as uuidv4 } from 'uuid';
10
10
  import BaseNode from '../common/BaseNode';
11
11
  import classMap from '../common/classMap';
12
12
 
13
-
14
13
  /**
15
14
  * 矩形信息
16
15
  */
@@ -46,8 +45,6 @@ export class Rect extends BaseNode {
46
45
  @property()
47
46
  height: number = undefined;
48
47
 
49
-
50
-
51
48
  /**
52
49
  * @param source 需要合并的部分参数
53
50
  */
@@ -75,11 +72,6 @@ export class Rect extends BaseNode {
75
72
  }
76
73
  return params;
77
74
  }
78
-
79
-
80
-
81
-
82
-
83
75
 
84
76
  //================================================================================
85
77
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
@@ -343,7 +343,7 @@ export class Return extends BaseNode {
343
343
  }
344
344
  // 处理下拉属性
345
345
  try {
346
- this.completionChildren = this.getSelectRef(typeAnnotation);
346
+ this.completionChildren = this.getSelectRef(typeAnnotation, true);
347
347
  } catch (err) {
348
348
  this.completionChildren = [];
349
349
  console.log(err);
@@ -374,63 +374,6 @@ export class Return extends BaseNode {
374
374
  get readonly() {
375
375
  return !!this.module;
376
376
  }
377
- get hasChildren() {
378
- if (!this.typeAnnotation)
379
- return null;
380
- const { typeKind, typeNamespace, typeName } = this.typeAnnotation;
381
- if (typeKind === 'reference' || typeKind === 'generic') {
382
- if (typeNamespace.endsWith('.enums'))
383
- return null;
384
- return [{}];
385
- } else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
386
- return [{}];
387
- }
388
- return null;
389
- }
390
- get isTreeLeaf() {
391
- return !this.hasChildren;
392
- }
393
- getSelectRef(newTypeAnnotation: TypeAnnotation) {
394
- try {
395
- const { typeName, typeKind, typeNamespace, sortedTypeKey } = newTypeAnnotation || this.typeAnnotation;
396
- let completionChildren;
397
- if (typeKind === 'reference') {
398
- if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process' || typeNamespace === 'nasl.auth') {
399
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
400
- const properties = (node as Structure)?.properties || [];
401
- completionChildren = properties;
402
- } else if (typeNamespace.endsWith('.enums')) {
403
- completionChildren = [];
404
- } else {
405
- const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
406
- const properties = node?.properties || [];
407
- completionChildren = properties;
408
- }
409
- } else if (typeKind === 'generic') {
410
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
411
- const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
412
- for (let i = 0; i < properties.length; i++) {
413
- const item = properties[i];
414
- if (item?.typeAnnotation?.typeKind === 'typeParam') {
415
- const newItem = StructureProperty.from(item.toJSON());
416
- newItem.typeAnnotation = this?.typeAnnotation?.typeArguments[0];
417
- newItem.parentNode = this;
418
- properties[i] = newItem;
419
- }
420
- }
421
- completionChildren = properties;
422
- } else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
423
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
424
- const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
425
- completionChildren = properties;
426
- } else {
427
- completionChildren = [];
428
- }
429
- return completionChildren;
430
- } catch (err) {
431
- console.log(err);
432
- }
433
- }
434
377
  //================================================================================
435
378
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
436
379
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -232,46 +232,6 @@ export class SqlQueryComponent extends LogicItem {
232
232
  return sqlTypeBan;
233
233
  }
234
234
 
235
- getSelectRef(newTypeAnnotation: TypeAnnotation) {
236
- try {
237
- const { typeName, typeKind, typeNamespace } = newTypeAnnotation || this.typeAnnotation;
238
- let completionChildren;
239
- if (typeKind === 'reference') {
240
- if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process') {
241
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
242
- const properties = (node as Structure)?.properties || [];
243
- completionChildren = properties;
244
- } else if (typeNamespace.endsWith('.enums')) {
245
- completionChildren = [];
246
- } else {
247
- const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
248
- const properties = node?.properties || [];
249
- completionChildren = properties;
250
- }
251
- } else if (typeKind === 'generic') {
252
- // if (typeNamespace === 'nasl.collection' || typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.interface') {
253
- // }
254
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
255
- const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
256
- for (let i = 0; i < properties.length; i++) {
257
- const item = properties[i];
258
- if (item?.typeAnnotation?.typeKind === 'typeParam') {
259
- const newItem = StructureProperty.from(item.toJSON());
260
- newItem.typeAnnotation = this?.typeAnnotation?.typeArguments[0];
261
- newItem.parentNode = this;
262
- properties[i] = newItem;
263
- }
264
- }
265
- completionChildren = properties;
266
- } else {
267
- completionChildren = [];
268
- }
269
- return completionChildren;
270
- } catch (err) {
271
- console.log(err);
272
- }
273
- }
274
-
275
235
  @withSourceMap()
276
236
  toEmbeddedTS(state?: TranslatorState): string {
277
237
  let code: string;
@@ -246,69 +246,12 @@ export class StructureProperty extends BaseNode {
246
246
  // 自动生成的代码已结束。下面可以手动编写。
247
247
  //================================================================================
248
248
 
249
- get hasChildren() {
250
- const { typeKind, typeName, typeNamespace } = this.typeAnnotation;
251
- if (typeKind === 'reference' || typeKind === 'generic') {
252
- if (typeNamespace.endsWith('.enums'))
253
- return null;
254
- return [{}];
255
- } else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
256
- return [{}];
257
- }
258
- return null;
259
- }
260
- get isTreeLeaf() {
261
- return !this.hasChildren;
262
- }
263
249
  /**
264
250
  * 是否展开
265
251
  */
266
252
  @property()
267
253
  isLeaf: boolean = true;
268
254
 
269
- getSelectRef() {
270
- try {
271
- const { typeName, typeKind, typeNamespace } = this.typeAnnotation;
272
- let completionChildren;
273
- if (typeKind === 'reference') {
274
- if (typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.process' || typeNamespace === 'nasl.auth') {
275
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
276
- const properties = (node as Structure)?.properties || [];
277
- completionChildren = properties;
278
- } else if (typeNamespace.endsWith('.enums')) {
279
- completionChildren = [];
280
- } else {
281
- const node = getNodeByNodeCallee(this.app, typeNamespace + '.' + typeName);
282
- const properties = node?.properties || [];
283
- completionChildren = properties;
284
- }
285
- } else if (typeKind === 'generic') {
286
- // if (typeNamespace === 'nasl.collection' || typeNamespace === 'nasl.ui' || typeNamespace === 'nasl.interface') {
287
- // }
288
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
289
- const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
290
- for (let i = 0; i < properties.length; i++) {
291
- const item = properties[i];
292
- if (item?.typeAnnotation?.typeKind === 'typeParam') {
293
- const newItem = StructureProperty.from(item.toJSON());
294
- newItem.typeAnnotation = this?.typeAnnotation?.typeArguments[0];
295
- newItem.parentNode = this;
296
- properties[i] = newItem;
297
- }
298
- }
299
- completionChildren = properties;
300
- } else if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
301
- const node = getNaslNodeByNodeCallee(typeNamespace, typeName);
302
- const properties = ((node as Structure)?.properties && [...(node as Structure)?.properties]) || [];
303
- completionChildren = properties;
304
- } else {
305
- completionChildren = [];
306
- }
307
- return completionChildren;
308
- } catch (err) {
309
- console.log(err);
310
- }
311
- }
312
255
 
313
256
  @withSourceMap()
314
257
  toEmbeddedTS(state?: TranslatorState): string {