#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
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::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};
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "social.octosphere.publication",
tag = "$type"
)]
pub struct Publication<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub canonical_url: Option<UriValue<'a>>,
#[serde(borrow)]
pub citations: Vec<CowStr<'a>>,
#[serde(borrow)]
pub content_html: CowStr<'a>,
#[serde(borrow)]
pub content_text: CowStr<'a>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub doi: Option<UriValue<'a>>,
#[serde(borrow)]
pub linked_from: Vec<CowStr<'a>>,
#[serde(borrow)]
pub linked_to: Vec<CowStr<'a>>,
#[serde(borrow)]
pub octopus_id: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub owner_orcid: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub peer_review_of: Option<CowStr<'a>>,
#[serde(borrow)]
pub publication_type: PublicationPublicationType<'a>,
#[serde(borrow)]
pub status: PublicationStatus<'a>,
#[serde(borrow)]
pub title: CowStr<'a>,
pub updated_at: Datetime,
#[serde(borrow)]
pub version_id: CowStr<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum PublicationPublicationType<'a> {
ResearchProblem,
Hypothesis,
Protocol,
Analysis,
Interpretation,
RealWorldApplication,
Data,
PeerReview,
Other(CowStr<'a>),
}
impl<'a> PublicationPublicationType<'a> {
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(),
}
}
}
impl<'a> From<&'a str> for PublicationPublicationType<'a> {
fn from(s: &'a str) -> Self {
match s {
"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(CowStr::from(s)),
}
}
}
impl<'a> From<String> for PublicationPublicationType<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"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(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for PublicationPublicationType<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for PublicationPublicationType<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for PublicationPublicationType<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for PublicationPublicationType<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for PublicationPublicationType<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for PublicationPublicationType<'_> {
type Output = PublicationPublicationType<'static>;
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<'a> {
Live,
Draft,
Archived,
Other(CowStr<'a>),
}
impl<'a> PublicationStatus<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Live => "LIVE",
Self::Draft => "DRAFT",
Self::Archived => "ARCHIVED",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for PublicationStatus<'a> {
fn from(s: &'a str) -> Self {
match s {
"LIVE" => Self::Live,
"DRAFT" => Self::Draft,
"ARCHIVED" => Self::Archived,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for PublicationStatus<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"LIVE" => Self::Live,
"DRAFT" => Self::Draft,
"ARCHIVED" => Self::Archived,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for PublicationStatus<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for PublicationStatus<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for PublicationStatus<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for PublicationStatus<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for PublicationStatus<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for PublicationStatus<'_> {
type Output = PublicationStatus<'static>;
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<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Publication<'a>,
}
impl<'a> Publication<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, PublicationRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[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<'de> = PublicationGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<PublicationGetRecordOutput<'_>> for Publication<'_> {
fn from(output: PublicationGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Publication<'_> {
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<'a> LexiconSchema for Publication<'a> {
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 Title;
type PublicationType;
type OctopusId;
type Status;
type ContentText;
type Citations;
type VersionId;
type LinkedFrom;
type CreatedAt;
type LinkedTo;
type UpdatedAt;
type ContentHtml;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Title = Unset;
type PublicationType = Unset;
type OctopusId = Unset;
type Status = Unset;
type ContentText = Unset;
type Citations = Unset;
type VersionId = Unset;
type LinkedFrom = Unset;
type CreatedAt = Unset;
type LinkedTo = Unset;
type UpdatedAt = Unset;
type ContentHtml = Unset;
}
pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTitle<S> {}
impl<S: State> State for SetTitle<S> {
type Title = Set<members::title>;
type PublicationType = S::PublicationType;
type OctopusId = S::OctopusId;
type Status = S::Status;
type ContentText = S::ContentText;
type Citations = S::Citations;
type VersionId = S::VersionId;
type LinkedFrom = S::LinkedFrom;
type CreatedAt = S::CreatedAt;
type LinkedTo = S::LinkedTo;
type UpdatedAt = S::UpdatedAt;
type ContentHtml = S::ContentHtml;
}
pub struct SetPublicationType<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPublicationType<S> {}
impl<S: State> State for SetPublicationType<S> {
type Title = S::Title;
type PublicationType = Set<members::publication_type>;
type OctopusId = S::OctopusId;
type Status = S::Status;
type ContentText = S::ContentText;
type Citations = S::Citations;
type VersionId = S::VersionId;
type LinkedFrom = S::LinkedFrom;
type CreatedAt = S::CreatedAt;
type LinkedTo = S::LinkedTo;
type UpdatedAt = S::UpdatedAt;
type ContentHtml = S::ContentHtml;
}
pub struct SetOctopusId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetOctopusId<S> {}
impl<S: State> State for SetOctopusId<S> {
type Title = S::Title;
type PublicationType = S::PublicationType;
type OctopusId = Set<members::octopus_id>;
type Status = S::Status;
type ContentText = S::ContentText;
type Citations = S::Citations;
type VersionId = S::VersionId;
type LinkedFrom = S::LinkedFrom;
type CreatedAt = S::CreatedAt;
type LinkedTo = S::LinkedTo;
type UpdatedAt = S::UpdatedAt;
type ContentHtml = S::ContentHtml;
}
pub struct SetStatus<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetStatus<S> {}
impl<S: State> State for SetStatus<S> {
type Title = S::Title;
type PublicationType = S::PublicationType;
type OctopusId = S::OctopusId;
type Status = Set<members::status>;
type ContentText = S::ContentText;
type Citations = S::Citations;
type VersionId = S::VersionId;
type LinkedFrom = S::LinkedFrom;
type CreatedAt = S::CreatedAt;
type LinkedTo = S::LinkedTo;
type UpdatedAt = S::UpdatedAt;
type ContentHtml = S::ContentHtml;
}
pub struct SetContentText<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetContentText<S> {}
impl<S: State> State for SetContentText<S> {
type Title = S::Title;
type PublicationType = S::PublicationType;
type OctopusId = S::OctopusId;
type Status = S::Status;
type ContentText = Set<members::content_text>;
type Citations = S::Citations;
type VersionId = S::VersionId;
type LinkedFrom = S::LinkedFrom;
type CreatedAt = S::CreatedAt;
type LinkedTo = S::LinkedTo;
type UpdatedAt = S::UpdatedAt;
type ContentHtml = S::ContentHtml;
}
pub struct SetCitations<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCitations<S> {}
impl<S: State> State for SetCitations<S> {
type Title = S::Title;
type PublicationType = S::PublicationType;
type OctopusId = S::OctopusId;
type Status = S::Status;
type ContentText = S::ContentText;
type Citations = Set<members::citations>;
type VersionId = S::VersionId;
type LinkedFrom = S::LinkedFrom;
type CreatedAt = S::CreatedAt;
type LinkedTo = S::LinkedTo;
type UpdatedAt = S::UpdatedAt;
type ContentHtml = S::ContentHtml;
}
pub struct SetVersionId<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetVersionId<S> {}
impl<S: State> State for SetVersionId<S> {
type Title = S::Title;
type PublicationType = S::PublicationType;
type OctopusId = S::OctopusId;
type Status = S::Status;
type ContentText = S::ContentText;
type Citations = S::Citations;
type VersionId = Set<members::version_id>;
type LinkedFrom = S::LinkedFrom;
type CreatedAt = S::CreatedAt;
type LinkedTo = S::LinkedTo;
type UpdatedAt = S::UpdatedAt;
type ContentHtml = S::ContentHtml;
}
pub struct SetLinkedFrom<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLinkedFrom<S> {}
impl<S: State> State for SetLinkedFrom<S> {
type Title = S::Title;
type PublicationType = S::PublicationType;
type OctopusId = S::OctopusId;
type Status = S::Status;
type ContentText = S::ContentText;
type Citations = S::Citations;
type VersionId = S::VersionId;
type LinkedFrom = Set<members::linked_from>;
type CreatedAt = S::CreatedAt;
type LinkedTo = S::LinkedTo;
type UpdatedAt = S::UpdatedAt;
type ContentHtml = S::ContentHtml;
}
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 Title = S::Title;
type PublicationType = S::PublicationType;
type OctopusId = S::OctopusId;
type Status = S::Status;
type ContentText = S::ContentText;
type Citations = S::Citations;
type VersionId = S::VersionId;
type LinkedFrom = S::LinkedFrom;
type CreatedAt = Set<members::created_at>;
type LinkedTo = S::LinkedTo;
type UpdatedAt = S::UpdatedAt;
type ContentHtml = S::ContentHtml;
}
pub struct SetLinkedTo<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLinkedTo<S> {}
impl<S: State> State for SetLinkedTo<S> {
type Title = S::Title;
type PublicationType = S::PublicationType;
type OctopusId = S::OctopusId;
type Status = S::Status;
type ContentText = S::ContentText;
type Citations = S::Citations;
type VersionId = S::VersionId;
type LinkedFrom = S::LinkedFrom;
type CreatedAt = S::CreatedAt;
type LinkedTo = Set<members::linked_to>;
type UpdatedAt = S::UpdatedAt;
type ContentHtml = S::ContentHtml;
}
pub struct SetUpdatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUpdatedAt<S> {}
impl<S: State> State for SetUpdatedAt<S> {
type Title = S::Title;
type PublicationType = S::PublicationType;
type OctopusId = S::OctopusId;
type Status = S::Status;
type ContentText = S::ContentText;
type Citations = S::Citations;
type VersionId = S::VersionId;
type LinkedFrom = S::LinkedFrom;
type CreatedAt = S::CreatedAt;
type LinkedTo = S::LinkedTo;
type UpdatedAt = Set<members::updated_at>;
type ContentHtml = S::ContentHtml;
}
pub struct SetContentHtml<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetContentHtml<S> {}
impl<S: State> State for SetContentHtml<S> {
type Title = S::Title;
type PublicationType = S::PublicationType;
type OctopusId = S::OctopusId;
type Status = S::Status;
type ContentText = S::ContentText;
type Citations = S::Citations;
type VersionId = S::VersionId;
type LinkedFrom = S::LinkedFrom;
type CreatedAt = S::CreatedAt;
type LinkedTo = S::LinkedTo;
type UpdatedAt = S::UpdatedAt;
type ContentHtml = Set<members::content_html>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct title(());
pub struct publication_type(());
pub struct octopus_id(());
pub struct status(());
pub struct content_text(());
pub struct citations(());
pub struct version_id(());
pub struct linked_from(());
pub struct created_at(());
pub struct linked_to(());
pub struct updated_at(());
pub struct content_html(());
}
}
pub struct PublicationBuilder<'a, S: publication_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<UriValue<'a>>,
Option<Vec<CowStr<'a>>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<UriValue<'a>>,
Option<Vec<CowStr<'a>>>,
Option<Vec<CowStr<'a>>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<PublicationPublicationType<'a>>,
Option<PublicationStatus<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<CowStr<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Publication<'a> {
pub fn new() -> PublicationBuilder<'a, publication_state::Empty> {
PublicationBuilder::new()
}
}
impl<'a> PublicationBuilder<'a, 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,
),
_lifetime: PhantomData,
}
}
}
impl<'a, S: publication_state::State> PublicationBuilder<'a, S> {
pub fn canonical_url(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_canonical_url(mut self, value: Option<UriValue<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> PublicationBuilder<'a, S>
where
S: publication_state::State,
S::Citations: publication_state::IsUnset,
{
pub fn citations(
mut self,
value: impl Into<Vec<CowStr<'a>>>,
) -> PublicationBuilder<'a, publication_state::SetCitations<S>> {
self._fields.1 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PublicationBuilder<'a, S>
where
S: publication_state::State,
S::ContentHtml: publication_state::IsUnset,
{
pub fn content_html(
mut self,
value: impl Into<CowStr<'a>>,
) -> PublicationBuilder<'a, publication_state::SetContentHtml<S>> {
self._fields.2 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PublicationBuilder<'a, S>
where
S: publication_state::State,
S::ContentText: publication_state::IsUnset,
{
pub fn content_text(
mut self,
value: impl Into<CowStr<'a>>,
) -> PublicationBuilder<'a, publication_state::SetContentText<S>> {
self._fields.3 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PublicationBuilder<'a, S>
where
S: publication_state::State,
S::CreatedAt: publication_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> PublicationBuilder<'a, publication_state::SetCreatedAt<S>> {
self._fields.4 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: publication_state::State> PublicationBuilder<'a, S> {
pub fn doi(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_doi(mut self, value: Option<UriValue<'a>>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S> PublicationBuilder<'a, S>
where
S: publication_state::State,
S::LinkedFrom: publication_state::IsUnset,
{
pub fn linked_from(
mut self,
value: impl Into<Vec<CowStr<'a>>>,
) -> PublicationBuilder<'a, publication_state::SetLinkedFrom<S>> {
self._fields.6 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PublicationBuilder<'a, S>
where
S: publication_state::State,
S::LinkedTo: publication_state::IsUnset,
{
pub fn linked_to(
mut self,
value: impl Into<Vec<CowStr<'a>>>,
) -> PublicationBuilder<'a, publication_state::SetLinkedTo<S>> {
self._fields.7 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PublicationBuilder<'a, S>
where
S: publication_state::State,
S::OctopusId: publication_state::IsUnset,
{
pub fn octopus_id(
mut self,
value: impl Into<CowStr<'a>>,
) -> PublicationBuilder<'a, publication_state::SetOctopusId<S>> {
self._fields.8 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: publication_state::State> PublicationBuilder<'a, S> {
pub fn owner_orcid(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.9 = value.into();
self
}
pub fn maybe_owner_orcid(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.9 = value;
self
}
}
impl<'a, S: publication_state::State> PublicationBuilder<'a, S> {
pub fn peer_review_of(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_peer_review_of(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.10 = value;
self
}
}
impl<'a, S> PublicationBuilder<'a, S>
where
S: publication_state::State,
S::PublicationType: publication_state::IsUnset,
{
pub fn publication_type(
mut self,
value: impl Into<PublicationPublicationType<'a>>,
) -> PublicationBuilder<'a, publication_state::SetPublicationType<S>> {
self._fields.11 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PublicationBuilder<'a, S>
where
S: publication_state::State,
S::Status: publication_state::IsUnset,
{
pub fn status(
mut self,
value: impl Into<PublicationStatus<'a>>,
) -> PublicationBuilder<'a, publication_state::SetStatus<S>> {
self._fields.12 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PublicationBuilder<'a, S>
where
S: publication_state::State,
S::Title: publication_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<CowStr<'a>>,
) -> PublicationBuilder<'a, publication_state::SetTitle<S>> {
self._fields.13 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PublicationBuilder<'a, S>
where
S: publication_state::State,
S::UpdatedAt: publication_state::IsUnset,
{
pub fn updated_at(
mut self,
value: impl Into<Datetime>,
) -> PublicationBuilder<'a, publication_state::SetUpdatedAt<S>> {
self._fields.14 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PublicationBuilder<'a, S>
where
S: publication_state::State,
S::VersionId: publication_state::IsUnset,
{
pub fn version_id(
mut self,
value: impl Into<CowStr<'a>>,
) -> PublicationBuilder<'a, publication_state::SetVersionId<S>> {
self._fields.15 = Option::Some(value.into());
PublicationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PublicationBuilder<'a, S>
where
S: publication_state::State,
S::Title: publication_state::IsSet,
S::PublicationType: publication_state::IsSet,
S::OctopusId: publication_state::IsSet,
S::Status: publication_state::IsSet,
S::ContentText: publication_state::IsSet,
S::Citations: publication_state::IsSet,
S::VersionId: publication_state::IsSet,
S::LinkedFrom: publication_state::IsSet,
S::CreatedAt: publication_state::IsSet,
S::LinkedTo: publication_state::IsSet,
S::UpdatedAt: publication_state::IsSet,
S::ContentHtml: publication_state::IsSet,
{
pub fn build(self) -> Publication<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Publication<'a> {
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()
}
}