@sap-cloud-sdk/connectivity
Version:
SAP Cloud SDK for JavaScript connectivity
47 lines (46 loc) • 2.84 kB
TypeScript
import type { DestinationFetchOptions, AllDestinationOptions, DestinationWithoutToken } from './destination-accessor-types';
import type { DestinationFromServiceBindingOptions } from './destination-from-vcap';
import type { Destination } from './destination-service-types';
import type { DestinationOrFetchOptions } from './destination';
/**
* Returns the parameter if it is a destination, calls {@link getDestination} otherwise (which will try to fetch the destination
* from the Cloud Foundry destination service).
*
* Fetching a destination requires:
* - A binding to exactly one XSUAA service instance with service plan "application".
* - A binding to a destination service instance.
*
* If either of the prerequisites is not met or one of the services returns an error, this function will either throw an error or return a promise that rejects.
* @param destination - A destination or the necessary parameters to fetch one.
* @returns A promise resolving to the requested destination on success.
*/
export declare function useOrFetchDestination(destination: DestinationOrFetchOptions): Promise<Destination | null>;
/**
* Resolve a destination by the following steps:
* 1. Call [[useOrFetchDestination]]
* 2. Throw an error, when the resulting destination from the previous step is falsy
* 3. Return the checked destination.
* @param destination - A destination or the necessary parameters to fetch one.
* @returns A promise resolving to the requested destination on success.
* @internal
*/
export declare function resolveDestination(destination: DestinationOrFetchOptions): Promise<Destination>;
/**
* Builds a destination from one of three sources (in the given order):
* - from the environment variable "destinations".
* - from service bindings.
* - from the destination service.
*
* If you want to get a destination only from a specific source, use the corresponding function directly
* (`getDestinationFromEnvByName`, `getDestinationFromServiceBinding`, `getDestinationFromDestinationService`).
* @param options - The options to retrieve the destination.
* @returns A promise returning the requested destination on success.
*/
export declare function getDestination(options: DestinationFetchOptions & DestinationFromServiceBindingOptions): Promise<Destination | null>;
/**
* Fetches all destinations from the destination service which match the token.
* With a subscriber token it fetches all subscriber destinations, otherwise all provider destinations.
* @param options - The {@link AllDestinationOptions | options} to fetch all destinations.
* @returns A promise of an array of all destinations without authTokens from the destination service, on success.
*/
export declare function getAllDestinationsFromDestinationService(options?: AllDestinationOptions): Promise<DestinationWithoutToken[]>;