import type { Mastra } from '@mastra/core/mastra'; import type { RequestContext } from '@mastra/core/request-context'; import type { ServerRoute, ZodErrorLike } from '@mastra/server/server-adapter'; import type { MastraModuleOptions } from '../mastra.module.js'; export interface RouteMatch { route: ServerRoute; pathParams: Record; } export interface RouteHandlerParams { /** URL path parameters (e.g., { agentId: '123' }) */ pathParams: Record; /** Query string parameters */ queryParams: Record; /** Request body (for POST/PUT/PATCH) */ body: unknown; /** Request context (user, session, etc.) */ requestContext: RequestContext; /** Abort signal for request cancellation */ abortSignal: AbortSignal; /** The web-standard Request object for accessing headers, cookies, etc. */ request?: Request; } export interface RouteHandlerResult { /** The result data from the handler */ data: unknown; /** Response type determines how to send the response */ responseType: 'json' | 'stream' | 'datastream-response' | 'mcp-http' | 'mcp-sse'; /** Stream format (only for 'stream' responseType) */ streamFormat?: 'sse' | 'stream'; /** Whether to flush an SSE comment on connect before stream data arrives */ sseFlushOnConnect?: boolean; } /** * Service that bridges NestJS controllers to Mastra route handlers. * Handles parameter validation and invokes the appropriate handler. */ export declare class RouteHandlerService { private readonly mastra; private readonly options; private readonly logger; private readonly routeMap; private readonly reservedParamKeys; constructor(mastra: Mastra, options: MastraModuleOptions); /** * Register a route with the catch-all NestJS controller. */ registerRoute(route: ServerRoute): void; /** * Find a route by exact method and path pattern. * Use matchRoute() for parameterized path matching. */ findRoute(method: string, path: string): ServerRoute | undefined; /** * Match a request method and path against registered routes. * Handles both exact matches and parameterized path patterns. * * @param method - HTTP method (GET, POST, etc.) * @param path - Request path to match * @returns Route match with path parameters, or null if no match */ matchRoute(method: string, path: string): RouteMatch | null; /** * Get all routes (for dynamic controller generation). */ getAllRoutes(): readonly ServerRoute[]; /** * Match a path against a route pattern. * Returns path parameters if matched, null otherwise. */ private matchPath; /** * Execute a route handler with the given parameters. */ executeHandler(route: ServerRoute, params: RouteHandlerParams): Promise; private parseBody; private createValidationError; private getRouteKey; private omitReservedKeys; } /** * Error class for validation failures with Zod error details. * * `zodError` is typed as `ZodErrorLike` (a structural subset of `ZodError` * exposing `issues[]`) so that consumers pinning a different `zod` major than * the one bundled with this adapter still type-check. The runtime value is * the actual `ZodError` thrown by the route schema and supports all of its * methods at runtime — cast to your installed `ZodError` if you need them. */ export declare class ValidationError extends Error { readonly zodError: ZodErrorLike; readonly status: number; readonly body: unknown; constructor(message: string, zodError: ZodErrorLike, status?: number, body?: unknown); } //# sourceMappingURL=route-handler.service.d.ts.map