/// /// /// import type { ReadStream } from 'node:fs'; import { DeleteObjectCommandOutput, CompleteMultipartUploadCommandOutput, AbortMultipartUploadCommandOutput, S3ClientConfig, ObjectCannedACL, StorageClass, ServerSideEncryption } from '@aws-sdk/client-s3'; import type { AwsCredentialIdentity } from '@aws-sdk/types'; /** * Supported checksum algorithms for data integrity validation. * CRC64NVME is recommended for best performance on modern hardware. */ export type SupportedChecksumAlgorithm = 'CRC32' | 'CRC32C' | 'SHA1' | 'SHA256' | 'CRC64NVME'; /** * Supported S3 storage classes for cost optimization. */ export type SupportedStorageClass = 'STANDARD' | 'REDUCED_REDUNDANCY' | 'STANDARD_IA' | 'ONEZONE_IA' | 'INTELLIGENT_TIERING' | 'GLACIER' | 'DEEP_ARCHIVE' | 'GLACIER_IR'; /** * Server-side encryption types. */ export type EncryptionType = 'AES256' | 'aws:kms' | 'aws:kms:dsse'; /** * Encryption configuration for server-side encryption. */ export interface EncryptionConfig { type: EncryptionType; kmsKeyId?: string; } /** * Multipart upload configuration for large files. */ export interface MultipartConfig { partSize?: number; queueSize?: number; leavePartsOnError?: boolean; } export interface File { name: string; alternativeText?: string; caption?: string; width?: number; height?: number; formats?: Record; hash: string; ext?: string; mime: string; size: number; sizeInBytes: number; url: string; previewUrl?: string; path?: string; provider?: string; provider_metadata?: Record; stream?: ReadStream; buffer?: Buffer; etag?: string; } export type UploadCommandOutput = (CompleteMultipartUploadCommandOutput | AbortMultipartUploadCommandOutput) & { Location?: string; ETag?: string; }; export interface AWSParams { Bucket: string; ACL?: ObjectCannedACL; signedUrlExpires?: number; } /** * Extended configuration options for the S3 provider. */ export interface ProviderConfig { /** * Checksum algorithm for data integrity validation during upload. * When enabled, the SDK calculates a checksum and S3 validates it server-side. */ checksumAlgorithm?: SupportedChecksumAlgorithm; /** * When true, uploads will fail if an object with the same key already exists. * This prevents accidental overwrites due to race conditions. */ preventOverwrite?: boolean; /** * S3 storage class for uploaded objects. * Use lower-cost classes for infrequently accessed data. */ storageClass?: SupportedStorageClass; /** * Server-side encryption configuration. */ encryption?: EncryptionConfig; /** * Tags to apply to uploaded objects. * Useful for cost allocation and lifecycle policies. */ tags?: Record; /** * Multipart upload configuration for large files. */ multipart?: MultipartConfig; } export interface DefaultOptions extends S3ClientConfig { accessKeyId?: AwsCredentialIdentity['accessKeyId']; secretAccessKey?: AwsCredentialIdentity['secretAccessKey']; credentials?: AwsCredentialIdentity; params?: AWSParams; [k: string]: unknown; } export type InitOptions = (DefaultOptions | { s3Options: DefaultOptions; }) & { baseUrl?: string; rootPath?: string; providerConfig?: ProviderConfig; [k: string]: unknown; }; declare const _default: { init({ baseUrl, rootPath, s3Options, providerConfig, ...legacyS3Options }: InitOptions): { /** * Returns whether the bucket is configured with private ACL. */ isPrivate(): boolean; /** * Returns the current provider configuration. */ getProviderConfig(): ProviderConfig | undefined; /** * Generates a signed URL for accessing a private object. */ getSignedUrl(file: File, customParams: any): Promise<{ url: string; }>; /** * Uploads a file using streaming. */ uploadStream(file: File, customParams?: {}): Promise; /** * Uploads a file to S3. */ upload(file: File, customParams?: {}): Promise; /** * Uploads a file only if it matches the expected ETag (optimistic locking). * Throws PreconditionFailed error if ETag does not match. */ uploadIfMatch(file: File, expectedETag: string, customParams?: {}): Promise; /** * Retrieves object metadata including ETag. */ getObjectMetadata(file: File): Promise<{ etag: string | undefined; contentLength: number | undefined; contentType: string | undefined; lastModified: Date | undefined; storageClass: StorageClass | undefined; serverSideEncryption: ServerSideEncryption | undefined; }>; /** * Checks if an object exists in the bucket. */ objectExists(file: File): Promise; /** * Deletes an object from S3. */ delete(file: File, customParams?: {}): Promise; }; }; export default _default; //# sourceMappingURL=index.d.ts.map