mold_cli/generators/
mod.rs1mod prisma;
2mod typescript;
3mod zod;
4
5pub use prisma::PrismaGenerator;
6pub use typescript::TypeScriptGenerator;
7pub use zod::ZodGenerator;
8
9use crate::types::Schema;
10use anyhow::Result;
11
12#[derive(Debug, Clone)]
13pub struct GeneratorConfig {
14 pub flat_mode: bool,
15 pub indent: String,
16 pub ts_export_interfaces: bool,
17 pub ts_readonly_fields: bool,
18 pub zod_strict_objects: bool,
19 pub prisma_generate_relations: bool,
20}
21
22impl Default for GeneratorConfig {
23 fn default() -> Self {
24 Self {
25 flat_mode: false,
26 indent: " ".to_string(),
27 ts_export_interfaces: false,
28 ts_readonly_fields: false,
29 zod_strict_objects: false,
30 prisma_generate_relations: true,
31 }
32 }
33}
34
35pub trait Generator {
36 fn generate(&self, schema: &Schema, config: &GeneratorConfig) -> Result<String>;
37 fn file_extension(&self) -> &'static str;
38}