import { F as File, u as MetaStorageOptions, L as LocalMetaStorageOptions, i as BaseStorageOptions, M as MetaStorage, s as HttpError, 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 { RetryConfig } from 'gaxios'; import { GoogleAuthOptions, GoogleAuth } from 'google-auth-library'; import 'node:stream'; import 'node:timers'; import 'node:crypto'; import 'node:http'; import 'lru-cache'; declare const GCSConfig: Record; declare class GCSFile extends File { GCSUploadURI?: string; uri?: string; } interface StorageSettings { projectId: string; retryOptions?: RetryConfig; storageAPI?: string; uploadAPI?: string; useAuthWithCustomEndpoint?: boolean; userProject?: string; } interface ClientError extends Error { code: string; config: Record; response?: Record; } interface GCStorageOptions extends BaseStorageOptions, Omit, StorageSettings { /** * Google Cloud Storage bucket */ bucket?: string; /** * Force compatible client upload directly to GCS */ clientDirectUpload?: boolean; /** * Configure metafiles storage * @example * ```ts * Using local metafiles * const storage = new GCStorage({ * bucket: 'upload', * metaStorageConfig: { directory: '/tmp/upload-metafiles' } * }) * ``` * Using a separate bucket for metafiles * ```ts * const storage = new GCStorage({ * bucket: 'upload', * metaStorageConfig: { bucket: 'upload-metafiles' } * }) * ``` */ metaStorageConfig?: GCSMetaStorageOptions | LocalMetaStorageOptions; } interface GCSMetaStorageOptions extends MetaStorageOptions, Omit, StorageSettings { bucket?: string; } declare class GCSMetaStorage extends MetaStorage { readonly config: GCSMetaStorageOptions; private authClient; private readonly storageBaseURI; private readonly uploadBaseURI; private readonly isCustomEndpoint; private readonly retryOptions; private readonly useAuthWithCustomEndpoint; private readonly userProject; constructor(config: GCSMetaStorageOptions); override save(id: string, file: T): Promise; override delete(id: string): Promise; override get(id: string): Promise; override touch(id: string, file: T): Promise; private accessCheck; /** * Returns metafile URL path for the given upload ID. * @param id Upload ID to get metafile path for * @returns Full URL path to the metafile in GCS */ private getMetaPath; private makeRequest; } /** * Google cloud storage based backend. * @example * ```ts * const storage = new GCStorage({ * bucket: , * keyFile: , * metaStorage: new MetaStorage(), * clientDirectUpload: true, * maxUploadSize: '15GB', * allowMIME: ['video/*', 'image/*'], * filename: file => file.originalName * }); * ``` * @remarks * ## Supported Operations * - ✅ create, write, delete, get, list, update, copy, move * - ✅ Batch operations: deleteBatch, copyBatch, moveBatch (inherited from BaseStorage) * - ✅ exists: Implemented (checks metadata and GCS object) * - ❌ getStream: Not implemented (use get() for file retrieval) * - ❌ getUrl: Not implemented (GCS public URLs not supported) * - ❌ getUploadUrl: Not implemented (resumable upload URLs handled internally) */ declare class GCStorage extends BaseStorage { static override readonly name: string; override checksumTypes: string[]; override readonly supportsDelimiter: boolean; override get raw(): GoogleAuth; protected meta: MetaStorage; private readonly bucket; private authClient; private readonly storageBaseURI; private readonly uploadBaseURI; private readonly isCustomEndpoint; private readonly retryOptions; private readonly useAuthWithCustomEndpoint; private readonly userProject; constructor(config: GCStorageOptions); override normalizeError(error: ClientError): HttpError; create(config: FileInit, options?: OperationOptions): Promise; write(part: FilePart | FileQuery | GCSFile, options?: OperationOptions): Promise; /** * Deletes an upload and its metadata. * @param query File query containing the file ID to delete. * @param query.id File ID to delete. * @returns Promise resolving to the deleted file object with status: "deleted". * @throws {UploadError} If the file metadata cannot be found. */ delete({ id }: FileQuery, options?: OperationOptions): Promise; /** * Copies an upload file to a new location. * @param name Source file name/ID. * @param destination Destination file name/ID. * @returns Promise resolving to the copied file object. * @throws {UploadError} If the source file cannot be found. */ copy(name: string, destination: string, options?: OperationOptions & { storageClass?: string; }): Promise; /** * Moves an upload file to a new location. * @param name Source file name/ID. * @param destination Destination file name/ID. * @returns Promise resolving to the moved file object. * @throws {UploadError} If the source file cannot be found. */ move(name: string, destination: string, options?: OperationOptions): Promise; /** * Gets an uploaded file by ID with content buffer. * @param query File query object containing the file ID. * @param query.id Unique identifier of the file to retrieve. * @returns Promise resolving to file object with content buffer. * @throws {UploadError} If the file cannot be found (ERRORS.FILE_NOT_FOUND) or has expired (ERRORS.GONE). */ get({ id }: FileQuery, options?: OperationOptions): Promise; /** * Checks if a file exists by verifying both metadata and the actual GCS object. * Returns true only if both the metadata and the GCS object exist. * @param query File query containing the file ID to check. * @returns Promise resolving to true if both metadata and GCS object exist, false otherwise. */ override exists({ id }: FileQuery, options?: OperationOptions): Promise; override list(limit?: number, options?: OperationOptions): Promise; /** * Directory-style listing via the GCS JSON API's native `delimiter`/`prefix` — the API returns * the direct child objects in `items` and the common prefixes ("subdirectories") in `prefixes`, * so the subtree is never fully walked. Pages until exhausted or `limit` files are collected. */ override listDirectory(options?: OperationOptions & { delimiter: string; limit?: number; prefix?: string; }): Promise<{ files: GCSFile[]; prefixes: string[]; }>; protected internalWrite(part: GCSFile & Partial, callOptions?: OperationOptions): Promise; private internalOnComplete; /** * Merge a body-level abort signal with the caller's per-operation * `options.signal` so gaxios cancels the in-flight request on either. * `options.timeout` is handed to gaxios' native `timeout` instead of a * second `AbortSignal.timeout` to avoid two competing deadlines. */ private static buildCallSignal; private makeRequest; private accessCheck; } export { type ClientError, GCSConfig, GCSFile, GCSMetaStorage, type GCSMetaStorageOptions, GCStorage, type GCStorageOptions };