@lcap/nasl 2.20.0-beta.1 → 2.20.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/automate/engine/index.d.ts +1 -1
- package/out/automate/engine/index.js +7 -7
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +1 -1
- package/out/automate/engine/uniqueName.js +3 -3
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/template/myProcess.js +1 -1
- package/out/automate/template/myProcess.js.map +1 -1
- package/out/bak/translator.js +38 -85
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.d.ts +10 -6
- package/out/common/BaseNode.js +53 -7
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +1 -0
- package/out/concepts/AnonymousFunction__.js +40 -2
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.d.ts +89 -261
- package/out/concepts/App__.js +315 -367
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/AssignmentLine__.d.ts +5 -5
- package/out/concepts/AssignmentLine__.js +6 -6
- package/out/concepts/AssignmentLine__.js.map +1 -1
- package/out/concepts/Assignment__.js +1 -2
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +62 -60
- package/out/concepts/BatchAssignment__.js +113 -42
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +24 -0
- package/out/concepts/BindAttribute__.js +54 -4
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +5 -0
- package/out/concepts/BindDirective__.js +6 -0
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +5 -0
- package/out/concepts/BindEvent__.js +6 -0
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +7 -2
- package/out/concepts/BindStyle__.js +9 -3
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.js +0 -8
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +90 -38
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +7 -0
- package/out/concepts/CallInterface__.js +54 -7
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +2 -1
- package/out/concepts/CallLogic__.js +171 -37
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +16 -1
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js +3 -0
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Constant__.d.ts +5 -0
- package/out/concepts/Constant__.js +6 -0
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +8 -0
- package/out/concepts/DataSource__.js +96 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +11 -2
- package/out/concepts/Destination__.js +156 -51
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +21 -8
- package/out/concepts/EntityProperty__.js +109 -23
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +32 -0
- package/out/concepts/Entity__.js +117 -2
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.js +0 -4
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ExternalDestination__.d.ts +73 -0
- package/out/concepts/ExternalDestination__.js +264 -0
- package/out/concepts/ExternalDestination__.js.map +1 -0
- package/out/concepts/ForEachStatement__.d.ts +0 -4
- package/out/concepts/ForEachStatement__.js +4 -8
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +370 -0
- package/out/concepts/Frontend__.js +669 -0
- package/out/concepts/Frontend__.js.map +1 -0
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +1 -0
- package/out/concepts/Identifier__.js +33 -10
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.d.ts +8 -0
- package/out/concepts/IfStatement__.js +22 -0
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +6 -1
- package/out/concepts/LogicItem__.js +6 -0
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +91 -80
- package/out/concepts/Logic__.js +178 -59
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.d.ts +1 -1
- package/out/concepts/MatchCase__.js +15 -8
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.d.ts +21 -19
- package/out/concepts/Match__.js +118 -26
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +4 -1
- package/out/concepts/MemberExpression__.js +30 -15
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +345 -0
- package/out/concepts/NewComposite__.js +1068 -0
- package/out/concepts/NewComposite__.js.map +1 -0
- package/out/concepts/NewList__.d.ts +130 -0
- package/out/concepts/NewList__.js +349 -0
- package/out/concepts/NewList__.js.map +1 -0
- package/out/concepts/NewMap__.d.ts +221 -0
- package/out/concepts/NewMap__.js +480 -0
- package/out/concepts/NewMap__.js.map +1 -0
- package/out/concepts/New__.d.ts +19 -0
- package/out/concepts/New__.js +66 -0
- package/out/concepts/New__.js.map +1 -0
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.d.ts +7 -3
- package/out/concepts/OqlQueryComponent__.js +56 -95
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.d.ts +8 -1
- package/out/concepts/Param__.js +85 -6
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +42 -13
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcomes__.d.ts +30 -0
- package/out/concepts/ProcessOutcomes__.js +87 -0
- package/out/concepts/ProcessOutcomes__.js.map +1 -0
- package/out/concepts/Process__.d.ts +4 -20
- package/out/concepts/Process__.js +0 -7
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.d.ts +3 -3
- package/out/concepts/QueryOrderByExpression__.js +3 -3
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Return__.d.ts +5 -0
- package/out/concepts/Return__.js +45 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/SelectMembers__.d.ts +1 -1
- package/out/concepts/SelectMembers__.js +5 -5
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +2 -4
- package/out/concepts/SqlQueryComponent__.js +9 -88
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringInterpolation__.d.ts +113 -0
- package/out/concepts/StringInterpolation__.js +227 -0
- package/out/concepts/StringInterpolation__.js.map +1 -0
- package/out/concepts/StringLiteral__.js +0 -7
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/Transactional__.d.ts +5 -0
- package/out/concepts/Transactional__.js +6 -0
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +4 -0
- package/out/concepts/TypeAnnotation__.js +67 -15
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +1 -0
- package/out/concepts/TypeParam__.js +2 -0
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +6 -9
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +87 -22
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +5 -0
- package/out/concepts/Variable__.js +46 -3
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +35 -29
- package/out/concepts/ViewElement__.js +138 -54
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +10 -3
- package/out/concepts/View__.js +116 -86
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +1 -1
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.browser.js +50 -0
- package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.logging.js +5 -0
- package/out/concepts/basics/stdlib/nasl.logging.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +38 -4
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +214 -62
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/index__.d.ts +9 -0
- package/out/concepts/index__.js +9 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.d.ts +1 -0
- package/out/enums/KEYWORDS.js +9 -1
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +10 -4
- package/out/generator/genBundleFiles.js +127 -162
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +2 -11
- package/out/generator/genMetaData.js +185 -51
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +57 -0
- package/out/generator/genReleaseBody.js +380 -0
- package/out/generator/genReleaseBody.js.map +1 -0
- package/out/generator/index.d.ts +2 -0
- package/out/generator/index.js +2 -0
- package/out/generator/index.js.map +1 -1
- package/out/generator/permission.d.ts +17 -0
- package/out/generator/permission.js +221 -0
- package/out/generator/permission.js.map +1 -0
- package/out/index.d.ts +3 -2
- package/out/index.js +7 -1
- package/out/index.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +100 -20
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +33 -20
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +1 -2
- package/out/server/formatTsUtils.js +46 -64
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.d.ts +2 -1
- package/out/server/getLogics.js +24 -6
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +11 -11
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +1 -1
- package/out/server/getProcesses.js +1 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/index.d.ts +0 -1
- package/out/server/index.js +2 -27
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +50 -8
- package/out/server/naslServer.js +816 -429
- package/out/server/naslServer.js.map +1 -1
- package/out/server/naslStdlibMap.js +30 -28
- package/out/server/naslStdlibMap.js.map +1 -1
- package/out/server/process2LogicNamespace.js +8 -0
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.js +90 -12
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/add.configs.js +4 -0
- package/out/service/creator/add.configs.js.map +1 -1
- package/out/service/datasource/api.d.ts +12 -0
- package/out/service/datasource/api.js +14 -0
- package/out/service/datasource/api.js.map +1 -0
- package/out/service/datasource/index.d.ts +2 -0
- package/out/service/datasource/index.js +10 -0
- package/out/service/datasource/index.js.map +1 -0
- package/out/service/defaultErrorMessage.json +97 -0
- package/out/service/logic/api.d.ts +9 -0
- package/out/service/logic/api.js +11 -0
- package/out/service/logic/api.js.map +1 -0
- package/out/service/logic/index.d.ts +2 -0
- package/out/service/logic/index.js +10 -0
- package/out/service/logic/index.js.map +1 -0
- package/out/service/storage/init.js +48 -7
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +6 -4
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +7 -4
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +7 -5
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +4 -5
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +5 -2
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +4 -3
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +18 -16
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -7
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.d.ts +2 -2
- package/out/templator/genQueryComponent.js +4 -1
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genTableBlock.js +8 -12
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +4 -3
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.js +1 -1
- package/out/templator/utils.js.map +1 -1
- package/out/test/integration/node-nasl-server.js +10 -38
- package/out/test/integration/node-nasl-server.js.map +1 -1
- package/out/translator/index.d.ts +1 -0
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/index.d.ts +1 -0
- package/out/utils/index.js +38 -1
- package/out/utils/index.js.map +1 -1
- package/out/utils/string.d.ts +15 -2
- package/out/utils/string.js +18 -3
- package/out/utils/string.js.map +1 -1
- package/package.json +1 -1
- package/src/concepts/App__.ts +11 -36
- package/src/concepts/Frontend__.ts +8 -0
- package/src/concepts/ViewElement__.ts +7 -28
- package/src/concepts/View__.ts +1 -1
- package/src/server/getLogics.ts +2 -2
- package/src/server/naslServer.ts +8 -8
- package/src/service/storage/init.ts +3 -4
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { TranslatorState } from '../translator';
|
|
2
|
+
import ForEachStatement from './ForEachStatement__';
|
|
2
3
|
import Assignment from './Assignment__';
|
|
3
4
|
import BatchAssignment from './BatchAssignment__';
|
|
5
|
+
import MatchCase from './MatchCase__';
|
|
4
6
|
import { EventPayload, Params } from '../common/EventEmitter';
|
|
5
7
|
import BaseNode from '../common/BaseNode';
|
|
6
8
|
import Transactional from './Transactional__';
|
|
@@ -13,6 +15,7 @@ import Module from './Module__';
|
|
|
13
15
|
import View from './View__';
|
|
14
16
|
import ProcessElement from './ProcessElement__';
|
|
15
17
|
import App from './App__';
|
|
18
|
+
import Frontend from './Frontend__';
|
|
16
19
|
import Process from './Process__';
|
|
17
20
|
/**
|
|
18
21
|
* 逻辑
|
|
@@ -87,6 +90,10 @@ export declare class Logic extends BaseNode {
|
|
|
87
90
|
* 祖先 View
|
|
88
91
|
*/
|
|
89
92
|
get view(): View;
|
|
93
|
+
/**
|
|
94
|
+
* 祖先 Frontend
|
|
95
|
+
*/
|
|
96
|
+
get frontend(): Frontend;
|
|
90
97
|
/**
|
|
91
98
|
* 祖先 ProcessElement
|
|
92
99
|
*/
|
|
@@ -128,22 +135,22 @@ export declare class Logic extends BaseNode {
|
|
|
128
135
|
getTypeParamExistingNames(excludedList?: Array<TypeParam>): string[];
|
|
129
136
|
getTypeParamUniqueName(name?: string): string;
|
|
130
137
|
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
138
|
+
* 插入类型参数
|
|
139
|
+
* @internal
|
|
140
|
+
* @param name 类型参数名称,如果不填会自动生成一个唯一名称
|
|
141
|
+
*/
|
|
135
142
|
_insertTypeParamAt(name: string, index: number): TypeParam;
|
|
136
143
|
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
144
|
+
* 插入类型参数
|
|
145
|
+
* @internal
|
|
146
|
+
* @param typeParamOptions 类型参数参数
|
|
147
|
+
*/
|
|
141
148
|
_insertTypeParamAt(typeParamOptions: Partial<TypeParam>, index: number): TypeParam;
|
|
142
149
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
* 插入类型参数
|
|
151
|
+
* @internal
|
|
152
|
+
* @param typeParam 已有的类型参数实例
|
|
153
|
+
*/
|
|
147
154
|
_insertTypeParamAt(typeParam: TypeParam, index: number): TypeParam;
|
|
148
155
|
/**
|
|
149
156
|
* 插入类型参数
|
|
@@ -196,22 +203,22 @@ export declare class Logic extends BaseNode {
|
|
|
196
203
|
addTypeParam(typeParam: TypeParam): TypeParam;
|
|
197
204
|
getParamUniqueName(name?: string): string;
|
|
198
205
|
/**
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
206
|
+
* 插入输入参数
|
|
207
|
+
* @internal
|
|
208
|
+
* @param name 输入参数名称,如果不填会自动生成一个唯一名称
|
|
209
|
+
*/
|
|
203
210
|
_insertParamAt(name: string, index: number): Param;
|
|
204
211
|
/**
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
212
|
+
* 插入输入参数
|
|
213
|
+
* @internal
|
|
214
|
+
* @param paramOptions 输入参数参数
|
|
215
|
+
*/
|
|
209
216
|
_insertParamAt(paramOptions: Partial<Param>, index: number): Param;
|
|
210
217
|
/**
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
218
|
+
* 插入输入参数
|
|
219
|
+
* @internal
|
|
220
|
+
* @param param 已有的输入参数实例
|
|
221
|
+
*/
|
|
215
222
|
_insertParamAt(param: Param, index: number): Param;
|
|
216
223
|
/**
|
|
217
224
|
* 插入输入参数
|
|
@@ -264,22 +271,22 @@ export declare class Logic extends BaseNode {
|
|
|
264
271
|
addParam(param: Param): Param;
|
|
265
272
|
getReturnUniqueName(name?: string): string;
|
|
266
273
|
/**
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
274
|
+
* 插入输出参数
|
|
275
|
+
* @internal
|
|
276
|
+
* @param name 输出参数名称,如果不填会自动生成一个唯一名称
|
|
277
|
+
*/
|
|
271
278
|
_insertReturnAt(name: string, index: number): Return;
|
|
272
279
|
/**
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
280
|
+
* 插入输出参数
|
|
281
|
+
* @internal
|
|
282
|
+
* @param retOptions 输出参数参数
|
|
283
|
+
*/
|
|
277
284
|
_insertReturnAt(retOptions: Partial<Return>, index: number): Return;
|
|
278
285
|
/**
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
286
|
+
* 插入输出参数
|
|
287
|
+
* @internal
|
|
288
|
+
* @param ret 已有的输出参数实例
|
|
289
|
+
*/
|
|
283
290
|
_insertReturnAt(ret: Return, index: number): Return;
|
|
284
291
|
/**
|
|
285
292
|
* 插入输出参数
|
|
@@ -332,22 +339,22 @@ export declare class Logic extends BaseNode {
|
|
|
332
339
|
addReturn(ret: Return): Return;
|
|
333
340
|
getVariableUniqueName(name?: string): string;
|
|
334
341
|
/**
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
342
|
+
* 插入变量
|
|
343
|
+
* @internal
|
|
344
|
+
* @param name 变量名称,如果不填会自动生成一个唯一名称
|
|
345
|
+
*/
|
|
339
346
|
_insertVariableAt(name: string, index: number): Variable;
|
|
340
347
|
/**
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
348
|
+
* 插入变量
|
|
349
|
+
* @internal
|
|
350
|
+
* @param variableOptions 变量参数
|
|
351
|
+
*/
|
|
345
352
|
_insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
|
|
346
353
|
/**
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
354
|
+
* 插入变量
|
|
355
|
+
* @internal
|
|
356
|
+
* @param variable 已有的变量实例
|
|
357
|
+
*/
|
|
351
358
|
_insertVariableAt(variable: Variable, index: number): Variable;
|
|
352
359
|
/**
|
|
353
360
|
* 插入变量
|
|
@@ -399,16 +406,16 @@ export declare class Logic extends BaseNode {
|
|
|
399
406
|
*/
|
|
400
407
|
addVariable(variable: Variable): Variable;
|
|
401
408
|
/**
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
409
|
+
* 插入逻辑项
|
|
410
|
+
* @internal
|
|
411
|
+
* @param logicItemOptions 逻辑项参数
|
|
412
|
+
*/
|
|
406
413
|
_insertItemInBodyAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
|
|
407
414
|
/**
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
415
|
+
* 插入逻辑项
|
|
416
|
+
* @internal
|
|
417
|
+
* @param logicItem 已有的逻辑项实例
|
|
418
|
+
*/
|
|
412
419
|
_insertItemInBodyAt(logicItem: LogicItem, index: number): LogicItem;
|
|
413
420
|
/**
|
|
414
421
|
* 插入逻辑项
|
|
@@ -443,16 +450,16 @@ export declare class Logic extends BaseNode {
|
|
|
443
450
|
*/
|
|
444
451
|
addItemInBody(logicItem: LogicItem): LogicItem;
|
|
445
452
|
/**
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
453
|
+
* 插入逻辑项
|
|
454
|
+
* @internal
|
|
455
|
+
* @param logicItemOptions 逻辑项参数
|
|
456
|
+
*/
|
|
450
457
|
_insertItemInPlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
|
|
451
458
|
/**
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
459
|
+
* 插入逻辑项
|
|
460
|
+
* @internal
|
|
461
|
+
* @param logicItem 已有的逻辑项实例
|
|
462
|
+
*/
|
|
456
463
|
_insertItemInPlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
|
|
457
464
|
/**
|
|
458
465
|
* 插入逻辑项
|
|
@@ -487,9 +494,9 @@ export declare class Logic extends BaseNode {
|
|
|
487
494
|
*/
|
|
488
495
|
addItemInPlayground(logicItem: LogicItem): LogicItem;
|
|
489
496
|
/**
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
497
|
+
* 删除事务
|
|
498
|
+
* @param name 事务名称
|
|
499
|
+
*/
|
|
493
500
|
removeTransactional(name: string): void;
|
|
494
501
|
/**
|
|
495
502
|
* 删除事务
|
|
@@ -498,9 +505,9 @@ export declare class Logic extends BaseNode {
|
|
|
498
505
|
removeTransactional(transactional: Transactional): void;
|
|
499
506
|
__removeTransactional(transactional: Transactional): Params;
|
|
500
507
|
/**
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
508
|
+
* 删除类型参数
|
|
509
|
+
* @param name 类型参数名称
|
|
510
|
+
*/
|
|
504
511
|
removeTypeParam(name: string): void;
|
|
505
512
|
/**
|
|
506
513
|
* 删除类型参数
|
|
@@ -509,9 +516,9 @@ export declare class Logic extends BaseNode {
|
|
|
509
516
|
removeTypeParam(typeParam: TypeParam): void;
|
|
510
517
|
__removeTypeParam(typeParam: TypeParam): Params;
|
|
511
518
|
/**
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
519
|
+
* 删除输入参数
|
|
520
|
+
* @param name 输入参数名称
|
|
521
|
+
*/
|
|
515
522
|
removeParam(name: string): void;
|
|
516
523
|
/**
|
|
517
524
|
* 删除输入参数
|
|
@@ -520,9 +527,9 @@ export declare class Logic extends BaseNode {
|
|
|
520
527
|
removeParam(param: Param): void;
|
|
521
528
|
__removeParam(param: Param): Params;
|
|
522
529
|
/**
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
530
|
+
* 删除输出参数
|
|
531
|
+
* @param name 输出参数名称
|
|
532
|
+
*/
|
|
526
533
|
removeReturn(name: string): void;
|
|
527
534
|
/**
|
|
528
535
|
* 删除输出参数
|
|
@@ -531,9 +538,9 @@ export declare class Logic extends BaseNode {
|
|
|
531
538
|
removeReturn(ret: Return): void;
|
|
532
539
|
__removeReturn(ret: Return): Params;
|
|
533
540
|
/**
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
541
|
+
* 删除变量
|
|
542
|
+
* @param name 变量名称
|
|
543
|
+
*/
|
|
537
544
|
removeVariable(name: string): void;
|
|
538
545
|
/**
|
|
539
546
|
* 删除变量
|
|
@@ -584,7 +591,10 @@ export declare class Logic extends BaseNode {
|
|
|
584
591
|
toEmbeddedTSInProcess(state?: TranslatorState, prependCode?: string, noName?: boolean, prefix?: boolean): string;
|
|
585
592
|
toEmbeddedTSNoExport(state?: TranslatorState): string;
|
|
586
593
|
toEmbeddedTS(state?: TranslatorState, prefix?: string): string;
|
|
587
|
-
getRightCode(code: string, assignment: Assignment | BatchAssignment): string;
|
|
594
|
+
getRightCode(code: string, assignment: Assignment | BatchAssignment, rightNode: any): string;
|
|
595
|
+
handleReplaceCode(code: string, variable: string, replaceCode: string): string;
|
|
596
|
+
handleForEachCode(code: string, forEachStatement: ForEachStatement): string;
|
|
597
|
+
handleMatchCaseCode(code: string, matchCase: MatchCase): string;
|
|
588
598
|
getNamespace(): string;
|
|
589
599
|
getTsNamespace(): string;
|
|
590
600
|
/**
|
|
@@ -615,5 +625,6 @@ export declare class Logic extends BaseNode {
|
|
|
615
625
|
get pathName(): string;
|
|
616
626
|
getEventLogicName(type?: string): string;
|
|
617
627
|
virtualParams: Array<Param>;
|
|
628
|
+
get getLogicBelongTo(): string;
|
|
618
629
|
}
|
|
619
630
|
export default Logic;
|
package/out/concepts/Logic__.js
CHANGED
|
@@ -41,6 +41,10 @@ const Assignment__1 = __importDefault(require("./Assignment__"));
|
|
|
41
41
|
const Identifier__1 = __importDefault(require("./Identifier__"));
|
|
42
42
|
const BindEvent__1 = __importDefault(require("./BindEvent__"));
|
|
43
43
|
const BatchAssignment__1 = __importDefault(require("./BatchAssignment__"));
|
|
44
|
+
const OqlQueryComponent__1 = __importDefault(require("./OqlQueryComponent__"));
|
|
45
|
+
const TypeAnnotation__1 = __importDefault(require("./TypeAnnotation__"));
|
|
46
|
+
const CallInterface__1 = __importDefault(require("./CallInterface__"));
|
|
47
|
+
const CallLogic__1 = __importDefault(require("./CallLogic__"));
|
|
44
48
|
const decorators_1 = require("../decorators");
|
|
45
49
|
const utils = __importStar(require("../utils"));
|
|
46
50
|
const BaseNode_1 = __importDefault(require("../common/BaseNode"));
|
|
@@ -126,6 +130,12 @@ let Logic = Logic_1 = class Logic extends BaseNode_1.default {
|
|
|
126
130
|
get view() {
|
|
127
131
|
return this.getAncestor('View');
|
|
128
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* 祖先 Frontend
|
|
135
|
+
*/
|
|
136
|
+
get frontend() {
|
|
137
|
+
return this.getAncestor('Frontend');
|
|
138
|
+
}
|
|
129
139
|
/**
|
|
130
140
|
* 祖先 ProcessElement
|
|
131
141
|
*/
|
|
@@ -710,11 +720,11 @@ let Logic = Logic_1 = class Logic extends BaseNode_1.default {
|
|
|
710
720
|
return params;
|
|
711
721
|
}
|
|
712
722
|
removeItemInBody(options) {
|
|
713
|
-
|
|
723
|
+
const logicItem = options;
|
|
714
724
|
return logicItem.delete();
|
|
715
725
|
}
|
|
716
726
|
removeItemInPlayground(options) {
|
|
717
|
-
|
|
727
|
+
const logicItem = options;
|
|
718
728
|
return logicItem.delete();
|
|
719
729
|
}
|
|
720
730
|
__removeLogicItem(logicItem) {
|
|
@@ -854,7 +864,7 @@ let Logic = Logic_1 = class Logic extends BaseNode_1.default {
|
|
|
854
864
|
toJS(state, type) {
|
|
855
865
|
let code = '';
|
|
856
866
|
if (type === 'IIFE') {
|
|
857
|
-
code += `(async () => {\n`;
|
|
867
|
+
code += `await (async () => {\n`;
|
|
858
868
|
code = this.toJSContent(code, state);
|
|
859
869
|
code += (0, translator_1.indent)(state?.tabSize || 0) + '})();\n';
|
|
860
870
|
return code;
|
|
@@ -1002,7 +1012,7 @@ let Logic = Logic_1 = class Logic extends BaseNode_1.default {
|
|
|
1002
1012
|
}
|
|
1003
1013
|
this.body.forEach((item) => {
|
|
1004
1014
|
code += item.toEmbeddedTS && item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1005
|
-
code += '
|
|
1015
|
+
code += ';\n';
|
|
1006
1016
|
});
|
|
1007
1017
|
}
|
|
1008
1018
|
// 在body渲染完成之后把其余的节点放到下面
|
|
@@ -1029,20 +1039,24 @@ let Logic = Logic_1 = class Logic extends BaseNode_1.default {
|
|
|
1029
1039
|
else if (prefix === 'inObject') {
|
|
1030
1040
|
code += `${this.name}`;
|
|
1031
1041
|
}
|
|
1042
|
+
if (this.typeParams?.length) {
|
|
1043
|
+
code += '<';
|
|
1044
|
+
this.typeParams.forEach((typeParam, typeParamIndex) => {
|
|
1045
|
+
code += typeParam.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
1046
|
+
if (typeParamIndex !== this.typeParams.length - 1)
|
|
1047
|
+
code += ', ';
|
|
1048
|
+
});
|
|
1049
|
+
code += '>';
|
|
1050
|
+
}
|
|
1032
1051
|
// 有参数长度
|
|
1033
1052
|
if (this.params.length) {
|
|
1034
1053
|
code += '(';
|
|
1035
1054
|
this.params.forEach((param, index) => {
|
|
1036
1055
|
code += param.toEmbeddedTS((0, translator_1.shiftState)(state, code));
|
|
1037
|
-
code += ',';
|
|
1038
|
-
});
|
|
1039
|
-
code += '\n, __defaultValues?: { \n';
|
|
1040
|
-
this.params.forEach((param, index) => {
|
|
1041
|
-
code += `${param.name}: "${param.defaultValue || ''}"`;
|
|
1042
1056
|
if (index !== this.params.length - 1)
|
|
1043
|
-
code += '
|
|
1057
|
+
code += ', ';
|
|
1044
1058
|
});
|
|
1045
|
-
code += '
|
|
1059
|
+
code += ')';
|
|
1046
1060
|
}
|
|
1047
1061
|
else {
|
|
1048
1062
|
// 没有参数的
|
|
@@ -1050,6 +1064,7 @@ let Logic = Logic_1 = class Logic extends BaseNode_1.default {
|
|
|
1050
1064
|
}
|
|
1051
1065
|
// 需要类型推导的局部变量/返回值需要调整申明顺序
|
|
1052
1066
|
const advanceMap = new Map();
|
|
1067
|
+
const needGetSourceMapOqlList = [];
|
|
1053
1068
|
this.traverseChildren((el) => {
|
|
1054
1069
|
if (el && (el instanceof BatchAssignment__1.default || (el instanceof Assignment__1.default && el.left?.name))) {
|
|
1055
1070
|
const jsCode = el.toJS();
|
|
@@ -1062,31 +1077,42 @@ let Logic = Logic_1 = class Logic extends BaseNode_1.default {
|
|
|
1062
1077
|
advanceMap.set(advanceRn, el);
|
|
1063
1078
|
}
|
|
1064
1079
|
}
|
|
1080
|
+
// 如果有sql查询组件就需要把他们存起来
|
|
1081
|
+
if (el instanceof OqlQueryComponent__1.default) {
|
|
1082
|
+
if (!el.codeSourceMap) {
|
|
1083
|
+
needGetSourceMapOqlList.push(el.requestEmbeddedTS());
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1065
1086
|
});
|
|
1087
|
+
if (needGetSourceMapOqlList.length) {
|
|
1088
|
+
Promise.all(needGetSourceMapOqlList).then(() => {
|
|
1089
|
+
// 触发一下更新重新生成代码
|
|
1090
|
+
this.app?.naslServer?.embeddedTSEmitter.emit('change', {
|
|
1091
|
+
value: [
|
|
1092
|
+
{
|
|
1093
|
+
originEvent: {
|
|
1094
|
+
action: 'update',
|
|
1095
|
+
target: this,
|
|
1096
|
+
},
|
|
1097
|
+
},
|
|
1098
|
+
],
|
|
1099
|
+
});
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1066
1102
|
// 兼容 return 没有类型情况
|
|
1067
1103
|
if (this.returns.length && this.returns[0].typeAnnotation) {
|
|
1068
1104
|
code += ': ';
|
|
1069
1105
|
code += this.returns[0].typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
1070
1106
|
}
|
|
1071
|
-
if (prefix === 'arrowFunction') {
|
|
1072
|
-
code += ` => `;
|
|
1073
|
-
}
|
|
1074
1107
|
code += '{\n';
|
|
1075
|
-
if (this.typeParams?.length) {
|
|
1076
|
-
code += '<';
|
|
1077
|
-
this.typeParams.forEach((typeParam, typeParamIndex) => {
|
|
1078
|
-
code += typeParam.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
1079
|
-
if (typeParamIndex !== this.typeParams.length - 1)
|
|
1080
|
-
code += ', ';
|
|
1081
|
-
});
|
|
1082
|
-
code += '>';
|
|
1083
|
-
}
|
|
1084
1108
|
// 用于虚拟节点的查找引用
|
|
1085
|
-
this.virtualParams
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1109
|
+
this.virtualParams
|
|
1110
|
+
&& Array.isArray(this.virtualParams)
|
|
1111
|
+
&& this.virtualParams.forEach((param) => {
|
|
1112
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 1);
|
|
1113
|
+
code += param.toEmbeddedNameTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
1114
|
+
code += '\n';
|
|
1115
|
+
});
|
|
1090
1116
|
this.variables.forEach((variable) => {
|
|
1091
1117
|
if (!advanceMap.get(variable)) {
|
|
1092
1118
|
code += (0, translator_1.indent)((state?.tabSize || 0) + 1) + 'let ';
|
|
@@ -1102,25 +1128,49 @@ let Logic = Logic_1 = class Logic extends BaseNode_1.default {
|
|
|
1102
1128
|
}
|
|
1103
1129
|
});
|
|
1104
1130
|
advanceMap.forEach((assignment, node) => {
|
|
1131
|
+
code += (0, translator_1.indent)((state?.tabSize || 0) + 1) + '// @ts-ignore\n';
|
|
1105
1132
|
code += (0, translator_1.indent)((state?.tabSize || 0) + 1) + 'let ';
|
|
1106
1133
|
code += node.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
1107
|
-
code += ' = ';
|
|
1108
1134
|
if (assignment instanceof BatchAssignment__1.default) {
|
|
1109
1135
|
assignment.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
|
|
1110
1136
|
const leftCode = leftIndex.length === 1 ? assignment.left.expression.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) : assignment.left.members[leftIndex[1]]?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
1111
1137
|
if (leftCode === node.name) {
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1138
|
+
const rightNode = rightIndex.length === 1 ? assignment.rights[rightIndex[0]]?.expression : assignment.rights[rightIndex[0]]?.members[rightIndex[1]];
|
|
1139
|
+
// 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
|
|
1140
|
+
if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent__1.default && rightNode.ideVersion !== '2.11')) {
|
|
1141
|
+
code += ': ';
|
|
1142
|
+
code += rightNode.typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
|
|
1143
|
+
}
|
|
1144
|
+
else {
|
|
1145
|
+
code += ' = ';
|
|
1146
|
+
const rightCode = rightNode?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
1147
|
+
code += this.getRightCode(rightCode, assignment, rightNode);
|
|
1148
|
+
}
|
|
1114
1149
|
}
|
|
1115
1150
|
});
|
|
1116
1151
|
}
|
|
1152
|
+
else if (['NewList', 'NewMap'].includes(assignment.right.concept) && !assignment.right.typeAnnotation) {
|
|
1153
|
+
const rightNode = assignment.right;
|
|
1154
|
+
code += ' = ';
|
|
1155
|
+
code += rightNode.getInitCode((0, translator_1.shiftState)(state, code, { inline: true }));
|
|
1156
|
+
}
|
|
1117
1157
|
else {
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1158
|
+
const rightNode = assignment.right;
|
|
1159
|
+
// 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
|
|
1160
|
+
if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent__1.default && rightNode.ideVersion !== '2.11')) {
|
|
1161
|
+
code += ': ';
|
|
1162
|
+
code += rightNode.typeAnnotation?.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) || 'null';
|
|
1163
|
+
}
|
|
1164
|
+
else {
|
|
1165
|
+
code += ' = ';
|
|
1166
|
+
let rightCode = '';
|
|
1167
|
+
// 因为右侧枚举要赋值就得new 一下;
|
|
1168
|
+
if (rightNode && rightNode instanceof Identifier__1.default && rightNode.namespace && rightNode.namespace.endsWith('enums')) {
|
|
1169
|
+
rightCode += 'new ';
|
|
1170
|
+
}
|
|
1171
|
+
rightCode += rightNode && rightNode.toEmbeddedTS ? rightNode.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) : '__RIGHT__';
|
|
1172
|
+
code += this.getRightCode(rightCode, assignment, rightNode);
|
|
1121
1173
|
}
|
|
1122
|
-
const rightCode = (assignment.right && assignment.right.toEmbeddedTS) ? assignment.right.toEmbeddedTS((0, translator_1.shiftState)(state, code, { inline: true })) : '__RIGHT__';
|
|
1123
|
-
code += this.getRightCode(rightCode, assignment);
|
|
1124
1174
|
}
|
|
1125
1175
|
code += ';\n';
|
|
1126
1176
|
});
|
|
@@ -1135,7 +1185,7 @@ let Logic = Logic_1 = class Logic extends BaseNode_1.default {
|
|
|
1135
1185
|
}
|
|
1136
1186
|
this.body.forEach((item) => {
|
|
1137
1187
|
code += item.toEmbeddedTS && item.toEmbeddedTS((0, translator_1.shiftState)(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1138
|
-
code += '
|
|
1188
|
+
code += ';\n';
|
|
1139
1189
|
});
|
|
1140
1190
|
}
|
|
1141
1191
|
// 在body渲染完成之后把其余的节点放到下面
|
|
@@ -1150,34 +1200,97 @@ let Logic = Logic_1 = class Logic extends BaseNode_1.default {
|
|
|
1150
1200
|
code += '\n';
|
|
1151
1201
|
return code;
|
|
1152
1202
|
}
|
|
1153
|
-
getRightCode(code, assignment) {
|
|
1203
|
+
getRightCode(code, assignment, rightNode) {
|
|
1154
1204
|
if (assignment instanceof Assignment__1.default && !assignment.right)
|
|
1155
1205
|
return code;
|
|
1206
|
+
// 调用接口,参数替换成 null
|
|
1207
|
+
if (rightNode instanceof CallInterface__1.default) {
|
|
1208
|
+
const { _interface } = rightNode.getModuleInterface();
|
|
1209
|
+
return _interface ? `${rightNode.tsCalleeKey}(${_interface.params.map(() => 'null').join(',')})` : null;
|
|
1210
|
+
}
|
|
1211
|
+
// 调用全局逻辑,参数替换成 null
|
|
1212
|
+
if (rightNode instanceof CallLogic__1.default && rightNode.calleeNamespace === 'app.logics') {
|
|
1213
|
+
const calleeName = rightNode?.calleeName;
|
|
1214
|
+
const calleeLogic = this.app.logics.find((l) => l.name === calleeName);
|
|
1215
|
+
return calleeLogic ? `app.logics.${calleeName}(${calleeLogic.params.map(() => 'null').join(',')})` : null;
|
|
1216
|
+
}
|
|
1156
1217
|
// ForEachStatement 内部变量需要替换处理,如 item、index
|
|
1157
1218
|
const forEachStatement = assignment.getAncestor('ForEachStatement');
|
|
1158
1219
|
if (forEachStatement) {
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1220
|
+
code = this.handleForEachCode(code, forEachStatement);
|
|
1221
|
+
}
|
|
1222
|
+
// Match 需要针对分支缩小类型范围
|
|
1223
|
+
const matchCase = assignment.getAncestor('MatchCase');
|
|
1224
|
+
if (matchCase) {
|
|
1225
|
+
code = this.handleMatchCaseCode(code, matchCase);
|
|
1226
|
+
}
|
|
1227
|
+
return code;
|
|
1228
|
+
}
|
|
1229
|
+
handleReplaceCode(code, variable, replaceCode) {
|
|
1230
|
+
return code.replace(/\S+/g, ($1) => {
|
|
1231
|
+
if ($1 === `${variable},`)
|
|
1232
|
+
return `${replaceCode},`;
|
|
1233
|
+
if ($1 === variable)
|
|
1234
|
+
return replaceCode;
|
|
1235
|
+
let fnCode = $1;
|
|
1236
|
+
if ($1.startsWith(`${variable}.`))
|
|
1237
|
+
fnCode = $1.replaceAll(`${variable}.`, `${replaceCode}.`);
|
|
1238
|
+
if ($1.startsWith(`${variable},`))
|
|
1239
|
+
fnCode = $1.replaceAll(`${variable},`, `${replaceCode},`);
|
|
1240
|
+
if ($1.includes(`(${variable},`))
|
|
1241
|
+
fnCode = $1.replaceAll(`(${variable},`, `(${replaceCode},`);
|
|
1242
|
+
if ($1.includes(`(${variable}.`))
|
|
1243
|
+
fnCode = $1.replaceAll(`(${variable}.`, `(${replaceCode}.`);
|
|
1244
|
+
if ($1.includes(`(${variable})`))
|
|
1245
|
+
fnCode = $1.replaceAll(`(${variable})`, `(${replaceCode})`);
|
|
1246
|
+
if ($1.includes(`,${variable},`))
|
|
1247
|
+
fnCode = $1.replaceAll(`,${variable},`, `,${replaceCode},`);
|
|
1248
|
+
if ($1.includes(`,${variable}.`))
|
|
1249
|
+
fnCode = $1.replaceAll(`,${variable}.`, `,${replaceCode}.`);
|
|
1250
|
+
if ($1.includes(`,${variable})`))
|
|
1251
|
+
fnCode = $1.replaceAll(`,${variable})`, `,${replaceCode})`);
|
|
1252
|
+
return fnCode;
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
handleForEachCode(code, forEachStatement) {
|
|
1256
|
+
const { item, index, each } = forEachStatement;
|
|
1257
|
+
if (code.includes(item.name)) {
|
|
1258
|
+
const eachTSCode = each.toEmbeddedTS();
|
|
1259
|
+
code = this.handleReplaceCode(code, item.name, eachTSCode === '__IDENTIFIER__' ? eachTSCode : `${eachTSCode}.__get(0)`);
|
|
1260
|
+
}
|
|
1261
|
+
if (code.includes(index.name))
|
|
1262
|
+
code = this.handleReplaceCode(code, index.name, 'new nasl.core.Integer(0)');
|
|
1263
|
+
const parentForEachStatement = forEachStatement.getAncestor('ForEachStatement');
|
|
1264
|
+
if (parentForEachStatement) {
|
|
1265
|
+
this.handleForEachCode(code, parentForEachStatement);
|
|
1266
|
+
}
|
|
1267
|
+
return code;
|
|
1268
|
+
}
|
|
1269
|
+
handleMatchCaseCode(code, matchCase) {
|
|
1270
|
+
const match = matchCase.getAncestor('Match');
|
|
1271
|
+
const expressionTsCode = match.expression.toEmbeddedTS();
|
|
1272
|
+
if (code.includes(expressionTsCode)) {
|
|
1273
|
+
let typeCode = '';
|
|
1274
|
+
matchCase.patterns.forEach((pattern, index) => {
|
|
1275
|
+
if (pattern instanceof TypeAnnotation__1.default) {
|
|
1276
|
+
if (index === 0) {
|
|
1277
|
+
typeCode += pattern.toEmbeddedTS();
|
|
1278
|
+
}
|
|
1279
|
+
else {
|
|
1280
|
+
typeCode += '|';
|
|
1281
|
+
typeCode += pattern.toEmbeddedTS();
|
|
1282
|
+
}
|
|
1170
1283
|
}
|
|
1171
|
-
if ($1.includes(`${index.name},`)
|
|
1172
|
-
|| $1.includes(`${index.name};`)
|
|
1173
|
-
|| $1.includes(`${index.name})`)
|
|
1174
|
-
|| $1 === index.name)
|
|
1175
|
-
return $1.replaceAll(index.name, 'new nasl.core.Integer(0)');
|
|
1176
|
-
return $1;
|
|
1177
1284
|
});
|
|
1285
|
+
if (typeCode) {
|
|
1286
|
+
code = this.handleReplaceCode(code, expressionTsCode, `(${expressionTsCode} as ${typeCode})`);
|
|
1287
|
+
}
|
|
1178
1288
|
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1289
|
+
const parentMatchCase = match.getAncestor('MatchCase');
|
|
1290
|
+
if (parentMatchCase) {
|
|
1291
|
+
code = this.handleMatchCaseCode(code, parentMatchCase);
|
|
1292
|
+
}
|
|
1293
|
+
return code;
|
|
1181
1294
|
}
|
|
1182
1295
|
getNamespace() {
|
|
1183
1296
|
if (this.parentNode) {
|
|
@@ -1188,7 +1301,8 @@ let Logic = Logic_1 = class Logic extends BaseNode_1.default {
|
|
|
1188
1301
|
arr.push(parentName);
|
|
1189
1302
|
}
|
|
1190
1303
|
let namespace = arr.join('.');
|
|
1191
|
-
if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace)
|
|
1304
|
+
if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace)
|
|
1305
|
+
&& !namespace.includes('.logics')) {
|
|
1192
1306
|
namespace = `${namespace}.logics`;
|
|
1193
1307
|
}
|
|
1194
1308
|
return namespace;
|
|
@@ -1205,7 +1319,8 @@ let Logic = Logic_1 = class Logic extends BaseNode_1.default {
|
|
|
1205
1319
|
arr.push(parentName);
|
|
1206
1320
|
}
|
|
1207
1321
|
let namespace = arr.join('.');
|
|
1208
|
-
if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace)
|
|
1322
|
+
if (!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace)
|
|
1323
|
+
&& !namespace.includes('.logics')) {
|
|
1209
1324
|
namespace = `${namespace}.logics`;
|
|
1210
1325
|
}
|
|
1211
1326
|
return namespace;
|
|
@@ -1334,6 +1449,10 @@ let Logic = Logic_1 = class Logic extends BaseNode_1.default {
|
|
|
1334
1449
|
}
|
|
1335
1450
|
// 虚拟输入参数列表
|
|
1336
1451
|
virtualParams = [];
|
|
1452
|
+
get getLogicBelongTo() {
|
|
1453
|
+
const [, belongTo] = this.calleewholeKey.split('.');
|
|
1454
|
+
return belongTo;
|
|
1455
|
+
}
|
|
1337
1456
|
};
|
|
1338
1457
|
__decorate([
|
|
1339
1458
|
(0, decorators_1.property)()
|