UNPKG

@thaumaturgy/zod

Version:

Thaumaturgy is a fixtures and seeding library for TypeScript.

35 lines (34 loc) 1.38 kB
import { DefineOptions, Sequences } from '@thaumaturgy/core'; import { z } from 'zod'; /** * A realm is an isolated environment that entities may be registered with. * * Entity names must be unique within a realm. */ export declare class Realm<TContext> { private readonly realm; /** * Defines an entity in the realm using the specified manifester and persister. */ readonly define: <C extends z.ZodTypeAny, TSequences extends Sequences>(Entity: C, options: DefineOptions<z.TypeOf<C>, TSequences, TContext>) => void; /** * Clears all of the entities within the realm. */ clear(): void; /** * Manifests an instance of the specified entity. * * @param Entity The entity to manifest. * @param overrides The overrides to pass to the manifester. */ readonly manifest: <C extends z.ZodTypeAny>(Entity: C, overrides?: Partial<z.TypeOf<C>>) => z.TypeOf<C>; /** * Persists an instance of the specified entity. * * @param Entity The entity to persist. * @param context The context to pass to the persister. * @param overrides The overrides to pass to the persister. */ readonly persist: <C extends z.ZodTypeAny>(Entity: C, context: TContext, overrides?: Partial<z.TypeOf<C>>) => Promise<z.TypeOf<C>>; readonly persistLeaves: (context: TContext) => Promise<unknown[]>; }