import { RoutePattern } from '@remix-run/route-pattern'; import { type RouteMetadata } from './metadata.js'; import type { RawBodySchema, RouteSchema } from './types/schema.js'; /** HTTP methods supported by Rouzer action declarations. */ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; /** * Callable endpoint leaf in an HTTP route tree. * * @remarks Actions declare one HTTP operation. Their property name becomes the * client/handler name, while their optional `path` contributes URL segments. */ export type HttpAction

= { /** Discriminator used internally when traversing route trees. */ kind: 'action'; /** Optional action-local path segment appended after parent resources. */ path?: RoutePattern

; /** HTTP method used when the client sends this action. */ method: M; /** Request validation and optional response type schema. */ schema: T; /** Optional runtime metadata for generated tooling. */ metadata?: RouteMetadata; }; /** * Path-scoped namespace in an HTTP route tree. * * @remarks Resources contribute URL path segments and contain child resources or * actions. They do not have handlers of their own. */ export type HttpResource

= { /** Discriminator used internally when traversing route trees. */ kind: 'resource'; /** Path segment contributed by this resource. */ path: RoutePattern

; /** Child resources and actions exposed below this resource. */ children: TChildren; /** Optional runtime metadata for generated tooling. */ metadata?: RouteMetadata; }; /** Node type accepted inside an HTTP route tree. */ export type HttpNode = HttpAction | HttpResource; /** Route tree accepted by HTTP clients and routers. */ export type HttpRouteTree = { [key: string]: HttpNode; }; type StringKeys = Pick>; /** * Declare an HTTP resource namespace. * * @remarks The resource `path` is joined with any parent resource path. Child * property names are API names only; they do not affect the URL unless the child * is another resource or an action with an explicit path. */ export declare function resource(path: P, children: TChildren): HttpResource>; /** Declare a GET action, optionally with an action-local path segment. */ export declare function get(path: P, schema: T): HttpAction; export declare function get(schema: T): HttpAction<'', T, 'GET'>; /** Declare a POST action, optionally with an action-local path segment. */ export declare function post(path: P, schema: T): HttpAction; export declare function post(schema: T): HttpAction<'', T, 'POST'>; /** Declare a PUT action, optionally with an action-local path segment. */ export declare function put(path: P, schema: T): HttpAction; export declare function put(schema: T): HttpAction<'', T, 'PUT'>; /** Declare a PATCH action, optionally with an action-local path segment. */ export declare function patch(path: P, schema: T): HttpAction; export declare function patch(schema: T): HttpAction<'', T, 'PATCH'>; /** Declare a DELETE action, optionally with an action-local path segment. */ declare function deleteAction(path: P, schema: T): HttpAction; declare function deleteAction(schema: T): HttpAction<'', T, 'DELETE'>; export { deleteAction as delete }; /** * Declare a request body that is passed through to `fetch` without JSON encoding. * * @remarks For routes with path or query input, pass the body as * `options.body`. For raw-body routes without input, generated client actions * accept the body as their first argument. */ export declare function rawBody(): RawBodySchema; export declare function isRawBodySchema(schema: unknown): schema is RawBodySchema;