import { OpenApiZodAny } from '@anatine/zod-openapi'; import * as z from 'zod'; import type { TupleToUnion, Merge } from './types'; /** * This file was originally taken from: * https://github.com/kbkk/abitia/blob/master/packages/zod-dto/src/createZodDto.ts * * It is used to create a DTO from a Zod object. * I assume that the create method is called within NestJS. */ /** * ZodType is a very complex interface describing not just public properties but private ones as well * causing the interface to change fairly often among versions * * Since we're interested in the main subset of Zod functionality (type inferring + parsing) this type is introduced * to achieve the most compatibility. */ export type CompatibleZodType = Pick, '_input' | '_output' | 'parse' | 'safeParse'>; export type CompatibleZodInfer = T['_output']; export type MergeZodSchemaOutput = T extends z.ZodDiscriminatedUnion ? Merge> : T extends z.ZodUnion ? UnionTypes extends z.ZodType[] ? Merge> : T['_output'] : T['_output']; export type ZodDtoStatic = { new (): MergeZodSchemaOutput; zodSchema: T; create(input: unknown): CompatibleZodInfer; }; export declare const createZodDto: (zodSchema: T) => ZodDtoStatic;