import { DynamoEntity } from '../core/entity.js'; import { ObjectLikeZodType, EntitySchema } from '../core/index.js'; import { Projection } from '../projections/index.js'; import { QueryConfig } from './query.js'; import { BaseResult, BaseCommand, BasePaginatable } from './index.js'; import { QueryCommandInput, NativeAttributeValue, QueryCommandOutput } from '@aws-sdk/lib-dynamodb'; /** * Configuration for the ProjectedQuery command. * * @template Schema - The Zod schema defining the structure of the entity. * @template ProjectionSchema - The Zod schema defining the structure of the projected attributes. */ type ProjectedQueryConfig = QueryConfig & { projection: Projection; projectionSchema: ProjectionSchema; }; /** * Result of the ProjectedQuery command. * * @template Schema - The Zod schema defining the structure of the entity. * @template ProjectionSchema - The Zod schema defining the structure of the projected attributes. */ type ProjectedQueryResult = BaseResult & { items: EntitySchema[]; count: number; scannedCount: number; lastEvaluatedKey?: Partial> | undefined; }; /** * Command to retrieve specific attributes of multiple items by partition key with optional sort key conditions. * * @template Schema - The Zod schema defining the structure of the entity. * @template ProjectionSchema - The Zod schema defining the structure of the projected attributes. * * @example * ```typescript * import { DynamoTable, DynamoEntity, key, ProjectedQuery, 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(), * description: z.string(), * isComplete: z.boolean(), * }), * partitionKey: todo => key('USER', todo.userId), * sortKey: todo => key('TODO', todo.todoId), * }); * * const projectedQueryCommand = new ProjectedQuery({ * key: { userId: 'user123' }, * projection: ['title', 'isComplete'], * projectionSchema: z.object({ * title: z.string(), * isComplete: z.boolean(), * }), * limit: 10, * }); * * const { items, count } = await todoEntity.send(projectedQueryCommand); * ``` */ declare class ProjectedQuery implements BaseCommand, Schema>, BasePaginatable, Schema> { #private; constructor(config: ProjectedQueryConfig); buildCommandInput(entity: DynamoEntity): QueryCommandInput; validateItems(items: Record[] | undefined): Promise[]>; buildResult(items: EntitySchema[], queryResult: QueryCommandOutput): ProjectedQueryResult; execute(entity: DynamoEntity): Promise>; executePaginated(entity: DynamoEntity): AsyncGenerator, void, unknown>; } export { ProjectedQuery }; export type { ProjectedQueryConfig, ProjectedQueryResult };