The best way to control Claude Code, Codex and more from any computer or phone

main
ts 43 lines 1.66 KB
Raw
1 import type * as storage from "@distilled.cloud/gcp/storage_v1";
2 import * as Binding from "alchemy/Binding";
3 import type { RuntimeContext } from "alchemy/RuntimeContext";
4 import type * as Effect from "effect/Effect";
5 import type { Bucket } from "./Bucket.ts";
6 import type { ObjectNotFound, ObjectRequestFailed, PutObjectContent } from "./ObjectMedia.ts";
7
8 /** Write-only client for one Cloud Storage bucket. */
9 export interface WriteBucketClient {
10 /** Upload (or overwrite) an object. `ObjectNotFound` means the bucket is gone. */
11 put(
12 name: string,
13 body: string | Uint8Array,
14 options?: Omit<PutObjectContent, "name" | "body">,
15 ): Effect.Effect<storage.Storage_Object, ObjectNotFound | ObjectRequestFailed, RuntimeContext>;
16 /** Delete an object. Deleting a missing object succeeds. */
17 delete(object: string): Effect.Effect<void, storage.DeleteObjectsError, RuntimeContext>;
18 }
19
20 /**
21 * Write access to a Cloud Storage {@link Bucket}: `put`, `delete`.
22 * Grants `roles/storage.objectUser` on the bucket only (overwriting needs
23 * delete, which `objectCreator` lacks).
24 *
25 * ### Writing to a bucket
26 * **Example:** Upload and delete
27 * ```typescript
28 * const uploads = yield* GCP.Storage.WriteBucket(bucket);
29 * yield* uploads.put("hello.txt", "Hello!", { contentType: "text/plain" });
30 * yield* uploads.delete("old.txt");
31 * // …provided with Effect.provide(GCP.Storage.WriteBucketHttp)
32 * ```
33 *
34 * @binding
35 * @category Storage
36 */
37 export interface WriteBucket extends Binding.Service<
38 WriteBucket,
39 "GCP.Storage.WriteBucket",
40 (bucket: Bucket) => Effect.Effect<WriteBucketClient>
41 > {}
42
43 export const WriteBucket = Binding.Service<WriteBucket>("GCP.Storage.WriteBucket");