import { Condition } from '../conditions/index.js'; import { DynamoEntity } from '../core/entity.js'; import { ObjectLikeZodType, EntitySchema, TransactWriteOperation } from '../core/index.js'; import { ReturnValuesOnConditionCheckFailure, ItemCollectionMetrics } from '@aws-sdk/client-dynamodb'; import { UpdateConfig } from './update.js'; import { BaseResult, BaseCommand, WriteTransactable } from './index.js'; /** * Configuration for the ConditionalUpdate command. * * @template Schema - The Zod schema defining the structure of the entity. */ type ConditionalUpdateConfig = UpdateConfig & { condition: Condition; returnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure; }; /** * Result of the ConditionalUpdate command. * * @template Schema - The Zod schema defining the structure of the entity. */ type ConditionalUpdateResult = BaseResult & { updatedItem?: EntitySchema | undefined; itemCollectionMetrics?: ItemCollectionMetrics; }; /** * Command to modify existing item attributes with a condition expression. * * @template Schema - The Zod schema defining the structure of the entity. * * @example * ```typescript * import { DynamoTable, DynamoEntity, key, ConditionalUpdate, add } 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(), * status: z.string(), * }), * partitionKey: user => key('USER', user.userId), * sortKey: () => 'METADATA', * }); * * const conditionalUpdateCommand = new ConditionalUpdate({ * key: { userId: 'user123' }, * update: { balance: add(50) }, * condition: { status: 'active' }, * returnValues: 'ALL_NEW', * }); * * const { updatedItem } = await userEntity.send(conditionalUpdateCommand); * ``` */ declare class ConditionalUpdate implements BaseCommand, Schema>, WriteTransactable { #private; constructor(config: ConditionalUpdateConfig); execute(entity: DynamoEntity): Promise>; prepareWriteTransaction(entity: DynamoEntity): Promise; } export { ConditionalUpdate }; export type { ConditionalUpdateConfig, ConditionalUpdateResult };