import type { z, AnyZodObject, ZodArray, ZodObject, ZodEffects, ZodUnion, ZodUnionOptions } from 'zod'; import type { Entity, UnwrappedEntity } from './server/entity.js'; import type { Writable } from 'svelte/store'; export type MaybePromise = T | Promise; export declare class SuperFormError extends Error { constructor(message?: string); } export type UnwrapEffects = T extends ZodEffects ? UnwrapEffects : T extends AnyZodObject ? T : never; export type DrainOuterGeneric = [T] extends [unknown] ? T : never; export type ZodValidation = DrainOuterGeneric | ZodEffects> | ZodEffects>> | ZodEffects>>> | ZodEffects>>>>>; export { type FormPath, type FormPathLeaves } from './stringPath.js'; export type RawShape = T extends ZodObject ? U : never; type UnwrappedRawShape> = UnwrappedEntity[P]>; type IntersectArray = T extends [ infer U, ...infer Rest ] ? Rest extends [] ? U : U & IntersectArray : never; type IntersectUnion> = T extends ZodUnion ? IntersectArray : never; type SuperStructArray = { [Property in keyof RawShape]?: T extends any ? UnwrappedEntity extends ZodUnion ? SuperStructArray>, Data, ArrayData> : UnwrappedRawShape extends AnyZodObject ? SuperStructArray, Data, ArrayData> : UnwrappedRawShape extends ZodArray ? ArrayData & Record extends AnyZodObject ? SuperStructArray, Data, ArrayData> : UnwrappedEntity extends ZodUnion ? SuperStructArray>, Data, ArrayData> : Data> : Data : never; }; type SuperStruct = Partial<{ [Property in keyof RawShape]: T extends any ? UnwrappedEntity extends ZodUnion ? SuperStruct>, Data> : UnwrappedRawShape extends AnyZodObject ? SuperStruct, Data> : UnwrappedRawShape extends ZodArray ? UnwrappedEntity extends ZodUnion ? SuperStruct>, Data> : UnwrappedEntity extends AnyZodObject ? SuperStruct, Data> : InputConstraint : InputConstraint : never; }>; export type Validator = (value: V) => MaybePromise; export type Validators = Partial<{ [Property in keyof RawShape]: T extends any ? UnwrappedRawShape extends AnyZodObject ? Validators> : UnwrappedRawShape extends ZodArray ? UnwrappedEntity extends AnyZodObject ? Validators> : Validator[Property] extends Array ? A2 : z.infer[Property]> : Validator[Property]> : never; }>; export type TaintedFields = SuperStructArray; export type ValidationErrors = { _errors?: string[]; } & SuperStructArray; export type InputConstraint = Partial<{ pattern: string; min: number | string; max: number | string; required: boolean; step: number | 'any'; minlength: number; maxlength: number; }>; export type InputConstraints = SuperStruct; export type SuperValidated>, M = any> = DrainOuterGeneric<{ valid: boolean; posted: boolean; errors: ValidationErrors>; data: z.infer>; constraints: Entity>['constraints']; message?: M; id?: string; }>; /** * @deprecated Use SuperValidated instead. */ export type Validation, M = any> = SuperValidated; export type FormField> = { readonly name: string; value: Writable[Property]>; errors?: Writable[Property]>; constraints?: Writable[Property]>; }; export type FormFields = { [Property in keyof z.infer]-?: FormField; }; export type FieldPath = [keyof T, ...(string | number)[]];