import { PresignR2Creds } from "./presign-s3compat.js";
import { R2PutBucket } from "./r2-binding.js";
import { StorageAdapter, StorageError } from "./storage.js";
//#region src/storage-r2.d.ts
interface R2HttpMetadataLike {
  contentType?: string;
  cacheControl?: string;
}
interface R2ObjectLike {
  key: string;
  size: number;
  etag: string;
  httpMetadata?: R2HttpMetadataLike;
  customMetadata?: Record<string, string>;
  uploaded?: Date;
}
interface R2ObjectBodyLike extends R2ObjectLike {
  body: ReadableStream<Uint8Array>;
}
interface R2ListLike {
  objects: R2ObjectLike[];
  truncated: boolean;
  cursor?: string;
}
/** Structural R2Bucket surface the adapter consumes. The native Workers `R2Bucket` satisfies it. */
interface R2StorageBucket extends R2PutBucket {
  get(key: string): Promise<R2ObjectBodyLike | null>;
  head(key: string): Promise<R2ObjectLike | null>;
  delete(key: string): Promise<void>;
  list(opts?: {
    prefix?: string;
    cursor?: string;
    limit?: number;
  }): Promise<R2ListLike>;
}
interface CreateR2StorageOptions {
  bucket: R2StorageBucket;
  /** S3-API creds for presign — R2 native binding cannot presign. Omit on public-bucket hosts. */
  presign?: PresignR2Creds;
}
/** CF R2 StorageAdapter — the mod-cms production backend. Wraps the existing putObject/presignR2Put leaves. */
declare function createR2Storage(options: CreateR2StorageOptions): StorageAdapter;
//#endregion
export { CreateR2StorageOptions, R2StorageBucket, StorageError, createR2Storage };