@lcap/nasl 3.4.0-alpha.2 → 3.4.0-beta.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 (299) hide show
  1. package/out/common/BaseNode.d.ts +14 -11
  2. package/out/common/BaseNode.js +72 -52
  3. package/out/common/BaseNode.js.map +1 -1
  4. package/out/concepts/Anchor__.js +3 -1
  5. package/out/concepts/Anchor__.js.map +1 -1
  6. package/out/concepts/AnonymousFunction__.js +10 -3
  7. package/out/concepts/AnonymousFunction__.js.map +1 -1
  8. package/out/concepts/App__.js +69 -18
  9. package/out/concepts/App__.js.map +1 -1
  10. package/out/concepts/Argument__.js +3 -1
  11. package/out/concepts/Argument__.js.map +1 -1
  12. package/out/concepts/Assignee__.js +18 -5
  13. package/out/concepts/Assignee__.js.map +1 -1
  14. package/out/concepts/AssignmentLine__.js +6 -2
  15. package/out/concepts/AssignmentLine__.js.map +1 -1
  16. package/out/concepts/Assignment__.js +6 -2
  17. package/out/concepts/Assignment__.js.map +1 -1
  18. package/out/concepts/Attribute__.js +3 -1
  19. package/out/concepts/Attribute__.js.map +1 -1
  20. package/out/concepts/AuthLogicForCallInterface__.js +4 -1
  21. package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
  22. package/out/concepts/AuthLogic__.js.map +1 -1
  23. package/out/concepts/BackendVariable__.js +3 -1
  24. package/out/concepts/BackendVariable__.js.map +1 -1
  25. package/out/concepts/Backend__.js +4 -1
  26. package/out/concepts/Backend__.js.map +1 -1
  27. package/out/concepts/BatchAssignment__.js +11 -3
  28. package/out/concepts/BatchAssignment__.js.map +1 -1
  29. package/out/concepts/BinaryExpression__.js +6 -2
  30. package/out/concepts/BinaryExpression__.js.map +1 -1
  31. package/out/concepts/BindAttribute__.js +20 -6
  32. package/out/concepts/BindAttribute__.js.map +1 -1
  33. package/out/concepts/BindDirective__.js +7 -2
  34. package/out/concepts/BindDirective__.js.map +1 -1
  35. package/out/concepts/BindEvent__.js +8 -2
  36. package/out/concepts/BindEvent__.js.map +1 -1
  37. package/out/concepts/BindStyle__.js +7 -2
  38. package/out/concepts/BindStyle__.js.map +1 -1
  39. package/out/concepts/CallAuthInterface__.js +4 -1
  40. package/out/concepts/CallAuthInterface__.js.map +1 -1
  41. package/out/concepts/CallFunction__.js +8 -2
  42. package/out/concepts/CallFunction__.js.map +1 -1
  43. package/out/concepts/CallInterface__.d.ts +2 -1
  44. package/out/concepts/CallInterface__.js +51 -13
  45. package/out/concepts/CallInterface__.js.map +1 -1
  46. package/out/concepts/CallLogic__.js +11 -3
  47. package/out/concepts/CallLogic__.js.map +1 -1
  48. package/out/concepts/CallQueryComponent__.js +34 -10
  49. package/out/concepts/CallQueryComponent__.js.map +1 -1
  50. package/out/concepts/CompletionProperty__.js +3 -1
  51. package/out/concepts/CompletionProperty__.js.map +1 -1
  52. package/out/concepts/ConfigGroup__.js +4 -1
  53. package/out/concepts/ConfigGroup__.js.map +1 -1
  54. package/out/concepts/ConfigProperty__.js +4 -1
  55. package/out/concepts/ConfigProperty__.js.map +1 -1
  56. package/out/concepts/Configuration__.js +4 -1
  57. package/out/concepts/Configuration__.js.map +1 -1
  58. package/out/concepts/Connection__.js +4 -1
  59. package/out/concepts/Connection__.js.map +1 -1
  60. package/out/concepts/Connector__.js +26 -7
  61. package/out/concepts/Connector__.js.map +1 -1
  62. package/out/concepts/Constant__.js +3 -1
  63. package/out/concepts/Constant__.js.map +1 -1
  64. package/out/concepts/DataSource__.js +4 -1
  65. package/out/concepts/DataSource__.js.map +1 -1
  66. package/out/concepts/Destination__.js +7 -2
  67. package/out/concepts/Destination__.js.map +1 -1
  68. package/out/concepts/EntityIndex__.js +3 -1
  69. package/out/concepts/EntityIndex__.js.map +1 -1
  70. package/out/concepts/EntityProperty__.js +9 -3
  71. package/out/concepts/EntityProperty__.js.map +1 -1
  72. package/out/concepts/Entity__.js +8 -2
  73. package/out/concepts/Entity__.js.map +1 -1
  74. package/out/concepts/Enum__.js +4 -1
  75. package/out/concepts/Enum__.js.map +1 -1
  76. package/out/concepts/Event__.js +4 -1
  77. package/out/concepts/Event__.js.map +1 -1
  78. package/out/concepts/ExternalDestination__.js +6 -2
  79. package/out/concepts/ExternalDestination__.js.map +1 -1
  80. package/out/concepts/ForEachStatement__.js +19 -6
  81. package/out/concepts/ForEachStatement__.js.map +1 -1
  82. package/out/concepts/FrontendLibrary__.js +8 -2
  83. package/out/concepts/FrontendLibrary__.js.map +1 -1
  84. package/out/concepts/Frontend__.js +19 -5
  85. package/out/concepts/Frontend__.js.map +1 -1
  86. package/out/concepts/Function__.js +19 -5
  87. package/out/concepts/Function__.js.map +1 -1
  88. package/out/concepts/IfStatement__.js +11 -3
  89. package/out/concepts/IfStatement__.js.map +1 -1
  90. package/out/concepts/Integration__.js +7 -2
  91. package/out/concepts/Integration__.js.map +1 -1
  92. package/out/concepts/InterfaceParam__.js +3 -1
  93. package/out/concepts/InterfaceParam__.js.map +1 -1
  94. package/out/concepts/Interface__.js +11 -3
  95. package/out/concepts/Interface__.js.map +1 -1
  96. package/out/concepts/Logic__.js +46 -46
  97. package/out/concepts/Logic__.js.map +1 -1
  98. package/out/concepts/MatchCase__.js +8 -2
  99. package/out/concepts/MatchCase__.js.map +1 -1
  100. package/out/concepts/Match__.js +7 -2
  101. package/out/concepts/Match__.js.map +1 -1
  102. package/out/concepts/MemberExpression__.js +6 -2
  103. package/out/concepts/MemberExpression__.js.map +1 -1
  104. package/out/concepts/Module__.js +55 -14
  105. package/out/concepts/Module__.js.map +1 -1
  106. package/out/concepts/MsgTriggerEvent__.js +4 -1
  107. package/out/concepts/MsgTriggerEvent__.js.map +1 -1
  108. package/out/concepts/MsgTriggerLauncher__.js +4 -1
  109. package/out/concepts/MsgTriggerLauncher__.js.map +1 -1
  110. package/out/concepts/Namespace__.js +48 -12
  111. package/out/concepts/Namespace__.js.map +1 -1
  112. package/out/concepts/NewComposite__.js +15 -4
  113. package/out/concepts/NewComposite__.js.map +1 -1
  114. package/out/concepts/NewList__.js +7 -2
  115. package/out/concepts/NewList__.js.map +1 -1
  116. package/out/concepts/NewMap__.js +11 -3
  117. package/out/concepts/NewMap__.js.map +1 -1
  118. package/out/concepts/NumericLiteral__.js +3 -1
  119. package/out/concepts/NumericLiteral__.js.map +1 -1
  120. package/out/concepts/OqlQueryComponent__.js +3 -1
  121. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  122. package/out/concepts/OverriddenLogic__.js +28 -8
  123. package/out/concepts/OverriddenLogic__.js.map +1 -1
  124. package/out/concepts/Param__.js +3 -1
  125. package/out/concepts/Param__.js.map +1 -1
  126. package/out/concepts/ProcessComponent__.js +8 -2
  127. package/out/concepts/ProcessComponent__.js.map +1 -1
  128. package/out/concepts/ProcessElement__.js +30 -8
  129. package/out/concepts/ProcessElement__.js.map +1 -1
  130. package/out/concepts/ProcessOutcomes__.js +3 -1
  131. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  132. package/out/concepts/Process__.js +20 -5
  133. package/out/concepts/Process__.js.map +1 -1
  134. package/out/concepts/QueryAggregateExpression__.js +3 -1
  135. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  136. package/out/concepts/QueryFromExpression__.js +4 -1
  137. package/out/concepts/QueryFromExpression__.js.map +1 -1
  138. package/out/concepts/QueryGroupByExpression__.js +3 -1
  139. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  140. package/out/concepts/QueryJoinExpression__.js +8 -2
  141. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  142. package/out/concepts/QueryLimitExpression__.js +6 -2
  143. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  144. package/out/concepts/QueryOrderByExpression__.js +6 -2
  145. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  146. package/out/concepts/QuerySelectExpression__.js +4 -1
  147. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  148. package/out/concepts/Return__.js +3 -1
  149. package/out/concepts/Return__.js.map +1 -1
  150. package/out/concepts/SelectMembers__.js +7 -2
  151. package/out/concepts/SelectMembers__.js.map +1 -1
  152. package/out/concepts/Slot__.js +3 -1
  153. package/out/concepts/Slot__.js.map +1 -1
  154. package/out/concepts/SqlQueryComponent__.js +3 -1
  155. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  156. package/out/concepts/StringInterpolation__.js +4 -1
  157. package/out/concepts/StringInterpolation__.js.map +1 -1
  158. package/out/concepts/StructureProperty__.js +3 -1
  159. package/out/concepts/StructureProperty__.js.map +1 -1
  160. package/out/concepts/Structure__.js +8 -2
  161. package/out/concepts/Structure__.js.map +1 -1
  162. package/out/concepts/SwitchCase__.js +7 -2
  163. package/out/concepts/SwitchCase__.js.map +1 -1
  164. package/out/concepts/SwitchStatement__.js +4 -1
  165. package/out/concepts/SwitchStatement__.js.map +1 -1
  166. package/out/concepts/TriggerEvent__.js +4 -1
  167. package/out/concepts/TriggerEvent__.js.map +1 -1
  168. package/out/concepts/TypeAnnotation__.js +12 -3
  169. package/out/concepts/TypeAnnotation__.js.map +1 -1
  170. package/out/concepts/UnaryExpression__.js +3 -1
  171. package/out/concepts/UnaryExpression__.js.map +1 -1
  172. package/out/concepts/ValidationRule__.js +10 -3
  173. package/out/concepts/ValidationRule__.js.map +1 -1
  174. package/out/concepts/Variable__.js +3 -1
  175. package/out/concepts/Variable__.js.map +1 -1
  176. package/out/concepts/ViewComponent__.js +24 -6
  177. package/out/concepts/ViewComponent__.js.map +1 -1
  178. package/out/concepts/ViewElement__.js +24 -7
  179. package/out/concepts/ViewElement__.js.map +1 -1
  180. package/out/concepts/View__.js +27 -7
  181. package/out/concepts/View__.js.map +1 -1
  182. package/out/concepts/WhileStatement__.js +7 -2
  183. package/out/concepts/WhileStatement__.js.map +1 -1
  184. package/out/concepts/types__.d.ts +2 -3
  185. package/out/decorators/index.d.ts +3 -3
  186. package/out/decorators/index.js +3 -1
  187. package/out/decorators/index.js.map +1 -1
  188. package/out/natural/genNaturalTS.js +1 -1
  189. package/out/natural/genNaturalTS.js.map +1 -1
  190. package/out/natural/transformTSCode.js +10 -5
  191. package/out/natural/transformTSCode.js.map +1 -1
  192. package/out/server/formatTsUtils.d.ts +3 -3
  193. package/out/server/getMemberIdentifier.d.ts +4 -4
  194. package/out/server/naslServer.d.ts +1 -1
  195. package/out/server/naslServer.js +4 -2
  196. package/out/server/naslServer.js.map +1 -1
  197. package/out/translator/utils.js +24 -28
  198. package/out/translator/utils.js.map +1 -1
  199. package/package.json +1 -1
  200. package/src/common/BaseNode.ts +92 -68
  201. package/src/concepts/Anchor__.ts +3 -1
  202. package/src/concepts/AnonymousFunction__.ts +10 -3
  203. package/src/concepts/App__.ts +69 -18
  204. package/src/concepts/Argument__.ts +3 -1
  205. package/src/concepts/Assignee__.ts +18 -5
  206. package/src/concepts/AssignmentLine__.ts +6 -2
  207. package/src/concepts/Assignment__.ts +6 -2
  208. package/src/concepts/Attribute__.ts +3 -1
  209. package/src/concepts/AuthLogicForCallInterface__.ts +4 -1
  210. package/src/concepts/AuthLogic__.ts +3 -0
  211. package/src/concepts/BackendVariable__.ts +3 -1
  212. package/src/concepts/Backend__.ts +4 -1
  213. package/src/concepts/BatchAssignment__.ts +11 -3
  214. package/src/concepts/BinaryExpression__.ts +6 -2
  215. package/src/concepts/BindAttribute__.ts +20 -7
  216. package/src/concepts/BindDirective__.ts +7 -2
  217. package/src/concepts/BindEvent__.ts +8 -2
  218. package/src/concepts/BindStyle__.ts +7 -2
  219. package/src/concepts/CallAuthInterface__.ts +4 -1
  220. package/src/concepts/CallFunction__.ts +8 -2
  221. package/src/concepts/CallInterface__.ts +49 -14
  222. package/src/concepts/CallLogic__.ts +11 -3
  223. package/src/concepts/CallQueryComponent__.ts +34 -10
  224. package/src/concepts/CompletionProperty__.ts +3 -1
  225. package/src/concepts/ConfigGroup__.ts +4 -1
  226. package/src/concepts/ConfigProperty__.ts +4 -1
  227. package/src/concepts/Configuration__.ts +4 -1
  228. package/src/concepts/Connection__.ts +4 -1
  229. package/src/concepts/Connector__.ts +26 -7
  230. package/src/concepts/Constant__.ts +3 -1
  231. package/src/concepts/DataSource__.ts +4 -1
  232. package/src/concepts/Destination__.ts +7 -2
  233. package/src/concepts/EntityIndex__.ts +3 -1
  234. package/src/concepts/EntityProperty__.ts +9 -3
  235. package/src/concepts/Entity__.ts +8 -2
  236. package/src/concepts/Enum__.ts +4 -1
  237. package/src/concepts/Event__.ts +4 -1
  238. package/src/concepts/ExternalDestination__.ts +6 -2
  239. package/src/concepts/ForEachStatement__.ts +19 -6
  240. package/src/concepts/FrontendLibrary__.ts +8 -2
  241. package/src/concepts/Frontend__.ts +19 -5
  242. package/src/concepts/Function__.ts +19 -5
  243. package/src/concepts/IfStatement__.ts +11 -3
  244. package/src/concepts/Integration__.ts +7 -2
  245. package/src/concepts/InterfaceParam__.ts +3 -1
  246. package/src/concepts/Interface__.ts +11 -3
  247. package/src/concepts/Logic__.ts +62 -57
  248. package/src/concepts/MatchCase__.ts +8 -2
  249. package/src/concepts/Match__.ts +7 -2
  250. package/src/concepts/MemberExpression__.ts +6 -2
  251. package/src/concepts/Module__.ts +55 -14
  252. package/src/concepts/MsgTriggerEvent__.ts +4 -1
  253. package/src/concepts/MsgTriggerLauncher__.ts +4 -1
  254. package/src/concepts/Namespace__.ts +48 -12
  255. package/src/concepts/NewComposite__.ts +15 -4
  256. package/src/concepts/NewList__.ts +7 -2
  257. package/src/concepts/NewMap__.ts +11 -3
  258. package/src/concepts/NumericLiteral__.ts +3 -1
  259. package/src/concepts/OqlQueryComponent__.ts +3 -1
  260. package/src/concepts/OverriddenLogic__.ts +28 -8
  261. package/src/concepts/Param__.ts +3 -1
  262. package/src/concepts/ProcessComponent__.ts +8 -2
  263. package/src/concepts/ProcessElement__.ts +30 -8
  264. package/src/concepts/ProcessOutcomes__.ts +3 -1
  265. package/src/concepts/Process__.ts +20 -5
  266. package/src/concepts/QueryAggregateExpression__.ts +3 -1
  267. package/src/concepts/QueryFromExpression__.ts +4 -1
  268. package/src/concepts/QueryGroupByExpression__.ts +3 -1
  269. package/src/concepts/QueryJoinExpression__.ts +8 -2
  270. package/src/concepts/QueryLimitExpression__.ts +6 -2
  271. package/src/concepts/QueryOrderByExpression__.ts +6 -2
  272. package/src/concepts/QuerySelectExpression__.ts +4 -1
  273. package/src/concepts/Return__.ts +3 -1
  274. package/src/concepts/SelectMembers__.ts +7 -2
  275. package/src/concepts/Slot__.ts +3 -1
  276. package/src/concepts/SqlQueryComponent__.ts +3 -1
  277. package/src/concepts/StringInterpolation__.ts +4 -1
  278. package/src/concepts/StructureProperty__.ts +3 -1
  279. package/src/concepts/Structure__.ts +8 -2
  280. package/src/concepts/SwitchCase__.ts +7 -2
  281. package/src/concepts/SwitchStatement__.ts +4 -1
  282. package/src/concepts/TriggerEvent__.ts +4 -1
  283. package/src/concepts/TypeAnnotation__.ts +13 -4
  284. package/src/concepts/UnaryExpression__.ts +3 -1
  285. package/src/concepts/ValidationRule__.ts +10 -3
  286. package/src/concepts/Variable__.ts +3 -1
  287. package/src/concepts/ViewComponent__.ts +24 -6
  288. package/src/concepts/ViewElement__.ts +92 -72
  289. package/src/concepts/View__.ts +27 -7
  290. package/src/concepts/WhileStatement__.ts +7 -2
  291. package/src/concepts/types__.ts +2 -4
  292. package/src/decorators/index.ts +7 -5
  293. package/src/natural/genNaturalTS.ts +1 -1
  294. package/src/natural/transformTSCode.ts +11 -5
  295. package/src/server/formatTsUtils.ts +8 -8
  296. package/src/server/getMemberIdentifier.ts +4 -4
  297. package/src/server/naslServer.ts +4 -4
  298. package/src/service/storage/init.ts +2 -2
  299. package/src/translator/utils.ts +7 -9
@@ -32,7 +32,10 @@ export class StringInterpolation extends LogicItem {
32
32
  /**
33
33
  * 插值表达式
34
34
  */
35
- @property('LogicItem')
35
+ @property({
36
+ objectRef: 'LogicItem',
37
+ isArray: true,
38
+ })
36
39
  expressions: Array<LogicItem> = [];
37
40
 
38
41
  /**
@@ -56,7 +56,9 @@ export class StructureProperty extends BaseNode {
56
56
  /**
57
57
  * 类型
58
58
  */
59
- @property('TypeAnnotation')
59
+ @property({
60
+ objectRef: 'TypeAnnotation',
61
+ })
60
62
  // @ts-ignore
61
63
  typeAnnotation!: TypeAnnotation;
62
64
 
@@ -55,13 +55,19 @@ export class Structure extends BaseNode {
55
55
  /**
56
56
  * 类型参数列表
57
57
  */
58
- @property('TypeParam')
58
+ @property({
59
+ objectRef: 'TypeParam',
60
+ isArray: true,
61
+ })
59
62
  typeParams: Array<TypeParam> = null;
60
63
 
61
64
  /**
62
65
  * 数据结构属性列表
63
66
  */
64
- @property('StructureProperty')
67
+ @property({
68
+ objectRef: 'StructureProperty',
69
+ isArray: true,
70
+ })
65
71
  properties: Array<StructureProperty> = [];
66
72
 
67
73
  /**
@@ -30,14 +30,19 @@ export class SwitchCase extends LogicItem {
30
30
  /**
31
31
  * 条件表达式
32
32
  */
33
- @property('LogicItem')
33
+ @property({
34
+ objectRef: 'LogicItem',
35
+ })
34
36
  // @ts-ignore
35
37
  test!: LogicItem;
36
38
 
37
39
  /**
38
40
  * then
39
41
  */
40
- @property('LogicItem')
42
+ @property({
43
+ objectRef: 'LogicItem',
44
+ isArray: true,
45
+ })
41
46
  consequent: Array<LogicItem> = [];
42
47
 
43
48
  /**
@@ -32,7 +32,10 @@ export class SwitchStatement extends LogicItem {
32
32
  /**
33
33
  * 选择分支情况列表
34
34
  */
35
- @property('SwitchCase')
35
+ @property({
36
+ objectRef: 'SwitchCase',
37
+ isArray: true,
38
+ })
36
39
  cases: Array<SwitchCase> = [];
37
40
 
38
41
  /**
@@ -36,7 +36,10 @@ export class TriggerEvent extends BaseNode {
36
36
  /**
37
37
  * 类型标注列表
38
38
  */
39
- @property('TypeAnnotation')
39
+ @property({
40
+ objectRef: 'TypeAnnotation',
41
+ isArray: true,
42
+ })
40
43
  callBackLogic: Array<TypeAnnotation> = [];
41
44
 
42
45
  /**
@@ -139,13 +139,19 @@ export class TypeAnnotation extends BaseNode {
139
139
  /**
140
140
  * 类型参数
141
141
  */
142
- @property('TypeAnnotation')
142
+ @property({
143
+ objectRef: 'TypeAnnotation',
144
+ isArray: true,
145
+ })
143
146
  typeArguments?: Array<TypeAnnotation> = null;
144
147
 
145
148
  /**
146
149
  * 返回类型
147
150
  */
148
- @property('TypeAnnotation')
151
+ @property({
152
+ objectRef: 'TypeAnnotation',
153
+ isArray: true,
154
+ })
149
155
  returnType?: Array<TypeAnnotation> = null;
150
156
 
151
157
  /**
@@ -158,7 +164,10 @@ export class TypeAnnotation extends BaseNode {
158
164
  /**
159
165
  * 匿名数据结构属性
160
166
  */
161
- @property('StructureProperty')
167
+ @property({
168
+ objectRef: 'StructureProperty',
169
+ isArray: true,
170
+ })
162
171
  properties?: Array<StructureProperty> = null;
163
172
 
164
173
  /**
@@ -1163,7 +1172,7 @@ export class TypeAnnotation extends BaseNode {
1163
1172
 
1164
1173
  // 是否是系统类型
1165
1174
  isSystemType() {
1166
- return ['nasl.ui', 'nasl.auth', 'nasl.http', 'nasl.process'].includes(this.typeNamespace)
1175
+ return ['nasl.ui', 'nasl.auth', 'nasl.http', 'nasl.process'].includes(this.typeNamespace);
1167
1176
  }
1168
1177
 
1169
1178
  // 是否包含系统类型
@@ -32,7 +32,9 @@ export class UnaryExpression extends LogicItem {
32
32
  /**
33
33
  * 参数
34
34
  */
35
- @property('LogicItem')
35
+ @property({
36
+ objectRef: 'LogicItem',
37
+ })
36
38
  // @ts-ignore
37
39
  argument!: LogicItem;
38
40
 
@@ -57,20 +57,27 @@ export class ValidationRule extends LogicItem {
57
57
  /**
58
58
  * 实际参数
59
59
  */
60
- @property('Argument')
60
+ @property({
61
+ objectRef: 'Argument',
62
+ isArray: true,
63
+ })
61
64
  arguments: Array<Argument> = [];
62
65
 
63
66
  /**
64
67
  * 错误信息
65
68
  */
66
- @property('LogicItem')
69
+ @property({
70
+ objectRef: 'LogicItem',
71
+ })
67
72
  // @ts-ignore
68
73
  errorMessage!: LogicItem;
69
74
 
70
75
  /**
71
76
  * 验证对象
72
77
  */
73
- @property('LogicItem')
78
+ @property({
79
+ objectRef: 'LogicItem',
80
+ })
74
81
  // @ts-ignore
75
82
  target!: LogicItem;
76
83
 
@@ -72,7 +72,9 @@ export class Variable extends BaseNode {
72
72
  /**
73
73
  * 类型
74
74
  */
75
- @property('TypeAnnotation')
75
+ @property({
76
+ objectRef: 'TypeAnnotation',
77
+ })
76
78
  // @ts-ignore
77
79
  typeAnnotation!: TypeAnnotation;
78
80
 
@@ -63,37 +63,55 @@ export class ViewComponent extends BaseNode {
63
63
  /**
64
64
  * 组件属性列表
65
65
  */
66
- @property('Attribute')
66
+ @property({
67
+ objectRef: 'Attribute',
68
+ isArray: true,
69
+ })
67
70
  attrs: Array<Attribute> = [];
68
71
 
69
72
  /**
70
73
  * 组件事件列表
71
74
  */
72
- @property('Event')
75
+ @property({
76
+ objectRef: 'Event',
77
+ isArray: true,
78
+ })
73
79
  events: Array<Event> = [];
74
80
 
75
81
  /**
76
82
  * 插槽列表
77
83
  */
78
- @property('Slot')
84
+ @property({
85
+ objectRef: 'Slot',
86
+ isArray: true,
87
+ })
79
88
  slots: Array<Slot> = [];
80
89
 
81
90
  /**
82
91
  * 逻辑列表
83
92
  */
84
- @property('Logic')
93
+ @property({
94
+ objectRef: 'Logic',
95
+ isArray: true,
96
+ })
85
97
  methods: Array<Logic> = [];
86
98
 
87
99
  /**
88
100
  * 页面组件列表
89
101
  */
90
- @property('ViewComponent')
102
+ @property({
103
+ objectRef: 'ViewComponent',
104
+ isArray: true,
105
+ })
91
106
  children: Array<ViewComponent> = [];
92
107
 
93
108
  /**
94
109
  * 页面代码块列表
95
110
  */
96
- @property('ViewBlock')
111
+ @property({
112
+ objectRef: 'ViewBlock',
113
+ isArray: true,
114
+ })
97
115
  blocks: Array<ViewBlock> = [];
98
116
 
99
117
  /**
@@ -325,37 +325,54 @@ export class ViewElement extends BaseNode {
325
325
  /**
326
326
  * 元素绑定属性列表
327
327
  */
328
- @property('BindAttribute')
328
+ @property({
329
+ objectRef: 'BindAttribute',
330
+ isArray: true,
331
+ })
329
332
  bindAttrs: Array<BindAttribute> = [];
330
333
 
331
334
  /**
332
335
  * 元素绑定事件列表
333
336
  */
334
- @property('BindEvent')
337
+ @property({
338
+ objectRef: 'BindEvent',
339
+ isArray: true,
340
+ })
335
341
  bindEvents: Array<BindEvent> = [];
336
342
 
337
343
  /**
338
344
  * 元素指令列表
339
345
  */
340
- @property('BindDirective')
346
+ @property({
347
+ objectRef: 'BindDirective',
348
+ isArray: true,
349
+ })
341
350
  bindDirectives: Array<BindDirective> = [];
342
351
 
343
352
  /**
344
353
  * 绑定的角色
345
354
  */
346
- @property()
355
+ @property({
356
+ isArray: true,
357
+ })
347
358
  bindRoles: Array<string> = [];
348
359
 
349
360
  /**
350
361
  * 元素绑定样式列表
351
362
  */
352
- @property('BindStyle')
363
+ @property({
364
+ objectRef: 'BindStyle',
365
+ isArray: true,
366
+ })
353
367
  bindStyles: Array<BindStyle> = [];
354
368
 
355
369
  /**
356
370
  * 子元素列表
357
371
  */
358
- @property('ViewElement')
372
+ @property({
373
+ objectRef: 'ViewElement',
374
+ isArray: true,
375
+ })
359
376
  children: Array<ViewElement> = [];
360
377
 
361
378
  /**
@@ -1586,76 +1603,79 @@ export class ViewElement extends BaseNode {
1586
1603
 
1587
1604
  toEmbeddedTSVariableFunctionDefinition(state?: TranslatorState, parentLevel?: number): string {
1588
1605
  let code = '';
1589
- code += indent((state?.tabSize || 0) + 2);
1590
- let levelIndex = parentLevel || 0;
1591
- code += `${this.name}: () => {\n`;
1592
- if (this.tag === 'template' && this.haveScope() && this.parentNode instanceof ViewElement) {
1593
- const currentType = this.parentNode.tag === 'u-table-view-column-dynamic' ? 'CurrentDynamic' : 'Current'
1594
- const _this = this.parentNode
1595
- let genericity = '';
1596
- if (_this.tag === 'u-table-view-column-dynamic') {
1597
- genericity += `<${(_this.parentNode as any).__tsVariableDataSourceTypeName}, ${(_this as any).__tsVariableDataSourceTypeName}>`;
1598
- } else {
1599
- let targetNode: any = _this
1600
- while (!targetNode.__tsVariableDataSourceTypeName && targetNode?.parentNode instanceof ViewElement) {
1601
- targetNode = targetNode.parentNode
1602
- }
1603
- genericity += `<${(targetNode as any).__tsVariableDataSourceTypeName ?? 'any'}>`;
1604
- }
1605
- code += indent((state?.tabSize || 0) + 3);
1606
- code += `let current${levelIndex === 0 ? '' : levelIndex}: nasl.ui.${currentType}${genericity}\n`
1607
- levelIndex++;
1608
- }
1609
- const attr = this.bindAttrs?.find((item) => item.name === 'data-source')
1610
- if (attr && attr.expression) {
1611
- const datasourceName = `datasourceName${this.name}`;
1612
- (this as any).__tsVariableDataSourceTypeName = datasourceName;
1613
- if (
1614
- attr.expression instanceof MemberExpression ||
1615
- attr.expression instanceof Identifier ||
1616
- attr.expression instanceof CallLogic
1617
- ) {
1618
- const extraParams = {
1619
- tabSize: 4,
1620
- inline: true,
1621
- noNeedParams: true,
1622
- };
1623
- let value = attr.expression.toEmbeddedTS(
1624
- shiftState(state, code, attr.expression.concept === 'CallLogic' ? extraParams : {}),
1625
- );
1626
- code += indent((state?.tabSize || 0) + 3);
1627
- code += `type ${datasourceName} = nasl.ui.GetItemTypeFromDataSource<typeof ${value}>;\n`;
1628
- // code += `let current${levelIndex === 0 ? '' : levelIndex}: nasl.ui.${currentType}<nasl.ui.GetItemTypeFromDataSource<typeof ${value}>>;\n`;
1629
- } else {
1630
- code += indent((state?.tabSize || 0) + 3);
1631
- code += `const __funcName = () => { return `;
1632
- code += attr.expression.toEmbeddedTS(shiftState(state, code));
1633
- code += '};\n';
1634
- code += indent((state?.tabSize || 0) + 3);
1635
- code += `type ${datasourceName} = nasl.ui.GetItemTypeFromDataSource<ReturnType<typeof __funcName>>;\n`;
1636
- // code += `let current${levelIndex === 0 ? '' : levelIndex}: nasl.ui.${currentType}<nasl.ui.GetItemTypeFromDataSource<ReturnType<typeof __funcName>>>;\n`;
1606
+ code += indent((state?.tabSize || 0) + 2);
1607
+ let levelIndex = parentLevel || 0;
1608
+ code += `${this.name}: () => {\n`;
1609
+ if (this.tag === 'template' && this.haveScope() && this.parentNode instanceof ViewElement) {
1610
+ const currentType = this.parentNode.tag === 'u-table-view-column-dynamic' ? 'CurrentDynamic' : 'Current';
1611
+ const _this = this.parentNode;
1612
+ let genericity = '';
1613
+ if (_this.tag === 'u-table-view-column-dynamic') {
1614
+ genericity += `<${(_this.parentNode as any).__tsVariableDataSourceTypeName}, ${
1615
+ (_this as any).__tsVariableDataSourceTypeName
1616
+ }>`;
1617
+ } else {
1618
+ let targetNode: any = _this;
1619
+ while (!targetNode.__tsVariableDataSourceTypeName && targetNode?.parentNode instanceof ViewElement) {
1620
+ targetNode = targetNode.parentNode;
1637
1621
  }
1622
+ genericity += `<${(targetNode as any).__tsVariableDataSourceTypeName ?? 'any'}>`;
1638
1623
  }
1639
1624
  code += indent((state?.tabSize || 0) + 3);
1640
- code += `return {\n`;
1641
- if (Array.isArray(this.bindAttrs)) {
1642
- this.bindAttrs
1643
- .filter((attr) => PAGE_COMPONENT_INCLUDE_TAG_MAP[this.tag]?.[attr.name])
1644
- .forEach((attr) => {
1645
- code += attr.toEmbeddedTSVariableFunctionDefinition(
1646
- shiftState(state, code, { inline: true }),
1647
- );
1648
- });
1625
+ code += `let current${levelIndex === 0 ? '' : levelIndex}: nasl.ui.${currentType}${genericity}\n`;
1626
+ levelIndex++;
1627
+ }
1628
+ const attr = this.bindAttrs?.find((item) => item.name === 'data-source');
1629
+ if (attr && attr.expression) {
1630
+ const datasourceName = `datasourceName${this.name}`;
1631
+ (this as any).__tsVariableDataSourceTypeName = datasourceName;
1632
+ if (
1633
+ attr.expression instanceof MemberExpression ||
1634
+ attr.expression instanceof Identifier ||
1635
+ attr.expression instanceof CallLogic
1636
+ ) {
1637
+ const extraParams = {
1638
+ tabSize: 4,
1639
+ inline: true,
1640
+ noNeedParams: true,
1641
+ };
1642
+ let value = attr.expression.toEmbeddedTS(
1643
+ shiftState(state, code, attr.expression.concept === 'CallLogic' ? extraParams : {}),
1644
+ );
1645
+ code += indent((state?.tabSize || 0) + 3);
1646
+ code += `type ${datasourceName} = nasl.ui.GetItemTypeFromDataSource<typeof ${value}>;\n`;
1647
+ // code += `let current${levelIndex === 0 ? '' : levelIndex}: nasl.ui.${currentType}<nasl.ui.GetItemTypeFromDataSource<typeof ${value}>>;\n`;
1648
+ } else {
1649
+ code += indent((state?.tabSize || 0) + 3);
1650
+ code += `const __funcName = () => { return `;
1651
+ code += attr.expression.toEmbeddedTS(shiftState(state, code));
1652
+ code += '};\n';
1653
+ code += indent((state?.tabSize || 0) + 3);
1654
+ code += `type ${datasourceName} = nasl.ui.GetItemTypeFromDataSource<ReturnType<typeof __funcName>>;\n`;
1655
+ // code += `let current${levelIndex === 0 ? '' : levelIndex}: nasl.ui.${currentType}<nasl.ui.GetItemTypeFromDataSource<ReturnType<typeof __funcName>>>;\n`;
1649
1656
  }
1650
- if (Array.isArray(this.children)) {
1651
- this.children.forEach((element) => {
1652
- code += element.toEmbeddedTSVariableFunctionDefinition(shiftState({...state, tabSize: state.tabSize + 2}, code), levelIndex);
1657
+ }
1658
+ code += indent((state?.tabSize || 0) + 3);
1659
+ code += `return {\n`;
1660
+ if (Array.isArray(this.bindAttrs)) {
1661
+ this.bindAttrs
1662
+ .filter((attr) => PAGE_COMPONENT_INCLUDE_TAG_MAP[this.tag]?.[attr.name])
1663
+ .forEach((attr) => {
1664
+ code += attr.toEmbeddedTSVariableFunctionDefinition(shiftState(state, code, { inline: true }));
1653
1665
  });
1654
- }
1655
- code += indent((state?.tabSize || 0) + 3);
1656
- code += `}\n`;
1657
- code += indent((state?.tabSize || 0) + 2);
1658
- code += `},\n`;
1666
+ }
1667
+ if (Array.isArray(this.children)) {
1668
+ this.children.forEach((element) => {
1669
+ code += element.toEmbeddedTSVariableFunctionDefinition(
1670
+ shiftState({ ...state, tabSize: state.tabSize + 2 }, code),
1671
+ levelIndex,
1672
+ );
1673
+ });
1674
+ }
1675
+ code += indent((state?.tabSize || 0) + 3);
1676
+ code += `}\n`;
1677
+ code += indent((state?.tabSize || 0) + 2);
1678
+ code += `},\n`;
1659
1679
  return code;
1660
1680
  }
1661
1681
 
@@ -2520,7 +2540,7 @@ export class ViewElement extends BaseNode {
2520
2540
 
2521
2541
  get keyName() {
2522
2542
  // 是否配置了v-if
2523
- const isDefineIf = this.bindDirectives.some((directive) => (directive.name === 'if' && directive.expression));
2543
+ const isDefineIf = this.bindDirectives.some((directive) => directive.name === 'if' && directive.expression);
2524
2544
  if (isDefineIf) {
2525
2545
  let key = this.name;
2526
2546
  const list = this.getCurrentList();
@@ -126,43 +126,63 @@ export class View extends BaseNode {
126
126
  /**
127
127
  * 页面元素列表
128
128
  */
129
- @property('ViewElement')
129
+ @property({
130
+ objectRef: 'ViewElement',
131
+ isArray: true,
132
+ })
130
133
  elements: Array<ViewElement> = [];
131
134
 
132
135
  /**
133
136
  * 输入参数列表
134
137
  */
135
- @property('Param')
138
+ @property({
139
+ objectRef: 'Param',
140
+ isArray: true,
141
+ })
136
142
  params: Array<Param> = [];
137
143
 
138
144
  /**
139
145
  * 变量列表
140
146
  */
141
- @property('Variable')
147
+ @property({
148
+ objectRef: 'Variable',
149
+ isArray: true,
150
+ })
142
151
  variables: Array<Variable> = [];
143
152
 
144
153
  /**
145
154
  * 逻辑列表
146
155
  */
147
- @property('Logic')
156
+ @property({
157
+ objectRef: 'Logic',
158
+ isArray: true,
159
+ })
148
160
  logics: Array<Logic> = [];
149
161
 
150
162
  /**
151
163
  * 元素绑定事件列表
152
164
  */
153
- @property('BindEvent')
165
+ @property({
166
+ objectRef: 'BindEvent',
167
+ isArray: true,
168
+ })
154
169
  bindEvents: Array<BindEvent> = [];
155
170
 
156
171
  /**
157
172
  * 绑定的角色
158
173
  */
159
- @property()
174
+ @property({
175
+ isArray: true,
176
+ })
160
177
  bindRoles: Array<string> = [];
161
178
 
162
179
  /**
163
180
  * 页面列表
164
181
  */
165
- @property('View')
182
+ @property({
183
+ objectRef: 'View',
184
+ isArray: true,
185
+ })
166
186
  children: Array<View> = [];
167
187
 
168
188
  /**
@@ -30,14 +30,19 @@ export class WhileStatement extends LogicItem {
30
30
  /**
31
31
  * 条件表达式
32
32
  */
33
- @property('LogicItem')
33
+ @property({
34
+ objectRef: 'LogicItem',
35
+ })
34
36
  // @ts-ignore
35
37
  test!: LogicItem;
36
38
 
37
39
  /**
38
40
  * 循环体
39
41
  */
40
- @property('LogicItem')
42
+ @property({
43
+ objectRef: 'LogicItem',
44
+ isArray: true,
45
+ })
41
46
  body: Array<LogicItem> = [];
42
47
 
43
48
  /**
@@ -37,7 +37,6 @@ import type { Variable } from './Variable__';
37
37
  import type { BackendVariable } from './BackendVariable__';
38
38
  import type { FrontendVariable } from './FrontendVariable__';
39
39
  import type { Constant } from './Constant__';
40
- import type { LogicItem } from './LogicItem__';
41
40
  import type { Function } from './Function__';
42
41
  import type { AnonymousFunction } from './AnonymousFunction__';
43
42
  import type { Interface } from './Interface__';
@@ -121,7 +120,7 @@ import type { Connector } from './Connector__';
121
120
  import type { CallConnector } from './CallConnector__';
122
121
  import type { Connection } from './Connection__';
123
122
 
124
- export type SynatxNode =
123
+ export type SyntaxNode =
125
124
  | App
126
125
  | Module
127
126
  | Namespace
@@ -161,7 +160,6 @@ export type SynatxNode =
161
160
  | BackendVariable
162
161
  | FrontendVariable
163
162
  | Constant
164
- | LogicItem
165
163
  | Function
166
164
  | AnonymousFunction
167
165
  | Interface
@@ -245,4 +243,4 @@ export type SynatxNode =
245
243
  | CallConnector
246
244
  | Connection;
247
245
 
248
- export type SynatxNodeConcept = SynatxNode['concept'];
246
+ export type SyntaxNodeConcept = SyntaxNode['concept'];
@@ -1,5 +1,5 @@
1
1
  import BaseNode from '../common/BaseNode';
2
- import type { SynatxNode, SynatxNodeConcept } from '../concepts';
2
+ import type { SyntaxNode, SyntaxNodeConcept } from '../concepts';
3
3
 
4
4
  export * from './promise';
5
5
 
@@ -72,8 +72,9 @@ export function concept(nodeTitle: string) {
72
72
  };
73
73
  }
74
74
 
75
- export function property(objectRef?: string) {
76
- return function handle(target: SynatxNode | BaseNode, key: string) {
75
+ export function property(params?: any) {
76
+ const { objectRef, isArray } = params || {};
77
+ return function handle(target: SyntaxNode | BaseNode, key: string) {
77
78
  const metaMap = getConceptPropertyMap(target.concept ?? target.constructor.name);
78
79
  const prototypeTarget = Object.getPrototypeOf(target);
79
80
  const prototypeConstructor = prototypeTarget.constructor;
@@ -86,14 +87,15 @@ export function property(objectRef?: string) {
86
87
  metaMap.set(key, {
87
88
  key,
88
89
  objectRef,
90
+ isArray,
89
91
  });
90
92
  };
91
93
  }
92
94
 
93
- export function ancestor(concept: SynatxNodeConcept) {
95
+ export function ancestor(concept: SyntaxNodeConcept) {
94
96
  return function handle(target: any, key: string, descriptor: PropertyDescriptor) {
95
97
  descriptor.get = function () {
96
- return (this as SynatxNode).getAncestor(concept);
98
+ return (this as SyntaxNode).getAncestor(concept);
97
99
  };
98
100
  };
99
101
  }
@@ -84,7 +84,7 @@ export function genNaturalTSContext(app: App, currentNode?: BaseNode) {
84
84
  console.log("lemon ~ genNaturalTSContext ~ view:", view)
85
85
  code += view?.toNaturalTS(undefined, currentNode);
86
86
  } else if (logic) { // 为全局逻辑
87
- code += logic?.toNaturalTS(undefined);
87
+ code += logic?.toNaturalTS(undefined, undefined, undefined, currentNode);
88
88
  }
89
89
  code += `\n\`\`\`\n`;
90
90
  return code;
@@ -223,6 +223,10 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
223
223
  return node;
224
224
  }
225
225
 
226
+ function isPageLogic(logicName: string) {
227
+ return logicName.includes('on_') || logicName.includes('viewLogic_')
228
+ }
229
+
226
230
  function transformLogicNode(node: babelTypes.Node, typeAnnotation?: naslTypes.TypeAnnotation): naslTypes.LogicItem {
227
231
  fixLogicNode(node);
228
232
  // console.log('lemon ~~~ node--1:', node);
@@ -276,13 +280,15 @@ export function transformTSCode(tsCode: string, contextLogicName: string, type?:
276
280
  });
277
281
  }
278
282
  if (calleeName === 'nasl.oql.query') {
279
- return new naslTypes.OqlQueryComponent({
280
- dataSource: 'app.dataSources.defaultDS',
281
- code: generate(node.arguments[0] as any).code.trim().slice(1, -1),
282
- });
283
+ if (!isPageLogic(contextLogicName)) {
284
+ return new naslTypes.OqlQueryComponent({
285
+ dataSource: 'app.dataSources.defaultDS',
286
+ code: generate(node.arguments[0] as any).code.trim().slice(1, -1),
287
+ });
288
+ }
283
289
  }
284
290
  if (calleeName === 'nasl.util.consoleLog' || calleeName === 'console.log') {
285
- if (contextLogicName.includes('on_') || contextLogicName.includes('viewLogic_')) {
291
+ if (!isPageLogic(contextLogicName)) {
286
292
  return new naslTypes.CallLogic({
287
293
  calleeNamespace: 'nasl.util',
288
294
  calleeName: 'consoleLog',