diff --git a/core/models/bindings/ServiceInterfaceId.ts b/core/models/bindings/ServiceInterfaceId.ts index 87edd8694..55315ab60 100644 --- a/core/models/bindings/ServiceInterfaceId.ts +++ b/core/models/bindings/ServiceInterfaceId.ts @@ -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 ServiceInterfaceId = string; \ No newline at end of file +export type ServiceInterfaceId = string; diff --git a/core/startos/src/auth.rs b/core/startos/src/auth.rs index 67a4fba3e..7a4c51237 100644 --- a/core/startos/src/auth.rs +++ b/core/startos/src/auth.rs @@ -24,7 +24,6 @@ use crate::util::serde::{display_serializable, HandlerExtSerde, WithIoFormat}; use crate::{ensure_code, Error, ResultExt}; #[derive(Debug, Clone, Default, Deserialize, Serialize, TS)] -#[ts(as = "BTreeMap::")] pub struct Sessions(pub BTreeMap); impl Sessions { pub fn new() -> Self { diff --git a/core/startos/src/db/model/package.rs b/core/startos/src/db/model/package.rs index 34c9c5f5d..9506bd6bb 100644 --- a/core/startos/src/db/model/package.rs +++ b/core/startos/src/db/model/package.rs @@ -375,7 +375,6 @@ pub struct PackageDataEntry { pub last_backup: Option>, pub current_dependencies: CurrentDependencies, pub actions: BTreeMap, - #[ts(as = "BTreeMap::")] pub tasks: BTreeMap, pub service_interfaces: BTreeMap, pub hosts: Hosts, diff --git a/core/startos/src/db/model/public.rs b/core/startos/src/db/model/public.rs index 79bc20b57..b4ab8e556 100644 --- a/core/startos/src/db/model/public.rs +++ b/core/startos/src/db/model/public.rs @@ -92,7 +92,6 @@ impl Public { }, gateways: OrdMap::new(), acme: BTreeMap::new(), - domains: BTreeMap::new(), dns: Default::default(), }, status_info: ServerStatus { @@ -195,9 +194,6 @@ pub struct NetworkInfo { #[serde(default)] pub acme: BTreeMap, #[serde(default)] - #[ts(as = "BTreeMap::")] - pub domains: BTreeMap, - #[serde(default)] pub dns: DnsSettings, } @@ -206,8 +202,7 @@ pub struct NetworkInfo { #[model = "Model"] #[ts(export)] pub struct DnsSettings { - pub dhcp: Vec, - #[serde(rename = "static")] + pub dhcp_servers: Vec, pub static_servers: Option>, } diff --git a/core/startos/src/dependencies.rs b/core/startos/src/dependencies.rs index 3b55c8fc3..8e08ea808 100644 --- a/core/startos/src/dependencies.rs +++ b/core/startos/src/dependencies.rs @@ -37,7 +37,6 @@ pub struct DepInfo { #[derive(Clone, Debug, Deserialize, Serialize, HasModel, TS)] #[serde(rename_all = "camelCase")] #[model = "Model"] -#[ts(export)] pub struct DependencyMetadata { #[ts(type = "string")] pub title: InternedString, diff --git a/core/startos/src/net/dns.rs b/core/startos/src/net/dns.rs index b5b6a69d5..aea5cd99a 100644 --- a/core/startos/src/net/dns.rs +++ b/core/startos/src/net/dns.rs @@ -21,11 +21,14 @@ use hickory_server::ServerFuture; use imbl::OrdMap; use imbl_value::InternedString; use models::{GatewayId, PackageId}; -use rpc_toolkit::{from_fn_blocking, Context, HandlerArgs, HandlerExt, ParentHandler}; +use rpc_toolkit::{ + from_fn_async, from_fn_blocking, Context, HandlerArgs, HandlerExt, ParentHandler, +}; use serde::{Deserialize, Serialize}; use tokio::net::{TcpListener, UdpSocket}; use tracing::instrument; +use crate::context::RpcContext; use crate::db::model::public::NetworkInterfaceInfo; use crate::net::gateway::NetworkInterfaceWatcher; use crate::util::serde::{display_serializable, HandlerExtSerde}; @@ -33,23 +36,30 @@ use crate::util::sync::{SyncRwLock, Watch}; use crate::{Error, ErrorKind, ResultExt}; pub fn dns_api() -> ParentHandler { - ParentHandler::new().subcommand( - "query", - from_fn_blocking(query_dns::) - .with_display_serializable() - .with_custom_display_fn(|HandlerArgs { params, .. }, res| { - if let Some(format) = params.format { - return display_serializable(format, res); - } + ParentHandler::new() + .subcommand( + "query", + from_fn_blocking(query_dns::) + .with_display_serializable() + .with_custom_display_fn(|HandlerArgs { params, .. }, res| { + if let Some(format) = params.format { + return display_serializable(format, res); + } - if let Some(ip) = res { - println!("{}", ip) - } + if let Some(ip) = res { + println!("{}", ip) + } - Ok(()) - }) - .with_about("Test the DNS configuration for a domain"), - ) + Ok(()) + }) + .with_about("Test the DNS configuration for a domain"), + ) + .subcommand( + "set-static", + from_fn_async(set_static_dns) + .no_display() + .with_about("Set static DNS servers"), + ) } #[derive(Deserialize, Serialize, Parser)] @@ -91,17 +101,17 @@ pub fn query_dns( .map_err(Error::from) } -// #[test] -// fn test_dns() { -// assert!(query_dns( -// (), -// QueryDnsParams { -// fqdn: "fakedomain-definitely-not-real.com" -// } -// ) -// .unwrap() -// .is_none()) -// } +#[derive(Deserialize, Serialize, Parser)] +pub struct SetStaticDnsParams { + pub servers: Option>, +} + +pub async fn set_static_dns( + ctx: RpcContext, + SetStaticDnsParams { servers }: SetStaticDnsParams, +) -> Result<(), Error> { + todo!() +} #[derive(Default)] struct ResolveMap { diff --git a/core/startos/src/net/gateway.rs b/core/startos/src/net/gateway.rs index 4dbfcd634..2d2251d92 100644 --- a/core/startos/src/net/gateway.rs +++ b/core/startos/src/net/gateway.rs @@ -856,7 +856,7 @@ impl NetworkInterfaceController { db.mutate(|db| { let net = db.as_public_mut().as_server_info_mut().as_network_mut(); - net.as_dns_mut().as_dhcp_mut().ser(&dns)?; + net.as_dns_mut().as_dhcp_servers_mut().ser(&dns)?; net.as_gateways_mut().ser(info) }) .await diff --git a/core/startos/src/registry/info.rs b/core/startos/src/registry/info.rs index 10efda2cb..382e0cae8 100644 --- a/core/startos/src/registry/info.rs +++ b/core/startos/src/registry/info.rs @@ -51,7 +51,6 @@ pub fn info_api() -> ParentHandler> { pub struct RegistryInfo { pub name: Option, pub icon: Option>, - #[ts(as = "BTreeMap::")] pub categories: BTreeMap, } diff --git a/core/startos/src/registry/os/index.rs b/core/startos/src/registry/os/index.rs index e182b4e46..9d02bcad8 100644 --- a/core/startos/src/registry/os/index.rs +++ b/core/startos/src/registry/os/index.rs @@ -8,8 +8,8 @@ use ts_rs::TS; use crate::prelude::*; use crate::registry::asset::RegistryAsset; use crate::registry::context::RegistryContext; -use crate::sign::commitment::blake3::Blake3Commitment; use crate::rpc_continuations::Guid; +use crate::sign::commitment::blake3::Blake3Commitment; #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[serde(rename_all = "camelCase")] @@ -44,11 +44,8 @@ pub struct OsVersionInfo { #[ts(type = "string")] pub source_version: VersionRange, pub authorized: BTreeSet, - #[ts(as = "BTreeMap::>")] pub iso: BTreeMap>, // platform (i.e. x86_64-nonfree) -> asset - #[ts(as = "BTreeMap::>")] pub squashfs: BTreeMap>, // platform (i.e. x86_64-nonfree) -> asset - #[ts(as = "BTreeMap::>")] pub img: BTreeMap>, // platform (i.e. raspberrypi) -> asset } diff --git a/core/startos/src/registry/package/index.rs b/core/startos/src/registry/package/index.rs index b5af40414..f4ca663da 100644 --- a/core/startos/src/registry/package/index.rs +++ b/core/startos/src/registry/package/index.rs @@ -12,20 +12,19 @@ use crate::prelude::*; use crate::registry::asset::RegistryAsset; use crate::registry::context::RegistryContext; use crate::registry::device_info::DeviceInfo; -use crate::sign::commitment::merkle_archive::MerkleArchiveCommitment; -use crate::sign::{AnySignature, AnyVerifyingKey}; use crate::rpc_continuations::Guid; use crate::s9pk::git_hash::GitHash; use crate::s9pk::manifest::{Alerts, Description, HardwareRequirements}; use crate::s9pk::merkle_archive::source::FileSource; use crate::s9pk::S9pk; +use crate::sign::commitment::merkle_archive::MerkleArchiveCommitment; +use crate::sign::{AnySignature, AnyVerifyingKey}; #[derive(Debug, Default, Deserialize, Serialize, HasModel, TS)] #[serde(rename_all = "camelCase")] #[model = "Model"] #[ts(export)] pub struct PackageIndex { - #[ts(as = "BTreeMap::")] pub categories: BTreeMap, pub packages: BTreeMap, } diff --git a/sdk/base/lib/dependencies/dependencies.ts b/sdk/base/lib/dependencies/dependencies.ts index 7002f54de..23bd1f1c8 100644 --- a/sdk/base/lib/dependencies/dependencies.ts +++ b/sdk/base/lib/dependencies/dependencies.ts @@ -77,7 +77,7 @@ export async function checkDependencies< } const tasksSatisfied = (packageId: DependencyId) => Object.entries(infoFor(packageId).result.tasks).filter( - ([_, t]) => t.active && t.task.severity === "critical", + ([_, t]) => t?.active && t.task.severity === "critical", ).length === 0 const healthCheckSatisfied = ( packageId: DependencyId, @@ -146,7 +146,7 @@ export async function checkDependencies< const throwIfTasksNotSatisfied = (packageId: DependencyId) => { const dep = infoFor(packageId) const reqs = Object.entries(dep.result.tasks) - .filter(([_, t]) => t.active && t.task.severity === "critical") + .filter(([_, t]) => t?.active && t.task.severity === "critical") .map(([id, _]) => id) if (reqs.length) { throw new Error( diff --git a/sdk/base/lib/dependencies/setupDependencies.ts b/sdk/base/lib/dependencies/setupDependencies.ts index 321dc1981..85b88fa66 100644 --- a/sdk/base/lib/dependencies/setupDependencies.ts +++ b/sdk/base/lib/dependencies/setupDependencies.ts @@ -2,7 +2,10 @@ import * as T from "../types" import { once } from "../util" export type RequiredDependenciesOf = { - [K in keyof Manifest["dependencies"]]: Manifest["dependencies"][K]["optional"] extends false + [K in keyof Manifest["dependencies"]]: Exclude< + Manifest["dependencies"][K], + undefined + >["optional"] extends false ? K : never }[keyof Manifest["dependencies"]] diff --git a/sdk/base/lib/osBindings/AllPackageData.ts b/sdk/base/lib/osBindings/AllPackageData.ts index b51b41bf5..ef4fda755 100644 --- a/sdk/base/lib/osBindings/AllPackageData.ts +++ b/sdk/base/lib/osBindings/AllPackageData.ts @@ -2,4 +2,4 @@ import type { PackageDataEntry } from "./PackageDataEntry" import type { PackageId } from "./PackageId" -export type AllPackageData = { [key: PackageId]: PackageDataEntry } +export type AllPackageData = { [key in PackageId]?: PackageDataEntry } diff --git a/sdk/base/lib/osBindings/CheckDependenciesResult.ts b/sdk/base/lib/osBindings/CheckDependenciesResult.ts index 2ddce973d..8061c4c8e 100644 --- a/sdk/base/lib/osBindings/CheckDependenciesResult.ts +++ b/sdk/base/lib/osBindings/CheckDependenciesResult.ts @@ -12,6 +12,6 @@ export type CheckDependenciesResult = { installedVersion: Version | null satisfies: Array isRunning: boolean - tasks: { [key: ReplayId]: TaskEntry } - healthChecks: { [key: HealthCheckId]: NamedHealthCheckResult } + tasks: { [key in ReplayId]?: TaskEntry } + healthChecks: { [key in HealthCheckId]?: NamedHealthCheckResult } } diff --git a/sdk/base/lib/osBindings/CurrentDependencies.ts b/sdk/base/lib/osBindings/CurrentDependencies.ts index 029a2f018..d359fa2b1 100644 --- a/sdk/base/lib/osBindings/CurrentDependencies.ts +++ b/sdk/base/lib/osBindings/CurrentDependencies.ts @@ -2,4 +2,4 @@ import type { CurrentDependencyInfo } from "./CurrentDependencyInfo" import type { PackageId } from "./PackageId" -export type CurrentDependencies = { [key: PackageId]: CurrentDependencyInfo } +export type CurrentDependencies = { [key in PackageId]?: CurrentDependencyInfo } diff --git a/sdk/base/lib/osBindings/Dependencies.ts b/sdk/base/lib/osBindings/Dependencies.ts index ad4c9b745..ee46a1f81 100644 --- a/sdk/base/lib/osBindings/Dependencies.ts +++ b/sdk/base/lib/osBindings/Dependencies.ts @@ -2,4 +2,4 @@ import type { DepInfo } from "./DepInfo" import type { PackageId } from "./PackageId" -export type Dependencies = { [key: PackageId]: DepInfo } +export type Dependencies = { [key in PackageId]?: DepInfo } diff --git a/sdk/base/lib/osBindings/DnsSettings.ts b/sdk/base/lib/osBindings/DnsSettings.ts index 667c61b99..37412159f 100644 --- a/sdk/base/lib/osBindings/DnsSettings.ts +++ b/sdk/base/lib/osBindings/DnsSettings.ts @@ -1,3 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type DnsSettings = { dhcp: Array; static: Array | null } +export type DnsSettings = { + dhcpServers: Array + staticServers: Array | null +} diff --git a/sdk/base/lib/osBindings/Domains.ts b/sdk/base/lib/osBindings/Domains.ts deleted file mode 100644 index 7af39bcf7..000000000 --- a/sdk/base/lib/osBindings/Domains.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { PublicDomainConfig } from "./PublicDomainConfig" - -export type Domains = { - public: { [key: string]: PublicDomainConfig } - private: Array -} diff --git a/sdk/base/lib/osBindings/FullIndex.ts b/sdk/base/lib/osBindings/FullIndex.ts index c7889760a..636746b5c 100644 --- a/sdk/base/lib/osBindings/FullIndex.ts +++ b/sdk/base/lib/osBindings/FullIndex.ts @@ -10,5 +10,5 @@ export type FullIndex = { icon: DataUrl | null package: PackageIndex os: OsIndex - signers: { [key: Guid]: SignerInfo } + signers: { [key in Guid]?: SignerInfo } } diff --git a/sdk/base/lib/osBindings/GetPackageResponse.ts b/sdk/base/lib/osBindings/GetPackageResponse.ts index 3e1dd4e9d..ca09e6777 100644 --- a/sdk/base/lib/osBindings/GetPackageResponse.ts +++ b/sdk/base/lib/osBindings/GetPackageResponse.ts @@ -5,6 +5,6 @@ import type { Version } from "./Version" export type GetPackageResponse = { categories: string[] - best: { [key: Version]: PackageVersionInfo } - otherVersions?: { [key: Version]: PackageInfoShort } + best: { [key in Version]?: PackageVersionInfo } + otherVersions?: { [key in Version]?: PackageInfoShort } } diff --git a/sdk/base/lib/osBindings/GetPackageResponseFull.ts b/sdk/base/lib/osBindings/GetPackageResponseFull.ts index e375dd489..849a14c42 100644 --- a/sdk/base/lib/osBindings/GetPackageResponseFull.ts +++ b/sdk/base/lib/osBindings/GetPackageResponseFull.ts @@ -4,6 +4,6 @@ import type { Version } from "./Version" export type GetPackageResponseFull = { categories: string[] - best: { [key: Version]: PackageVersionInfo } - otherVersions: { [key: Version]: PackageVersionInfo } + best: { [key in Version]?: PackageVersionInfo } + otherVersions: { [key in Version]?: PackageVersionInfo } } diff --git a/sdk/base/lib/osBindings/Host.ts b/sdk/base/lib/osBindings/Host.ts index 8962ad1e3..d4a956ff8 100644 --- a/sdk/base/lib/osBindings/Host.ts +++ b/sdk/base/lib/osBindings/Host.ts @@ -1,14 +1,15 @@ // 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 { Domains } from "./Domains" import type { HostnameInfo } from "./HostnameInfo" +import type { PublicDomainConfig } from "./PublicDomainConfig" export type Host = { - bindings: { [key: number]: BindInfo } + bindings: { [key in number]?: BindInfo } onions: string[] - domains: Domains + publicDomains: { [key in string]?: PublicDomainConfig } + privateDomains: Array /** * COMPUTED: NetService::update */ - hostnameInfo: { [key: number]: Array } + hostnameInfo: { [key in number]?: Array } } diff --git a/sdk/base/lib/osBindings/Hosts.ts b/sdk/base/lib/osBindings/Hosts.ts index c7aa84996..669f60fd9 100644 --- a/sdk/base/lib/osBindings/Hosts.ts +++ b/sdk/base/lib/osBindings/Hosts.ts @@ -2,4 +2,4 @@ import type { Host } from "./Host" import type { HostId } from "./HostId" -export type Hosts = { [key: HostId]: Host } +export type Hosts = { [key in HostId]?: Host } diff --git a/sdk/base/lib/osBindings/ImageSource.ts b/sdk/base/lib/osBindings/ImageSource.ts index d8f876aef..779fd2223 100644 --- a/sdk/base/lib/osBindings/ImageSource.ts +++ b/sdk/base/lib/osBindings/ImageSource.ts @@ -7,7 +7,7 @@ export type ImageSource = dockerBuild: { workdir?: string dockerfile?: string - buildArgs?: { [key: string]: BuildArg } + buildArgs?: { [key in string]?: BuildArg } } } | { dockerTag: string } diff --git a/sdk/base/lib/osBindings/MainStatus.ts b/sdk/base/lib/osBindings/MainStatus.ts index ca5655bd8..6c0192f10 100644 --- a/sdk/base/lib/osBindings/MainStatus.ts +++ b/sdk/base/lib/osBindings/MainStatus.ts @@ -15,11 +15,11 @@ export type MainStatus = | { main: "stopping" } | { main: "starting" - health: { [key: HealthCheckId]: NamedHealthCheckResult } + health: { [key in HealthCheckId]?: NamedHealthCheckResult } } | { main: "running" started: string - health: { [key: HealthCheckId]: NamedHealthCheckResult } + health: { [key in HealthCheckId]?: NamedHealthCheckResult } } | { main: "backingUp"; onComplete: StartStop } diff --git a/sdk/base/lib/osBindings/Manifest.ts b/sdk/base/lib/osBindings/Manifest.ts index 8e44e2056..10dfdf7b4 100644 --- a/sdk/base/lib/osBindings/Manifest.ts +++ b/sdk/base/lib/osBindings/Manifest.ts @@ -26,7 +26,7 @@ export type Manifest = { donationUrl: string | null docsUrl: string | null description: Description - images: { [key: ImageId]: ImageConfig } + images: { [key in ImageId]?: ImageConfig } volumes: Array alerts: Alerts dependencies: Dependencies diff --git a/sdk/base/lib/osBindings/NetworkInfo.ts b/sdk/base/lib/osBindings/NetworkInfo.ts index 118adcfe8..55f71bab2 100644 --- a/sdk/base/lib/osBindings/NetworkInfo.ts +++ b/sdk/base/lib/osBindings/NetworkInfo.ts @@ -2,7 +2,6 @@ import type { AcmeProvider } from "./AcmeProvider" import type { AcmeSettings } from "./AcmeSettings" import type { DnsSettings } from "./DnsSettings" -import type { DomainSettings } from "./DomainSettings" import type { GatewayId } from "./GatewayId" import type { Host } from "./Host" import type { NetworkInterfaceInfo } from "./NetworkInterfaceInfo" @@ -11,8 +10,7 @@ import type { WifiInfo } from "./WifiInfo" export type NetworkInfo = { wifi: WifiInfo host: Host - gateways: { [key: GatewayId]: NetworkInterfaceInfo } - acme: { [key: AcmeProvider]: AcmeSettings } - domains: { [key: string]: DomainSettings } + gateways: { [key in GatewayId]?: NetworkInterfaceInfo } + acme: { [key in AcmeProvider]?: AcmeSettings } dns: DnsSettings } diff --git a/sdk/base/lib/osBindings/OsVersionInfo.ts b/sdk/base/lib/osBindings/OsVersionInfo.ts index a88115350..28b6bbc21 100644 --- a/sdk/base/lib/osBindings/OsVersionInfo.ts +++ b/sdk/base/lib/osBindings/OsVersionInfo.ts @@ -8,7 +8,7 @@ export type OsVersionInfo = { releaseNotes: string sourceVersion: string authorized: Array - iso: { [key: string]: RegistryAsset } - squashfs: { [key: string]: RegistryAsset } - img: { [key: string]: RegistryAsset } + iso: { [key in string]?: RegistryAsset } + squashfs: { [key in string]?: RegistryAsset } + img: { [key in string]?: RegistryAsset } } diff --git a/sdk/base/lib/osBindings/OsVersionInfoMap.ts b/sdk/base/lib/osBindings/OsVersionInfoMap.ts index 6f333f1fb..8e6d4d000 100644 --- a/sdk/base/lib/osBindings/OsVersionInfoMap.ts +++ b/sdk/base/lib/osBindings/OsVersionInfoMap.ts @@ -1,4 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { OsVersionInfo } from "./OsVersionInfo" -export type OsVersionInfoMap = { [key: string]: OsVersionInfo } +export type OsVersionInfoMap = { [key in string]?: OsVersionInfo } diff --git a/sdk/base/lib/osBindings/PackageDataEntry.ts b/sdk/base/lib/osBindings/PackageDataEntry.ts index 52e55dd75..752c3f918 100644 --- a/sdk/base/lib/osBindings/PackageDataEntry.ts +++ b/sdk/base/lib/osBindings/PackageDataEntry.ts @@ -6,6 +6,7 @@ import type { DataUrl } from "./DataUrl" import type { Hosts } from "./Hosts" import type { MainStatus } from "./MainStatus" import type { PackageState } from "./PackageState" +import type { ReplayId } from "./ReplayId" import type { ServiceInterface } from "./ServiceInterface" import type { ServiceInterfaceId } from "./ServiceInterfaceId" import type { TaskEntry } from "./TaskEntry" @@ -19,9 +20,9 @@ export type PackageDataEntry = { icon: DataUrl lastBackup: string | null currentDependencies: CurrentDependencies - actions: { [key: ActionId]: ActionMetadata } - tasks: { [key: string]: TaskEntry } - serviceInterfaces: { [key: ServiceInterfaceId]: ServiceInterface } + actions: { [key in ActionId]?: ActionMetadata } + tasks: { [key in ReplayId]?: TaskEntry } + serviceInterfaces: { [key in ServiceInterfaceId]?: ServiceInterface } hosts: Hosts storeExposedDependents: string[] } diff --git a/sdk/base/lib/osBindings/PackageIndex.ts b/sdk/base/lib/osBindings/PackageIndex.ts index 5e8c94945..69c70c579 100644 --- a/sdk/base/lib/osBindings/PackageIndex.ts +++ b/sdk/base/lib/osBindings/PackageIndex.ts @@ -4,6 +4,6 @@ import type { PackageId } from "./PackageId" import type { PackageInfo } from "./PackageInfo" export type PackageIndex = { - categories: { [key: string]: Category } - packages: { [key: PackageId]: PackageInfo } + categories: { [key in string]?: Category } + packages: { [key in PackageId]?: PackageInfo } } diff --git a/sdk/base/lib/osBindings/PackageInfo.ts b/sdk/base/lib/osBindings/PackageInfo.ts index 6d07cd43e..80720b798 100644 --- a/sdk/base/lib/osBindings/PackageInfo.ts +++ b/sdk/base/lib/osBindings/PackageInfo.ts @@ -5,6 +5,6 @@ import type { Version } from "./Version" export type PackageInfo = { authorized: Array - versions: { [key: Version]: PackageVersionInfo } + versions: { [key in Version]?: PackageVersionInfo } categories: string[] } diff --git a/sdk/base/lib/osBindings/PackageVersionInfo.ts b/sdk/base/lib/osBindings/PackageVersionInfo.ts index f131dedae..d374fd45b 100644 --- a/sdk/base/lib/osBindings/PackageVersionInfo.ts +++ b/sdk/base/lib/osBindings/PackageVersionInfo.ts @@ -23,7 +23,7 @@ export type PackageVersionInfo = { donationUrl: string | null docsUrl: string | null alerts: Alerts - dependencyMetadata: { [key: PackageId]: DependencyMetadata } + dependencyMetadata: { [key in PackageId]?: DependencyMetadata } osVersion: string sdkVersion: string | null hardwareRequirements: HardwareRequirements diff --git a/sdk/base/lib/osBindings/RegistryAsset.ts b/sdk/base/lib/osBindings/RegistryAsset.ts index 41f09431f..01958d001 100644 --- a/sdk/base/lib/osBindings/RegistryAsset.ts +++ b/sdk/base/lib/osBindings/RegistryAsset.ts @@ -6,5 +6,5 @@ export type RegistryAsset = { publishedAt: string url: string commitment: Commitment - signatures: { [key: AnyVerifyingKey]: AnySignature } + signatures: { [key in AnyVerifyingKey]?: AnySignature } } diff --git a/sdk/base/lib/osBindings/RegistryInfo.ts b/sdk/base/lib/osBindings/RegistryInfo.ts index f9265fdec..ca87bfbbb 100644 --- a/sdk/base/lib/osBindings/RegistryInfo.ts +++ b/sdk/base/lib/osBindings/RegistryInfo.ts @@ -5,5 +5,5 @@ import type { DataUrl } from "./DataUrl" export type RegistryInfo = { name: string | null icon: DataUrl | null - categories: { [key: string]: Category } + categories: { [key in string]?: Category } } diff --git a/sdk/base/lib/osBindings/ServerStatus.ts b/sdk/base/lib/osBindings/ServerStatus.ts index 6bce57333..b4e15d82f 100644 --- a/sdk/base/lib/osBindings/ServerStatus.ts +++ b/sdk/base/lib/osBindings/ServerStatus.ts @@ -4,7 +4,7 @@ import type { FullProgress } from "./FullProgress" import type { PackageId } from "./PackageId" export type ServerStatus = { - backupProgress: { [key: PackageId]: BackupProgress } | null + backupProgress: { [key in PackageId]?: BackupProgress } | null updated: boolean updateProgress: FullProgress | null shuttingDown: boolean diff --git a/sdk/base/lib/osBindings/Sessions.ts b/sdk/base/lib/osBindings/Sessions.ts index 0f43f1d01..ed54fb59c 100644 --- a/sdk/base/lib/osBindings/Sessions.ts +++ b/sdk/base/lib/osBindings/Sessions.ts @@ -1,9 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Session } from "./Session" -export type Sessions = { - [key: string]: { - loggedIn: string - lastActive: string - userAgent: string | null - } -} +export type Sessions = { [key in string]?: Session } diff --git a/sdk/base/lib/osBindings/index.ts b/sdk/base/lib/osBindings/index.ts index 4898ef297..02c7123b4 100644 --- a/sdk/base/lib/osBindings/index.ts +++ b/sdk/base/lib/osBindings/index.ts @@ -68,7 +68,6 @@ export { DestroySubcontainerFsParams } from "./DestroySubcontainerFsParams" export { DeviceFilter } from "./DeviceFilter" export { DnsSettings } from "./DnsSettings" export { DomainSettings } from "./DomainSettings" -export { Domains } from "./Domains" export { Duration } from "./Duration" export { EchoParams } from "./EchoParams" export { EditSignerParams } from "./EditSignerParams" diff --git a/sdk/base/lib/s9pk/index.ts b/sdk/base/lib/s9pk/index.ts index 8d6a2c6ed..bb928384c 100644 --- a/sdk/base/lib/s9pk/index.ts +++ b/sdk/base/lib/s9pk/index.ts @@ -101,18 +101,20 @@ export class S9pk { ) } - async dependencyMetadata(): Promise> { + async dependencyMetadata() { return Object.fromEntries( await Promise.all( - Object.entries(this.manifest.dependencies).map(async ([id, info]) => [ - id, - { - ...(await this.dependencyMetadataFor(id)), - icon: await this.dependencyIconFor(id), - description: info.description, - optional: info.optional, - }, - ]), + Object.entries(this.manifest.dependencies) + .filter(([_, info]) => !!info) + .map(async ([id, info]) => [ + id, + { + ...(await this.dependencyMetadataFor(id)), + icon: await this.dependencyIconFor(id), + description: info!.description, + optional: info!.optional, + }, + ]), ), ) } diff --git a/sdk/base/lib/util/getServiceInterface.ts b/sdk/base/lib/util/getServiceInterface.ts index 037a95854..430c975c0 100644 --- a/sdk/base/lib/util/getServiceInterface.ts +++ b/sdk/base/lib/util/getServiceInterface.ts @@ -165,7 +165,7 @@ export const filledAddress = ( addressInfo: AddressInfo, ): FilledAddressInfo => { const toUrl = addressHostToUrl.bind(null, addressInfo) - const hostnames = host.hostnameInfo[addressInfo.internalPort] + const hostnames = host.hostnameInfo[addressInfo.internalPort] ?? [] return { ...addressInfo, diff --git a/web/projects/ui/src/app/routes/portal/routes/services/routes/service.component.ts b/web/projects/ui/src/app/routes/portal/routes/services/routes/service.component.ts index c5ca7e911..7c732c11c 100644 --- a/web/projects/ui/src/app/routes/portal/routes/services/routes/service.component.ts +++ b/web/projects/ui/src/app/routes/portal/routes/services/routes/service.component.ts @@ -211,5 +211,5 @@ export class ServiceRoute { function toHealthCheck(status: T.MainStatus): T.NamedHealthCheckResult[] { return status.main !== 'running' || isEmptyObject(status.health) ? [] - : Object.values(status.health) + : Object.values(status.health).filter(h => !!h) } diff --git a/web/projects/ui/src/app/services/dep-error.service.ts b/web/projects/ui/src/app/services/dep-error.service.ts index a45d18441..b528375c6 100644 --- a/web/projects/ui/src/app/services/dep-error.service.ts +++ b/web/projects/ui/src/app/services/dep-error.service.ts @@ -103,12 +103,14 @@ export class DepErrorService { // action required if ( - Object.values(pkg.tasks).some( - t => - t.active && - t.task.packageId === depId && - t.task.severity === 'critical', - ) + Object.values(pkg.tasks) + .filter(t => !!t) + .some( + t => + t.active && + t.task.packageId === depId && + t.task.severity === 'critical', + ) ) { return { type: 'actionRequired', diff --git a/web/projects/ui/src/app/services/gateway.service.ts b/web/projects/ui/src/app/services/gateway.service.ts index 185ca1981..0c4df5629 100644 --- a/web/projects/ui/src/app/services/gateway.service.ts +++ b/web/projects/ui/src/app/services/gateway.service.ts @@ -19,13 +19,13 @@ export class GatewayService { .pipe( map(gateways => Object.entries(gateways) - .filter(([_, val]) => !!val.ipInfo) + .filter(([_, val]) => !!val?.ipInfo) .map( ([id, val]) => ({ ...val, id, - lanIpv4: val.ipInfo?.subnets + lanIpv4: val?.ipInfo?.subnets .filter(s => !s.includes('::')) .map(s => s.split('/')[0]), }) as GatewayPlus, diff --git a/web/projects/ui/src/app/services/pkg-status-rendering.service.ts b/web/projects/ui/src/app/services/pkg-status-rendering.service.ts index d68d38726..f7f7cf004 100644 --- a/web/projects/ui/src/app/services/pkg-status-rendering.service.ts +++ b/web/projects/ui/src/app/services/pkg-status-rendering.service.ts @@ -25,9 +25,9 @@ export function getInstalledPrimaryStatus({ tasks, status, }: T.PackageDataEntry): PrimaryStatus { - return Object.values(tasks).some( - t => t.active && t.task.severity === 'critical', - ) + return Object.values(tasks) + .filter(t => !!t) + .some(t => t.active && t.task.severity === 'critical') ? 'actionRequired' : status.main } @@ -37,7 +37,7 @@ function getHealthStatus(status: T.MainStatus): T.HealthStatus | null { return null } - const values = Object.values(status.health) + const values = Object.values(status.health).filter(h => !!h) if (values.some(h => h.result === 'failure')) { return 'failure'