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 { drive_v3 } from '@googleapis/drive'; import 'node:stream'; import 'node:timers'; import 'node:crypto'; import 'node:http'; import 'lru-cache'; declare class GoogleDriveFile extends File { driveFileId?: string; mimeType?: string; publicUrl?: string; } declare class GoogleDriveMetaStorage extends LocalMetaStorage { constructor(config?: LocalMetaStorageOptions); } interface GoogleDriveStorageOptions extends BaseStorageOptions { /** * Pre-built `@googleapis/drive` v3 client. Escape hatch for callers that * have already wired auth (workload identity, ADC, etc.). When set, the * adapter uses it directly and `getUploadUrl()` will throw because there's * no stable way to recover the underlying auth handle. */ client?: drive_v3.Drive; /** * Inline service-account credentials. Mints a `JWT` auth client with * `https://www.googleapis.com/auth/drive` scope. Mutually exclusive with * the other auth shapes. */ credentials?: { client_email: string; private_key: string; }; /** * Shared Drive id. **Strongly recommended for service-account auth** — * service accounts have a 15 GB personal quota; production workloads * should target a Shared Drive with the service account added as a member. */ driveId?: string; /** * LRU capacity for the in-memory virtual-key → fileId cache. Drive has * no native key field; every read after the first round-trips a * `files.list` to resolve the id, which the cache amortizes. Defaults to * 1024. */ fileIdCacheSize?: number; /** * Path to a service-account JSON file. Mutually exclusive with the other * auth shapes. */ keyFilename?: string; /** * Configure metafiles storage. Defaults to local tmp directory. */ metaStorageConfig?: LocalMetaStorageOptions; /** * OAuth refresh token (3-legged OAuth, end-user Drive). The adapter mints * fresh access tokens against `clientId`/`clientSecret`. Mutually * exclusive with the other auth shapes. */ oauth?: { clientId: string; clientSecret: string; refreshToken: string; }; /** * When `true`, `write()` also creates an "anyone with link, reader" * permission and `getReadUrl()` returns the Drive public download URL. * When `false` (default), `getReadUrl()` throws — Drive has no signed-URL * primitive. */ publicByDefault?: boolean; /** * Logical "bucket root" — virtual keys live under this folder. Defaults * to `"root"` (My Drive root) or, when `driveId` is set, the Shared * Drive root id should be used here. */ rootFolderId?: string; /** * Domain-wide delegation subject (the user to impersonate). Only honored * with `credentials` or `keyFilename`. */ subject?: string; } /** * Google Drive storage backend. * * Drive is **not** a key-value store — it organizes files by `fileId`, and a * single virtual key (e.g. `"docs/report.pdf"`) can map to multiple Drive * files. The adapter routes by `appProperties.fsdkKey`, which it sets on * every upload and resolves via `files.list` on every read. An LRU cache * amortizes the resolve cost. * * **Auth precedence**: * 1. `client` (pre-built `drive_v3.Drive`) * 2. `credentials` (inline service account) * 3. `keyFilename` (service-account JSON path) * 4. `oauth` (refresh token + clientId/clientSecret) * 5. Env fallback: `GOOGLE_DRIVE_CLIENT_EMAIL` + `GOOGLE_DRIVE_PRIVATE_KEY`, or * `GOOGLE_DRIVE_KEY_FILE` (optional: `GOOGLE_DRIVE_SUBJECT` for DWD). * * **Limitations**: * - `getReadUrl()` only works with `publicByDefault: true` — Drive has no * signed-URL primitive. * - `responseContentDisposition` is not supported. * - `getUploadUrl()` requires explicit `credentials`/`keyFilename`/`oauth` * (not a pre-built `client`) so we can mint access tokens for the * resumable session. * - ⚠️ 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 GoogleDriveStorage extends BaseStorage { static override readonly name: string; override checksumTypes: string[]; protected meta: MetaStorage; private readonly authForTokens; private readonly driveClient; private readonly fileIdCache; private readonly publicByDefault; private readonly rootFolderId; private readonly sharedDriveParams; constructor(config: GoogleDriveStorageOptions); override get raw(): drive_v3.Drive; create(config: FileInit, _options?: OperationOptions): Promise; write(part: FilePart | FileQuery | GoogleDriveFile, options?: OperationOptions): Promise; delete({ 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 resolveFileId; private internalOnComplete; } export { GoogleDriveFile, GoogleDriveMetaStorage, GoogleDriveStorage, type GoogleDriveStorageOptions };