import type { IsAny, KnownAny } from './utils.js'; /** * Represents a cookie object */ export type VovkRequestCookie = { name: string; value: string; [key: string]: string; }; type RawSearchParamValue = T extends string ? T : string; type SearchParamItem = T extends readonly (infer ITEM)[] ? ITEM : T; type RawQuery = unknown extends TQueryInput ? TQuery : TQueryInput; type SearchParamValue = {} extends Pick ? RawSearchParamValue> | null : unknown extends T[KEY] ? string : undefined extends T[KEY] ? RawSearchParamValue> | null : T[KEY] extends object ? string | null : RawSearchParamValue; type IsQueryTyped = IsAny extends true ? true : unknown extends T ? false : [T] extends [null | undefined] ? false : true; type SearchParamKey = IsQueryTyped extends true ? keyof T & string : string; type SearchParams = { get: >(key: KEY) => IsQueryTyped extends true ? SearchParamValue : string | null; getAll: >(key: KEY) => IsQueryTyped extends true ? RawSearchParamValue>[] : string[]; has: >(key: KEY, value?: string) => boolean; entries: () => IterableIterator<[string, string]>; forEach: (callbackfn: (value: string, key: string) => void) => void; keys: () => IterableIterator; values: () => IterableIterator; }; /** * The Vovk.ts request object extending Next.js's NextRequest, generics: TBody, TQuery, TParams. * TBodyInput and TQueryInput are what the client sent, before a schema's defaults and transforms. * @see https://vovk.dev/procedure */ export interface VovkRequest extends Request { json: () => Promise; cookies: { set: (name: string, value: string) => void; get: (name: string) => VovkRequestCookie | undefined; getAll: (name?: string) => VovkRequestCookie[]; delete: (name: string) => boolean; has: (name: string) => boolean; clear: () => void; }; nextUrl: { basePath: string; buildId: string | undefined; pathname: string; search: string; searchParams: SearchParams>; }; vovk: { body: () => Promise; query: () => TQuery; meta: >(meta?: T | null) => T; params: () => TParams; }; } export {};