import { type FirebaseStorageAccessor } from './driver/accessor'; import { type FirebaseStorageDrivers } from './driver/driver'; import { type StorageBucketId, type StoragePathFactory } from './storage'; import { type FirebaseStorage } from './types'; /** * Central context for Firebase Cloud Storage operations within `@dereekb/firebase`. * * Wraps the underlying {@link FirebaseStorage} instance and its {@link FirebaseStorageDrivers}, * while exposing convenience methods for file/folder access via {@link FirebaseStorageAccessor}. * * Created by {@link firebaseStorageContextFactory}. */ export interface FirebaseStorageContext extends FirebaseStorageAccessor { readonly storage: F; readonly drivers: FirebaseStorageDrivers; /** * Normalizes a {@link StoragePathInput} into the full {@link StoragePath} this context would use for it, * applying the context's default bucket. * * Exposed so a caller that needs the resolved bucket and path — rather than an accessor — does not have to * build a file accessor just to read its `storagePath` back off. */ readonly storagePath: StoragePathFactory; } /** * Factory that creates a {@link FirebaseStorageContext} from a {@link FirebaseStorage} instance and optional configuration. * * Produced by {@link firebaseStorageContextFactory}. */ export type FirebaseStorageContextFactory = (firebaseStorage: F, config?: FirebaseStorageContextFactoryConfig) => FirebaseStorageContext; /** * Configuration for {@link firebaseStorageContextFactory}. */ export interface FirebaseStorageContextFactoryConfig { /** * The default bucket */ readonly defaultBucketId?: StorageBucketId; /** * Whether or not to force using the default bucket id. */ readonly forceBucket?: boolean; } /** * Creates a {@link FirebaseStorageContextFactory} that produces storage contexts using the given drivers. * * The returned factory resolves a default bucket (from driver, config, or error) and builds * a {@link StoragePathFactory} to normalize all path inputs. * * @param drivers - The storage driver implementations to use. * @returns A {@link FirebaseStorageContextFactory} that creates storage contexts for a given storage instance. * @throws {Error} When a default bucket ID cannot be resolved from the driver or config. * * @example * ```ts * const factory = firebaseStorageContextFactory(myDrivers); * const storageContext = factory(firebaseStorage, { defaultBucketId: 'my-bucket' }); * const file = storageContext.file('uploads/doc.pdf'); * ``` * * @__NO_SIDE_EFFECTS__ */ export declare function firebaseStorageContextFactory(drivers: FirebaseStorageDrivers): FirebaseStorageContextFactory;