Skip to content

Commit 6558f09

Browse files
committed
Switching version option type
BREAKING CHANGE: Switch the version option to be a number and not a string. For example 4 instead of 'v4'.
1 parent 79d8c71 commit 6558f09

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Diff for: src/core/infrastructure/BaseService.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface BaseServiceOptions {
1414
jobToken?: string;
1515
host?: string;
1616
url?: string;
17-
version?: 'v3' | 'v4';
17+
version?: 3 | 4;
1818
rejectUnauthorized?: boolean;
1919
camelize?: boolean;
2020
requester?: Requester;
@@ -46,13 +46,13 @@ export class BaseService {
4646
profileMode = 'execution',
4747
host = 'https://gitlab.com',
4848
url = '',
49-
version = 'v4',
49+
version = 4,
5050
camelize = false,
5151
rejectUnauthorized = true,
5252
requester = KyRequester as Requester,
5353
requestTimeout = 300000,
5454
}: BaseServiceOptions = {}) {
55-
this.url = [host, 'api', version, url].join('/');
55+
this.url = [host, 'api', `v${version}`, url].join('/');
5656
this.headers = {};
5757
this.rejectUnauthorized = rejectUnauthorized;
5858
this.camelize = camelize;

Diff for: test/unit/infrastructure/BaseService.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('Creation of BaseService instance', () => {
3333
});
3434

3535
test('API version should be modified', async () => {
36-
const service = new BaseService({ host: 'https://testing.com', token: '1234', version: 'v3' });
36+
const service = new BaseService({ host: 'https://testing.com', token: '1234', version: 3 });
3737

3838
expect(service.url).toBe('https://testing.com/api/v3/');
3939
});
@@ -44,7 +44,10 @@ describe('Creation of BaseService instance', () => {
4444

4545
service.show = jest.fn(() => RequestHelper.get(service, 'test'));
4646
KyRequester.get = jest.fn(() => ({
47-
body: [{ id: 3, gravatar_enable: true }, { id: 4, gravatar_enable: false }],
47+
body: [
48+
{ id: 3, gravatar_enable: true },
49+
{ id: 4, gravatar_enable: false },
50+
],
4851
headers: {},
4952
}));
5053

0 commit comments

Comments
 (0)