1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.sync.subscribeRepos
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8///Represents a change to an account's status on a host (eg, PDS or Relay). The semantics of this event are that the status is at the host which emitted the event, not necessarily that at the currently active PDS. Eg, a Relay takedown would emit a takedown with active=false, even if the PDS is still active.
9#[jacquard_derive::lexicon]
10#[derive(
11 serde::Serialize,
12 serde::Deserialize,
13 Debug,
14 Clone,
15 PartialEq,
16 Eq,
17 jacquard_derive::IntoStatic
18)]
19#[serde(rename_all = "camelCase")]
20pub struct Account<'a> {
21 ///Indicates that the account has a repository which can be fetched from the host that emitted this event.
22 pub active: bool,
23 #[serde(borrow)]
24 pub did: jacquard_common::types::string::Did<'a>,
25 pub seq: i64,
26 ///If active=false, this optional field indicates a reason for why the account is not active.
27 #[serde(skip_serializing_if = "std::option::Option::is_none")]
28 #[serde(borrow)]
29 pub status: std::option::Option<jacquard_common::CowStr<'a>>,
30 pub time: jacquard_common::types::string::Datetime,
31}
32
33///Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature.
34#[jacquard_derive::lexicon]
35#[derive(
36 serde::Serialize,
37 serde::Deserialize,
38 Debug,
39 Clone,
40 PartialEq,
41 Eq,
42 jacquard_derive::IntoStatic
43)]
44#[serde(rename_all = "camelCase")]
45pub struct Commit<'a> {
46 #[serde(borrow)]
47 pub blobs: Vec<jacquard_common::types::cid::CidLink<'a>>,
48 ///CAR file containing relevant blocks, as a diff since the previous repo state. The commit must be included as a block, and the commit block CID must be the first entry in the CAR header 'roots' list.
49 pub blocks: bytes::Bytes,
50 ///Repo commit object CID.
51 #[serde(borrow)]
52 pub commit: jacquard_common::types::cid::CidLink<'a>,
53 #[serde(borrow)]
54 pub ops: Vec<crate::com_atproto::sync::subscribe_repos::RepoOp<'a>>,
55 ///The root CID of the MST tree for the previous commit from this repo (indicated by the 'since' revision field in this message). Corresponds to the 'data' field in the repo commit object. NOTE: this field is effectively required for the 'inductive' version of firehose.
56 #[serde(skip_serializing_if = "std::option::Option::is_none")]
57 #[serde(borrow)]
58 pub prev_data: std::option::Option<jacquard_common::types::cid::CidLink<'a>>,
59 ///DEPRECATED -- unused
60 pub rebase: bool,
61 ///The repo this event comes from. Note that all other message types name this field 'did'.
62 #[serde(borrow)]
63 pub repo: jacquard_common::types::string::Did<'a>,
64 ///The rev of the emitted commit. Note that this information is also in the commit object included in blocks, unless this is a tooBig event.
65 pub rev: jacquard_common::types::string::Tid,
66 ///The stream sequence number of this message.
67 pub seq: i64,
68 ///The rev of the last emitted commit from this repo (if any).
69 pub since: jacquard_common::types::string::Tid,
70 ///Timestamp of when this message was originally broadcast.
71 pub time: jacquard_common::types::string::Datetime,
72 ///DEPRECATED -- replaced by #sync event and data limits. Indicates that this commit contained too many ops, or data size was too large. Consumers will need to make a separate request to get missing data.
73 pub too_big: bool,
74}
75
76///Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache.
77#[jacquard_derive::lexicon]
78#[derive(
79 serde::Serialize,
80 serde::Deserialize,
81 Debug,
82 Clone,
83 PartialEq,
84 Eq,
85 jacquard_derive::IntoStatic
86)]
87#[serde(rename_all = "camelCase")]
88pub struct Identity<'a> {
89 #[serde(borrow)]
90 pub did: jacquard_common::types::string::Did<'a>,
91 ///The current handle for the account, or 'handle.invalid' if validation fails. This field is optional, might have been validated or passed-through from an upstream source. Semantics and behaviors for PDS vs Relay may evolve in the future; see atproto specs for more details.
92 #[serde(skip_serializing_if = "std::option::Option::is_none")]
93 #[serde(borrow)]
94 pub handle: std::option::Option<jacquard_common::types::string::Handle<'a>>,
95 pub seq: i64,
96 pub time: jacquard_common::types::string::Datetime,
97}
98
99#[jacquard_derive::lexicon]
100#[derive(
101 serde::Serialize,
102 serde::Deserialize,
103 Debug,
104 Clone,
105 PartialEq,
106 Eq,
107 jacquard_derive::IntoStatic
108)]
109#[serde(rename_all = "camelCase")]
110pub struct Info<'a> {
111 #[serde(skip_serializing_if = "std::option::Option::is_none")]
112 #[serde(borrow)]
113 pub message: std::option::Option<jacquard_common::CowStr<'a>>,
114 #[serde(borrow)]
115 pub name: jacquard_common::CowStr<'a>,
116}
117
118#[derive(
119 serde::Serialize,
120 serde::Deserialize,
121 Debug,
122 Clone,
123 PartialEq,
124 Eq,
125 bon::Builder,
126 jacquard_derive::IntoStatic
127)]
128#[builder(start_fn = new)]
129#[serde(rename_all = "camelCase")]
130pub struct SubscribeRepos {
131 #[serde(skip_serializing_if = "std::option::Option::is_none")]
132 pub cursor: std::option::Option<i64>,
133}
134
135#[jacquard_derive::open_union]
136#[derive(
137 serde::Serialize,
138 serde::Deserialize,
139 Debug,
140 Clone,
141 PartialEq,
142 Eq,
143 jacquard_derive::IntoStatic
144)]
145#[serde(tag = "$type")]
146#[serde(bound(deserialize = "'de: 'a"))]
147pub enum SubscribeReposMessage<'a> {
148 #[serde(rename = "#commit")]
149 Commit(Box<jacquard_common::types::value::Data<'a>>),
150 #[serde(rename = "#sync")]
151 Sync(Box<jacquard_common::types::value::Data<'a>>),
152 #[serde(rename = "#identity")]
153 Identity(Box<jacquard_common::types::value::Data<'a>>),
154 #[serde(rename = "#account")]
155 Account(Box<jacquard_common::types::value::Data<'a>>),
156 #[serde(rename = "#info")]
157 Info(Box<jacquard_common::types::value::Data<'a>>),
158}
159
160#[jacquard_derive::open_union]
161#[derive(
162 serde::Serialize,
163 serde::Deserialize,
164 Debug,
165 Clone,
166 PartialEq,
167 Eq,
168 thiserror::Error,
169 miette::Diagnostic
170)]
171#[serde(tag = "error", content = "message")]
172#[serde(bound(deserialize = "'de: 'a"))]
173pub enum SubscribeReposError<'a> {
174 #[serde(rename = "FutureCursor")]
175 FutureCursor(std::option::Option<String>),
176 ///If the consumer of the stream can not keep up with events, and a backlog gets too large, the server will drop the connection.
177 #[serde(rename = "ConsumerTooSlow")]
178 ConsumerTooSlow(std::option::Option<String>),
179}
180
181impl std::fmt::Display for SubscribeReposError<'_> {
182 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
183 match self {
184 Self::FutureCursor(msg) => {
185 write!(f, "FutureCursor")?;
186 if let Some(msg) = msg {
187 write!(f, ": {}", msg)?;
188 }
189 Ok(())
190 }
191 Self::ConsumerTooSlow(msg) => {
192 write!(f, "ConsumerTooSlow")?;
193 if let Some(msg) = msg {
194 write!(f, ": {}", msg)?;
195 }
196 Ok(())
197 }
198 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
199 }
200 }
201}
202
203impl jacquard_common::IntoStatic for SubscribeReposError<'_> {
204 type Output = SubscribeReposError<'static>;
205 fn into_static(self) -> Self::Output {
206 match self {
207 SubscribeReposError::FutureCursor(v) => {
208 SubscribeReposError::FutureCursor(v.into_static())
209 }
210 SubscribeReposError::ConsumerTooSlow(v) => {
211 SubscribeReposError::ConsumerTooSlow(v.into_static())
212 }
213 SubscribeReposError::Unknown(v) => {
214 SubscribeReposError::Unknown(v.into_static())
215 }
216 }
217 }
218}
219
220///A repo operation, ie a mutation of a single record.
221#[jacquard_derive::lexicon]
222#[derive(
223 serde::Serialize,
224 serde::Deserialize,
225 Debug,
226 Clone,
227 PartialEq,
228 Eq,
229 jacquard_derive::IntoStatic
230)]
231#[serde(rename_all = "camelCase")]
232pub struct RepoOp<'a> {
233 #[serde(borrow)]
234 pub action: jacquard_common::CowStr<'a>,
235 ///For creates and updates, the new record CID. For deletions, null.
236 #[serde(borrow)]
237 pub cid: jacquard_common::types::cid::CidLink<'a>,
238 #[serde(borrow)]
239 pub path: jacquard_common::CowStr<'a>,
240 ///For updates and deletes, the previous record CID (required for inductive firehose). For creations, field should not be defined.
241 #[serde(skip_serializing_if = "std::option::Option::is_none")]
242 #[serde(borrow)]
243 pub prev: std::option::Option<jacquard_common::types::cid::CidLink<'a>>,
244}
245
246///Updates the repo to a new state, without necessarily including that state on the firehose. Used to recover from broken commit streams, data loss incidents, or in situations where upstream host does not know recent state of the repository.
247#[jacquard_derive::lexicon]
248#[derive(
249 serde::Serialize,
250 serde::Deserialize,
251 Debug,
252 Clone,
253 PartialEq,
254 Eq,
255 jacquard_derive::IntoStatic
256)]
257#[serde(rename_all = "camelCase")]
258pub struct Sync<'a> {
259 ///CAR file containing the commit, as a block. The CAR header must include the commit block CID as the first 'root'.
260 pub blocks: bytes::Bytes,
261 ///The account this repo event corresponds to. Must match that in the commit object.
262 #[serde(borrow)]
263 pub did: jacquard_common::types::string::Did<'a>,
264 ///The rev of the commit. This value must match that in the commit object.
265 #[serde(borrow)]
266 pub rev: jacquard_common::CowStr<'a>,
267 ///The stream sequence number of this message.
268 pub seq: i64,
269 ///Timestamp of when this message was originally broadcast.
270 pub time: jacquard_common::types::string::Datetime,
271}