1- import fetch from ' node-fetch' ;
1+ import fetch from " node-fetch" ;
22
3- import { CreateWorkspace , WorkspaceStreamer } from ' ../WorkspaceStreamer' ;
3+ import { CreateWorkspace , WorkspaceStreamer } from " ../WorkspaceStreamer" ;
44
5- import { IWorkspaceError } from ' ./IWorkspaceError' ;
5+ import { IWorkspaceError } from " ./IWorkspaceError" ;
66import { GitpodDataModel } from "./Model" ;
77
88type IWorkspaceParams = {
@@ -17,15 +17,15 @@ type ICreateWorkspaceParams = {
1717 ideSetting : {
1818 defaultIde : string ;
1919 useLatestVersion : false ;
20- }
21- }
20+ } ;
21+ } ;
2222
2323const workspaceURLs = {
2424 getWorkspace : "https://api.gitpod.io/gitpod.experimental.v1.WorkspacesService/GetWorkspace" ,
2525 getAllWorkspaces : "https://api.gitpod.io/gitpod.experimental.v1.WorkspacesService/ListWorkspaces" ,
2626 deleteWorkspace : "https://api.gitpod.io/gitpod.experimental.v1.WorkspacesService/DeleteWorkspace" ,
2727 startWorkspace : "https://api.gitpod.io/gitpod.experimental.v1.WorkspacesService/StartWorkspace" ,
28- stopWorkspace : "https://api.gitpod.io/gitpod.experimental.v1.WorkspacesService/StopWorkspace"
28+ stopWorkspace : "https://api.gitpod.io/gitpod.experimental.v1.WorkspacesService/StopWorkspace" ,
2929} ;
3030
3131export class IWorkspace implements GitpodDataModel {
@@ -43,15 +43,15 @@ export class IWorkspace implements GitpodDataModel {
4343 } ;
4444 private description : string ;
4545 public instanceId : string ;
46- public createdAt : string
46+ public createdAt : string ;
4747 private status : {
4848 phase : string ;
4949 } ;
5050
5151 private repository : string ;
5252
5353 getIDEURL ( ) {
54- return this . ideURL
54+ return this . ideURL ;
5555 }
5656
5757 setIDEURL ( url : string ) {
@@ -98,8 +98,8 @@ export class IWorkspace implements GitpodDataModel {
9898 return this . description ;
9999 }
100100
101- getRepositoryName ( ) : string {
102- if ( ! this . initialized ) {
101+ getRepositoryName ( ) : string {
102+ if ( ! this . initialized ) {
103103 throw new Error ( "IWorkspace instance not initailized" ) ;
104104 }
105105 return this . repository ;
@@ -120,11 +120,11 @@ export class IWorkspace implements GitpodDataModel {
120120 this . status = workspace . status . instance . status ;
121121 this . description = workspace . description ;
122122 this . token = token ;
123- this . instanceId = workspace . status . instance . instanceId
123+ this . instanceId = workspace . status . instance . instanceId ;
124124 this . initialized = true ;
125- this . createdAt = workspace . status . instance . createdAt
126- this . ideURL = workspace . status . instance ? workspace . status . instance . status . url : ' https://gitpod.io' ;
127- this . repository = workspace . context . git . repository . name
125+ this . createdAt = workspace . status . instance . createdAt ;
126+ this . ideURL = workspace . status . instance ? workspace . status . instance . status . url : " https://gitpod.io" ;
127+ this . repository = workspace . context . git . repository . name ;
128128 }
129129
130130 parse ( json : string ) : IWorkspace {
@@ -144,9 +144,9 @@ export class IWorkspace implements GitpodDataModel {
144144 this . status = {
145145 phase : data . result . status . instance . status . phase ,
146146 } ;
147- this . ideURL = data . result . status . instance ? data . result . status . instance . status . url : ''
147+ this . ideURL = data . result . status . instance ? data . result . status . instance . status . url : "" ;
148148
149- this . createdAt = data . result . status . instance . createdAt
149+ this . createdAt = data . result . status . instance . createdAt ;
150150
151151 return this ;
152152 }
@@ -167,23 +167,26 @@ export class IWorkspace implements GitpodDataModel {
167167 method : "POST" ,
168168 headers : {
169169 "content-type" : "application/json" ,
170- " Authorization" : `Bearer ${ this . token } ` ,
170+ Authorization : `Bearer ${ this . token } ` ,
171171 } ,
172172 body : JSON . stringify ( { workspaceId : workspaceID } ) ,
173173 } ) ;
174174 const json = await response . json ( ) ;
175175 if ( response . status !== 200 ) {
176- const errorState = json as { code ?: string , message ?: string }
176+ const errorState = json as { code ?: string ; message ?: string } ;
177177 const error : IWorkspaceError = {
178178 name : "WorkspaceStartError" ,
179179 code : response . status ,
180- message : errorState . message && errorState . message . startsWith ( "You cannot run more than 4 workspaces at the same time" ) ? errorState . message : "Error Occured in Starting Workspace"
181- }
182- throw error
180+ message :
181+ errorState . message && errorState . message . startsWith ( "You cannot run more than 4 workspaces at the same time" )
182+ ? errorState . message
183+ : "Error Occured in Starting Workspace" ,
184+ } ;
185+ throw error ;
183186 }
184187 const workspace = this . parse ( JSON . stringify ( json ) ) ;
185188 return workspace ;
186- }
189+ } ;
187190
188191 public stop : ( params : IWorkspaceParams ) => void = async ( params : IWorkspaceParams ) => {
189192 const { workspaceID } = params ;
@@ -192,7 +195,7 @@ export class IWorkspace implements GitpodDataModel {
192195 method : "POST" ,
193196 headers : {
194197 "content-type" : "application/json" ,
195- " Authorization" : `Bearer ${ this . token } ` ,
198+ Authorization : `Bearer ${ this . token } ` ,
196199 } ,
197200 body : JSON . stringify ( { workspaceId : workspaceID } ) ,
198201 } ) ;
@@ -201,32 +204,32 @@ export class IWorkspace implements GitpodDataModel {
201204 const error : IWorkspaceError = {
202205 name : "WorkspaceStartError" ,
203206 code : response . status ,
204- message : "Error Occured in Stopping Workspace"
205- }
206- throw error
207+ message : "Error Occured in Stopping Workspace" ,
208+ } ;
209+ throw error ;
207210 }
208- }
209-
210- public static create : ( streamer : WorkspaceStreamer , params : ICreateWorkspaceParams ) => void = async ( streamer : WorkspaceStreamer , params : ICreateWorkspaceParams ) => {
211+ } ;
211212
213+ public static create : ( streamer : WorkspaceStreamer , params : ICreateWorkspaceParams ) => void = async (
214+ streamer : WorkspaceStreamer ,
215+ params : ICreateWorkspaceParams
216+ ) => {
212217 const createParams : CreateWorkspace = {
213218 method : "createWorkspace" ,
214- params : params
215- }
219+ params : params ,
220+ } ;
216221
217- streamer . execute ( createParams )
218- }
222+ streamer . execute ( createParams ) ;
223+ } ;
219224
220- public fetch : ( params : IWorkspaceParams ) => Promise < IWorkspace > | never = async (
221- params : IWorkspaceParams
222- ) => {
225+ public fetch : ( params : IWorkspaceParams ) => Promise < IWorkspace > | never = async ( params : IWorkspaceParams ) => {
223226 const { workspaceID } = params ;
224227
225228 const response = await fetch ( workspaceURLs . getWorkspace , {
226229 method : "GET" ,
227230 headers : {
228231 "content-type" : "application/json" ,
229- " Authorization" : `Bearer ${ this . token } ` ,
232+ Authorization : `Bearer ${ this . token } ` ,
230233 } ,
231234 body : JSON . stringify ( { workspaceID } ) ,
232235 } ) ;
@@ -235,9 +238,9 @@ export class IWorkspace implements GitpodDataModel {
235238 const error : IWorkspaceError = {
236239 name : "WorkspaceFetchError" ,
237240 code : response . status ,
238- message : response . statusText
239- }
240- throw error
241+ message : response . statusText ,
242+ } ;
243+ throw error ;
241244 }
242245
243246 const json = await response . json ( ) ;
@@ -252,27 +255,27 @@ export class IWorkspace implements GitpodDataModel {
252255 method : "POST" ,
253256 headers : {
254257 "content-type" : "application/json" ,
255- " Authorization" : `Bearer ${ token } ` ,
258+ Authorization : `Bearer ${ token } ` ,
256259 } ,
257260 body : JSON . stringify ( { } ) ,
258- } )
261+ } ) ;
259262 if ( response . status != 200 ) {
260263 const error : IWorkspaceError = {
261264 name : "WorkspaceFetchError" ,
262265 code : response . status ,
263- message : response . statusText
264- }
265- throw error
266+ message : response . statusText ,
267+ } ;
268+ throw error ;
266269 }
267270
268- const json = await response . json ( ) as any ;
271+ const json = ( await response . json ( ) ) as any ;
269272
270273 json . result . map ( ( workspace : unknown ) => {
271274 const space = new IWorkspace ( workspace , token ) ;
272275 workspaceMap . set ( space . workspaceId , space ) ;
273- } )
274- return workspaceMap
275- }
276+ } ) ;
277+ return workspaceMap ;
278+ } ;
276279
277280 // public delete = async () => {
278281 // const response = await fetch(workspaceURLs.deleteWorkspace, {
0 commit comments