export api types to ts (#2583)

This commit is contained in:
Aiden McClelland
2024-04-01 13:14:22 -06:00
committed by GitHub
parent 8884f64b4e
commit f021ad9b0a
94 changed files with 629 additions and 179 deletions

View File

@@ -183,7 +183,7 @@ container-runtime/node_modules: container-runtime/package.json container-runtime
core/startos/bindings: $(shell git ls-files -- core ':!:core/startos/bindings/*') $(ENVIRONMENT_FILE)
rm -rf core/startos/bindings
(cd core/ && cargo test --features=test)
ls core/startos/bindings/*.ts | sed 's/core\/startos\/bindings\/\([^.]*\)\.ts/export { \1 } from ".\/\1.ts";/g' > core/startos/bindings/index.ts
ls core/startos/bindings/*.ts | sed 's/core\/startos\/bindings\/\([^.]*\)\.ts/export { \1 } from ".\/\1";/g' > core/startos/bindings/index.ts
npm --prefix sdk exec -- prettier -w ./core/startos/bindings/*.ts
sdk/dist: $(shell git ls-files sdk) core/startos/bindings

4
core/Cargo.lock generated
View File

@@ -5400,7 +5400,7 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
[[package]]
name = "ts-rs"
version = "8.1.0"
source = "git+https://github.com/dr-bonez/ts-rs.git?branch=feature/top-level-type-override#3f7ff0f0f418c7fa1f1cf6b48697ca9e74f68201"
source = "git+https://github.com/dr-bonez/ts-rs.git?branch=feature/top-level-as#d5f359d803158e06f47977a6f785878a82221d4f"
dependencies = [
"thiserror",
"ts-rs-macros",
@@ -5409,7 +5409,7 @@ dependencies = [
[[package]]
name = "ts-rs-macros"
version = "8.1.0"
source = "git+https://github.com/dr-bonez/ts-rs.git?branch=feature/top-level-type-override#3f7ff0f0f418c7fa1f1cf6b48697ca9e74f68201"
source = "git+https://github.com/dr-bonez/ts-rs.git?branch=feature/top-level-as#d5f359d803158e06f47977a6f785878a82221d4f"
dependencies = [
"Inflector",
"proc-macro2",

View File

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

View File

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

View File

@@ -0,0 +1,9 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ActionId } from "./ActionId";
import type { PackageId } from "./PackageId";
export type ActionParams = {
id: PackageId;
actionId: ActionId;
input: { [key: string]: any } | null;
};

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { EncryptedWire } from "./EncryptedWire";
export type AttachParams = {
startOsPassword: EncryptedWire | null;
guid: string;
};

View File

@@ -0,0 +1,11 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { BackupTargetId } from "./BackupTargetId";
import type { PackageId } from "./PackageId";
import type { PasswordType } from "./PasswordType";
export type BackupParams = {
targetId: BackupTargetId;
oldPassword: PasswordType | null;
packageIds: Array<PackageId> | null;
password: PasswordType;
};

View File

@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { BlockDev } from "./BlockDev";
import type { Cifs } from "./Cifs";
export type BackupTargetFS =
| ({ type: "disk" } & BlockDev)
| ({ type: "cifs" } & Cifs);

View File

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

View File

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

View File

@@ -0,0 +1,8 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type Cifs = {
hostname: string;
path: string;
username: string;
password: string | null;
};

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,10 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { NotificationLevel } from "./NotificationLevel";
import type { PackageId } from "./PackageId";
export type CreateParams = {
package: PackageId | null;
level: NotificationLevel;
title: string;
message: string;
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,10 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { EncryptedWire } from "./EncryptedWire";
import type { RecoverySource } from "./RecoverySource";
export type ExecuteParams = {
startOsLogicalname: string;
startOsPassword: EncryptedWire;
recoverySource: RecoverySource | null;
recoveryPassword: EncryptedWire | null;
};

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,10 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { MinMax } from "./MinMax";
import type { PackageId } from "./PackageId";
export type InstallParams = {
id: PackageId;
marketplaceUrl: string | null;
versionSpec: string | null;
versionPriority: MinMax | null;
};

View File

@@ -0,0 +1,8 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type KernelLogsParams = {
limit: number | null;
cursor: string | null;
before: boolean;
follow: boolean;
};

View File

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

View File

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

View File

@@ -0,0 +1,8 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { PasswordType } from "./PasswordType";
export type LoginParams = {
password: PasswordType | null;
userAgent: string | null;
metadata: any;
};

View File

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

View File

@@ -0,0 +1,8 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type LogsParams = {
limit: number | null;
cursor: string | null;
before: boolean;
follow: boolean;
};

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { BackupTargetFS } from "./BackupTargetFS";
export type RecoverySource =
| { type: "migrate"; guid: string }
| { type: "backup"; target: BackupTargetFS };

View File

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

View File

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

View File

@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { PasswordType } from "./PasswordType";
export type ResetPasswordParams = {
oldPassword: PasswordType | null;
newPassword: PasswordType | null;
};

View File

@@ -0,0 +1,9 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { BackupTargetId } from "./BackupTargetId";
import type { PackageId } from "./PackageId";
export type RestorePackageParams = {
ids: Array<PackageId>;
targetId: BackupTargetId;
password: string;
};

View File

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

View File

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

View File

@@ -0,0 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type Sessions = {
[key: string]: { loggedIn: string; lastActive: string; metadata: any };
};

View File

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

View File

@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Duration } from "./Duration";
export type SetParams = {
timeout: Duration | null;
config: { [key: string]: any } | null;
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,9 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { EncryptedWire } from "./EncryptedWire";
export type VerifyCifsParams = {
hostname: string;
path: string;
username: string;
password: EncryptedWire | null;
};

View File

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

View File

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

View File

@@ -1,97 +1,152 @@
export { ActionId } from "./ActionId.ts";
export { ActionMetadata } from "./ActionMetadata.ts";
export { AddressInfo } from "./AddressInfo.ts";
export { AddSslOptions } from "./AddSslOptions.ts";
export { Alerts } from "./Alerts.ts";
export { Algorithm } from "./Algorithm.ts";
export { AllowedStatuses } from "./AllowedStatuses.ts";
export { AllPackageData } from "./AllPackageData.ts";
export { AlpnInfo } from "./AlpnInfo.ts";
export { BackupProgress } from "./BackupProgress.ts";
export { BindInfo } from "./BindInfo.ts";
export { BindOptions } from "./BindOptions.ts";
export { BindParams } from "./BindParams.ts";
export { Callback } from "./Callback.ts";
export { ChrootParams } from "./ChrootParams.ts";
export { CreateOverlayedImageParams } from "./CreateOverlayedImageParams.ts";
export { CurrentDependencies } from "./CurrentDependencies.ts";
export { CurrentDependencyInfo } from "./CurrentDependencyInfo.ts";
export { DataUrl } from "./DataUrl.ts";
export { Dependencies } from "./Dependencies.ts";
export { DependencyConfigErrors } from "./DependencyConfigErrors.ts";
export { DependencyKind } from "./DependencyKind.ts";
export { DependencyRequirement } from "./DependencyRequirement.ts";
export { DepInfo } from "./DepInfo.ts";
export { Description } from "./Description.ts";
export { DestroyOverlayedImageParams } from "./DestroyOverlayedImageParams.ts";
export { Duration } from "./Duration.ts";
export { ExecuteAction } from "./ExecuteAction.ts";
export { ExportActionParams } from "./ExportActionParams.ts";
export { ExportedHostInfo } from "./ExportedHostInfo.ts";
export { ExportedHostnameInfo } from "./ExportedHostnameInfo.ts";
export { ExportedIpHostname } from "./ExportedIpHostname.ts";
export { ExportedOnionHostname } from "./ExportedOnionHostname.ts";
export { ExportServiceInterfaceParams } from "./ExportServiceInterfaceParams.ts";
export { ExposeForDependentsParams } from "./ExposeForDependentsParams.ts";
export { FullProgress } from "./FullProgress.ts";
export { GetHostInfoParamsKind } from "./GetHostInfoParamsKind.ts";
export { GetHostInfoParams } from "./GetHostInfoParams.ts";
export { GetPrimaryUrlParams } from "./GetPrimaryUrlParams.ts";
export { GetServiceInterfaceParams } from "./GetServiceInterfaceParams.ts";
export { GetServicePortForwardParams } from "./GetServicePortForwardParams.ts";
export { GetSslCertificateParams } from "./GetSslCertificateParams.ts";
export { GetSslKeyParams } from "./GetSslKeyParams.ts";
export { GetStoreParams } from "./GetStoreParams.ts";
export { GetSystemSmtpParams } from "./GetSystemSmtpParams.ts";
export { Governor } from "./Governor.ts";
export { HardwareRequirements } from "./HardwareRequirements.ts";
export { HealthCheckId } from "./HealthCheckId.ts";
export { HealthCheckResult } from "./HealthCheckResult.ts";
export { HostAddress } from "./HostAddress.ts";
export { HostId } from "./HostId.ts";
export { HostInfo } from "./HostInfo.ts";
export { HostKind } from "./HostKind.ts";
export { Host } from "./Host.ts";
export { ImageId } from "./ImageId.ts";
export { InstalledState } from "./InstalledState.ts";
export { InstallingInfo } from "./InstallingInfo.ts";
export { InstallingState } from "./InstallingState.ts";
export { IpInfo } from "./IpInfo.ts";
export { ListServiceInterfacesParams } from "./ListServiceInterfacesParams.ts";
export { MainStatus } from "./MainStatus.ts";
export { Manifest } from "./Manifest.ts";
export { MaybeUtf8String } from "./MaybeUtf8String.ts";
export { MountParams } from "./MountParams.ts";
export { MountTarget } from "./MountTarget.ts";
export { NamedProgress } from "./NamedProgress.ts";
export { PackageDataEntry } from "./PackageDataEntry.ts";
export { PackageId } from "./PackageId.ts";
export { PackageState } from "./PackageState.ts";
export { ParamsMaybePackageId } from "./ParamsMaybePackageId.ts";
export { ParamsPackageId } from "./ParamsPackageId.ts";
export { Progress } from "./Progress.ts";
export { Public } from "./Public.ts";
export { RemoveActionParams } from "./RemoveActionParams.ts";
export { RemoveAddressParams } from "./RemoveAddressParams.ts";
export { ReverseProxyBind } from "./ReverseProxyBind.ts";
export { ReverseProxyDestination } from "./ReverseProxyDestination.ts";
export { ReverseProxyHttp } from "./ReverseProxyHttp.ts";
export { ReverseProxyParams } from "./ReverseProxyParams.ts";
export { Security } from "./Security.ts";
export { ServerInfo } from "./ServerInfo.ts";
export { ServerSpecs } from "./ServerSpecs.ts";
export { ServerStatus } from "./ServerStatus.ts";
export { ServiceInterfaceId } from "./ServiceInterfaceId.ts";
export { ServiceInterface } from "./ServiceInterface.ts";
export { ServiceInterfaceType } from "./ServiceInterfaceType.ts";
export { ServiceInterfaceWithHostInfo } from "./ServiceInterfaceWithHostInfo.ts";
export { SetConfigured } from "./SetConfigured.ts";
export { SetDependenciesParams } from "./SetDependenciesParams.ts";
export { SetHealth } from "./SetHealth.ts";
export { SetMainStatus } from "./SetMainStatus.ts";
export { SetStoreParams } from "./SetStoreParams.ts";
export { Status } from "./Status.ts";
export { UpdateProgress } from "./UpdateProgress.ts";
export { UpdatingState } from "./UpdatingState.ts";
export { VolumeId } from "./VolumeId.ts";
export { WifiInfo } from "./WifiInfo.ts";
export { ActionId } from "./ActionId";
export { ActionMetadata } from "./ActionMetadata";
export { ActionParams } from "./ActionParams";
export { AddImageParams } from "./AddImageParams";
export { AddParams } from "./AddParams";
export { AddressInfo } from "./AddressInfo";
export { AddSslOptions } from "./AddSslOptions";
export { Alerts } from "./Alerts";
export { Algorithm } from "./Algorithm";
export { AllowedStatuses } from "./AllowedStatuses";
export { AllPackageData } from "./AllPackageData";
export { AlpnInfo } from "./AlpnInfo";
export { ApplyParams } from "./ApplyParams";
export { AttachParams } from "./AttachParams";
export { BackupParams } from "./BackupParams";
export { BackupProgress } from "./BackupProgress";
export { BackupTargetFS } from "./BackupTargetFS";
export { BackupTargetId } from "./BackupTargetId";
export { BindInfo } from "./BindInfo";
export { BindOptions } from "./BindOptions";
export { BindParams } from "./BindParams";
export { BlockDev } from "./BlockDev";
export { Callback } from "./Callback";
export { ChrootParams } from "./ChrootParams";
export { Cifs } from "./Cifs";
export { ConfigParams } from "./ConfigParams";
export { ConfigureParams } from "./ConfigureParams";
export { ConnectParams } from "./ConnectParams";
export { ControlParams } from "./ControlParams";
export { CreateOverlayedImageParams } from "./CreateOverlayedImageParams";
export { CreateParams } from "./CreateParams";
export { CurrentDependencies } from "./CurrentDependencies";
export { CurrentDependencyInfo } from "./CurrentDependencyInfo";
export { DataUrl } from "./DataUrl";
export { DeleteBeforeParams } from "./DeleteBeforeParams";
export { DeleteParams } from "./DeleteParams";
export { Dependencies } from "./Dependencies";
export { DependencyConfigErrors } from "./DependencyConfigErrors";
export { DependencyKind } from "./DependencyKind";
export { DependencyRequirement } from "./DependencyRequirement";
export { DepInfo } from "./DepInfo";
export { Description } from "./Description";
export { DestroyOverlayedImageParams } from "./DestroyOverlayedImageParams";
export { DumpParams } from "./DumpParams";
export { Duration } from "./Duration";
export { EchoParams } from "./EchoParams";
export { EditManifestParams } from "./EditManifestParams";
export { EncryptedWire } from "./EncryptedWire";
export { ExecuteAction } from "./ExecuteAction";
export { ExecuteParams } from "./ExecuteParams";
export { ExportActionParams } from "./ExportActionParams";
export { ExportedHostInfo } from "./ExportedHostInfo";
export { ExportedHostnameInfo } from "./ExportedHostnameInfo";
export { ExportedIpHostname } from "./ExportedIpHostname";
export { ExportedOnionHostname } from "./ExportedOnionHostname";
export { ExportServiceInterfaceParams } from "./ExportServiceInterfaceParams";
export { ExposeForDependentsParams } from "./ExposeForDependentsParams";
export { FullProgress } from "./FullProgress";
export { GetHostInfoParamsKind } from "./GetHostInfoParamsKind";
export { GetHostInfoParams } from "./GetHostInfoParams";
export { GetParams } from "./GetParams";
export { GetPrimaryUrlParams } from "./GetPrimaryUrlParams";
export { GetServiceInterfaceParams } from "./GetServiceInterfaceParams";
export { GetServicePortForwardParams } from "./GetServicePortForwardParams";
export { GetSslCertificateParams } from "./GetSslCertificateParams";
export { GetSslKeyParams } from "./GetSslKeyParams";
export { GetStoreParams } from "./GetStoreParams";
export { GetSystemSmtpParams } from "./GetSystemSmtpParams";
export { GovernorParams } from "./GovernorParams";
export { Governor } from "./Governor";
export { HardwareRequirements } from "./HardwareRequirements";
export { HealthCheckId } from "./HealthCheckId";
export { HealthCheckResult } from "./HealthCheckResult";
export { HostAddress } from "./HostAddress";
export { HostId } from "./HostId";
export { HostInfo } from "./HostInfo";
export { HostKind } from "./HostKind";
export { Host } from "./Host";
export { ImageId } from "./ImageId";
export { InfoParams } from "./InfoParams";
export { InstalledState } from "./InstalledState";
export { InstallingInfo } from "./InstallingInfo";
export { InstallingState } from "./InstallingState";
export { InstallParams } from "./InstallParams";
export { IpInfo } from "./IpInfo";
export { KernelLogsParams } from "./KernelLogsParams";
export { KillParams } from "./KillParams";
export { ListParams } from "./ListParams";
export { ListServiceInterfacesParams } from "./ListServiceInterfacesParams";
export { LoginParams } from "./LoginParams";
export { LogoutParams } from "./LogoutParams";
export { LogsParams } from "./LogsParams";
export { MainStatus } from "./MainStatus";
export { Manifest } from "./Manifest";
export { MaybeUtf8String } from "./MaybeUtf8String";
export { MinMax } from "./MinMax";
export { MountParams } from "./MountParams";
export { MountTarget } from "./MountTarget";
export { NamedProgress } from "./NamedProgress";
export { NotificationLevel } from "./NotificationLevel";
export { PackageDataEntry } from "./PackageDataEntry";
export { PackageId } from "./PackageId";
export { PackageState } from "./PackageState";
export { ParamsMaybePackageId } from "./ParamsMaybePackageId";
export { ParamsPackageId } from "./ParamsPackageId";
export { PasswordType } from "./PasswordType";
export { Progress } from "./Progress";
export { Public } from "./Public";
export { RecoverySource } from "./RecoverySource";
export { RemoveActionParams } from "./RemoveActionParams";
export { RemoveAddressParams } from "./RemoveAddressParams";
export { RemoveParams } from "./RemoveParams";
export { ResetParams } from "./ResetParams";
export { ResetPasswordParams } from "./ResetPasswordParams";
export { RestorePackageParams } from "./RestorePackageParams";
export { ReverseProxyBind } from "./ReverseProxyBind";
export { ReverseProxyDestination } from "./ReverseProxyDestination";
export { ReverseProxyHttp } from "./ReverseProxyHttp";
export { ReverseProxyParams } from "./ReverseProxyParams";
export { Security } from "./Security";
export { ServerInfo } from "./ServerInfo";
export { ServerSpecs } from "./ServerSpecs";
export { ServerStatus } from "./ServerStatus";
export { ServiceInterfaceId } from "./ServiceInterfaceId";
export { ServiceInterface } from "./ServiceInterface";
export { ServiceInterfaceType } from "./ServiceInterfaceType";
export { ServiceInterfaceWithHostInfo } from "./ServiceInterfaceWithHostInfo";
export { SessionList } from "./SessionList";
export { Sessions } from "./Sessions";
export { Session } from "./Session";
export { SetConfigured } from "./SetConfigured";
export { SetCountryParams } from "./SetCountryParams";
export { SetDependenciesParams } from "./SetDependenciesParams";
export { SetHealth } from "./SetHealth";
export { SetMainStatus } from "./SetMainStatus";
export { SetParams } from "./SetParams";
export { SetStoreParams } from "./SetStoreParams";
export { SshPubKey } from "./SshPubKey";
export { SsidParams } from "./SsidParams";
export { Status } from "./Status";
export { UiParams } from "./UiParams";
export { UmountParams } from "./UmountParams";
export { UninstallParams } from "./UninstallParams";
export { UpdateParams } from "./UpdateParams";
export { UpdateProgress } from "./UpdateProgress";
export { UpdateSystemParams } from "./UpdateSystemParams";
export { UpdatingState } from "./UpdatingState";
export { VerifyCifsParams } from "./VerifyCifsParams";
export { VerifyParams } from "./VerifyParams";
export { VolumeId } from "./VolumeId";
export { WifiInfo } from "./WifiInfo";
export { ZramParams } from "./ZramParams";

View File

@@ -4,6 +4,7 @@ use models::PackageId;
use rpc_toolkit::command;
use serde::{Deserialize, Serialize};
use tracing::instrument;
use ts_rs::TS;
use crate::config::Config;
use crate::context::RpcContext;
@@ -47,17 +48,17 @@ pub fn display_action_result(params: WithIoFormat<ActionParams>, result: ActionR
}
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct ActionParams {
#[arg(id = "id")]
#[serde(rename = "id")]
pub package_id: PackageId,
#[arg(id = "action-id")]
#[serde(rename = "action-id")]
pub action_id: ActionId,
#[command(flatten)]
#[ts(type = "{ [key: string]: any } | null")]
pub input: StdinDeserializable<Option<Config>>,
}
// impl C

View File

@@ -9,6 +9,7 @@ use rpc_toolkit::yajrc::RpcError;
use rpc_toolkit::{command, from_fn_async, AnyContext, CallRemote, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize};
use tracing::instrument;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext};
use crate::db::model::DatabaseModel;
@@ -20,7 +21,8 @@ use crate::util::crypto::EncryptedWire;
use crate::util::serde::{display_serializable, HandlerExtSerde, WithIoFormat};
use crate::{ensure_code, Error, ResultExt};
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
#[derive(Debug, Clone, Default, Deserialize, Serialize, TS)]
#[ts(as = "BTreeMap::<String, Session>")]
pub struct Sessions(pub BTreeMap<InternedString, Session>);
impl Sessions {
pub fn new() -> Self {
@@ -38,8 +40,9 @@ impl Map for Sessions {
}
}
#[derive(Clone, Serialize, Deserialize)]
#[derive(Clone, Serialize, Deserialize, TS)]
#[serde(untagged)]
#[ts(export)]
pub enum PasswordType {
EncryptedWire(EncryptedWire),
String(String),
@@ -177,14 +180,16 @@ pub fn check_password_against_db(db: &DatabaseModel, password: &str) -> Result<(
Ok(())
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct LoginParams {
password: Option<PasswordType>,
#[serde(default)]
user_agent: Option<String>,
#[serde(default)]
#[ts(type = "any")]
metadata: Value,
}
@@ -218,10 +223,12 @@ pub async fn login_impl(
.await
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct LogoutParams {
#[ts(type = "string")]
session: InternedString,
}
@@ -234,18 +241,25 @@ pub async fn logout(
))
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct Session {
#[ts(type = "string")]
pub logged_in: DateTime<Utc>,
#[ts(type = "string")]
pub last_active: DateTime<Utc>,
#[ts(skip)]
pub user_agent: Option<String>,
#[ts(type = "any")]
pub metadata: Value,
}
#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct SessionList {
#[ts(type = "string")]
current: InternedString,
sessions: Sessions,
}
@@ -303,11 +317,13 @@ fn display_sessions(params: WithIoFormat<ListParams>, arg: SessionList) {
table.print_tty(false).unwrap();
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct ListParams {
#[arg(skip)]
#[ts(skip)]
session: InternedString,
}
@@ -338,9 +354,10 @@ impl AsLogoutSessionId for KillSessionId {
}
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct KillParams {
ids: Vec<String>,
}
@@ -351,9 +368,10 @@ pub async fn kill(ctx: RpcContext, KillParams { ids }: KillParams) -> Result<(),
Ok(())
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct ResetPasswordParams {
old_password: Option<PasswordType>,
new_password: Option<PasswordType>,

View File

@@ -11,6 +11,7 @@ use models::PackageId;
use serde::{Deserialize, Serialize};
use tokio::io::AsyncWriteExt;
use tracing::instrument;
use ts_rs::TS;
use super::target::BackupTargetId;
use super::PackageBackupReport;
@@ -29,9 +30,10 @@ use crate::util::io::dir_copy;
use crate::util::serde::IoFormat;
use crate::version::VersionT;
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct BackupParams {
target_id: BackupTargetId,
#[arg(long = "old-password")]

View File

@@ -9,6 +9,7 @@ use patch_db::json_ptr::ROOT;
use serde::{Deserialize, Serialize};
use torut::onion::OnionAddressV3;
use tracing::instrument;
use ts_rs::TS;
use super::target::BackupTargetId;
use crate::backup::os::OsBackup;
@@ -24,9 +25,10 @@ use crate::s9pk::S9pk;
use crate::service::service_map::DownloadInstallFuture;
use crate::util::serde::IoFormat;
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct RestorePackageParams {
pub ids: Vec<PackageId>,
pub target_id: BackupTargetId,

View File

@@ -6,6 +6,7 @@ use color_eyre::eyre::eyre;
use imbl_value::InternedString;
use rpc_toolkit::{command, from_fn_async, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize};
use ts_rs::TS;
use super::{BackupTarget, BackupTargetId};
use crate::context::{CliContext, RpcContext};
@@ -67,9 +68,10 @@ pub fn cifs() -> ParentHandler {
)
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct AddParams {
pub hostname: String,
pub path: PathBuf,
@@ -121,9 +123,10 @@ pub async fn add(
})
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct UpdateParams {
pub id: BackupTargetId,
pub hostname: String,
@@ -185,9 +188,10 @@ pub async fn update(
})
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct RemoveParams {
pub id: BackupTargetId,
}

View File

@@ -13,6 +13,7 @@ use serde::{Deserialize, Serialize};
use sha2::Sha256;
use tokio::sync::Mutex;
use tracing::instrument;
use ts_rs::TS;
use self::cifs::CifsBackupTarget;
use crate::context::{CliContext, RpcContext};
@@ -46,7 +47,8 @@ pub enum BackupTarget {
Cifs(CifsBackupTarget),
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, TS)]
#[ts(type = "string")]
pub enum BackupTargetId {
Disk { logicalname: PathBuf },
Cifs { id: u32 },
@@ -107,7 +109,7 @@ impl Serialize for BackupTargetId {
}
}
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, TS)]
#[serde(tag = "type")]
#[serde(rename_all = "camelCase")]
pub enum BackupTargetFS {
@@ -242,9 +244,10 @@ fn display_backup_info(params: WithIoFormat<InfoParams>, info: BackupInfo) {
table.print_tty(false).unwrap();
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct InfoParams {
target_id: BackupTargetId,
password: String,
@@ -276,9 +279,10 @@ lazy_static::lazy_static! {
Mutex::new(BTreeMap::new());
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct MountParams {
target_id: BackupTargetId,
password: String,
@@ -311,9 +315,10 @@ pub async fn mount(
Ok(res)
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct UmountParams {
target_id: Option<BackupTargetId>,
}

View File

@@ -12,6 +12,7 @@ use regex::Regex;
use rpc_toolkit::{from_fn_async, Empty, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize};
use tracing::instrument;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext};
use crate::prelude::*;
@@ -125,9 +126,10 @@ pub enum MatchError {
ListUniquenessViolation,
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct ConfigParams {
pub id: PackageId,
}
@@ -156,12 +158,14 @@ pub async fn get(ctx: RpcContext, _: Empty, id: PackageId) -> Result<ConfigRes,
.await
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct SetParams {
#[arg(long = "timeout")]
pub timeout: Option<crate::util::serde::Duration>,
#[command(flatten)]
#[ts(type = "{ [key: string]: any } | null")]
pub config: StdinDeserializable<Option<Config>>,
}

View File

@@ -4,14 +4,16 @@ use models::PackageId;
use rpc_toolkit::command;
use serde::{Deserialize, Serialize};
use tracing::instrument;
use ts_rs::TS;
use crate::context::RpcContext;
use crate::prelude::*;
use crate::Error;
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct ControlParams {
pub id: PackageId,
}

View File

@@ -19,6 +19,7 @@ use serde::{Deserialize, Serialize};
use serde_json::Value;
use tokio::sync::oneshot;
use tracing::instrument;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext};
use crate::middleware::auth::{HasValidSession, HashSessionToken};
@@ -215,12 +216,14 @@ async fn cli_dump(
Ok(dump)
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct DumpParams {
#[arg(long = "include-private", short = 'p')]
#[serde(default)]
#[ts(skip)]
include_private: bool,
}
@@ -271,9 +274,10 @@ async fn cli_apply(
Ok(())
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct ApplyParams {
expr: String,
path: Option<PathBuf>,
@@ -309,11 +313,14 @@ pub fn put() -> ParentHandler {
.with_remote_cli::<CliContext>(),
)
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct UiParams {
#[ts(type = "string")]
pointer: JsonPointer,
#[ts(type = "any")]
value: Value,
}

View File

@@ -43,9 +43,10 @@ pub struct DepInfo {
pub optional: bool,
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct ConfigureParams {
dependent_id: PackageId,
dependency_id: PackageId,

View File

@@ -5,6 +5,7 @@ use clap::Parser;
use rpc_toolkit::yajrc::RpcError;
use rpc_toolkit::{command, from_fn, from_fn_async, AnyContext, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize};
use ts_rs::TS;
use crate::context::{CliContext, DiagnosticContext};
use crate::init::SYSTEM_REBUILD_PATH;
@@ -40,10 +41,12 @@ pub fn error(ctx: DiagnosticContext) -> Result<Arc<RpcError>, Error> {
Ok(ctx.error.clone())
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct LogsParams {
#[ts(type = "number | null")]
limit: Option<usize>,
cursor: Option<String>,
before: bool,

View File

@@ -5,12 +5,14 @@ use digest::generic_array::GenericArray;
use digest::{Digest, OutputSizeUser};
use serde::{Deserialize, Serialize};
use sha2::Sha256;
use ts_rs::TS;
use super::FileSystem;
use crate::prelude::*;
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(concrete(LogicalName = std::path::PathBuf))]
pub struct BlockDev<LogicalName: AsRef<Path>> {
logicalname: LogicalName,
}

View File

@@ -8,6 +8,7 @@ use serde::{Deserialize, Serialize};
use sha2::Sha256;
use tokio::process::Command;
use tracing::instrument;
use ts_rs::TS;
use super::{FileSystem, MountType, ReadOnly};
use crate::disk::mount::guard::{GenericMountGuard, TmpMountGuard};
@@ -62,7 +63,7 @@ pub async fn mount_cifs(
Ok(())
}
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
pub struct Cifs {
pub hostname: String,

View File

@@ -23,9 +23,10 @@ pub fn inspect() -> ParentHandler {
.subcommand("docker-images", from_fn_async(docker_images).no_display())
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct HashParams {
path: PathBuf,
}
@@ -38,9 +39,10 @@ pub async fn hash(_: CliContext, HashParams { path }: HashParams) -> Result<Stri
.to_owned())
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct ManifestParams {
path: PathBuf,
#[arg(long = "no-verify")]
@@ -56,9 +58,10 @@ pub async fn manifest(
todo!()
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct InspectParams {
path: PathBuf,
#[arg(long = "no-verify")]
@@ -88,9 +91,10 @@ pub async fn icon(
.await?;
Ok(())
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct InstructionParams {
path: PathBuf,
#[arg(long = "no-verify")]

View File

@@ -15,6 +15,7 @@ use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use tokio::sync::oneshot;
use tracing::instrument;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext};
use crate::core::rpc_continuations::{RequestGuid, RpcContinuation};
@@ -63,7 +64,7 @@ pub async fn list(ctx: RpcContext) -> Result<Value, Error> {
.collect())
}
#[derive(Debug, Clone, Copy, serde::Deserialize, serde::Serialize)]
#[derive(Debug, Clone, Copy, serde::Deserialize, serde::Serialize, TS)]
#[serde(rename_all = "camelCase")]
pub enum MinMax {
Min,
@@ -102,12 +103,14 @@ impl std::fmt::Display for MinMax {
}
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct InstallParams {
id: PackageId,
#[arg(short = 'm', long = "marketplace-url")]
#[ts(type = "string | null")]
marketplace_url: Option<Url>,
#[arg(short = 'v', long = "version-spec")]
version_spec: Option<String>,
@@ -391,9 +394,10 @@ pub async fn cli_install(ctx: CliContext, params: CliInstallParams) -> Result<()
Ok(())
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct UninstallParams {
id: PackageId,
}

View File

@@ -75,13 +75,15 @@ use rpc_toolkit::{
command, from_fn, from_fn_async, from_fn_blocking, AnyContext, HandlerExt, ParentHandler,
};
use serde::{Deserialize, Serialize};
use ts_rs::TS;
use crate::context::CliContext;
use crate::util::serde::HandlerExtSerde;
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct EchoParams {
message: String,
}

View File

@@ -20,6 +20,7 @@ use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::process::Command;
use tokio::sync::Mutex;
use tokio::time::Instant;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext};
use crate::core::rpc_continuations::{RequestGuid, RpcContinuation};
@@ -351,8 +352,10 @@ pub async fn list(ctx: RpcContext) -> Result<Vec<InternedString>, Error> {
Ok(ctx.dev.lxc.lock().await.keys().cloned().collect())
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[ts(export)]
pub struct RemoveParams {
#[ts(type = "string")]
pub guid: InternedString,
}
@@ -363,8 +366,10 @@ pub async fn remove(ctx: RpcContext, RemoveParams { guid }: RemoveParams) -> Res
Ok(())
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[ts(export)]
pub struct ConnectParams {
#[ts(type = "string")]
pub guid: InternedString,
}

View File

@@ -6,6 +6,7 @@ use futures::TryStreamExt;
use rpc_toolkit::{from_fn_async, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize};
use tokio::sync::RwLock;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext};
use crate::db::model::public::IpInfo;
@@ -60,9 +61,10 @@ pub fn dhcp() -> ParentHandler {
.with_remote_cli::<CliContext>(),
)
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct UpdateParams {
interface: String,
}

View File

@@ -22,6 +22,7 @@ use tokio::time::Instant;
use torut::control::{AsyncEvent, AuthenticatedConn, ConnError};
use torut::onion::{OnionAddressV3, TorSecretKeyV3};
use tracing::instrument;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext};
use crate::logs::{
@@ -104,9 +105,10 @@ pub fn tor() -> ParentHandler {
.with_remote_cli::<CliContext>(),
)
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct ResetParams {
#[arg(name = "wipe-state", short = 'w', long = "wipe-state")]
wipe_state: bool,
@@ -142,11 +144,13 @@ pub async fn list_services(ctx: RpcContext, _: Empty) -> Result<Vec<OnionAddress
ctx.net_controller.tor.list_services().await
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct LogsParams {
#[arg(short = 'l', long = "limit")]
#[ts(type = "number | null")]
limit: Option<usize>,
#[arg(short = 'c', long = "cursor")]
cursor: Option<String>,

View File

@@ -13,6 +13,7 @@ use serde::{Deserialize, Serialize};
use tokio::process::Command;
use tokio::sync::RwLock;
use tracing::instrument;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext};
use crate::prelude::*;
@@ -87,9 +88,10 @@ pub fn country() -> ParentHandler {
)
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct AddParams {
ssid: String,
password: String,
@@ -138,9 +140,10 @@ pub async fn add(ctx: RpcContext, AddParams { ssid, password }: AddParams) -> Re
}
Ok(())
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct SsidParams {
ssid: String,
}
@@ -402,11 +405,13 @@ pub async fn get_available(ctx: RpcContext, _: Empty) -> Result<Vec<WifiListOut>
Ok(wifi_list)
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct SetCountryParams {
#[arg(value_parser = CountryCodeParser)]
#[ts(type = "string")]
country: CountryCode,
}
pub async fn set_country(

View File

@@ -11,6 +11,7 @@ use models::PackageId;
use rpc_toolkit::{command, from_fn_async, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize};
use tracing::instrument;
use ts_rs::TS;
use crate::backup::BackupReport;
use crate::context::{CliContext, RpcContext};
@@ -48,11 +49,14 @@ pub fn notification() -> ParentHandler {
)
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct ListParams {
#[ts(type = "number | null")]
before: Option<u32>,
#[ts(type = "number | null")]
limit: Option<usize>,
}
// #[command(display(display_serializable))]
@@ -110,10 +114,12 @@ pub async fn list(
.await
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct DeleteParams {
#[ts(type = "number")]
id: u32,
}
@@ -125,10 +131,12 @@ pub async fn delete(ctx: RpcContext, DeleteParams { id }: DeleteParams) -> Resul
})
.await
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct DeleteBeforeParams {
#[ts(type = "number")]
before: u32,
}
@@ -148,9 +156,10 @@ pub async fn delete_before(
.await
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct CreateParams {
package: Option<PackageId>,
level: NotificationLevel,
@@ -172,7 +181,7 @@ pub async fn create(
.await
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, TS)]
#[serde(rename_all = "camelCase")]
pub enum NotificationLevel {
Success,

View File

@@ -6,6 +6,7 @@ use models::Error;
use rpc_toolkit::{command, from_fn_async, AnyContext, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize};
use tokio::process::Command;
use ts_rs::TS;
use crate::context::config::ServerConfig;
use crate::context::{CliContext, InstallContext};
@@ -112,9 +113,10 @@ async fn partition(disk: &mut DiskInfo, overwrite: bool) -> Result<OsPartitionIn
}
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct ExecuteParams {
logicalname: PathBuf,
#[arg(short = 'o')]

View File

@@ -9,6 +9,7 @@ use indicatif::{ProgressBar, ProgressStyle};
use reqwest::{header, Body, Client, Url};
use rpc_toolkit::command;
use serde::{Deserialize, Serialize};
use ts_rs::TS;
use crate::context::CliContext;
use crate::s9pk::S9pk;

View File

@@ -5,6 +5,7 @@ use reqwest::{StatusCode, Url};
use rpc_toolkit::{command, from_fn_async, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext};
use crate::version::VersionT;
@@ -36,10 +37,12 @@ pub fn with_query_params(ctx: RpcContext, mut url: Url) -> Url {
url
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct GetParams {
#[ts(type = "string")]
url: Url,
}

View File

@@ -8,6 +8,7 @@ use rpc_toolkit::{from_fn_async, Empty, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize};
use tokio::fs::File;
use tokio::process::Command;
use ts_rs::TS;
use crate::context::CliContext;
use crate::prelude::*;
@@ -67,7 +68,8 @@ fn inspect() -> ParentHandler<S9pkPath> {
)
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[ts(export)]
struct AddImageParams {
id: ImageId,
image: String,
@@ -183,7 +185,8 @@ async fn add_image(
Ok(())
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[ts(export)]
struct EditManifestParams {
expression: String,
}

View File

@@ -2,6 +2,7 @@ use std::path::PathBuf;
use clap::Parser;
use serde::{Deserialize, Serialize};
use ts_rs::TS;
pub mod builder;
pub mod docker;
@@ -12,9 +13,10 @@ pub mod reader;
pub const SIG_CONTEXT: &[u8] = b"s9pk";
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct VerifyParams {
pub path: PathBuf,
}

View File

@@ -11,7 +11,9 @@ use rpc_toolkit::{from_fn_async, CallRemoteHandler, Empty, Handler, HandlerArgs}
use serde::{Deserialize, Serialize};
use start_stop::StartStop;
use tokio::sync::Notify;
use ts_rs::TS;
use crate::action::ActionResult;
use crate::config::action::ConfigRes;
use crate::context::{CliContext, RpcContext};
use crate::core::rpc_continuations::RequestGuid;
@@ -28,8 +30,8 @@ use crate::service::transition::TransitionKind;
use crate::status::health_check::HealthCheckResult;
use crate::status::MainStatus;
use crate::util::actor::{Actor, BackgroundJobs, SimpleActor};
use crate::util::serde::Pem;
use crate::volume::data_dir;
use crate::{action::ActionResult, util::serde::Pem};
pub mod cli;
mod config;
@@ -498,7 +500,8 @@ impl Actor for ServiceActor {
}
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[ts(export)]
pub struct ConnectParams {
pub id: PackageId,
}

View File

@@ -4,6 +4,7 @@ use imbl_value::Value;
use models::ProcedureName;
use rpc_toolkit::yajrc::RpcMethod;
use rpc_toolkit::Empty;
use ts_rs::TS;
use crate::prelude::*;
@@ -43,9 +44,10 @@ impl serde::Serialize for Exit {
}
}
#[derive(Clone, serde::Deserialize, serde::Serialize)]
#[derive(Clone, serde::Deserialize, serde::Serialize, TS)]
pub struct ExecuteParams {
procedure: String,
#[ts(type = "any")]
input: Value,
timeout: Option<u128>,
}

View File

@@ -14,6 +14,7 @@ use tokio::io::AsyncWriteExt;
use tokio::try_join;
use torut::onion::OnionAddressV3;
use tracing::instrument;
use ts_rs::TS;
use crate::account::AccountInfo;
use crate::backup::restore::recover_full_embassy;
@@ -99,10 +100,11 @@ async fn setup_init(
))
}
#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct AttachParams {
#[serde(rename = "embassy-password")]
#[serde(rename = "startOsPassword")]
password: Option<EncryptedWire>,
guid: Arc<String>,
}
@@ -210,8 +212,9 @@ pub fn cifs() -> ParentHandler {
ParentHandler::new().subcommand("verify", from_fn_async(verify_cifs).no_cli())
}
#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct VerifyCifsParams {
hostname: String,
path: PathBuf,
@@ -245,7 +248,7 @@ pub async fn verify_cifs(
start_os.ok_or_else(|| Error::new(eyre!("No Backup Found"), crate::ErrorKind::NotFound))
}
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, TS)]
#[serde(tag = "type")]
#[serde(rename_all = "camelCase")]
pub enum RecoverySource {
@@ -253,8 +256,9 @@ pub enum RecoverySource {
Backup { target: BackupTargetFS },
}
#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct ExecuteParams {
start_os_logicalname: PathBuf,
start_os_password: EncryptedWire,

View File

@@ -8,6 +8,7 @@ use imbl_value::InternedString;
use rpc_toolkit::{command, from_fn_async, AnyContext, Empty, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize};
use tracing::instrument;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext};
use crate::prelude::*;
@@ -34,7 +35,8 @@ impl Map for SshKeys {
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[ts(type = "string")]
pub struct SshPubKey(
#[serde(serialize_with = "crate::util::serde::serialize_display")]
#[serde(deserialize_with = "crate::util::serde::deserialize_from_str")]
@@ -102,9 +104,10 @@ pub fn ssh() -> ParentHandler {
)
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct AddParams {
key: SshPubKey,
}
@@ -135,10 +138,12 @@ pub async fn add(ctx: RpcContext, AddParams { key }: AddParams) -> Result<SshKey
Ok(res)
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct DeleteParams {
#[ts(type = "string")]
fingerprint: InternedString,
}

View File

@@ -12,6 +12,7 @@ use tokio::process::Command;
use tokio::sync::broadcast::Receiver;
use tokio::sync::RwLock;
use tracing::instrument;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext};
use crate::disk::util::{get_available, get_used};
@@ -73,9 +74,10 @@ pub async fn enable_zram() -> Result<(), Error> {
Ok(())
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct ZramParams {
enable: bool,
}
@@ -135,9 +137,10 @@ fn display_governor_info(params: WithIoFormat<GovernorParams>, result: GovernorI
table.print_tty(false).unwrap();
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct GovernorParams {
set: Option<Governor>,
}
@@ -229,11 +232,13 @@ pub async fn time(ctx: RpcContext, _: Empty) -> Result<TimeInfo, Error> {
uptime: ctx.start_time.elapsed().as_secs(),
})
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct LogsParams {
#[arg(short = 'l', long = "limit")]
#[ts(type = "number | null")]
limit: Option<usize>,
#[arg(short = 'c', long = "cursor")]
cursor: Option<String>,
@@ -313,11 +318,13 @@ pub async fn logs_follow(
) -> Result<LogFollowResponse, Error> {
follow_logs(ctx, LogSource::System, limit).await
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct KernelLogsParams {
#[arg(short = 'l', long = "limit")]
#[ts(type = "number | null")]
limit: Option<usize>,
#[arg(short = 'c', long = "cursor")]
cursor: Option<String>,

View File

@@ -12,6 +12,7 @@ use serde::{Deserialize, Serialize};
use tokio::process::Command;
use tokio_stream::StreamExt;
use tracing::instrument;
use ts_rs::TS;
use crate::context::RpcContext;
use crate::db::model::public::UpdateProgress;
@@ -34,10 +35,12 @@ lazy_static! {
static ref UPDATED: AtomicBool = AtomicBool::new(false);
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct UpdateSystemParams {
#[ts(type = "string")]
marketplace_url: Url,
}

View File

@@ -15,6 +15,9 @@ use josekit::jwk::Jwk;
use serde::{Deserialize, Serialize};
use sha2::Sha256;
use tracing::instrument;
use ts_rs::TS;
use crate::prelude::*;
pub fn pbkdf2(password: impl AsRef<[u8]>, salt: impl AsRef<[u8]>) -> CipherKey<Aes256Ctr> {
let mut aeskey = CipherKey::<Aes256Ctr>::default();
@@ -53,9 +56,11 @@ pub fn decrypt_slice(input: impl AsRef<[u8]>, password: impl AsRef<[u8]>) -> Vec
res
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[ts(export)]
pub struct EncryptedWire {
encrypted: serde_json::Value,
#[ts(type = "any")]
encrypted: Value,
}
impl EncryptedWire {
#[instrument(skip_all)]

View File

@@ -580,7 +580,7 @@ where
}
}
#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, TS)]
pub struct StdinDeserializable<T>(pub T);
impl<T> FromArgMatches for StdinDeserializable<T>
where