UNPKG

@sap/adp-common

Version:
68 lines 3.08 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"); class Manifest { static setCredentials(credentials) { this.credentials = credentials; } /** * Filters all dataSources where type is 'OData' and returns only the needed properties * @param {DataSource} dataSources * @returns {ODataTargetSource[]} array of OData target sources */ static getTargetODataSources(dataSources) { return Object.entries(dataSources) .filter((dS) => { var _a; return ((_a = dS[1]) === null || _a === void 0 ? void 0 : _a.type) === "OData"; }) .map((dS) => { var _a, _b, _c; return { dataSourceName: dS[0], uri: (_a = dS[1]) === null || _a === void 0 ? void 0 : _a.uri, annotations: ((_c = (_b = dS[1]) === null || _b === void 0 ? void 0 : _b.settings) === null || _c === void 0 ? void 0 : _c.annotations) || [] }; }); } static getTargetODataAnnotations(dataSources) { const annotations = {}; Object.entries(dataSources) .filter((dS) => { var _a; return ((_a = dS[1]) === null || _a === void 0 ? void 0 : _a.type) === "ODataAnnotation"; }) .forEach((dS) => { var _a; annotations[dS[0]] = (_a = dS[1]) === null || _a === void 0 ? void 0 : _a.uri; }); return annotations; } static getManifest(projectData, manifsetCF, manifestABAP) { return __awaiter(this, void 0, void 0, function* () { try { switch (projectData.environment) { case "CF": { return yield manifsetCF.get(projectData); } case "ABAP": { return yield manifestABAP.get(projectData); } case "S4HANACLOUD": { return yield manifestABAP.get(projectData); } default: throw new Error("Incorrect environment"); } } catch (e) { throw new Error(messages_1.Messages.ERROR_COULD_NOT_RETRIEVE_MANIFEST(e.message)); } }); } } exports.default = Manifest; //# sourceMappingURL=Manifest.js.map