import { Condition } from '../conditions/index.js'; import { EntityKeyInput, DynamoEntity } from '../core/entity.js'; import { ObjectLikeZodType, EntitySchema } from '../core/index.js'; import { Select } from '@aws-sdk/client-dynamodb'; import { BaseConfig, BaseResult, BaseCommand, BasePaginatable } from './index.js'; import { QueryCommandInput, NativeAttributeValue, QueryCommandOutput } from '@aws-sdk/lib-dynamodb'; /** * Configuration for the Query command. * * @template Schema - The Zod schema defining the structure of the entity. */ type QueryConfig = BaseConfig & EntityKeyInput> & { sortKeyCondition?: Condition; filter?: Condition; limit?: number; selectAttributes?: Select; consistent?: boolean; validationConcurrency?: number; reverseIndexScan?: boolean; exclusiveStartKey?: Partial>; pageSize?: number; }; /** * Result of the Query command. * * @template Schema - The Zod schema defining the structure of the entity. */ type QueryResult = BaseResult & { items: EntitySchema[]; count: number; scannedCount: number; lastEvaluatedKey?: Partial> | undefined; }; /** * Command to retrieve multiple items by partition key with optional sort key conditions. * * @template Schema - The Zod schema defining the structure of the entity. * * @example * ```typescript * import { DynamoTable, DynamoEntity, key, Query, beginsWith } 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(), * isComplete: z.boolean(), * }), * partitionKey: todo => key('USER', todo.userId), * sortKey: todo => key('TODO', todo.todoId), * }); * * const queryCommand = new Query({ * key: { userId: 'user123' }, * sortKeyCondition: { SK: beginsWith('TODO#') }, * limit: 10, * }); * * const { items, count } = await todoEntity.send(queryCommand); * ``` */ declare class Query implements BaseCommand, Schema>, BasePaginatable, Schema> { #private; constructor(config: QueryConfig); buildCommandInput(entity: DynamoEntity): QueryCommandInput; validateItems(entity: DynamoEntity, items: Record[] | undefined): Promise[]>; buildResult(items: EntitySchema[], queryResult: QueryCommandOutput): QueryResult; execute(entity: DynamoEntity): Promise>; executePaginated(entity: DynamoEntity): AsyncGenerator, void, unknown>; } export { Query }; export type { QueryConfig, QueryResult };