#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Webhook<'a> {
pub created_at: jacquard_common::types::string::Datetime,
#[serde(borrow)]
pub hold_did: jacquard_common::types::string::Did<'a>,
#[serde(borrow)]
pub private_cid: jacquard_common::CowStr<'a>,
pub triggers: i64,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
pub updated_at: std::option::Option<jacquard_common::types::string::Datetime>,
}
pub mod webhook_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type PrivateCid;
type Triggers;
type HoldDid;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type PrivateCid = Unset;
type Triggers = Unset;
type HoldDid = Unset;
type CreatedAt = Unset;
}
pub struct SetPrivateCid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPrivateCid<S> {}
impl<S: State> State for SetPrivateCid<S> {
type PrivateCid = Set<members::private_cid>;
type Triggers = S::Triggers;
type HoldDid = S::HoldDid;
type CreatedAt = S::CreatedAt;
}
pub struct SetTriggers<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTriggers<S> {}
impl<S: State> State for SetTriggers<S> {
type PrivateCid = S::PrivateCid;
type Triggers = Set<members::triggers>;
type HoldDid = S::HoldDid;
type CreatedAt = S::CreatedAt;
}
pub struct SetHoldDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHoldDid<S> {}
impl<S: State> State for SetHoldDid<S> {
type PrivateCid = S::PrivateCid;
type Triggers = S::Triggers;
type HoldDid = Set<members::hold_did>;
type CreatedAt = S::CreatedAt;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type PrivateCid = S::PrivateCid;
type Triggers = S::Triggers;
type HoldDid = S::HoldDid;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct private_cid(());
pub struct triggers(());
pub struct hold_did(());
pub struct created_at(());
}
}
pub struct WebhookBuilder<'a, S: webhook_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::types::string::Datetime>,
::core::option::Option<jacquard_common::types::string::Did<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<i64>,
::core::option::Option<jacquard_common::types::string::Datetime>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Webhook<'a> {
pub fn new() -> WebhookBuilder<'a, webhook_state::Empty> {
WebhookBuilder::new()
}
}
impl<'a> WebhookBuilder<'a, webhook_state::Empty> {
pub fn new() -> Self {
WebhookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> WebhookBuilder<'a, S>
where
S: webhook_state::State,
S::CreatedAt: webhook_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<jacquard_common::types::string::Datetime>,
) -> WebhookBuilder<'a, webhook_state::SetCreatedAt<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
WebhookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> WebhookBuilder<'a, S>
where
S: webhook_state::State,
S::HoldDid: webhook_state::IsUnset,
{
pub fn hold_did(
mut self,
value: impl Into<jacquard_common::types::string::Did<'a>>,
) -> WebhookBuilder<'a, webhook_state::SetHoldDid<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
WebhookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> WebhookBuilder<'a, S>
where
S: webhook_state::State,
S::PrivateCid: webhook_state::IsUnset,
{
pub fn private_cid(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> WebhookBuilder<'a, webhook_state::SetPrivateCid<S>> {
self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
WebhookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> WebhookBuilder<'a, S>
where
S: webhook_state::State,
S::Triggers: webhook_state::IsUnset,
{
pub fn triggers(
mut self,
value: impl Into<i64>,
) -> WebhookBuilder<'a, webhook_state::SetTriggers<S>> {
self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
WebhookBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S: webhook_state::State> WebhookBuilder<'a, S> {
pub fn updated_at(
mut self,
value: impl Into<Option<jacquard_common::types::string::Datetime>>,
) -> Self {
self.__unsafe_private_named.4 = value.into();
self
}
pub fn maybe_updated_at(
mut self,
value: Option<jacquard_common::types::string::Datetime>,
) -> Self {
self.__unsafe_private_named.4 = value;
self
}
}
impl<'a, S> WebhookBuilder<'a, S>
where
S: webhook_state::State,
S::PrivateCid: webhook_state::IsSet,
S::Triggers: webhook_state::IsSet,
S::HoldDid: webhook_state::IsSet,
S::CreatedAt: webhook_state::IsSet,
{
pub fn build(self) -> Webhook<'a> {
Webhook {
created_at: self.__unsafe_private_named.0.unwrap(),
hold_did: self.__unsafe_private_named.1.unwrap(),
private_cid: self.__unsafe_private_named.2.unwrap(),
triggers: self.__unsafe_private_named.3.unwrap(),
updated_at: self.__unsafe_private_named.4,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Webhook<'a> {
Webhook {
created_at: self.__unsafe_private_named.0.unwrap(),
hold_did: self.__unsafe_private_named.1.unwrap(),
private_cid: self.__unsafe_private_named.2.unwrap(),
triggers: self.__unsafe_private_named.3.unwrap(),
updated_at: self.__unsafe_private_named.4,
extra_data: Some(extra_data),
}
}
}
impl<'a> Webhook<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, WebhookRecord>,
jacquard_common::types::uri::UriError,
> {
jacquard_common::types::uri::RecordUri::try_from_uri(
jacquard_common::types::string::AtUri::new_cow(uri.into())?,
)
}
}
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct WebhookGetRecordOutput<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
#[serde(borrow)]
pub uri: jacquard_common::types::string::AtUri<'a>,
#[serde(borrow)]
pub value: Webhook<'a>,
}
impl From<WebhookGetRecordOutput<'_>> for Webhook<'_> {
fn from(output: WebhookGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for Webhook<'_> {
const NSID: &'static str = "io.atcr.sailor.webhook";
type Record = WebhookRecord;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct WebhookRecord;
impl jacquard_common::xrpc::XrpcResp for WebhookRecord {
const NSID: &'static str = "io.atcr.sailor.webhook";
const ENCODING: &'static str = "application/json";
type Output<'de> = WebhookGetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for WebhookRecord {
const NSID: &'static str = "io.atcr.sailor.webhook";
type Record = WebhookRecord;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Webhook<'a> {
fn nsid() -> &'static str {
"io.atcr.sailor.webhook"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_io_atcr_sailor_webhook()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
{
let value = &self.private_cid;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"private_cid",
),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.triggers;
if *value < 0i64 {
return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"triggers",
),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
fn lexicon_doc_io_atcr_sailor_webhook() -> ::jacquard_lexicon::lexicon::LexiconDoc<
'static,
> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("io.atcr.sailor.webhook"),
revision: None,
description: None,
defs: {
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("main"),
::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
description: Some(
::jacquard_common::CowStr::new_static(
"Public webhook metadata stored in the user's PDS. Links to a private io.atcr.hold.webhook record on the hold where URL and secret are stored. Part of a two-record split: this record is visible via ATProto (Jetstream), the hold record is not.",
),
),
key: Some(::jacquard_common::CowStr::new_static("tid")),
record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("holdDid"),
::jacquard_common::deps::smol_str::SmolStr::new_static("triggers"),
::jacquard_common::deps::smol_str::SmolStr::new_static("privateCid"),
::jacquard_common::deps::smol_str::SmolStr::new_static("createdAt")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"createdAt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"RFC3339 timestamp of when the webhook was created",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"holdDid",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"DID of the hold where the webhook is configured",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Did,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"privateCid",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"CID of the corresponding io.atcr.hold.webhook record on the hold",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(128usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"triggers",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
description: None,
default: None,
minimum: Some(0i64),
maximum: None,
r#enum: None,
r#const: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"updatedAt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"RFC3339 timestamp of when the webhook was last updated",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map
},
}),
}),
);
map
},
}
}