UNPKG

prisma-zod-generator

Version:

Prisma 2+ generator to emit Zod schemas from your Prisma schema

43 lines (42 loc) 1.57 kB
import type { DMMF as PrismaDMMF } from '@prisma/generator-helper'; /** * Result of circular dependency detection */ export interface CircularDependencyResult { /** Map of model name -> set of relation field names that should be excluded to break cycles */ excludedRelations: Map<string, Set<string>>; /** List of detected cycles for debugging */ cycles: string[][]; } /** * Detects circular dependencies in Prisma model relationships and determines * which relations should be excluded to break the cycles. */ export declare class CircularDependencyDetector { private models; private relationGraph; constructor(models: PrismaDMMF.Model[]); /** * Build a graph of all model relationships */ private buildRelationGraph; /** * Detect problematic circular dependencies (not just any cycle). * Only considers cycles that would cause TypeScript compilation issues. */ private detectProblematicCycles; /** * Determine which relations to exclude to break cycles. * Strategy: For bidirectional relationships, prefer to exclude optional relations * over required ones, and exclude "back-references" over "forward-references". */ private determineExclusions; /** * Detect circular dependencies and return which relations should be excluded */ detect(): CircularDependencyResult; } /** * Utility function to detect circular dependencies in Prisma models */ export declare function detectCircularDependencies(models: PrismaDMMF.Model[]): CircularDependencyResult;