data_modelling_sdk/import/
mod.rs

1//! Import functionality
2//!
3//! Provides parsers for importing data models from various formats:
4//! - SQL (CREATE TABLE statements)
5//! - ODCS (Open Data Contract Standard) v3.1.0 YAML format (legacy ODCL formats supported for import)
6//! - JSON Schema
7//! - AVRO
8//! - Protobuf
9
10pub mod avro;
11pub mod dataflow;
12pub mod json_schema;
13pub mod odcs;
14pub mod protobuf;
15pub mod sql;
16
17// anyhow::Result not currently used in this module
18
19/// Result of an import operation.
20///
21/// Contains extracted tables and any errors/warnings from the import process.
22#[derive(Debug, serde::Serialize, serde::Deserialize)]
23#[must_use = "import results should be processed or errors checked"]
24pub struct ImportResult {
25    /// Tables extracted from the import
26    pub tables: Vec<TableData>,
27    /// Tables that require name input (for SQL imports with unnamed tables)
28    pub tables_requiring_name: Vec<TableRequiringName>,
29    /// Parse errors/warnings
30    pub errors: Vec<ImportError>,
31    /// Whether AI suggestions are available
32    pub ai_suggestions: Option<Vec<serde_json::Value>>,
33}
34
35/// Error during import
36#[derive(Debug, thiserror::Error, serde::Serialize, serde::Deserialize)]
37pub enum ImportError {
38    #[error("Parse error: {0}")]
39    ParseError(String),
40    #[error("Validation error: {0}")]
41    ValidationError(String),
42    #[error("IO error: {0}")]
43    IoError(String),
44}
45
46/// Table data from import
47#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
48pub struct TableData {
49    pub table_index: usize,
50    pub name: Option<String>,
51    pub columns: Vec<ColumnData>,
52    // Additional fields can be added as needed
53}
54
55/// Column data from import
56#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
57pub struct ColumnData {
58    pub name: String,
59    pub data_type: String,
60    pub nullable: bool,
61    pub primary_key: bool,
62}
63
64// Re-export for convenience
65pub use avro::AvroImporter;
66pub use json_schema::JSONSchemaImporter;
67pub use odcs::ODCSImporter;
68pub use protobuf::ProtobufImporter;
69pub use sql::SQLImporter;
70
71/// Table requiring name input (for SQL imports)
72#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
73pub struct TableRequiringName {
74    pub table_index: usize,
75    pub suggested_name: Option<String>,
76}