@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as utils from '../utils';
|
|
2
|
-
import { App, Namespace, Entity, EntityProperty, View } from '../concepts';
|
|
2
|
+
import { App, Module, Namespace, Entity, EntityProperty, View, DataSource } from '../concepts';
|
|
3
3
|
import {
|
|
4
4
|
getExpression,
|
|
5
5
|
filterProperty,
|
|
@@ -20,16 +20,20 @@ import { NaslCoreTypeAnnotation, NaslCollectionTypeAnnotation, NaslUITypeAnnotat
|
|
|
20
20
|
*/
|
|
21
21
|
export function genTableColumnTemplate(property: EntityProperty) {
|
|
22
22
|
const entity = property.entity;
|
|
23
|
+
const dataSource = entity.parentNode as DataSource;
|
|
23
24
|
const lowerEntityName = utils.firstLowerCase(entity.name);
|
|
24
25
|
let expression = `scope.item.${lowerEntityName}.${property.name}`;
|
|
25
26
|
const title = property.label || property.name;
|
|
26
27
|
|
|
27
28
|
if (property.relationEntity) {
|
|
28
29
|
const relationLowerEntityName = utils.firstLowerCase(property.relationEntity);
|
|
30
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
31
|
+
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
29
32
|
// 有外键关联
|
|
30
|
-
expression = getExpression(property, `scope.item.${relationLowerEntityName}.${property.relationProperty}`);
|
|
31
|
-
} else
|
|
33
|
+
expression = getExpression(property, `scope.item.${relationLowerEntityName}.${displayedProperty?.name || property.relationProperty}`);
|
|
34
|
+
} else {
|
|
32
35
|
expression = getExpression(property, `scope.item.${lowerEntityName}.${property.name}`);
|
|
36
|
+
}
|
|
33
37
|
|
|
34
38
|
const getText = (property: EntityProperty) => {
|
|
35
39
|
if (property.typeAnnotation.typeName === 'Boolean') {
|
|
@@ -83,8 +87,8 @@ export function genTableTemplate(entity: Entity, nameGroup: NameGroup, modifyabl
|
|
|
83
87
|
* @param entity 实体
|
|
84
88
|
*/
|
|
85
89
|
export function genTableLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic: any, supportFilter: boolean) {
|
|
86
|
-
const
|
|
87
|
-
const
|
|
90
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
91
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
88
92
|
const params = [
|
|
89
93
|
genLogicParam(`${newLogic.params[0].name}`, 'params.page'),
|
|
90
94
|
genLogicParam(`${newLogic.params[1].name}`, 'params.size'),
|
|
@@ -108,7 +112,7 @@ export function genTableLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic
|
|
|
108
112
|
name: 'result',
|
|
109
113
|
typeAnnotation: NaslCollectionTypeAnnotation.PageOf([
|
|
110
114
|
NaslTypeAnnotation.Reference({
|
|
111
|
-
typeNamespace: `${
|
|
115
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
112
116
|
typeName: nameGroup.structure,
|
|
113
117
|
}),
|
|
114
118
|
]),
|
|
@@ -122,7 +126,7 @@ export function genTableLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic
|
|
|
122
126
|
name: 'result',
|
|
123
127
|
}),
|
|
124
128
|
right: NaslLogicItem.CallLogic({
|
|
125
|
-
calleeNamespace: `${
|
|
129
|
+
calleeNamespace: `${moduleNamespace}.logics`,
|
|
126
130
|
calleeName: newLogic.name,
|
|
127
131
|
arguments: params,
|
|
128
132
|
}),
|
|
@@ -138,8 +142,8 @@ export function genTableLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic
|
|
|
138
142
|
*/
|
|
139
143
|
export function genTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
140
144
|
const lowerEntityName = utils.firstLowerCase(entity.name);
|
|
141
|
-
const
|
|
142
|
-
const
|
|
145
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
146
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
143
147
|
const ns = entity.ns;
|
|
144
148
|
const deleteLogic = ns?.logics?.find((logic) => logic.name === 'delete');
|
|
145
149
|
const idPropertys = entity.properties.filter((property) => property.primaryKey);
|
|
@@ -154,7 +158,7 @@ export function genTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
154
158
|
name: 'scope',
|
|
155
159
|
typeAnnotation: NaslUITypeAnnotation.ScopeOf([
|
|
156
160
|
NaslTypeAnnotation.Reference({
|
|
157
|
-
typeNamespace: `${
|
|
161
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
158
162
|
typeName: nameGroup.structure,
|
|
159
163
|
}),
|
|
160
164
|
]),
|
|
@@ -192,32 +196,35 @@ export function genTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
192
196
|
* load_select_student -> load_someView_select_student
|
|
193
197
|
*/
|
|
194
198
|
export function genTableBlock(entity: Entity, view: View) {
|
|
195
|
-
const
|
|
199
|
+
const dataSource = entity.parentNode as DataSource;
|
|
200
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
196
201
|
|
|
197
202
|
const viewElementMainView = view.getViewElementUniqueName('tableView');
|
|
198
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
203
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
|
|
199
204
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
200
205
|
nameGroup.viewVariableEntity = view.getVariableUniqueName(utils.firstLowerCase(entity.name));
|
|
201
206
|
nameGroup.viewLogicRemove = view.getLogicUniqueName('remove');
|
|
202
207
|
|
|
203
208
|
// 收集所有和本实体关联的实体
|
|
204
|
-
const
|
|
209
|
+
const entitySet: Set<Entity> = new Set();
|
|
210
|
+
entitySet.add(entity);
|
|
205
211
|
const newStructures: any[] = [];
|
|
206
212
|
const newLogics: any[] = [];
|
|
207
213
|
entity.properties.forEach((property) => {
|
|
208
214
|
if (property.relationEntity) {
|
|
209
215
|
// 有外键关联
|
|
210
|
-
const relationEntity =
|
|
216
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
211
217
|
if (relationEntity) {
|
|
212
218
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
213
219
|
if (displayedProperty)
|
|
214
|
-
|
|
220
|
+
entitySet.add(relationEntity);
|
|
215
221
|
}
|
|
216
222
|
}
|
|
217
223
|
});
|
|
224
|
+
const allEntities = [...entitySet];
|
|
218
225
|
const entityStructure = genQueryStructure(allEntities, nameGroup);
|
|
219
226
|
newStructures.push(entityStructure);
|
|
220
|
-
const entityLogic = genQueryLogic(allEntities, nameGroup, false, true,
|
|
227
|
+
const entityLogic = genQueryLogic(allEntities, nameGroup, false, true, module);
|
|
221
228
|
newLogics.push(entityLogic);
|
|
222
229
|
|
|
223
230
|
return `
|
|
@@ -240,34 +247,36 @@ export function genTableBlock(entity: Entity, view: View) {
|
|
|
240
247
|
|
|
241
248
|
export function genTableColumnBlock(property: EntityProperty, view: View) {
|
|
242
249
|
const entity = property.entity;
|
|
243
|
-
const
|
|
250
|
+
const dataSource = entity.parentNode as DataSource;
|
|
251
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
244
252
|
|
|
245
253
|
const viewElementMainView = view.getViewElementUniqueName('tableView');
|
|
246
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
254
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
|
|
247
255
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
248
256
|
nameGroup.viewVariableEntity = view.getVariableUniqueName(utils.firstLowerCase(entity.name));
|
|
249
257
|
nameGroup.viewLogicRemove = view.getLogicUniqueName('remove');
|
|
250
258
|
|
|
251
259
|
// 收集所有和本实体关联的实体
|
|
252
|
-
const
|
|
260
|
+
const entitySet: Set<Entity> = new Set();
|
|
261
|
+
entitySet.add(entity);
|
|
253
262
|
const newStructures: any[] = [];
|
|
254
263
|
const newLogics: any[] = [];
|
|
255
264
|
const properties = [property];
|
|
256
265
|
properties.forEach((property) => {
|
|
257
266
|
if (property.relationEntity) {
|
|
258
267
|
// 有外键关联
|
|
259
|
-
const relationEntity =
|
|
268
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
260
269
|
if (relationEntity) {
|
|
261
270
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
262
271
|
if (displayedProperty)
|
|
263
|
-
|
|
272
|
+
entitySet.add(relationEntity);
|
|
264
273
|
}
|
|
265
274
|
}
|
|
266
275
|
});
|
|
267
|
-
|
|
276
|
+
const allEntities = [...entitySet];
|
|
268
277
|
const entityStructure = genQueryStructure(allEntities, nameGroup);
|
|
269
278
|
newStructures.push(entityStructure);
|
|
270
|
-
const entityLogic = genQueryLogic(allEntities, nameGroup, false, true,
|
|
279
|
+
const entityLogic = genQueryLogic(allEntities, nameGroup, false, true, module);
|
|
271
280
|
newLogics.push(entityLogic);
|
|
272
281
|
|
|
273
282
|
return `
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { config } from '../config';
|
|
2
2
|
import * as utils from '../utils';
|
|
3
|
-
import { App, Namespace, Entity, Logic, View, Enum } from '../concepts';
|
|
3
|
+
import { App, Module, Namespace, Entity, Logic, View, Enum, DataSource } from '../concepts';
|
|
4
4
|
import { NaslCoreTypeAnnotation, NaslUITypeAnnotation, NaslTypeAnnotation, NaslLogicItem, NaslNode } from './utils';
|
|
5
5
|
import {
|
|
6
6
|
NameGroup,
|
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
} from '.';
|
|
17
17
|
|
|
18
18
|
export function genUpdateFormTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
19
|
-
const
|
|
19
|
+
const dataSource = entity.parentNode as DataSource;
|
|
20
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
20
21
|
const properties = entity.properties.filter(filterProperty('inForm'));
|
|
21
22
|
|
|
22
23
|
return `<u-form ref="${nameGroup.viewElementMainView}">
|
|
@@ -39,13 +40,15 @@ export function genUpdateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
|
|
|
39
40
|
const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
|
|
40
41
|
if (property.relationEntity) {
|
|
41
42
|
// 有外键关联
|
|
42
|
-
const relationEntity =
|
|
43
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
43
44
|
if (relationEntity) {
|
|
44
45
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
45
46
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
46
47
|
if (displayedProperty) {
|
|
47
48
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
48
|
-
|
|
49
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
50
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
51
|
+
const selectNameGroup = selectNameGroupMap.get(key);
|
|
49
52
|
formItem += `
|
|
50
53
|
<u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroup.viewLogicLoad}"
|
|
51
54
|
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="${vModel}">
|
|
@@ -73,7 +76,7 @@ export function genUpdateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
|
|
|
73
76
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
74
77
|
const type = namespaceArr.pop();
|
|
75
78
|
if (type === 'enums') {
|
|
76
|
-
formItem += genEnumSelectBlock(
|
|
79
|
+
formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
77
80
|
} else {
|
|
78
81
|
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
|
|
79
82
|
}
|
|
@@ -90,7 +93,8 @@ export function genUpdateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
|
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
export function genH5UpdateFormTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
93
|
-
const
|
|
96
|
+
const dataSource = entity.parentNode as DataSource;
|
|
97
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
94
98
|
const properties = entity.properties.filter(filterProperty('inForm'));
|
|
95
99
|
|
|
96
100
|
return `<van-form ref="${nameGroup.viewElementMainView}">
|
|
@@ -107,55 +111,58 @@ export function genH5UpdateFormTemplate(entity: Entity, nameGroup: NameGroup, se
|
|
|
107
111
|
rules.push('required');
|
|
108
112
|
const rulesStr = rules.join(' | ');
|
|
109
113
|
|
|
110
|
-
let formItem = ` <van-field drole="other"
|
|
114
|
+
let formItem = ` <van-field drole="other" ${required ? ' required' : ''}${rulesStr.length ? ` rules="${rulesStr}"` : ''}>\n`;
|
|
111
115
|
|
|
112
116
|
const { typeAnnotation } = property || {};
|
|
113
117
|
const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
|
|
114
118
|
if (property.relationEntity) {
|
|
115
119
|
// 有外键关联
|
|
116
|
-
const relationEntity =
|
|
120
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
117
121
|
if (relationEntity) {
|
|
118
122
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
119
123
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
120
124
|
if (displayedProperty) {
|
|
121
125
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
122
|
-
|
|
126
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
127
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
128
|
+
const selectNameGroup = selectNameGroupMap.get(key);
|
|
123
129
|
formItem += `
|
|
124
|
-
<template #input><van-cascader title="请选择${label}" placeholder="请选择${label}"
|
|
130
|
+
<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-cascader title="请选择${label}" placeholder="请选择${label}"
|
|
125
131
|
v-model="${vModel}" :data-source="${selectNameGroup.viewLogicLoad}"
|
|
126
132
|
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}"
|
|
127
133
|
:notitleblock="true"
|
|
128
|
-
:pageable="true" :remote-paging="true"></van-cascader></template>
|
|
134
|
+
:pageable="true" input-align="left" :remote-paging="true"></van-cascader></van-linear-layout></template>
|
|
129
135
|
`;
|
|
130
136
|
} else
|
|
131
137
|
return '';
|
|
132
138
|
} else
|
|
133
139
|
return '';
|
|
134
140
|
} else if (propertyTypeName === 'Boolean') {
|
|
135
|
-
formItem += `<template #input><van-switch v-model="${vModel}"></van-switch></template>`;
|
|
141
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-switch v-model="${vModel}"></van-switch></van-linear-layout></template>`;
|
|
136
142
|
} else if (propertyTypeName === 'Integer' || propertyTypeName === 'Long') {
|
|
137
|
-
formItem += `<template #input><van-stepper v-model="${vModel}" placeholder="请输入${label}"></van-stepper></template>`;
|
|
143
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-stepper-new v-model="${vModel}" placeholder="请输入${label}" :showPlus="false" :showMinus="false" align="left"></van-stepper-new></van-linear-layout></template>`;
|
|
138
144
|
} else if (propertyTypeName === 'Double') {
|
|
139
|
-
formItem += `<template #input><van-stepper v-model="${vModel}" placeholder="请输入${label}"></van-stepper></template>`;
|
|
145
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-stepper-new v-model="${vModel}" placeholder="请输入${label}" :showPlus="false" :showMinus="false" align="left"></van-stepper-new></van-linear-layout></template>`;
|
|
140
146
|
} else if (propertyTypeName === 'Text') {
|
|
141
|
-
formItem += `<template #input><van-fieldtextarea v-model="${vModel}" placeholder="请输入${label}"></van-fieldtextarea></template>`;
|
|
147
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-fieldtextarea v-model="${vModel}" placeholder="请输入${label}"></van-fieldtextarea></van-linear-layout></template>`;
|
|
142
148
|
// @TODO
|
|
143
149
|
} else if (propertyTypeName === 'Date') {
|
|
144
|
-
formItem += `<template #input><van-calendar clearable :default-date.sync="${vModel}" placeholder="请输入${label}"></van-calendar></template>`;
|
|
150
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-calendar clearable :default-date.sync="${vModel}" placeholder="请输入${label}" input-align="left"></van-calendar></van-linear-layout></template>`;
|
|
145
151
|
} else if (propertyTypeName === 'Time') {
|
|
146
|
-
formItem += `<template #input><van-datetime-picker type="time" v-model="${vModel}" title="请选择${label}" label-field=""></van-datetime-picker></template>`;
|
|
152
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-datetime-picker type="time" v-model="${vModel}" title="请选择${label}" label-field="" input-align="left"></van-datetime-picker></van-linear-layout></template>`;
|
|
147
153
|
} else if (propertyTypeName === 'DateTime') {
|
|
148
|
-
formItem += `<template #input><van-datetime-picker type="datetime" v-model="${vModel}" title="请选择${label}" label-field=""></van-datetime-picker></template>`;
|
|
154
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-datetime-picker type="datetime" v-model="${vModel}" title="请选择${label}" label-field="" input-align="left"></van-datetime-picker></van-linear-layout></template>`;
|
|
149
155
|
} else {
|
|
150
156
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
151
157
|
const type = namespaceArr.pop();
|
|
152
158
|
if (type === 'enums') {
|
|
153
|
-
formItem += '<template #input>' + genEnumSelectBlock(
|
|
159
|
+
formItem += '<template #input><van-linear-layout style="width:100%;" direction="horizontal">' + genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true) + '</van-linear-layout></template>';
|
|
154
160
|
} else {
|
|
155
|
-
formItem += `<template #input><van-fieldinput v-model="${vModel}" placeholder="请输入${label}"></van-fieldinput></template>`;
|
|
161
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-fieldinput v-model="${vModel}" placeholder="请输入${label}"></van-fieldinput></van-linear-layout></template>`;
|
|
156
162
|
}
|
|
157
163
|
}
|
|
158
164
|
|
|
165
|
+
formItem += `<template #title><van-text text="${label}"><van-text></template>`;
|
|
159
166
|
formItem += ` </van-field>\n`;
|
|
160
167
|
|
|
161
168
|
formItem = formItem.replace(/>\n<van-input|<\/van-input>/g, '');
|
|
@@ -226,7 +233,7 @@ function genSubmitLogic(updateLogic: Logic, nameGroup: NameGroup) {
|
|
|
226
233
|
}
|
|
227
234
|
|
|
228
235
|
function genLoadLogic(getLogic: Logic, nameGroup: NameGroup) {
|
|
229
|
-
const params = [genLogicParam(`${getLogic.params[0].name}`,
|
|
236
|
+
const params = [genLogicParam(`${getLogic.params[0].name}`, nameGroup.viewParamId)];
|
|
230
237
|
return NaslNode.Logic({
|
|
231
238
|
name: nameGroup.viewLogicLoad,
|
|
232
239
|
description: '',
|
|
@@ -251,7 +258,8 @@ function genLoadLogic(getLogic: Logic, nameGroup: NameGroup) {
|
|
|
251
258
|
}
|
|
252
259
|
|
|
253
260
|
export function genUpdateBlock(entity: Entity, view: View) {
|
|
254
|
-
const
|
|
261
|
+
const dataSource = entity.parentNode as DataSource;
|
|
262
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
255
263
|
const ns = entity.ns;
|
|
256
264
|
const getLogic = ns?.logics?.find((logic) => logic.name === `get`);
|
|
257
265
|
const updateLogic = ns?.logics?.find((logic) => logic.name === `update`);
|
|
@@ -271,16 +279,18 @@ export function genUpdateBlock(entity: Entity, view: View) {
|
|
|
271
279
|
entity.properties.forEach((property) => {
|
|
272
280
|
// 有外键关联
|
|
273
281
|
if (property.relationEntity) {
|
|
274
|
-
const relationEntity =
|
|
282
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
275
283
|
if (relationEntity) {
|
|
276
284
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
277
285
|
if (displayedProperty) {
|
|
278
286
|
const viewElementSelect = view.getViewElementUniqueName('select');
|
|
279
|
-
const selectNameGroup = genUniqueQueryNameGroup(
|
|
287
|
+
const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
|
|
280
288
|
selectNameGroup.viewElementSelect = viewElementSelect;
|
|
281
|
-
|
|
289
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
290
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
291
|
+
selectNameGroupMap.set(key, selectNameGroup);
|
|
282
292
|
const newStructure = genQueryStructure([relationEntity], selectNameGroup);
|
|
283
|
-
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false,
|
|
293
|
+
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, module);
|
|
284
294
|
newStructures.push(newStructure);
|
|
285
295
|
newLogics.push(newLogic);
|
|
286
296
|
newLoadSelectLogics.push(genLoadSelectLogic(relationEntity, selectNameGroup, newLogic));
|
package/src/templator/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { utils } from '..';
|
|
2
|
-
import { App,
|
|
2
|
+
import { App, Module, Entity, EntityProperty, Logic, View, Namespace } from '../concepts';
|
|
3
3
|
|
|
4
4
|
export const filterProperty = (key: 'inTable' | 'inFilter' | 'inForm' | 'inDetail') => (property: EntityProperty) => {
|
|
5
5
|
if (property.display) {
|
|
@@ -136,7 +136,7 @@ function capFirstLetter(word: string) {
|
|
|
136
136
|
* @param suffix 其它后缀,比如实体名等等
|
|
137
137
|
* @param defaultInView 是否在页面逻辑中用 load 简写
|
|
138
138
|
*/
|
|
139
|
-
export function genUniqueQueryNameGroup(scope: App | Namespace, view: View, componentName: string = '', defaultInView: boolean = true, suffix: string = '') {
|
|
139
|
+
export function genUniqueQueryNameGroup(scope: App | Module | Namespace, view: View, componentName: string = '', defaultInView: boolean = true, suffix: string = '') {
|
|
140
140
|
const result: NameGroup = {};
|
|
141
141
|
result.viewLogicLoad = view.getLogicUniqueName(`load${defaultInView ? '' : capFirstLetter(componentName)}${suffix ? capFirstLetter(suffix) : ''}`);
|
|
142
142
|
result.logic = scope.getLogicUniqueName(`load${capFirstLetter(view.name)}${componentName ? capFirstLetter(componentName) : ''}${suffix ? capFirstLetter(suffix) : ''}`);
|
|
@@ -440,6 +440,7 @@ export const NaslQueryExpression = {
|
|
|
440
440
|
orderBy,
|
|
441
441
|
logicName,
|
|
442
442
|
structureName,
|
|
443
|
+
ideVersion,
|
|
443
444
|
}: {
|
|
444
445
|
label?: string;
|
|
445
446
|
typeAnnotation: any;
|
|
@@ -452,6 +453,7 @@ export const NaslQueryExpression = {
|
|
|
452
453
|
orderBy: any[];
|
|
453
454
|
logicName: string;
|
|
454
455
|
structureName: string;
|
|
456
|
+
ideVersion: string
|
|
455
457
|
}) => ({
|
|
456
458
|
concept: 'CallQueryComponent',
|
|
457
459
|
name: '',
|
|
@@ -467,6 +469,7 @@ export const NaslQueryExpression = {
|
|
|
467
469
|
orderBy,
|
|
468
470
|
logicName,
|
|
469
471
|
structureName,
|
|
472
|
+
ideVersion,
|
|
470
473
|
}),
|
|
471
474
|
};
|
|
472
475
|
|
|
@@ -12,13 +12,13 @@ describe('connect-file', () => {
|
|
|
12
12
|
it('batchAction', async () => {
|
|
13
13
|
await nasl.connect('file', path.join(__dirname, '../examples/app1.json'));
|
|
14
14
|
const app = await nasl.loadApp();
|
|
15
|
-
if (app.
|
|
16
|
-
const oldLength = app.
|
|
17
|
-
await app.
|
|
18
|
-
expect(app.
|
|
15
|
+
if (app.dataSources.length > 0) {
|
|
16
|
+
const oldLength = app.dataSources.length;
|
|
17
|
+
await app.dataSources[0].delete();
|
|
18
|
+
expect(app.dataSources.length).to.equal(oldLength - 1);
|
|
19
19
|
} else {
|
|
20
|
-
await app.
|
|
21
|
-
expect(app.
|
|
20
|
+
await app.addDataSource();
|
|
21
|
+
expect(app.dataSources.length).to.equal(1);
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
});
|
package/src/translator/index.ts
CHANGED
|
@@ -97,7 +97,7 @@ export function withSourceMap() {
|
|
|
97
97
|
|
|
98
98
|
let before: string = '';
|
|
99
99
|
if (!state.inline) {
|
|
100
|
-
before = indent(state
|
|
100
|
+
before = indent((state?.tabSize || 0));
|
|
101
101
|
state = shiftState(state, before);
|
|
102
102
|
} else {
|
|
103
103
|
state = shiftState(state, before, {
|
package/src/utils/index.ts
CHANGED
|
@@ -3,8 +3,59 @@ export * from './traverse';
|
|
|
3
3
|
export * from './logger';
|
|
4
4
|
|
|
5
5
|
import { compare } from 'compare-versions';
|
|
6
|
+
import { BaseNode } from '..';
|
|
6
7
|
import { traverse } from './traverse';
|
|
7
8
|
|
|
9
|
+
// 查找最近的模块
|
|
10
|
+
export function findClosestModule(node: BaseNode) {
|
|
11
|
+
let moduleNode = node;
|
|
12
|
+
while (moduleNode && !['App', 'Module'].includes(moduleNode.concept)) {
|
|
13
|
+
moduleNode = moduleNode.parentNode;
|
|
14
|
+
}
|
|
15
|
+
return moduleNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 从namespace获取关键字
|
|
19
|
+
export function findConceptKeyWordByNamespace(namespace: string) {
|
|
20
|
+
const namespaceArr = namespace?.split('.') || [];
|
|
21
|
+
const start = namespaceArr[0];
|
|
22
|
+
const mod = start === 'app' ? 1 : 0;
|
|
23
|
+
const keywordViews = namespaceArr.filter((namespaceItem, index) => index % 2 === mod);
|
|
24
|
+
return keywordViews.pop();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 从namespace中查找concept关键字
|
|
28
|
+
export function findConceptKeyWordIndexFromNamespace(namespace: string, keyword: string) {
|
|
29
|
+
const namespaceArr = namespace?.split('.') || [];
|
|
30
|
+
const start = namespaceArr[0];
|
|
31
|
+
const mod = start === 'app' ? 1 : 0;
|
|
32
|
+
return namespaceArr.findIndex((namespaceItem, index) => {
|
|
33
|
+
if (index % 2 === mod) {
|
|
34
|
+
return namespaceItem === keyword;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 从namespace中查找concept,返回找到类型对应的值
|
|
41
|
+
// 如 namespace : app.datasource.defaultDS keyword: datasource
|
|
42
|
+
// 返回 defaultDS
|
|
43
|
+
export function findConceptValueFromNamespace(namespace: string, keyword: string) {
|
|
44
|
+
const namespaceArr = namespace?.split('.') || [];
|
|
45
|
+
const start = namespaceArr[0];
|
|
46
|
+
const mod = start === 'app' ? 1 : 0;
|
|
47
|
+
const findIndex = namespaceArr.findIndex((namespaceItem, index) => {
|
|
48
|
+
if (index % 2 === mod) {
|
|
49
|
+
return namespaceItem === keyword;
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (findIndex)
|
|
55
|
+
return namespaceArr[findIndex + 1];
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
|
|
8
59
|
export function getGlobalEnv() {
|
|
9
60
|
return typeof window !== 'undefined' ? (window as any).appInfo.env : (global as any).appInfoEnv;
|
|
10
61
|
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const Namespace__1 = __importDefault(require("../../Namespace__"));
|
|
7
|
-
const Param__1 = __importDefault(require("../../Param__"));
|
|
8
|
-
const Logic__1 = __importDefault(require("../../Logic__"));
|
|
9
|
-
const TypeAnnotation__1 = __importDefault(require("../../TypeAnnotation__"));
|
|
10
|
-
exports.default = new Namespace__1.default({
|
|
11
|
-
name: 'browser',
|
|
12
|
-
logics: [
|
|
13
|
-
new Logic__1.default({
|
|
14
|
-
name: 'requestFullscreen',
|
|
15
|
-
params: [],
|
|
16
|
-
}),
|
|
17
|
-
new Logic__1.default({
|
|
18
|
-
name: 'exitFullscreen',
|
|
19
|
-
}),
|
|
20
|
-
new Logic__1.default({
|
|
21
|
-
name: 'hasAuth',
|
|
22
|
-
params: [
|
|
23
|
-
new Param__1.default({
|
|
24
|
-
name: 'authPath',
|
|
25
|
-
typeAnnotation: TypeAnnotation__1.default.createPrimitive('String'),
|
|
26
|
-
}),
|
|
27
|
-
],
|
|
28
|
-
returns: [],
|
|
29
|
-
}),
|
|
30
|
-
new Logic__1.default({
|
|
31
|
-
name: 'getDistance',
|
|
32
|
-
params: [
|
|
33
|
-
new Param__1.default({
|
|
34
|
-
name: 'Point1',
|
|
35
|
-
typeAnnotation: TypeAnnotation__1.default.createPrimitive('String'),
|
|
36
|
-
}),
|
|
37
|
-
new Param__1.default({
|
|
38
|
-
name: 'Point2',
|
|
39
|
-
typeAnnotation: TypeAnnotation__1.default.createPrimitive('String'),
|
|
40
|
-
}),
|
|
41
|
-
],
|
|
42
|
-
returns: [],
|
|
43
|
-
}),
|
|
44
|
-
new Logic__1.default({
|
|
45
|
-
name: 'logOut',
|
|
46
|
-
params: [
|
|
47
|
-
new Param__1.default({
|
|
48
|
-
name: 'Point1',
|
|
49
|
-
typeAnnotation: TypeAnnotation__1.default.createPrimitive('String'),
|
|
50
|
-
}),
|
|
51
|
-
new Param__1.default({
|
|
52
|
-
name: 'Point2',
|
|
53
|
-
typeAnnotation: TypeAnnotation__1.default.createPrimitive('String'),
|
|
54
|
-
}),
|
|
55
|
-
],
|
|
56
|
-
returns: [],
|
|
57
|
-
}),
|
|
58
|
-
new Logic__1.default({
|
|
59
|
-
name: 'getConfiguration',
|
|
60
|
-
params: [
|
|
61
|
-
new Param__1.default({
|
|
62
|
-
name: 'name',
|
|
63
|
-
typeAnnotation: TypeAnnotation__1.default.createPrimitive('String'),
|
|
64
|
-
}),
|
|
65
|
-
],
|
|
66
|
-
returns: [],
|
|
67
|
-
}),
|
|
68
|
-
],
|
|
69
|
-
});
|
|
70
|
-
//# sourceMappingURL=nasl.browser%20copy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nasl.browser copy.js","sourceRoot":"","sources":["../../../../src/concepts/basics/stdlib/nasl.browser copy.ts"],"names":[],"mappings":";;;;;AAAA,mEAA0C;AAC1C,2DAAkC;AAElC,2DAAkC;AAClC,6EAAoD;AAEpD,kBAAe,IAAI,oBAAS,CAAC;IACzB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE;QACJ,IAAI,gBAAK,CAAC;YACN,IAAI,EAAE,mBAAmB;YACzB,MAAM,EAAE,EACP;SACJ,CAAC;QACF,IAAI,gBAAK,CAAC;YACN,IAAI,EAAE,gBAAgB;SACzB,CAAC;QACF,IAAI,gBAAK,CAAC;YACN,IAAI,EAAE,SAAS;YACf,MAAM,EAAE;gBACJ,IAAI,gBAAK,CAAC;oBACN,IAAI,EAAE,UAAU;oBAChB,cAAc,EAAE,yBAAc,CAAC,eAAe,CAAC,QAAQ,CAAC;iBAC3D,CAAC;aACL;YACD,OAAO,EAAE,EACR;SACJ,CAAC;QACF,IAAI,gBAAK,CAAC;YACN,IAAI,EAAE,aAAa;YACnB,MAAM,EAAE;gBACJ,IAAI,gBAAK,CAAC;oBACN,IAAI,EAAE,QAAQ;oBACd,cAAc,EAAE,yBAAc,CAAC,eAAe,CAAC,QAAQ,CAAC;iBAC3D,CAAC;gBACF,IAAI,gBAAK,CAAC;oBACN,IAAI,EAAE,QAAQ;oBACd,cAAc,EAAE,yBAAc,CAAC,eAAe,CAAC,QAAQ,CAAC;iBAC3D,CAAC;aACL;YACD,OAAO,EAAE,EACR;SACJ,CAAC;QACF,IAAI,gBAAK,CAAC;YACN,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE;gBACJ,IAAI,gBAAK,CAAC;oBACN,IAAI,EAAE,QAAQ;oBACd,cAAc,EAAE,yBAAc,CAAC,eAAe,CAAC,QAAQ,CAAC;iBAC3D,CAAC;gBACF,IAAI,gBAAK,CAAC;oBACN,IAAI,EAAE,QAAQ;oBACd,cAAc,EAAE,yBAAc,CAAC,eAAe,CAAC,QAAQ,CAAC;iBAC3D,CAAC;aACL;YACD,OAAO,EAAE,EACR;SACJ,CAAC;QACF,IAAI,gBAAK,CAAC;YACN,IAAI,EAAE,kBAAkB;YACxB,MAAM,EAAE;gBACJ,IAAI,gBAAK,CAAC;oBACN,IAAI,EAAE,MAAM;oBACZ,cAAc,EAAE,yBAAc,CAAC,eAAe,CAAC,QAAQ,CAAC;iBAC3D,CAAC;aACL;YACD,OAAO,EAAE,EACR;SACJ,CAAC;KACL;CACJ,CAAC,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export declare const LEVEL_NAME_MAP: {
|
|
2
|
-
app: string;
|
|
3
|
-
service: string;
|
|
4
|
-
page: string;
|
|
5
|
-
view: string;
|
|
6
|
-
block: string;
|
|
7
|
-
logic: string;
|
|
8
|
-
param: string;
|
|
9
|
-
timer: string;
|
|
10
|
-
variable: string;
|
|
11
|
-
return: string;
|
|
12
|
-
interface: string;
|
|
13
|
-
dataNode: string;
|
|
14
|
-
entity: string;
|
|
15
|
-
structure: string;
|
|
16
|
-
enum: string;
|
|
17
|
-
enumItem: string;
|
|
18
|
-
property: string;
|
|
19
|
-
element: string;
|
|
20
|
-
attr: string;
|
|
21
|
-
event: string;
|
|
22
|
-
directive: string;
|
|
23
|
-
logicItem: string;
|
|
24
|
-
logicNode: string;
|
|
25
|
-
expressionNode: string;
|
|
26
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LEVEL_NAME_MAP = void 0;
|
|
4
|
-
exports.LEVEL_NAME_MAP = {
|
|
5
|
-
app: '应用',
|
|
6
|
-
service: '服务',
|
|
7
|
-
page: '页面',
|
|
8
|
-
view: '子页面',
|
|
9
|
-
block: '区块',
|
|
10
|
-
logic: '逻辑',
|
|
11
|
-
param: '输入参数',
|
|
12
|
-
timer: '定时任务',
|
|
13
|
-
variable: '局部变量',
|
|
14
|
-
return: '输出参数',
|
|
15
|
-
interface: '接口',
|
|
16
|
-
dataNode: '数据',
|
|
17
|
-
entity: '实体',
|
|
18
|
-
structure: '数据结构',
|
|
19
|
-
enum: '枚举',
|
|
20
|
-
enumItem: '枚举项',
|
|
21
|
-
property: '属性',
|
|
22
|
-
element: '元素',
|
|
23
|
-
attr: '属性',
|
|
24
|
-
event: '事件',
|
|
25
|
-
directive: '指令',
|
|
26
|
-
logicItem: '逻辑项',
|
|
27
|
-
logicNode: '逻辑节点',
|
|
28
|
-
expressionNode: '表达式节点',
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=LEVEL_NAME_MAP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LEVEL_NAME_MAP.js","sourceRoot":"","sources":["../../src/terms/LEVEL_NAME_MAP.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG;IAC1B,GAAG,EAAE,IAAI;IACT,OAAO,EAAE,IAAI;IAEb,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,IAAI;IAEX,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,IAAI;IAEf,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,IAAI;IAEd,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,IAAI;IAEf,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,MAAM;IACjB,cAAc,EAAE,OAAO;CAC1B,CAAC"}
|