@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
@@ -744,7 +744,7 @@ export class CallLogic extends LogicItem {
744
744
  const namespaceArr = calleeNamespace.split('.');
745
745
  const start = namespaceArr[0];
746
746
  const isFrontendLibrary = ~calleeNamespace.indexOf('frontends');
747
- if (start === 'app' || (start === 'extensions' && !isFrontendLibrary)) {
747
+ if (start === 'app' || (start === 'extensions' && !isFrontendLibrary) || this.isProcessV2Logic) {
748
748
  const keywordViewsIndex = findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'views');
749
749
  if (keywordViewsIndex === -1) {
750
750
  flag = false;
@@ -754,6 +754,13 @@ export class CallLogic extends LogicItem {
754
754
  return flag;
755
755
  }
756
756
 
757
+ // 是否来自于 前端依赖库
758
+ get isFrontendLibrary() {
759
+ const { calleeNamespace } = this;
760
+ const isFrontendLibrary = calleeNamespace?.startsWith('extensions') && calleeNamespace?.indexOf('frontends') > -1;
761
+ return isFrontendLibrary;
762
+ }
763
+
757
764
  // 是否属于组件逻辑
758
765
  get isComponentLogic() {
759
766
  // 组件逻辑
@@ -770,6 +777,13 @@ export class CallLogic extends LogicItem {
770
777
  return flag;
771
778
  }
772
779
 
780
+ /**
781
+ * 是否属于新流程逻辑
782
+ */
783
+ get isProcessV2Logic() {
784
+ return this.calleeNamespace === 'nasl.processV2';
785
+ }
786
+
773
787
  toJS(state?: TranslatorState): string {
774
788
  let code = '';
775
789
  if (this.getAncestor?.('DefaultValue')) {
@@ -781,6 +795,7 @@ export class CallLogic extends LogicItem {
781
795
  let extensionName = '';
782
796
 
783
797
  const { calleeName, calleeNamespace, isComponentLogic, completeArguments, isViewLogic, typeArguments } = this;
798
+ const completeTypeArguments = this.__TypeArguments?.length ? this.__TypeArguments : typeArguments;
784
799
 
785
800
  const isShowArgument = (arg?: Argument) => {
786
801
  return arg?.expression;
@@ -801,10 +816,23 @@ export class CallLogic extends LogicItem {
801
816
  extensionName = namespaceArr[1];
802
817
  }
803
818
  }
804
- // 全局逻辑
805
- if (!isViewLogic) {
819
+ // 调用新流程逻辑
820
+ if (this.isProcessV2Logic) {
821
+ code += `this.$systemProcessV2['${this.calleeName}']`;
822
+ code += `({
823
+ body: {
824
+ `;
825
+ const argsStr = (this?.arguments || []).filter((obj) => obj?.expression)
826
+ .map((obj) => `\n${obj.keyword}: ${obj.expression?.toJS(state)}`)
827
+ .join(', ');
828
+ code += argsStr;
829
+
830
+ code += `}
831
+ })`;
832
+ } else if (!isViewLogic) { // 非页面逻辑
806
833
  const logic = this.getCallNode();
807
834
  const args = logic?.params || [];
835
+ const isSpreadFunc = args.some((arg) => arg.spread);
808
836
  const keywordEntitiesIndex = findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'entities');
809
837
 
810
838
  code += `this.$logics['${
@@ -931,20 +959,41 @@ export class CallLogic extends LogicItem {
931
959
  code += `path: {},
932
960
  body: {`;
933
961
  if (!isProcessLogic) {
934
- const argsStr = args
962
+ const formatArgs: Array<Param> = [...args];
963
+ let spreadParams = null;
964
+ // 如果是可变参数,需要先去掉最后一位可变参数位,在后面进行单独处理
965
+ if (isSpreadFunc) {
966
+ spreadParams = formatArgs.pop();
967
+ }
968
+ const argsStr = formatArgs
935
969
  .map((arg, index) => {
936
970
  const actualArg = completeArguments[index];
971
+ const keyword = arg?.name;
937
972
  return {
938
- keyword: arg?.name,
973
+ keyword,
939
974
  arg: actualArg,
940
975
  };
941
976
  })
942
- .filter((item) => isShowArgument(item.arg))
977
+ .filter((item) => {
978
+ return isShowArgument(item.arg);
979
+ })
943
980
  .map((obj) => `\n${obj?.keyword}: ${obj?.arg?.toJS(state)}`)
944
981
  .join(', ');
945
982
  code += argsStr;
946
- if (Array.isArray(typeArguments) && typeArguments.length) {
947
- code += `,\n__typeArguments: ${JSON5.stringify(this.typeArguments)}`;
983
+ // 如果是可变参数,需要单独处理
984
+ if (isSpreadFunc) {
985
+ const spreadArg = completeArguments.slice(formatArgs.length);
986
+ const spreadArgStr = spreadArg
987
+ .filter((arg) => {
988
+ return isShowArgument(arg);
989
+ })
990
+ .map((arg) => arg?.toJS?.(state) || '')
991
+ .join(', ');
992
+ code += `,\n${spreadParams.name}: [${spreadArgStr}]`;
993
+ }
994
+
995
+ if (Array.isArray(completeTypeArguments) && completeTypeArguments.length) {
996
+ code += `,\n__typeArguments: ${JSON5.stringify(completeTypeArguments)}`;
948
997
  }
949
998
  }
950
999
  code += '\n}';
@@ -1146,10 +1195,12 @@ export class CallLogic extends LogicItem {
1146
1195
  typeArguments,
1147
1196
  tsCalleeNamespace,
1148
1197
  completeArguments,
1198
+ needCompleteTypeArguments,
1149
1199
  parentNode,
1150
1200
  validation,
1151
1201
  useIife,
1152
1202
  useValidation,
1203
+ completeTypeParams,
1153
1204
  arguments: logicArgs,
1154
1205
  } = self;
1155
1206
  /** 设置函数范型参数 */
@@ -1166,8 +1217,22 @@ export class CallLogic extends LogicItem {
1166
1217
  code += `>`;
1167
1218
  }
1168
1219
  };
1220
+ /** 设置需要选择的函数范型参数 */
1221
+ const setNeedCompleteTypeArguments = function* setNeedCompleteTypeArguments() {
1222
+ // 如果有内容
1223
+ if (needCompleteTypeArguments?.length) {
1224
+ code += `<`;
1225
+ yield* wrapForEach(needCompleteTypeArguments, function* warpForEachGenerator(arg, i, arr) {
1226
+ code += yield* arg.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
1227
+ if (i !== arr.length - 1) {
1228
+ code += ', ';
1229
+ }
1230
+ });
1231
+ code += `>`;
1232
+ }
1233
+ };
1169
1234
  /** 设置输入参数 */
1170
- const setInputParam = function* setTypeArguments() {
1235
+ const setInputParam = function* setInputParam() {
1171
1236
  let paramRequired = ['showMessage', 'consoleLog', 'jsonDeserialize', 'jsonSerialize'].includes(calleeName);
1172
1237
  if (
1173
1238
  ['expression'].includes(parentKey) &&
@@ -1252,6 +1317,28 @@ export class CallLogic extends LogicItem {
1252
1317
  }
1253
1318
  };
1254
1319
 
1320
+ // 统一处理需要有泛型的 调用逻辑,其余的走老逻辑
1321
+ if (completeTypeParams.length) {
1322
+ code += '(() =>{';
1323
+ code += '\nconst genericWrapper = ';
1324
+ code += calleeKey;
1325
+ yield* setInputParam();
1326
+ code += ';\nconst warpperRes =';
1327
+ code += 'genericWrapper';
1328
+ yield* setNeedCompleteTypeArguments();
1329
+ code += '();\nconst wrapper =';
1330
+ if (handleError) {
1331
+ code += 'nasl.util.autoTypeHandleError(';
1332
+ }
1333
+ code += 'warpperRes[0]';
1334
+ if (handleError) {
1335
+ code += ')';
1336
+ }
1337
+ code += ';\nreturn wrapper';
1338
+ code += ';\n})()';
1339
+ setEndSemi();
1340
+ return code;
1341
+ }
1255
1342
  if (!state.callLogicNoIife && self.isSpecificProcessLogic) {
1256
1343
  const procDefKey = self.arguments?.find((arg) => {
1257
1344
  return arg?.keyword === 'procDefKey';
@@ -1343,8 +1430,8 @@ export class CallLogic extends LogicItem {
1343
1430
 
1344
1431
  let code = '';
1345
1432
  let calleeKey = this.calleeKey.replace('__elements', '$refs');
1346
- // if (/^app.+?\.entities\..+?logics/.test(calleeKey))
1347
- // calleeKey = calleeKey.replace(/^app.+?\.entities\.(.+?)\.logics/, '$1Entity');
1433
+ if (/^app.+?\.entities\..+?logics/.test(calleeKey))
1434
+ calleeKey = calleeKey.replace(/^app.+?\.entities\.(.+?)\.logics/, '$1Entity');
1348
1435
  /** 设置函数范型参数 */
1349
1436
  const setTypeArguments = () => {
1350
1437
  if (Array.isArray(typeArguments) && typeArguments.length) {
@@ -1521,7 +1608,16 @@ export class CallLogic extends LogicItem {
1521
1608
 
1522
1609
  /** 获取类型标注时的偏移量 */
1523
1610
  getQuickInfoOffset(range: Range, getCode: GetCode) {
1524
- if (this.useIife) {
1611
+ if (this.completeTypeParams.length) {
1612
+ const characterOffset = 7;
1613
+ const code = getCode();
1614
+ const lines = code.split('\n');
1615
+ const lineOffset = lines.findIndex((item) => item.startsWith('const warpperRes'));
1616
+ return {
1617
+ line: range.start.line + lineOffset + 1,
1618
+ offset: characterOffset,
1619
+ };
1620
+ } else if (this.useIife) {
1525
1621
  const characterOffset = 8;
1526
1622
  const code = getCode();
1527
1623
  const lines = code.split('\n');
@@ -1545,7 +1641,9 @@ export class CallLogic extends LogicItem {
1545
1641
  */
1546
1642
  enableValidation() {
1547
1643
  const calledLogic = this.getCallNode();
1548
- return Boolean(this.view) && calledLogic && !calledLogic.view;
1644
+ // 调用依赖库且有泛型的都不展示, 因为不支持推导出来的泛型,或者选择的泛型参数支持选择
1645
+ const moduleTypeLogic = this.calleeNamespace?.startsWith('extensions.') && calledLogic.completeTypeParams?.length;
1646
+ return Boolean(this.view) && calledLogic && !calledLogic.view && !moduleTypeLogic;
1549
1647
  }
1550
1648
 
1551
1649
  // 可以设置默认值的节点
@@ -1556,14 +1654,26 @@ export class CallLogic extends LogicItem {
1556
1654
  const node = callArguments.length > 0 ? this.getCallNode() : undefined;
1557
1655
  const logicParams = node?.params ?? [];
1558
1656
 
1657
+ // 判断是否有展开的参数
1658
+ // 如果有展开参数,则可能出现 标注 形参 和实际 入参数不匹配的情况,需要特殊处理
1659
+ const isSpreadFunc = logicParams.some((param) => param.spread);
1660
+
1559
1661
  callArguments.forEach((arg, index) => {
1560
1662
  if (!arg) return;
1561
- const param = logicParams[index] || ({} as Param);
1663
+ let param = logicParams[index] || ({} as Param);
1664
+ if (index >= logicParams.length && isSpreadFunc) {
1665
+ // 展开参数时,参数个数可能不匹配,这里需要特殊处理
1666
+ // 强行指定为最后一个参数,因为可变参数只能放在最后
1667
+ // && 超长参数使用当前自己的名称
1668
+ param = logicParams[logicParams.length - 1];
1669
+ } else {
1670
+ // 强制更新当前的 keyword
1671
+ arg.keyword = param?.name && param.name.length > 0 ? param.name : arg.keyword;
1672
+ }
1673
+ // 没有默认值,就是必填项
1562
1674
  arg.paramRequired = Boolean(!param?.defaultValue?.expression);
1563
1675
  arg.paramTypeAnnotation = undefined;
1564
1676
  arg.paramDefaultValue = undefined;
1565
- // 强制更新当前的 keyword
1566
- arg.keyword = param?.name && param.name.length > 0 ? param.name : arg.keyword;
1567
1677
  // 取到是不是必填放入参数中
1568
1678
  if (param && !arg.expression) {
1569
1679
  // 非必填时 才会有默认值
@@ -1575,6 +1685,33 @@ export class CallLogic extends LogicItem {
1575
1685
  return callArguments;
1576
1686
  }
1577
1687
 
1688
+ // 推导泛型参数列表,目前只有在调用依赖库时才会有
1689
+ __TypeArguments?: Array<TypeAnnotation> = [];
1690
+ /**
1691
+ * 获取 例如依赖库 等的 完整 声明的类型参数
1692
+ */
1693
+ get completeTypeParams() {
1694
+ const node = this.typeArguments?.length ? this.getCallNode() : undefined;
1695
+ const completeTypeParams = node?.completeTypeParams ?? [];
1696
+ return completeTypeParams;
1697
+ }
1698
+
1699
+ /**
1700
+ * 获取需要用户手动选择的参数列表
1701
+ * 如果没有声明参数但是本身有泛型参数列表,也直接输出出来
1702
+ */
1703
+ get needCompleteTypeArguments() {
1704
+ if (this.completeTypeParams?.length) {
1705
+ const typeArguments: TypeAnnotation[] = [];
1706
+ this.completeTypeParams.forEach((typeParam, typeIndex) => {
1707
+ if (typeParam.needChoose && this.typeArguments?.[typeIndex]) {
1708
+ typeArguments.push(this.typeArguments?.[typeIndex]);
1709
+ }
1710
+ });
1711
+ return typeArguments;
1712
+ }
1713
+ return this.typeArguments;
1714
+ }
1578
1715
  static isSystem(node: CallLogic) {
1579
1716
  // 如此处需要更新,则需同时更新 menu-poppup 组件下的 includesSystemLogic 校验逻辑
1580
1717
  return ['nasl.process', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.io'].includes(
@@ -25,7 +25,7 @@ export class ConnectorLogic extends Logic {
25
25
  */
26
26
  static isAbstract: boolean = false;
27
27
  /** 继承链 */
28
- static readonly inheritanceChain: string[] = ['Logic', 'BaseNode'];
28
+ static readonly inheritanceChain: string[] = ['Logic', 'Annotatable', 'BaseNode'];
29
29
 
30
30
  /**
31
31
  * 产品概念
@@ -62,18 +62,7 @@ export class DatabaseTypeAnnotation extends BaseNode {
62
62
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
63
63
  // 自动生成的代码已结束。下面可以手动编写。
64
64
  //================================================================================
65
- @withSourceMap()
66
- toNaturalTS(state = createCompilerState()): string {
67
- return '';
68
- }
69
65
 
70
- @withSourceMap()
71
- toTextualNASL(state = createCompilerState()): string {
72
- let code = createDecoratorCode(state, this, ['typeName', 'arguments'], {
73
- concept: true,
74
- });
75
- return code;
76
- }
77
66
  //================================================================================
78
67
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
79
68
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -0,0 +1,70 @@
1
+ //================================================================================
2
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
3
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
4
+ //================================================================================
5
+ import { EventPayload, Params } from '../common/EventEmitter';
6
+ import { concept, excludedInJSON, property, getConceptConstructor } from '../decorators';
7
+
8
+ import * as utils from '../utils';
9
+ import { createUUID } from '../utils/create';
10
+ import * as types from './utils/types';
11
+ import * as asserts from './utils/asserts';
12
+
13
+ import ManagerV2 from './ManagerV2__';
14
+
15
+ /**
16
+ * 部门主管
17
+ */
18
+ @concept('部门主管')
19
+ export class DepartmentManagerV2 extends ManagerV2 {
20
+ /** 类名 */
21
+ static readonly ConceptName: string = 'DepartmentManagerV2';
22
+ /**
23
+ * 是否为抽象类
24
+ * 抽象类不能产生 concept: string
25
+ */
26
+ static isAbstract: boolean = false;
27
+ /** 继承链 */
28
+ static readonly inheritanceChain: string[] = ['ManagerV2', 'BaseNode'];
29
+
30
+ /**
31
+ * 产品概念
32
+ */
33
+ @property('concept')
34
+ // @ts-ignore
35
+ readonly concept!: 'DepartmentManagerV2';
36
+ /**
37
+ * 是否从subordinate向上数
38
+ */
39
+ @property()
40
+ isUp: boolean;
41
+
42
+ /**
43
+ * @param source 需要合并的部分参数
44
+ */
45
+ constructor(source?: Partial<DepartmentManagerV2>) {
46
+ source = Object.assign({}, DepartmentManagerV2.getDefaultOptions(), source);
47
+ super(source);
48
+ super.subConstructor(source);
49
+ }
50
+
51
+ static from(source: any, parentNode?: any, parentKey?: string): DepartmentManagerV2 {
52
+ return super.from(source, parentNode, parentKey) as DepartmentManagerV2;
53
+ }
54
+
55
+ //================================================================================
56
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
57
+ // 自动生成的代码已结束。下面可以手动编写。
58
+ //================================================================================
59
+
60
+ //================================================================================
61
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
62
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
63
+ //================================================================================
64
+ }
65
+
66
+ export default DepartmentManagerV2;
67
+ //================================================================================
68
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
69
+ // 自动生成的代码已结束。下面可以手动编写。
70
+ //================================================================================
@@ -0,0 +1,75 @@
1
+ //================================================================================
2
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
3
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
4
+ //================================================================================
5
+ import { EventPayload, Params } from '../common/EventEmitter';
6
+ import { concept, excludedInJSON, property, getConceptConstructor } from '../decorators';
7
+
8
+ import * as utils from '../utils';
9
+ import { createUUID } from '../utils/create';
10
+ import * as types from './utils/types';
11
+ import * as asserts from './utils/asserts';
12
+ import BaseNode from '../common/BaseNode';
13
+
14
+ /**
15
+ * 部门用户
16
+ */
17
+ @concept('部门用户')
18
+ export class DepartmentV2 extends BaseNode {
19
+ /** 类名 */
20
+ static readonly ConceptName: string = 'DepartmentV2';
21
+ /**
22
+ * 是否为抽象类
23
+ * 抽象类不能产生 concept: string
24
+ */
25
+ static isAbstract: boolean = false;
26
+ /** 继承链 */
27
+ static readonly inheritanceChain: string[] = ['BaseNode'];
28
+
29
+ /**
30
+ * 产品概念
31
+ */
32
+ @property('concept')
33
+ // @ts-ignore
34
+ readonly concept!: 'DepartmentV2';
35
+ /**
36
+ * 部门唯一标识
37
+ */
38
+ @property()
39
+ name: string;
40
+
41
+ /**
42
+ * 是否仅部门主管
43
+ */
44
+ @property()
45
+ managerOnly: boolean = false;
46
+
47
+ /**
48
+ * @param source 需要合并的部分参数
49
+ */
50
+ constructor(source?: Partial<DepartmentV2>) {
51
+ source = Object.assign({}, DepartmentV2.getDefaultOptions(), source);
52
+ super(source);
53
+ super.subConstructor(source);
54
+ }
55
+
56
+ static from(source: any, parentNode?: any, parentKey?: string): DepartmentV2 {
57
+ return super.from(source, parentNode, parentKey) as DepartmentV2;
58
+ }
59
+
60
+ //================================================================================
61
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
62
+ // 自动生成的代码已结束。下面可以手动编写。
63
+ //================================================================================
64
+
65
+ //================================================================================
66
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
67
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
68
+ //================================================================================
69
+ }
70
+
71
+ export default DepartmentV2;
72
+ //================================================================================
73
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
74
+ // 自动生成的代码已结束。下面可以手动编写。
75
+ //================================================================================
@@ -0,0 +1,65 @@
1
+ //================================================================================
2
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
3
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
4
+ //================================================================================
5
+ import { EventPayload, Params } from '../common/EventEmitter';
6
+ import { concept, excludedInJSON, property, getConceptConstructor } from '../decorators';
7
+
8
+ import * as utils from '../utils';
9
+ import { createUUID } from '../utils/create';
10
+ import * as types from './utils/types';
11
+ import * as asserts from './utils/asserts';
12
+
13
+ import ManagerV2 from './ManagerV2__';
14
+
15
+ /**
16
+ * 直接主管
17
+ */
18
+ @concept('直接主管')
19
+ export class DirectManagerV2 extends ManagerV2 {
20
+ /** 类名 */
21
+ static readonly ConceptName: string = 'DirectManagerV2';
22
+ /**
23
+ * 是否为抽象类
24
+ * 抽象类不能产生 concept: string
25
+ */
26
+ static isAbstract: boolean = false;
27
+ /** 继承链 */
28
+ static readonly inheritanceChain: string[] = ['ManagerV2', 'BaseNode'];
29
+
30
+ /**
31
+ * 产品概念
32
+ */
33
+ @property('concept')
34
+ // @ts-ignore
35
+ readonly concept!: 'DirectManagerV2';
36
+
37
+ /**
38
+ * @param source 需要合并的部分参数
39
+ */
40
+ constructor(source?: Partial<DirectManagerV2>) {
41
+ source = Object.assign({}, DirectManagerV2.getDefaultOptions(), source);
42
+ super(source);
43
+ super.subConstructor(source);
44
+ }
45
+
46
+ static from(source: any, parentNode?: any, parentKey?: string): DirectManagerV2 {
47
+ return super.from(source, parentNode, parentKey) as DirectManagerV2;
48
+ }
49
+
50
+ //================================================================================
51
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
52
+ // 自动生成的代码已结束。下面可以手动编写。
53
+ //================================================================================
54
+
55
+ //================================================================================
56
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
57
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
58
+ //================================================================================
59
+ }
60
+
61
+ export default DirectManagerV2;
62
+ //================================================================================
63
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
64
+ // 自动生成的代码已结束。下面可以手动编写。
65
+ //================================================================================
@@ -10,6 +10,8 @@ import {
10
10
  import type Return from './Return__';
11
11
  import type Logic from './Logic__';
12
12
  import type BusinessLogic from './BusinessLogic__';
13
+ import type SubLogic from './SubLogic__';
14
+
13
15
  //================================================================================
14
16
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
15
17
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -66,7 +68,14 @@ export class End extends LogicItem {
66
68
 
67
69
  toJS(state?: TranslatorState): string {
68
70
  let code = '';
69
- const logic = this.logic ?? (this.getAncestor('BusinessLogic') as BusinessLogic);
71
+ let logic: Logic | BusinessLogic | SubLogic;
72
+ // 子逻辑目前仅可能存在于 Logic 下,因此其上面也会挂载 this.logic
73
+ // 导致翻译错误,因此,需要进行短路处理
74
+ if (this.getAncestor('SubLogic')) {
75
+ logic = this.getAncestor('SubLogic') as SubLogic;
76
+ } else {
77
+ logic = this.logic ?? (this.getAncestor('BusinessLogic') as BusinessLogic);
78
+ }
70
79
  const ret = logic?.returns?.[0];
71
80
  if (ret) {
72
81
  code += `return ${ret.name};`;
@@ -10,7 +10,6 @@ import {
10
10
  withGenerator,
11
11
  TranslatorGenerator,
12
12
  createDecoratorCode,
13
- createDescriptionComment,
14
13
  } from '../translator';
15
14
  import type CallQueryComponent from './CallQueryComponent__';
16
15
 
@@ -478,10 +477,6 @@ export class EntityProperty extends BaseNode {
478
477
  @withSourceMap()
479
478
  toNaturalTS(state = createCompilerState()): string {
480
479
  let code = '';
481
-
482
- if (state.descriptionComment)
483
- code += createDescriptionComment(state, this, ['label', 'description']);
484
-
485
480
  if (this.relationNamespace && this.relationEntity && this.relationProperty) {
486
481
  code += `@EntityRelation(() => new ${this.relationEntity}().${this.relationProperty})\n`;
487
482
  code += indent(state.tabSize);
@@ -11,7 +11,6 @@ import {
11
11
  withGenerator,
12
12
  TranslatorGenerator,
13
13
  createDecoratorCode,
14
- createDescriptionComment,
15
14
  } from '../translator';
16
15
  import { entity2LogicNamespace } from '../server/entity2LogicNamespace';
17
16
  import type CallQueryComponent from './CallQueryComponent__';
@@ -29,15 +28,16 @@ import * as utils from '../utils';
29
28
  import { createUUID } from '../utils/create';
30
29
  import * as types from './utils/types';
31
30
  import * as asserts from './utils/asserts';
32
- import BaseNode from '../common/BaseNode';
31
+
33
32
  import EntityProperty from './EntityProperty__';
34
33
  import EntityIndex from './EntityIndex__';
34
+ import Annotatable from './Annotatable__';
35
35
 
36
36
  /**
37
37
  * 实体
38
38
  */
39
39
  @concept('实体')
40
- export class Entity extends BaseNode {
40
+ export class Entity extends Annotatable {
41
41
  /** 类名 */
42
42
  static readonly ConceptName: string = 'Entity';
43
43
  /**
@@ -46,7 +46,7 @@ export class Entity extends BaseNode {
46
46
  */
47
47
  static isAbstract: boolean = false;
48
48
  /** 继承链 */
49
- static readonly inheritanceChain: string[] = ['BaseNode'];
49
+ static readonly inheritanceChain: string[] = ['Annotatable', 'BaseNode'];
50
50
 
51
51
  /**
52
52
  * 产品概念
@@ -837,11 +837,7 @@ export class Entity extends BaseNode {
837
837
 
838
838
  @withSourceMap()
839
839
  toNaturalTS(state = createCompilerState(), entityName?: string): string {
840
- let code = '';
841
- if (state.descriptionComment)
842
- code += createDescriptionComment(state, this, ['description']);
843
- code = `class ${this?.name} {\n`;
844
-
840
+ let code = `class ${this?.name} {\n`;
845
841
  this.properties.forEach((property) => {
846
842
  code += `${property.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 }))};\n`;
847
843
  });