import { DIRECT_HTTP_ROUTES } from '../route-model.ts'; /** Union of all handler names derived from the shared direct-route model. */ export type DirectRouteHandlerName = (typeof DIRECT_HTTP_ROUTES)[number]['handler']; export type RouteMatch = { handler: DirectRouteHandlerName; params: Record; path: string; }; export declare function matchDirectRoute(method: string, pathname: string): RouteMatch | null; /** * Extract path parameter values from a regex match against a route pattern. * * Pairs the ordered `parameterNames` (from the route's compiled pattern) * with the corresponding capture groups in `match`, decoding each value with * `decodeURIComponent`. Used by route dispatchers to turn a regex hit into a * `{ paramName: value }` map for the operation handler. * * The in-tree direct routes are parameter-free meta endpoints. The function * remains public for tests and user-supplied route extensions. * * @example Extract route params from a synthetic custom route * ```ts * import { extractRouteParameters } from '@lostgradient/weft/server/handler'; * * const pattern = /^\/projects\/([^/]+)\/workflows\/([^/]+)$/; * const match = pattern.exec('/projects/acme/workflows/wf-42'); * if (match) { * const params = extractRouteParameters(['projectId', 'workflowId'], match); * console.log(params); // { projectId: 'acme', workflowId: 'wf-42' } * } * ``` */ export declare function extractRouteParameters(parameterNames: readonly string[], match: Pick): Record; /** * Extracts a named parameter from a route parameter map, throwing a descriptive * `Error` if the parameter is absent. * * Used by direct-route helpers and any user-supplied route handlers that * extend the catalog. In-tree `RestBinding` routes do not call this function; * they receive a pre-populated `pathParams` map from `bindingPathMatches` via * `RestBinding.extractInput`. * * @example * ```ts * import { getRequiredRouteParameter } from '@lostgradient/weft/server/handler'; * * const params = { workflowId: 'wf-123' }; * const id = getRequiredRouteParameter(params, 'workflowId', 'GET /v1/workflows/:workflowId'); * console.log(id); // 'wf-123' * * // Throws: Missing route parameter "workflowId" for GET /v1/workflows/:workflowId * getRequiredRouteParameter({}, 'workflowId', 'GET /v1/workflows/:workflowId'); * ``` */ export declare function getRequiredRouteParameter(params: Record, name: string, routeDescription: string): string;