pub mod confluence;
pub mod jira;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct SourceDocument {
pub id: String,
pub partition_key: String,
pub fields: HashMap<String, serde_json::Value>,
pub updated_at: DateTime<Utc>,
pub source_link: String,
}
pub struct FetchPage {
pub documents: Vec<SourceDocument>,
pub next_page_token: Option<String>,
pub last_seen: Option<BackfillCheckpoint>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct BackfillCheckpoint {
pub updated: DateTime<Utc>,
pub key: String,
}
#[derive(Default)]
pub struct Companions {
pub sprints: Vec<SourceDocument>,
pub fix_versions: Vec<SourceDocument>,
pub projects: Vec<SourceDocument>,
pub spaces: Vec<SourceDocument>,
}
#[trait_variant::make(Send)]
pub trait SourceConnector: Sync {
fn source_type(&self) -> &str;
fn source_name(&self) -> &str;
fn subsources(&self) -> &[String];
fn primary_container(&self) -> &str;
async fn fetch_window(
&self,
subsource: &str,
window_start: DateTime<Utc>,
window_end: DateTime<Utc>,
batch_size: usize,
page_token: Option<&str>,
) -> anyhow::Result<FetchPage>;
async fn fetch_backfill_page(
&self,
subsource: &str,
backfill_target: DateTime<Utc>,
last_seen: Option<&BackfillCheckpoint>,
batch_size: usize,
) -> anyhow::Result<FetchPage>;
async fn list_all_ids(&self, subsource: &str) -> anyhow::Result<Vec<String>>;
async fn fetch_companions(&self, _subsource: &str) -> anyhow::Result<Companions>;
}