@lcap/nasl 3.6.0-alpha.1 → 3.6.0-alpha.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 (245) hide show
  1. package/out/bak/translator.js +119 -39
  2. package/out/bak/translator.js.map +1 -1
  3. package/out/breakpoint/generator/BreakpointNode.d.ts +3 -0
  4. package/out/breakpoint/generator/BreakpointNode.js +9 -0
  5. package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
  6. package/out/breakpoint/shared/constants.js +1 -0
  7. package/out/breakpoint/shared/constants.js.map +1 -1
  8. package/out/breakpoint/shared/utils.js +12 -6
  9. package/out/breakpoint/shared/utils.js.map +1 -1
  10. package/out/breakpoint/store/core.js +1 -1
  11. package/out/breakpoint/store/core.js.map +1 -1
  12. package/out/common/BaseNode.d.ts +1 -4
  13. package/out/common/BaseNode.js +23 -37
  14. package/out/common/BaseNode.js.map +1 -1
  15. package/out/concepts/AnonymousFunction__.d.ts +6 -1
  16. package/out/concepts/AnonymousFunction__.js +34 -16
  17. package/out/concepts/AnonymousFunction__.js.map +1 -1
  18. package/out/concepts/App__.d.ts +55 -51
  19. package/out/concepts/App__.js +76 -80
  20. package/out/concepts/App__.js.map +1 -1
  21. package/out/concepts/BackendVariable__.js +10 -2
  22. package/out/concepts/BackendVariable__.js.map +1 -1
  23. package/out/concepts/BindAttribute__.js +16 -6
  24. package/out/concepts/BindAttribute__.js.map +1 -1
  25. package/out/concepts/BindDirective__.d.ts +1 -0
  26. package/out/concepts/BindDirective__.js +19 -4
  27. package/out/concepts/BindDirective__.js.map +1 -1
  28. package/out/concepts/BindEvent__.d.ts +3 -1
  29. package/out/concepts/BindEvent__.js +39 -14
  30. package/out/concepts/BindEvent__.js.map +1 -1
  31. package/out/concepts/BusinessComponent__.d.ts +641 -0
  32. package/out/concepts/BusinessComponent__.js +1921 -0
  33. package/out/concepts/BusinessComponent__.js.map +1 -0
  34. package/out/concepts/BusinessLogic__.d.ts +38 -0
  35. package/out/concepts/BusinessLogic__.js +358 -0
  36. package/out/concepts/BusinessLogic__.js.map +1 -0
  37. package/out/concepts/CallEvent__.d.ts +101 -0
  38. package/out/concepts/CallEvent__.js +280 -0
  39. package/out/concepts/CallEvent__.js.map +1 -0
  40. package/out/concepts/CallFunction__.d.ts +0 -1
  41. package/out/concepts/CallFunction__.js +10 -10
  42. package/out/concepts/CallFunction__.js.map +1 -1
  43. package/out/concepts/CallLogic__.d.ts +2 -0
  44. package/out/concepts/CallLogic__.js +38 -27
  45. package/out/concepts/CallLogic__.js.map +1 -1
  46. package/out/concepts/Constant__.js +7 -6
  47. package/out/concepts/Constant__.js.map +1 -1
  48. package/out/concepts/Destination__.d.ts +1 -1
  49. package/out/concepts/Destination__.js +7 -5
  50. package/out/concepts/Destination__.js.map +1 -1
  51. package/out/concepts/End__.js +2 -1
  52. package/out/concepts/End__.js.map +1 -1
  53. package/out/concepts/Event__.d.ts +14 -0
  54. package/out/concepts/Event__.js +61 -0
  55. package/out/concepts/Event__.js.map +1 -1
  56. package/out/concepts/FrontendType__.d.ts +308 -0
  57. package/out/concepts/FrontendType__.js +605 -0
  58. package/out/concepts/FrontendType__.js.map +1 -0
  59. package/out/concepts/Frontend__.d.ts +0 -88
  60. package/out/concepts/Frontend__.js +1 -143
  61. package/out/concepts/Frontend__.js.map +1 -1
  62. package/out/concepts/Identifier__.d.ts +5 -0
  63. package/out/concepts/Identifier__.js +19 -9
  64. package/out/concepts/Identifier__.js.map +1 -1
  65. package/out/concepts/LogicItem__.d.ts +1 -1
  66. package/out/concepts/LogicItem__.js.map +1 -1
  67. package/out/concepts/Logic__.d.ts +3 -1
  68. package/out/concepts/Logic__.js +31 -21
  69. package/out/concepts/Logic__.js.map +1 -1
  70. package/out/concepts/Match__.d.ts +1 -1
  71. package/out/concepts/MemberExpression__.d.ts +1 -1
  72. package/out/concepts/MemberExpression__.js +3 -3
  73. package/out/concepts/MemberExpression__.js.map +1 -1
  74. package/out/concepts/NewComposite__.js.map +1 -1
  75. package/out/concepts/ParamWithGroup__.d.ts +39 -0
  76. package/out/concepts/ParamWithGroup__.js +85 -0
  77. package/out/concepts/ParamWithGroup__.js.map +1 -0
  78. package/out/concepts/Param__.js +11 -3
  79. package/out/concepts/Param__.js.map +1 -1
  80. package/out/concepts/ProcessElement__.js +9 -1
  81. package/out/concepts/ProcessElement__.js.map +1 -1
  82. package/out/concepts/Return__.js +17 -9
  83. package/out/concepts/Return__.js.map +1 -1
  84. package/out/concepts/ValidationRule__.js +2 -1
  85. package/out/concepts/ValidationRule__.js.map +1 -1
  86. package/out/concepts/Variable__.js +17 -8
  87. package/out/concepts/Variable__.js.map +1 -1
  88. package/out/concepts/ViewElement__.d.ts +17 -1
  89. package/out/concepts/ViewElement__.js +145 -16
  90. package/out/concepts/ViewElement__.js.map +1 -1
  91. package/out/concepts/View__.js +21 -20
  92. package/out/concepts/View__.js.map +1 -1
  93. package/out/concepts/index__.d.ts +5 -0
  94. package/out/concepts/index__.js +5 -0
  95. package/out/concepts/index__.js.map +1 -1
  96. package/out/concepts/utils/asserts.d.ts +258 -3
  97. package/out/concepts/utils/asserts.js +351 -13
  98. package/out/concepts/utils/asserts.js.map +1 -1
  99. package/out/concepts/utils/types.d.ts +20 -3
  100. package/out/generator/genBundleFiles.js +25 -11
  101. package/out/generator/genBundleFiles.js.map +1 -1
  102. package/out/generator/genReleaseBody.js +12 -3
  103. package/out/generator/genReleaseBody.js.map +1 -1
  104. package/out/generator/permission.js +3 -3
  105. package/out/generator/permission.js.map +1 -1
  106. package/out/natural/transformTSCode.js +1 -1
  107. package/out/natural/transformTSCode.js.map +1 -1
  108. package/out/server/extendBaseNode.js +6 -4
  109. package/out/server/extendBaseNode.js.map +1 -1
  110. package/out/server/getLogics.js +62 -27
  111. package/out/server/getLogics.js.map +1 -1
  112. package/out/server/getMemberIdentifier.js +6 -1
  113. package/out/server/getMemberIdentifier.js.map +1 -1
  114. package/out/server/getProcesses.js +3 -3
  115. package/out/server/getProcesses.js.map +1 -1
  116. package/out/server/naslServer.js +40 -19
  117. package/out/server/naslServer.js.map +1 -1
  118. package/out/server/translator.js +6 -1
  119. package/out/server/translator.js.map +1 -1
  120. package/out/service/storage/init.js +1 -2
  121. package/out/service/storage/init.js.map +1 -1
  122. package/out/templator/genCreateBlock.js +6 -6
  123. package/out/templator/genCreateBlock.js.map +1 -1
  124. package/out/templator/genCurdEditMultipleKeyBlock.js +16 -16
  125. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  126. package/out/templator/genCurdMultipleKeyBlock.js +36 -36
  127. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  128. package/out/templator/genGetBlock.js +6 -5
  129. package/out/templator/genGetBlock.js.map +1 -1
  130. package/out/templator/genGridViewBlock.js +12 -12
  131. package/out/templator/genGridViewBlock.js.map +1 -1
  132. package/out/templator/genListViewBlock.js +4 -4
  133. package/out/templator/genListViewBlock.js.map +1 -1
  134. package/out/templator/genSelectBlock.js +3 -3
  135. package/out/templator/genSelectBlock.js.map +1 -1
  136. package/out/templator/genTableBlock.js +10 -10
  137. package/out/templator/genTableBlock.js.map +1 -1
  138. package/out/templator/genUpdateBlock.js +10 -9
  139. package/out/templator/genUpdateBlock.js.map +1 -1
  140. package/out/templator/utils.d.ts +2 -2
  141. package/out/templator/utils.js.map +1 -1
  142. package/out/translator/utils.js +12 -1
  143. package/out/translator/utils.js.map +1 -1
  144. package/out/utils/i18nInfo.js +7 -2
  145. package/out/utils/i18nInfo.js.map +1 -1
  146. package/out/utils/index.d.ts +17 -0
  147. package/out/utils/index.js +184 -1
  148. package/out/utils/index.js.map +1 -1
  149. package/package.json +2 -2
  150. package/src/bak/translator.js +121 -43
  151. package/src/breakpoint/generator/BreakpointNode.ts +12 -0
  152. package/src/breakpoint/shared/constants.ts +1 -0
  153. package/src/breakpoint/shared/utils.ts +13 -8
  154. package/src/breakpoint/store/core.ts +1 -1
  155. package/src/common/BaseNode.ts +22 -41
  156. package/src/concepts/AnonymousFunction__.ts +36 -18
  157. package/src/concepts/App__.ts +129 -130
  158. package/src/concepts/BackendVariable__.ts +10 -2
  159. package/src/concepts/BindAttribute__.ts +14 -6
  160. package/src/concepts/BindDirective__.ts +19 -4
  161. package/src/concepts/BindEvent__.ts +41 -13
  162. package/src/concepts/BusinessComponent__.ts +2693 -0
  163. package/src/concepts/BusinessLogic__.ts +376 -0
  164. package/src/concepts/CallEvent__.ts +351 -0
  165. package/src/concepts/CallFunction__.ts +10 -13
  166. package/src/concepts/CallLogic__.ts +45 -32
  167. package/src/concepts/Constant__.ts +5 -7
  168. package/src/concepts/Destination__.ts +7 -5
  169. package/src/concepts/End__.ts +1 -0
  170. package/src/concepts/Event__.ts +70 -0
  171. package/src/concepts/FrontendType__.ts +919 -0
  172. package/src/concepts/Frontend__.ts +3 -251
  173. package/src/concepts/Identifier__.ts +29 -13
  174. package/src/concepts/LogicItem__.ts +1 -0
  175. package/src/concepts/Logic__.ts +36 -23
  176. package/src/concepts/MemberExpression__.ts +3 -3
  177. package/src/concepts/NewComposite__.ts +4 -6
  178. package/src/concepts/ParamWithGroup__.ts +101 -0
  179. package/src/concepts/Param__.ts +11 -3
  180. package/src/concepts/ProcessElement__.ts +8 -1
  181. package/src/concepts/Return__.ts +15 -12
  182. package/src/concepts/ValidationRule__.ts +6 -1
  183. package/src/concepts/Variable__.ts +17 -9
  184. package/src/concepts/ViewElement__.ts +168 -33
  185. package/src/concepts/View__.ts +23 -20
  186. package/src/concepts/index__.ts +5 -0
  187. package/src/concepts/utils/asserts.ts +367 -4
  188. package/src/concepts/utils/types.ts +28 -0
  189. package/src/generator/genBundleFiles.ts +33 -15
  190. package/src/generator/genReleaseBody.ts +14 -3
  191. package/src/generator/permission.ts +8 -6
  192. package/src/natural/transformTSCode.ts +1 -1
  193. package/src/server/extendBaseNode.ts +22 -20
  194. package/src/server/getLogics.ts +79 -41
  195. package/src/server/getMemberIdentifier.ts +7 -1
  196. package/src/server/getProcesses.ts +3 -3
  197. package/src/server/naslServer.ts +44 -20
  198. package/src/server/translator.ts +7 -1
  199. package/src/service/storage/init.ts +1 -2
  200. package/src/templator/genCreateBlock.ts +6 -6
  201. package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -16
  202. package/src/templator/genCurdMultipleKeyBlock.ts +36 -36
  203. package/src/templator/genGetBlock.ts +6 -5
  204. package/src/templator/genGridViewBlock.ts +12 -12
  205. package/src/templator/genListViewBlock.ts +4 -4
  206. package/src/templator/genSelectBlock.ts +3 -3
  207. package/src/templator/genTableBlock.ts +10 -10
  208. package/src/templator/genUpdateBlock.ts +10 -9
  209. package/src/templator/utils.ts +2 -2
  210. package/src/translator/utils.ts +12 -1
  211. package/src/utils/i18nInfo.ts +7 -2
  212. package/src/utils/index.ts +211 -1
  213. package/test/concepts/call-function/fixtures/from-string.json +68 -59
  214. package/test/concepts/call-function/fixtures/to-string-global-tz.json +67 -58
  215. package/test/concepts/call-function/fixtures/to-string-no-tz.json +57 -48
  216. package/test/concepts/call-function/fixtures/to-string-user-tz.json +69 -60
  217. package/test/concepts/call-function/fixtures/to-string-utc-tz.json +69 -60
  218. package/test/concepts/call-interface/fixtures/only-interface.json +81 -72
  219. package/test/concepts/call-interface/fixtures/with-body-complex-argument.json +223 -214
  220. package/test/concepts/call-interface/fixtures/with-body-no-argument.json +85 -76
  221. package/test/concepts/call-interface/fixtures/with-body-simple-argument.json +100 -91
  222. package/test/concepts/call-interface/fixtures/with-headers-no-argument.json +88 -79
  223. package/test/concepts/call-interface/fixtures/with-headers.json +90 -81
  224. package/test/concepts/call-interface/fixtures/with-query-no-argument.json +88 -79
  225. package/test/concepts/call-interface/fixtures/with-query.json +90 -81
  226. package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +4 -2
  227. package/test/concepts/call-logic/fixtures/entries-get-with-arguments.json +104 -95
  228. package/test/concepts/call-logic/fixtures/entries-update-with-arguments.json +209 -200
  229. package/test/concepts/call-logic/fixtures/global-logic-argument-no-expression.json +97 -88
  230. package/test/concepts/call-logic/fixtures/global-logic-argument-some-expression.json +124 -115
  231. package/test/concepts/call-logic/fixtures/json-deserialize.json +120 -111
  232. package/test/concepts/call-logic/fixtures/json-serialize-with-string.json +124 -115
  233. package/test/concepts/call-logic/fixtures/json-serialize.json +124 -115
  234. package/test/concepts/call-logic/fixtures/view-buildin-logic-with-argument.json +91 -82
  235. package/test/concepts/call-logic/fixtures/view-component-logic-no-argument.json +88 -79
  236. package/test/concepts/call-logic/fixtures/view-component-with-validation.json +144 -135
  237. package/test/concepts/identifier/fixtures/view-variable.json +145 -136
  238. package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +1 -1
  239. package/test/concepts/view-element/fixtures/default-login.json +221 -212
  240. package/test/concepts/view-element/fixtures/default-not-found.json +183 -174
  241. package/test/concepts/view-element/fixtures/with-role-auth.json +91 -82
  242. package/test/concepts/view-element/fixtures/with-table.json +1894 -1885
  243. package/test/concepts/view-element/toVue.spec.ts +1 -0
  244. package/ts-worker/package.json +1 -1
  245. package/ts-worker/src/index.js +1 -0
@@ -4,24 +4,103 @@ function safeCodeAsKey(name) {
4
4
  return `['${name}']`;
5
5
  }
6
6
 
7
- function tryJSONParse(str) {
8
- let result;
7
+ /**
8
+ * 获取变量初始值
9
+ * @param {*} variable
10
+ * @param {*} URLParamRetrieval 从地址栏获取
11
+ * @returns
12
+ */
13
+ function genVarInitialVal(variable, URLParamRetrieval) {
14
+ const typeAnnotation = variable.typeAnnotation || variable.__TypeAnnotation;
15
+ let { typeKind, typeNamespace, typeName, sortedTypeKey } = typeAnnotation || {};
16
+ if (typeNamespace?.endsWith('.metadataTypes')) {
17
+ const referenceNode = variable.getAncestor('App').findNodeByCompleteName(typeNamespace + '.' + typeName) || {}
18
+ const typeAn = referenceNode.typeAnnotation || {};
19
+ typeKind = typeAn.typeKind;
20
+ typeNamespace = typeAn.typeNamespace;
21
+ typeName = typeAn.typeName;
22
+ sortedTypeKey = `${typeNamespace}.${typeName}`;
23
+ }
24
+ const needGenInitFromSchema =
25
+ typeAnnotation && (!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
9
26
 
10
- try {
11
- result = JSON.parse(str);
12
- } catch (e) { }
27
+ let code = '';
28
+ if (needGenInitFromSchema) {
29
+ code += `this.$genInitFromSchema('${sortedTypeKey}', `;
30
+ }
31
+ if (variable.concept === 'Param' && URLParamRetrieval) {
32
+ code += `this.$route.query.hasOwnProperty('${variable.name}') ? this.$genInitFromSchema('${sortedTypeKey}', this.$route.query.${variable.name}) :`;
33
+ }
34
+ const { defaultValue } = variable;
35
+ // 设置成null,才能同步给后端清除该值,但是null对checkbox组件是一种特殊状态
36
+ const parsedValue = defaultValue?.expression?.toJS?.() ?? undefined;
13
37
 
14
- return result;
38
+ code += parsedValue;
39
+ if (needGenInitFromSchema) {
40
+ code += `)`;
41
+ }
42
+ return code;
43
+ }
44
+
45
+ /**
46
+ * 获取组件入参的类型
47
+ * @param {*} typeAnnotation
48
+ */
49
+ function getPropsType(typeAnnotation) {
50
+ let type = 'Object';
51
+ const { typeKind, typeNamespace, typeName, typeArguments } = typeAnnotation || {};
52
+ if (
53
+ typeKind === 'union'
54
+ && typeNamespace === 'nasl.core'
55
+ && typeName === 'Union'
56
+ && Array.isArray(typeArguments)
57
+ && typeArguments.length
58
+ ) {
59
+ const arr = typeArguments.map((typeArgument) => {
60
+ return getPropsType(typeArgument);
61
+ });
62
+ type = `[${arr.join(', ')}]`;
63
+ } else {
64
+ if (typeKind === 'primitive' && typeNamespace === 'nasl.core') {
65
+ const typeMap = {
66
+ Boolean: 'Boolean',
67
+ Decimal: 'Number',
68
+ Long: 'Number',
69
+ String: 'String',
70
+ Date: 'String',
71
+ Time: 'String',
72
+ DateTime: 'String',
73
+ };
74
+ if (typeMap[typeName]) {
75
+ type = typeMap[typeName];
76
+ }
77
+ } else if (typeKind === "generic" && typeNamespace === "nasl.collection" && typeName === 'List') {
78
+ type = 'Array';
79
+ }
80
+ }
81
+ return type;
15
82
  }
16
83
 
17
84
  export default function (definition, view) {
85
+ let isBusinessComponent = false;
86
+ if (view.concept === 'BusinessComponent') {
87
+ isBusinessComponent = true;
88
+ }
18
89
  /**
19
90
  * 页面的 data
20
91
  * 包含 页面变量 / 页面入参 / 页面元素绑定的表达式的返回
21
92
  */
22
93
  const viewVariablesData = [];
94
+ // 组件入参
95
+ const viewProps = [];
23
96
  // 所有的页面变量
24
- const viewVariables = [...(definition.params || []), ...(definition.variables || [])];
97
+ const viewVariables = [...(definition.variables || [])];
98
+ if (isBusinessComponent) {
99
+ viewProps.push(...(definition.params || []));
100
+ } else {
101
+ viewVariables.push(...(definition.params || []));
102
+ }
103
+
25
104
  // 页面元素绑定的表达式
26
105
  const { viewExpressions } = definition;
27
106
  const hasViewExpressions = Array.isArray(viewExpressions) && viewExpressions.length;
@@ -29,38 +108,8 @@ export default function (definition, view) {
29
108
  * genInitFromSchema 是为了将数据类型的处理和页面逻辑的生成分开
30
109
  * 比如 param a.b 的 schema 有变化,View 代码无需再次生成
31
110
  */
32
- const dataMap = {};
33
111
  viewVariables.forEach((viewVariable) => {
34
- dataMap[viewVariable.code || viewVariable.name] = true;
35
- const typeAnnotation = viewVariable.typeAnnotation || viewVariable.__TypeAnnotation;
36
- let { typeKind, typeNamespace, typeName, sortedTypeKey } = typeAnnotation || {};
37
- if (typeNamespace?.endsWith('.metadataTypes')) {
38
- const referenceNode = view.getAncestor('App').findNodeByCompleteName(typeNamespace + '.' + typeName) || {}
39
- const typeAn = referenceNode.typeAnnotation || {};
40
- typeKind = typeAn.typeKind;
41
- typeNamespace = typeAn.typeNamespace;
42
- typeName = typeAn.typeName;
43
- sortedTypeKey = `${typeNamespace}.${typeName}`;
44
- }
45
- const needGenInitFromSchema =
46
- typeAnnotation && (!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
47
- let code = `${safeCodeAsKey(viewVariable.name)}:`;
48
- if (needGenInitFromSchema) {
49
- code += `this.$genInitFromSchema('${sortedTypeKey}', `;
50
- }
51
- if (viewVariable.concept === 'Param') {
52
- code += `this.$route.query.hasOwnProperty('${viewVariable.name}') ? this.$genInitFromSchema('${sortedTypeKey}', this.$route.query.${viewVariable.name}) :`;
53
- }
54
-
55
- const { defaultValue } = viewVariable;
56
- // 设置成null,才能同步给后端清除该值,但是null对checkbox组件是一种特殊状态
57
- const parsedValue = defaultValue?.expression?.toJS?.() ?? undefined;
58
-
59
- code += parsedValue;
60
- if (needGenInitFromSchema) {
61
- code += `)`;
62
- }
63
- viewVariablesData.push(code);
112
+ viewVariablesData.push(`${safeCodeAsKey(viewVariable.name)}: ${genVarInitialVal(viewVariable, !isBusinessComponent)}`);
64
113
  });
65
114
  /**
66
115
  * 页面的 computed
@@ -152,7 +201,9 @@ export default function (definition, view) {
152
201
 
153
202
  const events = Array.from(eventMap).map(([name, bindEvents]) => {
154
203
  let code = `async ${name} () {
155
- ${bindEvents.map((event) => `await this.${event.view.name}_${event.name}();`).join('\n')}`;
204
+ ${bindEvents.map((event) =>{
205
+ const likeComponent = event.view || event.getAncestor('BusinessComponent');
206
+ return `await this.${likeComponent?.name}_${event.name}();`}).join('\n')}`;
156
207
  code += '}';
157
208
  return code;
158
209
  });
@@ -167,15 +218,42 @@ export default function (definition, view) {
167
218
  tabSize: 1,
168
219
  })
169
220
  );
170
-
171
- const output = `
221
+ const viewPropArr = [];
222
+ // 监听
223
+ const watcherArr = [];
224
+ let output = '';
225
+ if (Array.isArray(viewProps) && viewProps.length) {
226
+ viewProps.forEach((viewProp) => {
227
+ const typeAnnotation = viewProp.typeAnnotation || viewProp.__TypeAnnotation;
228
+ viewPropArr.push(`${safeCodeAsKey(viewProp.name)}: {
229
+ type: ${getPropsType(typeAnnotation)},
230
+ default: ${genVarInitialVal(viewProp, !isBusinessComponent)}
231
+ }`);
232
+ watcherArr.push(`${safeCodeAsKey(viewProp.name)}: {
233
+ handler(val) {
234
+ this.$emit('update:${viewProp.name}', val);
235
+ },
236
+ }`);
237
+ });
238
+ }
239
+ if (Array.isArray(viewPropArr) && viewPropArr.length) {
240
+ output += `props: {
241
+ ${viewPropArr.join(',\n')}
242
+ },\n`;
243
+ }
244
+ if (Array.isArray(watcherArr) && watcherArr.length) {
245
+ output += `watch: {
246
+ ${watcherArr.join(',\n')}
247
+ },\n`;
248
+ }
249
+ output += `
172
250
  data() {
173
251
  return {
174
- ${viewVariablesData.join(',\n').trim()}
252
+ ${viewVariablesData.join(',\n').trim()}
175
253
  };
176
254
  },
177
255
  computed: {
178
- ${viewComputedData.join(',\n').trim()}
256
+ ${viewComputedData.join(',\n').trim()}
179
257
  },
180
258
  meta: {
181
259
  title: ${JSON.stringify(definition.title)},
@@ -349,6 +349,18 @@ export default class BreakpointNode extends BaseNode {
349
349
  return this.logic || this.variable;
350
350
  }
351
351
 
352
+ get items() {
353
+ return (this.node as any)?.items;
354
+ }
355
+
356
+ get concept() {
357
+ return (this.node as any)?.concept;
358
+ }
359
+
360
+ get getCallNode() {
361
+ return (this.node as any)?.getCallNode;
362
+ }
363
+
352
364
  init() {
353
365
  const source = this.logic || this.variable;
354
366
  const node = getRealNode(source);
@@ -57,6 +57,7 @@ export const BREAKPOINT_CONCEPTS = [
57
57
  'Unparsed',
58
58
  'CallFunction',
59
59
  'CallLogic',
60
+ 'CallEvent',
60
61
  'CallInterface',
61
62
  'CallConnector',
62
63
  'CallAuthInterface',
@@ -3,6 +3,7 @@ import {
3
3
  View,
4
4
  BaseNode,
5
5
  ViewElement,
6
+ BusinessComponent,
6
7
  } from '../../concepts';
7
8
 
8
9
  import {
@@ -197,7 +198,7 @@ export const getLogics = (app: App) => {
197
198
  return [];
198
199
  }
199
200
 
200
- const { frontends = [] } = app;
201
+ const { frontendTypes = [] } = app;
201
202
 
202
203
  let result = getGlobalLogics(app) || [];
203
204
 
@@ -220,7 +221,7 @@ export const getLogics = (app: App) => {
220
221
  viewElementChildren.forEach(forViewElement);
221
222
  };
222
223
 
223
- const forView = (view: View) => {
224
+ const forView = (view: View | BusinessComponent) => {
224
225
  if (!view) {
225
226
  return;
226
227
  }
@@ -228,7 +229,6 @@ export const getLogics = (app: App) => {
228
229
  const {
229
230
  logics: viewLogics = [],
230
231
  elements: viewElements = [],
231
- children: viewChildren = [],
232
232
  bindEvents: viewBindEvents = [],
233
233
  } = view;
234
234
 
@@ -241,13 +241,18 @@ export const getLogics = (app: App) => {
241
241
  });
242
242
 
243
243
  viewElements.forEach(forViewElement);
244
- viewChildren.forEach(forView);
244
+ (view as View)?.children?.forEach(forView);
245
245
  };
246
246
 
247
- frontends.forEach((frontend) => {
248
- const { views = [] } = frontend;
249
-
250
- views && views.forEach(forView);
247
+ frontendTypes.forEach((frontendType) => {
248
+ frontendType?.frontends?.forEach((frontend) => {
249
+ const { views = [] } = frontend;
250
+ views && views.forEach(forView);
251
+ });
252
+ const { businessComponents } = frontendType || {};
253
+ if (Array.isArray(businessComponents) && businessComponents.length) {
254
+ businessComponents.forEach(forView);
255
+ }
251
256
  });
252
257
 
253
258
  return result;
@@ -138,7 +138,7 @@ const isFrontend = (node: BaseNode) => {
138
138
 
139
139
  const { getAncestor } = node;
140
140
 
141
- return getAncestor && getAncestor.call(node, 'View');
141
+ return getAncestor && getAncestor.call(node, 'FrontendType');
142
142
  };
143
143
 
144
144
  const updateToBackend = (node: BaseNode) => {
@@ -20,38 +20,6 @@ export function setActionable(value: boolean) {
20
20
  actionable = value;
21
21
  }
22
22
 
23
- // 确保属性都是定义过的
24
- function ensureDefined(object: any, concept: string) {
25
- if (!object) {
26
- return object;
27
- }
28
- const newObject: any = {};
29
- const actualConcept = object?.concept || concept;
30
- if (actualConcept) {
31
- const propertyMap = getConceptPropertyMap(actualConcept);
32
- for (const key in object) {
33
- const property = propertyMap.get(key);
34
- if (property) {
35
- const objProperty = object[key] ?? null;
36
- const propertyConcept = property?.objectRef;
37
- if (propertyConcept) {
38
- if (Array.isArray(objProperty)) {
39
- newObject[key] = objProperty.map((objItem: any) => {
40
- return ensureDefined(objItem, propertyConcept);
41
- });
42
- } else {
43
- newObject[key] = ensureDefined(objProperty, propertyConcept);
44
- }
45
- } else {
46
- newObject[key] = objProperty;
47
- }
48
- }
49
- }
50
-
51
- newObject.concept = actualConcept;
52
- }
53
- return newObject;
54
- }
55
23
 
56
24
  type NodePathOption = {
57
25
  useName?: boolean,
@@ -249,13 +217,6 @@ export class BaseNode extends EventEmitter {
249
217
  @property()
250
218
  composedBy?: Array<string>;
251
219
 
252
-
253
- /**
254
- * 分组管理在多人协作场景触点
255
- */
256
- @property()
257
- composedOrigin?: 'Form' | 'Table' | 'Process';
258
-
259
220
  /**
260
221
  * 当前节点的类型标注
261
222
  */
@@ -1103,7 +1064,27 @@ export class BaseNode extends EventEmitter {
1103
1064
  });
1104
1065
  return JSON.parse(JSON.stringify(temp));
1105
1066
  }
1106
-
1067
+ // 给国际化展示用
1068
+ getNodeChinesePath(useIndex: boolean | string[] | NodePathOption) {
1069
+ let node: BaseNode = this;
1070
+ const pathArr: string[] = [];
1071
+ while (node && node.concept) {
1072
+ let pathText = '';
1073
+ const { parentNode } = node;
1074
+ if (parentNode) {
1075
+ const { name, title, label } = parentNode as any;
1076
+ pathText = `${(parentNode.constructor as any)?.nodeTitle || ''}${name || ''}`;
1077
+ if (title && label) {
1078
+ pathText += `(${title} | ${label})`;
1079
+ } else if (title || label) {
1080
+ pathText += `(${title || label})`;
1081
+ }
1082
+ pathArr.unshift(pathText);
1083
+ }
1084
+ node = parentNode;
1085
+ }
1086
+ return pathArr.join('/');
1087
+ }
1107
1088
  /**
1108
1089
  * 查找引用
1109
1090
  */
@@ -1496,7 +1477,7 @@ export class BaseNode extends EventEmitter {
1496
1477
  if (typeAnnotation) {
1497
1478
  const { typeKind, typeNamespace, typeName, properties } = typeAnnotation;
1498
1479
  if (typeKind === 'reference' || typeKind === 'generic') {
1499
- if (typeNamespace.endsWith('.enums')) return null;
1480
+ if (typeNamespace?.endsWith('.enums')) return null;
1500
1481
  return [{}];
1501
1482
  }
1502
1483
  if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
@@ -649,27 +649,45 @@ export class AnonymousFunction extends LogicItem {
649
649
  return code;
650
650
  }
651
651
 
652
- checkParamName() {
653
- let node: types.SyntaxNode = this;
654
- const names: Set<string> = new Set();
655
- while (node && node.concept !== 'Logic') {
656
- node = node.parentNode;
657
- if (asserts.isAnonymousFunction(node)) {
658
- node.params.forEach((param) => {
659
- names.add(param.name);
660
- });
652
+ /**
653
+ * 确保参数名称都是不重复的,且更新内部的引用关系
654
+ * @param paramNames
655
+ * @returns
656
+ */
657
+ ensureParamName(paramNames: Set<string>) {
658
+ const paramInfoMap = new Map<string, any>();
659
+ this.params.forEach((param) => {
660
+ const name = utils.unique(param.name, paramNames);
661
+ if (!paramInfoMap.get(param.name)) {
662
+ paramInfoMap.set(param.name, {});
661
663
  }
662
-
663
- if (asserts.isForEachStatement(node)) {
664
- names.add(node.item.name);
665
- names.add(node.index.name);
664
+ const paramInfo = paramInfoMap.get(param.name);
665
+ // 即使没有修改,也需要把名字塞进去
666
+ paramInfo.newName = name;
667
+ if (name !== param.name) {
668
+ paramInfo.param = param;
669
+ }
670
+ });
671
+ this.traverseChildren((node) => {
672
+ if (node?.concept === 'Identifier') {
673
+ const parentNode = node.parentNode;
674
+ if (
675
+ parentNode?.concept !== 'MemberExpression'
676
+ || (parentNode.parentNode?.concept !== 'MemberExpression' && (parentNode as any).object === node)
677
+ ) {
678
+ if (node) {
679
+ const paramInfo = paramInfoMap.get(node.name);
680
+ if (paramInfo?.param) {
681
+ if (!Array.isArray(paramInfo?.identifiers)) {
682
+ paramInfo.identifiers = [];
683
+ }
684
+ paramInfo.identifiers.push(node);
685
+ }
686
+ }
687
+ }
666
688
  }
667
- }
668
-
669
- this.params.forEach((param) => {
670
- const name = utils.unique(param.name, names);
671
- param.name = name;
672
689
  });
690
+ return paramInfoMap;
673
691
  }
674
692
 
675
693
  //================================================================================