1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.repo.applyWrites
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// Operation which creates a new record.
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 bon::Builder
19)]
20#[serde(rename_all = "camelCase")]
21pub struct Create<'a> {
22 #[serde(borrow)]
23 pub collection: jacquard_common::types::string::Nsid<'a>,
24 /// NOTE: maxLength is redundant with record-key format. Keeping it temporarily to ensure backwards compatibility.
25 #[serde(skip_serializing_if = "std::option::Option::is_none")]
26 #[builder(into)]
27 #[serde(borrow)]
28 pub rkey: Option<
29 jacquard_common::types::string::RecordKey<
30 jacquard_common::types::string::Rkey<'a>,
31 >,
32 >,
33 #[serde(borrow)]
34 pub value: jacquard_common::types::value::Data<'a>,
35}
36
37#[jacquard_derive::lexicon]
38#[derive(
39 serde::Serialize,
40 serde::Deserialize,
41 Debug,
42 Clone,
43 PartialEq,
44 Eq,
45 jacquard_derive::IntoStatic,
46 bon::Builder
47)]
48#[serde(rename_all = "camelCase")]
49pub struct CreateResult<'a> {
50 #[serde(borrow)]
51 pub cid: jacquard_common::types::string::Cid<'a>,
52 #[serde(borrow)]
53 pub uri: jacquard_common::types::string::AtUri<'a>,
54 #[serde(skip_serializing_if = "std::option::Option::is_none")]
55 #[builder(into)]
56 #[serde(borrow)]
57 pub validation_status: Option<jacquard_common::CowStr<'a>>,
58}
59
60/// Operation which deletes an existing record.
61#[jacquard_derive::lexicon]
62#[derive(
63 serde::Serialize,
64 serde::Deserialize,
65 Debug,
66 Clone,
67 PartialEq,
68 Eq,
69 jacquard_derive::IntoStatic,
70 bon::Builder
71)]
72#[serde(rename_all = "camelCase")]
73pub struct Delete<'a> {
74 #[serde(borrow)]
75 pub collection: jacquard_common::types::string::Nsid<'a>,
76 #[serde(borrow)]
77 pub rkey: jacquard_common::types::string::RecordKey<
78 jacquard_common::types::string::Rkey<'a>,
79 >,
80}
81
82#[jacquard_derive::lexicon]
83#[derive(
84 serde::Serialize,
85 serde::Deserialize,
86 Debug,
87 Clone,
88 PartialEq,
89 Eq,
90 jacquard_derive::IntoStatic,
91 Default
92)]
93#[serde(rename_all = "camelCase")]
94pub struct DeleteResult<'a> {}
95#[jacquard_derive::lexicon]
96#[derive(
97 serde::Serialize,
98 serde::Deserialize,
99 Debug,
100 Clone,
101 PartialEq,
102 Eq,
103 bon::Builder,
104 jacquard_derive::IntoStatic
105)]
106#[serde(rename_all = "camelCase")]
107#[builder(start_fn = new)]
108pub struct ApplyWrites<'a> {
109 /// The handle or DID of the repo (aka, current account).
110 #[serde(borrow)]
111 pub repo: jacquard_common::types::ident::AtIdentifier<'a>,
112 /// If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations.
113 #[serde(skip_serializing_if = "std::option::Option::is_none")]
114 #[builder(into)]
115 #[serde(borrow)]
116 pub swap_commit: Option<jacquard_common::types::string::Cid<'a>>,
117 /// Can be set to 'false' to skip Lexicon schema validation of record data across all operations, 'true' to require it, or leave unset to validate only for known Lexicons.
118 #[serde(skip_serializing_if = "std::option::Option::is_none")]
119 #[builder(into)]
120 pub validate: Option<bool>,
121 #[serde(borrow)]
122 pub writes: Vec<ApplyWritesWritesItem<'a>>,
123 #[serde(flatten)]
124 #[serde(borrow)]
125 #[builder(default)]
126 pub extra_data: ::std::collections::BTreeMap<
127 ::jacquard_common::smol_str::SmolStr,
128 ::jacquard_common::types::value::Data<'a>,
129 >,
130}
131
132#[derive(
133 serde::Serialize,
134 serde::Deserialize,
135 Debug,
136 Clone,
137 PartialEq,
138 Eq,
139 jacquard_derive::IntoStatic
140)]
141#[serde(tag = "$type")]
142#[serde(bound(deserialize = "'de: 'a"))]
143pub enum ApplyWritesWritesItem<'a> {
144 #[serde(rename = "com.atproto.repo.applyWrites#create")]
145 Create(Box<crate::com_atproto::repo::apply_writes::Create<'a>>),
146 #[serde(rename = "com.atproto.repo.applyWrites#update")]
147 Update(Box<crate::com_atproto::repo::apply_writes::Update<'a>>),
148 #[serde(rename = "com.atproto.repo.applyWrites#delete")]
149 Delete(Box<crate::com_atproto::repo::apply_writes::Delete<'a>>),
150}
151
152#[jacquard_derive::lexicon]
153#[derive(
154 serde::Serialize,
155 serde::Deserialize,
156 Debug,
157 Clone,
158 PartialEq,
159 Eq,
160 jacquard_derive::IntoStatic,
161 Default
162)]
163#[serde(rename_all = "camelCase")]
164pub struct ApplyWritesOutput<'a> {
165 #[serde(skip_serializing_if = "std::option::Option::is_none")]
166 #[serde(borrow)]
167 pub commit: std::option::Option<crate::com_atproto::repo::CommitMeta<'a>>,
168 #[serde(skip_serializing_if = "std::option::Option::is_none")]
169 #[serde(borrow)]
170 pub results: std::option::Option<Vec<ApplyWritesOutputResultsItem<'a>>>,
171}
172
173#[derive(
174 serde::Serialize,
175 serde::Deserialize,
176 Debug,
177 Clone,
178 PartialEq,
179 Eq,
180 jacquard_derive::IntoStatic
181)]
182#[serde(tag = "$type")]
183#[serde(bound(deserialize = "'de: 'a"))]
184pub enum ApplyWritesOutputResultsItem<'a> {
185 #[serde(rename = "com.atproto.repo.applyWrites#createResult")]
186 CreateResult(Box<crate::com_atproto::repo::apply_writes::CreateResult<'a>>),
187 #[serde(rename = "com.atproto.repo.applyWrites#updateResult")]
188 UpdateResult(Box<crate::com_atproto::repo::apply_writes::UpdateResult<'a>>),
189 #[serde(rename = "com.atproto.repo.applyWrites#deleteResult")]
190 DeleteResult(Box<crate::com_atproto::repo::apply_writes::DeleteResult<'a>>),
191}
192
193#[jacquard_derive::open_union]
194#[derive(
195 serde::Serialize,
196 serde::Deserialize,
197 Debug,
198 Clone,
199 PartialEq,
200 Eq,
201 thiserror::Error,
202 miette::Diagnostic,
203 jacquard_derive::IntoStatic
204)]
205#[serde(tag = "error", content = "message")]
206#[serde(bound(deserialize = "'de: 'a"))]
207pub enum ApplyWritesError<'a> {
208 /// Indicates that the 'swapCommit' parameter did not match current commit.
209 #[serde(rename = "InvalidSwap")]
210 InvalidSwap(std::option::Option<String>),
211}
212
213impl std::fmt::Display for ApplyWritesError<'_> {
214 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
215 match self {
216 Self::InvalidSwap(msg) => {
217 write!(f, "InvalidSwap")?;
218 if let Some(msg) = msg {
219 write!(f, ": {}", msg)?;
220 }
221 Ok(())
222 }
223 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
224 }
225 }
226}
227
228///Response type for
229///com.atproto.repo.applyWrites
230pub struct ApplyWritesResponse;
231impl jacquard_common::xrpc::XrpcResp for ApplyWritesResponse {
232 const NSID: &'static str = "com.atproto.repo.applyWrites";
233 const ENCODING: &'static str = "application/json";
234 type Output<'de> = ApplyWritesOutput<'de>;
235 type Err<'de> = ApplyWritesError<'de>;
236}
237
238impl<'a> jacquard_common::xrpc::XrpcRequest for ApplyWrites<'a> {
239 const NSID: &'static str = "com.atproto.repo.applyWrites";
240 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
241 "application/json",
242 );
243 type Response = ApplyWritesResponse;
244}
245
246///Endpoint type for
247///com.atproto.repo.applyWrites
248pub struct ApplyWritesRequest;
249impl jacquard_common::xrpc::XrpcEndpoint for ApplyWritesRequest {
250 const PATH: &'static str = "/xrpc/com.atproto.repo.applyWrites";
251 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
252 "application/json",
253 );
254 type Request<'de> = ApplyWrites<'de>;
255 type Response = ApplyWritesResponse;
256}
257
258/// Operation which updates an existing record.
259#[jacquard_derive::lexicon]
260#[derive(
261 serde::Serialize,
262 serde::Deserialize,
263 Debug,
264 Clone,
265 PartialEq,
266 Eq,
267 jacquard_derive::IntoStatic,
268 bon::Builder
269)]
270#[serde(rename_all = "camelCase")]
271pub struct Update<'a> {
272 #[serde(borrow)]
273 pub collection: jacquard_common::types::string::Nsid<'a>,
274 #[serde(borrow)]
275 pub rkey: jacquard_common::types::string::RecordKey<
276 jacquard_common::types::string::Rkey<'a>,
277 >,
278 #[serde(borrow)]
279 pub value: jacquard_common::types::value::Data<'a>,
280}
281
282#[jacquard_derive::lexicon]
283#[derive(
284 serde::Serialize,
285 serde::Deserialize,
286 Debug,
287 Clone,
288 PartialEq,
289 Eq,
290 jacquard_derive::IntoStatic,
291 bon::Builder
292)]
293#[serde(rename_all = "camelCase")]
294pub struct UpdateResult<'a> {
295 #[serde(borrow)]
296 pub cid: jacquard_common::types::string::Cid<'a>,
297 #[serde(borrow)]
298 pub uri: jacquard_common::types::string::AtUri<'a>,
299 #[serde(skip_serializing_if = "std::option::Option::is_none")]
300 #[builder(into)]
301 #[serde(borrow)]
302 pub validation_status: Option<jacquard_common::CowStr<'a>>,
303}