@kellanjs/actioncraft
Version:
Fluent, type-safe builder for Next.js server actions.
16 lines (15 loc) • 915 B
TypeScript
import type { CraftedAction } from "./types/actions.js";
import type { BaseError } from "./types/errors.js";
import type { Result } from "./types/result.js";
import type { ApiResult, ThrowableAction } from "./types/shared.js";
/**
* Unwraps an ActionCraft result, returning the data or throwing an error.
* Supports both async and sync usage patterns.
*/
export declare function unwrap<TData, TError extends BaseError>(promiseResult: Promise<ApiResult<TData, TError> | Result<TData, TError>>): Promise<TData>;
export declare function unwrap<TData, TError extends BaseError>(result: ApiResult<TData, TError> | Result<TData, TError>): TData;
/**
* Creates a throwable version of an ActionCraft action.
* The returned function throws on error instead of returning Result objects.
*/
export declare function throwable<TAction extends CraftedAction<any, any, any, any>>(action: TAction): ThrowableAction<TAction>;