#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::cid::CidLink;
use jacquard_common::types::string::{Datetime, Did, Tid, UriValue};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::zone_stratos::sync::subscribe_records;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Commit<S: BosStr = DefaultStr> {
pub did: Did<S>,
pub ops: Vec<subscribe_records::RecordOp<S>>,
pub rev: Tid,
pub seq: i64,
pub time: Datetime,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Enrollment<S: BosStr = DefaultStr> {
pub action: EnrollmentAction<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub boundaries: Option<Vec<S>>,
pub did: Did<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub service: Option<UriValue<S>>,
pub time: Datetime,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum EnrollmentAction<S: BosStr = DefaultStr> {
Enroll,
Unenroll,
Other(S),
}
impl<S: BosStr> EnrollmentAction<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Enroll => "enroll",
Self::Unenroll => "unenroll",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"enroll" => Self::Enroll,
"unenroll" => Self::Unenroll,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for EnrollmentAction<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for EnrollmentAction<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for EnrollmentAction<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for EnrollmentAction<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for EnrollmentAction<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for EnrollmentAction<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = EnrollmentAction<S::Output>;
fn into_static(self) -> Self::Output {
match self {
EnrollmentAction::Enroll => EnrollmentAction::Enroll,
EnrollmentAction::Unenroll => EnrollmentAction::Unenroll,
EnrollmentAction::Other(v) => EnrollmentAction::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Info<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<S>,
pub name: InfoName<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum InfoName<S: BosStr = DefaultStr> {
OutdatedCursor,
Other(S),
}
impl<S: BosStr> InfoName<S> {
pub fn as_str(&self) -> &str {
match self {
Self::OutdatedCursor => "OutdatedCursor",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"OutdatedCursor" => Self::OutdatedCursor,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for InfoName<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for InfoName<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for InfoName<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for InfoName<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for InfoName<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for InfoName<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = InfoName<S::Output>;
fn into_static(self) -> Self::Output {
match self {
InfoName::OutdatedCursor => InfoName::OutdatedCursor,
InfoName::Other(v) => InfoName::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct SubscribeRecords<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub did: Option<Did<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub domain: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub sync_token: Option<S>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum SubscribeRecordsMessage<S: BosStr = DefaultStr> {
#[serde(rename = "#commit")]
Commit(Box<subscribe_records::Commit<S>>),
#[serde(rename = "#enrollment")]
Enrollment(Box<subscribe_records::Enrollment<S>>),
#[serde(rename = "#info")]
Info(Box<subscribe_records::Info<S>>),
}
impl<S: BosStr> SubscribeRecordsMessage<S> {
pub fn decode_framed<'de>(
bytes: &'de [u8],
) -> Result<SubscribeRecordsMessage<S>, jacquard_common::error::DecodeError>
where
S: serde::Deserialize<'de>,
{
let (header, body) = jacquard_common::xrpc::subscription::parse_event_header(bytes)?;
match header.t.as_str() {
"#commit" => {
let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(body)?;
Ok(Self::Commit(Box::new(variant)))
}
"#enrollment" => {
let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(body)?;
Ok(Self::Enrollment(Box::new(variant)))
}
"#info" => {
let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(body)?;
Ok(Self::Info(Box::new(variant)))
}
unknown => Err(jacquard_common::error::DecodeError::UnknownEventType(
unknown.into(),
)),
}
}
}
#[derive(
Serialize, Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic,
)]
#[serde(tag = "error", content = "message")]
pub enum SubscribeRecordsError {
#[serde(rename = "FutureCursor")]
FutureCursor(Option<SmolStr>),
#[serde(rename = "AuthRequired")]
AuthRequired(Option<SmolStr>),
#[serde(untagged)]
Other {
error: SmolStr,
message: Option<SmolStr>,
},
}
impl core::fmt::Display for SubscribeRecordsError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::FutureCursor(msg) => {
write!(f, "FutureCursor")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::AuthRequired(msg) => {
write!(f, "AuthRequired")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Other { error, message } => {
write!(f, "{}", error)?;
if let Some(msg) = message {
write!(f, ": {}", msg)?;
}
Ok(())
}
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct RecordOp<S: BosStr = DefaultStr> {
pub action: RecordOpAction<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<CidLink<S>>,
pub path: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub record: Option<Data<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum RecordOpAction<S: BosStr = DefaultStr> {
Create,
Update,
Delete,
Other(S),
}
impl<S: BosStr> RecordOpAction<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Create => "create",
Self::Update => "update",
Self::Delete => "delete",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"create" => Self::Create,
"update" => Self::Update,
"delete" => Self::Delete,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for RecordOpAction<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for RecordOpAction<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for RecordOpAction<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for RecordOpAction<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for RecordOpAction<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for RecordOpAction<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = RecordOpAction<S::Output>;
fn into_static(self) -> Self::Output {
match self {
RecordOpAction::Create => RecordOpAction::Create,
RecordOpAction::Update => RecordOpAction::Update,
RecordOpAction::Delete => RecordOpAction::Delete,
RecordOpAction::Other(v) => RecordOpAction::Other(v.into_static()),
}
}
}
impl<S: BosStr> LexiconSchema for Commit<S> {
fn nsid() -> &'static str {
"zone.stratos.sync.subscribeRecords"
}
fn def_name() -> &'static str {
"commit"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_zone_stratos_sync_subscribeRecords()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Enrollment<S> {
fn nsid() -> &'static str {
"zone.stratos.sync.subscribeRecords"
}
fn def_name() -> &'static str {
"enrollment"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_zone_stratos_sync_subscribeRecords()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.action;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("action"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Info<S> {
fn nsid() -> &'static str {
"zone.stratos.sync.subscribeRecords"
}
fn def_name() -> &'static str {
"info"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_zone_stratos_sync_subscribeRecords()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.message {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1024usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("message"),
max: 1024usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub struct SubscribeRecordsStream;
impl jacquard_common::xrpc::SubscriptionResp for SubscribeRecordsStream {
const NSID: &'static str = "zone.stratos.sync.subscribeRecords";
const ENCODING: jacquard_common::xrpc::MessageEncoding =
jacquard_common::xrpc::MessageEncoding::Json;
type Message<S: BosStr> = SubscribeRecordsMessage<S>;
type Error = SubscribeRecordsError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcSubscription for SubscribeRecords<S> {
const NSID: &'static str = "zone.stratos.sync.subscribeRecords";
const ENCODING: jacquard_common::xrpc::MessageEncoding =
jacquard_common::xrpc::MessageEncoding::Json;
type Stream = SubscribeRecordsStream;
}
pub struct SubscribeRecordsEndpoint;
impl jacquard_common::xrpc::SubscriptionEndpoint for SubscribeRecordsEndpoint {
const PATH: &'static str = "/xrpc/zone.stratos.sync.subscribeRecords";
const ENCODING: jacquard_common::xrpc::MessageEncoding =
jacquard_common::xrpc::MessageEncoding::Json;
type Params<S: BosStr> = SubscribeRecords<S>;
type Stream = SubscribeRecordsStream;
}
impl<S: BosStr> LexiconSchema for RecordOp<S> {
fn nsid() -> &'static str {
"zone.stratos.sync.subscribeRecords"
}
fn def_name() -> &'static str {
"recordOp"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_zone_stratos_sync_subscribeRecords()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.action;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("action"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.path;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 512usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("path"),
max: 512usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub mod commit_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Seq;
type Rev;
type Did;
type Ops;
type Time;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Seq = Unset;
type Rev = Unset;
type Did = Unset;
type Ops = Unset;
type Time = Unset;
}
pub struct SetSeq<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSeq<St> {}
impl<St: State> State for SetSeq<St> {
type Seq = Set<members::seq>;
type Rev = St::Rev;
type Did = St::Did;
type Ops = St::Ops;
type Time = St::Time;
}
pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRev<St> {}
impl<St: State> State for SetRev<St> {
type Seq = St::Seq;
type Rev = Set<members::rev>;
type Did = St::Did;
type Ops = St::Ops;
type Time = St::Time;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type Seq = St::Seq;
type Rev = St::Rev;
type Did = Set<members::did>;
type Ops = St::Ops;
type Time = St::Time;
}
pub struct SetOps<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetOps<St> {}
impl<St: State> State for SetOps<St> {
type Seq = St::Seq;
type Rev = St::Rev;
type Did = St::Did;
type Ops = Set<members::ops>;
type Time = St::Time;
}
pub struct SetTime<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTime<St> {}
impl<St: State> State for SetTime<St> {
type Seq = St::Seq;
type Rev = St::Rev;
type Did = St::Did;
type Ops = St::Ops;
type Time = Set<members::time>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct seq(());
pub struct rev(());
pub struct did(());
pub struct ops(());
pub struct time(());
}
}
pub struct CommitBuilder<S: BosStr, St: commit_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Did<S>>,
Option<Vec<subscribe_records::RecordOp<S>>>,
Option<Tid>,
Option<i64>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Commit<S> {
pub fn new() -> CommitBuilder<S, commit_state::Empty> {
CommitBuilder::new()
}
}
impl<S: BosStr> CommitBuilder<S, commit_state::Empty> {
pub fn new() -> Self {
CommitBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Did: commit_state::IsUnset,
{
pub fn did(mut self, value: impl Into<Did<S>>) -> CommitBuilder<S, commit_state::SetDid<St>> {
self._fields.0 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Ops: commit_state::IsUnset,
{
pub fn ops(
mut self,
value: impl Into<Vec<subscribe_records::RecordOp<S>>>,
) -> CommitBuilder<S, commit_state::SetOps<St>> {
self._fields.1 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Rev: commit_state::IsUnset,
{
pub fn rev(mut self, value: impl Into<Tid>) -> CommitBuilder<S, commit_state::SetRev<St>> {
self._fields.2 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Seq: commit_state::IsUnset,
{
pub fn seq(mut self, value: impl Into<i64>) -> CommitBuilder<S, commit_state::SetSeq<St>> {
self._fields.3 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Time: commit_state::IsUnset,
{
pub fn time(
mut self,
value: impl Into<Datetime>,
) -> CommitBuilder<S, commit_state::SetTime<St>> {
self._fields.4 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Seq: commit_state::IsSet,
St::Rev: commit_state::IsSet,
St::Did: commit_state::IsSet,
St::Ops: commit_state::IsSet,
St::Time: commit_state::IsSet,
{
pub fn build(self) -> Commit<S> {
Commit {
did: self._fields.0.unwrap(),
ops: self._fields.1.unwrap(),
rev: self._fields.2.unwrap(),
seq: self._fields.3.unwrap(),
time: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Commit<S> {
Commit {
did: self._fields.0.unwrap(),
ops: self._fields.1.unwrap(),
rev: self._fields.2.unwrap(),
seq: self._fields.3.unwrap(),
time: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_zone_stratos_sync_subscribeRecords() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("zone.stratos.sync.subscribeRecords"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("commit"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"A commit event containing record operations.",
)),
required: Some(vec![
SmolStr::new_static("seq"),
SmolStr::new_static("did"),
SmolStr::new_static("time"),
SmolStr::new_static("rev"),
SmolStr::new_static("ops"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The DID of the account.")),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("ops"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"List of record operations in this commit.",
)),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#recordOp"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rev"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The repo revision.")),
format: Some(LexStringFormat::Tid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("seq"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("time"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Timestamp of when the event was sequenced.",
)),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("enrollment"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"An enrollment event indicating a user has enrolled or unenrolled from the service.",
),
),
required: Some(
vec![
SmolStr::new_static("did"), SmolStr::new_static("action"),
SmolStr::new_static("time")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("action"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The enrollment action."),
),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("boundaries"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static("The boundaries assigned to the user."),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The DID of the user."),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("service"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The Stratos service endpoint URL."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("time"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Timestamp of the enrollment event."),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("info"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"An informational message about the subscription state.",
)),
required: Some(vec![SmolStr::new_static("name")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("message"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Additional details about the info message.",
)),
max_length: Some(1024usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The type of info message.")),
max_length: Some(128usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcSubscription(LexXrpcSubscription {
parameters: Some(
LexXrpcSubscriptionParameter::Params(LexXrpcParameters {
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cursor"),
LexXrpcParametersProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("did"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static(
"The DID of the account to subscribe to. If omitted, subscribes to service-level enrollment events.",
),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("domain"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static(
"Optional domain filter. Only events for records with this domain in their boundary will be emitted.",
),
),
max_length: Some(253usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("syncToken"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static(
"Signed service JWT for AppView authentication. Must include iss, aud, exp, and lxm claims. Required for service callers; owner callers may use the Authorization header instead.",
),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("recordOp"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"A single record operation within a commit.",
)),
required: Some(vec![
SmolStr::new_static("action"),
SmolStr::new_static("path"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("action"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The type of operation.")),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cid"),
LexObjectProperty::CidLink(LexCidLink {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("path"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The record path (collection/rkey).",
)),
max_length: Some(512usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("record"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod enrollment_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Did;
type Action;
type Time;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Did = Unset;
type Action = Unset;
type Time = Unset;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type Did = Set<members::did>;
type Action = St::Action;
type Time = St::Time;
}
pub struct SetAction<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAction<St> {}
impl<St: State> State for SetAction<St> {
type Did = St::Did;
type Action = Set<members::action>;
type Time = St::Time;
}
pub struct SetTime<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTime<St> {}
impl<St: State> State for SetTime<St> {
type Did = St::Did;
type Action = St::Action;
type Time = Set<members::time>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct did(());
pub struct action(());
pub struct time(());
}
}
pub struct EnrollmentBuilder<S: BosStr, St: enrollment_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<EnrollmentAction<S>>,
Option<Vec<S>>,
Option<Did<S>>,
Option<UriValue<S>>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Enrollment<S> {
pub fn new() -> EnrollmentBuilder<S, enrollment_state::Empty> {
EnrollmentBuilder::new()
}
}
impl<S: BosStr> EnrollmentBuilder<S, enrollment_state::Empty> {
pub fn new() -> Self {
EnrollmentBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EnrollmentBuilder<S, St>
where
St: enrollment_state::State,
St::Action: enrollment_state::IsUnset,
{
pub fn action(
mut self,
value: impl Into<EnrollmentAction<S>>,
) -> EnrollmentBuilder<S, enrollment_state::SetAction<St>> {
self._fields.0 = Option::Some(value.into());
EnrollmentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: enrollment_state::State> EnrollmentBuilder<S, St> {
pub fn boundaries(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_boundaries(mut self, value: Option<Vec<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> EnrollmentBuilder<S, St>
where
St: enrollment_state::State,
St::Did: enrollment_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<S>>,
) -> EnrollmentBuilder<S, enrollment_state::SetDid<St>> {
self._fields.2 = Option::Some(value.into());
EnrollmentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: enrollment_state::State> EnrollmentBuilder<S, St> {
pub fn service(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_service(mut self, value: Option<UriValue<S>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> EnrollmentBuilder<S, St>
where
St: enrollment_state::State,
St::Time: enrollment_state::IsUnset,
{
pub fn time(
mut self,
value: impl Into<Datetime>,
) -> EnrollmentBuilder<S, enrollment_state::SetTime<St>> {
self._fields.4 = Option::Some(value.into());
EnrollmentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> EnrollmentBuilder<S, St>
where
St: enrollment_state::State,
St::Did: enrollment_state::IsSet,
St::Action: enrollment_state::IsSet,
St::Time: enrollment_state::IsSet,
{
pub fn build(self) -> Enrollment<S> {
Enrollment {
action: self._fields.0.unwrap(),
boundaries: self._fields.1,
did: self._fields.2.unwrap(),
service: self._fields.3,
time: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Enrollment<S> {
Enrollment {
action: self._fields.0.unwrap(),
boundaries: self._fields.1,
did: self._fields.2.unwrap(),
service: self._fields.3,
time: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod subscribe_records_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {}
#[allow(non_camel_case_types)]
pub mod members {}
}
pub struct SubscribeRecordsBuilder<S: BosStr, St: subscribe_records_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>, Option<Did<S>>, Option<S>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> SubscribeRecords<S> {
pub fn new() -> SubscribeRecordsBuilder<S, subscribe_records_state::Empty> {
SubscribeRecordsBuilder::new()
}
}
impl<S: BosStr> SubscribeRecordsBuilder<S, subscribe_records_state::Empty> {
pub fn new() -> Self {
SubscribeRecordsBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: subscribe_records_state::State> SubscribeRecordsBuilder<S, St> {
pub fn cursor(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_cursor(mut self, value: Option<i64>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: subscribe_records_state::State> SubscribeRecordsBuilder<S, St> {
pub fn did(mut self, value: impl Into<Option<Did<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_did(mut self, value: Option<Did<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: subscribe_records_state::State> SubscribeRecordsBuilder<S, St> {
pub fn domain(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_domain(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: subscribe_records_state::State> SubscribeRecordsBuilder<S, St> {
pub fn sync_token(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_sync_token(mut self, value: Option<S>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> SubscribeRecordsBuilder<S, St>
where
St: subscribe_records_state::State,
{
pub fn build(self) -> SubscribeRecords<S> {
SubscribeRecords {
cursor: self._fields.0,
did: self._fields.1,
domain: self._fields.2,
sync_token: self._fields.3,
}
}
}