import type { RefreshErrorCode } from "./ConfigServiceBase.js"; import type { ProjectConfig } from "./ProjectConfig.js"; import type { Message } from "./Utils.js"; export declare enum FetchStatus { Fetched = 0, NotModified = 1, Errored = 2 } export type FetchResult = { readonly config: ProjectConfig; } & ({ readonly status: FetchStatus.Fetched | FetchStatus.NotModified; readonly errorCode: RefreshErrorCode.None; readonly errorMessage?: undefined; readonly errorException?: undefined; } | { readonly status: FetchStatus.Errored; readonly errorCode: Exclude; readonly errorMessage: Message; readonly errorException?: any; }); export declare function fetchResultFromSuccess(config: ProjectConfig): FetchResult; export declare function fetchResultFromNotModified(config: ProjectConfig): FetchResult; export declare function fetchResultFromError(config: ProjectConfig, errorCode: Exclude, errorMessage: Message, errorException?: any): FetchResult; /** The request parameters for a ConfigCat config fetch operation. */ export declare class FetchRequest { /** The URL of the config. */ readonly url: string; /** * The value of the `ETag` HTTP response header received during the last successful request (if any). * If available, should be included in the HTTP request, either in the `If-None-Match` header or in the `ccetag` query string parameter. * * @remarks In browser runtime environments the `If-None-Match` header should be avoided because that may cause unnecessary CORS preflight requests. */ readonly lastETag: string | undefined; /** Additional HTTP request headers. Should be included in every HTTP request. */ readonly headers: ReadonlyArray; /** The request timeout to apply, configured via `IOptions.requestTimeoutMs`. */ readonly timeoutMs: number; constructor( /** The URL of the config. */ url: string, /** * The value of the `ETag` HTTP response header received during the last successful request (if any). * If available, should be included in the HTTP request, either in the `If-None-Match` header or in the `ccetag` query string parameter. * * @remarks In browser runtime environments the `If-None-Match` header should be avoided because that may cause unnecessary CORS preflight requests. */ lastETag: string | undefined, /** Additional HTTP request headers. Should be included in every HTTP request. */ headers: ReadonlyArray, /** The request timeout to apply, configured via `IOptions.requestTimeoutMs`. */ timeoutMs: number); } /** The response data of a ConfigCat config fetch operation. */ export declare class FetchResponse { /** The HTTP status code. */ readonly statusCode: number; /** The HTTP reason phrase. */ readonly reasonPhrase: string; /** The response body. */ readonly body?: string | undefined; /** The value of the `ETag` HTTP response header. */ readonly eTag?: string; private readonly rayId?; constructor( /** The HTTP status code. */ statusCode: number, /** The HTTP reason phrase. */ reasonPhrase: string, /** The HTTP response headers. */ headers: ReadonlyArray, /** The response body. */ body?: string | undefined); } export type FetchErrorCauses = { abort: []; timeout: [timeoutMs: number]; failure: [err?: any]; }; export declare class FetchError extends Error { cause: TCause; readonly name: string; readonly args: FetchErrorCauses[TCause]; constructor(cause: TCause, ...args: FetchErrorCauses[TCause]); } /** Defines the interface used by the ConfigCat SDK to perform ConfigCat config fetch operations. */ export interface IConfigCatConfigFetcher { /** * Fetches the JSON content of the requested config asynchronously. * @param request The fetch request. * @returns A promise that fulfills with the fetch response. * @throws {FetchErrorException} The fetch operation failed. */ fetchAsync(request: FetchRequest): Promise; }