import type { Hook, OpenAPIHono } from '@hono/zod-openapi'; import type { TDataRange } from '../../repositories/common/types'; import type { AnyType, TNullable, ValueOrPromise } from '@venizia/ignis-helpers/common'; import type { Env, Schema } from 'hono'; import type { TResponseFormat } from '../common/constants'; import type { IAuthRouteConfig, IBindRouteOptions, IDefineRouteOptions, TRouteContext, TRouteHandler } from '../common/types'; import { AbstractRestController } from './abstract'; import type { IRequestedExtra, TResponseExtra } from './extras'; /** `Content-Range` of a page: inclusive `end`, and `records * /` (no space) when the page is empty. Exported so a route that writes the header itself uses the one formatter. */ export declare const toContentRange: (opts: { range: TDataRange; count: number; }) => string; /** Recommended base class for REST controllers with concrete bindRoute and defineRoute implementations. */ export declare abstract class BaseRestController = Record> extends AbstractRestController { /** Runs a handler task under performance measurement (fixed logger/level/description). */ measure(opts: { scope: string; args: unknown; task: () => Promise; }): Promise; /** Returns the full `{ count, data }` envelope, or just `data` when the client sent `x-request-count: false`; `X-Response-Count` is set either way. */ normalizeCountData = TRouteContext, ResponseData extends { count: number; data?: TNullable; } = { count: number; data?: TNullable; }>(opts: { context: RequestContext; payload: ResponseData; }): TNullable | ResponseData; /** `x-request-extra`, parsed: `name`, `-name` (a default switched off) and `name(key,key)`. */ getRequestedExtras(opts: { context: TRouteContext; }): Array; /** * The one response call. Sets `X-Response-Format`, and with `range` (a list) also `Content-Range` - * `payload.count` is the rows of THIS response, never the total - then normalizes count/data per * the request-count header. * * `extra` offers figures beside the rows (see {@link TResponseExtra}): each runs when the client * names it in `x-request-extra`, or always when it is a default. When any runs, the body is * `{ data, extra }` (with `count` when it is requested); when none does, nothing is computed and the * body is what it would be without `extra`. A name the route does not offer is a 400 listing the * ones it does. */ respond(opts: { context: TRouteContext; format: TResponseFormat; payload: { count: number; data?: TNullable; }; range?: TDataRange; extra?: never; }): R | { count: number; data?: TNullable; } | null | undefined; respond>(opts: { context: TRouteContext; format: TResponseFormat; payload: { count: number; data?: TNullable; }; range?: TDataRange; extra: Extra; }): Promise; } | { count?: number; data?: TNullable; extra: Partial>; } | null | undefined>; respond(opts: { context: TRouteContext; format: TResponseFormat; payload: { count: number; data?: TNullable; }; range?: TDataRange; extra?: Record; }): ValueOrPromise; extra?: Record; } | null | undefined>; /** The `extra` half of `respond`: resolves what was asked against what is offered, runs it in parallel. */ respondWithExtra(opts: { context: TRouteContext; payload: { count: number; data?: TNullable; }; extra: Record; }): Promise; } | { count: number; data: TNullable; extra: Record; } | { data: TNullable; extra: Record; count?: undefined; } | null | undefined>; /** The list headers without the body, for a list whose body is not a `{ count, data }` envelope: `Content-Range`, `X-Response-Count` = rows in THIS response, `X-Response-Format: array`. Pass a `range`, or `offset` + `total` for an engine that reports those (a search page): the range is derived with the same inclusive-end rule. */ setListHeaders(opts: { context: TRouteContext; count: number; } & ({ range: TDataRange; } | { offset: number; total: number; })): void; /** TRouteHandler's TRouteContext is a lightweight custom shape (different `json`/`req.valid` signatures) built on Hono's real Context, not a subtype of the RouteHandler `.openapi()` expects - genuinely different handler types bridged here. */ toHonoHandler(opts: { handler: TRouteHandler; }): Parameters["openapi"]>[1]; /** Creates a fluent binding for registering a route (call .to() to attach handler). */ bindRoute(opts: { configs: RouteConfig; }): IBindRouteOptions; /** Defines and registers a route with its handler in a single call. */ defineRoute(opts: { configs: RouteConfig; handler: TRouteHandler; hook?: Hook>; }): IDefineRouteOptions; /** Defines a JSX route that renders server-side HTML via c.html(). */ defineJSXRoute(opts: { configs: RouteConfig; handler: TRouteHandler; hook?: Hook>; }): IDefineRouteOptions; } //# sourceMappingURL=base.d.ts.map