@lcap/nasl 2.20.0-beta.3 → 2.20.0-beta.5
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/engine/index.d.ts +1 -1
- package/out/automate/engine/index.js +2 -3
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +1 -1
- package/out/automate/engine/uniqueName.js +2 -2
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.js +4 -1
- package/out/automate/engine/utils.js.map +1 -1
- package/out/automate/template/myProcess.d.ts +1 -1
- package/out/automate/template/myProcess.js +2 -2
- package/out/automate/template/myProcess.js.map +1 -1
- package/out/bak/translator.js +14 -22
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.js +4 -1
- 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/App__.d.ts +4 -0
- package/out/concepts/App__.js +30 -6
- 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__.js +3 -3
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +7 -0
- package/out/concepts/BindAttribute__.js +271 -39
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +7 -0
- package/out/concepts/BindDirective__.js +215 -16
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +7 -0
- package/out/concepts/BindStyle__.js +192 -2
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/CallFunction__.js +22 -8
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +3 -2
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +3 -0
- package/out/concepts/CallLogic__.js +78 -89
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +20 -3
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +13 -0
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +19 -0
- package/out/concepts/ConfigProperty__.js +63 -0
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +13 -0
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/DataSource__.js +11 -3
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -0
- package/out/concepts/Destination__.js +61 -7
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +9 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +5 -5
- package/out/concepts/EnumItem__.js +6 -6
- package/out/concepts/Enum__.d.ts +20 -19
- package/out/concepts/Enum__.js +28 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ExternalDestination__.d.ts +1 -0
- package/out/concepts/ExternalDestination__.js +22 -4
- package/out/concepts/ExternalDestination__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -0
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +2 -1
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Identifier__.js +16 -5
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +9 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/JSBlock__.js +5 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +79 -79
- package/out/concepts/Logic__.js +30 -8
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.d.ts +2 -2
- package/out/concepts/Match__.js +29 -13
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +9 -0
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +16 -0
- package/out/concepts/Module__.js +43 -0
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +3 -4
- package/out/concepts/NewComposite__.js +99 -116
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.d.ts +1 -0
- package/out/concepts/NewList__.js +22 -2
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.d.ts +1 -0
- package/out/concepts/NewMap__.js +43 -11
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +40 -12
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.js +10 -2
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +2 -1
- 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__.js +1 -1
- package/out/concepts/ProcessOutcomes__.js.map +1 -1
- package/out/concepts/Process__.js +1 -0
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/Return__.js +13 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/StringInterpolation__.js +14 -2
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +6 -6
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +9 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +6 -3
- package/out/concepts/TypeAnnotation__.js +67 -13
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +1 -0
- package/out/concepts/ValidationRule__.js +53 -0
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +12 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +1 -0
- package/out/concepts/ViewElement__.js +24 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -3
- package/out/concepts/View__.js +33 -12
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.collection.js +6 -1
- package/out/concepts/basics/stdlib/nasl.collection.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.js +3 -0
- package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.core.d.ts +2 -0
- package/out/concepts/basics/stdlib/nasl.core.js +34 -0
- package/out/concepts/basics/stdlib/nasl.core.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +4 -2
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +3 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +0 -1
- package/out/concepts/index__.js +0 -1
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +8 -0
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.js +24 -5
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +3 -3
- package/out/generator/genReleaseBody.js +98 -23
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.d.ts +3 -10
- package/out/generator/permission.js +43 -21
- package/out/generator/permission.js.map +1 -1
- 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 +2 -20
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +16 -5
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +2 -1
- package/out/server/formatTsUtils.js +40 -10
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.d.ts +2 -2
- package/out/server/getLogics.js +3 -3
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -0
- package/out/server/getMemberIdentifier.js +27 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/index.js +1 -0
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +7 -1
- package/out/server/naslServer.js +558 -62
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +109 -33
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +22 -2
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +1 -3
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +1 -3
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +2 -4
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +2 -2
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -1
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +1 -1
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +2 -2
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -3
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/translator/index.js +4 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/traverse.js +8 -2
- package/out/utils/traverse.js.map +1 -1
- package/package.json +2 -2
- package/sandbox/stdlib/dist/nasl.logging.js +0 -0
- package/sandbox/stdlib/dist/nasl.util.js +0 -0
- package/sandbox/stdlib/nasl.collection.ts +1 -0
- package/sandbox/stdlib/nasl.core.ts +34 -0
- package/sandbox/stdlib/nasl.oql.ts +71 -15
- package/sandbox/stdlib/nasl.util.ts +9 -3
- package/src/automate/engine/dist/index.dev.js +517 -0
- package/src/automate/engine/index.js +2 -3
- package/src/automate/engine/uniqueName.js +2 -2
- package/src/automate/engine/utils.js +4 -2
- package/src/automate/template/myProcess.js +2 -2
- package/src/bak/translator.js +16 -25
- package/src/common/BaseNode.ts +3 -1
- package/src/common/Command.ts +4 -0
- package/src/common/dist/BaseNode.js +1101 -0
- package/src/concepts/App__.ts +36 -7
- package/src/concepts/Assignee__.ts +4 -3
- package/src/concepts/BatchAssignment__.ts +3 -3
- package/src/concepts/BindAttribute__.ts +301 -38
- package/src/concepts/BindDirective__.ts +205 -30
- package/src/concepts/BindStyle__.ts +188 -24
- package/src/concepts/CallFunction__.ts +55 -10
- package/src/concepts/CallInterface__.ts +3 -2
- package/src/concepts/CallLogic__.ts +110 -90
- package/src/concepts/CallQueryComponent__.ts +18 -3
- package/src/concepts/ConfigGroup__.ts +17 -4
- package/src/concepts/ConfigProperty__.ts +72 -4
- package/src/concepts/Configuration__.ts +14 -5
- package/src/concepts/DataSource__.ts +10 -3
- package/src/concepts/Destination__.ts +61 -7
- package/src/concepts/EntityProperty__.ts +7 -1
- package/src/concepts/EnumItem__.ts +6 -6
- package/src/concepts/Enum__.ts +22 -19
- package/src/concepts/ExternalDestination__.ts +29 -9
- package/src/concepts/ForEachStatement__.ts +2 -0
- package/src/concepts/Frontend__.ts +2 -1
- package/src/concepts/Identifier__.ts +16 -5
- package/src/concepts/InterfaceParam__.ts +7 -1
- package/src/concepts/JSBlock__.ts +3 -2
- package/src/concepts/Logic__.ts +110 -89
- package/src/concepts/Match__.ts +53 -14
- package/src/concepts/MemberExpression__.ts +6 -0
- package/src/concepts/Module__.ts +57 -0
- package/src/concepts/NewComposite__.ts +104 -131
- package/src/concepts/NewList__.ts +23 -2
- package/src/concepts/NewMap__.ts +48 -24
- package/src/concepts/OqlQueryComponent__.ts +40 -20
- package/src/concepts/Param__.ts +178 -176
- package/src/concepts/ProcessElement__.ts +2 -1
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/ProcessOutcomes__.ts +1 -1
- package/src/concepts/Process__.ts +1 -0
- package/src/concepts/Return__.ts +10 -2
- package/src/concepts/StringInterpolation__.ts +19 -7
- package/src/concepts/StringLiteral__.ts +7 -6
- package/src/concepts/StructureProperty__.ts +7 -1
- package/src/concepts/TypeAnnotation__.ts +102 -15
- package/src/concepts/ValidationRule__.ts +58 -9
- package/src/concepts/Variable__.ts +13 -1
- package/src/concepts/ViewElement__.ts +47 -2
- package/src/concepts/View__.ts +39 -18
- package/src/concepts/basics/stdlib/dist/nasl.util.js +1602 -0
- package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
- package/src/concepts/basics/stdlib/nasl.collection.ts +6 -1
- package/src/concepts/basics/stdlib/nasl.configuration.ts +3 -0
- package/src/concepts/basics/stdlib/nasl.core.ts +33 -2
- package/src/concepts/basics/stdlib/nasl.util.ts +4 -2
- package/src/concepts/basics/types/index.ts +1 -0
- package/src/concepts/dist/BindAttribute__.js +795 -0
- package/src/concepts/dist/BindEvent__.js +732 -0
- package/src/concepts/dist/CallFunction__.js +527 -0
- package/src/concepts/dist/CallLogic__.js +932 -0
- package/src/concepts/dist/Destination__.js +708 -0
- package/src/concepts/dist/ExternalDestination__.js +298 -0
- 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 +0 -1
- package/src/enums/KEYWORDS.ts +8 -0
- package/src/generator/dist/genBundleFiles.js +261 -0
- package/src/generator/dist/genMetaData.js +245 -0
- package/src/generator/dist/permission.js +405 -0
- package/src/generator/genBundleFiles.ts +24 -5
- package/src/generator/genReleaseBody.ts +77 -31
- package/src/generator/permission.ts +47 -21
- package/src/index.ts +1 -1
- package/src/server/entity2LogicNamespace.ts +2 -20
- package/src/server/extendBaseNode.ts +15 -5
- package/src/server/formatTsUtils.ts +41 -10
- package/src/server/getLogics.ts +4 -4
- package/src/server/getMemberIdentifier.ts +27 -1
- package/src/server/index.ts +2 -0
- package/src/server/naslServer.ts +555 -63
- package/src/server/translator.ts +96 -34
- package/src/service/storage/dist/init.js +579 -0
- package/src/service/storage/init.ts +23 -3
- 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/genCreateBlock.ts +1 -3
- package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -3
- package/src/templator/genCurdMultipleKeyBlock.ts +2 -4
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +3 -4
- package/src/templator/genListViewBlock.ts +9 -3
- package/src/templator/genSelectBlock.ts +1 -1
- package/src/templator/genTableBlock.ts +3 -3
- package/src/templator/genUpdateBlock.ts +2 -3
- package/src/translator/index.ts +3 -1
- package/src/utils/traverse.ts +10 -2
- package/ts-worker/lib/tsserver.js +10 -2
- package/ts-worker/package.json +1 -0
- package/ts-worker/webpack.config.js +11 -2
- package/out/concepts/ConstructArgument__.d.ts +0 -40
- package/out/concepts/ConstructArgument__.js +0 -108
- 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/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
|
@@ -0,0 +1,405 @@
|
|
|
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 (['logic1', 'logic2'].includes(logic.name)) {
|
|
161
|
+
console.log(usage.node);
|
|
162
|
+
}
|
|
163
|
+
if ((usage.node instanceof concepts_1.BindEvent || usage.node instanceof concepts_1.BindAttribute)
|
|
164
|
+
&& (parent.node instanceof concepts_1.View || parent.node instanceof concepts_1.ViewElement))
|
|
165
|
+
res.push(parent.node);
|
|
166
|
+
(_a = usage.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
|
|
167
|
+
dfs(child, usage);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
var usageMap, usages, res;
|
|
171
|
+
return __generator(this, function (_a) {
|
|
172
|
+
switch (_a.label) {
|
|
173
|
+
case 0: return [4 /*yield*/, findUsage(logic)];
|
|
174
|
+
case 1:
|
|
175
|
+
usageMap = _a.sent();
|
|
176
|
+
usages = [];
|
|
177
|
+
usageMap.forEach(function (usage, node) {
|
|
178
|
+
if (node instanceof concepts_1.View)
|
|
179
|
+
usages.push(usage);
|
|
180
|
+
});
|
|
181
|
+
res = [];
|
|
182
|
+
usages.forEach(function (usage) {
|
|
183
|
+
dfs(usage);
|
|
184
|
+
});
|
|
185
|
+
return [2 /*return*/, res];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function findResourcesOfUI(view) {
|
|
191
|
+
var res = [];
|
|
192
|
+
var node = view;
|
|
193
|
+
while (node) {
|
|
194
|
+
if (node instanceof concepts_1.View && node.auth)
|
|
195
|
+
res.push({
|
|
196
|
+
path: node.authPath,
|
|
197
|
+
type: 'page'
|
|
198
|
+
});
|
|
199
|
+
else if (node instanceof concepts_1.ViewElement) {
|
|
200
|
+
var hasAuth = node.bindDirectives.find(function (directive) { return directive.name === 'auth'; });
|
|
201
|
+
if (hasAuth)
|
|
202
|
+
res.push({
|
|
203
|
+
path: node.authPath,
|
|
204
|
+
type: 'component'
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
node = node.parentNode;
|
|
208
|
+
}
|
|
209
|
+
return res;
|
|
210
|
+
}
|
|
211
|
+
function optimizeResourceData(resources) {
|
|
212
|
+
var res = removeRedundantResourceData(resources);
|
|
213
|
+
res = removeRedundantResourceData2(res);
|
|
214
|
+
return res;
|
|
215
|
+
}
|
|
216
|
+
// [['b'], ['a' ,'b']] 只需要保留 [['b']]
|
|
217
|
+
function removeRedundantResourceData(resources) {
|
|
218
|
+
var wm = new WeakMap();
|
|
219
|
+
for (var _i = 0, resources_1 = resources; _i < resources_1.length; _i++) {
|
|
220
|
+
var resource = resources_1[_i];
|
|
221
|
+
var hash = resource.map(function (_a) {
|
|
222
|
+
var path = _a.path, type = _a.type;
|
|
223
|
+
return path + "_" + type;
|
|
224
|
+
})
|
|
225
|
+
.join();
|
|
226
|
+
wm.set(resource, hash);
|
|
227
|
+
}
|
|
228
|
+
resources.sort(function (a, b) { return wm.get(a).length - wm.get(b).length; });
|
|
229
|
+
var res = [];
|
|
230
|
+
var hashs = [];
|
|
231
|
+
;
|
|
232
|
+
var _loop_1 = function (resource) {
|
|
233
|
+
var hash = wm.get(resource);
|
|
234
|
+
if (hashs.some(function (h) { return hash.endsWith(h); }))
|
|
235
|
+
return "continue";
|
|
236
|
+
res.push(resource);
|
|
237
|
+
hashs.push(hash);
|
|
238
|
+
};
|
|
239
|
+
for (var _a = 0, resources_2 = resources; _a < resources_2.length; _a++) {
|
|
240
|
+
var resource = resources_2[_a];
|
|
241
|
+
_loop_1(resource);
|
|
242
|
+
}
|
|
243
|
+
return res;
|
|
244
|
+
}
|
|
245
|
+
// 子页面有权限,父页面默认也有权限,所以不需要记录父页面权限;
|
|
246
|
+
// 组件有权限,组件所在的页面默认也有权限,所以不需要记录页面权限
|
|
247
|
+
function removeRedundantResourceData2(resources) {
|
|
248
|
+
return resources.map(function (resource) {
|
|
249
|
+
if (resource.length <= 1)
|
|
250
|
+
return resource;
|
|
251
|
+
if (resource[0].type === 'page')
|
|
252
|
+
return resource.slice(0, 1);
|
|
253
|
+
else if (resource[0].type === 'component')
|
|
254
|
+
return resource.filter(function (item) { return item.type === 'component'; });
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function findResourcesOfLogic(logic, uploaders) {
|
|
258
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
259
|
+
var logics, UIs, _i, logics_1, logic_2, _a, _b, service, res;
|
|
260
|
+
return __generator(this, function (_c) {
|
|
261
|
+
switch (_c.label) {
|
|
262
|
+
case 0:
|
|
263
|
+
if (['logic1', 'logic2'].includes(logic.name)) {
|
|
264
|
+
debugger;
|
|
265
|
+
}
|
|
266
|
+
return [4 /*yield*/, findViewLogicReferences(logic)];
|
|
267
|
+
case 1:
|
|
268
|
+
logics = _c.sent();
|
|
269
|
+
logics.push(logic);
|
|
270
|
+
UIs = [];
|
|
271
|
+
_i = 0, logics_1 = logics;
|
|
272
|
+
_c.label = 2;
|
|
273
|
+
case 2:
|
|
274
|
+
if (!(_i < logics_1.length)) return [3 /*break*/, 5];
|
|
275
|
+
logic_2 = logics_1[_i];
|
|
276
|
+
_b = (_a = UIs).concat;
|
|
277
|
+
return [4 /*yield*/, findUIReferences(logic_2)];
|
|
278
|
+
case 3:
|
|
279
|
+
UIs = _b.apply(_a, [_c.sent()]);
|
|
280
|
+
if (['logic1', 'logic2'].includes(logic_2.name)) {
|
|
281
|
+
console.log(UIs);
|
|
282
|
+
}
|
|
283
|
+
_c.label = 4;
|
|
284
|
+
case 4:
|
|
285
|
+
_i++;
|
|
286
|
+
return [3 /*break*/, 2];
|
|
287
|
+
case 5:
|
|
288
|
+
service = logic.toService();
|
|
289
|
+
if (uploaders.has(service.url.path)) {
|
|
290
|
+
UIs = UIs.concat(uploaders.get(service.url.path));
|
|
291
|
+
}
|
|
292
|
+
UIs = Array.from(new Set(UIs));
|
|
293
|
+
res = UIs.map(function (ui) { return findResourcesOfUI(ui); });
|
|
294
|
+
if (['logic1', 'logic2'].includes(logic.name)) {
|
|
295
|
+
console.log(logic.name, UIs, res);
|
|
296
|
+
}
|
|
297
|
+
return [2 /*return*/, optimizeResourceData(res)];
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
function getAllLogics(app) {
|
|
303
|
+
var modules = [];
|
|
304
|
+
var entities = [];
|
|
305
|
+
var logics = [];
|
|
306
|
+
if (Array.isArray(app.dataSources)) {
|
|
307
|
+
app.dataSources.forEach(function (dataSource) {
|
|
308
|
+
if (Array.isArray(dataSource.entities)) {
|
|
309
|
+
entities.push.apply(entities, dataSource.entities);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
app.logics && logics.push.apply(logics, app.logics);
|
|
314
|
+
app.dependencies && modules.push.apply(modules, app.dependencies);
|
|
315
|
+
app.interfaceDependencies && modules.push.apply(modules, app.interfaceDependencies);
|
|
316
|
+
modules.forEach(function (module) {
|
|
317
|
+
module.logics && logics.push.apply(logics, module.logics);
|
|
318
|
+
if (Array.isArray(module.dataSources)) {
|
|
319
|
+
module.dataSources.forEach(function (dataSource) {
|
|
320
|
+
if (Array.isArray(dataSource.entities)) {
|
|
321
|
+
entities.push.apply(entities, dataSource.entities);
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
var allLogics = [];
|
|
327
|
+
if (Array.isArray(entities)) {
|
|
328
|
+
entities.forEach(function (entity) {
|
|
329
|
+
var ns = entity.ns;
|
|
330
|
+
if (Array.isArray(ns === null || ns === void 0 ? void 0 : ns.logics)) {
|
|
331
|
+
allLogics.push.apply(allLogics, ns.logics);
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
if (Array.isArray(logics)) {
|
|
336
|
+
allLogics.push.apply(allLogics, logics);
|
|
337
|
+
}
|
|
338
|
+
var processLogics = [];
|
|
339
|
+
var processTreeFragments = (app.processes || [])
|
|
340
|
+
.map(process2LogicNamespace_1.processToTreeFragment);
|
|
341
|
+
processTreeFragments.forEach(function (tree) {
|
|
342
|
+
processLogics.push.apply(processLogics, tree.logics);
|
|
343
|
+
tree.elements.forEach(function (element) {
|
|
344
|
+
processLogics.push.apply(processLogics, element.logics);
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
return {
|
|
348
|
+
logics: allLogics,
|
|
349
|
+
processLogics: processLogics
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function findUploaders(app) {
|
|
353
|
+
var map = new Map();
|
|
354
|
+
app.traverseChildren(function (node) {
|
|
355
|
+
var _a;
|
|
356
|
+
if (node instanceof concepts_1.ViewElement && ((_a = node.tag) === null || _a === void 0 ? void 0 : _a.includes('uploader'))) {
|
|
357
|
+
var urlAttr = node.bindAttrs.find(function (item) { return item.name === 'url'; });
|
|
358
|
+
var url = urlAttr === null || urlAttr === void 0 ? void 0 : urlAttr.value;
|
|
359
|
+
if (url) {
|
|
360
|
+
if (!map.has(url))
|
|
361
|
+
map.set(url, [node]);
|
|
362
|
+
else
|
|
363
|
+
map.get(url).push(node);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
return map;
|
|
368
|
+
}
|
|
369
|
+
function genPermissionData(app) {
|
|
370
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
371
|
+
var logicPageResourceDtoList, _a, logics, processLogics, uploaders, _i, _b, logic, resources, service, key;
|
|
372
|
+
return __generator(this, function (_c) {
|
|
373
|
+
switch (_c.label) {
|
|
374
|
+
case 0:
|
|
375
|
+
// console.time('xxx');
|
|
376
|
+
openCache();
|
|
377
|
+
logicPageResourceDtoList = {};
|
|
378
|
+
_a = getAllLogics(app), logics = _a.logics, processLogics = _a.processLogics;
|
|
379
|
+
uploaders = findUploaders(app);
|
|
380
|
+
_i = 0, _b = __spreadArrays(logics, processLogics);
|
|
381
|
+
_c.label = 1;
|
|
382
|
+
case 1:
|
|
383
|
+
if (!(_i < _b.length)) return [3 /*break*/, 4];
|
|
384
|
+
logic = _b[_i];
|
|
385
|
+
return [4 /*yield*/, findResourcesOfLogic(logic, uploaders)];
|
|
386
|
+
case 2:
|
|
387
|
+
resources = _c.sent();
|
|
388
|
+
if (resources.length === 0)
|
|
389
|
+
return [3 /*break*/, 3];
|
|
390
|
+
service = logics.includes(logic) ? logic.toService() : logic.toProcessService();
|
|
391
|
+
key = service.url.path + ":" + service.url.method;
|
|
392
|
+
logicPageResourceDtoList[key] = resources;
|
|
393
|
+
_c.label = 3;
|
|
394
|
+
case 3:
|
|
395
|
+
_i++;
|
|
396
|
+
return [3 /*break*/, 1];
|
|
397
|
+
case 4:
|
|
398
|
+
closeCache();
|
|
399
|
+
// console.timeEnd('xxx');
|
|
400
|
+
return [2 /*return*/, logicPageResourceDtoList];
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
exports.genPermissionData = genPermissionData;
|
|
@@ -82,7 +82,7 @@ export function genBundleFiles(app: App, frontend: Frontend,
|
|
|
82
82
|
let routePath = viewName;
|
|
83
83
|
if (isRootView) {
|
|
84
84
|
rootViewData.push({ name: viewName, title: view.title || viewName, isIndex: view.isIndex });
|
|
85
|
-
routePath =
|
|
85
|
+
routePath = `${frontend.basePath}/${viewName}`;
|
|
86
86
|
if (!isViewAuth) {
|
|
87
87
|
if (viewName === 'notFound') {
|
|
88
88
|
defaultRoute = routePath;
|
|
@@ -133,11 +133,17 @@ export function genBundleFiles(app: App, frontend: Frontend,
|
|
|
133
133
|
routes.push(route);
|
|
134
134
|
if (view.isIndex) {
|
|
135
135
|
routes.push({
|
|
136
|
-
path: '/',
|
|
137
|
-
redirect: `'/${view.name}'`,
|
|
136
|
+
path: frontend.basePath ? frontend.basePath : '/',
|
|
137
|
+
redirect: `'${frontend.basePath}/${view.name}'`,
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
});
|
|
141
|
+
if (frontend.basePath) {
|
|
142
|
+
routes.push({
|
|
143
|
+
path: '/',
|
|
144
|
+
redirect: `'${frontend.basePath}'`,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
141
147
|
const authResourcePathMap: any = {};
|
|
142
148
|
// 默认跳转子页面开启权限的情况,需要把父页面也都加入权限校验列表
|
|
143
149
|
if (Array.isArray(authResourceViews)) {
|
|
@@ -150,6 +156,9 @@ export function genBundleFiles(app: App, frontend: Frontend,
|
|
|
150
156
|
if (parentViewNode.concept === 'View') {
|
|
151
157
|
authResourcePathMap[parentViewNode.path] = true;
|
|
152
158
|
} else { // viewNode是根页面
|
|
159
|
+
if (frontend.basePath) {
|
|
160
|
+
authResourcePathMap[frontend.basePath] = true;
|
|
161
|
+
}
|
|
153
162
|
authResourcePathMap['/'] = true;
|
|
154
163
|
}
|
|
155
164
|
viewNode = parentViewNode;
|
|
@@ -214,6 +223,7 @@ export function genBundleFiles(app: App, frontend: Frontend,
|
|
|
214
223
|
documentTitle: frontend.documentTitle,
|
|
215
224
|
rootViewData,
|
|
216
225
|
basePath: frontend.basePath,
|
|
226
|
+
frontendName: frontend.name,
|
|
217
227
|
},
|
|
218
228
|
dnsAddr: app.dnsAddr,
|
|
219
229
|
devDnsAddr: config.devDnsAddr,
|
|
@@ -357,7 +367,7 @@ export function genBundleFiles(app: App, frontend: Frontend,
|
|
|
357
367
|
bundleMinPath = `${baseUrl}${frontend.basePath}/bundle.${genHash(content)}.min.js`;
|
|
358
368
|
}
|
|
359
369
|
const bundleSourceMapPath = `${bundlePath}.map`;
|
|
360
|
-
const otherJsList =
|
|
370
|
+
const otherJsList = (frontend as any)?.appletsConfig?.enable ? ['//res.wx.qq.com/open/js/jweixin-1.3.2.js'] : [];
|
|
361
371
|
const assetsContent = `(function() {
|
|
362
372
|
LazyLoad.js(${JSON5.stringify(assetsInfo.basic.js.concat(assetsInfo.custom.js, otherJsList).concat([bundleMinPath]))});
|
|
363
373
|
LazyLoad.css(${JSON5.stringify(assetsInfo.basic.css.concat(assetsInfo.custom.css))});
|
|
@@ -377,9 +387,18 @@ export function genBundleFiles(app: App, frontend: Frontend,
|
|
|
377
387
|
sourceMap: {
|
|
378
388
|
url: bundleSourceMapPath,
|
|
379
389
|
},
|
|
390
|
+
compress: {
|
|
391
|
+
// @ts-ignore
|
|
392
|
+
awaits: false,
|
|
393
|
+
},
|
|
380
394
|
});
|
|
381
395
|
} else {
|
|
382
|
-
minifyObj = UglifyJS.minify(content
|
|
396
|
+
minifyObj = UglifyJS.minify(content, {
|
|
397
|
+
compress: {
|
|
398
|
+
// @ts-ignore
|
|
399
|
+
awaits: false,
|
|
400
|
+
},
|
|
401
|
+
});
|
|
383
402
|
}
|
|
384
403
|
const outputs = [
|
|
385
404
|
{
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { App, Assignment, BatchAssignment, CallFunction, CallInterface, CallLogic, ForEachStatement, IfStatement, Logic, LogicItem, Match, MatchCase, Role, SwitchCase, SwitchStatement, View, ViewElement, WhileStatement, Frontend } from '../concepts';
|
|
1
|
+
import { App, Assignment, BatchAssignment, CallFunction, CallInterface, CallLogic, ForEachStatement, IfStatement, Logic, LogicItem, Match, MatchCase, MemberExpression, Role, SwitchCase, SwitchStatement, View, ViewElement, WhileStatement, StringInterpolation, Frontend, ExternalDestination, NewComposite, SelectMembers, NewList } from '../concepts';
|
|
2
2
|
import { genFrontendBundleFiles } from './genBundleFiles';
|
|
3
|
-
import { genPermissionData } from './permission';
|
|
3
|
+
import { genPermissionData, genLogicAuthFlag } from './permission';
|
|
4
|
+
import * as utils from '../utils';
|
|
4
5
|
|
|
5
6
|
export async function genReleaseBody(app: App, {
|
|
6
7
|
env,
|
|
7
8
|
replicas,
|
|
8
|
-
generateMini,
|
|
9
9
|
realRelease,
|
|
10
10
|
appInfo,
|
|
11
11
|
staticUrl,
|
|
@@ -13,7 +13,6 @@ export async function genReleaseBody(app: App, {
|
|
|
13
13
|
}: {
|
|
14
14
|
env: string,
|
|
15
15
|
replicas: number,
|
|
16
|
-
generateMini: boolean,
|
|
17
16
|
realRelease: boolean,
|
|
18
17
|
appInfo: {
|
|
19
18
|
tenant: string,
|
|
@@ -34,11 +33,7 @@ export async function genReleaseBody(app: App, {
|
|
|
34
33
|
let logicPageResourceDtoList;
|
|
35
34
|
if (realRelease) {
|
|
36
35
|
authReport = getAuthReport(app, frontends);
|
|
37
|
-
|
|
38
|
-
authReport.resourceDataList = authReport.resourceDataList.concat(permissionData.resourceDataList);
|
|
39
|
-
authReport.resourceList = authReport.resourceList.concat(permissionData.resourceList);
|
|
40
|
-
|
|
41
|
-
logicPageResourceDtoList = permissionData.logicPageResourceDtoList;
|
|
36
|
+
logicPageResourceDtoList = await genPermissionData(app);
|
|
42
37
|
}
|
|
43
38
|
|
|
44
39
|
const releaseFrontends = app.frontends.map((frontend) => ({
|
|
@@ -46,21 +41,26 @@ export async function genReleaseBody(app: App, {
|
|
|
46
41
|
type: frontend.type,
|
|
47
42
|
path: frontend.path,
|
|
48
43
|
selected: frontends.includes(frontend),
|
|
44
|
+
title: frontend.title,
|
|
49
45
|
}));
|
|
50
46
|
|
|
51
47
|
const body = {
|
|
52
48
|
...authReport, // 如果发布需要上报权限,导出源码不需要
|
|
53
49
|
logicPageResourceDtoList,
|
|
50
|
+
logicAuthFlag: genLogicAuthFlag(app),
|
|
54
51
|
noAuthApiPathList: getAuthApiPathList(app, frontends),
|
|
55
52
|
reportIdList: findAllReportIdList(app, frontends),
|
|
56
53
|
appId: app.id,
|
|
57
54
|
env,
|
|
58
55
|
replicas,
|
|
59
56
|
callbackLogicsName: app.getExtensionsCallbackLogics(),
|
|
60
|
-
generateMini,
|
|
61
57
|
frontends: releaseFrontends,
|
|
62
58
|
files: [] as Array<{ name: string, content: string }>,
|
|
63
59
|
};
|
|
60
|
+
|
|
61
|
+
if (logicPageResourceDtoList)
|
|
62
|
+
Object.assign(body, { logicPageResourceDtoList });
|
|
63
|
+
|
|
64
64
|
let NaslAnnotatedJSON;
|
|
65
65
|
try {
|
|
66
66
|
NaslAnnotatedJSON = await (app as any).naslServer.getNaslAnnotatedJSON(app, true);
|
|
@@ -69,22 +69,29 @@ export async function genReleaseBody(app: App, {
|
|
|
69
69
|
throw new Error('代码标注失败');
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
// 可能所有的前端都不选
|
|
73
|
+
let files = [];
|
|
74
|
+
if (frontends && frontends.length) {
|
|
75
|
+
files = genFrontendBundleFiles(app, frontends, Object.assign({}, appInfo, {
|
|
76
|
+
env,
|
|
77
|
+
appid: app.id,
|
|
78
|
+
devDnsAddr: (app as any).devDnsAddr,
|
|
79
|
+
miniEnable: (app as any).miniEnable,
|
|
80
|
+
}) as any);
|
|
81
|
+
if (files && files.length === 0) {
|
|
82
|
+
throw new Error('前端代码生成失败');
|
|
83
|
+
}
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
if (staticUrl)
|
|
86
|
+
files = replaceAssetUrl(files, appInfo.USER_STATIC_URL, staticUrl);
|
|
87
|
+
}
|
|
84
88
|
|
|
85
89
|
// 如果是发布,就排除views,导出源码就不排除
|
|
86
|
-
if (realRelease)
|
|
87
|
-
|
|
90
|
+
if (realRelease) {
|
|
91
|
+
NaslAnnotatedJSON.frontends.forEach((frontend: Frontend) => {
|
|
92
|
+
delete frontend.views;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
88
95
|
const jsonString = JSON.stringify(NaslAnnotatedJSON);
|
|
89
96
|
|
|
90
97
|
// 打印传给服务端的nasl,为了服务端排查问题方便
|
|
@@ -156,7 +163,7 @@ function getAuthReport(app: App, frontends: Array<Frontend>) {
|
|
|
156
163
|
* 上报白名单
|
|
157
164
|
*/
|
|
158
165
|
function getAuthApiPathList(app: App, frontends: Array<Frontend>) {
|
|
159
|
-
const thisDiffLogicList: Array<{logicName:string, frontendName: string}> = [];
|
|
166
|
+
const thisDiffLogicList: Array<{ logicName: string, frontendName: string }> = [];
|
|
160
167
|
|
|
161
168
|
/* 转换Path */
|
|
162
169
|
function getPathMethods(logicNameSpace: string) {
|
|
@@ -275,6 +282,16 @@ function getAuthApiPathList(app: App, frontends: Array<Frontend>) {
|
|
|
275
282
|
logicItems = state.arguments?.map((item) => item.expression);
|
|
276
283
|
} else if (state instanceof CallInterface) {
|
|
277
284
|
logicItems = state.arguments?.map((item) => item.expression);
|
|
285
|
+
} else if (state instanceof MemberExpression) {
|
|
286
|
+
logicItems = [state.object, state.property];
|
|
287
|
+
} else if (state instanceof StringInterpolation) {
|
|
288
|
+
logicItems = [...state.expressions];
|
|
289
|
+
} else if (state instanceof ExternalDestination) {
|
|
290
|
+
logicItems = [state.anchor, state.link];
|
|
291
|
+
} else if (state instanceof NewComposite) {
|
|
292
|
+
logicItems = [...(state.rights || []).map((item) => item.expression)];
|
|
293
|
+
} else if (state instanceof NewList) {
|
|
294
|
+
logicItems = [...state.items];
|
|
278
295
|
}
|
|
279
296
|
|
|
280
297
|
return logicItems.filter((item) => !!item);
|
|
@@ -290,7 +307,7 @@ function getAuthApiPathList(app: App, frontends: Array<Frontend>) {
|
|
|
290
307
|
}
|
|
291
308
|
}
|
|
292
309
|
|
|
293
|
-
const importList: Array<string> = [];
|
|
310
|
+
const importList: Array<{ path: string, frontendName: string }> = [];
|
|
294
311
|
const itemloop = (state: LogicItem, view: View | ViewElement, frontend: Frontend) => {
|
|
295
312
|
const logicItems = getStatement(state, frontend);
|
|
296
313
|
if (logicItems.length) {
|
|
@@ -315,15 +332,42 @@ function getAuthApiPathList(app: App, frontends: Array<Frontend>) {
|
|
|
315
332
|
}
|
|
316
333
|
});
|
|
317
334
|
}
|
|
335
|
+
const bindExpressions = [];
|
|
336
|
+
const bindAttrs = (view as ViewElement).bindAttrs || [];
|
|
337
|
+
const bindDirectives = (view as ViewElement).bindDirectives || [];
|
|
338
|
+
const bindStyles = (view as ViewElement).bindStyles || [];
|
|
339
|
+
bindExpressions.push(...bindAttrs, ...bindDirectives, ...bindStyles);
|
|
340
|
+
if (Array.isArray(bindExpressions) && bindExpressions.length) {
|
|
341
|
+
bindExpressions.forEach((bindExpression) => utils.traverse((current) => {
|
|
342
|
+
if (current.node instanceof CallLogic) {
|
|
343
|
+
getLogic((current.node as CallLogic).calleewholeKey, frontend);
|
|
344
|
+
}
|
|
345
|
+
}, { node: bindExpression }, {
|
|
346
|
+
mode: 'anyObject',
|
|
347
|
+
excludedKeySet: new Set([
|
|
348
|
+
// 排除playground里的表达式
|
|
349
|
+
'playground',
|
|
350
|
+
'parentNode',
|
|
351
|
+
'sourceMap',
|
|
352
|
+
'storageJSON',
|
|
353
|
+
'tsErrorDetail',
|
|
354
|
+
'NaslAnnotatedJSON',
|
|
355
|
+
'calledFrom',
|
|
356
|
+
'_events',
|
|
357
|
+
'_collectingList',
|
|
358
|
+
'_historyList',
|
|
359
|
+
]),
|
|
360
|
+
}));
|
|
361
|
+
}
|
|
318
362
|
}
|
|
319
363
|
if (view.concept === 'ViewElement' && (view.tag === 'u-uploader' || view.tag === 'van-uploader')) {
|
|
320
364
|
const attr = view?.bindAttrs.find((item) => item.name === 'url');
|
|
321
365
|
if (attr?.value.endsWith('/import') && !view.parentAuth) {
|
|
322
|
-
importList.push(attr?.value);
|
|
366
|
+
importList.push({ path: attr?.value, frontendName: frontend.name });
|
|
323
367
|
}
|
|
324
368
|
}
|
|
325
369
|
};
|
|
326
|
-
const loopViews = (view: View, isChild: boolean, frontend:Frontend) => {
|
|
370
|
+
const loopViews = (view: View, isChild: boolean, frontend: Frontend) => {
|
|
327
371
|
// 有权限的页面下的逻辑都不需要上报白名单
|
|
328
372
|
if (!view.auth) {
|
|
329
373
|
if (view.logics) {
|
|
@@ -357,16 +401,18 @@ function getAuthApiPathList(app: App, frontends: Array<Frontend>) {
|
|
|
357
401
|
}
|
|
358
402
|
};
|
|
359
403
|
frontends.forEach((frontend) => {
|
|
360
|
-
frontend.views.forEach((view) => loopViews(view,
|
|
404
|
+
frontend.views.forEach((view) => loopViews(view, false, frontend));
|
|
361
405
|
});
|
|
362
406
|
|
|
363
407
|
const diffLogicList = thisDiffLogicList.filter((item) => item.logicName.startsWith('app') || item.logicName.startsWith('extensions'));
|
|
364
408
|
const authApiList = [
|
|
365
409
|
...diffLogicList.map((diffLogic) => {
|
|
366
410
|
const path = getPathMethods(diffLogic.logicName);
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
411
|
+
if (path)
|
|
412
|
+
return `${path}:${diffLogic.frontendName}`;
|
|
413
|
+
return '';
|
|
414
|
+
}).filter((path) => !!path),
|
|
415
|
+
...Array.from(new Set(importList.map((item) => `${item.path}:POST:${item.frontendName}`))),
|
|
370
416
|
].filter((item) => !!item);
|
|
371
417
|
return authApiList;
|
|
372
418
|
}
|