Skip to content

Commit 85a0e6d

Browse files
committed
addressed comments
1 parent 1e6bdf1 commit 85a0e6d

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

examples/repl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function initClient({ host, endpointId, token }) {
1515
host,
1616
path: `/sql/2.0/warehouses/${endpointId}`,
1717
token,
18-
userAgentHeader: 'REPL',
18+
userAgentEntry: 'REPL',
1919
});
2020
}
2121

lib/DBSQLClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient, I
111111
socketTimeout: options.socketTimeout,
112112
proxy: options.proxy,
113113
headers: {
114-
'User-Agent': buildUserAgentString(options.userAgentHeader),
114+
'User-Agent': buildUserAgentString(options.userAgentEntry),
115115
},
116116
};
117117
}

lib/contracts/IDBSQLClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export type ConnectionOptions = {
3030
host: string;
3131
port?: number;
3232
path: string;
33-
userAgentHeader?: string;
33+
userAgentEntry?: string;
3434
socketTimeout?: number;
3535
proxy?: ProxyOptions;
3636
} & AuthOptions;

lib/utils/buildUserAgentString.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function getOperatingSystemVersion(): string {
1111
return `${os.type()} ${os.release()}`;
1212
}
1313

14-
export default function buildUserAgentString(userAgentHeader?: string): string {
15-
const extra = [userAgentHeader, getNodeVersion(), getOperatingSystemVersion()].filter(Boolean);
14+
export default function buildUserAgentString(userAgentEntry?: string): string {
15+
const extra = [userAgentEntry, getNodeVersion(), getOperatingSystemVersion()].filter(Boolean);
1616
return `${productName}/${packageVersion} (${extra.join('; ')})`;
1717
}

tests/unit/utils/utils.test.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ describe('buildUserAgentString', () => {
1919
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent
2020
//
2121
// UserAgent ::= <ProductName> '/' <ProductVersion> '(' <Comment> ')'
22+
// where:
2223
// ProductName ::= 'NodejsDatabricksSqlConnector'
23-
// <Comment> ::= [ <userAgentHeader> ';' ] 'Node.js' <NodeJsVersion> ';' <OSPlatform> <OSVersion>
24+
// ProductVersion ::= three period-separated digits
25+
// <Comment> ::= [ <userAgentEntry> ';' ] 'Node.js' <NodeJsVersion> ';' <OSPlatform> <OSVersion>
2426
//
2527
// Examples:
26-
// - with <userAgentHeader> provided: NodejsDatabricksSqlConnector/0.1.8-beta.1 (Client ID; Node.js 16.13.1; Darwin 21.5.0)
27-
// - without <userAgentHeader> provided: NodejsDatabricksSqlConnector/0.1.8-beta.1 (Node.js 16.13.1; Darwin 21.5.0)
28+
// - with <userAgentEntry> provided: NodejsDatabricksSqlConnector/0.1.8-beta.1 (<userAgentEntry>; Node.js 16.13.1; Darwin 21.5.0)
29+
// - without <userAgentEntry> provided: NodejsDatabricksSqlConnector/0.1.8-beta.1 (Node.js 16.13.1; Darwin 21.5.0)
2830

29-
function checkUserAgentString(ua: string, userAgentHeader?: string) {
31+
function checkUserAgentString(ua: string, userAgentEntry?: string) {
3032
// Prefix: 'NodejsDatabricksSqlConnector/'
3133
// Version: three period-separated digits and optional suffix
3234
const re =
@@ -39,18 +41,18 @@ describe('buildUserAgentString', () => {
3941
const parts = comment.split(';').map((s) => s.trim());
4042
expect(parts.length).to.be.gte(2); // at least Node and OS version should be there
4143

42-
if (userAgentHeader) {
43-
expect(comment.trim()).to.satisfy((s: string) => s.startsWith(`${userAgentHeader};`));
44+
if (userAgentEntry) {
45+
expect(comment.trim()).to.satisfy((s: string) => s.startsWith(`${userAgentEntry};`));
4446
}
4547
}
4648

47-
it('matches pattern with userAgentHeader', () => {
48-
const userAgentHeader = 'Some Client ID';
49-
const ua = buildUserAgentString(userAgentHeader);
50-
checkUserAgentString(ua, userAgentHeader);
49+
it('matches pattern with userAgentEntry', () => {
50+
const userAgentEntry = 'Some user agent';
51+
const ua = buildUserAgentString(userAgentEntry);
52+
checkUserAgentString(ua, userAgentEntry);
5153
});
5254

53-
it('matches pattern without userAgentHeader', () => {
55+
it('matches pattern without userAgentEntry', () => {
5456
const ua = buildUserAgentString();
5557
checkUserAgentString(ua);
5658
});

0 commit comments

Comments
 (0)