/** * Validate Prisma Converters Executor * * Validates that Prisma converter methods follow a scalable pattern: * methods returning XxxDto (where XxxDbo exists in schema.prisma) must * accept that exact XxxDbo as the first parameter. This keeps single-table * converters clean and forces join converters to compose them. * * ============================================================================ * RULES * ============================================================================ * * 1. First param must be exact Dbo: * If method returns XxxDto and XxxDbo exists in schema.prisma, * the first parameter must be of type XxxDbo. * * 2. Extra params must be booleans: * Additional parameters beyond the Dbo are allowed but must be boolean * (used for filtering payloads / security info). * * 3. No async converters: * Methods returning Promise are flagged — converters should be * pure data mapping, no async work. * * 4. No standalone functions: * Standalone functions in converter files are flagged — must be class * methods so the converter class can be injected (dependency tree tracing). * * 5. Dto creation outside converters directory: * Files outside the configured convertersPath that create `new XxxDto(...)` * where XxxDbo exists in schema.prisma are flagged — Dto instances tied to * a Dbo must only be created via a converter class. * * ============================================================================ * SKIP CONDITIONS * ============================================================================ * - Methods with @deprecated decorator or JSDoc tag * - Lines with: // webpieces-disable prisma-converter -- [reason] * * ============================================================================ * MODES * ============================================================================ * - OFF: Skip validation entirely * - NEW_AND_MODIFIED_METHODS: Validate new/modified methods in converters + changed lines in non-converters * - MODIFIED_FILES: Validate all methods in modified files */ import type { ExecutorContext } from '@nx/devkit'; export type PrismaConverterMode = 'OFF' | 'NEW_AND_MODIFIED_METHODS' | 'MODIFIED_FILES'; export interface ValidatePrismaConvertersOptions { mode?: PrismaConverterMode; disableAllowed?: boolean; schemaPath?: string; convertersPaths?: string[]; enforcePaths?: string[]; ignoreModifiedUntilEpoch?: number; } export interface ExecutorResult { success: boolean; } export default function runExecutor(options: ValidatePrismaConvertersOptions, context: ExecutorContext): Promise;