import { Context, internal, LDLogger, Platform } from '@launchdarkly/js-sdk-common'; import FlagStore from './FlagStore'; import { FlagUpdater } from './FlagUpdater'; import { ItemDescriptor } from './ItemDescriptor'; /** * This class handles persisting and loading flag values from a persistent * store. It intercepts updates and forwards them to the flag updater and * then persists changes after the updater has completed. * * Freshness metadata (timestamp + context attribute hash) is stored in a * separate storage key (`{contextKey}_freshness`) alongside the flag data. * Both keys are managed together — when a context is evicted, both the flag * data and freshness record are cleared. */ export default class FlagPersistence { private readonly _platform; private readonly _environmentNamespace; private readonly _maxCachedContexts; private readonly _disableCache; private readonly _flagStore; private readonly _flagUpdater; private readonly _logger; private readonly _timeStamper; private _contextIndex; private _indexKey?; private _indexKeyPromise; constructor(_platform: Platform, _environmentNamespace: string, _maxCachedContexts: number, _disableCache: boolean, _flagStore: FlagStore, _flagUpdater: FlagUpdater, _logger: LDLogger, _timeStamper?: () => number); /** * Inits flag persistence for the provided context with the provided flags. This will result * in the underlying {@link FlagUpdater} switching its active context. */ init(context: Context, newFlags: { [key: string]: ItemDescriptor; }): Promise; /** * Upserts a flag into the {@link FlagUpdater} and stores that to persistence if the upsert * was successful / accepted. An upsert may be rejected if the provided context is not * the active context. */ upsert(context: Context, key: string, item: ItemDescriptor): Promise; /** * Applies a changeset to the flag store. * - `'full'`: replaces all flags via {@link FlagUpdater.init}. * - `'partial'`: upserts individual flags via {@link FlagUpdater.upsert}. * - `'none'`: no flag changes, only persists cache to update freshness. * * Always persists to cache afterwards, which updates the freshness timestamp * even when no flags change (e.g., transfer-none). */ applyChanges(context: Context, updates: { [key: string]: ItemDescriptor; }, type: internal.PayloadType): Promise; /** * Loads the flags from persistence for the provided context and gives those to the * {@link FlagUpdater} this {@link FlagPersistence} was constructed with. */ loadCached(context: Context): Promise; private _storeFreshness; private _loadIndex; private _storeCache; } //# sourceMappingURL=FlagPersistence.d.ts.map