Skip to main content
Glama

Prisma MCP Server

Official
by prisma
Apache 2.0
4
44,192
  • Linux
  • Apple
Enum.ts1.07 kB
import { objectEnumNames, strictEnumNames } from '@prisma/client-common' import type * as DMMF from '@prisma/dmmf' import indent from 'indent-string' import { TAB_SIZE } from './constants' export class Enum { constructor( protected readonly type: DMMF.SchemaEnum, protected readonly useNamespace: boolean, ) {} private isObjectEnum(): boolean { return this.useNamespace && objectEnumNames.includes(this.type.name) } private isStrictEnum(): boolean { return this.useNamespace && strictEnumNames.includes(this.type.name) } public toTS(): string { const { type } = this const enumVariants = `{ ${indent(type.values.map((v) => `${v}: ${this.getValue(v)}`).join(',\n'), TAB_SIZE)} } as const` const enumBody = this.isStrictEnum() ? `runtime.makeStrictEnum(${enumVariants})` : enumVariants return `export const ${type.name} = ${enumBody} export type ${type.name} = (typeof ${type.name})[keyof typeof ${type.name}]\n` } private getValue(value: string): string { return this.isObjectEnum() ? value : `'${value}'` } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/prisma/prisma'

If you have feedback or need assistance with the MCP directory API, please join our Discord server