import type { LoggerWrapper } from "./ConfigCatLogger.js"; import type { RefreshErrorCode } from "./ConfigServiceBase.js"; import type { ProjectConfig } from "./ProjectConfig.js"; import type { Message } from "./Utils.js"; export declare const USER_AGENT_HEADER_NAME = "User-Agent"; export declare const CONFIGCAT_USER_AGENT_HEADER_NAME = "X-ConfigCat-UserAgent"; export declare const SDK_QUERYPARAM_NAME = "sdk"; export declare const ETAG_QUERYPARAM_NAME = "ccetag"; 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; private readonly _guard; 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); isExpected(): boolean; } export type FetchErrorCauses = { abort: []; timeout: [timeoutMs: number]; failure: [err?: any]; }; type FetchErrorArgsInternal = [...FetchErrorCauses[TCause], /* rayId: */ string?]; export type FetchErrorCtorInternal = new (cause: TCause, ...args: FetchErrorArgsInternal) => FetchError; export declare class FetchError extends Error { cause: TCause; readonly name: string; readonly args: FetchErrorCauses[TCause]; private readonly rayId; 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; dispose?(): void; } export declare function getRequestHeaders(clientVersion: string): [string, string][]; export declare function adjustUrlForBrowser(url: string, request: FetchRequest): string; export declare const fetchInternalAsyncMethodName = "fetchInternalAsync"; export type FetchInternalAsyncMethod = (this: TFetcher, request: FetchRequest, logger?: LoggerWrapper) => Promise; export declare const FETCH_RETRY_LIMIT = 1; export declare const FETCH_RETRY_DELAY_MS = 50; export declare const CONNECTIONPOOL_RESET_THRESHOLD_MS = 30000; export declare const REQUEST_ID_ARG_NAME = "REQUEST_ID"; export {};