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 * as Effect from "effect/Effect"; |
| 4 | import type { Object, ObjectDecodeError } from "./Object.ts"; |
| 5 | import type { ReadBucketClient } from "./ReadBucket.ts"; |
| 6 | import type { StorageBindingOptions } from "./StorageBinding.ts"; |
| 7 | |
| 8 | export type ObjectValue<T> = [T] extends [never] ? Uint8Array : T; |
| 9 | export interface ReadObjectClient<T> { |
| 10 | /** Decode typed JSON, or return bytes for a raw body/file resource. */ |
| 11 | get(): Effect.Effect< |
| 12 | ObjectValue<T> | undefined, |
| 13 | Effect.Error<ReturnType<ReadBucketClient["get"]>> | ObjectDecodeError | Error, |
| 14 | RuntimeContext |
| 15 | >; |
| 16 | /** Always read exact bytes, including for JSON resources. */ |
| 17 | bytes(): Effect.Effect< |
| 18 | Uint8Array | undefined, |
| 19 | Effect.Error<ReturnType<ReadBucketClient["get"]>> | Error, |
| 20 | RuntimeContext |
| 21 | >; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Bind an object's key and JSON type without repeating either. A TypeScript |
| 26 | * generic is an application contract, not runtime validation; an optional schema |
| 27 | * rejects invalid external writes. No object-only credential scope is claimed. |
| 28 | * |
| 29 | * ### Typed Reads |
| 30 | * **Example:** Read the inferred settings shape |
| 31 | * ```typescript |
| 32 | * const settings = yield* Neon.ReadObject(settingsObject); |
| 33 | * const value = yield* settings.get(); |
| 34 | * ``` |
| 35 | * |
| 36 | * @binding |
| 37 | * @product Bucket |
| 38 | */ |
| 39 | export interface ReadObject extends Binding.Service< |
| 40 | ReadObject, |
| 41 | "Neon.ReadObject", |
| 42 | <T>(object: Object<T>, options?: StorageBindingOptions) => Effect.Effect<ReadObjectClient<T>> |
| 43 | > { |
| 44 | <T>( |
| 45 | object: Object<T>, |
| 46 | options?: StorageBindingOptions, |
| 47 | ): Effect.Effect<ReadObjectClient<T>, never, ReadObject>; |
| 48 | } |
| 49 | export const ReadObject = Binding.Service<ReadObject>("Neon.ReadObject"); |