UNPKG

@kellanjs/actioncraft

Version:

Fluent, type-safe builder for Next.js server actions.

30 lines (29 loc) 1.76 kB
import type { StandardSchemaV1 } from "../../standard-schema.js"; import { EXTERNAL_ERROR_TYPES, INTERNAL_ERROR_TYPES } from "../../types/errors.js"; import type { UnhandledError, ImplicitReturnError, InternalLogicError, ValidationErrorFormat, NoInputSchemaError } from "../../types/errors.js"; import type { Result } from "../../types/result.js"; export declare const UNHANDLED_ERROR: UnhandledError; export declare const IMPLICIT_RETURN_ERROR: ImplicitReturnError; export declare const NO_INPUT_SCHEMA_ERROR: NoInputSchemaError; /** * 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>(actionId: string, actionName?: string): Result<TData, TError>; /** * Creates Result objects for implicit return errors. */ export declare function createImplicitReturnErrorResult<TData = never, TError = ImplicitReturnError>(actionId: string, actionName?: string): 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, actionName?: string): TError; export {};