Skip to content

Commit 0e83f09

Browse files
committed
precisely typed
1 parent 672d683 commit 0e83f09

3 files changed

Lines changed: 32 additions & 19 deletions

File tree

src/api/index.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ const cookiesMap = new Map<string, string[]>();
3030
export interface ConnectionSettings {
3131
serverName: string;
3232
active: boolean;
33-
apiVersion: number;
34-
serverVersion: string;
33+
apiVersion?: number;
34+
serverVersion?: string;
3535
https: boolean;
3636
host: string;
3737
port: number;
3838
superserverPort?: number;
39-
pathPrefix: string;
39+
pathPrefix?: string;
4040
ns: string;
4141
auth: Authorization;
42-
docker: boolean;
42+
docker?: boolean;
4343
dockerService?: string;
4444
}
4545

@@ -278,14 +278,18 @@ export class AtelierAPI {
278278
dockerService: conn["docker-compose"].service,
279279
};
280280
} else {
281-
this._config = conn;
282-
this._config.ns = ns;
283-
this._config.serverName = "";
281+
this._config = {
282+
...conn,
283+
ns,
284+
serverName: "",
285+
};
284286
}
285287
} else {
286-
this._config = conn;
287-
this._config.ns = ns;
288-
this._config.serverName = "";
288+
this._config = {
289+
...conn,
290+
ns,
291+
serverName: "",
292+
};
289293
}
290294
}
291295

src/extension.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import { ObjectScriptRoutineSymbolProvider } from "./providers/ObjectScriptRouti
7171
import { ObjectScriptCodeLensProvider } from "./providers/ObjectScriptCodeLensProvider";
7272
import { XmlContentProvider } from "./providers/XmlContentProvider";
7373

74-
import { AtelierAPI } from "./api";
74+
import { AtelierAPI, ConnectionSettings } from "./api";
7575
import { ObjectScriptDebugAdapterDescriptorFactory } from "./debug/debugAdapterFactory";
7676
import { ObjectScriptConfigurationProvider } from "./debug/debugConfProvider";
7777
import { ProjectsExplorerProvider } from "./explorer/projectsExplorer";
@@ -155,7 +155,15 @@ const lowCodeEditorViewType = packageJson.contributes.customEditors[0].viewType;
155155

156156
const _onDidChangeConnection = new vscode.EventEmitter<void>();
157157

158-
export const config = (setting?: string, workspaceFolderName?: string): vscode.WorkspaceConfiguration | any => {
158+
type ConnConfig = Pick<ConnectionSettings, "active" | "https" | "ns" | "host" | "port" | "auth"> & {
159+
"docker-compose"?: any;
160+
server?: any;
161+
links?: any;
162+
};
163+
164+
export function config(setting: "conn", workspaceFolderName?: string): ConnConfig;
165+
export function config(setting?: string, workspaceFolderName?: string): any;
166+
export function config(setting?: string, workspaceFolderName?: string): any {
159167
workspaceFolderName = workspaceFolderName || currentWorkspaceFolder();
160168
if (
161169
vscode.workspace.workspaceFolders?.length &&
@@ -181,16 +189,17 @@ export const config = (setting?: string, workspaceFolderName?: string): vscode.W
181189
const { port, hostname: host, auth, query } = url.parse("http://" + workspaceFolderName, true);
182190
const { ns = "USER", https = false } = query;
183191
const [username, password] = (auth || "_SYSTEM:SYS").split(":");
192+
const authorization = serverManagerApi.defaultAuth();
193+
authorization.resolve({ username, accessToken: password });
184194
if (setting == "conn") {
185195
return {
186196
active: true,
187197
https,
188198
ns,
189199
host,
190-
port,
191-
username,
192-
password,
193-
};
200+
port: +port,
201+
auth: authorization,
202+
} as ConnConfig;
194203
} else if (setting == "export") {
195204
return {};
196205
}
@@ -199,7 +208,7 @@ export const config = (setting?: string, workspaceFolderName?: string): vscode.W
199208
}
200209
const result = vscode.workspace.getConfiguration(prefix, workspaceFolder?.uri);
201210
return setting && setting.length ? result.get(setting) : result;
202-
};
211+
}
203212

204213
let reporter: TelemetryReporter;
205214

src/providers/DocumentContentProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { getUrisForDocument } from "../utils/documentIndex";
99
import { isfsConfig, IsfsUriParam } from "../utils/FileProviderUtil";
1010

1111
export function compareConns(
12-
conn1: { ns: any; server: any; host: any; port: any; "docker-compose": any },
13-
conn2: { ns: any; server: any; host: any; port: any; "docker-compose": any }
12+
conn1: { ns: any; server?: any; host: any; port: any; "docker-compose"?: any },
13+
conn2: { ns: any; server?: any; host: any; port: any; "docker-compose"?: any }
1414
): boolean {
1515
if (conn1.ns === conn2.ns) {
1616
// Same namespace name

0 commit comments

Comments
 (0)