@lcap/nasl 1.0.2 → 2.12.0-beta
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.js +11 -0
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/uniqueName.js +1 -1
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.d.ts +1 -0
- package/out/automate/engine/utils.js +89 -67
- package/out/automate/engine/utils.js.map +1 -1
- package/out/concepts/App__.d.ts +51 -49
- package/out/concepts/App__.js +86 -54
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js +1 -1
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignee__.js +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/Assignment__.js +1 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/Attribute__.js +1 -1
- package/out/concepts/Attribute__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js +1 -1
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +3 -3
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +1 -1
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +11 -6
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.js +1 -1
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +8 -3
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +1 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +23 -21
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +9 -8
- package/out/concepts/CallQueryComponent__.js +89 -79
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +2 -2
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js +1 -1
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +8 -1
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigPropertyValue__.js +1 -1
- package/out/concepts/ConfigPropertyValue__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +1 -0
- package/out/concepts/ConfigProperty__.js +4 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +4 -1
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Constant__.js +1 -1
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataElement__.js +1 -1
- package/out/concepts/DataElement__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +143 -0
- package/out/concepts/DataSource__.js +316 -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 +3 -3
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +5 -0
- package/out/concepts/EntityIndex__.js +7 -1
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +9 -0
- package/out/concepts/EntityProperty__.js +20 -3
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +5 -0
- package/out/concepts/Entity__.js +21 -11
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.js +1 -1
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.js +11 -5
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +3 -3
- 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 +3 -13
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +9 -9
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +1 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js +19 -12
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicItem__.js +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +41 -42
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +1 -1
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +1 -85
- package/out/concepts/Module__.js +6 -107
- 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/NullLiteral__.js +1 -1
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.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/Point__.js +1 -1
- package/out/concepts/Point__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js +1 -1
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +26 -11
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/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__.js +9 -2
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +4 -0
- package/out/concepts/QueryFromExpression__.js +14 -3
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.js +1 -1
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +4 -0
- package/out/concepts/QueryJoinExpression__.js +15 -4
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js +1 -1
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.js +1 -1
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Rect__.js +1 -1
- package/out/concepts/Rect__.js.map +1 -1
- package/out/concepts/Return__.js +1 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +11 -4
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/Slot__.js +1 -1
- package/out/concepts/Slot__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +10 -0
- package/out/concepts/SqlQueryComponent__.js +32 -5
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Start__.js +1 -1
- package/out/concepts/Start__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +1 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +1 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +20 -13
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js +6 -6
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +1 -1
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/Theme__.js +1 -1
- package/out/concepts/Theme__.js.map +1 -1
- package/out/concepts/Transactional__.js +1 -1
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +8 -0
- package/out/concepts/TypeAnnotation__.js +46 -4
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.js +1 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +1 -1
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/Unparsed__.js +1 -1
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/UseComponent__.js +1 -1
- package/out/concepts/UseComponent__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +1 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +1 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js +1 -1
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.js +18 -18
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +25 -23
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +5 -5
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +278 -0
- package/out/concepts/basics/stdlib/nasl.util.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.js +8 -3
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.js +13 -12
- package/out/generator/genMetaData.js.map +1 -1
- package/out/server/createUiTs.js +1 -0
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/getLogics.js +9 -1
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getProcesses.d.ts +3 -0
- package/out/server/getProcesses.js +61 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.js +128 -6
- 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 +19 -1
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +2 -2
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +15 -11
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +15 -12
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +25 -21
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +12 -12
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +21 -20
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +6 -3
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.js +5 -5
- 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 +17 -15
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +15 -11
- 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 +4 -0
- package/out/utils/index.js +32 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/automate/engine/index.js +12 -1
- package/src/automate/engine/uniqueName.js +1 -1
- package/src/automate/engine/utils.js +92 -67
- package/src/concepts/App__.ts +165 -95
- package/src/concepts/Argument__.ts +1 -1
- package/src/concepts/Assignee__.ts +1 -1
- package/src/concepts/Assignment__.ts +1 -1
- package/src/concepts/Attribute__.ts +1 -1
- package/src/concepts/BinaryExpression__.ts +1 -1
- package/src/concepts/BindAttribute__.ts +3 -3
- package/src/concepts/BindDirective__.ts +1 -1
- package/src/concepts/BindEvent__.ts +10 -6
- package/src/concepts/BooleanLiteral__.ts +1 -1
- package/src/concepts/CallFunction__.ts +19 -16
- package/src/concepts/CallInterface__.ts +1 -1
- package/src/concepts/CallLogic__.ts +23 -23
- package/src/concepts/CallQueryComponent__.ts +96 -113
- package/src/concepts/Comment__.ts +2 -2
- package/src/concepts/CompletionProperty__.ts +1 -1
- package/src/concepts/ConfigGroup__.ts +4 -2
- package/src/concepts/ConfigPropertyValue__.ts +1 -1
- package/src/concepts/ConfigProperty__.ts +5 -1
- package/src/concepts/Configuration__.ts +4 -1
- package/src/concepts/Constant__.ts +1 -1
- package/src/concepts/DataElement__.ts +1 -1
- package/src/concepts/DataSource__.ts +389 -0
- package/src/concepts/Destination__.ts +24 -8
- package/src/concepts/End__.ts +3 -3
- package/src/concepts/EntityIndex__.ts +8 -1
- package/src/concepts/EntityProperty__.ts +21 -3
- package/src/concepts/Entity__.ts +24 -12
- package/src/concepts/EnumItem__.ts +1 -1
- package/src/concepts/Enum__.ts +24 -5
- package/src/concepts/Event__.ts +1 -1
- package/src/concepts/ForEachStatement__.ts +3 -3
- package/src/concepts/Function__.ts +97 -3
- package/src/concepts/Identifier__.ts +12 -13
- package/src/concepts/IfStatement__.ts +10 -10
- package/src/concepts/InterfaceParam__.ts +1 -1
- package/src/concepts/Interface__.ts +20 -12
- package/src/concepts/JSBlock__.ts +1 -1
- package/src/concepts/LogicItem__.ts +1 -1
- package/src/concepts/Logic__.ts +41 -39
- package/src/concepts/MemberExpression__.ts +1 -1
- package/src/concepts/Module__.ts +9 -204
- package/src/concepts/Namespace__.ts +1 -204
- package/src/concepts/NullLiteral__.ts +1 -1
- package/src/concepts/NumericLiteral__.ts +1 -1
- package/src/concepts/Param__.ts +3 -2
- package/src/concepts/Point__.ts +1 -1
- package/src/concepts/ProcessComponent__.ts +1 -1
- package/src/concepts/ProcessElement__.ts +29 -13
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/Process__.ts +17 -11
- package/src/concepts/QueryAggregateExpression__.ts +1 -1
- package/src/concepts/QueryFieldExpression__.ts +10 -2
- package/src/concepts/QueryFromExpression__.ts +14 -3
- package/src/concepts/QueryGroupByExpression__.ts +1 -1
- package/src/concepts/QueryJoinExpression__.ts +15 -4
- package/src/concepts/QueryLimitExpression__.ts +1 -1
- package/src/concepts/QueryOrderByExpression__.ts +1 -1
- package/src/concepts/QuerySelectExpression__.ts +1 -1
- package/src/concepts/Rect__.ts +1 -1
- package/src/concepts/Return__.ts +1 -1
- package/src/concepts/Role__.ts +11 -5
- package/src/concepts/Slot__.ts +1 -1
- package/src/concepts/SqlQueryComponent__.ts +30 -11
- package/src/concepts/Start__.ts +1 -1
- package/src/concepts/StringLiteral__.ts +1 -1
- package/src/concepts/StructureProperty__.ts +1 -1
- package/src/concepts/Structure__.ts +20 -12
- package/src/concepts/SwitchCase__.ts +6 -6
- package/src/concepts/SwitchStatement__.ts +1 -1
- package/src/concepts/Theme__.ts +1 -1
- package/src/concepts/Transactional__.ts +1 -1
- package/src/concepts/TypeAnnotation__.ts +45 -23
- package/src/concepts/TypeParam__.ts +1 -1
- package/src/concepts/UnaryExpression__.ts +1 -1
- package/src/concepts/Unparsed__.ts +1 -1
- package/src/concepts/UseComponent__.ts +1 -1
- package/src/concepts/ValidationRule__.ts +1 -1
- package/src/concepts/Variable__.ts +1 -1
- package/src/concepts/ViewComponent__.ts +1 -1
- package/src/concepts/ViewElement__.ts +19 -19
- package/src/concepts/View__.ts +25 -23
- package/src/concepts/WhileStatement__.ts +5 -5
- package/src/concepts/basics/stdlib/nasl.util.ts +279 -0
- package/src/concepts/index__.ts +1 -0
- package/src/generator/genBundleFiles.ts +8 -3
- package/src/generator/genMetaData.ts +13 -13
- package/src/server/createUiTs.ts +1 -0
- package/src/server/getLogics.ts +11 -3
- package/src/server/getProcesses.ts +61 -0
- package/src/server/naslServer.ts +124 -6
- package/src/server/process2LogicNamespace.ts +29 -19
- package/src/server/translator.ts +22 -1
- package/src/service/storage/init.ts +2 -2
- package/src/templator/genCreateBlock.ts +16 -13
- package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -13
- package/src/templator/genCurdMultipleKeyBlock.ts +26 -22
- package/src/templator/genEditTableBlock.ts +14 -13
- package/src/templator/genGridViewBlock.ts +22 -21
- package/src/templator/genListViewBlock.ts +9 -5
- package/src/templator/genQueryComponent.ts +6 -6
- package/src/templator/genSelectBlock.ts +9 -8
- package/src/templator/genTableBlock.ts +18 -16
- package/src/templator/genUpdateBlock.ts +16 -12
- 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 +32 -0
package/src/server/naslServer.ts
CHANGED
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
Namespace,
|
|
45
45
|
Theme,
|
|
46
46
|
Variable,
|
|
47
|
+
DataSource,
|
|
47
48
|
Assignee,
|
|
48
49
|
} from '../concepts';
|
|
49
50
|
import { lsp2tspNumber, SourceMap, SourceMapItem, embeddedTSEmitter } from '../translator';
|
|
@@ -142,17 +143,30 @@ const naslServer = {
|
|
|
142
143
|
console.log(err);
|
|
143
144
|
}
|
|
144
145
|
});
|
|
145
|
-
module.
|
|
146
|
+
(module as App).dataSources?.forEach((dataSource) => {
|
|
147
|
+
// 本身dataSource也要生成一个文件用于改名
|
|
146
148
|
try {
|
|
147
|
-
const result =
|
|
149
|
+
const result = dataSource.toEmbeddedTSFile();
|
|
148
150
|
results.push(result);
|
|
149
151
|
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
150
|
-
|
|
151
|
-
this.file2NodeMap.set(result.filePath,
|
|
152
|
+
dataSource.sourceMap = result.sourceMap;
|
|
153
|
+
this.file2NodeMap.set(result.filePath, dataSource);
|
|
152
154
|
} catch (err) {
|
|
153
155
|
console.log(err);
|
|
154
156
|
}
|
|
157
|
+
dataSource.entities.forEach((entity) => {
|
|
158
|
+
try {
|
|
159
|
+
const result = entity.toEmbeddedTSFile();
|
|
160
|
+
results.push(result);
|
|
161
|
+
// sourceMap都存在目录级别内容下,在页面层级下去找
|
|
162
|
+
entity.sourceMap = result.sourceMap;
|
|
163
|
+
this.file2NodeMap.set(result.filePath, entity);
|
|
164
|
+
} catch (err) {
|
|
165
|
+
console.log(err);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
155
168
|
});
|
|
169
|
+
|
|
156
170
|
module.interfaces.forEach((_interface) => {
|
|
157
171
|
try {
|
|
158
172
|
const result = _interface.toEmbeddedTSFile();
|
|
@@ -529,6 +543,32 @@ const naslServer = {
|
|
|
529
543
|
}
|
|
530
544
|
}, { node: { children: fileNode.elements } as ViewElement });
|
|
531
545
|
}
|
|
546
|
+
if (fileNode instanceof DataSource) {
|
|
547
|
+
const dataSourceGroup = (fileNode.rootNode as App).configuration?.getGroup('dataSource');
|
|
548
|
+
if (dataSourceGroup) {
|
|
549
|
+
const property = dataSourceGroup.getProperty(fileNode.name);
|
|
550
|
+
if (property && property.values) {
|
|
551
|
+
property.values.forEach((propertyValue) => {
|
|
552
|
+
if (!propertyValue.value) {
|
|
553
|
+
const diagnostic = {
|
|
554
|
+
node: fileNode,
|
|
555
|
+
severity: 'error',
|
|
556
|
+
message: `数据源配置:数据源${property.name}${propertyValue.env === 'dev' ? '开发环境' : '生产环境'}未配置数据信息`,
|
|
557
|
+
// 保留原来的内容方便查询一些问题
|
|
558
|
+
originalDiagnostic: {
|
|
559
|
+
fileName: '',
|
|
560
|
+
start: <any>null,
|
|
561
|
+
end: <any>null,
|
|
562
|
+
category: 'error',
|
|
563
|
+
text: `Data Source is not config`,
|
|
564
|
+
},
|
|
565
|
+
};
|
|
566
|
+
diagnostics.push(diagnostic);
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
532
572
|
|
|
533
573
|
return diagnostics;
|
|
534
574
|
},
|
|
@@ -625,6 +665,33 @@ const naslServer = {
|
|
|
625
665
|
}
|
|
626
666
|
}
|
|
627
667
|
|
|
668
|
+
// 如果是DataSource就需要在单独,查一边来修改名字
|
|
669
|
+
if (node instanceof DataSource) {
|
|
670
|
+
// 过滤一把不需要改的信息
|
|
671
|
+
refsList = refsList.filter((item) => {
|
|
672
|
+
const dataSourceFile = (fileNode as FileNode).getEmbeddedFilePath();
|
|
673
|
+
const entityFilePrefix = dataSourceFile.replace('.ts', '');
|
|
674
|
+
/**
|
|
675
|
+
* 特殊处理,因为关联属性或者关联实体等等都是在实体里,在实体中因为自己不可以是自己的类型
|
|
676
|
+
* 所以全部过滤掉了,
|
|
677
|
+
* 但是在datasource里面在实体里会有大量的引用,不需要全部修改.只需要处理除了8个函数之外的引用
|
|
678
|
+
* 所以底部内容是8个函数,所以这里就 用entity的行数 减去8个函数的行数,然后其余的在进行处理
|
|
679
|
+
* 进行过滤
|
|
680
|
+
*/
|
|
681
|
+
// 不要数据源下面的实体里的引用 ,保留原始的节点内容
|
|
682
|
+
let flag = false;
|
|
683
|
+
if (item.file.includes(entityFilePrefix)) {
|
|
684
|
+
const entity = this.file2NodeMap.get(item.file);
|
|
685
|
+
const { currentSource } = naslServer.getCurrentSource(entity);
|
|
686
|
+
// 32 8个函数的总行数
|
|
687
|
+
if (item.end.line < (currentSource.range.end.line - 32) && item.start.line > 1) {
|
|
688
|
+
flag = true;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
// 属于实体而且需要修改和查到 || 不是实体前缀的 || 他本身
|
|
692
|
+
return flag || !item.file.includes(entityFilePrefix) || dataSourceFile === item.file;
|
|
693
|
+
});
|
|
694
|
+
}
|
|
628
695
|
// 如果是entity就需要在单独,查一边来修改名字
|
|
629
696
|
if (node instanceof Entity) {
|
|
630
697
|
// 过滤一把不需要改的信息
|
|
@@ -983,6 +1050,40 @@ const naslServer = {
|
|
|
983
1050
|
if (minRange.node instanceof QueryFieldExpression && node instanceof Entity) {
|
|
984
1051
|
minRange.setTypeMethods = 'setEntityAsName';
|
|
985
1052
|
}
|
|
1053
|
+
// 如果修改的是dataSource字段
|
|
1054
|
+
if (node instanceof DataSource) {
|
|
1055
|
+
const setTypeNamespace = (typeNamespace: string, record: any) => {
|
|
1056
|
+
// 先看下标位置
|
|
1057
|
+
const lineText = record.lineText;
|
|
1058
|
+
const index = lineText.indexOf(typeNamespace);
|
|
1059
|
+
// 在把开始结束位置的-开始位置,来知道是哪里要替换
|
|
1060
|
+
const start = record.start.offset - index - 1;
|
|
1061
|
+
const end = record.end.offset - index - 1;
|
|
1062
|
+
// 新的完整的value
|
|
1063
|
+
const newTextValue = typeNamespace.substring(0, start) + newValue + typeNamespace.substring(end, typeNamespace.length);
|
|
1064
|
+
minRange.newValue = newTextValue;
|
|
1065
|
+
return newTextValue;
|
|
1066
|
+
};
|
|
1067
|
+
if (minRange.node instanceof TypeAnnotation) {
|
|
1068
|
+
minRange.setTypeMethods = 'setTypeNamespace';
|
|
1069
|
+
const newValue = setTypeNamespace(minRange.node.typeNamespace, record);
|
|
1070
|
+
minRange.newValue = newValue;
|
|
1071
|
+
} else if (minRange.node instanceof QueryFromExpression || minRange.node instanceof QueryJoinExpression) {
|
|
1072
|
+
minRange.setTypeMethods = 'setEntityNamespace';
|
|
1073
|
+
const newValue = setTypeNamespace(minRange.node.entityNamespace, record);
|
|
1074
|
+
minRange.newValue = newValue;
|
|
1075
|
+
} else if (minRange.node instanceof QueryFieldExpression) {
|
|
1076
|
+
return null;
|
|
1077
|
+
} else if (minRange.node instanceof CallLogic) {
|
|
1078
|
+
minRange.setTypeMethods = 'setCalleeNamespace';
|
|
1079
|
+
const newValue = setTypeNamespace(minRange.node.calleeNamespace, record);
|
|
1080
|
+
minRange.newValue = newValue;
|
|
1081
|
+
} else if (minRange.node instanceof EntityProperty) {
|
|
1082
|
+
minRange.setTypeMethods = 'setRelationNamespace';
|
|
1083
|
+
const newValue = setTypeNamespace(minRange.node.relationNamespace, record);
|
|
1084
|
+
minRange.newValue = newValue;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
986
1087
|
if (minRange.node instanceof QueryGroupByExpression && node instanceof Entity) {
|
|
987
1088
|
minRange.setTypeMethods = 'setEntityAsName';
|
|
988
1089
|
}
|
|
@@ -1276,8 +1377,9 @@ const naslServer = {
|
|
|
1276
1377
|
let sourceMap = node.sourceMap;
|
|
1277
1378
|
let fileNode = node;
|
|
1278
1379
|
// 如果没有sourceMap,就继续向上找 ,或者到module结束
|
|
1279
|
-
// 如果 节点找到 app 或者module 停止
|
|
1280
|
-
|
|
1380
|
+
// 如果 节点找到 app 或者module 停止 或者entity找到DataSource为止
|
|
1381
|
+
// 如果当前节点是view就不要向上查找了
|
|
1382
|
+
while (!sourceMap && fileNode && !(fileNode.parentNode instanceof App) && !(fileNode.parentNode instanceof Module) && !(fileNode.parentNode instanceof DataSource) && !(fileNode instanceof View)) {
|
|
1281
1383
|
fileNode = fileNode.parentNode;
|
|
1282
1384
|
sourceMap = fileNode?.sourceMap;
|
|
1283
1385
|
}
|
|
@@ -1523,6 +1625,22 @@ async function incidentalAction(action: string, fileNode: BaseNode, targetNode:
|
|
|
1523
1625
|
}
|
|
1524
1626
|
}
|
|
1525
1627
|
}
|
|
1628
|
+
/**
|
|
1629
|
+
* DataSource只会重命名时候,需要把子集全部重新生成一下
|
|
1630
|
+
*/
|
|
1631
|
+
if (fileNode instanceof DataSource) {
|
|
1632
|
+
(fileNode as DataSource).entities.forEach(async(entity) => {
|
|
1633
|
+
try {
|
|
1634
|
+
const result = entity.toEmbeddedTSFile();
|
|
1635
|
+
const parentPath = oldpath.replace('.ts', '/');
|
|
1636
|
+
const currentOldPath = parentPath + '/entities/' + entity.name + '.ts';
|
|
1637
|
+
// 因为重命名这里只有当前修改父级的 旧名称, 所以他的子集也要根据旧名称去查依赖 更新内容
|
|
1638
|
+
await handleRename(entity, entity, result, currentOldPath);
|
|
1639
|
+
} catch (err) {
|
|
1640
|
+
console.log(err);
|
|
1641
|
+
}
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1526
1644
|
}
|
|
1527
1645
|
}
|
|
1528
1646
|
|
|
@@ -3,8 +3,8 @@ import { genLaunchProcess, genUserTaskLogic } from './getProcesses';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 给调用逻辑用
|
|
6
|
-
* @param process
|
|
7
|
-
* @returns
|
|
6
|
+
* @param process
|
|
7
|
+
* @returns
|
|
8
8
|
*/
|
|
9
9
|
export function process2LogicNamespace(process: Process) {
|
|
10
10
|
const children: Array<Namespace> = [];
|
|
@@ -18,13 +18,13 @@ export function process2LogicNamespace(process: Process) {
|
|
|
18
18
|
});
|
|
19
19
|
// 与process 中 toEmbededTS 所设置的 namespace 相关
|
|
20
20
|
const path = `app.processes.${process.name}.elements.${e.name}.logics`;
|
|
21
|
-
l.getNamespace = function() {
|
|
21
|
+
l.getNamespace = function () {
|
|
22
22
|
return path;
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
24
|
const api = `/api/${process.name}/${e.name}/${l.name}`;
|
|
25
|
-
l.getPath = function() {
|
|
25
|
+
l.getPath = function () {
|
|
26
26
|
return api;
|
|
27
|
-
}
|
|
27
|
+
};
|
|
28
28
|
children.push(ns);
|
|
29
29
|
ns.path = `app.processes.${process.name}.elements.${e.name}`;
|
|
30
30
|
ns.expanded = true;
|
|
@@ -38,12 +38,12 @@ export function process2LogicNamespace(process: Process) {
|
|
|
38
38
|
});
|
|
39
39
|
ns.path = `app.processes.${process.name}.logics`;
|
|
40
40
|
const api = `/api/${process.name}/${launchLogic.name}`;
|
|
41
|
-
launchLogic.getNamespace = function() {
|
|
41
|
+
launchLogic.getNamespace = function () {
|
|
42
42
|
return ns.path;
|
|
43
|
-
}
|
|
44
|
-
launchLogic.getPath = function() {
|
|
43
|
+
};
|
|
44
|
+
launchLogic.getPath = function () {
|
|
45
45
|
return api;
|
|
46
|
-
}
|
|
46
|
+
};
|
|
47
47
|
return ns;
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -61,8 +61,8 @@ interface processTreeFragment {
|
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* 给侧边栏树形用
|
|
64
|
-
* @param process
|
|
65
|
-
* @returns
|
|
64
|
+
* @param process
|
|
65
|
+
* @returns
|
|
66
66
|
*/
|
|
67
67
|
export function processToTreeFragment(process: Process) {
|
|
68
68
|
const fragment: processTreeFragment = {
|
|
@@ -71,28 +71,38 @@ export function processToTreeFragment(process: Process) {
|
|
|
71
71
|
id: process.id,
|
|
72
72
|
logics: [],
|
|
73
73
|
elements: [],
|
|
74
|
-
}
|
|
74
|
+
};
|
|
75
75
|
process.elements.forEach((e) => {
|
|
76
76
|
if (e.type === 'UserTask') {
|
|
77
77
|
const l = genUserTaskLogic(e);
|
|
78
|
-
l.parentKey = 'readonly'
|
|
79
|
-
l.params.forEach(p => {
|
|
78
|
+
l.parentKey = 'readonly';
|
|
79
|
+
l.params.forEach((p) => {
|
|
80
80
|
p.readonly = true;
|
|
81
|
-
})
|
|
81
|
+
});
|
|
82
82
|
l.parentNode = process;
|
|
83
|
+
// 与process 中 toEmbededTS 所设置的 namespace 相关
|
|
84
|
+
const path = `app.processes.${process.name}.elements.${e.name}.logics`;
|
|
85
|
+
l.getNamespace = function () {
|
|
86
|
+
return path;
|
|
87
|
+
};
|
|
83
88
|
fragment.elements.push({
|
|
84
89
|
level: 'processTreeElementFragment',
|
|
85
90
|
id: e.id,
|
|
86
91
|
name: e.name,
|
|
87
92
|
logics: [l],
|
|
88
|
-
})
|
|
93
|
+
});
|
|
89
94
|
}
|
|
90
95
|
});
|
|
91
96
|
|
|
92
97
|
const launchLogic = genLaunchProcess(process);
|
|
93
98
|
launchLogic.parentNode = process;
|
|
94
|
-
|
|
99
|
+
|
|
100
|
+
const path = `app.processes.${process.name}.logics`;
|
|
101
|
+
launchLogic.getNamespace = function () {
|
|
102
|
+
return path;
|
|
103
|
+
};
|
|
104
|
+
|
|
95
105
|
fragment.logics.push(launchLogic);
|
|
96
|
-
launchLogic.parentKey = 'readonly'
|
|
106
|
+
launchLogic.parentKey = 'readonly';
|
|
97
107
|
return fragment;
|
|
98
108
|
}
|
package/src/server/translator.ts
CHANGED
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
ForEachStatement,
|
|
42
42
|
CallFunction,
|
|
43
43
|
ProcessOutcome,
|
|
44
|
+
Function,
|
|
44
45
|
} from '../concepts';
|
|
45
46
|
import { SourceMapItem } from '../translator';
|
|
46
47
|
import { Diagnostic } from '../manager/diagnostic';
|
|
@@ -226,6 +227,10 @@ const TS_RULES: Array<{
|
|
|
226
227
|
re: /No value exists in scope for the shorthand property '__(?:IDENTIFIER|LEFT|RIGHT)__'. Either declare one or provide an initializer./,
|
|
227
228
|
result: '用户任务未关联页面',
|
|
228
229
|
},
|
|
230
|
+
{
|
|
231
|
+
re: /No value exists in scope for the shorthand property '__(?:outOfProcess)__'. Either declare one or provide an initializer./,
|
|
232
|
+
result: '节点未关联到流程图',
|
|
233
|
+
},
|
|
229
234
|
{
|
|
230
235
|
re: /'(.+?)' is declared but its value is never read/,
|
|
231
236
|
result: "已添加'$1',但从来没有使用过。",
|
|
@@ -363,6 +368,22 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
|
|
|
363
368
|
if (node instanceof BindEvent) {
|
|
364
369
|
return null;
|
|
365
370
|
}
|
|
371
|
+
|
|
372
|
+
if (node instanceof ProcessElement && (node.type === 'UserTask' || node.type === 'AutoTask')) {
|
|
373
|
+
let u = '用户任务';
|
|
374
|
+
if(node.type === 'AutoTask') {
|
|
375
|
+
u = '自动任务';
|
|
376
|
+
}
|
|
377
|
+
tsErrorDetail.message = `${u}出口顺序流个数不能大于1`;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (node instanceof ProcessElement && (node.type === 'ExclusiveGateway' || node.type === 'ParallelGateway')) {
|
|
381
|
+
let u = '排他网关';
|
|
382
|
+
if(node.type === 'ParallelGateway') {
|
|
383
|
+
u = '并行网关';
|
|
384
|
+
}
|
|
385
|
+
tsErrorDetail.message = `${u}出口顺序流个数不能小于2`;
|
|
386
|
+
}
|
|
366
387
|
}
|
|
367
388
|
|
|
368
389
|
// 因为缺少参数时候有可能有特殊情况,因为原本少的多了就会找到 callLogic上,
|
|
@@ -427,7 +448,7 @@ export function naslNodeTranslateMessage(minRange: MinRange, tsErrorDetail: Diag
|
|
|
427
448
|
tsErrorDetail.message = '调用函数:参数不能为空!';
|
|
428
449
|
} else if ((node instanceof Argument && node.parentNode instanceof CallLogic) || node instanceof CallLogic) {
|
|
429
450
|
tsErrorDetail.message = '调用逻辑:参数不能为空!';
|
|
430
|
-
} else if (node instanceof ProcessOutcome) {
|
|
451
|
+
} else if (node instanceof ProcessOutcome || node instanceof Function) {
|
|
431
452
|
tsErrorDetail.message = (node as any).constructor.nodeTitle + ':不能为空!';
|
|
432
453
|
} else if (node instanceof Argument || node instanceof TypeAnnotation) {
|
|
433
454
|
let str = tsErrorDetail.message;
|
|
@@ -103,7 +103,7 @@ async function doAction(app: any, actionItem: any) {
|
|
|
103
103
|
const _path: string = event.originEvent.path;
|
|
104
104
|
const _root = _path.split('.')?.[1] || '';
|
|
105
105
|
if (
|
|
106
|
-
['
|
|
106
|
+
['dataSources', 'processes', 'logics', 'enums', 'structures', 'interfaces', 'interfaceDependencies', 'componentDependencies', 'configuration', 'dependencies'].some((item) =>
|
|
107
107
|
_root.startsWith(item))
|
|
108
108
|
) {
|
|
109
109
|
hasBackEnd = true;
|
|
@@ -392,7 +392,7 @@ export async function loadApp(appId?: string) {
|
|
|
392
392
|
scope: 'pc',
|
|
393
393
|
envs: 'dev,online',
|
|
394
394
|
hasAuth: true,
|
|
395
|
-
|
|
395
|
+
dataSources: [],
|
|
396
396
|
structures: [],
|
|
397
397
|
enums: [],
|
|
398
398
|
logics: [],
|
|
@@ -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 { 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 genCreateFormTemplate(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,7 +40,7 @@ export function genCreateFormTemplate(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);
|
|
@@ -73,7 +74,7 @@ export function genCreateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
|
|
|
73
74
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
74
75
|
const type = namespaceArr.pop();
|
|
75
76
|
if (type === 'enums') {
|
|
76
|
-
formItem += genEnumSelectBlock(
|
|
77
|
+
formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
77
78
|
} else {
|
|
78
79
|
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
|
|
79
80
|
}
|
|
@@ -89,7 +90,8 @@ export function genCreateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
|
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
export function genH5CreateFormTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
92
|
-
const
|
|
93
|
+
const dataSource = entity.parentNode as DataSource;
|
|
94
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
93
95
|
const properties = entity.properties.filter(filterProperty('inForm'));
|
|
94
96
|
|
|
95
97
|
return `<van-form ref="${nameGroup.viewElementMainView}">
|
|
@@ -106,12 +108,12 @@ export function genH5CreateFormTemplate(entity: Entity, nameGroup: NameGroup, se
|
|
|
106
108
|
rules.push('required');
|
|
107
109
|
const rulesStr = rules.join(' | ');
|
|
108
110
|
|
|
109
|
-
let formItem = ` <van-field drole="other"
|
|
111
|
+
let formItem = ` <van-field drole="other" ${required ? ' required' : ''}${rulesStr.length ? ` rules="${rulesStr}"` : ''}>\n`;
|
|
110
112
|
const { typeAnnotation } = property || {};
|
|
111
113
|
const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
|
|
112
114
|
if (property.relationEntity) {
|
|
113
115
|
// 有外键关联
|
|
114
|
-
const relationEntity =
|
|
116
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
115
117
|
if (relationEntity) {
|
|
116
118
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
117
119
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
@@ -147,12 +149,12 @@ export function genH5CreateFormTemplate(entity: Entity, nameGroup: NameGroup, se
|
|
|
147
149
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
148
150
|
const type = namespaceArr.pop();
|
|
149
151
|
if (type === 'enums') {
|
|
150
|
-
formItem += '<template #input>' + genEnumSelectBlock(
|
|
152
|
+
formItem += '<template #input>' + genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true) + '</template>';
|
|
151
153
|
} else {
|
|
152
154
|
formItem += `<template #input><van-fieldinput v-model="${vModel}" placeholder="请输入${property.label || property.name}"></van-fieldinput></template>`;
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
|
-
|
|
157
|
+
formItem += `<template #title><van-text text="${property.label || property.name}"><van-text></template>`;
|
|
156
158
|
formItem += ` </van-field>\n`;
|
|
157
159
|
|
|
158
160
|
formItem = formItem.replace(/>\n<van-input|<\/van-input>/g, '');
|
|
@@ -227,7 +229,8 @@ function genSubmitLogic(createLogic: Logic, nameGroup: NameGroup) {
|
|
|
227
229
|
* @param resolver 实体创建 Action
|
|
228
230
|
*/
|
|
229
231
|
export function genCreateBlock(entity: Entity, view: View) {
|
|
230
|
-
const
|
|
232
|
+
const dataSource = entity.parentNode as DataSource;
|
|
233
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
231
234
|
const ns = entity.ns;
|
|
232
235
|
const createLogic = ns?.logics?.find((logic) => logic.name === `create`);
|
|
233
236
|
|
|
@@ -244,16 +247,16 @@ export function genCreateBlock(entity: Entity, view: View) {
|
|
|
244
247
|
entity.properties.forEach((property) => {
|
|
245
248
|
// 有外键关联
|
|
246
249
|
if (property.relationEntity) {
|
|
247
|
-
const relationEntity =
|
|
250
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
248
251
|
if (relationEntity) {
|
|
249
252
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
250
253
|
if (displayedProperty) {
|
|
251
254
|
const viewElementSelect = view.getViewElementUniqueName('select');
|
|
252
|
-
const selectNameGroup = genUniqueQueryNameGroup(
|
|
255
|
+
const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
|
|
253
256
|
selectNameGroup.viewElementSelect = viewElementSelect;
|
|
254
257
|
selectNameGroupMap.set(relationEntity.name, selectNameGroup);
|
|
255
258
|
const newStructure = genQueryStructure([relationEntity], selectNameGroup);
|
|
256
|
-
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false,
|
|
259
|
+
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, module);
|
|
257
260
|
newStructures.push(newStructure);
|
|
258
261
|
newLogics.push(newLogic);
|
|
259
262
|
newLoadSelectLogics.push(genLoadSelectLogic(relationEntity, selectNameGroup, newLogic));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 3. 先简单做后续在看如何优化
|
|
5
5
|
*/
|
|
6
6
|
import * as utils from '../utils';
|
|
7
|
-
import { App, Namespace, Entity, View, Enum } from '../concepts';
|
|
7
|
+
import { App, Module, Namespace, Entity, View, Enum, DataSource } from '../concepts';
|
|
8
8
|
import { NaslCoreTypeAnnotation, NaslUITypeAnnotation, NaslTypeAnnotation, NaslLogicItem, NaslNode } from './utils';
|
|
9
9
|
import {
|
|
10
10
|
filterProperty,
|
|
@@ -25,7 +25,8 @@ import {
|
|
|
25
25
|
} from '.';
|
|
26
26
|
|
|
27
27
|
function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
28
|
-
const
|
|
28
|
+
const dataSource = entity.parentNode as DataSource;
|
|
29
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
29
30
|
const properties = entity.properties.filter(filterProperty('inFilter'));
|
|
30
31
|
|
|
31
32
|
return `
|
|
@@ -41,7 +42,7 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
41
42
|
const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
|
|
42
43
|
if (property.relationEntity) {
|
|
43
44
|
// 有外键关联
|
|
44
|
-
const relationEntity =
|
|
45
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
45
46
|
if (relationEntity) {
|
|
46
47
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
47
48
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
@@ -80,7 +81,7 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
80
81
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
81
82
|
const type = namespaceArr.pop();
|
|
82
83
|
if (type === 'enums') {
|
|
83
|
-
formItem += genEnumSelectBlock(
|
|
84
|
+
formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
84
85
|
} else {
|
|
85
86
|
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
|
|
86
87
|
}
|
|
@@ -102,7 +103,8 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
105
|
-
const
|
|
106
|
+
const dataSource = entity.parentNode as DataSource;
|
|
107
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
106
108
|
const properties = entity.properties.filter(filterProperty('inForm'));
|
|
107
109
|
|
|
108
110
|
return `
|
|
@@ -136,7 +138,7 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
136
138
|
const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
|
|
137
139
|
if (property.relationEntity) {
|
|
138
140
|
// 有外键关联
|
|
139
|
-
const relationEntity =
|
|
141
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
140
142
|
if (relationEntity) {
|
|
141
143
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
142
144
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
@@ -174,7 +176,7 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
174
176
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
175
177
|
const type = namespaceArr.pop();
|
|
176
178
|
if (type === 'enums') {
|
|
177
|
-
formItem += genEnumSelectBlock(
|
|
179
|
+
formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
178
180
|
} else {
|
|
179
181
|
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
|
|
180
182
|
}
|
|
@@ -332,10 +334,11 @@ function genSubmitLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
332
334
|
}
|
|
333
335
|
|
|
334
336
|
export function genCurdEditMultipleKeyBlock(entity: Entity, view: View) {
|
|
335
|
-
const
|
|
337
|
+
const dataSource = entity.parentNode as DataSource;
|
|
338
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
336
339
|
|
|
337
340
|
const viewElementMainView = view.getViewElementUniqueName('tableView');
|
|
338
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
341
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
|
|
339
342
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
340
343
|
nameGroup.viewElementSaveModal = view.getViewElementUniqueName('saveModal');
|
|
341
344
|
nameGroup.viewElementSaveModalForm = view.getViewElementUniqueName('saveModalForm');
|
|
@@ -358,17 +361,17 @@ export function genCurdEditMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
358
361
|
entity.properties.forEach((property) => {
|
|
359
362
|
// 有外键关联
|
|
360
363
|
if (property.relationEntity) {
|
|
361
|
-
const relationEntity =
|
|
364
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
362
365
|
if (relationEntity) {
|
|
363
366
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
364
367
|
if (displayedProperty) {
|
|
365
368
|
allEntities.push(relationEntity);
|
|
366
369
|
const viewElementSelect = view.getViewElementUniqueName('select');
|
|
367
|
-
const selectNameGroup = genUniqueQueryNameGroup(
|
|
370
|
+
const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
|
|
368
371
|
selectNameGroup.viewElementSelect = viewElementSelect;
|
|
369
372
|
selectNameGroupMap.set(relationEntity.name, selectNameGroup);
|
|
370
373
|
const newStructure = genQueryStructure([relationEntity], selectNameGroup);
|
|
371
|
-
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false,
|
|
374
|
+
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, module);
|
|
372
375
|
newStructures.push(newStructure);
|
|
373
376
|
newLogics.push(newLogic);
|
|
374
377
|
newLoadSelectLogics.push(genLoadSelectLogic(relationEntity, selectNameGroup, newLogic));
|
|
@@ -378,7 +381,7 @@ export function genCurdEditMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
378
381
|
});
|
|
379
382
|
const entityStructure = genEditQueryStructure(allEntities, nameGroup);
|
|
380
383
|
newStructures.push(entityStructure);
|
|
381
|
-
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true,
|
|
384
|
+
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true, module);
|
|
382
385
|
newLogics.push(entityLogic);
|
|
383
386
|
|
|
384
387
|
// console.log(entityStructure);
|