| 1 | import type * as DynamoDB from "@distilled.cloud/aws/dynamodb"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Table } from "./Table.ts"; |
| 5 | |
| 6 | export interface GetItemRequest extends Omit< |
| 7 | DynamoDB.GetItemInput, |
| 8 | "TableName" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `dynamodb:GetItem`. |
| 13 | * |
| 14 | * Bind this operation to a `Table` inside a function runtime to get a callable |
| 15 | * that automatically injects the table name. |
| 16 | * ### Reading Data |
| 17 | * **Example:** Read a Single Item |
| 18 | * ```typescript |
| 19 | * const getItem = yield* AWS.DynamoDB.GetItem(table); |
| 20 | * |
| 21 | * const response = yield* getItem({ |
| 22 | * Key: { |
| 23 | * pk: { S: "user#123" }, |
| 24 | * }, |
| 25 | * }); |
| 26 | * ``` |
| 27 | * |
| 28 | * @binding |
| 29 | */ |
| 30 | export interface GetItem extends Binding.Service< |
| 31 | GetItem, |
| 32 | "AWS.DynamoDB.GetItem", |
| 33 | <T extends Table>( |
| 34 | table: T, |
| 35 | ) => Effect.Effect< |
| 36 | ( |
| 37 | request: GetItemRequest, |
| 38 | ) => Effect.Effect<DynamoDB.GetItemOutput, DynamoDB.GetItemError> |
| 39 | > |
| 40 | > {} |
| 41 | export const GetItem = Binding.Service<GetItem>("AWS.DynamoDB.GetItem"); |