UNPKG

@kellanjs/actioncraft

Version:

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

18 lines (17 loc) 1.19 kB
import type { InferSerializedErrorValues } from "../types/actions.js"; import type { CrafterSchemas } from "../types/config.js"; import type { CrafterConfig, CrafterErrors } from "../types/config.js"; import type { PossibleErrors, AllPossibleErrors } from "../types/errors.js"; import type { InferRawInput, InferValidatedInput } from "../types/schemas.js"; /** * Converts input to a serializable format for the `values` field in action results. * * If the input is `FormData`, it is flattened into a plain object so that it can * be safely JSON-serialized. Otherwise, the input is returned as-is. */ export declare function serializeRawInput<TSchemas extends CrafterSchemas>(input: InferRawInput<TSchemas> | InferValidatedInput<TSchemas> | undefined): InferSerializedErrorValues<TSchemas>; /** * Converts internal error objects into client-facing errors, hiding * implementation details that should not leak outside the server. */ export declare function convertToClientError<TErrors extends CrafterErrors, TConfig extends CrafterConfig, TSchemas extends CrafterSchemas>(internalError: AllPossibleErrors<TErrors, TConfig, TSchemas>): PossibleErrors<TErrors, TConfig, TSchemas>;