import { PreparedBatchGet, BaseConfig, TableCommand } from './index.js'; import { ObjectLikeZodType, EntitySchema } from '../core/index.js'; import { DynamoTable } from '../core/table.js'; import { ConsumedCapacity } from '@aws-sdk/client-dynamodb'; import { ResponseMetadata } from '@aws-sdk/types'; /** * Extracts the result item type from a PreparedBatchGet. */ type ExtractSchema = T extends PreparedBatchGet ? EntitySchema : never; /** * Maps an array of PreparedBatchGets to a tuple of their result item arrays. */ type TableBatchGetItems[]> = { [K in keyof Gets]: Array>; }; /** * Maps an array of PreparedBatchGets to a tuple of their unprocessed key arrays. */ type TableBatchGetUnprocessedKeys[]> = { [K in keyof Gets]: Array>> | undefined; }; /** * Configuration for the TableBatchGet command. * * @template Gets - Tuple of PreparedBatchGet types, one per entity group. */ type TableBatchGetConfig[]> = BaseConfig & { gets: [...Gets]; /** * If set, overrides the `consistent` setting on all individual prepared groups. * When `true`, DynamoDB will use strongly consistent reads for all entity groups. * When `false`, DynamoDB will use eventually consistent reads for all entity groups. * When not set, the command falls back to the per-group `consistent` setting * (any group with `consistent: true` makes the entire request consistent). */ consistent?: boolean; }; /** * Result of the TableBatchGet command. * * @template Gets - Tuple of PreparedBatchGet types, one per entity group. */ type TableBatchGetResult[]> = { responseMetadata?: ResponseMetadata; consumedCapacity?: ConsumedCapacity | undefined; items: TableBatchGetItems; unprocessedKeys: TableBatchGetUnprocessedKeys; }; /** * Table-level command to perform a batch get across multiple entity types. * * Unlike `BatchGet` which operates on a single entity type, this command accepts * get operations from multiple entities via `entity.prepare(new BatchGet({ keys: [...] }))` * and returns results grouped by entity in a tuple structure. * * Unprocessed keys are returned per entity in a tuple matching the input order. * * @example * ```typescript * const { items, unprocessedKeys } = await table.send(new TableBatchGet({ * gets: [ * userEntity.prepare(new BatchGet({ * keys: [{ userId: 'u1' }, { userId: 'u2' }], * })), * orderEntity.prepare(new BatchGet({ * keys: [{ orderId: 'o1' }], * })), * ], * consistent: true, // Apply strongly consistent reads to all groups * })) * * const [users, orders] = items * // users: User[] * // orders: Order[] * ``` */ declare class TableBatchGet[]> implements TableCommand> { #private; constructor(config: TableBatchGetConfig); execute(table: DynamoTable): Promise>; } export { TableBatchGet }; export type { TableBatchGetConfig, TableBatchGetResult };