@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
|
@@ -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,
|
|
@@ -83,8 +83,8 @@ export function genTableTemplate(entity: Entity, nameGroup: NameGroup, modifyabl
|
|
|
83
83
|
* @param entity 实体
|
|
84
84
|
*/
|
|
85
85
|
export function genTableLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic: any, supportFilter: boolean) {
|
|
86
|
-
const
|
|
87
|
-
const
|
|
86
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
87
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
88
88
|
const params = [
|
|
89
89
|
genLogicParam(`${newLogic.params[0].name}`, 'params.page'),
|
|
90
90
|
genLogicParam(`${newLogic.params[1].name}`, 'params.size'),
|
|
@@ -108,7 +108,7 @@ export function genTableLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic
|
|
|
108
108
|
name: 'result',
|
|
109
109
|
typeAnnotation: NaslCollectionTypeAnnotation.PageOf([
|
|
110
110
|
NaslTypeAnnotation.Reference({
|
|
111
|
-
typeNamespace: `${
|
|
111
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
112
112
|
typeName: nameGroup.structure,
|
|
113
113
|
}),
|
|
114
114
|
]),
|
|
@@ -122,7 +122,7 @@ export function genTableLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic
|
|
|
122
122
|
name: 'result',
|
|
123
123
|
}),
|
|
124
124
|
right: NaslLogicItem.CallLogic({
|
|
125
|
-
calleeNamespace: `${
|
|
125
|
+
calleeNamespace: `${moduleNamespace}.logics`,
|
|
126
126
|
calleeName: newLogic.name,
|
|
127
127
|
arguments: params,
|
|
128
128
|
}),
|
|
@@ -138,8 +138,8 @@ export function genTableLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic
|
|
|
138
138
|
*/
|
|
139
139
|
export function genTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
140
140
|
const lowerEntityName = utils.firstLowerCase(entity.name);
|
|
141
|
-
const
|
|
142
|
-
const
|
|
141
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
142
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
143
143
|
const ns = entity.ns;
|
|
144
144
|
const deleteLogic = ns?.logics?.find((logic) => logic.name === 'delete');
|
|
145
145
|
const idPropertys = entity.properties.filter((property) => property.primaryKey);
|
|
@@ -154,7 +154,7 @@ export function genTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
154
154
|
name: 'scope',
|
|
155
155
|
typeAnnotation: NaslUITypeAnnotation.ScopeOf([
|
|
156
156
|
NaslTypeAnnotation.Reference({
|
|
157
|
-
typeNamespace: `${
|
|
157
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
158
158
|
typeName: nameGroup.structure,
|
|
159
159
|
}),
|
|
160
160
|
]),
|
|
@@ -192,10 +192,11 @@ export function genTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
192
192
|
* load_select_student -> load_someView_select_student
|
|
193
193
|
*/
|
|
194
194
|
export function genTableBlock(entity: Entity, view: View) {
|
|
195
|
-
const
|
|
195
|
+
const dataSource = entity.parentNode as DataSource;
|
|
196
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
196
197
|
|
|
197
198
|
const viewElementMainView = view.getViewElementUniqueName('tableView');
|
|
198
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
199
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
|
|
199
200
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
200
201
|
nameGroup.viewVariableEntity = view.getVariableUniqueName(utils.firstLowerCase(entity.name));
|
|
201
202
|
nameGroup.viewLogicRemove = view.getLogicUniqueName('remove');
|
|
@@ -207,7 +208,7 @@ export function genTableBlock(entity: Entity, view: View) {
|
|
|
207
208
|
entity.properties.forEach((property) => {
|
|
208
209
|
if (property.relationEntity) {
|
|
209
210
|
// 有外键关联
|
|
210
|
-
const relationEntity =
|
|
211
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
211
212
|
if (relationEntity) {
|
|
212
213
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
213
214
|
if (displayedProperty)
|
|
@@ -217,7 +218,7 @@ export function genTableBlock(entity: Entity, view: View) {
|
|
|
217
218
|
});
|
|
218
219
|
const entityStructure = genQueryStructure(allEntities, nameGroup);
|
|
219
220
|
newStructures.push(entityStructure);
|
|
220
|
-
const entityLogic = genQueryLogic(allEntities, nameGroup, false, true,
|
|
221
|
+
const entityLogic = genQueryLogic(allEntities, nameGroup, false, true, module);
|
|
221
222
|
newLogics.push(entityLogic);
|
|
222
223
|
|
|
223
224
|
return `
|
|
@@ -240,10 +241,11 @@ export function genTableBlock(entity: Entity, view: View) {
|
|
|
240
241
|
|
|
241
242
|
export function genTableColumnBlock(property: EntityProperty, view: View) {
|
|
242
243
|
const entity = property.entity;
|
|
243
|
-
const
|
|
244
|
+
const dataSource = entity.parentNode as DataSource;
|
|
245
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
244
246
|
|
|
245
247
|
const viewElementMainView = view.getViewElementUniqueName('tableView');
|
|
246
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
248
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
|
|
247
249
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
248
250
|
nameGroup.viewVariableEntity = view.getVariableUniqueName(utils.firstLowerCase(entity.name));
|
|
249
251
|
nameGroup.viewLogicRemove = view.getLogicUniqueName('remove');
|
|
@@ -256,7 +258,7 @@ export function genTableColumnBlock(property: EntityProperty, view: View) {
|
|
|
256
258
|
properties.forEach((property) => {
|
|
257
259
|
if (property.relationEntity) {
|
|
258
260
|
// 有外键关联
|
|
259
|
-
const relationEntity =
|
|
261
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
260
262
|
if (relationEntity) {
|
|
261
263
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
262
264
|
if (displayedProperty)
|
|
@@ -267,7 +269,7 @@ export function genTableColumnBlock(property: EntityProperty, view: View) {
|
|
|
267
269
|
|
|
268
270
|
const entityStructure = genQueryStructure(allEntities, nameGroup);
|
|
269
271
|
newStructures.push(entityStructure);
|
|
270
|
-
const entityLogic = genQueryLogic(allEntities, nameGroup, false, true,
|
|
272
|
+
const entityLogic = genQueryLogic(allEntities, nameGroup, false, true, module);
|
|
271
273
|
newLogics.push(entityLogic);
|
|
272
274
|
|
|
273
275
|
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,7 +40,7 @@ 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);
|
|
@@ -73,7 +74,7 @@ export function genUpdateFormTemplate(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
|
}
|
|
@@ -90,7 +91,8 @@ export function genUpdateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
export function genH5UpdateFormTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
93
|
-
const
|
|
94
|
+
const dataSource = entity.parentNode as DataSource;
|
|
95
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
94
96
|
const properties = entity.properties.filter(filterProperty('inForm'));
|
|
95
97
|
|
|
96
98
|
return `<van-form ref="${nameGroup.viewElementMainView}">
|
|
@@ -107,13 +109,13 @@ export function genH5UpdateFormTemplate(entity: Entity, nameGroup: NameGroup, se
|
|
|
107
109
|
rules.push('required');
|
|
108
110
|
const rulesStr = rules.join(' | ');
|
|
109
111
|
|
|
110
|
-
let formItem = ` <van-field drole="other"
|
|
112
|
+
let formItem = ` <van-field drole="other" ${required ? ' required' : ''}${rulesStr.length ? ` rules="${rulesStr}"` : ''}>\n`;
|
|
111
113
|
|
|
112
114
|
const { typeAnnotation } = property || {};
|
|
113
115
|
const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
|
|
114
116
|
if (property.relationEntity) {
|
|
115
117
|
// 有外键关联
|
|
116
|
-
const relationEntity =
|
|
118
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
117
119
|
if (relationEntity) {
|
|
118
120
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
119
121
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
@@ -150,12 +152,13 @@ export function genH5UpdateFormTemplate(entity: Entity, nameGroup: NameGroup, se
|
|
|
150
152
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
151
153
|
const type = namespaceArr.pop();
|
|
152
154
|
if (type === 'enums') {
|
|
153
|
-
formItem += '<template #input>' + genEnumSelectBlock(
|
|
155
|
+
formItem += '<template #input>' + genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true) + '</template>';
|
|
154
156
|
} else {
|
|
155
157
|
formItem += `<template #input><van-fieldinput v-model="${vModel}" placeholder="请输入${label}"></van-fieldinput></template>`;
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
160
|
|
|
161
|
+
formItem += `<template #title><van-text text="${label}"><van-text></template>`;
|
|
159
162
|
formItem += ` </van-field>\n`;
|
|
160
163
|
|
|
161
164
|
formItem = formItem.replace(/>\n<van-input|<\/van-input>/g, '');
|
|
@@ -251,7 +254,8 @@ function genLoadLogic(getLogic: Logic, nameGroup: NameGroup) {
|
|
|
251
254
|
}
|
|
252
255
|
|
|
253
256
|
export function genUpdateBlock(entity: Entity, view: View) {
|
|
254
|
-
const
|
|
257
|
+
const dataSource = entity.parentNode as DataSource;
|
|
258
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
255
259
|
const ns = entity.ns;
|
|
256
260
|
const getLogic = ns?.logics?.find((logic) => logic.name === `get`);
|
|
257
261
|
const updateLogic = ns?.logics?.find((logic) => logic.name === `update`);
|
|
@@ -271,16 +275,16 @@ export function genUpdateBlock(entity: Entity, view: View) {
|
|
|
271
275
|
entity.properties.forEach((property) => {
|
|
272
276
|
// 有外键关联
|
|
273
277
|
if (property.relationEntity) {
|
|
274
|
-
const relationEntity =
|
|
278
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
275
279
|
if (relationEntity) {
|
|
276
280
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
277
281
|
if (displayedProperty) {
|
|
278
282
|
const viewElementSelect = view.getViewElementUniqueName('select');
|
|
279
|
-
const selectNameGroup = genUniqueQueryNameGroup(
|
|
283
|
+
const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
|
|
280
284
|
selectNameGroup.viewElementSelect = viewElementSelect;
|
|
281
285
|
selectNameGroupMap.set(relationEntity.name, selectNameGroup);
|
|
282
286
|
const newStructure = genQueryStructure([relationEntity], selectNameGroup);
|
|
283
|
-
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false,
|
|
287
|
+
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, module);
|
|
284
288
|
newStructures.push(newStructure);
|
|
285
289
|
newLogics.push(newLogic);
|
|
286
290
|
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,40 @@ 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
|
+
|
|
8
40
|
export function getGlobalEnv() {
|
|
9
41
|
return typeof window !== 'undefined' ? (window as any).appInfo.env : (global as any).appInfoEnv;
|
|
10
42
|
}
|