@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.
- package/out/common/BaseNode.d.ts +14 -11
- package/out/common/BaseNode.js +72 -52
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/Anchor__.js +3 -1
- package/out/concepts/Anchor__.js.map +1 -1
- package/out/concepts/AnonymousFunction__.js +10 -3
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.js +69 -18
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js +3 -1
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignee__.js +18 -5
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/AssignmentLine__.js +6 -2
- package/out/concepts/AssignmentLine__.js.map +1 -1
- package/out/concepts/Assignment__.js +6 -2
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/Attribute__.js +3 -1
- package/out/concepts/Attribute__.js.map +1 -1
- package/out/concepts/AuthLogicForCallInterface__.js +4 -1
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
- package/out/concepts/AuthLogic__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +3 -1
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/Backend__.js +4 -1
- package/out/concepts/Backend__.js.map +1 -1
- package/out/concepts/BatchAssignment__.js +11 -3
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js +6 -2
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +20 -6
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +7 -2
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +8 -2
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.js +7 -2
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/CallAuthInterface__.js +4 -1
- package/out/concepts/CallAuthInterface__.js.map +1 -1
- package/out/concepts/CallFunction__.js +8 -2
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +2 -1
- package/out/concepts/CallInterface__.js +51 -13
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +11 -3
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +34 -10
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js +3 -1
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.js +4 -1
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js +4 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.js +4 -1
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Connection__.js +4 -1
- package/out/concepts/Connection__.js.map +1 -1
- package/out/concepts/Connector__.js +26 -7
- package/out/concepts/Connector__.js.map +1 -1
- package/out/concepts/Constant__.js +3 -1
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.js +4 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.js +7 -2
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityIndex__.js +3 -1
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +9 -3
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.js +8 -2
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.js +4 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js +4 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ExternalDestination__.js +6 -2
- package/out/concepts/ExternalDestination__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +19 -6
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.js +8 -2
- package/out/concepts/FrontendLibrary__.js.map +1 -1
- package/out/concepts/Frontend__.js +19 -5
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Function__.js +19 -5
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/IfStatement__.js +11 -3
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Integration__.js +7 -2
- package/out/concepts/Integration__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +3 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js +11 -3
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/Logic__.js +46 -46
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.js +8 -2
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.js +7 -2
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +6 -2
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.js +55 -14
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/MsgTriggerEvent__.js +4 -1
- package/out/concepts/MsgTriggerEvent__.js.map +1 -1
- package/out/concepts/MsgTriggerLauncher__.js +4 -1
- package/out/concepts/MsgTriggerLauncher__.js.map +1 -1
- package/out/concepts/Namespace__.js +48 -12
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NewComposite__.js +15 -4
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.js +7 -2
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.js +11 -3
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/NumericLiteral__.js +3 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +3 -1
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.js +28 -8
- package/out/concepts/OverriddenLogic__.js.map +1 -1
- package/out/concepts/Param__.js +3 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js +8 -2
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +30 -8
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcomes__.js +3 -1
- package/out/concepts/ProcessOutcomes__.js.map +1 -1
- package/out/concepts/Process__.js +20 -5
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js +3 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +4 -1
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.js +3 -1
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +8 -2
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js +6 -2
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.js +6 -2
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js +4 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Return__.js +3 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/SelectMembers__.js +7 -2
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/Slot__.js +3 -1
- package/out/concepts/Slot__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.js +3 -1
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringInterpolation__.js +4 -1
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +3 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +8 -2
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js +7 -2
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +4 -1
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TriggerEvent__.js +4 -1
- package/out/concepts/TriggerEvent__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +12 -3
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +3 -1
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +10 -3
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +3 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js +24 -6
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.js +24 -7
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +27 -7
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +7 -2
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/types__.d.ts +2 -3
- package/out/decorators/index.d.ts +3 -3
- package/out/decorators/index.js +3 -1
- package/out/decorators/index.js.map +1 -1
- package/out/natural/genNaturalTS.js +1 -1
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/transformTSCode.js +10 -5
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +3 -3
- package/out/server/getMemberIdentifier.d.ts +4 -4
- package/out/server/naslServer.d.ts +1 -1
- package/out/server/naslServer.js +4 -2
- package/out/server/naslServer.js.map +1 -1
- package/out/translator/utils.js +24 -28
- package/out/translator/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/common/BaseNode.ts +92 -68
- package/src/concepts/Anchor__.ts +3 -1
- package/src/concepts/AnonymousFunction__.ts +10 -3
- package/src/concepts/App__.ts +69 -18
- package/src/concepts/Argument__.ts +3 -1
- package/src/concepts/Assignee__.ts +18 -5
- package/src/concepts/AssignmentLine__.ts +6 -2
- package/src/concepts/Assignment__.ts +6 -2
- package/src/concepts/Attribute__.ts +3 -1
- package/src/concepts/AuthLogicForCallInterface__.ts +4 -1
- package/src/concepts/AuthLogic__.ts +3 -0
- package/src/concepts/BackendVariable__.ts +3 -1
- package/src/concepts/Backend__.ts +4 -1
- package/src/concepts/BatchAssignment__.ts +11 -3
- package/src/concepts/BinaryExpression__.ts +6 -2
- package/src/concepts/BindAttribute__.ts +20 -7
- package/src/concepts/BindDirective__.ts +7 -2
- package/src/concepts/BindEvent__.ts +8 -2
- package/src/concepts/BindStyle__.ts +7 -2
- package/src/concepts/CallAuthInterface__.ts +4 -1
- package/src/concepts/CallFunction__.ts +8 -2
- package/src/concepts/CallInterface__.ts +49 -14
- package/src/concepts/CallLogic__.ts +11 -3
- package/src/concepts/CallQueryComponent__.ts +34 -10
- package/src/concepts/CompletionProperty__.ts +3 -1
- package/src/concepts/ConfigGroup__.ts +4 -1
- package/src/concepts/ConfigProperty__.ts +4 -1
- package/src/concepts/Configuration__.ts +4 -1
- package/src/concepts/Connection__.ts +4 -1
- package/src/concepts/Connector__.ts +26 -7
- package/src/concepts/Constant__.ts +3 -1
- package/src/concepts/DataSource__.ts +4 -1
- package/src/concepts/Destination__.ts +7 -2
- package/src/concepts/EntityIndex__.ts +3 -1
- package/src/concepts/EntityProperty__.ts +9 -3
- package/src/concepts/Entity__.ts +8 -2
- package/src/concepts/Enum__.ts +4 -1
- package/src/concepts/Event__.ts +4 -1
- package/src/concepts/ExternalDestination__.ts +6 -2
- package/src/concepts/ForEachStatement__.ts +19 -6
- package/src/concepts/FrontendLibrary__.ts +8 -2
- package/src/concepts/Frontend__.ts +19 -5
- package/src/concepts/Function__.ts +19 -5
- package/src/concepts/IfStatement__.ts +11 -3
- package/src/concepts/Integration__.ts +7 -2
- package/src/concepts/InterfaceParam__.ts +3 -1
- package/src/concepts/Interface__.ts +11 -3
- package/src/concepts/Logic__.ts +62 -57
- package/src/concepts/MatchCase__.ts +8 -2
- package/src/concepts/Match__.ts +7 -2
- package/src/concepts/MemberExpression__.ts +6 -2
- package/src/concepts/Module__.ts +55 -14
- package/src/concepts/MsgTriggerEvent__.ts +4 -1
- package/src/concepts/MsgTriggerLauncher__.ts +4 -1
- package/src/concepts/Namespace__.ts +48 -12
- package/src/concepts/NewComposite__.ts +15 -4
- package/src/concepts/NewList__.ts +7 -2
- package/src/concepts/NewMap__.ts +11 -3
- package/src/concepts/NumericLiteral__.ts +3 -1
- package/src/concepts/OqlQueryComponent__.ts +3 -1
- package/src/concepts/OverriddenLogic__.ts +28 -8
- package/src/concepts/Param__.ts +3 -1
- package/src/concepts/ProcessComponent__.ts +8 -2
- package/src/concepts/ProcessElement__.ts +30 -8
- package/src/concepts/ProcessOutcomes__.ts +3 -1
- package/src/concepts/Process__.ts +20 -5
- package/src/concepts/QueryAggregateExpression__.ts +3 -1
- package/src/concepts/QueryFromExpression__.ts +4 -1
- package/src/concepts/QueryGroupByExpression__.ts +3 -1
- package/src/concepts/QueryJoinExpression__.ts +8 -2
- package/src/concepts/QueryLimitExpression__.ts +6 -2
- package/src/concepts/QueryOrderByExpression__.ts +6 -2
- package/src/concepts/QuerySelectExpression__.ts +4 -1
- package/src/concepts/Return__.ts +3 -1
- package/src/concepts/SelectMembers__.ts +7 -2
- package/src/concepts/Slot__.ts +3 -1
- package/src/concepts/SqlQueryComponent__.ts +3 -1
- package/src/concepts/StringInterpolation__.ts +4 -1
- package/src/concepts/StructureProperty__.ts +3 -1
- package/src/concepts/Structure__.ts +8 -2
- package/src/concepts/SwitchCase__.ts +7 -2
- package/src/concepts/SwitchStatement__.ts +4 -1
- package/src/concepts/TriggerEvent__.ts +4 -1
- package/src/concepts/TypeAnnotation__.ts +13 -4
- package/src/concepts/UnaryExpression__.ts +3 -1
- package/src/concepts/ValidationRule__.ts +10 -3
- package/src/concepts/Variable__.ts +3 -1
- package/src/concepts/ViewComponent__.ts +24 -6
- package/src/concepts/ViewElement__.ts +92 -72
- package/src/concepts/View__.ts +27 -7
- package/src/concepts/WhileStatement__.ts +7 -2
- package/src/concepts/types__.ts +2 -4
- package/src/decorators/index.ts +7 -5
- package/src/natural/genNaturalTS.ts +1 -1
- package/src/natural/transformTSCode.ts +11 -5
- package/src/server/formatTsUtils.ts +8 -8
- package/src/server/getMemberIdentifier.ts +4 -4
- package/src/server/naslServer.ts +4 -4
- package/src/service/storage/init.ts +2 -2
- package/src/translator/utils.ts +7 -9
|
@@ -55,13 +55,19 @@ export class Structure extends BaseNode {
|
|
|
55
55
|
/**
|
|
56
56
|
* 类型参数列表
|
|
57
57
|
*/
|
|
58
|
-
@property(
|
|
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(
|
|
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(
|
|
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(
|
|
42
|
+
@property({
|
|
43
|
+
objectRef: 'LogicItem',
|
|
44
|
+
isArray: true,
|
|
45
|
+
})
|
|
41
46
|
consequent: Array<LogicItem> = [];
|
|
42
47
|
|
|
43
48
|
/**
|
|
@@ -139,13 +139,19 @@ export class TypeAnnotation extends BaseNode {
|
|
|
139
139
|
/**
|
|
140
140
|
* 类型参数
|
|
141
141
|
*/
|
|
142
|
-
@property(
|
|
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(
|
|
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(
|
|
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
|
// 是否包含系统类型
|
|
@@ -57,20 +57,27 @@ export class ValidationRule extends LogicItem {
|
|
|
57
57
|
/**
|
|
58
58
|
* 实际参数
|
|
59
59
|
*/
|
|
60
|
-
@property(
|
|
60
|
+
@property({
|
|
61
|
+
objectRef: 'Argument',
|
|
62
|
+
isArray: true,
|
|
63
|
+
})
|
|
61
64
|
arguments: Array<Argument> = [];
|
|
62
65
|
|
|
63
66
|
/**
|
|
64
67
|
* 错误信息
|
|
65
68
|
*/
|
|
66
|
-
@property(
|
|
69
|
+
@property({
|
|
70
|
+
objectRef: 'LogicItem',
|
|
71
|
+
})
|
|
67
72
|
// @ts-ignore
|
|
68
73
|
errorMessage!: LogicItem;
|
|
69
74
|
|
|
70
75
|
/**
|
|
71
76
|
* 验证对象
|
|
72
77
|
*/
|
|
73
|
-
@property(
|
|
78
|
+
@property({
|
|
79
|
+
objectRef: 'LogicItem',
|
|
80
|
+
})
|
|
74
81
|
// @ts-ignore
|
|
75
82
|
target!: LogicItem;
|
|
76
83
|
|
|
@@ -63,37 +63,55 @@ export class ViewComponent extends BaseNode {
|
|
|
63
63
|
/**
|
|
64
64
|
* 组件属性列表
|
|
65
65
|
*/
|
|
66
|
-
@property(
|
|
66
|
+
@property({
|
|
67
|
+
objectRef: 'Attribute',
|
|
68
|
+
isArray: true,
|
|
69
|
+
})
|
|
67
70
|
attrs: Array<Attribute> = [];
|
|
68
71
|
|
|
69
72
|
/**
|
|
70
73
|
* 组件事件列表
|
|
71
74
|
*/
|
|
72
|
-
@property(
|
|
75
|
+
@property({
|
|
76
|
+
objectRef: 'Event',
|
|
77
|
+
isArray: true,
|
|
78
|
+
})
|
|
73
79
|
events: Array<Event> = [];
|
|
74
80
|
|
|
75
81
|
/**
|
|
76
82
|
* 插槽列表
|
|
77
83
|
*/
|
|
78
|
-
@property(
|
|
84
|
+
@property({
|
|
85
|
+
objectRef: 'Slot',
|
|
86
|
+
isArray: true,
|
|
87
|
+
})
|
|
79
88
|
slots: Array<Slot> = [];
|
|
80
89
|
|
|
81
90
|
/**
|
|
82
91
|
* 逻辑列表
|
|
83
92
|
*/
|
|
84
|
-
@property(
|
|
93
|
+
@property({
|
|
94
|
+
objectRef: 'Logic',
|
|
95
|
+
isArray: true,
|
|
96
|
+
})
|
|
85
97
|
methods: Array<Logic> = [];
|
|
86
98
|
|
|
87
99
|
/**
|
|
88
100
|
* 页面组件列表
|
|
89
101
|
*/
|
|
90
|
-
@property(
|
|
102
|
+
@property({
|
|
103
|
+
objectRef: 'ViewComponent',
|
|
104
|
+
isArray: true,
|
|
105
|
+
})
|
|
91
106
|
children: Array<ViewComponent> = [];
|
|
92
107
|
|
|
93
108
|
/**
|
|
94
109
|
* 页面代码块列表
|
|
95
110
|
*/
|
|
96
|
-
@property(
|
|
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(
|
|
328
|
+
@property({
|
|
329
|
+
objectRef: 'BindAttribute',
|
|
330
|
+
isArray: true,
|
|
331
|
+
})
|
|
329
332
|
bindAttrs: Array<BindAttribute> = [];
|
|
330
333
|
|
|
331
334
|
/**
|
|
332
335
|
* 元素绑定事件列表
|
|
333
336
|
*/
|
|
334
|
-
@property(
|
|
337
|
+
@property({
|
|
338
|
+
objectRef: 'BindEvent',
|
|
339
|
+
isArray: true,
|
|
340
|
+
})
|
|
335
341
|
bindEvents: Array<BindEvent> = [];
|
|
336
342
|
|
|
337
343
|
/**
|
|
338
344
|
* 元素指令列表
|
|
339
345
|
*/
|
|
340
|
-
@property(
|
|
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(
|
|
363
|
+
@property({
|
|
364
|
+
objectRef: 'BindStyle',
|
|
365
|
+
isArray: true,
|
|
366
|
+
})
|
|
353
367
|
bindStyles: Array<BindStyle> = [];
|
|
354
368
|
|
|
355
369
|
/**
|
|
356
370
|
* 子元素列表
|
|
357
371
|
*/
|
|
358
|
-
@property(
|
|
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
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
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 += `
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
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
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
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
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
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) =>
|
|
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();
|
package/src/concepts/View__.ts
CHANGED
|
@@ -126,43 +126,63 @@ export class View extends BaseNode {
|
|
|
126
126
|
/**
|
|
127
127
|
* 页面元素列表
|
|
128
128
|
*/
|
|
129
|
-
@property(
|
|
129
|
+
@property({
|
|
130
|
+
objectRef: 'ViewElement',
|
|
131
|
+
isArray: true,
|
|
132
|
+
})
|
|
130
133
|
elements: Array<ViewElement> = [];
|
|
131
134
|
|
|
132
135
|
/**
|
|
133
136
|
* 输入参数列表
|
|
134
137
|
*/
|
|
135
|
-
@property(
|
|
138
|
+
@property({
|
|
139
|
+
objectRef: 'Param',
|
|
140
|
+
isArray: true,
|
|
141
|
+
})
|
|
136
142
|
params: Array<Param> = [];
|
|
137
143
|
|
|
138
144
|
/**
|
|
139
145
|
* 变量列表
|
|
140
146
|
*/
|
|
141
|
-
@property(
|
|
147
|
+
@property({
|
|
148
|
+
objectRef: 'Variable',
|
|
149
|
+
isArray: true,
|
|
150
|
+
})
|
|
142
151
|
variables: Array<Variable> = [];
|
|
143
152
|
|
|
144
153
|
/**
|
|
145
154
|
* 逻辑列表
|
|
146
155
|
*/
|
|
147
|
-
@property(
|
|
156
|
+
@property({
|
|
157
|
+
objectRef: 'Logic',
|
|
158
|
+
isArray: true,
|
|
159
|
+
})
|
|
148
160
|
logics: Array<Logic> = [];
|
|
149
161
|
|
|
150
162
|
/**
|
|
151
163
|
* 元素绑定事件列表
|
|
152
164
|
*/
|
|
153
|
-
@property(
|
|
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(
|
|
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(
|
|
33
|
+
@property({
|
|
34
|
+
objectRef: 'LogicItem',
|
|
35
|
+
})
|
|
34
36
|
// @ts-ignore
|
|
35
37
|
test!: LogicItem;
|
|
36
38
|
|
|
37
39
|
/**
|
|
38
40
|
* 循环体
|
|
39
41
|
*/
|
|
40
|
-
@property(
|
|
42
|
+
@property({
|
|
43
|
+
objectRef: 'LogicItem',
|
|
44
|
+
isArray: true,
|
|
45
|
+
})
|
|
41
46
|
body: Array<LogicItem> = [];
|
|
42
47
|
|
|
43
48
|
/**
|
package/src/concepts/types__.ts
CHANGED
|
@@ -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
|
|
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
|
|
246
|
+
export type SyntaxNodeConcept = SyntaxNode['concept'];
|
package/src/decorators/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BaseNode from '../common/BaseNode';
|
|
2
|
-
import type {
|
|
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(
|
|
76
|
-
|
|
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:
|
|
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
|
|
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
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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 (
|
|
291
|
+
if (!isPageLogic(contextLogicName)) {
|
|
286
292
|
return new naslTypes.CallLogic({
|
|
287
293
|
calleeNamespace: 'nasl.util',
|
|
288
294
|
calleeName: 'consoleLog',
|