import { Context, internal, LDLogger } from '@launchdarkly/js-sdk-common'; import FlagStore from './FlagStore'; import { ItemDescriptor } from './ItemDescriptor'; export type FlagChangeType = 'init' | 'patch' | 'override'; /** * This callback indicates that the details associated with one or more flags * have changed. * * This could be the value of the flag, but it could also include changes * to the evaluation reason, such as being included in an experiment. * * It can include new or deleted flags as well, so an evaluation may result * in a FLAG_NOT_FOUND reason. * * This event does not include the value of the flag. It is expected that you * will call a variation method for flag values which you require. */ export type FlagsChangeCallback = (context: Context, flagKeys: Array, type: FlagChangeType) => void; /** * The flag updater handles logic required during the flag update process. * It handles versions checking to handle out of order flag updates and * also handles flag comparisons for change notification. */ export interface FlagUpdater { /** * Handles the flag changes by calling the change callbacks. * * @param keys keys of the flags that changed * @param type type of change that occurred see {@link FlagChangeType} */ handleFlagChanges(keys: string[], type: FlagChangeType): void; /** * Initializes the flag updater with the given context and flags. * This will be called every time a new context is identified. * * @param context the context to initialize the flag updater with * @param newFlags the flags to initialize the flag updater with */ init(context: Context, newFlags: { [key: string]: ItemDescriptor; }): void; initCached(context: Context, newFlags: { [key: string]: ItemDescriptor; }): void; /** * Upserts the flag with the given key and item. * * @param context the context to upsert the flag with * @param key the key of the flag to upsert * @param item the item to upsert the flag with * @returns true if the flag was upserted, false otherwise */ upsert(context: Context, key: string, item: ItemDescriptor): boolean; /** * Applies a changeset directly to the flag store, bypassing version checks * and inactive-context guards. Used by the FDv2 data path where ordering * is handled at the protocol layer. * * - `'full'`: replaces all flags and emits change events for differences. * - `'partial'`: merges updates and emits change events for each key. * - `'none'`: no flag changes (caller handles freshness separately). */ applyChanges(context: Context, updates: { [key: string]: ItemDescriptor; }, type: internal.PayloadType): void; /** * Registers a callback to be called when the flags change. * * @param callback the callback to register */ on(callback: FlagsChangeCallback): void; /** * Unregisters a callback to be called when the flags change. * * @param callback the callback to unregister */ off(callback: FlagsChangeCallback): void; } export default function createFlagUpdater(_flagStore: FlagStore, _logger: LDLogger): FlagUpdater; //# sourceMappingURL=FlagUpdater.d.ts.map