@lcap/nasl 1.0.1 → 2.12.0-beta.1
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 -0
- package/out/automate/engine/index.js +34 -12
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/operators.d.ts +10 -2
- package/out/automate/engine/operators.js +105 -7
- package/out/automate/engine/operators.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +8 -2
- package/out/automate/engine/uniqueName.js +72 -4
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.d.ts +1 -0
- package/out/automate/engine/utils.js +108 -67
- package/out/automate/engine/utils.js.map +1 -1
- package/out/automate/template/process.d.ts +9 -0
- package/out/automate/template/process.js +10976 -0
- package/out/automate/template/process.js.map +1 -0
- package/out/bak/translator.js +1 -0
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.d.ts +6 -1
- package/out/common/BaseNode.js +37 -6
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +52 -49
- package/out/concepts/App__.js +89 -53
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.d.ts +11 -0
- package/out/concepts/Assignee__.js +34 -0
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +2 -2
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +10 -3
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +15 -6
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +4 -0
- package/out/concepts/BooleanLiteral__.js +11 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +9 -4
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.js +48 -30
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +34 -4
- package/out/concepts/CallQueryComponent__.js +340 -95
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +1 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +7 -0
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +1 -0
- package/out/concepts/ConfigProperty__.js +3 -0
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +3 -0
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Constant__.js +6 -6
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +143 -0
- package/out/concepts/DataSource__.js +318 -0
- package/out/concepts/DataSource__.js.map +1 -0
- package/out/concepts/Destination__.js +22 -8
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +2 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +5 -0
- package/out/concepts/EntityIndex__.js +10 -2
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +9 -0
- package/out/concepts/EntityProperty__.js +22 -7
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +6 -0
- package/out/concepts/Entity__.js +27 -11
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +1 -0
- package/out/concepts/Enum__.js +14 -4
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -2
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.d.ts +18 -0
- package/out/concepts/Function__.js +96 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +5 -14
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +8 -8
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +9 -4
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js +19 -12
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js +3 -5
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/Logic__.js +44 -44
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Module__.d.ts +116 -194
- package/out/concepts/Module__.js +31 -114
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +0 -86
- package/out/concepts/Namespace__.js +1 -108
- package/out/concepts/Namespace__.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/ProcessElement__.js +38 -12
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Process__.d.ts +1 -1
- package/out/concepts/Process__.js +17 -10
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js +1 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +1 -0
- package/out/concepts/QueryFieldExpression__.js +11 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +4 -0
- package/out/concepts/QueryFromExpression__.js +13 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.d.ts +3 -0
- package/out/concepts/QueryGroupByExpression__.js +20 -0
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +4 -0
- package/out/concepts/QueryJoinExpression__.js +14 -3
- package/out/concepts/QueryJoinExpression__.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 +10 -3
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +14 -0
- package/out/concepts/SqlQueryComponent__.js +48 -5
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -1
- package/out/concepts/StringLiteral__.js +2 -9
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +11 -10
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +19 -12
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.d.ts +1 -1
- package/out/concepts/SwitchCase__.js +23 -25
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +1 -6
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +8 -0
- package/out/concepts/TypeAnnotation__.js +53 -3
- package/out/concepts/TypeAnnotation__.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/ViewElement__.js +25 -20
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -3
- package/out/concepts/View__.js +42 -36
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +4 -4
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +20 -0
- package/out/concepts/basics/stdlib/nasl.auth.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.process.d.ts +4 -0
- package/out/concepts/basics/stdlib/nasl.process.js +410 -0
- package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +1 -11
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +270 -8
- 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 +2 -0
- package/out/concepts/basics/types/index.js +6 -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 -7
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +3 -1
- package/out/generator/genBundleFiles.js +23 -5
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +1 -0
- package/out/generator/genMetaData.js +20 -12
- package/out/generator/genMetaData.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js +2 -1
- package/out/index.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/{test/integration/connect-file copy.d.ts → server/extendBaseNode.d.ts} +0 -0
- package/out/server/extendBaseNode.js +323 -0
- package/out/server/extendBaseNode.js.map +1 -0
- package/out/server/getLogics.js +49 -2
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +52 -2
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +8 -2
- package/out/server/getProcesses.js +228 -20
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/getScope.d.ts +1 -0
- package/out/server/getScope.js +4 -0
- 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 +8 -5
- package/out/server/naslServer.js +314 -383
- 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 +40 -2
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/errHandles.js +5 -0
- package/out/service/creator/errHandles.js.map +1 -1
- package/out/service/storage/init.d.ts +1 -0
- package/out/service/storage/init.js +113 -94
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +34 -24
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +28 -18
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +45 -29
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +15 -13
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +1 -1
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +29 -24
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -5
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.js +31 -29
- 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 +31 -21
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +35 -25
- 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 +5 -0
- package/out/utils/index.js +50 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -2
- package/src/automate/engine/index.js +33 -8
- package/src/automate/engine/operators.js +114 -17
- package/src/automate/engine/uniqueName.js +77 -9
- package/src/automate/engine/utils.js +110 -69
- package/src/automate/template/process.js +10999 -0
- package/src/bak/translator.js +1 -0
- package/src/common/BaseNode.ts +35 -7
- package/src/concepts/App__.ts +132 -131
- package/src/concepts/Assignee__.ts +30 -0
- package/src/concepts/BindAttribute__.ts +2 -2
- package/src/concepts/BindDirective__.ts +9 -7
- package/src/concepts/BindEvent__.ts +14 -6
- package/src/concepts/BooleanLiteral__.ts +12 -0
- package/src/concepts/CallFunction__.ts +7 -4
- package/src/concepts/CallLogic__.ts +47 -32
- package/src/concepts/CallQueryComponent__.ts +352 -101
- package/src/concepts/Comment__.ts +1 -1
- package/src/concepts/ConfigGroup__.ts +3 -1
- package/src/concepts/ConfigProperty__.ts +4 -0
- package/src/concepts/Configuration__.ts +3 -0
- package/src/concepts/Constant__.ts +6 -6
- package/src/concepts/DataSource__.ts +391 -0
- package/src/concepts/Destination__.ts +22 -8
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +11 -2
- package/src/concepts/EntityProperty__.ts +23 -7
- package/src/concepts/Entity__.ts +38 -14
- package/src/concepts/Enum__.ts +15 -4
- package/src/concepts/ForEachStatement__.ts +2 -2
- package/src/concepts/Function__.ts +95 -1
- package/src/concepts/Identifier__.ts +5 -14
- package/src/concepts/IfStatement__.ts +9 -9
- package/src/concepts/InterfaceParam__.ts +9 -4
- package/src/concepts/Interface__.ts +20 -12
- package/src/concepts/JSBlock__.ts +3 -12
- package/src/concepts/Logic__.ts +45 -79
- package/src/concepts/Module__.ts +141 -342
- package/src/concepts/Namespace__.ts +1 -204
- package/src/concepts/Param__.ts +17 -9
- package/src/concepts/ProcessElement__.ts +42 -15
- package/src/concepts/Process__.ts +18 -12
- package/src/concepts/QueryAggregateExpression__.ts +1 -1
- package/src/concepts/QueryFieldExpression__.ts +13 -1
- package/src/concepts/QueryFromExpression__.ts +13 -2
- package/src/concepts/QueryGroupByExpression__.ts +23 -0
- package/src/concepts/QueryJoinExpression__.ts +14 -3
- package/src/concepts/Return__.ts +16 -11
- package/src/concepts/Role__.ts +10 -4
- package/src/concepts/SqlQueryComponent__.ts +47 -11
- package/src/concepts/StringLiteral__.ts +2 -9
- package/src/concepts/StructureProperty__.ts +11 -14
- package/src/concepts/Structure__.ts +19 -11
- package/src/concepts/SwitchCase__.ts +23 -27
- package/src/concepts/SwitchStatement__.ts +1 -5
- package/src/concepts/TypeAnnotation__.ts +52 -3
- package/src/concepts/Variable__.ts +16 -11
- package/src/concepts/ViewElement__.ts +26 -39
- package/src/concepts/View__.ts +45 -38
- package/src/concepts/WhileStatement__.ts +4 -4
- package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
- 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.process.ts +406 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +1 -11
- package/src/concepts/basics/stdlib/nasl.util.ts +271 -8
- package/src/concepts/basics/stdlib/reference2TypeAnnotationList.ts +1 -1
- package/src/concepts/basics/types/index.ts +2 -0
- package/src/concepts/index__.ts +1 -0
- package/src/enums/KEYWORDS.ts +0 -7
- package/src/generator/genBundleFiles.ts +28 -7
- package/src/generator/genMetaData.ts +22 -13
- package/src/index.ts +1 -1
- 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 +51 -5
- package/src/server/getMemberIdentifier.ts +53 -2
- package/src/server/getProcesses.ts +238 -21
- package/src/server/getScope.ts +5 -0
- package/src/server/index.ts +1 -0
- package/src/server/naslServer.ts +322 -380
- package/src/server/process2LogicNamespace.ts +29 -19
- package/src/server/translator.ts +42 -2
- package/src/service/creator/errHandles.js +6 -0
- package/src/service/storage/init.ts +115 -97
- package/src/templator/genCreateBlock.ts +35 -26
- package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -21
- package/src/templator/genCurdMultipleKeyBlock.ts +46 -31
- package/src/templator/genEditTableBlock.ts +17 -14
- package/src/templator/genEnumSelectBlock.ts +1 -1
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +30 -25
- package/src/templator/genListViewBlock.ts +10 -7
- package/src/templator/genQueryComponent.ts +34 -30
- package/src/templator/genSelectBlock.ts +14 -23
- package/src/templator/genTableBlock.ts +32 -23
- package/src/templator/genUpdateBlock.ts +36 -26
- 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 +51 -0
- 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
- package/out/test/integration/connect-file copy.js +0 -50
- package/out/test/integration/connect-file copy.js.map +0 -1
- package/out/test/integration/node-nasl-server.d.ts +0 -1
- package/out/test/integration/node-nasl-server.js +0 -41
- package/out/test/integration/node-nasl-server.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
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -750,16 +751,16 @@ export class CallQueryComponent extends LogicItem {
|
|
|
750
751
|
if (list.length === 0)
|
|
751
752
|
return code;
|
|
752
753
|
|
|
753
|
-
code += indent(state
|
|
754
|
+
code += indent((state?.tabSize || 0) + 1) + `.${key}(() => `;
|
|
754
755
|
list.forEach((item, index) => {
|
|
755
756
|
if (index > 0)
|
|
756
|
-
code += `,\n${indent(state
|
|
757
|
+
code += `,\n${indent((state?.tabSize || 0) + 2)}() => `;
|
|
757
758
|
code += item?.toEmbeddedTS?.(shiftState(state, code, { tabSize: 0 }));
|
|
758
759
|
});
|
|
759
760
|
if (list.length > 1) {
|
|
760
761
|
if (multipleErrorType)
|
|
761
|
-
code += `,\n${indent(state
|
|
762
|
-
code += `\n${indent(state
|
|
762
|
+
code += `,\n${indent((state?.tabSize || 0) + 2)}() => ${multipleErrorType}`;
|
|
763
|
+
code += `\n${indent((state?.tabSize || 0) + 1)}`;
|
|
763
764
|
}
|
|
764
765
|
code += ')\n';
|
|
765
766
|
|
|
@@ -781,13 +782,44 @@ export class CallQueryComponent extends LogicItem {
|
|
|
781
782
|
// })`;
|
|
782
783
|
}
|
|
783
784
|
|
|
785
|
+
isAutoInfer() {
|
|
786
|
+
return this.ideVersion === '2.11';
|
|
787
|
+
}
|
|
788
|
+
|
|
784
789
|
@withSourceMap()
|
|
785
790
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
786
|
-
|
|
787
|
-
|
|
791
|
+
if (!this.typeAnnotation)
|
|
792
|
+
return `(function () {
|
|
793
|
+
return;
|
|
794
|
+
})()`;
|
|
795
|
+
let code = `(function(): `;
|
|
796
|
+
if (this.isAutoInfer()) {
|
|
797
|
+
code += `${this.typeAnnotation.toEmbeddedTS(shiftState(state, code))} {\n`;
|
|
798
|
+
} else {
|
|
799
|
+
code += `nasl.collection.PageOf<`;
|
|
800
|
+
code += `${this.typeAnnotation.toEmbeddedTS(shiftState(state, code))}> {\n`;
|
|
801
|
+
}
|
|
802
|
+
// 2.11版本后 分组使用别名
|
|
803
|
+
if (this.isAutoInfer()) {
|
|
804
|
+
// 分组别名(列别名)
|
|
805
|
+
this.groupBy.forEach((item, index, array) => {
|
|
806
|
+
code += indent(state.tabSize + 1);
|
|
807
|
+
const groupElement = item.groupElement as QueryFieldExpression;
|
|
808
|
+
if (groupElement.asName)
|
|
809
|
+
code += `const __${groupElement.asName} = `;
|
|
810
|
+
if (groupElement.propertyName) {
|
|
811
|
+
code += groupElement.toEmbeddedTS(shiftState(state, code, { tabSize: 0 }));
|
|
812
|
+
code += ';\n';
|
|
813
|
+
} else
|
|
814
|
+
code += `__EMPTY_GROUP_BY_NAME__;\n`;
|
|
815
|
+
|
|
816
|
+
if (index === array.length - 1)
|
|
817
|
+
code += '\n';
|
|
818
|
+
});
|
|
819
|
+
}
|
|
788
820
|
// 聚合属性别名
|
|
789
821
|
this.select.selectElements.forEach((item, index, array) => {
|
|
790
|
-
code += indent(state
|
|
822
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
791
823
|
const { asName, aggregateName, aggregateParam } = item;
|
|
792
824
|
if (asName)
|
|
793
825
|
code += `const __${asName} = `;
|
|
@@ -803,9 +835,9 @@ export class CallQueryComponent extends LogicItem {
|
|
|
803
835
|
});
|
|
804
836
|
|
|
805
837
|
if (this.from)
|
|
806
|
-
code += this.from.toEmbeddedTS(shiftState(state, code, { tabSize: state
|
|
838
|
+
code += this.from.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
807
839
|
else
|
|
808
|
-
code += `${indent(state
|
|
840
|
+
code += `${indent((state?.tabSize || 0) + 1)}nasl.langUtil.FROM()\n`;
|
|
809
841
|
|
|
810
842
|
// where 子句
|
|
811
843
|
code = this.toEmbeddedTSOfSubPart('WHERE', this.where ? [this.where] : [], {
|
|
@@ -821,7 +853,7 @@ export class CallQueryComponent extends LogicItem {
|
|
|
821
853
|
});
|
|
822
854
|
|
|
823
855
|
// 分组属性(Group by)
|
|
824
|
-
code = this.toEmbeddedTSOfSubPart('GROUP_BY', this.groupBy
|
|
856
|
+
code = this.toEmbeddedTSOfSubPart('GROUP_BY', this.groupBy, {
|
|
825
857
|
code,
|
|
826
858
|
state,
|
|
827
859
|
});
|
|
@@ -846,75 +878,250 @@ export class CallQueryComponent extends LogicItem {
|
|
|
846
878
|
});
|
|
847
879
|
|
|
848
880
|
code += '\n';
|
|
849
|
-
code += indent(state
|
|
850
|
-
code += indent(state
|
|
881
|
+
code += indent((state?.tabSize || 0) + 1) + 'return;\n';
|
|
882
|
+
code += indent((state?.tabSize || 0)) + '})();\n';
|
|
851
883
|
return code;
|
|
852
884
|
}
|
|
853
885
|
|
|
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
|
-
});
|
|
886
|
+
genPropertyListOfFrom(node: QueryFromExpression | QueryJoinExpression, entities: any[] = []) {
|
|
887
|
+
if (!node)
|
|
888
|
+
return [];
|
|
871
889
|
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
890
|
+
const entityName = node.entityName;
|
|
891
|
+
const entityNamespace = node.entityNamespace;
|
|
892
|
+
entities.push({
|
|
893
|
+
concept: 'StructureProperty',
|
|
894
|
+
name: utils.firstLowerCase(entityName),
|
|
895
|
+
typeAnnotation: {
|
|
896
|
+
concept: 'TypeAnnotation',
|
|
897
|
+
typeKind: 'reference',
|
|
898
|
+
typeName: entityName,
|
|
899
|
+
typeNamespace: entityNamespace,
|
|
900
|
+
},
|
|
901
|
+
});
|
|
875
902
|
|
|
876
|
-
|
|
903
|
+
for (const sub of node.joinParts) {
|
|
904
|
+
this.genPropertyListOfFrom(sub, entities);
|
|
877
905
|
}
|
|
878
906
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
.filter((item) => item.aggregateName && item.asName)
|
|
882
|
-
.map((item) => {
|
|
883
|
-
let typeName;
|
|
884
|
-
if (['COUNT', 'COUNTD'].includes(item.aggregateName))
|
|
885
|
-
typeName = 'Integer';
|
|
886
|
-
else {
|
|
887
|
-
const { entityAsName, propertyName } = item.aggregateParam;
|
|
888
|
-
const entity = app.entities.find((item: Entity) => item.name === entityAsName);
|
|
889
|
-
const property = entity?.properties.find((item) => item.name === propertyName);
|
|
890
|
-
typeName = property?.typeAnnotation.typeName;
|
|
891
|
-
}
|
|
892
|
-
return {
|
|
893
|
-
concept: 'StructureProperty',
|
|
894
|
-
name: item.asName,
|
|
895
|
-
typeAnnotation: {
|
|
896
|
-
concept: 'TypeAnnotation',
|
|
897
|
-
typeKind: 'primitive',
|
|
898
|
-
typeNamespace: 'nasl.core',
|
|
899
|
-
typeName,
|
|
900
|
-
},
|
|
901
|
-
};
|
|
902
|
-
});
|
|
903
|
-
}
|
|
907
|
+
return entities;
|
|
908
|
+
}
|
|
904
909
|
|
|
905
|
-
|
|
910
|
+
genPropertyListOfAggregate(node: CallQueryComponent, entities: Entity[]) {
|
|
911
|
+
return node.select.selectElements
|
|
912
|
+
.filter((item) => item.aggregateName && item.asName)
|
|
913
|
+
.map((item) => {
|
|
914
|
+
let typeName;
|
|
915
|
+
if (['COUNT', 'COUNTD'].includes(item.aggregateName)) {
|
|
916
|
+
typeName = 'Integer';
|
|
917
|
+
} else if (['AVG'].includes(item.aggregateName)) {
|
|
918
|
+
typeName = 'Double';
|
|
919
|
+
} else {
|
|
920
|
+
const { entityAsName, propertyName } = item.aggregateParam;
|
|
921
|
+
const entity = entities.find((item: Entity) => item.name === entityAsName);
|
|
922
|
+
const property = entity?.properties.find((item) => item.name === propertyName);
|
|
923
|
+
typeName = property?.typeAnnotation?.typeName;
|
|
924
|
+
}
|
|
925
|
+
return {
|
|
926
|
+
concept: 'StructureProperty',
|
|
927
|
+
name: item.asName,
|
|
928
|
+
typeAnnotation: {
|
|
929
|
+
concept: 'TypeAnnotation',
|
|
930
|
+
typeKind: 'primitive',
|
|
931
|
+
typeNamespace: 'nasl.core',
|
|
932
|
+
typeName,
|
|
933
|
+
},
|
|
934
|
+
};
|
|
935
|
+
});
|
|
936
|
+
}
|
|
906
937
|
|
|
938
|
+
genPropertyListOfGroupBy(node: CallQueryComponent, entities: Entity[]) {
|
|
939
|
+
return node.groupBy
|
|
940
|
+
.filter((item) => item.groupElement && (item.groupElement as QueryFieldExpression).propertyName && (item.groupElement as QueryFieldExpression).asName)
|
|
941
|
+
.map((item) => {
|
|
942
|
+
const { entityAsName, propertyName, asName } = item.groupElement as QueryFieldExpression;
|
|
943
|
+
const entity = entities.find((item: Entity) => item.name === entityAsName);
|
|
944
|
+
const property = entity?.properties.find((item) => item.name === propertyName);
|
|
945
|
+
const propertyTypeAnnotation = property.typeAnnotation;
|
|
946
|
+
|
|
947
|
+
return {
|
|
948
|
+
concept: 'StructureProperty',
|
|
949
|
+
name: asName,
|
|
950
|
+
typeAnnotation: {
|
|
951
|
+
concept: propertyTypeAnnotation.concept,
|
|
952
|
+
typeKind: propertyTypeAnnotation.typeKind,
|
|
953
|
+
typeName: propertyTypeAnnotation.typeName,
|
|
954
|
+
typeNamespace: propertyTypeAnnotation.typeNamespace,
|
|
955
|
+
},
|
|
956
|
+
};
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
genStructure(structureName?: string, properties: any[] = []) {
|
|
907
961
|
return Structure.from({
|
|
908
962
|
concept: 'Structure',
|
|
909
|
-
name: structureName
|
|
963
|
+
name: structureName || this.typeAnnotation?.typeName || `${utils.firstUpperCase(this.logic.name)}Structure`,
|
|
910
964
|
origin: 'CallQueryComponent',
|
|
911
|
-
properties
|
|
965
|
+
properties,
|
|
912
966
|
});
|
|
913
967
|
}
|
|
914
968
|
|
|
915
969
|
saveStructure() {
|
|
916
|
-
|
|
917
|
-
|
|
970
|
+
// 没有数据源时不初始化数据结构
|
|
971
|
+
if (!this.entityInfos.length) {
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
const entityNamespace = this.from?.entityNamespace;
|
|
975
|
+
const entities = this.app.findNodeByCompleteName(entityNamespace);
|
|
976
|
+
if (!this.isAutoInfer()) {
|
|
977
|
+
// 存量应用走之前的逻辑
|
|
978
|
+
return this.saveStructureNoInfer(entities);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
const groupBy = this.groupBy;
|
|
982
|
+
const selectElements = this.select.selectElements;
|
|
983
|
+
let structureName;
|
|
984
|
+
let typeAnnotation;
|
|
985
|
+
|
|
986
|
+
// Structures
|
|
987
|
+
if (this.typeAnnotation) {
|
|
988
|
+
const { typeNamespace, typeName, typeArguments } = this.typeAnnotation;
|
|
989
|
+
if (typeNamespace === 'app.structures') {
|
|
990
|
+
structureName = typeName;
|
|
991
|
+
this.removeStructure(structureName);
|
|
992
|
+
} else if (typeNamespace === 'nasl.collection' && typeName === 'PageOf') {
|
|
993
|
+
// PageOf<Structures>
|
|
994
|
+
if (typeArguments[0].typeNamespace === 'app.structures') {
|
|
995
|
+
structureName = typeArguments[0].typeName;
|
|
996
|
+
this.removeStructure(structureName);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
structureName = structureName || utils.unique(`${utils.firstUpperCase(this.logic.name)}Structure`, this.app.getStructureExistingNames());
|
|
1002
|
+
const groupByLength = groupBy.filter((item) => (item.groupElement as QueryFieldExpression)?.propertyName && (item.groupElement as QueryFieldExpression).asName).length;
|
|
1003
|
+
const aggregateLength = selectElements.filter((item) => item.aggregateName && item.asName).length;
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
// 1. 有分组
|
|
1008
|
+
if (groupByLength) {
|
|
1009
|
+
if (!aggregateLength && groupByLength === 1) {
|
|
1010
|
+
// 1.1 单分组无聚合:`PageOf<列的类型>`
|
|
1011
|
+
const { entityAsName, propertyName } = groupBy[0].groupElement as QueryFieldExpression;
|
|
1012
|
+
const entity = entities.find((item: Entity) => item.name === entityAsName);
|
|
1013
|
+
const property = entity?.properties.find((item: any) => item.name === propertyName);
|
|
1014
|
+
const propertyTypeAnnotation = property.typeAnnotation;
|
|
1015
|
+
|
|
1016
|
+
typeAnnotation = TypeAnnotation.from({
|
|
1017
|
+
text: `PageOf<${propertyTypeAnnotation.typeName}>`,
|
|
1018
|
+
concept: 'TypeAnnotation',
|
|
1019
|
+
typeKind: 'generic',
|
|
1020
|
+
typeName: 'PageOf',
|
|
1021
|
+
typeNamespace: `nasl.collection`,
|
|
1022
|
+
typeArguments: [TypeAnnotation.from({
|
|
1023
|
+
concept: propertyTypeAnnotation.concept,
|
|
1024
|
+
typeKind: propertyTypeAnnotation.typeKind,
|
|
1025
|
+
typeName: propertyTypeAnnotation.typeName,
|
|
1026
|
+
typeNamespace: propertyTypeAnnotation.typeNamespace,
|
|
1027
|
+
}, this.typeAnnotation, 'typeAnnotation')],
|
|
1028
|
+
}, this, 'typeAnnotation');
|
|
1029
|
+
} else {
|
|
1030
|
+
// 1.2 多分组:`PageOf<Structure>`
|
|
1031
|
+
const structure = this.genStructure(structureName, [
|
|
1032
|
+
...this.genPropertyListOfGroupBy(this, entities),
|
|
1033
|
+
...this.genPropertyListOfAggregate(this, entities),
|
|
1034
|
+
]);
|
|
1035
|
+
this.app.addStructure(structure);
|
|
1036
|
+
|
|
1037
|
+
typeAnnotation = TypeAnnotation.from({
|
|
1038
|
+
text: `PageOf<${structureName}>`,
|
|
1039
|
+
concept: 'TypeAnnotation',
|
|
1040
|
+
typeKind: 'generic',
|
|
1041
|
+
typeName: 'PageOf',
|
|
1042
|
+
typeNamespace: `nasl.collection`,
|
|
1043
|
+
typeArguments: [
|
|
1044
|
+
TypeAnnotation.from({
|
|
1045
|
+
concept: 'TypeAnnotation',
|
|
1046
|
+
typeKind: 'reference',
|
|
1047
|
+
typeName: structureName,
|
|
1048
|
+
typeNamespace: 'app.structures',
|
|
1049
|
+
}, this.typeAnnotation, 'typeAnnotation'),
|
|
1050
|
+
],
|
|
1051
|
+
}, this, 'typeAnnotation');
|
|
1052
|
+
}
|
|
1053
|
+
} else { // 2. 无分组
|
|
1054
|
+
if (aggregateLength) {
|
|
1055
|
+
if (aggregateLength === 1) {
|
|
1056
|
+
// 2.1 单聚合:`基本类型`
|
|
1057
|
+
let typeName;
|
|
1058
|
+
if (['COUNT', 'COUNTD'].includes(selectElements[0].aggregateName)) {
|
|
1059
|
+
// 2.1.1. `COUNT`、`COUNTD` 返回 `Integer`
|
|
1060
|
+
typeName = 'Integer';
|
|
1061
|
+
} else if (['AVG'].includes(selectElements[0].aggregateName)) {
|
|
1062
|
+
// 2.1.2. `AVG` 返回 `Double`
|
|
1063
|
+
typeName = 'Double';
|
|
1064
|
+
} else {
|
|
1065
|
+
// 2.1.3. 其他返回列类型,包含:`Integer`、`Long`、`Double`
|
|
1066
|
+
const { entityAsName, propertyName } = selectElements[0].aggregateParam;
|
|
1067
|
+
const entity = entities.find((item: Entity) => item.name === entityAsName);
|
|
1068
|
+
const property = entity?.properties.find((item: any) => item.name === propertyName);
|
|
1069
|
+
typeName = property?.typeAnnotation?.typeName;
|
|
1070
|
+
}
|
|
1071
|
+
typeAnnotation = TypeAnnotation.from({
|
|
1072
|
+
concept: 'TypeAnnotation',
|
|
1073
|
+
typeKind: 'primitive',
|
|
1074
|
+
typeName,
|
|
1075
|
+
typeNamespace: 'nasl.core',
|
|
1076
|
+
}, this, 'typeAnnotation');
|
|
1077
|
+
} else {
|
|
1078
|
+
// 2.2. 多聚合:`Structure`(自动创建 `Structure`)
|
|
1079
|
+
const structure = this.genStructure(structureName, [
|
|
1080
|
+
...this.genPropertyListOfAggregate(this, entities),
|
|
1081
|
+
]);
|
|
1082
|
+
this.app.addStructure(structure);
|
|
1083
|
+
|
|
1084
|
+
typeAnnotation = TypeAnnotation.from({
|
|
1085
|
+
concept: 'TypeAnnotation',
|
|
1086
|
+
typeKind: 'reference',
|
|
1087
|
+
typeName: structureName,
|
|
1088
|
+
typeNamespace: `app.structures`,
|
|
1089
|
+
}, this, 'typeAnnotation');
|
|
1090
|
+
}
|
|
1091
|
+
} else {
|
|
1092
|
+
// 2.3. 无聚合(默认情况):`PageOf<Structure>`(自动创建 `Structure`)
|
|
1093
|
+
const structure = this.genStructure(structureName, [
|
|
1094
|
+
...this.genPropertyListOfFrom(this.from),
|
|
1095
|
+
...this.genPropertyListOfAggregate(this, entities),
|
|
1096
|
+
]);
|
|
1097
|
+
this.app.addStructure(structure);
|
|
1098
|
+
|
|
1099
|
+
typeAnnotation = TypeAnnotation.from({
|
|
1100
|
+
text: structureName,
|
|
1101
|
+
concept: 'TypeAnnotation',
|
|
1102
|
+
typeKind: 'generic',
|
|
1103
|
+
typeName: 'PageOf',
|
|
1104
|
+
typeNamespace: `nasl.collection`,
|
|
1105
|
+
typeArguments: [
|
|
1106
|
+
TypeAnnotation.from({
|
|
1107
|
+
concept: 'TypeAnnotation',
|
|
1108
|
+
typeKind: 'reference',
|
|
1109
|
+
typeName: structureName,
|
|
1110
|
+
typeNamespace: 'app.structures',
|
|
1111
|
+
}, this.typeAnnotation, 'typeAnnotation'),
|
|
1112
|
+
],
|
|
1113
|
+
}, this, 'typeAnnotation');
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
this.update({ typeAnnotation });
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
saveStructureNoInfer(entities: any[] = []) {
|
|
1121
|
+
const source = this.genStructure(null, [
|
|
1122
|
+
...this.genPropertyListOfFrom(this.from),
|
|
1123
|
+
...this.genPropertyListOfAggregate(this, entities),
|
|
1124
|
+
]);
|
|
918
1125
|
if (this.typeAnnotation) {
|
|
919
1126
|
const structure = this.app.structures.find((item) => item.name === this.typeAnnotation.typeName);
|
|
920
1127
|
if (structure) {
|
|
@@ -939,59 +1146,80 @@ export class CallQueryComponent extends LogicItem {
|
|
|
939
1146
|
}
|
|
940
1147
|
}
|
|
941
1148
|
|
|
942
|
-
removeStructure() {
|
|
1149
|
+
removeStructure(structureName?: string) {
|
|
943
1150
|
try {
|
|
944
|
-
|
|
1151
|
+
if (this.typeAnnotation) {
|
|
1152
|
+
const { typeNamespace, typeName, typeArguments } = this.typeAnnotation;
|
|
1153
|
+
if (typeNamespace === 'app.structures') {
|
|
1154
|
+
// Structures
|
|
1155
|
+
structureName = typeName;
|
|
1156
|
+
this.app.removeStructure(structureName);
|
|
1157
|
+
} else if (typeNamespace === 'nasl.collection' && typeName === 'PageOf') {
|
|
1158
|
+
// PageOf<Structures>
|
|
1159
|
+
if (typeArguments[0].typeNamespace === 'app.structures') {
|
|
1160
|
+
structureName = typeArguments[0].typeName;
|
|
1161
|
+
this.app.removeStructure(structureName);
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
945
1165
|
} catch {}
|
|
946
1166
|
}
|
|
947
1167
|
|
|
948
|
-
|
|
1168
|
+
getEntityInfos(node: QueryFromExpression | QueryJoinExpression, set = new Set()) {
|
|
949
1169
|
if (node?.entityName)
|
|
950
|
-
set.add(
|
|
1170
|
+
set.add({
|
|
1171
|
+
namespace: node.entityNamespace,
|
|
1172
|
+
name: node.entityName,
|
|
1173
|
+
});
|
|
951
1174
|
|
|
952
1175
|
node?.joinParts?.forEach((child) => {
|
|
953
|
-
this.
|
|
1176
|
+
this.getEntityInfos(child, set);
|
|
954
1177
|
});
|
|
955
1178
|
return Array.from(set);
|
|
956
1179
|
}
|
|
957
1180
|
|
|
958
|
-
get
|
|
959
|
-
return this.
|
|
1181
|
+
get entityInfos() {
|
|
1182
|
+
return this.getEntityInfos(this.from);
|
|
960
1183
|
}
|
|
961
1184
|
|
|
962
1185
|
getCompletionPropertyOfEntities() {
|
|
963
|
-
const
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
.
|
|
967
|
-
.
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
concept: '
|
|
973
|
-
name:
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1186
|
+
const firstEntityInfo: any = this.entityInfos[0];
|
|
1187
|
+
if (firstEntityInfo) {
|
|
1188
|
+
const namespace = firstEntityInfo.namespace;
|
|
1189
|
+
const entities: Entity[] = this.app.findNodeByCompleteName(namespace);
|
|
1190
|
+
if (Array.isArray(entities)) {
|
|
1191
|
+
const children = this.entityInfos
|
|
1192
|
+
.map(({ name }) => entities.find((item) => item.name === name))
|
|
1193
|
+
.filter((item) => item)
|
|
1194
|
+
.map((entity) => ({
|
|
1195
|
+
concept: 'Entity',
|
|
1196
|
+
name: entity.name,
|
|
1197
|
+
children: entity.properties.map((property) => {
|
|
1198
|
+
const completionProperty = new CompletionProperty({
|
|
1199
|
+
concept: 'CompletionProperty',
|
|
1200
|
+
name: property.name,
|
|
1201
|
+
value: `${entity.name}.${property.name}`,
|
|
1202
|
+
expression: LogicItem.from({
|
|
1203
|
+
concept: 'QueryFieldExpression',
|
|
1204
|
+
name: property.name,
|
|
1205
|
+
value: `${entity.name}.${property.name}`,
|
|
1206
|
+
entityAsName: entity.name,
|
|
1207
|
+
propertyName: property.name,
|
|
1208
|
+
}),
|
|
1209
|
+
});
|
|
1210
|
+
completionProperty.icon = 'property';
|
|
1211
|
+
return completionProperty;
|
|
981
1212
|
}),
|
|
982
|
-
});
|
|
983
|
-
|
|
984
|
-
return
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
icon: 'category',
|
|
993
|
-
children,
|
|
994
|
-
};
|
|
1213
|
+
}));
|
|
1214
|
+
if (children.length) {
|
|
1215
|
+
return {
|
|
1216
|
+
name: '实体',
|
|
1217
|
+
icon: 'category',
|
|
1218
|
+
children,
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
995
1223
|
}
|
|
996
1224
|
|
|
997
1225
|
getCompletionPropertyOfAggregateAsNames() {
|
|
@@ -1017,6 +1245,29 @@ export class CallQueryComponent extends LogicItem {
|
|
|
1017
1245
|
return { name: '聚合属性别名', icon: 'category', children, expanded: true };
|
|
1018
1246
|
}
|
|
1019
1247
|
|
|
1248
|
+
getCompletionPropertyOfGroupByAsNames() {
|
|
1249
|
+
const children = this.groupBy
|
|
1250
|
+
?.filter((item) => item.concept === 'QueryGroupByExpression' && (item.groupElement as QueryFieldExpression)?.asName)
|
|
1251
|
+
.map((item) =>
|
|
1252
|
+
new CompletionProperty({
|
|
1253
|
+
concept: 'CompletionProperty',
|
|
1254
|
+
name: (item.groupElement as QueryFieldExpression).asName,
|
|
1255
|
+
value: `inner.${(item.groupElement as QueryFieldExpression).asName}`,
|
|
1256
|
+
expression: LogicItem.from({
|
|
1257
|
+
concept: 'Identifier',
|
|
1258
|
+
name: (item.groupElement as QueryFieldExpression).asName,
|
|
1259
|
+
namespace: 'inner',
|
|
1260
|
+
}),
|
|
1261
|
+
}));
|
|
1262
|
+
if (!children || children.length === 0)
|
|
1263
|
+
return;
|
|
1264
|
+
|
|
1265
|
+
children.forEach((item) => {
|
|
1266
|
+
item.icon = 'variable';
|
|
1267
|
+
});
|
|
1268
|
+
return { name: '分组属性别名', icon: 'category', children, expanded: true };
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1020
1271
|
//================================================================================
|
|
1021
1272
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
1022
1273
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -275,7 +275,9 @@ export class ConfigGroup extends BaseNode {
|
|
|
275
275
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
276
276
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
277
277
|
//================================================================================
|
|
278
|
-
|
|
278
|
+
getProperty(name = '') {
|
|
279
|
+
return this.properties.find((item) => item.name === name);
|
|
280
|
+
}
|
|
279
281
|
//================================================================================
|
|
280
282
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
281
283
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -292,6 +292,10 @@ export class ConfigProperty extends BaseNode {
|
|
|
292
292
|
...object,
|
|
293
293
|
});
|
|
294
294
|
}
|
|
295
|
+
|
|
296
|
+
getPropertyEnv(env = '') {
|
|
297
|
+
return this.values.find((item) => item.env === env);
|
|
298
|
+
}
|
|
295
299
|
//================================================================================
|
|
296
300
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
297
301
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -271,6 +271,9 @@ export class Configuration extends BaseNode {
|
|
|
271
271
|
],
|
|
272
272
|
};
|
|
273
273
|
}
|
|
274
|
+
getGroup(name = '') {
|
|
275
|
+
return this.groups.find((item) => item.name === name);
|
|
276
|
+
}
|
|
274
277
|
|
|
275
278
|
//================================================================================
|
|
276
279
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -230,9 +230,9 @@ export class Constant extends BaseNode {
|
|
|
230
230
|
code += ': ';
|
|
231
231
|
code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
|
|
232
232
|
}
|
|
233
|
-
if (this.defaultValue) {
|
|
234
|
-
|
|
235
|
-
}
|
|
233
|
+
// if (this.defaultValue) {
|
|
234
|
+
// code += ` = ${this.defaultValue}`;
|
|
235
|
+
// }
|
|
236
236
|
return code;
|
|
237
237
|
}
|
|
238
238
|
@withSourceMap()
|
|
@@ -242,9 +242,9 @@ export class Constant extends BaseNode {
|
|
|
242
242
|
code += ': undefined as ';
|
|
243
243
|
code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
|
|
244
244
|
}
|
|
245
|
-
if (this.defaultValue) {
|
|
246
|
-
|
|
247
|
-
}
|
|
245
|
+
// if (this.defaultValue) {
|
|
246
|
+
// code += ` : ${this.defaultValue}`;
|
|
247
|
+
// }
|
|
248
248
|
return code;
|
|
249
249
|
}
|
|
250
250
|
//================================================================================
|