@lcap/nasl 3.6.0-alpha.1 → 3.6.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/bak/translator.js +119 -39
- package/out/bak/translator.js.map +1 -1
- package/out/breakpoint/generator/BreakpointNode.d.ts +3 -0
- package/out/breakpoint/generator/BreakpointNode.js +9 -0
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
- package/out/breakpoint/shared/constants.js +1 -0
- package/out/breakpoint/shared/constants.js.map +1 -1
- package/out/breakpoint/shared/utils.js +12 -6
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/breakpoint/store/core.js +1 -1
- package/out/breakpoint/store/core.js.map +1 -1
- package/out/common/BaseNode.d.ts +1 -4
- package/out/common/BaseNode.js +23 -37
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +6 -1
- package/out/concepts/AnonymousFunction__.js +34 -16
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.d.ts +55 -51
- package/out/concepts/App__.js +76 -80
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +10 -2
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +16 -6
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +1 -0
- package/out/concepts/BindDirective__.js +19 -4
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +3 -1
- package/out/concepts/BindEvent__.js +39 -14
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +641 -0
- package/out/concepts/BusinessComponent__.js +1921 -0
- package/out/concepts/BusinessComponent__.js.map +1 -0
- package/out/concepts/BusinessLogic__.d.ts +38 -0
- package/out/concepts/BusinessLogic__.js +358 -0
- package/out/concepts/BusinessLogic__.js.map +1 -0
- package/out/concepts/CallEvent__.d.ts +101 -0
- package/out/concepts/CallEvent__.js +280 -0
- package/out/concepts/CallEvent__.js.map +1 -0
- package/out/concepts/CallFunction__.d.ts +0 -1
- package/out/concepts/CallFunction__.js +10 -10
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +2 -0
- package/out/concepts/CallLogic__.js +38 -27
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Constant__.js +7 -6
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -1
- package/out/concepts/Destination__.js +7 -5
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +2 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/Event__.d.ts +14 -0
- package/out/concepts/Event__.js +61 -0
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/FrontendType__.d.ts +308 -0
- package/out/concepts/FrontendType__.js +605 -0
- package/out/concepts/FrontendType__.js.map +1 -0
- package/out/concepts/Frontend__.d.ts +0 -88
- package/out/concepts/Frontend__.js +1 -143
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +5 -0
- package/out/concepts/Identifier__.js +19 -9
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +3 -1
- package/out/concepts/Logic__.js +31 -21
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.d.ts +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -1
- package/out/concepts/MemberExpression__.js +3 -3
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/ParamWithGroup__.d.ts +39 -0
- package/out/concepts/ParamWithGroup__.js +85 -0
- package/out/concepts/ParamWithGroup__.js.map +1 -0
- package/out/concepts/Param__.js +11 -3
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +9 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Return__.js +17 -9
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +2 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +17 -8
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +17 -1
- package/out/concepts/ViewElement__.js +145 -16
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +21 -20
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/index__.d.ts +5 -0
- package/out/concepts/index__.js +5 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/concepts/utils/asserts.d.ts +258 -3
- package/out/concepts/utils/asserts.js +351 -13
- package/out/concepts/utils/asserts.js.map +1 -1
- package/out/concepts/utils/types.d.ts +20 -3
- package/out/generator/genBundleFiles.js +25 -11
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.js +12 -3
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.js +3 -3
- package/out/generator/permission.js.map +1 -1
- package/out/natural/transformTSCode.js +1 -1
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/extendBaseNode.js +6 -4
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/getLogics.js +62 -27
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +6 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.js +3 -3
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.js +40 -19
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +6 -1
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +1 -2
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +6 -6
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +16 -16
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +36 -36
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +6 -5
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +12 -12
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +4 -4
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +3 -3
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +10 -10
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +10 -9
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +2 -2
- package/out/templator/utils.js.map +1 -1
- package/out/translator/utils.js +12 -1
- package/out/translator/utils.js.map +1 -1
- package/out/utils/i18nInfo.js +7 -2
- package/out/utils/i18nInfo.js.map +1 -1
- package/out/utils/index.d.ts +17 -0
- package/out/utils/index.js +184 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/src/bak/translator.js +121 -43
- package/src/breakpoint/generator/BreakpointNode.ts +12 -0
- package/src/breakpoint/shared/constants.ts +1 -0
- package/src/breakpoint/shared/utils.ts +13 -8
- package/src/breakpoint/store/core.ts +1 -1
- package/src/common/BaseNode.ts +22 -41
- package/src/concepts/AnonymousFunction__.ts +36 -18
- package/src/concepts/App__.ts +129 -130
- package/src/concepts/BackendVariable__.ts +10 -2
- package/src/concepts/BindAttribute__.ts +14 -6
- package/src/concepts/BindDirective__.ts +19 -4
- package/src/concepts/BindEvent__.ts +41 -13
- package/src/concepts/BusinessComponent__.ts +2693 -0
- package/src/concepts/BusinessLogic__.ts +376 -0
- package/src/concepts/CallEvent__.ts +351 -0
- package/src/concepts/CallFunction__.ts +10 -13
- package/src/concepts/CallLogic__.ts +45 -32
- package/src/concepts/Constant__.ts +5 -7
- package/src/concepts/Destination__.ts +7 -5
- package/src/concepts/End__.ts +1 -0
- package/src/concepts/Event__.ts +70 -0
- package/src/concepts/FrontendType__.ts +919 -0
- package/src/concepts/Frontend__.ts +3 -251
- package/src/concepts/Identifier__.ts +29 -13
- package/src/concepts/LogicItem__.ts +1 -0
- package/src/concepts/Logic__.ts +36 -23
- package/src/concepts/MemberExpression__.ts +3 -3
- package/src/concepts/NewComposite__.ts +4 -6
- package/src/concepts/ParamWithGroup__.ts +101 -0
- package/src/concepts/Param__.ts +11 -3
- package/src/concepts/ProcessElement__.ts +8 -1
- package/src/concepts/Return__.ts +15 -12
- package/src/concepts/ValidationRule__.ts +6 -1
- package/src/concepts/Variable__.ts +17 -9
- package/src/concepts/ViewElement__.ts +168 -33
- package/src/concepts/View__.ts +23 -20
- package/src/concepts/index__.ts +5 -0
- package/src/concepts/utils/asserts.ts +367 -4
- package/src/concepts/utils/types.ts +28 -0
- package/src/generator/genBundleFiles.ts +33 -15
- package/src/generator/genReleaseBody.ts +14 -3
- package/src/generator/permission.ts +8 -6
- package/src/natural/transformTSCode.ts +1 -1
- package/src/server/extendBaseNode.ts +22 -20
- package/src/server/getLogics.ts +79 -41
- package/src/server/getMemberIdentifier.ts +7 -1
- package/src/server/getProcesses.ts +3 -3
- package/src/server/naslServer.ts +44 -20
- package/src/server/translator.ts +7 -1
- package/src/service/storage/init.ts +1 -2
- package/src/templator/genCreateBlock.ts +6 -6
- package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -16
- package/src/templator/genCurdMultipleKeyBlock.ts +36 -36
- package/src/templator/genGetBlock.ts +6 -5
- package/src/templator/genGridViewBlock.ts +12 -12
- package/src/templator/genListViewBlock.ts +4 -4
- package/src/templator/genSelectBlock.ts +3 -3
- package/src/templator/genTableBlock.ts +10 -10
- package/src/templator/genUpdateBlock.ts +10 -9
- package/src/templator/utils.ts +2 -2
- package/src/translator/utils.ts +12 -1
- package/src/utils/i18nInfo.ts +7 -2
- package/src/utils/index.ts +211 -1
- package/test/concepts/call-function/fixtures/from-string.json +68 -59
- package/test/concepts/call-function/fixtures/to-string-global-tz.json +67 -58
- package/test/concepts/call-function/fixtures/to-string-no-tz.json +57 -48
- package/test/concepts/call-function/fixtures/to-string-user-tz.json +69 -60
- package/test/concepts/call-function/fixtures/to-string-utc-tz.json +69 -60
- package/test/concepts/call-interface/fixtures/only-interface.json +81 -72
- package/test/concepts/call-interface/fixtures/with-body-complex-argument.json +223 -214
- package/test/concepts/call-interface/fixtures/with-body-no-argument.json +85 -76
- package/test/concepts/call-interface/fixtures/with-body-simple-argument.json +100 -91
- package/test/concepts/call-interface/fixtures/with-headers-no-argument.json +88 -79
- package/test/concepts/call-interface/fixtures/with-headers.json +90 -81
- package/test/concepts/call-interface/fixtures/with-query-no-argument.json +88 -79
- package/test/concepts/call-interface/fixtures/with-query.json +90 -81
- package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +4 -2
- package/test/concepts/call-logic/fixtures/entries-get-with-arguments.json +104 -95
- package/test/concepts/call-logic/fixtures/entries-update-with-arguments.json +209 -200
- package/test/concepts/call-logic/fixtures/global-logic-argument-no-expression.json +97 -88
- package/test/concepts/call-logic/fixtures/global-logic-argument-some-expression.json +124 -115
- package/test/concepts/call-logic/fixtures/json-deserialize.json +120 -111
- package/test/concepts/call-logic/fixtures/json-serialize-with-string.json +124 -115
- package/test/concepts/call-logic/fixtures/json-serialize.json +124 -115
- package/test/concepts/call-logic/fixtures/view-buildin-logic-with-argument.json +91 -82
- package/test/concepts/call-logic/fixtures/view-component-logic-no-argument.json +88 -79
- package/test/concepts/call-logic/fixtures/view-component-with-validation.json +144 -135
- package/test/concepts/identifier/fixtures/view-variable.json +145 -136
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +1 -1
- package/test/concepts/view-element/fixtures/default-login.json +221 -212
- package/test/concepts/view-element/fixtures/default-not-found.json +183 -174
- package/test/concepts/view-element/fixtures/with-role-auth.json +91 -82
- package/test/concepts/view-element/fixtures/with-table.json +1894 -1885
- package/test/concepts/view-element/toVue.spec.ts +1 -0
- package/ts-worker/package.json +1 -1
- package/ts-worker/src/index.js +1 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { wrapForEachToGenerator as wrapForEach } from '../utils/time-slicing';
|
|
2
|
+
import {
|
|
3
|
+
TranslatorState,
|
|
4
|
+
shiftState,
|
|
5
|
+
createCompilerState,
|
|
6
|
+
withSourceMapGenerator,
|
|
7
|
+
TranslatorGenerator,
|
|
8
|
+
} from '../translator';
|
|
9
|
+
import type Event from './Event__';
|
|
10
|
+
import type Param from './Param__';
|
|
11
|
+
import { BusinessComponent } from './BusinessComponent__';
|
|
12
|
+
//================================================================================
|
|
13
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
14
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
15
|
+
//================================================================================
|
|
16
|
+
import { EventPayload, Params } from '../common/EventEmitter';
|
|
17
|
+
import { concept, excludedInJSON, property, getConceptConstructor, getBaseNode } from '../decorators';
|
|
18
|
+
|
|
19
|
+
import * as utils from '../utils';
|
|
20
|
+
import * as types from './utils/types';
|
|
21
|
+
import * as asserts from './utils/asserts';
|
|
22
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
23
|
+
import LogicItem from './LogicItem__';
|
|
24
|
+
import type Argument from './Argument__';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 触发事件
|
|
28
|
+
*/
|
|
29
|
+
@concept('触发事件')
|
|
30
|
+
export class CallEvent extends LogicItem {
|
|
31
|
+
/** 类名 */
|
|
32
|
+
static readonly ConceptName: string = 'CallEvent';
|
|
33
|
+
|
|
34
|
+
/** 继承链 */
|
|
35
|
+
static readonly inheritanceChain: string[] = ['LogicItem', 'BaseNode'];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 产品概念
|
|
39
|
+
*/
|
|
40
|
+
@property('concept')
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
readonly concept!: 'CallEvent';
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 触发事件标题
|
|
46
|
+
*/
|
|
47
|
+
@property()
|
|
48
|
+
label: string = '触发事件';
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* calleeNamespace
|
|
52
|
+
*/
|
|
53
|
+
@property()
|
|
54
|
+
calleeNamespace!: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* calleeName
|
|
58
|
+
*/
|
|
59
|
+
@property()
|
|
60
|
+
calleeName!: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 参数
|
|
64
|
+
*/
|
|
65
|
+
@property({
|
|
66
|
+
objectRef: 'Argument',
|
|
67
|
+
isArray: true,
|
|
68
|
+
defaultValue: [],
|
|
69
|
+
})
|
|
70
|
+
arguments: Array<Argument> = [];
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param source 需要合并的部分参数
|
|
74
|
+
*/
|
|
75
|
+
constructor(source?: Partial<CallEvent>) {
|
|
76
|
+
source = Object.assign({}, CallEvent.getDefaultOptions(), source);
|
|
77
|
+
super(source);
|
|
78
|
+
super.subConstructor(source);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static from(source: any, parentNode?: any, parentKey?: string): CallEvent {
|
|
82
|
+
return super.from(source, parentNode, parentKey) as CallEvent;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 设置calleeName
|
|
87
|
+
*/
|
|
88
|
+
setCalleeName(calleeName: string) {
|
|
89
|
+
const object = {
|
|
90
|
+
calleeName,
|
|
91
|
+
};
|
|
92
|
+
this.update({
|
|
93
|
+
...object,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 插入实际参数
|
|
99
|
+
* @internal
|
|
100
|
+
* @param argumentOptions 实际参数参数
|
|
101
|
+
*/
|
|
102
|
+
_insertArgumentAt(argumentOptions: Partial<Argument>, index: number): Argument;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 插入实际参数
|
|
106
|
+
* @internal
|
|
107
|
+
* @param argument 已有的实际参数实例
|
|
108
|
+
*/
|
|
109
|
+
_insertArgumentAt(argument: Argument, index: number): Argument;
|
|
110
|
+
|
|
111
|
+
_insertArgumentAt(options: Partial<Argument> | Argument, index: number) {
|
|
112
|
+
const argumentOptions: any = {};
|
|
113
|
+
const relationOptions = { parentNode: this, parentKey: 'arguments' };
|
|
114
|
+
const Argument = getConceptConstructor('Argument');
|
|
115
|
+
let argument: Argument;
|
|
116
|
+
if (asserts.isArgument(options)) {
|
|
117
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
118
|
+
argument = options;
|
|
119
|
+
Object.assign(argument, relationOptions);
|
|
120
|
+
} else {
|
|
121
|
+
argument = Argument.from(
|
|
122
|
+
{
|
|
123
|
+
...argumentOptions,
|
|
124
|
+
...options,
|
|
125
|
+
},
|
|
126
|
+
this,
|
|
127
|
+
'arguments',
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
this.arguments.splice(index, 0, argument);
|
|
131
|
+
return argument;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 插入实际参数
|
|
136
|
+
* @param argumentOptions 实际参数参数
|
|
137
|
+
*/
|
|
138
|
+
insertArgumentAt(argumentOptions: Partial<Argument>, index: number): Argument;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 插入实际参数
|
|
142
|
+
* @param argument 已有的实际参数实例
|
|
143
|
+
*/
|
|
144
|
+
insertArgumentAt(argument: Argument, index: number): Argument;
|
|
145
|
+
|
|
146
|
+
insertArgumentAt(options: Partial<Argument> | Argument, index: number) {
|
|
147
|
+
const node = this._insertArgumentAt(options as any, index);
|
|
148
|
+
node.create({
|
|
149
|
+
index,
|
|
150
|
+
parentNode: this,
|
|
151
|
+
parentKey: 'arguments',
|
|
152
|
+
});
|
|
153
|
+
return node;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* 添加实际参数
|
|
158
|
+
* @internal
|
|
159
|
+
* @param argumentOptions 实际参数参数
|
|
160
|
+
*/
|
|
161
|
+
_addArgument(argumentOptions: Partial<Argument>): Argument;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* 添加实际参数
|
|
165
|
+
* @internal
|
|
166
|
+
* @param argument 已有的实际参数实例
|
|
167
|
+
*/
|
|
168
|
+
_addArgument(argument: Argument): Argument;
|
|
169
|
+
|
|
170
|
+
_addArgument(options?: Partial<Argument> | Argument) {
|
|
171
|
+
const index = this.arguments.length;
|
|
172
|
+
return this._insertArgumentAt(options as any, index);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* 添加实际参数
|
|
177
|
+
* @param argumentOptions 实际参数参数
|
|
178
|
+
*/
|
|
179
|
+
addArgument(argumentOptions: Partial<Argument>): Argument;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* 添加实际参数
|
|
183
|
+
* @param argument 已有的实际参数实例
|
|
184
|
+
*/
|
|
185
|
+
addArgument(argument: Argument): Argument;
|
|
186
|
+
|
|
187
|
+
addArgument(options?: Partial<Argument> | Argument) {
|
|
188
|
+
const node = this._addArgument(options as any);
|
|
189
|
+
const index = this.arguments.indexOf(node);
|
|
190
|
+
node.create({
|
|
191
|
+
index,
|
|
192
|
+
parentNode: this,
|
|
193
|
+
parentKey: 'arguments',
|
|
194
|
+
});
|
|
195
|
+
return node;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 删除实际参数
|
|
200
|
+
* @param argument 已有的实际参数实例
|
|
201
|
+
*/
|
|
202
|
+
removeArgument(argument: Argument): void;
|
|
203
|
+
|
|
204
|
+
removeArgument(options: Argument) {
|
|
205
|
+
let argument: Argument = options;
|
|
206
|
+
return argument.delete();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
__removeLogicItem(logicItem: LogicItem) {
|
|
210
|
+
const parentKey = logicItem.parentKey;
|
|
211
|
+
const params: Params = {
|
|
212
|
+
parentNode: this,
|
|
213
|
+
parentKey,
|
|
214
|
+
index: -1,
|
|
215
|
+
object: null,
|
|
216
|
+
oldObject: logicItem,
|
|
217
|
+
};
|
|
218
|
+
if (parentKey) {
|
|
219
|
+
params.parentKey = parentKey;
|
|
220
|
+
// @ts-ignore
|
|
221
|
+
const t = this.__v_raw || this;
|
|
222
|
+
// @ts-ignore
|
|
223
|
+
const n = logicItem.__v_raw || logicItem;
|
|
224
|
+
if (Array.isArray((t as any)[parentKey])) {
|
|
225
|
+
// @ts-ignore
|
|
226
|
+
const index = (t as any)[parentKey].findIndex((el) => (el.__v_raw || el) === n);
|
|
227
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
228
|
+
params.index = index;
|
|
229
|
+
} else {
|
|
230
|
+
const q = (t as any)[parentKey];
|
|
231
|
+
if ((q.__v_raw || q) === n) {
|
|
232
|
+
params.index = 0;
|
|
233
|
+
(this as any)[parentKey] = undefined;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return params;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
//================================================================================
|
|
241
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
242
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
243
|
+
//================================================================================
|
|
244
|
+
get businessComponent() {
|
|
245
|
+
return this.getAncestor('BusinessComponent') as BusinessComponent;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// 设置触发的事件
|
|
249
|
+
setCallee(event: Event) {
|
|
250
|
+
const Argument = getConceptConstructor('Argument');
|
|
251
|
+
const Identifier = getConceptConstructor('Identifier');
|
|
252
|
+
const calleeName = event.name;
|
|
253
|
+
const params = event?.params?.map((param) => {
|
|
254
|
+
const relationOptions = { parentNode: this, parentKey: 'arguments' };
|
|
255
|
+
const argument = Argument.from(
|
|
256
|
+
{
|
|
257
|
+
keyword: param.name,
|
|
258
|
+
expression: param.isFunction ? new Identifier() : param.defaultExpression,
|
|
259
|
+
},
|
|
260
|
+
this,
|
|
261
|
+
);
|
|
262
|
+
Object.assign(argument, relationOptions);
|
|
263
|
+
return argument;
|
|
264
|
+
});
|
|
265
|
+
this.update({
|
|
266
|
+
calleeName,
|
|
267
|
+
arguments: params,
|
|
268
|
+
folded: false,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// 被调用的事件
|
|
273
|
+
getCallNode(): Event | undefined {
|
|
274
|
+
return this.businessComponent?.events?.find((event: Event) => event.name === this.calleeName);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// 实参列表
|
|
278
|
+
get completeArguments() {
|
|
279
|
+
const callArguments = (this.arguments ?? []).slice();
|
|
280
|
+
// 没有参数时可以跳过查询原逻辑标签
|
|
281
|
+
const node = callArguments.length > 0 ? this.getCallNode() : undefined;
|
|
282
|
+
const logicParams = node?.params ?? [];
|
|
283
|
+
|
|
284
|
+
callArguments.forEach((arg, index) => {
|
|
285
|
+
const param = logicParams[index] || ({} as Param);
|
|
286
|
+
arg.paramRequired = Boolean(!param?.defaultValue?.expression);
|
|
287
|
+
arg.paramTypeAnnotation = undefined;
|
|
288
|
+
arg.paramDefaultValue = undefined;
|
|
289
|
+
// 强制更新当前的 keyword
|
|
290
|
+
arg.keyword = param?.name && param.name.length > 0 ? param.name : arg.keyword;
|
|
291
|
+
// 取到是不是必填放入参数中
|
|
292
|
+
if (param && !arg.expression) {
|
|
293
|
+
// 非必填时 才会有默认值
|
|
294
|
+
arg.paramTypeAnnotation = param.typeAnnotation;
|
|
295
|
+
arg.paramDefaultValue = param.defaultValue;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
return callArguments;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
@withSourceMapGenerator
|
|
303
|
+
*toEmbeddedTS(state = createCompilerState()): TranslatorGenerator {
|
|
304
|
+
const self = this;
|
|
305
|
+
const { calleeName, completeArguments, arguments: eventArgs } = self;
|
|
306
|
+
let code = `(this as ${this.businessComponent.name}).${calleeName ?? '__IDENTIFIER__'}(`;
|
|
307
|
+
if (completeArguments?.length) {
|
|
308
|
+
yield* wrapForEach(completeArguments, function* warpForEachGenerator(arg, index) {
|
|
309
|
+
// 取到是不是必填放入参数中
|
|
310
|
+
code += yield* arg.toEmbeddedTS(shiftState(state, code), arg?.paramRequired);
|
|
311
|
+
if (index !== eventArgs.length - 1) code += ', ';
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
code += ')';
|
|
315
|
+
code += '\n';
|
|
316
|
+
return code;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
toJS(state?: TranslatorState): string {
|
|
320
|
+
const { completeArguments = [] } = this;
|
|
321
|
+
let code = '';
|
|
322
|
+
code += `this.$emit('${this.calleeName}', {\n`;
|
|
323
|
+
if (Array.isArray(completeArguments) && completeArguments.length) {
|
|
324
|
+
const eventNode = this.getCallNode();
|
|
325
|
+
const eventParams = eventNode?.params;
|
|
326
|
+
completeArguments.forEach((arg, index) => {
|
|
327
|
+
let argStr = arg?.toJS(shiftState(state, code));
|
|
328
|
+
const paramDefaultValue = eventParams?.[index]?.defaultValue?.toJS?.();
|
|
329
|
+
if (paramDefaultValue) {
|
|
330
|
+
argStr = `${argStr} !== undefined ? ${argStr} : ${paramDefaultValue}`;
|
|
331
|
+
}
|
|
332
|
+
code += `${arg.keyword}: ${argStr}`;
|
|
333
|
+
if (index !== completeArguments?.length - 1) {
|
|
334
|
+
code += ', ';
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
code += '\n})';
|
|
339
|
+
return code;
|
|
340
|
+
}
|
|
341
|
+
//================================================================================
|
|
342
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
343
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
344
|
+
//================================================================================
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export default CallEvent;
|
|
348
|
+
//================================================================================
|
|
349
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
350
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
351
|
+
//================================================================================
|
|
@@ -16,7 +16,6 @@ import type Function from './Function__';
|
|
|
16
16
|
import { ElementToVueOptions } from './ViewElement__';
|
|
17
17
|
import type Identifier from './Identifier__';
|
|
18
18
|
import { getBuildInFunction } from '../server/getFunctions';
|
|
19
|
-
import type AnonymousFunction from './AnonymousFunction__';
|
|
20
19
|
import type MemberExpression from './MemberExpression__';
|
|
21
20
|
import asyncFuncMap from '../common/asyncFuncMap';
|
|
22
21
|
|
|
@@ -527,10 +526,18 @@ export class CallFunction extends LogicItem {
|
|
|
527
526
|
|
|
528
527
|
code += ')';
|
|
529
528
|
const tyAnno = (this as any).typeAnnotation || this.__TypeAnnotation;
|
|
529
|
+
let { sortedTypeKey, typeKind, typeName, typeNamespace } = tyAnno || {};
|
|
530
|
+
if (typeNamespace?.endsWith('.metadataTypes')) {
|
|
531
|
+
const referenceNode = this.app.findNodeByCompleteName(typeNamespace + '.' + typeName) || {};
|
|
532
|
+
const typeAn = referenceNode.typeAnnotation || {};
|
|
533
|
+
sortedTypeKey = `${typeAn.typeNamespace}.${typeAn.typeName}`;
|
|
534
|
+
typeKind = typeAn.typeKind;
|
|
535
|
+
typeName = typeAn.typeName;
|
|
536
|
+
}
|
|
530
537
|
const needGenInitFromSchema =
|
|
531
|
-
tyAnno && (!['primitive', 'union'].includes(
|
|
538
|
+
tyAnno && (!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
|
|
532
539
|
if (needGenInitFromSchema) {
|
|
533
|
-
code = `this.$genInitFromSchema('${
|
|
540
|
+
code = `this.$genInitFromSchema('${sortedTypeKey}', ${code})`;
|
|
534
541
|
}
|
|
535
542
|
return code;
|
|
536
543
|
}
|
|
@@ -713,16 +720,6 @@ export class CallFunction extends LogicItem {
|
|
|
713
720
|
return code;
|
|
714
721
|
}
|
|
715
722
|
|
|
716
|
-
checkParamNameOfAnonymousFunction() {
|
|
717
|
-
const fns = this.arguments
|
|
718
|
-
.map((arg) => arg.expression)
|
|
719
|
-
.filter((exp) => asserts.isAnonymousFunction(exp)) as unknown as AnonymousFunction[];
|
|
720
|
-
|
|
721
|
-
fns.forEach((fn) => {
|
|
722
|
-
fn.checkParamName();
|
|
723
|
-
});
|
|
724
|
-
}
|
|
725
|
-
|
|
726
723
|
getQuickInfoOffset(range: Range, getCode: GetCode) {
|
|
727
724
|
return getCallExpressionQuickInfo(range, getCode);
|
|
728
725
|
}
|
|
@@ -591,7 +591,7 @@ export class CallLogic extends LogicItem {
|
|
|
591
591
|
_setCallee(logic: Logic) {
|
|
592
592
|
const BaseNode = getBaseNode();
|
|
593
593
|
this.calleeNamespace = logic.getNamespace();
|
|
594
|
-
if (asserts.isView(logic.parentNode)) {
|
|
594
|
+
if (asserts.isView(logic.parentNode) || asserts.isBusinessComponent(logic.parentNode)) {
|
|
595
595
|
this.calleeNamespace = '';
|
|
596
596
|
}
|
|
597
597
|
this.calleeName = logic.name;
|
|
@@ -615,7 +615,7 @@ export class CallLogic extends LogicItem {
|
|
|
615
615
|
|
|
616
616
|
setCallee(logic: Logic) {
|
|
617
617
|
let calleeNamespace = logic?.getNamespace() || '';
|
|
618
|
-
if (asserts.isView(logic.parentNode)) {
|
|
618
|
+
if (asserts.isView(logic.parentNode) || asserts.isBusinessComponent(logic.parentNode)) {
|
|
619
619
|
calleeNamespace = '';
|
|
620
620
|
}
|
|
621
621
|
const calleeName = logic.name;
|
|
@@ -773,23 +773,23 @@ export class CallLogic extends LogicItem {
|
|
|
773
773
|
code += calleeName;
|
|
774
774
|
}
|
|
775
775
|
return code;
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
}
|
|
786
|
-
setArguments();
|
|
787
|
-
return code;
|
|
788
|
-
} else if (calleeName === 'jsonDeserialize') {
|
|
789
|
-
code += options?.finalCode === false ? 'JSON 反序列化' : 'JSON.parse';
|
|
790
|
-
setArguments();
|
|
791
|
-
return code;
|
|
776
|
+
}
|
|
777
|
+
if (calleeName === 'jsonSerialize') {
|
|
778
|
+
if (
|
|
779
|
+
this.arguments[0]?.expression?.__TypeAnnotation?.typeName === 'String' &&
|
|
780
|
+
this.arguments[0]?.expression?.__TypeAnnotation?.typeNamespace === 'nasl.core'
|
|
781
|
+
) {
|
|
782
|
+
code += options?.finalCode === false ? 'JSON 序列化' : 'JSON.stringify';
|
|
783
|
+
} else {
|
|
784
|
+
code += options?.finalCode === false ? 'JSON 序列化' : `$utils['JsonSerialize']`;
|
|
792
785
|
}
|
|
786
|
+
setArguments();
|
|
787
|
+
return code;
|
|
788
|
+
}
|
|
789
|
+
if (calleeName === 'jsonDeserialize') {
|
|
790
|
+
code += options?.finalCode === false ? 'JSON 反序列化' : 'JSON.parse';
|
|
791
|
+
setArguments();
|
|
792
|
+
return code;
|
|
793
793
|
}
|
|
794
794
|
}
|
|
795
795
|
|
|
@@ -815,12 +815,11 @@ export class CallLogic extends LogicItem {
|
|
|
815
815
|
|
|
816
816
|
if (bindAttr?.name === 'data-source') {
|
|
817
817
|
return this.calleeName;
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
}
|
|
818
|
+
}
|
|
819
|
+
if (calleeName === 'jsonSerialize') {
|
|
820
|
+
return 'JSON 序列化';
|
|
821
|
+
} if (calleeName === 'jsonDeserialize') {
|
|
822
|
+
return 'JSON 反序列化';
|
|
824
823
|
}
|
|
825
824
|
}
|
|
826
825
|
|
|
@@ -907,9 +906,8 @@ export class CallLogic extends LogicItem {
|
|
|
907
906
|
const args = logic?.params || [];
|
|
908
907
|
const keywordEntitiesIndex = findConceptKeyWordIndexFromNamespace(this.calleeNamespace, 'entities');
|
|
909
908
|
|
|
910
|
-
code += `this.$logics['${
|
|
911
|
-
|
|
912
|
-
}']`;
|
|
909
|
+
code += `this.$logics['${this.calleeNamespace ? `${this.calleeNamespace}.${this.calleeName}` : this.calleeName
|
|
910
|
+
}']`;
|
|
913
911
|
code += `({
|
|
914
912
|
config: {
|
|
915
913
|
download: false,
|
|
@@ -1193,11 +1191,17 @@ export class CallLogic extends LogicItem {
|
|
|
1193
1191
|
};
|
|
1194
1192
|
}
|
|
1195
1193
|
const typeAnnotation = (this as any).typeAnnotation || this.__TypeAnnotation;
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
(
|
|
1194
|
+
let { sortedTypeKey, typeKind, typeName, typeNamespace } = typeAnnotation || {};
|
|
1195
|
+
if (typeNamespace?.endsWith('.metadataTypes')) {
|
|
1196
|
+
const referenceNode = this.app.findNodeByCompleteName(typeNamespace + '.' + typeName) || {};
|
|
1197
|
+
const typeAn = referenceNode.typeAnnotation || {};
|
|
1198
|
+
sortedTypeKey = `${typeAn.typeNamespace}.${typeAn.typeName}`;
|
|
1199
|
+
typeKind = typeAn.typeKind;
|
|
1200
|
+
typeName = typeAn.typeName;
|
|
1201
|
+
}
|
|
1202
|
+
const needGenInitFromSchema = typeAnnotation && (!['primitive', 'union'].includes(typeKind) || typeName === 'DateTime');
|
|
1199
1203
|
if (needGenInitFromSchema) {
|
|
1200
|
-
code = `this.$genInitFromSchema('${
|
|
1204
|
+
code = `this.$genInitFromSchema('${sortedTypeKey}', ${code})`;
|
|
1201
1205
|
}
|
|
1202
1206
|
code += ')';
|
|
1203
1207
|
return code;
|
|
@@ -1217,6 +1221,10 @@ export class CallLogic extends LogicItem {
|
|
|
1217
1221
|
return Boolean(this.handleError || this.useValidation);
|
|
1218
1222
|
}
|
|
1219
1223
|
|
|
1224
|
+
get businessComponent() {
|
|
1225
|
+
return this.getAncestor('BusinessComponent');
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1220
1228
|
@withSourceMapGenerator
|
|
1221
1229
|
*toEmbeddedTS(state = createCompilerState()): TranslatorGenerator {
|
|
1222
1230
|
const self = this;
|
|
@@ -1351,6 +1359,11 @@ export class CallLogic extends LogicItem {
|
|
|
1351
1359
|
yield* setInputParam();
|
|
1352
1360
|
code += ';\n})()';
|
|
1353
1361
|
} else {
|
|
1362
|
+
// 属于业务组件
|
|
1363
|
+
const belongBusinessComponent = !!this.businessComponent;
|
|
1364
|
+
if (belongBusinessComponent && !self.calleeNamespace) {
|
|
1365
|
+
code += `(this as ${this.businessComponent.name}).`;
|
|
1366
|
+
}
|
|
1354
1367
|
code += calleeKey;
|
|
1355
1368
|
yield* setTypeArguments();
|
|
1356
1369
|
yield* setInputParam();
|
|
@@ -1508,7 +1521,7 @@ export class CallLogic extends LogicItem {
|
|
|
1508
1521
|
state: Array.isArray(t) ? 2 : 1,
|
|
1509
1522
|
};
|
|
1510
1523
|
});
|
|
1511
|
-
} catch (err) {}
|
|
1524
|
+
} catch (err) { }
|
|
1512
1525
|
}
|
|
1513
1526
|
return node;
|
|
1514
1527
|
}
|
|
@@ -347,15 +347,13 @@ export class Constant extends BaseNode {
|
|
|
347
347
|
}
|
|
348
348
|
if (this.typeAnnotation) {
|
|
349
349
|
code += `: `;
|
|
350
|
-
if (
|
|
351
|
-
this.
|
|
352
|
-
!(this.typeAnnotation && ['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(typeKey))
|
|
353
|
-
) {
|
|
354
|
-
code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
|
|
355
|
-
} else {
|
|
356
|
-
if (['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(typeKey)) {
|
|
350
|
+
if (this.defaultValue?.expression) {
|
|
351
|
+
if (['nasl.core.DateTime', 'nasl.core.Time', 'nasl.core.Date'].includes(this.typeAnnotation.typeKey)) {
|
|
357
352
|
code += yield* this.defaultValue.toEmbeddedTS(shiftState(state, code), true);
|
|
353
|
+
} else {
|
|
354
|
+
code += `${yield* this.defaultValue.toEmbeddedTS(shiftState(state, code))}`;
|
|
358
355
|
}
|
|
356
|
+
} else {
|
|
359
357
|
code += 'undefined';
|
|
360
358
|
}
|
|
361
359
|
code += ' as ';
|
|
@@ -358,7 +358,8 @@ export class Destination extends LogicItem {
|
|
|
358
358
|
if (this.viewName) {
|
|
359
359
|
viewArr.push(this.viewName);
|
|
360
360
|
}
|
|
361
|
-
//
|
|
361
|
+
// 端名和端类型名都需要去掉
|
|
362
|
+
viewArr.shift();
|
|
362
363
|
viewArr.shift();
|
|
363
364
|
return viewArr;
|
|
364
365
|
}
|
|
@@ -367,7 +368,7 @@ export class Destination extends LogicItem {
|
|
|
367
368
|
let code = '';
|
|
368
369
|
const viewArr = this.genViewArr();
|
|
369
370
|
if (Array.isArray(viewArr) && viewArr.length) {
|
|
370
|
-
code += `let url = '${this.viewNode
|
|
371
|
+
code += `let url = '${this.viewNode?.frontend?.prefixPath ? this.viewNode.frontend.prefixPath : ''}/${viewArr.join(
|
|
371
372
|
'/',
|
|
372
373
|
)}';\n`;
|
|
373
374
|
const { completeArguments } = this;
|
|
@@ -690,20 +691,21 @@ export class Destination extends LogicItem {
|
|
|
690
691
|
}
|
|
691
692
|
});
|
|
692
693
|
}
|
|
694
|
+
console.log(viewNameAttr);
|
|
693
695
|
if (this.viewNode) {
|
|
694
|
-
return `${this.viewNode
|
|
696
|
+
return `${this.viewNode?.frontend?.prefixPath}/${viewNameAttr.join('/')}`;
|
|
695
697
|
}
|
|
696
698
|
return `/${viewNameAttr.join('/')}`;
|
|
697
699
|
}
|
|
698
700
|
|
|
699
701
|
@withSourceMapGenerator
|
|
700
|
-
*toEmbeddedTSInProcess(state = createCompilerState(),
|
|
702
|
+
*toEmbeddedTSInProcess(state = createCompilerState(), prevCode: string): TranslatorGenerator {
|
|
701
703
|
const self = this;
|
|
702
704
|
// const tab = indent((state?.tabSize || 0));
|
|
703
705
|
if (self.tsCalleeNamespace && self.tsName) {
|
|
704
706
|
const destinationName = self.parentNode.name.replace('-', '_');
|
|
705
707
|
let code = `${destinationName}: function() {\n`;
|
|
706
|
-
code +=
|
|
708
|
+
code += prevCode;
|
|
707
709
|
code += '\n';
|
|
708
710
|
if (self.tsCalleeNamespace && self.viewName) {
|
|
709
711
|
code += `${self.tsCalleeNamespace}.${self.viewName}.$destination({`;
|
package/src/concepts/End__.ts
CHANGED
|
@@ -99,6 +99,7 @@ export class End extends LogicItem {
|
|
|
99
99
|
// 旧逻辑默认走这里,
|
|
100
100
|
// 期望后期可以直接走完整的case, default 直接抛出异常好更明确定位错误
|
|
101
101
|
logic =
|
|
102
|
+
self.getAncestor('BusinessLogic') ||
|
|
102
103
|
self.parentNode.getAncestor('Logic') ||
|
|
103
104
|
self.parentNode.getAncestor('AuthLogic') ||
|
|
104
105
|
self.parentNode.getAncestor('AuthLogicForCallInterface') ||
|