#[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::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::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "app.gainforest.organization.info",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Info<S: BosStr = DefaultStr> {
pub country: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub cover_image: Option<Data<S>>,
pub created_at: Datetime,
pub display_name: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub logo: Option<Data<S>>,
pub long_description: S,
pub objectives: Vec<S>,
pub short_description: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub start_date: Option<Datetime>,
pub visibility: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub website: Option<UriValue<S>>,
#[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")]
pub struct InfoGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Info<S>,
}
impl<S: BosStr> Info<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, InfoRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct InfoRecord;
impl XrpcResp for InfoRecord {
const NSID: &'static str = "app.gainforest.organization.info";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = InfoGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<InfoGetRecordOutput<S>> for Info<S> {
fn from(output: InfoGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Info<S> {
const NSID: &'static str = "app.gainforest.organization.info";
type Record = InfoRecord;
}
impl Collection for InfoRecord {
const NSID: &'static str = "app.gainforest.organization.info";
type Record = InfoRecord;
}
impl<S: BosStr> LexiconSchema for Info<S> {
fn nsid() -> &'static str {
"app.gainforest.organization.info"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_gainforest_organization_info()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.display_name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 255usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("display_name"),
max: 255usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.display_name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 8usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("display_name"),
min: 8usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.long_description;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 5000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("long_description"),
max: 5000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.long_description;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 50usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("long_description"),
min: 50usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.short_description;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 2000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("short_description"),
max: 2000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.short_description;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 50usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("short_description"),
min: 50usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub mod info_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 Country;
type LongDescription;
type CreatedAt;
type DisplayName;
type ShortDescription;
type Objectives;
type Visibility;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Country = Unset;
type LongDescription = Unset;
type CreatedAt = Unset;
type DisplayName = Unset;
type ShortDescription = Unset;
type Objectives = Unset;
type Visibility = Unset;
}
pub struct SetCountry<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCountry<St> {}
impl<St: State> State for SetCountry<St> {
type Country = Set<members::country>;
type LongDescription = St::LongDescription;
type CreatedAt = St::CreatedAt;
type DisplayName = St::DisplayName;
type ShortDescription = St::ShortDescription;
type Objectives = St::Objectives;
type Visibility = St::Visibility;
}
pub struct SetLongDescription<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLongDescription<St> {}
impl<St: State> State for SetLongDescription<St> {
type Country = St::Country;
type LongDescription = Set<members::long_description>;
type CreatedAt = St::CreatedAt;
type DisplayName = St::DisplayName;
type ShortDescription = St::ShortDescription;
type Objectives = St::Objectives;
type Visibility = St::Visibility;
}
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 Country = St::Country;
type LongDescription = St::LongDescription;
type CreatedAt = Set<members::created_at>;
type DisplayName = St::DisplayName;
type ShortDescription = St::ShortDescription;
type Objectives = St::Objectives;
type Visibility = St::Visibility;
}
pub struct SetDisplayName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDisplayName<St> {}
impl<St: State> State for SetDisplayName<St> {
type Country = St::Country;
type LongDescription = St::LongDescription;
type CreatedAt = St::CreatedAt;
type DisplayName = Set<members::display_name>;
type ShortDescription = St::ShortDescription;
type Objectives = St::Objectives;
type Visibility = St::Visibility;
}
pub struct SetShortDescription<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetShortDescription<St> {}
impl<St: State> State for SetShortDescription<St> {
type Country = St::Country;
type LongDescription = St::LongDescription;
type CreatedAt = St::CreatedAt;
type DisplayName = St::DisplayName;
type ShortDescription = Set<members::short_description>;
type Objectives = St::Objectives;
type Visibility = St::Visibility;
}
pub struct SetObjectives<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetObjectives<St> {}
impl<St: State> State for SetObjectives<St> {
type Country = St::Country;
type LongDescription = St::LongDescription;
type CreatedAt = St::CreatedAt;
type DisplayName = St::DisplayName;
type ShortDescription = St::ShortDescription;
type Objectives = Set<members::objectives>;
type Visibility = St::Visibility;
}
pub struct SetVisibility<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetVisibility<St> {}
impl<St: State> State for SetVisibility<St> {
type Country = St::Country;
type LongDescription = St::LongDescription;
type CreatedAt = St::CreatedAt;
type DisplayName = St::DisplayName;
type ShortDescription = St::ShortDescription;
type Objectives = St::Objectives;
type Visibility = Set<members::visibility>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct country(());
pub struct long_description(());
pub struct created_at(());
pub struct display_name(());
pub struct short_description(());
pub struct objectives(());
pub struct visibility(());
}
}
pub struct InfoBuilder<S: BosStr, St: info_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<Data<S>>,
Option<Datetime>,
Option<S>,
Option<Data<S>>,
Option<S>,
Option<Vec<S>>,
Option<S>,
Option<Datetime>,
Option<S>,
Option<UriValue<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Info<S> {
pub fn new() -> InfoBuilder<S, info_state::Empty> {
InfoBuilder::new()
}
}
impl<S: BosStr> InfoBuilder<S, info_state::Empty> {
pub fn new() -> Self {
InfoBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> InfoBuilder<S, St>
where
St: info_state::State,
St::Country: info_state::IsUnset,
{
pub fn country(mut self, value: impl Into<S>) -> InfoBuilder<S, info_state::SetCountry<St>> {
self._fields.0 = Option::Some(value.into());
InfoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: info_state::State> InfoBuilder<S, St> {
pub fn cover_image(mut self, value: impl Into<Option<Data<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_cover_image(mut self, value: Option<Data<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> InfoBuilder<S, St>
where
St: info_state::State,
St::CreatedAt: info_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> InfoBuilder<S, info_state::SetCreatedAt<St>> {
self._fields.2 = Option::Some(value.into());
InfoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> InfoBuilder<S, St>
where
St: info_state::State,
St::DisplayName: info_state::IsUnset,
{
pub fn display_name(
mut self,
value: impl Into<S>,
) -> InfoBuilder<S, info_state::SetDisplayName<St>> {
self._fields.3 = Option::Some(value.into());
InfoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: info_state::State> InfoBuilder<S, St> {
pub fn logo(mut self, value: impl Into<Option<Data<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_logo(mut self, value: Option<Data<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> InfoBuilder<S, St>
where
St: info_state::State,
St::LongDescription: info_state::IsUnset,
{
pub fn long_description(
mut self,
value: impl Into<S>,
) -> InfoBuilder<S, info_state::SetLongDescription<St>> {
self._fields.5 = Option::Some(value.into());
InfoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> InfoBuilder<S, St>
where
St: info_state::State,
St::Objectives: info_state::IsUnset,
{
pub fn objectives(
mut self,
value: impl Into<Vec<S>>,
) -> InfoBuilder<S, info_state::SetObjectives<St>> {
self._fields.6 = Option::Some(value.into());
InfoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> InfoBuilder<S, St>
where
St: info_state::State,
St::ShortDescription: info_state::IsUnset,
{
pub fn short_description(
mut self,
value: impl Into<S>,
) -> InfoBuilder<S, info_state::SetShortDescription<St>> {
self._fields.7 = Option::Some(value.into());
InfoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: info_state::State> InfoBuilder<S, St> {
pub fn start_date(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_start_date(mut self, value: Option<Datetime>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> InfoBuilder<S, St>
where
St: info_state::State,
St::Visibility: info_state::IsUnset,
{
pub fn visibility(
mut self,
value: impl Into<S>,
) -> InfoBuilder<S, info_state::SetVisibility<St>> {
self._fields.9 = Option::Some(value.into());
InfoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: info_state::State> InfoBuilder<S, St> {
pub fn website(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_website(mut self, value: Option<UriValue<S>>) -> Self {
self._fields.10 = value;
self
}
}
impl<S: BosStr, St> InfoBuilder<S, St>
where
St: info_state::State,
St::Country: info_state::IsSet,
St::LongDescription: info_state::IsSet,
St::CreatedAt: info_state::IsSet,
St::DisplayName: info_state::IsSet,
St::ShortDescription: info_state::IsSet,
St::Objectives: info_state::IsSet,
St::Visibility: info_state::IsSet,
{
pub fn build(self) -> Info<S> {
Info {
country: self._fields.0.unwrap(),
cover_image: self._fields.1,
created_at: self._fields.2.unwrap(),
display_name: self._fields.3.unwrap(),
logo: self._fields.4,
long_description: self._fields.5.unwrap(),
objectives: self._fields.6.unwrap(),
short_description: self._fields.7.unwrap(),
start_date: self._fields.8,
visibility: self._fields.9.unwrap(),
website: self._fields.10,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Info<S> {
Info {
country: self._fields.0.unwrap(),
cover_image: self._fields.1,
created_at: self._fields.2.unwrap(),
display_name: self._fields.3.unwrap(),
logo: self._fields.4,
long_description: self._fields.5.unwrap(),
objectives: self._fields.6.unwrap(),
short_description: self._fields.7.unwrap(),
start_date: self._fields.8,
visibility: self._fields.9.unwrap(),
website: self._fields.10,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_gainforest_organization_info() -> 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("app.gainforest.organization.info"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static("A declaration of an organization or project"),
),
key: Some(CowStr::new_static("literal:self")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("displayName"),
SmolStr::new_static("shortDescription"),
SmolStr::new_static("longDescription"),
SmolStr::new_static("objectives"),
SmolStr::new_static("country"),
SmolStr::new_static("visibility"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("country"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The country of the organization or project in two letter code (ISO 3166-1 alpha-2)",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("coverImage"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"app.gainforest.common.defs#smallImage",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The date and time of the creation of the record",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("displayName"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The name of the organization or project",
),
),
min_length: Some(8usize),
max_length: Some(255usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("logo"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"app.gainforest.common.defs#smallImage",
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("longDescription"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The long description of the organization or project in richtext",
),
),
min_length: Some(50usize),
max_length: Some(5000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("objectives"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"The objectives of the organization or project",
),
),
items: LexArrayItem::String(LexString {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("shortDescription"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The description of the organization or project",
),
),
min_length: Some(50usize),
max_length: Some(2000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("startDate"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The start date of the organization or project",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("visibility"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The visibility of the organization or project in the Green Globe",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("website"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The website of the organization or project",
),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}