import { HttpClient, HttpMethod, HttpOptions, HttpRequest } from 'simple-http-request-builder'; import { HttpPromise } from '../promise/HttpPromise'; import { FetchResponseHandler } from '../handler/FetchResponseHandlers'; import { HttpResponse } from './HttpResponse'; /** * A {@link HttpClient} that executes an {@link HttpRequest} * using a timeout specified with {@link HttpRequest#optionValues}. * * Returns the result of the {@link fetch} execution, i.e. a `Promise`. * * @param httpRequest The request to execute */ export declare const fetchClientExecutor: HttpClient>; /** * A {@link HttpClient} that uses: * - {@link fetchClientExecutor} to execute an {@link HttpRequest} * - {@link FetchResponseHandler} handlers to validate and transform the response with {@link processHandlers} * * There are two outcomes for the execution of the {@link HttpRequest}: * - If the execution is successful (an HTTP response has been received), * handlers will be executed and the result of the first handler to return will be returned. * If no handler return a result, the HTTP response parsed body JSON object will be returned. * - Else it means that there is a network issue, * or that the request has been cancelled using the {@link HttpOptions#timeoutAbortController} * (see {@link HttpRequest#optionValues} for details), * or else it means there is a bug in the library... * * @param httpRequest The {@link HttpRequest} to execute * @param handlers The {@link FetchResponseHandler}s to execute on an OK response (status code = 2xx) */ export declare const fetchClient: (httpRequest: HttpRequest, ...handlers: FetchResponseHandler[]) => Promise>; /** * A {@link HttpClient} that uses {@link HttpRequest} and returns a `Promise>`. * * This is used by {@link createHttpFetchRequest} to make fetch requests. * * Common clients are: * - {@link defaultJsonFetchClient} for REST JSON API * - raw {@link fetchClient} for non-JSON API (so often just for binary content) */ export type HttpFetchClient = (httpRequest: HttpRequest) => Promise>; /** * Factory function to create fetch {@link HttpRequest}. * * @param baseUrl The base URL. It should not contain an ending slash. A valid base URL is: http://hostname/api * @param method The HTTP method used for the request, see {@link HttpMethod} * @param path The path of the endpoint to call, it should be composed with a leading slash * and will be appended to the {@link HttpRequest#baseUrl}. A valid path is: /users * @param httpClient The fetch client that uses {@link HttpRequest} and returns a `Promise>` * @param options Optional options to configure the request */ export declare const createHttpFetchRequest: (baseUrl: string, method: HttpMethod, path: string, httpClient: HttpFetchClient, options?: Partial) => HttpRequest>;