@gitkraken/core-gitlens 0.43.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -1
- package/dist/git/errors.d.ts +1 -0
- package/dist/git/errors.js +7 -1
- package/dist/git/errors.js.map +1 -1
- package/dist/git-cli/providers/config.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/staging.js +1 -1
- package/dist/ipc/discovery.js +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
- package/dist/plus/git-github/api/aliasedQuery.d.ts +3 -2
- package/dist/plus/git-github/api/aliasedQuery.js +7 -3
- package/dist/plus/git-github/api/aliasedQuery.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +5 -0
- package/dist/plus/git-github/api/github.js +100 -12
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/issueWrites.d.ts +4 -1
- package/dist/plus/git-github/api/issueWrites.js +9 -4
- package/dist/plus/git-github/api/issueWrites.js.map +1 -1
- package/dist/plus/integrations/collectionMetadata.js +2 -1
- package/dist/plus/integrations/collectionMetadata.js.map +1 -1
- package/dist/plus/integrations/context.d.ts +3 -3
- package/dist/plus/integrations/errors.d.ts +4 -0
- package/dist/plus/integrations/errors.js +8 -1
- package/dist/plus/integrations/errors.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +2 -1
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +16 -0
- package/dist/plus/integrations/integrationService.js +6 -1
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/lite.js +11 -1
- package/dist/plus/integrations/lite.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +87 -2
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +21 -2
- package/dist/plus/integrations/models/gitHostIntegration.js +182 -14
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +9 -1
- package/dist/plus/integrations/models/integration.js +43 -3
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/apiClients.d.ts +1 -0
- package/dist/plus/integrations/providers/apiClients.js +3 -0
- package/dist/plus/integrations/providers/apiClients.js.map +1 -1
- package/dist/plus/integrations/providers/azure/azure.d.ts +3 -0
- package/dist/plus/integrations/providers/azure/azure.js +110 -19
- package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOps.d.ts +12 -0
- package/dist/plus/integrations/providers/azureDevOps.js +22 -0
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +21 -2
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js +59 -19
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket-server.d.ts +2 -0
- package/dist/plus/integrations/providers/bitbucket-server.js +11 -3
- package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket.d.ts +14 -0
- package/dist/plus/integrations/providers/bitbucket.js +30 -2
- package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +7 -0
- package/dist/plus/integrations/providers/github.js +12 -1
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +19 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.js +116 -17
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab.d.ts +15 -2
- package/dist/plus/integrations/providers/gitlab.js +34 -4
- package/dist/plus/integrations/providers/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/providers/providerErrors.d.ts +8 -0
- package/dist/plus/integrations/providers/providerErrors.js +15 -2
- package/dist/plus/integrations/providers/providerErrors.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +1 -0
- package/dist/plus/integrations/reads/pullRequestsForCommits.d.ts +45 -0
- package/dist/plus/integrations/reads/pullRequestsForCommits.js +97 -0
- package/dist/plus/integrations/reads/pullRequestsForCommits.js.map +1 -0
- package/dist/plus/integrations/utils/domain.utils.d.ts +1 -0
- package/dist/plus/integrations/utils/domain.utils.js +5 -1
- package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
- package/dist/plus/integrations/utils/failureBackoff.d.ts +13 -0
- package/dist/plus/integrations/utils/failureBackoff.js +47 -0
- package/dist/plus/integrations/utils/failureBackoff.js.map +1 -0
- package/dist/utils/env/node/exec.js +2 -2
- package/docs/integrations.md +90 -6
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CancellationError, isCancellationError } from "../../../../utils/cancellation.js";
|
|
1
|
+
import { AbortAggregate, CancellationError, isCancellationError, raceWithSignal } from "../../../../utils/cancellation.js";
|
|
2
2
|
import { equalsIgnoreCase } from "../../../../utils/string.js";
|
|
3
3
|
import { Logger as _logger } from "../../../../utils/logger.js";
|
|
4
4
|
import { getScopedLogger } from "../../../../utils/logger.scoped.js";
|
|
@@ -6,12 +6,14 @@ import { mapSettledBounded } from "../../../../utils/promise.js";
|
|
|
6
6
|
import { trace } from "../../../../utils/decorators/log.js";
|
|
7
7
|
import { joinUriPath, parseUri } from "../../../../utils/uri.js";
|
|
8
8
|
import __decorate from "../../../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
|
|
9
|
-
import { AuthenticationError, RequestClientError, RequestNotFoundError, reportRequestFailure } from "../../../../git/errors.js";
|
|
9
|
+
import { AuthenticationError, RequestClientError, RequestNotFoundError, RequestRateLimitError, reportRequestFailure, takeDeferredRequestFailure } from "../../../../git/errors.js";
|
|
10
10
|
import { maybeStopWatch } from "../../../../utils/stopwatch.js";
|
|
11
11
|
import { PullRequest } from "../../../../git/models/pullRequest.js";
|
|
12
|
-
import { ProviderFetchError, isRateLimitResponse, toRateLimitError } from "../../errors.js";
|
|
12
|
+
import { LookupBackedOffError, ProviderFetchError, isRateLimitResponse, toRateLimitError } from "../../errors.js";
|
|
13
13
|
import "../../constants.js";
|
|
14
|
+
import { isNotFoundResponse } from "../providerErrors.js";
|
|
14
15
|
import { selectBranchPullRequests } from "../utils/providerPaging.js";
|
|
16
|
+
import { FailureBackoff } from "../../utils/failureBackoff.js";
|
|
15
17
|
import { baseProviderApiConfig } from "../apiConfig.js";
|
|
16
18
|
import { selectGitLabUserForCommit } from "./gitlab.utils.js";
|
|
17
19
|
import { fromGitLabMergeRequest, fromGitLabMergeRequestREST, fromGitLabMergeRequestState, getRepoName, getRepoNamespace, toGitLabMergeRequestState } from "./models.js";
|
|
@@ -42,10 +44,17 @@ function interleaveByRank(lists, limit) {
|
|
|
42
44
|
}
|
|
43
45
|
return merged;
|
|
44
46
|
}
|
|
47
|
+
function isRefusedProjectLookup(ex) {
|
|
48
|
+
return ex instanceof AuthenticationError && ex.reason !== 3;
|
|
49
|
+
}
|
|
45
50
|
var GitLabApi = class {
|
|
46
51
|
config;
|
|
47
52
|
_disposable;
|
|
48
53
|
_projectIds = /* @__PURE__ */ new Map();
|
|
54
|
+
_projectLookupCallers = /* @__PURE__ */ new WeakMap();
|
|
55
|
+
_projectLookupAborts = /* @__PURE__ */ new WeakMap();
|
|
56
|
+
_projectLookupBackoffs = /* @__PURE__ */ new WeakMap();
|
|
57
|
+
_reauthenticationPrompted = /* @__PURE__ */ new Set();
|
|
49
58
|
constructor(config) {
|
|
50
59
|
this.config = config;
|
|
51
60
|
this._disposable = config.onConfigChanged?.(() => this.resetCaches());
|
|
@@ -53,8 +62,24 @@ var GitLabApi = class {
|
|
|
53
62
|
dispose() {
|
|
54
63
|
this._disposable?.dispose();
|
|
55
64
|
}
|
|
65
|
+
clearProjectLookupBackoff(provider) {
|
|
66
|
+
this._projectLookupBackoffs.delete(provider);
|
|
67
|
+
}
|
|
56
68
|
resetCaches() {
|
|
57
69
|
this._projectIds.clear();
|
|
70
|
+
this._projectLookupBackoffs = /* @__PURE__ */ new WeakMap();
|
|
71
|
+
this._reauthenticationPrompted.clear();
|
|
72
|
+
}
|
|
73
|
+
getProjectLookupBackoffs(provider) {
|
|
74
|
+
let backoffs = this._projectLookupBackoffs.get(provider);
|
|
75
|
+
if (backoffs == null) {
|
|
76
|
+
backoffs = {
|
|
77
|
+
failed: new FailureBackoff(),
|
|
78
|
+
refused: new FailureBackoff()
|
|
79
|
+
};
|
|
80
|
+
this._projectLookupBackoffs.set(provider, backoffs);
|
|
81
|
+
}
|
|
82
|
+
return backoffs;
|
|
58
83
|
}
|
|
59
84
|
async getAccountForCommit(provider, token, owner, repo, rev, options, cancellation) {
|
|
60
85
|
const scope = getScopedLogger();
|
|
@@ -318,10 +343,14 @@ var GitLabApi = class {
|
|
|
318
343
|
}
|
|
319
344
|
async getPullRequestForCommit(provider, token, owner, repo, rev, options, cancellation) {
|
|
320
345
|
const scope = getScopedLogger();
|
|
321
|
-
const projectId = await this.getProjectId(provider, token, owner, repo, options?.baseUrl, cancellation
|
|
346
|
+
const projectId = await this.getProjectId(provider, token, owner, repo, options?.baseUrl, cancellation, {
|
|
347
|
+
strict: true,
|
|
348
|
+
backoff: options?.backoff ?? !options?.deferFailure,
|
|
349
|
+
deferFailure: options?.deferFailure
|
|
350
|
+
});
|
|
322
351
|
if (!projectId) return void 0;
|
|
323
352
|
try {
|
|
324
|
-
const mrs = await this.request(provider, token, options?.baseUrl, `v4/projects/${projectId}/repository/commits/${rev}/merge_requests`, { method: "GET" }, cancellation, scope);
|
|
353
|
+
const mrs = await this.request(provider, token, options?.baseUrl, `v4/projects/${projectId}/repository/commits/${rev}/merge_requests`, { method: "GET" }, cancellation, scope, options?.deferFailure);
|
|
325
354
|
if (mrs == null || mrs.length === 0) return void 0;
|
|
326
355
|
if (mrs.length > 1) mrs.sort((a, b) => (a.state === "opened" ? -1 : 1) - (b.state === "opened" ? -1 : 1) || new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime());
|
|
327
356
|
const fullPath = `${owner}/${repo}`;
|
|
@@ -330,6 +359,11 @@ var GitLabApi = class {
|
|
|
330
359
|
repo: getRepoName(fullPath)
|
|
331
360
|
}, "point");
|
|
332
361
|
} catch (ex) {
|
|
362
|
+
if (options?.deferFailure) {
|
|
363
|
+
if (isNotFoundResponse(ex)) return void 0;
|
|
364
|
+
scope?.error(ex);
|
|
365
|
+
throw ex;
|
|
366
|
+
}
|
|
333
367
|
if (ex instanceof RequestNotFoundError) return void 0;
|
|
334
368
|
throw this.handleException(ex, provider, scope);
|
|
335
369
|
}
|
|
@@ -571,7 +605,12 @@ var GitLabApi = class {
|
|
|
571
605
|
}
|
|
572
606
|
async getRepositoryMetadata(provider, token, owner, repo, options, cancellation) {
|
|
573
607
|
const scope = getScopedLogger();
|
|
574
|
-
const projectId = await this.getProjectId(provider, token, owner, repo, options?.baseUrl, cancellation
|
|
608
|
+
const projectId = await this.getProjectId(provider, token, owner, repo, options?.baseUrl, cancellation, {
|
|
609
|
+
strict: true,
|
|
610
|
+
backoff: options?.backoff
|
|
611
|
+
}).catch((ex) => {
|
|
612
|
+
throw ex instanceof RequestNotFoundError ? ex.original : ex;
|
|
613
|
+
});
|
|
575
614
|
if (!projectId) return void 0;
|
|
576
615
|
try {
|
|
577
616
|
const proj = await this.request(provider, token, options?.baseUrl, `v4/projects/${projectId}`, { method: "GET" }, cancellation, scope);
|
|
@@ -735,17 +774,65 @@ $search: String!
|
|
|
735
774
|
return [];
|
|
736
775
|
}
|
|
737
776
|
}
|
|
738
|
-
getProjectId(provider, token, group, repo, baseUrl, cancellation) {
|
|
777
|
+
getProjectId(provider, token, group, repo, baseUrl, cancellation, options) {
|
|
739
778
|
const { accessToken } = token;
|
|
740
779
|
const key = `${accessToken}|${group}/${repo}`;
|
|
780
|
+
const backoff = options?.backoff ?? true;
|
|
781
|
+
const strict = options?.strict ?? false;
|
|
782
|
+
const reportFailure = !options?.deferFailure;
|
|
783
|
+
if (cancellation?.aborted) return strict ? Promise.reject(new CancellationError()) : Promise.resolve(void 0);
|
|
741
784
|
let projectId = this._projectIds.get(key);
|
|
785
|
+
if (projectId != null && this._projectLookupAborts.get(projectId)?.signal.aborted) projectId = void 0;
|
|
786
|
+
if (projectId == null && backoff) {
|
|
787
|
+
const backoffs = this.getProjectLookupBackoffs(provider);
|
|
788
|
+
const now = Date.now();
|
|
789
|
+
const until = backoffs.failed.backedOffUntil(key, now) ?? (strict ? void 0 : backoffs.refused.backedOffUntil(key, now));
|
|
790
|
+
if (until != null) {
|
|
791
|
+
if (!strict) return Promise.resolve(void 0);
|
|
792
|
+
return Promise.reject(new LookupBackedOffError(until, `The GitLab project lookup of ${group}/${repo}`));
|
|
793
|
+
}
|
|
794
|
+
}
|
|
742
795
|
if (projectId == null) {
|
|
743
|
-
|
|
744
|
-
|
|
796
|
+
const callers = {
|
|
797
|
+
backoff,
|
|
798
|
+
reportFailure
|
|
799
|
+
};
|
|
800
|
+
const aborts = new AbortAggregate();
|
|
801
|
+
const lookup = this.getProjectIdCore(provider, token, group, repo, baseUrl, callers, aborts.signal);
|
|
802
|
+
this._projectIds.set(key, lookup);
|
|
803
|
+
this._projectLookupCallers.set(lookup, callers);
|
|
804
|
+
this._projectLookupAborts.set(lookup, aborts);
|
|
805
|
+
const settle = () => {
|
|
806
|
+
aborts.dispose();
|
|
807
|
+
this._projectLookupAborts.delete(lookup);
|
|
808
|
+
};
|
|
809
|
+
lookup.then(() => {
|
|
810
|
+
settle();
|
|
811
|
+
const backoffs = this._projectLookupBackoffs.get(provider);
|
|
812
|
+
backoffs?.failed.clear(key);
|
|
813
|
+
backoffs?.refused.clear(key);
|
|
814
|
+
}, (ex) => {
|
|
815
|
+
settle();
|
|
816
|
+
if (this._projectIds.get(key) === lookup) this._projectIds.delete(key);
|
|
817
|
+
if (callers.backoff && (!isCancellationError(ex) || ex.reason === "timeout")) {
|
|
818
|
+
const backoffs = this.getProjectLookupBackoffs(provider);
|
|
819
|
+
(isRefusedProjectLookup(ex) ? backoffs.refused : backoffs.failed).fail(key, Date.now(), ex instanceof RequestRateLimitError && ex.resetAt != null ? ex.resetAt * 1e3 : void 0);
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
projectId = lookup;
|
|
823
|
+
} else {
|
|
824
|
+
const callers = this._projectLookupCallers.get(projectId);
|
|
825
|
+
if (callers != null) {
|
|
826
|
+
callers.backoff ||= backoff;
|
|
827
|
+
callers.reportFailure ||= reportFailure;
|
|
828
|
+
}
|
|
745
829
|
}
|
|
746
|
-
|
|
830
|
+
const lookup = projectId;
|
|
831
|
+
this._projectLookupAborts.get(lookup)?.add(cancellation);
|
|
832
|
+
const awaited = cancellation != null ? raceWithSignal(lookup, cancellation) : lookup;
|
|
833
|
+
return strict ? awaited : awaited.catch(() => void 0);
|
|
747
834
|
}
|
|
748
|
-
async getProjectIdCore(provider, token, group, repo, baseUrl, cancellation) {
|
|
835
|
+
async getProjectIdCore(provider, token, group, repo, baseUrl, callers, cancellation) {
|
|
749
836
|
const scope = getScopedLogger();
|
|
750
837
|
try {
|
|
751
838
|
const gid = (await this.graphql(provider, token, baseUrl, `query getProjectId(
|
|
@@ -754,7 +841,7 @@ $search: String!
|
|
|
754
841
|
project(fullPath: $fullPath) {
|
|
755
842
|
id
|
|
756
843
|
}
|
|
757
|
-
}`, { fullPath: `${group}/${repo}` }, cancellation, scope))?.data?.project?.id;
|
|
844
|
+
}`, { fullPath: `${group}/${repo}` }, cancellation, scope, true))?.data?.project?.id;
|
|
758
845
|
if (gid == null) return void 0;
|
|
759
846
|
const match = /gid:\/\/gitlab\/Project\/([0-9]+)\b/.exec(gid);
|
|
760
847
|
if (match == null) return void 0;
|
|
@@ -762,9 +849,21 @@ $search: String!
|
|
|
762
849
|
scope?.addExitInfo(`projectId=${projectId}`);
|
|
763
850
|
return projectId;
|
|
764
851
|
} catch (ex) {
|
|
765
|
-
if (ex
|
|
766
|
-
|
|
767
|
-
|
|
852
|
+
if (isCancellationError(ex) && ex.reason !== "timeout") throw ex;
|
|
853
|
+
if (ex instanceof AuthenticationError) {
|
|
854
|
+
if (!callers.reportFailure || this._reauthenticationPrompted.has(token.accessToken)) {
|
|
855
|
+
scope?.error(ex);
|
|
856
|
+
throw ex;
|
|
857
|
+
}
|
|
858
|
+
this._reauthenticationPrompted.add(token.accessToken);
|
|
859
|
+
} else if (callers.reportFailure) {
|
|
860
|
+
const notify = takeDeferredRequestFailure(ex);
|
|
861
|
+
if (notify != null) {
|
|
862
|
+
provider.trackRequestException({ connectionId: token.connectionId });
|
|
863
|
+
notify();
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
throw this.handleException(ex, provider, scope);
|
|
768
867
|
}
|
|
769
868
|
}
|
|
770
869
|
async graphql(provider, token, baseUrl, query, variables, cancellation, scope, deferFailure) {
|
|
@@ -803,7 +902,7 @@ $search: String!
|
|
|
803
902
|
throw ex;
|
|
804
903
|
}
|
|
805
904
|
}
|
|
806
|
-
async request(provider, token, baseUrl, route, options, cancellation, scope) {
|
|
905
|
+
async request(provider, token, baseUrl, route, options, cancellation, scope, deferFailure) {
|
|
807
906
|
const { accessToken } = token;
|
|
808
907
|
const url = `${baseUrl ?? "https://gitlab.com/api"}/${route}`;
|
|
809
908
|
let rsp;
|
|
@@ -826,7 +925,7 @@ $search: String!
|
|
|
826
925
|
sw?.stop();
|
|
827
926
|
}
|
|
828
927
|
} catch (ex) {
|
|
829
|
-
if (ex instanceof ProviderFetchError || ex.name === "AbortError") this.handleRequestError(provider, token, ex, scope,
|
|
928
|
+
if (ex instanceof ProviderFetchError || ex.name === "AbortError") this.handleRequestError(provider, token, ex, scope, deferFailure);
|
|
830
929
|
else if (_logger.isDebugging) this.config.onError?.(`GitLab request failed: ${ex.message}`);
|
|
831
930
|
throw ex;
|
|
832
931
|
}
|