UNPKG

next-action-forge

Version:

A simple, type-safe toolkit for Next.js server actions with Zod validation

53 lines (48 loc) 2.16 kB
export { A as ActionResult, E as ExtractSuccessData, I as IsErrorResponse, R as RedirectConfig, b as ServerAction, S as ServerActionError, a as ServerActionResponse } from './index-CeOJE6T8.js'; export { ServerActionClient, createActionClient, handleServerActionError, isErrorResponse } from './core/index.js'; import 'zod'; declare enum RedirectStatusCode { SeeOther = 303, TemporaryRedirect = 307, PermanentRedirect = 308 } declare const REDIRECT_ERROR_CODE = "NEXT_REDIRECT"; declare enum RedirectType { push = "push", replace = "replace" } type RedirectError = Error & { digest: `${typeof REDIRECT_ERROR_CODE};${RedirectType};${string};${RedirectStatusCode};`; }; /** * Checks an error to determine if it's an error generated by the * `redirect(url)` helper. * * @param error the error that may reference a redirect error * @returns true if the error is a redirect error */ declare function isRedirectError(error: unknown): error is RedirectError; declare const HTTP_ERROR_FALLBACK_ERROR_CODE = "NEXT_HTTP_ERROR_FALLBACK"; type HTTPAccessFallbackError = Error & { digest: `${typeof HTTP_ERROR_FALLBACK_ERROR_CODE};${string}`; }; /** * Checks an error to determine if it's an error generated by * the HTTP navigation APIs `notFound()`, `forbidden()` or `unauthorized()`. * * @param error the error that may reference a HTTP access error * @returns true if the error is a HTTP access error */ declare function isHTTPAccessFallbackError(error: unknown): error is HTTPAccessFallbackError; /** * Checks if the error is a navigation error that should be re-thrown * This includes redirect errors and HTTP access errors (notFound, forbidden, unauthorized) */ declare function isNextNavigationError(error: unknown): boolean; /** * Checks if the error is a notFound error * Note: Next.js implements notFound() using HTTP_ERROR_FALLBACK with status 404, * not as a separate error type like NEXT_REDIRECT */ declare function isNotFoundError(error: unknown): boolean; export { type HTTPAccessFallbackError, type RedirectError, isHTTPAccessFallbackError, isNextNavigationError, isNotFoundError, isRedirectError };