@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.
Files changed (85) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/dist/git/errors.d.ts +1 -0
  3. package/dist/git/errors.js +7 -1
  4. package/dist/git/errors.js.map +1 -1
  5. package/dist/git-cli/providers/config.js +2 -2
  6. package/dist/git-cli/providers/pausedOperations.js +2 -2
  7. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  8. package/dist/git-cli/providers/staging.js +1 -1
  9. package/dist/ipc/discovery.js +1 -1
  10. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  11. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  12. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  13. package/dist/plus/git-github/api/aliasedQuery.d.ts +3 -2
  14. package/dist/plus/git-github/api/aliasedQuery.js +7 -3
  15. package/dist/plus/git-github/api/aliasedQuery.js.map +1 -1
  16. package/dist/plus/git-github/api/github.d.ts +5 -0
  17. package/dist/plus/git-github/api/github.js +100 -12
  18. package/dist/plus/git-github/api/github.js.map +1 -1
  19. package/dist/plus/git-github/api/issueWrites.d.ts +4 -1
  20. package/dist/plus/git-github/api/issueWrites.js +9 -4
  21. package/dist/plus/git-github/api/issueWrites.js.map +1 -1
  22. package/dist/plus/integrations/collectionMetadata.js +2 -1
  23. package/dist/plus/integrations/collectionMetadata.js.map +1 -1
  24. package/dist/plus/integrations/context.d.ts +3 -3
  25. package/dist/plus/integrations/errors.d.ts +4 -0
  26. package/dist/plus/integrations/errors.js +8 -1
  27. package/dist/plus/integrations/errors.js.map +1 -1
  28. package/dist/plus/integrations/index.d.ts +2 -1
  29. package/dist/plus/integrations/index.js.map +1 -1
  30. package/dist/plus/integrations/integrationService.d.ts +16 -0
  31. package/dist/plus/integrations/integrationService.js +6 -1
  32. package/dist/plus/integrations/integrationService.js.map +1 -1
  33. package/dist/plus/integrations/lite.js +11 -1
  34. package/dist/plus/integrations/lite.js.map +1 -1
  35. package/dist/plus/integrations/manager.d.ts +87 -2
  36. package/dist/plus/integrations/models/gitHostIntegration.d.ts +21 -2
  37. package/dist/plus/integrations/models/gitHostIntegration.js +182 -14
  38. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  39. package/dist/plus/integrations/models/integration.d.ts +9 -1
  40. package/dist/plus/integrations/models/integration.js +43 -3
  41. package/dist/plus/integrations/models/integration.js.map +1 -1
  42. package/dist/plus/integrations/providers/apiClients.d.ts +1 -0
  43. package/dist/plus/integrations/providers/apiClients.js +3 -0
  44. package/dist/plus/integrations/providers/apiClients.js.map +1 -1
  45. package/dist/plus/integrations/providers/azure/azure.d.ts +3 -0
  46. package/dist/plus/integrations/providers/azure/azure.js +110 -19
  47. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  48. package/dist/plus/integrations/providers/azureDevOps.d.ts +12 -0
  49. package/dist/plus/integrations/providers/azureDevOps.js +22 -0
  50. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  51. package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +21 -2
  52. package/dist/plus/integrations/providers/bitbucket/bitbucket.js +59 -19
  53. package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
  54. package/dist/plus/integrations/providers/bitbucket-server.d.ts +2 -0
  55. package/dist/plus/integrations/providers/bitbucket-server.js +11 -3
  56. package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
  57. package/dist/plus/integrations/providers/bitbucket.d.ts +14 -0
  58. package/dist/plus/integrations/providers/bitbucket.js +30 -2
  59. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  60. package/dist/plus/integrations/providers/github.d.ts +7 -0
  61. package/dist/plus/integrations/providers/github.js +12 -1
  62. package/dist/plus/integrations/providers/github.js.map +1 -1
  63. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +19 -1
  64. package/dist/plus/integrations/providers/gitlab/gitlab.js +116 -17
  65. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  66. package/dist/plus/integrations/providers/gitlab.d.ts +15 -2
  67. package/dist/plus/integrations/providers/gitlab.js +34 -4
  68. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  69. package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
  70. package/dist/plus/integrations/providers/providerErrors.d.ts +8 -0
  71. package/dist/plus/integrations/providers/providerErrors.js +15 -2
  72. package/dist/plus/integrations/providers/providerErrors.js.map +1 -1
  73. package/dist/plus/integrations/reads/drains.d.ts +1 -0
  74. package/dist/plus/integrations/reads/pullRequestsForCommits.d.ts +45 -0
  75. package/dist/plus/integrations/reads/pullRequestsForCommits.js +97 -0
  76. package/dist/plus/integrations/reads/pullRequestsForCommits.js.map +1 -0
  77. package/dist/plus/integrations/utils/domain.utils.d.ts +1 -0
  78. package/dist/plus/integrations/utils/domain.utils.js +5 -1
  79. package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
  80. package/dist/plus/integrations/utils/failureBackoff.d.ts +13 -0
  81. package/dist/plus/integrations/utils/failureBackoff.js +47 -0
  82. package/dist/plus/integrations/utils/failureBackoff.js.map +1 -0
  83. package/dist/utils/env/node/exec.js +2 -2
  84. package/docs/integrations.md +90 -6
  85. package/package.json +1 -1
@@ -135,6 +135,11 @@ export declare class GitHubApi {
135
135
  */
136
136
  mergeQueue?: boolean;
137
137
  }, cancellation?: AbortSignal): Promise<PullRequest | undefined>;
138
+ getPullRequestsForCommits(provider: Provider, token: GitHubTokenInfo, owner: string, repo: string, shas: readonly string[], options?: {
139
+ baseUrl?: string;
140
+ avatarSize?: number;
141
+ mergeQueue?: boolean;
142
+ }, cancellation?: AbortSignal): Promise<PromiseSettledResult<PullRequest | undefined>[]>;
138
143
  getRepositoryMetadata(provider: Provider, token: GitHubTokenInfo, owner: string, repo: string, options?: {
139
144
  baseUrl?: string;
140
145
  }, cancellation?: AbortSignal): Promise<RepositoryMetadata | undefined>;
@@ -465,6 +465,23 @@ reactions(content: THUMBS_UP) {
465
465
  function isByteStream(value) {
466
466
  return typeof value === "object" && value != null && "getReader" in value && typeof value.getReader === "function";
467
467
  }
468
+ function gqlCommitAssociatedPullRequests(options, config) {
469
+ return `associatedPullRequests(first: 2, orderBy: {field: UPDATED_AT, direction: DESC}) {
470
+ nodes {
471
+ ${gqlPullRequestLiteFragment}
472
+ ${gqlPullRequestStackFragmentFor(options)}
473
+ ${gqlPullRequestMergeQueueFragmentFor(options, config)}
474
+ }
475
+ }`;
476
+ }
477
+ function selectCommitPullRequest(nodes, owner) {
478
+ const ownerKey = owner.toLowerCase();
479
+ const isOwners = (pr) => pr.repository.owner.login.toLowerCase() === ownerKey;
480
+ const prs = nodes?.filter((pr) => pr != null && (!pr.repository.isFork || isOwners(pr)));
481
+ if (prs == null || prs.length === 0) return void 0;
482
+ if (prs.length > 1) prs.sort((a, b) => (isOwners(a) ? -1 : 1) - (isOwners(b) ? -1 : 1) || (a.state === "MERGED" ? -1 : 1) - (b.state === "MERGED" ? -1 : 1) || new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime());
483
+ return prs[0];
484
+ }
468
485
  var GitHubApi = class {
469
486
  config;
470
487
  _onDidReauthenticate = new Emitter();
@@ -807,31 +824,98 @@ var GitHubApi = class {
807
824
  repository(name: $repo, owner: $owner) {
808
825
  object(oid: $rev) {
809
826
  ... on Commit {
810
- associatedPullRequests(first: 2, orderBy: {field: UPDATED_AT, direction: DESC}) {
811
- nodes {
812
- ${gqlPullRequestLiteFragment}
813
- ${gqlPullRequestStackFragmentFor(options)}
814
- ${gqlPullRequestMergeQueueFragmentFor(options, this.config)}
815
- }
816
- }
827
+ ${gqlCommitAssociatedPullRequests(options, this.config)}
817
828
  }
818
829
  }
819
830
  }
820
831
  }`;
821
- const prs = (await this.graphql(provider, token, query, {
832
+ const pr = selectCommitPullRequest((await this.graphql(provider, token, query, {
822
833
  ...options,
823
834
  owner,
824
835
  repo,
825
836
  rev
826
- }, scope, cancellation))?.repository?.object?.associatedPullRequests?.nodes?.filter((pr) => pr != null && (!pr.repository.isFork || pr.repository.owner.login === owner));
827
- if (prs == null || prs.length === 0) return void 0;
828
- if (prs.length > 1) prs.sort((a, b) => (a.repository.owner.login === owner ? -1 : 1) - (b.repository.owner.login === owner ? -1 : 1) || (a.state === "MERGED" ? -1 : 1) - (b.state === "MERGED" ? -1 : 1) || new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime());
829
- return fromGitHubPullRequestLite(prs[0], provider, "point");
837
+ }, scope, cancellation))?.repository?.object?.associatedPullRequests?.nodes, owner);
838
+ return pr != null ? fromGitHubPullRequestLite(pr, provider, "point") : void 0;
830
839
  } catch (ex) {
831
840
  if (ex instanceof RequestNotFoundError) return void 0;
832
841
  throw this.handleException(ex, provider, scope);
833
842
  }
834
843
  }
844
+ async getPullRequestsForCommits(provider, token, owner, repo, shas, options, cancellation) {
845
+ const scope = getScopedLogger();
846
+ const slots = shas.map(() => ({
847
+ status: "fulfilled",
848
+ value: void 0
849
+ }));
850
+ if (shas.length === 0) return slots;
851
+ const asked = shas.map((sha, index) => ({
852
+ sha,
853
+ index
854
+ }));
855
+ const query = `query getPullRequestsForCommits(
856
+ $owner: String!
857
+ $repo: String!
858
+ ${asked.map((_, i) => `$sha${i}: GitObjectID!`).join("\n ")}
859
+ $avatarSize: Int
860
+ ) {
861
+ repository(name: $repo, owner: $owner) {
862
+ ${asked.map((_, i) => `c${i}: object(oid: $sha${i}) {
863
+ ... on Commit {
864
+ ${gqlCommitAssociatedPullRequests(options, this.config)}
865
+ }
866
+ }`).join("\n ")}
867
+ }
868
+ }`;
869
+ const variables = {
870
+ baseUrl: options?.baseUrl,
871
+ avatarSize: options?.avatarSize,
872
+ owner,
873
+ repo
874
+ };
875
+ asked.forEach((a, i) => {
876
+ variables[`sha${i}`] = a.sha;
877
+ });
878
+ try {
879
+ const rsp = await this.graphql(provider, token, query, variables, scope, cancellation, "aliased");
880
+ if (rsp?.data == null) throw new Error("GitHub returned no data for the pull requests by commit");
881
+ const repository = rsp.data.repository;
882
+ if (repository == null) {
883
+ const forbidden = rsp.errors.find((e) => e.path?.[0] === "repository" && e.type === "FORBIDDEN");
884
+ if (forbidden != null) {
885
+ const { accessToken: _accessToken, ...tokenInfo } = token;
886
+ throw new AuthenticationError(tokenInfo, 3, new Error(forbidden.message));
887
+ }
888
+ const verdict = getAliasErrorVerdict(rsp.errors, "repository", repository);
889
+ if (verdict != null && verdict !== "absent") for (const a of asked) slots[a.index] = verdict;
890
+ return slots;
891
+ }
892
+ asked.forEach((a, i) => {
893
+ const alias = `c${i}`;
894
+ const node = repository[alias];
895
+ const verdict = getAliasErrorVerdict(rsp.errors, alias, node, "repository");
896
+ if (verdict != null && verdict !== "absent") {
897
+ slots[a.index] = verdict;
898
+ return;
899
+ }
900
+ try {
901
+ const pr = selectCommitPullRequest(node?.associatedPullRequests?.nodes, owner);
902
+ slots[a.index] = {
903
+ status: "fulfilled",
904
+ value: pr != null ? fromGitHubPullRequestLite(pr, provider, "point") : void 0
905
+ };
906
+ } catch (ex) {
907
+ scope?.warn(`failed to map pull request; ${owner}/${repo}@${a.sha}, ex=${ex}`);
908
+ slots[a.index] = {
909
+ status: "rejected",
910
+ reason: ex
911
+ };
912
+ }
913
+ });
914
+ return slots;
915
+ } catch (ex) {
916
+ throw this.handleException(ex, provider, scope, true);
917
+ }
918
+ }
835
919
  async getRepositoryMetadata(provider, token, owner, repo, options, cancellation) {
836
920
  const scope = getScopedLogger();
837
921
  try {
@@ -3736,6 +3820,10 @@ __decorate([trace({ args: (provider, token, owner, repo, rev) => ({
3736
3820
  repo,
3737
3821
  rev
3738
3822
  }) })], GitHubApi.prototype, "getPullRequestForCommit", null);
3823
+ __decorate([trace({ args: (provider, token) => ({
3824
+ provider: provider.name,
3825
+ token: `<token:${token.microHash}>`
3826
+ }) })], GitHubApi.prototype, "getPullRequestsForCommits", null);
3739
3827
  __decorate([trace({ args: (provider, token, owner, repo) => ({
3740
3828
  provider: provider.name,
3741
3829
  token: `<token:${token.microHash}>`,