UNPKG

featurehub-repository

Version:

Core package of API that exposes FeatureHub feature flags, values and configuration to client applications written in Typescript or Javascript.

78 lines (77 loc) 3.6 kB
import { FeatureStateValueInterceptor, InterceptorValueMatch } from './interceptors'; import { FeatureStateHolder } from './feature_state'; import { AnalyticsCollector } from './analytics'; import { RolloutStrategy, SSEResultState } from './models'; import { ClientContext } from './client_context'; import { ApplyFeature, Applied } from './strategy_matcher'; import { InternalFeatureRepository } from './internal_feature_repository'; export declare enum Readyness { NotReady = "NotReady", Ready = "Ready", Failed = "Failed" } export interface ReadynessListener { (state: Readyness): void; } export interface PostLoadNewFeatureStateAvailableListener { (repo: ClientFeatureRepository): void; } export interface FeatureHubRepository { readyness: Readyness; catchAndReleaseMode: boolean; logAnalyticsEvent(action: string, other?: Map<string, string>, ctx?: ClientContext): any; hasFeature(key: string): FeatureStateHolder; feature(key: string): FeatureStateHolder; getFeatureState(key: string): FeatureStateHolder; release(disableCatchAndRelease?: boolean): Promise<void>; simpleFeatures(): Map<string, string | undefined>; getFlag(key: string): boolean | undefined; getString(key: string): string | undefined; getJson(key: string): string | undefined; getNumber(key: string): number | undefined; isSet(key: string): boolean; addValueInterceptor(interceptor: FeatureStateValueInterceptor): any; addReadynessListener(listener: ReadynessListener): any; addAnalyticCollector(collector: AnalyticsCollector): void; addPostLoadNewFeatureStateAvailableListener(listener: PostLoadNewFeatureStateAvailableListener): any; } export declare class ClientFeatureRepository implements InternalFeatureRepository { private hasReceivedInitialState; private features; private analyticsCollectors; private readynessState; private readynessListeners; private _catchAndReleaseMode; private _catchReleaseStates; private _newFeatureStateAvailableListeners; private _matchers; private readonly _applyFeature; constructor(applyFeature?: ApplyFeature); apply(strategies: Array<RolloutStrategy>, key: string, featureValueId: string, context: ClientContext): Applied; get readyness(): Readyness; notify(state: SSEResultState, data: any): void; addValueInterceptor(matcher: FeatureStateValueInterceptor): void; valueInterceptorMatched(key: string): InterceptorValueMatch; addPostLoadNewFeatureStateAvailableListener(listener: PostLoadNewFeatureStateAvailableListener): void; addReadynessListener(listener: ReadynessListener): void; notReady(): void; broadcastReadynessState(): Promise<void>; addAnalyticCollector(collector: AnalyticsCollector): void; simpleFeatures(): Map<string, string | undefined>; logAnalyticsEvent(action: string, other?: Map<string, string>, ctx?: ClientContext): Promise<void>; hasFeature(key: string): FeatureStateHolder; feature(key: string): FeatureStateHolder; getFeatureState(key: string): FeatureStateHolder; get catchAndReleaseMode(): boolean; set catchAndReleaseMode(value: boolean); release(disableCatchAndRelease?: boolean): Promise<void>; getFlag(key: string): boolean | undefined; getString(key: string): string | undefined; getJson(key: string): string | undefined; getNumber(key: string): number | undefined; isSet(key: string): boolean; private _catchUpdatedFeatures; private triggerNewStateAvailable; private featureUpdate; private deleteFeature; }