@lcap/nasl 1.0.0-alpha.2 → 1.0.0-alpha.5
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/README.md +3 -3
- package/docs/assets/search.js +1 -1
- package/docs/classes/Entity.html +2832 -204
- package/docs/classes/View.html +4567 -365
- package/out/common/BaseNode.d.ts +1 -1
- package/out/common/BaseNode.js +38 -23
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +22 -0
- package/out/concepts/App__.js +77 -15
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.d.ts +2 -1
- package/out/concepts/Argument__.js +2 -2
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignment__.d.ts +2 -1
- package/out/concepts/Assignment__.js +3 -8
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/Attribute__.js.map +1 -1
- package/out/concepts/BinaryExpression__.d.ts +2 -1
- package/out/concepts/BinaryExpression__.js +5 -5
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +2 -1
- package/out/concepts/BindAttribute__.js +9 -4
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +2 -1
- package/out/concepts/BindDirective__.js +2 -2
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +2 -1
- package/out/concepts/BindEvent__.js +4 -3
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +2 -1
- package/out/concepts/BooleanLiteral__.js +1 -1
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.d.ts +57 -1
- package/out/concepts/CallFunction__.js +119 -11
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +2 -1
- package/out/concepts/CallInterface__.js +2 -2
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +57 -1
- package/out/concepts/CallLogic__.js +117 -10
- 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__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +120 -0
- package/out/concepts/ConfigGroup__.js +214 -0
- package/out/concepts/ConfigGroup__.js.map +1 -0
- package/out/concepts/ConfigPropertyValue__.d.ts +43 -0
- package/out/concepts/ConfigPropertyValue__.js +103 -0
- package/out/concepts/ConfigPropertyValue__.js.map +1 -0
- package/out/concepts/ConfigProperty__.d.ts +128 -0
- package/out/concepts/ConfigProperty__.js +236 -0
- package/out/concepts/ConfigProperty__.js.map +1 -0
- package/out/concepts/Configuration__.d.ts +120 -0
- package/out/concepts/Configuration__.js +210 -0
- package/out/concepts/Configuration__.js.map +1 -0
- package/out/concepts/Constant__.d.ts +2 -1
- package/out/concepts/Constant__.js +1 -1
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataElement__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +2 -1
- package/out/concepts/Destination__.js +4 -3
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +8 -0
- package/out/concepts/EntityIndex__.js +18 -0
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +5 -5
- package/out/concepts/EntityProperty__.js +10 -9
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +30 -26
- package/out/concepts/Entity__.js +44 -36
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +8 -8
- package/out/concepts/Enum__.js +10 -4
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.d.ts +35 -33
- package/out/concepts/ForEachStatement__.js +103 -36
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.js +1 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +2 -1
- package/out/concepts/Identifier__.js +15 -1
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +1 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +5 -1
- package/out/concepts/Interface__.js +19 -5
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +2 -1
- package/out/concepts/LogicItem__.js +2 -2
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +9 -7
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +2 -5
- package/out/concepts/MemberExpression__.js +12 -18
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +121 -126
- package/out/concepts/Module__.js +10 -17
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.js +12 -12
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NullLiteral__.d.ts +2 -1
- package/out/concepts/NullLiteral__.js +1 -1
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.d.ts +2 -1
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/Param__.d.ts +1 -1
- package/out/concepts/Param__.js +2 -2
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/Point__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js +2 -2
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.d.ts +82 -81
- package/out/concepts/ProcessElement__.js +19 -6
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/Process__.d.ts +1 -0
- package/out/concepts/Process__.js +10 -4
- package/out/concepts/Process__.js.map +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.map +1 -1
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +1 -1
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Rect__.js.map +1 -1
- package/out/concepts/Return__.d.ts +1 -1
- package/out/concepts/Return__.js +2 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.d.ts +5 -0
- package/out/concepts/Role__.js +19 -2
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/Slot__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +2 -0
- package/out/concepts/SqlQueryComponent__.js +16 -0
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Start__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +2 -1
- package/out/concepts/StringLiteral__.js +1 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +1 -1
- package/out/concepts/StructureProperty__.js +1 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +1 -1
- package/out/concepts/Structure__.js +4 -4
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/Theme__.js.map +1 -1
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +3 -0
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.d.ts +2 -1
- package/out/concepts/UnaryExpression__.js +3 -3
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/Unparsed__.d.ts +2 -1
- package/out/concepts/Unparsed__.js +1 -1
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/UseComponent__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +2 -1
- package/out/concepts/ValidationRule__.js +2 -2
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +6 -5
- package/out/concepts/Variable__.js +3 -3
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js +5 -5
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +5 -4
- package/out/concepts/ViewElement__.js +109 -65
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +97 -90
- package/out/concepts/View__.js +153 -118
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/index.js +2 -2
- package/out/concepts/basics/stdlib/index.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +3 -137
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +21 -5
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.validation.d.ts +3 -0
- package/out/concepts/basics/stdlib/nasl.validation.js +527 -0
- package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -0
- package/out/concepts/index__.d.ts +4 -0
- package/out/concepts/index__.js +4 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/data/Module.d.ts +34 -0
- package/out/data/Module.js +53 -0
- package/out/data/Module.js.map +1 -0
- package/out/generator/compileComponent.d.ts +1 -1
- package/out/generator/genBundleFiles.d.ts +0 -1
- package/out/generator/genBundleFiles.js +1 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +35 -0
- package/out/generator/genMetaData.js +78 -0
- package/out/generator/genMetaData.js.map +1 -0
- package/out/generator/index.d.ts +1 -0
- package/out/generator/index.js +1 -0
- package/out/generator/index.js.map +1 -1
- package/out/index.d.ts +2 -2
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/server/createUiTs.d.ts +7 -0
- package/out/server/createUiTs.js +157 -0
- package/out/server/createUiTs.js.map +1 -0
- package/out/server/entity2LogicNamespace.d.ts +9 -1
- package/out/server/entity2LogicNamespace.js +11 -1
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/getExtensionModules.d.ts +3 -0
- package/out/server/getExtensionModules.js +18 -0
- package/out/server/getExtensionModules.js.map +1 -0
- package/out/server/getLogics.js +18 -15
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +3 -2
- package/out/server/getMemberIdentifier.js +47 -15
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +4 -1
- package/out/server/getProcesses.js +16 -7
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/getValidates.js +1 -1
- package/out/server/getValidates.js.map +1 -1
- package/out/server/index.js +1 -0
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +23 -5
- package/out/server/naslServer.js +199 -25
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.d.ts +15 -1
- package/out/server/process2LogicNamespace.js +30 -3
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.js +28 -0
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.d.ts +5 -0
- package/out/service/storage/init.js +60 -52
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCallComponentLogic.js +2 -2
- package/out/templator/genCallComponentLogic.js.map +1 -1
- package/out/templator/genCreateBlock.js +6 -8
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +3 -3
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +4 -4
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +3 -3
- 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/genListViewBlock.js +2 -2
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +1 -1
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +8 -12
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +20 -20
- package/out/templator/utils.js +22 -22
- package/out/templator/utils.js.map +1 -1
- package/package.json +3 -1
- package/src/automate/engine/index.js +37 -3
- package/src/automate/engine/utils.js +68 -64
- package/src/common/BaseNode.ts +43 -28
- package/src/concepts/App__.ts +93 -17
- package/src/concepts/Argument__.ts +4 -2
- package/src/concepts/Assignment__.ts +5 -7
- package/src/concepts/Attribute__.ts +1 -0
- package/src/concepts/BinaryExpression__.ts +7 -5
- package/src/concepts/BindAttribute__.ts +9 -4
- package/src/concepts/BindDirective__.ts +4 -2
- package/src/concepts/BindEvent__.ts +6 -4
- package/src/concepts/BooleanLiteral__.ts +3 -1
- package/src/concepts/CallFunction__.ts +195 -11
- package/src/concepts/CallInterface__.ts +4 -2
- package/src/concepts/CallLogic__.ts +211 -12
- package/src/concepts/CallQueryComponent__.ts +2 -1
- package/src/concepts/Comment__.ts +1 -0
- package/src/concepts/CompletionProperty__.ts +1 -0
- package/src/concepts/ConfigGroup__.ts +290 -0
- package/src/concepts/ConfigPropertyValue__.ts +112 -0
- package/src/concepts/ConfigProperty__.ts +306 -0
- package/src/concepts/Configuration__.ts +286 -0
- package/src/concepts/Constant__.ts +3 -1
- package/src/concepts/DataElement__.ts +1 -0
- package/src/concepts/Destination__.ts +7 -5
- package/src/concepts/End__.ts +1 -0
- package/src/concepts/EntityIndex__.ts +19 -0
- package/src/concepts/EntityProperty__.ts +9 -8
- package/src/concepts/Entity__.ts +66 -59
- package/src/concepts/EnumItem__.ts +1 -0
- package/src/concepts/Enum__.ts +32 -12
- package/src/concepts/Event__.ts +2 -1
- package/src/concepts/ForEachStatement__.ts +115 -69
- package/src/concepts/Function__.ts +2 -1
- package/src/concepts/Identifier__.ts +18 -1
- package/src/concepts/IfStatement__.ts +1 -0
- package/src/concepts/InterfaceParam__.ts +2 -1
- package/src/concepts/Interface__.ts +21 -5
- package/src/concepts/JSBlock__.ts +1 -0
- package/src/concepts/LogicItem__.ts +9 -40
- package/src/concepts/Logic__.ts +48 -9
- package/src/concepts/MemberExpression__.ts +14 -17
- package/src/concepts/Module__.ts +158 -139
- package/src/concepts/Namespace__.ts +13 -12
- package/src/concepts/NullLiteral__.ts +3 -1
- package/src/concepts/NumericLiteral__.ts +3 -1
- package/src/concepts/Param__.ts +3 -2
- package/src/concepts/Point__.ts +1 -0
- package/src/concepts/ProcessComponent__.ts +3 -2
- package/src/concepts/ProcessElement__.ts +102 -107
- package/src/concepts/ProcessOutcome__.ts +1 -0
- package/src/concepts/Process__.ts +12 -4
- package/src/concepts/QueryAggregateExpression__.ts +1 -0
- package/src/concepts/QueryFieldExpression__.ts +2 -1
- package/src/concepts/QueryFromExpression__.ts +1 -0
- package/src/concepts/QueryGroupByExpression__.ts +1 -0
- package/src/concepts/QueryJoinExpression__.ts +2 -1
- package/src/concepts/QueryLimitExpression__.ts +1 -0
- package/src/concepts/QueryOrderByExpression__.ts +1 -0
- package/src/concepts/QuerySelectExpression__.ts +2 -1
- package/src/concepts/Rect__.ts +1 -0
- package/src/concepts/Return__.ts +3 -2
- package/src/concepts/Role__.ts +19 -2
- package/src/concepts/Slot__.ts +1 -0
- package/src/concepts/SqlQueryComponent__.ts +11 -1
- package/src/concepts/Start__.ts +1 -0
- package/src/concepts/StringLiteral__.ts +3 -1
- package/src/concepts/StructureProperty__.ts +2 -1
- package/src/concepts/Structure__.ts +5 -4
- package/src/concepts/SwitchCase__.ts +1 -0
- package/src/concepts/SwitchStatement__.ts +1 -0
- package/src/concepts/Theme__.ts +1 -0
- package/src/concepts/Transactional__.ts +1 -0
- package/src/concepts/TypeAnnotation__.ts +4 -0
- package/src/concepts/TypeParam__.ts +1 -0
- package/src/concepts/UnaryExpression__.ts +6 -3
- package/src/concepts/Unparsed__.ts +3 -1
- package/src/concepts/UseComponent__.ts +1 -0
- package/src/concepts/ValidationRule__.ts +5 -2
- package/src/concepts/Variable__.ts +12 -6
- package/src/concepts/ViewComponent__.ts +6 -5
- package/src/concepts/ViewElement__.ts +109 -80
- package/src/concepts/View__.ts +245 -206
- package/src/concepts/WhileStatement__.ts +1 -0
- package/src/concepts/basics/stdlib/index.ts +2 -2
- package/src/concepts/basics/stdlib/nasl.ui.ts +3 -137
- package/src/concepts/basics/stdlib/nasl.util.ts +21 -5
- package/src/concepts/basics/stdlib/{nasl.validate.ts → nasl.validation.ts} +28 -28
- package/src/concepts/index__.ts +4 -0
- package/src/generator/compileComponent.ts +1 -1
- package/src/generator/genBundleFiles.ts +1 -2
- package/src/generator/genMetaData.ts +111 -0
- package/src/generator/index.ts +1 -0
- package/src/index.ts +2 -2
- package/src/server/createUiTs.ts +153 -0
- package/src/server/entity2LogicNamespace.ts +17 -1
- package/src/server/getExtensionModules.ts +13 -0
- package/src/server/getLogics.ts +19 -18
- package/src/server/getMemberIdentifier.ts +60 -19
- package/src/server/getProcesses.ts +15 -8
- package/src/server/getValidates.ts +1 -1
- package/src/server/index.ts +2 -1
- package/src/server/naslServer.ts +204 -24
- package/src/server/process2LogicNamespace.ts +44 -3
- package/src/server/translator.ts +121 -97
- package/src/service/config/api.js +32 -0
- package/src/service/config/index.js +6 -0
- package/src/service/creator/index.js +2 -2
- package/src/service/logic/checktypeSocket.js +49 -0
- package/src/service/modules/api.js +20 -0
- package/src/service/modules/index.js +6 -0
- package/src/service/storage/init.ts +62 -54
- package/src/templator/genCallComponentLogic.ts +2 -2
- package/src/templator/genCreateBlock.ts +19 -25
- package/src/templator/genCurdEditMultipleKeyBlock.ts +3 -3
- package/src/templator/genCurdMultipleKeyBlock.ts +4 -4
- package/src/templator/genEditTableBlock.ts +3 -3
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genListViewBlock.ts +2 -2
- package/src/templator/genSelectBlock.ts +1 -1
- package/src/templator/genUpdateBlock.ts +19 -25
- package/src/templator/utils.ts +25 -153
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Logic, TypeAnnotation, Param } from '..';
|
|
2
|
+
|
|
3
|
+
export default function formatUiTs(allComponent: any) {
|
|
4
|
+
const indent = (tabSize: number) => ' '.repeat(tabSize * 2);
|
|
5
|
+
|
|
6
|
+
const toHump = (name: string) => name ? name.replace(/\-(\w)/g, (all, letter) => letter.toUpperCase()) : '';
|
|
7
|
+
|
|
8
|
+
const toNaslType = (type: string) => {
|
|
9
|
+
if (type === 'number')
|
|
10
|
+
return 'nasl.core.Long';
|
|
11
|
+
if (type === 'string')
|
|
12
|
+
return 'nasl.core.String';
|
|
13
|
+
if (type === 'boolean')
|
|
14
|
+
return 'nasl.core.Boolean';
|
|
15
|
+
if (type === 'Array<string>')
|
|
16
|
+
return 'nasl.collection.List<nasl.core.String>';
|
|
17
|
+
else
|
|
18
|
+
return type;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const creatMethodLogic = (method: {name: string, params: any[]}) => {
|
|
22
|
+
const { name, params } = method;
|
|
23
|
+
const logic = new Logic({
|
|
24
|
+
name,
|
|
25
|
+
params: params.map((param) => {
|
|
26
|
+
let typeAnnotation = null;
|
|
27
|
+
const { name, type } = param;
|
|
28
|
+
if (type === 'number')
|
|
29
|
+
typeAnnotation = TypeAnnotation.createPrimitive('Long');
|
|
30
|
+
else if (type === 'string')
|
|
31
|
+
typeAnnotation = TypeAnnotation.createPrimitive('String');
|
|
32
|
+
else if (type === 'boolean')
|
|
33
|
+
typeAnnotation = TypeAnnotation.createPrimitive('Boolean');
|
|
34
|
+
else if (type === 'Array<string>')
|
|
35
|
+
typeAnnotation = TypeAnnotation.createGeneric('List', {
|
|
36
|
+
typeArguments: [TypeAnnotation.createPrimitive('String')],
|
|
37
|
+
});
|
|
38
|
+
else {
|
|
39
|
+
typeAnnotation = TypeAnnotation.createPrimitive('any');
|
|
40
|
+
}
|
|
41
|
+
return new Param({
|
|
42
|
+
name,
|
|
43
|
+
typeAnnotation,
|
|
44
|
+
});
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
return logic;
|
|
48
|
+
};
|
|
49
|
+
const elementsLogic: { [componentName: string]: Array<Logic> } = {};
|
|
50
|
+
let value = `namespace nasl.ui {
|
|
51
|
+
export class VueComponent {
|
|
52
|
+
}
|
|
53
|
+
export class lRoot<T> extends VueComponent{
|
|
54
|
+
constructor(
|
|
55
|
+
options?: {
|
|
56
|
+
slotDefault?: ()=> Array<any>,
|
|
57
|
+
}){super()}
|
|
58
|
+
}
|
|
59
|
+
export class div<T> extends VueComponent {
|
|
60
|
+
constructor(
|
|
61
|
+
options?: {
|
|
62
|
+
slotDefault?: ()=> Array<any>,
|
|
63
|
+
}){super()}
|
|
64
|
+
}
|
|
65
|
+
export class template<T> extends VueComponent {
|
|
66
|
+
constructor(
|
|
67
|
+
options?: {
|
|
68
|
+
slotDefault?: ()=> Array<any>,
|
|
69
|
+
}){super()}
|
|
70
|
+
}
|
|
71
|
+
export type GetItemTypeFromDataSource<T> = T extends nasl.collection.PageOf<infer U> | Array<infer U> | ((...args: any) => nasl.collection.PageOf<infer U> | Array<infer U>) ? U : never;
|
|
72
|
+
\n`;
|
|
73
|
+
for (const i in allComponent) {
|
|
74
|
+
const item = allComponent[i];
|
|
75
|
+
const componentName = toHump(item.name);
|
|
76
|
+
if (!componentName)
|
|
77
|
+
break;
|
|
78
|
+
// console.log(item);
|
|
79
|
+
value += `export class ${componentName}<T> extends VueComponent{\n
|
|
80
|
+
constructor(\n
|
|
81
|
+
options?: {\n
|
|
82
|
+
[propname: string]: any,\n`;
|
|
83
|
+
// 生成slot
|
|
84
|
+
if (Object.prototype.toString.call(item.slots) === '[object Array]') {
|
|
85
|
+
let hasDefault = false;
|
|
86
|
+
if (item.attrs && item.attrs.find((item: any) => item.name === 'data-source')) {
|
|
87
|
+
// 没有插槽的
|
|
88
|
+
value += `slotDefault?: (scope: nasl.ui.ScopeOf<T>)=> Array<any>,\n`;
|
|
89
|
+
hasDefault = true;
|
|
90
|
+
}
|
|
91
|
+
item.slots.forEach((slot: any) => {
|
|
92
|
+
if (!slot.advanced) {
|
|
93
|
+
const slotName = toHump('slot-' + slot.name);
|
|
94
|
+
// 如果已经有带参数的slotDefault
|
|
95
|
+
if (slotName === 'slotDefault' && hasDefault)
|
|
96
|
+
return;
|
|
97
|
+
if (Array.isArray(slot.props) && slot.props.length === 5) {
|
|
98
|
+
value += indent(3);
|
|
99
|
+
value += slotName + `?: (scope: nasl.ui.ScopeOf<T>) => Array<any>,\n`;
|
|
100
|
+
} else if (Array.isArray(slot.props)) {
|
|
101
|
+
value += indent(3);
|
|
102
|
+
value += slotName + `?: (scope: {`;
|
|
103
|
+
slot.props.forEach((prop: any) => {
|
|
104
|
+
const type = prop.type || '';
|
|
105
|
+
value += `${prop.name}: ${type}, `;
|
|
106
|
+
});
|
|
107
|
+
value += `}) => Array<any>,\n`;
|
|
108
|
+
} else {
|
|
109
|
+
value += indent(3);
|
|
110
|
+
value += slotName + `?: ()=> Array<any>,\n`;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
} else {
|
|
115
|
+
// 没有插槽的
|
|
116
|
+
value += `slotDefault?: ()=> Array<any>,\n`;
|
|
117
|
+
}
|
|
118
|
+
value += indent(1) + '\n}){super()}\n';
|
|
119
|
+
// 生成methods
|
|
120
|
+
if (Object.prototype.toString.call(item.methods) === '[object Array]') {
|
|
121
|
+
// beforeNavigate?:($event: {to: string | Location, replace: boolean, append: boolean, preventDefault: Function}) => void
|
|
122
|
+
const logics: Array<Logic> = [];
|
|
123
|
+
item.methods.forEach((method: any) => {
|
|
124
|
+
if (!method.advanced) {
|
|
125
|
+
const methodName = toHump(method.name);
|
|
126
|
+
if (Array.isArray(method.params) && method.params.length) {
|
|
127
|
+
let methodParamStr = '';
|
|
128
|
+
method.params.forEach((param: any) => {
|
|
129
|
+
methodParamStr += param.name + ': ';
|
|
130
|
+
const type = toNaslType(param.type);
|
|
131
|
+
methodParamStr += type;
|
|
132
|
+
methodParamStr += ',';
|
|
133
|
+
});
|
|
134
|
+
value += indent(1);
|
|
135
|
+
value += methodName + `: (fn: (${methodParamStr}) => any) => void\n`;
|
|
136
|
+
logics.push(creatMethodLogic(method));
|
|
137
|
+
} else {
|
|
138
|
+
value += indent(1);
|
|
139
|
+
value += methodName + `: () => void;\n`;
|
|
140
|
+
logics.push(creatMethodLogic({ name: methodName, params: [] }));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
elementsLogic[componentName] = logics;
|
|
145
|
+
}
|
|
146
|
+
value += '}\n';
|
|
147
|
+
}
|
|
148
|
+
value += '}\n';
|
|
149
|
+
return {
|
|
150
|
+
code: value,
|
|
151
|
+
elementsLogic,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CallLogic, BindEvent, App, Namespace, Entity, BaseNode, Logic, Param, TypeAnnotation, Return
|
|
1
|
+
import { CallLogic, BindEvent, App, Namespace, Entity, BaseNode, Logic, Param, TypeAnnotation, Return } from '..';
|
|
2
2
|
export function entity2LogicNamespace(entity: Entity) {
|
|
3
3
|
const ns = new Namespace({
|
|
4
4
|
name: entity.name,
|
|
@@ -186,3 +186,19 @@ export function entity2LogicNamespace(entity: Entity) {
|
|
|
186
186
|
|
|
187
187
|
return ns;
|
|
188
188
|
}
|
|
189
|
+
|
|
190
|
+
interface entityTreeFragment {
|
|
191
|
+
logics: Array<Logic>;
|
|
192
|
+
name: string;
|
|
193
|
+
id: string;
|
|
194
|
+
concept: string;
|
|
195
|
+
}
|
|
196
|
+
export function entityToTreeFragment(entity: Entity) {
|
|
197
|
+
const fragment: entityTreeFragment = {
|
|
198
|
+
name: entity.name,
|
|
199
|
+
id: entity.id,
|
|
200
|
+
concept: entity.concept,
|
|
201
|
+
logics: entity.ns.logics,
|
|
202
|
+
};
|
|
203
|
+
return fragment;
|
|
204
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { App, Module, Namespace } from '..';
|
|
2
|
+
export function getExtensionModules(app: App) {
|
|
3
|
+
return app.dependencies;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function moduleToLogicNamesapce(m: Module) {
|
|
7
|
+
const ns = new Namespace({
|
|
8
|
+
name: m.name,
|
|
9
|
+
logics: m.logics,
|
|
10
|
+
});
|
|
11
|
+
ns.path = `app.${m.name}.logics`;
|
|
12
|
+
return ns;
|
|
13
|
+
}
|
package/src/server/getLogics.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { CallLogic, BindEvent, App, Namespace, Entity, BaseNode, Logic, Param, TypeAnnotation, Return, Process } from '..';
|
|
1
|
+
import { CallLogic, BindEvent, App, Namespace, Entity, BaseNode, Logic, Param, TypeAnnotation, Return, Process, ViewElement } from '..';
|
|
2
2
|
import { process2LogicNamespace } from './process2LogicNamespace';
|
|
3
|
+
import { moduleToLogicNamesapce } from './getExtensionModules';
|
|
3
4
|
import naslServer from './naslServer';
|
|
4
5
|
|
|
5
6
|
type FakeNode = Partial<Namespace> & {
|
|
@@ -51,6 +52,9 @@ function iterator(tree: FakeNode | FakeProcessNode, searchContent: string, fakeN
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
function toHump(name: string): string {
|
|
56
|
+
return name.replace(/\-(\w)/g, (all, letter) => letter.toUpperCase());
|
|
57
|
+
}
|
|
54
58
|
export async function getLogics(node: CallLogic | BindEvent, needAllLogic: boolean = true) {
|
|
55
59
|
const app = node.rootNode as App;
|
|
56
60
|
if (node.concept === 'CallLogic' || node.concept === 'BindEvent') {
|
|
@@ -63,41 +67,38 @@ export async function getLogics(node: CallLogic | BindEvent, needAllLogic: boole
|
|
|
63
67
|
return item;
|
|
64
68
|
});
|
|
65
69
|
const ps = app.processes.map((p) => process2LogicNamespace(p));
|
|
70
|
+
const extensions = app.dependencies.map(moduleToLogicNamesapce);
|
|
66
71
|
const tree = new Namespace({
|
|
67
72
|
name: 'logics',
|
|
68
73
|
path: `${app.getNamespace()}.logics`,
|
|
69
74
|
title: '全局逻辑',
|
|
70
75
|
logics: app.logics,
|
|
71
|
-
children: [...nc, ...
|
|
76
|
+
children: [...nc, ...extensions, ...ps],
|
|
72
77
|
});
|
|
73
78
|
result.push(tree);
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
if (node.view && node.view.logics) {
|
|
77
82
|
// 获取组件逻辑, 获取传入字段的子集
|
|
78
|
-
const
|
|
79
|
-
|
|
83
|
+
const elements: Array<ViewElement> = [];
|
|
84
|
+
node.view.elementsMethods(node.view.elements, elements);
|
|
80
85
|
const viewElements: Array<Namespace> = [];
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
returns: [],
|
|
89
|
-
body: [],
|
|
90
|
-
}));
|
|
86
|
+
elements.forEach((item) => {
|
|
87
|
+
const itemTag = toHump(item.tag);
|
|
88
|
+
const elementsLogic = naslServer.elementsLogic;
|
|
89
|
+
const elementsLogicName = itemTag;
|
|
90
|
+
const eleLogis = elementsLogic[elementsLogicName];
|
|
91
|
+
// 看是不是有已经有有参数的函数了
|
|
92
|
+
if (Array.isArray(eleLogis) && eleLogis.length) {
|
|
91
93
|
const viewElement = new Namespace({
|
|
92
|
-
title:
|
|
94
|
+
title: toHump(item.name),
|
|
93
95
|
name: 'methods',
|
|
94
|
-
logics,
|
|
95
|
-
path: `elements.${
|
|
96
|
+
logics: elementsLogic[elementsLogicName],
|
|
97
|
+
path: `elements.${toHump(item.name)}.logics`,
|
|
96
98
|
});
|
|
97
99
|
viewElements.push(viewElement);
|
|
98
100
|
}
|
|
99
101
|
});
|
|
100
|
-
|
|
101
102
|
// 增加页面逻辑
|
|
102
103
|
const tree = new Namespace({
|
|
103
104
|
name: 'logics',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseNode, CompletionProperty, App, Identifier, MemberExpression, Enum, NullLiteral, BooleanLiteral, Param } from '..';
|
|
1
|
+
import { BaseNode, CompletionProperty, App, Identifier, MemberExpression, Enum, NullLiteral, BooleanLiteral, Param, BindAttribute } from '..';
|
|
2
2
|
import naslServer from './naslServer';
|
|
3
3
|
|
|
4
4
|
interface variableItem {
|
|
@@ -23,7 +23,6 @@ function formatVariableData(data: unknown | variableItem[], node: BaseNode, pare
|
|
|
23
23
|
} else {
|
|
24
24
|
item.expression = new MemberExpression({
|
|
25
25
|
object: parent.expression,
|
|
26
|
-
objectqwer: parent.expression,
|
|
27
26
|
property: new Identifier({ name: item.name }),
|
|
28
27
|
});
|
|
29
28
|
}
|
|
@@ -76,7 +75,6 @@ function formatEnums(enums: Array<Enum>) {
|
|
|
76
75
|
newEnumItem.name = newEnumItem.value;
|
|
77
76
|
newEnumItem.expression = new MemberExpression({
|
|
78
77
|
object: item.expression,
|
|
79
|
-
objectqwer: item.expression,
|
|
80
78
|
property: new Identifier({ name: newEnumItem.value }),
|
|
81
79
|
});
|
|
82
80
|
const completionProperty = new CompletionProperty(newEnumItem);
|
|
@@ -90,10 +88,10 @@ function formatEnums(enums: Array<Enum>) {
|
|
|
90
88
|
return result;
|
|
91
89
|
}
|
|
92
90
|
type LiteralDefination = {
|
|
93
|
-
name: string
|
|
94
|
-
value: string
|
|
95
|
-
expression?: Identifier
|
|
96
|
-
}
|
|
91
|
+
name: string;
|
|
92
|
+
value: string;
|
|
93
|
+
expression?: Identifier;
|
|
94
|
+
};
|
|
97
95
|
// 先简单处理一下
|
|
98
96
|
function formatLiterals() {
|
|
99
97
|
const list: Array<LiteralDefination> = [
|
|
@@ -110,19 +108,54 @@ function formatLiterals() {
|
|
|
110
108
|
return newList;
|
|
111
109
|
}
|
|
112
110
|
|
|
113
|
-
|
|
111
|
+
// 获取当前可选的逻辑
|
|
112
|
+
function getCurrentLogic(node: BaseNode,
|
|
113
|
+
result: {
|
|
114
|
+
name: string;
|
|
115
|
+
children: CompletionProperty[];
|
|
116
|
+
level: string;
|
|
117
|
+
}[]) {
|
|
118
|
+
// 只有data-source可以
|
|
119
|
+
if (node instanceof Identifier && node.parentNode instanceof BindAttribute && node.parentNode.name === 'data-source') {
|
|
120
|
+
const view = node.view;
|
|
121
|
+
const viewLogics = view.logics;
|
|
122
|
+
const logicVariable = viewLogics.map((item) => {
|
|
123
|
+
const newLogic: LiteralDefination = {
|
|
124
|
+
name: item.name,
|
|
125
|
+
value: item.name,
|
|
126
|
+
};
|
|
127
|
+
newLogic.expression = new Identifier({ name: item.name });
|
|
128
|
+
const completionProperty = new CompletionProperty(newLogic);
|
|
129
|
+
completionProperty.level = 'logic';
|
|
130
|
+
return completionProperty;
|
|
131
|
+
});
|
|
132
|
+
result.push({ name: '逻辑', children: logicVariable, level: 'category' });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export async function getMemberIdentifier(node: BaseNode) {
|
|
114
137
|
if (node) {
|
|
115
|
-
// 先去获取
|
|
116
|
-
const completion = await naslServer.getSelectCompletion(node) as variableItem[];
|
|
117
|
-
const completionData = formatVariableData(completion, node);
|
|
118
138
|
// 获取枚举
|
|
119
139
|
const app = node.rootNode as App;
|
|
120
140
|
const literals = formatLiterals();
|
|
121
141
|
const enums = app?.enums;
|
|
122
|
-
const newEnums = formatEnums(enums);
|
|
142
|
+
const newEnums = enums ? formatEnums(enums) : [];
|
|
143
|
+
|
|
123
144
|
// extensionModules(state) {
|
|
124
145
|
// return state.app?.dependencies?.filter((module) => module.type === 'extension') || {};
|
|
125
146
|
// },
|
|
147
|
+
|
|
148
|
+
// 如果之前有选好的值就需要的把之前那一列的内容渲染出来
|
|
149
|
+
// 先去获取
|
|
150
|
+
|
|
151
|
+
let completionData: CompletionProperty[] = [new CompletionProperty({})];
|
|
152
|
+
if (node instanceof Identifier || node instanceof MemberExpression) {
|
|
153
|
+
const value = (node as Identifier | MemberExpression).getValue();
|
|
154
|
+
if (value) {
|
|
155
|
+
const completion = (await naslServer.getValueSelectCompletion(node, value)) as variableItem[];
|
|
156
|
+
completionData = formatVariableData(completion, node);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
126
159
|
// 这个可能需要自己算一下
|
|
127
160
|
const result = [
|
|
128
161
|
{ name: '字面量', children: literals, level: 'category' },
|
|
@@ -130,14 +163,22 @@ export async function getMemberIdentifier(node: BaseNode, filterText?: string) {
|
|
|
130
163
|
{ name: '变量', children: completionData, level: 'category' },
|
|
131
164
|
// { name: '流程变量', children: [] },
|
|
132
165
|
];
|
|
166
|
+
getCurrentLogic(node, result);
|
|
133
167
|
return result;
|
|
134
168
|
}
|
|
135
169
|
}
|
|
136
170
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
171
|
+
export async function getSelectNextCompletionData(node: Identifier, completionProperty?: CompletionProperty) {
|
|
172
|
+
if (node) {
|
|
173
|
+
let fieldKey: string = null;
|
|
174
|
+
if (completionProperty) {
|
|
175
|
+
const exp = BaseNode.from(completionProperty.expression);
|
|
176
|
+
const value = (exp as Identifier).getValue();
|
|
177
|
+
fieldKey = value;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const nextCompletion = await naslServer.getFieldKeySelectCompletion(node, fieldKey);
|
|
181
|
+
const completionData = formatVariableData(nextCompletion, node, completionProperty);
|
|
182
|
+
return completionData;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -10,7 +10,7 @@ function alphaUpper(name: string) {
|
|
|
10
10
|
|
|
11
11
|
export function genLaunchProcess(process: Process) {
|
|
12
12
|
const l = new Logic({
|
|
13
|
-
name: 'launch'
|
|
13
|
+
name: 'launch',
|
|
14
14
|
params: process.params,
|
|
15
15
|
body: [],
|
|
16
16
|
returns: [
|
|
@@ -33,24 +33,31 @@ export function process2LogicNamespace(process: Process) {
|
|
|
33
33
|
return ns;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function returnToParam(r: Return) {
|
|
37
|
-
|
|
36
|
+
export function returnToParam(r: Return) {
|
|
37
|
+
const obj = r.toJSON() as { concept: string };
|
|
38
|
+
delete obj.concept;
|
|
39
|
+
return Param.from(obj);
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
function variableToParam(v: Variable) {
|
|
41
|
-
|
|
43
|
+
const obj = v.toJSON() as { concept: string };
|
|
44
|
+
delete obj.concept;
|
|
45
|
+
return Param.from(obj);
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
function constantToParam(v: Constant) {
|
|
45
|
-
|
|
48
|
+
export function constantToParam(v: Constant) {
|
|
49
|
+
const obj = v.toJSON() as { concept: string };
|
|
50
|
+
delete obj.concept;
|
|
51
|
+
// console.log(Param.from(obj));
|
|
52
|
+
return Param.from(obj);
|
|
46
53
|
}
|
|
47
54
|
|
|
48
55
|
export function genUserTaskLogic(userTask: ProcessElement) {
|
|
49
56
|
const taskId = userTask.constants.find((p) => p.name === 'taskId');
|
|
50
57
|
const l = new Logic({
|
|
51
|
-
name: `complete
|
|
58
|
+
name: `complete`,
|
|
52
59
|
fake: true,
|
|
53
|
-
params: [...userTask.returns.map(returnToParam)
|
|
60
|
+
params: [constantToParam(taskId), ...userTask.returns.map(returnToParam)],
|
|
54
61
|
body: [],
|
|
55
62
|
returns: [],
|
|
56
63
|
});
|
package/src/server/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { getInterfaces } from './getInterfaces';
|
|
|
3
3
|
import { getFunctions, getBuildInFunction } from './getFunctions';
|
|
4
4
|
import { getValidates, getValidateFunction } from './getValidates';
|
|
5
5
|
import { getProcessComponents, getProcessComponent } from './getProcessComponents';
|
|
6
|
-
import { getMemberIdentifier } from './getMemberIdentifier';
|
|
6
|
+
import { getMemberIdentifier, getSelectNextCompletionData } from './getMemberIdentifier';
|
|
7
7
|
import naslServer from './naslServer';
|
|
8
8
|
|
|
9
9
|
const server: any = {
|
|
@@ -18,5 +18,6 @@ const server: any = {
|
|
|
18
18
|
getMemberIdentifier,
|
|
19
19
|
getValidates,
|
|
20
20
|
getValidateFunction,
|
|
21
|
+
getSelectNextCompletionData,
|
|
21
22
|
};
|
|
22
23
|
export default server;
|