@kellanjs/actioncraft
Version:
Fluent, type-safe builder for Next.js server actions.
29 lines (28 loc) • 1.57 kB
TypeScript
import type { StandardSchemaV1 } from "../standard-schema.js";
import { EXTERNAL_ERROR_TYPES, INTERNAL_ERROR_TYPES } from "../types/errors.js";
import type { UnhandledError, ImplicitReturnError, InternalLogicError, ValidationErrorFormat } from "../types/errors.js";
import type { Result } from "../types/result.js";
export declare const UNHANDLED_ERROR: UnhandledError;
export declare const IMPLICIT_RETURN_ERROR: ImplicitReturnError;
/**
* Creates internal logic errors with custom messages.
*/
export declare const createInternalLogicError: (message: string) => InternalLogicError;
/**
* Creates Result objects for unhandled errors.
*/
export declare function createUnhandledErrorResult<TData = never, TError = UnhandledError>(): Result<TData, TError>;
/**
* Creates Result objects for implicit return errors.
*/
export declare function createImplicitReturnErrorResult<TData = never, TError = ImplicitReturnError>(): Result<TData, TError>;
/**
* Formats validation issues into structured error objects based on the configured format.
*/
export declare function formatValidationIssues(issues: readonly StandardSchemaV1.Issue[], format: "flattened" | "nested"): ValidationErrorFormat;
type ValidationErrorType = typeof EXTERNAL_ERROR_TYPES.INPUT_VALIDATION | typeof EXTERNAL_ERROR_TYPES.BIND_ARGS_VALIDATION | typeof INTERNAL_ERROR_TYPES.OUTPUT_VALIDATION;
/**
* Creates validation error objects.
*/
export declare function createValidationError<TError>(type: ValidationErrorType, message: string, errorStructure: ValidationErrorFormat): TError;
export {};