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 * as Binding from "alchemy/Binding"; |
| 2 | import type { RuntimeContext } from "alchemy/RuntimeContext"; |
| 3 | import type * as Effect from "effect/Effect"; |
| 4 | import type { Bucket } from "./Bucket.ts"; |
| 5 | import type { ObjectContent, ObjectNotFound, ObjectRequestFailed } from "./ObjectMedia.ts"; |
| 6 | |
| 7 | export type { ObjectContent } from "./ObjectMedia.ts"; |
| 8 | |
| 9 | export interface GetObjectRequest { |
| 10 | /** Object name (key). */ |
| 11 | object: string; |
| 12 | /** Serve this generation instead of the live one. */ |
| 13 | generation?: string; |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Runtime binding that downloads an object's content from a Cloud Storage |
| 18 | * {@link Bucket} (`objects.get` with `alt=media`). Grants |
| 19 | * `roles/storage.objectViewer` on the bucket. |
| 20 | * |
| 21 | * Bind this operation to a {@link Bucket} in a Function/Action init phase. |
| 22 | * Provide {@link GetObjectHttp}. |
| 23 | * |
| 24 | * ### Reading Objects |
| 25 | * **Example:** Read an object as text |
| 26 | * ```typescript |
| 27 | * const getObject = yield* GCP.Storage.GetObject(bucket); |
| 28 | * const { body } = yield* getObject({ object: "hello.txt" }); |
| 29 | * const text = new TextDecoder().decode(body); |
| 30 | * ``` |
| 31 | * |
| 32 | * @binding |
| 33 | * @category Storage |
| 34 | */ |
| 35 | export interface GetObject extends Binding.Service< |
| 36 | GetObject, |
| 37 | "GCP.Storage.GetObject", |
| 38 | ( |
| 39 | bucket: Bucket, |
| 40 | ) => Effect.Effect< |
| 41 | ( |
| 42 | request: GetObjectRequest, |
| 43 | ) => Effect.Effect<ObjectContent, ObjectNotFound | ObjectRequestFailed, RuntimeContext> |
| 44 | > |
| 45 | > {} |
| 46 | |
| 47 | export const GetObject = Binding.Service<GetObject>("GCP.Storage.GetObject"); |