@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, 04:45 UTC

main
ts 59 lines 1.82 KB
Raw
1 import type * as neptunegraph from "@distilled.cloud/aws/neptune-graph";
2 import * as Binding from "alchemy/Binding";
3 import type * as Effect from "effect/Effect";
4 import type { Graph } from "./Graph.ts";
5
6 export interface ExecuteQueryRequest extends Omit<
7 neptunegraph.ExecuteQueryInput,
8 "graphIdentifier"
9 > {}
10
11 /**
12 * Runtime binding for `neptune-graph:ExecuteQuery` — run an openCypher query
13 * against a Neptune Analytics {@link Graph}.
14 *
15 * Bind this operation to a `Graph` inside a function runtime to get a
16 * callable that automatically injects the graph identifier and grants the
17 * data-plane query actions (`ReadDataViaQuery`, `WriteDataViaQuery`,
18 * `DeleteDataViaQuery`) on the graph.
19 *
20 * The response `payload` is a streaming body — collect it to parse the JSON
21 * result document.
22 * ### Querying a Graph
23 * **Example:** Run an openCypher query
24 * ```typescript
25 * const executeQuery = yield* AWS.NeptuneGraph.ExecuteQuery(graph);
26 *
27 * const response = yield* executeQuery({
28 * queryString: "MATCH (n) RETURN count(n) AS nodes",
29 * language: "OPEN_CYPHER",
30 * });
31 * const body = yield* Stream.mkString(
32 * Stream.decodeText(response.payload),
33 * );
34 * const { results } = JSON.parse(body);
35 * ```
36 *
37 * **Example:** Write data with parameters
38 * ```typescript
39 * yield* executeQuery({
40 * queryString: "CREATE (n:Person {name: $name})",
41 * language: "OPEN_CYPHER",
42 * parameters: { name: "Ada" },
43 * });
44 * ```
45 *
46 * @binding
47 */
48 export interface ExecuteQuery extends Binding.Service<
49 ExecuteQuery,
50 "AWS.NeptuneGraph.ExecuteQuery",
51 <G extends Graph>(
52 graph: G,
53 ) => Effect.Effect<
54 (
55 request: ExecuteQueryRequest,
56 ) => Effect.Effect<neptunegraph.ExecuteQueryOutput, neptunegraph.ExecuteQueryError>
57 >
58 > {}
59 export const ExecuteQuery = Binding.Service<ExecuteQuery>("AWS.NeptuneGraph.ExecuteQuery");