pub mod add_secret;
pub mod archive;
pub mod artifact;
pub mod blob;
pub mod branch;
pub mod branches;
pub mod collaborator;
pub mod compare;
pub mod create;
pub mod delete;
pub mod delete_branch;
pub mod diff;
pub mod fork_status;
pub mod fork_sync;
pub mod get_default_branch;
pub mod hidden_ref;
pub mod issue;
pub mod languages;
pub mod list_secrets;
pub mod log;
pub mod merge;
pub mod merge_check;
pub mod pull;
pub mod remove_secret;
pub mod set_default_branch;
pub mod tag;
pub mod tags;
pub mod tree;
#[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 = "sh.tangled.repo",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Repo<S: BosStr = DefaultStr> {
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<S>,
pub knot: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub labels: Option<Vec<AtUri<S>>>,
pub name: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub source: Option<UriValue<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub spindle: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub topics: Option<Vec<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 RepoGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Repo<S>,
}
impl<S: BosStr> Repo<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, RepoRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct RepoRecord;
impl XrpcResp for RepoRecord {
const NSID: &'static str = "sh.tangled.repo";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = RepoGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<RepoGetRecordOutput<S>> for Repo<S> {
fn from(output: RepoGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Repo<S> {
const NSID: &'static str = "sh.tangled.repo";
type Record = RepoRecord;
}
impl Collection for RepoRecord {
const NSID: &'static str = "sh.tangled.repo";
type Record = RepoRecord;
}
impl<S: BosStr> LexiconSchema for Repo<S> {
fn nsid() -> &'static str {
"sh.tangled.repo"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_repo()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.description {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 140usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("description"),
max: 140usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.description {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count < 1usize {
return Err(ConstraintError::MinGraphemes {
path: ValidationPath::from_field("description"),
min: 1usize,
actual: count,
});
}
}
}
if let Some(ref value) = self.topics {
#[allow(unused_comparisons)]
if value.len() > 50usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("topics"),
max: 50usize,
actual: value.len(),
});
}
}
Ok(())
}
}
pub mod repo_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 Knot;
type CreatedAt;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Knot = Unset;
type CreatedAt = Unset;
type Name = Unset;
}
pub struct SetKnot<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetKnot<St> {}
impl<St: State> State for SetKnot<St> {
type Knot = Set<members::knot>;
type CreatedAt = St::CreatedAt;
type Name = St::Name;
}
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 Knot = St::Knot;
type CreatedAt = Set<members::created_at>;
type Name = St::Name;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type Knot = St::Knot;
type CreatedAt = St::CreatedAt;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct knot(());
pub struct created_at(());
pub struct name(());
}
}
pub struct RepoBuilder<S: BosStr, St: repo_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Datetime>,
Option<S>,
Option<S>,
Option<Vec<AtUri<S>>>,
Option<S>,
Option<UriValue<S>>,
Option<S>,
Option<Vec<S>>,
Option<UriValue<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Repo<S> {
pub fn new() -> RepoBuilder<S, repo_state::Empty> {
RepoBuilder::new()
}
}
impl<S: BosStr> RepoBuilder<S, repo_state::Empty> {
pub fn new() -> Self {
RepoBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RepoBuilder<S, St>
where
St: repo_state::State,
St::CreatedAt: repo_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> RepoBuilder<S, repo_state::SetCreatedAt<St>> {
self._fields.0 = Option::Some(value.into());
RepoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: repo_state::State> RepoBuilder<S, St> {
pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> RepoBuilder<S, St>
where
St: repo_state::State,
St::Knot: repo_state::IsUnset,
{
pub fn knot(mut self, value: impl Into<S>) -> RepoBuilder<S, repo_state::SetKnot<St>> {
self._fields.2 = Option::Some(value.into());
RepoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: repo_state::State> RepoBuilder<S, St> {
pub fn labels(mut self, value: impl Into<Option<Vec<AtUri<S>>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_labels(mut self, value: Option<Vec<AtUri<S>>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> RepoBuilder<S, St>
where
St: repo_state::State,
St::Name: repo_state::IsUnset,
{
pub fn name(mut self, value: impl Into<S>) -> RepoBuilder<S, repo_state::SetName<St>> {
self._fields.4 = Option::Some(value.into());
RepoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: repo_state::State> RepoBuilder<S, St> {
pub fn source(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_source(mut self, value: Option<UriValue<S>>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St: repo_state::State> RepoBuilder<S, St> {
pub fn spindle(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_spindle(mut self, value: Option<S>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St: repo_state::State> RepoBuilder<S, St> {
pub fn topics(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_topics(mut self, value: Option<Vec<S>>) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St: repo_state::State> RepoBuilder<S, St> {
pub fn website(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_website(mut self, value: Option<UriValue<S>>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> RepoBuilder<S, St>
where
St: repo_state::State,
St::Knot: repo_state::IsSet,
St::CreatedAt: repo_state::IsSet,
St::Name: repo_state::IsSet,
{
pub fn build(self) -> Repo<S> {
Repo {
created_at: self._fields.0.unwrap(),
description: self._fields.1,
knot: self._fields.2.unwrap(),
labels: self._fields.3,
name: self._fields.4.unwrap(),
source: self._fields.5,
spindle: self._fields.6,
topics: self._fields.7,
website: self._fields.8,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Repo<S> {
Repo {
created_at: self._fields.0.unwrap(),
description: self._fields.1,
knot: self._fields.2.unwrap(),
labels: self._fields.3,
name: self._fields.4.unwrap(),
source: self._fields.5,
spindle: self._fields.6,
topics: self._fields.7,
website: self._fields.8,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_tangled_repo() -> 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("sh.tangled.repo"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(vec![
SmolStr::new_static("name"),
SmolStr::new_static("knot"),
SmolStr::new_static("createdAt"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
min_graphemes: Some(1usize),
max_graphemes: Some(140usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("knot"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"knot where the repo was created",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("labels"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"List of labels that this repo subscribes to",
)),
items: LexArrayItem::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("name of the repo")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("source"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("source of the repo")),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("spindle"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"CI runner to send jobs to and receive results from",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("topics"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"Topics related to the repo",
)),
items: LexArrayItem::String(LexString {
min_length: Some(1usize),
max_length: Some(50usize),
..Default::default()
}),
max_length: Some(50usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("website"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Any URI related to the repo",
)),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}