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