UNPKG

@contiva/sap-integration-suite-client

Version:
1,023 lines 83.8 kB
"use strict"; /** * SAP Integration Content Client * * Diese Datei enthält eine vereinfachte Client-Klasse für die Interaktion mit * den Integration Content APIs von SAP Cloud Integration. * * @module sap-integration-suite-client/integration-content */ Object.defineProperty(exports, "__esModule", { value: true }); exports.IntegrationContentClient = void 0; const response_normalizer_1 = require("../utils/response-normalizer"); const integration_content_advanced_client_1 = require("./custom/integration-content-advanced-client"); /** * Erweiterter SAP Integration Content Client * * Diese Klasse stellt eine vereinfachte API für die Interaktion * mit den SAP Integration Content APIs bereit. */ class IntegrationContentClient { /** * Erstellt einen neuen IntegrationContentClient * * @param {IntegrationContentApi<unknown>} api - Die zugrunde liegende API-Instanz */ constructor(api) { this.api = api; this.normalizer = new response_normalizer_1.ResponseNormalizer(); this.advancedClient = new integration_content_advanced_client_1.IntegrationContentAdvancedClient(this); } /** * Gibt alle Integrationspakete zurück * * @param {Object} options Optionale Parameter für die Anfrage * @param {number} [options.top] Maximale Anzahl der zurückzugebenden Pakete * @param {number} [options.skip] Anzahl der zu überspringenden Pakete * @param {string} [options.author] Filtern nach Autor (Custom Tag) * @param {string} [options.lob] Filtern nach Line of Business (Custom Tag) * @returns {Promise<ComSapHciApiIntegrationPackage[]>} Promise mit einer Liste von Integrationspaketen * * @example * // Alle Integrationspakete abrufen * const packages = await client.getIntegrationPackages(); * * @example * // Pakete mit Paginierung abrufen * const packages = await client.getIntegrationPackages({ top: 10, skip: 20 }); */ async getIntegrationPackages(options = {}) { const response = await this.api.integrationPackages.integrationPackagesList({ $top: options.top, $skip: options.skip, Author: options.author, LoB: options.lob }); return this.normalizer.normalizeArrayResponse(response.data, 'getIntegrationPackages', 'IntegrationPackages'); } /** * Gibt ein Integrationspaket anhand seiner ID zurück * * @param {string} packageId ID des Integrationspakets * @returns {Promise<ComSapHciApiIntegrationPackage>} Promise mit dem Integrationspaket * * @example * const package = await client.getIntegrationPackageById('MyPackageId'); */ async getIntegrationPackageById(packageId) { const response = await this.api.integrationPackagesId.integrationPackagesList(packageId); return response.data; } /** * Erstellt ein neues Integrationspaket * * @param {ComSapHciApiIntegrationPackageCreate} packageData Daten des Integrationspakets * @param {boolean} [overwrite=false] Ob ein existierendes Paket mit der gleichen ID überschrieben werden soll * @returns {Promise<ComSapHciApiIntegrationPackage>} Promise mit dem erstellten Integrationspaket * * @example * const newPackage = await client.createIntegrationPackage({ * Id: 'MyNewPackage', * Name: 'My New Integration Package', * Description: 'This is a new package' * }); */ async createIntegrationPackage(packageData, overwrite = false) { const response = await this.api.integrationPackages.integrationPackagesCreate(packageData, overwrite ? { Overwrite: ["true"] } : undefined); return response.data; } /** * Löscht ein Integrationspaket anhand seiner ID * * @param {string} packageId ID des zu löschenden Integrationspakets * @returns {Promise<void>} Promise, der aufgelöst wird, wenn das Paket gelöscht wurde * * @example * await client.deleteIntegrationPackage('MyPackageId'); */ async deleteIntegrationPackage(packageId) { await this.api.integrationPackagesId.integrationPackagesDelete(packageId); } /** * Gibt alle Integrationsflows für ein bestimmtes Paket zurück * * @param {string} packageId ID des Integrationspakets * @returns {Promise<ComSapHciApiIntegrationDesigntimeArtifact[]>} Promise mit einer Liste von Integrationsflows * * @example * const flows = await client.getIntegrationFlows('MyPackageId'); */ async getIntegrationFlows(packageId) { try { const response = await this.api.integrationPackagesId.integrationDesigntimeArtifactsList(packageId); return this.normalizer.normalizeArrayResponse(response.data, 'getIntegrationFlows', 'IntegrationDesigntimeArtifacts'); } catch (error) { // Check for 500 Internal Server Error - skip these packages gracefully if ((error === null || error === void 0 ? void 0 : error.statusCode) === 500 && (error === null || error === void 0 ? void 0 : error.errorCode) === 'Internal Server Error') { console.warn(`Failed to fetch Integration Flows for package ${packageId}. Skipping and returning empty array.`); return []; } // For other errors, rethrow throw error; } } /** * Gibt einen bestimmten Integrationsflow anhand seiner ID und Version zurück * * @param {string} flowId ID des Integrationsflows * @param {string} version Version des Integrationsflows (Standard: 'active') * @returns {Promise<ComSapHciApiIntegrationDesigntimeArtifact>} Promise mit dem Integrationsflow * * @example * const flow = await client.getIntegrationFlowById('MyFlowId', '1.0.0'); */ async getIntegrationFlowById(flowId, version = 'active') { const response = await this.api.integrationDesigntimeArtifactsIdIdVersionVersion.integrationDesigntimeArtifactsIdVersionList(flowId, version); return this.normalizer.normalizeEntityResponse(response.data, 'getIntegrationFlowById'); } /** * Erstellt oder lädt einen neuen Integrationsflow hoch. * * @param {ComSapHciApiIntegrationDesigntimeArtifactCreate} flowData Daten des zu erstellenden Flows * @returns {Promise<ComSapHciApiIntegrationDesigntimeArtifact>} Promise mit dem erstellten Integrationsflow * * @example * const newFlow = await client.createIntegrationFlow({ * Id: 'MyNewFlow', * Name: 'My New Flow', * PackageId: 'MyPackageId', * ArtifactContent: 'base64encodedZipContent' // Base64 kodierter ZIP-Inhalt * }); */ async createIntegrationFlow(flowData) { const response = await this.api.integrationDesigntimeArtifacts.integrationDesigntimeArtifactsCreate(flowData); return this.normalizer.normalizeEntityResponse(response.data, 'createIntegrationFlow'); } /** * Aktualisiert einen vorhandenen Integrationsflow. * * @param {string} flowId ID des zu aktualisierenden Flows * @param {string} version Version des zu aktualisierenden Flows * @param {ComSapHciApiIntegrationDesigntimeArtifactUpdate} flowData Die zu aktualisierenden Daten * @returns {Promise<void>} Promise, der aufgelöst wird, wenn der Flow aktualisiert wurde * * @example * await client.updateIntegrationFlow('MyFlowId', '1.0.0', { * Name: 'Updated Flow Name', * ArtifactContent: 'newBase64encodedZipContent' // Neuer Base64 kodierter ZIP-Inhalt * }); */ async updateIntegrationFlow(flowId, version, flowData) { await this.api.integrationDesigntimeArtifactsIdIdVersionVersion.integrationDesigntimeArtifactsIdVersionUpdate(flowId, version, flowData); } /** * Löscht einen Integrationsflow anhand seiner ID und Version. * * @param {string} flowId ID des zu löschenden Integrationsflows * @param {string} version Version des zu löschenden Integrationsflows * @returns {Promise<void>} Promise, der aufgelöst wird, wenn der Flow gelöscht wurde * * @example * await client.deleteIntegrationFlow('MyFlowId', '1.0.0'); */ async deleteIntegrationFlow(flowId, version) { await this.api.integrationDesigntimeArtifactsIdIdVersionVersion.integrationDesigntimeArtifactsIdVersionDelete(flowId, version); } /** * Lädt einen Integrationsflow als ZIP-Datei herunter. * * Hinweis: Download von Flows aus Configure-Only-Paketen ist nicht möglich. * Die Methode gibt in Node.js-Umgebungen einen Buffer zurück und * in Browser-Umgebungen einen Blob/File. * * @param {string} flowId ID des herunterzuladenden Flows * @param {string} [version='active'] Version des herunterzuladenden Flows * @returns {Promise<Buffer | Blob>} Promise mit den Binärdaten des Flows * * @example * // In Node.js: * try { * const buffer = await client.downloadIntegrationFlow('MyFlowId', '1.0.1'); * fs.writeFileSync('MyFlowId.zip', buffer); * } catch (error) { * console.error('Download failed:', error); * } */ async downloadIntegrationFlow(flowId, version = 'active') { try { // Für diesen API-Call verwenden wir direkt axios, da wir einen binären Response benötigen // und der generierte HTTP-Client nicht optimal mit arraybuffer umgeht const axios = require('axios'); // Erhalte das Security-Token (wird von der API-Client-Instanz verwaltet) const securityWorker = this.api['securityWorker']; const securityData = this.api['securityData']; // Debug-Logging für die Sicherheitsinformationen if (process.env.DEBUG === 'true') { console.debug('[IntegrationContentClient] Preparing download for flow:', flowId, version); console.debug('[IntegrationContentClient] Security worker available:', !!securityWorker); console.debug('[IntegrationContentClient] Security data available:', !!securityData); } // Sicherheitsparameter abrufen und sicherstellen, dass wir ein Objekt haben let securityParams = {}; if (securityWorker) { try { const params = await securityWorker(securityData); if (params && typeof params === 'object') { securityParams = params; } } catch (securityError) { console.error('[IntegrationContentClient] Error getting security params:', securityError); } } if (process.env.DEBUG === 'true') { console.debug('[IntegrationContentClient] Security params:', securityParams && typeof securityParams === 'object' ? Object.keys(securityParams).length : 'none'); } // URL aus dem API-Client extrahieren const baseUrl = this.api['baseUrl']; const url = `${baseUrl}/IntegrationDesigntimeArtifacts(Id='${flowId}',Version='${version}')/$value`; // Wenn keine Sicherheitsparameter vorhanden sind oder die Headers fehlen, // verwenden wir einen Fallback const hasSecurityHeaders = securityParams && typeof securityParams === 'object' && 'headers' in securityParams && securityParams.headers && typeof securityParams.headers === 'object' && 'Authorization' in securityParams.headers; if (!hasSecurityHeaders) { if (process.env.SAP_OAUTH_CLIENT_ID && process.env.SAP_OAUTH_CLIENT_SECRET && process.env.SAP_OAUTH_TOKEN_URL) { // Direktes Token-Holen als Fallback if (process.env.DEBUG === 'true') { console.debug('[IntegrationContentClient] Using direct token acquisition as fallback'); } // Token direkt holen (ähnlich wie in getArtifacts.js) const tokenResponse = await axios({ method: 'post', url: process.env.SAP_OAUTH_TOKEN_URL, params: { grant_type: 'client_credentials', client_id: process.env.SAP_OAUTH_CLIENT_ID, client_secret: process.env.SAP_OAUTH_CLIENT_SECRET }, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }); if (process.env.DEBUG === 'true') { console.debug('[IntegrationContentClient] Token acquired successfully, making download request'); } // API-Aufruf mit dem direkt geholten Token durchführen const response = await axios({ method: 'get', url, headers: { 'Authorization': `Bearer ${tokenResponse.data.access_token}`, 'Accept': 'application/zip' }, responseType: 'arraybuffer' }); // Prüfen, ob wir Daten erhalten haben if (response && response.data) { if (process.env.DEBUG === 'true') { console.debug('[IntegrationContentClient] Download successful, data length:', response.data.length || (response.data.byteLength || 'unknown')); } // In Node.js-Umgebung if (typeof Buffer !== 'undefined') { return Buffer.from(response.data); } // In Browser-Umgebung if (typeof Blob !== 'undefined' && typeof window !== 'undefined') { return new Blob([response.data], { type: 'application/zip' }); } } throw new Error(`Unexpected response format or environment when downloading flow ${flowId}`); } else { if (process.env.DEBUG === 'true') { console.debug('[IntegrationContentClient] No security parameters and no environment variables for fallback'); } } } // Nur hier ankommen, wenn wir gültige securityParams haben oder keine Fallback-Variablen vorhanden sind if (process.env.DEBUG === 'true') { console.debug('[IntegrationContentClient] Using security parameters from API client'); } // API-Aufruf mit axios durchführen const response = await axios({ method: 'get', url, headers: { ...((securityParams && typeof securityParams === 'object' && 'headers' in securityParams) ? securityParams.headers : {}), 'Accept': 'application/zip' }, responseType: 'arraybuffer' }); // Prüfen, ob wir Daten erhalten haben if (response && response.data) { if (process.env.DEBUG === 'true') { console.debug('[IntegrationContentClient] Download successful, data length:', response.data.length || (response.data.byteLength || 'unknown')); } // In Node.js-Umgebung if (typeof Buffer !== 'undefined') { return Buffer.from(response.data); } // In Browser-Umgebung if (typeof Blob !== 'undefined' && typeof window !== 'undefined') { return new Blob([response.data], { type: 'application/zip' }); } } throw new Error(`Unexpected response format or environment when downloading flow ${flowId}`); } catch (error) { // Verbesserte Fehlerbehandlung mit mehr Informationen console.error(`[IntegrationContentClient] Error downloading flow ${flowId}:`, error.message || 'Unknown error'); if (error.response) { console.error(`Status: ${error.response.status}, Status text: ${error.response.statusText}`); if (error.response.data) { // Wenn die Fehlerdaten ein Buffer sind, versuchen wir, sie als Text zu decodieren const errorData = Buffer.isBuffer(error.response.data) ? Buffer.from(error.response.data).toString('utf8') : error.response.data; console.error('Error details:', errorData); } } throw error; } } /** * Deployed einen Integrationsflow * * @param {string} flowId ID des zu deployenden Integrationsflows * @param {string} [version='active'] Version des Integrationsflows * @returns {Promise<void>} Promise, der aufgelöst wird, wenn das Deployment gestartet wurde * * @example * await client.deployIntegrationFlow('MyFlowId'); */ async deployIntegrationFlow(flowId, version = 'active') { await this.api.deployIntegrationDesigntimeArtifact.deployIntegrationDesigntimeArtifactCreate({ Id: flowId, Version: `'${version}'` }); } /** * Undeployed einen Integrationsflow * * @param {string} flowId ID des zu undeployenden Integrationsflows * @returns {Promise<void>} Promise, der aufgelöst wird, wenn der Flow undeployed wurde * * @example * await client.undeployIntegrationFlow('MyFlowId'); */ async undeployIntegrationFlow(flowId) { await this.api.integrationRuntimeArtifactsId.integrationRuntimeArtifactsDelete(flowId); } /** * Gibt alle deployten Integrationsartefakte zurück * * @param {Object} options Optionale Parameter für die Anfrage * @param {number} [options.top] Maximale Anzahl der zurückzugebenden Artefakte * @param {number} [options.skip] Anzahl der zu überspringenden Artefakte * @param {string} [options.filter] OData-Filterausdruck * @returns {Promise<ComSapHciApiIntegrationRuntimeArtifact[]>} Promise mit einer Liste von Runtime-Artefakten * * @example * // Alle deployten Artefakte abrufen * const runtimeArtifacts = await client.getDeployedArtifacts(); * * @example * // Deployten Artefakte mit Filter abrufen * const errorArtifacts = await client.getDeployedArtifacts({ * filter: "Status eq 'ERROR'" * }); */ async getDeployedArtifacts(options = {}) { const response = await this.api.integrationRuntimeArtifacts.integrationRuntimeArtifactsList({ $top: options.top, $skip: options.skip, $filter: options.filter }); return this.normalizer.normalizeArrayResponse(response.data, 'getDeployedArtifacts'); } /** * Gibt Konfigurationsparameter für einen Integrationsflow zurück * * @param {string} flowId ID des Integrationsflows * @param {string} [version='active'] Version des Integrationsflows * @param {string} [filter] Optionaler OData-Filterausdruck * @returns {Promise<ComSapHciApiConfiguration[]>} Promise mit einer Liste von Konfigurationen * * @example * const configs = await client.getIntegrationFlowConfigurations('MyFlowId'); */ async getIntegrationFlowConfigurations(flowId, version = 'active', filter) { const response = await this.api.integrationDesigntimeArtifactsIdIdVersionVersion.configurationsList(flowId, version, { $filter: filter }); return this.normalizer.normalizeArrayResponse(response.data, 'getIntegrationFlowConfigurations'); } /** * Gibt die Anzahl der Konfigurationsparameter für einen Integrationsflow zurück. * * @param {string} flowId ID des Integrationsflows * @param {string} [version='active'] Version des Integrationsflows * @param {string} [filter] Optionaler OData-Filterausdruck * @returns {Promise<number>} Promise mit der Anzahl der Konfigurationen * * @example * const count = await client.getIntegrationFlowConfigurationCount('MyFlowId'); * console.log(`Flow has ${count} configurations.`); */ async getIntegrationFlowConfigurationCount(flowId, version = 'active', filter) { // Die API gibt keinen direkten Zähler zurück, daher holen wir alle und zählen sie. // Beachte: Das ist bei sehr vielen Konfigurationen ineffizient. // Eine bessere Implementierung würde die $count-Option nutzen, falls die generierte API sie unterstützt. // Da der generierte Client `configurationsCountList` hat, verwenden wir diesen. const response = await this.api.integrationDesigntimeArtifactsIdIdVersionVersion.configurationsCountList(flowId, version, { $filter: filter }); // Die API gibt die Anzahl als String im Body zurück, wenn $count verwendet wird. // Wir parsen diesen String zu einer Zahl. const countString = response.data; return parseInt(countString || '0', 10); } /** * Aktualisiert einen Konfigurationsparameter für einen Integrationsflow * * @param {string} flowId ID des Integrationsflows * @param {string} parameterKey Schlüssel des zu aktualisierenden Parameters * @param {string} parameterValue Neuer Wert für den Parameter * @param {string} [dataType] Datentyp des Parameters (z.B., 'xsd:string') * @param {string} [version='active'] Version des Integrationsflows * @returns {Promise<void>} Promise, der aufgelöst wird, wenn der Parameter aktualisiert wurde * * @example * await client.updateIntegrationFlowConfiguration( * 'MyFlowId', * 'Receiver_Host', * 'api.example.com', * 'xsd:string' * ); */ async updateIntegrationFlowConfiguration(flowId, parameterKey, parameterValue, dataType, version = 'active') { await this.api.integrationDesigntimeArtifactsIdIdVersionVersion.linksConfigurationsUpdate(flowId, version, parameterKey, { ParameterValue: parameterValue, DataType: dataType }); } /** * Gibt alle Service-Endpoints von deployten Integrationsflows zurück * * @param {Object} options Optionale Parameter für die Anfrage * @param {number} [options.top] Maximale Anzahl der zurückzugebenden Endpoints * @param {number} [options.skip] Anzahl der zu überspringenden Endpoints * @param {string} [options.filter] OData-Filterausdruck * @returns {Promise<ComSapHciApiServiceEndpoint[]>} Promise mit einer Liste von Service-Endpoints * * @example * const endpoints = await client.getServiceEndpoints(); */ async getServiceEndpoints(options = {}) { // Korrektur: OData-konforme Parameter für $expand // Bei OData werden mehrere expand-Werte durch Kommas getrennt in einem Parameter übergeben const response = await this.api.serviceEndpoints.serviceEndpointsList({ $top: options.top, $skip: options.skip, $filter: options.filter, $expand: "EntryPoints,ApiDefinitions" // Type Assertion, damit der TypeScript-Compiler dies akzeptiert }); return this.normalizer.normalizeArrayResponse(response.data, 'getServiceEndpoints'); } /** * Gibt Fehlerinformationen für ein deployten Integrationsartefakt zurück * * @param {string} artifactId ID des deployten Integrationsartefakts * @returns {Promise<ComSapHciApiRuntimeArtifactErrorInformation | null>} Promise mit den Fehlerinformationen oder null bei Fehlern * * @example * const errorInfo = await client.getArtifactErrorInformation('MyFailedFlow'); * if (errorInfo && errorInfo.Id) { * console.log(`Fehler-ID: ${errorInfo.Id}`); * } */ async getArtifactErrorInformation(artifactId) { try { // Verwende die generierte API, um das Artefakt mit Fehlerinformationen zu holen const response = await this.api.integrationRuntimeArtifactsId.integrationRuntimeArtifactsList(artifactId); // Hole das RuntimeArtifact aus der Antwort const runtimeArtifact = this.normalizer.normalizeEntityResponse(response.data, 'getDeployedArtifactById'); // Wenn es keine Fehlerinformationen gibt, gib null zurück if (!(runtimeArtifact === null || runtimeArtifact === void 0 ? void 0 : runtimeArtifact.ErrorInformation)) { return null; } // Da die ErrorInformation bereits im Artefakt enthalten ist, können wir sie direkt zurückgeben return runtimeArtifact.ErrorInformation; } catch (error) { console.error('Error fetching error information:', error); return null; } } /** * Gibt detaillierte Fehlerinformationen für ein deployten Integrationsartefakt zurück * Diese Methode ruft den spezifischen $value-Endpunkt auf, der mehr Details enthält * * @param {string} artifactId ID des deployten Integrationsartefakts * @returns {Promise<DetailedErrorInformation | null>} Promise mit den detaillierten Fehlerinformationen oder null bei Fehlern * * @example * const detailedError = await client.getDetailedArtifactErrorInformation('MyFailedFlow'); * if (detailedError && detailedError.message) { * console.log(`Fehlertyp: ${detailedError.message.messageId}`); * if (detailedError.parameter && detailedError.parameter.length > 0) { * try { * const paramJson = JSON.parse(detailedError.parameter[0]); * console.log(`Fehlermeldung: ${paramJson.message}`); * } catch (e) { * console.log(`Parameter: ${detailedError.parameter[0]}`); * } * } * } * * @deprecated Diese Methode wird in zukünftigen Versionen ausgelagert. Bitte verwenden Sie die entsprechenden Methoden im IntegrationContentAdvancedClient. */ async getDetailedArtifactErrorInformation(artifactId) { return this.advancedClient.getDetailedArtifactErrorInformation(artifactId); } /** * Parst die Fehlerdetails aus den Parametern einer DetailedErrorInformation * * @param {DetailedErrorInformation} errorInfo Die detaillierten Fehlerinformationen * @returns {ParsedErrorDetails | null} Die geparsten Fehlerdetails oder null, wenn keine Parameter vorhanden oder das Parsing fehlschlägt * * @example * const detailedError = await client.getDetailedArtifactErrorInformation('MyFailedFlow'); * if (detailedError) { * const errorDetails = client.parseErrorDetails(detailedError); * if (errorDetails && errorDetails.message) { * console.log(`Fehlermeldung: ${errorDetails.message}`); * * if (errorDetails.childMessageInstances && errorDetails.childMessageInstances.length > 0) { * console.log(`Hauptursache: ${errorDetails.childMessageInstances[0].message}`); * } * } * } * * @deprecated Diese Methode wird in zukünftigen Versionen ausgelagert. Bitte verwenden Sie die entsprechenden Methoden im IntegrationContentAdvancedClient. */ parseErrorDetails(errorInfo) { return this.advancedClient.parseErrorDetails(errorInfo); } /** * Gibt alle Value Mappings für ein bestimmtes Paket zurück * * @param {string} packageId ID des Integrationspakets * @returns {Promise<ComSapHciApiValueMappingDesigntimeArtifact[]>} Promise mit einer Liste von Value Mappings * * @example * const valueMappings = await client.getValueMappings('MyPackageId'); */ async getValueMappings(packageId) { try { const response = await this.api.integrationPackagesId.valueMappingDesigntimeArtifactsList(packageId); return this.normalizer.normalizeArrayResponse(response.data, 'getValueMappings'); } catch (error) { // Check for the specific 500 Internal Server Error case if ((error === null || error === void 0 ? void 0 : error.statusCode) === 500 && (error === null || error === void 0 ? void 0 : error.errorCode) === 'Internal Server Error') { console.warn(`Failed to fetch Value Mappings for package ${packageId}. Skipping and returning empty array.`); return []; } // For other errors, rethrow throw error; } } /** * Gibt alle Message Mappings für ein bestimmtes Paket zurück * * @param {string} packageId ID des Integrationspakets * @returns {Promise<ComSapHciApiMessageMappingDesigntimeArtifact[]>} Promise mit einer Liste von Message Mappings * * @example * const messageMappings = await client.getMessageMappings('MyPackageId'); */ async getMessageMappings(packageId) { try { const response = await this.api.integrationPackagesId.messageMappingDesigntimeArtifactsList(packageId); return this.normalizer.normalizeArrayResponse(response.data, 'getMessageMappings'); } catch (error) { // Check for the specific 500 Internal Server Error case if ((error === null || error === void 0 ? void 0 : error.statusCode) === 500 && (error === null || error === void 0 ? void 0 : error.errorCode) === 'Internal Server Error') { console.warn(`Failed to fetch Message Mappings for package ${packageId}. Skipping and returning empty array.`); return []; } // For other errors, rethrow throw error; } } /** * Ruft alle Integrationspakete mit ihren zugehörigen Artefakten ab * * Diese Methode holt alle Integrationspakete und sammelt für jedes Paket: * - Integrationsflows * - Message Mappings * - Value Mappings * - Script Collections * * @param {Object} options Optionale Parameter für die Anfrage * @param {number} [options.top] Maximale Anzahl der zurückzugebenden Pakete * @param {number} [options.skip] Anzahl der zu überspringenden Pakete * @param {boolean} [options.includeEmpty=false] Ob leere Pakete ohne Artefakte inkludiert werden sollen * @param {boolean} [options.parallel=false] Ob die Artefakte parallel abgerufen werden sollen (schneller, aber möglicherweise API-Limits) * @returns {Promise<PackageWithArtifacts[]>} Liste von Paketen mit ihren Artefakten * * @example * // Alle Pakete mit ihren Artefakten abrufen * const packagesWithArtifacts = await client.getPackagesWithArtifacts(); * * // Nur die ersten 5 Pakete mit Artefakten abrufen * const packagesWithArtifacts = await client.getPackagesWithArtifacts({ top: 5 }); * * // Alle Pakete mit parallelen API-Aufrufen abrufen (schneller) * const packagesWithArtifacts = await client.getPackagesWithArtifacts({ parallel: true }); * * @deprecated Diese Methode wird in zukünftigen Versionen ausgelagert. Bitte verwenden Sie die entsprechenden Methoden im IntegrationContentAdvancedClient. */ async getPackagesWithArtifacts(options = {}) { return this.advancedClient.getPackagesWithArtifacts(options); } /** * Ruft alle Integrationsflows aller Pakete ab * * @param {Object} options Optionale Parameter für die Anfrage * @param {number} [options.top] Maximale Anzahl der zurückzugebenden Pakete für die Abfrage * @param {ComSapHciApiIntegrationPackage[]} [options.packages] Bereits abgerufene Pakete, um redundante API-Aufrufe zu vermeiden * @returns {Promise<ComSapHciApiIntegrationDesigntimeArtifact[]>} Liste aller Integrationsflows * * @example * const allFlows = await client.getAllIntegrationFlows(); * * // Mit bereits vorhandenen Paketen * const packages = await client.getIntegrationPackages(); * const allFlows = await client.getAllIntegrationFlows({ packages }); * * @deprecated Diese Methode wird in zukünftigen Versionen ausgelagert. Bitte verwenden Sie die entsprechenden Methoden im IntegrationContentAdvancedClient. */ async getAllIntegrationFlows(options = {}) { return this.advancedClient.getAllIntegrationFlows(options); } /** * Ruft alle Script Collections aller Pakete ab * * @param {Object} options Optionale Parameter für die Anfrage * @param {number} [options.top] Maximale Anzahl der zurückzugebenden Pakete für die Abfrage * @param {ComSapHciApiIntegrationPackage[]} [options.packages] Bereits abgerufene Pakete, um redundante API-Aufrufe zu vermeiden * @returns {Promise<ComSapHciApiScriptCollectionDesigntimeArtifact[]>} Liste aller Script Collections * * @example * const allScriptCollections = await client.getAllScriptCollections(); * * // Mit bereits vorhandenen Paketen * const packages = await client.getIntegrationPackages(); * const allScripts = await client.getAllScriptCollections({ packages }); * * @deprecated Diese Methode wird in zukünftigen Versionen ausgelagert. Bitte verwenden Sie die entsprechenden Methoden im IntegrationContentAdvancedClient. */ async getAllScriptCollections(options = {}) { return this.advancedClient.getAllScriptCollections(options); } /** * Aktualisiert ein Integrationspaket anhand seiner ID * * @param {string} packageId ID des zu aktualisierenden Integrationspakets * @param {ComSapHciApiIntegrationPackageUpdate} packageData Die zu aktualisierenden Daten des Pakets * @returns {Promise<void>} Promise, der aufgelöst wird, wenn das Paket aktualisiert wurde * * @example * await client.updateIntegrationPackage('MyPackageId', { * Name: 'Updated Package Name', * Description: 'This package has been updated.' * }); */ async updateIntegrationPackage(packageId, packageData) { await this.api.integrationPackagesId.integrationPackagesUpdate(packageId, packageData); } /** * Lädt ein Integrationspaket als ZIP-Datei herunter * * Hinweis: Download schlägt fehl, wenn das Paket Artefakte im Entwurfsstatus enthält. * Der Rückgabetyp `File` ist primär für Browser-Umgebungen relevant. In Node.js * müsste die Response anders behandelt werden (z.B. als Stream oder Buffer). * * @param {string} packageId ID des herunterzuladenden Integrationspakets * @returns {Promise<File>} Promise mit der heruntergeladenen Datei (im Browser-Kontext) * * @example * // Im Browser: * try { * const file = await client.downloadIntegrationPackage('MyPackageId'); * const url = URL.createObjectURL(file); * const a = document.createElement('a'); * a.href = url; * a.download = 'MyPackageId.zip'; * document.body.appendChild(a); * a.click(); * window.URL.revokeObjectURL(url); * document.body.removeChild(a); * } catch (error) { * console.error('Download failed:', error); * } */ async downloadIntegrationPackage(packageId) { const response = await this.api.integrationPackagesId.valueList(packageId); // Die API-Client-Generierung gibt 'File' zurück, was ggf. angepasst werden muss. return response.data; } /** * Speichert einen Integrationsflow unter einer neuen Version. * * @param {string} flowId ID des Integrationsflows * @param {string} newVersion Die neue Versionsnummer (z.B. '1.0.1') * @returns {Promise<void>} Promise, der aufgelöst wird, wenn die neue Version gespeichert wurde * * @example * await client.saveIntegrationFlowAsVersion('MyFlowId', '1.0.1'); */ async saveIntegrationFlowAsVersion(flowId, newVersion) { await this.api.integrationDesigntimeArtifactSaveAsVersion.integrationDesigntimeArtifactSaveAsVersionCreate({ Id: flowId, SaveAsVersion: newVersion }); } /** * Gibt ein spezifisches deploytes Integrationsartefakt anhand seiner ID zurück. * * @param {string} artifactId ID des deployten Artefakts * @returns {Promise<ComSapHciApiIntegrationRuntimeArtifact | undefined>} Promise mit dem Runtime-Artefakt oder undefined, wenn nicht gefunden. * * @example * const artifact = await client.getDeployedArtifactById('MyDeployedFlow'); * if (artifact) { * console.log(`Status of ${artifact.Name}: ${artifact.Status}`); * } */ async getDeployedArtifactById(artifactId) { const response = await this.api.integrationRuntimeArtifactsId.integrationRuntimeArtifactsList(artifactId); return this.normalizer.normalizeEntityResponse(response.data, 'getDeployedArtifactById'); } /** * Gibt die Anzahl der Service-Endpoints von deployten Integrationsflows zurück. * * @param {string} [filter] Optionaler OData-Filterausdruck * @returns {Promise<number>} Promise mit der Anzahl der Service-Endpoints * * @example * const count = await client.getServiceEndpointCount("Protocol eq 'SOAP'"); * console.log(`Number of SOAP endpoints: ${count}`); */ async getServiceEndpointCount(filter) { const response = await this.api.serviceEndpoints.countList({ $filter: filter }); // Die API gibt die Anzahl als String im Body zurück. const countString = response.data; return parseInt(countString || '0', 10); } /** * Gibt den Build- und Deploy-Status für eine bestimmte Task-ID zurück. * * @param {string} taskId Die ID des Build/Deploy-Tasks * @returns {Promise<ComSapHciApiBuildAndDeployStatus['d'] | undefined>} Promise mit dem Status-Objekt oder undefined. * * @example * const status = await client.getBuildAndDeployStatus('task123'); * if (status) { * console.log(`Task ${status.TaskId} status: ${status.Status}`); * } */ async getBuildAndDeployStatus(taskId) { var _a, _b; const response = await this.api.buildAndDeployStatusTaskIdTaskId.buildAndDeployStatusTaskIdList(taskId); return (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.d) === null || _b === void 0 ? void 0 : _b.d; } /** * Gibt alle Message Mappings (tenant-weit) zurück. * * @param {Object} options Optionale Parameter für die Anfrage * @param {number} [options.top] Maximale Anzahl der zurückzugebenden Mappings * @param {number} [options.skip] Anzahl der zu überspringenden Mappings * @param {string} [options.select] Zu selektierende Properties * @param {string} [options.orderby] Sortierreihenfolge * @returns {Promise<ComSapHciApiMessageMappingDesigntimeArtifact[]>} Promise mit einer Liste von Message Mappings * * @example * const allMappings = await client.getAllMessageMappings({ top: 50 }); * * @deprecated Diese Methode wird in zukünftigen Versionen ausgelagert. Bitte verwenden Sie die entsprechenden Methoden im IntegrationContentAdvancedClient. */ async getAllMessageMappings(options = {}) { return this.advancedClient.getAllMessageMappings(options); } /** * Erstellt/lädt ein neues Message Mapping hoch. * * @param {ComSapHciApiMessageMappingDesigntimeArtifactCreate} mappingData Daten des zu erstellenden Mappings * @returns {Promise<ComSapHciApiMessageMappingDesigntimeArtifact | undefined>} Promise mit dem erstellten Mapping * * @example * const newMapping = await client.createMessageMapping({ * Id: 'MyNewMapping', * Name: 'My New Mapping', * PackageId: 'MyPackageId', * Description: 'Mapping Description', * ArtifactContent: 'base64encodedZipContent' // Base64 kodierter ZIP-Inhalt * }); */ async createMessageMapping(mappingData) { const response = await this.api.messageMappingDesigntimeArtifacts.messageMappingDesigntimeArtifactsCreate( // Der generierte Client erwartet hier fälschlicherweise ValueMappingCreate, wir casten es. mappingData); return this.normalizer.normalizeEntityResponse(response.data, 'createMessageMapping'); } /** * Gibt alle Value Mappings (tenant-weit) zurück. * * @param {Object} options Optionale Parameter für die Anfrage * @param {number} [options.top] Maximale Anzahl der zurückzugebenden Mappings * @param {number} [options.skip] Anzahl der zu überspringenden Mappings * @param {string} [options.select] Zu selektierende Properties * @param {string} [options.orderby] Sortierreihenfolge * @returns {Promise<ComSapHciApiValueMappingDesigntimeArtifact[]>} Promise mit einer Liste von Value Mappings * * @example * const allValueMappings = await client.getAllValueMappings({ top: 20 }); */ async getAllValueMappings(options = {}) { return this.advancedClient.getAllValueMappings(options); } /** * Erstellt/lädt ein neues Value Mapping hoch. * * @param {ComSapHciApiValueMappingDesigntimeArtifactCreate} mappingData Daten des zu erstellenden Mappings * @returns {Promise<ComSapHciApiValueMappingDesigntimeArtifact | undefined>} Promise mit dem erstellten Mapping * * @example * const newMapping = await client.createValueMapping({ * Id: 'MyNewValueMap', * Name: 'My New Value Map', * PackageId: 'MyPackageId', * Description: 'Value Map Description', * ArtifactContent: 'base64encodedZipContent' // Base64 kodierter ZIP-Inhalt * }); */ async createValueMapping(mappingData) { const response = await this.api.valueMappingDesigntimeArtifacts.valueMappingDesigntimeArtifactsCreate(mappingData); return this.normalizer.normalizeEntityResponse(response.data, 'createValueMapping'); } /** * Gibt alle Value Mapping Schemas (Agency Identifiers) für ein Value Mapping zurück. * * @param {string} mappingId ID des Value Mappings * @param {string} [version='active'] Version des Value Mappings * @param {string} [filter] OData-Filterausdruck (z.B. "State eq 'Configured'") * @returns {Promise<ComSapHciApiValMapSchema[]>} Promise mit einer Liste von Schemas * * @example * const schemas = await client.getValueMappingSchemas('MyValueMapId'); * const configuredSchemas = await client.getValueMappingSchemas('MyValueMapId', 'active', "State eq 'Configured'"); */ async getValueMappingSchemas(mappingId, version = 'active', filter) { const response = await this.api.valueMappingDesigntimeArtifactsIdIdVersionVersion.valMapSchemaList(mappingId, version, { $filter: filter }); return this.normalizer.normalizeArrayResponse(response.data, 'getValueMappingSchemas'); } /** * Gibt alle Value Mappings für ein spezifisches Schema (Agency Identifiers) zurück. * * @param {string} mappingId ID des Value Mappings * @param {string} version Version des Value Mappings * @param {string} srcAgency Source Agency * @param {string} srcId Source ID * @param {string} tgtAgency Target Agency * @param {string} tgtId Target ID * @param {string} [filter] OData-Filterausdruck (z.B. "Value/SrcValue eq 'SourceVal' and Value/TgtValue eq 'TargetVal'") * @returns {Promise<ComSapHciApiValMaps[]>} Promise mit einer Liste von Mappings für das Schema * * @example * const schemaMappings = await client.getValueMappingsForSchema( * 'MyValueMapId', 'active', 'SourceAgency', 'SrcID1', 'TargetAgency', 'TgtID1' * ); */ async getValueMappingsForSchema(mappingId, version, srcAgency, srcId, tgtAgency, tgtId, filter) { const response = await this.api.valueMappingDesigntimeArtifactsIdIdVersionVersion.valMapSchemaSrcAgencySrcIdTgtAgencyTgtIdValMapsList(mappingId, version, srcAgency, srcId, tgtAgency, tgtId, { $filter: filter }); return this.normalizer.normalizeArrayResponse(response.data, 'getValueMappingsForSchema'); } /** * Gibt alle Default Value Mappings für ein spezifisches Schema (Agency Identifiers) zurück. * * @param {string} mappingId ID des Value Mappings * @param {string} version Version des Value Mappings * @param {string} srcAgency Source Agency * @param {string} srcId Source ID * @param {string} tgtAgency Target Agency * @param {string} tgtId Target ID * @returns {Promise<ComSapHciApiValMaps[]>} Promise mit einer Liste von Default Mappings für das Schema * * @example * const defaultMappings = await client.getDefaultValueMappingsForSchema( * 'MyValueMapId', 'active', 'SourceAgency', 'SrcID1', 'TargetAgency', 'TgtID1' * ); */ async getDefaultValueMappingsForSchema(mappingId, version, srcAgency, srcId, tgtAgency, tgtId) { const response = await this.api.valueMappingDesigntimeArtifactsIdIdVersionVersion.valMapSchemaSrcAgencySrcIdTgtAgencyTgtIdDefaultValMapsList(mappingId, version, srcAgency, srcId, tgtAgency, tgtId); return this.normalizer.normalizeArrayResponse(response.data, 'getDefaultValueMappingsForSchema'); } /** * Deployed ein Value Mapping. * * @param {string} mappingId ID des zu deployenden Mappings * @param {string} [version='active'] Version des Mappings * @returns {Promise<void>} Promise, der aufgelöst wird, wenn das Deployment gestartet wurde * * @example * await client.deployValueMapping('MyValueMapId'); */ async deployValueMapping(mappingId, version = 'active') { await this.api.deployValueMappingDesigntimeArtifact.deployValueMappingDesigntimeArtifactCreate({ Id: `'${mappingId}'`, // API erwartet ID in einfachen Anführungszeichen Version: `'${version}'` // API erwartet Version in einfachen Anführungszeichen }); } /** * Speichert ein Value Mapping unter einer neuen Version. * * @param {string} mappingId ID des Value Mappings * @param {string} newVersion Die neue Versionsnummer (z.B. '1.0.1') * @returns {Promise<void>} Promise, der aufgelöst wird, wenn die neue Version gespeichert wurde * * @example * await client.saveValueMappingAsVersion('MyValueMapId', '1.0.1'); */ async saveValueMappingAsVersion(mappingId, newVersion) { await this.api.valueMappingDesigntimeArtifactSaveAsVersion.valueMappingDesigntimeArtifactSaveAsVersionCreate({ Id: mappingId, SaveAsVersion: newVersion }); } /** * Erstellt oder aktualisiert einen Eintrag (Value Pair) in einem Value Mapping. * * @param {string} mappingId ID des Value Mappings * @param {string} version Version des Value Mappings * @param {string} srcAgency Source Agency * @param {string} srcId Source ID * @param {string} tgtAgency Target Agency * @param {string} tgtId Target ID * @param {string} srcValue Source Value * @param {string} tgtValue Target Value * @param {boolean} isConfigured Gibt an, ob das Schema konfiguriert ist * @returns {Promise<void>} Promise, der aufgelöst wird, wenn der Eintrag erstellt/aktualisiert wurde * * @example * await client.upsertValueMappingEntry( * 'MyValueMapId', 'active', 'AgencyA', 'ID1', 'AgencyB', 'ID2', * 'SourceVal1', 'TargetVal1', true * ); */ async upsertValueMappingEntry(mappingId, version, srcAgency, srcId, tgtAgency, tgtId, srcValue, tgtValue, isConfigured) { await this.api.upsertValMaps.upsertValMapsCreate({ Id: `'${mappingId}'`, // API erwartet IDs in einfachen Anführungszeichen Version: `'${version}'`, SrcAgency: `'${srcAgency}'`, SrcId: `'${srcId}'`, TgtAgency: `'${tgtAgency}'`, TgtId: `'${tgtId}'`, SrcValue: `'${srcValue}'`, TgtValue: `'${tgtValue}'`, IsConfigured: String(isConfigured) // API erwartet String 'true'/'false' }); } /** * Aktualisiert den Default-Eintrag für ein Value Mapping Schema. * * @param {string} mappingId ID des Value Mappings * @param {string} version Version des Value Mappings * @param {string} srcAgency Source Agency * @param {string} srcId Source ID * @param {string} tgtAgency Target Agency * @param {string} tgtId Target ID * @param {string} valMapId ID des Value Mappings (ValMaps entry ID) * @param {boolean} isConfigured Gibt an, ob das Schema konfiguriert ist * @returns {Promise<void>} Promise, der aufgelöst wird, wenn der Default-Eintrag aktualisiert wurde * * @example * await client.updateDefaultValueMappingEntry( * 'MyValueMapId', 'active', 'AgencyA', 'ID1', 'AgencyB', 'ID2', 'valMapEntry123', true * ); */ async updateDefaultValueMappingEntry(mappingId, version, srcAgency, srcId, tgtAgency, tgtId, valMapId, isConfigured) { await this.api.updateDefaultValMap.updateDefaultValMapCreate({ Id: `'${mappingId}'`, Version: `'${version}'`, SrcAgency: `'${srcAgency}'`, SrcId: `'${srcId}'`, TgtAgency: `'${tgtAgency}'`, TgtId: `'${tgtId}'`, ValM