UNPKG

dynamodb-toolbox

Version:

Lightweight and type-safe query builder for DynamoDB and TypeScript.

36 lines (35 loc) 2.65 kB
import type { UpdateCommandInput, UpdateCommandOutput } from '@aws-sdk/lib-dynamodb'; import { $sentArgs } from '../../../entity/constants.js'; import type { Entity, EntitySendableAction } from '../../../entity/entity.js'; import type { FormattedItem } from '../../../entity/index.js'; import { EntityAction } from '../../../entity/index.js'; import type { AllNewReturnValuesOption, AllOldReturnValuesOption, NoneReturnValuesOption, UpdatedNewReturnValuesOption, UpdatedOldReturnValuesOption } from '../../../options/returnValues.js'; import type { DocumentClientOptions } from '../../../types/documentClientOptions.js'; import type { Merge } from '../../../types/merge.js'; import { $item, $options } from './constants.js'; import type { UpdateItemOptions } from './options.js'; import type { UpdateItemInput } from './types.js'; export type ReturnedAttributes<ENTITY extends Entity, OPTIONS extends UpdateItemOptions<ENTITY>> = OPTIONS['returnValues'] extends NoneReturnValuesOption ? undefined : OPTIONS['returnValues'] extends UpdatedOldReturnValuesOption | UpdatedNewReturnValuesOption ? FormattedItem<ENTITY, { partial: OPTIONS['returnValues'] extends UpdatedOldReturnValuesOption | UpdatedNewReturnValuesOption ? true : false; }> | undefined : OPTIONS['returnValues'] extends AllNewReturnValuesOption | AllOldReturnValuesOption ? FormattedItem<ENTITY> | undefined : never; export type UpdateItemResponse<ENTITY extends Entity, OPTIONS extends UpdateItemOptions<ENTITY> = UpdateItemOptions<ENTITY>> = Merge<Omit<UpdateCommandOutput, 'Attributes'>, { Attributes?: ReturnedAttributes<ENTITY, OPTIONS>; ToolboxItem: UpdateItemInput<ENTITY, { filled: true; }>; }>; export declare class UpdateItemCommand<ENTITY extends Entity = Entity, OPTIONS extends UpdateItemOptions<ENTITY> = UpdateItemOptions<ENTITY>> extends EntityAction<ENTITY> implements EntitySendableAction<ENTITY> { static actionName: "updateItem"; [$item]?: UpdateItemInput<ENTITY>; [$options]: OPTIONS; constructor(entity: ENTITY, item?: UpdateItemInput<ENTITY>, options?: OPTIONS); item(nextItem: UpdateItemInput<ENTITY>): UpdateItemCommand<ENTITY, OPTIONS>; options<NEXT_OPTIONS extends UpdateItemOptions<ENTITY>>(nextOptions: NEXT_OPTIONS | ((prevOptions: OPTIONS) => NEXT_OPTIONS)): UpdateItemCommand<ENTITY, NEXT_OPTIONS>; [$sentArgs](): [UpdateItemInput<ENTITY>, UpdateItemOptions<ENTITY>]; params(): UpdateCommandInput & { ToolboxItem: UpdateItemInput<ENTITY, { filled: true; }>; }; send(documentClientOptions?: DocumentClientOptions): Promise<UpdateItemResponse<ENTITY, OPTIONS>>; }