@lcap/nasl 3.3.0-beta.0 → 3.3.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/common/BaseNode.js +2 -1
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/Abort__.js +2 -1
- package/out/concepts/Abort__.js.map +1 -1
- package/out/concepts/Anchor__.d.ts +1 -0
- package/out/concepts/Anchor__.js +16 -0
- package/out/concepts/Anchor__.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +1 -0
- package/out/concepts/AnonymousFunction__.js +27 -1
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.js +2 -1
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.d.ts +1 -0
- package/out/concepts/Argument__.js +21 -0
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/AssignmentLine__.js +1 -1
- package/out/concepts/AssignmentLine__.js.map +1 -1
- package/out/concepts/Assignment__.d.ts +1 -0
- package/out/concepts/Assignment__.js +15 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +1 -1
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/Backend__.js +1 -1
- package/out/concepts/Backend__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +1 -0
- package/out/concepts/BatchAssignment__.js +18 -1
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BinaryExpression__.d.ts +1 -0
- package/out/concepts/BinaryExpression__.js +38 -1
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +1 -0
- package/out/concepts/BindAttribute__.js +67 -3
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +1 -1
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +1 -0
- package/out/concepts/BindEvent__.js +57 -0
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.js +1 -1
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +1 -0
- package/out/concepts/BooleanLiteral__.js +7 -1
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallAuthInterface__.js +1 -1
- package/out/concepts/CallAuthInterface__.js.map +1 -1
- package/out/concepts/CallConnector__.js +1 -1
- package/out/concepts/CallConnector__.js.map +1 -1
- package/out/concepts/CallFunction__.d.ts +1 -0
- package/out/concepts/CallFunction__.js +45 -1
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +3 -1
- package/out/concepts/CallInterface__.js +112 -17
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +1 -0
- package/out/concepts/CallLogic__.js +101 -1
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +1 -1
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.d.ts +1 -0
- package/out/concepts/Comment__.js +7 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js +1 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Constant__.js +1 -1
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.js +1 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -0
- package/out/concepts/Destination__.js +52 -1
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +1 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.js +1 -1
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +1 -0
- package/out/concepts/EntityProperty__.js +17 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -0
- package/out/concepts/Entity__.js +25 -1
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +1 -0
- package/out/concepts/EnumItem__.js +7 -1
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +1 -0
- package/out/concepts/Enum__.js +14 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.d.ts +1 -0
- package/out/concepts/ForEachStatement__.js +44 -1
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Frontend__.js +1 -1
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Function__.d.ts +1 -0
- package/out/concepts/Function__.js +29 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +1 -1
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.d.ts +1 -0
- package/out/concepts/IfStatement__.js +30 -1
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +3 -1
- package/out/concepts/Interface__.js +19 -3
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.d.ts +1 -0
- package/out/concepts/JSBlock__.js +7 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/JavaLogic__.js +1 -1
- package/out/concepts/JavaLogic__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +6 -0
- package/out/concepts/LogicItem__.js +10 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +1 -0
- package/out/concepts/Logic__.js +132 -20
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.d.ts +1 -0
- package/out/concepts/MatchCase__.js +88 -0
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.d.ts +1 -0
- package/out/concepts/Match__.js +44 -1
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -0
- package/out/concepts/MemberExpression__.js +19 -1
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +1 -0
- package/out/concepts/Module__.js +16 -0
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +1 -0
- package/out/concepts/NewComposite__.js +91 -1
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.d.ts +1 -0
- package/out/concepts/NewList__.js +17 -1
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.d.ts +1 -0
- package/out/concepts/NewMap__.js +11 -1
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/New__.js +1 -1
- package/out/concepts/New__.js.map +1 -1
- package/out/concepts/NullLiteral__.js +1 -1
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.d.ts +1 -0
- package/out/concepts/NumericLiteral__.js +7 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.d.ts +1 -0
- package/out/concepts/OqlQueryComponent__.js +8 -1
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.js +1 -1
- package/out/concepts/OverriddenLogic__.js.map +1 -1
- package/out/concepts/Param__.d.ts +1 -0
- package/out/concepts/Param__.js +41 -0
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +1 -1
- 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/ProcessOutcomes__.js +1 -1
- package/out/concepts/ProcessOutcomes__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js +1 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.js +1 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +1 -1
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +1 -1
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js +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/Return__.d.ts +1 -0
- package/out/concepts/Return__.js +20 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +1 -1
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SelectMembers__.js +1 -1
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +1 -0
- package/out/concepts/SqlQueryComponent__.js +8 -1
- 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/StringInterpolation__.d.ts +1 -0
- package/out/concepts/StringInterpolation__.js +19 -1
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -0
- package/out/concepts/StringLiteral__.js +6 -0
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +5 -0
- package/out/concepts/StructureProperty__.js +19 -2
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +5 -0
- package/out/concepts/Structure__.js +22 -2
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.d.ts +1 -0
- package/out/concepts/SwitchCase__.js +34 -0
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.d.ts +1 -0
- package/out/concepts/SwitchStatement__.js +19 -1
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TriggerLauncher__.js +1 -1
- package/out/concepts/TriggerLauncher__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +1 -0
- package/out/concepts/TypeAnnotation__.js +47 -1
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +1 -0
- package/out/concepts/TypeParam__.js +6 -0
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.d.ts +1 -0
- package/out/concepts/UnaryExpression__.js +19 -1
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/Unparsed__.d.ts +1 -0
- package/out/concepts/Unparsed__.js +6 -0
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +1 -0
- package/out/concepts/Variable__.js +20 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +2 -0
- package/out/concepts/ViewElement__.js +74 -2
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +2 -0
- package/out/concepts/View__.js +106 -2
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.d.ts +1 -0
- package/out/concepts/WhileStatement__.js +21 -1
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/generator/permission.js +3 -1
- package/out/generator/permission.js.map +1 -1
- package/out/index.d.ts +1 -0
- package/out/index.js +1 -0
- package/out/index.js.map +1 -1
- package/out/natural/componentData.d.ts +31 -0
- package/out/natural/componentData.js +85 -0
- package/out/natural/componentData.js.map +1 -0
- package/out/natural/genNaturalTS.d.ts +3 -0
- package/out/natural/genNaturalTS.js +90 -0
- package/out/natural/genNaturalTS.js.map +1 -0
- package/out/natural/index.d.ts +2 -0
- package/out/natural/index.js +19 -0
- package/out/natural/index.js.map +1 -0
- package/out/natural/naslStdlibMap.d.ts +2 -0
- package/out/natural/naslStdlibMap.js +26 -0
- package/out/natural/naslStdlibMap.js.map +1 -0
- package/out/natural/transformTSCode.d.ts +7 -0
- package/out/natural/transformTSCode.js +883 -0
- package/out/natural/transformTSCode.js.map +1 -0
- package/out/server/naslServer.d.ts +4 -4
- package/out/server/naslServer.js +98 -111
- package/out/server/naslServer.js.map +1 -1
- package/out/service/storage/init.js +16 -0
- package/out/service/storage/init.js.map +1 -1
- package/out/translator/utils.js +24 -28
- package/out/translator/utils.js.map +1 -1
- package/out/utils/env.d.ts +2 -0
- package/out/utils/env.js +6 -0
- package/out/utils/env.js.map +1 -0
- package/out/utils/index.d.ts +1 -0
- package/out/utils/index.js +1 -0
- package/out/utils/index.js.map +1 -1
- package/out/utils/time-slicing.js +2 -1
- package/out/utils/time-slicing.js.map +1 -1
- package/package.json +11 -5
- package/sandbox-natural/stdlib/nasl.core.ts +36 -0
- package/sandbox-natural/stdlib/nasl.oql.ts +8 -0
- package/sandbox-natural/stdlib/nasl.ui.ts +63 -0
- package/sandbox-natural/stdlib/nasl.util.ts +119 -0
- package/sandbox-natural/tsconfig.json +12 -0
- package/src/common/BaseNode.ts +3 -1
- package/src/concepts/Abort__.ts +2 -2
- package/src/concepts/Anchor__.ts +16 -2
- package/src/concepts/AnonymousFunction__.ts +28 -2
- package/src/concepts/App__.ts +2 -1
- package/src/concepts/Argument__.ts +19 -1
- package/src/concepts/Assignee__.ts +1 -1
- package/src/concepts/AssignmentLine__.ts +2 -2
- package/src/concepts/Assignment__.ts +26 -11
- package/src/concepts/BackendVariable__.ts +2 -2
- package/src/concepts/Backend__.ts +1 -1
- package/src/concepts/BatchAssignment__.ts +20 -3
- package/src/concepts/BinaryExpression__.ts +38 -3
- package/src/concepts/BindAttribute__.ts +63 -4
- package/src/concepts/BindDirective__.ts +2 -2
- package/src/concepts/BindEvent__.ts +58 -0
- package/src/concepts/BindStyle__.ts +2 -2
- package/src/concepts/BooleanLiteral__.ts +7 -2
- package/src/concepts/CallAuthInterface__.ts +2 -2
- package/src/concepts/CallConnector__.ts +2 -2
- package/src/concepts/CallFunction__.ts +42 -2
- package/src/concepts/CallInterface__.ts +113 -20
- package/src/concepts/CallLogic__.ts +123 -3
- package/src/concepts/CallQueryComponent__.ts +2 -2
- package/src/concepts/Comment__.ts +9 -3
- package/src/concepts/ConfigProperty__.ts +1 -1
- package/src/concepts/Constant__.ts +2 -2
- package/src/concepts/DataSource__.ts +1 -1
- package/src/concepts/Destination__.ts +58 -2
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +2 -2
- package/src/concepts/EntityProperty__.ts +18 -2
- package/src/concepts/Entity__.ts +27 -1
- package/src/concepts/EnumItem__.ts +7 -2
- package/src/concepts/Enum__.ts +14 -1
- package/src/concepts/ForEachStatement__.ts +48 -4
- package/src/concepts/Frontend__.ts +1 -1
- package/src/concepts/Function__.ts +30 -2
- package/src/concepts/Identifier__.ts +2 -2
- package/src/concepts/IfStatement__.ts +39 -3
- package/src/concepts/Interface__.ts +20 -3
- package/src/concepts/JSBlock__.ts +7 -2
- package/src/concepts/JavaLogic__.ts +2 -2
- package/src/concepts/LogicItem__.ts +11 -2
- package/src/concepts/Logic__.ts +149 -26
- package/src/concepts/MatchCase__.ts +90 -2
- package/src/concepts/Match__.ts +47 -3
- package/src/concepts/MemberExpression__.ts +19 -2
- package/src/concepts/Module__.ts +16 -0
- package/src/concepts/NewComposite__.ts +85 -2
- package/src/concepts/NewList__.ts +17 -2
- package/src/concepts/NewMap__.ts +11 -2
- package/src/concepts/New__.ts +2 -2
- package/src/concepts/NullLiteral__.ts +2 -2
- package/src/concepts/NumericLiteral__.ts +7 -2
- package/src/concepts/OqlQueryComponent__.ts +8 -2
- package/src/concepts/OverriddenLogic__.ts +1 -1
- package/src/concepts/Param__.ts +40 -1
- package/src/concepts/ProcessElement__.ts +2 -2
- package/src/concepts/ProcessOutcome__.ts +2 -2
- package/src/concepts/ProcessOutcomes__.ts +2 -2
- package/src/concepts/QueryAggregateExpression__.ts +2 -2
- package/src/concepts/QueryFieldExpression__.ts +2 -2
- package/src/concepts/QueryFromExpression__.ts +2 -2
- package/src/concepts/QueryJoinExpression__.ts +2 -2
- package/src/concepts/QueryLimitExpression__.ts +2 -2
- package/src/concepts/QueryOrderByExpression__.ts +2 -2
- package/src/concepts/Return__.ts +20 -2
- package/src/concepts/Role__.ts +1 -1
- package/src/concepts/SelectMembers__.ts +2 -2
- package/src/concepts/SqlQueryComponent__.ts +8 -2
- package/src/concepts/Start__.ts +2 -2
- package/src/concepts/StringInterpolation__.ts +20 -3
- package/src/concepts/StringLiteral__.ts +6 -1
- package/src/concepts/StructureProperty__.ts +20 -3
- package/src/concepts/Structure__.ts +22 -2
- package/src/concepts/SwitchCase__.ts +35 -2
- package/src/concepts/SwitchStatement__.ts +20 -3
- package/src/concepts/TriggerLauncher__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +47 -2
- package/src/concepts/TypeParam__.ts +8 -2
- package/src/concepts/UnaryExpression__.ts +22 -3
- package/src/concepts/Unparsed__.ts +5 -1
- package/src/concepts/ValidationRule__.ts +2 -2
- package/src/concepts/Variable__.ts +20 -2
- package/src/concepts/ViewElement__.ts +77 -4
- package/src/concepts/View__.ts +122 -8
- package/src/concepts/WhileStatement__.ts +25 -3
- package/src/generator/permission.ts +3 -1
- package/src/index.ts +1 -0
- package/src/natural/componentData.ts +81 -0
- package/src/natural/genNaturalTS.ts +90 -0
- package/src/natural/index.ts +2 -0
- package/src/natural/naslStdlibMap.ts +24 -0
- package/src/natural/transformTSCode.ts +840 -0
- package/src/server/naslServer.ts +95 -90
- package/src/service/storage/init.ts +17 -0
- package/src/translator/utils.ts +7 -9
- package/src/utils/env.ts +2 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/time-slicing.ts +3 -1
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +66 -62
package/src/concepts/Entity__.ts
CHANGED
|
@@ -810,7 +810,7 @@ export class Entity extends BaseNode {
|
|
|
810
810
|
}
|
|
811
811
|
|
|
812
812
|
@withSourceMap()
|
|
813
|
-
toEmbeddedTS(state
|
|
813
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
814
814
|
let code = `export class ${this.name} {\n`;
|
|
815
815
|
code += indent((state?.tabSize || 0) + 1);
|
|
816
816
|
code += `__name: '${this.getNamespace()}.${this.name}';\n`;
|
|
@@ -848,6 +848,32 @@ export class Entity extends BaseNode {
|
|
|
848
848
|
return code;
|
|
849
849
|
}
|
|
850
850
|
|
|
851
|
+
@withSourceMap()
|
|
852
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
853
|
+
let code = `class ${this.name} {\n`;
|
|
854
|
+
// code += `${indent(state.tabSize + 1)}__name: '${this.getNamespace()}.${this.name}';\n`;
|
|
855
|
+
this.properties.forEach((property) => {
|
|
856
|
+
code += `${property.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1 }))};\n`;
|
|
857
|
+
});
|
|
858
|
+
if (this.indexes && this.indexes.length) {
|
|
859
|
+
code += indent(state.tabSize + 1);
|
|
860
|
+
code += `__IndexList() {\n`;
|
|
861
|
+
code += ` return [`;
|
|
862
|
+
this.indexes.forEach((entityIndex) => {
|
|
863
|
+
code += indent(state.tabSize + 1);
|
|
864
|
+
code += '\n ';
|
|
865
|
+
code += entityIndex.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
866
|
+
});
|
|
867
|
+
code += `${indent(state.tabSize)}\n ];\n }\n`;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
code += `${indent(state.tabSize)}}\n`;
|
|
871
|
+
|
|
872
|
+
code += `const ${this.name}Entity = createEntity<${this.name}>();\n`;
|
|
873
|
+
|
|
874
|
+
return code;
|
|
875
|
+
}
|
|
876
|
+
|
|
851
877
|
getNamespace() {
|
|
852
878
|
if (this.parentNode && (this.parentNode as DataSource).getNamespace)
|
|
853
879
|
return `${(this.parentNode as DataSource).getNamespace()}.${this.parentNode.name}.entities`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, withSourceMap } from '../translator';
|
|
1
|
+
import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
|
|
2
2
|
//================================================================================
|
|
3
3
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
4
4
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -121,10 +121,15 @@ export class EnumItem extends BaseNode {
|
|
|
121
121
|
expression: undefined;
|
|
122
122
|
|
|
123
123
|
@withSourceMap()
|
|
124
|
-
toEmbeddedTS(state
|
|
124
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
125
125
|
return `static '${this.value}': ${this.enumeration.name}`;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
@withSourceMap()
|
|
129
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
130
|
+
return `'${this.value}' = '${this.label}'`;
|
|
131
|
+
}
|
|
132
|
+
|
|
128
133
|
setName(value: string) {
|
|
129
134
|
this.setValue(value);
|
|
130
135
|
}
|
package/src/concepts/Enum__.ts
CHANGED
|
@@ -295,7 +295,7 @@ export class Enum extends BaseNode {
|
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
@withSourceMap()
|
|
298
|
-
toEmbeddedTS(state
|
|
298
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
299
299
|
let code = `export class ${this.name} extends nasl.core.Enums {\n`;
|
|
300
300
|
// 增加一个单独的标签
|
|
301
301
|
code += `${indent((state?.tabSize || 0) + 1)}__name: '${this.getNamespace()}.${this.name}';\n`;
|
|
@@ -315,6 +315,19 @@ export class Enum extends BaseNode {
|
|
|
315
315
|
return code;
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
+
@withSourceMap()
|
|
319
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
320
|
+
let code = `enum ${this.name} {\n`;
|
|
321
|
+
this.enumItems.forEach((property) => {
|
|
322
|
+
code += indent(state.tabSize + 1);
|
|
323
|
+
code += property.toNaturalTS(shiftState(state, code, { tabSize: 0 }));
|
|
324
|
+
code += ',\n';
|
|
325
|
+
});
|
|
326
|
+
code += `${indent(state?.tabSize || 0)}}\n`;
|
|
327
|
+
|
|
328
|
+
return code;
|
|
329
|
+
}
|
|
330
|
+
|
|
318
331
|
getNamespace() {
|
|
319
332
|
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
320
333
|
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
2
3
|
import TypeAnnotation from './TypeAnnotation__';
|
|
3
4
|
import Identifier from './Identifier__';
|
|
4
5
|
import MemberExpression from './MemberExpression__';
|
|
@@ -11,7 +12,6 @@ import { EventPayload, Params } from '../common/EventEmitter';
|
|
|
11
12
|
import { concept, excludedInJSON, property, className } from '../decorators';
|
|
12
13
|
|
|
13
14
|
import * as utils from '../utils';
|
|
14
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
15
15
|
import BaseNode from '../common/BaseNode';
|
|
16
16
|
import LogicItem from './LogicItem__';
|
|
17
17
|
import Param from './Param__';
|
|
@@ -532,7 +532,7 @@ export class ForEachStatement extends LogicItem {
|
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
@withSourceMap()
|
|
535
|
-
toEmbeddedTS(state
|
|
535
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
536
536
|
let code = '';
|
|
537
537
|
code += this.each
|
|
538
538
|
? this.each.toEmbeddedTS(
|
|
@@ -565,7 +565,51 @@ export class ForEachStatement extends LogicItem {
|
|
|
565
565
|
|
|
566
566
|
return code;
|
|
567
567
|
}
|
|
568
|
-
|
|
568
|
+
|
|
569
|
+
@withSourceMap()
|
|
570
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
571
|
+
let code = '';
|
|
572
|
+
code += this.each
|
|
573
|
+
? this.each.toNaturalTS(
|
|
574
|
+
shiftState(state, code, {
|
|
575
|
+
tabSize: 0,
|
|
576
|
+
})
|
|
577
|
+
)
|
|
578
|
+
: '__IDENTIFIER__';
|
|
579
|
+
if (['NewList', 'NewMap'].includes(this.each?.concept)) code += '\n';
|
|
580
|
+
code += '.__slice(';
|
|
581
|
+
code += this.start ? this.start.toNaturalTS(shiftState(state, code)) : '__IDENTIFIER__';
|
|
582
|
+
code += ', ';
|
|
583
|
+
let virtualEnd: LogicItem = this.end;
|
|
584
|
+
if (!virtualEnd && this.each) {
|
|
585
|
+
// if (['List', 'String', 'Email', 'Text', 'Map'].includes(this.each.__TypeAnnotation?.typeName)) {
|
|
586
|
+
virtualEnd = new MemberExpression({
|
|
587
|
+
object: BaseNode.from({ ...this.each.toJSON(), name: this.each.name }) as LogicItem,
|
|
588
|
+
property: new Identifier({ name: 'length' }),
|
|
589
|
+
});
|
|
590
|
+
// }
|
|
591
|
+
}
|
|
592
|
+
code += virtualEnd ? virtualEnd.toNaturalTS(shiftState(state, code)) : '__IDENTIFIER__';
|
|
593
|
+
code += ').__forEach((';
|
|
594
|
+
code += this.item ? this.item.toNaturalTS(shiftState(state, code), true) : '__IDENTIFIER__';
|
|
595
|
+
code += ', ';
|
|
596
|
+
code += this.index ? this.index.toNaturalTS(shiftState(state, code), true) : '__IDENTIFIER__';
|
|
597
|
+
code += ') => {\n';
|
|
598
|
+
if (Array.isArray(this.body)) {
|
|
599
|
+
this.body.forEach((logicItem) => {
|
|
600
|
+
code += `${logicItem.toNaturalTS(
|
|
601
|
+
shiftState(state, code, {
|
|
602
|
+
tabSize: (state?.tabSize || 0) + 1,
|
|
603
|
+
})
|
|
604
|
+
)};\n`;
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
code += `${indent(state?.tabSize || 0)}})\n`;
|
|
608
|
+
|
|
609
|
+
return code;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
//= ===============================================================================
|
|
569
613
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
570
614
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
571
615
|
//================================================================================
|
|
@@ -1167,7 +1167,7 @@ export class Frontend extends BaseNode {
|
|
|
1167
1167
|
}
|
|
1168
1168
|
|
|
1169
1169
|
@withSourceMap()
|
|
1170
|
-
toEmbeddedTS(state
|
|
1170
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
1171
1171
|
let code = `export namespace ${this.name} {\n`;
|
|
1172
1172
|
code += 'const name = ';
|
|
1173
1173
|
code += `"${this.name}";\n`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Namespace from './Namespace__';
|
|
2
|
-
import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
3
3
|
import { ElementToVueOptions } from './ViewElement__';
|
|
4
4
|
import asyncFuncMap from '../common/asyncFuncMap';
|
|
5
5
|
|
|
@@ -1048,7 +1048,7 @@ export class Function extends BaseNode {
|
|
|
1048
1048
|
}
|
|
1049
1049
|
|
|
1050
1050
|
@withSourceMap()
|
|
1051
|
-
toEmbeddedTS(state
|
|
1051
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
1052
1052
|
let code = '';
|
|
1053
1053
|
if (this.returnExpression) {
|
|
1054
1054
|
code += `(`;
|
|
@@ -1076,6 +1076,34 @@ export class Function extends BaseNode {
|
|
|
1076
1076
|
return code;
|
|
1077
1077
|
}
|
|
1078
1078
|
|
|
1079
|
+
@withSourceMap()
|
|
1080
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
1081
|
+
let code = '';
|
|
1082
|
+
if (this.returnExpression) {
|
|
1083
|
+
code += `(`;
|
|
1084
|
+
this.params.forEach((param, index) => {
|
|
1085
|
+
code += param.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
1086
|
+
if (index !== this.params.length - 1)
|
|
1087
|
+
code += ', ';
|
|
1088
|
+
});
|
|
1089
|
+
code += `)`;
|
|
1090
|
+
if (this.returns.length) {
|
|
1091
|
+
code += ': ';
|
|
1092
|
+
code += this.returns[0].typeAnnotation?.toNaturalTS(shiftState(state, code, { inline: true }));
|
|
1093
|
+
}
|
|
1094
|
+
code += ` => (`;
|
|
1095
|
+
|
|
1096
|
+
if (this.returnExpression) {
|
|
1097
|
+
code += this.returnExpression.toNaturalTS && this.returnExpression.toNaturalTS(shiftState(state, code, { tabSize: state.tabSize + 1, inline: true }));
|
|
1098
|
+
}
|
|
1099
|
+
code += `${indent(state.tabSize)})`;
|
|
1100
|
+
} else {
|
|
1101
|
+
code += '__IDENTIFIER__';
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
return code;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1079
1107
|
toVue(options?: ElementToVueOptions): string {
|
|
1080
1108
|
let code = '(';
|
|
1081
1109
|
this.params.forEach((param, index) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, withSourceMap } from '../translator';
|
|
1
|
+
import { TranslatorState, withSourceMap, createCompilerState } from '../translator';
|
|
2
2
|
import { BindAttribute, CallLogic, TypeAnnotation } from '..';
|
|
3
3
|
import { ElementToVueOptions } from './ViewElement__';
|
|
4
4
|
import { findConceptKeyWordByNamespace } from '../utils';
|
|
@@ -197,7 +197,7 @@ export class Identifier extends LogicItem {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
@withSourceMap()
|
|
200
|
-
toEmbeddedTS(state
|
|
200
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
201
201
|
// 只有data-source可以是函数 ,也可能是属性
|
|
202
202
|
if (this.parentNode instanceof BindAttribute && this.parentNode.name === 'data-source') {
|
|
203
203
|
const { view } = this;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, shiftState, withSourceMap, indent } from '../translator';
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
2
2
|
|
|
3
3
|
//================================================================================
|
|
4
4
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
@@ -417,7 +417,7 @@ export class IfStatement extends LogicItem {
|
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
@withSourceMap()
|
|
420
|
-
toEmbeddedTS(state
|
|
420
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
421
421
|
let code = '';
|
|
422
422
|
code += 'if (nasl.core.ensureBoolean(';
|
|
423
423
|
code += this.test
|
|
@@ -454,7 +454,43 @@ export class IfStatement extends LogicItem {
|
|
|
454
454
|
}
|
|
455
455
|
return code;
|
|
456
456
|
}
|
|
457
|
-
|
|
457
|
+
|
|
458
|
+
@withSourceMap()
|
|
459
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
460
|
+
let code = '';
|
|
461
|
+
code += 'if (';
|
|
462
|
+
code += this.test ? this.test.toNaturalTS(shiftState(state, code, {
|
|
463
|
+
inline: true,
|
|
464
|
+
})) : '__IDENTIFIER__';
|
|
465
|
+
|
|
466
|
+
code += ') {\n';
|
|
467
|
+
|
|
468
|
+
if (Array.isArray(this.consequent)) {
|
|
469
|
+
this.consequent.forEach((logicItem) => {
|
|
470
|
+
code += `${logicItem.toNaturalTS(
|
|
471
|
+
shiftState(state, code, {
|
|
472
|
+
tabSize: (state?.tabSize || 0) + 1,
|
|
473
|
+
})
|
|
474
|
+
)};\n`;
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
code += `${indent(state?.tabSize || 0)}}\n`;
|
|
479
|
+
if (Array.isArray(this.alternate)) {
|
|
480
|
+
code += ' else {\n';
|
|
481
|
+
this.alternate.forEach((logicItem) => {
|
|
482
|
+
code += `${logicItem.toNaturalTS(
|
|
483
|
+
shiftState(state, code, {
|
|
484
|
+
tabSize: (state?.tabSize || 0) + 1,
|
|
485
|
+
})
|
|
486
|
+
)};\n`;
|
|
487
|
+
});
|
|
488
|
+
code += `${indent(state?.tabSize || 0)}}\n`;
|
|
489
|
+
}
|
|
490
|
+
return code;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
//= ===============================================================================
|
|
458
494
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
459
495
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
460
496
|
//================================================================================
|
|
@@ -939,7 +939,7 @@ export class Interface extends BaseNode {
|
|
|
939
939
|
}
|
|
940
940
|
|
|
941
941
|
@withSourceMap()
|
|
942
|
-
toEmbeddedTS(state
|
|
942
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
943
943
|
let code = '';
|
|
944
944
|
const getCheckerCode = () => {
|
|
945
945
|
if (this.validation) {
|
|
@@ -1045,7 +1045,7 @@ export class Interface extends BaseNode {
|
|
|
1045
1045
|
}
|
|
1046
1046
|
|
|
1047
1047
|
// 递归找出 response/request 的 Body/Returns 引用的数据结构
|
|
1048
|
-
getRefStructures(structures: Structure[] = []): Set<Structure> {
|
|
1048
|
+
getRefStructures(structures: Structure[] = [], includeNameList?: string[] ): Set<Structure> {
|
|
1049
1049
|
const structuresSet: Set<Structure> = new Set();
|
|
1050
1050
|
const loopSaveStructure = (typeAnnotation: TypeAnnotation) => {
|
|
1051
1051
|
if (!typeAnnotation) return;
|
|
@@ -1063,7 +1063,11 @@ export class Interface extends BaseNode {
|
|
|
1063
1063
|
};
|
|
1064
1064
|
|
|
1065
1065
|
const { params = [], returns = [] } = this;
|
|
1066
|
-
[...params, ...returns]
|
|
1066
|
+
let targetList = [...params, ...returns]
|
|
1067
|
+
if (includeNameList && includeNameList.length > 0) {
|
|
1068
|
+
targetList = targetList.filter((item) => includeNameList.includes(item.name))
|
|
1069
|
+
}
|
|
1070
|
+
targetList.forEach((p) => {
|
|
1067
1071
|
if ('in' in p && p.in === 'cookie') {
|
|
1068
1072
|
p.in = 'header';
|
|
1069
1073
|
return;
|
|
@@ -1073,6 +1077,19 @@ export class Interface extends BaseNode {
|
|
|
1073
1077
|
return structuresSet;
|
|
1074
1078
|
}
|
|
1075
1079
|
|
|
1080
|
+
deleteRefStructures(includeNameList?: string[]) {
|
|
1081
|
+
if (this.upperNode instanceof Connector) {
|
|
1082
|
+
const module = this.upperNode
|
|
1083
|
+
const oldStructuresSet = this.getRefStructures(module.structures, includeNameList);
|
|
1084
|
+
oldStructuresSet.forEach((s: Structure) => s.delete());
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
deleteInterface() {
|
|
1089
|
+
this.deleteRefStructures()
|
|
1090
|
+
this.delete()
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1076
1093
|
//================================================================================
|
|
1077
1094
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
1078
1095
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { withSourceMap, TranslatorState } from '../translator';
|
|
1
|
+
import { withSourceMap, TranslatorState, createCompilerState } from '../translator';
|
|
2
2
|
//================================================================================
|
|
3
3
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
4
4
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -80,10 +80,15 @@ export class JSBlock extends LogicItem {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
@withSourceMap()
|
|
83
|
-
toEmbeddedTS(state
|
|
83
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
84
84
|
return 'nasl.core.universalVariable';
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
@withSourceMap()
|
|
88
|
+
toNaturalTS(): string {
|
|
89
|
+
return ``;
|
|
90
|
+
}
|
|
91
|
+
|
|
87
92
|
toBrief(): string {
|
|
88
93
|
if (!this.code) {
|
|
89
94
|
return '';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState, indent } from '../translator';
|
|
1
|
+
import { TranslatorState, indent, createCompilerState } from '../translator';
|
|
2
2
|
//================================================================================
|
|
3
3
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
4
4
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -83,7 +83,7 @@ export class JavaLogic extends LogicItem {
|
|
|
83
83
|
* @param state 编译状态
|
|
84
84
|
* @returns 生成的代码
|
|
85
85
|
*/
|
|
86
|
-
toEmbeddedTS(state
|
|
86
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
87
87
|
let code = '';
|
|
88
88
|
const ret = this.logic.returns[0];
|
|
89
89
|
if (ret) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TranslatorState } from '../translator';
|
|
1
|
+
import { TranslatorState, createCompilerState } from '../translator';
|
|
2
2
|
import { ElementToVueOptions } from './ViewElement__';
|
|
3
3
|
import CallQueryComponent from './CallQueryComponent__';
|
|
4
4
|
import CallInterface from './CallInterface__';
|
|
@@ -322,10 +322,19 @@ export class LogicItem extends BaseNode {
|
|
|
322
322
|
* @param state 编译状态
|
|
323
323
|
* @returns 生成的代码
|
|
324
324
|
*/
|
|
325
|
-
toEmbeddedTS(state
|
|
325
|
+
toEmbeddedTS(state = createCompilerState()): string {
|
|
326
326
|
return this.toJS(state);
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
/**
|
|
330
|
+
* 生成自然的 TS 代码
|
|
331
|
+
* @param state 编译状态
|
|
332
|
+
* @returns 生成的代码
|
|
333
|
+
*/
|
|
334
|
+
toNaturalTS(state = createCompilerState()): string {
|
|
335
|
+
return this.toEmbeddedTS(state);
|
|
336
|
+
}
|
|
337
|
+
|
|
329
338
|
delete() {
|
|
330
339
|
let actionMsg = '删除逻辑项';
|
|
331
340
|
if (this.name) actionMsg += `“${this.name}”`;
|