export patchdb types

This commit is contained in:
Aiden McClelland
2024-03-27 13:58:42 -06:00
parent 5698b830ed
commit f770d5072e
81 changed files with 646 additions and 441 deletions

452
core/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -32,7 +32,7 @@ sqlx = { version = "0.7.2", features = [
"postgres",
] }
ssh-key = "0.6.2"
ts-rs = "7"
ts-rs = { git = "https://github.com/dr-bonez/ts-rs.git", branch = "feature/top-level-type-override" } # "8"
thiserror = "1.0"
tokio = { version = "1", features = ["full"] }
torut = { git = "https://github.com/Start9Labs/torut.git", branch = "update/dependencies" }

View File

@@ -6,11 +6,13 @@ use color_eyre::eyre::eyre;
use reqwest::header::CONTENT_TYPE;
use serde::{Deserialize, Serialize};
use tokio::io::{AsyncRead, AsyncReadExt};
use ts_rs::TS;
use yasi::InternedString;
use crate::{mime, Error, ErrorKind, ResultExt};
#[derive(Clone)]
#[derive(Clone, TS)]
#[ts(type = "string")]
pub struct DataUrl<'a> {
mime: InternedString,
data: Cow<'a, [u8]>,

View File

@@ -2,10 +2,12 @@ use std::path::Path;
use std::str::FromStr;
use serde::{Deserialize, Serialize};
use ts_rs::TS;
use crate::{Id, InvalidId};
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, ts_rs::TS)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, TS)]
#[ts(type = "string")]
pub struct ActionId(Id);
impl FromStr for ActionId {
type Err = InvalidId;

View File

@@ -2,10 +2,12 @@ use std::path::Path;
use std::str::FromStr;
use serde::{Deserialize, Deserializer, Serialize};
use ts_rs::TS;
use crate::{Id, InvalidId};
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, ts_rs::TS)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, TS)]
#[ts(type = "string")]
pub struct HealthCheckId(Id);
impl std::fmt::Display for HealthCheckId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {

View File

@@ -2,11 +2,13 @@ use std::path::Path;
use std::str::FromStr;
use serde::{Deserialize, Deserializer, Serialize};
use ts_rs::TS;
use yasi::InternedString;
use crate::{Id, InvalidId};
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, TS)]
#[ts(type = "string")]
pub struct HostId(Id);
impl FromStr for HostId {
type Err = InvalidId;

View File

@@ -3,10 +3,12 @@ use std::path::Path;
use std::str::FromStr;
use serde::{Deserialize, Deserializer, Serialize};
use ts_rs::TS;
use crate::{Id, InvalidId, PackageId, Version};
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, ts_rs::TS)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, TS)]
#[ts(type = "string")]
pub struct ImageId(Id);
impl AsRef<Path> for ImageId {
fn as_ref(&self) -> &Path {

View File

@@ -28,8 +28,8 @@ lazy_static::lazy_static! {
pub static ref SYSTEM_ID: Id = Id(InternedString::intern("x_system"));
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default, ts_rs::TS)]
pub struct Id(#[ts(type = "string")] InternedString);
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct Id(InternedString);
impl TryFrom<InternedString> for Id {
type Error = InvalidId;
fn try_from(value: InternedString) -> Result<Self, Self::Error> {

View File

@@ -12,6 +12,7 @@ lazy_static::lazy_static! {
pub static ref SYSTEM_PACKAGE_ID: PackageId = PackageId(SYSTEM_ID.clone());
}
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, TS)]
#[ts(type = "string")]
pub struct PackageId(Id);
impl FromStr for PackageId {
type Err = InvalidId;

View File

@@ -2,10 +2,12 @@ use std::borrow::Borrow;
use std::path::Path;
use serde::{Deserialize, Deserializer, Serialize};
use ts_rs::TS;
use crate::Id;
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, TS)]
#[ts(type = "string")]
pub enum VolumeId {
Backup,
Custom(Id),

View File

@@ -175,7 +175,7 @@ tracing-futures = "0.2.5"
tracing-journald = "0.3.0"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
trust-dns-server = "0.23.1"
ts-rs = "8.1.0"
ts-rs = { git = "https://github.com/dr-bonez/ts-rs.git", branch = "feature/top-level-type-override" } # "8.1.0"
typed-builder = "0.18.0"
url = { version = "2.4.1", features = ["serde"] }
urlencoding = "2.1.3"

View File

@@ -1,3 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AlpnInfo } from "./AlpnInfo";
export type AddSslOptions = { scheme: string | null, preferredExternalPort: number, addXForwardedHeaders: boolean | null, };
export type AddSslOptions = { scheme: string, preferredExternalPort: number, alpn: AlpnInfo, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type Alerts = { install: string | null, uninstall: string | null, restore: string | null, start: string | null, stop: string | null, };

View File

@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { PackageDataEntry } from "./PackageDataEntry";
import type { PackageId } from "./PackageId";
export type AllPackageData = { [key: PackageId]: PackageDataEntry };

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { MaybeUtf8String } from "./MaybeUtf8String";
export type AlpnInfo = "reflect" | { "specified": Array<MaybeUtf8String> };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type BackupProgress = { complete: boolean, };

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { BindOptions } from "./BindOptions";
export type BindInfo = { options: BindOptions, assignedLanPort: number | null, };

View File

@@ -1,5 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AddSslOptions } from "./AddSslOptions";
import type { BindOptionsSecure } from "./BindOptionsSecure";
export type BindOptions = { scheme: string | null, preferredExternalPort: number, addSsl: AddSslOptions | null, secure: BindOptionsSecure | null, };
export type BindOptions = { scheme: string, preferredExternalPort: number, addSsl: AddSslOptions | null, secure: boolean, ssl: boolean, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ConnectionAddresses = { tor: Array<string>, clearnet: Array<string>, };

View File

@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { CurrentDependencyInfo } from "./CurrentDependencyInfo";
import type { PackageId } from "./PackageId";
export type CurrentDependencies = { [key: PackageId]: CurrentDependencyInfo };

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { DataUrl } from "./DataUrl";
export type CurrentDependencyInfo = { title: string, icon: DataUrl, registry: string, versionSpec: string, } & ({ "kind": "exists" } | { "kind": "running", healthChecks: string[], });

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type DataUrl = string;

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type DepInfo = { description: string | null, optional: boolean, };

View File

@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { DepInfo } from "./DepInfo";
import type { PackageId } from "./PackageId";
export type Dependencies = { [key: PackageId]: DepInfo };

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { PackageId } from "./PackageId";
export type DependencyConfigErrors = { [key: PackageId]: string };

View File

@@ -1,3 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type DependencyRequirement = { "kind": "running", id: string, healthChecks: string[], versionSpec: string, url: string, } | { "kind": "exists", id: string, versionSpec: string, url: string, };
export type DependencyRequirement = { "kind": "running", id: string, healthChecks: string[], versionSpec: string, registry: string, } | { "kind": "exists", id: string, versionSpec: string, registry: string, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type Description = { short: string, long: string, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type Duration = string;

View File

@@ -1,3 +0,0 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ExposeUiParams = { "type": "object", value: {[key: string]: ExposeUiParams}, } | { "type": "string", path: string, description: string | null, masked: boolean, copyable: boolean | null, qr: boolean | null, };

View File

@@ -1,3 +0,0 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ExposedUI = { "type": "object", value: {[key: string]: ExposedUI}, description: string | null, } | { "type": "string", path: string, description: string | null, masked: boolean, copyable: boolean | null, qr: boolean | null, };

View File

@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { NamedProgress } from "./NamedProgress";
import type { Progress } from "./Progress";
export type FullProgress = { overall: Progress, phases: Array<NamedProgress>, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type Governor = string;

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type HardwareRequirements = { device: { [key: string]: string }, ram: bigint | null, arch: Array<string> | null, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type HealthCheckId = string;

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type HealthCheckResult = { "result": "success" } | { "result": "disabled" } | { "result": "starting" } | { "result": "loading", message: string, } | { "result": "failure", error: string, };

View File

@@ -0,0 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { BindInfo } from "./BindInfo";
import type { HostAddress } from "./HostAddress";
import type { HostKind } from "./HostKind";
export type Host = { kind: HostKind, bindings: { [key: number]: BindInfo }, addresses: Array<HostAddress>, primary: HostAddress | null, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type HostAddress = { "kind": "onion", address: string, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type HostId = string;

View File

@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Host } from "./Host";
import type { HostId } from "./HostId";
export type HostInfo = { [key: HostId]: Host };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type HostKind = "multi";

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ImageId = string;

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Manifest } from "./Manifest";
export type InstalledState = { manifest: Manifest, };

View File

@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FullProgress } from "./FullProgress";
import type { Manifest } from "./Manifest";
export type InstallingInfo = { newManifest: Manifest, progress: FullProgress, };

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { InstallingInfo } from "./InstallingInfo";
export type InstallingState = { installingInfo: InstallingInfo, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type IpInfo = { ipv4Range: string | null, ipv4: string | null, ipv6Range: string | null, ipv6: string | null, };

View File

@@ -0,0 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Duration } from "./Duration";
import type { HealthCheckId } from "./HealthCheckId";
import type { HealthCheckResult } from "./HealthCheckResult";
export type MainStatus = { "status": "stopped" } | { "status": "restarting" } | { "status": "stopping", timeout: Duration, } | { "status": "starting" } | { "status": "running", started: string, health: { [key: HealthCheckId]: HealthCheckResult }, } | { "status": "backingUp", started: string | null, health: { [key: HealthCheckId]: HealthCheckResult }, };

View File

@@ -0,0 +1,10 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Alerts } from "./Alerts";
import type { Dependencies } from "./Dependencies";
import type { Description } from "./Description";
import type { HardwareRequirements } from "./HardwareRequirements";
import type { ImageId } from "./ImageId";
import type { PackageId } from "./PackageId";
import type { VolumeId } from "./VolumeId";
export type Manifest = { id: PackageId, title: string, version: string, releaseNotes: string, license: string, replaces: Array<string>, wrapperRepo: string, upstreamRepo: string, supportSite: string, marketingSite: string, donationUrl: string | null, description: Description, images: Array<ImageId>, assets: Array<VolumeId>, volumes: Array<VolumeId>, alerts: Alerts, dependencies: Dependencies, hardwareRequirements: HardwareRequirements, gitHash: string | null, osVersion: string, hasConfig: boolean, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type MaybeUtf8String = string | number[];

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Progress } from "./Progress";
export type NamedProgress = { name: string, progress: Progress, };

View File

@@ -0,0 +1,8 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { CurrentDependencies } from "./CurrentDependencies";
import type { DataUrl } from "./DataUrl";
import type { HostInfo } from "./HostInfo";
import type { PackageState } from "./PackageState";
import type { Status } from "./Status";
export type PackageDataEntry = { stateInfo: PackageState, status: Status, marketplaceUrl: string | null, developerKey: string, icon: DataUrl, lastBackup: string | null, currentDependencies: CurrentDependencies, hosts: HostInfo, storeExposedDependents: string[], };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type PackageId = string;

View File

@@ -0,0 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { InstalledState } from "./InstalledState";
import type { InstallingState } from "./InstallingState";
import type { UpdatingState } from "./UpdatingState";
export type PackageState = { "state": "installing" } & InstallingState | { "state": "restoring" } & InstallingState | { "state": "updating" } & UpdatingState | { "state": "installed" } & InstalledState | { "state": "removing" } & InstalledState;

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type Progress = boolean | { done: bigint, total: bigint | null, };

View File

@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AllPackageData } from "./AllPackageData";
import type { ServerInfo } from "./ServerInfo";
export type Public = { serverInfo: ServerInfo, packageData: AllPackageData, ui: any, };

View File

@@ -0,0 +1,16 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ConnectionAddresses } from "./ConnectionAddresses";
import type { Governor } from "./Governor";
import type { IpInfo } from "./IpInfo";
import type { ServerStatus } from "./ServerStatus";
import type { WifiInfo } from "./WifiInfo";
export type ServerInfo = { arch: string, platform: string, id: string, hostname: string, version: string, lastBackup: string | null,
/**
* Used in the wifi to determine the region to set the system to
*/
lastWifiRegion: string | null, eosVersionCompat: string, lanAddress: string, onionAddress: string,
/**
* for backwards compatibility
*/
torAddress: string, ipInfo: { [key: string]: IpInfo }, statusInfo: ServerStatus, wifi: WifiInfo, unreadNotificationCount: bigint, connectionAddresses: ConnectionAddresses, passwordHash: string, pubkey: string, caFingerprint: string, ntpSynced: boolean, zram: boolean, governor: Governor | null, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ServerSpecs = { cpu: string, disk: string, memory: string, };

View File

@@ -0,0 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { BackupProgress } from "./BackupProgress";
import type { PackageId } from "./PackageId";
import type { UpdateProgress } from "./UpdateProgress";
export type ServerStatus = { backupProgress: { [key: PackageId]: BackupProgress } | null, updated: boolean, updateProgress: UpdateProgress | null, shuttingDown: boolean, restarting: boolean, };

View File

@@ -1,3 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { DependencyConfigErrors } from "./DependencyConfigErrors";
import type { MainStatus } from "./MainStatus";
export type Status = "running" | "stopped";
export type Status = { configured: boolean, main: MainStatus, dependencyConfigErrors: DependencyConfigErrors, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type UpdateProgress = { size: bigint | null, downloaded: bigint, };

View File

@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { InstallingInfo } from "./InstallingInfo";
import type { Manifest } from "./Manifest";
export type UpdatingState = { manifest: Manifest, installingInfo: InstallingInfo, };

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type VolumeId = string;

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type WifiInfo = { ssids: Array<string>, selected: string | null, connected: string | null, };

View File

@@ -2,6 +2,7 @@ use std::collections::BTreeMap;
use patch_db::HasModel;
use serde::{Deserialize, Serialize};
use ts_rs::TS;
use crate::account::AccountInfo;
use crate::auth::Sessions;

View File

@@ -10,13 +10,15 @@ use reqwest::Url;
use serde::{Deserialize, Serialize};
use ts_rs::TS;
use crate::net::host::HostInfo;
use crate::prelude::*;
use crate::progress::FullProgress;
use crate::s9pk::manifest::Manifest;
use crate::status::Status;
use crate::{net::host::HostInfo, util::serde::Pem};
use crate::util::serde::Pem;
#[derive(Debug, Default, Deserialize, Serialize)]
#[derive(Debug, Default, Deserialize, Serialize, TS)]
#[ts(export)]
pub struct AllPackageData(pub BTreeMap<PackageId, PackageDataEntry>);
impl Map for AllPackageData {
type Key = PackageId;
@@ -35,10 +37,11 @@ pub enum ManifestPreference {
New,
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "state")]
#[model = "Model<Self>"]
#[ts(export)]
pub enum PackageState {
Installing(InstallingState),
Restoring(InstallingState),
@@ -257,51 +260,57 @@ impl Model<PackageState> {
}
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct InstallingState {
pub installing_info: InstallingInfo,
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct UpdatingState {
pub manifest: Manifest,
pub installing_info: InstallingInfo,
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct InstalledState {
pub manifest: Manifest,
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct InstallingInfo {
pub new_manifest: Manifest,
pub progress: FullProgress,
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct PackageDataEntry {
pub state_info: PackageState,
pub status: Status,
#[ts(type = "string | null")]
pub marketplace_url: Option<Url>,
#[ts(type = "string")]
pub developer_key: Pem<ed25519_dalek::VerifyingKey>,
pub icon: DataUrl<'static>,
#[ts(type = "string | null")]
pub last_backup: Option<DateTime<Utc>>,
pub dependency_info: BTreeMap<PackageId, StaticDependencyInfo>,
pub current_dependencies: CurrentDependencies,
pub interface_addresses: InterfaceAddressMap,
pub hosts: HostInfo,
pub store_exposed_ui: StoreExposedUI,
#[ts(type = "string[]")]
pub store_exposed_dependents: Vec<JsonPointer>,
}
impl AsRef<PackageDataEntry> for PackageDataEntry {
@@ -310,52 +319,8 @@ impl AsRef<PackageDataEntry> for PackageDataEntry {
}
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[model = "Model<Self>"]
pub struct ExposedDependent {
path: String,
title: String,
description: Option<String>,
masked: Option<bool>,
copyable: Option<bool>,
qr: Option<bool>,
}
#[derive(Default, Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StoreExposedUI(pub BTreeMap<InternedString, ExposedUI>);
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "type")]
#[derive(Debug, Clone, Default, Deserialize, Serialize, TS)]
#[ts(export)]
pub enum ExposedUI {
Object {
#[ts(type = "{[key: string]: ExposedUI}")]
value: BTreeMap<String, ExposedUI>,
#[serde(default)]
#[ts(type = "string | null")]
description: String,
},
String {
#[ts(type = "string")]
path: JsonPointer,
description: Option<String>,
masked: bool,
copyable: Option<bool>,
qr: Option<bool>,
},
}
impl Default for ExposedUI {
fn default() -> Self {
ExposedUI::Object {
value: BTreeMap::new(),
description: "".to_string(),
}
}
}
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
pub struct CurrentDependencies(pub BTreeMap<PackageId, CurrentDependencyInfo>);
impl CurrentDependencies {
pub fn map(
@@ -379,31 +344,26 @@ impl Map for CurrentDependencies {
}
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct StaticDependencyInfo {
pub struct CurrentDependencyInfo {
#[serde(flatten)]
pub kind: CurrentDependencyKind,
pub title: String,
pub icon: DataUrl<'static>,
#[ts(type = "string")]
pub registry: Url,
#[ts(type = "string")]
pub version_spec: VersionRange,
}
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "kind")]
pub enum CurrentDependencyInfo {
#[serde(rename_all = "camelCase")]
Exists {
#[ts(type = "string")]
url: Url,
#[ts(type = "string")]
version_spec: VersionRange,
},
pub enum CurrentDependencyKind {
Exists,
#[serde(rename_all = "camelCase")]
Running {
#[ts(type = "string")]
url: Url,
#[ts(type = "string")]
version_spec: VersionRange,
#[serde(default)]
#[ts(type = "string[]")]
health_checks: BTreeSet<HealthCheckId>,

View File

@@ -13,6 +13,7 @@ use patch_db::{HasModel, Value};
use reqwest::Url;
use serde::{Deserialize, Serialize};
use torut::onion::OnionAddressV3;
use ts_rs::TS;
use crate::account::AccountInfo;
use crate::db::model::package::AllPackageData;
@@ -23,13 +24,14 @@ use crate::util::Version;
use crate::version::{Current, VersionT};
use crate::{ARCH, PLATFORM};
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
// #[macro_debug]
#[ts(export)]
pub struct Public {
pub server_info: ServerInfo,
pub package_data: AllPackageData,
#[ts(type = "any")]
pub ui: Value,
}
impl Public {
@@ -101,24 +103,34 @@ fn get_platform() -> InternedString {
(&*PLATFORM).into()
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct ServerInfo {
#[serde(default = "get_arch")]
#[ts(type = "string")]
pub arch: InternedString,
#[serde(default = "get_platform")]
#[ts(type = "string")]
pub platform: InternedString,
pub id: String,
pub hostname: String,
#[ts(type = "string")]
pub version: Version,
#[ts(type = "string | null")]
pub last_backup: Option<DateTime<Utc>>,
/// Used in the wifi to determine the region to set the system to
#[ts(type = "string | null")]
pub last_wifi_region: Option<CountryCode>,
#[ts(type = "string")]
pub eos_version_compat: VersionRange,
#[ts(type = "string")]
pub lan_address: Url,
#[ts(type = "string")]
pub onion_address: OnionAddressV3,
/// for backwards compatibility
#[ts(type = "string")]
pub tor_address: Url,
pub ip_info: BTreeMap<String, IpInfo>,
#[serde(default)]
@@ -136,12 +148,15 @@ pub struct ServerInfo {
pub governor: Option<Governor>,
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct IpInfo {
#[ts(type = "string | null")]
pub ipv4_range: Option<Ipv4Net>,
pub ipv4: Option<Ipv4Addr>,
#[ts(type = "string | null")]
pub ipv6_range: Option<Ipv6Net>,
pub ipv6: Option<Ipv6Addr>,
}
@@ -158,15 +173,17 @@ impl IpInfo {
}
}
#[derive(Debug, Default, Deserialize, Serialize, HasModel)]
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[model = "Model<Self>"]
#[ts(export)]
pub struct BackupProgress {
pub complete: bool,
}
#[derive(Debug, Default, Deserialize, Serialize, HasModel)]
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct ServerStatus {
pub backup_progress: Option<BTreeMap<PackageId, BackupProgress>>,
pub updated: bool,
@@ -177,33 +194,37 @@ pub struct ServerStatus {
pub restarting: bool,
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct UpdateProgress {
pub size: Option<u64>,
pub downloaded: u64,
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct WifiInfo {
pub ssids: Vec<String>,
pub selected: Option<String>,
pub connected: Option<String>,
}
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct ServerSpecs {
pub cpu: String,
pub disk: String,
pub memory: String,
}
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct ConnectionAddresses {
pub tor: Vec<String>,
pub clearnet: Vec<String>,

View File

@@ -2,18 +2,16 @@ use std::collections::BTreeMap;
use std::time::Duration;
use clap::Parser;
use emver::VersionRange;
use models::{OptionExt, PackageId};
use models::PackageId;
use rpc_toolkit::{command, from_fn_async, Empty, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize};
use tracing::instrument;
use ts_rs::TS;
use crate::config::{Config, ConfigSpec, ConfigureContext};
use crate::context::RpcContext;
use crate::db::model::package::CurrentDependencies;
use crate::db::model::Database;
use crate::prelude::*;
use crate::s9pk::manifest::Manifest;
use crate::status::DependencyConfigErrors;
use crate::Error;
@@ -21,8 +19,9 @@ pub fn dependency() -> ParentHandler {
ParentHandler::new().subcommand("configure", configure())
}
#[derive(Clone, Debug, Default, Deserialize, Serialize, HasModel)]
#[derive(Clone, Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[model = "Model<Self>"]
#[ts(export)]
pub struct Dependencies(pub BTreeMap<PackageId, DepInfo>);
impl Map for Dependencies {
type Key = PackageId;
@@ -35,27 +34,13 @@ impl Map for Dependencies {
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "type")]
pub enum DependencyRequirement {
OptIn { how: String },
OptOut { how: String },
Required,
}
impl DependencyRequirement {
pub fn required(&self) -> bool {
matches!(self, &DependencyRequirement::Required)
}
}
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
#[derive(Clone, Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct DepInfo {
pub version: VersionRange,
pub requirement: DependencyRequirement,
pub description: Option<String>,
pub optional: bool,
}
#[derive(Deserialize, Serialize, Parser)]

View File

@@ -1,9 +1,14 @@
use serde::{Deserialize, Serialize};
use torut::onion::OnionAddressV3;
use ts_rs::TS;
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, TS)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "kind")]
#[ts(export)]
pub enum HostAddress {
Onion { address: OnionAddressV3 },
Onion {
#[ts(type = "string")]
address: OnionAddressV3,
},
}

View File

@@ -1,12 +1,14 @@
use imbl_value::InternedString;
use serde::{Deserialize, Serialize};
use ts_rs::TS;
use crate::net::forward::AvailablePorts;
use crate::net::vhost::AlpnInfo;
use crate::prelude::*;
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct BindInfo {
pub options: BindOptions,
pub assigned_lan_port: Option<u16>,
@@ -49,9 +51,11 @@ impl BindInfo {
}
}
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct BindOptions {
#[ts(type = "string")]
pub scheme: InternedString,
pub preferred_external_port: u16,
pub add_ssl: Option<AddSslOptions>,
@@ -59,9 +63,11 @@ pub struct BindOptions {
pub ssl: bool,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct AddSslOptions {
#[ts(type = "string")]
pub scheme: InternedString,
pub preferred_external_port: u16,
// #[serde(default)]

View File

@@ -3,6 +3,7 @@ use std::collections::{BTreeMap, BTreeSet};
use imbl_value::InternedString;
use models::HostId;
use serde::{Deserialize, Serialize};
use ts_rs::TS;
use crate::net::forward::AvailablePorts;
use crate::net::host::address::HostAddress;
@@ -12,9 +13,10 @@ use crate::prelude::*;
pub mod address;
pub mod binding;
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct Host {
pub kind: HostKind,
pub bindings: BTreeMap<u16, BindInfo>,
@@ -37,16 +39,18 @@ impl Host {
}
}
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub enum HostKind {
Multi,
// Single,
// Static,
}
#[derive(Debug, Default, Deserialize, Serialize, HasModel)]
#[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)]
#[model = "Model<Self>"]
#[ts(export)]
pub struct HostInfo(BTreeMap<HostId, Host>);
impl Map for HostInfo {

View File

@@ -17,6 +17,7 @@ use tokio_rustls::rustls::server::Acceptor;
use tokio_rustls::rustls::{RootCertStore, ServerConfig};
use tokio_rustls::{LazyConfigAcceptor, TlsConnector};
use tracing::instrument;
use ts_rs::TS;
use crate::prelude::*;
use crate::util::io::{BackTrackingReader, TimeoutStream};
@@ -80,8 +81,9 @@ struct TargetInfo {
connect_ssl: Result<(), AlpnInfo>,
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub enum AlpnInfo {
Reflect,
Specified(Vec<MaybeUtf8String>),

View File

@@ -9,6 +9,7 @@ use itertools::Itertools;
use serde::{Deserialize, Serialize};
use tokio::io::{AsyncSeek, AsyncWrite};
use tokio::sync::{mpsc, watch};
use ts_rs::TS;
use crate::db::model::DatabaseModel;
use crate::prelude::*;
@@ -19,7 +20,7 @@ lazy_static::lazy_static! {
static ref BYTES: ProgressStyle = ProgressStyle::with_template("{spinner} {wide_msg} [{bytes}/?] [{binary_bytes_per_sec} {elapsed}]").unwrap();
}
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord, TS)]
#[serde(untagged)]
pub enum Progress {
Complete(bool),
@@ -126,13 +127,16 @@ impl std::ops::AddAssign<u64> for Progress {
}
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[ts(export)]
pub struct NamedProgress {
#[ts(type = "string")]
pub name: InternedString,
pub progress: Progress,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[ts(export)]
pub struct FullProgress {
pub overall: Progress,
pub phases: Vec<NamedProgress>,

View File

@@ -1,13 +1,10 @@
use std::{borrow::Borrow, collections::BTreeMap};
use clap::Parser;
use imbl_value::{json, InOMap, InternedString, Value};
use imbl_value::Value;
use models::PackageId;
use rpc_toolkit::command;
use serde::{Deserialize, Serialize};
use crate::context::RpcContext;
use crate::db::model::package::{ExposedUI, StoreExposedUI};
use crate::prelude::*;
use crate::Error;

View File

@@ -1,6 +1,7 @@
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use emver::VersionRange;
use imbl_value::InOMap;
pub use models::PackageId;
use models::VolumeId;
@@ -8,7 +9,6 @@ use serde::{Deserialize, Serialize};
use url::Url;
use super::git_hash::GitHash;
use crate::dependencies::Dependencies;
use crate::prelude::*;
use crate::s9pk::manifest::{Alerts, Description, HardwareRequirements};
use crate::util::Version;
@@ -43,7 +43,7 @@ pub struct Manifest {
pub alerts: Alerts,
pub volumes: BTreeMap<VolumeId, Value>,
#[serde(default)]
pub dependencies: Dependencies,
pub dependencies: BTreeMap<PackageId, DepInfo>,
pub config: Option<InOMap<String, Value>>,
#[serde(default)]
@@ -53,6 +53,29 @@ pub struct Manifest {
pub hardware_requirements: HardwareRequirements,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "type")]
pub enum DependencyRequirement {
OptIn { how: String },
OptOut { how: String },
Required,
}
impl DependencyRequirement {
pub fn required(&self) -> bool {
matches!(self, &DependencyRequirement::Required)
}
}
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct DepInfo {
pub version: VersionRange,
pub requirement: DependencyRequirement,
pub description: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Assets {

View File

@@ -7,6 +7,7 @@ use tokio::fs::File;
use tokio::io::{AsyncRead, AsyncSeek, AsyncWriteExt};
use tokio::process::Command;
use crate::dependencies::{DepInfo, Dependencies};
use crate::prelude::*;
use crate::s9pk::manifest::Manifest;
use crate::s9pk::merkle_archive::directory_contents::DirectoryContents;
@@ -347,7 +348,21 @@ impl From<ManifestV1> for Manifest {
.map(|(id, _)| id.clone())
.collect(),
alerts: value.alerts,
dependencies: value.dependencies,
dependencies: Dependencies(
value
.dependencies
.into_iter()
.map(|(id, value)| {
(
id,
DepInfo {
description: value.description,
optional: !value.requirement.required(),
},
)
})
.collect(),
),
hardware_requirements: value.hardware_requirements,
git_hash: value.git_hash,
os_version: value.eos_version,

View File

@@ -5,6 +5,7 @@ use helpers::const_true;
pub use models::PackageId;
use models::{ImageId, VolumeId};
use serde::{Deserialize, Serialize};
use ts_rs::TS;
use url::Url;
use crate::dependencies::Dependencies;
@@ -18,21 +19,28 @@ fn current_version() -> Version {
Current::new().semver().into()
}
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
#[derive(Clone, Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct Manifest {
pub id: PackageId,
pub title: String,
#[ts(type = "string")]
pub version: Version,
pub release_notes: String,
pub license: String, // type of license
#[serde(default)]
pub replaces: Vec<String>,
#[ts(type = "string")]
pub wrapper_repo: Url,
#[ts(type = "string")]
pub upstream_repo: Url,
#[ts(type = "string")]
pub support_site: Url,
#[ts(type = "string")]
pub marketing_site: Url,
#[ts(type = "string | null")]
pub donation_url: Option<Url>,
pub description: Description,
pub images: Vec<ImageId>,
@@ -45,23 +53,28 @@ pub struct Manifest {
#[serde(default)]
pub hardware_requirements: HardwareRequirements,
#[serde(default)]
#[ts(type = "string | null")]
pub git_hash: Option<GitHash>,
#[serde(default = "current_version")]
#[ts(type = "string")]
pub os_version: Version,
#[serde(default = "const_true")]
pub has_config: bool,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[derive(Clone, Debug, Default, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct HardwareRequirements {
#[serde(default)]
#[ts(type = "{ [key: string]: string }")]
device: BTreeMap<String, Regex>,
ram: Option<u64>,
pub arch: Option<Vec<String>>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[ts(export)]
pub struct Description {
pub short: String,
pub long: String,
@@ -84,8 +97,9 @@ impl Description {
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[derive(Clone, Debug, Default, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct Alerts {
pub install: Option<String>,
pub uninstall: Option<String>,

View File

@@ -20,7 +20,7 @@ use ts_rs::TS;
use url::Url;
use crate::db::model::package::{
CurrentDependencies, CurrentDependencyInfo, ExposedUI, StoreExposedUI,
CurrentDependencies, CurrentDependencyInfo, CurrentDependencyKind,
};
use crate::disk::mount::filesystem::idmapped::IdMapped;
use crate::disk::mount::filesystem::loop_dev::LoopDev;
@@ -114,7 +114,6 @@ pub fn service_effect_handler() -> ParentHandler {
"exposeForDependents",
from_fn_async(expose_for_dependents).no_cli(),
)
.subcommand("exposeUi", from_fn_async(expose_ui).no_cli())
.subcommand(
"createOverlayedImage",
from_fn_async(create_overlayed_image)
@@ -699,23 +698,6 @@ async fn expose_for_dependents(
Ok(())
}
async fn expose_ui(context: EffectContext, params: StoreExposedUI) -> Result<(), Error> {
let context = context.deref()?;
let package_id = context.id.clone();
context
.ctx
.db
.mutate(|db| {
db.as_public_mut()
.as_package_data_mut()
.as_idx_mut(&package_id)
.or_not_found(&package_id)?
.as_store_exposed_ui_mut()
.ser(&params)
})
.await?;
Ok(())
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
@@ -1101,7 +1083,7 @@ enum DependencyRequirement {
#[ts(type = "string")]
version_spec: VersionRange,
#[ts(type = "string")]
url: Url,
registry: Url,
},
#[serde(rename_all = "camelCase")]
Exists {
@@ -1110,7 +1092,7 @@ enum DependencyRequirement {
#[ts(type = "string")]
version_spec: VersionRange,
#[ts(type = "string")]
url: Url,
registry: Url,
},
}
// filebrowser:exists,bitcoind:running:foo+bar+baz
@@ -1120,7 +1102,7 @@ impl FromStr for DependencyRequirement {
match s.split_once(':') {
Some((id, "e")) | Some((id, "exists")) => Ok(Self::Exists {
id: id.parse()?,
url: "".parse()?, // TODO
registry: "".parse()?, // TODO
version_spec: "*".parse()?, // TODO
}),
Some((id, rest)) => {
@@ -1144,14 +1126,14 @@ impl FromStr for DependencyRequirement {
Ok(Self::Running {
id: id.parse()?,
health_checks,
url: "".parse()?, // TODO
registry: "".parse()?, // TODO
version_spec: "*".parse()?, // TODO
})
}
None => Ok(Self::Running {
id: s.parse()?,
health_checks: BTreeSet::new(),
url: "".parse()?, // TODO
registry: "".parse()?, // TODO
version_spec: "*".parse()?, // TODO
}),
}
@@ -1187,20 +1169,31 @@ async fn set_dependencies(
.map(|dependency| match dependency {
DependencyRequirement::Exists {
id,
url,
version_spec,
} => (id, CurrentDependencyInfo::Exists { url, version_spec }),
DependencyRequirement::Running {
id,
health_checks,
url,
registry,
version_spec,
} => (
id,
CurrentDependencyInfo::Running {
url,
CurrentDependencyInfo {
kind: CurrentDependencyKind::Exists,
registry,
version_spec,
health_checks,
icon: todo!(),
title: todo!(),
},
),
DependencyRequirement::Running {
id,
health_checks,
registry,
version_spec,
} => (
id,
CurrentDependencyInfo {
kind: CurrentDependencyKind::Running { health_checks },
registry,
version_spec,
icon: todo!(),
title: todo!(),
},
),
})

View File

@@ -10,6 +10,7 @@ use imbl_value::InternedString;
use tokio::sync::{Mutex, OwnedRwLockReadGuard, OwnedRwLockWriteGuard, RwLock};
use tracing::instrument;
use crate::context::RpcContext;
use crate::db::model::package::{
InstallingInfo, InstallingState, PackageDataEntry, PackageState, UpdatingState,
};
@@ -26,7 +27,7 @@ use crate::s9pk::merkle_archive::source::FileSource;
use crate::s9pk::S9pk;
use crate::service::{LoadDisposition, Service};
use crate::status::{MainStatus, Status};
use crate::{context::RpcContext, util::serde::Pem};
use crate::util::serde::Pem;
pub type DownloadInstallFuture = BoxFuture<'static, Result<InstallFuture, Error>>;
pub type InstallFuture = BoxFuture<'static, Result<(), Error>>;
@@ -170,11 +171,8 @@ impl ServiceMap {
developer_key: Pem::new(developer_key),
icon,
last_backup: None,
dependency_info: Default::default(),
current_dependencies: Default::default(),
interface_addresses: Default::default(),
hosts: Default::default(),
store_exposed_ui: Default::default(),
store_exposed_dependents: Default::default(),
},
)?;

View File

@@ -1,7 +1,8 @@
pub use models::HealthCheckId;
use serde::{Deserialize, Serialize};
use ts_rs::TS;
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, TS)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "result")]
pub enum HealthCheckResult {

View File

@@ -4,15 +4,17 @@ use chrono::{DateTime, Utc};
use imbl::OrdMap;
use models::PackageId;
use serde::{Deserialize, Serialize};
use ts_rs::TS;
use self::health_check::HealthCheckId;
use crate::prelude::*;
use crate::status::health_check::HealthCheckResult;
pub mod health_check;
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
#[derive(Clone, Debug, Deserialize, Serialize, HasModel, TS)]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
#[ts(export)]
pub struct Status {
pub configured: bool,
pub main: MainStatus,
@@ -20,9 +22,9 @@ pub struct Status {
pub dependency_config_errors: DependencyConfigErrors,
}
#[derive(Clone, Debug, Deserialize, Serialize, HasModel, Default)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize, HasModel, Default, TS)]
#[model = "Model<Self>"]
#[ts(export)]
pub struct DependencyConfigErrors(pub BTreeMap<PackageId, String>);
impl Map for DependencyConfigErrors {
type Key = PackageId;
@@ -35,22 +37,29 @@ impl Map for DependencyConfigErrors {
}
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, TS)]
#[serde(tag = "status")]
#[serde(rename_all = "camelCase")]
pub enum MainStatus {
Stopped,
Restarting,
#[serde(rename_all = "camelCase")]
Stopping {
timeout: crate::util::serde::Duration,
},
Starting,
#[serde(rename_all = "camelCase")]
Running {
#[ts(type = "string")]
started: DateTime<Utc>,
#[ts(as = "BTreeMap<HealthCheckId, HealthCheckResult>")]
health: OrdMap<HealthCheckId, HealthCheckResult>,
},
#[serde(rename_all = "camelCase")]
BackingUp {
#[ts(type = "string | null")]
started: Option<DateTime<Utc>>,
#[ts(as = "BTreeMap<HealthCheckId, HealthCheckResult>")]
health: OrdMap<HealthCheckId, HealthCheckResult>,
},
}

View File

@@ -3,6 +3,7 @@ use std::collections::BTreeSet;
use imbl::OrdMap;
use tokio::process::Command;
use ts_rs::TS;
use crate::prelude::*;
use crate::util::Invoke;
@@ -13,7 +14,10 @@ pub const GOVERNOR_HEIRARCHY: &[Governor] = &[
Governor(Cow::Borrowed("conservative")),
];
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
#[derive(
Debug, Clone, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize, TS,
)]
#[ts(export, type = "string")]
pub struct Governor(Cow<'static, str>);
impl std::str::FromStr for Governor {
type Err = std::convert::Infallible;

View File

@@ -15,6 +15,7 @@ use serde::de::DeserializeOwned;
use serde::ser::{SerializeMap, SerializeSeq};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_json::Value;
use ts_rs::TS;
use super::IntoDoubleEndedIterator;
use crate::util::clap::FromStrParser;
@@ -633,7 +634,8 @@ where
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, TS)]
#[ts(export, type = "string")]
pub struct Duration(std::time::Duration);
impl Deref for Duration {
type Target = std::time::Duration;
@@ -1175,7 +1177,8 @@ impl<T: PemEncoding> Pem<T> {
}
}
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, TS)]
#[ts(export, type = "string | number[]")]
pub struct MaybeUtf8String(pub Vec<u8>);
impl std::fmt::Debug for MaybeUtf8String {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {