@lcap/nasl 3.5.0-beta.3 → 3.5.0-beta.5

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 (289) hide show
  1. package/out/breakpoint/store/core.js +1 -1
  2. package/out/breakpoint/store/core.js.map +1 -1
  3. package/out/common/BaseNode.d.ts +7 -0
  4. package/out/common/BaseNode.js +15 -2
  5. package/out/common/BaseNode.js.map +1 -1
  6. package/out/concepts/AnonymousFunction__.d.ts +1 -0
  7. package/out/concepts/AnonymousFunction__.js +34 -16
  8. package/out/concepts/AnonymousFunction__.js.map +1 -1
  9. package/out/concepts/Argument__.d.ts +1 -0
  10. package/out/concepts/Argument__.js +28 -8
  11. package/out/concepts/Argument__.js.map +1 -1
  12. package/out/concepts/Assignment__.js +5 -7
  13. package/out/concepts/Assignment__.js.map +1 -1
  14. package/out/concepts/BatchAssignment__.js +5 -3
  15. package/out/concepts/BatchAssignment__.js.map +1 -1
  16. package/out/concepts/BinaryExpression__.d.ts +1 -0
  17. package/out/concepts/BinaryExpression__.js +30 -13
  18. package/out/concepts/BinaryExpression__.js.map +1 -1
  19. package/out/concepts/BindAttribute__.js +11 -3
  20. package/out/concepts/BindAttribute__.js.map +1 -1
  21. package/out/concepts/BindDirective__.js +3 -3
  22. package/out/concepts/BindDirective__.js.map +1 -1
  23. package/out/concepts/BindEvent__.js +2 -2
  24. package/out/concepts/BindEvent__.js.map +1 -1
  25. package/out/concepts/BooleanLiteral__.d.ts +1 -0
  26. package/out/concepts/BooleanLiteral__.js +6 -0
  27. package/out/concepts/BooleanLiteral__.js.map +1 -1
  28. package/out/concepts/BusinessComponent__.d.ts +4 -2
  29. package/out/concepts/BusinessComponent__.js +128 -89
  30. package/out/concepts/BusinessComponent__.js.map +1 -1
  31. package/out/concepts/CallConnector__.d.ts +1 -0
  32. package/out/concepts/CallConnector__.js +6 -0
  33. package/out/concepts/CallConnector__.js.map +1 -1
  34. package/out/concepts/CallEvent__.d.ts +4 -0
  35. package/out/concepts/CallEvent__.js +19 -2
  36. package/out/concepts/CallEvent__.js.map +1 -1
  37. package/out/concepts/CallFunction__.d.ts +1 -0
  38. package/out/concepts/CallFunction__.js +62 -8
  39. package/out/concepts/CallFunction__.js.map +1 -1
  40. package/out/concepts/CallInterface__.js +31 -22
  41. package/out/concepts/CallInterface__.js.map +1 -1
  42. package/out/concepts/CallLogic__.js +49 -38
  43. package/out/concepts/CallLogic__.js.map +1 -1
  44. package/out/concepts/CallQueryComponent__.d.ts +2 -0
  45. package/out/concepts/CallQueryComponent__.js +94 -8
  46. package/out/concepts/CallQueryComponent__.js.map +1 -1
  47. package/out/concepts/DefaultValue__.d.ts +1 -0
  48. package/out/concepts/DefaultValue__.js +7 -1
  49. package/out/concepts/DefaultValue__.js.map +1 -1
  50. package/out/concepts/Destination__.d.ts +1 -1
  51. package/out/concepts/Destination__.js +34 -22
  52. package/out/concepts/Destination__.js.map +1 -1
  53. package/out/concepts/EntityProperty__.d.ts +1 -0
  54. package/out/concepts/EntityProperty__.js +26 -2
  55. package/out/concepts/EntityProperty__.js.map +1 -1
  56. package/out/concepts/Entity__.d.ts +1 -0
  57. package/out/concepts/Entity__.js +25 -0
  58. package/out/concepts/Entity__.js.map +1 -1
  59. package/out/concepts/EnumItem__.d.ts +1 -0
  60. package/out/concepts/EnumItem__.js +12 -0
  61. package/out/concepts/EnumItem__.js.map +1 -1
  62. package/out/concepts/Enum__.d.ts +1 -0
  63. package/out/concepts/Enum__.js +16 -2
  64. package/out/concepts/Enum__.js.map +1 -1
  65. package/out/concepts/Event__.d.ts +4 -0
  66. package/out/concepts/Event__.js +12 -0
  67. package/out/concepts/Event__.js.map +1 -1
  68. package/out/concepts/ForEachStatement__.js +10 -16
  69. package/out/concepts/ForEachStatement__.js.map +1 -1
  70. package/out/concepts/FrontendType__.js +1 -0
  71. package/out/concepts/FrontendType__.js.map +1 -1
  72. package/out/concepts/Identifier__.d.ts +2 -0
  73. package/out/concepts/Identifier__.js +21 -0
  74. package/out/concepts/Identifier__.js.map +1 -1
  75. package/out/concepts/JSBlock__.js +1 -1
  76. package/out/concepts/JSBlock__.js.map +1 -1
  77. package/out/concepts/LogicItem__.d.ts +6 -0
  78. package/out/concepts/LogicItem__.js +11 -1
  79. package/out/concepts/LogicItem__.js.map +1 -1
  80. package/out/concepts/Logic__.js +24 -23
  81. package/out/concepts/Logic__.js.map +1 -1
  82. package/out/concepts/MatchCase__.js +5 -5
  83. package/out/concepts/MatchCase__.js.map +1 -1
  84. package/out/concepts/Match__.js +1 -1
  85. package/out/concepts/Match__.js.map +1 -1
  86. package/out/concepts/MemberExpression__.d.ts +1 -0
  87. package/out/concepts/MemberExpression__.js +13 -3
  88. package/out/concepts/MemberExpression__.js.map +1 -1
  89. package/out/concepts/NewComposite__.js +3 -3
  90. package/out/concepts/NewComposite__.js.map +1 -1
  91. package/out/concepts/NewList__.js +4 -4
  92. package/out/concepts/NewList__.js.map +1 -1
  93. package/out/concepts/NewMap__.d.ts +1 -1
  94. package/out/concepts/NewMap__.js +6 -5
  95. package/out/concepts/NewMap__.js.map +1 -1
  96. package/out/concepts/NullLiteral__.d.ts +2 -0
  97. package/out/concepts/NullLiteral__.js +12 -0
  98. package/out/concepts/NullLiteral__.js.map +1 -1
  99. package/out/concepts/NumericLiteral__.d.ts +1 -0
  100. package/out/concepts/NumericLiteral__.js +7 -1
  101. package/out/concepts/NumericLiteral__.js.map +1 -1
  102. package/out/concepts/OqlQueryComponent__.js +4 -2
  103. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  104. package/out/concepts/Param__.d.ts +1 -0
  105. package/out/concepts/Param__.js +41 -0
  106. package/out/concepts/Param__.js.map +1 -1
  107. package/out/concepts/ProcessElement__.js +9 -1
  108. package/out/concepts/ProcessElement__.js.map +1 -1
  109. package/out/concepts/QueryAggregateExpression__.d.ts +2 -0
  110. package/out/concepts/QueryAggregateExpression__.js +16 -0
  111. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  112. package/out/concepts/QueryFieldExpression__.d.ts +2 -0
  113. package/out/concepts/QueryFieldExpression__.js +33 -0
  114. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  115. package/out/concepts/QueryFromExpression__.d.ts +2 -0
  116. package/out/concepts/QueryFromExpression__.js +27 -0
  117. package/out/concepts/QueryFromExpression__.js.map +1 -1
  118. package/out/concepts/QueryGroupByExpression__.d.ts +2 -0
  119. package/out/concepts/QueryGroupByExpression__.js +13 -1
  120. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  121. package/out/concepts/QueryJoinExpression__.d.ts +2 -0
  122. package/out/concepts/QueryJoinExpression__.js +37 -0
  123. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  124. package/out/concepts/QueryLimitExpression__.d.ts +2 -0
  125. package/out/concepts/QueryLimitExpression__.js +16 -0
  126. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  127. package/out/concepts/QueryOrderByExpression__.d.ts +2 -0
  128. package/out/concepts/QueryOrderByExpression__.js +22 -0
  129. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  130. package/out/concepts/QuerySelectExpression__.d.ts +3 -0
  131. package/out/concepts/QuerySelectExpression__.js +41 -0
  132. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  133. package/out/concepts/SelectMembers__.d.ts +1 -0
  134. package/out/concepts/SelectMembers__.js +7 -0
  135. package/out/concepts/SelectMembers__.js.map +1 -1
  136. package/out/concepts/SqlQueryComponent__.js +4 -2
  137. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  138. package/out/concepts/StringInterpolation__.d.ts +1 -0
  139. package/out/concepts/StringInterpolation__.js +20 -2
  140. package/out/concepts/StringInterpolation__.js.map +1 -1
  141. package/out/concepts/StringLiteral__.d.ts +1 -0
  142. package/out/concepts/StringLiteral__.js +21 -1
  143. package/out/concepts/StringLiteral__.js.map +1 -1
  144. package/out/concepts/StructureProperty__.d.ts +1 -0
  145. package/out/concepts/StructureProperty__.js +19 -0
  146. package/out/concepts/StructureProperty__.js.map +1 -1
  147. package/out/concepts/Structure__.d.ts +1 -0
  148. package/out/concepts/Structure__.js +22 -7
  149. package/out/concepts/Structure__.js.map +1 -1
  150. package/out/concepts/SwitchCase__.js +1 -1
  151. package/out/concepts/SwitchCase__.js.map +1 -1
  152. package/out/concepts/TypeAnnotation__.d.ts +1 -0
  153. package/out/concepts/TypeAnnotation__.js +42 -1
  154. package/out/concepts/TypeAnnotation__.js.map +1 -1
  155. package/out/concepts/TypeParam__.d.ts +2 -1
  156. package/out/concepts/TypeParam__.js +7 -1
  157. package/out/concepts/TypeParam__.js.map +1 -1
  158. package/out/concepts/Unparsed__.js +1 -1
  159. package/out/concepts/Unparsed__.js.map +1 -1
  160. package/out/concepts/ValidationRule__.js +2 -1
  161. package/out/concepts/ValidationRule__.js.map +1 -1
  162. package/out/concepts/ViewElement__.d.ts +1 -0
  163. package/out/concepts/ViewElement__.js +72 -59
  164. package/out/concepts/ViewElement__.js.map +1 -1
  165. package/out/concepts/View__.d.ts +2 -1
  166. package/out/concepts/View__.js +6 -19
  167. package/out/concepts/View__.js.map +1 -1
  168. package/out/generator/genBundleFiles.d.ts +1 -0
  169. package/out/generator/genBundleFiles.js +4 -1
  170. package/out/generator/genBundleFiles.js.map +1 -1
  171. package/out/natural/genNaturalTS.d.ts +4 -1
  172. package/out/natural/genNaturalTS.js +38 -1
  173. package/out/natural/genNaturalTS.js.map +1 -1
  174. package/out/natural/transformTSCode.js +52 -41
  175. package/out/natural/transformTSCode.js.map +1 -1
  176. package/out/server/formatTsUtils.js +10 -9
  177. package/out/server/formatTsUtils.js.map +1 -1
  178. package/out/server/getFunctions.js +3 -3
  179. package/out/server/getFunctions.js.map +1 -1
  180. package/out/server/getProcesses.js +3 -3
  181. package/out/server/getProcesses.js.map +1 -1
  182. package/out/server/naslServer.js +52 -17
  183. package/out/server/naslServer.js.map +1 -1
  184. package/out/server/translator.js +8 -0
  185. package/out/server/translator.js.map +1 -1
  186. package/out/templator/genCurdEditMultipleKeyBlock.js +1 -1
  187. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  188. package/out/templator/genGetBlock.js +2 -1
  189. package/out/templator/genGetBlock.js.map +1 -1
  190. package/out/templator/genUpdateBlock.js +2 -1
  191. package/out/templator/genUpdateBlock.js.map +1 -1
  192. package/out/templator/utils.js +3 -3
  193. package/out/templator/utils.js.map +1 -1
  194. package/out/translator/types.d.ts +2 -0
  195. package/out/translator/utils.d.ts +2 -1
  196. package/out/translator/utils.js +44 -7
  197. package/out/translator/utils.js.map +1 -1
  198. package/out/utils/string.js +2 -2
  199. package/out/utils/string.js.map +1 -1
  200. package/out/utils/time-slicing/performance.js +3 -3
  201. package/out/utils/time-slicing/performance.js.map +1 -1
  202. package/package.json +2 -2
  203. package/src/breakpoint/store/core.ts +1 -1
  204. package/src/common/BaseNode.ts +17 -3
  205. package/src/concepts/AnonymousFunction__.ts +24 -9
  206. package/src/concepts/Argument__.ts +28 -6
  207. package/src/concepts/Assignment__.ts +5 -7
  208. package/src/concepts/BatchAssignment__.ts +6 -3
  209. package/src/concepts/BinaryExpression__.ts +30 -13
  210. package/src/concepts/BindAttribute__.ts +10 -3
  211. package/src/concepts/BindDirective__.ts +3 -3
  212. package/src/concepts/BindEvent__.ts +2 -2
  213. package/src/concepts/BooleanLiteral__.ts +5 -0
  214. package/src/concepts/BusinessComponent__.ts +144 -100
  215. package/src/concepts/CallConnector__.ts +5 -0
  216. package/src/concepts/CallEvent__.ts +20 -3
  217. package/src/concepts/CallFunction__.ts +54 -8
  218. package/src/concepts/CallInterface__.ts +31 -24
  219. package/src/concepts/CallLogic__.ts +48 -37
  220. package/src/concepts/CallQueryComponent__.ts +101 -8
  221. package/src/concepts/DefaultValue__.ts +6 -1
  222. package/src/concepts/Destination__.ts +32 -22
  223. package/src/concepts/EntityProperty__.ts +30 -2
  224. package/src/concepts/Entity__.ts +29 -0
  225. package/src/concepts/EnumItem__.ts +17 -0
  226. package/src/concepts/Enum__.ts +19 -2
  227. package/src/concepts/Event__.ts +13 -0
  228. package/src/concepts/ForEachStatement__.ts +10 -20
  229. package/src/concepts/FrontendType__.ts +1 -0
  230. package/src/concepts/Identifier__.ts +19 -0
  231. package/src/concepts/JSBlock__.ts +1 -1
  232. package/src/concepts/LogicItem__.ts +13 -1
  233. package/src/concepts/Logic__.ts +24 -24
  234. package/src/concepts/MatchCase__.ts +5 -5
  235. package/src/concepts/Match__.ts +1 -1
  236. package/src/concepts/MemberExpression__.ts +12 -3
  237. package/src/concepts/NewComposite__.ts +7 -9
  238. package/src/concepts/NewList__.ts +4 -4
  239. package/src/concepts/NewMap__.ts +6 -5
  240. package/src/concepts/NullLiteral__.ts +10 -0
  241. package/src/concepts/NumericLiteral__.ts +6 -1
  242. package/src/concepts/OqlQueryComponent__.ts +4 -2
  243. package/src/concepts/Param__.ts +39 -0
  244. package/src/concepts/ProcessElement__.ts +8 -1
  245. package/src/concepts/QueryAggregateExpression__.ts +15 -0
  246. package/src/concepts/QueryFieldExpression__.ts +34 -0
  247. package/src/concepts/QueryFromExpression__.ts +29 -0
  248. package/src/concepts/QueryGroupByExpression__.ts +11 -1
  249. package/src/concepts/QueryJoinExpression__.ts +39 -0
  250. package/src/concepts/QueryLimitExpression__.ts +14 -0
  251. package/src/concepts/QueryOrderByExpression__.ts +23 -0
  252. package/src/concepts/QuerySelectExpression__.ts +55 -0
  253. package/src/concepts/SelectMembers__.ts +7 -0
  254. package/src/concepts/SqlQueryComponent__.ts +4 -2
  255. package/src/concepts/StringInterpolation__.ts +18 -2
  256. package/src/concepts/StringLiteral__.ts +20 -1
  257. package/src/concepts/StructureProperty__.ts +22 -0
  258. package/src/concepts/Structure__.ts +24 -7
  259. package/src/concepts/SwitchCase__.ts +1 -1
  260. package/src/concepts/TypeAnnotation__.ts +37 -1
  261. package/src/concepts/TypeParam__.ts +6 -1
  262. package/src/concepts/Unparsed__.ts +1 -1
  263. package/src/concepts/ValidationRule__.ts +6 -1
  264. package/src/concepts/ViewElement__.ts +74 -58
  265. package/src/concepts/View__.ts +6 -19
  266. package/src/generator/genBundleFiles.ts +6 -1
  267. package/src/natural/genNaturalTS.ts +41 -0
  268. package/src/natural/transformTSCode.ts +50 -42
  269. package/src/server/formatTsUtils.ts +16 -11
  270. package/src/server/getFunctions.ts +3 -3
  271. package/src/server/getProcesses.ts +3 -3
  272. package/src/server/naslServer.ts +56 -18
  273. package/src/server/translator.ts +7 -0
  274. package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -1
  275. package/src/templator/genGetBlock.ts +2 -1
  276. package/src/templator/genUpdateBlock.ts +2 -1
  277. package/src/templator/utils.ts +3 -3
  278. package/src/translator/types.ts +4 -0
  279. package/src/translator/utils.ts +73 -34
  280. package/src/utils/string.ts +2 -2
  281. package/src/utils/time-slicing/performance.ts +3 -3
  282. package/test/concepts/call-interface/__snapshots__/getQuickInfoOffset.spec.ts.snap +3 -3
  283. package/test/concepts/call-interface/__snapshots__/toEmbeddedTS.spec.ts.snap +3 -3
  284. package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +199 -0
  285. package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +127 -6
  286. package/test/concepts/view-element/fixtures/table-data-source-calllogic-with-server-validation.json +2074 -0
  287. package/test/concepts/view-element/toVue.spec.ts +0 -1
  288. package/ts-worker/package.json +1 -1
  289. package/ts-worker/src/index.js +1 -0
@@ -32,6 +32,7 @@ interface Config {
32
32
  tenantType: any;
33
33
  tenantLevel: any;
34
34
  appid: string;
35
+ isExport?:string;
35
36
  devDnsAddr: string;
36
37
  miniEnable: boolean;
37
38
  }
@@ -614,7 +615,11 @@ export function genBundleFiles(app: App, frontend: Frontend, config: Config) {
614
615
  `;
615
616
  content += str;
616
617
  }
617
- const baseUrl = `${config.USER_STATIC_URL}/${config.tenant}/${app.id}/${config.env}`;
618
+ let baseUrl = `${config.USER_STATIC_URL}/${config.tenant}/${app.id}/${config.env}`;
619
+
620
+ if((config.isExport)as any){
621
+ baseUrl = '';
622
+ }
618
623
  let bundleMinPath = `${baseUrl}/bundle.${genHash(content)}.min.js`;
619
624
  if (frontend.basePath) {
620
625
  bundleMinPath = `${baseUrl}${frontend.basePath}/bundle.${genHash(content)}.min.js`;
@@ -88,3 +88,44 @@ export function genNaturalTSContext(app: App, currentNode?: BaseNode, focusedNod
88
88
  code += `\n\`\`\`\n`;
89
89
  return code;
90
90
  }
91
+
92
+ export function genNaturalTSContextForAI(app: App) {
93
+ let code = ``;
94
+ /* 标准库 */
95
+ app.enums.forEach((enumeration) => code += `${enumeration?.toNaturalTS()}\n`);
96
+ app.dataSources.forEach((dataSource) => dataSource.entities
97
+ .forEach((entity) => code += `${entity?.toNaturalTS()}\n`));
98
+ app.structures
99
+ .forEach((structure) => code += `${structure?.toNaturalTS()}\n`);
100
+
101
+ app.frontendTypes.forEach((frontendType) => {
102
+ frontendType.frontends.forEach((frontend) => {
103
+ code += `namespace frontends.${frontend.name} {\n// 前端全局变量\n`;
104
+ const state = createCompilerState(undefined, { tabSize: 1 });
105
+ frontend?.variables?.forEach((variable) => {
106
+ code += 'let ';
107
+ code += variable?.toNaturalTS(shiftState(state, code, { inline: true }));
108
+ code += ';\n';
109
+ });
110
+
111
+ code += '\n// 前端页面\n';
112
+ frontend?.views?.forEach((view) => {
113
+ code += view?.toNaturalTS(state, undefined, true);
114
+ });
115
+ code += `}\n`;
116
+ });
117
+ });
118
+
119
+ return code;
120
+ }
121
+
122
+ export function genNaturalTSStdlibForAI() {
123
+ return `${Object.values(naslStdlibMap).join('\n')}\n`;
124
+ }
125
+
126
+ export function genNaturalTSViewContextForAI(view: View) {
127
+ let code = ``;
128
+ code += view?.toNaturalTS(createCompilerState(''), view);
129
+
130
+ return code;
131
+ }
@@ -4,9 +4,12 @@ import * as babel from '@babel/core';
4
4
  import * as babelTypes from '@babel/types';
5
5
  import generate from '@babel/generator';
6
6
  import * as naslTypes from '../concepts';
7
- import { traverse } from '../utils';
8
7
 
9
- const debug = false;
8
+ const DEBUG = false;
9
+ function throwError(message: string) {
10
+ if (DEBUG) throw new Error(message);
11
+ else console.error(message);
12
+ }
10
13
 
11
14
  export function tryParseTS(tsCode: string) {
12
15
  try {
@@ -91,10 +94,7 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
91
94
  typeNamespace: 'app.dataSources.defaultDS',
92
95
  });
93
96
  }
94
- console.error(node);
95
- if (debug) {
96
- throw new Error(`Unhandled node ${node.type}`);
97
- }
97
+ throwError(`Unhandled node ${node.type}`);
98
98
  } else if (node.type === 'TSTypeLiteral') {
99
99
  return naslTypes.TypeAnnotation.createTypeAnonymousStructure(node.members.map((member: babelTypes.TSPropertySignature) => new naslTypes.StructureProperty({
100
100
  name: (member.key as babelTypes.Identifier).name,
@@ -114,10 +114,7 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
114
114
  });
115
115
  return union;
116
116
  } else {
117
- console.error(node);
118
- if (debug) {
119
- throw new Error(`Unhandled node ${node.type}`);
120
- }
117
+ throwError(`Unhandled node ${node.type}`);
121
118
  }
122
119
  }
123
120
  function transformParam(node: babelTypes.Identifier): naslTypes.Param {
@@ -169,6 +166,7 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
169
166
  if (calleeName === 'NewMap') {
170
167
  const keys: any = [];
171
168
  const values: any = [];
169
+
172
170
  node?.arguments?.[0]?.properties.forEach((arg: any) => {
173
171
  keys.push(transformLogicNode(arg.key));
174
172
  values.push(transformLogicNode(arg.value));
@@ -200,7 +198,7 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
200
198
  rights,
201
199
  });
202
200
  }
203
- if (calleeName === 'NewAnonymityStructure') {
201
+ if (calleeName === 'NewAnonymousStructure') {
204
202
  const properties: any = [];
205
203
  const rights: any = [];
206
204
  const structureProperties: any = [];
@@ -257,6 +255,8 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
257
255
  }
258
256
  });
259
257
  if (newNode) return newNode;
258
+ } else if (node.type === 'CallExpression' && node.callee.type === 'CallExpression') {
259
+ // (function match() {})(...) 的情况
260
260
  } else if (node.type === 'CallExpression') {
261
261
  const callee = flatMemberExpression(node.callee);
262
262
  const calleeName = generate(node.callee as any).code;
@@ -308,6 +308,16 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
308
308
  })) as naslTypes.Argument[],
309
309
  });
310
310
  }
311
+ if (calleeName.startsWith('nasl.logging.')) {
312
+ return new naslTypes.CallLogic({
313
+ calleeNamespace: 'nasl.logging',
314
+ calleeName: (callee[2] as babelTypes.Identifier).name,
315
+ shortcut: true,
316
+ arguments: node.arguments.map((arg) => new naslTypes.Argument({
317
+ expression: transformLogicNode(arg),
318
+ })) as naslTypes.Argument[],
319
+ });
320
+ }
311
321
  if (calleeName === 'nasl.util.jsonSerialize' || calleeName === 'nasl.util.jsonDeserialize') {
312
322
  const curCalleeName = (node.callee as any).property.name;
313
323
  return new naslTypes.CallLogic({
@@ -321,14 +331,22 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
321
331
  });
322
332
  };
323
333
  if (calleeName.startsWith('nasl.util.')) {
324
- const curCalleeName = callee.length === 3 ? (callee[callee.length - 1] as babelTypes.Identifier).name : (callee[0] as any).callee.property.name;
334
+ let curCalleeName: string;
335
+ if (callee.length === 3)
336
+ curCalleeName = (callee[callee.length - 1] as babelTypes.Identifier).name;
337
+ else {
338
+ let _callee = (callee[0] as any).callee;
339
+ while (_callee.type === 'CallExpression')
340
+ _callee = _callee.callee;
341
+ curCalleeName = _callee.property.name
342
+ }
325
343
  const argument = callee.length === 3 ? node.arguments : (callee[0] as any).arguments as any;
326
344
 
327
345
  if (['plus', 'minus', 'multiply', 'divide', 'remainder'].includes(curCalleeName)) {
328
346
  return handleBinaryExpression(curCalleeName, argument);
329
347
  };
330
348
 
331
- if (['NewList', 'NewMap', 'NewEntity', 'NewAnonymityStructure'].includes(curCalleeName)) {
349
+ if (['NewList', 'NewMap', 'NewEntity', 'NewAnonymousStructure'].includes(curCalleeName)) {
332
350
  return handleNewExpression(curCalleeName, node);
333
351
  }
334
352
 
@@ -355,7 +373,7 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
355
373
  const viewName = nsArr.pop();
356
374
 
357
375
  return new naslTypes.Destination({
358
- viewNamespace: `app.frontends.pc.views${nsArr.map((item) => `.${item}.views`).join('')}`, // viewNamespace
376
+ viewNamespace: `app.frontendTypes.pc.frontends.pc.views${nsArr.map((item) => `.${item}.views`).join('')}`, // viewNamespace
359
377
  viewName, // viewName
360
378
  arguments: node.arguments.slice(1).map((arg) => new naslTypes.Argument({
361
379
  expression: transformLogicNode(arg),
@@ -448,6 +466,14 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
448
466
  })) as naslTypes.Argument[],
449
467
  });
450
468
  }
469
+ if (calleeName === 'FROM') {
470
+ // TODO
471
+ return new naslTypes.CallLogic({
472
+ calleeNamespace: `app.logics`,
473
+ calleeName,
474
+ arguments: [],
475
+ });
476
+ }
451
477
  return new naslTypes.CallLogic({
452
478
  calleeNamespace: `app.logics`,
453
479
  calleeName,
@@ -459,10 +485,10 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
459
485
  return new naslTypes.CallInterface({
460
486
  calleeNamespace: generate((node.callee as any).object).code,
461
487
  calleeName: (callee[callee.length - 1] as babelTypes.Identifier).name,
462
- arguments: node.arguments.map((arg: any) => new naslTypes.Argument({
463
- keyword: arg.properties[0].key.name,
464
- expression: transformLogicNode(arg.properties[0].value),
465
- })) as naslTypes.Argument[],
488
+ arguments: node.arguments.length === 1 && node.arguments[0].type === 'ObjectExpression' ? node.arguments[0].properties.map((property) => property.type === 'ObjectProperty' && new naslTypes.Argument({
489
+ keyword: (property.key as babelTypes.Identifier).name,
490
+ expression: transformLogicNode(property.value),
491
+ })) as naslTypes.Argument[] : [],
466
492
  });
467
493
  }
468
494
  // else if (/destination/.test(calleeName)) {
@@ -521,15 +547,9 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
521
547
  const switchStatement = transformLogicNode(newCallee[0].body.body[0]);
522
548
  return switchStatement;
523
549
  }
524
- console.error(node);
525
- if (debug) {
526
- throw new Error(`Unhandled ArrowFunctionExpression node ${node.type}`);
527
- }
550
+ throwError(`Unhandled ArrowFunctionExpression node ${node.type}`);
528
551
  } else {
529
- console.error(node);
530
- if (debug) {
531
- throw new Error(`Unhandled node ${callee.map((item: babelTypes.Identifier) => item.name).join('.')} ${node.type}`);
532
- }
552
+ throwError(`Unhandled node ${callee.map((item: babelTypes.Identifier) => item.name).join('.')} ${node.type}`);
533
553
  }
534
554
  } else if (node.type === 'IfStatement') {
535
555
  if (node.alternate && node.alternate.type === 'IfStatement') {
@@ -629,10 +649,7 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
629
649
  if (['Boolean', 'Integer', 'Double', 'Decimal', 'Long'].includes(calleeName)) {
630
650
  return transformLogicNode(node.arguments[0], naslTypes.TypeAnnotation.createPrimitive(calleeName));
631
651
  }
632
- console.error(node);
633
- if (debug) {
634
- throw new Error(`Unhandled node ${node.type}`);
635
- }
652
+ throwError(`Unhandled node ${node.type}`);
636
653
  } else if (node.type === 'ArrowFunctionExpression') {
637
654
  return new naslTypes.AnonymousFunction({
638
655
  params: node.params.map((param: babelTypes.Identifier) => transformParam(param)),
@@ -679,10 +696,7 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
679
696
  right: transformLogicNode(node.right),
680
697
  });
681
698
  }
682
- console.error(node);
683
- if (debug) {
684
- throw new Error(`Unhandled node ${node.type}`);
685
- }
699
+ throwError(`Unhandled node ${node.type}`);
686
700
  } else if (node.type === 'UnaryExpression') {
687
701
  if (['!'].includes(node.operator)) {
688
702
  return new naslTypes.UnaryExpression({
@@ -696,10 +710,7 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
696
710
  value: -node.argument.value,
697
711
  } as babelTypes.NumericLiteral);
698
712
  }
699
- console.error(node);
700
- if (debug) {
701
- throw new Error(`Unhandled node ${node.type}`);
702
- }
713
+ throwError(`Unhandled node ${node.type}`);
703
714
  } else if (node.type === 'UpdateExpression') {
704
715
  if (node.operator === '++' || node.operator === '--') {
705
716
  return new naslTypes.Assignment({
@@ -757,10 +768,7 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
757
768
  rights,
758
769
  });
759
770
  } else {
760
- console.error(node);
761
- if (debug) {
762
- throw new Error(`Unhandled node ${node.type}`);
763
- }
771
+ throwError(`Unhandled node ${node.type}`);
764
772
  }
765
773
  }
766
774
 
@@ -19,6 +19,10 @@ import {
19
19
  BackendVariable,
20
20
  AuthLogic,
21
21
  AuthLogicForCallInterface,
22
+ BusinessComponent,
23
+ BusinessLogic,
24
+ View,
25
+ ParamWithGroup
22
26
  } from '..';
23
27
  import { getNaslNodeByNodeCallee } from '../automate/engine/utils';
24
28
  import { runGeneratorSync as runSync } from '../utils';
@@ -255,16 +259,16 @@ export function getPlatformType(type: string): string {
255
259
  return tsType;
256
260
  }
257
261
  export function isNoChildType(type: String) {
258
- return (type?.startsWith('nasl.core') && !['String', 'Text', 'Email'].includes(type.split('.')[2])) || type?.startsWith('app.enums');
262
+ return (type?.startsWith?.('nasl.core') && !['String', 'Text', 'Email'].includes(type.split('.')[2])) || type?.startsWith?.('app.enums');
259
263
  }
260
264
  function findNode(typeKey: string, node: BaseNode) {
261
265
  let newType: Structure | Logic;
262
- if (typeKey.startsWith('nasl.') && typeKey.includes('<')) {
266
+ if (typeKey?.startsWith?.('nasl.') && typeKey?.includes?.('<')) {
263
267
  const findGenericsIndex = typeKey.indexOf('<');
264
268
  typeKey = typeKey.substring(0, findGenericsIndex);
265
269
  const typeIndex = typeKey.lastIndexOf('.');
266
270
  newType = getNaslNodeByNodeCallee(typeKey.substring(0, typeIndex), typeKey.substring(typeIndex + 1, typeKey.length));
267
- } else if (typeKey.startsWith('nasl.')) {
271
+ } else if (typeKey?.startsWith?.('nasl.')) {
268
272
  const typeIndex = typeKey.lastIndexOf('.');
269
273
  newType = getNaslNodeByNodeCallee(typeKey.substring(0, typeIndex), typeKey.substring(typeIndex + 1, typeKey.length));
270
274
  } else {
@@ -589,6 +593,7 @@ function getNextFlag(typeKey: string, typeKeyMap: Map<string, number>) {
589
593
  }
590
594
  return true;
591
595
  }
596
+
592
597
  // 格式化变量数据
593
598
  export function formatVariableData(data: unknown | variableItem[], node: types.SyntaxNode, parent?: any) {
594
599
  if (Array.isArray(data)) {
@@ -684,6 +689,7 @@ export function formatVariableData(data: unknown | variableItem[], node: types.S
684
689
  result = sortFirstVariableData(result, node);
685
690
  }
686
691
 
692
+
687
693
  return result.filter(Boolean);
688
694
  }
689
695
  }
@@ -691,8 +697,8 @@ export function formatVariableData(data: unknown | variableItem[], node: types.S
691
697
  // 从logic获取节点的icon
692
698
  function getNodeiconFromLogic(completionProperty: CompletionProperty, node: types.SyntaxNode): string {
693
699
  const { name: propName } = completionProperty;
694
- const { view } = node as Param;
695
- const logic = (node as Param).logic || (node as Param).OverriddenLogic || (node as Param).AuthLogic || (node as Param).AuthLogicForCallInterface;
700
+ const likeComponent = node.getAncestor('View') as View || node.getAncestor('BusinessComponent') as BusinessComponent;
701
+ const logic = (node as Param).logic || node.getAncestor('BusinessLogic') as BusinessLogic || (node as Param).OverriddenLogic || (node as Param).AuthLogic || (node as Param).AuthLogicForCallInterface;
696
702
 
697
703
  if (node.concept === 'Identifier' || node.concept === 'BindAttribute' || node.concept === 'MemberExpression') {
698
704
  const callLogic = node.getAncestor<CallLogic>('CallLogic');
@@ -703,18 +709,17 @@ function getNodeiconFromLogic(completionProperty: CompletionProperty, node: type
703
709
  }
704
710
  }
705
711
 
706
- if (view) {
712
+ if (likeComponent) {
713
+ const params: any[] = likeComponent.params;
707
714
  // 前端逻辑调用
708
- const { params } = view;
709
-
710
715
  if (params.find((item) => item.name === propName)) {
711
716
  return 'param';
712
717
  }
713
718
  }
714
719
 
715
720
  if (logic) {
716
- const { params, returns } = logic;
717
-
721
+ const { returns } = logic;
722
+ const params: Param[] = logic.params;
718
723
  if (logic instanceof AuthLogicForCallInterface) {
719
724
  const { authParams } = logic;
720
725
  if (authParams.find((item) => item.name === completionProperty.name)) return 'api-auth-params';
@@ -759,7 +764,7 @@ function getNodeiconFromLogic(completionProperty: CompletionProperty, node: type
759
764
  function sortFirstVariableData(result: CompletionProperty[], node: BaseNode) {
760
765
  const newResult: CompletionProperty[] = [];
761
766
  const logic = (node as Param).logic;
762
- const view = (node as Param).view;
767
+ const view: any = (node as Param).view || (node as Param).getAncestor('BusinessComponent');
763
768
  if (view) {
764
769
  const { params, variables } = view;
765
770
  const list = [...params, ...variables];
@@ -1,12 +1,12 @@
1
1
  import { getStdlibNamespace } from '..';
2
2
 
3
3
  export function getFunctions() {
4
- return getStdlibNamespace().findChild('util');
4
+ return getStdlibNamespace()?.findChild?.('util');
5
5
  }
6
6
 
7
7
  export function getBuildInFunction(name: string) {
8
- const utilFunctions = getFunctions().functions;
9
- return utilFunctions.find((f) => f.name === name);
8
+ const utilFunctions = getFunctions()?.functions;
9
+ return utilFunctions?.find?.((f) => f.name === name);
10
10
  }
11
11
 
12
12
  export function getValidationInFunction(name: string) {
@@ -267,7 +267,7 @@ export function syncMemberExpression(elem: ProcessElement | Process, callback: (
267
267
  }
268
268
  });
269
269
  }
270
- if (el.type === 'ExclusiveGateway' || el.type === 'AutoTask') {
270
+ if (['ExclusiveGateway', 'AutoTask', 'InclusiveGateway'].includes(el.type)) {
271
271
  travelDown(el.logic, (node) => {
272
272
  if (node instanceof MemberExpression) {
273
273
  callback(node);
@@ -435,7 +435,7 @@ export function getProcessVariableSuggestions(node: LogicItem, abandonConstant:
435
435
  ],
436
436
  });
437
437
  processVariables.icon = 'Process';
438
- if (processElem.type === 'ExclusiveGateway') {
438
+ if (['ExclusiveGateway', 'InclusiveGateway'].includes(processElem.type)) {
439
439
  const scopeVariable = new CompletionProperty({
440
440
  name: processElem.name,
441
441
  value: processElem.name,
@@ -589,7 +589,7 @@ export function getProcessVariableSuggestionsAll(node: ProcessElement, exitConst
589
589
  });
590
590
  processVariables.expanded = true;
591
591
  processVariables.icon = 'Process';
592
- if (processElem.type === 'ExclusiveGateway') {
592
+ if (['ExclusiveGateway', 'AutoTask', 'InclusiveGateway'].includes(processElem.type)) {
593
593
  const scopeVariable = new CompletionProperty({
594
594
  name: processElem.name,
595
595
  value: processElem.name,
@@ -89,6 +89,7 @@ import {
89
89
  types,
90
90
  asserts,
91
91
  BusinessComponent,
92
+ CallEvent,
92
93
  } from '../concepts';
93
94
 
94
95
  import * as utils from '../utils';
@@ -109,6 +110,7 @@ import { EventEmitter } from '../common/EventEmitter';
109
110
  import { traverse, FileNode } from '../utils';
110
111
  import { withQueueExecute } from '../decorators';
111
112
  import { getNodeByNodeCallee } from '../automate/engine/utils';
113
+ import { isConnection, isConnector } from '../concepts/utils/asserts';
112
114
 
113
115
  const EmbeddedTSFileLineMap: { [name: string]: number } = {
114
116
  Entity: 3,
@@ -147,6 +149,22 @@ let timer: number | null = null; //超时器用于收集导入接口相关
147
149
  // naslStdlib文件缓存;作为全局变量给多实例用复用
148
150
  const __naslStdlibFileCacheMap: Map<tsProtocol.OpenRequestArgs['file'], tsProtocol.OpenRequestArgs> = new Map();
149
151
 
152
+ /**
153
+ * 业务组件先特殊处理一下
154
+ * 获取业务组件的位置信息
155
+ */
156
+ function getBusinessComponentPos(fileNode: BaseNode) {
157
+ if (fileNode.concept === 'BusinessComponent') {
158
+ const sourceMap = fileNode?.sourceMap?.get(fileNode);
159
+ if (sourceMap) {
160
+ const { start } = sourceMap;
161
+ return {
162
+ ...start,
163
+ }
164
+ }
165
+ }
166
+ }
167
+
150
168
  // 联合类型切割取出类型
151
169
  export function getDisplayString2Type(displayString: string) {
152
170
  const targetString = displayString.match(/value:\s(\S+)\)/)?.[1];
@@ -1603,9 +1621,10 @@ class NaslServer {
1603
1621
  const self = this;
1604
1622
  const diagnostics: Diagnostic[] = [];
1605
1623
 
1606
- if (fileNode instanceof View) {
1624
+ if (fileNode instanceof View || fileNode instanceof BusinessComponent) {
1607
1625
  yield* utils.wrapIteratorToGenerator(fileNode.sourceMap.entries(), function* attachView([node, value]) {
1608
- if (node instanceof ViewElement && node.view === fileNode) {
1626
+ const likeComponent = node.getAncestor('View') || node.getAncestor('BusinessComponent');
1627
+ if (node instanceof ViewElement && likeComponent === fileNode) {
1609
1628
  if (node.tag) {
1610
1629
  yield* utils.wrapForEachToGenerator(node.bindAttrs, (bindAttr) => {
1611
1630
  if ((bindAttr.model || bindAttr.sync) && bindAttr.expression) {
@@ -1646,14 +1665,14 @@ class NaslServer {
1646
1665
  }
1647
1666
  });
1648
1667
  }
1649
- } else if ((node instanceof Variable || node instanceof Return) && node.view === fileNode) {
1668
+ } else if ((node instanceof Variable || node instanceof Return) && likeComponent === fileNode) {
1650
1669
  if (!node.typeAnnotation && !node.__TypeAnnotation) {
1651
1670
  const nodeTypeName = node.concept === 'Return' ? '输出参数' : '局部变量';
1652
1671
  let msg;
1653
1672
  yield* fileNode.traverseChildrenGenerator((nodeIn) => {
1654
1673
  if (nodeIn && (nodeIn instanceof BatchAssignment || (nodeIn instanceof Assignment && nodeIn.left?.name))) {
1655
1674
  // 子页面内部逻辑过滤
1656
- if (nodeIn.view !== fileNode) return;
1675
+ if ((nodeIn.view || nodeIn.getAncestor('BusinessComponent')) !== fileNode) return;
1657
1676
  // 当局部变量、输出参数属于页面内逻辑时,需过滤同页面下不同逻辑下的同名变量
1658
1677
  if (node.logic && node.logic !== nodeIn.logic) return;
1659
1678
  // 跟变量无关的赋值过滤
@@ -2730,7 +2749,7 @@ class NaslServer {
2730
2749
  }
2731
2750
 
2732
2751
  if (!minRange) {
2733
- if (fileNode instanceof View) {
2752
+ if (fileNode instanceof View || fileNode instanceof BusinessComponent) {
2734
2753
  return { node: fileNode, item: sourceMap.get(fileNode) } as MinRange;
2735
2754
  }
2736
2755
  if (process.env.NODE_ENV === 'development') {
@@ -3131,6 +3150,9 @@ class NaslServer {
3131
3150
  );
3132
3151
  const results = await Promise.all(promises);
3133
3152
  results.forEach((constRefs) => {
3153
+ if(constRefs.symbolDisplayString.includes('(parameter)')) {
3154
+ return;
3155
+ }
3134
3156
  refsList = [...refsList, ...constRefs.refs];
3135
3157
  });
3136
3158
  }
@@ -3181,6 +3203,9 @@ class NaslServer {
3181
3203
  minRange.setTypeMethods = 'setCalleeNamespace';
3182
3204
  minRange.newValue = `elements.${ newValue }.logics`;
3183
3205
  }
3206
+ if (minRange.node instanceof CallEvent) {
3207
+ minRange.setTypeMethods = 'setCalleeName';
3208
+ }
3184
3209
  // 如果节点是实体修改引发calllogic修改
3185
3210
  if (
3186
3211
  minRange.node instanceof CallLogic &&
@@ -3551,11 +3576,12 @@ class NaslServer {
3551
3576
  if (node instanceof Param && minRange.node instanceof Interface) {
3552
3577
  return null;
3553
3578
  }
3554
- // 如果是被影响的是页面
3555
- if (minRange.node instanceof View) {
3556
- if (node instanceof View) {
3579
+ // 如果是被影响的是页面/业务组件
3580
+ if (minRange.node instanceof View || minRange.node instanceof BusinessComponent) {
3581
+ if (node instanceof View || node instanceof BusinessComponent) {
3557
3582
  // 如果是子页面修改
3558
3583
  // 父页面引起子页面改名,就可以不改了,自动同步
3584
+ // 页面中的业务组件,业务组件中的业务组件等都需要忽略
3559
3585
  if (minRange.node !== node) {
3560
3586
  return null;
3561
3587
  }
@@ -4377,8 +4403,12 @@ class NaslServer {
4377
4403
  (matchExpression instanceof Identifier || matchExpression instanceof MemberExpression)
4378
4404
  ) {
4379
4405
  const { currentSource, fileNode } = matchExpression?.getCurrentSource();
4406
+ const currentCode = this.getNodeCode(fileNode, currentSource);
4407
+
4380
4408
  fileNode.sourceMap.forEach((item, itemNode) => {
4381
- if (itemNode.concept === matchExpression.concept && isSameRange(item, currentSource)) {
4409
+ const itemCode = this.getNodeCode(fileNode, item);
4410
+
4411
+ if (itemNode.concept === matchExpression.concept && itemCode === currentCode) {
4382
4412
  const jsonNode = jsoner.queryNodeByPath(json, itemNode.getNodePath(false));
4383
4413
  jsonNode.typeAnnotation = matchExpression.__TypeAnnotation;
4384
4414
  }
@@ -4386,14 +4416,14 @@ class NaslServer {
4386
4416
  }
4387
4417
  }
4388
4418
  // 特殊处理param有类型错误的
4389
- if (node instanceof Param && value) {
4419
+ if (value && (node instanceof Param)) {
4390
4420
  // index在nasl foreach上有脏数据
4391
4421
  if (node.parentKey === 'index' && node.parentNode instanceof ForEachStatement) {
4392
4422
  const jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
4393
4423
  jsonNode.typeAnnotation = (value as TypeAnnotation).toJSON();
4394
4424
  }
4395
4425
  }
4396
- if (node instanceof NewComposite && (node.typeAnnotation?.typeKind === 'anonymousStructure' || node.typeAnnotation?.typeKind === 'generic')) {
4426
+ if (value && (node instanceof NewComposite) && (node.typeAnnotation?.typeKind === 'anonymousStructure' || node.typeAnnotation?.typeKind === 'generic')) {
4397
4427
  const jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
4398
4428
  jsonNode.typeAnnotation = (value as TypeAnnotation).toJSON();
4399
4429
  }
@@ -4556,11 +4586,13 @@ class NaslServer {
4556
4586
  * 删除节点中的一个内容,删除了以后,就查一下引用的地方一起查一下异常
4557
4587
  */
4558
4588
  let outputFiles: any = [];
4589
+ // 先特殊处理业务组件
4590
+ const pos = getBusinessComponentPos(fileNode);
4559
4591
  // 删除之前先查一下内容的依赖
4560
4592
  const newRefs = await this.references({
4561
4593
  file: result.filePath,
4562
- line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
4563
- offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
4594
+ line: pos?.line ?? EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
4595
+ offset: pos?.offset ?? EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
4564
4596
  });
4565
4597
  // 如果是要删除的内容,就是当前的file节点,要关闭当前文件,就把内容置为空
4566
4598
  if (fileNode === targetNode) {
@@ -4595,12 +4627,14 @@ class NaslServer {
4595
4627
  const outputFiles = [{ file: result.filePath, fileContent: result.code }];
4596
4628
  // 创建和更新都用update,内部会做判断
4597
4629
  await this.updateFiles({ outputFiles });
4630
+ // 先特殊处理业务组件
4631
+ const pos = getBusinessComponentPos(fileNode);
4598
4632
 
4599
4633
  // 查一下新函数名的依赖
4600
4634
  const newRefs = await this.references({
4601
4635
  file: result.filePath,
4602
- line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
4603
- offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
4636
+ line: pos?.line ?? EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
4637
+ offset: pos?.offset ?? EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
4604
4638
  });
4605
4639
 
4606
4640
  const files = new Set();
@@ -4645,12 +4679,13 @@ class NaslServer {
4645
4679
 
4646
4680
  // 修改名字新的添加进去,旧的置为空
4647
4681
  outputFiles.unshift({ file: oldFilePath, fileContent: '' });
4648
-
4682
+ // 先特殊处理业务组件
4683
+ const pos = getBusinessComponentPos(fileNode);
4649
4684
  // 查一下旧文件名的依赖
4650
4685
  const oldRefs = await this.references({
4651
4686
  file: oldFilePath,
4652
- line: EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
4653
- offset: EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
4687
+ line: pos?.line ?? EmbeddedTSFileLineMap[fileNode.concept] ?? 2,
4688
+ offset: pos?.offset ?? EmbeddedTSFileOffsetMap[fileNode.concept] ?? 6,
4654
4689
  });
4655
4690
  oldRefs.refs.forEach((ref) => this.filesToCheck.add(ref.file));
4656
4691
  this.filesToCheck.delete(oldFilePath);
@@ -4947,6 +4982,9 @@ class NaslServer {
4947
4982
  */
4948
4983
  static getPropertyNames(fileNode: Connection|Connector) {
4949
4984
  const names: string[] = [];
4985
+ if (!isConnection(fileNode) && !isConnector(fileNode)) {
4986
+ return names;
4987
+ }
4950
4988
  // TODO 如果不存在对应的 Connector 时,应该提示错误
4951
4989
  if (fileNode) {
4952
4990
  fileNode.properties.forEach((property) => {
@@ -457,6 +457,11 @@ Object.keys(NAMESPACE_CONCEPT_MAP).forEach((key) => {
457
457
  });
458
458
 
459
459
  export function translateDiagnosticMessage(message: string) {
460
+ // 业务组件先处理
461
+ const businessComponent = /Namespace 'app.frontendTypes.(.+?).businessComponents' has no exported member '(.+?)'./.exec(message);
462
+ if (businessComponent?.[1] && businessComponent?.[2]) {
463
+ return `找不到${businessComponent?.[1]}端下的业务组件${businessComponent?.[2]}`;
464
+ }
460
465
  for (const rule of TS_RULES) {
461
466
  const cap = rule.re.exec(message);
462
467
  if (cap) {
@@ -488,6 +493,8 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
488
493
  return null;
489
494
  } else if (text.startsWith(`Function expression, which lacks return-type annotation, implicitly has an 'any[]' return type.`)) {
490
495
  return null;
496
+ } else if (/Property 'businessComponents' does not exist on type 'typeof (pc|h5)'./.exec(text)) {
497
+ return null;
491
498
  }
492
499
  }
493
500
  // 处理bindevent参数没传递的报错
@@ -413,7 +413,7 @@ export function genEditTableColumnComponent(app: App, entity: Entity, property:
413
413
  const propertyTypeMaxLength: number =
414
414
  Number(
415
415
  property.rules
416
- .find((item) => item.indexOf('max') > -1)
416
+ ?.find?.((item) => item.indexOf('max') > -1)
417
417
  ?.split('(')[1]
418
418
  .slice(0, -1)
419
419
  ) || 0;
@@ -69,6 +69,7 @@ export function genH5GetTemplate(entity: Entity, nameGroup: NameGroup) {
69
69
 
70
70
  export function genGetBlock(entity: Entity, oldNode: ViewElement) {
71
71
  const likeComponent = oldNode?.likeComponent;
72
+ const isBusinessComponent = likeComponent.concept === 'BusinessComponent';
72
73
  const { ns } = entity;
73
74
  const getLogic = ns?.logics?.find((logic) => logic.name === `get`);
74
75
 
@@ -85,7 +86,7 @@ export function genGetBlock(entity: Entity, oldNode: ViewElement) {
85
86
  {
86
87
  "viewParams": [
87
88
  {
88
- "concept": "Param",
89
+ "concept": "${isBusinessComponent ? 'ParamWithGroup' : 'Param'}",
89
90
  "name": "${nameGroup.viewParamId}",
90
91
  "typeAnnotation": ${JSON.stringify(NaslCoreTypeAnnotation.Long)}
91
92
  }