1import * as Effect from "effect/Effect";
2import * as Binding from "../Binding.ts";
3import type { Bucket } from "./Bucket.ts";
4import type {
5 RuntimeStorageMethods,
6 StorageBindingOptions,
7} from "./StorageBinding.ts";
8
9export interface ReadBucketClient extends RuntimeStorageMethods<
10 "get" | "head" | "list"
11> {
12 /** Presign an object download. This does not make the bucket public. */
13 presignGet(
14 key: string,
15 options?: { expiresIn?: number },
16 ): ReturnType<RuntimeStorageMethods<"presign">["presign"]>;
17}
18
19/**
20 * Read/list storage on a branch. The bucket name limits this client's surface,
21 * not credential authorization. Injected Function credentials remain available
22 * to the entire process; this is not a Function-level security sandbox.
23 *
24 * ### Read Objects
25 * **Example:** Bind a bucket in Function initialization
26 * ```typescript
27 * const files = yield* Neon.ReadBucket(uploads);
28 * const object = yield* files.get("welcome.txt");
29 * ```
30 *
31 * @binding
32 * @product Bucket
33 */
34export interface ReadBucket extends Binding.Service<
35 ReadBucket,
36 "Neon.ReadBucket",
37 (
38 bucket: Bucket,
39 options?: StorageBindingOptions,
40 ) => Effect.Effect<ReadBucketClient>
41> {}
42export const ReadBucket = Binding.Service<ReadBucket>("Neon.ReadBucket");