type OneOrMany = T | readonly T[]; type KeysAssignableTo = { [P in keyof C & string]: C[P] extends V ? P : never; }[keyof C & string]; declare class FieldBuilder { private readonly state; constructor(field: Field, Value, Flag>); from>(keyOrList: OneOrMany): FieldBuilder; from(keyOrList: OneOrMany, getValueFromContext: (ctx: Pick) => Value): FieldBuilder; maybeFrom>(keyOrList: OneOrMany): FieldBuilder; maybeFrom(keyOrList: OneOrMany, getValueFromContext: (ctx: Pick) => Value | undefined): FieldBuilder; optional(): FieldBuilder; default(defaultValue: Value | (() => Value)): FieldBuilder; } type NewFieldBuilder = { type: () => FieldBuilder; }; type Prettify = { [K in keyof T]: T[K]; } & {}; type RequiredFlag = 'required' | 'optional' | 'default' | 'from' | 'maybeFrom'; type Field = { fixtureList: (keyof Fixtures & string)[]; getValueFromContext: undefined | ((ctx: Fixtures) => Value | undefined); isRequired: Flag extends 'required' ? true : Flag extends 'default' ? true : Flag extends 'from' ? true : Flag extends 'maybeFrom' ? true : Flag extends 'optional' ? false : true; defaultValue: undefined | Value | (() => Value); }; type AsField> = F extends FieldBuilder ? Field>, Value, Flag> : never; type AnySchemaBuilder = Record>; type SchemaOf = { [K in keyof SchemaBuilder]: AsField; }; type AnySchemaBuilderWithContext = Record>; type AnyFieldWithContext = Field; type AnySchema = Record>; type EmptySchema = Record; type MissingField = { key: string; fixtureList: string[]; }; type DestroyFn = () => Promise | void; type VitestFixtureFn = (context: object & Context, use: (value: FixtureValue) => Promise) => Promise; type FactoryResult = { value: Value; destroy?: DestroyFn; }; type FactoryFn = (attrs: Attrs) => Promise> | FactoryResult; type FixtureFn = (attrs: Attrs, use: (value: Value) => Promise) => Promise; type FactoryOptions = { shouldDestroy?: boolean; }; type ValueOf = S[K] extends Field ? Value : never; type FixturesOf = S[K] extends Field ? Fixtures : never; type FlagOf = S[K] extends Field ? Flag : never; type OptionalInputKeysOf = { [K in keyof S]: FlagOf extends 'optional' | 'default' | 'from' | 'maybeFrom' ? K : never; }[keyof S]; type RequiredInputKeysOf = S extends EmptySchema ? never : Exclude>; type InputOf = S extends EmptySchema ? EmptySchema : Prettify<{ [K in RequiredInputKeysOf]: ValueOf; } & { [K in OptionalInputKeysOf]?: ValueOf; }>; type OutputOf = S extends EmptySchema ? EmptySchema : { [K in keyof S]: ValueOf; }; type VoidableInputOf = RequiredInputKeysOf extends never ? InputOf | void : InputOf; type RequiredKeys = { [K in keyof T]-?: {} extends Pick ? never : K; }[keyof T]; type MaybeVoid = RequiredKeys extends never ? T | void : T; type InferFixtureValue = T extends () => VitestFixtureFn ? Value : never; type SetSchemaFieldsOptional = { [K in keyof Schema]: K extends Keys ? Field, ValueOf, 'optional'> : Schema[K]; }; type FactoryState = { name: string; schema: S; fixtureFn: FixtureFn>, V> | undefined; }; type CreateFn = (attrs: VoidableInputOf) => Promise; declare class FactoryBuilder { private readonly state; constructor(state: FactoryState); withContext(): FactoryBuilder; withSchema>(schemaFn: (f: NewFieldBuilder) => SchemaBuilder): FactoryBuilder, Value>; withValue(factoryFn: FactoryFn>, NextValue>): FactoryBuilder; fixture(fixtureFn: FixtureFn>, Value>): FactoryBuilder; build(attrs: VoidableInputOf, context: MaybeVoid): Promise<{ readonly value: Awaited; [Symbol.asyncDispose]: () => Promise; }>; useCreateValue>>(presetAttrs?: PresetAttrs, { shouldDestroy }?: FactoryOptions): VitestFixtureFn, Value>>; useValue(attrs: VoidableInputOf, options?: FactoryOptions): VitestFixtureFn; } declare const createFactory: (name: string) => FactoryBuilder; declare class UndefinedFieldError extends Error { constructor(name: string, missingFields: MissingField[]); } export { type InferFixtureValue, UndefinedFieldError, createFactory };