data_modelling_core/models/odcs/
mod.rs

1//! ODCS Native Data Structures
2//!
3//! This module provides native Rust types that model the ODCS (Open Data Contract Standard)
4//! v3.1.0 specification accurately. These types preserve the three-level hierarchy:
5//!
6//! 1. **Contract Level** ([`ODCSContract`]) - Root document with metadata
7//! 2. **Schema Level** ([`SchemaObject`]) - Tables/views/topics within a contract
8//! 3. **Property Level** ([`Property`]) - Columns/fields within a schema
9//!
10//! ## Design Goals
11//!
12//! - **Zero data loss**: Full round-trip import/export without losing metadata
13//! - **Multi-table support**: Native support for contracts with multiple schema objects
14//! - **Nested properties**: Proper hierarchical representation for OBJECT and ARRAY types
15//! - **Format mapping**: Clean mapping from Avro, Protobuf, JSON Schema, OpenAPI via custom properties
16//! - **Backwards compatibility**: Converters to/from existing `Table`/`Column` types
17//!
18//! ## Example
19//!
20//! ```rust
21//! use data_modelling_core::models::odcs::{ODCSContract, SchemaObject, Property};
22//!
23//! // Create a contract with two tables
24//! let contract = ODCSContract::new("ecommerce", "1.0.0")
25//!     .with_domain("retail")
26//!     .with_status("active")
27//!     .with_schema(
28//!         SchemaObject::new("orders")
29//!             .with_physical_type("table")
30//!             .with_properties(vec![
31//!                 Property::new("id", "integer").with_primary_key(true),
32//!                 Property::new("customer_id", "integer").with_required(true),
33//!                 Property::new("total", "number"),
34//!             ])
35//!     )
36//!     .with_schema(
37//!         SchemaObject::new("order_items")
38//!             .with_physical_type("table")
39//!             .with_properties(vec![
40//!                 Property::new("id", "integer").with_primary_key(true),
41//!                 Property::new("order_id", "integer").with_required(true),
42//!                 Property::new("product_name", "string"),
43//!             ])
44//!     );
45//!
46//! assert_eq!(contract.schema_count(), 2);
47//! ```
48
49pub mod contract;
50pub mod converters;
51pub mod property;
52pub mod schema;
53pub mod supporting;
54
55// Re-export main types for convenience
56pub use contract::ODCSContract;
57pub use property::Property;
58pub use schema::SchemaObject;
59
60// Re-export supporting types
61pub use supporting::{
62    AuthoritativeDefinition, CustomProperty, Description, Link, LogicalTypeOptions, Price,
63    PropertyRelationship, QualityRule, Role, SchemaRelationship, Server, ServiceLevel,
64    StructuredDescription, Support, Team, TeamMember, Terms,
65};