@@ -7,11 +7,16 @@ export class AtelierAPI {
7
7
private cookies : string [ ] = [ ] ;
8
8
private _config : any ;
9
9
private _namespace : string ;
10
+ private _apiVersion : string ;
10
11
11
12
private get ns ( ) : string {
12
13
return this . _namespace || this . _config . ns ;
13
14
}
14
15
16
+ private get apiVersion ( ) : string {
17
+ return this . _apiVersion || this . _config . apiVersion ;
18
+ }
19
+
15
20
constructor ( ) {
16
21
this . setConnection ( currentWorkspaceFolder ( ) ) ;
17
22
}
@@ -20,6 +25,10 @@ export class AtelierAPI {
20
25
this . _namespace = namespace ;
21
26
}
22
27
28
+ setApiVersion ( apiVersion : string ) {
29
+ this . _apiVersion = apiVersion ;
30
+ }
31
+
23
32
updateCookies ( cookies : string [ ] ) {
24
33
cookies . forEach ( cookie => {
25
34
let [ cookieName ] = cookie . split ( '=' ) ;
@@ -146,7 +155,7 @@ export class AtelierAPI {
146
155
type ?: string ;
147
156
filter ?: string ;
148
157
} ) : Promise < any > {
149
- return this . request ( 'GET' , `v3 /${ this . ns } /docnames/${ category } /${ type } ` , null , {
158
+ return this . request ( 'GET' , `${ this . apiVersion } /${ this . ns } /docnames/${ category } /${ type } ` , null , {
150
159
filter,
151
160
generated
152
161
} ) ;
@@ -159,47 +168,47 @@ export class AtelierAPI {
159
168
format
160
169
} ;
161
170
}
162
- return this . request ( 'GET' , `v3 /${ this . ns } /doc/${ name } ` , params ) ;
171
+ return this . request ( 'GET' , `${ this . apiVersion } /${ this . ns } /doc/${ name } ` , params ) ;
163
172
}
164
173
165
174
putDoc ( name : string , data : { enc : boolean ; content : string [ ] } , ignoreConflict ?: boolean ) : Promise < any > {
166
175
let params = { ignoreConflict } ;
167
- return this . request ( 'PUT' , `v3 /${ this . ns } /doc/${ name } ` , data , params ) ;
176
+ return this . request ( 'PUT' , `${ this . apiVersion } /${ this . ns } /doc/${ name } ` , data , params ) ;
168
177
}
169
178
170
179
actionIndex ( docs : string [ ] ) : Promise < any > {
171
- return this . request ( 'POST' , `v3 /${ this . ns } /action/index` , docs ) ;
180
+ return this . request ( 'POST' , `${ this . apiVersion } /${ this . ns } /action/index` , docs ) ;
172
181
}
173
182
174
183
actionSearch ( params : { query : string ; files ?: string ; sys ?: boolean ; gen ?: boolean ; max ?: number } ) : Promise < any > {
175
- return this . request ( 'GET' , `v3 /${ this . ns } /action/search` , null , params ) ;
184
+ return this . request ( 'GET' , `${ this . apiVersion } /${ this . ns } /action/search` , null , params ) ;
176
185
}
177
186
178
187
actionQuery ( query : string , parameters : string [ ] ) : Promise < any > {
179
- return this . request ( 'POST' , `v3 /${ this . ns } /action/query` , {
188
+ return this . request ( 'POST' , `${ this . apiVersion } /${ this . ns } /action/query` , {
180
189
query,
181
190
parameters
182
191
} ) ;
183
192
}
184
193
185
194
actionCompile ( docs : string [ ] , flags ?: string , source = false ) : Promise < any > {
186
- return this . request ( 'POST' , `v3 /${ this . ns } /action/compile` , docs , { flags, source } ) ;
195
+ return this . request ( 'POST' , `${ this . apiVersion } /${ this . ns } /action/compile` , docs , { flags, source } ) ;
187
196
}
188
197
189
198
cvtXmlUdl ( source : string ) : Promise < any > {
190
- return this . request ( 'POST' , `v3 /${ this . ns } /cvt/xml/doc` , source , { } , { 'Content-Type' : 'application/xml' } ) ;
199
+ return this . request ( 'POST' , `${ this . apiVersion } /${ this . ns } /cvt/xml/doc` , source , { } , { 'Content-Type' : 'application/xml' } ) ;
191
200
}
192
201
193
202
getmacrodefinition ( docname : string , macroname : string , includes : string [ ] ) {
194
- return this . request ( 'POST' , `v3 /${ this . ns } /action/getmacrodefinition` , {
203
+ return this . request ( 'POST' , `${ this . apiVersion } /${ this . ns } /action/getmacrodefinition` , {
195
204
docname,
196
205
macroname,
197
206
includes
198
207
} ) ;
199
208
}
200
209
201
210
getmacrolocation ( docname : string , macroname : string , includes : string [ ] ) {
202
- return this . request ( 'POST' , `v3 /${ this . ns } /action/getmacrolocation` , {
211
+ return this . request ( 'POST' , `${ this . apiVersion } /${ this . ns } /action/getmacrolocation` , {
203
212
docname,
204
213
macroname,
205
214
includes
0 commit comments