#![doc = include_str!("../README.md")]
#![deny(rust_2018_idioms, unsafe_code, missing_docs)]
pub use psl_core::builtin_connectors;
pub use psl_core::{
datamodel_connector,
diagnostics::{self, Diagnostics},
is_reserved_type_name,
mcf::config_to_mcf_json_value as get_config,
mcf::{generators_to_json, render_sources_to_json}, parser_database::{self, SourceFile},
reformat,
schema_ast,
set_config_dir,
Configuration,
ConnectorRegistry,
Datasource,
DatasourceConnectorData,
Generator,
GeneratorConfigValue,
PreviewFeature,
PreviewFeatures,
StringFromEnvVar,
ValidatedSchema,
ALL_PREVIEW_FEATURES,
};
pub mod get_config {
pub use psl_core::mcf::{config_to_mcf_json_value as get_config, *};
}
pub fn parse_configuration(schema: &str) -> Result<Configuration, Diagnostics> {
psl_core::parse_configuration(schema, builtin_connectors::BUILTIN_CONNECTORS)
}
pub fn parse_schema(file: impl Into<SourceFile>) -> Result<ValidatedSchema, String> {
let mut schema = validate(file.into());
schema
.diagnostics
.to_result()
.map_err(|err| err.to_pretty_string("schema.prisma", schema.db.source()))?;
Ok(schema)
}
pub fn validate(file: SourceFile) -> ValidatedSchema {
psl_core::validate(file, builtin_connectors::BUILTIN_CONNECTORS)
}
pub fn parse_without_validation(file: SourceFile, connector_registry: ConnectorRegistry<'_>) -> ValidatedSchema {
psl_core::parse_without_validation(file, connector_registry)
}