A TypeScript library for parsing, manipulating, and generating Prisma schema files using an Abstract Syntax Tree.
prisma-ast is a library that parses Prisma schema files into an Abstract Syntax Tree (AST) for programmatic manipulation. It allows developers to read, modify, and regenerate `schema.prisma` files using JavaScript or TypeScript, preserving comments and formatting that are often lost with other tools. It solves the problem of automating schema changes or generating schemas dynamically in Prisma-based projects.
Developers working with Prisma who need to programmatically generate, modify, or analyze Prisma schema files, such as those building code generators, migration tools, or schema linters.
Developers choose prisma-ast over alternatives like the official @prisma/sdk because it preserves comments and model attributes, offers a fluent builder API for easy schema manipulation, and focuses solely on parsing and generation without imposing validation rules.
Abstract Syntax Tree for parsing schema.prisma files
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Maintains all comments and original formatting when reading and writing schema files, addressing a key limitation of the official @prisma/sdk as highlighted in the README.
Offers an intuitive, TypeScript-supported builder pattern for programmatic schema changes, demonstrated in examples like produceSchema for adding models and fields.
Enables precise searching for models, fields, or attributes using name or RegExp, useful for testing or enforcing conventions, as shown in the findByType method examples.
Can automatically sort schema blocks alphabetically or in custom order with configurable locales, via print options for organized schema management.
Completely lacks validation of schema correctness, meaning errors like invalid types or relations can be introduced without warnings, as stated in the philosophy section.
The underlying AST representation is not fully documented and more likely to change than the builder API, posing a breakage risk for advanced direct manipulation.
Enabling node tracking for location data (e.g., via configuration) can impact parsing performance, as noted in the options with 'none' as the default to avoid slowdowns.