#![allow(unused)] use chrono::prelude::*; use ipld_core::cid::Cid; use serde::Deserialize; use serde_bytes::ByteBuf; #[derive(Debug)] pub enum FirehoseOutput { Close, Event(Box), Error(AtpEventStreamError), Continue, } #[derive(Debug, Deserialize)] pub struct AtpEventStreamHeader { pub op: i32, pub t: Option, } #[derive(Debug, Deserialize)] pub struct AtpEventStreamError { pub error: String, pub message: Option, } #[derive(Debug)] pub enum FirehoseEvent { Identity(AtpIdentityEvent), Account(AtpAccountEvent), Commit(AtpCommitEvent), Label(AtpLabelEvent), Sync(AtpSyncEvent), } #[derive(Debug, Deserialize)] pub struct AtpIdentityEvent { pub seq: u64, pub did: String, pub time: DateTime, pub handle: Option, } #[derive(Debug, Deserialize)] #[serde(rename_all = "lowercase")] pub enum AtpAccountStatus { Takendown, Suspended, Deleted, Deactivated, Throttled, Desynchronized, } impl AtpAccountStatus { pub fn as_str(&self) -> &'static str { match self { AtpAccountStatus::Takendown => "takendown", AtpAccountStatus::Suspended => "suspended", AtpAccountStatus::Deleted => "deleted", AtpAccountStatus::Deactivated => "deactivated", AtpAccountStatus::Throttled => "throttled", AtpAccountStatus::Desynchronized => "desynchronized", } } } impl From for parakeet_db::types::ActorStatus { fn from(value: AtpAccountStatus) -> Self { match value { AtpAccountStatus::Takendown => parakeet_db::types::ActorStatus::Takendown, AtpAccountStatus::Suspended => parakeet_db::types::ActorStatus::Suspended, AtpAccountStatus::Deleted => parakeet_db::types::ActorStatus::Deleted, AtpAccountStatus::Deactivated => parakeet_db::types::ActorStatus::Deactivated, AtpAccountStatus::Throttled | AtpAccountStatus::Desynchronized => { parakeet_db::types::ActorStatus::Active } } } } #[derive(Debug, Deserialize)] pub struct AtpAccountEvent { pub seq: u64, pub did: String, pub time: DateTime, pub active: bool, pub status: Option, } #[derive(Debug, Deserialize)] pub struct AtpCommitEvent { pub seq: u64, pub repo: String, pub time: DateTime, pub rev: String, pub since: Option, pub commit: Cid, #[serde(rename = "tooBig")] #[deprecated] pub too_big: bool, #[serde(default)] pub blocks: ByteBuf, #[serde(default)] pub ops: Vec, #[serde(default)] #[deprecated] pub blobs: Vec, #[serde(rename = "prevData")] pub prev_data: Option, } #[derive(Debug, Deserialize)] pub struct CommitOp { pub action: String, pub cid: Option, pub prev: Option, pub path: String, } #[derive(Debug, Deserialize)] pub struct AtpLabel { pub ver: i32, pub src: String, pub uri: String, pub cid: Option, pub val: String, pub neg: Option, pub cts: DateTime, pub exp: Option>, pub sig: Option, } #[derive(Debug, Deserialize)] pub struct AtpLabelEvent { pub seq: u64, pub labels: Vec, } #[derive(Debug, Deserialize)] pub struct AtpSyncEvent { pub seq: u64, pub did: String, pub time: DateTime, pub rev: String, #[serde(default)] pub blocks: ByteBuf, }