11import http , { FractalResponseData , FractalResponseList } from '@/api/http' ;
22import { rawDataToServerAllocation , rawDataToServerEggVariable } from '@/api/transformers' ;
3- import { ServerEggVariable } from '@/api/server/types' ;
3+ import { ServerEggVariable , ServerStatus } from '@/api/server/types' ;
44
55export interface Allocation {
66 id : number ;
@@ -17,6 +17,7 @@ export interface Server {
1717 uuid : string ;
1818 name : string ;
1919 node : string ;
20+ status : ServerStatus ;
2021 sftpDetails : {
2122 ip : string ;
2223 port : number ;
@@ -38,6 +39,10 @@ export interface Server {
3839 allocations : number ;
3940 backups : number ;
4041 } ;
42+ // Only isSuspended got marked as deprecated since the isInstalling is a nice helper
43+ // since you'd have to check multiple potential values for that. isSuspended should
44+ // be replaced with status !== 'suspended'.
45+ /** @deprecated */
4146 isSuspended : boolean ;
4247 isInstalling : boolean ;
4348 isTransferring : boolean ;
@@ -51,6 +56,7 @@ export const rawDataToServerObject = ({ attributes: data }: FractalResponseData)
5156 uuid : data . uuid ,
5257 name : data . name ,
5358 node : data . node ,
59+ status : data . status ,
5460 invocation : data . invocation ,
5561 dockerImage : data . docker_image ,
5662 sftpDetails : {
@@ -61,8 +67,8 @@ export const rawDataToServerObject = ({ attributes: data }: FractalResponseData)
6167 limits : { ...data . limits } ,
6268 eggFeatures : data . egg_features || [ ] ,
6369 featureLimits : { ...data . feature_limits } ,
64- isSuspended : data . is_suspended ,
65- isInstalling : data . is_installing ,
70+ isSuspended : data . status === 'suspended' ,
71+ isInstalling : data . status === 'installing' || data . status === 'install_failed' ,
6672 isTransferring : data . is_transferring ,
6773 variables : ( ( data . relationships ?. variables as FractalResponseList | undefined ) ?. data || [ ] ) . map ( rawDataToServerEggVariable ) ,
6874 allocations : ( ( data . relationships ?. allocations as FractalResponseList | undefined ) ?. data || [ ] ) . map ( rawDataToServerAllocation ) ,
0 commit comments