diff --git a/core/startos/bindings/CreateOverlayedImageParams.ts b/core/startos/bindings/CreateOverlayedImageParams.ts index 98a72b497..34924cb1a 100644 --- a/core/startos/bindings/CreateOverlayedImageParams.ts +++ b/core/startos/bindings/CreateOverlayedImageParams.ts @@ -1,4 +1,3 @@ // 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, } \ No newline at end of file +export interface CreateOverlayedImageParams { imageId: string, } \ No newline at end of file diff --git a/core/startos/bindings/DestroyOverlayedImageParams.ts b/core/startos/bindings/DestroyOverlayedImageParams.ts index aef910544..15dd2bf53 100644 --- a/core/startos/bindings/DestroyOverlayedImageParams.ts +++ b/core/startos/bindings/DestroyOverlayedImageParams.ts @@ -1,4 +1,3 @@ // 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, } \ No newline at end of file +export interface DestroyOverlayedImageParams { imageId: string , guid: string, } \ No newline at end of file diff --git a/core/startos/bindings/ExecuteAction.ts b/core/startos/bindings/ExecuteAction.ts index a92852147..d31ae9279 100644 --- a/core/startos/bindings/ExecuteAction.ts +++ b/core/startos/bindings/ExecuteAction.ts @@ -1,5 +1,3 @@ // 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, } \ No newline at end of file +export interface ExecuteAction { serviceId: string | null, actionId: string, input: any, } \ No newline at end of file diff --git a/core/startos/bindings/ExposedUI.ts b/core/startos/bindings/ExposedUI.ts new file mode 100644 index 000000000..1354bb576 --- /dev/null +++ b/core/startos/bindings/ExposedUI.ts @@ -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 ExposedUI { path: string, title: string, description: string | null, masked: boolean | null, copyable: boolean | null, qr: boolean | null, } \ No newline at end of file diff --git a/core/startos/bindings/GetServiceInterfaceParams.ts b/core/startos/bindings/GetServiceInterfaceParams.ts index e0e4d2477..fb0f96791 100644 --- a/core/startos/bindings/GetServiceInterfaceParams.ts +++ b/core/startos/bindings/GetServiceInterfaceParams.ts @@ -1,5 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { Callback } from "./Callback"; -import type { PackageId } from "./PackageId"; -export interface GetServiceInterfaceParams { packageId: PackageId | null, serviceInterfaceId: string, callback: Callback, } \ No newline at end of file +export interface GetServiceInterfaceParams { packageId: string | null, serviceInterfaceId: string, callback: Callback, } \ No newline at end of file diff --git a/core/startos/bindings/GetStoreParams.ts b/core/startos/bindings/GetStoreParams.ts index f2087832a..65703be7a 100644 --- a/core/startos/bindings/GetStoreParams.ts +++ b/core/startos/bindings/GetStoreParams.ts @@ -1,4 +1,3 @@ // 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, } \ No newline at end of file +export interface GetStoreParams { packageId: string | null, path: string, } \ No newline at end of file diff --git a/core/startos/bindings/HealthCheckString.ts b/core/startos/bindings/HealthCheckString.ts new file mode 100644 index 000000000..efe9f42bd --- /dev/null +++ b/core/startos/bindings/HealthCheckString.ts @@ -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 HealthCheckString = "passing" | "disabled" | "starting" | "warning" | "failure"; \ No newline at end of file diff --git a/core/startos/bindings/ParamsMaybePackageId.ts b/core/startos/bindings/ParamsMaybePackageId.ts index 9a2e46c0b..80bdd9a55 100644 --- a/core/startos/bindings/ParamsMaybePackageId.ts +++ b/core/startos/bindings/ParamsMaybePackageId.ts @@ -1,4 +1,3 @@ // 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, } \ No newline at end of file +export interface ParamsMaybePackageId { packageId: string | null, } \ No newline at end of file diff --git a/core/startos/bindings/ParamsPackageId.ts b/core/startos/bindings/ParamsPackageId.ts index 784f268f5..7631cfb11 100644 --- a/core/startos/bindings/ParamsPackageId.ts +++ b/core/startos/bindings/ParamsPackageId.ts @@ -1,4 +1,3 @@ // 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, } \ No newline at end of file +export interface ParamsPackageId { packageId: string, } \ No newline at end of file diff --git a/core/startos/bindings/SetHealth.ts b/core/startos/bindings/SetHealth.ts index d4c202067..3635ec9c5 100644 --- a/core/startos/bindings/SetHealth.ts +++ b/core/startos/bindings/SetHealth.ts @@ -1,5 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { HealthCheckId } from "./HealthCheckId"; import type { HealthCheckString } from "./HealthCheckString"; -export interface SetHealth { name: HealthCheckId, status: HealthCheckString, message: string | null, } \ No newline at end of file +export interface SetHealth { name: string, status: HealthCheckString, message: string | null, } \ No newline at end of file diff --git a/core/startos/src/db/model.rs b/core/startos/src/db/model.rs index d3dd9db74..b79d9d417 100644 --- a/core/startos/src/db/model.rs +++ b/core/startos/src/db/model.rs @@ -531,6 +531,7 @@ pub struct ExposedDependent { } #[derive(Clone, Debug, Deserialize, Serialize, HasModel, ts_rs::TS)] #[model = "Model"] +#[ts(export)] pub struct ExposedUI { #[ts(type = "string")] pub path: JsonPointer, diff --git a/core/startos/src/service/service_effect_handler.rs b/core/startos/src/service/service_effect_handler.rs index 4524eb0ee..4ed160eb7 100644 --- a/core/startos/src/service/service_effect_handler.rs +++ b/core/startos/src/service/service_effect_handler.rs @@ -222,6 +222,7 @@ async fn bind(_: AnyContext, BindParams { .. }: BindParams) -> Result, service_interface_id: String, callback: Callback, @@ -375,6 +376,7 @@ async fn get_ssl_key( #[serde(rename_all = "camelCase")] #[ts(export)] struct GetStoreParams { + #[ts(type = "string | null")] package_id: Option, #[ts(type = "string")] path: JsonPointer, @@ -494,10 +496,11 @@ async fn expose_ui( .await?; Ok(()) } -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, TS)] #[ts(export)] #[serde(rename_all = "camelCase")] struct ParamsPackageId { + #[ts(type = "string")] package_id: PackageId, } #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, TS)] @@ -505,6 +508,7 @@ struct ParamsPackageId { #[command(rename_all = "camelCase")] #[ts(export)] struct ParamsMaybePackageId { + #[ts(type = "string | null")] package_id: Option, } @@ -523,7 +527,9 @@ async fn exists(context: EffectContext, params: ParamsPackageId) -> Result, + #[ts(type = "string")] action_id: ActionId, #[ts(type = "any")] input: Value, @@ -584,11 +590,11 @@ async fn stopped(context: EffectContext, params: ParamsMaybePackageId) -> Result .de()?; Ok(json!(matches!(package, MainStatus::Stopped))) } -async fn running(context: EffectContext, params: ParamsMaybePackageId) -> Result { +async fn running(context: EffectContext, params: ParamsPackageId) -> Result { dbg!("Starting the running {params:?}"); let context = context.deref()?; let peeked = context.ctx.db.peek().await; - let package_id = params.package_id.unwrap_or_else(|| context.id.clone()); + let package_id = params.package_id; let package = peeked .as_public() .as_package_data() @@ -701,6 +707,7 @@ async fn set_main_status(context: EffectContext, params: SetMainStatus) -> Resul #[serde(rename_all = "camelCase")] #[ts(export)] struct SetHealth { + #[ts(type = "string")] name: HealthCheckId, status: HealthCheckString, message: Option, @@ -771,6 +778,7 @@ async fn set_health( #[command(rename_all = "camelCase")] #[ts(export)] pub struct DestroyOverlayedImageParams { + #[ts(type = "string ")] image_id: ImageId, #[ts(type = "string")] guid: InternedString, @@ -799,6 +807,7 @@ pub async fn destroy_overlayed_image( #[command(rename_all = "camelCase")] #[ts(export)] pub struct CreateOverlayedImageParams { + #[ts(type = "string")] image_id: ImageId, } diff --git a/core/startos/src/status/health_check.rs b/core/startos/src/status/health_check.rs index fd3a89683..39434115c 100644 --- a/core/startos/src/status/health_check.rs +++ b/core/startos/src/status/health_check.rs @@ -25,6 +25,7 @@ impl std::fmt::Display for HealthCheckResult { #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, ts_rs::TS)] #[serde(rename_all = "camelCase")] +#[ts(export)] pub enum HealthCheckString { Passing, Disabled, diff --git a/sdk/lib/inits/setupInit.ts b/sdk/lib/inits/setupInit.ts index 9139de23b..4c52ddad2 100644 --- a/sdk/lib/inits/setupInit.ts +++ b/sdk/lib/inits/setupInit.ts @@ -32,7 +32,14 @@ export function setupInit( utils, }) await opts.effects.exposeForDependents(services) - await opts.effects.exposeUi({ paths: ui }) + await opts.effects.exposeUi({ + paths: ui.map((x) => ({ + description: null, + copyable: null, + qr: null, + ...x, + })), + }) }, uninit: async (opts) => { await migrations.uninit(opts) diff --git a/sdk/lib/test/startosTypeValidation.test.ts b/sdk/lib/test/startosTypeValidation.test.ts index b07d6dd0c..e3824a970 100644 --- a/sdk/lib/test/startosTypeValidation.test.ts +++ b/sdk/lib/test/startosTypeValidation.test.ts @@ -57,7 +57,7 @@ describe("startosTypeValidation ", () => { exists: {} as ParamsPackageId, getConfigured: undefined, stopped: {} as ParamsMaybePackageId, - running: {} as ParamsMaybePackageId, + running: {} as ParamsPackageId, restart: undefined, shutdown: undefined, setConfigured: {} as SetConfigured, diff --git a/sdk/lib/types.ts b/sdk/lib/types.ts index d863fe3d1..0ab0b73db 100644 --- a/sdk/lib/types.ts +++ b/sdk/lib/types.ts @@ -269,7 +269,7 @@ export type ExposeUiPaths = Array<{ /** A human readable description or explanation of the value */ description?: string /** (string/number only) Whether or not to mask the value, for example, when displaying a password */ - masked?: boolean + masked: boolean /** (string/number only) Whether or not to include a button for copying the value to clipboard */ copyable?: boolean /** (string/number only) Whether or not to include a button for displaying the value as a QR code */ @@ -278,7 +278,7 @@ export type ExposeUiPaths = Array<{ /** Used to reach out from the pure js runtime */ export type Effects = { executeAction(opts: { - serviceId?: string + serviceId: string | null input: Input }): Promise @@ -362,10 +362,10 @@ export type Effects = { /** * Get the port address for another service */ - getServicePortForward( - internalPort: number, - packageId?: string, - ): Promise + getServicePortForward(options: { + internalPort: number + packageId: string | null + }): Promise /** Removes all network interfaces */ clearServiceInterfaces(): Promise @@ -379,11 +379,11 @@ export type Effects = { exposeUi(options: { paths: { path: string - title: string - description?: string | undefined - masked?: boolean | undefined - copyable?: boolean | undefined - qr?: boolean | undefined + title: string | null + description: string | null + masked: boolean | null + copyable: boolean | null + qr: boolean | null }[] }): Promise /**