use crate::address::is_valid_entity_id;
use crate::error::{Result, RototoError};
pub(super) fn checked_id(kind: &str, id: &str) -> Result<()> {
if is_valid_entity_id(id) {
Ok(())
} else {
Err(RototoError::new(format!(
"{kind} id `{id}` must be lowercase snake_case segments separated by `/`"
)))
}
}
pub(super) fn variable_path(id: &str) -> String {
format!("variables/{id}.toml")
}
pub(super) fn list_path(id: &str) -> String {
format!("lists/{id}.toml")
}
pub(super) fn layer_path(id: &str) -> String {
format!("layers/{id}.toml")
}
pub(super) fn catalog_schema_path(id: &str) -> String {
format!("model/catalogs/{id}.schema.json")
}
pub(super) fn catalog_data_dir(id: &str) -> String {
format!("data/catalogs/{id}/")
}
pub(super) fn entry_path(catalog: &str, key: &str) -> String {
format!("data/catalogs/{catalog}/{key}.toml")
}
pub(super) fn context_schema_path(id: &str) -> String {
format!("model/context/{id}.schema.json")
}
pub(super) fn samples_dir(context: &str) -> String {
format!("model/context/{context}-samples/")
}
pub(super) fn sample_path(context: &str, key: &str) -> String {
format!("model/context/{context}-samples/{key}.json")
}