type_bridge_server/lib.rs
1#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
2#![deny(missing_docs)]
3
4//! # type-bridge-server
5//!
6//! Transport-agnostic query pipeline for TypeDB with composable interceptors.
7//!
8//! This crate provides both a library and a standalone binary for executing
9//! TypeQL queries through a structured pipeline: **validate → intercept →
10//! compile → execute → intercept**.
11//!
12//! ## Feature flags
13//!
14//! | Feature | Default | Description |
15//! |---------|---------|-------------|
16//! | `typedb` | yes | TypeDB backend via [`TypeDBClient`](typedb::TypeDBClient) |
17//! | `axum-transport` | yes | HTTP server with `/query`, `/query/validate`, `/health`, `/schema` endpoints |
18//! | `v2-query` | yes | Additive prepared `/v2/capabilities` and `/v2/query` routes |
19//!
20//! Disable defaults with `--no-default-features` to use the core pipeline as
21//! a library without any transport or backend.
22//!
23//! ## Library usage
24//!
25//! This example is ignored because the executor and interceptor values are
26//! application-defined extension points rather than crate-provided fixtures.
27//!
28//! ```rust,ignore
29//! use type_bridge_server::pipeline::PipelineBuilder;
30//! use type_bridge_server::schema_source::InMemorySchemaSource;
31//!
32//! let pipeline = PipelineBuilder::new(my_executor)
33//! .with_schema_source(InMemorySchemaSource::new(tql_schema))
34//! .with_default_database("my_db")
35//! .with_interceptor(my_audit_log)
36//! .build()?;
37//!
38//! let output = pipeline.execute_query(input).await?;
39//! ```
40//!
41//! ## Extension points
42//!
43//! - **[`QueryExecutor`](executor::QueryExecutor)** — implement to use a
44//! non-TypeDB backend or a mock.
45//! - **[`Interceptor`](interceptor::Interceptor)** — implement to add
46//! cross-cutting concerns (audit, auth, rate limiting).
47//! - **[`SchemaSource`](schema_source::SchemaSource)** — implement to load
48//! TypeQL schemas from custom sources.
49
50#[cfg(doctest)]
51#[doc = include_str!("../README.md")]
52pub mod readme_doctests {}
53
54/// Standalone server configuration and bounded material loading.
55pub mod config;
56/// Errors returned by the query pipeline and transports.
57pub mod error;
58/// Provider-independent query execution interfaces.
59pub mod executor;
60/// Request, response, audit, and CRUD interceptor APIs.
61pub mod interceptor;
62/// The transport-independent query execution pipeline.
63pub mod pipeline;
64/// Schema-loading interfaces and built-in sources.
65pub mod schema_source;
66
67#[cfg(feature = "axum-transport")]
68/// Axum HTTP request and response transports.
69pub mod transport;
70
71#[cfg(feature = "typedb")]
72/// TypeDB-backed query executor implementation.
73pub mod typedb;
74
75#[cfg(test)]
76#[cfg_attr(coverage_nightly, coverage(off))]
77mod test_helpers;