Skip to content

Commit a35f468

Browse files
committed
renamed clientId to userAgentHeader in connect args
1 parent 14d31a4 commit a35f468

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-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-
clientId: 'REPL',
18+
userAgentHeader: '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.clientId),
114+
'User-Agent': buildUserAgentString(options.userAgentHeader),
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-
clientId?: string;
33+
userAgentHeader?: 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(clientId?: string): string {
15-
const extra = [clientId, getNodeVersion(), getOperatingSystemVersion()].filter(Boolean);
14+
export default function buildUserAgentString(userAgentHeader?: string): string {
15+
const extra = [userAgentHeader, getNodeVersion(), getOperatingSystemVersion()].filter(Boolean);
1616
return `${productName}/${packageVersion} (${extra.join('; ')})`;
1717
}

tests/unit/utils/utils.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ describe('buildUserAgentString', () => {
2020
//
2121
// UserAgent ::= <ProductName> '/' <ProductVersion> '(' <Comment> ')'
2222
// ProductName ::= 'NodejsDatabricksSqlConnector'
23-
// <Comment> ::= [ <ClientId> ';' ] 'Node.js' <NodeJsVersion> ';' <OSPlatform> <OSVersion>
23+
// <Comment> ::= [ <userAgentHeader> ';' ] 'Node.js' <NodeJsVersion> ';' <OSPlatform> <OSVersion>
2424
//
2525
// Examples:
26-
// - with <ClientId> provided: NodejsDatabricksSqlConnector/0.1.8-beta.1 (Client ID; Node.js 16.13.1; Darwin 21.5.0)
27-
// - without <ClientId> provided: NodejsDatabricksSqlConnector/0.1.8-beta.1 (Node.js 16.13.1; Darwin 21.5.0)
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)
2828

29-
function checkUserAgentString(ua: string, clientId?: string) {
29+
function checkUserAgentString(ua: string, userAgentHeader?: string) {
3030
// Prefix: 'NodejsDatabricksSqlConnector/'
3131
// Version: three period-separated digits and optional suffix
3232
const re =
@@ -38,18 +38,18 @@ describe('buildUserAgentString', () => {
3838

3939
expect(comment.split(';').length).to.be.gte(2); // at least Node and OS version should be there
4040

41-
if (clientId) {
42-
expect(comment.trim()).to.satisfy((s: string) => s.startsWith(`${clientId};`));
41+
if (userAgentHeader) {
42+
expect(comment.trim()).to.satisfy((s: string) => s.startsWith(`${userAgentHeader};`));
4343
}
4444
}
4545

46-
it('matches pattern with clientId', () => {
47-
const clientId = 'Some Client ID';
48-
const ua = buildUserAgentString(clientId);
49-
checkUserAgentString(ua, clientId);
46+
it('matches pattern with userAgentHeader', () => {
47+
const userAgentHeader = 'Some Client ID';
48+
const ua = buildUserAgentString(userAgentHeader);
49+
checkUserAgentString(ua, userAgentHeader);
5050
});
5151

52-
it('matches pattern without clientId', () => {
52+
it('matches pattern without userAgentHeader', () => {
5353
const ua = buildUserAgentString();
5454
checkUserAgentString(ua);
5555
});

0 commit comments

Comments
 (0)