The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 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 | export type PutObjectRequest = PutObjectContent; |
| 9 | |
| 10 | /** |
| 11 | * Runtime binding that uploads an object's content to a Cloud Storage |
| 12 | * {@link Bucket} (multipart `objects.insert`), overwriting any live object |
| 13 | * with the same name. Grants `roles/storage.objectUser` on the bucket |
| 14 | * (overwrite needs delete permission, which `objectCreator` lacks). |
| 15 | * |
| 16 | * Bind this operation to a {@link Bucket} in a Function/Action init phase. |
| 17 | * Provide {@link PutObjectHttp}. |
| 18 | * |
| 19 | * ### Writing Objects |
| 20 | * **Example:** Write a text object |
| 21 | * ```typescript |
| 22 | * const putObject = yield* GCP.Storage.PutObject(bucket); |
| 23 | * yield* putObject({ name: "hello.txt", body: "Hello, World!" }); |
| 24 | * ``` |
| 25 | * |
| 26 | * **Example:** Write bytes with metadata |
| 27 | * ```typescript |
| 28 | * yield* putObject({ |
| 29 | * name: "report.json", |
| 30 | * body: new TextEncoder().encode(JSON.stringify(report)), |
| 31 | * contentType: "application/json", |
| 32 | * metadata: { source: "nightly" }, |
| 33 | * }); |
| 34 | * ``` |
| 35 | * |
| 36 | * @binding |
| 37 | * @category Storage |
| 38 | */ |
| 39 | export interface PutObject extends Binding.Service< |
| 40 | PutObject, |
| 41 | "GCP.Storage.PutObject", |
| 42 | ( |
| 43 | bucket: Bucket, |
| 44 | ) => Effect.Effect< |
| 45 | ( |
| 46 | request: PutObjectRequest, |
| 47 | ) => Effect.Effect<storage.Storage_Object, ObjectNotFound | ObjectRequestFailed, RuntimeContext> |
| 48 | > |
| 49 | > {} |
| 50 | |
| 51 | export const PutObject = Binding.Service<PutObject>("GCP.Storage.PutObject"); |