UNPKG

@sap-ux/btp-utils

Version:

Library to simplify working with SAP BTP specific features especially in SAP Business Application

91 lines 4.6 kB
import type { Logger } from '@sap-ux/logger'; import { type Destination, type ListDestinationOpts } from './destination'; import type { ServiceInfo } from './service-info'; /** * HTTP header that is to be used for encoded credentials when communicating with a destination service instance. */ export declare const BAS_DEST_INSTANCE_CRED_HEADER = "bas-destination-instance-cred"; /** * Check if this is executed in SAP Business Application Studio. * * @returns true if yes */ export declare function isAppStudio(): boolean; /** * Read and return the BAS proxy url. * * @returns the proxy url or undefined if called outside of BAS. */ export declare function getAppStudioProxyURL(): string | undefined; /** * Read and return the BAS base url. * * @returns the base url or undefined if called outside of BAS. */ export declare function getAppStudioBaseURL(): string | undefined; /** * Asynchronously creates a base64 encoded credentials for the given destination service instance based on the client information fetched from BTP. * * @param instance name/id of the destination service instance * @returns the base64 encoded user */ export declare function getCredentialsForDestinationService(instance: string): Promise<string>; /** * Returns a url for AppStudio for the given url with the given destination. * * @param name name of the destination * @param path optional path * @returns destination url working in BAS */ export declare function getDestinationUrlForAppStudio(name: string, path?: string): string; export type Destinations = { [name: string]: Destination; }; /** * Get a list of available destinations in SAP Business Application Studio. * * @param options - options for the destinations * @returns the list of destinations */ export declare function listDestinations(options?: ListDestinationOpts): Promise<Destinations>; /** * Exposes port in SAP Business Application Studio. * * @param port Port that needs to be exposed * @param logger Logger * @returns url on which the port is exposed */ export declare function exposePort(port: number, logger?: Logger): Promise<string>; /** * Generate a destination name representing the CF target the user is logged into i.e. abap-cloud-mydestination-myorg-mydevspace. * * @param name destination name * @returns formatted destination name using target space and target organisation */ export declare function generateABAPCloudDestinationName(name: string): Promise<string>; /** * Creates a new SAP BTP subaccount destination of type 'OAuth2UserTokenExchange' using the specified `serviceInstanceName` * param to generate a new destination name with the format: `abap-cloud-<serviceInstanceName>-<cfOrg>-<cfDevSpace>`. * If the destination already exists, missing properties will be appended, existing fields are not updated with newer values. * For example: If an existing SAP BTP destination already contains `WebIDEEnabled` and the value is set as `false`, * the value will remain `false` even after the update. The specified `serviceInstanceInfo` parameter will be used as part of the destination name. * If the param `uaaCredentials` is not provided, the function will attempt to retrieve the UAA properties from the specified service instance. * * Exceptions: an exception will be thrown if the user is not logged into Cloud Foundry, * ensure you are logged in using: `cf login -a https://<cf-api-endpoint-path> -o <cfOrg> -s <cfSpace>` * * @param serviceInstanceName The name of the service instance (returned in {@link ServiceInstanceInfo} as `label`, not the `serviceName` (technical name)), * for example, as returned by the CF tools API: apiGetServicesInstancesFilteredByType {@link ServiceInstanceInfo}. * @param serviceCredentials * @param serviceCredentials.uaaCredentials object representing the Client ID and Client Secret and token endpoint {@link ServiceInfo['uaa']} * @param serviceCredentials.hostUrl The full resolved cloud host instance url e.g. https://123bd07a-eda5-50bc-b11a-b1a7b88b632b.abap.somewhereaws.hanavlab.ondemand.com * Note: This is not necessarily the same as the credentials uaa url, which is used as the host part of the tokenServiceURL. * @param logger Logger * @returns the newly generated SAP BTP destination * @throws an error if the destination could not be created */ export declare function createOAuth2UserTokenExchangeDest(serviceInstanceName: string, serviceCredentials?: { uaaCredentials: ServiceInfo['uaa']; hostUrl: string; }, logger?: Logger): Promise<Destination>; //# sourceMappingURL=app-studio.d.ts.map