@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
@@ -536,39 +536,18 @@ export class BindEvent extends BaseNode {
536
536
  if (logic.name.startsWith('__')) {
537
537
  return;
538
538
  }
539
- if (logic.view) {
540
- const logicName = logic.name;
541
- if ((logic.parentNode as BindEvent)?.element) {
542
- logic.name = '__' + logic.view.name + (logic.parentNode as BindEvent).element.name + logic.name;
543
- }
544
- logic.name = logic.name.replace(/-/g, '');
545
- try {
546
- code += yield* logic.toEmbeddedTS(
547
- shiftState(state, code, {
548
- tabSize: (state?.tabSize || 0) + 2,
549
- }),
550
- 'noExport',
551
- );
552
- } finally {
553
- // 翻译logic可能出错
554
- logic.name = logicName;
555
- }
556
- } else {
557
- code += yield* logic.toEmbeddedTS(
558
- shiftState(state, code, {
559
- tabSize: (state?.tabSize || 0) + 2,
560
- }),
561
- 'noExport',
562
- );
563
- }
539
+ code += yield* logic.toEmbeddedTS(
540
+ shiftState(state, code, {
541
+ tabSize: (state?.tabSize || 0) + 2,
542
+ }),
543
+ 'noExport',
544
+ );
564
545
  code += indent(state?.tabSize || 0);
565
546
  code += ',\n';
566
547
  });
567
548
  code += '];\n';
568
549
  } else {
569
550
  yield* wrapForEach(self.logics, function* warpForEachGenerator(logic, index) {
570
- const logicName = logic.name;
571
- logic.name = logic.likeComponent.name + logic.name + index;
572
551
  code += yield* logic.toEmbeddedTS(
573
552
  shiftState(state, code, {
574
553
  tabSize: (state?.tabSize || 0) + 2,
@@ -576,8 +555,7 @@ export class BindEvent extends BaseNode {
576
555
  'noExport',
577
556
  );
578
557
  code += indent(state?.tabSize || 0);
579
- code += `${logic.name}();\n`;
580
- logic.name = logicName;
558
+ code += `${logic.tsName}();\n`;
581
559
  });
582
560
  }
583
561
  return code;
@@ -598,24 +576,7 @@ export class BindEvent extends BaseNode {
598
576
  if (logic.name.startsWith('__')) {
599
577
  return;
600
578
  }
601
- if (logic.view) {
602
- const logicName = logic.name;
603
- if ((logic.parentNode as BindEvent)?.element) {
604
- logic.name = '__' + logic.view.name + (logic.parentNode as BindEvent).element.name + logic.name;
605
- }
606
- logic.name = logic.name.replace(/-/g, '');
607
- try {
608
- code += yield* logic.toEmbeddedTS(
609
- shiftState(state, code, {
610
- tabSize: (state?.tabSize || 0) + 2,
611
- }),
612
- 'noExport',
613
- );
614
- } finally {
615
- // 翻译logic可能出错
616
- logic.name = logicName;
617
- }
618
- } else if (logic.processV2) {
579
+ if (logic.processV2) {
619
580
  code += yield* logic.toEmbeddedTSInProcess(
620
581
  shiftState(state, code, {
621
582
  tabSize: (state?.tabSize || 0) + 2,
@@ -1841,6 +1841,10 @@ export class BusinessComponent extends BaseNode {
1841
1841
  const calleeLogic = (this.getAncestor('App') as App).logics.find((l) => l.name === calleeName);
1842
1842
  return calleeLogic ? `app.logics.${calleeName}(${calleeLogic.params.map(() => 'null').join(',')})` : null;
1843
1843
  }
1844
+ // 调用依赖库逻辑可能会有子逻辑,子逻辑拼接可能有ts忽略先去掉
1845
+ if (asserts.isCallLogic(rightNode) && rightNode.calleeNamespace?.startsWith('extensions.')) {
1846
+ code = code.replaceAll('// @ts-ignore', '');
1847
+ }
1844
1848
 
1845
1849
  // view 局部变量,申明提升前增加判断,使用 logic 内的 result 直接替换成对应 logic,logic 内部变量替换成 null
1846
1850
  if (logicRtn && code.includes(logicRtn.name)) {
@@ -2004,6 +2008,9 @@ export class BusinessComponent extends BaseNode {
2004
2008
  // 内置函数对集合类型的推导
2005
2009
  (asserts.isCallFunction(el) && el.derivablecollection?.name))
2006
2010
  ) {
2011
+ if (el?.getAncestor('SubLogic')) {
2012
+ return;
2013
+ }
2007
2014
  if (asserts.isAssignment(el)) {
2008
2015
  const advanceVar = self.variables?.find(
2009
2016
  (variable) => !variable.typeAnnotation && el.left?.name === variable.name,
@@ -2458,6 +2465,16 @@ export class BusinessComponent extends BaseNode {
2458
2465
  });
2459
2466
  return Array.from(res);
2460
2467
  }
2468
+
2469
+ getViewCallLogics(): string[] {
2470
+ const callbackLogics: string[] = [];
2471
+ this.traverseChildren((el) => {
2472
+ if (asserts.isIdentifier(el) && el.namespace?.endsWith('logics')) {
2473
+ callbackLogics.push(`${el.namespace}.${el.name}`);
2474
+ }
2475
+ });
2476
+ return callbackLogics;
2477
+ }
2461
2478
  //================================================================================
2462
2479
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
2463
2480
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -145,6 +145,9 @@ export class BusinessLogic extends Logic {
145
145
  // 内置函数对集合类型的推导
146
146
  (asserts.isCallFunction(el) && el.derivablecollection?.name))
147
147
  ) {
148
+ if (el?.getAncestor('SubLogic')) {
149
+ return;
150
+ }
148
151
  if (asserts.isAssignment(el)) {
149
152
  const advanceVar = self.variables?.find(
150
153
  (variable) => !variable.typeAnnotation && el.left?.name === variable.name,
@@ -98,7 +98,7 @@ export class CallConnector extends CallLogic {
98
98
  if (this.calleeConnectionName) {
99
99
  let tsName = this.calleeConnectionName;
100
100
  // 匹配所有特殊字符都转为_
101
- tsName = tsName.replace(/\W/g, '_');
101
+ tsName = tsName.replace(/[^\w\u4e00-\u9fa5]/g, '_');
102
102
  if (/^\d/.test(tsName)) {
103
103
  tsName = `$${tsName}`;
104
104
  }
@@ -690,7 +690,7 @@ export class CallFunction extends LogicItem {
690
690
  if (!arg) {
691
691
  code += '__IDENTIFIER__';
692
692
  } else {
693
- code += arg.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 }));
693
+ code += indent(state.tabSize + 1) + arg.toNaturalTS(shiftState(state, code, { inline: true, tabSize: state.tabSize + 1 }));
694
694
  }
695
695
  if (index !== this.arguments.length - 1) {
696
696
  code += ',\n';
@@ -25,6 +25,7 @@ import {
25
25
  import type { ViewElement, ElementToVueOptions } from './ViewElement__';
26
26
  import type { MemberExpression } from './MemberExpression__';
27
27
  import type { StringLiteral } from './StringLiteral__';
28
+ import type { TypeParam } from './TypeParam__';
28
29
 
29
30
  //================================================================================
30
31
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -965,7 +966,7 @@ export class CallLogic extends LogicItem {
965
966
  if (isSpreadFunc) {
966
967
  spreadParams = formatArgs.pop();
967
968
  }
968
- const argsStr = formatArgs
969
+ const filterArgs = formatArgs
969
970
  .map((arg, index) => {
970
971
  const actualArg = completeArguments[index];
971
972
  const keyword = arg?.name;
@@ -976,10 +977,18 @@ export class CallLogic extends LogicItem {
976
977
  })
977
978
  .filter((item) => {
978
979
  return isShowArgument(item.arg);
979
- })
980
+ });
981
+ const argsStr = filterArgs
980
982
  .map((obj) => `\n${obj?.keyword}: ${obj?.arg?.toJS(state)}`)
981
983
  .join(', ');
984
+
982
985
  code += argsStr;
986
+ // 如果参数长度不为 0,则表示有参数,需要添加逗号
987
+ // 放弃开头加逗号的写法,因为这样会导致参数为空的时候,会多一个逗号
988
+ // https://projectmanage.netease-official.lcap.163yun.com/dashboard/BugDetail?id=2851152441926912
989
+ if (filterArgs.length) {
990
+ code += ', ';
991
+ }
983
992
  // 如果是可变参数,需要单独处理
984
993
  if (isSpreadFunc) {
985
994
  const spreadArg = completeArguments.slice(formatArgs.length);
@@ -989,11 +998,11 @@ export class CallLogic extends LogicItem {
989
998
  })
990
999
  .map((arg) => arg?.toJS?.(state) || '')
991
1000
  .join(', ');
992
- code += `,\n${spreadParams.name}: [${spreadArgStr}]`;
1001
+ code += `\n${spreadParams.name}: [${spreadArgStr}], `;
993
1002
  }
994
1003
 
995
1004
  if (Array.isArray(completeTypeArguments) && completeTypeArguments.length) {
996
- code += `,\n__typeArguments: ${JSON5.stringify(completeTypeArguments)}`;
1005
+ code += `\n__typeArguments: ${JSON5.stringify(completeTypeArguments)}`;
997
1006
  }
998
1007
  }
999
1008
  code += '\n}';
@@ -1320,21 +1329,21 @@ export class CallLogic extends LogicItem {
1320
1329
  // 统一处理需要有泛型的 调用逻辑,其余的走老逻辑
1321
1330
  if (completeTypeParams.length) {
1322
1331
  code += '(() =>{';
1323
- code += '\nconst genericWrapper = ';
1332
+ code += '\nconst __genericWrapper = ';
1324
1333
  code += calleeKey;
1325
1334
  yield* setInputParam();
1326
- code += ';\nconst warpperRes =';
1327
- code += 'genericWrapper';
1335
+ code += ';\nconst __warpperRes =';
1336
+ code += '__genericWrapper';
1328
1337
  yield* setNeedCompleteTypeArguments();
1329
- code += '();\nconst wrapper =';
1338
+ code += '();\nconst __wrapper =';
1330
1339
  if (handleError) {
1331
1340
  code += 'nasl.util.autoTypeHandleError(';
1332
1341
  }
1333
- code += 'warpperRes[0]';
1342
+ code += '__warpperRes[0]';
1334
1343
  if (handleError) {
1335
1344
  code += ')';
1336
1345
  }
1337
- code += ';\nreturn wrapper';
1346
+ code += ';\nreturn __wrapper';
1338
1347
  code += ';\n})()';
1339
1348
  setEndSemi();
1340
1349
  return code;
@@ -1363,7 +1372,7 @@ export class CallLogic extends LogicItem {
1363
1372
  }
1364
1373
 
1365
1374
  if (!state.callLogicNoIife && useIife) {
1366
- code += '(() =>{\nconst wrapper = ';
1375
+ code += '(() =>{\nconst __wrapper = ';
1367
1376
  if (handleError) {
1368
1377
  code += 'nasl.util.autoHandleError(';
1369
1378
  }
@@ -1382,7 +1391,7 @@ export class CallLogic extends LogicItem {
1382
1391
  if (handleError) {
1383
1392
  code += ')';
1384
1393
  }
1385
- code += ';\nreturn wrapper';
1394
+ code += ';\nreturn __wrapper';
1386
1395
  yield* setInputParam();
1387
1396
  code += ';\n})()';
1388
1397
  } else {
@@ -1430,8 +1439,8 @@ export class CallLogic extends LogicItem {
1430
1439
 
1431
1440
  let code = '';
1432
1441
  let calleeKey = this.calleeKey.replace('__elements', '$refs');
1433
- if (/^app.+?\.entities\..+?logics/.test(calleeKey))
1434
- calleeKey = calleeKey.replace(/^app.+?\.entities\.(.+?)\.logics/, '$1Entity');
1442
+ // if (/^app.+?\.entities\..+?logics/.test(calleeKey))
1443
+ // calleeKey = calleeKey.replace(/^app.+?\.entities\.(.+?)\.logics/, '$1Entity');
1435
1444
  /** 设置函数范型参数 */
1436
1445
  const setTypeArguments = () => {
1437
1446
  if (Array.isArray(typeArguments) && typeArguments.length) {
@@ -1612,7 +1621,14 @@ export class CallLogic extends LogicItem {
1612
1621
  const characterOffset = 7;
1613
1622
  const code = getCode();
1614
1623
  const lines = code.split('\n');
1615
- const lineOffset = lines.findIndex((item) => item.startsWith('const warpperRes'));
1624
+ let lineOffset = 0;
1625
+ // nasl的 check 不让用 findLastIndex,自己写个for循环
1626
+ for (let i = lines.length - 1; i >= 0; i--) {
1627
+ if (lines[i]?.startsWith('const __warpperRes')) {
1628
+ lineOffset = i;
1629
+ break;
1630
+ }
1631
+ }
1616
1632
  return {
1617
1633
  line: range.start.line + lineOffset + 1,
1618
1634
  offset: characterOffset,
@@ -1621,7 +1637,7 @@ export class CallLogic extends LogicItem {
1621
1637
  const characterOffset = 8;
1622
1638
  const code = getCode();
1623
1639
  const lines = code.split('\n');
1624
- const lineOffset = lines.findIndex((item) => item.startsWith('return wrapper'));
1640
+ const lineOffset = lines.findIndex((item) => item.startsWith('return __wrapper'));
1625
1641
 
1626
1642
  return {
1627
1643
  line: range.start.line + lineOffset + 1,
@@ -1631,7 +1647,19 @@ export class CallLogic extends LogicItem {
1631
1647
  // 怕改坏其他地方,业务组件单独处理
1632
1648
  return getBusinessComponentCallExpressionQuickInfo(range, getCode);
1633
1649
  } else {
1634
- return getCallExpressionQuickInfo(range, getCode);
1650
+ const result = getCallExpressionQuickInfo(range, getCode);
1651
+ let code = getCode();
1652
+ if(code.includes('__elements.')){
1653
+ const prefixOffset = code.indexOf('__elements.');
1654
+ code = code.slice(prefixOffset);
1655
+ let indexOf = code.indexOf('(');
1656
+ const subStr = code.substring(0, indexOf);
1657
+ const codeArr = subStr?.split('.');
1658
+ const lastLen = codeArr?.[codeArr.length - 1]?.length;
1659
+ indexOf = subStr.length - lastLen;
1660
+ result.offset = result.offset + prefixOffset + indexOf;
1661
+ }
1662
+ return result;
1635
1663
  }
1636
1664
  }
1637
1665
 
@@ -1712,6 +1740,24 @@ export class CallLogic extends LogicItem {
1712
1740
  }
1713
1741
  return this.typeArguments;
1714
1742
  }
1743
+
1744
+ /**
1745
+ * 获取需要用户手动选择的参数列表 的原始范型参数
1746
+ */
1747
+ get needCompleteTypeArgumentGenerics() {
1748
+ if (this.completeTypeParams?.length) {
1749
+ const typeParams: TypeParam[] = [];
1750
+ this.completeTypeParams.forEach((typeParam, typeIndex) => {
1751
+ if (typeParam.needChoose && this.typeArguments?.[typeIndex]) {
1752
+ typeParams.push(typeParam);
1753
+ }
1754
+ });
1755
+ return typeParams;
1756
+ }
1757
+ return [];
1758
+ }
1759
+
1760
+
1715
1761
  static isSystem(node: CallLogic) {
1716
1762
  // 如此处需要更新,则需同时更新 menu-poppup 组件下的 includesSystemLogic 校验逻辑
1717
1763
  return ['nasl.process', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.io'].includes(
@@ -375,6 +375,22 @@ export class Connection extends BaseNode {
375
375
  };
376
376
  }
377
377
 
378
+ /**
379
+ * 获取当前的TsName
380
+ */
381
+ get tsName() {
382
+ if (this.name) {
383
+ let tsName = this.name;
384
+ // 匹配所有非数字、字母、中文字符都转为_
385
+ tsName = tsName.replace(/[^\w\u4e00-\u9fa5]/g, '_');
386
+ if (/^\d/.test(tsName)) {
387
+ tsName = `$${tsName}`;
388
+ }
389
+ return tsName;
390
+ }
391
+ return '';
392
+ }
393
+
378
394
  @withSourceMapGenerator
379
395
  *toEmbeddedTS(
380
396
  state = createCompilerState(),
@@ -62,7 +62,18 @@ export class DatabaseTypeAnnotation extends BaseNode {
62
62
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
63
63
  // 自动生成的代码已结束。下面可以手动编写。
64
64
  //================================================================================
65
+ @withSourceMap()
66
+ toNaturalTS(state = createCompilerState()): string {
67
+ return '';
68
+ }
65
69
 
70
+ @withSourceMap()
71
+ toTextualNASL(state = createCompilerState()): string {
72
+ let code = createDecoratorCode(state, this, ['typeName', 'arguments'], {
73
+ concept: true,
74
+ });
75
+ return code;
76
+ }
66
77
  //================================================================================
67
78
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
68
79
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -108,6 +108,9 @@ export class End extends LogicItem {
108
108
  case 'OverriddenLogic':
109
109
  ret = self.OverriddenLogic.returns[0];
110
110
  break;
111
+ case 'SubLogic':
112
+ ret = self.parentNode?.returns?.[0];
113
+ break;
111
114
  default:
112
115
  // 旧逻辑默认走这里,
113
116
  // 期望后期可以直接走完整的case, default 直接抛出异常好更明确定位错误
@@ -116,7 +119,8 @@ export class End extends LogicItem {
116
119
  self.parentNode.getAncestor('Logic') ||
117
120
  self.parentNode.getAncestor('AuthLogic') ||
118
121
  self.parentNode.getAncestor('AuthLogicForCallInterface') ||
119
- self.parentNode.getAncestor('OverriddenLogic');
122
+ self.parentNode.getAncestor('OverriddenLogic') ||
123
+ self.parentNode.getAncestor('SubLogic');
120
124
  ret = (logic as Logic).returns[0];
121
125
  }
122
126
  if (ret && self.parentNode.concept === 'AuthLogicForCallInterface') {
@@ -10,6 +10,7 @@ import {
10
10
  withGenerator,
11
11
  TranslatorGenerator,
12
12
  createDecoratorCode,
13
+ createDescriptionComment,
13
14
  } from '../translator';
14
15
  import type CallQueryComponent from './CallQueryComponent__';
15
16
 
@@ -477,6 +478,10 @@ export class EntityProperty extends BaseNode {
477
478
  @withSourceMap()
478
479
  toNaturalTS(state = createCompilerState()): string {
479
480
  let code = '';
481
+
482
+ if (state.descriptionComment)
483
+ code += createDescriptionComment(state, this, ['label', 'description']);
484
+
480
485
  if (this.relationNamespace && this.relationEntity && this.relationProperty) {
481
486
  code += `@EntityRelation(() => new ${this.relationEntity}().${this.relationProperty})\n`;
482
487
  code += indent(state.tabSize);
@@ -11,12 +11,15 @@ import {
11
11
  withGenerator,
12
12
  TranslatorGenerator,
13
13
  createDecoratorCode,
14
+ createDescriptionComment,
14
15
  } from '../translator';
15
16
  import { entity2LogicNamespace } from '../server/entity2LogicNamespace';
16
17
  import type CallQueryComponent from './CallQueryComponent__';
17
18
  import Module from './Module__';
18
19
  import DataSource from './DataSource__';
19
20
  import View from './View__';
21
+ import ProcessV2 from './ProcessV2__';
22
+
20
23
  //================================================================================
21
24
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
22
25
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -837,7 +840,11 @@ export class Entity extends Annotatable {
837
840
 
838
841
  @withSourceMap()
839
842
  toNaturalTS(state = createCompilerState(), entityName?: string): string {
840
- let code = `class ${this?.name} {\n`;
843
+ let code = '';
844
+ if (state.descriptionComment)
845
+ code += createDescriptionComment(state, this, ['description']);
846
+ code = `class ${this?.name} {\n`;
847
+
841
848
  this.properties.forEach((property) => {
842
849
  code += `${property.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 }))};\n`;
843
850
  });
@@ -961,6 +968,27 @@ export class Entity extends Annotatable {
961
968
  });
962
969
  return res;
963
970
  }
971
+
972
+ syncProcessPermission(propertyNames: string[]) {
973
+ const path = `${this.ns?.path}.${this.name}`
974
+ const bindProcessV2s = this.app?.processV2s.filter((processV2) => `${processV2.bind.refNamespace}.${processV2.bind.refName}` === path) || []
975
+ bindProcessV2s.forEach((processV2) => {
976
+ processV2.elements.forEach((ele) => {
977
+ if (['InitiateTask', 'ApprovalTask'].includes(ele.type)) {
978
+ const fieldPermissions = propertyNames.map((propertyName: string) => {
979
+ return {
980
+ concept: 'FieldPermissionV2',
981
+ propertyName,
982
+ permission: 'hidden',
983
+ }
984
+ })
985
+ ele.update({
986
+ fieldPermissions: [...ele.fieldPermissions, ...fieldPermissions]
987
+ })
988
+ }
989
+ })
990
+ })
991
+ }
964
992
  //================================================================================
965
993
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
966
994
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -8,6 +8,7 @@ import {
8
8
  TranslatorGenerator,
9
9
  indent,
10
10
  createDecoratorCode,
11
+ createDescriptionComment,
11
12
  } from '../translator';
12
13
  import type Namespace from './Namespace__';
13
14
  import Enum from './Enum__';
@@ -106,6 +107,62 @@ export class EnumItem extends BaseNode {
106
107
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
107
108
  // 自动生成的代码已结束。下面可以手动编写。
108
109
  //================================================================================
110
+ /**
111
+ * 删除静态字符串
112
+ * @param name 静态字符串名称
113
+ */
114
+ removeLabel(name: string): void;
115
+
116
+ /**
117
+ * 删除静态字符串
118
+ * @param label 已有的静态字符串实例
119
+ */
120
+ removeLabel(label: StaticString): void;
121
+
122
+ removeLabel(options: string | StaticString) {
123
+ let label: StaticString;
124
+ if (typeof options === 'string') {
125
+ label = this.label;
126
+ if (!label) {
127
+ throw new Error('找不到静态字符串 ' + options);
128
+ }
129
+ } else {
130
+ label = options;
131
+ }
132
+ return label.delete();
133
+ }
134
+
135
+ __removeStaticString(staticString: StaticString) {
136
+ const parentKey = staticString.parentKey;
137
+ const params: Params = {
138
+ parentNode: this,
139
+ parentKey,
140
+ index: -1,
141
+ object: null,
142
+ oldObject: staticString,
143
+ };
144
+ if (parentKey) {
145
+ params.parentKey = parentKey;
146
+ // @ts-ignore
147
+ const t = this.__v_raw || this;
148
+ // @ts-ignore
149
+ const n = staticString.__v_raw || staticString;
150
+ if (Array.isArray((t as any)[parentKey])) {
151
+ // @ts-ignore
152
+ const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
153
+ ~index && (this as any)[parentKey].splice(index, 1);
154
+ params.index = index;
155
+ } else {
156
+ const q = (t as any)[parentKey];
157
+ if ((q.__v_raw || q) === n) {
158
+ params.index = 0;
159
+ (this as any)[parentKey] = undefined;
160
+ }
161
+ }
162
+ }
163
+ return params;
164
+ }
165
+
109
166
  /**
110
167
  * 祖先 Enum
111
168
  */
@@ -151,7 +208,13 @@ export class EnumItem extends BaseNode {
151
208
 
152
209
  @withSourceMap()
153
210
  toNaturalTS(state = createCompilerState()): string {
154
- return `'${this.value}' = '${this.label?.value}'`;
211
+ let code = '';
212
+
213
+ if (state.descriptionComment)
214
+ code += createDescriptionComment(state, this, ['label']);
215
+ code += `'${this.value}' = '${this.label?.value}'`;
216
+
217
+ return code;
155
218
  }
156
219
 
157
220
  @withSourceMap()
@@ -10,6 +10,7 @@ import {
10
10
  withGenerator,
11
11
  TranslatorGenerator,
12
12
  createDecoratorCode,
13
+ createDescriptionComment,
13
14
  } from '../translator';
14
15
  import type Namespace from './Namespace__';
15
16
  import type Identifier from './Identifier__';
@@ -317,7 +318,11 @@ export class Enum extends BaseNode {
317
318
 
318
319
  @withSourceMap()
319
320
  toNaturalTS(state = createCompilerState()): string {
320
- let code = `enum ${this.name} {\n`;
321
+ let code = '';
322
+ if (state.descriptionComment)
323
+ code += createDescriptionComment(state, this, ['label', 'description']);
324
+
325
+ code += `enum ${this.name} {\n`;
321
326
  this.enumItems.forEach((item) => {
322
327
  code += indent(state.tabSize + 1);
323
328
  code += item.toNaturalTS(shiftState(state, code, { tabSize: 0 }));
@@ -472,7 +472,7 @@ export class ForEachStatement extends LogicItem {
472
472
  if (state?.focusedNodePath === `${this?.nodePath}.body[${this.body?.length}]`)
473
473
  code += `${indent((state?.tabSize || 0) + 1)}/* 当前位置 */\n`;
474
474
 
475
- code += `${indent(state.tabSize)}\n}\n`;
475
+ code += `${indent(state.tabSize)}}\n`;
476
476
 
477
477
  return code;
478
478
  }