Skip to content

Commit

Permalink
refactor: improve APIApplicationStatusAll usability with generics
Browse files Browse the repository at this point in the history
  • Loading branch information
joaotonaco committed Dec 4, 2024
1 parent faeebaf commit 3bfd7c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-schools-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@squarecloud/api-types": minor
---

Fix `APIApplicationStatusAll` to show/hide usage depending on `running` property.
9 changes: 4 additions & 5 deletions payloads/v2/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ export type APIApplicationStatusPayload = APIPayload<APIApplicationStatus>;
/**
* @see /apps/status https://docs.squarecloud.app/api-reference/endpoint/apps/status-all
*/
export interface APIApplicationStatusAll {
export type APIApplicationStatusAll<Running extends boolean = boolean> = {
id: ApplicationId;
cpu?: string;
ram?: string;
running: boolean;
}
} & (Running extends true
? { running: true; cpu: string; ram: string }
: { running: false; cpu?: never; ram?: never });

export type APIApplicationStatusAllPayload = APIPayload<
APIApplicationStatusAll[]
Expand Down

0 comments on commit 3bfd7c6

Please sign in to comment.