1 | import { AxiosRequestConfig } from 'axios';
|
2 | import { Destination, DestinationNameAndJwt } from '../connectivity/scp-cf';
|
3 | import { DestinationHttpRequestConfig, ExecuteHttpRequestFn, HttpRequestConfig, HttpRequestOptions, HttpResponse } from './http-client-types';
|
4 | /**
|
5 | * Builds a [[DestinationHttpRequestConfig]] for the given destination.
|
6 | * If a destination name (and a JWT) are provided, it will try to resolve the destination.
|
7 | * @param destination - A destination or a destination name and a JWT.
|
8 | * @param customHeaders - Custom default headers for the resulting HTTP request.
|
9 | * @returns A [[DestinationHttpRequestConfig]].
|
10 | */
|
11 | export declare function buildHttpRequest(destination: Destination | DestinationNameAndJwt, customHeaders?: Record<string, any>): Promise<DestinationHttpRequestConfig>;
|
12 | /**
|
13 | * Builds a [[DestinationHttpRequestConfig]] for the given destination
|
14 | * and then merges it into the given request configuration.
|
15 | * Setting of the given request configuration take precedence over any destination related configuration.
|
16 | * @param destination - A destination or a destination name and a JWT.
|
17 | * @param requestConfig - Any object representing an HTTP request.
|
18 | * @returns The given request config merged with the config built for the given destination.
|
19 | */
|
20 | export declare function addDestinationToRequestConfig<T extends HttpRequestConfig>(destination: Destination | DestinationNameAndJwt, requestConfig: T): Promise<T & DestinationHttpRequestConfig>;
|
21 | /**
|
22 | * Takes as parameter a function that expects an [[HttpRequest]] and returns a Promise of [[HttpResponse]].
|
23 | * Returns a function that takes a destination and a request-config (extends [[HttpRequestConfig]]), builds an [[HttpRequest]] from them, and calls
|
24 | * the provided execute function.
|
25 | *
|
26 | * NOTE: If you simply want to execute a request without passing your own execute function, use [[executeHttpRequest]] instead.
|
27 | * @param executeFn - A function that can execute an [[HttpRequestConfig]].
|
28 | * @returns A function expecting destination and a request.
|
29 | */
|
30 | export declare function execute<ReturnT>(executeFn: ExecuteHttpRequestFn<ReturnT>): <T extends HttpRequestConfig>(destination: Destination | DestinationNameAndJwt, requestConfig: T, options?: HttpRequestOptions | undefined) => Promise<ReturnT>;
|
31 | /**
|
32 | *
|
33 | * @experimental This API is experimental and might change in newer versions. Use with caution.
|
34 | * @param destination - A destination or a destination name and a JWT.
|
35 | * @param requestConfig - Any object representing an HTTP request.
|
36 | */
|
37 | export declare function buildAxiosRequestConfig<T extends HttpRequestConfig>(destination: Destination | DestinationNameAndJwt, requestConfig?: Partial<T>): Promise<AxiosRequestConfig>;
|
38 | /**
|
39 | * Builds a [[DestinationHttpRequestConfig]] for the given destination, merges it into the given requestConfig
|
40 | * and executes it (using Axios).
|
41 | * @param destination - A destination or a destination name and a JWT.
|
42 | * @param requestConfig - Any object representing an HTTP request.
|
43 | * @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.
|
44 | * @returns A promise resolving to an [[HttpResponse]].
|
45 | */
|
46 | export declare function executeHttpRequest<T extends HttpRequestConfig>(destination: Destination | DestinationNameAndJwt, requestConfig: T, options?: HttpRequestOptions): Promise<HttpResponse>;
|
47 | /**
|
48 | * Builds an Axios config with default configuration i.e. no_proxy, default http and https agent and GET as request method.
|
49 | * @returns AxiosRequestConfig with default parameters
|
50 | */
|
51 | export declare function getAxiosConfigWithDefaults(): HttpRequestConfig;
|
52 | export declare function getAxiosConfigWithDefaultsWithoutMethod(): Omit<HttpRequestConfig, 'method'>;
|
53 | export declare function shouldHandleCsrfToken(requestConfig: HttpRequestConfig, options: HttpRequestOptions): boolean;
|
54 | //# sourceMappingURL=http-client.d.ts.map |
\ | No newline at end of file |