/** * Represents a failed action result. Returned by `fail()` from server actions. * * The `__nix_js_action_failure` marker is set on the instance so the server can * detect it even when the value crosses a bundling boundary (e.g. the CLI is * bundled separately from the user's action modules). */ export declare class ActionFailure { status: number; data: TData; readonly __nix_js_action_failure = true; constructor(status: number, data: TData); } /** * Represents a redirect returned by a server action. Returned by `redirect()`. */ export declare class RedirectResponse { status: number; location: string; readonly __nix_js_action_redirect = true; constructor(status: number, location: string); } /** * Helper to return a validation/error response from a server action. * * Both argument orders are accepted: * * ```ts * return fail(400, { email: "Invalid email" }); * return fail({ email: "Invalid email" }, 400); * return fail({ email: "Invalid email" }); // defaults to status 400 * ``` */ export declare function fail(statusOrData: number | TData, dataOrStatus?: TData | number): ActionFailure; /** * Helper to return a redirect from a server action. * * Both argument orders are accepted: * * ```ts * return redirect(303, "/login"); * return redirect("/login"); // defaults to status 303 * ``` */ export declare function redirect(statusOrLocation: number | string, locationOrStatus?: string | number): RedirectResponse; /** * Type guard for action failures. Uses the marker field so it works across * bundling boundaries where `instanceof` fails. */ export declare function isActionFailure(value: unknown): value is ActionFailure; /** * Type guard for redirects. Uses the marker field so it works across bundling * boundaries where `instanceof` fails. */ export declare function isRedirectResponse(value: unknown): value is RedirectResponse; /** * A stable, publicly safe error description. Never includes stacks, internal * paths or messages that could leak secrets or filesystem details. */ export interface PublicErrorInfo { /** Stable machine-readable code for the response body. */ code: string; /** Stable public message. In non-production this may include the raw message. */ message: string; status: number; } /** * Maps an arbitrary thrown value to a public-safe error info. By default the * public message is generic; `includeDetail` (dev/verbose mode) appends the * original `Error.message` for local debugging. */ export declare function toPublicErrorInfo(error: unknown, options?: { includeDetail?: boolean; }): PublicErrorInfo; /** * Builds a production-safe JSON error Response. Logs the raw error separately * (never reflected in the response body) and keeps the request id header. */ export declare function publicErrorResponse(error: unknown, options?: { includeDetail?: boolean; requestId?: string; }): Response; /** True when the error should be re-thrown as control flow instead of a 500. */ export declare function isFirstClassResponse(error: unknown): error is Response;