use thiserror::Error;
mod assets;
#[cfg(feature = "cli")]
mod cli;
mod graph;
mod server;
pub use server::serve;
#[derive(Clone, Debug, serde::Serialize)]
pub struct ProjectInfo {
pub name: String,
pub root_path: String,
pub db_path: String,
pub node_count: u64,
pub edge_count: u64,
}
#[derive(Clone, serde::Serialize)]
pub struct GraphNode {
pub id: String,
pub label: String,
pub name: String,
pub file_path: Option<String>,
pub project: String,
pub qualified_name: Option<String>,
pub start_line: Option<u32>,
pub end_line: Option<u32>,
pub x: f64,
pub y: f64,
pub z: f64,
}
#[derive(Clone, serde::Serialize)]
pub struct GraphEdge {
pub id: String,
pub source: String,
pub target: String,
pub edge_type: String,
pub confidence: f32,
pub start_line: Option<u32>,
pub project: String,
}
#[derive(serde::Serialize)]
pub struct GraphData {
pub nodes: Vec<GraphNode>,
pub edges: Vec<GraphEdge>,
pub total_nodes: u64,
pub total_edges: u64,
}
#[derive(serde::Serialize)]
pub struct SchemaInfo {
pub node_labels: Vec<LabelCount>,
pub edge_types: Vec<TypeCount>,
pub total_nodes: u64,
pub total_edges: u64,
}
#[derive(serde::Serialize)]
pub struct LabelCount {
pub label: String,
pub count: u64,
}
#[derive(serde::Serialize)]
pub struct TypeCount {
pub r#type: String,
pub count: u64,
}
#[derive(serde::Serialize)]
pub struct TraceResult {
pub origin: GraphNode,
pub paths: Vec<TracePath>,
pub direction: String,
}
#[derive(serde::Serialize)]
pub struct TracePath {
pub nodes: Vec<GraphNode>,
pub edges: Vec<GraphEdge>,
}
#[derive(serde::Serialize)]
pub struct ErrorBody {
pub error: String,
}
#[derive(Clone, Debug)]
pub struct ViewerConfig {
pub port: u16,
}
#[derive(Debug, Error)]
pub enum ViewerError {
#[error("failed to bind 127.0.0.1:{port}: {source}")]
Bind {
port: u16,
#[source]
source: std::io::Error,
},
#[error("viewer server io error: {0}")]
Io(#[from] std::io::Error),
}