UNPKG

@msugiura/rawsql-prisma

Version:

Prisma integration for rawsql-ts - Dynamic SQL generation with type safety and hierarchical JSON serialization

64 lines (63 loc) 2.01 kB
/** * Automatic Type Compatibility Validator * * Uses TypeScript compiler API to automatically validate JsonMapping compatibility * with target TypeScript interfaces. Only requires interface name and import path! */ import * as ts from 'typescript'; import { EnhancedJsonMapping, TypeValidationResult } from './EnhancedJsonMapping'; export interface AutoTypeValidationOptions { /** * Base directory for resolving relative import paths */ baseDir?: string; /** * TypeScript compiler options */ compilerOptions?: ts.CompilerOptions; /** * Enable debug logging */ debug?: boolean; } /** * Automatic type compatibility validator that reads TypeScript interfaces * and validates JsonMapping structure compatibility */ export declare class AutoTypeCompatibilityValidator { private options; constructor(options?: AutoTypeValidationOptions); /** * Validate JsonMapping compatibility with TypeScript interface * * @param jsonMapping - Enhanced JsonMapping with typeInfo * @returns Validation result with detailed compatibility information */ validateMapping(jsonMapping: EnhancedJsonMapping): Promise<TypeValidationResult>; /** * Resolve interface file path relative to base directory */ private resolveInterfacePath; /** * Parse TypeScript interface and extract structure */ private parseInterface; /** * Extract structure from TypeScript interface declaration */ private extractInterfaceStructure; /** * Extract type information from TypeScript type node */ private extractTypeInfo; /** * Generate expected structure from JsonMapping */ private generateStructureFromMapping; /** * Infer TypeScript type from SQL column name (basic heuristics) */ private inferTypeFromColumnName; /** * Compare interface structure with mapping structure (structure-only validation) */ private compareStructures; }