@sap-cloud-sdk/connectivity
Version:
SAP Cloud SDK for JavaScript connectivity
40 lines (39 loc) • 1.94 kB
TypeScript
import type { DestinationFetchOptions } from './destination-accessor-types';
import type { Destination } from './destination-service-types';
import type { CachingOptions } from '../cache';
import type { Service } from '../environment-accessor';
import type { JwtPayload } from '../jsonwebtoken-type';
/**
* Tries to build a destination from a service binding with the given name.
* Throws an error if no services are bound at all, no service with the given name can be found, or the service type is not supported.
* The last error can be circumvent by using the second parameter to provide a custom function that transforms a service binding to a destination.
* @param options - Options to customize the behavior of this function.
* @returns A destination.
*/
export declare function getDestinationFromServiceBinding(options: Pick<DestinationFetchOptions, 'jwt' | 'iss' | 'useCache' | 'destinationName'> & DestinationFromServiceBindingOptions): Promise<Destination>;
/**
* Options to customize the behavior of {@link getDestinationFromServiceBinding}.
*/
export interface DestinationFromServiceBindingOptions {
/**
* Custom transformation function to control how a {@link Destination} is built from the given {@link Service}.
*/
serviceBindingTransformFn?: ServiceBindingTransformFunction;
}
/**
* Represents options passed to the service binding transform function.
*/
export type ServiceBindingTransformOptions = {
/**
* The JWT payload used to fetch destinations.
*/
jwt?: JwtPayload;
} & CachingOptions;
/**
* Type of the function to transform the service binding.
*/
export type ServiceBindingTransformFunction = (service: Service, options?: ServiceBindingTransformOptions) => Promise<Destination>;
/**
* @internal
*/
export declare function searchServiceBindingForDestination(options: DestinationFetchOptions & DestinationFromServiceBindingOptions): Promise<Destination | null>;