| 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 type TransactGetItemsTables = [Table, ...Table[]]; |
| 7 | |
| 8 | type NativeTransactGet = NonNullable< |
| 9 | NonNullable<DynamoDB.TransactGetItemsInput["TransactItems"]>[number]["Get"] |
| 10 | >; |
| 11 | |
| 12 | export interface TransactGet extends Omit<NativeTransactGet, "TableName"> { |
| 13 | Table: string; |
| 14 | } |
| 15 | |
| 16 | export interface TransactGetItemsRequest extends Omit< |
| 17 | DynamoDB.TransactGetItemsInput, |
| 18 | "TransactItems" |
| 19 | > { |
| 20 | TransactItems: Array<{ |
| 21 | Get: TransactGet; |
| 22 | }>; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Runtime binding for `dynamodb:TransactGetItems`. |
| 27 | * |
| 28 | * Bind this operation to one or more tables and identify each table in the |
| 29 | * request with the bound table's `LogicalId`. |
| 30 | * ### Reading Data |
| 31 | * **Example:** Read Items Transactionally |
| 32 | * ```typescript |
| 33 | * const transactGetItems = yield* AWS.DynamoDB.TransactGetItems( |
| 34 | * sourceTable, |
| 35 | * archiveTable, |
| 36 | * ); |
| 37 | * |
| 38 | * const response = yield* transactGetItems({ |
| 39 | * TransactItems: [ |
| 40 | * { |
| 41 | * Get: { |
| 42 | * Table: sourceTable.LogicalId, |
| 43 | * Key: { pk: { S: "user#1" }, sk: { S: "profile" } }, |
| 44 | * }, |
| 45 | * }, |
| 46 | * ], |
| 47 | * }); |
| 48 | * ``` |
| 49 | * |
| 50 | * @binding |
| 51 | */ |
| 52 | export interface TransactGetItems extends Binding.Service< |
| 53 | TransactGetItems, |
| 54 | "AWS.DynamoDB.TransactGetItems", |
| 55 | ( |
| 56 | ...tables: TransactGetItemsTables |
| 57 | ) => Effect.Effect< |
| 58 | ( |
| 59 | request: TransactGetItemsRequest, |
| 60 | ) => Effect.Effect< |
| 61 | DynamoDB.TransactGetItemsOutput, |
| 62 | DynamoDB.TransactGetItemsError |
| 63 | > |
| 64 | > |
| 65 | > {} |
| 66 | export const TransactGetItems = Binding.Service<TransactGetItems>( |
| 67 | "AWS.DynamoDB.TransactGetItems", |
| 68 | ); |