1pub mod dismiss_match;
9pub mod get_matches;
10pub mod get_sync_status;
11pub mod import_contacts;
12pub mod remove_data;
13pub mod send_notification;
14pub mod start_phone_verification;
15pub mod verify_phone;
16
17
18#[allow(unused_imports)]
19use alloc::collections::BTreeMap;
20
21#[allow(unused_imports)]
22use core::marker::PhantomData;
23
24#[allow(unused_imports)]
25use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
26use jacquard_common::types::string::{Did, Datetime};
27use jacquard_derive::{IntoStatic, lexicon};
28use jacquard_lexicon::lexicon::LexiconDoc;
29use jacquard_lexicon::schema::LexiconSchema;
30
31#[allow(unused_imports)]
32use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
33use serde::{Serialize, Deserialize};
34use crate::app_bsky::actor::ProfileView;
35#[lexicon]
38#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
39#[serde(rename_all = "camelCase")]
40pub struct MatchAndContactIndex<'a> {
41 pub contact_index: i64,
43 #[serde(borrow)]
45 pub r#match: ProfileView<'a>,
46}
47
48#[lexicon]
51#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
52#[serde(rename_all = "camelCase")]
53pub struct Notification<'a> {
54 #[serde(borrow)]
56 pub from: Did<'a>,
57 #[serde(borrow)]
59 pub to: Did<'a>,
60}
61
62
63#[lexicon]
64#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
65#[serde(rename_all = "camelCase")]
66pub struct SyncStatus<'a> {
67 pub matches_count: i64,
69 pub synced_at: Datetime,
71}
72
73impl<'a> LexiconSchema for MatchAndContactIndex<'a> {
74 fn nsid() -> &'static str {
75 "app.bsky.contact.defs"
76 }
77 fn def_name() -> &'static str {
78 "matchAndContactIndex"
79 }
80 fn lexicon_doc() -> LexiconDoc<'static> {
81 lexicon_doc_app_bsky_contact_defs()
82 }
83 fn validate(&self) -> Result<(), ConstraintError> {
84 {
85 let value = &self.contact_index;
86 if *value > 999i64 {
87 return Err(ConstraintError::Maximum {
88 path: ValidationPath::from_field("contact_index"),
89 max: 999i64,
90 actual: *value,
91 });
92 }
93 }
94 {
95 let value = &self.contact_index;
96 if *value < 0i64 {
97 return Err(ConstraintError::Minimum {
98 path: ValidationPath::from_field("contact_index"),
99 min: 0i64,
100 actual: *value,
101 });
102 }
103 }
104 Ok(())
105 }
106}
107
108impl<'a> LexiconSchema for Notification<'a> {
109 fn nsid() -> &'static str {
110 "app.bsky.contact.defs"
111 }
112 fn def_name() -> &'static str {
113 "notification"
114 }
115 fn lexicon_doc() -> LexiconDoc<'static> {
116 lexicon_doc_app_bsky_contact_defs()
117 }
118 fn validate(&self) -> Result<(), ConstraintError> {
119 Ok(())
120 }
121}
122
123impl<'a> LexiconSchema for SyncStatus<'a> {
124 fn nsid() -> &'static str {
125 "app.bsky.contact.defs"
126 }
127 fn def_name() -> &'static str {
128 "syncStatus"
129 }
130 fn lexicon_doc() -> LexiconDoc<'static> {
131 lexicon_doc_app_bsky_contact_defs()
132 }
133 fn validate(&self) -> Result<(), ConstraintError> {
134 {
135 let value = &self.matches_count;
136 if *value < 0i64 {
137 return Err(ConstraintError::Minimum {
138 path: ValidationPath::from_field("matches_count"),
139 min: 0i64,
140 actual: *value,
141 });
142 }
143 }
144 Ok(())
145 }
146}
147
148pub mod match_and_contact_index_state {
149
150 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
151 #[allow(unused)]
152 use ::core::marker::PhantomData;
153 mod sealed {
154 pub trait Sealed {}
155 }
156 pub trait State: sealed::Sealed {
158 type Match;
159 type ContactIndex;
160 }
161 pub struct Empty(());
163 impl sealed::Sealed for Empty {}
164 impl State for Empty {
165 type Match = Unset;
166 type ContactIndex = Unset;
167 }
168 pub struct SetMatch<S: State = Empty>(PhantomData<fn() -> S>);
170 impl<S: State> sealed::Sealed for SetMatch<S> {}
171 impl<S: State> State for SetMatch<S> {
172 type Match = Set<members::r#match>;
173 type ContactIndex = S::ContactIndex;
174 }
175 pub struct SetContactIndex<S: State = Empty>(PhantomData<fn() -> S>);
177 impl<S: State> sealed::Sealed for SetContactIndex<S> {}
178 impl<S: State> State for SetContactIndex<S> {
179 type Match = S::Match;
180 type ContactIndex = Set<members::contact_index>;
181 }
182 #[allow(non_camel_case_types)]
184 pub mod members {
185 pub struct r#match(());
187 pub struct contact_index(());
189 }
190}
191
192pub struct MatchAndContactIndexBuilder<'a, S: match_and_contact_index_state::State> {
194 _state: PhantomData<fn() -> S>,
195 _fields: (Option<i64>, Option<ProfileView<'a>>),
196 _lifetime: PhantomData<&'a ()>,
197}
198
199impl<'a> MatchAndContactIndex<'a> {
200 pub fn new() -> MatchAndContactIndexBuilder<
202 'a,
203 match_and_contact_index_state::Empty,
204 > {
205 MatchAndContactIndexBuilder::new()
206 }
207}
208
209impl<'a> MatchAndContactIndexBuilder<'a, match_and_contact_index_state::Empty> {
210 pub fn new() -> Self {
212 MatchAndContactIndexBuilder {
213 _state: PhantomData,
214 _fields: (None, None),
215 _lifetime: PhantomData,
216 }
217 }
218}
219
220impl<'a, S> MatchAndContactIndexBuilder<'a, S>
221where
222 S: match_and_contact_index_state::State,
223 S::ContactIndex: match_and_contact_index_state::IsUnset,
224{
225 pub fn contact_index(
227 mut self,
228 value: impl Into<i64>,
229 ) -> MatchAndContactIndexBuilder<
230 'a,
231 match_and_contact_index_state::SetContactIndex<S>,
232 > {
233 self._fields.0 = Option::Some(value.into());
234 MatchAndContactIndexBuilder {
235 _state: PhantomData,
236 _fields: self._fields,
237 _lifetime: PhantomData,
238 }
239 }
240}
241
242impl<'a, S> MatchAndContactIndexBuilder<'a, S>
243where
244 S: match_and_contact_index_state::State,
245 S::Match: match_and_contact_index_state::IsUnset,
246{
247 pub fn r#match(
249 mut self,
250 value: impl Into<ProfileView<'a>>,
251 ) -> MatchAndContactIndexBuilder<'a, match_and_contact_index_state::SetMatch<S>> {
252 self._fields.1 = Option::Some(value.into());
253 MatchAndContactIndexBuilder {
254 _state: PhantomData,
255 _fields: self._fields,
256 _lifetime: PhantomData,
257 }
258 }
259}
260
261impl<'a, S> MatchAndContactIndexBuilder<'a, S>
262where
263 S: match_and_contact_index_state::State,
264 S::Match: match_and_contact_index_state::IsSet,
265 S::ContactIndex: match_and_contact_index_state::IsSet,
266{
267 pub fn build(self) -> MatchAndContactIndex<'a> {
269 MatchAndContactIndex {
270 contact_index: self._fields.0.unwrap(),
271 r#match: self._fields.1.unwrap(),
272 extra_data: Default::default(),
273 }
274 }
275 pub fn build_with_data(
277 self,
278 extra_data: BTreeMap<
279 jacquard_common::deps::smol_str::SmolStr,
280 jacquard_common::types::value::Data<'a>,
281 >,
282 ) -> MatchAndContactIndex<'a> {
283 MatchAndContactIndex {
284 contact_index: self._fields.0.unwrap(),
285 r#match: self._fields.1.unwrap(),
286 extra_data: Some(extra_data),
287 }
288 }
289}
290
291fn lexicon_doc_app_bsky_contact_defs() -> LexiconDoc<'static> {
292 #[allow(unused_imports)]
293 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
294 use jacquard_lexicon::lexicon::*;
295 use alloc::collections::BTreeMap;
296 LexiconDoc {
297 lexicon: Lexicon::Lexicon1,
298 id: CowStr::new_static("app.bsky.contact.defs"),
299 defs: {
300 let mut map = BTreeMap::new();
301 map.insert(
302 SmolStr::new_static("matchAndContactIndex"),
303 LexUserType::Object(LexObject {
304 description: Some(
305 CowStr::new_static(
306 "Associates a profile with the positional index of the contact import input in the call to `app.bsky.contact.importContacts`, so clients can know which phone caused a particular match.",
307 ),
308 ),
309 required: Some(
310 vec![
311 SmolStr::new_static("match"),
312 SmolStr::new_static("contactIndex")
313 ],
314 ),
315 properties: {
316 #[allow(unused_mut)]
317 let mut map = BTreeMap::new();
318 map.insert(
319 SmolStr::new_static("contactIndex"),
320 LexObjectProperty::Integer(LexInteger {
321 minimum: Some(0i64),
322 maximum: Some(999i64),
323 ..Default::default()
324 }),
325 );
326 map.insert(
327 SmolStr::new_static("match"),
328 LexObjectProperty::Ref(LexRef {
329 r#ref: CowStr::new_static(
330 "app.bsky.actor.defs#profileView",
331 ),
332 ..Default::default()
333 }),
334 );
335 map
336 },
337 ..Default::default()
338 }),
339 );
340 map.insert(
341 SmolStr::new_static("notification"),
342 LexUserType::Object(LexObject {
343 description: Some(
344 CowStr::new_static(
345 "A stash object to be sent via bsync representing a notification to be created.",
346 ),
347 ),
348 required: Some(
349 vec![SmolStr::new_static("from"), SmolStr::new_static("to")],
350 ),
351 properties: {
352 #[allow(unused_mut)]
353 let mut map = BTreeMap::new();
354 map.insert(
355 SmolStr::new_static("from"),
356 LexObjectProperty::String(LexString {
357 description: Some(
358 CowStr::new_static(
359 "The DID of who this notification comes from.",
360 ),
361 ),
362 format: Some(LexStringFormat::Did),
363 ..Default::default()
364 }),
365 );
366 map.insert(
367 SmolStr::new_static("to"),
368 LexObjectProperty::String(LexString {
369 description: Some(
370 CowStr::new_static(
371 "The DID of who this notification should go to.",
372 ),
373 ),
374 format: Some(LexStringFormat::Did),
375 ..Default::default()
376 }),
377 );
378 map
379 },
380 ..Default::default()
381 }),
382 );
383 map.insert(
384 SmolStr::new_static("syncStatus"),
385 LexUserType::Object(LexObject {
386 required: Some(
387 vec![
388 SmolStr::new_static("syncedAt"),
389 SmolStr::new_static("matchesCount")
390 ],
391 ),
392 properties: {
393 #[allow(unused_mut)]
394 let mut map = BTreeMap::new();
395 map.insert(
396 SmolStr::new_static("matchesCount"),
397 LexObjectProperty::Integer(LexInteger {
398 minimum: Some(0i64),
399 ..Default::default()
400 }),
401 );
402 map.insert(
403 SmolStr::new_static("syncedAt"),
404 LexObjectProperty::String(LexString {
405 description: Some(
406 CowStr::new_static(
407 "Last date when contacts where imported.",
408 ),
409 ),
410 format: Some(LexStringFormat::Datetime),
411 ..Default::default()
412 }),
413 );
414 map
415 },
416 ..Default::default()
417 }),
418 );
419 map
420 },
421 ..Default::default()
422 }
423}
424
425pub mod notification_state {
426
427 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
428 #[allow(unused)]
429 use ::core::marker::PhantomData;
430 mod sealed {
431 pub trait Sealed {}
432 }
433 pub trait State: sealed::Sealed {
435 type From;
436 type To;
437 }
438 pub struct Empty(());
440 impl sealed::Sealed for Empty {}
441 impl State for Empty {
442 type From = Unset;
443 type To = Unset;
444 }
445 pub struct SetFrom<S: State = Empty>(PhantomData<fn() -> S>);
447 impl<S: State> sealed::Sealed for SetFrom<S> {}
448 impl<S: State> State for SetFrom<S> {
449 type From = Set<members::from>;
450 type To = S::To;
451 }
452 pub struct SetTo<S: State = Empty>(PhantomData<fn() -> S>);
454 impl<S: State> sealed::Sealed for SetTo<S> {}
455 impl<S: State> State for SetTo<S> {
456 type From = S::From;
457 type To = Set<members::to>;
458 }
459 #[allow(non_camel_case_types)]
461 pub mod members {
462 pub struct from(());
464 pub struct to(());
466 }
467}
468
469pub struct NotificationBuilder<'a, S: notification_state::State> {
471 _state: PhantomData<fn() -> S>,
472 _fields: (Option<Did<'a>>, Option<Did<'a>>),
473 _lifetime: PhantomData<&'a ()>,
474}
475
476impl<'a> Notification<'a> {
477 pub fn new() -> NotificationBuilder<'a, notification_state::Empty> {
479 NotificationBuilder::new()
480 }
481}
482
483impl<'a> NotificationBuilder<'a, notification_state::Empty> {
484 pub fn new() -> Self {
486 NotificationBuilder {
487 _state: PhantomData,
488 _fields: (None, None),
489 _lifetime: PhantomData,
490 }
491 }
492}
493
494impl<'a, S> NotificationBuilder<'a, S>
495where
496 S: notification_state::State,
497 S::From: notification_state::IsUnset,
498{
499 pub fn from(
501 mut self,
502 value: impl Into<Did<'a>>,
503 ) -> NotificationBuilder<'a, notification_state::SetFrom<S>> {
504 self._fields.0 = Option::Some(value.into());
505 NotificationBuilder {
506 _state: PhantomData,
507 _fields: self._fields,
508 _lifetime: PhantomData,
509 }
510 }
511}
512
513impl<'a, S> NotificationBuilder<'a, S>
514where
515 S: notification_state::State,
516 S::To: notification_state::IsUnset,
517{
518 pub fn to(
520 mut self,
521 value: impl Into<Did<'a>>,
522 ) -> NotificationBuilder<'a, notification_state::SetTo<S>> {
523 self._fields.1 = Option::Some(value.into());
524 NotificationBuilder {
525 _state: PhantomData,
526 _fields: self._fields,
527 _lifetime: PhantomData,
528 }
529 }
530}
531
532impl<'a, S> NotificationBuilder<'a, S>
533where
534 S: notification_state::State,
535 S::From: notification_state::IsSet,
536 S::To: notification_state::IsSet,
537{
538 pub fn build(self) -> Notification<'a> {
540 Notification {
541 from: self._fields.0.unwrap(),
542 to: self._fields.1.unwrap(),
543 extra_data: Default::default(),
544 }
545 }
546 pub fn build_with_data(
548 self,
549 extra_data: BTreeMap<
550 jacquard_common::deps::smol_str::SmolStr,
551 jacquard_common::types::value::Data<'a>,
552 >,
553 ) -> Notification<'a> {
554 Notification {
555 from: self._fields.0.unwrap(),
556 to: self._fields.1.unwrap(),
557 extra_data: Some(extra_data),
558 }
559 }
560}
561
562pub mod sync_status_state {
563
564 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
565 #[allow(unused)]
566 use ::core::marker::PhantomData;
567 mod sealed {
568 pub trait Sealed {}
569 }
570 pub trait State: sealed::Sealed {
572 type MatchesCount;
573 type SyncedAt;
574 }
575 pub struct Empty(());
577 impl sealed::Sealed for Empty {}
578 impl State for Empty {
579 type MatchesCount = Unset;
580 type SyncedAt = Unset;
581 }
582 pub struct SetMatchesCount<S: State = Empty>(PhantomData<fn() -> S>);
584 impl<S: State> sealed::Sealed for SetMatchesCount<S> {}
585 impl<S: State> State for SetMatchesCount<S> {
586 type MatchesCount = Set<members::matches_count>;
587 type SyncedAt = S::SyncedAt;
588 }
589 pub struct SetSyncedAt<S: State = Empty>(PhantomData<fn() -> S>);
591 impl<S: State> sealed::Sealed for SetSyncedAt<S> {}
592 impl<S: State> State for SetSyncedAt<S> {
593 type MatchesCount = S::MatchesCount;
594 type SyncedAt = Set<members::synced_at>;
595 }
596 #[allow(non_camel_case_types)]
598 pub mod members {
599 pub struct matches_count(());
601 pub struct synced_at(());
603 }
604}
605
606pub struct SyncStatusBuilder<'a, S: sync_status_state::State> {
608 _state: PhantomData<fn() -> S>,
609 _fields: (Option<i64>, Option<Datetime>),
610 _lifetime: PhantomData<&'a ()>,
611}
612
613impl<'a> SyncStatus<'a> {
614 pub fn new() -> SyncStatusBuilder<'a, sync_status_state::Empty> {
616 SyncStatusBuilder::new()
617 }
618}
619
620impl<'a> SyncStatusBuilder<'a, sync_status_state::Empty> {
621 pub fn new() -> Self {
623 SyncStatusBuilder {
624 _state: PhantomData,
625 _fields: (None, None),
626 _lifetime: PhantomData,
627 }
628 }
629}
630
631impl<'a, S> SyncStatusBuilder<'a, S>
632where
633 S: sync_status_state::State,
634 S::MatchesCount: sync_status_state::IsUnset,
635{
636 pub fn matches_count(
638 mut self,
639 value: impl Into<i64>,
640 ) -> SyncStatusBuilder<'a, sync_status_state::SetMatchesCount<S>> {
641 self._fields.0 = Option::Some(value.into());
642 SyncStatusBuilder {
643 _state: PhantomData,
644 _fields: self._fields,
645 _lifetime: PhantomData,
646 }
647 }
648}
649
650impl<'a, S> SyncStatusBuilder<'a, S>
651where
652 S: sync_status_state::State,
653 S::SyncedAt: sync_status_state::IsUnset,
654{
655 pub fn synced_at(
657 mut self,
658 value: impl Into<Datetime>,
659 ) -> SyncStatusBuilder<'a, sync_status_state::SetSyncedAt<S>> {
660 self._fields.1 = Option::Some(value.into());
661 SyncStatusBuilder {
662 _state: PhantomData,
663 _fields: self._fields,
664 _lifetime: PhantomData,
665 }
666 }
667}
668
669impl<'a, S> SyncStatusBuilder<'a, S>
670where
671 S: sync_status_state::State,
672 S::MatchesCount: sync_status_state::IsSet,
673 S::SyncedAt: sync_status_state::IsSet,
674{
675 pub fn build(self) -> SyncStatus<'a> {
677 SyncStatus {
678 matches_count: self._fields.0.unwrap(),
679 synced_at: self._fields.1.unwrap(),
680 extra_data: Default::default(),
681 }
682 }
683 pub fn build_with_data(
685 self,
686 extra_data: BTreeMap<
687 jacquard_common::deps::smol_str::SmolStr,
688 jacquard_common::types::value::Data<'a>,
689 >,
690 ) -> SyncStatus<'a> {
691 SyncStatus {
692 matches_count: self._fields.0.unwrap(),
693 synced_at: self._fields.1.unwrap(),
694 extra_data: Some(extra_data),
695 }
696 }
697}