Skip to content

Commit 285582f

Browse files
committed
fixed connection settings
1 parent fd4ef5f commit 285582f

File tree

6 files changed

+44
-39
lines changed

6 files changed

+44
-39
lines changed

.vscodeignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
.github/**
12
.vscode/**
23
.vscode-test/**
34
out/test/**
4-
src/**
5+
**/*.ts
6+
**/*.map
57
.gitignore
68
**/tsconfig.json
9+
**/tslint.json
710
**/.eslintrc.json
8-
**/*.map
9-
**/*.ts

connection.schema.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"namespace": {
66
"title": "Namespace",
77
"type": "string",
8-
"minLength": 1
8+
"minLength": 1,
9+
"default": "USER"
910
},
1011
"username": {
1112
"title": "Username",
@@ -24,6 +25,7 @@
2425
}
2526
},
2627
"properties": {
28+
"namespace": { "$ref": "#/definitions/namespace" },
2729
"connectionMethod": {
2830
"title": "Connect using",
2931
"type": "string",
@@ -52,7 +54,6 @@
5254
"default": 52773,
5355
"type": "integer"
5456
},
55-
"namespace": { "$ref": "#/definitions/namespace" },
5657
"username": { "$ref": "#/definitions/username" },
5758
"askForPassword": { "$ref": "#/definitions/askForPassword" }
5859
},
@@ -69,7 +70,7 @@
6970
"minLength": 1
7071
}
7172
},
72-
"required": ["connectString"]
73+
"required": ["serverName"]
7374
}
7475
]
7576
},
@@ -87,6 +88,6 @@
8788
}
8889
},
8990
"required": [
90-
"connectionMethod"
91+
"connectionMethod", "namespace"
9192
]
9293
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"devDependencies": {
4848
"@babel/preset-env": "^7.5.5",
4949
"@types/node": "^14.0.14",
50-
"@types/vscode": "^1.42.0",
50+
"@types/vscode": "^1.46.0",
5151
"typescript": "^3.7.3"
5252
}
5353
}

src/ls/driver.ts

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,48 @@ import AbstractDriver from '@sqltools/base-driver';
22
import queries from './queries';
33
import { IConnectionDriver, MConnectionExplorer, NSDatabase, ContextValue, Arg0 } from '@sqltools/types';
44
import { v4 as generateId } from 'uuid';
5-
import IRISdb, { IRISConfiguration } from './irisdb';
5+
import IRISdb, { IRISDirect } from './irisdb';
66
import keywordsCompletion from './keywords';
7+
// import { workspace } from "vscode";
78

89
type DriverOptions = any;
910

1011
export default class IRISDriver extends AbstractDriver<IRISdb, DriverOptions> implements IConnectionDriver {
1112

1213
queries = queries;
13-
14+
1415
public async open() {
1516
if (this.connection) {
1617
return this.connection;
1718
}
1819

19-
let config: IRISConfiguration;
20+
const { namespace } = this.credentials;
21+
let config: IRISDirect;
2022
if (this.credentials.serverName) {
23+
// const serverName = this.credentials.serverName;
24+
// const server = workspace.getConfiguration(`intersystems.servers.${serverName}.webServer`);
25+
// let { scheme, host, port, pathPrefix, username, password } = server;
26+
// config = {
27+
// https: scheme === "https",
28+
// host,
29+
// port,
30+
// pathPrefix,
31+
// namespace,
32+
// username,
33+
// password
34+
// };
35+
} else {
36+
let { https, server: host, port, pathPrefix, username, password } = this.credentials;
2137
config = {
22-
serverName: this.credentials.serverName
38+
https,
39+
host,
40+
port,
41+
pathPrefix,
42+
namespace,
43+
username,
44+
password
2345
};
2446
}
25-
else {
26-
config = {
27-
host: this.credentials.server,
28-
port: this.credentials.port,
29-
namespace: this.credentials.namespace
30-
}
31-
}
3247

3348
const irisdb = new IRISdb(config);
3449
return irisdb.open()
@@ -54,7 +69,7 @@ export default class IRISDriver extends AbstractDriver<IRISdb, DriverOptions> im
5469
resultsAgg.push({
5570
cols: Object.keys(queryResult[0]),
5671
connId: this.getId(),
57-
messages: [{ date: new Date(), message: `Query ok with ${queryResult.length} results`}],
72+
messages: [{ date: new Date(), message: `Query ok with ${queryResult.length} results` }],
5873
results: queryResult,
5974
query: queries.toString(),
6075
requestId: opt.requestId,

src/ls/irisdb.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,24 @@ import * as httpModule from "http";
22
import * as httpsModule from "https";
33
import requestPromise from "request-promise";
44

5-
interface IRISDirect {
5+
export class IRISDirect {
66
https?: boolean;
77
host: string;
88
port: number;
9+
pathPrefix?: string;
910
namespace: string;
1011
username?: string;
1112
password?: string;
1213
}
1314

14-
interface IRISServerManager {
15-
serverName: string;
16-
}
17-
18-
export type IRISConfiguration = IRISDirect | IRISServerManager;
19-
2015
export default class IRISdb {
2116

2217
private config: IRISDirect;
2318
private cookies: string[] = [];
2419
private apiVersion = 1;
2520

26-
public constructor(config: IRISConfiguration) {
27-
this.config = {
28-
https: false,
29-
host: 'localhost',
30-
port: 52774,
31-
namespace: 'LIBERO',
32-
username: '_SYSTEM',
33-
password: 'SYS'
34-
};
21+
public constructor(config: IRISDirect) {
22+
this.config = config;
3523
this.config.namespace = this.config.namespace.toUpperCase();
3624
}
3725

@@ -109,7 +97,7 @@ export default class IRISdb {
10997
return auth.then(cookie =>
11098
requestPromise({
11199
agent,
112-
auth: { username, password, sendImmediately: true },
100+
auth: { user: username, pass: password, sendImmediately: true },
113101
body: ["PUT", "POST"].includes(method) ? body : null,
114102
headers: {
115103
...headers,

src/ls/plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { ILanguageServerPlugin } from '@sqltools/types';
2-
import YourDriver from './driver';
2+
import IRISDriver from './driver';
33
import { DRIVER_ALIASES } from './../constants';
44

55
const InterSystemsPlugin: ILanguageServerPlugin = {
66
register(server) {
77
DRIVER_ALIASES.forEach(({ value }) => {
8-
server.getContext().drivers.set(value, YourDriver as any);
8+
server.getContext().drivers.set(value, IRISDriver as any);
99
});
1010
}
1111
}

0 commit comments

Comments
 (0)