The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as DynamoDB from "@distilled.cloud/aws/dynamodb"; |
| 2 | import * as Binding from "alchemy/Binding"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import type { Table } from "./Table.ts"; |
| 5 | |
| 6 | export interface PutItemRequest extends Omit<DynamoDB.PutItemInput, "TableName"> {} |
| 7 | |
| 8 | /** |
| 9 | * Runtime binding for `dynamodb:PutItem`. |
| 10 | * |
| 11 | * Bind this operation to a `Table` inside a function runtime to get a callable |
| 12 | * that writes a single item, automatically injecting the table name and |
| 13 | * granting the host `dynamodb:PutItem` on the table. Provide the `PutItemHttp` |
| 14 | * layer on the Function to satisfy the binding. |
| 15 | * ### Writing Data |
| 16 | * **Example:** Write a Single Item |
| 17 | * ```typescript |
| 18 | * // inside the Function's Effect.gen, with Effect.provide(DynamoDB.PutItemHttp) |
| 19 | * const putItem = yield* AWS.DynamoDB.PutItem(table); |
| 20 | * |
| 21 | * yield* putItem({ |
| 22 | * Item: { |
| 23 | * pk: { S: "user#123" }, |
| 24 | * sk: { S: "profile" }, |
| 25 | * name: { S: "Alice" }, |
| 26 | * }, |
| 27 | * }); |
| 28 | * ``` |
| 29 | * |
| 30 | * @binding |
| 31 | */ |
| 32 | export interface PutItem extends Binding.Service< |
| 33 | PutItem, |
| 34 | "AWS.DynamoDB.PutItem", |
| 35 | <T extends Table>( |
| 36 | table: T, |
| 37 | ) => Effect.Effect< |
| 38 | (request: PutItemRequest) => Effect.Effect<DynamoDB.PutItemOutput, DynamoDB.PutItemError> |
| 39 | > |
| 40 | > {} |
| 41 | |
| 42 | export const PutItem = Binding.Service<PutItem>("AWS.DynamoDB.PutItem"); |