UNPKG

@msugiura/rawsql-prisma

Version:

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

130 lines (129 loc) 3.72 kB
/** * Generic Domain Model Compatibility Test Helper * * Provides utility functions for automatically testing JsonMapping compatibility * with TypeScript interfaces using only interface name and import path. */ export interface TestValidationOptions { /** * Base directory for resolving import paths (defaults to process.cwd()) */ baseDir?: string; /** * Directory containing JsonMapping files (defaults to './rawsql-ts') */ mappingDir?: string; /** * Enable debug logging */ debug?: boolean; } /** * Generic test helper for domain model compatibility validation */ export declare class DomainModelCompatibilityTester { private validator; private options; constructor(options?: TestValidationOptions); /** * Validate a single JsonMapping file against its specified interface * * @param mappingFileName - Name of the JsonMapping file (e.g., 'getTodoDetail.json') * @returns Promise<{ isValid: boolean, errors: string[], details: any }> */ validateMappingFile(mappingFileName: string): Promise<{ isValid: boolean; errors: string[]; details: null; } | { isValid: boolean; errors: string[]; details: { missingProperties: string[]; extraProperties: string[]; typeConflicts: { property: string; expected: string; actual: string; }[]; }; }>; /** * Validate all JsonMapping files in the mapping directory * * @returns Promise<{ [fileName: string]: ValidationResult }> */ validateAllMappingFiles(): Promise<{ [fileName: string]: any; }>; /** * Generate a vitest test case for a specific JsonMapping file * * Usage in test files: * ```typescript * const tester = new DomainModelCompatibilityTester({ debug: true }); * * it('should validate getTodoDetail JsonMapping compatibility', async () => { * await tester.generateTestCase('getTodoDetail.json'); * }); * ``` */ generateTestCase(mappingFileName: string): Promise<{ isValid: boolean; errors: string[]; details: null; } | { isValid: boolean; errors: string[]; details: { missingProperties: string[]; extraProperties: string[]; typeConflicts: { property: string; expected: string; actual: string; }[]; }; }>; /** * Create a comprehensive test suite for all JsonMapping files * * Usage: * ```typescript * describe('Domain Model Compatibility Tests', () => { * const tester = new DomainModelCompatibilityTester(); * tester.createTestSuite(); * }); * ``` */ createTestSuite(): void; } /** * Convenience function for quick validation in tests * * Usage: * ```typescript * import { validateJsonMappingCompatibility } from './DomainModelCompatibilityTester'; * * it('should validate getTodoDetail compatibility', async () => { * await validateJsonMappingCompatibility('getTodoDetail.json'); * }); * ``` */ export declare function validateJsonMappingCompatibility(mappingFileName: string, options?: TestValidationOptions): Promise<{ isValid: boolean; errors: string[]; details: null; } | { isValid: boolean; errors: string[]; details: { missingProperties: string[]; extraProperties: string[]; typeConflicts: { property: string; expected: string; actual: string; }[]; }; }>;