@kellanjs/actioncraft
Version:
Fluent, type-safe builder for Next.js server actions.
18 lines (17 loc) • 1.15 kB
TypeScript
import type { InferSerializedErrorValues } from "../../types/actions.js";
import type { Schemas } from "../../types/builder.js";
import type { Config, Errors } from "../../types/builder.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 Schemas>(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 Errors, TConfig extends Config, TSchemas extends Schemas>(internalError: AllPossibleErrors<TErrors, TConfig, TSchemas>): PossibleErrors<TErrors, TConfig, TSchemas>;