import type { DMMF as ExternalDMMF } from '@prisma/generator-helper' ; import pluralize from 'pluralize' ; import type { DMMF } from './dmmf-types' ; import { capitalize , lowerCase } from './utils/common' ; export function getCountAggregateOutputName ( modelName ) { return `${ capitalize ( modelName ) }CountAggregateOutputType` ; } param document export function externalToInternalDmmf ( document ) { return { ... document , mappings : getMappings ( document . mappings , document . datamodel ) , } ; } function getMappings ( mappings , datamodel ) { const modelOperations = mappings . modelOperations . filter ( ( mapping ) => { const model = datamodel . models . find ( ( m ) => m . name === mapping . model ) ; if ( ! model ) { throw new Error ( `Mapping without model ${ mapping . model }` ) ; } return model . fields . some ( ( f ) => f . kind !== 'object' ) ; } ) . map ( ( mapping ) => ( { model : mapping . model , plural : pluralize ( lowerCase ( mapping . model ) ) , findUnique : mapping . findUnique || mapping . findSingle , findFirst : mapping . findFirst , findMany : mapping . findMany , create : mapping . createOne || mapping . createSingle || mapping . create , createMany : mapping . createMany , delete : mapping . deleteOne || mapping . deleteSingle || mapping . delete , update : mapping . updateOne || mapping . updateSingle || mapping . update , deleteMany : mapping . deleteMany , updateMany : mapping . updateMany , upsert : mapping . upsertOne || mapping . upsertSingle || mapping . upsert , aggregate : mapping . aggregate , groupBy : mapping . groupBy , } ) ) ; return { modelOperations , otherOperations : mappings . otherOperations , } ; }