1pub mod get_subscription_updates;
9pub mod get_unread_count;
10pub mod list_notifications;
11pub mod update_seen;
12
13
14#[allow(unused_imports)]
15use alloc::collections::BTreeMap;
16
17#[allow(unused_imports)]
18use core::marker::PhantomData;
19use jacquard_common::CowStr;
20
21#[allow(unused_imports)]
22use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
23use jacquard_common::types::string::{AtUri, Cid, Datetime};
24use jacquard_common::types::value::Data;
25use jacquard_derive::{IntoStatic, lexicon, open_union};
26use jacquard_lexicon::lexicon::LexiconDoc;
27use jacquard_lexicon::schema::LexiconSchema;
28
29#[allow(unused_imports)]
30use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
31use serde::{Serialize, Deserialize};
32use crate::sh_weaver::actor::ProfileViewBasic;
33use crate::sh_weaver::notebook::EntryView;
34use crate::sh_weaver::notebook::NotebookView;
35use crate::sh_weaver::notification;
36#[lexicon]
39#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
40#[serde(rename_all = "camelCase")]
41pub struct Notification<'a> {
42 #[serde(borrow)]
43 pub author: ProfileViewBasic<'a>,
44 #[serde(borrow)]
45 pub cid: Cid<'a>,
46 pub indexed_at: Datetime,
47 pub is_read: bool,
48 #[serde(borrow)]
49 pub reason: notification::NotificationReason<'a>,
50 #[serde(skip_serializing_if = "Option::is_none")]
52 #[serde(borrow)]
53 pub reason_subject: Option<AtUri<'a>>,
54 #[serde(skip_serializing_if = "Option::is_none")]
55 #[serde(borrow)]
56 pub record: Option<Data<'a>>,
57 #[serde(borrow)]
58 pub uri: AtUri<'a>,
59}
60
61#[lexicon]
64#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
65#[serde(rename_all = "camelCase")]
66pub struct NotificationGroup<'a> {
67 #[serde(borrow)]
69 pub actors: Vec<ProfileViewBasic<'a>>,
70 pub count: i64,
71 #[serde(skip_serializing_if = "Option::is_none")]
72 pub is_read: Option<bool>,
73 pub most_recent_at: Datetime,
74 #[serde(borrow)]
75 pub reason: notification::NotificationReason<'a>,
76 #[serde(borrow)]
77 pub subject: NotificationGroupSubject<'a>,
78}
79
80
81#[open_union]
82#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
83#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
84pub enum NotificationGroupSubject<'a> {
85 #[serde(rename = "sh.weaver.notebook.defs#notebookView")]
86 NotebookView(Box<NotebookView<'a>>),
87 #[serde(rename = "sh.weaver.notebook.defs#entryView")]
88 EntryView(Box<EntryView<'a>>),
89}
90
91#[derive(Debug, Clone, PartialEq, Eq, Hash)]
94pub enum NotificationReason<'a> {
95 Like,
96 Bookmark,
97 Follow,
98 FollowAccept,
99 Subscribe,
100 SubscribeAccept,
101 CollaborationInvite,
102 CollaborationAccept,
103 NewEntry,
104 EntryUpdate,
105 Mention,
106 Tag,
107 Comment,
108 Other(CowStr<'a>),
109}
110
111impl<'a> NotificationReason<'a> {
112 pub fn as_str(&self) -> &str {
113 match self {
114 Self::Like => "like",
115 Self::Bookmark => "bookmark",
116 Self::Follow => "follow",
117 Self::FollowAccept => "followAccept",
118 Self::Subscribe => "subscribe",
119 Self::SubscribeAccept => "subscribeAccept",
120 Self::CollaborationInvite => "collaborationInvite",
121 Self::CollaborationAccept => "collaborationAccept",
122 Self::NewEntry => "newEntry",
123 Self::EntryUpdate => "entryUpdate",
124 Self::Mention => "mention",
125 Self::Tag => "tag",
126 Self::Comment => "comment",
127 Self::Other(s) => s.as_ref(),
128 }
129 }
130}
131
132impl<'a> From<&'a str> for NotificationReason<'a> {
133 fn from(s: &'a str) -> Self {
134 match s {
135 "like" => Self::Like,
136 "bookmark" => Self::Bookmark,
137 "follow" => Self::Follow,
138 "followAccept" => Self::FollowAccept,
139 "subscribe" => Self::Subscribe,
140 "subscribeAccept" => Self::SubscribeAccept,
141 "collaborationInvite" => Self::CollaborationInvite,
142 "collaborationAccept" => Self::CollaborationAccept,
143 "newEntry" => Self::NewEntry,
144 "entryUpdate" => Self::EntryUpdate,
145 "mention" => Self::Mention,
146 "tag" => Self::Tag,
147 "comment" => Self::Comment,
148 _ => Self::Other(CowStr::from(s)),
149 }
150 }
151}
152
153impl<'a> From<String> for NotificationReason<'a> {
154 fn from(s: String) -> Self {
155 match s.as_str() {
156 "like" => Self::Like,
157 "bookmark" => Self::Bookmark,
158 "follow" => Self::Follow,
159 "followAccept" => Self::FollowAccept,
160 "subscribe" => Self::Subscribe,
161 "subscribeAccept" => Self::SubscribeAccept,
162 "collaborationInvite" => Self::CollaborationInvite,
163 "collaborationAccept" => Self::CollaborationAccept,
164 "newEntry" => Self::NewEntry,
165 "entryUpdate" => Self::EntryUpdate,
166 "mention" => Self::Mention,
167 "tag" => Self::Tag,
168 "comment" => Self::Comment,
169 _ => Self::Other(CowStr::from(s)),
170 }
171 }
172}
173
174impl<'a> AsRef<str> for NotificationReason<'a> {
175 fn as_ref(&self) -> &str {
176 self.as_str()
177 }
178}
179
180impl<'a> core::fmt::Display for NotificationReason<'a> {
181 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
182 write!(f, "{}", self.as_str())
183 }
184}
185
186impl<'a> serde::Serialize for NotificationReason<'a> {
187 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
188 where
189 S: serde::Serializer,
190 {
191 serializer.serialize_str(self.as_str())
192 }
193}
194
195impl<'de, 'a> serde::Deserialize<'de> for NotificationReason<'a>
196where
197 'de: 'a,
198{
199 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
200 where
201 D: serde::Deserializer<'de>,
202 {
203 let s = <&'de str>::deserialize(deserializer)?;
204 Ok(Self::from(s))
205 }
206}
207
208impl jacquard_common::IntoStatic for NotificationReason<'_> {
209 type Output = NotificationReason<'static>;
210 fn into_static(self) -> Self::Output {
211 match self {
212 NotificationReason::Like => NotificationReason::Like,
213 NotificationReason::Bookmark => NotificationReason::Bookmark,
214 NotificationReason::Follow => NotificationReason::Follow,
215 NotificationReason::FollowAccept => NotificationReason::FollowAccept,
216 NotificationReason::Subscribe => NotificationReason::Subscribe,
217 NotificationReason::SubscribeAccept => NotificationReason::SubscribeAccept,
218 NotificationReason::CollaborationInvite => {
219 NotificationReason::CollaborationInvite
220 }
221 NotificationReason::CollaborationAccept => {
222 NotificationReason::CollaborationAccept
223 }
224 NotificationReason::NewEntry => NotificationReason::NewEntry,
225 NotificationReason::EntryUpdate => NotificationReason::EntryUpdate,
226 NotificationReason::Mention => NotificationReason::Mention,
227 NotificationReason::Tag => NotificationReason::Tag,
228 NotificationReason::Comment => NotificationReason::Comment,
229 NotificationReason::Other(v) => NotificationReason::Other(v.into_static()),
230 }
231 }
232}
233
234#[lexicon]
237#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
238#[serde(rename_all = "camelCase")]
239pub struct SubscriptionUpdateView<'a> {
240 #[serde(borrow)]
242 pub new_entries: Vec<EntryView<'a>>,
243 #[serde(borrow)]
244 pub notebook: NotebookView<'a>,
245 pub updated_at: Datetime,
246 #[serde(skip_serializing_if = "Option::is_none")]
248 #[serde(borrow)]
249 pub updated_entries: Option<Vec<EntryView<'a>>>,
250}
251
252impl<'a> LexiconSchema for Notification<'a> {
253 fn nsid() -> &'static str {
254 "sh.weaver.notification.defs"
255 }
256 fn def_name() -> &'static str {
257 "notification"
258 }
259 fn lexicon_doc() -> LexiconDoc<'static> {
260 lexicon_doc_sh_weaver_notification_defs()
261 }
262 fn validate(&self) -> Result<(), ConstraintError> {
263 Ok(())
264 }
265}
266
267impl<'a> LexiconSchema for NotificationGroup<'a> {
268 fn nsid() -> &'static str {
269 "sh.weaver.notification.defs"
270 }
271 fn def_name() -> &'static str {
272 "notificationGroup"
273 }
274 fn lexicon_doc() -> LexiconDoc<'static> {
275 lexicon_doc_sh_weaver_notification_defs()
276 }
277 fn validate(&self) -> Result<(), ConstraintError> {
278 {
279 let value = &self.actors;
280 #[allow(unused_comparisons)]
281 if value.len() > 5usize {
282 return Err(ConstraintError::MaxLength {
283 path: ValidationPath::from_field("actors"),
284 max: 5usize,
285 actual: value.len(),
286 });
287 }
288 }
289 Ok(())
290 }
291}
292
293impl<'a> LexiconSchema for SubscriptionUpdateView<'a> {
294 fn nsid() -> &'static str {
295 "sh.weaver.notification.defs"
296 }
297 fn def_name() -> &'static str {
298 "subscriptionUpdateView"
299 }
300 fn lexicon_doc() -> LexiconDoc<'static> {
301 lexicon_doc_sh_weaver_notification_defs()
302 }
303 fn validate(&self) -> Result<(), ConstraintError> {
304 Ok(())
305 }
306}
307
308pub mod notification_state {
309
310 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
311 #[allow(unused)]
312 use ::core::marker::PhantomData;
313 mod sealed {
314 pub trait Sealed {}
315 }
316 pub trait State: sealed::Sealed {
318 type Uri;
319 type IsRead;
320 type Cid;
321 type Author;
322 type Reason;
323 type IndexedAt;
324 }
325 pub struct Empty(());
327 impl sealed::Sealed for Empty {}
328 impl State for Empty {
329 type Uri = Unset;
330 type IsRead = Unset;
331 type Cid = Unset;
332 type Author = Unset;
333 type Reason = Unset;
334 type IndexedAt = Unset;
335 }
336 pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
338 impl<S: State> sealed::Sealed for SetUri<S> {}
339 impl<S: State> State for SetUri<S> {
340 type Uri = Set<members::uri>;
341 type IsRead = S::IsRead;
342 type Cid = S::Cid;
343 type Author = S::Author;
344 type Reason = S::Reason;
345 type IndexedAt = S::IndexedAt;
346 }
347 pub struct SetIsRead<S: State = Empty>(PhantomData<fn() -> S>);
349 impl<S: State> sealed::Sealed for SetIsRead<S> {}
350 impl<S: State> State for SetIsRead<S> {
351 type Uri = S::Uri;
352 type IsRead = Set<members::is_read>;
353 type Cid = S::Cid;
354 type Author = S::Author;
355 type Reason = S::Reason;
356 type IndexedAt = S::IndexedAt;
357 }
358 pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
360 impl<S: State> sealed::Sealed for SetCid<S> {}
361 impl<S: State> State for SetCid<S> {
362 type Uri = S::Uri;
363 type IsRead = S::IsRead;
364 type Cid = Set<members::cid>;
365 type Author = S::Author;
366 type Reason = S::Reason;
367 type IndexedAt = S::IndexedAt;
368 }
369 pub struct SetAuthor<S: State = Empty>(PhantomData<fn() -> S>);
371 impl<S: State> sealed::Sealed for SetAuthor<S> {}
372 impl<S: State> State for SetAuthor<S> {
373 type Uri = S::Uri;
374 type IsRead = S::IsRead;
375 type Cid = S::Cid;
376 type Author = Set<members::author>;
377 type Reason = S::Reason;
378 type IndexedAt = S::IndexedAt;
379 }
380 pub struct SetReason<S: State = Empty>(PhantomData<fn() -> S>);
382 impl<S: State> sealed::Sealed for SetReason<S> {}
383 impl<S: State> State for SetReason<S> {
384 type Uri = S::Uri;
385 type IsRead = S::IsRead;
386 type Cid = S::Cid;
387 type Author = S::Author;
388 type Reason = Set<members::reason>;
389 type IndexedAt = S::IndexedAt;
390 }
391 pub struct SetIndexedAt<S: State = Empty>(PhantomData<fn() -> S>);
393 impl<S: State> sealed::Sealed for SetIndexedAt<S> {}
394 impl<S: State> State for SetIndexedAt<S> {
395 type Uri = S::Uri;
396 type IsRead = S::IsRead;
397 type Cid = S::Cid;
398 type Author = S::Author;
399 type Reason = S::Reason;
400 type IndexedAt = Set<members::indexed_at>;
401 }
402 #[allow(non_camel_case_types)]
404 pub mod members {
405 pub struct uri(());
407 pub struct is_read(());
409 pub struct cid(());
411 pub struct author(());
413 pub struct reason(());
415 pub struct indexed_at(());
417 }
418}
419
420pub struct NotificationBuilder<'a, S: notification_state::State> {
422 _state: PhantomData<fn() -> S>,
423 _fields: (
424 Option<ProfileViewBasic<'a>>,
425 Option<Cid<'a>>,
426 Option<Datetime>,
427 Option<bool>,
428 Option<notification::NotificationReason<'a>>,
429 Option<AtUri<'a>>,
430 Option<Data<'a>>,
431 Option<AtUri<'a>>,
432 ),
433 _lifetime: PhantomData<&'a ()>,
434}
435
436impl<'a> Notification<'a> {
437 pub fn new() -> NotificationBuilder<'a, notification_state::Empty> {
439 NotificationBuilder::new()
440 }
441}
442
443impl<'a> NotificationBuilder<'a, notification_state::Empty> {
444 pub fn new() -> Self {
446 NotificationBuilder {
447 _state: PhantomData,
448 _fields: (None, None, None, None, None, None, None, None),
449 _lifetime: PhantomData,
450 }
451 }
452}
453
454impl<'a, S> NotificationBuilder<'a, S>
455where
456 S: notification_state::State,
457 S::Author: notification_state::IsUnset,
458{
459 pub fn author(
461 mut self,
462 value: impl Into<ProfileViewBasic<'a>>,
463 ) -> NotificationBuilder<'a, notification_state::SetAuthor<S>> {
464 self._fields.0 = Option::Some(value.into());
465 NotificationBuilder {
466 _state: PhantomData,
467 _fields: self._fields,
468 _lifetime: PhantomData,
469 }
470 }
471}
472
473impl<'a, S> NotificationBuilder<'a, S>
474where
475 S: notification_state::State,
476 S::Cid: notification_state::IsUnset,
477{
478 pub fn cid(
480 mut self,
481 value: impl Into<Cid<'a>>,
482 ) -> NotificationBuilder<'a, notification_state::SetCid<S>> {
483 self._fields.1 = Option::Some(value.into());
484 NotificationBuilder {
485 _state: PhantomData,
486 _fields: self._fields,
487 _lifetime: PhantomData,
488 }
489 }
490}
491
492impl<'a, S> NotificationBuilder<'a, S>
493where
494 S: notification_state::State,
495 S::IndexedAt: notification_state::IsUnset,
496{
497 pub fn indexed_at(
499 mut self,
500 value: impl Into<Datetime>,
501 ) -> NotificationBuilder<'a, notification_state::SetIndexedAt<S>> {
502 self._fields.2 = Option::Some(value.into());
503 NotificationBuilder {
504 _state: PhantomData,
505 _fields: self._fields,
506 _lifetime: PhantomData,
507 }
508 }
509}
510
511impl<'a, S> NotificationBuilder<'a, S>
512where
513 S: notification_state::State,
514 S::IsRead: notification_state::IsUnset,
515{
516 pub fn is_read(
518 mut self,
519 value: impl Into<bool>,
520 ) -> NotificationBuilder<'a, notification_state::SetIsRead<S>> {
521 self._fields.3 = Option::Some(value.into());
522 NotificationBuilder {
523 _state: PhantomData,
524 _fields: self._fields,
525 _lifetime: PhantomData,
526 }
527 }
528}
529
530impl<'a, S> NotificationBuilder<'a, S>
531where
532 S: notification_state::State,
533 S::Reason: notification_state::IsUnset,
534{
535 pub fn reason(
537 mut self,
538 value: impl Into<notification::NotificationReason<'a>>,
539 ) -> NotificationBuilder<'a, notification_state::SetReason<S>> {
540 self._fields.4 = Option::Some(value.into());
541 NotificationBuilder {
542 _state: PhantomData,
543 _fields: self._fields,
544 _lifetime: PhantomData,
545 }
546 }
547}
548
549impl<'a, S: notification_state::State> NotificationBuilder<'a, S> {
550 pub fn reason_subject(mut self, value: impl Into<Option<AtUri<'a>>>) -> Self {
552 self._fields.5 = value.into();
553 self
554 }
555 pub fn maybe_reason_subject(mut self, value: Option<AtUri<'a>>) -> Self {
557 self._fields.5 = value;
558 self
559 }
560}
561
562impl<'a, S: notification_state::State> NotificationBuilder<'a, S> {
563 pub fn record(mut self, value: impl Into<Option<Data<'a>>>) -> Self {
565 self._fields.6 = value.into();
566 self
567 }
568 pub fn maybe_record(mut self, value: Option<Data<'a>>) -> Self {
570 self._fields.6 = value;
571 self
572 }
573}
574
575impl<'a, S> NotificationBuilder<'a, S>
576where
577 S: notification_state::State,
578 S::Uri: notification_state::IsUnset,
579{
580 pub fn uri(
582 mut self,
583 value: impl Into<AtUri<'a>>,
584 ) -> NotificationBuilder<'a, notification_state::SetUri<S>> {
585 self._fields.7 = Option::Some(value.into());
586 NotificationBuilder {
587 _state: PhantomData,
588 _fields: self._fields,
589 _lifetime: PhantomData,
590 }
591 }
592}
593
594impl<'a, S> NotificationBuilder<'a, S>
595where
596 S: notification_state::State,
597 S::Uri: notification_state::IsSet,
598 S::IsRead: notification_state::IsSet,
599 S::Cid: notification_state::IsSet,
600 S::Author: notification_state::IsSet,
601 S::Reason: notification_state::IsSet,
602 S::IndexedAt: notification_state::IsSet,
603{
604 pub fn build(self) -> Notification<'a> {
606 Notification {
607 author: self._fields.0.unwrap(),
608 cid: self._fields.1.unwrap(),
609 indexed_at: self._fields.2.unwrap(),
610 is_read: self._fields.3.unwrap(),
611 reason: self._fields.4.unwrap(),
612 reason_subject: self._fields.5,
613 record: self._fields.6,
614 uri: self._fields.7.unwrap(),
615 extra_data: Default::default(),
616 }
617 }
618 pub fn build_with_data(
620 self,
621 extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
622 ) -> Notification<'a> {
623 Notification {
624 author: self._fields.0.unwrap(),
625 cid: self._fields.1.unwrap(),
626 indexed_at: self._fields.2.unwrap(),
627 is_read: self._fields.3.unwrap(),
628 reason: self._fields.4.unwrap(),
629 reason_subject: self._fields.5,
630 record: self._fields.6,
631 uri: self._fields.7.unwrap(),
632 extra_data: Some(extra_data),
633 }
634 }
635}
636
637fn lexicon_doc_sh_weaver_notification_defs() -> LexiconDoc<'static> {
638 #[allow(unused_imports)]
639 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
640 use jacquard_lexicon::lexicon::*;
641 use alloc::collections::BTreeMap;
642 LexiconDoc {
643 lexicon: Lexicon::Lexicon1,
644 id: CowStr::new_static("sh.weaver.notification.defs"),
645 defs: {
646 let mut map = BTreeMap::new();
647 map.insert(
648 SmolStr::new_static("notification"),
649 LexUserType::Object(LexObject {
650 description: Some(CowStr::new_static("A notification for a user.")),
651 required: Some(
652 vec![
653 SmolStr::new_static("uri"), SmolStr::new_static("cid"),
654 SmolStr::new_static("author"), SmolStr::new_static("reason"),
655 SmolStr::new_static("isRead"),
656 SmolStr::new_static("indexedAt")
657 ],
658 ),
659 properties: {
660 #[allow(unused_mut)]
661 let mut map = BTreeMap::new();
662 map.insert(
663 SmolStr::new_static("author"),
664 LexObjectProperty::Ref(LexRef {
665 r#ref: CowStr::new_static(
666 "sh.weaver.actor.defs#profileViewBasic",
667 ),
668 ..Default::default()
669 }),
670 );
671 map.insert(
672 SmolStr::new_static("cid"),
673 LexObjectProperty::String(LexString {
674 format: Some(LexStringFormat::Cid),
675 ..Default::default()
676 }),
677 );
678 map.insert(
679 SmolStr::new_static("indexedAt"),
680 LexObjectProperty::String(LexString {
681 format: Some(LexStringFormat::Datetime),
682 ..Default::default()
683 }),
684 );
685 map.insert(
686 SmolStr::new_static("isRead"),
687 LexObjectProperty::Boolean(LexBoolean {
688 ..Default::default()
689 }),
690 );
691 map.insert(
692 SmolStr::new_static("reason"),
693 LexObjectProperty::Ref(LexRef {
694 r#ref: CowStr::new_static("#notificationReason"),
695 ..Default::default()
696 }),
697 );
698 map.insert(
699 SmolStr::new_static("reasonSubject"),
700 LexObjectProperty::String(LexString {
701 description: Some(
702 CowStr::new_static(
703 "The subject of the notification (entry, notebook, etc).",
704 ),
705 ),
706 format: Some(LexStringFormat::AtUri),
707 ..Default::default()
708 }),
709 );
710 map.insert(
711 SmolStr::new_static("record"),
712 LexObjectProperty::Unknown(LexUnknown {
713 ..Default::default()
714 }),
715 );
716 map.insert(
717 SmolStr::new_static("uri"),
718 LexObjectProperty::String(LexString {
719 format: Some(LexStringFormat::AtUri),
720 ..Default::default()
721 }),
722 );
723 map
724 },
725 ..Default::default()
726 }),
727 );
728 map.insert(
729 SmolStr::new_static("notificationGroup"),
730 LexUserType::Object(LexObject {
731 description: Some(
732 CowStr::new_static(
733 "Grouped notifications (e.g., '5 people liked your entry').",
734 ),
735 ),
736 required: Some(
737 vec![
738 SmolStr::new_static("reason"),
739 SmolStr::new_static("subject"), SmolStr::new_static("count"),
740 SmolStr::new_static("actors"),
741 SmolStr::new_static("mostRecentAt")
742 ],
743 ),
744 properties: {
745 #[allow(unused_mut)]
746 let mut map = BTreeMap::new();
747 map.insert(
748 SmolStr::new_static("actors"),
749 LexObjectProperty::Array(LexArray {
750 description: Some(
751 CowStr::new_static("Most recent actors (up to 5)."),
752 ),
753 items: LexArrayItem::Ref(LexRef {
754 r#ref: CowStr::new_static(
755 "sh.weaver.actor.defs#profileViewBasic",
756 ),
757 ..Default::default()
758 }),
759 max_length: Some(5usize),
760 ..Default::default()
761 }),
762 );
763 map.insert(
764 SmolStr::new_static("count"),
765 LexObjectProperty::Integer(LexInteger {
766 ..Default::default()
767 }),
768 );
769 map.insert(
770 SmolStr::new_static("isRead"),
771 LexObjectProperty::Boolean(LexBoolean {
772 ..Default::default()
773 }),
774 );
775 map.insert(
776 SmolStr::new_static("mostRecentAt"),
777 LexObjectProperty::String(LexString {
778 format: Some(LexStringFormat::Datetime),
779 ..Default::default()
780 }),
781 );
782 map.insert(
783 SmolStr::new_static("reason"),
784 LexObjectProperty::Ref(LexRef {
785 r#ref: CowStr::new_static("#notificationReason"),
786 ..Default::default()
787 }),
788 );
789 map.insert(
790 SmolStr::new_static("subject"),
791 LexObjectProperty::Union(LexRefUnion {
792 refs: vec![
793 CowStr::new_static("sh.weaver.notebook.defs#notebookView"),
794 CowStr::new_static("sh.weaver.notebook.defs#entryView")
795 ],
796 ..Default::default()
797 }),
798 );
799 map
800 },
801 ..Default::default()
802 }),
803 );
804 map.insert(
805 SmolStr::new_static("notificationReason"),
806 LexUserType::String(LexString {
807 description: Some(
808 CowStr::new_static("Why this notification was generated."),
809 ),
810 ..Default::default()
811 }),
812 );
813 map.insert(
814 SmolStr::new_static("subscriptionUpdateView"),
815 LexUserType::Object(LexObject {
816 description: Some(
817 CowStr::new_static("New content from a notebook subscription."),
818 ),
819 required: Some(
820 vec![
821 SmolStr::new_static("notebook"),
822 SmolStr::new_static("newEntries"),
823 SmolStr::new_static("updatedAt")
824 ],
825 ),
826 properties: {
827 #[allow(unused_mut)]
828 let mut map = BTreeMap::new();
829 map.insert(
830 SmolStr::new_static("newEntries"),
831 LexObjectProperty::Array(LexArray {
832 description: Some(
833 CowStr::new_static("New entries since last check."),
834 ),
835 items: LexArrayItem::Ref(LexRef {
836 r#ref: CowStr::new_static(
837 "sh.weaver.notebook.defs#entryView",
838 ),
839 ..Default::default()
840 }),
841 ..Default::default()
842 }),
843 );
844 map.insert(
845 SmolStr::new_static("notebook"),
846 LexObjectProperty::Ref(LexRef {
847 r#ref: CowStr::new_static(
848 "sh.weaver.notebook.defs#notebookView",
849 ),
850 ..Default::default()
851 }),
852 );
853 map.insert(
854 SmolStr::new_static("updatedAt"),
855 LexObjectProperty::String(LexString {
856 format: Some(LexStringFormat::Datetime),
857 ..Default::default()
858 }),
859 );
860 map.insert(
861 SmolStr::new_static("updatedEntries"),
862 LexObjectProperty::Array(LexArray {
863 description: Some(
864 CowStr::new_static("Entries that were updated."),
865 ),
866 items: LexArrayItem::Ref(LexRef {
867 r#ref: CowStr::new_static(
868 "sh.weaver.notebook.defs#entryView",
869 ),
870 ..Default::default()
871 }),
872 ..Default::default()
873 }),
874 );
875 map
876 },
877 ..Default::default()
878 }),
879 );
880 map
881 },
882 ..Default::default()
883 }
884}
885
886pub mod notification_group_state {
887
888 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
889 #[allow(unused)]
890 use ::core::marker::PhantomData;
891 mod sealed {
892 pub trait Sealed {}
893 }
894 pub trait State: sealed::Sealed {
896 type Count;
897 type Actors;
898 type MostRecentAt;
899 type Reason;
900 type Subject;
901 }
902 pub struct Empty(());
904 impl sealed::Sealed for Empty {}
905 impl State for Empty {
906 type Count = Unset;
907 type Actors = Unset;
908 type MostRecentAt = Unset;
909 type Reason = Unset;
910 type Subject = Unset;
911 }
912 pub struct SetCount<S: State = Empty>(PhantomData<fn() -> S>);
914 impl<S: State> sealed::Sealed for SetCount<S> {}
915 impl<S: State> State for SetCount<S> {
916 type Count = Set<members::count>;
917 type Actors = S::Actors;
918 type MostRecentAt = S::MostRecentAt;
919 type Reason = S::Reason;
920 type Subject = S::Subject;
921 }
922 pub struct SetActors<S: State = Empty>(PhantomData<fn() -> S>);
924 impl<S: State> sealed::Sealed for SetActors<S> {}
925 impl<S: State> State for SetActors<S> {
926 type Count = S::Count;
927 type Actors = Set<members::actors>;
928 type MostRecentAt = S::MostRecentAt;
929 type Reason = S::Reason;
930 type Subject = S::Subject;
931 }
932 pub struct SetMostRecentAt<S: State = Empty>(PhantomData<fn() -> S>);
934 impl<S: State> sealed::Sealed for SetMostRecentAt<S> {}
935 impl<S: State> State for SetMostRecentAt<S> {
936 type Count = S::Count;
937 type Actors = S::Actors;
938 type MostRecentAt = Set<members::most_recent_at>;
939 type Reason = S::Reason;
940 type Subject = S::Subject;
941 }
942 pub struct SetReason<S: State = Empty>(PhantomData<fn() -> S>);
944 impl<S: State> sealed::Sealed for SetReason<S> {}
945 impl<S: State> State for SetReason<S> {
946 type Count = S::Count;
947 type Actors = S::Actors;
948 type MostRecentAt = S::MostRecentAt;
949 type Reason = Set<members::reason>;
950 type Subject = S::Subject;
951 }
952 pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
954 impl<S: State> sealed::Sealed for SetSubject<S> {}
955 impl<S: State> State for SetSubject<S> {
956 type Count = S::Count;
957 type Actors = S::Actors;
958 type MostRecentAt = S::MostRecentAt;
959 type Reason = S::Reason;
960 type Subject = Set<members::subject>;
961 }
962 #[allow(non_camel_case_types)]
964 pub mod members {
965 pub struct count(());
967 pub struct actors(());
969 pub struct most_recent_at(());
971 pub struct reason(());
973 pub struct subject(());
975 }
976}
977
978pub struct NotificationGroupBuilder<'a, S: notification_group_state::State> {
980 _state: PhantomData<fn() -> S>,
981 _fields: (
982 Option<Vec<ProfileViewBasic<'a>>>,
983 Option<i64>,
984 Option<bool>,
985 Option<Datetime>,
986 Option<notification::NotificationReason<'a>>,
987 Option<NotificationGroupSubject<'a>>,
988 ),
989 _lifetime: PhantomData<&'a ()>,
990}
991
992impl<'a> NotificationGroup<'a> {
993 pub fn new() -> NotificationGroupBuilder<'a, notification_group_state::Empty> {
995 NotificationGroupBuilder::new()
996 }
997}
998
999impl<'a> NotificationGroupBuilder<'a, notification_group_state::Empty> {
1000 pub fn new() -> Self {
1002 NotificationGroupBuilder {
1003 _state: PhantomData,
1004 _fields: (None, None, None, None, None, None),
1005 _lifetime: PhantomData,
1006 }
1007 }
1008}
1009
1010impl<'a, S> NotificationGroupBuilder<'a, S>
1011where
1012 S: notification_group_state::State,
1013 S::Actors: notification_group_state::IsUnset,
1014{
1015 pub fn actors(
1017 mut self,
1018 value: impl Into<Vec<ProfileViewBasic<'a>>>,
1019 ) -> NotificationGroupBuilder<'a, notification_group_state::SetActors<S>> {
1020 self._fields.0 = Option::Some(value.into());
1021 NotificationGroupBuilder {
1022 _state: PhantomData,
1023 _fields: self._fields,
1024 _lifetime: PhantomData,
1025 }
1026 }
1027}
1028
1029impl<'a, S> NotificationGroupBuilder<'a, S>
1030where
1031 S: notification_group_state::State,
1032 S::Count: notification_group_state::IsUnset,
1033{
1034 pub fn count(
1036 mut self,
1037 value: impl Into<i64>,
1038 ) -> NotificationGroupBuilder<'a, notification_group_state::SetCount<S>> {
1039 self._fields.1 = Option::Some(value.into());
1040 NotificationGroupBuilder {
1041 _state: PhantomData,
1042 _fields: self._fields,
1043 _lifetime: PhantomData,
1044 }
1045 }
1046}
1047
1048impl<'a, S: notification_group_state::State> NotificationGroupBuilder<'a, S> {
1049 pub fn is_read(mut self, value: impl Into<Option<bool>>) -> Self {
1051 self._fields.2 = value.into();
1052 self
1053 }
1054 pub fn maybe_is_read(mut self, value: Option<bool>) -> Self {
1056 self._fields.2 = value;
1057 self
1058 }
1059}
1060
1061impl<'a, S> NotificationGroupBuilder<'a, S>
1062where
1063 S: notification_group_state::State,
1064 S::MostRecentAt: notification_group_state::IsUnset,
1065{
1066 pub fn most_recent_at(
1068 mut self,
1069 value: impl Into<Datetime>,
1070 ) -> NotificationGroupBuilder<'a, notification_group_state::SetMostRecentAt<S>> {
1071 self._fields.3 = Option::Some(value.into());
1072 NotificationGroupBuilder {
1073 _state: PhantomData,
1074 _fields: self._fields,
1075 _lifetime: PhantomData,
1076 }
1077 }
1078}
1079
1080impl<'a, S> NotificationGroupBuilder<'a, S>
1081where
1082 S: notification_group_state::State,
1083 S::Reason: notification_group_state::IsUnset,
1084{
1085 pub fn reason(
1087 mut self,
1088 value: impl Into<notification::NotificationReason<'a>>,
1089 ) -> NotificationGroupBuilder<'a, notification_group_state::SetReason<S>> {
1090 self._fields.4 = Option::Some(value.into());
1091 NotificationGroupBuilder {
1092 _state: PhantomData,
1093 _fields: self._fields,
1094 _lifetime: PhantomData,
1095 }
1096 }
1097}
1098
1099impl<'a, S> NotificationGroupBuilder<'a, S>
1100where
1101 S: notification_group_state::State,
1102 S::Subject: notification_group_state::IsUnset,
1103{
1104 pub fn subject(
1106 mut self,
1107 value: impl Into<NotificationGroupSubject<'a>>,
1108 ) -> NotificationGroupBuilder<'a, notification_group_state::SetSubject<S>> {
1109 self._fields.5 = Option::Some(value.into());
1110 NotificationGroupBuilder {
1111 _state: PhantomData,
1112 _fields: self._fields,
1113 _lifetime: PhantomData,
1114 }
1115 }
1116}
1117
1118impl<'a, S> NotificationGroupBuilder<'a, S>
1119where
1120 S: notification_group_state::State,
1121 S::Count: notification_group_state::IsSet,
1122 S::Actors: notification_group_state::IsSet,
1123 S::MostRecentAt: notification_group_state::IsSet,
1124 S::Reason: notification_group_state::IsSet,
1125 S::Subject: notification_group_state::IsSet,
1126{
1127 pub fn build(self) -> NotificationGroup<'a> {
1129 NotificationGroup {
1130 actors: self._fields.0.unwrap(),
1131 count: self._fields.1.unwrap(),
1132 is_read: self._fields.2,
1133 most_recent_at: self._fields.3.unwrap(),
1134 reason: self._fields.4.unwrap(),
1135 subject: self._fields.5.unwrap(),
1136 extra_data: Default::default(),
1137 }
1138 }
1139 pub fn build_with_data(
1141 self,
1142 extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
1143 ) -> NotificationGroup<'a> {
1144 NotificationGroup {
1145 actors: self._fields.0.unwrap(),
1146 count: self._fields.1.unwrap(),
1147 is_read: self._fields.2,
1148 most_recent_at: self._fields.3.unwrap(),
1149 reason: self._fields.4.unwrap(),
1150 subject: self._fields.5.unwrap(),
1151 extra_data: Some(extra_data),
1152 }
1153 }
1154}
1155
1156pub mod subscription_update_view_state {
1157
1158 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1159 #[allow(unused)]
1160 use ::core::marker::PhantomData;
1161 mod sealed {
1162 pub trait Sealed {}
1163 }
1164 pub trait State: sealed::Sealed {
1166 type NewEntries;
1167 type UpdatedAt;
1168 type Notebook;
1169 }
1170 pub struct Empty(());
1172 impl sealed::Sealed for Empty {}
1173 impl State for Empty {
1174 type NewEntries = Unset;
1175 type UpdatedAt = Unset;
1176 type Notebook = Unset;
1177 }
1178 pub struct SetNewEntries<S: State = Empty>(PhantomData<fn() -> S>);
1180 impl<S: State> sealed::Sealed for SetNewEntries<S> {}
1181 impl<S: State> State for SetNewEntries<S> {
1182 type NewEntries = Set<members::new_entries>;
1183 type UpdatedAt = S::UpdatedAt;
1184 type Notebook = S::Notebook;
1185 }
1186 pub struct SetUpdatedAt<S: State = Empty>(PhantomData<fn() -> S>);
1188 impl<S: State> sealed::Sealed for SetUpdatedAt<S> {}
1189 impl<S: State> State for SetUpdatedAt<S> {
1190 type NewEntries = S::NewEntries;
1191 type UpdatedAt = Set<members::updated_at>;
1192 type Notebook = S::Notebook;
1193 }
1194 pub struct SetNotebook<S: State = Empty>(PhantomData<fn() -> S>);
1196 impl<S: State> sealed::Sealed for SetNotebook<S> {}
1197 impl<S: State> State for SetNotebook<S> {
1198 type NewEntries = S::NewEntries;
1199 type UpdatedAt = S::UpdatedAt;
1200 type Notebook = Set<members::notebook>;
1201 }
1202 #[allow(non_camel_case_types)]
1204 pub mod members {
1205 pub struct new_entries(());
1207 pub struct updated_at(());
1209 pub struct notebook(());
1211 }
1212}
1213
1214pub struct SubscriptionUpdateViewBuilder<'a, S: subscription_update_view_state::State> {
1216 _state: PhantomData<fn() -> S>,
1217 _fields: (
1218 Option<Vec<EntryView<'a>>>,
1219 Option<NotebookView<'a>>,
1220 Option<Datetime>,
1221 Option<Vec<EntryView<'a>>>,
1222 ),
1223 _lifetime: PhantomData<&'a ()>,
1224}
1225
1226impl<'a> SubscriptionUpdateView<'a> {
1227 pub fn new() -> SubscriptionUpdateViewBuilder<
1229 'a,
1230 subscription_update_view_state::Empty,
1231 > {
1232 SubscriptionUpdateViewBuilder::new()
1233 }
1234}
1235
1236impl<'a> SubscriptionUpdateViewBuilder<'a, subscription_update_view_state::Empty> {
1237 pub fn new() -> Self {
1239 SubscriptionUpdateViewBuilder {
1240 _state: PhantomData,
1241 _fields: (None, None, None, None),
1242 _lifetime: PhantomData,
1243 }
1244 }
1245}
1246
1247impl<'a, S> SubscriptionUpdateViewBuilder<'a, S>
1248where
1249 S: subscription_update_view_state::State,
1250 S::NewEntries: subscription_update_view_state::IsUnset,
1251{
1252 pub fn new_entries(
1254 mut self,
1255 value: impl Into<Vec<EntryView<'a>>>,
1256 ) -> SubscriptionUpdateViewBuilder<
1257 'a,
1258 subscription_update_view_state::SetNewEntries<S>,
1259 > {
1260 self._fields.0 = Option::Some(value.into());
1261 SubscriptionUpdateViewBuilder {
1262 _state: PhantomData,
1263 _fields: self._fields,
1264 _lifetime: PhantomData,
1265 }
1266 }
1267}
1268
1269impl<'a, S> SubscriptionUpdateViewBuilder<'a, S>
1270where
1271 S: subscription_update_view_state::State,
1272 S::Notebook: subscription_update_view_state::IsUnset,
1273{
1274 pub fn notebook(
1276 mut self,
1277 value: impl Into<NotebookView<'a>>,
1278 ) -> SubscriptionUpdateViewBuilder<
1279 'a,
1280 subscription_update_view_state::SetNotebook<S>,
1281 > {
1282 self._fields.1 = Option::Some(value.into());
1283 SubscriptionUpdateViewBuilder {
1284 _state: PhantomData,
1285 _fields: self._fields,
1286 _lifetime: PhantomData,
1287 }
1288 }
1289}
1290
1291impl<'a, S> SubscriptionUpdateViewBuilder<'a, S>
1292where
1293 S: subscription_update_view_state::State,
1294 S::UpdatedAt: subscription_update_view_state::IsUnset,
1295{
1296 pub fn updated_at(
1298 mut self,
1299 value: impl Into<Datetime>,
1300 ) -> SubscriptionUpdateViewBuilder<
1301 'a,
1302 subscription_update_view_state::SetUpdatedAt<S>,
1303 > {
1304 self._fields.2 = Option::Some(value.into());
1305 SubscriptionUpdateViewBuilder {
1306 _state: PhantomData,
1307 _fields: self._fields,
1308 _lifetime: PhantomData,
1309 }
1310 }
1311}
1312
1313impl<'a, S: subscription_update_view_state::State> SubscriptionUpdateViewBuilder<'a, S> {
1314 pub fn updated_entries(
1316 mut self,
1317 value: impl Into<Option<Vec<EntryView<'a>>>>,
1318 ) -> Self {
1319 self._fields.3 = value.into();
1320 self
1321 }
1322 pub fn maybe_updated_entries(mut self, value: Option<Vec<EntryView<'a>>>) -> Self {
1324 self._fields.3 = value;
1325 self
1326 }
1327}
1328
1329impl<'a, S> SubscriptionUpdateViewBuilder<'a, S>
1330where
1331 S: subscription_update_view_state::State,
1332 S::NewEntries: subscription_update_view_state::IsSet,
1333 S::UpdatedAt: subscription_update_view_state::IsSet,
1334 S::Notebook: subscription_update_view_state::IsSet,
1335{
1336 pub fn build(self) -> SubscriptionUpdateView<'a> {
1338 SubscriptionUpdateView {
1339 new_entries: self._fields.0.unwrap(),
1340 notebook: self._fields.1.unwrap(),
1341 updated_at: self._fields.2.unwrap(),
1342 updated_entries: self._fields.3,
1343 extra_data: Default::default(),
1344 }
1345 }
1346 pub fn build_with_data(
1348 self,
1349 extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
1350 ) -> SubscriptionUpdateView<'a> {
1351 SubscriptionUpdateView {
1352 new_entries: self._fields.0.unwrap(),
1353 notebook: self._fields.1.unwrap(),
1354 updated_at: self._fields.2.unwrap(),
1355 updated_entries: self._fields.3,
1356 extra_data: Some(extra_data),
1357 }
1358 }
1359}