@lcap/nasl 1.0.2 → 2.12.0-beta

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 (355) hide show
  1. package/out/automate/engine/index.js +11 -0
  2. package/out/automate/engine/index.js.map +1 -1
  3. package/out/automate/engine/uniqueName.js +1 -1
  4. package/out/automate/engine/uniqueName.js.map +1 -1
  5. package/out/automate/engine/utils.d.ts +1 -0
  6. package/out/automate/engine/utils.js +89 -67
  7. package/out/automate/engine/utils.js.map +1 -1
  8. package/out/concepts/App__.d.ts +51 -49
  9. package/out/concepts/App__.js +86 -54
  10. package/out/concepts/App__.js.map +1 -1
  11. package/out/concepts/Argument__.js +1 -1
  12. package/out/concepts/Argument__.js.map +1 -1
  13. package/out/concepts/Assignee__.js +1 -1
  14. package/out/concepts/Assignee__.js.map +1 -1
  15. package/out/concepts/Assignment__.js +1 -1
  16. package/out/concepts/Assignment__.js.map +1 -1
  17. package/out/concepts/Attribute__.js +1 -1
  18. package/out/concepts/Attribute__.js.map +1 -1
  19. package/out/concepts/BinaryExpression__.js +1 -1
  20. package/out/concepts/BinaryExpression__.js.map +1 -1
  21. package/out/concepts/BindAttribute__.js +3 -3
  22. package/out/concepts/BindAttribute__.js.map +1 -1
  23. package/out/concepts/BindDirective__.js +1 -1
  24. package/out/concepts/BindDirective__.js.map +1 -1
  25. package/out/concepts/BindEvent__.js +11 -6
  26. package/out/concepts/BindEvent__.js.map +1 -1
  27. package/out/concepts/BooleanLiteral__.js +1 -1
  28. package/out/concepts/BooleanLiteral__.js.map +1 -1
  29. package/out/concepts/CallFunction__.js +8 -3
  30. package/out/concepts/CallFunction__.js.map +1 -1
  31. package/out/concepts/CallInterface__.js +1 -1
  32. package/out/concepts/CallInterface__.js.map +1 -1
  33. package/out/concepts/CallLogic__.js +23 -21
  34. package/out/concepts/CallLogic__.js.map +1 -1
  35. package/out/concepts/CallQueryComponent__.d.ts +9 -8
  36. package/out/concepts/CallQueryComponent__.js +89 -79
  37. package/out/concepts/CallQueryComponent__.js.map +1 -1
  38. package/out/concepts/Comment__.js +2 -2
  39. package/out/concepts/Comment__.js.map +1 -1
  40. package/out/concepts/CompletionProperty__.js +1 -1
  41. package/out/concepts/CompletionProperty__.js.map +1 -1
  42. package/out/concepts/ConfigGroup__.d.ts +1 -0
  43. package/out/concepts/ConfigGroup__.js +8 -1
  44. package/out/concepts/ConfigGroup__.js.map +1 -1
  45. package/out/concepts/ConfigPropertyValue__.js +1 -1
  46. package/out/concepts/ConfigPropertyValue__.js.map +1 -1
  47. package/out/concepts/ConfigProperty__.d.ts +1 -0
  48. package/out/concepts/ConfigProperty__.js +4 -1
  49. package/out/concepts/ConfigProperty__.js.map +1 -1
  50. package/out/concepts/Configuration__.d.ts +1 -0
  51. package/out/concepts/Configuration__.js +4 -1
  52. package/out/concepts/Configuration__.js.map +1 -1
  53. package/out/concepts/Constant__.js +1 -1
  54. package/out/concepts/Constant__.js.map +1 -1
  55. package/out/concepts/DataElement__.js +1 -1
  56. package/out/concepts/DataElement__.js.map +1 -1
  57. package/out/concepts/DataSource__.d.ts +143 -0
  58. package/out/concepts/DataSource__.js +316 -0
  59. package/out/concepts/DataSource__.js.map +1 -0
  60. package/out/concepts/Destination__.js +8 -8
  61. package/out/concepts/Destination__.js.map +1 -1
  62. package/out/concepts/End__.js +3 -3
  63. package/out/concepts/End__.js.map +1 -1
  64. package/out/concepts/EntityIndex__.d.ts +5 -0
  65. package/out/concepts/EntityIndex__.js +7 -1
  66. package/out/concepts/EntityIndex__.js.map +1 -1
  67. package/out/concepts/EntityProperty__.d.ts +9 -0
  68. package/out/concepts/EntityProperty__.js +20 -3
  69. package/out/concepts/EntityProperty__.js.map +1 -1
  70. package/out/concepts/Entity__.d.ts +5 -0
  71. package/out/concepts/Entity__.js +21 -11
  72. package/out/concepts/Entity__.js.map +1 -1
  73. package/out/concepts/EnumItem__.js +1 -1
  74. package/out/concepts/EnumItem__.js.map +1 -1
  75. package/out/concepts/Enum__.js +11 -5
  76. package/out/concepts/Enum__.js.map +1 -1
  77. package/out/concepts/Event__.js +1 -1
  78. package/out/concepts/Event__.js.map +1 -1
  79. package/out/concepts/ForEachStatement__.js +3 -3
  80. package/out/concepts/ForEachStatement__.js.map +1 -1
  81. package/out/concepts/Function__.d.ts +18 -0
  82. package/out/concepts/Function__.js +96 -1
  83. package/out/concepts/Function__.js.map +1 -1
  84. package/out/concepts/Identifier__.js +3 -13
  85. package/out/concepts/Identifier__.js.map +1 -1
  86. package/out/concepts/IfStatement__.js +9 -9
  87. package/out/concepts/IfStatement__.js.map +1 -1
  88. package/out/concepts/InterfaceParam__.js +1 -1
  89. package/out/concepts/InterfaceParam__.js.map +1 -1
  90. package/out/concepts/Interface__.js +19 -12
  91. package/out/concepts/Interface__.js.map +1 -1
  92. package/out/concepts/JSBlock__.js +1 -1
  93. package/out/concepts/JSBlock__.js.map +1 -1
  94. package/out/concepts/LogicItem__.js +1 -1
  95. package/out/concepts/LogicItem__.js.map +1 -1
  96. package/out/concepts/Logic__.js +41 -42
  97. package/out/concepts/Logic__.js.map +1 -1
  98. package/out/concepts/MemberExpression__.js +1 -1
  99. package/out/concepts/MemberExpression__.js.map +1 -1
  100. package/out/concepts/Module__.d.ts +1 -85
  101. package/out/concepts/Module__.js +6 -107
  102. package/out/concepts/Module__.js.map +1 -1
  103. package/out/concepts/Namespace__.d.ts +0 -86
  104. package/out/concepts/Namespace__.js +1 -108
  105. package/out/concepts/Namespace__.js.map +1 -1
  106. package/out/concepts/NullLiteral__.js +1 -1
  107. package/out/concepts/NullLiteral__.js.map +1 -1
  108. package/out/concepts/NumericLiteral__.js +1 -1
  109. package/out/concepts/NumericLiteral__.js.map +1 -1
  110. package/out/concepts/Param__.d.ts +2 -1
  111. package/out/concepts/Param__.js +1 -1
  112. package/out/concepts/Param__.js.map +1 -1
  113. package/out/concepts/Point__.js +1 -1
  114. package/out/concepts/Point__.js.map +1 -1
  115. package/out/concepts/ProcessComponent__.js +1 -1
  116. package/out/concepts/ProcessComponent__.js.map +1 -1
  117. package/out/concepts/ProcessElement__.js +26 -11
  118. package/out/concepts/ProcessElement__.js.map +1 -1
  119. package/out/concepts/ProcessOutcome__.js +1 -1
  120. package/out/concepts/ProcessOutcome__.js.map +1 -1
  121. package/out/concepts/Process__.js +17 -10
  122. package/out/concepts/Process__.js.map +1 -1
  123. package/out/concepts/QueryAggregateExpression__.js +1 -1
  124. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  125. package/out/concepts/QueryFieldExpression__.js +9 -2
  126. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  127. package/out/concepts/QueryFromExpression__.d.ts +4 -0
  128. package/out/concepts/QueryFromExpression__.js +14 -3
  129. package/out/concepts/QueryFromExpression__.js.map +1 -1
  130. package/out/concepts/QueryGroupByExpression__.js +1 -1
  131. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  132. package/out/concepts/QueryJoinExpression__.d.ts +4 -0
  133. package/out/concepts/QueryJoinExpression__.js +15 -4
  134. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  135. package/out/concepts/QueryLimitExpression__.js +1 -1
  136. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  137. package/out/concepts/QueryOrderByExpression__.js +1 -1
  138. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  139. package/out/concepts/QuerySelectExpression__.js +1 -1
  140. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  141. package/out/concepts/Rect__.js +1 -1
  142. package/out/concepts/Rect__.js.map +1 -1
  143. package/out/concepts/Return__.js +1 -1
  144. package/out/concepts/Return__.js.map +1 -1
  145. package/out/concepts/Role__.js +11 -4
  146. package/out/concepts/Role__.js.map +1 -1
  147. package/out/concepts/Slot__.js +1 -1
  148. package/out/concepts/Slot__.js.map +1 -1
  149. package/out/concepts/SqlQueryComponent__.d.ts +10 -0
  150. package/out/concepts/SqlQueryComponent__.js +32 -5
  151. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  152. package/out/concepts/Start__.js +1 -1
  153. package/out/concepts/Start__.js.map +1 -1
  154. package/out/concepts/StringLiteral__.js +1 -1
  155. package/out/concepts/StringLiteral__.js.map +1 -1
  156. package/out/concepts/StructureProperty__.js +1 -1
  157. package/out/concepts/StructureProperty__.js.map +1 -1
  158. package/out/concepts/Structure__.js +20 -13
  159. package/out/concepts/Structure__.js.map +1 -1
  160. package/out/concepts/SwitchCase__.js +6 -6
  161. package/out/concepts/SwitchCase__.js.map +1 -1
  162. package/out/concepts/SwitchStatement__.js +1 -1
  163. package/out/concepts/SwitchStatement__.js.map +1 -1
  164. package/out/concepts/Theme__.js +1 -1
  165. package/out/concepts/Theme__.js.map +1 -1
  166. package/out/concepts/Transactional__.js +1 -1
  167. package/out/concepts/Transactional__.js.map +1 -1
  168. package/out/concepts/TypeAnnotation__.d.ts +8 -0
  169. package/out/concepts/TypeAnnotation__.js +46 -4
  170. package/out/concepts/TypeAnnotation__.js.map +1 -1
  171. package/out/concepts/TypeParam__.js +1 -1
  172. package/out/concepts/TypeParam__.js.map +1 -1
  173. package/out/concepts/UnaryExpression__.js +1 -1
  174. package/out/concepts/UnaryExpression__.js.map +1 -1
  175. package/out/concepts/Unparsed__.js +1 -1
  176. package/out/concepts/Unparsed__.js.map +1 -1
  177. package/out/concepts/UseComponent__.js +1 -1
  178. package/out/concepts/UseComponent__.js.map +1 -1
  179. package/out/concepts/ValidationRule__.js +1 -1
  180. package/out/concepts/ValidationRule__.js.map +1 -1
  181. package/out/concepts/Variable__.js +1 -1
  182. package/out/concepts/Variable__.js.map +1 -1
  183. package/out/concepts/ViewComponent__.js +1 -1
  184. package/out/concepts/ViewComponent__.js.map +1 -1
  185. package/out/concepts/ViewElement__.js +18 -18
  186. package/out/concepts/ViewElement__.js.map +1 -1
  187. package/out/concepts/View__.js +25 -23
  188. package/out/concepts/View__.js.map +1 -1
  189. package/out/concepts/WhileStatement__.js +5 -5
  190. package/out/concepts/WhileStatement__.js.map +1 -1
  191. package/out/concepts/basics/stdlib/nasl.util.js +278 -0
  192. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  193. package/out/concepts/index__.d.ts +1 -0
  194. package/out/concepts/index__.js +1 -0
  195. package/out/concepts/index__.js.map +1 -1
  196. package/out/generator/genBundleFiles.js +8 -3
  197. package/out/generator/genBundleFiles.js.map +1 -1
  198. package/out/generator/genMetaData.js +13 -12
  199. package/out/generator/genMetaData.js.map +1 -1
  200. package/out/server/createUiTs.js +1 -0
  201. package/out/server/createUiTs.js.map +1 -1
  202. package/out/server/getLogics.js +9 -1
  203. package/out/server/getLogics.js.map +1 -1
  204. package/out/server/getProcesses.d.ts +3 -0
  205. package/out/server/getProcesses.js +61 -1
  206. package/out/server/getProcesses.js.map +1 -1
  207. package/out/server/naslServer.js +128 -6
  208. package/out/server/naslServer.js.map +1 -1
  209. package/out/server/process2LogicNamespace.js +10 -1
  210. package/out/server/process2LogicNamespace.js.map +1 -1
  211. package/out/server/translator.js +19 -1
  212. package/out/server/translator.js.map +1 -1
  213. package/out/service/storage/init.js +2 -2
  214. package/out/service/storage/init.js.map +1 -1
  215. package/out/templator/genCreateBlock.js +15 -11
  216. package/out/templator/genCreateBlock.js.map +1 -1
  217. package/out/templator/genCurdEditMultipleKeyBlock.js +15 -12
  218. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  219. package/out/templator/genCurdMultipleKeyBlock.js +25 -21
  220. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  221. package/out/templator/genEditTableBlock.js +12 -12
  222. package/out/templator/genEditTableBlock.js.map +1 -1
  223. package/out/templator/genGridViewBlock.js +21 -20
  224. package/out/templator/genGridViewBlock.js.map +1 -1
  225. package/out/templator/genListViewBlock.js +6 -3
  226. package/out/templator/genListViewBlock.js.map +1 -1
  227. package/out/templator/genQueryComponent.js +5 -5
  228. package/out/templator/genQueryComponent.js.map +1 -1
  229. package/out/templator/genSelectBlock.js +8 -7
  230. package/out/templator/genSelectBlock.js.map +1 -1
  231. package/out/templator/genTableBlock.js +17 -15
  232. package/out/templator/genTableBlock.js.map +1 -1
  233. package/out/templator/genUpdateBlock.js +15 -11
  234. package/out/templator/genUpdateBlock.js.map +1 -1
  235. package/out/templator/utils.d.ts +2 -2
  236. package/out/templator/utils.js.map +1 -1
  237. package/out/test/integration/connect-file.js +6 -6
  238. package/out/test/integration/connect-file.js.map +1 -1
  239. package/out/translator/index.js +1 -1
  240. package/out/translator/index.js.map +1 -1
  241. package/out/utils/index.d.ts +4 -0
  242. package/out/utils/index.js +32 -1
  243. package/out/utils/index.js.map +1 -1
  244. package/package.json +1 -1
  245. package/src/automate/engine/index.js +12 -1
  246. package/src/automate/engine/uniqueName.js +1 -1
  247. package/src/automate/engine/utils.js +92 -67
  248. package/src/concepts/App__.ts +165 -95
  249. package/src/concepts/Argument__.ts +1 -1
  250. package/src/concepts/Assignee__.ts +1 -1
  251. package/src/concepts/Assignment__.ts +1 -1
  252. package/src/concepts/Attribute__.ts +1 -1
  253. package/src/concepts/BinaryExpression__.ts +1 -1
  254. package/src/concepts/BindAttribute__.ts +3 -3
  255. package/src/concepts/BindDirective__.ts +1 -1
  256. package/src/concepts/BindEvent__.ts +10 -6
  257. package/src/concepts/BooleanLiteral__.ts +1 -1
  258. package/src/concepts/CallFunction__.ts +19 -16
  259. package/src/concepts/CallInterface__.ts +1 -1
  260. package/src/concepts/CallLogic__.ts +23 -23
  261. package/src/concepts/CallQueryComponent__.ts +96 -113
  262. package/src/concepts/Comment__.ts +2 -2
  263. package/src/concepts/CompletionProperty__.ts +1 -1
  264. package/src/concepts/ConfigGroup__.ts +4 -2
  265. package/src/concepts/ConfigPropertyValue__.ts +1 -1
  266. package/src/concepts/ConfigProperty__.ts +5 -1
  267. package/src/concepts/Configuration__.ts +4 -1
  268. package/src/concepts/Constant__.ts +1 -1
  269. package/src/concepts/DataElement__.ts +1 -1
  270. package/src/concepts/DataSource__.ts +389 -0
  271. package/src/concepts/Destination__.ts +24 -8
  272. package/src/concepts/End__.ts +3 -3
  273. package/src/concepts/EntityIndex__.ts +8 -1
  274. package/src/concepts/EntityProperty__.ts +21 -3
  275. package/src/concepts/Entity__.ts +24 -12
  276. package/src/concepts/EnumItem__.ts +1 -1
  277. package/src/concepts/Enum__.ts +24 -5
  278. package/src/concepts/Event__.ts +1 -1
  279. package/src/concepts/ForEachStatement__.ts +3 -3
  280. package/src/concepts/Function__.ts +97 -3
  281. package/src/concepts/Identifier__.ts +12 -13
  282. package/src/concepts/IfStatement__.ts +10 -10
  283. package/src/concepts/InterfaceParam__.ts +1 -1
  284. package/src/concepts/Interface__.ts +20 -12
  285. package/src/concepts/JSBlock__.ts +1 -1
  286. package/src/concepts/LogicItem__.ts +1 -1
  287. package/src/concepts/Logic__.ts +41 -39
  288. package/src/concepts/MemberExpression__.ts +1 -1
  289. package/src/concepts/Module__.ts +9 -204
  290. package/src/concepts/Namespace__.ts +1 -204
  291. package/src/concepts/NullLiteral__.ts +1 -1
  292. package/src/concepts/NumericLiteral__.ts +1 -1
  293. package/src/concepts/Param__.ts +3 -2
  294. package/src/concepts/Point__.ts +1 -1
  295. package/src/concepts/ProcessComponent__.ts +1 -1
  296. package/src/concepts/ProcessElement__.ts +29 -13
  297. package/src/concepts/ProcessOutcome__.ts +1 -1
  298. package/src/concepts/Process__.ts +17 -11
  299. package/src/concepts/QueryAggregateExpression__.ts +1 -1
  300. package/src/concepts/QueryFieldExpression__.ts +10 -2
  301. package/src/concepts/QueryFromExpression__.ts +14 -3
  302. package/src/concepts/QueryGroupByExpression__.ts +1 -1
  303. package/src/concepts/QueryJoinExpression__.ts +15 -4
  304. package/src/concepts/QueryLimitExpression__.ts +1 -1
  305. package/src/concepts/QueryOrderByExpression__.ts +1 -1
  306. package/src/concepts/QuerySelectExpression__.ts +1 -1
  307. package/src/concepts/Rect__.ts +1 -1
  308. package/src/concepts/Return__.ts +1 -1
  309. package/src/concepts/Role__.ts +11 -5
  310. package/src/concepts/Slot__.ts +1 -1
  311. package/src/concepts/SqlQueryComponent__.ts +30 -11
  312. package/src/concepts/Start__.ts +1 -1
  313. package/src/concepts/StringLiteral__.ts +1 -1
  314. package/src/concepts/StructureProperty__.ts +1 -1
  315. package/src/concepts/Structure__.ts +20 -12
  316. package/src/concepts/SwitchCase__.ts +6 -6
  317. package/src/concepts/SwitchStatement__.ts +1 -1
  318. package/src/concepts/Theme__.ts +1 -1
  319. package/src/concepts/Transactional__.ts +1 -1
  320. package/src/concepts/TypeAnnotation__.ts +45 -23
  321. package/src/concepts/TypeParam__.ts +1 -1
  322. package/src/concepts/UnaryExpression__.ts +1 -1
  323. package/src/concepts/Unparsed__.ts +1 -1
  324. package/src/concepts/UseComponent__.ts +1 -1
  325. package/src/concepts/ValidationRule__.ts +1 -1
  326. package/src/concepts/Variable__.ts +1 -1
  327. package/src/concepts/ViewComponent__.ts +1 -1
  328. package/src/concepts/ViewElement__.ts +19 -19
  329. package/src/concepts/View__.ts +25 -23
  330. package/src/concepts/WhileStatement__.ts +5 -5
  331. package/src/concepts/basics/stdlib/nasl.util.ts +279 -0
  332. package/src/concepts/index__.ts +1 -0
  333. package/src/generator/genBundleFiles.ts +8 -3
  334. package/src/generator/genMetaData.ts +13 -13
  335. package/src/server/createUiTs.ts +1 -0
  336. package/src/server/getLogics.ts +11 -3
  337. package/src/server/getProcesses.ts +61 -0
  338. package/src/server/naslServer.ts +124 -6
  339. package/src/server/process2LogicNamespace.ts +29 -19
  340. package/src/server/translator.ts +22 -1
  341. package/src/service/storage/init.ts +2 -2
  342. package/src/templator/genCreateBlock.ts +16 -13
  343. package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -13
  344. package/src/templator/genCurdMultipleKeyBlock.ts +26 -22
  345. package/src/templator/genEditTableBlock.ts +14 -13
  346. package/src/templator/genGridViewBlock.ts +22 -21
  347. package/src/templator/genListViewBlock.ts +9 -5
  348. package/src/templator/genQueryComponent.ts +6 -6
  349. package/src/templator/genSelectBlock.ts +9 -8
  350. package/src/templator/genTableBlock.ts +18 -16
  351. package/src/templator/genUpdateBlock.ts +16 -12
  352. package/src/templator/utils.ts +2 -2
  353. package/src/test/integration/connect-file.ts +6 -6
  354. package/src/translator/index.ts +1 -1
  355. package/src/utils/index.ts +32 -0
@@ -1,5 +1,5 @@
1
1
  import * as utils from '../utils';
2
- import { App, Namespace, Entity, EntityProperty, View } from '../concepts';
2
+ import { App, Module, Namespace, Entity, EntityProperty, View, DataSource } from '../concepts';
3
3
  import {
4
4
  getExpression,
5
5
  filterProperty,
@@ -83,8 +83,8 @@ export function genTableTemplate(entity: Entity, nameGroup: NameGroup, modifyabl
83
83
  * @param entity 实体
84
84
  */
85
85
  export function genTableLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic: any, supportFilter: boolean) {
86
- const parentNode = entity.parentNode as App | Namespace;
87
- const parentNamespace = parentNode?.getNamespace();
86
+ const moduleNode = utils.findClosestModule(entity) as App | Module;
87
+ const moduleNamespace = moduleNode?.getNamespace();
88
88
  const params = [
89
89
  genLogicParam(`${newLogic.params[0].name}`, 'params.page'),
90
90
  genLogicParam(`${newLogic.params[1].name}`, 'params.size'),
@@ -108,7 +108,7 @@ export function genTableLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic
108
108
  name: 'result',
109
109
  typeAnnotation: NaslCollectionTypeAnnotation.PageOf([
110
110
  NaslTypeAnnotation.Reference({
111
- typeNamespace: `${parentNamespace}.structures`,
111
+ typeNamespace: `${moduleNamespace}.structures`,
112
112
  typeName: nameGroup.structure,
113
113
  }),
114
114
  ]),
@@ -122,7 +122,7 @@ export function genTableLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic
122
122
  name: 'result',
123
123
  }),
124
124
  right: NaslLogicItem.CallLogic({
125
- calleeNamespace: `${parentNamespace}.logics`,
125
+ calleeNamespace: `${moduleNamespace}.logics`,
126
126
  calleeName: newLogic.name,
127
127
  arguments: params,
128
128
  }),
@@ -138,8 +138,8 @@ export function genTableLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic
138
138
  */
139
139
  export function genTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
140
140
  const lowerEntityName = utils.firstLowerCase(entity.name);
141
- const parentNode = entity.parentNode as App | Namespace;
142
- const parentNamespace = parentNode?.getNamespace();
141
+ const moduleNode = utils.findClosestModule(entity) as App | Module;
142
+ const moduleNamespace = moduleNode?.getNamespace();
143
143
  const ns = entity.ns;
144
144
  const deleteLogic = ns?.logics?.find((logic) => logic.name === 'delete');
145
145
  const idPropertys = entity.properties.filter((property) => property.primaryKey);
@@ -154,7 +154,7 @@ export function genTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
154
154
  name: 'scope',
155
155
  typeAnnotation: NaslUITypeAnnotation.ScopeOf([
156
156
  NaslTypeAnnotation.Reference({
157
- typeNamespace: `${parentNamespace}.structures`,
157
+ typeNamespace: `${moduleNamespace}.structures`,
158
158
  typeName: nameGroup.structure,
159
159
  }),
160
160
  ]),
@@ -192,10 +192,11 @@ export function genTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
192
192
  * load_select_student -> load_someView_select_student
193
193
  */
194
194
  export function genTableBlock(entity: Entity, view: View) {
195
- const parentNode = entity.parentNode as App | Namespace;
195
+ const dataSource = entity.parentNode as DataSource;
196
+ const module = dataSource.parentNode as App | Module | Namespace;
196
197
 
197
198
  const viewElementMainView = view.getViewElementUniqueName('tableView');
198
- const nameGroup = genUniqueQueryNameGroup(parentNode, view, viewElementMainView);
199
+ const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
199
200
  nameGroup.viewElementMainView = viewElementMainView;
200
201
  nameGroup.viewVariableEntity = view.getVariableUniqueName(utils.firstLowerCase(entity.name));
201
202
  nameGroup.viewLogicRemove = view.getLogicUniqueName('remove');
@@ -207,7 +208,7 @@ export function genTableBlock(entity: Entity, view: View) {
207
208
  entity.properties.forEach((property) => {
208
209
  if (property.relationEntity) {
209
210
  // 有外键关联
210
- const relationEntity = parentNode?.findEntityByName(property.relationEntity);
211
+ const relationEntity = dataSource?.findEntityByName(property.relationEntity);
211
212
  if (relationEntity) {
212
213
  const displayedProperty = getFirstDisplayedProperty(relationEntity);
213
214
  if (displayedProperty)
@@ -217,7 +218,7 @@ export function genTableBlock(entity: Entity, view: View) {
217
218
  });
218
219
  const entityStructure = genQueryStructure(allEntities, nameGroup);
219
220
  newStructures.push(entityStructure);
220
- const entityLogic = genQueryLogic(allEntities, nameGroup, false, true, parentNode);
221
+ const entityLogic = genQueryLogic(allEntities, nameGroup, false, true, module);
221
222
  newLogics.push(entityLogic);
222
223
 
223
224
  return `
@@ -240,10 +241,11 @@ export function genTableBlock(entity: Entity, view: View) {
240
241
 
241
242
  export function genTableColumnBlock(property: EntityProperty, view: View) {
242
243
  const entity = property.entity;
243
- const parentNode = entity.parentNode as App | Namespace;
244
+ const dataSource = entity.parentNode as DataSource;
245
+ const module = dataSource.parentNode as App | Module | Namespace;
244
246
 
245
247
  const viewElementMainView = view.getViewElementUniqueName('tableView');
246
- const nameGroup = genUniqueQueryNameGroup(parentNode, view, viewElementMainView);
248
+ const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
247
249
  nameGroup.viewElementMainView = viewElementMainView;
248
250
  nameGroup.viewVariableEntity = view.getVariableUniqueName(utils.firstLowerCase(entity.name));
249
251
  nameGroup.viewLogicRemove = view.getLogicUniqueName('remove');
@@ -256,7 +258,7 @@ export function genTableColumnBlock(property: EntityProperty, view: View) {
256
258
  properties.forEach((property) => {
257
259
  if (property.relationEntity) {
258
260
  // 有外键关联
259
- const relationEntity = parentNode?.findEntityByName(property.relationEntity);
261
+ const relationEntity = dataSource?.findEntityByName(property.relationEntity);
260
262
  if (relationEntity) {
261
263
  const displayedProperty = getFirstDisplayedProperty(relationEntity);
262
264
  if (displayedProperty)
@@ -267,7 +269,7 @@ export function genTableColumnBlock(property: EntityProperty, view: View) {
267
269
 
268
270
  const entityStructure = genQueryStructure(allEntities, nameGroup);
269
271
  newStructures.push(entityStructure);
270
- const entityLogic = genQueryLogic(allEntities, nameGroup, false, true, parentNode);
272
+ const entityLogic = genQueryLogic(allEntities, nameGroup, false, true, module);
271
273
  newLogics.push(entityLogic);
272
274
 
273
275
  return `
@@ -1,6 +1,6 @@
1
1
  import { config } from '../config';
2
2
  import * as utils from '../utils';
3
- import { App, Namespace, Entity, Logic, View, Enum } from '../concepts';
3
+ import { App, Module, Namespace, Entity, Logic, View, Enum, DataSource } from '../concepts';
4
4
  import { NaslCoreTypeAnnotation, NaslUITypeAnnotation, NaslTypeAnnotation, NaslLogicItem, NaslNode } from './utils';
5
5
  import {
6
6
  NameGroup,
@@ -16,7 +16,8 @@ import {
16
16
  } from '.';
17
17
 
18
18
  export function genUpdateFormTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
19
- const parentNode = entity.parentNode as App | Namespace;
19
+ const dataSource = entity.parentNode as DataSource;
20
+ const module = dataSource.parentNode as App | Module | Namespace;
20
21
  const properties = entity.properties.filter(filterProperty('inForm'));
21
22
 
22
23
  return `<u-form ref="${nameGroup.viewElementMainView}">
@@ -39,7 +40,7 @@ export function genUpdateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
39
40
  const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
40
41
  if (property.relationEntity) {
41
42
  // 有外键关联
42
- const relationEntity = parentNode?.findEntityByName(property.relationEntity);
43
+ const relationEntity = dataSource?.findEntityByName(property.relationEntity);
43
44
  if (relationEntity) {
44
45
  const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
45
46
  const displayedProperty = getFirstDisplayedProperty(relationEntity);
@@ -73,7 +74,7 @@ export function genUpdateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
73
74
  const namespaceArr = propertyTypeNamespace.split('.');
74
75
  const type = namespaceArr.pop();
75
76
  if (type === 'enums') {
76
- formItem += genEnumSelectBlock(parentNode.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
77
+ formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
77
78
  } else {
78
79
  formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
79
80
  }
@@ -90,7 +91,8 @@ export function genUpdateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
90
91
  }
91
92
 
92
93
  export function genH5UpdateFormTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
93
- const parentNode = entity.parentNode as App | Namespace;
94
+ const dataSource = entity.parentNode as DataSource;
95
+ const module = dataSource.parentNode as App | Module | Namespace;
94
96
  const properties = entity.properties.filter(filterProperty('inForm'));
95
97
 
96
98
  return `<van-form ref="${nameGroup.viewElementMainView}">
@@ -107,13 +109,13 @@ export function genH5UpdateFormTemplate(entity: Entity, nameGroup: NameGroup, se
107
109
  rules.push('required');
108
110
  const rulesStr = rules.join(' | ');
109
111
 
110
- let formItem = ` <van-field drole="other" label="${label}"${required ? ' required' : ''}${rulesStr.length ? ` rules="${rulesStr}"` : ''}>\n`;
112
+ let formItem = ` <van-field drole="other" ${required ? ' required' : ''}${rulesStr.length ? ` rules="${rulesStr}"` : ''}>\n`;
111
113
 
112
114
  const { typeAnnotation } = property || {};
113
115
  const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
114
116
  if (property.relationEntity) {
115
117
  // 有外键关联
116
- const relationEntity = parentNode?.findEntityByName(property.relationEntity);
118
+ const relationEntity = dataSource?.findEntityByName(property.relationEntity);
117
119
  if (relationEntity) {
118
120
  const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
119
121
  const displayedProperty = getFirstDisplayedProperty(relationEntity);
@@ -150,12 +152,13 @@ export function genH5UpdateFormTemplate(entity: Entity, nameGroup: NameGroup, se
150
152
  const namespaceArr = propertyTypeNamespace.split('.');
151
153
  const type = namespaceArr.pop();
152
154
  if (type === 'enums') {
153
- formItem += '<template #input>' + genEnumSelectBlock(parentNode.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true) + '</template>';
155
+ formItem += '<template #input>' + genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true) + '</template>';
154
156
  } else {
155
157
  formItem += `<template #input><van-fieldinput v-model="${vModel}" placeholder="请输入${label}"></van-fieldinput></template>`;
156
158
  }
157
159
  }
158
160
 
161
+ formItem += `<template #title><van-text text="${label}"><van-text></template>`;
159
162
  formItem += ` </van-field>\n`;
160
163
 
161
164
  formItem = formItem.replace(/>\n<van-input|<\/van-input>/g, '');
@@ -251,7 +254,8 @@ function genLoadLogic(getLogic: Logic, nameGroup: NameGroup) {
251
254
  }
252
255
 
253
256
  export function genUpdateBlock(entity: Entity, view: View) {
254
- const parentNode = entity.parentNode as App | Namespace;
257
+ const dataSource = entity.parentNode as DataSource;
258
+ const module = dataSource.parentNode as App | Module | Namespace;
255
259
  const ns = entity.ns;
256
260
  const getLogic = ns?.logics?.find((logic) => logic.name === `get`);
257
261
  const updateLogic = ns?.logics?.find((logic) => logic.name === `update`);
@@ -271,16 +275,16 @@ export function genUpdateBlock(entity: Entity, view: View) {
271
275
  entity.properties.forEach((property) => {
272
276
  // 有外键关联
273
277
  if (property.relationEntity) {
274
- const relationEntity = parentNode?.findEntityByName(property.relationEntity);
278
+ const relationEntity = dataSource?.findEntityByName(property.relationEntity);
275
279
  if (relationEntity) {
276
280
  const displayedProperty = getFirstDisplayedProperty(relationEntity);
277
281
  if (displayedProperty) {
278
282
  const viewElementSelect = view.getViewElementUniqueName('select');
279
- const selectNameGroup = genUniqueQueryNameGroup(parentNode, view, viewElementSelect, false, relationEntity.name);
283
+ const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
280
284
  selectNameGroup.viewElementSelect = viewElementSelect;
281
285
  selectNameGroupMap.set(relationEntity.name, selectNameGroup);
282
286
  const newStructure = genQueryStructure([relationEntity], selectNameGroup);
283
- const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, parentNode);
287
+ const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, module);
284
288
  newStructures.push(newStructure);
285
289
  newLogics.push(newLogic);
286
290
  newLoadSelectLogics.push(genLoadSelectLogic(relationEntity, selectNameGroup, newLogic));
@@ -1,5 +1,5 @@
1
1
  import { utils } from '..';
2
- import { App, Namespace, Entity, EntityProperty, Logic, View } from '../concepts';
2
+ import { App, Module, Entity, EntityProperty, Logic, View, Namespace } from '../concepts';
3
3
 
4
4
  export const filterProperty = (key: 'inTable' | 'inFilter' | 'inForm' | 'inDetail') => (property: EntityProperty) => {
5
5
  if (property.display) {
@@ -136,7 +136,7 @@ function capFirstLetter(word: string) {
136
136
  * @param suffix 其它后缀,比如实体名等等
137
137
  * @param defaultInView 是否在页面逻辑中用 load 简写
138
138
  */
139
- export function genUniqueQueryNameGroup(scope: App | Namespace, view: View, componentName: string = '', defaultInView: boolean = true, suffix: string = '') {
139
+ export function genUniqueQueryNameGroup(scope: App | Module | Namespace, view: View, componentName: string = '', defaultInView: boolean = true, suffix: string = '') {
140
140
  const result: NameGroup = {};
141
141
  result.viewLogicLoad = view.getLogicUniqueName(`load${defaultInView ? '' : capFirstLetter(componentName)}${suffix ? capFirstLetter(suffix) : ''}`);
142
142
  result.logic = scope.getLogicUniqueName(`load${capFirstLetter(view.name)}${componentName ? capFirstLetter(componentName) : ''}${suffix ? capFirstLetter(suffix) : ''}`);
@@ -12,13 +12,13 @@ describe('connect-file', () => {
12
12
  it('batchAction', async () => {
13
13
  await nasl.connect('file', path.join(__dirname, '../examples/app1.json'));
14
14
  const app = await nasl.loadApp();
15
- if (app.entities.length > 0) {
16
- const oldLength = app.entities.length;
17
- await app.entities[0].delete();
18
- expect(app.entities.length).to.equal(oldLength - 1);
15
+ if (app.dataSources.length > 0) {
16
+ const oldLength = app.dataSources.length;
17
+ await app.dataSources[0].delete();
18
+ expect(app.dataSources.length).to.equal(oldLength - 1);
19
19
  } else {
20
- await app.addEntity();
21
- expect(app.entities.length).to.equal(1);
20
+ await app.addDataSource();
21
+ expect(app.dataSources.length).to.equal(1);
22
22
  }
23
23
  });
24
24
  });
@@ -97,7 +97,7 @@ export function withSourceMap() {
97
97
 
98
98
  let before: string = '';
99
99
  if (!state.inline) {
100
- before = indent(state.tabSize);
100
+ before = indent((state?.tabSize || 0));
101
101
  state = shiftState(state, before);
102
102
  } else {
103
103
  state = shiftState(state, before, {
@@ -3,8 +3,40 @@ export * from './traverse';
3
3
  export * from './logger';
4
4
 
5
5
  import { compare } from 'compare-versions';
6
+ import { BaseNode } from '..';
6
7
  import { traverse } from './traverse';
7
8
 
9
+ // 查找最近的模块
10
+ export function findClosestModule(node: BaseNode) {
11
+ let moduleNode = node;
12
+ while (moduleNode && !['App', 'Module'].includes(moduleNode.concept)) {
13
+ moduleNode = moduleNode.parentNode;
14
+ }
15
+ return moduleNode;
16
+ }
17
+
18
+ // 从namespace获取关键字
19
+ export function findConceptKeyWordByNamespace(namespace: string) {
20
+ const namespaceArr = namespace?.split('.') || [];
21
+ const start = namespaceArr[0];
22
+ const mod = start === 'app' ? 1 : 0;
23
+ const keywordViews = namespaceArr.filter((namespaceItem, index) => index % 2 === mod);
24
+ return keywordViews.pop();
25
+ }
26
+
27
+ // 从namespace中查找concept关键字
28
+ export function findConceptKeyWordIndexFromNamespace(namespace: string, keyword: string) {
29
+ const namespaceArr = namespace?.split('.') || [];
30
+ const start = namespaceArr[0];
31
+ const mod = start === 'app' ? 1 : 0;
32
+ return namespaceArr.findIndex((namespaceItem, index) => {
33
+ if (index % 2 === mod) {
34
+ return namespaceItem === keyword;
35
+ }
36
+ return false;
37
+ });
38
+ }
39
+
8
40
  export function getGlobalEnv() {
9
41
  return typeof window !== 'undefined' ? (window as any).appInfo.env : (global as any).appInfoEnv;
10
42
  }