import { ObjectLikeZodType, EntitySchema } from '../core/index.js'; import { BaseConfig, BaseResult, BaseCommand, BatchWritePreparable } from './index.js'; import { DynamoEntity } from '../core/entity.js'; import { ReturnItemCollectionMetrics, ItemCollectionMetrics } from '@aws-sdk/client-dynamodb'; import { DynamoKey } from '../core/key.js'; /** * Configuration for the BatchWrite command. * * @template Schema - The Zod schema defining the structure of the entity. */ type BatchWriteConfig = BaseConfig & { items?: Array>; deletes?: Array>>; returnItemCollectionMetrics?: ReturnItemCollectionMetrics; }; /** * Result of the BatchWrite command. * * @template Schema - The Zod schema defining the structure of the entity. */ type BatchWriteResult = BaseResult & { unprocessedPuts?: Array>; unprocessedDeletes?: Array>>; itemColectionMetrics?: ItemCollectionMetrics; }; /** * Command to put and/or delete multiple items in a single operation. * * @template Schema - The Zod schema defining the structure of the entity. * * @example * ```typescript * import { DynamoTable, DynamoEntity, key, BatchWrite } from 'dynamo-document-builder'; * * const table = new DynamoTable({ * tableName: 'ExampleTable', * documentClient, * }); * * const todoEntity = new DynamoEntity({ * table, * schema: z.object({ * userId: z.string(), * todoId: z.string(), * title: z.string(), * }), * partitionKey: todo => key('USER', todo.userId), * sortKey: todo => key('TODO', todo.todoId), * }); * * const batchWriteCommand = new BatchWrite({ * items: [ * { userId: 'user1', todoId: 'todo1', title: 'Task 1' }, * { userId: 'user2', todoId: 'todo2', title: 'Task 2' }, * ], * deletes: [ * { userId: 'user3', todoId: 'todo3' }, * ], * }); * * const { unprocessedPuts, unprocessedDeletes } = await todoEntity.send(batchWriteCommand); * ``` */ declare class BatchWrite implements BaseCommand, Schema>, BatchWritePreparable { #private; constructor(config: BatchWriteConfig); get items(): Array> | undefined; get deletes(): Array>> | undefined; buildPutRequests(entity: DynamoEntity): Promise<{ PutRequest: { Item: { [x: string]: unknown; }; }; }[]>; buildDeleteRequests(entity: DynamoEntity): Promise<{ DeleteRequest: { Key: DynamoKey; }; }[]>; execute(entity: DynamoEntity): Promise>; } export { BatchWrite }; export type { BatchWriteConfig, BatchWriteResult };