import type { ResolvedField } from '../schema/types.js'; export interface ParsedFilter { field: string; operator: string; value: unknown; } export interface ParsedSort { field: string; direction: 'asc' | 'desc'; } export interface ParsedPagination { page: number; limit: number; offset: number; } export interface ParsedInclude { relation: string; nested?: ParsedInclude[]; } export interface ParsedQuery { filters: ParsedFilter[]; sort: ParsedSort[]; pagination: ParsedPagination; includes: ParsedInclude[]; fields: string[]; search?: string; } /** * Parses incoming query-string parameters into a structured, validated query object. * Validates field names, operators, and types against the entity schema. */ export declare class QueryParser { private readonly fieldMap; private readonly relationNames; constructor(fields: ResolvedField[], relationNames: string[]); /** Parse all query sections at once. */ parse(query: Record): ParsedQuery; /** * Parse filter conditions from `query.filter`. * Expected shape: { filter: { fieldName: { operator: value } } } */ parseFilters(query: Record): ParsedFilter[]; /** * Parse sort directives from `query.sort`. * Expected format: "field1,-field2" (prefix with `-` for descending). */ parseSort(query: Record): ParsedSort[]; /** Parse page/limit from the query, applying defaults and bounds. */ parsePagination(query: Record): ParsedPagination; /** * Parse relation includes from `query.include`. * Supports dot notation for nested relations up to depth 2: "posts.comments" */ parseIncludes(query: Record): ParsedInclude[]; /** * Parse sparse fieldsets from `query.fields`. * Always ensures "id" is included. */ parseFields(query: Record): string[]; /** Look up a field config, throwing if the field is not recognized. */ private getFieldConfigOrThrow; /** Validate that the operator is allowed for the field's type. */ private validateOperatorForType; /** Coerce a raw query value to the appropriate JS type based on the operator and field config. */ private coerceValue; /** Coerce a single string value to its typed representation (number, boolean, or string). */ private coerceSingleValue; /** Parse and validate the page number, defaulting to 1 if invalid. */ private parsePageNumber; /** Parse and validate the limit, clamping to [MIN_LIMIT, MAX_LIMIT]. */ private parseLimit; /** Parse the search term from the query, trimming whitespace. */ parseSearch(query: Record): string | undefined; } /** Thrown when a query string contains invalid field names, operators, or values. */ export declare class QueryValidationError extends Error { readonly statusCode = 400; readonly code = "QUERY_VALIDATION_ERROR"; constructor(message: string); } //# sourceMappingURL=query-parser.d.ts.map