Skip to content

Commit d2d1b68

Browse files
author
Kenneth Shepherd
committed
Fixed an issue with extensionContext not being exported and also added a config option dropdownlist for the api version number. You can choose v2 or v3.. My 2017 server does not like the v3 api calls at all.
1 parent 5bc1600 commit d2d1b68

File tree

4 files changed

+36
-12
lines changed

4 files changed

+36
-12
lines changed

Diff for: api/index.ts

+19-10
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ export class AtelierAPI {
77
private cookies: string[] = [];
88
private _config: any;
99
private _namespace: string;
10+
private _apiVersion: string;
1011

1112
private get ns(): string {
1213
return this._namespace || this._config.ns;
1314
}
1415

16+
private get apiVersion(): string {
17+
return this._apiVersion || this._config.apiVersion;
18+
}
19+
1520
constructor() {
1621
this.setConnection(currentWorkspaceFolder());
1722
}
@@ -20,6 +25,10 @@ export class AtelierAPI {
2025
this._namespace = namespace;
2126
}
2227

28+
setApiVersion(apiVersion: string) {
29+
this._apiVersion = apiVersion;
30+
}
31+
2332
updateCookies(cookies: string[]) {
2433
cookies.forEach(cookie => {
2534
let [cookieName] = cookie.split('=');
@@ -146,7 +155,7 @@ export class AtelierAPI {
146155
type?: string;
147156
filter?: string;
148157
}): 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, {
150159
filter,
151160
generated
152161
});
@@ -159,47 +168,47 @@ export class AtelierAPI {
159168
format
160169
};
161170
}
162-
return this.request('GET', `v3/${this.ns}/doc/${name}`, params);
171+
return this.request('GET', `${this.apiVersion}/${this.ns}/doc/${name}`, params);
163172
}
164173

165174
putDoc(name: string, data: { enc: boolean; content: string[] }, ignoreConflict?: boolean): Promise<any> {
166175
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);
168177
}
169178

170179
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);
172181
}
173182

174183
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);
176185
}
177186

178187
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`, {
180189
query,
181190
parameters
182191
});
183192
}
184193

185194
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 });
187196
}
188197

189198
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' });
191200
}
192201

193202
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`, {
195204
docname,
196205
macroname,
197206
includes
198207
});
199208
}
200209

201210
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`, {
203212
docname,
204213
macroname,
205214
includes

Diff for: extension.ts

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { WorkspaceSymbolProvider } from './providers/WorkspaceSymbolProvider';
2929
export var explorerProvider: ObjectScriptExplorerProvider;
3030
export var documentContentProvider: DocumentContentProvider;
3131
export var workspaceState: vscode.Memento;
32+
export var extensionContext: vscode.ExtensionContext;
3233

3334
export const config = (config?: string, workspaceFolderName?: string): any => {
3435
workspaceFolderName = workspaceFolderName || currentWorkspaceFolder();
@@ -62,6 +63,7 @@ export function getXmlUri(uri: vscode.Uri): vscode.Uri {
6263
export async function activate(context: vscode.ExtensionContext): Promise<void> {
6364
const languages = require(context.asAbsolutePath('./package.json'))['contributes']['languages'].map(lang => lang.id);
6465
workspaceState = context.workspaceState;
66+
extensionContext = context;
6567
workspaceState.update('workspaceFolder', '');
6668

6769
explorerProvider = new ObjectScriptExplorerProvider();

Diff for: package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+13
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,19 @@
369369
"type": "boolean",
370370
"default": false
371371
},
372+
"objectscript.conn.apiVersion": {
373+
"description": "Version of the API to use.",
374+
"type": "string",
375+
"enum": [
376+
"v2",
377+
"v3"
378+
],
379+
"enumDescriptions": [
380+
"Use v2 api",
381+
"Use v3 api"
382+
],
383+
"default": "v3"
384+
},
372385
"objectscript.export": {
373386
"type": "object",
374387
"description": "Export only the necessary stuff "

0 commit comments

Comments
 (0)