import { ObjectLikeZodType, TransactWriteOperation, EntitySchema } from '../core/index.js'; import { DynamoEntity } from '../core/entity.js'; import { DynamoTable } from '../core/table.js'; import { DynamoKey } from '../core/key.js'; import { ReturnConsumedCapacity, ConsumedCapacity } from '@aws-sdk/client-dynamodb'; import { ResponseMetadata } from '@aws-sdk/types'; export { Get, GetConfig, GetResult } from './get.js'; export { Query, QueryConfig, QueryResult } from './query.js'; export { Scan, ScanConfig, ScanResult } from './scan.js'; export { ProjectedGet, ProjectedGetConfig, ProjectedGetResult } from './projected-get.js'; export { ProjectedQuery, ProjectedQueryConfig, ProjectedQueryResult } from './projected-query.js'; export { ProjectedScan, ProjectedScanConfig, ProjectedScanResult } from './projected-scan.js'; export { BatchGet, BatchGetConfig, BatchGetResult } from './batch-get.js'; export { BatchProjectedGet, BatchProjectedGetConfig, BatchProjectedGetResult } from './batch-projected-get.js'; export { TransactGet, TransactGetConfig, TransactGetResult } from './transact-get.js'; export { Put, PutConfig, PutResult } from './put.js'; export { Update, UpdateConfig, UpdateResult } from './update.js'; export { Delete, DeleteConfig, DeleteResult } from './delete.js'; export { ConditionalPut, ConditionalPutConfig, ConditionalPutResult } from './conditional-put.js'; export { ConditionalUpdate, ConditionalUpdateConfig, ConditionalUpdateResult } from './conditional-update.js'; export { ConditionalDelete, ConditionalDeleteConfig, ConditionalDeleteResult } from './conditional-delete.js'; export { BatchWrite, BatchWriteConfig, BatchWriteResult } from './batch-write.js'; export { TransactWrite, TransactWriteConfig, TransactWriteResult } from './transact-write.js'; export { TableTransactWrite, TableTransactWriteConfig, TableTransactWriteResult } from './table-transact-write.js'; export { TableBatchWrite, TableBatchWriteConfig, TableBatchWriteResult } from './table-batch-write.js'; export { TableTransactGet, TableTransactGetConfig, TableTransactGetResult } from './table-transact-get.js'; export { TableBatchGet, TableBatchGetConfig, TableBatchGetResult } from './table-batch-get.js'; export { ConditionCheck, ConditionCheckConfig } from './condition-check.js'; /** * Interface for commands that can be prepared for use in a table-level batch write. * * @template Schema The Zod schema type associated with the DynamoEntity. */ type BatchWritePreparable = { readonly items?: Array>; readonly deletes?: Array>>; }; /** * Interface for commands that can be prepared for use in a table-level batch get. * * @template Schema The Zod schema type associated with the DynamoEntity. */ type BatchGetPreparable = { readonly keys: Array>>; readonly consistent?: boolean; }; /** * Interface-like type for command classes to extend from that defines the execute method. * * This is what enables the command-based pattern for DynamoDB operations that makes tree-shaking possible. * * @template Output The output type of the command's execute method. * @template Schema The Zod schema type associated with the DynamoEntity. */ type BaseCommand = { execute(entity: DynamoEntity): Promise; }; /** * Interface-like type for paginatable command classes to extend from that defines the executePaginated method. * * Commands should only implement this interface if they support pagination. * * @template Output The output type of the command's executePaginated method. * @template Schema The Zod schema type associated with the DynamoEntity. */ type BasePaginatable = { executePaginated(entity: DynamoEntity): AsyncGenerator; }; /** * Interface-like type for get commands that can be included in a table-level get transaction. * * @template Schema The Zod schema type associated with the DynamoEntity. */ type GetTransactable = { readonly keys: Array>>; }; /** * Interface-like type for write commands that can be included in a write transaction. * * @template Schema The Zod schema type associated with the DynamoEntity. */ type WriteTransactable = { prepareWriteTransaction(entity: DynamoEntity): Promise; }; /** * Interface-like type for table-level commands that execute directly against a DynamoTable. * * @template Output The output type of the command's execute method. */ type TableCommand = { execute(table: DynamoTable): Promise; }; /** * Represents a set of write operations bound to a specific entity, ready to be included * in a table-level TransactWrite command. * * @template Schema The Zod schema type associated with the DynamoEntity. */ type PreparedWriteTransaction = { entity: DynamoEntity; writes: WriteTransactable[]; }; /** * Represents a TransactGet command bound to a specific entity, ready to be included * in a table-level TransactGet command. * * @template Schema The Zod schema type associated with the DynamoEntity. */ type PreparedGetTransaction = { entity: DynamoEntity; keys: Array<{ TableName: string; Key: DynamoKey; }>; parseResults(items: unknown[], skipValidation: boolean): Promise | undefined>>; }; /** * Represents a BatchWrite command bound to a specific entity, ready to be included * in a table-level TableBatchWrite command. * * @template Schema The Zod schema type associated with the DynamoEntity. */ type PreparedBatchWrite = { entity: DynamoEntity; buildRequests(skipValidation: boolean, abortSignal?: AbortSignal): Promise; }; } | { DeleteRequest: { Key: DynamoKey; }; }>>; matchUnprocessedPut(item: Record): EntitySchema | undefined; matchUnprocessedDelete(key: DynamoKey): Partial> | undefined; }; /** * Represents a BatchGet command bound to a specific entity, ready to be included * in a table-level TableBatchGet command. * * @template Schema The Zod schema type associated with the DynamoEntity. */ type PreparedBatchGet = { entity: DynamoEntity; keys: Array; consistent: boolean; matchItem(item: Record): boolean; parseResults(items: unknown[], skipValidation: boolean): Promise>>; matchUnprocessedKey(key: DynamoKey): Partial> | undefined; }; /** * Base configuration options for DynamoDB commands. * * @property skipValidation - If true, skips schema validation of the returned item(s). * @property returnConsumedCapacity - Specifies the level of detail about provisioned throughput consumption that is returned in the response. * @property abortController - An AbortController to allow cancellation of the operation. * @property timeoutMs - The maximum time in milliseconds to wait for the operation to complete. */ type BaseConfig = { skipValidation?: boolean; returnConsumedCapacity?: ReturnConsumedCapacity; abortController?: AbortController; timeoutMs?: number; }; /** * Base result type for DynamoDB commands. * * @property responseMetadata - Metadata about the response from DynamoDB. * @property consumedCapacity - Information about the capacity units consumed by the operation. */ type BaseResult = { responseMetadata?: ResponseMetadata; consumedCapacity?: ConsumedCapacity | undefined; }; export type { BaseCommand, BaseConfig, BasePaginatable, BaseResult, BatchGetPreparable, BatchWritePreparable, GetTransactable, PreparedBatchGet, PreparedBatchWrite, PreparedGetTransaction, PreparedWriteTransaction, TableCommand, WriteTransactable };