/** * Validate DTOs Executor * * Validates that every non-deprecated field in a XxxDto class/interface exists * in the corresponding XxxDbo Prisma model. This catches AI agents inventing * field names that don't match the database schema. * * ============================================================================ * MODES * ============================================================================ * - OFF: Skip validation entirely * - MODIFIED_CLASS: Only validate Dto classes that have changed lines in the diff * - MODIFIED_FILES: Validate ALL Dto classes in files that were modified * * ============================================================================ * SKIP CONDITIONS * ============================================================================ * - If schema.prisma itself is modified, validation is skipped (schema in flux) * - Dto classes ending with "JoinDto" are skipped (they compose other Dtos) * - Fields marked @deprecated in a comment are exempt * * ============================================================================ * MATCHING * ============================================================================ * - UserDto matches UserDbo by case-insensitive prefix ("user") * - Dbo field names are converted from snake_case to camelCase for comparison * - Dto fields must be a subset of Dbo fields * - Extra Dbo fields are allowed (e.g., password) */ import type { ExecutorContext } from '@nx/devkit'; export type ValidateDtosMode = 'OFF' | 'MODIFIED_CLASS' | 'MODIFIED_FILES'; export interface ValidateDtosOptions { mode?: ValidateDtosMode; disableAllowed?: boolean; prismaSchemaPath?: string; dtoSourcePaths?: string[]; ignoreModifiedUntilEpoch?: number; } export interface ExecutorResult { success: boolean; } export default function runExecutor(options: ValidateDtosOptions, context: ExecutorContext): Promise;