import { F as File, L as LocalMetaStorageOptions, i as BaseStorageOptions, M as MetaStorage, d as FileInit, O as OperationOptions, e as FilePart, f as FileQuery, g as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C9EdfTf1.js"; import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CYWYyCUo.js"; import 'node:stream'; import 'node:timers'; import 'node:crypto'; import 'node:http'; import 'lru-cache'; declare class FirebaseFile extends File { bucket?: string; path?: string; publicUrl?: string; } declare class FirebaseMetaStorage extends LocalMetaStorage { constructor(config?: LocalMetaStorageOptions); } /** * Minimal structural type for a `@google-cloud/storage` `File` as returned by * `firebase-admin`'s `getStorage(app).bucket().file()`. Declared locally so the * adapter type-checks without `firebase-admin` / `@google-cloud/storage` * installed (optional peer dependency). */ interface FirebaseGcsFile { copy: (destination: FirebaseGcsFile | string) => Promise; delete: (options?: { ignoreNotFound?: boolean; }) => Promise; download: () => Promise<[Buffer]>; exists: () => Promise<[boolean]>; getMetadata: () => Promise<[FirebaseGcsFileMetadata]>; getSignedUrl: (options: FirebaseSignedUrlOptions) => Promise<[string]>; move: (destination: FirebaseGcsFile | string) => Promise; name: string; save: (data: Buffer, options?: { contentType?: string; resumable?: boolean; }) => Promise; } interface FirebaseGcsFileMetadata { contentType?: string; etag?: string; md5Hash?: string; name?: string; size?: number | string; timeCreated?: string; updated?: string; } interface FirebaseSignedUrlOptions { action: "delete" | "read" | "resumable" | "write"; contentType?: string; expires: Date | number | string; version?: "v2" | "v4"; } /** * Minimal structural type for a `@google-cloud/storage` `Bucket` as returned by * `firebase-admin`'s `getStorage(app).bucket()`. */ interface FirebaseBucket { file: (key: string) => FirebaseGcsFile; getFiles: (options?: { maxResults?: number; prefix?: string; }) => Promise<[FirebaseGcsFile[]]>; name?: string; } /** * Structural type for a `firebase-admin` `App`. Only the shape needed by * `getStorage()` is declared. */ interface FirebaseApp { name: string; } interface FirebaseStorageOptions extends BaseStorageOptions { /** * Pre-built `firebase-admin` {@link FirebaseApp} or an already-built * `@google-cloud/storage` `Bucket`. When a Bucket is supplied (detected by * the presence of `.file()` and `.getFiles()`), it is used directly and no * Firebase app is initialized. Use this to share an instance, run tests, or * customize the underlying GCS client. */ app?: FirebaseApp | FirebaseBucket; /** * Named `firebase-admin` app to reuse/create. Defaults to the SDK default * app. Ignored when `app` is supplied. */ appName?: string; /** * Storage bucket name (e.g. `my-project.appspot.com`). Falls back to * `FIREBASE_STORAGE_BUCKET`. Required unless a pre-built Bucket is passed * via `app`. */ bucket?: string; /** * Service-account credentials. Ignored when `app` is supplied or * `serviceAccountPath` is used. Falls back to `FIREBASE_CLIENT_EMAIL` / * `FIREBASE_PRIVATE_KEY`. */ credentials?: { clientEmail: string; privateKey: string; }; /** * Default expiry, in seconds, for `getReadUrl` / `getUploadUrl` signed * URLs. Defaults to 3600 (1 hour). */ defaultUrlExpiresIn?: number; /** * Configure metafiles storage. Used for TUS-style resumable upload * bookkeeping. Defaults to {@link LocalMetaStorage} under the OS tmp * directory. */ metaStorageConfig?: LocalMetaStorageOptions; /** * Google Cloud project id. Falls back to `FIREBASE_PROJECT_ID`, * `GOOGLE_CLOUD_PROJECT`, or `GCLOUD_PROJECT`. */ projectId?: string; /** * When set, `getReadUrl` returns `${publicBaseUrl}/${key}` instead of a * signed URL. Use for objects served through a public bucket or CDN. */ publicBaseUrl?: string; /** * Path to a service-account JSON key file. Ignored when `app` or * `credentials` is supplied. Falls back to * `GOOGLE_APPLICATION_CREDENTIALS`. */ serviceAccountPath?: string; } /** * Firebase Storage backend. * * Firebase Storage is a Google Cloud Storage bucket under the hood; this * adapter resolves a `firebase-admin` app, obtains its `@google-cloud/storage` * `Bucket`, and drives single-shot uploads through it. The part stream is * buffered and uploaded in one `file.save()` call. Use `getUploadUrl` for * direct-from-client large transfers. * @example * ```ts * import { FirebaseStorage } from "@visulima/storage/provider/firebase"; * * const storage = new FirebaseStorage({ * bucket: "my-project.appspot.com", * projectId: process.env.FIREBASE_PROJECT_ID, * credentials: { * clientEmail: process.env.FIREBASE_CLIENT_EMAIL, * privateKey: process.env.FIREBASE_PRIVATE_KEY, * }, * }); * ``` * @remarks * - ⚠️ Per-operation `signal`/`timeout` are best-effort: the underlying SDK does not support request cancellation, so an in-flight call may complete server-side even after abort. `retries` is honored. */ declare class FirebaseStorage extends BaseStorage { static override readonly name: string; override checksumTypes: string[]; protected meta: MetaStorage; private readonly bucket; private readonly bucketName; private readonly defaultUrlExpiresIn; private readonly publicBaseUrl?; constructor(config: FirebaseStorageOptions); override get raw(): FirebaseBucket; create(config: FileInit, _options?: OperationOptions): Promise; write(part: FilePart | FileQuery | FirebaseFile, options?: OperationOptions): Promise; delete({ id }: FileQuery, options?: OperationOptions): Promise; override exists({ id }: FileQuery, options?: OperationOptions): Promise; get({ id }: FileQuery, options?: OperationOptions): Promise; copy(name: string, destination: string, options?: OperationOptions & { storageClass?: string; }): Promise; move(name: string, destination: string, options?: OperationOptions): Promise; override list(limit?: number, options?: OperationOptions): Promise; override getReadUrl(key: string, options?: { expiresIn?: number; responseContentDisposition?: string; responseContentType?: string; }): Promise; override getUploadUrl(key: string, options?: { contentLength?: number; contentType?: string; expiresIn?: number; }): Promise; private static resolveApp; private getMetaSafe; private internalOnComplete; } export { FirebaseFile, FirebaseMetaStorage, FirebaseStorage, type FirebaseStorageOptions };