import type { ZodType } from "./zod-like"; /** * A Parser is either a generic mapping function, or a Zod schema. * It's used for run-time validation and/or transformation * of the results of a field. */ export type Parser = ParserFunction | ZodType; /** * Same as `Parser`, except it allows for wider input types, * so that a value of `string` can be handled * by a parser that accepts `string | null` etc. */ export type ParserWithWidenedInput = ParserFunction | ZodType; export type InferParserInput = TParser extends Parser ? TInput : never; export type InferParserOutput = TParser extends Parser ? TOutput : never; /** * A generic "parser" object which can take any input and output a parsed type. */ export type ParserObject = { parse: ParserFunction; }; /** * A generic "parser" function which takes any input and outputs a parsed type. */ export type ParserFunction = (input: TInput) => TOutput; export type ParserFunctionMaybe = null | ParserFunction;