Add list_repo and config commands

This commit is contained in:
Sebastian Martinez
2024-09-05 12:37:00 +02:00
parent 3edfcf9192
commit b6711a5698
23 changed files with 332 additions and 146 deletions
+23
View File
@@ -0,0 +1,23 @@
use radicle::crypto::PublicKey;
use serde::Serialize;
use ts_rs::TS;
use radicle::node::config::DefaultSeedingPolicy;
use radicle::node::Alias;
/// Service configuration.
#[derive(Debug, Clone, TS, Serialize)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct Config {
/// Node Public Key in NID format.
#[ts(as = "String")]
pub public_key: PublicKey,
/// Node alias.
#[ts(as = "String")]
pub alias: Alias,
/// Default seeding policy.
#[serde(default)]
#[ts(type = "{ default: 'allow', scope: 'followed' | 'all' } | { default: 'block' }")]
pub seeding_policy: DefaultSeedingPolicy,
}
+2
View File
@@ -0,0 +1,2 @@
pub mod config;
pub mod repo;
+50
View File
@@ -0,0 +1,50 @@
use serde::Serialize;
use serde_json::Value;
use ts_rs::TS;
use radicle::identity::RepoId;
/// Repos info.
#[derive(Serialize, TS)]
#[ts(export)]
pub struct RepoInfo {
pub payloads: SupportedPayloads,
#[ts(type = "({ id: string } | { id: string, alias?: string })[]")]
pub delegates: Vec<Value>,
pub threshold: usize,
#[ts(type = "{ type: 'public' } | { type: 'private', allow?: string[] }")]
pub visibility: radicle::identity::Visibility,
#[ts(as = "String")]
pub rid: RepoId,
pub seeding: usize,
}
#[derive(Serialize, TS)]
#[ts(export)]
pub struct SupportedPayloads {
#[serde(rename = "xyz.radicle.project")]
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
#[ts(type = r#"{
data: {
defaultBranch: string,
description: string,
name: string,
},
meta: {
head: string,
issues: {
open: number,
closed: number,
},
patches: {
open: number,
draft: number,
archived: number,
merged: number,
}
lastCommit: number,
}
}"#)]
pub project: Option<Value>,
}