@gitkraken/core-gitlens 0.41.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 (106) hide show
  1. package/CHANGELOG.md +34 -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/models/issue.d.ts +2 -0
  6. package/dist/git/models/issue.js.map +1 -1
  7. package/dist/git/models/issueOrPullRequest.d.ts +4 -0
  8. package/dist/git/models/pullRequest.d.ts +2 -0
  9. package/dist/git/models/pullRequest.js.map +1 -1
  10. package/dist/git-cli/providers/config.js +2 -2
  11. package/dist/git-cli/providers/pausedOperations.js +2 -2
  12. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  13. package/dist/git-cli/providers/staging.js +1 -1
  14. package/dist/ipc/discovery.js +1 -1
  15. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  16. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  17. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  18. package/dist/plus/git-github/api/aliasedQuery.d.ts +3 -2
  19. package/dist/plus/git-github/api/aliasedQuery.js +7 -3
  20. package/dist/plus/git-github/api/aliasedQuery.js.map +1 -1
  21. package/dist/plus/git-github/api/github.d.ts +7 -4
  22. package/dist/plus/git-github/api/github.js +112 -14
  23. package/dist/plus/git-github/api/github.js.map +1 -1
  24. package/dist/plus/git-github/api/issueWrites.d.ts +5 -1
  25. package/dist/plus/git-github/api/issueWrites.js +15 -5
  26. package/dist/plus/git-github/api/issueWrites.js.map +1 -1
  27. package/dist/plus/git-github/models.js +7 -3
  28. package/dist/plus/git-github/models.js.map +1 -1
  29. package/dist/plus/integrations/collectionMetadata.js +2 -1
  30. package/dist/plus/integrations/collectionMetadata.js.map +1 -1
  31. package/dist/plus/integrations/context.d.ts +3 -3
  32. package/dist/plus/integrations/errors.d.ts +4 -0
  33. package/dist/plus/integrations/errors.js +8 -1
  34. package/dist/plus/integrations/errors.js.map +1 -1
  35. package/dist/plus/integrations/index.d.ts +3 -2
  36. package/dist/plus/integrations/index.js.map +1 -1
  37. package/dist/plus/integrations/integrationService.d.ts +18 -1
  38. package/dist/plus/integrations/integrationService.js +19 -0
  39. package/dist/plus/integrations/integrationService.js.map +1 -1
  40. package/dist/plus/integrations/lite.js +11 -1
  41. package/dist/plus/integrations/lite.js.map +1 -1
  42. package/dist/plus/integrations/manager.d.ts +93 -0
  43. package/dist/plus/integrations/models/gitHostIntegration.d.ts +21 -2
  44. package/dist/plus/integrations/models/gitHostIntegration.js +182 -14
  45. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  46. package/dist/plus/integrations/models/integration.d.ts +9 -1
  47. package/dist/plus/integrations/models/integration.js +43 -3
  48. package/dist/plus/integrations/models/integration.js.map +1 -1
  49. package/dist/plus/integrations/providers/apiClients.d.ts +1 -0
  50. package/dist/plus/integrations/providers/apiClients.js +3 -0
  51. package/dist/plus/integrations/providers/apiClients.js.map +1 -1
  52. package/dist/plus/integrations/providers/azure/azure.d.ts +3 -0
  53. package/dist/plus/integrations/providers/azure/azure.js +130 -33
  54. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  55. package/dist/plus/integrations/providers/azure/models.js +7 -3
  56. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  57. package/dist/plus/integrations/providers/azureDevOps.d.ts +12 -0
  58. package/dist/plus/integrations/providers/azureDevOps.js +22 -0
  59. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  60. package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +21 -2
  61. package/dist/plus/integrations/providers/bitbucket/bitbucket.js +77 -32
  62. package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
  63. package/dist/plus/integrations/providers/bitbucket/models.js +5 -2
  64. package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
  65. package/dist/plus/integrations/providers/bitbucket-server/models.js +3 -1
  66. package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -1
  67. package/dist/plus/integrations/providers/bitbucket-server.d.ts +2 -0
  68. package/dist/plus/integrations/providers/bitbucket-server.js +11 -3
  69. package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
  70. package/dist/plus/integrations/providers/bitbucket.d.ts +14 -0
  71. package/dist/plus/integrations/providers/bitbucket.js +30 -2
  72. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  73. package/dist/plus/integrations/providers/github.d.ts +9 -4
  74. package/dist/plus/integrations/providers/github.js +12 -1
  75. package/dist/plus/integrations/providers/github.js.map +1 -1
  76. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +19 -1
  77. package/dist/plus/integrations/providers/gitlab/gitlab.js +128 -23
  78. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  79. package/dist/plus/integrations/providers/gitlab/models.js +5 -2
  80. package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
  81. package/dist/plus/integrations/providers/gitlab.d.ts +15 -2
  82. package/dist/plus/integrations/providers/gitlab.js +34 -4
  83. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  84. package/dist/plus/integrations/providers/jiraIssueByKey.js +3 -1
  85. package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
  86. package/dist/plus/integrations/providers/models.js +9 -4
  87. package/dist/plus/integrations/providers/models.js.map +1 -1
  88. package/dist/plus/integrations/providers/providerApiClient.js +10 -7
  89. package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
  90. package/dist/plus/integrations/providers/providerErrors.d.ts +8 -0
  91. package/dist/plus/integrations/providers/providerErrors.js +15 -2
  92. package/dist/plus/integrations/providers/providerErrors.js.map +1 -1
  93. package/dist/plus/integrations/providers/providersApi.js +3 -1
  94. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  95. package/dist/plus/integrations/reads/pullRequestsForCommits.d.ts +45 -0
  96. package/dist/plus/integrations/reads/pullRequestsForCommits.js +97 -0
  97. package/dist/plus/integrations/reads/pullRequestsForCommits.js.map +1 -0
  98. package/dist/plus/integrations/utils/domain.utils.d.ts +1 -0
  99. package/dist/plus/integrations/utils/domain.utils.js +5 -1
  100. package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
  101. package/dist/plus/integrations/utils/failureBackoff.d.ts +13 -0
  102. package/dist/plus/integrations/utils/failureBackoff.js +47 -0
  103. package/dist/plus/integrations/utils/failureBackoff.js.map +1 -0
  104. package/dist/utils/env/node/exec.js +2 -2
  105. package/docs/integrations.md +105 -15
  106. package/package.json +2 -2
@@ -35,7 +35,17 @@ function createTokenScopedGitHostIntegration(id, token, http) {
35
35
  }
36
36
  const baseUrl = resolveApiBaseUrl(id, rawDomain, host);
37
37
  const config = toProviderApiConfig(http, wrapForForcedInsecureSSL);
38
- const api = id === "gitlab" || id === "cloud-gitlab-self-hosted" ? new GitLabApi(config) : id === "bitbucket" ? new BitbucketApi(config) : new AzureDevOpsApi(config);
38
+ if (id === "gitlab" || id === "cloud-gitlab-self-hosted") {
39
+ const api = new GitLabApi(config);
40
+ return {
41
+ getRepositoryMetadata: (owner, repo, cancellation) => api.getRepositoryMetadata(provider, tokenInfo, owner, repo, {
42
+ baseUrl,
43
+ backoff: false
44
+ }, cancellation),
45
+ getDefaultBranch: (owner, repo, cancellation) => api.getDefaultBranch(provider, tokenInfo, owner, repo, { baseUrl }, cancellation)
46
+ };
47
+ }
48
+ const api = id === "bitbucket" ? new BitbucketApi(config) : new AzureDevOpsApi(config);
39
49
  return {
40
50
  getRepositoryMetadata: (owner, repo, cancellation) => api.getRepositoryMetadata(provider, tokenInfo, owner, repo, { baseUrl }, cancellation),
41
51
  getDefaultBranch: (owner, repo, cancellation) => api.getDefaultBranch(provider, tokenInfo, owner, repo, { baseUrl }, cancellation)
@@ -1 +1 @@
1
- {"version":3,"file":"lite.js","names":[],"sources":["../../../../plus/integrations/src/lite.ts"],"sourcesContent":["// A lightweight, token-scoped entry point for stateless single-shot provider reads.\n//\n// Unlike `createIntegrationManager`, this does NOT build an `IntegrationServiceContext`\n// (no storage/account/config/cache/repositories/hooks) and runs no session/OAuth lifecycle.\n// A consumer that already holds a provider access token (obtained by its own means, e.g.\n// the GitKraken account backend's `v1/provider-tokens/{provider}` endpoint) can call the\n// per-provider API client directly and get back the same DTOs the session-managed\n// `GitHostIntegration` returns.\n//\n// Provider notes:\n// - Azure DevOps encodes the repository as the composite string `\"{project}/_git/{repoName}\"`\n// in the `repo` argument (matching the descriptor `GitHostIntegration` uses); `owner` is the\n// organization. Pass `repo` in that shape for Azure.\n// - Bitbucket Cloud `getDefaultBranch`/`getRepositoryMetadata` depend on `mainbranch`/`parent`\n// fields the API may omit for some repos; they resolve to `undefined` when absent.\n// - Bitbucket Server (`bitbucket-server`) is not supported here — its reads use a different\n// REST surface that this token-scoped path doesn't wire up.\n\nimport type { GitHubApiConfig } from '@gitlens/git-github/api/config.js';\nimport { GitHubApi } from '@gitlens/git-github/api/github.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport { trimTrailingSlashes } from '@gitlens/utils/path.js';\nimport type { TokenWithInfo } from './authentication/models.js';\nimport { toTokenInfo } from './authentication/models.js';\nimport { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId } from './constants.js';\nimport type { ProviderApiConfig } from './providers/apiConfig.js';\nimport { AzureDevOpsApi } from './providers/azure/azure.js';\nimport { BitbucketApi } from './providers/bitbucket/bitbucket.js';\nimport { GitLabApi } from './providers/gitlab/gitlab.js';\nimport { providersMetadata } from './providers/models.js';\n\n/** The git-hosting integrations that expose a token-scoped read path here. */\nexport type TokenScopedGitHostId =\n\t| GitCloudHostIntegrationId.GitHub\n\t| GitCloudHostIntegrationId.GitLab\n\t| GitCloudHostIntegrationId.Bitbucket\n\t| GitCloudHostIntegrationId.AzureDevOps\n\t| GitSelfManagedHostIntegrationId.CloudGitHubEnterprise\n\t| GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted\n\t| GitSelfManagedHostIntegrationId.AzureDevOpsServer;\n\nexport interface TokenScopedGitHostToken {\n\t/** The provider access token the consumer already holds. */\n\treadonly accessToken: string;\n\t/**\n\t * Host domain for self-managed instances (e.g. `git.example.com`). Ignored for cloud ids. For an Azure\n\t * DevOps Server reachable over plain HTTP, include the scheme (e.g. `http://tfs.example.com`); otherwise\n\t * `https` is assumed.\n\t */\n\treadonly domain?: string;\n\t/** Optional scopes carried by the token, surfaced only in logging metadata. */\n\treadonly scopes?: readonly string[];\n\t/** Whether the token came from a GK-cloud connection (vs a raw PAT). Defaults to `true`. */\n\treadonly cloud?: boolean;\n}\n\nexport interface TokenScopedHttpConfig {\n\t/** The `fetch` implementation to use for HTTP requests. */\n\tfetch(input: string | URL, init?: RequestInit): Promise<Response>;\n\t/**\n\t * Wrap an async op so TLS validation is disabled when `ignoreSSLErrors` is `'force'`. Optional —\n\t * defaults to a pass-through, which is correct for the browser and for any consumer not toggling SSL.\n\t */\n\twrapForForcedInsecureSSL?<T>(ignoreSSLErrors: boolean | 'force', fn: () => Promise<T> | PromiseLike<T>): Promise<T>;\n\t/** Whether to ignore SSL certificate errors on requests. Defaults to `false`. */\n\tignoreSSLErrors?: boolean | 'force';\n\t/**\n\t * Whether the consumer runs in a web worker / browser (vs Node.js). GitHub uses this to drop the\n\t * `user-agent` header, which browsers reject and warn about. Defaults to `false`.\n\t */\n\tisWeb?: boolean;\n}\n\n/** The stateless reads a token-scoped integration exposes. */\nexport interface TokenScopedGitHostIntegration {\n\tgetRepositoryMetadata(\n\t\towner: string,\n\t\trepo: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined>;\n\tgetDefaultBranch(owner: string, repo: string, cancellation?: AbortSignal): Promise<DefaultBranch | undefined>;\n}\n\n/**\n * Build a token-scoped git-host integration for a single provider, backed only by a `fetch` + a token —\n * no `IntegrationServiceContext`, no session/OAuth lifecycle. The returned DTOs match those from the\n * session-managed {@link GitHostIntegration}.\n */\nexport function createTokenScopedGitHostIntegration(\n\tid: TokenScopedGitHostId,\n\ttoken: TokenScopedGitHostToken,\n\thttp: TokenScopedHttpConfig,\n): TokenScopedGitHostIntegration {\n\t// `token.domain` only applies to self-managed ids; cloud ids always use their canonical domain.\n\tconst selfManaged =\n\t\tid === GitSelfManagedHostIntegrationId.CloudGitHubEnterprise ||\n\t\tid === GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted ||\n\t\tid === GitSelfManagedHostIntegrationId.AzureDevOpsServer;\n\t// Self-managed ids carry no canonical domain (`providersMetadata[id].domain` is empty), so a missing\n\t// `token.domain` would silently build a malformed base URL (e.g. `https:///api/v3`). Fail fast instead.\n\tif (selfManaged && !token.domain) {\n\t\tthrow new Error(`A token-scoped integration for the self-managed host '${id}' requires 'token.domain'.`);\n\t}\n\n\tconst rawDomain = (selfManaged && token.domain) || providersMetadata[id].domain;\n\t// The provider/DTO domain drops the scheme (a subpath/collection is preserved for Azure Server and subpath\n\t// installs); only Azure DevOps Server's base URL honors an explicit scheme (per its doc). Stripping keeps a\n\t// scheme out of the DTO and prevents a malformed base URL (e.g. `https://http://host/api/v3`) if one is\n\t// accidentally passed for GHE/GitLab.\n\tconst host = stripScheme(rawDomain);\n\tconst provider = createProviderStub(id, host, http.ignoreSSLErrors ?? false);\n\tconst tokenInfo = buildTokenWithInfo(id, token);\n\n\tconst wrapForForcedInsecureSSL: NonNullable<TokenScopedHttpConfig['wrapForForcedInsecureSSL']> =\n\t\t// `Promise.resolve().then(fn)` (not `Promise.resolve(fn())`) so a synchronous throw in `fn` surfaces as\n\t\t// a rejected promise, honoring the `Promise<T>` contract.\n\t\thttp.wrapForForcedInsecureSSL ?? ((_ignore, fn) => Promise.resolve().then(fn));\n\n\t// GitHub has its own VS Code-free config type and a `getDefaultBranch` without a cancellation param.\n\tif (id === GitCloudHostIntegrationId.GitHub || id === GitSelfManagedHostIntegrationId.CloudGitHubEnterprise) {\n\t\tconst config: GitHubApiConfig = {\n\t\t\tisWeb: http.isWeb ?? false,\n\t\t\tfetch: (url, init) => http.fetch(url, init),\n\t\t\twrapForForcedInsecureSSL: wrapForForcedInsecureSSL,\n\t\t};\n\t\tconst api = new GitHubApi(config);\n\t\t// GitHub is the one family whose base URL can legitimately be absent — see `resolveGitHubApiBaseUrl`.\n\t\tconst baseUrl = resolveGitHubApiBaseUrl(id, host);\n\t\treturn {\n\t\t\tgetRepositoryMetadata: (owner, repo, cancellation) =>\n\t\t\t\tapi.getRepositoryMetadata(provider, tokenInfo, owner, repo, { baseUrl: baseUrl }, cancellation),\n\t\t\t// `GitHubApi.getDefaultBranch` has no cancellation param; accept and intentionally ignore it here so\n\t\t\t// the signature matches the other providers and the drop is explicit at the call site.\n\t\t\tgetDefaultBranch: (owner, repo, _cancellation) =>\n\t\t\t\tapi.getDefaultBranch(provider, tokenInfo, owner, repo, { baseUrl: baseUrl }),\n\t\t};\n\t}\n\n\t// GitLab, Bitbucket, and Azure DevOps share the `ProviderApiConfig` client shape and identical read signatures.\n\tconst baseUrl = resolveApiBaseUrl(id, rawDomain, host);\n\tconst config = toProviderApiConfig(http, wrapForForcedInsecureSSL);\n\tconst api =\n\t\tid === GitCloudHostIntegrationId.GitLab || id === GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted\n\t\t\t? new GitLabApi(config)\n\t\t\t: id === GitCloudHostIntegrationId.Bitbucket\n\t\t\t\t? new BitbucketApi(config)\n\t\t\t\t: new AzureDevOpsApi(config);\n\treturn {\n\t\tgetRepositoryMetadata: (owner, repo, cancellation) =>\n\t\t\tapi.getRepositoryMetadata(provider, tokenInfo, owner, repo, { baseUrl: baseUrl }, cancellation),\n\t\tgetDefaultBranch: (owner, repo, cancellation) =>\n\t\t\tapi.getDefaultBranch(provider, tokenInfo, owner, repo, { baseUrl: baseUrl }, cancellation),\n\t};\n}\n\nfunction toProviderApiConfig(\n\thttp: TokenScopedHttpConfig,\n\twrapForForcedInsecureSSL: NonNullable<TokenScopedHttpConfig['wrapForForcedInsecureSSL']>,\n): ProviderApiConfig {\n\treturn {\n\t\tfetch: (input, init) => http.fetch(input, init),\n\t\twrapForForcedInsecureSSL: wrapForForcedInsecureSSL,\n\t};\n}\n\nfunction buildTokenWithInfo(id: TokenScopedGitHostId, token: TokenScopedGitHostToken): TokenWithInfo {\n\tconst cloud = token.cloud ?? true;\n\treturn {\n\t\t...toTokenInfo(id, token.accessToken, { cloud: cloud, type: undefined, scopes: token.scopes }),\n\t\taccessToken: token.accessToken,\n\t};\n}\n\n/** A minimal {@link Provider} for the API clients: identity + no-op reauth/telemetry, SSL from config. */\nfunction createProviderStub(id: TokenScopedGitHostId, domain: string, ignoreSSLErrors: boolean | 'force'): Provider {\n\tconst metadata = providersMetadata[id];\n\treturn {\n\t\tid: id,\n\t\tname: metadata.name,\n\t\tdomain: domain,\n\t\ticon: metadata.iconKey,\n\t\tgetIgnoreSSLErrors: () => ignoreSSLErrors,\n\t\treauthenticate: () => Promise.resolve(),\n\t\ttrackRequestException: () => {},\n\t};\n}\n\n/** Strips a leading `scheme://` and any trailing slashes; a subpath/collection (e.g. `host/tfs/Col`) is preserved. */\nfunction stripScheme(domain: string): string {\n\treturn trimTrailingSlashes(domain.replace(/^[a-z][\\w+.-]*:\\/\\//i, ''));\n}\n\n/**\n * GitHub's base URL, which `@gitkraken/provider-apis` derives BOTH the REST and the GraphQL endpoint from. Omitting it\n * is what selects the cloud endpoints, so cloud passes nothing. Mirrors the cloud `GitHubIntegration.apiBaseUrlFor`.\n */\nfunction resolveGitHubApiBaseUrl(\n\tid: GitCloudHostIntegrationId.GitHub | GitSelfManagedHostIntegrationId.CloudGitHubEnterprise,\n\thost: string,\n): string | undefined {\n\treturn id === GitCloudHostIntegrationId.GitHub ? undefined : `https://${host}/api/v3`;\n}\n\n/**\n * Mirrors the per-provider `apiBaseUrlFor` methods on the `GitHostIntegration` subclasses for an installation at\n * the host root. Covers every family whose base URL is always concrete (GitHub's is not — see\n * {@link resolveGitHubApiBaseUrl}). `rawDomain` may carry a scheme (only Azure DevOps Server honors it); `host` is\n * the bare host used everywhere else.\n */\nfunction resolveApiBaseUrl(\n\tid: Exclude<\n\t\tTokenScopedGitHostId,\n\t\tGitCloudHostIntegrationId.GitHub | GitSelfManagedHostIntegrationId.CloudGitHubEnterprise\n\t>,\n\trawDomain: string,\n\thost: string,\n): string {\n\tswitch (id) {\n\t\tcase GitCloudHostIntegrationId.GitLab:\n\t\t\treturn 'https://gitlab.com/api';\n\t\tcase GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted:\n\t\t\treturn `https://${host}/api`;\n\t\tcase GitCloudHostIntegrationId.Bitbucket:\n\t\t\treturn 'https://api.bitbucket.org/2.0';\n\t\tcase GitCloudHostIntegrationId.AzureDevOps:\n\t\t\treturn 'https://dev.azure.com';\n\t\tcase GitSelfManagedHostIntegrationId.AzureDevOpsServer:\n\t\t\t// Mirror the session-managed getter, which honors the connection protocol; default to https.\n\t\t\treturn rawDomain.includes('://') ? trimTrailingSlashes(rawDomain) : `https://${host}`;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AA0FA,SAAgB,oCACf,IACA,OACA,MACgC;CAEhC,MAAM,cACL,OAAA,6BACA,OAAA,8BACA,OAAA;CAGD,IAAI,eAAe,CAAC,MAAM,QACzB,MAAM,IAAI,MAAM,yDAAyD,GAAG,2BAA2B;CAGxG,MAAM,YAAa,eAAe,MAAM,UAAW,kBAAkB,GAAG,CAAC;CAKzE,MAAM,OAAO,YAAY,SAAS;CAClC,MAAM,WAAW,mBAAmB,IAAI,MAAM,KAAK,mBAAmB,KAAK;CAC3E,MAAM,YAAY,mBAAmB,IAAI,KAAK;CAE9C,MAAM,2BAGL,KAAK,8BAA8B,SAAS,OAAO,QAAQ,QAAQ,CAAC,CAAC,KAAK,EAAE;CAG7E,IAAI,OAAA,YAA2C,OAAA,2BAA8D;EAC5G,MAAM,SAA0B;GAC/B,OAAO,KAAK,SAAS;GACrB,QAAQ,KAAK,SAAS,KAAK,MAAM,KAAK,IAAI;GAChB;EAC3B;EACA,MAAM,MAAM,IAAI,UAAU,MAAM;EAEhC,MAAM,UAAU,wBAAwB,IAAI,IAAI;EAChD,OAAO;GACN,wBAAwB,OAAO,MAAM,iBACpC,IAAI,sBAAsB,UAAU,WAAW,OAAO,MAAM,EAAW,QAAQ,GAAG,YAAY;GAG/F,mBAAmB,OAAO,MAAM,kBAC/B,IAAI,iBAAiB,UAAU,WAAW,OAAO,MAAM,EAAW,QAAQ,CAAC;EAC7E;CACD;CAGA,MAAM,UAAU,kBAAkB,IAAI,WAAW,IAAI;CACrD,MAAM,SAAS,oBAAoB,MAAM,wBAAwB;CACjE,MAAM,MACL,OAAA,YAA2C,OAAA,6BACxC,IAAI,UAAU,MAAM,IACpB,OAAA,cACC,IAAI,aAAa,MAAM,IACvB,IAAI,eAAe,MAAM;CAC9B,OAAO;EACN,wBAAwB,OAAO,MAAM,iBACpC,IAAI,sBAAsB,UAAU,WAAW,OAAO,MAAM,EAAW,QAAQ,GAAG,YAAY;EAC/F,mBAAmB,OAAO,MAAM,iBAC/B,IAAI,iBAAiB,UAAU,WAAW,OAAO,MAAM,EAAW,QAAQ,GAAG,YAAY;CAC3F;AACD;AAEA,SAAS,oBACR,MACA,0BACoB;CACpB,OAAO;EACN,QAAQ,OAAO,SAAS,KAAK,MAAM,OAAO,IAAI;EACpB;CAC3B;AACD;AAEA,SAAS,mBAAmB,IAA0B,OAA+C;CACpG,MAAM,QAAQ,MAAM,SAAS;CAC7B,OAAO;EACN,GAAG,YAAY,IAAI,MAAM,aAAa;GAAS;GAAO,MAAM,KAAA;GAAW,QAAQ,MAAM;EAAO,CAAC;EAC7F,aAAa,MAAM;CACpB;AACD;;AAGA,SAAS,mBAAmB,IAA0B,QAAgB,iBAA8C;CACnH,MAAM,WAAW,kBAAkB;CACnC,OAAO;EACF;EACJ,MAAM,SAAS;EACP;EACR,MAAM,SAAS;EACf,0BAA0B;EAC1B,sBAAsB,QAAQ,QAAQ;EACtC,6BAA6B,CAAC;CAC/B;AACD;;AAGA,SAAS,YAAY,QAAwB;CAC5C,OAAO,oBAAoB,OAAO,QAAQ,wBAAwB,EAAE,CAAC;AACtE;;;;;AAMA,SAAS,wBACR,IACA,MACqB;CACrB,OAAO,OAAA,WAA0C,KAAA,IAAY,WAAW,KAAK;AAC9E;;;;;;;AAQA,SAAS,kBACR,IAIA,WACA,MACS;CACT,QAAQ,IAAR;EACC,KAAA,UACC,OAAO;EACR,KAAA,4BACC,OAAO,WAAW,KAAK;EACxB,KAAA,aACC,OAAO;EACR,KAAA,eACC,OAAO;EACR,KAAA,uBAEC,OAAO,UAAU,SAAS,KAAK,IAAI,oBAAoB,SAAS,IAAI,WAAW;CACjF;AACD"}
1
+ {"version":3,"file":"lite.js","names":[],"sources":["../../../../plus/integrations/src/lite.ts"],"sourcesContent":["// A lightweight, token-scoped entry point for stateless single-shot provider reads.\n//\n// Unlike `createIntegrationManager`, this does NOT build an `IntegrationServiceContext`\n// (no storage/account/config/cache/repositories/hooks) and runs no session/OAuth lifecycle.\n// A consumer that already holds a provider access token (obtained by its own means, e.g.\n// the GitKraken account backend's `v1/provider-tokens/{provider}` endpoint) can call the\n// per-provider API client directly and get back the same DTOs the session-managed\n// `GitHostIntegration` returns.\n//\n// Provider notes:\n// - Azure DevOps encodes the repository as the composite string `\"{project}/_git/{repoName}\"`\n// in the `repo` argument (matching the descriptor `GitHostIntegration` uses); `owner` is the\n// organization. Pass `repo` in that shape for Azure.\n// - Bitbucket Cloud `getDefaultBranch`/`getRepositoryMetadata` depend on `mainbranch`/`parent`\n// fields the API may omit for some repos; they resolve to `undefined` when absent.\n// - Bitbucket Server (`bitbucket-server`) is not supported here — its reads use a different\n// REST surface that this token-scoped path doesn't wire up.\n\nimport type { GitHubApiConfig } from '@gitlens/git-github/api/config.js';\nimport { GitHubApi } from '@gitlens/git-github/api/github.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport { trimTrailingSlashes } from '@gitlens/utils/path.js';\nimport type { TokenWithInfo } from './authentication/models.js';\nimport { toTokenInfo } from './authentication/models.js';\nimport { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId } from './constants.js';\nimport type { ProviderApiConfig } from './providers/apiConfig.js';\nimport { AzureDevOpsApi } from './providers/azure/azure.js';\nimport { BitbucketApi } from './providers/bitbucket/bitbucket.js';\nimport { GitLabApi } from './providers/gitlab/gitlab.js';\nimport { providersMetadata } from './providers/models.js';\n\n/** The git-hosting integrations that expose a token-scoped read path here. */\nexport type TokenScopedGitHostId =\n\t| GitCloudHostIntegrationId.GitHub\n\t| GitCloudHostIntegrationId.GitLab\n\t| GitCloudHostIntegrationId.Bitbucket\n\t| GitCloudHostIntegrationId.AzureDevOps\n\t| GitSelfManagedHostIntegrationId.CloudGitHubEnterprise\n\t| GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted\n\t| GitSelfManagedHostIntegrationId.AzureDevOpsServer;\n\nexport interface TokenScopedGitHostToken {\n\t/** The provider access token the consumer already holds. */\n\treadonly accessToken: string;\n\t/**\n\t * Host domain for self-managed instances (e.g. `git.example.com`). Ignored for cloud ids. For an Azure\n\t * DevOps Server reachable over plain HTTP, include the scheme (e.g. `http://tfs.example.com`); otherwise\n\t * `https` is assumed.\n\t */\n\treadonly domain?: string;\n\t/** Optional scopes carried by the token, surfaced only in logging metadata. */\n\treadonly scopes?: readonly string[];\n\t/** Whether the token came from a GK-cloud connection (vs a raw PAT). Defaults to `true`. */\n\treadonly cloud?: boolean;\n}\n\nexport interface TokenScopedHttpConfig {\n\t/** The `fetch` implementation to use for HTTP requests. */\n\tfetch(input: string | URL, init?: RequestInit): Promise<Response>;\n\t/**\n\t * Wrap an async op so TLS validation is disabled when `ignoreSSLErrors` is `'force'`. Optional —\n\t * defaults to a pass-through, which is correct for the browser and for any consumer not toggling SSL.\n\t */\n\twrapForForcedInsecureSSL?<T>(ignoreSSLErrors: boolean | 'force', fn: () => Promise<T> | PromiseLike<T>): Promise<T>;\n\t/** Whether to ignore SSL certificate errors on requests. Defaults to `false`. */\n\tignoreSSLErrors?: boolean | 'force';\n\t/**\n\t * Whether the consumer runs in a web worker / browser (vs Node.js). GitHub uses this to drop the\n\t * `user-agent` header, which browsers reject and warn about. Defaults to `false`.\n\t */\n\tisWeb?: boolean;\n}\n\n/** The stateless reads a token-scoped integration exposes. */\nexport interface TokenScopedGitHostIntegration {\n\tgetRepositoryMetadata(\n\t\towner: string,\n\t\trepo: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined>;\n\tgetDefaultBranch(owner: string, repo: string, cancellation?: AbortSignal): Promise<DefaultBranch | undefined>;\n}\n\n/**\n * Build a token-scoped git-host integration for a single provider, backed only by a `fetch` + a token —\n * no `IntegrationServiceContext`, no session/OAuth lifecycle. The returned DTOs match those from the\n * session-managed {@link GitHostIntegration}.\n */\nexport function createTokenScopedGitHostIntegration(\n\tid: TokenScopedGitHostId,\n\ttoken: TokenScopedGitHostToken,\n\thttp: TokenScopedHttpConfig,\n): TokenScopedGitHostIntegration {\n\tconst selfManaged =\n\t\tid === GitSelfManagedHostIntegrationId.CloudGitHubEnterprise ||\n\t\tid === GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted ||\n\t\tid === GitSelfManagedHostIntegrationId.AzureDevOpsServer;\n\t// Self-managed ids carry no canonical domain (`providersMetadata[id].domain` is empty), so a missing\n\t// `token.domain` would silently build a malformed base URL (e.g. `https:///api/v3`). Fail fast instead.\n\tif (selfManaged && !token.domain) {\n\t\tthrow new Error(`A token-scoped integration for the self-managed host '${id}' requires 'token.domain'.`);\n\t}\n\n\tconst rawDomain = (selfManaged && token.domain) || providersMetadata[id].domain;\n\t// The provider/DTO domain drops the scheme (a subpath/collection is preserved for Azure Server and subpath\n\t// installs); only Azure DevOps Server's base URL honors an explicit scheme (per its doc). Stripping keeps a\n\t// scheme out of the DTO and prevents a malformed base URL (e.g. `https://http://host/api/v3`) if one is\n\t// accidentally passed for GHE/GitLab.\n\tconst host = stripScheme(rawDomain);\n\tconst provider = createProviderStub(id, host, http.ignoreSSLErrors ?? false);\n\tconst tokenInfo = buildTokenWithInfo(id, token);\n\n\tconst wrapForForcedInsecureSSL: NonNullable<TokenScopedHttpConfig['wrapForForcedInsecureSSL']> =\n\t\t// `Promise.resolve().then(fn)` (not `Promise.resolve(fn())`) so a synchronous throw in `fn` surfaces as\n\t\t// a rejected promise, honoring the `Promise<T>` contract.\n\t\thttp.wrapForForcedInsecureSSL ?? ((_ignore, fn) => Promise.resolve().then(fn));\n\n\tif (id === GitCloudHostIntegrationId.GitHub || id === GitSelfManagedHostIntegrationId.CloudGitHubEnterprise) {\n\t\tconst config: GitHubApiConfig = {\n\t\t\tisWeb: http.isWeb ?? false,\n\t\t\tfetch: (url, init) => http.fetch(url, init),\n\t\t\twrapForForcedInsecureSSL: wrapForForcedInsecureSSL,\n\t\t};\n\t\tconst api = new GitHubApi(config);\n\t\t// GitHub is the one family whose base URL can legitimately be absent — see `resolveGitHubApiBaseUrl`.\n\t\tconst baseUrl = resolveGitHubApiBaseUrl(id, host);\n\t\treturn {\n\t\t\tgetRepositoryMetadata: (owner, repo, cancellation) =>\n\t\t\t\tapi.getRepositoryMetadata(provider, tokenInfo, owner, repo, { baseUrl: baseUrl }, cancellation),\n\t\t\t// `GitHubApi.getDefaultBranch` has no cancellation param; accept and intentionally ignore it here so\n\t\t\t// the signature matches the other providers and the drop is explicit at the call site.\n\t\t\tgetDefaultBranch: (owner, repo, _cancellation) =>\n\t\t\t\tapi.getDefaultBranch(provider, tokenInfo, owner, repo, { baseUrl: baseUrl }),\n\t\t};\n\t}\n\n\tconst baseUrl = resolveApiBaseUrl(id, rawDomain, host);\n\tconst config = toProviderApiConfig(http, wrapForForcedInsecureSSL);\n\tif (id === GitCloudHostIntegrationId.GitLab || id === GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted) {\n\t\tconst api = new GitLabApi(config);\n\t\treturn {\n\t\t\tgetRepositoryMetadata: (owner, repo, cancellation) =>\n\t\t\t\tapi.getRepositoryMetadata(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttokenInfo,\n\t\t\t\t\towner,\n\t\t\t\t\trepo,\n\t\t\t\t\t{ baseUrl: baseUrl, backoff: false },\n\t\t\t\t\tcancellation,\n\t\t\t\t),\n\t\t\tgetDefaultBranch: (owner, repo, cancellation) =>\n\t\t\t\tapi.getDefaultBranch(provider, tokenInfo, owner, repo, { baseUrl: baseUrl }, cancellation),\n\t\t};\n\t}\n\n\tconst api = id === GitCloudHostIntegrationId.Bitbucket ? new BitbucketApi(config) : new AzureDevOpsApi(config);\n\treturn {\n\t\tgetRepositoryMetadata: (owner, repo, cancellation) =>\n\t\t\tapi.getRepositoryMetadata(provider, tokenInfo, owner, repo, { baseUrl: baseUrl }, cancellation),\n\t\tgetDefaultBranch: (owner, repo, cancellation) =>\n\t\t\tapi.getDefaultBranch(provider, tokenInfo, owner, repo, { baseUrl: baseUrl }, cancellation),\n\t};\n}\n\nfunction toProviderApiConfig(\n\thttp: TokenScopedHttpConfig,\n\twrapForForcedInsecureSSL: NonNullable<TokenScopedHttpConfig['wrapForForcedInsecureSSL']>,\n): ProviderApiConfig {\n\treturn {\n\t\tfetch: (input, init) => http.fetch(input, init),\n\t\twrapForForcedInsecureSSL: wrapForForcedInsecureSSL,\n\t};\n}\n\nfunction buildTokenWithInfo(id: TokenScopedGitHostId, token: TokenScopedGitHostToken): TokenWithInfo {\n\tconst cloud = token.cloud ?? true;\n\treturn {\n\t\t...toTokenInfo(id, token.accessToken, { cloud: cloud, type: undefined, scopes: token.scopes }),\n\t\taccessToken: token.accessToken,\n\t};\n}\n\n/** A minimal {@link Provider} for the API clients: identity + no-op reauth/telemetry, SSL from config. */\nfunction createProviderStub(id: TokenScopedGitHostId, domain: string, ignoreSSLErrors: boolean | 'force'): Provider {\n\tconst metadata = providersMetadata[id];\n\treturn {\n\t\tid: id,\n\t\tname: metadata.name,\n\t\tdomain: domain,\n\t\ticon: metadata.iconKey,\n\t\tgetIgnoreSSLErrors: () => ignoreSSLErrors,\n\t\treauthenticate: () => Promise.resolve(),\n\t\ttrackRequestException: () => {},\n\t};\n}\n\n/** Strips a leading `scheme://` and any trailing slashes; a subpath/collection (e.g. `host/tfs/Col`) is preserved. */\nfunction stripScheme(domain: string): string {\n\treturn trimTrailingSlashes(domain.replace(/^[a-z][\\w+.-]*:\\/\\//i, ''));\n}\n\n/**\n * GitHub's base URL, which `@gitkraken/provider-apis` derives BOTH the REST and the GraphQL endpoint from. Omitting it\n * is what selects the cloud endpoints, so cloud passes nothing. Mirrors the cloud `GitHubIntegration.apiBaseUrlFor`.\n */\nfunction resolveGitHubApiBaseUrl(\n\tid: GitCloudHostIntegrationId.GitHub | GitSelfManagedHostIntegrationId.CloudGitHubEnterprise,\n\thost: string,\n): string | undefined {\n\treturn id === GitCloudHostIntegrationId.GitHub ? undefined : `https://${host}/api/v3`;\n}\n\n/**\n * Mirrors the per-provider `apiBaseUrlFor` methods on the `GitHostIntegration` subclasses for an installation at\n * the host root. Covers every family whose base URL is always concrete (GitHub's is not — see\n * {@link resolveGitHubApiBaseUrl}). `rawDomain` may carry a scheme (only Azure DevOps Server honors it); `host` is\n * the bare host used everywhere else.\n */\nfunction resolveApiBaseUrl(\n\tid: Exclude<\n\t\tTokenScopedGitHostId,\n\t\tGitCloudHostIntegrationId.GitHub | GitSelfManagedHostIntegrationId.CloudGitHubEnterprise\n\t>,\n\trawDomain: string,\n\thost: string,\n): string {\n\tswitch (id) {\n\t\tcase GitCloudHostIntegrationId.GitLab:\n\t\t\treturn 'https://gitlab.com/api';\n\t\tcase GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted:\n\t\t\treturn `https://${host}/api`;\n\t\tcase GitCloudHostIntegrationId.Bitbucket:\n\t\t\treturn 'https://api.bitbucket.org/2.0';\n\t\tcase GitCloudHostIntegrationId.AzureDevOps:\n\t\t\treturn 'https://dev.azure.com';\n\t\tcase GitSelfManagedHostIntegrationId.AzureDevOpsServer:\n\t\t\t// Mirror the session-managed getter, which honors the connection protocol; default to https.\n\t\t\treturn rawDomain.includes('://') ? trimTrailingSlashes(rawDomain) : `https://${host}`;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AA0FA,SAAgB,oCACf,IACA,OACA,MACgC;CAChC,MAAM,cACL,OAAA,6BACA,OAAA,8BACA,OAAA;CAGD,IAAI,eAAe,CAAC,MAAM,QACzB,MAAM,IAAI,MAAM,yDAAyD,GAAG,2BAA2B;CAGxG,MAAM,YAAa,eAAe,MAAM,UAAW,kBAAkB,GAAG,CAAC;CAKzE,MAAM,OAAO,YAAY,SAAS;CAClC,MAAM,WAAW,mBAAmB,IAAI,MAAM,KAAK,mBAAmB,KAAK;CAC3E,MAAM,YAAY,mBAAmB,IAAI,KAAK;CAE9C,MAAM,2BAGL,KAAK,8BAA8B,SAAS,OAAO,QAAQ,QAAQ,CAAC,CAAC,KAAK,EAAE;CAE7E,IAAI,OAAA,YAA2C,OAAA,2BAA8D;EAC5G,MAAM,SAA0B;GAC/B,OAAO,KAAK,SAAS;GACrB,QAAQ,KAAK,SAAS,KAAK,MAAM,KAAK,IAAI;GAChB;EAC3B;EACA,MAAM,MAAM,IAAI,UAAU,MAAM;EAEhC,MAAM,UAAU,wBAAwB,IAAI,IAAI;EAChD,OAAO;GACN,wBAAwB,OAAO,MAAM,iBACpC,IAAI,sBAAsB,UAAU,WAAW,OAAO,MAAM,EAAW,QAAQ,GAAG,YAAY;GAG/F,mBAAmB,OAAO,MAAM,kBAC/B,IAAI,iBAAiB,UAAU,WAAW,OAAO,MAAM,EAAW,QAAQ,CAAC;EAC7E;CACD;CAEA,MAAM,UAAU,kBAAkB,IAAI,WAAW,IAAI;CACrD,MAAM,SAAS,oBAAoB,MAAM,wBAAwB;CACjE,IAAI,OAAA,YAA2C,OAAA,4BAA8D;EAC5G,MAAM,MAAM,IAAI,UAAU,MAAM;EAChC,OAAO;GACN,wBAAwB,OAAO,MAAM,iBACpC,IAAI,sBACH,UACA,WACA,OACA,MACA;IAAW;IAAS,SAAS;GAAM,GACnC,YACD;GACD,mBAAmB,OAAO,MAAM,iBAC/B,IAAI,iBAAiB,UAAU,WAAW,OAAO,MAAM,EAAW,QAAQ,GAAG,YAAY;EAC3F;CACD;CAEA,MAAM,MAAM,OAAA,cAA6C,IAAI,aAAa,MAAM,IAAI,IAAI,eAAe,MAAM;CAC7G,OAAO;EACN,wBAAwB,OAAO,MAAM,iBACpC,IAAI,sBAAsB,UAAU,WAAW,OAAO,MAAM,EAAW,QAAQ,GAAG,YAAY;EAC/F,mBAAmB,OAAO,MAAM,iBAC/B,IAAI,iBAAiB,UAAU,WAAW,OAAO,MAAM,EAAW,QAAQ,GAAG,YAAY;CAC3F;AACD;AAEA,SAAS,oBACR,MACA,0BACoB;CACpB,OAAO;EACN,QAAQ,OAAO,SAAS,KAAK,MAAM,OAAO,IAAI;EACpB;CAC3B;AACD;AAEA,SAAS,mBAAmB,IAA0B,OAA+C;CACpG,MAAM,QAAQ,MAAM,SAAS;CAC7B,OAAO;EACN,GAAG,YAAY,IAAI,MAAM,aAAa;GAAS;GAAO,MAAM,KAAA;GAAW,QAAQ,MAAM;EAAO,CAAC;EAC7F,aAAa,MAAM;CACpB;AACD;;AAGA,SAAS,mBAAmB,IAA0B,QAAgB,iBAA8C;CACnH,MAAM,WAAW,kBAAkB;CACnC,OAAO;EACF;EACJ,MAAM,SAAS;EACP;EACR,MAAM,SAAS;EACf,0BAA0B;EAC1B,sBAAsB,QAAQ,QAAQ;EACtC,6BAA6B,CAAC;CAC/B;AACD;;AAGA,SAAS,YAAY,QAAwB;CAC5C,OAAO,oBAAoB,OAAO,QAAQ,wBAAwB,EAAE,CAAC;AACtE;;;;;AAMA,SAAS,wBACR,IACA,MACqB;CACrB,OAAO,OAAA,WAA0C,KAAA,IAAY,WAAW,KAAK;AAC9E;;;;;;;AAQA,SAAS,kBACR,IAIA,WACA,MACS;CACT,QAAQ,IAAR;EACC,KAAA,UACC,OAAO;EACR,KAAA,4BACC,OAAO,WAAW,KAAK;EACxB,KAAA,aACC,OAAO;EACR,KAAA,eACC,OAAO;EACR,KAAA,uBAEC,OAAO,UAAU,SAAS,KAAK,IAAI,oBAAoB,SAAS,IAAI,WAAW;CACjF;AACD"}
@@ -17,13 +17,31 @@ import { PullRequestActivityResult, PullRequestActivityTarget } from "./reads/pu
17
17
  import { PullRequestBatchResult, PullRequestBatchTarget } from "./reads/pullRequestBatch.js";
18
18
  import { PullRequestBranchResult, PullRequestBranchTarget } from "./reads/pullRequestBranches.js";
19
19
  import { PullRequestCheckLogResult, PullRequestCheckLogTarget } from "./reads/pullRequestCheckLogs.js";
20
+ import { PullRequestForCommitResult } from "./reads/pullRequestsForCommits.js";
20
21
  //#region ../plus/integrations/src/manager.d.ts
21
22
  type IssueWriteConnection = {
22
23
  providerId: IntegrationIds;
23
24
  connectionId: string;
24
25
  };
25
26
  export type IssueWriteOptions = IssueWriteConnection & GitHubIssueWrite;
27
+ /**
28
+ * `intent: 'delete'` also requires that the connection may delete the issue, so a host can refuse before asking
29
+ * the user to confirm a deletion GitHub would reject.
30
+ */
31
+ export type IssueWriteTargetOptions = IssueWriteConnection & GitHubIssueDelete & {
32
+ intent?: 'delete';
33
+ };
26
34
  export type IssueDeleteOptions = IssueWriteConnection & GitHubIssueDelete;
35
+ /** The canonical node ID, and the issue as GitHub reports it now: where it lives, its URL, title and state. */
36
+ export type IssueWriteTargetResult = {
37
+ ok: true;
38
+ nodeId: string;
39
+ issue: Extract<IssueWriteResult, {
40
+ ok: true;
41
+ }>['issue'];
42
+ } | Extract<IssueWriteResult, {
43
+ ok: false;
44
+ }>;
27
45
  /** Neutral repository input accepted by repo-scoped provider reads. */
28
46
  export interface ProviderRepositoryInput {
29
47
  namespace: string;
@@ -983,6 +1001,80 @@ export interface IntegrationManager {
983
1001
  /** Timeline items (reviews and conversation comments) per target: an integer from 1 to 100. Defaults to 30. */
984
1002
  limit?: number;
985
1003
  }): Promise<ProviderResult<PullRequestActivityResult>>;
1004
+ /**
1005
+ * Finds the pull request each of several commits of ONE repository belongs to, in a few requests rather than one
1006
+ * per commit, for a whole history window. The batch form of the single-commit lookup, answered without the user's
1007
+ * relationship to the pull request.
1008
+ *
1009
+ * Results are echoed under the commit's own `sha`, so no positional matching is needed. Repeats in `shas`
1010
+ * (ignoring case) are resolved once and answered once. Per-SHA isolation is the rule, as in
1011
+ * {@link getPullRequestsBatch}:
1012
+ * - `{ sha, pullRequest }` — the commit belongs to that pull request, in any state. When it belongs to several, the
1013
+ * one the single-commit lookup returns, which each host picks its own way:
1014
+ * - GitHub/GHE: of the two most recently updated pull requests GitHub associates with the commit, one from a fork
1015
+ * only when the fork is `owner`'s; of those, `owner`'s own (ignoring case), then a merged one, then the most
1016
+ * recently updated. A third one is never considered.
1017
+ * - GitLab: of the first page GitLab lists, an open one, then the most recently updated.
1018
+ * - Bitbucket Cloud and Bitbucket Data Center: of the first page the host lists, the most recently updated.
1019
+ * - Azure DevOps: the first the pull request query lists.
1020
+ * - `{ sha }` with no `pullRequest` — RESOLVED NONE: the host answered and the commit has no pull request (also a
1021
+ * commit or repository the host doesn't have or this connection can't see, and the working tree's all-zero SHA,
1022
+ * which is never sent). Safe to cache. Bitbucket Cloud answers `404` alike for a commit it doesn't have and for a
1023
+ * repository it doesn't have, so its `404` is none only once another commit of the repository answered, in this
1024
+ * call or an earlier one with the same token; until then it fails. So on Bitbucket Cloud don't pass
1025
+ * commits the remote doesn't have (unpushed ones): a window made only of those can't resolve. A repository whose
1026
+ * pull request links aren't indexed yet (an answer without a list, or `repo_indexed: false`) fails every SHA.
1027
+ * - No item for a `sha`, with `fetchFailed` and a warning naming it in `targetKeys` — the read could not check
1028
+ * (auth, rate limit, network, missing session, an unmappable response). Never treat that as none.
1029
+ *
1030
+ * Every entry of `shas` must be a full 40-character commit SHA, in either letter case (surrounding whitespace is
1031
+ * trimmed): anything else, a branch name or a short SHA included, refuses the whole call with a warning and
1032
+ * `fetchFailed`, since a ref the host can't resolve as a commit would otherwise read as a cacheable none.
1033
+ *
1034
+ * UNCACHED, and deliberately not routed through the integration's cached single-commit lookup: that cache's key
1035
+ * carries no connection, and the lookup answers a failure as `undefined`, which a caller can't tell from a commit
1036
+ * without a pull request. The caller owns caching, per SHA.
1037
+ *
1038
+ * Request cost, for N commits: GitHub/GHE one aliased GraphQL request per 25; Azure DevOps one pull request query per 100, then one read per distinct pull request
1039
+ * found; GitLab one project lookup, kept per token, then one request per commit; Bitbucket Cloud and Bitbucket
1040
+ * Data Center one request per commit. Every fan-out runs with bounded concurrency, through a strict form of the
1041
+ * single-commit lookup's read, so its row is that lookup's row. After the first rate limit or refused credential
1042
+ * (and on Bitbucket Cloud, the first commit refused because the pull request commit links app isn't installed, or
1043
+ * the first answer that its links aren't indexed yet), or a `403` before any SHA answered, the requests not yet
1044
+ * sent aren't: their SHAs fail with that reason under one warning. There is no cap on
1045
+ * `shas`, so a caller sizes its window to the cost it accepts.
1046
+ *
1047
+ * Rows are the single-commit lookup's: the lite pull request shape, without `authoredByMe` or `viewer`.
1048
+ */
1049
+ getPullRequestsForCommits(options: {
1050
+ providerId: IntegrationIds;
1051
+ /**
1052
+ * GitHub owner, GitLab namespace path (may be nested), Bitbucket workspace, Bitbucket Data Center project key, or
1053
+ * Azure DevOps organization.
1054
+ */
1055
+ owner: string;
1056
+ /** Repository name or slug. */
1057
+ repo: string;
1058
+ /** Azure DevOps project. Required there, ignored elsewhere. */
1059
+ project?: string;
1060
+ /** The commits, as full 40-character SHAs; see above. */
1061
+ shas: readonly string[];
1062
+ connectionId?: string;
1063
+ /** Self-managed host domain fallback; see {@link ProviderSweepTarget.domain}. */
1064
+ domain?: string;
1065
+ /**
1066
+ * Selects merge-queue data (`mergeQueue`, `mergeQueueRequired`, `mergeQueueRemoval`) on GitHub.com for this
1067
+ * read: `true` selects it, `false` doesn't, omitted follows the host's
1068
+ * `ConfigProvider.getPullRequestReadOptions`, resolved once per call. Every other provider ignores it.
1069
+ * Selecting it costs a rate-limit request per row.
1070
+ */
1071
+ mergeQueue?: boolean;
1072
+ /**
1073
+ * Aborts the read: the requests in flight, and every request it has yet to send. The read then rejects with a
1074
+ * `CancellationError` instead of resolving, so a cancelled read is never mistaken for a failed or an empty one.
1075
+ */
1076
+ cancellation?: AbortSignal;
1077
+ }): Promise<ProviderResult<PullRequestForCommitResult>>;
986
1078
  /**
987
1079
  * How many pull requests match each scope — the PR twin of {@link countIssues}, behind a "this will fetch ~N pull
988
1080
  * requests" preview and a live count next to an unapplied filter. Same per-scope isolation, `key`-echo, and
@@ -1074,6 +1166,7 @@ export interface IntegrationManager {
1074
1166
  }): Promise<ProviderBroadenResult<IssueShape>>;
1075
1167
  writeIssue(options: IssueWriteOptions): Promise<IssueWriteResult>;
1076
1168
  deleteIssue(options: IssueDeleteOptions): Promise<IssueWriteResult>;
1169
+ resolveIssueWriteTarget(options: IssueWriteTargetOptions): Promise<IssueWriteTargetResult>;
1077
1170
  resolveRepository(options: {
1078
1171
  providerId?: IntegrationIds;
1079
1172
  remoteUrl: string;
@@ -199,7 +199,9 @@ export declare abstract class GitHostIntegration<ID extends IntegrationIds = Int
199
199
  cancellation?: AbortSignal;
200
200
  expiryOverride?: boolean | number;
201
201
  }): Promise<RepositoryMetadata | undefined>;
202
- protected abstract getProviderRepositoryMetadata(session: ProviderAuthenticationSession, repo: T, cancellation?: AbortSignal): Promise<RepositoryMetadata | undefined>;
202
+ protected abstract getProviderRepositoryMetadata(session: ProviderAuthenticationSession, repo: T, cancellation?: AbortSignal, options?: {
203
+ fresh?: boolean;
204
+ }): Promise<RepositoryMetadata | undefined>;
203
205
  /**
204
206
  * Whether this git host implements generic org discovery. False for providers that register no
205
207
  * {@link getProviderOrganizationsForUser} hook — the facade uses this to
@@ -335,7 +337,14 @@ export declare abstract class GitHostIntegration<ID extends IntegrationIds = Int
335
337
  expiryOverride?: boolean | number;
336
338
  throwOnError?: boolean;
337
339
  }): Promise<PullRequest | undefined>;
338
- protected abstract getProviderPullRequestForCommit(session: ProviderAuthenticationSession, repo: T, rev: string): Promise<PullRequest | undefined>;
340
+ protected abstract getProviderPullRequestForCommit(session: ProviderAuthenticationSession, repo: T, rev: string, options?: {
341
+ fresh?: boolean;
342
+ }): Promise<PullRequest | undefined>;
343
+ private getCommitLookupBackoffKeys;
344
+ protected getCommitLookupBackoff(ex: unknown): {
345
+ scope: 'repository' | 'commit';
346
+ until?: number;
347
+ } | undefined;
339
348
  /**
340
349
  * Memoized identity lookups backing filter resolution. Keyed by the session's token fingerprint plus the
341
350
  * scope of the lookup (base URL, and the Azure organization for the per-instance variant), so a different
@@ -812,6 +821,16 @@ export declare abstract class GitHostIntegration<ID extends IntegrationIds = Int
812
821
  pullRequests: PullRequestShape[];
813
822
  truncated: boolean;
814
823
  }>[] | undefined>;
824
+ getPullRequestsForCommitsResult(repo: RepositoryCoordinate, shas: readonly string[], options: {
825
+ mergeQueue?: boolean;
826
+ }, cancellation?: AbortSignal, connectionId?: string): Promise<IntegrationResult<BatchSlot<PullRequestShape | undefined>[] | undefined>>;
827
+ protected getProviderPullRequestsForCommits(session: ProviderAuthenticationSession, repo: RepositoryCoordinate, shas: readonly string[], _options: {
828
+ mergeQueue?: boolean;
829
+ }, cancellation?: AbortSignal): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined>;
830
+ protected getProviderPullRequestForCommitInBatch?(session: ProviderAuthenticationSession, repo: T, sha: string, cancellation?: AbortSignal): Promise<PullRequest | undefined>;
831
+ protected commitFanOutGate(cancellation: AbortSignal | undefined): <R>(send: () => Promise<R>, stopsOn?: (reason: unknown) => boolean) => Promise<R>;
832
+ protected stopsCommitFanOut(reason: unknown, answered: boolean): boolean;
833
+ protected toCommitRepositoryDescriptor(repo: RepositoryCoordinate): T;
815
834
  /**
816
835
  * The PR twin of {@link countIssuesResult}: counts each scope's pull requests, transferring none where the
817
836
  * provider has a count query. Each slot is a {@link ProviderPullRequestCount}, so a provider that can only count
@@ -1,15 +1,16 @@
1
1
  import { first } from "../../../utils/iterable.js";
2
2
  import { ensureArray } from "../../../utils/array.js";
3
- import { isCancellationError } from "../../../utils/cancellation.js";
3
+ import { CancellationError, isCancellationError } from "../../../utils/cancellation.js";
4
4
  import { Logger as _logger } from "../../../utils/logger.js";
5
5
  import { getScopedLogger } from "../../../utils/logger.scoped.js";
6
6
  import { mapSettledBounded } from "../../../utils/promise.js";
7
7
  import { trace } from "../../../utils/decorators/log.js";
8
+ import { isUncommitted } from "../../../git/utils/revision.utils.js";
8
9
  import __decorate from "../../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
9
- import { RequestNotFoundError } from "../../../git/errors.js";
10
+ import { AuthenticationError, RequestNotFoundError, RequestRateLimitError } from "../../../git/errors.js";
10
11
  import { gate } from "../../../utils/decorators/gate.js";
11
12
  import "../../../git/models/pullRequest.js";
12
- import { toError } from "../errors.js";
13
+ import { IntegrationReadUnavailableError, LookupBackedOffError, isProviderUnreachableError, toError } from "../errors.js";
13
14
  import "../constants.js";
14
15
  import { isAzureProviderId } from "../providers/providerErrors.js";
15
16
  import { throwIfCallerContractError, toCollectionFailureError, toCollectionScopeFailure, toUnsettledScopeFailure, unsettledMissMessage } from "../collectionMetadata.js";
@@ -47,6 +48,22 @@ function rejectUnsettledMisses(slots, unsettled, isMiss) {
47
48
  reason: new Error(unsettledMissMessage)
48
49
  } : slot);
49
50
  }
51
+ function createCommitFanOutGate(stops, cancellation) {
52
+ let stopped;
53
+ let answered = false;
54
+ return async (send, stopsOn) => {
55
+ if (stopped != null) throw stopped;
56
+ if (cancellation?.aborted) throw new CancellationError();
57
+ try {
58
+ const result = await send();
59
+ answered = true;
60
+ return result;
61
+ } catch (ex) {
62
+ if (stopped == null && (stopsOn != null ? stopsOn(ex) : stops(ex, answered))) stopped = toError(ex);
63
+ throw ex;
64
+ }
65
+ };
66
+ }
50
67
  /**
51
68
  * The keys of the scopes {@link GitHostIntegration.resolveRepositoryInputs} couldn't settle, for a list read to record
52
69
  * a miss for one as a failure ({@link toUnsettledScopeFailure}) rather than as an empty scope.
@@ -254,7 +271,7 @@ var GitHostIntegration = class extends IntegrationBase {
254
271
  if (await this.prepareSessionLookup() != null) return void 0;
255
272
  return this.ctx.cache.getRepositoryMetadata(repo, this, (cacheable) => ({ value: (async () => {
256
273
  try {
257
- const result = await this.getProviderRepositoryMetadata(this._session, repo, options?.cancellation);
274
+ const result = await this.getProviderRepositoryMetadata(this._session, repo, options?.cancellation, { fresh: options?.expiryOverride === true });
258
275
  if (result == null && options?.cancellation?.aborted) {
259
276
  cacheable.invalidate();
260
277
  return;
@@ -263,7 +280,7 @@ var GitHostIntegration = class extends IntegrationBase {
263
280
  return result;
264
281
  } catch (ex) {
265
282
  if (!(ex instanceof RequestNotFoundError)) cacheable.invalidate();
266
- this.handleProviderException("getRepositoryMetadata", ex, { scope });
283
+ if (!(ex instanceof LookupBackedOffError)) this.handleProviderException("getRepositoryMetadata", ex, { scope });
267
284
  return;
268
285
  }
269
286
  })() }), { expiryOverride: options?.expiryOverride });
@@ -552,19 +569,65 @@ var GitHostIntegration = class extends IntegrationBase {
552
569
  if (throwOnError) throw refreshFailure;
553
570
  return;
554
571
  }
572
+ const fresh = cacheOptions.expiryOverride === true;
555
573
  return this.ctx.cache.getPullRequestForSha(rev, repo, this, (cacheable) => ({ value: (async () => {
574
+ const session = this._session;
575
+ const keys = this.getCommitLookupBackoffKeys(session, repo, rev);
576
+ if (!fresh) {
577
+ const now = Date.now();
578
+ const until = this.lookupBackoff.backedOffUntil(keys.repository, now) ?? this.lookupBackoff.backedOffUntil(keys.commit, now);
579
+ if (until != null) {
580
+ cacheable.invalidate();
581
+ if (throwOnError) throw new LookupBackedOffError(until, `The pull request lookup of ${rev}`);
582
+ return;
583
+ }
584
+ }
556
585
  try {
557
- const result = await this.getProviderPullRequestForCommit(this._session, repo, rev);
586
+ const result = await this.getProviderPullRequestForCommit(session, repo, rev, { fresh });
587
+ this.lookupBackoff.clear(keys.commit);
588
+ this.lookupBackoff.clear(keys.repository);
558
589
  this.resetRequestExceptionCount("getPullRequestForCommit");
559
590
  return result;
560
591
  } catch (ex) {
561
592
  cacheable.invalidate();
562
- this.handleProviderException("getPullRequestForCommit", ex, { scope });
593
+ const backoff = this.getCommitLookupBackoff(ex);
594
+ if (backoff != null) this.lookupBackoff.fail(backoff.scope === "repository" ? keys.repository : keys.commit, Date.now(), backoff.until);
595
+ if (!(ex instanceof LookupBackedOffError)) this.handleProviderException("getPullRequestForCommit", ex, { scope });
563
596
  if (throwOnError) throw ex;
564
597
  return;
565
598
  }
566
599
  })() }), cacheOptions);
567
600
  }
601
+ getCommitLookupBackoffKeys(session, repo, rev) {
602
+ const repository = JSON.stringify([
603
+ this.getSessionFingerprint(session),
604
+ session.domain,
605
+ session.baseUrl ?? "",
606
+ repo.key,
607
+ repo.owner,
608
+ repo.name,
609
+ repo.project
610
+ ]);
611
+ return {
612
+ repository,
613
+ commit: `${repository}@${rev}`
614
+ };
615
+ }
616
+ getCommitLookupBackoff(ex) {
617
+ if (isCancellationError(ex)) return ex.reason === "timeout" ? { scope: "repository" } : void 0;
618
+ if (ex instanceof AuthenticationError && ex.reason !== 3) return void 0;
619
+ if (ex instanceof LookupBackedOffError) return {
620
+ scope: "repository",
621
+ until: ex.until
622
+ };
623
+ if (ex instanceof IntegrationReadUnavailableError) return { scope: "repository" };
624
+ if (ex instanceof RequestRateLimitError) return {
625
+ scope: "repository",
626
+ until: ex.resetAt != null ? ex.resetAt * 1e3 : void 0
627
+ };
628
+ if (isProviderUnreachableError(ex)) return { scope: "repository" };
629
+ return { scope: "commit" };
630
+ }
568
631
  /**
569
632
  * Memoized identity lookups backing filter resolution. Keyed by the session's token fingerprint plus the
570
633
  * scope of the lookup (base URL, and the Azure organization for the per-instance variant), so a different
@@ -1440,7 +1503,11 @@ var GitHostIntegration = class extends IntegrationBase {
1440
1503
  };
1441
1504
  }
1442
1505
  const settled = await this.settleResolvedSlots(session, targets, slots, (issue) => issue == null);
1443
- this.resetRequestExceptionCount("getIssuesBatch", connectionId);
1506
+ this.settleBatchCredential("getIssuesBatch", settled, {
1507
+ scope,
1508
+ connectionId,
1509
+ reset: true
1510
+ });
1444
1511
  this.reportDeferredRequestFailures(settled, false, connectionId);
1445
1512
  return {
1446
1513
  value: settled,
@@ -1492,7 +1559,11 @@ var GitHostIntegration = class extends IntegrationBase {
1492
1559
  };
1493
1560
  }
1494
1561
  const settled = await this.settleResolvedSlots(session, targets, slots, (pr) => pr == null);
1495
- this.resetRequestExceptionCount("getPullRequestsBatch", connectionId);
1562
+ this.settleBatchCredential("getPullRequestsBatch", settled, {
1563
+ scope,
1564
+ connectionId,
1565
+ reset: true
1566
+ });
1496
1567
  this.reportDeferredRequestFailures(settled, false, connectionId);
1497
1568
  return {
1498
1569
  value: settled,
@@ -1526,7 +1597,11 @@ var GitHostIntegration = class extends IntegrationBase {
1526
1597
  };
1527
1598
  }
1528
1599
  const settled = await this.settleBatchRefusals(session, targets, slots);
1529
- this.resetRequestExceptionCount("getPullRequestCheckLogs", connectionId);
1600
+ this.settleBatchCredential("getPullRequestCheckLogs", settled, {
1601
+ scope,
1602
+ connectionId,
1603
+ reset: true
1604
+ });
1530
1605
  this.reportDeferredRequestFailures(settled, false, connectionId);
1531
1606
  return {
1532
1607
  value: settled,
@@ -1560,7 +1635,11 @@ var GitHostIntegration = class extends IntegrationBase {
1560
1635
  };
1561
1636
  }
1562
1637
  const settled = await this.settleBatchRefusals(session, targets, slots);
1563
- this.resetRequestExceptionCount("getPullRequestActivity", connectionId);
1638
+ this.settleBatchCredential("getPullRequestActivity", settled, {
1639
+ scope,
1640
+ connectionId,
1641
+ reset: true
1642
+ });
1564
1643
  this.reportDeferredRequestFailures(settled, false, connectionId);
1565
1644
  return {
1566
1645
  value: settled,
@@ -1605,7 +1684,11 @@ var GitHostIntegration = class extends IntegrationBase {
1605
1684
  duration: performance.now() - start
1606
1685
  };
1607
1686
  const settled = await this.settleResolvedSlots(session, targets, read, (fields) => fields == null, { keepOtherFailures: true });
1608
- if (settled.some((slot) => slot.status === "fulfilled")) this.resetRequestExceptionCount("getIssuesEtagFields", connectionId);
1687
+ this.settleBatchCredential("getIssuesEtagFields", settled, {
1688
+ scope,
1689
+ connectionId,
1690
+ reset: settled.some((slot) => slot.status === "fulfilled")
1691
+ });
1609
1692
  return {
1610
1693
  value: settled,
1611
1694
  duration: performance.now() - start
@@ -1642,7 +1725,11 @@ var GitHostIntegration = class extends IntegrationBase {
1642
1725
  duration: performance.now() - start
1643
1726
  };
1644
1727
  const settled = await this.settleResolvedSlots(session, targets, read, (fields) => fields == null, { keepOtherFailures: true });
1645
- if (settled.some((slot) => slot.status === "fulfilled")) this.resetRequestExceptionCount("getPullRequestsEtagFields", connectionId);
1728
+ this.settleBatchCredential("getPullRequestsEtagFields", settled, {
1729
+ scope,
1730
+ connectionId,
1731
+ reset: settled.some((slot) => slot.status === "fulfilled")
1732
+ });
1646
1733
  return {
1647
1734
  value: settled,
1648
1735
  duration: performance.now() - start
@@ -1690,7 +1777,11 @@ var GitHostIntegration = class extends IntegrationBase {
1690
1777
  };
1691
1778
  }
1692
1779
  const settled = await this.settleResolvedSlots(session, resolved, slots, (found) => found.pullRequests.length === 0 && !found.truncated);
1693
- this.resetRequestExceptionCount("getPullRequestsForBranches", connectionId);
1780
+ this.settleBatchCredential("getPullRequestsForBranches", settled, {
1781
+ scope,
1782
+ connectionId,
1783
+ reset: true
1784
+ });
1694
1785
  this.reportDeferredRequestFailures(settled, false, connectionId);
1695
1786
  return {
1696
1787
  value: settled,
@@ -1708,6 +1799,83 @@ var GitHostIntegration = class extends IntegrationBase {
1708
1799
  };
1709
1800
  }
1710
1801
  }
1802
+ async getPullRequestsForCommitsResult(repo, shas, options, cancellation, connectionId) {
1803
+ const scope = getScopedLogger();
1804
+ const session = await this.resolveReadSession(connectionId, scope);
1805
+ if (session == null || isReadSessionFailure(session)) return session && { error: session.error };
1806
+ const start = performance.now();
1807
+ const asked = shas.flatMap((sha, index) => isUncommitted(sha) ? [] : [index]);
1808
+ let slots;
1809
+ try {
1810
+ const resolved = await this.resolveRepositoryCoordinates(session, [repo], cancellation);
1811
+ const settledRepo = resolved.coordinates[0] ?? repo;
1812
+ slots = await this.getProviderPullRequestsForCommits(session, settledRepo, asked.map((index) => shas[index]), options, cancellation);
1813
+ if (slots == null) {
1814
+ this.resetRequestExceptionCount("getPullRequestsForCommits", connectionId);
1815
+ return {
1816
+ value: void 0,
1817
+ duration: performance.now() - start
1818
+ };
1819
+ }
1820
+ const unsettled = resolved.unsettled?.[0] === true;
1821
+ const settled = await this.settleResolvedSlots(session, {
1822
+ coordinates: asked.map(() => settledRepo),
1823
+ unsettled: asked.map(() => unsettled)
1824
+ }, slots, (pr) => pr == null);
1825
+ this.settleBatchCredential("getPullRequestsForCommits", settled, {
1826
+ scope,
1827
+ connectionId,
1828
+ reset: asked.length > 0
1829
+ });
1830
+ this.reportDeferredRequestFailures(settled, false, connectionId);
1831
+ const value = shas.map(() => ({
1832
+ status: "fulfilled",
1833
+ value: void 0
1834
+ }));
1835
+ asked.forEach((index, i) => {
1836
+ value[index] = settled[i];
1837
+ });
1838
+ return {
1839
+ value,
1840
+ duration: performance.now() - start
1841
+ };
1842
+ } catch (ex) {
1843
+ const struck = this.handleProviderException("getPullRequestsForCommits", ex, {
1844
+ scope,
1845
+ connectionId
1846
+ });
1847
+ this.reportDeferredRequestFailures(slots ?? [{
1848
+ status: "rejected",
1849
+ reason: ex
1850
+ }], !struck, connectionId);
1851
+ return {
1852
+ error: toError(ex),
1853
+ duration: performance.now() - start
1854
+ };
1855
+ }
1856
+ }
1857
+ getProviderPullRequestsForCommits(session, repo, shas, _options, cancellation) {
1858
+ const read = this.getProviderPullRequestForCommitInBatch?.bind(this);
1859
+ if (read == null) return Promise.resolve(void 0);
1860
+ const descriptor = this.toCommitRepositoryDescriptor(repo);
1861
+ const send = this.commitFanOutGate(cancellation);
1862
+ return mapSettledBounded(shas, 6, (sha) => send(() => read(session, descriptor, sha, cancellation)));
1863
+ }
1864
+ commitFanOutGate(cancellation) {
1865
+ return createCommitFanOutGate((reason, answered) => this.stopsCommitFanOut(reason, answered), cancellation);
1866
+ }
1867
+ stopsCommitFanOut(reason, answered) {
1868
+ if (reason instanceof RequestRateLimitError) return true;
1869
+ if (!(reason instanceof AuthenticationError)) return false;
1870
+ return reason.reason !== 3 || !answered;
1871
+ }
1872
+ toCommitRepositoryDescriptor(repo) {
1873
+ return {
1874
+ key: `${repo.owner}/${repo.repo}`,
1875
+ owner: repo.owner,
1876
+ name: repo.repo
1877
+ };
1878
+ }
1711
1879
  /**
1712
1880
  * The PR twin of {@link countIssuesResult}: counts each scope's pull requests, transferring none where the
1713
1881
  * provider has a count query. Each slot is a {@link ProviderPullRequestCount}, so a provider that can only count