feat: add dashboard

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2026-03-07 20:31:18 +01:00
parent b439762877
commit d46c365112
21 changed files with 2955 additions and 1367 deletions

View File

@@ -23,6 +23,12 @@ pub struct Artifact {
pub artifact_id: String,
pub slug: String,
pub context: ArtifactContext,
#[serde(default)]
pub source: Option<ArtifactSource>,
#[serde(default)]
pub git_ref: Option<ArtifactRef>,
#[serde(default)]
pub destinations: Vec<ArtifactDestination>,
pub created_at: String,
}
@@ -32,6 +38,37 @@ pub struct ArtifactContext {
pub description: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ArtifactSource {
pub user: Option<String>,
pub email: Option<String>,
pub source_type: Option<String>,
pub run_url: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ArtifactRef {
pub commit_sha: String,
pub branch: Option<String>,
pub commit_message: Option<String>,
pub version: Option<String>,
pub repo_url: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ArtifactDestination {
pub name: String,
pub environment: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OrgMember {
pub user_id: String,
pub username: String,
pub role: String,
pub joined_at: Option<String>,
}
#[derive(Debug, Clone, thiserror::Error)]
pub enum PlatformError {
#[error("not authenticated")]
@@ -68,6 +105,41 @@ pub trait ForestPlatform: Send + Sync {
organisation: &str,
project: &str,
) -> Result<Vec<Artifact>, PlatformError>;
async fn create_organisation(
&self,
access_token: &str,
name: &str,
) -> Result<String, PlatformError>;
async fn list_members(
&self,
access_token: &str,
organisation_id: &str,
) -> Result<Vec<OrgMember>, PlatformError>;
async fn add_member(
&self,
access_token: &str,
organisation_id: &str,
user_id: &str,
role: &str,
) -> Result<OrgMember, PlatformError>;
async fn remove_member(
&self,
access_token: &str,
organisation_id: &str,
user_id: &str,
) -> Result<(), PlatformError>;
async fn update_member_role(
&self,
access_token: &str,
organisation_id: &str,
user_id: &str,
role: &str,
) -> Result<OrgMember, PlatformError>;
}
#[cfg(test)]

View File

@@ -70,6 +70,8 @@ pub struct CachedUser {
/// Cached organisation membership.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CachedOrg {
#[serde(default)]
pub organisation_id: String,
pub name: String,
pub role: String,
}