@lcap/nasl 2.22.1 → 2.22.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 (116) hide show
  1. package/out/breakpoint/generator/AfterStartNode.d.ts +7 -0
  2. package/out/breakpoint/generator/AfterStartNode.js +27 -0
  3. package/out/breakpoint/generator/AfterStartNode.js.map +1 -0
  4. package/out/breakpoint/generator/BeforeEndNode.d.ts +7 -0
  5. package/out/breakpoint/generator/BeforeEndNode.js +27 -0
  6. package/out/breakpoint/generator/BeforeEndNode.js.map +1 -0
  7. package/out/breakpoint/generator/BreakpointNode.d.ts +14 -0
  8. package/out/breakpoint/generator/BreakpointNode.js +200 -0
  9. package/out/breakpoint/generator/BreakpointNode.js.map +1 -0
  10. package/out/breakpoint/generator/index.d.ts +4 -0
  11. package/out/breakpoint/generator/index.js +98 -0
  12. package/out/breakpoint/generator/index.js.map +1 -0
  13. package/out/breakpoint/index.d.ts +3 -0
  14. package/out/breakpoint/index.js +20 -0
  15. package/out/breakpoint/index.js.map +1 -0
  16. package/out/breakpoint/shared/constants.d.ts +31 -0
  17. package/out/breakpoint/shared/constants.js +89 -0
  18. package/out/breakpoint/shared/constants.js.map +1 -0
  19. package/out/breakpoint/shared/index.d.ts +3 -0
  20. package/out/breakpoint/shared/index.js +33 -0
  21. package/out/breakpoint/shared/index.js.map +1 -0
  22. package/out/breakpoint/shared/operations.d.ts +10 -0
  23. package/out/breakpoint/shared/operations.js +25 -0
  24. package/out/breakpoint/shared/operations.js.map +1 -0
  25. package/out/breakpoint/shared/socket.d.ts +47 -0
  26. package/out/breakpoint/shared/socket.js +210 -0
  27. package/out/breakpoint/shared/socket.js.map +1 -0
  28. package/out/breakpoint/shared/utils.d.ts +23 -0
  29. package/out/breakpoint/shared/utils.js +165 -0
  30. package/out/breakpoint/shared/utils.js.map +1 -0
  31. package/out/breakpoint/store/core.d.ts +32 -0
  32. package/out/breakpoint/store/core.js +388 -0
  33. package/out/breakpoint/store/core.js.map +1 -0
  34. package/out/breakpoint/store/dock.d.ts +1 -0
  35. package/out/breakpoint/store/dock.js +127 -0
  36. package/out/breakpoint/store/dock.js.map +1 -0
  37. package/out/breakpoint/store/index.d.ts +2 -0
  38. package/out/breakpoint/store/index.js +19 -0
  39. package/out/breakpoint/store/index.js.map +1 -0
  40. package/out/common/asyncFuncMap.d.ts +2 -0
  41. package/out/common/asyncFuncMap.js +16 -0
  42. package/out/common/asyncFuncMap.js.map +1 -0
  43. package/out/concepts/AnonymousFunction__.js +1 -1
  44. package/out/concepts/AnonymousFunction__.js.map +1 -1
  45. package/out/concepts/AuthInterface__.d.ts +37 -0
  46. package/out/concepts/AuthInterface__.js +141 -0
  47. package/out/concepts/AuthInterface__.js.map +1 -0
  48. package/out/concepts/AuthLogicForCallInterface__.d.ts +138 -0
  49. package/out/concepts/AuthLogicForCallInterface__.js +493 -0
  50. package/out/concepts/AuthLogicForCallInterface__.js.map +1 -0
  51. package/out/concepts/AuthLogic__.d.ts +66 -0
  52. package/out/concepts/AuthLogic__.js +206 -0
  53. package/out/concepts/AuthLogic__.js.map +1 -0
  54. package/out/concepts/BackendVariable__.d.ts +137 -0
  55. package/out/concepts/BackendVariable__.js +422 -0
  56. package/out/concepts/BackendVariable__.js.map +1 -0
  57. package/out/concepts/Backend__.d.ts +134 -0
  58. package/out/concepts/Backend__.js +274 -0
  59. package/out/concepts/Backend__.js.map +1 -0
  60. package/out/concepts/CallAuthInterface__.d.ts +126 -0
  61. package/out/concepts/CallAuthInterface__.js +408 -0
  62. package/out/concepts/CallAuthInterface__.js.map +1 -0
  63. package/out/concepts/Destination__.js +6 -4
  64. package/out/concepts/Destination__.js.map +1 -1
  65. package/out/concepts/FrontendVariable__.d.ts +21 -0
  66. package/out/concepts/FrontendVariable__.js +64 -0
  67. package/out/concepts/FrontendVariable__.js.map +1 -0
  68. package/out/concepts/Match__.js +25 -6
  69. package/out/concepts/Match__.js.map +1 -1
  70. package/out/concepts/OverriddenLogic__.d.ts +643 -0
  71. package/out/concepts/OverriddenLogic__.js +1602 -0
  72. package/out/concepts/OverriddenLogic__.js.map +1 -0
  73. package/out/concepts/Param__.js +1 -1
  74. package/out/concepts/Param__.js.map +1 -1
  75. package/out/concepts/basics/stdlib/nasl.http.d.ts +7 -0
  76. package/out/concepts/basics/stdlib/nasl.http.js +167 -0
  77. package/out/concepts/basics/stdlib/nasl.http.js.map +1 -0
  78. package/out/server/naslServer.js +4 -0
  79. package/out/server/naslServer.js.map +1 -1
  80. package/out/service/creator/errHandles.js +5 -0
  81. package/out/service/creator/errHandles.js.map +1 -1
  82. package/out/templator/genCreateBlock.js +2 -1
  83. package/out/templator/genCreateBlock.js.map +1 -1
  84. package/out/templator/genCurdEditMultipleKeyBlock.js +6 -3
  85. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  86. package/out/templator/genCurdMultipleKeyBlock.js +4 -2
  87. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  88. package/out/templator/genEditTableBlock.js +2 -1
  89. package/out/templator/genEditTableBlock.js.map +1 -1
  90. package/out/templator/genUpdateBlock.js +2 -1
  91. package/out/templator/genUpdateBlock.js.map +1 -1
  92. package/package.json +2 -2
  93. package/src/concepts/AnonymousFunction__.ts +1 -1
  94. package/src/concepts/Destination__.ts +7 -5
  95. package/src/concepts/Match__.ts +24 -6
  96. package/src/concepts/Param__.ts +1 -1
  97. package/src/concepts/dist/App__.js +2204 -0
  98. package/src/concepts/dist/CallLogic__.js +1149 -0
  99. package/src/concepts/dist/Destination__.js +756 -0
  100. package/src/concepts/dist/Logic__.js +1612 -0
  101. package/src/concepts/dist/Match__.js +768 -0
  102. package/src/concepts/dist/MsgTriggerEvent__.js +245 -0
  103. package/src/concepts/dist/OqlQueryComponent__.js +377 -0
  104. package/src/concepts/dist/Param__.js +1 -1
  105. package/src/generator/dist/genBundleFiles.js +15 -4
  106. package/src/generator/dist/genReleaseBody.js +501 -0
  107. package/src/server/dist/naslServer.js +25 -6
  108. package/src/server/naslServer.ts +4 -0
  109. package/src/service/creator/errHandles.js +8 -3
  110. package/src/service/storage/dist/init.js +34 -32
  111. package/src/templator/genCreateBlock.ts +2 -1
  112. package/src/templator/genCurdEditMultipleKeyBlock.ts +6 -3
  113. package/src/templator/genCurdMultipleKeyBlock.ts +4 -2
  114. package/src/templator/genEditTableBlock.ts +2 -1
  115. package/src/templator/genUpdateBlock.ts +2 -1
  116. package/test/examples/qzbusiness.json +1 -98265
@@ -0,0 +1,1149 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __assign = (this && this.__assign) || function () {
16
+ __assign = Object.assign || function(t) {
17
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
18
+ s = arguments[i];
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
+ t[p] = s[p];
21
+ }
22
+ return t;
23
+ };
24
+ return __assign.apply(this, arguments);
25
+ };
26
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
27
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
28
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
29
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
30
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
31
+ };
32
+ exports.__esModule = true;
33
+ exports.CallLogic = void 0;
34
+ var translator_1 = require("../translator");
35
+ var Logic__1 = require("./Logic__");
36
+ var View__1 = require("./View__");
37
+ var utils_1 = require("../automate/engine/utils");
38
+ var utils_2 = require("../utils");
39
+ var JSON5 = require("json5");
40
+ var config_1 = require("../config");
41
+ var Identifier__1 = require("./Identifier__");
42
+ var decorators_1 = require("../decorators");
43
+ var uuid_1 = require("uuid");
44
+ var BaseNode_1 = require("../common/BaseNode");
45
+ var classMap_1 = require("../common/classMap");
46
+ var TypeAnnotation__1 = require("./TypeAnnotation__");
47
+ var Argument__1 = require("./Argument__");
48
+ var LogicItem__1 = require("./LogicItem__");
49
+ /**
50
+ * 调用逻辑
51
+ */
52
+ var CallLogic = /** @class */ (function (_super) {
53
+ __extends(CallLogic, _super);
54
+ /**
55
+ * @param source 需要合并的部分参数
56
+ */
57
+ function CallLogic(source) {
58
+ var _this = this;
59
+ source = Object.assign({}, CallLogic_1.getDefaultOptions(), source);
60
+ _this = _super.call(this, source) || this;
61
+ /**
62
+ * uuid
63
+ */
64
+ _this.uuid = uuid_1.v4().replace(/-/g, '');
65
+ /**
66
+ * 产品概念
67
+ */
68
+ _this.concept = 'CallLogic';
69
+ /**
70
+ * 调用逻辑标题
71
+ */
72
+ _this.label = '调用逻辑';
73
+ /**
74
+ * calleeNamespace
75
+ */
76
+ _this.calleeNamespace = undefined;
77
+ /**
78
+ * calleeName
79
+ */
80
+ _this.calleeName = undefined;
81
+ /**
82
+ * shortcut
83
+ */
84
+ _this.shortcut = undefined;
85
+ /**
86
+ * handleError
87
+ */
88
+ _this.handleError = undefined;
89
+ /**
90
+ * 类型参数
91
+ */
92
+ _this.typeArguments = null;
93
+ /**
94
+ * 实际参数
95
+ */
96
+ _this.arguments = [];
97
+ /**
98
+ * 验证规则
99
+ */
100
+ _this.validation = undefined;
101
+ /**
102
+ * 是否被折叠
103
+ */
104
+ _this.isAdvancedSettingFolded = undefined;
105
+ _super.prototype.subConstructor.call(_this, source);
106
+ return _this;
107
+ }
108
+ CallLogic_1 = CallLogic;
109
+ CallLogic.prototype.getClassName = function () {
110
+ return 'CallLogic';
111
+ };
112
+ CallLogic.from = function (source, parentNode, parentKey) {
113
+ return _super.from.call(this, source, parentNode, parentKey);
114
+ };
115
+ /**
116
+ * 设置验证规则
117
+ */
118
+ CallLogic.prototype.setValidation = function (validation) {
119
+ validation._delete();
120
+ var relationOptions = { parentNode: this, parentKey: 'validation' };
121
+ Object.assign(validation, relationOptions);
122
+ var object = {
123
+ validation: validation
124
+ };
125
+ this.update(__assign({}, object));
126
+ };
127
+ /**
128
+ * 设置是否被折叠
129
+ */
130
+ CallLogic.prototype.setIsAdvancedSettingFolded = function (isAdvancedSettingFolded) {
131
+ var object = {
132
+ isAdvancedSettingFolded: isAdvancedSettingFolded
133
+ };
134
+ this.update(__assign({}, object));
135
+ };
136
+ CallLogic.prototype._insertTypeAnnotationAt = function (options, index) {
137
+ var typeAnnotationOptions = {};
138
+ var relationOptions = { parentNode: this, parentKey: 'typeArguments' };
139
+ var typeAnnotation;
140
+ if (options instanceof TypeAnnotation__1["default"]) {
141
+ options.ensureDelete(); // 同一实例不支持多处存在
142
+ typeAnnotation = options;
143
+ Object.assign(typeAnnotation, relationOptions);
144
+ }
145
+ else {
146
+ typeAnnotation = TypeAnnotation__1["default"].from(__assign(__assign({}, typeAnnotationOptions), options), this, 'typeArguments');
147
+ }
148
+ this.typeArguments.splice(index, 0, typeAnnotation);
149
+ return typeAnnotation;
150
+ };
151
+ CallLogic.prototype.insertTypeAnnotationAt = function (options, index) {
152
+ var node = this._insertTypeAnnotationAt(options, index);
153
+ node.create({
154
+ index: index,
155
+ parentNode: this,
156
+ parentKey: 'typeArguments'
157
+ });
158
+ return node;
159
+ };
160
+ CallLogic.prototype._addTypeAnnotation = function (options) {
161
+ var index = this.typeArguments.length;
162
+ return this._insertTypeAnnotationAt(options, index);
163
+ };
164
+ CallLogic.prototype.addTypeAnnotation = function (options) {
165
+ var node = this._addTypeAnnotation(options);
166
+ var index = this.typeArguments.indexOf(node);
167
+ node.create({
168
+ index: index,
169
+ parentNode: this,
170
+ parentKey: 'typeArguments'
171
+ });
172
+ return node;
173
+ };
174
+ CallLogic.prototype._insertArgumentAt = function (options, index) {
175
+ var argumentOptions = {};
176
+ var relationOptions = { parentNode: this, parentKey: 'arguments' };
177
+ var argument;
178
+ if (options instanceof Argument__1["default"]) {
179
+ options.ensureDelete(); // 同一实例不支持多处存在
180
+ argument = options;
181
+ Object.assign(argument, relationOptions);
182
+ }
183
+ else {
184
+ argument = Argument__1["default"].from(__assign(__assign({}, argumentOptions), options), this, 'arguments');
185
+ }
186
+ this.arguments.splice(index, 0, argument);
187
+ return argument;
188
+ };
189
+ CallLogic.prototype.insertArgumentAt = function (options, index) {
190
+ var node = this._insertArgumentAt(options, index);
191
+ node.create({
192
+ index: index,
193
+ parentNode: this,
194
+ parentKey: 'arguments'
195
+ });
196
+ return node;
197
+ };
198
+ CallLogic.prototype._addArgument = function (options) {
199
+ var index = this.arguments.length;
200
+ return this._insertArgumentAt(options, index);
201
+ };
202
+ CallLogic.prototype.addArgument = function (options) {
203
+ var node = this._addArgument(options);
204
+ var index = this.arguments.indexOf(node);
205
+ node.create({
206
+ index: index,
207
+ parentNode: this,
208
+ parentKey: 'arguments'
209
+ });
210
+ return node;
211
+ };
212
+ CallLogic.prototype.removeTypeAnnotation = function (options) {
213
+ var typeAnnotation = options;
214
+ return typeAnnotation["delete"]();
215
+ };
216
+ CallLogic.prototype.__removeTypeAnnotation = function (typeAnnotation) {
217
+ var parentKey = typeAnnotation.parentKey;
218
+ var params = {
219
+ parentNode: this,
220
+ parentKey: parentKey,
221
+ index: -1,
222
+ object: null,
223
+ oldObject: typeAnnotation
224
+ };
225
+ if (parentKey) {
226
+ params.parentKey = parentKey;
227
+ if (Array.isArray(this[parentKey])) {
228
+ var index = this[parentKey].indexOf(typeAnnotation);
229
+ ~index && this[parentKey].splice(index, 1);
230
+ params.index = index;
231
+ }
232
+ else if (this[parentKey] === typeAnnotation) {
233
+ params.index = 0;
234
+ this[parentKey] = undefined;
235
+ }
236
+ }
237
+ return params;
238
+ };
239
+ CallLogic.prototype.removeArgument = function (options) {
240
+ var argument = options;
241
+ return argument["delete"]();
242
+ };
243
+ CallLogic.prototype.__removeLogicItem = function (logicItem) {
244
+ var parentKey = logicItem.parentKey;
245
+ var params = {
246
+ parentNode: this,
247
+ parentKey: parentKey,
248
+ index: -1,
249
+ object: null,
250
+ oldObject: logicItem
251
+ };
252
+ if (parentKey) {
253
+ params.parentKey = parentKey;
254
+ if (Array.isArray(this[parentKey])) {
255
+ var index = this[parentKey].indexOf(logicItem);
256
+ ~index && this[parentKey].splice(index, 1);
257
+ params.index = index;
258
+ }
259
+ else if (this[parentKey] === logicItem) {
260
+ params.index = 0;
261
+ this[parentKey] = undefined;
262
+ }
263
+ }
264
+ return params;
265
+ };
266
+ CallLogic.prototype.removeValidation = function (options) {
267
+ var validation;
268
+ if (typeof options === 'string') {
269
+ validation = this.validation;
270
+ if (!validation) {
271
+ throw new Error('找不到元素绑定属性 ' + options);
272
+ }
273
+ }
274
+ else {
275
+ validation = options;
276
+ }
277
+ return validation["delete"]();
278
+ };
279
+ CallLogic.prototype.__removeBindAttribute = function (bindAttribute) {
280
+ var parentKey = bindAttribute.parentKey;
281
+ var params = {
282
+ parentNode: this,
283
+ parentKey: parentKey,
284
+ index: -1,
285
+ object: null,
286
+ oldObject: bindAttribute
287
+ };
288
+ if (parentKey) {
289
+ params.parentKey = parentKey;
290
+ if (Array.isArray(this[parentKey])) {
291
+ var index = this[parentKey].indexOf(bindAttribute);
292
+ ~index && this[parentKey].splice(index, 1);
293
+ params.index = index;
294
+ }
295
+ else if (this[parentKey] === bindAttribute) {
296
+ params.index = 0;
297
+ this[parentKey] = undefined;
298
+ }
299
+ }
300
+ return params;
301
+ };
302
+ Object.defineProperty(CallLogic.prototype, "tsCalleeNamespace", {
303
+ //================================================================================
304
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
305
+ // 自动生成的代码已结束。下面可以手动编写。
306
+ //================================================================================
307
+ get: function () {
308
+ if (this.calleeNamespace) {
309
+ var tsCalleeNamespace = this.calleeNamespace;
310
+ tsCalleeNamespace = tsCalleeNamespace.replace(/\.[0-9]/g, function (m) { return m.replace('.', '.$'); });
311
+ tsCalleeNamespace = tsCalleeNamespace.replace(/-/g, '_');
312
+ return tsCalleeNamespace;
313
+ }
314
+ return '';
315
+ },
316
+ enumerable: false,
317
+ configurable: true
318
+ });
319
+ Object.defineProperty(CallLogic.prototype, "calleewholeKey", {
320
+ // 用于logic回填
321
+ get: function () {
322
+ if (!this.calleeNamespace && this.calleeName && this.view) {
323
+ // 页面逻辑单独处理
324
+ return this.view.getNamespace() + "." + this.view.name + ".logics." + this.calleeName;
325
+ }
326
+ // "app.logics"
327
+ return this.calleeNamespace + '.' + this.calleeName;
328
+ },
329
+ enumerable: false,
330
+ configurable: true
331
+ });
332
+ Object.defineProperty(CallLogic.prototype, "calleeKey", {
333
+ get: function () {
334
+ var tsCalleeNamespace = this.tsCalleeNamespace;
335
+ var calleeName = this.calleeName;
336
+ if (!tsCalleeNamespace) {
337
+ return calleeName ? "" + calleeName : '__IDENTIFIER__';
338
+ }
339
+ // elements单独处理相对路径,和后缀的问题
340
+ if (tsCalleeNamespace.startsWith('elements') && tsCalleeNamespace.endsWith('logics')) {
341
+ var methodName = tsCalleeNamespace.substring(0, tsCalleeNamespace.length - '.logics'.length);
342
+ return '__' + methodName + ("." + calleeName);
343
+ }
344
+ return calleeName ? tsCalleeNamespace + "." + calleeName : '__IDENTIFIER__';
345
+ },
346
+ enumerable: false,
347
+ configurable: true
348
+ });
349
+ /**
350
+ * 设置argment 触发别的地方的更新
351
+ */
352
+ CallLogic.prototype.setArgumentName = function (_a) {
353
+ var argument = _a.argument;
354
+ // argument.setKeyword(newKeyword);
355
+ // this.arguments = argument;
356
+ };
357
+ /**
358
+ * 设置setCalleeName
359
+ */
360
+ CallLogic.prototype.setCalleeName = function (calleeName) {
361
+ var object = {
362
+ calleeName: calleeName
363
+ };
364
+ this.update(__assign({}, object));
365
+ };
366
+ /**
367
+ * 设置calleeNamespace
368
+ */
369
+ CallLogic.prototype.setCalleeNamespace = function (calleeNamespace) {
370
+ var object = {
371
+ calleeNamespace: calleeNamespace
372
+ };
373
+ this.update(__assign({}, object));
374
+ };
375
+ /**
376
+ * 设置 handleError
377
+ */
378
+ CallLogic.prototype.setHandleError = function (handleError) {
379
+ var object = {
380
+ handleError: handleError
381
+ };
382
+ this.update(__assign({}, object));
383
+ };
384
+ CallLogic.prototype._setCallee = function (logic) {
385
+ var _this = this;
386
+ console.trace();
387
+ this.calleeNamespace = logic.getNamespace();
388
+ if (logic.parentNode instanceof View__1["default"]) {
389
+ this.calleeNamespace = '';
390
+ }
391
+ this.calleeName = logic.name;
392
+ this.arguments = [];
393
+ logic.params.forEach(function (param) {
394
+ var argument = _this._addArgument({
395
+ keyword: param.name
396
+ });
397
+ if (param.defaultExpression) {
398
+ var exp = BaseNode_1["default"].from(__assign({}, param.defaultExpression.toJSON()));
399
+ argument.setExpression(exp);
400
+ }
401
+ });
402
+ if (logic.typeParams) {
403
+ this.typeArguments = [];
404
+ logic.typeParams.forEach(function () {
405
+ _this._addTypeAnnotation({});
406
+ });
407
+ }
408
+ };
409
+ CallLogic.prototype.setCallee = function (logic) {
410
+ var _this = this;
411
+ var calleeNamespace = (logic === null || logic === void 0 ? void 0 : logic.getNamespace()) || '';
412
+ if (logic.parentNode instanceof View__1["default"]) {
413
+ calleeNamespace = '';
414
+ }
415
+ var calleeName = logic.name;
416
+ var params = logic.params.map(function (param) {
417
+ var relationOptions = { parentNode: _this, parentKey: 'arguments' };
418
+ var argument = Argument__1["default"].from({
419
+ keyword: param.name,
420
+ expression: param.isFunction ? new Identifier__1["default"]() : param.defaultExpression
421
+ }, _this);
422
+ Object.assign(argument, relationOptions);
423
+ return argument;
424
+ });
425
+ var typeArguments = null;
426
+ if (logic.typeParams) {
427
+ typeArguments = logic.typeParams.map(function () {
428
+ var relationOptions = { parentNode: _this, parentKey: 'typeArguments' };
429
+ var typeArgu = new TypeAnnotation__1["default"]();
430
+ Object.assign(typeArgu, relationOptions);
431
+ return typeArgu;
432
+ });
433
+ }
434
+ // 如果打开了处理error的开关 或者是 依赖库的逻辑引用,而且类型中携带了Error的
435
+ var handleError = false;
436
+ if ((calleeNamespace === null || calleeNamespace === void 0 ? void 0 : calleeNamespace.startsWith('extensions')) && Logic__1["default"].checkLogicReturnTypeHasError(logic)) {
437
+ handleError = true;
438
+ }
439
+ if (this.app) {
440
+ this.app.emit('collect:start', {
441
+ actionMsg: "\u5207\u6362\u8C03\u7528\u903B\u8F91"
442
+ });
443
+ var parentNode = this.parentNode;
444
+ this.update({
445
+ calleeNamespace: calleeNamespace,
446
+ calleeName: calleeName,
447
+ arguments: params,
448
+ typeArguments: typeArguments,
449
+ folded: false,
450
+ handleError: handleError
451
+ });
452
+ if (parentNode.concept === 'MemberExpression') {
453
+ var topNode = parentNode.firstMemberExpressionNode();
454
+ topNode.replaceNode(this);
455
+ }
456
+ this.app.emit('collect:end');
457
+ }
458
+ else {
459
+ this.update({
460
+ calleeNamespace: calleeNamespace,
461
+ calleeName: calleeName,
462
+ arguments: params,
463
+ typeArguments: typeArguments,
464
+ folded: false,
465
+ handleError: handleError
466
+ });
467
+ }
468
+ };
469
+ CallLogic.prototype.addCalleeArg = function (logic) {
470
+ var _this = this;
471
+ var newArgs = this.arguments.map(function (argument) {
472
+ return Argument__1["default"].from(__assign({}, argument), _this);
473
+ });
474
+ var relationOptions = { parentNode: this, parentKey: 'arguments' };
475
+ /**
476
+ * 当前两个参数对应上,添加的时候,logic会比参数位内容多,就添加一个 argment
477
+ */
478
+ if (logic.params.length >= newArgs.length) {
479
+ logic.params.forEach(function (param, index) {
480
+ var arg = newArgs[index];
481
+ if (!arg) {
482
+ var newParam = Argument__1["default"].from({
483
+ keyword: param.name
484
+ }, _this);
485
+ Object.assign(newParam, relationOptions);
486
+ newArgs.push(newParam);
487
+ }
488
+ else {
489
+ arg.keyword = param.name;
490
+ }
491
+ });
492
+ }
493
+ else {
494
+ /**
495
+ * 当前calllogic上数量比logic参数还多,他就需要找一个arg使他变成可用的参数
496
+ */
497
+ newArgs.forEach(function (arg, index) {
498
+ var param = logic.params[index];
499
+ if (param) {
500
+ arg.keyword = param.name;
501
+ }
502
+ });
503
+ }
504
+ this.update({
505
+ arguments: newArgs
506
+ });
507
+ };
508
+ CallLogic.prototype.deleteCalleeArg = function (argIndex) {
509
+ var _a, _b, _c;
510
+ /**
511
+ * 传递过下标来,然后直接移动到最后结束
512
+ * 如果原来就是最后一个位置就不移动了
513
+ */
514
+ if (typeof argIndex === 'number') {
515
+ if (!((_a = this.arguments[argIndex]) === null || _a === void 0 ? void 0 : _a.expression)) {
516
+ // 如果本身没有值就直接删除
517
+ return (_b = this.arguments[argIndex]) === null || _b === void 0 ? void 0 : _b["delete"]();
518
+ }
519
+ if (argIndex !== this.arguments.length - 1) {
520
+ (_c = this.arguments[argIndex]) === null || _c === void 0 ? void 0 : _c.moveNode({
521
+ sourceNode: this.arguments[this.arguments.length - 1],
522
+ position: 'insertAfter'
523
+ });
524
+ }
525
+ }
526
+ };
527
+ CallLogic.prototype.toVue = function (options) {
528
+ var code = '';
529
+ if (this.calleeNamespace === 'nasl.browser' || this.calleeNamespace === 'nasl.auth' || this.calleeNamespace === 'nasl.configuration' || this.calleeNamespace === 'nasl.process') {
530
+ code += '$global.';
531
+ }
532
+ code += this.calleeName;
533
+ code += '(';
534
+ var completeArguments = this.completeArguments;
535
+ completeArguments.forEach(function (arg, index) {
536
+ code += arg === null || arg === void 0 ? void 0 : arg.toVue(options);
537
+ if (index !== completeArguments.length - 1)
538
+ code += ', ';
539
+ });
540
+ code += ')';
541
+ return code;
542
+ };
543
+ CallLogic.prototype.toUI = function (state) {
544
+ var _this = this;
545
+ var _a;
546
+ var code = this.calleeName;
547
+ code += '(';
548
+ var node = this.getCallNode();
549
+ var logicParam = [];
550
+ if (node === null || node === void 0 ? void 0 : node.params) {
551
+ logicParam = node.params;
552
+ }
553
+ if ((_a = this.arguments) === null || _a === void 0 ? void 0 : _a.length) {
554
+ this.arguments.forEach(function (arg, index) {
555
+ var _a;
556
+ var param = logicParam[index] || {};
557
+ // 打开了必填,
558
+ // 或者遗留问题,没有required = undefined 而且没有defaultValue,就是之前的必填项
559
+ var paramRequired = Boolean(param.required || (param.required === undefined && !param.defaultValue));
560
+ // 取到是不是必填放入参数中
561
+ if (param && !arg.expression && !paramRequired) {
562
+ // 非必填时 才会有默认值
563
+ code += param.defaultValue;
564
+ }
565
+ else {
566
+ code += arg === null || arg === void 0 ? void 0 : arg.toUI();
567
+ }
568
+ if (index !== ((_a = _this.arguments) === null || _a === void 0 ? void 0 : _a.length) - 1)
569
+ code += ', ';
570
+ });
571
+ }
572
+ code += ')';
573
+ return code;
574
+ };
575
+ Object.defineProperty(CallLogic.prototype, "isViewLogic", {
576
+ // 是否属于页面逻辑
577
+ get: function () {
578
+ // 页面逻辑
579
+ var flag = true;
580
+ var calleeNamespace = this.calleeNamespace;
581
+ // calleeNamespace不存在,一定是页面逻辑
582
+ if (calleeNamespace) {
583
+ var namespaceArr = calleeNamespace.split('.');
584
+ var start = namespaceArr[0];
585
+ var isFrontendLibrary = ~calleeNamespace.indexOf('frontends');
586
+ if (start === 'app' || (start === 'extensions' && !isFrontendLibrary)) {
587
+ var keywordViewsIndex = utils_2.findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'views');
588
+ if (keywordViewsIndex === -1) {
589
+ flag = false;
590
+ }
591
+ }
592
+ }
593
+ return flag;
594
+ },
595
+ enumerable: false,
596
+ configurable: true
597
+ });
598
+ Object.defineProperty(CallLogic.prototype, "isComponentLogic", {
599
+ // 是否属于组件逻辑
600
+ get: function () {
601
+ // 组件逻辑
602
+ var flag = false;
603
+ var calleeNamespace = this.calleeNamespace;
604
+ // calleeNamespace不存在,一定是页面逻辑
605
+ if (calleeNamespace) {
606
+ var namespaceArr = calleeNamespace.split('.');
607
+ var start = namespaceArr[0];
608
+ if (start === 'elements' && namespaceArr.length === 3 && namespaceArr[2] === 'logics') {
609
+ flag = true;
610
+ }
611
+ }
612
+ return flag;
613
+ },
614
+ enumerable: false,
615
+ configurable: true
616
+ });
617
+ CallLogic.prototype.toJS = function (state) {
618
+ var _this = this;
619
+ var _a, _b, _c;
620
+ var code = '';
621
+ code += 'await (';
622
+ var refName = '';
623
+ var extensionName = '';
624
+ var calleeNamespace = this.calleeNamespace;
625
+ var keywordProcessIndex = utils_2.findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'processes');
626
+ var isProcessLogic = keywordProcessIndex !== -1;
627
+ var isFrontendLibrary = calleeNamespace.startsWith('extensions') && calleeNamespace.indexOf('frontends');
628
+ // calleeNamespace不存在,一定是页面逻辑
629
+ if (calleeNamespace) {
630
+ var namespaceArr = calleeNamespace.split('.');
631
+ if (this.isComponentLogic) {
632
+ var componentName = namespaceArr[1];
633
+ var viewElement = (_a = this.view) === null || _a === void 0 ? void 0 : _a.findElementByName(componentName);
634
+ refName = (_b = viewElement === null || viewElement === void 0 ? void 0 : viewElement.refName) !== null && _b !== void 0 ? _b : componentName;
635
+ console.log(componentName);
636
+ console.log(refName);
637
+ }
638
+ if (isFrontendLibrary) {
639
+ extensionName = namespaceArr[1];
640
+ }
641
+ }
642
+ var completeArguments = this.completeArguments;
643
+ // 服务端逻辑
644
+ if (!this.isViewLogic) {
645
+ var logic = utils_1.getNodeByNodeCallee(this.app, this.calleewholeKey, function (key, tempPoint) {
646
+ // 处理 NASL 中未定义的假的节点
647
+ if (key === tempPoint.name) {
648
+ return {
649
+ tempPoint: tempPoint,
650
+ state: 1
651
+ };
652
+ }
653
+ var t = tempPoint[key];
654
+ return {
655
+ tempPoint: t,
656
+ state: Array.isArray(t) ? 2 : 1
657
+ };
658
+ });
659
+ var args = (logic === null || logic === void 0 ? void 0 : logic.params) || [];
660
+ var keywordEntitiesIndex = utils_2.findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'entities');
661
+ code += "this.$logics['" + (this.calleeNamespace ? this.calleeNamespace + "." + this.calleeName : this.calleeName) + "']";
662
+ code += "({\n config: {\n download: false,\n },\n query: {";
663
+ if (isProcessLogic) {
664
+ var argsStr = args
665
+ .map(function (arg, index) {
666
+ var actualArg = completeArguments[index];
667
+ return {
668
+ keyword: arg === null || arg === void 0 ? void 0 : arg.name,
669
+ arg: actualArg
670
+ };
671
+ })
672
+ .map(function (obj) { var _a; return "\n" + (obj === null || obj === void 0 ? void 0 : obj.keyword) + ": " + ((_a = obj === null || obj === void 0 ? void 0 : obj.arg) === null || _a === void 0 ? void 0 : _a.toJS(translator_1.shiftState(state, code))); })
673
+ .join(', ');
674
+ code += argsStr;
675
+ }
676
+ code += "},\n headers: {\n \"lcap-calllogic-uuid\": \"" + this.uuid + "\",\n },\n ";
677
+ if (keywordEntitiesIndex !== -1) {
678
+ var logicArgs = this.arguments;
679
+ var breakBody = false;
680
+ switch (this.calleeName) {
681
+ case 'get':
682
+ case 'delete': {
683
+ logicArgs = [];
684
+ code += "query: {";
685
+ var argsStr = args
686
+ .map(function (arg, index) {
687
+ var _a;
688
+ var actualArg = (_a = _this.arguments) === null || _a === void 0 ? void 0 : _a[index];
689
+ return {
690
+ keyword: arg === null || arg === void 0 ? void 0 : arg.name,
691
+ arg: actualArg
692
+ };
693
+ })
694
+ .map(function (obj) { var _a; return "\n" + (obj === null || obj === void 0 ? void 0 : obj.keyword) + ": " + ((_a = obj === null || obj === void 0 ? void 0 : obj.arg) === null || _a === void 0 ? void 0 : _a.toJS(translator_1.shiftState(state, code))); })
695
+ .join(', ');
696
+ code += argsStr;
697
+ code += "},\n";
698
+ break;
699
+ }
700
+ case 'update':
701
+ case 'createOrUpdate':
702
+ case 'batchUpdate': {
703
+ code += "body: {\n";
704
+ var argsStr = logicArgs
705
+ .filter(function (arg) { return arg.expression; })
706
+ .map(function (arg) {
707
+ var name = arg.keyword === 'body' ? (_this.calleeName === 'batchUpdate' ? 'entities' : 'entity') : arg.keyword;
708
+ return name + ": " + arg.expression.toJS(translator_1.shiftState(state, code));
709
+ })
710
+ .join(',\n');
711
+ code += argsStr;
712
+ code += "},\n";
713
+ logicArgs = [];
714
+ breakBody = true;
715
+ break;
716
+ }
717
+ case 'updateBy': {
718
+ code += "body: {";
719
+ var argsStr = logicArgs
720
+ .filter(function (arg) { return arg.expression; })
721
+ .map(function (arg) {
722
+ var name = arg.keyword === 'body' ? 'entity' : arg.keyword;
723
+ // filter回调函数
724
+ if (arg.expression.returnExpression) {
725
+ var argsStr_1 = JSON.stringify(handleMember(arg.expression.returnExpression)).replace(/"__@@(.*?)@@__"/g, '$1');
726
+ return name + ": {\n concept: 'Function',\n name: 'filter',\n returnExpression: this.$resolveRequestData(" + argsStr_1 + ")\n }";
727
+ }
728
+ else {
729
+ return name + ": " + arg.expression.toJS(translator_1.shiftState(state, code));
730
+ }
731
+ })
732
+ .join(',');
733
+ code += argsStr;
734
+ code += "},\n";
735
+ logicArgs = [];
736
+ breakBody = true;
737
+ break;
738
+ }
739
+ case 'deleteBy': {
740
+ code += "body: ";
741
+ var argsStr = JSON.stringify(handleMember(logicArgs[0].expression.returnExpression)).replace(/"__@@(.*?)@@__"/g, '$1');
742
+ code += "{\n concept: 'Function',\n name: 'filter',\n returnExpression: this.$resolveRequestData(" + argsStr + ")\n }";
743
+ code += ",\n";
744
+ logicArgs = [];
745
+ breakBody = true;
746
+ break;
747
+ }
748
+ }
749
+ var bodyArgument = logicArgs.find(function (arg) { return arg.keyword === 'body'; });
750
+ if (!breakBody) {
751
+ if (bodyArgument) {
752
+ code += "\n" + (bodyArgument === null || bodyArgument === void 0 ? void 0 : bodyArgument.keyword) + ": " + (bodyArgument === null || bodyArgument === void 0 ? void 0 : bodyArgument.toJS(translator_1.shiftState(state, code)));
753
+ }
754
+ else {
755
+ code += "body: {}";
756
+ }
757
+ }
758
+ }
759
+ else {
760
+ code += "path: {},\n body: {";
761
+ if (!isProcessLogic) {
762
+ var argsStr = args
763
+ .map(function (arg, index) {
764
+ var actualArg = completeArguments[index];
765
+ return {
766
+ keyword: arg === null || arg === void 0 ? void 0 : arg.name,
767
+ arg: actualArg
768
+ };
769
+ })
770
+ .map(function (obj) { var _a; return "\n" + (obj === null || obj === void 0 ? void 0 : obj.keyword) + ": " + ((_a = obj === null || obj === void 0 ? void 0 : obj.arg) === null || _a === void 0 ? void 0 : _a.toJS(translator_1.shiftState(state, code))); })
771
+ .join(', ');
772
+ code += argsStr;
773
+ if (Array.isArray(this.typeArguments) && this.typeArguments.length) {
774
+ code += ",\n__typeArguments: " + JSON5.stringify(this.typeArguments);
775
+ }
776
+ }
777
+ code += '\n}';
778
+ }
779
+ code += '\n})';
780
+ }
781
+ else {
782
+ if (this.isComponentLogic) {
783
+ // 组件ref元素的对象没有qu dao的容错
784
+ code += "this.$refs && this.$refs[`" + refName + "`] && this.$refs[`" + refName + "`]." + this.calleeName + " && this.$refs[`" + refName + "`]." + this.calleeName;
785
+ }
786
+ else if (calleeNamespace === 'nasl.ui' || calleeNamespace === 'nasl.util') {
787
+ switch (this.calleeName) {
788
+ case 'showMessage':
789
+ code += "this.$toast.show";
790
+ break;
791
+ case 'consoleLog':
792
+ code += "console.log";
793
+ break;
794
+ case 'jsonSerialize':
795
+ code += "JSON.stringify";
796
+ break;
797
+ case 'jsonDeserialize':
798
+ code += "JSON.parse";
799
+ break;
800
+ }
801
+ }
802
+ else if (calleeNamespace === 'nasl.browser' || calleeNamespace === 'nasl.auth' || calleeNamespace === 'nasl.configuration' || calleeNamespace === 'nasl.process' || calleeNamespace === 'nasl.io') {
803
+ code += "this.$global." + this.calleeName;
804
+ }
805
+ else if (isFrontendLibrary) {
806
+ code += "this.$library['" + extensionName + "']." + this.calleeName;
807
+ }
808
+ else {
809
+ code += "this." + this.calleeName;
810
+ }
811
+ if (calleeNamespace === 'nasl.process' || calleeNamespace === 'nasl.auth') {
812
+ code += '({';
813
+ (_c = this.arguments) === null || _c === void 0 ? void 0 : _c.filter(function (arg) { return arg === null || arg === void 0 ? void 0 : arg.expression; }).forEach(function (arg, index) {
814
+ var _a;
815
+ code += arg.keyword + ": " + (arg === null || arg === void 0 ? void 0 : arg.toJS(translator_1.shiftState(state, code)));
816
+ if (index !== ((_a = _this.arguments) === null || _a === void 0 ? void 0 : _a.length) - 1)
817
+ code += ', ';
818
+ });
819
+ code += '})';
820
+ }
821
+ else {
822
+ code += '(';
823
+ var needToString = ['showMessage', 'consoleLog'].includes(this.calleeName);
824
+ if (needToString) {
825
+ code += "this.$utils['ToString'](";
826
+ }
827
+ if (Array.isArray(completeArguments) && completeArguments.length) {
828
+ completeArguments.forEach(function (arg, index) {
829
+ code += arg === null || arg === void 0 ? void 0 : arg.toJS(translator_1.shiftState(state, code));
830
+ if (index !== (completeArguments === null || completeArguments === void 0 ? void 0 : completeArguments.length) - 1)
831
+ code += ', ';
832
+ });
833
+ if (needToString) {
834
+ var arg = this.arguments[0];
835
+ var argTypeAnnotation = arg.typeAnnotation || arg.__TypeAnnotation;
836
+ if (argTypeAnnotation) {
837
+ code += ", '" + (argTypeAnnotation === null || argTypeAnnotation === void 0 ? void 0 : argTypeAnnotation.sortedTypeKey) + "'";
838
+ }
839
+ }
840
+ }
841
+ if (needToString) {
842
+ code += ")";
843
+ }
844
+ code += ')';
845
+ }
846
+ }
847
+ function handleMember(root) {
848
+ var _a;
849
+ if (!root)
850
+ return;
851
+ if (root.concept === 'Identifier') {
852
+ return {
853
+ concept: root.concept,
854
+ name: root.name,
855
+ value: "__@@" + root.toJS() + "@@__",
856
+ expression: root.toJS()
857
+ };
858
+ }
859
+ if (root.concept === 'MemberExpression') {
860
+ var concept_1 = root.concept;
861
+ var value = root.value;
862
+ if ((root === null || root === void 0 ? void 0 : root.object.name) === '_') {
863
+ return {
864
+ concept: concept_1,
865
+ name: root.name,
866
+ value: value,
867
+ object: root.object,
868
+ property: root.property
869
+ };
870
+ }
871
+ var expression = root.toJS();
872
+ if (((_a = root.object) === null || _a === void 0 ? void 0 : _a.namespace) === 'app.enums') {
873
+ value = expression.replace(/^"(.+)"$/, '$1');
874
+ expression = undefined;
875
+ concept_1 = 'StringLiteral';
876
+ }
877
+ else {
878
+ value = "__@@" + expression + "@@__";
879
+ }
880
+ return {
881
+ concept: concept_1,
882
+ name: root.name,
883
+ value: value,
884
+ expression: expression
885
+ };
886
+ }
887
+ var left;
888
+ if (root.concept === 'UnaryExpression') {
889
+ left = handleMember(root.argument);
890
+ }
891
+ else {
892
+ left = handleMember(root.left);
893
+ }
894
+ var right = handleMember(root.right);
895
+ return {
896
+ concept: root.concept,
897
+ name: root.name,
898
+ value: root.value,
899
+ expression: root.expression,
900
+ operator: root.operator,
901
+ left: left,
902
+ right: right
903
+ };
904
+ }
905
+ var typeAnnotation = this.typeAnnotation || this.__TypeAnnotation;
906
+ var needGenInitFromSchema = typeAnnotation && (!['primitive', 'union'].includes(typeAnnotation.typeKind)
907
+ || typeAnnotation.typeName === 'DateTime');
908
+ if (needGenInitFromSchema) {
909
+ code = "this.$genInitFromSchema('" + (typeAnnotation === null || typeAnnotation === void 0 ? void 0 : typeAnnotation.sortedTypeKey) + "', " + code + ")";
910
+ }
911
+ code += ')';
912
+ return code;
913
+ };
914
+ CallLogic.prototype.toBrief = function () {
915
+ return this.arguments.map(function (a) { return a.toBrief(); }).join('<br />');
916
+ };
917
+ CallLogic.prototype.toEmbeddedTS = function (state) {
918
+ var code = '';
919
+ var _a = this, handleError = _a.handleError, calleeKey = _a.calleeKey, calleeName = _a.calleeName, parentKey = _a.parentKey, typeArguments = _a.typeArguments, tsCalleeNamespace = _a.tsCalleeNamespace, completeArguments = _a.completeArguments, parentNode = _a.parentNode, validation = _a.validation, logicArgs = _a.arguments;
920
+ var useValidation = (config_1.config.viewCallLogicValidation === 2 &&
921
+ Boolean(validation));
922
+ /** 设置函数范型参数 */
923
+ var setTypeArguments = function () {
924
+ if (Array.isArray(typeArguments) && typeArguments.length) {
925
+ // 如果有内容
926
+ code += "<";
927
+ typeArguments.forEach(function (arg, i, arr) {
928
+ code += arg.toEmbeddedTS(translator_1.shiftState(state, code, { tabSize: 0 }));
929
+ if (i !== arr.length - 1) {
930
+ code += ', ';
931
+ }
932
+ });
933
+ code += ">";
934
+ }
935
+ };
936
+ /** 设置输入参数 */
937
+ var setInputParam = function () {
938
+ var paramRequired = ['showMessage', 'consoleLog'].includes(calleeName);
939
+ if ((tsCalleeNamespace.startsWith('elements') && tsCalleeNamespace.endsWith('logics')) || tsCalleeNamespace.startsWith('nasl.')) {
940
+ code += '(';
941
+ logicArgs.forEach(function (arg, index) {
942
+ // 页面逻辑先都非必填
943
+ code += arg.toEmbeddedTS(translator_1.shiftState(state, code), paramRequired);
944
+ if (index !== logicArgs.length - 1)
945
+ code += ', ';
946
+ });
947
+ code += ')';
948
+ }
949
+ else {
950
+ if (completeArguments.length) {
951
+ code += '(';
952
+ completeArguments.forEach(function (arg, index) {
953
+ // 取到是不是必填放入参数中
954
+ code += arg.toEmbeddedTS(translator_1.shiftState(state, code), arg === null || arg === void 0 ? void 0 : arg.paramRequired);
955
+ if (index !== logicArgs.length - 1)
956
+ code += ', ';
957
+ });
958
+ code += ')';
959
+ }
960
+ else {
961
+ code += '()';
962
+ }
963
+ }
964
+ };
965
+ /** 设置表达式末尾分号 */
966
+ var setEndSemi = function () {
967
+ var parentConcept = parentNode.concept;
968
+ if (!['test', 'patterns', 'returnExpression'].includes(parentKey) &&
969
+ ![
970
+ 'Argument',
971
+ 'Assignment',
972
+ 'ForEachStatement',
973
+ 'SelectMembers',
974
+ 'UnaryExpression',
975
+ 'BinaryExpression',
976
+ 'StringInterpolation',
977
+ 'MemberExpression',
978
+ 'NewMap',
979
+ 'NewList',
980
+ ].includes(parentConcept)) {
981
+ code += ';';
982
+ }
983
+ };
984
+ /** 使用立即执行函数包裹 */
985
+ var useIife = Boolean(handleError || useValidation);
986
+ if (useIife) {
987
+ code += '(() =>{\nconst wrapper = ';
988
+ if (handleError) {
989
+ code += 'nasl.util.autoHandleError(';
990
+ }
991
+ if (useValidation) {
992
+ code += 'nasl.util.callLogicWithChecker(';
993
+ }
994
+ code += calleeKey;
995
+ setTypeArguments();
996
+ if (useValidation) {
997
+ code += ', (';
998
+ code += completeArguments.map(function (item) { return item.keyword; }).join(', ');
999
+ code += ') => {\n';
1000
+ code += validation.toEmbeddedTS(translator_1.shiftState(state, code));
1001
+ code += ';\n})';
1002
+ }
1003
+ if (handleError) {
1004
+ code += ')';
1005
+ }
1006
+ code += ';\nreturn wrapper';
1007
+ setInputParam();
1008
+ code += ';\n})()';
1009
+ }
1010
+ else {
1011
+ code += calleeKey;
1012
+ setTypeArguments();
1013
+ setInputParam();
1014
+ }
1015
+ setEndSemi();
1016
+ return code;
1017
+ };
1018
+ // 通过内容过去节点
1019
+ CallLogic.prototype.getCallNode = function () {
1020
+ var _this = this;
1021
+ var _a;
1022
+ var node;
1023
+ // 如果是页面局部逻辑
1024
+ if (!this.calleeNamespace && this.calleeName && this.view) {
1025
+ node = this.view.logics.find(function (l) { return l.name === _this.calleeName; });
1026
+ }
1027
+ else if ((_a = this.calleeNamespace) === null || _a === void 0 ? void 0 : _a.startsWith('nasl.')) {
1028
+ // 如果是平台类型
1029
+ node = utils_1.getNaslNodeByNodeCallee(this.calleeNamespace, this.calleeName);
1030
+ }
1031
+ else {
1032
+ // 如果是其余app下自定义逻辑
1033
+ try {
1034
+ node = utils_1.getNodeByNodeCallee(this.app, this.calleewholeKey, function (key, tempPoint) {
1035
+ // 处理 NASL 中未定义的假的节点
1036
+ if (key === tempPoint.name) {
1037
+ return {
1038
+ tempPoint: tempPoint,
1039
+ state: 1
1040
+ };
1041
+ }
1042
+ var t = tempPoint[key];
1043
+ return {
1044
+ tempPoint: t,
1045
+ state: Array.isArray(t) ? 2 : 1
1046
+ };
1047
+ });
1048
+ }
1049
+ catch (err) { }
1050
+ }
1051
+ return node;
1052
+ };
1053
+ /**
1054
+ * 是否允许验证规则
1055
+ * - 当前元素在前端,但是调用的函数在后端
1056
+ */
1057
+ CallLogic.prototype.enableValidation = function () {
1058
+ var calledLogic = this.getCallNode();
1059
+ return Boolean(this.view) && calledLogic && !calledLogic.view;
1060
+ };
1061
+ Object.defineProperty(CallLogic.prototype, "completeArguments", {
1062
+ // 可以设置默认值的节点
1063
+ // 目前只开放了app下的,所以这些节点,查找引用吧默认值塞回来
1064
+ get: function () {
1065
+ var _a;
1066
+ var node = this.getCallNode();
1067
+ var logicParam = [];
1068
+ var Arguments = [];
1069
+ if (node === null || node === void 0 ? void 0 : node.params) {
1070
+ logicParam = node.params;
1071
+ }
1072
+ if ((_a = this.arguments) === null || _a === void 0 ? void 0 : _a.length) {
1073
+ this.arguments.forEach(function (arg, index) {
1074
+ var param = logicParam[index] || {};
1075
+ // 打开了必填,
1076
+ // 或者遗留问题,没有required = undefined 而且没有defaultValue,就是之前的必填项
1077
+ arg.paramRequired = Boolean(param.required || (param.required === undefined && !param.defaultValue));
1078
+ arg.paramTypeAnnotation = undefined;
1079
+ arg.paramDefaultValue = undefined;
1080
+ arg.keyword = param.name;
1081
+ // 取到是不是必填放入参数中
1082
+ if (param && !arg.expression) {
1083
+ // 非必填时 才会有默认值
1084
+ arg.paramTypeAnnotation = param.typeAnnotation;
1085
+ arg.paramDefaultValue = param.defaultValue;
1086
+ }
1087
+ Arguments.push(arg);
1088
+ });
1089
+ }
1090
+ return Arguments;
1091
+ },
1092
+ enumerable: false,
1093
+ configurable: true
1094
+ });
1095
+ CallLogic.isSystem = function (node) {
1096
+ return ['nasl.process', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.io'].includes(node === null || node === void 0 ? void 0 : node.calleeNamespace);
1097
+ };
1098
+ CallLogic.getDefaultOptions = function () {
1099
+ return {};
1100
+ };
1101
+ var CallLogic_1;
1102
+ __decorate([
1103
+ decorators_1.property()
1104
+ ], CallLogic.prototype, "uuid");
1105
+ __decorate([
1106
+ decorators_1.property()
1107
+ ], CallLogic.prototype, "concept");
1108
+ __decorate([
1109
+ decorators_1.property()
1110
+ ], CallLogic.prototype, "label");
1111
+ __decorate([
1112
+ decorators_1.property()
1113
+ ], CallLogic.prototype, "calleeNamespace");
1114
+ __decorate([
1115
+ decorators_1.property()
1116
+ ], CallLogic.prototype, "calleeName");
1117
+ __decorate([
1118
+ decorators_1.property()
1119
+ ], CallLogic.prototype, "shortcut");
1120
+ __decorate([
1121
+ decorators_1.property()
1122
+ ], CallLogic.prototype, "handleError");
1123
+ __decorate([
1124
+ decorators_1.property('TypeAnnotation')
1125
+ ], CallLogic.prototype, "typeArguments");
1126
+ __decorate([
1127
+ decorators_1.property('Argument')
1128
+ ], CallLogic.prototype, "arguments");
1129
+ __decorate([
1130
+ decorators_1.property('BindAttribute')
1131
+ ], CallLogic.prototype, "validation");
1132
+ __decorate([
1133
+ decorators_1.property()
1134
+ ], CallLogic.prototype, "isAdvancedSettingFolded");
1135
+ __decorate([
1136
+ translator_1.withSourceMap()
1137
+ ], CallLogic.prototype, "toEmbeddedTS");
1138
+ CallLogic = CallLogic_1 = __decorate([
1139
+ decorators_1.concept('调用逻辑')
1140
+ ], CallLogic);
1141
+ return CallLogic;
1142
+ }(LogicItem__1["default"]));
1143
+ exports.CallLogic = CallLogic;
1144
+ classMap_1["default"].CallLogic = CallLogic;
1145
+ exports["default"] = CallLogic;
1146
+ //================================================================================
1147
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1148
+ // 自动生成的代码已结束。下面可以手动编写。
1149
+ //================================================================================