@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,28 +1,76 @@
|
|
|
1
1
|
import { BaseNode } from '../../common/BaseNode';
|
|
2
2
|
import { getConceptConstructor, getConceptMeta } from '../../decorators/index';
|
|
3
|
-
import { firstUpperCase } from '../../utils/string';
|
|
3
|
+
import { firstUpperCase, unique } from '../../utils/string';
|
|
4
4
|
|
|
5
5
|
function instanceOfBaseNode(item) {
|
|
6
6
|
return (item instanceof BaseNode);
|
|
7
7
|
}
|
|
8
|
-
const ops = {
|
|
8
|
+
export const ops = {
|
|
9
9
|
_set(item, propertyName, value, callback) {
|
|
10
|
-
if(instanceOfBaseNode(value)) {
|
|
10
|
+
if (instanceOfBaseNode(value)) {
|
|
11
11
|
value.parentNode = item;
|
|
12
12
|
value.parentKey = propertyName;
|
|
13
13
|
}
|
|
14
|
-
if(item[propertyName] !== value) {
|
|
14
|
+
if (item[propertyName] !== value) {
|
|
15
15
|
item.update({
|
|
16
16
|
[propertyName]: value,
|
|
17
17
|
});
|
|
18
|
-
|
|
19
|
-
if(instanceOfBaseNode(value) && callback) {
|
|
18
|
+
|
|
19
|
+
if (instanceOfBaseNode(value) && callback) {
|
|
20
20
|
callback(item[propertyName]);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
_push(item, propertyName, value) {
|
|
25
|
-
if(
|
|
25
|
+
if (propertyName === 'dataSources' && value.concept === 'DataSource') {
|
|
26
|
+
// 合并策略
|
|
27
|
+
const exsitDataSource = item.dataSources.find((d) => d.name === value.name);
|
|
28
|
+
if (exsitDataSource) {
|
|
29
|
+
const nameSet = new Set(exsitDataSource.getEntityExistingNames());
|
|
30
|
+
value.entities.forEach((e) => {
|
|
31
|
+
const n = unique(e.name, nameSet, 1, true);
|
|
32
|
+
nameSet.add(n);
|
|
33
|
+
e.update({
|
|
34
|
+
name: n,
|
|
35
|
+
});
|
|
36
|
+
e.parentNode = exsitDataSource;
|
|
37
|
+
exsitDataSource.entities.push(e);
|
|
38
|
+
const index = exsitDataSource.entities.length;
|
|
39
|
+
e.create({
|
|
40
|
+
index,
|
|
41
|
+
parentNode: exsitDataSource,
|
|
42
|
+
parentKey: 'entities',
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
} else {
|
|
47
|
+
const dataSourceGroup = item.configuration?.getGroup('dataSource');
|
|
48
|
+
dataSourceGroup.addConfigProperty({
|
|
49
|
+
name: value.name,
|
|
50
|
+
description: '',
|
|
51
|
+
values: [
|
|
52
|
+
{ env: 'dev', value: '', concept: 'ConfigPropertyValue' },
|
|
53
|
+
{ env: 'online', value: '', concept: 'ConfigPropertyValue' },
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (item.concept === 'App' && propertyName === 'entities' && value.concept === 'Entity') {
|
|
59
|
+
// 兼容 2.11之前无 datasource 模板
|
|
60
|
+
const defaultDS = item.dataSources.find((d) => d.name === 'defaultDS');
|
|
61
|
+
// defaultDS.addEntity(value);
|
|
62
|
+
value.parentNode = defaultDS;
|
|
63
|
+
value.parentKey = 'entities';
|
|
64
|
+
defaultDS.entities.push(value);
|
|
65
|
+
const index = defaultDS.entities.length;
|
|
66
|
+
value.create({
|
|
67
|
+
index,
|
|
68
|
+
parentNode: defaultDS,
|
|
69
|
+
parentKey: 'entities',
|
|
70
|
+
});
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!item[propertyName]) {
|
|
26
74
|
item[propertyName] = [];
|
|
27
75
|
}
|
|
28
76
|
value.parentNode = item;
|
|
@@ -39,10 +87,10 @@ const ops = {
|
|
|
39
87
|
const _ctor = getConceptConstructor(concept);
|
|
40
88
|
const item = new _ctor();
|
|
41
89
|
const { propertyMap } = getConceptMeta(concept);
|
|
42
|
-
for(const p of propertyMap) {
|
|
90
|
+
for (const p of propertyMap) {
|
|
43
91
|
const [propertyName] = p;
|
|
44
92
|
const t = item[propertyName];
|
|
45
|
-
if(Array.isArray(t)) {
|
|
93
|
+
if (Array.isArray(t)) {
|
|
46
94
|
ops._set(item, propertyName, []);
|
|
47
95
|
}
|
|
48
96
|
}
|
|
@@ -50,14 +98,63 @@ const ops = {
|
|
|
50
98
|
},
|
|
51
99
|
_addModule(app, name, belongs, data) {
|
|
52
100
|
const ms = app[belongs];
|
|
53
|
-
const exist = ms.find(m => m.name === name);
|
|
54
|
-
if(!exist) {
|
|
55
|
-
app[
|
|
101
|
+
const exist = ms.find((m) => m.name === name);
|
|
102
|
+
if (!exist) {
|
|
103
|
+
app['addModuleIn' + firstUpperCase(belongs)](data);
|
|
56
104
|
}
|
|
57
105
|
},
|
|
58
|
-
_bindRoles(){
|
|
59
|
-
return Array.prototype.map.call(arguments, r => r.name);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
106
|
+
_bindRoles() {
|
|
107
|
+
return Array.prototype.map.call(arguments, (r) => r.name);
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
//组件模板的导入有些不同
|
|
111
|
+
let handleDatas = [];
|
|
112
|
+
let dynamicNames = {};
|
|
113
|
+
export const ComponentOps = {
|
|
114
|
+
...ops,
|
|
115
|
+
_set(item, propertyName, value, callback) {
|
|
116
|
+
if (instanceOfBaseNode(value)) {
|
|
117
|
+
value.parentNode = item;
|
|
118
|
+
value.parentKey = propertyName;
|
|
119
|
+
}
|
|
120
|
+
if (item[propertyName] !== value) {
|
|
121
|
+
//指view的全局逻辑或全局变量名称修改
|
|
122
|
+
if (propertyName === 'name' && dynamicNames[item.name]) {
|
|
123
|
+
dynamicNames[item.name] = value;
|
|
124
|
+
}
|
|
125
|
+
item.update({
|
|
126
|
+
[propertyName]: value,
|
|
127
|
+
});
|
|
128
|
+
//有函数或者组件引用了view的全局逻辑或全局变量名称
|
|
129
|
+
if ((propertyName === 'name' || propertyName === 'calleeName') && dynamicNames[value]
|
|
130
|
+
&& item.parentKey !== 'property' && item.concept !== 'StructureProperty') {
|
|
131
|
+
handleDatas.push({
|
|
132
|
+
item,
|
|
133
|
+
propertyName,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (instanceOfBaseNode(value) && callback) {
|
|
138
|
+
callback(item[propertyName]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
_rename() {
|
|
143
|
+
handleDatas.forEach(({ item, propertyName }) => {
|
|
144
|
+
const changeName = item[propertyName];
|
|
145
|
+
if (dynamicNames[changeName] && changeName !== dynamicNames[changeName])
|
|
146
|
+
item.update({
|
|
147
|
+
[propertyName]: dynamicNames[changeName],
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
handleDatas = [];
|
|
151
|
+
dynamicNames = {};
|
|
152
|
+
},
|
|
153
|
+
_startNames(...initialNames) {
|
|
154
|
+
initialNames.forEach((name) => {
|
|
155
|
+
dynamicNames[name] = name;
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
};
|
|
62
159
|
|
|
63
|
-
export default ops;
|
|
160
|
+
export default ops;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { unique } from '../../utils/string';
|
|
2
|
-
class uniqueName {
|
|
2
|
+
export class uniqueName {
|
|
3
3
|
NamesWeakMap = new Map();
|
|
4
4
|
initAppUniqueNames(app) {
|
|
5
5
|
const NamesWeakMap = this.NamesWeakMap;
|
|
6
|
-
|
|
6
|
+
const defaultDS = app.dataSources.find(d => d.name === 'defaultDS');
|
|
7
|
+
NamesWeakMap.set('defaultDS', new Set(defaultDS.getEntityExistingNames()));
|
|
8
|
+
|
|
9
|
+
// NamesWeakMap.set('DataSource', new Set(app.getDataSourceExistingNames()));
|
|
7
10
|
NamesWeakMap.set('Structure', new Set(app.getStructureExistingNames()));
|
|
8
11
|
NamesWeakMap.set('Enum', new Set(app.getEnumExistingNames()));
|
|
9
12
|
NamesWeakMap.set('Logic', new Set(app.getLogicExistingNames()));
|
|
@@ -15,22 +18,87 @@ class uniqueName {
|
|
|
15
18
|
getGenUniqNameFunctionName(item, concept) {
|
|
16
19
|
const p = item.parentNode;
|
|
17
20
|
const NamesWeakMap = this.NamesWeakMap;
|
|
18
|
-
if(!p) {
|
|
21
|
+
if (!p) {
|
|
22
|
+
// 添加至顶层 App 的对象
|
|
23
|
+
if(concept === 'DataSource') {
|
|
24
|
+
return item.name;
|
|
25
|
+
}
|
|
26
|
+
if(concept === 'Entity') {
|
|
27
|
+
// Entity 是为了兼容 2.11 及之前的模板
|
|
28
|
+
concept = 'defaultDS';
|
|
29
|
+
}
|
|
30
|
+
const nameSet = NamesWeakMap.get(concept);
|
|
31
|
+
const n = unique(item.name, nameSet, 1, true);
|
|
32
|
+
nameSet.add(n);
|
|
33
|
+
return n;
|
|
34
|
+
}
|
|
35
|
+
const f1 = p['get' + concept + 'UniqueName'];
|
|
36
|
+
const f2 = p['get' + concept + 'ExistingNames'];
|
|
37
|
+
if (f1 && f2) {
|
|
38
|
+
const names = f2.call(p);
|
|
39
|
+
const t = names.filter((n) => n === item.name);
|
|
40
|
+
if (t.length > 1) {
|
|
41
|
+
return f1.call(p, item.name);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return item.name;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class componentUniqueName {
|
|
49
|
+
NamesWeakMap = new Map();
|
|
50
|
+
view = null;
|
|
51
|
+
initAppUniqueNames(app, view) {
|
|
52
|
+
const NamesWeakMap = this.NamesWeakMap;
|
|
53
|
+
this.view = view;
|
|
54
|
+
NamesWeakMap.set('DataSource', new Set(app.getDataSourceExistingNames()));
|
|
55
|
+
NamesWeakMap.set('Structure', new Set(app.getStructureExistingNames()));
|
|
56
|
+
NamesWeakMap.set('Enum', new Set(app.getEnumExistingNames()));
|
|
57
|
+
NamesWeakMap.set('Logic', new Set(app.getLogicExistingNames()));
|
|
58
|
+
NamesWeakMap.set('Interface', new Set(app.getInterfaceExistingNames()));
|
|
59
|
+
NamesWeakMap.set('View', new Set(app.getViewExistingNames()));
|
|
60
|
+
NamesWeakMap.set('Process', new Set(app.getProcessExistingNames()));
|
|
61
|
+
NamesWeakMap.set('Role', new Set(app.getRoleExistingNames()));
|
|
62
|
+
// .... 这里要补一下 view 下面 variable, logics的名字
|
|
63
|
+
NamesWeakMap.set('Variable', new Set(view.getVarExistingNames()));
|
|
64
|
+
NamesWeakMap.set('Logic', new Set(view.getLogicExistingNames()));
|
|
65
|
+
}
|
|
66
|
+
getGenUniqNameFunctionName(item, concept) {
|
|
67
|
+
const p = concept === 'ViewElement' ? this.view : item.parentNode;
|
|
68
|
+
const NamesWeakMap = this.NamesWeakMap;
|
|
69
|
+
if (!p) {
|
|
19
70
|
const nameSet = NamesWeakMap.get(concept);
|
|
20
71
|
const n = unique(item.name, nameSet, 1, true);
|
|
21
72
|
nameSet.add(n);
|
|
22
73
|
return n;
|
|
23
74
|
}
|
|
24
|
-
const f1 = p[
|
|
25
|
-
const f2 = p[
|
|
26
|
-
if(f1 && f2) {
|
|
75
|
+
const f1 = p['get' + concept + 'UniqueName'];
|
|
76
|
+
const f2 = p['get' + concept + 'ExistingNames'];
|
|
77
|
+
if (f1 && f2) {
|
|
27
78
|
const names = f2.call(p);
|
|
28
|
-
const t = names.filter(n => n === item.name);
|
|
29
|
-
if(t.length > 1) {
|
|
79
|
+
const t = names.filter((n) => n === item.name);
|
|
80
|
+
if (t.length > 1) {
|
|
81
|
+
return f1.call(p, item.name);
|
|
82
|
+
}
|
|
83
|
+
if (concept === 'ViewElement' && t.length)
|
|
84
|
+
return f1.call(p, item.name);
|
|
85
|
+
}
|
|
86
|
+
// 逻辑里面的变量也需要再判断
|
|
87
|
+
if (concept === 'Variable' && f1) {
|
|
88
|
+
const variables = p.getVarExistingNames();
|
|
89
|
+
if (Array.isArray(this.view.params)) {
|
|
90
|
+
variables.push(...this.view.params.map((item) => item.name));
|
|
91
|
+
}
|
|
92
|
+
if (Array.isArray(this.view.variables)) {
|
|
93
|
+
variables.push(...this.view.variables.map((item) => item.name));
|
|
94
|
+
}
|
|
95
|
+
const t = variables.filter((n) => n === item.name);
|
|
96
|
+
if (t.length > 1) {
|
|
30
97
|
return f1.call(p, item.name);
|
|
31
98
|
}
|
|
32
99
|
}
|
|
33
100
|
return item.name;
|
|
34
101
|
}
|
|
35
102
|
}
|
|
36
|
-
|
|
103
|
+
|
|
104
|
+
export default uniqueName;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// BaseNode,
|
|
3
3
|
// Module
|
|
4
4
|
// } from '../../concepts';
|
|
5
|
-
import { BaseNode, uiStructures, collectionStructures, interfaceStructures } from '../../concepts';
|
|
5
|
+
import { BaseNode, uiStructures, collectionStructures, interfaceStructures, processStructures } from '../../concepts';
|
|
6
6
|
import { getConceptMeta } from '../../decorators/index';
|
|
7
7
|
/*
|
|
8
8
|
根据 namespace 字符串来获取 node
|
|
@@ -74,12 +74,15 @@ export function getNaslNodeByNodeCallee(namespace, typeName) {
|
|
|
74
74
|
return collectionStructures.find((item) => item.name === typeName);
|
|
75
75
|
} else if (namespace === 'nasl.interface') {
|
|
76
76
|
return interfaceStructures.find((item) => item.name === typeName);
|
|
77
|
+
} else if (namespace === 'nasl.process') {
|
|
78
|
+
return processStructures.find((item) => item.name === typeName);
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
export const TRACK_TYPE = {
|
|
80
82
|
PLAIN: 'plain',
|
|
81
83
|
PROPERTY: 'property',
|
|
82
84
|
ARRAY: 'array',
|
|
85
|
+
ARRAY_NO_FURTHER: 'array_no_further',
|
|
83
86
|
CALLEE: 'callee',
|
|
84
87
|
CALLEE_TEMPLATE: 'callee_template',
|
|
85
88
|
MODULE: 'module',
|
|
@@ -118,6 +121,10 @@ function getRelatedProperyName(nspropertyname) {
|
|
|
118
121
|
return '';
|
|
119
122
|
}
|
|
120
123
|
|
|
124
|
+
const TRACKING_ONLY_ONE_LAYER = [
|
|
125
|
+
'DataSource'
|
|
126
|
+
]
|
|
127
|
+
|
|
121
128
|
const BACKTRACKING_IGNORE_NAMESPACE = [
|
|
122
129
|
'nasl.core',
|
|
123
130
|
'',
|
|
@@ -154,7 +161,6 @@ const ROLE_PROPERTY = 'bindRoles';
|
|
|
154
161
|
|
|
155
162
|
export function tracking(node, startNode, callback) {
|
|
156
163
|
const { propertyMap } = getConceptMeta(node.concept);
|
|
157
|
-
// console.log(propertyMap)
|
|
158
164
|
for (const p of propertyMap) {
|
|
159
165
|
// console.log(p)
|
|
160
166
|
const [propertyName, _data] = p;
|
|
@@ -166,13 +172,20 @@ export function tracking(node, startNode, callback) {
|
|
|
166
172
|
}
|
|
167
173
|
continue;
|
|
168
174
|
}
|
|
175
|
+
const isOnlyOneLayerTracking = TRACKING_ONLY_ONE_LAYER.includes(node.concept);
|
|
169
176
|
const property = node[propertyName];
|
|
170
177
|
if (Array.isArray(property)) {
|
|
171
178
|
if (property.length > 0) {
|
|
172
179
|
if (property[0] instanceof BaseNode) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
180
|
+
if (!isOnlyOneLayerTracking) {
|
|
181
|
+
property.forEach((p) => {
|
|
182
|
+
callback(TRACK_TYPE.ARRAY, propertyName, p);
|
|
183
|
+
});
|
|
184
|
+
} else {
|
|
185
|
+
property.forEach((p) => {
|
|
186
|
+
callback(TRACK_TYPE.ARRAY_NO_FURTHER, propertyName, p);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
176
189
|
} else {
|
|
177
190
|
if (ROLE_PROPERTY === propertyName) {
|
|
178
191
|
const rootNode = node.rootNode;
|
|
@@ -208,7 +221,7 @@ export function tracking(node, startNode, callback) {
|
|
|
208
221
|
|
|
209
222
|
const rootNode = node.rootNode;
|
|
210
223
|
const ns = node[propertyName];
|
|
211
|
-
if (!ns) {
|
|
224
|
+
if (!ns || !node[relatedPropertyName]) {
|
|
212
225
|
callback(TRACK_TYPE.PLAIN, propertyName, property);
|
|
213
226
|
callback(TRACK_TYPE.PLAIN, relatedPropertyName, node[relatedPropertyName]);
|
|
214
227
|
break;
|
|
@@ -218,71 +231,84 @@ export function tracking(node, startNode, callback) {
|
|
|
218
231
|
callback(TRACK_TYPE.PLAIN, propertyName, property);
|
|
219
232
|
callback(TRACK_TYPE.PLAIN, relatedPropertyName, node[relatedPropertyName]);
|
|
220
233
|
} else {
|
|
221
|
-
const r1 = /app\.(?:entities|processes)\.([^.]+)\.logics/.exec(ns);
|
|
222
|
-
const r2 = /app\.processes\.([^.]+)\.elements\.([^.]+)\.logics/.exec(ns);
|
|
223
234
|
const calleeN = node[relatedPropertyName];
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
235
|
+
|
|
236
|
+
const r1 = /app\.processes\.([^.]+)\.logics/.exec(ns);
|
|
237
|
+
const r2 = /app\.processes\.([^.]+)\.elements\.([^.]+)\.logics/.exec(ns);
|
|
238
|
+
if(r1 || r2) {
|
|
239
|
+
// Process 处理
|
|
240
|
+
if (r2) {
|
|
241
|
+
const nodeName = r2[1];
|
|
242
|
+
const subNodename = r2[2];
|
|
243
|
+
if (subNodename) {
|
|
244
|
+
// 目前只有 userTask
|
|
245
|
+
const process = rootNode.processes.find((p) => p.name === nodeName);
|
|
246
|
+
if (process) {
|
|
247
|
+
const usertask = process.elements.find((e) => e.name === subNodename);
|
|
248
|
+
if (usertask) {
|
|
249
|
+
callback(TRACK_TYPE.CALLEE_TEMPLATE, propertyName, node[propertyName], {
|
|
250
|
+
rootNode: process,
|
|
251
|
+
metaNodes: [process, usertask],
|
|
252
|
+
nstemplate: `function(meta, meta2){ return "app.processes" + meta.name + ".elements." + meta2.name + ".logics"; }`,
|
|
253
|
+
nametemplate: `function(meta, meta2){ return "complete"; }`,
|
|
254
|
+
relatedPropertyName,
|
|
255
|
+
AppPropertyName: 'processes',
|
|
256
|
+
});
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
241
259
|
}
|
|
242
260
|
}
|
|
261
|
+
} else if (r1){
|
|
262
|
+
const nodeName = r1[1];
|
|
263
|
+
const process = rootNode.processes.find((p) => p.name === nodeName);
|
|
264
|
+
if (/launch/.test(calleeN) && process) {
|
|
265
|
+
// const prefix = /(launch|complete).+/.exec(calleeN)[1];
|
|
266
|
+
callback(TRACK_TYPE.CALLEE_TEMPLATE, propertyName, node[propertyName], {
|
|
267
|
+
rootNode: process,
|
|
268
|
+
metaNodes: [process],
|
|
269
|
+
nstemplate: `function(meta){ return "app.processes" + meta.name + ".logics"; }`,
|
|
270
|
+
nametemplate: `function(){ return "${calleeN}"; }`,
|
|
271
|
+
relatedPropertyName,
|
|
272
|
+
AppPropertyName: 'processes',
|
|
273
|
+
});
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
243
276
|
}
|
|
244
|
-
}
|
|
245
|
-
const nodeName = r1[1];
|
|
246
|
-
const process = rootNode.processes.find((p) => p.name === nodeName);
|
|
247
|
-
if (/launch/.test(calleeN) && process) {
|
|
248
|
-
// const prefix = /(launch|complete).+/.exec(calleeN)[1];
|
|
249
|
-
callback(TRACK_TYPE.CALLEE_TEMPLATE, propertyName, node[propertyName], {
|
|
250
|
-
rootNode: process,
|
|
251
|
-
metaNodes: [process],
|
|
252
|
-
nstemplate: `function(meta){ return "app.processes" + meta.name + ".logics"; }`,
|
|
253
|
-
nametemplate: `function(){ return "${calleeN}"; }`,
|
|
254
|
-
relatedPropertyName,
|
|
255
|
-
AppPropertyName: 'processes',
|
|
256
|
-
});
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
277
|
+
}
|
|
259
278
|
|
|
260
|
-
|
|
261
|
-
|
|
279
|
+
const r3 = /app\.dataSources\.([^.]+)\.entities\.([^.]+)\.logics/.exec(ns);
|
|
280
|
+
if(r3) {
|
|
281
|
+
const datasourceName = r3[1];
|
|
282
|
+
const entityName = r3[2];
|
|
283
|
+
|
|
284
|
+
if (/get|create|update|delete|batchCreate|batchUpdate|batchDelete|import/.test(calleeN)) {
|
|
262
285
|
// const prefix = /(get|create|update|delete|batchCreate|batchUpdate|batchDelete|import)/.exec(calleeN)[1];
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (calleeNode) {
|
|
277
|
-
backtracking({
|
|
278
|
-
node,
|
|
279
|
-
startNode,
|
|
280
|
-
calleeNode,
|
|
281
|
-
propertyName,
|
|
282
|
-
relatedPropertyName,
|
|
283
|
-
}, callback);
|
|
286
|
+
const datasource = rootNode.dataSources.find(d => d.name === datasourceName);
|
|
287
|
+
if (datasource) {
|
|
288
|
+
const entity = datasource.entities.find((e) => e.name === entityName);
|
|
289
|
+
callback(TRACK_TYPE.CALLEE_TEMPLATE, propertyName, node[propertyName], {
|
|
290
|
+
rootNode: datasource,
|
|
291
|
+
metaNodes: [datasource, entity],
|
|
292
|
+
nstemplate: `function(meta, meta2){ return "app.dataSources." + meta.name + ".entities." + meta2.name + ".logics"; }`,
|
|
293
|
+
nametemplate: `function(){ return "${calleeN}"; }`,
|
|
294
|
+
relatedPropertyName,
|
|
295
|
+
AppPropertyName: 'dataSources',
|
|
296
|
+
});
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
284
299
|
}
|
|
285
300
|
}
|
|
301
|
+
const nsPath = `${ns}.${calleeN}`;
|
|
302
|
+
const calleeNode = getNodeByNodeCallee(rootNode, nsPath);
|
|
303
|
+
if (calleeNode) {
|
|
304
|
+
backtracking({
|
|
305
|
+
node,
|
|
306
|
+
startNode,
|
|
307
|
+
calleeNode,
|
|
308
|
+
propertyName,
|
|
309
|
+
relatedPropertyName,
|
|
310
|
+
}, callback);
|
|
311
|
+
}
|
|
286
312
|
}
|
|
287
313
|
break;
|
|
288
314
|
|
|
@@ -296,10 +322,11 @@ export function tracking(node, startNode, callback) {
|
|
|
296
322
|
callback(TRACK_TYPE.PROPERTY_TEMPLATE, propertyName, property, {
|
|
297
323
|
getRelatedVar: () => {
|
|
298
324
|
const queryCom = node.getAncestor('CallQueryComponent');
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
325
|
+
const entityNamespace = queryCom?.from?.entityNamespace;
|
|
326
|
+
if (queryCom && entityNamespace && property) {
|
|
327
|
+
const rootNode = queryCom.rootNode;
|
|
328
|
+
const entity = getNodeByNodeCallee(rootNode, `${entityNamespace}.${property}`);
|
|
329
|
+
return entity;
|
|
303
330
|
}
|
|
304
331
|
return null;
|
|
305
332
|
},
|
|
@@ -361,7 +388,7 @@ export function backtracking({ node, startNode, calleeNode, propertyName, relate
|
|
|
361
388
|
while (t) {
|
|
362
389
|
const pnode = t.parentNode;
|
|
363
390
|
if (pnode === approot) {
|
|
364
|
-
AppPropertyName = getAppPropertyName(
|
|
391
|
+
AppPropertyName = getAppPropertyName(t);
|
|
365
392
|
}
|
|
366
393
|
if (pnode !== approot && pnode !== startNode) {
|
|
367
394
|
t = pnode;
|