@lcap/nasl 3.7.3-beta.1 → 3.8.0-beta.2

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 (370) hide show
  1. package/.mocharc.js +0 -1
  2. package/out/automate/engine/utils.js +6 -1
  3. package/out/automate/engine/utils.js.map +1 -1
  4. package/out/bak/translator.js +37 -0
  5. package/out/bak/translator.js.map +1 -1
  6. package/out/breakpoint/shared/utils.d.ts +1 -0
  7. package/out/breakpoint/shared/utils.js +1 -1
  8. package/out/breakpoint/shared/utils.js.map +1 -1
  9. package/out/common/BaseNode.d.ts +11 -0
  10. package/out/common/BaseNode.js +101 -5
  11. package/out/common/BaseNode.js.map +1 -1
  12. package/out/concepts/Annotatable__.d.ts +109 -0
  13. package/out/concepts/Annotatable__.js +161 -0
  14. package/out/concepts/Annotatable__.js.map +1 -0
  15. package/out/concepts/AnnotationProperty__.d.ts +48 -0
  16. package/out/concepts/AnnotationProperty__.js +74 -0
  17. package/out/concepts/AnnotationProperty__.js.map +1 -0
  18. package/out/concepts/Annotation__.d.ts +128 -0
  19. package/out/concepts/Annotation__.js +248 -0
  20. package/out/concepts/Annotation__.js.map +1 -0
  21. package/out/concepts/App__.d.ts +14 -26
  22. package/out/concepts/App__.js +50 -20
  23. package/out/concepts/App__.js.map +1 -1
  24. package/out/concepts/ApplyAnnotation__.d.ts +87 -0
  25. package/out/concepts/ApplyAnnotation__.js +140 -0
  26. package/out/concepts/ApplyAnnotation__.js.map +1 -0
  27. package/out/concepts/Argument__.d.ts +19 -0
  28. package/out/concepts/Argument__.js +126 -0
  29. package/out/concepts/Argument__.js.map +1 -1
  30. package/out/concepts/AssigneeV2__.d.ts +169 -0
  31. package/out/concepts/AssigneeV2__.js +176 -1
  32. package/out/concepts/AssigneeV2__.js.map +1 -1
  33. package/out/concepts/AuthLogicForCallInterface__.js +1 -1
  34. package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
  35. package/out/concepts/AuthLogic__.js +1 -1
  36. package/out/concepts/AuthLogic__.js.map +1 -1
  37. package/out/concepts/BooleanLiteral__.d.ts +1 -0
  38. package/out/concepts/BooleanLiteral__.js +9 -0
  39. package/out/concepts/BooleanLiteral__.js.map +1 -1
  40. package/out/concepts/BusinessLogic__.js +1 -1
  41. package/out/concepts/BusinessLogic__.js.map +1 -1
  42. package/out/concepts/CallFunction__.js +1 -1
  43. package/out/concepts/CallFunction__.js.map +1 -1
  44. package/out/concepts/CallLogic__.d.ts +15 -0
  45. package/out/concepts/CallLogic__.js +149 -17
  46. package/out/concepts/CallLogic__.js.map +1 -1
  47. package/out/concepts/ConnectorLogic__.js +1 -1
  48. package/out/concepts/ConnectorLogic__.js.map +1 -1
  49. package/out/concepts/DatabaseTypeAnnotation__.d.ts +0 -2
  50. package/out/concepts/DatabaseTypeAnnotation__.js +0 -20
  51. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
  52. package/out/concepts/DepartmentManagerV2__.d.ts +29 -0
  53. package/out/concepts/DepartmentManagerV2__.js +56 -0
  54. package/out/concepts/DepartmentManagerV2__.js.map +1 -0
  55. package/out/concepts/DepartmentV2__.d.ts +33 -0
  56. package/out/concepts/DepartmentV2__.js +63 -0
  57. package/out/concepts/DepartmentV2__.js.map +1 -0
  58. package/out/concepts/DirectManagerV2__.d.ts +25 -0
  59. package/out/concepts/DirectManagerV2__.js +53 -0
  60. package/out/concepts/DirectManagerV2__.js.map +1 -0
  61. package/out/concepts/End__.js +9 -1
  62. package/out/concepts/End__.js.map +1 -1
  63. package/out/concepts/EntityProperty__.js +0 -2
  64. package/out/concepts/EntityProperty__.js.map +1 -1
  65. package/out/concepts/Entity__.d.ts +2 -2
  66. package/out/concepts/Entity__.js +4 -7
  67. package/out/concepts/Entity__.js.map +1 -1
  68. package/out/concepts/EnumItem__.d.ts +1 -12
  69. package/out/concepts/EnumItem__.js +17 -49
  70. package/out/concepts/EnumItem__.js.map +1 -1
  71. package/out/concepts/EnumSelectSetter__.d.ts +4 -0
  72. package/out/concepts/EnumSelectSetter__.js +7 -0
  73. package/out/concepts/EnumSelectSetter__.js.map +1 -1
  74. package/out/concepts/Enum__.js +1 -4
  75. package/out/concepts/Enum__.js.map +1 -1
  76. package/out/concepts/ForEachStatement__.js +1 -1
  77. package/out/concepts/ForEachStatement__.js.map +1 -1
  78. package/out/concepts/FrontendLibrary__.d.ts +52 -48
  79. package/out/concepts/FrontendLibrary__.js +45 -36
  80. package/out/concepts/FrontendLibrary__.js.map +1 -1
  81. package/out/concepts/FrontendType__.d.ts +4 -0
  82. package/out/concepts/FrontendType__.js +7 -0
  83. package/out/concepts/FrontendType__.js.map +1 -1
  84. package/out/concepts/Frontend__.d.ts +2 -0
  85. package/out/concepts/Frontend__.js +21 -2
  86. package/out/concepts/Frontend__.js.map +1 -1
  87. package/out/concepts/HistoryProcessV2__.js +4 -1
  88. package/out/concepts/HistoryProcessV2__.js.map +1 -1
  89. package/out/concepts/I18nInfo__.d.ts +0 -1
  90. package/out/concepts/I18nInfo__.js +0 -7
  91. package/out/concepts/I18nInfo__.js.map +1 -1
  92. package/out/concepts/Identifier__.d.ts +2 -0
  93. package/out/concepts/Identifier__.js +31 -0
  94. package/out/concepts/Identifier__.js.map +1 -1
  95. package/out/concepts/IfStatement__.js +2 -2
  96. package/out/concepts/IfStatement__.js.map +1 -1
  97. package/out/concepts/Interface__.js +1 -4
  98. package/out/concepts/Interface__.js.map +1 -1
  99. package/out/concepts/LogicItem__.d.ts +1 -1
  100. package/out/concepts/LogicItem__.js.map +1 -1
  101. package/out/concepts/Logic__.d.ts +16 -1
  102. package/out/concepts/Logic__.js +133 -15
  103. package/out/concepts/Logic__.js.map +1 -1
  104. package/out/concepts/ManagerV2__.d.ts +34 -0
  105. package/out/concepts/ManagerV2__.js +61 -0
  106. package/out/concepts/ManagerV2__.js.map +1 -0
  107. package/out/concepts/MatchCase__.d.ts +2 -2
  108. package/out/concepts/MatchCase__.js +7 -7
  109. package/out/concepts/MatchCase__.js.map +1 -1
  110. package/out/concepts/MemberExpression__.js +1 -0
  111. package/out/concepts/MemberExpression__.js.map +1 -1
  112. package/out/concepts/Module__.d.ts +88 -0
  113. package/out/concepts/Module__.js +85 -0
  114. package/out/concepts/Module__.js.map +1 -1
  115. package/out/concepts/OperatePermissionV2__.d.ts +1 -1
  116. package/out/concepts/OperatePermissionV2__.js.map +1 -1
  117. package/out/concepts/Param__.d.ts +4 -0
  118. package/out/concepts/Param__.js +13 -21
  119. package/out/concepts/Param__.js.map +1 -1
  120. package/out/concepts/ProcessElementV2__.d.ts +6 -1
  121. package/out/concepts/ProcessElementV2__.js +20 -0
  122. package/out/concepts/ProcessElementV2__.js.map +1 -1
  123. package/out/concepts/ProcessElement__.d.ts +7 -0
  124. package/out/concepts/ProcessElement__.js +47 -0
  125. package/out/concepts/ProcessElement__.js.map +1 -1
  126. package/out/concepts/ProcessV2__.d.ts +1 -34
  127. package/out/concepts/ProcessV2__.js +3 -70
  128. package/out/concepts/ProcessV2__.js.map +1 -1
  129. package/out/concepts/QueryFromExpression__.js +2 -2
  130. package/out/concepts/QueryFromExpression__.js.map +1 -1
  131. package/out/concepts/QueryJoinExpression__.js +2 -2
  132. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  133. package/out/concepts/StaticString__.d.ts +0 -4
  134. package/out/concepts/StaticString__.js +0 -11
  135. package/out/concepts/StaticString__.js.map +1 -1
  136. package/out/concepts/StructureProperty__.d.ts +1 -0
  137. package/out/concepts/StructureProperty__.js +14 -5
  138. package/out/concepts/StructureProperty__.js.map +1 -1
  139. package/out/concepts/Structure__.d.ts +4 -0
  140. package/out/concepts/Structure__.js +6 -9
  141. package/out/concepts/Structure__.js.map +1 -1
  142. package/out/concepts/SubLogic__.d.ts +418 -0
  143. package/out/concepts/SubLogic__.js +992 -0
  144. package/out/concepts/SubLogic__.js.map +1 -0
  145. package/out/concepts/Theme__.d.ts +9 -0
  146. package/out/concepts/Theme__.js +10 -0
  147. package/out/concepts/Theme__.js.map +1 -1
  148. package/out/concepts/Transactional__.d.ts +0 -1
  149. package/out/concepts/Transactional__.js +0 -7
  150. package/out/concepts/Transactional__.js.map +1 -1
  151. package/out/concepts/TypeAnnotation__.js +18 -0
  152. package/out/concepts/TypeAnnotation__.js.map +1 -1
  153. package/out/concepts/TypeParam__.d.ts +1 -0
  154. package/out/concepts/TypeParam__.js.map +1 -1
  155. package/out/concepts/ValidationRule__.d.ts +6 -1
  156. package/out/concepts/ValidationRule__.js +6 -1
  157. package/out/concepts/ValidationRule__.js.map +1 -1
  158. package/out/concepts/ViewElement__.d.ts +8 -2
  159. package/out/concepts/ViewElement__.js +213 -32
  160. package/out/concepts/ViewElement__.js.map +1 -1
  161. package/out/concepts/View__.d.ts +10 -2
  162. package/out/concepts/View__.js +129 -17
  163. package/out/concepts/View__.js.map +1 -1
  164. package/out/concepts/basics/stdlib/nasl.processV2.d.ts +2 -0
  165. package/out/concepts/basics/stdlib/nasl.processV2.js +50 -4
  166. package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
  167. package/out/concepts/basics/types/index.d.ts +1 -1
  168. package/out/concepts/basics/types/index.js +2 -1
  169. package/out/concepts/basics/types/index.js.map +1 -1
  170. package/out/concepts/index__.d.ts +9 -0
  171. package/out/concepts/index__.js +9 -0
  172. package/out/concepts/index__.js.map +1 -1
  173. package/out/concepts/utils/asserts.d.ts +409 -0
  174. package/out/concepts/utils/asserts.js +564 -14
  175. package/out/concepts/utils/asserts.js.map +1 -1
  176. package/out/concepts/utils/types.d.ts +33 -2
  177. package/out/generator/genBundleFiles.d.ts +13 -9
  178. package/out/generator/genBundleFiles.js +383 -63
  179. package/out/generator/genBundleFiles.js.map +1 -1
  180. package/out/generator/genMetaData.js +2 -0
  181. package/out/generator/genMetaData.js.map +1 -1
  182. package/out/generator/release-body/body.js +1 -0
  183. package/out/generator/release-body/body.js.map +1 -1
  184. package/out/generator/release-body/utils.d.ts +15 -7
  185. package/out/generator/release-body/utils.js +50 -7
  186. package/out/generator/release-body/utils.js.map +1 -1
  187. package/out/natural/genNaturalTS.js +2 -4
  188. package/out/natural/genNaturalTS.js.map +1 -1
  189. package/out/natural/getContext/index.js +0 -2
  190. package/out/natural/getContext/index.js.map +1 -1
  191. package/out/natural/transformTS2UI.js.map +1 -1
  192. package/out/natural/transformTSCode.d.ts +1 -1
  193. package/out/natural/transformTSCode.js.map +1 -1
  194. package/out/server/extendBaseNode.js +9 -0
  195. package/out/server/extendBaseNode.js.map +1 -1
  196. package/out/server/getLogics.js +10 -6
  197. package/out/server/getLogics.js.map +1 -1
  198. package/out/server/getMemberIdentifier.js +6 -0
  199. package/out/server/getMemberIdentifier.js.map +1 -1
  200. package/out/server/getProcessesV2.d.ts +3 -2
  201. package/out/server/getProcessesV2.js +15 -6
  202. package/out/server/getProcessesV2.js.map +1 -1
  203. package/out/server/naslServer.d.ts +5 -1
  204. package/out/server/naslServer.js +120 -30
  205. package/out/server/naslServer.js.map +1 -1
  206. package/out/server/translator.js +4 -0
  207. package/out/server/translator.js.map +1 -1
  208. package/out/service/storage/init.d.ts +2 -1
  209. package/out/service/storage/init.js +28 -71
  210. package/out/service/storage/init.js.map +1 -1
  211. package/out/templator/genCreateBlock.d.ts +6 -2
  212. package/out/templator/genCreateBlock.js +25 -8
  213. package/out/templator/genCreateBlock.js.map +1 -1
  214. package/out/templator/genCurdEditMultipleKeyBlock.d.ts +22 -0
  215. package/out/templator/genCurdEditMultipleKeyBlock.js +60 -1
  216. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  217. package/out/templator/genCurdMultipleKeyBlock.d.ts +13 -3
  218. package/out/templator/genCurdMultipleKeyBlock.js +29 -23
  219. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  220. package/out/templator/genGetBlock.d.ts +1 -1
  221. package/out/templator/genGetBlock.js +3 -2
  222. package/out/templator/genGetBlock.js.map +1 -1
  223. package/out/templator/genListViewBlock.d.ts +1 -1
  224. package/out/templator/genListViewBlock.js +3 -2
  225. package/out/templator/genListViewBlock.js.map +1 -1
  226. package/out/templator/genSelectBlock.d.ts +1 -1
  227. package/out/templator/genSelectBlock.js +3 -2
  228. package/out/templator/genSelectBlock.js.map +1 -1
  229. package/out/templator/genTableBlock.d.ts +9 -4
  230. package/out/templator/genTableBlock.js +31 -17
  231. package/out/templator/genTableBlock.js.map +1 -1
  232. package/out/templator/genUpdateBlock.d.ts +2 -2
  233. package/out/templator/genUpdateBlock.js +11 -11
  234. package/out/templator/genUpdateBlock.js.map +1 -1
  235. package/out/translator/types.d.ts +0 -4
  236. package/out/translator/utils.d.ts +0 -1
  237. package/out/translator/utils.js +1 -6
  238. package/out/translator/utils.js.map +1 -1
  239. package/out/utils/delay/index.d.ts +0 -0
  240. package/out/utils/delay/index.js +1 -0
  241. package/out/utils/delay/index.js.map +1 -0
  242. package/out/utils/env.d.ts +0 -4
  243. package/out/utils/env.js +3 -6
  244. package/out/utils/env.js.map +1 -1
  245. package/out/utils/index.d.ts +3 -2
  246. package/out/utils/index.js +18 -14
  247. package/out/utils/index.js.map +1 -1
  248. package/out/utils/time-slicing/controller.js.map +1 -1
  249. package/out/utils/types.d.ts +0 -17
  250. package/package.json +27 -20
  251. package/sandbox/stdlib/extension.component.ts +29 -0
  252. package/sandbox/stdlib/nasl.process.ts +17 -0
  253. package/sandbox/stdlib/nasl.processV2.ts +10 -5
  254. package/sandbox/stdlib/nasl.util.ts +3 -1
  255. package/src/automate/engine/utils.js +7 -2
  256. package/src/bak/translator.js +42 -1
  257. package/src/breakpoint/shared/utils.ts +2 -1
  258. package/src/common/BaseNode.ts +117 -5
  259. package/src/concepts/Annotatable__.ts +263 -0
  260. package/src/concepts/AnnotationProperty__.ts +102 -0
  261. package/src/concepts/Annotation__.ts +344 -0
  262. package/src/concepts/App__.ts +917 -26
  263. package/src/concepts/ApplyAnnotation__.ts +198 -0
  264. package/src/concepts/Argument__.ts +145 -1
  265. package/src/concepts/AssigneeV2__.ts +387 -1
  266. package/src/concepts/AuthLogicForCallInterface__.ts +1 -1
  267. package/src/concepts/AuthLogic__.ts +1 -1
  268. package/src/concepts/BooleanLiteral__.ts +9 -1
  269. package/src/concepts/BusinessLogic__.ts +1 -1
  270. package/src/concepts/CallFunction__.ts +1 -1
  271. package/src/concepts/CallLogic__.ts +153 -16
  272. package/src/concepts/ConnectorLogic__.ts +1 -1
  273. package/src/concepts/DatabaseTypeAnnotation__.ts +0 -11
  274. package/src/concepts/DepartmentManagerV2__.ts +70 -0
  275. package/src/concepts/DepartmentV2__.ts +75 -0
  276. package/src/concepts/DirectManagerV2__.ts +65 -0
  277. package/src/concepts/End__.ts +10 -1
  278. package/src/concepts/EntityProperty__.ts +0 -5
  279. package/src/concepts/Entity__.ts +5 -9
  280. package/src/concepts/EnumItem__.ts +16 -65
  281. package/src/concepts/EnumSelectSetter__.ts +6 -0
  282. package/src/concepts/Enum__.ts +1 -6
  283. package/src/concepts/ForEachStatement__.ts +1 -1
  284. package/src/concepts/FrontendLibrary__.ts +88 -80
  285. package/src/concepts/FrontendType__.ts +6 -0
  286. package/src/concepts/Frontend__.ts +26 -3
  287. package/src/concepts/HistoryProcessV2__.ts +5 -0
  288. package/src/concepts/I18nInfo__.ts +0 -5
  289. package/src/concepts/Identifier__.ts +32 -0
  290. package/src/concepts/IfStatement__.ts +2 -2
  291. package/src/concepts/Interface__.ts +1 -6
  292. package/src/concepts/LogicItem__.ts +1 -0
  293. package/src/concepts/Logic__.ts +140 -17
  294. package/src/concepts/ManagerV2__.ts +78 -0
  295. package/src/concepts/MatchCase__.ts +9 -8
  296. package/src/concepts/MemberExpression__.ts +1 -0
  297. package/src/concepts/Module__.ts +194 -0
  298. package/src/concepts/OperatePermissionV2__.ts +1 -1
  299. package/src/concepts/Param__.ts +17 -20
  300. package/src/concepts/ProcessElementV2__.ts +23 -0
  301. package/src/concepts/ProcessElement__.ts +18 -0
  302. package/src/concepts/ProcessV2__.ts +4 -70
  303. package/src/concepts/QueryFromExpression__.ts +2 -2
  304. package/src/concepts/QueryJoinExpression__.ts +2 -2
  305. package/src/concepts/StaticString__.ts +0 -13
  306. package/src/concepts/StructureProperty__.ts +16 -7
  307. package/src/concepts/Structure__.ts +10 -11
  308. package/src/concepts/SubLogic__.ts +1516 -0
  309. package/src/concepts/Theme__.ts +9 -0
  310. package/src/concepts/Transactional__.ts +0 -5
  311. package/src/concepts/TriggerLauncher__.ts +1 -1
  312. package/src/concepts/TypeAnnotation__.ts +17 -0
  313. package/src/concepts/TypeParam__.ts +3 -0
  314. package/src/concepts/ValidationRule__.ts +6 -1
  315. package/src/concepts/ViewElement__.ts +224 -34
  316. package/src/concepts/View__.ts +135 -22
  317. package/src/concepts/basics/stdlib/nasl.processV2.ts +56 -3
  318. package/src/concepts/basics/types/index.ts +1 -1
  319. package/src/concepts/index__.ts +9 -0
  320. package/src/concepts/utils/asserts.ts +595 -0
  321. package/src/concepts/utils/types.ts +53 -0
  322. package/src/generator/genBundleFiles.ts +408 -68
  323. package/src/generator/genMetaData.ts +3 -0
  324. package/src/generator/release-body/body.ts +1 -0
  325. package/src/generator/release-body/utils.ts +159 -55
  326. package/src/natural/genNaturalTS.ts +3 -5
  327. package/src/natural/getContext/index.ts +0 -2
  328. package/src/natural/transformTS2UI.ts +5 -2
  329. package/src/natural/transformTSCode.ts +2 -2
  330. package/src/server/extendBaseNode.ts +11 -2
  331. package/src/server/getLogics.ts +9 -7
  332. package/src/server/getMemberIdentifier.ts +7 -0
  333. package/src/server/getProcessesV2.ts +16 -6
  334. package/src/server/naslServer.ts +133 -30
  335. package/src/server/translator.ts +4 -0
  336. package/src/service/storage/init.ts +52 -97
  337. package/src/templator/genCreateBlock.ts +35 -14
  338. package/src/templator/genCurdEditMultipleKeyBlock.ts +65 -1
  339. package/src/templator/genCurdMultipleKeyBlock.ts +42 -23
  340. package/src/templator/genGetBlock.ts +4 -3
  341. package/src/templator/genListViewBlock.ts +3 -3
  342. package/src/templator/genSelectBlock.ts +4 -2
  343. package/src/templator/genTableBlock.ts +32 -17
  344. package/src/templator/genUpdateBlock.ts +21 -18
  345. package/src/translator/types.ts +0 -4
  346. package/src/translator/utils.ts +0 -6
  347. package/src/utils/delay/index.ts +0 -0
  348. package/src/utils/env.ts +4 -5
  349. package/src/utils/index.ts +16 -4
  350. package/src/utils/time-slicing/controller.ts +1 -0
  351. package/src/utils/types.ts +0 -20
  352. package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +2 -1
  353. package/ts-worker/bundle.js +1 -1
  354. package/ts-worker/src/index.js +1 -0
  355. package/out/utils/language-cache/constant.d.ts +0 -18
  356. package/out/utils/language-cache/constant.js +0 -35
  357. package/out/utils/language-cache/constant.js.map +0 -1
  358. package/out/utils/language-cache/index.d.ts +0 -2
  359. package/out/utils/language-cache/index.js +0 -19
  360. package/out/utils/language-cache/index.js.map +0 -1
  361. package/out/utils/language-cache/nasl.d.ts +0 -10
  362. package/out/utils/language-cache/nasl.js +0 -98
  363. package/out/utils/language-cache/nasl.js.map +0 -1
  364. package/out/utils/language-cache/types.d.ts +0 -44
  365. package/out/utils/language-cache/types.js +0 -4
  366. package/out/utils/language-cache/types.js.map +0 -1
  367. package/src/utils/language-cache/constant.ts +0 -37
  368. package/src/utils/language-cache/index.ts +0 -2
  369. package/src/utils/language-cache/nasl.ts +0 -83
  370. package/src/utils/language-cache/types.ts +0 -48
@@ -4,7 +4,7 @@
4
4
  * 3. 先简单做后续在看如何优化
5
5
  */
6
6
  import * as utils from '../utils';
7
- import { App, Module, Namespace, Entity, View, Enum, DataSource, ViewElement, EntityProperty } from '../concepts';
7
+ import { App, Module, Namespace, Entity, View, Enum, DataSource, ViewElement, EntityProperty, NumericLiteral, StringLiteral} from '../concepts';
8
8
  import { NaslCoreTypeAnnotation, NaslUITypeAnnotation, NaslTypeAnnotation, NaslLogicItem, NaslNode } from './utils';
9
9
  import {
10
10
  filterProperty,
@@ -506,3 +506,67 @@ export function genEditTableColumnComponent(app: App, entity: Entity, property:
506
506
  }
507
507
  </definition>`;
508
508
  }
509
+
510
+ // 生成单选、多选、选择器的数据源
511
+ export function genFormDesignerSelectLoadLogic(
512
+ entity: Entity,
513
+ nameGroup: NameGroup,
514
+ newLogic: any,
515
+ defaultValue: { [key: string]: string | number } = {}
516
+ ) {
517
+ const moduleNode = entity.app;
518
+ const moduleNamespace = moduleNode?.getNamespace();
519
+ const params = [] as Array<any>;
520
+ Object.entries(defaultValue).forEach(([key, value], index) => {
521
+ params.push(genLogicParamWithDefaultValue(`${newLogic.params[index].name}`, value));
522
+ });
523
+
524
+ return {
525
+ logic: NaslNode.Logic({
526
+ name: nameGroup.viewLogicLoad,
527
+ params: [
528
+ NaslNode.Param({
529
+ name: 'params',
530
+ typeAnnotation: NaslUITypeAnnotation.DataSourceParams,
531
+ }),
532
+ ],
533
+ returns: [
534
+ NaslNode.Return({
535
+ name: 'result',
536
+ typeAnnotation: null,
537
+ }),
538
+ ],
539
+ variables: [] as Array<any>,
540
+ body: [
541
+ NaslLogicItem.Start,
542
+ NaslLogicItem.Assignment({
543
+ left: NaslLogicItem.Identifier({
544
+ name: 'result',
545
+ }),
546
+ right: NaslLogicItem.CallLogic({
547
+ calleeNamespace: `${moduleNamespace}.logics`,
548
+ calleeName: newLogic.name,
549
+ arguments: params,
550
+ }),
551
+ }),
552
+ NaslLogicItem.End,
553
+ ],
554
+ }),
555
+ params
556
+ };
557
+ }
558
+
559
+ export function genLogicParamWithDefaultValue(paramIdOrName: string, defaultValue: string | number) {
560
+ const genArgumentExpression = (defaultValue: string | number) => {
561
+ if (typeof defaultValue === 'string') {
562
+ return new StringLiteral({ value: defaultValue as string });
563
+ } else if (typeof defaultValue === 'number') {
564
+ return new NumericLiteral({ value: defaultValue.toString() });
565
+ }
566
+ };
567
+
568
+ return NaslLogicItem.Argument({
569
+ keyword: paramIdOrName,
570
+ expression: genArgumentExpression(defaultValue),
571
+ });
572
+ }
@@ -276,7 +276,7 @@ function genInitLogic(nameGroup: NameGroup) {
276
276
  });
277
277
  }
278
278
 
279
- function genCreateLogic(nameGroup: NameGroup) {
279
+ function genCreateLogic(nameGroup: NameGroup, entity?: Entity ) {
280
280
  return NaslNode.Logic({
281
281
  name: nameGroup.viewLogicCreate,
282
282
  description: '',
@@ -517,7 +517,18 @@ function genDetailLogic(entity: Entity, nameGroup: NameGroup) {
517
517
  }
518
518
 
519
519
  // 列表(全)
520
- export function genCurdMultipleKeyBlock(entity: Entity, oldNode: ViewElement) {
520
+ export function genCurdMultipleKeyBlock(entity: Entity, oldNode: ViewElement,
521
+ localTemplate: {
522
+ genFilterTemplateLocal?: (entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) => string,
523
+ genTableTemplateLocal?: (entity: Entity, nameGroup: NameGroup, newLogic: any, modifyable?: boolean, entryFromCall?: string) => string,
524
+ genSaveModalTemplateLocal?: (entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) => string,
525
+ genWrapper?: (code: string) => string,
526
+ genSubmitLogicLocal?: (entity: Entity, nameGroup: NameGroup) => any,
527
+ genUpdateSubmitLogicLocal?: (entity: Entity, nameGroup: NameGroup) => any
528
+ genModifyLogicLocal?: (entity: Entity, nameGroup: NameGroup) => any,
529
+ genCreateLogicLocal?: (nameGroup: NameGroup, entity?: Entity) => any,
530
+ genReloadLogicLocal?: (nameGroup: NameGroup) => any,
531
+ } = {}) {
521
532
  const likeComponent = oldNode?.likeComponent;
522
533
  const dataSource = entity.parentNode as DataSource;
523
534
  const module = dataSource.app;
@@ -525,6 +536,7 @@ export function genCurdMultipleKeyBlock(entity: Entity, oldNode: ViewElement) {
525
536
  const viewElementMainView = likeComponent.getViewElementUniqueName('tableView');
526
537
  const nameGroup = genUniqueQueryNameGroup(module, likeComponent, viewElementMainView);
527
538
  nameGroup.viewElementMainView = viewElementMainView;
539
+ nameGroup.viewElementFilterForm = likeComponent.getViewElementUniqueName('filterform');
528
540
  nameGroup.viewElementSaveModal = likeComponent.getViewElementUniqueName('saveModal');
529
541
  nameGroup.viewElementSaveModalForm = likeComponent.getViewElementUniqueName('saveModalForm');
530
542
  nameGroup.viewLogicRemove = likeComponent.getLogicUniqueName('remove');
@@ -539,6 +551,7 @@ export function genCurdMultipleKeyBlock(entity: Entity, oldNode: ViewElement) {
539
551
  nameGroup.viewVariableFilter = likeComponent.getVariableUniqueName('filter');
540
552
  nameGroup.viewVariableIsUpdate = likeComponent.getVariableUniqueName('isUpdate');
541
553
 
554
+
542
555
  // 收集所有和本实体关联的实体
543
556
  const entitySet: Set<Entity> = new Set();
544
557
  entitySet.add(entity);
@@ -569,13 +582,14 @@ export function genCurdMultipleKeyBlock(entity: Entity, oldNode: ViewElement) {
569
582
  const allEntities = [...entitySet];
570
583
  const entityLogic = genQueryLogic(allEntities, nameGroup, true, true, module);
571
584
  newLogics.push(entityLogic);
572
-
585
+ const genFilter = localTemplate.genFilterTemplateLocal || genFilterTemplate;
586
+ const genTable = localTemplate.genTableTemplateLocal || genTableTemplate;
587
+ const genSaveModal = localTemplate.genSaveModalTemplateLocal || genSaveModalTemplate;
588
+ const wrapper = localTemplate.genWrapper || (code => `<u-linear-layout direction="vertical">${code}</u-linear-layout>`);
573
589
  return `<template>
574
- <u-linear-layout direction="vertical">
575
- ${genFilterTemplate(entity, nameGroup, selectNameGroupMap)}
576
- ${genTableTemplate(entity, nameGroup, entityLogic, true, 'genCurdMultipleKeyBlock')}
577
- ${genSaveModalTemplate(entity, nameGroup, selectNameGroupMap)}
578
- </u-linear-layout>
590
+ ${wrapper(`${genFilter(entity, nameGroup, selectNameGroupMap)}
591
+ ${genTable(entity, nameGroup, entityLogic, true, 'genCurdMultipleKeyBlock')}
592
+ ${genSaveModal(entity, nameGroup, selectNameGroupMap)}`)}
579
593
  </template>
580
594
 
581
595
  <definition>
@@ -621,11 +635,11 @@ export function genCurdMultipleKeyBlock(entity: Entity, oldNode: ViewElement) {
621
635
  ${JSON.stringify(genTableLoadLogic(entity, nameGroup, entityLogic, true))},
622
636
  ${JSON.stringify(genTableRemoveLogic(entity, nameGroup))},
623
637
  ${JSON.stringify(genInitLogic(nameGroup))},
624
- ${JSON.stringify(genCreateLogic(nameGroup))},
625
- ${JSON.stringify(genModifyLogic(entity, nameGroup))},
626
- ${JSON.stringify(genSubmitLogic(entity, nameGroup))},
627
- ${JSON.stringify(genUpdateSubmitLogic(entity, nameGroup))},
628
- ${JSON.stringify(genReloadLogic(nameGroup))}
638
+ ${JSON.stringify((localTemplate.genCreateLogicLocal || genCreateLogic)(nameGroup, entity))},
639
+ ${JSON.stringify((localTemplate.genModifyLogicLocal || genModifyLogic)(entity, nameGroup))},
640
+ ${JSON.stringify((localTemplate.genSubmitLogicLocal || genSubmitLogic)(entity, nameGroup))},
641
+ ${JSON.stringify((localTemplate.genUpdateSubmitLogicLocal || genUpdateSubmitLogic)(entity, nameGroup))},
642
+ ${JSON.stringify((localTemplate.genReloadLogicLocal || genReloadLogic)(nameGroup))}
629
643
  ${newLoadSelectLogics.map((logic) => `,${JSON.stringify(logic)}`).join('\n')}
630
644
  ],
631
645
  "viewBindEvents": [
@@ -977,7 +991,7 @@ function genDelModalSubmitLogic(entity: Entity, nameGroup: NameGroup) {
977
991
  });
978
992
  }
979
993
 
980
- export function genFilterTemplateTableDesigner(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>, optionsMap?: any) {
994
+ export function genFilterTemplateTableDesigner(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>, optionsMap?: any, dataSourcesMap?: any) {
981
995
  const dataSource = entity.parentNode as DataSource;
982
996
  const properties = entity.properties.filter(filterProperty('inFilter')).filter((it) => it?.typeAnnotation?.typeName !== 'List');
983
997
  const getCol = (code: string) => `<u-grid-layout-column span="6" style="padding: 10px 0;">${code}</u-grid-layout-column>`;
@@ -1003,10 +1017,15 @@ export function genFilterTemplateTableDesigner(entity: Entity, nameGroup: NameGr
1003
1017
  const options = optionsMap?.[property.name];
1004
1018
  const multiple = property?.typeAnnotation?.typeName === 'List';
1005
1019
  formItem += `
1006
- <u-select :clearable="true" v-model="${vModel}" placeholder="请选择" ${multiple ? 'multiple' : ''}>
1007
- ${options.map((option: any) => `<u-select-item value="${option.value}">${option.label}</u-select-item>`).join('')}
1020
+ <u-select style="height: auto;" :clearable="true" v-model="${vModel}" placeholder="请选择" ${multiple ? 'multiple' : ''}>
1021
+ ${options.map((option: any) => `<u-select-item value="${option.value}"><u-text text="${option.label}"></u-text></u-select-item>`).join('')}
1008
1022
  </u-select>
1009
1023
  `;
1024
+ } else if (dataSourcesMap?.[property.name]) {
1025
+ const { dataSource, multiple, textField, valueField } = dataSourcesMap?.[property.name];
1026
+ formItem += ` <u-select v-model="${vModel}" placeholder="请选择" ${
1027
+ multiple ? 'multiple' : ''
1028
+ } :dataSource="(params)=>${dataSource?.calleeName}(params)" :textField="${textField}" :valueField="${valueField}"></u-select>`;
1010
1029
  } else if (property.relationEntity) {
1011
1030
  // 有外键关联
1012
1031
  const relationEntity = dataSource?.findEntityByName(property.relationEntity);
@@ -1029,8 +1048,8 @@ export function genFilterTemplateTableDesigner(entity: Entity, nameGroup: NameGr
1029
1048
  } else if (propertyTypeName === 'Boolean') {
1030
1049
  formItem += `
1031
1050
  <u-select :clearable="true" v-model="${vModel}" placeholder="请输入${label}">
1032
- <u-select-item :value="true" text="是">是</u-select-item>
1033
- <u-select-item :value="false" text="否">否</u-select-item>
1051
+ <u-select-item :value="true" text="是"><u-text text="是"></u-text></u-select-item>
1052
+ <u-select-item :value="false" text="否"><u-text text="否"></u-text></u-select-item>
1034
1053
  </u-select>
1035
1054
  `;
1036
1055
  } else if (propertyTypeName === 'Integer' || propertyTypeName === 'Long') {
@@ -1230,7 +1249,7 @@ export const genDelModalTemplate = (nameGroup: NameGroup) => {
1230
1249
  icon="warning"
1231
1250
  >
1232
1251
  <template #title>
1233
- <div>提示</div>
1252
+ <u-text :text="'删除'"></u-text>
1234
1253
  </template>
1235
1254
  <template #foot>
1236
1255
  <u-linear-layout style="text-align: right" :vusion-disabled-cut="true" justify="center">
@@ -1248,8 +1267,7 @@ export const genDelModalTemplate = (nameGroup: NameGroup) => {
1248
1267
  ></u-text>
1249
1268
  </u-linear-layout>
1250
1269
  </template>
1251
- <template #title> <u-text></u-text> </template
1252
- ></u-modal>
1270
+ </u-modal>
1253
1271
  `;
1254
1272
  };
1255
1273
 
@@ -1259,6 +1277,7 @@ export function genCurdMultipleKeyBlockForTableDesigner(
1259
1277
  view: View,
1260
1278
  SaveModalFormTemplate?: string,
1261
1279
  optionsMap?: any,
1280
+ dataSourcesMap?: any,
1262
1281
  composedBy?: string
1263
1282
  ) {
1264
1283
  const dataSource = entity.parentNode as DataSource;
@@ -1332,8 +1351,8 @@ export function genCurdMultipleKeyBlockForTableDesigner(
1332
1351
 
1333
1352
  const code = `<template>
1334
1353
  <u-linear-layout direction="vertical" :bindEntity="" :TableDesignerLocked="true" style="background: #F7F8FA;">
1335
- ${genFilterTemplateTableDesigner(entity, nameGroup, selectNameGroupMap, optionsMap)}
1336
- ${genTableTemplateTableDesigner(entity, nameGroup, entityLogic, true, 'genCurdMultipleKeyBlock', optionsMap)}
1354
+ ${genFilterTemplateTableDesigner(entity, nameGroup, selectNameGroupMap, optionsMap, dataSourcesMap)}
1355
+ ${genTableTemplateTableDesigner(entity, nameGroup, entityLogic, true, 'genCurdMultipleKeyBlock', optionsMap, dataSourcesMap)}
1337
1356
  ${genSaveModalTemplateDesigner(entity, nameGroup, selectNameGroupMap, SaveModalFormTemplate)}
1338
1357
  ${genDelModalTemplate(nameGroup)}
1339
1358
  </u-linear-layout>
@@ -67,7 +67,8 @@ export function genH5GetTemplate(entity: Entity, nameGroup: NameGroup) {
67
67
  </van-cell-group>`;
68
68
  }
69
69
 
70
- export function genGetBlock(entity: Entity, oldNode: ViewElement) {
70
+ export function genGetBlock(entity: Entity, oldNode: ViewElement,
71
+ getGetTemplate: (entity: Entity, nameGroup: NameGroup) => string) {
71
72
  const likeComponent = oldNode?.likeComponent;
72
73
  const isBusinessComponent = likeComponent.concept === 'BusinessComponent';
73
74
  const { ns } = entity;
@@ -77,9 +78,9 @@ export function genGetBlock(entity: Entity, oldNode: ViewElement) {
77
78
  nameGroup.viewParamId = likeComponent.getParamUniqueName('id');
78
79
  nameGroup.viewVariableEntity = likeComponent.getVariableUniqueName(utils.firstLowerCase(entity.name));
79
80
  nameGroup.viewLogicLoad = likeComponent.getLogicUniqueName('load');
80
-
81
+ const genTemplate = getGetTemplate || (config.scope === 'h5' ? genH5GetTemplate: genGetTemplate);
81
82
  return `<template>
82
- ${config.scope === 'h5' ? genH5GetTemplate(entity, nameGroup) : genGetTemplate(entity, nameGroup)}
83
+ ${genTemplate(entity, nameGroup)}
83
84
  </template>
84
85
 
85
86
  <definition>
@@ -93,7 +93,7 @@ export function genLoadListViewLogic(entity: Entity, nameGroup: NameGroup, newLo
93
93
  /**
94
94
  * 生成实体选择框区块
95
95
  */
96
- export function genListViewBlock(entity: Entity, oldNode: ViewElement, property: EntityProperty) {
96
+ export function genListViewBlock(entity: Entity, oldNode: ViewElement, property: EntityProperty, genListTemplate: any) {
97
97
  const likeComponent = oldNode?.likeComponent;
98
98
  const dataSource = entity.parentNode as DataSource;
99
99
  const module = dataSource.app;
@@ -110,9 +110,9 @@ export function genListViewBlock(entity: Entity, oldNode: ViewElement, property:
110
110
 
111
111
  const parentNode = entity.parentNode as App | Module | Namespace;
112
112
  const entityLogic = genQueryLogic([entity], nameGroup, false, false, parentNode);
113
-
113
+ const genTemplate = genListTemplate ? genListTemplate : (config.scope === 'h5' ? genH5ListViewTemplate : genListViewTemplate);
114
114
  return `<template>
115
- ${config.scope === 'h5' ? genH5ListViewTemplate(displayedProperty, nameGroup, entityLogic) : genListViewTemplate(displayedProperty, nameGroup, entityLogic)}
115
+ ${genTemplate(displayedProperty, nameGroup, entityLogic)}
116
116
  </template>
117
117
 
118
118
  <definition>
@@ -103,7 +103,8 @@ export function genLoadSelectLogic(entity: Entity, nameGroup: NameGroup, newLogi
103
103
  * @param view
104
104
  * @returns
105
105
  */
106
- export function genSelectBlock(entity: Entity, oldNode: ViewElement) {
106
+ export function genSelectBlock(entity: Entity, oldNode: ViewElement,
107
+ genSelectTemplateLocal?: (property: EntityProperty, nameGroup: NameGroup, newLogic: any) => string ) {
107
108
  const likeComponent = oldNode?.likeComponent;
108
109
  const dataSource = entity.parentNode as DataSource;
109
110
  const module = dataSource.app;
@@ -119,9 +120,10 @@ export function genSelectBlock(entity: Entity, oldNode: ViewElement) {
119
120
 
120
121
  const newLogic = genQueryLogic(allEntities, nameGroup, false, false, module);
121
122
  const newLogics: Array<any> = [newLogic];
123
+ const templateFunc = genSelectTemplateLocal || (config.scope === 'h5' ? genH5SelectTemplate : genSelectTemplate);
122
124
 
123
125
  return `<template>
124
- ${config.scope === 'h5' ? genH5SelectTemplate(displayedProperty, nameGroup, newLogic) : genSelectTemplate(displayedProperty, nameGroup, newLogic)}
126
+ ${templateFunc(displayedProperty, nameGroup, newLogic)}
125
127
  </template>
126
128
 
127
129
  <definition>
@@ -12,11 +12,8 @@ import {
12
12
  } from '.';
13
13
  import { NaslCoreTypeAnnotation, NaslCollectionTypeAnnotation, NaslUITypeAnnotation, NaslTypeAnnotation, NaslLogicItem, NaslNode } from './utils';
14
14
 
15
- /**
16
- * 根据实体属性生成表格列模板
17
- * @param property 实体属性
18
- */
19
- export function genTableColumnTemplate(property: EntityProperty, currentName: string = 'current') {
15
+
16
+ export function genTableColumnTemplateMeta(property: EntityProperty, currentName: string = 'current') {
20
17
  const { entity } = property;
21
18
 
22
19
  const dataSource = entity.parentNode as DataSource;
@@ -30,7 +27,14 @@ export function genTableColumnTemplate(property: EntityProperty, currentName: st
30
27
  const displayedProperty = getFirstDisplayedProperty(relationEntity);
31
28
  valueExpression = `${currentName}.item.${relationLowerEntityName}.${displayedProperty?.name || property.relationProperty}`;
32
29
  }
33
-
30
+ return { lowerEntityName, valueExpression, title};
31
+ }
32
+ /**
33
+ * 根据实体属性生成表格列模板
34
+ * @param property 实体属性
35
+ */
36
+ export function genTableColumnTemplate(property: EntityProperty, currentName: string = 'current') {
37
+ const { lowerEntityName, valueExpression, title } = genTableColumnTemplateMeta(property, currentName);
34
38
  const getText = (property: EntityProperty) => {
35
39
  if (property.typeAnnotation.typeName === 'Boolean') {
36
40
  return `
@@ -197,7 +201,7 @@ export function genTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
197
201
  * load -> load_someView_tableView
198
202
  * load_select_student -> load_someView_select_student
199
203
  */
200
- export function genTableBlock(entity: Entity, oldNode: ViewElement) {
204
+ export function genTableBlock(entity: Entity, oldNode: ViewElement, genTable: (entity: Entity, nameGroup: NameGroup, newLogic: any) => string) {
201
205
  const likeComponent = oldNode?.likeComponent;
202
206
  const dataSource = entity.parentNode as DataSource;
203
207
  const module = dataSource.app;
@@ -229,7 +233,7 @@ export function genTableBlock(entity: Entity, oldNode: ViewElement) {
229
233
 
230
234
  return `
231
235
  <template>
232
- ${genTableTemplate(entity, nameGroup, entityLogic)}
236
+ ${genTable ? genTable(entity, nameGroup, entityLogic) : genTableTemplate(entity, nameGroup, entityLogic)}
233
237
  </template>
234
238
  <definition>
235
239
  {
@@ -244,7 +248,7 @@ export function genTableBlock(entity: Entity, oldNode: ViewElement) {
244
248
  `;
245
249
  }
246
250
 
247
- export function genTableColumnBlock(property: EntityProperty, oldNode: ViewElement) {
251
+ export function genTableColumnBlock(property: EntityProperty, oldNode: ViewElement, genTableColumnTemplate:any) {
248
252
  const likeComponent = oldNode?.likeComponent;
249
253
  const { entity } = property;
250
254
  const dataSource = entity.parentNode as DataSource;
@@ -277,9 +281,12 @@ export function genTableColumnBlock(property: EntityProperty, oldNode: ViewEleme
277
281
  let dataSourceValue = `(params) => ${entityLogic.name}(elements.$ce.page, elements.$ce.size,elements.$ce.sort,elements.$ce.order)`;
278
282
  return `
279
283
  <template>
280
- <u-table-view ref="${nameGroup.viewElementMainView}" :dataSource="${dataSourceValue}" :pagination="true" :pageSize="20" :pageNumber="1" :showSizer="true" dataSchema="${nameGroup.structure}">
281
- ${properties.map((property) => `${genTableColumnTemplate(property)}\n`).join('')}
282
- </u-table-view>
284
+ ${genTableColumnTemplate
285
+ ? genTableColumnTemplate(nameGroup)
286
+ : `<u-table-view ref="${nameGroup.viewElementMainView}" :dataSource="${dataSourceValue}" :pagination="true" :pageSize="20" :pageNumber="1" :showSizer="true" dataSchema="${nameGroup.structure}">
287
+ ${properties.map((property) => `${genTableColumnTemplate(property)}\n`).join('')}
288
+ </u-table-view>`}
289
+
283
290
  </template>
284
291
  <definition>
285
292
  {
@@ -301,7 +308,8 @@ export function genTableTemplateTableDesigner(
301
308
  newLogic: any,
302
309
  modifyable?: boolean,
303
310
  entryFromCall?: string,
304
- optionsMap?: any
311
+ optionsMap?: any,
312
+ dataSourcesMap?: any
305
313
  ) {
306
314
  const currentName = nameGroup.currentName || 'current';
307
315
  const _properties = entity.properties.filter(filterProperty('inTable'));
@@ -371,7 +379,7 @@ export function genTableTemplateTableDesigner(
371
379
  valueField="${utils.firstLowerCase(entity.name)}.${entity.properties.find((p) => p.primaryKey)?.name || 'id'}"
372
380
  :pagination="true" :showSizer="true" :pageSize="20" :pageNumber="1" style="margin-top: 12px">
373
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>
374
- ${properties.map((property) => `${genTableColumnTemplateTableDesigner(property, currentName, optionsMap)}\n`).join('')}
382
+ ${properties.map((property) => `${genTableColumnTemplateTableDesigner(property, currentName, optionsMap, dataSourcesMap)}\n`).join('')}
375
383
  <u-table-view-column title="操作">
376
384
  <template #title><u-text text="操作"></u-text></template>
377
385
  <template #cell="current">
@@ -386,9 +394,10 @@ export function genTableTemplateTableDesigner(
386
394
  `;
387
395
  }
388
396
 
389
- export const genTableColumnTemplateTableDesigner = (property: EntityProperty, currentName: string = 'current', optionsMap?: any) => {
397
+ export const genTableColumnTemplateTableDesigner = (property: EntityProperty, currentName: string = 'current', optionsMap?: any, dataSourcesMap?: any) => {
390
398
  const { entity } = property;
391
399
  const hasOptions = optionsMap?.[property.name];
400
+ const hasDataSource = dataSourcesMap?.[property.name];
392
401
 
393
402
  const dataSource = entity.parentNode as DataSource;
394
403
  const lowerEntityName = utils.firstLowerCase(entity.name);
@@ -407,8 +416,8 @@ export const genTableColumnTemplateTableDesigner = (property: EntityProperty, cu
407
416
  if (hasOptions) {
408
417
  const options = optionsMap[property.name];
409
418
  return `
410
- <u-select :preview="true" :value="${valueExpression}" placeholder="--" ${multiple ? 'multiple tags-overflow="visible" ' : ''}>
411
- ${options.map((option: any) => `<u-select-item value="${option.value}" text="${option.label}">${option.label}</u-select-item>`)}
419
+ <u-select style="height: auto;" :preview="true" :value="${valueExpression}" placeholder="--" ${multiple ? 'multiple tags-overflow="visible" ' : ''}>
420
+ ${options.map((option: any) => `<u-select-item value="${option.value}"><u-text text="${option.label}"></u-text></u-select-item>`)}
412
421
  </u-select>
413
422
  `;
414
423
  } else if (property.typeAnnotation.typeName === 'Boolean') {
@@ -416,6 +425,12 @@ export const genTableColumnTemplateTableDesigner = (property: EntityProperty, cu
416
425
  <u-text v-if="${valueExpression}" text="是"></u-text>
417
426
  <u-text v-if="!${valueExpression}" text="否"></u-text>
418
427
  `;
428
+ } else if (hasDataSource) {
429
+ const { dataSource, multiple, textField, valueField } = dataSourcesMap[property.name];
430
+ return `
431
+ <u-select :preview="true" :value.sync="${valueExpression}" placeholder="--" ${
432
+ multiple ? 'multiple tags-overflow="visible" ' : ''
433
+ } :dataSource="(params)=>${dataSource?.calleeName}(params)" :textField="${textField}" :valueField="${valueField}"></u-select>`;
419
434
  }
420
435
  return `<u-text :text="${valueExpression}"></u-text>`;
421
436
  };
@@ -307,7 +307,10 @@ function genLoadLogic(getLogic: Logic, nameGroup: NameGroup) {
307
307
  }
308
308
 
309
309
  // 生成修改区块
310
- export function genUpdateBlock(entity: Entity, oldNode: ViewElement) {
310
+ export function genUpdateBlock(entity: Entity, oldNode: ViewElement, useViewVariable = true,
311
+ genUpdateTemplate?: (entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) => string,
312
+ genLoadLogicLocal?: (getLogic: Logic, nameGroup: NameGroup, entity?: Entity) => any,
313
+ genSubmitLogicLocal?: (updateLogic: Logic, nameGroup: NameGroup) => any) {
311
314
  const likeComponent = oldNode?.likeComponent;
312
315
  const isBusinessComponent = likeComponent.concept === 'BusinessComponent';
313
316
  const dataSource = entity.parentNode as DataSource;
@@ -347,12 +350,9 @@ export function genUpdateBlock(entity: Entity, oldNode: ViewElement) {
347
350
  }
348
351
  }
349
352
  });
350
-
353
+ const genTemplate = genUpdateTemplate || (config.scope === 'h5' ? genH5UpdateFormTemplate : genUpdateFormTemplate);
351
354
  return `<template>
352
- ${config.scope === 'h5'
353
- ? genH5UpdateFormTemplate(entity, nameGroup, selectNameGroupMap)
354
- : genUpdateFormTemplate(entity, nameGroup, selectNameGroupMap)
355
- }
355
+ ${genTemplate(entity, nameGroup, selectNameGroupMap)}
356
356
  </template>
357
357
 
358
358
  <definition>
@@ -365,20 +365,23 @@ export function genUpdateBlock(entity: Entity, oldNode: ViewElement) {
365
365
  }
366
366
  ],
367
367
  "viewVariables": [
368
- {
369
- "concept": "Variable",
370
- "name": "${nameGroup.viewVariableEntity}",
371
- "typeAnnotation": ${JSON.stringify(
372
- NaslTypeAnnotation.Reference({
373
- typeNamespace: entity.getNamespace(),
374
- typeName: entity.name,
375
- })
376
- )}
377
- }
368
+ ${
369
+ useViewVariable ? `{
370
+ "concept": "Variable",
371
+ "name": "${nameGroup.viewVariableEntity}",
372
+ "typeAnnotation": ${JSON.stringify(
373
+ NaslTypeAnnotation.Reference({
374
+ typeNamespace: entity.getNamespace(),
375
+ typeName: entity.name,
376
+ })
377
+ )}
378
+ }` : ''
379
+ }
380
+
378
381
  ],
379
382
  "viewLogics": [
380
- ${JSON.stringify(genLoadLogic(getLogic, nameGroup))},
381
- ${JSON.stringify(genSubmitLogic(updateLogic, nameGroup))}
383
+ ${JSON.stringify((genLoadLogicLocal || genLoadLogic)(getLogic, nameGroup, entity))},
384
+ ${JSON.stringify((genSubmitLogicLocal || genSubmitLogic)(updateLogic, nameGroup))}
382
385
  ${newLoadSelectLogics.map((logic) => `,${JSON.stringify(logic)}`).join('\n')}
383
386
  ],
384
387
  "viewBindEvents": [
@@ -61,10 +61,6 @@ export interface TranslatorState {
61
61
  * @description 修改逻辑节点
62
62
  */
63
63
  nodePathComment?: boolean;
64
- /**
65
- * 生成时带上 label 和 description 的 comment
66
- */
67
- descriptionComment?: boolean;
68
64
  /**
69
65
  * 只生成对应节点的声明信息
70
66
  */
@@ -255,12 +255,6 @@ 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
-
264
258
  export function createDecoratorCode<T extends BaseNode>(state: TranslatorState, node: T, properties: Array<keyof T>, options?: {
265
259
  '@'?: boolean;
266
260
  concept?: boolean;
File without changes
package/src/utils/env.ts CHANGED
@@ -2,9 +2,8 @@
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);
9
5
  /** 是否是浏览器测试环境 */
10
- export const isTestBrowser = isBrowser && (/codewave-(test|dev)\.163yun\.com$/.test(location.hostname) || isLocalMode);
6
+ export const isTestBrowser = isBrowser && (
7
+ /codewave-(test|dev)\.163yun\.com$/.test(location.hostname) ||
8
+ location.hostname.includes('localhost')
9
+ );
@@ -1,6 +1,6 @@
1
1
  import { compare } from 'compare-versions';
2
2
  import { BaseNode, LogicItem, AnonymousFunction, Param } from '..';
3
- import type { ForEachStatement, Logic, TypeAnnotation, View } from '..';
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';
6
6
  import { traverse } from './traverse';
@@ -16,8 +16,6 @@ export * from './env';
16
16
  export * from './file';
17
17
  export * from './time-slicing';
18
18
 
19
- export * as LsCache from './language-cache';
20
-
21
19
  // 查找最近的模块
22
20
  export function findClosestModule(node: BaseNode) {
23
21
  let moduleNode = node;
@@ -485,6 +483,20 @@ export function isSameInType(source: TypeAnnotation[], target: TypeAnnotation[])
485
483
  return flag;
486
484
  }
487
485
 
486
+ // 获取控件,如input等
487
+ export function getControlNode(node: ViewElement){
488
+ const isH5 = (node: ViewElement) => node?.tag.startsWith('van-');
489
+ if (isH5(node)) {
490
+ return node?.children?.find((it) => it?.slotTarget === 'input')?.children?.[0];
491
+ } else {
492
+ return node?.children?.[1];
493
+ }
494
+ };
495
+
496
+ export function isSelectClassComponent(node: ViewElement){
497
+ return ['u-select', 'u-radios', 'u-checkboxes', 'van-radio-group', 'van-checkbox-group', 'van-pickerson'].includes(node?.tag);
498
+ };
499
+
488
500
  /**
489
501
  * 获取节点对应的注释
490
502
  */
@@ -497,4 +509,4 @@ export function getDescription(title: string, description: string) {
497
509
  desc += description ? `${description}` : '';
498
510
  }
499
511
  return desc;
500
- }
512
+ }
@@ -16,6 +16,7 @@ import {
16
16
  NextState,
17
17
  TheoreticalLimitCalculationCoefficient as Coefficient,
18
18
  } from './constant';
19
+ import { delayInWorker } from '../delay';
19
20
 
20
21
  /** 时间分片控制器 */
21
22
  export class TimeSlicingController {
@@ -15,23 +15,3 @@ 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
- }
@@ -1,7 +1,8 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`validation-rule:toEmbeddedTS argument-without-keyword 1`] = `
4
- "nasl.validation.max(new nasl.core.Long(10));
4
+ "__IDENTIFIER__;
5
+ nasl.validation.max(new nasl.core.Long(10));
5
6
  "
6
7
  `;
7
8