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
| 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 ExecuteTransactionRequest extends DynamoDB.ExecuteTransactionInput {} |
| 7 | |
| 8 | export type ExecuteTransactionTables = [Table, ...Table[]]; |
| 9 | |
| 10 | /** |
| 11 | * Runtime binding for `dynamodb:ExecuteTransaction`. |
| 12 | * |
| 13 | * Bind this operation to one or more tables inside a function runtime to get a |
| 14 | * callable that runs a PartiQL transaction. Statements reference the bound |
| 15 | * tables by their physical names (resolve them via `table.tableName`); the |
| 16 | * host is granted the transactional read/write actions on every bound table. |
| 17 | * Provide the `ExecuteTransactionHttp` layer on the Function to satisfy the |
| 18 | * binding. |
| 19 | * ### PartiQL |
| 20 | * **Example:** Run a PartiQL Transaction |
| 21 | * ```typescript |
| 22 | * const executeTransaction = yield* AWS.DynamoDB.ExecuteTransaction(table); |
| 23 | * const tableName = yield* table.tableName; |
| 24 | * |
| 25 | * yield* executeTransaction({ |
| 26 | * TransactStatements: [ |
| 27 | * { |
| 28 | * Statement: `UPDATE "${tableName}" SET balance = balance - 10 WHERE pk = ? AND sk = ?`, |
| 29 | * Parameters: [{ S: "account#1" }, { S: "balance" }], |
| 30 | * }, |
| 31 | * { |
| 32 | * Statement: `UPDATE "${tableName}" SET balance = balance + 10 WHERE pk = ? AND sk = ?`, |
| 33 | * Parameters: [{ S: "account#2" }, { S: "balance" }], |
| 34 | * }, |
| 35 | * ], |
| 36 | * }); |
| 37 | * ``` |
| 38 | * |
| 39 | * @binding |
| 40 | */ |
| 41 | export interface ExecuteTransaction extends Binding.Service< |
| 42 | ExecuteTransaction, |
| 43 | "AWS.DynamoDB.ExecuteTransaction", |
| 44 | ( |
| 45 | ...tables: ExecuteTransactionTables |
| 46 | ) => Effect.Effect< |
| 47 | ( |
| 48 | request: ExecuteTransactionRequest, |
| 49 | ) => Effect.Effect<DynamoDB.ExecuteTransactionOutput, DynamoDB.ExecuteTransactionError> |
| 50 | > |
| 51 | > {} |
| 52 | |
| 53 | export const ExecuteTransaction = Binding.Service<ExecuteTransaction>( |
| 54 | "AWS.DynamoDB.ExecuteTransaction", |
| 55 | ); |