import { LDHeaders, Platform } from '@launchdarkly/js-sdk-common'; import { FDv2ConnectionMode, ModeResolutionTable } from '../api/datasource'; import { LDIdentifyOptions } from '../api/LDIdentifyOptions'; import { Configuration } from '../configuration/Configuration'; import { DataManager } from '../DataManager'; import { FlagManager } from '../flag-manager/FlagManager'; import LDEmitter from '../LDEmitter'; import { ModeTable } from './ConnectionModeConfig'; import { DataSourceEndpoints } from './Endpoints'; import { SourceFactoryProvider } from './SourceFactoryProvider'; import { LifecycleState, NetworkState } from './StateDebounceManager'; /** * Configuration for creating an {@link FDv2DataManagerControl}. */ export interface FDv2DataManagerBaseConfig { platform: Platform; flagManager: FlagManager; credential: string; config: Configuration; baseHeaders: LDHeaders; emitter: LDEmitter; /** Mode resolution table for this platform. */ transitionTable: ModeResolutionTable; /** The configured foreground connection mode. Use {@link resolveForegroundMode} to derive. */ foregroundMode: FDv2ConnectionMode; /** The background connection mode, if any. */ backgroundMode: FDv2ConnectionMode | undefined; /** The mode table mapping modes to data source definitions. */ modeTable: ModeTable; /** Provider that converts DataSourceEntry descriptors to concrete factories. */ sourceFactoryProvider: SourceFactoryProvider; /** * Platform-specific function to build query params for each identify call. * Browser returns `[{ key: 'auth', value: credential }]` + optional hash. * Mobile returns `[]` (uses Authorization header instead). */ buildQueryParams: (identifyOptions?: LDIdentifyOptions) => { key: string; value: string; }[]; /** * FDv1 endpoint factory for fallback. When provided, a blocked FDv1 * polling synchronizer slot is automatically appended to every data * source. It is activated when an FDv2 response includes the * `x-ld-fd-fallback` header. * * Browser: `browserFdv1Endpoints(clientSideId)` * Mobile: `mobileFdv1Endpoints()` */ fdv1Endpoints?: DataSourceEndpoints; /** Fallback condition timeout in ms (default 120s). */ fallbackTimeoutMs?: number; /** Recovery condition timeout in ms (default 300s). */ recoveryTimeoutMs?: number; } /** * The public interface returned by {@link createFDv2DataManagerBase}. * Extends {@link DataManager} with mode control methods. */ export interface FDv2DataManagerControl extends DataManager { /** Update the pending network state. Goes through debounce. */ setNetworkState(state: NetworkState): void; /** Update the pending lifecycle state. Goes through debounce. */ setLifecycleState(state: LifecycleState): void; /** * Set an explicit connection mode override that bypasses all automatic * behavior (transition table, streaming, lifecycle). Pass undefined to * clear the override and return to automatic behavior. */ setConnectionMode(mode?: FDv2ConnectionMode): void; /** Get the currently resolved connection mode. */ getCurrentMode(): FDv2ConnectionMode; /** The configured default foreground mode (from config, not auto-promoted). */ readonly configuredForegroundMode: FDv2ConnectionMode; /** * Set a callback to flush pending analytics events. Called immediately * (not debounced) when the lifecycle transitions to background. */ setFlushCallback(callback: () => void): void; } /** * Creates a shared FDv2 data manager that owns mode resolution, debouncing, * selector state, and FDv2DataSource lifecycle. Platform SDKs (browser, RN) * wrap this with platform-specific config and event wiring. */ export declare function createFDv2DataManagerBase(baseConfig: FDv2DataManagerBaseConfig): FDv2DataManagerControl; //# sourceMappingURL=FDv2DataManagerBase.d.ts.map