import { D as DbAdapter, C as CacheAdapter, aa as RolleaseHooks, P as ImpressionConfig, ap as WebhookConfig, a5 as ResilienceConfig, Z as PrivacyConfig, ag as TelemetryAdapter, Q as InvalidationBus, d as AuditConfig, a as AnalyticsSink, j as CreateFlagInput, F as Flag, U as ListFlagsInput, V as ListFlagsResult, ak as UpdateFlagInput, af as SetLockInput, b as ArchiveFlagInput, a6 as RestoreFlagInput, c as AuditActor, i as CloneFlagInput, O as HistoryEntry, u as FlagContext, ao as Variant, Y as MultiContext, G as FlagResult, x as FlagMap, n as DetailedFlagMap, T as KillFlagInput, A as AddRuleInput, H as FlagRule, al as UpdateRuleInput, ac as RuleOrdering, ab as RolloutConfig, l as CreateSegmentInput, ad as Segment, am as UpdateSegmentInput, ae as SegmentUsage, q as ExclusionLayer, r as ExclusionLayerAllocation, k as CreateReleaseInput, $ as Release, a2 as ReleasePreview, m as DeployReleaseInput, a7 as RollbackReleaseInput, a9 as RolleaseHealthResult, ai as TrackEventInput, aj as TrackingEvent, N as HistoryAction, aq as WebhookPayload, B as BulkCreateResult, g as BulkUpdateResult } from '../types-YdF1AOxp.js'; import { RolleaseLogger } from '../core/logger.js'; import { MetricsAdapter } from '../core/metrics.js'; import '../core/flag-types.js'; type ChangeListener = (event: { flagKey: string; action: string; value?: unknown; }) => void; declare class FlagManager { private db; private l1Cache; private l2Cache?; private l1TtlMs; private l2TtlMs; private useLocalOverrides; private localOverridesFile; private listeners; private hooks; private impressions; private logger; private evaluateAllPageSize; private autoResolveSegments; private webhookDispatcher; private environment?; private overrideCache; private overrideReadAt; private resilience; private privacy; private telemetry?; private evalCount; private cacheHitCount; private cacheMissCount; private startedAt; private invalidationBus?; private invalidationUnsubscribe?; private instanceId; private circuitPhase; private circuitFailures; private circuitWindowStartedAt; private circuitOpenedAt; private metrics?; private exposureTracker?; private dbReader?; private cacheNamespace; private audit?; private analyticsSink?; constructor(opts: { db: DbAdapter; l2Cache?: CacheAdapter; l1TtlMs?: number; l2TtlMs?: number; useLocalOverrides?: boolean; localOverridesFile?: string; hooks?: RolleaseHooks; impressions?: ImpressionConfig; logger?: RolleaseLogger; evaluateAllPageSize?: number; autoResolveSegments?: boolean; webhooks?: WebhookConfig[]; environment?: string; resilience?: ResilienceConfig; privacy?: PrivacyConfig; telemetry?: TelemetryAdapter; invalidationBus?: InvalidationBus; metrics?: MetricsAdapter; dbReader?: DbAdapter; cacheNamespace?: string; audit?: AuditConfig; analyticsSink?: AnalyticsSink; }); create(input: CreateFlagInput): Promise; get(key: string): Promise; list(filters?: ListFlagsInput): Promise; update(key: string, patch: UpdateFlagInput): Promise; setLock(key: string, input: SetLockInput): Promise; archive(key: string, opts?: ArchiveFlagInput): Promise; restore(key: string, opts?: RestoreFlagInput): Promise; delete(key: string, opts?: { confirm: boolean; actor?: AuditActor; }): Promise; clone(key: string, opts: CloneFlagInput): Promise; getHistory(key: string, opts?: { limit?: number; }): Promise; isEnabled(key: string, context: FlagContext): Promise; getVariant(key: string, context: FlagContext): Promise; evaluateMultiContext(key: string, multiContext: MultiContext): Promise>; getValue(key: string, context: FlagContext): Promise; evaluateAll(context: FlagContext, opts?: { keys?: string[]; namespace?: string; tags?: string[]; }): Promise; evaluateAllDetailed(context: FlagContext, opts?: { keys?: string[]; namespace?: string; tags?: string[]; trace?: boolean; }): Promise; kill(key: string, opts?: KillFlagInput): Promise; killAll(opts: { environment?: string; reason?: string; killedBy?: string; actor?: AuditActor; }): Promise; restoreAll(opts: { environment?: string; restoredBy?: string; actor?: AuditActor; }): Promise; addRule(flagKey: string, rule: AddRuleInput): Promise; updateRule(flagKey: string, ruleId: string, patch: UpdateRuleInput): Promise; removeRule(flagKey: string, ruleId: string, opts?: { actor?: AuditActor; }): Promise; listRules(flagKey: string): Promise; reorderRules(flagKey: string, ordering: RuleOrdering[], opts?: { actor?: AuditActor; }): Promise; setRollout(key: string, config: Partial, opts?: { actor?: AuditActor; }): Promise; createSegment(input: CreateSegmentInput): Promise; updateSegment(key: string, patch: UpdateSegmentInput): Promise; deleteSegment(key: string, opts?: { actor?: AuditActor; }): Promise; listSegments(): Promise; getSegmentUsage(key: string): Promise; createExclusionLayer(input: ExclusionLayer, opts?: { actor?: AuditActor; }): Promise; getExclusionLayer(key: string): Promise; updateExclusionLayer(key: string, allocations: ExclusionLayerAllocation[], opts?: { actor?: AuditActor; }): Promise; deleteExclusionLayer(key: string, opts?: { actor?: AuditActor; }): Promise; listExclusionLayers(): Promise; createRelease(input: CreateReleaseInput): Promise; previewRelease(releaseId: string): Promise; deployRelease(releaseId: string, opts?: DeployReleaseInput): Promise; rollbackRelease(releaseId: string, opts?: RollbackReleaseInput): Promise; approveRelease(releaseId: string, approverId: string, opts?: { actor?: AuditActor; }): Promise; rejectRelease(releaseId: string, rejectorId: string, opts?: { reason?: string; actor?: AuditActor; }): Promise; listReleases(filters?: { environment?: string; status?: string; limit?: number; }): Promise; health(): Promise; /** Return serialized Prometheus-format metrics. Returns empty string when no metrics adapter is configured. */ getMetrics(): string; forgetUser(userId: string, scope?: Array<"impressions" | "assignments" | "history" | "events">): Promise; /** * Return all flag evaluation impressions for a specific user. * Implements GDPR right-to-explanation — callers can see which flags * affected a user, what value they received, and when. */ getUserImpressions(userId: string, opts?: { limit?: number; flagKey?: string; }): Promise>; /** * Enforce retention windows from `privacy.impressionRetentionDays` and * `privacy.auditRetentionDays`. Safe to call on a schedule (cron, k8s job). * No-op when neither window is configured or when the adapter doesn't * implement the corresponding delete methods. */ runRetentionPolicies(): Promise<{ impressionsDeleted: number; historyDeleted: number; errors: Array<{ scope: "impressions" | "history"; error: string; }>; }>; trackEvent(event: TrackEventInput): Promise; close(): Promise; runScheduledReleases(): Promise<{ deployed: string[]; failed: Array<{ id: string; error: string; }>; }>; addTags(key: string, tags: string[], opts?: { actor?: AuditActor; }): Promise; removeTags(key: string, tags: string[], opts?: { actor?: AuditActor; }): Promise; invalidateCache(key: string): Promise; invalidateAllCaches(): Promise; onChange(listener: ChangeListener): () => void; /** Register a local Javascript/Typescript event listener callback */ on(event: HistoryAction | "*", callback: (payload: WebhookPayload) => void | Promise): void; /** Remove a local Javascript/Typescript event listener callback */ off(event: HistoryAction | "*", callback: (payload: WebhookPayload) => void | Promise): void; /** * Return flags that haven't been evaluated since `staleDays` ago. * Useful for cleaning up flag debt. */ getStaleFlags(opts?: { staleDays?: number; namespace?: string; }): Promise; /** * Create multiple flags in a single call. Individual failures are returned * as errors — not thrown — so partial successes are possible. */ bulkCreate(inputs: CreateFlagInput[]): Promise; /** * Update multiple flags in a single call. Individual failures are returned * as errors — not thrown — so partial successes are possible. */ bulkUpdate(updates: Array<{ key: string; patch: UpdateFlagInput; }>): Promise; /** * Delete multiple flags in a single call. Requires `confirm: true`. * Stops at the first failure and throws. */ bulkDelete(keys: string[], opts?: { confirm: boolean; actor?: AuditActor; }): Promise; /** * Evaluate a single flag and return the full FlagResult (value, variant, * reason, ruleId, evaluatedAt). This is the detailed counterpart to * `isEnabled`/`getValue`/`getVariant` — use it when you need the reason * (e.g. for analytics, debugging, or RBAC auditing). * * ```ts * const result = await rl.flags.evaluate('checkout_v2', { userId: 'u1' }) * console.log(result.value, result.reason, result.variant) * ``` */ evaluate(key: string, context: FlagContext, callOptions?: { trace?: boolean; }): Promise>; /** * Internal evaluation with cycle-tracking for recursive prerequisite * resolution. The public `evaluate()` delegates here without exposing the * chain bookkeeping. */ private evaluateInternal; /** * Resolve segments automatically by evaluating all segment definitions * against the provided context. Returns an array of matching segment keys. * * This is opt-in via `autoResolveSegments: true` in the config. * When segments are pre-populated in context, this step is skipped. */ private resolveSegments; private withDbResilience; private throwIfCircuitOpen; private recordDbSuccess; private recordDbFailure; private flagCacheKey; private rulesCacheKey; private getFlagCached; private getRulesCached; private getExclusionLayerCached; private getLocalOverride; private ensureNotLocked; private bustCache; private bustAllCaches; private publishInvalidation; private handleInvalidation; private emit; private runMutationHook; private writeAudit; private runBeforeEvaluation; private fireOnEvaluate; private maybeTrackImpression; private scrubContext; /** * Validate that a set of prerequisites does not create circular * dependency chains. Uses DFS with max depth of 10. */ private validatePrerequisiteChain; private touchFlagEvaluation; } export { FlagManager };