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 dbmv;
20pub mod decision;
21#[cfg(feature = "dmn")]
22pub mod dmn;
23pub mod json_schema;
24pub mod knowledge;
25pub mod markdown;
26pub mod odcl;
27pub mod odcs;
28pub mod odps;
29#[cfg(feature = "openapi")]
30pub mod openapi;
31pub mod pdf;
32#[cfg(feature = "png-export")]
33pub mod png;
34pub mod protobuf;
35pub mod sketch;
36pub mod sql;
37
38// anyhow::Result not currently used in this module
39
40/// Result of an export operation.
41///
42/// Contains the exported content and format identifier.
43#[derive(Debug, serde::Serialize, serde::Deserialize)]
44#[must_use = "export results contain the exported content and should be used"]
45pub struct ExportResult {
46    /// Exported content (as string - binary formats will be base64 encoded)
47    pub content: String,
48    /// Format identifier
49    pub format: String,
50}
51
52/// Error during export
53#[derive(Debug, thiserror::Error, serde::Serialize, serde::Deserialize)]
54pub enum ExportError {
55    #[error("Serialization error: {0}")]
56    SerializationError(String),
57    #[error("Validation error: {0}")]
58    ValidationError(String),
59    #[error("Invalid argument: {0}")]
60    InvalidArgument(String),
61    #[error("IO error: {0}")]
62    IoError(String),
63    #[error("Export error: {0}")]
64    ExportError(String),
65    #[error("BPMN export error: {0}")]
66    BPMNExportError(String),
67    #[error("DMN export error: {0}")]
68    DMNExportError(String),
69    #[error("OpenAPI export error: {0}")]
70    OpenAPIExportError(String),
71    #[error("Model not found: {0}")]
72    ModelNotFound(String),
73}
74
75impl From<Box<dyn std::error::Error>> for ExportError {
76    fn from(err: Box<dyn std::error::Error>) -> Self {
77        ExportError::ExportError(err.to_string())
78    }
79}
80
81// Re-export for convenience
82pub use avro::AvroExporter;
83#[cfg(feature = "bpmn")]
84pub use bpmn::BPMNExporter;
85pub use cads::CADSExporter;
86pub use dbmv::DBMVExporter;
87pub use decision::DecisionExporter;
88#[cfg(feature = "dmn")]
89pub use dmn::DMNExporter;
90pub use json_schema::JSONSchemaExporter;
91pub use knowledge::KnowledgeExporter;
92pub use markdown::{BrandedMarkdownExporter, MarkdownBrandingConfig, MarkdownExporter};
93pub use odcl::ODCLExporter;
94pub use odcs::ODCSExporter;
95pub use odps::ODPSExporter;
96#[cfg(feature = "openapi")]
97pub use openapi::OpenAPIExporter;
98pub use pdf::{BrandingConfig, PageSize, PdfExportResult, PdfExporter};
99#[cfg(feature = "png-export")]
100pub use png::PNGExporter;
101pub use protobuf::ProtobufExporter;
102pub use sketch::SketchExporter;
103pub use sql::SQLExporter;