Skip to main content

Crate saola_psl

Crate saola_psl 

Source
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_*_VERSION constants 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 datasource from the prisma schema.
DatasourceConnectorData
DatasourceUrls
Diagnostics
Represents a list of validation or parser errors and warnings.
FeatureMapWithProvider
Generator
SourceFile
A Prisma schema document.
StringFromEnvVar
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.
ValidatedSchema

Enums§

GeneratorConfigValue
PreviewFeature

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 Diagnostics contains errors, it implies that the Configuration content is partial. Consumers may then decide whether to convert Diagnostics into 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§

ConnectorRegistry
The collection of all available connectors.
PreviewFeatures
A set of preview features.