import { Readable } from 'node:stream'; import { F as File, M as MetaStorage, c as createRetryWrapper, R as RetryConfig, d as FileInit, B as BaseStorage, O as OperationOptions, e as FilePart, f as FileQuery, g as FileReturn } from "./storage.d-C9EdfTf1.js"; /** * Part interface for multipart uploads. */ interface Part { ETag?: string; PartNumber: number; Size?: number; } /** * Base file type for S3-compatible storage. */ interface S3CompatibleFile extends File { Parts?: Part[]; partSize?: number; partsUrls?: string[]; UploadId?: string; uri?: string; } /** * Per-call options forwarded to the underlying AWS SDK send(). */ interface S3CallOptions { /** Forwarded to `client.send(command, { abortSignal })`. */ signal?: AbortSignal; } /** * S3 API operations interface that must be implemented by concrete storage classes. */ interface S3ApiOperations { abortMultipartUpload: (params: { Bucket: string; Key: string; UploadId: string; }, options?: S3CallOptions) => Promise; checkBucketAccess: (params: { Bucket: string; }) => Promise; completeMultipartUpload: (params: { Bucket: string; Key: string; Parts: { ETag: string; PartNumber: number; }[]; UploadId: string; }, options?: S3CallOptions) => Promise<{ ETag?: string; Location: string; }>; copyObject: (params: { Bucket: string; CopySource: string; Key: string; StorageClass?: string; }, options?: S3CallOptions) => Promise; createMultipartUpload: (params: { ACL?: string; Bucket: string; ContentType?: string; Key: string; Metadata?: Record; }, options?: S3CallOptions) => Promise<{ UploadId: string; }>; deleteObject: (params: { Bucket: string; Key: string; }, options?: S3CallOptions) => Promise; getObject: (params: { Bucket: string; Key: string; Range?: string; }, options?: S3CallOptions) => Promise<{ Body?: ReadableStream | Readable; ContentLength?: number; ContentType?: string; ETag?: string; Expires?: Date; LastModified?: Date; Metadata?: Record; }>; getPresignedUrl: (params: { Bucket: string; expiresIn: number; Key: string; PartNumber: number; UploadId: string; }) => Promise; headObject: (params: { Bucket: string; Key: string; }, options?: S3CallOptions) => Promise<{ ContentLength?: number; ContentType?: string; ETag?: string; Expires?: Date; LastModified?: Date; Metadata?: Record; }>; listObjectsV2: (params: { Bucket: string; ContinuationToken?: string; Delimiter?: string; MaxKeys?: number; Prefix?: string; }, options?: S3CallOptions) => Promise<{ CommonPrefixes?: { Prefix?: string; }[]; Contents?: { Key?: string; LastModified?: Date; }[]; IsTruncated?: boolean; NextContinuationToken?: string; }>; listParts: (params: { Bucket: string; Key: string; UploadId: string; }, options?: S3CallOptions) => Promise<{ Parts?: Part[]; }>; uploadPart: (params: { Body: Readable | ReadableStream | Uint8Array; Bucket: string; ContentLength?: number; ContentMD5?: string; Key: string; PartNumber: number; UploadId: string; }, options?: S3CallOptions) => Promise<{ ETag: string; }>; } /** * Base class for S3-compatible storage implementations. * Contains all shared business logic for S3 operations. * @template TFile The file type used by this storage backend. */ declare abstract class S3BaseStorage extends BaseStorage { override checksumTypes: string[]; override readonly supportsRange: boolean; override readonly supportsDelimiter: boolean; protected bucket: string; protected meta: MetaStorage; /** * S3 multipart upload does not allow more than 10000 parts. */ protected readonly MAX_PARTS = 1e4; protected readonly partSize: number; protected readonly retry: ReturnType; protected readonly resolvedRetryConfig: RetryConfig; /** * Abstract method to get S3 API operations implementation. */ protected abstract getS3Api(): S3ApiOperations; /** * Abstract method to get the file class constructor. */ protected abstract getFileClass(): new (config: FileInit) => TFile; /** * Abstract method to get ACL value. */ protected abstract getAcl(): string | undefined; /** * Abstract method for access check. */ protected abstract accessCheck(maxWaitTime?: number): Promise; constructor(config: { bucket: string; clientDirectUpload?: boolean; expiration?: { maxAge?: string; }; filename?: (file: TFile) => string; logger?: BaseStorage["logger"]; metaStorage?: MetaStorage; metaStorageConfig?: unknown; partSize?: number | string; retryConfig?: RetryConfig; }); protected override getRetryConfig(): RetryConfig; /** * Creates a new S3 multipart upload. */ create(config: FileInit, options?: OperationOptions): Promise; /** * Writes data to an S3 multipart upload. */ write(part: FilePart | FileQuery | TFile, options?: OperationOptions): Promise; /** * Deletes an upload and its metadata. */ delete({ id }: FileQuery, options?: OperationOptions): Promise; /** * Copies an upload file to a new location. */ copy(name: string, destination: string, options?: OperationOptions & { storageClass?: string; }): Promise; /** * Moves an upload file to a new location. */ move(name: string, destination: string, options?: OperationOptions): Promise; /** * Lists files in the bucket. */ override list(limit?: number, options?: OperationOptions): Promise; /** * Directory-style listing via S3's native `Delimiter`/`Prefix` — the provider returns the direct * child objects plus the `CommonPrefixes` ("subdirectories") one delimiter level below `prefix`, * so the whole subtree never has to be fetched. Pages until exhausted or `limit` direct files * have been collected; common prefixes are accumulated (deduped) across pages. */ override listDirectory(options?: OperationOptions & { delimiter: string; limit?: number; prefix?: string; }): Promise<{ files: TFile[]; prefixes: string[]; }>; /** * Checks if a file exists by verifying both metadata and the actual S3 object. * Returns true only if both the metadata and the S3 object exist. * @param query File query containing the file ID to check. * @returns Promise resolving to true if both metadata and S3 object exist, false otherwise. */ override exists({ id }: FileQuery, options?: OperationOptions): Promise; /** * Gets an uploaded file by ID. */ get({ id }: FileQuery, options?: OperationOptions & { range?: { end?: number; start: number; }; }): Promise; /** * Gets file stream (abstract - must be implemented by subclasses due to stream differences). */ abstract override getStream(query: FileQuery, options?: OperationOptions): Promise<{ headers?: Record; size?: number; stream: Readable; }>; /** * Builds presigned URLs for client uploads. */ protected buildPresigned(file: TFile): Promise; /** * Gets presigned URLs for all parts. */ protected getPartsPresignedUrls(file: TFile): Promise; /** * Gets parts for a multipart upload. */ protected getParts(file: TFile): Promise; /** * Completes a multipart upload. */ protected completeMultipartUpload(file: TFile): Promise<{ ETag?: string; Location: string; }>; /** * Aborts a multipart upload. */ protected abortMultipartUpload(file: TFile, options?: OperationOptions): Promise; /** * Internal onComplete handler. */ protected internalOnComplete: (file: TFile) => Promise<[{ ETag?: string; Location: string; }, TFile]>; } export { Part as P, S3CallOptions as S, S3ApiOperations as a, S3BaseStorage as b };