import type { IDslBuilder, InferDslDefinition, InferSchema } from "schema-dsl/pure"; /** Request locations supported by RouteOptions.validate and req.valid(). */ export type VextValidationLocation = "query" | "body" | "param" | "header" | "cookie"; /** Broad validated-data shape used when a handler has no route schema context. */ export type VextDefaultValidatedData = Record>; /** Shape consumed by a typed VextRequest or VextHandler. */ export type VextValidatedData = Record; /** * Infer the runtime value represented by one Vext schema definition. * * schema-dsl owns DSL-string and object inference. Vext only adapts its * single-item array shorthand and deliberately treats chainable builders as * unknown because their runtime mutations cannot be recovered from the * public builder interface alone. */ type NormalizeVextSchema = TSchema extends IDslBuilder ? true : TSchema extends readonly [infer TItem] ? { type: "array"; items: NormalizeVextSchema; } : TSchema extends readonly (infer TItem)[] ? { type: "array"; items: NormalizeVextSchema; } : TSchema extends { type: unknown; } | { properties: unknown; } | { oneOf: unknown; } | { anyOf: unknown; } | { enum: unknown; } | { const: unknown; } ? TSchema : TSchema extends Record ? { [TKey in keyof TSchema]: NormalizeVextSchema; } : TSchema; export type InferVextSchema = InferSchema>; type InferVextValidationSchema = TSchema extends Record ? InferDslDefinition<{ [TKey in keyof TSchema]: NormalizeVextSchema; }> : InferVextSchema; type InferVextValidationLocation = TValidation extends object ? TLocation extends keyof TValidation ? InferVextValidationSchema> : undefined : undefined; /** Map RouteOptions.validate into the five req.valid() result locations. */ export type InferVextValidation = { [TLocation in VextValidationLocation]: InferVextValidationLocation; }; export {};