UNPKG

2.9 kBTypeScriptView Raw
1import { VerifyJwtOptions } from '../jwt';
2import { Destination, DestinationNameAndJwt, DestinationRetrievalOptions } from './destination-service-types';
3import type { DestinationAccessorOptions } from './destination-accessor-types';
4/**
5 * Returns the parameter if it is a destination, calls [[getDestination]] otherwise (which will try to fetch the destination
6 * from the Cloud Foundry destination service).
7 *
8 * Fetching a destination requires:
9 * - a binding to exactly one XSUAA service instance with service plan "application"
10 * - a binding to a destination service instance
11 *
12 * 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.
13 * @param destination - A destination or the necessary parameters to fetch one.
14 * @param options - Caching options by fetching destination.
15 * @returns A promise resolving to the requested destination on success.
16 */
17export declare function useOrFetchDestination(destination: Destination | DestinationNameAndJwt, options?: DestinationOptions): Promise<Destination | null>;
18export declare type DestinationOptions = DestinationAccessorOptions & DestinationRetrievalOptions & VerifyJwtOptions;
19/**
20 * @deprecated Since v1.0.1. Use [[getDestination]] instead.
21 *
22 * Retrieves a destination with the given name from the Cloud Foundry destination service.
23 * Returns `null`, if no destination can be found.
24 * Requires the following service bindings: destination, XSUAA
25 * By default, selects subscriber over provider and instance over subaccount destinations.
26 *
27 * If the destinations are read from the environment, the jwt will be ignored.
28 * @param name - The name of the destination to be retrieved.
29 * @param options - The options of the fetching query of the destination that include the JWT of the current request and the strategy for selecting a destination.
30 * @returns A promise returning the requested destination on success.
31 */
32export declare function getDestinationOptions(name: string, options?: DestinationOptions): Promise<Destination | null>;
33/**
34 * Builds a destination from one of three sources (in the given order):
35 * - from the environment variable "destinations"
36 * - from service bindings
37 * - from the destination service
38 *
39 * If you want to get a destination only from a specific source, use the corresponding function directly
40 * (`getDestinationFromEnvByName`, `destinationForServiceBinding`, `getDestinationFromDestinationService`).
41 * @param name - The name of the destination to be retrieved.
42 * @param options - Configuration for how to retrieve destinations from the destination service.
43 * @returns A promise returning the requested destination on success.
44 */
45export declare function getDestination(name: string, options?: DestinationOptions): Promise<Destination | null>;
46//# sourceMappingURL=destination-accessor.d.ts.map
\No newline at end of file