single-source-of-truth
Version:
Use Zod schemas to your generate Prisma schema
30 lines • 1.72 kB
TypeScript
import type * as z from 'zod/v4';
import { id, unique } from '../symbols.js';
import { TruthRelationUtil } from './relation.js';
export type ZodShape = z.core.$ZodLooseShape;
export interface AttributesShape {
[id]?: string[];
[unique]?: string[][];
}
export type TruthShape = AttributesShape & ZodShape;
export declare namespace TruthShapeUtil {
type IsAttributesKey<Key extends string> = Key extends keyof AttributesShape ? true : false;
function isAttributesKey<Key extends string>(key: Key): key is keyof AttributesShape & Key;
type ExtractAttributesShape<Shape extends TruthShape> = {
[Key in keyof Shape as Key extends keyof AttributesShape ? Key : never]: Shape[Key];
};
function extractAttributesShape<Shape extends TruthShape>(shape: Shape): ExtractAttributesShape<Shape>;
type NormaliseAttributesShape<Shape extends AttributesShape> = {
[Key in keyof Shape as Key extends ` ${infer K}` ? K : Key]: Shape[Key];
};
function normaliseAttributesShape<Shape extends AttributesShape>(shape: Shape): NormaliseAttributesShape<Shape>;
type ExtractRelationsShape<Shape extends TruthShape> = {
[Key in keyof Shape as Shape[Key] extends TruthRelationUtil.AnyRelationAny ? Key : never]: Shape[Key];
};
function extractRelationsShape<Shape extends TruthShape>(shape: Shape): ExtractRelationsShape<Shape>;
type ExtractZodShape<Shape extends TruthShape> = Omit<{
[K in keyof Shape as Shape[K] extends z.ZodType ? K : never]: Shape[K];
}, keyof AttributesShape | keyof ExtractRelationsShape<Shape>>;
function extractZodShape<Shape extends TruthShape>(shape: Shape): ExtractZodShape<Shape>;
}
//# sourceMappingURL=shape.d.ts.map