import { ServiceKey, type ServiceScope } from '@microsoft/sp-core-library'; import type { IHttpClientConfigurations } from './HttpClientConfiguration'; import type HttpClientConfiguration from './HttpClientConfiguration'; import HttpClientResponse from './HttpClientResponse'; import type { IRequestCacheOptions, IHttpRequestCacheOptions } from '../caching/IRequestCacheOptions'; import type { IClientCachableResponse } from '../caching/IClientCachableResponse'; import type { IAuthenticationScheme } from '../oauthTokenProvider/ITokenProvider'; /** * HttpClient implements a basic set of features for performing REST operations against * a generic service. * * @remarks * For communicating with SharePoint, use the {@link SPHttpClient} class instead. * * @public */ export default class HttpClient { /** * The standard predefined HttpClientConfiguration objects for use with * the HttpClient class. */ static readonly configurations: IHttpClientConfigurations; /** * The service key for HttpClient. * * @public */ static readonly serviceKey: ServiceKey; private static readonly _className; /** * Service scope used to construct the HttpClient. * @internal */ private _serviceScope; private _fetchProvider; private _cacheProvider; /** * Starts a fixed 1-second tracking window for the given manifest ID. After 1 second, * if the request count exceeds the threshold, the result is written to localStorage * and the entry is cleared. * * @param manifestId - The component manifest ID (GUID) to track * @param instanceId - The instance ID to track * @internal */ static startTrackingWindow(manifestId: string, instanceId: string): void; constructor(serviceScope: ServiceScope); /** * Performs a REST service call. * * @remarks * Although the SPHttpClient subclass adds additional enhancements, the parameters and semantics * for HttpClient.fetch() are essentially the same as the WHATWG API standard that is documented here: * https://fetch.spec.whatwg.org/ * * @param url - the URL to fetch * @param configuration - determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations * @param options - additional options that affect the request * @returns A promise with behavior similar to WHATWG fetch(). This promise will resolve normally * (with {@link HttpClientResponse.ok} being false) for error status codes such as HTTP 404 * or 500. The promise will only reject for network failures or other errors that prevent communication * with the server. * * @public */ fetch(url: string, configuration: HttpClientConfiguration, options: IHttpClientOptions): Promise; /** * Performs a REST service call. * * @remarks * Although the SPHttpClient subclass adds additional enhancements, the parameters and semantics * for HttpClient.fetch() are essentially the same as the WHATWG API standard that is documented here: * https://fetch.spec.whatwg.org/ * * @param url - the URL to fetch * @param configuration - determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations * @param options - additional options that affect the request * @param cacheConfiguration - determines the configuration for cache management of this request * @returns A promise containing a IClientCachableResponse, which contains a * Promise to the cached data response and a Promise to the server response * * @internal */ fetch(url: string, configuration: HttpClientConfiguration, options: IHttpClientOptions, cacheConfiguration: IRequestCacheOptions): Promise>; /** * Performs a REST service call. * * @remarks * Although the SPHttpClient subclass adds additional enhancements, the parameters and semantics * for HttpClient.fetch() are essentially the same as the WHATWG API standard that is documented here: * https://fetch.spec.whatwg.org/ * * @param url - the URL to fetch * @param configuration - determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations * @param options - additional options that affect the request * @param cacheConfiguration - determines the configuration for cache management of this request * @returns A Promise to the cached data response or a Promise to the server response * * @internal */ fetch(url: string, configuration: HttpClientConfiguration, options: IHttpClientOptions, cacheConfiguration: IHttpRequestCacheOptions): Promise; /** * Calls fetch(), but sets the method to "GET". * * @param url - the URL to fetch * @param configuration - determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations * @param options - additional options that affect the request * @returns A promise with behavior similar to WHATWG fetch(). This promise will resolve normally * (with {@link HttpClientResponse.ok} being false) for error status codes such as HTTP 404 * or 500. The promise will only reject for network failures or other errors that prevent communication * with the server. * * @public */ get(url: string, configuration: HttpClientConfiguration, options?: IHttpClientOptions): Promise; /** * Calls fetch(), but sets the method to "GET". * * @param url - the URL to fetch * @param configuration - determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations * @param options - additional options that affect the request * @param cacheConfiguration - determines the configuration for cache management of this request * @returns A promise containing a IClientCachableResponse, which contains a * Promise to the cached data response and a Promise to the server response * * @internal */ get(url: string, configuration: HttpClientConfiguration, options: IHttpClientOptions | undefined, cacheConfiguration: IRequestCacheOptions): Promise>; /** * Calls fetch(), but sets the method to "GET". * * @param url - the URL to fetch * @param configuration - determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations * @param options - additional options that affect the request * @param cacheConfiguration - determines the configuration for cache management of this request * @returns A Promise to the cached data response or a Promise to the server response * * @internal */ get(url: string, configuration: HttpClientConfiguration, options: IHttpClientOptions | undefined, cacheConfiguration: IHttpRequestCacheOptions): Promise; /** * Calls fetch(), but sets the method to "POST". * * @param url - the URL to fetch * @param configuration - determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations * @param options - additional options that affect the request * @returns A promise with behavior similar to WHATWG fetch(). This promise will resolve normally * (with {@link HttpClientResponse.ok} being false) for error status codes such as HTTP 404 * or 500. The promise will only reject for network failures or other errors that prevent communication * with the server. */ post(url: string, configuration: HttpClientConfiguration, options: IHttpClientOptions): Promise; private _fetch; /** * Gets the cache data provider */ private get _cacheDataProvider(); } /** * Options for HttpClient * * @remarks * This interface defines the options for the HttpClient operations such as * get(), post(), fetch(), etc. It is based on the whatwg API standard * parameters that are documented here: * https://fetch.spec.whatwg.org/ * * @public */ export interface IHttpClientOptions extends RequestInit { /** * Indicates whether acquire a Bearer or PoP * By defalut authenticationScheme is Bearer. * * @internal */ _authenticationScheme?: IAuthenticationScheme; /** * A stringified JSON object containing custom client claims * * @internal */ _resourceRequestMethod?: string; /** * A stringified JSON object containing custom client claims * * @internal */ _shrClaims?: string; } //# sourceMappingURL=HttpClient.d.ts.map