UNPKG

@sap/adp-abap

Version:

abap service for all yeoman generators

99 lines 6.14 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const messages_1 = require("../i18n/messages"); const _1 = require("./"); const adp_common_1 = require("@sap/adp-common"); const path_1 = require("path"); const i18n_1 = require("../i18n"); class Manifest { static setCredentials(credentials) { this.credentials = credentials; } static get(projectData) { return __awaiter(this, void 0, void 0, function* () { try { const localDestinationService = new _1.LocalDestinationService(); let username = this.credentials.username; let password = this.credentials.password; let sourceSystem = projectData.sourceSystem; let client = projectData.client; if (!adp_common_1.EnvironmentUtils.isRunningInBAS() && localDestinationService.getIsExtensionInstalled() && !(yield localDestinationService.getDestinationRequiresAuthentication(projectData.sourceSystem))) { const systemAuthDetails = yield localDestinationService.getSystemAuthDetails(sourceSystem); username = systemAuthDetails.username; sourceSystem = systemAuthDetails.url; client = systemAuthDetails.client; password = systemAuthDetails.password; } const endpointsManager = yield adp_common_1.EndpointsManager.getInstance(); const providerManager = new _1.AbapProvider(endpointsManager); yield providerManager.setProvider(sourceSystem, client, username, password); const manifestManager = new _1.ManifestManager(providerManager); const manifest = yield manifestManager.getManifest(projectData.applicationIdx); return manifest; } catch (e) { throw new Error(messages_1.Messages.ERROR_COULD_NOT_RETRIEVE_MANIFEST(e.message)); } }); } static getManifestInboundIds(manifest) { let inboundIds = []; if (manifest["sap.app"].crossNavigation && manifest["sap.app"].crossNavigation.inbounds) { // we are taking the first inbound id from the manifest inboundIds = Object.keys(manifest["sap.app"].crossNavigation.inbounds); } return inboundIds; } static getAdpProjectManifestInboundId(projectPath) { var _a; const manifest = adp_common_1.Workspace.getManifestAppdescrFile(projectPath); const change = manifest.content.find((change) => change.changeType === "appdescr_app_removeAllInboundsExceptOne"); return (_a = change === null || change === void 0 ? void 0 : change.content) === null || _a === void 0 ? void 0 : _a.inboundId; } static getFlpConfig(projectPath) { var _a, _b, _c; return __awaiter(this, void 0, void 0, function* () { const manifestAppDescrPath = (0, path_1.join)(projectPath, "webapp", "manifest.appdescr_variant"); adp_common_1.Workspace.validateFileExists(manifestAppDescrPath, "manifest.appdescr_variant"); const i18nFilePath = (0, path_1.join)(projectPath, "webapp", "i18n", "i18n.properties"); adp_common_1.Workspace.validateFileExists(i18nFilePath, "i18n.properties"); const titleSubTitle = (0, i18n_1.extractTitleAndSubtitleFromI18n)(i18nFilePath); const config = { title: titleSubTitle === null || titleSubTitle === void 0 ? void 0 : titleSubTitle.title, subtitle: titleSubTitle === null || titleSubTitle === void 0 ? void 0 : titleSubTitle.subtitle }; const manifest = adp_common_1.Workspace.getManifestAppdescrFile(projectPath); const addNewInboundChangeContent = (_a = manifest === null || manifest === void 0 ? void 0 : manifest.content.find((change) => change.changeType === "appdescr_app_addNewInbound")) === null || _a === void 0 ? void 0 : _a.content; const changeInboundChangeContent = (_b = manifest === null || manifest === void 0 ? void 0 : manifest.content.find((change) => change.changeType === "appdescr_app_changeInbound")) === null || _b === void 0 ? void 0 : _b.content; if (changeInboundChangeContent) { config.inboundId = changeInboundChangeContent === null || changeInboundChangeContent === void 0 ? void 0 : changeInboundChangeContent.inboundId; } else if (addNewInboundChangeContent) { const inbound = addNewInboundChangeContent === null || addNewInboundChangeContent === void 0 ? void 0 : addNewInboundChangeContent.inbound[`${manifest.id}.InboundID`]; const parameters = (_c = inbound === null || inbound === void 0 ? void 0 : inbound.signature) === null || _c === void 0 ? void 0 : _c.parameters; delete parameters["sap-appvar-id"]; config.action = inbound === null || inbound === void 0 ? void 0 : inbound.action; config.semanticObject = inbound === null || inbound === void 0 ? void 0 : inbound.semanticObject; config.parameterString = (0, _1.stringifyParameters)(parameters); } return config; }); } } exports.default = Manifest; Manifest.credentials = { password: "", username: "" }; //# sourceMappingURL=Manifest.js.map