@lcap/nasl 1.0.0 → 2.12.0-beta
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.js +39 -127
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/operators.d.ts +13 -0
- package/out/automate/engine/operators.js +63 -0
- package/out/automate/engine/operators.js.map +1 -0
- package/out/automate/engine/uniqueName.d.ts +6 -0
- package/out/automate/engine/uniqueName.js +39 -0
- package/out/automate/engine/uniqueName.js.map +1 -0
- package/out/automate/engine/utils.d.ts +1 -0
- package/out/automate/engine/utils.js +105 -67
- package/out/automate/engine/utils.js.map +1 -1
- package/out/common/BaseNode.d.ts +1 -1
- package/out/common/BaseNode.js +13 -3
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +52 -49
- package/out/concepts/App__.js +95 -60
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js +1 -1
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignee__.d.ts +11 -0
- package/out/concepts/Assignee__.js +36 -2
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/Assignment__.js +1 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/Attribute__.js +1 -1
- package/out/concepts/Attribute__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js +1 -1
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +4 -4
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +2 -2
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +11 -6
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.js +1 -1
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +25 -5
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +1 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +24 -22
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +35 -5
- package/out/concepts/CallQueryComponent__.js +344 -99
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +2 -2
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js +1 -1
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +9 -2
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigPropertyValue__.js +1 -1
- package/out/concepts/ConfigPropertyValue__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +1 -0
- package/out/concepts/ConfigProperty__.js +5 -2
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +5 -2
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Constant__.js +7 -7
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataElement__.js +1 -1
- package/out/concepts/DataElement__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +143 -0
- package/out/concepts/DataSource__.js +316 -0
- package/out/concepts/DataSource__.js.map +1 -0
- package/out/concepts/Destination__.js +26 -9
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +3 -3
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +5 -0
- package/out/concepts/EntityIndex__.js +11 -3
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +9 -0
- package/out/concepts/EntityProperty__.js +23 -8
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +6 -3
- package/out/concepts/Entity__.js +28 -24
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.js +1 -1
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +1 -0
- package/out/concepts/Enum__.js +15 -5
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js +2 -2
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.d.ts +1 -1
- package/out/concepts/ForEachStatement__.js +5 -5
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.d.ts +18 -0
- package/out/concepts/Function__.js +100 -5
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +2 -12
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +9 -9
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +10 -5
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js +21 -14
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicItem__.js +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +4 -0
- package/out/concepts/Logic__.js +59 -46
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +1 -2
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +1 -85
- package/out/concepts/Module__.js +13 -114
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +0 -86
- package/out/concepts/Namespace__.js +12 -119
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NullLiteral__.js +1 -1
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/Param__.d.ts +3 -2
- package/out/concepts/Param__.js +15 -8
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/Point__.js +1 -1
- package/out/concepts/Point__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js +3 -3
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +39 -18
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/Process__.js +21 -14
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js +2 -2
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +1 -0
- package/out/concepts/QueryFieldExpression__.js +12 -2
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +4 -0
- package/out/concepts/QueryFromExpression__.js +14 -3
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.d.ts +3 -0
- package/out/concepts/QueryGroupByExpression__.js +21 -1
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +4 -0
- package/out/concepts/QueryJoinExpression__.js +16 -5
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.js +1 -1
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js +2 -2
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Rect__.js +1 -1
- package/out/concepts/Rect__.js.map +1 -1
- package/out/concepts/Return__.d.ts +1 -1
- package/out/concepts/Return__.js +16 -11
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +11 -4
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/Slot__.js +1 -1
- package/out/concepts/Slot__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +10 -0
- package/out/concepts/SqlQueryComponent__.js +32 -5
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Start__.js +1 -1
- package/out/concepts/Start__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +2 -9
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +6 -6
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +22 -15
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js +6 -6
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +1 -1
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/Theme__.js +1 -1
- package/out/concepts/Theme__.js.map +1 -1
- package/out/concepts/Transactional__.js +1 -1
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +8 -0
- package/out/concepts/TypeAnnotation__.js +56 -6
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.js +1 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +1 -1
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/Unparsed__.js +1 -1
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/UseComponent__.js +1 -1
- package/out/concepts/UseComponent__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +1 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +1 -1
- package/out/concepts/Variable__.js +16 -11
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js +6 -6
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.js +21 -21
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +3 -1
- package/out/concepts/View__.js +53 -32
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +5 -5
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.js +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.interface.d.ts +2 -0
- package/out/concepts/basics/stdlib/nasl.interface.js +4 -4
- package/out/concepts/basics/stdlib/nasl.interface.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +268 -6
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +1 -1
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +3 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +1 -0
- package/out/concepts/index__.js +1 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +0 -9
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.js +8 -3
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.js +13 -12
- package/out/generator/genMetaData.js.map +1 -1
- package/out/manager/diagnostic.d.ts +1 -1
- package/out/server/createUiTs.js +1 -0
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/extendBaseNode.d.ts +1 -0
- package/out/server/extendBaseNode.js +323 -0
- package/out/server/extendBaseNode.js.map +1 -0
- package/out/server/getLogics.js +31 -2
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +47 -2
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +7 -2
- package/out/server/getProcesses.js +220 -20
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/getScope.d.ts +3 -1
- package/out/server/getScope.js +30 -14
- package/out/server/getScope.js.map +1 -1
- package/out/server/index.d.ts +1 -0
- package/out/server/index.js +1 -0
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +7 -5
- package/out/server/naslServer.js +249 -372
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.js +10 -1
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.d.ts +1 -1
- package/out/server/translator.js +22 -2
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +32 -11
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +15 -11
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +15 -12
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +25 -21
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +12 -12
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +21 -20
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +6 -3
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.js +11 -8
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genSelectBlock.js +13 -22
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +17 -15
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +16 -12
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +5 -3
- package/out/templator/utils.js +2 -1
- package/out/templator/utils.js.map +1 -1
- package/out/test/integration/connect-file.js +6 -6
- package/out/test/integration/connect-file.js.map +1 -1
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/index.d.ts +4 -0
- package/out/utils/index.js +38 -2
- package/out/utils/index.js.map +1 -1
- package/out/utils/string.d.ts +1 -1
- package/out/utils/string.js +38 -9
- package/out/utils/string.js.map +1 -1
- package/package.json +1 -2
- package/src/automate/engine/index.js +38 -128
- package/src/automate/engine/operators.js +63 -0
- package/src/automate/engine/uniqueName.js +36 -0
- package/src/automate/engine/utils.js +108 -69
- package/src/common/BaseNode.ts +14 -3
- package/src/concepts/App__.ts +138 -101
- package/src/concepts/Argument__.ts +1 -1
- package/src/concepts/Assignee__.ts +32 -2
- package/src/concepts/Assignment__.ts +1 -1
- package/src/concepts/Attribute__.ts +1 -1
- package/src/concepts/BinaryExpression__.ts +1 -1
- package/src/concepts/BindAttribute__.ts +4 -4
- package/src/concepts/BindDirective__.ts +2 -2
- package/src/concepts/BindEvent__.ts +10 -6
- package/src/concepts/BooleanLiteral__.ts +1 -1
- package/src/concepts/CallFunction__.ts +36 -18
- package/src/concepts/CallInterface__.ts +1 -1
- package/src/concepts/CallLogic__.ts +55 -24
- package/src/concepts/CallQueryComponent__.ts +357 -134
- package/src/concepts/Comment__.ts +2 -2
- package/src/concepts/CompletionProperty__.ts +1 -1
- package/src/concepts/ConfigGroup__.ts +5 -3
- package/src/concepts/ConfigPropertyValue__.ts +1 -1
- package/src/concepts/ConfigProperty__.ts +6 -2
- package/src/concepts/Configuration__.ts +5 -2
- package/src/concepts/Constant__.ts +7 -7
- package/src/concepts/DataElement__.ts +1 -1
- package/src/concepts/DataSource__.ts +389 -0
- package/src/concepts/Destination__.ts +28 -10
- package/src/concepts/End__.ts +3 -3
- package/src/concepts/EntityIndex__.ts +12 -3
- package/src/concepts/EntityProperty__.ts +24 -8
- package/src/concepts/Entity__.ts +39 -27
- package/src/concepts/EnumItem__.ts +1 -1
- package/src/concepts/Enum__.ts +16 -5
- package/src/concepts/Event__.ts +2 -2
- package/src/concepts/ForEachStatement__.ts +5 -5
- package/src/concepts/Function__.ts +101 -7
- package/src/concepts/Identifier__.ts +2 -12
- package/src/concepts/IfStatement__.ts +10 -10
- package/src/concepts/InterfaceParam__.ts +10 -5
- package/src/concepts/Interface__.ts +22 -14
- package/src/concepts/JSBlock__.ts +1 -1
- package/src/concepts/LogicItem__.ts +1 -1
- package/src/concepts/Logic__.ts +60 -43
- package/src/concepts/MemberExpression__.ts +1 -2
- package/src/concepts/Module__.ts +16 -211
- package/src/concepts/Namespace__.ts +12 -215
- package/src/concepts/NullLiteral__.ts +1 -1
- package/src/concepts/NumericLiteral__.ts +1 -1
- package/src/concepts/Param__.ts +17 -9
- package/src/concepts/Point__.ts +1 -1
- package/src/concepts/ProcessComponent__.ts +3 -3
- package/src/concepts/ProcessElement__.ts +43 -21
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/Process__.ts +21 -15
- package/src/concepts/QueryAggregateExpression__.ts +2 -2
- package/src/concepts/QueryFieldExpression__.ts +14 -2
- package/src/concepts/QueryFromExpression__.ts +14 -3
- package/src/concepts/QueryGroupByExpression__.ts +24 -1
- package/src/concepts/QueryJoinExpression__.ts +16 -5
- package/src/concepts/QueryLimitExpression__.ts +9 -0
- package/src/concepts/QueryOrderByExpression__.ts +1 -1
- package/src/concepts/QuerySelectExpression__.ts +2 -2
- package/src/concepts/Rect__.ts +1 -1
- package/src/concepts/Return__.ts +16 -11
- package/src/concepts/Role__.ts +11 -5
- package/src/concepts/Slot__.ts +1 -1
- package/src/concepts/SqlQueryComponent__.ts +30 -11
- package/src/concepts/Start__.ts +1 -1
- package/src/concepts/StringLiteral__.ts +2 -9
- package/src/concepts/StructureProperty__.ts +6 -6
- package/src/concepts/Structure__.ts +22 -14
- package/src/concepts/SwitchCase__.ts +6 -6
- package/src/concepts/SwitchStatement__.ts +1 -1
- package/src/concepts/Theme__.ts +1 -1
- package/src/concepts/Transactional__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +55 -25
- package/src/concepts/TypeParam__.ts +1 -1
- package/src/concepts/UnaryExpression__.ts +1 -1
- package/src/concepts/Unparsed__.ts +1 -1
- package/src/concepts/UseComponent__.ts +1 -1
- package/src/concepts/ValidationRule__.ts +1 -1
- package/src/concepts/Variable__.ts +16 -11
- package/src/concepts/ViewComponent__.ts +6 -6
- package/src/concepts/ViewElement__.ts +21 -21
- package/src/concepts/View__.ts +54 -32
- package/src/concepts/WhileStatement__.ts +5 -5
- package/src/concepts/basics/stdlib/nasl.configuration.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.interface.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.util.ts +269 -6
- package/src/concepts/basics/stdlib/reference2TypeAnnotationList.ts +1 -1
- package/src/concepts/basics/types/index.ts +1 -0
- package/src/concepts/index__.ts +1 -0
- package/src/enums/KEYWORDS.ts +0 -9
- package/src/generator/genBundleFiles.ts +8 -3
- package/src/generator/genMetaData.ts +13 -13
- package/src/manager/diagnostic.ts +1 -1
- package/src/server/createUiTs.ts +1 -0
- package/src/server/extendBaseNode.ts +318 -0
- package/src/server/getLogics.ts +33 -4
- package/src/server/getMemberIdentifier.ts +49 -2
- package/src/server/getProcesses.ts +231 -21
- package/src/server/getScope.ts +41 -24
- package/src/server/index.ts +1 -0
- package/src/server/naslServer.ts +248 -366
- package/src/server/process2LogicNamespace.ts +29 -19
- package/src/server/translator.ts +25 -2
- package/src/service/storage/init.ts +32 -12
- package/src/templator/genCreateBlock.ts +16 -13
- package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -13
- package/src/templator/genCurdMultipleKeyBlock.ts +26 -22
- package/src/templator/genEditTableBlock.ts +14 -13
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +22 -21
- package/src/templator/genListViewBlock.ts +9 -5
- package/src/templator/genQueryComponent.ts +12 -9
- package/src/templator/genSelectBlock.ts +14 -23
- package/src/templator/genTableBlock.ts +18 -16
- package/src/templator/genUpdateBlock.ts +17 -13
- package/src/templator/utils.ts +5 -2
- package/src/test/integration/connect-file.ts +6 -6
- package/src/translator/index.ts +1 -1
- package/src/utils/index.ts +38 -1
- package/src/utils/string.ts +39 -9
- package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +0 -3
- package/out/concepts/basics/stdlib/nasl.browser copy.js +0 -70
- package/out/concepts/basics/stdlib/nasl.browser copy.js.map +0 -1
- package/out/terms/LEVEL_NAME_MAP.d.ts +0 -26
- package/out/terms/LEVEL_NAME_MAP.js +0 -30
- package/out/terms/LEVEL_NAME_MAP.js.map +0 -1
|
@@ -4,6 +4,7 @@ import Entity from './Entity__';
|
|
|
4
4
|
import Structure from './Structure__';
|
|
5
5
|
import StructureProperty from './StructureProperty__';
|
|
6
6
|
import CompletionProperty from './CompletionProperty__';
|
|
7
|
+
import QueryFieldExpression from './QueryFieldExpression__';
|
|
7
8
|
//================================================================================
|
|
8
9
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
9
10
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -83,13 +84,11 @@ export class CallQueryComponent extends LogicItem {
|
|
|
83
84
|
limit: QueryLimitExpression = undefined;
|
|
84
85
|
|
|
85
86
|
/**
|
|
86
|
-
*
|
|
87
|
+
* 局部版本
|
|
87
88
|
*/
|
|
88
89
|
@property()
|
|
89
90
|
ideVersion: string = undefined;
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
92
|
/**
|
|
94
93
|
* @param source 需要合并的部分参数
|
|
95
94
|
*/
|
|
@@ -103,7 +102,6 @@ export class CallQueryComponent extends LogicItem {
|
|
|
103
102
|
return super.from(source, parentNode, parentKey) as CallQueryComponent;
|
|
104
103
|
}
|
|
105
104
|
|
|
106
|
-
|
|
107
105
|
/**
|
|
108
106
|
* 设置select
|
|
109
107
|
*/
|
|
@@ -203,12 +201,12 @@ export class CallQueryComponent extends LogicItem {
|
|
|
203
201
|
});
|
|
204
202
|
}
|
|
205
203
|
|
|
206
|
-
|
|
204
|
+
getQueryGroupByExpressionExistingNames(excludedList: Array<QueryGroupByExpression> = []) {
|
|
207
205
|
const excludedSet = new Set(excludedList);
|
|
208
206
|
return (this.groupBy || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
209
207
|
}
|
|
210
208
|
getQueryGroupByExpressionUniqueName(name = 'queryGroupByExpression1') {
|
|
211
|
-
return utils.unique(name, this.getQueryGroupByExpressionExistingNames());
|
|
209
|
+
return utils.unique(name, this.getQueryGroupByExpressionExistingNames(), undefined, false);
|
|
212
210
|
}
|
|
213
211
|
|
|
214
212
|
/**
|
|
@@ -344,8 +342,6 @@ export class CallQueryComponent extends LogicItem {
|
|
|
344
342
|
return node;
|
|
345
343
|
}
|
|
346
344
|
|
|
347
|
-
|
|
348
|
-
|
|
349
345
|
/**
|
|
350
346
|
* 插入查询排序子句
|
|
351
347
|
* @internal
|
|
@@ -378,8 +374,6 @@ export class CallQueryComponent extends LogicItem {
|
|
|
378
374
|
return queryOrderByExpression;
|
|
379
375
|
}
|
|
380
376
|
|
|
381
|
-
|
|
382
|
-
|
|
383
377
|
/**
|
|
384
378
|
* 插入查询排序子句
|
|
385
379
|
* @param queryOrderByExpressionOptions 查询排序子句参数
|
|
@@ -402,8 +396,6 @@ export class CallQueryComponent extends LogicItem {
|
|
|
402
396
|
return node;
|
|
403
397
|
}
|
|
404
398
|
|
|
405
|
-
|
|
406
|
-
|
|
407
399
|
/**
|
|
408
400
|
* 添加查询排序子句
|
|
409
401
|
* @internal
|
|
@@ -423,8 +415,6 @@ export class CallQueryComponent extends LogicItem {
|
|
|
423
415
|
return this._insertQueryOrderByExpressionInOrderByAt(options as any, index);
|
|
424
416
|
}
|
|
425
417
|
|
|
426
|
-
|
|
427
|
-
|
|
428
418
|
/**
|
|
429
419
|
* 添加查询排序子句
|
|
430
420
|
* @param queryOrderByExpressionOptions 查询排序子句参数
|
|
@@ -448,9 +438,6 @@ export class CallQueryComponent extends LogicItem {
|
|
|
448
438
|
return node;
|
|
449
439
|
}
|
|
450
440
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
441
|
/**
|
|
455
442
|
* 删除类型标注
|
|
456
443
|
* @param name 类型标注名称
|
|
@@ -499,8 +486,6 @@ export class CallQueryComponent extends LogicItem {
|
|
|
499
486
|
return params;
|
|
500
487
|
}
|
|
501
488
|
|
|
502
|
-
|
|
503
|
-
|
|
504
489
|
/**
|
|
505
490
|
* 删除查询选择子句
|
|
506
491
|
* @param name 查询选择子句名称
|
|
@@ -526,8 +511,6 @@ export class CallQueryComponent extends LogicItem {
|
|
|
526
511
|
return select.delete();
|
|
527
512
|
}
|
|
528
513
|
|
|
529
|
-
|
|
530
|
-
|
|
531
514
|
/**
|
|
532
515
|
* 删除查询 From 子句
|
|
533
516
|
* @param name 查询 From 子句名称
|
|
@@ -553,8 +536,6 @@ export class CallQueryComponent extends LogicItem {
|
|
|
553
536
|
return from.delete();
|
|
554
537
|
}
|
|
555
538
|
|
|
556
|
-
|
|
557
|
-
|
|
558
539
|
/**
|
|
559
540
|
* 删除逻辑项
|
|
560
541
|
* @param name 逻辑项名称
|
|
@@ -580,8 +561,6 @@ export class CallQueryComponent extends LogicItem {
|
|
|
580
561
|
return where.delete();
|
|
581
562
|
}
|
|
582
563
|
|
|
583
|
-
|
|
584
|
-
|
|
585
564
|
/**
|
|
586
565
|
* 删除查询分组
|
|
587
566
|
* @param name 查询分组名称
|
|
@@ -607,8 +586,6 @@ export class CallQueryComponent extends LogicItem {
|
|
|
607
586
|
return queryGroupByExpression.delete();
|
|
608
587
|
}
|
|
609
588
|
|
|
610
|
-
|
|
611
|
-
|
|
612
589
|
/**
|
|
613
590
|
* 删除逻辑项
|
|
614
591
|
* @param name 逻辑项名称
|
|
@@ -634,8 +611,6 @@ export class CallQueryComponent extends LogicItem {
|
|
|
634
611
|
return having.delete();
|
|
635
612
|
}
|
|
636
613
|
|
|
637
|
-
|
|
638
|
-
|
|
639
614
|
/**
|
|
640
615
|
* 删除查询排序子句
|
|
641
616
|
* @param queryOrderByExpression 已有的查询排序子句实例
|
|
@@ -643,12 +618,10 @@ export class CallQueryComponent extends LogicItem {
|
|
|
643
618
|
removeQueryOrderByExpressionInOrderBy(queryOrderByExpression: QueryOrderByExpression): void;
|
|
644
619
|
|
|
645
620
|
removeQueryOrderByExpressionInOrderBy(options: QueryOrderByExpression) {
|
|
646
|
-
|
|
621
|
+
const queryOrderByExpression: QueryOrderByExpression = options;
|
|
647
622
|
return queryOrderByExpression.delete();
|
|
648
623
|
}
|
|
649
624
|
|
|
650
|
-
|
|
651
|
-
|
|
652
625
|
/**
|
|
653
626
|
* 删除查询分页子句
|
|
654
627
|
* @param name 查询分页子句名称
|
|
@@ -750,16 +723,16 @@ export class CallQueryComponent extends LogicItem {
|
|
|
750
723
|
if (list.length === 0)
|
|
751
724
|
return code;
|
|
752
725
|
|
|
753
|
-
code += indent(state
|
|
726
|
+
code += indent((state?.tabSize || 0) + 1) + `.${key}(() => `;
|
|
754
727
|
list.forEach((item, index) => {
|
|
755
728
|
if (index > 0)
|
|
756
|
-
code += `,\n${indent(state
|
|
729
|
+
code += `,\n${indent((state?.tabSize || 0) + 2)}() => `;
|
|
757
730
|
code += item?.toEmbeddedTS?.(shiftState(state, code, { tabSize: 0 }));
|
|
758
731
|
});
|
|
759
732
|
if (list.length > 1) {
|
|
760
733
|
if (multipleErrorType)
|
|
761
|
-
code += `,\n${indent(state
|
|
762
|
-
code += `\n${indent(state
|
|
734
|
+
code += `,\n${indent((state?.tabSize || 0) + 2)}() => ${multipleErrorType}`;
|
|
735
|
+
code += `\n${indent((state?.tabSize || 0) + 1)}`;
|
|
763
736
|
}
|
|
764
737
|
code += ')\n';
|
|
765
738
|
|
|
@@ -781,13 +754,44 @@ export class CallQueryComponent extends LogicItem {
|
|
|
781
754
|
// })`;
|
|
782
755
|
}
|
|
783
756
|
|
|
757
|
+
isAutoInfer() {
|
|
758
|
+
return this.ideVersion === '2.11';
|
|
759
|
+
}
|
|
760
|
+
|
|
784
761
|
@withSourceMap()
|
|
785
762
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
786
|
-
|
|
787
|
-
|
|
763
|
+
if (!this.typeAnnotation)
|
|
764
|
+
return `(function () {
|
|
765
|
+
return;
|
|
766
|
+
})()`;
|
|
767
|
+
let code = `(function(): `;
|
|
768
|
+
if (this.isAutoInfer()) {
|
|
769
|
+
code += `${this.typeAnnotation.toEmbeddedTS(shiftState(state, code))} {\n`;
|
|
770
|
+
} else {
|
|
771
|
+
code += `nasl.collection.PageOf<`;
|
|
772
|
+
code += `${this.typeAnnotation.toEmbeddedTS(shiftState(state, code))}> {\n`;
|
|
773
|
+
}
|
|
774
|
+
// 2.11版本后 分组使用别名
|
|
775
|
+
if (this.isAutoInfer()) {
|
|
776
|
+
// 分组别名(列别名)
|
|
777
|
+
this.groupBy.forEach((item, index, array) => {
|
|
778
|
+
code += indent(state.tabSize + 1);
|
|
779
|
+
const groupElement = item.groupElement as QueryFieldExpression;
|
|
780
|
+
if (groupElement.asName)
|
|
781
|
+
code += `const __${groupElement.asName} = `;
|
|
782
|
+
if (groupElement.propertyName) {
|
|
783
|
+
code += groupElement.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
|
|
784
|
+
code += ';\n';
|
|
785
|
+
} else
|
|
786
|
+
code += `__EMPTY_GROUP_BY_NAME__;\n`;
|
|
787
|
+
|
|
788
|
+
if (index === array.length - 1)
|
|
789
|
+
code += '\n';
|
|
790
|
+
});
|
|
791
|
+
}
|
|
788
792
|
// 聚合属性别名
|
|
789
793
|
this.select.selectElements.forEach((item, index, array) => {
|
|
790
|
-
code += indent(state
|
|
794
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
791
795
|
const { asName, aggregateName, aggregateParam } = item;
|
|
792
796
|
if (asName)
|
|
793
797
|
code += `const __${asName} = `;
|
|
@@ -803,9 +807,9 @@ export class CallQueryComponent extends LogicItem {
|
|
|
803
807
|
});
|
|
804
808
|
|
|
805
809
|
if (this.from)
|
|
806
|
-
code += this.from.toEmbeddedTS(shiftState(state, code, { tabSize: state
|
|
810
|
+
code += this.from.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
807
811
|
else
|
|
808
|
-
code += `${indent(state
|
|
812
|
+
code += `${indent((state?.tabSize || 0) + 1)}nasl.langUtil.FROM()\n`;
|
|
809
813
|
|
|
810
814
|
// where 子句
|
|
811
815
|
code = this.toEmbeddedTSOfSubPart('WHERE', this.where ? [this.where] : [], {
|
|
@@ -821,7 +825,7 @@ export class CallQueryComponent extends LogicItem {
|
|
|
821
825
|
});
|
|
822
826
|
|
|
823
827
|
// 分组属性(Group by)
|
|
824
|
-
code = this.toEmbeddedTSOfSubPart('GROUP_BY', this.groupBy
|
|
828
|
+
code = this.toEmbeddedTSOfSubPart('GROUP_BY', this.groupBy, {
|
|
825
829
|
code,
|
|
826
830
|
state,
|
|
827
831
|
});
|
|
@@ -846,75 +850,250 @@ export class CallQueryComponent extends LogicItem {
|
|
|
846
850
|
});
|
|
847
851
|
|
|
848
852
|
code += '\n';
|
|
849
|
-
code += indent(state
|
|
850
|
-
code += indent(state
|
|
853
|
+
code += indent((state?.tabSize || 0) + 1) + 'return;\n';
|
|
854
|
+
code += indent((state?.tabSize || 0)) + '})();\n';
|
|
851
855
|
return code;
|
|
852
856
|
}
|
|
853
857
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
if (!node)
|
|
858
|
-
return [];
|
|
859
|
-
|
|
860
|
-
const entityName = node.entityName;
|
|
861
|
-
entities.push({
|
|
862
|
-
concept: 'StructureProperty',
|
|
863
|
-
name: utils.firstLowerCase(entityName),
|
|
864
|
-
typeAnnotation: {
|
|
865
|
-
concept: 'TypeAnnotation',
|
|
866
|
-
typeKind: 'reference',
|
|
867
|
-
typeName: entityName,
|
|
868
|
-
typeNamespace: `${app.getNamespace()}.entities`,
|
|
869
|
-
},
|
|
870
|
-
});
|
|
858
|
+
genPropertyListOfFrom(node: QueryFromExpression | QueryJoinExpression, entities: any[] = []) {
|
|
859
|
+
if (!node)
|
|
860
|
+
return [];
|
|
871
861
|
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
862
|
+
const entityName = node.entityName;
|
|
863
|
+
const entityNamespace = node.entityNamespace;
|
|
864
|
+
entities.push({
|
|
865
|
+
concept: 'StructureProperty',
|
|
866
|
+
name: utils.firstLowerCase(entityName),
|
|
867
|
+
typeAnnotation: {
|
|
868
|
+
concept: 'TypeAnnotation',
|
|
869
|
+
typeKind: 'reference',
|
|
870
|
+
typeName: entityName,
|
|
871
|
+
typeNamespace: entityNamespace,
|
|
872
|
+
},
|
|
873
|
+
});
|
|
875
874
|
|
|
876
|
-
|
|
875
|
+
for (const sub of node.joinParts) {
|
|
876
|
+
this.genPropertyListOfFrom(sub, entities);
|
|
877
877
|
}
|
|
878
878
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
879
|
+
return entities;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
genPropertyListOfAggregate(node: CallQueryComponent, entities: Entity[]) {
|
|
883
|
+
return node.select.selectElements
|
|
884
|
+
.filter((item) => item.aggregateName && item.asName)
|
|
885
|
+
.map((item) => {
|
|
886
|
+
let typeName;
|
|
887
|
+
if (['COUNT', 'COUNTD'].includes(item.aggregateName)) {
|
|
888
|
+
typeName = 'Integer';
|
|
889
|
+
} else if (['AVG'].includes(item.aggregateName)) {
|
|
890
|
+
typeName = 'Double';
|
|
891
|
+
} else {
|
|
892
|
+
const { entityAsName, propertyName } = item.aggregateParam;
|
|
893
|
+
const entity = entities.find((item: Entity) => item.name === entityAsName);
|
|
894
|
+
const property = entity?.properties.find((item) => item.name === propertyName);
|
|
895
|
+
typeName = property?.typeAnnotation?.typeName;
|
|
896
|
+
}
|
|
897
|
+
return {
|
|
898
|
+
concept: 'StructureProperty',
|
|
899
|
+
name: item.asName,
|
|
900
|
+
typeAnnotation: {
|
|
901
|
+
concept: 'TypeAnnotation',
|
|
902
|
+
typeKind: 'primitive',
|
|
903
|
+
typeNamespace: 'nasl.core',
|
|
904
|
+
typeName,
|
|
905
|
+
},
|
|
906
|
+
};
|
|
907
|
+
});
|
|
908
|
+
}
|
|
904
909
|
|
|
905
|
-
|
|
910
|
+
genPropertyListOfGroupBy(node: CallQueryComponent, entities: Entity[]) {
|
|
911
|
+
return node.groupBy
|
|
912
|
+
.filter((item) => item.groupElement && (item.groupElement as QueryFieldExpression).propertyName && (item.groupElement as QueryFieldExpression).asName)
|
|
913
|
+
.map((item) => {
|
|
914
|
+
const { entityAsName, propertyName, asName } = item.groupElement as QueryFieldExpression;
|
|
915
|
+
const entity = entities.find((item: Entity) => item.name === entityAsName);
|
|
916
|
+
const property = entity?.properties.find((item) => item.name === propertyName);
|
|
917
|
+
const propertyTypeAnnotation = property.typeAnnotation;
|
|
918
|
+
|
|
919
|
+
return {
|
|
920
|
+
concept: 'StructureProperty',
|
|
921
|
+
name: asName,
|
|
922
|
+
typeAnnotation: {
|
|
923
|
+
concept: propertyTypeAnnotation.concept,
|
|
924
|
+
typeKind: propertyTypeAnnotation.typeKind,
|
|
925
|
+
typeName: propertyTypeAnnotation.typeName,
|
|
926
|
+
typeNamespace: propertyTypeAnnotation.typeNamespace,
|
|
927
|
+
},
|
|
928
|
+
};
|
|
929
|
+
});
|
|
930
|
+
}
|
|
906
931
|
|
|
932
|
+
genStructure(structureName?: string, properties: any[] = []) {
|
|
907
933
|
return Structure.from({
|
|
908
934
|
concept: 'Structure',
|
|
909
|
-
name: structureName
|
|
935
|
+
name: structureName || this.typeAnnotation?.typeName || `${utils.firstUpperCase(this.logic.name)}Structure`,
|
|
910
936
|
origin: 'CallQueryComponent',
|
|
911
|
-
properties
|
|
937
|
+
properties,
|
|
912
938
|
});
|
|
913
939
|
}
|
|
914
940
|
|
|
915
941
|
saveStructure() {
|
|
916
|
-
|
|
917
|
-
|
|
942
|
+
// 没有数据源时不初始化数据结构
|
|
943
|
+
if (!this.entityInfos.length) {
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
const entityNamespace = this.from?.entityNamespace;
|
|
947
|
+
const entities = this.app.findNodeByCompleteName(entityNamespace);
|
|
948
|
+
if (!this.isAutoInfer()) {
|
|
949
|
+
// 存量应用走之前的逻辑
|
|
950
|
+
return this.saveStructureNoInfer(entities);
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
const groupBy = this.groupBy;
|
|
954
|
+
const selectElements = this.select.selectElements;
|
|
955
|
+
let structureName;
|
|
956
|
+
let typeAnnotation;
|
|
957
|
+
|
|
958
|
+
// Structures
|
|
959
|
+
if (this.typeAnnotation) {
|
|
960
|
+
const { typeNamespace, typeName, typeArguments } = this.typeAnnotation;
|
|
961
|
+
if (typeNamespace === 'app.structures') {
|
|
962
|
+
structureName = typeName;
|
|
963
|
+
this.removeStructure(structureName);
|
|
964
|
+
} else if (typeNamespace === 'nasl.collection' && typeName === 'PageOf') {
|
|
965
|
+
// PageOf<Structures>
|
|
966
|
+
if (typeArguments[0].typeNamespace === 'app.structures') {
|
|
967
|
+
structureName = typeArguments[0].typeName;
|
|
968
|
+
this.removeStructure(structureName);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
structureName = structureName || utils.unique(`${utils.firstUpperCase(this.logic.name)}Structure`, this.app.getStructureExistingNames());
|
|
974
|
+
const groupByLength = groupBy.filter((item) => (item.groupElement as QueryFieldExpression)?.propertyName && (item.groupElement as QueryFieldExpression).asName).length;
|
|
975
|
+
const aggregateLength = selectElements.filter((item) => item.aggregateName && item.asName).length;
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
// 1. 有分组
|
|
980
|
+
if (groupByLength) {
|
|
981
|
+
if (!aggregateLength && groupByLength === 1) {
|
|
982
|
+
// 1.1 单分组无聚合:`PageOf<列的类型>`
|
|
983
|
+
const { entityAsName, propertyName } = groupBy[0].groupElement as QueryFieldExpression;
|
|
984
|
+
const entity = entities.find((item: Entity) => item.name === entityAsName);
|
|
985
|
+
const property = entity?.properties.find((item: any) => item.name === propertyName);
|
|
986
|
+
const propertyTypeAnnotation = property.typeAnnotation;
|
|
987
|
+
|
|
988
|
+
typeAnnotation = TypeAnnotation.from({
|
|
989
|
+
text: `PageOf<${propertyTypeAnnotation.typeName}>`,
|
|
990
|
+
concept: 'TypeAnnotation',
|
|
991
|
+
typeKind: 'generic',
|
|
992
|
+
typeName: 'PageOf',
|
|
993
|
+
typeNamespace: `nasl.collection`,
|
|
994
|
+
typeArguments: [TypeAnnotation.from({
|
|
995
|
+
concept: propertyTypeAnnotation.concept,
|
|
996
|
+
typeKind: propertyTypeAnnotation.typeKind,
|
|
997
|
+
typeName: propertyTypeAnnotation.typeName,
|
|
998
|
+
typeNamespace: propertyTypeAnnotation.typeNamespace,
|
|
999
|
+
}, this.typeAnnotation, 'typeAnnotation')],
|
|
1000
|
+
}, this, 'typeAnnotation');
|
|
1001
|
+
} else {
|
|
1002
|
+
// 1.2 多分组:`PageOf<Structure>`
|
|
1003
|
+
const structure = this.genStructure(structureName, [
|
|
1004
|
+
...this.genPropertyListOfGroupBy(this, entities),
|
|
1005
|
+
...this.genPropertyListOfAggregate(this, entities),
|
|
1006
|
+
]);
|
|
1007
|
+
this.app.addStructure(structure);
|
|
1008
|
+
|
|
1009
|
+
typeAnnotation = TypeAnnotation.from({
|
|
1010
|
+
text: `PageOf<${structureName}>`,
|
|
1011
|
+
concept: 'TypeAnnotation',
|
|
1012
|
+
typeKind: 'generic',
|
|
1013
|
+
typeName: 'PageOf',
|
|
1014
|
+
typeNamespace: `nasl.collection`,
|
|
1015
|
+
typeArguments: [
|
|
1016
|
+
TypeAnnotation.from({
|
|
1017
|
+
concept: 'TypeAnnotation',
|
|
1018
|
+
typeKind: 'reference',
|
|
1019
|
+
typeName: structureName,
|
|
1020
|
+
typeNamespace: 'app.structures',
|
|
1021
|
+
}, this.typeAnnotation, 'typeAnnotation'),
|
|
1022
|
+
],
|
|
1023
|
+
}, this, 'typeAnnotation');
|
|
1024
|
+
}
|
|
1025
|
+
} else { // 2. 无分组
|
|
1026
|
+
if (aggregateLength) {
|
|
1027
|
+
if (aggregateLength === 1) {
|
|
1028
|
+
// 2.1 单聚合:`基本类型`
|
|
1029
|
+
let typeName;
|
|
1030
|
+
if (['COUNT', 'COUNTD'].includes(selectElements[0].aggregateName)) {
|
|
1031
|
+
// 2.1.1. `COUNT`、`COUNTD` 返回 `Integer`
|
|
1032
|
+
typeName = 'Integer';
|
|
1033
|
+
} else if (['AVG'].includes(selectElements[0].aggregateName)) {
|
|
1034
|
+
// 2.1.2. `AVG` 返回 `Double`
|
|
1035
|
+
typeName = 'Double';
|
|
1036
|
+
} else {
|
|
1037
|
+
// 2.1.3. 其他返回列类型,包含:`Integer`、`Long`、`Double`
|
|
1038
|
+
const { entityAsName, propertyName } = selectElements[0].aggregateParam;
|
|
1039
|
+
const entity = entities.find((item: Entity) => item.name === entityAsName);
|
|
1040
|
+
const property = entity?.properties.find((item: any) => item.name === propertyName);
|
|
1041
|
+
typeName = property?.typeAnnotation?.typeName;
|
|
1042
|
+
}
|
|
1043
|
+
typeAnnotation = TypeAnnotation.from({
|
|
1044
|
+
concept: 'TypeAnnotation',
|
|
1045
|
+
typeKind: 'primitive',
|
|
1046
|
+
typeName,
|
|
1047
|
+
typeNamespace: 'nasl.core',
|
|
1048
|
+
}, this, 'typeAnnotation');
|
|
1049
|
+
} else {
|
|
1050
|
+
// 2.2. 多聚合:`Structure`(自动创建 `Structure`)
|
|
1051
|
+
const structure = this.genStructure(structureName, [
|
|
1052
|
+
...this.genPropertyListOfAggregate(this, entities),
|
|
1053
|
+
]);
|
|
1054
|
+
this.app.addStructure(structure);
|
|
1055
|
+
|
|
1056
|
+
typeAnnotation = TypeAnnotation.from({
|
|
1057
|
+
concept: 'TypeAnnotation',
|
|
1058
|
+
typeKind: 'reference',
|
|
1059
|
+
typeName: structureName,
|
|
1060
|
+
typeNamespace: `app.structures`,
|
|
1061
|
+
}, this, 'typeAnnotation');
|
|
1062
|
+
}
|
|
1063
|
+
} else {
|
|
1064
|
+
// 2.3. 无聚合(默认情况):`PageOf<Structure>`(自动创建 `Structure`)
|
|
1065
|
+
const structure = this.genStructure(structureName, [
|
|
1066
|
+
...this.genPropertyListOfFrom(this.from),
|
|
1067
|
+
...this.genPropertyListOfAggregate(this, entities),
|
|
1068
|
+
]);
|
|
1069
|
+
this.app.addStructure(structure);
|
|
1070
|
+
|
|
1071
|
+
typeAnnotation = TypeAnnotation.from({
|
|
1072
|
+
text: structureName,
|
|
1073
|
+
concept: 'TypeAnnotation',
|
|
1074
|
+
typeKind: 'generic',
|
|
1075
|
+
typeName: 'PageOf',
|
|
1076
|
+
typeNamespace: `nasl.collection`,
|
|
1077
|
+
typeArguments: [
|
|
1078
|
+
TypeAnnotation.from({
|
|
1079
|
+
concept: 'TypeAnnotation',
|
|
1080
|
+
typeKind: 'reference',
|
|
1081
|
+
typeName: structureName,
|
|
1082
|
+
typeNamespace: 'app.structures',
|
|
1083
|
+
}, this.typeAnnotation, 'typeAnnotation'),
|
|
1084
|
+
],
|
|
1085
|
+
}, this, 'typeAnnotation');
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
this.update({ typeAnnotation });
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
saveStructureNoInfer(entities: any[] = []) {
|
|
1093
|
+
const source = this.genStructure(null, [
|
|
1094
|
+
...this.genPropertyListOfFrom(this.from),
|
|
1095
|
+
...this.genPropertyListOfAggregate(this, entities),
|
|
1096
|
+
]);
|
|
918
1097
|
if (this.typeAnnotation) {
|
|
919
1098
|
const structure = this.app.structures.find((item) => item.name === this.typeAnnotation.typeName);
|
|
920
1099
|
if (structure) {
|
|
@@ -939,59 +1118,80 @@ export class CallQueryComponent extends LogicItem {
|
|
|
939
1118
|
}
|
|
940
1119
|
}
|
|
941
1120
|
|
|
942
|
-
removeStructure() {
|
|
1121
|
+
removeStructure(structureName?: string) {
|
|
943
1122
|
try {
|
|
944
|
-
|
|
1123
|
+
if (this.typeAnnotation) {
|
|
1124
|
+
const { typeNamespace, typeName, typeArguments } = this.typeAnnotation;
|
|
1125
|
+
if (typeNamespace === 'app.structures') {
|
|
1126
|
+
// Structures
|
|
1127
|
+
structureName = typeName;
|
|
1128
|
+
this.app.removeStructure(structureName);
|
|
1129
|
+
} else if (typeNamespace === 'nasl.collection' && typeName === 'PageOf') {
|
|
1130
|
+
// PageOf<Structures>
|
|
1131
|
+
if (typeArguments[0].typeNamespace === 'app.structures') {
|
|
1132
|
+
structureName = typeArguments[0].typeName;
|
|
1133
|
+
this.app.removeStructure(structureName);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
945
1137
|
} catch {}
|
|
946
1138
|
}
|
|
947
1139
|
|
|
948
|
-
|
|
1140
|
+
getEntityInfos(node: QueryFromExpression | QueryJoinExpression, set = new Set()) {
|
|
949
1141
|
if (node?.entityName)
|
|
950
|
-
set.add(
|
|
1142
|
+
set.add({
|
|
1143
|
+
namespace: node.entityNamespace,
|
|
1144
|
+
name: node.entityName,
|
|
1145
|
+
});
|
|
951
1146
|
|
|
952
1147
|
node?.joinParts?.forEach((child) => {
|
|
953
|
-
this.
|
|
1148
|
+
this.getEntityInfos(child, set);
|
|
954
1149
|
});
|
|
955
1150
|
return Array.from(set);
|
|
956
1151
|
}
|
|
957
1152
|
|
|
958
|
-
get
|
|
959
|
-
return this.
|
|
1153
|
+
get entityInfos() {
|
|
1154
|
+
return this.getEntityInfos(this.from);
|
|
960
1155
|
}
|
|
961
1156
|
|
|
962
1157
|
getCompletionPropertyOfEntities() {
|
|
963
|
-
const
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
.
|
|
967
|
-
.
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
concept: '
|
|
973
|
-
name:
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1158
|
+
const firstEntityInfo: any = this.entityInfos[0];
|
|
1159
|
+
if (firstEntityInfo) {
|
|
1160
|
+
const namespace = firstEntityInfo.namespace;
|
|
1161
|
+
const entities: Entity[] = this.app.findNodeByCompleteName(namespace);
|
|
1162
|
+
if (Array.isArray(entities)) {
|
|
1163
|
+
const children = this.entityInfos
|
|
1164
|
+
.map(({ name }) => entities.find((item) => item.name === name))
|
|
1165
|
+
.filter((item) => item)
|
|
1166
|
+
.map((entity) => ({
|
|
1167
|
+
concept: 'Entity',
|
|
1168
|
+
name: entity.name,
|
|
1169
|
+
children: entity.properties.map((property) => {
|
|
1170
|
+
const completionProperty = new CompletionProperty({
|
|
1171
|
+
concept: 'CompletionProperty',
|
|
1172
|
+
name: property.name,
|
|
1173
|
+
value: `${entity.name}.${property.name}`,
|
|
1174
|
+
expression: LogicItem.from({
|
|
1175
|
+
concept: 'QueryFieldExpression',
|
|
1176
|
+
name: property.name,
|
|
1177
|
+
value: `${entity.name}.${property.name}`,
|
|
1178
|
+
entityAsName: entity.name,
|
|
1179
|
+
propertyName: property.name,
|
|
1180
|
+
}),
|
|
1181
|
+
});
|
|
1182
|
+
completionProperty.icon = 'property';
|
|
1183
|
+
return completionProperty;
|
|
981
1184
|
}),
|
|
982
|
-
});
|
|
983
|
-
|
|
984
|
-
return
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
icon: 'category',
|
|
993
|
-
children,
|
|
994
|
-
};
|
|
1185
|
+
}));
|
|
1186
|
+
if (children.length) {
|
|
1187
|
+
return {
|
|
1188
|
+
name: '实体',
|
|
1189
|
+
icon: 'category',
|
|
1190
|
+
children,
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
995
1195
|
}
|
|
996
1196
|
|
|
997
1197
|
getCompletionPropertyOfAggregateAsNames() {
|
|
@@ -1017,13 +1217,36 @@ export class CallQueryComponent extends LogicItem {
|
|
|
1017
1217
|
return { name: '聚合属性别名', icon: 'category', children, expanded: true };
|
|
1018
1218
|
}
|
|
1019
1219
|
|
|
1220
|
+
getCompletionPropertyOfGroupByAsNames() {
|
|
1221
|
+
const children = this.groupBy
|
|
1222
|
+
?.filter((item) => item.concept === 'QueryGroupByExpression' && (item.groupElement as QueryFieldExpression)?.asName)
|
|
1223
|
+
.map((item) =>
|
|
1224
|
+
new CompletionProperty({
|
|
1225
|
+
concept: 'CompletionProperty',
|
|
1226
|
+
name: (item.groupElement as QueryFieldExpression).asName,
|
|
1227
|
+
value: `inner.${(item.groupElement as QueryFieldExpression).asName}`,
|
|
1228
|
+
expression: LogicItem.from({
|
|
1229
|
+
concept: 'Identifier',
|
|
1230
|
+
name: (item.groupElement as QueryFieldExpression).asName,
|
|
1231
|
+
namespace: 'inner',
|
|
1232
|
+
}),
|
|
1233
|
+
}));
|
|
1234
|
+
if (!children || children.length === 0)
|
|
1235
|
+
return;
|
|
1236
|
+
|
|
1237
|
+
children.forEach((item) => {
|
|
1238
|
+
item.icon = 'variable';
|
|
1239
|
+
});
|
|
1240
|
+
return { name: '分组属性别名', icon: 'category', children, expanded: true };
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1020
1243
|
//================================================================================
|
|
1021
1244
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
1022
1245
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
1023
1246
|
//================================================================================
|
|
1024
1247
|
}
|
|
1025
1248
|
|
|
1026
|
-
classMap
|
|
1249
|
+
classMap.CallQueryComponent = CallQueryComponent;
|
|
1027
1250
|
export default CallQueryComponent;
|
|
1028
1251
|
//================================================================================
|
|
1029
1252
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|