import { Config } from "./config"; import Loader from "./loader"; import TelemetryUploader from "./telemetry/uploader"; import type { ConfigValue, Contexts, Duration, EvaluationCallback, EvaluationDetails, EvaluationPayload, InitOptions } from "./types"; type PollStatus = { status: "not-started"; } | { status: "pending"; } | { status: "stopped"; } | { status: "running"; frequencyInMs: number; }; export interface QuonfigBootstrap { evaluations: EvaluationPayload["evaluations"]; context: Contexts; } export declare class Quonfig { private _configs; private _telemetryUploader; private _pollCount; private _pollStatus; private _pollTimeoutId; private _instanceHash; private _collectEvaluationSummaries; private _collectLoggerNames; private evaluationSummaryAggregator; private loggerAggregator; private _contexts; private _loggerKey; private _dataVersion; private _subscribers; clientName: string; clientVersion: string; loaded: boolean; loader: Loader | undefined; afterEvaluationCallback: EvaluationCallback; /** * Initialize the SDK. Must be called before any other methods. */ init({ sdkKey, context, domain, apiUrls, apiUrl, telemetryUrl, timeout, afterEvaluationCallback, collectEvaluationSummaries, collectLoggerNames, collectContextMode, loggerKey, }: InitOptions): Promise; get configs(): { [key: string]: Config; }; get contexts(): Contexts; get instanceHash(): string; get pollTimeoutId(): NodeJS.Timeout | undefined; get pollCount(): number; get pollStatus(): PollStatus; get telemetryUploader(): TelemetryUploader | undefined; /** The init-time `loggerKey` used by the `shouldLog({loggerPath, ...})` overload. */ get loggerKey(): string | undefined; /** * Monotonic version counter that increments every time the in-memory config * changes (via `setConfig` or `hydrate`). Pair with `subscribe()` and * React's `useSyncExternalStore` to drive re-renders on poll updates. */ get dataVersion(): number; /** * Register a listener invoked synchronously after every config mutation * (poll fetch, `setConfig`, `hydrate`). Returns an unsubscribe function. * * Listeners must not throw — exceptions are swallowed so one bad subscriber * cannot break the others. */ subscribe(listener: () => void): () => void; private notifySubscribers; /** * Internal: load configs from server. */ private load; /** * Update the context and re-fetch evaluated configs from the server. */ updateContext(context: Contexts, skipLoad?: boolean): Promise; /** * Start polling the server for config updates at the given frequency. */ poll({ frequencyInMs }: { frequencyInMs: number; }): Promise; private doPolling; /** * Stop polling for config updates. */ stopPolling(): void; /** * Drain in-memory telemetry counters by POSTing them to the telemetry * endpoint. Use this when you want to ensure counters are shipped without * tearing down the SDK (e.g. before a context swap in a long-lived SPA). */ flush(): Promise; /** * Tear down the SDK: drain telemetry, then stop polling and telemetry timers. */ close(): Promise; /** * Stop telemetry aggregator timers without draining. Prefer `close()` or * `flush()` for normal teardown — those drain pending counters first. */ stopTelemetry(): void; /** * Set configs from a raw evaluation payload. */ setConfig(rawValues: EvaluationPayload): void; /** * Seed the client with pre-evaluated flags (e.g. for SSR hydration). * Flags are flat key-value pairs: { flagKey: value }. */ hydrate(flags: Record): void; /** * Extract the current evaluated config as a flat key-value map. */ extract(): Record; /** * Check if a feature flag is enabled. Returns false for any non-true value. */ isEnabled(key: string): boolean; /** * Get the evaluated value for a config key. */ get(key: string): ConfigValue; /** * Return the evaluated value plus OpenFeature-style resolution details * (reason, variant, flagMetadata) for the given key. * * Mirrors sdk-node's `getBoolDetails` / `getStringDetails` etc. so the * openfeature-web provider can populate `variant` and `flagMetadata` per * `project/plans/openfeature-resolution-details.md`. */ getDetails(key: string): EvaluationDetails; /** * Get the evaluated value for a key, asserting it is a Duration. */ getDuration(key: string): Duration | undefined; /** * Determine whether a log message at the given level should be emitted. * * Two shapes are supported: * * 1. `{configKey, ...}` — primitive shape. Evaluates the named config as a * log level. The caller is responsible for any per-logger routing. * * 2. `{loggerPath, ...}` — convenience shape. Requires `loggerKey` on * `init()`. The SDK uses `loggerKey` as the underlying config key and * injects `contexts["quonfig-sdk-logging"] = { key: loggerPath }` into * the live client contexts so the logger path is auto-captured by the * existing example-context telemetry. `loggerPath` is passed through * without normalization. */ shouldLog(args: { configKey: string; desiredLevel: string; defaultLevel: string; }, async?: boolean): boolean; shouldLog(args: { loggerPath: string; desiredLevel: string; defaultLevel?: string; }, async?: boolean): boolean; /** * Whether evaluation summary telemetry is being collected. */ isCollectingEvaluationSummaries(): boolean; /** * Whether logger name telemetry is being collected. */ isCollectingLoggerNames(): boolean; } /** Singleton instance for convenience. */ export declare const quonfig: Quonfig; export {};