@lcap/nasl 2.18.0 → 2.19.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/automate/template/myProcess.js +1 -1
- package/out/automate/template/myProcess.js.map +1 -1
- package/out/bak/translator.js +2 -1
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.js +1 -0
- package/out/common/BaseNode.js.map +1 -1
- package/out/common/Command.d.ts +1 -0
- package/out/common/Command.js +5 -1
- package/out/common/Command.js.map +1 -1
- package/out/concepts/AnonymousFunction__.d.ts +1 -0
- package/out/concepts/AnonymousFunction__.js +40 -2
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.d.ts +10 -0
- package/out/concepts/App__.js +132 -0
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.js +4 -3
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +2 -0
- package/out/concepts/BatchAssignment__.js +108 -47
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +8 -1
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/CallFunction__.js +51 -18
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +6 -4
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +2 -1
- package/out/concepts/CallLogic__.js +113 -26
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +4 -1
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +2 -0
- package/out/concepts/DataSource__.js +55 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +2 -1
- package/out/concepts/Destination__.js +90 -22
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -0
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +1 -0
- package/out/concepts/Identifier__.js +18 -7
- 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 +1 -0
- package/out/concepts/Logic__.js +33 -21
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.js +13 -8
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +345 -0
- package/out/concepts/NewComposite__.js +1067 -0
- package/out/concepts/NewComposite__.js.map +1 -0
- package/out/concepts/NewList__.d.ts +130 -0
- package/out/concepts/NewList__.js +353 -0
- package/out/concepts/NewList__.js.map +1 -0
- package/out/concepts/NewMap__.d.ts +221 -0
- package/out/concepts/NewMap__.js +492 -0
- package/out/concepts/NewMap__.js.map +1 -0
- package/out/concepts/New__.d.ts +19 -0
- package/out/concepts/New__.js +66 -0
- package/out/concepts/New__.js.map +1 -0
- package/out/concepts/Param__.d.ts +2 -0
- package/out/concepts/Param__.js +40 -3
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +31 -10
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/ProcessOutcomes__.d.ts +30 -0
- package/out/concepts/{ConstructArgument__.js → ProcessOutcomes__.js} +27 -48
- package/out/concepts/ProcessOutcomes__.js.map +1 -0
- package/out/concepts/Return__.js +2 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/SelectMembers__.js +3 -3
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/StringInterpolation__.js +12 -2
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +4 -0
- package/out/concepts/TypeAnnotation__.js +66 -12
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +1 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +2 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +13 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -0
- package/out/concepts/View__.js +13 -0
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.logging.js +5 -0
- package/out/concepts/basics/stdlib/nasl.logging.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +2 -0
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +151 -19
- package/out/concepts/basics/stdlib/nasl.util.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/enums/KEYWORDS.js +1 -0
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.js +32 -182
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +1 -10
- package/out/generator/genMetaData.js +184 -50
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +2 -0
- package/out/generator/genReleaseBody.js +29 -3
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/index.d.ts +1 -0
- package/out/generator/index.js +1 -0
- package/out/generator/index.js.map +1 -1
- package/out/generator/permission.d.ts +9 -0
- package/out/generator/permission.js +235 -0
- package/out/generator/permission.js.map +1 -0
- package/out/index.d.ts +1 -1
- package/out/index.js +2 -1
- package/out/index.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +69 -9
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +10 -20
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +1 -2
- package/out/server/formatTsUtils.js +36 -47
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.d.ts +2 -1
- package/out/server/getLogics.js +11 -0
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +1 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.js +1 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.d.ts +1 -1
- package/out/server/naslServer.js +181 -35
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.js +8 -0
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.js +66 -6
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/add.configs.js +4 -0
- package/out/service/creator/add.configs.js.map +1 -1
- package/out/service/datasource/api.d.ts +12 -0
- package/out/service/datasource/api.js +14 -0
- package/out/service/datasource/api.js.map +1 -0
- package/out/service/datasource/index.d.ts +2 -0
- package/out/service/datasource/index.js +10 -0
- package/out/service/datasource/index.js.map +1 -0
- package/out/service/storage/init.js +8 -1
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genEditTableBlock.js +4 -5
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +4 -3
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +16 -14
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +5 -5
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +6 -10
- package/out/templator/genTableBlock.js.map +1 -1
- package/package.json +1 -1
- package/sandbox/stdlib/dist/nasl.logging.js +0 -0
- package/sandbox/stdlib/dist/nasl.util.js +0 -0
- package/sandbox/stdlib/nasl.auth.ts +1 -1
- package/sandbox/stdlib/nasl.core.ts +4 -0
- package/sandbox/stdlib/nasl.logging.ts +4 -4
- package/sandbox/stdlib/nasl.util.ts +14 -5
- package/src/automate/template/myProcess.js +1 -1
- package/src/bak/translator.js +4 -1
- package/src/common/BaseNode.ts +1 -0
- package/src/common/Command.ts +4 -0
- package/src/concepts/AnonymousFunction__.ts +48 -2
- package/src/concepts/App__.ts +140 -41
- package/src/concepts/Assignee__.ts +4 -3
- package/src/concepts/BatchAssignment__.ts +111 -51
- package/src/concepts/BindAttribute__.ts +9 -2
- package/src/concepts/CallFunction__.ts +65 -31
- package/src/concepts/CallInterface__.ts +6 -22
- package/src/concepts/CallLogic__.ts +88 -24
- package/src/concepts/CallQueryComponent__.ts +4 -1
- package/src/concepts/DataSource__.ts +56 -1
- package/src/concepts/Destination__.ts +92 -22
- package/src/concepts/ForEachStatement__.ts +2 -0
- package/src/concepts/Identifier__.ts +18 -7
- package/src/concepts/LogicItem__.ts +1 -1
- package/src/concepts/Logic__.ts +54 -39
- package/src/concepts/Match__.ts +12 -8
- package/src/concepts/NewComposite__.ts +1356 -0
- package/src/concepts/NewList__.ts +444 -0
- package/src/concepts/NewMap__.ts +678 -0
- package/src/concepts/New__.ts +73 -0
- package/src/concepts/Param__.ts +238 -199
- package/src/concepts/ProcessElement__.ts +32 -10
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/ProcessOutcomes__.ts +90 -0
- package/src/concepts/Return__.ts +4 -1
- package/src/concepts/SelectMembers__.ts +3 -3
- package/src/concepts/StringInterpolation__.ts +21 -11
- package/src/concepts/TypeAnnotation__.ts +71 -50
- package/src/concepts/ValidationRule__.ts +19 -1
- package/src/concepts/Variable__.ts +4 -1
- package/src/concepts/ViewElement__.ts +23 -7
- package/src/concepts/View__.ts +16 -2
- package/src/concepts/basics/stdlib/dist/nasl.util.js +1602 -0
- package/src/concepts/basics/stdlib/nasl.auth.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.logging.ts +5 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +2 -0
- package/src/concepts/basics/stdlib/nasl.util.ts +153 -19
- package/src/concepts/dist/BindAttribute__.js +760 -0
- package/src/concepts/dist/BindEvent__.js +732 -0
- package/src/concepts/dist/CallFunction__.js +82 -28
- package/src/concepts/dist/CallLogic__.js +95 -27
- package/src/concepts/dist/Identifier__.js +311 -0
- package/src/concepts/dist/StringInterpolation__.js +231 -0
- package/src/concepts/dist/TypeAnnotation__.js +834 -0
- package/src/concepts/dist/ViewElement__.js +1692 -0
- package/src/concepts/dist/View__.js +1601 -0
- package/src/concepts/index__.ts +5 -0
- package/src/enums/KEYWORDS.ts +1 -0
- package/src/generator/dist/genBundleFiles.js +23 -176
- package/src/generator/dist/genMetaData.js +245 -0
- package/src/generator/dist/permission.js +392 -0
- package/src/generator/genBundleFiles.ts +34 -219
- package/src/generator/genMetaData.ts +177 -77
- package/src/generator/genReleaseBody.ts +30 -5
- package/src/generator/index.ts +1 -0
- package/src/generator/permission.ts +271 -0
- package/src/index.ts +1 -1
- package/src/server/dist/naslServer.js +443 -249
- package/src/server/entity2LogicNamespace.ts +70 -10
- package/src/server/extendBaseNode.ts +10 -21
- package/src/server/formatTsUtils.ts +36 -46
- package/src/server/getLogics.ts +13 -1
- package/src/server/getMemberIdentifier.ts +1 -1
- package/src/server/getProcesses.ts +1 -1
- package/src/server/naslServer.ts +181 -42
- package/src/server/process2LogicNamespace.ts +8 -0
- package/src/server/translator.ts +64 -7
- package/src/service/creator/add.configs.js +4 -0
- package/src/service/dataSource/api.js +11 -0
- package/src/service/dataSource/index.js +6 -0
- package/src/service/storage/dist/init.js +48 -10
- package/src/service/storage/init.ts +9 -2
- package/src/service/video/VideoTranscribe.js +1 -0
- package/src/templator/dist/genEditTableBlock.js +204 -0
- package/src/templator/dist/genGridViewBlock.js +265 -0
- package/src/templator/dist/genListViewBlock.js +84 -0
- package/src/templator/dist/genTableBlock.js +209 -0
- package/src/templator/dist/utils.js +527 -0
- package/src/templator/genEditTableBlock.ts +8 -16
- package/src/templator/genGetBlock.ts +18 -19
- package/src/templator/genGridViewBlock.ts +18 -18
- package/src/templator/genListViewBlock.ts +8 -11
- package/src/templator/genTableBlock.ts +6 -10
- package/ts-worker/dist/webpack.config.dev.js +3 -1
- package/ts-worker/lib/tsserver.js +8 -1
- package/out/automate/engine/2.14-components.d.ts +0 -1115
- package/out/automate/engine/2.14-components.js +0 -1087
- package/out/automate/engine/2.14-components.js.map +0 -1
- package/out/concepts/ConstructArgument__.d.ts +0 -40
- package/out/concepts/ConstructArgument__.js.map +0 -1
- package/out/concepts/Construct__.d.ts +0 -189
- package/out/concepts/Construct__.js +0 -340
- package/out/concepts/Construct__.js.map +0 -1
- package/out/concepts/MatchExpression__.d.ts +0 -97
- package/out/concepts/MatchExpression__.js +0 -281
- package/out/concepts/MatchExpression__.js.map +0 -1
- package/out/templator/sql-parser/index.d.ts +0 -1
- package/out/templator/sql-parser/index.js +0 -228
- package/out/templator/sql-parser/index.js.map +0 -1
- package/out/templator/sql-parser/parser.js +0 -26664
- package/out/templator/sql-parser/parser.js.map +0 -1
- package/src/concepts/dist/Anchor__.js +0 -179
- package/src/concepts/dist/Assignment__.js +0 -301
- package/src/concepts/dist/CallInterface__.js +0 -533
- package/src/concepts/dist/ForEachStatement__.js +0 -426
- package/src/concepts/dist/MatchCase__.js +0 -587
- package/src/concepts/dist/MemberExpression__.js +0 -348
- package/src/concepts/dist/Param__.js +0 -537
- package/src/concepts/dist/Return__.js +0 -493
- package/src/server/dist/formatTsUtils.js +0 -683
- package/ts-worker/lib/dist/tsserver.dev.js +0 -22953
- package/ts-worker/sources/lib/dist/tsserver.dev.js +0 -22912
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
39
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
40
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
41
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
42
|
+
r[k] = a[j];
|
|
43
|
+
return r;
|
|
44
|
+
};
|
|
45
|
+
exports.__esModule = true;
|
|
46
|
+
exports.genPermissionData = void 0;
|
|
47
|
+
var concepts_1 = require("../concepts");
|
|
48
|
+
var process2LogicNamespace_1 = require("../server/process2LogicNamespace");
|
|
49
|
+
function isReadOnly(logic) {
|
|
50
|
+
var _a;
|
|
51
|
+
return !!logic.module
|
|
52
|
+
|| ((_a = logic.parentNode) === null || _a === void 0 ? void 0 : _a.concept) === 'Namespace'
|
|
53
|
+
|| logic.parentKey === 'readonly'; // process logic
|
|
54
|
+
}
|
|
55
|
+
var cache = new Map();
|
|
56
|
+
var useCache = false;
|
|
57
|
+
function findUsage(logic) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
+
var res, _a;
|
|
60
|
+
return __generator(this, function (_b) {
|
|
61
|
+
switch (_b.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
if (useCache && cache.has(logic))
|
|
64
|
+
return [2 /*return*/, cache.get(logic)];
|
|
65
|
+
if (!isReadOnly(logic)) return [3 /*break*/, 2];
|
|
66
|
+
return [4 /*yield*/, logic.findReadOnlyLogicUsage()];
|
|
67
|
+
case 1:
|
|
68
|
+
_a = _b.sent();
|
|
69
|
+
return [3 /*break*/, 4];
|
|
70
|
+
case 2: return [4 /*yield*/, logic.findUsage()];
|
|
71
|
+
case 3:
|
|
72
|
+
_a = _b.sent();
|
|
73
|
+
_b.label = 4;
|
|
74
|
+
case 4:
|
|
75
|
+
res = _a;
|
|
76
|
+
if (useCache)
|
|
77
|
+
cache.set(logic, res);
|
|
78
|
+
return [2 /*return*/, res];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function openCache() {
|
|
84
|
+
useCache = true;
|
|
85
|
+
cache.clear();
|
|
86
|
+
}
|
|
87
|
+
function closeCache() {
|
|
88
|
+
useCache = false;
|
|
89
|
+
cache.clear();
|
|
90
|
+
}
|
|
91
|
+
function findViewLogicReferences(logic, vis) {
|
|
92
|
+
if (vis === void 0) { vis = new Set(); }
|
|
93
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
+
function dfs(usage) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
var logic_1, _i, _a, child;
|
|
97
|
+
return __generator(this, function (_b) {
|
|
98
|
+
switch (_b.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
if (!(usage.node instanceof concepts_1.CallLogic)) return [3 /*break*/, 2];
|
|
101
|
+
logic_1 = usage.node.logic;
|
|
102
|
+
if (!(!vis.has(logic_1) && logic_1)) return [3 /*break*/, 2];
|
|
103
|
+
vis.add(logic_1);
|
|
104
|
+
return [4 /*yield*/, findViewLogicReferences(logic_1, vis)];
|
|
105
|
+
case 1:
|
|
106
|
+
_b.sent();
|
|
107
|
+
_b.label = 2;
|
|
108
|
+
case 2:
|
|
109
|
+
if (!usage.children) return [3 /*break*/, 6];
|
|
110
|
+
_i = 0, _a = usage.children;
|
|
111
|
+
_b.label = 3;
|
|
112
|
+
case 3:
|
|
113
|
+
if (!(_i < _a.length)) return [3 /*break*/, 6];
|
|
114
|
+
child = _a[_i];
|
|
115
|
+
return [4 /*yield*/, dfs(child)];
|
|
116
|
+
case 4:
|
|
117
|
+
_b.sent();
|
|
118
|
+
_b.label = 5;
|
|
119
|
+
case 5:
|
|
120
|
+
_i++;
|
|
121
|
+
return [3 /*break*/, 3];
|
|
122
|
+
case 6: return [2 /*return*/];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
var usageMap, usages, _i, usages_1, usage;
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
switch (_a.label) {
|
|
130
|
+
case 0: return [4 /*yield*/, findUsage(logic)];
|
|
131
|
+
case 1:
|
|
132
|
+
usageMap = _a.sent();
|
|
133
|
+
usages = [];
|
|
134
|
+
usageMap.forEach(function (usage, node) {
|
|
135
|
+
if (node instanceof concepts_1.View)
|
|
136
|
+
usages.push(usage);
|
|
137
|
+
});
|
|
138
|
+
_i = 0, usages_1 = usages;
|
|
139
|
+
_a.label = 2;
|
|
140
|
+
case 2:
|
|
141
|
+
if (!(_i < usages_1.length)) return [3 /*break*/, 5];
|
|
142
|
+
usage = usages_1[_i];
|
|
143
|
+
return [4 /*yield*/, dfs(usage)];
|
|
144
|
+
case 3:
|
|
145
|
+
_a.sent();
|
|
146
|
+
_a.label = 4;
|
|
147
|
+
case 4:
|
|
148
|
+
_i++;
|
|
149
|
+
return [3 /*break*/, 2];
|
|
150
|
+
case 5: return [2 /*return*/, Array.from(vis)];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function findUIReferences(logic) {
|
|
156
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
157
|
+
function dfs(usage, parent) {
|
|
158
|
+
var _a;
|
|
159
|
+
if (parent === void 0) { parent = null; }
|
|
160
|
+
if ((usage.node instanceof concepts_1.BindEvent || usage.node instanceof concepts_1.BindAttribute)
|
|
161
|
+
&& (parent.node instanceof concepts_1.View || parent.node instanceof concepts_1.ViewElement))
|
|
162
|
+
res.push(parent.node);
|
|
163
|
+
(_a = usage.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
|
|
164
|
+
dfs(child, usage);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
var usageMap, usages, res;
|
|
168
|
+
return __generator(this, function (_a) {
|
|
169
|
+
switch (_a.label) {
|
|
170
|
+
case 0: return [4 /*yield*/, findUsage(logic)];
|
|
171
|
+
case 1:
|
|
172
|
+
usageMap = _a.sent();
|
|
173
|
+
usages = [];
|
|
174
|
+
usageMap.forEach(function (usage, node) {
|
|
175
|
+
if (node instanceof concepts_1.View)
|
|
176
|
+
usages.push(usage);
|
|
177
|
+
});
|
|
178
|
+
res = [];
|
|
179
|
+
usages.forEach(function (usage) {
|
|
180
|
+
dfs(usage);
|
|
181
|
+
});
|
|
182
|
+
return [2 /*return*/, res];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function findResourcesOfUI(view) {
|
|
188
|
+
var res = [];
|
|
189
|
+
var node = view;
|
|
190
|
+
while (node) {
|
|
191
|
+
if (node instanceof concepts_1.View && node.auth)
|
|
192
|
+
res.push({
|
|
193
|
+
path: node.authPath,
|
|
194
|
+
type: 'page'
|
|
195
|
+
});
|
|
196
|
+
else if (node instanceof concepts_1.ViewElement) {
|
|
197
|
+
var hasAuth = node.bindDirectives.find(function (directive) { return directive.name === 'auth'; });
|
|
198
|
+
if (hasAuth)
|
|
199
|
+
res.push({
|
|
200
|
+
path: node.authPath,
|
|
201
|
+
type: 'component'
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
node = node.parentNode;
|
|
205
|
+
}
|
|
206
|
+
return res;
|
|
207
|
+
}
|
|
208
|
+
function optimizeResourceData(resources) {
|
|
209
|
+
var res = removeRedundantResourceData(resources);
|
|
210
|
+
res = removeRedundantResourceData2(res);
|
|
211
|
+
return res;
|
|
212
|
+
}
|
|
213
|
+
// [['b'], ['a' ,'b']] 只需要保留 [['b']]
|
|
214
|
+
function removeRedundantResourceData(resources) {
|
|
215
|
+
var wm = new WeakMap();
|
|
216
|
+
for (var _i = 0, resources_1 = resources; _i < resources_1.length; _i++) {
|
|
217
|
+
var resource = resources_1[_i];
|
|
218
|
+
var hash = resource.map(function (_a) {
|
|
219
|
+
var path = _a.path, type = _a.type;
|
|
220
|
+
return path + "_" + type;
|
|
221
|
+
})
|
|
222
|
+
.join();
|
|
223
|
+
wm.set(resource, hash);
|
|
224
|
+
}
|
|
225
|
+
resources.sort(function (a, b) { return wm.get(a).length - wm.get(b).length; });
|
|
226
|
+
var res = [];
|
|
227
|
+
var hashs = [];
|
|
228
|
+
;
|
|
229
|
+
var _loop_1 = function (resource) {
|
|
230
|
+
var hash = wm.get(resource);
|
|
231
|
+
if (hashs.some(function (h) { return hash.endsWith(h); }))
|
|
232
|
+
return "continue";
|
|
233
|
+
res.push(resource);
|
|
234
|
+
hashs.push(hash);
|
|
235
|
+
};
|
|
236
|
+
for (var _a = 0, resources_2 = resources; _a < resources_2.length; _a++) {
|
|
237
|
+
var resource = resources_2[_a];
|
|
238
|
+
_loop_1(resource);
|
|
239
|
+
}
|
|
240
|
+
return res;
|
|
241
|
+
}
|
|
242
|
+
// 子页面有权限,父页面默认也有权限,所以不需要记录父页面权限;
|
|
243
|
+
// 组件有权限,组件所在的页面默认也有权限,所以不需要记录页面权限
|
|
244
|
+
function removeRedundantResourceData2(resources) {
|
|
245
|
+
return resources.map(function (resource) {
|
|
246
|
+
if (resource.length <= 1)
|
|
247
|
+
return resource;
|
|
248
|
+
if (resource[0].type === 'page')
|
|
249
|
+
return resource.slice(0, 1);
|
|
250
|
+
else if (resource[0].type === 'component')
|
|
251
|
+
return resource.filter(function (item) { return item.type === 'component'; });
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function findResourcesOfLogic(logic, uploaders) {
|
|
255
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
256
|
+
var logics, UIs, _i, logics_1, logic_2, _a, _b, service, res;
|
|
257
|
+
return __generator(this, function (_c) {
|
|
258
|
+
switch (_c.label) {
|
|
259
|
+
case 0: return [4 /*yield*/, findViewLogicReferences(logic)];
|
|
260
|
+
case 1:
|
|
261
|
+
logics = _c.sent();
|
|
262
|
+
logics.push(logic);
|
|
263
|
+
UIs = [];
|
|
264
|
+
_i = 0, logics_1 = logics;
|
|
265
|
+
_c.label = 2;
|
|
266
|
+
case 2:
|
|
267
|
+
if (!(_i < logics_1.length)) return [3 /*break*/, 5];
|
|
268
|
+
logic_2 = logics_1[_i];
|
|
269
|
+
_b = (_a = UIs).concat;
|
|
270
|
+
return [4 /*yield*/, findUIReferences(logic_2)];
|
|
271
|
+
case 3:
|
|
272
|
+
UIs = _b.apply(_a, [_c.sent()]);
|
|
273
|
+
_c.label = 4;
|
|
274
|
+
case 4:
|
|
275
|
+
_i++;
|
|
276
|
+
return [3 /*break*/, 2];
|
|
277
|
+
case 5:
|
|
278
|
+
service = logic.toService();
|
|
279
|
+
if (uploaders.has(service.url.path)) {
|
|
280
|
+
UIs = UIs.concat(uploaders.get(service.url.path));
|
|
281
|
+
}
|
|
282
|
+
UIs = Array.from(new Set(UIs));
|
|
283
|
+
res = UIs.map(function (ui) { return findResourcesOfUI(ui); });
|
|
284
|
+
return [2 /*return*/, optimizeResourceData(res)];
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function getAllLogics(app) {
|
|
290
|
+
var modules = [];
|
|
291
|
+
var entities = [];
|
|
292
|
+
var logics = [];
|
|
293
|
+
if (Array.isArray(app.dataSources)) {
|
|
294
|
+
app.dataSources.forEach(function (dataSource) {
|
|
295
|
+
if (Array.isArray(dataSource.entities)) {
|
|
296
|
+
entities.push.apply(entities, dataSource.entities);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
app.logics && logics.push.apply(logics, app.logics);
|
|
301
|
+
app.dependencies && modules.push.apply(modules, app.dependencies);
|
|
302
|
+
app.interfaceDependencies && modules.push.apply(modules, app.interfaceDependencies);
|
|
303
|
+
modules.forEach(function (module) {
|
|
304
|
+
module.logics && logics.push.apply(logics, module.logics);
|
|
305
|
+
if (Array.isArray(module.dataSources)) {
|
|
306
|
+
module.dataSources.forEach(function (dataSource) {
|
|
307
|
+
if (Array.isArray(dataSource.entities)) {
|
|
308
|
+
entities.push.apply(entities, dataSource.entities);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
var allLogics = [];
|
|
314
|
+
if (Array.isArray(entities)) {
|
|
315
|
+
entities.forEach(function (entity) {
|
|
316
|
+
var ns = entity.ns;
|
|
317
|
+
if (Array.isArray(ns === null || ns === void 0 ? void 0 : ns.logics)) {
|
|
318
|
+
allLogics.push.apply(allLogics, ns.logics);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
if (Array.isArray(logics)) {
|
|
323
|
+
allLogics.push.apply(allLogics, logics);
|
|
324
|
+
}
|
|
325
|
+
var processLogics = [];
|
|
326
|
+
var processTreeFragments = (app.processes || [])
|
|
327
|
+
.map(process2LogicNamespace_1.processToTreeFragment);
|
|
328
|
+
processTreeFragments.forEach(function (tree) {
|
|
329
|
+
processLogics.push.apply(processLogics, tree.logics);
|
|
330
|
+
tree.elements.forEach(function (element) {
|
|
331
|
+
processLogics.push.apply(processLogics, element.logics);
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
return {
|
|
335
|
+
logics: allLogics,
|
|
336
|
+
processLogics: processLogics
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function findUploaders(app) {
|
|
340
|
+
var map = new Map();
|
|
341
|
+
app.traverseChildren(function (node) {
|
|
342
|
+
var _a;
|
|
343
|
+
if (node instanceof concepts_1.ViewElement && ((_a = node.tag) === null || _a === void 0 ? void 0 : _a.includes('uploader'))) {
|
|
344
|
+
var urlAttr = node.bindAttrs.find(function (item) { return item.name === 'url'; });
|
|
345
|
+
var url = urlAttr === null || urlAttr === void 0 ? void 0 : urlAttr.value;
|
|
346
|
+
if (url) {
|
|
347
|
+
if (!map.has(url))
|
|
348
|
+
map.set(url, [node]);
|
|
349
|
+
else
|
|
350
|
+
map.get(url).push(node);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
return map;
|
|
355
|
+
}
|
|
356
|
+
function genPermissionData(app) {
|
|
357
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
358
|
+
var logicPageResourceDtoList, _a, logics, processLogics, uploaders, _i, _b, logic, resources, service, key;
|
|
359
|
+
return __generator(this, function (_c) {
|
|
360
|
+
switch (_c.label) {
|
|
361
|
+
case 0:
|
|
362
|
+
// console.time('xxx');
|
|
363
|
+
openCache();
|
|
364
|
+
logicPageResourceDtoList = {};
|
|
365
|
+
_a = getAllLogics(app), logics = _a.logics, processLogics = _a.processLogics;
|
|
366
|
+
uploaders = findUploaders(app);
|
|
367
|
+
_i = 0, _b = __spreadArrays(logics, processLogics);
|
|
368
|
+
_c.label = 1;
|
|
369
|
+
case 1:
|
|
370
|
+
if (!(_i < _b.length)) return [3 /*break*/, 4];
|
|
371
|
+
logic = _b[_i];
|
|
372
|
+
return [4 /*yield*/, findResourcesOfLogic(logic, uploaders)];
|
|
373
|
+
case 2:
|
|
374
|
+
resources = _c.sent();
|
|
375
|
+
if (resources.length === 0)
|
|
376
|
+
return [3 /*break*/, 3];
|
|
377
|
+
service = logics.includes(logic) ? logic.toService() : logic.toProcessService();
|
|
378
|
+
key = service.url.path + ":" + service.url.method;
|
|
379
|
+
logicPageResourceDtoList[key] = resources;
|
|
380
|
+
_c.label = 3;
|
|
381
|
+
case 3:
|
|
382
|
+
_i++;
|
|
383
|
+
return [3 /*break*/, 1];
|
|
384
|
+
case 4:
|
|
385
|
+
closeCache();
|
|
386
|
+
// console.timeEnd('xxx');
|
|
387
|
+
return [2 /*return*/, logicPageResourceDtoList];
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
exports.genPermissionData = genPermissionData;
|