@lcap/nasl 1.0.2 → 2.12.0

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 (299) hide show
  1. package/out/automate/engine/index.d.ts +1 -0
  2. package/out/automate/engine/index.js +34 -12
  3. package/out/automate/engine/index.js.map +1 -1
  4. package/out/automate/engine/operators.d.ts +10 -2
  5. package/out/automate/engine/operators.js +105 -7
  6. package/out/automate/engine/operators.js.map +1 -1
  7. package/out/automate/engine/uniqueName.d.ts +8 -2
  8. package/out/automate/engine/uniqueName.js +72 -4
  9. package/out/automate/engine/uniqueName.js.map +1 -1
  10. package/out/automate/engine/utils.d.ts +1 -0
  11. package/out/automate/engine/utils.js +92 -67
  12. package/out/automate/engine/utils.js.map +1 -1
  13. package/out/automate/template/process.d.ts +9 -0
  14. package/out/automate/template/process.js +10976 -0
  15. package/out/automate/template/process.js.map +1 -0
  16. package/out/bak/translator.js +1 -0
  17. package/out/bak/translator.js.map +1 -1
  18. package/out/common/BaseNode.d.ts +5 -0
  19. package/out/common/BaseNode.js +24 -3
  20. package/out/common/BaseNode.js.map +1 -1
  21. package/out/concepts/App__.d.ts +51 -49
  22. package/out/concepts/App__.js +86 -53
  23. package/out/concepts/App__.js.map +1 -1
  24. package/out/concepts/BindAttribute__.js +2 -2
  25. package/out/concepts/BindAttribute__.js.map +1 -1
  26. package/out/concepts/BindDirective__.js +10 -3
  27. package/out/concepts/BindDirective__.js.map +1 -1
  28. package/out/concepts/BindEvent__.js +15 -6
  29. package/out/concepts/BindEvent__.js.map +1 -1
  30. package/out/concepts/BooleanLiteral__.d.ts +4 -0
  31. package/out/concepts/BooleanLiteral__.js +11 -0
  32. package/out/concepts/BooleanLiteral__.js.map +1 -1
  33. package/out/concepts/CallFunction__.js +8 -2
  34. package/out/concepts/CallFunction__.js.map +1 -1
  35. package/out/concepts/CallLogic__.js +48 -30
  36. package/out/concepts/CallLogic__.js.map +1 -1
  37. package/out/concepts/CallQueryComponent__.d.ts +8 -7
  38. package/out/concepts/CallQueryComponent__.js +86 -76
  39. package/out/concepts/CallQueryComponent__.js.map +1 -1
  40. package/out/concepts/Comment__.js +1 -1
  41. package/out/concepts/Comment__.js.map +1 -1
  42. package/out/concepts/ConfigGroup__.d.ts +1 -0
  43. package/out/concepts/ConfigGroup__.js +7 -0
  44. package/out/concepts/ConfigGroup__.js.map +1 -1
  45. package/out/concepts/ConfigProperty__.d.ts +1 -0
  46. package/out/concepts/ConfigProperty__.js +3 -0
  47. package/out/concepts/ConfigProperty__.js.map +1 -1
  48. package/out/concepts/Configuration__.d.ts +1 -0
  49. package/out/concepts/Configuration__.js +3 -0
  50. package/out/concepts/Configuration__.js.map +1 -1
  51. package/out/concepts/DataSource__.d.ts +143 -0
  52. package/out/concepts/DataSource__.js +318 -0
  53. package/out/concepts/DataSource__.js.map +1 -0
  54. package/out/concepts/Destination__.js +8 -8
  55. package/out/concepts/Destination__.js.map +1 -1
  56. package/out/concepts/End__.js +2 -2
  57. package/out/concepts/End__.js.map +1 -1
  58. package/out/concepts/EntityIndex__.d.ts +5 -0
  59. package/out/concepts/EntityIndex__.js +6 -0
  60. package/out/concepts/EntityIndex__.js.map +1 -1
  61. package/out/concepts/EntityProperty__.d.ts +9 -0
  62. package/out/concepts/EntityProperty__.js +19 -2
  63. package/out/concepts/EntityProperty__.js.map +1 -1
  64. package/out/concepts/Entity__.d.ts +5 -0
  65. package/out/concepts/Entity__.js +20 -10
  66. package/out/concepts/Entity__.js.map +1 -1
  67. package/out/concepts/Enum__.js +12 -6
  68. package/out/concepts/Enum__.js.map +1 -1
  69. package/out/concepts/ForEachStatement__.js +2 -2
  70. package/out/concepts/ForEachStatement__.js.map +1 -1
  71. package/out/concepts/Function__.d.ts +18 -0
  72. package/out/concepts/Function__.js +96 -1
  73. package/out/concepts/Function__.js.map +1 -1
  74. package/out/concepts/Identifier__.js +6 -15
  75. package/out/concepts/Identifier__.js.map +1 -1
  76. package/out/concepts/IfStatement__.js +8 -8
  77. package/out/concepts/IfStatement__.js.map +1 -1
  78. package/out/concepts/Interface__.js +19 -12
  79. package/out/concepts/Interface__.js.map +1 -1
  80. package/out/concepts/JSBlock__.js +3 -5
  81. package/out/concepts/JSBlock__.js.map +1 -1
  82. package/out/concepts/Logic__.js +44 -44
  83. package/out/concepts/Logic__.js.map +1 -1
  84. package/out/concepts/Module__.d.ts +116 -194
  85. package/out/concepts/Module__.js +31 -114
  86. package/out/concepts/Module__.js.map +1 -1
  87. package/out/concepts/Namespace__.d.ts +0 -86
  88. package/out/concepts/Namespace__.js +1 -108
  89. package/out/concepts/Namespace__.js.map +1 -1
  90. package/out/concepts/Param__.d.ts +2 -1
  91. package/out/concepts/Param__.js +1 -1
  92. package/out/concepts/Param__.js.map +1 -1
  93. package/out/concepts/ProcessElement__.js +30 -10
  94. package/out/concepts/ProcessElement__.js.map +1 -1
  95. package/out/concepts/Process__.d.ts +1 -1
  96. package/out/concepts/Process__.js +17 -10
  97. package/out/concepts/Process__.js.map +1 -1
  98. package/out/concepts/QueryFieldExpression__.js +8 -1
  99. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  100. package/out/concepts/QueryFromExpression__.d.ts +4 -0
  101. package/out/concepts/QueryFromExpression__.js +13 -2
  102. package/out/concepts/QueryFromExpression__.js.map +1 -1
  103. package/out/concepts/QueryJoinExpression__.d.ts +4 -0
  104. package/out/concepts/QueryJoinExpression__.js +14 -3
  105. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  106. package/out/concepts/Return__.js +1 -1
  107. package/out/concepts/Return__.js.map +1 -1
  108. package/out/concepts/Role__.js +10 -3
  109. package/out/concepts/Role__.js.map +1 -1
  110. package/out/concepts/SqlQueryComponent__.d.ts +14 -0
  111. package/out/concepts/SqlQueryComponent__.js +48 -5
  112. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  113. package/out/concepts/StringLiteral__.d.ts +1 -1
  114. package/out/concepts/StringLiteral__.js +1 -1
  115. package/out/concepts/StructureProperty__.js +6 -5
  116. package/out/concepts/StructureProperty__.js.map +1 -1
  117. package/out/concepts/Structure__.js +19 -12
  118. package/out/concepts/Structure__.js.map +1 -1
  119. package/out/concepts/SwitchCase__.d.ts +1 -1
  120. package/out/concepts/SwitchCase__.js +23 -25
  121. package/out/concepts/SwitchCase__.js.map +1 -1
  122. package/out/concepts/SwitchStatement__.js +1 -6
  123. package/out/concepts/SwitchStatement__.js.map +1 -1
  124. package/out/concepts/TypeAnnotation__.d.ts +8 -0
  125. package/out/concepts/TypeAnnotation__.js +44 -2
  126. package/out/concepts/TypeAnnotation__.js.map +1 -1
  127. package/out/concepts/Variable__.js +1 -1
  128. package/out/concepts/Variable__.js.map +1 -1
  129. package/out/concepts/ViewElement__.js +25 -20
  130. package/out/concepts/ViewElement__.js.map +1 -1
  131. package/out/concepts/View__.d.ts +0 -2
  132. package/out/concepts/View__.js +27 -32
  133. package/out/concepts/View__.js.map +1 -1
  134. package/out/concepts/WhileStatement__.js +4 -4
  135. package/out/concepts/WhileStatement__.js.map +1 -1
  136. package/out/concepts/basics/stdlib/nasl.auth.js +20 -0
  137. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
  138. package/out/concepts/basics/stdlib/nasl.process.d.ts +4 -0
  139. package/out/concepts/basics/stdlib/nasl.process.js +410 -0
  140. package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
  141. package/out/concepts/basics/stdlib/nasl.ui.js +1 -11
  142. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  143. package/out/concepts/basics/stdlib/nasl.util.js +280 -2
  144. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  145. package/out/concepts/basics/types/index.d.ts +1 -0
  146. package/out/concepts/basics/types/index.js +4 -1
  147. package/out/concepts/basics/types/index.js.map +1 -1
  148. package/out/concepts/index__.d.ts +1 -0
  149. package/out/concepts/index__.js +1 -0
  150. package/out/concepts/index__.js.map +1 -1
  151. package/out/generator/genBundleFiles.d.ts +3 -1
  152. package/out/generator/genBundleFiles.js +23 -5
  153. package/out/generator/genBundleFiles.js.map +1 -1
  154. package/out/generator/genMetaData.d.ts +1 -0
  155. package/out/generator/genMetaData.js +20 -12
  156. package/out/generator/genMetaData.js.map +1 -1
  157. package/out/index.d.ts +1 -1
  158. package/out/index.js +2 -1
  159. package/out/index.js.map +1 -1
  160. package/out/server/createUiTs.js +1 -0
  161. package/out/server/createUiTs.js.map +1 -1
  162. package/out/server/getLogics.js +27 -1
  163. package/out/server/getLogics.js.map +1 -1
  164. package/out/server/getMemberIdentifier.js +5 -0
  165. package/out/server/getMemberIdentifier.js.map +1 -1
  166. package/out/server/getProcesses.d.ts +4 -0
  167. package/out/server/getProcesses.js +69 -1
  168. package/out/server/getProcesses.js.map +1 -1
  169. package/out/server/naslServer.d.ts +1 -0
  170. package/out/server/naslServer.js +223 -26
  171. package/out/server/naslServer.js.map +1 -1
  172. package/out/server/process2LogicNamespace.js +10 -1
  173. package/out/server/process2LogicNamespace.js.map +1 -1
  174. package/out/server/translator.js +37 -1
  175. package/out/server/translator.js.map +1 -1
  176. package/out/service/creator/errHandles.js +5 -0
  177. package/out/service/creator/errHandles.js.map +1 -1
  178. package/out/service/storage/init.d.ts +1 -0
  179. package/out/service/storage/init.js +95 -84
  180. package/out/service/storage/init.js.map +1 -1
  181. package/out/templator/genCreateBlock.js +34 -24
  182. package/out/templator/genCreateBlock.js.map +1 -1
  183. package/out/templator/genCurdEditMultipleKeyBlock.js +28 -18
  184. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  185. package/out/templator/genCurdMultipleKeyBlock.js +45 -29
  186. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  187. package/out/templator/genEditTableBlock.js +15 -13
  188. package/out/templator/genEditTableBlock.js.map +1 -1
  189. package/out/templator/genEnumSelectBlock.js +1 -1
  190. package/out/templator/genEnumSelectBlock.js.map +1 -1
  191. package/out/templator/genGridViewBlock.js +29 -24
  192. package/out/templator/genGridViewBlock.js.map +1 -1
  193. package/out/templator/genListViewBlock.js +7 -5
  194. package/out/templator/genListViewBlock.js.map +1 -1
  195. package/out/templator/genQueryComponent.js +25 -26
  196. package/out/templator/genQueryComponent.js.map +1 -1
  197. package/out/templator/genSelectBlock.js +8 -7
  198. package/out/templator/genSelectBlock.js.map +1 -1
  199. package/out/templator/genTableBlock.js +31 -21
  200. package/out/templator/genTableBlock.js.map +1 -1
  201. package/out/templator/genUpdateBlock.js +34 -24
  202. package/out/templator/genUpdateBlock.js.map +1 -1
  203. package/out/templator/utils.d.ts +2 -2
  204. package/out/templator/utils.js.map +1 -1
  205. package/out/test/integration/connect-file.js +6 -6
  206. package/out/test/integration/connect-file.js.map +1 -1
  207. package/out/translator/index.js +1 -1
  208. package/out/translator/index.js.map +1 -1
  209. package/out/utils/index.d.ts +5 -0
  210. package/out/utils/index.js +50 -1
  211. package/out/utils/index.js.map +1 -1
  212. package/package.json +1 -1
  213. package/src/automate/engine/index.js +33 -8
  214. package/src/automate/engine/operators.js +114 -17
  215. package/src/automate/engine/uniqueName.js +77 -9
  216. package/src/automate/engine/utils.js +95 -68
  217. package/src/automate/template/process.js +10999 -0
  218. package/src/bak/translator.js +1 -0
  219. package/src/common/BaseNode.ts +21 -4
  220. package/src/concepts/App__.ts +128 -94
  221. package/src/concepts/BindAttribute__.ts +2 -2
  222. package/src/concepts/BindDirective__.ts +9 -7
  223. package/src/concepts/BindEvent__.ts +14 -6
  224. package/src/concepts/BooleanLiteral__.ts +12 -0
  225. package/src/concepts/CallFunction__.ts +6 -2
  226. package/src/concepts/CallLogic__.ts +47 -32
  227. package/src/concepts/CallQueryComponent__.ts +92 -81
  228. package/src/concepts/Comment__.ts +1 -1
  229. package/src/concepts/ConfigGroup__.ts +3 -1
  230. package/src/concepts/ConfigProperty__.ts +4 -0
  231. package/src/concepts/Configuration__.ts +3 -0
  232. package/src/concepts/DataSource__.ts +391 -0
  233. package/src/concepts/Destination__.ts +24 -8
  234. package/src/concepts/End__.ts +2 -2
  235. package/src/concepts/EntityIndex__.ts +7 -0
  236. package/src/concepts/EntityProperty__.ts +20 -2
  237. package/src/concepts/Entity__.ts +23 -11
  238. package/src/concepts/Enum__.ts +25 -6
  239. package/src/concepts/ForEachStatement__.ts +2 -2
  240. package/src/concepts/Function__.ts +95 -1
  241. package/src/concepts/Identifier__.ts +15 -15
  242. package/src/concepts/IfStatement__.ts +9 -9
  243. package/src/concepts/Interface__.ts +20 -12
  244. package/src/concepts/JSBlock__.ts +3 -12
  245. package/src/concepts/Logic__.ts +45 -79
  246. package/src/concepts/Module__.ts +141 -342
  247. package/src/concepts/Namespace__.ts +1 -204
  248. package/src/concepts/Param__.ts +3 -2
  249. package/src/concepts/ProcessElement__.ts +33 -12
  250. package/src/concepts/Process__.ts +18 -12
  251. package/src/concepts/QueryFieldExpression__.ts +9 -1
  252. package/src/concepts/QueryFromExpression__.ts +13 -2
  253. package/src/concepts/QueryJoinExpression__.ts +14 -3
  254. package/src/concepts/Return__.ts +1 -1
  255. package/src/concepts/Role__.ts +10 -4
  256. package/src/concepts/SqlQueryComponent__.ts +47 -11
  257. package/src/concepts/StringLiteral__.ts +1 -1
  258. package/src/concepts/StructureProperty__.ts +6 -9
  259. package/src/concepts/Structure__.ts +19 -11
  260. package/src/concepts/SwitchCase__.ts +23 -27
  261. package/src/concepts/SwitchStatement__.ts +1 -5
  262. package/src/concepts/TypeAnnotation__.ts +43 -2
  263. package/src/concepts/Variable__.ts +1 -1
  264. package/src/concepts/ViewElement__.ts +26 -39
  265. package/src/concepts/View__.ts +29 -34
  266. package/src/concepts/WhileStatement__.ts +4 -4
  267. package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
  268. package/src/concepts/basics/stdlib/nasl.process.ts +406 -0
  269. package/src/concepts/basics/stdlib/nasl.ui.ts +1 -11
  270. package/src/concepts/basics/stdlib/nasl.util.ts +281 -2
  271. package/src/concepts/basics/types/index.ts +1 -0
  272. package/src/concepts/index__.ts +1 -0
  273. package/src/generator/genBundleFiles.ts +28 -7
  274. package/src/generator/genMetaData.ts +22 -13
  275. package/src/index.ts +1 -1
  276. package/src/server/createUiTs.ts +1 -0
  277. package/src/server/getLogics.ts +29 -4
  278. package/src/server/getMemberIdentifier.ts +4 -0
  279. package/src/server/getProcesses.ts +68 -0
  280. package/src/server/naslServer.ts +227 -30
  281. package/src/server/process2LogicNamespace.ts +29 -19
  282. package/src/server/translator.ts +39 -1
  283. package/src/service/creator/errHandles.js +6 -0
  284. package/src/service/storage/init.ts +97 -86
  285. package/src/templator/genCreateBlock.ts +35 -26
  286. package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -21
  287. package/src/templator/genCurdMultipleKeyBlock.ts +46 -31
  288. package/src/templator/genEditTableBlock.ts +17 -14
  289. package/src/templator/genEnumSelectBlock.ts +1 -1
  290. package/src/templator/genGridViewBlock.ts +30 -25
  291. package/src/templator/genListViewBlock.ts +10 -7
  292. package/src/templator/genQueryComponent.ts +28 -27
  293. package/src/templator/genSelectBlock.ts +9 -8
  294. package/src/templator/genTableBlock.ts +32 -23
  295. package/src/templator/genUpdateBlock.ts +35 -25
  296. package/src/templator/utils.ts +2 -2
  297. package/src/test/integration/connect-file.ts +6 -6
  298. package/src/translator/index.ts +1 -1
  299. package/src/utils/index.ts +51 -0
@@ -26,6 +26,12 @@ export default {
26
26
  if (config.noErrorTip)
27
27
  return;
28
28
 
29
+ // 检测到当前应用拉取操作已被强制结束
30
+ if(err.code === 401650) {
31
+ eventBus.emit('forceCancelPull');
32
+ return;
33
+ }
34
+
29
35
  if (versionStatus[err.code])
30
36
  eventBus.emit('updateVersionStatus', {
31
37
  status: versionStatus[err.code],
@@ -26,10 +26,10 @@ function getLogic(key: string, app: any, diffLogicList: string[]) {
26
26
  const _path = _pathArr[3];
27
27
  const _list = app.dependencies;
28
28
  const _module = _list.find((it: Module) => {
29
- const name = it.name.replace('-', '_');
29
+ const name = it.name.replaceAll('-', '_');
30
30
  return name === _name;
31
31
  });
32
- const logic = _module.logics.find((item: Logic) => item.name === _path);
32
+ const logic = _module?.logics?.find((item: Logic) => item.name === _path);
33
33
  if (logic && logic.body && logic.body.length > 2) {
34
34
  logic.body.map((item: any) => getStatement(item, app, diffLogicList));
35
35
  }
@@ -50,7 +50,7 @@ function getStatement(state: any, app: any, diffLogicList: string[]) {
50
50
  logicItems = [...state.body, state.each, state.start, state.end];
51
51
  break;
52
52
  case 'SwitchStatement':
53
- logicItems = state.cases.map(getStatement);
53
+ logicItems = state.cases.map(getStatement).flat(1);
54
54
  break;
55
55
  case 'SwitchCase':
56
56
  logicItems = [state.test, ...state.consequent];
@@ -97,104 +97,110 @@ async function doAction(app: any, actionItem: any) {
97
97
  }
98
98
  }
99
99
  };
100
- if (Array.isArray(list)) {
101
- list.forEach((event) => {
102
- const emitTarget = event?.originEvent?.target;
103
- const _path: string = event.originEvent.path;
104
- const _root = _path.split('.')?.[1] || '';
105
- if (
106
- ['entities', 'processes', 'logics', 'enums', 'structures', 'interfaces', 'interfaceDependencies', 'componentDependencies', 'configuration', 'dependencies'].some((item) =>
107
- _root.startsWith(item))
108
- ) {
109
- hasBackEnd = true;
110
- }
111
- const itemloop = (_i: LogicItem, app: any, diffArr: string[]) => {
112
- const _l = getStatement(_i, app, diffArr);
113
- if (_l.length) {
114
- _l.map((_ii: LogicItem) => itemloop(_ii, app, diffArr));
115
- }
116
- };
117
- if (emitTarget.concept === 'Logic') {
118
- const diffArr: string[] = [];
119
- if (emitTarget.body.length > 2) {
120
- emitTarget.body.forEach((it: LogicItem) => {
121
- itemloop(it, app, diffArr);
122
- });
123
- }
124
- const result = diffArr.filter((item) => item.startsWith('app') || item.startsWith('extensions'));
125
- if (result.length) {
100
+ try {
101
+ if (Array.isArray(list)) {
102
+ list.forEach((event) => {
103
+ const emitTarget = event?.originEvent?.target;
104
+ const _path: string = event.originEvent.path;
105
+ const _root = _path.split('.')?.[1] || '';
106
+ if (
107
+ ['dataSources', 'processes', 'logics', 'enums', 'structures', 'interfaces', 'interfaceDependencies', 'componentDependencies', 'configuration', 'dependencies'].some((item) =>
108
+ _root.startsWith(item))
109
+ ) {
126
110
  hasBackEnd = true;
127
111
  }
128
- }
129
- if (emitTarget.view) {
130
- hasFrontEnd = true;
131
- }
132
- if (emitTarget.concept === 'View') {
133
- const isDelete = event?.originEvent?.action === 'delete';
134
- const isUpdateAuth = event?.originEvent?.action === 'update' && event?.originEvent?.object && 'auth' in event?.originEvent?.object;
135
- if (isDelete || isUpdateAuth) {
136
- const app = emitTarget.app;
112
+ const itemloop = (_i: LogicItem, app: any, diffArr: string[]) => {
113
+ const _l = getStatement(_i, app, diffArr);
114
+ if (_l.length) {
115
+ _l.map((_ii: LogicItem) => itemloop(_ii, app, diffArr));
116
+ }
117
+ };
118
+ if (emitTarget.concept === 'Logic') {
137
119
  const diffArr: string[] = [];
138
- emitTarget.logics.forEach((logic: Logic) => {
139
- if (logic.body.length > 2) {
140
- logic.body.forEach((it: LogicItem) => {
141
- itemloop(it, app, diffArr);
142
- });
143
- }
144
- });
120
+ if (emitTarget.body.length > 2) {
121
+ emitTarget.body.forEach((it: LogicItem) => {
122
+ itemloop(it, app, diffArr);
123
+ });
124
+ }
145
125
  const result = diffArr.filter((item) => item.startsWith('app') || item.startsWith('extensions'));
146
126
  if (result.length) {
147
127
  hasBackEnd = true;
148
128
  }
149
- emitTarget.children.forEach((item: View | ViewElement) => loopEle(item, isDelete));
150
- emitTarget.elements.forEach((item: View | ViewElement) => loopEle(item, isDelete));
151
129
  }
152
- hasFrontEnd = true;
153
- }
154
- if (emitTarget.concept === 'ViewElement') {
155
- loopEle(emitTarget, true);
156
- }
157
- if (emitTarget.concept === 'BindAttribute' && emitTarget.name === 'url' && emitTarget.value.endsWith('/import')) {
158
- if (!emitTarget.view.parentAuth) {
159
- hasBackEnd = true;
160
- }
161
- }
162
- if (emitTarget.concept === 'CallLogic') {
163
- const arrlist: string[] = [];
164
- getLogic(emitTarget.calleeKey, emitTarget.app, arrlist);
165
- const result = arrlist.filter((item) => item.startsWith('app') || item.startsWith('extensions'));
166
- // console.log(result, 'CallLogic');
167
- if (result.length) {
168
- hasBackEnd = true;
130
+ if (emitTarget.view) {
131
+ hasFrontEnd = true;
169
132
  }
170
- }
171
- event.eventList.forEach(({ action, path, object: objItem }: { action: string; path: string; object: any }) => {
172
- if (Array.isArray(objItem)) {
173
- if (action === 'update') {
174
- actionList.push({
175
- action,
176
- path,
177
- node: objItem[0],
133
+ if (emitTarget.concept === 'View') {
134
+ const isDelete = event?.originEvent?.action === 'delete';
135
+ const isUpdateAuth = event?.originEvent?.action === 'update' && event?.originEvent?.object && 'auth' in event?.originEvent?.object;
136
+ if (isDelete || isUpdateAuth) {
137
+ const app = emitTarget.app;
138
+ const diffArr: string[] = [];
139
+ emitTarget.logics.forEach((logic: Logic) => {
140
+ if (logic.body.length > 2) {
141
+ logic.body.forEach((it: LogicItem) => {
142
+ itemloop(it, app, diffArr);
143
+ });
144
+ }
178
145
  });
179
- } else {
180
- objItem.forEach((item, index) => {
146
+ const result = diffArr.filter((item) => item.startsWith('app') || item.startsWith('extensions'));
147
+ if (result.length) {
148
+ hasBackEnd = true;
149
+ }
150
+ emitTarget.children.forEach((item: View | ViewElement) => loopEle(item, isDelete));
151
+ emitTarget.elements.forEach((item: View | ViewElement) => loopEle(item, isDelete));
152
+ }
153
+ hasFrontEnd = true;
154
+ }
155
+ if (emitTarget.concept === 'ViewElement') {
156
+ loopEle(emitTarget, true);
157
+ }
158
+ if (emitTarget.concept === 'BindAttribute' && emitTarget.name === 'url' && emitTarget.value.endsWith('/import')) {
159
+ if (!emitTarget.view.parentAuth) {
160
+ hasBackEnd = true;
161
+ }
162
+ }
163
+ if (emitTarget.concept === 'CallLogic') {
164
+ const arrlist: string[] = [];
165
+ getLogic(emitTarget.calleeKey, emitTarget.app, arrlist);
166
+ const result = arrlist.filter((item) => item.startsWith('app') || item.startsWith('extensions'));
167
+ // console.log(result, 'CallLogic');
168
+ if (result.length) {
169
+ hasBackEnd = true;
170
+ }
171
+ }
172
+ event.eventList.forEach(({ action, path, object: objItem }: { action: string; path: string; object: any }) => {
173
+ if (Array.isArray(objItem)) {
174
+ if (action === 'update') {
181
175
  actionList.push({
182
176
  action,
183
177
  path,
184
- node: item,
178
+ node: objItem[0],
185
179
  });
180
+ } else {
181
+ objItem.forEach((item, index) => {
182
+ actionList.push({
183
+ action,
184
+ path,
185
+ node: item,
186
+ });
187
+ });
188
+ }
189
+ } else {
190
+ actionList.push({
191
+ action,
192
+ path,
193
+ object: objItem,
186
194
  });
187
195
  }
188
- } else {
189
- actionList.push({
190
- action,
191
- path,
192
- object: objItem,
193
- });
194
- }
196
+ });
195
197
  });
196
- });
198
+ }
199
+ } catch (error) {
200
+ console.log(error);
201
+ app.emit('refresh');
197
202
  }
203
+
198
204
  let ChangedNASLType = '';
199
205
  if (hasFrontEnd && hasBackEnd) {
200
206
  ChangedNASLType = 'both';
@@ -213,11 +219,15 @@ async function doAction(app: any, actionItem: any) {
213
219
  ChangedNASLType,
214
220
  'request-appBaseVersion': (window as any).appData?.baseVersion || '',
215
221
  'request-versionChangedTime': (window as any).appData?.versionChangedTime || '',
222
+ operateArea: (window as any).appData?.branchStatus === 'merging' ? 'merge_conflict' : '',
216
223
  },
217
224
  });
218
225
  } catch (error) {
219
226
  err = error;
220
- app.emit('refresh');
227
+
228
+ // 401650, 检测到当前应用拉取操作已被强制结束, 用户确认后再刷新
229
+ if (error?.code !== 401650)
230
+ app.emit('refresh');
221
231
  }
222
232
  } else if (config.storage.protocol === 'mock') {
223
233
  // Do nothing
@@ -250,7 +260,7 @@ async function doAction(app: any, actionItem: any) {
250
260
  }
251
261
  }
252
262
 
253
- function handleApp(app: any) {
263
+ export function handleApp(app: any) {
254
264
  app._isCollectingCount = 0;
255
265
  app._collectingList = [];
256
266
  app._historyList = [];
@@ -379,6 +389,7 @@ export async function loadApp(appId?: string) {
379
389
  appId,
380
390
  'request-appBaseVersion': (window as any).appData?.baseVersion || '',
381
391
  'request-versionChangedTime': (window as any).appData?.versionChangedTime || '',
392
+ operateArea: (window as any).appData?.branchStatus === 'merging' ? 'merge_conflict' : '',
382
393
  },
383
394
  });
384
395
  // const data = res?.data?.result;
@@ -392,7 +403,7 @@ export async function loadApp(appId?: string) {
392
403
  scope: 'pc',
393
404
  envs: 'dev,online',
394
405
  hasAuth: true,
395
- entities: [],
406
+ dataSources: [],
396
407
  structures: [],
397
408
  enums: [],
398
409
  logics: [],
@@ -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 { 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 genCreateFormTemplate(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,13 +40,15 @@ export function genCreateFormTemplate(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);
46
47
  if (displayedProperty) {
47
48
  const lowerEntityName = utils.firstLowerCase(relationEntity.name);
48
- const selectNameGroup = selectNameGroupMap.get(relationEntity.name);
49
+ // 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
50
+ const key = [property.name, relationEntity.name].join('-');
51
+ const selectNameGroup = selectNameGroupMap.get(key);
49
52
  formItem += `
50
53
  <u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroup.viewLogicLoad}"
51
54
  text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="${vModel}">
@@ -73,7 +76,7 @@ export function genCreateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
73
76
  const namespaceArr = propertyTypeNamespace.split('.');
74
77
  const type = namespaceArr.pop();
75
78
  if (type === 'enums') {
76
- formItem += genEnumSelectBlock(parentNode.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
79
+ formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
77
80
  } else {
78
81
  formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
79
82
  }
@@ -89,7 +92,8 @@ export function genCreateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
89
92
  }
90
93
 
91
94
  export function genH5CreateFormTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
92
- const parentNode = entity.parentNode as App | Namespace;
95
+ const dataSource = entity.parentNode as DataSource;
96
+ const module = dataSource.parentNode as App | Module | Namespace;
93
97
  const properties = entity.properties.filter(filterProperty('inForm'));
94
98
 
95
99
  return `<van-form ref="${nameGroup.viewElementMainView}">
@@ -106,53 +110,55 @@ export function genH5CreateFormTemplate(entity: Entity, nameGroup: NameGroup, se
106
110
  rules.push('required');
107
111
  const rulesStr = rules.join(' | ');
108
112
 
109
- let formItem = ` <van-field drole="other" label="${property.label || property.name}"${required ? ' required' : ''}${rulesStr.length ? ` rules="${rulesStr}"` : ''}>\n`;
113
+ let formItem = ` <van-field drole="other" ${required ? ' required' : ''}${rulesStr.length ? ` rules="${rulesStr}"` : ''}>\n`;
110
114
  const { typeAnnotation } = property || {};
111
115
  const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
112
116
  if (property.relationEntity) {
113
117
  // 有外键关联
114
- const relationEntity = parentNode?.findEntityByName(property.relationEntity);
118
+ const relationEntity = dataSource?.findEntityByName(property.relationEntity);
115
119
  if (relationEntity) {
116
120
  const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
117
121
  const displayedProperty = getFirstDisplayedProperty(relationEntity);
118
122
  if (displayedProperty) {
119
123
  const lowerEntityName = utils.firstLowerCase(relationEntity.name);
120
- const selectNameGroup = selectNameGroupMap.get(relationEntity.name);
124
+ // 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
125
+ const key = [property.name, relationEntity.name].join('-');
126
+ const selectNameGroup = selectNameGroupMap.get(key);
121
127
  formItem += `
122
- <template #input><van-cascader title="请选择${label}" placeholder="请选择${label}"
128
+ <template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-cascader title="请选择${label}" placeholder="请选择${label}"
123
129
  v-model="${vModel}" :data-source="${selectNameGroup.viewLogicLoad}"
124
130
  text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}"
125
131
  :notitleblock="true"
126
- :pageable="true" :remote-paging="true"></van-cascader></template>
132
+ :pageable="true" input-align="left" :remote-paging="true"></van-cascader></van-linear-layout></template>
127
133
  `;
128
134
  } else
129
135
  return '';
130
136
  } else
131
137
  return '';
132
138
  } else if (propertyTypeName === 'Boolean') {
133
- formItem += `<template #input><van-switch v-model="${vModel}"></van-switch></template>`;
139
+ formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-switch v-model="${vModel}"></van-switch></van-linear-layout></template>`;
134
140
  } else if (propertyTypeName === 'Integer' || propertyTypeName === 'Long') {
135
- formItem += `<template #input><van-stepper v-model="${vModel}" placeholder="请输入${property.label || property.name}"></van-stepper></template>`;
141
+ formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-stepper-new v-model="${vModel}" placeholder="请输入${property.label || property.name}" :showPlus="false" :showMinus="false" align="left"></van-stepper-new></van-linear-layout></template>`;
136
142
  } else if (propertyTypeName === 'Double') {
137
- formItem += `<template #input><van-stepper v-model="${vModel}" placeholder="请输入${property.label || property.name}"></van-stepper></template>`;
143
+ formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-stepper-new v-model="${vModel}" placeholder="请输入${property.label || property.name}" :showPlus="false" :showMinus="false" align="left"></van-stepper-new></van-linear-layout></template>`;
138
144
  } else if (propertyTypeName === 'Text') {
139
- formItem += `<template #input><van-fieldtextarea v-model="${vModel}" placeholder="请输入${property.label || property.name}"></van-fieldtextarea></template>`;
145
+ formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-fieldtextarea v-model="${vModel}" placeholder="请输入${property.label || property.name}"></van-fieldtextarea></van-linear-layout></template>`;
140
146
  } else if (propertyTypeName === 'Date') {
141
- formItem += `<template #input><van-calendar :default-date.sync="${vModel}" title="选择日期"></van-calendar></template>`;
147
+ formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-calendar :default-date.sync="${vModel}" title="选择日期" input-align="left"></van-calendar></van-linear-layout></template>`;
142
148
  } else if (propertyTypeName === 'Time') {
143
- formItem += `<template #input><van-datetime-picker type="time" v-model="${vModel}" title="请选择${property.label || property.name}" label-field=""></van-datetime-picker></template>`;
149
+ formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-datetime-picker type="time" v-model="${vModel}" title="请选择${property.label || property.name}" label-field="" input-align="left"></van-datetime-picker></van-linear-layout></template>`;
144
150
  } else if (propertyTypeName === 'DateTime') {
145
- formItem += `<template #input><van-datetime-picker type="datetime" v-model="${vModel}" title="请选择${property.label || property.name}" label-field=""></van-datetime-picker></template>`;
151
+ formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-datetime-picker type="datetime" v-model="${vModel}" title="请选择${property.label || property.name}" label-field="" input-align="left"></van-datetime-picker></van-linear-layout></template>`;
146
152
  } else {
147
153
  const namespaceArr = propertyTypeNamespace.split('.');
148
154
  const type = namespaceArr.pop();
149
155
  if (type === 'enums') {
150
- formItem += '<template #input>' + genEnumSelectBlock(parentNode.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true) + '</template>';
156
+ formItem += '<template #input><van-linear-layout style="width:100%;" direction="horizontal">' + genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true) + '</van-linear-layout></template>';
151
157
  } else {
152
- formItem += `<template #input><van-fieldinput v-model="${vModel}" placeholder="请输入${property.label || property.name}"></van-fieldinput></template>`;
158
+ formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-fieldinput v-model="${vModel}" placeholder="请输入${property.label || property.name}"></van-fieldinput></van-linear-layout></template>`;
153
159
  }
154
160
  }
155
-
161
+ formItem += `<template #title><van-text text="${property.label || property.name}"><van-text></template>`;
156
162
  formItem += ` </van-field>\n`;
157
163
 
158
164
  formItem = formItem.replace(/>\n<van-input|<\/van-input>/g, '');
@@ -227,7 +233,8 @@ function genSubmitLogic(createLogic: Logic, nameGroup: NameGroup) {
227
233
  * @param resolver 实体创建 Action
228
234
  */
229
235
  export function genCreateBlock(entity: Entity, view: View) {
230
- const parentNode = entity.parentNode as App | Namespace;
236
+ const dataSource = entity.parentNode as DataSource;
237
+ const module = dataSource.parentNode as App | Module | Namespace;
231
238
  const ns = entity.ns;
232
239
  const createLogic = ns?.logics?.find((logic) => logic.name === `create`);
233
240
 
@@ -244,16 +251,18 @@ export function genCreateBlock(entity: Entity, view: View) {
244
251
  entity.properties.forEach((property) => {
245
252
  // 有外键关联
246
253
  if (property.relationEntity) {
247
- const relationEntity = parentNode?.findEntityByName(property.relationEntity);
254
+ const relationEntity = dataSource?.findEntityByName(property.relationEntity);
248
255
  if (relationEntity) {
249
256
  const displayedProperty = getFirstDisplayedProperty(relationEntity);
250
257
  if (displayedProperty) {
251
258
  const viewElementSelect = view.getViewElementUniqueName('select');
252
- const selectNameGroup = genUniqueQueryNameGroup(parentNode, view, viewElementSelect, false, relationEntity.name);
259
+ const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
253
260
  selectNameGroup.viewElementSelect = viewElementSelect;
254
- selectNameGroupMap.set(relationEntity.name, selectNameGroup);
261
+ // 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
262
+ const key = [property.name, relationEntity.name].join('-');
263
+ selectNameGroupMap.set(key, selectNameGroup);
255
264
  const newStructure = genQueryStructure([relationEntity], selectNameGroup);
256
- const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, parentNode);
265
+ const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, module);
257
266
  newStructures.push(newStructure);
258
267
  newLogics.push(newLogic);
259
268
  newLoadSelectLogics.push(genLoadSelectLogic(relationEntity, selectNameGroup, newLogic));
@@ -4,7 +4,7 @@
4
4
  * 3. 先简单做后续在看如何优化
5
5
  */
6
6
  import * as utils from '../utils';
7
- import { App, Namespace, Entity, View, Enum } from '../concepts';
7
+ import { App, Module, Namespace, Entity, View, Enum, DataSource } from '../concepts';
8
8
  import { NaslCoreTypeAnnotation, NaslUITypeAnnotation, NaslTypeAnnotation, NaslLogicItem, NaslNode } from './utils';
9
9
  import {
10
10
  filterProperty,
@@ -25,7 +25,8 @@ import {
25
25
  } from '.';
26
26
 
27
27
  function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
28
- const parentNode = entity.parentNode as App | Namespace;
28
+ const dataSource = entity.parentNode as DataSource;
29
+ const module = dataSource.parentNode as App | Module | Namespace;
29
30
  const properties = entity.properties.filter(filterProperty('inFilter'));
30
31
 
31
32
  return `
@@ -41,13 +42,15 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
41
42
  const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
42
43
  if (property.relationEntity) {
43
44
  // 有外键关联
44
- const relationEntity = parentNode?.findEntityByName(property.relationEntity);
45
+ const relationEntity = dataSource?.findEntityByName(property.relationEntity);
45
46
  if (relationEntity) {
46
47
  const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
47
48
  const displayedProperty = getFirstDisplayedProperty(relationEntity);
48
49
  if (displayedProperty) {
49
50
  const lowerEntityName = utils.firstLowerCase(relationEntity.name);
50
- const selectNameGroup = selectNameGroupMap.get(relationEntity.name);
51
+ // 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
52
+ const key = [property.name, relationEntity.name].join('-');
53
+ const selectNameGroup = selectNameGroupMap.get(key);
51
54
  formItem += `
52
55
  <u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroup.viewLogicLoad}"
53
56
  text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="${vModel}">
@@ -80,7 +83,7 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
80
83
  const namespaceArr = propertyTypeNamespace.split('.');
81
84
  const type = namespaceArr.pop();
82
85
  if (type === 'enums') {
83
- formItem += genEnumSelectBlock(parentNode.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
86
+ formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
84
87
  } else {
85
88
  formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
86
89
  }
@@ -102,7 +105,8 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
102
105
  }
103
106
 
104
107
  function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
105
- const parentNode = entity.parentNode as App | Namespace;
108
+ const dataSource = entity.parentNode as DataSource;
109
+ const module = dataSource.parentNode as App | Module | Namespace;
106
110
  const properties = entity.properties.filter(filterProperty('inForm'));
107
111
 
108
112
  return `
@@ -136,13 +140,15 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
136
140
  const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
137
141
  if (property.relationEntity) {
138
142
  // 有外键关联
139
- const relationEntity = parentNode?.findEntityByName(property.relationEntity);
143
+ const relationEntity = dataSource?.findEntityByName(property.relationEntity);
140
144
  if (relationEntity) {
141
145
  const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
142
146
  const displayedProperty = getFirstDisplayedProperty(relationEntity);
143
147
  if (displayedProperty) {
144
148
  const lowerEntityName = utils.firstLowerCase(relationEntity.name);
145
- const selectNameGroup = selectNameGroupMap.get(relationEntity.name);
149
+ // 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
150
+ const key = [property.name, relationEntity.name].join('-');
151
+ const selectNameGroup = selectNameGroupMap.get(key);
146
152
  formItem += `
147
153
  <u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroup.load}"
148
154
  text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="${vModel}">
@@ -174,7 +180,7 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
174
180
  const namespaceArr = propertyTypeNamespace.split('.');
175
181
  const type = namespaceArr.pop();
176
182
  if (type === 'enums') {
177
- formItem += genEnumSelectBlock(parentNode.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
183
+ formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
178
184
  } else {
179
185
  formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
180
186
  }
@@ -332,10 +338,11 @@ function genSubmitLogic(entity: Entity, nameGroup: NameGroup) {
332
338
  }
333
339
 
334
340
  export function genCurdEditMultipleKeyBlock(entity: Entity, view: View) {
335
- const parentNode = entity.parentNode as App | Namespace;
341
+ const dataSource = entity.parentNode as DataSource;
342
+ const module = dataSource.parentNode as App | Module | Namespace;
336
343
 
337
344
  const viewElementMainView = view.getViewElementUniqueName('tableView');
338
- const nameGroup = genUniqueQueryNameGroup(parentNode, view, viewElementMainView);
345
+ const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
339
346
  nameGroup.viewElementMainView = viewElementMainView;
340
347
  nameGroup.viewElementSaveModal = view.getViewElementUniqueName('saveModal');
341
348
  nameGroup.viewElementSaveModalForm = view.getViewElementUniqueName('saveModalForm');
@@ -350,7 +357,8 @@ export function genCurdEditMultipleKeyBlock(entity: Entity, view: View) {
350
357
  nameGroup.viewVariableIsUpdate = view.getVariableUniqueName('isUpdate');
351
358
 
352
359
  // 收集所有和本实体关联的实体
353
- const allEntities = [entity];
360
+ const entitySet: Set<Entity> = new Set();
361
+ entitySet.add(entity);
354
362
  const selectNameGroupMap: Map<string, NameGroup> = new Map();
355
363
  const newStructures: any[] = [];
356
364
  const newLogics: any[] = [];
@@ -358,17 +366,19 @@ export function genCurdEditMultipleKeyBlock(entity: Entity, view: View) {
358
366
  entity.properties.forEach((property) => {
359
367
  // 有外键关联
360
368
  if (property.relationEntity) {
361
- const relationEntity = parentNode?.findEntityByName(property.relationEntity);
369
+ const relationEntity = dataSource?.findEntityByName(property.relationEntity);
362
370
  if (relationEntity) {
363
371
  const displayedProperty = getFirstDisplayedProperty(relationEntity);
364
372
  if (displayedProperty) {
365
- allEntities.push(relationEntity);
373
+ entitySet.add(relationEntity);
366
374
  const viewElementSelect = view.getViewElementUniqueName('select');
367
- const selectNameGroup = genUniqueQueryNameGroup(parentNode, view, viewElementSelect, false, relationEntity.name);
375
+ const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
368
376
  selectNameGroup.viewElementSelect = viewElementSelect;
369
- selectNameGroupMap.set(relationEntity.name, selectNameGroup);
377
+ // 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
378
+ const key = [property.name, relationEntity.name].join('-');
379
+ selectNameGroupMap.set(key, selectNameGroup);
370
380
  const newStructure = genQueryStructure([relationEntity], selectNameGroup);
371
- const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, parentNode);
381
+ const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, module);
372
382
  newStructures.push(newStructure);
373
383
  newLogics.push(newLogic);
374
384
  newLoadSelectLogics.push(genLoadSelectLogic(relationEntity, selectNameGroup, newLogic));
@@ -376,13 +386,11 @@ export function genCurdEditMultipleKeyBlock(entity: Entity, view: View) {
376
386
  }
377
387
  }
378
388
  });
389
+ const allEntities = [...entitySet];
379
390
  const entityStructure = genEditQueryStructure(allEntities, nameGroup);
380
391
  newStructures.push(entityStructure);
381
- const entityLogic = genQueryLogic(allEntities, nameGroup, true, true, parentNode);
392
+ const entityLogic = genQueryLogic(allEntities, nameGroup, true, true, module);
382
393
  newLogics.push(entityLogic);
383
-
384
- // console.log(entityStructure);
385
-
386
394
  return `<template>
387
395
  <u-linear-layout direction="vertical">
388
396
  ${genFilterTemplate(entity, nameGroup, selectNameGroupMap)}