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

main
ts 53 lines 2.03 KB
Raw
1 import * as Binding from "alchemy/Binding";
2 import type { Input } from "alchemy/Input";
3 import type { RuntimeContext } from "alchemy/RuntimeContext";
4 import * as Effect from "effect/Effect";
5 import type { InstantNamespace } from "./InstantNamespace.ts";
6 import type { WriteInstantNamespaceClient } from "./InstantNamespaceTypes.ts";
7 import type { Namespace } from "./Namespace.ts";
8 import type { NamespaceError } from "./NamespaceTypes.ts";
9
10 /**
11 * Bind a {@link Namespace} to a Worker with write access and obtain the
12 * Effect-native KV client (`put`, `delete`).
13 *
14 * `WriteNamespace` is a single identifier that is simultaneously the binding's
15 * Context tag, its type, and the callable —
16 * `yield* Cloudflare.KV.WriteNamespace(ns)`.
17 *
18 * Also accepts InstantNamespace, returning a client without metadata or
19 * paginated listing options.
20 *
21 * @binding
22 * @product KV
23 * @category Storage & Databases
24 */
25 export interface WriteNamespace extends Binding.Service<
26 WriteNamespace,
27 "Cloudflare.KV.WriteNamespace",
28 {
29 (namespace: InstantNamespace): Effect.Effect<WriteInstantNamespaceClient>;
30 (namespace: Namespace): Effect.Effect<WriteNamespaceClient>;
31 (namespace: Namespace | InstantNamespace): Effect.Effect<WriteInstantNamespaceClient>;
32 }
33 > {
34 <Req = never>(
35 namespace: Input<Namespace> | Effect.Effect<Namespace, never, Req>,
36 ): Effect.Effect<WriteNamespaceClient, never, WriteNamespace | Req>;
37 <Req = never>(
38 namespace:
39 | Input<Namespace | InstantNamespace>
40 | Effect.Effect<Namespace | InstantNamespace, never, Req>,
41 ): Effect.Effect<WriteInstantNamespaceClient, never, WriteNamespace | Req>;
42 }
43
44 export const WriteNamespace = Binding.Service<WriteNamespace>("Cloudflare.KV.WriteNamespace");
45
46 export interface WriteNamespaceClient<Key extends string = string> {
47 put(
48 key: Key,
49 value: string | ArrayBuffer | ArrayBufferView | ReadableStream,
50 options?: KVNamespacePutOptions,
51 ): Effect.Effect<void, NamespaceError, RuntimeContext>;
52 delete(key: Key): Effect.Effect<void, NamespaceError, RuntimeContext>;
53 }