Skip to main content

type_bridge_server/
lib.rs

1#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
2
3//! # type-bridge-server
4//!
5//! Transport-agnostic query pipeline for TypeDB with composable interceptors.
6//!
7//! This crate provides both a library and a standalone binary for executing
8//! TypeQL queries through a structured pipeline: **validate → intercept →
9//! compile → execute → intercept**.
10//!
11//! ## Feature flags
12//!
13//! | Feature | Default | Description |
14//! |---------|---------|-------------|
15//! | `typedb` | yes | TypeDB backend via [`TypeDBClient`](typedb::TypeDBClient) |
16//! | `axum-transport` | yes | HTTP server with `/query`, `/query/validate`, `/health`, `/schema` endpoints |
17//! | `v2-query` | no | Additive prepared `/v2/capabilities` and `/v2/query` routes |
18//!
19//! Disable defaults with `--no-default-features` to use the core pipeline as
20//! a library without any transport or backend.
21//!
22//! ## Library usage
23//!
24//! ```rust,ignore
25//! use type_bridge_server::pipeline::PipelineBuilder;
26//! use type_bridge_server::schema_source::InMemorySchemaSource;
27//!
28//! let pipeline = PipelineBuilder::new(my_executor)
29//!     .with_schema_source(InMemorySchemaSource::new(tql_schema))
30//!     .with_default_database("my_db")
31//!     .with_interceptor(my_audit_log)
32//!     .build()?;
33//!
34//! let output = pipeline.execute_query(input).await?;
35//! ```
36//!
37//! ## Extension points
38//!
39//! - **[`QueryExecutor`](executor::QueryExecutor)** — implement to use a
40//!   non-TypeDB backend or a mock.
41//! - **[`Interceptor`](interceptor::Interceptor)** — implement to add
42//!   cross-cutting concerns (audit, auth, rate limiting).
43//! - **[`SchemaSource`](schema_source::SchemaSource)** — implement to load
44//!   TypeQL schemas from custom sources.
45
46pub mod config;
47pub mod error;
48pub mod executor;
49pub mod interceptor;
50pub mod pipeline;
51pub mod schema_source;
52
53#[cfg(feature = "axum-transport")]
54pub mod transport;
55
56#[cfg(feature = "typedb")]
57pub mod typedb;
58
59#[cfg(any(test, feature = "test-helpers"))]
60#[cfg_attr(coverage_nightly, coverage(off))]
61pub mod test_helpers;