2026-04-20 22:54:31 +01:00
|
|
|
use crate::query;
|
|
|
|
|
|
2026-04-21 20:30:41 +01:00
|
|
|
pub(crate) mod auth;
|
2026-04-20 22:54:31 +01:00
|
|
|
pub(crate) mod repo;
|
2026-04-21 11:50:04 +01:00
|
|
|
pub(crate) mod user;
|
2026-04-20 22:54:31 +01:00
|
|
|
|
2026-04-21 11:50:04 +01:00
|
|
|
#[derive(Clone)]
|
2026-04-20 22:54:31 +01:00
|
|
|
pub struct QueryContext {
|
|
|
|
|
pub(crate) http: reqwest::Client,
|
2026-04-21 11:50:04 +01:00
|
|
|
pub(crate) auth: Option<Auth>,
|
2026-04-21 20:30:41 +01:00
|
|
|
pub(crate) github: GithubCredentials,
|
2026-04-20 22:54:31 +01:00
|
|
|
}
|
|
|
|
|
|
2026-04-21 11:50:04 +01:00
|
|
|
#[derive(Clone)]
|
|
|
|
|
pub(crate) struct Auth {
|
2026-04-21 20:30:41 +01:00
|
|
|
pub(crate) access_token: &'static str,
|
|
|
|
|
pub(crate) refresh_token: &'static str,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
|
pub(crate) struct GithubCredentials {
|
|
|
|
|
pub(crate) client_id: &'static str,
|
2026-04-21 11:50:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub enum Error {
|
|
|
|
|
Unauthenticated,
|
2026-04-21 20:30:41 +01:00
|
|
|
MalformedResponse(serde_json::Error),
|
|
|
|
|
HttpError(reqwest::Error),
|
2026-04-21 11:50:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl query::Context for QueryContext {}
|
2026-04-21 20:30:41 +01:00
|
|
|
|
|
|
|
|
impl From<reqwest::Error> for Error {
|
|
|
|
|
fn from(value: reqwest::Error) -> Self {
|
|
|
|
|
Self::HttpError(value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl From<serde_json::Error> for Error {
|
|
|
|
|
fn from(value: serde_json::Error) -> Self {
|
|
|
|
|
Self::MalformedResponse(value)
|
|
|
|
|
}
|
|
|
|
|
}
|