prisma-zod-generator
Version:
Prisma 2+ generator to emit Zod schemas from your Prisma schema
79 lines (78 loc) • 2.63 kB
TypeScript
import type { GeneratorConfig } from '../config/parser';
/**
* Context information for strict mode resolution
*/
export interface StrictModeContext {
/** The model name (if applicable) */
modelName?: string;
/** The operation name (if applicable) */
operation?: string;
/** The schema type: 'operation', 'object', 'variant' */
schemaType: 'operation' | 'object' | 'variant';
/** The variant type (if applicable) */
variant?: 'pure' | 'input' | 'result';
}
/**
* Utility class for resolving strict mode settings based on configuration hierarchy
*/
export declare class StrictModeResolver {
private config;
constructor(config: GeneratorConfig);
/**
* Normalize operation names for backward compatibility
* Maps both short names (create, update) and full names (createOne, updateOne)
*/
private normalizeOperationName;
/**
* Resolve whether strict mode should be applied for a given context
*/
shouldApplyStrictMode(context: StrictModeContext): boolean;
/**
* Resolve strict mode from the complete hierarchy
*/
private resolveFromHierarchy;
/**
* Get global setting for a specific schema type
*/
private getGlobalSchemaTypeSetting;
/**
* Resolve model-specific strict mode settings
*/
private resolveModelSpecific;
/**
* Resolve variant-specific strict mode settings
*/
private resolveVariantSpecific;
/**
* Convenience method for operation schemas
*/
shouldApplyStrictModeToOperation(modelName: string, operation: string): boolean;
/**
* Convenience method for object schemas
*/
shouldApplyStrictModeToObject(modelName?: string): boolean;
/**
* Convenience method for variant schemas
*/
shouldApplyStrictModeToVariant(modelName: string, variant: 'pure' | 'input' | 'result'): boolean;
/**
* Get the strict mode suffix to append to schema definitions
*/
getStrictModeSuffix(context: StrictModeContext): string;
/**
* Get the strict mode suffix for operation schemas
*/
getOperationStrictModeSuffix(modelName: string, operation: string): string;
/**
* Get the strict mode suffix for object schemas
*/
getObjectStrictModeSuffix(modelName?: string): string;
/**
* Get the strict mode suffix for variant schemas
*/
getVariantStrictModeSuffix(modelName: string, variant: 'pure' | 'input' | 'result'): string;
}
/**
* Create a strict mode resolver instance
*/
export declare function createStrictModeResolver(config: GeneratorConfig): StrictModeResolver;