@@ -20,18 +20,6 @@ export class AtelierAPI {
2020 return this . namespace || this . config . ns ;
2121 }
2222
23- private get apiVersion ( ) : number {
24- return workspaceState . get ( this . workspaceFolder + ":apiVersion" , DEFAULT_API_VERSION ) ;
25- }
26-
27- private get port ( ) : number {
28- return workspaceState . get ( this . workspaceFolder + ":port" , this . config . port ) ;
29- }
30-
31- private get password ( ) : string {
32- return workspaceState . get ( this . workspaceFolder + ":password" , this . config . password ) ;
33- }
34-
3523 private get iris ( ) : boolean {
3624 return workspaceState . get ( this . workspaceFolder + ":iris" , false ) ;
3725 }
@@ -74,14 +62,12 @@ export class AtelierAPI {
7462 }
7563
7664 public xdebugUrl ( ) : string {
77- const { host, username, https } = this . config ;
78- const port = this . port ;
79- const password = this . password ;
65+ const { host, username, https, port, password, apiVersion } = this . config ;
8066 const proto = https ? "wss" : "ws" ;
8167 const auth = this . iris
8268 ? `IRISUsername=${ username } &IRISPassword=${ password } `
8369 : `CacheUserName=${ username } &CachePassword=${ password } ` ;
84- return `${ proto } ://${ host } :${ port } /api/atelier/v${ this . apiVersion } /%25SYS/debug?${ auth } ` ;
70+ return `${ proto } ://${ host } :${ port } /api/atelier/v${ apiVersion } /%25SYS/debug?${ auth } ` ;
8571 }
8672
8773 public updateCookies ( newCookies : string [ ] ) : Promise < any > {
@@ -102,8 +88,11 @@ export class AtelierAPI {
10288 this . workspaceFolder = workspaceFolderName ;
10389 const conn = config ( "conn" , workspaceFolderName ) ;
10490 this . config = conn ;
105- const { name, host } = this . config ;
106- const port = this . port ;
91+ this . config . port = workspaceState . get ( this . workspaceFolder + ":port" , this . config . port ) ;
92+ this . config . password = workspaceState . get ( this . workspaceFolder + ":password" , this . config . password ) ;
93+ this . config . apiVersion = workspaceState . get ( this . workspaceFolder + ":apiVersion" , DEFAULT_API_VERSION ) ;
94+
95+ const { name, host, port } = this . config ;
10796 this . cache = new Cache ( extensionContext , `API:${ name } :${ host } :${ port } ` ) ;
10897 }
10998
@@ -115,14 +104,15 @@ export class AtelierAPI {
115104 params ?: any ,
116105 headers ?: any
117106 ) : Promise < any > {
118- if ( minVersion > this . apiVersion ) {
119- return Promise . reject ( `${ path } not supported by API version ${ this . apiVersion } ` ) ;
107+ const { active, apiVersion, host, username, https, port, password } = this . config ;
108+ if ( ! active ) {
109+ return Promise . reject ( ) ;
120110 }
121- if ( minVersion && minVersion > 0 ) {
122- path = `v ${ this . apiVersion } / ${ path } ` ;
111+ if ( minVersion > apiVersion ) {
112+ return Promise . reject ( ` ${ path } not supported by API version ${ apiVersion } ` ) ;
123113 }
124- if ( ! this . config . active ) {
125- return Promise . reject ( ) ;
114+ if ( minVersion && minVersion > 0 ) {
115+ path = `v ${ apiVersion } / ${ path } ` ;
126116 }
127117 headers = {
128118 ...headers ,
@@ -149,9 +139,6 @@ export class AtelierAPI {
149139 }
150140 headers [ "Cache-Control" ] = "no-cache" ;
151141
152- const { host, username, https } = this . config ;
153- const port = this . port ;
154- const password = this . password ;
155142 const proto = this . config . https ? "https" : "http" ;
156143 const http : any = this . config . https ? httpsModule : httpModule ;
157144 const agent = new http . Agent ( {
0 commit comments