Skip to main content

data_modelling_core/export/
mod.rs

1//! Export functionality
2//!
3//! Provides exporters for various formats:
4//! - SQL
5//! - JSON Schema
6//! - AVRO
7//! - Protobuf
8//! - ODCS (Open Data Contract Standard) v3.1.0
9//! - PNG
10//! - PDF (with branding support)
11//! - Decision (MADR-compliant decision records)
12//! - Knowledge (Knowledge Base articles)
13//! - Markdown (for GitHub readability)
14
15pub mod avro;
16#[cfg(feature = "bpmn")]
17pub mod bpmn;
18pub mod cads;
19pub mod decision;
20#[cfg(feature = "dmn")]
21pub mod dmn;
22pub mod json_schema;
23pub mod knowledge;
24pub mod markdown;
25pub mod odcl;
26pub mod odcs;
27pub mod odps;
28#[cfg(feature = "openapi")]
29pub mod openapi;
30pub mod pdf;
31#[cfg(feature = "png-export")]
32pub mod png;
33pub mod protobuf;
34pub mod sketch;
35pub mod sql;
36
37// anyhow::Result not currently used in this module
38
39/// Result of an export operation.
40///
41/// Contains the exported content and format identifier.
42#[derive(Debug, serde::Serialize, serde::Deserialize)]
43#[must_use = "export results contain the exported content and should be used"]
44pub struct ExportResult {
45    /// Exported content (as string - binary formats will be base64 encoded)
46    pub content: String,
47    /// Format identifier
48    pub format: String,
49}
50
51/// Error during export
52#[derive(Debug, thiserror::Error, serde::Serialize, serde::Deserialize)]
53pub enum ExportError {
54    #[error("Serialization error: {0}")]
55    SerializationError(String),
56    #[error("Validation error: {0}")]
57    ValidationError(String),
58    #[error("Invalid argument: {0}")]
59    InvalidArgument(String),
60    #[error("IO error: {0}")]
61    IoError(String),
62    #[error("Export error: {0}")]
63    ExportError(String),
64    #[error("BPMN export error: {0}")]
65    BPMNExportError(String),
66    #[error("DMN export error: {0}")]
67    DMNExportError(String),
68    #[error("OpenAPI export error: {0}")]
69    OpenAPIExportError(String),
70    #[error("Model not found: {0}")]
71    ModelNotFound(String),
72}
73
74impl From<Box<dyn std::error::Error>> for ExportError {
75    fn from(err: Box<dyn std::error::Error>) -> Self {
76        ExportError::ExportError(err.to_string())
77    }
78}
79
80// Re-export for convenience
81pub use avro::AvroExporter;
82#[cfg(feature = "bpmn")]
83pub use bpmn::BPMNExporter;
84pub use cads::CADSExporter;
85pub use decision::DecisionExporter;
86#[cfg(feature = "dmn")]
87pub use dmn::DMNExporter;
88pub use json_schema::JSONSchemaExporter;
89pub use knowledge::KnowledgeExporter;
90pub use markdown::{BrandedMarkdownExporter, MarkdownBrandingConfig, MarkdownExporter};
91pub use odcl::ODCLExporter;
92pub use odcs::ODCSExporter;
93pub use odps::ODPSExporter;
94#[cfg(feature = "openapi")]
95pub use openapi::OpenAPIExporter;
96pub use pdf::{BrandingConfig, PageSize, PdfExportResult, PdfExporter};
97#[cfg(feature = "png-export")]
98pub use png::PNGExporter;
99pub use protobuf::ProtobufExporter;
100pub use sketch::SketchExporter;
101pub use sql::SQLExporter;