@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 49 lines 1.72 KB
Raw
1 import type * as TSQ from "@distilled.cloud/aws/timestream-query";
2 import * as Binding from "alchemy/Binding";
3 import type * as Effect from "effect/Effect";
4 import type { Table } from "./Table.ts";
5
6 export interface PrepareQueryRequest extends TSQ.PrepareQueryRequest {}
7
8 /**
9 * Runtime binding for `timestream-query:PrepareQuery` — validate a SQL query
10 * against a Timestream {@link Table} and inspect its result schema and
11 * parameter mappings without running it.
12 *
13 * Bind the operation to the table the SQL reads so the host is granted
14 * `timestream:PrepareQuery` and `timestream:Select` on it (plus the unscoped
15 * `timestream:DescribeEndpoints` the endpoint-discovery flow needs). The
16 * query string itself still references the database and table by name.
17 *
18 * Provide `Timestream.PrepareQueryHttp` on the Function to implement the
19 * binding.
20 *
21 * ### Querying Data
22 * **Example:** Validate a query before running it
23 * ```typescript
24 * // init — bind the operation to the table the SQL reads
25 * const prepareQuery = yield* Timestream.PrepareQuery(table);
26 *
27 * // runtime — validate only; Columns/Parameters describe the result shape
28 * const prepared = yield* prepareQuery({
29 * QueryString: `SELECT COUNT(*) AS c FROM "${databaseName}"."${tableName}"`,
30 * ValidateOnly: true,
31 * });
32 * // prepared.Columns[0].Name === "c"
33 * ```
34 *
35 * @binding
36 */
37 export interface PrepareQuery extends Binding.Service<
38 PrepareQuery,
39 "AWS.Timestream.PrepareQuery",
40 (
41 table: Table,
42 ) => Effect.Effect<
43 (
44 request: PrepareQueryRequest,
45 ) => Effect.Effect<TSQ.PrepareQueryResponse, TSQ.PrepareQueryError | TSQ.DescribeEndpointsError>
46 >
47 > {}
48
49 export const PrepareQuery = Binding.Service<PrepareQuery>("AWS.Timestream.PrepareQuery");