import indent from 'indent-string' ; import type { Generatable } from './Generatable' ; import type { DMMF } from '../../runtime/dmmf-types' ; import type { ExportCollector } from './helpers' ; import { TAB_SIZE } from './constants' ; export class Enum implements Generatable { constructor ( protected readonly type , protected readonly useNamespace , protected readonly collector ? ) { if ( useNamespace ) { this . collector ?. addSymbol ( type . name ) ; } } public toJS ( ) { const { type } = this ; return `exports.${ this . useNamespace ? 'Prisma.' : '' }${ type . name } = makeEnum({
${ indent ( type . values . map ( ( v ) => `${ v }: '${ v }'` ) . join ( ',\n' ) , TAB_SIZE ) }
});` ; } public toTS ( ) { const { type } = this ; return `export const ${ type . name }: {
${ indent ( type . values . map ( ( v ) => `${ v }: '${ v }'` ) . join ( ',\n' ) , TAB_SIZE ) }
};

export type ${ type . name } = (typeof ${ type . name })[keyof typeof ${ type . name }]\n` ; } }