UNPKG

single-source-of-truth

Version:
28 lines 1.76 kB
import * as z from 'zod/v4'; import type { Standard } from "../../../standard.js"; import { TruthRelationUtil } from './relation.js'; import { type TruthShape, TruthShapeUtil } from './shape.js'; export interface TruthModelDef<Shape extends TruthShape = TruthShape> extends z.core.$ZodObjectDef<TruthShapeUtil.ExtractZodShape<Shape>> { name: string | null; attributes: TruthShapeUtil.NormaliseAttributesShape<TruthShapeUtil.ExtractAttributesShape<Shape>>; relations: TruthShapeUtil.ExtractRelationsShape<Shape>; includes: string[]; } export interface TruthModelInternals<Shape extends TruthShape> extends z.core.$ZodObjectInternals<TruthShapeUtil.ExtractZodShape<Shape>, { in: Record<never, never>; out: Record<never, never>; }> { def: TruthModelDef<Shape>; } export interface TruthModel<Shape extends TruthShape = TruthShape> extends z.ZodObject<TruthShapeUtil.ExtractZodShape<Shape>, { in: Record<never, never>; out: Record<never, never>; }> { _zod: TruthModelInternals<Shape>; def: TruthModelDef<Shape>; with<Include extends keyof TruthShapeUtil.ExtractRelationsShape<Shape>, Relation extends TruthRelationUtil.AnyRelationAny = TruthShapeUtil.ExtractRelationsShape<Shape>[Include], Model extends z.ZodType = TruthRelationUtil.ExtractModelFromRelation<Relation>, Schema extends z.ZodType = Model>(include: Extract<Include, string>, override?: (model: Model) => Schema): TruthModel<Omit<Shape, Include> & Record<Include, TruthRelationUtil.ApplyRelationWrapping<Relation, Schema>>>; toStandard(): Standard.Model; } export declare const TruthModel: z.core.$constructor<TruthModel>; export declare function model<Shape extends TruthShape>(shape: Shape): TruthModel<Shape>; //# sourceMappingURL=model.d.ts.map