Open History to see the last commit
1import * as Binding from "alchemy/Binding";
2import * as Effect from "effect/Effect";
3import type { Bucket } from "./Bucket.ts";
4import type { RuntimeStorageMethods, StorageBindingOptions } from "./StorageBinding.ts";
5
6export interface WriteBucketClient extends RuntimeStorageMethods<
7 | "put"
8 | "delete"
9 | "deleteMany"
10 | "createMultipartUpload"
11 | "uploadPart"
12 | "completeMultipartUpload"
13 | "abortMultipartUpload"
14 | "listMultipartUploads"
15 | "listParts"
16> {
17 /** Presign an upload; the uploader must send the signed content type. */
18 presignPut(
19 key: string,
20 options?: { expiresIn?: number; contentType?: string },
21 ): ReturnType<RuntimeStorageMethods<"presign">["presign"]>;
22}
23
24/**
25 * Mutate a bucket. Managed clients request storage:read and storage:write because
26 * the current S3 service requires explicit read scope, despite the documented
27 * write-implies-read contract. Credentials reach descendant branches.
28 *
29 * ### Upload Objects
30 * **Example:** Raw bytes without manual credential handling
31 * ```typescript
32 * const files = yield* Neon.WriteBucket(uploads);
33 * yield* files.put("message.txt", "hello", { ContentType: "text/plain" });
34 * ```
35 *
36 * @binding
37 * @product Bucket
38 */
39export interface WriteBucket extends Binding.Service<
40 WriteBucket,
41 "Neon.WriteBucket",
42 (bucket: Bucket, options?: StorageBindingOptions) => Effect.Effect<WriteBucketClient>
43> {}
44export const WriteBucket = Binding.Service<WriteBucket>("Neon.WriteBucket");