import { Condition } from '../conditions/index.js'; import { DynamoEntity } from '../core/entity.js'; import { ObjectLikeZodType, EntitySchema, TransactWriteOperation } from '../core/index.js'; import { ReturnValuesOnConditionCheckFailure } from '@aws-sdk/client-dynamodb'; import { WriteTransactable } from './index.js'; /** * Configuration for the ConditionCheck command. * * @template Schema - The Zod schema defining the structure of the entity. */ type ConditionCheckConfig = { key: Partial>; condition: Condition; returnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure; }; /** * Command to verify a condition without modifying data in a transaction. * * @template Schema - The Zod schema defining the structure of the entity. * * @example * ```typescript * import { DynamoTable, DynamoEntity, key, TransactWrite, ConditionCheck, Update } from 'dynamo-document-builder'; * * const table = new DynamoTable({ * tableName: 'ExampleTable', * documentClient, * }); * * const userEntity = new DynamoEntity({ * table, * schema: z.object({ * userId: z.string(), * balance: z.number(), * }), * partitionKey: user => key('USER', user.userId), * sortKey: () => 'METADATA', * }); * * const transactWriteCommand = new TransactWrite({ * writes: [ * new ConditionCheck({ * key: { userId: 'user1' }, * condition: { balance: greaterThan(100) }, * }), * new Update({ key: { userId: 'user2' }, update: { balance: add(50) } }), * ], * }); * * await userEntity.send(transactWriteCommand); * ``` */ declare class ConditionCheck implements WriteTransactable { #private; constructor(config: ConditionCheckConfig); prepareWriteTransaction(entity: DynamoEntity): Promise; } export { ConditionCheck }; export type { ConditionCheckConfig };