//! Polyglot type and validator generation from schemas.
//!
//! `normalize-typegen` converts schema formats (JSON Schema, OpenAPI, Protobuf) into
//! idiomatic type definitions and runtime validators for multiple languages.
//!
//! # Architecture
//!
//! ```text
//! Input Formats          IR              Output Backends
//! ──────────────     ─────────────     ─────────────────
//! JSON Schema   ─┐                  ┌─> TypeScript types
//! OpenAPI       ─┤                  ├─> TypeScript validators (Zod, Valibot)
//! Protobuf      ─┼─> Schema ────────├─> Python types (dataclasses, TypedDict)
//! GraphQL SDL   ─┤   (ir.rs)        ├─> Python validators (Pydantic)
//! TypeScript    ─┘                  ├─> Go types (structs)
//!                                   ├─> Rust types (serde structs)
//!                                   ├─> JSON Schema (draft 2020-12)
//!                                   ├─> GraphQL SDL
//!                                   └─> Protobuf (proto3)
//! ```
//!
//! # Example
//!
//! ```
//! use normalize_typegen::{input, output, ir::Schema};
//!
//! let json_schema = serde_json::json!({
//!     "type": "object",
//!     "title": "User",
//!     "properties": {
//!         "id": { "type": "string" },
//!         "name": { "type": "string" }
//!     },
//!     "required": ["id", "name"]
//! });
//!
//! // Parse JSON Schema to IR
//! let schema = input::parse_json_schema(&json_schema).unwrap();
//!
//! // Generate TypeScript
//! let ts = output::generate_typescript_types(&schema, &Default::default());
//! assert!(ts.contains("interface User"));
//! ```
//!
//! # Using the Backend Registry
//!
//! ```ignore
//! use normalize_typegen::{get_backend, backend_names};
//!
//! // List all available backends
//! for name in backend_names() {
//!     println!("Backend: {}", name);
//! }
//!
//! // Get and use a specific backend
//! if let Some(backend) = get_backend("typescript") {
//!     let output = backend.generate(&schema);
//!     println!("{}", output);
//! }
//! ```
//!
//! # Feature Flags
//!
//! Backend flags (use `backend-*` prefix):
//! - `backend-typescript` - TypeScript interfaces/types
//! - `backend-zod` - Zod schema generation
//! - `backend-valibot` - Valibot schema generation
//! - `backend-python` - Python dataclasses/TypedDict
//! - `backend-pydantic` - Pydantic model generation
//! - `backend-go` - Go structs with json tags
//! - `backend-rust` - Rust structs with serde
//! - `backend-jsonschema` - JSON Schema (draft 2020-12) output
//! - `backend-graphql` - GraphQL SDL output
//! - `backend-proto` - Protobuf (proto3) output
//!
//! Language umbrella flags (convenience, enable types + validators):
//! - `typescript` - backend-typescript + backend-zod + backend-valibot
//! - `python` - backend-python + backend-pydantic
//! - `go` - backend-go
//! - `rust-types` - backend-rust
//!
//! Input parser flags:
//! - `input-typescript` - TypeScript source parser (requires arborium-typescript)
//! - `input-graphql` - GraphQL SDL parser (requires arborium-graphql)
//! - Protobuf (`.proto`) parsing is always available via [`parse_proto`] (no extra feature needed)

pub mod input;
pub mod ir;
pub mod output;
pub mod registry;
pub mod traits;

// Re-export commonly used items
#[cfg(feature = "input-graphql")]
pub use input::parse_graphql_schema;
#[cfg(feature = "input-typescript")]
pub use input::parse_typescript_types;
pub use input::{ParseError, parse_json_schema, parse_openapi, parse_proto};

// Re-export traits
pub use traits::{Backend, BackendCategory};

// Re-export registry functions
pub use registry::{
    backend_names, backends, backends_by_category, backends_for_language, get_backend,
    register_backend,
};

// Re-export generators (kept for backwards compatibility)
#[cfg(feature = "backend-typescript")]
pub use output::generate_typescript_types;

#[cfg(feature = "backend-zod")]
pub use output::generate_zod;

#[cfg(feature = "backend-valibot")]
pub use output::generate_valibot;

#[cfg(feature = "backend-python")]
pub use output::generate_python_types;

#[cfg(feature = "backend-pydantic")]
pub use output::generate_pydantic;

#[cfg(feature = "backend-go")]
pub use output::generate_go_types;

#[cfg(feature = "backend-rust")]
pub use output::generate_rust_types;

#[cfg(feature = "backend-jsonschema")]
pub use output::generate_json_schema;

#[cfg(feature = "backend-graphql")]
pub use output::generate_graphql_sdl;

#[cfg(feature = "backend-proto")]
pub use output::generate_proto;

// Re-export backend structs
#[cfg(feature = "backend-typescript")]
pub use output::typescript::TypeScriptBackend;

#[cfg(feature = "backend-zod")]
pub use output::zod::ZodBackend;

#[cfg(feature = "backend-valibot")]
pub use output::valibot::ValibotBackend;

#[cfg(feature = "backend-python")]
pub use output::python::PythonBackend;

#[cfg(feature = "backend-pydantic")]
pub use output::pydantic::PydanticBackend;

#[cfg(feature = "backend-go")]
pub use output::go::GoBackend;

#[cfg(feature = "backend-rust")]
pub use output::rust::RustBackend;

#[cfg(feature = "backend-jsonschema")]
pub use output::jsonschema::JsonSchemaBackend;

#[cfg(feature = "backend-graphql")]
pub use output::graphql::GraphQlBackend;

#[cfg(feature = "backend-proto")]
pub use output::proto::ProtoBackend;
