mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
reconcile types
This commit is contained in:
@@ -99,12 +99,24 @@ impl RpcContext {
|
||||
Ok(Self(seed))
|
||||
}
|
||||
pub async fn package_registry_url(&self) -> Result<Url, Error> {
|
||||
Ok(crate::db::DatabaseModel::new()
|
||||
.server_info()
|
||||
.registry()
|
||||
.get(&mut self.db.handle(), false)
|
||||
.await?
|
||||
.to_owned())
|
||||
Ok(
|
||||
if let Some(market) = crate::db::DatabaseModel::new()
|
||||
.server_info()
|
||||
.package_marketplace()
|
||||
.get(&mut self.db.handle(), false)
|
||||
.await?
|
||||
.to_owned()
|
||||
{
|
||||
market
|
||||
} else {
|
||||
crate::db::DatabaseModel::new()
|
||||
.server_info()
|
||||
.eos_marketplace()
|
||||
.get(&mut self.db.handle(), false)
|
||||
.await?
|
||||
.to_owned()
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
impl Context for RpcContext {
|
||||
|
||||
@@ -39,9 +39,33 @@ impl Database {
|
||||
"http://privacy34kn4ez3y3nijweec6w4g54i3g54sdv7r5mr6soma3w4begyd.onion"
|
||||
.parse()
|
||||
.unwrap(),
|
||||
updating: false,
|
||||
registry: "https://beta-registry-0-3.start9labs.com".parse().unwrap(),
|
||||
status: ServerStatus::Running,
|
||||
eos_marketplace: "https://beta-registry-0-3.start9labs.com".parse().unwrap(),
|
||||
package_marketplace: None,
|
||||
wifi: WifiInfo {
|
||||
ssids: Vec::new(),
|
||||
connected: None,
|
||||
selected: None,
|
||||
},
|
||||
unread_notification_count: 0,
|
||||
specs: ServerSpecs {
|
||||
cpu: Usage {
|
||||
used: 0_f64,
|
||||
total: 1_f64,
|
||||
},
|
||||
disk: Usage {
|
||||
used: 0_f64,
|
||||
total: 1_f64,
|
||||
},
|
||||
memory: Usage {
|
||||
used: 0_f64,
|
||||
total: 1_f64,
|
||||
},
|
||||
},
|
||||
connection_addresses: ConnectionAddresses {
|
||||
tor: Vec::new(),
|
||||
clearnet: Vec::new(),
|
||||
},
|
||||
},
|
||||
package_data: AllPackageData::default(),
|
||||
broken_packages: Vec::new(),
|
||||
@@ -62,9 +86,51 @@ pub struct ServerInfo {
|
||||
version: Version,
|
||||
lan_address: Url,
|
||||
tor_address: Url,
|
||||
updating: bool,
|
||||
registry: Url,
|
||||
status: ServerStatus,
|
||||
eos_marketplace: Url,
|
||||
package_marketplace: Option<Url>,
|
||||
wifi: WifiInfo,
|
||||
unread_notification_count: u64,
|
||||
specs: ServerSpecs,
|
||||
connection_addresses: ConnectionAddresses,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum ServerStatus {
|
||||
Running,
|
||||
Updating,
|
||||
BackingUp,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct WifiInfo {
|
||||
pub ssids: Vec<String>,
|
||||
pub selected: Option<String>,
|
||||
pub connected: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct ServerSpecs {
|
||||
pub cpu: Usage,
|
||||
pub disk: Usage,
|
||||
pub memory: Usage,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct Usage {
|
||||
pub used: f64,
|
||||
pub total: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct ConnectionAddresses {
|
||||
pub tor: Vec<String>,
|
||||
pub clearnet: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, Serialize)]
|
||||
@@ -150,6 +216,8 @@ impl PackageDataEntryModel {
|
||||
pub struct InstalledPackageDataEntry {
|
||||
#[model]
|
||||
pub status: Status,
|
||||
#[model]
|
||||
pub manifest: Manifest,
|
||||
pub system_pointers: Vec<SystemPointerSpec>,
|
||||
#[model]
|
||||
pub current_dependents: IndexMap<PackageId, CurrentDependencyInfo>,
|
||||
@@ -158,13 +226,6 @@ pub struct InstalledPackageDataEntry {
|
||||
#[model]
|
||||
pub interface_addresses: InterfaceAddressMap,
|
||||
}
|
||||
impl InstalledPackageDataEntryModel {
|
||||
pub fn manifest(self) -> ManifestModel {
|
||||
let mut ptr = JsonPointer::from(self);
|
||||
ptr.pop_end();
|
||||
PackageDataEntryModel::from(ptr).manifest()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, HasModel)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
|
||||
@@ -121,6 +121,7 @@ impl HasModel for Dependencies {
|
||||
pub struct DepInfo {
|
||||
pub version: VersionRange,
|
||||
pub optional: Option<String>,
|
||||
pub recommended: bool,
|
||||
pub description: Option<String>,
|
||||
pub critical: bool,
|
||||
#[serde(default)]
|
||||
|
||||
@@ -406,6 +406,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
|
||||
dependency_errors: DependencyErrors::init(&mut tx, &manifest, ¤t_dependencies)
|
||||
.await?,
|
||||
},
|
||||
manifest: manifest.clone(),
|
||||
system_pointers: Vec::new(),
|
||||
current_dependents: {
|
||||
// search required dependencies
|
||||
|
||||
@@ -135,6 +135,8 @@ impl<S: AsRef<str>> AsRef<Path> for InterfaceId<S> {
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct Interface {
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub tor_config: Option<TorConfig>,
|
||||
pub lan_config: Option<IndexMap<Port, LanPortConfig>>,
|
||||
pub ui: bool,
|
||||
|
||||
@@ -113,6 +113,7 @@ pub struct Manifest {
|
||||
pub upstream_repo: Url,
|
||||
pub support_site: Option<Url>,
|
||||
pub marketing_site: Option<Url>,
|
||||
pub donation_url: Option<Url>,
|
||||
#[serde(default)]
|
||||
pub alerts: Alerts,
|
||||
#[model]
|
||||
|
||||
@@ -95,7 +95,8 @@ impl HealthCheck {
|
||||
result: match res {
|
||||
Ok(()) => HealthCheckResultVariant::Success,
|
||||
Err((59, _)) => HealthCheckResultVariant::Disabled,
|
||||
Err((60, _)) => HealthCheckResultVariant::WarmingUp,
|
||||
Err((60, _)) => HealthCheckResultVariant::Starting,
|
||||
Err((61, message)) => HealthCheckResultVariant::Loading { message },
|
||||
Err((_, error)) => HealthCheckResultVariant::Failure { error },
|
||||
},
|
||||
})
|
||||
@@ -123,17 +124,19 @@ impl HealthCheckResult {
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[serde(tag = "result")]
|
||||
pub enum HealthCheckResultVariant {
|
||||
WarmingUp,
|
||||
Disabled,
|
||||
Success,
|
||||
Disabled,
|
||||
Starting,
|
||||
Loading { message: String },
|
||||
Failure { error: String },
|
||||
}
|
||||
impl std::fmt::Display for HealthCheckResultVariant {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
HealthCheckResultVariant::WarmingUp => write!(f, "Warming Up"),
|
||||
HealthCheckResultVariant::Disabled => write!(f, "Disabled"),
|
||||
HealthCheckResultVariant::Success => write!(f, "Succeeded"),
|
||||
HealthCheckResultVariant::Disabled => write!(f, "Disabled"),
|
||||
HealthCheckResultVariant::Starting => write!(f, "Starting"),
|
||||
HealthCheckResultVariant::Loading { message } => write!(f, "Loading ({})", message),
|
||||
HealthCheckResultVariant::Failure { error } => write!(f, "Failed ({})", error),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user