UNPKG

dynamodb-toolbox

Version:

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

20 lines (19 loc) 1.05 kB
import { z } from 'zod'; import type { ItemSchema } from '../../../../schema/index.js'; import type { Overwrite } from '../../../../types/overwrite.js'; import type { SelectKeys } from '../../../../types/selectKeys.js'; import type { SchemaZodParser } from './schema.js'; import type { ZodParserOptions } from './types.js'; import type { WithAttributeNameEncoding } from './utils.js'; export type ItemZodParser<SCHEMA extends ItemSchema, OPTIONS extends ZodParserOptions = {}> = ItemSchema extends SCHEMA ? z.ZodTypeAny : WithAttributeNameEncoding<SCHEMA, OPTIONS, z.ZodObject<{ [KEY in OPTIONS extends { mode: 'key'; } ? SelectKeys<SCHEMA['attributes'], { props: { key: true; }; }> : keyof SCHEMA['attributes']]: SchemaZodParser<SCHEMA['attributes'][KEY], Overwrite<OPTIONS, { defined: false; }>>; }, 'strip'>>; export declare const itemZodParser: <SCHEMA extends ItemSchema, OPTIONS extends ZodParserOptions = {}>(schema: SCHEMA, options?: OPTIONS) => ItemZodParser<SCHEMA, OPTIONS>;