configcat-common
Version:
ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.
69 lines • 3.33 kB
TypeScript
import type { OptionsBase } from "./ConfigCatClientOptions";
import type { IConfigFetcher } from "./ConfigFetcher";
import { FetchResult } from "./ConfigFetcher";
import { ProjectConfig } from "./ProjectConfig";
/** Contains the result of an `IConfigCatClient.forceRefresh` or `IConfigCatClient.forceRefreshAsync` operation. */
export declare class RefreshResult {
/** Error message in case the operation failed, otherwise `null`. */
errorMessage: string | null;
/** The exception object related to the error in case the operation failed (if any). */
errorException?: any;
constructor(
/** Error message in case the operation failed, otherwise `null`. */
errorMessage: string | null,
/** The exception object related to the error in case the operation failed (if any). */
errorException?: any);
/** Indicates whether the operation was successful or not. */
get isSuccess(): boolean;
static from(fetchResult: FetchResult): RefreshResult;
/** Creates an instance of the `RefreshResult` class which indicates that the operation was successful. */
static success(): RefreshResult;
/** Creates an instance of the `RefreshResult` class which indicates that the operation failed. */
static failure(errorMessage: string, errorException?: any): RefreshResult;
}
/** Specifies the possible states of the local cache. */
export declare enum ClientCacheState {
NoFlagData = 0,
HasLocalOverrideFlagDataOnly = 1,
HasCachedFlagDataOnly = 2,
HasUpToDateFlagData = 3
}
export interface IConfigService {
readonly readyPromise: Promise<ClientCacheState>;
getConfig(): Promise<ProjectConfig>;
refreshConfigAsync(): Promise<[RefreshResult, ProjectConfig]>;
readonly isOffline: boolean;
setOnline(): void;
setOffline(): void;
getCacheState(cachedConfig: ProjectConfig): ClientCacheState;
dispose(): void;
}
export declare abstract class ConfigServiceBase<TOptions extends OptionsBase> {
protected readonly configFetcher: IConfigFetcher;
protected readonly options: TOptions;
private status;
private pendingFetch;
protected readonly cacheKey: string;
abstract readonly readyPromise: Promise<ClientCacheState>;
constructor(configFetcher: IConfigFetcher, options: TOptions);
dispose(): void;
protected get disposed(): boolean;
abstract getConfig(): Promise<ProjectConfig>;
refreshConfigAsync(): Promise<[RefreshResult, ProjectConfig]>;
protected refreshConfigCoreAsync(latestConfig: ProjectConfig): Promise<[FetchResult, ProjectConfig]>;
protected onConfigFetched(newConfig: ProjectConfig): void;
protected onConfigChanged(newConfig: ProjectConfig): void;
private fetchAsync;
private fetchLogicAsync;
private fetchRequestAsync;
protected get isOfflineExactly(): boolean;
get isOffline(): boolean;
protected setOnlineCore(): void;
setOnline(): void;
protected setOfflineCore(): void;
setOffline(): void;
abstract getCacheState(cachedConfig: ProjectConfig): ClientCacheState;
protected syncUpWithCache(): ProjectConfig | Promise<ProjectConfig>;
protected getReadyPromise<TState>(state: TState, waitForReadyAsync: (state: TState) => Promise<ClientCacheState>): Promise<ClientCacheState>;
}
//# sourceMappingURL=ConfigServiceBase.d.ts.map