Highly ambitious ATProtocol AppView service and sdks
at main 2.4 kB view raw
1use chrono::{DateTime, Utc}; 2use serde::{Deserialize, Serialize}; 3use serde_json::Value; 4 5pub use crate::database::{SortField, WhereClause, WhereCondition}; 6 7#[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)] 8#[serde(rename_all = "camelCase")] 9pub struct Record { 10 pub uri: String, 11 pub cid: String, 12 pub did: String, 13 pub collection: String, 14 pub json: Value, 15 pub indexed_at: DateTime<Utc>, 16 pub slice_uri: Option<String>, 17} 18 19#[derive(Debug, Clone, Serialize, Deserialize)] 20#[serde(rename_all = "camelCase")] 21pub struct IndexedRecord { 22 pub uri: String, 23 pub cid: String, 24 pub did: String, 25 pub collection: String, 26 pub value: Value, 27 pub indexed_at: String, 28} 29 30#[derive(Debug, Clone, Serialize, Deserialize)] 31#[serde(rename_all = "camelCase")] 32pub struct BulkSyncParams { 33 pub collections: Option<Vec<String>>, 34 pub external_collections: Option<Vec<String>>, 35 pub repos: Option<Vec<String>>, 36 pub limit_per_repo: Option<i32>, 37 pub skip_validation: Option<bool>, 38 pub max_repos: Option<i32>, 39} 40 41#[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)] 42#[serde(rename_all = "camelCase")] 43pub struct Actor { 44 pub did: String, 45 pub handle: Option<String>, 46 pub slice_uri: String, 47 pub indexed_at: String, 48} 49 50#[derive(Debug, Serialize, Deserialize)] 51#[serde(rename_all = "camelCase")] 52pub struct CollectionStats { 53 pub collection: String, 54 pub record_count: i64, 55 pub unique_actors: i64, 56} 57 58#[derive(Debug, Serialize, Deserialize)] 59#[serde(rename_all = "camelCase")] 60pub struct SliceRecordsParams { 61 pub slice: String, 62 pub limit: Option<i32>, 63 pub cursor: Option<String>, 64 #[serde(rename = "where")] 65 pub where_clause: Option<WhereClause>, 66 pub sort_by: Option<Vec<SortField>>, 67} 68 69#[derive(Debug, Serialize, Deserialize)] 70#[serde(rename_all = "camelCase")] 71pub struct SliceRecordsOutput { 72 pub records: Vec<IndexedRecord>, 73 pub cursor: Option<String>, 74} 75 76#[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)] 77#[serde(rename_all = "camelCase")] 78pub struct OAuthClient { 79 pub id: i32, 80 pub slice_uri: String, 81 pub client_id: String, 82 pub registration_access_token: Option<String>, 83 pub created_at: DateTime<Utc>, 84 pub created_by_did: String, 85} 86 87#[derive(Debug, Serialize, Deserialize)] 88#[serde(rename_all = "camelCase")] 89pub struct SparklinePoint { 90 pub timestamp: String, 91 pub count: i64, 92}