import { PrismaSchema } from "../types"; /** * A parser for Prisma schema files that extracts models, enums, and their properties. * * @example * ```typescript * const schemaContent = ` * model User { * id Int @id @default(autoincrement()) * email String @unique * } * `; * const parser = new PrismaSchemaParser(schemaContent); * const schema = parser.parse(); * ``` */ export declare class PrismaSchemaParser { /** The raw Prisma schema content */ private schema; /** Collection of parsed enum definitions */ private enums; /** Collection of parsed model definitions */ private models; /** * Creates a new Prisma schema parser instance. * * @param schemaContent - The raw Prisma schema file content as a string */ constructor(schemaContent: string); /** * Parses the Prisma schema and extracts all models and enums. * * @returns The parsed schema containing arrays of models and enums */ parse(): PrismaSchema; /** * Extracts all enum definitions from the schema. * * @private * @returns Array of parsed enum objects */ private extractEnums; /** * Parses a single enum block and extracts its name and values. * * @private * @param block - The enum block string (e.g., "enum Status { ACTIVE INACTIVE }") * @returns The parsed enum object or null if parsing fails */ private parseEnumBlock; /** * Extracts all model definitions from the schema. * * @private * @returns Array of parsed model objects */ private extractModels; /** * Extracts raw model block strings from the schema using regex. * * @private * @returns Array of model block strings */ private extractModelBlocks; /** * Parses a single model block and extracts its name, fields, and metadata. * * @private * @param block - The model block string * @returns The parsed model object or null if parsing fails */ private parseModelBlock; /** * Parses all field definitions within a model block. * * @private * @param block - The model block string containing field definitions * @returns Array of parsed field objects */ private parseFields; /** * Parses a single field line and extracts all field properties. * * @private * @param line - A single field definition line (e.g., "id Int @id @default(autoincrement())") * @returns The parsed field object or null if parsing fails * * @example * ```typescript * // Input: "email String? @unique @default("user@example.com")" * // Output: { * // name: "email", * // type: "String", * // isOptional: true, * // isArray: false, * // defaultValue: "user@example.com", * // isId: false, * // isUnique: true, * // attributes: ["@unique", "@default(\"user@example.com\")"] * // } * ``` */ private parseFieldLine; /** * Parses a default value string and converts it to the appropriate JavaScript type. * * @private * @param defaultStr - The default value string from @default() attribute * @returns The parsed default value in appropriate JavaScript type, or undefined for functions * * @example * ```typescript * parseDefaultValue('"hello"') // returns "hello" * parseDefaultValue('true') // returns true * parseDefaultValue('42') // returns 42 * parseDefaultValue('3.14') // returns 3.14 * parseDefaultValue('ACTIVE') // returns "ACTIVE" (enum value) * parseDefaultValue('now()') // returns undefined (function) * ``` */ private parseDefaultValue; /** * Checks if a given type name corresponds to a defined enum. * * @param typeName - The type name to check * @returns True if the type is an enum, false otherwise * * @example * ```typescript * const parser = new PrismaSchemaParser(schemaWithStatusEnum); * parser.parse(); * parser.isEnum('Status'); // true * parser.isEnum('String'); // false * ``` */ isEnum(typeName: string): boolean; /** * Checks if a given type name corresponds to a defined model. * * @param typeName - The type name to check * @returns True if the type is a model, false otherwise * * @example * ```typescript * const parser = new PrismaSchemaParser(schemaWithUserModel); * parser.parse(); * parser.isModel('User'); // true * parser.isModel('String'); // false * ``` */ isModel(typeName: string): boolean; } //# sourceMappingURL=prisma.parser.d.ts.map