import type { IConfigCache, IConfigCatCache } from "./ConfigCatCache.js"; import type { IConfigCatLogger, LogFilterCallback } from "./ConfigCatLogger.js"; import { LoggerWrapper } from "./ConfigCatLogger.js"; import type { IConfigCatConfigFetcher } from "./ConfigFetcher.js"; import type { IConfigService } from "./ConfigServiceBase.js"; import type { IEventEmitter } from "./EventEmitter.js"; import type { FlagOverrides } from "./FlagOverrides.js"; import type { IProvidesHooks, SafeHooksWrapper } from "./Hooks.js"; import { Hooks } from "./Hooks.js"; import type { IUser } from "./User.js"; export declare const PROXY_SDKKEY_PREFIX = "configcat-proxy/"; /** Specifies the supported polling modes. */ export declare enum PollingMode { /** The ConfigCat SDK downloads the latest config data automatically and stores it in the cache. */ AutoPoll = 0, /** The ConfigCat SDK downloads the latest config data only if it is not present in the cache, or if it is but has expired. */ LazyLoad = 1, /** The ConfigCat SDK will not download the config data automatically. You need to update the cache manually, by calling `forceRefreshAsync()`. */ ManualPoll = 2 } /** Controls the location of the config JSON files containing your feature flags and settings within the ConfigCat CDN. */ export declare enum DataGovernance { /** Choose this option if your config JSON files are published to all global CDN nodes. */ Global = 0, /** Choose this option if your config JSON files are published to CDN nodes only in the EU. */ EuOnly = 1 } /** Options used to configure the ConfigCat SDK. */ export interface IOptions { /** * An optional callback that can be used to filter log events beyond the minimum log level setting * (see `IConfigCatLogger.level` and `createConsoleLogger`). */ logFilter?: LogFilterCallback | null; /** * The logger implementation to use for performing logging. * * If not set, `ConfigCatConsoleLogger` with `LogLevel.Warn` will be used by default. * If you want to use custom logging instead, you can provide an implementation of `IConfigCatLogger`. */ logger?: IConfigCatLogger | null; /** Timeout (in milliseconds) for underlying HTTP calls. Defaults to 30 seconds. */ requestTimeoutMs?: number | null; /** * The base URL of the remote server providing the latest version of the config. * Defaults to the URL of the ConfigCat CDN. * * If you want to use a proxy server between your application and ConfigCat, you need to set this property to the proxy URL. */ baseUrl?: string | null; /** * Set this property to be in sync with the Data Governance preference on the Dashboard: * https://app.configcat.com/organization/data-governance (only Organization Admins have access). * Defaults to `DataGovernance.Global`. */ dataGovernance?: DataGovernance | null; /** * The cache implementation to use for storing and retrieving downloaded config data. * * If not set, a default implementation will be used (depending on the platform). * If you want to use custom caching instead, you can provide an implementation of `IConfigCatCache`. */ cache?: IConfigCatCache | null; /** * The config fetcher implementation to use for performing ConfigCat config fetch operations. * * If not set, a default implementation will be used depending on the current platform. * If you want to use custom a config fetcher, you can provide an implementation of `IConfigCatConfigFetcher`. * * @remarks Implementing a config fetcher that makes HTTP requests to the ConfigCat CDN is tricky, especially when the * SDK runs in a browser. Therefore, please **avoid writing actual config fetcher implementations from scratch** * unless absolutely necessary and you know exactly what you are doing. (Writing mock implementations for testing * purposes is fine, of course.) * * If you use the SDK with a {@link https://configcat.com/docs/advanced/proxy/proxy-overview/ | proxy } and need to set * custom HTTP request headers, you can subclass the built-in config fetcher implementations (e.g. FetchApiConfigFetcher) * and override the `setRequestHeaders` method. */ configFetcher?: IConfigCatConfigFetcher | null; /** The flag override to use. If not set, no flag override will be used. */ flagOverrides?: FlagOverrides | null; /** * The default user, used as fallback when there's no user parameter is passed to the setting evaluation methods like * `IConfigCatClient.getValueAsync`, `ConfigCatClient.getValueAsync`, etc. */ defaultUser?: IUser | null; /** * Indicates whether the client should be initialized to offline mode or not. Defaults to `false`. */ offline?: boolean | null; /** Provides an opportunity to add listeners to client hooks (events) at client initalization time. */ setupHooks?: (hooks: IProvidesHooks) => void; } /** Options used to configure the ConfigCat SDK in the case of Auto Polling mode. */ export interface IAutoPollOptions extends IOptions { /** * Config refresh interval. * Specifies how frequently the internally cached config will be updated by synchronizing with * the external cache and/or by fetching the latest version from the ConfigCat CDN. * * Default value is 60 seconds. Minimum value is 1 second. Maximum value is 2147483 seconds. */ pollIntervalSeconds?: number; /** * Maximum waiting time before reporting the ready state, i.e. emitting the `clientReady` event. * * Default value is 5 seconds. Maximum value is 2147483 seconds. Negative values mean infinite waiting. */ maxInitWaitTimeSeconds?: number; } /** Options used to configure the ConfigCat SDK in the case of Manual Polling mode. */ export interface IManualPollOptions extends IOptions { } /** Options used to configure the ConfigCat SDK in the case of Lazy Loading mode. */ export interface ILazyLoadingOptions extends IOptions { /** * Cache time to live value. * Specifies how long the cached config can be used before updating it again * by fetching the latest version from the ConfigCat CDN. * * Default value is 60 seconds. Minimum value is 1 second. Maximum value is 2147483647 seconds. */ cacheTimeToLiveSeconds?: number; } export type OptionsForPollingMode = TMode extends PollingMode.AutoPoll ? IAutoPollOptions : TMode extends PollingMode.ManualPoll ? IManualPollOptions : TMode extends PollingMode.LazyLoad ? ILazyLoadingOptions : TMode extends undefined ? IAutoPollOptions : never; export interface IConfigCatKernel { sdkType: string; sdkVersion: string; eventEmitterFactory: (() => IEventEmitter) | null | undefined; defaultCacheFactory: ((options: OptionsBase) => IConfigCache) | null | undefined; configFetcherFactory: (options: OptionsBase) => IConfigCatConfigFetcher; } export declare abstract class OptionsBase { private static readonly configFileName; logger: LoggerWrapper; sdkKey: string; clientVersion: string; requestTimeoutMs: number; baseUrl: string; baseUrlOverriden: boolean; dataGovernance: DataGovernance; cache: IConfigCache; configFetcher: IConfigCatConfigFetcher; flagOverrides: FlagOverrides | null; defaultUser: IUser | undefined; offline: boolean; hooks: SafeHooksWrapper; constructor(sdkKey: string, kernel: IConfigCatKernel, clientVersion: string, options?: IOptions | null); yieldHooks(): Hooks; getUrl(): string; getCacheKey(): string; abstract createConfigService(): IConfigService; } export declare function isCdnUrl(url: string): boolean; export declare class AutoPollOptions extends OptionsBase { pollIntervalSeconds: number; maxInitWaitTimeSeconds: number; constructor(sdkKey: string, kernel: IConfigCatKernel, options?: IAutoPollOptions | null); createConfigService(): IConfigService; } export declare class ManualPollOptions extends OptionsBase { constructor(sdkKey: string, kernel: IConfigCatKernel, options?: IManualPollOptions | null); createConfigService(): IConfigService; } export declare class LazyLoadOptions extends OptionsBase { cacheTimeToLiveSeconds: number; constructor(sdkKey: string, kernel: IConfigCatKernel, options?: ILazyLoadingOptions | null); createConfigService(): IConfigService; } export type ConfigCatClientOptions = AutoPollOptions | ManualPollOptions | LazyLoadOptions;