/// import { FormikErrors, FormikProps, FormikTouched } from 'formik'; import { GetServerSidePropsContext } from 'next'; import qs from 'querystring'; import { ReactNode } from 'react'; import * as Stream from 'stream'; import * as z from 'zod'; import { ZodRawShape } from 'zod/lib/src/types/base'; export interface MockIncomingMessage extends Stream.Readable { method: string; url: string; } export interface MockGetServerSidePropsContext { req: MockIncomingMessage; resolvedUrl: string; } declare type Primitive = string | number | boolean; declare type DefaultValues = { [P in keyof T]: T[P] extends Primitive ? DefaultValues | T[P] | '' : DefaultValues; }; declare type FieldError = { path: (string | number)[]; message: string; }; declare type PostResponseError = { type: 'ValidationError'; message: string; stack?: string | undefined; fieldErrors: FieldError[]; } | { type: 'MutationError'; message: string; stack?: string | undefined; fieldErrors?: null; }; declare type PostResponse = { success: true; input: TValues; data: TMutationData; error?: null; } | { success: false; input: TValues; data?: null; error: PostResponseError; }; declare type PagePropsValue = { endpoints: { /** * endpoint for using in `fetch()` */ fetch: string; /** * endpoint for using in `
| null; }; export declare function createForm, TSchemaShape extends ZodRawShape, TFormId extends string>({ schema, defaultValues, formId, }: { schema: TSchema; defaultValues: DefaultValues>; /** * A unique identifier for the form on the page, will used to identifiy it in the post receiver */ formId: TFormId; }): { formId: TFormId; schema: TSchema; getPageProps: >({ ctx, mutation, }: { ctx: TContext; mutation: (data: z.TypeOf) => Promise; }) => Promise>>>; clientRequest: >>, TMutationData_1>({ values, props }: { props: TProps; values: z.TypeOf; }) => Promise<{ newProps: TProps; }>; getInitialValues: >>, TMutationData_2>(props: TProps_1) => z.TypeOf; getInitialErrors: >>, TMutationData_3>(props: TProps_2) => FormikErrors> | undefined; getInitialTouched: >>, TMutationData_4>(props: TProps_3) => FormikTouched> | undefined; getFeedbackFromProps: >>, TMutationData_5>(props: TProps_4) => { state: "success"; error?: undefined; } | { state: "error"; error: Error | { type: "ValidationError"; message: string; stack?: string | undefined; fieldErrors: FieldError[]; } | { type: "MutationError"; message: string; stack?: string | undefined; fieldErrors?: null | undefined; }; } | null; formikValidator: (values: z.TypeOf) => FormikErrors>; _unstable_useFormikScaffold: >>, TMutationData_6>(props: TProps_5) => { Form: (formProps: { children: (formikProps: FormikProps>) => ReactNode; onSuccess?: (({ newProps }: { newProps: TProps_5; }) => void) | undefined; }) => JSX.Element; feedback: { state: "success"; error?: undefined; } | { state: "error"; error: Error | { type: "ValidationError"; message: string; stack?: string | undefined; fieldErrors: FieldError[]; } | { type: "MutationError"; message: string; stack?: string | undefined; fieldErrors?: null | undefined; }; } | null; }; }; export {};