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

main
ts 57 lines 1.8 KB
Raw
1 import type * as datastore from "@distilled.cloud/gcp/datastore_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 { Database } from "../Firestore/Database.ts";
6 import type { DatastoreDatabaseRequest } from "./BindingHttp.ts";
7
8 /** Request for {@link Commit}; project and database come from the bound database. */
9 export type CommitRequest = DatastoreDatabaseRequest<datastore.CommitProjectsRequest>;
10
11 /**
12 * Runtime binding for Datastore `projects.commit`.
13 *
14 * Bind this operation to a Datastore-mode `GCP.Firestore.Database` in a Function/Action init
15 * phase. Provide {@link CommitHttp}. The bound database supplies the
16 * project and database id; mutations run against that database only.
17 * The host is granted the role on the project under an IAM Condition
18 * matching the database.
19 *
20 * ### Committing Mutations
21 * **Example:** Upsert an entity
22 * ```typescript
23 * const database = yield* GCP.Firestore.Database("Tasks", {
24 * type: "DATASTORE_MODE",
25 * });
26 * const commit = yield* GCP.Datastore.Commit(database);
27 * const result = yield* commit({
28 * body: {
29 * mode: "NON_TRANSACTIONAL",
30 * mutations: [
31 * {
32 * upsert: {
33 * key: { path: [{ kind: "Task", name: "t1" }] },
34 * properties: { title: { stringValue: "Ship" } },
35 * },
36 * },
37 * ],
38 * },
39 * });
40 * ```
41 *
42 * @binding
43 * @category Datastore
44 */
45 export interface Commit extends Binding.Service<
46 Commit,
47 "GCP.Datastore.Commit",
48 (
49 database: Database,
50 ) => Effect.Effect<
51 (
52 request: CommitRequest,
53 ) => Effect.Effect<datastore.CommitResponse, datastore.CommitProjectsError, RuntimeContext>
54 >
55 > {}
56
57 export const Commit = Binding.Service<Commit>("GCP.Datastore.Commit");