1pub mod invite;
10pub mod request;
11
12
13#[allow(unused_imports)]
14use alloc::collections::BTreeMap;
15
16#[allow(unused_imports)]
17use core::marker::PhantomData;
18use jacquard_common::{BosStr, DefaultStr, FromStaticStr};
19
20#[allow(unused_imports)]
21use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
22use jacquard_common::deps::smol_str::SmolStr;
23use jacquard_common::types::string::{Did, AtUri, Datetime};
24use jacquard_common::types::value::Data;
25use jacquard_derive::IntoStatic;
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::app_bsky::actor::ProfileViewBasic;
33#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
36#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
37pub struct InviteView<S: BosStr = DefaultStr> {
38 pub created_at: Datetime,
40 pub did: Did<S>,
42 #[serde(skip_serializing_if = "Option::is_none")]
44 pub expires_at: Option<Datetime>,
45 #[serde(skip_serializing_if = "Option::is_none")]
47 pub profile: Option<ProfileViewBasic<S>>,
48 pub slice: AtUri<S>,
50 #[serde(skip_serializing_if = "Option::is_none")]
52 pub uri: Option<AtUri<S>>,
53 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
54 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
55}
56
57#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
60#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
61pub struct RequestView<S: BosStr = DefaultStr> {
62 pub created_at: Datetime,
64 #[serde(skip_serializing_if = "Option::is_none")]
66 pub profile: Option<ProfileViewBasic<S>>,
67 pub slice: AtUri<S>,
69 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
70 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
71}
72
73impl<S: BosStr> LexiconSchema for InviteView<S> {
74 fn nsid() -> &'static str {
75 "network.slices.waitlist.defs"
76 }
77 fn def_name() -> &'static str {
78 "inviteView"
79 }
80 fn lexicon_doc() -> LexiconDoc<'static> {
81 lexicon_doc_network_slices_waitlist_defs()
82 }
83 fn validate(&self) -> Result<(), ConstraintError> {
84 Ok(())
85 }
86}
87
88impl<S: BosStr> LexiconSchema for RequestView<S> {
89 fn nsid() -> &'static str {
90 "network.slices.waitlist.defs"
91 }
92 fn def_name() -> &'static str {
93 "requestView"
94 }
95 fn lexicon_doc() -> LexiconDoc<'static> {
96 lexicon_doc_network_slices_waitlist_defs()
97 }
98 fn validate(&self) -> Result<(), ConstraintError> {
99 Ok(())
100 }
101}
102
103pub mod invite_view_state {
104
105 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
106 #[allow(unused)]
107 use ::core::marker::PhantomData;
108 mod sealed {
109 pub trait Sealed {}
110 }
111 pub trait State: sealed::Sealed {
113 type CreatedAt;
114 type Did;
115 type Slice;
116 }
117 pub struct Empty(());
119 impl sealed::Sealed for Empty {}
120 impl State for Empty {
121 type CreatedAt = Unset;
122 type Did = Unset;
123 type Slice = Unset;
124 }
125 pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
127 impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
128 impl<St: State> State for SetCreatedAt<St> {
129 type CreatedAt = Set<members::created_at>;
130 type Did = St::Did;
131 type Slice = St::Slice;
132 }
133 pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
135 impl<St: State> sealed::Sealed for SetDid<St> {}
136 impl<St: State> State for SetDid<St> {
137 type CreatedAt = St::CreatedAt;
138 type Did = Set<members::did>;
139 type Slice = St::Slice;
140 }
141 pub struct SetSlice<St: State = Empty>(PhantomData<fn() -> St>);
143 impl<St: State> sealed::Sealed for SetSlice<St> {}
144 impl<St: State> State for SetSlice<St> {
145 type CreatedAt = St::CreatedAt;
146 type Did = St::Did;
147 type Slice = Set<members::slice>;
148 }
149 #[allow(non_camel_case_types)]
151 pub mod members {
152 pub struct created_at(());
154 pub struct did(());
156 pub struct slice(());
158 }
159}
160
161pub struct InviteViewBuilder<St: invite_view_state::State, S: BosStr = DefaultStr> {
163 _state: PhantomData<fn() -> St>,
164 _fields: (
165 Option<Datetime>,
166 Option<Did<S>>,
167 Option<Datetime>,
168 Option<ProfileViewBasic<S>>,
169 Option<AtUri<S>>,
170 Option<AtUri<S>>,
171 ),
172 _type: PhantomData<fn() -> S>,
173}
174
175impl InviteView<DefaultStr> {
176 pub fn new() -> InviteViewBuilder<invite_view_state::Empty, DefaultStr> {
178 InviteViewBuilder::new()
179 }
180}
181
182impl<S: BosStr> InviteView<S> {
183 pub fn builder() -> InviteViewBuilder<invite_view_state::Empty, S> {
185 InviteViewBuilder::builder()
186 }
187}
188
189impl InviteViewBuilder<invite_view_state::Empty, DefaultStr> {
190 pub fn new() -> Self {
192 InviteViewBuilder {
193 _state: PhantomData,
194 _fields: (None, None, None, None, None, None),
195 _type: PhantomData,
196 }
197 }
198}
199
200impl<S: BosStr> InviteViewBuilder<invite_view_state::Empty, S> {
201 pub fn builder() -> Self {
203 InviteViewBuilder {
204 _state: PhantomData,
205 _fields: (None, None, None, None, None, None),
206 _type: PhantomData,
207 }
208 }
209}
210
211impl<St, S: BosStr> InviteViewBuilder<St, S>
212where
213 St: invite_view_state::State,
214 St::CreatedAt: invite_view_state::IsUnset,
215{
216 pub fn created_at(
218 mut self,
219 value: impl Into<Datetime>,
220 ) -> InviteViewBuilder<invite_view_state::SetCreatedAt<St>, S> {
221 self._fields.0 = Option::Some(value.into());
222 InviteViewBuilder {
223 _state: PhantomData,
224 _fields: self._fields,
225 _type: PhantomData,
226 }
227 }
228}
229
230impl<St, S: BosStr> InviteViewBuilder<St, S>
231where
232 St: invite_view_state::State,
233 St::Did: invite_view_state::IsUnset,
234{
235 pub fn did(
237 mut self,
238 value: impl Into<Did<S>>,
239 ) -> InviteViewBuilder<invite_view_state::SetDid<St>, S> {
240 self._fields.1 = Option::Some(value.into());
241 InviteViewBuilder {
242 _state: PhantomData,
243 _fields: self._fields,
244 _type: PhantomData,
245 }
246 }
247}
248
249impl<St: invite_view_state::State, S: BosStr> InviteViewBuilder<St, S> {
250 pub fn expires_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
252 self._fields.2 = value.into();
253 self
254 }
255 pub fn maybe_expires_at(mut self, value: Option<Datetime>) -> Self {
257 self._fields.2 = value;
258 self
259 }
260}
261
262impl<St: invite_view_state::State, S: BosStr> InviteViewBuilder<St, S> {
263 pub fn profile(mut self, value: impl Into<Option<ProfileViewBasic<S>>>) -> Self {
265 self._fields.3 = value.into();
266 self
267 }
268 pub fn maybe_profile(mut self, value: Option<ProfileViewBasic<S>>) -> Self {
270 self._fields.3 = value;
271 self
272 }
273}
274
275impl<St, S: BosStr> InviteViewBuilder<St, S>
276where
277 St: invite_view_state::State,
278 St::Slice: invite_view_state::IsUnset,
279{
280 pub fn slice(
282 mut self,
283 value: impl Into<AtUri<S>>,
284 ) -> InviteViewBuilder<invite_view_state::SetSlice<St>, S> {
285 self._fields.4 = Option::Some(value.into());
286 InviteViewBuilder {
287 _state: PhantomData,
288 _fields: self._fields,
289 _type: PhantomData,
290 }
291 }
292}
293
294impl<St: invite_view_state::State, S: BosStr> InviteViewBuilder<St, S> {
295 pub fn uri(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
297 self._fields.5 = value.into();
298 self
299 }
300 pub fn maybe_uri(mut self, value: Option<AtUri<S>>) -> Self {
302 self._fields.5 = value;
303 self
304 }
305}
306
307impl<St, S: BosStr> InviteViewBuilder<St, S>
308where
309 St: invite_view_state::State,
310 St::CreatedAt: invite_view_state::IsSet,
311 St::Did: invite_view_state::IsSet,
312 St::Slice: invite_view_state::IsSet,
313{
314 pub fn build(self) -> InviteView<S> {
316 InviteView {
317 created_at: self._fields.0.unwrap(),
318 did: self._fields.1.unwrap(),
319 expires_at: self._fields.2,
320 profile: self._fields.3,
321 slice: self._fields.4.unwrap(),
322 uri: self._fields.5,
323 extra_data: Default::default(),
324 }
325 }
326 pub fn build_with_data(
328 self,
329 extra_data: BTreeMap<SmolStr, Data<S>>,
330 ) -> InviteView<S> {
331 InviteView {
332 created_at: self._fields.0.unwrap(),
333 did: self._fields.1.unwrap(),
334 expires_at: self._fields.2,
335 profile: self._fields.3,
336 slice: self._fields.4.unwrap(),
337 uri: self._fields.5,
338 extra_data: Some(extra_data),
339 }
340 }
341}
342
343fn lexicon_doc_network_slices_waitlist_defs() -> LexiconDoc<'static> {
344 #[allow(unused_imports)]
345 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
346 use jacquard_lexicon::lexicon::*;
347 use alloc::collections::BTreeMap;
348 LexiconDoc {
349 lexicon: Lexicon::Lexicon1,
350 id: CowStr::new_static("network.slices.waitlist.defs"),
351 defs: {
352 let mut map = BTreeMap::new();
353 map.insert(
354 SmolStr::new_static("inviteView"),
355 LexUserType::Object(LexObject {
356 description: Some(
357 CowStr::new_static(
358 "An invite granting a DID access with profile information",
359 ),
360 ),
361 required: Some(
362 vec![
363 SmolStr::new_static("did"), SmolStr::new_static("slice"),
364 SmolStr::new_static("createdAt")
365 ],
366 ),
367 properties: {
368 #[allow(unused_mut)]
369 let mut map = BTreeMap::new();
370 map.insert(
371 SmolStr::new_static("createdAt"),
372 LexObjectProperty::String(LexString {
373 description: Some(
374 CowStr::new_static("When this invitation was created"),
375 ),
376 format: Some(LexStringFormat::Datetime),
377 ..Default::default()
378 }),
379 );
380 map.insert(
381 SmolStr::new_static("did"),
382 LexObjectProperty::String(LexString {
383 description: Some(
384 CowStr::new_static("The DID being invited"),
385 ),
386 format: Some(LexStringFormat::Did),
387 ..Default::default()
388 }),
389 );
390 map.insert(
391 SmolStr::new_static("expiresAt"),
392 LexObjectProperty::String(LexString {
393 description: Some(
394 CowStr::new_static(
395 "Optional expiration date for this invitation",
396 ),
397 ),
398 format: Some(LexStringFormat::Datetime),
399 ..Default::default()
400 }),
401 );
402 map.insert(
403 SmolStr::new_static("profile"),
404 LexObjectProperty::Ref(LexRef {
405 r#ref: CowStr::new_static(
406 "app.bsky.actor.defs#profileViewBasic",
407 ),
408 ..Default::default()
409 }),
410 );
411 map.insert(
412 SmolStr::new_static("slice"),
413 LexObjectProperty::String(LexString {
414 description: Some(
415 CowStr::new_static(
416 "The AT URI of the slice this invite is for",
417 ),
418 ),
419 format: Some(LexStringFormat::AtUri),
420 ..Default::default()
421 }),
422 );
423 map.insert(
424 SmolStr::new_static("uri"),
425 LexObjectProperty::String(LexString {
426 description: Some(
427 CowStr::new_static("The AT URI of this invite record"),
428 ),
429 format: Some(LexStringFormat::AtUri),
430 ..Default::default()
431 }),
432 );
433 map
434 },
435 ..Default::default()
436 }),
437 );
438 map.insert(
439 SmolStr::new_static("requestView"),
440 LexUserType::Object(LexObject {
441 description: Some(
442 CowStr::new_static(
443 "A request to join the waitlist with profile information",
444 ),
445 ),
446 required: Some(
447 vec![
448 SmolStr::new_static("slice"),
449 SmolStr::new_static("createdAt")
450 ],
451 ),
452 properties: {
453 #[allow(unused_mut)]
454 let mut map = BTreeMap::new();
455 map.insert(
456 SmolStr::new_static("createdAt"),
457 LexObjectProperty::String(LexString {
458 description: Some(
459 CowStr::new_static("When the user joined the waitlist"),
460 ),
461 format: Some(LexStringFormat::Datetime),
462 ..Default::default()
463 }),
464 );
465 map.insert(
466 SmolStr::new_static("profile"),
467 LexObjectProperty::Ref(LexRef {
468 r#ref: CowStr::new_static(
469 "app.bsky.actor.defs#profileViewBasic",
470 ),
471 ..Default::default()
472 }),
473 );
474 map.insert(
475 SmolStr::new_static("slice"),
476 LexObjectProperty::String(LexString {
477 description: Some(
478 CowStr::new_static(
479 "The AT URI of the slice being requested access to",
480 ),
481 ),
482 format: Some(LexStringFormat::AtUri),
483 ..Default::default()
484 }),
485 );
486 map
487 },
488 ..Default::default()
489 }),
490 );
491 map
492 },
493 ..Default::default()
494 }
495}
496
497pub mod request_view_state {
498
499 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
500 #[allow(unused)]
501 use ::core::marker::PhantomData;
502 mod sealed {
503 pub trait Sealed {}
504 }
505 pub trait State: sealed::Sealed {
507 type CreatedAt;
508 type Slice;
509 }
510 pub struct Empty(());
512 impl sealed::Sealed for Empty {}
513 impl State for Empty {
514 type CreatedAt = Unset;
515 type Slice = Unset;
516 }
517 pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
519 impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
520 impl<St: State> State for SetCreatedAt<St> {
521 type CreatedAt = Set<members::created_at>;
522 type Slice = St::Slice;
523 }
524 pub struct SetSlice<St: State = Empty>(PhantomData<fn() -> St>);
526 impl<St: State> sealed::Sealed for SetSlice<St> {}
527 impl<St: State> State for SetSlice<St> {
528 type CreatedAt = St::CreatedAt;
529 type Slice = Set<members::slice>;
530 }
531 #[allow(non_camel_case_types)]
533 pub mod members {
534 pub struct created_at(());
536 pub struct slice(());
538 }
539}
540
541pub struct RequestViewBuilder<St: request_view_state::State, S: BosStr = DefaultStr> {
543 _state: PhantomData<fn() -> St>,
544 _fields: (Option<Datetime>, Option<ProfileViewBasic<S>>, Option<AtUri<S>>),
545 _type: PhantomData<fn() -> S>,
546}
547
548impl RequestView<DefaultStr> {
549 pub fn new() -> RequestViewBuilder<request_view_state::Empty, DefaultStr> {
551 RequestViewBuilder::new()
552 }
553}
554
555impl<S: BosStr> RequestView<S> {
556 pub fn builder() -> RequestViewBuilder<request_view_state::Empty, S> {
558 RequestViewBuilder::builder()
559 }
560}
561
562impl RequestViewBuilder<request_view_state::Empty, DefaultStr> {
563 pub fn new() -> Self {
565 RequestViewBuilder {
566 _state: PhantomData,
567 _fields: (None, None, None),
568 _type: PhantomData,
569 }
570 }
571}
572
573impl<S: BosStr> RequestViewBuilder<request_view_state::Empty, S> {
574 pub fn builder() -> Self {
576 RequestViewBuilder {
577 _state: PhantomData,
578 _fields: (None, None, None),
579 _type: PhantomData,
580 }
581 }
582}
583
584impl<St, S: BosStr> RequestViewBuilder<St, S>
585where
586 St: request_view_state::State,
587 St::CreatedAt: request_view_state::IsUnset,
588{
589 pub fn created_at(
591 mut self,
592 value: impl Into<Datetime>,
593 ) -> RequestViewBuilder<request_view_state::SetCreatedAt<St>, S> {
594 self._fields.0 = Option::Some(value.into());
595 RequestViewBuilder {
596 _state: PhantomData,
597 _fields: self._fields,
598 _type: PhantomData,
599 }
600 }
601}
602
603impl<St: request_view_state::State, S: BosStr> RequestViewBuilder<St, S> {
604 pub fn profile(mut self, value: impl Into<Option<ProfileViewBasic<S>>>) -> Self {
606 self._fields.1 = value.into();
607 self
608 }
609 pub fn maybe_profile(mut self, value: Option<ProfileViewBasic<S>>) -> Self {
611 self._fields.1 = value;
612 self
613 }
614}
615
616impl<St, S: BosStr> RequestViewBuilder<St, S>
617where
618 St: request_view_state::State,
619 St::Slice: request_view_state::IsUnset,
620{
621 pub fn slice(
623 mut self,
624 value: impl Into<AtUri<S>>,
625 ) -> RequestViewBuilder<request_view_state::SetSlice<St>, S> {
626 self._fields.2 = Option::Some(value.into());
627 RequestViewBuilder {
628 _state: PhantomData,
629 _fields: self._fields,
630 _type: PhantomData,
631 }
632 }
633}
634
635impl<St, S: BosStr> RequestViewBuilder<St, S>
636where
637 St: request_view_state::State,
638 St::CreatedAt: request_view_state::IsSet,
639 St::Slice: request_view_state::IsSet,
640{
641 pub fn build(self) -> RequestView<S> {
643 RequestView {
644 created_at: self._fields.0.unwrap(),
645 profile: self._fields.1,
646 slice: self._fields.2.unwrap(),
647 extra_data: Default::default(),
648 }
649 }
650 pub fn build_with_data(
652 self,
653 extra_data: BTreeMap<SmolStr, Data<S>>,
654 ) -> RequestView<S> {
655 RequestView {
656 created_at: self._fields.0.unwrap(),
657 profile: self._fields.1,
658 slice: self._fields.2.unwrap(),
659 extra_data: Some(extra_data),
660 }
661 }
662}