@lcap/nasl 3.6.0-alpha.1 → 3.6.0-alpha.2
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/bak/translator.js +119 -39
- package/out/bak/translator.js.map +1 -1
- package/out/breakpoint/generator/BreakpointNode.d.ts +3 -0
- package/out/breakpoint/generator/BreakpointNode.js +9 -0
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
- package/out/breakpoint/shared/constants.js +1 -0
- package/out/breakpoint/shared/constants.js.map +1 -1
- package/out/breakpoint/shared/utils.js +12 -6
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/breakpoint/store/core.js +1 -1
- package/out/breakpoint/store/core.js.map +1 -1
- package/out/common/BaseNode.d.ts +1 -4
- package/out/common/BaseNode.js +23 -37
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +6 -1
- package/out/concepts/AnonymousFunction__.js +34 -16
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.d.ts +55 -51
- package/out/concepts/App__.js +76 -80
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +10 -2
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +16 -6
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +1 -0
- package/out/concepts/BindDirective__.js +19 -4
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +3 -1
- package/out/concepts/BindEvent__.js +39 -14
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +641 -0
- package/out/concepts/BusinessComponent__.js +1921 -0
- package/out/concepts/BusinessComponent__.js.map +1 -0
- package/out/concepts/BusinessLogic__.d.ts +38 -0
- package/out/concepts/BusinessLogic__.js +358 -0
- package/out/concepts/BusinessLogic__.js.map +1 -0
- package/out/concepts/CallEvent__.d.ts +101 -0
- package/out/concepts/CallEvent__.js +280 -0
- package/out/concepts/CallEvent__.js.map +1 -0
- package/out/concepts/CallFunction__.d.ts +0 -1
- package/out/concepts/CallFunction__.js +10 -10
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +2 -0
- package/out/concepts/CallLogic__.js +38 -27
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Constant__.js +7 -6
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -1
- package/out/concepts/Destination__.js +7 -5
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +2 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/Event__.d.ts +14 -0
- package/out/concepts/Event__.js +61 -0
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/FrontendType__.d.ts +308 -0
- package/out/concepts/FrontendType__.js +605 -0
- package/out/concepts/FrontendType__.js.map +1 -0
- package/out/concepts/Frontend__.d.ts +0 -88
- package/out/concepts/Frontend__.js +1 -143
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +5 -0
- package/out/concepts/Identifier__.js +19 -9
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +3 -1
- package/out/concepts/Logic__.js +31 -21
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.d.ts +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -1
- package/out/concepts/MemberExpression__.js +3 -3
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/ParamWithGroup__.d.ts +39 -0
- package/out/concepts/ParamWithGroup__.js +85 -0
- package/out/concepts/ParamWithGroup__.js.map +1 -0
- package/out/concepts/Param__.js +11 -3
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +9 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Return__.js +17 -9
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +2 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +17 -8
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +17 -1
- package/out/concepts/ViewElement__.js +145 -16
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +21 -20
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/index__.d.ts +5 -0
- package/out/concepts/index__.js +5 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/concepts/utils/asserts.d.ts +258 -3
- package/out/concepts/utils/asserts.js +351 -13
- package/out/concepts/utils/asserts.js.map +1 -1
- package/out/concepts/utils/types.d.ts +20 -3
- package/out/generator/genBundleFiles.js +25 -11
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.js +12 -3
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.js +3 -3
- package/out/generator/permission.js.map +1 -1
- package/out/natural/transformTSCode.js +1 -1
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/extendBaseNode.js +6 -4
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/getLogics.js +62 -27
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +6 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.js +3 -3
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.js +40 -19
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +6 -1
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +1 -2
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +6 -6
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +16 -16
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +36 -36
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +6 -5
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +12 -12
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +4 -4
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +3 -3
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +10 -10
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +10 -9
- 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/translator/utils.js +12 -1
- package/out/translator/utils.js.map +1 -1
- package/out/utils/i18nInfo.js +7 -2
- package/out/utils/i18nInfo.js.map +1 -1
- package/out/utils/index.d.ts +17 -0
- package/out/utils/index.js +184 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/src/bak/translator.js +121 -43
- package/src/breakpoint/generator/BreakpointNode.ts +12 -0
- package/src/breakpoint/shared/constants.ts +1 -0
- package/src/breakpoint/shared/utils.ts +13 -8
- package/src/breakpoint/store/core.ts +1 -1
- package/src/common/BaseNode.ts +22 -41
- package/src/concepts/AnonymousFunction__.ts +36 -18
- package/src/concepts/App__.ts +129 -130
- package/src/concepts/BackendVariable__.ts +10 -2
- package/src/concepts/BindAttribute__.ts +14 -6
- package/src/concepts/BindDirective__.ts +19 -4
- package/src/concepts/BindEvent__.ts +41 -13
- package/src/concepts/BusinessComponent__.ts +2693 -0
- package/src/concepts/BusinessLogic__.ts +376 -0
- package/src/concepts/CallEvent__.ts +351 -0
- package/src/concepts/CallFunction__.ts +10 -13
- package/src/concepts/CallLogic__.ts +45 -32
- package/src/concepts/Constant__.ts +5 -7
- package/src/concepts/Destination__.ts +7 -5
- package/src/concepts/End__.ts +1 -0
- package/src/concepts/Event__.ts +70 -0
- package/src/concepts/FrontendType__.ts +919 -0
- package/src/concepts/Frontend__.ts +3 -251
- package/src/concepts/Identifier__.ts +29 -13
- package/src/concepts/LogicItem__.ts +1 -0
- package/src/concepts/Logic__.ts +36 -23
- package/src/concepts/MemberExpression__.ts +3 -3
- package/src/concepts/NewComposite__.ts +4 -6
- package/src/concepts/ParamWithGroup__.ts +101 -0
- package/src/concepts/Param__.ts +11 -3
- package/src/concepts/ProcessElement__.ts +8 -1
- package/src/concepts/Return__.ts +15 -12
- package/src/concepts/ValidationRule__.ts +6 -1
- package/src/concepts/Variable__.ts +17 -9
- package/src/concepts/ViewElement__.ts +168 -33
- package/src/concepts/View__.ts +23 -20
- package/src/concepts/index__.ts +5 -0
- package/src/concepts/utils/asserts.ts +367 -4
- package/src/concepts/utils/types.ts +28 -0
- package/src/generator/genBundleFiles.ts +33 -15
- package/src/generator/genReleaseBody.ts +14 -3
- package/src/generator/permission.ts +8 -6
- package/src/natural/transformTSCode.ts +1 -1
- package/src/server/extendBaseNode.ts +22 -20
- package/src/server/getLogics.ts +79 -41
- package/src/server/getMemberIdentifier.ts +7 -1
- package/src/server/getProcesses.ts +3 -3
- package/src/server/naslServer.ts +44 -20
- package/src/server/translator.ts +7 -1
- package/src/service/storage/init.ts +1 -2
- package/src/templator/genCreateBlock.ts +6 -6
- package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -16
- package/src/templator/genCurdMultipleKeyBlock.ts +36 -36
- package/src/templator/genGetBlock.ts +6 -5
- package/src/templator/genGridViewBlock.ts +12 -12
- package/src/templator/genListViewBlock.ts +4 -4
- package/src/templator/genSelectBlock.ts +3 -3
- package/src/templator/genTableBlock.ts +10 -10
- package/src/templator/genUpdateBlock.ts +10 -9
- package/src/templator/utils.ts +2 -2
- package/src/translator/utils.ts +12 -1
- package/src/utils/i18nInfo.ts +7 -2
- package/src/utils/index.ts +211 -1
- package/test/concepts/call-function/fixtures/from-string.json +68 -59
- package/test/concepts/call-function/fixtures/to-string-global-tz.json +67 -58
- package/test/concepts/call-function/fixtures/to-string-no-tz.json +57 -48
- package/test/concepts/call-function/fixtures/to-string-user-tz.json +69 -60
- package/test/concepts/call-function/fixtures/to-string-utc-tz.json +69 -60
- package/test/concepts/call-interface/fixtures/only-interface.json +81 -72
- package/test/concepts/call-interface/fixtures/with-body-complex-argument.json +223 -214
- package/test/concepts/call-interface/fixtures/with-body-no-argument.json +85 -76
- package/test/concepts/call-interface/fixtures/with-body-simple-argument.json +100 -91
- package/test/concepts/call-interface/fixtures/with-headers-no-argument.json +88 -79
- package/test/concepts/call-interface/fixtures/with-headers.json +90 -81
- package/test/concepts/call-interface/fixtures/with-query-no-argument.json +88 -79
- package/test/concepts/call-interface/fixtures/with-query.json +90 -81
- package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +4 -2
- package/test/concepts/call-logic/fixtures/entries-get-with-arguments.json +104 -95
- package/test/concepts/call-logic/fixtures/entries-update-with-arguments.json +209 -200
- package/test/concepts/call-logic/fixtures/global-logic-argument-no-expression.json +97 -88
- package/test/concepts/call-logic/fixtures/global-logic-argument-some-expression.json +124 -115
- package/test/concepts/call-logic/fixtures/json-deserialize.json +120 -111
- package/test/concepts/call-logic/fixtures/json-serialize-with-string.json +124 -115
- package/test/concepts/call-logic/fixtures/json-serialize.json +124 -115
- package/test/concepts/call-logic/fixtures/view-buildin-logic-with-argument.json +91 -82
- package/test/concepts/call-logic/fixtures/view-component-logic-no-argument.json +88 -79
- package/test/concepts/call-logic/fixtures/view-component-with-validation.json +144 -135
- package/test/concepts/identifier/fixtures/view-variable.json +145 -136
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +1 -1
- package/test/concepts/view-element/fixtures/default-login.json +221 -212
- package/test/concepts/view-element/fixtures/default-not-found.json +183 -174
- package/test/concepts/view-element/fixtures/with-role-auth.json +91 -82
- package/test/concepts/view-element/fixtures/with-table.json +1894 -1885
- package/test/concepts/view-element/toVue.spec.ts +1 -0
- package/ts-worker/package.json +1 -1
- package/ts-worker/src/index.js +1 -0
package/src/bak/translator.js
CHANGED
|
@@ -4,24 +4,103 @@ function safeCodeAsKey(name) {
|
|
|
4
4
|
return `['${name}']`;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* 获取变量初始值
|
|
9
|
+
* @param {*} variable
|
|
10
|
+
* @param {*} URLParamRetrieval 从地址栏获取
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
function genVarInitialVal(variable, URLParamRetrieval) {
|
|
14
|
+
const typeAnnotation = variable.typeAnnotation || variable.__TypeAnnotation;
|
|
15
|
+
let { typeKind, typeNamespace, typeName, sortedTypeKey } = typeAnnotation || {};
|
|
16
|
+
if (typeNamespace?.endsWith('.metadataTypes')) {
|
|
17
|
+
const referenceNode = variable.getAncestor('App').findNodeByCompleteName(typeNamespace + '.' + typeName) || {}
|
|
18
|
+
const typeAn = referenceNode.typeAnnotation || {};
|
|
19
|
+
typeKind = typeAn.typeKind;
|
|
20
|
+
typeNamespace = typeAn.typeNamespace;
|
|
21
|
+
typeName = typeAn.typeName;
|
|
22
|
+
sortedTypeKey = `${typeNamespace}.${typeName}`;
|
|
23
|
+
}
|
|
24
|
+
const needGenInitFromSchema =
|
|
25
|
+
typeAnnotation && (!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
|
|
9
26
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
27
|
+
let code = '';
|
|
28
|
+
if (needGenInitFromSchema) {
|
|
29
|
+
code += `this.$genInitFromSchema('${sortedTypeKey}', `;
|
|
30
|
+
}
|
|
31
|
+
if (variable.concept === 'Param' && URLParamRetrieval) {
|
|
32
|
+
code += `this.$route.query.hasOwnProperty('${variable.name}') ? this.$genInitFromSchema('${sortedTypeKey}', this.$route.query.${variable.name}) :`;
|
|
33
|
+
}
|
|
34
|
+
const { defaultValue } = variable;
|
|
35
|
+
// 设置成null,才能同步给后端清除该值,但是null对checkbox组件是一种特殊状态
|
|
36
|
+
const parsedValue = defaultValue?.expression?.toJS?.() ?? undefined;
|
|
13
37
|
|
|
14
|
-
|
|
38
|
+
code += parsedValue;
|
|
39
|
+
if (needGenInitFromSchema) {
|
|
40
|
+
code += `)`;
|
|
41
|
+
}
|
|
42
|
+
return code;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 获取组件入参的类型
|
|
47
|
+
* @param {*} typeAnnotation
|
|
48
|
+
*/
|
|
49
|
+
function getPropsType(typeAnnotation) {
|
|
50
|
+
let type = 'Object';
|
|
51
|
+
const { typeKind, typeNamespace, typeName, typeArguments } = typeAnnotation || {};
|
|
52
|
+
if (
|
|
53
|
+
typeKind === 'union'
|
|
54
|
+
&& typeNamespace === 'nasl.core'
|
|
55
|
+
&& typeName === 'Union'
|
|
56
|
+
&& Array.isArray(typeArguments)
|
|
57
|
+
&& typeArguments.length
|
|
58
|
+
) {
|
|
59
|
+
const arr = typeArguments.map((typeArgument) => {
|
|
60
|
+
return getPropsType(typeArgument);
|
|
61
|
+
});
|
|
62
|
+
type = `[${arr.join(', ')}]`;
|
|
63
|
+
} else {
|
|
64
|
+
if (typeKind === 'primitive' && typeNamespace === 'nasl.core') {
|
|
65
|
+
const typeMap = {
|
|
66
|
+
Boolean: 'Boolean',
|
|
67
|
+
Decimal: 'Number',
|
|
68
|
+
Long: 'Number',
|
|
69
|
+
String: 'String',
|
|
70
|
+
Date: 'String',
|
|
71
|
+
Time: 'String',
|
|
72
|
+
DateTime: 'String',
|
|
73
|
+
};
|
|
74
|
+
if (typeMap[typeName]) {
|
|
75
|
+
type = typeMap[typeName];
|
|
76
|
+
}
|
|
77
|
+
} else if (typeKind === "generic" && typeNamespace === "nasl.collection" && typeName === 'List') {
|
|
78
|
+
type = 'Array';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return type;
|
|
15
82
|
}
|
|
16
83
|
|
|
17
84
|
export default function (definition, view) {
|
|
85
|
+
let isBusinessComponent = false;
|
|
86
|
+
if (view.concept === 'BusinessComponent') {
|
|
87
|
+
isBusinessComponent = true;
|
|
88
|
+
}
|
|
18
89
|
/**
|
|
19
90
|
* 页面的 data
|
|
20
91
|
* 包含 页面变量 / 页面入参 / 页面元素绑定的表达式的返回
|
|
21
92
|
*/
|
|
22
93
|
const viewVariablesData = [];
|
|
94
|
+
// 组件入参
|
|
95
|
+
const viewProps = [];
|
|
23
96
|
// 所有的页面变量
|
|
24
|
-
const viewVariables = [...(definition.
|
|
97
|
+
const viewVariables = [...(definition.variables || [])];
|
|
98
|
+
if (isBusinessComponent) {
|
|
99
|
+
viewProps.push(...(definition.params || []));
|
|
100
|
+
} else {
|
|
101
|
+
viewVariables.push(...(definition.params || []));
|
|
102
|
+
}
|
|
103
|
+
|
|
25
104
|
// 页面元素绑定的表达式
|
|
26
105
|
const { viewExpressions } = definition;
|
|
27
106
|
const hasViewExpressions = Array.isArray(viewExpressions) && viewExpressions.length;
|
|
@@ -29,38 +108,8 @@ export default function (definition, view) {
|
|
|
29
108
|
* genInitFromSchema 是为了将数据类型的处理和页面逻辑的生成分开
|
|
30
109
|
* 比如 param a.b 的 schema 有变化,View 代码无需再次生成
|
|
31
110
|
*/
|
|
32
|
-
const dataMap = {};
|
|
33
111
|
viewVariables.forEach((viewVariable) => {
|
|
34
|
-
|
|
35
|
-
const typeAnnotation = viewVariable.typeAnnotation || viewVariable.__TypeAnnotation;
|
|
36
|
-
let { typeKind, typeNamespace, typeName, sortedTypeKey } = typeAnnotation || {};
|
|
37
|
-
if (typeNamespace?.endsWith('.metadataTypes')) {
|
|
38
|
-
const referenceNode = view.getAncestor('App').findNodeByCompleteName(typeNamespace + '.' + typeName) || {}
|
|
39
|
-
const typeAn = referenceNode.typeAnnotation || {};
|
|
40
|
-
typeKind = typeAn.typeKind;
|
|
41
|
-
typeNamespace = typeAn.typeNamespace;
|
|
42
|
-
typeName = typeAn.typeName;
|
|
43
|
-
sortedTypeKey = `${typeNamespace}.${typeName}`;
|
|
44
|
-
}
|
|
45
|
-
const needGenInitFromSchema =
|
|
46
|
-
typeAnnotation && (!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
|
|
47
|
-
let code = `${safeCodeAsKey(viewVariable.name)}:`;
|
|
48
|
-
if (needGenInitFromSchema) {
|
|
49
|
-
code += `this.$genInitFromSchema('${sortedTypeKey}', `;
|
|
50
|
-
}
|
|
51
|
-
if (viewVariable.concept === 'Param') {
|
|
52
|
-
code += `this.$route.query.hasOwnProperty('${viewVariable.name}') ? this.$genInitFromSchema('${sortedTypeKey}', this.$route.query.${viewVariable.name}) :`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const { defaultValue } = viewVariable;
|
|
56
|
-
// 设置成null,才能同步给后端清除该值,但是null对checkbox组件是一种特殊状态
|
|
57
|
-
const parsedValue = defaultValue?.expression?.toJS?.() ?? undefined;
|
|
58
|
-
|
|
59
|
-
code += parsedValue;
|
|
60
|
-
if (needGenInitFromSchema) {
|
|
61
|
-
code += `)`;
|
|
62
|
-
}
|
|
63
|
-
viewVariablesData.push(code);
|
|
112
|
+
viewVariablesData.push(`${safeCodeAsKey(viewVariable.name)}: ${genVarInitialVal(viewVariable, !isBusinessComponent)}`);
|
|
64
113
|
});
|
|
65
114
|
/**
|
|
66
115
|
* 页面的 computed
|
|
@@ -152,7 +201,9 @@ export default function (definition, view) {
|
|
|
152
201
|
|
|
153
202
|
const events = Array.from(eventMap).map(([name, bindEvents]) => {
|
|
154
203
|
let code = `async ${name} () {
|
|
155
|
-
|
|
204
|
+
${bindEvents.map((event) =>{
|
|
205
|
+
const likeComponent = event.view || event.getAncestor('BusinessComponent');
|
|
206
|
+
return `await this.${likeComponent?.name}_${event.name}();`}).join('\n')}`;
|
|
156
207
|
code += '}';
|
|
157
208
|
return code;
|
|
158
209
|
});
|
|
@@ -167,15 +218,42 @@ export default function (definition, view) {
|
|
|
167
218
|
tabSize: 1,
|
|
168
219
|
})
|
|
169
220
|
);
|
|
170
|
-
|
|
171
|
-
|
|
221
|
+
const viewPropArr = [];
|
|
222
|
+
// 监听
|
|
223
|
+
const watcherArr = [];
|
|
224
|
+
let output = '';
|
|
225
|
+
if (Array.isArray(viewProps) && viewProps.length) {
|
|
226
|
+
viewProps.forEach((viewProp) => {
|
|
227
|
+
const typeAnnotation = viewProp.typeAnnotation || viewProp.__TypeAnnotation;
|
|
228
|
+
viewPropArr.push(`${safeCodeAsKey(viewProp.name)}: {
|
|
229
|
+
type: ${getPropsType(typeAnnotation)},
|
|
230
|
+
default: ${genVarInitialVal(viewProp, !isBusinessComponent)}
|
|
231
|
+
}`);
|
|
232
|
+
watcherArr.push(`${safeCodeAsKey(viewProp.name)}: {
|
|
233
|
+
handler(val) {
|
|
234
|
+
this.$emit('update:${viewProp.name}', val);
|
|
235
|
+
},
|
|
236
|
+
}`);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (Array.isArray(viewPropArr) && viewPropArr.length) {
|
|
240
|
+
output += `props: {
|
|
241
|
+
${viewPropArr.join(',\n')}
|
|
242
|
+
},\n`;
|
|
243
|
+
}
|
|
244
|
+
if (Array.isArray(watcherArr) && watcherArr.length) {
|
|
245
|
+
output += `watch: {
|
|
246
|
+
${watcherArr.join(',\n')}
|
|
247
|
+
},\n`;
|
|
248
|
+
}
|
|
249
|
+
output += `
|
|
172
250
|
data() {
|
|
173
251
|
return {
|
|
174
|
-
|
|
252
|
+
${viewVariablesData.join(',\n').trim()}
|
|
175
253
|
};
|
|
176
254
|
},
|
|
177
255
|
computed: {
|
|
178
|
-
|
|
256
|
+
${viewComputedData.join(',\n').trim()}
|
|
179
257
|
},
|
|
180
258
|
meta: {
|
|
181
259
|
title: ${JSON.stringify(definition.title)},
|
|
@@ -349,6 +349,18 @@ export default class BreakpointNode extends BaseNode {
|
|
|
349
349
|
return this.logic || this.variable;
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
+
get items() {
|
|
353
|
+
return (this.node as any)?.items;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
get concept() {
|
|
357
|
+
return (this.node as any)?.concept;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
get getCallNode() {
|
|
361
|
+
return (this.node as any)?.getCallNode;
|
|
362
|
+
}
|
|
363
|
+
|
|
352
364
|
init() {
|
|
353
365
|
const source = this.logic || this.variable;
|
|
354
366
|
const node = getRealNode(source);
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
View,
|
|
4
4
|
BaseNode,
|
|
5
5
|
ViewElement,
|
|
6
|
+
BusinessComponent,
|
|
6
7
|
} from '../../concepts';
|
|
7
8
|
|
|
8
9
|
import {
|
|
@@ -197,7 +198,7 @@ export const getLogics = (app: App) => {
|
|
|
197
198
|
return [];
|
|
198
199
|
}
|
|
199
200
|
|
|
200
|
-
const {
|
|
201
|
+
const { frontendTypes = [] } = app;
|
|
201
202
|
|
|
202
203
|
let result = getGlobalLogics(app) || [];
|
|
203
204
|
|
|
@@ -220,7 +221,7 @@ export const getLogics = (app: App) => {
|
|
|
220
221
|
viewElementChildren.forEach(forViewElement);
|
|
221
222
|
};
|
|
222
223
|
|
|
223
|
-
const forView = (view: View) => {
|
|
224
|
+
const forView = (view: View | BusinessComponent) => {
|
|
224
225
|
if (!view) {
|
|
225
226
|
return;
|
|
226
227
|
}
|
|
@@ -228,7 +229,6 @@ export const getLogics = (app: App) => {
|
|
|
228
229
|
const {
|
|
229
230
|
logics: viewLogics = [],
|
|
230
231
|
elements: viewElements = [],
|
|
231
|
-
children: viewChildren = [],
|
|
232
232
|
bindEvents: viewBindEvents = [],
|
|
233
233
|
} = view;
|
|
234
234
|
|
|
@@ -241,13 +241,18 @@ export const getLogics = (app: App) => {
|
|
|
241
241
|
});
|
|
242
242
|
|
|
243
243
|
viewElements.forEach(forViewElement);
|
|
244
|
-
|
|
244
|
+
(view as View)?.children?.forEach(forView);
|
|
245
245
|
};
|
|
246
246
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
247
|
+
frontendTypes.forEach((frontendType) => {
|
|
248
|
+
frontendType?.frontends?.forEach((frontend) => {
|
|
249
|
+
const { views = [] } = frontend;
|
|
250
|
+
views && views.forEach(forView);
|
|
251
|
+
});
|
|
252
|
+
const { businessComponents } = frontendType || {};
|
|
253
|
+
if (Array.isArray(businessComponents) && businessComponents.length) {
|
|
254
|
+
businessComponents.forEach(forView);
|
|
255
|
+
}
|
|
251
256
|
});
|
|
252
257
|
|
|
253
258
|
return result;
|
|
@@ -138,7 +138,7 @@ const isFrontend = (node: BaseNode) => {
|
|
|
138
138
|
|
|
139
139
|
const { getAncestor } = node;
|
|
140
140
|
|
|
141
|
-
return getAncestor && getAncestor.call(node, '
|
|
141
|
+
return getAncestor && getAncestor.call(node, 'FrontendType');
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
const updateToBackend = (node: BaseNode) => {
|
package/src/common/BaseNode.ts
CHANGED
|
@@ -20,38 +20,6 @@ export function setActionable(value: boolean) {
|
|
|
20
20
|
actionable = value;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
// 确保属性都是定义过的
|
|
24
|
-
function ensureDefined(object: any, concept: string) {
|
|
25
|
-
if (!object) {
|
|
26
|
-
return object;
|
|
27
|
-
}
|
|
28
|
-
const newObject: any = {};
|
|
29
|
-
const actualConcept = object?.concept || concept;
|
|
30
|
-
if (actualConcept) {
|
|
31
|
-
const propertyMap = getConceptPropertyMap(actualConcept);
|
|
32
|
-
for (const key in object) {
|
|
33
|
-
const property = propertyMap.get(key);
|
|
34
|
-
if (property) {
|
|
35
|
-
const objProperty = object[key] ?? null;
|
|
36
|
-
const propertyConcept = property?.objectRef;
|
|
37
|
-
if (propertyConcept) {
|
|
38
|
-
if (Array.isArray(objProperty)) {
|
|
39
|
-
newObject[key] = objProperty.map((objItem: any) => {
|
|
40
|
-
return ensureDefined(objItem, propertyConcept);
|
|
41
|
-
});
|
|
42
|
-
} else {
|
|
43
|
-
newObject[key] = ensureDefined(objProperty, propertyConcept);
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
newObject[key] = objProperty;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
newObject.concept = actualConcept;
|
|
52
|
-
}
|
|
53
|
-
return newObject;
|
|
54
|
-
}
|
|
55
23
|
|
|
56
24
|
type NodePathOption = {
|
|
57
25
|
useName?: boolean,
|
|
@@ -249,13 +217,6 @@ export class BaseNode extends EventEmitter {
|
|
|
249
217
|
@property()
|
|
250
218
|
composedBy?: Array<string>;
|
|
251
219
|
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* 分组管理在多人协作场景触点
|
|
255
|
-
*/
|
|
256
|
-
@property()
|
|
257
|
-
composedOrigin?: 'Form' | 'Table' | 'Process';
|
|
258
|
-
|
|
259
220
|
/**
|
|
260
221
|
* 当前节点的类型标注
|
|
261
222
|
*/
|
|
@@ -1103,7 +1064,27 @@ export class BaseNode extends EventEmitter {
|
|
|
1103
1064
|
});
|
|
1104
1065
|
return JSON.parse(JSON.stringify(temp));
|
|
1105
1066
|
}
|
|
1106
|
-
|
|
1067
|
+
// 给国际化展示用
|
|
1068
|
+
getNodeChinesePath(useIndex: boolean | string[] | NodePathOption) {
|
|
1069
|
+
let node: BaseNode = this;
|
|
1070
|
+
const pathArr: string[] = [];
|
|
1071
|
+
while (node && node.concept) {
|
|
1072
|
+
let pathText = '';
|
|
1073
|
+
const { parentNode } = node;
|
|
1074
|
+
if (parentNode) {
|
|
1075
|
+
const { name, title, label } = parentNode as any;
|
|
1076
|
+
pathText = `${(parentNode.constructor as any)?.nodeTitle || ''}${name || ''}`;
|
|
1077
|
+
if (title && label) {
|
|
1078
|
+
pathText += `(${title} | ${label})`;
|
|
1079
|
+
} else if (title || label) {
|
|
1080
|
+
pathText += `(${title || label})`;
|
|
1081
|
+
}
|
|
1082
|
+
pathArr.unshift(pathText);
|
|
1083
|
+
}
|
|
1084
|
+
node = parentNode;
|
|
1085
|
+
}
|
|
1086
|
+
return pathArr.join('/');
|
|
1087
|
+
}
|
|
1107
1088
|
/**
|
|
1108
1089
|
* 查找引用
|
|
1109
1090
|
*/
|
|
@@ -1496,7 +1477,7 @@ export class BaseNode extends EventEmitter {
|
|
|
1496
1477
|
if (typeAnnotation) {
|
|
1497
1478
|
const { typeKind, typeNamespace, typeName, properties } = typeAnnotation;
|
|
1498
1479
|
if (typeKind === 'reference' || typeKind === 'generic') {
|
|
1499
|
-
if (typeNamespace
|
|
1480
|
+
if (typeNamespace?.endsWith('.enums')) return null;
|
|
1500
1481
|
return [{}];
|
|
1501
1482
|
}
|
|
1502
1483
|
if (typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName)) {
|
|
@@ -649,27 +649,45 @@ export class AnonymousFunction extends LogicItem {
|
|
|
649
649
|
return code;
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
652
|
+
/**
|
|
653
|
+
* 确保参数名称都是不重复的,且更新内部的引用关系
|
|
654
|
+
* @param paramNames
|
|
655
|
+
* @returns
|
|
656
|
+
*/
|
|
657
|
+
ensureParamName(paramNames: Set<string>) {
|
|
658
|
+
const paramInfoMap = new Map<string, any>();
|
|
659
|
+
this.params.forEach((param) => {
|
|
660
|
+
const name = utils.unique(param.name, paramNames);
|
|
661
|
+
if (!paramInfoMap.get(param.name)) {
|
|
662
|
+
paramInfoMap.set(param.name, {});
|
|
661
663
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
664
|
+
const paramInfo = paramInfoMap.get(param.name);
|
|
665
|
+
// 即使没有修改,也需要把名字塞进去
|
|
666
|
+
paramInfo.newName = name;
|
|
667
|
+
if (name !== param.name) {
|
|
668
|
+
paramInfo.param = param;
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
this.traverseChildren((node) => {
|
|
672
|
+
if (node?.concept === 'Identifier') {
|
|
673
|
+
const parentNode = node.parentNode;
|
|
674
|
+
if (
|
|
675
|
+
parentNode?.concept !== 'MemberExpression'
|
|
676
|
+
|| (parentNode.parentNode?.concept !== 'MemberExpression' && (parentNode as any).object === node)
|
|
677
|
+
) {
|
|
678
|
+
if (node) {
|
|
679
|
+
const paramInfo = paramInfoMap.get(node.name);
|
|
680
|
+
if (paramInfo?.param) {
|
|
681
|
+
if (!Array.isArray(paramInfo?.identifiers)) {
|
|
682
|
+
paramInfo.identifiers = [];
|
|
683
|
+
}
|
|
684
|
+
paramInfo.identifiers.push(node);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
666
688
|
}
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
this.params.forEach((param) => {
|
|
670
|
-
const name = utils.unique(param.name, names);
|
|
671
|
-
param.name = name;
|
|
672
689
|
});
|
|
690
|
+
return paramInfoMap;
|
|
673
691
|
}
|
|
674
692
|
|
|
675
693
|
//================================================================================
|