@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
@@ -0,0 +1,351 @@
1
+ import { wrapForEachToGenerator as wrapForEach } from '../utils/time-slicing';
2
+ import {
3
+ TranslatorState,
4
+ shiftState,
5
+ createCompilerState,
6
+ withSourceMapGenerator,
7
+ TranslatorGenerator,
8
+ } from '../translator';
9
+ import type Event from './Event__';
10
+ import type Param from './Param__';
11
+ import { BusinessComponent } from './BusinessComponent__';
12
+ //================================================================================
13
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
14
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
15
+ //================================================================================
16
+ import { EventPayload, Params } from '../common/EventEmitter';
17
+ import { concept, excludedInJSON, property, getConceptConstructor, getBaseNode } from '../decorators';
18
+
19
+ import * as utils from '../utils';
20
+ import * as types from './utils/types';
21
+ import * as asserts from './utils/asserts';
22
+ import { v4 as uuidv4 } from 'uuid';
23
+ import LogicItem from './LogicItem__';
24
+ import type Argument from './Argument__';
25
+
26
+ /**
27
+ * 触发事件
28
+ */
29
+ @concept('触发事件')
30
+ export class CallEvent extends LogicItem {
31
+ /** 类名 */
32
+ static readonly ConceptName: string = 'CallEvent';
33
+
34
+ /** 继承链 */
35
+ static readonly inheritanceChain: string[] = ['LogicItem', 'BaseNode'];
36
+
37
+ /**
38
+ * 产品概念
39
+ */
40
+ @property('concept')
41
+ // @ts-ignore
42
+ readonly concept!: 'CallEvent';
43
+
44
+ /**
45
+ * 触发事件标题
46
+ */
47
+ @property()
48
+ label: string = '触发事件';
49
+
50
+ /**
51
+ * calleeNamespace
52
+ */
53
+ @property()
54
+ calleeNamespace!: string;
55
+
56
+ /**
57
+ * calleeName
58
+ */
59
+ @property()
60
+ calleeName!: string;
61
+
62
+ /**
63
+ * 参数
64
+ */
65
+ @property({
66
+ objectRef: 'Argument',
67
+ isArray: true,
68
+ defaultValue: [],
69
+ })
70
+ arguments: Array<Argument> = [];
71
+
72
+ /**
73
+ * @param source 需要合并的部分参数
74
+ */
75
+ constructor(source?: Partial<CallEvent>) {
76
+ source = Object.assign({}, CallEvent.getDefaultOptions(), source);
77
+ super(source);
78
+ super.subConstructor(source);
79
+ }
80
+
81
+ static from(source: any, parentNode?: any, parentKey?: string): CallEvent {
82
+ return super.from(source, parentNode, parentKey) as CallEvent;
83
+ }
84
+
85
+ /**
86
+ * 设置calleeName
87
+ */
88
+ setCalleeName(calleeName: string) {
89
+ const object = {
90
+ calleeName,
91
+ };
92
+ this.update({
93
+ ...object,
94
+ });
95
+ }
96
+
97
+ /**
98
+ * 插入实际参数
99
+ * @internal
100
+ * @param argumentOptions 实际参数参数
101
+ */
102
+ _insertArgumentAt(argumentOptions: Partial<Argument>, index: number): Argument;
103
+
104
+ /**
105
+ * 插入实际参数
106
+ * @internal
107
+ * @param argument 已有的实际参数实例
108
+ */
109
+ _insertArgumentAt(argument: Argument, index: number): Argument;
110
+
111
+ _insertArgumentAt(options: Partial<Argument> | Argument, index: number) {
112
+ const argumentOptions: any = {};
113
+ const relationOptions = { parentNode: this, parentKey: 'arguments' };
114
+ const Argument = getConceptConstructor('Argument');
115
+ let argument: Argument;
116
+ if (asserts.isArgument(options)) {
117
+ options.ensureDelete(); // 同一实例不支持多处存在
118
+ argument = options;
119
+ Object.assign(argument, relationOptions);
120
+ } else {
121
+ argument = Argument.from(
122
+ {
123
+ ...argumentOptions,
124
+ ...options,
125
+ },
126
+ this,
127
+ 'arguments',
128
+ );
129
+ }
130
+ this.arguments.splice(index, 0, argument);
131
+ return argument;
132
+ }
133
+
134
+ /**
135
+ * 插入实际参数
136
+ * @param argumentOptions 实际参数参数
137
+ */
138
+ insertArgumentAt(argumentOptions: Partial<Argument>, index: number): Argument;
139
+
140
+ /**
141
+ * 插入实际参数
142
+ * @param argument 已有的实际参数实例
143
+ */
144
+ insertArgumentAt(argument: Argument, index: number): Argument;
145
+
146
+ insertArgumentAt(options: Partial<Argument> | Argument, index: number) {
147
+ const node = this._insertArgumentAt(options as any, index);
148
+ node.create({
149
+ index,
150
+ parentNode: this,
151
+ parentKey: 'arguments',
152
+ });
153
+ return node;
154
+ }
155
+
156
+ /**
157
+ * 添加实际参数
158
+ * @internal
159
+ * @param argumentOptions 实际参数参数
160
+ */
161
+ _addArgument(argumentOptions: Partial<Argument>): Argument;
162
+
163
+ /**
164
+ * 添加实际参数
165
+ * @internal
166
+ * @param argument 已有的实际参数实例
167
+ */
168
+ _addArgument(argument: Argument): Argument;
169
+
170
+ _addArgument(options?: Partial<Argument> | Argument) {
171
+ const index = this.arguments.length;
172
+ return this._insertArgumentAt(options as any, index);
173
+ }
174
+
175
+ /**
176
+ * 添加实际参数
177
+ * @param argumentOptions 实际参数参数
178
+ */
179
+ addArgument(argumentOptions: Partial<Argument>): Argument;
180
+
181
+ /**
182
+ * 添加实际参数
183
+ * @param argument 已有的实际参数实例
184
+ */
185
+ addArgument(argument: Argument): Argument;
186
+
187
+ addArgument(options?: Partial<Argument> | Argument) {
188
+ const node = this._addArgument(options as any);
189
+ const index = this.arguments.indexOf(node);
190
+ node.create({
191
+ index,
192
+ parentNode: this,
193
+ parentKey: 'arguments',
194
+ });
195
+ return node;
196
+ }
197
+
198
+ /**
199
+ * 删除实际参数
200
+ * @param argument 已有的实际参数实例
201
+ */
202
+ removeArgument(argument: Argument): void;
203
+
204
+ removeArgument(options: Argument) {
205
+ let argument: Argument = options;
206
+ return argument.delete();
207
+ }
208
+
209
+ __removeLogicItem(logicItem: LogicItem) {
210
+ const parentKey = logicItem.parentKey;
211
+ const params: Params = {
212
+ parentNode: this,
213
+ parentKey,
214
+ index: -1,
215
+ object: null,
216
+ oldObject: logicItem,
217
+ };
218
+ if (parentKey) {
219
+ params.parentKey = parentKey;
220
+ // @ts-ignore
221
+ const t = this.__v_raw || this;
222
+ // @ts-ignore
223
+ const n = logicItem.__v_raw || logicItem;
224
+ if (Array.isArray((t as any)[parentKey])) {
225
+ // @ts-ignore
226
+ const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
227
+ ~index && (this as any)[parentKey].splice(index, 1);
228
+ params.index = index;
229
+ } else {
230
+ const q = (t as any)[parentKey];
231
+ if ((q.__v_raw || q) === n) {
232
+ params.index = 0;
233
+ (this as any)[parentKey] = undefined;
234
+ }
235
+ }
236
+ }
237
+ return params;
238
+ }
239
+
240
+ //================================================================================
241
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
242
+ // 自动生成的代码已结束。下面可以手动编写。
243
+ //================================================================================
244
+ get businessComponent() {
245
+ return this.getAncestor('BusinessComponent') as BusinessComponent;
246
+ }
247
+
248
+ // 设置触发的事件
249
+ setCallee(event: Event) {
250
+ const Argument = getConceptConstructor('Argument');
251
+ const Identifier = getConceptConstructor('Identifier');
252
+ const calleeName = event.name;
253
+ const params = event?.params?.map((param) => {
254
+ const relationOptions = { parentNode: this, parentKey: 'arguments' };
255
+ const argument = Argument.from(
256
+ {
257
+ keyword: param.name,
258
+ expression: param.isFunction ? new Identifier() : param.defaultExpression,
259
+ },
260
+ this,
261
+ );
262
+ Object.assign(argument, relationOptions);
263
+ return argument;
264
+ });
265
+ this.update({
266
+ calleeName,
267
+ arguments: params,
268
+ folded: false,
269
+ });
270
+ }
271
+
272
+ // 被调用的事件
273
+ getCallNode(): Event | undefined {
274
+ return this.businessComponent?.events?.find((event: Event) => event.name === this.calleeName);
275
+ }
276
+
277
+ // 实参列表
278
+ get completeArguments() {
279
+ const callArguments = (this.arguments ?? []).slice();
280
+ // 没有参数时可以跳过查询原逻辑标签
281
+ const node = callArguments.length > 0 ? this.getCallNode() : undefined;
282
+ const logicParams = node?.params ?? [];
283
+
284
+ callArguments.forEach((arg, index) => {
285
+ const param = logicParams[index] || ({} as Param);
286
+ arg.paramRequired = Boolean(!param?.defaultValue?.expression);
287
+ arg.paramTypeAnnotation = undefined;
288
+ arg.paramDefaultValue = undefined;
289
+ // 强制更新当前的 keyword
290
+ arg.keyword = param?.name && param.name.length > 0 ? param.name : arg.keyword;
291
+ // 取到是不是必填放入参数中
292
+ if (param && !arg.expression) {
293
+ // 非必填时 才会有默认值
294
+ arg.paramTypeAnnotation = param.typeAnnotation;
295
+ arg.paramDefaultValue = param.defaultValue;
296
+ }
297
+ });
298
+
299
+ return callArguments;
300
+ }
301
+
302
+ @withSourceMapGenerator
303
+ *toEmbeddedTS(state = createCompilerState()): TranslatorGenerator {
304
+ const self = this;
305
+ const { calleeName, completeArguments, arguments: eventArgs } = self;
306
+ let code = `(this as ${this.businessComponent.name}).${calleeName ?? '__IDENTIFIER__'}(`;
307
+ if (completeArguments?.length) {
308
+ yield* wrapForEach(completeArguments, function* warpForEachGenerator(arg, index) {
309
+ // 取到是不是必填放入参数中
310
+ code += yield* arg.toEmbeddedTS(shiftState(state, code), arg?.paramRequired);
311
+ if (index !== eventArgs.length - 1) code += ', ';
312
+ });
313
+ }
314
+ code += ')';
315
+ code += '\n';
316
+ return code;
317
+ }
318
+
319
+ toJS(state?: TranslatorState): string {
320
+ const { completeArguments = [] } = this;
321
+ let code = '';
322
+ code += `this.$emit('${this.calleeName}', {\n`;
323
+ if (Array.isArray(completeArguments) && completeArguments.length) {
324
+ const eventNode = this.getCallNode();
325
+ const eventParams = eventNode?.params;
326
+ completeArguments.forEach((arg, index) => {
327
+ let argStr = arg?.toJS(shiftState(state, code));
328
+ const paramDefaultValue = eventParams?.[index]?.defaultValue?.toJS?.();
329
+ if (paramDefaultValue) {
330
+ argStr = `${argStr} !== undefined ? ${argStr} : ${paramDefaultValue}`;
331
+ }
332
+ code += `${arg.keyword}: ${argStr}`;
333
+ if (index !== completeArguments?.length - 1) {
334
+ code += ', ';
335
+ }
336
+ });
337
+ }
338
+ code += '\n})';
339
+ return code;
340
+ }
341
+ //================================================================================
342
+ // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
343
+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
344
+ //================================================================================
345
+ }
346
+
347
+ export default CallEvent;
348
+ //================================================================================
349
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
350
+ // 自动生成的代码已结束。下面可以手动编写。
351
+ //================================================================================
@@ -16,7 +16,6 @@ import type Function from './Function__';
16
16
  import { ElementToVueOptions } from './ViewElement__';
17
17
  import type Identifier from './Identifier__';
18
18
  import { getBuildInFunction } from '../server/getFunctions';
19
- import type AnonymousFunction from './AnonymousFunction__';
20
19
  import type MemberExpression from './MemberExpression__';
21
20
  import asyncFuncMap from '../common/asyncFuncMap';
22
21
 
@@ -527,10 +526,18 @@ export class CallFunction extends LogicItem {
527
526
 
528
527
  code += ')';
529
528
  const tyAnno = (this as any).typeAnnotation || this.__TypeAnnotation;
529
+ let { sortedTypeKey, typeKind, typeName, typeNamespace } = tyAnno || {};
530
+ if (typeNamespace?.endsWith('.metadataTypes')) {
531
+ const referenceNode = this.app.findNodeByCompleteName(typeNamespace + '.' + typeName) || {};
532
+ const typeAn = referenceNode.typeAnnotation || {};
533
+ sortedTypeKey = `${typeAn.typeNamespace}.${typeAn.typeName}`;
534
+ typeKind = typeAn.typeKind;
535
+ typeName = typeAn.typeName;
536
+ }
530
537
  const needGenInitFromSchema =
531
- tyAnno && (!['primitive', 'union'].includes(tyAnno.typeKind) || tyAnno.typeName === 'DateTime');
538
+ tyAnno && (!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
532
539
  if (needGenInitFromSchema) {
533
- code = `this.$genInitFromSchema('${tyAnno?.sortedTypeKey}', ${code})`;
540
+ code = `this.$genInitFromSchema('${sortedTypeKey}', ${code})`;
534
541
  }
535
542
  return code;
536
543
  }
@@ -713,16 +720,6 @@ export class CallFunction extends LogicItem {
713
720
  return code;
714
721
  }
715
722
 
716
- checkParamNameOfAnonymousFunction() {
717
- const fns = this.arguments
718
- .map((arg) => arg.expression)
719
- .filter((exp) => asserts.isAnonymousFunction(exp)) as unknown as AnonymousFunction[];
720
-
721
- fns.forEach((fn) => {
722
- fn.checkParamName();
723
- });
724
- }
725
-
726
723
  getQuickInfoOffset(range: Range, getCode: GetCode) {
727
724
  return getCallExpressionQuickInfo(range, getCode);
728
725
  }
@@ -591,7 +591,7 @@ export class CallLogic extends LogicItem {
591
591
  _setCallee(logic: Logic) {
592
592
  const BaseNode = getBaseNode();
593
593
  this.calleeNamespace = logic.getNamespace();
594
- if (asserts.isView(logic.parentNode)) {
594
+ if (asserts.isView(logic.parentNode) || asserts.isBusinessComponent(logic.parentNode)) {
595
595
  this.calleeNamespace = '';
596
596
  }
597
597
  this.calleeName = logic.name;
@@ -615,7 +615,7 @@ export class CallLogic extends LogicItem {
615
615
 
616
616
  setCallee(logic: Logic) {
617
617
  let calleeNamespace = logic?.getNamespace() || '';
618
- if (asserts.isView(logic.parentNode)) {
618
+ if (asserts.isView(logic.parentNode) || asserts.isBusinessComponent(logic.parentNode)) {
619
619
  calleeNamespace = '';
620
620
  }
621
621
  const calleeName = logic.name;
@@ -773,23 +773,23 @@ export class CallLogic extends LogicItem {
773
773
  code += calleeName;
774
774
  }
775
775
  return code;
776
- } else if (bindAttr?.name === 'text') {
777
- if (calleeName === 'jsonSerialize') {
778
- if (
779
- this.arguments[0]?.expression?.__TypeAnnotation?.typeName === 'String' &&
780
- this.arguments[0]?.expression?.__TypeAnnotation?.typeNamespace === 'nasl.core'
781
- ) {
782
- code += options?.finalCode === false ? 'JSON 序列化' : 'JSON.stringify';
783
- } else {
784
- code += options?.finalCode === false ? 'JSON 序列化' : `$utils['JsonSerialize']`;
785
- }
786
- setArguments();
787
- return code;
788
- } else if (calleeName === 'jsonDeserialize') {
789
- code += options?.finalCode === false ? 'JSON 反序列化' : 'JSON.parse';
790
- setArguments();
791
- return code;
776
+ }
777
+ if (calleeName === 'jsonSerialize') {
778
+ if (
779
+ this.arguments[0]?.expression?.__TypeAnnotation?.typeName === 'String' &&
780
+ this.arguments[0]?.expression?.__TypeAnnotation?.typeNamespace === 'nasl.core'
781
+ ) {
782
+ code += options?.finalCode === false ? 'JSON 序列化' : 'JSON.stringify';
783
+ } else {
784
+ code += options?.finalCode === false ? 'JSON 序列化' : `$utils['JsonSerialize']`;
792
785
  }
786
+ setArguments();
787
+ return code;
788
+ }
789
+ if (calleeName === 'jsonDeserialize') {
790
+ code += options?.finalCode === false ? 'JSON 反序列化' : 'JSON.parse';
791
+ setArguments();
792
+ return code;
793
793
  }
794
794
  }
795
795
 
@@ -815,12 +815,11 @@ export class CallLogic extends LogicItem {
815
815
 
816
816
  if (bindAttr?.name === 'data-source') {
817
817
  return this.calleeName;
818
- } else if (bindAttr?.name === 'text') {
819
- if (calleeName === 'jsonSerialize') {
820
- return 'JSON 序列化';
821
- } else if (calleeName === 'jsonDeserialize') {
822
- return 'JSON 反序列化';
823
- }
818
+ }
819
+ if (calleeName === 'jsonSerialize') {
820
+ return 'JSON 序列化';
821
+ } if (calleeName === 'jsonDeserialize') {
822
+ return 'JSON 反序列化';
824
823
  }
825
824
  }
826
825
 
@@ -907,9 +906,8 @@ export class CallLogic extends LogicItem {
907
906
  const args = logic?.params || [];
908
907
  const keywordEntitiesIndex = findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'entities');
909
908
 
910
- code += `this.$logics['${
911
- this.calleeNamespace ? `${this.calleeNamespace}.${this.calleeName}` : this.calleeName
912
- }']`;
909
+ code += `this.$logics['${this.calleeNamespace ? `${this.calleeNamespace}.${this.calleeName}` : this.calleeName
910
+ }']`;
913
911
  code += `({
914
912
  config: {
915
913
  download: false,
@@ -1193,11 +1191,17 @@ export class CallLogic extends LogicItem {
1193
1191
  };
1194
1192
  }
1195
1193
  const typeAnnotation = (this as any).typeAnnotation || this.__TypeAnnotation;
1196
- const needGenInitFromSchema =
1197
- typeAnnotation &&
1198
- (!['primitive', 'union'].includes(typeAnnotation.typeKind) || typeAnnotation.typeName === 'DateTime');
1194
+ let { sortedTypeKey, typeKind, typeName, typeNamespace } = typeAnnotation || {};
1195
+ if (typeNamespace?.endsWith('.metadataTypes')) {
1196
+ const referenceNode = this.app.findNodeByCompleteName(typeNamespace + '.' + typeName) || {};
1197
+ const typeAn = referenceNode.typeAnnotation || {};
1198
+ sortedTypeKey = `${typeAn.typeNamespace}.${typeAn.typeName}`;
1199
+ typeKind = typeAn.typeKind;
1200
+ typeName = typeAn.typeName;
1201
+ }
1202
+ const needGenInitFromSchema = typeAnnotation && (!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
1199
1203
  if (needGenInitFromSchema) {
1200
- code = `this.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}', ${code})`;
1204
+ code = `this.$genInitFromSchema('${sortedTypeKey}', ${code})`;
1201
1205
  }
1202
1206
  code += ')';
1203
1207
  return code;
@@ -1217,6 +1221,10 @@ export class CallLogic extends LogicItem {
1217
1221
  return Boolean(this.handleError || this.useValidation);
1218
1222
  }
1219
1223
 
1224
+ get businessComponent() {
1225
+ return this.getAncestor('BusinessComponent');
1226
+ }
1227
+
1220
1228
  @withSourceMapGenerator
1221
1229
  *toEmbeddedTS(state = createCompilerState()): TranslatorGenerator {
1222
1230
  const self = this;
@@ -1351,6 +1359,11 @@ export class CallLogic extends LogicItem {
1351
1359
  yield* setInputParam();
1352
1360
  code += ';\n})()';
1353
1361
  } else {
1362
+ // 属于业务组件
1363
+ const belongBusinessComponent = !!this.businessComponent;
1364
+ if (belongBusinessComponent && !self.calleeNamespace) {
1365
+ code += `(this as ${this.businessComponent.name}).`;
1366
+ }
1354
1367
  code += calleeKey;
1355
1368
  yield* setTypeArguments();
1356
1369
  yield* setInputParam();
@@ -1508,7 +1521,7 @@ export class CallLogic extends LogicItem {
1508
1521
  state: Array.isArray(t) ? 2 : 1,
1509
1522
  };
1510
1523
  });
1511
- } catch (err) {}
1524
+ } catch (err) { }
1512
1525
  }
1513
1526
  return node;
1514
1527
  }
@@ -347,15 +347,13 @@ export class Constant extends BaseNode {
347
347
  }
348
348
  if (this.typeAnnotation) {
349
349
  code += `: `;
350
- if (
351
- this.defaultValue?.expression &&
352
- !(this.typeAnnotation && ['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(typeKey))
353
- ) {
354
- code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
355
- } else {
356
- if (['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(typeKey)) {
350
+ if (this.defaultValue?.expression) {
351
+ if (['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(this.typeAnnotation.typeKey)) {
357
352
  code += yield* this.defaultValue.toEmbeddedTS(shiftState(state, code), true);
353
+ } else {
354
+ code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
358
355
  }
356
+ } else {
359
357
  code += 'undefined';
360
358
  }
361
359
  code += ' as ';
@@ -358,7 +358,8 @@ export class Destination extends LogicItem {
358
358
  if (this.viewName) {
359
359
  viewArr.push(this.viewName);
360
360
  }
361
- // 第一个是端名,需要去掉
361
+ // 端名和端类型名都需要去掉
362
+ viewArr.shift();
362
363
  viewArr.shift();
363
364
  return viewArr;
364
365
  }
@@ -367,7 +368,7 @@ export class Destination extends LogicItem {
367
368
  let code = '';
368
369
  const viewArr = this.genViewArr();
369
370
  if (Array.isArray(viewArr) && viewArr.length) {
370
- code += `let url = '${this.viewNode.frontend.prefixPath ? this.viewNode.frontend.prefixPath : ''}/${viewArr.join(
371
+ code += `let url = '${this.viewNode?.frontend?.prefixPath ? this.viewNode.frontend.prefixPath : ''}/${viewArr.join(
371
372
  '/',
372
373
  )}';\n`;
373
374
  const { completeArguments } = this;
@@ -690,20 +691,21 @@ export class Destination extends LogicItem {
690
691
  }
691
692
  });
692
693
  }
694
+ console.log(viewNameAttr);
693
695
  if (this.viewNode) {
694
- return `${this.viewNode.frontend.prefixPath}/${viewNameAttr.join('/')}`;
696
+ return `${this.viewNode?.frontend?.prefixPath}/${viewNameAttr.join('/')}`;
695
697
  }
696
698
  return `/${viewNameAttr.join('/')}`;
697
699
  }
698
700
 
699
701
  @withSourceMapGenerator
700
- *toEmbeddedTSInProcess(state = createCompilerState(), prependCode: string): TranslatorGenerator {
702
+ *toEmbeddedTSInProcess(state = createCompilerState(), prevCode: string): TranslatorGenerator {
701
703
  const self = this;
702
704
  // const tab = indent((state?.tabSize || 0));
703
705
  if (self.tsCalleeNamespace && self.tsName) {
704
706
  const destinationName = self.parentNode.name.replace('-', '_');
705
707
  let code = `${destinationName}: function() {\n`;
706
- code += prependCode;
708
+ code += prevCode;
707
709
  code += '\n';
708
710
  if (self.tsCalleeNamespace && self.viewName) {
709
711
  code += `${self.tsCalleeNamespace}.${self.viewName}.$destination({`;
@@ -99,6 +99,7 @@ export class End extends LogicItem {
99
99
  // 旧逻辑默认走这里,
100
100
  // 期望后期可以直接走完整的case, default 直接抛出异常好更明确定位错误
101
101
  logic =
102
+ self.getAncestor('BusinessLogic') ||
102
103
  self.parentNode.getAncestor('Logic') ||
103
104
  self.parentNode.getAncestor('AuthLogic') ||
104
105
  self.parentNode.getAncestor('AuthLogicForCallInterface') ||