1import type * as DynamoDB from "@distilled.cloud/aws/dynamodb";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { Table } from "./Table.ts";
5
6export interface QueryRequest extends Omit<DynamoDB.QueryInput, "TableName"> {}
7
8/**
9 * Runtime binding for `dynamodb:Query`.
10 *
11 * Bind this operation to a `Table` inside a function runtime to get a callable
12 * that queries items by key condition, automatically injecting the table name.
13 * Provide the `QueryHttp` layer on the Function to satisfy the binding.
14 * ### Reading Data
15 * **Example:** Query Items by Partition Key
16 * ```typescript
17 * const query = yield* AWS.DynamoDB.Query(table);
18 *
19 * const response = yield* query({
20 * KeyConditionExpression: "pk = :pk",
21 * ExpressionAttributeValues: { ":pk": { S: "user#123" } },
22 * });
23 * const items = response.Items;
24 * ```
25 *
26 * @binding
27 */
28export interface Query extends Binding.Service<
29 Query,
30 "AWS.DynamoDB.Query",
31 <T extends Table>(
32 table: T,
33 ) => Effect.Effect<
34 (
35 request: QueryRequest,
36 ) => Effect.Effect<DynamoDB.QueryOutput, DynamoDB.QueryError>
37 >
38> {}
39export const Query = Binding.Service<Query>("AWS.DynamoDB.Query");