@lcap/nasl 4.4.0-beta.3 → 4.4.0-beta.30

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 (268) hide show
  1. package/out/generator/genBundleFiles.d.ts +2 -0
  2. package/out/generator/genBundleFiles.d.ts.map +1 -1
  3. package/out/generator/genBundleFiles.js +77 -12
  4. package/out/generator/genBundleFiles.js.map +1 -1
  5. package/out/generator/icestark.d.ts +1 -1
  6. package/out/generator/icestark.d.ts.map +1 -1
  7. package/out/generator/icestark.js +6 -1
  8. package/out/generator/icestark.js.map +1 -1
  9. package/out/generator/qiankun.d.ts +1 -1
  10. package/out/generator/qiankun.d.ts.map +1 -1
  11. package/out/generator/qiankun.js +9 -3
  12. package/out/generator/qiankun.js.map +1 -1
  13. package/out/generator/release-body/body.d.ts +0 -1
  14. package/out/generator/release-body/body.d.ts.map +1 -1
  15. package/out/generator/release-body/body.js +1 -390
  16. package/out/generator/release-body/body.js.map +1 -1
  17. package/out/generator/release-body/data.d.ts.map +1 -1
  18. package/out/generator/release-body/data.js +38 -11
  19. package/out/generator/release-body/data.js.map +1 -1
  20. package/out/generator/release-body/internal.d.ts +1 -0
  21. package/out/generator/release-body/internal.d.ts.map +1 -1
  22. package/out/generator/release-body/internal.js.map +1 -1
  23. package/out/generator/release-body/share-content.js +1 -1
  24. package/out/generator/release-body/share-content.js.map +1 -1
  25. package/out/generator/release-body/types.d.ts +2 -0
  26. package/out/generator/release-body/types.d.ts.map +1 -1
  27. package/out/generator/release-body/utils.d.ts +1 -0
  28. package/out/generator/release-body/utils.d.ts.map +1 -1
  29. package/out/generator/release-body/utils.js +2 -1
  30. package/out/generator/release-body/utils.js.map +1 -1
  31. package/out/generator/templates/chunk.js +1 -1
  32. package/out/generator/templates/runtime.js +2 -2
  33. package/out/generator/wujie.d.ts +1 -1
  34. package/out/generator/wujie.d.ts.map +1 -1
  35. package/out/generator/wujie.js +6 -1
  36. package/out/generator/wujie.js.map +1 -1
  37. package/out/natural/exports/nasl2Files.d.ts +34 -0
  38. package/out/natural/exports/nasl2Files.d.ts.map +1 -0
  39. package/out/natural/exports/nasl2Files.js +237 -0
  40. package/out/natural/exports/nasl2Files.js.map +1 -0
  41. package/out/natural/{transform2BatchActions.d.ts → exports/transform2BatchActions.d.ts} +20 -2
  42. package/out/natural/exports/transform2BatchActions.d.ts.map +1 -0
  43. package/out/natural/exports/transform2BatchActions.js +1233 -0
  44. package/out/natural/exports/transform2BatchActions.js.map +1 -0
  45. package/out/natural/index.d.ts +12 -12
  46. package/out/natural/index.d.ts.map +1 -1
  47. package/out/natural/index.js +12 -14
  48. package/out/natural/index.js.map +1 -1
  49. package/out/natural/{genNaturalTS.d.ts → old/getContext/genNaturalTS.d.ts} +12 -12
  50. package/out/natural/old/getContext/genNaturalTS.d.ts.map +1 -0
  51. package/out/natural/{genNaturalTS.js → old/getContext/genNaturalTS.js} +65 -65
  52. package/out/natural/old/getContext/genNaturalTS.js.map +1 -0
  53. package/out/natural/old/getContext/genTextualNASL.d.ts.map +1 -0
  54. package/out/natural/old/getContext/genTextualNASL.js.map +1 -0
  55. package/out/natural/{getContext → old/getContext}/getUILib.d.ts +1 -1
  56. package/out/natural/old/getContext/getUILib.d.ts.map +1 -0
  57. package/out/natural/{getContext → old/getContext}/getUILib.js +14 -14
  58. package/out/natural/old/getContext/getUILib.js.map +1 -0
  59. package/out/natural/{getContext → old/getContext}/index.d.ts +3 -3
  60. package/out/natural/old/getContext/index.d.ts.map +1 -0
  61. package/out/natural/{getContext → old/getContext}/index.js +4 -4
  62. package/out/natural/old/getContext/index.js.map +1 -0
  63. package/out/natural/old/getContext/naslStdlibMap.d.ts.map +1 -0
  64. package/out/natural/{getContext → old/getContext}/naslStdlibMap.js +10 -10
  65. package/out/natural/old/getContext/naslStdlibMap.js.map +1 -0
  66. package/out/natural/{transformTS2UI.d.ts → old/parser/transformTS2UI.d.ts} +2 -2
  67. package/out/natural/old/parser/transformTS2UI.d.ts.map +1 -0
  68. package/out/natural/{transformTS2UI.js → old/parser/transformTS2UI.js} +13 -14
  69. package/out/natural/old/parser/transformTS2UI.js.map +1 -0
  70. package/out/natural/{transformTSCode.d.ts → old/parser/transformTSCode.d.ts} +1 -1
  71. package/out/natural/old/parser/transformTSCode.d.ts.map +1 -0
  72. package/out/natural/{transformTSCode.js → old/parser/transformTSCode.js} +32 -8
  73. package/out/natural/old/parser/transformTSCode.js.map +1 -0
  74. package/out/natural/{tools.d.ts → old/tools.d.ts} +0 -4
  75. package/out/natural/old/tools.d.ts.map +1 -0
  76. package/out/natural/{tools.js → old/tools.js} +7 -25
  77. package/out/natural/old/tools.js.map +1 -0
  78. package/out/natural/{parseNaturalTS.d.ts → parser/parseNaturalTS.d.ts} +9 -2
  79. package/out/natural/parser/parseNaturalTS.d.ts.map +1 -0
  80. package/out/natural/{parseNaturalTS.js → parser/parseNaturalTS.js} +119 -38
  81. package/out/natural/parser/parseNaturalTS.js.map +1 -0
  82. package/out/natural/{parseNaturalTSXView.d.ts → parser/parseNaturalTSXView.d.ts} +1 -2
  83. package/out/natural/parser/parseNaturalTSXView.d.ts.map +1 -0
  84. package/out/natural/{parseNaturalTSXView.js → parser/parseNaturalTSXView.js} +181 -139
  85. package/out/natural/parser/parseNaturalTSXView.js.map +1 -0
  86. package/out/natural/transforms/checker/checkDataQueryCalleeNameOrder.d.ts +7 -0
  87. package/out/natural/transforms/checker/checkDataQueryCalleeNameOrder.d.ts.map +1 -0
  88. package/out/natural/transforms/checker/checkDataQueryCalleeNameOrder.js +38 -0
  89. package/out/natural/transforms/checker/checkDataQueryCalleeNameOrder.js.map +1 -0
  90. package/out/natural/transforms/checker/checkDefaultValue.d.ts +14 -0
  91. package/out/natural/transforms/checker/checkDefaultValue.d.ts.map +1 -0
  92. package/out/natural/transforms/checker/checkDefaultValue.js +39 -0
  93. package/out/natural/transforms/checker/checkDefaultValue.js.map +1 -0
  94. package/out/natural/transforms/checker/checkLcapEntity.d.ts +16 -0
  95. package/out/natural/transforms/checker/checkLcapEntity.d.ts.map +1 -0
  96. package/out/natural/transforms/checker/checkLcapEntity.js +337 -0
  97. package/out/natural/transforms/checker/checkLcapEntity.js.map +1 -0
  98. package/out/natural/transforms/checker/checkValidationCalleeName.d.ts +3 -0
  99. package/out/natural/transforms/checker/checkValidationCalleeName.d.ts.map +1 -0
  100. package/out/natural/transforms/checker/checkValidationCalleeName.js +88 -0
  101. package/out/natural/transforms/checker/checkValidationCalleeName.js.map +1 -0
  102. package/out/natural/transforms/checker/checkViewElement.d.ts +29 -0
  103. package/out/natural/transforms/checker/checkViewElement.d.ts.map +1 -0
  104. package/out/natural/transforms/checker/checkViewElement.js +618 -0
  105. package/out/natural/transforms/checker/checkViewElement.js.map +1 -0
  106. package/out/natural/transforms/checker/index.d.ts +19 -0
  107. package/out/natural/transforms/checker/index.d.ts.map +1 -0
  108. package/out/natural/transforms/checker/index.js +30 -0
  109. package/out/natural/transforms/checker/index.js.map +1 -0
  110. package/out/natural/transforms/transform2Entity.d.ts +13 -1
  111. package/out/natural/transforms/transform2Entity.d.ts.map +1 -1
  112. package/out/natural/transforms/transform2Entity.js +172 -17
  113. package/out/natural/transforms/transform2Entity.js.map +1 -1
  114. package/out/natural/transforms/transform2Enum.d.ts +1 -1
  115. package/out/natural/transforms/transform2Enum.d.ts.map +1 -1
  116. package/out/natural/transforms/transform2Enum.js +5 -1
  117. package/out/natural/transforms/transform2Enum.js.map +1 -1
  118. package/out/natural/transforms/transform2GlobalLogicDeclaration.d.ts +2 -2
  119. package/out/natural/transforms/transform2GlobalLogicDeclaration.d.ts.map +1 -1
  120. package/out/natural/transforms/transform2GlobalLogicDeclaration.js +18 -4
  121. package/out/natural/transforms/transform2GlobalLogicDeclaration.js.map +1 -1
  122. package/out/natural/transforms/transform2Logic.d.ts +4 -4
  123. package/out/natural/transforms/transform2Logic.d.ts.map +1 -1
  124. package/out/natural/transforms/transform2Logic.js +58 -17
  125. package/out/natural/transforms/transform2Logic.js.map +1 -1
  126. package/out/natural/transforms/transform2LogicItem.d.ts +11 -4
  127. package/out/natural/transforms/transform2LogicItem.d.ts.map +1 -1
  128. package/out/natural/transforms/transform2LogicItem.js +279 -178
  129. package/out/natural/transforms/transform2LogicItem.js.map +1 -1
  130. package/out/natural/transforms/transform2MetadataType.d.ts +1 -1
  131. package/out/natural/transforms/transform2MetadataType.d.ts.map +1 -1
  132. package/out/natural/transforms/transform2MetadataType.js +1 -1
  133. package/out/natural/transforms/transform2MetadataType.js.map +1 -1
  134. package/out/natural/transforms/transform2Param.d.ts +4 -0
  135. package/out/natural/transforms/transform2Param.d.ts.map +1 -0
  136. package/out/natural/transforms/transform2Param.js +114 -0
  137. package/out/natural/transforms/transform2Param.js.map +1 -0
  138. package/out/natural/transforms/transform2Structure.d.ts +1 -1
  139. package/out/natural/transforms/transform2Structure.d.ts.map +1 -1
  140. package/out/natural/transforms/transform2Structure.js +13 -2
  141. package/out/natural/transforms/transform2Structure.js.map +1 -1
  142. package/out/natural/transforms/transform2TypeAnnotation.d.ts +1 -1
  143. package/out/natural/transforms/transform2TypeAnnotation.d.ts.map +1 -1
  144. package/out/natural/transforms/transform2TypeAnnotation.js +3 -3
  145. package/out/natural/transforms/transform2TypeAnnotation.js.map +1 -1
  146. package/out/natural/transforms/transform2ValidationRule.d.ts +2 -2
  147. package/out/natural/transforms/transform2ValidationRule.d.ts.map +1 -1
  148. package/out/natural/transforms/transform2ValidationRule.js +6 -1
  149. package/out/natural/transforms/transform2ValidationRule.js.map +1 -1
  150. package/out/natural/transforms/transform2Variable.d.ts +4 -3
  151. package/out/natural/transforms/transform2Variable.d.ts.map +1 -1
  152. package/out/natural/transforms/transform2Variable.js +57 -6
  153. package/out/natural/transforms/transform2Variable.js.map +1 -1
  154. package/out/natural/transforms/transformThemeAndStyle.d.ts +5 -2
  155. package/out/natural/transforms/transformThemeAndStyle.d.ts.map +1 -1
  156. package/out/natural/transforms/transformThemeAndStyle.js +26 -13
  157. package/out/natural/transforms/transformThemeAndStyle.js.map +1 -1
  158. package/out/natural/transforms/utils/createComponentLookupMap.d.ts +32 -0
  159. package/out/natural/transforms/utils/createComponentLookupMap.d.ts.map +1 -0
  160. package/out/natural/transforms/utils/createComponentLookupMap.js +57 -0
  161. package/out/natural/transforms/utils/createComponentLookupMap.js.map +1 -0
  162. package/out/natural/transforms/utils/iconNames.d.ts +2 -0
  163. package/out/natural/transforms/utils/iconNames.d.ts.map +1 -0
  164. package/out/natural/transforms/utils/iconNames.js +299 -0
  165. package/out/natural/transforms/utils/iconNames.js.map +1 -0
  166. package/out/natural/transforms/utils/misc.d.ts +16 -0
  167. package/out/natural/transforms/utils/misc.d.ts.map +1 -0
  168. package/out/natural/transforms/utils/misc.js +240 -0
  169. package/out/natural/transforms/utils/misc.js.map +1 -0
  170. package/out/natural/transforms/utils/normalizeNode.d.ts +3 -0
  171. package/out/natural/transforms/utils/normalizeNode.d.ts.map +1 -0
  172. package/out/natural/transforms/utils/normalizeNode.js +15 -0
  173. package/out/natural/transforms/utils/normalizeNode.js.map +1 -0
  174. package/out/natural/transforms/utils/parseDecorator.d.ts +74 -0
  175. package/out/natural/transforms/utils/parseDecorator.d.ts.map +1 -0
  176. package/out/natural/transforms/utils/parseDecorator.js +252 -0
  177. package/out/natural/transforms/utils/parseDecorator.js.map +1 -0
  178. package/out/natural/transforms/utils/transform2Directory.d.ts +59 -0
  179. package/out/natural/transforms/utils/transform2Directory.d.ts.map +1 -0
  180. package/out/natural/transforms/utils/transform2Directory.js +229 -0
  181. package/out/natural/transforms/utils/transform2Directory.js.map +1 -0
  182. package/out/natural/{transforms/utils.d.ts → utils/index.d.ts} +35 -18
  183. package/out/natural/utils/index.d.ts.map +1 -0
  184. package/out/natural/utils/index.js +206 -0
  185. package/out/natural/utils/index.js.map +1 -0
  186. package/out/natural/utils/nasl-file-types.d.ts +45 -0
  187. package/out/natural/utils/nasl-file-types.d.ts.map +1 -0
  188. package/out/natural/utils/nasl-file-types.js +131 -0
  189. package/out/natural/utils/nasl-file-types.js.map +1 -0
  190. package/out/server/OQL/sqlDbTypes.json +717 -0
  191. package/out/server/createUiTs.d.ts +0 -1
  192. package/out/server/createUiTs.d.ts.map +1 -1
  193. package/out/server/createUiTs.js +1 -118
  194. package/out/server/createUiTs.js.map +1 -1
  195. package/out/server/extendBaseNode.d.ts.map +1 -1
  196. package/out/server/extendBaseNode.js +17 -0
  197. package/out/server/extendBaseNode.js.map +1 -1
  198. package/out/server/findReference.js +1 -1
  199. package/out/server/findReference.js.map +1 -1
  200. package/out/server/naslServer.d.ts +0 -1
  201. package/out/server/naslServer.d.ts.map +1 -1
  202. package/out/server/naslServer.js +66 -55
  203. package/out/server/naslServer.js.map +1 -1
  204. package/out/server/translator.js.map +1 -1
  205. package/out/service/autofix/rules/rule-convert-incompatible-assignment-to-union.js.map +1 -1
  206. package/out/service/creator/add.configs.js +1 -1
  207. package/out/service/creator/add.configs.js.map +1 -1
  208. package/out/service/storage/init.d.ts +1 -1
  209. package/out/service/storage/init.d.ts.map +1 -1
  210. package/out/service/storage/init.js +26 -9
  211. package/out/service/storage/init.js.map +1 -1
  212. package/out/service/storage/specTools.d.ts +20 -8
  213. package/out/service/storage/specTools.d.ts.map +1 -1
  214. package/out/service/storage/specTools.js +157 -5
  215. package/out/service/storage/specTools.js.map +1 -1
  216. package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.d.ts +4 -0
  217. package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.d.ts.map +1 -1
  218. package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.js +20 -1
  219. package/out/templator/block2nasl/jsx2nasl/transform-func2nasl.js.map +1 -1
  220. package/out/templator/block2nasl/jsx2nasl/transform-tsx2nasl.d.ts.map +1 -1
  221. package/out/templator/block2nasl/jsx2nasl/transform-tsx2nasl.js +28 -1
  222. package/out/templator/block2nasl/jsx2nasl/transform-tsx2nasl.js.map +1 -1
  223. package/out/templator/block2nasl/transformBlock2Nasl.js +2 -2
  224. package/out/templator/block2nasl/transformBlock2Nasl.js.map +1 -1
  225. package/out/templator/block2nasl/viewMergeBlock.js +3 -2
  226. package/out/templator/block2nasl/viewMergeBlock.js.map +1 -1
  227. package/out/utils/can-i-use.d.ts.map +1 -1
  228. package/out/utils/can-i-use.js +1 -0
  229. package/out/utils/can-i-use.js.map +1 -1
  230. package/package.json +9 -9
  231. package/sandbox/stdlib/nasl.core.ts +2 -0
  232. package/sandbox/stdlib/nasl.io.ts +1 -1
  233. package/sandbox/stdlib/nasl.oql.ts +2 -0
  234. package/sandbox/stdlib/nasl.util.ts +1 -1
  235. package/sandbox/stdlib/nasl.validation.ts +50 -14
  236. package/out/natural/genNaturalTS.d.ts.map +0 -1
  237. package/out/natural/genNaturalTS.js.map +0 -1
  238. package/out/natural/genTextualNASL.d.ts.map +0 -1
  239. package/out/natural/genTextualNASL.js.map +0 -1
  240. package/out/natural/getContext/getUILib.d.ts.map +0 -1
  241. package/out/natural/getContext/getUILib.js.map +0 -1
  242. package/out/natural/getContext/index.d.ts.map +0 -1
  243. package/out/natural/getContext/index.js.map +0 -1
  244. package/out/natural/getContext/nasl2Files.d.ts +0 -15
  245. package/out/natural/getContext/nasl2Files.d.ts.map +0 -1
  246. package/out/natural/getContext/nasl2Files.js +0 -75
  247. package/out/natural/getContext/nasl2Files.js.map +0 -1
  248. package/out/natural/getContext/naslStdlibMap.d.ts.map +0 -1
  249. package/out/natural/getContext/naslStdlibMap.js.map +0 -1
  250. package/out/natural/parseNaturalTS.d.ts.map +0 -1
  251. package/out/natural/parseNaturalTS.js.map +0 -1
  252. package/out/natural/parseNaturalTSXView.d.ts.map +0 -1
  253. package/out/natural/parseNaturalTSXView.js.map +0 -1
  254. package/out/natural/tools.d.ts.map +0 -1
  255. package/out/natural/tools.js.map +0 -1
  256. package/out/natural/transform2BatchActions.d.ts.map +0 -1
  257. package/out/natural/transform2BatchActions.js +0 -387
  258. package/out/natural/transform2BatchActions.js.map +0 -1
  259. package/out/natural/transformTS2UI.d.ts.map +0 -1
  260. package/out/natural/transformTS2UI.js.map +0 -1
  261. package/out/natural/transformTSCode.d.ts.map +0 -1
  262. package/out/natural/transformTSCode.js.map +0 -1
  263. package/out/natural/transforms/utils.d.ts.map +0 -1
  264. package/out/natural/transforms/utils.js +0 -407
  265. package/out/natural/transforms/utils.js.map +0 -1
  266. /package/out/natural/{genTextualNASL.d.ts → old/getContext/genTextualNASL.d.ts} +0 -0
  267. /package/out/natural/{genTextualNASL.js → old/getContext/genTextualNASL.js} +0 -0
  268. /package/out/natural/{getContext → old/getContext}/naslStdlibMap.d.ts +0 -0
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nasl2Files = exports.convertDependenciesToNaturalTS = void 0;
4
+ const index_1 = require("../../index");
5
+ const moduleType2DepNamespaceMap = {
6
+ extension: 'extensions',
7
+ interface: 'apis',
8
+ connector: 'connectors',
9
+ customInterface: 'apis',
10
+ // component: 'components',
11
+ // sharedApp: 'sharedApp',
12
+ };
13
+ /**
14
+ * 将 NASL 变量转换为 NaturalTS 代码
15
+ * @param variables - 变量列表
16
+ * @param state - 编译器状态
17
+ * @returns 生成的变量声明代码
18
+ */
19
+ const convertVariablesToNaturalTS = (variables, state) => {
20
+ let code = '';
21
+ variables.forEach((variable) => {
22
+ code += variable.toNaturalTS(state);
23
+ code += ';\n';
24
+ });
25
+ return code;
26
+ };
27
+ /**
28
+ * 收集并去重所有领域目录
29
+ * @param app - NASL 应用实例
30
+ * @returns 去重后的领域目录数组,格式为 ["name(title)", "name"]
31
+ */
32
+ const collectDomainDirectories = (app) => {
33
+ const domainSet = new Set();
34
+ // 遍历 app.directories 下的 children
35
+ if (app.directories && app.directories.length > 0) {
36
+ app.directories.forEach((directory) => {
37
+ if (directory.children && directory.children.length > 0) {
38
+ directory.children.forEach((child) => {
39
+ const domain = child.title ? `${child.name}(${child.title})` : child.name;
40
+ domainSet.add(domain);
41
+ });
42
+ }
43
+ });
44
+ }
45
+ // 遍历数据源目录
46
+ if (app.dataSources && app.dataSources.length > 0) {
47
+ app.dataSources.forEach((dataSource) => {
48
+ if (dataSource.directories && dataSource.directories.length > 0) {
49
+ dataSource.directories.forEach((directory) => {
50
+ const domain = directory.title ? `${directory.name}(${directory.title})` : directory.name;
51
+ domainSet.add(domain);
52
+ });
53
+ }
54
+ });
55
+ }
56
+ return Array.from(domainSet);
57
+ };
58
+ /**
59
+ * 将应用依赖转换为 NaturalTS 文件
60
+ * @param dependencies - 依赖列表
61
+ * @param state - 编译器状态
62
+ * @returns 生成的依赖文件列表
63
+ */
64
+ const convertDependenciesToNaturalTS = (dependencies, withTypeLibraryDefinition, state) => {
65
+ const files = [];
66
+ // 用于生成 app.dependencies.json 的数据结构
67
+ const dependenciesInfo = {};
68
+ const addDependencyInfo = (category, name, version) => {
69
+ if (!dependenciesInfo[category]) {
70
+ dependenciesInfo[category] = {};
71
+ }
72
+ dependenciesInfo[category][name] = version;
73
+ };
74
+ dependencies?.forEach((dep) => {
75
+ let category;
76
+ const file = { path: '', content: '' };
77
+ if (dep.type === 'extension') {
78
+ if (dep.logics?.length > 0) {
79
+ // 判定为服务端依赖库
80
+ // extension 有 logics 为后端扩展
81
+ category = 'extensions';
82
+ file.path = `${category}.${dep.name}.ts`;
83
+ file.content = dep.toNaturalTS((0, index_1.shiftState)(state, '', { tabSize: 0, descriptionComment: true, needNamespace: false })).trim() + '\n';
84
+ }
85
+ else if (dep.frontends?.length > 0) {
86
+ // 判定为前端依赖库
87
+ // extension 有 frontends 为前端扩展
88
+ category = 'uilibs';
89
+ // if (withTypeLibraryDefinition?.[dep.name]) {
90
+ // file.path = `${category}.${dep.name}.d.ts`;
91
+ // file.content = withTypeLibraryDefinition[dep.name] || '';
92
+ // }
93
+ file.path = `${category}.${dep.name}.ts`;
94
+ file.content = dep.toNaturalTS((0, index_1.shiftState)(state, '', { tabSize: 0, descriptionComment: true, needNamespace: false })).trim() + '\n';
95
+ }
96
+ }
97
+ else {
98
+ category = moduleType2DepNamespaceMap[dep.type];
99
+ file.path = `${category}.${dep.name}.ts`;
100
+ file.content = dep.toNaturalTS((0, index_1.shiftState)(state, '', { tabSize: 0, descriptionComment: true, needNamespace: false })).trim() + '\n';
101
+ }
102
+ // 收集依赖信息
103
+ if (file.path && file.content && category) {
104
+ files.push(file);
105
+ if (category === 'apis') {
106
+ const apiCodes = dep.interfaces?.map((i) => i.name);
107
+ addDependencyInfo(category, dep.name, apiCodes);
108
+ }
109
+ else {
110
+ addDependencyInfo(category, dep.name, dep.version || '0.0.0');
111
+ }
112
+ }
113
+ });
114
+ // 生成 app.dependencies.json 文件
115
+ if (Object.keys(dependenciesInfo).length > 0) {
116
+ const content = JSON.stringify(dependenciesInfo, null, 2);
117
+ files.push({ path: 'app.dependencies.json', content });
118
+ }
119
+ return files;
120
+ };
121
+ exports.convertDependenciesToNaturalTS = convertDependenciesToNaturalTS;
122
+ /**
123
+ * 将 NASL 对象转换为文件
124
+ * @param params - 包含 NASL 应用对象的参数
125
+ * @param params.app - NASL 应用实例
126
+ * @param params.withTypeLibraryDefinition - 可选,往沙箱写时必传,前端依赖库的.d.ts文件
127
+ * @param params.range - 生成文件的范围,可选值:'ts'(仅生成 TypeScript 文件)、'tsx'(仅生成 TSX 文件)、'all'(默认,生成所有类型的文件)
128
+ * @returns 生成的文件列表,每个文件包含路径和内容
129
+ */
130
+ const nasl2Files = ({ app, withTypeLibraryDefinition, range = 'all', }) => {
131
+ const result = [];
132
+ const state = (0, index_1.createCompilerState)('', { descriptionComment: true, consistentMode: true });
133
+ try {
134
+ if (range === 'all' || range === 'ts') {
135
+ // 收集所有领域目录并生成 JSON 文件
136
+ const domainDirectories = collectDomainDirectories(app);
137
+ if (domainDirectories.length > 0) {
138
+ const content = JSON.stringify(domainDirectories, null, 2);
139
+ result.push({ path: 'app.directories.json', content });
140
+ }
141
+ // 处理后端全局变量
142
+ if (app.backend?.variables && app.backend.variables.length > 0) {
143
+ const path = `app.backend.variables.ts`;
144
+ const content = convertVariablesToNaturalTS(app.backend.variables, state);
145
+ result.push({ path, content });
146
+ }
147
+ // 处理前端全局变量
148
+ if (app.frontendTypes?.[0]?.frontends[0]?.variables &&
149
+ app.frontendTypes[0].frontends[0].variables.length > 0) {
150
+ const path = `app.frontendTypes.pc.frontends.pc.variables.ts`;
151
+ const content = convertVariablesToNaturalTS(app.frontendTypes[0].frontends[0].variables, state);
152
+ result.push({ path, content });
153
+ }
154
+ // 处理 theme.css
155
+ const theme = app.frontendTypes?.[0]?.frontends?.[0]?.theme;
156
+ if (theme) {
157
+ let cssContent = '';
158
+ cssContent += theme.toThemeCSS();
159
+ if (cssContent) {
160
+ result.push({
161
+ path: 'app.frontendTypes.pc.frontends.pc.theme.css',
162
+ content: cssContent.trim() + '\n',
163
+ });
164
+ }
165
+ }
166
+ // 处理枚举
167
+ if (app.enums && app.enums.length > 0) {
168
+ app.enums.forEach((item) => {
169
+ const path = `app.enums.${item.name}.ts`;
170
+ const content = item.toNaturalTS((0, index_1.shiftState)(state, '', { tabSize: 0, descriptionComment: false }));
171
+ result.push({ path, content });
172
+ });
173
+ }
174
+ // 处理结构体
175
+ if (app.structures && app.structures.length > 0) {
176
+ app.structures.forEach((item) => {
177
+ const path = `app.structures.${item.name}.ts`;
178
+ const content = item.toNaturalTS((0, index_1.shiftState)(state, '', { tabSize: 0, descriptionComment: false }));
179
+ result.push({ path, content });
180
+ });
181
+ }
182
+ // 处理数据源实体
183
+ if (app.dataSources && app.dataSources.length > 0 && app.dataSources[0]?.entities) {
184
+ app.dataSources[0].entities.forEach((item) => {
185
+ const path = `app.dataSources.defaultDS.entities.${item.name}.ts`;
186
+ const content = item.toNaturalTS((0, index_1.shiftState)(state, '', { tabSize: 0, descriptionComment: false }));
187
+ result.push({ path, content });
188
+ });
189
+ }
190
+ // 处理依赖
191
+ const allDependencies = [...(app.dependencies || []), ...(app.interfaceDependencies || []), ...(app.connectorDependencies || [])];
192
+ if (allDependencies && allDependencies.length > 0) {
193
+ const dependencyFiles = (0, exports.convertDependenciesToNaturalTS)(allDependencies, withTypeLibraryDefinition, state);
194
+ result.push(...dependencyFiles);
195
+ }
196
+ // 处理逻辑
197
+ if (app.logics && app.logics.length > 0) {
198
+ app.logics.forEach((item) => {
199
+ const path = `app.logics.${item.name}.ts`;
200
+ const content = item.toNaturalTS((0, index_1.shiftState)(state, '', {
201
+ tabSize: 0,
202
+ functionPrefix: 'export',
203
+ descriptionComment: false,
204
+ }));
205
+ result.push({ path, content });
206
+ });
207
+ }
208
+ }
209
+ // 处理前端视图
210
+ if ((range === 'all' || range === 'tsx') && app.frontendTypes?.[0]?.frontends[0]?.views) {
211
+ // 递归处理视图及其子视图的函数
212
+ const processView = (view, pathPrefix) => {
213
+ const path = `${pathPrefix}.${view.name}.tsx`;
214
+ const content = view.toNaturalTSX((0, index_1.shiftState)(state, '', { tabSize: 0 }));
215
+ result.push({ path, content });
216
+ // 如果视图有 children,递归处理子视图
217
+ if (view.children && view.children.length > 0) {
218
+ view.children.forEach((childView) => {
219
+ processView(childView, `${pathPrefix}.${view.name}.views`);
220
+ });
221
+ }
222
+ };
223
+ app.frontendTypes[0].frontends[0].views.forEach((item) => {
224
+ processView(item, 'app.frontendTypes.pc.frontends.pc.views');
225
+ });
226
+ }
227
+ }
228
+ catch (error) {
229
+ console.error('Error in nasl2File:', error);
230
+ return [];
231
+ }
232
+ // 输出结果
233
+ console.log('Generated files count:', result.length);
234
+ return result;
235
+ };
236
+ exports.nasl2Files = nasl2Files;
237
+ //# sourceMappingURL=nasl2Files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nasl2Files.js","sourceRoot":"","sources":["../../../src/natural/exports/nasl2Files.ts"],"names":[],"mappings":";;;AAAA,uCAAuF;AAUvF,MAAM,0BAA0B,GAA+C;IAC7E,SAAS,EAAE,YAAY;IACvB,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,YAAY;IACvB,eAAe,EAAE,MAAM;IACvB,2BAA2B;IAC3B,0BAA0B;CAC3B,CAAC;AAEF;;;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AAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC9C,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,SAAc,EAAE,EAAE;wBACvC,WAAW,CAAC,SAAS,EAAE,GAAG,UAAU,IAAI,IAAI,CAAC,IAAI,QAAQ,CAAC,CAAC;oBAC7D,CAAC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CAAC;YAEF,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAS,EAAE,EAAE;gBAC5D,WAAW,CAAC,IAAI,EAAE,yCAAyC,CAAC,CAAC;YAC/D,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;QAC5C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO;IACP,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AA7IW,QAAA,UAAU,cA6IrB"}
@@ -16,6 +16,8 @@
16
16
  * - enum: 枚举类型
17
17
  * - logic: 业务逻辑
18
18
  * - view: 视图组件
19
+ * - backendVariables: 后端变量
20
+ * - frontendVariables: 前端类型变量
19
21
  */
20
22
  /**
21
23
  * 用于描述对代码文件的操作,包括路径、内容和操作类型
@@ -25,8 +27,8 @@ export interface CodeAction {
25
27
  path: string;
26
28
  /** 文件内容 */
27
29
  content: string;
28
- /** 操作类型:创建、更新或删除 */
29
- action: 'create' | 'update' | 'delete';
30
+ /** 操作类型:创建、更新、删除或已存在(用于自动生成的父级视图) */
31
+ action: 'create' | 'update' | 'delete' | 'exist';
30
32
  }
31
33
  /**
32
34
  * 批量操作接口
@@ -53,6 +55,21 @@ export interface Operators {
53
55
  /** 源类型 */
54
56
  sourceType: string;
55
57
  }
58
+ /**
59
+ * 布局模板参数接口
60
+ */
61
+ interface LayoutTemplateParams {
62
+ viewName: string;
63
+ title: string;
64
+ namespace: string;
65
+ }
66
+ /**
67
+ * 生成空的路由容器模板
68
+ * 用于为嵌套视图创建父级容器视图
69
+ * @param params - 包含视图名称、标题和命名空间的参数
70
+ * @returns 生成的路由容器模板代码
71
+ */
72
+ export declare const generateRouterContainerTemplate: (params: Pick<LayoutTemplateParams, 'viewName' | 'title' | 'namespace'>) => string;
56
73
  /**
57
74
  * 将 codeAction 数组转换为批量操作
58
75
  * 这是整个模块的核心函数,负责将多个codeAction 转换成统一的批量操作格式
@@ -68,6 +85,7 @@ export interface Operators {
68
85
  * @param app - NASL 应用实例,用于操作目标应用
69
86
  * @param sessionId - 会话 ID,用于生成唯一标识
70
87
  * @param type - 操作类型,'normal' 为正常模式,'debug' 为调试模式(会返回更多信息)
88
+ * @param files - 可选的完整文件列表,包含现有文件和新文件
71
89
  * @returns 包含批量操作和可选调试信息的对象
72
90
  */
73
91
  export declare const transform2BatchActions: ({ codeActions, app, sessionId, type, }: {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform2BatchActions.d.ts","sourceRoot":"","sources":["../../../src/natural/exports/transform2BatchActions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;CAClD;AAED;;;GAGG;AACH,UAAU,WAAW;IACnB,WAAW;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW;IACX,IAAI,EAAE,MAAM,CAAC;IACb,cAAc;IACd,MAAM,EAAE,GAAG,CAAC;CACb;AAED;;GAEG;AACH,M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