import { type Maybe } from '@dereekb/util'; import { type StorageListFilesPageToken, type FirebaseStorageAccessorFile, type FirebaseStorageAccessorFolder, type StorageListFilesOptions, type StorageListFilesResult, type StorageListItemResult } from './accessor'; /** * Input context for {@link StorageListFilesResultFactory} and related delegate methods. * * Bundles the storage instance, target folder, and listing options into a single parameter. * * @template S - the storage instance type (client or server SDK) */ export interface StorageListFilesResultFactoryInput { readonly storage: S; readonly folder: FirebaseStorageAccessorFolder; readonly options: Maybe; } /** * Delegate that adapts platform-specific list results into the generic {@link StorageListFilesResult} interface. * * Implementations extract items, pagination tokens, and convert raw results into typed file/folder accessors. * Used by {@link storageListFilesResultFactory} to create the normalized result objects. * * @template S - the storage instance type (client or server SDK) * @template R - the raw list result type from the underlying SDK */ export interface StorageListFilesResultFactoryDelegate { hasItems(result: R): boolean; hasNext(result: R): boolean; nextPageTokenFromResult(result: R): Maybe; next(input: StorageListFilesResultFactoryInput, result: R): Promise; file(storage: S, fileResult: StorageListItemResult): FirebaseStorageAccessorFile; folder(storage: S, folderResult: StorageListItemResult): FirebaseStorageAccessorFolder; filesFromResult(result: R, folder: FirebaseStorageAccessorFolder): StorageListItemResult[]; foldersFromResult(result: R, folder: FirebaseStorageAccessorFolder): StorageListItemResult[]; } /** * Factory function that transforms a raw SDK list result into a normalized {@link StorageListFilesResult}. */ export type StorageListFilesResultFactory = (input: StorageListFilesResultFactoryInput, result: R) => StorageListFilesResult; /** * Creates a {@link StorageListFilesResultFactory} from a platform-specific delegate. * * The returned factory lazily computes file and folder arrays (via {@link cachedGetter}) and * provides cursor-based pagination through the `next()` method. * * @param delegate - platform-specific implementation for extracting results * @returns a {@link StorageListFilesResultFactory} that normalizes raw SDK list results * * @example * ```ts * const factory = storageListFilesResultFactory(myDelegate); * const result = factory({ storage, folder, options: { maxResults: 50 } }, rawSdkResult); * const files = result.files(); * ``` */ export declare function storageListFilesResultFactory(delegate: StorageListFilesResultFactoryDelegate): StorageListFilesResultFactory; /** * Creates an error thrown when `next()` is called on a list result that has no more pages. * * @returns an {@link Error} indicating there are no more pages to fetch */ export declare function storageListFilesResultHasNoNextError(): Error;