@lcap/nasl 2.22.1 → 2.22.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/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 +200 -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 +31 -0
- package/out/breakpoint/shared/constants.js +89 -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 +23 -0
- package/out/breakpoint/shared/utils.js +165 -0
- package/out/breakpoint/shared/utils.js.map +1 -0
- package/out/breakpoint/store/core.d.ts +32 -0
- package/out/breakpoint/store/core.js +388 -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/asyncFuncMap.d.ts +2 -0
- package/out/common/asyncFuncMap.js +16 -0
- package/out/common/asyncFuncMap.js.map +1 -0
- package/out/concepts/AnonymousFunction__.js +1 -1
- package/out/concepts/AnonymousFunction__.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/CallAuthInterface__.d.ts +126 -0
- package/out/concepts/CallAuthInterface__.js +408 -0
- package/out/concepts/CallAuthInterface__.js.map +1 -0
- package/out/concepts/Destination__.js +6 -4
- package/out/concepts/Destination__.js.map +1 -1
- 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/Match__.js +25 -6
- package/out/concepts/Match__.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__.js +1 -1
- package/out/concepts/Param__.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/server/naslServer.js +4 -0
- package/out/server/naslServer.js.map +1 -1
- package/out/service/creator/errHandles.js +5 -0
- package/out/service/creator/errHandles.js.map +1 -1
- package/out/templator/genCreateBlock.js +2 -1
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +6 -3
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +4 -2
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +2 -1
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -1
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/package.json +2 -2
- package/src/concepts/AnonymousFunction__.ts +1 -1
- package/src/concepts/Destination__.ts +7 -5
- package/src/concepts/Match__.ts +24 -6
- package/src/concepts/Param__.ts +1 -1
- package/src/concepts/dist/App__.js +2204 -0
- package/src/concepts/dist/CallLogic__.js +1149 -0
- package/src/concepts/dist/Destination__.js +756 -0
- package/src/concepts/dist/Logic__.js +1612 -0
- package/src/concepts/dist/Match__.js +768 -0
- package/src/concepts/dist/MsgTriggerEvent__.js +245 -0
- package/src/concepts/dist/OqlQueryComponent__.js +377 -0
- package/src/concepts/dist/Param__.js +1 -1
- package/src/generator/dist/genBundleFiles.js +15 -4
- package/src/generator/dist/genReleaseBody.js +501 -0
- package/src/server/dist/naslServer.js +25 -6
- package/src/server/naslServer.ts +4 -0
- package/src/service/creator/errHandles.js +8 -3
- package/src/service/storage/dist/init.js +34 -32
- package/src/templator/genCreateBlock.ts +2 -1
- package/src/templator/genCurdEditMultipleKeyBlock.ts +6 -3
- package/src/templator/genCurdMultipleKeyBlock.ts +4 -2
- package/src/templator/genEditTableBlock.ts +2 -1
- package/src/templator/genUpdateBlock.ts +2 -1
- package/test/examples/qzbusiness.json +1 -98265
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
27
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
30
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
+
};
|
|
32
|
+
exports.__esModule = true;
|
|
33
|
+
exports.MsgTriggerEvent = void 0;
|
|
34
|
+
var decorators_1 = require("../decorators");
|
|
35
|
+
var utils = require("../utils");
|
|
36
|
+
var classMap_1 = require("../common/classMap");
|
|
37
|
+
var Param__1 = require("./Param__");
|
|
38
|
+
var TriggerEvent__1 = require("./TriggerEvent__");
|
|
39
|
+
/**
|
|
40
|
+
* 触发器事件
|
|
41
|
+
*/
|
|
42
|
+
var MsgTriggerEvent = /** @class */ (function (_super) {
|
|
43
|
+
__extends(MsgTriggerEvent, _super);
|
|
44
|
+
/**
|
|
45
|
+
* @param source 需要合并的部分参数
|
|
46
|
+
*/
|
|
47
|
+
function MsgTriggerEvent(source) {
|
|
48
|
+
var _this = this;
|
|
49
|
+
source = Object.assign({}, MsgTriggerEvent_1.getDefaultOptions(), source);
|
|
50
|
+
_this = _super.call(this, source) || this;
|
|
51
|
+
/**
|
|
52
|
+
* 产品概念
|
|
53
|
+
*/
|
|
54
|
+
_this.concept = 'MsgTriggerEvent';
|
|
55
|
+
/**
|
|
56
|
+
* 输入参数列表
|
|
57
|
+
*/
|
|
58
|
+
_this.properties = [];
|
|
59
|
+
_super.prototype.subConstructor.call(_this, source);
|
|
60
|
+
return _this;
|
|
61
|
+
}
|
|
62
|
+
MsgTriggerEvent_1 = MsgTriggerEvent;
|
|
63
|
+
Object.defineProperty(MsgTriggerEvent.prototype, "module", {
|
|
64
|
+
/**
|
|
65
|
+
* 祖先 Module
|
|
66
|
+
*/
|
|
67
|
+
get: function () {
|
|
68
|
+
return this.getAncestor('Module');
|
|
69
|
+
},
|
|
70
|
+
enumerable: false,
|
|
71
|
+
configurable: true
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(MsgTriggerEvent.prototype, "app", {
|
|
74
|
+
/**
|
|
75
|
+
* 祖先 App
|
|
76
|
+
*/
|
|
77
|
+
get: function () {
|
|
78
|
+
return this.getAncestor('App');
|
|
79
|
+
},
|
|
80
|
+
enumerable: false,
|
|
81
|
+
configurable: true
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(MsgTriggerEvent.prototype, "view", {
|
|
84
|
+
/**
|
|
85
|
+
* 祖先 View
|
|
86
|
+
*/
|
|
87
|
+
get: function () {
|
|
88
|
+
return this.getAncestor('View');
|
|
89
|
+
},
|
|
90
|
+
enumerable: false,
|
|
91
|
+
configurable: true
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(MsgTriggerEvent.prototype, "frontend", {
|
|
94
|
+
/**
|
|
95
|
+
* 祖先 Frontend
|
|
96
|
+
*/
|
|
97
|
+
get: function () {
|
|
98
|
+
return this.getAncestor('Frontend');
|
|
99
|
+
},
|
|
100
|
+
enumerable: false,
|
|
101
|
+
configurable: true
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(MsgTriggerEvent.prototype, "processElement", {
|
|
104
|
+
/**
|
|
105
|
+
* 祖先 ProcessElement
|
|
106
|
+
*/
|
|
107
|
+
get: function () {
|
|
108
|
+
return this.getAncestor('ProcessElement');
|
|
109
|
+
},
|
|
110
|
+
enumerable: false,
|
|
111
|
+
configurable: true
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(MsgTriggerEvent.prototype, "process", {
|
|
114
|
+
/**
|
|
115
|
+
* 祖先 Process
|
|
116
|
+
*/
|
|
117
|
+
get: function () {
|
|
118
|
+
return this.getAncestor('Process');
|
|
119
|
+
},
|
|
120
|
+
enumerable: false,
|
|
121
|
+
configurable: true
|
|
122
|
+
});
|
|
123
|
+
MsgTriggerEvent.prototype.getClassName = function () {
|
|
124
|
+
return 'MsgTriggerEvent';
|
|
125
|
+
};
|
|
126
|
+
MsgTriggerEvent.from = function (source, parentNode, parentKey) {
|
|
127
|
+
return _super.from.call(this, source, parentNode, parentKey);
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* 设置输入参数列表
|
|
131
|
+
*/
|
|
132
|
+
MsgTriggerEvent.prototype.setProperties = function (properties) {
|
|
133
|
+
var object = {
|
|
134
|
+
properties: properties
|
|
135
|
+
};
|
|
136
|
+
this.update(__assign({}, object));
|
|
137
|
+
};
|
|
138
|
+
MsgTriggerEvent.prototype.getParamExistingNames = function (excludedList) {
|
|
139
|
+
if (excludedList === void 0) { excludedList = []; }
|
|
140
|
+
var excludedSet = new Set(excludedList);
|
|
141
|
+
return (this.properties || []).filter(function (item) { return !excludedSet.has(item); }).map(function (item) { return item.name; });
|
|
142
|
+
};
|
|
143
|
+
MsgTriggerEvent.prototype.getParamUniqueName = function (name) {
|
|
144
|
+
if (name === void 0) { name = 'param1'; }
|
|
145
|
+
return utils.unique(name, this.getParamExistingNames(), undefined, false);
|
|
146
|
+
};
|
|
147
|
+
MsgTriggerEvent.prototype._insertParamAt = function (options, index) {
|
|
148
|
+
var paramOptions = {};
|
|
149
|
+
var relationOptions = { parentNode: this, parentKey: 'properties' };
|
|
150
|
+
var param;
|
|
151
|
+
if (!options) {
|
|
152
|
+
param = Param__1["default"].from(__assign(__assign({}, paramOptions), { name: this.getParamUniqueName() }), this, 'properties');
|
|
153
|
+
}
|
|
154
|
+
else if (typeof options === 'string') {
|
|
155
|
+
param = Param__1["default"].from(__assign(__assign({}, paramOptions), { name: options }), this, 'properties');
|
|
156
|
+
}
|
|
157
|
+
else if (options instanceof Param__1["default"]) {
|
|
158
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
159
|
+
param = options;
|
|
160
|
+
Object.assign(param, relationOptions);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
param = Param__1["default"].from(__assign(__assign({}, paramOptions), options), this, 'properties');
|
|
164
|
+
}
|
|
165
|
+
this.properties.splice(index, 0, param);
|
|
166
|
+
return param;
|
|
167
|
+
};
|
|
168
|
+
MsgTriggerEvent.prototype.insertParamAt = function (options, index) {
|
|
169
|
+
var node = this._insertParamAt(options, index);
|
|
170
|
+
node.create({
|
|
171
|
+
index: index,
|
|
172
|
+
parentNode: this,
|
|
173
|
+
parentKey: 'properties'
|
|
174
|
+
});
|
|
175
|
+
return node;
|
|
176
|
+
};
|
|
177
|
+
MsgTriggerEvent.prototype._addParam = function (options) {
|
|
178
|
+
var index = this.properties.length;
|
|
179
|
+
return this._insertParamAt(options, index);
|
|
180
|
+
};
|
|
181
|
+
MsgTriggerEvent.prototype.addParam = function (options) {
|
|
182
|
+
var node = this._addParam(options);
|
|
183
|
+
var index = this.properties.indexOf(node);
|
|
184
|
+
node.create({
|
|
185
|
+
index: index,
|
|
186
|
+
parentNode: this,
|
|
187
|
+
parentKey: 'properties'
|
|
188
|
+
});
|
|
189
|
+
return node;
|
|
190
|
+
};
|
|
191
|
+
MsgTriggerEvent.prototype.removeParam = function (options) {
|
|
192
|
+
var param;
|
|
193
|
+
if (typeof options === 'string') {
|
|
194
|
+
param = this.properties.find(function (item) { return item.name === options; });
|
|
195
|
+
if (!param) {
|
|
196
|
+
throw new Error('找不到输入参数 ' + options);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
param = options;
|
|
201
|
+
}
|
|
202
|
+
return param["delete"]();
|
|
203
|
+
};
|
|
204
|
+
MsgTriggerEvent.prototype.__removeParam = function (param) {
|
|
205
|
+
var parentKey = param.parentKey;
|
|
206
|
+
var params = {
|
|
207
|
+
parentNode: this,
|
|
208
|
+
parentKey: parentKey,
|
|
209
|
+
index: -1,
|
|
210
|
+
object: null,
|
|
211
|
+
oldObject: param
|
|
212
|
+
};
|
|
213
|
+
if (parentKey) {
|
|
214
|
+
params.parentKey = parentKey;
|
|
215
|
+
if (Array.isArray(this[parentKey])) {
|
|
216
|
+
var index = this[parentKey].indexOf(param);
|
|
217
|
+
~index && this[parentKey].splice(index, 1);
|
|
218
|
+
params.index = index;
|
|
219
|
+
}
|
|
220
|
+
else if (this[parentKey] === param) {
|
|
221
|
+
params.index = 0;
|
|
222
|
+
this[parentKey] = undefined;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return params;
|
|
226
|
+
};
|
|
227
|
+
var MsgTriggerEvent_1;
|
|
228
|
+
__decorate([
|
|
229
|
+
decorators_1.property()
|
|
230
|
+
], MsgTriggerEvent.prototype, "concept");
|
|
231
|
+
__decorate([
|
|
232
|
+
decorators_1.property('Param')
|
|
233
|
+
], MsgTriggerEvent.prototype, "properties");
|
|
234
|
+
MsgTriggerEvent = MsgTriggerEvent_1 = __decorate([
|
|
235
|
+
decorators_1.concept('触发器事件')
|
|
236
|
+
], MsgTriggerEvent);
|
|
237
|
+
return MsgTriggerEvent;
|
|
238
|
+
}(TriggerEvent__1["default"]));
|
|
239
|
+
exports.MsgTriggerEvent = MsgTriggerEvent;
|
|
240
|
+
classMap_1["default"].MsgTriggerEvent = MsgTriggerEvent;
|
|
241
|
+
exports["default"] = MsgTriggerEvent;
|
|
242
|
+
//================================================================================
|
|
243
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
244
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
245
|
+
//================================================================================
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
27
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
30
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
+
};
|
|
32
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
33
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
34
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
35
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
36
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
37
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
38
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
42
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
43
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
44
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
45
|
+
function step(op) {
|
|
46
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
47
|
+
while (_) try {
|
|
48
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
49
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
50
|
+
switch (op[0]) {
|
|
51
|
+
case 0: case 1: t = op; break;
|
|
52
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
53
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
54
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
55
|
+
default:
|
|
56
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
57
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
58
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
59
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
60
|
+
if (t[2]) _.ops.pop();
|
|
61
|
+
_.trys.pop(); continue;
|
|
62
|
+
}
|
|
63
|
+
op = body.call(thisArg, _);
|
|
64
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
65
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
exports.__esModule = true;
|
|
69
|
+
exports.OqlQueryComponent = void 0;
|
|
70
|
+
var translator_1 = require("../translator");
|
|
71
|
+
var Identifier__1 = require("./Identifier__");
|
|
72
|
+
var MemberExpression__1 = require("./MemberExpression__");
|
|
73
|
+
var decorators_1 = require("../decorators");
|
|
74
|
+
var classMap_1 = require("../common/classMap");
|
|
75
|
+
var LogicItem__1 = require("./LogicItem__");
|
|
76
|
+
/**
|
|
77
|
+
* SQL 查询
|
|
78
|
+
*/
|
|
79
|
+
var OqlQueryComponent = /** @class */ (function (_super) {
|
|
80
|
+
__extends(OqlQueryComponent, _super);
|
|
81
|
+
/**
|
|
82
|
+
* @param source 需要合并的部分参数
|
|
83
|
+
*/
|
|
84
|
+
function OqlQueryComponent(source) {
|
|
85
|
+
var _this = this;
|
|
86
|
+
source = Object.assign({}, OqlQueryComponent_1.getDefaultOptions(), source);
|
|
87
|
+
_this = _super.call(this, source) || this;
|
|
88
|
+
/**
|
|
89
|
+
* 产品概念
|
|
90
|
+
*/
|
|
91
|
+
_this.concept = 'OqlQueryComponent';
|
|
92
|
+
/**
|
|
93
|
+
* SQL 查询标题
|
|
94
|
+
*/
|
|
95
|
+
_this.label = 'SQL 查询';
|
|
96
|
+
/**
|
|
97
|
+
* SQL 查询
|
|
98
|
+
*/
|
|
99
|
+
_this.code = undefined;
|
|
100
|
+
/**
|
|
101
|
+
* 相关类型
|
|
102
|
+
*/
|
|
103
|
+
_this.typeAnnotation = undefined;
|
|
104
|
+
/**
|
|
105
|
+
* 数据源
|
|
106
|
+
*/
|
|
107
|
+
_this.dataSource = undefined;
|
|
108
|
+
_this._TsVariables = [];
|
|
109
|
+
// 节点的sourcemap
|
|
110
|
+
_this.codeSourceMap = undefined;
|
|
111
|
+
_super.prototype.subConstructor.call(_this, source);
|
|
112
|
+
return _this;
|
|
113
|
+
}
|
|
114
|
+
OqlQueryComponent_1 = OqlQueryComponent;
|
|
115
|
+
OqlQueryComponent.prototype.getClassName = function () {
|
|
116
|
+
return 'OqlQueryComponent';
|
|
117
|
+
};
|
|
118
|
+
OqlQueryComponent.from = function (source, parentNode, parentKey) {
|
|
119
|
+
return _super.from.call(this, source, parentNode, parentKey);
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* 设置SQL 查询
|
|
123
|
+
*/
|
|
124
|
+
OqlQueryComponent.prototype.setCode = function (code) {
|
|
125
|
+
var object = {
|
|
126
|
+
code: code
|
|
127
|
+
};
|
|
128
|
+
this.update(__assign({}, object));
|
|
129
|
+
};
|
|
130
|
+
OqlQueryComponent.prototype.removeTypeAnnotation = function (options) {
|
|
131
|
+
var typeAnnotation;
|
|
132
|
+
if (typeof options === 'string') {
|
|
133
|
+
typeAnnotation = this.typeAnnotation;
|
|
134
|
+
if (!typeAnnotation) {
|
|
135
|
+
throw new Error('找不到类型标注 ' + options);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
typeAnnotation = options;
|
|
140
|
+
}
|
|
141
|
+
return typeAnnotation["delete"]();
|
|
142
|
+
};
|
|
143
|
+
OqlQueryComponent.prototype.__removeTypeAnnotation = function (typeAnnotation) {
|
|
144
|
+
var parentKey = typeAnnotation.parentKey;
|
|
145
|
+
var params = {
|
|
146
|
+
parentNode: this,
|
|
147
|
+
parentKey: parentKey,
|
|
148
|
+
index: -1,
|
|
149
|
+
object: null,
|
|
150
|
+
oldObject: typeAnnotation
|
|
151
|
+
};
|
|
152
|
+
if (parentKey) {
|
|
153
|
+
params.parentKey = parentKey;
|
|
154
|
+
if (Array.isArray(this[parentKey])) {
|
|
155
|
+
var index = this[parentKey].indexOf(typeAnnotation);
|
|
156
|
+
~index && this[parentKey].splice(index, 1);
|
|
157
|
+
params.index = index;
|
|
158
|
+
}
|
|
159
|
+
else if (this[parentKey] === typeAnnotation) {
|
|
160
|
+
params.index = 0;
|
|
161
|
+
this[parentKey] = undefined;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return params;
|
|
165
|
+
};
|
|
166
|
+
//================================================================================
|
|
167
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
168
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
169
|
+
//================================================================================
|
|
170
|
+
/**
|
|
171
|
+
* APP数据源重命名时,同步OQL数据源;此方法仅提供给APP重命名时使用
|
|
172
|
+
*/
|
|
173
|
+
OqlQueryComponent.prototype.renameDataSource = function (dataSource) {
|
|
174
|
+
// 此参数dataSource不带命名空间
|
|
175
|
+
// 考虑到扩展模块不允许重命名,所以拼接app.dataSources
|
|
176
|
+
this.setDataSource("app.dataSources." + dataSource);
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* 设置OQL数据源
|
|
180
|
+
*/
|
|
181
|
+
OqlQueryComponent.prototype.setDataSource = function (dataSource) {
|
|
182
|
+
this.codeSourceMap = null;
|
|
183
|
+
this.update({
|
|
184
|
+
dataSource: dataSource
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
OqlQueryComponent.prototype.getTextVariables = function () {
|
|
188
|
+
this._TsVariables = [];
|
|
189
|
+
var str = this.code;
|
|
190
|
+
var variables = new Set();
|
|
191
|
+
var temp;
|
|
192
|
+
var re = /\{(.+?)\}/g;
|
|
193
|
+
while ((temp = re.exec(str))) {
|
|
194
|
+
var variable = temp[1];
|
|
195
|
+
variable = variable.replaceAll(' ', '');
|
|
196
|
+
variables.add(variable);
|
|
197
|
+
}
|
|
198
|
+
for (var _i = 0, variables_1 = variables; _i < variables_1.length; _i++) { // 遍历Set
|
|
199
|
+
var variable = variables_1[_i];
|
|
200
|
+
var newVariable = void 0;
|
|
201
|
+
if (variable.includes('.')) {
|
|
202
|
+
var arr = variable.split('.');
|
|
203
|
+
for (var i = 0; i < arr.length; i++) {
|
|
204
|
+
if (!newVariable) {
|
|
205
|
+
// value需要拼接生成
|
|
206
|
+
newVariable = new Identifier__1["default"]({ name: arr[i] });
|
|
207
|
+
newVariable.noTsReName = true;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
var property_1 = new Identifier__1["default"]({ name: arr[i] });
|
|
211
|
+
property_1.noTsReName = true;
|
|
212
|
+
newVariable = new MemberExpression__1["default"]({
|
|
213
|
+
object: newVariable,
|
|
214
|
+
property: property_1
|
|
215
|
+
});
|
|
216
|
+
newVariable.noTsReName = true;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
newVariable = new Identifier__1["default"]({ name: variable });
|
|
222
|
+
newVariable.noTsReName = true;
|
|
223
|
+
}
|
|
224
|
+
newVariable.parentNode = this;
|
|
225
|
+
newVariable.parentKey = '_TsVariables';
|
|
226
|
+
this._TsVariables.push(newVariable);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
OqlQueryComponent.prototype.getTypeBanError = function () {
|
|
230
|
+
var _this = this;
|
|
231
|
+
var _a;
|
|
232
|
+
var sqlTypeBan = false;
|
|
233
|
+
if (this.typeAnnotation) {
|
|
234
|
+
var getSqlTypeBan_1 = function (typeAnnotation) {
|
|
235
|
+
var ref = _this.getSelectRef(typeAnnotation);
|
|
236
|
+
if (ref === null || ref === void 0 ? void 0 : ref.length) {
|
|
237
|
+
ref.forEach(function (item) {
|
|
238
|
+
// 如果有类型但是类型不是基本类型,就需要打开开关,注入变量
|
|
239
|
+
if ((item === null || item === void 0 ? void 0 : item.typeAnnotation) && item.typeAnnotation.typeNamespace !== 'nasl.core' && !(item.typeAnnotation.typeNamespace.endsWith('.enums'))) {
|
|
240
|
+
sqlTypeBan = true;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
if ((_a = this.typeAnnotation.typeArguments) === null || _a === void 0 ? void 0 : _a.length) {
|
|
246
|
+
// list 就去校验一下内部的类型
|
|
247
|
+
if (this.typeAnnotation.typeName === 'List') {
|
|
248
|
+
this.typeAnnotation.typeArguments.forEach(function (item) {
|
|
249
|
+
getSqlTypeBan_1(item);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
// 别的都不放开
|
|
254
|
+
sqlTypeBan = true;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
getSqlTypeBan_1(this.typeAnnotation);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return sqlTypeBan;
|
|
262
|
+
};
|
|
263
|
+
OqlQueryComponent.prototype.toEmbeddedTS = function (state) {
|
|
264
|
+
var _a, _b, _c, _d, _e, _f;
|
|
265
|
+
var code;
|
|
266
|
+
var typeAnnotation = this.typeAnnotation;
|
|
267
|
+
if (typeAnnotation) {
|
|
268
|
+
code = "(function(): " + typeAnnotation.toEmbeddedTS() + " {\n";
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
code = "(function __oqlQueryFn" + String(this.id).slice(0, 8) + " () {\n";
|
|
272
|
+
}
|
|
273
|
+
var indent1 = translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1);
|
|
274
|
+
// this.dataSource: 'app.dataSources.defaultDS';
|
|
275
|
+
if (this.dataSource) {
|
|
276
|
+
code += indent1;
|
|
277
|
+
code += "const dataSource = " + (this.dataSource || 'app.dataSources.defaultDS') + ";\n";
|
|
278
|
+
}
|
|
279
|
+
var hasSyntaxErrors = !!((_c = (_b = (_a = this.codeSourceMap) === null || _a === void 0 ? void 0 : _a.oqlSyntaxError) === null || _b === void 0 ? void 0 : _b.syntaxErrors) === null || _c === void 0 ? void 0 : _c.length);
|
|
280
|
+
// 生成内部的ts内容
|
|
281
|
+
if (!this.code) {
|
|
282
|
+
// SQL 为空
|
|
283
|
+
code += indent1 + "__OQL_EMPTY_ERROR__;\n";
|
|
284
|
+
}
|
|
285
|
+
else if (hasSyntaxErrors) {
|
|
286
|
+
var syntaxErrors = ((_e = (_d = this.codeSourceMap) === null || _d === void 0 ? void 0 : _d.oqlSyntaxError) === null || _e === void 0 ? void 0 : _e.syntaxErrors) || [];
|
|
287
|
+
var warningList = syntaxErrors.filter(function (err) { return err.errorMsg.includes('别名不符合规范'); });
|
|
288
|
+
if (warningList.length === syntaxErrors.length) {
|
|
289
|
+
// SQL 别名警告
|
|
290
|
+
code += indent1 + "__OQL_ALIAS_WARNING__;\n";
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
if (warningList.length > 0) {
|
|
294
|
+
// SQL 别名警告
|
|
295
|
+
code += indent1 + "__OQL_ALIAS_WARNING__;\n";
|
|
296
|
+
}
|
|
297
|
+
// SQL 语法错误
|
|
298
|
+
code += indent1 + "__OQL_GRAMMAR_ERROR__;\n";
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// insert typescript code
|
|
302
|
+
var typescript = (_f = this.codeSourceMap) === null || _f === void 0 ? void 0 : _f.typescript;
|
|
303
|
+
if (typescript) {
|
|
304
|
+
code += indent1 + "const __oqlQueryResult = " + typescript + ";";
|
|
305
|
+
}
|
|
306
|
+
// 临时方案拼接字符串
|
|
307
|
+
this.getTextVariables();
|
|
308
|
+
// 翻译字段
|
|
309
|
+
code += '\n';
|
|
310
|
+
this._TsVariables.forEach(function (variable) {
|
|
311
|
+
code += variable.toEmbeddedTS(translator_1.shiftState(state, code));
|
|
312
|
+
code += ';\n';
|
|
313
|
+
});
|
|
314
|
+
code += '\n';
|
|
315
|
+
if (typescript && !typeAnnotation) {
|
|
316
|
+
code += indent1 + "return __oqlQueryResult;\n";
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
code += indent1 + "return;\n";
|
|
320
|
+
}
|
|
321
|
+
code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0)) + '})()';
|
|
322
|
+
return code;
|
|
323
|
+
};
|
|
324
|
+
// 从服务端获取 SQL -> TS 的翻译和 sourceMap
|
|
325
|
+
OqlQueryComponent.prototype.requestEmbeddedTS = function () {
|
|
326
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
327
|
+
return __generator(this, function (_a) {
|
|
328
|
+
if (this.code) {
|
|
329
|
+
return [2 /*return*/, this.code];
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
this.codeSourceMap = { typescript: '', lexicalErrorCode: 1001 };
|
|
333
|
+
}
|
|
334
|
+
return [2 /*return*/];
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* 获取添加时的默认选项
|
|
340
|
+
* @returns
|
|
341
|
+
*/
|
|
342
|
+
OqlQueryComponent.getDefaultOptions = function () {
|
|
343
|
+
return {
|
|
344
|
+
dataSource: 'app.dataSources.defaultDS'
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
var OqlQueryComponent_1;
|
|
348
|
+
__decorate([
|
|
349
|
+
decorators_1.property()
|
|
350
|
+
], OqlQueryComponent.prototype, "concept");
|
|
351
|
+
__decorate([
|
|
352
|
+
decorators_1.property()
|
|
353
|
+
], OqlQueryComponent.prototype, "label");
|
|
354
|
+
__decorate([
|
|
355
|
+
decorators_1.property()
|
|
356
|
+
], OqlQueryComponent.prototype, "code");
|
|
357
|
+
__decorate([
|
|
358
|
+
decorators_1.property('TypeAnnotation')
|
|
359
|
+
], OqlQueryComponent.prototype, "typeAnnotation");
|
|
360
|
+
__decorate([
|
|
361
|
+
decorators_1.property()
|
|
362
|
+
], OqlQueryComponent.prototype, "dataSource");
|
|
363
|
+
__decorate([
|
|
364
|
+
translator_1.withSourceMap()
|
|
365
|
+
], OqlQueryComponent.prototype, "toEmbeddedTS");
|
|
366
|
+
OqlQueryComponent = OqlQueryComponent_1 = __decorate([
|
|
367
|
+
decorators_1.concept('SQL 查询')
|
|
368
|
+
], OqlQueryComponent);
|
|
369
|
+
return OqlQueryComponent;
|
|
370
|
+
}(LogicItem__1["default"]));
|
|
371
|
+
exports.OqlQueryComponent = OqlQueryComponent;
|
|
372
|
+
classMap_1["default"].OqlQueryComponent = OqlQueryComponent;
|
|
373
|
+
exports["default"] = OqlQueryComponent;
|
|
374
|
+
//================================================================================
|
|
375
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
376
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
377
|
+
//================================================================================
|
|
@@ -324,7 +324,7 @@ var Param = /** @class */ (function (_super) {
|
|
|
324
324
|
parsedValue = (_a = tryJSONParse(defaultValue)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
-
code += this.name + "
|
|
327
|
+
code += this.name + " !== undefined ? " + this.name + " : (this.$route.query.hasOwnProperty('" + this.name + "') ? this.$genInitFromSchema('" + (typeAnnotation === null || typeAnnotation === void 0 ? void 0 : typeAnnotation.sortedTypeKey) + "', this.$route.query." + this.name + ") : " + JSON.stringify(this.defaultValue) + ")";
|
|
328
328
|
if (needGenInitFromSchema) {
|
|
329
329
|
code += ")";
|
|
330
330
|
}
|