mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
chore: Add in some more files for the testing of the sdk and the rust interface
This commit is contained in:
31
core/Cargo.lock
generated
31
core/Cargo.lock
generated
@@ -2,6 +2,12 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "Inflector"
|
||||
version = "0.11.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3"
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.21.0"
|
||||
@@ -2679,6 +2685,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"torut",
|
||||
"tracing",
|
||||
"ts-rs",
|
||||
"yasi",
|
||||
]
|
||||
|
||||
@@ -4723,6 +4730,7 @@ dependencies = [
|
||||
"tracing-journald",
|
||||
"tracing-subscriber",
|
||||
"trust-dns-server",
|
||||
"ts-rs",
|
||||
"typed-builder",
|
||||
"url",
|
||||
"urlencoding",
|
||||
@@ -5426,6 +5434,29 @@ version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
||||
|
||||
[[package]]
|
||||
name = "ts-rs"
|
||||
version = "7.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc2cae1fc5d05d47aa24b64f9a4f7cba24cdc9187a2084dd97ac57bef5eccae6"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
"ts-rs-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ts-rs-macros"
|
||||
version = "7.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73f7f9b821696963053a89a7bd8b292dc34420aea8294d7b225274d488f3ec92"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.52",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tungstenite"
|
||||
version = "0.21.0"
|
||||
|
||||
@@ -32,6 +32,7 @@ sqlx = { version = "0.7.2", features = [
|
||||
"postgres",
|
||||
] }
|
||||
ssh-key = "0.6.2"
|
||||
ts-rs = "7"
|
||||
thiserror = "1.0"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
torut = { git = "https://github.com/Start9Labs/torut.git", branch = "update/dependencies" }
|
||||
|
||||
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{Id, InvalidId};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, ts_rs::TS)]
|
||||
pub struct ActionId(Id);
|
||||
impl FromStr for ActionId {
|
||||
type Err = InvalidId;
|
||||
|
||||
@@ -4,7 +4,7 @@ use serde::{Deserialize, Deserializer, Serialize};
|
||||
|
||||
use crate::Id;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, ts_rs::TS)]
|
||||
pub struct HealthCheckId(Id);
|
||||
impl std::fmt::Display for HealthCheckId {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
|
||||
@@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer, Serialize};
|
||||
|
||||
use crate::{Id, InvalidId, PackageId, Version};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, ts_rs::TS)]
|
||||
pub struct ImageId(Id);
|
||||
impl AsRef<Path> for ImageId {
|
||||
fn as_ref(&self) -> &Path {
|
||||
|
||||
@@ -27,12 +27,12 @@ lazy_static::lazy_static! {
|
||||
pub static ref SYSTEM_ID: Id = Id(InternedString::intern("x_system"));
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
pub struct Id(InternedString);
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default, ts_rs::TS)]
|
||||
pub struct Id(#[ts(type = "string")] InternedString);
|
||||
impl TryFrom<InternedString> for Id {
|
||||
type Error = InvalidId;
|
||||
fn try_from(value: InternedString) -> Result<Self, Self::Error> {
|
||||
if ID_REGEX.is_match(&*value) {
|
||||
if ID_REGEX.is_match(&value) {
|
||||
Ok(Id(value))
|
||||
} else {
|
||||
Err(InvalidId)
|
||||
@@ -52,7 +52,7 @@ impl TryFrom<String> for Id {
|
||||
impl TryFrom<&str> for Id {
|
||||
type Error = InvalidId;
|
||||
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
||||
if ID_REGEX.is_match(&value) {
|
||||
if ID_REGEX.is_match(value) {
|
||||
Ok(Id(InternedString::intern(value)))
|
||||
} else {
|
||||
Err(InvalidId)
|
||||
@@ -67,7 +67,7 @@ impl From<Id> for InternedString {
|
||||
impl std::ops::Deref for Id {
|
||||
type Target = str;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&*self.0
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for Id {
|
||||
@@ -77,7 +77,7 @@ impl std::fmt::Display for Id {
|
||||
}
|
||||
impl AsRef<str> for Id {
|
||||
fn as_ref(&self) -> &str {
|
||||
&*self.0
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
impl Borrow<str> for Id {
|
||||
@@ -99,7 +99,7 @@ impl Serialize for Id {
|
||||
where
|
||||
Ser: Serializer,
|
||||
{
|
||||
serializer.serialize_str(&*self)
|
||||
serializer.serialize_str(self)
|
||||
}
|
||||
}
|
||||
impl<'q> sqlx::Encode<'q, sqlx::Postgres> for Id {
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
|
||||
use serde::{Deserialize, Serialize, Serializer};
|
||||
use ts_rs::TS;
|
||||
use yasi::InternedString;
|
||||
|
||||
use crate::{Id, InvalidId, SYSTEM_ID};
|
||||
@@ -10,7 +11,7 @@ use crate::{Id, InvalidId, SYSTEM_ID};
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref SYSTEM_PACKAGE_ID: PackageId = PackageId(SYSTEM_ID.clone());
|
||||
}
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, TS)]
|
||||
pub struct PackageId(Id);
|
||||
impl FromStr for PackageId {
|
||||
type Err = InvalidId;
|
||||
@@ -36,7 +37,7 @@ impl From<PackageId> for InternedString {
|
||||
impl std::ops::Deref for PackageId {
|
||||
type Target = str;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&*self.0
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
impl AsRef<PackageId> for PackageId {
|
||||
|
||||
@@ -174,6 +174,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 = "7.1.1"
|
||||
typed-builder = "0.18.0"
|
||||
url = { version = "2.4.1", features = ["serde"] }
|
||||
urlencoding = "2.1.3"
|
||||
|
||||
3
core/startos/Effects.ts
Normal file
3
core/startos/Effects.ts
Normal 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 interface SetStoreParams { value: any, path: string, }
|
||||
3
core/startos/bindings/AddSslOptions.ts
Normal file
3
core/startos/bindings/AddSslOptions.ts
Normal 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 interface AddSslOptions { scheme: string | null, preferredExternalPort: number, addXForwardedHeaders: boolean | null, }
|
||||
3
core/startos/bindings/Algorithm.ts
Normal file
3
core/startos/bindings/Algorithm.ts
Normal 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 Algorithm = "ecdsa" | "ed25519";
|
||||
3
core/startos/bindings/BindKind.ts
Normal file
3
core/startos/bindings/BindKind.ts
Normal 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 BindKind = "static" | "single" | "multi";
|
||||
5
core/startos/bindings/BindParams.ts
Normal file
5
core/startos/bindings/BindParams.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { AddSslOptions } from "./AddSslOptions";
|
||||
import type { BindKind } from "./BindKind";
|
||||
|
||||
export interface BindParams { kind: BindKind, id: string, internalPort: number, scheme: string, preferredExternalPort: number, addSsl: AddSslOptions | null, secure: boolean, ssl: boolean, }
|
||||
3
core/startos/bindings/Callback.ts
Normal file
3
core/startos/bindings/Callback.ts
Normal 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 Callback = () => void;
|
||||
3
core/startos/bindings/ChrootParams.ts
Normal file
3
core/startos/bindings/ChrootParams.ts
Normal 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 interface ChrootParams { env: string | null, workdir: string | null, user: string | null, path: string, command: string, args: string[], }
|
||||
4
core/startos/bindings/CreateOverlayedImageParams.ts
Normal file
4
core/startos/bindings/CreateOverlayedImageParams.ts
Normal 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 interface CreateOverlayedImageParams { imageId: ImageId, }
|
||||
4
core/startos/bindings/DestroyOverlayedImageParams.ts
Normal file
4
core/startos/bindings/DestroyOverlayedImageParams.ts
Normal 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 interface DestroyOverlayedImageParams { imageId: ImageId, guid: string, }
|
||||
5
core/startos/bindings/ExecuteAction.ts
Normal file
5
core/startos/bindings/ExecuteAction.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { ActionId } from "./ActionId";
|
||||
import type { PackageId } from "./PackageId";
|
||||
|
||||
export interface ExecuteAction { serviceId: PackageId | null, actionId: ActionId, input: any, }
|
||||
3
core/startos/bindings/ExposeForDependentsParams.ts
Normal file
3
core/startos/bindings/ExposeForDependentsParams.ts
Normal 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 interface ExposeForDependentsParams { paths: string[], }
|
||||
4
core/startos/bindings/ExposeUiParams.ts
Normal file
4
core/startos/bindings/ExposeUiParams.ts
Normal 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 { ExposedUI } from "./ExposedUI";
|
||||
|
||||
export interface ExposeUiParams { paths: Array<ExposedUI>, }
|
||||
5
core/startos/bindings/GetHostInfoParams.ts
Normal file
5
core/startos/bindings/GetHostInfoParams.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { Callback } from "./Callback";
|
||||
import type { GetHostInfoParamsKind } from "./GetHostInfoParamsKind";
|
||||
|
||||
export interface GetHostInfoParams { kind: GetHostInfoParamsKind | null, serviceInterfaceId: string, packageId: string | null, callback: Callback, }
|
||||
3
core/startos/bindings/GetHostInfoParamsKind.ts
Normal file
3
core/startos/bindings/GetHostInfoParamsKind.ts
Normal 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 GetHostInfoParamsKind = "multi";
|
||||
5
core/startos/bindings/GetServiceInterfaceParams.ts
Normal file
5
core/startos/bindings/GetServiceInterfaceParams.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { Callback } from "./Callback";
|
||||
import type { PackageId } from "./PackageId";
|
||||
|
||||
export interface GetServiceInterfaceParams { packageId: PackageId | null, serviceInterfaceId: string, callback: Callback, }
|
||||
4
core/startos/bindings/GetSslCertificateParams.ts
Normal file
4
core/startos/bindings/GetSslCertificateParams.ts
Normal 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 { Algorithm } from "./Algorithm";
|
||||
|
||||
export interface GetSslCertificateParams { packageId: string | null, hostId: string, algorithm: Algorithm | null, }
|
||||
4
core/startos/bindings/GetSslKeyParams.ts
Normal file
4
core/startos/bindings/GetSslKeyParams.ts
Normal 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 { Algorithm } from "./Algorithm";
|
||||
|
||||
export interface GetSslKeyParams { packageId: string | null, hostId: string, algorithm: Algorithm | null, }
|
||||
4
core/startos/bindings/GetStoreParams.ts
Normal file
4
core/startos/bindings/GetStoreParams.ts
Normal 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 interface GetStoreParams { packageId: PackageId | null, path: string, }
|
||||
4
core/startos/bindings/ParamsMaybePackageId.ts
Normal file
4
core/startos/bindings/ParamsMaybePackageId.ts
Normal 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 interface ParamsMaybePackageId { packageId: PackageId | null, }
|
||||
4
core/startos/bindings/ParamsPackageId.ts
Normal file
4
core/startos/bindings/ParamsPackageId.ts
Normal 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 interface ParamsPackageId { packageId: PackageId, }
|
||||
3
core/startos/bindings/SetConfigured.ts
Normal file
3
core/startos/bindings/SetConfigured.ts
Normal 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 interface SetConfigured { configured: boolean, }
|
||||
5
core/startos/bindings/SetHealth.ts
Normal file
5
core/startos/bindings/SetHealth.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { HealthCheckId } from "./HealthCheckId";
|
||||
import type { HealthCheckString } from "./HealthCheckString";
|
||||
|
||||
export interface SetHealth { name: HealthCheckId, status: HealthCheckString, message: string | null, }
|
||||
4
core/startos/bindings/SetMainStatus.ts
Normal file
4
core/startos/bindings/SetMainStatus.ts
Normal 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 { Status } from "./Status";
|
||||
|
||||
export interface SetMainStatus { status: Status, }
|
||||
3
core/startos/bindings/SetStoreParams.ts
Normal file
3
core/startos/bindings/SetStoreParams.ts
Normal 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 interface SetStoreParams { value: any, path: string, }
|
||||
3
core/startos/bindings/Status.ts
Normal file
3
core/startos/bindings/Status.ts
Normal 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 Status = "running" | "stopped";
|
||||
@@ -529,9 +529,10 @@ pub struct ExposedDependent {
|
||||
copyable: Option<bool>,
|
||||
qr: Option<bool>,
|
||||
}
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, HasModel, ts_rs::TS)]
|
||||
#[model = "Model<Self>"]
|
||||
pub struct ExposedUI {
|
||||
#[ts(type = "string")]
|
||||
pub path: JsonPointer,
|
||||
pub title: String,
|
||||
pub description: Option<String>,
|
||||
|
||||
@@ -11,6 +11,7 @@ use models::{ActionId, HealthCheckId, ImageId, PackageId};
|
||||
use patch_db::json_ptr::JsonPointer;
|
||||
use rpc_toolkit::{from_fn, from_fn_async, AnyContext, Context, Empty, HandlerExt, ParentHandler};
|
||||
use tokio::process::Command;
|
||||
use ts_rs::TS;
|
||||
|
||||
use crate::db::model::ExposedUI;
|
||||
use crate::disk::mount::filesystem::idmapped::IdMapped;
|
||||
@@ -127,36 +128,103 @@ pub fn service_effect_handler() -> ParentHandler {
|
||||
"getServiceInterface",
|
||||
from_fn_async(get_service_interface).no_cli(),
|
||||
)
|
||||
.subcommand("clearBindings", from_fn_async(clear_bindings).no_cli())
|
||||
.subcommand("bind", from_fn_async(bind).no_cli())
|
||||
.subcommand("getHostInfo", from_fn_async(get_host_info).no_cli())
|
||||
// TODO @DrBonez when we get the new api for 4.0
|
||||
// .subcommand("setDependencies",from_fn(set_dependencies))
|
||||
// .subcommand("embassyGetInterface",from_fn(embassy_get_interface))
|
||||
// .subcommand("mount",from_fn(mount))
|
||||
// .subcommand("removeAction",from_fn(remove_action))
|
||||
// .subcommand("removeAddress",from_fn(remove_address))
|
||||
// .subcommand("exportAction",from_fn(export_action))
|
||||
// .subcommand("bind",from_fn(bind))
|
||||
// .subcommand("clearServiceInterfaces",from_fn(clear_network_interfaces))
|
||||
// .subcommand("exportServiceInterface",from_fn(export_network_interface))
|
||||
// .subcommand("clearBindings",from_fn(clear_bindings))
|
||||
// .subcommand("getHostnames",from_fn(get_hostnames))
|
||||
// .subcommand("getInterface",from_fn(get_interface))
|
||||
// .subcommand("listInterface",from_fn(list_interface))
|
||||
// .subcommand("getIPHostname",from_fn(get_ip_hostname))
|
||||
// .subcommand("getContainerIp",from_fn(get_container_ip))
|
||||
// .subcommand("getLocalHostname",from_fn(get_local_hostname))
|
||||
// .subcommand("getPrimaryUrl",from_fn(get_primary_url))
|
||||
// .subcommand("getServicePortForward",from_fn(get_service_port_forward))
|
||||
// .subcommand("getServiceTorHostname",from_fn(get_service_tor_hostname))
|
||||
// .subcommand("getSystemSmtp",from_fn(get_system_smtp))
|
||||
// .subcommand("reverseProxy",from_fn(reverse_pro)xy)
|
||||
// .subcommand("setDependencies",from_fn_async(set_dependencies).no_cli())
|
||||
// .subcommand("embassyGetInterface",from_fn_async(embassy_get_interface).no_cli())
|
||||
// .subcommand("mount",from_fn_async(mount).no_cli())
|
||||
// .subcommand("removeAction",from_fn_async(remove_action).no_cli())
|
||||
// .subcommand("removeAddress",from_fn_async(remove_address).no_cli())
|
||||
// .subcommand("exportAction",from_fn_async(export_action).no_cli())
|
||||
// .subcommand("clearServiceInterfaces",from_fn_async(clear_network_interfaces).no_cli())
|
||||
// .subcommand("exportServiceInterface",from_fn_async(export_network_interface).no_cli())
|
||||
// .subcommand("getHostnames",from_fn_async(get_hostnames).no_cli())
|
||||
// .subcommand("getInterface",from_fn_async(get_interface).no_cli())
|
||||
// .subcommand("listInterface",from_fn_async(list_interface).no_cli())
|
||||
// .subcommand("getIPHostname",from_fn_async(get_ip_hostname).no_cli())
|
||||
// .subcommand("getContainerIp",from_fn_async(get_container_ip).no_cli())
|
||||
// .subcommand("getLocalHostname",from_fn_async(get_local_hostname).no_cli())
|
||||
// .subcommand("getPrimaryUrl",from_fn_async(get_primary_url).no_cli())
|
||||
// .subcommand("getServicePortForward",from_fn_async(get_service_port_forward).no_cli())
|
||||
// .subcommand("getServiceTorHostname",from_fn_async(get_service_tor_hostname).no_cli())
|
||||
// .subcommand("getSystemSmtp",from_fn_async(get_system_smtp).no_cli())
|
||||
// .subcommand("reverseProxy",from_fn_async(reverse_proxy).no_cli())
|
||||
// TODO Callbacks
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser)]
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[ts(export)]
|
||||
struct Callback(#[ts(type = "() => void")] i64);
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
enum GetHostInfoParamsKind {
|
||||
Multi,
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct GetHostInfoParams {
|
||||
kind: Option<GetHostInfoParamsKind>,
|
||||
service_interface_id: String,
|
||||
package_id: Option<String>,
|
||||
callback: Callback,
|
||||
}
|
||||
async fn get_host_info(
|
||||
_: AnyContext,
|
||||
GetHostInfoParams { .. }: GetHostInfoParams,
|
||||
) -> Result<Value, Error> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn clear_bindings(context: EffectContext, _: Empty) -> Result<Value, Error> {
|
||||
todo!()
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
|
||||
enum BindKind {
|
||||
Static,
|
||||
Single,
|
||||
Multi,
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
|
||||
struct AddSslOptions {
|
||||
scheme: Option<String>,
|
||||
preferred_external_port: u32,
|
||||
add_x_forwarded_headers: Option<bool>,
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct BindParams {
|
||||
kind: BindKind,
|
||||
id: String,
|
||||
internal_port: u32,
|
||||
scheme: String,
|
||||
preferred_external_port: u32,
|
||||
add_ssl: Option<AddSslOptions>,
|
||||
secure: bool,
|
||||
ssl: bool,
|
||||
}
|
||||
async fn bind(_: AnyContext, BindParams { .. }: BindParams) -> Result<Value, Error> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct GetServiceInterfaceParams {
|
||||
package_id: Option<PackageId>,
|
||||
service_interface_id: String,
|
||||
callback: String,
|
||||
callback: Callback,
|
||||
}
|
||||
async fn get_service_interface(
|
||||
_: AnyContext,
|
||||
@@ -190,8 +258,9 @@ async fn get_service_interface(
|
||||
}))
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct ChrootParams {
|
||||
#[arg(short = 'e', long = "env")]
|
||||
env: Option<PathBuf>,
|
||||
@@ -200,7 +269,9 @@ struct ChrootParams {
|
||||
#[arg(short = 'u', long = "user")]
|
||||
user: Option<String>,
|
||||
path: PathBuf,
|
||||
#[ts(type = "string")]
|
||||
command: OsString,
|
||||
#[ts(type = "string[]")]
|
||||
args: Vec<OsString>,
|
||||
}
|
||||
fn chroot(
|
||||
@@ -250,11 +321,22 @@ fn chroot(
|
||||
cmd.args(args);
|
||||
Err(cmd.exec().into())
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
enum Algorithm {
|
||||
Ecdsa,
|
||||
Ed25519,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct GetSslCertificateParams {
|
||||
package_id: Option<String>,
|
||||
algorithm: Option<String>, //"ecdsa" | "ed25519"
|
||||
host_id: String,
|
||||
algorithm: Option<Algorithm>, //"ecdsa" | "ed25519"
|
||||
}
|
||||
|
||||
async fn get_ssl_certificate(
|
||||
@@ -262,33 +344,39 @@ async fn get_ssl_certificate(
|
||||
GetSslCertificateParams {
|
||||
package_id,
|
||||
algorithm,
|
||||
host_id,
|
||||
}: GetSslCertificateParams,
|
||||
) -> Result<Value, Error> {
|
||||
let fake = include_str!("./fake.cert.pem");
|
||||
Ok(json!([fake, fake, fake]))
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct GetSslKeyParams {
|
||||
package_id: Option<String>,
|
||||
algorithm: Option<String>, //"ecdsa" | "ed25519"
|
||||
host_id: String,
|
||||
algorithm: Option<Algorithm>,
|
||||
}
|
||||
|
||||
async fn get_ssl_key(
|
||||
context: EffectContext,
|
||||
GetSslKeyParams {
|
||||
package_id,
|
||||
host_id,
|
||||
algorithm,
|
||||
}: GetSslKeyParams,
|
||||
) -> Result<Value, Error> {
|
||||
let fake = include_str!("./fake.cert.key");
|
||||
Ok(json!(fake))
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct GetStoreParams {
|
||||
package_id: Option<PackageId>,
|
||||
#[ts(type = "string")]
|
||||
path: JsonPointer,
|
||||
}
|
||||
|
||||
@@ -311,10 +399,13 @@ async fn get_store(
|
||||
.ok_or_else(|| Error::new(eyre!("Did not find value at path"), ErrorKind::NotFound))?
|
||||
.clone())
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct SetStoreParams {
|
||||
#[ts(type = "any")]
|
||||
value: Value,
|
||||
#[ts(type = "string")]
|
||||
path: JsonPointer,
|
||||
}
|
||||
|
||||
@@ -344,9 +435,11 @@ async fn set_store(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct ExposeForDependentsParams {
|
||||
#[ts(type = "string[]")]
|
||||
paths: Vec<JsonPointer>,
|
||||
}
|
||||
|
||||
@@ -372,8 +465,9 @@ async fn expose_for_dependents(
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct ExposeUiParams {
|
||||
paths: Vec<ExposedUI>,
|
||||
}
|
||||
@@ -400,13 +494,16 @@ async fn expose_ui(
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ParamsPackageId {
|
||||
package: PackageId,
|
||||
package_id: PackageId,
|
||||
}
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct ParamsMaybePackageId {
|
||||
package_id: Option<PackageId>,
|
||||
}
|
||||
@@ -417,16 +514,18 @@ async fn exists(context: EffectContext, params: ParamsPackageId) -> Result<Value
|
||||
let package = peeked
|
||||
.as_public()
|
||||
.as_package_data()
|
||||
.as_idx(¶ms.package)
|
||||
.as_idx(¶ms.package_id)
|
||||
.is_some();
|
||||
Ok(json!(package))
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct ExecuteAction {
|
||||
service_id: Option<PackageId>,
|
||||
action_id: ActionId,
|
||||
#[ts(type = "any")]
|
||||
input: Value,
|
||||
}
|
||||
async fn execute_action(
|
||||
@@ -529,9 +628,10 @@ async fn shutdown(context: EffectContext, _: Empty) -> Result<Value, Error> {
|
||||
Ok(json!(()))
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct SetConfigured {
|
||||
configured: bool,
|
||||
}
|
||||
@@ -556,8 +656,9 @@ async fn set_configured(context: EffectContext, params: SetConfigured) -> Result
|
||||
Ok(json!(()))
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
enum Status {
|
||||
Running,
|
||||
Stopped,
|
||||
@@ -579,9 +680,10 @@ impl ValueParserFactory for Status {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct SetMainStatus {
|
||||
status: Status,
|
||||
}
|
||||
@@ -595,8 +697,9 @@ async fn set_main_status(context: EffectContext, params: SetMainStatus) -> Resul
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
struct SetHealth {
|
||||
name: HealthCheckId,
|
||||
status: HealthCheckString,
|
||||
@@ -663,11 +766,13 @@ async fn set_health(
|
||||
.await?;
|
||||
Ok(json!(()))
|
||||
}
|
||||
#[derive(serde::Deserialize, serde::Serialize, Parser)]
|
||||
#[derive(serde::Deserialize, serde::Serialize, Parser, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
pub struct DestroyOverlayedImageParams {
|
||||
image_id: ImageId,
|
||||
#[ts(type = "string")]
|
||||
guid: InternedString,
|
||||
}
|
||||
|
||||
@@ -689,9 +794,10 @@ pub async fn destroy_overlayed_image(
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
#[derive(serde::Deserialize, serde::Serialize, Parser)]
|
||||
#[derive(serde::Deserialize, serde::Serialize, Parser, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
pub struct CreateOverlayedImageParams {
|
||||
image_id: ImageId,
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ impl std::fmt::Display for HealthCheckResult {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, ts_rs::TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum HealthCheckString {
|
||||
Passing,
|
||||
|
||||
Reference in New Issue
Block a user