@lcap/nasl 1.0.2 → 2.12.0
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 +92 -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 +5 -0
- package/out/common/BaseNode.js +24 -3
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +51 -49
- package/out/concepts/App__.js +86 -53
- package/out/concepts/App__.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 +8 -2
- 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 +8 -7
- package/out/concepts/CallQueryComponent__.js +86 -76
- 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/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 +8 -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 +6 -0
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +9 -0
- package/out/concepts/EntityProperty__.js +19 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +5 -0
- package/out/concepts/Entity__.js +20 -10
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.js +12 -6
- 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 +6 -15
- 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/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 +2 -1
- package/out/concepts/Param__.js +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +30 -10
- 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/QueryFieldExpression__.js +8 -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/QueryJoinExpression__.d.ts +4 -0
- package/out/concepts/QueryJoinExpression__.js +14 -3
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/Return__.js +1 -1
- 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 +1 -1
- package/out/concepts/StructureProperty__.js +6 -5
- 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 +44 -2
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/Variable__.js +1 -1
- 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 +0 -2
- package/out/concepts/View__.js +27 -32
- 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.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 +280 -2
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +4 -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/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/server/createUiTs.js +1 -0
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/getLogics.js +27 -1
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +5 -0
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +4 -0
- package/out/server/getProcesses.js +69 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.d.ts +1 -0
- package/out/server/naslServer.js +223 -26
- 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.js +37 -1
- 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 +95 -84
- 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/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 +25 -26
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genSelectBlock.js +8 -7
- 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 +34 -24
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +2 -2
- 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 -1
- 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 +95 -68
- package/src/automate/template/process.js +10999 -0
- package/src/bak/translator.js +1 -0
- package/src/common/BaseNode.ts +21 -4
- package/src/concepts/App__.ts +128 -94
- 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 +6 -2
- package/src/concepts/CallLogic__.ts +47 -32
- package/src/concepts/CallQueryComponent__.ts +92 -81
- 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/DataSource__.ts +391 -0
- package/src/concepts/Destination__.ts +24 -8
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +7 -0
- package/src/concepts/EntityProperty__.ts +20 -2
- package/src/concepts/Entity__.ts +23 -11
- package/src/concepts/Enum__.ts +25 -6
- package/src/concepts/ForEachStatement__.ts +2 -2
- package/src/concepts/Function__.ts +95 -1
- package/src/concepts/Identifier__.ts +15 -15
- package/src/concepts/IfStatement__.ts +9 -9
- 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 +3 -2
- package/src/concepts/ProcessElement__.ts +33 -12
- package/src/concepts/Process__.ts +18 -12
- package/src/concepts/QueryFieldExpression__.ts +9 -1
- package/src/concepts/QueryFromExpression__.ts +13 -2
- package/src/concepts/QueryJoinExpression__.ts +14 -3
- package/src/concepts/Return__.ts +1 -1
- package/src/concepts/Role__.ts +10 -4
- package/src/concepts/SqlQueryComponent__.ts +47 -11
- package/src/concepts/StringLiteral__.ts +1 -1
- package/src/concepts/StructureProperty__.ts +6 -9
- 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 +43 -2
- package/src/concepts/Variable__.ts +1 -1
- package/src/concepts/ViewElement__.ts +26 -39
- package/src/concepts/View__.ts +29 -34
- package/src/concepts/WhileStatement__.ts +4 -4
- package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
- 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 +281 -2
- package/src/concepts/basics/types/index.ts +1 -0
- package/src/concepts/index__.ts +1 -0
- package/src/generator/genBundleFiles.ts +28 -7
- package/src/generator/genMetaData.ts +22 -13
- package/src/index.ts +1 -1
- package/src/server/createUiTs.ts +1 -0
- package/src/server/getLogics.ts +29 -4
- package/src/server/getMemberIdentifier.ts +4 -0
- package/src/server/getProcesses.ts +68 -0
- package/src/server/naslServer.ts +227 -30
- package/src/server/process2LogicNamespace.ts +29 -19
- package/src/server/translator.ts +39 -1
- package/src/service/creator/errHandles.js +6 -0
- package/src/service/storage/init.ts +97 -86
- 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/genGridViewBlock.ts +30 -25
- package/src/templator/genListViewBlock.ts +10 -7
- package/src/templator/genQueryComponent.ts +28 -27
- package/src/templator/genSelectBlock.ts +9 -8
- package/src/templator/genTableBlock.ts +32 -23
- package/src/templator/genUpdateBlock.ts +35 -25
- package/src/templator/utils.ts +2 -2
- package/src/test/integration/connect-file.ts +6 -6
- package/src/translator/index.ts +1 -1
- package/src/utils/index.ts +51 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as utils from '../utils';
|
|
2
|
-
import { App, Namespace, Entity, Structure, QueryJoinExpression, CallQueryComponent, StructureProperty } from '../concepts';
|
|
2
|
+
import { App, Module, Namespace, Entity, Structure, QueryJoinExpression, CallQueryComponent, StructureProperty, DataSource } from '../concepts';
|
|
3
3
|
import { NameGroup, NaslCoreTypeAnnotation, NaslCollectionTypeAnnotation, NaslTypeAnnotation, NaslQueryExpression, NaslLogicItem, NaslNode } from './utils';
|
|
4
4
|
|
|
5
5
|
export function genQueryStructure(allEntities: Array<Entity>, nameGroup: NameGroup) {
|
|
@@ -66,35 +66,33 @@ function genWhereExpression(entity: Entity) {
|
|
|
66
66
|
export function genQueryAssignment(allEntities: Array<Entity>, nameGroup: NameGroup, supportFilter: boolean, supportSort: boolean) {
|
|
67
67
|
allEntities = Array.from(allEntities);
|
|
68
68
|
const entity = allEntities.shift();
|
|
69
|
-
const
|
|
70
|
-
const
|
|
69
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
70
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
71
71
|
|
|
72
72
|
const from = NaslQueryExpression.QueryFromExpression({
|
|
73
73
|
entityNamespace: entity.getNamespace(),
|
|
74
74
|
entityName: entity.name,
|
|
75
75
|
joinParts: allEntities.map((relationEntity) => {
|
|
76
|
-
const
|
|
76
|
+
const onExpressions = entity.properties?.filter((property) => property.relationEntity === relationEntity.name).map((leftProperty) => NaslLogicItem.BinaryExpression({
|
|
77
|
+
operator: '==',
|
|
78
|
+
left: NaslQueryExpression.QueryFieldExpression({
|
|
79
|
+
label: '查询组件实体属性',
|
|
80
|
+
isDotStar: false,
|
|
81
|
+
entityAsName: entity.name,
|
|
82
|
+
propertyName: leftProperty.name,
|
|
83
|
+
}),
|
|
84
|
+
right: NaslQueryExpression.QueryFieldExpression({
|
|
85
|
+
label: '查询组件实体属性',
|
|
86
|
+
isDotStar: false,
|
|
87
|
+
entityAsName: relationEntity.name,
|
|
88
|
+
propertyName: leftProperty.relationProperty,
|
|
89
|
+
}),
|
|
90
|
+
}));
|
|
77
91
|
return NaslQueryExpression.QueryJoinExpression({
|
|
78
92
|
entityNamespace: relationEntity.getNamespace(),
|
|
79
93
|
entityName: relationEntity.name,
|
|
80
94
|
joinType: 'LEFT',
|
|
81
|
-
onExpressions
|
|
82
|
-
NaslLogicItem.BinaryExpression({
|
|
83
|
-
operator: '==',
|
|
84
|
-
left: NaslQueryExpression.QueryFieldExpression({
|
|
85
|
-
label: '查询组件实体属性',
|
|
86
|
-
isDotStar: false,
|
|
87
|
-
entityAsName: entity.name,
|
|
88
|
-
propertyName: leftProperty.name,
|
|
89
|
-
}),
|
|
90
|
-
right: NaslQueryExpression.QueryFieldExpression({
|
|
91
|
-
label: '查询组件实体属性',
|
|
92
|
-
isDotStar: false,
|
|
93
|
-
entityAsName: relationEntity.name,
|
|
94
|
-
propertyName: leftProperty.relationProperty,
|
|
95
|
-
}),
|
|
96
|
-
}),
|
|
97
|
-
],
|
|
95
|
+
onExpressions,
|
|
98
96
|
joinParts: [],
|
|
99
97
|
});
|
|
100
98
|
}),
|
|
@@ -109,7 +107,7 @@ export function genQueryAssignment(allEntities: Array<Entity>, nameGroup: NameGr
|
|
|
109
107
|
ideVersion: '2.11', // 2.11版本新创建的数据查询组件,返回类型将自动推断
|
|
110
108
|
typeAnnotation: NaslCollectionTypeAnnotation.PageOf([
|
|
111
109
|
NaslTypeAnnotation.Reference({
|
|
112
|
-
typeNamespace: `${
|
|
110
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
113
111
|
typeName: nameGroup.structure,
|
|
114
112
|
}),
|
|
115
113
|
]),
|
|
@@ -150,7 +148,10 @@ export function genQueryAssignment(allEntities: Array<Entity>, nameGroup: NameGr
|
|
|
150
148
|
}
|
|
151
149
|
|
|
152
150
|
export function genQueryLogic(allEntities: Array<Entity>, nameGroup: NameGroup, supportFilter: boolean, supportSort: boolean, parentNode: any) {
|
|
153
|
-
const
|
|
151
|
+
const entity = allEntities?.[0];
|
|
152
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
153
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
154
|
+
|
|
154
155
|
const logic = NaslNode.Logic({
|
|
155
156
|
name: nameGroup.logic,
|
|
156
157
|
description: '',
|
|
@@ -169,7 +170,7 @@ export function genQueryLogic(allEntities: Array<Entity>, nameGroup: NameGroup,
|
|
|
169
170
|
name: 'result',
|
|
170
171
|
typeAnnotation: NaslCollectionTypeAnnotation.PageOf([
|
|
171
172
|
NaslTypeAnnotation.Reference({
|
|
172
|
-
typeNamespace: `${
|
|
173
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
173
174
|
typeName: nameGroup.structure,
|
|
174
175
|
}),
|
|
175
176
|
]),
|
|
@@ -188,7 +189,7 @@ export function genQueryLogic(allEntities: Array<Entity>, nameGroup: NameGroup,
|
|
|
188
189
|
typeAnnotation: NaslCoreTypeAnnotation.String,
|
|
189
190
|
}));
|
|
190
191
|
}
|
|
191
|
-
|
|
192
|
+
|
|
192
193
|
if (supportFilter && entity) {
|
|
193
194
|
logic.params.push(NaslNode.Param({
|
|
194
195
|
name: 'filter',
|
|
@@ -202,11 +203,11 @@ export function genQueryLogic(allEntities: Array<Entity>, nameGroup: NameGroup,
|
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
export async function joinEntity(callQueryComponent: CallQueryComponent, entity: Entity, recordStructure: Structure) {
|
|
205
|
-
const
|
|
206
|
+
const dataSource = entity.parentNode as DataSource;
|
|
206
207
|
const from = callQueryComponent.from;
|
|
207
208
|
let joinInfo;
|
|
208
209
|
// 无法判断用户行为,优先加有关系的
|
|
209
|
-
const lastEntity =
|
|
210
|
+
const lastEntity = dataSource.findEntityByName(from.entityName);
|
|
210
211
|
// lastEntity 和 entity Join
|
|
211
212
|
// 判断要不要自动关联 onExpression
|
|
212
213
|
// 一般左联是自动有的了
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { config } from '../config';
|
|
2
2
|
import * as utils from '../utils';
|
|
3
|
-
import { App, Namespace, Entity, EntityProperty, View } from '../concepts';
|
|
3
|
+
import { App, Module, Namespace, Entity, EntityProperty, View, DataSource } from '../concepts';
|
|
4
4
|
import { NameGroup, genUniqueQueryNameGroup, getFirstDisplayedProperty, genQueryLogic, genQueryStructure, genLogicParam } from '.';
|
|
5
5
|
import {
|
|
6
6
|
NaslUITypeAnnotation, NaslCollectionTypeAnnotation, NaslLogicItem,
|
|
@@ -35,8 +35,8 @@ export function genH5SelectTemplate(property: EntityProperty, nameGroup: NameGro
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export function genLoadSelectLogic(entity: Entity, nameGroup: NameGroup, newLogic: any) {
|
|
38
|
-
const
|
|
39
|
-
const
|
|
38
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
39
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
40
40
|
const params = [
|
|
41
41
|
genLogicParam(`${newLogic.params[0].name}`, 'params.page'),
|
|
42
42
|
genLogicParam(`${newLogic.params[1].name}`, 'params.size'),
|
|
@@ -54,7 +54,7 @@ export function genLoadSelectLogic(entity: Entity, nameGroup: NameGroup, newLogi
|
|
|
54
54
|
name: 'result',
|
|
55
55
|
typeAnnotation: NaslCollectionTypeAnnotation.PageOf([
|
|
56
56
|
NaslTypeAnnotation.Reference({
|
|
57
|
-
typeNamespace: `${
|
|
57
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
58
58
|
typeName: nameGroup.structure,
|
|
59
59
|
}),
|
|
60
60
|
]),
|
|
@@ -68,7 +68,7 @@ export function genLoadSelectLogic(entity: Entity, nameGroup: NameGroup, newLogi
|
|
|
68
68
|
name: 'result',
|
|
69
69
|
}),
|
|
70
70
|
right: NaslLogicItem.CallLogic({
|
|
71
|
-
calleeNamespace: `${
|
|
71
|
+
calleeNamespace: `${moduleNamespace}.logics`,
|
|
72
72
|
calleeName: newLogic.name,
|
|
73
73
|
arguments: params,
|
|
74
74
|
}),
|
|
@@ -85,10 +85,11 @@ export function genLoadSelectLogic(entity: Entity, nameGroup: NameGroup, newLogi
|
|
|
85
85
|
* @returns
|
|
86
86
|
*/
|
|
87
87
|
export function genSelectBlock(entity: Entity, view: View) {
|
|
88
|
-
const
|
|
88
|
+
const dataSource = entity.parentNode as DataSource;
|
|
89
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
89
90
|
|
|
90
91
|
const viewElementMainView = view.getViewElementUniqueName('select');
|
|
91
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
92
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView, false);
|
|
92
93
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
93
94
|
nameGroup.lowerEntity = utils.firstLowerCase(entity.name);
|
|
94
95
|
|
|
@@ -101,7 +102,7 @@ export function genSelectBlock(entity: Entity, view: View) {
|
|
|
101
102
|
const newStructures: Array<any> = [
|
|
102
103
|
genQueryStructure(allEntities, nameGroup),
|
|
103
104
|
];
|
|
104
|
-
const newLogic = genQueryLogic(allEntities, nameGroup, false, false,
|
|
105
|
+
const newLogic = genQueryLogic(allEntities, nameGroup, false, false, module);
|
|
105
106
|
const newLogics: Array<any> = [
|
|
106
107
|
newLogic,
|
|
107
108
|
];
|
|
@@ -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, '');
|
|
@@ -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) : ''}`);
|
|
@@ -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
|
}
|