| 1 | import * as DynamoDB from "@distilled.cloud/aws/dynamodb"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Table } from "./Table.ts"; |
| 5 | |
| 6 | export interface DeleteItemRequest extends Omit< |
| 7 | DynamoDB.DeleteItemInput, |
| 8 | "TableName" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `dynamodb:DeleteItem`. |
| 13 | * |
| 14 | * Bind this operation to a `Table` inside a function runtime to get a callable |
| 15 | * that deletes a single item by key, automatically injecting the table name. |
| 16 | * Provide the `DeleteItemHttp` layer on the Function to satisfy the binding. |
| 17 | * ### Writing Data |
| 18 | * **Example:** Delete an Item by Key |
| 19 | * ```typescript |
| 20 | * const deleteItem = yield* AWS.DynamoDB.DeleteItem(table); |
| 21 | * |
| 22 | * yield* deleteItem({ |
| 23 | * Key: { |
| 24 | * pk: { S: "user#123" }, |
| 25 | * sk: { S: "profile" }, |
| 26 | * }, |
| 27 | * }); |
| 28 | * ``` |
| 29 | * |
| 30 | * @binding |
| 31 | */ |
| 32 | export interface DeleteItem extends Binding.Service< |
| 33 | DeleteItem, |
| 34 | "AWS.DynamoDB.DeleteItem", |
| 35 | <T extends Table>( |
| 36 | table: T, |
| 37 | ) => Effect.Effect< |
| 38 | ( |
| 39 | request: DeleteItemRequest, |
| 40 | ) => Effect.Effect<DynamoDB.DeleteItemOutput, DynamoDB.DeleteItemError> |
| 41 | > |
| 42 | > {} |
| 43 | |
| 44 | export const DeleteItem = Binding.Service<DeleteItem>( |
| 45 | "AWS.DynamoDB.DeleteItem", |
| 46 | ); |