@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
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
3
|
exports.genFrontendBundleFiles = exports.genBundleFiles = void 0;
|
|
4
|
+
var breakpoint_1 = require("../breakpoint");
|
|
4
5
|
var utils = require("../utils");
|
|
5
6
|
var _1 = require(".");
|
|
6
7
|
var compileComponent_1 = require("./compileComponent");
|
|
7
8
|
var JSON5 = require("json5");
|
|
8
9
|
var UglifyJS = require("uglify-js-export");
|
|
9
10
|
var genMetaData_1 = require("./genMetaData");
|
|
11
|
+
var microApp_1 = require("./microApp");
|
|
10
12
|
function genBundleFiles(app, frontend, config) {
|
|
11
13
|
var _a, _b, _c, _d, _e;
|
|
12
14
|
var fnNuimsDomain = ((_a = config === null || config === void 0 ? void 0 : config.envNuimsDomain) === null || _a === void 0 ? void 0 : _a[config === null || config === void 0 ? void 0 : config.env]) || (config === null || config === void 0 ? void 0 : config.nuimsDomain);
|
|
@@ -20,6 +22,7 @@ function genBundleFiles(app, frontend, config) {
|
|
|
20
22
|
module.views && views.push.apply(views, module.views);
|
|
21
23
|
});
|
|
22
24
|
var componentMap = {};
|
|
25
|
+
(config === null || config === void 0 ? void 0 : config.debug) && breakpoint_1.genBreakpoints(app);
|
|
23
26
|
utils.traverse(function (current) {
|
|
24
27
|
if (current.node.toVueOptions)
|
|
25
28
|
componentMap[current.node.id] = current.node.toVueOptions();
|
|
@@ -28,6 +31,7 @@ function genBundleFiles(app, frontend, config) {
|
|
|
28
31
|
children: views
|
|
29
32
|
}
|
|
30
33
|
});
|
|
34
|
+
(config === null || config === void 0 ? void 0 : config.debug) && breakpoint_1.clearBreakpoints(app);
|
|
31
35
|
/**
|
|
32
36
|
* vue.config.js page options
|
|
33
37
|
*/
|
|
@@ -161,6 +165,7 @@ function genBundleFiles(app, frontend, config) {
|
|
|
161
165
|
routesStr += ']';
|
|
162
166
|
var platformConfig = JSON5.stringify({
|
|
163
167
|
appConfig: {
|
|
168
|
+
id: app.id,
|
|
164
169
|
project: app.name,
|
|
165
170
|
domainName: app.name,
|
|
166
171
|
nuimsDomain: fnNuimsDomain,
|
|
@@ -175,7 +180,7 @@ function genBundleFiles(app, frontend, config) {
|
|
|
175
180
|
documentTitle: frontend.documentTitle,
|
|
176
181
|
rootViewData: rootViewData,
|
|
177
182
|
basePath: frontend.prefixPath,
|
|
178
|
-
frontendName: frontend.name,
|
|
183
|
+
//frontendName: frontend.name,
|
|
179
184
|
// 加上统一前缀
|
|
180
185
|
sysPrefixPath: app.sysPrefixPath
|
|
181
186
|
},
|
|
@@ -201,8 +206,11 @@ function genBundleFiles(app, frontend, config) {
|
|
|
201
206
|
if (frontend.documentIcon) {
|
|
202
207
|
content += "{\n const link = document.createElement('link');\n link.rel = 'shortcut icon';\n link.href = `" + frontend.documentIcon + "`;\n document.head.appendChild(link);\n }";
|
|
203
208
|
}
|
|
209
|
+
if (frontend.globalScaleEnabled) {
|
|
210
|
+
content += "{\n const body = document.body;\n const rootElement = document.documentElement;\n\n function scalePage() {\n const windowWidth = window.innerWidth;\n const baseWidth = " + (frontend.canvasWidth || frontend.defaultCanvasWidth) + ";\n const scale = windowWidth / baseWidth;\n body.style.transform = `scale(${scale})`;\n body.style.transformOrigin = '0 0';\n body.style.width = baseWidth + 'px';\n rootElement.style.height = '100vh';\n rootElement.style.overflow = 'auto';\n rootElement.style.setProperty('--scrollbar-size', 0);\n }\n window.addEventListener('resize', scalePage);\n scalePage()\n }";
|
|
211
|
+
}
|
|
204
212
|
content += "\n var customNames = " + customNames + ";\n for(var i=0;i<customNames.length;i++){\n var name = window.kebab2Camel(customNames[i]);\n if(window[name]){\n window.CloudUI.install(window.Vue, window[name]);\n }\n }";
|
|
205
|
-
content += "\n var platformConfig = " + platformConfig + ";\n var metaData = " + metaDataStr + ";\n var routes = " + routesStr + ";\n\n window.createLcapApp = () =>
|
|
213
|
+
content += "\n var platformConfig = " + platformConfig + ";\n var metaData = " + metaDataStr + ";\n var routes = " + routesStr + ";\n\n window.createLcapApp = () => {\n appVM = window.cloudAdminDesigner.init(platformConfig.appConfig, platformConfig, routes, metaData);\n\n try {\n var push = appVM.$router.history.push;\n appVM.$router.history.push = function (a, b) {\n push.apply(this, [a, b, console.warn]);\n };\n } catch (e) { console.error(e) }\n\n return window.appVM = appVM;\n };\n window.createLcapApp();\n })();";
|
|
206
214
|
if (config.env === 'dev') {
|
|
207
215
|
// 加载资源js
|
|
208
216
|
// const domain = fnLowcodeDomain.slice(fnLowcodeDomain.indexOf('.') + 1);
|
|
@@ -226,7 +234,11 @@ function genBundleFiles(app, frontend, config) {
|
|
|
226
234
|
bundleMinPath = "" + baseUrl + frontend.basePath + "/bundle." + _1.genHash(content) + ".min.js";
|
|
227
235
|
}
|
|
228
236
|
var otherJsList = ((_e = (_d = frontend) === null || _d === void 0 ? void 0 : _d.appletsConfig) === null || _e === void 0 ? void 0 : _e.enable) ? ['//res.wx.qq.com/open/js/jweixin-1.3.2.js'] : [];
|
|
229
|
-
var
|
|
237
|
+
var microAppIntegration = microApp_1.integrateMicroApp(frontend);
|
|
238
|
+
if (config === null || config === void 0 ? void 0 : config.debug) {
|
|
239
|
+
otherJsList.push(config.STATIC_URL + "/packages/@lcap/breakpoint-client@1.0.0/dist/index.js?time=" + Date.now());
|
|
240
|
+
}
|
|
241
|
+
var assetsContent = "(function() {\n const loadAssets = () => {\n LazyLoad.js(" + JSON5.stringify(assetsInfo.basic.js.concat(assetsInfo.custom.js, otherJsList).concat([bundleMinPath])) + ");\n LazyLoad.css(" + JSON5.stringify(assetsInfo.basic.css.concat(assetsInfo.custom.css)) + "); \n }\n\n " + (microAppIntegration || 'loadAssets();') + "\n})()\n";
|
|
230
242
|
var minifyObj = { code: '' };
|
|
231
243
|
// 开发环境加上sourceMap
|
|
232
244
|
if (config.env === 'dev') {
|
|
@@ -250,7 +262,6 @@ function genBundleFiles(app, frontend, config) {
|
|
|
250
262
|
content: assetsContent
|
|
251
263
|
},
|
|
252
264
|
];
|
|
253
|
-
console.log('outputs:', outputs);
|
|
254
265
|
return outputs;
|
|
255
266
|
}
|
|
256
267
|
exports.genBundleFiles = genBundleFiles;
|
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
50
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
51
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
52
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
53
|
+
r[k] = a[j];
|
|
54
|
+
return r;
|
|
55
|
+
};
|
|
56
|
+
exports.__esModule = true;
|
|
57
|
+
exports.genReleaseBody = void 0;
|
|
58
|
+
var concepts_1 = require("../concepts");
|
|
59
|
+
var genBundleFiles_1 = require("./genBundleFiles");
|
|
60
|
+
var permission_1 = require("./permission");
|
|
61
|
+
var utils = require("../utils");
|
|
62
|
+
function genReleaseBody(app, _a) {
|
|
63
|
+
var env = _a.env, replicas = _a.replicas, realRelease = _a.realRelease, appInfo = _a.appInfo, staticUrl = _a.staticUrl, _b = _a.frontends, frontends = _b === void 0 ? [] : _b, _c = _a.logPublishFunc, logPublishFunc = _c === void 0 ? function () { } : _c;
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
var authReport, logicPageResourceDtoList, releaseFrontends, body, NaslAnnotatedJSON, err_1, files, jsonString;
|
|
66
|
+
return __generator(this, function (_d) {
|
|
67
|
+
switch (_d.label) {
|
|
68
|
+
case 0:
|
|
69
|
+
if (!realRelease) return [3 /*break*/, 2];
|
|
70
|
+
authReport = getAuthReport(app, frontends);
|
|
71
|
+
return [4 /*yield*/, permission_1.genPermissionData(app)];
|
|
72
|
+
case 1:
|
|
73
|
+
logicPageResourceDtoList = _d.sent();
|
|
74
|
+
logPublishFunc("[\u6743\u9650] \"[" + app.title + "]\" \u5206\u6790\u6743\u9650\u6570\u636E\u6210\u529F\uFF01");
|
|
75
|
+
_d.label = 2;
|
|
76
|
+
case 2:
|
|
77
|
+
releaseFrontends = app.frontends.map(function (frontend) { return ({
|
|
78
|
+
name: frontend.name,
|
|
79
|
+
type: frontend.type,
|
|
80
|
+
path: frontend.path,
|
|
81
|
+
selected: frontends.includes(frontend),
|
|
82
|
+
title: frontend.title
|
|
83
|
+
}); });
|
|
84
|
+
body = __assign(__assign({}, authReport), { // 如果发布需要上报权限,导出源码不需要
|
|
85
|
+
logicPageResourceDtoList: logicPageResourceDtoList, logicAuthFlag: permission_1.genLogicAuthFlag(app), noAuthApiPathList: getAuthApiPathList(app, frontends), reportIdList: findAllReportIdList(app, frontends), appId: app.id, env: env,
|
|
86
|
+
replicas: replicas, callbackLogicsName: app.getExtensionsCallbackLogics(), frontends: releaseFrontends, files: [] });
|
|
87
|
+
if (logicPageResourceDtoList)
|
|
88
|
+
Object.assign(body, { logicPageResourceDtoList: logicPageResourceDtoList });
|
|
89
|
+
_d.label = 3;
|
|
90
|
+
case 3:
|
|
91
|
+
_d.trys.push([3, 5, , 6]);
|
|
92
|
+
return [4 /*yield*/, app.naslServer.getNaslAnnotatedJSON(app, true)];
|
|
93
|
+
case 4:
|
|
94
|
+
NaslAnnotatedJSON = _d.sent();
|
|
95
|
+
logPublishFunc("[\u8BED\u8A00] \"[" + app.title + "]\" \u83B7\u53D6\u7C7B\u578B\u6807\u6CE8\u6210\u529F\uFF01");
|
|
96
|
+
return [3 /*break*/, 6];
|
|
97
|
+
case 5:
|
|
98
|
+
err_1 = _d.sent();
|
|
99
|
+
console.error(err_1);
|
|
100
|
+
throw new Error('代码标注失败,请稍后重试!或刷新后重试!');
|
|
101
|
+
case 6:
|
|
102
|
+
files = [];
|
|
103
|
+
if (frontends && frontends.length) {
|
|
104
|
+
logPublishFunc("[\u4EE3\u7801] \"[" + app.title + "]\" \u751F\u6210\u9875\u9762\u4EE3\u7801\uFF1A\u5F00\u59CB");
|
|
105
|
+
files = genBundleFiles_1.genFrontendBundleFiles(app, frontends, Object.assign({}, appInfo, {
|
|
106
|
+
env: env,
|
|
107
|
+
appid: app.id,
|
|
108
|
+
devDnsAddr: app.devDnsAddr,
|
|
109
|
+
miniEnable: app.miniEnable
|
|
110
|
+
}));
|
|
111
|
+
if (files && files.length === 0) {
|
|
112
|
+
throw new Error('前端代码生成失败');
|
|
113
|
+
}
|
|
114
|
+
if (staticUrl)
|
|
115
|
+
files = replaceAssetUrl(files, appInfo.USER_STATIC_URL, staticUrl);
|
|
116
|
+
console.log(Date.now());
|
|
117
|
+
console.time('onGetDeploymentStatus');
|
|
118
|
+
logPublishFunc("[\u4EE3\u7801] \"[" + app.title + "]\" \u751F\u6210\u9875\u9762\u4EE3\u7801\uFF1A\u5B8C\u6210\uFF01");
|
|
119
|
+
}
|
|
120
|
+
// 如果是发布,就排除views,导出源码就不排除
|
|
121
|
+
if (realRelease) {
|
|
122
|
+
NaslAnnotatedJSON.frontends.forEach(function (frontend) {
|
|
123
|
+
delete frontend.views;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
jsonString = JSON.stringify(NaslAnnotatedJSON);
|
|
127
|
+
// 打印传给服务端的nasl,为了服务端排查问题方便
|
|
128
|
+
if (globalThis.window) {
|
|
129
|
+
console.info(NaslAnnotatedJSON, '标注后的nasl');
|
|
130
|
+
}
|
|
131
|
+
files.push({ name: 'nasl-annotated.json', content: jsonString });
|
|
132
|
+
body.files = files;
|
|
133
|
+
return [2 /*return*/, body];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
exports.genReleaseBody = genReleaseBody;
|
|
139
|
+
/**
|
|
140
|
+
* 权限上报数据
|
|
141
|
+
*/
|
|
142
|
+
function getAuthReport(app, frontends) {
|
|
143
|
+
var result = {
|
|
144
|
+
roleList: [],
|
|
145
|
+
resourceList: [],
|
|
146
|
+
resourceDataList: [],
|
|
147
|
+
roleResourceMappingList: []
|
|
148
|
+
};
|
|
149
|
+
result.roleList = app.roles;
|
|
150
|
+
var getAuth = function (target) {
|
|
151
|
+
var authDirective = target.bindDirectives.find(function (item) { return item.name === 'auth'; });
|
|
152
|
+
return authDirective === null || authDirective === void 0 ? void 0 : authDirective.value;
|
|
153
|
+
};
|
|
154
|
+
var loopViews = function (view, isMain, frontend) {
|
|
155
|
+
var _a;
|
|
156
|
+
if (view.children) {
|
|
157
|
+
view.children.forEach(function (item) { return loopViews(item, false, frontend); });
|
|
158
|
+
}
|
|
159
|
+
if (view.concept === 'View' && view.elements) {
|
|
160
|
+
view.elements.forEach(function (item) { return loopViews(item, false, frontend); });
|
|
161
|
+
}
|
|
162
|
+
if ((view.concept === 'View' && view.auth)
|
|
163
|
+
|| (view.concept === 'View' && !isMain && view.parentAuth)
|
|
164
|
+
|| (view.concept === 'ViewElement' && getAuth(view))) {
|
|
165
|
+
result.resourceList.push(view.authPath);
|
|
166
|
+
result.resourceDataList.push({
|
|
167
|
+
value: view.authPath,
|
|
168
|
+
description: view.authDescription,
|
|
169
|
+
type: view.concept === 'View' ? 'page' : 'component',
|
|
170
|
+
clientType: frontend.name
|
|
171
|
+
});
|
|
172
|
+
if (view.bindRoles) {
|
|
173
|
+
var _arr = view.bindRoles.map(function (it) { return ({
|
|
174
|
+
roleName: it,
|
|
175
|
+
resourcePath: view.authPath
|
|
176
|
+
}); });
|
|
177
|
+
(_a = result.roleResourceMappingList).push.apply(_a, _arr);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
frontends.forEach(function (frontend) {
|
|
182
|
+
frontend.views.forEach(function (view) { return loopViews(view, true, frontend); });
|
|
183
|
+
});
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
// 以下四个函数 导出源码也有引用 需同步改动
|
|
187
|
+
/**
|
|
188
|
+
* 上报白名单
|
|
189
|
+
*/
|
|
190
|
+
function getAuthApiPathList(app, frontends) {
|
|
191
|
+
var thisDiffLogicList = [];
|
|
192
|
+
/* 转换Path */
|
|
193
|
+
function getPathMethods(logicNameSpace) {
|
|
194
|
+
var logic = app.findNodeByCompleteName(logicNameSpace);
|
|
195
|
+
if (!logic) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
var logicName = logic === null || logic === void 0 ? void 0 : logic.name;
|
|
199
|
+
var _pathArr = logicNameSpace.split('.');
|
|
200
|
+
var isProcess = _pathArr[1] === 'processes';
|
|
201
|
+
var moduleNode = logic.getAncestor('Module');
|
|
202
|
+
var isEntity = false;
|
|
203
|
+
var namespaceLinkedNode = null;
|
|
204
|
+
var namespaceNode = logic.getAncestor('Namespace');
|
|
205
|
+
if (namespaceNode) {
|
|
206
|
+
namespaceLinkedNode = app.findNodeByCompleteName([namespaceNode.getNamespace(), namespaceNode.name].join('.'));
|
|
207
|
+
isEntity = namespaceNode && (namespaceLinkedNode === null || namespaceLinkedNode === void 0 ? void 0 : namespaceLinkedNode.concept) === 'Entity';
|
|
208
|
+
}
|
|
209
|
+
// 实体
|
|
210
|
+
if (isEntity) {
|
|
211
|
+
var dataSource = namespaceLinkedNode.parentNode;
|
|
212
|
+
if (dataSource.name !== 'defaultDS') {
|
|
213
|
+
return "/api/" + dataSource.name + "/" + getName(namespaceLinkedNode.name) + getEntityMethods(logic.name);
|
|
214
|
+
}
|
|
215
|
+
return "/api/" + getName(namespaceLinkedNode.name) + getEntityMethods(logic.name);
|
|
216
|
+
}
|
|
217
|
+
else if (moduleNode) {
|
|
218
|
+
// 外部模块引入的逻辑
|
|
219
|
+
return "/api/" + getModuleName(moduleNode.name) + "/" + logicName + ":POST";
|
|
220
|
+
}
|
|
221
|
+
else if (isProcess) {
|
|
222
|
+
if (_pathArr.length === 7) {
|
|
223
|
+
var _name = _pathArr[2];
|
|
224
|
+
var _path = _pathArr[4];
|
|
225
|
+
var _logic = _pathArr[6];
|
|
226
|
+
return "/api/" + _name + "/" + _path + "/" + _logic + ":POST";
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
var _name = _pathArr[2];
|
|
230
|
+
var _path = _pathArr[4];
|
|
231
|
+
return "/api/" + _name + "/" + _path + ":POST";
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
return "/api/lcplogics/" + logicName + ":POST";
|
|
236
|
+
}
|
|
237
|
+
function getName(name) {
|
|
238
|
+
var _name = name.replace(/[A-Z]/g, function (item) { return '-' + item.toLowerCase(); });
|
|
239
|
+
return _name[0] === '-' ? _name.slice(1) : _name;
|
|
240
|
+
}
|
|
241
|
+
function getModuleName(name) {
|
|
242
|
+
return name.replace(/-/g, '_');
|
|
243
|
+
}
|
|
244
|
+
function getEntityMethods(path) {
|
|
245
|
+
var name = '';
|
|
246
|
+
switch (path) {
|
|
247
|
+
case 'get':
|
|
248
|
+
name = ":GET";
|
|
249
|
+
break;
|
|
250
|
+
case 'import':
|
|
251
|
+
name = '/import:POST';
|
|
252
|
+
break;
|
|
253
|
+
case 'create':
|
|
254
|
+
name = ':POST';
|
|
255
|
+
break;
|
|
256
|
+
case 'update':
|
|
257
|
+
name = ':PUT';
|
|
258
|
+
break;
|
|
259
|
+
case 'delete':
|
|
260
|
+
name = ":DELETE";
|
|
261
|
+
break;
|
|
262
|
+
case 'createOrUpdate':
|
|
263
|
+
name = '/createOrUpdate:POST';
|
|
264
|
+
break;
|
|
265
|
+
case 'updateBy':
|
|
266
|
+
name = '/by:PUT';
|
|
267
|
+
break;
|
|
268
|
+
case 'deleteBy':
|
|
269
|
+
name = '/by:DELETE';
|
|
270
|
+
break;
|
|
271
|
+
case 'batchUpdate':
|
|
272
|
+
name = "/batch:PUT";
|
|
273
|
+
break;
|
|
274
|
+
case 'batchDelete':
|
|
275
|
+
name = "/batch:DELETE";
|
|
276
|
+
break;
|
|
277
|
+
case 'batchCreate':
|
|
278
|
+
name = "/batch:POST";
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
return name;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/* 获取LogicITEM */
|
|
285
|
+
function getStatement(state, frontend) {
|
|
286
|
+
var _a, _b, _c, _d, _e;
|
|
287
|
+
var logicItems = [];
|
|
288
|
+
if (state instanceof concepts_1.Assignment) {
|
|
289
|
+
logicItems = [state.left, state.right];
|
|
290
|
+
}
|
|
291
|
+
else if (state instanceof concepts_1.BatchAssignment) {
|
|
292
|
+
logicItems = __spreadArrays([(_a = state.left) === null || _a === void 0 ? void 0 : _a.expression], (_b = state.left) === null || _b === void 0 ? void 0 : _b.members, state.rights.map(function (item) { return __spreadArrays([item === null || item === void 0 ? void 0 : item.expression], item === null || item === void 0 ? void 0 : item.members); }).flat(1));
|
|
293
|
+
}
|
|
294
|
+
else if (state instanceof concepts_1.IfStatement) {
|
|
295
|
+
logicItems = __spreadArrays(state.consequent, state.alternate);
|
|
296
|
+
}
|
|
297
|
+
else if (state instanceof concepts_1.ForEachStatement) {
|
|
298
|
+
logicItems = __spreadArrays(state.body, [state.each, state.start, state.end]);
|
|
299
|
+
}
|
|
300
|
+
else if (state instanceof concepts_1.Match) {
|
|
301
|
+
logicItems = __spreadArrays([state.expression], state.cases.map(function (case1) { return getStatement(case1, frontend); }).flat(1));
|
|
302
|
+
}
|
|
303
|
+
else if (state instanceof concepts_1.MatchCase) {
|
|
304
|
+
logicItems = __spreadArrays(state.patterns, state.body);
|
|
305
|
+
}
|
|
306
|
+
else if (state instanceof concepts_1.SwitchStatement) {
|
|
307
|
+
logicItems = state.cases.map(function (case1) { return getStatement(case1, frontend); }).flat(1);
|
|
308
|
+
}
|
|
309
|
+
else if (state instanceof concepts_1.SwitchCase) {
|
|
310
|
+
logicItems = __spreadArrays([state.test], state.consequent);
|
|
311
|
+
}
|
|
312
|
+
else if (state instanceof concepts_1.WhileStatement) {
|
|
313
|
+
logicItems = __spreadArrays([state.test], state.body);
|
|
314
|
+
}
|
|
315
|
+
else if (state instanceof concepts_1.CallLogic) {
|
|
316
|
+
logicItems = (_c = state.arguments) === null || _c === void 0 ? void 0 : _c.map(function (item) { return item.expression; });
|
|
317
|
+
getLogic(state.calleewholeKey, frontend);
|
|
318
|
+
}
|
|
319
|
+
else if (state instanceof concepts_1.CallFunction) {
|
|
320
|
+
logicItems = (_d = state.arguments) === null || _d === void 0 ? void 0 : _d.map(function (item) { return item.expression; });
|
|
321
|
+
}
|
|
322
|
+
else if (state instanceof concepts_1.CallInterface) {
|
|
323
|
+
logicItems = (_e = state.arguments) === null || _e === void 0 ? void 0 : _e.map(function (item) { return item.expression; });
|
|
324
|
+
}
|
|
325
|
+
else if (state instanceof concepts_1.MemberExpression) {
|
|
326
|
+
logicItems = [state.object, state.property];
|
|
327
|
+
}
|
|
328
|
+
else if (state instanceof concepts_1.StringInterpolation) {
|
|
329
|
+
logicItems = __spreadArrays(state.expressions);
|
|
330
|
+
}
|
|
331
|
+
else if (state instanceof concepts_1.ExternalDestination) {
|
|
332
|
+
logicItems = [state.anchor, state.link];
|
|
333
|
+
}
|
|
334
|
+
else if (state instanceof concepts_1.NewComposite) {
|
|
335
|
+
logicItems = __spreadArrays((state.rights || []).map(function (item) { return item.expression; }));
|
|
336
|
+
}
|
|
337
|
+
else if (state instanceof concepts_1.NewList) {
|
|
338
|
+
logicItems = __spreadArrays(state.items);
|
|
339
|
+
}
|
|
340
|
+
return logicItems.filter(function (item) { return !!item; });
|
|
341
|
+
}
|
|
342
|
+
/* 获取非鉴权全局逻辑 */
|
|
343
|
+
function getLogic(key, frontend) {
|
|
344
|
+
if (!thisDiffLogicList.find(function (diffLogic) { return diffLogic.logicName === key && diffLogic.frontendName === frontend.name; })) {
|
|
345
|
+
thisDiffLogicList.push({ logicName: key, frontendName: frontend.name });
|
|
346
|
+
var logic = app.findNodeByCompleteName(key);
|
|
347
|
+
if (logic && logic.body && logic.body.length > 2) {
|
|
348
|
+
logic.body.map(function (item) { return getStatement(item, frontend); });
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
var importList = [];
|
|
353
|
+
var itemloop = function (state, view, frontend) {
|
|
354
|
+
var logicItems = getStatement(state, frontend);
|
|
355
|
+
if (logicItems.length) {
|
|
356
|
+
logicItems.map(function (item) { return itemloop(item, view, frontend); });
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
var loopEle = function (view, frontend) {
|
|
360
|
+
var _a, _b;
|
|
361
|
+
(_a = view === null || view === void 0 ? void 0 : view.children) === null || _a === void 0 ? void 0 : _a.forEach(function (vitem) { return loopEle(vitem, frontend); });
|
|
362
|
+
view.concept === 'View' && ((_b = view === null || view === void 0 ? void 0 : view.elements) === null || _b === void 0 ? void 0 : _b.forEach(function (ele) { return loopEle(ele, frontend); }));
|
|
363
|
+
if (!view.parentAuth) {
|
|
364
|
+
if (view.bindEvents) {
|
|
365
|
+
view.bindEvents.forEach(function (item) {
|
|
366
|
+
if (item.logics) {
|
|
367
|
+
item.logics.forEach(function (logic) {
|
|
368
|
+
if (logic.body.length > 2) {
|
|
369
|
+
logic.body.forEach(function (it) {
|
|
370
|
+
itemloop(it, view, frontend);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
var bindExpressions = [];
|
|
378
|
+
var bindAttrs = view.bindAttrs || [];
|
|
379
|
+
var bindDirectives = view.bindDirectives || [];
|
|
380
|
+
var bindStyles = view.bindStyles || [];
|
|
381
|
+
bindExpressions.push.apply(bindExpressions, __spreadArrays(bindAttrs, bindDirectives, bindStyles));
|
|
382
|
+
if (Array.isArray(bindExpressions) && bindExpressions.length) {
|
|
383
|
+
bindExpressions.forEach(function (bindExpression) { return utils.traverse(function (current) {
|
|
384
|
+
if (current.node instanceof concepts_1.CallLogic) {
|
|
385
|
+
getLogic(current.node.calleewholeKey, frontend);
|
|
386
|
+
}
|
|
387
|
+
}, { node: bindExpression }, {
|
|
388
|
+
mode: 'anyObject',
|
|
389
|
+
excludedKeySet: new Set([
|
|
390
|
+
// 排除playground里的表达式
|
|
391
|
+
'playground',
|
|
392
|
+
'parentNode',
|
|
393
|
+
'sourceMap',
|
|
394
|
+
'storageJSON',
|
|
395
|
+
'tsErrorDetail',
|
|
396
|
+
'NaslAnnotatedJSON',
|
|
397
|
+
'calledFrom',
|
|
398
|
+
'_events',
|
|
399
|
+
'_collectingList',
|
|
400
|
+
'_historyList',
|
|
401
|
+
])
|
|
402
|
+
}); });
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (view.concept === 'ViewElement' && (view.tag === 'u-uploader' || view.tag === 'van-uploader')) {
|
|
406
|
+
var attr = view === null || view === void 0 ? void 0 : view.bindAttrs.find(function (item) { return item.name === 'url'; });
|
|
407
|
+
if ((attr === null || attr === void 0 ? void 0 : attr.value.endsWith('/import')) && !view.parentAuth) {
|
|
408
|
+
importList.push({ path: attr === null || attr === void 0 ? void 0 : attr.value, frontendName: frontend.name });
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
var loopViews = function (view, isChild, frontend) {
|
|
413
|
+
// 有权限的页面下的逻辑都不需要上报白名单
|
|
414
|
+
if (!view.auth) {
|
|
415
|
+
if (view.logics) {
|
|
416
|
+
view.logics.forEach(function (logic) {
|
|
417
|
+
if (logic.body.length > 2) {
|
|
418
|
+
logic.body.forEach(function (it) {
|
|
419
|
+
itemloop(it, view, frontend);
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
if (view.bindEvents) {
|
|
425
|
+
view.bindEvents.forEach(function (item) {
|
|
426
|
+
if (item.logics) {
|
|
427
|
+
item.logics.forEach(function (logic) {
|
|
428
|
+
if (logic.body.length > 2) {
|
|
429
|
+
logic.body.forEach(function (it) {
|
|
430
|
+
itemloop(it, view, frontend);
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
view.children.forEach(function (item) { return loopViews(item, true, frontend); });
|
|
438
|
+
}
|
|
439
|
+
if (!isChild) {
|
|
440
|
+
view.children.forEach(function (vitem) { return loopEle(vitem, frontend); });
|
|
441
|
+
view.elements.forEach(function (vele) { return loopEle(vele, frontend); });
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
frontends.forEach(function (frontend) {
|
|
445
|
+
frontend.views.forEach(function (view) { return loopViews(view, false, frontend); });
|
|
446
|
+
});
|
|
447
|
+
var diffLogicList = thisDiffLogicList.filter(function (item) { return item.logicName.startsWith('app') || item.logicName.startsWith('extensions'); });
|
|
448
|
+
var authApiList = __spreadArrays(diffLogicList.map(function (diffLogic) {
|
|
449
|
+
var path = getPathMethods(diffLogic.logicName);
|
|
450
|
+
if (path)
|
|
451
|
+
return path + ":" + diffLogic.frontendName;
|
|
452
|
+
return '';
|
|
453
|
+
}).filter(function (path) { return !!path; }), Array.from(new Set(importList.map(function (item) { return item.path + ":POST:" + item.frontendName; })))).filter(function (item) { return !!item; });
|
|
454
|
+
return authApiList;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* 获取页面中所有 分析报告组件 的reportId
|
|
458
|
+
*/
|
|
459
|
+
function findAllReportIdList(app, frontends) {
|
|
460
|
+
var reportIds = [];
|
|
461
|
+
frontends.forEach(function (frontend) {
|
|
462
|
+
frontend.views.forEach(function (view) { return loop(view); });
|
|
463
|
+
});
|
|
464
|
+
function loop(root) {
|
|
465
|
+
if (root.concept === 'ViewElement') {
|
|
466
|
+
root.bindAttrs.forEach(function (attr) {
|
|
467
|
+
if (attr.name === 'reportId') {
|
|
468
|
+
reportIds.push(JSON.parse(attr.value || '{}').id);
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
if (root.children && root.children.length) {
|
|
473
|
+
root.children.forEach(function (item) { return loop(item); });
|
|
474
|
+
}
|
|
475
|
+
if (root.concept === 'View' && root.elements && root.elements.length) {
|
|
476
|
+
root.elements.forEach(function (item) { return loop(item); });
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return __spreadArrays(new Set(reportIds)).filter(Boolean);
|
|
480
|
+
}
|
|
481
|
+
function replaceAssetUrl(files, oldUrlWithoutProtocol, newUrlWithProtocol) {
|
|
482
|
+
var newUrlWithoutProtocol = newUrlWithProtocol.replace(/^https?:/, '');
|
|
483
|
+
if (newUrlWithoutProtocol === oldUrlWithoutProtocol)
|
|
484
|
+
return files;
|
|
485
|
+
var reg = new RegExp(oldUrlWithoutProtocol + "[^?'\"\\s]*\\?[^?'\"\\s]*(?=(\"|'))", 'g');
|
|
486
|
+
var reg2 = new RegExp("(https?:)?" + oldUrlWithoutProtocol, 'g');
|
|
487
|
+
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
|
|
488
|
+
var file = files_1[_i];
|
|
489
|
+
// 清除 query 参数
|
|
490
|
+
file.content = file.content.replace(reg, function () {
|
|
491
|
+
var args = [];
|
|
492
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
493
|
+
args[_i] = arguments[_i];
|
|
494
|
+
}
|
|
495
|
+
return args[0].split('?')[0];
|
|
496
|
+
});
|
|
497
|
+
file.content = file.content.replace(reg2, function (whole, protocol) { return (protocol ? newUrlWithProtocol : newUrlWithoutProtocol); });
|
|
498
|
+
file.name = file.name.replace(reg2, function (whole, protocol) { return (protocol ? newUrlWithProtocol : newUrlWithoutProtocol); });
|
|
499
|
+
}
|
|
500
|
+
return files;
|
|
501
|
+
}
|
|
@@ -180,6 +180,8 @@ var NaslServer = /** @class */ (function () {
|
|
|
180
180
|
records = _b.sent();
|
|
181
181
|
this.diagnosticManager.pushAll(records);
|
|
182
182
|
try {
|
|
183
|
+
// 结束诊断和标注
|
|
184
|
+
common_1.invokeCommand('naslServer:endWork');
|
|
183
185
|
common_1.invokeCommand('naslServer:nodeChange');
|
|
184
186
|
}
|
|
185
187
|
catch (e) {
|
|
@@ -981,7 +983,10 @@ var NaslServer = /** @class */ (function () {
|
|
|
981
983
|
var records;
|
|
982
984
|
return __generator(this, function (_a) {
|
|
983
985
|
switch (_a.label) {
|
|
984
|
-
case 0:
|
|
986
|
+
case 0:
|
|
987
|
+
// 开始诊断和标注
|
|
988
|
+
common_1.invokeCommand('naslServer:startWork');
|
|
989
|
+
return [4 /*yield*/, this.getDiagnosticRecords(fileNames)];
|
|
985
990
|
case 1:
|
|
986
991
|
records = _a.sent();
|
|
987
992
|
return [2 /*return*/];
|
|
@@ -2899,7 +2904,10 @@ var NaslServer = /** @class */ (function () {
|
|
|
2899
2904
|
if (minRange.node instanceof concepts_1.EntityProperty) {
|
|
2900
2905
|
minRange.setTypeMethods = 'setRelationEntity';
|
|
2901
2906
|
}
|
|
2902
|
-
else if (minRange.node instanceof concepts_1.QueryFieldExpression
|
|
2907
|
+
else if (minRange.node instanceof concepts_1.QueryFieldExpression) {
|
|
2908
|
+
minRange.setTypeMethods = 'setEntityAsNameAndEffect';
|
|
2909
|
+
}
|
|
2910
|
+
else if (minRange.node instanceof concepts_1.QueryGroupByExpression) {
|
|
2903
2911
|
minRange.setTypeMethods = 'setEntityAsName';
|
|
2904
2912
|
}
|
|
2905
2913
|
else if (minRange.node instanceof concepts_1.QueryFromExpression || minRange.node instanceof concepts_1.QueryJoinExpression) {
|
|
@@ -3182,7 +3190,18 @@ var NaslServer = /** @class */ (function () {
|
|
|
3182
3190
|
return minRange;
|
|
3183
3191
|
})
|
|
3184
3192
|
// 过滤掉不需要操作的
|
|
3185
|
-
.filter(function (item) { return !!item; })
|
|
3193
|
+
.filter(function (item) { return !!item; })
|
|
3194
|
+
// 排序:
|
|
3195
|
+
// QueryFieldExpression依赖Entity,把Entity放在QueryFieldExpression前,
|
|
3196
|
+
.sort(function (a, b) {
|
|
3197
|
+
if (a.node.concept === 'QueryFieldExpression') {
|
|
3198
|
+
return 1;
|
|
3199
|
+
}
|
|
3200
|
+
else if (b.node.concept === 'QueryFieldExpression') {
|
|
3201
|
+
return -1;
|
|
3202
|
+
}
|
|
3203
|
+
return 0;
|
|
3204
|
+
});
|
|
3186
3205
|
return result;
|
|
3187
3206
|
};
|
|
3188
3207
|
// 增加参数的副作用,用于更新logic和view
|
|
@@ -3972,7 +3991,7 @@ var NaslServer = /** @class */ (function () {
|
|
|
3972
3991
|
};
|
|
3973
3992
|
NaslServer.prototype.annotationToJson = function (typesMap, json) {
|
|
3974
3993
|
typesMap.forEach(function (value, node) {
|
|
3975
|
-
var _a, _b, _c, _d, _e;
|
|
3994
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3976
3995
|
// 如果节点本身有类型就不去在塞一遍了
|
|
3977
3996
|
// 有值而且没有类型再去设置
|
|
3978
3997
|
// 但是Identifier 和 MemberExpression 都用标注出来的因为本身是变量,有类型也需要覆盖一下
|
|
@@ -4043,7 +4062,7 @@ var NaslServer = /** @class */ (function () {
|
|
|
4043
4062
|
if (node instanceof concepts_1.Match) {
|
|
4044
4063
|
var matchExpression_1 = node.expression;
|
|
4045
4064
|
if (((_d = matchExpression_1 === null || matchExpression_1 === void 0 ? void 0 : matchExpression_1.__TypeAnnotation) === null || _d === void 0 ? void 0 : _d.typeKind) === 'union' && (matchExpression_1 instanceof concepts_1.Identifier || matchExpression_1 instanceof concepts_1.MemberExpression)) {
|
|
4046
|
-
var
|
|
4065
|
+
var _g = matchExpression_1 === null || matchExpression_1 === void 0 ? void 0 : matchExpression_1.getCurrentSource(), currentSource_6 = _g.currentSource, fileNode = _g.fileNode;
|
|
4047
4066
|
fileNode.sourceMap.forEach(function (item, itemNode) {
|
|
4048
4067
|
if (itemNode.concept === matchExpression_1.concept && item.code === currentSource_6.code) {
|
|
4049
4068
|
var jsonNode = jsoner.queryNodeByPath(json, itemNode.getNodePath(false));
|
|
@@ -4060,7 +4079,7 @@ var NaslServer = /** @class */ (function () {
|
|
|
4060
4079
|
jsonNode.typeAnnotation = value.toJSON();
|
|
4061
4080
|
}
|
|
4062
4081
|
}
|
|
4063
|
-
if (node instanceof concepts_1.NewComposite && ((_e = node.typeAnnotation) === null || _e === void 0 ? void 0 : _e.typeKind) === 'anonymousStructure') {
|
|
4082
|
+
if (node instanceof concepts_1.NewComposite && (((_e = node.typeAnnotation) === null || _e === void 0 ? void 0 : _e.typeKind) === 'anonymousStructure' || ((_f = node.typeAnnotation) === null || _f === void 0 ? void 0 : _f.typeKind) === 'generic')) {
|
|
4064
4083
|
var jsonNode = jsoner.queryNodeByPath(json, node.getNodePath(false));
|
|
4065
4084
|
jsonNode.typeAnnotation = value.toJSON();
|
|
4066
4085
|
}
|