import { P as Part, S as S3CallOptions, a as S3ApiOperations, b as S3BaseStorage } from "../../packem_shared/s3-base-storage.d-BmuspwCF.js"; import { F as File, u as MetaStorageOptions, i as BaseStorageOptions, M as MetaStorage, s as HttpError, f as FileQuery, O as OperationOptions, d as FileInit } from "../../packem_shared/storage.d-C9EdfTf1.js"; import { Readable } from 'node:stream'; import { AwsClient } from 'aws4fetch'; import 'node:timers'; import 'node:crypto'; import 'node:http'; import 'lru-cache'; declare class AwsLightFile extends File { Parts?: Part[]; UploadId?: string; uri?: string; partsUrls?: string[]; partSize?: number; } interface AwsLightClientConfig { accessKeyId: string; endpoint?: string; region: string; secretAccessKey: string; service?: string; sessionToken?: string; } type AwsLightMetaStorageOptions = AwsLightClientConfig & MetaStorageOptions & { bucket?: string; }; type AwsLightStorageOptions = AwsLightClientConfig & BaseStorageOptions & { /** * S3 bucket name. */ bucket?: string; /** * Force compatible client upload directly to S3 storage */ clientDirectUpload?: boolean; /** * Configure metafiles storage */ metaStorageConfig?: AwsLightMetaStorageOptions; /** * The parts size that the client should use for presigned multipart unloading. * @default '16MB' */ partSize?: number | string; }; interface AwsLightError extends Error { code?: string; requestId?: string; statusCode?: number; } /** * AWS Light meta storage implementation using aws4fetch. * Stores metadata in S3 object metadata headers (x-amz-meta-*). * Optimized for worker environments (Cloudflare Workers, Web Workers, etc.). */ declare class AwsLightMetaStorage extends MetaStorage { config: AwsLightMetaStorageOptions; private readonly adapter; private readonly bucket; constructor(config: AwsLightMetaStorageOptions); override get(id: string): Promise; override touch(id: string, file: T): Promise; override delete(id: string): Promise; override save(id: string, file: T): Promise; } /** * Adapter that uses aws4fetch to implement S3ApiOperations interface. */ declare class AwsLightApiAdapter implements S3ApiOperations { aws: AwsClient; private readonly bucket; private readonly endpoint; constructor(config: AwsLightClientConfig & { bucket: string; }); createMultipartUpload(params: { ACL?: string; Bucket: string; ContentType?: string; Key: string; Metadata?: Record; }, options?: S3CallOptions): Promise<{ UploadId: string; }>; uploadPart(params: { Body: Readable | ReadableStream | Uint8Array; Bucket: string; ContentLength?: number; ContentMD5?: string; Key: string; PartNumber: number; UploadId: string; }, options?: S3CallOptions): Promise<{ ETag: string; }>; completeMultipartUpload(params: { Bucket: string; Key: string; Parts: { ETag: string; PartNumber: number; }[]; UploadId: string; }, options?: S3CallOptions): Promise<{ ETag?: string; Location: string; }>; abortMultipartUpload(params: { Bucket: string; Key: string; UploadId: string; }, options?: S3CallOptions): Promise; listParts(params: { Bucket: string; Key: string; UploadId: string; }, options?: S3CallOptions): Promise<{ Parts?: Part[]; }>; getObject(params: { Bucket: string; Key: string; }, options?: S3CallOptions): Promise<{ Body?: ReadableStream | Readable; ContentLength?: number; ContentType?: string; ETag?: string; Expires?: Date; LastModified?: Date; Metadata?: Record; }>; headObject(params: { Bucket: string; Key: string; }, options?: S3CallOptions): Promise<{ ContentLength?: number; ContentType?: string; ETag?: string; Expires?: Date; LastModified?: Date; Metadata?: Record; }>; deleteObject(params: { Bucket: string; Key: string; }, options?: S3CallOptions): Promise; copyObject(params: { Bucket: string; CopySource: string; Key: string; StorageClass?: string; }, options?: S3CallOptions): Promise; 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; }>; getPresignedUrl(params: { Bucket: string; expiresIn: number; Key: string; PartNumber: number; UploadId: string; }): Promise; putObject(params: { Body?: Uint8Array | ReadableStream; Bucket: string; ContentLength?: number; ContentType?: string; Key: string; Metadata?: Record; }): Promise; checkBucketAccess(_params: { Bucket: string; }): Promise; /** * Builds S3 API URL. */ private buildUrl; /** * Converts ReadableStream to Readable for Node.js compatibility. */ private streamToReadable; } /** * AWS Light storage implementation using aws4fetch. * Optimized for worker environments (Cloudflare Workers, Web Workers, etc.). * @example * ```ts * const storage = new AwsLightStorage({ * bucket: , * region: , * accessKeyId: , * secretAccessKey: * }); * ``` * @remarks * ## Worker Compatibility * - Uses aws4fetch for AWS request signing (works in workers) * - No Node.js-specific dependencies * - Compatible with Cloudflare Workers, Web Workers, and edge runtimes * * ## Error Handling * - S3 API errors are normalized with AWS-specific context * - Errors include S3 error codes and status codes for debugging * * ## Retry Behavior * - All S3 API calls are wrapped with configurable retry logic via `retryConfig` option * - Default retryable status codes: 408, 429, 500, 502, 503, 504 * - Custom `shouldRetry` function can be provided for advanced retry logic * * ## Multipart Uploads * - Large files are automatically split into multipart uploads * - Maximum 10,000 parts per upload (S3 limitation) * - Part size is configurable (default: 16MB, minimum: 5MB) * - Failed multipart uploads are automatically aborted * * ## Supported Operations * - ✅ create, write, delete, get, getStream, list, update, copy, move * - ✅ Batch operations: deleteBatch, copyBatch, moveBatch (inherited from BaseStorage) * - ✅ exists: Implemented (checks metadata and S3 object) * - ⚠️ getUrl/getUploadUrl: Limited presigned URL support (uses aws4fetch signing) */ declare class AwsLightStorage extends S3BaseStorage { static override readonly name: string; private s3Api; constructor(config: AwsLightStorageOptions); /** * Normalizes AWS S3 errors with S3-specific context. */ override normalizeError(error: AwsLightError | Error): HttpError; override update({ id }: FileQuery, metadata: Partial): Promise; override getStream({ id }: FileQuery, options?: OperationOptions): Promise<{ headers?: Record; size?: number; stream: Readable; }>; override get raw(): AwsClient; protected getS3Api(): AwsLightApiAdapter; protected getFileClass(): new (config: FileInit) => AwsLightFile; protected getAcl(): string | undefined; protected accessCheck(_maxWaitTime?: number): Promise; } export { type AwsLightClientConfig, type AwsLightError, AwsLightFile, AwsLightMetaStorage, type AwsLightMetaStorageOptions, AwsLightStorage, type AwsLightStorageOptions };