import type { FeatureFlagRule, FeatureFlagStorageAdapter, FeatureFlagStoreListener } from '@littoral/literally/feature-flags'; import { type CollectionReference, type DocumentReference, type Firestore, type FirestoreDataConverter } from 'firebase/firestore'; /** * Standard FirestoreDataConverter for `FeatureFlagRule` documents. * Ensures clean data writes with zero `undefined` properties and safe defaults. */ export declare const featureFlagRuleConverter: FirestoreDataConverter; export interface FirestoreFeatureFlagAdapterOptions { /** * Firestore database instance. */ firestore: Firestore; /** * Optional namespace to isolate feature flags for a specific application, product, or environment. * * - When `namespaceStrategy` is `'collection_prefix'` (default): * resolves collection `${namespace}_${collectionName}` (e.g. `'canopy_feature_flags'`). * - When `namespaceStrategy` is `'subcollection'`: * resolves subcollection `${parentCollection}/${namespace}/${collectionName}` * (e.g. `'namespaces/canopy/feature_flags'`). * - When `namespaceStrategy` is `'document_prefix'`: * stores documents in `${collectionName}` with document IDs prefixed by * `${namespace}${namespaceSeparator}${key}` (e.g. `'canopy__classroom_freeze'`). */ namespace?: string; /** * Base collection name for feature flags. Defaults to `'feature_flags'`. * May also be a slash-delimited collection path (e.g. `'apps/canopy/feature_flags'`). */ collectionName?: string; /** * How `namespace` is applied in Firestore when provided. Defaults to `'collection_prefix'`. */ namespaceStrategy?: 'collection_prefix' | 'subcollection' | 'document_prefix'; /** * Parent collection name when `namespaceStrategy` is `'subcollection'`. Defaults to `'namespaces'`. */ parentCollection?: string; /** * Separator used when `namespaceStrategy` is `'document_prefix'`. Defaults to `'__'`. */ namespaceSeparator?: string; } /** * Resolves the Firestore `CollectionReference` for the given adapter options. */ export declare function resolveFeatureFlagCollection(options: FirestoreFeatureFlagAdapterOptions): CollectionReference; /** * Resolves a Firestore `DocumentReference` for a specific storage key. */ export declare function resolveFeatureFlagDoc(key: string, options: FirestoreFeatureFlagAdapterOptions): DocumentReference; /** * Firestore storage adapter implementing `@littoral/literally`'s `FeatureFlagStorageAdapter`. * Supports namespaced collections (`canopy_feature_flags`), subcollections * (`namespaces/canopy/feature_flags`), and document-prefixed keys within a shared collection. */ export declare class FirestoreFeatureFlagAdapter implements FeatureFlagStorageAdapter { private readonly options; constructor(options: FirestoreFeatureFlagAdapterOptions); /** * Returns the resolved Firestore `CollectionReference` backing this adapter. */ getCollectionRef(): CollectionReference; /** * Returns a `DocumentReference` for a specific feature flag key (`flagId` or `scope__flagId`). */ getDocRef(key: string): DocumentReference; /** * Fetches all feature flag rules in the namespaced collection. */ getFlags(): Promise>; /** * Fetches a single feature flag rule by its storage key (`flagId` or `scope__flagId`). */ getFlag(key: string): Promise; /** * Creates or updates a feature flag rule in Firestore. * Cleans `undefined` fields prior to writing. */ setFlag(key: string, rule: Partial, options?: { merge?: boolean; }): Promise; /** * Deletes a feature flag rule or scoped override document from Firestore. */ deleteFlag(key: string): Promise; /** * Subscribes to real-time updates on the feature flags collection using `onSnapshot`. */ subscribe(listener: FeatureFlagStoreListener, onError?: (error: Error) => void): () => void; } //# sourceMappingURL=adapter.d.ts.map