/** * Global route tree. One instance per app, lives on `app.routeRegistry`. * * Producers (controllers, ad-hoc routes) register subtrees here. Consumers * (the runtime adapter, codegen, OpenAPI / MCP emitters) walk it. */ import type { FlatRoute, HandlerEntry, HttpMethod, MatchResult, RouteNode } from './RouteNode.ts'; /** Construct an empty node with the given segment. */ export declare function createNode(segment: string): RouteNode; export declare class RouteRegistry { readonly root: RouteNode; /** * Mount a subtree at a path prefix. Intermediate nodes are created; * existing ones are merged (middlewares appended, methods added, * children recursively merged). Conflicting handlers throw. * * The subtree's root `segment` is metadata only — its CONTENTS go * under `prefix` (mount-style convention). Wrap with `{ segment: '', * children: ... }` for clean semantics; `translateController` does * exactly that. */ registerSubtree(prefix: string, subtree: RouteNode): void; /** * Register a single ad-hoc route. Escape hatch for routes that don't * fit the controller convention (webhooks, healthchecks, OAuth callbacks). */ registerRoute(method: HttpMethod, path: string, entry: HandlerEntry): void; /** Walk depth-first; `fullPath` is the slash-joined path to the node. */ walk(visitor: (node: RouteNode, fullPath: string) => void): void; /** * Flatten to one entry per (method, full-path) leaf. Middlewares are * accumulated root → leaf; `bodyParsing` inherits leaf-wins. */ flatten(): FlatRoute[]; /** Match a request. See `MatchResult` for return cases (404 / 405 / hit). */ match(method: string, path: string): MatchResult | null; } /** * Descend one segment, creating the child if absent. The single source of the * segment-keying scheme (lowercase static keys, `:`/`*` folded onto the * param/splat child). Shared with the controller subtree assembler so producers * key children exactly as the matcher looks them up. */ export declare function ensureChildBySegment(node: RouteNode, segment: string): RouteNode;