@gitkraken/core-gitlens 0.58.0 → 0.60.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 (101) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/dist/git/context.d.ts +1 -0
  3. package/dist/git/context.js.map +1 -1
  4. package/dist/git/features.d.ts +1 -1
  5. package/dist/git/features.js +1 -0
  6. package/dist/git/features.js.map +1 -1
  7. package/dist/git/models/graph.d.ts +2 -1
  8. package/dist/git/models/graph.js.map +1 -1
  9. package/dist/git/models/graphSession.d.ts +8 -0
  10. package/dist/git/models/graphSession.js.map +1 -1
  11. package/dist/git/parsers/diffParser.js +1 -1
  12. package/dist/git/utils/hiddenRefs.utils.d.ts +26 -0
  13. package/dist/git/utils/hiddenRefs.utils.js +89 -0
  14. package/dist/git/utils/hiddenRefs.utils.js.map +1 -0
  15. package/dist/git/utils/search.utils.d.ts +3 -1
  16. package/dist/git/utils/search.utils.js +3 -1
  17. package/dist/git/utils/search.utils.js.map +1 -1
  18. package/dist/git-cli/exec/git.js +2 -1
  19. package/dist/git-cli/exec/git.js.map +1 -1
  20. package/dist/git-cli/exec/locator.d.ts +2 -1
  21. package/dist/git-cli/exec/locator.js +11 -3
  22. package/dist/git-cli/exec/locator.js.map +1 -1
  23. package/dist/git-cli/parsers/blameParser.js +1 -1
  24. package/dist/git-cli/parsers/indexParser.js +1 -1
  25. package/dist/git-cli/parsers/statusParser.js +1 -1
  26. package/dist/git-cli/providers/branches.js +1 -1
  27. package/dist/git-cli/providers/commits.js +3 -2
  28. package/dist/git-cli/providers/commits.js.map +1 -1
  29. package/dist/git-cli/providers/config.js +2 -2
  30. package/dist/git-cli/providers/graph.d.ts +11 -1
  31. package/dist/git-cli/providers/graph.js +156 -38
  32. package/dist/git-cli/providers/graph.js.map +1 -1
  33. package/dist/git-cli/providers/pausedOperations.js +2 -2
  34. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  35. package/dist/git-cli/providers/refs.js +1 -1
  36. package/dist/git-cli/providers/staging.js +1 -1
  37. package/dist/git-cli/providers/tags.js +1 -1
  38. package/dist/git-cli/service.js +1 -1
  39. package/dist/ipc/discovery.js +1 -1
  40. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  41. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  42. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  43. package/dist/plus/integrations/index.d.ts +2 -1
  44. package/dist/plus/integrations/index.js.map +1 -1
  45. package/dist/plus/integrations/integrationService.d.ts +7 -0
  46. package/dist/plus/integrations/integrationService.js +71 -8
  47. package/dist/plus/integrations/integrationService.js.map +1 -1
  48. package/dist/plus/integrations/manager.d.ts +6 -0
  49. package/dist/plus/integrations/models/azurePullRequestWrites.d.ts +3 -1
  50. package/dist/plus/integrations/models/gitlabIssueWrites.d.ts +86 -0
  51. package/dist/plus/integrations/models/gitlabIssueWrites.js +9 -0
  52. package/dist/plus/integrations/models/gitlabIssueWrites.js.map +1 -0
  53. package/dist/plus/integrations/models/integration.d.ts +1 -1
  54. package/dist/plus/integrations/models/integration.js +1 -1
  55. package/dist/plus/integrations/models/integration.js.map +1 -1
  56. package/dist/plus/integrations/models/issueTrackerWrites.d.ts +12 -3
  57. package/dist/plus/integrations/models/publicIntegration.d.ts +1 -0
  58. package/dist/plus/integrations/providers/azure/azure.js +1 -1
  59. package/dist/plus/integrations/providers/azure/models.d.ts +1 -1
  60. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  61. package/dist/plus/integrations/providers/azurePullRequestWriteErrors.d.ts +6 -2
  62. package/dist/plus/integrations/providers/azurePullRequestWriteErrors.js +44 -10
  63. package/dist/plus/integrations/providers/azurePullRequestWriteErrors.js.map +1 -1
  64. package/dist/plus/integrations/providers/azurePullRequestWrites.d.ts +1 -0
  65. package/dist/plus/integrations/providers/azurePullRequestWrites.js +28 -13
  66. package/dist/plus/integrations/providers/azurePullRequestWrites.js.map +1 -1
  67. package/dist/plus/integrations/providers/github.js +1 -1
  68. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +4 -1
  69. package/dist/plus/integrations/providers/gitlab/gitlab.js +4 -0
  70. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  71. package/dist/plus/integrations/providers/gitlab/issueWriteErrors.d.ts +11 -0
  72. package/dist/plus/integrations/providers/gitlab/issueWriteErrors.js +73 -0
  73. package/dist/plus/integrations/providers/gitlab/issueWriteErrors.js.map +1 -0
  74. package/dist/plus/integrations/providers/gitlab/issueWrites.d.ts +33 -0
  75. package/dist/plus/integrations/providers/gitlab/issueWrites.js +325 -0
  76. package/dist/plus/integrations/providers/gitlab/issueWrites.js.map +1 -0
  77. package/dist/plus/integrations/providers/gitlab.d.ts +7 -1
  78. package/dist/plus/integrations/providers/gitlab.js +24 -0
  79. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  80. package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
  81. package/dist/plus/integrations/providers/jira-server.d.ts +10 -0
  82. package/dist/plus/integrations/providers/jira-server.js +16 -1
  83. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  84. package/dist/plus/integrations/providers/jiraIssueWrites.d.ts +6 -0
  85. package/dist/plus/integrations/providers/jiraIssueWrites.js +60 -11
  86. package/dist/plus/integrations/providers/jiraIssueWrites.js.map +1 -1
  87. package/dist/plus/integrations/providers/providerApiClient.js +6 -2
  88. package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
  89. package/dist/plus/integrations/providers/providersApi.d.ts +3 -0
  90. package/dist/plus/integrations/providers/providersApi.js +13 -0
  91. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  92. package/dist/plus/integrations/reads/currentAccount.d.ts +1 -1
  93. package/dist/plus/integrations/reads/currentAccount.js +1 -1
  94. package/dist/plus/integrations/reads/currentAccount.js.map +1 -1
  95. package/dist/plus/integrations/reads/drains.d.ts +1 -0
  96. package/dist/plus/integrations/reads/issueTracker.js +4 -1
  97. package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
  98. package/dist/utils/env/node/exec.js +2 -2
  99. package/docs/integrations.md +65 -5
  100. package/docs/kepler-read-api-parity.md +2 -1
  101. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"integration.js","names":[],"sources":["../../../../../plus/integrations/src/models/integration.ts"],"sourcesContent":["import type { CollectionMetadata, CollectionScope } from '@gitkraken/provider-apis';\nimport { takeDeferredRequestFailure } from '@gitlens/git/errors.js';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { AutolinkReference, DynamicAutolinkReference } from '@gitlens/git/models/autolink.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequest } from '@gitlens/git/models/pullRequest.js';\nimport type { ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { CancellationError, isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug, trace } from '@gitlens/utils/decorators/log.js';\nimport type { Disposable } from '@gitlens/utils/disposable.js';\nimport type { Event } from '@gitlens/utils/event.js';\nimport { Emitter } from '@gitlens/utils/event.js';\nimport { fnv1aHash64 } from '@gitlens/utils/hash.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport type { ScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { PromiseCache } from '@gitlens/utils/promiseCache.js';\nimport { CloudIntegrationAuthenticationProvider } from '../authentication/cloudIntegrationAuthenticationProvider.js';\nimport type { CloudIntegrationSync } from '../authentication/cloudIntegrationObservations.js';\nimport type {\n\tIntegrationAuthenticationProviderDescriptor,\n\tIntegrationAuthenticationSessionDescriptor,\n} from '../authentication/integrationAuthenticationProvider.js';\nimport type {\n\tIntegrationAuthenticationService,\n\tTrackedSession,\n} from '../authentication/integrationAuthenticationService.js';\nimport type {\n\tConnectionResource,\n\tProviderAuthenticationSession,\n\tSessionPublication,\n} from '../authentication/models.js';\nimport { getSessionIdentity, isSameAuthenticationSession } from '../authentication/models.js';\nimport { RejectedTokenTracker } from '../authentication/rejectedTokenTracker.js';\nimport type { ProviderRefusal, ProviderScopeFailure } from '../collectionMetadata.js';\nimport {\n\tattributeScopedAuthFailures,\n\thasOnlyScopedAuthFailures,\n\tmarkCredentialRefusals,\n\ttoCollectionScopeFailure,\n} from '../collectionMetadata.js';\nimport type { IntegrationIds, IssuesHostIntegrationIds } from '../constants.js';\nimport { GitCloudHostIntegrationId } from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport {\n\tAuthenticationError,\n\tAuthenticationErrorReason,\n\tisProviderUnreachableError,\n\tRequestClientError,\n\ttoError,\n} from '../errors.js';\nimport type { IntegrationConnectionChangeEvent } from '../integrationService.js';\nimport { providersMetadata } from '../providers/metadata.js';\nimport { isAzureProviderId } from '../providers/providerErrors.js';\nimport type { ProvidersApi } from '../providers/providersApi.js';\nimport { throwIfAllSettledFailed } from '../providers/utils/providerPaging.js';\nimport type { ProviderWarningCause, ProviderWarningScope } from '../results.js';\nimport type { Sources } from '../telemetry.js';\nimport { areDomainsOnSameHost } from '../utils/domain.utils.js';\nimport { FailureBackoff } from '../utils/failureBackoff.js';\nimport { isSelfManagedHostIntegrationId } from '../utils/integration.utils.js';\nimport type { GitHostIntegration } from './gitHostIntegration.js';\nimport { getCachedIssue } from './issueCache.js';\nimport type { AccountWideIssuesResult, SearchMyIssuesOptions } from './issueReads.js';\nimport type { IssuesIntegration } from './issuesIntegration.js';\nimport type {\n\tIntegrationCacheDescriptor,\n\tIntegrationConnectedKey,\n\tIntegrationCredential,\n\tIntegrationKey,\n\tIntegrationResult,\n\tIntegrationType,\n} from './publicIntegration.js';\n\nexport type Integration = GitHostIntegration | IssuesIntegration;\nexport type IntegrationById<T extends IntegrationIds> = T extends IssuesHostIntegrationIds\n\t? IssuesIntegration\n\t: GitHostIntegration;\n\n// The issue-read contracts live in their own module (pure data, and their relationship to each other is the\n// point of reading them together); re-exported here so the providers that implement these reads keep one import.\nexport type {\n\tAccountWideIssuesResult,\n\tProviderIssueSearchPage,\n\tProviderSearchCount,\n\tSearchMyIssuesOptions,\n} from './issueReads.js';\nexport type { ProviderPullRequestCount, ProviderPullRequestSearchPage } from './pullRequestReads.js';\n\n/** A per-connection read's session that could not be resolved for a retryable reason (see `resolveReadSession`). */\nexport class ReadSessionFailure {\n\tconstructor(readonly error: Error) {}\n}\n\nexport function isReadSessionFailure(\n\tsession: ProviderAuthenticationSession | ReadSessionFailure | undefined,\n): session is ReadSessionFailure {\n\treturn session instanceof ReadSessionFailure;\n}\n\n/**\n * One target's answer in a batch read. A slot rejected by an authentication refusal carries the scope failure it was\n * recorded as (see `IntegrationBase.settleBatchRefusals`).\n */\nexport type BatchSlot<T> = PromiseFulfilledResult<T> | (PromiseRejectedResult & { failure?: ProviderScopeFailure });\n\n/** A batch read's target, in the form its provider addresses it by: a repository coordinate, or a tracker's resource. */\ntype BatchTarget = { owner: string; repo: string; project?: string } | { resourceId: string };\n\nfunction batchTargetRepository(target: BatchTarget): string | undefined {\n\tif ('resourceId' in target) return undefined;\n\n\treturn [target.owner, target.project ?? '', target.repo].join('/').toLowerCase();\n}\n\nfunction isRefusedCredential(reason: unknown): reason is AuthenticationError {\n\treturn reason instanceof AuthenticationError && reason.reason !== AuthenticationErrorReason.Forbidden;\n}\n\nfunction findRefusedCredentialSlot<T>(\n\tslots: readonly BatchSlot<T>[],\n): (PromiseRejectedResult & { reason: AuthenticationError }) | undefined {\n\treturn slots.find(\n\t\t(slot): slot is PromiseRejectedResult & { reason: AuthenticationError } =>\n\t\t\tslot.status === 'rejected' && slot.failure == null && isRefusedCredential(slot.reason),\n\t);\n}\n\n/**\n * The scope a batch read records a refused target under. It is decided here rather than in the read, which has the\n * same targets, because naming the refusal's cause (`describeRefusal`) needs it too. Azure DevOps: the organization\n * and project, since its refusals come from those (an organization's OAuth policy or tenant, a project's permissions)\n * and its work items belong to no repository. Every other git host: the repository, `owner/repo`, which is how its\n * repo-scoped reads record one. A tracker: the resource.\n */\nfunction batchTargetScope(providerId: IntegrationIds, target: BatchTarget): CollectionScope {\n\tif ('resourceId' in target) return { providerId: providerId, resourceId: target.resourceId };\n\tif (isAzureProviderId(providerId)) {\n\t\treturn { providerId: providerId, resourceId: target.owner, projectId: target.project };\n\t}\n\treturn { providerId: providerId, repositoryId: `${target.owner}/${target.repo}` };\n}\n\ntype SyncReqUsecase = Exclude<\n\t| 'getAccountForCommit'\n\t| 'getAccountForEmail'\n\t| 'getAccountForResource'\n\t| 'getCurrentAccount'\n\t| 'getDefaultBranch'\n\t| 'getIssue'\n\t| 'getIssueOrPullRequest'\n\t| 'getIssuesBatch'\n\t| 'getIssuesEtagFields'\n\t| 'getIssuesForProject'\n\t| 'getIssuesForRepos'\n\t| 'getMyPullRequestsForUser'\n\t| 'getOrganizationsForUser'\n\t| 'getProjectsForOrg'\n\t| 'getProjectsForResources'\n\t| 'getPullRequest'\n\t| 'getPullRequestActivity'\n\t| 'getPullRequestCheckLogs'\n\t| 'getPullRequestsBatch'\n\t| 'getPullRequestsEtagFields'\n\t| 'getPullRequestsForBranches'\n\t| 'getPullRequestsForCommits'\n\t| 'getRepositoriesForOrg'\n\t| 'getRepositoriesForUser'\n\t| 'getPullRequestForBranch'\n\t| 'getPullRequestForCommit'\n\t| 'getPullRequestsForRepos'\n\t| 'getRepositoryMetadata'\n\t| 'getResourcesForUser'\n\t| 'getSshSigningKeysForEmails'\n\t| 'countIssues'\n\t| 'countPullRequests'\n\t| 'dequeuePullRequest'\n\t| 'enqueuePullRequest'\n\t| 'mergePullRequest'\n\t| 'mutateIssue'\n\t| 'writePullRequest'\n\t| 'searchIssuesPage'\n\t| 'searchPullRequestsPage'\n\t| 'searchMyIssues'\n\t| 'searchMyPullRequests'\n\t| 'searchPullRequests',\n\t// excluding to show explicitly that we don't want to add 'all' key occasionally\n\t'all'\n>;\n\nexport abstract class IntegrationBase<\n\tID extends IntegrationIds = IntegrationIds,\n\tT extends ResourceDescriptor = ResourceDescriptor,\n> implements Disposable {\n\tabstract readonly type: IntegrationType;\n\n\tprivate readonly _onDidChange = new Emitter<void>();\n\tget onDidChange(): Event<void> {\n\t\treturn this._onDidChange.event;\n\t}\n\n\tconstructor(\n\t\tprotected readonly ctx: IntegrationServiceContext,\n\t\tprotected readonly authenticationService: IntegrationAuthenticationService,\n\t\tprotected readonly getProvidersApi: () => Promise<ProvidersApi>,\n\t\tprivate readonly didChangeConnection: Emitter<IntegrationConnectionChangeEvent>,\n\t) {}\n\n\tdispose(): void {\n\t\tthis.invalidateDiscoveryCaches();\n\t\tthis._onDidChange.dispose();\n\t}\n\n\tabstract get authProvider(): IntegrationAuthenticationProviderDescriptor;\n\tabstract get id(): ID;\n\tprotected abstract get key(): IntegrationKey<ID>;\n\tabstract get name(): string;\n\tabstract get domain(): string;\n\n\tget authProviderDescriptor(): IntegrationAuthenticationSessionDescriptor {\n\t\treturn { domain: this.domain, scopes: this.authProvider.scopes };\n\t}\n\n\t/**\n\t * The `gl-provider-<key>` glicon key for this provider, which is NOT always its id.\n\t *\n\t * `providersMetadata.iconKey` is the field that says which glyph a provider draws with, and a\n\t * self-managed variant reuses its cloud family's — Jira Data Center draws with Jira's, because it is the\n\t * same product and the id only selects an icon. Returning the id instead named a glyph the registry has\n\t * no entry for, so a consumer rendering a `gl-provider-` glicon from `issue.provider.icon` requested a\n\t * glyph that does not exist.\n\t */\n\tget icon(): string {\n\t\treturn providersMetadata[this.id]?.iconKey ?? this.id;\n\t}\n\n\taccess(): Promise<boolean> {\n\t\treturn this.ctx.account.isTrialOrPaid();\n\t}\n\n\tautolinks():\n\t\t| (AutolinkReference | DynamicAutolinkReference)[]\n\t\t| Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\treturn [];\n\t}\n\n\tprivate get connectedKey(): IntegrationConnectedKey<ID> {\n\t\treturn `connected:${this.key}`;\n\t}\n\n\tget maybeConnected(): boolean | undefined {\n\t\treturn this._session === undefined ? undefined : this._session !== null;\n\t}\n\n\t/** Hash of the current session's access token. Changes on any token change (account switch or refresh). */\n\tprivate _sessionFingerprint: { session: ProviderAuthenticationSession; hash: string } | undefined;\n\tget sessionFingerprint(): string | undefined {\n\t\tif (this._session == null) return undefined;\n\n\t\tif (this._sessionFingerprint?.session !== this._session) {\n\t\t\tthis._sessionFingerprint = { session: this._session, hash: this.getSessionFingerprint(this._session) };\n\t\t}\n\t\treturn this._sessionFingerprint.hash;\n\t}\n\n\tprotected getSessionFingerprint(session: ProviderAuthenticationSession): string {\n\t\treturn fnv1aHash64(session.accessToken);\n\t}\n\n\tprotected getPullRequestCacheDescriptor(_session: ProviderAuthenticationSession): IntegrationCacheDescriptor {\n\t\treturn this;\n\t}\n\n\tget connectionExpired(): boolean | undefined {\n\t\tif (this._session?.expiresAt == null) return undefined;\n\t\treturn new Date(this._session.expiresAt) < new Date();\n\t}\n\n\tprotected _session: ProviderAuthenticationSession | null | undefined;\n\t/**\n\t * Every change to the session (a resolution, a forced re-sync, a disconnect, a reauthentication, a connection\n\t * switch, a refused token) runs here, one at a time. Each one reads storage and the cloud and then settles\n\t * `_session`, the stored tokens and the connected flag; run concurrently, one would publish what it read over\n\t * what another settled meanwhile (gitkraken/kepler#3546). Reads don't queue: they read `_session` as it is.\n\t */\n\tprivate _sessionTransitions: Promise<void> = Promise.resolve();\n\t/**\n\t * Runs `fn` after every transition queued before it. `fn` must not queue another transition and wait for it,\n\t * which would wait for itself: inside a transition, call the `*Locked` methods instead.\n\t */\n\tprotected runSessionTransition<T>(fn: () => Promise<T>): Promise<T> {\n\t\tconst run = this._sessionTransitions.then(fn);\n\t\tthis._sessionTransitions = run.then(\n\t\t\t() => undefined,\n\t\t\t() => undefined,\n\t\t);\n\t\treturn run;\n\t}\n\n\t/** An expired session is refreshed first; when that fails, nothing is returned rather than a token the provider refuses. */\n\tgetSession(\n\t\tsource: Sources,\n\t): ProviderAuthenticationSession | Promise<ProviderAuthenticationSession | undefined> | undefined {\n\t\t// Served as is even while a transition runs: a forced re-sync keeps the session it is replacing, and a read\n\t\t// meanwhile reads with it rather than waiting on the cloud.\n\t\tif (this._session === undefined) {\n\t\t\treturn this.ensureSession({ createIfNeeded: false, source: source });\n\t\t}\n\t\tif (this._session == null || !this.isSessionForIntegrationHost(this._session)) return undefined;\n\t\tif (this.connectionExpired) return this.getRefreshedSession();\n\n\t\treturn this._session;\n\t}\n\n\t/** {@link getSession}'s token, for a consumer of the public view, which never sees the session itself. */\n\tasync getCredential(source: Sources): Promise<IntegrationCredential | undefined> {\n\t\tconst session = await this.getSession(source);\n\t\tif (session == null) return undefined;\n\n\t\treturn { providerId: this.authProvider.id, accessToken: session.accessToken };\n\t}\n\n\tprivate async getRefreshedSession(): Promise<ProviderAuthenticationSession | undefined> {\n\t\tconst failure = await this.refreshSessionIfExpired();\n\t\tif (failure != null) return undefined;\n\n\t\t// The refresh may have been skipped (a non-cloud session) or overtaken by a disconnect or a switch.\n\t\treturn this._session != null &&\n\t\t\tthis.connectionExpired !== true &&\n\t\t\tthis.isSessionForIntegrationHost(this._session)\n\t\t\t? this._session\n\t\t\t: undefined;\n\t}\n\n\tprotected isIntegrationAccessEnabled(): boolean {\n\t\treturn (\n\t\t\tthis.ctx.config.isIntegrationsEnabled?.() !== false &&\n\t\t\tthis.ctx.storage.getWorkspace(this.connectedKey) !== false\n\t\t);\n\t}\n\n\tprivate isSessionForIntegrationHost(session: ProviderAuthenticationSession): boolean {\n\t\tif (!isSelfManagedHostIntegrationId(this.id)) return true;\n\n\t\treturn areDomainsOnSameHost(this.domain, session.domain);\n\t}\n\n\t/**\n\t * Resolves the session to read as, for a per-connection (multi-account) read. When `connectionId` is\n\t * omitted this is the integration's primary session, resolved exactly like the existing read flow\n\t * (ensure-connected + refresh-if-expired). When set, it resolves THAT connection's session directly\n\t * from the auth provider — refreshing it if expired — WITHOUT disturbing the cached primary\n\t * `_session`. Never throws: `undefined` when there is no session to read with (the connection is gone,\n\t * the provider isn't connected), `{ error }` when the connection's token could not be fetched.\n\t *\n\t * The two must not be conflated. A token fetch that THROWS is, by `getConnectionSession`'s contract, a\n\t * retryable failure (a rate-limited or failing GK API, a network error), not evidence that the connection is\n\t * gone (#5569). Answering \"no session\" for it made every connection read during a GK API 429 report\n\t * `no-connection`, which a consumer rightly treats as a credential to reconnect (gitkraken/kepler#3546).\n\t * Returned as the read's error instead, the read core surfaces it like any other failed request: a rate\n\t * limit as `rate-limit`, anything else as `other`.\n\t */\n\tprotected async resolveReadSession(\n\t\tconnectionId: string | undefined,\n\t\tscope: ScopedLogger | undefined,\n\t\tsource?: Sources,\n\t\tcloud = true,\n\t): Promise<ProviderAuthenticationSession | ReadSessionFailure | undefined> {\n\t\tif (!this.isIntegrationAccessEnabled()) return undefined;\n\n\t\t// A truthy connectionId targets a specific account; an empty string is not a real target, so it falls\n\t\t// through to the primary path below.\n\t\tif (connectionId) {\n\t\t\t// The provider previously refused this connection's token. Ask for a refresh before using it again, which\n\t\t\t// is this branch's equivalent of the primary path's `refreshSessionIfExpired`. Claimed here so\n\t\t\t// the forced refresh runs at most once per rejection.\n\t\t\tconst rejectedToken = this._rejectedTokens.claimRefresh(connectionId);\n\t\t\t// Never throws, matching the primary path (whose ensureSession/refreshSessionIfExpired swallow\n\t\t\t// errors), so read methods keep their never-throws contract.\n\t\t\ttry {\n\t\t\t\tconst authProvider = await this.authenticationService.get(this.authProvider.id);\n\t\t\t\tconst session = await authProvider.getSession(\n\t\t\t\t\t{ ...this.authProviderDescriptor, connectionId: connectionId, cloud: cloud },\n\t\t\t\t\t{\n\t\t\t\t\t\tsource: source,\n\t\t\t\t\t\trefreshRejectedToken: rejectedToken === true,\n\t\t\t\t\t\tisRejectedToken: typeof rejectedToken === 'function' ? rejectedToken : undefined,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn session != null && this.isSessionForIntegrationHost(session) ? session : undefined;\n\t\t\t} catch (ex) {\n\t\t\t\tif (isCancellationError(ex)) return undefined;\n\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn new ReadSessionFailure(toError(ex));\n\t\t\t}\n\t\t}\n\n\t\tconst connected = this.maybeConnected ?? (await this.isConnected());\n\t\tif (!connected) return undefined;\n\n\t\t// The primary path's equivalent of the per-connection failure above: an expired session the cloud could not\n\t\t// replace right now is the refresh's failure, not a missing connection, and is never read with.\n\t\tconst refreshFailure = await this.refreshSessionIfExpired();\n\t\tif (refreshFailure != null) return new ReadSessionFailure(refreshFailure);\n\n\t\treturn this._session != null && this.isSessionForIntegrationHost(this._session) ? this._session : undefined;\n\t}\n\n\t/**\n\t * The session lookups' prelude for a caller that can surface a failure (`throwOnError`): the refresh's failure to\n\t * report, or `'unconnected'`, so a throttled refresh is not mistaken for \"no pull request\" and kept.\n\t */\n\tprotected async prepareSessionLookup(): Promise<Error | 'unconnected' | undefined> {\n\t\tconst connected = this.maybeConnected ?? (await this.isConnected());\n\t\tif (!connected) return 'unconnected';\n\n\t\tconst failure = await this.refreshSessionIfExpired();\n\t\tif (failure != null) return failure;\n\n\t\t// A disconnect, or a refetch the cloud answered for another host, can leave no session to read with.\n\t\treturn this._session != null ? undefined : 'unconnected';\n\t}\n\n\t/**\n\t * {@link resolveReadSession} for a read that already rethrows its provider's failures (a repository or account\n\t * lookup), or whose callers treat any failure as \"nothing to show\": a token that could not be fetched is\n\t * thrown like those failures, so it is classified as the failed request it is rather than as a missing\n\t * connection.\n\t */\n\tprotected async resolveReadSessionOrThrow(\n\t\tconnectionId: string | undefined,\n\t\tscope: ScopedLogger | undefined,\n\t\tcloud = true,\n\t): Promise<ProviderAuthenticationSession | undefined> {\n\t\tconst session = await this.resolveReadSession(connectionId, scope, undefined, cloud);\n\t\tif (isReadSessionFailure(session)) throw session.error;\n\n\t\treturn session;\n\t}\n\n\tprotected trackWriteSession(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { cloud: boolean; observeHostChanges: boolean },\n\t): TrackedSession {\n\t\tconst verify = async () => {\n\t\t\tconst current = await this.resolveReadSessionOrThrow(session.id, undefined, options?.cloud);\n\t\t\treturn current != null && isSameAuthenticationSession(current, session);\n\t\t};\n\t\treturn this.authenticationService.trackIssuedSession(this.id, session, verify, options?.observeHostChanges);\n\t}\n\n\t@debug()\n\tasync connect(source: Sources): Promise<boolean> {\n\t\ttry {\n\t\t\treturn Boolean(await this.ensureSession({ createIfNeeded: true, source: source }));\n\t\t} catch (_ex) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprotected providerOnConnect?(): void | Promise<void>;\n\n\t@gate()\n\t@debug()\n\tasync disconnect(options?: { silent?: boolean; currentSessionOnly?: boolean }): Promise<void> {\n\t\tif (options?.currentSessionOnly && this._session === null) return;\n\n\t\tlet signOut = !options?.currentSessionOnly;\n\n\t\t// Asked before queueing: the user's answer can take any time, and the queue must not wait on it.\n\t\tif (this._session != null && !options?.currentSessionOnly && !options?.silent) {\n\t\t\tconst decision = await this.ctx.hooks?.onConfirmDisconnect?.({\n\t\t\t\tintegrationName: this.name,\n\t\t\t\tofferSignOut: this.authenticationService.supports(this.authProvider.id),\n\t\t\t});\n\t\t\tif (decision == null) return;\n\n\t\t\tsignOut = decision.signOut;\n\t\t}\n\n\t\t// Waits for a forced re-sync in flight, so the session it settles cannot land over the disconnect.\n\t\tawait this.runSessionTransition(() => this.disconnectLocked(options, signOut));\n\t}\n\n\tprivate async disconnectLocked(\n\t\toptions: { silent?: boolean; currentSessionOnly?: boolean } | undefined,\n\t\tsignOut: boolean,\n\t\tauthority?: CloudIntegrationSync,\n\t): Promise<boolean> {\n\t\tif (options?.currentSessionOnly && this._session === null) return false;\n\n\t\tconst connected = this._session != null;\n\n\t\tif (authority != null) {\n\t\t\tconst cleared = await this.authenticationService.clearAbsentCloudScope(\n\t\t\t\tthis.authProvider.id,\n\t\t\t\tthis.authProviderDescriptor,\n\t\t\t\tauthority,\n\t\t\t);\n\t\t\tif (\n\t\t\t\t!cleared ||\n\t\t\t\t!this.authenticationService.isCloudListCurrent(this.authProvider.id, this.domain, authority)\n\t\t\t) {\n\t\t\t\tthis._session = undefined;\n\t\t\t\tthis.invalidateDiscoveryCaches();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (signOut) {\n\t\t\tconst authProvider = await this.authenticationService.get(this.authProvider.id);\n\t\t\tawait authProvider.deleteAllSessions(this.authProviderDescriptor);\n\t\t}\n\n\t\tthis.resetRequestExceptionCount('all');\n\t\tthis._session = null;\n\n\t\tif (connected) {\n\t\t\t// Don't store the disconnected flag if silently disconnecting or disconnecting this only for\n\t\t\t// this current VS Code session (will be re-connected on next restart)\n\t\t\tif (!options?.currentSessionOnly && !options?.silent) {\n\t\t\t\tvoid this.ctx.storage.storeWorkspace(this.connectedKey, false).catch();\n\t\t\t}\n\n\t\t\tthis._onDidChange.fire();\n\t\t\t// Fired even for a session-only disconnect: the integration IS disconnected until it reconnects, and the\n\t\t\t// service's connected-key cache only forgets the key on this event — skipped, listeners kept showing it\n\t\t\t// connected and the cache swallowed the eventual reconnect as a duplicate\n\t\t\tthis.didChangeConnection?.fire({ integration: this, key: this.key, reason: 'disconnected' });\n\t\t}\n\n\t\tawait this.providerOnDisconnect?.();\n\t\treturn true;\n\t}\n\n\tprotected providerOnDisconnect?(): void | Promise<void>;\n\n\t@debug()\n\tasync reauthenticate(): Promise<void> {\n\t\t// `forceNewSession` below deletes the stored secrets to reconnect. Ahead of the guard — see\n\t\t// `onStoredTokensReplaced`.\n\t\tthis.onStoredTokensReplaced();\n\n\t\tconst cleared = await this.runSessionTransition(() => {\n\t\t\tif (this._session === undefined) return Promise.resolve(false);\n\n\t\t\tthis._session = undefined;\n\t\t\treturn Promise.resolve(true);\n\t\t});\n\t\tif (!cleared) return;\n\n\t\tvoid (await this.ensureSession({ createIfNeeded: true, forceNewSession: true }));\n\t}\n\n\trefresh(): void {\n\t\tvoid this.ensureSession({ createIfNeeded: false });\n\t}\n\n\t/**\n\t * Drops the cached session when its token is no longer `accessToken` (a session replaced outside the\n\t * integration) and resolves it again, in one transition, so nothing in flight publishes the replaced one.\n\t */\n\tprotected resyncSessionIfTokenChanged(accessToken: string | undefined): Promise<void> {\n\t\treturn this.runSessionTransition(async () => {\n\t\t\tif (this._session != null && this._session.accessToken !== accessToken) {\n\t\t\t\tthis._session = undefined;\n\t\t\t}\n\t\t\tawait this.resolveSessionLocked({ createIfNeeded: false });\n\t\t});\n\t}\n\n\tprivate _syncRequestsPerFailedUsecase = new Set<SyncReqUsecase>();\n\thasSessionSyncRequests(): boolean {\n\t\treturn this._syncRequestsPerFailedUsecase.size > 0;\n\t}\n\trequestSessionSyncForUsecase(syncReqUsecase: SyncReqUsecase): void {\n\t\tthis._syncRequestsPerFailedUsecase.add(syncReqUsecase);\n\t}\n\n\t/**\n\t * The per-connection counterpart of the primary session's expire-and-resync recovery: a token the\n\t * provider refused is refreshed once through the GK cloud, which exchanges the refresh token server-side\n\t * (the client never holds one). Armed by {@link handleConnectionAuthenticationRejection} and consumed by\n\t * {@link resolveReadSession}; a rejection it declines belongs to {@link trackRequestException} instead.\n\t */\n\tprivate readonly _rejectedTokens = new RejectedTokenTracker();\n\tprotected readonly lookupBackoff = new FailureBackoff();\n\n\tprotected clearLookupBackoff(): void {\n\t\tthis.lookupBackoff.clearAll();\n\t}\n\n\t/**\n\t * Called by every path that replaces or removes the stored tokens — a disconnect, a forced re-sync, a\n\t * reauthentication, or the connection set changing. A rejection names a specific credential, so once that\n\t * credential is gone the rejection describes nothing and must not force a refresh (or, for a deleted\n\t * connection, outlive it).\n\t *\n\t * Deliberately NOT conditioned on `_session`. A per-connection read resolves through the auth provider and\n\t * never populates the cached primary session, so the connections this recovery exists for are exactly the\n\t * ones with no `_session` to inspect — the same blind spot the recovery itself was added to fix. Callers\n\t * that guard on `_session` therefore invoke this ahead of that guard.\n\t */\n\tprotected onStoredTokensReplaced(): void {\n\t\tthis._rejectedTokens.clear();\n\t\tthis.clearLookupBackoff();\n\t\tthis.invalidateDiscoveryCaches();\n\t}\n\n\t/**\n\t * Drops what this integration discovered through its session and kept for later reads: a tracker's sites,\n\t * projects or teams. Called by every path that replaces the stored tokens (see {@link onStoredTokensReplaced}),\n\t * which includes the forced re-sync a consumer's refresh runs, and by a read asked to `forceSync`. A refresh is\n\t * the consumer saying the account may have changed, and a project created or deleted since the first read would\n\t * otherwise stay invisible, or keep being searched, for the rest of the session (#5907).\n\t */\n\tinvalidateDiscoveryCaches(): void {}\n\n\tinvalidateDiscoveryForConnection(_connectionId?: string): void {\n\t\tthis.invalidateDiscoveryCaches();\n\t}\n\n\t/**\n\t * The one owner of the drop a forced refresh makes before its sync, so it never serves a discovery list cached\n\t * before it: drops the discovery of `connectionId` (the primary when omitted), whether the sync then succeeds,\n\t * fails transiently and keeps the stored token, or hands back the same token (a PAT always does).\n\t *\n\t * Called once per forced refresh, by the path that runs its sync: an explicit forced re-sync of the primary\n\t * ({@link syncCloudConnection}, run by a primary `forceSync` read and by `refreshConnections`), and a\n\t * per-connection `forceSync` read, whose re-sync goes through the auth provider and never reaches it. An `expired`\n\t * re-sync is not a refresh the caller asked for and keeps its discovery. A strict autolinks refresh also drops at\n\t * completion, a separate drop that retires the reads started while it was pending (see `getAutolinkReferences`).\n\t */\n\tbeginForcedRefresh(connectionId?: string): void {\n\t\tthis.invalidateDiscoveryForConnection(connectionId);\n\t}\n\n\tgetSessionDiscoveryGeneration(_sessionId?: string, _connectionId?: string, _cloud?: boolean): number {\n\t\treturn this.discoveryGeneration;\n\t}\n\n\tget discoveryGeneration(): number {\n\t\treturn 0;\n\t}\n\n\tprotected isResolvedSessionCurrent(\n\t\t_session: ProviderAuthenticationSession | undefined,\n\t\t_generation: number,\n\t): boolean {\n\t\treturn true;\n\t}\n\n\tonSessionPublishing(publication: SessionPublication): void {\n\t\tconst { session, previousSessionId, replacePrimary } = publication;\n\t\tconst cloud = session != null ? session.cloud : publication.cloud;\n\t\tconst sameVariant = cloud == null || this._session?.cloud == null || cloud === this._session.cloud;\n\t\tconst affectsPrimary =\n\t\t\t(replacePrimary === true && (session != null || cloud == null || (this._session != null && sameVariant))) ||\n\t\t\t(this._session === null && session != null) ||\n\t\t\t(this._session != null &&\n\t\t\t\tsameVariant &&\n\t\t\t\t(session?.id === this._session.id || previousSessionId === this._session.id));\n\t\tif (affectsPrimary && getSessionIdentity(this._session) !== getSessionIdentity(session)) {\n\t\t\tthis._session = undefined;\n\t\t}\n\t\tthis.invalidatePublishedSession(publication, affectsPrimary);\n\t}\n\n\tprotected invalidatePublishedSession(_publication: SessionPublication, _affectsPrimary: boolean): void {\n\t\tthis.invalidateDiscoveryCaches();\n\t}\n\n\tonCloudConnectionRetired(connectionId: string, retained = false): void {\n\t\tconst wasConnected = this._session?.cloud === true && this._session.id === connectionId;\n\t\tthis.onSessionPublishing({ previousSessionId: connectionId, connectionId: connectionId, cloud: true });\n\t\tif (!wasConnected || retained) return;\n\n\t\tthis._onDidChange.fire();\n\t\tthis.didChangeConnection.fire({ integration: this, key: this.key, reason: 'disconnected' });\n\t\tvoid this.providerOnDisconnect?.();\n\t}\n\n\tonSessionsRemoving(connectionId?: string, cloud?: boolean): void {\n\t\tthis.invalidatePublishedSession(\n\t\t\t{\n\t\t\t\tpreviousSessionId: connectionId,\n\t\t\t\tconnectionId: connectionId,\n\t\t\t\tcloud: cloud,\n\t\t\t\tretireAll: connectionId == null,\n\t\t\t},\n\t\t\tfalse,\n\t\t);\n\t}\n\n\tprivate static readonly requestExceptionLimit = 5;\n\t/** The primary connection's strikes (see {@link trackRequestException}). */\n\tprivate requestExceptionCount = 0;\n\t/** The strikes of every other connection, by connection id. */\n\tprivate readonly connectionRequestExceptionCounts = new Map<string, number>();\n\n\t/**\n\t * The connection a read's strikes and successes count against: `undefined` for the primary, which a read reaches\n\t * by omitting `connectionId` or by naming it, else the connection named. The primary is named by its session's id,\n\t * which is its connection's id, or, before that session is resolved, by the connection configured as primary.\n\t */\n\tprivate getSecondaryConnectionId(connectionId: string | undefined): string | undefined {\n\t\tif (!connectionId || connectionId === this._session?.id) return undefined;\n\t\tif (\n\t\t\tconnectionId ===\n\t\t\tthis.authenticationService.getPrimaryConnectionId(this.authProvider.id, this.authProviderDescriptor)\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn connectionId;\n\t}\n\n\tprivate resetRecoveryAccounting(): void {\n\t\tthis.requestExceptionCount = 0;\n\t\tthis.connectionRequestExceptionCounts.clear();\n\t\tthis._syncRequestsPerFailedUsecase.clear();\n\t\tthis._rejectedTokens.clear();\n\t\tthis.clearLookupBackoff();\n\t}\n\n\t/**\n\t * Clears the strikes of the selected connection (the primary when omitted) after a successful request,\n\t * or of every connection for `'all'`.\n\t */\n\tresetRequestExceptionCount(syncReqUsecase: SyncReqUsecase | 'all', connectionId?: string): void {\n\t\tif (syncReqUsecase === 'all') {\n\t\t\tthis.resetRecoveryAccounting();\n\t\t\tthis.invalidateDiscoveryCaches();\n\t\t\treturn;\n\t\t}\n\n\t\tconst secondary = this.getSecondaryConnectionId(connectionId);\n\t\tif (secondary != null) {\n\t\t\tthis.connectionRequestExceptionCounts.delete(secondary);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.requestExceptionCount = 0;\n\t\t// Only the primary session's refused token requests a re-sync.\n\t\tthis._syncRequestsPerFailedUsecase.delete(syncReqUsecase);\n\t}\n\n\t/**\n\t * Resets the primary connection's request exceptions without resetting the amount of syncs\n\t */\n\tsmoothifyRequestExceptionCount(): void {\n\t\t// On resync we reset exception count only to avoid infinitive syncs on failure\n\t\tthis.requestExceptionCount = 0;\n\t}\n\n\tasync reset(): Promise<void> {\n\t\tawait this.runSessionTransition(async () => {\n\t\t\tawait this.disconnectLocked({ silent: true }, true);\n\t\t\tawait this.ctx.storage.deleteWorkspace(this.connectedKey);\n\t\t});\n\t}\n\n\t/**\n\t * Drops the in-memory session so the next access re-resolves it from storage. Used when the primary\n\t * connection changed underneath a warm integration (e.g. after `setPrimaryConnection`/\n\t * `deleteConnection`). Unlike {@link reset}/{@link disconnect}, it deletes nothing from storage.\n\t */\n\tswitchConnection(): Promise<void> {\n\t\t// A connection was deleted, or a different one became primary. Ahead of the guard — see\n\t\t// `onStoredTokensReplaced`.\n\t\tthis.onStoredTokensReplaced();\n\t\t// The strikes are kept by role, so the former primary's would otherwise pass to the new one.\n\t\tthis.requestExceptionCount = 0;\n\t\tthis.connectionRequestExceptionCounts.clear();\n\n\t\t// Queued, so a resolution already running finishes with the former primary and this one then re-resolves.\n\t\treturn this.runSessionTransition(async () => {\n\t\t\tif (this._session === undefined) return;\n\n\t\t\tconst wasConnected = this._session != null;\n\t\t\tthis._session = undefined;\n\t\t\tthis._onDidChange.fire();\n\n\t\t\tconst session = await this.resolveSessionLocked({ createIfNeeded: false });\n\t\t\tif (session != null || !wasConnected) return;\n\n\t\t\tthis._onDidChange.fire();\n\t\t\tthis.didChangeConnection?.fire({ integration: this, key: this.key, reason: 'disconnected' });\n\t\t\tawait this.providerOnDisconnect?.();\n\t\t});\n\t}\n\n\tprivate skippedNonCloudReported = false;\n\t/**\n\t * Resolves the re-sync's failure, when its token fetch threw (cancellations included), so a caller can report it.\n\t * Never rejects: the cloud sync fans this out over every integration and must not fail on one.\n\t */\n\t@debug()\n\tsyncCloudConnection(state: 'connected' | 'disconnected', forceSync: boolean): Promise<Error | undefined> {\n\t\treturn this.runSessionTransition(() => this.syncCloudConnectionLocked(state, forceSync));\n\t}\n\n\tsyncListedCloudConnection(\n\t\tstate: 'connected' | 'disconnected',\n\t\tforceSync: boolean,\n\t\tauthority: CloudIntegrationSync,\n\t): Promise<Error | undefined> {\n\t\treturn this.runSessionTransition(() => this.syncCloudConnectionLocked(state, forceSync, 'explicit', authority));\n\t}\n\n\tprivate async syncCloudConnectionLocked(\n\t\tstate: 'connected' | 'disconnected',\n\t\tforceSync: boolean,\n\t\treason: 'explicit' | 'expired' = 'explicit',\n\t\tauthority?: CloudIntegrationSync,\n\t): Promise<Error | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tif (authority?.isCurrent() === false) return undefined;\n\n\t\tif (this._session?.cloud === false && state !== 'connected') {\n\t\t\tif (this.id !== GitCloudHostIntegrationId.GitHub && !this.skippedNonCloudReported) {\n\t\t\t\tthis.ctx.hooks?.session?.onRefreshSkipped?.({\n\t\t\t\t\tid: this.id,\n\t\t\t\t\treason: 'skip-non-cloud',\n\t\t\t\t\tcloud: false,\n\t\t\t\t});\n\t\t\t\tthis.skippedNonCloudReported = true;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tlet failure: Error | undefined;\n\t\tswitch (state) {\n\t\t\tcase 'connected': {\n\t\t\t\tconst oldSession = this._session;\n\t\t\t\tlet resyncing = false;\n\t\t\t\tif (forceSync) {\n\t\t\t\t\t// Get a new session from the cloud. The stored one is refetched rather than deleted first (see\n\t\t\t\t\t// `GetSessionOptions.refetch`), so a fetch that fails transiently keeps the token it had.\n\t\t\t\t\tif (reason === 'explicit') {\n\t\t\t\t\t\tthis._rejectedTokens.clear();\n\t\t\t\t\t\tthis.clearLookupBackoff();\n\t\t\t\t\t\tthis.beginForcedRefresh();\n\t\t\t\t\t}\n\t\t\t\t\t// The cached session is kept while the replacement is fetched (the refetch does not read it): a\n\t\t\t\t\t// transient failure then leaves it as it was, expiry included, and a read meanwhile does not have to\n\t\t\t\t\t// resolve a session of its own, which during a GK API outage fails the same way and reports the\n\t\t\t\t\t// integration as not connected (gitkraken/kepler#3546). Clear our \"stay disconnected\" flag.\n\t\t\t\t\tawait this.ctx.storage.deleteWorkspace(this.connectedKey);\n\t\t\t\t\tresyncing = true;\n\t\t\t\t} else {\n\t\t\t\t\t// Only sync if we're not connected and not disabled and don't have pending errors\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis._session != null ||\n\t\t\t\t\t\tthis.requestExceptionCount > 0 ||\n\t\t\t\t\t\tthis.ctx.storage.getWorkspace(this.connectedKey) === false\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tforceSync = true;\n\t\t\t\t}\n\n\t\t\t\t// sync option, rather than createIfNeeded, makes sure we don't call connectCloudIntegrations and open a gkdev window\n\t\t\t\t// if there was no session or some problem fetching/refreshing the existing session from the cloud api\n\t\t\t\tlet newSession: ProviderAuthenticationSession | undefined;\n\t\t\t\tlet refetchFailed = false;\n\t\t\t\tconst signOutMark = resyncing ? this.authenticationService.getSignOutMark() : undefined;\n\t\t\t\ttry {\n\t\t\t\t\tnewSession = await this.resolveSessionLocked({\n\t\t\t\t\t\tsync: forceSync,\n\t\t\t\t\t\trefetch: resyncing,\n\t\t\t\t\t\tauthority: authority,\n\t\t\t\t\t});\n\t\t\t\t} catch (ex) {\n\t\t\t\t\trefetchFailed = true;\n\t\t\t\t\tif (!isCancellationError(ex)) {\n\t\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\t}\n\t\t\t\t\t// Not evidence the connection is gone (#5569). A cancelled refetch is still reported: its caller must\n\t\t\t\t\t// not read with the session it could not replace.\n\t\t\t\t\tfailure = toError(ex);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\toldSession &&\n\t\t\t\t\tnewSession &&\n\t\t\t\t\tnewSession === this._session &&\n\t\t\t\t\tnewSession.accessToken !== oldSession.accessToken\n\t\t\t\t) {\n\t\t\t\t\tthis.resetRecoveryAccounting();\n\t\t\t\t}\n\n\t\t\t\t// The forced re-sync above kept the stored token and its descriptor until a replacement arrived.\n\t\t\t\t// Drop both only when the replacement fetch came back definitively empty, so a connection whose\n\t\t\t\t// token is really gone is cleanly disconnected (#5497) while a healthy one survives a blip (#5569).\n\t\t\t\tif (resyncing && newSession == null && !refetchFailed) {\n\t\t\t\t\tconst authProvider = await this.authenticationService.get(this.authProvider.id);\n\t\t\t\t\tif (authority?.isCurrent() === false) return undefined;\n\n\t\t\t\t\tconst options = { preserveConfigured: false, signOutMark: signOutMark };\n\t\t\t\t\tif (authProvider instanceof CloudIntegrationAuthenticationProvider) {\n\t\t\t\t\t\tawait authProvider.deleteSession(this.authProviderDescriptor, { ...options, sync: authority });\n\t\t\t\t\t} else {\n\t\t\t\t\t\tawait authProvider.deleteSession(this.authProviderDescriptor, options);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'disconnected':\n\t\t\t\tif (!(await this.disconnectLocked({ silent: true }, true, authority))) return undefined;\n\t\t\t\tbreak;\n\t\t}\n\t\tthis._resyncs++;\n\t\tthis._lastResyncFailure = failure;\n\t\treturn failure;\n\t}\n\n\t/**\n\t * Proves the credential with an uncached check, rejecting with the provider's `AuthenticationError` when it is\n\t * refused, and with anything else when the check proves nothing. A `403` proves nothing either: the credential\n\t * authenticated and was only denied the check's request.\n\t *\n\t * Implemented by the providers whose reads can reach their scopes without an uncached request to the connection\n\t * first: discovery served from a per-token cache (Azure DevOps, Bitbucket, Jira Cloud), or an SDK fan-out across\n\t * the requested repositories (Bitbucket Data Center). There, a dead token comes back as scoped refusals with no\n\t * failure of the connection: the same shape as one scope refusing a sound credential.\n\t * {@link confirmScopedAuthFailures} uses this to tell the two apart.\n\t */\n\tprotected validateCredential?(session: ProviderAuthenticationSession): Promise<void>;\n\n\t/**\n\t * Credentials that passed {@link validateCredential} within the last minute. A probe already in flight is\n\t * shared rather than repeated, and a refused one is not kept. Cleared whenever a credential is refused (see\n\t * {@link handleProviderException}), so a pass is never vouched for past a refusal this instance has seen.\n\t */\n\tprivate readonly _validatedCredentials = new PromiseCache<string, void>({ createTTL: 60 * 1000, capacity: 10 });\n\n\t/**\n\t * Whether a scope's refusal is the credential's own, by the provider's account of it: e.g. a token missing the\n\t * OAuth scopes the read needs. The probe cannot see that, because it proves the token authenticates, not that\n\t * it is authorized. So {@link confirmScopedAuthFailures} publishes one for the connection, unscoped, which asks\n\t * for the reconnect (consenting to the scopes again) that fixes it, and keeps the results of the scopes that\n\t * answered.\n\t */\n\tprotected isCredentialRefusal?(refusal: ProviderRefusal): boolean;\n\n\t/**\n\t * Names why a confirmed credential was refused by one scope, from what the refusal said (see\n\t * `ProviderWarning.cause`). Called only by {@link confirmScopedAuthFailures}, once the credential passed: the\n\t * refusals this names are indistinguishable from a dead credential until then.\n\t */\n\tprotected describeRefusal?(\n\t\tsession: ProviderAuthenticationSession,\n\t\trefusal: ProviderRefusal,\n\t\tscope: ProviderWarningScope,\n\t): ProviderWarningCause | undefined;\n\n\t/**\n\t * Settles what a read's only-scoped authentication failures mean, when the provider can tell (see\n\t * {@link validateCredential}).\n\t *\n\t * A refused credential is thrown: the caller's `catch` then fails the read as a whole, exactly as it does when\n\t * discovery is not cached and the first request is the one refused. Without this, a token revoked after\n\t * discovery would publish scoped `auth` warnings, which a consumer must not answer with a reconnect (see\n\t * `ProviderWarning.scope`), next to results served from the cache, for as long as the token stays stored.\n\t *\n\t * A confirmed credential makes each refusal the scope's own, so its cause is named through\n\t * {@link describeRefusal}. A probe that fails for another reason proves nothing either way and leaves the read\n\t * as it was.\n\t *\n\t * A refusal the provider pins on the credential itself (see {@link isCredentialRefusal}) is published for the\n\t * connection instead, without a probe.\n\t *\n\t * A token that passed within the last minute is not probed again, so a scope that keeps refusing it costs one\n\t * probe a minute, and a revocation right after a probe can take up to a minute to surface: until then its\n\t * refusals stay scoped, and may be named. A probe that proved nothing is not remembered, so the next read probes\n\t * again, and a credential no probe can confirm (e.g. a Bitbucket Data Center project access token) is probed on\n\t * every read that has scoped refusals.\n\t */\n\tprotected async confirmScopedAuthFailures(\n\t\tsession: ProviderAuthenticationSession,\n\t\tmetadata: CollectionMetadata | undefined,\n\t): Promise<void> {\n\t\tif (!hasOnlyScopedAuthFailures(metadata)) return;\n\n\t\t// Published for the connection, as a refusal outside any scope would be, while the scopes that answered keep\n\t\t// their results. That already asks for a reconnect, so there is nothing left for a probe to settle.\n\t\tif (this.markCredentialRefusals(metadata)) return;\n\t\tif ((await this.confirmCredential(session)) !== 'confirmed') return;\n\n\t\tthis.nameRefusalCauses(session, metadata);\n\t}\n\n\t/**\n\t * Settles what a batch read's authentication refusals mean before the call is judged, as\n\t * {@link confirmScopedAuthFailures} settles an account-wide read's: each refused slot comes back carrying the scope\n\t * failure it was recorded as, against the scope its target names (see {@link batchTargetScope}), and a read\n\t * publishes that instead of the bare reason.\n\t *\n\t * When any target answered, that proved the credential, so each refusal is its own target's. When every target\n\t * failed, the call fails as a whole, as it always has, unless every failure is a refusal of a credential that checks\n\t * out. Every target refusing is also what a dead credential looks like, so the credential is checked once first,\n\t * with {@link validateCredential}. A check that proves nothing leaves the refusals scoped and unnamed, as it leaves\n\t * an account-wide read's. A provider with no check cannot tell, and a refusal it pins on the credential (see\n\t * {@link isCredentialRefusal}) needs none, so either still fails the call.\n\t *\n\t * `keepOtherFailures` is for the etag cheap check, whose failed targets fall through to a full read one by one:\n\t * there, only a refused credential fails the call, always on one of the refusals, and every other failure stays\n\t * its own slot's. A batch with refusals and other failures but no answer then has its credential checked, as when\n\t * every target refused, and a provider with no check leaves its refusals scoped and unnamed.\n\t */\n\tprotected async settleBatchRefusals<T>(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly BatchTarget[],\n\t\tslots: PromiseSettledResult<T>[],\n\t\toptions?: { keepOtherFailures?: boolean },\n\t): Promise<BatchSlot<T>[]> {\n\t\tconst keepOtherFailures = options?.keepOtherFailures ?? false;\n\t\tconst answered = new Set(\n\t\t\tslots.flatMap((slot, i) => (slot.status === 'fulfilled' ? [batchTargetRepository(targets[i])] : [])),\n\t\t);\n\t\tconst credentialDied = slots.some((slot, i) => {\n\t\t\tif (slot.status !== 'rejected' || !isRefusedCredential(slot.reason)) return false;\n\n\t\t\tconst repository = batchTargetRepository(targets[i]);\n\t\t\treturn repository != null && answered.has(repository);\n\t\t});\n\t\tconst failures = slots.map((slot, i) => {\n\t\t\tif (slot.status !== 'rejected' || !(slot.reason instanceof AuthenticationError)) return undefined;\n\t\t\tif (credentialDied && isRefusedCredential(slot.reason)) return undefined;\n\n\t\t\treturn toCollectionScopeFailure(batchTargetScope(this.id, targets[i]), slot.reason);\n\t\t});\n\t\tconst refused = failures.filter(f => f != null);\n\t\tif (!refused.length) {\n\t\t\tif (!keepOtherFailures) {\n\t\t\t\tthrowIfAllSettledFailed(slots);\n\t\t\t}\n\t\t\treturn slots;\n\t\t}\n\n\t\tconst metadata: CollectionMetadata = { completeness: 'partial', failures: refused };\n\t\tconst credentialRefused = this.markCredentialRefusals(metadata);\n\t\tif (slots.some(slot => slot.status === 'fulfilled')) {\n\t\t\tthis.nameRefusalCauses(session, metadata);\n\t\t} else if (credentialRefused) {\n\t\t\tthrowIfAllSettledFailed(keepOtherFailures ? slots.filter((_, i) => failures[i] != null) : slots);\n\t\t} else if (refused.length < slots.length && !keepOtherFailures) {\n\t\t\t// Fails on a target that failed for another reason: failing on a refusal would run the credential's own\n\t\t\t// recovery (a session expiry or a disconnect strike) for what may be only its target's refusal.\n\t\t\tthrowIfAllSettledFailed(slots.filter((_, i) => failures[i] == null));\n\t\t} else {\n\t\t\tconst confirmation = await this.confirmCredential(session);\n\t\t\tif (confirmation == null) {\n\t\t\t\tif (refused.length === slots.length) {\n\t\t\t\t\tthrowIfAllSettledFailed(slots);\n\t\t\t\t}\n\t\t\t} else if (confirmation === 'confirmed') {\n\t\t\t\tthis.nameRefusalCauses(session, metadata);\n\t\t\t}\n\t\t}\n\n\t\treturn slots.map((slot, i) => {\n\t\t\tconst failure = failures[i];\n\t\t\treturn slot.status === 'rejected' && failure != null ? { ...slot, failure: failure } : slot;\n\t\t});\n\t}\n\n\tprotected settleBatchCredential<T>(\n\t\tsyncReqUsecase: SyncReqUsecase,\n\t\tsettled: readonly BatchSlot<T>[],\n\t\toptions: { scope: ScopedLogger | undefined; connectionId: string | undefined; reset: boolean },\n\t): void {\n\t\tconst refusal = findRefusedCredentialSlot(settled);\n\t\tif (refusal != null) {\n\t\t\tthis.handleProviderException(syncReqUsecase, refusal.reason, {\n\t\t\t\tscope: options.scope,\n\t\t\t\tconnectionId: options.connectionId,\n\t\t\t});\n\t\t} else if (options.reset) {\n\t\t\tthis.resetRequestExceptionCount(syncReqUsecase, options.connectionId);\n\t\t}\n\t}\n\n\t/**\n\t * Shows one notice, and spends at most one strike, for a batch read whose targets failed with a server error or a\n\t * timeout. Our own clients leave both to the batch (see `reportRequestFailure`) instead of spending them per\n\t * target. `strike` is true only when every target failed and the call's own failure spent none: a call that\n\t * answered some targets showed the host is up, and budgets strikes the same way as the rest of its failures. The\n\t * strike is `connectionId`'s, the connection the call read.\n\t */\n\tprotected reportDeferredRequestFailures(\n\t\tslots: readonly PromiseSettledResult<unknown>[] | undefined,\n\t\tstrike: boolean,\n\t\tconnectionId: string | undefined,\n\t): void {\n\t\tlet notify: (() => void) | undefined;\n\t\tfor (const slot of slots ?? []) {\n\t\t\tif (slot.status !== 'rejected') continue;\n\n\t\t\tnotify = takeDeferredRequestFailure(slot.reason);\n\t\t\tif (notify != null) break;\n\t\t}\n\n\t\tif (notify == null) return;\n\n\t\tif (strike) {\n\t\t\tthis.trackRequestException({ connectionId: connectionId });\n\t\t}\n\t\tnotify();\n\t}\n\n\t/**\n\t * The failure handling of an etag cheap check that failed as a whole. Only a refused credential runs\n\t * {@link handleProviderException}, for its session expiry, re-authentication and strike. Anything else is only\n\t * logged, spending no strike and showing no notice: every target the check held then falls through to a full\n\t * read, which spends and notifies if the host really is failing, or is dropped, as rate-limited or without a\n\t * connection, with the check's warning. A rate limit costs nothing in `handleProviderException` either.\n\t */\n\tprotected handleEtagCheckException(\n\t\tsyncReqUsecase: SyncReqUsecase,\n\t\tex: Error,\n\t\toptions: { scope: ScopedLogger | undefined; connectionId: string | undefined },\n\t): void {\n\t\tif (ex instanceof AuthenticationError) {\n\t\t\tthis.handleProviderException(syncReqUsecase, ex, options);\n\t\t\treturn;\n\t\t}\n\t\tif (isCancellationError(ex)) return;\n\n\t\tif (options.scope != null) {\n\t\t\toptions.scope.error(ex);\n\t\t} else {\n\t\t\tLogger.error(ex);\n\t\t}\n\t}\n\n\t/** Marks the scoped refusals the provider pins on the credential (see {@link isCredentialRefusal}). */\n\tprivate markCredentialRefusals(metadata: CollectionMetadata | undefined): boolean {\n\t\tconst isCredentialRefusal = this.isCredentialRefusal?.bind(this);\n\t\treturn isCredentialRefusal != null && markCredentialRefusals(metadata, isCredentialRefusal);\n\t}\n\n\t/**\n\t * Checks the credential with {@link validateCredential}, rethrowing the provider's refusal when it is refused.\n\t * `undefined` when the provider has no check, and `'unproven'` when the check proved nothing either way.\n\t */\n\tprivate async confirmCredential(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<'confirmed' | 'unproven' | undefined> {\n\t\tconst validateCredential = this.validateCredential?.bind(this);\n\t\tif (validateCredential == null) return undefined;\n\n\t\t// Keyed by the address as well as the token: a self-managed instance serves every installation on its host,\n\t\t// and one installation accepting a token says nothing about another.\n\t\tconst key = [session.domain, session.baseUrl ?? '', session.accessToken].join('\\n');\n\t\ttry {\n\t\t\tawait this._validatedCredentials.getOrCreate(key, () => validateCredential(session));\n\t\t} catch (ex) {\n\t\t\t// A 403 answered a credential that authenticated and was only denied the check's own request, so it proves\n\t\t\t// nothing about the scopes' refusals either.\n\t\t\tif (ex instanceof AuthenticationError && ex.reason !== AuthenticationErrorReason.Forbidden) throw ex;\n\n\t\t\treturn 'unproven';\n\t\t}\n\t\treturn 'confirmed';\n\t}\n\n\t/** Names each scoped refusal's cause (see {@link describeRefusal}); only once the credential is proven. */\n\tprivate nameRefusalCauses(session: ProviderAuthenticationSession, metadata: CollectionMetadata | undefined): void {\n\t\tconst describeRefusal = this.describeRefusal?.bind(this);\n\t\tif (describeRefusal == null) return;\n\n\t\tattributeScopedAuthFailures(metadata, (refusal, scope) => describeRefusal(session, refusal, scope));\n\t}\n\n\t/** Returns whether it spent a strike (see {@link trackRequestException}). */\n\tprotected handleConnectionAuthenticationRejection(\n\t\tconnectionId: string,\n\t\tsilent?: boolean,\n\t\trejectedAccessToken?: string,\n\t): boolean {\n\t\tthis._validatedCredentials.clear();\n\t\tif (this._rejectedTokens.recordRejection(connectionId, rejectedAccessToken)) return false;\n\n\t\tthis.trackRequestException({ connectionId: connectionId, silent: silent });\n\t\treturn true;\n\t}\n\n\t/** Returns whether it spent a strike (see {@link trackRequestException}). */\n\tprotected handleProviderException(\n\t\tsyncReqUsecase: SyncReqUsecase,\n\t\tex: Error,\n\t\toptions?: { scope?: ScopedLogger | undefined; silent?: boolean; connectionId?: string },\n\t): boolean {\n\t\tif (isCancellationError(ex)) return false;\n\n\t\t// A refused credential may be one a probe passed moments ago: stop vouching for it.\n\t\tif (ex instanceof AuthenticationError && !options?.connectionId) {\n\t\t\tthis._validatedCredentials.clear();\n\t\t}\n\n\t\tif (options?.scope != null) {\n\t\t\toptions.scope.error(ex);\n\t\t} else {\n\t\t\tLogger.error(ex);\n\t\t}\n\n\t\tif (ex instanceof AuthenticationError && options?.connectionId) {\n\t\t\treturn this.handleConnectionAuthenticationRejection(options.connectionId, options.silent);\n\t\t}\n\n\t\tif (ex instanceof AuthenticationError && this._session?.cloud && !this.hasSessionSyncRequests()) {\n\t\t\tthis.requestSessionSyncForUsecase(syncReqUsecase);\n\t\t\t// Expired now, so a read in progress stops using it, and again once any transition in flight settles, in\n\t\t\t// case it publishes the same token anew (compared by token: a re-read is a new object).\n\t\t\tconst refused = this._session.accessToken;\n\t\t\tthis.expireSessionIfToken(refused);\n\t\t\tvoid this.runSessionTransition(() => {\n\t\t\t\tthis.expireSessionIfToken(refused);\n\t\t\t\treturn Promise.resolve();\n\t\t\t});\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!(ex instanceof AuthenticationError) && !(ex instanceof RequestClientError)) return false;\n\n\t\tthis.trackRequestException(options);\n\t\treturn true;\n\t}\n\n\tprivate expireSessionIfToken(accessToken: string): void {\n\t\tif (this._session?.accessToken !== accessToken || this.connectionExpired === true) return;\n\n\t\tthis._session = { ...this._session, expiresAt: new Date(Date.now() - 1) };\n\t}\n\n\t/** Counts completed cloud re-syncs, so a refresh queued behind one reuses its outcome rather than running another. */\n\tprivate _resyncs = 0;\n\tprivate _lastResyncFailure: Error | undefined;\n\tprivate missingExpirityReported = false;\n\t/**\n\t * Resolves the refresh's failure while the session it could not replace is still unusable, so a read can report\n\t * that instead of reading with an expired token or as a missing connection.\n\t */\n\t@gate()\n\tprotected async refreshSessionIfExpired(): Promise<Error | undefined> {\n\t\tif (this._session?.expiresAt != null && this._session.expiresAt < new Date()) {\n\t\t\t// The current session is expired, so get the latest from the cloud and refresh if needed. Queued, so it\n\t\t\t// sees what any transition in flight settles: a re-sync that already replaced the session, or ran meanwhile\n\t\t\t// and could not, is not repeated, and a disconnect stands.\n\t\t\tconst resyncs = this._resyncs;\n\t\t\treturn this.runSessionTransition(async () => {\n\t\t\t\tlet failure: Error | undefined;\n\t\t\t\tif (this._resyncs !== resyncs) {\n\t\t\t\t\tfailure = this._lastResyncFailure;\n\t\t\t\t} else if (this._session != null && this.connectionExpired === true) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfailure = await this.syncCloudConnectionLocked('connected', true, 'expired');\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tfailure = toError(ex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Only a session still there and still expired is this read's failure, including one a provider\n\t\t\t\t// refusal expired again after the re-sync replaced it.\n\t\t\t\tif (this._session == null || this.connectionExpired !== true) return undefined;\n\n\t\t\t\treturn failure ?? new Error(`The ${this.name} session could not be refreshed`);\n\t\t\t});\n\t\t} else if (\n\t\t\tthis._session?.expiresAt == null &&\n\t\t\tthis.id !== GitCloudHostIntegrationId.GitHub &&\n\t\t\t!this.missingExpirityReported\n\t\t) {\n\t\t\tthis.ctx.hooks?.session?.onRefreshSkipped?.({\n\t\t\t\tid: this.id,\n\t\t\t\treason: 'missing-expiry',\n\t\t\t\tcloud: this._session?.cloud,\n\t\t\t});\n\t\t\tthis.missingExpirityReported = true;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Spends a strike against the connection `connectionId` names (the primary when omitted); a server error or timeout\n\t * our API clients report names the connection whose token made the request (see `reportRequestFailure`). At\n\t * `requestExceptionLimit` the primary session is dropped for this session of the host. Another connection has no\n\t * cached session to drop, since each read resolves its own, so its failures go on surfacing on its reads, and\n\t * reaching the limit leaves the primary and every other connection as they are.\n\t */\n\t@trace()\n\ttrackRequestException(options?: { silent?: boolean; connectionId?: string }): void {\n\t\tconst secondary = this.getSecondaryConnectionId(options?.connectionId);\n\t\tif (secondary != null) {\n\t\t\tconst count = (this.connectionRequestExceptionCounts.get(secondary) ?? 0) + 1;\n\t\t\tthis.connectionRequestExceptionCounts.set(secondary, count);\n\t\t\tif (count === IntegrationBase.requestExceptionLimit) {\n\t\t\t\tLogger.warn(\n\t\t\t\t\t`${this.name} connection '${secondary}' has failed ${count} requests since its last success; it is not the primary, so nothing is disconnected`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tthis.requestExceptionCount++;\n\n\t\tif (this.requestExceptionCount >= IntegrationBase.requestExceptionLimit && this._session !== null) {\n\t\t\tif (!options?.silent) {\n\t\t\t\tthis.ctx.hooks?.ui?.onDisconnectedAfterTooManyFailures?.(this.name);\n\t\t\t}\n\t\t\tvoid this.disconnect({ currentSessionOnly: true });\n\t\t}\n\t}\n\n\t@gate()\n\t@trace({ exit: true })\n\tasync isConnected(): Promise<boolean> {\n\t\t// Not `getSession()`: an expired session is still a connection, and refreshing it here would put a GK API round\n\t\t// trip on every connection check and report a throttled refresh as no connection (gitkraken/kepler#3546).\n\t\tconst session =\n\t\t\tthis._session === undefined\n\t\t\t\t? await this.ensureSession({ createIfNeeded: false, source: 'integrations' })\n\t\t\t\t: this._session;\n\t\treturn session != null && this.isSessionForIntegrationHost(session);\n\t}\n\n\t@gate()\n\tprivate async ensureSession(\n\t\toptions:\n\t\t\t| {\n\t\t\t\t\tcreateIfNeeded?: boolean;\n\t\t\t\t\tforceNewSession?: boolean;\n\t\t\t\t\tsync?: never;\n\t\t\t\t\trefetch?: never;\n\t\t\t\t\tsource?: Sources;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tcreateIfNeeded?: never;\n\t\t\t\t\tforceNewSession?: never;\n\t\t\t\t\tsync: boolean;\n\t\t\t\t\trefetch?: boolean;\n\t\t\t\t\tsource?: Sources;\n\t\t\t },\n\t): Promise<ProviderAuthenticationSession | undefined> {\n\t\tif (options.createIfNeeded || options.forceNewSession) {\n\t\t\t// The sign-in runs outside the queue: it waits on the user, and its cloud sync re-enters this integration\n\t\t\t// (`syncCloudConnection`, `isConnected`), which would wait for it. What it stored is then resolved in a\n\t\t\t// transition, so a disconnect during the sign-in still stands.\n\t\t\tif (!(await this.signIn(options))) return this._session ?? undefined;\n\n\t\t\treturn this.runSessionTransition(() => this.resolveSessionLocked({ createIfNeeded: false }));\n\t\t}\n\n\t\treturn this.runSessionTransition(() => this.resolveSessionLocked(options));\n\t}\n\n\t/**\n\t * Asks the auth provider for a session interactively, storing what it gets; whether one came back. A declined\n\t * consent or any other failure is not one, and never throws: it is resolved, like any read, from storage.\n\t */\n\tprivate async signIn(options: {\n\t\tcreateIfNeeded?: boolean;\n\t\tforceNewSession?: boolean;\n\t\tsource?: Sources;\n\t}): Promise<boolean> {\n\t\tif (this.ctx.config.isIntegrationsEnabled?.() === false) return false;\n\n\t\tawait this.ctx.storage.deleteWorkspace(this.connectedKey);\n\t\ttry {\n\t\t\tconst authProvider = await this.authenticationService.get(this.authProvider.id);\n\t\t\treturn (await authProvider.getSession(this.authProviderDescriptor, options)) != null;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Resolves and publishes the session. Only ever runs inside a transition (see {@link runSessionTransition}). */\n\tprivate async resolveSessionLocked(options: {\n\t\tcreateIfNeeded?: boolean;\n\t\tsync?: boolean;\n\t\tauthority?: CloudIntegrationSync;\n\t\trefetch?: boolean;\n\t\tsource?: Sources;\n\t}): Promise<ProviderAuthenticationSession | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst { createIfNeeded, source, sync, refetch } = options;\n\t\t// A forced re-sync keeps the session it is replacing; serving it would skip the refetch the caller forced.\n\t\tif (this._session != null && !refetch) {\n\t\t\tif (this.isSessionForIntegrationHost(this._session)) return this._session;\n\n\t\t\tthis._session = null;\n\t\t}\n\t\tif (this.ctx.config.isIntegrationsEnabled?.() === false) return undefined;\n\n\t\tconst generation = this.discoveryGeneration;\n\n\t\tif (createIfNeeded || sync) {\n\t\t\tawait this.ctx.storage.deleteWorkspace(this.connectedKey);\n\t\t\tif (this.getSessionDiscoveryGeneration(this._session?.id, undefined, this._session?.cloud) > generation) {\n\t\t\t\tif (sync) throw new CancellationError();\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t} else if (this.ctx.storage.getWorkspace(this.connectedKey) === false) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tlet session: ProviderAuthenticationSession | undefined | null;\n\t\ttry {\n\t\t\tconst authProvider = await this.authenticationService.get(this.authProvider.id);\n\t\t\tif (options.authority?.isCurrent() === false) throw new CancellationError();\n\n\t\t\tconst request = sync\n\t\t\t\t? { sync: sync, refetch: refetch, source: source }\n\t\t\t\t: { createIfNeeded: createIfNeeded, source: source };\n\t\t\tsession =\n\t\t\t\tauthProvider instanceof CloudIntegrationAuthenticationProvider\n\t\t\t\t\t? await authProvider.getSession(this.authProviderDescriptor, request, options.authority)\n\t\t\t\t\t: await authProvider.getSession(this.authProviderDescriptor, request);\n\t\t\tif (options.authority?.isCurrent() === false) throw new CancellationError();\n\n\t\t\tif (session?.expiresAt != null && session.expiresAt < new Date()) {\n\t\t\t\tsession = null;\n\t\t\t}\n\t\t\tif (session != null && !this.isSessionForIntegrationHost(session)) {\n\t\t\t\tsession = undefined;\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex) || !this.isResolvedSessionCurrent(undefined, generation)) {\n\t\t\t\tif (sync) throw new CancellationError();\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tawait this.ctx.storage.deleteWorkspace(this.connectedKey);\n\n\t\t\tif (!this.isResolvedSessionCurrent(undefined, generation)) {\n\t\t\t\tif (sync) throw new CancellationError();\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// Only interactive paths can prompt for consent, so a sync failure must reach the rethrow below.\n\t\t\tif (!sync && ex instanceof Error && ex.message.includes('User did not consent')) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// On a forced re-sync, propagate so syncCloudConnection can tell a failure from a definitive empty\n\t\t\t// result (#5569); other callers keep swallowing to null so reads never throw.\n\t\t\tif (sync) {\n\t\t\t\t// Throwing skips the reset below, and a lingering count blocks the next non-forced sync.\n\t\t\t\tthis.smoothifyRequestExceptionCount();\n\t\t\t\tthrow ex;\n\t\t\t}\n\n\t\t\tsession = null;\n\t\t}\n\n\t\tif (!this.isResolvedSessionCurrent(session ?? undefined, generation)) {\n\t\t\tif (sync) throw new CancellationError();\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (session === undefined && !createIfNeeded && !sync) {\n\t\t\tawait this.ctx.storage.deleteWorkspace(this.connectedKey);\n\t\t\tif (!this.isResolvedSessionCurrent(undefined, generation)) return undefined;\n\t\t}\n\n\t\tif (getSessionIdentity(this._session) !== getSessionIdentity(session)) {\n\t\t\t// Retire reads before the replacement becomes visible across the storage await.\n\t\t\tthis.onSessionPublishing({ session: session ?? undefined, replacePrimary: true });\n\t\t} else if (refetch && session != null) {\n\t\t\tthis.onSessionPublishing({ session: session, replacePrimary: true });\n\t\t}\n\t\tthis._session = session ?? null;\n\t\tthis.smoothifyRequestExceptionCount();\n\n\t\tif (session != null) {\n\t\t\tconst publishedGeneration = this.getSessionDiscoveryGeneration(session.id, undefined, session.cloud);\n\t\t\tawait this.ctx.storage.storeWorkspace(this.connectedKey, true);\n\t\t\tif (\n\t\t\t\toptions.authority?.isCurrent() === false ||\n\t\t\t\tthis._session !== session ||\n\t\t\t\tpublishedGeneration !== this.getSessionDiscoveryGeneration(session.id, undefined, session.cloud)\n\t\t\t) {\n\t\t\t\tif (sync) throw new CancellationError();\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (\n\t\t\t\t\toptions.authority?.isCurrent() === false ||\n\t\t\t\t\tthis._session !== session ||\n\t\t\t\t\tpublishedGeneration !== this.getSessionDiscoveryGeneration(session.id, undefined, session.cloud)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis._onDidChange.fire();\n\t\t\t\tthis.didChangeConnection?.fire({ integration: this, key: this.key, reason: 'connected' });\n\t\t\t\tif (\n\t\t\t\t\toptions.authority?.isCurrent() === false ||\n\t\t\t\t\tthis._session !== session ||\n\t\t\t\t\tpublishedGeneration !== this.getSessionDiscoveryGeneration(session.id, undefined, session.cloud)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Fired detached, so there is no caller left to catch anything: every implementor is async, and\n\t\t\t\t// a rejection would surface as a process-level unhandled rejection in the host. It is a\n\t\t\t\t// best-effort warm-up, so swallow the failure with a warning instead. Never awaited by the\n\t\t\t\t// transition: its reads can disconnect, which queues a transition of their own.\n\t\t\t\tvoid (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.providerOnConnect?.();\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tscope?.warn(\n\t\t\t\t\t\t\t`Failed to run providerOnConnect for ${this.key}: ${ex instanceof Error ? ex.message : String(ex)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t});\n\t\t}\n\n\t\treturn session ?? undefined;\n\t}\n\n\tgetIgnoreSSLErrors(): boolean | 'force' {\n\t\treturn this.authenticationService.ignoreSSLErrors(this);\n\t}\n\n\tasync searchMyIssues(\n\t\tresource?: ResourceDescriptor,\n\t\tcancellation?: AbortSignal,\n\t\tconnectionId?: string,\n\t): Promise<IssueShape[] | undefined>;\n\tasync searchMyIssues(\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\tconnectionId?: string,\n\t): Promise<IssueShape[] | undefined>;\n\t@trace()\n\tasync searchMyIssues(\n\t\tresources?: ResourceDescriptor | ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\tconnectionId?: string,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.searchMyIssuesResult(resources, cancellation, connectionId))?.value;\n\t}\n\n\t/**\n\t * Result-returning core of {@link searchMyIssues}. Recovers thrown errors into `{ error }` so callers\n\t * (e.g. the ProviderBackend account-wide issues read) can surface a per-provider warning instead of a\n\t * silent empty result. Returns the normalized {@link IssueShape} (there is no raw account-wide issue read).\n\t */\n\tasync searchMyIssuesResult(\n\t\tresources?: ResourceDescriptor | ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\tconnectionId?: string,\n\t): Promise<IntegrationResult<IssueShape[] | undefined>> {\n\t\tconst scope = getScopedLogger();\n\t\t// `connectionId` targets a specific account (multi-account); omitted reads the primary.\n\t\tconst session = await this.resolveReadSession(connectionId, scope);\n\t\tif (session == null || isReadSessionFailure(session)) return session && { error: session.error };\n\n\t\tconst start = performance.now();\n\t\ttry {\n\t\t\tconst issues = await this.searchProviderMyIssues(\n\t\t\t\tsession,\n\t\t\t\tresources != null ? (Array.isArray(resources) ? resources : [resources]) : undefined,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tthis.resetRequestExceptionCount('searchMyIssues', connectionId);\n\t\t\treturn { value: issues, duration: performance.now() - start };\n\t\t} catch (ex) {\n\t\t\tthis.handleProviderException('searchMyIssues', ex, { scope: scope, connectionId: connectionId });\n\t\t\treturn { error: toError(ex), duration: performance.now() - start };\n\t\t}\n\t}\n\n\tprotected abstract searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<IssueShape[] | undefined>;\n\n\t/**\n\t * Paging/truncation-aware variant of {@link searchProviderMyIssues}. The default wraps the normalized read\n\t * as a complete single page; providers with native cursors or fan-out metadata override it.\n\t */\n\tprotected async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\t_options?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\t// The default read has no assignee scoping to broaden, so `_options` is inert here; a provider whose\n\t\t// account-wide read is user-scoped (GitHub/GitLab/Azure) overrides this and honors `includeAllAssignees`.\n\t\tconst values = await this.searchProviderMyIssues(session, resources, cancellation);\n\t\tif (values == null) return undefined;\n\t\treturn { values: values, truncated: false };\n\t}\n\n\t/**\n\t * Result-returning, truncation-aware account-wide issue read. Recovers thrown errors into `{ error }` and\n\t * carries the `truncated` flag so the ProviderBackend facade can report an incomplete read honestly.\n\t */\n\tasync searchMyIssuesWithTruncationResult(\n\t\tresources?: ResourceDescriptor | ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\tconnectionId?: string,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<IntegrationResult<AccountWideIssuesResult | undefined>> {\n\t\tconst scope = getScopedLogger();\n\t\tconst session = await this.resolveReadSession(connectionId, scope);\n\t\tif (session == null || isReadSessionFailure(session)) return session && { error: session.error };\n\n\t\ttry {\n\t\t\tconst result = await this.searchProviderMyIssuesWithTruncation(\n\t\t\t\tsession,\n\t\t\t\tresources != null ? (Array.isArray(resources) ? resources : [resources]) : undefined,\n\t\t\t\tcancellation,\n\t\t\t\toptions,\n\t\t\t);\n\t\t\tawait this.confirmScopedAuthFailures(session, result?.metadata);\n\t\t\tthis.resetRequestExceptionCount('searchMyIssues', connectionId);\n\t\t\treturn { value: result };\n\t\t} catch (ex) {\n\t\t\tthis.handleProviderException('searchMyIssues', ex, { scope: scope, connectionId: connectionId });\n\t\t\treturn { error: toError(ex) };\n\t\t}\n\t}\n\n\t@trace()\n\tasync getLinkedIssueOrPullRequest(\n\t\tresource: T,\n\t\tlink: { id: string; key: string },\n\t\toptions?: { expiryOverride?: boolean | number; type?: IssueOrPullRequestType; throwOnError?: boolean },\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif ((await this.prepareSessionLookup()) != null) return undefined;\n\n\t\tconst session = this._session;\n\t\tif (session == null) return undefined;\n\n\t\tconst { throwOnError, ...cacheOptions } = options ?? {};\n\n\t\tconst issueOrPR = this.ctx.cache.getIssueOrPullRequest(\n\t\t\tlink.key,\n\t\t\toptions?.type,\n\t\t\tresource,\n\t\t\tthis.getPullRequestCacheDescriptor(session),\n\t\t\tcacheable => ({\n\t\t\t\tvalue: (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.getProviderLinkedIssueOrPullRequest(\n\t\t\t\t\t\t\tsession,\n\t\t\t\t\t\t\tresource,\n\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\toptions?.type,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resetRequestExceptionCount('getIssueOrPullRequest');\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\tthis.handleProviderException('getIssueOrPullRequest', ex, { scope: scope });\n\t\t\t\t\t\tif (throwOnError) throw ex;\n\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t})(),\n\t\t\t}),\n\t\t\tcacheOptions,\n\t\t);\n\t\treturn issueOrPR;\n\t}\n\n\tprotected abstract getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: T,\n\t\tlink: { id: string; key: string },\n\t\ttype: undefined | IssueOrPullRequestType,\n\t): Promise<IssueOrPullRequest | undefined>;\n\n\tasync getIssue(\n\t\tresource: T,\n\t\tid: string,\n\t\toptions?: { connectionId?: string; expiryOverride?: boolean | number },\n\t): Promise<Issue | undefined> {\n\t\treturn (await this.getIssueResult(resource, id, options))?.value;\n\t}\n\n\tgetIssueResult(\n\t\tresource: T,\n\t\tid: string,\n\t\toptions?: { connectionId?: string; expiryOverride?: boolean | number },\n\t): Promise<IntegrationResult<Issue | undefined>> {\n\t\treturn this.getIssueResultCore(resource, id, options, session => this.getProviderIssue(session, resource, id));\n\t}\n\n\t@trace()\n\tprotected async getIssueResultCore(\n\t\tresource: ResourceDescriptor,\n\t\tid: string,\n\t\toptions: { connectionId?: string; expiryOverride?: boolean | number } | undefined,\n\t\tgetProviderIssue: (session: ProviderAuthenticationSession) => Promise<Issue | undefined>,\n\t): Promise<IntegrationResult<Issue | undefined>> {\n\t\tconst scope = getScopedLogger();\n\t\tconst { connectionId: requestedConnectionId, expiryOverride } = options ?? {};\n\t\tconst connectionId = requestedConnectionId || undefined;\n\t\tconst session = await this.resolveReadSession(connectionId, scope);\n\t\tif (session == null || isReadSessionFailure(session)) return session && { error: session.error };\n\n\t\ttry {\n\t\t\tconst issue = await getCachedIssue({\n\t\t\t\tcache: this.ctx.cache,\n\t\t\t\tid: id,\n\t\t\t\tresource: resource,\n\t\t\t\tintegration: this,\n\t\t\t\tload: async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst issue = await getProviderIssue(session);\n\t\t\t\t\t\tthis.resetRequestExceptionCount('getIssue', connectionId);\n\t\t\t\t\t\treturn issue;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tif (!isCancellationError(ex)) {\n\t\t\t\t\t\t\tthis.handleProviderException('getIssue', toError(ex), {\n\t\t\t\t\t\t\t\tscope: scope,\n\t\t\t\t\t\t\t\tconnectionId: connectionId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow ex;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcacheOptions: {\n\t\t\t\t\tconnectionId: connectionId,\n\t\t\t\t\texpiryOverride: expiryOverride,\n\t\t\t\t\tetag: `${this.id}:${this.maybeConnected ?? false}:${this.getSessionFingerprint(session)}`,\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn { value: issue };\n\t\t} catch (ex) {\n\t\t\treturn { error: toError(ex) };\n\t\t}\n\t}\n\n\tprotected abstract getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: T,\n\t\tid: string,\n\t): Promise<Issue | undefined>;\n\n\tasync getCurrentAccount(options?: {\n\t\tavatarSize?: number;\n\t\tconnectionId?: string;\n\t\texpiryOverride?: boolean | number;\n\t}): Promise<Account | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst { connectionId: requestedConnectionId, expiryOverride, ...opts } = options ?? {};\n\t\tconst connectionId = requestedConnectionId || undefined;\n\t\tconst session = await this.resolveReadSessionOrThrow(connectionId, scope);\n\t\tif (session == null) return undefined;\n\n\t\tconst sessionFingerprint = this.getSessionFingerprint(session);\n\n\t\tconst currentAccount = await this.ctx.cache.getCurrentAccount(\n\t\t\tthis,\n\n\t\t\t(cacheable: any) => ({\n\t\t\t\tvalue: (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst account = await this.getProviderCurrentAccount?.(session, opts);\n\t\t\t\t\t\tthis.resetRequestExceptionCount('getCurrentAccount', connectionId);\n\t\t\t\t\t\treturn account;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tif (isCancellationError(ex) && !isProviderUnreachableError(ex)) {\n\t\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.handleProviderException('getCurrentAccount', ex, {\n\t\t\t\t\t\t\tscope: scope,\n\t\t\t\t\t\t\tconnectionId: connectionId,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// Invalidate the cache on error, except for auth errors\n\t\t\t\t\t\tif (!(ex instanceof AuthenticationError)) {\n\t\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Re-throw to the caller\n\t\t\t\t\t\tthrow ex;\n\t\t\t\t\t}\n\t\t\t\t})(),\n\t\t\t}),\n\t\t\t{\n\t\t\t\tconnectionId: connectionId,\n\t\t\t\texpiryOverride: expiryOverride,\n\t\t\t\texpireOnError: false,\n\t\t\t\tetag: `${this.id}:${this.maybeConnected ?? false}:${sessionFingerprint}`,\n\t\t\t},\n\t\t);\n\t\treturn currentAccount;\n\t}\n\n\tprotected getProviderCurrentAccount?(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { avatarSize?: number },\n\t): Promise<Account | undefined>;\n\n\t/** Whether this integration can answer {@link getCurrentAccount} at all — Jira Data Center cannot. */\n\tget supportsCurrentAccount(): boolean {\n\t\treturn this.getProviderCurrentAccount != null;\n\t}\n\n\t/**\n\t * Resolves the account for a specific session/token — including connections other than the current\n\t * primary (multi-account) — using this integration's provider API base URL and auth type. Returns\n\t * undefined when the provider doesn't support account lookup. Uncached (callers cache per connection).\n\t */\n\tgetProviderAccountForSession(session: ProviderAuthenticationSession): Promise<Account | undefined> {\n\t\treturn this.getProviderCurrentAccount?.(session) ?? Promise.resolve(undefined);\n\t}\n\n\t/**\n\t * Resolves the workspace a specific session's token was granted for, separate from the person, asking the\n\t * provider every time so a renamed workspace is picked up. Undefined when the provider has no such workspace.\n\t */\n\tgetProviderResourceForSession(_session: ProviderAuthenticationSession): Promise<ConnectionResource | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\t@trace()\n\tasync getPullRequest(\n\t\tresource: T,\n\t\tid: string,\n\t\toptions?: { expiryOverride?: boolean | number; throwOnError?: boolean },\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst refreshFailure = await this.prepareSessionLookup();\n\t\tif (refreshFailure === 'unconnected') return undefined;\n\t\tif (refreshFailure != null) {\n\t\t\tif (options?.throwOnError) throw refreshFailure;\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst session = this._session;\n\t\tif (session == null) return undefined;\n\n\t\tconst pr = await this.ctx.cache.getPullRequest(\n\t\t\tid,\n\t\t\tresource,\n\t\t\tthis.getPullRequestCacheDescriptor(session),\n\t\t\tcacheable => ({\n\t\t\t\tvalue: (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.getProviderPullRequest?.(session, resource, id);\n\t\t\t\t\t\tthis.resetRequestExceptionCount('getPullRequest');\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\tthis.handleProviderException('getPullRequest', ex, { scope: scope });\n\t\t\t\t\t\tif (options?.throwOnError) throw ex;\n\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t})(),\n\t\t\t}),\n\t\t\t{ expiryOverride: options?.expiryOverride },\n\t\t);\n\t\treturn pr;\n\t}\n\n\tprotected getProviderPullRequest?(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: T,\n\t\tid: string,\n\t): Promise<PullRequest | undefined>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,IAAa,qBAAb,MAAgC;CACV;CAArB,YAAY,OAAuB;EAAd,KAAA,QAAA;CAAe;AACrC;AAEA,SAAgB,qBACf,SACgC;CAChC,OAAO,mBAAmB;AAC3B;AAWA,SAAS,sBAAsB,QAAyC;CACvE,IAAI,gBAAgB,QAAQ,OAAO,KAAA;CAEnC,OAAO;EAAC,OAAO;EAAO,OAAO,WAAW;EAAI,OAAO;CAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,YAAY;AAChF;AAEA,SAAS,oBAAoB,QAAgD;CAC5E,OAAO,kBAAkB,uBAAuB,OAAO,WAAA;AACxD;AAEA,SAAS,0BACR,OACwE;CACxE,OAAO,MAAM,MACX,SACA,KAAK,WAAW,cAAc,KAAK,WAAW,QAAQ,oBAAoB,KAAK,MAAM,CACvF;AACD;;;;;;;;AASA,SAAS,iBAAiB,YAA4B,QAAsC;CAC3F,IAAI,gBAAgB,QAAQ,OAAO;EAAc;EAAY,YAAY,OAAO;CAAW;CAC3F,I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WAAA,CAAA,MAAM,CAAA,GAAA,gBAAA,WAAA,sBAAA,IAAA;AAoIN,WAAA,CAAA,MAAM,CAAA,GAAA,gBAAA,WAAA,kBAAA,IAAA"}
1
+ {"version":3,"file":"integration.js","names":[],"sources":["../../../../../plus/integrations/src/models/integration.ts"],"sourcesContent":["import type { CollectionMetadata, CollectionScope } from '@gitkraken/provider-apis';\nimport { takeDeferredRequestFailure } from '@gitlens/git/errors.js';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { AutolinkReference, DynamicAutolinkReference } from '@gitlens/git/models/autolink.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequest } from '@gitlens/git/models/pullRequest.js';\nimport type { ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { CancellationError, isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug, trace } from '@gitlens/utils/decorators/log.js';\nimport type { Disposable } from '@gitlens/utils/disposable.js';\nimport type { Event } from '@gitlens/utils/event.js';\nimport { Emitter } from '@gitlens/utils/event.js';\nimport { fnv1aHash64 } from '@gitlens/utils/hash.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport type { ScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { PromiseCache } from '@gitlens/utils/promiseCache.js';\nimport { CloudIntegrationAuthenticationProvider } from '../authentication/cloudIntegrationAuthenticationProvider.js';\nimport type { CloudIntegrationSync } from '../authentication/cloudIntegrationObservations.js';\nimport type {\n\tIntegrationAuthenticationProviderDescriptor,\n\tIntegrationAuthenticationSessionDescriptor,\n} from '../authentication/integrationAuthenticationProvider.js';\nimport type {\n\tIntegrationAuthenticationService,\n\tTrackedSession,\n} from '../authentication/integrationAuthenticationService.js';\nimport type {\n\tConnectionResource,\n\tProviderAuthenticationSession,\n\tSessionPublication,\n} from '../authentication/models.js';\nimport { getSessionIdentity, isSameAuthenticationSession } from '../authentication/models.js';\nimport { RejectedTokenTracker } from '../authentication/rejectedTokenTracker.js';\nimport type { ProviderRefusal, ProviderScopeFailure } from '../collectionMetadata.js';\nimport {\n\tattributeScopedAuthFailures,\n\thasOnlyScopedAuthFailures,\n\tmarkCredentialRefusals,\n\ttoCollectionScopeFailure,\n} from '../collectionMetadata.js';\nimport type { IntegrationIds, IssuesHostIntegrationIds } from '../constants.js';\nimport { GitCloudHostIntegrationId } from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport {\n\tAuthenticationError,\n\tAuthenticationErrorReason,\n\tisProviderUnreachableError,\n\tRequestClientError,\n\ttoError,\n} from '../errors.js';\nimport type { IntegrationConnectionChangeEvent } from '../integrationService.js';\nimport { providersMetadata } from '../providers/metadata.js';\nimport { isAzureProviderId } from '../providers/providerErrors.js';\nimport type { ProvidersApi } from '../providers/providersApi.js';\nimport { throwIfAllSettledFailed } from '../providers/utils/providerPaging.js';\nimport type { ProviderWarningCause, ProviderWarningScope } from '../results.js';\nimport type { Sources } from '../telemetry.js';\nimport { areDomainsOnSameHost } from '../utils/domain.utils.js';\nimport { FailureBackoff } from '../utils/failureBackoff.js';\nimport { isSelfManagedHostIntegrationId } from '../utils/integration.utils.js';\nimport type { GitHostIntegration } from './gitHostIntegration.js';\nimport { getCachedIssue } from './issueCache.js';\nimport type { AccountWideIssuesResult, SearchMyIssuesOptions } from './issueReads.js';\nimport type { IssuesIntegration } from './issuesIntegration.js';\nimport type {\n\tIntegrationCacheDescriptor,\n\tIntegrationConnectedKey,\n\tIntegrationCredential,\n\tIntegrationKey,\n\tIntegrationResult,\n\tIntegrationType,\n} from './publicIntegration.js';\n\nexport type Integration = GitHostIntegration | IssuesIntegration;\nexport type IntegrationById<T extends IntegrationIds> = T extends IssuesHostIntegrationIds\n\t? IssuesIntegration\n\t: GitHostIntegration;\n\n// The issue-read contracts live in their own module (pure data, and their relationship to each other is the\n// point of reading them together); re-exported here so the providers that implement these reads keep one import.\nexport type {\n\tAccountWideIssuesResult,\n\tProviderIssueSearchPage,\n\tProviderSearchCount,\n\tSearchMyIssuesOptions,\n} from './issueReads.js';\nexport type { ProviderPullRequestCount, ProviderPullRequestSearchPage } from './pullRequestReads.js';\n\n/** A per-connection read's session that could not be resolved for a retryable reason (see `resolveReadSession`). */\nexport class ReadSessionFailure {\n\tconstructor(readonly error: Error) {}\n}\n\nexport function isReadSessionFailure(\n\tsession: ProviderAuthenticationSession | ReadSessionFailure | undefined,\n): session is ReadSessionFailure {\n\treturn session instanceof ReadSessionFailure;\n}\n\n/**\n * One target's answer in a batch read. A slot rejected by an authentication refusal carries the scope failure it was\n * recorded as (see `IntegrationBase.settleBatchRefusals`).\n */\nexport type BatchSlot<T> = PromiseFulfilledResult<T> | (PromiseRejectedResult & { failure?: ProviderScopeFailure });\n\n/** A batch read's target, in the form its provider addresses it by: a repository coordinate, or a tracker's resource. */\ntype BatchTarget = { owner: string; repo: string; project?: string } | { resourceId: string };\n\nfunction batchTargetRepository(target: BatchTarget): string | undefined {\n\tif ('resourceId' in target) return undefined;\n\n\treturn [target.owner, target.project ?? '', target.repo].join('/').toLowerCase();\n}\n\nfunction isRefusedCredential(reason: unknown): reason is AuthenticationError {\n\treturn reason instanceof AuthenticationError && reason.reason !== AuthenticationErrorReason.Forbidden;\n}\n\nfunction findRefusedCredentialSlot<T>(\n\tslots: readonly BatchSlot<T>[],\n): (PromiseRejectedResult & { reason: AuthenticationError }) | undefined {\n\treturn slots.find(\n\t\t(slot): slot is PromiseRejectedResult & { reason: AuthenticationError } =>\n\t\t\tslot.status === 'rejected' && slot.failure == null && isRefusedCredential(slot.reason),\n\t);\n}\n\n/**\n * The scope a batch read records a refused target under. It is decided here rather than in the read, which has the\n * same targets, because naming the refusal's cause (`describeRefusal`) needs it too. Azure DevOps: the organization\n * and project, since its refusals come from those (an organization's OAuth policy or tenant, a project's permissions)\n * and its work items belong to no repository. Every other git host: the repository, `owner/repo`, which is how its\n * repo-scoped reads record one. A tracker: the resource.\n */\nfunction batchTargetScope(providerId: IntegrationIds, target: BatchTarget): CollectionScope {\n\tif ('resourceId' in target) return { providerId: providerId, resourceId: target.resourceId };\n\tif (isAzureProviderId(providerId)) {\n\t\treturn { providerId: providerId, resourceId: target.owner, projectId: target.project };\n\t}\n\treturn { providerId: providerId, repositoryId: `${target.owner}/${target.repo}` };\n}\n\ntype SyncReqUsecase = Exclude<\n\t| 'getAccountForCommit'\n\t| 'getAccountForEmail'\n\t| 'getAccountForResource'\n\t| 'getCurrentAccount'\n\t| 'getDefaultBranch'\n\t| 'getIssue'\n\t| 'getIssueOrPullRequest'\n\t| 'getIssuesBatch'\n\t| 'getIssuesEtagFields'\n\t| 'getIssuesForProject'\n\t| 'getIssuesForRepos'\n\t| 'getMyPullRequestsForUser'\n\t| 'getOrganizationsForUser'\n\t| 'getProjectsForOrg'\n\t| 'getProjectsForResources'\n\t| 'getPullRequest'\n\t| 'getPullRequestActivity'\n\t| 'getPullRequestCheckLogs'\n\t| 'getPullRequestsBatch'\n\t| 'getPullRequestsEtagFields'\n\t| 'getPullRequestsForBranches'\n\t| 'getPullRequestsForCommits'\n\t| 'getRepositoriesForOrg'\n\t| 'getRepositoriesForUser'\n\t| 'getPullRequestForBranch'\n\t| 'getPullRequestForCommit'\n\t| 'getPullRequestsForRepos'\n\t| 'getRepositoryMetadata'\n\t| 'getResourcesForUser'\n\t| 'getSshSigningKeysForEmails'\n\t| 'countIssues'\n\t| 'countPullRequests'\n\t| 'dequeuePullRequest'\n\t| 'enqueuePullRequest'\n\t| 'mergePullRequest'\n\t| 'mutateIssue'\n\t| 'writePullRequest'\n\t| 'searchIssuesPage'\n\t| 'searchPullRequestsPage'\n\t| 'searchMyIssues'\n\t| 'searchMyPullRequests'\n\t| 'searchPullRequests',\n\t// excluding to show explicitly that we don't want to add 'all' key occasionally\n\t'all'\n>;\n\nexport abstract class IntegrationBase<\n\tID extends IntegrationIds = IntegrationIds,\n\tT extends ResourceDescriptor = ResourceDescriptor,\n> implements Disposable {\n\tabstract readonly type: IntegrationType;\n\n\tprivate readonly _onDidChange = new Emitter<void>();\n\tget onDidChange(): Event<void> {\n\t\treturn this._onDidChange.event;\n\t}\n\n\tconstructor(\n\t\tprotected readonly ctx: IntegrationServiceContext,\n\t\tprotected readonly authenticationService: IntegrationAuthenticationService,\n\t\tprotected readonly getProvidersApi: () => Promise<ProvidersApi>,\n\t\tprivate readonly didChangeConnection: Emitter<IntegrationConnectionChangeEvent>,\n\t) {}\n\n\tdispose(): void {\n\t\tthis.invalidateDiscoveryCaches();\n\t\tthis._onDidChange.dispose();\n\t}\n\n\tabstract get authProvider(): IntegrationAuthenticationProviderDescriptor;\n\tabstract get id(): ID;\n\tprotected abstract get key(): IntegrationKey<ID>;\n\tabstract get name(): string;\n\tabstract get domain(): string;\n\n\tget authProviderDescriptor(): IntegrationAuthenticationSessionDescriptor {\n\t\treturn { domain: this.domain, scopes: this.authProvider.scopes };\n\t}\n\n\t/**\n\t * The `gl-provider-<key>` glicon key for this provider, which is NOT always its id.\n\t *\n\t * `providersMetadata.iconKey` is the field that says which glyph a provider draws with, and a\n\t * self-managed variant reuses its cloud family's — Jira Data Center draws with Jira's, because it is the\n\t * same product and the id only selects an icon. Returning the id instead named a glyph the registry has\n\t * no entry for, so a consumer rendering a `gl-provider-` glicon from `issue.provider.icon` requested a\n\t * glyph that does not exist.\n\t */\n\tget icon(): string {\n\t\treturn providersMetadata[this.id]?.iconKey ?? this.id;\n\t}\n\n\taccess(): Promise<boolean> {\n\t\treturn this.ctx.account.isTrialOrPaid();\n\t}\n\n\tautolinks():\n\t\t| (AutolinkReference | DynamicAutolinkReference)[]\n\t\t| Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\treturn [];\n\t}\n\n\tprivate get connectedKey(): IntegrationConnectedKey<ID> {\n\t\treturn `connected:${this.key}`;\n\t}\n\n\tget maybeConnected(): boolean | undefined {\n\t\treturn this._session === undefined ? undefined : this._session !== null;\n\t}\n\n\t/** Hash of the current session's access token. Changes on any token change (account switch or refresh). */\n\tprivate _sessionFingerprint: { session: ProviderAuthenticationSession; hash: string } | undefined;\n\tget sessionFingerprint(): string | undefined {\n\t\tif (this._session == null) return undefined;\n\n\t\tif (this._sessionFingerprint?.session !== this._session) {\n\t\t\tthis._sessionFingerprint = { session: this._session, hash: this.getSessionFingerprint(this._session) };\n\t\t}\n\t\treturn this._sessionFingerprint.hash;\n\t}\n\n\tprotected getSessionFingerprint(session: ProviderAuthenticationSession): string {\n\t\treturn fnv1aHash64(session.accessToken);\n\t}\n\n\tprotected getPullRequestCacheDescriptor(_session: ProviderAuthenticationSession): IntegrationCacheDescriptor {\n\t\treturn this;\n\t}\n\n\tget connectionExpired(): boolean | undefined {\n\t\tif (this._session?.expiresAt == null) return undefined;\n\t\treturn new Date(this._session.expiresAt) < new Date();\n\t}\n\n\tprotected _session: ProviderAuthenticationSession | null | undefined;\n\t/**\n\t * Every change to the session (a resolution, a forced re-sync, a disconnect, a reauthentication, a connection\n\t * switch, a refused token) runs here, one at a time. Each one reads storage and the cloud and then settles\n\t * `_session`, the stored tokens and the connected flag; run concurrently, one would publish what it read over\n\t * what another settled meanwhile (gitkraken/kepler#3546). Reads don't queue: they read `_session` as it is.\n\t */\n\tprivate _sessionTransitions: Promise<void> = Promise.resolve();\n\t/**\n\t * Runs `fn` after every transition queued before it. `fn` must not queue another transition and wait for it,\n\t * which would wait for itself: inside a transition, call the `*Locked` methods instead.\n\t */\n\tprotected runSessionTransition<T>(fn: () => Promise<T>): Promise<T> {\n\t\tconst run = this._sessionTransitions.then(fn);\n\t\tthis._sessionTransitions = run.then(\n\t\t\t() => undefined,\n\t\t\t() => undefined,\n\t\t);\n\t\treturn run;\n\t}\n\n\t/** An expired session is refreshed first; when that fails, nothing is returned rather than a token the provider refuses. */\n\tgetSession(\n\t\tsource: Sources,\n\t): ProviderAuthenticationSession | Promise<ProviderAuthenticationSession | undefined> | undefined {\n\t\t// Served as is even while a transition runs: a forced re-sync keeps the session it is replacing, and a read\n\t\t// meanwhile reads with it rather than waiting on the cloud.\n\t\tif (this._session === undefined) {\n\t\t\treturn this.ensureSession({ createIfNeeded: false, source: source });\n\t\t}\n\t\tif (this._session == null || !this.isSessionForIntegrationHost(this._session)) return undefined;\n\t\tif (this.connectionExpired) return this.getRefreshedSession();\n\n\t\treturn this._session;\n\t}\n\n\t/** {@link getSession}'s token, for a consumer of the public view, which never sees the session itself. */\n\tasync getCredential(source: Sources): Promise<IntegrationCredential | undefined> {\n\t\tconst session = await this.getSession(source);\n\t\tif (session == null) return undefined;\n\n\t\treturn { providerId: this.authProvider.id, accessToken: session.accessToken };\n\t}\n\n\tprivate async getRefreshedSession(): Promise<ProviderAuthenticationSession | undefined> {\n\t\tconst failure = await this.refreshSessionIfExpired();\n\t\tif (failure != null) return undefined;\n\n\t\t// The refresh may have been skipped (a non-cloud session) or overtaken by a disconnect or a switch.\n\t\treturn this._session != null &&\n\t\t\tthis.connectionExpired !== true &&\n\t\t\tthis.isSessionForIntegrationHost(this._session)\n\t\t\t? this._session\n\t\t\t: undefined;\n\t}\n\n\tprotected isIntegrationAccessEnabled(): boolean {\n\t\treturn (\n\t\t\tthis.ctx.config.isIntegrationsEnabled?.() !== false &&\n\t\t\tthis.ctx.storage.getWorkspace(this.connectedKey) !== false\n\t\t);\n\t}\n\n\tprivate isSessionForIntegrationHost(session: ProviderAuthenticationSession): boolean {\n\t\tif (!isSelfManagedHostIntegrationId(this.id)) return true;\n\n\t\treturn areDomainsOnSameHost(this.domain, session.domain);\n\t}\n\n\t/**\n\t * Resolves the session to read as, for a per-connection (multi-account) read. When `connectionId` is\n\t * omitted this is the integration's primary session, resolved exactly like the existing read flow\n\t * (ensure-connected + refresh-if-expired). When set, it resolves THAT connection's session directly\n\t * from the auth provider — refreshing it if expired — WITHOUT disturbing the cached primary\n\t * `_session`. Never throws: `undefined` when there is no session to read with (the connection is gone,\n\t * the provider isn't connected), `{ error }` when the connection's token could not be fetched.\n\t *\n\t * The two must not be conflated. A token fetch that THROWS is, by `getConnectionSession`'s contract, a\n\t * retryable failure (a rate-limited or failing GK API, a network error), not evidence that the connection is\n\t * gone (#5569). Answering \"no session\" for it made every connection read during a GK API 429 report\n\t * `no-connection`, which a consumer rightly treats as a credential to reconnect (gitkraken/kepler#3546).\n\t * Returned as the read's error instead, the read core surfaces it like any other failed request: a rate\n\t * limit as `rate-limit`, anything else as `other`.\n\t */\n\tprotected async resolveReadSession(\n\t\tconnectionId: string | undefined,\n\t\tscope: ScopedLogger | undefined,\n\t\tsource?: Sources,\n\t\tcloud = true,\n\t): Promise<ProviderAuthenticationSession | ReadSessionFailure | undefined> {\n\t\tif (!this.isIntegrationAccessEnabled()) return undefined;\n\n\t\t// A truthy connectionId targets a specific account; an empty string is not a real target, so it falls\n\t\t// through to the primary path below.\n\t\tif (connectionId) {\n\t\t\t// The provider previously refused this connection's token. Ask for a refresh before using it again, which\n\t\t\t// is this branch's equivalent of the primary path's `refreshSessionIfExpired`. Claimed here so\n\t\t\t// the forced refresh runs at most once per rejection.\n\t\t\tconst rejectedToken = this._rejectedTokens.claimRefresh(connectionId);\n\t\t\t// Never throws, matching the primary path (whose ensureSession/refreshSessionIfExpired swallow\n\t\t\t// errors), so read methods keep their never-throws contract.\n\t\t\ttry {\n\t\t\t\tconst authProvider = await this.authenticationService.get(this.authProvider.id);\n\t\t\t\tconst session = await authProvider.getSession(\n\t\t\t\t\t{ ...this.authProviderDescriptor, connectionId: connectionId, cloud: cloud },\n\t\t\t\t\t{\n\t\t\t\t\t\tsource: source,\n\t\t\t\t\t\trefreshRejectedToken: rejectedToken === true,\n\t\t\t\t\t\tisRejectedToken: typeof rejectedToken === 'function' ? rejectedToken : undefined,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn session != null && this.isSessionForIntegrationHost(session) ? session : undefined;\n\t\t\t} catch (ex) {\n\t\t\t\tif (isCancellationError(ex)) return undefined;\n\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn new ReadSessionFailure(toError(ex));\n\t\t\t}\n\t\t}\n\n\t\tconst connected = this.maybeConnected ?? (await this.isConnected());\n\t\tif (!connected) return undefined;\n\n\t\t// The primary path's equivalent of the per-connection failure above: an expired session the cloud could not\n\t\t// replace right now is the refresh's failure, not a missing connection, and is never read with.\n\t\tconst refreshFailure = await this.refreshSessionIfExpired();\n\t\tif (refreshFailure != null) return new ReadSessionFailure(refreshFailure);\n\n\t\treturn this._session != null && this.isSessionForIntegrationHost(this._session) ? this._session : undefined;\n\t}\n\n\t/**\n\t * The session lookups' prelude for a caller that can surface a failure (`throwOnError`): the refresh's failure to\n\t * report, or `'unconnected'`, so a throttled refresh is not mistaken for \"no pull request\" and kept.\n\t */\n\tprotected async prepareSessionLookup(): Promise<Error | 'unconnected' | undefined> {\n\t\tconst connected = this.maybeConnected ?? (await this.isConnected());\n\t\tif (!connected) return 'unconnected';\n\n\t\tconst failure = await this.refreshSessionIfExpired();\n\t\tif (failure != null) return failure;\n\n\t\t// A disconnect, or a refetch the cloud answered for another host, can leave no session to read with.\n\t\treturn this._session != null ? undefined : 'unconnected';\n\t}\n\n\t/**\n\t * {@link resolveReadSession} for a read that already rethrows its provider's failures (a repository or account\n\t * lookup), or whose callers treat any failure as \"nothing to show\": a token that could not be fetched is\n\t * thrown like those failures, so it is classified as the failed request it is rather than as a missing\n\t * connection.\n\t */\n\tprotected async resolveReadSessionOrThrow(\n\t\tconnectionId: string | undefined,\n\t\tscope: ScopedLogger | undefined,\n\t\tcloud = true,\n\t): Promise<ProviderAuthenticationSession | undefined> {\n\t\tconst session = await this.resolveReadSession(connectionId, scope, undefined, cloud);\n\t\tif (isReadSessionFailure(session)) throw session.error;\n\n\t\treturn session;\n\t}\n\n\tprotected trackWriteSession(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { cloud: boolean; observeHostChanges: boolean },\n\t): TrackedSession {\n\t\tconst verify = async () => {\n\t\t\tconst current = await this.resolveReadSessionOrThrow(session.id, undefined, options?.cloud);\n\t\t\treturn current != null && isSameAuthenticationSession(current, session);\n\t\t};\n\t\treturn this.authenticationService.trackIssuedSession(this.id, session, verify, options?.observeHostChanges);\n\t}\n\n\t@debug()\n\tasync connect(source: Sources): Promise<boolean> {\n\t\ttry {\n\t\t\treturn Boolean(await this.ensureSession({ createIfNeeded: true, source: source }));\n\t\t} catch (_ex) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprotected providerOnConnect?(): void | Promise<void>;\n\n\t@gate()\n\t@debug()\n\tasync disconnect(options?: { silent?: boolean; currentSessionOnly?: boolean }): Promise<void> {\n\t\tif (options?.currentSessionOnly && this._session === null) return;\n\n\t\tlet signOut = !options?.currentSessionOnly;\n\n\t\t// Asked before queueing: the user's answer can take any time, and the queue must not wait on it.\n\t\tif (this._session != null && !options?.currentSessionOnly && !options?.silent) {\n\t\t\tconst decision = await this.ctx.hooks?.onConfirmDisconnect?.({\n\t\t\t\tintegrationName: this.name,\n\t\t\t\tofferSignOut: this.authenticationService.supports(this.authProvider.id),\n\t\t\t});\n\t\t\tif (decision == null) return;\n\n\t\t\tsignOut = decision.signOut;\n\t\t}\n\n\t\t// Waits for a forced re-sync in flight, so the session it settles cannot land over the disconnect.\n\t\tawait this.runSessionTransition(() => this.disconnectLocked(options, signOut));\n\t}\n\n\tprivate async disconnectLocked(\n\t\toptions: { silent?: boolean; currentSessionOnly?: boolean } | undefined,\n\t\tsignOut: boolean,\n\t\tauthority?: CloudIntegrationSync,\n\t): Promise<boolean> {\n\t\tif (options?.currentSessionOnly && this._session === null) return false;\n\n\t\tconst connected = this._session != null;\n\n\t\tif (authority != null) {\n\t\t\tconst cleared = await this.authenticationService.clearAbsentCloudScope(\n\t\t\t\tthis.authProvider.id,\n\t\t\t\tthis.authProviderDescriptor,\n\t\t\t\tauthority,\n\t\t\t);\n\t\t\tif (\n\t\t\t\t!cleared ||\n\t\t\t\t!this.authenticationService.isCloudListCurrent(this.authProvider.id, this.domain, authority)\n\t\t\t) {\n\t\t\t\tthis._session = undefined;\n\t\t\t\tthis.invalidateDiscoveryCaches();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (signOut) {\n\t\t\tconst authProvider = await this.authenticationService.get(this.authProvider.id);\n\t\t\tawait authProvider.deleteAllSessions(this.authProviderDescriptor);\n\t\t}\n\n\t\tthis.resetRequestExceptionCount('all');\n\t\tthis._session = null;\n\n\t\tif (connected) {\n\t\t\t// Don't store the disconnected flag if silently disconnecting or disconnecting this only for\n\t\t\t// this current VS Code session (will be re-connected on next restart)\n\t\t\tif (!options?.currentSessionOnly && !options?.silent) {\n\t\t\t\tvoid this.ctx.storage.storeWorkspace(this.connectedKey, false).catch();\n\t\t\t}\n\n\t\t\tthis._onDidChange.fire();\n\t\t\t// Fired even for a session-only disconnect: the integration IS disconnected until it reconnects, and the\n\t\t\t// service's connected-key cache only forgets the key on this event — skipped, listeners kept showing it\n\t\t\t// connected and the cache swallowed the eventual reconnect as a duplicate\n\t\t\tthis.didChangeConnection?.fire({ integration: this, key: this.key, reason: 'disconnected' });\n\t\t}\n\n\t\tawait this.providerOnDisconnect?.();\n\t\treturn true;\n\t}\n\n\tprotected providerOnDisconnect?(): void | Promise<void>;\n\n\t@debug()\n\tasync reauthenticate(): Promise<void> {\n\t\t// `forceNewSession` below deletes the stored secrets to reconnect. Ahead of the guard — see\n\t\t// `onStoredTokensReplaced`.\n\t\tthis.onStoredTokensReplaced();\n\n\t\tconst cleared = await this.runSessionTransition(() => {\n\t\t\tif (this._session === undefined) return Promise.resolve(false);\n\n\t\t\tthis._session = undefined;\n\t\t\treturn Promise.resolve(true);\n\t\t});\n\t\tif (!cleared) return;\n\n\t\tvoid (await this.ensureSession({ createIfNeeded: true, forceNewSession: true }));\n\t}\n\n\trefresh(): void {\n\t\tvoid this.ensureSession({ createIfNeeded: false });\n\t}\n\n\t/**\n\t * Drops the cached session when its token is no longer `accessToken` (a session replaced outside the\n\t * integration) and resolves it again, in one transition, so nothing in flight publishes the replaced one.\n\t */\n\tprotected resyncSessionIfTokenChanged(accessToken: string | undefined): Promise<void> {\n\t\treturn this.runSessionTransition(async () => {\n\t\t\tif (this._session != null && this._session.accessToken !== accessToken) {\n\t\t\t\tthis._session = undefined;\n\t\t\t}\n\t\t\tawait this.resolveSessionLocked({ createIfNeeded: false });\n\t\t});\n\t}\n\n\tprivate _syncRequestsPerFailedUsecase = new Set<SyncReqUsecase>();\n\thasSessionSyncRequests(): boolean {\n\t\treturn this._syncRequestsPerFailedUsecase.size > 0;\n\t}\n\trequestSessionSyncForUsecase(syncReqUsecase: SyncReqUsecase): void {\n\t\tthis._syncRequestsPerFailedUsecase.add(syncReqUsecase);\n\t}\n\n\t/**\n\t * The per-connection counterpart of the primary session's expire-and-resync recovery: a token the\n\t * provider refused is refreshed once through the GK cloud, which exchanges the refresh token server-side\n\t * (the client never holds one). Armed by {@link handleConnectionAuthenticationRejection} and consumed by\n\t * {@link resolveReadSession}; a rejection it declines belongs to {@link trackRequestException} instead.\n\t */\n\tprivate readonly _rejectedTokens = new RejectedTokenTracker();\n\tprotected readonly lookupBackoff = new FailureBackoff();\n\n\tprotected clearLookupBackoff(): void {\n\t\tthis.lookupBackoff.clearAll();\n\t}\n\n\t/**\n\t * Called by every path that replaces or removes the stored tokens — a disconnect, a forced re-sync, a\n\t * reauthentication, or the connection set changing. A rejection names a specific credential, so once that\n\t * credential is gone the rejection describes nothing and must not force a refresh (or, for a deleted\n\t * connection, outlive it).\n\t *\n\t * Deliberately NOT conditioned on `_session`. A per-connection read resolves through the auth provider and\n\t * never populates the cached primary session, so the connections this recovery exists for are exactly the\n\t * ones with no `_session` to inspect — the same blind spot the recovery itself was added to fix. Callers\n\t * that guard on `_session` therefore invoke this ahead of that guard.\n\t */\n\tprotected onStoredTokensReplaced(): void {\n\t\tthis._rejectedTokens.clear();\n\t\tthis.clearLookupBackoff();\n\t\tthis.invalidateDiscoveryCaches();\n\t}\n\n\t/**\n\t * Drops what this integration discovered through its session and kept for later reads: a tracker's sites,\n\t * projects or teams. Called by every path that replaces the stored tokens (see {@link onStoredTokensReplaced}),\n\t * which includes the forced re-sync a consumer's refresh runs, and by a read asked to `forceSync`. A refresh is\n\t * the consumer saying the account may have changed, and a project created or deleted since the first read would\n\t * otherwise stay invisible, or keep being searched, for the rest of the session (#5907).\n\t */\n\tinvalidateDiscoveryCaches(): void {}\n\n\tinvalidateDiscoveryForConnection(_connectionId?: string): void {\n\t\tthis.invalidateDiscoveryCaches();\n\t}\n\n\t/**\n\t * The one owner of the drop a forced refresh makes before its sync, so it never serves a discovery list cached\n\t * before it: drops the discovery of `connectionId` (the primary when omitted), whether the sync then succeeds,\n\t * fails transiently and keeps the stored token, or hands back the same token (a PAT always does).\n\t *\n\t * Called once per forced refresh, by the path that runs its sync: an explicit forced re-sync of the primary\n\t * ({@link syncCloudConnection}, run by a primary `forceSync` read and by `refreshConnections`), and a\n\t * per-connection `forceSync` read, whose re-sync goes through the auth provider and never reaches it. An `expired`\n\t * re-sync is not a refresh the caller asked for and keeps its discovery. A strict autolinks refresh also drops at\n\t * completion, a separate drop that retires the reads started while it was pending (see `getAutolinkReferences`).\n\t */\n\tbeginForcedRefresh(connectionId?: string): void {\n\t\tthis.invalidateDiscoveryForConnection(connectionId);\n\t}\n\n\tgetSessionDiscoveryGeneration(_sessionId?: string, _connectionId?: string, _cloud?: boolean): number {\n\t\treturn this.discoveryGeneration;\n\t}\n\n\tget discoveryGeneration(): number {\n\t\treturn 0;\n\t}\n\n\tprotected isResolvedSessionCurrent(\n\t\t_session: ProviderAuthenticationSession | undefined,\n\t\t_generation: number,\n\t): boolean {\n\t\treturn true;\n\t}\n\n\tonSessionPublishing(publication: SessionPublication): void {\n\t\tconst { session, previousSessionId, replacePrimary } = publication;\n\t\tconst cloud = session != null ? session.cloud : publication.cloud;\n\t\tconst sameVariant = cloud == null || this._session?.cloud == null || cloud === this._session.cloud;\n\t\tconst affectsPrimary =\n\t\t\t(replacePrimary === true && (session != null || cloud == null || (this._session != null && sameVariant))) ||\n\t\t\t(this._session === null && session != null) ||\n\t\t\t(this._session != null &&\n\t\t\t\tsameVariant &&\n\t\t\t\t(session?.id === this._session.id || previousSessionId === this._session.id));\n\t\tif (affectsPrimary && getSessionIdentity(this._session) !== getSessionIdentity(session)) {\n\t\t\tthis._session = undefined;\n\t\t}\n\t\tthis.invalidatePublishedSession(publication, affectsPrimary);\n\t}\n\n\tprotected invalidatePublishedSession(_publication: SessionPublication, _affectsPrimary: boolean): void {\n\t\tthis.invalidateDiscoveryCaches();\n\t}\n\n\tonCloudConnectionRetired(connectionId: string, retained = false): void {\n\t\tconst wasConnected = this._session?.cloud === true && this._session.id === connectionId;\n\t\tthis.onSessionPublishing({ previousSessionId: connectionId, connectionId: connectionId, cloud: true });\n\t\tif (!wasConnected || retained) return;\n\n\t\tthis._onDidChange.fire();\n\t\tthis.didChangeConnection.fire({ integration: this, key: this.key, reason: 'disconnected' });\n\t\tvoid this.providerOnDisconnect?.();\n\t}\n\n\tonSessionsRemoving(connectionId?: string, cloud?: boolean): void {\n\t\tthis.invalidatePublishedSession(\n\t\t\t{\n\t\t\t\tpreviousSessionId: connectionId,\n\t\t\t\tconnectionId: connectionId,\n\t\t\t\tcloud: cloud,\n\t\t\t\tretireAll: connectionId == null,\n\t\t\t},\n\t\t\tfalse,\n\t\t);\n\t}\n\n\tprivate static readonly requestExceptionLimit = 5;\n\t/** The primary connection's strikes (see {@link trackRequestException}). */\n\tprivate requestExceptionCount = 0;\n\t/** The strikes of every other connection, by connection id. */\n\tprivate readonly connectionRequestExceptionCounts = new Map<string, number>();\n\n\t/**\n\t * The connection a read's strikes and successes count against: `undefined` for the primary, which a read reaches\n\t * by omitting `connectionId` or by naming it, else the connection named. The primary is named by its session's id,\n\t * which is its connection's id, or, before that session is resolved, by the connection configured as primary.\n\t */\n\tprivate getSecondaryConnectionId(connectionId: string | undefined): string | undefined {\n\t\tif (!connectionId || connectionId === this._session?.id) return undefined;\n\t\tif (\n\t\t\tconnectionId ===\n\t\t\tthis.authenticationService.getPrimaryConnectionId(this.authProvider.id, this.authProviderDescriptor)\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn connectionId;\n\t}\n\n\tprivate resetRecoveryAccounting(): void {\n\t\tthis.requestExceptionCount = 0;\n\t\tthis.connectionRequestExceptionCounts.clear();\n\t\tthis._syncRequestsPerFailedUsecase.clear();\n\t\tthis._rejectedTokens.clear();\n\t\tthis.clearLookupBackoff();\n\t}\n\n\t/**\n\t * Clears the strikes of the selected connection (the primary when omitted) after a successful request,\n\t * or of every connection for `'all'`.\n\t */\n\tresetRequestExceptionCount(syncReqUsecase: SyncReqUsecase | 'all', connectionId?: string): void {\n\t\tif (syncReqUsecase === 'all') {\n\t\t\tthis.resetRecoveryAccounting();\n\t\t\tthis.invalidateDiscoveryCaches();\n\t\t\treturn;\n\t\t}\n\n\t\tconst secondary = this.getSecondaryConnectionId(connectionId);\n\t\tif (secondary != null) {\n\t\t\tthis.connectionRequestExceptionCounts.delete(secondary);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.requestExceptionCount = 0;\n\t\t// Only the primary session's refused token requests a re-sync.\n\t\tthis._syncRequestsPerFailedUsecase.delete(syncReqUsecase);\n\t}\n\n\t/**\n\t * Resets the primary connection's request exceptions without resetting the amount of syncs\n\t */\n\tsmoothifyRequestExceptionCount(): void {\n\t\t// On resync we reset exception count only to avoid infinitive syncs on failure\n\t\tthis.requestExceptionCount = 0;\n\t}\n\n\tasync reset(): Promise<void> {\n\t\tawait this.runSessionTransition(async () => {\n\t\t\tawait this.disconnectLocked({ silent: true }, true);\n\t\t\tawait this.ctx.storage.deleteWorkspace(this.connectedKey);\n\t\t});\n\t}\n\n\t/**\n\t * Drops the in-memory session so the next access re-resolves it from storage. Used when the primary\n\t * connection changed underneath a warm integration (e.g. after `setPrimaryConnection`/\n\t * `deleteConnection`). Unlike {@link reset}/{@link disconnect}, it deletes nothing from storage.\n\t */\n\tswitchConnection(): Promise<void> {\n\t\t// A connection was deleted, or a different one became primary. Ahead of the guard — see\n\t\t// `onStoredTokensReplaced`.\n\t\tthis.onStoredTokensReplaced();\n\t\t// The strikes are kept by role, so the former primary's would otherwise pass to the new one.\n\t\tthis.requestExceptionCount = 0;\n\t\tthis.connectionRequestExceptionCounts.clear();\n\n\t\t// Queued, so a resolution already running finishes with the former primary and this one then re-resolves.\n\t\treturn this.runSessionTransition(async () => {\n\t\t\tif (this._session === undefined) return;\n\n\t\t\tconst wasConnected = this._session != null;\n\t\t\tthis._session = undefined;\n\t\t\tthis._onDidChange.fire();\n\n\t\t\tconst session = await this.resolveSessionLocked({ createIfNeeded: false });\n\t\t\tif (session != null || !wasConnected) return;\n\n\t\t\tthis._onDidChange.fire();\n\t\t\tthis.didChangeConnection?.fire({ integration: this, key: this.key, reason: 'disconnected' });\n\t\t\tawait this.providerOnDisconnect?.();\n\t\t});\n\t}\n\n\tprivate skippedNonCloudReported = false;\n\t/**\n\t * Resolves the re-sync's failure, when its token fetch threw (cancellations included), so a caller can report it.\n\t * Never rejects: the cloud sync fans this out over every integration and must not fail on one.\n\t */\n\t@debug()\n\tsyncCloudConnection(state: 'connected' | 'disconnected', forceSync: boolean): Promise<Error | undefined> {\n\t\treturn this.runSessionTransition(() => this.syncCloudConnectionLocked(state, forceSync));\n\t}\n\n\tsyncListedCloudConnection(\n\t\tstate: 'connected' | 'disconnected',\n\t\tforceSync: boolean,\n\t\tauthority: CloudIntegrationSync,\n\t): Promise<Error | undefined> {\n\t\treturn this.runSessionTransition(() => this.syncCloudConnectionLocked(state, forceSync, 'explicit', authority));\n\t}\n\n\tprivate async syncCloudConnectionLocked(\n\t\tstate: 'connected' | 'disconnected',\n\t\tforceSync: boolean,\n\t\treason: 'explicit' | 'expired' = 'explicit',\n\t\tauthority?: CloudIntegrationSync,\n\t): Promise<Error | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tif (authority?.isCurrent() === false) return undefined;\n\n\t\tif (this._session?.cloud === false && state !== 'connected') {\n\t\t\tif (this.id !== GitCloudHostIntegrationId.GitHub && !this.skippedNonCloudReported) {\n\t\t\t\tthis.ctx.hooks?.session?.onRefreshSkipped?.({\n\t\t\t\t\tid: this.id,\n\t\t\t\t\treason: 'skip-non-cloud',\n\t\t\t\t\tcloud: false,\n\t\t\t\t});\n\t\t\t\tthis.skippedNonCloudReported = true;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\n\t\tlet failure: Error | undefined;\n\t\tswitch (state) {\n\t\t\tcase 'connected': {\n\t\t\t\tconst oldSession = this._session;\n\t\t\t\tlet resyncing = false;\n\t\t\t\tif (forceSync) {\n\t\t\t\t\t// Get a new session from the cloud. The stored one is refetched rather than deleted first (see\n\t\t\t\t\t// `GetSessionOptions.refetch`), so a fetch that fails transiently keeps the token it had.\n\t\t\t\t\tif (reason === 'explicit') {\n\t\t\t\t\t\tthis._rejectedTokens.clear();\n\t\t\t\t\t\tthis.clearLookupBackoff();\n\t\t\t\t\t\tthis.beginForcedRefresh();\n\t\t\t\t\t}\n\t\t\t\t\t// The cached session is kept while the replacement is fetched (the refetch does not read it): a\n\t\t\t\t\t// transient failure then leaves it as it was, expiry included, and a read meanwhile does not have to\n\t\t\t\t\t// resolve a session of its own, which during a GK API outage fails the same way and reports the\n\t\t\t\t\t// integration as not connected (gitkraken/kepler#3546). Clear our \"stay disconnected\" flag.\n\t\t\t\t\tawait this.ctx.storage.deleteWorkspace(this.connectedKey);\n\t\t\t\t\tresyncing = true;\n\t\t\t\t} else {\n\t\t\t\t\t// Only sync if we're not connected and not disabled and don't have pending errors\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis._session != null ||\n\t\t\t\t\t\tthis.requestExceptionCount > 0 ||\n\t\t\t\t\t\tthis.ctx.storage.getWorkspace(this.connectedKey) === false\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\n\t\t\t\t\tforceSync = true;\n\t\t\t\t}\n\n\t\t\t\t// sync option, rather than createIfNeeded, makes sure we don't call connectCloudIntegrations and open a gkdev window\n\t\t\t\t// if there was no session or some problem fetching/refreshing the existing session from the cloud api\n\t\t\t\tlet newSession: ProviderAuthenticationSession | undefined;\n\t\t\t\tlet refetchFailed = false;\n\t\t\t\tconst signOutMark = resyncing ? this.authenticationService.getSignOutMark() : undefined;\n\t\t\t\ttry {\n\t\t\t\t\tnewSession = await this.resolveSessionLocked({\n\t\t\t\t\t\tsync: forceSync,\n\t\t\t\t\t\trefetch: resyncing,\n\t\t\t\t\t\tauthority: authority,\n\t\t\t\t\t});\n\t\t\t\t} catch (ex) {\n\t\t\t\t\trefetchFailed = true;\n\t\t\t\t\tif (!isCancellationError(ex)) {\n\t\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\t}\n\t\t\t\t\t// Not evidence the connection is gone (#5569). A cancelled refetch is still reported: its caller must\n\t\t\t\t\t// not read with the session it could not replace.\n\t\t\t\t\tfailure = toError(ex);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\toldSession &&\n\t\t\t\t\tnewSession &&\n\t\t\t\t\tnewSession === this._session &&\n\t\t\t\t\tnewSession.accessToken !== oldSession.accessToken\n\t\t\t\t) {\n\t\t\t\t\tthis.resetRecoveryAccounting();\n\t\t\t\t}\n\n\t\t\t\t// The forced re-sync above kept the stored token and its descriptor until a replacement arrived.\n\t\t\t\t// Drop both only when the replacement fetch came back definitively empty, so a connection whose\n\t\t\t\t// token is really gone is cleanly disconnected (#5497) while a healthy one survives a blip (#5569).\n\t\t\t\tif (resyncing && newSession == null && !refetchFailed) {\n\t\t\t\t\tconst authProvider = await this.authenticationService.get(this.authProvider.id);\n\t\t\t\t\tif (authority?.isCurrent() === false) return undefined;\n\n\t\t\t\t\tconst options = { preserveConfigured: false, signOutMark: signOutMark };\n\t\t\t\t\tif (authProvider instanceof CloudIntegrationAuthenticationProvider) {\n\t\t\t\t\t\tawait authProvider.deleteSession(this.authProviderDescriptor, { ...options, sync: authority });\n\t\t\t\t\t} else {\n\t\t\t\t\t\tawait authProvider.deleteSession(this.authProviderDescriptor, options);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'disconnected':\n\t\t\t\tif (!(await this.disconnectLocked({ silent: true }, true, authority))) return undefined;\n\t\t\t\tbreak;\n\t\t}\n\t\tthis._resyncs++;\n\t\tthis._lastResyncFailure = failure;\n\t\treturn failure;\n\t}\n\n\t/**\n\t * Proves the credential with an uncached check, rejecting with the provider's `AuthenticationError` when it is\n\t * refused, and with anything else when the check proves nothing. A `403` proves nothing either: the credential\n\t * authenticated and was only denied the check's request.\n\t *\n\t * Implemented by the providers whose reads can reach their scopes without an uncached request to the connection\n\t * first: discovery served from a per-token cache (Azure DevOps, Bitbucket, Jira Cloud), or an SDK fan-out across\n\t * the requested repositories (Bitbucket Data Center). There, a dead token comes back as scoped refusals with no\n\t * failure of the connection: the same shape as one scope refusing a sound credential.\n\t * {@link confirmScopedAuthFailures} uses this to tell the two apart.\n\t */\n\tprotected validateCredential?(session: ProviderAuthenticationSession): Promise<void>;\n\n\t/**\n\t * Credentials that passed {@link validateCredential} within the last minute. A probe already in flight is\n\t * shared rather than repeated, and a refused one is not kept. Cleared whenever a credential is refused (see\n\t * {@link handleProviderException}), so a pass is never vouched for past a refusal this instance has seen.\n\t */\n\tprivate readonly _validatedCredentials = new PromiseCache<string, void>({ createTTL: 60 * 1000, capacity: 10 });\n\n\t/**\n\t * Whether a scope's refusal is the credential's own, by the provider's account of it: e.g. a token missing the\n\t * OAuth scopes the read needs. The probe cannot see that, because it proves the token authenticates, not that\n\t * it is authorized. So {@link confirmScopedAuthFailures} publishes one for the connection, unscoped, which asks\n\t * for the reconnect (consenting to the scopes again) that fixes it, and keeps the results of the scopes that\n\t * answered.\n\t */\n\tprotected isCredentialRefusal?(refusal: ProviderRefusal): boolean;\n\n\t/**\n\t * Names why a confirmed credential was refused by one scope, from what the refusal said (see\n\t * `ProviderWarning.cause`). Called only by {@link confirmScopedAuthFailures}, once the credential passed: the\n\t * refusals this names are indistinguishable from a dead credential until then.\n\t */\n\tprotected describeRefusal?(\n\t\tsession: ProviderAuthenticationSession,\n\t\trefusal: ProviderRefusal,\n\t\tscope: ProviderWarningScope,\n\t): ProviderWarningCause | undefined;\n\n\t/**\n\t * Settles what a read's only-scoped authentication failures mean, when the provider can tell (see\n\t * {@link validateCredential}).\n\t *\n\t * A refused credential is thrown: the caller's `catch` then fails the read as a whole, exactly as it does when\n\t * discovery is not cached and the first request is the one refused. Without this, a token revoked after\n\t * discovery would publish scoped `auth` warnings, which a consumer must not answer with a reconnect (see\n\t * `ProviderWarning.scope`), next to results served from the cache, for as long as the token stays stored.\n\t *\n\t * A confirmed credential makes each refusal the scope's own, so its cause is named through\n\t * {@link describeRefusal}. A probe that fails for another reason proves nothing either way and leaves the read\n\t * as it was.\n\t *\n\t * A refusal the provider pins on the credential itself (see {@link isCredentialRefusal}) is published for the\n\t * connection instead, without a probe.\n\t *\n\t * A token that passed within the last minute is not probed again, so a scope that keeps refusing it costs one\n\t * probe a minute, and a revocation right after a probe can take up to a minute to surface: until then its\n\t * refusals stay scoped, and may be named. A probe that proved nothing is not remembered, so the next read probes\n\t * again, and a credential no probe can confirm (e.g. a Bitbucket Data Center project access token) is probed on\n\t * every read that has scoped refusals.\n\t */\n\tprotected async confirmScopedAuthFailures(\n\t\tsession: ProviderAuthenticationSession,\n\t\tmetadata: CollectionMetadata | undefined,\n\t): Promise<void> {\n\t\tif (!hasOnlyScopedAuthFailures(metadata)) return;\n\n\t\t// Published for the connection, as a refusal outside any scope would be, while the scopes that answered keep\n\t\t// their results. That already asks for a reconnect, so there is nothing left for a probe to settle.\n\t\tif (this.markCredentialRefusals(metadata)) return;\n\t\tif ((await this.confirmCredential(session)) !== 'confirmed') return;\n\n\t\tthis.nameRefusalCauses(session, metadata);\n\t}\n\n\t/**\n\t * Settles what a batch read's authentication refusals mean before the call is judged, as\n\t * {@link confirmScopedAuthFailures} settles an account-wide read's: each refused slot comes back carrying the scope\n\t * failure it was recorded as, against the scope its target names (see {@link batchTargetScope}), and a read\n\t * publishes that instead of the bare reason.\n\t *\n\t * When any target answered, that proved the credential, so each refusal is its own target's. When every target\n\t * failed, the call fails as a whole, as it always has, unless every failure is a refusal of a credential that checks\n\t * out. Every target refusing is also what a dead credential looks like, so the credential is checked once first,\n\t * with {@link validateCredential}. A check that proves nothing leaves the refusals scoped and unnamed, as it leaves\n\t * an account-wide read's. A provider with no check cannot tell, and a refusal it pins on the credential (see\n\t * {@link isCredentialRefusal}) needs none, so either still fails the call.\n\t *\n\t * `keepOtherFailures` is for the etag cheap check, whose failed targets fall through to a full read one by one:\n\t * there, only a refused credential fails the call, always on one of the refusals, and every other failure stays\n\t * its own slot's. A batch with refusals and other failures but no answer then has its credential checked, as when\n\t * every target refused, and a provider with no check leaves its refusals scoped and unnamed.\n\t */\n\tprotected async settleBatchRefusals<T>(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly BatchTarget[],\n\t\tslots: PromiseSettledResult<T>[],\n\t\toptions?: { keepOtherFailures?: boolean },\n\t): Promise<BatchSlot<T>[]> {\n\t\tconst keepOtherFailures = options?.keepOtherFailures ?? false;\n\t\tconst answered = new Set(\n\t\t\tslots.flatMap((slot, i) => (slot.status === 'fulfilled' ? [batchTargetRepository(targets[i])] : [])),\n\t\t);\n\t\tconst credentialDied = slots.some((slot, i) => {\n\t\t\tif (slot.status !== 'rejected' || !isRefusedCredential(slot.reason)) return false;\n\n\t\t\tconst repository = batchTargetRepository(targets[i]);\n\t\t\treturn repository != null && answered.has(repository);\n\t\t});\n\t\tconst failures = slots.map((slot, i) => {\n\t\t\tif (slot.status !== 'rejected' || !(slot.reason instanceof AuthenticationError)) return undefined;\n\t\t\tif (credentialDied && isRefusedCredential(slot.reason)) return undefined;\n\n\t\t\treturn toCollectionScopeFailure(batchTargetScope(this.id, targets[i]), slot.reason);\n\t\t});\n\t\tconst refused = failures.filter(f => f != null);\n\t\tif (!refused.length) {\n\t\t\tif (!keepOtherFailures) {\n\t\t\t\tthrowIfAllSettledFailed(slots);\n\t\t\t}\n\t\t\treturn slots;\n\t\t}\n\n\t\tconst metadata: CollectionMetadata = { completeness: 'partial', failures: refused };\n\t\tconst credentialRefused = this.markCredentialRefusals(metadata);\n\t\tif (slots.some(slot => slot.status === 'fulfilled')) {\n\t\t\tthis.nameRefusalCauses(session, metadata);\n\t\t} else if (credentialRefused) {\n\t\t\tthrowIfAllSettledFailed(keepOtherFailures ? slots.filter((_, i) => failures[i] != null) : slots);\n\t\t} else if (refused.length < slots.length && !keepOtherFailures) {\n\t\t\t// Fails on a target that failed for another reason: failing on a refusal would run the credential's own\n\t\t\t// recovery (a session expiry or a disconnect strike) for what may be only its target's refusal.\n\t\t\tthrowIfAllSettledFailed(slots.filter((_, i) => failures[i] == null));\n\t\t} else {\n\t\t\tconst confirmation = await this.confirmCredential(session);\n\t\t\tif (confirmation == null) {\n\t\t\t\tif (refused.length === slots.length) {\n\t\t\t\t\tthrowIfAllSettledFailed(slots);\n\t\t\t\t}\n\t\t\t} else if (confirmation === 'confirmed') {\n\t\t\t\tthis.nameRefusalCauses(session, metadata);\n\t\t\t}\n\t\t}\n\n\t\treturn slots.map((slot, i) => {\n\t\t\tconst failure = failures[i];\n\t\t\treturn slot.status === 'rejected' && failure != null ? { ...slot, failure: failure } : slot;\n\t\t});\n\t}\n\n\tprotected settleBatchCredential<T>(\n\t\tsyncReqUsecase: SyncReqUsecase,\n\t\tsettled: readonly BatchSlot<T>[],\n\t\toptions: { scope: ScopedLogger | undefined; connectionId: string | undefined; reset: boolean },\n\t): void {\n\t\tconst refusal = findRefusedCredentialSlot(settled);\n\t\tif (refusal != null) {\n\t\t\tthis.handleProviderException(syncReqUsecase, refusal.reason, {\n\t\t\t\tscope: options.scope,\n\t\t\t\tconnectionId: options.connectionId,\n\t\t\t});\n\t\t} else if (options.reset) {\n\t\t\tthis.resetRequestExceptionCount(syncReqUsecase, options.connectionId);\n\t\t}\n\t}\n\n\t/**\n\t * Shows one notice, and spends at most one strike, for a batch read whose targets failed with a server error or a\n\t * timeout. Our own clients leave both to the batch (see `reportRequestFailure`) instead of spending them per\n\t * target. `strike` is true only when every target failed and the call's own failure spent none: a call that\n\t * answered some targets showed the host is up, and budgets strikes the same way as the rest of its failures. The\n\t * strike is `connectionId`'s, the connection the call read.\n\t */\n\tprotected reportDeferredRequestFailures(\n\t\tslots: readonly PromiseSettledResult<unknown>[] | undefined,\n\t\tstrike: boolean,\n\t\tconnectionId: string | undefined,\n\t): void {\n\t\tlet notify: (() => void) | undefined;\n\t\tfor (const slot of slots ?? []) {\n\t\t\tif (slot.status !== 'rejected') continue;\n\n\t\t\tnotify = takeDeferredRequestFailure(slot.reason);\n\t\t\tif (notify != null) break;\n\t\t}\n\n\t\tif (notify == null) return;\n\n\t\tif (strike) {\n\t\t\tthis.trackRequestException({ connectionId: connectionId });\n\t\t}\n\t\tnotify();\n\t}\n\n\t/**\n\t * The failure handling of an etag cheap check that failed as a whole. Only a refused credential runs\n\t * {@link handleProviderException}, for its session expiry, re-authentication and strike. Anything else is only\n\t * logged, spending no strike and showing no notice: every target the check held then falls through to a full\n\t * read, which spends and notifies if the host really is failing, or is dropped, as rate-limited or without a\n\t * connection, with the check's warning. A rate limit costs nothing in `handleProviderException` either.\n\t */\n\tprotected handleEtagCheckException(\n\t\tsyncReqUsecase: SyncReqUsecase,\n\t\tex: Error,\n\t\toptions: { scope: ScopedLogger | undefined; connectionId: string | undefined },\n\t): void {\n\t\tif (ex instanceof AuthenticationError) {\n\t\t\tthis.handleProviderException(syncReqUsecase, ex, options);\n\t\t\treturn;\n\t\t}\n\t\tif (isCancellationError(ex)) return;\n\n\t\tif (options.scope != null) {\n\t\t\toptions.scope.error(ex);\n\t\t} else {\n\t\t\tLogger.error(ex);\n\t\t}\n\t}\n\n\t/** Marks the scoped refusals the provider pins on the credential (see {@link isCredentialRefusal}). */\n\tprivate markCredentialRefusals(metadata: CollectionMetadata | undefined): boolean {\n\t\tconst isCredentialRefusal = this.isCredentialRefusal?.bind(this);\n\t\treturn isCredentialRefusal != null && markCredentialRefusals(metadata, isCredentialRefusal);\n\t}\n\n\t/**\n\t * Checks the credential with {@link validateCredential}, rethrowing the provider's refusal when it is refused.\n\t * `undefined` when the provider has no check, and `'unproven'` when the check proved nothing either way.\n\t */\n\tprivate async confirmCredential(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<'confirmed' | 'unproven' | undefined> {\n\t\tconst validateCredential = this.validateCredential?.bind(this);\n\t\tif (validateCredential == null) return undefined;\n\n\t\t// Keyed by the address as well as the token: a self-managed instance serves every installation on its host,\n\t\t// and one installation accepting a token says nothing about another.\n\t\tconst key = [session.domain, session.baseUrl ?? '', session.accessToken].join('\\n');\n\t\ttry {\n\t\t\tawait this._validatedCredentials.getOrCreate(key, () => validateCredential(session));\n\t\t} catch (ex) {\n\t\t\t// A 403 answered a credential that authenticated and was only denied the check's own request, so it proves\n\t\t\t// nothing about the scopes' refusals either.\n\t\t\tif (ex instanceof AuthenticationError && ex.reason !== AuthenticationErrorReason.Forbidden) throw ex;\n\n\t\t\treturn 'unproven';\n\t\t}\n\t\treturn 'confirmed';\n\t}\n\n\t/** Names each scoped refusal's cause (see {@link describeRefusal}); only once the credential is proven. */\n\tprivate nameRefusalCauses(session: ProviderAuthenticationSession, metadata: CollectionMetadata | undefined): void {\n\t\tconst describeRefusal = this.describeRefusal?.bind(this);\n\t\tif (describeRefusal == null) return;\n\n\t\tattributeScopedAuthFailures(metadata, (refusal, scope) => describeRefusal(session, refusal, scope));\n\t}\n\n\t/** Returns whether it spent a strike (see {@link trackRequestException}). */\n\tprotected handleConnectionAuthenticationRejection(\n\t\tconnectionId: string,\n\t\tsilent?: boolean,\n\t\trejectedAccessToken?: string,\n\t): boolean {\n\t\tthis._validatedCredentials.clear();\n\t\tif (this._rejectedTokens.recordRejection(connectionId, rejectedAccessToken)) return false;\n\n\t\tthis.trackRequestException({ connectionId: connectionId, silent: silent });\n\t\treturn true;\n\t}\n\n\t/** Returns whether it spent a strike (see {@link trackRequestException}). */\n\tprotected handleProviderException(\n\t\tsyncReqUsecase: SyncReqUsecase,\n\t\tex: Error,\n\t\toptions?: { scope?: ScopedLogger | undefined; silent?: boolean; connectionId?: string },\n\t): boolean {\n\t\tif (isCancellationError(ex)) return false;\n\n\t\t// A refused credential may be one a probe passed moments ago: stop vouching for it.\n\t\tif (ex instanceof AuthenticationError && !options?.connectionId) {\n\t\t\tthis._validatedCredentials.clear();\n\t\t}\n\n\t\tif (options?.scope != null) {\n\t\t\toptions.scope.error(ex);\n\t\t} else {\n\t\t\tLogger.error(ex);\n\t\t}\n\n\t\tif (ex instanceof AuthenticationError && options?.connectionId) {\n\t\t\treturn this.handleConnectionAuthenticationRejection(options.connectionId, options.silent);\n\t\t}\n\n\t\tif (ex instanceof AuthenticationError && this._session?.cloud && !this.hasSessionSyncRequests()) {\n\t\t\tthis.requestSessionSyncForUsecase(syncReqUsecase);\n\t\t\t// Expired now, so a read in progress stops using it, and again once any transition in flight settles, in\n\t\t\t// case it publishes the same token anew (compared by token: a re-read is a new object).\n\t\t\tconst refused = this._session.accessToken;\n\t\t\tthis.expireSessionIfToken(refused);\n\t\t\tvoid this.runSessionTransition(() => {\n\t\t\t\tthis.expireSessionIfToken(refused);\n\t\t\t\treturn Promise.resolve();\n\t\t\t});\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!(ex instanceof AuthenticationError) && !(ex instanceof RequestClientError)) return false;\n\n\t\tthis.trackRequestException(options);\n\t\treturn true;\n\t}\n\n\tprivate expireSessionIfToken(accessToken: string): void {\n\t\tif (this._session?.accessToken !== accessToken || this.connectionExpired === true) return;\n\n\t\tthis._session = { ...this._session, expiresAt: new Date(Date.now() - 1) };\n\t}\n\n\t/** Counts completed cloud re-syncs, so a refresh queued behind one reuses its outcome rather than running another. */\n\tprivate _resyncs = 0;\n\tprivate _lastResyncFailure: Error | undefined;\n\tprivate missingExpirityReported = false;\n\t/**\n\t * Resolves the refresh's failure while the session it could not replace is still unusable, so a read can report\n\t * that instead of reading with an expired token or as a missing connection.\n\t */\n\t@gate()\n\tprotected async refreshSessionIfExpired(): Promise<Error | undefined> {\n\t\tif (this._session?.expiresAt != null && this._session.expiresAt < new Date()) {\n\t\t\t// The current session is expired, so get the latest from the cloud and refresh if needed. Queued, so it\n\t\t\t// sees what any transition in flight settles: a re-sync that already replaced the session, or ran meanwhile\n\t\t\t// and could not, is not repeated, and a disconnect stands.\n\t\t\tconst resyncs = this._resyncs;\n\t\t\treturn this.runSessionTransition(async () => {\n\t\t\t\tlet failure: Error | undefined;\n\t\t\t\tif (this._resyncs !== resyncs) {\n\t\t\t\t\tfailure = this._lastResyncFailure;\n\t\t\t\t} else if (this._session != null && this.connectionExpired === true) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfailure = await this.syncCloudConnectionLocked('connected', true, 'expired');\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tfailure = toError(ex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Only a session still there and still expired is this read's failure, including one a provider\n\t\t\t\t// refusal expired again after the re-sync replaced it.\n\t\t\t\tif (this._session == null || this.connectionExpired !== true) return undefined;\n\n\t\t\t\treturn failure ?? new Error(`The ${this.name} session could not be refreshed`);\n\t\t\t});\n\t\t} else if (\n\t\t\tthis._session?.expiresAt == null &&\n\t\t\tthis.id !== GitCloudHostIntegrationId.GitHub &&\n\t\t\t!this.missingExpirityReported\n\t\t) {\n\t\t\tthis.ctx.hooks?.session?.onRefreshSkipped?.({\n\t\t\t\tid: this.id,\n\t\t\t\treason: 'missing-expiry',\n\t\t\t\tcloud: this._session?.cloud,\n\t\t\t});\n\t\t\tthis.missingExpirityReported = true;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Spends a strike against the connection `connectionId` names (the primary when omitted); a server error or timeout\n\t * our API clients report names the connection whose token made the request (see `reportRequestFailure`). At\n\t * `requestExceptionLimit` the primary session is dropped for this session of the host. Another connection has no\n\t * cached session to drop, since each read resolves its own, so its failures go on surfacing on its reads, and\n\t * reaching the limit leaves the primary and every other connection as they are.\n\t */\n\t@trace()\n\ttrackRequestException(options?: { silent?: boolean; connectionId?: string }): void {\n\t\tconst secondary = this.getSecondaryConnectionId(options?.connectionId);\n\t\tif (secondary != null) {\n\t\t\tconst count = (this.connectionRequestExceptionCounts.get(secondary) ?? 0) + 1;\n\t\t\tthis.connectionRequestExceptionCounts.set(secondary, count);\n\t\t\tif (count === IntegrationBase.requestExceptionLimit) {\n\t\t\t\tLogger.warn(\n\t\t\t\t\t`${this.name} connection '${secondary}' has failed ${count} requests since its last success; it is not the primary, so nothing is disconnected`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tthis.requestExceptionCount++;\n\n\t\tif (this.requestExceptionCount >= IntegrationBase.requestExceptionLimit && this._session !== null) {\n\t\t\tif (!options?.silent) {\n\t\t\t\tthis.ctx.hooks?.ui?.onDisconnectedAfterTooManyFailures?.(this.name);\n\t\t\t}\n\t\t\tvoid this.disconnect({ currentSessionOnly: true });\n\t\t}\n\t}\n\n\t@gate()\n\t@trace({ exit: true })\n\tasync isConnected(): Promise<boolean> {\n\t\t// Not `getSession()`: an expired session is still a connection, and refreshing it here would put a GK API round\n\t\t// trip on every connection check and report a throttled refresh as no connection (gitkraken/kepler#3546).\n\t\tconst session =\n\t\t\tthis._session === undefined\n\t\t\t\t? await this.ensureSession({ createIfNeeded: false, source: 'integrations' })\n\t\t\t\t: this._session;\n\t\treturn session != null && this.isSessionForIntegrationHost(session);\n\t}\n\n\t@gate()\n\tprivate async ensureSession(\n\t\toptions:\n\t\t\t| {\n\t\t\t\t\tcreateIfNeeded?: boolean;\n\t\t\t\t\tforceNewSession?: boolean;\n\t\t\t\t\tsync?: never;\n\t\t\t\t\trefetch?: never;\n\t\t\t\t\tsource?: Sources;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tcreateIfNeeded?: never;\n\t\t\t\t\tforceNewSession?: never;\n\t\t\t\t\tsync: boolean;\n\t\t\t\t\trefetch?: boolean;\n\t\t\t\t\tsource?: Sources;\n\t\t\t },\n\t): Promise<ProviderAuthenticationSession | undefined> {\n\t\tif (options.createIfNeeded || options.forceNewSession) {\n\t\t\t// The sign-in runs outside the queue: it waits on the user, and its cloud sync re-enters this integration\n\t\t\t// (`syncCloudConnection`, `isConnected`), which would wait for it. What it stored is then resolved in a\n\t\t\t// transition, so a disconnect during the sign-in still stands.\n\t\t\tif (!(await this.signIn(options))) return this._session ?? undefined;\n\n\t\t\treturn this.runSessionTransition(() => this.resolveSessionLocked({ createIfNeeded: false }));\n\t\t}\n\n\t\treturn this.runSessionTransition(() => this.resolveSessionLocked(options));\n\t}\n\n\t/**\n\t * Asks the auth provider for a session interactively, storing what it gets; whether one came back. A declined\n\t * consent or any other failure is not one, and never throws: it is resolved, like any read, from storage.\n\t */\n\tprivate async signIn(options: {\n\t\tcreateIfNeeded?: boolean;\n\t\tforceNewSession?: boolean;\n\t\tsource?: Sources;\n\t}): Promise<boolean> {\n\t\tif (this.ctx.config.isIntegrationsEnabled?.() === false) return false;\n\n\t\tawait this.ctx.storage.deleteWorkspace(this.connectedKey);\n\t\ttry {\n\t\t\tconst authProvider = await this.authenticationService.get(this.authProvider.id);\n\t\t\treturn (await authProvider.getSession(this.authProviderDescriptor, options)) != null;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Resolves and publishes the session. Only ever runs inside a transition (see {@link runSessionTransition}). */\n\tprivate async resolveSessionLocked(options: {\n\t\tcreateIfNeeded?: boolean;\n\t\tsync?: boolean;\n\t\tauthority?: CloudIntegrationSync;\n\t\trefetch?: boolean;\n\t\tsource?: Sources;\n\t}): Promise<ProviderAuthenticationSession | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst { createIfNeeded, source, sync, refetch } = options;\n\t\t// A forced re-sync keeps the session it is replacing; serving it would skip the refetch the caller forced.\n\t\tif (this._session != null && !refetch) {\n\t\t\tif (this.isSessionForIntegrationHost(this._session)) return this._session;\n\n\t\t\tthis._session = null;\n\t\t}\n\t\tif (this.ctx.config.isIntegrationsEnabled?.() === false) return undefined;\n\n\t\tconst generation = this.discoveryGeneration;\n\n\t\tif (createIfNeeded || sync) {\n\t\t\tawait this.ctx.storage.deleteWorkspace(this.connectedKey);\n\t\t\tif (this.getSessionDiscoveryGeneration(this._session?.id, undefined, this._session?.cloud) > generation) {\n\t\t\t\tif (sync) throw new CancellationError();\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t} else if (this.ctx.storage.getWorkspace(this.connectedKey) === false) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tlet session: ProviderAuthenticationSession | undefined | null;\n\t\ttry {\n\t\t\tconst authProvider = await this.authenticationService.get(this.authProvider.id);\n\t\t\tif (options.authority?.isCurrent() === false) throw new CancellationError();\n\n\t\t\tconst request = sync\n\t\t\t\t? { sync: sync, refetch: refetch, source: source }\n\t\t\t\t: { createIfNeeded: createIfNeeded, source: source };\n\t\t\tsession =\n\t\t\t\tauthProvider instanceof CloudIntegrationAuthenticationProvider\n\t\t\t\t\t? await authProvider.getSession(this.authProviderDescriptor, request, options.authority)\n\t\t\t\t\t: await authProvider.getSession(this.authProviderDescriptor, request);\n\t\t\tif (options.authority?.isCurrent() === false) throw new CancellationError();\n\n\t\t\tif (session?.expiresAt != null && session.expiresAt < new Date()) {\n\t\t\t\tsession = null;\n\t\t\t}\n\t\t\tif (session != null && !this.isSessionForIntegrationHost(session)) {\n\t\t\t\tsession = undefined;\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex) || !this.isResolvedSessionCurrent(undefined, generation)) {\n\t\t\t\tif (sync) throw new CancellationError();\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tawait this.ctx.storage.deleteWorkspace(this.connectedKey);\n\n\t\t\tif (!this.isResolvedSessionCurrent(undefined, generation)) {\n\t\t\t\tif (sync) throw new CancellationError();\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// Only interactive paths can prompt for consent, so a sync failure must reach the rethrow below.\n\t\t\tif (!sync && ex instanceof Error && ex.message.includes('User did not consent')) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\t// On a forced re-sync, propagate so syncCloudConnection can tell a failure from a definitive empty\n\t\t\t// result (#5569); other callers keep swallowing to null so reads never throw.\n\t\t\tif (sync) {\n\t\t\t\t// Throwing skips the reset below, and a lingering count blocks the next non-forced sync.\n\t\t\t\tthis.smoothifyRequestExceptionCount();\n\t\t\t\tthrow ex;\n\t\t\t}\n\n\t\t\tsession = null;\n\t\t}\n\n\t\tif (!this.isResolvedSessionCurrent(session ?? undefined, generation)) {\n\t\t\tif (sync) throw new CancellationError();\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (session === undefined && !createIfNeeded && !sync) {\n\t\t\tawait this.ctx.storage.deleteWorkspace(this.connectedKey);\n\t\t\tif (!this.isResolvedSessionCurrent(undefined, generation)) return undefined;\n\t\t}\n\n\t\tif (getSessionIdentity(this._session) !== getSessionIdentity(session)) {\n\t\t\t// Retire reads before the replacement becomes visible across the storage await.\n\t\t\tthis.onSessionPublishing({ session: session ?? undefined, replacePrimary: true });\n\t\t} else if (refetch && session != null) {\n\t\t\tthis.onSessionPublishing({ session: session, replacePrimary: true });\n\t\t}\n\t\tthis._session = session ?? null;\n\t\tthis.smoothifyRequestExceptionCount();\n\n\t\tif (session != null) {\n\t\t\tconst publishedGeneration = this.getSessionDiscoveryGeneration(session.id, undefined, session.cloud);\n\t\t\tawait this.ctx.storage.storeWorkspace(this.connectedKey, true);\n\t\t\tif (\n\t\t\t\toptions.authority?.isCurrent() === false ||\n\t\t\t\tthis._session !== session ||\n\t\t\t\tpublishedGeneration !== this.getSessionDiscoveryGeneration(session.id, undefined, session.cloud)\n\t\t\t) {\n\t\t\t\tif (sync) throw new CancellationError();\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (\n\t\t\t\t\toptions.authority?.isCurrent() === false ||\n\t\t\t\t\tthis._session !== session ||\n\t\t\t\t\tpublishedGeneration !== this.getSessionDiscoveryGeneration(session.id, undefined, session.cloud)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis._onDidChange.fire();\n\t\t\t\tthis.didChangeConnection?.fire({ integration: this, key: this.key, reason: 'connected' });\n\t\t\t\tif (\n\t\t\t\t\toptions.authority?.isCurrent() === false ||\n\t\t\t\t\tthis._session !== session ||\n\t\t\t\t\tpublishedGeneration !== this.getSessionDiscoveryGeneration(session.id, undefined, session.cloud)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Fired detached, so there is no caller left to catch anything: every implementor is async, and\n\t\t\t\t// a rejection would surface as a process-level unhandled rejection in the host. It is a\n\t\t\t\t// best-effort warm-up, so swallow the failure with a warning instead. Never awaited by the\n\t\t\t\t// transition: its reads can disconnect, which queues a transition of their own.\n\t\t\t\tvoid (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.providerOnConnect?.();\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tscope?.warn(\n\t\t\t\t\t\t\t`Failed to run providerOnConnect for ${this.key}: ${ex instanceof Error ? ex.message : String(ex)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t});\n\t\t}\n\n\t\treturn session ?? undefined;\n\t}\n\n\tgetIgnoreSSLErrors(): boolean | 'force' {\n\t\treturn this.authenticationService.ignoreSSLErrors(this);\n\t}\n\n\tasync searchMyIssues(\n\t\tresource?: ResourceDescriptor,\n\t\tcancellation?: AbortSignal,\n\t\tconnectionId?: string,\n\t): Promise<IssueShape[] | undefined>;\n\tasync searchMyIssues(\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\tconnectionId?: string,\n\t): Promise<IssueShape[] | undefined>;\n\t@trace()\n\tasync searchMyIssues(\n\t\tresources?: ResourceDescriptor | ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\tconnectionId?: string,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.searchMyIssuesResult(resources, cancellation, connectionId))?.value;\n\t}\n\n\t/**\n\t * Result-returning core of {@link searchMyIssues}. Recovers thrown errors into `{ error }` so callers\n\t * (e.g. the ProviderBackend account-wide issues read) can surface a per-provider warning instead of a\n\t * silent empty result. Returns the normalized {@link IssueShape} (there is no raw account-wide issue read).\n\t */\n\tasync searchMyIssuesResult(\n\t\tresources?: ResourceDescriptor | ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\tconnectionId?: string,\n\t): Promise<IntegrationResult<IssueShape[] | undefined>> {\n\t\tconst scope = getScopedLogger();\n\t\t// `connectionId` targets a specific account (multi-account); omitted reads the primary.\n\t\tconst session = await this.resolveReadSession(connectionId, scope);\n\t\tif (session == null || isReadSessionFailure(session)) return session && { error: session.error };\n\n\t\tconst start = performance.now();\n\t\ttry {\n\t\t\tconst issues = await this.searchProviderMyIssues(\n\t\t\t\tsession,\n\t\t\t\tresources != null ? (Array.isArray(resources) ? resources : [resources]) : undefined,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tthis.resetRequestExceptionCount('searchMyIssues', connectionId);\n\t\t\treturn { value: issues, duration: performance.now() - start };\n\t\t} catch (ex) {\n\t\t\tthis.handleProviderException('searchMyIssues', ex, { scope: scope, connectionId: connectionId });\n\t\t\treturn { error: toError(ex), duration: performance.now() - start };\n\t\t}\n\t}\n\n\tprotected abstract searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<IssueShape[] | undefined>;\n\n\t/**\n\t * Paging/truncation-aware variant of {@link searchProviderMyIssues}. The default wraps the normalized read\n\t * as a complete single page; providers with native cursors or fan-out metadata override it.\n\t */\n\tprotected async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\t_options?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\t// The default read has no assignee scoping to broaden, so `_options` is inert here; a provider whose\n\t\t// account-wide read is user-scoped (GitHub/GitLab/Azure) overrides this and honors `includeAllAssignees`.\n\t\tconst values = await this.searchProviderMyIssues(session, resources, cancellation);\n\t\tif (values == null) return undefined;\n\t\treturn { values: values, truncated: false };\n\t}\n\n\t/**\n\t * Result-returning, truncation-aware account-wide issue read. Recovers thrown errors into `{ error }` and\n\t * carries the `truncated` flag so the ProviderBackend facade can report an incomplete read honestly.\n\t */\n\tasync searchMyIssuesWithTruncationResult(\n\t\tresources?: ResourceDescriptor | ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\tconnectionId?: string,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<IntegrationResult<AccountWideIssuesResult | undefined>> {\n\t\tconst scope = getScopedLogger();\n\t\tconst session = await this.resolveReadSession(connectionId, scope);\n\t\tif (session == null || isReadSessionFailure(session)) return session && { error: session.error };\n\n\t\ttry {\n\t\t\tconst result = await this.searchProviderMyIssuesWithTruncation(\n\t\t\t\tsession,\n\t\t\t\tresources != null ? (Array.isArray(resources) ? resources : [resources]) : undefined,\n\t\t\t\tcancellation,\n\t\t\t\toptions,\n\t\t\t);\n\t\t\tawait this.confirmScopedAuthFailures(session, result?.metadata);\n\t\t\tthis.resetRequestExceptionCount('searchMyIssues', connectionId);\n\t\t\treturn { value: result };\n\t\t} catch (ex) {\n\t\t\tthis.handleProviderException('searchMyIssues', ex, { scope: scope, connectionId: connectionId });\n\t\t\treturn { error: toError(ex) };\n\t\t}\n\t}\n\n\t@trace()\n\tasync getLinkedIssueOrPullRequest(\n\t\tresource: T,\n\t\tlink: { id: string; key: string },\n\t\toptions?: { expiryOverride?: boolean | number; type?: IssueOrPullRequestType; throwOnError?: boolean },\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif ((await this.prepareSessionLookup()) != null) return undefined;\n\n\t\tconst session = this._session;\n\t\tif (session == null) return undefined;\n\n\t\tconst { throwOnError, ...cacheOptions } = options ?? {};\n\n\t\tconst issueOrPR = this.ctx.cache.getIssueOrPullRequest(\n\t\t\tlink.key,\n\t\t\toptions?.type,\n\t\t\tresource,\n\t\t\tthis.getPullRequestCacheDescriptor(session),\n\t\t\tcacheable => ({\n\t\t\t\tvalue: (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.getProviderLinkedIssueOrPullRequest(\n\t\t\t\t\t\t\tsession,\n\t\t\t\t\t\t\tresource,\n\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\toptions?.type,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.resetRequestExceptionCount('getIssueOrPullRequest');\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\tthis.handleProviderException('getIssueOrPullRequest', ex, { scope: scope });\n\t\t\t\t\t\tif (throwOnError) throw ex;\n\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t})(),\n\t\t\t}),\n\t\t\tcacheOptions,\n\t\t);\n\t\treturn issueOrPR;\n\t}\n\n\tprotected abstract getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: T,\n\t\tlink: { id: string; key: string },\n\t\ttype: undefined | IssueOrPullRequestType,\n\t): Promise<IssueOrPullRequest | undefined>;\n\n\tasync getIssue(\n\t\tresource: T,\n\t\tid: string,\n\t\toptions?: { connectionId?: string; expiryOverride?: boolean | number },\n\t): Promise<Issue | undefined> {\n\t\treturn (await this.getIssueResult(resource, id, options))?.value;\n\t}\n\n\tgetIssueResult(\n\t\tresource: T,\n\t\tid: string,\n\t\toptions?: { connectionId?: string; expiryOverride?: boolean | number },\n\t): Promise<IntegrationResult<Issue | undefined>> {\n\t\treturn this.getIssueResultCore(resource, id, options, session => this.getProviderIssue(session, resource, id));\n\t}\n\n\t@trace()\n\tprotected async getIssueResultCore(\n\t\tresource: ResourceDescriptor,\n\t\tid: string,\n\t\toptions: { connectionId?: string; expiryOverride?: boolean | number } | undefined,\n\t\tgetProviderIssue: (session: ProviderAuthenticationSession) => Promise<Issue | undefined>,\n\t): Promise<IntegrationResult<Issue | undefined>> {\n\t\tconst scope = getScopedLogger();\n\t\tconst { connectionId: requestedConnectionId, expiryOverride } = options ?? {};\n\t\tconst connectionId = requestedConnectionId || undefined;\n\t\tconst session = await this.resolveReadSession(connectionId, scope);\n\t\tif (session == null || isReadSessionFailure(session)) return session && { error: session.error };\n\n\t\ttry {\n\t\t\tconst issue = await getCachedIssue({\n\t\t\t\tcache: this.ctx.cache,\n\t\t\t\tid: id,\n\t\t\t\tresource: resource,\n\t\t\t\tintegration: this,\n\t\t\t\tload: async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst issue = await getProviderIssue(session);\n\t\t\t\t\t\tthis.resetRequestExceptionCount('getIssue', connectionId);\n\t\t\t\t\t\treturn issue;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tif (!isCancellationError(ex)) {\n\t\t\t\t\t\t\tthis.handleProviderException('getIssue', toError(ex), {\n\t\t\t\t\t\t\t\tscope: scope,\n\t\t\t\t\t\t\t\tconnectionId: connectionId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow ex;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcacheOptions: {\n\t\t\t\t\tconnectionId: connectionId,\n\t\t\t\t\texpiryOverride: expiryOverride,\n\t\t\t\t\tetag: `${this.id}:${this.maybeConnected ?? false}:${this.getSessionFingerprint(session)}`,\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn { value: issue };\n\t\t} catch (ex) {\n\t\t\treturn { error: toError(ex) };\n\t\t}\n\t}\n\n\tprotected abstract getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: T,\n\t\tid: string,\n\t): Promise<Issue | undefined>;\n\n\tasync getCurrentAccount(options?: {\n\t\tavatarSize?: number;\n\t\tconnectionId?: string;\n\t\texpiryOverride?: boolean | number;\n\t}): Promise<Account | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst { connectionId: requestedConnectionId, expiryOverride, ...opts } = options ?? {};\n\t\tconst connectionId = requestedConnectionId || undefined;\n\t\tconst session = await this.resolveReadSessionOrThrow(connectionId, scope);\n\t\tif (session == null) return undefined;\n\n\t\tconst sessionFingerprint = this.getSessionFingerprint(session);\n\n\t\tconst currentAccount = await this.ctx.cache.getCurrentAccount(\n\t\t\tthis,\n\n\t\t\t(cacheable: any) => ({\n\t\t\t\tvalue: (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst account = await this.getProviderCurrentAccount?.(session, opts);\n\t\t\t\t\t\tthis.resetRequestExceptionCount('getCurrentAccount', connectionId);\n\t\t\t\t\t\treturn account;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tif (isCancellationError(ex) && !isProviderUnreachableError(ex)) {\n\t\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.handleProviderException('getCurrentAccount', ex, {\n\t\t\t\t\t\t\tscope: scope,\n\t\t\t\t\t\t\tconnectionId: connectionId,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// Invalidate the cache on error, except for auth errors\n\t\t\t\t\t\tif (!(ex instanceof AuthenticationError)) {\n\t\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Re-throw to the caller\n\t\t\t\t\t\tthrow ex;\n\t\t\t\t\t}\n\t\t\t\t})(),\n\t\t\t}),\n\t\t\t{\n\t\t\t\tconnectionId: connectionId,\n\t\t\t\texpiryOverride: expiryOverride,\n\t\t\t\texpireOnError: false,\n\t\t\t\tetag: `${this.id}:${this.maybeConnected ?? false}:${sessionFingerprint}`,\n\t\t\t},\n\t\t);\n\t\treturn currentAccount;\n\t}\n\n\tprotected getProviderCurrentAccount?(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { avatarSize?: number },\n\t): Promise<Account | undefined>;\n\n\t/** Whether this integration can answer {@link getCurrentAccount}. */\n\tget supportsCurrentAccount(): boolean {\n\t\treturn this.getProviderCurrentAccount != null;\n\t}\n\n\t/**\n\t * Resolves the account for a specific session/token — including connections other than the current\n\t * primary (multi-account) — using this integration's provider API base URL and auth type. Returns\n\t * undefined when the provider doesn't support account lookup. Uncached (callers cache per connection).\n\t */\n\tgetProviderAccountForSession(session: ProviderAuthenticationSession): Promise<Account | undefined> {\n\t\treturn this.getProviderCurrentAccount?.(session) ?? Promise.resolve(undefined);\n\t}\n\n\t/**\n\t * Resolves the workspace a specific session's token was granted for, separate from the person, asking the\n\t * provider every time so a renamed workspace is picked up. Undefined when the provider has no such workspace.\n\t */\n\tgetProviderResourceForSession(_session: ProviderAuthenticationSession): Promise<ConnectionResource | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\t@trace()\n\tasync getPullRequest(\n\t\tresource: T,\n\t\tid: string,\n\t\toptions?: { expiryOverride?: boolean | number; throwOnError?: boolean },\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst refreshFailure = await this.prepareSessionLookup();\n\t\tif (refreshFailure === 'unconnected') return undefined;\n\t\tif (refreshFailure != null) {\n\t\t\tif (options?.throwOnError) throw refreshFailure;\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst session = this._session;\n\t\tif (session == null) return undefined;\n\n\t\tconst pr = await this.ctx.cache.getPullRequest(\n\t\t\tid,\n\t\t\tresource,\n\t\t\tthis.getPullRequestCacheDescriptor(session),\n\t\t\tcacheable => ({\n\t\t\t\tvalue: (async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await this.getProviderPullRequest?.(session, resource, id);\n\t\t\t\t\t\tthis.resetRequestExceptionCount('getPullRequest');\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\t\tthis.handleProviderException('getPullRequest', ex, { scope: scope });\n\t\t\t\t\t\tif (options?.throwOnError) throw ex;\n\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t})(),\n\t\t\t}),\n\t\t\t{ expiryOverride: options?.expiryOverride },\n\t\t);\n\t\treturn pr;\n\t}\n\n\tprotected getProviderPullRequest?(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: T,\n\t\tid: string,\n\t): Promise<PullRequest | undefined>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,IAAa,qBAAb,MAAgC;CACV;CAArB,YAAY,OAAuB;EAAd,KAAA,QAAA;CAAe;AACrC;AAEA,SAAgB,qBACf,SACgC;CAChC,OAAO,mBAAmB;AAC3B;AAWA,SAAS,sBAAsB,QAAyC;CACvE,IAAI,gBAAgB,QAAQ,OAAO,KAAA;CAEnC,OAAO;EAAC,OAAO;EAAO,OAAO,WAAW;EAAI,OAAO;CAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,YAAY;AAChF;AAEA,SAAS,oBAAoB,QAAgD;CAC5E,OAAO,kBAAkB,uBAAuB,OAAO,WAAA;AACxD;AAEA,SAAS,0BACR,OACwE;CACxE,OAAO,MAAM,MACX,SACA,KAAK,WAAW,cAAc,KAAK,WAAW,QAAQ,oBAAoB,KAAK,MAAM,CACvF;AACD;;;;;;;;AASA,SAAS,iBAAiB,YAA4B,QAAsC;CAC3F,IAAI,gBAAgB,QAAQ,OAAO;EAAc;EAAY,YAAY,OAAO;CAAW;CAC3F,IAAI,kBAAkB,UAAU,GAC/B,OAAO;EAAc;EAAY,YAA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A,IAAA;AAoIN,WAAA,CAAA,MAAM,CAAA,GAAA,gBAAA,WAAA,kBAAA,IAAA"}
@@ -1,7 +1,11 @@
1
- import { IssuesCloudHostIntegrationId } from "../constants.js";
1
+ import { IssuesCloudHostIntegrationId, IssuesSelfManagedHostIntegrationId } from "../constants.js";
2
2
  //#region ../plus/integrations/src/models/issueTrackerWrites.d.ts
3
- export type IssueTrackerWriteConnection = {
3
+ export type IssueTrackerWriteConnection = ({
4
4
  providerId: IssuesCloudHostIntegrationId.Jira;
5
+ } | {
6
+ providerId: IssuesSelfManagedHostIntegrationId.JiraServer;
7
+ siteUrl: string;
8
+ }) & {
5
9
  connectionId: string;
6
10
  resourceId: string;
7
11
  expectedAccountId?: string;
@@ -12,7 +16,12 @@ type IssueTrackerIssueAddress = IssueTrackerWriteConnection & {
12
16
  };
13
17
  type IssueTrackerExistingIssue = IssueTrackerIssueAddress & {
14
18
  expectedIssueId: string;
15
- };
19
+ } & ({
20
+ providerId: IssuesCloudHostIntegrationId.Jira;
21
+ } | {
22
+ providerId: IssuesSelfManagedHostIntegrationId.JiraServer;
23
+ expectedProjectId: string;
24
+ });
16
25
  type IssueTrackerEditableFields = {
17
26
  description?: string;
18
27
  fields?: Readonly<Record<string, unknown>>;
@@ -10,6 +10,7 @@ import { RepositoryMetadata } from "../../../git/models/repositoryMetadata.js";
10
10
  import { PullRequestUrlIdentity } from "../../../git/utils/pullRequest.utils.js";
11
11
  import { GitCloudHostIntegrationId, IntegrationIds, IssuesCloudHostIntegrationId, IssuesHostIntegrationIds } from "../constants.js";
12
12
  import { Sources } from "../telemetry.js";
13
+ import "../providerFilters.js";
13
14
  import { ProviderRepositoryShape } from "../results.js";
14
15
  import { ProviderRepositoriesInput } from "../manager.js";
15
16
  //#region ../plus/integrations/src/models/publicIntegration.d.ts
@@ -7,9 +7,9 @@ import { trace } from "../../../../utils/decorators/log.js";
7
7
  import { PromiseCache } from "../../../../utils/promiseCache.js";
8
8
  import __decorate from "../../../../_virtual/@oxc-project+runtime/helpers/esm/decorate.js";
9
9
  import { AuthenticationError, RequestClientError, RequestNotFoundError, RequestRateLimitError, getDeferredRequestFailure, reportRequestFailure } from "../../../../git/errors.js";
10
- import { sha256, uuid } from "../../../../utils/crypto.js";
11
10
  import { maybeStopWatch } from "../../../../utils/stopwatch.js";
12
11
  import { base64 } from "../../../../utils/base64.js";
12
+ import { sha256, uuid } from "../../../../utils/crypto.js";
13
13
  import { effectiveIssueSort } from "../../../../git/utils/issue.utils.js";
14
14
  import { ProviderFetchError, isRateLimitResponse, toRateLimitError } from "../../errors.js";
15
15
  import { CommitReadRefusedError, isCommitReadRefusal, isNotFoundResponse, throwProviderError } from "../providerErrors.js";
@@ -266,6 +266,7 @@ export interface AzurePullRequest {
266
266
  isDraft: boolean;
267
267
  mergeId: string;
268
268
  mergeStatus?: AzurePullRequestAsyncStatus;
269
+ mergeFailureMessage?: string;
269
270
  lastMergeCommit?: AzureGitCommitRef;
270
271
  lastMergeSourceCommit: AzureGitCommitRef;
271
272
  lastMergeTargetCommit: AzureGitCommitRef;
@@ -293,7 +294,6 @@ export interface AzurePullRequestWithLinks extends AzurePullRequest {
293
294
  completionQueueTime?: string;
294
295
  hasMultipleMergeBases?: boolean;
295
296
  labels?: AzureWebApiTagDefinition[];
296
- mergeFailureMessage?: string;
297
297
  mergeFailureType?: 'caseSensitive' | 'none' | 'objectTooLarge' | 'unknown';
298
298
  mergeOptions?: AzureGitPullRequestMergeOptions;
299
299
  remoteUrl?: string;