UNPKG

dynamodb-toolbox

Version:

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

27 lines (26 loc) 1.65 kB
import type { WriteItemOptions } from '../../../entity/index.js'; import { EntityAction } from '../../../entity/index.js'; import type { Entity, InputItem, TransformedItem, ValidItem } from '../../../entity/index.js'; import { Parser } from '../../../schema/actions/parse/index.js'; import type { PrimaryKey } from '../../../table/actions/parsePrimaryKey/index.js'; import { $parser } from './constants.js'; import type { InferWriteItemOptions, ParseItemOptions } from './options.js'; type EntityParserInput<ENTITY extends Entity, OPTIONS extends ParseItemOptions = {}, WRITE_ITEM_OPTIONS extends WriteItemOptions = InferWriteItemOptions<OPTIONS>> = OPTIONS extends { fill: false; } ? ValidItem<ENTITY, WRITE_ITEM_OPTIONS> : InputItem<ENTITY, WRITE_ITEM_OPTIONS>; export declare class EntityParser<ENTITY extends Entity = Entity> extends EntityAction<ENTITY> { static actionName: 'parse'; [$parser]: Parser<ENTITY['schema']>; constructor(entity: ENTITY); parse<OPTIONS extends ParseItemOptions = {}>(input: unknown, options?: OPTIONS): { parsedItem: ValidItem<ENTITY, InferWriteItemOptions<OPTIONS>>; item: TransformedItem<ENTITY, InferWriteItemOptions<OPTIONS>> & PrimaryKey<ENTITY['table']>; key: PrimaryKey<ENTITY['table']>; }; reparse<OPTIONS extends ParseItemOptions = {}>(input: EntityParserInput<ENTITY, InferWriteItemOptions<OPTIONS>>, options?: OPTIONS): { parsedItem: ValidItem<ENTITY, InferWriteItemOptions<OPTIONS>>; item: TransformedItem<ENTITY, InferWriteItemOptions<OPTIONS>> & PrimaryKey<ENTITY['table']>; key: PrimaryKey<ENTITY['table']>; }; } export {};