@sap-ux/btp-utils
Advanced tools
Comparing version 0.16.0 to 0.17.0
import type { Logger } from '@sap-ux/logger'; | ||
import type { Destination } from './destination'; | ||
import { type Destination, type ListDestinationOpts } from './destination'; | ||
/** | ||
@@ -46,5 +46,6 @@ * HTTP header that is to be used for encoded credentials when communicating with a destination service instance. | ||
* | ||
* @param options - options for the destinations | ||
* @returns the list of destinations | ||
*/ | ||
export declare function listDestinations(): Promise<Destinations>; | ||
export declare function listDestinations(options?: ListDestinationOpts): Promise<Destinations>; | ||
/** | ||
@@ -51,0 +52,0 @@ * Exposes port in SAP Business Application Studio. |
@@ -17,2 +17,3 @@ "use strict"; | ||
const app_studio_env_1 = require("./app-studio.env"); | ||
const destination_1 = require("./destination"); | ||
/** | ||
@@ -82,7 +83,18 @@ * HTTP header that is to be used for encoded credentials when communicating with a destination service instance. | ||
/** | ||
* Helper function to strip `-api` from the host name. | ||
* | ||
* @param host - | ||
* @returns | ||
*/ | ||
function stripS4HCApiHost(host) { | ||
const [first, ...rest] = host.split('.'); | ||
return [first.replace(/-api$/, ''), ...rest].join('.'); | ||
} | ||
/** | ||
* Get a list of available destinations in SAP Business Application Studio. | ||
* | ||
* @param options - options for the destinations | ||
* @returns the list of destinations | ||
*/ | ||
async function listDestinations() { | ||
async function listDestinations(options) { | ||
const destinations = {}; | ||
@@ -93,2 +105,5 @@ await axios_1.default.get('/reload', { baseURL: process.env[app_studio_env_1.ENV.PROXY_URL] }); | ||
list.forEach((destination) => { | ||
if (options?.stripS4HCApiHosts && (0, destination_1.isS4HC)(destination)) { | ||
destination.Host = stripS4HCApiHost(destination.Host); | ||
} | ||
if (destination.WebIDEEnabled) { | ||
@@ -95,0 +110,0 @@ destinations[destination.Name] = destination; |
@@ -70,2 +70,5 @@ /** | ||
} | ||
export interface ListDestinationOpts { | ||
stripS4HCApiHosts?: boolean; | ||
} | ||
/** | ||
@@ -72,0 +75,0 @@ * Checks whether the provided destination is configured to point to an ABAP system (both cloud and on-premise). |
{ | ||
"name": "@sap-ux/btp-utils", | ||
"version": "0.16.0", | ||
"version": "0.17.0", | ||
"description": "Library to simplify working with SAP BTP specific features especially in SAP Business Application", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36809
595