chore: Add some of the fixes to make the build work !!!

This commit is contained in:
J H
2024-03-13 17:44:13 -06:00
parent b6fe0be1b2
commit a089d544a5
16 changed files with 48 additions and 33 deletions

View File

@@ -1,4 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // 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, } export interface CreateOverlayedImageParams { imageId: string, }

View File

@@ -1,4 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // 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, } export interface DestroyOverlayedImageParams { imageId: string , guid: string, }

View File

@@ -1,5 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // 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, } export interface ExecuteAction { serviceId: string | null, actionId: string, input: 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 interface ExposedUI { path: string, title: string, description: string | null, masked: boolean | null, copyable: boolean | null, qr: boolean | null, }

View File

@@ -1,5 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // 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 { Callback } from "./Callback";
import type { PackageId } from "./PackageId";
export interface GetServiceInterfaceParams { packageId: PackageId | null, serviceInterfaceId: string, callback: Callback, } export interface GetServiceInterfaceParams { packageId: string | null, serviceInterfaceId: string, callback: Callback, }

View File

@@ -1,4 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // 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, } export interface GetStoreParams { packageId: string | null, 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 HealthCheckString = "passing" | "disabled" | "starting" | "warning" | "failure";

View File

@@ -1,4 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // 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, } export interface ParamsMaybePackageId { packageId: string | null, }

View File

@@ -1,4 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // 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, } export interface ParamsPackageId { packageId: string, }

View File

@@ -1,5 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // 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"; import type { HealthCheckString } from "./HealthCheckString";
export interface SetHealth { name: HealthCheckId, status: HealthCheckString, message: string | null, } export interface SetHealth { name: string, status: HealthCheckString, message: string | null, }

View File

@@ -531,6 +531,7 @@ pub struct ExposedDependent {
} }
#[derive(Clone, Debug, Deserialize, Serialize, HasModel, ts_rs::TS)] #[derive(Clone, Debug, Deserialize, Serialize, HasModel, ts_rs::TS)]
#[model = "Model<Self>"] #[model = "Model<Self>"]
#[ts(export)]
pub struct ExposedUI { pub struct ExposedUI {
#[ts(type = "string")] #[ts(type = "string")]
pub path: JsonPointer, pub path: JsonPointer,

View File

@@ -222,6 +222,7 @@ async fn bind(_: AnyContext, BindParams { .. }: BindParams) -> Result<Value, Err
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)] #[ts(export)]
struct GetServiceInterfaceParams { struct GetServiceInterfaceParams {
#[ts(type = "string | null")]
package_id: Option<PackageId>, package_id: Option<PackageId>,
service_interface_id: String, service_interface_id: String,
callback: Callback, callback: Callback,
@@ -375,6 +376,7 @@ async fn get_ssl_key(
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)] #[ts(export)]
struct GetStoreParams { struct GetStoreParams {
#[ts(type = "string | null")]
package_id: Option<PackageId>, package_id: Option<PackageId>,
#[ts(type = "string")] #[ts(type = "string")]
path: JsonPointer, path: JsonPointer,
@@ -494,10 +496,11 @@ async fn expose_ui(
.await?; .await?;
Ok(()) Ok(())
} }
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, TS)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, TS)]
#[ts(export)] #[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
struct ParamsPackageId { struct ParamsPackageId {
#[ts(type = "string")]
package_id: PackageId, package_id: PackageId,
} }
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, TS)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Parser, TS)]
@@ -505,6 +508,7 @@ struct ParamsPackageId {
#[command(rename_all = "camelCase")] #[command(rename_all = "camelCase")]
#[ts(export)] #[ts(export)]
struct ParamsMaybePackageId { struct ParamsMaybePackageId {
#[ts(type = "string | null")]
package_id: Option<PackageId>, package_id: Option<PackageId>,
} }
@@ -523,7 +527,9 @@ async fn exists(context: EffectContext, params: ParamsPackageId) -> Result<Value
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)] #[ts(export)]
struct ExecuteAction { struct ExecuteAction {
#[ts(type = "string | null")]
service_id: Option<PackageId>, service_id: Option<PackageId>,
#[ts(type = "string")]
action_id: ActionId, action_id: ActionId,
#[ts(type = "any")] #[ts(type = "any")]
input: Value, input: Value,
@@ -584,11 +590,11 @@ async fn stopped(context: EffectContext, params: ParamsMaybePackageId) -> Result
.de()?; .de()?;
Ok(json!(matches!(package, MainStatus::Stopped))) Ok(json!(matches!(package, MainStatus::Stopped)))
} }
async fn running(context: EffectContext, params: ParamsMaybePackageId) -> Result<Value, Error> { async fn running(context: EffectContext, params: ParamsPackageId) -> Result<Value, Error> {
dbg!("Starting the running {params:?}"); dbg!("Starting the running {params:?}");
let context = context.deref()?; let context = context.deref()?;
let peeked = context.ctx.db.peek().await; 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 let package = peeked
.as_public() .as_public()
.as_package_data() .as_package_data()
@@ -701,6 +707,7 @@ async fn set_main_status(context: EffectContext, params: SetMainStatus) -> Resul
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)] #[ts(export)]
struct SetHealth { struct SetHealth {
#[ts(type = "string")]
name: HealthCheckId, name: HealthCheckId,
status: HealthCheckString, status: HealthCheckString,
message: Option<String>, message: Option<String>,
@@ -771,6 +778,7 @@ async fn set_health(
#[command(rename_all = "camelCase")] #[command(rename_all = "camelCase")]
#[ts(export)] #[ts(export)]
pub struct DestroyOverlayedImageParams { pub struct DestroyOverlayedImageParams {
#[ts(type = "string ")]
image_id: ImageId, image_id: ImageId,
#[ts(type = "string")] #[ts(type = "string")]
guid: InternedString, guid: InternedString,
@@ -799,6 +807,7 @@ pub async fn destroy_overlayed_image(
#[command(rename_all = "camelCase")] #[command(rename_all = "camelCase")]
#[ts(export)] #[ts(export)]
pub struct CreateOverlayedImageParams { pub struct CreateOverlayedImageParams {
#[ts(type = "string")]
image_id: ImageId, image_id: ImageId,
} }

View File

@@ -25,6 +25,7 @@ impl std::fmt::Display for HealthCheckResult {
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, ts_rs::TS)] #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, ts_rs::TS)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[ts(export)]
pub enum HealthCheckString { pub enum HealthCheckString {
Passing, Passing,
Disabled, Disabled,

View File

@@ -32,7 +32,14 @@ export function setupInit<Manifest extends SDKManifest, Store>(
utils, utils,
}) })
await opts.effects.exposeForDependents(services) 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) => { uninit: async (opts) => {
await migrations.uninit(opts) await migrations.uninit(opts)

View File

@@ -57,7 +57,7 @@ describe("startosTypeValidation ", () => {
exists: {} as ParamsPackageId, exists: {} as ParamsPackageId,
getConfigured: undefined, getConfigured: undefined,
stopped: {} as ParamsMaybePackageId, stopped: {} as ParamsMaybePackageId,
running: {} as ParamsMaybePackageId, running: {} as ParamsPackageId,
restart: undefined, restart: undefined,
shutdown: undefined, shutdown: undefined,
setConfigured: {} as SetConfigured, setConfigured: {} as SetConfigured,

View File

@@ -269,7 +269,7 @@ export type ExposeUiPaths<Store> = Array<{
/** A human readable description or explanation of the value */ /** A human readable description or explanation of the value */
description?: string description?: string
/** (string/number only) Whether or not to mask the value, for example, when displaying a password */ /** (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 */ /** (string/number only) Whether or not to include a button for copying the value to clipboard */
copyable?: boolean copyable?: boolean
/** (string/number only) Whether or not to include a button for displaying the value as a QR code */ /** (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<Store> = Array<{
/** Used to reach out from the pure js runtime */ /** Used to reach out from the pure js runtime */
export type Effects = { export type Effects = {
executeAction<Input>(opts: { executeAction<Input>(opts: {
serviceId?: string serviceId: string | null
input: Input input: Input
}): Promise<unknown> }): Promise<unknown>
@@ -362,10 +362,10 @@ export type Effects = {
/** /**
* Get the port address for another service * Get the port address for another service
*/ */
getServicePortForward( getServicePortForward(options: {
internalPort: number, internalPort: number
packageId?: string, packageId: string | null
): Promise<number> }): Promise<number>
/** Removes all network interfaces */ /** Removes all network interfaces */
clearServiceInterfaces(): Promise<void> clearServiceInterfaces(): Promise<void>
@@ -379,11 +379,11 @@ export type Effects = {
exposeUi<Store = never>(options: { exposeUi<Store = never>(options: {
paths: { paths: {
path: string path: string
title: string title: string | null
description?: string | undefined description: string | null
masked?: boolean | undefined masked: boolean | null
copyable?: boolean | undefined copyable: boolean | null
qr?: boolean | undefined qr: boolean | null
}[] }[]
}): Promise<void> }): Promise<void>
/** /**