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