diff --git a/container-runtime/src/Adapters/RpcListener.ts b/container-runtime/src/Adapters/RpcListener.ts index 6e8e7aac8..28f578149 100644 --- a/container-runtime/src/Adapters/RpcListener.ts +++ b/container-runtime/src/Adapters/RpcListener.ts @@ -64,7 +64,7 @@ const runType = object({ input: any, timeout: number, }, - ["timeout"], + ["timeout", "input"], ), }) const sandboxRunType = object({ @@ -77,7 +77,7 @@ const sandboxRunType = object({ input: any, timeout: number, }, - ["timeout"], + ["timeout", "input"], ), }) const callbackType = object({ diff --git a/container-runtime/src/Adapters/Systems/SystemForEmbassy/index.ts b/container-runtime/src/Adapters/Systems/SystemForEmbassy/index.ts index 2e0836bb0..e5d2e096b 100644 --- a/container-runtime/src/Adapters/Systems/SystemForEmbassy/index.ts +++ b/container-runtime/src/Adapters/Systems/SystemForEmbassy/index.ts @@ -232,7 +232,7 @@ export class SystemForEmbassy implements System { effects: Effects, options: { procedure: JsonPath - input: unknown + input?: unknown timeout?: number | undefined }, ): Promise { @@ -294,7 +294,7 @@ export class SystemForEmbassy implements System { effects: Effects, options: { procedure: JsonPath - input: unknown + input?: unknown timeout?: number | undefined }, ): Promise { diff --git a/container-runtime/src/Adapters/Systems/SystemForStartOs.ts b/container-runtime/src/Adapters/Systems/SystemForStartOs.ts index 78c21b7c7..029b504c0 100644 --- a/container-runtime/src/Adapters/Systems/SystemForStartOs.ts +++ b/container-runtime/src/Adapters/Systems/SystemForStartOs.ts @@ -75,7 +75,7 @@ export class SystemForStartOs implements System { effects: Effects, options: { procedure: Procedure - input: unknown + input?: unknown timeout?: number | undefined }, ): Promise { @@ -137,7 +137,7 @@ export class SystemForStartOs implements System { effects: Effects | MainEffects, options: { procedure: Procedure - input: unknown + input?: unknown timeout?: number | undefined }, ): Promise { @@ -219,7 +219,7 @@ export class SystemForStartOs implements System { async sandbox( effects: Effects, - options: { procedure: Procedure; input: unknown; timeout?: number }, + options: { procedure: Procedure; input?: unknown; timeout?: number }, ): Promise { return this.execute(effects, options) } diff --git a/core/startos/src/action.rs b/core/startos/src/action.rs index e93af4a4d..7c4492adc 100644 --- a/core/startos/src/action.rs +++ b/core/startos/src/action.rs @@ -58,6 +58,7 @@ pub struct ActionParams { pub action_id: ActionId, #[command(flatten)] #[ts(type = "{ [key: string]: any } | null")] + #[serde(default)] pub input: StdinDeserializable>, } // impl C diff --git a/core/startos/src/util/serde.rs b/core/startos/src/util/serde.rs index bac2c524a..88d7bfc11 100644 --- a/core/startos/src/util/serde.rs +++ b/core/startos/src/util/serde.rs @@ -568,6 +568,14 @@ where #[derive(Deserialize, Serialize, TS)] pub struct StdinDeserializable(pub T); +impl Default for StdinDeserializable +where + T: Default, +{ + fn default() -> Self { + Self(T::default()) + } +} impl FromArgMatches for StdinDeserializable where T: DeserializeOwned, diff --git a/web/projects/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts b/web/projects/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts index 63c534bb6..99bd70e48 100644 --- a/web/projects/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts +++ b/web/projects/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts @@ -20,6 +20,20 @@ import { import { getAllPackages, getManifest } from 'src/app/util/get-package-data' import { hasCurrentDeps } from 'src/app/util/has-deps' +const allowedStatuses = { + onlyRunning: new Set(['running']), + onlyStopped: new Set(['stopped']), + any: new Set([ + 'running', + 'stopped', + 'restarting', + 'restoring', + 'stopping', + 'starting', + 'backingUp', + ]), +} + @Component({ selector: 'app-actions', templateUrl: './app-actions.page.html', @@ -46,7 +60,10 @@ export class AppActionsPage { status: T.Status, action: { key: string; value: T.ActionMetadata }, ) { - if (status && action.value.allowedStatuses.includes(status.main.status)) { + if ( + status && + allowedStatuses[action.value.allowedStatuses].has(status.main.status) + ) { if (!isEmptyObject(action.value.input || {})) { this.formDialog.open(FormComponent, { label: action.value.name, @@ -84,7 +101,7 @@ export class AppActionsPage { await alert.present() } } else { - const statuses = [...action.value.allowedStatuses] + const statuses = [...allowedStatuses[action.value.allowedStatuses]] const last = statuses.pop() let statusesStr = statuses.join(', ') let error = ''