prisma-zod-generator
Version:
Prisma 2+ generator to emit Zod schemas from your Prisma schema
165 lines (164 loc) • 5.57 kB
TypeScript
import { ValidationError } from './schema';
/**
* Base class for all configuration-related errors
*/
export declare abstract class ConfigurationError extends Error {
readonly cause?: Error | undefined;
abstract readonly errorCode: string;
abstract readonly category: ConfigurationErrorCategory;
readonly timestamp: Date;
readonly context: Record<string, unknown>;
constructor(message: string, cause?: Error | undefined, context?: Record<string, unknown>);
/**
* Convert error to structured format for logging/debugging
*/
toStructured(): StructuredError;
/**
* Get user-friendly error message with suggestions
*/
abstract getUserFriendlyMessage(): string;
}
/**
* Configuration error categories
*/
export declare enum ConfigurationErrorCategory {
FILE_SYSTEM = "FILE_SYSTEM",
PARSING = "PARSING",
VALIDATION = "VALIDATION",
BUSINESS_LOGIC = "BUSINESS_LOGIC",
INTEGRATION = "INTEGRATION"
}
/**
* Structured error format for logging
*/
export interface StructuredError {
name: string;
errorCode: string;
category: ConfigurationErrorCategory;
message: string;
timestamp: string;
context: Record<string, unknown>;
cause?: {
name: string;
message: string;
stack?: string;
};
stack?: string;
}
/**
* Configuration file not found error
*/
export declare class ConfigFileNotFoundError extends ConfigurationError {
readonly errorCode = "CONFIG_FILE_NOT_FOUND";
readonly category = ConfigurationErrorCategory.FILE_SYSTEM;
constructor(filePath: string, cause?: Error);
getUserFriendlyMessage(): string;
}
/**
* Configuration file permission error
*/
export declare class ConfigFilePermissionError extends ConfigurationError {
readonly errorCode = "CONFIG_FILE_PERMISSION_DENIED";
readonly category = ConfigurationErrorCategory.FILE_SYSTEM;
constructor(filePath: string, operation: string, cause?: Error);
getUserFriendlyMessage(): string;
}
/**
* Configuration parsing error (JSON syntax, etc.)
*/
export declare class ConfigParsingError extends ConfigurationError {
readonly errorCode = "CONFIG_PARSING_FAILED";
readonly category = ConfigurationErrorCategory.PARSING;
constructor(filePath: string, parseError: string, line?: number, column?: number, cause?: Error);
getUserFriendlyMessage(): string;
}
/**
* Configuration validation error (schema violations)
*/
export declare class ConfigValidationError extends ConfigurationError {
readonly errorCode = "CONFIG_VALIDATION_FAILED";
readonly category = ConfigurationErrorCategory.VALIDATION;
constructor(validationErrors: ValidationError[], filePath?: string);
getUserFriendlyMessage(): string;
}
/**
* Model reference error (model not found in Prisma schema)
*/
export declare class ModelReferenceError extends ConfigurationError {
readonly errorCode = "MODEL_REFERENCE_INVALID";
readonly category = ConfigurationErrorCategory.BUSINESS_LOGIC;
constructor(modelName: string, availableModels: string[], configPath?: string);
getUserFriendlyMessage(): string;
}
/**
* Integration error (Prisma schema issues, dependency problems)
*/
export declare class IntegrationError extends ConfigurationError {
readonly errorCode = "INTEGRATION_FAILED";
readonly category = ConfigurationErrorCategory.INTEGRATION;
constructor(component: string, issue: string, cause?: Error);
getUserFriendlyMessage(): string;
}
/**
* Configuration warning (non-critical issues)
*/
export declare class ConfigurationWarning {
readonly message: string;
readonly path?: string | undefined;
readonly context: Record<string, unknown>;
readonly timestamp: Date;
constructor(message: string, path?: string | undefined, context?: Record<string, unknown>);
toString(): string;
getUserFriendlyMessage(): string;
}
/**
* Error handler utility class
*/
export declare class ConfigurationErrorHandler {
private readonly context;
constructor(context?: Record<string, unknown>);
/**
* Handle file system errors
*/
handleFileSystemError(error: unknown, filePath: string, operation: string): never;
/**
* Handle parsing errors
*/
handleParsingError(error: unknown, filePath: string): never;
/**
* Handle validation errors
*/
handleValidationError(validationErrors: ValidationError[], filePath?: string): never;
/**
* Handle model reference errors
*/
handleModelReferenceError(modelName: string, availableModels: string[], configPath?: string): never;
/**
* Create warning
*/
createWarning(message: string, path?: string, context?: Record<string, unknown>): ConfigurationWarning;
/**
* Format multiple errors for display
*/
formatErrors(errors: ConfigurationError[]): string;
/**
* Format multiple warnings for display
*/
formatWarnings(warnings: ConfigurationWarning[]): string;
}
/**
* Create error handler with context
*/
export declare function createErrorHandler(context?: Record<string, unknown>): ConfigurationErrorHandler;
/**
* Check if error is a configuration error
*/
export declare function isConfigurationError(error: unknown): error is ConfigurationError;
/**
* Extract error code from configuration error
*/
export declare function getErrorCode(error: unknown): string | undefined;
/**
* Extract error category from configuration error
*/
export declare function getErrorCategory(error: unknown): ConfigurationErrorCategory | undefined;