Skip to content

Commit a7ef866

Browse files
committed
Consolidates to *.gitkraken.dev URLs for apis
1 parent 32aab62 commit a7ef866

File tree

9 files changed

+44
-63
lines changed

9 files changed

+44
-63
lines changed

src/plus/drafts/draftsService.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { Container } from '../../container';
88
import type { GitCommit } from '../../git/models/commit';
99
import type { PullRequest } from '../../git/models/pullRequest';
1010
import { isRepository, Repository } from '../../git/models/repository';
11-
import { isSha, isUncommitted , shortenRevision } from '../../git/models/revision.utils';
11+
import { isSha, isUncommitted, shortenRevision } from '../../git/models/revision.utils';
1212
import type { GitUser } from '../../git/models/user';
1313
import { getRemoteProviderMatcher } from '../../git/remotes/remoteProviders';
1414
import type {
@@ -123,7 +123,7 @@ export class DraftService implements Disposable {
123123
}
124124

125125
// POST v1/drafts
126-
const createDraftRsp = await this.connection.fetchGkDevApi('v1/drafts', {
126+
const createDraftRsp = await this.connection.fetchGkApi('v1/drafts', {
127127
method: 'POST',
128128
body: JSON.stringify({
129129
type: type,
@@ -143,7 +143,7 @@ export class DraftService implements Disposable {
143143
type ChangesetResult = { data: DraftChangesetCreateResponse };
144144

145145
// POST /v1/drafts/:draftId/changesets
146-
const createChangesetRsp = await this.connection.fetchGkDevApi(`v1/drafts/${draftId}/changesets`, {
146+
const createChangesetRsp = await this.connection.fetchGkApi(`v1/drafts/${draftId}/changesets`, {
147147
method: 'POST',
148148
body: JSON.stringify({
149149
// parentChangesetId: null,
@@ -205,7 +205,7 @@ export class DraftService implements Disposable {
205205
}
206206

207207
// POST /v1/drafts/:draftId/publish
208-
const publishRsp = await this.connection.fetchGkDevApi(`v1/drafts/${draftId}/publish`, {
208+
const publishRsp = await this.connection.fetchGkApi(`v1/drafts/${draftId}/publish`, {
209209
method: 'POST',
210210
headers: providerAuthHeader,
211211
body: prEntityIdBody != null ? JSON.stringify(prEntityIdBody) : undefined,
@@ -216,7 +216,7 @@ export class DraftService implements Disposable {
216216

217217
type Result = { data: DraftResponse };
218218

219-
const draftRsp = await this.connection.fetchGkDevApi(`v1/drafts/${draftId}`, {
219+
const draftRsp = await this.connection.fetchGkApi(`v1/drafts/${draftId}`, {
220220
method: 'GET',
221221
headers: providerAuthHeader,
222222
});
@@ -324,7 +324,7 @@ export class DraftService implements Disposable {
324324

325325
@log()
326326
async deleteDraft(id: string): Promise<void> {
327-
await this.connection.fetchGkDevApi(`v1/drafts/${id}`, { method: 'DELETE' });
327+
await this.connection.fetchGkApi(`v1/drafts/${id}`, { method: 'DELETE' });
328328
}
329329

330330
@log<DraftService['archiveDraft']>({ args: { 1: opts => JSON.stringify({ ...opts, providerAuth: undefined }) } })
@@ -347,7 +347,7 @@ export class DraftService implements Disposable {
347347
};
348348
}
349349

350-
const rsp = await this.connection.fetchGkDevApi(`v1/drafts/${draft.id}/archive`, {
350+
const rsp = await this.connection.fetchGkApi(`v1/drafts/${draft.id}/archive`, {
351351
method: 'POST',
352352
body:
353353
options?.archiveReason != null
@@ -381,7 +381,7 @@ export class DraftService implements Disposable {
381381
}
382382

383383
const [rspResult, changesetsResult] = await Promise.allSettled([
384-
this.connection.fetchGkDevApi(`v1/drafts/${id}`, { method: 'GET', headers: headers }),
384+
this.connection.fetchGkApi(`v1/drafts/${id}`, { method: 'GET', headers: headers }),
385385
this.getChangesets(id),
386386
]);
387387

@@ -458,7 +458,7 @@ export class DraftService implements Disposable {
458458
};
459459
}
460460

461-
const rsp = await this.connection.fetchGkDevApi(
461+
const rsp = await this.connection.fetchGkApi(
462462
'/v1/drafts',
463463
{
464464
method: 'GET',
@@ -500,7 +500,7 @@ export class DraftService implements Disposable {
500500
type Result = { data: DraftChangesetResponse[] };
501501

502502
try {
503-
const rsp = await this.connection.fetchGkDevApi(`/v1/drafts/${id}/changesets`, { method: 'GET' });
503+
const rsp = await this.connection.fetchGkApi(`/v1/drafts/${id}/changesets`, { method: 'GET' });
504504
if (!rsp.ok) {
505505
await handleBadDraftResponse(`Unable to open changesets for draft '${id}'`, rsp, scope);
506506
}
@@ -538,7 +538,7 @@ export class DraftService implements Disposable {
538538
type Result = { data: DraftPatchResponse };
539539

540540
// GET /v1/patches/:patchId
541-
const rsp = await this.connection.fetchGkDevApi(`/v1/patches/${id}`, { method: 'GET' });
541+
const rsp = await this.connection.fetchGkApi(`/v1/patches/${id}`, { method: 'GET' });
542542

543543
if (!rsp.ok) {
544544
await handleBadDraftResponse(`Unable to open patch '${id}'`, rsp, scope);
@@ -610,7 +610,7 @@ export class DraftService implements Disposable {
610610
type Result = { data: Draft };
611611

612612
try {
613-
const rsp = await this.connection.fetchGkDevApi(`/v1/drafts/${id}`, {
613+
const rsp = await this.connection.fetchGkApi(`/v1/drafts/${id}`, {
614614
method: 'PATCH',
615615
body: JSON.stringify({ visibility: visibility }),
616616
});
@@ -636,7 +636,7 @@ export class DraftService implements Disposable {
636636
type Result = { data: DraftUser[] };
637637

638638
try {
639-
const rsp = await this.connection.fetchGkDevApi(`/v1/drafts/${id}/users`, { method: 'GET' });
639+
const rsp = await this.connection.fetchGkApi(`/v1/drafts/${id}/users`, { method: 'GET' });
640640

641641
if (rsp?.ok === false) {
642642
await handleBadDraftResponse(`Unable to get users for draft '${id}'`, rsp, scope);
@@ -664,7 +664,7 @@ export class DraftService implements Disposable {
664664
throw new Error('No changes found');
665665
}
666666

667-
const rsp = await this.connection.fetchGkDevApi(`/v1/drafts/${id}/users`, {
667+
const rsp = await this.connection.fetchGkApi(`/v1/drafts/${id}/users`, {
668668
method: 'POST',
669669
body: JSON.stringify({
670670
id: id,
@@ -690,7 +690,7 @@ export class DraftService implements Disposable {
690690
async removeDraftUser(id: string, userId: DraftUser['userId']): Promise<boolean> {
691691
const scope = getLogScope();
692692
try {
693-
const rsp = await this.connection.fetchGkDevApi(`/v1/drafts/${id}/users/${userId}`, { method: 'DELETE' });
693+
const rsp = await this.connection.fetchGkApi(`/v1/drafts/${id}/users/${userId}`, { method: 'DELETE' });
694694

695695
if (rsp?.ok === false) {
696696
await handleBadDraftResponse(`Unable to update user ${userId} for draft '${id}'`, rsp, scope);
@@ -718,7 +718,7 @@ export class DraftService implements Disposable {
718718
async getRepositoryIdentity(draftId: Draft['id'], repoId: GkRepositoryId): Promise<RepositoryIdentity> {
719719
type Result = { data: RepositoryIdentityResponse };
720720

721-
const rsp = await this.connection.fetchGkDevApi(`/v1/drafts/${draftId}/git-repositories/${repoId}`, {
721+
const rsp = await this.connection.fetchGkApi(`/v1/drafts/${draftId}/git-repositories/${repoId}`, {
722722
method: 'GET',
723723
});
724724
const data = ((await rsp.json()) as Result).data;
@@ -862,7 +862,7 @@ export class DraftService implements Disposable {
862862
});
863863

864864
try {
865-
const rsp = await this.connection.fetchGkDevApi(
865+
const rsp = await this.connection.fetchGkApi(
866866
'v1/drafts/counts',
867867
{
868868
method: 'POST',

src/plus/gk/account/authenticationConnection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class AuthenticationConnection implements Disposable {
4747

4848
let rsp: Response;
4949
try {
50-
rsp = await this.connection.fetchApi('user', undefined, { token: token });
50+
rsp = await this.connection.fetchGkApi('user', undefined, { token: token });
5151
} catch (ex) {
5252
Logger.error(ex, scope);
5353
throw ex;
@@ -195,7 +195,7 @@ export class AuthenticationConnection implements Disposable {
195195
}
196196
}
197197

198-
const rsp = await this.connection.fetchGkDevApi(
198+
const rsp = await this.connection.fetchGkApi(
199199
'oauth/access_token',
200200
{
201201
method: 'POST',
@@ -258,7 +258,7 @@ export class AuthenticationConnection implements Disposable {
258258
)
259259
: undefined;
260260

261-
const rsp = await this.connection.fetchGkDevApi('v1/login/auth-exchange', {
261+
const rsp = await this.connection.fetchGkApi('v1/login/auth-exchange', {
262262
method: 'POST',
263263
body: JSON.stringify({
264264
source: 'gitlens',

src/plus/gk/account/organizationService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class OrganizationService implements Disposable {
6161

6262
let rsp;
6363
try {
64-
rsp = await this.connection.fetchApi(
64+
rsp = await this.connection.fetchGkApi(
6565
'user/organizations-light',
6666
{
6767
method: 'GET',
@@ -152,7 +152,7 @@ export class OrganizationService implements Disposable {
152152
options?: { force?: boolean },
153153
): Promise<FullOrganization | undefined> {
154154
if (!this._fullOrganizations?.has(id) || options?.force === true) {
155-
const rsp = await this.connection.fetchApi(`organization/${id}`, { method: 'GET' });
155+
const rsp = await this.connection.fetchGkApi(`organization/${id}`, { method: 'GET' });
156156
if (!rsp.ok) {
157157
Logger.error(
158158
'',
@@ -213,7 +213,7 @@ export class OrganizationService implements Disposable {
213213
if (id == null) return undefined;
214214

215215
if (!this._organizationSettings?.has(id) || options?.force === true) {
216-
const rsp = await this.connection.fetchApi(
216+
const rsp = await this.connection.fetchGkApi(
217217
`v1/organizations/settings`,
218218
{ method: 'GET' },
219219
{ organizationId: id },

src/plus/gk/account/subscriptionService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ export class SubscriptionService implements Disposable {
654654
if (session == null) return;
655655

656656
try {
657-
const rsp = await this.connection.fetchApi('user/reactivate-trial', {
657+
const rsp = await this.connection.fetchGkApi('user/reactivate-trial', {
658658
method: 'POST',
659659
body: JSON.stringify({ client: 'gitlens' }),
660660
});
@@ -735,7 +735,7 @@ export class SubscriptionService implements Disposable {
735735
if (session == null) return false;
736736

737737
try {
738-
const rsp = await this.connection.fetchApi(
738+
const rsp = await this.connection.fetchGkApi(
739739
'resend-email',
740740
{
741741
method: 'POST',
@@ -1041,7 +1041,7 @@ export class SubscriptionService implements Disposable {
10411041
previewExpiresOn: this._subscription.previewTrial?.expiresOn,
10421042
};
10431043

1044-
const rsp = await this.connection.fetchApi(
1044+
const rsp = await this.connection.fetchGkApi(
10451045
'gitlens/checkin',
10461046
{
10471047
method: 'POST',

src/plus/gk/serverConnection.ts

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,7 @@ export class ServerConnection implements Disposable {
4646
dispose() {}
4747

4848
@memoize()
49-
private get baseApiUri(): Uri {
50-
if (this.container.env === 'staging') {
51-
return Uri.parse('https://stagingapi.gitkraken.com');
52-
}
53-
54-
if (this.container.env === 'dev') {
55-
return Uri.parse('https://devapi.gitkraken.com');
56-
}
57-
58-
return Uri.parse('https://api.gitkraken.com');
59-
}
60-
61-
getApiUrl(...pathSegments: string[]) {
62-
return Uri.joinPath(this.baseApiUri, ...pathSegments).toString();
63-
}
64-
65-
@memoize()
66-
private get baseGkDevApiUri(): Uri {
49+
private get baseGkApiUri(): Uri {
6750
if (this.container.env === 'staging') {
6851
return Uri.parse('https://staging-api.gitkraken.dev');
6952
}
@@ -75,8 +58,8 @@ export class ServerConnection implements Disposable {
7558
return Uri.parse('https://api.gitkraken.dev');
7659
}
7760

78-
getGkDevApiUrl(...pathSegments: string[]) {
79-
return Uri.joinPath(this.baseGkDevApiUri, ...pathSegments).toString();
61+
getGkApiUrl(...pathSegments: string[]) {
62+
return Uri.joinPath(this.baseGkApiUri, ...pathSegments).toString();
8063
}
8164

8265
@memoize()
@@ -133,12 +116,12 @@ export class ServerConnection implements Disposable {
133116
}
134117
}
135118

136-
async fetchApi(path: string, init?: RequestInit, options?: GKFetchOptions): Promise<Response> {
137-
return this.gkFetch(this.getApiUrl(path), init, options);
119+
async fetchGkApi(path: string, init?: RequestInit, options?: GKFetchOptions): Promise<Response> {
120+
return this.gkFetch(this.getGkApiUrl(path), init, options);
138121
}
139122

140-
async fetchApiGraphQL(path: string, request: GraphQLRequest, init?: RequestInit, options?: GKFetchOptions) {
141-
return this.fetchApi(
123+
async fetchGkApiGraphQL(path: string, request: GraphQLRequest, init?: RequestInit, options?: GKFetchOptions) {
124+
return this.fetchGkApi(
142125
path,
143126
{
144127
method: 'POST',
@@ -149,10 +132,6 @@ export class ServerConnection implements Disposable {
149132
);
150133
}
151134

152-
async fetchGkDevApi(path: string, init?: RequestInit, options?: GKFetchOptions): Promise<Response> {
153-
return this.gkFetch(this.getGkDevApiUrl(path), init, options);
154-
}
155-
156135
private async gkFetch(url: RequestInfo, init?: RequestInit, options?: GKFetchOptions): Promise<Response> {
157136
if (this.requestsAreBlocked) {
158137
throw new RequestsAreBlockedTemporarilyError();

src/plus/integrations/authentication/cloudIntegrationService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class CloudIntegrationService {
1515
async getConnections(): Promise<CloudIntegrationConnection[] | undefined> {
1616
const scope = getLogScope();
1717

18-
const providersRsp = await this.connection.fetchGkDevApi(
18+
const providersRsp = await this.connection.fetchGkApi(
1919
'v1/provider-tokens',
2020
{ method: 'GET' },
2121
{ organizationId: false },
@@ -59,7 +59,7 @@ export class CloudIntegrationService {
5959
}
6060
: { method: 'GET' };
6161

62-
const tokenRsp = await this.connection.fetchGkDevApi(
62+
const tokenRsp = await this.connection.fetchGkApi(
6363
`v1/provider-tokens/${cloudIntegrationType}${refresh ? '/refresh' : ''}`,
6464
reqInitOptions,
6565
{ organizationId: false },
@@ -100,7 +100,7 @@ export class CloudIntegrationService {
100100
return false;
101101
}
102102

103-
const tokenRsp = await this.connection.fetchGkDevApi(
103+
const tokenRsp = await this.connection.fetchGkApi(
104104
`v1/provider-tokens/${cloudIntegrationType}`,
105105
{ method: 'DELETE' },
106106
{ organizationId: false },

src/plus/launchpad/enrichmentService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class EnrichmentService implements Disposable {
6666
const scope = getLogScope();
6767

6868
try {
69-
const rsp = await this.connection.fetchGkDevApi(`v1/enrich-items/${id}`, { method: 'DELETE' });
69+
const rsp = await this.connection.fetchGkApi(`v1/enrich-items/${id}`, { method: 'DELETE' });
7070

7171
if (!rsp.ok) throw new Error(`Unable to ${context} item '${id}': (${rsp.status}) ${rsp.statusText}`);
7272
} catch (ex) {
@@ -83,7 +83,7 @@ export class EnrichmentService implements Disposable {
8383
try {
8484
type Result = { data: EnrichedItemResponse[] };
8585

86-
const rsp = await this.connection.fetchGkDevApi('v1/enrich-items', { method: 'GET' });
86+
const rsp = await this.connection.fetchGkApi('v1/enrich-items', { method: 'GET' });
8787
if (cancellation?.isCancellationRequested) throw new CancellationError();
8888

8989
const result = (await rsp.json()) as Result;
@@ -132,7 +132,7 @@ export class EnrichmentService implements Disposable {
132132
entityUrl: item.url,
133133
};
134134

135-
const rsp = await this.connection.fetchGkDevApi('v1/enrich-items/pin', {
135+
const rsp = await this.connection.fetchGkApi('v1/enrich-items/pin', {
136136
method: 'POST',
137137
body: JSON.stringify(rq),
138138
});
@@ -183,7 +183,7 @@ export class EnrichmentService implements Disposable {
183183
rq.expiresAt = item.expiresAt;
184184
}
185185

186-
const rsp = await this.connection.fetchGkDevApi('v1/enrich-items/snooze', {
186+
const rsp = await this.connection.fetchGkApi('v1/enrich-items/snooze', {
187187
method: 'POST',
188188
body: JSON.stringify(rq),
189189
});

src/plus/workspaces/workspacesApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,6 @@ export class WorkspacesApi {
471471
}
472472

473473
private async fetch(request: GraphQLRequest, init?: RequestInit) {
474-
return this.connection.fetchApiGraphQL('api/projects/graphql', request, init);
474+
return this.connection.fetchGkApiGraphQL('api/projects/graphql', request, init);
475475
}
476476
}

src/webviews/home/homeWebview.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import type { StartWorkCommandArgs } from '../../plus/startWork/startWork';
4646
import type { ShowInCommitGraphCommandArgs } from '../../plus/webviews/graph/protocol';
4747
import type { Change } from '../../plus/webviews/patchDetails/protocol';
4848
import { showRepositoryPicker } from '../../quickpicks/repositoryPicker';
49+
import { debug } from '../../system/decorators/log';
4950
import type { Deferrable } from '../../system/function';
5051
import { debounce } from '../../system/function';
5152
import { filterMap } from '../../system/iterable';
@@ -742,7 +743,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
742743

743744
private subscribeToRepository(repo: Repository): Disposable {
744745
return Disposable.from(
745-
// TODO: advanced confiugration for the watchFileSystem timing
746+
// TODO: advanced configuration for the watchFileSystem timing
746747
repo.watchFileSystem(1000),
747748
repo.onDidChangeFileSystem(() => this.onOverviewRepoChanged('wip')),
748749
repo.onDidChange(e => {
@@ -764,6 +765,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
764765
);
765766
}
766767

768+
@debug()
767769
private onOverviewRepoChanged(scope: 'repo' | 'wip') {
768770
if (this._invalidateOverview !== 'repo') {
769771
this._invalidateOverview = scope;

0 commit comments

Comments
 (0)