@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,2165 @@
|
|
|
1
|
+
import { FrontendLibrary } from './FrontendLibrary__';
|
|
2
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState, embeddedTSEmitter } from '../translator';
|
|
3
|
+
import Namespace from './Namespace__';
|
|
4
|
+
import CallQueryComponent from './CallQueryComponent__';
|
|
5
|
+
import ForEachStatement from './ForEachStatement__';
|
|
6
|
+
import Assignment from './Assignment__';
|
|
7
|
+
import Identifier from './Identifier__';
|
|
8
|
+
import BindEvent from './BindEvent__';
|
|
9
|
+
import BatchAssignment from './BatchAssignment__';
|
|
10
|
+
import OqlQueryComponent from './OqlQueryComponent__';
|
|
11
|
+
import Match from './Match__';
|
|
12
|
+
import MatchCase from './MatchCase__';
|
|
13
|
+
import TypeAnnotation from './TypeAnnotation__';
|
|
14
|
+
import CallInterface from './CallInterface__';
|
|
15
|
+
import CallLogic from './CallLogic__';
|
|
16
|
+
import Logic from './Logic__';
|
|
17
|
+
|
|
18
|
+
//================================================================================
|
|
19
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
20
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
21
|
+
//================================================================================
|
|
22
|
+
import { EventPayload, Params } from '../common/EventEmitter';
|
|
23
|
+
import { concept, excludedInJSON, property } from '../decorators';
|
|
24
|
+
|
|
25
|
+
import * as utils from '../utils';
|
|
26
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
27
|
+
import BaseNode from '../common/BaseNode';
|
|
28
|
+
import classMap from '../common/classMap';
|
|
29
|
+
import Transactional from './Transactional__';
|
|
30
|
+
import TypeParam from './TypeParam__';
|
|
31
|
+
import Param from './Param__';
|
|
32
|
+
import Return from './Return__';
|
|
33
|
+
import Variable from './Variable__';
|
|
34
|
+
import LogicItem from './LogicItem__';
|
|
35
|
+
import Module from './Module__';
|
|
36
|
+
import View from './View__';
|
|
37
|
+
import ProcessElement from './ProcessElement__';
|
|
38
|
+
import App from './App__';
|
|
39
|
+
import Frontend from './Frontend__';
|
|
40
|
+
import Process from './Process__';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 逻辑
|
|
44
|
+
*/
|
|
45
|
+
@concept('逻辑')
|
|
46
|
+
export class OverriddenLogic extends BaseNode {
|
|
47
|
+
/**
|
|
48
|
+
* 产品概念
|
|
49
|
+
*/
|
|
50
|
+
@property()
|
|
51
|
+
concept: 'OverriddenLogic' = 'OverriddenLogic';
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* overriddenModule
|
|
55
|
+
*/
|
|
56
|
+
@property()
|
|
57
|
+
overriddenModule: string = undefined;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 逻辑名称
|
|
61
|
+
*/
|
|
62
|
+
@property()
|
|
63
|
+
name: string = undefined;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 逻辑描述
|
|
67
|
+
*/
|
|
68
|
+
@property()
|
|
69
|
+
description: string = undefined;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* triggerType
|
|
73
|
+
*/
|
|
74
|
+
@property()
|
|
75
|
+
triggerType: string = undefined;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* cron
|
|
79
|
+
*/
|
|
80
|
+
@property()
|
|
81
|
+
cron: string = undefined;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 事务
|
|
85
|
+
*/
|
|
86
|
+
@property('Transactional')
|
|
87
|
+
transactional: Transactional = undefined;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 编译器信息
|
|
91
|
+
*/
|
|
92
|
+
@property()
|
|
93
|
+
compilerInfoMap: { java?: { packageName: string, className: string } } = undefined;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 类型参数列表
|
|
97
|
+
*/
|
|
98
|
+
@property('TypeParam')
|
|
99
|
+
typeParams: Array<TypeParam> = null;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 输入参数列表
|
|
103
|
+
*/
|
|
104
|
+
@property('Param')
|
|
105
|
+
params: Array<Param> = [];
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 输出参数列表
|
|
109
|
+
*/
|
|
110
|
+
@property('Return')
|
|
111
|
+
returns: Array<Return> = [];
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 变量列表
|
|
115
|
+
*/
|
|
116
|
+
@property('Variable')
|
|
117
|
+
variables: Array<Variable> = [];
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 逻辑项列表
|
|
121
|
+
*/
|
|
122
|
+
@property('LogicItem')
|
|
123
|
+
body: Array<LogicItem> = [];
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 逻辑项列表
|
|
127
|
+
*/
|
|
128
|
+
@property('LogicItem')
|
|
129
|
+
playground: Array<LogicItem> = [];
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 祖先 Module
|
|
133
|
+
*/
|
|
134
|
+
get module() {
|
|
135
|
+
return this.getAncestor('Module') as Module;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 祖先 App
|
|
139
|
+
*/
|
|
140
|
+
get app() {
|
|
141
|
+
return this.getAncestor('App') as App;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 祖先 View
|
|
145
|
+
*/
|
|
146
|
+
get view() {
|
|
147
|
+
return this.getAncestor('View') as View;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* 祖先 Frontend
|
|
151
|
+
*/
|
|
152
|
+
get frontend() {
|
|
153
|
+
return this.getAncestor('Frontend') as Frontend;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* 祖先 ProcessElement
|
|
157
|
+
*/
|
|
158
|
+
get processElement() {
|
|
159
|
+
return this.getAncestor('ProcessElement') as ProcessElement;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* 祖先 Process
|
|
163
|
+
*/
|
|
164
|
+
get process() {
|
|
165
|
+
return this.getAncestor('Process') as Process;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @param source 需要合并的部分参数
|
|
170
|
+
*/
|
|
171
|
+
constructor(source?: Partial<OverriddenLogic>) {
|
|
172
|
+
source = Object.assign({}, OverriddenLogic.getDefaultOptions(), source);
|
|
173
|
+
super(source);
|
|
174
|
+
super.subConstructor(source);
|
|
175
|
+
}
|
|
176
|
+
getClassName() {
|
|
177
|
+
return 'OverriddenLogic';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
static from(source: any, parentNode?: any, parentKey?: string): OverriddenLogic {
|
|
181
|
+
return super.from(source, parentNode, parentKey) as OverriddenLogic;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* 从父级删除该节点
|
|
186
|
+
* @internal
|
|
187
|
+
*/
|
|
188
|
+
_delete() {
|
|
189
|
+
let params: Params = null;
|
|
190
|
+
if (this.parentNode) {
|
|
191
|
+
params = (this.parentNode as any)?.__removeOverriddenLogic?.(this);
|
|
192
|
+
}
|
|
193
|
+
return params;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* 设置overriddenModule
|
|
197
|
+
*/
|
|
198
|
+
setOverriddenModule(overriddenModule: string) {
|
|
199
|
+
const object = {
|
|
200
|
+
overriddenModule,
|
|
201
|
+
};
|
|
202
|
+
this.update({
|
|
203
|
+
...object,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 设置逻辑名称
|
|
209
|
+
*/
|
|
210
|
+
setName(name: string) {
|
|
211
|
+
const object = {
|
|
212
|
+
name,
|
|
213
|
+
};
|
|
214
|
+
this.update({
|
|
215
|
+
...object,
|
|
216
|
+
field: 'name',
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* 设置逻辑描述
|
|
222
|
+
*/
|
|
223
|
+
setDescription(description: string) {
|
|
224
|
+
const object = {
|
|
225
|
+
description,
|
|
226
|
+
};
|
|
227
|
+
this.update({
|
|
228
|
+
...object,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 设置triggerType
|
|
234
|
+
*/
|
|
235
|
+
setTriggerType(triggerType: string) {
|
|
236
|
+
const object = {
|
|
237
|
+
triggerType,
|
|
238
|
+
};
|
|
239
|
+
this.update({
|
|
240
|
+
...object,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* 设置cron
|
|
246
|
+
*/
|
|
247
|
+
setCron(cron: string) {
|
|
248
|
+
const object = {
|
|
249
|
+
cron,
|
|
250
|
+
};
|
|
251
|
+
this.update({
|
|
252
|
+
...object,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* 设置事务
|
|
258
|
+
*/
|
|
259
|
+
setTransactional(transactional: Transactional) {
|
|
260
|
+
transactional._delete();
|
|
261
|
+
const relationOptions = { parentNode: this, parentKey: 'transactional' };
|
|
262
|
+
Object.assign(transactional, relationOptions);
|
|
263
|
+
const object = {
|
|
264
|
+
transactional,
|
|
265
|
+
};
|
|
266
|
+
this.update({
|
|
267
|
+
...object,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
getTypeParamExistingNames(excludedList: Array<TypeParam> = []) {
|
|
272
|
+
const excludedSet = new Set(excludedList);
|
|
273
|
+
return ((this.typeParams as TypeParam[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
274
|
+
}
|
|
275
|
+
getTypeParamUniqueName(name = 'typeParam1') {
|
|
276
|
+
return utils.unique(name, this.getTypeParamExistingNames(), undefined, false);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 插入类型参数
|
|
281
|
+
* @internal
|
|
282
|
+
* @param name 类型参数名称,如果不填会自动生成一个唯一名称
|
|
283
|
+
*/
|
|
284
|
+
_insertTypeParamAt(name: string, index: number): TypeParam;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* 插入类型参数
|
|
288
|
+
* @internal
|
|
289
|
+
* @param typeParamOptions 类型参数参数
|
|
290
|
+
*/
|
|
291
|
+
_insertTypeParamAt(typeParamOptions: Partial<TypeParam>, index: number): TypeParam;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* 插入类型参数
|
|
295
|
+
* @internal
|
|
296
|
+
* @param typeParam 已有的类型参数实例
|
|
297
|
+
*/
|
|
298
|
+
_insertTypeParamAt(typeParam: TypeParam, index: number): TypeParam;
|
|
299
|
+
|
|
300
|
+
_insertTypeParamAt(options: string | Partial<TypeParam> | TypeParam, index: number) {
|
|
301
|
+
const typeParamOptions: any = {};
|
|
302
|
+
const relationOptions = { parentNode: this, parentKey: 'typeParams' };
|
|
303
|
+
let typeParam: TypeParam;
|
|
304
|
+
if (!options) {
|
|
305
|
+
typeParam = TypeParam.from({
|
|
306
|
+
...typeParamOptions,
|
|
307
|
+
name: this.getTypeParamUniqueName(),
|
|
308
|
+
}, this, 'typeParams');
|
|
309
|
+
} else if (typeof options === 'string') {
|
|
310
|
+
typeParam = TypeParam.from({
|
|
311
|
+
...typeParamOptions,
|
|
312
|
+
name: options,
|
|
313
|
+
}, this, 'typeParams');
|
|
314
|
+
} else if (options instanceof TypeParam) {
|
|
315
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
316
|
+
typeParam = options;
|
|
317
|
+
Object.assign(typeParam, relationOptions);
|
|
318
|
+
} else {
|
|
319
|
+
typeParam = TypeParam.from({
|
|
320
|
+
...typeParamOptions,
|
|
321
|
+
...options,
|
|
322
|
+
}, this, 'typeParams');
|
|
323
|
+
}
|
|
324
|
+
this.typeParams.splice(index, 0, typeParam);
|
|
325
|
+
return typeParam;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* 插入类型参数
|
|
330
|
+
* @param name 类型参数名称,如果不填会自动生成一个唯一名称
|
|
331
|
+
*/
|
|
332
|
+
insertTypeParamAt(name: string, index: number): TypeParam;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* 插入类型参数
|
|
336
|
+
* @param typeParamOptions 类型参数参数
|
|
337
|
+
*/
|
|
338
|
+
insertTypeParamAt(typeParamOptions: Partial<TypeParam>, index: number): TypeParam;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* 插入类型参数
|
|
342
|
+
* @param typeParam 已有的类型参数实例
|
|
343
|
+
*/
|
|
344
|
+
insertTypeParamAt(typeParam: TypeParam, index: number): TypeParam;
|
|
345
|
+
|
|
346
|
+
insertTypeParamAt(options: string | Partial<TypeParam> | TypeParam, index: number) {
|
|
347
|
+
const node = this._insertTypeParamAt(options as any, index);
|
|
348
|
+
node.create({
|
|
349
|
+
index,
|
|
350
|
+
parentNode: this,
|
|
351
|
+
parentKey: 'typeParams',
|
|
352
|
+
});
|
|
353
|
+
return node;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* 添加类型参数
|
|
358
|
+
* @internal
|
|
359
|
+
* @param name 类型参数名称,如果不填会自动生成一个唯一名称
|
|
360
|
+
*/
|
|
361
|
+
_addTypeParam(name?: string): TypeParam;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* 添加类型参数
|
|
365
|
+
* @internal
|
|
366
|
+
* @param typeParamOptions 类型参数参数
|
|
367
|
+
*/
|
|
368
|
+
_addTypeParam(typeParamOptions: Partial<TypeParam>): TypeParam;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* 添加类型参数
|
|
372
|
+
* @internal
|
|
373
|
+
* @param typeParam 已有的类型参数实例
|
|
374
|
+
*/
|
|
375
|
+
_addTypeParam(typeParam: TypeParam): TypeParam;
|
|
376
|
+
|
|
377
|
+
_addTypeParam(options?: string | Partial<TypeParam> | TypeParam) {
|
|
378
|
+
const index = this.typeParams.length;
|
|
379
|
+
return this._insertTypeParamAt(options as any, index);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* 添加类型参数
|
|
384
|
+
* @internal
|
|
385
|
+
* @param name 类型参数名称,如果不填会自动生成一个唯一名称
|
|
386
|
+
*/
|
|
387
|
+
addTypeParam(name?: string): TypeParam;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* 添加类型参数
|
|
391
|
+
* @param typeParamOptions 类型参数参数
|
|
392
|
+
*/
|
|
393
|
+
addTypeParam(typeParamOptions: Partial<TypeParam>): TypeParam;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* 添加类型参数
|
|
397
|
+
* @param typeParam 已有的类型参数实例
|
|
398
|
+
*/
|
|
399
|
+
addTypeParam(typeParam: TypeParam): TypeParam;
|
|
400
|
+
|
|
401
|
+
addTypeParam(options?: string | Partial<TypeParam> | TypeParam) {
|
|
402
|
+
const node = this._addTypeParam(options as any);
|
|
403
|
+
const index = this.typeParams.indexOf(node);
|
|
404
|
+
node.create({
|
|
405
|
+
index,
|
|
406
|
+
parentNode: this,
|
|
407
|
+
parentKey: 'typeParams',
|
|
408
|
+
});
|
|
409
|
+
return node;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
getParamUniqueName(name = 'param1') {
|
|
414
|
+
return utils.unique(name, this.getVarExistingNames(), undefined, false);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* 插入输入参数
|
|
419
|
+
* @internal
|
|
420
|
+
* @param name 输入参数名称,如果不填会自动生成一个唯一名称
|
|
421
|
+
*/
|
|
422
|
+
_insertParamAt(name: string, index: number): Param;
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* 插入输入参数
|
|
426
|
+
* @internal
|
|
427
|
+
* @param paramOptions 输入参数参数
|
|
428
|
+
*/
|
|
429
|
+
_insertParamAt(paramOptions: Partial<Param>, index: number): Param;
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* 插入输入参数
|
|
433
|
+
* @internal
|
|
434
|
+
* @param param 已有的输入参数实例
|
|
435
|
+
*/
|
|
436
|
+
_insertParamAt(param: Param, index: number): Param;
|
|
437
|
+
|
|
438
|
+
_insertParamAt(options: string | Partial<Param> | Param, index: number) {
|
|
439
|
+
const paramOptions: any = {};
|
|
440
|
+
const relationOptions = { parentNode: this, parentKey: 'params' };
|
|
441
|
+
let param: Param;
|
|
442
|
+
if (!options) {
|
|
443
|
+
param = Param.from({
|
|
444
|
+
...paramOptions,
|
|
445
|
+
name: this.getParamUniqueName(),
|
|
446
|
+
}, this, 'params');
|
|
447
|
+
} else if (typeof options === 'string') {
|
|
448
|
+
param = Param.from({
|
|
449
|
+
...paramOptions,
|
|
450
|
+
name: options,
|
|
451
|
+
}, this, 'params');
|
|
452
|
+
} else if (options instanceof Param) {
|
|
453
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
454
|
+
param = options;
|
|
455
|
+
Object.assign(param, relationOptions);
|
|
456
|
+
} else {
|
|
457
|
+
param = Param.from({
|
|
458
|
+
...paramOptions,
|
|
459
|
+
...options,
|
|
460
|
+
}, this, 'params');
|
|
461
|
+
}
|
|
462
|
+
this.params.splice(index, 0, param);
|
|
463
|
+
return param;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* 插入输入参数
|
|
468
|
+
* @param name 输入参数名称,如果不填会自动生成一个唯一名称
|
|
469
|
+
*/
|
|
470
|
+
insertParamAt(name: string, index: number): Param;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* 插入输入参数
|
|
474
|
+
* @param paramOptions 输入参数参数
|
|
475
|
+
*/
|
|
476
|
+
insertParamAt(paramOptions: Partial<Param>, index: number): Param;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* 插入输入参数
|
|
480
|
+
* @param param 已有的输入参数实例
|
|
481
|
+
*/
|
|
482
|
+
insertParamAt(param: Param, index: number): Param;
|
|
483
|
+
|
|
484
|
+
insertParamAt(options: string | Partial<Param> | Param, index: number) {
|
|
485
|
+
const node = this._insertParamAt(options as any, index);
|
|
486
|
+
node.create({
|
|
487
|
+
index,
|
|
488
|
+
parentNode: this,
|
|
489
|
+
parentKey: 'params',
|
|
490
|
+
});
|
|
491
|
+
return node;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* 添加输入参数
|
|
496
|
+
* @internal
|
|
497
|
+
* @param name 输入参数名称,如果不填会自动生成一个唯一名称
|
|
498
|
+
*/
|
|
499
|
+
_addParam(name?: string): Param;
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* 添加输入参数
|
|
503
|
+
* @internal
|
|
504
|
+
* @param paramOptions 输入参数参数
|
|
505
|
+
*/
|
|
506
|
+
_addParam(paramOptions: Partial<Param>): Param;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* 添加输入参数
|
|
510
|
+
* @internal
|
|
511
|
+
* @param param 已有的输入参数实例
|
|
512
|
+
*/
|
|
513
|
+
_addParam(param: Param): Param;
|
|
514
|
+
|
|
515
|
+
_addParam(options?: string | Partial<Param> | Param) {
|
|
516
|
+
const index = this.params.length;
|
|
517
|
+
return this._insertParamAt(options as any, index);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* 添加输入参数
|
|
522
|
+
* @internal
|
|
523
|
+
* @param name 输入参数名称,如果不填会自动生成一个唯一名称
|
|
524
|
+
*/
|
|
525
|
+
addParam(name?: string): Param;
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* 添加输入参数
|
|
529
|
+
* @param paramOptions 输入参数参数
|
|
530
|
+
*/
|
|
531
|
+
addParam(paramOptions: Partial<Param>): Param;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* 添加输入参数
|
|
535
|
+
* @param param 已有的输入参数实例
|
|
536
|
+
*/
|
|
537
|
+
addParam(param: Param): Param;
|
|
538
|
+
|
|
539
|
+
addParam(options?: string | Partial<Param> | Param) {
|
|
540
|
+
const node = this._addParam(options as any);
|
|
541
|
+
const index = this.params.indexOf(node);
|
|
542
|
+
node.create({
|
|
543
|
+
index,
|
|
544
|
+
parentNode: this,
|
|
545
|
+
parentKey: 'params',
|
|
546
|
+
});
|
|
547
|
+
return node;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
getReturnUniqueName(name = 'result') {
|
|
552
|
+
return utils.unique(name, this.getVarExistingNames(), undefined, false);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* 插入输出参数
|
|
557
|
+
* @internal
|
|
558
|
+
* @param name 输出参数名称,如果不填会自动生成一个唯一名称
|
|
559
|
+
*/
|
|
560
|
+
_insertReturnAt(name: string, index: number): Return;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* 插入输出参数
|
|
564
|
+
* @internal
|
|
565
|
+
* @param retOptions 输出参数参数
|
|
566
|
+
*/
|
|
567
|
+
_insertReturnAt(retOptions: Partial<Return>, index: number): Return;
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* 插入输出参数
|
|
571
|
+
* @internal
|
|
572
|
+
* @param ret 已有的输出参数实例
|
|
573
|
+
*/
|
|
574
|
+
_insertReturnAt(ret: Return, index: number): Return;
|
|
575
|
+
|
|
576
|
+
_insertReturnAt(options: string | Partial<Return> | Return, index: number) {
|
|
577
|
+
const retOptions: any = {};
|
|
578
|
+
const relationOptions = { parentNode: this, parentKey: 'returns' };
|
|
579
|
+
let ret: Return;
|
|
580
|
+
if (!options) {
|
|
581
|
+
ret = Return.from({
|
|
582
|
+
...retOptions,
|
|
583
|
+
name: this.getReturnUniqueName(),
|
|
584
|
+
}, this, 'returns');
|
|
585
|
+
} else if (typeof options === 'string') {
|
|
586
|
+
ret = Return.from({
|
|
587
|
+
...retOptions,
|
|
588
|
+
name: options,
|
|
589
|
+
}, this, 'returns');
|
|
590
|
+
} else if (options instanceof Return) {
|
|
591
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
592
|
+
ret = options;
|
|
593
|
+
Object.assign(ret, relationOptions);
|
|
594
|
+
} else {
|
|
595
|
+
ret = Return.from({
|
|
596
|
+
...retOptions,
|
|
597
|
+
...options,
|
|
598
|
+
}, this, 'returns');
|
|
599
|
+
}
|
|
600
|
+
this.returns.splice(index, 0, ret);
|
|
601
|
+
return ret;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* 插入输出参数
|
|
606
|
+
* @param name 输出参数名称,如果不填会自动生成一个唯一名称
|
|
607
|
+
*/
|
|
608
|
+
insertReturnAt(name: string, index: number): Return;
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* 插入输出参数
|
|
612
|
+
* @param retOptions 输出参数参数
|
|
613
|
+
*/
|
|
614
|
+
insertReturnAt(retOptions: Partial<Return>, index: number): Return;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* 插入输出参数
|
|
618
|
+
* @param ret 已有的输出参数实例
|
|
619
|
+
*/
|
|
620
|
+
insertReturnAt(ret: Return, index: number): Return;
|
|
621
|
+
|
|
622
|
+
insertReturnAt(options: string | Partial<Return> | Return, index: number) {
|
|
623
|
+
const node = this._insertReturnAt(options as any, index);
|
|
624
|
+
node.create({
|
|
625
|
+
index,
|
|
626
|
+
parentNode: this,
|
|
627
|
+
parentKey: 'returns',
|
|
628
|
+
});
|
|
629
|
+
return node;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* 添加输出参数
|
|
634
|
+
* @internal
|
|
635
|
+
* @param name 输出参数名称,如果不填会自动生成一个唯一名称
|
|
636
|
+
*/
|
|
637
|
+
_addReturn(name?: string): Return;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* 添加输出参数
|
|
641
|
+
* @internal
|
|
642
|
+
* @param retOptions 输出参数参数
|
|
643
|
+
*/
|
|
644
|
+
_addReturn(retOptions: Partial<Return>): Return;
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* 添加输出参数
|
|
648
|
+
* @internal
|
|
649
|
+
* @param ret 已有的输出参数实例
|
|
650
|
+
*/
|
|
651
|
+
_addReturn(ret: Return): Return;
|
|
652
|
+
|
|
653
|
+
_addReturn(options?: string | Partial<Return> | Return) {
|
|
654
|
+
const index = this.returns.length;
|
|
655
|
+
return this._insertReturnAt(options as any, index);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* 添加输出参数
|
|
660
|
+
* @internal
|
|
661
|
+
* @param name 输出参数名称,如果不填会自动生成一个唯一名称
|
|
662
|
+
*/
|
|
663
|
+
addReturn(name?: string): Return;
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* 添加输出参数
|
|
667
|
+
* @param retOptions 输出参数参数
|
|
668
|
+
*/
|
|
669
|
+
addReturn(retOptions: Partial<Return>): Return;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* 添加输出参数
|
|
673
|
+
* @param ret 已有的输出参数实例
|
|
674
|
+
*/
|
|
675
|
+
addReturn(ret: Return): Return;
|
|
676
|
+
|
|
677
|
+
addReturn(options?: string | Partial<Return> | Return) {
|
|
678
|
+
const node = this._addReturn(options as any);
|
|
679
|
+
const index = this.returns.indexOf(node);
|
|
680
|
+
node.create({
|
|
681
|
+
index,
|
|
682
|
+
parentNode: this,
|
|
683
|
+
parentKey: 'returns',
|
|
684
|
+
});
|
|
685
|
+
return node;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
getVariableUniqueName(name = 'variable1') {
|
|
690
|
+
return utils.unique(name, this.getVarExistingNames(), undefined, false);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* 插入变量
|
|
695
|
+
* @internal
|
|
696
|
+
* @param name 变量名称,如果不填会自动生成一个唯一名称
|
|
697
|
+
*/
|
|
698
|
+
_insertVariableAt(name: string, index: number): Variable;
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* 插入变量
|
|
702
|
+
* @internal
|
|
703
|
+
* @param variableOptions 变量参数
|
|
704
|
+
*/
|
|
705
|
+
_insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* 插入变量
|
|
709
|
+
* @internal
|
|
710
|
+
* @param variable 已有的变量实例
|
|
711
|
+
*/
|
|
712
|
+
_insertVariableAt(variable: Variable, index: number): Variable;
|
|
713
|
+
|
|
714
|
+
_insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
|
|
715
|
+
const variableOptions: any = {};
|
|
716
|
+
const relationOptions = { parentNode: this, parentKey: 'variables' };
|
|
717
|
+
let variable: Variable;
|
|
718
|
+
if (!options) {
|
|
719
|
+
variable = Variable.from({
|
|
720
|
+
...variableOptions,
|
|
721
|
+
name: this.getVariableUniqueName(),
|
|
722
|
+
}, this, 'variables');
|
|
723
|
+
} else if (typeof options === 'string') {
|
|
724
|
+
variable = Variable.from({
|
|
725
|
+
...variableOptions,
|
|
726
|
+
name: options,
|
|
727
|
+
}, this, 'variables');
|
|
728
|
+
} else if (options instanceof Variable) {
|
|
729
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
730
|
+
variable = options;
|
|
731
|
+
Object.assign(variable, relationOptions);
|
|
732
|
+
} else {
|
|
733
|
+
variable = Variable.from({
|
|
734
|
+
...variableOptions,
|
|
735
|
+
...options,
|
|
736
|
+
}, this, 'variables');
|
|
737
|
+
}
|
|
738
|
+
this.variables.splice(index, 0, variable);
|
|
739
|
+
return variable;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* 插入变量
|
|
744
|
+
* @param name 变量名称,如果不填会自动生成一个唯一名称
|
|
745
|
+
*/
|
|
746
|
+
insertVariableAt(name: string, index: number): Variable;
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* 插入变量
|
|
750
|
+
* @param variableOptions 变量参数
|
|
751
|
+
*/
|
|
752
|
+
insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* 插入变量
|
|
756
|
+
* @param variable 已有的变量实例
|
|
757
|
+
*/
|
|
758
|
+
insertVariableAt(variable: Variable, index: number): Variable;
|
|
759
|
+
|
|
760
|
+
insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
|
|
761
|
+
const node = this._insertVariableAt(options as any, index);
|
|
762
|
+
node.create({
|
|
763
|
+
index,
|
|
764
|
+
parentNode: this,
|
|
765
|
+
parentKey: 'variables',
|
|
766
|
+
});
|
|
767
|
+
return node;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* 添加变量
|
|
772
|
+
* @internal
|
|
773
|
+
* @param name 变量名称,如果不填会自动生成一个唯一名称
|
|
774
|
+
*/
|
|
775
|
+
_addVariable(name?: string): Variable;
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* 添加变量
|
|
779
|
+
* @internal
|
|
780
|
+
* @param variableOptions 变量参数
|
|
781
|
+
*/
|
|
782
|
+
_addVariable(variableOptions: Partial<Variable>): Variable;
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* 添加变量
|
|
786
|
+
* @internal
|
|
787
|
+
* @param variable 已有的变量实例
|
|
788
|
+
*/
|
|
789
|
+
_addVariable(variable: Variable): Variable;
|
|
790
|
+
|
|
791
|
+
_addVariable(options?: string | Partial<Variable> | Variable) {
|
|
792
|
+
const index = this.variables.length;
|
|
793
|
+
return this._insertVariableAt(options as any, index);
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* 添加变量
|
|
798
|
+
* @internal
|
|
799
|
+
* @param name 变量名称,如果不填会自动生成一个唯一名称
|
|
800
|
+
*/
|
|
801
|
+
addVariable(name?: string): Variable;
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* 添加变量
|
|
805
|
+
* @param variableOptions 变量参数
|
|
806
|
+
*/
|
|
807
|
+
addVariable(variableOptions: Partial<Variable>): Variable;
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* 添加变量
|
|
811
|
+
* @param variable 已有的变量实例
|
|
812
|
+
*/
|
|
813
|
+
addVariable(variable: Variable): Variable;
|
|
814
|
+
|
|
815
|
+
addVariable(options?: string | Partial<Variable> | Variable) {
|
|
816
|
+
const node = this._addVariable(options as any);
|
|
817
|
+
const index = this.variables.indexOf(node);
|
|
818
|
+
node.create({
|
|
819
|
+
index,
|
|
820
|
+
parentNode: this,
|
|
821
|
+
parentKey: 'variables',
|
|
822
|
+
});
|
|
823
|
+
return node;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* 插入逻辑项
|
|
833
|
+
* @internal
|
|
834
|
+
* @param logicItemOptions 逻辑项参数
|
|
835
|
+
*/
|
|
836
|
+
_insertItemInBodyAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* 插入逻辑项
|
|
840
|
+
* @internal
|
|
841
|
+
* @param logicItem 已有的逻辑项实例
|
|
842
|
+
*/
|
|
843
|
+
_insertItemInBodyAt(logicItem: LogicItem, index: number): LogicItem;
|
|
844
|
+
|
|
845
|
+
_insertItemInBodyAt(options: Partial<LogicItem> | LogicItem, index: number) {
|
|
846
|
+
const logicItemOptions: any = {};
|
|
847
|
+
const relationOptions = { parentNode: this, parentKey: 'body' };
|
|
848
|
+
let logicItem: LogicItem;
|
|
849
|
+
if (options instanceof LogicItem) {
|
|
850
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
851
|
+
logicItem = options;
|
|
852
|
+
Object.assign(logicItem, relationOptions);
|
|
853
|
+
} else {
|
|
854
|
+
logicItem = LogicItem.from({
|
|
855
|
+
...logicItemOptions,
|
|
856
|
+
...options,
|
|
857
|
+
}, this, 'body');
|
|
858
|
+
}
|
|
859
|
+
this.body.splice(index, 0, logicItem);
|
|
860
|
+
return logicItem;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* 插入逻辑项
|
|
867
|
+
* @param logicItemOptions 逻辑项参数
|
|
868
|
+
*/
|
|
869
|
+
insertItemInBodyAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* 插入逻辑项
|
|
873
|
+
* @param logicItem 已有的逻辑项实例
|
|
874
|
+
*/
|
|
875
|
+
insertItemInBodyAt(logicItem: LogicItem, index: number): LogicItem;
|
|
876
|
+
|
|
877
|
+
insertItemInBodyAt(options: Partial<LogicItem> | LogicItem, index: number) {
|
|
878
|
+
const node = this._insertItemInBodyAt(options as any, index);
|
|
879
|
+
node.create({
|
|
880
|
+
index,
|
|
881
|
+
parentNode: this,
|
|
882
|
+
parentKey: 'body',
|
|
883
|
+
});
|
|
884
|
+
return node;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* 添加逻辑项
|
|
891
|
+
* @internal
|
|
892
|
+
* @param logicItemOptions 逻辑项参数
|
|
893
|
+
*/
|
|
894
|
+
_addItemInBody(logicItemOptions: Partial<LogicItem>): LogicItem;
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* 添加逻辑项
|
|
898
|
+
* @internal
|
|
899
|
+
* @param logicItem 已有的逻辑项实例
|
|
900
|
+
*/
|
|
901
|
+
_addItemInBody(logicItem: LogicItem): LogicItem;
|
|
902
|
+
|
|
903
|
+
_addItemInBody(options?: Partial<LogicItem> | LogicItem) {
|
|
904
|
+
const index = this.body.length;
|
|
905
|
+
return this._insertItemInBodyAt(options as any, index);
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* 添加逻辑项
|
|
912
|
+
* @param logicItemOptions 逻辑项参数
|
|
913
|
+
*/
|
|
914
|
+
addItemInBody(logicItemOptions: Partial<LogicItem>): LogicItem;
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* 添加逻辑项
|
|
918
|
+
* @param logicItem 已有的逻辑项实例
|
|
919
|
+
*/
|
|
920
|
+
addItemInBody(logicItem: LogicItem): LogicItem;
|
|
921
|
+
|
|
922
|
+
addItemInBody(options?: Partial<LogicItem> | LogicItem) {
|
|
923
|
+
const node = this._addItemInBody(options as any);
|
|
924
|
+
const index = this.body.indexOf(node);
|
|
925
|
+
node.create({
|
|
926
|
+
index,
|
|
927
|
+
parentNode: this,
|
|
928
|
+
parentKey: 'body',
|
|
929
|
+
});
|
|
930
|
+
return node;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* 插入逻辑项
|
|
937
|
+
* @internal
|
|
938
|
+
* @param logicItemOptions 逻辑项参数
|
|
939
|
+
*/
|
|
940
|
+
_insertItemInPlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* 插入逻辑项
|
|
944
|
+
* @internal
|
|
945
|
+
* @param logicItem 已有的逻辑项实例
|
|
946
|
+
*/
|
|
947
|
+
_insertItemInPlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
|
|
948
|
+
|
|
949
|
+
_insertItemInPlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
|
|
950
|
+
const logicItemOptions: any = {};
|
|
951
|
+
const relationOptions = { parentNode: this, parentKey: 'playground' };
|
|
952
|
+
let logicItem: LogicItem;
|
|
953
|
+
if (options instanceof LogicItem) {
|
|
954
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
955
|
+
logicItem = options;
|
|
956
|
+
Object.assign(logicItem, relationOptions);
|
|
957
|
+
} else {
|
|
958
|
+
logicItem = LogicItem.from({
|
|
959
|
+
...logicItemOptions,
|
|
960
|
+
...options,
|
|
961
|
+
}, this, 'playground');
|
|
962
|
+
}
|
|
963
|
+
this.playground.splice(index, 0, logicItem);
|
|
964
|
+
return logicItem;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* 插入逻辑项
|
|
971
|
+
* @param logicItemOptions 逻辑项参数
|
|
972
|
+
*/
|
|
973
|
+
insertItemInPlaygroundAt(logicItemOptions: Partial<LogicItem>, index: number): LogicItem;
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* 插入逻辑项
|
|
977
|
+
* @param logicItem 已有的逻辑项实例
|
|
978
|
+
*/
|
|
979
|
+
insertItemInPlaygroundAt(logicItem: LogicItem, index: number): LogicItem;
|
|
980
|
+
|
|
981
|
+
insertItemInPlaygroundAt(options: Partial<LogicItem> | LogicItem, index: number) {
|
|
982
|
+
const node = this._insertItemInPlaygroundAt(options as any, index);
|
|
983
|
+
node.create({
|
|
984
|
+
index,
|
|
985
|
+
parentNode: this,
|
|
986
|
+
parentKey: 'playground',
|
|
987
|
+
});
|
|
988
|
+
return node;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* 添加逻辑项
|
|
995
|
+
* @internal
|
|
996
|
+
* @param logicItemOptions 逻辑项参数
|
|
997
|
+
*/
|
|
998
|
+
_addItemInPlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* 添加逻辑项
|
|
1002
|
+
* @internal
|
|
1003
|
+
* @param logicItem 已有的逻辑项实例
|
|
1004
|
+
*/
|
|
1005
|
+
_addItemInPlayground(logicItem: LogicItem): LogicItem;
|
|
1006
|
+
|
|
1007
|
+
_addItemInPlayground(options?: Partial<LogicItem> | LogicItem) {
|
|
1008
|
+
const index = this.playground.length;
|
|
1009
|
+
return this._insertItemInPlaygroundAt(options as any, index);
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* 添加逻辑项
|
|
1016
|
+
* @param logicItemOptions 逻辑项参数
|
|
1017
|
+
*/
|
|
1018
|
+
addItemInPlayground(logicItemOptions: Partial<LogicItem>): LogicItem;
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* 添加逻辑项
|
|
1022
|
+
* @param logicItem 已有的逻辑项实例
|
|
1023
|
+
*/
|
|
1024
|
+
addItemInPlayground(logicItem: LogicItem): LogicItem;
|
|
1025
|
+
|
|
1026
|
+
addItemInPlayground(options?: Partial<LogicItem> | LogicItem) {
|
|
1027
|
+
const node = this._addItemInPlayground(options as any);
|
|
1028
|
+
const index = this.playground.indexOf(node);
|
|
1029
|
+
node.create({
|
|
1030
|
+
index,
|
|
1031
|
+
parentNode: this,
|
|
1032
|
+
parentKey: 'playground',
|
|
1033
|
+
});
|
|
1034
|
+
return node;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* 删除事务
|
|
1042
|
+
* @param name 事务名称
|
|
1043
|
+
*/
|
|
1044
|
+
removeTransactional(name: string): void;
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* 删除事务
|
|
1048
|
+
* @param transactional 已有的事务实例
|
|
1049
|
+
*/
|
|
1050
|
+
removeTransactional(transactional: Transactional): void;
|
|
1051
|
+
|
|
1052
|
+
removeTransactional(options: string | Transactional) {
|
|
1053
|
+
let transactional: Transactional;
|
|
1054
|
+
if (typeof options === 'string') {
|
|
1055
|
+
transactional = this.transactional;
|
|
1056
|
+
if (!transactional) {
|
|
1057
|
+
throw new Error('找不到事务 ' + options);
|
|
1058
|
+
}
|
|
1059
|
+
} else {
|
|
1060
|
+
transactional = options;
|
|
1061
|
+
}
|
|
1062
|
+
return transactional.delete();
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
__removeTransactional(transactional: Transactional) {
|
|
1066
|
+
const parentKey = transactional.parentKey;
|
|
1067
|
+
const params: Params = {
|
|
1068
|
+
parentNode: this,
|
|
1069
|
+
parentKey,
|
|
1070
|
+
index: -1,
|
|
1071
|
+
object: null,
|
|
1072
|
+
oldObject: transactional,
|
|
1073
|
+
};
|
|
1074
|
+
if (parentKey) {
|
|
1075
|
+
params.parentKey = parentKey;
|
|
1076
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
1077
|
+
const index = (this as any)[parentKey].indexOf(transactional);
|
|
1078
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
1079
|
+
params.index = index;
|
|
1080
|
+
} else if ((this as any)[parentKey] === transactional) {
|
|
1081
|
+
params.index = 0;
|
|
1082
|
+
(this as any)[parentKey] = undefined;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
return params;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* 删除类型参数
|
|
1092
|
+
* @param name 类型参数名称
|
|
1093
|
+
*/
|
|
1094
|
+
removeTypeParam(name: string): void;
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* 删除类型参数
|
|
1098
|
+
* @param typeParam 已有的类型参数实例
|
|
1099
|
+
*/
|
|
1100
|
+
removeTypeParam(typeParam: TypeParam): void;
|
|
1101
|
+
|
|
1102
|
+
removeTypeParam(options: string | TypeParam) {
|
|
1103
|
+
let typeParam: TypeParam;
|
|
1104
|
+
if (typeof options === 'string') {
|
|
1105
|
+
typeParam = (this.typeParams as TypeParam[]).find((item) => item.name === options);
|
|
1106
|
+
if (!typeParam) {
|
|
1107
|
+
throw new Error('找不到类型参数 ' + options);
|
|
1108
|
+
}
|
|
1109
|
+
} else {
|
|
1110
|
+
typeParam = options;
|
|
1111
|
+
}
|
|
1112
|
+
return typeParam.delete();
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
__removeTypeParam(typeParam: TypeParam) {
|
|
1116
|
+
const parentKey = typeParam.parentKey;
|
|
1117
|
+
const params: Params = {
|
|
1118
|
+
parentNode: this,
|
|
1119
|
+
parentKey,
|
|
1120
|
+
index: -1,
|
|
1121
|
+
object: null,
|
|
1122
|
+
oldObject: typeParam,
|
|
1123
|
+
};
|
|
1124
|
+
if (parentKey) {
|
|
1125
|
+
params.parentKey = parentKey;
|
|
1126
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
1127
|
+
const index = (this as any)[parentKey].indexOf(typeParam);
|
|
1128
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
1129
|
+
params.index = index;
|
|
1130
|
+
} else if ((this as any)[parentKey] === typeParam) {
|
|
1131
|
+
params.index = 0;
|
|
1132
|
+
(this as any)[parentKey] = undefined;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
return params;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* 删除输入参数
|
|
1142
|
+
* @param name 输入参数名称
|
|
1143
|
+
*/
|
|
1144
|
+
removeParam(name: string): void;
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* 删除输入参数
|
|
1148
|
+
* @param param 已有的输入参数实例
|
|
1149
|
+
*/
|
|
1150
|
+
removeParam(param: Param): void;
|
|
1151
|
+
|
|
1152
|
+
removeParam(options: string | Param) {
|
|
1153
|
+
let param: Param;
|
|
1154
|
+
if (typeof options === 'string') {
|
|
1155
|
+
param = (this.params as Param[]).find((item) => item.name === options);
|
|
1156
|
+
if (!param) {
|
|
1157
|
+
throw new Error('找不到输入参数 ' + options);
|
|
1158
|
+
}
|
|
1159
|
+
} else {
|
|
1160
|
+
param = options;
|
|
1161
|
+
}
|
|
1162
|
+
return param.delete();
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
__removeParam(param: Param) {
|
|
1166
|
+
const parentKey = param.parentKey;
|
|
1167
|
+
const params: Params = {
|
|
1168
|
+
parentNode: this,
|
|
1169
|
+
parentKey,
|
|
1170
|
+
index: -1,
|
|
1171
|
+
object: null,
|
|
1172
|
+
oldObject: param,
|
|
1173
|
+
};
|
|
1174
|
+
if (parentKey) {
|
|
1175
|
+
params.parentKey = parentKey;
|
|
1176
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
1177
|
+
const index = (this as any)[parentKey].indexOf(param);
|
|
1178
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
1179
|
+
params.index = index;
|
|
1180
|
+
} else if ((this as any)[parentKey] === param) {
|
|
1181
|
+
params.index = 0;
|
|
1182
|
+
(this as any)[parentKey] = undefined;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
return params;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
/**
|
|
1191
|
+
* 删除输出参数
|
|
1192
|
+
* @param name 输出参数名称
|
|
1193
|
+
*/
|
|
1194
|
+
removeReturn(name: string): void;
|
|
1195
|
+
|
|
1196
|
+
/**
|
|
1197
|
+
* 删除输出参数
|
|
1198
|
+
* @param ret 已有的输出参数实例
|
|
1199
|
+
*/
|
|
1200
|
+
removeReturn(ret: Return): void;
|
|
1201
|
+
|
|
1202
|
+
removeReturn(options: string | Return) {
|
|
1203
|
+
let ret: Return;
|
|
1204
|
+
if (typeof options === 'string') {
|
|
1205
|
+
ret = (this.returns as Return[]).find((item) => item.name === options);
|
|
1206
|
+
if (!ret) {
|
|
1207
|
+
throw new Error('找不到输出参数 ' + options);
|
|
1208
|
+
}
|
|
1209
|
+
} else {
|
|
1210
|
+
ret = options;
|
|
1211
|
+
}
|
|
1212
|
+
return ret.delete();
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
__removeReturn(ret: Return) {
|
|
1216
|
+
const parentKey = ret.parentKey;
|
|
1217
|
+
const params: Params = {
|
|
1218
|
+
parentNode: this,
|
|
1219
|
+
parentKey,
|
|
1220
|
+
index: -1,
|
|
1221
|
+
object: null,
|
|
1222
|
+
oldObject: ret,
|
|
1223
|
+
};
|
|
1224
|
+
if (parentKey) {
|
|
1225
|
+
params.parentKey = parentKey;
|
|
1226
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
1227
|
+
const index = (this as any)[parentKey].indexOf(ret);
|
|
1228
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
1229
|
+
params.index = index;
|
|
1230
|
+
} else if ((this as any)[parentKey] === ret) {
|
|
1231
|
+
params.index = 0;
|
|
1232
|
+
(this as any)[parentKey] = undefined;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
return params;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* 删除变量
|
|
1242
|
+
* @param name 变量名称
|
|
1243
|
+
*/
|
|
1244
|
+
removeVariable(name: string): void;
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* 删除变量
|
|
1248
|
+
* @param variable 已有的变量实例
|
|
1249
|
+
*/
|
|
1250
|
+
removeVariable(variable: Variable): void;
|
|
1251
|
+
|
|
1252
|
+
removeVariable(options: string | Variable) {
|
|
1253
|
+
let variable: Variable;
|
|
1254
|
+
if (typeof options === 'string') {
|
|
1255
|
+
variable = (this.variables as Variable[]).find((item) => item.name === options);
|
|
1256
|
+
if (!variable) {
|
|
1257
|
+
throw new Error('找不到变量 ' + options);
|
|
1258
|
+
}
|
|
1259
|
+
} else {
|
|
1260
|
+
variable = options;
|
|
1261
|
+
}
|
|
1262
|
+
return variable.delete();
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
__removeVariable(variable: Variable) {
|
|
1266
|
+
const parentKey = variable.parentKey;
|
|
1267
|
+
const params: Params = {
|
|
1268
|
+
parentNode: this,
|
|
1269
|
+
parentKey,
|
|
1270
|
+
index: -1,
|
|
1271
|
+
object: null,
|
|
1272
|
+
oldObject: variable,
|
|
1273
|
+
};
|
|
1274
|
+
if (parentKey) {
|
|
1275
|
+
params.parentKey = parentKey;
|
|
1276
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
1277
|
+
const index = (this as any)[parentKey].indexOf(variable);
|
|
1278
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
1279
|
+
params.index = index;
|
|
1280
|
+
} else if ((this as any)[parentKey] === variable) {
|
|
1281
|
+
params.index = 0;
|
|
1282
|
+
(this as any)[parentKey] = undefined;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
return params;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* 删除逻辑项
|
|
1292
|
+
* @param logicItem 已有的逻辑项实例
|
|
1293
|
+
*/
|
|
1294
|
+
removeItemInBody(logicItem: LogicItem): void;
|
|
1295
|
+
|
|
1296
|
+
removeItemInBody(options: LogicItem) {
|
|
1297
|
+
let logicItem: LogicItem = options;
|
|
1298
|
+
return logicItem.delete();
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
/**
|
|
1304
|
+
* 删除逻辑项
|
|
1305
|
+
* @param logicItem 已有的逻辑项实例
|
|
1306
|
+
*/
|
|
1307
|
+
removeItemInPlayground(logicItem: LogicItem): void;
|
|
1308
|
+
|
|
1309
|
+
removeItemInPlayground(options: LogicItem) {
|
|
1310
|
+
let logicItem: LogicItem = options;
|
|
1311
|
+
return logicItem.delete();
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
__removeLogicItem(logicItem: LogicItem) {
|
|
1315
|
+
const parentKey = logicItem.parentKey;
|
|
1316
|
+
const params: Params = {
|
|
1317
|
+
parentNode: this,
|
|
1318
|
+
parentKey,
|
|
1319
|
+
index: -1,
|
|
1320
|
+
object: null,
|
|
1321
|
+
oldObject: logicItem,
|
|
1322
|
+
};
|
|
1323
|
+
if (parentKey) {
|
|
1324
|
+
params.parentKey = parentKey;
|
|
1325
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
1326
|
+
const index = (this as any)[parentKey].indexOf(logicItem);
|
|
1327
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
1328
|
+
params.index = index;
|
|
1329
|
+
} else if ((this as any)[parentKey] === logicItem) {
|
|
1330
|
+
params.index = 0;
|
|
1331
|
+
(this as any)[parentKey] = undefined;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
return params;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
//================================================================================
|
|
1338
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
1339
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
1340
|
+
//================================================================================
|
|
1341
|
+
// 用于calllogic树中定位是那个logic,回显
|
|
1342
|
+
get calleewholeKey() {
|
|
1343
|
+
return this.getNamespace() + '.' + this.name;
|
|
1344
|
+
}
|
|
1345
|
+
// 设置定时任务
|
|
1346
|
+
setCronAndTriggerType(cron: string, triggerType: string) {
|
|
1347
|
+
const object = {
|
|
1348
|
+
cron,
|
|
1349
|
+
triggerType,
|
|
1350
|
+
};
|
|
1351
|
+
this.update({
|
|
1352
|
+
...object,
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* 创建的时候 打开事务 通过开关设置数据库事务
|
|
1358
|
+
*/
|
|
1359
|
+
openTransactional(flag: boolean) {
|
|
1360
|
+
if (flag) {
|
|
1361
|
+
const transactional = new Transactional({
|
|
1362
|
+
enabled: flag,
|
|
1363
|
+
});
|
|
1364
|
+
transactional._delete();
|
|
1365
|
+
const relationOptions = { parentNode: this, parentKey: 'transactional' };
|
|
1366
|
+
Object.assign(transactional, relationOptions);
|
|
1367
|
+
this.transactional = transactional;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
findLogicItemByConcept(concept: string) {
|
|
1371
|
+
let result: any;
|
|
1372
|
+
|
|
1373
|
+
utils.traverse((current) => {
|
|
1374
|
+
if ((current.node as any).concept === concept)
|
|
1375
|
+
return (result = current.node);
|
|
1376
|
+
}, { node: this }, {
|
|
1377
|
+
mode: 'anyObject',
|
|
1378
|
+
excludedKeySet: this.JSON_EXCLUDED_KEYS,
|
|
1379
|
+
});
|
|
1380
|
+
|
|
1381
|
+
return result as LogicItem;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
onChange($event?: EventPayload): void {
|
|
1385
|
+
this.emit('change', $event);
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
getVarExistingNames(excludedList: Array<Param | Return | Variable> = []) {
|
|
1389
|
+
const excludedSet = new Set(excludedList);
|
|
1390
|
+
const varList: any[] = [];
|
|
1391
|
+
if (Array.isArray(this.params)) {
|
|
1392
|
+
varList.push(...this.params);
|
|
1393
|
+
}
|
|
1394
|
+
if (Array.isArray(this.returns)) {
|
|
1395
|
+
varList.push(...this.returns);
|
|
1396
|
+
}
|
|
1397
|
+
if (Array.isArray(this.variables)) {
|
|
1398
|
+
varList.push(...this.variables);
|
|
1399
|
+
}
|
|
1400
|
+
if (this.view) {
|
|
1401
|
+
if (Array.isArray(this.view.params)) {
|
|
1402
|
+
varList.push(...this.view.params);
|
|
1403
|
+
}
|
|
1404
|
+
if (Array.isArray(this.view.variables)) {
|
|
1405
|
+
varList.push(...this.view.variables);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
this.traverseChildren((el) => {
|
|
1410
|
+
if (el?.concept === 'ForEachStatement') {
|
|
1411
|
+
if ((el as ForEachStatement)?.item) {
|
|
1412
|
+
varList.push((el as ForEachStatement)?.item);
|
|
1413
|
+
}
|
|
1414
|
+
if ((el as ForEachStatement)?.index) {
|
|
1415
|
+
varList.push((el as ForEachStatement)?.index);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1419
|
+
return varList.filter((item) => !excludedSet.has(item)).map((item) => item?.name);
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
toJSContent(code: string, state?: TranslatorState): string {
|
|
1423
|
+
// params
|
|
1424
|
+
if (Array.isArray(this.params)) {
|
|
1425
|
+
this.params.forEach((param) => {
|
|
1426
|
+
code += indent((state?.tabSize || 0) + 1) + '';
|
|
1427
|
+
code += param.toJS(shiftState(state, code, { inline: true }));
|
|
1428
|
+
code += ';\n';
|
|
1429
|
+
});
|
|
1430
|
+
}
|
|
1431
|
+
// variables
|
|
1432
|
+
if (Array.isArray(this.variables)) {
|
|
1433
|
+
this.variables.forEach((variable) => {
|
|
1434
|
+
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
1435
|
+
code += variable.toJS(shiftState(state, code, { inline: true }));
|
|
1436
|
+
code += ';\n';
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
// returns
|
|
1441
|
+
if (Array.isArray(this.returns)) {
|
|
1442
|
+
this.returns.forEach((ret) => {
|
|
1443
|
+
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
1444
|
+
code += ret.toJS(shiftState(state, code, { inline: true }));
|
|
1445
|
+
code += ';\n';
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
if (Array.isArray(this.body)) {
|
|
1449
|
+
this.body.forEach((item) => {
|
|
1450
|
+
code += item.toJS && item.toJS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1451
|
+
code += '\n';
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
return code;
|
|
1456
|
+
}
|
|
1457
|
+
toJS(state?: TranslatorState, type?: string): string {
|
|
1458
|
+
let code = '';
|
|
1459
|
+
if (type === 'IIFE') {
|
|
1460
|
+
code += `await (async () => {\n`;
|
|
1461
|
+
code = this.toJSContent(code, state);
|
|
1462
|
+
code += indent(state?.tabSize || 0) + '})();\n';
|
|
1463
|
+
return code;
|
|
1464
|
+
}
|
|
1465
|
+
code += `async ${this.name} (`;
|
|
1466
|
+
|
|
1467
|
+
if (this.params?.length) {
|
|
1468
|
+
this.params.forEach((param, index) => {
|
|
1469
|
+
code += param.name;
|
|
1470
|
+
if (index !== this.params.length - 1)
|
|
1471
|
+
code += ', ';
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
code += ') {\n';
|
|
1475
|
+
|
|
1476
|
+
code = this.toJSContent(code, state);
|
|
1477
|
+
code += indent(state?.tabSize || 0) + '}\n';
|
|
1478
|
+
return code;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
toProcessService() {
|
|
1482
|
+
return {
|
|
1483
|
+
config: {
|
|
1484
|
+
serviceType: 'micro',
|
|
1485
|
+
},
|
|
1486
|
+
url: {
|
|
1487
|
+
method: 'POST',
|
|
1488
|
+
path: this.getPath(),
|
|
1489
|
+
},
|
|
1490
|
+
};
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
toService() {
|
|
1494
|
+
const parentNode = this.parentNode;
|
|
1495
|
+
const { concept, name: entityName } = parentNode || {};
|
|
1496
|
+
const logicName = this.name;
|
|
1497
|
+
let serviceType = 'micro';
|
|
1498
|
+
let method = 'POST';
|
|
1499
|
+
// let path = `/api/${logicName}`;
|
|
1500
|
+
const map: Record<string, string> = {
|
|
1501
|
+
GetUser: 'LCAPAuth',
|
|
1502
|
+
Logout: 'LCAPAuth',
|
|
1503
|
+
CheckPermission: 'LCAPPermission',
|
|
1504
|
+
GetUserResources: 'LCAPPermission',
|
|
1505
|
+
UploadPermission: 'LCAPPermission',
|
|
1506
|
+
GetUserList: 'LCAPUserManage',
|
|
1507
|
+
GetRoleList: 'LCAPUserManage',
|
|
1508
|
+
};
|
|
1509
|
+
let path = `/api/${map[logicName]}/overridden/${logicName}`;
|
|
1510
|
+
if (concept === 'Module') {
|
|
1511
|
+
path = `/api/${entityName.replace('-', '_')}/${logicName}`;
|
|
1512
|
+
} else if (concept === 'Namespace') {
|
|
1513
|
+
serviceType = 'entity';
|
|
1514
|
+
let entityPath = entityName.replace(/[A-Z]/g, (char, index) => {
|
|
1515
|
+
const lowerChar = char.toLowerCase();
|
|
1516
|
+
return index === 0 ? lowerChar : `-${lowerChar}`;
|
|
1517
|
+
});
|
|
1518
|
+
const dataSource = parentNode.getAncestor('DataSource');
|
|
1519
|
+
// 默认数据源不动,其他数据源需要拼接数据源信息
|
|
1520
|
+
if (dataSource && dataSource.name !== 'defaultDS') {
|
|
1521
|
+
entityPath = dataSource.name + '/' + entityPath;
|
|
1522
|
+
}
|
|
1523
|
+
path = `/api/${entityPath}`;
|
|
1524
|
+
switch (this.name) {
|
|
1525
|
+
case 'get':
|
|
1526
|
+
method = 'GET';
|
|
1527
|
+
path = `/api/${entityPath}`;
|
|
1528
|
+
break;
|
|
1529
|
+
case 'create':
|
|
1530
|
+
method = 'POST';
|
|
1531
|
+
break;
|
|
1532
|
+
case 'update':
|
|
1533
|
+
method = 'PUT';
|
|
1534
|
+
break;
|
|
1535
|
+
case 'delete':
|
|
1536
|
+
method = 'DELETE';
|
|
1537
|
+
path = `/api/${entityPath}`;
|
|
1538
|
+
break;
|
|
1539
|
+
case 'createOrUpdate':
|
|
1540
|
+
method = 'POST';
|
|
1541
|
+
path = `/api/${entityPath}/createOrUpdate`;
|
|
1542
|
+
break;
|
|
1543
|
+
case 'updateBy':
|
|
1544
|
+
method = 'PUT';
|
|
1545
|
+
path = `/api/${entityPath}/by`;
|
|
1546
|
+
break;
|
|
1547
|
+
case 'deleteBy':
|
|
1548
|
+
method = 'DELETE';
|
|
1549
|
+
path = `/api/${entityPath}/by`;
|
|
1550
|
+
break;
|
|
1551
|
+
case 'batchCreate':
|
|
1552
|
+
method = 'POST';
|
|
1553
|
+
path = `/api/${entityPath}/batch`;
|
|
1554
|
+
break;
|
|
1555
|
+
case 'batchUpdate':
|
|
1556
|
+
method = 'PUT';
|
|
1557
|
+
path = `/api/${entityPath}/batch`;
|
|
1558
|
+
break;
|
|
1559
|
+
case 'batchDelete':
|
|
1560
|
+
method = 'DELETE';
|
|
1561
|
+
path = `/api/${entityPath}/batch`;
|
|
1562
|
+
break;
|
|
1563
|
+
case 'import':
|
|
1564
|
+
method = 'POST';
|
|
1565
|
+
path = `/api/${entityPath}/import`;
|
|
1566
|
+
break;
|
|
1567
|
+
default:
|
|
1568
|
+
break;
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
return {
|
|
1573
|
+
config: {
|
|
1574
|
+
serviceType,
|
|
1575
|
+
},
|
|
1576
|
+
url: {
|
|
1577
|
+
method,
|
|
1578
|
+
path,
|
|
1579
|
+
},
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
@withSourceMap()
|
|
1584
|
+
toEmbeddedTSInProcess(state?: TranslatorState, prependCode?: string, noName?: boolean, prefix?: boolean): string {
|
|
1585
|
+
let code = '';
|
|
1586
|
+
if (!prefix)
|
|
1587
|
+
code += `${noName ? '' : `${this.name}:`} function(`;
|
|
1588
|
+
else
|
|
1589
|
+
code += `function ${this.name}(`; //加空格会导致无法查询到引用
|
|
1590
|
+
this.params.forEach((param, index) => {
|
|
1591
|
+
code += param.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1592
|
+
if (index !== this.params.length - 1)
|
|
1593
|
+
code += ', ';
|
|
1594
|
+
});
|
|
1595
|
+
code += `) {\n`;
|
|
1596
|
+
code += prependCode || '';
|
|
1597
|
+
code += '\n';
|
|
1598
|
+
this.variables.forEach((variable) => {
|
|
1599
|
+
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
1600
|
+
code += variable.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1601
|
+
code += ';\n';
|
|
1602
|
+
});
|
|
1603
|
+
|
|
1604
|
+
this.returns.forEach((ret) => {
|
|
1605
|
+
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
1606
|
+
code += ret.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1607
|
+
code += ';\n';
|
|
1608
|
+
});
|
|
1609
|
+
|
|
1610
|
+
if (!this.body.length && this.returns.length) {
|
|
1611
|
+
code += indent((state?.tabSize || 0) + 1) + `return ${this.returns[0].name};\n`;
|
|
1612
|
+
} else {
|
|
1613
|
+
if ((this.parentNode as any).type === 'ExclusiveGateway') {
|
|
1614
|
+
if (this.body.length <= 1) {
|
|
1615
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
1616
|
+
code += 'const __LogicEmpty: any = null;';
|
|
1617
|
+
}
|
|
1618
|
+
} else if (this.body.length <= 2 && !(this.parentNode instanceof Namespace) && !(this.parentNode instanceof Process)) {
|
|
1619
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
1620
|
+
code += indent(state?.tabSize || 0 + 4) + 'const __LogicEmpty: any = null;';
|
|
1621
|
+
}
|
|
1622
|
+
this.body.forEach((item) => {
|
|
1623
|
+
code += item.toEmbeddedTS && item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1624
|
+
code += ';\n';
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
// 在body渲染完成之后把其余的节点放到下面
|
|
1629
|
+
this.playground.forEach((item) => {
|
|
1630
|
+
code += item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1631
|
+
code += '\n';
|
|
1632
|
+
});
|
|
1633
|
+
|
|
1634
|
+
code += indent(state?.tabSize || 0 + 4) + '}';
|
|
1635
|
+
code += '\n';
|
|
1636
|
+
return code;
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
toEmbeddedTSNoExport(state?: TranslatorState): string {
|
|
1640
|
+
return this.toEmbeddedTS(state, 'noExport');
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
@withSourceMap()
|
|
1644
|
+
toEmbeddedTS(state?: TranslatorState, prefix?: string): string {
|
|
1645
|
+
// 如果传了不要前缀那就为空, 要不用传进来的,要是都没有就默认导出
|
|
1646
|
+
let code = '';
|
|
1647
|
+
if (!prefix) {
|
|
1648
|
+
code += `export function ${this.name}`;
|
|
1649
|
+
} else if (prefix === 'noExport') {
|
|
1650
|
+
code += `function ${this.name}`;
|
|
1651
|
+
} else if (prefix === 'inObject') {
|
|
1652
|
+
code += `${this.name}`;
|
|
1653
|
+
}
|
|
1654
|
+
if (this.typeParams?.length) {
|
|
1655
|
+
code += '<';
|
|
1656
|
+
this.typeParams.forEach((typeParam, typeParamIndex) => {
|
|
1657
|
+
code += typeParam.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1658
|
+
if (typeParamIndex !== this.typeParams.length - 1)
|
|
1659
|
+
code += ', ';
|
|
1660
|
+
});
|
|
1661
|
+
code += '>';
|
|
1662
|
+
}
|
|
1663
|
+
// 有参数长度
|
|
1664
|
+
if (this.params.length) {
|
|
1665
|
+
code += '(';
|
|
1666
|
+
this.params.forEach((param, index) => {
|
|
1667
|
+
code += param.toEmbeddedTS(shiftState(state, code));
|
|
1668
|
+
if (index !== this.params.length - 1)
|
|
1669
|
+
code += ', ';
|
|
1670
|
+
});
|
|
1671
|
+
code += ')';
|
|
1672
|
+
} else {
|
|
1673
|
+
// 没有参数的
|
|
1674
|
+
code += '()';
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
// 需要类型推导的局部变量/返回值需要调整申明顺序
|
|
1678
|
+
const advanceMap: Map<Return | Variable, Assignment | BatchAssignment> = new Map();
|
|
1679
|
+
const needGetSourceMapOqlList: Promise<any>[] = [];
|
|
1680
|
+
this.traverseChildren((el) => {
|
|
1681
|
+
if (el && (el instanceof BatchAssignment || (el instanceof Assignment && el.left?.name))) {
|
|
1682
|
+
if (el instanceof Assignment) {
|
|
1683
|
+
const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && (el.left?.name === variable.name));
|
|
1684
|
+
if (advanceVar && !advanceMap.get(advanceVar)) {
|
|
1685
|
+
advanceMap.set(advanceVar, el);
|
|
1686
|
+
}
|
|
1687
|
+
const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && el.left?.name === ret.name);
|
|
1688
|
+
if (advanceRn && !advanceMap.get(advanceRn)) {
|
|
1689
|
+
advanceMap.set(advanceRn, el);
|
|
1690
|
+
}
|
|
1691
|
+
} else if (el instanceof BatchAssignment) {
|
|
1692
|
+
el.assignmentLines.forEach(({ leftIndex }) => {
|
|
1693
|
+
const leftCode
|
|
1694
|
+
= leftIndex.length === 1 ? el.left.expression.toEmbeddedTS(shiftState(state, code, { inline: true })) : el.left.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1695
|
+
const advanceVar = this.variables?.find((variable) => !variable.typeAnnotation && (leftCode === variable.name));
|
|
1696
|
+
if (advanceVar && !advanceMap.get(advanceVar)) {
|
|
1697
|
+
advanceMap.set(advanceVar, el);
|
|
1698
|
+
}
|
|
1699
|
+
const advanceRn = this.returns?.find((ret) => !ret.typeAnnotation && leftCode === ret.name);
|
|
1700
|
+
if (advanceRn && !advanceMap.get(advanceRn)) {
|
|
1701
|
+
advanceMap.set(advanceRn, el);
|
|
1702
|
+
}
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
// 如果有sql查询组件就需要把他们存起来
|
|
1707
|
+
if (el instanceof OqlQueryComponent) {
|
|
1708
|
+
if (!el.codeSourceMap) {
|
|
1709
|
+
needGetSourceMapOqlList.push(el.requestEmbeddedTS());
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
});
|
|
1713
|
+
|
|
1714
|
+
if (needGetSourceMapOqlList.length) {
|
|
1715
|
+
Promise.all(needGetSourceMapOqlList).then(() => {
|
|
1716
|
+
// 触发一下更新重新生成代码
|
|
1717
|
+
(this.app as any)?.naslServer?.embeddedTSEmitter.emit('change', {
|
|
1718
|
+
value: [
|
|
1719
|
+
{
|
|
1720
|
+
originEvent: {
|
|
1721
|
+
action: 'update',
|
|
1722
|
+
target: this,
|
|
1723
|
+
},
|
|
1724
|
+
},
|
|
1725
|
+
],
|
|
1726
|
+
});
|
|
1727
|
+
});
|
|
1728
|
+
}
|
|
1729
|
+
// 兼容 return 没有类型情况
|
|
1730
|
+
if (this.returns.length && this.returns[0].typeAnnotation) {
|
|
1731
|
+
code += ': ';
|
|
1732
|
+
code += this.returns[0].typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1733
|
+
}
|
|
1734
|
+
code += '{\n';
|
|
1735
|
+
|
|
1736
|
+
// 用于虚拟节点的查找引用
|
|
1737
|
+
this.virtualParams
|
|
1738
|
+
&& Array.isArray(this.virtualParams)
|
|
1739
|
+
&& this.virtualParams.forEach((param) => {
|
|
1740
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
1741
|
+
code += param.toEmbeddedNameTS(shiftState(state, code, { inline: true }));
|
|
1742
|
+
code += '\n';
|
|
1743
|
+
});
|
|
1744
|
+
|
|
1745
|
+
this.variables.forEach((variable) => {
|
|
1746
|
+
if (!advanceMap.get(variable)) {
|
|
1747
|
+
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
1748
|
+
code += variable.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1749
|
+
code += ';\n';
|
|
1750
|
+
}
|
|
1751
|
+
});
|
|
1752
|
+
|
|
1753
|
+
this.returns.forEach((ret) => {
|
|
1754
|
+
if (!advanceMap.get(ret)) {
|
|
1755
|
+
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
1756
|
+
code += ret.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1757
|
+
code += ';\n';
|
|
1758
|
+
}
|
|
1759
|
+
});
|
|
1760
|
+
|
|
1761
|
+
advanceMap.forEach((assignment, node) => {
|
|
1762
|
+
code += indent((state?.tabSize || 0) + 1) + '// @ts-ignore\n';
|
|
1763
|
+
code += indent((state?.tabSize || 0) + 1) + 'let ';
|
|
1764
|
+
code += node.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1765
|
+
if (assignment instanceof BatchAssignment) {
|
|
1766
|
+
assignment.assignmentLines.forEach(({ leftIndex, rightIndex }) => {
|
|
1767
|
+
const leftCode
|
|
1768
|
+
= leftIndex.length === 1 ? assignment.left.expression.toEmbeddedTS(shiftState(state, code, { inline: true })) : assignment.left.members[leftIndex[1]]?.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1769
|
+
if (leftCode === node.name) {
|
|
1770
|
+
const rightNode: any = rightIndex.length === 1 ? assignment.rights[rightIndex[0]]?.expression : assignment.rights[rightIndex[0]]?.members[rightIndex[1]];
|
|
1771
|
+
// 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
|
|
1772
|
+
if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
|
|
1773
|
+
code += ': ';
|
|
1774
|
+
code += rightNode.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) || 'null';
|
|
1775
|
+
} else {
|
|
1776
|
+
code += ' = ';
|
|
1777
|
+
const rightCode = rightNode?.toEmbeddedTS(shiftState(state, code, { inline: true }));
|
|
1778
|
+
code += this.getRightCode(rightCode, assignment, rightNode);
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
});
|
|
1782
|
+
} else if (['NewList', 'NewMap'].includes(assignment.right?.concept) && !(assignment.right as any)?.typeAnnotation) {
|
|
1783
|
+
const rightNode: any = assignment.right;
|
|
1784
|
+
code += ' = ';
|
|
1785
|
+
code += rightNode.getInitCode(shiftState(state, code, { inline: true }));
|
|
1786
|
+
} else if (assignment.right?.concept === 'NewComposite' && (assignment.right as any)?.typeAnnotation?.typeKind === 'anonymousStructure') {
|
|
1787
|
+
const rightNode: any = assignment.right;
|
|
1788
|
+
code += ' = ';
|
|
1789
|
+
code += rightNode.getInitCode(shiftState(state, code, { inline: true }));
|
|
1790
|
+
} else {
|
|
1791
|
+
const rightNode: any = assignment.right;
|
|
1792
|
+
// 当右边有明确类型时,直接使用其类型。旧版本数据查询不能直接使用其 typeAnnotation
|
|
1793
|
+
if (rightNode?.typeAnnotation && !(rightNode instanceof CallQueryComponent && rightNode.ideVersion !== '2.11')) {
|
|
1794
|
+
code += ': ';
|
|
1795
|
+
code += rightNode.typeAnnotation?.toEmbeddedTS(shiftState(state, code, { inline: true })) || 'null';
|
|
1796
|
+
} else {
|
|
1797
|
+
code += ' = ';
|
|
1798
|
+
let rightCode = '';
|
|
1799
|
+
// 因为右侧枚举要赋值就得new 一下;
|
|
1800
|
+
if (rightNode && rightNode instanceof Identifier && rightNode.namespace && rightNode.namespace.endsWith('enums')) {
|
|
1801
|
+
rightCode += 'new ';
|
|
1802
|
+
}
|
|
1803
|
+
rightCode += rightNode && rightNode.toEmbeddedTS ? rightNode.toEmbeddedTS(shiftState(state, code, { inline: true })) : '__RIGHT__';
|
|
1804
|
+
code += this.getRightCode(rightCode, assignment, rightNode);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
code += ';\n';
|
|
1808
|
+
});
|
|
1809
|
+
|
|
1810
|
+
if (!this.body.length && this.returns.length) {
|
|
1811
|
+
code += indent((state?.tabSize || 0) + 1) + `return ${this.returns[0].name};\n`;
|
|
1812
|
+
} else {
|
|
1813
|
+
// 如果长度小于2 并且不是虚拟节点就 加 报错,
|
|
1814
|
+
if (this.body.length <= 2 && !(this.parentNode instanceof Namespace)) {
|
|
1815
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
1816
|
+
code += 'const __LogicEmpty: any = null;';
|
|
1817
|
+
}
|
|
1818
|
+
this.body.forEach((item) => {
|
|
1819
|
+
code += item.toEmbeddedTS && item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1820
|
+
code += ';\n';
|
|
1821
|
+
});
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
// 在body渲染完成之后把其余的节点放到下面
|
|
1825
|
+
this.playground.forEach((item) => {
|
|
1826
|
+
code += item.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
1827
|
+
code += ';\n';
|
|
1828
|
+
});
|
|
1829
|
+
|
|
1830
|
+
code += indent(state?.tabSize || 0) + '}';
|
|
1831
|
+
if (prefix === 'inObject') {
|
|
1832
|
+
code += `,`;
|
|
1833
|
+
}
|
|
1834
|
+
code += '\n';
|
|
1835
|
+
return code;
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
getRightCode(code: string, assignment: Assignment | BatchAssignment, rightNode: any): string {
|
|
1839
|
+
code = code.replaceAll('\n', ' ');
|
|
1840
|
+
if (assignment instanceof Assignment && !assignment.right)
|
|
1841
|
+
return code;
|
|
1842
|
+
|
|
1843
|
+
// 调用接口,参数替换成 null
|
|
1844
|
+
if (rightNode instanceof CallInterface) {
|
|
1845
|
+
const { _interface } = rightNode.getModuleInterface();
|
|
1846
|
+
return _interface ? `${rightNode.tsCalleeKey}(${_interface.params.map(() => 'null').join(',')})` : null;
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
// 调用服务端逻辑,参数替换成 null
|
|
1850
|
+
if (rightNode instanceof CallLogic && rightNode.calleeNamespace === 'app.logics') {
|
|
1851
|
+
const calleeName = rightNode?.calleeName;
|
|
1852
|
+
const calleeLogic = this.app.logics.find((l) => l.name === calleeName);
|
|
1853
|
+
return calleeLogic ? `app.logics.${calleeName}(${calleeLogic.params.map(() => 'null').join(',')})` : null;
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
// ForEachStatement 内部变量需要替换处理,如 item、index
|
|
1857
|
+
const forEachStatement = assignment.getAncestor('ForEachStatement') as ForEachStatement;
|
|
1858
|
+
if (forEachStatement) {
|
|
1859
|
+
code = this.handleForEachCode(code, forEachStatement);
|
|
1860
|
+
}
|
|
1861
|
+
// Match 需要针对分支缩小类型范围
|
|
1862
|
+
const matchCase = assignment.getAncestor('MatchCase') as MatchCase;
|
|
1863
|
+
if (matchCase) {
|
|
1864
|
+
code = this.handleMatchCaseCode(code, matchCase);
|
|
1865
|
+
}
|
|
1866
|
+
return code;
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
handleReplaceCode(code: string, variable: string, replaceCode: string) {
|
|
1870
|
+
return code.replace(/\S+/g, ($1) => {
|
|
1871
|
+
if ($1 === `${variable},`)
|
|
1872
|
+
return `${replaceCode},`;
|
|
1873
|
+
if ($1 === variable)
|
|
1874
|
+
return replaceCode;
|
|
1875
|
+
|
|
1876
|
+
let fnCode = $1;
|
|
1877
|
+
if ($1.startsWith(`${variable}.`))
|
|
1878
|
+
fnCode = $1.replaceAll(`${variable}.`, `${replaceCode}.`);
|
|
1879
|
+
if ($1.startsWith(`${variable},`))
|
|
1880
|
+
fnCode = $1.replaceAll(`${variable},`, `${replaceCode},`);
|
|
1881
|
+
if ($1.includes(`(${variable},`))
|
|
1882
|
+
fnCode = $1.replaceAll(`(${variable},`, `(${replaceCode},`);
|
|
1883
|
+
if ($1.includes(`(${variable}.`))
|
|
1884
|
+
fnCode = $1.replaceAll(`(${variable}.`, `(${replaceCode}.`);
|
|
1885
|
+
if ($1.includes(`(${variable})`))
|
|
1886
|
+
fnCode = $1.replaceAll(`(${variable})`, `(${replaceCode})`);
|
|
1887
|
+
if ($1.includes(`,${variable},`))
|
|
1888
|
+
fnCode = $1.replaceAll(`,${variable},`, `,${replaceCode},`);
|
|
1889
|
+
if ($1.includes(`,${variable}.`))
|
|
1890
|
+
fnCode = $1.replaceAll(`,${variable}.`, `,${replaceCode}.`);
|
|
1891
|
+
if ($1.includes(`,${variable})`))
|
|
1892
|
+
fnCode = $1.replaceAll(`,${variable})`, `,${replaceCode})`);
|
|
1893
|
+
return fnCode;
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
handleForEachCode(code: string, forEachStatement: ForEachStatement): string {
|
|
1898
|
+
const { item, index, each } = forEachStatement;
|
|
1899
|
+
if (code.includes(item.name)) {
|
|
1900
|
+
const eachTSCode = each.toEmbeddedTS();
|
|
1901
|
+
code = this.handleReplaceCode(code, item.name, eachTSCode === '__IDENTIFIER__' ? eachTSCode : `${eachTSCode}.__get(0)`);
|
|
1902
|
+
}
|
|
1903
|
+
if (code.includes(index.name))
|
|
1904
|
+
code = this.handleReplaceCode(code, index.name, 'new nasl.core.Integer(0)');
|
|
1905
|
+
|
|
1906
|
+
const parentForEachStatement = forEachStatement.getAncestor('ForEachStatement') as ForEachStatement;
|
|
1907
|
+
if (parentForEachStatement) {
|
|
1908
|
+
this.handleForEachCode(code, parentForEachStatement);
|
|
1909
|
+
}
|
|
1910
|
+
return code;
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
handleMatchCaseCode(code: string, matchCase: MatchCase): string {
|
|
1914
|
+
const match = matchCase.getAncestor('Match') as Match;
|
|
1915
|
+
const expressionTsCode = match.expression.toEmbeddedTS();
|
|
1916
|
+
if (code.includes(expressionTsCode)) {
|
|
1917
|
+
let typeCode = '';
|
|
1918
|
+
matchCase.patterns.forEach((pattern, index) => {
|
|
1919
|
+
if (pattern instanceof TypeAnnotation) {
|
|
1920
|
+
if (index === 0) {
|
|
1921
|
+
typeCode += pattern.toEmbeddedTS();
|
|
1922
|
+
} else {
|
|
1923
|
+
typeCode += '|';
|
|
1924
|
+
typeCode += pattern.toEmbeddedTS();
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
});
|
|
1928
|
+
if (typeCode) {
|
|
1929
|
+
code = this.handleReplaceCode(code, expressionTsCode, `(${expressionTsCode} as ${typeCode})`);
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
const parentMatchCase = match.getAncestor('MatchCase') as MatchCase;
|
|
1933
|
+
if (parentMatchCase) {
|
|
1934
|
+
code = this.handleMatchCaseCode(code, parentMatchCase);
|
|
1935
|
+
}
|
|
1936
|
+
return code;
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
getNamespace(): string {
|
|
1940
|
+
if (this.parentNode) {
|
|
1941
|
+
const parentNamespace = (this.parentNode as any)?.getNamespace();
|
|
1942
|
+
const parentName = this.parentNode.name;
|
|
1943
|
+
const arr = [parentNamespace];
|
|
1944
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
1945
|
+
arr.push(parentName);
|
|
1946
|
+
}
|
|
1947
|
+
let namespace = arr.join('.');
|
|
1948
|
+
if (
|
|
1949
|
+
!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace)
|
|
1950
|
+
&& !namespace.includes('.overriddenLogics')
|
|
1951
|
+
) {
|
|
1952
|
+
namespace = `${namespace}.overriddenLogics`;
|
|
1953
|
+
}
|
|
1954
|
+
if (this.concept === 'OverriddenLogic') {
|
|
1955
|
+
namespace = `extensions.${this.overriddenModule}.logics`;
|
|
1956
|
+
}
|
|
1957
|
+
return namespace;
|
|
1958
|
+
} else
|
|
1959
|
+
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
getTsNamespace(): string {
|
|
1963
|
+
if (this.parentNode) {
|
|
1964
|
+
const parentNamespace = (this.parentNode as any)?.getTsNamespace();
|
|
1965
|
+
const parentName = this.parentNode.tsName || this.parentNode.name;
|
|
1966
|
+
const arr = [parentNamespace];
|
|
1967
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
1968
|
+
arr.push(parentName);
|
|
1969
|
+
}
|
|
1970
|
+
let namespace = arr.join('.');
|
|
1971
|
+
if (
|
|
1972
|
+
!['nasl.ui', 'nasl.utils', 'nasl.util', 'nasl.browser', 'nasl.auth', 'nasl.configuration', 'nasl.process', 'nasl.logging', 'nasl.io'].includes(namespace)
|
|
1973
|
+
&& !namespace.includes('.overriddenLogics')
|
|
1974
|
+
) {
|
|
1975
|
+
namespace = `${namespace}.overriddenLogics`;
|
|
1976
|
+
}
|
|
1977
|
+
return namespace;
|
|
1978
|
+
} else
|
|
1979
|
+
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
/**
|
|
1983
|
+
* 生成宿主语言的文件路径
|
|
1984
|
+
* @param name 一般不用传,用于 rename
|
|
1985
|
+
*/
|
|
1986
|
+
getEmbeddedFilePath(name = this.name) {
|
|
1987
|
+
let _path = this.module ? `/${this.module.parentKey}/${this.module.name}` : '';
|
|
1988
|
+
if (this.parentNode instanceof FrontendLibrary) {
|
|
1989
|
+
_path += `/frontends/${this.parentNode.type}`;
|
|
1990
|
+
}
|
|
1991
|
+
return `/embedded/${this.app.name}${_path}/overriddenLogics/${name}.ts`;
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
toEmbeddedTSFile() {
|
|
1995
|
+
let code = `namespace ${this.getTsNamespace()} {\n`;
|
|
1996
|
+
|
|
1997
|
+
const state = createCompilerState(code, { tabSize: 1 });
|
|
1998
|
+
try {
|
|
1999
|
+
code += this.toEmbeddedTS(state);
|
|
2000
|
+
} catch (err) {
|
|
2001
|
+
console.log(err, '有问题翻译失败');
|
|
2002
|
+
code += '';
|
|
2003
|
+
console.log(err);
|
|
2004
|
+
}
|
|
2005
|
+
code += '}\n';
|
|
2006
|
+
return {
|
|
2007
|
+
code,
|
|
2008
|
+
filePath: this.getEmbeddedFilePath(),
|
|
2009
|
+
sourceMap: state.sourceMap,
|
|
2010
|
+
};
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
public static getDefaultOptions() {
|
|
2014
|
+
return {
|
|
2015
|
+
body: [
|
|
2016
|
+
{
|
|
2017
|
+
concept: 'Start',
|
|
2018
|
+
label: '开始',
|
|
2019
|
+
kind: 'Statement',
|
|
2020
|
+
type: 'Start',
|
|
2021
|
+
},
|
|
2022
|
+
{
|
|
2023
|
+
concept: 'End',
|
|
2024
|
+
label: '结束',
|
|
2025
|
+
kind: 'Statement',
|
|
2026
|
+
type: 'End',
|
|
2027
|
+
},
|
|
2028
|
+
],
|
|
2029
|
+
};
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
async saveStructureOfCallQueryComponents(root?: BaseNode | Logic) {
|
|
2033
|
+
if (!root)
|
|
2034
|
+
root = this;
|
|
2035
|
+
const set = new Set();
|
|
2036
|
+
utils.traverse(({ node }) => {
|
|
2037
|
+
if (node instanceof CallQueryComponent) {
|
|
2038
|
+
set.add(node);
|
|
2039
|
+
}
|
|
2040
|
+
}, { node: root }, {
|
|
2041
|
+
mode: 'anyObject',
|
|
2042
|
+
excludedKeySet: new Set(['parentNode', '__assignment__']),
|
|
2043
|
+
});
|
|
2044
|
+
for (const node of set) {
|
|
2045
|
+
(<CallQueryComponent>node).saveStructure();
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
// 通过开关设置数据库事务
|
|
2050
|
+
setTransactionEnabled(flag: boolean) {
|
|
2051
|
+
this.setTransactional(new Transactional({
|
|
2052
|
+
enabled: flag,
|
|
2053
|
+
}));
|
|
2054
|
+
}
|
|
2055
|
+
fake: boolean;
|
|
2056
|
+
|
|
2057
|
+
getPath: () => string;
|
|
2058
|
+
|
|
2059
|
+
delete() {
|
|
2060
|
+
let actionMsg = '删除逻辑项';
|
|
2061
|
+
if (this.name)
|
|
2062
|
+
actionMsg += `“${this.name}”`;
|
|
2063
|
+
this.app?.emit('collect:start', {
|
|
2064
|
+
actionMsg,
|
|
2065
|
+
});
|
|
2066
|
+
super.delete();
|
|
2067
|
+
this.traverseChildren((el) => {
|
|
2068
|
+
if (el?.concept === 'CallQueryComponent')
|
|
2069
|
+
(el as CallQueryComponent).removeStructure();
|
|
2070
|
+
});
|
|
2071
|
+
this.app?.emit('collect:end');
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
// 是不是内部有错误
|
|
2075
|
+
haveError: boolean = false;
|
|
2076
|
+
|
|
2077
|
+
// 是否body为空
|
|
2078
|
+
isSmpty: boolean = false;
|
|
2079
|
+
|
|
2080
|
+
get pathName() {
|
|
2081
|
+
if (this.view) {
|
|
2082
|
+
return this.getEventLogicName('chinese');
|
|
2083
|
+
}
|
|
2084
|
+
const nameMap = {
|
|
2085
|
+
OnProcessStart: '流程开始时',
|
|
2086
|
+
OnTasksCreate: '任务创建时',
|
|
2087
|
+
OnTasksOpen: '任务打开时',
|
|
2088
|
+
OnTasksClose: '任务关闭时',
|
|
2089
|
+
OnCreate: '用户任务创建时',
|
|
2090
|
+
OnOpen: '用户任务打开时',
|
|
2091
|
+
OnClose: '用户任务关闭时',
|
|
2092
|
+
};
|
|
2093
|
+
const pathName = [this.name];
|
|
2094
|
+
let parentNode = this.parentNode;
|
|
2095
|
+
while (parentNode && parentNode.concept !== 'Process') {
|
|
2096
|
+
const name = (nameMap as any)[parentNode.name] || parentNode.name;
|
|
2097
|
+
pathName.unshift(name);
|
|
2098
|
+
parentNode = parentNode.parentNode;
|
|
2099
|
+
}
|
|
2100
|
+
return pathName.join('-');
|
|
2101
|
+
}
|
|
2102
|
+
// 获取bindEvent下的logic的名称
|
|
2103
|
+
getEventLogicName(type?: string) {
|
|
2104
|
+
if (this.parentNode instanceof BindEvent) {
|
|
2105
|
+
if (type === 'chinese') {
|
|
2106
|
+
const bindEvent = this.parentNode;
|
|
2107
|
+
const bindChineseName = bindEvent.getPageViewEventChineseName();
|
|
2108
|
+
return `${bindChineseName}-${this.name}`;
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
return this.name;
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2114
|
+
// 虚拟输入参数列表
|
|
2115
|
+
virtualParams: Array<Param> = [];
|
|
2116
|
+
|
|
2117
|
+
get getLogicBelongTo() {
|
|
2118
|
+
const [, belongTo] = this.calleewholeKey.split('.');
|
|
2119
|
+
return belongTo;
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2122
|
+
// 校验logic的返回值是不是有error类型
|
|
2123
|
+
static checkLogicReturnTypeHasError(logic: Logic) {
|
|
2124
|
+
let findHasError = false;
|
|
2125
|
+
if (!logic) {
|
|
2126
|
+
return findHasError;
|
|
2127
|
+
}
|
|
2128
|
+
if (logic.returns?.length && logic.returns[0]?.typeAnnotation) {
|
|
2129
|
+
// 如果新导入的logic还有Error类型
|
|
2130
|
+
const logicType = logic.returns[0].typeAnnotation;
|
|
2131
|
+
if (logicType.typeNamespace === 'nasl.ui' && logicType.typeName === 'Error') {
|
|
2132
|
+
findHasError = true;
|
|
2133
|
+
} else if (logicType.typeNamespace === 'nasl.core' && logicType.typeKind === 'union') {
|
|
2134
|
+
// 如果 logic 有 returns 而且,也有typeArguments的长度
|
|
2135
|
+
findHasError = Boolean(logicType.typeArguments?.find((item) => (
|
|
2136
|
+
item?.typeNamespace === 'nasl.ui' && item?.typeName === 'Error'
|
|
2137
|
+
)));
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
return findHasError;
|
|
2141
|
+
}
|
|
2142
|
+
get getIsEmptyLogic() {
|
|
2143
|
+
return this.body?.filter((node) => !['Start', 'End'].includes(node?.concept))?.length <= 0;
|
|
2144
|
+
}
|
|
2145
|
+
getOverriddenDepLogic() {
|
|
2146
|
+
const dep = this.app.dependencies?.find((dep) => dep.name === this.overriddenModule);
|
|
2147
|
+
if (dep) {
|
|
2148
|
+
const depLogic = dep?.logics?.find((l) => l.name === this.name);
|
|
2149
|
+
return depLogic || null;
|
|
2150
|
+
} else {
|
|
2151
|
+
return null;
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
//================================================================================
|
|
2155
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
2156
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
2157
|
+
//================================================================================
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
classMap.OverriddenLogic = OverriddenLogic;
|
|
2161
|
+
export default OverriddenLogic;
|
|
2162
|
+
//================================================================================
|
|
2163
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
2164
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
2165
|
+
//================================================================================
|