import { F as File, s as MetaStorageOptions, L as LocalMetaStorageOptions, f as BaseStorageOptions, M as MetaStorage, e as FileInit, O as OperationOptions, h as FilePart, i as FileQuery, c as FileReturn, S as StoredObject, B as BaseStorage } from "../../packem_shared/storage.d-Cnjmzau5.js"; import { RetryConfig } from 'gaxios'; import { GoogleAuthOptions, GoogleAuth } from 'google-auth-library'; import { b as HttpError } from "../../packem_shared/types.d-DFh9698o.js"; import 'node:stream'; import 'lru-cache'; import 'node:crypto'; import 'node:http'; 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; /** Uses `ifGenerationMatch` preconditions. */ override readonly supportsConditionalSave: boolean; private authClient; private readonly storageBaseURI; private readonly uploadBaseURI; private readonly isCustomEndpoint; private readonly retryOptions; private readonly useAuthWithCustomEndpoint; private readonly userProject; private readonly bucketName; constructor(config: GCSMetaStorageOptions); override save(id: string, file: T): Promise; override saveIfVersion(id: string, file: T, version: string): Promise; override delete(id: string): Promise; override get(id: string): Promise; /** * Every record in the bucket, page by page: the uploads purge checks, including unfinished * ones (no object yet) and those stored under a custom filename. */ override list(): Promise; override touch(id: string, file: T): Promise; private upload; /** * 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, listDirectory (native delimiter), update, copy, move * - ✅ Deferred upload length (TUS creation-defer-length): the session learns the total from the last chunk * - ✅ clientDirectUpload: `create()` returns the resumable session URI as `GCSUploadURI` * - ✅ Batch operations: deleteBatch, copyBatch, moveBatch (inherited from BaseStorage) * - ✅ exists: Implemented (checks metadata and GCS object) * - ❌ getStream: Not implemented natively (falls back to get()) * - ❌ getReadUrl / getUploadUrl: Not implemented */ declare class GCStorage extends BaseStorage { static override readonly name: string; override readonly storageKind: string; /** Parts are appended in order (see assertContiguousWrite). */ override readonly sequentialWrites: boolean; /** A part's length goes into the provider request before its bytes, so it must be known. */ override readonly requiresContentLength: boolean; /** * GCS resumable uploads only verify whole-object hashes on finalize, never a single chunk, * so no per-write checksum algorithm can be honoured. */ 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; protected override statObject(id: string, options?: OperationOptions): Promise; /** * Whether an upload's object exists: the one its metadata names, or, for an ID without metadata * (a copied object, or one written by other means), the object stored under it. Only a missing * object answers `false`; any other failure throws. */ 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; /** * 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; /** The JSON API takes the object name as one path segment, so a "/" in it must be encoded. */ private objectUrl; /** Upload metadata sidecars share the bucket with the files. */ private isMetaObject; private accessCheck; } export { type ClientError, GCSConfig, GCSFile, GCSMetaStorage, type GCSMetaStorageOptions, GCStorage, type GCStorageOptions };