prisma-zod-generator
Version:
Prisma 2+ generator to emit Zod schemas from your Prisma schema
50 lines (49 loc) • 1.57 kB
TypeScript
/**
* PZG Pro - Drift Guard Generator
* DMMF-based implementation for schema change detection
*/
import { DMMF } from '@prisma/generator-helper';
import { ProFeatureBase } from '../../core/ProFeatureBase';
export interface DriftGuardConfig {
baseBranch?: string;
headBranch?: string;
outputFormat?: 'github' | 'json' | 'text';
strictMode?: boolean;
allowedBreaks?: string[];
}
export interface SchemaChange {
type: 'breaking' | 'non-breaking';
category: 'field' | 'enum' | 'model' | 'type' | 'validation';
model: string;
field?: string;
change: string;
description: string;
severity: 'error' | 'warning' | 'info';
}
export declare class DriftGuardGenerator extends ProFeatureBase {
private config;
constructor(context: any, config?: DriftGuardConfig);
protected getFeatureName(): string;
protected generateFeature(): Promise<void>;
/**
* Compare two DMMF documents and detect schema changes
*/
compareSchemas(baseDMMF: DMMF.Document, headDMMF: DMMF.Document): SchemaChange[];
private compareModels;
private compareModelFields;
private compareFieldProperties;
private compareEnums;
private compareEnumValues;
/**
* Format changes for output
*/
formatOutput(changes: SchemaChange[]): string;
private formatGitHubOutput;
private formatJSONOutput;
private formatTextOutput;
/**
* Validate changes and determine if they should fail CI
*/
shouldFailCI(changes: SchemaChange[]): boolean;
private buildChangeIdentifier;
}