dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
20 lines (19 loc) • 1.07 kB
TypeScript
import { z } from 'zod';
import type { ItemSchema } from '../../../../schema/index.js';
import type { OmitKeys } from '../../../../types/omitKeys.js';
import type { Overwrite } from '../../../../types/overwrite.js';
import type { SchemaZodFormatter } from './schema.js';
import type { ZodFormatterOptions } from './types.js';
import type { WithAttributeNameDecoding } from './utils.js';
export type ItemZodFormatter<SCHEMA extends ItemSchema, OPTIONS extends ZodFormatterOptions = {}> = ItemSchema extends SCHEMA ? z.ZodTypeAny : WithAttributeNameDecoding<SCHEMA, OPTIONS, z.ZodObject<{
[KEY in OPTIONS extends {
format: false;
} ? keyof SCHEMA['attributes'] : OmitKeys<SCHEMA['attributes'], {
props: {
hidden: true;
};
}>]: SchemaZodFormatter<SCHEMA['attributes'][KEY], Overwrite<OPTIONS, {
defined: false;
}>>;
}, 'strip'>>;
export declare const itemZodFormatter: <SCHEMA extends ItemSchema, OPTIONS extends ZodFormatterOptions = {}>(schema: SCHEMA, options?: OPTIONS) => ItemZodFormatter<SCHEMA, OPTIONS>;