import { FeatureFlagManager, type EffectiveFeatureFlagState, type FeatureFlagDefinition, type FeatureFlagEvaluationContext, type FeatureFlagRule } from '@littoral/literally/feature-flags'; import { type Firestore } from 'firebase/firestore'; import { type ReactiveController, type ReactiveControllerHost } from 'lit'; import { type FirestoreFeatureFlagAdapterOptions } from './adapter.js'; export interface FirestoreFeatureFlagControllerOptions extends Omit { /** * Firestore database instance or reactive getter function. */ firestore?: Firestore | (() => Firestore | null | undefined); /** * Optional reactive getter or static value for the namespace. */ namespace?: string | (() => string | undefined); /** * Optional catalog of known feature definitions. */ definitions?: ReadonlyArray>; /** * Optional baseline defaults by flag key. */ defaults?: Partial>; /** * Evaluation context (or reactive getter returning one) representing the current user, * scope/tenant, and attributes. */ context?: FeatureFlagEvaluationContext | (() => FeatureFlagEvaluationContext | undefined); /** * Separator between scope prefix and flag ID in storage keys (defaults to `'__'`). */ scopeSeparator?: string; /** * Callback invoked when a Firestore subscription error occurs. */ onError?: (error: Error) => void; /** * Whether to automatically subscribe when the host connects. Defaults to `true`. */ autoStart?: boolean; } /** * A Lit Reactive Controller that connects a `FeatureFlagManager` directly to a * namespaced Firestore collection via `FirestoreFeatureFlagAdapter`. * * Automatically manages real-time `onSnapshot` subscriptions on `hostConnected` / * `hostDisconnected` and re-evaluates flags when reactive context properties change. */ export declare class FirestoreFeatureFlagController implements ReactiveController { protected host: ReactiveControllerHost; protected options: FirestoreFeatureFlagControllerOptions; protected isHostConnected: boolean; protected activeDb: Firestore | null; protected activeNamespace: string | undefined; /** * Underlying `FeatureFlagManager` instance. Can be provided via `@provide({ context: featureFlagContext })` * so child `` elements or `FeatureFlagController` instances share the same state. */ readonly manager: FeatureFlagManager; /** * Whether the controller is waiting for the initial Firestore snapshot. */ loading: boolean; /** * Any error encountered during the Firestore subscription. */ error?: Error; constructor(host: ReactiveControllerHost, options?: FirestoreFeatureFlagControllerOptions); /** * Evaluated boolean map for all registered and stored feature flags. */ get flags(): Record; /** * Raw feature flag rules currently synced from Firestore. */ get rules(): Record; hostConnected(): void; hostDisconnected(): void; hostUpdate(): void; /** * Subscribes to the configured Firestore feature flags collection. */ subscribe(): void; /** * Stops the active Firestore listener. */ unsubscribe(): void; /** * Evaluates whether a specific feature flag is enabled. */ isEnabled(flagKey: TKey | (string & {}), contextOverride?: FeatureFlagEvaluationContext): boolean; /** * Resolves the effective rule configuration for a flag in a given scope. */ getEffectiveState(flagId: TKey | (string & {}), scope?: string | null | undefined): EffectiveFeatureFlagState; /** * Saves or updates a feature flag rule in Firestore. */ setFlagRule(flagId: TKey | (string & {}), rule: Partial, options?: { scope?: string | null; merge?: boolean; preventWhenGloballyTrumped?: boolean; }): Promise; /** * Deletes a feature flag rule or scoped override from Firestore. */ deleteFlagRule(flagId: TKey | (string & {}), scope?: string | null | undefined): Promise; protected syncManagerContext(): void; protected resolveFirestore(): Firestore | null; protected resolveNamespace(): string | undefined; protected resolveContext(): FeatureFlagEvaluationContext | undefined; } //# sourceMappingURL=controller.d.ts.map