Prisma Ast

screenshot of Prisma Ast
prisma

Abstract Syntax Tree for parsing schema.prisma files

Overview:

The @mrleebo/prisma-ast library provides a powerful tool for working with Prisma schema files in JavaScript. By utilizing an abstract syntax tree, it enables users to parse .prisma files into easily manageable JavaScript objects. This library stands out from others, such as @prisma/sdk, by preserving comments and model attributes, making it an ideal choice for developers who require a clear and complete representation of their schema information. Unlike other parsers, it focuses purely on parsing and manipulating schema files rather than validating them, which can be especially useful when modifying large or complex schemas.

The flexibility offered by the @mrleebo/prisma-ast library, in combination with its TypeScript implementation, makes it an appealing option for developers looking to programmatically interact with their Prisma schemas. With features designed for both simplicity and advanced use, it greatly enhances the user's ability to customize and manage their data models.

Features:

  • Schema Parsing: Easily parse .prisma files into JavaScript objects without losing comments and model attributes, allowing for seamless manipulation.
  • Builder Object Pattern: Utilize a fully implemented TypeScript Builder object to update and modify the Prisma schema, enhancing ease of use and functionality.
  • produceSchema Utility: A simple way to apply modifications to schema sources through a producer function, resulting in quick schema updates.
  • Schema Querying: Use the builder to find specific objects in the schema based on names or contexts, aiding in testing and ensuring consistent naming conventions.
  • Custom Sorting: Automatically sort your schema with a default order of generators, datasources, models, and enums, or customize the sort to fit your needs.
  • Flexible Configuration: Leverage lilconfig to read configuration options from various file formats, accommodating different project setups easily.
  • Performance Tracking: Optionally include token locations of CST Nodes in the output schema, with adjustable settings to balance performance and detail.

This library not only enhances the way developers interact with Prisma schemas, but also streamlines processes, making it an invaluable asset for any project relying on Prisma.

prisma
Prisma

Prisma is a server-side library that helps developers read and write data to the database in an intuitive, efficient and safe way.

fullstack
Fullstack

A fullstack boilerplate provides a starter application that includes both frontend and backend. It should include database, auth, payments, user roles and other backend services to build a fully featured saas or webapps.

eslint
Eslint

ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.