UNPKG

featurehub-javascript-client-sdk

Version:
62 lines (61 loc) 3.1 kB
import { InternalFeatureRepository } from './internal_feature_repository'; import { EdgeServiceSupplier, FeatureHubConfig } from './feature_hub_config'; import { StrategyAttributeCountryName, StrategyAttributeDeviceName, StrategyAttributePlatformName } from './models'; import { FeatureStateHolder } from './feature_state'; import { EdgeService } from './edge_service'; import { FeatureHubRepository } from './featurehub_repository'; import { ClientContext } from './client_context'; export declare abstract class BaseClientContext implements ClientContext { protected readonly _repository: InternalFeatureRepository; protected _attributes: Map<string, string[]>; protected constructor(repository: InternalFeatureRepository); userKey(value: string): ClientContext; sessionKey(value: string): ClientContext; country(value: StrategyAttributeCountryName): ClientContext; device(value: StrategyAttributeDeviceName): ClientContext; platform(value: StrategyAttributePlatformName): ClientContext; version(version: string): ClientContext; attribute_value(key: string, value: string): ClientContext; attributeValue(key: string, value: string): ClientContext; attribute_values(key: string, values: Array<string>): ClientContext; attributeValues(key: string, values: Array<string>): ClientContext; clear(): ClientContext; getAttr(key: string, defaultValue?: string): string | undefined; getAttrs(key: string): Array<string>; defaultPercentageKey(): string | undefined; isEnabled(name: string): boolean; isSet(name: string): boolean; getNumber(name: string, def?: number): number | undefined; getString(name: string, def?: string): string | undefined; getJson(name: string, def?: any): any | undefined; getRawJson(name: string, def?: string): string | undefined; getFlag(name: string, def?: boolean): boolean | undefined; getBoolean(name: string, def?: boolean): boolean | undefined; abstract build(): Promise<ClientContext>; abstract feature(name: string): FeatureStateHolder; abstract close(): void; repository(): FeatureHubRepository; logAnalyticsEvent(action: string, other?: Map<string, string>, user?: string): void; } export declare class ServerEvalFeatureContext extends BaseClientContext { private readonly _edgeServiceSupplier; private _currentEdge; private _config?; private _xHeader; private _clientCount; constructor(repository: InternalFeatureRepository, edgeServiceSupplier: EdgeServiceSupplier, config?: FeatureHubConfig); addClient(): void; removeClient(): boolean; build(): Promise<ClientContext>; close(): void; edgeService(): EdgeService | undefined; feature(name: string): FeatureStateHolder; } export declare class ClientEvalFeatureContext extends BaseClientContext { private readonly _edgeService; constructor(repository: InternalFeatureRepository, edgeService: EdgeService); build(): Promise<ClientContext>; close(): void; edgeService(): EdgeService; feature(name: string): FeatureStateHolder; }