The best way to control Claude Code, Codex and more from any computer or phone
| 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 RunQuery}; project and database come from the bound database. */ |
| 9 | export type RunQueryRequest = DatastoreDatabaseRequest<datastore.RunQueryProjectsRequest>; |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for Datastore `projects.runQuery`. |
| 13 | * |
| 14 | * Bind this operation to a Datastore-mode `GCP.Firestore.Database` in a Function/Action init |
| 15 | * phase. Provide {@link RunQueryHttp}. The bound database supplies the |
| 16 | * project and database id; queries 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 | * ### Querying Entities |
| 21 | * **Example:** Query a kind |
| 22 | * ```typescript |
| 23 | * const database = yield* GCP.Firestore.Database("Tasks", { |
| 24 | * type: "DATASTORE_MODE", |
| 25 | * }); |
| 26 | * const runQuery = yield* GCP.Datastore.RunQuery(database); |
| 27 | * const page = yield* runQuery({ |
| 28 | * body: { query: { kind: [{ name: "Task" }] } }, |
| 29 | * }); |
| 30 | * ``` |
| 31 | * |
| 32 | * @binding |
| 33 | * @category Datastore |
| 34 | */ |
| 35 | export interface RunQuery extends Binding.Service< |
| 36 | RunQuery, |
| 37 | "GCP.Datastore.RunQuery", |
| 38 | ( |
| 39 | database: Database, |
| 40 | ) => Effect.Effect< |
| 41 | ( |
| 42 | request: RunQueryRequest, |
| 43 | ) => Effect.Effect<datastore.RunQueryResponse, datastore.RunQueryProjectsError, RuntimeContext> |
| 44 | > |
| 45 | > {} |
| 46 | |
| 47 | export const RunQuery = Binding.Service<RunQuery>("GCP.Datastore.RunQuery"); |