@lcap/nasl 2.19.0-beta.1 → 2.19.0-beta.3

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 (178) hide show
  1. package/out/common/BaseNode.js +4 -1
  2. package/out/common/BaseNode.js.map +1 -1
  3. package/out/concepts/Abort__.d.ts +25 -0
  4. package/out/concepts/Abort__.js +80 -0
  5. package/out/concepts/Abort__.js.map +1 -0
  6. package/out/concepts/App__.js.map +1 -1
  7. package/out/concepts/BatchAssignment__.js +3 -3
  8. package/out/concepts/BatchAssignment__.js.map +1 -1
  9. package/out/concepts/CallFunction__.js +23 -7
  10. package/out/concepts/CallFunction__.js.map +1 -1
  11. package/out/concepts/CallInterface__.js +1 -1
  12. package/out/concepts/CallInterface__.js.map +1 -1
  13. package/out/concepts/CallLogic__.js +9 -65
  14. package/out/concepts/CallLogic__.js.map +1 -1
  15. package/out/concepts/DatabaseTypeAnnotation__.d.ts +31 -0
  16. package/out/concepts/DatabaseTypeAnnotation__.js +78 -0
  17. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -0
  18. package/out/concepts/EnumItem__.d.ts +5 -5
  19. package/out/concepts/EnumItem__.js +6 -6
  20. package/out/concepts/Enum__.d.ts +20 -19
  21. package/out/concepts/Enum__.js +28 -1
  22. package/out/concepts/Enum__.js.map +1 -1
  23. package/out/concepts/ForEachStatement__.js +1 -1
  24. package/out/concepts/ForEachStatement__.js.map +1 -1
  25. package/out/concepts/FrontendLibrary__.d.ts +213 -0
  26. package/out/concepts/FrontendLibrary__.js +352 -0
  27. package/out/concepts/FrontendLibrary__.js.map +1 -0
  28. package/out/concepts/Frontend__.d.ts +373 -0
  29. package/out/concepts/Frontend__.js +685 -0
  30. package/out/concepts/Frontend__.js.map +1 -0
  31. package/out/concepts/Integration__.d.ts +53 -0
  32. package/out/concepts/Integration__.js +143 -0
  33. package/out/concepts/Integration__.js.map +1 -0
  34. package/out/concepts/JavaLogic__.d.ts +42 -0
  35. package/out/concepts/JavaLogic__.js +122 -0
  36. package/out/concepts/JavaLogic__.js.map +1 -0
  37. package/out/concepts/Logic__.js +3 -0
  38. package/out/concepts/Logic__.js.map +1 -1
  39. package/out/concepts/MicroApp__.d.ts +51 -0
  40. package/out/concepts/MicroApp__.js +113 -0
  41. package/out/concepts/MicroApp__.js.map +1 -0
  42. package/out/concepts/NewComposite__.js +14 -14
  43. package/out/concepts/NewComposite__.js.map +1 -1
  44. package/out/concepts/NewList__.d.ts +1 -0
  45. package/out/concepts/NewList__.js +17 -1
  46. package/out/concepts/NewList__.js.map +1 -1
  47. package/out/concepts/NewMap__.d.ts +1 -0
  48. package/out/concepts/NewMap__.js +18 -1
  49. package/out/concepts/NewMap__.js.map +1 -1
  50. package/out/concepts/OqlQueryComponent__.js +2 -0
  51. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  52. package/out/concepts/StringInterpolation__.js +2 -0
  53. package/out/concepts/StringInterpolation__.js.map +1 -1
  54. package/out/concepts/TypeAnnotation__.js +3 -3
  55. package/out/concepts/TypeAnnotation__.js.map +1 -1
  56. package/out/concepts/ViewBlock__.d.ts +35 -0
  57. package/out/concepts/ViewBlock__.js +85 -0
  58. package/out/concepts/ViewBlock__.js.map +1 -0
  59. package/out/concepts/ViewElement__.js +1 -1
  60. package/out/concepts/ViewElement__.js.map +1 -1
  61. package/out/concepts/View__.js +1 -0
  62. package/out/concepts/View__.js.map +1 -1
  63. package/out/concepts/basics/stdlib/nasl.util.js +4 -2
  64. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  65. package/out/generator/genBundleFiles.js +10 -1
  66. package/out/generator/genBundleFiles.js.map +1 -1
  67. package/out/generator/genReleaseBody.js +3 -0
  68. package/out/generator/genReleaseBody.js.map +1 -1
  69. package/out/generator/icestark.d.ts +2 -0
  70. package/out/generator/icestark.js +48 -0
  71. package/out/generator/icestark.js.map +1 -0
  72. package/out/generator/microApp.d.ts +2 -0
  73. package/out/generator/microApp.js +35 -0
  74. package/out/generator/microApp.js.map +1 -0
  75. package/out/generator/qiankun.d.ts +2 -0
  76. package/out/generator/qiankun.js +52 -0
  77. package/out/generator/qiankun.js.map +1 -0
  78. package/out/manager/stepRecorder.d.ts +20 -0
  79. package/out/manager/stepRecorder.js +110 -0
  80. package/out/manager/stepRecorder.js.map +1 -0
  81. package/out/sentry/index.d.ts +29 -0
  82. package/out/sentry/index.js +111 -0
  83. package/out/sentry/index.js.map +1 -0
  84. package/out/server/extendBaseNode.js +5 -1
  85. package/out/server/extendBaseNode.js.map +1 -1
  86. package/out/server/formatTsUtils.js +11 -8
  87. package/out/server/formatTsUtils.js.map +1 -1
  88. package/out/server/naslServer.js +118 -9
  89. package/out/server/naslServer.js.map +1 -1
  90. package/out/server/translator.js +43 -10
  91. package/out/server/translator.js.map +1 -1
  92. package/out/service/creator/add.configs.js +2 -0
  93. package/out/service/creator/add.configs.js.map +1 -1
  94. package/out/service/creator/errHandles.js +5 -0
  95. package/out/service/creator/errHandles.js.map +1 -1
  96. package/out/service/creator/index.js +2 -0
  97. package/out/service/creator/index.js.map +1 -1
  98. package/out/service/storage/api.d.ts +18 -0
  99. package/out/service/storage/api.js +12 -0
  100. package/out/service/storage/api.js.map +1 -1
  101. package/out/service/storage/init.d.ts +41 -1
  102. package/out/service/storage/init.js +175 -30
  103. package/out/service/storage/init.js.map +1 -1
  104. package/out/service/storage/service.d.ts +9 -1
  105. package/out/service/storage/service.js +27 -1
  106. package/out/service/storage/service.js.map +1 -1
  107. package/out/templator/genGetBlock.js +1 -1
  108. package/out/templator/genGetBlock.js.map +1 -1
  109. package/out/templator/genListViewBlock.js +6 -0
  110. package/out/templator/genListViewBlock.js.map +1 -1
  111. package/package.json +2 -2
  112. package/sandbox/stdlib/nasl.core.ts +2 -0
  113. package/sandbox/stdlib/nasl.oql.ts +16 -4
  114. package/sandbox/stdlib/nasl.util.ts +2 -1
  115. package/src/common/BaseNode.ts +3 -1
  116. package/src/concepts/App__.ts +41 -1
  117. package/src/concepts/BatchAssignment__.ts +3 -3
  118. package/src/concepts/CallFunction__.ts +34 -20
  119. package/src/concepts/CallInterface__.ts +19 -1
  120. package/src/concepts/CallLogic__.ts +8 -65
  121. package/src/concepts/EnumItem__.ts +6 -6
  122. package/src/concepts/Enum__.ts +22 -19
  123. package/src/concepts/ForEachStatement__.ts +1 -1
  124. package/src/concepts/Logic__.ts +13 -10
  125. package/src/concepts/NewComposite__.ts +14 -14
  126. package/src/concepts/NewList__.ts +18 -1
  127. package/src/concepts/NewMap__.ts +19 -1
  128. package/src/concepts/OqlQueryComponent__.ts +2 -0
  129. package/src/concepts/StringInterpolation__.ts +6 -4
  130. package/src/concepts/TypeAnnotation__.ts +41 -3
  131. package/src/concepts/ViewElement__.ts +1 -1
  132. package/src/concepts/View__.ts +3 -2
  133. package/src/concepts/basics/stdlib/nasl.util.ts +4 -2
  134. package/src/generator/genBundleFiles.ts +10 -1
  135. package/src/generator/genReleaseBody.ts +3 -1
  136. package/src/server/extendBaseNode.ts +4 -1
  137. package/src/server/formatTsUtils.ts +11 -8
  138. package/src/server/naslServer.ts +124 -11
  139. package/src/server/translator.ts +37 -10
  140. package/src/service/creator/add.configs.js +3 -0
  141. package/src/service/creator/errHandles.js +6 -0
  142. package/src/service/creator/index.js +3 -0
  143. package/src/service/storage/api.js +12 -0
  144. package/src/service/storage/init.ts +207 -29
  145. package/src/service/storage/service.ts +29 -1
  146. package/src/templator/genGetBlock.ts +1 -1
  147. package/src/templator/genListViewBlock.ts +6 -0
  148. package/ts-worker/lib/tsserver.js +10 -2
  149. package/ts-worker/package.json +1 -0
  150. package/ts-worker/webpack.config.js +11 -2
  151. package/sandbox/stdlib/dist/nasl.logging.js +0 -0
  152. package/sandbox/stdlib/dist/nasl.util.js +0 -0
  153. package/src/automate/engine/dist/index.dev.js +0 -517
  154. package/src/common/dist/BaseNode.js +0 -1101
  155. package/src/concepts/basics/stdlib/dist/nasl.util.js +0 -1602
  156. package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +0 -24
  157. package/src/concepts/dist/BindAttribute__.js +0 -760
  158. package/src/concepts/dist/BindEvent__.js +0 -732
  159. package/src/concepts/dist/CallFunction__.js +0 -527
  160. package/src/concepts/dist/CallLogic__.js +0 -932
  161. package/src/concepts/dist/Identifier__.js +0 -311
  162. package/src/concepts/dist/StringInterpolation__.js +0 -231
  163. package/src/concepts/dist/TypeAnnotation__.js +0 -834
  164. package/src/concepts/dist/ViewElement__.js +0 -1692
  165. package/src/concepts/dist/View__.js +0 -1601
  166. package/src/generator/dist/genBundleFiles.js +0 -261
  167. package/src/generator/dist/genMetaData.js +0 -245
  168. package/src/generator/dist/permission.js +0 -392
  169. package/src/server/dist/naslServer.js +0 -3590
  170. package/src/service/storage/dist/init.js +0 -579
  171. package/src/templator/dist/genEditTableBlock.js +0 -204
  172. package/src/templator/dist/genGridViewBlock.js +0 -265
  173. package/src/templator/dist/genListViewBlock.js +0 -84
  174. package/src/templator/dist/genTableBlock.js +0 -209
  175. package/src/templator/dist/utils.js +0 -527
  176. package/ts-worker/dist/webpack.config.dev.js +0 -106
  177. /package/src/service/{dataSource → datasource}/api.js +0 -0
  178. /package/src/service/{dataSource → datasource}/index.js +0 -0
@@ -61,6 +61,8 @@ export class CallInterface extends LogicItem {
61
61
  @property('Argument')
62
62
  arguments: Array<Argument> = [];
63
63
 
64
+
65
+
64
66
  /**
65
67
  * @param source 需要合并的部分参数
66
68
  */
@@ -74,6 +76,13 @@ export class CallInterface extends LogicItem {
74
76
  return super.from(source, parentNode, parentKey) as CallInterface;
75
77
  }
76
78
 
79
+
80
+
81
+
82
+
83
+
84
+
85
+
77
86
  /**
78
87
  * 插入实际参数
79
88
  * @internal
@@ -106,6 +115,8 @@ export class CallInterface extends LogicItem {
106
115
  return argument;
107
116
  }
108
117
 
118
+
119
+
109
120
  /**
110
121
  * 插入实际参数
111
122
  * @param argumentOptions 实际参数参数
@@ -128,6 +139,8 @@ export class CallInterface extends LogicItem {
128
139
  return node;
129
140
  }
130
141
 
142
+
143
+
131
144
  /**
132
145
  * 添加实际参数
133
146
  * @internal
@@ -147,6 +160,8 @@ export class CallInterface extends LogicItem {
147
160
  return this._insertArgumentAt(options as any, index);
148
161
  }
149
162
 
163
+
164
+
150
165
  /**
151
166
  * 添加实际参数
152
167
  * @param argumentOptions 实际参数参数
@@ -170,6 +185,9 @@ export class CallInterface extends LogicItem {
170
185
  return node;
171
186
  }
172
187
 
188
+
189
+
190
+
173
191
  /**
174
192
  * 删除实际参数
175
193
  * @param argument 已有的实际参数实例
@@ -177,7 +195,7 @@ export class CallInterface extends LogicItem {
177
195
  removeArgument(argument: Argument): void;
178
196
 
179
197
  removeArgument(options: Argument) {
180
- const argument: Argument = options;
198
+ let argument: Argument = options;
181
199
  return argument.delete();
182
200
  }
183
201
 
@@ -608,68 +608,6 @@ export class CallLogic extends LogicItem {
608
608
 
609
609
  toJS(state?: TranslatorState): string {
610
610
  let code = '';
611
- if (this.calleeName === 'deleteBy' || this.calleeName === 'updateBy') {
612
- code += `
613
- var __resolveData = __resolveData || ((root) => {
614
- if (!root)
615
- return
616
- // console.log(root.concept)
617
- delete root.folded
618
-
619
- if (root.concept === 'NumericLiteral') {
620
- root.value = root.value
621
- } else if (root.concept === "StringLiteral") {
622
- root.value = root.value
623
- } else if (root.concept === "NullLiteral") {
624
- delete root.value
625
- } else if (root.concept === "BooleanLiteral") {
626
- root.value = root.value === 'true'
627
- } else if (root.concept === "Identifier") {
628
- __parseType(root, 'expression')
629
- } else if (root.concept === "MemberExpression") {
630
- if (root.expression) {
631
- __parseType(root, 'expression')
632
-
633
- }
634
- }
635
-
636
- __resolveData(root.left)
637
- __resolveData(root.right)
638
- return root
639
- })
640
-
641
- var __parseType = __parseType || ((root, prop) => {
642
- const value = eval(root[prop])
643
- const type = typeof value
644
- // console.log('type:', type, value)
645
- if (type === 'number') {
646
- root.concept = 'NumericLiteral'
647
- root.value = value + ''
648
- } else if (type === 'string') {
649
- root.concept = 'StringLiteral'
650
- root.value = value
651
- } else if (type === 'boolean') {
652
- root.concept = 'BooleanLiteral'
653
- root.value = value
654
- } else if (type === 'object') {
655
- if (Array.isArray(value)) {
656
- var itemValue = value[0]
657
- if(itemValue !== undefined) {
658
- var itemType = typeof itemValue
659
- root.concept = 'ListLiteral'
660
- if (itemType === 'number') {
661
- root.value = value.map(v => v + '').join(',')
662
- } else if (itemType === 'string') {
663
- root.value = value.map(v => "'" + v + "'").join(',')
664
- } else if (itemType === 'boolean') {
665
- root.value = value.join(',')
666
- }
667
- }
668
- }
669
- }
670
- })
671
- `;
672
- }
673
611
  code += 'await ';
674
612
  // 页面逻辑
675
613
  let isViewLogic = true;
@@ -790,7 +728,7 @@ var __parseType = __parseType || ((root, prop) => {
790
728
  return `${name}: {
791
729
  concept: 'Function',
792
730
  name: 'filter',
793
- returnExpression: __resolveData(${argsStr})
731
+ returnExpression: this.$resolveRequestData(${argsStr}, __eventArg, __currentArg)
794
732
  }`;
795
733
  } else {
796
734
  return `${name}: ${arg.expression.toJS(shiftState(state, code))}`;
@@ -809,7 +747,7 @@ var __parseType = __parseType || ((root, prop) => {
809
747
  code += `{
810
748
  concept: 'Function',
811
749
  name: 'filter',
812
- returnExpression: __resolveData(${argsStr})
750
+ returnExpression: this.$resolveRequestData(${argsStr}, __eventArg, __currentArg)
813
751
  }`;
814
752
  code += `,\n`;
815
753
  logicArgs = [];
@@ -943,7 +881,12 @@ var __parseType = __parseType || ((root, prop) => {
943
881
  };
944
882
  }
945
883
 
946
- const left = handleMember(root.left);
884
+ let left;
885
+ if (root.concept === 'UnaryExpression') {
886
+ left = handleMember(root.argument);
887
+ } else {
888
+ left = handleMember(root.left);
889
+ }
947
890
  const right = handleMember(root.right);
948
891
  return {
949
892
  concept: root.concept,
@@ -15,9 +15,9 @@ import Module from './Module__';
15
15
  import App from './App__';
16
16
 
17
17
  /**
18
- * 枚举项
18
+ * 枚举值
19
19
  */
20
- @concept('枚举项')
20
+ @concept('枚举值')
21
21
  export class EnumItem extends BaseNode {
22
22
  /**
23
23
  * 产品概念
@@ -26,13 +26,13 @@ export class EnumItem extends BaseNode {
26
26
  concept: 'EnumItem' = 'EnumItem';
27
27
 
28
28
  /**
29
- * 枚举项的值
29
+ * 枚举值的值
30
30
  */
31
31
  @property()
32
32
  value: string = undefined;
33
33
 
34
34
  /**
35
- * 枚举项标题
35
+ * 枚举值标题
36
36
  */
37
37
  @property()
38
38
  label: string = undefined;
@@ -81,7 +81,7 @@ export class EnumItem extends BaseNode {
81
81
  return params;
82
82
  }
83
83
  /**
84
- * 设置枚举项的值
84
+ * 设置枚举值的值
85
85
  */
86
86
  setValue(value: string) {
87
87
  const object = {
@@ -93,7 +93,7 @@ export class EnumItem extends BaseNode {
93
93
  }
94
94
 
95
95
  /**
96
- * 设置枚举项标题
96
+ * 设置枚举值标题
97
97
  */
98
98
  setLabel(label: string) {
99
99
  const object = {
@@ -46,7 +46,7 @@ export class Enum extends BaseNode {
46
46
  description: string = undefined;
47
47
 
48
48
  /**
49
- * 枚举项列表
49
+ * 枚举值列表
50
50
  */
51
51
  @property('EnumItem')
52
52
  enumItems: Array<EnumItem> = [];
@@ -130,16 +130,16 @@ export class Enum extends BaseNode {
130
130
 
131
131
 
132
132
  /**
133
- * 插入枚举项
133
+ * 插入枚举值
134
134
  * @internal
135
- * @param enumItemOptions 枚举项参数
135
+ * @param enumItemOptions 枚举值参数
136
136
  */
137
137
  _insertEnumItemAt(enumItemOptions: Partial<EnumItem>, index: number): EnumItem;
138
138
 
139
139
  /**
140
- * 插入枚举项
140
+ * 插入枚举值
141
141
  * @internal
142
- * @param enumItem 已有的枚举项实例
142
+ * @param enumItem 已有的枚举值实例
143
143
  */
144
144
  _insertEnumItemAt(enumItem: EnumItem, index: number): EnumItem;
145
145
 
@@ -164,14 +164,14 @@ export class Enum extends BaseNode {
164
164
 
165
165
 
166
166
  /**
167
- * 插入枚举项
168
- * @param enumItemOptions 枚举项参数
167
+ * 插入枚举值
168
+ * @param enumItemOptions 枚举值参数
169
169
  */
170
170
  insertEnumItemAt(enumItemOptions: Partial<EnumItem>, index: number): EnumItem;
171
171
 
172
172
  /**
173
- * 插入枚举项
174
- * @param enumItem 已有的枚举项实例
173
+ * 插入枚举值
174
+ * @param enumItem 已有的枚举值实例
175
175
  */
176
176
  insertEnumItemAt(enumItem: EnumItem, index: number): EnumItem;
177
177
 
@@ -188,16 +188,16 @@ export class Enum extends BaseNode {
188
188
 
189
189
 
190
190
  /**
191
- * 添加枚举项
191
+ * 添加枚举值
192
192
  * @internal
193
- * @param enumItemOptions 枚举项参数
193
+ * @param enumItemOptions 枚举值参数
194
194
  */
195
195
  _addEnumItem(enumItemOptions: Partial<EnumItem>): EnumItem;
196
196
 
197
197
  /**
198
- * 添加枚举项
198
+ * 添加枚举值
199
199
  * @internal
200
- * @param enumItem 已有的枚举项实例
200
+ * @param enumItem 已有的枚举值实例
201
201
  */
202
202
  _addEnumItem(enumItem: EnumItem): EnumItem;
203
203
 
@@ -209,14 +209,14 @@ export class Enum extends BaseNode {
209
209
 
210
210
 
211
211
  /**
212
- * 添加枚举项
213
- * @param enumItemOptions 枚举项参数
212
+ * 添加枚举值
213
+ * @param enumItemOptions 枚举值参数
214
214
  */
215
215
  addEnumItem(enumItemOptions: Partial<EnumItem>): EnumItem;
216
216
 
217
217
  /**
218
- * 添加枚举项
219
- * @param enumItem 已有的枚举项实例
218
+ * 添加枚举值
219
+ * @param enumItem 已有的枚举值实例
220
220
  */
221
221
  addEnumItem(enumItem: EnumItem): EnumItem;
222
222
 
@@ -235,8 +235,8 @@ export class Enum extends BaseNode {
235
235
 
236
236
 
237
237
  /**
238
- * 删除枚举项
239
- * @param enumItem 已有的枚举项实例
238
+ * 删除枚举值
239
+ * @param enumItem 已有的枚举值实例
240
240
  */
241
241
  removeEnumItem(enumItem: EnumItem): void;
242
242
 
@@ -290,6 +290,9 @@ export class Enum extends BaseNode {
290
290
  const excludedSet = new Set(excludedList);
291
291
  return (this.enumItems || []).filter((item) => !excludedSet.has(item)).map((item) => item.value);
292
292
  }
293
+ getEnumItemUniqueName(name = 'VALUE1') {
294
+ return utils.unique(name, this.getEnumItemExistingNames(), undefined, false);
295
+ }
293
296
 
294
297
  @withSourceMap()
295
298
  toEmbeddedTS(state?: TranslatorState): string {
@@ -531,7 +531,7 @@ export class ForEachStatement extends LogicItem {
531
531
  code += this.each ? this.each.toEmbeddedTS(shiftState(state, code, {
532
532
  tabSize: 0,
533
533
  })) : '__IDENTIFIER__';
534
- if (['NewList', 'NewMap'].includes(this.each.concept))
534
+ if (['NewList', 'NewMap'].includes(this.each?.concept))
535
535
  code += '\n';
536
536
  code += '.__slice(';
537
537
  code += this.start ? this.start.toEmbeddedTS(shiftState(state, code)) : '__IDENTIFIER__';
@@ -796,7 +796,7 @@ export class Logic extends BaseNode {
796
796
 
797
797
 
798
798
 
799
-
799
+
800
800
 
801
801
  /**
802
802
  * 插入逻辑项
@@ -830,7 +830,7 @@ export class Logic extends BaseNode {
830
830
  return logicItem;
831
831
  }
832
832
 
833
-
833
+
834
834
 
835
835
  /**
836
836
  * 插入逻辑项
@@ -854,7 +854,7 @@ export class Logic extends BaseNode {
854
854
  return node;
855
855
  }
856
856
 
857
-
857
+
858
858
 
859
859
  /**
860
860
  * 添加逻辑项
@@ -875,7 +875,7 @@ export class Logic extends BaseNode {
875
875
  return this._insertItemInBodyAt(options as any, index);
876
876
  }
877
877
 
878
-
878
+
879
879
 
880
880
  /**
881
881
  * 添加逻辑项
@@ -900,7 +900,7 @@ export class Logic extends BaseNode {
900
900
  return node;
901
901
  }
902
902
 
903
-
903
+
904
904
 
905
905
  /**
906
906
  * 插入逻辑项
@@ -934,7 +934,7 @@ export class Logic extends BaseNode {
934
934
  return logicItem;
935
935
  }
936
936
 
937
-
937
+
938
938
 
939
939
  /**
940
940
  * 插入逻辑项
@@ -958,7 +958,7 @@ export class Logic extends BaseNode {
958
958
  return node;
959
959
  }
960
960
 
961
-
961
+
962
962
 
963
963
  /**
964
964
  * 添加逻辑项
@@ -979,7 +979,7 @@ export class Logic extends BaseNode {
979
979
  return this._insertItemInPlaygroundAt(options as any, index);
980
980
  }
981
981
 
982
-
982
+
983
983
 
984
984
  /**
985
985
  * 添加逻辑项
@@ -1005,7 +1005,7 @@ export class Logic extends BaseNode {
1005
1005
  }
1006
1006
 
1007
1007
 
1008
-
1008
+
1009
1009
 
1010
1010
  /**
1011
1011
  * 删除事务
@@ -1268,7 +1268,7 @@ export class Logic extends BaseNode {
1268
1268
  return logicItem.delete();
1269
1269
  }
1270
1270
 
1271
-
1271
+
1272
1272
 
1273
1273
  /**
1274
1274
  * 删除逻辑项
@@ -1390,6 +1390,8 @@ export class Logic extends BaseNode {
1390
1390
  }
1391
1391
 
1392
1392
  toJSContent(code: string, state?: TranslatorState): string {
1393
+ // 兼容前端事件逻辑参数中的 current event,deleteBy updateBy 需要对 current、event 进行预处理
1394
+ code += `var __currentArg;var __eventArg;try {__currentArg = current;__eventArg = event;} catch(e) {}`;
1393
1395
  // params
1394
1396
  if (Array.isArray(this.params)) {
1395
1397
  this.params.forEach((param) => {
@@ -1778,6 +1780,7 @@ export class Logic extends BaseNode {
1778
1780
  }
1779
1781
 
1780
1782
  getRightCode(code: string, assignment: Assignment | BatchAssignment, rightNode: any): string {
1783
+ code = code.replaceAll('\n', ' ');
1781
1784
  if (assignment instanceof Assignment && !assignment.right)
1782
1785
  return code;
1783
1786
 
@@ -823,16 +823,13 @@ export class NewComposite extends LogicItem {
823
823
  });
824
824
 
825
825
  const autoConnection = () => {
826
- let structure: any;
827
826
  const isAnnotation = this.typeAnnotation.typeKind === 'anonymousStructure';
828
- if (!isAnnotation)
829
- structure = this.app.findNodeByCompleteName(this.typeAnnotation.typeNamespace + '.' + this.typeAnnotation.typeName);
830
827
  this.app.emit('collect:start', {
831
828
  actionMsg: '自动连线',
832
829
  });
833
830
  this.properties.forEach((property: Identifier, leftSecondIndex: number) => {
834
831
  const leftName = property.name;
835
- const leftTypeAnnotation = !isAnnotation && structure.properties.find((p: StructureProperty) => p.name === property.name).typeAnnotation;
832
+ const leftTypeAnnotation = !isAnnotation && property.__TypeAnnotation;
836
833
  const typeStruct = isAnnotation && this.typeAnnotation.properties[leftSecondIndex]; // 获取匿名数据结构typeAnnotation的具体property
837
834
  if (leftLineSet.has(leftSecondIndex) || leftLineSet.has(leftName))
838
835
  return;
@@ -902,9 +899,10 @@ export class NewComposite extends LogicItem {
902
899
 
903
900
  let count = 0;
904
901
  const typeAnnotationEnd = () => {
905
- const r = this.rights.every((right) => right.members.every((item) => item.__isCorrectTypeAnnotation));
902
+ const l = this.properties.every((item) => item.__isCorrectTypeAnnotation);
903
+ const r = this.rights.every((right) => right.members.every((item) => item.__isCorrectTypeAnnotation) && right.expression.__isCorrectTypeAnnotation);
906
904
  count++;
907
- if (r) {
905
+ if (r && l) {
908
906
  autoConnection();
909
907
  } else if (count <= 10) {
910
908
  setTimeout(() => {
@@ -1016,7 +1014,7 @@ export class NewComposite extends LogicItem {
1016
1014
  this.app.emit('collect:start', {
1017
1015
  actionMsg: '匿名数据结构删除右侧变量',
1018
1016
  });
1019
- if (this.typeAnnotation.typeKind === 'anonymousStructure') {
1017
+ if (this.typeAnnotation?.typeKind === 'anonymousStructure') {
1020
1018
  oldLines.forEach(({ leftIndex }) => {
1021
1019
  const leftItem = this.typeAnnotation.properties[leftIndex[1]];
1022
1020
  leftItem.update({
@@ -1044,7 +1042,7 @@ export class NewComposite extends LogicItem {
1044
1042
  let oldLines: AssignmentLine[] = this.assignmentLines.filter(({ rightIndex }) => rightIndex[0] === splitIndex);
1045
1043
  // 右侧变量改变后,修改连线
1046
1044
  members.forEach((item, index) => {
1047
- if (keepMembers.has(item.completeName)) {
1045
+ if (keepMembers?.has(item.completeName)) {
1048
1046
  const lines = this.findlines(item, selectMember);
1049
1047
  lines.forEach((line) => {
1050
1048
  const newLine = Object.assign({}, line, { rightIndex: [line.rightIndex[0], index] });
@@ -1219,8 +1217,7 @@ export class NewComposite extends LogicItem {
1219
1217
  });
1220
1218
  // 方便ts报错检查
1221
1219
  code += 'function __newComposite() {\n';
1222
- code += `let __obj = nasl.util.New<${this.typeAnnotation.sortedTypeKey}>();`;
1223
- code += '\n';
1220
+ code += `let __obj = nasl.util.New<${this.typeAnnotation.sortedTypeKey}>();\n`;
1224
1221
  // 是否是左边的顶层连线
1225
1222
  const leftTopIndex = this.assignmentLines.findIndex(({ leftIndex }) => leftIndex[1] === undefined);
1226
1223
  if (leftTopIndex !== -1) {
@@ -1230,10 +1227,13 @@ export class NewComposite extends LogicItem {
1230
1227
  code += '\n';
1231
1228
  } else {
1232
1229
  // 左侧properties的identifier的类型标注
1233
- this.properties.forEach((item) => {
1234
- code += `const `;
1235
- code += `${item.toEmbeddedTS(shiftState(state, code, { inline: true }))} = __obj.${item.name};\n`;
1230
+ code += 'const { ';
1231
+ this.properties.forEach((item, index) => {
1232
+ code += item.toEmbeddedTS(shiftState(state, code, { inline: true }));
1233
+ if (index < this.properties.length - 1)
1234
+ code += ', ';
1236
1235
  });
1236
+ code += ' } = __obj;\n';
1237
1237
  this.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
1238
1238
  const leftSecondIndex = leftIndex[1];
1239
1239
  const [rightFirst, rightSecond] = [rightIndex[0], rightIndex[1]];
@@ -1286,7 +1286,7 @@ export class NewComposite extends LogicItem {
1286
1286
  const name = property.name;
1287
1287
  const rightItem = nameMap.get(name);
1288
1288
  if (rightMap.get(rightItem) !== undefined) {
1289
- code += `{ const x = ${rightMap.get(rightItem)}; const `;
1289
+ code += `{ const x${rightMap.get(rightItem) === 'null' ? ':void' : ''} = ${rightMap.get(rightItem)}; const `;
1290
1290
  code += property.toEmbeddedTS(shiftState(state, code, { inline: true }));
1291
1291
  code += `: nasl.core.Incompatible<typeof x, void> = x`;
1292
1292
  code += '; }\n';
@@ -326,6 +326,22 @@ export class NewList extends LogicItem {
326
326
  // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
327
327
  // 自动生成的代码已结束。下面可以手动编写。
328
328
  //================================================================================
329
+ toBrief(): string {
330
+ let code = '';
331
+ code += '[ ';
332
+ this.items.forEach((value, index) => {
333
+ if (index >= 10)
334
+ return;
335
+ if (index)
336
+ code += ',';
337
+ code += value.toBrief();
338
+ });
339
+ if (this.items.length > 10)
340
+ code += ', ...';
341
+ code += ' ]';
342
+ return code;
343
+ }
344
+
329
345
  toUI(state?: TranslatorState): string {
330
346
  let code = '';
331
347
  code += '[';
@@ -378,9 +394,10 @@ export class NewList extends LogicItem {
378
394
  this.items.forEach((item, index) => {
379
395
  if (item.concept === 'Unparsed')
380
396
  return;
397
+ code += 'nasl.core.ensureVoid(';
381
398
  arr.push(item.toEmbeddedTS(shiftState(state, code, { inline: true })));
382
399
  code += arr[index];
383
- code += '; ';
400
+ code += '); ';
384
401
  });
385
402
  code += '\n';
386
403
  if (!arr.length || arr.every((item: any) => ['__IDENTIFIER__', '__IDENTIFIER__()', 'null'].includes(item)))
@@ -530,6 +530,23 @@ export class NewMap extends LogicItem {
530
530
  })
531
531
  }
532
532
 
533
+ toBrief(): string {
534
+ let code = '';
535
+ code += '[<br />';
536
+ this.keys.forEach((key, index) => {
537
+ if (index >= 10)
538
+ return;
539
+ const value = this.values[index];
540
+ code += '&nbsp;&nbsp;&nbsp;&nbsp;';
541
+ code += `${key ? key.toBrief() : 'null'} -> ${value ? value.toBrief() : 'null'}`;
542
+ code += '<br />';
543
+ });
544
+ if (this.keys.length > 10)
545
+ code += '&nbsp;&nbsp;&nbsp;&nbsp...<br />';
546
+ code += ']';
547
+ return code;
548
+ }
549
+
533
550
  toJS(state?: TranslatorState): string {
534
551
  let code = '';
535
552
  code += 'await (async () => {\n';
@@ -594,10 +611,11 @@ export class NewMap extends LogicItem {
594
611
  this.values.forEach((item, index) => {
595
612
  if (item)
596
613
  valueTs = true;
614
+ code += 'nasl.core.ensureVoid(';
597
615
  const ts = item ? item.toEmbeddedTS(shiftState(state, code, { inline: true })) : null;
598
616
  valueTsArr.push(ts);
599
617
  code += valueTsArr[index];
600
- code += '; ';
618
+ code += '); ';
601
619
  });
602
620
  code += '\n';
603
621
  if (keyTs === 'null' || !valueTs) {
@@ -319,6 +319,8 @@ export class OqlQueryComponent extends LogicItem {
319
319
  },
320
320
  }).then((res: any) => {
321
321
  this.codeSourceMap = res || { typescript: '', lexicalErrorCode: 1001 };
322
+ }).catch(() => {
323
+ this.codeSourceMap = { typescript: '', lexicalErrorCode: 1001 };
322
324
  });
323
325
  } else {
324
326
  this.codeSourceMap = { typescript: '', lexicalErrorCode: 1001 };
@@ -30,7 +30,7 @@ export class StringInterpolation extends LogicItem {
30
30
  @property('LogicItem')
31
31
  expressions: Array<LogicItem> = [];
32
32
 
33
-
33
+
34
34
 
35
35
  /**
36
36
  * @param source 需要合并的部分参数
@@ -45,7 +45,7 @@ export class StringInterpolation extends LogicItem {
45
45
  return super.from(source, parentNode, parentKey) as StringInterpolation;
46
46
  }
47
47
 
48
-
48
+
49
49
  /**
50
50
  * 设置插值表达式
51
51
  */
@@ -58,7 +58,7 @@ export class StringInterpolation extends LogicItem {
58
58
  });
59
59
  }
60
60
 
61
- getItemExistingNames(excludedList: Array<LogicItem> = []) {
61
+ getItemExistingNames(excludedList: Array<LogicItem> = []) {
62
62
  const excludedSet = new Set(excludedList);
63
63
  return ((this.expressions as LogicItem[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
64
64
  }
@@ -200,7 +200,7 @@ export class StringInterpolation extends LogicItem {
200
200
  }
201
201
 
202
202
 
203
-
203
+
204
204
 
205
205
  /**
206
206
  * 删除逻辑项
@@ -279,6 +279,8 @@ export class StringInterpolation extends LogicItem {
279
279
  }
280
280
 
281
281
  toJS(): string {
282
+ if (!this.expressions.length)
283
+ return `''`;
282
284
  return this.expressions.map((exp: any) => {
283
285
  const expTypeAnnotation = exp.typeAnnotation || exp.__TypeAnnotation;
284
286
  return `this.$utils['ToString'](${exp.toJS()}, '${expTypeAnnotation?.sortedTypeKey}')`;