import type { MiddlewareHandler } from 'hono'; /** * Which of production's two validation pipes guards the operation's query, and so how an unknown * parameter is reported. Both answer 422 with `message: 'Validation failed'`: * * - `validation` (`ValidationPipe`): `errors: [{ field, code: 'property should not exist' }]` * and no top-level `code`. * - `validation_with_error_code` (`ValidationWithErrorCodePipe`): `code: * 'invalid_request_parameters'` and `errors: [{ code: '_not_supported', message: * 'property should not exist' }]`. */ export type StrictQueryPipe = 'validation' | 'validation_with_error_code'; /** An operation whose query takes only the parameters it declares. */ export interface StrictQueryRule { method: string; /** The path as an OpenAPI template: `/organizations/{organizationId}/groups`. */ path: string; allowed: readonly string[]; pipe: StrictQueryPipe; } /** * The property a query key names once production has parsed the query. Production parses with * `qs` (Express's extended parser), so `name[]=`, `name[0]=` and `name[key]=` all name the * property `name`, a key that opens with a bracket names what the bracket holds, and a key that * is empty or `__proto__` names nothing. */ export declare function queryPropertyName(key: string): string | undefined; /** The properties of a query that `allowed` does not list, each once, in the order they first appear. */ export declare function unknownQueryProperties(params: URLSearchParams, allowed: ReadonlySet): string[]; /** * Refuses a query parameter the operation does not declare, for the operations in `rules`, the * way production's query pipe does under `forbidNonWhitelisted`. Register it after authentication * and before the routes: production's guards run before its pipes and its pipes before the handler, * so a bad credential is still a 401, while an unknown parameter is a 422 even when the path names * something that does not exist. The values of the declared parameters are not checked here. */ export declare function strictQueryMiddleware(rules: readonly StrictQueryRule[]): MiddlewareHandler;