UNPKG

@sap-cloud-sdk/core

Version:
54 lines 3.94 kB
import { AxiosRequestConfig } from 'axios'; import { Destination, DestinationNameAndJwt } from '../connectivity/scp-cf'; import { DestinationHttpRequestConfig, ExecuteHttpRequestFn, HttpRequestConfig, HttpRequestOptions, HttpResponse } from './http-client-types'; /** * Builds a [[DestinationHttpRequestConfig]] for the given destination. * If a destination name (and a JWT) are provided, it will try to resolve the destination. * @param destination - A destination or a destination name and a JWT. * @param customHeaders - Custom default headers for the resulting HTTP request. * @returns A [[DestinationHttpRequestConfig]]. */ export declare function buildHttpRequest(destination: Destination | DestinationNameAndJwt, customHeaders?: Record<string, any>): Promise<DestinationHttpRequestConfig>; /** * Builds a [[DestinationHttpRequestConfig]] for the given destination * and then merges it into the given request configuration. * Setting of the given request configuration take precedence over any destination related configuration. * @param destination - A destination or a destination name and a JWT. * @param requestConfig - Any object representing an HTTP request. * @returns The given request config merged with the config built for the given destination. */ export declare function addDestinationToRequestConfig<T extends HttpRequestConfig>(destination: Destination | DestinationNameAndJwt, requestConfig: T): Promise<T & DestinationHttpRequestConfig>; /** * Takes as parameter a function that expects an [[HttpRequest]] and returns a Promise of [[HttpResponse]]. * Returns a function that takes a destination and a request-config (extends [[HttpRequestConfig]]), builds an [[HttpRequest]] from them, and calls * the provided execute function. * * NOTE: If you simply want to execute a request without passing your own execute function, use [[executeHttpRequest]] instead. * @param executeFn - A function that can execute an [[HttpRequestConfig]]. * @returns A function expecting destination and a request. */ export declare function execute<ReturnT>(executeFn: ExecuteHttpRequestFn<ReturnT>): <T extends HttpRequestConfig>(destination: Destination | DestinationNameAndJwt, requestConfig: T, options?: HttpRequestOptions | undefined) => Promise<ReturnT>; /** * * @experimental This API is experimental and might change in newer versions. Use with caution. * @param destination - A destination or a destination name and a JWT. * @param requestConfig - Any object representing an HTTP request. */ export declare function buildAxiosRequestConfig<T extends HttpRequestConfig>(destination: Destination | DestinationNameAndJwt, requestConfig?: Partial<T>): Promise<AxiosRequestConfig>; /** * Builds a [[DestinationHttpRequestConfig]] for the given destination, merges it into the given requestConfig * and executes it (using Axios). * @param destination - A destination or a destination name and a JWT. * @param requestConfig - Any object representing an HTTP request. * @param options - An [[HttpRequestOptions]] of the http request for configuring e.g., csrf token delegation. By default, the SDK will not fetch the csrf token. * @returns A promise resolving to an [[HttpResponse]]. */ export declare function executeHttpRequest<T extends HttpRequestConfig>(destination: Destination | DestinationNameAndJwt, requestConfig: T, options?: HttpRequestOptions): Promise<HttpResponse>; /** * Builds an Axios config with default configuration i.e. no_proxy, default http and https agent and GET as request method. * @returns AxiosRequestConfig with default parameters */ export declare function getAxiosConfigWithDefaults(): HttpRequestConfig; export declare function getAxiosConfigWithDefaultsWithoutMethod(): Omit<HttpRequestConfig, 'method'>; export declare function shouldHandleCsrfToken(requestConfig: HttpRequestConfig, options: HttpRequestOptions): boolean; //# sourceMappingURL=http-client.d.ts.map