@lcap/nasl 2.22.0-beta.5 → 3.0.0-beta.1
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/README.md +13 -0
- package/docs/classes/Module.html +15 -15
- package/docs/classes/Namespace.html +15 -15
- package/docs/classes/ViewComponent.html +19 -19
- package/out/automate/engine/utils.js +4 -0
- package/out/automate/engine/utils.js.map +1 -1
- package/out/breakpoint/generator/AfterStartNode.d.ts +7 -0
- package/out/breakpoint/generator/AfterStartNode.js +27 -0
- package/out/breakpoint/generator/AfterStartNode.js.map +1 -0
- package/out/breakpoint/generator/BeforeEndNode.d.ts +7 -0
- package/out/breakpoint/generator/BeforeEndNode.js +27 -0
- package/out/breakpoint/generator/BeforeEndNode.js.map +1 -0
- package/out/breakpoint/generator/BreakpointNode.d.ts +14 -0
- package/out/breakpoint/generator/BreakpointNode.js +166 -0
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -0
- package/out/breakpoint/generator/index.d.ts +4 -0
- package/out/breakpoint/generator/index.js +98 -0
- package/out/breakpoint/generator/index.js.map +1 -0
- package/out/breakpoint/index.d.ts +3 -0
- package/out/breakpoint/index.js +20 -0
- package/out/breakpoint/index.js.map +1 -0
- package/out/breakpoint/shared/constants.d.ts +30 -0
- package/out/breakpoint/shared/constants.js +87 -0
- package/out/breakpoint/shared/constants.js.map +1 -0
- package/out/breakpoint/shared/index.d.ts +3 -0
- package/out/breakpoint/shared/index.js +33 -0
- package/out/breakpoint/shared/index.js.map +1 -0
- package/out/breakpoint/shared/operations.d.ts +10 -0
- package/out/breakpoint/shared/operations.js +25 -0
- package/out/breakpoint/shared/operations.js.map +1 -0
- package/out/breakpoint/shared/socket.d.ts +47 -0
- package/out/breakpoint/shared/socket.js +210 -0
- package/out/breakpoint/shared/socket.js.map +1 -0
- package/out/breakpoint/shared/utils.d.ts +20 -0
- package/out/breakpoint/shared/utils.js +133 -0
- package/out/breakpoint/shared/utils.js.map +1 -0
- package/out/breakpoint/store/core.d.ts +30 -0
- package/out/breakpoint/store/core.js +341 -0
- package/out/breakpoint/store/core.js.map +1 -0
- package/out/breakpoint/store/dock.d.ts +1 -0
- package/out/breakpoint/store/dock.js +127 -0
- package/out/breakpoint/store/dock.js.map +1 -0
- package/out/breakpoint/store/index.d.ts +2 -0
- package/out/breakpoint/store/index.js +19 -0
- package/out/breakpoint/store/index.js.map +1 -0
- package/out/common/BaseNode.d.ts +8 -0
- package/out/common/BaseNode.js +19 -0
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +365 -16
- package/out/concepts/App__.js +431 -10
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignment__.js +1 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/AuthInterface__.d.ts +37 -0
- package/out/concepts/AuthInterface__.js +141 -0
- package/out/concepts/AuthInterface__.js.map +1 -0
- package/out/concepts/AuthLogicForCallInterface__.d.ts +138 -0
- package/out/concepts/AuthLogicForCallInterface__.js +493 -0
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -0
- package/out/concepts/AuthLogic__.d.ts +66 -0
- package/out/concepts/AuthLogic__.js +206 -0
- package/out/concepts/AuthLogic__.js.map +1 -0
- package/out/concepts/BackendVariable__.d.ts +137 -0
- package/out/concepts/BackendVariable__.js +422 -0
- package/out/concepts/BackendVariable__.js.map +1 -0
- package/out/concepts/Backend__.d.ts +134 -0
- package/out/concepts/Backend__.js +274 -0
- package/out/concepts/Backend__.js.map +1 -0
- package/out/concepts/BindAttribute__.d.ts +1 -1
- package/out/concepts/BindAttribute__.js +3 -1
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +12 -0
- package/out/concepts/BindEvent__.js +68 -0
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/CallAuthInterface__.d.ts +126 -0
- package/out/concepts/CallAuthInterface__.js +408 -0
- package/out/concepts/CallAuthInterface__.js.map +1 -0
- package/out/concepts/CallInterface__.d.ts +6 -1
- package/out/concepts/CallInterface__.js +9 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +3 -1
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +9 -7
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Destination__.js +1 -1
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +29 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -2
- package/out/concepts/Entity__.js +1 -31
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +9 -4
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.d.ts +29 -29
- package/out/concepts/FrontendLibrary__.js +2 -2
- package/out/concepts/FrontendVariable__.d.ts +21 -0
- package/out/concepts/FrontendVariable__.js +64 -0
- package/out/concepts/FrontendVariable__.js.map +1 -0
- package/out/concepts/Frontend__.d.ts +151 -47
- package/out/concepts/Frontend__.js +188 -32
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Function__.js +1 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +1 -1
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +18 -3
- package/out/concepts/LogicItem__.js +22 -4
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +14 -9
- package/out/concepts/Logic__.js +43 -5
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +29 -29
- package/out/concepts/Namespace__.js +2 -2
- package/out/concepts/NewComposite__.js +2 -2
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.d.ts +643 -0
- package/out/concepts/OverriddenLogic__.js +1602 -0
- package/out/concepts/OverriddenLogic__.js.map +1 -0
- package/out/concepts/Param__.d.ts +6 -0
- package/out/concepts/Param__.js +10 -0
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +2 -0
- package/out/concepts/QueryFieldExpression__.js +9 -0
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.d.ts +2 -2
- package/out/concepts/QuerySelectExpression__.js +2 -2
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +6 -6
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +10 -0
- package/out/concepts/Variable__.js +12 -0
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.d.ts +33 -33
- package/out/concepts/ViewComponent__.js +7 -7
- package/out/concepts/ViewElement__.d.ts +6 -0
- package/out/concepts/ViewElement__.js +104 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +2 -2
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/index.js +2 -1
- package/out/concepts/basics/stdlib/index.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +24 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.http.d.ts +7 -0
- package/out/concepts/basics/stdlib/nasl.http.js +167 -0
- package/out/concepts/basics/stdlib/nasl.http.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.process.js +68 -0
- package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +4 -19
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +83 -17
- 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 +8 -0
- package/out/concepts/index__.js +8 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +0 -1
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +1 -0
- package/out/generator/genBundleFiles.js +27 -0
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +4 -1
- package/out/generator/genMetaData.js +14 -0
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +2 -1
- package/out/generator/genReleaseBody.js +2 -1
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/index.d.ts +2 -1
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/server/extendBaseNode.js +16 -4
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +2 -1
- package/out/server/formatTsUtils.js +39 -4
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getExtensionModules.d.ts +2 -2
- package/out/server/getExtensionModules.js +16 -2
- package/out/server/getExtensionModules.js.map +1 -1
- package/out/server/getLogics.js +5 -5
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -0
- package/out/server/getMemberIdentifier.js +34 -7
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.d.ts +64 -64
- package/out/server/naslServer.js +249 -121
- package/out/server/naslServer.js.map +1 -1
- package/out/server/naslStdlibMap.js +2 -0
- package/out/server/naslStdlibMap.js.map +1 -1
- package/out/server/translator.d.ts +1 -0
- package/out/server/translator.js +67 -2
- package/out/server/translator.js.map +1 -1
- package/out/service/defaultErrorMessage.json +1 -0
- package/out/service/storage/api.d.ts +10 -1
- package/out/service/storage/api.js +6 -0
- package/out/service/storage/api.js.map +1 -1
- package/out/service/storage/init.d.ts +4 -0
- package/out/service/storage/init.js +55 -35
- package/out/service/storage/init.js.map +1 -1
- package/out/service/storage/service.d.ts +3 -0
- package/out/service/storage/service.js +14 -0
- package/out/service/storage/service.js.map +1 -1
- package/out/utils/sortTsString.d.ts +1 -0
- package/out/utils/sortTsString.js +36 -0
- package/out/utils/sortTsString.js.map +1 -0
- package/out/utils/traverse.js +2 -2
- package/out/utils/traverse.js.map +1 -1
- package/package.json +7 -2
- package/sandbox/stdlib/nasl.auth.ts +8 -4
- package/sandbox/stdlib/nasl.core.d.ts +206 -0
- package/sandbox/stdlib/nasl.core.js +1 -0
- package/sandbox/stdlib/nasl.core.js.map +1 -0
- package/sandbox/stdlib/nasl.http.ts +35 -0
- package/sandbox/stdlib/nasl.process.ts +13 -0
- package/sandbox/stdlib/nasl.ui.ts +0 -5
- package/src/automate/engine/utils.js +4 -1
- package/src/breakpoint/generator/AfterStartNode.ts +27 -0
- package/src/breakpoint/generator/BeforeEndNode.ts +27 -0
- package/src/breakpoint/generator/BreakpointNode.ts +228 -0
- package/src/breakpoint/generator/index.ts +114 -0
- package/src/breakpoint/index.ts +3 -0
- package/src/breakpoint/shared/constants.ts +95 -0
- package/src/breakpoint/shared/index.ts +3 -0
- package/src/breakpoint/shared/operations.ts +25 -0
- package/src/breakpoint/shared/socket.ts +326 -0
- package/src/breakpoint/shared/utils.ts +195 -0
- package/src/breakpoint/store/core.ts +411 -0
- package/src/breakpoint/store/dock.ts +166 -0
- package/src/breakpoint/store/index.ts +2 -0
- package/src/breakpoint/types/index.d.ts +19 -0
- package/src/common/BaseNode.ts +19 -1
- package/src/concepts/App__.ts +828 -26
- package/src/concepts/Assignment__.ts +1 -1
- package/src/concepts/AuthInterface__.ts +148 -0
- package/src/concepts/AuthLogicForCallInterface__.ts +573 -0
- package/src/concepts/AuthLogic__.ts +225 -0
- package/src/concepts/BackendVariable__.ts +466 -0
- package/src/concepts/Backend__.ts +347 -0
- package/src/concepts/BindAttribute__.ts +4 -3
- package/src/concepts/BindEvent__.ts +71 -2
- package/src/concepts/CallAuthInterface__.ts +490 -0
- package/src/concepts/CallInterface__.ts +10 -2
- package/src/concepts/CallLogic__.ts +3 -1
- package/src/concepts/CallQueryComponent__.ts +67 -7
- package/src/concepts/Destination__.ts +19 -1
- package/src/concepts/End__.ts +31 -3
- package/src/concepts/EntityProperty__.ts +6 -0
- package/src/concepts/Entity__.ts +8 -31
- package/src/concepts/ForEachStatement__.ts +9 -4
- package/src/concepts/FrontendLibrary__.ts +30 -30
- package/src/concepts/FrontendVariable__.ts +76 -0
- package/src/concepts/Frontend__.ts +352 -89
- package/src/concepts/Function__.ts +1 -1
- package/src/concepts/Identifier__.ts +5 -5
- package/src/concepts/Interface__.ts +1 -1
- package/src/concepts/LogicItem__.ts +26 -6
- package/src/concepts/Logic__.ts +86 -8
- package/src/concepts/Module__.ts +32 -2
- package/src/concepts/Namespace__.ts +30 -30
- package/src/concepts/NewComposite__.ts +2 -3
- package/src/concepts/OverriddenLogic__.ts +2165 -0
- package/src/concepts/Param__.ts +13 -3
- package/src/concepts/QueryFieldExpression__.ts +18 -0
- package/src/concepts/QuerySelectExpression__.ts +11 -3
- package/src/concepts/TypeAnnotation__.ts +45 -6
- package/src/concepts/Variable__.ts +14 -0
- package/src/concepts/ViewComponent__.ts +35 -35
- package/src/concepts/ViewElement__.ts +104 -1
- package/src/concepts/View__.ts +24 -2
- package/src/concepts/basics/stdlib/index.ts +2 -1
- package/src/concepts/basics/stdlib/nasl.auth.ts +24 -0
- package/src/concepts/basics/stdlib/nasl.http.ts +166 -0
- package/src/concepts/basics/stdlib/nasl.process.ts +68 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +4 -19
- package/src/concepts/basics/stdlib/nasl.util.ts +83 -17
- package/src/concepts/basics/types/index.ts +5 -4
- package/src/concepts/index__.ts +8 -0
- package/src/enums/KEYWORDS.ts +0 -1
- package/src/generator/genBundleFiles.ts +36 -2
- package/src/generator/genMetaData.ts +16 -1
- package/src/generator/genReleaseBody.ts +4 -1
- package/src/index.ts +2 -1
- package/src/server/extendBaseNode.ts +18 -7
- package/src/server/formatTsUtils.ts +37 -5
- package/src/server/getExtensionModules.ts +18 -3
- package/src/server/getLogics.ts +6 -6
- package/src/server/getMemberIdentifier.ts +35 -9
- package/src/server/naslServer.ts +250 -124
- package/src/server/naslStdlibMap.ts +2 -0
- package/src/server/translator.ts +67 -1
- package/src/service/defaultErrorMessage.json +1 -0
- package/src/service/storage/api.js +7 -1
- package/src/service/storage/init.ts +66 -35
- package/src/service/storage/service.ts +18 -2
- package/src/utils/sortTsString.ts +32 -0
- package/src/utils/traverse.ts +2 -2
- package/test/examples/app-simple.json +73635 -0
- package/ts-worker/lib/tsserver.js +3 -3
- package/ts-worker/package.json +1 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
//================================================================================
|
|
2
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
3
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
4
|
+
//================================================================================
|
|
5
|
+
import { EventPayload, Params } from '../common/EventEmitter';
|
|
6
|
+
import { concept, excludedInJSON, property } from '../decorators';
|
|
7
|
+
|
|
8
|
+
import * as utils from '../utils';
|
|
9
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
10
|
+
import BaseNode from '../common/BaseNode';
|
|
11
|
+
import classMap from '../common/classMap';
|
|
12
|
+
import Module from './Module__';
|
|
13
|
+
import View from './View__';
|
|
14
|
+
import ProcessElement from './ProcessElement__';
|
|
15
|
+
import App from './App__';
|
|
16
|
+
import Frontend from './Frontend__';
|
|
17
|
+
import Process from './Process__';
|
|
18
|
+
import Logic from './Logic__';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 开放接口的鉴权逻辑
|
|
22
|
+
*/
|
|
23
|
+
@concept('开放接口的鉴权逻辑')
|
|
24
|
+
export class AuthLogic extends Logic {
|
|
25
|
+
/**
|
|
26
|
+
* 产品概念
|
|
27
|
+
*/
|
|
28
|
+
@property()
|
|
29
|
+
concept: 'AuthLogic' | 'AuthLogicForCallInterface' = 'AuthLogic';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 是否为默认鉴权逻辑
|
|
33
|
+
*/
|
|
34
|
+
@property()
|
|
35
|
+
isDefault: boolean = undefined;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 祖先 Module
|
|
39
|
+
*/
|
|
40
|
+
get module() {
|
|
41
|
+
return this.getAncestor('Module') as Module;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 祖先 App
|
|
45
|
+
*/
|
|
46
|
+
get app() {
|
|
47
|
+
return this.getAncestor('App') as App;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 祖先 View
|
|
51
|
+
*/
|
|
52
|
+
get view() {
|
|
53
|
+
return this.getAncestor('View') as View;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 祖先 Frontend
|
|
57
|
+
*/
|
|
58
|
+
get frontend() {
|
|
59
|
+
return this.getAncestor('Frontend') as Frontend;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 祖先 ProcessElement
|
|
63
|
+
*/
|
|
64
|
+
get processElement() {
|
|
65
|
+
return this.getAncestor('ProcessElement') as ProcessElement;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 祖先 Process
|
|
69
|
+
*/
|
|
70
|
+
get process() {
|
|
71
|
+
return this.getAncestor('Process') as Process;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param source 需要合并的部分参数
|
|
76
|
+
*/
|
|
77
|
+
constructor(source?: Partial<AuthLogic>) {
|
|
78
|
+
source = Object.assign({}, AuthLogic.getDefaultOptions(), source);
|
|
79
|
+
super(source);
|
|
80
|
+
super.subConstructor(source);
|
|
81
|
+
}
|
|
82
|
+
getClassName() {
|
|
83
|
+
return 'AuthLogic';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static from(source: any, parentNode?: any, parentKey?: string): AuthLogic {
|
|
87
|
+
return super.from(source, parentNode, parentKey) as AuthLogic;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 设置是否为默认鉴权逻辑
|
|
93
|
+
*/
|
|
94
|
+
setIsDefault(isDefault: boolean) {
|
|
95
|
+
const object = {
|
|
96
|
+
isDefault,
|
|
97
|
+
};
|
|
98
|
+
this.update({
|
|
99
|
+
...object,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
//================================================================================
|
|
108
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
109
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
110
|
+
//================================================================================
|
|
111
|
+
public static getDefaultOptions(): Partial<{
|
|
112
|
+
body: Array<any>,
|
|
113
|
+
params: Array<any>,
|
|
114
|
+
returns: Array<any>,
|
|
115
|
+
}> {
|
|
116
|
+
return {
|
|
117
|
+
body: [
|
|
118
|
+
{
|
|
119
|
+
concept: 'Start',
|
|
120
|
+
label: '开始',
|
|
121
|
+
kind: 'Statement',
|
|
122
|
+
type: 'Start',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
concept: 'End',
|
|
126
|
+
label: '结束',
|
|
127
|
+
kind: 'Statement',
|
|
128
|
+
type: 'End',
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
params: [
|
|
132
|
+
{
|
|
133
|
+
concept: 'Param', // 产品概念
|
|
134
|
+
name: 'request', // 输入参数名称
|
|
135
|
+
description: '请求信息,系统自动注入,包含 method、url、header、cookie、body等', // 输入参数描述
|
|
136
|
+
typeAnnotation: {
|
|
137
|
+
concept: 'TypeAnnotation',
|
|
138
|
+
typeKind: 'generic',
|
|
139
|
+
typeNamespace: 'nasl.http',
|
|
140
|
+
typeName: 'HttpRequest',
|
|
141
|
+
typeArguments: [{
|
|
142
|
+
concept: 'TypeAnnotation',
|
|
143
|
+
typeKind: 'primitive',
|
|
144
|
+
typeNamespace: 'nasl.core',
|
|
145
|
+
typeName: 'String',
|
|
146
|
+
}],
|
|
147
|
+
}, // 类型
|
|
148
|
+
required: true, // 是否必填
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
concept: 'Param', // 产品概念
|
|
152
|
+
name: 'response', // 输入参数名称
|
|
153
|
+
description: '请求响应信息,系统自动注入,包含 status、header、cookie、body等', // 输入参数描述
|
|
154
|
+
typeAnnotation: {
|
|
155
|
+
concept: 'TypeAnnotation',
|
|
156
|
+
typeKind: 'generic',
|
|
157
|
+
typeNamespace: 'nasl.http',
|
|
158
|
+
typeName: 'HttpResponse',
|
|
159
|
+
typeArguments: [{
|
|
160
|
+
concept: 'TypeAnnotation',
|
|
161
|
+
typeKind: 'primitive',
|
|
162
|
+
typeNamespace: 'nasl.core',
|
|
163
|
+
typeName: 'String',
|
|
164
|
+
}],
|
|
165
|
+
}, // 类型
|
|
166
|
+
required: true, // 是否必填
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
returns: [
|
|
170
|
+
{
|
|
171
|
+
concept: 'Return', // 产品概念
|
|
172
|
+
name: 'result', // 输出参数名称
|
|
173
|
+
description: '', // 输出参数描述
|
|
174
|
+
typeAnnotation: {
|
|
175
|
+
concept: 'TypeAnnotation',
|
|
176
|
+
typeKind: 'primitive',
|
|
177
|
+
typeNamespace: 'nasl.core',
|
|
178
|
+
typeName: 'Boolean',
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* 生成宿主语言的文件路径
|
|
187
|
+
* @param name 一般不用传,用于 rename
|
|
188
|
+
*/
|
|
189
|
+
getEmbeddedFilePath(name = this.name) {
|
|
190
|
+
const _path = this.module ? `/${this.module.parentKey}/${this.module.name}` : '';
|
|
191
|
+
return `/embedded/${this.app.name}${_path}/authLogics/${name}.ts`;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
getTsNamespace(): string {
|
|
195
|
+
if (this.parentNode) {
|
|
196
|
+
const parentNamespace = (this.parentNode as any)?.getTsNamespace();
|
|
197
|
+
const parentName = this.parentNode.tsName || this.parentNode.name;
|
|
198
|
+
const arr = [parentNamespace];
|
|
199
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
200
|
+
arr.push(parentName);
|
|
201
|
+
}
|
|
202
|
+
let namespace = arr.join('.');
|
|
203
|
+
if (
|
|
204
|
+
!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace)
|
|
205
|
+
&& !namespace.includes('.authLogics')
|
|
206
|
+
) {
|
|
207
|
+
namespace = `${namespace}.authLogics`;
|
|
208
|
+
}
|
|
209
|
+
return namespace;
|
|
210
|
+
} else
|
|
211
|
+
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
//================================================================================
|
|
215
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
216
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
217
|
+
//================================================================================
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
classMap.AuthLogic = AuthLogic;
|
|
221
|
+
export default AuthLogic;
|
|
222
|
+
//================================================================================
|
|
223
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
224
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
225
|
+
//================================================================================
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { dataTypesMap } from './basics/types';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, createCompilerState, indent } from '../translator';
|
|
3
|
+
import { ElementToVueOptions } from './ViewElement__';
|
|
4
|
+
import EntityProperty from './EntityProperty__';
|
|
5
|
+
import StructureProperty from './StructureProperty__';
|
|
6
|
+
import Structure from './Structure__';
|
|
7
|
+
import { getNodeByNodeCallee, getNaslNodeByNodeCallee } from '../automate/engine/utils';
|
|
8
|
+
import Namespace from './Namespace__';
|
|
9
|
+
|
|
10
|
+
function tryJSONParse(str: string) {
|
|
11
|
+
let result;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
result = JSON.parse(str);
|
|
15
|
+
} catch (e) { }
|
|
16
|
+
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
//================================================================================
|
|
20
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
21
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
22
|
+
//================================================================================
|
|
23
|
+
import { EventPayload, Params } from '../common/EventEmitter';
|
|
24
|
+
import { concept, excludedInJSON, property } from '../decorators';
|
|
25
|
+
|
|
26
|
+
import * as utils from '../utils';
|
|
27
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
28
|
+
import BaseNode from '../common/BaseNode';
|
|
29
|
+
import classMap from '../common/classMap';
|
|
30
|
+
import TypeAnnotation from './TypeAnnotation__';
|
|
31
|
+
import Backend from './Backend__';
|
|
32
|
+
import View from './View__';
|
|
33
|
+
import App from './App__';
|
|
34
|
+
import Module from './Module__';
|
|
35
|
+
import Frontend from './Frontend__';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 全局变量
|
|
39
|
+
*/
|
|
40
|
+
@concept('全局变量')
|
|
41
|
+
export class BackendVariable extends BaseNode {
|
|
42
|
+
/**
|
|
43
|
+
* 产品概念
|
|
44
|
+
*/
|
|
45
|
+
@property()
|
|
46
|
+
concept: 'BackendVariable' = 'BackendVariable';
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 全局变量名称
|
|
50
|
+
*/
|
|
51
|
+
@property()
|
|
52
|
+
name: string = undefined;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 全局变量描述
|
|
56
|
+
*/
|
|
57
|
+
@property()
|
|
58
|
+
description: string = undefined;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 类型
|
|
62
|
+
*/
|
|
63
|
+
@property('TypeAnnotation')
|
|
64
|
+
typeAnnotation: TypeAnnotation = undefined;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 默认值
|
|
68
|
+
*/
|
|
69
|
+
@property()
|
|
70
|
+
defaultValue: string = undefined;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 作用域
|
|
74
|
+
*/
|
|
75
|
+
@property()
|
|
76
|
+
scope: 'request' | 'applicaion' = undefined;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 祖先 Backend
|
|
80
|
+
*/
|
|
81
|
+
get Backend() {
|
|
82
|
+
return this.getAncestor('Backend') as Backend;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 祖先 App
|
|
86
|
+
*/
|
|
87
|
+
get app() {
|
|
88
|
+
return this.getAncestor('App') as App;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 祖先 View
|
|
92
|
+
*/
|
|
93
|
+
get view() {
|
|
94
|
+
return this.getAncestor('View') as View;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 祖先 Module
|
|
98
|
+
*/
|
|
99
|
+
get module() {
|
|
100
|
+
return this.getAncestor('Module') as Module;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 祖先 Frontend
|
|
104
|
+
*/
|
|
105
|
+
get frontend() {
|
|
106
|
+
return this.getAncestor('Frontend') as Frontend;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @param source 需要合并的部分参数
|
|
111
|
+
*/
|
|
112
|
+
constructor(source?: Partial<BackendVariable>) {
|
|
113
|
+
source = Object.assign({}, BackendVariable.getDefaultOptions(), source);
|
|
114
|
+
super(source);
|
|
115
|
+
super.subConstructor(source);
|
|
116
|
+
}
|
|
117
|
+
getClassName() {
|
|
118
|
+
return 'BackendVariable';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static from(source: any, parentNode?: any, parentKey?: string): BackendVariable {
|
|
122
|
+
return super.from(source, parentNode, parentKey) as BackendVariable;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 从父级删除该节点
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
129
|
+
_delete() {
|
|
130
|
+
let params: Params = null;
|
|
131
|
+
if (this.parentNode) {
|
|
132
|
+
params = (this.parentNode as any)?.__removeBackendVariable?.(this);
|
|
133
|
+
}
|
|
134
|
+
return params;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* 设置全局变量名称
|
|
138
|
+
*/
|
|
139
|
+
setName(name: string) {
|
|
140
|
+
const object = {
|
|
141
|
+
name,
|
|
142
|
+
};
|
|
143
|
+
this.update({
|
|
144
|
+
...object,
|
|
145
|
+
field: 'name',
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 设置全局变量描述
|
|
151
|
+
*/
|
|
152
|
+
setDescription(description: string) {
|
|
153
|
+
const object = {
|
|
154
|
+
description,
|
|
155
|
+
};
|
|
156
|
+
this.update({
|
|
157
|
+
...object,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 设置默认值
|
|
163
|
+
*/
|
|
164
|
+
setDefaultValue(defaultValue: string) {
|
|
165
|
+
const object = {
|
|
166
|
+
defaultValue,
|
|
167
|
+
};
|
|
168
|
+
this.update({
|
|
169
|
+
...object,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 设置作用域
|
|
175
|
+
*/
|
|
176
|
+
setScope(scope: 'request' | 'applicaion') {
|
|
177
|
+
const object = {
|
|
178
|
+
scope,
|
|
179
|
+
};
|
|
180
|
+
this.update({
|
|
181
|
+
...object,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* 删除类型标注
|
|
191
|
+
* @param name 类型标注名称
|
|
192
|
+
*/
|
|
193
|
+
removeTypeAnnotation(name: string): void;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 删除类型标注
|
|
197
|
+
* @param typeAnnotation 已有的类型标注实例
|
|
198
|
+
*/
|
|
199
|
+
removeTypeAnnotation(typeAnnotation: TypeAnnotation): void;
|
|
200
|
+
|
|
201
|
+
removeTypeAnnotation(options: string | TypeAnnotation) {
|
|
202
|
+
let typeAnnotation: TypeAnnotation;
|
|
203
|
+
if (typeof options === 'string') {
|
|
204
|
+
typeAnnotation = this.typeAnnotation;
|
|
205
|
+
if (!typeAnnotation) {
|
|
206
|
+
throw new Error('找不到类型标注 ' + options);
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
typeAnnotation = options;
|
|
210
|
+
}
|
|
211
|
+
return typeAnnotation.delete();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
__removeTypeAnnotation(typeAnnotation: TypeAnnotation) {
|
|
215
|
+
const parentKey = typeAnnotation.parentKey;
|
|
216
|
+
const params: Params = {
|
|
217
|
+
parentNode: this,
|
|
218
|
+
parentKey,
|
|
219
|
+
index: -1,
|
|
220
|
+
object: null,
|
|
221
|
+
oldObject: typeAnnotation,
|
|
222
|
+
};
|
|
223
|
+
if (parentKey) {
|
|
224
|
+
params.parentKey = parentKey;
|
|
225
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
226
|
+
const index = (this as any)[parentKey].indexOf(typeAnnotation);
|
|
227
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
228
|
+
params.index = index;
|
|
229
|
+
} else if ((this as any)[parentKey] === typeAnnotation) {
|
|
230
|
+
params.index = 0;
|
|
231
|
+
(this as any)[parentKey] = undefined;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return params;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
//================================================================================
|
|
238
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
239
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
240
|
+
//================================================================================
|
|
241
|
+
/**
|
|
242
|
+
* 自动补全的属性列表
|
|
243
|
+
*/
|
|
244
|
+
completionChildren: Array<EntityProperty | StructureProperty> = undefined;
|
|
245
|
+
|
|
246
|
+
toVue(options?: ElementToVueOptions): string {
|
|
247
|
+
return this.name;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
toUI(): string {
|
|
251
|
+
return this.name;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
toJS(state?: TranslatorState): string {
|
|
255
|
+
const context = this.view ? 'this' : 'Vue.prototype';
|
|
256
|
+
const typeAnnotation = this.typeAnnotation || this.__TypeAnnotation;
|
|
257
|
+
const needGenInitFromSchema = typeAnnotation && (
|
|
258
|
+
!['primitive', 'union'].includes(typeAnnotation.typeKind)
|
|
259
|
+
|| typeAnnotation.typeName === 'DateTime'
|
|
260
|
+
);
|
|
261
|
+
let code = `${this.name} =`;
|
|
262
|
+
if (needGenInitFromSchema) {
|
|
263
|
+
code += `${context}.$genInitFromSchema('${typeAnnotation?.sortedTypeKey}',`;
|
|
264
|
+
}
|
|
265
|
+
const defaultValue = this.defaultValue;
|
|
266
|
+
const defaultValueType = Object.prototype.toString.call(defaultValue);
|
|
267
|
+
const { typeKind, typeNamespace, typeName } = typeAnnotation || {};
|
|
268
|
+
// 设置成null,才能同步给后端清除该值,但是null对checkbox组件是一种特殊状态
|
|
269
|
+
let parsedValue = defaultValue ?? undefined;
|
|
270
|
+
if (
|
|
271
|
+
defaultValueType === '[object String]'
|
|
272
|
+
&& (
|
|
273
|
+
!(typeKind === 'primitive' && typeNamespace === 'nasl.core' && ['String', 'Text', 'Email'].includes(typeName))
|
|
274
|
+
&& !(this.isEnum())
|
|
275
|
+
&& !['union'].includes(typeKind)
|
|
276
|
+
)
|
|
277
|
+
) {
|
|
278
|
+
// 一些特殊情况,特殊处理成undefined
|
|
279
|
+
// 1.defaultValue在nasl节点上错误得赋值给了空制符串
|
|
280
|
+
if ([''].includes(defaultValue)) {
|
|
281
|
+
parsedValue = undefined;
|
|
282
|
+
} else {
|
|
283
|
+
parsedValue = tryJSONParse(defaultValue) ?? defaultValue;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
code += JSON.stringify(parsedValue);
|
|
287
|
+
if (needGenInitFromSchema) {
|
|
288
|
+
code += `)`;
|
|
289
|
+
}
|
|
290
|
+
return code;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
@withSourceMap()
|
|
294
|
+
toEmbeddedTS(state?: TranslatorState): string {
|
|
295
|
+
let code = this.name;
|
|
296
|
+
if (this.typeAnnotation) {
|
|
297
|
+
code += ': ';
|
|
298
|
+
code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
|
|
299
|
+
// toTS暂时只需要翻译引用数据类型的,因为值都是字符串
|
|
300
|
+
// 就不在这里赋值了,这里单纯就为了快速查找
|
|
301
|
+
// 并且屏蔽了一些异常的错误
|
|
302
|
+
if (this.typeAnnotation?.typeKind !== 'primitive' && this.defaultValue) {
|
|
303
|
+
if (this.isEnum()) {
|
|
304
|
+
code += `= ${this.typeAnnotation.typeKey}['${this.defaultValue}']`;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return code;
|
|
309
|
+
}
|
|
310
|
+
isEnum() {
|
|
311
|
+
return this.typeAnnotation?.typeNamespace?.endsWith('.enums');
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* 生成宿主语言的文件路径
|
|
316
|
+
* @param name 一般不用传,用于 rename
|
|
317
|
+
*/
|
|
318
|
+
getEmbeddedFilePath(name = this.name) {
|
|
319
|
+
return `/embedded/${this.app.name}/Backend/${this.parentNode.name || 'backend'}/variables/${name}.ts`;
|
|
320
|
+
}
|
|
321
|
+
getNamespace() {
|
|
322
|
+
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
323
|
+
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
|
324
|
+
const parentName = this.parentNode.name;
|
|
325
|
+
const arr = [parentNamespace];
|
|
326
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
327
|
+
arr.push(parentName);
|
|
328
|
+
}
|
|
329
|
+
if (['App', 'Module', 'Namespace', 'Backend'].includes(this.parentNode?.concept) && this.parentKey === 'variables') {
|
|
330
|
+
// return `${arr.join('.')}.backendVariables`;
|
|
331
|
+
return `${arr.join('.')}.variables`;
|
|
332
|
+
} else {
|
|
333
|
+
return `${arr.join('.')}.variables`;
|
|
334
|
+
}
|
|
335
|
+
} else
|
|
336
|
+
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
337
|
+
}
|
|
338
|
+
toEmbeddedTSFile() {
|
|
339
|
+
let code = `namespace ${this.getNamespace()} {\n`;
|
|
340
|
+
code += `${indent(1)}export let `;
|
|
341
|
+
const state = createCompilerState(code, { tabSize: 1 });
|
|
342
|
+
try {
|
|
343
|
+
code += `${this.toEmbeddedTS(state)}\n`;
|
|
344
|
+
} catch (err) {
|
|
345
|
+
code += '\n';
|
|
346
|
+
}
|
|
347
|
+
code += '}\n';
|
|
348
|
+
|
|
349
|
+
return {
|
|
350
|
+
code,
|
|
351
|
+
filePath: this.getEmbeddedFilePath(),
|
|
352
|
+
sourceMap: state.sourceMap,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
@withSourceMap()
|
|
357
|
+
toEmbeddedTSInProcess(state?: TranslatorState): string {
|
|
358
|
+
let code = this.name;
|
|
359
|
+
if (this.typeAnnotation) {
|
|
360
|
+
code += ': undefined as ';
|
|
361
|
+
code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
|
|
362
|
+
}
|
|
363
|
+
// if (this.defaultValue) {
|
|
364
|
+
// code += `: ${this.defaultValue}`;
|
|
365
|
+
// }
|
|
366
|
+
return code;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* 设置数据类型
|
|
371
|
+
* @param typeAnnotation 类型标注对象
|
|
372
|
+
*/
|
|
373
|
+
async setDataType(typeAnnotation: TypeAnnotation): Promise<void>;
|
|
374
|
+
/**
|
|
375
|
+
* 设置数据类型
|
|
376
|
+
* @param typeAnnotation 类型唯一标识
|
|
377
|
+
*/
|
|
378
|
+
async setDataType(typeKey: string): Promise<void>;
|
|
379
|
+
async setDataType(typeAnnotation: TypeAnnotation | string) {
|
|
380
|
+
if (typeAnnotation) {
|
|
381
|
+
if (typeof typeAnnotation === 'string') {
|
|
382
|
+
typeAnnotation = dataTypesMap[typeAnnotation];
|
|
383
|
+
if (!typeAnnotation)
|
|
384
|
+
throw new Error('找不到类型:' + typeAnnotation);
|
|
385
|
+
} else {
|
|
386
|
+
typeAnnotation._delete?.();
|
|
387
|
+
const relationOptions = { parentId: this.id, parentConcept: this.concept, parentNode: this };
|
|
388
|
+
Object.assign(typeAnnotation, relationOptions);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// 处理下拉属性
|
|
392
|
+
try {
|
|
393
|
+
this.completionChildren = this.getSelectRef(typeAnnotation, true);
|
|
394
|
+
} catch (err) {
|
|
395
|
+
this.completionChildren = [];
|
|
396
|
+
console.log(err);
|
|
397
|
+
}
|
|
398
|
+
} else {
|
|
399
|
+
this.completionChildren = [];
|
|
400
|
+
}
|
|
401
|
+
const object: any = {
|
|
402
|
+
typeAnnotation: typeAnnotation || null,
|
|
403
|
+
};
|
|
404
|
+
// 切换类型的时候如果有默认值就清除掉
|
|
405
|
+
if (this.defaultValue) {
|
|
406
|
+
object.defaultValue = '';
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
return this.update({
|
|
410
|
+
...object,
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
async _setDataType(typeAnnotation: TypeAnnotation | string) {
|
|
416
|
+
if (typeAnnotation) {
|
|
417
|
+
if (typeof typeAnnotation === 'string') {
|
|
418
|
+
typeAnnotation = dataTypesMap[typeAnnotation];
|
|
419
|
+
if (!typeAnnotation)
|
|
420
|
+
throw new Error('找不到类型:' + typeAnnotation);
|
|
421
|
+
} else {
|
|
422
|
+
// typeAnnotation._delete?.();
|
|
423
|
+
const relationOptions = { parentId: this.id, parentConcept: this.concept, parentNode: this };
|
|
424
|
+
Object.assign(typeAnnotation, relationOptions);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// 处理下拉属性
|
|
428
|
+
try {
|
|
429
|
+
this.completionChildren = this.getSelectRef(typeAnnotation, true);
|
|
430
|
+
} catch (err) {
|
|
431
|
+
this.completionChildren = [];
|
|
432
|
+
console.log(err);
|
|
433
|
+
}
|
|
434
|
+
} else {
|
|
435
|
+
this.completionChildren = [];
|
|
436
|
+
}
|
|
437
|
+
const object: any = {
|
|
438
|
+
typeAnnotation: typeAnnotation || null,
|
|
439
|
+
};
|
|
440
|
+
// 切换类型的时候如果有默认值就清除掉
|
|
441
|
+
if (this.defaultValue) {
|
|
442
|
+
object.defaultValue = '';
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
public static getDefaultOptions() {
|
|
446
|
+
return {};
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* 是否可编辑
|
|
451
|
+
* */
|
|
452
|
+
get readonly() {
|
|
453
|
+
return !!this.module;
|
|
454
|
+
}
|
|
455
|
+
//================================================================================
|
|
456
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
457
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
458
|
+
//================================================================================
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
classMap.BackendVariable = BackendVariable;
|
|
462
|
+
export default BackendVariable;
|
|
463
|
+
//================================================================================
|
|
464
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
465
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
466
|
+
//================================================================================
|