import { u as AnyContext, z as RouterExtension } from "../router-Cwb7ak0J.mjs"; import { n as RoutekitResponse } from "../core-CzUCxvGk.mjs"; import { a as ok, c as ProblemError, d as ProblemResponse, f as StandardResponse, i as ValidationProblemInit, l as ProblemIssue, n as SuccessResponseInit, o as problem, p as SuccessResponse, r as VALIDATION_PROBLEM_CODE, s as validationProblem, t as ProblemResponseInit, u as ProblemIssuePathSegment } from "../responses-B379Ep9Y.mjs"; import { HttpStatus } from "@mpen/http"; //#region src/router/response/formats/problem/created.d.ts /** * Create a `201 Created` standard response envelope. * * @example * ```ts * router.post('/users', () => created({ id: 'user_123' })) * ``` * * @param data - Successful response payload. * @param init - Response headers and optional metadata. * @returns Routekit logical response with an [`SuccessResponse`]{@link SuccessResponse} body. * @typeParam Data - Successful response payload type. * @typeParam Meta - Optional metadata payload type. */ declare function created(data: Data, init?: SuccessResponseInit): RoutekitResponse, HttpStatus.CREATED>; //#endregion //#region src/router/response/formats/problem/notFound.d.ts /** * Options accepted by [`notFound`]{@link notFound}. * * @example * ```ts * notFound({ * message: 'No user exists for the provided id.', * }) * ``` * * @typeParam Code - Machine-readable primary error code. */ interface NotFoundInit extends Omit, 'code' | 'status' | 'message'> { /** * Machine-readable error code. Defaults to `'not_found'`. */ code?: Code; /** * Human-readable problem message. */ message?: string; /** * HTTP status code for this response. Defaults to `404`. */ status?: number | HttpStatus; } /** * Create a standard 404 Not Found problem response envelope. * * @example * ```ts * return notFound('Todo not found.') * ``` * * @param message - Human-readable problem message. * @param init - Optional extra problem response options. * @returns Routekit logical response with a `'not_found'` [`ProblemResponse`]{@link ProblemResponse}. */ declare function notFound(message: string, init?: Omit, 'message'>): RoutekitResponse>; /** * Create a standard 404 Not Found problem response envelope. * * @example * ```ts * return notFound({ message: 'Todo not found.' }) * ``` * * @param init - Optional problem response options. * @returns Routekit logical response with a [`ProblemResponse`]{@link ProblemResponse}. * @typeParam Code - Machine-readable primary error code. */ declare function notFound(init?: NotFoundInit): RoutekitResponse>; //#endregion //#region src/router/response/formats/problem/permissionDenied.d.ts /** * Options accepted by [`permissionDenied`]{@link permissionDenied}. * * @example * ```ts * permissionDenied({ * message: 'You do not have permission to perform this action.', * }) * ``` * * @typeParam Code - Machine-readable primary error code. */ interface PermissionDeniedInit extends Omit, 'code' | 'status' | 'message'> { /** * Machine-readable error code. Defaults to `'permission_denied'`. */ code?: Code; /** * Human-readable problem message. */ message?: string; /** * HTTP status code for this response. Defaults to `403`. */ status?: number | HttpStatus; } /** * Create a standard 403 Permission Denied problem response envelope. * * @example * ```ts * return permissionDenied('You are not authorized to edit this profile.') * ``` * * @param message - Human-readable problem message. * @param init - Optional extra problem response options. * @returns Routekit logical response with a `'permission_denied'` [`ProblemResponse`]{@link ProblemResponse}. */ declare function permissionDenied(message: string, init?: Omit, 'message'>): RoutekitResponse>; /** * Create a standard 403 Permission Denied problem response envelope. * * @example * ```ts * return permissionDenied({ message: 'Insufficient scope.' }) * ``` * * @param init - Optional problem response options. * @returns Routekit logical response with a [`ProblemResponse`]{@link ProblemResponse}. * @typeParam Code - Machine-readable primary error code. */ declare function permissionDenied(init?: PermissionDeniedInit): RoutekitResponse>; //#endregion //#region src/router/response/formats/problem/unauthenticated.d.ts /** * Options accepted by [`unauthenticated`]{@link unauthenticated}. * * @example * ```ts * unauthenticated({ * message: 'You must be logged in to access this resource.', * }) * ``` * * @typeParam Code - Machine-readable primary error code. */ interface UnauthenticatedInit extends Omit, 'code' | 'status' | 'message'> { /** * Machine-readable error code. Defaults to `'unauthenticated'`. */ code?: Code; /** * Human-readable problem message. */ message?: string; /** * HTTP status code for this response. Defaults to `401`. */ status?: number | HttpStatus; } /** * Create a standard 401 Unauthenticated problem response envelope. * * @example * ```ts * return unauthenticated('Missing authorization token.') * ``` * * @param message - Human-readable problem message. * @param init - Optional extra problem response options. * @returns Routekit logical response with a `'unauthenticated'` [`ProblemResponse`]{@link ProblemResponse}. */ declare function unauthenticated(message: string, init?: Omit, 'message'>): RoutekitResponse>; /** * Create a standard 401 Unauthenticated problem response envelope. * * @example * ```ts * return unauthenticated({ message: 'Invalid credentials.' }) * ``` * * @param init - Optional problem response options. * @returns Routekit logical response with a [`ProblemResponse`]{@link ProblemResponse}. * @typeParam Code - Machine-readable primary error code. */ declare function unauthenticated(init?: UnauthenticatedInit): RoutekitResponse>; //#endregion //#region src/router/response/formats/problem/sessionExpired.d.ts /** * Options accepted by [`sessionExpired`]{@link sessionExpired}. * * @example * ```ts * sessionExpired({ * message: 'Your login session has expired. Please log in again.', * }) * ``` * * @typeParam Code - Machine-readable primary error code. */ interface SessionExpiredInit extends Omit, 'code' | 'status' | 'message'> { /** * Machine-readable error code. Defaults to `'session_expired'`. */ code?: Code; /** * Human-readable problem message. */ message?: string; /** * HTTP status code for this response. Defaults to `401`. */ status?: number | HttpStatus; } /** * Create a standard 401 Session Expired problem response envelope. * * @example * ```ts * return sessionExpired('Session has timed out.') * ``` * * @param message - Human-readable problem message. * @param init - Optional extra problem response options. * @returns Routekit logical response with a `'session_expired'` [`ProblemResponse`]{@link ProblemResponse}. */ declare function sessionExpired(message: string, init?: Omit, 'message'>): RoutekitResponse>; /** * Create a standard 401 Session Expired problem response envelope. * * @example * ```ts * return sessionExpired({ message: 'Session expired.' }) * ``` * * @param init - Optional problem response options. * @returns Routekit logical response with a [`ProblemResponse`]{@link ProblemResponse}. * @typeParam Code - Machine-readable primary error code. */ declare function sessionExpired(init?: SessionExpiredInit): RoutekitResponse>; //#endregion //#region src/router/response/formats/problem/badRequest.d.ts /** * Options accepted by [`badRequest`]{@link badRequest}. * * @example * ```ts * badRequest({ * message: 'The request is malformed.', * }) * ``` * * @typeParam Code - Machine-readable primary error code. */ interface BadRequestInit extends Omit, 'code' | 'status' | 'message'> { /** * Machine-readable error code. Defaults to `'bad_request'`. */ code?: Code; /** * Human-readable problem message. */ message?: string; /** * HTTP status code for this response. Defaults to `400`. */ status?: number | HttpStatus; } /** * Create a standard 400 Bad Request problem response envelope. * * @example * ```ts * return badRequest('Invalid query parameter format.') * ``` * * @param message - Human-readable problem message. * @param init - Optional extra problem response options. * @returns Routekit logical response with a `'bad_request'` [`ProblemResponse`]{@link ProblemResponse}. */ declare function badRequest(message: string, init?: Omit, 'message'>): RoutekitResponse>; /** * Create a standard 400 Bad Request problem response envelope. * * @example * ```ts * return badRequest({ message: 'Malformed payload.' }) * ``` * * @param init - Optional problem response options. * @returns Routekit logical response with a [`ProblemResponse`]{@link ProblemResponse}. * @typeParam Code - Machine-readable primary error code. */ declare function badRequest(init?: BadRequestInit): RoutekitResponse>; //#endregion //#region src/router/response/formats/problem/conflict.d.ts /** * Options accepted by [`conflict`]{@link conflict}. * * @example * ```ts * conflict({ * message: 'The resource already exists.', * }) * ``` * * @typeParam Code - Machine-readable primary error code. */ interface ConflictInit extends Omit, 'code' | 'status' | 'message'> { /** * Machine-readable error code. Defaults to `'conflict'`. */ code?: Code; /** * Human-readable problem message. */ message?: string; /** * HTTP status code for this response. Defaults to `409`. */ status?: number | HttpStatus; } /** * Create a standard 409 Conflict problem response envelope. * * @example * ```ts * return conflict('A user with this email address already exists.') * ``` * * @param message - Human-readable problem message. * @param init - Optional extra problem response options. * @returns Routekit logical response with a `'conflict'` [`ProblemResponse`]{@link ProblemResponse}. */ declare function conflict(message: string, init?: Omit, 'message'>): RoutekitResponse>; /** * Create a standard 409 Conflict problem response envelope. * * @example * ```ts * return conflict({ message: 'State conflict.' }) * ``` * * @param init - Optional problem response options. * @returns Routekit logical response with a [`ProblemResponse`]{@link ProblemResponse}. * @typeParam Code - Machine-readable primary error code. */ declare function conflict(init?: ConflictInit): RoutekitResponse>; //#endregion //#region src/router/response/formats/problem/rateLimited.d.ts /** * Options accepted by [`rateLimited`]{@link rateLimited}. * * @example * ```ts * rateLimited({ * message: 'Too many requests. Please try again later.', * }) * ``` * * @typeParam Code - Machine-readable primary error code. */ interface RateLimitedInit extends Omit, 'code' | 'status' | 'message'> { /** * Machine-readable error code. Defaults to `'rate_limited'`. */ code?: Code; /** * Human-readable problem message. */ message?: string; /** * HTTP status code for this response. Defaults to `429`. */ status?: number | HttpStatus; } /** * Create a standard 429 Too Many Requests problem response envelope. * * @example * ```ts * return rateLimited('Rate limit exceeded. Please wait 60 seconds.') * ``` * * @param message - Human-readable problem message. * @param init - Optional extra problem response options. * @returns Routekit logical response with a `'rate_limited'` [`ProblemResponse`]{@link ProblemResponse}. */ declare function rateLimited(message: string, init?: Omit, 'message'>): RoutekitResponse>; /** * Create a standard 429 Too Many Requests problem response envelope. * * @example * ```ts * return rateLimited({ message: 'Rate limit exceeded.' }) * ``` * * @param init - Optional problem response options. * @returns Routekit logical response with a [`ProblemResponse`]{@link ProblemResponse}. * @typeParam Code - Machine-readable primary error code. */ declare function rateLimited(init?: RateLimitedInit): RoutekitResponse>; //#endregion //#region src/router/response/formats/problem/root-errors.d.ts /** * Install standard problem-envelope handlers for router-level errors. * * @example * ```ts * const router = new Router().install(problemRootErrors()) * ``` * * @returns Router extension that registers not-found, method, media-type, and internal-error handlers. * @typeParam Ctx - Context carried by the router being configured. */ declare function problemRootErrors(): RouterExtension; //#endregion export { type BadRequestInit, type ConflictInit, type NotFoundInit, type PermissionDeniedInit, type ProblemError, type ProblemIssue, type ProblemIssuePathSegment, type ProblemResponse, type ProblemResponseInit, type RateLimitedInit, type SessionExpiredInit, type StandardResponse, type SuccessResponse, type SuccessResponseInit, type UnauthenticatedInit, VALIDATION_PROBLEM_CODE, type ValidationProblemInit, badRequest, conflict, created, notFound, ok, permissionDenied, problem, problemRootErrors, rateLimited, sessionExpired, unauthenticated, validationProblem };