use rmcp::schemars::{self, JsonSchema};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct GetNodeRequest {
#[schemars(description = "The unique identifier of the node")]
pub node_id: u64,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct CreateNodeRequest {
#[schemars(description = "The label/type of the node (e.g., 'Person', 'Document')")]
pub label: String,
#[schemars(description = "Properties to set on the node as key-value pairs")]
pub properties: Option<HashMap<String, serde_json::Value>>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct UpdateNodeRequest {
#[schemars(description = "The unique identifier of the node to update")]
pub node_id: u64,
#[schemars(description = "New properties to set (replaces all existing properties)")]
pub properties: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct DeleteNodeRequest {
#[schemars(description = "The unique identifier of the node to delete")]
pub node_id: u64,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct DeleteNodeCascadeRequest {
#[schemars(
description = "The unique identifier of the node to delete along with all its connected edges"
)]
pub node_id: u64,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct ListNodesRequest {
#[schemars(description = "Filter by node label (optional)")]
pub label: Option<String>,
#[schemars(
description = "Filter by property key. Must be used with 'label' and 'property_value'."
)]
pub property_key: Option<String>,
#[schemars(
description = "Filter by property value (JSON). Must be used with 'label' and 'property_key'."
)]
pub property_value: Option<serde_json::Value>,
#[schemars(description = "Maximum number of nodes to return (default: 100)")]
pub limit: Option<usize>,
#[schemars(description = "Number of nodes to skip (for pagination)")]
pub offset: Option<usize>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct CountNodesRequest {
#[schemars(description = "Filter by node label (optional, if not provided counts all nodes)")]
pub label: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct GetEdgeRequest {
#[schemars(description = "The unique identifier of the edge")]
pub edge_id: u64,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct CreateEdgeRequest {
#[schemars(description = "The source node ID")]
pub source_id: u64,
#[schemars(description = "The target node ID")]
pub target_id: u64,
#[schemars(description = "The label/type of the edge (e.g., 'KNOWS', 'WORKS_AT')")]
pub label: String,
#[schemars(description = "Properties to set on the edge as key-value pairs")]
pub properties: Option<HashMap<String, serde_json::Value>>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct UpdateEdgeRequest {
#[schemars(description = "The unique identifier of the edge to update")]
pub edge_id: u64,
#[schemars(description = "New properties to set (replaces all existing properties)")]
pub properties: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct DeleteEdgeRequest {
#[schemars(description = "The unique identifier of the edge to delete")]
pub edge_id: u64,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct ListEdgesRequest {
#[schemars(description = "Filter by edge label (optional)")]
pub label: Option<String>,
#[schemars(description = "Maximum number of edges to return (default: 100)")]
pub limit: Option<usize>,
#[schemars(description = "Number of edges to skip (for pagination)")]
pub offset: Option<usize>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct CountEdgesRequest {
#[schemars(description = "Filter by edge label (optional, if not provided counts all edges)")]
pub label: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct GetOutgoingEdgesRequest {
#[schemars(description = "The source node ID")]
pub node_id: u64,
#[schemars(description = "Filter by edge label (optional)")]
pub label: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct GetIncomingEdgesRequest {
#[schemars(description = "The target node ID")]
pub node_id: u64,
#[schemars(description = "Filter by edge label (optional)")]
pub label: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct TraverseRequest {
#[schemars(description = "Starting node ID for traversal")]
pub start_node_id: u64,
#[schemars(description = "Edge label to traverse (e.g., 'KNOWS', 'WORKS_AT')")]
pub edge_label: String,
#[schemars(
description = "Traversal direction: 'outgoing', 'incoming', or 'both' (default: 'outgoing')"
)]
pub direction: Option<String>,
#[schemars(description = "Maximum traversal depth (default: 1)")]
pub depth: Option<usize>,
#[schemars(description = "Maximum number of results to return (default: 100)")]
pub limit: Option<usize>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct FindSimilarRequest {
#[schemars(
description = "The property name that contains the vector embedding (e.g., 'embedding')"
)]
pub property_name: String,
#[schemars(description = "The query embedding vector (array of f32 values)")]
pub embedding: Vec<f32>,
#[schemars(description = "Number of similar results to return (default: 10)")]
pub k: Option<usize>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct EnableVectorIndexRequest {
#[schemars(description = "The property name to index (e.g., 'embedding')")]
pub property_name: String,
#[schemars(description = "The dimension of the vectors")]
pub dimensions: usize,
#[schemars(
description = "Distance metric: 'cosine', 'euclidean', or 'dot' (default: 'cosine')"
)]
pub distance_metric: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct ListVectorIndexesRequest {}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct GetNodeAtTimeRequest {
#[schemars(description = "The unique identifier of the node")]
pub node_id: u64,
#[schemars(
description = "Valid time as ISO 8601 timestamp (when the fact was true in reality)"
)]
pub valid_time: String,
#[schemars(
description = "Transaction time as ISO 8601 timestamp (when recorded). If not provided, uses current time."
)]
pub transaction_time: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct GetEdgeAtTimeRequest {
#[schemars(description = "The unique identifier of the edge")]
pub edge_id: u64,
#[schemars(
description = "Valid time as ISO 8601 timestamp (when the fact was true in reality)"
)]
pub valid_time: String,
#[schemars(
description = "Transaction time as ISO 8601 timestamp (when recorded). If not provided, uses current time."
)]
pub transaction_time: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct GetNodeAtValidTimeRequest {
#[schemars(description = "The unique identifier of the node")]
pub node_id: u64,
#[schemars(
description = "Valid time as ISO 8601 timestamp (when the fact was true in reality)"
)]
pub valid_time: String,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct GetNodeAtTransactionTimeRequest {
#[schemars(description = "The unique identifier of the node")]
pub node_id: u64,
#[schemars(
description = "Transaction time as ISO 8601 timestamp (when the fact was recorded)"
)]
pub transaction_time: String,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct GetNodeHistoryRequest {
#[schemars(description = "The unique identifier of the node")]
pub node_id: u64,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct DiffNodeVersionsRequest {
#[schemars(description = "The unique identifier of the node")]
pub node_id: u64,
#[schemars(description = "The ID of the older version (from)")]
pub from_version: u64,
#[schemars(description = "The ID of the newer version (to)")]
pub to_version: u64,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct GetEdgeAtValidTimeRequest {
#[schemars(description = "The unique identifier of the edge")]
pub edge_id: u64,
#[schemars(
description = "Valid time as ISO 8601 timestamp (when the fact was true in reality)"
)]
pub valid_time: String,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct GetEdgeAtTransactionTimeRequest {
#[schemars(description = "The unique identifier of the edge")]
pub edge_id: u64,
#[schemars(
description = "Transaction time as ISO 8601 timestamp (when the fact was recorded)"
)]
pub transaction_time: String,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct GetEdgeHistoryRequest {
#[schemars(description = "The unique identifier of the edge")]
pub edge_id: u64,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct DiffEdgeVersionsRequest {
#[schemars(description = "The unique identifier of the edge")]
pub edge_id: u64,
#[schemars(description = "The ID of the older version (from)")]
pub from_version: u64,
#[schemars(description = "The ID of the newer version (to)")]
pub to_version: u64,
}
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub struct HybridQueryRequest {
#[schemars(description = "Starting node ID (optional, for graph-first queries)")]
pub start_node_id: Option<u64>,
#[schemars(description = "Edge label for traversal (optional)")]
pub traverse_edge: Option<String>,
#[schemars(description = "Traversal depth (optional, default: 1)")]
pub traverse_depth: Option<usize>,
#[schemars(description = "Property name for vector similarity (optional)")]
pub vector_property: Option<String>,
#[schemars(description = "Query embedding for vector similarity (optional)")]
pub query_embedding: Option<Vec<f32>>,
#[schemars(description = "Number of similar results for vector search (optional)")]
pub top_k: Option<usize>,
#[schemars(description = "Valid time for temporal filtering (optional, ISO 8601)")]
pub valid_time: Option<String>,
#[schemars(description = "Transaction time for temporal filtering (optional, ISO 8601)")]
pub transaction_time: Option<String>,
#[schemars(description = "Filter by node label (optional)")]
pub filter_label: Option<String>,
#[schemars(description = "Maximum number of results (default: 100)")]
pub limit: Option<usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NodeResponse {
pub id: u64,
pub label: String,
pub properties: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EdgeResponse {
pub id: u64,
pub source_id: u64,
pub target_id: u64,
pub label: String,
pub properties: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SimilarityResult {
pub node: NodeResponse,
pub score: f32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TraversalResult {
pub node: NodeResponse,
pub path: Vec<u64>,
pub depth: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HybridQueryResult {
pub node: NodeResponse,
pub similarity_score: Option<f32>,
pub traversal_path: Option<Vec<u64>>,
pub timestamp: Option<String>,
}
#[allow(dead_code)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VersionInfoResponse {
pub version_number: u64,
pub version_id: u64,
pub valid_from: String,
pub valid_to: Option<String>,
pub transaction_from: String,
pub transaction_to: Option<String>,
pub properties: HashMap<String, serde_json::Value>,
pub label: String,
}
#[allow(dead_code)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EntityHistoryResponse {
pub versions: Vec<VersionInfoResponse>,
}
#[allow(dead_code)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VersionDiffResponse {
pub from_version: u64,
pub to_version: u64,
pub added: HashMap<String, serde_json::Value>,
pub removed: HashMap<String, serde_json::Value>,
pub modified: Vec<PropertyChangeResponse>,
}
#[allow(dead_code)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PropertyChangeResponse {
pub key: String,
pub old_value: serde_json::Value,
pub new_value: serde_json::Value,
}