Skip to main content

omnigraph_server/
api.rs

1//! HTTP wire DTOs. The types and their engine-result -> DTO mappings live
2//! in the shared `omnigraph-api-types` crate (RFC-009 Phase 2) so the CLI
3//! and server share one definition; re-exported here so every
4//! `omnigraph_server::api::*` path (handlers, the OpenApi schema list,
5//! CLI imports) keeps resolving unchanged. Only `query_catalog_entry`
6//! stays — it maps the server's runtime `StoredQuery` (not a wire type)
7//! into the shared `QueryCatalogEntry` DTO.
8
9pub use omnigraph_api_types::*;
10
11use crate::queries::StoredQuery;
12
13/// Project a loaded stored query into its catalog entry (typed params,
14/// MCP tool name, read/mutate flag, description/instruction).
15pub fn query_catalog_entry(query: &StoredQuery) -> QueryCatalogEntry {
16    QueryCatalogEntry {
17        name: query.name.clone(),
18        tool_name: query.effective_tool_name().to_string(),
19        description: query.decl.description.clone(),
20        instruction: query.decl.instruction.clone(),
21        mutation: query.is_mutation(),
22        params: query.decl.params.iter().map(param_descriptor).collect(),
23    }
24}