| 1 | import type * as runtime from "@cloudflare/workers-types"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { RuntimeContext } from "../../RuntimeContext.ts"; |
| 5 | import type { Bucket } from "./Bucket.ts"; |
| 6 | import type { |
| 7 | R2Error, |
| 8 | GetOptions, |
| 9 | ListOptions, |
| 10 | R2Object, |
| 11 | ObjectBody, |
| 12 | Objects, |
| 13 | } from "./BucketTypes.ts"; |
| 14 | |
| 15 | /** |
| 16 | * @binding |
| 17 | * @product R2 |
| 18 | * @category Storage & Databases |
| 19 | */ |
| 20 | export interface ReadBucket extends Binding.Service< |
| 21 | ReadBucket, |
| 22 | "Cloudflare.R2.ReadBucket", |
| 23 | (bucket: Bucket) => Effect.Effect<ReadBucketClient> |
| 24 | > {} |
| 25 | |
| 26 | export const ReadBucket = Binding.Service<ReadBucket>( |
| 27 | "Cloudflare.R2.ReadBucket", |
| 28 | ); |
| 29 | |
| 30 | export interface ReadBucketClient { |
| 31 | raw: Effect.Effect<runtime.R2Bucket, never, RuntimeContext>; |
| 32 | head(key: string): Effect.Effect<R2Object | null, R2Error, RuntimeContext>; |
| 33 | get( |
| 34 | key: string, |
| 35 | options: GetOptions & { |
| 36 | onlyIf: runtime.R2Conditional | Headers; |
| 37 | }, |
| 38 | ): Effect.Effect<ObjectBody | R2Object | null, R2Error, RuntimeContext>; |
| 39 | get( |
| 40 | key: string, |
| 41 | options?: GetOptions, |
| 42 | ): Effect.Effect<ObjectBody | null, R2Error, RuntimeContext>; |
| 43 | list(options?: ListOptions): Effect.Effect<Objects, R2Error, RuntimeContext>; |
| 44 | } |