@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 53 lines 1.9 KB
Raw
1 import type * as cloudtrail from "@distilled.cloud/aws/cloudtrail";
2 import * as Binding from "alchemy/Binding";
3 import type * as Effect from "effect/Effect";
4 import type { EventDataStore } from "./EventDataStore.ts";
5
6 /**
7 * Request for the {@link StartQuery} binding. CloudTrail Lake SQL references
8 * the event data store by its ID (the ARN's `eventdatastore/` suffix) in the
9 * `FROM` clause, so `QueryStatement` may be a function that receives the
10 * bound store's ID and returns the SQL text.
11 */
12 export interface StartQueryRequest extends Omit<cloudtrail.StartQueryRequest, "QueryStatement"> {
13 /**
14 * The SQL statement, or a function producing it from the bound event data
15 * store's ID (for the `FROM <eventDataStoreId>` clause).
16 */
17 QueryStatement: string | ((eventDataStoreId: string) => string);
18 }
19
20 /**
21 * Runtime binding for `cloudtrail:StartQuery`.
22 *
23 * Starts a CloudTrail Lake SQL query against the bound
24 * {@link EventDataStore} and returns the `QueryId` to poll with
25 * {@link DescribeQuery} / {@link GetQueryResults}. Provide the implementation
26 * with `Effect.provide(AWS.CloudTrail.StartQueryHttp)`.
27 * ### Querying CloudTrail Lake
28 * **Example:** Start a Lake Query
29 * ```typescript
30 * // init — bind the operation to the event data store
31 * const startQuery = yield* AWS.CloudTrail.StartQuery(store);
32 *
33 * // runtime — the callback receives the store's ID for the FROM clause
34 * const { QueryId } = yield* startQuery({
35 * QueryStatement: (id) =>
36 * `SELECT eventID, eventName FROM ${id} LIMIT 10`,
37 * });
38 * ```
39 *
40 * @binding
41 */
42 export interface StartQuery extends Binding.Service<
43 StartQuery,
44 "AWS.CloudTrail.StartQuery",
45 (
46 store: EventDataStore,
47 ) => Effect.Effect<
48 (
49 request: StartQueryRequest,
50 ) => Effect.Effect<cloudtrail.StartQueryResponse, cloudtrail.StartQueryError>
51 >
52 > {}
53 export const StartQuery = Binding.Service<StartQuery>("AWS.CloudTrail.StartQuery");