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 { PutConfig } from './put.js'; import { BaseResult, BaseCommand, WriteTransactable } from './index.js'; /** * Configuration for the ConditionalPut command. * * @template Schema - The Zod schema defining the structure of the entity. */ type ConditionalPutConfig = PutConfig & { condition: Condition; returnValuesOnConditionCheckFailure?: ReturnValuesOnConditionCheckFailure; }; /** * Result of the ConditionalPut command. * * @template Schema - The Zod schema defining the structure of the entity. */ type ConditionalPutResult = BaseResult & { returnItem: EntitySchema | undefined; itemCollectionMetrics: ItemCollectionMetrics | undefined; }; /** * Command to create or replace an item with a condition expression. * * @template Schema - The Zod schema defining the structure of the entity. * * @example * ```typescript * import { DynamoTable, DynamoEntity, key, ConditionalPut, notExists } from 'dynamo-document-builder'; * * const table = new DynamoTable({ * tableName: 'ExampleTable', * documentClient, * }); * * const userEntity = new DynamoEntity({ * table, * schema: z.object({ * userId: z.string(), * name: z.string(), * status: z.string(), * }), * partitionKey: user => key('USER', user.userId), * sortKey: () => 'METADATA', * }); * * const conditionalPutCommand = new ConditionalPut({ * item: { userId: 'user123', name: 'John', status: 'active' }, * condition: { status: 'draft' }, * returnValuesOnConditionCheckFailure: 'ALL_OLD', * }); * * await userEntity.send(conditionalPutCommand); * ``` */ declare class ConditionalPut implements BaseCommand, Schema>, WriteTransactable { #private; constructor(config: ConditionalPutConfig); buildItem(entity: DynamoEntity): Promise<{ [x: string]: unknown; }>; execute(entity: DynamoEntity): Promise>; prepareWriteTransaction(entity: DynamoEntity): Promise; } export { ConditionalPut }; export type { ConditionalPutConfig, ConditionalPutResult };