Expand description
§PSL stands for Prisma Schema Language
§Overview
This crate is the public API for working with Prisma schemas: parsing and validating their string representation, analyzing them, providing convenient APIs, rendering, reformatting, etc. It is the main implementation of the Prisma Schema Language, and it is used by all Prisma engines in this repository.
The query engine further processes Prisma schemas to produce the client API, and the DMMF JSON format.
§Usage
Please see lib.rs and the rustdoc documentation for the public API.
Main use-case, parsing a string to datamodel:
ⓘ
let file = std::fs::read_to_string(&args[1]).unwrap();
let validated_schema = datamodel::parse_schema(&file)?;Re-exports§
pub use psl_core::diagnostics;pub use psl_core::parser_database;pub use psl_core::schema_ast;
Modules§
- builtin_
connectors - datamodel_
connector - The interface implemented by connectors for Prisma schema validation and interpretation.
- generators
- Convenient access to a ID generator constants, used by Prisma in psl, Query Engine and Schema Engine.
Every change to the
DEFAULT_*_VERSIONconstants in this module is a breaking change. - get_
config - The implementation of the CLI getConfig() utility and its JSON format.
Macros§
- reachable_
only_ with_ capability - Marks the code as reachable only by the connectors, having the specific capability. Optimizer usually can optimize the code away if none of the connectors current build supports the capability.
Structs§
- Configuration
- Datasource
- a
datasourcefrom the prisma schema. - Datasource
Connector Data - Datasource
Urls - Diagnostics
- Represents a list of validation or parser errors and warnings.
- Feature
MapWith Provider - Generator
- Source
File - A Prisma schema document.
- String
From EnvVar - Either an env var or a string literal. TODO: From Prisma 7 onwards, this struct will not be needed, as the value will always be a plain String.
- Validated
Schema
Enums§
Statics§
- ALL_
PREVIEW_ FEATURES - The default feature map with an unknown provider.
This is used for convenience in
prisma/language-tools, which needs the list of all available preview features before a provider is necessarily known.
Functions§
- can_
have_ capability - Helper function for determining if engine, compiled with the current settings, can potentially have provided capability on. Useful for single-connector builds and can be used to exclude certain code that we know for sure can’t be executed for current connector. Has no effect on multi-connector builds
- can_
support_ relation_ load_ strategy - error_
tolerant_ parse_ configuration - Parses and validates Prisma schemas, but skip analyzing everything except datasource and generator
blocks. It never fails, but when the returned
Diagnosticscontains errors, it implies that theConfigurationcontent is partial. Consumers may then decide whether to convertDiagnosticsinto an error. - generators_
to_ json - get_
config - has_
capability - is_
reserved_ type_ name - Is this a valid type name for the Prisma Client API?
- parse_
configuration - Parses and validate a schema, but skip analyzing everything except datasource and generator blocks.
- parse_
configuration_ multi_ file - Parses and validates Prisma schemas, but skip analyzing everything except datasource and generator blocks.
- parse_
schema - Parse and analyze a Prisma schema.
- parse_
schema_ multi - Parse and analyze a Prisma schema.
- parse_
schema_ multi_ without_ extensions - Parse and analyze a Prisma schema. This variant does not support extensions.
- parse_
schema_ without_ extensions - Parse and analyze a Prisma schema. This variant does not support extensions.
- parse_
without_ validation - Parse a Prisma schema, but skip validations.
- reformat
- Returns either the reformatted schema, or the original input if we can’t reformat. This happens if and only if the source does not parse to a well formed AST.
- reformat_
multiple - reformat_
validated_ schema_ into_ single - render_
sources_ to_ json - set_
config_ dir - validate
- The most general API for dealing with Prisma schemas. It accumulates what analysis and validation information it can, and returns it along with any error and warning diagnostics.
- validate_
multi_ file - The most general API for dealing with Prisma schemas. It accumulates what analysis and validation information it can, and returns it along with any error and warning diagnostics.
- validate_
multi_ file_ without_ extensions - The most general API for dealing with Prisma schemas. It accumulates what analysis and validation information it can, and returns it along with any error and warning diagnostics. This variant does not support extensions.
- validate_
without_ extensions - The most general API for dealing with Prisma schemas. It accumulates what analysis and validation information it can, and returns it along with any error and warning diagnostics. This variant does not support extensions.
Type Aliases§
- Connector
Registry - The collection of all available connectors.
- Preview
Features - A set of preview features.