import { drive_v3 } from '@googleapis/drive'; import { Adapter, FilesError } from '../index.js'; interface GoogleDriveAdapterOptions { /** * 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; }; /** * Path to a service-account JSON file. Mutually exclusive with the other * auth shapes. */ keyFilename?: string; /** * 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; }; /** * Pre-built `@googleapis/drive` v3 client — escape hatch for callers that * have already wired auth (workload identity, ADC, etc.). When passed, * the adapter uses it directly. `signedUploadUrl()` requires an auth * handle to mint access tokens for the resumable session POST; if you * use this escape hatch, that method will throw because we can't * recover the underlying auth from the wrapped client in a stable way. */ client?: drive_v3.Drive; /** * Domain-wide delegation subject (the user to impersonate). Only honored * with `credentials` or `keyFilename`. */ subject?: 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. When set, all queries scope to that Shared Drive. */ driveId?: string; /** * 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; /** * When `true`, `upload()` also creates an `anyone with link, reader` * permission and `url()` returns the Drive public download URL. When * `false` (default), `url()` throws — Drive has no signed URL primitive. * * Security note: this is public-by-default for the entire adapter * lifetime. If you need a mix of public and private files, instantiate * two `Files` instances or grant permissions explicitly via `raw`. */ publicByDefault?: boolean; /** * 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 within a * single adapter instance. Defaults to 1024. */ fileIdCacheSize?: number; } type GoogleDriveClient = drive_v3.Drive; type GoogleDriveAdapter = Adapter & { readonly rootFolderId: string; }; declare const mapDriveError: (err: unknown) => FilesError; declare const googleDrive: (opts?: GoogleDriveAdapterOptions) => GoogleDriveAdapter; export { type GoogleDriveAdapter, type GoogleDriveAdapterOptions, type GoogleDriveClient, googleDrive, mapDriveError };