#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "social.octosphere.publication",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Publication<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub canonical_url: Option<UriValue<S>>,
pub citations: Vec<S>,
pub content_html: S,
pub content_text: S,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub doi: Option<UriValue<S>>,
pub linked_from: Vec<S>,
pub linked_to: Vec<S>,
pub octopus_id: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub owner_orcid: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub peer_review_of: Option<S>,
pub publication_type: PublicationPublicationType<S>,
pub status: PublicationStatus<S>,
pub title: S,
pub updated_at: Datetime,
pub version_id: 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 PublicationPublicationType<S: BosStr = DefaultStr> {
ResearchProblem,
Hypothesis,
Protocol,
Analysis,
Interpretation,
RealWorldApplication,
Data,
PeerReview,
Other(S),
}
impl<S: BosStr> PublicationPublicationType<S> {
pub fn as_str(&self) -> &str {
match self {
Self::ResearchProblem => "RESEARCH_PROBLEM",
Self::Hypothesis => "HYPOTHESIS",
Self::Protocol => "PROTOCOL",
Self::Analysis => "ANALYSIS",
Self::Interpretation => "INTERPRETATION",
Self::RealWorldApplication => "REAL_WORLD_APPLICATION",
Self::Data => "DATA",
Self::PeerReview => "PEER_REVIEW",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"RESEARCH_PROBLEM" => Self::ResearchProblem,
"HYPOTHESIS" => Self::Hypothesis,
"PROTOCOL" => Self::Protocol,
"ANALYSIS" => Self::Analysis,
"INTERPRETATION" => Self::Interpretation,
"REAL_WORLD_APPLICATION" => Self::RealWorldApplication,
"DATA" => Self::Data,
"PEER_REVIEW" => Self::PeerReview,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for PublicationPublicationType<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for PublicationPublicationType<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for PublicationPublicationType<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 PublicationPublicationType<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 PublicationPublicationType<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for PublicationPublicationType<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = PublicationPublicationType<S::Output>;
fn into_static(self) -> Self::Output {
match self {
PublicationPublicationType::ResearchProblem => {
PublicationPublicationType::ResearchProblem
}
PublicationPublicationType::Hypothesis => {
PublicationPublicationType::Hypothesis
}
PublicationPublicationType::Protocol => PublicationPublicationType::Protocol,
PublicationPublicationType::Analysis => PublicationPublicationType::Analysis,
PublicationPublicationType::Interpretation => {
PublicationPublicationType::Interpretation
}
PublicationPublicationType::RealWorldApplication => {
PublicationPublicationType::RealWorldApplication
}
PublicationPublicationType::Data => PublicationPublicationType::Data,
PublicationPublicationType::PeerReview => {
PublicationPublicationType::PeerReview
}
PublicationPublicationType::Other(v) => {
PublicationPublicationType::Other(v.into_static())
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum PublicationStatus<S: BosStr = DefaultStr> {
Live,
Draft,
Archived,
Other(S),
}
impl<S: BosStr> PublicationStatus<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Live => "LIVE",
Self::Draft => "DRAFT",
Self::Archived => "ARCHIVED",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"LIVE" => Self::Live,
"DRAFT" => Self::Draft,
"ARCHIVED" => Self::Archived,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for PublicationStatus<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for PublicationStatus<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for PublicationStatus<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 PublicationStatus<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 PublicationStatus<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for PublicationStatus<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = PublicationStatus<S::Output>;
fn into_static(self) -> Self::Output {
match self {
PublicationStatus::Live => PublicationStatus::Live,
PublicationStatus::Draft => PublicationStatus::Draft,
PublicationStatus::Archived => PublicationStatus::Archived,
PublicationStatus::Other(v) => PublicationStatus::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct PublicationGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Publication<S>,
}
impl<S: BosStr> Publication<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, PublicationRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct PublicationRecord;
impl XrpcResp for PublicationRecord {
const NSID: &'static str = "social.octosphere.publication";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = PublicationGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<PublicationGetRecordOutput<S>> for Publication<S> {
fn from(output: PublicationGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Publication<S> {
const NSID: &'static str = "social.octosphere.publication";
type Record = PublicationRecord;
}
impl Collection for PublicationRecord {
const NSID: &'static str = "social.octosphere.publication";
type Record = PublicationRecord;
}
impl<S: BosStr> LexiconSchema for Publication<S> {
fn nsid() -> &'static str {
"social.octosphere.publication"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_social_octosphere_publication()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.title;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("title"),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub mod publication_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 ContentHtml;
type CreatedAt;
type UpdatedAt;
type LinkedTo;
type ContentText;
type LinkedFrom;
type PublicationType;
type Title;
type OctopusId;
type Citations;
type Status;
type VersionId;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ContentHtml = Unset;
type CreatedAt = Unset;
type UpdatedAt = Unset;
type LinkedTo = Unset;
type ContentText = Unset;
type LinkedFrom = Unset;
type PublicationType = Unset;
type Title = Unset;
type OctopusId = Unset;
type Citations = Unset;
type Status = Unset;
type VersionId = Unset;
}
pub struct SetContentHtml<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContentHtml<St> {}
impl<St: State> State for SetContentHtml<St> {
type ContentHtml = Set<members::content_html>;
type CreatedAt = St::CreatedAt;
type UpdatedAt = St::UpdatedAt;
type LinkedTo = St::LinkedTo;
type ContentText = St::ContentText;
type LinkedFrom = St::LinkedFrom;
type PublicationType = St::PublicationType;
type Title = St::Title;
type OctopusId = St::OctopusId;
type Citations = St::Citations;
type Status = St::Status;
type VersionId = St::VersionId;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type ContentHtml = St::ContentHtml;
type CreatedAt = Set<members::created_at>;
type UpdatedAt = St::UpdatedAt;
type LinkedTo = St::LinkedTo;
type ContentText = St::ContentText;
type LinkedFrom = St::LinkedFrom;
type PublicationType = St::PublicationType;
type Title = St::Title;
type OctopusId = St::OctopusId;
type Citations = St::Citations;
type Status = St::Status;
type VersionId = St::VersionId;
}
pub struct SetUpdatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUpdatedAt<St> {}
impl<St: State> State for SetUpdatedAt<St> {
type ContentHtml = St::ContentHtml;
type CreatedAt = St::CreatedAt;
type UpdatedAt = Set<members::updated_at>;
type LinkedTo = St::LinkedTo;
type ContentText = St::ContentText;
type LinkedFrom = St::LinkedFrom;
type PublicationType = St::PublicationType;
type Title = St::Title;
type OctopusId = St::OctopusId;
type Citations = St::Citations;
type Status = St::Status;
type VersionId = St::VersionId;
}
pub struct SetLinkedTo<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLinkedTo<St> {}
impl<St: State> State for SetLinkedTo<St> {
type ContentHtml = St::ContentHtml;
type CreatedAt = St::CreatedAt;
type UpdatedAt = St::UpdatedAt;
type LinkedTo = Set<members::linked_to>;
type ContentText = St::ContentText;
type LinkedFrom = St::LinkedFrom;
type PublicationType = St::PublicationType;
type Title = St::Title;
type OctopusId = St::OctopusId;
type Citations = St::Citations;
type Status = St::Status;
type VersionId = St::VersionId;
}
pub struct SetContentText<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContentText<St> {}
impl<St: State> State for SetContentText<St> {
type ContentHtml = St::ContentHtml;
type CreatedAt = St::CreatedAt;
type UpdatedAt = St::UpdatedAt;
type LinkedTo = St::LinkedTo;
type ContentText = Set<members::content_text>;
type LinkedFrom = St::LinkedFrom;
type PublicationType = St::PublicationType;
type Title = St::Title;
type OctopusId = St::OctopusId;
type Citations = St::Citations;
type Status = St::Status;
type VersionId = St::VersionId;
}
pub struct SetLinkedFrom<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLinkedFrom<St> {}
impl<St: State> State for SetLinkedFrom<St> {
type ContentHtml = St::ContentHtml;
type CreatedAt = St::CreatedAt;
type UpdatedAt = St::UpdatedAt;
type LinkedTo = St::LinkedTo;
type ContentText = St::ContentText;
type LinkedFrom = Set<members::linked_from>;
type PublicationType = St::PublicationType;
type Title = St::Title;
type OctopusId = St::OctopusId;
type Citations = St::Citations;
type Status = St::Status;
type VersionId = St::VersionId;
}
pub struct SetPublicationType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPublicationType<St> {}
impl<St: State> State for SetPublicationType<St> {
type ContentHtml = St::ContentHtml;
type CreatedAt = St::CreatedAt;
type UpdatedAt = St::UpdatedAt;
type LinkedTo = St::LinkedTo;
type ContentText = St::ContentText;
type LinkedFrom = St::LinkedFrom;
type PublicationType = Set<members::publication_type>;
type Title = St::Title;
type OctopusId = St::OctopusId;
type Citations = St::Citations;
type Status = St::Status;
type VersionId = St::VersionId;
}
pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTitle<St> {}
impl<St: State> State for SetTitle<St> {
type ContentHtml = St::ContentHtml;
type CreatedAt = St::CreatedAt;
type UpdatedAt = St::UpdatedAt;
type LinkedTo = St::LinkedTo;
type ContentText = St::ContentText;
type LinkedFrom = St::LinkedFrom;
type PublicationType = St::PublicationType;
type Title = Set<members::title>;
type OctopusId = St::OctopusId;
type Citations = St::Citations;
type Status = St::Status;
type VersionId = St::VersionId;
}
pub struct SetOctopusId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetOctopusId<St> {}
impl<St: State> State for SetOctopusId<St> {
type ContentHtml = St::ContentHtml;
type CreatedAt = St::CreatedAt;
type UpdatedAt = St::UpdatedAt;
type LinkedTo = St::LinkedTo;
type ContentText = St::ContentText;
type LinkedFrom = St::LinkedFrom;
type PublicationType = St::PublicationType;
type Title = St::Title;
type OctopusId = Set<members::octopus_id>;
type Citations = St::Citations;
type Status = St::Status;
type VersionId = St::VersionId;
}
pub struct SetCitations<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCitations<St> {}
impl<St: State> State for SetCitations<St> {
type ContentHtml = St::ContentHtml;
type CreatedAt = St::CreatedAt;
type UpdatedAt = St::UpdatedAt;
type LinkedTo = St::LinkedTo;
type ContentText = St::ContentText;
type LinkedFrom = St::LinkedFrom;
type PublicationType = St::PublicationType;
type Title = St::Title;
type OctopusId = St::OctopusId;
type Citations = Set<members::citations>;
type Status = St::Status;
type VersionId = St::VersionId;
}
pub struct SetStatus<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStatus<St> {}
impl<St: State> State for SetStatus<St> {
type ContentHtml = St::ContentHtml;
type CreatedAt = St::CreatedAt;
type UpdatedAt = St::UpdatedAt;
type LinkedTo = St::LinkedTo;
type ContentText = St::ContentText;
type LinkedFrom = St::LinkedFrom;
type PublicationType = St::PublicationType;
type Title = St::Title;
type OctopusId = St::OctopusId;
type Citations = St::Citations;
type Status = Set<members::status>;
type VersionId = St::VersionId;
}
pub struct SetVersionId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetVersionId<St> {}
impl<St: State> State for SetVersionId<St> {
type ContentHtml = St::ContentHtml;
type CreatedAt = St::CreatedAt;
type UpdatedAt = St::UpdatedAt;
type LinkedTo = St::LinkedTo;
type ContentText = St::ContentText;
type LinkedFrom = St::LinkedFrom;
type PublicationType = St::PublicationType;
type Title = St::Title;
type OctopusId = St::OctopusId;
type Citations = St::Citations;
type Status = St::Status;
type VersionId = Set<members::version_id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct content_html(());
pub struct created_at(());
pub struct updated_at(());
pub struct linked_to(());
pub struct content_text(());
pub struct linked_from(());
pub struct publication_type(());
pub struct title(());
pub struct octopus_id(());
pub struct citations(());
pub struct status(());
pub struct version_id(());
}
}
pub struct PublicationBuilder<S: BosStr, St: publication_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<UriValue<S>>,
Option<Vec<S>>,
Option<S>,
Option<S>,
Option<Datetime>,
Option<UriValue<S>>,
Option<Vec<S>>,
Option<Vec<S>>,
Option<S>,
Option<S>,
Option<S>,
Option<PublicationPublicationType<S>>,
Option<PublicationStatus<S>>,
Option<S>,
Option<Datetime>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Publication<S> {
pub fn new() -> PublicationBuilder<S, publication_state::Empty> {
PublicationBuilder::new()
}
}
impl<S: BosStr> PublicationBuilder<S, publication_state::Empty> {
pub fn new() -> Self {
PublicationBuilder {
_state: PhantomData,
_fields: (
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: publication_state::State> PublicationBuilder<S, St> {
pub fn canonical_url(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_canonical_url(mut self, value: Option<UriValue<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> PublicationBuilder<S, St>
where
St: publication_state::State,
St::Citations: publication_state::IsUnset,
{
pub fn citations(
mut self,
value: impl Into<Vec<S>>,
) -> PublicationBuilder<S, publication_state::SetCitations<St>> {
self._fields.1 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PublicationBuilder<S, St>
where
St: publication_state::State,
St::ContentHtml: publication_state::IsUnset,
{
pub fn content_html(
mut self,
value: impl Into<S>,
) -> PublicationBuilder<S, publication_state::SetContentHtml<St>> {
self._fields.2 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PublicationBuilder<S, St>
where
St: publication_state::State,
St::ContentText: publication_state::IsUnset,
{
pub fn content_text(
mut self,
value: impl Into<S>,
) -> PublicationBuilder<S, publication_state::SetContentText<St>> {
self._fields.3 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PublicationBuilder<S, St>
where
St: publication_state::State,
St::CreatedAt: publication_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> PublicationBuilder<S, publication_state::SetCreatedAt<St>> {
self._fields.4 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: publication_state::State> PublicationBuilder<S, St> {
pub fn doi(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_doi(mut self, value: Option<UriValue<S>>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St> PublicationBuilder<S, St>
where
St: publication_state::State,
St::LinkedFrom: publication_state::IsUnset,
{
pub fn linked_from(
mut self,
value: impl Into<Vec<S>>,
) -> PublicationBuilder<S, publication_state::SetLinkedFrom<St>> {
self._fields.6 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PublicationBuilder<S, St>
where
St: publication_state::State,
St::LinkedTo: publication_state::IsUnset,
{
pub fn linked_to(
mut self,
value: impl Into<Vec<S>>,
) -> PublicationBuilder<S, publication_state::SetLinkedTo<St>> {
self._fields.7 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PublicationBuilder<S, St>
where
St: publication_state::State,
St::OctopusId: publication_state::IsUnset,
{
pub fn octopus_id(
mut self,
value: impl Into<S>,
) -> PublicationBuilder<S, publication_state::SetOctopusId<St>> {
self._fields.8 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: publication_state::State> PublicationBuilder<S, St> {
pub fn owner_orcid(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.9 = value.into();
self
}
pub fn maybe_owner_orcid(mut self, value: Option<S>) -> Self {
self._fields.9 = value;
self
}
}
impl<S: BosStr, St: publication_state::State> PublicationBuilder<S, St> {
pub fn peer_review_of(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_peer_review_of(mut self, value: Option<S>) -> Self {
self._fields.10 = value;
self
}
}
impl<S: BosStr, St> PublicationBuilder<S, St>
where
St: publication_state::State,
St::PublicationType: publication_state::IsUnset,
{
pub fn publication_type(
mut self,
value: impl Into<PublicationPublicationType<S>>,
) -> PublicationBuilder<S, publication_state::SetPublicationType<St>> {
self._fields.11 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PublicationBuilder<S, St>
where
St: publication_state::State,
St::Status: publication_state::IsUnset,
{
pub fn status(
mut self,
value: impl Into<PublicationStatus<S>>,
) -> PublicationBuilder<S, publication_state::SetStatus<St>> {
self._fields.12 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PublicationBuilder<S, St>
where
St: publication_state::State,
St::Title: publication_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<S>,
) -> PublicationBuilder<S, publication_state::SetTitle<St>> {
self._fields.13 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PublicationBuilder<S, St>
where
St: publication_state::State,
St::UpdatedAt: publication_state::IsUnset,
{
pub fn updated_at(
mut self,
value: impl Into<Datetime>,
) -> PublicationBuilder<S, publication_state::SetUpdatedAt<St>> {
self._fields.14 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PublicationBuilder<S, St>
where
St: publication_state::State,
St::VersionId: publication_state::IsUnset,
{
pub fn version_id(
mut self,
value: impl Into<S>,
) -> PublicationBuilder<S, publication_state::SetVersionId<St>> {
self._fields.15 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PublicationBuilder<S, St>
where
St: publication_state::State,
St::ContentHtml: publication_state::IsSet,
St::CreatedAt: publication_state::IsSet,
St::UpdatedAt: publication_state::IsSet,
St::LinkedTo: publication_state::IsSet,
St::ContentText: publication_state::IsSet,
St::LinkedFrom: publication_state::IsSet,
St::PublicationType: publication_state::IsSet,
St::Title: publication_state::IsSet,
St::OctopusId: publication_state::IsSet,
St::Citations: publication_state::IsSet,
St::Status: publication_state::IsSet,
St::VersionId: publication_state::IsSet,
{
pub fn build(self) -> Publication<S> {
Publication {
canonical_url: self._fields.0,
citations: self._fields.1.unwrap(),
content_html: self._fields.2.unwrap(),
content_text: self._fields.3.unwrap(),
created_at: self._fields.4.unwrap(),
doi: self._fields.5,
linked_from: self._fields.6.unwrap(),
linked_to: self._fields.7.unwrap(),
octopus_id: self._fields.8.unwrap(),
owner_orcid: self._fields.9,
peer_review_of: self._fields.10,
publication_type: self._fields.11.unwrap(),
status: self._fields.12.unwrap(),
title: self._fields.13.unwrap(),
updated_at: self._fields.14.unwrap(),
version_id: self._fields.15.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> Publication<S> {
Publication {
canonical_url: self._fields.0,
citations: self._fields.1.unwrap(),
content_html: self._fields.2.unwrap(),
content_text: self._fields.3.unwrap(),
created_at: self._fields.4.unwrap(),
doi: self._fields.5,
linked_from: self._fields.6.unwrap(),
linked_to: self._fields.7.unwrap(),
octopus_id: self._fields.8.unwrap(),
owner_orcid: self._fields.9,
peer_review_of: self._fields.10,
publication_type: self._fields.11.unwrap(),
status: self._fields.12.unwrap(),
title: self._fields.13.unwrap(),
updated_at: self._fields.14.unwrap(),
version_id: self._fields.15.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_social_octosphere_publication() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("social.octosphere.publication"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"Scientific publication record bridged from Octopus.ac via Octosphere. Represents a single version of an Octopus publication.",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("octopusId"),
SmolStr::new_static("versionId"),
SmolStr::new_static("publicationType"),
SmolStr::new_static("title"), SmolStr::new_static("status"),
SmolStr::new_static("contentHtml"),
SmolStr::new_static("contentText"),
SmolStr::new_static("citations"),
SmolStr::new_static("linkedTo"),
SmolStr::new_static("linkedFrom"),
SmolStr::new_static("createdAt"),
SmolStr::new_static("updatedAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("canonicalUrl"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Public Octopus URL for the publication version.",
),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("citations"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"List of citation strings extracted from references.",
),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("contentHtml"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Raw HTML content body."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("contentText"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Plain text content for compact consumption.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"ISO timestamp of when the publication was created in Octopus.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("doi"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Publication version DOI URL, if present.",
),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("linkedFrom"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Publication ids that link to this record.",
),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("linkedTo"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static("Publication ids this record links to."),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("octopusId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Octopus publication id (UUID)."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("ownerOrcid"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"ORCID of the publication owner (if available).",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("peerReviewOf"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Publication id this peer review references, if applicable.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("publicationType"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Octopus publication type."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("status"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Octopus publication status (expected LIVE).",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Publication title.")),
max_length: Some(1000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"ISO timestamp of when the publication was last updated in Octopus.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("versionId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Octopus publication version id (UUID)."),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}