import { Try } from '@oats-ts/try' import { ValidatorConfig } from '@oats-ts/validators' /** Types that can be individual parameter values */ export type Primitive = string | number | boolean export type PrimitiveArray = ReadonlyArray export type PrimitiveRecord = Record /** Union type for above */ export type ParameterValue = Primitive | PrimitiveArray | PrimitiveRecord export type FieldParsers = { [P in keyof T]: ValueParser } /** Object, collection of named parameter values */ export type ParameterObject = Record export type ValueParser = ( input: I, name: string, path: string, config: ValidatorConfig, ) => Try /** Query related types */ export type QueryOptions = { explode?: boolean required?: boolean } export type RawQueryParams = Record export type QueryValueDeserializer = ( value: RawQueryParams, name: string, path: string, config: ValidatorConfig, ) => Try export type QueryValueDeserializers = { [P in keyof T]: QueryValueDeserializer } export type QueryDeserializer = ( input: string, path?: string, config?: ValidatorConfig, ) => Try /** Path related types */ export type PathOptions = { explode?: boolean } export type RawPathParams = Record export type PathValueDeserializer = ( value: RawPathParams, name: string, path: string, config: ValidatorConfig, ) => Try export type PathValueDeserializers = { [P in keyof T]: PathValueDeserializer } export type PathDeserializer = ( input: string, path?: string, config?: ValidatorConfig, ) => Try /** Header related types */ export type HeaderOptions = { explode?: boolean required?: boolean } export type RawHeaders = Record export type HeaderValueDeserializer = ( value: RawHeaders, name: string, path: string, config: ValidatorConfig, ) => Try export type HeaderValueDeserializers = { [P in keyof T]: HeaderValueDeserializer } export type HeaderDeserializer = ( input: RawHeaders, path?: string, config?: ValidatorConfig, ) => Try