@devries-cameron20 / t3code Mirror · read-only
Fork 0

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, 06:00 UTC

main
ts 55 lines 1.54 KB
Raw
1 import type * as firestore from "@distilled.cloud/gcp/firestore_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 "./Database.ts";
6
7 export interface PatchDocumentRequest extends Omit<
8 firestore.PatchProjectsDatabasesDocumentsRequest,
9 "name"
10 > {
11 /**
12 * Document path relative to the database, e.g. `users/alice`. Creates
13 * the document if it does not exist unless `currentDocument.exists` is
14 * set.
15 */
16 documentPath: string;
17 }
18
19 /**
20 * Runtime binding for Firestore `documents.patch`.
21 *
22 * Bind this operation to a {@link Database} in a Function/Action init
23 * phase. Provide {@link PatchDocumentHttp}. Patch upserts unless a
24 * current-document precondition is set.
25 *
26 * ### Writing Documents
27 * **Example:** Upsert a document
28 * ```typescript
29 * const patchDocument = yield* GCP.Firestore.PatchDocument(database);
30 * yield* patchDocument({
31 * documentPath: "users/alice",
32 * body: { fields: { name: { stringValue: "Alice" } } },
33 * });
34 * ```
35 *
36 * @binding
37 * @category Firestore
38 */
39 export interface PatchDocument extends Binding.Service<
40 PatchDocument,
41 "GCP.Firestore.PatchDocument",
42 (
43 database: Database,
44 ) => Effect.Effect<
45 (
46 request: PatchDocumentRequest,
47 ) => Effect.Effect<
48 firestore.Document,
49 firestore.PatchProjectsDatabasesDocumentsError,
50 RuntimeContext
51 >
52 >
53 > {}
54
55 export const PatchDocument = Binding.Service<PatchDocument>("GCP.Firestore.PatchDocument");