type Duration$1 = { seconds: number; ms: number; }; type ConfigEvaluationMetadata = { configRowIndex: number; conditionalValueIndex: number; type: string; configId: string; }; type ConfigEvaluationCounter = Omit & { selectedValue: any; count: number; }; type ConfigEvaluationSummary = { key: string; type: string; counters: ConfigEvaluationCounter[]; }; type ConfigEvaluationSummaries = { start: number; end: number; summaries: ConfigEvaluationSummary[]; }; type LoggerCounter = { loggerName: string; traces: number; debugs: number; infos: number; warns: number; errors: number; fatals: number; }; type LoggersTelemetryEvent = { startAt: number; endAt: number; loggers: LoggerCounter[]; }; type TelemetryEvent = { loggers: LoggersTelemetryEvent; } | { summaries: ConfigEvaluationSummaries; }; type TelemetryEvents = { instanceHash: string; events: TelemetryEvent[]; }; interface FrontEndConfigurationRaw { } type TypedFrontEndConfigurationRaw = keyof FrontEndConfigurationRaw extends never ? Record : { [TypedFlagKey in keyof FrontEndConfigurationRaw]: FrontEndConfigurationRaw[TypedFlagKey]; }; type ContextValue = number | string | boolean; type Contexts = { [key: string]: Record; }; declare enum ReforgeLogLevel { Trace = 1, Debug = 2, Info = 3, Warn = 4, Error = 5, Fatal = 6 } interface ShouldLogParams { loggerName: string; desiredLevel: ReforgeLogLevel; defaultLevel: ReforgeLogLevel; get: (key: K) => TypedFrontEndConfigurationRaw[K]; } declare enum LogLevel { TRACE = "TRACE", DEBUG = "DEBUG", INFO = "INFO", WARN = "WARN", ERROR = "ERROR", FATAL = "FATAL" } declare const getLogLevelSeverity: (level: LogLevel) => number; declare const shouldLogAtLevel: (configuredLevel: LogLevel, desiredLevel: LogLevel) => boolean; type RawConfigWithoutTypes = Record; type APIKeyMetadata = { id: string | number; }; type Duration = { definition: string; millis: number; }; interface IntRange { /** if empty treat as Number.MIN_VALUE. Inclusive */ start?: bigint | undefined; /** if empty treat as Number.MAX_VALUE. Exclusive */ end?: bigint | undefined; } declare enum ProvidedSource { EnvVar = "ENV_VAR" } interface Provided { source?: ProvidedSource | undefined; /** eg MY_ENV_VAR */ lookup?: string | undefined; } declare enum SchemaType { UNKNOWN = 0, ZOD = 1, JSON_SCHEMA = 2 } interface Schema { schema: string; schemaType: SchemaType; } interface WeightedValue { /** out of 1000 */ weight: number; value: ConfigValue | undefined; } declare enum LimitResponse_LimitPolicyNames { SecondlyRolling = 1, MinutelyRolling = 3, HourlyRolling = 5, DailyRolling = 7, MonthlyRolling = 8, Infinite = 9, YearlyRolling = 10 } declare enum LimitDefinition_SafetyLevel { L4_BEST_EFFORT = 4, L5_BOMBPROOF = 5 } interface LimitDefinition { policyName: LimitResponse_LimitPolicyNames; limit: number; burst: number; accountId: number; lastModified: number; returnable: boolean; /** [default = L4_BEST_EFFORT]; // Overridable by request */ safetyLevel: LimitDefinition_SafetyLevel; } interface WeightedValues { weightedValues: WeightedValue[]; hashByPropertyName?: string | undefined; } type ConfigValue = { int: number | undefined; } | { string: string | undefined; } | { bytes: Buffer | undefined; } | { double: number | undefined; } | { bool: boolean | undefined; } | { weightedValues?: WeightedValues | undefined; } | { limitDefinition?: LimitDefinition | undefined; } | { logLevel: ReforgeLogLevel | undefined; } | { stringList: string[] | undefined; } | { intRange: IntRange | undefined; } | { provided: Provided | undefined; } | { duration: Duration | undefined; } | { json: string | undefined; } | { schema: Schema | undefined; } | { /** don't log or telemetry this value */ confidential: boolean | undefined; } | { /** key name to decrypt with */ decryptWith: string | undefined; }; type Evaluation = { value: ConfigValue; configEvaluationMetadata: { configRowIndex: string | number; conditionalValueIndex: string | number; weightedValueIndex?: string | number; type: string; valueType: string; id: string; }; }; type EvaluationPayload = { evaluations: { [key: string]: Evaluation; }; apikeyMetadata: APIKeyMetadata; }; declare class Config { key: K; value: TypedFrontEndConfigurationRaw[K]; rawValue: ConfigValue | undefined; type: keyof ConfigValue; configEvaluationMetadata: ConfigEvaluationMetadata | undefined; constructor(key: K, value: TypedFrontEndConfigurationRaw[K], type: keyof ConfigValue, rawValue?: ConfigValue, metadata?: ConfigEvaluationMetadata); static digest(payload: EvaluationPayload | RawConfigWithoutTypes): { [key: string]: Config; }; } declare class Context { contexts: Contexts; constructor(contexts: Contexts); equals(other: Context): boolean; encode(): string; } type CollectContextModeType = "NONE" | "SHAPE_ONLY" | "PERIODIC_EXAMPLE"; type LoaderParams = { sdkKey: string; context: Context; endpoints?: string[] | undefined; timeout?: number; collectContextMode?: CollectContextModeType; clientVersion?: string; }; type Headers = { [key: string]: string; }; type FetchOptions = { headers: Headers; }; declare class Loader { sdkKey: string; context: Context; endpoints: string[]; timeout: number; abortTimeoutId: ReturnType | undefined; collectContextMode: CollectContextModeType; clientVersion: string; abortController: AbortController | undefined; isAborted: boolean; constructor({ sdkKey, context, endpoints, timeout, collectContextMode, clientVersion, }: LoaderParams); url(root: string): string; loadFromEndpoint(index: number, options: FetchOptions, resolve: (value: any) => void, reject: (value: any) => void): void; load(): Promise; clearAbortTimeout(): void; } type TelemetryUploaderParams = { sdkKey: string; apiEndpoint?: string; timeout?: number; clientVersion: string; }; declare class TelemetryUploader { sdkKey: Required["sdkKey"]; apiEndpoint: Required["apiEndpoint"]; timeout: Required["timeout"]; clientVersion: Required["clientVersion"]; abortTimeoutId: ReturnType | undefined; constructor({ sdkKey, apiEndpoint, timeout, clientVersion, }: TelemetryUploaderParams); clearAbortTimeout(): void; static postUrl(root: string): string; postToEndpoint(options: RequestInit, resolve: (value: unknown) => void, reject: (value: unknown) => void): void; post(data: TelemetryEvents): Promise; } type EvaluationCallback = (key: K, value: TypedFrontEndConfigurationRaw[K], context: Context | undefined) => void; interface ReforgeBootstrap { evaluations: EvaluationPayload; context: Contexts; } type ReforgeInitParams = { sdkKey: string; context: Context; endpoints?: string[] | undefined; apiEndpoint?: string; timeout?: number; afterEvaluationCallback?: EvaluationCallback; collectEvaluationSummaries?: boolean; collectLoggerNames?: boolean; collectContextMode?: CollectContextModeType; clientNameString?: string; clientVersionString?: string; loggerKey?: string; }; type PollStatus = { status: "not-started"; } | { status: "pending"; } | { status: "stopped"; } | { status: "running"; frequencyInMs: number; }; type PublicShouldLogParams = Omit; declare class ReforgeLogger { private reforge; constructor(reforge: Reforge); private log; trace(message: string): void; debug(message: string): void; info(message: string): void; warn(message: string): void; error(message: string): void; fatal(message: string): void; } declare class Reforge { private _configs; private _telemetryUploader; private _pollCount; private _pollStatus; private _pollTimeoutId; private _instanceHash; private collectEvaluationSummaries; private collectLoggerNames; private evalutionSummaryAggregator; private loggerAggregator; clientNameString: string; loaded: boolean; loader: Loader | undefined; afterEvaluationCallback: EvaluationCallback; private _context; private _loggerKey; logger: ReforgeLogger; constructor(); init({ sdkKey, context: providedContext, endpoints, apiEndpoint, timeout, afterEvaluationCallback, collectEvaluationSummaries, collectLoggerNames, collectContextMode, clientNameString, clientVersionString, loggerKey, }: ReforgeInitParams): Promise; extract(): Record; hydrate(rawValues: RawConfigWithoutTypes | EvaluationPayload): void; get context(): Context; get instanceHash(): string; get pollTimeoutId(): NodeJS.Timeout | undefined; get pollCount(): number; get pollStatus(): PollStatus; get telemetryUploader(): TelemetryUploader | undefined; private load; updateContext(context: Context, skipLoad?: boolean): Promise; poll({ frequencyInMs }: { frequencyInMs: number; }): Promise; private doPolling; stopPolling(): void; stopTelemetry(): void; private setConfigPrivate; isEnabled(key: K): boolean; get(key: K): TypedFrontEndConfigurationRaw[K]; getDuration(key: K): Duration$1 | undefined; shouldLog(args: PublicShouldLogParams, async?: boolean): boolean; getLogLevel(_loggerName: string): LogLevel; isCollectingEvaluationSummaries(): boolean; isCollectingLoggerNames(): boolean; } declare const reforge: Reforge; declare function prefetchReforgeConfig({ sdkKey, context, endpoints, timeout, collectContextMode, clientNameString, clientVersionString, }: ReforgeInitParams): void; declare const version: any; export { type CollectContextModeType, Config, type ConfigValue, Context, type ContextValue, type Contexts, type Duration$1 as Duration, type FrontEndConfigurationRaw, LogLevel, Reforge, type ReforgeBootstrap, type ReforgeInitParams, type TypedFrontEndConfigurationRaw, getLogLevelSeverity, prefetchReforgeConfig, reforge, shouldLogAtLevel, version };