import type { OptionsBase } from "./ConfigCatClientOptions.js"; import type { FetchResult, IConfigCatConfigFetcher } from "./ConfigFetcher.js"; import { ProjectConfig } from "./ProjectConfig.js"; import type { Message, PickWithType } from "./Utils.js"; /** Specifies the possible config data refresh error codes. */ export declare enum RefreshErrorCode { /** An unexpected error occurred during the refresh operation. */ UnexpectedError = -1, /** No error occurred (the refresh operation was successful). */ None = 0, /** * The refresh operation failed because the client is configured to use the `OverrideBehaviour.LocalOnly` override behavior, * which prevents synchronization with the external cache and making HTTP requests. */ LocalOnlyClient = 1, /** The refresh operation failed because the client is in offline mode, it cannot initiate HTTP requests. */ OfflineClient = 3200, /** The refresh operation failed because a HTTP response indicating an invalid SDK Key was received (403 Forbidden or 404 Not Found). */ InvalidSdkKey = 1100, /** The refresh operation failed because an invalid HTTP response was received (unexpected HTTP status code). */ UnexpectedHttpResponse = 1101, /** The refresh operation failed because the HTTP request timed out. */ HttpRequestTimeout = 1102, /** The refresh operation failed because the HTTP request failed (most likely, due to a local network issue). */ HttpRequestFailure = 1103, /** The refresh operation failed because an invalid HTTP response was received (200 OK with an invalid content). */ InvalidHttpResponseContent = 1105, /** The refresh operation failed because an invalid HTTP response was received (304 Not Modified when no config JSON was cached locally). */ InvalidHttpResponseWhenLocalCacheIsEmpty = 1106 } /** Contains the result of an `IConfigCatClient.forceRefreshAsync` operation. */ type RefreshResultProps = { /** Indicates whether the operation was successful or not. */ readonly isSuccess: boolean; /** The code identifying the reason for the error in case the operation failed. */ readonly errorCode: RefreshErrorCode; /** Error message in case the operation failed. */ readonly errorMessage?: string; /** The exception object related to the error in case the operation failed (if any). */ readonly errorException?: undefined; }; export type RefreshResult = RefreshResultProps & (PickWithType | PickWithType; errorMessage: string; errorException?: any; }>); export declare function refreshResultFromSuccess(): RefreshResult; export declare function refreshResultFromFailure(errorCode: Exclude, errorMessage: Message, errorException?: any): RefreshResult; export declare function refreshResultFromFetchResult(fetchResult: FetchResult): RefreshResult; /** Specifies the possible states of the internal cache. */ export declare enum ClientCacheState { /** No config data is available in the internal cache. */ NoFlagData = 0, /** Only config data provided by local flag override is available in the internal cache. */ HasLocalOverrideFlagDataOnly = 1, /** Only expired config data obtained from the external cache or the ConfigCat CDN is available in the internal cache. */ HasCachedFlagDataOnly = 2, /** Up-to-date config data obtained from the external cache or the ConfigCat CDN is available in the internal cache. */ HasUpToDateFlagData = 3 } export interface IConfigService { readonly readyPromise: Promise; getConfigAsync(): Promise; refreshConfigAsync(): Promise<[RefreshResult, ProjectConfig]>; readonly isOffline: boolean; setOnline(): void; setOffline(): void; getCacheState(cachedConfig: ProjectConfig): ClientCacheState; dispose(): void; } export declare abstract class ConfigServiceBase { protected readonly options: TOptions; private status; private pendingCacheSyncUp; private pendingConfigRefresh; protected readonly cacheKey: string; protected readonly configFetcher: IConfigCatConfigFetcher; private readonly requestHeaders; abstract readonly readyPromise: Promise; constructor(options: TOptions); protected prepareClientForEvents(): void; dispose(): void; protected get disposed(): boolean; abstract getConfigAsync(): Promise; refreshConfigAsync(): Promise<[RefreshResult, ProjectConfig]>; protected refreshConfigCoreAsync(latestConfig: ProjectConfig, isInitiatedByUser: boolean): Promise<[FetchResult, ProjectConfig]>; protected onConfigFetched(fetchResult: FetchResult, isInitiatedByUser: boolean): void; protected onConfigChanged(newConfig: ProjectConfig): void; private fetchAsync; private fetchRequestAsync; protected get isOfflineExactly(): boolean; get isOffline(): boolean; protected goOnline(): void; setOnline(): void; setOffline(): void; abstract getCacheState(cachedConfig: ProjectConfig): ClientCacheState; protected syncUpWithCache(): ProjectConfig | Promise; private onCacheSynced; protected waitForReadyAsync(initialCacheSyncUp: ProjectConfig | Promise): Promise; protected getReadyPromise(initialCacheSyncUp: ProjectConfig | Promise): Promise; } export {};