import { Buffer } from 'node:buffer'; import type { ChecksumOptions, DirectoryListing, FileContents, GetStreamOptions, ListOptions, MimeTypeOptions, PresignedUploadPolicy, PresignedUploadPolicyOptions, PresignedUploadUrl, PresignedUploadUrlOptions, PublicUrlOptions, PutResult, PutStreamOptions, SignedUrlOptions, StatEntry, StorageAdapter, StorageAdapterConfig, TemporaryUrlOptions, Visibility } from '../types'; import type { S3Client } from '@stacksjs/ts-cloud'; /** * Build ts-cloud `S3ClientOptions` from adapter config, or `undefined` for a * plain AWS S3 client. The config endpoint may carry a scheme * (`https://s3.filebase.com`); ts-cloud wants a scheme-less host, so it's * stripped here. This is what routes the adapter to S3-compatible providers - * Filebase, Backblaze B2, Cloudflare R2, Hetzner Object Storage * (stacksjs/stacks#938, #1897, #1896). */ export declare function resolveS3ClientOptions(config: { endpoint?: string usePathStyleEndpoint?: boolean credentials?: { accessKeyId: string, secretAccessKey: string, sessionToken?: string } }): S3ClientOptions | undefined; /** * Create an S3 storage adapter instance */ export declare function createS3Storage(client: S3Client | null, config: StorageAdapterConfig): S3StorageAdapter; /** * Options for the ts-cloud S3 client. Mirrors ts-cloud's internal * `S3ClientOptions` (declared but not re-exported from its package root); * structural typing lets this satisfy the `S3Client` constructor's 3rd argument. */ declare interface S3ClientOptions { endpoint?: string forcePathStyle?: boolean credentials?: { accessKeyId: string, secretAccessKey: string, sessionToken?: string } } /** * Append-and-take byte buffer used by the multipart pipeline * (stacksjs/stacks#1886). Holds incoming chunks until they reach * the configured part size, then yields them as a single Uint8Array * via `take(n)` or `flush()`. */ declare class ChunkBuffer { constructor(_partSize: number); get length(): number; push(c: Uint8Array): void; take(n: number): Uint8Array; flush(): Uint8Array; } /** * AWS S3 storage adapter using ts-cloud S3Client */ export declare class S3StorageAdapter implements StorageAdapter { constructor(client: S3Client | null, config: StorageAdapterConfig); write(path: string, contents: FileContents): Promise; read(path: string): Promise; getStream(path: string, _options?: GetStreamOptions): Promise>; putStream(path: string, stream: ReadableStream, options?: PutStreamOptions): Promise; readToString(path: string): Promise; readToBuffer(path: string): Promise; readToUint8Array(path: string): Promise; deleteFile(path: string): Promise; deleteDirectory(path: string): Promise; createDirectory(_path: string): Promise; moveFile(from: string, to: string): Promise; copyFile(from: string, to: string): Promise; stat(path: string): Promise; list(path: string, options?: ListOptions): DirectoryListing; changeVisibility(path: string, vis: Visibility): Promise; visibility(path: string): Promise; fileExists(path: string): Promise; directoryExists(path: string): Promise; publicUrl(path: string, options?: PublicUrlOptions): Promise; temporaryUrl(path: string, options: TemporaryUrlOptions): Promise; signedUrl(path: string, options: SignedUrlOptions): Promise; presignedUploadUrl(options: PresignedUploadUrlOptions): Promise; presignedUploadPolicy(options: PresignedUploadPolicyOptions): Promise; checksum(path: string, options?: ChecksumOptions): Promise; mimeType(path: string, _options?: MimeTypeOptions): Promise; lastModified(path: string): Promise; fileSize(path: string): Promise; }