@lcap/nasl 3.8.0-beta.3 → 3.8.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 (320) hide show
  1. package/out/automate/engine/utils.js +1 -2
  2. package/out/automate/engine/utils.js.map +1 -1
  3. package/out/bak/translator.js +1 -1
  4. package/out/bak/translator.js.map +1 -1
  5. package/out/common/BaseNode.js +7 -2
  6. package/out/common/BaseNode.js.map +1 -1
  7. package/out/concepts/App__.js +6 -1
  8. package/out/concepts/App__.js.map +1 -1
  9. package/out/concepts/Argument__.js +11 -5
  10. package/out/concepts/Argument__.js.map +1 -1
  11. package/out/concepts/AuthLogicForCallInterface__.js +3 -0
  12. package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
  13. package/out/concepts/BinaryExpression__.js +49 -2
  14. package/out/concepts/BinaryExpression__.js.map +1 -1
  15. package/out/concepts/BindAttribute__.d.ts +4 -3
  16. package/out/concepts/BindAttribute__.js +121 -42
  17. package/out/concepts/BindAttribute__.js.map +1 -1
  18. package/out/concepts/BindEvent__.js +5 -42
  19. package/out/concepts/BindEvent__.js.map +1 -1
  20. package/out/concepts/BusinessComponent__.d.ts +1 -0
  21. package/out/concepts/BusinessComponent__.js +16 -0
  22. package/out/concepts/BusinessComponent__.js.map +1 -1
  23. package/out/concepts/BusinessLogic__.js +3 -0
  24. package/out/concepts/BusinessLogic__.js.map +1 -1
  25. package/out/concepts/CallConnector__.js +1 -1
  26. package/out/concepts/CallConnector__.js.map +1 -1
  27. package/out/concepts/CallFunction__.js +1 -1
  28. package/out/concepts/CallFunction__.js.map +1 -1
  29. package/out/concepts/CallLogic__.d.ts +6 -1
  30. package/out/concepts/CallLogic__.js +58 -17
  31. package/out/concepts/CallLogic__.js.map +1 -1
  32. package/out/concepts/Connection__.d.ts +4 -0
  33. package/out/concepts/Connection__.js +15 -0
  34. package/out/concepts/Connection__.js.map +1 -1
  35. package/out/concepts/DatabaseTypeAnnotation__.d.ts +2 -0
  36. package/out/concepts/DatabaseTypeAnnotation__.js +20 -0
  37. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
  38. package/out/concepts/End__.js +5 -1
  39. package/out/concepts/End__.js.map +1 -1
  40. package/out/concepts/EntityProperty__.js +2 -0
  41. package/out/concepts/EntityProperty__.js.map +1 -1
  42. package/out/concepts/Entity__.d.ts +1 -0
  43. package/out/concepts/Entity__.js +24 -1
  44. package/out/concepts/Entity__.js.map +1 -1
  45. package/out/concepts/EnumItem__.d.ts +12 -0
  46. package/out/concepts/EnumItem__.js +49 -5
  47. package/out/concepts/EnumItem__.js.map +1 -1
  48. package/out/concepts/Enum__.js +4 -1
  49. package/out/concepts/Enum__.js.map +1 -1
  50. package/out/concepts/ForEachStatement__.js +1 -1
  51. package/out/concepts/ForEachStatement__.js.map +1 -1
  52. package/out/concepts/FrontendLibrary__.d.ts +46 -46
  53. package/out/concepts/FrontendLibrary__.js +34 -36
  54. package/out/concepts/FrontendLibrary__.js.map +1 -1
  55. package/out/concepts/I18nInfo__.d.ts +1 -0
  56. package/out/concepts/I18nInfo__.js +7 -0
  57. package/out/concepts/I18nInfo__.js.map +1 -1
  58. package/out/concepts/IfStatement__.js +2 -2
  59. package/out/concepts/IfStatement__.js.map +1 -1
  60. package/out/concepts/Interface__.js +4 -1
  61. package/out/concepts/Interface__.js.map +1 -1
  62. package/out/concepts/Logic__.d.ts +2 -3
  63. package/out/concepts/Logic__.js +33 -8
  64. package/out/concepts/Logic__.js.map +1 -1
  65. package/out/concepts/MatchCase__.d.ts +2 -2
  66. package/out/concepts/MatchCase__.js +7 -7
  67. package/out/concepts/MatchCase__.js.map +1 -1
  68. package/out/concepts/NewComposite__.js +2 -1
  69. package/out/concepts/NewComposite__.js.map +1 -1
  70. package/out/concepts/NewList__.js +2 -1
  71. package/out/concepts/NewList__.js.map +1 -1
  72. package/out/concepts/NewMap__.js +2 -1
  73. package/out/concepts/NewMap__.js.map +1 -1
  74. package/out/concepts/OqlQueryComponent__.js +3 -11
  75. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  76. package/out/concepts/OverriddenLogic__.js +7 -0
  77. package/out/concepts/OverriddenLogic__.js.map +1 -1
  78. package/out/concepts/Param__.js +2 -1
  79. package/out/concepts/Param__.js.map +1 -1
  80. package/out/concepts/ProcessElementV2__.d.ts +4 -5
  81. package/out/concepts/ProcessElementV2__.js +12 -17
  82. package/out/concepts/ProcessElementV2__.js.map +1 -1
  83. package/out/concepts/ProcessElement__.d.ts +3 -4
  84. package/out/concepts/ProcessElement__.js +44 -46
  85. package/out/concepts/ProcessElement__.js.map +1 -1
  86. package/out/concepts/ProcessV2__.d.ts +5 -0
  87. package/out/concepts/ProcessV2__.js +30 -2
  88. package/out/concepts/ProcessV2__.js.map +1 -1
  89. package/out/concepts/Process__.d.ts +5 -0
  90. package/out/concepts/Process__.js +28 -0
  91. package/out/concepts/Process__.js.map +1 -1
  92. package/out/concepts/QueryFromExpression__.js +2 -2
  93. package/out/concepts/QueryFromExpression__.js.map +1 -1
  94. package/out/concepts/QueryJoinExpression__.js +2 -2
  95. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  96. package/out/concepts/Return__.d.ts +1 -1
  97. package/out/concepts/Return__.js +2 -1
  98. package/out/concepts/Return__.js.map +1 -1
  99. package/out/concepts/StaticString__.d.ts +4 -0
  100. package/out/concepts/StaticString__.js +11 -0
  101. package/out/concepts/StaticString__.js.map +1 -1
  102. package/out/concepts/StructureProperty__.js +5 -2
  103. package/out/concepts/StructureProperty__.js.map +1 -1
  104. package/out/concepts/Structure__.js +9 -3
  105. package/out/concepts/Structure__.js.map +1 -1
  106. package/out/concepts/SubLogic__.d.ts +1 -3
  107. package/out/concepts/SubLogic__.js +14 -8
  108. package/out/concepts/SubLogic__.js.map +1 -1
  109. package/out/concepts/Transactional__.d.ts +1 -0
  110. package/out/concepts/Transactional__.js +7 -0
  111. package/out/concepts/Transactional__.js.map +1 -1
  112. package/out/concepts/TypeParam__.d.ts +4 -0
  113. package/out/concepts/TypeParam__.js +3 -0
  114. package/out/concepts/TypeParam__.js.map +1 -1
  115. package/out/concepts/ValidationRule__.d.ts +1 -6
  116. package/out/concepts/ValidationRule__.js +9 -6
  117. package/out/concepts/ValidationRule__.js.map +1 -1
  118. package/out/concepts/Variable__.d.ts +1 -1
  119. package/out/concepts/Variable__.js +7 -2
  120. package/out/concepts/Variable__.js.map +1 -1
  121. package/out/concepts/ViewElement__.d.ts +2 -0
  122. package/out/concepts/ViewElement__.js +130 -47
  123. package/out/concepts/ViewElement__.js.map +1 -1
  124. package/out/concepts/View__.d.ts +8 -0
  125. package/out/concepts/View__.js +123 -7
  126. package/out/concepts/View__.js.map +1 -1
  127. package/out/concepts/basics/stdlib/nasl.processV2.js +2 -2
  128. package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
  129. package/out/concepts/basics/stdlib/nasl.ui.js +1 -1
  130. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  131. package/out/concepts/basics/stdlib/nasl.validation.js +110 -4
  132. package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -1
  133. package/out/generator/genBundleFiles.d.ts +2 -0
  134. package/out/generator/genBundleFiles.js +51 -37
  135. package/out/generator/genBundleFiles.js.map +1 -1
  136. package/out/generator/genMetaData.js +20 -26
  137. package/out/generator/genMetaData.js.map +1 -1
  138. package/out/generator/release-body/body.js +8 -6
  139. package/out/generator/release-body/body.js.map +1 -1
  140. package/out/generator/release-body/index.d.ts +1 -0
  141. package/out/generator/release-body/index.js +1 -0
  142. package/out/generator/release-body/index.js.map +1 -1
  143. package/out/generator/release-body/utils.js +1 -1
  144. package/out/generator/release-body/utils.js.map +1 -1
  145. package/out/natural/genNaturalTS.d.ts +56 -24
  146. package/out/natural/genNaturalTS.js +182 -112
  147. package/out/natural/genNaturalTS.js.map +1 -1
  148. package/out/natural/getContext/getUILib.js +4 -2
  149. package/out/natural/getContext/getUILib.js.map +1 -1
  150. package/out/natural/getContext/index.d.ts +34 -25
  151. package/out/natural/getContext/index.js +304 -157
  152. package/out/natural/getContext/index.js.map +1 -1
  153. package/out/natural/index.d.ts +1 -0
  154. package/out/natural/index.js +1 -0
  155. package/out/natural/index.js.map +1 -1
  156. package/out/natural/tools.d.ts +11 -0
  157. package/out/natural/tools.js +155 -0
  158. package/out/natural/tools.js.map +1 -0
  159. package/out/natural/transformTS2UI.js +84 -22
  160. package/out/natural/transformTS2UI.js.map +1 -1
  161. package/out/natural/transformTSCode.js +83 -22
  162. package/out/natural/transformTSCode.js.map +1 -1
  163. package/out/server/formatTsUtils.js +17 -1
  164. package/out/server/formatTsUtils.js.map +1 -1
  165. package/out/server/getLogics.js +1 -4
  166. package/out/server/getLogics.js.map +1 -1
  167. package/out/server/naslServer.js +285 -32
  168. package/out/server/naslServer.js.map +1 -1
  169. package/out/server/translator.js +5 -1
  170. package/out/server/translator.js.map +1 -1
  171. package/out/templator/genCreateBlock.js +5 -18
  172. package/out/templator/genCreateBlock.js.map +1 -1
  173. package/out/templator/genCurdMultipleKeyBlock.js +11 -32
  174. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  175. package/out/templator/genGetBlock.js +1 -2
  176. package/out/templator/genGetBlock.js.map +1 -1
  177. package/out/templator/genListViewBlock.js +6 -4
  178. package/out/templator/genListViewBlock.js.map +1 -1
  179. package/out/templator/genSelectBlock.js +82 -59
  180. package/out/templator/genSelectBlock.js.map +1 -1
  181. package/out/templator/genTableBlock.js +4 -4
  182. package/out/templator/genTableBlock.js.map +1 -1
  183. package/out/templator/genUpdateBlock.js +2 -15
  184. package/out/templator/genUpdateBlock.js.map +1 -1
  185. package/out/templator/utils.d.ts +1 -1
  186. package/out/templator/utils.js +1 -1
  187. package/out/templator/utils.js.map +1 -1
  188. package/out/translator/types.d.ts +4 -0
  189. package/out/translator/utils.d.ts +1 -0
  190. package/out/translator/utils.js +6 -1
  191. package/out/translator/utils.js.map +1 -1
  192. package/out/utils/env.d.ts +4 -0
  193. package/out/utils/env.js +6 -3
  194. package/out/utils/env.js.map +1 -1
  195. package/out/utils/index.d.ts +19 -0
  196. package/out/utils/index.js +61 -1
  197. package/out/utils/index.js.map +1 -1
  198. package/out/utils/language-cache/constant.d.ts +18 -0
  199. package/out/utils/language-cache/constant.js +35 -0
  200. package/out/utils/language-cache/constant.js.map +1 -0
  201. package/out/utils/language-cache/index.d.ts +2 -0
  202. package/out/utils/language-cache/index.js +19 -0
  203. package/out/utils/language-cache/index.js.map +1 -0
  204. package/out/utils/language-cache/nasl.d.ts +10 -0
  205. package/out/utils/language-cache/nasl.js +98 -0
  206. package/out/utils/language-cache/nasl.js.map +1 -0
  207. package/out/utils/language-cache/types.d.ts +44 -0
  208. package/out/utils/language-cache/types.js +4 -0
  209. package/out/utils/language-cache/types.js.map +1 -0
  210. package/out/utils/time-slicing/controller.js.map +1 -1
  211. package/out/utils/types.d.ts +17 -0
  212. package/package.json +3 -2
  213. package/sandbox/stdlib/nasl.core.ts +15 -11
  214. package/sandbox/stdlib/nasl.oql.ts +5 -1
  215. package/sandbox/stdlib/nasl.processV2.ts +5 -4
  216. package/sandbox/stdlib/nasl.ui.components.pc.ts +225 -225
  217. package/sandbox/stdlib/nasl.ui.ts +10 -0
  218. package/sandbox/stdlib/nasl.util.ts +11 -0
  219. package/sandbox/stdlib/nasl.validation.ts +3 -2
  220. package/sandbox-natural/stdlib/nasl.ui.pre.d.ts +1 -1
  221. package/sandbox-natural/stdlib/nasl.ui.ts +2 -2
  222. package/sandbox-natural/stdlib/nasl.util.ts +2 -2
  223. package/src/automate/engine/utils.js +1 -2
  224. package/src/bak/translator.js +1 -1
  225. package/src/common/BaseNode.ts +7 -3
  226. package/src/concepts/App__.ts +9 -1
  227. package/src/concepts/Argument__.ts +10 -5
  228. package/src/concepts/AuthLogicForCallInterface__.ts +3 -0
  229. package/src/concepts/BinaryExpression__.ts +46 -2
  230. package/src/concepts/BindAttribute__.ts +144 -46
  231. package/src/concepts/BindEvent__.ts +8 -47
  232. package/src/concepts/BusinessComponent__.ts +17 -0
  233. package/src/concepts/BusinessLogic__.ts +3 -0
  234. package/src/concepts/CallConnector__.ts +1 -1
  235. package/src/concepts/CallFunction__.ts +1 -1
  236. package/src/concepts/CallLogic__.ts +63 -17
  237. package/src/concepts/Connection__.ts +16 -0
  238. package/src/concepts/DatabaseTypeAnnotation__.ts +11 -0
  239. package/src/concepts/End__.ts +5 -1
  240. package/src/concepts/EntityProperty__.ts +5 -0
  241. package/src/concepts/Entity__.ts +29 -1
  242. package/src/concepts/EnumItem__.ts +64 -1
  243. package/src/concepts/Enum__.ts +6 -1
  244. package/src/concepts/ForEachStatement__.ts +1 -1
  245. package/src/concepts/FrontendLibrary__.ts +78 -80
  246. package/src/concepts/I18nInfo__.ts +5 -0
  247. package/src/concepts/IfStatement__.ts +2 -2
  248. package/src/concepts/Interface__.ts +6 -1
  249. package/src/concepts/Logic__.ts +39 -10
  250. package/src/concepts/MatchCase__.ts +8 -9
  251. package/src/concepts/NewComposite__.ts +2 -1
  252. package/src/concepts/NewList__.ts +2 -1
  253. package/src/concepts/NewMap__.ts +2 -1
  254. package/src/concepts/OqlQueryComponent__.ts +3 -11
  255. package/src/concepts/OverriddenLogic__.ts +7 -0
  256. package/src/concepts/Param__.ts +1 -0
  257. package/src/concepts/ProcessElementV2__.ts +14 -16
  258. package/src/concepts/ProcessElement__.ts +16 -16
  259. package/src/concepts/ProcessV2__.ts +39 -3
  260. package/src/concepts/Process__.ts +36 -0
  261. package/src/concepts/QueryFromExpression__.ts +2 -2
  262. package/src/concepts/QueryJoinExpression__.ts +2 -2
  263. package/src/concepts/Return__.ts +2 -1
  264. package/src/concepts/StaticString__.ts +12 -0
  265. package/src/concepts/StructureProperty__.ts +7 -2
  266. package/src/concepts/Structure__.ts +11 -3
  267. package/src/concepts/SubLogic__.ts +15 -9
  268. package/src/concepts/Transactional__.ts +5 -0
  269. package/src/concepts/TypeParam__.ts +6 -0
  270. package/src/concepts/ValidationRule__.ts +7 -6
  271. package/src/concepts/Variable__.ts +7 -2
  272. package/src/concepts/ViewElement__.ts +130 -47
  273. package/src/concepts/View__.ts +157 -8
  274. package/src/concepts/basics/stdlib/nasl.processV2.ts +2 -2
  275. package/src/concepts/basics/stdlib/nasl.ui.ts +1 -1
  276. package/src/concepts/basics/stdlib/nasl.validation.ts +111 -4
  277. package/src/generator/genBundleFiles.ts +53 -39
  278. package/src/generator/genMetaData.ts +21 -26
  279. package/src/generator/release-body/body.ts +9 -6
  280. package/src/generator/release-body/index.ts +1 -0
  281. package/src/generator/release-body/utils.ts +4 -2
  282. package/src/natural/genNaturalTS.ts +327 -141
  283. package/src/natural/getContext/getUILib.ts +4 -2
  284. package/src/natural/getContext/index.ts +348 -171
  285. package/src/natural/index.ts +1 -0
  286. package/src/natural/tools.ts +130 -0
  287. package/src/natural/transformTS2UI.ts +84 -22
  288. package/src/natural/transformTSCode.ts +83 -22
  289. package/src/server/formatTsUtils.ts +21 -1
  290. package/src/server/getLogics.ts +1 -4
  291. package/src/server/naslServer.ts +302 -33
  292. package/src/server/translator.ts +5 -1
  293. package/src/templator/genCreateBlock.ts +5 -18
  294. package/src/templator/genCurdMultipleKeyBlock.ts +14 -32
  295. package/src/templator/genGetBlock.ts +2 -4
  296. package/src/templator/genListViewBlock.ts +6 -4
  297. package/src/templator/genSelectBlock.ts +88 -61
  298. package/src/templator/genTableBlock.ts +4 -4
  299. package/src/templator/genUpdateBlock.ts +2 -15
  300. package/src/templator/utils.ts +1 -1
  301. package/src/translator/types.ts +4 -0
  302. package/src/translator/utils.ts +6 -0
  303. package/src/utils/env.ts +5 -4
  304. package/src/utils/index.ts +50 -1
  305. package/src/utils/language-cache/constant.ts +37 -0
  306. package/src/utils/language-cache/index.ts +2 -0
  307. package/src/utils/language-cache/nasl.ts +83 -0
  308. package/src/utils/language-cache/types.ts +48 -0
  309. package/src/utils/time-slicing/controller.ts +0 -1
  310. package/src/utils/types.ts +20 -0
  311. package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +13 -13
  312. package/test/concepts/call-logic/__snapshots__/toEmbeddedTS.spec.ts.snap +12 -12
  313. package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +1 -2
  314. package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +221 -217
  315. package/ts-worker/bundle.js +1 -1
  316. package/ts-worker/src/index.js +0 -1
  317. package/out/utils/delay/index.d.ts +0 -0
  318. package/out/utils/delay/index.js +0 -1
  319. package/out/utils/delay/index.js.map +0 -1
  320. package/src/utils/delay/index.ts +0 -0
@@ -269,6 +269,20 @@ let NaslServer = NaslServer_1 = class NaslServer {
269
269
  } = optinos;
270
270
  Object.assign(allComponent, components);
271
271
  const { code, elementsLogic } = await (0, createUiTs_1.default)(allComponent);
272
+ // 处理一堆api.ts的类型
273
+ const convertTsCode = (code) => {
274
+ code = code.replace(/nasl.core.Integer/g, 'nasl.core.Long');
275
+ // 匹配union类型的正则
276
+ const unionReg = /\s*['"].*['"](\s*\|\s*['"].*['"])+/g;
277
+ code = code.replace(unionReg, 'nasl.core.String');
278
+ const extendsBooleanReg = /extends\s+(true|false)/g;
279
+ code = code.replace(extendsBooleanReg, ($0, $1) => {
280
+ return $1 === 'true' ? 'extends nasl.core.BooleanTrue' : 'extends nasl.core.BooleanFalse';
281
+ });
282
+ const extendsStringReg = /extends\s+(['"](.*)['"])/g;
283
+ code = code.replace(extendsStringReg, ($0, $1, $2) => `extends nasl.core.StringLiteral<\`${$2}\`>`);
284
+ return code;
285
+ };
272
286
  /// process.env.BUILD_TARGET !== 'node'
273
287
  if (!utils.isNode) {
274
288
  await this.addFile({
@@ -279,9 +293,10 @@ let NaslServer = NaslServer_1 = class NaslServer {
279
293
  }
280
294
  /// #endif
281
295
  if (utils.isNode) {
296
+ let content = await fs.readFile(path.join(__dirname, '../../sandbox/stdlib/nasl.ui.definition.ts'), 'utf-8');
282
297
  await this.addFile({
283
298
  file: 'nasl.ui.definition.ts',
284
- fileContent: await fs.readFile(path.join(__dirname, '../../sandbox/stdlib/nasl.ui.definition.ts'), 'utf-8'),
299
+ fileContent: content,
285
300
  }, { cache: true });
286
301
  }
287
302
  // 放入生產的uits文件
@@ -294,12 +309,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
294
309
  // 基础组件
295
310
  await this.addFile({
296
311
  file: 'nasl.ui.component.ts',
297
- fileContent: optinos.basicUITsCode,
312
+ // FIXME 临时解决方式将union类型转换为string类型
313
+ fileContent: convertTsCode(optinos.basicUITsCode),
298
314
  }, { cache: true });
299
315
  // 带有类型的依赖库组件
300
316
  await this.addFile({
301
317
  file: 'extension.component.ts',
302
- fileContent: optinos.withTypeLibraryTsCode,
318
+ fileContent: convertTsCode(optinos.withTypeLibraryTsCode),
303
319
  }, { cache: true });
304
320
  // 内置标准库类型
305
321
  Object.keys(naslStdlibMap_1.default).forEach(async (libFileName) => {
@@ -328,7 +344,7 @@ let NaslServer = NaslServer_1 = class NaslServer {
328
344
  self.file2NodeMap.set(result.filePath, node);
329
345
  }
330
346
  catch (err) {
331
- if (process.env.NODE_ENV === 'development') {
347
+ if (utils.isDebugMode) {
332
348
  self.logger.warn(node.nodePath ? node.nodePath : name, '代码转换失败', err);
333
349
  }
334
350
  }
@@ -539,7 +555,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
539
555
  await Promise.all(openFiles.map(async (file) => fs.outputFile(path.join(__dirname, '../debug/apps', app.id, file.file), file.fileContent)));
540
556
  }
541
557
  catch (e) {
542
- this.logger.error(e);
558
+ if (utils.isDebugMode) {
559
+ this.logger.error(e);
560
+ }
543
561
  }
544
562
  }
545
563
  /// #endif
@@ -654,6 +672,8 @@ let NaslServer = NaslServer_1 = class NaslServer {
654
672
  let typeStr = types && types[1];
655
673
  // 从 {entity1:Entity1(defaultDS);},unknown,unknown,unknown 取出{entity1:Entity1(defaultDS);}
656
674
  typeStr = typeStr?.split(',')[0];
675
+ // 将Long转换为Integer
676
+ typeStr = typeStr?.replace('Long', 'Integer');
657
677
  if (flag) {
658
678
  // 自定义结构的展示
659
679
  if (typeStr.includes('__name: "AStructure_')) {
@@ -905,6 +925,25 @@ let NaslServer = NaslServer_1 = class NaslServer {
905
925
  return null;
906
926
  }
907
927
  }
928
+ // 组件部分属性错误降级
929
+ if (concepts_1.asserts.isBindAttribute(currentNode) && concepts_1.asserts.isViewElement(currentNode.parentNode)) {
930
+ const element = currentNode.parentNode;
931
+ const tags = {
932
+ 'u-number-input': ['value', 'min', 'max'],
933
+ 'u-input': ['value'],
934
+ 'van-fieldinput': ['value'],
935
+ 'van-stepper-new': ['value', 'min', 'max'],
936
+ };
937
+ if (tags[element.tag] && tags[element.tag].includes(currentNode.name)) {
938
+ diagnostic.severity = 'warning';
939
+ if (diagnostic.node?.tsErrorDetail) {
940
+ // 重置组件节点上的错误信息
941
+ diagnostic.node.tsErrorDetail.severity = 'warning';
942
+ }
943
+ record.suggestionDiagnostics.push(diagnostic);
944
+ return null;
945
+ }
946
+ }
908
947
  while (currentNode && currentNode?.parentNode?.concept !== 'App') {
909
948
  if (currentNode.parentKey?.toLowerCase()?.includes('playground')) {
910
949
  // 草稿区降级
@@ -1541,7 +1580,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
1541
1580
  jsCode = nodeIn.toJS();
1542
1581
  }
1543
1582
  catch (err) {
1544
- self.logger.error(err);
1583
+ if (utils.isDebugMode) {
1584
+ self.logger.error(err);
1585
+ }
1545
1586
  }
1546
1587
  if (!jsCode.startsWith(`${node.name} = `))
1547
1588
  return;
@@ -1913,6 +1954,19 @@ let NaslServer = NaslServer_1 = class NaslServer {
1913
1954
  typeAnnotationErrorDetail.errorPos.scale = errorMsg;
1914
1955
  }
1915
1956
  }
1957
+ if (property.defaultValue?.expression?.concept === 'NumericLiteral') {
1958
+ const numeric = property.defaultValue.expression;
1959
+ const value = numeric.value;
1960
+ const decimalPlaces = value?.split('.')[1]?.length || 0;
1961
+ if (decimalPlaces > +scale) {
1962
+ const diag = {
1963
+ node: property,
1964
+ severity: 'error',
1965
+ message: `实体字段${property.name}默认值的小数位数不能大于设置的小数位数${scale}`,
1966
+ };
1967
+ diagnostics.push(diag);
1968
+ }
1969
+ }
1916
1970
  break;
1917
1971
  }
1918
1972
  }
@@ -2089,6 +2143,13 @@ let NaslServer = NaslServer_1 = class NaslServer {
2089
2143
  if (jsCode.startsWith(`${node.name} = `)) {
2090
2144
  used = true;
2091
2145
  if (!nodeIn.tsErrorDetail) {
2146
+ // 如果要加报错的时候,当前赋值或者批量复制,属于子逻辑的
2147
+ // 但是没有类型的参数 或者返回值,不是 属于他的
2148
+ // 就不加了,只有是子逻辑,而且是自己的参数没类型才加
2149
+ const isSubLogic = nodeIn?.getAncestor('SubLogic');
2150
+ if (isSubLogic && isSubLogic !== node.parentNode) {
2151
+ return;
2152
+ }
2092
2153
  const diagnostic = {
2093
2154
  node: nodeIn,
2094
2155
  severity: 'error',
@@ -2151,6 +2212,50 @@ let NaslServer = NaslServer_1 = class NaslServer {
2151
2212
  this.checkNodeError(node, diagnostics);
2152
2213
  });
2153
2214
  }
2215
+ else if (fileNode instanceof concepts_1.ProcessV2) {
2216
+ yield* utils.wrapIteratorToGenerator(fileNode.sourceMap.entries(), function* wrapIterator([node, value]) {
2217
+ if (node instanceof concepts_1.Return || node instanceof concepts_1.Variable) {
2218
+ const nodeTypeName = node.concept === 'Return' ? '输出参数' : '局部变量';
2219
+ if (!node.typeAnnotation && !node.__TypeAnnotation) {
2220
+ let used = false;
2221
+ fileNode?.sourceMap.forEach((valueIn, nodeIn) => {
2222
+ if (!used && nodeIn && (nodeIn instanceof concepts_1.BatchAssignment || (nodeIn instanceof concepts_1.Assignment && nodeIn.left?.name))) {
2223
+ let jsCode = '';
2224
+ try {
2225
+ jsCode = nodeIn.toJS();
2226
+ }
2227
+ catch (err) {
2228
+ self.logger.error(err);
2229
+ }
2230
+ if (jsCode.startsWith(`${node.name} = `)) {
2231
+ used = true;
2232
+ if (!nodeIn.tsErrorDetail) {
2233
+ const diagnostic = {
2234
+ node: nodeIn,
2235
+ severity: 'error',
2236
+ message: `${nodeIn.label || ''}左边 ${node.name} 未设置类型,右边必须为有返回值的内容。`,
2237
+ };
2238
+ nodeIn.tsErrorDetail = diagnostic;
2239
+ diagnostics.push(diagnostic);
2240
+ }
2241
+ }
2242
+ }
2243
+ });
2244
+ const msg = used ? '必须赋值有返回值的内容。' : '未设置类型或未赋值。直接赋值系统可以自动推断类型。';
2245
+ const diagnostic = {
2246
+ node,
2247
+ severity: 'error',
2248
+ message: `${nodeTypeName} ${node.name} ${msg}`,
2249
+ };
2250
+ node.__aStructureError = diagnostic;
2251
+ diagnostics.push(diagnostic);
2252
+ }
2253
+ else {
2254
+ node.__aStructureError = null;
2255
+ }
2256
+ }
2257
+ });
2258
+ }
2154
2259
  else if (fileNode instanceof concepts_1.Connection) {
2155
2260
  const connectorPropertyNames = NaslServer_1.getPropertyNames(fileNode);
2156
2261
  const connectionPropertyNames = NaslServer_1.getPropertyNames(fileNode?.connector);
@@ -2232,6 +2337,70 @@ let NaslServer = NaslServer_1 = class NaslServer {
2232
2337
  }
2233
2338
  });
2234
2339
  }
2340
+ // TODO need reset when process support hoc & spread param & type annotation
2341
+ const isInProcess = fileNode instanceof concepts_1.Process ||
2342
+ fileNode instanceof concepts_1.ProcessV2 ||
2343
+ !!fileNode?.getAncestor('Process') ||
2344
+ !!fileNode?.getAncestor('ProcessV2');
2345
+ if (isInProcess) {
2346
+ // 查找计算过 subLogic 的节点。(目前只有 Logic、ProcessElement、ProcessElementV2)
2347
+ let targetNode = fileNode;
2348
+ if ((0, asserts_1.isProcess)(fileNode) ||
2349
+ (0, asserts_1.isProcessV2)(fileNode)) {
2350
+ targetNode = fileNode;
2351
+ }
2352
+ else {
2353
+ targetNode = fileNode.getAncestor('Process') || fileNode.getAncestor('ProcessV2');
2354
+ }
2355
+ if (targetNode?.subLogics?.length) {
2356
+ const diagnostic = {
2357
+ node: fileNode,
2358
+ severity: 'error',
2359
+ message: `流程暂不支持子逻辑`,
2360
+ // 保留原来的内容方便查询一些问题
2361
+ originalDiagnostic: {
2362
+ fileName: '',
2363
+ start: null,
2364
+ end: null,
2365
+ category: 'error',
2366
+ text: `process not support subLogic`,
2367
+ },
2368
+ };
2369
+ diagnostics.push(diagnostic);
2370
+ }
2371
+ if (targetNode.includeSpreadCallLogic) {
2372
+ const diagnostic = {
2373
+ node: fileNode,
2374
+ severity: 'error',
2375
+ message: `流程暂不支持可变参数`,
2376
+ // 保留原来的内容方便查询一些问题
2377
+ originalDiagnostic: {
2378
+ fileName: '',
2379
+ start: null,
2380
+ end: null,
2381
+ category: 'error',
2382
+ text: `process not support spread call`,
2383
+ },
2384
+ };
2385
+ diagnostics.push(diagnostic);
2386
+ }
2387
+ if (targetNode.includeTypeArgs) {
2388
+ const diagnostic = {
2389
+ node: fileNode,
2390
+ severity: 'error',
2391
+ message: `流程暂不支持范型参数`,
2392
+ // 保留原来的内容方便查询一些问题
2393
+ originalDiagnostic: {
2394
+ fileName: '',
2395
+ start: null,
2396
+ end: null,
2397
+ category: 'error',
2398
+ text: `process not support type args`,
2399
+ },
2400
+ };
2401
+ diagnostics.push(diagnostic);
2402
+ }
2403
+ }
2235
2404
  return diagnostics;
2236
2405
  }
2237
2406
  *_treeMetadataType2CoreType(type, app) {
@@ -2527,11 +2696,26 @@ let NaslServer = NaslServer_1 = class NaslServer {
2527
2696
  }
2528
2697
  }
2529
2698
  }
2699
+ // 加上信用卡验证规则的静态检查
2700
+ if (node instanceof concepts_1.ValidationRule && node.calleeName === 'creditCard') {
2701
+ const typesArg = node.arguments?.find((arg) => {
2702
+ return arg?.keyword === 'types';
2703
+ });
2704
+ if (typesArg?.expression?.concept !== 'NewList' || !(typesArg?.expression?.items?.length)) {
2705
+ const diagnostic = {
2706
+ node: typesArg?.expression,
2707
+ severity: 'error',
2708
+ message: '至少选择1项验证信用卡',
2709
+ };
2710
+ typesArg.expression.tsErrorDetail = diagnostic;
2711
+ diagnostics.push(diagnostic);
2712
+ }
2713
+ }
2530
2714
  if (node instanceof concepts_1.CallLogic) {
2531
2715
  // 处理依赖库高阶函数,函数签名和函数调用参数要完全一一对应
2532
2716
  if (node.calleeNamespace?.startsWith('extensions.')) {
2533
2717
  const logicNode = node.getCallNode();
2534
- const params = logicNode?.params?.slice();
2718
+ const params = logicNode?.params?.slice() || [];
2535
2719
  const findFunction = params.find(param => param?.typeAnnotation?.typeKind === 'function');
2536
2720
  if (findFunction) {
2537
2721
  node.arguments?.forEach((argument, index) => {
@@ -2958,7 +3142,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
2958
3142
  }
2959
3143
  }
2960
3144
  catch (e) {
2961
- this.logger.error('naslServer实体引用', e);
3145
+ if (utils.isDebugMode) {
3146
+ this.logger.error('naslServer实体引用', e);
3147
+ }
2962
3148
  }
2963
3149
  }
2964
3150
  }
@@ -3267,8 +3453,12 @@ let NaslServer = NaslServer_1 = class NaslServer {
3267
3453
  // return null;
3268
3454
  // }
3269
3455
  }
3270
- // 如果节点是Identifier表达式
3456
+ // 如果匹配到的节点是Identifier表达式
3271
3457
  if (minRange.node instanceof concepts_1.Identifier) {
3458
+ // 如果参数修改影响了Identifier, 就说明是上一级逻辑的引用,所以就直接过滤掉就好了
3459
+ if (node instanceof concepts_1.Param && minRange.node?.namespace?.endsWith('logics')) {
3460
+ return null;
3461
+ }
3272
3462
  // 匹配到的内容,当前这一行的内容;
3273
3463
  // 因为要用下面的点位信息
3274
3464
  const { name } = minRange.node;
@@ -3378,7 +3568,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
3378
3568
  }
3379
3569
  }
3380
3570
  catch (error) {
3381
- console.error(error);
3571
+ if (utils.isDebugMode) {
3572
+ this.logger.error(error);
3573
+ }
3382
3574
  }
3383
3575
  }
3384
3576
  else if (minRange.node instanceof concepts_1.Identifier) {
@@ -3765,7 +3957,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
3765
3957
  }
3766
3958
  }
3767
3959
  catch (err) {
3768
- this.logger.error(err);
3960
+ if (utils.isDebugMode) {
3961
+ this.logger.error(err);
3962
+ }
3769
3963
  }
3770
3964
  return result;
3771
3965
  }
@@ -3790,7 +3984,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
3790
3984
  });
3791
3985
  }
3792
3986
  catch (err) {
3793
- this.logger.error(err);
3987
+ if (utils.isDebugMode) {
3988
+ this.logger.error(err);
3989
+ }
3794
3990
  }
3795
3991
  return [...result];
3796
3992
  }
@@ -4277,26 +4473,23 @@ let NaslServer = NaslServer_1 = class NaslServer {
4277
4473
  if (node instanceof concepts_1.CallLogic &&
4278
4474
  node.completeTypeParams?.length &&
4279
4475
  node?.__nodeType) {
4280
- const logicNode = node.getCallNode();
4281
4476
  const autoTypeArguments = node.__nodeType?.typeArguments || [];
4282
4477
  const newAutoTypeArguments = [...autoTypeArguments];
4283
- if (logicNode.returns?.length) {
4284
- let returnType = newAutoTypeArguments.shift();
4285
- if (node.handleError && returnType.typeName === 'Union') {
4286
- const returnTypeArguments = returnType.typeArguments || [];
4287
- const typeArguments = [...returnTypeArguments];
4288
- const errorType = typeArguments.find((t) => t.typeName === 'Error');
4289
- if (errorType) {
4290
- if (typeArguments.length === 2) {
4291
- returnType = typeArguments.filter((t) => t !== errorType)[0];
4292
- }
4293
- else {
4294
- returnType.typeArguments = typeArguments.filter((t) => t !== errorType);
4295
- }
4478
+ let returnType = newAutoTypeArguments.shift();
4479
+ if (node.handleError && returnType.typeName === 'Union') {
4480
+ const returnTypeArguments = returnType.typeArguments || [];
4481
+ const typeArguments = [...returnTypeArguments];
4482
+ const errorType = typeArguments.find((t) => t.typeName === 'Error');
4483
+ if (errorType) {
4484
+ if (typeArguments.length === 2) {
4485
+ returnType = typeArguments.filter((t) => t !== errorType)[0];
4486
+ }
4487
+ else {
4488
+ returnType.typeArguments = typeArguments.filter((t) => t !== errorType);
4296
4489
  }
4297
4490
  }
4298
- node.__TypeAnnotation = utils.runGeneratorSync((0, formatTsUtils_1.type2TypeAnnotation)(returnType));
4299
4491
  }
4492
+ node.__TypeAnnotation = utils.runGeneratorSync((0, formatTsUtils_1.type2TypeAnnotation)(returnType));
4300
4493
  const typeArgs = [];
4301
4494
  const typeArguments = node.typeArguments;
4302
4495
  node.completeTypeParams.forEach((typeArg, typeIndex) => {
@@ -4348,8 +4541,8 @@ let NaslServer = NaslServer_1 = class NaslServer {
4348
4541
  const typesMap = await this.getQuickInfoNodesTypeMap(nodes, true);
4349
4542
  const json = app.toJSON();
4350
4543
  this.logger.timeEnd('全量标注');
4351
- // 测试环境打印数据
4352
- if (utils.isTestBrowser) {
4544
+ // 测试环境或者是调试模式打印数据
4545
+ if (utils.isDebugMode || utils.isTestBrowser) {
4353
4546
  this.logger.info('全量标注数据', json);
4354
4547
  }
4355
4548
  if (releaseFlag) {
@@ -4498,8 +4691,66 @@ let NaslServer = NaslServer_1 = class NaslServer {
4498
4691
  */
4499
4692
  if (node instanceof concepts_1.CallLogic && node.__TypeArguments?.length) {
4500
4693
  const jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
4501
- jsonNode.typeArguments = node.__TypeArguments;
4502
- jsonNode.typeAnnotation = node.__TypeAnnotation;
4694
+ jsonNode.typeArguments = node.__TypeArguments.map((type) => type?.toJSON());
4695
+ jsonNode.typeAnnotation = node.__TypeAnnotation?.toJSON();
4696
+ }
4697
+ // 根据 https://projectmanage.netease-official.lcap.163yun.com/dashboard/FeatureDetail?id=2737356895760128&id1=null&iterationId=null&versionid=null&tab=info
4698
+ // 对CallFunction节点,若其callee为部分List/Map内置函数,则修改其argument类型标注以让服务端据此插入显式的类型转换。规则如下:
4699
+ // - 对argument.expression.typeAnnotation 无需做修改,保持为其实际类型
4700
+ // - 对argument.typeAnnotation,为根据对应Collection的泛型参数的类型填写其类型
4701
+ if (node instanceof concepts_1.CallFunction) {
4702
+ if (node.calleeNamespace === 'nasl.util') {
4703
+ const calleeName = node.calleeName;
4704
+ const listFunctionParamIndexMaps = new Map(Object.entries({
4705
+ Add: { collection: 0, item: 1 },
4706
+ Insert: { collection: 0, item: 2 },
4707
+ Remove: { collection: 0, item: 1 },
4708
+ Contains: { collection: 0, item: 1 },
4709
+ }));
4710
+ const mapFunctionParamIndexMaps = new Map(Object.entries({
4711
+ MapPut: { collection: 0, key: 1, value: 2 },
4712
+ MapGet: { collection: 0, key: 1, },
4713
+ MapRemove: { collection: 0, key: 1 },
4714
+ MapContains: { collection: 0, key: 1 },
4715
+ }));
4716
+ const listParamIndex = listFunctionParamIndexMaps.get(calleeName);
4717
+ if (listParamIndex) {
4718
+ const list = node.arguments[listParamIndex.collection];
4719
+ const item = node.arguments[listParamIndex.item];
4720
+ const itemExpression = item?.expression;
4721
+ if (itemExpression) {
4722
+ const listTypeArgument = list.__TypeAnnotation?.typeArguments?.[0]?.toJSON();
4723
+ if (listTypeArgument) {
4724
+ const jsonNode = jsoner.queryNodeByPath(json, item.getNodePath(false));
4725
+ jsonNode.typeAnnotation = listTypeArgument;
4726
+ }
4727
+ }
4728
+ }
4729
+ else {
4730
+ const mapParamIndex = mapFunctionParamIndexMaps.get(calleeName);
4731
+ if (mapParamIndex) {
4732
+ const map = node.arguments[mapParamIndex.collection];
4733
+ const key = node.arguments[mapParamIndex.key];
4734
+ const value = node.arguments[mapParamIndex.value];
4735
+ const keyExpression = key?.expression;
4736
+ const valueExpression = value?.expression;
4737
+ if (keyExpression) {
4738
+ const mapKeyTypeArgument = map.__TypeAnnotation?.typeArguments?.[0]?.toJSON();
4739
+ if (mapKeyTypeArgument) {
4740
+ const jsonNode = jsoner.queryNodeByPath(json, key.getNodePath(false));
4741
+ jsonNode.typeAnnotation = mapKeyTypeArgument;
4742
+ }
4743
+ }
4744
+ if (valueExpression) {
4745
+ const mapValueTypeArgument = map.__TypeAnnotation?.typeArguments?.[1]?.toJSON();
4746
+ if (mapValueTypeArgument) {
4747
+ const jsonNode = jsoner.queryNodeByPath(json, value.getNodePath(false));
4748
+ jsonNode.typeAnnotation = mapValueTypeArgument;
4749
+ }
4750
+ }
4751
+ }
4752
+ }
4753
+ }
4503
4754
  }
4504
4755
  }
4505
4756
  // 服务端需要默认值节点有类型来判断父节点是否是日期类型
@@ -4558,7 +4809,9 @@ let NaslServer = NaslServer_1 = class NaslServer {
4558
4809
  }
4559
4810
  return new Promise((resolve, reject) => {
4560
4811
  const myTimer = setTimeout(() => {
4561
- this.logger.warn(node, '没有获取到类型');
4812
+ if (utils.isDebugMode) {
4813
+ this.logger.warn(node, '没有获取到类型');
4814
+ }
4562
4815
  clearTimeout(myTimer);
4563
4816
  clearInterval(mySetInterval);
4564
4817
  if (node.__isCorrectTypeAnnotation) {