Merge branch 'integration/new-container-runtime' of github.com:Start9Labs/start-os into rebase/feat/domains

This commit is contained in:
Matt Hill
2024-03-24 12:19:37 -06:00
69 changed files with 368 additions and 357 deletions

View File

@@ -26,7 +26,7 @@ pub struct ActionResultV0 {
}
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub enum DockerStatus {
Running,
Stopped,
@@ -48,7 +48,7 @@ pub fn display_action_result(params: WithIoFormat<ActionParams>, result: ActionR
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct ActionParams {
#[arg(id = "id")]

View File

@@ -127,7 +127,7 @@ fn gen_pwd() {
)
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct CliLoginParams {
password: Option<PasswordType>,
@@ -179,7 +179,7 @@ pub fn check_password_against_db(db: &DatabaseModel, password: &str) -> Result<(
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct LoginParams {
password: Option<PasswordType>,
@@ -220,7 +220,7 @@ pub async fn login_impl(
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct LogoutParams {
session: InternedString,
@@ -236,7 +236,7 @@ pub async fn logout(
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct Session {
pub logged_in: DateTime<Utc>,
pub last_active: DateTime<Utc>,
@@ -245,7 +245,7 @@ pub struct Session {
}
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct SessionList {
current: InternedString,
sessions: Sessions,
@@ -305,7 +305,7 @@ fn display_sessions(params: WithIoFormat<ListParams>, arg: SessionList) {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct ListParams {
#[arg(skip)]
@@ -340,7 +340,7 @@ impl AsLogoutSessionId for KillSessionId {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct KillParams {
ids: Vec<String>,
@@ -353,12 +353,10 @@ pub async fn kill(ctx: RpcContext, KillParams { ids }: KillParams) -> Result<(),
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct ResetPasswordParams {
#[arg(name = "old-password")]
old_password: Option<PasswordType>,
#[arg(name = "new-password")]
new_password: Option<PasswordType>,
}

View File

@@ -30,7 +30,7 @@ use crate::util::serde::IoFormat;
use crate::version::VersionT;
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct BackupParams {
target_id: BackupTargetId,

View File

@@ -25,7 +25,7 @@ use crate::service::service_map::DownloadInstallFuture;
use crate::util::serde::IoFormat;
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct RestorePackageParams {
pub ids: Vec<PackageId>,

View File

@@ -36,7 +36,7 @@ impl Map for CifsTargets {
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct CifsBackupTarget {
hostname: String,
path: PathBuf,
@@ -68,7 +68,7 @@ pub fn cifs() -> ParentHandler {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct AddParams {
pub hostname: String,
@@ -122,7 +122,7 @@ pub async fn add(
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct UpdateParams {
pub id: BackupTargetId,
@@ -186,7 +186,7 @@ pub async fn update(
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct RemoveParams {
pub id: BackupTargetId,

View File

@@ -34,9 +34,9 @@ pub mod cifs;
#[derive(Debug, Deserialize, Serialize)]
#[serde(tag = "type")]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub enum BackupTarget {
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
Disk {
vendor: Option<String>,
model: Option<String>,
@@ -109,7 +109,7 @@ impl Serialize for BackupTargetId {
#[derive(Debug, Deserialize, Serialize)]
#[serde(tag = "type")]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub enum BackupTargetFS {
Disk(BlockDev<PathBuf>),
Cifs(Cifs),
@@ -190,7 +190,7 @@ pub async fn list(ctx: RpcContext) -> Result<BTreeMap<BackupTargetId, BackupTarg
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct BackupInfo {
pub version: Version,
pub timestamp: Option<DateTime<Utc>>,
@@ -198,7 +198,7 @@ pub struct BackupInfo {
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct PackageBackupInfo {
pub title: String,
pub version: Version,
@@ -243,7 +243,7 @@ fn display_backup_info(params: WithIoFormat<InfoParams>, info: BackupInfo) {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct InfoParams {
target_id: BackupTargetId,
@@ -277,7 +277,7 @@ lazy_static::lazy_static! {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct MountParams {
target_id: BackupTargetId,
@@ -312,7 +312,7 @@ pub async fn mount(
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct UmountParams {
target_id: Option<BackupTargetId>,

View File

@@ -9,14 +9,14 @@ use crate::prelude::*;
use crate::status::health_check::HealthCheckId;
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct ConfigRes {
pub config: Option<Config>,
pub spec: ConfigSpec,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct SetResult {
pub depends_on: BTreeMap<PackageId, BTreeSet<HealthCheckId>>,
}

View File

@@ -126,7 +126,7 @@ pub enum MatchError {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct ConfigParams {
pub id: PackageId,
@@ -157,7 +157,7 @@ pub async fn get(ctx: RpcContext, _: Empty, id: PackageId) -> Result<ConfigRes,
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct SetParams {
#[arg(long = "timeout")]
pub timeout: Option<crate::util::serde::Duration>,

View File

@@ -28,7 +28,7 @@ lazy_static::lazy_static! {
}
#[derive(Clone, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct SetupResult {
pub tor_address: String,
pub lan_address: String,

View File

@@ -10,7 +10,7 @@ use crate::prelude::*;
use crate::Error;
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct ControlParams {
pub id: PackageId,

View File

@@ -183,7 +183,7 @@ pub enum RevisionsRes {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct CliDumpParams {
#[arg(long = "include-private", short = 'p')]
@@ -216,7 +216,7 @@ async fn cli_dump(
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct DumpParams {
#[arg(long = "include-private", short = 'p')]
@@ -272,7 +272,7 @@ async fn cli_apply(
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct ApplyParams {
expr: String,
@@ -310,7 +310,7 @@ pub fn put() -> ParentHandler {
)
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct UiParams {
pointer: JsonPointer,

View File

@@ -20,7 +20,7 @@ pub mod private;
pub mod public;
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct Database {
pub public: Public,

View File

@@ -35,7 +35,7 @@ pub enum ManifestPreference {
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[serde(tag = "state")]
#[model = "Model<Self>"]
pub enum PackageState {
@@ -257,14 +257,14 @@ impl Model<PackageState> {
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct InstallingState {
pub installing_info: InstallingInfo,
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct UpdatingState {
pub manifest: Manifest,
@@ -272,14 +272,14 @@ pub struct UpdatingState {
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct InstalledState {
pub manifest: Manifest,
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct InstallingInfo {
pub new_manifest: Manifest,
@@ -287,7 +287,7 @@ pub struct InstallingInfo {
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct PackageDataEntry {
pub state_info: PackageState,
@@ -405,7 +405,7 @@ impl Map for CurrentDependencies {
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct StaticDependencyInfo {
pub title: String,
@@ -413,11 +413,11 @@ pub struct StaticDependencyInfo {
}
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[serde(tag = "kind")]
pub enum CurrentDependencyInfo {
Exists,
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
Running {
#[serde(default)]
health_checks: BTreeSet<HealthCheckId>,
@@ -438,7 +438,7 @@ impl Map for InterfaceAddressMap {
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct InterfaceAddresses {
pub tor_address: Option<String>,

View File

@@ -14,7 +14,7 @@ use crate::ssh::SshKeys;
use crate::util::serde::Pem;
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct Private {
pub key_store: KeyStore,

View File

@@ -24,7 +24,7 @@ use crate::version::{Current, VersionT};
use crate::{ARCH, PLATFORM};
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
// #[macro_debug]
pub struct Public {
@@ -102,7 +102,7 @@ fn get_platform() -> InternedString {
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct ServerInfo {
#[serde(default = "get_arch")]
@@ -137,7 +137,7 @@ pub struct ServerInfo {
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct IpInfo {
pub ipv4_range: Option<Ipv4Net>,
@@ -165,7 +165,7 @@ pub struct BackupProgress {
}
#[derive(Debug, Default, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct ServerStatus {
pub backup_progress: Option<BTreeMap<PackageId, BackupProgress>>,
@@ -178,7 +178,7 @@ pub struct ServerStatus {
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct UpdateProgress {
pub size: Option<u64>,
@@ -186,7 +186,7 @@ pub struct UpdateProgress {
}
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct WifiInfo {
pub ssids: Vec<String>,
@@ -195,7 +195,7 @@ pub struct WifiInfo {
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct ServerSpecs {
pub cpu: String,
pub disk: String,
@@ -203,7 +203,7 @@ pub struct ServerSpecs {
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct ConnectionAddresses {
pub tor: Vec<String>,
pub clearnet: Vec<String>,

View File

@@ -36,7 +36,7 @@ impl Map for Dependencies {
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[serde(tag = "type")]
pub enum DependencyRequirement {
OptIn { how: String },
@@ -50,7 +50,7 @@ impl DependencyRequirement {
}
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct DepInfo {
pub version: VersionRange,
@@ -61,12 +61,10 @@ pub struct DepInfo {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct ConfigureParams {
#[arg(name = "dependent-id")]
dependent_id: PackageId,
#[arg(name = "dependency-id")]
dependency_id: PackageId,
}
pub fn configure() -> ParentHandler<ConfigureParams> {
@@ -111,7 +109,7 @@ pub async fn configure_impl(
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct ConfigDryRes {
pub old_config: Config,
pub new_config: Config,

View File

@@ -41,7 +41,7 @@ pub fn error(ctx: DiagnosticContext) -> Result<Arc<RpcError>, Error> {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct LogsParams {
limit: Option<usize>,

View File

@@ -17,7 +17,7 @@ pub const BOOT_RW_PATH: &str = "/media/boot-rw";
pub const REPAIR_DISK_PATH: &str = "/media/embassy/config/repair-disk";
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct OsPartitionInfo {
pub efi: Option<PathBuf>,
pub bios: Option<PathBuf>,

View File

@@ -10,7 +10,7 @@ use super::FileSystem;
use crate::prelude::*;
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct BlockDev<LogicalName: AsRef<Path>> {
logicalname: LogicalName,
}

View File

@@ -63,7 +63,7 @@ pub async fn mount_cifs(
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct Cifs {
pub hostname: String,
pub path: PathBuf,

View File

@@ -22,7 +22,7 @@ pub async fn mount_httpdirfs(url: &Url, mountpoint: impl AsRef<Path>) -> Result<
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct HttpDirFS {
url: Url,
}

View File

@@ -14,7 +14,7 @@ use crate::prelude::*;
use crate::util::Invoke;
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct IdMapped<Fs: FileSystem> {
filesystem: Fs,
from_id: u32,

View File

@@ -12,7 +12,7 @@ use super::FileSystem;
use crate::prelude::*;
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct LoopDev<LogicalName: AsRef<Path>> {
logicalname: LogicalName,
offset: u64,

View File

@@ -24,14 +24,14 @@ use crate::util::{Invoke, Version};
use crate::{Error, ResultExt as _};
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub enum PartitionTable {
Mbr,
Gpt,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct DiskInfo {
pub logicalname: PathBuf,
pub partition_table: Option<PartitionTable>,
@@ -43,7 +43,7 @@ pub struct DiskInfo {
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct PartitionInfo {
pub logicalname: PathBuf,
pub label: Option<String>,
@@ -54,7 +54,7 @@ pub struct PartitionInfo {
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct EmbassyOsRecoveryInfo {
pub version: Version,
pub full: bool,

View File

@@ -14,7 +14,7 @@ use crate::PLATFORM;
/// Part of the Firmware, look there for more about
#[derive(Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct VersionMatcher {
/// Strip this prefix on the version matcher
semver_prefix: Option<String>,
@@ -28,7 +28,7 @@ pub struct VersionMatcher {
/// wanted a structure that could help decide what to do
/// for each of the firmware versions
#[derive(Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct Firmware {
id: String,
/// This is the platform(s) the firmware was built for

View File

@@ -24,7 +24,7 @@ pub fn inspect() -> ParentHandler {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct HashParams {
path: PathBuf,
@@ -39,11 +39,11 @@ pub async fn hash(_: CliContext, HashParams { path }: HashParams) -> Result<Stri
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct ManifestParams {
path: PathBuf,
#[arg(name = "no-verify", long = "no-verify")]
#[arg(long = "no-verify")]
no_verify: bool,
}
@@ -57,11 +57,11 @@ pub async fn manifest(
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct InspectParams {
path: PathBuf,
#[arg(name = "no-verify", long = "no-verify")]
#[arg(long = "no-verify")]
no_verify: bool,
}
@@ -89,11 +89,11 @@ pub async fn icon(
Ok(())
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct InstructionParams {
path: PathBuf,
#[arg(name = "no-verify", long = "no-verify")]
#[arg(long = "no-verify")]
no_verify: bool,
}

View File

@@ -64,7 +64,7 @@ pub async fn list(ctx: RpcContext) -> Result<Value, Error> {
}
#[derive(Debug, Clone, Copy, serde::Deserialize, serde::Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub enum MinMax {
Min,
Max,
@@ -103,7 +103,7 @@ impl std::fmt::Display for MinMax {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct InstallParams {
id: PackageId,
@@ -165,7 +165,7 @@ pub async fn install(
}
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct SideloadResponse {
pub upload: RequestGuid,
pub progress: RequestGuid,
@@ -275,7 +275,7 @@ pub async fn sideload(ctx: RpcContext) -> Result<SideloadResponse, Error> {
}
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub enum CliInstallParams {
Marketplace(InstallParams),
Sideload(PathBuf),
@@ -392,7 +392,7 @@ pub async fn cli_install(ctx: CliContext, params: CliInstallParams) -> Result<()
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct UninstallParams {
id: PackageId,

View File

@@ -80,7 +80,7 @@ use crate::context::CliContext;
use crate::util::serde::HandlerExtSerde;
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct EchoParams {
message: String,

View File

@@ -102,14 +102,14 @@ async fn ws_handler(
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct LogResponse {
entries: Reversible<LogEntry>,
start_cursor: Option<String>,
end_cursor: Option<String>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct LogFollowResponse {
start_cursor: Option<String>,
guid: RequestGuid,
@@ -211,7 +211,7 @@ pub enum LogSource {
pub const SYSTEM_UNIT: &str = "startd";
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct LogsParam {
id: PackageId,

View File

@@ -26,7 +26,7 @@ use crate::prelude::*;
pub const LOCAL_AUTH_COOKIE_PATH: &str = "/run/embassy/rpc.authcookie";
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct LoginRes {
pub session: InternedString,
}
@@ -245,7 +245,7 @@ impl Borrow<str> for HashSessionToken {
}
#[derive(Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct Metadata {
#[serde(default = "const_true")]
authenticated: bool,

View File

@@ -7,7 +7,7 @@ use serde::Deserialize;
use crate::context::RpcContext;
#[derive(Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct Metadata {
#[serde(default)]
sync_db: bool,

View File

@@ -61,7 +61,7 @@ pub fn dhcp() -> ParentHandler {
)
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct UpdateParams {
interface: String,

View File

@@ -29,7 +29,7 @@ use crate::SOURCE_DATE;
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[model = "Model<Self>"]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct CertStore {
pub root_key: Pem<PKey<Private>>,
pub root_cert: Pem<X509>,

View File

@@ -105,7 +105,7 @@ pub fn tor() -> ParentHandler {
)
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct ResetParams {
#[arg(name = "wipe-state", short = 'w', long = "wipe-state")]
@@ -143,7 +143,7 @@ pub async fn list_services(ctx: RpcContext, _: Empty) -> Result<Vec<OnionAddress
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct LogsParams {
#[arg(short = 'l', long = "limit")]

View File

@@ -88,7 +88,7 @@ pub fn country() -> ParentHandler {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct AddParams {
ssid: String,
@@ -139,7 +139,7 @@ pub async fn add(ctx: RpcContext, AddParams { ssid, password }: AddParams) -> Re
Ok(())
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct SsidParams {
ssid: String,
@@ -217,7 +217,7 @@ pub async fn delete(ctx: RpcContext, SsidParams { ssid }: SsidParams) -> Result<
Ok(())
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct WiFiInfo {
ssids: HashMap<Ssid, SignalStrength>,
connected: Option<Ssid>,
@@ -226,13 +226,13 @@ pub struct WiFiInfo {
available_wifi: Vec<WifiListOut>,
}
#[derive(serde::Serialize, serde::Deserialize, Clone)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct WifiListInfo {
strength: SignalStrength,
security: Vec<String>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct WifiListOut {
ssid: Ssid,
strength: SignalStrength,
@@ -403,7 +403,7 @@ pub async fn get_available(ctx: RpcContext, _: Empty) -> Result<Vec<WifiListOut>
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct SetCountryParams {
#[arg(value_parser = CountryCodeParser)]

View File

@@ -49,7 +49,7 @@ pub fn notification() -> ParentHandler {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct ListParams {
before: Option<u32>,
@@ -111,7 +111,7 @@ pub async fn list(
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct DeleteParams {
id: u32,
@@ -126,7 +126,7 @@ pub async fn delete(ctx: RpcContext, DeleteParams { id }: DeleteParams) -> Resul
.await
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct DeleteBeforeParams {
before: u32,
@@ -149,7 +149,7 @@ pub async fn delete_before(
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct CreateParams {
package: Option<PackageId>,
@@ -173,7 +173,7 @@ pub async fn create(
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub enum NotificationLevel {
Success,
Info,
@@ -225,7 +225,7 @@ impl fmt::Display for InvalidNotificationLevel {
}
#[derive(Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct Notifications(pub BTreeMap<u32, Notification>);
impl Notifications {
pub fn new() -> Self {
@@ -244,7 +244,7 @@ impl Map for Notifications {
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct Notification {
package_id: Option<PackageId>,
created_at: DateTime<Utc>,
@@ -256,7 +256,7 @@ pub struct Notification {
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct NotificationWithId {
id: u32,
#[serde(flatten)]

View File

@@ -24,7 +24,7 @@ mod gpt;
mod mbr;
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct PostInstallConfig {
os_partitions: OsPartitionInfo,
ethernet_interface: String,
@@ -120,7 +120,7 @@ async fn partition(disk: &mut DiskInfo, overwrite: bool) -> Result<OsPartitionIn
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct ExecuteParams {
logicalname: PathBuf,

View File

@@ -6,10 +6,10 @@ use models::PackageId;
use rpc_toolkit::command;
use serde::{Deserialize, Serialize};
use crate::db::model::package::ExposedUI;
use crate::context::RpcContext;
use crate::db::model::package::{ExposedUI, StoreExposedUI};
use crate::prelude::*;
use crate::Error;
use crate::{context::RpcContext, db::model::package::StoreExposedUI};
pub fn display_properties(response: Value) {
println!("{}", response);
@@ -58,7 +58,7 @@ impl IntoProperties for StoreExposedUI {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct PropertiesParam {
id: PackageId,

View File

@@ -91,7 +91,7 @@ async fn do_upload(
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct PublishParams {
location: String,

View File

@@ -37,7 +37,7 @@ pub fn with_query_params(ctx: RpcContext, mut url: Url) -> Url {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct GetParams {
url: Url,

View File

@@ -13,7 +13,7 @@ use crate::util::io::from_cbor_async_reader;
use crate::{Error, ErrorKind, ARCH};
#[derive(Default, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct DockerMultiArch {
pub default: String,
pub available: BTreeSet<String>,

View File

@@ -18,7 +18,7 @@ fn current_version() -> Version {
}
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct Manifest {
#[serde(default = "current_version")]
@@ -53,7 +53,7 @@ pub struct Manifest {
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct Assets {
#[serde(default)]
pub license: Option<PathBuf>,

View File

@@ -13,7 +13,7 @@ pub mod reader;
pub const SIG_CONTEXT: &[u8] = b"s9pk";
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct VerifyParams {
pub path: PathBuf,

View File

@@ -53,7 +53,7 @@ pub struct Manifest {
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct HardwareRequirements {
#[serde(default)]
device: BTreeMap<String, Regex>,
@@ -85,7 +85,7 @@ impl Description {
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct Alerts {
pub install: Option<String>,
pub uninstall: Option<String>,

View File

@@ -257,7 +257,7 @@ struct RemoveAddressParams {
#[ts(export)]
#[serde(rename_all = "kebab-case")]
enum AllowedStatuses {
OnlyRunning,
OnlyRunning, // onlyRunning
OnlyStopped,
Any,
}
@@ -1090,20 +1090,19 @@ enum DependencyKind {
#[serde(rename_all = "camelCase", tag = "kind")]
#[ts(export)]
enum DependencyRequirement {
#[serde(rename_all = "camelCase")]
Running {
#[ts(type = "string")]
id: PackageId,
#[ts(type = "string[]")]
#[serde(rename = "healthChecks")]
health_checks: BTreeSet<HealthCheckId>,
#[serde(rename = "versionSpec")]
version_spec: String,
url: String,
},
#[serde(rename_all = "camelCase")]
Exists {
#[ts(type = "string")]
id: PackageId,
#[serde(rename = "versionSpec")]
version_spec: String,
url: String,
},

View File

@@ -100,7 +100,7 @@ async fn setup_init(
}
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct AttachParams {
#[serde(rename = "embassy-password")]
password: Option<EncryptedWire>,
@@ -185,7 +185,7 @@ pub async fn attach(
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct SetupStatus {
pub bytes_transferred: u64,
pub total_bytes: Option<u64>,
@@ -211,7 +211,7 @@ pub fn cifs() -> ParentHandler {
}
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct VerifyCifsParams {
hostname: String,
path: PathBuf,
@@ -247,14 +247,14 @@ pub async fn verify_cifs(
#[derive(Debug, Deserialize, Serialize)]
#[serde(tag = "type")]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub enum RecoverySource {
Migrate { guid: String },
Backup { target: BackupTargetFS },
}
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct ExecuteParams {
embassy_logicalname: PathBuf,
embassy_password: EncryptedWire,

View File

@@ -48,7 +48,7 @@ impl ValueParserFactory for SshPubKey {
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct SshKeyResponse {
pub alg: String,
pub fingerprint: InternedString,
@@ -103,7 +103,7 @@ pub fn ssh() -> ParentHandler {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct AddParams {
key: SshPubKey,
@@ -136,7 +136,7 @@ pub async fn add(ctx: RpcContext, AddParams { key }: AddParams) -> Result<SshKey
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct DeleteParams {
fingerprint: InternedString,

View File

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

View File

@@ -11,7 +11,7 @@ use crate::status::health_check::HealthCheckResult;
pub mod health_check;
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct Status {
pub configured: bool,
@@ -21,7 +21,7 @@ pub struct Status {
}
#[derive(Clone, Debug, Deserialize, Serialize, HasModel, Default)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[model = "Model<Self>"]
pub struct DependencyConfigErrors(pub BTreeMap<PackageId, String>);
impl Map for DependencyConfigErrors {
@@ -37,7 +37,7 @@ impl Map for DependencyConfigErrors {
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
#[serde(tag = "status")]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub enum MainStatus {
Stopped,
Restarting,

View File

@@ -74,7 +74,7 @@ pub async fn enable_zram() -> Result<(), Error> {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct ZramParams {
enable: bool,
@@ -136,7 +136,7 @@ fn display_governor_info(params: WithIoFormat<GovernorParams>, result: GovernorI
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct GovernorParams {
set: Option<Governor>,
@@ -230,7 +230,7 @@ pub async fn time(ctx: RpcContext, _: Empty) -> Result<TimeInfo, Error> {
})
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct LogsParams {
#[arg(short = 'l', long = "limit")]
@@ -314,7 +314,7 @@ pub async fn logs_follow(
follow_logs(ctx, LogSource::System, limit).await
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct KernelLogsParams {
#[arg(short = 'l', long = "limit")]
@@ -509,12 +509,12 @@ impl<'de> Deserialize<'de> for GigaBytes {
}
#[derive(Deserialize, Serialize, Clone, Debug)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct MetricsGeneral {
pub temperature: Option<Celsius>,
}
#[derive(Deserialize, Serialize, Clone, Debug)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct MetricsMemory {
pub percentage_used: Percentage,
pub total: MebiBytes,
@@ -525,7 +525,7 @@ pub struct MetricsMemory {
pub zram_used: MebiBytes,
}
#[derive(Deserialize, Serialize, Clone, Debug)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct MetricsCpu {
percentage_used: Percentage,
idle: Percentage,
@@ -534,7 +534,7 @@ pub struct MetricsCpu {
wait: Percentage,
}
#[derive(Deserialize, Serialize, Clone, Debug)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct MetricsDisk {
percentage_used: Percentage,
used: GigaBytes,
@@ -542,7 +542,7 @@ pub struct MetricsDisk {
capacity: GigaBytes,
}
#[derive(Deserialize, Serialize, Clone, Debug)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub struct Metrics {
general: MetricsGeneral,
memory: MetricsMemory,

View File

@@ -35,7 +35,7 @@ lazy_static! {
}
#[derive(Deserialize, Serialize, Parser)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
pub struct UpdateSystemParams {
marketplace_url: Url,
@@ -60,7 +60,7 @@ pub async fn update_system(
/// What is the status of the updates?
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub enum UpdateResult {
NoUpdates,
Updating,

View File

@@ -8,7 +8,7 @@ const KNOWN_CLASSES: &[&str] = &["processor", "display"];
#[derive(Debug, Deserialize, Serialize)]
#[serde(tag = "class")]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub enum LshwDevice {
Processor(LshwProcessor),
Display(LshwDisplay),

View File

@@ -111,25 +111,25 @@ pub fn cert_dir(pkg_id: &PackageId, host_id: &HostId) -> PathBuf {
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "type")]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
pub enum Volume {
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
Data {
#[serde(skip)]
readonly: bool,
},
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
Assets {},
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
Pointer {
package_id: PackageId,
volume_id: VolumeId,
path: PathBuf,
readonly: bool,
},
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
Certificate { interface_id: HostId },
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "camelCase")]
Backup { readonly: bool },
}
impl Volume {

View File

@@ -21,8 +21,6 @@ import {
MaybePromise,
ServiceInterfaceId,
PackageId,
EnsureStorePath,
ExtractStore,
ValidIfNoStupidEscape,
} from "./types"
import * as patterns from "./util/patterns"
@@ -60,7 +58,6 @@ import {
setupInterfaces,
} from "./interfaces/setupInterfaces"
import { successFailure } from "./trigger/successFailure"
import { SetupExports } from "./inits/setupExports"
import { HealthReceipt } from "./health/HealthReceipt"
import { MultiHost, Scheme, SingleHost, StaticHost } from "./interfaces/Host"
import { ServiceInterfaceBuilder } from "./interfaces/ServiceInterfaceBuilder"
@@ -78,6 +75,8 @@ import { Mounts } from "./mainFn/Mounts"
import { Dependency } from "./Dependency"
import * as T from "./types"
import { Checker, EmVer } from "./emverLite/mod"
import { ExposedStorePaths } from "./store/setupExposeStore"
import { PathBuilder, extractJsonPath, pathBuilder } from "./store/PathBuilder"
// prettier-ignore
type AnyNeverCond<T extends any[], Then, Else> =
@@ -150,25 +149,29 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
},
store: {
get: <E extends Effects, Path extends string = never>(
get: <E extends Effects, StoreValue = unknown>(
effects: E,
packageId: string,
path: EnsureStorePath<Store, Path>,
path: PathBuilder<Store, StoreValue>,
) =>
removeConstType<E>()(
getStore<Store, Path>(effects, path as any, {
getStore<Store, StoreValue>(effects, path, {
packageId,
}),
),
getOwn: <E extends Effects, Path extends string>(
getOwn: <E extends Effects, StoreValue = unknown>(
effects: E,
path: EnsureStorePath<Store, Path>,
) => removeConstType<E>()(getStore<Store, Path>(effects, path as any)),
setOwn: <E extends Effects, Path extends string | never>(
path: PathBuilder<Store, StoreValue>,
) => removeConstType<E>()(getStore<Store, StoreValue>(effects, path)),
setOwn: <E extends Effects, Path extends PathBuilder<Store, unknown>>(
effects: E,
path: EnsureStorePath<Store, Path>,
value: ExtractStore<Store, Path>,
) => effects.store.set<Store, Path>({ value, path: path as any }),
path: Path,
value: Path extends PathBuilder<Store, infer Value> ? Value : never,
) =>
effects.store.set<Store>({
value,
path: extractJsonPath(path),
}),
},
host: {
@@ -179,7 +182,41 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
multi: (effects: Effects, id: string) => new MultiHost({ id, effects }),
},
nullIfEmpty,
runCommand: async <A extends string>(
effects: Effects,
imageId: Manifest["images"][number],
command: ValidIfNoStupidEscape<A> | [string, ...string[]],
options: CommandOptions & {
mounts?: { path: string; options: MountOptions }[]
},
): Promise<{ stdout: string | Buffer; stderr: string | Buffer }> => {
return runCommand<Manifest>(effects, imageId, command, options)
},
createAction: <
ConfigType extends
| Record<string, any>
| Config<any, any>
| Config<any, never>,
Type extends Record<string, any> = ExtractConfigType<ConfigType>,
>(
id: string,
metaData: Omit<ActionMetadata, "input"> & {
input: Config<Type, Store> | Config<Type, never>
},
fn: (options: {
effects: Effects
input: Type
}) => Promise<ActionResult>,
) => {
const { input, ...rest } = metaData
return createAction<Manifest, Store, ConfigType, Type>(
id,
rest,
fn,
input,
)
},
configConstants: { smtpConfig },
createInterface: (
effects: Effects,
@@ -197,42 +234,8 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
masked: boolean
},
) => new ServiceInterfaceBuilder({ ...options, effects }),
createAction: <
ConfigType extends
| Record<string, any>
| Config<any, any>
| Config<any, never>,
Type extends Record<string, any> = ExtractConfigType<ConfigType>,
>(
id: string,
metadata: Omit<ActionMetadata, "input"> & {
input: Config<Type, Store> | Config<Type, never>
},
fn: (options: {
effects: Effects
input: Type
}) => Promise<ActionResult>,
) => {
const { input, ...rest } = metadata
return createAction<Manifest, Store, ConfigType, Type>(
id,
rest,
fn,
input,
)
},
getSystemSmtp: <E extends Effects>(effects: E) =>
removeConstType<E>()(new GetSystemSmtp(effects)),
runCommand: async <A extends string>(
effects: Effects,
imageId: Manifest["images"][number],
command: ValidIfNoStupidEscape<A> | [string, ...string[]],
options: CommandOptions & {
mounts?: { path: string; options: MountOptions }[]
},
): Promise<{ stdout: string | Buffer; stderr: string | Buffer }> => {
return runCommand<Manifest>(effects, imageId, command, options)
},
createDynamicAction: <
ConfigType extends
@@ -242,7 +245,7 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
Type extends Record<string, any> = ExtractConfigType<ConfigType>,
>(
id: string,
metadata: (options: {
metaData: (options: {
effects: Effects
}) => MaybePromise<Omit<ActionMetadata, "input">>,
fn: (options: {
@@ -253,7 +256,7 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
) => {
return createAction<Manifest, Store, ConfigType, Type>(
id,
metadata,
metaData,
fn,
input,
)
@@ -343,7 +346,6 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
})
}
},
setupExports: (fn: SetupExports<Store>) => fn,
setupInit: (
migrations: Migrations<Manifest, Store>,
install: Install<Manifest, Store>,
@@ -353,15 +355,15 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
effects: Effects
input: any
}) => Promise<DependenciesReceipt>,
setupExports: SetupExports<Store>,
exposedStore: ExposedStorePaths,
) =>
setupInit<Manifest, Store>(
migrations,
install,
uninstall,
setInterfaces,
setupExports,
setDependencies,
exposedStore,
),
setupInstall: (fn: InstallFn<Manifest, Store>) => Install.of(fn),
setupInterfaces: <
@@ -386,6 +388,12 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
this.manifest,
...migrations,
),
setupProperties:
(
fn: (options: { effects: Effects }) => Promise<T.SdkPropertiesReturn>,
): T.ExpectedExports.Properties =>
(options) =>
fn(options).then(nullifyProperties),
setupUninstall: (fn: UninstallFn<Manifest, Store>) =>
setupUninstall<Manifest, Store>(fn),
trigger: {
@@ -538,6 +546,7 @@ export class StartSdk<Manifest extends SDKManifest, Store> {
down: (opts: { effects: Effects }) => Promise<void>
}) => Migration.of<Manifest, Store, Version>(options),
},
StorePath: pathBuilder<Store>(),
Value: {
toggle: Value.toggle,
text: Value.text,
@@ -746,3 +755,20 @@ export async function runCommand<Manifest extends SDKManifest>(
await overlay.destroy()
}
}
function nullifyProperties(value: T.SdkPropertiesReturn): T.PropertiesReturn {
return Object.fromEntries(
Object.entries(value).map(([k, v]) => [k, nullifyProperties_(v)]),
)
}
function nullifyProperties_(value: T.SdkPropertiesValue): T.PropertiesValue {
if (value.type === "string") {
return { description: null, copyable: null, qr: null, ...value }
}
return {
description: null,
...value,
value: Object.fromEntries(
Object.entries(value.value).map(([k, v]) => [k, nullifyProperties_(v)]),
),
}
}

View File

@@ -1,4 +1,6 @@
import "./config"
import "./list"
import "./value"
import "./variants"
import { Config } from "./config"
import { List } from "./list"
import { Value } from "./value"
import { Variants } from "./variants"
export { Config, List, Value, Variants }

View File

@@ -6,7 +6,6 @@ import {
UniqueBy,
ValueSpecList,
ValueSpecListOf,
ValueSpecText,
} from "../configTypes"
import { Parser, arrayOf, number, string } from "ts-matches"
/**

View File

@@ -1,5 +1,3 @@
import "./builder"
import "./setupConfig"
import "./configDependencies"
import "./configConstants"
export * as constants from "./configConstants"
export * as types from "./configTypes"
export * as builder from "./builder"

View File

@@ -3,7 +3,6 @@ import { SDKManifest } from "../manifest/ManifestTypes"
import * as D from "./configDependencies"
import { Config, ExtractConfigType } from "./builder/config"
import nullIfEmpty from "../util/nullIfEmpty"
import { InterfaceReceipt } from "../interfaces/interfaceReceipt"
import { InterfacesReceipt as InterfacesReceipt } from "../interfaces/setupInterfaces"
declare const dependencyProof: unique symbol

View File

@@ -4,11 +4,12 @@ export { Overlay } from "./util/Overlay"
export { StartSdk } from "./StartSdk"
export { setupManifest } from "./manifest/setupManifest"
export { FileHelper } from "./util/fileHelper"
export { setupExposeStore } from "./store/setupExposeStore"
export * as actions from "./actions"
export * as backup from "./backup"
export * as config from "./config"
export * as configBuilder from "./config/builder"
export * as configTypes from "./config/configTypes"
export * as CB from "./config/builder"
export * as CT from "./config/configTypes"
export * as dependencyConfig from "./dependencyConfig"
export * as daemons from "./mainFn/Daemons"
export * as health from "./health"

View File

@@ -1,14 +0,0 @@
import { Effects, ExposeServicePaths, ExposeUiPaths } from "../types"
export type SetupExports<Store> = (opts: { effects: Effects }) =>
| {
ui: { [k: string]: ExposeUiPaths<Store> }
services: ExposeServicePaths<Store>["paths"]
}
| Promise<{
ui: { [k: string]: ExposeUiPaths<Store> }
services: ExposeServicePaths<Store>["paths"]
}>
export const setupExports = <Store>(fn: (opts: SetupExports<Store>) => void) =>
fn

View File

@@ -1,14 +1,9 @@
import { DependenciesReceipt } from "../config/setupConfig"
import { SetInterfaces } from "../interfaces/setupInterfaces"
import { SDKManifest } from "../manifest/ManifestTypes"
import {
Effects,
ExpectedExports,
ExposeUiPaths,
ExposeUiPathsAll,
} from "../types"
import { ExposedStorePaths } from "../store/setupExposeStore"
import { Effects, ExpectedExports } from "../types"
import { Migrations } from "./migrations/setupMigrations"
import { SetupExports } from "./setupExports"
import { Install } from "./setupInstall"
import { Uninstall } from "./setupUninstall"
@@ -17,11 +12,11 @@ export function setupInit<Manifest extends SDKManifest, Store>(
install: Install<Manifest, Store>,
uninstall: Uninstall<Manifest, Store>,
setInterfaces: SetInterfaces<Manifest, Store, any, any>,
setupExports: SetupExports<Store>,
setDependencies: (options: {
effects: Effects
input: any
}) => Promise<DependenciesReceipt>,
exposedStore: ExposedStorePaths,
): {
init: ExpectedExports.init
uninit: ExpectedExports.uninit
@@ -34,9 +29,7 @@ export function setupInit<Manifest extends SDKManifest, Store>(
...opts,
input: null,
})
const { services, ui } = await setupExports(opts)
await opts.effects.exposeForDependents({ paths: services })
await opts.effects.exposeUi(forExpose(ui))
await opts.effects.exposeForDependents({ paths: exposedStore })
await setDependencies({ effects: opts.effects, input: null })
},
uninit: async (opts) => {
@@ -45,30 +38,3 @@ export function setupInit<Manifest extends SDKManifest, Store>(
},
}
}
function forExpose<Store>(ui: { [key: string]: ExposeUiPaths<Store> }) {
return Object.fromEntries(
Object.entries(ui).map(([key, value]) => [key, forExpose_(value)]),
)
}
function forExpose_<Store>(ui: ExposeUiPaths<Store>): ExposeUiPathsAll {
if (ui.type === ("object" as const)) {
return {
type: "object" as const,
value: Object.fromEntries(
Object.entries(ui.value).map(([key, value]) => [
key,
forExpose_(value),
]),
),
description: ui.description ?? null,
}
}
return {
description: null,
copyable: null,
qr: null,
...ui,
}
}

View File

@@ -0,0 +1,38 @@
import { Affine } from "../util"
const pathValue = Symbol("pathValue")
export type PathValue = typeof pathValue
export type PathBuilderStored<AllStore, Store> = {
[K in PathValue]: [AllStore, Store]
}
export type PathBuilder<AllStore, Store = AllStore> = (Store extends Record<
string,
unknown
>
? {
[K in keyof Store]: PathBuilder<AllStore, Store[K]>
}
: {}) &
PathBuilderStored<AllStore, Store>
export type StorePath = string & Affine<"StorePath">
const privateSymbol = Symbol("jsonPath")
export const extractJsonPath = (builder: PathBuilder<unknown>) => {
return (builder as any)[privateSymbol] as StorePath
}
export const pathBuilder = <Store, StorePath = Store>(
paths: string[] = [],
): PathBuilder<Store, StorePath> => {
return new Proxy({} as PathBuilder<Store, StorePath>, {
get(target, prop) {
if (prop === privateSymbol) {
if (paths.length === 0) return ""
return `/${paths.join("/")}`
}
return pathBuilder<any>([...paths, prop as string])
},
}) as PathBuilder<Store, StorePath>
}

View File

@@ -1,9 +1,10 @@
import { Effects, EnsureStorePath } from "../types"
import { Effects } from "../types"
import { PathBuilder, extractJsonPath } from "./PathBuilder"
export class GetStore<Store, Path extends string> {
export class GetStore<Store, StoreValue> {
constructor(
readonly effects: Effects,
readonly path: Path & EnsureStorePath<Store, Path>,
readonly path: PathBuilder<Store, StoreValue>,
readonly options: {
/** Defaults to what ever the package currently in */
packageId?: string | undefined
@@ -14,9 +15,9 @@ export class GetStore<Store, Path extends string> {
* Returns the value of Store at the provided path. Restart the service if the value changes
*/
const() {
return this.effects.store.get<Store, Path>({
return this.effects.store.get<Store, StoreValue>({
...this.options,
path: this.path as any,
path: extractJsonPath(this.path),
callback: this.effects.restart,
})
}
@@ -24,9 +25,9 @@ export class GetStore<Store, Path extends string> {
* Returns the value of Store at the provided path. Does nothing if the value changes
*/
once() {
return this.effects.store.get<Store, Path>({
return this.effects.store.get<Store, StoreValue>({
...this.options,
path: this.path as any,
path: extractJsonPath(this.path),
callback: () => {},
})
}
@@ -40,22 +41,22 @@ export class GetStore<Store, Path extends string> {
const waitForNext = new Promise<void>((resolve) => {
callback = resolve
})
yield await this.effects.store.get<Store, Path>({
yield await this.effects.store.get<Store, StoreValue>({
...this.options,
path: this.path as any,
path: extractJsonPath(this.path),
callback: () => callback(),
})
await waitForNext
}
}
}
export function getStore<Store, Path extends string>(
export function getStore<Store, StoreValue>(
effects: Effects,
path: Path & EnsureStorePath<Store, Path>,
path: PathBuilder<Store, StoreValue>,
options: {
/** Defaults to what ever the package currently in */
packageId?: string | undefined
} = {},
) {
return new GetStore<Store, Path>(effects, path as any, options)
return new GetStore<Store, StoreValue>(effects, path, options)
}

View File

@@ -0,0 +1,12 @@
import { Affine, _ } from "../util"
import { PathBuilder, extractJsonPath, pathBuilder } from "./PathBuilder"
export type ExposedStorePaths = string[] & Affine<"ExposedStorePaths">
export const setupExposeStore = <Store extends Record<string, any>>(
fn: (pathBuilder: PathBuilder<Store>) => PathBuilder<Store, any>[],
) => {
return fn(pathBuilder<Store>()).map(
(x) => extractJsonPath(x) as string,
) as ExposedStorePaths
}

View File

@@ -425,7 +425,9 @@ describe("values", () => {
const value = Value.dynamicDatetime<{ test: "a" }>(
async ({ effects }) => {
;async () => {
;(await sdk.store.getOwn(effects, "/test").once()) satisfies "a"
;(await sdk.store
.getOwn(effects, sdk.StorePath.test)
.once()) satisfies "a"
}
return {

View File

@@ -49,7 +49,6 @@ describe("startosTypeValidation ", () => {
setConfigured: {} as SetConfigured,
setHealth: {} as SetHealth,
exposeForDependents: {} as ExposeForDependentsParams,
exposeUi: {} as { [key: string]: ExposedUI },
getSslCertificate: {} as GetSslCertificateParams,
getSslKey: {} as GetSslKeyParams,
getServiceInterface: {} as GetServiceInterfaceParams,

View File

@@ -1,4 +1,5 @@
import { MainEffects, StartSdk } from "../StartSdk"
import { extractJsonPath } from "../store/PathBuilder"
import { Effects } from "../types"
type Store = {
@@ -17,19 +18,21 @@ const sdk = StartSdk.of()
.withStore<Store>()
.build(true)
const storePath = sdk.StorePath
describe("Store", () => {
test("types", async () => {
;async () => {
sdk.store.setOwn(todo<Effects>(), "/config", {
sdk.store.setOwn(todo<Effects>(), storePath.config, {
someValue: "a",
})
sdk.store.setOwn(todo<Effects>(), "/config/someValue", "b")
sdk.store.setOwn(todo<Effects>(), "", {
sdk.store.setOwn(todo<Effects>(), storePath.config.someValue, "b")
sdk.store.setOwn(todo<Effects>(), storePath, {
config: { someValue: "b" },
})
sdk.store.setOwn(
todo<Effects>(),
"/config/someValue",
storePath.config.someValue,
// @ts-expect-error Type is wrong for the setting value
5,
@@ -41,48 +44,42 @@ describe("Store", () => {
"someValue",
)
todo<Effects>().store.set<Store, "/config/someValue">({
path: "/config/someValue",
todo<Effects>().store.set<Store>({
path: extractJsonPath(storePath.config.someValue),
value: "b",
})
todo<Effects>().store.set<Store, "/config/some2Value">({
//@ts-expect-error Path is wrong
path: "/config/someValue",
path: extractJsonPath(storePath.config.someValue),
//@ts-expect-error Path is wrong
value: "someValueIn",
})
todo<Effects>().store.set<Store, "/config/someValue">({
//@ts-expect-error Path is wrong
path: "/config/some2Value",
value: "a",
})
;(await sdk.store
.getOwn(todo<MainEffects>(), "/config/someValue")
.getOwn(todo<MainEffects>(), storePath.config.someValue)
.const()) satisfies string
;(await sdk.store
.getOwn(todo<MainEffects>(), "/config")
.getOwn(todo<MainEffects>(), storePath.config)
.const()) satisfies Store["config"]
await sdk.store // @ts-expect-error Path is wrong
.getOwn(todo<MainEffects>(), "/config/somdsfeValue")
.const()
/// ----------------- ERRORS -----------------
sdk.store.setOwn(todo<MainEffects>(), "", {
sdk.store.setOwn(todo<MainEffects>(), storePath, {
// @ts-expect-error Type is wrong for the setting value
config: { someValue: "notInAOrB" },
})
sdk.store.setOwn(
todo<MainEffects>(),
"/config/someValue",
sdk.StorePath.config.someValue,
// @ts-expect-error Type is wrong for the setting value
"notInAOrB",
)
;(await sdk.store
.getOwn(todo<Effects>(), "/config/someValue")
.getOwn(todo<Effects>(), storePath.config.someValue)
// @ts-expect-error Const should normally not be callable
.const()) satisfies string
;(await sdk.store
.getOwn(todo<Effects>(), "/config")
.getOwn(todo<Effects>(), storePath.config)
// @ts-expect-error Const should normally not be callable
.const()) satisfies Store["config"]
await sdk.store // @ts-expect-error Path is wrong
@@ -92,14 +89,14 @@ describe("Store", () => {
///
;(await sdk.store
.getOwn(todo<MainEffects>(), "/config/someValue")
.getOwn(todo<MainEffects>(), storePath.config.someValue)
// @ts-expect-error satisfies type is wrong
.const()) satisfies number
;(await sdk.store // @ts-expect-error Path is wrong
.getOwn(todo<MainEffects>(), "/config/")
.const()) satisfies Store["config"]
;(await todo<Effects>().store.get<Store, "/config/someValue">({
path: "/config/someValue",
await sdk.store // @ts-expect-error Path is wrong
.getOwn(todo<MainEffects>(), extractJsonPath(storePath.config))
.const()
;(await todo<Effects>().store.get({
path: extractJsonPath(storePath.config.someValue),
callback: noop,
})) satisfies string
await todo<Effects>().store.get<Store, "/config/someValue">({

View File

@@ -5,6 +5,8 @@ import { InputSpec } from "./config/configTypes"
import { DependenciesReceipt } from "./config/setupConfig"
import { BindOptions, Scheme } from "./interfaces/Host"
import { Daemons } from "./mainFn/Daemons"
import { PathBuilder, StorePath } from "./store/PathBuilder"
import { ExposedStorePaths } from "./store/setupExposeStore"
import { UrlString } from "./util/getServiceInterface"
export { SDKManifest } from "./manifest/ManifestTypes"
@@ -93,6 +95,10 @@ export namespace ExpectedExports {
* that this service could use.
*/
export type dependencyConfig = Record<PackageId, DependencyConfig | null>
export type Properties = (options: {
effects: Effects
}) => Promise<PropertiesReturn>
}
export type TimeMs = number
export type VersionString = string
@@ -249,31 +255,21 @@ export type ServiceInterfaceWithHostInfo = ServiceInterface & {
hostInfo: HostInfo
}
// prettier-ignore
export type ExposeAllServicePaths<Store, PreviousPath extends string = ""> =
Store extends never ? string :
Store extends Record<string, unknown> ? {[K in keyof Store & string]: ExposeAllServicePaths<Store[K], `${PreviousPath}/${K & string}`>}[keyof Store & string] :
PreviousPath
// prettier-ignore
export type ExposeAllUiPaths<Store, PreviousPath extends string = ""> =
Store extends Record<string, unknown> ? {[K in keyof Store & string]: ExposeAllUiPaths<Store[K], `${PreviousPath}/${K & string}`>}[keyof Store & string] :
Store extends string ? PreviousPath :
never
export type ExposeServicePaths<Store = never> = {
/** The path to the value in the Store. [JsonPath](https://jsonpath.com/) */
paths: Store extends never ? string[] : ExposeAllServicePaths<Store>[]
paths: ExposedStorePaths
}
export type ExposeUiPaths<Store> =
export type SdkPropertiesValue =
| {
type: "object"
value: { [k: string]: ExposeUiPaths<Store> }
value: { [k: string]: SdkPropertiesValue }
description?: string
}
| {
type: "string"
/** The path to the value in the Store. [JsonPath](https://jsonpath.com/) */
path: ExposeAllUiPaths<Store>
/** Value */
value: string
/** A human readable description or explanation of the value */
description?: string
/** (string/number only) Whether or not to mask the value, for example, when displaying a password */
@@ -283,16 +279,21 @@ export type ExposeUiPaths<Store> =
/** (string/number only) Whether or not to include a button for displaying the value as a QR code */
qr?: boolean
}
export type ExposeUiPathsAll =
export type SdkPropertiesReturn = {
[key: string]: SdkPropertiesValue
}
export type PropertiesValue =
| {
type: "object"
value: { [k: string]: ExposeUiPathsAll }
value: { [k: string]: PropertiesValue }
description: string | null
}
| {
type: "string"
/** The path to the value in the Store. [JsonPath](https://jsonpath.com/) */
path: string
/** Value */
value: string
/** A human readable description or explanation of the value */
description: string | null
/** (string/number only) Whether or not to mask the value, for example, when displaying a password */
@@ -303,6 +304,10 @@ export type ExposeUiPathsAll =
qr: boolean | null
}
export type PropertiesReturn = {
[key: string]: PropertiesValue
}
/** Used to reach out from the pure js runtime */
export type Effects = {
executeAction<Input>(opts: {
@@ -362,18 +367,18 @@ export type Effects = {
store: {
/** Get a value in a json like data, can be observed and subscribed */
get<Store = never, Path extends string = never>(options: {
get<Store = never, ExtractStore = unknown>(options: {
/** If there is no packageId it is assumed the current package */
packageId?: string
/** The path defaults to root level, using the [JsonPath](https://jsonpath.com/) */
path: Path & EnsureStorePath<Store, Path>
path: StorePath
callback: (config: unknown, previousConfig: unknown) => void
}): Promise<ExtractStore<Store, Path>>
}): Promise<ExtractStore>
/** Used to store values that can be accessed and subscribed to */
set<Store = never, Path extends string = never>(options: {
set<Store = never, ExtractStore = unknown>(options: {
/** Sets the value for the wrapper at the path, it will override, using the [JsonPath](https://jsonpath.com/) */
path: Path & EnsureStorePath<Store, Path>
value: ExtractStore<Store, Path>
path: StorePath
value: ExtractStore
}): Promise<void>
}
@@ -400,7 +405,6 @@ export type Effects = {
exposeForDependents(options: { paths: string[] }): Promise<void>
exposeUi(options: { [key: string]: ExposeUiPathsAll }): Promise<void>
/**
* There are times that we want to see the addresses that where exported
* @param options.addressId If we want to filter the address id
@@ -525,22 +529,6 @@ export type Effects = {
stopped(options: { packageId: string | null }): Promise<boolean>
}
// prettier-ignore
export type ExtractStore<Store, Path extends string> =
Path extends `/${infer A }/${infer Rest }` ? (A extends keyof Store ? ExtractStore<Store[A], `/${Rest}`> : never) :
Path extends `/${infer A }` ? (A extends keyof Store ? Store[A] : never) :
Path extends '' ? Store :
never
// prettier-ignore
type _EnsureStorePath<Store, Path extends string, Origin extends string> =
Path extends`/${infer A }/${infer Rest}` ? (Store extends {[K in A & string]: infer NextStore} ? _EnsureStorePath<NextStore, `/${Rest}`, Origin> : never) :
Path extends `/${infer A }` ? (Store extends {[K in A]: infer B} ? Origin : never) :
Path extends '' ? Origin :
never
// prettier-ignore
export type EnsureStorePath<Store, Path extends string> = _EnsureStorePath<Store, Path, Path>
/** rsync options: https://linux.die.net/man/1/rsync
*/
export type BackupOptions = {

View File

@@ -23,6 +23,8 @@ export const isKnownError = (e: unknown): e is T.KnownError =>
declare const affine: unique symbol
export type Affine<A> = { [affine]: A }
type NeverPossible = { [affine]: string }
export type NoAny<A> = NeverPossible extends A
? keyof NeverPossible extends keyof A