@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
@@ -56,9 +56,7 @@ export function genH5GetTemplate(entity: Entity, nameGroup: NameGroup) {
56
56
  ${properties
57
57
  .map((property) => {
58
58
  const temptitle = property.label || property.name;
59
- let formItem = ` <van-cell isLink`;
60
-
61
- formItem += ' :value="' + `${nameGroup.viewVariableEntity}.${property.name}` + '">';
59
+ let formItem = ` <van-cell isLink>`;
62
60
  formItem += `<template #title>${temptitle}</template>`;
63
61
  formItem += `{{ ${`${nameGroup.viewVariableEntity}.${property.name}`} }} </van-cell>\n`;
64
62
  return formItem;
@@ -67,7 +65,7 @@ export function genH5GetTemplate(entity: Entity, nameGroup: NameGroup) {
67
65
  </van-cell-group>`;
68
66
  }
69
67
 
70
- export function genGetBlock(entity: Entity, oldNode: ViewElement,
68
+ export function genGetBlock(entity: Entity, oldNode: ViewElement,
71
69
  getGetTemplate: (entity: Entity, nameGroup: NameGroup) => string) {
72
70
  const likeComponent = oldNode?.likeComponent;
73
71
  const isBusinessComponent = likeComponent.concept === 'BusinessComponent';
@@ -13,8 +13,9 @@ export function genListViewTemplate(property: EntityProperty, nameGroup: NameGro
13
13
  return `<u-list-view ref="${nameGroup.viewElementMainView}" :dataSource="${dataSourceValue}" dataSchema="${nameGroup.structure}"
14
14
  :pageSize="50"
15
15
  :pageNumber="1"
16
- textField="${nameGroup.viewVariableEntity}.${property.name}"
17
- valueField="${lowerEntityName}.id" :pageable="true" :remotePaging="true">
16
+ textField="${lowerEntityName}.${property.name}"
17
+ valueField="${lowerEntityName}.${entity.properties.find((p) => p.primaryKey)?.name || 'id'}"
18
+ :pageable="true" :remotePaging="true">
18
19
  <template #item="current">
19
20
  <u-linear-layout>
20
21
  <u-text :text="${valueExpression}"></u-text>
@@ -32,8 +33,9 @@ export function genH5ListViewTemplate(property: EntityProperty, nameGroup: NameG
32
33
  return `<van-list-view ref="${nameGroup.viewElementMainView}" :dataSource="${dataSourceValue}" dataSchema="${nameGroup.structure}"
33
34
  :pageSize="50"
34
35
  :pageNumber="1"
35
- textField="${nameGroup.viewVariableEntity}.${property.name}"
36
- valueField="${lowerEntityName}.id" pageable="auto-more" :remotePaging="true">
36
+ textField="${lowerEntityName}.${property.name}"
37
+ valueField="${lowerEntityName}.${entity.properties.find((p) => p.primaryKey)?.name || 'id'}"
38
+ pageable="auto-more" :remotePaging="true">
37
39
  <template #item="current">
38
40
  <van-cell :value="${valueExpression}" isLink>
39
41
  <template #title>{{ ${valueExpression} }}</template>
@@ -182,14 +182,14 @@ export function genSelectItemAddLogic(entity: Entity, nameGroup: NameGroup, view
182
182
  const callLogics = [];
183
183
  const variableName = view.getVariableUniqueName('itemVariable1');
184
184
  const itemVariable1Snapshot = view.getVariableUniqueName(`${variableName}Snapshot`);
185
- const variables = [
185
+ let variables = [
186
186
  NaslNode.Variable({
187
187
  name: variableName,
188
188
  typeAnnotation: null,
189
189
  }),
190
190
  ];
191
191
  const itemExpression = genLogicParam(`item`, `${variableName}.${nameGroup.textField}`);
192
- if (entity && entity.getNamespace) {
192
+ if (entity && entity.getNamespace) { // item是实体或者数据结构
193
193
  callLogics.push(
194
194
  NaslLogicItem.Assignment({
195
195
  left: NaslLogicItem.Identifier({
@@ -215,57 +215,51 @@ export function genSelectItemAddLogic(entity: Entity, nameGroup: NameGroup, view
215
215
  })
216
216
  );
217
217
  } else {
218
- callLogics.push(
219
- NaslLogicItem.Assignment({
220
- left: NaslLogicItem.Identifier({
221
- name: variableName,
222
- }),
223
- right: {
224
- concept: 'NewComposite',
225
- name: '',
226
- typeAnnotation: {
227
- concept: 'TypeAnnotation',
228
- name: '',
229
- typeKind: 'anonymousStructure',
230
- properties: [
231
- {
232
- concept: 'StructureProperty',
233
- name: nameGroup.textField,
234
- },
218
+ // item是基本类型
219
+ if(nameGroup.schemaRef === 'nasl.core.String'){
220
+ callLogics.push(
221
+ NaslLogicItem.Assignment({
222
+ left: NaslLogicItem.Identifier({
223
+ name: variableName,
224
+ }),
225
+ right: NaslLogicItem.Identifier({
226
+ name: nameGroup.itemInputVariableName,
227
+ }),
228
+ })
229
+ );
230
+ } else if (['nasl.core.Long', 'nasl.core.Decimal'].includes(nameGroup.schemaRef)) {
231
+ const typeAnnotation ={
232
+ concept: 'TypeAnnotation',
233
+ typeKind: 'primitive',
234
+ typeNamespace: 'nasl.core',
235
+ typeName: nameGroup.schemaRef.replace('nasl.core.', ''),
236
+ };
237
+ callLogics.push(
238
+ NaslLogicItem.Assignment({
239
+ left: NaslLogicItem.Identifier({
240
+ name: variableName,
241
+ }),
242
+ right: NaslLogicItem.CallFunction({
243
+ calleeName: 'Convert',
244
+ typeArguments: [typeAnnotation],
245
+ arguments: [
246
+ NaslLogicItem.Argument({
247
+ keyword: 'value',
248
+ expression: NaslLogicItem.Identifier({
249
+ name: nameGroup.itemInputVariableName,
250
+ }),
251
+ }),
235
252
  ],
236
- },
237
- properties: [
238
- {
239
- concept: 'Identifier',
240
- name: nameGroup.textField,
241
- },
242
- ],
243
- rights: [
244
- {
245
- concept: 'SelectMembers',
246
- name: '',
247
- expression: {
248
- concept: 'StringLiteral',
249
- name: '',
250
- value: '',
251
- },
252
- members: [],
253
- },
254
- ],
255
- assignmentLines: [
256
- {
257
- concept: 'AssignmentLine',
258
- name: '',
259
- leftIndex: [0, 0],
260
- rightIndex: [0],
261
- },
262
- ],
263
- hideProperties: false,
264
- hideDefaults: false,
265
- autoConnection: true,
266
- },
267
- })
268
- );
253
+ }),
254
+ })
255
+ );
256
+ } else {
257
+ callLogics.push({
258
+ concept: 'Comment',
259
+ name: '',
260
+ value: '存储输入框的值做处理',
261
+ });
262
+ }
269
263
  }
270
264
 
271
265
  // 该属性可能不是String类型,如Integer,需要转换下,否则问题处会报错
@@ -287,7 +281,7 @@ export function genSelectItemAddLogic(entity: Entity, nameGroup: NameGroup, view
287
281
  }),
288
282
  })
289
283
  );
290
- } else {
284
+ } else if (entity && entity.getNamespace) {
291
285
  callLogics.push(
292
286
  NaslLogicItem.Assignment({
293
287
  left: itemExpression.expression,
@@ -343,6 +337,10 @@ export function genSelectItemAddLogic(entity: Entity, nameGroup: NameGroup, view
343
337
  {
344
338
  concept: 'StructureProperty',
345
339
  name: nameGroup.prefixField,
340
+ typeAnnotation: NaslTypeAnnotation.Reference({
341
+ typeNamespace: entity.getNamespace(),
342
+ typeName: entity.name,
343
+ })
346
344
  },
347
345
  ],
348
346
  },
@@ -392,6 +390,42 @@ export function genSelectItemAddLogic(entity: Entity, nameGroup: NameGroup, view
392
390
  value: '调用后端接口保存数据',
393
391
  });
394
392
  }
393
+ const argumentsTemp = [];
394
+ if(variables.length >= 2) { // 实体
395
+ argumentsTemp.push(
396
+ NaslLogicItem.Argument({
397
+ keyword: 'item',
398
+ expression: NaslLogicItem.Identifier({
399
+ name: itemVariable1Snapshot,
400
+ }),
401
+ })
402
+ );
403
+ } else {
404
+ if(entity && entity.getNamespace || ['nasl.core.String', 'nasl.core.Long', 'nasl.core.Decimal'].includes(nameGroup.schemaRef)) {
405
+ argumentsTemp.push(
406
+ NaslLogicItem.Argument({
407
+ keyword: 'item',
408
+ expression: NaslLogicItem.Identifier({
409
+ name: variableName,
410
+ }),
411
+ })
412
+ );
413
+ } else {
414
+ // 其他类型就置空
415
+ variables = [];
416
+ callLogics.push({
417
+ concept: 'Comment',
418
+ name: '',
419
+ value: '如下调用addItem将数据添加到下拉框里,item参数填上值',
420
+ });
421
+ argumentsTemp.push(
422
+ NaslLogicItem.Argument({
423
+ keyword: 'item',
424
+ expression: null,
425
+ })
426
+ );
427
+ }
428
+ }
395
429
  return NaslNode.Logic({
396
430
  name: nameGroup.viewLogicAddItem,
397
431
  params: [],
@@ -400,14 +434,7 @@ export function genSelectItemAddLogic(entity: Entity, nameGroup: NameGroup, view
400
434
  body: [
401
435
  NaslLogicItem.Start,
402
436
  ...callLogics,
403
- genCallComponentLogic(nameGroup.viewElementMainView, 'addItem', [
404
- NaslLogicItem.Argument({
405
- keyword: 'item',
406
- expression: NaslLogicItem.Identifier({
407
- name: variables.length >= 2 ? itemVariable1Snapshot : variableName,
408
- }),
409
- }),
410
- ]),
437
+ genCallComponentLogic(nameGroup.viewElementMainView, 'addItem', argumentsTemp),
411
438
  NaslLogicItem.End,
412
439
  ],
413
440
  playground: [] as Array<any>,
@@ -89,7 +89,7 @@ export function genTableTemplate(entity: Entity, nameGroup: NameGroup, newLogic:
89
89
 
90
90
  ${properties.map((property) => `${genTableColumnTemplate(property, currentName)}\n`).join('')}
91
91
 
92
- <u-table-view-column title="操作">
92
+ <u-table-view-column>
93
93
  <template #title><u-text text="操作"></u-text></template>
94
94
  <template #cell="current">
95
95
  <u-linear-layout gap="small">
@@ -380,7 +380,7 @@ export function genTableTemplateTableDesigner(
380
380
  :pagination="true" :showSizer="true" :pageSize="20" :pageNumber="1" style="margin-top: 12px">
381
381
  <u-table-view-column type="index" width="60"><template #title><u-text text="序号"></u-text></template><template #cell="current"></template></u-table-view-column>
382
382
  ${properties.map((property) => `${genTableColumnTemplateTableDesigner(property, currentName, optionsMap, dataSourcesMap)}\n`).join('')}
383
- <u-table-view-column title="操作">
383
+ <u-table-view-column>
384
384
  <template #title><u-text text="操作"></u-text></template>
385
385
  <template #cell="current">
386
386
  <u-link style="margin-right:5px;" @click="${nameGroup.viewLogicPreview}">详情</u-link>
@@ -416,7 +416,7 @@ export const genTableColumnTemplateTableDesigner = (property: EntityProperty, cu
416
416
  if (hasOptions) {
417
417
  const options = optionsMap[property.name];
418
418
  return `
419
- <u-select style="height: auto;" :preview="true" :value="${valueExpression}" placeholder="--" ${multiple ? 'multiple tags-overflow="visible" ' : ''}>
419
+ <u-select style="height: auto;" :preview="true" :value="${valueExpression}" placeholder="--" ${multiple ? ':multiple="true" tags-overflow="visible" ' : ''}>
420
420
  ${options.map((option: any) => `<u-select-item value="${option.value}"><u-text text="${option.label}"></u-text></u-select-item>`)}
421
421
  </u-select>
422
422
  `;
@@ -429,7 +429,7 @@ export const genTableColumnTemplateTableDesigner = (property: EntityProperty, cu
429
429
  const { dataSource, multiple, textField, valueField } = dataSourcesMap[property.name];
430
430
  return `
431
431
  <u-select :preview="true" :value.sync="${valueExpression}" placeholder="--" ${
432
- multiple ? 'multiple tags-overflow="visible" ' : ''
432
+ multiple ? ':multiple="true" tags-overflow="visible" ' : ''
433
433
  } :dataSource="(params)=>${dataSource?.calleeName}(params)" :textField="${textField}" :valueField="${valueField}"></u-select>`;
434
434
  }
435
435
  return `<u-text :text="${valueExpression}"></u-text>`;
@@ -230,25 +230,12 @@ function genSubmitLogic(updateLogic: Logic, nameGroup: NameGroup) {
230
230
  name: nameGroup.viewLogicSubmit,
231
231
  params: [] as any,
232
232
  returns: [] as any,
233
- variables: [
234
- NaslNode.Variable({
235
- name: 'validateResult',
236
- typeAnnotation: NaslUITypeAnnotation.ValidateEvent,
237
- }),
238
- ],
233
+ variables: [],
239
234
  body: [
240
235
  NaslLogicItem.Start,
241
- NaslLogicItem.Assignment({
242
- left: NaslLogicItem.Identifier({
243
- name: 'validateResult',
244
- }),
245
- right: genCallComponentLogic(nameGroup.viewElementMainView, 'validate'),
246
- }),
247
236
  NaslLogicItem.IfStatement({
248
237
  test: NaslLogicItem.MemberExpression({
249
- object: NaslLogicItem.Identifier({
250
- name: 'validateResult',
251
- }),
238
+ object: genCallComponentLogic(nameGroup.viewElementMainView, 'validate'),
252
239
  property: NaslLogicItem.Identifier({
253
240
  name: 'valid',
254
241
  }),
@@ -217,7 +217,7 @@ export const NaslUITypeAnnotation = {
217
217
  SliderEvent: genNaslUITypeAnnotation('SliderEvent'),
218
218
  DateEvent: genNaslUITypeAnnotation('DateEvent'),
219
219
  OperatorItemEvent: genNaslUITypeAnnotation('OperatorItemEvent'),
220
- ValidateEvent: genNaslUITypeAnnotation('ValidateEvent'),
220
+ ValidateResult: genNaslUITypeAnnotation('ValidateResult'),
221
221
  PaginationEvent: genNaslUITypeAnnotation('PaginationEvent'),
222
222
  DurationEvent: genNaslUITypeAnnotation('DurationEvent'),
223
223
  TransferEvent: genNaslUITypeAnnotation('TransferEvent'),
@@ -61,6 +61,10 @@ export interface TranslatorState {
61
61
  * @description 修改逻辑节点
62
62
  */
63
63
  nodePathComment?: boolean;
64
+ /**
65
+ * 生成时带上 label 和 description 的 comment
66
+ */
67
+ descriptionComment?: boolean;
64
68
  /**
65
69
  * 只生成对应节点的声明信息
66
70
  */
@@ -255,6 +255,12 @@ export function transfromUnionTypeAnnotation(expTypeAnnotation: TypeAnnotation,
255
255
  }
256
256
  }
257
257
 
258
+ export function createDescriptionComment<T extends BaseNode>(state: TranslatorState, node: T, properties: Array<keyof T>) {
259
+ const content = properties.map((prop) => node[prop]).filter((value) => !!value).join(' ');
260
+
261
+ return content.trim() ? `/** ${content} */\n${indent(state.tabSize)}` : '';
262
+ }
263
+
258
264
  export function createDecoratorCode<T extends BaseNode>(state: TranslatorState, node: T, properties: Array<keyof T>, options?: {
259
265
  '@'?: boolean;
260
266
  concept?: boolean;
package/src/utils/env.ts CHANGED
@@ -2,8 +2,9 @@
2
2
  export const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
3
3
  /** Node 环境 */
4
4
  export const isNode = process.env.BUILD_TARGET === 'node' || !globalThis.window;
5
+ /** 本地模式 */
6
+ export const isLocalMode = isBrowser && location.hostname.includes('localhost');
7
+ /** 调试模式 */
8
+ export const isDebugMode = isBrowser && (/[?&]debug=true/.test(location.search) || isLocalMode);
5
9
  /** 是否是浏览器测试环境 */
6
- export const isTestBrowser = isBrowser && (
7
- /codewave-(test|dev)\.163yun\.com$/.test(location.hostname) ||
8
- location.hostname.includes('localhost')
9
- );
10
+ export const isTestBrowser = isBrowser && (/codewave-(test|dev)\.163yun\.com$/.test(location.hostname) || isLocalMode);
@@ -1,5 +1,5 @@
1
1
  import { compare } from 'compare-versions';
2
- import { BaseNode, LogicItem, AnonymousFunction, Param } from '..';
2
+ import { BaseNode, LogicItem, AnonymousFunction, Param, SubLogic } from '..';
3
3
  import type { ForEachStatement, Logic, TypeAnnotation, View, ViewElement } from '..';
4
4
  import * as types from '../concepts/utils/types';
5
5
  import { getConceptPropertyMap } from '../decorators/index';
@@ -16,6 +16,8 @@ export * from './env';
16
16
  export * from './file';
17
17
  export * from './time-slicing';
18
18
 
19
+ export * as LsCache from './language-cache';
20
+
19
21
  // 查找最近的模块
20
22
  export function findClosestModule(node: BaseNode) {
21
23
  let moduleNode = node;
@@ -298,8 +300,10 @@ export function getAncestorExistingParamNames(baseNode: types.SyntaxNode) {
298
300
  names.add((node as ForEachStatement).item?.name);
299
301
  names.add((node as ForEachStatement).index?.name);
300
302
  break;
303
+ case 'Interface':
301
304
  case 'Logic':
302
305
  case 'View':
306
+ case 'SubLogic':
303
307
  const varList = [
304
308
  ...((node as Logic | View).params || []),
305
309
  ];
@@ -312,6 +316,30 @@ export function getAncestorExistingParamNames(baseNode: types.SyntaxNode) {
312
316
  return names;
313
317
  }
314
318
 
319
+ /**
320
+ * 父链上存在的返回值名字
321
+ * @returns
322
+ */
323
+ export function getAncestorExistingReturnNames(baseNode: types.SyntaxNode) {
324
+ let node: BaseNode = baseNode;
325
+ const names: Set<string> = new Set();
326
+ while (node) {
327
+ node = node.parentNode;
328
+ switch (node?.concept) {
329
+ case 'Logic':
330
+ case 'SubLogic':
331
+ const varList = [
332
+ ...((node as Logic | SubLogic).returns || []),
333
+ ];
334
+ varList?.forEach((variable) => {
335
+ names.add(variable?.name);
336
+ });
337
+ break;
338
+ }
339
+ }
340
+ return names;
341
+ }
342
+
315
343
 
316
344
  /**
317
345
  * 父链上存在的变量名字
@@ -510,3 +538,24 @@ export function getDescription(title: string, description: string) {
510
538
  }
511
539
  return desc;
512
540
  }
541
+
542
+ /**
543
+ * 将url转换为正则的
544
+ * @param url
545
+ * @returns
546
+ */
547
+ export function transAssetsToRegx(assets: any[], key: string) {
548
+ return new RegExp(assets.map((asset) => {
549
+ return `(https?:)?` + asset[key]?.replace(/^(?:https?:)?/i, '')?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
550
+ }).join('|'), 'g');
551
+ }
552
+
553
+ /**
554
+ * 获取Asset
555
+ * @param assetsMap
556
+ * @param url
557
+ * @returns
558
+ */
559
+ export function getAssetFromAssetsMap(assetsMap: Map<string, any>, url: string) {
560
+ return assetsMap?.get(url) || assetsMap?.get(`http:${url}`) || assetsMap?.get(`https:${url}`);
561
+ }
@@ -0,0 +1,37 @@
1
+ import { isBrowser } from '../env';
2
+
3
+ /** 数据库名称 */
4
+ export const DbName = 'language-cache';
5
+
6
+ /**
7
+ * 缓存时长
8
+ *
9
+ * @description 3 天时间
10
+ */
11
+ export const NaslCacheLimit = 3 * 24 * 60 * 60 * 1000;
12
+
13
+ /** 数据库储存表 */
14
+ export enum StoreName {
15
+ Nasl = 'Nasl',
16
+ }
17
+
18
+ /**
19
+ * 标签页 ID
20
+ *
21
+ * @description 应用初始化时通过 sessionStorage 获取,Tab 页刷新时不会变化,tab 页关闭后消失
22
+ */
23
+ export const tabId = (() => {
24
+ if (!isBrowser) {
25
+ return 0;
26
+ }
27
+
28
+ const tabId = sessionStorage.getItem('tabId');
29
+
30
+ if (tabId) {
31
+ return Number(tabId);
32
+ }
33
+
34
+ const newId = Date.now();
35
+ sessionStorage.setItem('tabId', String(newId));
36
+ return newId;
37
+ })();
@@ -0,0 +1,2 @@
1
+ export * from './nasl';
2
+ export * from './types';
@@ -0,0 +1,83 @@
1
+ import { isNode } from '../env';
2
+ import { StoreName, DbName, NaslCacheLimit, tabId } from './constant';
3
+ import { LanguageDatabase, NaslCacheData, NaslCacheUpdateData } from './types';
4
+
5
+ /** 缓存数据库 */
6
+ const database = isNode
7
+ ? undefined
8
+ : import('idb').then((idb) => idb.openDB<LanguageDatabase>(DbName, 1, {
9
+ upgrade(db) {
10
+ db.createObjectStore(StoreName.Nasl);
11
+ },
12
+ blocked(currentVersion, blockedVersion, event) {
13
+ // TODO: 超出容量限制
14
+ },
15
+ }));
16
+
17
+ export async function canUseNaslCache(appId: string, globalChangedTime: number) {
18
+ const data = await getNaslCacheWithoutCheck(appId);
19
+ const now = Date.now();
20
+
21
+ if (!data || data.forceUpdate || ((now - data.createdTime) > NaslCacheLimit)) {
22
+ return false;
23
+ }
24
+
25
+ // 缓存等于服务端,则表示可以使用缓存
26
+ return data.updatedTime === globalChangedTime;
27
+ }
28
+
29
+ /**
30
+ * 取出缓存
31
+ *
32
+ * @description 只是取出缓存,并不校验缓存的有效性
33
+ */
34
+ export async function getNaslCacheWithoutCheck(appId: string) {
35
+ if (isNode) {
36
+ return;
37
+ }
38
+
39
+ const db = await database;
40
+ const data = await db.get(StoreName.Nasl, appId);
41
+ return data;
42
+ }
43
+
44
+ export async function clearCache(appId: string) {
45
+ if (isNode) {
46
+ return;
47
+ }
48
+
49
+ const db = await database;
50
+ await db.delete(StoreName.Nasl, appId);
51
+ }
52
+
53
+ export async function updateNaslCache(appId: string, data: NaslCacheUpdateData) {
54
+ if (isNode) {
55
+ return;
56
+ }
57
+
58
+ const db = await database;
59
+ const cache = await db.get(StoreName.Nasl, appId);
60
+
61
+ // 数据库中数据为新的,不更新缓存
62
+ if (cache && (data.globalChangedTime <= cache.updatedTime)) {
63
+ return;
64
+ }
65
+
66
+ const newData: NaslCacheData = {
67
+ id: appId,
68
+ tabId: tabId,
69
+ data: data.getData(),
70
+ updatedTime: data.globalChangedTime,
71
+ forceUpdate: cache
72
+ ? (
73
+ cache.forceUpdate ||
74
+ data.preGlobalChangedTime !== cache.updatedTime ||
75
+ tabId !== cache.tabId
76
+ )
77
+ : false,
78
+ createdTime: cache?.createdTime ?? Date.now(),
79
+ };
80
+
81
+ // await db.delete(StoreName.Nasl, appId);
82
+ await db.put(StoreName.Nasl, newData, appId);
83
+ }
@@ -0,0 +1,48 @@
1
+ import { DBSchema } from 'idb';
2
+ import { StoreName } from './constant';
3
+
4
+ export type NaslData = object;
5
+
6
+ export interface NaslCacheData {
7
+ /** 应用编号 appId */
8
+ id: string;
9
+ /** 开始缓存的时间 */
10
+ createdTime: number;
11
+ /**
12
+ * 变更时间
13
+ *
14
+ * @description 后端为空时,默认为当前时间
15
+ */
16
+ updatedTime: number;
17
+ /**
18
+ * 强制弃用缓存标志位
19
+ *
20
+ * 在某些特殊情况下,比如 A、B 两个人,A 先改了页面 PageA,然后 B 改了页面 PageB,再然后 A 又修改了页面 PageA。
21
+ * 此时 A 的电脑上标志位是最新的,所以他刷新页面是会走缓存,而不会走后端。
22
+ * 此时两个后端的 Nasl 已经不同,但是因为两个人改的是不同的页面,所以继续走缓存也没关系。
23
+ * 当 A 进入 B 页面的时候,后端会判定产生互锁,让 A 强制刷新页面,此时 A 的标志位是最新的,所以 A 即便刷新页面也会走缓存,
24
+ * 所以这里就需要另外的标志位来让 A 强制不走缓存。
25
+ */
26
+ forceUpdate: boolean;
27
+ /**
28
+ * 当前标签页编号
29
+ */
30
+ tabId: number;
31
+ /** 应用 Nasl 数据 */
32
+ data: NaslData;
33
+ }
34
+
35
+ export interface NaslCacheUpdateData {
36
+ preGlobalChangedTime: number;
37
+ globalChangedTime: number;
38
+ getData: () => NaslData;
39
+ }
40
+
41
+ export interface LanguageDatabase extends DBSchema {
42
+ /** Nasl 缓存数据库 */
43
+ [StoreName.Nasl]: {
44
+ /** AppId 为键名 */
45
+ key: string;
46
+ value: NaslCacheData;
47
+ };
48
+ }
@@ -16,7 +16,6 @@ import {
16
16
  NextState,
17
17
  TheoreticalLimitCalculationCoefficient as Coefficient,
18
18
  } from './constant';
19
- import { delayInWorker } from '../delay';
20
19
 
21
20
  /** 时间分片控制器 */
22
21
  export class TimeSlicingController {
@@ -15,3 +15,23 @@ export interface FileNode extends BaseNode {
15
15
  }
16
16
 
17
17
  export type EmbeddedTSFileGenerator = Generator<void, EmbeddedTSFileResult, string>;
18
+
19
+ export interface FullResponse<D> {
20
+ headers: Record<string, string>;
21
+ data: {
22
+ code: number;
23
+ msg: string;
24
+ success: boolean;
25
+ result: D[];
26
+ };
27
+ }
28
+
29
+ export interface BreakpointStatus {
30
+ path: string;
31
+ breakpointStatus: null | 'ENABLED' | 'DISABLED'
32
+ }
33
+
34
+ export interface BatchInstructResult {
35
+ globalChangedTime: number;
36
+ preGlobalChangedTime: number;
37
+ }