UNPKG

dynamodb-toolbox

Version:

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

17 lines (16 loc) 1.07 kB
import { z } from 'zod'; import type { Schema, TupleSchema } from '../../../../schema/index.js'; import type { Overwrite } from '../../../../types/overwrite.js'; import type { WithValidate } from '../utils.js'; import type { SchemaZodFormatter } from './schema.js'; import type { ZodFormatterOptions } from './types.js'; import type { SchemaZodFormatterRec, WithOptional } from './utils.js'; export type TupleZodFormatter<SCHEMA extends TupleSchema, OPTIONS extends ZodFormatterOptions = {}> = TupleSchema extends SCHEMA ? z.ZodTypeAny : WithOptional<SCHEMA, OPTIONS, WithValidate<SCHEMA, SCHEMA['elements'] extends [infer SCHEMAS_HEAD, ...infer SCHEMAS_TAIL] ? SCHEMAS_HEAD extends Schema ? SCHEMAS_TAIL extends Schema[] ? z.ZodTuple<[ SchemaZodFormatter<SCHEMAS_HEAD, Overwrite<OPTIONS, { defined: false; }>>, ...SchemaZodFormatterRec<SCHEMAS_TAIL, Overwrite<OPTIONS, { defined: false; }>> ]> : never : never : z.ZodTypeAny>>; export declare const tupleZodFormatter: (schema: TupleSchema, options?: ZodFormatterOptions) => z.ZodTypeAny;